@dodoex/wallet-web3 0.5.2 → 0.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{alchemy-provider-5870b6fa-1d4efe84.js → alchemy-provider-5870b6fa-1cd0b182.js} +1 -1
- package/dist/{alchemy-websocket-provider-213da986-d5cf3f6a.js → alchemy-websocket-provider-213da986-a1e43b83.js} +1 -1
- package/dist/{blocto-25c5c258.js → blocto-203f9ec1.js} +1 -1
- package/dist/{ccip-3ac23092.js → ccip-f118a914.js} +1 -1
- package/dist/cjs/{alchemy-provider-5870b6fa-5cbe3e31.cjs → alchemy-provider-5870b6fa-8031f5e9.cjs} +1 -1
- package/dist/cjs/{alchemy-websocket-provider-213da986-7065cb3f.cjs → alchemy-websocket-provider-213da986-ffd85fbf.cjs} +1 -1
- package/dist/cjs/{blocto-0c1d92db.cjs → blocto-fd5fce1b.cjs} +1 -1
- package/dist/cjs/{ccip-fb501af5.cjs → ccip-5821aa76.cjs} +1 -1
- package/dist/cjs/{draggabilly-1a578eed.cjs → draggabilly-534a06c4.cjs} +1 -1
- package/dist/cjs/id-20f6ce8c.cjs +1 -0
- package/dist/cjs/{index-b13bd062.cjs → index-11beefa2.cjs} +1 -1
- package/dist/cjs/{index-75b128c0.cjs → index-1cafa7ef.cjs} +1 -1
- package/dist/cjs/{index-803e4f67.cjs → index-2914fc1b.cjs} +1 -1
- package/dist/cjs/{index-a4906ebd.cjs → index-3c2f7ecb.cjs} +2 -2
- package/dist/cjs/{index-e103a51b.cjs → index-3e679370.cjs} +4 -4
- package/dist/cjs/{index-9e59c9f8.cjs → index-7d28ccd9.cjs} +1 -1
- package/dist/cjs/{index-49dfe63f.cjs → index-83d6612a.cjs} +1 -1
- package/dist/cjs/{index-64ab7e4d.cjs → index-8810c52e.cjs} +1 -1
- package/dist/cjs/{index-d78c1ab4.cjs → index-da0f0dc4.cjs} +1 -1
- package/dist/cjs/{index-1a823dfc.cjs → index-fe6d443a.cjs} +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/{index.es-cfbd4f15.cjs → index.es-1000eb22.cjs} +1 -1
- package/dist/cjs/{interface-ef9016d3.cjs → interface-d2286c23.cjs} +1 -1
- package/dist/cjs/{lib-typedarrays-22e0cfee.cjs → lib-typedarrays-f0840aa6.cjs} +1 -1
- package/dist/cjs/{portis-265f03df.cjs → portis-166a6955.cjs} +1 -1
- package/dist/cjs/{rainbow-48ed900d.cjs → rainbow-9e206ee7.cjs} +1 -1
- package/dist/cjs/{sha224-ba7123a0.cjs → sha224-bc65dfff.cjs} +1 -1
- package/dist/cjs/{sha256-00be81ad.cjs → sha256-0636f669.cjs} +1 -1
- package/dist/cjs/{typed-data-f167a2be.cjs → typed-data-8eaefdb5.cjs} +1 -1
- package/dist/cjs/{uAuth-c82eed54.cjs → uAuth-081ad6fc.cjs} +1 -1
- package/dist/cjs/{walletConnect-68f635da.cjs → walletConnect-073ff8dd.cjs} +1 -1
- package/dist/cjs/{walletLink-77a9287f.cjs → walletLink-101917c2.cjs} +1 -1
- package/dist/{draggabilly-ed1ea22f.js → draggabilly-5d335a04.js} +1 -1
- package/dist/id-b1749683.js +1 -0
- package/dist/{index-61916df2.js → index-0bf8d237.js} +1 -1
- package/dist/{index-fe388941.js → index-1ecaf2fe.js} +1 -1
- package/dist/{index-7152dee7.js → index-327eea25.js} +1 -1
- package/dist/{index-ff33ebed.js → index-540337a5.js} +1 -1
- package/dist/{index-76297fe2.js → index-5732342d.js} +2 -2
- package/dist/{index-bf37e2d0.js → index-8ed7d553.js} +1 -1
- package/dist/{index-fc1b4c33.js → index-b5f5db3c.js} +6 -6
- package/dist/{index-113ad8f8.js → index-b8d0e86d.js} +1 -1
- package/dist/{index-91b1499d.js → index-bfa2119a.js} +1 -1
- package/dist/{index-9a6126a2.js → index-d59ad34c.js} +1 -1
- package/dist/{index.es-166481e0.js → index.es-5e0a68ed.js} +1 -1
- package/dist/index.js +1 -1
- package/dist/{interface-8965a045.js → interface-3f9d4a5c.js} +1 -1
- package/dist/{lib-typedarrays-c5e5759f.js → lib-typedarrays-53c6b915.js} +1 -1
- package/dist/{portis-174647af.js → portis-9bab3be5.js} +1 -1
- package/dist/{rainbow-04d94d50.js → rainbow-5e0452af.js} +1 -1
- package/dist/sha224-204aec1e.js +1 -0
- package/dist/{sha256-b7dd8a5a.js → sha256-940f00e6.js} +1 -1
- package/dist/{typed-data-d3d4124b.js → typed-data-af5b29c1.js} +1 -1
- package/dist/{uAuth-ed5c6c9d.js → uAuth-4d80b0ec.js} +1 -1
- package/dist/{walletConnect-cd58a591.js → walletConnect-ae596280.js} +1 -1
- package/dist/{walletLink-874673f7.js → walletLink-0dd5c1e9.js} +1 -1
- package/package.json +2 -2
- package/dist/cjs/id-833d54a1.cjs +0 -1
- package/dist/id-3ec4567b.js +0 -1
- package/dist/sha224-76431e37.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var e=require("events"),t=require("./_commonjs-dynamic-modules-f09a98c7.cjs"),r=require("./index-e103a51b.cjs");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("@ethersproject/providers"),require("zustand"),require("@ethersproject/bytes"),require("@ethersproject/properties"),require("@ethersproject/address"),require("@ethersproject/abstract-signer"),require("buffer"),require("@ethersproject/abstract-provider"),require("@ethersproject/contracts"),require("@ethersproject/constants"),require("@ethersproject/transactions");var i=n(e),s={},o={},a={},c={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.mul=Math.imul||function(e,t){var r=65535&e,n=65535&t;return r*n+((e>>>16&65535)*n+r*(t>>>16&65535)<<16>>>0)|0},e.add=function(e,t){return e+t|0},e.sub=function(e,t){return e-t|0},e.rotl=function(e,t){return e<<t|e>>>32-t},e.rotr=function(e,t){return e<<32-t|e>>>t},e.isInteger=Number.isInteger||function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e},e.MAX_SAFE_INTEGER=9007199254740991,e.isSafeInteger=function(t){return e.isInteger(t)&&t>=-e.MAX_SAFE_INTEGER&&t<=e.MAX_SAFE_INTEGER}}(c),Object.defineProperty(a,"__esModule",{value:!0});var u=c;function h(e,t,r){return void 0===t&&(t=new Uint8Array(2)),void 0===r&&(r=0),t[r+0]=e>>>8,t[r+1]=e>>>0,t}function l(e,t,r){return void 0===t&&(t=new Uint8Array(2)),void 0===r&&(r=0),t[r+0]=e>>>0,t[r+1]=e>>>8,t}function f(e,t){return void 0===t&&(t=0),e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function p(e,t){return void 0===t&&(t=0),(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}function d(e,t){return void 0===t&&(t=0),e[t+3]<<24|e[t+2]<<16|e[t+1]<<8|e[t]}function g(e,t){return void 0===t&&(t=0),(e[t+3]<<24|e[t+2]<<16|e[t+1]<<8|e[t])>>>0}function y(e,t,r){return void 0===t&&(t=new Uint8Array(4)),void 0===r&&(r=0),t[r+0]=e>>>24,t[r+1]=e>>>16,t[r+2]=e>>>8,t[r+3]=e>>>0,t}function v(e,t,r){return void 0===t&&(t=new Uint8Array(4)),void 0===r&&(r=0),t[r+0]=e>>>0,t[r+1]=e>>>8,t[r+2]=e>>>16,t[r+3]=e>>>24,t}function _(e,t,r){return void 0===t&&(t=new Uint8Array(8)),void 0===r&&(r=0),y(e/4294967296>>>0,t,r),y(e>>>0,t,r+4),t}function m(e,t,r){return void 0===t&&(t=new Uint8Array(8)),void 0===r&&(r=0),v(e>>>0,t,r),v(e/4294967296>>>0,t,r+4),t}a.readInt16BE=function(e,t){return void 0===t&&(t=0),(e[t+0]<<8|e[t+1])<<16>>16},a.readUint16BE=function(e,t){return void 0===t&&(t=0),(e[t+0]<<8|e[t+1])>>>0},a.readInt16LE=function(e,t){return void 0===t&&(t=0),(e[t+1]<<8|e[t])<<16>>16},a.readUint16LE=function(e,t){return void 0===t&&(t=0),(e[t+1]<<8|e[t])>>>0},a.writeUint16BE=h,a.writeInt16BE=h,a.writeUint16LE=l,a.writeInt16LE=l,a.readInt32BE=f,a.readUint32BE=p,a.readInt32LE=d,a.readUint32LE=g,a.writeUint32BE=y,a.writeInt32BE=y,a.writeUint32LE=v,a.writeInt32LE=v,a.readInt64BE=function(e,t){void 0===t&&(t=0);var r=f(e,t),n=f(e,t+4);return 4294967296*r+n-4294967296*(n>>31)},a.readUint64BE=function(e,t){return void 0===t&&(t=0),4294967296*p(e,t)+p(e,t+4)},a.readInt64LE=function(e,t){void 0===t&&(t=0);var r=d(e,t);return 4294967296*d(e,t+4)+r-4294967296*(r>>31)},a.readUint64LE=function(e,t){void 0===t&&(t=0);var r=g(e,t);return 4294967296*g(e,t+4)+r},a.writeUint64BE=_,a.writeInt64BE=_,a.writeUint64LE=m,a.writeInt64LE=m,a.readUintBE=function(e,t,r){if(void 0===r&&(r=0),e%8!=0)throw new Error("readUintBE supports only bitLengths divisible by 8");if(e/8>t.length-r)throw new Error("readUintBE: array is too short for the given bitLength");for(var n=0,i=1,s=e/8+r-1;s>=r;s--)n+=t[s]*i,i*=256;return n},a.readUintLE=function(e,t,r){if(void 0===r&&(r=0),e%8!=0)throw new Error("readUintLE supports only bitLengths divisible by 8");if(e/8>t.length-r)throw new Error("readUintLE: array is too short for the given bitLength");for(var n=0,i=1,s=r;s<r+e/8;s++)n+=t[s]*i,i*=256;return n},a.writeUintBE=function(e,t,r,n){if(void 0===r&&(r=new Uint8Array(e/8)),void 0===n&&(n=0),e%8!=0)throw new Error("writeUintBE supports only bitLengths divisible by 8");if(!u.isSafeInteger(t))throw new Error("writeUintBE value must be an integer");for(var i=1,s=e/8+n-1;s>=n;s--)r[s]=t/i&255,i*=256;return r},a.writeUintLE=function(e,t,r,n){if(void 0===r&&(r=new Uint8Array(e/8)),void 0===n&&(n=0),e%8!=0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!u.isSafeInteger(t))throw new Error("writeUintLE value must be an integer");for(var i=1,s=n;s<n+e/8;s++)r[s]=t/i&255,i*=256;return r},a.readFloat32BE=function(e,t){return void 0===t&&(t=0),new DataView(e.buffer,e.byteOffset,e.byteLength).getFloat32(t)},a.readFloat32LE=function(e,t){return void 0===t&&(t=0),new DataView(e.buffer,e.byteOffset,e.byteLength).getFloat32(t,!0)},a.readFloat64BE=function(e,t){return void 0===t&&(t=0),new DataView(e.buffer,e.byteOffset,e.byteLength).getFloat64(t)},a.readFloat64LE=function(e,t){return void 0===t&&(t=0),new DataView(e.buffer,e.byteOffset,e.byteLength).getFloat64(t,!0)},a.writeFloat32BE=function(e,t,r){return void 0===t&&(t=new Uint8Array(4)),void 0===r&&(r=0),new DataView(t.buffer,t.byteOffset,t.byteLength).setFloat32(r,e),t},a.writeFloat32LE=function(e,t,r){return void 0===t&&(t=new Uint8Array(4)),void 0===r&&(r=0),new DataView(t.buffer,t.byteOffset,t.byteLength).setFloat32(r,e,!0),t},a.writeFloat64BE=function(e,t,r){return void 0===t&&(t=new Uint8Array(8)),void 0===r&&(r=0),new DataView(t.buffer,t.byteOffset,t.byteLength).setFloat64(r,e),t},a.writeFloat64LE=function(e,t,r){return void 0===t&&(t=new Uint8Array(8)),void 0===r&&(r=0),new DataView(t.buffer,t.byteOffset,t.byteLength).setFloat64(r,e,!0),t};var w={};Object.defineProperty(w,"__esModule",{value:!0}),w.wipe=function(e){for(var t=0;t<e.length;t++)e[t]=0;return e},Object.defineProperty(o,"__esModule",{value:!0});var b=a,E=w,S=20;function I(e,t,r){for(var n=1634760805,i=857760878,s=2036477234,o=1797285236,a=r[3]<<24|r[2]<<16|r[1]<<8|r[0],c=r[7]<<24|r[6]<<16|r[5]<<8|r[4],u=r[11]<<24|r[10]<<16|r[9]<<8|r[8],h=r[15]<<24|r[14]<<16|r[13]<<8|r[12],l=r[19]<<24|r[18]<<16|r[17]<<8|r[16],f=r[23]<<24|r[22]<<16|r[21]<<8|r[20],p=r[27]<<24|r[26]<<16|r[25]<<8|r[24],d=r[31]<<24|r[30]<<16|r[29]<<8|r[28],g=t[3]<<24|t[2]<<16|t[1]<<8|t[0],y=t[7]<<24|t[6]<<16|t[5]<<8|t[4],v=t[11]<<24|t[10]<<16|t[9]<<8|t[8],_=t[15]<<24|t[14]<<16|t[13]<<8|t[12],m=n,w=i,E=s,I=o,O=a,P=c,N=u,A=h,x=l,C=f,T=p,R=d,j=g,L=y,U=v,M=_,D=0;D<S;D+=2)O=(O^=x=x+(j=(j^=m=m+O|0)>>>16|j<<16)|0)>>>20|O<<12,P=(P^=C=C+(L=(L^=w=w+P|0)>>>16|L<<16)|0)>>>20|P<<12,N=(N^=T=T+(U=(U^=E=E+N|0)>>>16|U<<16)|0)>>>20|N<<12,A=(A^=R=R+(M=(M^=I=I+A|0)>>>16|M<<16)|0)>>>20|A<<12,N=(N^=T=T+(U=(U^=E=E+N|0)>>>24|U<<8)|0)>>>25|N<<7,A=(A^=R=R+(M=(M^=I=I+A|0)>>>24|M<<8)|0)>>>25|A<<7,P=(P^=C=C+(L=(L^=w=w+P|0)>>>24|L<<8)|0)>>>25|P<<7,O=(O^=x=x+(j=(j^=m=m+O|0)>>>24|j<<8)|0)>>>25|O<<7,P=(P^=T=T+(M=(M^=m=m+P|0)>>>16|M<<16)|0)>>>20|P<<12,N=(N^=R=R+(j=(j^=w=w+N|0)>>>16|j<<16)|0)>>>20|N<<12,A=(A^=x=x+(L=(L^=E=E+A|0)>>>16|L<<16)|0)>>>20|A<<12,O=(O^=C=C+(U=(U^=I=I+O|0)>>>16|U<<16)|0)>>>20|O<<12,A=(A^=x=x+(L=(L^=E=E+A|0)>>>24|L<<8)|0)>>>25|A<<7,O=(O^=C=C+(U=(U^=I=I+O|0)>>>24|U<<8)|0)>>>25|O<<7,N=(N^=R=R+(j=(j^=w=w+N|0)>>>24|j<<8)|0)>>>25|N<<7,P=(P^=T=T+(M=(M^=m=m+P|0)>>>24|M<<8)|0)>>>25|P<<7;b.writeUint32LE(m+n|0,e,0),b.writeUint32LE(w+i|0,e,4),b.writeUint32LE(E+s|0,e,8),b.writeUint32LE(I+o|0,e,12),b.writeUint32LE(O+a|0,e,16),b.writeUint32LE(P+c|0,e,20),b.writeUint32LE(N+u|0,e,24),b.writeUint32LE(A+h|0,e,28),b.writeUint32LE(x+l|0,e,32),b.writeUint32LE(C+f|0,e,36),b.writeUint32LE(T+p|0,e,40),b.writeUint32LE(R+d|0,e,44),b.writeUint32LE(j+g|0,e,48),b.writeUint32LE(L+y|0,e,52),b.writeUint32LE(U+v|0,e,56),b.writeUint32LE(M+_|0,e,60)}function O(e,t,r,n,i){if(void 0===i&&(i=0),32!==e.length)throw new Error("ChaCha: key size must be 32 bytes");if(n.length<r.length)throw new Error("ChaCha: destination is shorter than source");var s,o;if(0===i){if(8!==t.length&&12!==t.length)throw new Error("ChaCha nonce must be 8 or 12 bytes");o=(s=new Uint8Array(16)).length-t.length,s.set(t,o)}else{if(16!==t.length)throw new Error("ChaCha nonce with counter must be 16 bytes");s=t,o=i}for(var a=new Uint8Array(64),c=0;c<r.length;c+=64){I(a,s,e);for(var u=c;u<c+64&&u<r.length;u++)n[u]=r[u]^a[u-c];P(s,0,o)}return E.wipe(a),0===i&&E.wipe(s),n}function P(e,t,r){for(var n=1;r--;)n=n+(255&e[t])|0,e[t]=255&n,n>>>=8,t++;if(n>0)throw new Error("ChaCha: counter overflow")}o.streamXOR=O,o.stream=function(e,t,r,n){return void 0===n&&(n=0),E.wipe(r),O(e,t,r,r,n)};var N={},A={};function x(e,t){if(e.length!==t.length)return 0;for(var r=0,n=0;n<e.length;n++)r|=e[n]^t[n];return 1&r-1>>>8}Object.defineProperty(A,"__esModule",{value:!0}),A.select=function(e,t,r){return~(e-1)&t|e-1&r},A.lessOrEqual=function(e,t){return(0|e)-(0|t)-1>>>31&1},A.compare=x,A.equal=function(e,t){return 0!==e.length&&0!==t.length&&0!==x(e,t)},function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=A,r=w;e.DIGEST_LENGTH=16;var n=function(){function t(t){this.digestLength=e.DIGEST_LENGTH,this._buffer=new Uint8Array(16),this._r=new Uint16Array(10),this._h=new Uint16Array(10),this._pad=new Uint16Array(8),this._leftover=0,this._fin=0,this._finished=!1;var r=t[0]|t[1]<<8;this._r[0]=8191&r;var n=t[2]|t[3]<<8;this._r[1]=8191&(r>>>13|n<<3);var i=t[4]|t[5]<<8;this._r[2]=7939&(n>>>10|i<<6);var s=t[6]|t[7]<<8;this._r[3]=8191&(i>>>7|s<<9);var o=t[8]|t[9]<<8;this._r[4]=255&(s>>>4|o<<12),this._r[5]=o>>>1&8190;var a=t[10]|t[11]<<8;this._r[6]=8191&(o>>>14|a<<2);var c=t[12]|t[13]<<8;this._r[7]=8065&(a>>>11|c<<5);var u=t[14]|t[15]<<8;this._r[8]=8191&(c>>>8|u<<8),this._r[9]=u>>>5&127,this._pad[0]=t[16]|t[17]<<8,this._pad[1]=t[18]|t[19]<<8,this._pad[2]=t[20]|t[21]<<8,this._pad[3]=t[22]|t[23]<<8,this._pad[4]=t[24]|t[25]<<8,this._pad[5]=t[26]|t[27]<<8,this._pad[6]=t[28]|t[29]<<8,this._pad[7]=t[30]|t[31]<<8}return t.prototype._blocks=function(e,t,r){for(var n=this._fin?0:2048,i=this._h[0],s=this._h[1],o=this._h[2],a=this._h[3],c=this._h[4],u=this._h[5],h=this._h[6],l=this._h[7],f=this._h[8],p=this._h[9],d=this._r[0],g=this._r[1],y=this._r[2],v=this._r[3],_=this._r[4],m=this._r[5],w=this._r[6],b=this._r[7],E=this._r[8],S=this._r[9];r>=16;){var I=e[t+0]|e[t+1]<<8;i+=8191&I;var O=e[t+2]|e[t+3]<<8;s+=8191&(I>>>13|O<<3);var P=e[t+4]|e[t+5]<<8;o+=8191&(O>>>10|P<<6);var N=e[t+6]|e[t+7]<<8;a+=8191&(P>>>7|N<<9);var A=e[t+8]|e[t+9]<<8;c+=8191&(N>>>4|A<<12),u+=A>>>1&8191;var x=e[t+10]|e[t+11]<<8;h+=8191&(A>>>14|x<<2);var C=e[t+12]|e[t+13]<<8;l+=8191&(x>>>11|C<<5);var T=e[t+14]|e[t+15]<<8,R=0,j=R;j+=i*d,j+=s*(5*S),j+=o*(5*E),j+=a*(5*b),R=(j+=c*(5*w))>>>13,j&=8191,j+=u*(5*m),j+=h*(5*_),j+=l*(5*v),j+=(f+=8191&(C>>>8|T<<8))*(5*y);var L=R+=(j+=(p+=T>>>5|n)*(5*g))>>>13;L+=i*g,L+=s*d,L+=o*(5*S),L+=a*(5*E),R=(L+=c*(5*b))>>>13,L&=8191,L+=u*(5*w),L+=h*(5*m),L+=l*(5*_),L+=f*(5*v),R+=(L+=p*(5*y))>>>13,L&=8191;var U=R;U+=i*y,U+=s*g,U+=o*d,U+=a*(5*S),R=(U+=c*(5*E))>>>13,U&=8191,U+=u*(5*b),U+=h*(5*w),U+=l*(5*m),U+=f*(5*_);var M=R+=(U+=p*(5*v))>>>13;M+=i*v,M+=s*y,M+=o*g,M+=a*d,R=(M+=c*(5*S))>>>13,M&=8191,M+=u*(5*E),M+=h*(5*b),M+=l*(5*w),M+=f*(5*m);var D=R+=(M+=p*(5*_))>>>13;D+=i*_,D+=s*v,D+=o*y,D+=a*g,R=(D+=c*d)>>>13,D&=8191,D+=u*(5*S),D+=h*(5*E),D+=l*(5*b),D+=f*(5*w);var k=R+=(D+=p*(5*m))>>>13;k+=i*m,k+=s*_,k+=o*v,k+=a*y,R=(k+=c*g)>>>13,k&=8191,k+=u*d,k+=h*(5*S),k+=l*(5*E),k+=f*(5*b);var z=R+=(k+=p*(5*w))>>>13;z+=i*w,z+=s*m,z+=o*_,z+=a*v,R=(z+=c*y)>>>13,z&=8191,z+=u*g,z+=h*d,z+=l*(5*S),z+=f*(5*E);var $=R+=(z+=p*(5*b))>>>13;$+=i*b,$+=s*w,$+=o*m,$+=a*_,R=($+=c*v)>>>13,$&=8191,$+=u*y,$+=h*g,$+=l*d,$+=f*(5*S);var q=R+=($+=p*(5*E))>>>13;q+=i*E,q+=s*b,q+=o*w,q+=a*m,R=(q+=c*_)>>>13,q&=8191,q+=u*v,q+=h*y,q+=l*g,q+=f*d;var H=R+=(q+=p*(5*S))>>>13;H+=i*S,H+=s*E,H+=o*b,H+=a*w,R=(H+=c*m)>>>13,H&=8191,H+=u*_,H+=h*v,H+=l*y,H+=f*g,i=j=8191&(R=(R=((R+=(H+=p*d)>>>13)<<2)+R|0)+(j&=8191)|0),s=L+=R>>>=13,o=U&=8191,a=M&=8191,c=D&=8191,u=k&=8191,h=z&=8191,l=$&=8191,f=q&=8191,p=H&=8191,t+=16,r-=16}this._h[0]=i,this._h[1]=s,this._h[2]=o,this._h[3]=a,this._h[4]=c,this._h[5]=u,this._h[6]=h,this._h[7]=l,this._h[8]=f,this._h[9]=p},t.prototype.finish=function(e,t){void 0===t&&(t=0);var r,n,i,s,o=new Uint16Array(10);if(this._leftover){for(s=this._leftover,this._buffer[s++]=1;s<16;s++)this._buffer[s]=0;this._fin=1,this._blocks(this._buffer,0,16)}for(r=this._h[1]>>>13,this._h[1]&=8191,s=2;s<10;s++)this._h[s]+=r,r=this._h[s]>>>13,this._h[s]&=8191;for(this._h[0]+=5*r,r=this._h[0]>>>13,this._h[0]&=8191,this._h[1]+=r,r=this._h[1]>>>13,this._h[1]&=8191,this._h[2]+=r,o[0]=this._h[0]+5,r=o[0]>>>13,o[0]&=8191,s=1;s<10;s++)o[s]=this._h[s]+r,r=o[s]>>>13,o[s]&=8191;for(o[9]-=8192,n=(1^r)-1,s=0;s<10;s++)o[s]&=n;for(n=~n,s=0;s<10;s++)this._h[s]=this._h[s]&n|o[s];for(this._h[0]=65535&(this._h[0]|this._h[1]<<13),this._h[1]=65535&(this._h[1]>>>3|this._h[2]<<10),this._h[2]=65535&(this._h[2]>>>6|this._h[3]<<7),this._h[3]=65535&(this._h[3]>>>9|this._h[4]<<4),this._h[4]=65535&(this._h[4]>>>12|this._h[5]<<1|this._h[6]<<14),this._h[5]=65535&(this._h[6]>>>2|this._h[7]<<11),this._h[6]=65535&(this._h[7]>>>5|this._h[8]<<8),this._h[7]=65535&(this._h[8]>>>8|this._h[9]<<5),i=this._h[0]+this._pad[0],this._h[0]=65535&i,s=1;s<8;s++)i=(this._h[s]+this._pad[s]|0)+(i>>>16)|0,this._h[s]=65535&i;return e[t+0]=this._h[0]>>>0,e[t+1]=this._h[0]>>>8,e[t+2]=this._h[1]>>>0,e[t+3]=this._h[1]>>>8,e[t+4]=this._h[2]>>>0,e[t+5]=this._h[2]>>>8,e[t+6]=this._h[3]>>>0,e[t+7]=this._h[3]>>>8,e[t+8]=this._h[4]>>>0,e[t+9]=this._h[4]>>>8,e[t+10]=this._h[5]>>>0,e[t+11]=this._h[5]>>>8,e[t+12]=this._h[6]>>>0,e[t+13]=this._h[6]>>>8,e[t+14]=this._h[7]>>>0,e[t+15]=this._h[7]>>>8,this._finished=!0,this},t.prototype.update=function(e){var t,r=0,n=e.length;if(this._leftover){(t=16-this._leftover)>n&&(t=n);for(var i=0;i<t;i++)this._buffer[this._leftover+i]=e[r+i];if(n-=t,r+=t,this._leftover+=t,this._leftover<16)return this;this._blocks(this._buffer,0,16),this._leftover=0}if(n>=16&&(t=n-n%16,this._blocks(e,r,t),r+=t,n-=t),n){for(i=0;i<n;i++)this._buffer[this._leftover+i]=e[r+i];this._leftover+=n}return this},t.prototype.digest=function(){if(this._finished)throw new Error("Poly1305 was finished");var e=new Uint8Array(16);return this.finish(e),e},t.prototype.clean=function(){return r.wipe(this._buffer),r.wipe(this._r),r.wipe(this._h),r.wipe(this._pad),this._leftover=0,this._fin=0,this._finished=!0,this},t}();e.Poly1305=n,e.oneTimeAuth=function(e,t){var r=new n(e);r.update(t);var i=r.digest();return r.clean(),i},e.equal=function(r,n){return r.length===e.DIGEST_LENGTH&&n.length===e.DIGEST_LENGTH&&t.equal(r,n)}}(N),function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=o,r=N,n=w,i=a,s=A;e.KEY_LENGTH=32,e.NONCE_LENGTH=12,e.TAG_LENGTH=16;var c=new Uint8Array(16),u=function(){function o(t){if(this.nonceLength=e.NONCE_LENGTH,this.tagLength=e.TAG_LENGTH,t.length!==e.KEY_LENGTH)throw new Error("ChaCha20Poly1305 needs 32-byte key");this._key=new Uint8Array(t)}return o.prototype.seal=function(e,r,i,s){if(e.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");var o=new Uint8Array(16);o.set(e,o.length-e.length);var a=new Uint8Array(32);t.stream(this._key,o,a,4);var c,u=r.length+this.tagLength;if(s){if(s.length!==u)throw new Error("ChaCha20Poly1305: incorrect destination length");c=s}else c=new Uint8Array(u);return t.streamXOR(this._key,o,r,c,4),this._authenticate(c.subarray(c.length-this.tagLength,c.length),a,c.subarray(0,c.length-this.tagLength),i),n.wipe(o),c},o.prototype.open=function(e,r,i,o){if(e.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");if(r.length<this.tagLength)return null;var a=new Uint8Array(16);a.set(e,a.length-e.length);var c=new Uint8Array(32);t.stream(this._key,a,c,4);var u=new Uint8Array(this.tagLength);if(this._authenticate(u,c,r.subarray(0,r.length-this.tagLength),i),!s.equal(u,r.subarray(r.length-this.tagLength,r.length)))return null;var h,l=r.length-this.tagLength;if(o){if(o.length!==l)throw new Error("ChaCha20Poly1305: incorrect destination length");h=o}else h=new Uint8Array(l);return t.streamXOR(this._key,a,r.subarray(0,r.length-this.tagLength),h,4),n.wipe(a),h},o.prototype.clean=function(){return n.wipe(this._key),this},o.prototype._authenticate=function(e,t,s,o){var a=new r.Poly1305(t);o&&(a.update(o),o.length%16>0&&a.update(c.subarray(o.length%16))),a.update(s),s.length%16>0&&a.update(c.subarray(s.length%16));var u=new Uint8Array(8);o&&i.writeUint64LE(o.length,u),a.update(u),i.writeUint64LE(s.length,u),a.update(u);for(var h=a.digest(),l=0;l<h.length;l++)e[l]=h[l];a.clean(),n.wipe(h),n.wipe(u)},o}();e.ChaCha20Poly1305=u}(s);var C={},T={},R={};Object.defineProperty(R,"__esModule",{value:!0}),R.isSerializableHash=function(e){return void 0!==e.saveState&&void 0!==e.restoreState&&void 0!==e.cleanSavedState},Object.defineProperty(T,"__esModule",{value:!0});var j=R,L=A,U=w,M=function(){function e(e,t){this._finished=!1,this._inner=new e,this._outer=new e,this.blockSize=this._outer.blockSize,this.digestLength=this._outer.digestLength;var r=new Uint8Array(this.blockSize);t.length>this.blockSize?this._inner.update(t).finish(r).clean():r.set(t);for(var n=0;n<r.length;n++)r[n]^=54;this._inner.update(r);for(n=0;n<r.length;n++)r[n]^=106;this._outer.update(r),j.isSerializableHash(this._inner)&&j.isSerializableHash(this._outer)&&(this._innerKeyedState=this._inner.saveState(),this._outerKeyedState=this._outer.saveState()),U.wipe(r)}return e.prototype.reset=function(){if(!j.isSerializableHash(this._inner)||!j.isSerializableHash(this._outer))throw new Error("hmac: can't reset() because hash doesn't implement restoreState()");return this._inner.restoreState(this._innerKeyedState),this._outer.restoreState(this._outerKeyedState),this._finished=!1,this},e.prototype.clean=function(){j.isSerializableHash(this._inner)&&this._inner.cleanSavedState(this._innerKeyedState),j.isSerializableHash(this._outer)&&this._outer.cleanSavedState(this._outerKeyedState),this._inner.clean(),this._outer.clean()},e.prototype.update=function(e){return this._inner.update(e),this},e.prototype.finish=function(e){return this._finished?(this._outer.finish(e),this):(this._inner.finish(e),this._outer.update(e.subarray(0,this.digestLength)).finish(e),this._finished=!0,this)},e.prototype.digest=function(){var e=new Uint8Array(this.digestLength);return this.finish(e),e},e.prototype.saveState=function(){if(!j.isSerializableHash(this._inner))throw new Error("hmac: can't saveState() because hash doesn't implement it");return this._inner.saveState()},e.prototype.restoreState=function(e){if(!j.isSerializableHash(this._inner)||!j.isSerializableHash(this._outer))throw new Error("hmac: can't restoreState() because hash doesn't implement it");return this._inner.restoreState(e),this._outer.restoreState(this._outerKeyedState),this._finished=!1,this},e.prototype.cleanSavedState=function(e){if(!j.isSerializableHash(this._inner))throw new Error("hmac: can't cleanSavedState() because hash doesn't implement it");this._inner.cleanSavedState(e)},e}();T.HMAC=M,T.hmac=function(e,t,r){var n=new M(e,t);n.update(r);var i=n.digest();return n.clean(),i},T.equal=L.equal,Object.defineProperty(C,"__esModule",{value:!0});var D=T,k=w,z=function(){function e(e,t,r,n){void 0===r&&(r=new Uint8Array(0)),this._counter=new Uint8Array(1),this._hash=e,this._info=n;var i=D.hmac(this._hash,r,t);this._hmac=new D.HMAC(e,i),this._buffer=new Uint8Array(this._hmac.digestLength),this._bufpos=this._buffer.length}return e.prototype._fillBuffer=function(){this._counter[0]++;var e=this._counter[0];if(0===e)throw new Error("hkdf: cannot expand more");this._hmac.reset(),e>1&&this._hmac.update(this._buffer),this._info&&this._hmac.update(this._info),this._hmac.update(this._counter),this._hmac.finish(this._buffer),this._bufpos=0},e.prototype.expand=function(e){for(var t=new Uint8Array(e),r=0;r<t.length;r++)this._bufpos===this._buffer.length&&this._fillBuffer(),t[r]=this._buffer[this._bufpos++];return t},e.prototype.clean=function(){this._hmac.clean(),k.wipe(this._buffer),k.wipe(this._counter),this._bufpos=0},e}(),$=C.HKDF=z,q={},H={},K={};Object.defineProperty(K,"__esModule",{value:!0}),K.BrowserRandomSource=void 0;K.BrowserRandomSource=class{constructor(){this.isAvailable=!1,this.isInstantiated=!1;const e="undefined"!=typeof self?self.crypto||self.msCrypto:null;e&&void 0!==e.getRandomValues&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}randomBytes(e){if(!this.isAvailable||!this._crypto)throw new Error("Browser random byte generator is not available.");const t=new Uint8Array(e);for(let e=0;e<t.length;e+=65536)this._crypto.getRandomValues(t.subarray(e,e+Math.min(t.length-e,65536)));return t}};var V={};Object.defineProperty(V,"__esModule",{value:!0}),V.NodeRandomSource=void 0;const B=w;V.NodeRandomSource=class{constructor(){if(this.isAvailable=!1,this.isInstantiated=!1,void 0!==t.commonjsRequire){const e=r.require$$1;e&&e.randomBytes&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}}randomBytes(e){if(!this.isAvailable||!this._crypto)throw new Error("Node.js random byte generator is not available.");let t=this._crypto.randomBytes(e);if(t.length!==e)throw new Error("NodeRandomSource: got fewer bytes than requested");const r=new Uint8Array(e);for(let e=0;e<r.length;e++)r[e]=t[e];return(0,B.wipe)(t),r}},Object.defineProperty(H,"__esModule",{value:!0}),H.SystemRandomSource=void 0;const F=K,G=V;H.SystemRandomSource=class{constructor(){return this.isAvailable=!1,this.name="",this._source=new F.BrowserRandomSource,this._source.isAvailable?(this.isAvailable=!0,void(this.name="Browser")):(this._source=new G.NodeRandomSource,this._source.isAvailable?(this.isAvailable=!0,void(this.name="Node")):void 0)}randomBytes(e){if(!this.isAvailable)throw new Error("System random byte generator is not available.");return this._source.randomBytes(e)}},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.randomStringForEntropy=e.randomString=e.randomUint32=e.randomBytes=e.defaultRandomSource=void 0;const t=H,r=a,n=w;function i(t,r=e.defaultRandomSource){return r.randomBytes(t)}e.defaultRandomSource=new t.SystemRandomSource,e.randomBytes=i,e.randomUint32=function(t=e.defaultRandomSource){const s=i(4,t),o=(0,r.readUint32LE)(s);return(0,n.wipe)(s),o};const s="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function o(t,r=s,o=e.defaultRandomSource){if(r.length<2)throw new Error("randomString charset is too short");if(r.length>256)throw new Error("randomString charset is too long");let a="";const c=r.length,u=256-256%c;for(;t>0;){const e=i(Math.ceil(256*t/u),o);for(let n=0;n<e.length&&t>0;n++){const i=e[n];i<u&&(a+=r.charAt(i%c),t--)}(0,n.wipe)(e)}return a}e.randomString=o,e.randomStringForEntropy=function(t,r=s,n=e.defaultRandomSource){return o(Math.ceil(t/(Math.log(r.length)/Math.LN2)),r,n)}}(q);var W={};!function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=a,r=w;e.DIGEST_LENGTH=32,e.BLOCK_SIZE=64;var n=function(){function n(){this.digestLength=e.DIGEST_LENGTH,this.blockSize=e.BLOCK_SIZE,this._state=new Int32Array(8),this._temp=new Int32Array(64),this._buffer=new Uint8Array(128),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return n.prototype._initState=function(){this._state[0]=1779033703,this._state[1]=3144134277,this._state[2]=1013904242,this._state[3]=2773480762,this._state[4]=1359893119,this._state[5]=2600822924,this._state[6]=528734635,this._state[7]=1541459225},n.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},n.prototype.clean=function(){r.wipe(this._buffer),r.wipe(this._temp),this.reset()},n.prototype.update=function(e,t){if(void 0===t&&(t=e.length),this._finished)throw new Error("SHA256: can't update because hash was finished.");var r=0;if(this._bytesHashed+=t,this._bufferLength>0){for(;this._bufferLength<this.blockSize&&t>0;)this._buffer[this._bufferLength++]=e[r++],t--;this._bufferLength===this.blockSize&&(s(this._temp,this._state,this._buffer,0,this.blockSize),this._bufferLength=0)}for(t>=this.blockSize&&(r=s(this._temp,this._state,e,r,t),t%=this.blockSize);t>0;)this._buffer[this._bufferLength++]=e[r++],t--;return this},n.prototype.finish=function(e){if(!this._finished){var r=this._bytesHashed,n=this._bufferLength,i=r/536870912|0,o=r<<3,a=r%64<56?64:128;this._buffer[n]=128;for(var c=n+1;c<a-8;c++)this._buffer[c]=0;t.writeUint32BE(i,this._buffer,a-8),t.writeUint32BE(o,this._buffer,a-4),s(this._temp,this._state,this._buffer,0,a),this._finished=!0}for(c=0;c<this.digestLength/4;c++)t.writeUint32BE(this._state[c],e,4*c);return this},n.prototype.digest=function(){var e=new Uint8Array(this.digestLength);return this.finish(e),e},n.prototype.saveState=function(){if(this._finished)throw new Error("SHA256: cannot save finished state");return{state:new Int32Array(this._state),buffer:this._bufferLength>0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},n.prototype.restoreState=function(e){return this._state.set(e.state),this._bufferLength=e.bufferLength,e.buffer&&this._buffer.set(e.buffer),this._bytesHashed=e.bytesHashed,this._finished=!1,this},n.prototype.cleanSavedState=function(e){r.wipe(e.state),e.buffer&&r.wipe(e.buffer),e.bufferLength=0,e.bytesHashed=0},n}();e.SHA256=n;var i=new Int32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function s(e,r,n,s,o){for(;o>=64;){for(var a=r[0],c=r[1],u=r[2],h=r[3],l=r[4],f=r[5],p=r[6],d=r[7],g=0;g<16;g++){var y=s+4*g;e[g]=t.readUint32BE(n,y)}for(g=16;g<64;g++){var v=e[g-2],_=(v>>>17|v<<15)^(v>>>19|v<<13)^v>>>10,m=((v=e[g-15])>>>7|v<<25)^(v>>>18|v<<14)^v>>>3;e[g]=(_+e[g-7]|0)+(m+e[g-16]|0)}for(g=0;g<64;g++){_=(((l>>>6|l<<26)^(l>>>11|l<<21)^(l>>>25|l<<7))+(l&f^~l&p)|0)+(d+(i[g]+e[g]|0)|0)|0,m=((a>>>2|a<<30)^(a>>>13|a<<19)^(a>>>22|a<<10))+(a&c^a&u^c&u)|0;d=p,p=f,f=l,l=h+_|0,h=u,u=c,c=a,a=_+m|0}r[0]+=a,r[1]+=c,r[2]+=u,r[3]+=h,r[4]+=l,r[5]+=f,r[6]+=p,r[7]+=d,s+=64,o-=64}return s}e.hash=function(e){var t=new n;t.update(e);var r=t.digest();return t.clean(),r}}(W);var Y={};function J(e){return null!=globalThis.Buffer?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e}function X(e=0){return null!=globalThis.Buffer&&null!=globalThis.Buffer.allocUnsafe?J(globalThis.Buffer.allocUnsafe(e)):new Uint8Array(e)}function Z(e,t){t||(t=e.reduce(((e,t)=>e+t.length),0));const r=X(t);let n=0;for(const t of e)r.set(t,n),n+=t.length;return J(r)}!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.sharedKey=e.generateKeyPair=e.generateKeyPairFromSeed=e.scalarMultBase=e.scalarMult=e.SHARED_KEY_LENGTH=e.SECRET_KEY_LENGTH=e.PUBLIC_KEY_LENGTH=void 0;const t=q,r=w;function n(e){const t=new Float64Array(16);if(e)for(let r=0;r<e.length;r++)t[r]=e[r];return t}e.PUBLIC_KEY_LENGTH=32,e.SECRET_KEY_LENGTH=32,e.SHARED_KEY_LENGTH=32;const i=new Uint8Array(32);i[0]=9;const s=n([56129,1]);function o(e){let t=1;for(let r=0;r<16;r++){let n=e[r]+t+65535;t=Math.floor(n/65536),e[r]=n-65536*t}e[0]+=t-1+37*(t-1)}function a(e,t,r){const n=~(r-1);for(let r=0;r<16;r++){const i=n&(e[r]^t[r]);e[r]^=i,t[r]^=i}}function c(e,t,r){for(let n=0;n<16;n++)e[n]=t[n]+r[n]}function u(e,t,r){for(let n=0;n<16;n++)e[n]=t[n]-r[n]}function h(e,t,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,y=0,v=0,_=0,m=0,w=0,b=0,E=0,S=0,I=0,O=0,P=0,N=0,A=0,x=0,C=0,T=0,R=0,j=0,L=0,U=0,M=r[0],D=r[1],k=r[2],z=r[3],$=r[4],q=r[5],H=r[6],K=r[7],V=r[8],B=r[9],F=r[10],G=r[11],W=r[12],Y=r[13],J=r[14],X=r[15];n=t[0],s+=n*M,o+=n*D,a+=n*k,c+=n*z,u+=n*$,h+=n*q,l+=n*H,f+=n*K,p+=n*V,d+=n*B,g+=n*F,y+=n*G,v+=n*W,_+=n*Y,m+=n*J,w+=n*X,n=t[1],o+=n*M,a+=n*D,c+=n*k,u+=n*z,h+=n*$,l+=n*q,f+=n*H,p+=n*K,d+=n*V,g+=n*B,y+=n*F,v+=n*G,_+=n*W,m+=n*Y,w+=n*J,b+=n*X,n=t[2],a+=n*M,c+=n*D,u+=n*k,h+=n*z,l+=n*$,f+=n*q,p+=n*H,d+=n*K,g+=n*V,y+=n*B,v+=n*F,_+=n*G,m+=n*W,w+=n*Y,b+=n*J,E+=n*X,n=t[3],c+=n*M,u+=n*D,h+=n*k,l+=n*z,f+=n*$,p+=n*q,d+=n*H,g+=n*K,y+=n*V,v+=n*B,_+=n*F,m+=n*G,w+=n*W,b+=n*Y,E+=n*J,S+=n*X,n=t[4],u+=n*M,h+=n*D,l+=n*k,f+=n*z,p+=n*$,d+=n*q,g+=n*H,y+=n*K,v+=n*V,_+=n*B,m+=n*F,w+=n*G,b+=n*W,E+=n*Y,S+=n*J,I+=n*X,n=t[5],h+=n*M,l+=n*D,f+=n*k,p+=n*z,d+=n*$,g+=n*q,y+=n*H,v+=n*K,_+=n*V,m+=n*B,w+=n*F,b+=n*G,E+=n*W,S+=n*Y,I+=n*J,O+=n*X,n=t[6],l+=n*M,f+=n*D,p+=n*k,d+=n*z,g+=n*$,y+=n*q,v+=n*H,_+=n*K,m+=n*V,w+=n*B,b+=n*F,E+=n*G,S+=n*W,I+=n*Y,O+=n*J,P+=n*X,n=t[7],f+=n*M,p+=n*D,d+=n*k,g+=n*z,y+=n*$,v+=n*q,_+=n*H,m+=n*K,w+=n*V,b+=n*B,E+=n*F,S+=n*G,I+=n*W,O+=n*Y,P+=n*J,N+=n*X,n=t[8],p+=n*M,d+=n*D,g+=n*k,y+=n*z,v+=n*$,_+=n*q,m+=n*H,w+=n*K,b+=n*V,E+=n*B,S+=n*F,I+=n*G,O+=n*W,P+=n*Y,N+=n*J,A+=n*X,n=t[9],d+=n*M,g+=n*D,y+=n*k,v+=n*z,_+=n*$,m+=n*q,w+=n*H,b+=n*K,E+=n*V,S+=n*B,I+=n*F,O+=n*G,P+=n*W,N+=n*Y,A+=n*J,x+=n*X,n=t[10],g+=n*M,y+=n*D,v+=n*k,_+=n*z,m+=n*$,w+=n*q,b+=n*H,E+=n*K,S+=n*V,I+=n*B,O+=n*F,P+=n*G,N+=n*W,A+=n*Y,x+=n*J,C+=n*X,n=t[11],y+=n*M,v+=n*D,_+=n*k,m+=n*z,w+=n*$,b+=n*q,E+=n*H,S+=n*K,I+=n*V,O+=n*B,P+=n*F,N+=n*G,A+=n*W,x+=n*Y,C+=n*J,T+=n*X,n=t[12],v+=n*M,_+=n*D,m+=n*k,w+=n*z,b+=n*$,E+=n*q,S+=n*H,I+=n*K,O+=n*V,P+=n*B,N+=n*F,A+=n*G,x+=n*W,C+=n*Y,T+=n*J,R+=n*X,n=t[13],_+=n*M,m+=n*D,w+=n*k,b+=n*z,E+=n*$,S+=n*q,I+=n*H,O+=n*K,P+=n*V,N+=n*B,A+=n*F,x+=n*G,C+=n*W,T+=n*Y,R+=n*J,j+=n*X,n=t[14],m+=n*M,w+=n*D,b+=n*k,E+=n*z,S+=n*$,I+=n*q,O+=n*H,P+=n*K,N+=n*V,A+=n*B,x+=n*F,C+=n*G,T+=n*W,R+=n*Y,j+=n*J,L+=n*X,n=t[15],w+=n*M,b+=n*D,E+=n*k,S+=n*z,I+=n*$,O+=n*q,P+=n*H,N+=n*K,A+=n*V,x+=n*B,C+=n*F,T+=n*G,R+=n*W,j+=n*Y,L+=n*J,U+=n*X,s+=38*b,o+=38*E,a+=38*S,c+=38*I,u+=38*O,h+=38*P,l+=38*N,f+=38*A,p+=38*x,d+=38*C,g+=38*T,y+=38*R,v+=38*j,_+=38*L,m+=38*U,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=y+i+65535,i=Math.floor(n/65536),y=n-65536*i,n=v+i+65535,i=Math.floor(n/65536),v=n-65536*i,n=_+i+65535,i=Math.floor(n/65536),_=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,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=y+i+65535,i=Math.floor(n/65536),y=n-65536*i,n=v+i+65535,i=Math.floor(n/65536),v=n-65536*i,n=_+i+65535,i=Math.floor(n/65536),_=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,s+=i-1+37*(i-1),e[0]=s,e[1]=o,e[2]=a,e[3]=c,e[4]=u,e[5]=h,e[6]=l,e[7]=f,e[8]=p,e[9]=d,e[10]=g,e[11]=y,e[12]=v,e[13]=_,e[14]=m,e[15]=w}function l(e,t){h(e,t,t)}function f(e,t){const r=new Uint8Array(32),i=new Float64Array(80),f=n(),p=n(),d=n(),g=n(),y=n(),v=n();for(let t=0;t<31;t++)r[t]=e[t];r[31]=127&e[31]|64,r[0]&=248,function(e,t){for(let r=0;r<16;r++)e[r]=t[2*r]+(t[2*r+1]<<8);e[15]&=32767}(i,t);for(let e=0;e<16;e++)p[e]=i[e];f[0]=g[0]=1;for(let e=254;e>=0;--e){const t=r[e>>>3]>>>(7&e)&1;a(f,p,t),a(d,g,t),c(y,f,d),u(f,f,d),c(d,p,g),u(p,p,g),l(g,y),l(v,f),h(f,d,f),h(d,p,y),c(y,f,d),u(f,f,d),l(p,f),u(d,g,v),h(f,d,s),c(f,f,g),h(d,d,f),h(f,g,v),h(g,p,i),l(p,y),a(f,p,t),a(d,g,t)}for(let e=0;e<16;e++)i[e+16]=f[e],i[e+32]=d[e],i[e+48]=p[e],i[e+64]=g[e];const _=i.subarray(32),m=i.subarray(16);!function(e,t){const r=n();for(let e=0;e<16;e++)r[e]=t[e];for(let e=253;e>=0;e--)l(r,r),2!==e&&4!==e&&h(r,r,t);for(let t=0;t<16;t++)e[t]=r[t]}(_,_),h(m,m,_);const w=new Uint8Array(32);return function(e,t){const r=n(),i=n();for(let e=0;e<16;e++)i[e]=t[e];o(i),o(i),o(i);for(let e=0;e<2;e++){r[0]=i[0]-65517;for(let e=1;e<15;e++)r[e]=i[e]-65535-(r[e-1]>>16&1),r[e-1]&=65535;r[15]=i[15]-32767-(r[14]>>16&1);const e=r[15]>>16&1;r[14]&=65535,a(i,r,1-e)}for(let t=0;t<16;t++)e[2*t]=255&i[t],e[2*t+1]=i[t]>>8}(w,m),w}function p(e){return f(e,i)}function d(t){if(t.length!==e.SECRET_KEY_LENGTH)throw new Error(`x25519: seed must be ${e.SECRET_KEY_LENGTH} bytes`);const r=new Uint8Array(t);return{publicKey:p(r),secretKey:r}}e.scalarMult=f,e.scalarMultBase=p,e.generateKeyPairFromSeed=d,e.generateKeyPair=function(e){const n=(0,t.randomBytes)(32,e),i=d(n);return(0,r.wipe)(n),i},e.sharedKey=function(t,r,n=!1){if(t.length!==e.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect secret key length");if(r.length!==e.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect public key length");const i=f(t,r);if(n){let e=0;for(let t=0;t<i.length;t++)e|=i[t];if(0===e)throw new Error("X25519: invalid shared key")}return i}}(Y);var Q=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<e.length;i++){var s=e.charAt(i),o=s.charCodeAt(0);if(255!==r[o])throw new TypeError(s+" is ambiguous");r[o]=i}var a=e.length,c=e.charAt(0),u=Math.log(a)/Math.log(256),h=Math.log(256)/Math.log(a);function l(e){if("string"!=typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var n=0,i=0;e[t]===c;)n++,t++;for(var s=(e.length-t)*u+1>>>0,o=new Uint8Array(s);e[t];){var h=r[e.charCodeAt(t)];if(255===h)return;for(var l=0,f=s-1;(0!==h||l<i)&&-1!==f;f--,l++)h+=a*o[f]>>>0,o[f]=h%256>>>0,h=h/256>>>0;if(0!==h)throw new Error("Non-zero carry");i=l,t++}if(" "!==e[t]){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(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,i=0,s=t.length;i!==s&&0===t[i];)i++,r++;for(var o=(s-i)*h+1>>>0,u=new Uint8Array(o);i!==s;){for(var l=t[i],f=0,p=o-1;(0!==l||f<n)&&-1!==p;p--,f++)l+=256*u[p]>>>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<o;++d)g+=e.charAt(u[d]);return g},decodeUnsafe:l,decode:function(e){var r=l(e);if(r)return r;throw new Error(`Non-${t} character`)}}},ee=Q;const te=e=>{if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")};class re{constructor(e,t,r){this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class ne{constructor(e,t,r){if(this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=r}decode(e){if("string"==typeof e){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}throw Error("Can only multibase decode strings")}or(e){return se(this,e)}}class ie{constructor(e){this.decoders=e}or(e){return se(this,e)}decode(e){const t=e[0],r=this.decoders[t];if(r)return r.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const se=(e,t)=>new ie({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}});class oe{constructor(e,t,r,n){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new re(e,t,r),this.decoder=new ne(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const ae=({name:e,prefix:t,encode:r,decode:n})=>new oe(e,t,r,n),ce=({prefix:e,name:t,alphabet:r})=>{const{encode:n,decode:i}=ee(r,t);return ae({prefix:e,name:t,encode:n,decode:e=>te(i(e))})},ue=({name:e,prefix:t,bitsPerChar:r,alphabet:n})=>ae({prefix:t,name:e,encode:e=>((e,t,r)=>{const n="="===t[t.length-1],i=(1<<r)-1;let s="",o=0,a=0;for(let n=0;n<e.length;++n)for(a=a<<8|e[n],o+=8;o>r;)o-=r,s+=t[i&a>>o];if(o&&(s+=t[i&a<<r-o]),n)for(;s.length*r&7;)s+="=";return s})(e,n,r),decode:t=>((e,t,r,n)=>{const i={};for(let e=0;e<t.length;++e)i[t[e]]=e;let s=e.length;for(;"="===e[s-1];)--s;const o=new Uint8Array(s*r/8|0);let a=0,c=0,u=0;for(let t=0;t<s;++t){const s=i[e[t]];if(void 0===s)throw new SyntaxError(`Non-${n} character`);c=c<<r|s,a+=r,a>=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,n,r,e)}),he=ae({prefix:"\0",name:"identity",encode:e=>(e=>(new TextDecoder).decode(e))(e),decode:e=>(e=>(new TextEncoder).encode(e))(e)});var le=Object.freeze({__proto__:null,identity:he});const fe=ue({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var pe=Object.freeze({__proto__:null,base2:fe});const de=ue({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var ge=Object.freeze({__proto__:null,base8:de});const ye=ce({prefix:"9",name:"base10",alphabet:"0123456789"});var ve=Object.freeze({__proto__:null,base10:ye});const _e=ue({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),me=ue({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var we=Object.freeze({__proto__:null,base16:_e,base16upper:me});const be=ue({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Ee=ue({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Se=ue({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Ie=ue({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Oe=ue({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Pe=ue({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Ne=ue({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Ae=ue({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),xe=ue({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Ce=Object.freeze({__proto__:null,base32:be,base32upper:Ee,base32pad:Se,base32padupper:Ie,base32hex:Oe,base32hexupper:Pe,base32hexpad:Ne,base32hexpadupper:Ae,base32z:xe});const Te=ce({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Re=ce({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var je=Object.freeze({__proto__:null,base36:Te,base36upper:Re});const Le=ce({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ue=ce({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Me=Object.freeze({__proto__:null,base58btc:Le,base58flickr:Ue});const De=ue({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),ke=ue({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),ze=ue({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),$e=ue({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var qe=Object.freeze({__proto__:null,base64:De,base64pad:ke,base64url:ze,base64urlpad:$e});const He=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),Ke=He.reduce(((e,t,r)=>(e[r]=t,e)),[]),Ve=He.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const Be=ae({prefix:"🚀",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=Ke[t]),"")},decode:function(e){const t=[];for(const r of e){const e=Ve[r.codePointAt(0)];if(void 0===e)throw new Error(`Non-base256emoji character: ${r}`);t.push(e)}return new Uint8Array(t)}});var Fe=Object.freeze({__proto__:null,base256emoji:Be}),Ge=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=Je;)r[n++]=255&t|We,t/=128;for(;t&Ye;)r[n++]=255&t|We,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},We=128,Ye=-128,Je=Math.pow(2,31);var Xe=function e(t,r){var n,i=0,s=0,o=r=r||0,a=t.length;do{if(o>=a)throw e.bytes=0,new RangeError("Could not decode varint");n=t[o++],i+=s<28?(n&Qe)<<s:(n&Qe)*Math.pow(2,s),s+=7}while(n>=Ze);return e.bytes=o-r,i},Ze=128,Qe=127;var et=Math.pow(2,7),tt=Math.pow(2,14),rt=Math.pow(2,21),nt=Math.pow(2,28),it=Math.pow(2,35),st=Math.pow(2,42),ot=Math.pow(2,49),at=Math.pow(2,56),ct=Math.pow(2,63),ut={encode:Ge,decode:Xe,encodingLength:function(e){return e<et?1:e<tt?2:e<rt?3:e<nt?4:e<it?5:e<st?6:e<ot?7:e<at?8:e<ct?9:10}};const ht=(e,t,r=0)=>(ut.encode(e,t,r),t),lt=e=>ut.encodingLength(e),ft=(e,t)=>{const r=t.byteLength,n=lt(e),i=n+lt(r),s=new Uint8Array(i+r);return ht(e,s,0),ht(r,s,n),s.set(t,i),new pt(e,r,t,s)};class pt{constructor(e,t,r,n){this.code=e,this.size=t,this.digest=r,this.bytes=n}}const dt=({name:e,code:t,encode:r})=>new gt(e,t,r);class gt{constructor(e,t,r){this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?ft(this.code,t):t.then((e=>ft(this.code,e)))}throw Error("Unknown type, must be binary type")}}const yt=e=>async t=>new Uint8Array(await crypto.subtle.digest(e,t));dt({name:"sha2-256",code:18,encode:yt("SHA-256")}),dt({name:"sha2-512",code:19,encode:yt("SHA-512")});new TextEncoder,new TextDecoder;const vt={...le,...pe,...ge,...ve,...we,...Ce,...je,...Me,...qe,...Fe};function _t(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}const mt=_t("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),wt=_t("ascii","a",(e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t}),(e=>{const t=X((e=e.substring(1)).length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t})),bt={utf8:mt,"utf-8":mt,hex:vt.base16,latin1:wt,ascii:wt,binary:wt,...vt};function Et(e,t="utf8"){const r=bt[t];if(!r)throw new Error(`Unsupported encoding "${t}"`);return"utf8"!==t&&"utf-8"!==t||null==globalThis.Buffer||null==globalThis.Buffer.from?r.decoder.decode(`${r.prefix}${e}`):J(globalThis.Buffer.from(e,"utf-8"))}function St(e,t="utf8"){const r=bt[t];if(!r)throw new Error(`Unsupported encoding "${t}"`);return"utf8"!==t&&"utf-8"!==t||null==globalThis.Buffer||null==globalThis.Buffer.from?r.encoder.encode(e).substring(1):globalThis.Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString("utf8")}var It=function(e,t,r){if(r||2===arguments.length)for(var n,i=0,s=t.length;i<s;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))},Ot=function(e,t,r){this.name=e,this.version=t,this.os=r,this.type="browser"},Pt=function(e){this.version=e,this.type="node",this.name="node",this.os=process.platform},Nt=function(e,t,r,n){this.name=e,this.version=t,this.os=r,this.bot=n,this.type="bot-device"},At=function(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null},xt=function(){this.type="react-native",this.name="react-native",this.version=null,this.os=null},Ct=/(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,Tt=3,Rt=[["aol",/AOLShield\/([0-9\._]+)/],["edge",/Edge\/([0-9\._]+)/],["edge-ios",/EdgiOS\/([0-9\._]+)/],["yandexbrowser",/YaBrowser\/([0-9\._]+)/],["kakaotalk",/KAKAOTALK\s([0-9\.]+)/],["samsung",/SamsungBrowser\/([0-9\.]+)/],["silk",/\bSilk\/([0-9._-]+)\b/],["miui",/MiuiBrowser\/([0-9\.]+)$/],["beaker",/BeakerBrowser\/([0-9\.]+)/],["edge-chromium",/EdgA?\/([0-9\.]+)/],["chromium-webview",/(?!Chrom.*OPR)wv\).*Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["chrome",/(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["phantomjs",/PhantomJS\/([0-9\.]+)(:?\s|$)/],["crios",/CriOS\/([0-9\.]+)(:?\s|$)/],["firefox",/Firefox\/([0-9\.]+)(?:\s|$)/],["fxios",/FxiOS\/([0-9\.]+)/],["opera-mini",/Opera Mini.*Version\/([0-9\.]+)/],["opera",/Opera\/([0-9\.]+)(?:\s|$)/],["opera",/OPR\/([0-9\.]+)(:?\s|$)/],["pie",/^Microsoft Pocket Internet Explorer\/(\d+\.\d+)$/],["pie",/^Mozilla\/\d\.\d+\s\(compatible;\s(?:MSP?IE|MSInternet Explorer) (\d+\.\d+);.*Windows CE.*\)$/],["netfront",/^Mozilla\/\d\.\d+.*NetFront\/(\d.\d)/],["ie",/Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/],["ie",/MSIE\s([0-9\.]+);.*Trident\/[4-7].0/],["ie",/MSIE\s(7\.0)/],["bb10",/BB10;\sTouch.*Version\/([0-9\.]+)/],["android",/Android\s([0-9\.]+)/],["ios",/Version\/([0-9\._]+).*Mobile.*Safari.*/],["safari",/Version\/([0-9\._]+).*Safari/],["facebook",/FB[AS]V\/([0-9\.]+)/],["instagram",/Instagram\s([0-9\.]+)/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Mobile/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Gecko\)$/],["curl",/^curl\/([0-9\.]+)$/],["searchbot",/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/]],jt=[["iOS",/iP(hone|od|ad)/],["Android OS",/Android/],["BlackBerry OS",/BlackBerry|BB10/],["Windows Mobile",/IEMobile/],["Amazon OS",/Kindle/],["Windows 3.11",/Win16/],["Windows 95",/(Windows 95)|(Win95)|(Windows_95)/],["Windows 98",/(Windows 98)|(Win98)/],["Windows 2000",/(Windows NT 5.0)|(Windows 2000)/],["Windows XP",/(Windows NT 5.1)|(Windows XP)/],["Windows Server 2003",/(Windows NT 5.2)/],["Windows Vista",/(Windows NT 6.0)/],["Windows 7",/(Windows NT 6.1)/],["Windows 8",/(Windows NT 6.2)/],["Windows 8.1",/(Windows NT 6.3)/],["Windows 10",/(Windows NT 10.0)/],["Windows ME",/Windows ME/],["Windows CE",/Windows CE|WinCE|Microsoft Pocket Internet Explorer/],["Open BSD",/OpenBSD/],["Sun OS",/SunOS/],["Chrome OS",/CrOS/],["Linux",/(Linux)|(X11)/],["Mac OS",/(Mac_PowerPC)|(Macintosh)/],["QNX",/QNX/],["BeOS",/BeOS/],["OS/2",/OS\/2/]];function Lt(e){return e?Ut(e):"undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"===navigator.product?new xt:"undefined"!=typeof navigator?Ut(navigator.userAgent):"undefined"!=typeof process&&process.version?new Pt(process.version.slice(1)):null}function Ut(e){var t=function(e){return""!==e&&Rt.reduce((function(t,r){var n=r[0],i=r[1];if(t)return t;var s=i.exec(e);return!!s&&[n,s]}),!1)}(e);if(!t)return null;var r=t[0],n=t[1];if("searchbot"===r)return new At;var i=n[1]&&n[1].split(".").join("_").split("_").slice(0,3);i?i.length<Tt&&(i=It(It([],i,!0),function(e){for(var t=[],r=0;r<e;r++)t.push("0");return t}(Tt-i.length),!0)):i=[];var s=i.join("."),o=function(e){for(var t=0,r=jt.length;t<r;t++){var n=jt[t],i=n[0];if(n[1].exec(e))return i}return null}(e),a=Ct.exec(e);return a&&a[1]?new Nt(r,s,o,a[1]):new Ot(r,s,o)}var Mt={},Dt=function(e,t){return Dt=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},Dt(e,t)};var kt=function(){return kt=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},kt.apply(this,arguments)};var zt=Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]};function $t(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function qt(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,s=r.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(n=s.next()).done;)o.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=s.return)&&r.call(s)}finally{if(i)throw i.error}}return o}function Ht(e){return this instanceof Ht?(this.v=e,this):new Ht(e)}var Kt=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t};var Vt,Bt=Object.freeze({__proto__:null,__extends:function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}Dt(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)},get __assign(){return kt},__rest:function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]])}return r},__decorate:function(e,t,r,n){var i,s=arguments.length,o=s<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(o=(s<3?i(o):s>3?i(t,r,o):i(t,r))||o);return s>3&&o&&Object.defineProperty(t,r,o),o},__param:function(e,t){return function(r,n){t(r,n,e)}},__esDecorate:function(e,t,r,n,i,s){function o(e){if(void 0!==e&&"function"!=typeof e)throw new TypeError("Function expected");return e}for(var a,c=n.kind,u="getter"===c?"get":"setter"===c?"set":"value",h=!t&&e?n.static?e:e.prototype:null,l=t||(h?Object.getOwnPropertyDescriptor(h,n.name):{}),f=!1,p=r.length-1;p>=0;p--){var d={};for(var g in n)d[g]="access"===g?{}:n[g];for(var g in n.access)d.access[g]=n.access[g];d.addInitializer=function(e){if(f)throw new TypeError("Cannot add initializers after decoration has completed");s.push(o(e||null))};var y=(0,r[p])("accessor"===c?{get:l.get,set:l.set}:l[u],d);if("accessor"===c){if(void 0===y)continue;if(null===y||"object"!=typeof y)throw new TypeError("Object expected");(a=o(y.get))&&(l.get=a),(a=o(y.set))&&(l.set=a),(a=o(y.init))&&i.push(a)}else(a=o(y))&&("field"===c?i.push(a):l[u]=a)}h&&Object.defineProperty(h,n.name,l),f=!0},__runInitializers:function(e,t,r){for(var n=arguments.length>2,i=0;i<t.length;i++)r=n?t[i].call(e,r):t[i].call(e);return n?r:void 0},__propKey:function(e){return"symbol"==typeof e?e:"".concat(e)},__setFunctionName:function(e,t,r){return"symbol"==typeof t&&(t=t.description?"[".concat(t.description,"]"):""),Object.defineProperty(e,"name",{configurable:!0,value:r?"".concat(r," ",t):t})},__metadata:function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},__awaiter:function(e,t,r,n){return new(r||(r=Promise))((function(i,s){function o(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))},__generator:function(e,t){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(a){return function(c){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(o=0)),o;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,n=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){o.label=a[1];break}if(6===a[0]&&o.label<i[1]){o.label=i[1],i=a;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(a);break}i[2]&&o.ops.pop(),o.trys.pop();continue}a=t.call(e,o)}catch(e){a=[6,e],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},__createBinding:zt,__exportStar:function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||zt(t,e,r)},__values:$t,__read:qt,__spread:function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(qt(arguments[t]));return e},__spreadArrays:function(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var n=Array(e),i=0;for(t=0;t<r;t++)for(var s=arguments[t],o=0,a=s.length;o<a;o++,i++)n[i]=s[o];return n},__spreadArray:function(e,t,r){if(r||2===arguments.length)for(var n,i=0,s=t.length;i<s;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))},__await:Ht,__asyncGenerator:function(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,i=r.apply(e,t||[]),s=[];return n={},o("next"),o("throw"),o("return"),n[Symbol.asyncIterator]=function(){return this},n;function o(e){i[e]&&(n[e]=function(t){return new Promise((function(r,n){s.push([e,t,r,n])>1||a(e,t)}))})}function a(e,t){try{(r=i[e](t)).value instanceof Ht?Promise.resolve(r.value.v).then(c,u):h(s[0][2],r)}catch(e){h(s[0][3],e)}var r}function c(e){a("next",e)}function u(e){a("throw",e)}function h(e,t){e(t),s.shift(),s.length&&a(s[0][0],s[0][1])}},__asyncDelegator:function(e){var t,r;return t={},n("next"),n("throw",(function(e){throw e})),n("return"),t[Symbol.iterator]=function(){return this},t;function n(n,i){t[n]=e[n]?function(t){return(r=!r)?{value:Ht(e[n](t)),done:!1}:i?i(t):t}:i}},__asyncValues:function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=$t(e),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=e[r]&&function(t){return new Promise((function(n,i){(function(e,t,r,n){Promise.resolve(n).then((function(t){e({value:t,done:r})}),t)})(n,i,(t=e[r](t)).done,t.value)}))}}},__makeTemplateObject:function(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e},__importStar:function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&zt(t,e,r);return Kt(t,e),t},__importDefault:function(e){return e&&e.__esModule?e:{default:e}},__classPrivateFieldGet:function(e,t,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)},__classPrivateFieldSet:function(e,t,r,n,i){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?i.call(e,r):i?i.value=r:t.set(e,r),r},__classPrivateFieldIn:function(e,t){if(null===t||"object"!=typeof t&&"function"!=typeof t)throw new TypeError("Cannot use 'in' operator on non-object");return"function"==typeof e?t===e:e.has(t)}}),Ft=r.getAugmentedNamespace(Bt),Gt={},Wt={};var Yt,Jt={},Xt={},Zt={};var Qt,er,tr,rr,nr={};function ir(){return er||(er=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});const t=Ft;t.__exportStar((Yt||(Yt=1,Object.defineProperty(Zt,"__esModule",{value:!0}),Zt.ONE_THOUSAND=Zt.ONE_HUNDRED=void 0,Zt.ONE_HUNDRED=100,Zt.ONE_THOUSAND=1e3),Zt),e),t.__exportStar((Qt||(Qt=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.ONE_YEAR=e.FOUR_WEEKS=e.THREE_WEEKS=e.TWO_WEEKS=e.ONE_WEEK=e.THIRTY_DAYS=e.SEVEN_DAYS=e.FIVE_DAYS=e.THREE_DAYS=e.ONE_DAY=e.TWENTY_FOUR_HOURS=e.TWELVE_HOURS=e.SIX_HOURS=e.THREE_HOURS=e.ONE_HOUR=e.SIXTY_MINUTES=e.THIRTY_MINUTES=e.TEN_MINUTES=e.FIVE_MINUTES=e.ONE_MINUTE=e.SIXTY_SECONDS=e.THIRTY_SECONDS=e.TEN_SECONDS=e.FIVE_SECONDS=e.ONE_SECOND=void 0,e.ONE_SECOND=1,e.FIVE_SECONDS=5,e.TEN_SECONDS=10,e.THIRTY_SECONDS=30,e.SIXTY_SECONDS=60,e.ONE_MINUTE=e.SIXTY_SECONDS,e.FIVE_MINUTES=5*e.ONE_MINUTE,e.TEN_MINUTES=10*e.ONE_MINUTE,e.THIRTY_MINUTES=30*e.ONE_MINUTE,e.SIXTY_MINUTES=60*e.ONE_MINUTE,e.ONE_HOUR=e.SIXTY_MINUTES,e.THREE_HOURS=3*e.ONE_HOUR,e.SIX_HOURS=6*e.ONE_HOUR,e.TWELVE_HOURS=12*e.ONE_HOUR,e.TWENTY_FOUR_HOURS=24*e.ONE_HOUR,e.ONE_DAY=e.TWENTY_FOUR_HOURS,e.THREE_DAYS=3*e.ONE_DAY,e.FIVE_DAYS=5*e.ONE_DAY,e.SEVEN_DAYS=7*e.ONE_DAY,e.THIRTY_DAYS=30*e.ONE_DAY,e.ONE_WEEK=e.SEVEN_DAYS,e.TWO_WEEKS=2*e.ONE_WEEK,e.THREE_WEEKS=3*e.ONE_WEEK,e.FOUR_WEEKS=4*e.ONE_WEEK,e.ONE_YEAR=365*e.ONE_DAY}(nr)),nr),e)}(Xt)),Xt}function sr(){return rr||(rr=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});const t=Ft;t.__exportStar((Vt||(Vt=1,Object.defineProperty(Wt,"__esModule",{value:!0}),Wt.delay=void 0,Wt.delay=function(e){return new Promise((t=>{setTimeout((()=>{t(!0)}),e)}))}),Wt),e),t.__exportStar(function(){if(tr)return Jt;tr=1,Object.defineProperty(Jt,"__esModule",{value:!0}),Jt.fromMiliseconds=Jt.toMiliseconds=void 0;const e=ir();return Jt.toMiliseconds=function(t){return t*e.ONE_THOUSAND},Jt.fromMiliseconds=function(t){return Math.floor(t/e.ONE_THOUSAND)},Jt}(),e)}(Gt)),Gt}var or,ar={};var cr,ur,hr={},lr={};function fr(){return ur||(ur=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});Ft.__exportStar((cr||(cr=1,Object.defineProperty(lr,"__esModule",{value:!0}),lr.IWatch=void 0,lr.IWatch=class{}),lr),e)}(hr)),hr}!function(e){Object.defineProperty(e,"__esModule",{value:!0});const t=Ft;t.__exportStar(sr(),e),t.__exportStar(function(){if(or)return ar;or=1,Object.defineProperty(ar,"__esModule",{value:!0}),ar.Watch=void 0;class e{constructor(){this.timestamps=new Map}start(e){if(this.timestamps.has(e))throw new Error(`Watch already started for label: ${e}`);this.timestamps.set(e,{started:Date.now()})}stop(e){const t=this.get(e);if(void 0!==t.elapsed)throw new Error(`Watch already stopped for label: ${e}`);const r=Date.now()-t.started;this.timestamps.set(e,{started:t.started,elapsed:r})}get(e){const t=this.timestamps.get(e);if(void 0===t)throw new Error(`No timestamp found for label: ${e}`);return t}elapsed(e){const t=this.get(e);return t.elapsed||Date.now()-t.started}}return ar.Watch=e,ar.default=e,ar}(),e),t.__exportStar(fr(),e),t.__exportStar(ir(),e)}(Mt);var pr={};function dr(e){let t;return"undefined"!=typeof window&&void 0!==window[e]&&(t=window[e]),t}function gr(e){const t=dr(e);if(!t)throw new Error(`${e} is not defined in Window`);return t}Object.defineProperty(pr,"__esModule",{value:!0}),pr.getLocalStorage=pr.getLocalStorageOrThrow=pr.getCrypto=pr.getCryptoOrThrow=_r=pr.getLocation=pr.getLocationOrThrow=vr=pr.getNavigator=pr.getNavigatorOrThrow=yr=pr.getDocument=pr.getDocumentOrThrow=pr.getFromWindowOrThrow=pr.getFromWindow=void 0,pr.getFromWindow=dr,pr.getFromWindowOrThrow=gr,pr.getDocumentOrThrow=function(){return gr("document")};var yr=pr.getDocument=function(){return dr("document")};pr.getNavigatorOrThrow=function(){return gr("navigator")};var vr=pr.getNavigator=function(){return dr("navigator")};pr.getLocationOrThrow=function(){return gr("location")};var _r=pr.getLocation=function(){return dr("location")};pr.getCryptoOrThrow=function(){return gr("crypto")},pr.getCrypto=function(){return dr("crypto")},pr.getLocalStorageOrThrow=function(){return gr("localStorage")},pr.getLocalStorage=function(){return dr("localStorage")};var mr={};Object.defineProperty(mr,"__esModule",{value:!0});var wr=mr.getWindowMetadata=void 0;const br=pr;wr=mr.getWindowMetadata=function(){let e,t;try{e=br.getDocumentOrThrow(),t=br.getLocationOrThrow()}catch(e){return null}function r(...t){const r=e.getElementsByTagName("meta");for(let e=0;e<r.length;e++){const n=r[e],i=["itemprop","property","name"].map((e=>n.getAttribute(e))).filter((e=>!!e&&t.includes(e)));if(i.length&&i){const e=n.getAttribute("content");if(e)return e}}return""}const n=function(){let t=r("name","og:site_name","og:title","twitter:title");return t||(t=e.title),t}();return{description:r("description","og:description","twitter:description","keywords"),url:t.origin,icons:function(){const r=e.getElementsByTagName("link"),n=[];for(let e=0;e<r.length;e++){const i=r[e],s=i.getAttribute("rel");if(s&&s.toLowerCase().indexOf("icon")>-1){const e=i.getAttribute("href");if(e)if(-1===e.toLowerCase().indexOf("https:")&&-1===e.toLowerCase().indexOf("http:")&&0!==e.indexOf("//")){let r=t.protocol+"//"+t.host;if(0===e.indexOf("/"))r+=e;else{const n=t.pathname.split("/");n.pop();r+=n.join("/")+"/"+e}n.push(r)}else if(0===e.indexOf("//")){const r=t.protocol+e;n.push(r)}else n.push(e)}}return n}(),name:n}};var Er={},Sr=e=>encodeURIComponent(e).replace(/[!'()*]/g,(e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`)),Ir="%[a-f0-9]{2}",Or=new RegExp("("+Ir+")|([^%]+?)","gi"),Pr=new RegExp("("+Ir+")+","gi");function Nr(e,t){try{return[decodeURIComponent(e.join(""))]}catch(e){}if(1===e.length)return e;t=t||1;var r=e.slice(0,t),n=e.slice(t);return Array.prototype.concat.call([],Nr(r),Nr(n))}function Ar(e){try{return decodeURIComponent(e)}catch(n){for(var t=e.match(Or)||[],r=1;r<t.length;r++)t=(e=Nr(t,r).join("")).match(Or)||[];return e}}var xr=function(e){if("string"!=typeof e)throw new TypeError("Expected `encodedURI` to be of type `string`, got `"+typeof e+"`");try{return e=e.replace(/\+/g," "),decodeURIComponent(e)}catch(t){return function(e){for(var t={"%FE%FF":"��","%FF%FE":"��"},r=Pr.exec(e);r;){try{t[r[0]]=decodeURIComponent(r[0])}catch(e){var n=Ar(r[0]);n!==r[0]&&(t[r[0]]=n)}r=Pr.exec(e)}t["%C2"]="�";for(var i=Object.keys(t),s=0;s<i.length;s++){var o=i[s];e=e.replace(new RegExp(o,"g"),t[o])}return e}(e)}},Cr=(e,t)=>{if("string"!=typeof e||"string"!=typeof t)throw new TypeError("Expected the arguments to be of type `string`");if(""===t)return[e];const r=e.indexOf(t);return-1===r?[e]:[e.slice(0,r),e.slice(r+t.length)]},Tr=function(e,t){for(var r={},n=Object.keys(e),i=Array.isArray(t),s=0;s<n.length;s++){var o=n[s],a=e[o];(i?-1!==t.indexOf(o):t(o,a,e))&&(r[o]=a)}return r};!function(e){const t=Sr,r=xr,n=Cr,i=Tr,s=Symbol("encodeFragmentIdentifier");function o(e){if("string"!=typeof e||1!==e.length)throw new TypeError("arrayFormatSeparator must be single character string")}function a(e,r){return r.encode?r.strict?t(e):encodeURIComponent(e):e}function c(e,t){return t.decode?r(e):e}function u(e){return Array.isArray(e)?e.sort():"object"==typeof e?u(Object.keys(e)).sort(((e,t)=>Number(e)-Number(t))).map((t=>e[t])):e}function h(e){const t=e.indexOf("#");return-1!==t&&(e=e.slice(0,t)),e}function l(e){const t=(e=h(e)).indexOf("?");return-1===t?"":e.slice(t+1)}function f(e,t){return t.parseNumbers&&!Number.isNaN(Number(e))&&"string"==typeof e&&""!==e.trim()?e=Number(e):!t.parseBooleans||null===e||"true"!==e.toLowerCase()&&"false"!==e.toLowerCase()||(e="true"===e.toLowerCase()),e}function p(e,t){o((t=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},t)).arrayFormatSeparator);const r=function(e){let t;switch(e.arrayFormat){case"index":return(e,r,n)=>{t=/\[(\d*)\]$/.exec(e),e=e.replace(/\[\d*\]$/,""),t?(void 0===n[e]&&(n[e]={}),n[e][t[1]]=r):n[e]=r};case"bracket":return(e,r,n)=>{t=/(\[\])$/.exec(e),e=e.replace(/\[\]$/,""),t?void 0!==n[e]?n[e]=[].concat(n[e],r):n[e]=[r]:n[e]=r};case"colon-list-separator":return(e,r,n)=>{t=/(:list)$/.exec(e),e=e.replace(/:list$/,""),t?void 0!==n[e]?n[e]=[].concat(n[e],r):n[e]=[r]:n[e]=r};case"comma":case"separator":return(t,r,n)=>{const i="string"==typeof r&&r.includes(e.arrayFormatSeparator),s="string"==typeof r&&!i&&c(r,e).includes(e.arrayFormatSeparator);r=s?c(r,e):r;const o=i||s?r.split(e.arrayFormatSeparator).map((t=>c(t,e))):null===r?r:c(r,e);n[t]=o};case"bracket-separator":return(t,r,n)=>{const i=/(\[\])$/.test(t);if(t=t.replace(/\[\]$/,""),!i)return void(n[t]=r?c(r,e):r);const s=null===r?[]:r.split(e.arrayFormatSeparator).map((t=>c(t,e)));void 0!==n[t]?n[t]=[].concat(n[t],s):n[t]=s};default:return(e,t,r)=>{void 0!==r[e]?r[e]=[].concat(r[e],t):r[e]=t}}}(t),i=Object.create(null);if("string"!=typeof e)return i;if(!(e=e.trim().replace(/^[?#&]/,"")))return i;for(const s of e.split("&")){if(""===s)continue;let[e,o]=n(t.decode?s.replace(/\+/g," "):s,"=");o=void 0===o?null:["comma","separator","bracket-separator"].includes(t.arrayFormat)?o:c(o,t),r(c(e,t),o,i)}for(const e of Object.keys(i)){const r=i[e];if("object"==typeof r&&null!==r)for(const e of Object.keys(r))r[e]=f(r[e],t);else i[e]=f(r,t)}return!1===t.sort?i:(!0===t.sort?Object.keys(i).sort():Object.keys(i).sort(t.sort)).reduce(((e,t)=>{const r=i[t];return Boolean(r)&&"object"==typeof r&&!Array.isArray(r)?e[t]=u(r):e[t]=r,e}),Object.create(null))}e.extract=l,e.parse=p,e.stringify=(e,t)=>{if(!e)return"";o((t=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},t)).arrayFormatSeparator);const r=r=>t.skipNull&&null==e[r]||t.skipEmptyString&&""===e[r],n=function(e){switch(e.arrayFormat){case"index":return t=>(r,n)=>{const i=r.length;return void 0===n||e.skipNull&&null===n||e.skipEmptyString&&""===n?r:null===n?[...r,[a(t,e),"[",i,"]"].join("")]:[...r,[a(t,e),"[",a(i,e),"]=",a(n,e)].join("")]};case"bracket":return t=>(r,n)=>void 0===n||e.skipNull&&null===n||e.skipEmptyString&&""===n?r:null===n?[...r,[a(t,e),"[]"].join("")]:[...r,[a(t,e),"[]=",a(n,e)].join("")];case"colon-list-separator":return t=>(r,n)=>void 0===n||e.skipNull&&null===n||e.skipEmptyString&&""===n?r:null===n?[...r,[a(t,e),":list="].join("")]:[...r,[a(t,e),":list=",a(n,e)].join("")];case"comma":case"separator":case"bracket-separator":{const t="bracket-separator"===e.arrayFormat?"[]=":"=";return r=>(n,i)=>void 0===i||e.skipNull&&null===i||e.skipEmptyString&&""===i?n:(i=null===i?"":i,0===n.length?[[a(r,e),t,a(i,e)].join("")]:[[n,a(i,e)].join(e.arrayFormatSeparator)])}default:return t=>(r,n)=>void 0===n||e.skipNull&&null===n||e.skipEmptyString&&""===n?r:null===n?[...r,a(t,e)]:[...r,[a(t,e),"=",a(n,e)].join("")]}}(t),i={};for(const t of Object.keys(e))r(t)||(i[t]=e[t]);const s=Object.keys(i);return!1!==t.sort&&s.sort(t.sort),s.map((r=>{const i=e[r];return void 0===i?"":null===i?a(r,t):Array.isArray(i)?0===i.length&&"bracket-separator"===t.arrayFormat?a(r,t)+"[]":i.reduce(n(r),[]).join("&"):a(r,t)+"="+a(i,t)})).filter((e=>e.length>0)).join("&")},e.parseUrl=(e,t)=>{t=Object.assign({decode:!0},t);const[r,i]=n(e,"#");return Object.assign({url:r.split("?")[0]||"",query:p(l(e),t)},t&&t.parseFragmentIdentifier&&i?{fragmentIdentifier:c(i,t)}:{})},e.stringifyUrl=(t,r)=>{r=Object.assign({encode:!0,strict:!0,[s]:!0},r);const n=h(t.url).split("?")[0]||"",i=e.extract(t.url),o=e.parse(i,{sort:!1}),c=Object.assign(o,t.query);let u=e.stringify(c,r);u&&(u=`?${u}`);let l=function(e){let t="";const r=e.indexOf("#");return-1!==r&&(t=e.slice(r)),t}(t.url);return t.fragmentIdentifier&&(l=`#${r[s]?a(t.fragmentIdentifier,r):t.fragmentIdentifier}`),`${n}${u}${l}`},e.pick=(t,r,n)=>{n=Object.assign({parseFragmentIdentifier:!0,[s]:!1},n);const{url:o,query:a,fragmentIdentifier:c}=e.parseUrl(t,n);return e.stringifyUrl({url:o,query:i(a,r),fragmentIdentifier:c},n)},e.exclude=(t,r,n)=>{const i=Array.isArray(r)?e=>!r.includes(e):(e,t)=>!r(e,t);return e.pick(t,i,n)}}(Er);const Rr={waku:{publish:"waku_publish",batchPublish:"waku_batchPublish",subscribe:"waku_subscribe",batchSubscribe:"waku_batchSubscribe",subscription:"waku_subscription",unsubscribe:"waku_unsubscribe",batchUnsubscribe:"waku_batchUnsubscribe"},irn:{publish:"irn_publish",batchPublish:"irn_batchPublish",subscribe:"irn_subscribe",batchSubscribe:"irn_batchSubscribe",subscription:"irn_subscription",unsubscribe:"irn_unsubscribe",batchUnsubscribe:"irn_batchUnsubscribe"},iridium:{publish:"iridium_publish",batchPublish:"iridium_batchPublish",subscribe:"iridium_subscribe",batchSubscribe:"iridium_batchSubscribe",subscription:"iridium_subscription",unsubscribe:"iridium_unsubscribe",batchUnsubscribe:"iridium_batchUnsubscribe"}};function jr(e,t){return e.includes(":")?[e]:t.chains||[]}const Lr="base10",Ur="base16",Mr="base64pad",Dr="utf8",kr=0,zr=1,$r=0,qr=1,Hr=12,Kr=32;function Vr(){return St(q.randomBytes(Kr),Ur)}function Br(e){return St(W.hash(Et(e,Dr)),Ur)}function Fr(e){return Number(St(e,Lr))}function Gr(e){const t=function(e){return Et(`${e}`,Lr)}(typeof e.type<"u"?e.type:kr);if(Fr(t)===zr&&typeof e.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const r=typeof e.senderPublicKey<"u"?Et(e.senderPublicKey,Ur):void 0,n=typeof e.iv<"u"?Et(e.iv,Ur):q.randomBytes(Hr);return function(e){if(Fr(e.type)===zr){if(typeof e.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return St(Z([e.type,e.senderPublicKey,e.iv,e.sealed]),Mr)}return St(Z([e.type,e.iv,e.sealed]),Mr)}({type:t,sealed:new s.ChaCha20Poly1305(Et(e.symKey,Ur)).seal(n,Et(e.message,Dr)),iv:n,senderPublicKey:r})}function Wr(e){const t=Et(e,Mr),r=t.slice($r,qr),n=qr;if(Fr(r)===zr){const e=n+Kr,i=e+Hr,s=t.slice(n,e),o=t.slice(e,i);return{type:r,sealed:t.slice(i),iv:o,senderPublicKey:s}}const i=n+Hr,s=t.slice(n,i);return{type:r,sealed:t.slice(i),iv:s}}function Yr(e){const t=e?.type||kr;if(t===zr){if(typeof e?.senderPublicKey>"u")throw new Error("missing sender public key");if(typeof e?.receiverPublicKey>"u")throw new Error("missing receiver public key")}return{type:t,senderPublicKey:e?.senderPublicKey,receiverPublicKey:e?.receiverPublicKey}}function Jr(e){return e.type===zr&&"string"==typeof e.senderPublicKey&&"string"==typeof e.receiverPublicKey}var Xr=Object.defineProperty,Zr=Object.getOwnPropertySymbols,Qr=Object.prototype.hasOwnProperty,en=Object.prototype.propertyIsEnumerable,tn=(e,t,r)=>t in e?Xr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,rn=(e,t)=>{for(var r in t||(t={}))Qr.call(t,r)&&tn(e,r,t[r]);if(Zr)for(var r of Zr(t))en.call(t,r)&&tn(e,r,t[r]);return e};const nn="ReactNative",sn={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},on="js";function an(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function cn(){return!yr()&&!!vr()&&navigator.product===nn}function un(){return!an()&&!!vr()}function hn(){return cn()?sn.reactNative:an()?sn.node:un()?sn.browser:sn.unknown}function ln(e,t,r){const n=function(){if(hn()===sn.reactNative&&typeof global<"u"&&typeof(null==global?void 0:global.Platform)<"u"){const{OS:e,Version:t}=global.Platform;return[e,t].join("-")}const e=Lt();if(null===e)return"unknown";const t=e.os?e.os.replace(" ","").toLowerCase():"unknown";return"browser"===e.type?[t,e.name,e.version].join("-"):[t,e.version].join("-")}(),i=function(){var e;const t=hn();return t===sn.browser?[t,(null==(e=_r())?void 0:e.host)||"unknown"].join(":"):t}();return[[e,t].join("-"),[on,r].join("-"),n,i].join("/")}function fn({protocol:e,version:t,relayUrl:r,sdkVersion:n,auth:i,projectId:s,useOnCloseEvent:o}){const a=r.split("?"),c={auth:i,ua:ln(e,t,n),projectId:s,useOnCloseEvent:o||void 0},u=function(e,t){let r=Er.parse(e);return r=rn(rn({},r),t),Er.stringify(r)}(a[1]||"",c);return a[0]+"?"+u}function pn(e,t){return e.filter((e=>t.includes(e))).length===e.length}function dn(e){return Object.fromEntries(e.entries())}function gn(e){return new Map(Object.entries(e))}function yn(e=Mt.FIVE_MINUTES,t){const r=Mt.toMiliseconds(e||Mt.FIVE_MINUTES);let n,i,s;return{resolve:e=>{s&&n&&(clearTimeout(s),n(e))},reject:e=>{s&&i&&(clearTimeout(s),i(e))},done:()=>new Promise(((e,o)=>{s=setTimeout((()=>{o(new Error(t))}),r),n=e,i=o}))}}function vn(e,t,r){return new Promise((async(n,i)=>{const s=setTimeout((()=>i(new Error(r))),t);try{n(await e)}catch(e){i(e)}clearTimeout(s)}))}function _n(e,t){if("string"==typeof t&&t.startsWith(`${e}:`))return t;if("topic"===e.toLowerCase()){if("string"!=typeof t)throw new Error('Value must be "string" for expirer target type: topic');return`topic:${t}`}if("id"===e.toLowerCase()){if("number"!=typeof t)throw new Error('Value must be "number" for expirer target type: id');return`id:${t}`}throw new Error(`Unknown expirer target type: ${e}`)}function mn(e){const[t,r]=e.split(":"),n={id:void 0,topic:void 0};if("topic"===t&&"string"==typeof r)n.topic=r;else{if("id"!==t||!Number.isInteger(Number(r)))throw new Error(`Invalid target, expected id:number or topic:string, got ${t}:${r}`);n.id=Number(r)}return n}function wn(e,t){return Mt.fromMiliseconds((t||Date.now())+Mt.toMiliseconds(e))}function bn(e){return Date.now()>=Mt.toMiliseconds(e)}function En(e,t){return`${e}${t?`:${t}`:""}`}function Sn(e=[],t=[]){return[...new Set([...e,...t])]}function In(e){return e?.relay||{protocol:"irn"}}function On(e){const t=Rr[e];if(typeof t>"u")throw new Error(`Relay Protocol not supported: ${e}`);return t}var Pn=Object.defineProperty,Nn=Object.getOwnPropertySymbols,An=Object.prototype.hasOwnProperty,xn=Object.prototype.propertyIsEnumerable,Cn=(e,t,r)=>t in e?Pn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;function Tn(e,t="-"){const r={},n="relay"+t;return Object.keys(e).forEach((t=>{if(t.startsWith(n)){const i=t.replace(n,""),s=e[t];r[i]=s}})),r}function Rn(e){return e.startsWith("//")?e.substring(2):e}function jn(e){return`${e.protocol}:${e.topic}@${e.version}?`+Er.stringify(((e,t)=>{for(var r in t||(t={}))An.call(t,r)&&Cn(e,r,t[r]);if(Nn)for(var r of Nn(t))xn.call(t,r)&&Cn(e,r,t[r]);return e})({symKey:e.symKey},function(e,t="-"){const r={};return Object.keys(e).forEach((n=>{const i="relay"+t+n;e[n]&&(r[i]=e[n])})),r}(e.relay)))}function Ln(e){const t=[];return e.forEach((e=>{const[r,n]=e.split(":");t.push(`${r}:${n}`)})),t}function Un(e){return e.includes(":")}function Mn(e){return Un(e)?e.split(":")[0]:e}const Dn={INVALID_METHOD:{message:"Invalid method.",code:1001},INVALID_EVENT:{message:"Invalid event.",code:1002},INVALID_UPDATE_REQUEST:{message:"Invalid update request.",code:1003},INVALID_EXTEND_REQUEST:{message:"Invalid extend request.",code:1004},INVALID_SESSION_SETTLE_REQUEST:{message:"Invalid session settle request.",code:1005},UNAUTHORIZED_METHOD:{message:"Unauthorized method.",code:3001},UNAUTHORIZED_EVENT:{message:"Unauthorized event.",code:3002},UNAUTHORIZED_UPDATE_REQUEST:{message:"Unauthorized update request.",code:3003},UNAUTHORIZED_EXTEND_REQUEST:{message:"Unauthorized extend request.",code:3004},USER_REJECTED:{message:"User rejected.",code:5e3},USER_REJECTED_CHAINS:{message:"User rejected chains.",code:5001},USER_REJECTED_METHODS:{message:"User rejected methods.",code:5002},USER_REJECTED_EVENTS:{message:"User rejected events.",code:5003},UNSUPPORTED_CHAINS:{message:"Unsupported chains.",code:5100},UNSUPPORTED_METHODS:{message:"Unsupported methods.",code:5101},UNSUPPORTED_EVENTS:{message:"Unsupported events.",code:5102},UNSUPPORTED_ACCOUNTS:{message:"Unsupported accounts.",code:5103},UNSUPPORTED_NAMESPACE_KEY:{message:"Unsupported namespace key.",code:5104},USER_DISCONNECTED:{message:"User disconnected.",code:6e3},SESSION_SETTLEMENT_FAILED:{message:"Session settlement failed.",code:7e3},WC_METHOD_UNSUPPORTED:{message:"Unsupported wc_ method.",code:10001}},kn={NOT_INITIALIZED:{message:"Not initialized.",code:1},NO_MATCHING_KEY:{message:"No matching key.",code:2},RESTORE_WILL_OVERRIDE:{message:"Restore will override.",code:3},RESUBSCRIBED:{message:"Resubscribed.",code:4},MISSING_OR_INVALID:{message:"Missing or invalid.",code:5},EXPIRED:{message:"Expired.",code:6},UNKNOWN_TYPE:{message:"Unknown type.",code:7},MISMATCHED_TOPIC:{message:"Mismatched topic.",code:8},NON_CONFORMING_NAMESPACES:{message:"Non conforming namespaces.",code:9}};function zn(e,t){const{message:r,code:n}=kn[e];return{message:t?`${r} ${t}`:r,code:n}}function $n(e,t){const{message:r,code:n}=Dn[e];return{message:t?`${r} ${t}`:r,code:n}}function qn(e,t){return!!Array.isArray(e)&&(!(typeof t<"u"&&e.length)||e.every(t))}function Hn(e){return Object.getPrototypeOf(e)===Object.prototype&&Object.keys(e).length}function Kn(e){return typeof e>"u"}function Vn(e,t){return!(!t||!Kn(e))||"string"==typeof e&&!!e.trim().length}function Bn(e,t){return!(!t||!Kn(e))||"number"==typeof e&&!isNaN(e)}function Fn(e){return!(!Vn(e,!1)||!e.includes(":"))&&2===e.split(":").length}function Gn(e){let t=!0;return qn(e)?e.length&&(t=e.every((e=>Vn(e,!1)))):t=!1,t}function Wn(e,t,r){let n=null;return Object.entries(e).forEach((([e,i])=>{if(n)return;const s=function(e,t,r){let n=null;return qn(t)&&t.length?t.forEach((e=>{n||Fn(e)||(n=$n("UNSUPPORTED_CHAINS",`${r}, chain ${e} should be a string and conform to "namespace:chainId" format`))})):Fn(e)||(n=$n("UNSUPPORTED_CHAINS",`${r}, chains must be defined as "namespace:chainId" e.g. "eip155:1": {...} in the namespace key OR as an array of CAIP-2 chainIds e.g. eip155: { chains: ["eip155:1", "eip155:5"] }`)),n}(e,jr(e,i),`${t} ${r}`);s&&(n=s)})),n}function Yn(e,t){let r=null;return qn(e)?e.forEach((e=>{r||function(e){if(Vn(e,!1)&&e.includes(":")){const t=e.split(":");if(3===t.length){const e=t[0]+":"+t[1];return!!t[2]&&Fn(e)}}return!1}(e)||(r=$n("UNSUPPORTED_ACCOUNTS",`${t}, account ${e} should be a string and conform to "namespace:chainId:address" format`))})):r=$n("UNSUPPORTED_ACCOUNTS",`${t}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),r}function Jn(e,t){let r=null;return Object.values(e).forEach((e=>{if(r)return;const n=function(e,t){let r=null;return Gn(e?.methods)?Gn(e?.events)||(r=$n("UNSUPPORTED_EVENTS",`${t}, events should be an array of strings or empty array for no events`)):r=$n("UNSUPPORTED_METHODS",`${t}, methods should be an array of strings or empty array for no methods`),r}(e,`${t}, namespace`);n&&(r=n)})),r}function Xn(e,t){let r=null;if(e&&Hn(e)){const n=Jn(e,t);n&&(r=n);const i=function(e,t){let r=null;return Object.values(e).forEach((e=>{if(r)return;const n=Yn(e?.accounts,`${t} namespace`);n&&(r=n)})),r}(e,t);i&&(r=i)}else r=zn("MISSING_OR_INVALID",`${t}, namespaces should be an object with data`);return r}function Zn(e){return Vn(e.protocol,!0)}function Qn(e){return typeof e<"u"&&null!==typeof e}function ei(e,t){return!(!Fn(t)||!function(e){const t=[];return Object.values(e).forEach((e=>{t.push(...Ln(e.accounts))})),t}(e).includes(t))}function ti(e,t,r){return!!Vn(r,!1)&&function(e,t){const r=[];return Object.values(e).forEach((e=>{Ln(e.accounts).includes(t)&&r.push(...e.methods)})),r}(e,t).includes(r)}function ri(e,t,r){return!!Vn(r,!1)&&function(e,t){const r=[];return Object.values(e).forEach((e=>{Ln(e.accounts).includes(t)&&r.push(...e.events)})),r}(e,t).includes(r)}function ni(e,t,r){let n=null;const i=function(e){const t={};return Object.keys(e).forEach((r=>{var n;r.includes(":")?t[r]=e[r]:null==(n=e[r].chains)||n.forEach((n=>{t[n]={methods:e[r].methods,events:e[r].events}}))})),t}(e),s=function(e){const t={};return Object.keys(e).forEach((r=>{if(r.includes(":"))t[r]=e[r];else{const n=Ln(e[r].accounts);n?.forEach((n=>{t[n]={accounts:e[r].accounts.filter((e=>e.includes(`${n}:`))),methods:e[r].methods,events:e[r].events}}))}})),t}(t),o=Object.keys(i),a=Object.keys(s),c=ii(Object.keys(e)),u=ii(Object.keys(t)),h=c.filter((e=>!u.includes(e)));return h.length&&(n=zn("NON_CONFORMING_NAMESPACES",`${r} namespaces keys don't satisfy requiredNamespaces.\n Required: ${h.toString()}\n Received: ${Object.keys(t).toString()}`)),pn(o,a)||(n=zn("NON_CONFORMING_NAMESPACES",`${r} namespaces chains don't satisfy required namespaces.\n Required: ${o.toString()}\n Approved: ${a.toString()}`)),Object.keys(t).forEach((e=>{if(!e.includes(":")||n)return;const i=Ln(t[e].accounts);i.includes(e)||(n=zn("NON_CONFORMING_NAMESPACES",`${r} namespaces accounts don't satisfy namespace accounts for ${e}\n Required: ${e}\n Approved: ${i.toString()}`))})),o.forEach((e=>{n||(pn(i[e].methods,s[e].methods)?pn(i[e].events,s[e].events)||(n=zn("NON_CONFORMING_NAMESPACES",`${r} namespaces events don't satisfy namespace events for ${e}`)):n=zn("NON_CONFORMING_NAMESPACES",`${r} namespaces methods don't satisfy namespace methods for ${e}`))})),n}function ii(e){return[...new Set(e.map((e=>e.includes(":")?e.split(":")[0]:e)))]}var si={},oi={};Object.defineProperty(oi,"__esModule",{value:!0}),oi.safeJsonParse=function(e){if("string"!=typeof e)throw new Error("Cannot safe json parse value of type "+typeof e);try{return JSON.parse(e)}catch(t){return e}},oi.safeJsonStringify=function(e){return"string"==typeof e?e:JSON.stringify(e,((e,t)=>void 0===t?null:t))};var ai,ci={exports:{}};var ui,hi={},li={};var fi,pi,di={};Object.defineProperty(si,"__esModule",{value:!0}),si.KeyValueStorage=void 0;const gi=Ft,yi=oi,vi=gi.__importDefault((ai||(ai=1,function(){let e;function t(){}e=t,e.prototype.getItem=function(e){return this.hasOwnProperty(e)?String(this[e]):null},e.prototype.setItem=function(e,t){this[e]=String(t)},e.prototype.removeItem=function(e){delete this[e]},e.prototype.clear=function(){const e=this;Object.keys(e).forEach((function(t){e[t]=void 0,delete e[t]}))},e.prototype.key=function(e){return e=e||0,Object.keys(this)[e]},e.prototype.__defineGetter__("length",(function(){return Object.keys(this).length})),void 0!==r.commonjsGlobal&&r.commonjsGlobal.localStorage?ci.exports=r.commonjsGlobal.localStorage:"undefined"!=typeof window&&window.localStorage?ci.exports=window.localStorage:ci.exports=new t}()),ci.exports)),_i=(pi||(pi=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});const t=Ft;t.__exportStar((ui||(ui=1,Object.defineProperty(li,"__esModule",{value:!0}),li.IKeyValueStorage=void 0,li.IKeyValueStorage=class{}),li),e),t.__exportStar(function(){if(fi)return di;fi=1,Object.defineProperty(di,"__esModule",{value:!0}),di.parseEntry=void 0;const e=oi;return di.parseEntry=function(t){var r;return[t[0],e.safeJsonParse(null!==(r=t[1])&&void 0!==r?r:"")]},di}(),e)}(hi)),hi);class mi{constructor(){this.localStorage=vi.default}getKeys(){return gi.__awaiter(this,void 0,void 0,(function*(){return Object.keys(this.localStorage)}))}getEntries(){return gi.__awaiter(this,void 0,void 0,(function*(){return Object.entries(this.localStorage).map(_i.parseEntry)}))}getItem(e){return gi.__awaiter(this,void 0,void 0,(function*(){const t=this.localStorage.getItem(e);if(null!==t)return yi.safeJsonParse(t)}))}setItem(e,t){return gi.__awaiter(this,void 0,void 0,(function*(){this.localStorage.setItem(e,yi.safeJsonStringify(t))}))}removeItem(e){return gi.__awaiter(this,void 0,void 0,(function*(){this.localStorage.removeItem(e)}))}}si.KeyValueStorage=mi;var wi=si.default=mi,bi={},Ei={},Si={},Ii={};class Oi{}var Pi,Ni,Ai=Object.freeze({__proto__:null,IEvents:Oi}),xi=r.getAugmentedNamespace(Ai);function Ci(){return Ni||(Ni=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});Ft.__exportStar(function(){if(Pi)return Ii;Pi=1,Object.defineProperty(Ii,"__esModule",{value:!0}),Ii.IHeartBeat=void 0;const e=xi;class t extends e.IEvents{constructor(e){super()}}return Ii.IHeartBeat=t,Ii}(),e)}(Si)),Si}var Ti,Ri,ji,Li={},Ui={};function Mi(){return Ri||(Ri=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});Ft.__exportStar(function(){if(Ti)return Ui;Ti=1,Object.defineProperty(Ui,"__esModule",{value:!0}),Ui.HEARTBEAT_EVENTS=Ui.HEARTBEAT_INTERVAL=void 0;const e=Mt;return Ui.HEARTBEAT_INTERVAL=e.FIVE_SECONDS,Ui.HEARTBEAT_EVENTS={pulse:"heartbeat_pulse"},Ui}(),e)}(Li)),Li}!function(e){Object.defineProperty(e,"__esModule",{value:!0});const t=Ft;t.__exportStar(function(){if(ji)return Ei;ji=1,Object.defineProperty(Ei,"__esModule",{value:!0}),Ei.HeartBeat=void 0;const e=Ft,t=i.default,r=Mt,n=Ci(),s=Mi();class o extends n.IHeartBeat{constructor(e){super(e),this.events=new t.EventEmitter,this.interval=s.HEARTBEAT_INTERVAL,this.interval=(null==e?void 0:e.interval)||s.HEARTBEAT_INTERVAL}static init(t){return e.__awaiter(this,void 0,void 0,(function*(){const e=new o(t);return yield e.init(),e}))}init(){return e.__awaiter(this,void 0,void 0,(function*(){yield this.initialize()}))}stop(){clearInterval(this.intervalRef)}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}initialize(){return e.__awaiter(this,void 0,void 0,(function*(){this.intervalRef=setInterval((()=>this.pulse()),r.toMiliseconds(this.interval))}))}pulse(){this.events.emit(s.HEARTBEAT_EVENTS.pulse)}}return Ei.HeartBeat=o,Ei}(),e),t.__exportStar(Ci(),e),t.__exportStar(Mi(),e)}(bi);var Di,ki,zi,$i,qi={};function Hi(){if($i)return zi;$i=1;const e=function(){if(ki)return Di;function e(e){try{return JSON.stringify(e)}catch(e){return'"[Circular]"'}}return ki=1,Di=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<s;a++)o[a]=i(r[a]);return o.join(" ")}if("string"!=typeof t)return t;var c=r.length;if(0===c)return t;for(var u="",h=0,l=-1,f=t&&t.length||0,p=0;p<f;){if(37===t.charCodeAt(p)&&p+1<f){switch(l=l>-1?l:0,t.charCodeAt(p+1)){case 100:case 102:if(h>=c)break;if(null==r[h])break;l<p&&(u+=t.slice(l,p)),u+=Number(r[h]),l=p+2,p++;break;case 105:if(h>=c)break;if(null==r[h])break;l<p&&(u+=t.slice(l,p)),u+=Math.floor(Number(r[h])),l=p+2,p++;break;case 79:case 111:case 106:if(h>=c)break;if(void 0===r[h])break;l<p&&(u+=t.slice(l,p));var d=typeof r[h];if("string"===d){u+="'"+r[h]+"'",l=p+2,p++;break}if("function"===d){u+=r[h].name||"<anonymous>",l=p+2,p++;break}u+=i(r[h]),l=p+2,p++;break;case 115:if(h>=c)break;l<p&&(u+=t.slice(l,p)),u+=String(r[h]),l=p+2,p++;break;case 37:l<p&&(u+=t.slice(l,p)),u+="%",l=p+2,p++,h--}++h}++p}return-1===l?t:(l<f&&(u+=t.slice(l)),u)},Di}();zi=n;const t=function(){function e(e){return void 0!==e&&e}try{return"undefined"!=typeof globalThis||Object.defineProperty(Object.prototype,"globalThis",{get:function(){return delete Object.prototype.globalThis,this.globalThis=this},configurable:!0}),globalThis}catch(t){return e(self)||e(window)||e(this)||{}}}().console||{},r={mapHttpRequest:u,mapHttpResponse:u,wrapRequestSerializer:h,wrapResponseSerializer:h,wrapErrorSerializer:h,req:u,res:u,err:function(e){const t={type:e.constructor.name,msg:e.message,stack:e.stack};for(const r in e)void 0===t[r]&&(t[r]=e[r]);return t}};function n(e){(e=e||{}).browser=e.browser||{};const r=e.browser.transmit;if(r&&"function"!=typeof r.send)throw Error("pino: transmit option must have a send function");const u=e.browser.write||t;e.browser.write&&(e.browser.asObject=!0);const h=e.serializers||{},f=function(e,t){if(Array.isArray(e)){const t=e.filter((function(e){return"!stdSerializers.err"!==e}));return t}return!0===e&&Object.keys(t)}(e.browser.serialize,h);let p=e.browser.serialize;Array.isArray(e.browser.serialize)&&e.browser.serialize.indexOf("!stdSerializers.err")>-1&&(p=!1);"function"==typeof u&&(u.error=u.fatal=u.warn=u.info=u.debug=u.trace=u),!1===e.enabled&&(e.level="silent");const d=e.level||"info",g=Object.create(u);g.log||(g.log=l),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(e){if("silent"!==e&&!this.levels.values[e])throw Error("unknown level "+e);this._level=e,i(y,g,"error","log"),i(y,g,"fatal","error"),i(y,g,"warn","error"),i(y,g,"info","log"),i(y,g,"debug","log"),i(y,g,"trace","log")}});const y={transmit:r,serialize:f,asObject:e.browser.asObject,levels:["error","fatal","warn","info","debug","trace"],timestamp:c(e)};return g.levels=n.levels,g.level=d,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=l,g.serializers=h,g._serialize=f,g._stdErrSerialize=p,g.child=function(t,n){if(!t)throw new Error("missing bindings for child Pino");n=n||{},f&&t.serializers&&(n.serializers=t.serializers);const i=n.serializers;if(f&&i){var c=Object.assign({},h,i),u=!0===e.browser.serialize?Object.keys(c):f;delete t.serializers,s([t],u,c,this._stdErrSerialize)}function l(e){this._childLevel=1+(0|e._childLevel),this.error=o(e,t,"error"),this.fatal=o(e,t,"fatal"),this.warn=o(e,t,"warn"),this.info=o(e,t,"info"),this.debug=o(e,t,"debug"),this.trace=o(e,t,"trace"),c&&(this.serializers=c,this._serialize=u),r&&(this._logEvent=a([].concat(e._logEvent.bindings,t)))}return l.prototype=this,new l(this)},r&&(g._logEvent=a()),g}function i(r,i,o,c){const u=Object.getPrototypeOf(i);i[o]=i.levelVal>i.levels.values[o]?l:u[o]?u[o]:t[o]||t[c]||l,function(r,i,o){if(!r.transmit&&i[o]===l)return;i[o]=(c=i[o],function(){const u=r.timestamp(),h=new Array(arguments.length),l=Object.getPrototypeOf&&Object.getPrototypeOf(this)===t?t:this;for(var f=0;f<h.length;f++)h[f]=arguments[f];if(r.serialize&&!r.asObject&&s(h,this._serialize,this.serializers,this._stdErrSerialize),r.asObject?c.call(l,function(t,r,i,o){t._serialize&&s(i,t._serialize,t.serializers,t._stdErrSerialize);const a=i.slice();let c=a[0];const u={};o&&(u.time=o),u.level=n.levels.values[r];let h=1+(0|t._childLevel);if(h<1&&(h=1),null!==c&&"object"==typeof c){for(;h--&&"object"==typeof a[0];)Object.assign(u,a.shift());c=a.length?e(a.shift(),a):void 0}else"string"==typeof c&&(c=e(a.shift(),a));return void 0!==c&&(u.msg=c),u}(this,o,h,u)):c.apply(l,h),r.transmit){const e=r.transmit.level||i.level,t=n.levels.values[e],c=n.levels.values[o];if(c<t)return;!function(e,t,r){const n=t.send,i=t.ts,o=t.methodLevel,c=t.methodValue,u=t.val,h=e._logEvent.bindings;s(r,e._serialize||Object.keys(e.serializers),e.serializers,void 0===e._stdErrSerialize||e._stdErrSerialize),e._logEvent.ts=i,e._logEvent.messages=r.filter((function(e){return-1===h.indexOf(e)})),e._logEvent.level.label=o,e._logEvent.level.value=c,n(o,e._logEvent,u),e._logEvent=a(h)}(this,{ts:u,methodLevel:o,methodValue:c,transmitLevel:e,transmitValue:n.levels.values[r.transmit.level||i.level],send:r.transmit.send,val:i.levelVal},h)}});var c}(r,i,o)}function s(e,t,r,i){for(const s in e)if(i&&e[s]instanceof Error)e[s]=n.stdSerializers.err(e[s]);else if("object"==typeof e[s]&&!Array.isArray(e[s]))for(const n in e[s])t&&t.indexOf(n)>-1&&n in r&&(e[s][n]=r[n](e[s][n]))}function o(e,t,r){return function(){const n=new Array(1+arguments.length);n[0]=t;for(var i=1;i<n.length;i++)n[i]=arguments[i-1];return e[r].apply(this,n)}}function a(e){return{ts:0,messages:[],bindings:e||[],level:{label:"",value:0}}}function c(e){return"function"==typeof e.timestamp?e.timestamp:!1===e.timestamp?f:p}function u(){return{}}function h(e){return e}function l(){}function f(){return!1}function p(){return Date.now()}return n.levels={values:{fatal:60,error:50,warn:40,info:30,debug:20,trace:10},labels:{10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"}},n.stdSerializers=r,n.stdTimeFunctions=Object.assign({},{nullTime:f,epochTime:p,unixTime:function(){return Math.round(Date.now()/1e3)},isoTime:function(){return new Date(Date.now()).toISOString()}}),zi}var Ki,Vi={};function Bi(){return Ki||(Ki=1,Object.defineProperty(Vi,"__esModule",{value:!0}),Vi.PINO_CUSTOM_CONTEXT_KEY=Vi.PINO_LOGGER_DEFAULTS=void 0,Vi.PINO_LOGGER_DEFAULTS={level:"info"},Vi.PINO_CUSTOM_CONTEXT_KEY="custom_context"),Vi}var Fi,Gi={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.pino=void 0;const t=Ft,r=t.__importDefault(Hi());Object.defineProperty(e,"pino",{enumerable:!0,get:function(){return r.default}}),t.__exportStar(Bi(),e),t.__exportStar(function(){if(Fi)return Gi;Fi=1,Object.defineProperty(Gi,"__esModule",{value:!0}),Gi.generateChildLogger=Gi.formatChildLoggerContext=Gi.getLoggerContext=Gi.setBrowserLoggerContext=Gi.getBrowserLoggerContext=Gi.getDefaultLoggerOptions=void 0;const e=Bi();function t(t,r=e.PINO_CUSTOM_CONTEXT_KEY){return t[r]||""}function r(t,r,n=e.PINO_CUSTOM_CONTEXT_KEY){return t[n]=r,t}function n(r,n=e.PINO_CUSTOM_CONTEXT_KEY){let i="";return i=void 0===r.bindings?t(r,n):r.bindings().context||"",i}function i(t,r,i=e.PINO_CUSTOM_CONTEXT_KEY){const s=n(t,i);return s.trim()?`${s}/${r}`:r}return Gi.getDefaultLoggerOptions=function(t){return Object.assign(Object.assign({},t),{level:(null==t?void 0:t.level)||e.PINO_LOGGER_DEFAULTS.level})},Gi.getBrowserLoggerContext=t,Gi.setBrowserLoggerContext=r,Gi.getLoggerContext=n,Gi.formatChildLoggerContext=i,Gi.generateChildLogger=function(t,n,s=e.PINO_CUSTOM_CONTEXT_KEY){const o=i(t,n,s);return r(t.child({context:o}),o,s)},Gi}(),e)}(qi);class Wi extends Oi{constructor(e){super(),this.opts=e,this.protocol="wc",this.version=2}}class Yi extends Oi{constructor(e,t){super(),this.core=e,this.logger=t,this.records=new Map}}class Ji{constructor(e,t){this.logger=e,this.core=t}}class Xi extends Oi{constructor(e,t){super(),this.relayer=e,this.logger=t}}class Zi extends Oi{constructor(e){super()}}class Qi{constructor(e,t,r,n){this.core=e,this.logger=t,this.name=r}}class es extends Oi{constructor(e,t){super(),this.relayer=e,this.logger=t}}class ts extends Oi{constructor(e,t){super(),this.core=e,this.logger=t}}class rs{constructor(e,t){this.projectId=e,this.logger=t}}class ns{constructor(e){this.opts=e,this.protocol="wc",this.version=2}}class is{constructor(e){this.client=e}}const ss=e=>JSON.stringify(e,((e,t)=>"bigint"==typeof t?t.toString()+"n":t));function os(e){if("string"!=typeof e)throw new Error("Cannot safe json parse value of type "+typeof e);try{return(e=>{const t=e.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(t,((e,t)=>"string"==typeof t&&t.match(/^\d+n$/)?BigInt(t.substring(0,t.length-1)):t))})(e)}catch(t){return e}}function as(e){return"string"==typeof e?e:ss(e)||""}var cs={},us={};!function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=a,r=w;e.DIGEST_LENGTH=64,e.BLOCK_SIZE=128;var n=function(){function n(){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 n.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},n.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},n.prototype.clean=function(){r.wipe(this._buffer),r.wipe(this._tempHi),r.wipe(this._tempLo),this.reset()},n.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._bufferLength<e.BLOCK_SIZE&&r>0;)this._buffer[this._bufferLength++]=t[n++],r--;this._bufferLength===this.blockSize&&(s(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,this.blockSize),this._bufferLength=0)}for(r>=this.blockSize&&(n=s(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},n.prototype.finish=function(e){if(!this._finished){var r=this._bytesHashed,n=this._bufferLength,i=r/536870912|0,o=r<<3,a=r%128<112?128:256;this._buffer[n]=128;for(var c=n+1;c<a-8;c++)this._buffer[c]=0;t.writeUint32BE(i,this._buffer,a-8),t.writeUint32BE(o,this._buffer,a-4),s(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,a),this._finished=!0}for(c=0;c<this.digestLength/8;c++)t.writeUint32BE(this._stateHi[c],e,8*c),t.writeUint32BE(this._stateLo[c],e,8*c+4);return this},n.prototype.digest=function(){var e=new Uint8Array(this.digestLength);return this.finish(e),e},n.prototype.saveState=function(){if(this._finished)throw new Error("SHA256: cannot save finished state");return{stateHi:new Int32Array(this._stateHi),stateLo:new Int32Array(this._stateLo),buffer:this._bufferLength>0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},n.prototype.restoreState=function(e){return this._stateHi.set(e.stateHi),this._stateLo.set(e.stateLo),this._bufferLength=e.bufferLength,e.buffer&&this._buffer.set(e.buffer),this._bytesHashed=e.bytesHashed,this._finished=!1,this},n.prototype.cleanSavedState=function(e){r.wipe(e.stateHi),r.wipe(e.stateLo),e.buffer&&r.wipe(e.buffer),e.bufferLength=0,e.bytesHashed=0},n}();e.SHA512=n;var i=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 s(e,r,n,s,o,a,c){for(var u,h,l,f,p,d,g,y,v=n[0],_=n[1],m=n[2],w=n[3],b=n[4],E=n[5],S=n[6],I=n[7],O=s[0],P=s[1],N=s[2],A=s[3],x=s[4],C=s[5],T=s[6],R=s[7];c>=128;){for(var j=0;j<16;j++){var L=8*j+a;e[j]=t.readUint32BE(o,L),r[j]=t.readUint32BE(o,L+4)}for(j=0;j<80;j++){var U,M,D=v,k=_,z=m,$=w,q=b,H=E,K=S,V=O,B=P,F=N,G=A,W=x,Y=C,J=T;if(p=65535&(h=R),d=h>>>16,g=65535&(u=I),y=u>>>16,p+=65535&(h=(x>>>14|b<<18)^(x>>>18|b<<14)^(b>>>9|x<<23)),d+=h>>>16,g+=65535&(u=(b>>>14|x<<18)^(b>>>18|x<<14)^(x>>>9|b<<23)),y+=u>>>16,p+=65535&(h=x&C^~x&T),d+=h>>>16,g+=65535&(u=b&E^~b&S),y+=u>>>16,u=i[2*j],p+=65535&(h=i[2*j+1]),d+=h>>>16,g+=65535&u,y+=u>>>16,u=e[j%16],d+=(h=r[j%16])>>>16,g+=65535&u,y+=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|(y+=g>>>16)<<16),y=u>>>16,p+=65535&(h=(O>>>28|v<<4)^(v>>>2|O<<30)^(v>>>7|O<<25)),d+=h>>>16,g+=65535&(u=(v>>>28|O<<4)^(O>>>2|v<<30)^(O>>>7|v<<25)),y+=u>>>16,d+=(h=O&P^O&N^P&N)>>>16,g+=65535&(u=v&_^v&m^_&m),y+=u>>>16,U=65535&(g+=(d+=(p+=65535&h)>>>16)>>>16)|(y+=g>>>16)<<16,M=65535&p|d<<16,p=65535&(h=G),d=h>>>16,g=65535&(u=$),y=u>>>16,d+=(h=f)>>>16,g+=65535&(u=l),y+=u>>>16,_=D,m=k,w=z,b=$=65535&(g+=(d+=(p+=65535&h)>>>16)>>>16)|(y+=g>>>16)<<16,E=q,S=H,I=K,v=U,P=V,N=B,A=F,x=G=65535&p|d<<16,C=W,T=Y,R=J,O=M,j%16==15)for(L=0;L<16;L++)u=e[L],p=65535&(h=r[L]),d=h>>>16,g=65535&u,y=u>>>16,u=e[(L+9)%16],p+=65535&(h=r[(L+9)%16]),d+=h>>>16,g+=65535&u,y+=u>>>16,l=e[(L+1)%16],p+=65535&(h=((f=r[(L+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),y+=u>>>16,l=e[(L+14)%16],d+=(h=((f=r[(L+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),y+=u>>>16,y+=(g+=(d+=(p+=65535&h)>>>16)>>>16)>>>16,e[L]=65535&g|y<<16,r[L]=65535&p|d<<16}p=65535&(h=O),d=h>>>16,g=65535&(u=v),y=u>>>16,u=n[0],d+=(h=s[0])>>>16,g+=65535&u,y+=u>>>16,y+=(g+=(d+=(p+=65535&h)>>>16)>>>16)>>>16,n[0]=v=65535&g|y<<16,s[0]=O=65535&p|d<<16,p=65535&(h=P),d=h>>>16,g=65535&(u=_),y=u>>>16,u=n[1],d+=(h=s[1])>>>16,g+=65535&u,y+=u>>>16,y+=(g+=(d+=(p+=65535&h)>>>16)>>>16)>>>16,n[1]=_=65535&g|y<<16,s[1]=P=65535&p|d<<16,p=65535&(h=N),d=h>>>16,g=65535&(u=m),y=u>>>16,u=n[2],d+=(h=s[2])>>>16,g+=65535&u,y+=u>>>16,y+=(g+=(d+=(p+=65535&h)>>>16)>>>16)>>>16,n[2]=m=65535&g|y<<16,s[2]=N=65535&p|d<<16,p=65535&(h=A),d=h>>>16,g=65535&(u=w),y=u>>>16,u=n[3],d+=(h=s[3])>>>16,g+=65535&u,y+=u>>>16,y+=(g+=(d+=(p+=65535&h)>>>16)>>>16)>>>16,n[3]=w=65535&g|y<<16,s[3]=A=65535&p|d<<16,p=65535&(h=x),d=h>>>16,g=65535&(u=b),y=u>>>16,u=n[4],d+=(h=s[4])>>>16,g+=65535&u,y+=u>>>16,y+=(g+=(d+=(p+=65535&h)>>>16)>>>16)>>>16,n[4]=b=65535&g|y<<16,s[4]=x=65535&p|d<<16,p=65535&(h=C),d=h>>>16,g=65535&(u=E),y=u>>>16,u=n[5],d+=(h=s[5])>>>16,g+=65535&u,y+=u>>>16,y+=(g+=(d+=(p+=65535&h)>>>16)>>>16)>>>16,n[5]=E=65535&g|y<<16,s[5]=C=65535&p|d<<16,p=65535&(h=T),d=h>>>16,g=65535&(u=S),y=u>>>16,u=n[6],d+=(h=s[6])>>>16,g+=65535&u,y+=u>>>16,y+=(g+=(d+=(p+=65535&h)>>>16)>>>16)>>>16,n[6]=S=65535&g|y<<16,s[6]=T=65535&p|d<<16,p=65535&(h=R),d=h>>>16,g=65535&(u=I),y=u>>>16,u=n[7],d+=(h=s[7])>>>16,g+=65535&u,y+=u>>>16,y+=(g+=(d+=(p+=65535&h)>>>16)>>>16)>>>16,n[7]=I=65535&g|y<<16,s[7]=R=65535&p|d<<16,a+=128,c-=128}return a}e.hash=function(e){var t=new n;t.update(e);var r=t.digest();return t.clean(),r}}(us),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.convertSecretKeyToX25519=e.convertPublicKeyToX25519=e.verify=e.sign=e.extractPublicKeyFromSecretKey=e.generateKeyPair=e.generateKeyPairFromSeed=e.SEED_LENGTH=e.SECRET_KEY_LENGTH=e.PUBLIC_KEY_LENGTH=e.SIGNATURE_LENGTH=void 0;const t=q,r=us,n=w;function i(e){const t=new Float64Array(16);if(e)for(let r=0;r<e.length;r++)t[r]=e[r];return t}e.SIGNATURE_LENGTH=64,e.PUBLIC_KEY_LENGTH=32,e.SECRET_KEY_LENGTH=64,e.SEED_LENGTH=32;new Uint8Array(32)[0]=9;const s=i(),o=i([1]),a=i([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),c=i([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),u=i([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),h=i([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),l=i([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function f(e,t){for(let r=0;r<16;r++)e[r]=0|t[r]}function p(e){let t=1;for(let r=0;r<16;r++){let n=e[r]+t+65535;t=Math.floor(n/65536),e[r]=n-65536*t}e[0]+=t-1+37*(t-1)}function d(e,t,r){const n=~(r-1);for(let r=0;r<16;r++){const i=n&(e[r]^t[r]);e[r]^=i,t[r]^=i}}function g(e,t){const r=i(),n=i();for(let e=0;e<16;e++)n[e]=t[e];p(n),p(n),p(n);for(let e=0;e<2;e++){r[0]=n[0]-65517;for(let e=1;e<15;e++)r[e]=n[e]-65535-(r[e-1]>>16&1),r[e-1]&=65535;r[15]=n[15]-32767-(r[14]>>16&1);const e=r[15]>>16&1;r[14]&=65535,d(n,r,1-e)}for(let t=0;t<16;t++)e[2*t]=255&n[t],e[2*t+1]=n[t]>>8}function y(e,t){let r=0;for(let n=0;n<32;n++)r|=e[n]^t[n];return(1&r-1>>>8)-1}function v(e,t){const r=new Uint8Array(32),n=new Uint8Array(32);return g(r,e),g(n,t),y(r,n)}function _(e){const t=new Uint8Array(32);return g(t,e),1&t[0]}function m(e,t,r){for(let n=0;n<16;n++)e[n]=t[n]+r[n]}function b(e,t,r){for(let n=0;n<16;n++)e[n]=t[n]-r[n]}function E(e,t,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,y=0,v=0,_=0,m=0,w=0,b=0,E=0,S=0,I=0,O=0,P=0,N=0,A=0,x=0,C=0,T=0,R=0,j=0,L=0,U=0,M=r[0],D=r[1],k=r[2],z=r[3],$=r[4],q=r[5],H=r[6],K=r[7],V=r[8],B=r[9],F=r[10],G=r[11],W=r[12],Y=r[13],J=r[14],X=r[15];n=t[0],s+=n*M,o+=n*D,a+=n*k,c+=n*z,u+=n*$,h+=n*q,l+=n*H,f+=n*K,p+=n*V,d+=n*B,g+=n*F,y+=n*G,v+=n*W,_+=n*Y,m+=n*J,w+=n*X,n=t[1],o+=n*M,a+=n*D,c+=n*k,u+=n*z,h+=n*$,l+=n*q,f+=n*H,p+=n*K,d+=n*V,g+=n*B,y+=n*F,v+=n*G,_+=n*W,m+=n*Y,w+=n*J,b+=n*X,n=t[2],a+=n*M,c+=n*D,u+=n*k,h+=n*z,l+=n*$,f+=n*q,p+=n*H,d+=n*K,g+=n*V,y+=n*B,v+=n*F,_+=n*G,m+=n*W,w+=n*Y,b+=n*J,E+=n*X,n=t[3],c+=n*M,u+=n*D,h+=n*k,l+=n*z,f+=n*$,p+=n*q,d+=n*H,g+=n*K,y+=n*V,v+=n*B,_+=n*F,m+=n*G,w+=n*W,b+=n*Y,E+=n*J,S+=n*X,n=t[4],u+=n*M,h+=n*D,l+=n*k,f+=n*z,p+=n*$,d+=n*q,g+=n*H,y+=n*K,v+=n*V,_+=n*B,m+=n*F,w+=n*G,b+=n*W,E+=n*Y,S+=n*J,I+=n*X,n=t[5],h+=n*M,l+=n*D,f+=n*k,p+=n*z,d+=n*$,g+=n*q,y+=n*H,v+=n*K,_+=n*V,m+=n*B,w+=n*F,b+=n*G,E+=n*W,S+=n*Y,I+=n*J,O+=n*X,n=t[6],l+=n*M,f+=n*D,p+=n*k,d+=n*z,g+=n*$,y+=n*q,v+=n*H,_+=n*K,m+=n*V,w+=n*B,b+=n*F,E+=n*G,S+=n*W,I+=n*Y,O+=n*J,P+=n*X,n=t[7],f+=n*M,p+=n*D,d+=n*k,g+=n*z,y+=n*$,v+=n*q,_+=n*H,m+=n*K,w+=n*V,b+=n*B,E+=n*F,S+=n*G,I+=n*W,O+=n*Y,P+=n*J,N+=n*X,n=t[8],p+=n*M,d+=n*D,g+=n*k,y+=n*z,v+=n*$,_+=n*q,m+=n*H,w+=n*K,b+=n*V,E+=n*B,S+=n*F,I+=n*G,O+=n*W,P+=n*Y,N+=n*J,A+=n*X,n=t[9],d+=n*M,g+=n*D,y+=n*k,v+=n*z,_+=n*$,m+=n*q,w+=n*H,b+=n*K,E+=n*V,S+=n*B,I+=n*F,O+=n*G,P+=n*W,N+=n*Y,A+=n*J,x+=n*X,n=t[10],g+=n*M,y+=n*D,v+=n*k,_+=n*z,m+=n*$,w+=n*q,b+=n*H,E+=n*K,S+=n*V,I+=n*B,O+=n*F,P+=n*G,N+=n*W,A+=n*Y,x+=n*J,C+=n*X,n=t[11],y+=n*M,v+=n*D,_+=n*k,m+=n*z,w+=n*$,b+=n*q,E+=n*H,S+=n*K,I+=n*V,O+=n*B,P+=n*F,N+=n*G,A+=n*W,x+=n*Y,C+=n*J,T+=n*X,n=t[12],v+=n*M,_+=n*D,m+=n*k,w+=n*z,b+=n*$,E+=n*q,S+=n*H,I+=n*K,O+=n*V,P+=n*B,N+=n*F,A+=n*G,x+=n*W,C+=n*Y,T+=n*J,R+=n*X,n=t[13],_+=n*M,m+=n*D,w+=n*k,b+=n*z,E+=n*$,S+=n*q,I+=n*H,O+=n*K,P+=n*V,N+=n*B,A+=n*F,x+=n*G,C+=n*W,T+=n*Y,R+=n*J,j+=n*X,n=t[14],m+=n*M,w+=n*D,b+=n*k,E+=n*z,S+=n*$,I+=n*q,O+=n*H,P+=n*K,N+=n*V,A+=n*B,x+=n*F,C+=n*G,T+=n*W,R+=n*Y,j+=n*J,L+=n*X,n=t[15],w+=n*M,b+=n*D,E+=n*k,S+=n*z,I+=n*$,O+=n*q,P+=n*H,N+=n*K,A+=n*V,x+=n*B,C+=n*F,T+=n*G,R+=n*W,j+=n*Y,L+=n*J,U+=n*X,s+=38*b,o+=38*E,a+=38*S,c+=38*I,u+=38*O,h+=38*P,l+=38*N,f+=38*A,p+=38*x,d+=38*C,g+=38*T,y+=38*R,v+=38*j,_+=38*L,m+=38*U,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=y+i+65535,i=Math.floor(n/65536),y=n-65536*i,n=v+i+65535,i=Math.floor(n/65536),v=n-65536*i,n=_+i+65535,i=Math.floor(n/65536),_=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,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=y+i+65535,i=Math.floor(n/65536),y=n-65536*i,n=v+i+65535,i=Math.floor(n/65536),v=n-65536*i,n=_+i+65535,i=Math.floor(n/65536),_=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,s+=i-1+37*(i-1),e[0]=s,e[1]=o,e[2]=a,e[3]=c,e[4]=u,e[5]=h,e[6]=l,e[7]=f,e[8]=p,e[9]=d,e[10]=g,e[11]=y,e[12]=v,e[13]=_,e[14]=m,e[15]=w}function S(e,t){E(e,t,t)}function I(e,t){const r=i();let n;for(n=0;n<16;n++)r[n]=t[n];for(n=253;n>=0;n--)S(r,r),2!==n&&4!==n&&E(r,r,t);for(n=0;n<16;n++)e[n]=r[n]}function O(e,t){const r=i(),n=i(),s=i(),o=i(),a=i(),u=i(),h=i(),l=i(),f=i();b(r,e[1],e[0]),b(f,t[1],t[0]),E(r,r,f),m(n,e[0],e[1]),m(f,t[0],t[1]),E(n,n,f),E(s,e[3],t[3]),E(s,s,c),E(o,e[2],t[2]),m(o,o,o),b(a,n,r),b(u,o,s),m(h,o,s),m(l,n,r),E(e[0],a,u),E(e[1],l,h),E(e[2],h,u),E(e[3],a,l)}function P(e,t,r){for(let n=0;n<4;n++)d(e[n],t[n],r)}function N(e,t){const r=i(),n=i(),s=i();I(s,t[2]),E(r,t[0],s),E(n,t[1],s),g(e,n),e[31]^=_(r)<<7}function A(e,t,r){f(e[0],s),f(e[1],o),f(e[2],o),f(e[3],s);for(let n=255;n>=0;--n){const i=r[n/8|0]>>(7&n)&1;P(e,t,i),O(t,e),O(e,e),P(e,t,i)}}function x(e,t){const r=[i(),i(),i(),i()];f(r[0],u),f(r[1],h),f(r[2],o),E(r[3],u,h),A(e,r,t)}function C(t){if(t.length!==e.SEED_LENGTH)throw new Error(`ed25519: seed must be ${e.SEED_LENGTH} bytes`);const n=(0,r.hash)(t);n[0]&=248,n[31]&=127,n[31]|=64;const s=new Uint8Array(32),o=[i(),i(),i(),i()];x(o,n),N(s,o);const a=new Uint8Array(64);return a.set(t),a.set(s,32),{publicKey:s,secretKey:a}}e.generateKeyPairFromSeed=C,e.generateKeyPair=function(e){const r=(0,t.randomBytes)(32,e),i=C(r);return(0,n.wipe)(r),i},e.extractPublicKeyFromSecretKey=function(t){if(t.length!==e.SECRET_KEY_LENGTH)throw new Error(`ed25519: secret key must be ${e.SECRET_KEY_LENGTH} bytes`);return new Uint8Array(t.subarray(32))};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 R(e,t){let r,n,i,s;for(n=63;n>=32;--n){for(r=0,i=n-32,s=n-12;i<s;++i)t[i]+=r-16*t[n]*T[i-(n-32)],r=Math.floor((t[i]+128)/256),t[i]-=256*r;t[i]+=r,t[n]=0}for(r=0,i=0;i<32;i++)t[i]+=r-(t[31]>>4)*T[i],r=t[i]>>8,t[i]&=255;for(i=0;i<32;i++)t[i]-=r*T[i];for(n=0;n<32;n++)t[n+1]+=t[n]>>8,e[n]=255&t[n]}function j(e){const t=new Float64Array(64);for(let r=0;r<64;r++)t[r]=e[r];for(let t=0;t<64;t++)e[t]=0;R(e,t)}function L(e,t){const r=i(),n=i(),c=i(),u=i(),h=i(),p=i(),d=i();return f(e[2],o),function(e,t){for(let r=0;r<16;r++)e[r]=t[2*r]+(t[2*r+1]<<8);e[15]&=32767}(e[1],t),S(c,e[1]),E(u,c,a),b(c,c,e[2]),m(u,e[2],u),S(h,u),S(p,h),E(d,p,h),E(r,d,c),E(r,r,u),function(e,t){const r=i();let n;for(n=0;n<16;n++)r[n]=t[n];for(n=250;n>=0;n--)S(r,r),1!==n&&E(r,r,t);for(n=0;n<16;n++)e[n]=r[n]}(r,r),E(r,r,c),E(r,r,u),E(r,r,u),E(e[0],r,u),S(n,e[0]),E(n,n,u),v(n,c)&&E(e[0],e[0],l),S(n,e[0]),E(n,n,u),v(n,c)?-1:(_(e[0])===t[31]>>7&&b(e[0],s,e[0]),E(e[3],e[0],e[1]),0)}e.sign=function(e,t){const n=new Float64Array(64),s=[i(),i(),i(),i()],o=(0,r.hash)(e.subarray(0,32));o[0]&=248,o[31]&=127,o[31]|=64;const a=new Uint8Array(64);a.set(o.subarray(32),32);const c=new r.SHA512;c.update(a.subarray(32)),c.update(t);const u=c.digest();c.clean(),j(u),x(s,u),N(a,s),c.reset(),c.update(a.subarray(0,32)),c.update(e.subarray(32)),c.update(t);const h=c.digest();j(h);for(let e=0;e<32;e++)n[e]=u[e];for(let e=0;e<32;e++)for(let t=0;t<32;t++)n[e+t]+=h[e]*o[t];return R(a.subarray(32),n),a},e.verify=function(t,n,s){const o=new Uint8Array(32),a=[i(),i(),i(),i()],c=[i(),i(),i(),i()];if(s.length!==e.SIGNATURE_LENGTH)throw new Error(`ed25519: signature must be ${e.SIGNATURE_LENGTH} bytes`);if(L(c,t))return!1;const u=new r.SHA512;u.update(s.subarray(0,32)),u.update(t),u.update(n);const h=u.digest();return j(h),A(a,c,h),x(c,s.subarray(32)),O(a,c),N(o,a),!y(s,o)},e.convertPublicKeyToX25519=function(e){let t=[i(),i(),i(),i()];if(L(t,e))throw new Error("Ed25519: invalid public key");let r=i(),n=i(),s=t[1];m(r,o,s),b(n,o,s),I(n,n),E(r,r,n);let a=new Uint8Array(32);return g(a,r),a},e.convertSecretKeyToX25519=function(e){const t=(0,r.hash)(e.subarray(0,32));t[0]&=248,t[31]&=127,t[31]|=64;const i=new Uint8Array(t.subarray(0,32));return(0,n.wipe)(t),i}}(cs);const hs=".",ls="base64url",fs="utf8",ps="utf8",ds=":",gs="did",ys="key",vs="base58btc",_s="z",ms="K36";function ws(e){return St(Et(as(e),fs),ls)}function bs(e){const t=Et(ms,vs),r=_s+St(Z([t,e]),vs);return[gs,ys,r].join(ds)}function Es(e=q.randomBytes(32)){return cs.generateKeyPairFromSeed(e)}async function Ss(e,t,r,n,i=Mt.fromMiliseconds(Date.now())){const s={alg:"EdDSA",typ:"JWT"},o={iss:bs(n.publicKey),sub:e,aud:t,iat:i,exp:i+r},a=Et([ws((c={header:s,payload:o}).header),ws(c.payload)].join(hs),ps);var c;return function(e){return[ws(e.header),ws(e.payload),(t=e.signature,St(t,ls))].join(hs);var t}({header:s,payload:o,signature:cs.sign(n.secretKey,a)})}const Is="INTERNAL_ERROR",Os="SERVER_ERROR",Ps=[-32700,-32600,-32601,-32602,-32603],Ns={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"},[Is]:{code:-32603,message:"Internal error"},[Os]:{code:-32e3,message:"Server error"}},As=Os;function xs(e){return Object.keys(Ns).includes(e)?Ns[e]:Ns[As]}function Cs(e,t,r){return e.message.includes("getaddrinfo ENOTFOUND")||e.message.includes("connect ECONNREFUSED")?new Error(`Unavailable ${r} RPC url at ${t}`):e}var Ts,Rs={},js={};var Ls,Us={};function Ms(e=3){return Date.now()*Math.pow(10,e)+Math.floor(Math.random()*Math.pow(10,e))}function Ds(e=6){return BigInt(Ms(e))}function ks(e,t,r){return{id:r||Ms(),jsonrpc:"2.0",method:e,params:t}}function zs(e,t){return{id:e,jsonrpc:"2.0",result:t}}function $s(e,t,r){return{id:e,jsonrpc:"2.0",error:qs(t,r)}}function qs(e,t){return void 0===e?xs(Is):("string"==typeof e&&(e=Object.assign(Object.assign({},xs(Os)),{message:e})),void 0!==t&&(e.data=t),function(e){return Ps.includes(e)}(e.code)&&(e=function(e){const t=Object.values(Ns).find((t=>t.code===e));return t||Ns[As]}(e.code)),e)}!function(e){Object.defineProperty(e,"__esModule",{value:!0});const t=Ft;t.__exportStar(function(){if(Ts)return js;function e(){return(null===r.commonjsGlobal||void 0===r.commonjsGlobal?void 0:r.commonjsGlobal.crypto)||(null===r.commonjsGlobal||void 0===r.commonjsGlobal?void 0:r.commonjsGlobal.msCrypto)||{}}function t(){const t=e();return t.subtle||t.webkitSubtle}return Ts=1,Object.defineProperty(js,"__esModule",{value:!0}),js.isBrowserCryptoAvailable=js.getSubtleCrypto=js.getBrowerCrypto=void 0,js.getBrowerCrypto=e,js.getSubtleCrypto=t,js.isBrowserCryptoAvailable=function(){return!!e()&&!!t()},js}(),e),t.__exportStar(function(){if(Ls)return Us;function e(){return"undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"===navigator.product}function t(){return"undefined"!=typeof process&&void 0!==process.versions&&void 0!==process.versions.node}return Ls=1,Object.defineProperty(Us,"__esModule",{value:!0}),Us.isBrowser=Us.isNode=Us.isReactNative=void 0,Us.isReactNative=e,Us.isNode=t,Us.isBrowser=function(){return!e()&&!t()},Us}(),e)}(Rs);class Hs{}class Ks extends Hs{constructor(){super()}}class Vs extends Ks{constructor(e){super()}}function Bs(e,t){const r=function(e){const t=e.match(new RegExp(/^\w+:/,"gi"));if(t&&t.length)return t[0]}(e);return void 0!==r&&new RegExp(t).test(r)}function Fs(e){return Bs(e,"^https?:")}function Gs(e){return Bs(e,"^wss?:")}function Ws(e){return new RegExp("wss?://localhost(:d{2,5})?").test(e)}function Ys(e){return"object"==typeof e&&"id"in e&&"jsonrpc"in e&&"2.0"===e.jsonrpc}function Js(e){return Ys(e)&&"method"in e}function Xs(e){return Ys(e)&&(Zs(e)||Qs(e))}function Zs(e){return"result"in e}function Qs(e){return"error"in e}class eo extends Vs{constructor(t){super(t),this.events=new e.EventEmitter,this.hasRegisteredEventListeners=!1,this.connection=this.setConnection(t),this.connection.connected&&this.registerEventListeners()}async connect(e=this.connection){await this.open(e)}async disconnect(){await this.close()}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async request(e,t){return this.requestStrict(ks(e.method,e.params||[],e.id||Ds().toString()),t)}async requestStrict(e,t){return new Promise((async(r,n)=>{if(!this.connection.connected)try{await this.open()}catch(e){n(e)}this.events.on(`${e.id}`,(e=>{Qs(e)?n(e.error):r(e.result)}));try{await this.connection.send(e,t)}catch(e){n(e)}}))}setConnection(e=this.connection){return e}onPayload(e){this.events.emit("payload",e),Xs(e)?this.events.emit(`${e.id}`,e):this.events.emit("message",{type:e.method,data:e.params})}onClose(e){e&&3e3===e.code&&this.events.emit("error",new Error(`WebSocket connection closed abnormally with code: ${e.code} ${e.reason?`(${e.reason})`:""}`)),this.events.emit("disconnect")}async open(e=this.connection){this.connection===e&&this.connection.connected||(this.connection.connected&&this.close(),"string"==typeof e&&(await this.connection.open(e),e=this.connection),this.connection=this.setConnection(e),await this.connection.open(),this.registerEventListeners(),this.events.emit("connect"))}async close(){await this.connection.close()}registerEventListeners(){this.hasRegisteredEventListeners||(this.connection.on("payload",(e=>this.onPayload(e))),this.connection.on("close",(e=>this.onClose(e))),this.connection.on("error",(e=>this.events.emit("error",e))),this.connection.on("register_error",(e=>this.onClose())),this.hasRegisteredEventListeners=!0)}}const to=e=>e.split("?")[0],ro="undefined"!=typeof global&&void 0!==global.WebSocket?global.WebSocket:"undefined"!=typeof window&&void 0!==window.WebSocket?window.WebSocket:require("ws");class no{constructor(t){if(this.url=t,this.events=new e.EventEmitter,this.registering=!1,!Gs(t))throw new Error(`Provided URL is not compatible with WebSocket connection: ${t}`);this.url=t}get connected(){return void 0!==this.socket}get connecting(){return this.registering}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async open(e=this.url){await this.register(e)}async close(){return new Promise(((e,t)=>{void 0!==this.socket?(this.socket.onclose=t=>{this.onClose(t),e()},this.socket.close()):t(new Error("Connection already closed"))}))}async send(e,t){void 0===this.socket&&(this.socket=await this.register());try{this.socket.send(as(e))}catch(t){this.onError(e.id,t)}}register(e=this.url){if(!Gs(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);if(this.registering){const e=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=e||this.events.listenerCount("open")>=e)&&this.events.setMaxListeners(e+1),new Promise(((e,t)=>{this.events.once("register_error",(e=>{this.resetMaxListeners(),t(e)})),this.events.once("open",(()=>{if(this.resetMaxListeners(),void 0===this.socket)return t(new Error("WebSocket connection is missing or invalid"));e(this.socket)}))}))}return this.url=e,this.registering=!0,new Promise(((t,r)=>{const n=Rs.isReactNative()?void 0:{rejectUnauthorized:!Ws(e)},i=new ro(e,[],n);"undefined"!=typeof window?i.onerror=e=>{const t=e;r(this.emitError(t.error))}:i.on("error",(e=>{r(this.emitError(e))})),i.onopen=()=>{this.onOpen(i),t(i)}}))}onOpen(e){e.onmessage=e=>this.onPayload(e),e.onclose=e=>this.onClose(e),this.socket=e,this.registering=!1,this.events.emit("open")}onClose(e){this.socket=void 0,this.registering=!1,this.events.emit("close",e)}onPayload(e){if(void 0===e.data)return;const t="string"==typeof e.data?os(e.data):e.data;this.events.emit("payload",t)}onError(e,t){const r=this.parseError(t),n=$s(e,r.message||r.toString());this.events.emit("payload",n)}parseError(e,t=this.url){return Cs(e,to(t),"WS")}resetMaxListeners(){this.events.getMaxListeners()>10&&this.events.setMaxListeners(10)}emitError(e){const t=this.parseError(new Error((null==e?void 0:e.message)||`WebSocket connection failed for host: ${to(this.url)}`));return this.events.emit("register_error",t),t}}var io={exports:{}};!function(e,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]",y="[object Number]",v="[object Null]",_="[object Object]",m="[object Promise]",w="[object Proxy]",b="[object RegExp]",E="[object Set]",S="[object String]",I="[object Symbol]",O="[object Undefined]",P="[object WeakMap]",N="[object ArrayBuffer]",A="[object DataView]",x=/^\[object .+?Constructor\]$/,C=/^(?:0|[1-9]\d*)$/,T={};T["[object Float32Array]"]=T["[object Float64Array]"]=T["[object Int8Array]"]=T["[object Int16Array]"]=T["[object Int32Array]"]=T["[object Uint8Array]"]=T["[object Uint8ClampedArray]"]=T["[object Uint16Array]"]=T["[object Uint32Array]"]=!0,T[a]=T[c]=T[N]=T[h]=T[A]=T[l]=T[f]=T[p]=T[g]=T[y]=T[_]=T[b]=T[E]=T[S]=T[P]=!1;var R="object"==typeof r.commonjsGlobal&&r.commonjsGlobal&&r.commonjsGlobal.Object===Object&&r.commonjsGlobal,j="object"==typeof self&&self&&self.Object===Object&&self,L=R||j||Function("return this")(),U=t&&!t.nodeType&&t,M=U&&e&&!e.nodeType&&e,D=M&&M.exports===U,k=D&&R.process,z=function(){try{return k&&k.binding&&k.binding("util")}catch(e){}}(),$=z&&z.isTypedArray;function q(e,t){for(var r=-1,n=null==e?0:e.length;++r<n;)if(t(e[r],r,e))return!0;return!1}function H(e){var t=-1,r=Array(e.size);return e.forEach((function(e,n){r[++t]=[n,e]})),r}function K(e){var t=-1,r=Array(e.size);return e.forEach((function(e){r[++t]=e})),r}var V,B,F,G=Array.prototype,W=Function.prototype,Y=Object.prototype,J=L["__core-js_shared__"],X=W.toString,Z=Y.hasOwnProperty,Q=(V=/[^.]+$/.exec(J&&J.keys&&J.keys.IE_PROTO||""))?"Symbol(src)_1."+V:"",ee=Y.toString,te=RegExp("^"+X.call(Z).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),re=D?L.Buffer:void 0,ne=L.Symbol,ie=L.Uint8Array,se=Y.propertyIsEnumerable,oe=G.splice,ae=ne?ne.toStringTag:void 0,ce=Object.getOwnPropertySymbols,ue=re?re.isBuffer:void 0,he=(B=Object.keys,F=Object,function(e){return B(F(e))}),le=ze(L,"DataView"),fe=ze(L,"Map"),pe=ze(L,"Promise"),de=ze(L,"Set"),ge=ze(L,"WeakMap"),ye=ze(Object,"create"),ve=Ke(le),_e=Ke(fe),me=Ke(pe),we=Ke(de),be=Ke(ge),Ee=ne?ne.prototype:void 0,Se=Ee?Ee.valueOf:void 0;function Ie(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function Oe(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function Pe(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function Ne(e){var t=-1,r=null==e?0:e.length;for(this.__data__=new Pe;++t<r;)this.add(e[t])}function Ae(e){var t=this.__data__=new Oe(e);this.size=t.size}function xe(e,t){var r=Fe(e),n=!r&&Be(e),i=!r&&!n&&Ge(e),s=!r&&!n&&!i&&Ze(e),o=r||n||i||s,a=o?function(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}(e.length,String):[],c=a.length;for(var u in e)!t&&!Z.call(e,u)||o&&("length"==u||i&&("offset"==u||"parent"==u)||s&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||He(u,c))||a.push(u);return a}function Ce(e,t){for(var r=e.length;r--;)if(Ve(e[r][0],t))return r;return-1}function Te(e){return null==e?void 0===e?O:v:ae&&ae in Object(e)?function(e){var t=Z.call(e,ae),r=e[ae];try{e[ae]=void 0;var n=!0}catch(e){}var i=ee.call(e);n&&(t?e[ae]=r:delete e[ae]);return i}(e):function(e){return ee.call(e)}(e)}function Re(e){return Xe(e)&&Te(e)==a}function je(e,t,r,n,o){return e===t||(null==e||null==t||!Xe(e)&&!Xe(t)?e!=e&&t!=t:function(e,t,r,n,o,u){var p=Fe(e),d=Fe(t),v=p?c:qe(e),m=d?c:qe(t),w=(v=v==a?_:v)==_,O=(m=m==a?_:m)==_,P=v==m;if(P&&Ge(e)){if(!Ge(t))return!1;p=!0,w=!1}if(P&&!w)return u||(u=new Ae),p||Ze(e)?Me(e,t,r,n,o,u):function(e,t,r,n,o,a,c){switch(r){case A:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case N:return!(e.byteLength!=t.byteLength||!a(new ie(e),new ie(t)));case h:case l:case y:return Ve(+e,+t);case f:return e.name==t.name&&e.message==t.message;case b:case S:return e==t+"";case g:var u=H;case E:var p=n&i;if(u||(u=K),e.size!=t.size&&!p)return!1;var d=c.get(e);if(d)return d==t;n|=s,c.set(e,t);var v=Me(u(e),u(t),n,o,a,c);return c.delete(e),v;case I:if(Se)return Se.call(e)==Se.call(t)}return!1}(e,t,v,r,n,o,u);if(!(r&i)){var x=w&&Z.call(e,"__wrapped__"),C=O&&Z.call(t,"__wrapped__");if(x||C){var T=x?e.value():e,R=C?t.value():t;return u||(u=new Ae),o(T,R,r,n,u)}}if(!P)return!1;return u||(u=new Ae),function(e,t,r,n,s,o){var a=r&i,c=De(e),u=c.length,h=De(t),l=h.length;if(u!=l&&!a)return!1;var f=u;for(;f--;){var p=c[f];if(!(a?p in t:Z.call(t,p)))return!1}var d=o.get(e);if(d&&o.get(t))return d==t;var g=!0;o.set(e,t),o.set(t,e);var y=a;for(;++f<u;){var v=e[p=c[f]],_=t[p];if(n)var m=a?n(_,v,p,t,e,o):n(v,_,p,e,t,o);if(!(void 0===m?v===_||s(v,_,r,n,o):m)){g=!1;break}y||(y="constructor"==p)}if(g&&!y){var w=e.constructor,b=t.constructor;w==b||!("constructor"in e)||!("constructor"in t)||"function"==typeof w&&w instanceof w&&"function"==typeof b&&b instanceof b||(g=!1)}return o.delete(e),o.delete(t),g}(e,t,r,n,o,u)}(e,t,r,n,je,o))}function Le(e){return!(!Je(e)||function(e){return!!Q&&Q in e}(e))&&(We(e)?te:x).test(Ke(e))}function Ue(e){if(r=(t=e)&&t.constructor,n="function"==typeof r&&r.prototype||Y,t!==n)return he(e);var t,r,n,i=[];for(var s in Object(e))Z.call(e,s)&&"constructor"!=s&&i.push(s);return i}function Me(e,t,r,n,o,a){var c=r&i,u=e.length,h=t.length;if(u!=h&&!(c&&h>u))return!1;var l=a.get(e);if(l&&a.get(t))return l==t;var f=-1,p=!0,d=r&s?new Ne:void 0;for(a.set(e,t),a.set(t,e);++f<u;){var g=e[f],y=t[f];if(n)var v=c?n(y,g,f,t,e,a):n(g,y,f,e,t,a);if(void 0!==v){if(v)continue;p=!1;break}if(d){if(!q(t,(function(e,t){if(i=t,!d.has(i)&&(g===e||o(g,e,r,n,a)))return d.push(t);var i}))){p=!1;break}}else if(g!==y&&!o(g,y,r,n,a)){p=!1;break}}return a.delete(e),a.delete(t),p}function De(e){return function(e,t,r){var n=t(e);return Fe(e)?n:function(e,t){for(var r=-1,n=t.length,i=e.length;++r<n;)e[i+r]=t[r];return e}(n,r(e))}(e,Qe,$e)}function ke(e,t){var r,n,i=e.__data__;return("string"==(n=typeof(r=t))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==r:null===r)?i["string"==typeof t?"string":"hash"]:i.map}function ze(e,t){var r=function(e,t){return null==e?void 0:e[t]}(e,t);return Le(r)?r:void 0}Ie.prototype.clear=function(){this.__data__=ye?ye(null):{},this.size=0},Ie.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},Ie.prototype.get=function(e){var t=this.__data__;if(ye){var r=t[e];return r===n?void 0:r}return Z.call(t,e)?t[e]:void 0},Ie.prototype.has=function(e){var t=this.__data__;return ye?void 0!==t[e]:Z.call(t,e)},Ie.prototype.set=function(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=ye&&void 0===t?n:t,this},Oe.prototype.clear=function(){this.__data__=[],this.size=0},Oe.prototype.delete=function(e){var t=this.__data__,r=Ce(t,e);return!(r<0)&&(r==t.length-1?t.pop():oe.call(t,r,1),--this.size,!0)},Oe.prototype.get=function(e){var t=this.__data__,r=Ce(t,e);return r<0?void 0:t[r][1]},Oe.prototype.has=function(e){return Ce(this.__data__,e)>-1},Oe.prototype.set=function(e,t){var r=this.__data__,n=Ce(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this},Pe.prototype.clear=function(){this.size=0,this.__data__={hash:new Ie,map:new(fe||Oe),string:new Ie}},Pe.prototype.delete=function(e){var t=ke(this,e).delete(e);return this.size-=t?1:0,t},Pe.prototype.get=function(e){return ke(this,e).get(e)},Pe.prototype.has=function(e){return ke(this,e).has(e)},Pe.prototype.set=function(e,t){var r=ke(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this},Ne.prototype.add=Ne.prototype.push=function(e){return this.__data__.set(e,n),this},Ne.prototype.has=function(e){return this.__data__.has(e)},Ae.prototype.clear=function(){this.__data__=new Oe,this.size=0},Ae.prototype.delete=function(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r},Ae.prototype.get=function(e){return this.__data__.get(e)},Ae.prototype.has=function(e){return this.__data__.has(e)},Ae.prototype.set=function(e,t){var r=this.__data__;if(r instanceof Oe){var n=r.__data__;if(!fe||n.length<199)return n.push([e,t]),this.size=++r.size,this;r=this.__data__=new Pe(n)}return r.set(e,t),this.size=r.size,this};var $e=ce?function(e){return null==e?[]:(e=Object(e),function(e,t){for(var r=-1,n=null==e?0:e.length,i=0,s=[];++r<n;){var o=e[r];t(o,r,e)&&(s[i++]=o)}return s}(ce(e),(function(t){return se.call(e,t)})))}:function(){return[]},qe=Te;function He(e,t){return!!(t=null==t?o:t)&&("number"==typeof e||C.test(e))&&e>-1&&e%1==0&&e<t}function Ke(e){if(null!=e){try{return X.call(e)}catch(e){}try{return e+""}catch(e){}}return""}function Ve(e,t){return e===t||e!=e&&t!=t}(le&&qe(new le(new ArrayBuffer(1)))!=A||fe&&qe(new fe)!=g||pe&&qe(pe.resolve())!=m||de&&qe(new de)!=E||ge&&qe(new ge)!=P)&&(qe=function(e){var t=Te(e),r=t==_?e.constructor:void 0,n=r?Ke(r):"";if(n)switch(n){case ve:return A;case _e:return g;case me:return m;case we:return E;case be:return P}return t});var Be=Re(function(){return arguments}())?Re:function(e){return Xe(e)&&Z.call(e,"callee")&&!se.call(e,"callee")},Fe=Array.isArray;var Ge=ue||function(){return!1};function We(e){if(!Je(e))return!1;var t=Te(e);return t==p||t==d||t==u||t==w}function Ye(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=o}function Je(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function Xe(e){return null!=e&&"object"==typeof e}var Ze=$?function(e){return function(t){return e(t)}}($):function(e){return Xe(e)&&Ye(e.length)&&!!T[Te(e)]};function Qe(e){return null!=(t=e)&&Ye(t.length)&&!We(t)?xe(e):Ue(e);var t}e.exports=function(e,t){return je(e,t)}}(io,io.exports);var so=io.exports;var oo=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<e.length;i++){var s=e.charAt(i),o=s.charCodeAt(0);if(255!==r[o])throw new TypeError(s+" is ambiguous");r[o]=i}var a=e.length,c=e.charAt(0),u=Math.log(a)/Math.log(256),h=Math.log(256)/Math.log(a);function l(e){if("string"!=typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var n=0,i=0;e[t]===c;)n++,t++;for(var s=(e.length-t)*u+1>>>0,o=new Uint8Array(s);e[t];){var h=r[e.charCodeAt(t)];if(255===h)return;for(var l=0,f=s-1;(0!==h||l<i)&&-1!==f;f--,l++)h+=a*o[f]>>>0,o[f]=h%256>>>0,h=h/256>>>0;if(0!==h)throw new Error("Non-zero carry");i=l,t++}if(" "!==e[t]){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(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,i=0,s=t.length;i!==s&&0===t[i];)i++,r++;for(var o=(s-i)*h+1>>>0,u=new Uint8Array(o);i!==s;){for(var l=t[i],f=0,p=o-1;(0!==l||f<n)&&-1!==p;p--,f++)l+=256*u[p]>>>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<o;++d)g+=e.charAt(u[d]);return g},decodeUnsafe:l,decode:function(e){var r=l(e);if(r)return r;throw new Error(`Non-${t} character`)}}},ao=oo;const co=e=>{if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")};class uo{constructor(e,t,r){this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class ho{constructor(e,t,r){if(this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=r}decode(e){if("string"==typeof e){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}throw Error("Can only multibase decode strings")}or(e){return fo(this,e)}}class lo{constructor(e){this.decoders=e}or(e){return fo(this,e)}decode(e){const t=e[0],r=this.decoders[t];if(r)return r.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const fo=(e,t)=>new lo({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}});class po{constructor(e,t,r,n){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new uo(e,t,r),this.decoder=new ho(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const go=({name:e,prefix:t,encode:r,decode:n})=>new po(e,t,r,n),yo=({prefix:e,name:t,alphabet:r})=>{const{encode:n,decode:i}=ao(r,t);return go({prefix:e,name:t,encode:n,decode:e=>co(i(e))})},vo=({name:e,prefix:t,bitsPerChar:r,alphabet:n})=>go({prefix:t,name:e,encode:e=>((e,t,r)=>{const n="="===t[t.length-1],i=(1<<r)-1;let s="",o=0,a=0;for(let n=0;n<e.length;++n)for(a=a<<8|e[n],o+=8;o>r;)o-=r,s+=t[i&a>>o];if(o&&(s+=t[i&a<<r-o]),n)for(;s.length*r&7;)s+="=";return s})(e,n,r),decode:t=>((e,t,r,n)=>{const i={};for(let e=0;e<t.length;++e)i[t[e]]=e;let s=e.length;for(;"="===e[s-1];)--s;const o=new Uint8Array(s*r/8|0);let a=0,c=0,u=0;for(let t=0;t<s;++t){const s=i[e[t]];if(void 0===s)throw new SyntaxError(`Non-${n} character`);c=c<<r|s,a+=r,a>=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,n,r,e)}),_o=go({prefix:"\0",name:"identity",encode:e=>(e=>(new TextDecoder).decode(e))(e),decode:e=>(e=>(new TextEncoder).encode(e))(e)});var mo=Object.freeze({__proto__:null,identity:_o});const wo=vo({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var bo=Object.freeze({__proto__:null,base2:wo});const Eo=vo({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var So=Object.freeze({__proto__:null,base8:Eo});const Io=yo({prefix:"9",name:"base10",alphabet:"0123456789"});var Oo=Object.freeze({__proto__:null,base10:Io});const Po=vo({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),No=vo({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Ao=Object.freeze({__proto__:null,base16:Po,base16upper:No});const xo=vo({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Co=vo({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),To=vo({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Ro=vo({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),jo=vo({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Lo=vo({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Uo=vo({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Mo=vo({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Do=vo({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var ko=Object.freeze({__proto__:null,base32:xo,base32upper:Co,base32pad:To,base32padupper:Ro,base32hex:jo,base32hexupper:Lo,base32hexpad:Uo,base32hexpadupper:Mo,base32z:Do});const zo=yo({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),$o=yo({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var qo=Object.freeze({__proto__:null,base36:zo,base36upper:$o});const Ho=yo({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ko=yo({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Vo=Object.freeze({__proto__:null,base58btc:Ho,base58flickr:Ko});const Bo=vo({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Fo=vo({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Go=vo({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Wo=vo({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Yo=Object.freeze({__proto__:null,base64:Bo,base64pad:Fo,base64url:Go,base64urlpad:Wo});const Jo=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),Xo=Jo.reduce(((e,t,r)=>(e[r]=t,e)),[]),Zo=Jo.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const Qo=go({prefix:"🚀",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=Xo[t]),"")},decode:function(e){const t=[];for(const r of e){const e=Zo[r.codePointAt(0)];if(void 0===e)throw new Error(`Non-base256emoji character: ${r}`);t.push(e)}return new Uint8Array(t)}});var ea=Object.freeze({__proto__:null,base256emoji:Qo}),ta=function e(t,r,n){r=r||[];for(var i=n=n||0;t>=ia;)r[n++]=255&t|ra,t/=128;for(;t&na;)r[n++]=255&t|ra,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},ra=128,na=-128,ia=Math.pow(2,31);var sa=function e(t,r){var n,i=0,s=0,o=r=r||0,a=t.length;do{if(o>=a)throw e.bytes=0,new RangeError("Could not decode varint");n=t[o++],i+=s<28?(n&aa)<<s:(n&aa)*Math.pow(2,s),s+=7}while(n>=oa);return e.bytes=o-r,i},oa=128,aa=127;var ca=Math.pow(2,7),ua=Math.pow(2,14),ha=Math.pow(2,21),la=Math.pow(2,28),fa=Math.pow(2,35),pa=Math.pow(2,42),da=Math.pow(2,49),ga=Math.pow(2,56),ya=Math.pow(2,63),va={encode:ta,decode:sa,encodingLength:function(e){return e<ca?1:e<ua?2:e<ha?3:e<la?4:e<fa?5:e<pa?6:e<da?7:e<ga?8:e<ya?9:10}};const _a=(e,t,r=0)=>(va.encode(e,t,r),t),ma=e=>va.encodingLength(e),wa=(e,t)=>{const r=t.byteLength,n=ma(e),i=n+ma(r),s=new Uint8Array(i+r);return _a(e,s,0),_a(r,s,n),s.set(t,i),new ba(e,r,t,s)};class ba{constructor(e,t,r,n){this.code=e,this.size=t,this.digest=r,this.bytes=n}}const Ea=({name:e,code:t,encode:r})=>new Sa(e,t,r);class Sa{constructor(e,t,r){this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?wa(this.code,t):t.then((e=>wa(this.code,e)))}throw Error("Unknown type, must be binary type")}}const Ia=e=>async t=>new Uint8Array(await crypto.subtle.digest(e,t)),Oa=Ea({name:"sha2-256",code:18,encode:Ia("SHA-256")}),Pa=Ea({name:"sha2-512",code:19,encode:Ia("SHA-512")});Object.freeze({__proto__:null,sha256:Oa,sha512:Pa});const Na=co,Aa={code:0,name:"identity",encode:Na,digest:e=>wa(0,Na(e))};Object.freeze({__proto__:null,identity:Aa});new TextEncoder,new TextDecoder;const xa={...mo,...bo,...So,...Oo,...Ao,...ko,...qo,...Vo,...Yo,...ea};function Ca(e){return null!=globalThis.Buffer?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e}function Ta(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}const Ra=Ta("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),ja=Ta("ascii","a",(e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t}),(e=>{const t=function(e=0){return null!=globalThis.Buffer&&null!=globalThis.Buffer.allocUnsafe?Ca(globalThis.Buffer.allocUnsafe(e)):new Uint8Array(e)}((e=e.substring(1)).length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t})),La={utf8:Ra,"utf-8":Ra,hex:xa.base16,latin1:ja,ascii:ja,binary:ja,...xa};const Ua="core",Ma=`wc@2:${Ua}:`,Da="error",ka={database:":memory:"},za="client_ed25519_seed",$a=Mt.ONE_DAY,qa=Mt.SIX_HOURS,Ha="wss://relay.walletconnect.com",Ka="wss://relay.walletconnect.org",Va="relayer_message",Ba="relayer_message_ack",Fa="relayer_connect",Ga="relayer_disconnect",Wa="relayer_error",Ya="relayer_connection_stalled",Ja="relayer_transport_closed",Xa="relayer_publish",Za="payload",Qa="connect",ec="disconnect",tc="error",rc=Mt.ONE_SECOND/2,nc="subscription_created",ic="subscription_deleted",sc="subscription_sync",oc="subscription_resubscribed",ac=1e3*Mt.FIVE_SECONDS,cc={wc_pairingDelete:{req:{ttl:Mt.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:Mt.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:Mt.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:Mt.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:Mt.ONE_DAY,prompt:!1,tag:0},res:{ttl:Mt.ONE_DAY,prompt:!1,tag:0}}},uc="history_created",hc="history_updated",lc="history_deleted",fc="history_sync",pc="expirer_created",dc="expirer_deleted",gc="expirer_expired",yc="expirer_sync",vc="verify-api",_c="https://verify.walletconnect.com";class mc{constructor(e,t){this.core=e,this.logger=t,this.keychain=new Map,this.name="keychain",this.version="0.3",this.initialized=!1,this.storagePrefix=Ma,this.init=async()=>{if(!this.initialized){const e=await this.getKeyChain();typeof e<"u"&&(this.keychain=e),this.initialized=!0}},this.has=e=>(this.isInitialized(),this.keychain.has(e)),this.set=async(e,t)=>{this.isInitialized(),this.keychain.set(e,t),await this.persist()},this.get=e=>{this.isInitialized();const t=this.keychain.get(e);if(typeof t>"u"){const{message:t}=zn("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(t)}return t},this.del=async e=>{this.isInitialized(),this.keychain.delete(e),await this.persist()},this.core=e,this.logger=qi.generateChildLogger(t,this.name)}get context(){return qi.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,dn(e))}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?gn(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:e}=zn("NOT_INITIALIZED",this.name);throw new Error(e)}}}class wc{constructor(e,t,r){this.core=e,this.logger=t,this.name="crypto",this.initialized=!1,this.init=async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)},this.hasKeys=e=>(this.isInitialized(),this.keychain.has(e)),this.getClientId=async()=>{this.isInitialized();return bs(Es(await this.getClientSeed()).publicKey)},this.generateKeyPair=()=>{this.isInitialized();const e=function(){const e=Y.generateKeyPair();return{privateKey:St(e.secretKey,Ur),publicKey:St(e.publicKey,Ur)}}();return this.setPrivateKey(e.publicKey,e.privateKey)},this.signJWT=async e=>{this.isInitialized();const t=Es(await this.getClientSeed()),r=Vr(),n=$a;return await Ss(r,e,n,t)},this.generateSharedKey=(e,t,r)=>{this.isInitialized();const n=function(e,t){const r=Y.sharedKey(Et(e,Ur),Et(t,Ur));return St(new $(W.SHA256,r).expand(Kr),Ur)}(this.getPrivateKey(e),t);return this.setSymKey(n,r)},this.setSymKey=async(e,t)=>{this.isInitialized();const r=t||function(e){return St(W.hash(Et(e,Ur)),Ur)}(e);return await this.keychain.set(r,e),r},this.deleteKeyPair=async e=>{this.isInitialized(),await this.keychain.del(e)},this.deleteSymKey=async e=>{this.isInitialized(),await this.keychain.del(e)},this.encode=async(e,t,r)=>{this.isInitialized();const n=Yr(r),i=as(t);if(Jr(n)){const t=n.senderPublicKey,r=n.receiverPublicKey;e=await this.generateSharedKey(t,r)}const s=this.getSymKey(e),{type:o,senderPublicKey:a}=n;return Gr({type:o,symKey:s,message:i,senderPublicKey:a})},this.decode=async(e,t,r)=>{this.isInitialized();const n=function(e,t){const r=Wr(e);return Yr({type:Fr(r.type),senderPublicKey:typeof r.senderPublicKey<"u"?St(r.senderPublicKey,Ur):void 0,receiverPublicKey:t?.receiverPublicKey})}(t,r);if(Jr(n)){const t=n.receiverPublicKey,r=n.senderPublicKey;e=await this.generateSharedKey(t,r)}const i=function(e){const t=new s.ChaCha20Poly1305(Et(e.symKey,Ur)),{sealed:r,iv:n}=Wr(e.encoded),i=t.open(n,r);if(null===i)throw new Error("Failed to decrypt");return St(i,Dr)}({symKey:this.getSymKey(e),encoded:t});return os(i)},this.getPayloadType=e=>Fr(Wr(e).type),this.getPayloadSenderPublicKey=e=>{const t=Wr(e);return t.senderPublicKey?St(t.senderPublicKey,Ur):void 0},this.core=e,this.logger=qi.generateChildLogger(t,this.name),this.keychain=r||new mc(this.core,this.logger)}get context(){return qi.getLoggerContext(this.logger)}async setPrivateKey(e,t){return await this.keychain.set(e,t),e}getPrivateKey(e){return this.keychain.get(e)}async getClientSeed(){let e="";try{e=this.keychain.get(za)}catch{e=Vr(),await this.keychain.set(za,e)}return function(e,t="utf8"){const r=La[t];if(!r)throw new Error(`Unsupported encoding "${t}"`);return"utf8"!==t&&"utf-8"!==t||null==globalThis.Buffer||null==globalThis.Buffer.from?r.decoder.decode(`${r.prefix}${e}`):Ca(globalThis.Buffer.from(e,"utf-8"))}(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=zn("NOT_INITIALIZED",this.name);throw new Error(e)}}}class bc extends Ji{constructor(e,t){super(e,t),this.logger=e,this.core=t,this.messages=new Map,this.name="messages",this.version="0.3",this.initialized=!1,this.storagePrefix=Ma,this.init=async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const e=await this.getRelayerMessages();typeof e<"u"&&(this.messages=e),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e)}finally{this.initialized=!0}}},this.set=async(e,t)=>{this.isInitialized();const r=Br(t);let n=this.messages.get(e);return typeof n>"u"&&(n={}),typeof n[r]<"u"||(n[r]=t,this.messages.set(e,n),await this.persist()),r},this.get=e=>{this.isInitialized();let t=this.messages.get(e);return typeof t>"u"&&(t={}),t},this.has=(e,t)=>{this.isInitialized();return typeof this.get(e)[Br(t)]<"u"},this.del=async e=>{this.isInitialized(),this.messages.delete(e),await this.persist()},this.logger=qi.generateChildLogger(e,this.name),this.core=t}get context(){return qi.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,dn(e))}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?gn(e):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){const{message:e}=zn("NOT_INITIALIZED",this.name);throw new Error(e)}}}class Ec extends Xi{constructor(t,r){super(t,r),this.relayer=t,this.logger=r,this.events=new e.EventEmitter,this.name="publisher",this.queue=new Map,this.publishTimeout=Mt.toMiliseconds(Mt.TEN_SECONDS),this.queueTimeout=Mt.toMiliseconds(Mt.FIVE_SECONDS),this.needsTransportRestart=!1,this.publish=async(e,t,r)=>{this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:e,message:t,opts:r}});try{const n=r?.ttl||qa,i=In(r),s=r?.prompt||!1,o=r?.tag||0,a=r?.id||Ds().toString(),c={topic:e,message:t,opts:{ttl:n,relay:i,prompt:s,tag:o,id:a}},u=setTimeout((()=>this.queue.set(a,c)),this.queueTimeout);try{await await vn(this.rpcPublish(e,t,n,i,s,o,a),this.publishTimeout),clearTimeout(u),this.relayer.events.emit(Xa,c)}catch{return this.logger.debug("Publishing Payload stalled"),void(this.needsTransportRestart=!0)}this.logger.debug("Successfully Published Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:e,message:t,opts:r}})}catch(e){throw this.logger.debug("Failed to Publish Payload"),this.logger.error(e),e}},this.on=(e,t)=>{this.events.on(e,t)},this.once=(e,t)=>{this.events.once(e,t)},this.off=(e,t)=>{this.events.off(e,t)},this.removeListener=(e,t)=>{this.events.removeListener(e,t)},this.relayer=t,this.logger=qi.generateChildLogger(r,this.name),this.registerEventListeners()}get context(){return qi.getLoggerContext(this.logger)}rpcPublish(e,t,r,n,i,s,o){var a,c,u,h;const l={method:On(n.protocol).publish,params:{topic:e,message:t,ttl:r,prompt:i,tag:s},id:o};return Kn(null==(a=l.params)?void 0:a.prompt)&&(null==(c=l.params)||delete c.prompt),Kn(null==(u=l.params)?void 0:u.tag)&&(null==(h=l.params)||delete h.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:l}),this.relayer.request(l)}onPublish(e){this.queue.delete(e)}checkQueue(){this.queue.forEach((async e=>{const{topic:t,message:r,opts:n}=e;await this.publish(t,r,n)}))}registerEventListeners(){this.relayer.core.heartbeat.on(bi.HEARTBEAT_EVENTS.pulse,(()=>{if(this.needsTransportRestart)return this.needsTransportRestart=!1,void this.relayer.events.emit(Ya);this.checkQueue()})),this.relayer.on(Ba,(e=>{this.onPublish(e.id.toString())}))}}class Sc{constructor(){this.map=new Map,this.set=(e,t)=>{const r=this.get(e);this.exists(e,t)||this.map.set(e,[...r,t])},this.get=e=>this.map.get(e)||[],this.exists=(e,t)=>this.get(e).includes(t),this.delete=(e,t)=>{if(typeof t>"u")return void this.map.delete(e);if(!this.map.has(e))return;const r=this.get(e);if(!this.exists(e,t))return;const n=r.filter((e=>e!==t));n.length?this.map.set(e,n):this.map.delete(e)},this.clear=()=>{this.map.clear()}}get topics(){return Array.from(this.map.keys())}}var Ic=Object.defineProperty,Oc=Object.defineProperties,Pc=Object.getOwnPropertyDescriptors,Nc=Object.getOwnPropertySymbols,Ac=Object.prototype.hasOwnProperty,xc=Object.prototype.propertyIsEnumerable,Cc=(e,t,r)=>t in e?Ic(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Tc=(e,t)=>{for(var r in t||(t={}))Ac.call(t,r)&&Cc(e,r,t[r]);if(Nc)for(var r of Nc(t))xc.call(t,r)&&Cc(e,r,t[r]);return e},Rc=(e,t)=>Oc(e,Pc(t));class jc extends es{constructor(t,r){super(t,r),this.relayer=t,this.logger=r,this.subscriptions=new Map,this.topicMap=new Sc,this.events=new e.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=Ma,this.subscribeTimeout=1e4,this.restartInProgress=!1,this.batchSubscribeTopicsLimit=500,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restart(),this.registerEventListeners(),this.onEnable(),this.clientId=await this.relayer.core.crypto.getClientId())},this.subscribe=async(e,t)=>{await this.restartToComplete(),this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:e,opts:t}});try{const r=In(t),n={topic:e,relay:r};this.pending.set(e,n);const i=await this.rpcSubscribe(e,r);return this.onSubscribe(i,n),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:e,opts:t}}),i}catch(e){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(e),e}},this.unsubscribe=async(e,t)=>{await this.restartToComplete(),this.isInitialized(),typeof t?.id<"u"?await this.unsubscribeById(e,t.id,t):await this.unsubscribeByTopic(e,t)},this.isSubscribed=async e=>!!this.topics.includes(e)||await new Promise(((t,r)=>{const n=new Mt.Watch;n.start(this.pendingSubscriptionWatchLabel);const i=setInterval((()=>{!this.pending.has(e)&&this.topics.includes(e)&&(clearInterval(i),n.stop(this.pendingSubscriptionWatchLabel),t(!0)),n.elapsed(this.pendingSubscriptionWatchLabel)>=ac&&(clearInterval(i),n.stop(this.pendingSubscriptionWatchLabel),r(new Error("Subscription resolution timeout")))}),this.pollingInterval)})).catch((()=>!1)),this.on=(e,t)=>{this.events.on(e,t)},this.once=(e,t)=>{this.events.once(e,t)},this.off=(e,t)=>{this.events.off(e,t)},this.removeListener=(e,t)=>{this.events.removeListener(e,t)},this.restart=async()=>{this.restartInProgress=!0,await this.restore(),await this.reset(),this.restartInProgress=!1},this.relayer=t,this.logger=qi.generateChildLogger(r,this.name),this.clientId=""}get context(){return qi.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}hasSubscription(e,t){let r=!1;try{r=this.getSubscription(e).topic===t}catch{}return r}onEnable(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(e,t){const r=this.topicMap.get(e);await Promise.all(r.map((async r=>await this.unsubscribeById(e,r,t))))}async unsubscribeById(e,t,r){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:r}});try{const n=In(r);await this.rpcUnsubscribe(e,t,n);const i=$n("USER_DISCONNECTED",`${this.name}, ${e}`);await this.onUnsubscribe(e,t,i),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:r}})}catch(e){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(e),e}}async rpcSubscribe(e,t){const r={method:On(t.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:r});try{await await vn(this.relayer.request(r),this.subscribeTimeout)}catch{this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(Ya)}return Br(e+this.clientId)}async rpcBatchSubscribe(e){if(!e.length)return;const t={method:On(e[0].relay.protocol).batchSubscribe,params:{topics:e.map((e=>e.topic))}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:t});try{return await await vn(this.relayer.request(t),this.subscribeTimeout)}catch{this.logger.debug("Outgoing Relay Payload stalled"),this.relayer.events.emit(Ya)}}rpcUnsubscribe(e,t,r){const n={method:On(r.protocol).unsubscribe,params:{topic:e,id:t}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n}),this.relayer.request(n)}onSubscribe(e,t){this.setSubscription(e,Rc(Tc({},t),{id:e})),this.pending.delete(t.topic)}onBatchSubscribe(e){e.length&&e.forEach((e=>{this.setSubscription(e.id,Tc({},e)),this.pending.delete(e.topic)}))}async onUnsubscribe(e,t,r){this.events.removeAllListeners(t),this.hasSubscription(t,e)&&this.deleteSubscription(t,r),await this.relayer.messages.del(e)}async setRelayerSubscriptions(e){await this.relayer.core.storage.setItem(this.storageKey,e)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(e,t){this.subscriptions.has(e)||(this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:e,subscription:t}),this.addSubscription(e,t))}addSubscription(e,t){this.subscriptions.set(e,Tc({},t)),this.topicMap.set(t.topic,e),this.events.emit(nc,t)}getSubscription(e){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});const t=this.subscriptions.get(e);if(!t){const{message:t}=zn("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(t)}return t}deleteSubscription(e,t){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:t});const r=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(r.topic,e),this.events.emit(ic,Rc(Tc({},r),{reason:t}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(sc)}async reset(){if(this.cached.length){const e=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let t=0;t<e;t++){const e=this.cached.splice(0,this.batchSubscribeTopicsLimit);await this.batchSubscribe(e)}}this.events.emit(oc)}async restore(){try{const e=await this.getRelayerSubscriptions();if(typeof e>"u"||!e.length)return;if(this.subscriptions.size){const{message:e}=zn("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(e)}this.cached=e,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values})}catch(e){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(e)}}async batchSubscribe(e){if(!e.length)return;const t=await this.rpcBatchSubscribe(e);qn(t)&&this.onBatchSubscribe(t.map(((t,r)=>Rc(Tc({},e[r]),{id:t}))))}async onConnect(){this.restartInProgress||(await this.restart(),this.onEnable())}onDisconnect(){this.onDisable()}async checkPending(){if(this.relayer.transportExplicitlyClosed)return;const e=[];this.pending.forEach((t=>{e.push(t)})),await this.batchSubscribe(e)}registerEventListeners(){this.relayer.core.heartbeat.on(bi.HEARTBEAT_EVENTS.pulse,(async()=>{await this.checkPending()})),this.relayer.on(Fa,(async()=>{await this.onConnect()})),this.relayer.on(Ga,(()=>{this.onDisconnect()})),this.events.on(nc,(async e=>{const t=nc;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist()})),this.events.on(ic,(async e=>{const t=ic;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist()}))}isInitialized(){if(!this.initialized){const{message:e}=zn("NOT_INITIALIZED",this.name);throw new Error(e)}}async restartToComplete(){this.restartInProgress&&await new Promise((e=>{const t=setInterval((()=>{this.restartInProgress||(clearInterval(t),e())}),this.pollingInterval)}))}}var Lc=Object.defineProperty,Uc=Object.getOwnPropertySymbols,Mc=Object.prototype.hasOwnProperty,Dc=Object.prototype.propertyIsEnumerable,kc=(e,t,r)=>t in e?Lc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;class zc extends Zi{constructor(t){super(t),this.protocol="wc",this.version=2,this.events=new e.EventEmitter,this.name="relayer",this.transportExplicitlyClosed=!1,this.initialized=!1,this.reconnecting=!1,this.connectionStatusPollingInterval=20,this.staleConnectionErrors=["socket hang up","socket stalled"],this.request=async e=>{this.logger.debug("Publishing Request Payload");try{return await this.toEstablishConnection(),await this.provider.request(e)}catch(e){throw this.logger.debug("Failed to Publish Request"),this.logger.error(e),e}},this.core=t.core,this.logger=typeof t.logger<"u"&&"string"!=typeof t.logger?qi.generateChildLogger(t.logger,this.name):qi.pino(qi.getDefaultLoggerOptions({level:t.logger||"error"})),this.messages=new bc(this.logger,t.core),this.subscriber=new jc(this,this.logger),this.publisher=new Ec(this,this.logger),this.relayUrl=t?.relayUrl||Ha,this.projectId=t.projectId,this.provider={}}async init(){this.logger.trace("Initialized"),await this.createProvider(),await Promise.all([this.messages.init(),this.subscriber.init()]);try{await this.transportOpen()}catch{this.logger.warn(`Connection via ${this.relayUrl} failed, attempting to connect via failover domain ${Ka}...`),await this.restartTransport(Ka)}this.registerEventListeners(),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 qi.getLoggerContext(this.logger)}get connected(){return this.provider.connection.connected}get connecting(){return this.provider.connection.connecting}async publish(e,t,r){this.isInitialized(),await this.publisher.publish(e,t,r),await this.recordMessageEvent({topic:e,message:t,publishedAt:Date.now()})}async subscribe(e,t){var r;this.isInitialized();let n=(null==(r=this.subscriber.topicMap.get(e))?void 0:r[0])||"";return n||(await Promise.all([new Promise((t=>{this.subscriber.once(nc,(r=>{r.topic===e&&t()}))})),new Promise((async r=>{n=await this.subscriber.subscribe(e,t),r()}))]),n)}async unsubscribe(e,t){this.isInitialized(),await this.subscriber.unsubscribe(e,t)}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async transportClose(){this.transportExplicitlyClosed=!0,this.connected&&(await this.provider.disconnect(),this.events.emit(Ja))}async transportOpen(e){if(this.transportExplicitlyClosed=!1,!this.reconnecting){this.relayUrl=e||this.relayUrl,this.reconnecting=!0;try{await Promise.all([new Promise((e=>{this.initialized||e(),this.subscriber.once(oc,(()=>{e()}))})),await Promise.race([new Promise((async(e,t)=>{await vn(this.provider.connect(),5e3,`Socket stalled when trying to connect to ${this.relayUrl}`).catch((e=>t(e))).then((()=>e())).finally((()=>this.removeListener(Ja,this.rejectTransportOpen)))})),new Promise((e=>this.once(Ja,this.rejectTransportOpen)))])])}catch(e){this.logger.error(e);const t=e;if(!this.isConnectionStalled(t.message))throw e;this.events.emit(Ja)}finally{this.reconnecting=!1}}}async restartTransport(e){this.transportExplicitlyClosed||this.reconnecting||(this.relayUrl=e||this.relayUrl,this.connected&&await Promise.all([new Promise((e=>{this.provider.once(ec,(()=>{e()}))})),this.transportClose()]),await this.createProvider(),await this.transportOpen())}isConnectionStalled(e){return this.staleConnectionErrors.some((t=>e.includes(t)))}rejectTransportOpen(){throw new Error("Attempt to connect to relay via `transportOpen` has stalled. Retrying...")}async createProvider(){const e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new eo(new no(fn({sdkVersion:"2.9.0",protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e,useOnCloseEvent:!0}))),this.registerProviderListeners()}async recordMessageEvent(e){const{topic:t,message:r}=e;await this.messages.set(t,r)}async shouldIgnoreMessageEvent(e){const{topic:t,message:r}=e;return!await this.subscriber.isSubscribed(t)||this.messages.has(t,r)}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),Js(e)){if(!e.method.endsWith("_subscription"))return;const t=e.params,{topic:r,message:n,publishedAt:i}=t.data,s={topic:r,message:n,publishedAt:i};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(((e,t)=>{for(var r in t||(t={}))Mc.call(t,r)&&kc(e,r,t[r]);if(Uc)for(var r of Uc(t))Dc.call(t,r)&&kc(e,r,t[r]);return e})({type:"event",event:t.id},s)),this.events.emit(t.id,s),await this.acknowledgePayload(e),await this.onMessageEvent(s)}else Xs(e)&&this.events.emit(Ba,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(this.events.emit(Va,e),await this.recordMessageEvent(e))}async acknowledgePayload(e){const t=zs(e.id,!0);await this.provider.connection.send(t)}registerProviderListeners(){this.provider.on(Za,(e=>this.onProviderPayload(e))),this.provider.on(Qa,(()=>{this.events.emit(Fa)})),this.provider.on(ec,(()=>{this.onProviderDisconnect()})),this.provider.on(tc,(e=>{this.logger.error(e),this.events.emit(Wa,e)}))}registerEventListeners(){this.events.on(Ya,(async()=>{await this.restartTransport()}))}onProviderDisconnect(){this.events.emit(Ga),this.attemptToReconnect()}attemptToReconnect(){this.transportExplicitlyClosed||setTimeout((async()=>{await this.restartTransport()}),Mt.toMiliseconds(rc))}isInitialized(){if(!this.initialized){const{message:e}=zn("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){if(!this.connected){if(this.connecting)return await new Promise((e=>{const t=setInterval((()=>{this.connected&&(clearInterval(t),e())}),this.connectionStatusPollingInterval)}));await this.restartTransport()}}}var $c=Object.defineProperty,qc=Object.getOwnPropertySymbols,Hc=Object.prototype.hasOwnProperty,Kc=Object.prototype.propertyIsEnumerable,Vc=(e,t,r)=>t in e?$c(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Bc=(e,t)=>{for(var r in t||(t={}))Hc.call(t,r)&&Vc(e,r,t[r]);if(qc)for(var r of qc(t))Kc.call(t,r)&&Vc(e,r,t[r]);return e};class Fc extends Qi{constructor(e,t,r,n=Ma,i=void 0){super(e,t,r,n),this.core=e,this.logger=t,this.name=r,this.map=new Map,this.version="0.3",this.cached=[],this.initialized=!1,this.storagePrefix=Ma,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach((e=>{this.getKey&&null!==e&&!Kn(e)?this.map.set(this.getKey(e),e):function(e){var t;return null==(t=e?.proposer)?void 0:t.publicKey}(e)?this.map.set(e.id,e):function(e){return e?.topic}(e)&&this.map.set(e.topic,e)})),this.cached=[],this.initialized=!0)},this.set=async(e,t)=>{this.isInitialized(),this.map.has(e)?await this.update(e,t):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:e,value:t}),this.map.set(e,t),await this.persist())},this.get=e=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:e}),this.getData(e)),this.getAll=e=>(this.isInitialized(),e?this.values.filter((t=>Object.keys(e).every((r=>so(t[r],e[r]))))):this.values),this.update=async(e,t)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:e,update:t});const r=Bc(Bc({},this.getData(e)),t);this.map.set(e,r),await this.persist()},this.delete=async(e,t)=>{this.isInitialized(),this.map.has(e)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:e,reason:t}),this.map.delete(e),await this.persist())},this.logger=qi.generateChildLogger(t,this.name),this.storagePrefix=n,this.getKey=i}get context(){return qi.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}async setDataStore(e){await this.core.storage.setItem(this.storageKey,e)}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(e){const t=this.map.get(e);if(!t){const{message:t}=zn("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(t),new Error(t)}return t}async persist(){await this.setDataStore(this.values)}async restore(){try{const e=await this.getDataStore();if(typeof e>"u"||!e.length)return;if(this.map.size){const{message:e}=zn("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),new Error(e)}this.cached=e,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values})}catch(e){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(e)}}isInitialized(){if(!this.initialized){const{message:e}=zn("NOT_INITIALIZED",this.name);throw new Error(e)}}}class Gc{constructor(e,t){this.core=e,this.logger=t,this.name="pairing",this.version="0.3",this.events=new i.default,this.initialized=!1,this.storagePrefix=Ma,this.ignoredPayloadTypes=[zr],this.registeredMethods=[],this.init=async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))},this.register=({methods:e})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...e])]},this.create=async()=>{this.isInitialized();const e=Vr(),t=await this.core.crypto.setSymKey(e),r=wn(Mt.FIVE_MINUTES),n={protocol:"irn"},i={topic:t,expiry:r,relay:n,active:!1},s=jn({protocol:this.core.protocol,version:this.core.version,topic:t,symKey:e,relay:n});return await this.pairings.set(t,i),await this.core.relayer.subscribe(t),this.core.expirer.set(t,r),{topic:t,uri:s}},this.pair=async e=>{this.isInitialized(),this.isValidPair(e);const{topic:t,symKey:r,relay:n}=function(e){const t=e.indexOf(":"),r=-1!==e.indexOf("?")?e.indexOf("?"):void 0,n=e.substring(0,t),i=e.substring(t+1,r).split("@"),s=typeof r<"u"?e.substring(r):"",o=Er.parse(s);return{protocol:n,topic:Rn(i[0]),version:parseInt(i[1],10),symKey:o.symKey,relay:Tn(o)}}(e.uri);if(this.pairings.keys.includes(t))throw new Error(`Pairing already exists: ${t}`);if(this.core.crypto.hasKeys(t))throw new Error(`Keychain already exists: ${t}`);const i=wn(Mt.FIVE_MINUTES),s={topic:t,relay:n,expiry:i,active:!1};return await this.pairings.set(t,s),await this.core.crypto.setSymKey(r,t),await this.core.relayer.subscribe(t,{relay:n}),this.core.expirer.set(t,i),e.activatePairing&&await this.activate({topic:t}),s},this.activate=async({topic:e})=>{this.isInitialized();const t=wn(Mt.THIRTY_DAYS);await this.pairings.update(e,{active:!0,expiry:t}),this.core.expirer.set(e,t)},this.ping=async e=>{this.isInitialized(),await this.isValidPing(e);const{topic:t}=e;if(this.pairings.keys.includes(t)){const e=await this.sendRequest(t,"wc_pairingPing",{}),{done:r,resolve:n,reject:i}=yn();this.events.once(En("pairing_ping",e),(({error:e})=>{e?i(e):n()})),await r()}},this.updateExpiry=async({topic:e,expiry:t})=>{this.isInitialized(),await this.pairings.update(e,{expiry:t})},this.updateMetadata=async({topic:e,metadata:t})=>{this.isInitialized(),await this.pairings.update(e,{peerMetadata:t})},this.getPairings=()=>(this.isInitialized(),this.pairings.values),this.disconnect=async e=>{this.isInitialized(),await this.isValidDisconnect(e);const{topic:t}=e;this.pairings.keys.includes(t)&&(await this.sendRequest(t,"wc_pairingDelete",$n("USER_DISCONNECTED")),await this.deletePairing(t))},this.sendRequest=async(e,t,r)=>{const n=ks(t,r),i=await this.core.crypto.encode(e,n),s=cc[t].req;return this.core.history.set(e,n),this.core.relayer.publish(e,i,s),n.id},this.sendResult=async(e,t,r)=>{const n=zs(e,r),i=await this.core.crypto.encode(t,n),s=await this.core.history.get(t,e),o=cc[s.request.method].res;await this.core.relayer.publish(t,i,o),await this.core.history.resolve(n)},this.sendError=async(e,t,r)=>{const n=$s(e,r),i=await this.core.crypto.encode(t,n),s=await this.core.history.get(t,e),o=cc[s.request.method]?cc[s.request.method].res:cc.unregistered_method.res;await this.core.relayer.publish(t,i,o),await this.core.history.resolve(n)},this.deletePairing=async(e,t)=>{await this.core.relayer.unsubscribe(e),await Promise.all([this.pairings.delete(e,$n("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(e),t?Promise.resolve():this.core.expirer.del(e)])},this.cleanup=async()=>{const e=this.pairings.getAll().filter((e=>bn(e.expiry)));await Promise.all(e.map((e=>this.deletePairing(e.topic))))},this.onRelayEventRequest=e=>{const{topic:t,payload:r}=e,n=r.method;if(this.pairings.keys.includes(t))switch(n){case"wc_pairingPing":return this.onPairingPingRequest(t,r);case"wc_pairingDelete":return this.onPairingDeleteRequest(t,r);default:return this.onUnknownRpcMethodRequest(t,r)}},this.onRelayEventResponse=async e=>{const{topic:t,payload:r}=e,n=(await this.core.history.get(t,r.id)).request.method;if(this.pairings.keys.includes(t)){if("wc_pairingPing"===n)return this.onPairingPingResponse(t,r);return this.onUnknownRpcMethodResponse(n)}},this.onPairingPingRequest=async(e,t)=>{const{id:r}=t;try{this.isValidPing({topic:e}),await this.sendResult(r,e,!0),this.events.emit("pairing_ping",{id:r,topic:e})}catch(t){await this.sendError(r,e,t),this.logger.error(t)}},this.onPairingPingResponse=(e,t)=>{const{id:r}=t;setTimeout((()=>{Zs(t)?this.events.emit(En("pairing_ping",r),{}):Qs(t)&&this.events.emit(En("pairing_ping",r),{error:t.error})}),500)},this.onPairingDeleteRequest=async(e,t)=>{const{id:r}=t;try{this.isValidDisconnect({topic:e}),await this.deletePairing(e),this.events.emit("pairing_delete",{id:r,topic:e})}catch(t){await this.sendError(r,e,t),this.logger.error(t)}},this.onUnknownRpcMethodRequest=async(e,t)=>{const{id:r,method:n}=t;try{if(this.registeredMethods.includes(n))return;const t=$n("WC_METHOD_UNSUPPORTED",n);await this.sendError(r,e,t),this.logger.error(t)}catch(t){await this.sendError(r,e,t),this.logger.error(t)}},this.onUnknownRpcMethodResponse=e=>{this.registeredMethods.includes(e)||this.logger.error($n("WC_METHOD_UNSUPPORTED",e))},this.isValidPair=e=>{if(!Qn(e)){const{message:t}=zn("MISSING_OR_INVALID",`pair() params: ${e}`);throw new Error(t)}if(!function(e){if(Vn(e,!1))try{return typeof new URL(e)<"u"}catch{return!1}return!1}(e.uri)){const{message:t}=zn("MISSING_OR_INVALID",`pair() uri: ${e.uri}`);throw new Error(t)}},this.isValidPing=async e=>{if(!Qn(e)){const{message:t}=zn("MISSING_OR_INVALID",`ping() params: ${e}`);throw new Error(t)}const{topic:t}=e;await this.isValidPairingTopic(t)},this.isValidDisconnect=async e=>{if(!Qn(e)){const{message:t}=zn("MISSING_OR_INVALID",`disconnect() params: ${e}`);throw new Error(t)}const{topic:t}=e;await this.isValidPairingTopic(t)},this.isValidPairingTopic=async e=>{if(!Vn(e,!1)){const{message:t}=zn("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(t)}if(!this.pairings.keys.includes(e)){const{message:t}=zn("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(t)}if(bn(this.pairings.get(e).expiry)){await this.deletePairing(e);const{message:t}=zn("EXPIRED",`pairing topic: ${e}`);throw new Error(t)}},this.core=e,this.logger=qi.generateChildLogger(t,this.name),this.pairings=new Fc(this.core,this.logger,this.name,this.storagePrefix)}get context(){return qi.getLoggerContext(this.logger)}isInitialized(){if(!this.initialized){const{message:e}=zn("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(Va,(async e=>{const{topic:t,message:r}=e;if(this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(r)))return;const n=await this.core.crypto.decode(t,r);Js(n)?(this.core.history.set(t,n),this.onRelayEventRequest({topic:t,payload:n})):Xs(n)&&(await this.core.history.resolve(n),await this.onRelayEventResponse({topic:t,payload:n}),this.core.history.delete(t,n.id))}))}registerExpirerEvents(){this.core.expirer.on(gc,(async e=>{const{topic:t}=mn(e.target);t&&this.pairings.keys.includes(t)&&(await this.deletePairing(t,!0),this.events.emit("pairing_expire",{topic:t}))}))}}class Wc extends Yi{constructor(t,r){super(t,r),this.core=t,this.logger=r,this.records=new Map,this.events=new e.EventEmitter,this.name="history",this.version="0.3",this.cached=[],this.initialized=!1,this.storagePrefix=Ma,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach((e=>this.records.set(e.id,e))),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.set=(e,t,r)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:e,request:t,chainId:r}),this.records.has(t.id))return;const n={id:t.id,topic:e,request:{method:t.method,params:t.params||null},chainId:r,expiry:wn(Mt.THIRTY_DAYS)};this.records.set(n.id,n),this.events.emit(uc,n)},this.resolve=async e=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:e}),!this.records.has(e.id))return;const t=await this.getRecord(e.id);typeof t.response>"u"&&(t.response=Qs(e)?{error:e.error}:{result:e.result},this.records.set(t.id,t),this.events.emit(hc,t))},this.get=async(e,t)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:e,id:t}),await this.getRecord(t)),this.delete=(e,t)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:t}),this.values.forEach((r=>{if(r.topic===e){if(typeof t<"u"&&r.id!==t)return;this.records.delete(r.id),this.events.emit(lc,r)}}))},this.exists=async(e,t)=>(this.isInitialized(),!!this.records.has(t)&&(await this.getRecord(t)).topic===e),this.on=(e,t)=>{this.events.on(e,t)},this.once=(e,t)=>{this.events.once(e,t)},this.off=(e,t)=>{this.events.off(e,t)},this.removeListener=(e,t)=>{this.events.removeListener(e,t)},this.logger=qi.generateChildLogger(r,this.name)}get context(){return qi.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){const e=[];return this.values.forEach((t=>{if(typeof t.response<"u")return;const r={topic:t.topic,request:ks(t.request.method,t.request.params,t.id),chainId:t.chainId};return e.push(r)})),e}async setJsonRpcRecords(e){await this.core.storage.setItem(this.storageKey,e)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(e){this.isInitialized();const t=this.records.get(e);if(!t){const{message:t}=zn("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(t)}return t}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(fc)}async restore(){try{const e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){const{message:e}=zn("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),new Error(e)}this.cached=e,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values})}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e)}}registerEventListeners(){this.events.on(uc,(e=>{const t=uc;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e}),this.persist()})),this.events.on(hc,(e=>{const t=hc;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e}),this.persist()})),this.events.on(lc,(e=>{const t=lc;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e}),this.persist()})),this.core.heartbeat.on(bi.HEARTBEAT_EVENTS.pulse,(()=>{this.cleanup()}))}cleanup(){try{this.records.forEach((e=>{Mt.toMiliseconds(e.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${e.id}`),this.delete(e.topic,e.id))}))}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){const{message:e}=zn("NOT_INITIALIZED",this.name);throw new Error(e)}}}class Yc extends ts{constructor(t,r){super(t,r),this.core=t,this.logger=r,this.expirations=new Map,this.events=new e.EventEmitter,this.name="expirer",this.version="0.3",this.cached=[],this.initialized=!1,this.storagePrefix=Ma,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach((e=>this.expirations.set(e.target,e))),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.has=e=>{try{const t=this.formatTarget(e);return typeof this.getExpiration(t)<"u"}catch{return!1}},this.set=(e,t)=>{this.isInitialized();const r=this.formatTarget(e),n={target:r,expiry:t};this.expirations.set(r,n),this.checkExpiry(r,n),this.events.emit(pc,{target:r,expiration:n})},this.get=e=>{this.isInitialized();const t=this.formatTarget(e);return this.getExpiration(t)},this.del=e=>{if(this.isInitialized(),this.has(e)){const t=this.formatTarget(e),r=this.getExpiration(t);this.expirations.delete(t),this.events.emit(dc,{target:t,expiration:r})}},this.on=(e,t)=>{this.events.on(e,t)},this.once=(e,t)=>{this.events.once(e,t)},this.off=(e,t)=>{this.events.off(e,t)},this.removeListener=(e,t)=>{this.events.removeListener(e,t)},this.logger=qi.generateChildLogger(r,this.name)}get context(){return qi.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(e){if("string"==typeof e)return function(e){return _n("topic",e)}(e);if("number"==typeof e)return function(e){return _n("id",e)}(e);const{message:t}=zn("UNKNOWN_TYPE","Target type: "+typeof e);throw new Error(t)}async setExpirations(e){await this.core.storage.setItem(this.storageKey,e)}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit(yc)}async restore(){try{const e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){const{message:e}=zn("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),new Error(e)}this.cached=e,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(e){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(e)}}getExpiration(e){const t=this.expirations.get(e);if(!t){const{message:t}=zn("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(t),new Error(t)}return t}checkExpiry(e,t){const{expiry:r}=t;Mt.toMiliseconds(r)-Date.now()<=0&&this.expire(e,t)}expire(e,t){this.expirations.delete(e),this.events.emit(gc,{target:e,expiration:t})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach(((e,t)=>this.checkExpiry(t,e)))}registerEventListeners(){this.core.heartbeat.on(bi.HEARTBEAT_EVENTS.pulse,(()=>this.checkExpirations())),this.events.on(pc,(e=>{const t=pc;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()})),this.events.on(gc,(e=>{const t=gc;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()})),this.events.on(dc,(e=>{const t=dc;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}))}isInitialized(){if(!this.initialized){const{message:e}=zn("NOT_INITIALIZED",this.name);throw new Error(e)}}}class Jc extends rs{constructor(e,t){super(e,t),this.projectId=e,this.logger=t,this.name=vc,this.initialized=!1,this.init=async e=>{cn()||!un()||(this.verifyUrl=e?.verifyUrl||_c,await this.createIframe())},this.register=async e=>{var t;if(this.initialized||await this.init(),this.iframe)try{null==(t=this.iframe.contentWindow)||t.postMessage(e.attestationId,this.verifyUrl),this.logger.info(`postMessage sent: ${e.attestationId} ${this.verifyUrl}`)}catch{}},this.resolve=async e=>{var t;if(this.isDevEnv)return"";this.logger.info(`resolving attestation: ${e.attestationId}`);const r=this.startAbortTimer(Mt.FIVE_SECONDS),n=await fetch(`${this.verifyUrl}/attestation/${e.attestationId}`,{signal:this.abortController.signal});return clearTimeout(r),200===n.status?null==(t=await n.json())?void 0:t.origin:""},this.createIframe=async()=>{try{await Promise.race([new Promise(((e,t)=>{if(document.getElementById(vc))return e();const r=document.createElement("iframe");r.setAttribute("id",vc),r.setAttribute("src",`${this.verifyUrl}/${this.projectId}`),r.style.display="none",r.addEventListener("load",(()=>{this.initialized=!0,e()})),r.addEventListener("error",(e=>{t(e)})),document.body.append(r),this.iframe=r})),new Promise((e=>{setTimeout((()=>e("iframe load timeout")),Mt.toMiliseconds(Mt.ONE_SECOND/2))}))])}catch(e){this.logger.error(`Verify iframe failed to load: ${this.verifyUrl}`),this.logger.error(e)}},this.logger=qi.generateChildLogger(t,this.name),this.verifyUrl=_c,this.abortController=new AbortController,this.isDevEnv=an()&&process.env.IS_VITEST}get context(){return qi.getLoggerContext(this.logger)}startAbortTimer(e){return setTimeout((()=>this.abortController.abort()),Mt.toMiliseconds(e))}}var Xc=Object.defineProperty,Zc=Object.getOwnPropertySymbols,Qc=Object.prototype.hasOwnProperty,eu=Object.prototype.propertyIsEnumerable,tu=(e,t,r)=>t in e?Xc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ru=(e,t)=>{for(var r in t||(t={}))Qc.call(t,r)&&tu(e,r,t[r]);if(Zc)for(var r of Zc(t))eu.call(t,r)&&tu(e,r,t[r]);return e};class nu extends Wi{constructor(t){super(t),this.protocol="wc",this.version=2,this.name=Ua,this.events=new e.EventEmitter,this.initialized=!1,this.on=(e,t)=>this.events.on(e,t),this.once=(e,t)=>this.events.once(e,t),this.off=(e,t)=>this.events.off(e,t),this.removeListener=(e,t)=>this.events.removeListener(e,t),this.projectId=t?.projectId,this.relayUrl=t?.relayUrl||Ha;const r=typeof t?.logger<"u"&&"string"!=typeof t?.logger?t.logger:qi.pino(qi.getDefaultLoggerOptions({level:t?.logger||Da}));this.logger=qi.generateChildLogger(r,this.name),this.heartbeat=new bi.HeartBeat,this.crypto=new wc(this,this.logger,t?.keychain),this.history=new Wc(this,this.logger),this.expirer=new Yc(this,this.logger),this.storage=null!=t&&t.storage?t.storage:new wi(ru(ru({},ka),t?.storageOptions)),this.relayer=new zc({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new Gc(this,this.logger),this.verify=new Jc(this.projectId||"",this.logger)}static async init(e){const t=new nu(e);await t.initialize();const r=await t.crypto.getClientId();return await t.storage.setItem("WALLETCONNECT_CLIENT_ID",r),t}get context(){return qi.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(e){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,e),this.logger.error(e.message),e}}}const iu=nu,su="client",ou=`wc@2:${su}:`,au=su,cu="error",uu="Proposal expired",hu=Mt.SEVEN_DAYS,lu={wc_sessionPropose:{req:{ttl:Mt.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:Mt.FIVE_MINUTES,prompt:!1,tag:1101}},wc_sessionSettle:{req:{ttl:Mt.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:Mt.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:Mt.ONE_DAY,prompt:!1,tag:1104},res:{ttl:Mt.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:Mt.ONE_DAY,prompt:!1,tag:1106},res:{ttl:Mt.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:Mt.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:Mt.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:Mt.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:Mt.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:Mt.ONE_DAY,prompt:!1,tag:1112},res:{ttl:Mt.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:Mt.THIRTY_SECONDS,prompt:!1,tag:1114},res:{ttl:Mt.THIRTY_SECONDS,prompt:!1,tag:1115}}},fu={min:Mt.FIVE_MINUTES,max:Mt.SEVEN_DAYS},pu=["wc_sessionPropose","wc_sessionRequest","wc_authRequest"];var du=Object.defineProperty,gu=Object.defineProperties,yu=Object.getOwnPropertyDescriptors,vu=Object.getOwnPropertySymbols,_u=Object.prototype.hasOwnProperty,mu=Object.prototype.propertyIsEnumerable,wu=(e,t,r)=>t in e?du(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,bu=(e,t)=>{for(var r in t||(t={}))_u.call(t,r)&&wu(e,r,t[r]);if(vu)for(var r of vu(t))mu.call(t,r)&&wu(e,r,t[r]);return e},Eu=(e,t)=>gu(e,yu(t));class Su extends is{constructor(e){super(e),this.name="engine",this.events=new i.default,this.initialized=!1,this.ignoredPayloadTypes=[zr],this.init=async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.client.core.pairing.register({methods:Object.keys(lu)}),this.initialized=!0)},this.connect=async e=>{this.isInitialized();const t=Eu(bu({},e),{requiredNamespaces:e.requiredNamespaces||{},optionalNamespaces:e.optionalNamespaces||{}});await this.isValidConnect(t);const{pairingTopic:r,requiredNamespaces:n,optionalNamespaces:i,sessionProperties:s,relays:o}=t;let a,c=r,u=!1;if(c&&(u=this.client.core.pairing.pairings.get(c).active),!c||!u){const{topic:e,uri:t}=await this.client.core.pairing.create();c=e,a=t}const h=await this.client.core.crypto.generateKeyPair(),l=bu({requiredNamespaces:n,optionalNamespaces:i,relays:o??[{protocol:"irn"}],proposer:{publicKey:h,metadata:this.client.metadata}},s&&{sessionProperties:s}),{reject:f,resolve:p,done:d}=yn(Mt.FIVE_MINUTES,uu);if(this.events.once(En("session_connect"),(async({error:e,session:t})=>{if(e)f(e);else if(t){t.self.publicKey=h;const e=Eu(bu({},t),{requiredNamespaces:t.requiredNamespaces,optionalNamespaces:t.optionalNamespaces});await this.client.session.set(t.topic,e),await this.setExpiry(t.topic,t.expiry),c&&await this.client.core.pairing.updateMetadata({topic:c,metadata:t.peer.metadata}),p(e)}})),!c){const{message:e}=zn("NO_MATCHING_KEY",`connect() pairing topic: ${c}`);throw new Error(e)}const g=await this.sendRequest(c,"wc_sessionPropose",l),y=wn(Mt.FIVE_MINUTES);return await this.setProposal(g,bu({id:g,expiry:y},l)),{uri:a,approval:d}},this.pair=async e=>(this.isInitialized(),await this.client.core.pairing.pair(e)),this.approve=async e=>{this.isInitialized(),await this.isValidApprove(e);const{id:t,relayProtocol:r,namespaces:n,sessionProperties:i}=e,s=this.client.proposal.get(t);let{pairingTopic:o,proposer:a,requiredNamespaces:c,optionalNamespaces:u}=s;o=o||"",Hn(c)||(c=function(e,t){const r=Xn(e,t);if(r)throw new Error(r.message);const n={};for(const[t,r]of Object.entries(e))n[t]={methods:r.methods,events:r.events,chains:r.accounts.map((e=>`${e.split(":")[0]}:${e.split(":")[1]}`))};return n}(n,"approve()"));const h=await this.client.core.crypto.generateKeyPair(),l=a.publicKey,f=await this.client.core.crypto.generateSharedKey(h,l);o&&t&&(await this.client.core.pairing.updateMetadata({topic:o,metadata:a.metadata}),await this.sendResult(t,o,{relay:{protocol:r??"irn"},responderPublicKey:h}),await this.client.proposal.delete(t,$n("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:o}));const p=bu({relay:{protocol:r??"irn"},namespaces:n,requiredNamespaces:c,optionalNamespaces:u,pairingTopic:o,controller:{publicKey:h,metadata:this.client.metadata},expiry:wn(hu)},i&&{sessionProperties:i});await this.client.core.relayer.subscribe(f),await this.sendRequest(f,"wc_sessionSettle",p);const d=Eu(bu({},p),{topic:f,pairingTopic:o,acknowledged:!1,self:p.controller,peer:{publicKey:a.publicKey,metadata:a.metadata},controller:h});return await this.client.session.set(f,d),await this.setExpiry(f,wn(hu)),{topic:f,acknowledged:()=>new Promise((e=>setTimeout((()=>e(this.client.session.get(f))),500)))}},this.reject=async e=>{this.isInitialized(),await this.isValidReject(e);const{id:t,reason:r}=e,{pairingTopic:n}=this.client.proposal.get(t);n&&(await this.sendError(t,n,r),await this.client.proposal.delete(t,$n("USER_DISCONNECTED")))},this.update=async e=>{this.isInitialized(),await this.isValidUpdate(e);const{topic:t,namespaces:r}=e,n=await this.sendRequest(t,"wc_sessionUpdate",{namespaces:r}),{done:i,resolve:s,reject:o}=yn();return this.events.once(En("session_update",n),(({error:e})=>{e?o(e):s()})),await this.client.session.update(t,{namespaces:r}),{acknowledged:i}},this.extend=async e=>{this.isInitialized(),await this.isValidExtend(e);const{topic:t}=e,r=await this.sendRequest(t,"wc_sessionExtend",{}),{done:n,resolve:i,reject:s}=yn();return this.events.once(En("session_extend",r),(({error:e})=>{e?s(e):i()})),await this.setExpiry(t,wn(hu)),{acknowledged:n}},this.request=async e=>{this.isInitialized(),await this.isValidRequest(e);const{chainId:t,request:r,topic:n,expiry:i}=e,s=await this.sendRequest(n,"wc_sessionRequest",{request:r,chainId:t},i),{done:o,resolve:a,reject:c}=yn(i);this.events.once(En("session_request",s),(({error:e,result:t})=>{e?c(e):a(t)})),this.client.events.emit("session_request_sent",{topic:n,request:r,chainId:t,id:s});return async function({id:e,topic:t,wcDeepLink:r}){try{if(!r)return;const n="string"==typeof r?JSON.parse(r):r;let i=n?.href;if("string"!=typeof i)return;i.endsWith("/")&&(i=i.slice(0,-1));const s=`${i}/wc?requestId=${e}&sessionTopic=${t}`,o=hn();o===sn.browser?s.startsWith("https://")?window.open(s,"_blank","noreferrer noopener"):window.open(s,"_self","noreferrer noopener"):o===sn.reactNative&&typeof(null==global?void 0:global.Linking)<"u"&&await global.Linking.openURL(s)}catch(e){console.error(e)}}({id:s,topic:n,wcDeepLink:await this.client.core.storage.getItem("WALLETCONNECT_DEEPLINK_CHOICE")}),await o()},this.respond=async e=>{this.isInitialized(),await this.isValidRespond(e);const{topic:t,response:r}=e,{id:n}=r;Zs(r)?await this.sendResult(n,t,r.result):Qs(r)&&await this.sendError(n,t,r.error),this.deletePendingSessionRequest(e.response.id,{message:"fulfilled",code:0})},this.ping=async e=>{this.isInitialized(),await this.isValidPing(e);const{topic:t}=e;if(this.client.session.keys.includes(t)){const e=await this.sendRequest(t,"wc_sessionPing",{}),{done:r,resolve:n,reject:i}=yn();this.events.once(En("session_ping",e),(({error:e})=>{e?i(e):n()})),await r()}else this.client.core.pairing.pairings.keys.includes(t)&&await this.client.core.pairing.ping({topic:t})},this.emit=async e=>{this.isInitialized(),await this.isValidEmit(e);const{topic:t,event:r,chainId:n}=e;await this.sendRequest(t,"wc_sessionEvent",{event:r,chainId:n})},this.disconnect=async e=>{this.isInitialized(),await this.isValidDisconnect(e);const{topic:t}=e;if(this.client.session.keys.includes(t)){const e=Ds().toString();let r;const n=t=>{t?.id.toString()===e&&(this.client.core.relayer.events.removeListener(Ba,n),r())};await Promise.all([new Promise((e=>{r=e,this.client.core.relayer.on(Ba,n)})),this.sendRequest(t,"wc_sessionDelete",$n("USER_DISCONNECTED"),void 0,e)]),await this.deleteSession(t)}else await this.client.core.pairing.disconnect({topic:t})},this.find=e=>(this.isInitialized(),this.client.session.getAll().filter((t=>function(e,t){const{requiredNamespaces:r}=t,n=Object.keys(e.namespaces),i=Object.keys(r);let s=!0;return!!pn(i,n)&&(n.forEach((t=>{const{accounts:n,methods:i,events:o}=e.namespaces[t],a=Ln(n),c=r[t];pn(jr(t,c),a)&&pn(c.methods,i)&&pn(c.events,o)||(s=!1)})),s)}(t,e)))),this.getPendingSessionRequests=()=>(this.isInitialized(),this.client.pendingRequest.getAll()),this.cleanupDuplicatePairings=async e=>{if(e.pairingTopic)try{const t=this.client.core.pairing.pairings.get(e.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)===e.peer.metadata.url&&r.topic&&r.topic!==t.topic}));if(0===r.length)return;this.client.logger.info(`Cleaning up ${r.length} duplicate pairing(s)`),await Promise.all(r.map((e=>this.client.core.pairing.disconnect({topic:e.topic})))),this.client.logger.info("Duplicate pairings clean up finished")}catch(e){this.client.logger.error(e)}},this.deleteSession=async(e,t)=>{const{self:r}=this.client.session.get(e);await this.client.core.relayer.unsubscribe(e),this.client.session.delete(e,$n("USER_DISCONNECTED")),this.client.core.crypto.keychain.has(r.publicKey)&&await this.client.core.crypto.deleteKeyPair(r.publicKey),this.client.core.crypto.keychain.has(e)&&await this.client.core.crypto.deleteSymKey(e),t||this.client.core.expirer.del(e)},this.deleteProposal=async(e,t)=>{await Promise.all([this.client.proposal.delete(e,$n("USER_DISCONNECTED")),t?Promise.resolve():this.client.core.expirer.del(e)])},this.deletePendingSessionRequest=async(e,t,r=!1)=>{await Promise.all([this.client.pendingRequest.delete(e,t),r?Promise.resolve():this.client.core.expirer.del(e)])},this.setExpiry=async(e,t)=>{this.client.session.keys.includes(e)&&await this.client.session.update(e,{expiry:t}),this.client.core.expirer.set(e,t)},this.setProposal=async(e,t)=>{await this.client.proposal.set(e,t),this.client.core.expirer.set(e,t.expiry)},this.setPendingSessionRequest=async e=>{const t=lu.wc_sessionRequest.req.ttl,{id:r,topic:n,params:i}=e;await this.client.pendingRequest.set(r,{id:r,topic:n,params:i}),t&&this.client.core.expirer.set(r,wn(t))},this.sendRequest=async(e,t,r,n,i)=>{const s=ks(t,r);if(un()&&pu.includes(t)){const e=Br(JSON.stringify(s));await this.client.core.verify.register({attestationId:e})}const o=await this.client.core.crypto.encode(e,s),a=lu[t].req;return n&&(a.ttl=n),i&&(a.id=i),this.client.core.history.set(e,s),this.client.core.relayer.publish(e,o,a),s.id},this.sendResult=async(e,t,r)=>{const n=zs(e,r),i=await this.client.core.crypto.encode(t,n),s=await this.client.core.history.get(t,e),o=lu[s.request.method].res;this.client.core.relayer.publish(t,i,o),await this.client.core.history.resolve(n)},this.sendError=async(e,t,r)=>{const n=$s(e,r),i=await this.client.core.crypto.encode(t,n),s=await this.client.core.history.get(t,e),o=lu[s.request.method].res;this.client.core.relayer.publish(t,i,o),await this.client.core.history.resolve(n)},this.cleanup=async()=>{const e=[],t=[];this.client.session.getAll().forEach((t=>{bn(t.expiry)&&e.push(t.topic)})),this.client.proposal.getAll().forEach((e=>{bn(e.expiry)&&t.push(e.id)})),await Promise.all([...e.map((e=>this.deleteSession(e))),...t.map((e=>this.deleteProposal(e)))])},this.onRelayEventRequest=e=>{const{topic:t,payload:r}=e,n=r.method;switch(n){case"wc_sessionPropose":return this.onSessionProposeRequest(t,r);case"wc_sessionSettle":return this.onSessionSettleRequest(t,r);case"wc_sessionUpdate":return this.onSessionUpdateRequest(t,r);case"wc_sessionExtend":return this.onSessionExtendRequest(t,r);case"wc_sessionPing":return this.onSessionPingRequest(t,r);case"wc_sessionDelete":return this.onSessionDeleteRequest(t,r);case"wc_sessionRequest":return this.onSessionRequest(t,r);case"wc_sessionEvent":return this.onSessionEventRequest(t,r);default:return this.client.logger.info(`Unsupported request method ${n}`)}},this.onRelayEventResponse=async e=>{const{topic:t,payload:r}=e,n=(await this.client.core.history.get(t,r.id)).request.method;switch(n){case"wc_sessionPropose":return this.onSessionProposeResponse(t,r);case"wc_sessionSettle":return this.onSessionSettleResponse(t,r);case"wc_sessionUpdate":return this.onSessionUpdateResponse(t,r);case"wc_sessionExtend":return this.onSessionExtendResponse(t,r);case"wc_sessionPing":return this.onSessionPingResponse(t,r);case"wc_sessionRequest":return this.onSessionRequestResponse(t,r);default:return this.client.logger.info(`Unsupported response method ${n}`)}},this.onRelayEventUnknownPayload=e=>{const{topic:t}=e,{message:r}=zn("MISSING_OR_INVALID",`Decoded payload on topic ${t} is not identifiable as a JSON-RPC request or a response.`);throw new Error(r)},this.onSessionProposeRequest=async(e,t)=>{const{params:r,id:n}=t;try{this.isValidConnect(bu({},t.params));const i=wn(Mt.FIVE_MINUTES),s=bu({id:n,pairingTopic:e,expiry:i},r);await this.setProposal(n,s);const o=Br(JSON.stringify(t)),a=await this.getVerifyContext(o,s.proposer.metadata);this.client.events.emit("session_proposal",{id:n,params:s,verifyContext:a})}catch(t){await this.sendError(n,e,t),this.client.logger.error(t)}},this.onSessionProposeResponse=async(e,t)=>{const{id:r}=t;if(Zs(t)){const{result:n}=t;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:e})}else Qs(t)&&(await this.client.proposal.delete(r,$n("USER_DISCONNECTED")),this.events.emit(En("session_connect"),{error:t.error}))},this.onSessionSettleRequest=async(e,t)=>{const{id:r,params:n}=t;try{this.isValidSessionSettleRequest(n);const{relay:r,controller:i,expiry:s,namespaces:o,requiredNamespaces:a,optionalNamespaces:c,sessionProperties:u,pairingTopic:h}=t.params,l=bu({topic:e,relay:r,expiry:s,namespaces:o,acknowledged:!0,pairingTopic:h,requiredNamespaces:a,optionalNamespaces:c,controller:i.publicKey,self:{publicKey:"",metadata:this.client.metadata},peer:{publicKey:i.publicKey,metadata:i.metadata}},u&&{sessionProperties:u});await this.sendResult(t.id,e,!0),this.events.emit(En("session_connect"),{session:l}),this.cleanupDuplicatePairings(l)}catch(t){await this.sendError(r,e,t),this.client.logger.error(t)}},this.onSessionSettleResponse=async(e,t)=>{const{id:r}=t;Zs(t)?(await this.client.session.update(e,{acknowledged:!0}),this.events.emit(En("session_approve",r),{})):Qs(t)&&(await this.client.session.delete(e,$n("USER_DISCONNECTED")),this.events.emit(En("session_approve",r),{error:t.error}))},this.onSessionUpdateRequest=async(e,t)=>{const{params:r,id:n}=t;try{this.isValidUpdate(bu({topic:e},r)),await this.client.session.update(e,{namespaces:r.namespaces}),await this.sendResult(n,e,!0),this.client.events.emit("session_update",{id:n,topic:e,params:r})}catch(t){await this.sendError(n,e,t),this.client.logger.error(t)}},this.onSessionUpdateResponse=(e,t)=>{const{id:r}=t;Zs(t)?this.events.emit(En("session_update",r),{}):Qs(t)&&this.events.emit(En("session_update",r),{error:t.error})},this.onSessionExtendRequest=async(e,t)=>{const{id:r}=t;try{this.isValidExtend({topic:e}),await this.setExpiry(e,wn(hu)),await this.sendResult(r,e,!0),this.client.events.emit("session_extend",{id:r,topic:e})}catch(t){await this.sendError(r,e,t),this.client.logger.error(t)}},this.onSessionExtendResponse=(e,t)=>{const{id:r}=t;Zs(t)?this.events.emit(En("session_extend",r),{}):Qs(t)&&this.events.emit(En("session_extend",r),{error:t.error})},this.onSessionPingRequest=async(e,t)=>{const{id:r}=t;try{this.isValidPing({topic:e}),await this.sendResult(r,e,!0),this.client.events.emit("session_ping",{id:r,topic:e})}catch(t){await this.sendError(r,e,t),this.client.logger.error(t)}},this.onSessionPingResponse=(e,t)=>{const{id:r}=t;setTimeout((()=>{Zs(t)?this.events.emit(En("session_ping",r),{}):Qs(t)&&this.events.emit(En("session_ping",r),{error:t.error})}),500)},this.onSessionDeleteRequest=async(e,t)=>{const{id:r}=t;try{this.isValidDisconnect({topic:e,reason:t.params}),await Promise.all([new Promise((t=>{this.client.core.relayer.once(Xa,(async()=>{t(await this.deleteSession(e))}))})),this.sendResult(r,e,!0)]),this.client.events.emit("session_delete",{id:r,topic:e})}catch(e){this.client.logger.error(e)}},this.onSessionRequest=async(e,t)=>{const{id:r,params:n}=t;try{this.isValidRequest(bu({topic:e},n)),await this.setPendingSessionRequest({id:r,topic:e,params:n});const i=Br(JSON.stringify(t)),s=this.client.session.get(e),o=await this.getVerifyContext(i,s.peer.metadata);this.client.events.emit("session_request",{id:r,topic:e,params:n,verifyContext:o})}catch(t){await this.sendError(r,e,t),this.client.logger.error(t)}},this.onSessionRequestResponse=(e,t)=>{const{id:r}=t;Zs(t)?this.events.emit(En("session_request",r),{result:t.result}):Qs(t)&&this.events.emit(En("session_request",r),{error:t.error})},this.onSessionEventRequest=async(e,t)=>{const{id:r,params:n}=t;try{this.isValidEmit(bu({topic:e},n)),this.client.events.emit("session_event",{id:r,topic:e,params:n})}catch(t){await this.sendError(r,e,t),this.client.logger.error(t)}},this.isValidConnect=async e=>{if(!Qn(e)){const{message:t}=zn("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(e)}`);throw new Error(t)}const{pairingTopic:t,requiredNamespaces:r,optionalNamespaces:n,sessionProperties:i,relays:s}=e;if(Kn(t)||await this.isValidPairingTopic(t),!function(e,t){let r=!1;return t&&!e?r=!0:e&&qn(e)&&e.length&&e.forEach((e=>{r=Zn(e)})),r}(s,!0)){const{message:e}=zn("MISSING_OR_INVALID",`connect() relays: ${s}`);throw new Error(e)}!Kn(r)&&0!==Hn(r)&&this.validateNamespaces(r,"requiredNamespaces"),!Kn(n)&&0!==Hn(n)&&this.validateNamespaces(n,"optionalNamespaces"),Kn(i)||this.validateSessionProps(i,"sessionProperties")},this.validateNamespaces=(e,t)=>{const r=function(e,t,r){let n=null;if(e&&Hn(e)){const i=Jn(e,t);i&&(n=i);const s=Wn(e,t,r);s&&(n=s)}else n=zn("MISSING_OR_INVALID",`${t}, ${r} should be an object with data`);return n}(e,"connect()",t);if(r)throw new Error(r.message)},this.isValidApprove=async e=>{if(!Qn(e))throw new Error(zn("MISSING_OR_INVALID",`approve() params: ${e}`).message);const{id:t,namespaces:r,relayProtocol:n,sessionProperties:i}=e;await this.isValidProposalId(t);const s=this.client.proposal.get(t),o=Xn(r,"approve()");if(o)throw new Error(o.message);const a=ni(s.requiredNamespaces,r,"approve()");if(a)throw new Error(a.message);if(!Vn(n,!0)){const{message:e}=zn("MISSING_OR_INVALID",`approve() relayProtocol: ${n}`);throw new Error(e)}Kn(i)||this.validateSessionProps(i,"sessionProperties")},this.isValidReject=async e=>{if(!Qn(e)){const{message:t}=zn("MISSING_OR_INVALID",`reject() params: ${e}`);throw new Error(t)}const{id:t,reason:r}=e;if(await this.isValidProposalId(t),!function(e){return!!(e&&"object"==typeof e&&e.code&&Bn(e.code,!1)&&e.message&&Vn(e.message,!1))}(r)){const{message:e}=zn("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(r)}`);throw new Error(e)}},this.isValidSessionSettleRequest=e=>{if(!Qn(e)){const{message:t}=zn("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${e}`);throw new Error(t)}const{relay:t,controller:r,namespaces:n,expiry:i}=e;if(!Zn(t)){const{message:e}=zn("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(e)}const s=function(e,t){let r=null;return Vn(e?.publicKey,!1)||(r=zn("MISSING_OR_INVALID",`${t} controller public key should be a string`)),r}(r,"onSessionSettleRequest()");if(s)throw new Error(s.message);const o=Xn(n,"onSessionSettleRequest()");if(o)throw new Error(o.message);if(bn(i)){const{message:e}=zn("EXPIRED","onSessionSettleRequest()");throw new Error(e)}},this.isValidUpdate=async e=>{if(!Qn(e)){const{message:t}=zn("MISSING_OR_INVALID",`update() params: ${e}`);throw new Error(t)}const{topic:t,namespaces:r}=e;await this.isValidSessionTopic(t);const n=this.client.session.get(t),i=Xn(r,"update()");if(i)throw new Error(i.message);const s=ni(n.requiredNamespaces,r,"update()");if(s)throw new Error(s.message)},this.isValidExtend=async e=>{if(!Qn(e)){const{message:t}=zn("MISSING_OR_INVALID",`extend() params: ${e}`);throw new Error(t)}const{topic:t}=e;await this.isValidSessionTopic(t)},this.isValidRequest=async e=>{if(!Qn(e)){const{message:t}=zn("MISSING_OR_INVALID",`request() params: ${e}`);throw new Error(t)}const{topic:t,request:r,chainId:n,expiry:i}=e;await this.isValidSessionTopic(t);const{namespaces:s}=this.client.session.get(t);if(!ei(s,n)){const{message:e}=zn("MISSING_OR_INVALID",`request() chainId: ${n}`);throw new Error(e)}if(!function(e){return!(Kn(e)||!Vn(e.method,!1))}(r)){const{message:e}=zn("MISSING_OR_INVALID",`request() ${JSON.stringify(r)}`);throw new Error(e)}if(!ti(s,n,r.method)){const{message:e}=zn("MISSING_OR_INVALID",`request() method: ${r.method}`);throw new Error(e)}if(i&&!function(e,t){return Bn(e,!1)&&e<=t.max&&e>=t.min}(i,fu)){const{message:e}=zn("MISSING_OR_INVALID",`request() expiry: ${i}. Expiry must be a number (in seconds) between ${fu.min} and ${fu.max}`);throw new Error(e)}},this.isValidRespond=async e=>{if(!Qn(e)){const{message:t}=zn("MISSING_OR_INVALID",`respond() params: ${e}`);throw new Error(t)}const{topic:t,response:r}=e;if(await this.isValidSessionTopic(t),!function(e){return!(Kn(e)||Kn(e.result)&&Kn(e.error)||!Bn(e.id,!1)||!Vn(e.jsonrpc,!1))}(r)){const{message:e}=zn("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(r)}`);throw new Error(e)}},this.isValidPing=async e=>{if(!Qn(e)){const{message:t}=zn("MISSING_OR_INVALID",`ping() params: ${e}`);throw new Error(t)}const{topic:t}=e;await this.isValidSessionOrPairingTopic(t)},this.isValidEmit=async e=>{if(!Qn(e)){const{message:t}=zn("MISSING_OR_INVALID",`emit() params: ${e}`);throw new Error(t)}const{topic:t,event:r,chainId:n}=e;await this.isValidSessionTopic(t);const{namespaces:i}=this.client.session.get(t);if(!ei(i,n)){const{message:e}=zn("MISSING_OR_INVALID",`emit() chainId: ${n}`);throw new Error(e)}if(!function(e){return!(Kn(e)||!Vn(e.name,!1))}(r)){const{message:e}=zn("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(r)}`);throw new Error(e)}if(!ri(i,n,r.name)){const{message:e}=zn("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(r)}`);throw new Error(e)}},this.isValidDisconnect=async e=>{if(!Qn(e)){const{message:t}=zn("MISSING_OR_INVALID",`disconnect() params: ${e}`);throw new Error(t)}const{topic:t}=e;await this.isValidSessionOrPairingTopic(t)},this.getVerifyContext=async(e,t)=>{const r={verified:{verifyUrl:t.verifyUrl||"",validation:"UNKNOWN",origin:t.url||""}};try{const n=await this.client.core.verify.resolve({attestationId:e,verifyUrl:t.verifyUrl});n&&(r.verified.origin=n,r.verified.validation=n===t.url?"VALID":"INVALID")}catch(e){this.client.logger.error(e)}return this.client.logger.info(`Verify context: ${JSON.stringify(r)}`),r},this.validateSessionProps=(e,t)=>{Object.values(e).forEach((e=>{if(!Vn(e,!1)){const{message:r}=zn("MISSING_OR_INVALID",`${t} must be in Record<string, string> format. Received: ${JSON.stringify(e)}`);throw new Error(r)}}))}}isInitialized(){if(!this.initialized){const{message:e}=zn("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.client.core.relayer.on(Va,(async e=>{const{topic:t,message:r}=e;if(this.ignoredPayloadTypes.includes(this.client.core.crypto.getPayloadType(r)))return;const n=await this.client.core.crypto.decode(t,r);Js(n)?(this.client.core.history.set(t,n),this.onRelayEventRequest({topic:t,payload:n})):Xs(n)?(await this.client.core.history.resolve(n),await this.onRelayEventResponse({topic:t,payload:n}),this.client.core.history.delete(t,n.id)):this.onRelayEventUnknownPayload({topic:t,payload:n})}))}registerExpirerEvents(){this.client.core.expirer.on(gc,(async e=>{const{topic:t,id:r}=mn(e.target);if(r&&this.client.pendingRequest.keys.includes(r))return await this.deletePendingSessionRequest(r,zn("EXPIRED"),!0);t?this.client.session.keys.includes(t)&&(await this.deleteSession(t,!0),this.client.events.emit("session_expire",{topic:t})):r&&(await this.deleteProposal(r,!0),this.client.events.emit("proposal_expire",{id:r}))}))}isValidPairingTopic(e){if(!Vn(e,!1)){const{message:t}=zn("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(t)}if(!this.client.core.pairing.pairings.keys.includes(e)){const{message:t}=zn("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(t)}if(bn(this.client.core.pairing.pairings.get(e).expiry)){const{message:t}=zn("EXPIRED",`pairing topic: ${e}`);throw new Error(t)}}async isValidSessionTopic(e){if(!Vn(e,!1)){const{message:t}=zn("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw new Error(t)}if(!this.client.session.keys.includes(e)){const{message:t}=zn("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(t)}if(bn(this.client.session.get(e).expiry)){await this.deleteSession(e);const{message:t}=zn("EXPIRED",`session topic: ${e}`);throw new Error(t)}}async isValidSessionOrPairingTopic(e){if(this.client.session.keys.includes(e))await this.isValidSessionTopic(e);else{if(!this.client.core.pairing.pairings.keys.includes(e)){if(Vn(e,!1)){const{message:t}=zn("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(t)}{const{message:t}=zn("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(t)}}this.isValidPairingTopic(e)}}async isValidProposalId(e){if("number"!=typeof e){const{message:t}=zn("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(t)}if(!this.client.proposal.keys.includes(e)){const{message:t}=zn("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(t)}if(bn(this.client.proposal.get(e).expiry)){await this.deleteProposal(e);const{message:t}=zn("EXPIRED",`proposal id: ${e}`);throw new Error(t)}}}class Iu extends Fc{constructor(e,t){super(e,t,"proposal",ou),this.core=e,this.logger=t}}class Ou extends Fc{constructor(e,t){super(e,t,"session",ou),this.core=e,this.logger=t}}class Pu extends Fc{constructor(e,t){super(e,t,"request",ou,(e=>e.id)),this.core=e,this.logger=t}}class Nu extends ns{constructor(t){super(t),this.protocol="wc",this.version=2,this.name=au,this.events=new e.EventEmitter,this.on=(e,t)=>this.events.on(e,t),this.once=(e,t)=>this.events.once(e,t),this.off=(e,t)=>this.events.off(e,t),this.removeListener=(e,t)=>this.events.removeListener(e,t),this.removeAllListeners=e=>this.events.removeAllListeners(e),this.connect=async e=>{try{return await this.engine.connect(e)}catch(e){throw this.logger.error(e.message),e}},this.pair=async e=>{try{return await this.engine.pair(e)}catch(e){throw this.logger.error(e.message),e}},this.approve=async e=>{try{return await this.engine.approve(e)}catch(e){throw this.logger.error(e.message),e}},this.reject=async e=>{try{return await this.engine.reject(e)}catch(e){throw this.logger.error(e.message),e}},this.update=async e=>{try{return await this.engine.update(e)}catch(e){throw this.logger.error(e.message),e}},this.extend=async e=>{try{return await this.engine.extend(e)}catch(e){throw this.logger.error(e.message),e}},this.request=async e=>{try{return await this.engine.request(e)}catch(e){throw this.logger.error(e.message),e}},this.respond=async e=>{try{return await this.engine.respond(e)}catch(e){throw this.logger.error(e.message),e}},this.ping=async e=>{try{return await this.engine.ping(e)}catch(e){throw this.logger.error(e.message),e}},this.emit=async e=>{try{return await this.engine.emit(e)}catch(e){throw this.logger.error(e.message),e}},this.disconnect=async e=>{try{return await this.engine.disconnect(e)}catch(e){throw this.logger.error(e.message),e}},this.find=e=>{try{return this.engine.find(e)}catch(e){throw this.logger.error(e.message),e}},this.getPendingSessionRequests=()=>{try{return this.engine.getPendingSessionRequests()}catch(e){throw this.logger.error(e.message),e}},this.name=t?.name||au,this.metadata=t?.metadata||wr()||{name:"",description:"",url:"",icons:[""]};const r=typeof t?.logger<"u"&&"string"!=typeof t?.logger?t.logger:qi.pino(qi.getDefaultLoggerOptions({level:t?.logger||cu}));this.core=t?.core||new iu(t),this.logger=qi.generateChildLogger(r,this.name),this.session=new Ou(this.core,this.logger),this.proposal=new Iu(this.core,this.logger),this.pendingRequest=new Pu(this.core,this.logger),this.engine=new Su(this)}static async init(e){const t=new Nu(e);return await t.initialize(),t}get context(){return qi.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(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}}const Au={headers:{Accept:"application/json","Content-Type":"application/json"},method:"POST"};class xu{constructor(t,r=!1){if(this.url=t,this.disableProviderPing=r,this.events=new e.EventEmitter,this.isAvailable=!1,this.registering=!1,!Fs(t))throw new Error(`Provided URL is not compatible with HTTP connection: ${t}`);this.url=t,this.disableProviderPing=r}get connected(){return this.isAvailable}get connecting(){return this.registering}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async open(e=this.url){await this.register(e)}async close(){if(!this.isAvailable)throw new Error("Connection already closed");this.onClose()}async send(e,t){this.isAvailable||await this.register();try{const t=as(e),n=await r.m(this.url,Object.assign(Object.assign({},Au),{body:t})),i=await n.json();this.onPayload({data:i})}catch(t){this.onError(e.id,t)}}async register(e=this.url){if(!Fs(e))throw new Error(`Provided URL is not compatible with HTTP connection: ${e}`);if(this.registering){const e=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=e||this.events.listenerCount("open")>=e)&&this.events.setMaxListeners(e+1),new Promise(((e,t)=>{this.events.once("register_error",(e=>{this.resetMaxListeners(),t(e)})),this.events.once("open",(()=>{if(this.resetMaxListeners(),void 0===this.isAvailable)return t(new Error("HTTP connection is missing or invalid"));e()}))}))}this.url=e,this.registering=!0;try{if(!this.disableProviderPing){const t=as({id:1,jsonrpc:"2.0",method:"test",params:[]});await r.m(e,Object.assign(Object.assign({},Au),{body:t}))}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(e){if(void 0===e.data)return;const t="string"==typeof e.data?os(e.data):e.data;this.events.emit("payload",t)}onError(e,t){const r=this.parseError(t),n=$s(e,r.message||r.toString());this.events.emit("payload",n)}parseError(e,t=this.url){return Cs(e,t,"HTTP")}resetMaxListeners(){this.events.getMaxListeners()>10&&this.events.setMaxListeners(10)}}const Cu="error",Tu="wc@2:universal_provider:",Ru="default_chain_changed";var ju=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Lu={exports:{}};
|
|
1
|
+
"use strict";var e=require("events"),t=require("./_commonjs-dynamic-modules-f09a98c7.cjs"),r=require("./index-3e679370.cjs");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("@ethersproject/providers"),require("zustand"),require("@ethersproject/bytes"),require("@ethersproject/properties"),require("@ethersproject/address"),require("@ethersproject/abstract-signer"),require("buffer"),require("@ethersproject/abstract-provider"),require("@ethersproject/contracts"),require("@ethersproject/constants"),require("@ethersproject/transactions");var i=n(e),s={},o={},a={},c={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.mul=Math.imul||function(e,t){var r=65535&e,n=65535&t;return r*n+((e>>>16&65535)*n+r*(t>>>16&65535)<<16>>>0)|0},e.add=function(e,t){return e+t|0},e.sub=function(e,t){return e-t|0},e.rotl=function(e,t){return e<<t|e>>>32-t},e.rotr=function(e,t){return e<<32-t|e>>>t},e.isInteger=Number.isInteger||function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e},e.MAX_SAFE_INTEGER=9007199254740991,e.isSafeInteger=function(t){return e.isInteger(t)&&t>=-e.MAX_SAFE_INTEGER&&t<=e.MAX_SAFE_INTEGER}}(c),Object.defineProperty(a,"__esModule",{value:!0});var u=c;function h(e,t,r){return void 0===t&&(t=new Uint8Array(2)),void 0===r&&(r=0),t[r+0]=e>>>8,t[r+1]=e>>>0,t}function l(e,t,r){return void 0===t&&(t=new Uint8Array(2)),void 0===r&&(r=0),t[r+0]=e>>>0,t[r+1]=e>>>8,t}function f(e,t){return void 0===t&&(t=0),e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function p(e,t){return void 0===t&&(t=0),(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}function d(e,t){return void 0===t&&(t=0),e[t+3]<<24|e[t+2]<<16|e[t+1]<<8|e[t]}function g(e,t){return void 0===t&&(t=0),(e[t+3]<<24|e[t+2]<<16|e[t+1]<<8|e[t])>>>0}function y(e,t,r){return void 0===t&&(t=new Uint8Array(4)),void 0===r&&(r=0),t[r+0]=e>>>24,t[r+1]=e>>>16,t[r+2]=e>>>8,t[r+3]=e>>>0,t}function v(e,t,r){return void 0===t&&(t=new Uint8Array(4)),void 0===r&&(r=0),t[r+0]=e>>>0,t[r+1]=e>>>8,t[r+2]=e>>>16,t[r+3]=e>>>24,t}function _(e,t,r){return void 0===t&&(t=new Uint8Array(8)),void 0===r&&(r=0),y(e/4294967296>>>0,t,r),y(e>>>0,t,r+4),t}function m(e,t,r){return void 0===t&&(t=new Uint8Array(8)),void 0===r&&(r=0),v(e>>>0,t,r),v(e/4294967296>>>0,t,r+4),t}a.readInt16BE=function(e,t){return void 0===t&&(t=0),(e[t+0]<<8|e[t+1])<<16>>16},a.readUint16BE=function(e,t){return void 0===t&&(t=0),(e[t+0]<<8|e[t+1])>>>0},a.readInt16LE=function(e,t){return void 0===t&&(t=0),(e[t+1]<<8|e[t])<<16>>16},a.readUint16LE=function(e,t){return void 0===t&&(t=0),(e[t+1]<<8|e[t])>>>0},a.writeUint16BE=h,a.writeInt16BE=h,a.writeUint16LE=l,a.writeInt16LE=l,a.readInt32BE=f,a.readUint32BE=p,a.readInt32LE=d,a.readUint32LE=g,a.writeUint32BE=y,a.writeInt32BE=y,a.writeUint32LE=v,a.writeInt32LE=v,a.readInt64BE=function(e,t){void 0===t&&(t=0);var r=f(e,t),n=f(e,t+4);return 4294967296*r+n-4294967296*(n>>31)},a.readUint64BE=function(e,t){return void 0===t&&(t=0),4294967296*p(e,t)+p(e,t+4)},a.readInt64LE=function(e,t){void 0===t&&(t=0);var r=d(e,t);return 4294967296*d(e,t+4)+r-4294967296*(r>>31)},a.readUint64LE=function(e,t){void 0===t&&(t=0);var r=g(e,t);return 4294967296*g(e,t+4)+r},a.writeUint64BE=_,a.writeInt64BE=_,a.writeUint64LE=m,a.writeInt64LE=m,a.readUintBE=function(e,t,r){if(void 0===r&&(r=0),e%8!=0)throw new Error("readUintBE supports only bitLengths divisible by 8");if(e/8>t.length-r)throw new Error("readUintBE: array is too short for the given bitLength");for(var n=0,i=1,s=e/8+r-1;s>=r;s--)n+=t[s]*i,i*=256;return n},a.readUintLE=function(e,t,r){if(void 0===r&&(r=0),e%8!=0)throw new Error("readUintLE supports only bitLengths divisible by 8");if(e/8>t.length-r)throw new Error("readUintLE: array is too short for the given bitLength");for(var n=0,i=1,s=r;s<r+e/8;s++)n+=t[s]*i,i*=256;return n},a.writeUintBE=function(e,t,r,n){if(void 0===r&&(r=new Uint8Array(e/8)),void 0===n&&(n=0),e%8!=0)throw new Error("writeUintBE supports only bitLengths divisible by 8");if(!u.isSafeInteger(t))throw new Error("writeUintBE value must be an integer");for(var i=1,s=e/8+n-1;s>=n;s--)r[s]=t/i&255,i*=256;return r},a.writeUintLE=function(e,t,r,n){if(void 0===r&&(r=new Uint8Array(e/8)),void 0===n&&(n=0),e%8!=0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!u.isSafeInteger(t))throw new Error("writeUintLE value must be an integer");for(var i=1,s=n;s<n+e/8;s++)r[s]=t/i&255,i*=256;return r},a.readFloat32BE=function(e,t){return void 0===t&&(t=0),new DataView(e.buffer,e.byteOffset,e.byteLength).getFloat32(t)},a.readFloat32LE=function(e,t){return void 0===t&&(t=0),new DataView(e.buffer,e.byteOffset,e.byteLength).getFloat32(t,!0)},a.readFloat64BE=function(e,t){return void 0===t&&(t=0),new DataView(e.buffer,e.byteOffset,e.byteLength).getFloat64(t)},a.readFloat64LE=function(e,t){return void 0===t&&(t=0),new DataView(e.buffer,e.byteOffset,e.byteLength).getFloat64(t,!0)},a.writeFloat32BE=function(e,t,r){return void 0===t&&(t=new Uint8Array(4)),void 0===r&&(r=0),new DataView(t.buffer,t.byteOffset,t.byteLength).setFloat32(r,e),t},a.writeFloat32LE=function(e,t,r){return void 0===t&&(t=new Uint8Array(4)),void 0===r&&(r=0),new DataView(t.buffer,t.byteOffset,t.byteLength).setFloat32(r,e,!0),t},a.writeFloat64BE=function(e,t,r){return void 0===t&&(t=new Uint8Array(8)),void 0===r&&(r=0),new DataView(t.buffer,t.byteOffset,t.byteLength).setFloat64(r,e),t},a.writeFloat64LE=function(e,t,r){return void 0===t&&(t=new Uint8Array(8)),void 0===r&&(r=0),new DataView(t.buffer,t.byteOffset,t.byteLength).setFloat64(r,e,!0),t};var w={};Object.defineProperty(w,"__esModule",{value:!0}),w.wipe=function(e){for(var t=0;t<e.length;t++)e[t]=0;return e},Object.defineProperty(o,"__esModule",{value:!0});var b=a,E=w,S=20;function I(e,t,r){for(var n=1634760805,i=857760878,s=2036477234,o=1797285236,a=r[3]<<24|r[2]<<16|r[1]<<8|r[0],c=r[7]<<24|r[6]<<16|r[5]<<8|r[4],u=r[11]<<24|r[10]<<16|r[9]<<8|r[8],h=r[15]<<24|r[14]<<16|r[13]<<8|r[12],l=r[19]<<24|r[18]<<16|r[17]<<8|r[16],f=r[23]<<24|r[22]<<16|r[21]<<8|r[20],p=r[27]<<24|r[26]<<16|r[25]<<8|r[24],d=r[31]<<24|r[30]<<16|r[29]<<8|r[28],g=t[3]<<24|t[2]<<16|t[1]<<8|t[0],y=t[7]<<24|t[6]<<16|t[5]<<8|t[4],v=t[11]<<24|t[10]<<16|t[9]<<8|t[8],_=t[15]<<24|t[14]<<16|t[13]<<8|t[12],m=n,w=i,E=s,I=o,O=a,P=c,N=u,A=h,x=l,C=f,T=p,R=d,j=g,L=y,U=v,M=_,D=0;D<S;D+=2)O=(O^=x=x+(j=(j^=m=m+O|0)>>>16|j<<16)|0)>>>20|O<<12,P=(P^=C=C+(L=(L^=w=w+P|0)>>>16|L<<16)|0)>>>20|P<<12,N=(N^=T=T+(U=(U^=E=E+N|0)>>>16|U<<16)|0)>>>20|N<<12,A=(A^=R=R+(M=(M^=I=I+A|0)>>>16|M<<16)|0)>>>20|A<<12,N=(N^=T=T+(U=(U^=E=E+N|0)>>>24|U<<8)|0)>>>25|N<<7,A=(A^=R=R+(M=(M^=I=I+A|0)>>>24|M<<8)|0)>>>25|A<<7,P=(P^=C=C+(L=(L^=w=w+P|0)>>>24|L<<8)|0)>>>25|P<<7,O=(O^=x=x+(j=(j^=m=m+O|0)>>>24|j<<8)|0)>>>25|O<<7,P=(P^=T=T+(M=(M^=m=m+P|0)>>>16|M<<16)|0)>>>20|P<<12,N=(N^=R=R+(j=(j^=w=w+N|0)>>>16|j<<16)|0)>>>20|N<<12,A=(A^=x=x+(L=(L^=E=E+A|0)>>>16|L<<16)|0)>>>20|A<<12,O=(O^=C=C+(U=(U^=I=I+O|0)>>>16|U<<16)|0)>>>20|O<<12,A=(A^=x=x+(L=(L^=E=E+A|0)>>>24|L<<8)|0)>>>25|A<<7,O=(O^=C=C+(U=(U^=I=I+O|0)>>>24|U<<8)|0)>>>25|O<<7,N=(N^=R=R+(j=(j^=w=w+N|0)>>>24|j<<8)|0)>>>25|N<<7,P=(P^=T=T+(M=(M^=m=m+P|0)>>>24|M<<8)|0)>>>25|P<<7;b.writeUint32LE(m+n|0,e,0),b.writeUint32LE(w+i|0,e,4),b.writeUint32LE(E+s|0,e,8),b.writeUint32LE(I+o|0,e,12),b.writeUint32LE(O+a|0,e,16),b.writeUint32LE(P+c|0,e,20),b.writeUint32LE(N+u|0,e,24),b.writeUint32LE(A+h|0,e,28),b.writeUint32LE(x+l|0,e,32),b.writeUint32LE(C+f|0,e,36),b.writeUint32LE(T+p|0,e,40),b.writeUint32LE(R+d|0,e,44),b.writeUint32LE(j+g|0,e,48),b.writeUint32LE(L+y|0,e,52),b.writeUint32LE(U+v|0,e,56),b.writeUint32LE(M+_|0,e,60)}function O(e,t,r,n,i){if(void 0===i&&(i=0),32!==e.length)throw new Error("ChaCha: key size must be 32 bytes");if(n.length<r.length)throw new Error("ChaCha: destination is shorter than source");var s,o;if(0===i){if(8!==t.length&&12!==t.length)throw new Error("ChaCha nonce must be 8 or 12 bytes");o=(s=new Uint8Array(16)).length-t.length,s.set(t,o)}else{if(16!==t.length)throw new Error("ChaCha nonce with counter must be 16 bytes");s=t,o=i}for(var a=new Uint8Array(64),c=0;c<r.length;c+=64){I(a,s,e);for(var u=c;u<c+64&&u<r.length;u++)n[u]=r[u]^a[u-c];P(s,0,o)}return E.wipe(a),0===i&&E.wipe(s),n}function P(e,t,r){for(var n=1;r--;)n=n+(255&e[t])|0,e[t]=255&n,n>>>=8,t++;if(n>0)throw new Error("ChaCha: counter overflow")}o.streamXOR=O,o.stream=function(e,t,r,n){return void 0===n&&(n=0),E.wipe(r),O(e,t,r,r,n)};var N={},A={};function x(e,t){if(e.length!==t.length)return 0;for(var r=0,n=0;n<e.length;n++)r|=e[n]^t[n];return 1&r-1>>>8}Object.defineProperty(A,"__esModule",{value:!0}),A.select=function(e,t,r){return~(e-1)&t|e-1&r},A.lessOrEqual=function(e,t){return(0|e)-(0|t)-1>>>31&1},A.compare=x,A.equal=function(e,t){return 0!==e.length&&0!==t.length&&0!==x(e,t)},function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=A,r=w;e.DIGEST_LENGTH=16;var n=function(){function t(t){this.digestLength=e.DIGEST_LENGTH,this._buffer=new Uint8Array(16),this._r=new Uint16Array(10),this._h=new Uint16Array(10),this._pad=new Uint16Array(8),this._leftover=0,this._fin=0,this._finished=!1;var r=t[0]|t[1]<<8;this._r[0]=8191&r;var n=t[2]|t[3]<<8;this._r[1]=8191&(r>>>13|n<<3);var i=t[4]|t[5]<<8;this._r[2]=7939&(n>>>10|i<<6);var s=t[6]|t[7]<<8;this._r[3]=8191&(i>>>7|s<<9);var o=t[8]|t[9]<<8;this._r[4]=255&(s>>>4|o<<12),this._r[5]=o>>>1&8190;var a=t[10]|t[11]<<8;this._r[6]=8191&(o>>>14|a<<2);var c=t[12]|t[13]<<8;this._r[7]=8065&(a>>>11|c<<5);var u=t[14]|t[15]<<8;this._r[8]=8191&(c>>>8|u<<8),this._r[9]=u>>>5&127,this._pad[0]=t[16]|t[17]<<8,this._pad[1]=t[18]|t[19]<<8,this._pad[2]=t[20]|t[21]<<8,this._pad[3]=t[22]|t[23]<<8,this._pad[4]=t[24]|t[25]<<8,this._pad[5]=t[26]|t[27]<<8,this._pad[6]=t[28]|t[29]<<8,this._pad[7]=t[30]|t[31]<<8}return t.prototype._blocks=function(e,t,r){for(var n=this._fin?0:2048,i=this._h[0],s=this._h[1],o=this._h[2],a=this._h[3],c=this._h[4],u=this._h[5],h=this._h[6],l=this._h[7],f=this._h[8],p=this._h[9],d=this._r[0],g=this._r[1],y=this._r[2],v=this._r[3],_=this._r[4],m=this._r[5],w=this._r[6],b=this._r[7],E=this._r[8],S=this._r[9];r>=16;){var I=e[t+0]|e[t+1]<<8;i+=8191&I;var O=e[t+2]|e[t+3]<<8;s+=8191&(I>>>13|O<<3);var P=e[t+4]|e[t+5]<<8;o+=8191&(O>>>10|P<<6);var N=e[t+6]|e[t+7]<<8;a+=8191&(P>>>7|N<<9);var A=e[t+8]|e[t+9]<<8;c+=8191&(N>>>4|A<<12),u+=A>>>1&8191;var x=e[t+10]|e[t+11]<<8;h+=8191&(A>>>14|x<<2);var C=e[t+12]|e[t+13]<<8;l+=8191&(x>>>11|C<<5);var T=e[t+14]|e[t+15]<<8,R=0,j=R;j+=i*d,j+=s*(5*S),j+=o*(5*E),j+=a*(5*b),R=(j+=c*(5*w))>>>13,j&=8191,j+=u*(5*m),j+=h*(5*_),j+=l*(5*v),j+=(f+=8191&(C>>>8|T<<8))*(5*y);var L=R+=(j+=(p+=T>>>5|n)*(5*g))>>>13;L+=i*g,L+=s*d,L+=o*(5*S),L+=a*(5*E),R=(L+=c*(5*b))>>>13,L&=8191,L+=u*(5*w),L+=h*(5*m),L+=l*(5*_),L+=f*(5*v),R+=(L+=p*(5*y))>>>13,L&=8191;var U=R;U+=i*y,U+=s*g,U+=o*d,U+=a*(5*S),R=(U+=c*(5*E))>>>13,U&=8191,U+=u*(5*b),U+=h*(5*w),U+=l*(5*m),U+=f*(5*_);var M=R+=(U+=p*(5*v))>>>13;M+=i*v,M+=s*y,M+=o*g,M+=a*d,R=(M+=c*(5*S))>>>13,M&=8191,M+=u*(5*E),M+=h*(5*b),M+=l*(5*w),M+=f*(5*m);var D=R+=(M+=p*(5*_))>>>13;D+=i*_,D+=s*v,D+=o*y,D+=a*g,R=(D+=c*d)>>>13,D&=8191,D+=u*(5*S),D+=h*(5*E),D+=l*(5*b),D+=f*(5*w);var k=R+=(D+=p*(5*m))>>>13;k+=i*m,k+=s*_,k+=o*v,k+=a*y,R=(k+=c*g)>>>13,k&=8191,k+=u*d,k+=h*(5*S),k+=l*(5*E),k+=f*(5*b);var z=R+=(k+=p*(5*w))>>>13;z+=i*w,z+=s*m,z+=o*_,z+=a*v,R=(z+=c*y)>>>13,z&=8191,z+=u*g,z+=h*d,z+=l*(5*S),z+=f*(5*E);var $=R+=(z+=p*(5*b))>>>13;$+=i*b,$+=s*w,$+=o*m,$+=a*_,R=($+=c*v)>>>13,$&=8191,$+=u*y,$+=h*g,$+=l*d,$+=f*(5*S);var q=R+=($+=p*(5*E))>>>13;q+=i*E,q+=s*b,q+=o*w,q+=a*m,R=(q+=c*_)>>>13,q&=8191,q+=u*v,q+=h*y,q+=l*g,q+=f*d;var H=R+=(q+=p*(5*S))>>>13;H+=i*S,H+=s*E,H+=o*b,H+=a*w,R=(H+=c*m)>>>13,H&=8191,H+=u*_,H+=h*v,H+=l*y,H+=f*g,i=j=8191&(R=(R=((R+=(H+=p*d)>>>13)<<2)+R|0)+(j&=8191)|0),s=L+=R>>>=13,o=U&=8191,a=M&=8191,c=D&=8191,u=k&=8191,h=z&=8191,l=$&=8191,f=q&=8191,p=H&=8191,t+=16,r-=16}this._h[0]=i,this._h[1]=s,this._h[2]=o,this._h[3]=a,this._h[4]=c,this._h[5]=u,this._h[6]=h,this._h[7]=l,this._h[8]=f,this._h[9]=p},t.prototype.finish=function(e,t){void 0===t&&(t=0);var r,n,i,s,o=new Uint16Array(10);if(this._leftover){for(s=this._leftover,this._buffer[s++]=1;s<16;s++)this._buffer[s]=0;this._fin=1,this._blocks(this._buffer,0,16)}for(r=this._h[1]>>>13,this._h[1]&=8191,s=2;s<10;s++)this._h[s]+=r,r=this._h[s]>>>13,this._h[s]&=8191;for(this._h[0]+=5*r,r=this._h[0]>>>13,this._h[0]&=8191,this._h[1]+=r,r=this._h[1]>>>13,this._h[1]&=8191,this._h[2]+=r,o[0]=this._h[0]+5,r=o[0]>>>13,o[0]&=8191,s=1;s<10;s++)o[s]=this._h[s]+r,r=o[s]>>>13,o[s]&=8191;for(o[9]-=8192,n=(1^r)-1,s=0;s<10;s++)o[s]&=n;for(n=~n,s=0;s<10;s++)this._h[s]=this._h[s]&n|o[s];for(this._h[0]=65535&(this._h[0]|this._h[1]<<13),this._h[1]=65535&(this._h[1]>>>3|this._h[2]<<10),this._h[2]=65535&(this._h[2]>>>6|this._h[3]<<7),this._h[3]=65535&(this._h[3]>>>9|this._h[4]<<4),this._h[4]=65535&(this._h[4]>>>12|this._h[5]<<1|this._h[6]<<14),this._h[5]=65535&(this._h[6]>>>2|this._h[7]<<11),this._h[6]=65535&(this._h[7]>>>5|this._h[8]<<8),this._h[7]=65535&(this._h[8]>>>8|this._h[9]<<5),i=this._h[0]+this._pad[0],this._h[0]=65535&i,s=1;s<8;s++)i=(this._h[s]+this._pad[s]|0)+(i>>>16)|0,this._h[s]=65535&i;return e[t+0]=this._h[0]>>>0,e[t+1]=this._h[0]>>>8,e[t+2]=this._h[1]>>>0,e[t+3]=this._h[1]>>>8,e[t+4]=this._h[2]>>>0,e[t+5]=this._h[2]>>>8,e[t+6]=this._h[3]>>>0,e[t+7]=this._h[3]>>>8,e[t+8]=this._h[4]>>>0,e[t+9]=this._h[4]>>>8,e[t+10]=this._h[5]>>>0,e[t+11]=this._h[5]>>>8,e[t+12]=this._h[6]>>>0,e[t+13]=this._h[6]>>>8,e[t+14]=this._h[7]>>>0,e[t+15]=this._h[7]>>>8,this._finished=!0,this},t.prototype.update=function(e){var t,r=0,n=e.length;if(this._leftover){(t=16-this._leftover)>n&&(t=n);for(var i=0;i<t;i++)this._buffer[this._leftover+i]=e[r+i];if(n-=t,r+=t,this._leftover+=t,this._leftover<16)return this;this._blocks(this._buffer,0,16),this._leftover=0}if(n>=16&&(t=n-n%16,this._blocks(e,r,t),r+=t,n-=t),n){for(i=0;i<n;i++)this._buffer[this._leftover+i]=e[r+i];this._leftover+=n}return this},t.prototype.digest=function(){if(this._finished)throw new Error("Poly1305 was finished");var e=new Uint8Array(16);return this.finish(e),e},t.prototype.clean=function(){return r.wipe(this._buffer),r.wipe(this._r),r.wipe(this._h),r.wipe(this._pad),this._leftover=0,this._fin=0,this._finished=!0,this},t}();e.Poly1305=n,e.oneTimeAuth=function(e,t){var r=new n(e);r.update(t);var i=r.digest();return r.clean(),i},e.equal=function(r,n){return r.length===e.DIGEST_LENGTH&&n.length===e.DIGEST_LENGTH&&t.equal(r,n)}}(N),function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=o,r=N,n=w,i=a,s=A;e.KEY_LENGTH=32,e.NONCE_LENGTH=12,e.TAG_LENGTH=16;var c=new Uint8Array(16),u=function(){function o(t){if(this.nonceLength=e.NONCE_LENGTH,this.tagLength=e.TAG_LENGTH,t.length!==e.KEY_LENGTH)throw new Error("ChaCha20Poly1305 needs 32-byte key");this._key=new Uint8Array(t)}return o.prototype.seal=function(e,r,i,s){if(e.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");var o=new Uint8Array(16);o.set(e,o.length-e.length);var a=new Uint8Array(32);t.stream(this._key,o,a,4);var c,u=r.length+this.tagLength;if(s){if(s.length!==u)throw new Error("ChaCha20Poly1305: incorrect destination length");c=s}else c=new Uint8Array(u);return t.streamXOR(this._key,o,r,c,4),this._authenticate(c.subarray(c.length-this.tagLength,c.length),a,c.subarray(0,c.length-this.tagLength),i),n.wipe(o),c},o.prototype.open=function(e,r,i,o){if(e.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");if(r.length<this.tagLength)return null;var a=new Uint8Array(16);a.set(e,a.length-e.length);var c=new Uint8Array(32);t.stream(this._key,a,c,4);var u=new Uint8Array(this.tagLength);if(this._authenticate(u,c,r.subarray(0,r.length-this.tagLength),i),!s.equal(u,r.subarray(r.length-this.tagLength,r.length)))return null;var h,l=r.length-this.tagLength;if(o){if(o.length!==l)throw new Error("ChaCha20Poly1305: incorrect destination length");h=o}else h=new Uint8Array(l);return t.streamXOR(this._key,a,r.subarray(0,r.length-this.tagLength),h,4),n.wipe(a),h},o.prototype.clean=function(){return n.wipe(this._key),this},o.prototype._authenticate=function(e,t,s,o){var a=new r.Poly1305(t);o&&(a.update(o),o.length%16>0&&a.update(c.subarray(o.length%16))),a.update(s),s.length%16>0&&a.update(c.subarray(s.length%16));var u=new Uint8Array(8);o&&i.writeUint64LE(o.length,u),a.update(u),i.writeUint64LE(s.length,u),a.update(u);for(var h=a.digest(),l=0;l<h.length;l++)e[l]=h[l];a.clean(),n.wipe(h),n.wipe(u)},o}();e.ChaCha20Poly1305=u}(s);var C={},T={},R={};Object.defineProperty(R,"__esModule",{value:!0}),R.isSerializableHash=function(e){return void 0!==e.saveState&&void 0!==e.restoreState&&void 0!==e.cleanSavedState},Object.defineProperty(T,"__esModule",{value:!0});var j=R,L=A,U=w,M=function(){function e(e,t){this._finished=!1,this._inner=new e,this._outer=new e,this.blockSize=this._outer.blockSize,this.digestLength=this._outer.digestLength;var r=new Uint8Array(this.blockSize);t.length>this.blockSize?this._inner.update(t).finish(r).clean():r.set(t);for(var n=0;n<r.length;n++)r[n]^=54;this._inner.update(r);for(n=0;n<r.length;n++)r[n]^=106;this._outer.update(r),j.isSerializableHash(this._inner)&&j.isSerializableHash(this._outer)&&(this._innerKeyedState=this._inner.saveState(),this._outerKeyedState=this._outer.saveState()),U.wipe(r)}return e.prototype.reset=function(){if(!j.isSerializableHash(this._inner)||!j.isSerializableHash(this._outer))throw new Error("hmac: can't reset() because hash doesn't implement restoreState()");return this._inner.restoreState(this._innerKeyedState),this._outer.restoreState(this._outerKeyedState),this._finished=!1,this},e.prototype.clean=function(){j.isSerializableHash(this._inner)&&this._inner.cleanSavedState(this._innerKeyedState),j.isSerializableHash(this._outer)&&this._outer.cleanSavedState(this._outerKeyedState),this._inner.clean(),this._outer.clean()},e.prototype.update=function(e){return this._inner.update(e),this},e.prototype.finish=function(e){return this._finished?(this._outer.finish(e),this):(this._inner.finish(e),this._outer.update(e.subarray(0,this.digestLength)).finish(e),this._finished=!0,this)},e.prototype.digest=function(){var e=new Uint8Array(this.digestLength);return this.finish(e),e},e.prototype.saveState=function(){if(!j.isSerializableHash(this._inner))throw new Error("hmac: can't saveState() because hash doesn't implement it");return this._inner.saveState()},e.prototype.restoreState=function(e){if(!j.isSerializableHash(this._inner)||!j.isSerializableHash(this._outer))throw new Error("hmac: can't restoreState() because hash doesn't implement it");return this._inner.restoreState(e),this._outer.restoreState(this._outerKeyedState),this._finished=!1,this},e.prototype.cleanSavedState=function(e){if(!j.isSerializableHash(this._inner))throw new Error("hmac: can't cleanSavedState() because hash doesn't implement it");this._inner.cleanSavedState(e)},e}();T.HMAC=M,T.hmac=function(e,t,r){var n=new M(e,t);n.update(r);var i=n.digest();return n.clean(),i},T.equal=L.equal,Object.defineProperty(C,"__esModule",{value:!0});var D=T,k=w,z=function(){function e(e,t,r,n){void 0===r&&(r=new Uint8Array(0)),this._counter=new Uint8Array(1),this._hash=e,this._info=n;var i=D.hmac(this._hash,r,t);this._hmac=new D.HMAC(e,i),this._buffer=new Uint8Array(this._hmac.digestLength),this._bufpos=this._buffer.length}return e.prototype._fillBuffer=function(){this._counter[0]++;var e=this._counter[0];if(0===e)throw new Error("hkdf: cannot expand more");this._hmac.reset(),e>1&&this._hmac.update(this._buffer),this._info&&this._hmac.update(this._info),this._hmac.update(this._counter),this._hmac.finish(this._buffer),this._bufpos=0},e.prototype.expand=function(e){for(var t=new Uint8Array(e),r=0;r<t.length;r++)this._bufpos===this._buffer.length&&this._fillBuffer(),t[r]=this._buffer[this._bufpos++];return t},e.prototype.clean=function(){this._hmac.clean(),k.wipe(this._buffer),k.wipe(this._counter),this._bufpos=0},e}(),$=C.HKDF=z,q={},H={},K={};Object.defineProperty(K,"__esModule",{value:!0}),K.BrowserRandomSource=void 0;K.BrowserRandomSource=class{constructor(){this.isAvailable=!1,this.isInstantiated=!1;const e="undefined"!=typeof self?self.crypto||self.msCrypto:null;e&&void 0!==e.getRandomValues&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}randomBytes(e){if(!this.isAvailable||!this._crypto)throw new Error("Browser random byte generator is not available.");const t=new Uint8Array(e);for(let e=0;e<t.length;e+=65536)this._crypto.getRandomValues(t.subarray(e,e+Math.min(t.length-e,65536)));return t}};var V={};Object.defineProperty(V,"__esModule",{value:!0}),V.NodeRandomSource=void 0;const B=w;V.NodeRandomSource=class{constructor(){if(this.isAvailable=!1,this.isInstantiated=!1,void 0!==t.commonjsRequire){const e=r.require$$1;e&&e.randomBytes&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}}randomBytes(e){if(!this.isAvailable||!this._crypto)throw new Error("Node.js random byte generator is not available.");let t=this._crypto.randomBytes(e);if(t.length!==e)throw new Error("NodeRandomSource: got fewer bytes than requested");const r=new Uint8Array(e);for(let e=0;e<r.length;e++)r[e]=t[e];return(0,B.wipe)(t),r}},Object.defineProperty(H,"__esModule",{value:!0}),H.SystemRandomSource=void 0;const F=K,G=V;H.SystemRandomSource=class{constructor(){return this.isAvailable=!1,this.name="",this._source=new F.BrowserRandomSource,this._source.isAvailable?(this.isAvailable=!0,void(this.name="Browser")):(this._source=new G.NodeRandomSource,this._source.isAvailable?(this.isAvailable=!0,void(this.name="Node")):void 0)}randomBytes(e){if(!this.isAvailable)throw new Error("System random byte generator is not available.");return this._source.randomBytes(e)}},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.randomStringForEntropy=e.randomString=e.randomUint32=e.randomBytes=e.defaultRandomSource=void 0;const t=H,r=a,n=w;function i(t,r=e.defaultRandomSource){return r.randomBytes(t)}e.defaultRandomSource=new t.SystemRandomSource,e.randomBytes=i,e.randomUint32=function(t=e.defaultRandomSource){const s=i(4,t),o=(0,r.readUint32LE)(s);return(0,n.wipe)(s),o};const s="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function o(t,r=s,o=e.defaultRandomSource){if(r.length<2)throw new Error("randomString charset is too short");if(r.length>256)throw new Error("randomString charset is too long");let a="";const c=r.length,u=256-256%c;for(;t>0;){const e=i(Math.ceil(256*t/u),o);for(let n=0;n<e.length&&t>0;n++){const i=e[n];i<u&&(a+=r.charAt(i%c),t--)}(0,n.wipe)(e)}return a}e.randomString=o,e.randomStringForEntropy=function(t,r=s,n=e.defaultRandomSource){return o(Math.ceil(t/(Math.log(r.length)/Math.LN2)),r,n)}}(q);var W={};!function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=a,r=w;e.DIGEST_LENGTH=32,e.BLOCK_SIZE=64;var n=function(){function n(){this.digestLength=e.DIGEST_LENGTH,this.blockSize=e.BLOCK_SIZE,this._state=new Int32Array(8),this._temp=new Int32Array(64),this._buffer=new Uint8Array(128),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return n.prototype._initState=function(){this._state[0]=1779033703,this._state[1]=3144134277,this._state[2]=1013904242,this._state[3]=2773480762,this._state[4]=1359893119,this._state[5]=2600822924,this._state[6]=528734635,this._state[7]=1541459225},n.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},n.prototype.clean=function(){r.wipe(this._buffer),r.wipe(this._temp),this.reset()},n.prototype.update=function(e,t){if(void 0===t&&(t=e.length),this._finished)throw new Error("SHA256: can't update because hash was finished.");var r=0;if(this._bytesHashed+=t,this._bufferLength>0){for(;this._bufferLength<this.blockSize&&t>0;)this._buffer[this._bufferLength++]=e[r++],t--;this._bufferLength===this.blockSize&&(s(this._temp,this._state,this._buffer,0,this.blockSize),this._bufferLength=0)}for(t>=this.blockSize&&(r=s(this._temp,this._state,e,r,t),t%=this.blockSize);t>0;)this._buffer[this._bufferLength++]=e[r++],t--;return this},n.prototype.finish=function(e){if(!this._finished){var r=this._bytesHashed,n=this._bufferLength,i=r/536870912|0,o=r<<3,a=r%64<56?64:128;this._buffer[n]=128;for(var c=n+1;c<a-8;c++)this._buffer[c]=0;t.writeUint32BE(i,this._buffer,a-8),t.writeUint32BE(o,this._buffer,a-4),s(this._temp,this._state,this._buffer,0,a),this._finished=!0}for(c=0;c<this.digestLength/4;c++)t.writeUint32BE(this._state[c],e,4*c);return this},n.prototype.digest=function(){var e=new Uint8Array(this.digestLength);return this.finish(e),e},n.prototype.saveState=function(){if(this._finished)throw new Error("SHA256: cannot save finished state");return{state:new Int32Array(this._state),buffer:this._bufferLength>0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},n.prototype.restoreState=function(e){return this._state.set(e.state),this._bufferLength=e.bufferLength,e.buffer&&this._buffer.set(e.buffer),this._bytesHashed=e.bytesHashed,this._finished=!1,this},n.prototype.cleanSavedState=function(e){r.wipe(e.state),e.buffer&&r.wipe(e.buffer),e.bufferLength=0,e.bytesHashed=0},n}();e.SHA256=n;var i=new Int32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function s(e,r,n,s,o){for(;o>=64;){for(var a=r[0],c=r[1],u=r[2],h=r[3],l=r[4],f=r[5],p=r[6],d=r[7],g=0;g<16;g++){var y=s+4*g;e[g]=t.readUint32BE(n,y)}for(g=16;g<64;g++){var v=e[g-2],_=(v>>>17|v<<15)^(v>>>19|v<<13)^v>>>10,m=((v=e[g-15])>>>7|v<<25)^(v>>>18|v<<14)^v>>>3;e[g]=(_+e[g-7]|0)+(m+e[g-16]|0)}for(g=0;g<64;g++){_=(((l>>>6|l<<26)^(l>>>11|l<<21)^(l>>>25|l<<7))+(l&f^~l&p)|0)+(d+(i[g]+e[g]|0)|0)|0,m=((a>>>2|a<<30)^(a>>>13|a<<19)^(a>>>22|a<<10))+(a&c^a&u^c&u)|0;d=p,p=f,f=l,l=h+_|0,h=u,u=c,c=a,a=_+m|0}r[0]+=a,r[1]+=c,r[2]+=u,r[3]+=h,r[4]+=l,r[5]+=f,r[6]+=p,r[7]+=d,s+=64,o-=64}return s}e.hash=function(e){var t=new n;t.update(e);var r=t.digest();return t.clean(),r}}(W);var Y={};function J(e){return null!=globalThis.Buffer?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e}function X(e=0){return null!=globalThis.Buffer&&null!=globalThis.Buffer.allocUnsafe?J(globalThis.Buffer.allocUnsafe(e)):new Uint8Array(e)}function Z(e,t){t||(t=e.reduce(((e,t)=>e+t.length),0));const r=X(t);let n=0;for(const t of e)r.set(t,n),n+=t.length;return J(r)}!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.sharedKey=e.generateKeyPair=e.generateKeyPairFromSeed=e.scalarMultBase=e.scalarMult=e.SHARED_KEY_LENGTH=e.SECRET_KEY_LENGTH=e.PUBLIC_KEY_LENGTH=void 0;const t=q,r=w;function n(e){const t=new Float64Array(16);if(e)for(let r=0;r<e.length;r++)t[r]=e[r];return t}e.PUBLIC_KEY_LENGTH=32,e.SECRET_KEY_LENGTH=32,e.SHARED_KEY_LENGTH=32;const i=new Uint8Array(32);i[0]=9;const s=n([56129,1]);function o(e){let t=1;for(let r=0;r<16;r++){let n=e[r]+t+65535;t=Math.floor(n/65536),e[r]=n-65536*t}e[0]+=t-1+37*(t-1)}function a(e,t,r){const n=~(r-1);for(let r=0;r<16;r++){const i=n&(e[r]^t[r]);e[r]^=i,t[r]^=i}}function c(e,t,r){for(let n=0;n<16;n++)e[n]=t[n]+r[n]}function u(e,t,r){for(let n=0;n<16;n++)e[n]=t[n]-r[n]}function h(e,t,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,y=0,v=0,_=0,m=0,w=0,b=0,E=0,S=0,I=0,O=0,P=0,N=0,A=0,x=0,C=0,T=0,R=0,j=0,L=0,U=0,M=r[0],D=r[1],k=r[2],z=r[3],$=r[4],q=r[5],H=r[6],K=r[7],V=r[8],B=r[9],F=r[10],G=r[11],W=r[12],Y=r[13],J=r[14],X=r[15];n=t[0],s+=n*M,o+=n*D,a+=n*k,c+=n*z,u+=n*$,h+=n*q,l+=n*H,f+=n*K,p+=n*V,d+=n*B,g+=n*F,y+=n*G,v+=n*W,_+=n*Y,m+=n*J,w+=n*X,n=t[1],o+=n*M,a+=n*D,c+=n*k,u+=n*z,h+=n*$,l+=n*q,f+=n*H,p+=n*K,d+=n*V,g+=n*B,y+=n*F,v+=n*G,_+=n*W,m+=n*Y,w+=n*J,b+=n*X,n=t[2],a+=n*M,c+=n*D,u+=n*k,h+=n*z,l+=n*$,f+=n*q,p+=n*H,d+=n*K,g+=n*V,y+=n*B,v+=n*F,_+=n*G,m+=n*W,w+=n*Y,b+=n*J,E+=n*X,n=t[3],c+=n*M,u+=n*D,h+=n*k,l+=n*z,f+=n*$,p+=n*q,d+=n*H,g+=n*K,y+=n*V,v+=n*B,_+=n*F,m+=n*G,w+=n*W,b+=n*Y,E+=n*J,S+=n*X,n=t[4],u+=n*M,h+=n*D,l+=n*k,f+=n*z,p+=n*$,d+=n*q,g+=n*H,y+=n*K,v+=n*V,_+=n*B,m+=n*F,w+=n*G,b+=n*W,E+=n*Y,S+=n*J,I+=n*X,n=t[5],h+=n*M,l+=n*D,f+=n*k,p+=n*z,d+=n*$,g+=n*q,y+=n*H,v+=n*K,_+=n*V,m+=n*B,w+=n*F,b+=n*G,E+=n*W,S+=n*Y,I+=n*J,O+=n*X,n=t[6],l+=n*M,f+=n*D,p+=n*k,d+=n*z,g+=n*$,y+=n*q,v+=n*H,_+=n*K,m+=n*V,w+=n*B,b+=n*F,E+=n*G,S+=n*W,I+=n*Y,O+=n*J,P+=n*X,n=t[7],f+=n*M,p+=n*D,d+=n*k,g+=n*z,y+=n*$,v+=n*q,_+=n*H,m+=n*K,w+=n*V,b+=n*B,E+=n*F,S+=n*G,I+=n*W,O+=n*Y,P+=n*J,N+=n*X,n=t[8],p+=n*M,d+=n*D,g+=n*k,y+=n*z,v+=n*$,_+=n*q,m+=n*H,w+=n*K,b+=n*V,E+=n*B,S+=n*F,I+=n*G,O+=n*W,P+=n*Y,N+=n*J,A+=n*X,n=t[9],d+=n*M,g+=n*D,y+=n*k,v+=n*z,_+=n*$,m+=n*q,w+=n*H,b+=n*K,E+=n*V,S+=n*B,I+=n*F,O+=n*G,P+=n*W,N+=n*Y,A+=n*J,x+=n*X,n=t[10],g+=n*M,y+=n*D,v+=n*k,_+=n*z,m+=n*$,w+=n*q,b+=n*H,E+=n*K,S+=n*V,I+=n*B,O+=n*F,P+=n*G,N+=n*W,A+=n*Y,x+=n*J,C+=n*X,n=t[11],y+=n*M,v+=n*D,_+=n*k,m+=n*z,w+=n*$,b+=n*q,E+=n*H,S+=n*K,I+=n*V,O+=n*B,P+=n*F,N+=n*G,A+=n*W,x+=n*Y,C+=n*J,T+=n*X,n=t[12],v+=n*M,_+=n*D,m+=n*k,w+=n*z,b+=n*$,E+=n*q,S+=n*H,I+=n*K,O+=n*V,P+=n*B,N+=n*F,A+=n*G,x+=n*W,C+=n*Y,T+=n*J,R+=n*X,n=t[13],_+=n*M,m+=n*D,w+=n*k,b+=n*z,E+=n*$,S+=n*q,I+=n*H,O+=n*K,P+=n*V,N+=n*B,A+=n*F,x+=n*G,C+=n*W,T+=n*Y,R+=n*J,j+=n*X,n=t[14],m+=n*M,w+=n*D,b+=n*k,E+=n*z,S+=n*$,I+=n*q,O+=n*H,P+=n*K,N+=n*V,A+=n*B,x+=n*F,C+=n*G,T+=n*W,R+=n*Y,j+=n*J,L+=n*X,n=t[15],w+=n*M,b+=n*D,E+=n*k,S+=n*z,I+=n*$,O+=n*q,P+=n*H,N+=n*K,A+=n*V,x+=n*B,C+=n*F,T+=n*G,R+=n*W,j+=n*Y,L+=n*J,U+=n*X,s+=38*b,o+=38*E,a+=38*S,c+=38*I,u+=38*O,h+=38*P,l+=38*N,f+=38*A,p+=38*x,d+=38*C,g+=38*T,y+=38*R,v+=38*j,_+=38*L,m+=38*U,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=y+i+65535,i=Math.floor(n/65536),y=n-65536*i,n=v+i+65535,i=Math.floor(n/65536),v=n-65536*i,n=_+i+65535,i=Math.floor(n/65536),_=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,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=y+i+65535,i=Math.floor(n/65536),y=n-65536*i,n=v+i+65535,i=Math.floor(n/65536),v=n-65536*i,n=_+i+65535,i=Math.floor(n/65536),_=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,s+=i-1+37*(i-1),e[0]=s,e[1]=o,e[2]=a,e[3]=c,e[4]=u,e[5]=h,e[6]=l,e[7]=f,e[8]=p,e[9]=d,e[10]=g,e[11]=y,e[12]=v,e[13]=_,e[14]=m,e[15]=w}function l(e,t){h(e,t,t)}function f(e,t){const r=new Uint8Array(32),i=new Float64Array(80),f=n(),p=n(),d=n(),g=n(),y=n(),v=n();for(let t=0;t<31;t++)r[t]=e[t];r[31]=127&e[31]|64,r[0]&=248,function(e,t){for(let r=0;r<16;r++)e[r]=t[2*r]+(t[2*r+1]<<8);e[15]&=32767}(i,t);for(let e=0;e<16;e++)p[e]=i[e];f[0]=g[0]=1;for(let e=254;e>=0;--e){const t=r[e>>>3]>>>(7&e)&1;a(f,p,t),a(d,g,t),c(y,f,d),u(f,f,d),c(d,p,g),u(p,p,g),l(g,y),l(v,f),h(f,d,f),h(d,p,y),c(y,f,d),u(f,f,d),l(p,f),u(d,g,v),h(f,d,s),c(f,f,g),h(d,d,f),h(f,g,v),h(g,p,i),l(p,y),a(f,p,t),a(d,g,t)}for(let e=0;e<16;e++)i[e+16]=f[e],i[e+32]=d[e],i[e+48]=p[e],i[e+64]=g[e];const _=i.subarray(32),m=i.subarray(16);!function(e,t){const r=n();for(let e=0;e<16;e++)r[e]=t[e];for(let e=253;e>=0;e--)l(r,r),2!==e&&4!==e&&h(r,r,t);for(let t=0;t<16;t++)e[t]=r[t]}(_,_),h(m,m,_);const w=new Uint8Array(32);return function(e,t){const r=n(),i=n();for(let e=0;e<16;e++)i[e]=t[e];o(i),o(i),o(i);for(let e=0;e<2;e++){r[0]=i[0]-65517;for(let e=1;e<15;e++)r[e]=i[e]-65535-(r[e-1]>>16&1),r[e-1]&=65535;r[15]=i[15]-32767-(r[14]>>16&1);const e=r[15]>>16&1;r[14]&=65535,a(i,r,1-e)}for(let t=0;t<16;t++)e[2*t]=255&i[t],e[2*t+1]=i[t]>>8}(w,m),w}function p(e){return f(e,i)}function d(t){if(t.length!==e.SECRET_KEY_LENGTH)throw new Error(`x25519: seed must be ${e.SECRET_KEY_LENGTH} bytes`);const r=new Uint8Array(t);return{publicKey:p(r),secretKey:r}}e.scalarMult=f,e.scalarMultBase=p,e.generateKeyPairFromSeed=d,e.generateKeyPair=function(e){const n=(0,t.randomBytes)(32,e),i=d(n);return(0,r.wipe)(n),i},e.sharedKey=function(t,r,n=!1){if(t.length!==e.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect secret key length");if(r.length!==e.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect public key length");const i=f(t,r);if(n){let e=0;for(let t=0;t<i.length;t++)e|=i[t];if(0===e)throw new Error("X25519: invalid shared key")}return i}}(Y);var Q=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<e.length;i++){var s=e.charAt(i),o=s.charCodeAt(0);if(255!==r[o])throw new TypeError(s+" is ambiguous");r[o]=i}var a=e.length,c=e.charAt(0),u=Math.log(a)/Math.log(256),h=Math.log(256)/Math.log(a);function l(e){if("string"!=typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var n=0,i=0;e[t]===c;)n++,t++;for(var s=(e.length-t)*u+1>>>0,o=new Uint8Array(s);e[t];){var h=r[e.charCodeAt(t)];if(255===h)return;for(var l=0,f=s-1;(0!==h||l<i)&&-1!==f;f--,l++)h+=a*o[f]>>>0,o[f]=h%256>>>0,h=h/256>>>0;if(0!==h)throw new Error("Non-zero carry");i=l,t++}if(" "!==e[t]){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(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,i=0,s=t.length;i!==s&&0===t[i];)i++,r++;for(var o=(s-i)*h+1>>>0,u=new Uint8Array(o);i!==s;){for(var l=t[i],f=0,p=o-1;(0!==l||f<n)&&-1!==p;p--,f++)l+=256*u[p]>>>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<o;++d)g+=e.charAt(u[d]);return g},decodeUnsafe:l,decode:function(e){var r=l(e);if(r)return r;throw new Error(`Non-${t} character`)}}},ee=Q;const te=e=>{if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")};class re{constructor(e,t,r){this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class ne{constructor(e,t,r){if(this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=r}decode(e){if("string"==typeof e){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}throw Error("Can only multibase decode strings")}or(e){return se(this,e)}}class ie{constructor(e){this.decoders=e}or(e){return se(this,e)}decode(e){const t=e[0],r=this.decoders[t];if(r)return r.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const se=(e,t)=>new ie({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}});class oe{constructor(e,t,r,n){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new re(e,t,r),this.decoder=new ne(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const ae=({name:e,prefix:t,encode:r,decode:n})=>new oe(e,t,r,n),ce=({prefix:e,name:t,alphabet:r})=>{const{encode:n,decode:i}=ee(r,t);return ae({prefix:e,name:t,encode:n,decode:e=>te(i(e))})},ue=({name:e,prefix:t,bitsPerChar:r,alphabet:n})=>ae({prefix:t,name:e,encode:e=>((e,t,r)=>{const n="="===t[t.length-1],i=(1<<r)-1;let s="",o=0,a=0;for(let n=0;n<e.length;++n)for(a=a<<8|e[n],o+=8;o>r;)o-=r,s+=t[i&a>>o];if(o&&(s+=t[i&a<<r-o]),n)for(;s.length*r&7;)s+="=";return s})(e,n,r),decode:t=>((e,t,r,n)=>{const i={};for(let e=0;e<t.length;++e)i[t[e]]=e;let s=e.length;for(;"="===e[s-1];)--s;const o=new Uint8Array(s*r/8|0);let a=0,c=0,u=0;for(let t=0;t<s;++t){const s=i[e[t]];if(void 0===s)throw new SyntaxError(`Non-${n} character`);c=c<<r|s,a+=r,a>=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,n,r,e)}),he=ae({prefix:"\0",name:"identity",encode:e=>(e=>(new TextDecoder).decode(e))(e),decode:e=>(e=>(new TextEncoder).encode(e))(e)});var le=Object.freeze({__proto__:null,identity:he});const fe=ue({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var pe=Object.freeze({__proto__:null,base2:fe});const de=ue({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var ge=Object.freeze({__proto__:null,base8:de});const ye=ce({prefix:"9",name:"base10",alphabet:"0123456789"});var ve=Object.freeze({__proto__:null,base10:ye});const _e=ue({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),me=ue({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var we=Object.freeze({__proto__:null,base16:_e,base16upper:me});const be=ue({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Ee=ue({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Se=ue({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Ie=ue({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Oe=ue({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Pe=ue({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Ne=ue({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Ae=ue({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),xe=ue({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Ce=Object.freeze({__proto__:null,base32:be,base32upper:Ee,base32pad:Se,base32padupper:Ie,base32hex:Oe,base32hexupper:Pe,base32hexpad:Ne,base32hexpadupper:Ae,base32z:xe});const Te=ce({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Re=ce({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var je=Object.freeze({__proto__:null,base36:Te,base36upper:Re});const Le=ce({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ue=ce({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Me=Object.freeze({__proto__:null,base58btc:Le,base58flickr:Ue});const De=ue({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),ke=ue({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),ze=ue({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),$e=ue({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var qe=Object.freeze({__proto__:null,base64:De,base64pad:ke,base64url:ze,base64urlpad:$e});const He=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),Ke=He.reduce(((e,t,r)=>(e[r]=t,e)),[]),Ve=He.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const Be=ae({prefix:"🚀",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=Ke[t]),"")},decode:function(e){const t=[];for(const r of e){const e=Ve[r.codePointAt(0)];if(void 0===e)throw new Error(`Non-base256emoji character: ${r}`);t.push(e)}return new Uint8Array(t)}});var Fe=Object.freeze({__proto__:null,base256emoji:Be}),Ge=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=Je;)r[n++]=255&t|We,t/=128;for(;t&Ye;)r[n++]=255&t|We,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},We=128,Ye=-128,Je=Math.pow(2,31);var Xe=function e(t,r){var n,i=0,s=0,o=r=r||0,a=t.length;do{if(o>=a)throw e.bytes=0,new RangeError("Could not decode varint");n=t[o++],i+=s<28?(n&Qe)<<s:(n&Qe)*Math.pow(2,s),s+=7}while(n>=Ze);return e.bytes=o-r,i},Ze=128,Qe=127;var et=Math.pow(2,7),tt=Math.pow(2,14),rt=Math.pow(2,21),nt=Math.pow(2,28),it=Math.pow(2,35),st=Math.pow(2,42),ot=Math.pow(2,49),at=Math.pow(2,56),ct=Math.pow(2,63),ut={encode:Ge,decode:Xe,encodingLength:function(e){return e<et?1:e<tt?2:e<rt?3:e<nt?4:e<it?5:e<st?6:e<ot?7:e<at?8:e<ct?9:10}};const ht=(e,t,r=0)=>(ut.encode(e,t,r),t),lt=e=>ut.encodingLength(e),ft=(e,t)=>{const r=t.byteLength,n=lt(e),i=n+lt(r),s=new Uint8Array(i+r);return ht(e,s,0),ht(r,s,n),s.set(t,i),new pt(e,r,t,s)};class pt{constructor(e,t,r,n){this.code=e,this.size=t,this.digest=r,this.bytes=n}}const dt=({name:e,code:t,encode:r})=>new gt(e,t,r);class gt{constructor(e,t,r){this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?ft(this.code,t):t.then((e=>ft(this.code,e)))}throw Error("Unknown type, must be binary type")}}const yt=e=>async t=>new Uint8Array(await crypto.subtle.digest(e,t));dt({name:"sha2-256",code:18,encode:yt("SHA-256")}),dt({name:"sha2-512",code:19,encode:yt("SHA-512")});new TextEncoder,new TextDecoder;const vt={...le,...pe,...ge,...ve,...we,...Ce,...je,...Me,...qe,...Fe};function _t(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}const mt=_t("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),wt=_t("ascii","a",(e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t}),(e=>{const t=X((e=e.substring(1)).length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t})),bt={utf8:mt,"utf-8":mt,hex:vt.base16,latin1:wt,ascii:wt,binary:wt,...vt};function Et(e,t="utf8"){const r=bt[t];if(!r)throw new Error(`Unsupported encoding "${t}"`);return"utf8"!==t&&"utf-8"!==t||null==globalThis.Buffer||null==globalThis.Buffer.from?r.decoder.decode(`${r.prefix}${e}`):J(globalThis.Buffer.from(e,"utf-8"))}function St(e,t="utf8"){const r=bt[t];if(!r)throw new Error(`Unsupported encoding "${t}"`);return"utf8"!==t&&"utf-8"!==t||null==globalThis.Buffer||null==globalThis.Buffer.from?r.encoder.encode(e).substring(1):globalThis.Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString("utf8")}var It=function(e,t,r){if(r||2===arguments.length)for(var n,i=0,s=t.length;i<s;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))},Ot=function(e,t,r){this.name=e,this.version=t,this.os=r,this.type="browser"},Pt=function(e){this.version=e,this.type="node",this.name="node",this.os=process.platform},Nt=function(e,t,r,n){this.name=e,this.version=t,this.os=r,this.bot=n,this.type="bot-device"},At=function(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null},xt=function(){this.type="react-native",this.name="react-native",this.version=null,this.os=null},Ct=/(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,Tt=3,Rt=[["aol",/AOLShield\/([0-9\._]+)/],["edge",/Edge\/([0-9\._]+)/],["edge-ios",/EdgiOS\/([0-9\._]+)/],["yandexbrowser",/YaBrowser\/([0-9\._]+)/],["kakaotalk",/KAKAOTALK\s([0-9\.]+)/],["samsung",/SamsungBrowser\/([0-9\.]+)/],["silk",/\bSilk\/([0-9._-]+)\b/],["miui",/MiuiBrowser\/([0-9\.]+)$/],["beaker",/BeakerBrowser\/([0-9\.]+)/],["edge-chromium",/EdgA?\/([0-9\.]+)/],["chromium-webview",/(?!Chrom.*OPR)wv\).*Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["chrome",/(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["phantomjs",/PhantomJS\/([0-9\.]+)(:?\s|$)/],["crios",/CriOS\/([0-9\.]+)(:?\s|$)/],["firefox",/Firefox\/([0-9\.]+)(?:\s|$)/],["fxios",/FxiOS\/([0-9\.]+)/],["opera-mini",/Opera Mini.*Version\/([0-9\.]+)/],["opera",/Opera\/([0-9\.]+)(?:\s|$)/],["opera",/OPR\/([0-9\.]+)(:?\s|$)/],["pie",/^Microsoft Pocket Internet Explorer\/(\d+\.\d+)$/],["pie",/^Mozilla\/\d\.\d+\s\(compatible;\s(?:MSP?IE|MSInternet Explorer) (\d+\.\d+);.*Windows CE.*\)$/],["netfront",/^Mozilla\/\d\.\d+.*NetFront\/(\d.\d)/],["ie",/Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/],["ie",/MSIE\s([0-9\.]+);.*Trident\/[4-7].0/],["ie",/MSIE\s(7\.0)/],["bb10",/BB10;\sTouch.*Version\/([0-9\.]+)/],["android",/Android\s([0-9\.]+)/],["ios",/Version\/([0-9\._]+).*Mobile.*Safari.*/],["safari",/Version\/([0-9\._]+).*Safari/],["facebook",/FB[AS]V\/([0-9\.]+)/],["instagram",/Instagram\s([0-9\.]+)/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Mobile/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Gecko\)$/],["curl",/^curl\/([0-9\.]+)$/],["searchbot",/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/]],jt=[["iOS",/iP(hone|od|ad)/],["Android OS",/Android/],["BlackBerry OS",/BlackBerry|BB10/],["Windows Mobile",/IEMobile/],["Amazon OS",/Kindle/],["Windows 3.11",/Win16/],["Windows 95",/(Windows 95)|(Win95)|(Windows_95)/],["Windows 98",/(Windows 98)|(Win98)/],["Windows 2000",/(Windows NT 5.0)|(Windows 2000)/],["Windows XP",/(Windows NT 5.1)|(Windows XP)/],["Windows Server 2003",/(Windows NT 5.2)/],["Windows Vista",/(Windows NT 6.0)/],["Windows 7",/(Windows NT 6.1)/],["Windows 8",/(Windows NT 6.2)/],["Windows 8.1",/(Windows NT 6.3)/],["Windows 10",/(Windows NT 10.0)/],["Windows ME",/Windows ME/],["Windows CE",/Windows CE|WinCE|Microsoft Pocket Internet Explorer/],["Open BSD",/OpenBSD/],["Sun OS",/SunOS/],["Chrome OS",/CrOS/],["Linux",/(Linux)|(X11)/],["Mac OS",/(Mac_PowerPC)|(Macintosh)/],["QNX",/QNX/],["BeOS",/BeOS/],["OS/2",/OS\/2/]];function Lt(e){return e?Ut(e):"undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"===navigator.product?new xt:"undefined"!=typeof navigator?Ut(navigator.userAgent):"undefined"!=typeof process&&process.version?new Pt(process.version.slice(1)):null}function Ut(e){var t=function(e){return""!==e&&Rt.reduce((function(t,r){var n=r[0],i=r[1];if(t)return t;var s=i.exec(e);return!!s&&[n,s]}),!1)}(e);if(!t)return null;var r=t[0],n=t[1];if("searchbot"===r)return new At;var i=n[1]&&n[1].split(".").join("_").split("_").slice(0,3);i?i.length<Tt&&(i=It(It([],i,!0),function(e){for(var t=[],r=0;r<e;r++)t.push("0");return t}(Tt-i.length),!0)):i=[];var s=i.join("."),o=function(e){for(var t=0,r=jt.length;t<r;t++){var n=jt[t],i=n[0];if(n[1].exec(e))return i}return null}(e),a=Ct.exec(e);return a&&a[1]?new Nt(r,s,o,a[1]):new Ot(r,s,o)}var Mt={},Dt=function(e,t){return Dt=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},Dt(e,t)};var kt=function(){return kt=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},kt.apply(this,arguments)};var zt=Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]};function $t(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function qt(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,s=r.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(n=s.next()).done;)o.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=s.return)&&r.call(s)}finally{if(i)throw i.error}}return o}function Ht(e){return this instanceof Ht?(this.v=e,this):new Ht(e)}var Kt=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t};var Vt,Bt=Object.freeze({__proto__:null,__extends:function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}Dt(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)},get __assign(){return kt},__rest:function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]])}return r},__decorate:function(e,t,r,n){var i,s=arguments.length,o=s<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(o=(s<3?i(o):s>3?i(t,r,o):i(t,r))||o);return s>3&&o&&Object.defineProperty(t,r,o),o},__param:function(e,t){return function(r,n){t(r,n,e)}},__esDecorate:function(e,t,r,n,i,s){function o(e){if(void 0!==e&&"function"!=typeof e)throw new TypeError("Function expected");return e}for(var a,c=n.kind,u="getter"===c?"get":"setter"===c?"set":"value",h=!t&&e?n.static?e:e.prototype:null,l=t||(h?Object.getOwnPropertyDescriptor(h,n.name):{}),f=!1,p=r.length-1;p>=0;p--){var d={};for(var g in n)d[g]="access"===g?{}:n[g];for(var g in n.access)d.access[g]=n.access[g];d.addInitializer=function(e){if(f)throw new TypeError("Cannot add initializers after decoration has completed");s.push(o(e||null))};var y=(0,r[p])("accessor"===c?{get:l.get,set:l.set}:l[u],d);if("accessor"===c){if(void 0===y)continue;if(null===y||"object"!=typeof y)throw new TypeError("Object expected");(a=o(y.get))&&(l.get=a),(a=o(y.set))&&(l.set=a),(a=o(y.init))&&i.push(a)}else(a=o(y))&&("field"===c?i.push(a):l[u]=a)}h&&Object.defineProperty(h,n.name,l),f=!0},__runInitializers:function(e,t,r){for(var n=arguments.length>2,i=0;i<t.length;i++)r=n?t[i].call(e,r):t[i].call(e);return n?r:void 0},__propKey:function(e){return"symbol"==typeof e?e:"".concat(e)},__setFunctionName:function(e,t,r){return"symbol"==typeof t&&(t=t.description?"[".concat(t.description,"]"):""),Object.defineProperty(e,"name",{configurable:!0,value:r?"".concat(r," ",t):t})},__metadata:function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},__awaiter:function(e,t,r,n){return new(r||(r=Promise))((function(i,s){function o(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))},__generator:function(e,t){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(a){return function(c){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(o=0)),o;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,n=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){o.label=a[1];break}if(6===a[0]&&o.label<i[1]){o.label=i[1],i=a;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(a);break}i[2]&&o.ops.pop(),o.trys.pop();continue}a=t.call(e,o)}catch(e){a=[6,e],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},__createBinding:zt,__exportStar:function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||zt(t,e,r)},__values:$t,__read:qt,__spread:function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(qt(arguments[t]));return e},__spreadArrays:function(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var n=Array(e),i=0;for(t=0;t<r;t++)for(var s=arguments[t],o=0,a=s.length;o<a;o++,i++)n[i]=s[o];return n},__spreadArray:function(e,t,r){if(r||2===arguments.length)for(var n,i=0,s=t.length;i<s;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))},__await:Ht,__asyncGenerator:function(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,i=r.apply(e,t||[]),s=[];return n={},o("next"),o("throw"),o("return"),n[Symbol.asyncIterator]=function(){return this},n;function o(e){i[e]&&(n[e]=function(t){return new Promise((function(r,n){s.push([e,t,r,n])>1||a(e,t)}))})}function a(e,t){try{(r=i[e](t)).value instanceof Ht?Promise.resolve(r.value.v).then(c,u):h(s[0][2],r)}catch(e){h(s[0][3],e)}var r}function c(e){a("next",e)}function u(e){a("throw",e)}function h(e,t){e(t),s.shift(),s.length&&a(s[0][0],s[0][1])}},__asyncDelegator:function(e){var t,r;return t={},n("next"),n("throw",(function(e){throw e})),n("return"),t[Symbol.iterator]=function(){return this},t;function n(n,i){t[n]=e[n]?function(t){return(r=!r)?{value:Ht(e[n](t)),done:!1}:i?i(t):t}:i}},__asyncValues:function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=$t(e),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=e[r]&&function(t){return new Promise((function(n,i){(function(e,t,r,n){Promise.resolve(n).then((function(t){e({value:t,done:r})}),t)})(n,i,(t=e[r](t)).done,t.value)}))}}},__makeTemplateObject:function(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e},__importStar:function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&zt(t,e,r);return Kt(t,e),t},__importDefault:function(e){return e&&e.__esModule?e:{default:e}},__classPrivateFieldGet:function(e,t,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)},__classPrivateFieldSet:function(e,t,r,n,i){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?i.call(e,r):i?i.value=r:t.set(e,r),r},__classPrivateFieldIn:function(e,t){if(null===t||"object"!=typeof t&&"function"!=typeof t)throw new TypeError("Cannot use 'in' operator on non-object");return"function"==typeof e?t===e:e.has(t)}}),Ft=r.getAugmentedNamespace(Bt),Gt={},Wt={};var Yt,Jt={},Xt={},Zt={};var Qt,er,tr,rr,nr={};function ir(){return er||(er=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});const t=Ft;t.__exportStar((Yt||(Yt=1,Object.defineProperty(Zt,"__esModule",{value:!0}),Zt.ONE_THOUSAND=Zt.ONE_HUNDRED=void 0,Zt.ONE_HUNDRED=100,Zt.ONE_THOUSAND=1e3),Zt),e),t.__exportStar((Qt||(Qt=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.ONE_YEAR=e.FOUR_WEEKS=e.THREE_WEEKS=e.TWO_WEEKS=e.ONE_WEEK=e.THIRTY_DAYS=e.SEVEN_DAYS=e.FIVE_DAYS=e.THREE_DAYS=e.ONE_DAY=e.TWENTY_FOUR_HOURS=e.TWELVE_HOURS=e.SIX_HOURS=e.THREE_HOURS=e.ONE_HOUR=e.SIXTY_MINUTES=e.THIRTY_MINUTES=e.TEN_MINUTES=e.FIVE_MINUTES=e.ONE_MINUTE=e.SIXTY_SECONDS=e.THIRTY_SECONDS=e.TEN_SECONDS=e.FIVE_SECONDS=e.ONE_SECOND=void 0,e.ONE_SECOND=1,e.FIVE_SECONDS=5,e.TEN_SECONDS=10,e.THIRTY_SECONDS=30,e.SIXTY_SECONDS=60,e.ONE_MINUTE=e.SIXTY_SECONDS,e.FIVE_MINUTES=5*e.ONE_MINUTE,e.TEN_MINUTES=10*e.ONE_MINUTE,e.THIRTY_MINUTES=30*e.ONE_MINUTE,e.SIXTY_MINUTES=60*e.ONE_MINUTE,e.ONE_HOUR=e.SIXTY_MINUTES,e.THREE_HOURS=3*e.ONE_HOUR,e.SIX_HOURS=6*e.ONE_HOUR,e.TWELVE_HOURS=12*e.ONE_HOUR,e.TWENTY_FOUR_HOURS=24*e.ONE_HOUR,e.ONE_DAY=e.TWENTY_FOUR_HOURS,e.THREE_DAYS=3*e.ONE_DAY,e.FIVE_DAYS=5*e.ONE_DAY,e.SEVEN_DAYS=7*e.ONE_DAY,e.THIRTY_DAYS=30*e.ONE_DAY,e.ONE_WEEK=e.SEVEN_DAYS,e.TWO_WEEKS=2*e.ONE_WEEK,e.THREE_WEEKS=3*e.ONE_WEEK,e.FOUR_WEEKS=4*e.ONE_WEEK,e.ONE_YEAR=365*e.ONE_DAY}(nr)),nr),e)}(Xt)),Xt}function sr(){return rr||(rr=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});const t=Ft;t.__exportStar((Vt||(Vt=1,Object.defineProperty(Wt,"__esModule",{value:!0}),Wt.delay=void 0,Wt.delay=function(e){return new Promise((t=>{setTimeout((()=>{t(!0)}),e)}))}),Wt),e),t.__exportStar(function(){if(tr)return Jt;tr=1,Object.defineProperty(Jt,"__esModule",{value:!0}),Jt.fromMiliseconds=Jt.toMiliseconds=void 0;const e=ir();return Jt.toMiliseconds=function(t){return t*e.ONE_THOUSAND},Jt.fromMiliseconds=function(t){return Math.floor(t/e.ONE_THOUSAND)},Jt}(),e)}(Gt)),Gt}var or,ar={};var cr,ur,hr={},lr={};function fr(){return ur||(ur=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});Ft.__exportStar((cr||(cr=1,Object.defineProperty(lr,"__esModule",{value:!0}),lr.IWatch=void 0,lr.IWatch=class{}),lr),e)}(hr)),hr}!function(e){Object.defineProperty(e,"__esModule",{value:!0});const t=Ft;t.__exportStar(sr(),e),t.__exportStar(function(){if(or)return ar;or=1,Object.defineProperty(ar,"__esModule",{value:!0}),ar.Watch=void 0;class e{constructor(){this.timestamps=new Map}start(e){if(this.timestamps.has(e))throw new Error(`Watch already started for label: ${e}`);this.timestamps.set(e,{started:Date.now()})}stop(e){const t=this.get(e);if(void 0!==t.elapsed)throw new Error(`Watch already stopped for label: ${e}`);const r=Date.now()-t.started;this.timestamps.set(e,{started:t.started,elapsed:r})}get(e){const t=this.timestamps.get(e);if(void 0===t)throw new Error(`No timestamp found for label: ${e}`);return t}elapsed(e){const t=this.get(e);return t.elapsed||Date.now()-t.started}}return ar.Watch=e,ar.default=e,ar}(),e),t.__exportStar(fr(),e),t.__exportStar(ir(),e)}(Mt);var pr={};function dr(e){let t;return"undefined"!=typeof window&&void 0!==window[e]&&(t=window[e]),t}function gr(e){const t=dr(e);if(!t)throw new Error(`${e} is not defined in Window`);return t}Object.defineProperty(pr,"__esModule",{value:!0}),pr.getLocalStorage=pr.getLocalStorageOrThrow=pr.getCrypto=pr.getCryptoOrThrow=_r=pr.getLocation=pr.getLocationOrThrow=vr=pr.getNavigator=pr.getNavigatorOrThrow=yr=pr.getDocument=pr.getDocumentOrThrow=pr.getFromWindowOrThrow=pr.getFromWindow=void 0,pr.getFromWindow=dr,pr.getFromWindowOrThrow=gr,pr.getDocumentOrThrow=function(){return gr("document")};var yr=pr.getDocument=function(){return dr("document")};pr.getNavigatorOrThrow=function(){return gr("navigator")};var vr=pr.getNavigator=function(){return dr("navigator")};pr.getLocationOrThrow=function(){return gr("location")};var _r=pr.getLocation=function(){return dr("location")};pr.getCryptoOrThrow=function(){return gr("crypto")},pr.getCrypto=function(){return dr("crypto")},pr.getLocalStorageOrThrow=function(){return gr("localStorage")},pr.getLocalStorage=function(){return dr("localStorage")};var mr={};Object.defineProperty(mr,"__esModule",{value:!0});var wr=mr.getWindowMetadata=void 0;const br=pr;wr=mr.getWindowMetadata=function(){let e,t;try{e=br.getDocumentOrThrow(),t=br.getLocationOrThrow()}catch(e){return null}function r(...t){const r=e.getElementsByTagName("meta");for(let e=0;e<r.length;e++){const n=r[e],i=["itemprop","property","name"].map((e=>n.getAttribute(e))).filter((e=>!!e&&t.includes(e)));if(i.length&&i){const e=n.getAttribute("content");if(e)return e}}return""}const n=function(){let t=r("name","og:site_name","og:title","twitter:title");return t||(t=e.title),t}();return{description:r("description","og:description","twitter:description","keywords"),url:t.origin,icons:function(){const r=e.getElementsByTagName("link"),n=[];for(let e=0;e<r.length;e++){const i=r[e],s=i.getAttribute("rel");if(s&&s.toLowerCase().indexOf("icon")>-1){const e=i.getAttribute("href");if(e)if(-1===e.toLowerCase().indexOf("https:")&&-1===e.toLowerCase().indexOf("http:")&&0!==e.indexOf("//")){let r=t.protocol+"//"+t.host;if(0===e.indexOf("/"))r+=e;else{const n=t.pathname.split("/");n.pop();r+=n.join("/")+"/"+e}n.push(r)}else if(0===e.indexOf("//")){const r=t.protocol+e;n.push(r)}else n.push(e)}}return n}(),name:n}};var Er={},Sr=e=>encodeURIComponent(e).replace(/[!'()*]/g,(e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`)),Ir="%[a-f0-9]{2}",Or=new RegExp("("+Ir+")|([^%]+?)","gi"),Pr=new RegExp("("+Ir+")+","gi");function Nr(e,t){try{return[decodeURIComponent(e.join(""))]}catch(e){}if(1===e.length)return e;t=t||1;var r=e.slice(0,t),n=e.slice(t);return Array.prototype.concat.call([],Nr(r),Nr(n))}function Ar(e){try{return decodeURIComponent(e)}catch(n){for(var t=e.match(Or)||[],r=1;r<t.length;r++)t=(e=Nr(t,r).join("")).match(Or)||[];return e}}var xr=function(e){if("string"!=typeof e)throw new TypeError("Expected `encodedURI` to be of type `string`, got `"+typeof e+"`");try{return e=e.replace(/\+/g," "),decodeURIComponent(e)}catch(t){return function(e){for(var t={"%FE%FF":"��","%FF%FE":"��"},r=Pr.exec(e);r;){try{t[r[0]]=decodeURIComponent(r[0])}catch(e){var n=Ar(r[0]);n!==r[0]&&(t[r[0]]=n)}r=Pr.exec(e)}t["%C2"]="�";for(var i=Object.keys(t),s=0;s<i.length;s++){var o=i[s];e=e.replace(new RegExp(o,"g"),t[o])}return e}(e)}},Cr=(e,t)=>{if("string"!=typeof e||"string"!=typeof t)throw new TypeError("Expected the arguments to be of type `string`");if(""===t)return[e];const r=e.indexOf(t);return-1===r?[e]:[e.slice(0,r),e.slice(r+t.length)]},Tr=function(e,t){for(var r={},n=Object.keys(e),i=Array.isArray(t),s=0;s<n.length;s++){var o=n[s],a=e[o];(i?-1!==t.indexOf(o):t(o,a,e))&&(r[o]=a)}return r};!function(e){const t=Sr,r=xr,n=Cr,i=Tr,s=Symbol("encodeFragmentIdentifier");function o(e){if("string"!=typeof e||1!==e.length)throw new TypeError("arrayFormatSeparator must be single character string")}function a(e,r){return r.encode?r.strict?t(e):encodeURIComponent(e):e}function c(e,t){return t.decode?r(e):e}function u(e){return Array.isArray(e)?e.sort():"object"==typeof e?u(Object.keys(e)).sort(((e,t)=>Number(e)-Number(t))).map((t=>e[t])):e}function h(e){const t=e.indexOf("#");return-1!==t&&(e=e.slice(0,t)),e}function l(e){const t=(e=h(e)).indexOf("?");return-1===t?"":e.slice(t+1)}function f(e,t){return t.parseNumbers&&!Number.isNaN(Number(e))&&"string"==typeof e&&""!==e.trim()?e=Number(e):!t.parseBooleans||null===e||"true"!==e.toLowerCase()&&"false"!==e.toLowerCase()||(e="true"===e.toLowerCase()),e}function p(e,t){o((t=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},t)).arrayFormatSeparator);const r=function(e){let t;switch(e.arrayFormat){case"index":return(e,r,n)=>{t=/\[(\d*)\]$/.exec(e),e=e.replace(/\[\d*\]$/,""),t?(void 0===n[e]&&(n[e]={}),n[e][t[1]]=r):n[e]=r};case"bracket":return(e,r,n)=>{t=/(\[\])$/.exec(e),e=e.replace(/\[\]$/,""),t?void 0!==n[e]?n[e]=[].concat(n[e],r):n[e]=[r]:n[e]=r};case"colon-list-separator":return(e,r,n)=>{t=/(:list)$/.exec(e),e=e.replace(/:list$/,""),t?void 0!==n[e]?n[e]=[].concat(n[e],r):n[e]=[r]:n[e]=r};case"comma":case"separator":return(t,r,n)=>{const i="string"==typeof r&&r.includes(e.arrayFormatSeparator),s="string"==typeof r&&!i&&c(r,e).includes(e.arrayFormatSeparator);r=s?c(r,e):r;const o=i||s?r.split(e.arrayFormatSeparator).map((t=>c(t,e))):null===r?r:c(r,e);n[t]=o};case"bracket-separator":return(t,r,n)=>{const i=/(\[\])$/.test(t);if(t=t.replace(/\[\]$/,""),!i)return void(n[t]=r?c(r,e):r);const s=null===r?[]:r.split(e.arrayFormatSeparator).map((t=>c(t,e)));void 0!==n[t]?n[t]=[].concat(n[t],s):n[t]=s};default:return(e,t,r)=>{void 0!==r[e]?r[e]=[].concat(r[e],t):r[e]=t}}}(t),i=Object.create(null);if("string"!=typeof e)return i;if(!(e=e.trim().replace(/^[?#&]/,"")))return i;for(const s of e.split("&")){if(""===s)continue;let[e,o]=n(t.decode?s.replace(/\+/g," "):s,"=");o=void 0===o?null:["comma","separator","bracket-separator"].includes(t.arrayFormat)?o:c(o,t),r(c(e,t),o,i)}for(const e of Object.keys(i)){const r=i[e];if("object"==typeof r&&null!==r)for(const e of Object.keys(r))r[e]=f(r[e],t);else i[e]=f(r,t)}return!1===t.sort?i:(!0===t.sort?Object.keys(i).sort():Object.keys(i).sort(t.sort)).reduce(((e,t)=>{const r=i[t];return Boolean(r)&&"object"==typeof r&&!Array.isArray(r)?e[t]=u(r):e[t]=r,e}),Object.create(null))}e.extract=l,e.parse=p,e.stringify=(e,t)=>{if(!e)return"";o((t=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},t)).arrayFormatSeparator);const r=r=>t.skipNull&&null==e[r]||t.skipEmptyString&&""===e[r],n=function(e){switch(e.arrayFormat){case"index":return t=>(r,n)=>{const i=r.length;return void 0===n||e.skipNull&&null===n||e.skipEmptyString&&""===n?r:null===n?[...r,[a(t,e),"[",i,"]"].join("")]:[...r,[a(t,e),"[",a(i,e),"]=",a(n,e)].join("")]};case"bracket":return t=>(r,n)=>void 0===n||e.skipNull&&null===n||e.skipEmptyString&&""===n?r:null===n?[...r,[a(t,e),"[]"].join("")]:[...r,[a(t,e),"[]=",a(n,e)].join("")];case"colon-list-separator":return t=>(r,n)=>void 0===n||e.skipNull&&null===n||e.skipEmptyString&&""===n?r:null===n?[...r,[a(t,e),":list="].join("")]:[...r,[a(t,e),":list=",a(n,e)].join("")];case"comma":case"separator":case"bracket-separator":{const t="bracket-separator"===e.arrayFormat?"[]=":"=";return r=>(n,i)=>void 0===i||e.skipNull&&null===i||e.skipEmptyString&&""===i?n:(i=null===i?"":i,0===n.length?[[a(r,e),t,a(i,e)].join("")]:[[n,a(i,e)].join(e.arrayFormatSeparator)])}default:return t=>(r,n)=>void 0===n||e.skipNull&&null===n||e.skipEmptyString&&""===n?r:null===n?[...r,a(t,e)]:[...r,[a(t,e),"=",a(n,e)].join("")]}}(t),i={};for(const t of Object.keys(e))r(t)||(i[t]=e[t]);const s=Object.keys(i);return!1!==t.sort&&s.sort(t.sort),s.map((r=>{const i=e[r];return void 0===i?"":null===i?a(r,t):Array.isArray(i)?0===i.length&&"bracket-separator"===t.arrayFormat?a(r,t)+"[]":i.reduce(n(r),[]).join("&"):a(r,t)+"="+a(i,t)})).filter((e=>e.length>0)).join("&")},e.parseUrl=(e,t)=>{t=Object.assign({decode:!0},t);const[r,i]=n(e,"#");return Object.assign({url:r.split("?")[0]||"",query:p(l(e),t)},t&&t.parseFragmentIdentifier&&i?{fragmentIdentifier:c(i,t)}:{})},e.stringifyUrl=(t,r)=>{r=Object.assign({encode:!0,strict:!0,[s]:!0},r);const n=h(t.url).split("?")[0]||"",i=e.extract(t.url),o=e.parse(i,{sort:!1}),c=Object.assign(o,t.query);let u=e.stringify(c,r);u&&(u=`?${u}`);let l=function(e){let t="";const r=e.indexOf("#");return-1!==r&&(t=e.slice(r)),t}(t.url);return t.fragmentIdentifier&&(l=`#${r[s]?a(t.fragmentIdentifier,r):t.fragmentIdentifier}`),`${n}${u}${l}`},e.pick=(t,r,n)=>{n=Object.assign({parseFragmentIdentifier:!0,[s]:!1},n);const{url:o,query:a,fragmentIdentifier:c}=e.parseUrl(t,n);return e.stringifyUrl({url:o,query:i(a,r),fragmentIdentifier:c},n)},e.exclude=(t,r,n)=>{const i=Array.isArray(r)?e=>!r.includes(e):(e,t)=>!r(e,t);return e.pick(t,i,n)}}(Er);const Rr={waku:{publish:"waku_publish",batchPublish:"waku_batchPublish",subscribe:"waku_subscribe",batchSubscribe:"waku_batchSubscribe",subscription:"waku_subscription",unsubscribe:"waku_unsubscribe",batchUnsubscribe:"waku_batchUnsubscribe"},irn:{publish:"irn_publish",batchPublish:"irn_batchPublish",subscribe:"irn_subscribe",batchSubscribe:"irn_batchSubscribe",subscription:"irn_subscription",unsubscribe:"irn_unsubscribe",batchUnsubscribe:"irn_batchUnsubscribe"},iridium:{publish:"iridium_publish",batchPublish:"iridium_batchPublish",subscribe:"iridium_subscribe",batchSubscribe:"iridium_batchSubscribe",subscription:"iridium_subscription",unsubscribe:"iridium_unsubscribe",batchUnsubscribe:"iridium_batchUnsubscribe"}};function jr(e,t){return e.includes(":")?[e]:t.chains||[]}const Lr="base10",Ur="base16",Mr="base64pad",Dr="utf8",kr=0,zr=1,$r=0,qr=1,Hr=12,Kr=32;function Vr(){return St(q.randomBytes(Kr),Ur)}function Br(e){return St(W.hash(Et(e,Dr)),Ur)}function Fr(e){return Number(St(e,Lr))}function Gr(e){const t=function(e){return Et(`${e}`,Lr)}(typeof e.type<"u"?e.type:kr);if(Fr(t)===zr&&typeof e.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const r=typeof e.senderPublicKey<"u"?Et(e.senderPublicKey,Ur):void 0,n=typeof e.iv<"u"?Et(e.iv,Ur):q.randomBytes(Hr);return function(e){if(Fr(e.type)===zr){if(typeof e.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return St(Z([e.type,e.senderPublicKey,e.iv,e.sealed]),Mr)}return St(Z([e.type,e.iv,e.sealed]),Mr)}({type:t,sealed:new s.ChaCha20Poly1305(Et(e.symKey,Ur)).seal(n,Et(e.message,Dr)),iv:n,senderPublicKey:r})}function Wr(e){const t=Et(e,Mr),r=t.slice($r,qr),n=qr;if(Fr(r)===zr){const e=n+Kr,i=e+Hr,s=t.slice(n,e),o=t.slice(e,i);return{type:r,sealed:t.slice(i),iv:o,senderPublicKey:s}}const i=n+Hr,s=t.slice(n,i);return{type:r,sealed:t.slice(i),iv:s}}function Yr(e){const t=e?.type||kr;if(t===zr){if(typeof e?.senderPublicKey>"u")throw new Error("missing sender public key");if(typeof e?.receiverPublicKey>"u")throw new Error("missing receiver public key")}return{type:t,senderPublicKey:e?.senderPublicKey,receiverPublicKey:e?.receiverPublicKey}}function Jr(e){return e.type===zr&&"string"==typeof e.senderPublicKey&&"string"==typeof e.receiverPublicKey}var Xr=Object.defineProperty,Zr=Object.getOwnPropertySymbols,Qr=Object.prototype.hasOwnProperty,en=Object.prototype.propertyIsEnumerable,tn=(e,t,r)=>t in e?Xr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,rn=(e,t)=>{for(var r in t||(t={}))Qr.call(t,r)&&tn(e,r,t[r]);if(Zr)for(var r of Zr(t))en.call(t,r)&&tn(e,r,t[r]);return e};const nn="ReactNative",sn={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},on="js";function an(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function cn(){return!yr()&&!!vr()&&navigator.product===nn}function un(){return!an()&&!!vr()}function hn(){return cn()?sn.reactNative:an()?sn.node:un()?sn.browser:sn.unknown}function ln(e,t,r){const n=function(){if(hn()===sn.reactNative&&typeof global<"u"&&typeof(null==global?void 0:global.Platform)<"u"){const{OS:e,Version:t}=global.Platform;return[e,t].join("-")}const e=Lt();if(null===e)return"unknown";const t=e.os?e.os.replace(" ","").toLowerCase():"unknown";return"browser"===e.type?[t,e.name,e.version].join("-"):[t,e.version].join("-")}(),i=function(){var e;const t=hn();return t===sn.browser?[t,(null==(e=_r())?void 0:e.host)||"unknown"].join(":"):t}();return[[e,t].join("-"),[on,r].join("-"),n,i].join("/")}function fn({protocol:e,version:t,relayUrl:r,sdkVersion:n,auth:i,projectId:s,useOnCloseEvent:o}){const a=r.split("?"),c={auth:i,ua:ln(e,t,n),projectId:s,useOnCloseEvent:o||void 0},u=function(e,t){let r=Er.parse(e);return r=rn(rn({},r),t),Er.stringify(r)}(a[1]||"",c);return a[0]+"?"+u}function pn(e,t){return e.filter((e=>t.includes(e))).length===e.length}function dn(e){return Object.fromEntries(e.entries())}function gn(e){return new Map(Object.entries(e))}function yn(e=Mt.FIVE_MINUTES,t){const r=Mt.toMiliseconds(e||Mt.FIVE_MINUTES);let n,i,s;return{resolve:e=>{s&&n&&(clearTimeout(s),n(e))},reject:e=>{s&&i&&(clearTimeout(s),i(e))},done:()=>new Promise(((e,o)=>{s=setTimeout((()=>{o(new Error(t))}),r),n=e,i=o}))}}function vn(e,t,r){return new Promise((async(n,i)=>{const s=setTimeout((()=>i(new Error(r))),t);try{n(await e)}catch(e){i(e)}clearTimeout(s)}))}function _n(e,t){if("string"==typeof t&&t.startsWith(`${e}:`))return t;if("topic"===e.toLowerCase()){if("string"!=typeof t)throw new Error('Value must be "string" for expirer target type: topic');return`topic:${t}`}if("id"===e.toLowerCase()){if("number"!=typeof t)throw new Error('Value must be "number" for expirer target type: id');return`id:${t}`}throw new Error(`Unknown expirer target type: ${e}`)}function mn(e){const[t,r]=e.split(":"),n={id:void 0,topic:void 0};if("topic"===t&&"string"==typeof r)n.topic=r;else{if("id"!==t||!Number.isInteger(Number(r)))throw new Error(`Invalid target, expected id:number or topic:string, got ${t}:${r}`);n.id=Number(r)}return n}function wn(e,t){return Mt.fromMiliseconds((t||Date.now())+Mt.toMiliseconds(e))}function bn(e){return Date.now()>=Mt.toMiliseconds(e)}function En(e,t){return`${e}${t?`:${t}`:""}`}function Sn(e=[],t=[]){return[...new Set([...e,...t])]}function In(e){return e?.relay||{protocol:"irn"}}function On(e){const t=Rr[e];if(typeof t>"u")throw new Error(`Relay Protocol not supported: ${e}`);return t}var Pn=Object.defineProperty,Nn=Object.getOwnPropertySymbols,An=Object.prototype.hasOwnProperty,xn=Object.prototype.propertyIsEnumerable,Cn=(e,t,r)=>t in e?Pn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;function Tn(e,t="-"){const r={},n="relay"+t;return Object.keys(e).forEach((t=>{if(t.startsWith(n)){const i=t.replace(n,""),s=e[t];r[i]=s}})),r}function Rn(e){return e.startsWith("//")?e.substring(2):e}function jn(e){return`${e.protocol}:${e.topic}@${e.version}?`+Er.stringify(((e,t)=>{for(var r in t||(t={}))An.call(t,r)&&Cn(e,r,t[r]);if(Nn)for(var r of Nn(t))xn.call(t,r)&&Cn(e,r,t[r]);return e})({symKey:e.symKey},function(e,t="-"){const r={};return Object.keys(e).forEach((n=>{const i="relay"+t+n;e[n]&&(r[i]=e[n])})),r}(e.relay)))}function Ln(e){const t=[];return e.forEach((e=>{const[r,n]=e.split(":");t.push(`${r}:${n}`)})),t}function Un(e){return e.includes(":")}function Mn(e){return Un(e)?e.split(":")[0]:e}const Dn={INVALID_METHOD:{message:"Invalid method.",code:1001},INVALID_EVENT:{message:"Invalid event.",code:1002},INVALID_UPDATE_REQUEST:{message:"Invalid update request.",code:1003},INVALID_EXTEND_REQUEST:{message:"Invalid extend request.",code:1004},INVALID_SESSION_SETTLE_REQUEST:{message:"Invalid session settle request.",code:1005},UNAUTHORIZED_METHOD:{message:"Unauthorized method.",code:3001},UNAUTHORIZED_EVENT:{message:"Unauthorized event.",code:3002},UNAUTHORIZED_UPDATE_REQUEST:{message:"Unauthorized update request.",code:3003},UNAUTHORIZED_EXTEND_REQUEST:{message:"Unauthorized extend request.",code:3004},USER_REJECTED:{message:"User rejected.",code:5e3},USER_REJECTED_CHAINS:{message:"User rejected chains.",code:5001},USER_REJECTED_METHODS:{message:"User rejected methods.",code:5002},USER_REJECTED_EVENTS:{message:"User rejected events.",code:5003},UNSUPPORTED_CHAINS:{message:"Unsupported chains.",code:5100},UNSUPPORTED_METHODS:{message:"Unsupported methods.",code:5101},UNSUPPORTED_EVENTS:{message:"Unsupported events.",code:5102},UNSUPPORTED_ACCOUNTS:{message:"Unsupported accounts.",code:5103},UNSUPPORTED_NAMESPACE_KEY:{message:"Unsupported namespace key.",code:5104},USER_DISCONNECTED:{message:"User disconnected.",code:6e3},SESSION_SETTLEMENT_FAILED:{message:"Session settlement failed.",code:7e3},WC_METHOD_UNSUPPORTED:{message:"Unsupported wc_ method.",code:10001}},kn={NOT_INITIALIZED:{message:"Not initialized.",code:1},NO_MATCHING_KEY:{message:"No matching key.",code:2},RESTORE_WILL_OVERRIDE:{message:"Restore will override.",code:3},RESUBSCRIBED:{message:"Resubscribed.",code:4},MISSING_OR_INVALID:{message:"Missing or invalid.",code:5},EXPIRED:{message:"Expired.",code:6},UNKNOWN_TYPE:{message:"Unknown type.",code:7},MISMATCHED_TOPIC:{message:"Mismatched topic.",code:8},NON_CONFORMING_NAMESPACES:{message:"Non conforming namespaces.",code:9}};function zn(e,t){const{message:r,code:n}=kn[e];return{message:t?`${r} ${t}`:r,code:n}}function $n(e,t){const{message:r,code:n}=Dn[e];return{message:t?`${r} ${t}`:r,code:n}}function qn(e,t){return!!Array.isArray(e)&&(!(typeof t<"u"&&e.length)||e.every(t))}function Hn(e){return Object.getPrototypeOf(e)===Object.prototype&&Object.keys(e).length}function Kn(e){return typeof e>"u"}function Vn(e,t){return!(!t||!Kn(e))||"string"==typeof e&&!!e.trim().length}function Bn(e,t){return!(!t||!Kn(e))||"number"==typeof e&&!isNaN(e)}function Fn(e){return!(!Vn(e,!1)||!e.includes(":"))&&2===e.split(":").length}function Gn(e){let t=!0;return qn(e)?e.length&&(t=e.every((e=>Vn(e,!1)))):t=!1,t}function Wn(e,t,r){let n=null;return Object.entries(e).forEach((([e,i])=>{if(n)return;const s=function(e,t,r){let n=null;return qn(t)&&t.length?t.forEach((e=>{n||Fn(e)||(n=$n("UNSUPPORTED_CHAINS",`${r}, chain ${e} should be a string and conform to "namespace:chainId" format`))})):Fn(e)||(n=$n("UNSUPPORTED_CHAINS",`${r}, chains must be defined as "namespace:chainId" e.g. "eip155:1": {...} in the namespace key OR as an array of CAIP-2 chainIds e.g. eip155: { chains: ["eip155:1", "eip155:5"] }`)),n}(e,jr(e,i),`${t} ${r}`);s&&(n=s)})),n}function Yn(e,t){let r=null;return qn(e)?e.forEach((e=>{r||function(e){if(Vn(e,!1)&&e.includes(":")){const t=e.split(":");if(3===t.length){const e=t[0]+":"+t[1];return!!t[2]&&Fn(e)}}return!1}(e)||(r=$n("UNSUPPORTED_ACCOUNTS",`${t}, account ${e} should be a string and conform to "namespace:chainId:address" format`))})):r=$n("UNSUPPORTED_ACCOUNTS",`${t}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),r}function Jn(e,t){let r=null;return Object.values(e).forEach((e=>{if(r)return;const n=function(e,t){let r=null;return Gn(e?.methods)?Gn(e?.events)||(r=$n("UNSUPPORTED_EVENTS",`${t}, events should be an array of strings or empty array for no events`)):r=$n("UNSUPPORTED_METHODS",`${t}, methods should be an array of strings or empty array for no methods`),r}(e,`${t}, namespace`);n&&(r=n)})),r}function Xn(e,t){let r=null;if(e&&Hn(e)){const n=Jn(e,t);n&&(r=n);const i=function(e,t){let r=null;return Object.values(e).forEach((e=>{if(r)return;const n=Yn(e?.accounts,`${t} namespace`);n&&(r=n)})),r}(e,t);i&&(r=i)}else r=zn("MISSING_OR_INVALID",`${t}, namespaces should be an object with data`);return r}function Zn(e){return Vn(e.protocol,!0)}function Qn(e){return typeof e<"u"&&null!==typeof e}function ei(e,t){return!(!Fn(t)||!function(e){const t=[];return Object.values(e).forEach((e=>{t.push(...Ln(e.accounts))})),t}(e).includes(t))}function ti(e,t,r){return!!Vn(r,!1)&&function(e,t){const r=[];return Object.values(e).forEach((e=>{Ln(e.accounts).includes(t)&&r.push(...e.methods)})),r}(e,t).includes(r)}function ri(e,t,r){return!!Vn(r,!1)&&function(e,t){const r=[];return Object.values(e).forEach((e=>{Ln(e.accounts).includes(t)&&r.push(...e.events)})),r}(e,t).includes(r)}function ni(e,t,r){let n=null;const i=function(e){const t={};return Object.keys(e).forEach((r=>{var n;r.includes(":")?t[r]=e[r]:null==(n=e[r].chains)||n.forEach((n=>{t[n]={methods:e[r].methods,events:e[r].events}}))})),t}(e),s=function(e){const t={};return Object.keys(e).forEach((r=>{if(r.includes(":"))t[r]=e[r];else{const n=Ln(e[r].accounts);n?.forEach((n=>{t[n]={accounts:e[r].accounts.filter((e=>e.includes(`${n}:`))),methods:e[r].methods,events:e[r].events}}))}})),t}(t),o=Object.keys(i),a=Object.keys(s),c=ii(Object.keys(e)),u=ii(Object.keys(t)),h=c.filter((e=>!u.includes(e)));return h.length&&(n=zn("NON_CONFORMING_NAMESPACES",`${r} namespaces keys don't satisfy requiredNamespaces.\n Required: ${h.toString()}\n Received: ${Object.keys(t).toString()}`)),pn(o,a)||(n=zn("NON_CONFORMING_NAMESPACES",`${r} namespaces chains don't satisfy required namespaces.\n Required: ${o.toString()}\n Approved: ${a.toString()}`)),Object.keys(t).forEach((e=>{if(!e.includes(":")||n)return;const i=Ln(t[e].accounts);i.includes(e)||(n=zn("NON_CONFORMING_NAMESPACES",`${r} namespaces accounts don't satisfy namespace accounts for ${e}\n Required: ${e}\n Approved: ${i.toString()}`))})),o.forEach((e=>{n||(pn(i[e].methods,s[e].methods)?pn(i[e].events,s[e].events)||(n=zn("NON_CONFORMING_NAMESPACES",`${r} namespaces events don't satisfy namespace events for ${e}`)):n=zn("NON_CONFORMING_NAMESPACES",`${r} namespaces methods don't satisfy namespace methods for ${e}`))})),n}function ii(e){return[...new Set(e.map((e=>e.includes(":")?e.split(":")[0]:e)))]}var si={},oi={};Object.defineProperty(oi,"__esModule",{value:!0}),oi.safeJsonParse=function(e){if("string"!=typeof e)throw new Error("Cannot safe json parse value of type "+typeof e);try{return JSON.parse(e)}catch(t){return e}},oi.safeJsonStringify=function(e){return"string"==typeof e?e:JSON.stringify(e,((e,t)=>void 0===t?null:t))};var ai,ci={exports:{}};var ui,hi={},li={};var fi,pi,di={};Object.defineProperty(si,"__esModule",{value:!0}),si.KeyValueStorage=void 0;const gi=Ft,yi=oi,vi=gi.__importDefault((ai||(ai=1,function(){let e;function t(){}e=t,e.prototype.getItem=function(e){return this.hasOwnProperty(e)?String(this[e]):null},e.prototype.setItem=function(e,t){this[e]=String(t)},e.prototype.removeItem=function(e){delete this[e]},e.prototype.clear=function(){const e=this;Object.keys(e).forEach((function(t){e[t]=void 0,delete e[t]}))},e.prototype.key=function(e){return e=e||0,Object.keys(this)[e]},e.prototype.__defineGetter__("length",(function(){return Object.keys(this).length})),void 0!==r.commonjsGlobal&&r.commonjsGlobal.localStorage?ci.exports=r.commonjsGlobal.localStorage:"undefined"!=typeof window&&window.localStorage?ci.exports=window.localStorage:ci.exports=new t}()),ci.exports)),_i=(pi||(pi=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});const t=Ft;t.__exportStar((ui||(ui=1,Object.defineProperty(li,"__esModule",{value:!0}),li.IKeyValueStorage=void 0,li.IKeyValueStorage=class{}),li),e),t.__exportStar(function(){if(fi)return di;fi=1,Object.defineProperty(di,"__esModule",{value:!0}),di.parseEntry=void 0;const e=oi;return di.parseEntry=function(t){var r;return[t[0],e.safeJsonParse(null!==(r=t[1])&&void 0!==r?r:"")]},di}(),e)}(hi)),hi);class mi{constructor(){this.localStorage=vi.default}getKeys(){return gi.__awaiter(this,void 0,void 0,(function*(){return Object.keys(this.localStorage)}))}getEntries(){return gi.__awaiter(this,void 0,void 0,(function*(){return Object.entries(this.localStorage).map(_i.parseEntry)}))}getItem(e){return gi.__awaiter(this,void 0,void 0,(function*(){const t=this.localStorage.getItem(e);if(null!==t)return yi.safeJsonParse(t)}))}setItem(e,t){return gi.__awaiter(this,void 0,void 0,(function*(){this.localStorage.setItem(e,yi.safeJsonStringify(t))}))}removeItem(e){return gi.__awaiter(this,void 0,void 0,(function*(){this.localStorage.removeItem(e)}))}}si.KeyValueStorage=mi;var wi=si.default=mi,bi={},Ei={},Si={},Ii={};class Oi{}var Pi,Ni,Ai=Object.freeze({__proto__:null,IEvents:Oi}),xi=r.getAugmentedNamespace(Ai);function Ci(){return Ni||(Ni=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});Ft.__exportStar(function(){if(Pi)return Ii;Pi=1,Object.defineProperty(Ii,"__esModule",{value:!0}),Ii.IHeartBeat=void 0;const e=xi;class t extends e.IEvents{constructor(e){super()}}return Ii.IHeartBeat=t,Ii}(),e)}(Si)),Si}var Ti,Ri,ji,Li={},Ui={};function Mi(){return Ri||(Ri=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});Ft.__exportStar(function(){if(Ti)return Ui;Ti=1,Object.defineProperty(Ui,"__esModule",{value:!0}),Ui.HEARTBEAT_EVENTS=Ui.HEARTBEAT_INTERVAL=void 0;const e=Mt;return Ui.HEARTBEAT_INTERVAL=e.FIVE_SECONDS,Ui.HEARTBEAT_EVENTS={pulse:"heartbeat_pulse"},Ui}(),e)}(Li)),Li}!function(e){Object.defineProperty(e,"__esModule",{value:!0});const t=Ft;t.__exportStar(function(){if(ji)return Ei;ji=1,Object.defineProperty(Ei,"__esModule",{value:!0}),Ei.HeartBeat=void 0;const e=Ft,t=i.default,r=Mt,n=Ci(),s=Mi();class o extends n.IHeartBeat{constructor(e){super(e),this.events=new t.EventEmitter,this.interval=s.HEARTBEAT_INTERVAL,this.interval=(null==e?void 0:e.interval)||s.HEARTBEAT_INTERVAL}static init(t){return e.__awaiter(this,void 0,void 0,(function*(){const e=new o(t);return yield e.init(),e}))}init(){return e.__awaiter(this,void 0,void 0,(function*(){yield this.initialize()}))}stop(){clearInterval(this.intervalRef)}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}initialize(){return e.__awaiter(this,void 0,void 0,(function*(){this.intervalRef=setInterval((()=>this.pulse()),r.toMiliseconds(this.interval))}))}pulse(){this.events.emit(s.HEARTBEAT_EVENTS.pulse)}}return Ei.HeartBeat=o,Ei}(),e),t.__exportStar(Ci(),e),t.__exportStar(Mi(),e)}(bi);var Di,ki,zi,$i,qi={};function Hi(){if($i)return zi;$i=1;const e=function(){if(ki)return Di;function e(e){try{return JSON.stringify(e)}catch(e){return'"[Circular]"'}}return ki=1,Di=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<s;a++)o[a]=i(r[a]);return o.join(" ")}if("string"!=typeof t)return t;var c=r.length;if(0===c)return t;for(var u="",h=0,l=-1,f=t&&t.length||0,p=0;p<f;){if(37===t.charCodeAt(p)&&p+1<f){switch(l=l>-1?l:0,t.charCodeAt(p+1)){case 100:case 102:if(h>=c)break;if(null==r[h])break;l<p&&(u+=t.slice(l,p)),u+=Number(r[h]),l=p+2,p++;break;case 105:if(h>=c)break;if(null==r[h])break;l<p&&(u+=t.slice(l,p)),u+=Math.floor(Number(r[h])),l=p+2,p++;break;case 79:case 111:case 106:if(h>=c)break;if(void 0===r[h])break;l<p&&(u+=t.slice(l,p));var d=typeof r[h];if("string"===d){u+="'"+r[h]+"'",l=p+2,p++;break}if("function"===d){u+=r[h].name||"<anonymous>",l=p+2,p++;break}u+=i(r[h]),l=p+2,p++;break;case 115:if(h>=c)break;l<p&&(u+=t.slice(l,p)),u+=String(r[h]),l=p+2,p++;break;case 37:l<p&&(u+=t.slice(l,p)),u+="%",l=p+2,p++,h--}++h}++p}return-1===l?t:(l<f&&(u+=t.slice(l)),u)},Di}();zi=n;const t=function(){function e(e){return void 0!==e&&e}try{return"undefined"!=typeof globalThis||Object.defineProperty(Object.prototype,"globalThis",{get:function(){return delete Object.prototype.globalThis,this.globalThis=this},configurable:!0}),globalThis}catch(t){return e(self)||e(window)||e(this)||{}}}().console||{},r={mapHttpRequest:u,mapHttpResponse:u,wrapRequestSerializer:h,wrapResponseSerializer:h,wrapErrorSerializer:h,req:u,res:u,err:function(e){const t={type:e.constructor.name,msg:e.message,stack:e.stack};for(const r in e)void 0===t[r]&&(t[r]=e[r]);return t}};function n(e){(e=e||{}).browser=e.browser||{};const r=e.browser.transmit;if(r&&"function"!=typeof r.send)throw Error("pino: transmit option must have a send function");const u=e.browser.write||t;e.browser.write&&(e.browser.asObject=!0);const h=e.serializers||{},f=function(e,t){if(Array.isArray(e)){const t=e.filter((function(e){return"!stdSerializers.err"!==e}));return t}return!0===e&&Object.keys(t)}(e.browser.serialize,h);let p=e.browser.serialize;Array.isArray(e.browser.serialize)&&e.browser.serialize.indexOf("!stdSerializers.err")>-1&&(p=!1);"function"==typeof u&&(u.error=u.fatal=u.warn=u.info=u.debug=u.trace=u),!1===e.enabled&&(e.level="silent");const d=e.level||"info",g=Object.create(u);g.log||(g.log=l),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(e){if("silent"!==e&&!this.levels.values[e])throw Error("unknown level "+e);this._level=e,i(y,g,"error","log"),i(y,g,"fatal","error"),i(y,g,"warn","error"),i(y,g,"info","log"),i(y,g,"debug","log"),i(y,g,"trace","log")}});const y={transmit:r,serialize:f,asObject:e.browser.asObject,levels:["error","fatal","warn","info","debug","trace"],timestamp:c(e)};return g.levels=n.levels,g.level=d,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=l,g.serializers=h,g._serialize=f,g._stdErrSerialize=p,g.child=function(t,n){if(!t)throw new Error("missing bindings for child Pino");n=n||{},f&&t.serializers&&(n.serializers=t.serializers);const i=n.serializers;if(f&&i){var c=Object.assign({},h,i),u=!0===e.browser.serialize?Object.keys(c):f;delete t.serializers,s([t],u,c,this._stdErrSerialize)}function l(e){this._childLevel=1+(0|e._childLevel),this.error=o(e,t,"error"),this.fatal=o(e,t,"fatal"),this.warn=o(e,t,"warn"),this.info=o(e,t,"info"),this.debug=o(e,t,"debug"),this.trace=o(e,t,"trace"),c&&(this.serializers=c,this._serialize=u),r&&(this._logEvent=a([].concat(e._logEvent.bindings,t)))}return l.prototype=this,new l(this)},r&&(g._logEvent=a()),g}function i(r,i,o,c){const u=Object.getPrototypeOf(i);i[o]=i.levelVal>i.levels.values[o]?l:u[o]?u[o]:t[o]||t[c]||l,function(r,i,o){if(!r.transmit&&i[o]===l)return;i[o]=(c=i[o],function(){const u=r.timestamp(),h=new Array(arguments.length),l=Object.getPrototypeOf&&Object.getPrototypeOf(this)===t?t:this;for(var f=0;f<h.length;f++)h[f]=arguments[f];if(r.serialize&&!r.asObject&&s(h,this._serialize,this.serializers,this._stdErrSerialize),r.asObject?c.call(l,function(t,r,i,o){t._serialize&&s(i,t._serialize,t.serializers,t._stdErrSerialize);const a=i.slice();let c=a[0];const u={};o&&(u.time=o),u.level=n.levels.values[r];let h=1+(0|t._childLevel);if(h<1&&(h=1),null!==c&&"object"==typeof c){for(;h--&&"object"==typeof a[0];)Object.assign(u,a.shift());c=a.length?e(a.shift(),a):void 0}else"string"==typeof c&&(c=e(a.shift(),a));return void 0!==c&&(u.msg=c),u}(this,o,h,u)):c.apply(l,h),r.transmit){const e=r.transmit.level||i.level,t=n.levels.values[e],c=n.levels.values[o];if(c<t)return;!function(e,t,r){const n=t.send,i=t.ts,o=t.methodLevel,c=t.methodValue,u=t.val,h=e._logEvent.bindings;s(r,e._serialize||Object.keys(e.serializers),e.serializers,void 0===e._stdErrSerialize||e._stdErrSerialize),e._logEvent.ts=i,e._logEvent.messages=r.filter((function(e){return-1===h.indexOf(e)})),e._logEvent.level.label=o,e._logEvent.level.value=c,n(o,e._logEvent,u),e._logEvent=a(h)}(this,{ts:u,methodLevel:o,methodValue:c,transmitLevel:e,transmitValue:n.levels.values[r.transmit.level||i.level],send:r.transmit.send,val:i.levelVal},h)}});var c}(r,i,o)}function s(e,t,r,i){for(const s in e)if(i&&e[s]instanceof Error)e[s]=n.stdSerializers.err(e[s]);else if("object"==typeof e[s]&&!Array.isArray(e[s]))for(const n in e[s])t&&t.indexOf(n)>-1&&n in r&&(e[s][n]=r[n](e[s][n]))}function o(e,t,r){return function(){const n=new Array(1+arguments.length);n[0]=t;for(var i=1;i<n.length;i++)n[i]=arguments[i-1];return e[r].apply(this,n)}}function a(e){return{ts:0,messages:[],bindings:e||[],level:{label:"",value:0}}}function c(e){return"function"==typeof e.timestamp?e.timestamp:!1===e.timestamp?f:p}function u(){return{}}function h(e){return e}function l(){}function f(){return!1}function p(){return Date.now()}return n.levels={values:{fatal:60,error:50,warn:40,info:30,debug:20,trace:10},labels:{10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"}},n.stdSerializers=r,n.stdTimeFunctions=Object.assign({},{nullTime:f,epochTime:p,unixTime:function(){return Math.round(Date.now()/1e3)},isoTime:function(){return new Date(Date.now()).toISOString()}}),zi}var Ki,Vi={};function Bi(){return Ki||(Ki=1,Object.defineProperty(Vi,"__esModule",{value:!0}),Vi.PINO_CUSTOM_CONTEXT_KEY=Vi.PINO_LOGGER_DEFAULTS=void 0,Vi.PINO_LOGGER_DEFAULTS={level:"info"},Vi.PINO_CUSTOM_CONTEXT_KEY="custom_context"),Vi}var Fi,Gi={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.pino=void 0;const t=Ft,r=t.__importDefault(Hi());Object.defineProperty(e,"pino",{enumerable:!0,get:function(){return r.default}}),t.__exportStar(Bi(),e),t.__exportStar(function(){if(Fi)return Gi;Fi=1,Object.defineProperty(Gi,"__esModule",{value:!0}),Gi.generateChildLogger=Gi.formatChildLoggerContext=Gi.getLoggerContext=Gi.setBrowserLoggerContext=Gi.getBrowserLoggerContext=Gi.getDefaultLoggerOptions=void 0;const e=Bi();function t(t,r=e.PINO_CUSTOM_CONTEXT_KEY){return t[r]||""}function r(t,r,n=e.PINO_CUSTOM_CONTEXT_KEY){return t[n]=r,t}function n(r,n=e.PINO_CUSTOM_CONTEXT_KEY){let i="";return i=void 0===r.bindings?t(r,n):r.bindings().context||"",i}function i(t,r,i=e.PINO_CUSTOM_CONTEXT_KEY){const s=n(t,i);return s.trim()?`${s}/${r}`:r}return Gi.getDefaultLoggerOptions=function(t){return Object.assign(Object.assign({},t),{level:(null==t?void 0:t.level)||e.PINO_LOGGER_DEFAULTS.level})},Gi.getBrowserLoggerContext=t,Gi.setBrowserLoggerContext=r,Gi.getLoggerContext=n,Gi.formatChildLoggerContext=i,Gi.generateChildLogger=function(t,n,s=e.PINO_CUSTOM_CONTEXT_KEY){const o=i(t,n,s);return r(t.child({context:o}),o,s)},Gi}(),e)}(qi);class Wi extends Oi{constructor(e){super(),this.opts=e,this.protocol="wc",this.version=2}}class Yi extends Oi{constructor(e,t){super(),this.core=e,this.logger=t,this.records=new Map}}class Ji{constructor(e,t){this.logger=e,this.core=t}}class Xi extends Oi{constructor(e,t){super(),this.relayer=e,this.logger=t}}class Zi extends Oi{constructor(e){super()}}class Qi{constructor(e,t,r,n){this.core=e,this.logger=t,this.name=r}}class es extends Oi{constructor(e,t){super(),this.relayer=e,this.logger=t}}class ts extends Oi{constructor(e,t){super(),this.core=e,this.logger=t}}class rs{constructor(e,t){this.projectId=e,this.logger=t}}class ns{constructor(e){this.opts=e,this.protocol="wc",this.version=2}}class is{constructor(e){this.client=e}}const ss=e=>JSON.stringify(e,((e,t)=>"bigint"==typeof t?t.toString()+"n":t));function os(e){if("string"!=typeof e)throw new Error("Cannot safe json parse value of type "+typeof e);try{return(e=>{const t=e.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(t,((e,t)=>"string"==typeof t&&t.match(/^\d+n$/)?BigInt(t.substring(0,t.length-1)):t))})(e)}catch(t){return e}}function as(e){return"string"==typeof e?e:ss(e)||""}var cs={},us={};!function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=a,r=w;e.DIGEST_LENGTH=64,e.BLOCK_SIZE=128;var n=function(){function n(){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 n.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},n.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},n.prototype.clean=function(){r.wipe(this._buffer),r.wipe(this._tempHi),r.wipe(this._tempLo),this.reset()},n.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._bufferLength<e.BLOCK_SIZE&&r>0;)this._buffer[this._bufferLength++]=t[n++],r--;this._bufferLength===this.blockSize&&(s(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,this.blockSize),this._bufferLength=0)}for(r>=this.blockSize&&(n=s(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},n.prototype.finish=function(e){if(!this._finished){var r=this._bytesHashed,n=this._bufferLength,i=r/536870912|0,o=r<<3,a=r%128<112?128:256;this._buffer[n]=128;for(var c=n+1;c<a-8;c++)this._buffer[c]=0;t.writeUint32BE(i,this._buffer,a-8),t.writeUint32BE(o,this._buffer,a-4),s(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,a),this._finished=!0}for(c=0;c<this.digestLength/8;c++)t.writeUint32BE(this._stateHi[c],e,8*c),t.writeUint32BE(this._stateLo[c],e,8*c+4);return this},n.prototype.digest=function(){var e=new Uint8Array(this.digestLength);return this.finish(e),e},n.prototype.saveState=function(){if(this._finished)throw new Error("SHA256: cannot save finished state");return{stateHi:new Int32Array(this._stateHi),stateLo:new Int32Array(this._stateLo),buffer:this._bufferLength>0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},n.prototype.restoreState=function(e){return this._stateHi.set(e.stateHi),this._stateLo.set(e.stateLo),this._bufferLength=e.bufferLength,e.buffer&&this._buffer.set(e.buffer),this._bytesHashed=e.bytesHashed,this._finished=!1,this},n.prototype.cleanSavedState=function(e){r.wipe(e.stateHi),r.wipe(e.stateLo),e.buffer&&r.wipe(e.buffer),e.bufferLength=0,e.bytesHashed=0},n}();e.SHA512=n;var i=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 s(e,r,n,s,o,a,c){for(var u,h,l,f,p,d,g,y,v=n[0],_=n[1],m=n[2],w=n[3],b=n[4],E=n[5],S=n[6],I=n[7],O=s[0],P=s[1],N=s[2],A=s[3],x=s[4],C=s[5],T=s[6],R=s[7];c>=128;){for(var j=0;j<16;j++){var L=8*j+a;e[j]=t.readUint32BE(o,L),r[j]=t.readUint32BE(o,L+4)}for(j=0;j<80;j++){var U,M,D=v,k=_,z=m,$=w,q=b,H=E,K=S,V=O,B=P,F=N,G=A,W=x,Y=C,J=T;if(p=65535&(h=R),d=h>>>16,g=65535&(u=I),y=u>>>16,p+=65535&(h=(x>>>14|b<<18)^(x>>>18|b<<14)^(b>>>9|x<<23)),d+=h>>>16,g+=65535&(u=(b>>>14|x<<18)^(b>>>18|x<<14)^(x>>>9|b<<23)),y+=u>>>16,p+=65535&(h=x&C^~x&T),d+=h>>>16,g+=65535&(u=b&E^~b&S),y+=u>>>16,u=i[2*j],p+=65535&(h=i[2*j+1]),d+=h>>>16,g+=65535&u,y+=u>>>16,u=e[j%16],d+=(h=r[j%16])>>>16,g+=65535&u,y+=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|(y+=g>>>16)<<16),y=u>>>16,p+=65535&(h=(O>>>28|v<<4)^(v>>>2|O<<30)^(v>>>7|O<<25)),d+=h>>>16,g+=65535&(u=(v>>>28|O<<4)^(O>>>2|v<<30)^(O>>>7|v<<25)),y+=u>>>16,d+=(h=O&P^O&N^P&N)>>>16,g+=65535&(u=v&_^v&m^_&m),y+=u>>>16,U=65535&(g+=(d+=(p+=65535&h)>>>16)>>>16)|(y+=g>>>16)<<16,M=65535&p|d<<16,p=65535&(h=G),d=h>>>16,g=65535&(u=$),y=u>>>16,d+=(h=f)>>>16,g+=65535&(u=l),y+=u>>>16,_=D,m=k,w=z,b=$=65535&(g+=(d+=(p+=65535&h)>>>16)>>>16)|(y+=g>>>16)<<16,E=q,S=H,I=K,v=U,P=V,N=B,A=F,x=G=65535&p|d<<16,C=W,T=Y,R=J,O=M,j%16==15)for(L=0;L<16;L++)u=e[L],p=65535&(h=r[L]),d=h>>>16,g=65535&u,y=u>>>16,u=e[(L+9)%16],p+=65535&(h=r[(L+9)%16]),d+=h>>>16,g+=65535&u,y+=u>>>16,l=e[(L+1)%16],p+=65535&(h=((f=r[(L+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),y+=u>>>16,l=e[(L+14)%16],d+=(h=((f=r[(L+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),y+=u>>>16,y+=(g+=(d+=(p+=65535&h)>>>16)>>>16)>>>16,e[L]=65535&g|y<<16,r[L]=65535&p|d<<16}p=65535&(h=O),d=h>>>16,g=65535&(u=v),y=u>>>16,u=n[0],d+=(h=s[0])>>>16,g+=65535&u,y+=u>>>16,y+=(g+=(d+=(p+=65535&h)>>>16)>>>16)>>>16,n[0]=v=65535&g|y<<16,s[0]=O=65535&p|d<<16,p=65535&(h=P),d=h>>>16,g=65535&(u=_),y=u>>>16,u=n[1],d+=(h=s[1])>>>16,g+=65535&u,y+=u>>>16,y+=(g+=(d+=(p+=65535&h)>>>16)>>>16)>>>16,n[1]=_=65535&g|y<<16,s[1]=P=65535&p|d<<16,p=65535&(h=N),d=h>>>16,g=65535&(u=m),y=u>>>16,u=n[2],d+=(h=s[2])>>>16,g+=65535&u,y+=u>>>16,y+=(g+=(d+=(p+=65535&h)>>>16)>>>16)>>>16,n[2]=m=65535&g|y<<16,s[2]=N=65535&p|d<<16,p=65535&(h=A),d=h>>>16,g=65535&(u=w),y=u>>>16,u=n[3],d+=(h=s[3])>>>16,g+=65535&u,y+=u>>>16,y+=(g+=(d+=(p+=65535&h)>>>16)>>>16)>>>16,n[3]=w=65535&g|y<<16,s[3]=A=65535&p|d<<16,p=65535&(h=x),d=h>>>16,g=65535&(u=b),y=u>>>16,u=n[4],d+=(h=s[4])>>>16,g+=65535&u,y+=u>>>16,y+=(g+=(d+=(p+=65535&h)>>>16)>>>16)>>>16,n[4]=b=65535&g|y<<16,s[4]=x=65535&p|d<<16,p=65535&(h=C),d=h>>>16,g=65535&(u=E),y=u>>>16,u=n[5],d+=(h=s[5])>>>16,g+=65535&u,y+=u>>>16,y+=(g+=(d+=(p+=65535&h)>>>16)>>>16)>>>16,n[5]=E=65535&g|y<<16,s[5]=C=65535&p|d<<16,p=65535&(h=T),d=h>>>16,g=65535&(u=S),y=u>>>16,u=n[6],d+=(h=s[6])>>>16,g+=65535&u,y+=u>>>16,y+=(g+=(d+=(p+=65535&h)>>>16)>>>16)>>>16,n[6]=S=65535&g|y<<16,s[6]=T=65535&p|d<<16,p=65535&(h=R),d=h>>>16,g=65535&(u=I),y=u>>>16,u=n[7],d+=(h=s[7])>>>16,g+=65535&u,y+=u>>>16,y+=(g+=(d+=(p+=65535&h)>>>16)>>>16)>>>16,n[7]=I=65535&g|y<<16,s[7]=R=65535&p|d<<16,a+=128,c-=128}return a}e.hash=function(e){var t=new n;t.update(e);var r=t.digest();return t.clean(),r}}(us),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.convertSecretKeyToX25519=e.convertPublicKeyToX25519=e.verify=e.sign=e.extractPublicKeyFromSecretKey=e.generateKeyPair=e.generateKeyPairFromSeed=e.SEED_LENGTH=e.SECRET_KEY_LENGTH=e.PUBLIC_KEY_LENGTH=e.SIGNATURE_LENGTH=void 0;const t=q,r=us,n=w;function i(e){const t=new Float64Array(16);if(e)for(let r=0;r<e.length;r++)t[r]=e[r];return t}e.SIGNATURE_LENGTH=64,e.PUBLIC_KEY_LENGTH=32,e.SECRET_KEY_LENGTH=64,e.SEED_LENGTH=32;new Uint8Array(32)[0]=9;const s=i(),o=i([1]),a=i([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),c=i([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),u=i([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),h=i([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),l=i([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function f(e,t){for(let r=0;r<16;r++)e[r]=0|t[r]}function p(e){let t=1;for(let r=0;r<16;r++){let n=e[r]+t+65535;t=Math.floor(n/65536),e[r]=n-65536*t}e[0]+=t-1+37*(t-1)}function d(e,t,r){const n=~(r-1);for(let r=0;r<16;r++){const i=n&(e[r]^t[r]);e[r]^=i,t[r]^=i}}function g(e,t){const r=i(),n=i();for(let e=0;e<16;e++)n[e]=t[e];p(n),p(n),p(n);for(let e=0;e<2;e++){r[0]=n[0]-65517;for(let e=1;e<15;e++)r[e]=n[e]-65535-(r[e-1]>>16&1),r[e-1]&=65535;r[15]=n[15]-32767-(r[14]>>16&1);const e=r[15]>>16&1;r[14]&=65535,d(n,r,1-e)}for(let t=0;t<16;t++)e[2*t]=255&n[t],e[2*t+1]=n[t]>>8}function y(e,t){let r=0;for(let n=0;n<32;n++)r|=e[n]^t[n];return(1&r-1>>>8)-1}function v(e,t){const r=new Uint8Array(32),n=new Uint8Array(32);return g(r,e),g(n,t),y(r,n)}function _(e){const t=new Uint8Array(32);return g(t,e),1&t[0]}function m(e,t,r){for(let n=0;n<16;n++)e[n]=t[n]+r[n]}function b(e,t,r){for(let n=0;n<16;n++)e[n]=t[n]-r[n]}function E(e,t,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,y=0,v=0,_=0,m=0,w=0,b=0,E=0,S=0,I=0,O=0,P=0,N=0,A=0,x=0,C=0,T=0,R=0,j=0,L=0,U=0,M=r[0],D=r[1],k=r[2],z=r[3],$=r[4],q=r[5],H=r[6],K=r[7],V=r[8],B=r[9],F=r[10],G=r[11],W=r[12],Y=r[13],J=r[14],X=r[15];n=t[0],s+=n*M,o+=n*D,a+=n*k,c+=n*z,u+=n*$,h+=n*q,l+=n*H,f+=n*K,p+=n*V,d+=n*B,g+=n*F,y+=n*G,v+=n*W,_+=n*Y,m+=n*J,w+=n*X,n=t[1],o+=n*M,a+=n*D,c+=n*k,u+=n*z,h+=n*$,l+=n*q,f+=n*H,p+=n*K,d+=n*V,g+=n*B,y+=n*F,v+=n*G,_+=n*W,m+=n*Y,w+=n*J,b+=n*X,n=t[2],a+=n*M,c+=n*D,u+=n*k,h+=n*z,l+=n*$,f+=n*q,p+=n*H,d+=n*K,g+=n*V,y+=n*B,v+=n*F,_+=n*G,m+=n*W,w+=n*Y,b+=n*J,E+=n*X,n=t[3],c+=n*M,u+=n*D,h+=n*k,l+=n*z,f+=n*$,p+=n*q,d+=n*H,g+=n*K,y+=n*V,v+=n*B,_+=n*F,m+=n*G,w+=n*W,b+=n*Y,E+=n*J,S+=n*X,n=t[4],u+=n*M,h+=n*D,l+=n*k,f+=n*z,p+=n*$,d+=n*q,g+=n*H,y+=n*K,v+=n*V,_+=n*B,m+=n*F,w+=n*G,b+=n*W,E+=n*Y,S+=n*J,I+=n*X,n=t[5],h+=n*M,l+=n*D,f+=n*k,p+=n*z,d+=n*$,g+=n*q,y+=n*H,v+=n*K,_+=n*V,m+=n*B,w+=n*F,b+=n*G,E+=n*W,S+=n*Y,I+=n*J,O+=n*X,n=t[6],l+=n*M,f+=n*D,p+=n*k,d+=n*z,g+=n*$,y+=n*q,v+=n*H,_+=n*K,m+=n*V,w+=n*B,b+=n*F,E+=n*G,S+=n*W,I+=n*Y,O+=n*J,P+=n*X,n=t[7],f+=n*M,p+=n*D,d+=n*k,g+=n*z,y+=n*$,v+=n*q,_+=n*H,m+=n*K,w+=n*V,b+=n*B,E+=n*F,S+=n*G,I+=n*W,O+=n*Y,P+=n*J,N+=n*X,n=t[8],p+=n*M,d+=n*D,g+=n*k,y+=n*z,v+=n*$,_+=n*q,m+=n*H,w+=n*K,b+=n*V,E+=n*B,S+=n*F,I+=n*G,O+=n*W,P+=n*Y,N+=n*J,A+=n*X,n=t[9],d+=n*M,g+=n*D,y+=n*k,v+=n*z,_+=n*$,m+=n*q,w+=n*H,b+=n*K,E+=n*V,S+=n*B,I+=n*F,O+=n*G,P+=n*W,N+=n*Y,A+=n*J,x+=n*X,n=t[10],g+=n*M,y+=n*D,v+=n*k,_+=n*z,m+=n*$,w+=n*q,b+=n*H,E+=n*K,S+=n*V,I+=n*B,O+=n*F,P+=n*G,N+=n*W,A+=n*Y,x+=n*J,C+=n*X,n=t[11],y+=n*M,v+=n*D,_+=n*k,m+=n*z,w+=n*$,b+=n*q,E+=n*H,S+=n*K,I+=n*V,O+=n*B,P+=n*F,N+=n*G,A+=n*W,x+=n*Y,C+=n*J,T+=n*X,n=t[12],v+=n*M,_+=n*D,m+=n*k,w+=n*z,b+=n*$,E+=n*q,S+=n*H,I+=n*K,O+=n*V,P+=n*B,N+=n*F,A+=n*G,x+=n*W,C+=n*Y,T+=n*J,R+=n*X,n=t[13],_+=n*M,m+=n*D,w+=n*k,b+=n*z,E+=n*$,S+=n*q,I+=n*H,O+=n*K,P+=n*V,N+=n*B,A+=n*F,x+=n*G,C+=n*W,T+=n*Y,R+=n*J,j+=n*X,n=t[14],m+=n*M,w+=n*D,b+=n*k,E+=n*z,S+=n*$,I+=n*q,O+=n*H,P+=n*K,N+=n*V,A+=n*B,x+=n*F,C+=n*G,T+=n*W,R+=n*Y,j+=n*J,L+=n*X,n=t[15],w+=n*M,b+=n*D,E+=n*k,S+=n*z,I+=n*$,O+=n*q,P+=n*H,N+=n*K,A+=n*V,x+=n*B,C+=n*F,T+=n*G,R+=n*W,j+=n*Y,L+=n*J,U+=n*X,s+=38*b,o+=38*E,a+=38*S,c+=38*I,u+=38*O,h+=38*P,l+=38*N,f+=38*A,p+=38*x,d+=38*C,g+=38*T,y+=38*R,v+=38*j,_+=38*L,m+=38*U,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=y+i+65535,i=Math.floor(n/65536),y=n-65536*i,n=v+i+65535,i=Math.floor(n/65536),v=n-65536*i,n=_+i+65535,i=Math.floor(n/65536),_=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,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=y+i+65535,i=Math.floor(n/65536),y=n-65536*i,n=v+i+65535,i=Math.floor(n/65536),v=n-65536*i,n=_+i+65535,i=Math.floor(n/65536),_=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,s+=i-1+37*(i-1),e[0]=s,e[1]=o,e[2]=a,e[3]=c,e[4]=u,e[5]=h,e[6]=l,e[7]=f,e[8]=p,e[9]=d,e[10]=g,e[11]=y,e[12]=v,e[13]=_,e[14]=m,e[15]=w}function S(e,t){E(e,t,t)}function I(e,t){const r=i();let n;for(n=0;n<16;n++)r[n]=t[n];for(n=253;n>=0;n--)S(r,r),2!==n&&4!==n&&E(r,r,t);for(n=0;n<16;n++)e[n]=r[n]}function O(e,t){const r=i(),n=i(),s=i(),o=i(),a=i(),u=i(),h=i(),l=i(),f=i();b(r,e[1],e[0]),b(f,t[1],t[0]),E(r,r,f),m(n,e[0],e[1]),m(f,t[0],t[1]),E(n,n,f),E(s,e[3],t[3]),E(s,s,c),E(o,e[2],t[2]),m(o,o,o),b(a,n,r),b(u,o,s),m(h,o,s),m(l,n,r),E(e[0],a,u),E(e[1],l,h),E(e[2],h,u),E(e[3],a,l)}function P(e,t,r){for(let n=0;n<4;n++)d(e[n],t[n],r)}function N(e,t){const r=i(),n=i(),s=i();I(s,t[2]),E(r,t[0],s),E(n,t[1],s),g(e,n),e[31]^=_(r)<<7}function A(e,t,r){f(e[0],s),f(e[1],o),f(e[2],o),f(e[3],s);for(let n=255;n>=0;--n){const i=r[n/8|0]>>(7&n)&1;P(e,t,i),O(t,e),O(e,e),P(e,t,i)}}function x(e,t){const r=[i(),i(),i(),i()];f(r[0],u),f(r[1],h),f(r[2],o),E(r[3],u,h),A(e,r,t)}function C(t){if(t.length!==e.SEED_LENGTH)throw new Error(`ed25519: seed must be ${e.SEED_LENGTH} bytes`);const n=(0,r.hash)(t);n[0]&=248,n[31]&=127,n[31]|=64;const s=new Uint8Array(32),o=[i(),i(),i(),i()];x(o,n),N(s,o);const a=new Uint8Array(64);return a.set(t),a.set(s,32),{publicKey:s,secretKey:a}}e.generateKeyPairFromSeed=C,e.generateKeyPair=function(e){const r=(0,t.randomBytes)(32,e),i=C(r);return(0,n.wipe)(r),i},e.extractPublicKeyFromSecretKey=function(t){if(t.length!==e.SECRET_KEY_LENGTH)throw new Error(`ed25519: secret key must be ${e.SECRET_KEY_LENGTH} bytes`);return new Uint8Array(t.subarray(32))};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 R(e,t){let r,n,i,s;for(n=63;n>=32;--n){for(r=0,i=n-32,s=n-12;i<s;++i)t[i]+=r-16*t[n]*T[i-(n-32)],r=Math.floor((t[i]+128)/256),t[i]-=256*r;t[i]+=r,t[n]=0}for(r=0,i=0;i<32;i++)t[i]+=r-(t[31]>>4)*T[i],r=t[i]>>8,t[i]&=255;for(i=0;i<32;i++)t[i]-=r*T[i];for(n=0;n<32;n++)t[n+1]+=t[n]>>8,e[n]=255&t[n]}function j(e){const t=new Float64Array(64);for(let r=0;r<64;r++)t[r]=e[r];for(let t=0;t<64;t++)e[t]=0;R(e,t)}function L(e,t){const r=i(),n=i(),c=i(),u=i(),h=i(),p=i(),d=i();return f(e[2],o),function(e,t){for(let r=0;r<16;r++)e[r]=t[2*r]+(t[2*r+1]<<8);e[15]&=32767}(e[1],t),S(c,e[1]),E(u,c,a),b(c,c,e[2]),m(u,e[2],u),S(h,u),S(p,h),E(d,p,h),E(r,d,c),E(r,r,u),function(e,t){const r=i();let n;for(n=0;n<16;n++)r[n]=t[n];for(n=250;n>=0;n--)S(r,r),1!==n&&E(r,r,t);for(n=0;n<16;n++)e[n]=r[n]}(r,r),E(r,r,c),E(r,r,u),E(r,r,u),E(e[0],r,u),S(n,e[0]),E(n,n,u),v(n,c)&&E(e[0],e[0],l),S(n,e[0]),E(n,n,u),v(n,c)?-1:(_(e[0])===t[31]>>7&&b(e[0],s,e[0]),E(e[3],e[0],e[1]),0)}e.sign=function(e,t){const n=new Float64Array(64),s=[i(),i(),i(),i()],o=(0,r.hash)(e.subarray(0,32));o[0]&=248,o[31]&=127,o[31]|=64;const a=new Uint8Array(64);a.set(o.subarray(32),32);const c=new r.SHA512;c.update(a.subarray(32)),c.update(t);const u=c.digest();c.clean(),j(u),x(s,u),N(a,s),c.reset(),c.update(a.subarray(0,32)),c.update(e.subarray(32)),c.update(t);const h=c.digest();j(h);for(let e=0;e<32;e++)n[e]=u[e];for(let e=0;e<32;e++)for(let t=0;t<32;t++)n[e+t]+=h[e]*o[t];return R(a.subarray(32),n),a},e.verify=function(t,n,s){const o=new Uint8Array(32),a=[i(),i(),i(),i()],c=[i(),i(),i(),i()];if(s.length!==e.SIGNATURE_LENGTH)throw new Error(`ed25519: signature must be ${e.SIGNATURE_LENGTH} bytes`);if(L(c,t))return!1;const u=new r.SHA512;u.update(s.subarray(0,32)),u.update(t),u.update(n);const h=u.digest();return j(h),A(a,c,h),x(c,s.subarray(32)),O(a,c),N(o,a),!y(s,o)},e.convertPublicKeyToX25519=function(e){let t=[i(),i(),i(),i()];if(L(t,e))throw new Error("Ed25519: invalid public key");let r=i(),n=i(),s=t[1];m(r,o,s),b(n,o,s),I(n,n),E(r,r,n);let a=new Uint8Array(32);return g(a,r),a},e.convertSecretKeyToX25519=function(e){const t=(0,r.hash)(e.subarray(0,32));t[0]&=248,t[31]&=127,t[31]|=64;const i=new Uint8Array(t.subarray(0,32));return(0,n.wipe)(t),i}}(cs);const hs=".",ls="base64url",fs="utf8",ps="utf8",ds=":",gs="did",ys="key",vs="base58btc",_s="z",ms="K36";function ws(e){return St(Et(as(e),fs),ls)}function bs(e){const t=Et(ms,vs),r=_s+St(Z([t,e]),vs);return[gs,ys,r].join(ds)}function Es(e=q.randomBytes(32)){return cs.generateKeyPairFromSeed(e)}async function Ss(e,t,r,n,i=Mt.fromMiliseconds(Date.now())){const s={alg:"EdDSA",typ:"JWT"},o={iss:bs(n.publicKey),sub:e,aud:t,iat:i,exp:i+r},a=Et([ws((c={header:s,payload:o}).header),ws(c.payload)].join(hs),ps);var c;return function(e){return[ws(e.header),ws(e.payload),(t=e.signature,St(t,ls))].join(hs);var t}({header:s,payload:o,signature:cs.sign(n.secretKey,a)})}const Is="INTERNAL_ERROR",Os="SERVER_ERROR",Ps=[-32700,-32600,-32601,-32602,-32603],Ns={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"},[Is]:{code:-32603,message:"Internal error"},[Os]:{code:-32e3,message:"Server error"}},As=Os;function xs(e){return Object.keys(Ns).includes(e)?Ns[e]:Ns[As]}function Cs(e,t,r){return e.message.includes("getaddrinfo ENOTFOUND")||e.message.includes("connect ECONNREFUSED")?new Error(`Unavailable ${r} RPC url at ${t}`):e}var Ts,Rs={},js={};var Ls,Us={};function Ms(e=3){return Date.now()*Math.pow(10,e)+Math.floor(Math.random()*Math.pow(10,e))}function Ds(e=6){return BigInt(Ms(e))}function ks(e,t,r){return{id:r||Ms(),jsonrpc:"2.0",method:e,params:t}}function zs(e,t){return{id:e,jsonrpc:"2.0",result:t}}function $s(e,t,r){return{id:e,jsonrpc:"2.0",error:qs(t,r)}}function qs(e,t){return void 0===e?xs(Is):("string"==typeof e&&(e=Object.assign(Object.assign({},xs(Os)),{message:e})),void 0!==t&&(e.data=t),function(e){return Ps.includes(e)}(e.code)&&(e=function(e){const t=Object.values(Ns).find((t=>t.code===e));return t||Ns[As]}(e.code)),e)}!function(e){Object.defineProperty(e,"__esModule",{value:!0});const t=Ft;t.__exportStar(function(){if(Ts)return js;function e(){return(null===r.commonjsGlobal||void 0===r.commonjsGlobal?void 0:r.commonjsGlobal.crypto)||(null===r.commonjsGlobal||void 0===r.commonjsGlobal?void 0:r.commonjsGlobal.msCrypto)||{}}function t(){const t=e();return t.subtle||t.webkitSubtle}return Ts=1,Object.defineProperty(js,"__esModule",{value:!0}),js.isBrowserCryptoAvailable=js.getSubtleCrypto=js.getBrowerCrypto=void 0,js.getBrowerCrypto=e,js.getSubtleCrypto=t,js.isBrowserCryptoAvailable=function(){return!!e()&&!!t()},js}(),e),t.__exportStar(function(){if(Ls)return Us;function e(){return"undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"===navigator.product}function t(){return"undefined"!=typeof process&&void 0!==process.versions&&void 0!==process.versions.node}return Ls=1,Object.defineProperty(Us,"__esModule",{value:!0}),Us.isBrowser=Us.isNode=Us.isReactNative=void 0,Us.isReactNative=e,Us.isNode=t,Us.isBrowser=function(){return!e()&&!t()},Us}(),e)}(Rs);class Hs{}class Ks extends Hs{constructor(){super()}}class Vs extends Ks{constructor(e){super()}}function Bs(e,t){const r=function(e){const t=e.match(new RegExp(/^\w+:/,"gi"));if(t&&t.length)return t[0]}(e);return void 0!==r&&new RegExp(t).test(r)}function Fs(e){return Bs(e,"^https?:")}function Gs(e){return Bs(e,"^wss?:")}function Ws(e){return new RegExp("wss?://localhost(:d{2,5})?").test(e)}function Ys(e){return"object"==typeof e&&"id"in e&&"jsonrpc"in e&&"2.0"===e.jsonrpc}function Js(e){return Ys(e)&&"method"in e}function Xs(e){return Ys(e)&&(Zs(e)||Qs(e))}function Zs(e){return"result"in e}function Qs(e){return"error"in e}class eo extends Vs{constructor(t){super(t),this.events=new e.EventEmitter,this.hasRegisteredEventListeners=!1,this.connection=this.setConnection(t),this.connection.connected&&this.registerEventListeners()}async connect(e=this.connection){await this.open(e)}async disconnect(){await this.close()}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async request(e,t){return this.requestStrict(ks(e.method,e.params||[],e.id||Ds().toString()),t)}async requestStrict(e,t){return new Promise((async(r,n)=>{if(!this.connection.connected)try{await this.open()}catch(e){n(e)}this.events.on(`${e.id}`,(e=>{Qs(e)?n(e.error):r(e.result)}));try{await this.connection.send(e,t)}catch(e){n(e)}}))}setConnection(e=this.connection){return e}onPayload(e){this.events.emit("payload",e),Xs(e)?this.events.emit(`${e.id}`,e):this.events.emit("message",{type:e.method,data:e.params})}onClose(e){e&&3e3===e.code&&this.events.emit("error",new Error(`WebSocket connection closed abnormally with code: ${e.code} ${e.reason?`(${e.reason})`:""}`)),this.events.emit("disconnect")}async open(e=this.connection){this.connection===e&&this.connection.connected||(this.connection.connected&&this.close(),"string"==typeof e&&(await this.connection.open(e),e=this.connection),this.connection=this.setConnection(e),await this.connection.open(),this.registerEventListeners(),this.events.emit("connect"))}async close(){await this.connection.close()}registerEventListeners(){this.hasRegisteredEventListeners||(this.connection.on("payload",(e=>this.onPayload(e))),this.connection.on("close",(e=>this.onClose(e))),this.connection.on("error",(e=>this.events.emit("error",e))),this.connection.on("register_error",(e=>this.onClose())),this.hasRegisteredEventListeners=!0)}}const to=e=>e.split("?")[0],ro="undefined"!=typeof global&&void 0!==global.WebSocket?global.WebSocket:"undefined"!=typeof window&&void 0!==window.WebSocket?window.WebSocket:require("ws");class no{constructor(t){if(this.url=t,this.events=new e.EventEmitter,this.registering=!1,!Gs(t))throw new Error(`Provided URL is not compatible with WebSocket connection: ${t}`);this.url=t}get connected(){return void 0!==this.socket}get connecting(){return this.registering}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async open(e=this.url){await this.register(e)}async close(){return new Promise(((e,t)=>{void 0!==this.socket?(this.socket.onclose=t=>{this.onClose(t),e()},this.socket.close()):t(new Error("Connection already closed"))}))}async send(e,t){void 0===this.socket&&(this.socket=await this.register());try{this.socket.send(as(e))}catch(t){this.onError(e.id,t)}}register(e=this.url){if(!Gs(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);if(this.registering){const e=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=e||this.events.listenerCount("open")>=e)&&this.events.setMaxListeners(e+1),new Promise(((e,t)=>{this.events.once("register_error",(e=>{this.resetMaxListeners(),t(e)})),this.events.once("open",(()=>{if(this.resetMaxListeners(),void 0===this.socket)return t(new Error("WebSocket connection is missing or invalid"));e(this.socket)}))}))}return this.url=e,this.registering=!0,new Promise(((t,r)=>{const n=Rs.isReactNative()?void 0:{rejectUnauthorized:!Ws(e)},i=new ro(e,[],n);"undefined"!=typeof window?i.onerror=e=>{const t=e;r(this.emitError(t.error))}:i.on("error",(e=>{r(this.emitError(e))})),i.onopen=()=>{this.onOpen(i),t(i)}}))}onOpen(e){e.onmessage=e=>this.onPayload(e),e.onclose=e=>this.onClose(e),this.socket=e,this.registering=!1,this.events.emit("open")}onClose(e){this.socket=void 0,this.registering=!1,this.events.emit("close",e)}onPayload(e){if(void 0===e.data)return;const t="string"==typeof e.data?os(e.data):e.data;this.events.emit("payload",t)}onError(e,t){const r=this.parseError(t),n=$s(e,r.message||r.toString());this.events.emit("payload",n)}parseError(e,t=this.url){return Cs(e,to(t),"WS")}resetMaxListeners(){this.events.getMaxListeners()>10&&this.events.setMaxListeners(10)}emitError(e){const t=this.parseError(new Error((null==e?void 0:e.message)||`WebSocket connection failed for host: ${to(this.url)}`));return this.events.emit("register_error",t),t}}var io={exports:{}};!function(e,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]",y="[object Number]",v="[object Null]",_="[object Object]",m="[object Promise]",w="[object Proxy]",b="[object RegExp]",E="[object Set]",S="[object String]",I="[object Symbol]",O="[object Undefined]",P="[object WeakMap]",N="[object ArrayBuffer]",A="[object DataView]",x=/^\[object .+?Constructor\]$/,C=/^(?:0|[1-9]\d*)$/,T={};T["[object Float32Array]"]=T["[object Float64Array]"]=T["[object Int8Array]"]=T["[object Int16Array]"]=T["[object Int32Array]"]=T["[object Uint8Array]"]=T["[object Uint8ClampedArray]"]=T["[object Uint16Array]"]=T["[object Uint32Array]"]=!0,T[a]=T[c]=T[N]=T[h]=T[A]=T[l]=T[f]=T[p]=T[g]=T[y]=T[_]=T[b]=T[E]=T[S]=T[P]=!1;var R="object"==typeof r.commonjsGlobal&&r.commonjsGlobal&&r.commonjsGlobal.Object===Object&&r.commonjsGlobal,j="object"==typeof self&&self&&self.Object===Object&&self,L=R||j||Function("return this")(),U=t&&!t.nodeType&&t,M=U&&e&&!e.nodeType&&e,D=M&&M.exports===U,k=D&&R.process,z=function(){try{return k&&k.binding&&k.binding("util")}catch(e){}}(),$=z&&z.isTypedArray;function q(e,t){for(var r=-1,n=null==e?0:e.length;++r<n;)if(t(e[r],r,e))return!0;return!1}function H(e){var t=-1,r=Array(e.size);return e.forEach((function(e,n){r[++t]=[n,e]})),r}function K(e){var t=-1,r=Array(e.size);return e.forEach((function(e){r[++t]=e})),r}var V,B,F,G=Array.prototype,W=Function.prototype,Y=Object.prototype,J=L["__core-js_shared__"],X=W.toString,Z=Y.hasOwnProperty,Q=(V=/[^.]+$/.exec(J&&J.keys&&J.keys.IE_PROTO||""))?"Symbol(src)_1."+V:"",ee=Y.toString,te=RegExp("^"+X.call(Z).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),re=D?L.Buffer:void 0,ne=L.Symbol,ie=L.Uint8Array,se=Y.propertyIsEnumerable,oe=G.splice,ae=ne?ne.toStringTag:void 0,ce=Object.getOwnPropertySymbols,ue=re?re.isBuffer:void 0,he=(B=Object.keys,F=Object,function(e){return B(F(e))}),le=ze(L,"DataView"),fe=ze(L,"Map"),pe=ze(L,"Promise"),de=ze(L,"Set"),ge=ze(L,"WeakMap"),ye=ze(Object,"create"),ve=Ke(le),_e=Ke(fe),me=Ke(pe),we=Ke(de),be=Ke(ge),Ee=ne?ne.prototype:void 0,Se=Ee?Ee.valueOf:void 0;function Ie(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function Oe(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function Pe(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function Ne(e){var t=-1,r=null==e?0:e.length;for(this.__data__=new Pe;++t<r;)this.add(e[t])}function Ae(e){var t=this.__data__=new Oe(e);this.size=t.size}function xe(e,t){var r=Fe(e),n=!r&&Be(e),i=!r&&!n&&Ge(e),s=!r&&!n&&!i&&Ze(e),o=r||n||i||s,a=o?function(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}(e.length,String):[],c=a.length;for(var u in e)!t&&!Z.call(e,u)||o&&("length"==u||i&&("offset"==u||"parent"==u)||s&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||He(u,c))||a.push(u);return a}function Ce(e,t){for(var r=e.length;r--;)if(Ve(e[r][0],t))return r;return-1}function Te(e){return null==e?void 0===e?O:v:ae&&ae in Object(e)?function(e){var t=Z.call(e,ae),r=e[ae];try{e[ae]=void 0;var n=!0}catch(e){}var i=ee.call(e);n&&(t?e[ae]=r:delete e[ae]);return i}(e):function(e){return ee.call(e)}(e)}function Re(e){return Xe(e)&&Te(e)==a}function je(e,t,r,n,o){return e===t||(null==e||null==t||!Xe(e)&&!Xe(t)?e!=e&&t!=t:function(e,t,r,n,o,u){var p=Fe(e),d=Fe(t),v=p?c:qe(e),m=d?c:qe(t),w=(v=v==a?_:v)==_,O=(m=m==a?_:m)==_,P=v==m;if(P&&Ge(e)){if(!Ge(t))return!1;p=!0,w=!1}if(P&&!w)return u||(u=new Ae),p||Ze(e)?Me(e,t,r,n,o,u):function(e,t,r,n,o,a,c){switch(r){case A:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case N:return!(e.byteLength!=t.byteLength||!a(new ie(e),new ie(t)));case h:case l:case y:return Ve(+e,+t);case f:return e.name==t.name&&e.message==t.message;case b:case S:return e==t+"";case g:var u=H;case E:var p=n&i;if(u||(u=K),e.size!=t.size&&!p)return!1;var d=c.get(e);if(d)return d==t;n|=s,c.set(e,t);var v=Me(u(e),u(t),n,o,a,c);return c.delete(e),v;case I:if(Se)return Se.call(e)==Se.call(t)}return!1}(e,t,v,r,n,o,u);if(!(r&i)){var x=w&&Z.call(e,"__wrapped__"),C=O&&Z.call(t,"__wrapped__");if(x||C){var T=x?e.value():e,R=C?t.value():t;return u||(u=new Ae),o(T,R,r,n,u)}}if(!P)return!1;return u||(u=new Ae),function(e,t,r,n,s,o){var a=r&i,c=De(e),u=c.length,h=De(t),l=h.length;if(u!=l&&!a)return!1;var f=u;for(;f--;){var p=c[f];if(!(a?p in t:Z.call(t,p)))return!1}var d=o.get(e);if(d&&o.get(t))return d==t;var g=!0;o.set(e,t),o.set(t,e);var y=a;for(;++f<u;){var v=e[p=c[f]],_=t[p];if(n)var m=a?n(_,v,p,t,e,o):n(v,_,p,e,t,o);if(!(void 0===m?v===_||s(v,_,r,n,o):m)){g=!1;break}y||(y="constructor"==p)}if(g&&!y){var w=e.constructor,b=t.constructor;w==b||!("constructor"in e)||!("constructor"in t)||"function"==typeof w&&w instanceof w&&"function"==typeof b&&b instanceof b||(g=!1)}return o.delete(e),o.delete(t),g}(e,t,r,n,o,u)}(e,t,r,n,je,o))}function Le(e){return!(!Je(e)||function(e){return!!Q&&Q in e}(e))&&(We(e)?te:x).test(Ke(e))}function Ue(e){if(r=(t=e)&&t.constructor,n="function"==typeof r&&r.prototype||Y,t!==n)return he(e);var t,r,n,i=[];for(var s in Object(e))Z.call(e,s)&&"constructor"!=s&&i.push(s);return i}function Me(e,t,r,n,o,a){var c=r&i,u=e.length,h=t.length;if(u!=h&&!(c&&h>u))return!1;var l=a.get(e);if(l&&a.get(t))return l==t;var f=-1,p=!0,d=r&s?new Ne:void 0;for(a.set(e,t),a.set(t,e);++f<u;){var g=e[f],y=t[f];if(n)var v=c?n(y,g,f,t,e,a):n(g,y,f,e,t,a);if(void 0!==v){if(v)continue;p=!1;break}if(d){if(!q(t,(function(e,t){if(i=t,!d.has(i)&&(g===e||o(g,e,r,n,a)))return d.push(t);var i}))){p=!1;break}}else if(g!==y&&!o(g,y,r,n,a)){p=!1;break}}return a.delete(e),a.delete(t),p}function De(e){return function(e,t,r){var n=t(e);return Fe(e)?n:function(e,t){for(var r=-1,n=t.length,i=e.length;++r<n;)e[i+r]=t[r];return e}(n,r(e))}(e,Qe,$e)}function ke(e,t){var r,n,i=e.__data__;return("string"==(n=typeof(r=t))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==r:null===r)?i["string"==typeof t?"string":"hash"]:i.map}function ze(e,t){var r=function(e,t){return null==e?void 0:e[t]}(e,t);return Le(r)?r:void 0}Ie.prototype.clear=function(){this.__data__=ye?ye(null):{},this.size=0},Ie.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},Ie.prototype.get=function(e){var t=this.__data__;if(ye){var r=t[e];return r===n?void 0:r}return Z.call(t,e)?t[e]:void 0},Ie.prototype.has=function(e){var t=this.__data__;return ye?void 0!==t[e]:Z.call(t,e)},Ie.prototype.set=function(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=ye&&void 0===t?n:t,this},Oe.prototype.clear=function(){this.__data__=[],this.size=0},Oe.prototype.delete=function(e){var t=this.__data__,r=Ce(t,e);return!(r<0)&&(r==t.length-1?t.pop():oe.call(t,r,1),--this.size,!0)},Oe.prototype.get=function(e){var t=this.__data__,r=Ce(t,e);return r<0?void 0:t[r][1]},Oe.prototype.has=function(e){return Ce(this.__data__,e)>-1},Oe.prototype.set=function(e,t){var r=this.__data__,n=Ce(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this},Pe.prototype.clear=function(){this.size=0,this.__data__={hash:new Ie,map:new(fe||Oe),string:new Ie}},Pe.prototype.delete=function(e){var t=ke(this,e).delete(e);return this.size-=t?1:0,t},Pe.prototype.get=function(e){return ke(this,e).get(e)},Pe.prototype.has=function(e){return ke(this,e).has(e)},Pe.prototype.set=function(e,t){var r=ke(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this},Ne.prototype.add=Ne.prototype.push=function(e){return this.__data__.set(e,n),this},Ne.prototype.has=function(e){return this.__data__.has(e)},Ae.prototype.clear=function(){this.__data__=new Oe,this.size=0},Ae.prototype.delete=function(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r},Ae.prototype.get=function(e){return this.__data__.get(e)},Ae.prototype.has=function(e){return this.__data__.has(e)},Ae.prototype.set=function(e,t){var r=this.__data__;if(r instanceof Oe){var n=r.__data__;if(!fe||n.length<199)return n.push([e,t]),this.size=++r.size,this;r=this.__data__=new Pe(n)}return r.set(e,t),this.size=r.size,this};var $e=ce?function(e){return null==e?[]:(e=Object(e),function(e,t){for(var r=-1,n=null==e?0:e.length,i=0,s=[];++r<n;){var o=e[r];t(o,r,e)&&(s[i++]=o)}return s}(ce(e),(function(t){return se.call(e,t)})))}:function(){return[]},qe=Te;function He(e,t){return!!(t=null==t?o:t)&&("number"==typeof e||C.test(e))&&e>-1&&e%1==0&&e<t}function Ke(e){if(null!=e){try{return X.call(e)}catch(e){}try{return e+""}catch(e){}}return""}function Ve(e,t){return e===t||e!=e&&t!=t}(le&&qe(new le(new ArrayBuffer(1)))!=A||fe&&qe(new fe)!=g||pe&&qe(pe.resolve())!=m||de&&qe(new de)!=E||ge&&qe(new ge)!=P)&&(qe=function(e){var t=Te(e),r=t==_?e.constructor:void 0,n=r?Ke(r):"";if(n)switch(n){case ve:return A;case _e:return g;case me:return m;case we:return E;case be:return P}return t});var Be=Re(function(){return arguments}())?Re:function(e){return Xe(e)&&Z.call(e,"callee")&&!se.call(e,"callee")},Fe=Array.isArray;var Ge=ue||function(){return!1};function We(e){if(!Je(e))return!1;var t=Te(e);return t==p||t==d||t==u||t==w}function Ye(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=o}function Je(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function Xe(e){return null!=e&&"object"==typeof e}var Ze=$?function(e){return function(t){return e(t)}}($):function(e){return Xe(e)&&Ye(e.length)&&!!T[Te(e)]};function Qe(e){return null!=(t=e)&&Ye(t.length)&&!We(t)?xe(e):Ue(e);var t}e.exports=function(e,t){return je(e,t)}}(io,io.exports);var so=io.exports;var oo=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<e.length;i++){var s=e.charAt(i),o=s.charCodeAt(0);if(255!==r[o])throw new TypeError(s+" is ambiguous");r[o]=i}var a=e.length,c=e.charAt(0),u=Math.log(a)/Math.log(256),h=Math.log(256)/Math.log(a);function l(e){if("string"!=typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var n=0,i=0;e[t]===c;)n++,t++;for(var s=(e.length-t)*u+1>>>0,o=new Uint8Array(s);e[t];){var h=r[e.charCodeAt(t)];if(255===h)return;for(var l=0,f=s-1;(0!==h||l<i)&&-1!==f;f--,l++)h+=a*o[f]>>>0,o[f]=h%256>>>0,h=h/256>>>0;if(0!==h)throw new Error("Non-zero carry");i=l,t++}if(" "!==e[t]){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(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,i=0,s=t.length;i!==s&&0===t[i];)i++,r++;for(var o=(s-i)*h+1>>>0,u=new Uint8Array(o);i!==s;){for(var l=t[i],f=0,p=o-1;(0!==l||f<n)&&-1!==p;p--,f++)l+=256*u[p]>>>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<o;++d)g+=e.charAt(u[d]);return g},decodeUnsafe:l,decode:function(e){var r=l(e);if(r)return r;throw new Error(`Non-${t} character`)}}},ao=oo;const co=e=>{if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")};class uo{constructor(e,t,r){this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class ho{constructor(e,t,r){if(this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=r}decode(e){if("string"==typeof e){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}throw Error("Can only multibase decode strings")}or(e){return fo(this,e)}}class lo{constructor(e){this.decoders=e}or(e){return fo(this,e)}decode(e){const t=e[0],r=this.decoders[t];if(r)return r.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const fo=(e,t)=>new lo({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}});class po{constructor(e,t,r,n){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new uo(e,t,r),this.decoder=new ho(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const go=({name:e,prefix:t,encode:r,decode:n})=>new po(e,t,r,n),yo=({prefix:e,name:t,alphabet:r})=>{const{encode:n,decode:i}=ao(r,t);return go({prefix:e,name:t,encode:n,decode:e=>co(i(e))})},vo=({name:e,prefix:t,bitsPerChar:r,alphabet:n})=>go({prefix:t,name:e,encode:e=>((e,t,r)=>{const n="="===t[t.length-1],i=(1<<r)-1;let s="",o=0,a=0;for(let n=0;n<e.length;++n)for(a=a<<8|e[n],o+=8;o>r;)o-=r,s+=t[i&a>>o];if(o&&(s+=t[i&a<<r-o]),n)for(;s.length*r&7;)s+="=";return s})(e,n,r),decode:t=>((e,t,r,n)=>{const i={};for(let e=0;e<t.length;++e)i[t[e]]=e;let s=e.length;for(;"="===e[s-1];)--s;const o=new Uint8Array(s*r/8|0);let a=0,c=0,u=0;for(let t=0;t<s;++t){const s=i[e[t]];if(void 0===s)throw new SyntaxError(`Non-${n} character`);c=c<<r|s,a+=r,a>=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,n,r,e)}),_o=go({prefix:"\0",name:"identity",encode:e=>(e=>(new TextDecoder).decode(e))(e),decode:e=>(e=>(new TextEncoder).encode(e))(e)});var mo=Object.freeze({__proto__:null,identity:_o});const wo=vo({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var bo=Object.freeze({__proto__:null,base2:wo});const Eo=vo({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var So=Object.freeze({__proto__:null,base8:Eo});const Io=yo({prefix:"9",name:"base10",alphabet:"0123456789"});var Oo=Object.freeze({__proto__:null,base10:Io});const Po=vo({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),No=vo({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Ao=Object.freeze({__proto__:null,base16:Po,base16upper:No});const xo=vo({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Co=vo({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),To=vo({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Ro=vo({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),jo=vo({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Lo=vo({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Uo=vo({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Mo=vo({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Do=vo({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var ko=Object.freeze({__proto__:null,base32:xo,base32upper:Co,base32pad:To,base32padupper:Ro,base32hex:jo,base32hexupper:Lo,base32hexpad:Uo,base32hexpadupper:Mo,base32z:Do});const zo=yo({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),$o=yo({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var qo=Object.freeze({__proto__:null,base36:zo,base36upper:$o});const Ho=yo({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ko=yo({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Vo=Object.freeze({__proto__:null,base58btc:Ho,base58flickr:Ko});const Bo=vo({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Fo=vo({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Go=vo({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Wo=vo({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Yo=Object.freeze({__proto__:null,base64:Bo,base64pad:Fo,base64url:Go,base64urlpad:Wo});const Jo=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),Xo=Jo.reduce(((e,t,r)=>(e[r]=t,e)),[]),Zo=Jo.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const Qo=go({prefix:"🚀",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=Xo[t]),"")},decode:function(e){const t=[];for(const r of e){const e=Zo[r.codePointAt(0)];if(void 0===e)throw new Error(`Non-base256emoji character: ${r}`);t.push(e)}return new Uint8Array(t)}});var ea=Object.freeze({__proto__:null,base256emoji:Qo}),ta=function e(t,r,n){r=r||[];for(var i=n=n||0;t>=ia;)r[n++]=255&t|ra,t/=128;for(;t&na;)r[n++]=255&t|ra,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},ra=128,na=-128,ia=Math.pow(2,31);var sa=function e(t,r){var n,i=0,s=0,o=r=r||0,a=t.length;do{if(o>=a)throw e.bytes=0,new RangeError("Could not decode varint");n=t[o++],i+=s<28?(n&aa)<<s:(n&aa)*Math.pow(2,s),s+=7}while(n>=oa);return e.bytes=o-r,i},oa=128,aa=127;var ca=Math.pow(2,7),ua=Math.pow(2,14),ha=Math.pow(2,21),la=Math.pow(2,28),fa=Math.pow(2,35),pa=Math.pow(2,42),da=Math.pow(2,49),ga=Math.pow(2,56),ya=Math.pow(2,63),va={encode:ta,decode:sa,encodingLength:function(e){return e<ca?1:e<ua?2:e<ha?3:e<la?4:e<fa?5:e<pa?6:e<da?7:e<ga?8:e<ya?9:10}};const _a=(e,t,r=0)=>(va.encode(e,t,r),t),ma=e=>va.encodingLength(e),wa=(e,t)=>{const r=t.byteLength,n=ma(e),i=n+ma(r),s=new Uint8Array(i+r);return _a(e,s,0),_a(r,s,n),s.set(t,i),new ba(e,r,t,s)};class ba{constructor(e,t,r,n){this.code=e,this.size=t,this.digest=r,this.bytes=n}}const Ea=({name:e,code:t,encode:r})=>new Sa(e,t,r);class Sa{constructor(e,t,r){this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?wa(this.code,t):t.then((e=>wa(this.code,e)))}throw Error("Unknown type, must be binary type")}}const Ia=e=>async t=>new Uint8Array(await crypto.subtle.digest(e,t)),Oa=Ea({name:"sha2-256",code:18,encode:Ia("SHA-256")}),Pa=Ea({name:"sha2-512",code:19,encode:Ia("SHA-512")});Object.freeze({__proto__:null,sha256:Oa,sha512:Pa});const Na=co,Aa={code:0,name:"identity",encode:Na,digest:e=>wa(0,Na(e))};Object.freeze({__proto__:null,identity:Aa});new TextEncoder,new TextDecoder;const xa={...mo,...bo,...So,...Oo,...Ao,...ko,...qo,...Vo,...Yo,...ea};function Ca(e){return null!=globalThis.Buffer?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e}function Ta(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}const Ra=Ta("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),ja=Ta("ascii","a",(e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t}),(e=>{const t=function(e=0){return null!=globalThis.Buffer&&null!=globalThis.Buffer.allocUnsafe?Ca(globalThis.Buffer.allocUnsafe(e)):new Uint8Array(e)}((e=e.substring(1)).length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t})),La={utf8:Ra,"utf-8":Ra,hex:xa.base16,latin1:ja,ascii:ja,binary:ja,...xa};const Ua="core",Ma=`wc@2:${Ua}:`,Da="error",ka={database:":memory:"},za="client_ed25519_seed",$a=Mt.ONE_DAY,qa=Mt.SIX_HOURS,Ha="wss://relay.walletconnect.com",Ka="wss://relay.walletconnect.org",Va="relayer_message",Ba="relayer_message_ack",Fa="relayer_connect",Ga="relayer_disconnect",Wa="relayer_error",Ya="relayer_connection_stalled",Ja="relayer_transport_closed",Xa="relayer_publish",Za="payload",Qa="connect",ec="disconnect",tc="error",rc=Mt.ONE_SECOND/2,nc="subscription_created",ic="subscription_deleted",sc="subscription_sync",oc="subscription_resubscribed",ac=1e3*Mt.FIVE_SECONDS,cc={wc_pairingDelete:{req:{ttl:Mt.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:Mt.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:Mt.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:Mt.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:Mt.ONE_DAY,prompt:!1,tag:0},res:{ttl:Mt.ONE_DAY,prompt:!1,tag:0}}},uc="history_created",hc="history_updated",lc="history_deleted",fc="history_sync",pc="expirer_created",dc="expirer_deleted",gc="expirer_expired",yc="expirer_sync",vc="verify-api",_c="https://verify.walletconnect.com";class mc{constructor(e,t){this.core=e,this.logger=t,this.keychain=new Map,this.name="keychain",this.version="0.3",this.initialized=!1,this.storagePrefix=Ma,this.init=async()=>{if(!this.initialized){const e=await this.getKeyChain();typeof e<"u"&&(this.keychain=e),this.initialized=!0}},this.has=e=>(this.isInitialized(),this.keychain.has(e)),this.set=async(e,t)=>{this.isInitialized(),this.keychain.set(e,t),await this.persist()},this.get=e=>{this.isInitialized();const t=this.keychain.get(e);if(typeof t>"u"){const{message:t}=zn("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(t)}return t},this.del=async e=>{this.isInitialized(),this.keychain.delete(e),await this.persist()},this.core=e,this.logger=qi.generateChildLogger(t,this.name)}get context(){return qi.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,dn(e))}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?gn(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:e}=zn("NOT_INITIALIZED",this.name);throw new Error(e)}}}class wc{constructor(e,t,r){this.core=e,this.logger=t,this.name="crypto",this.initialized=!1,this.init=async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)},this.hasKeys=e=>(this.isInitialized(),this.keychain.has(e)),this.getClientId=async()=>{this.isInitialized();return bs(Es(await this.getClientSeed()).publicKey)},this.generateKeyPair=()=>{this.isInitialized();const e=function(){const e=Y.generateKeyPair();return{privateKey:St(e.secretKey,Ur),publicKey:St(e.publicKey,Ur)}}();return this.setPrivateKey(e.publicKey,e.privateKey)},this.signJWT=async e=>{this.isInitialized();const t=Es(await this.getClientSeed()),r=Vr(),n=$a;return await Ss(r,e,n,t)},this.generateSharedKey=(e,t,r)=>{this.isInitialized();const n=function(e,t){const r=Y.sharedKey(Et(e,Ur),Et(t,Ur));return St(new $(W.SHA256,r).expand(Kr),Ur)}(this.getPrivateKey(e),t);return this.setSymKey(n,r)},this.setSymKey=async(e,t)=>{this.isInitialized();const r=t||function(e){return St(W.hash(Et(e,Ur)),Ur)}(e);return await this.keychain.set(r,e),r},this.deleteKeyPair=async e=>{this.isInitialized(),await this.keychain.del(e)},this.deleteSymKey=async e=>{this.isInitialized(),await this.keychain.del(e)},this.encode=async(e,t,r)=>{this.isInitialized();const n=Yr(r),i=as(t);if(Jr(n)){const t=n.senderPublicKey,r=n.receiverPublicKey;e=await this.generateSharedKey(t,r)}const s=this.getSymKey(e),{type:o,senderPublicKey:a}=n;return Gr({type:o,symKey:s,message:i,senderPublicKey:a})},this.decode=async(e,t,r)=>{this.isInitialized();const n=function(e,t){const r=Wr(e);return Yr({type:Fr(r.type),senderPublicKey:typeof r.senderPublicKey<"u"?St(r.senderPublicKey,Ur):void 0,receiverPublicKey:t?.receiverPublicKey})}(t,r);if(Jr(n)){const t=n.receiverPublicKey,r=n.senderPublicKey;e=await this.generateSharedKey(t,r)}const i=function(e){const t=new s.ChaCha20Poly1305(Et(e.symKey,Ur)),{sealed:r,iv:n}=Wr(e.encoded),i=t.open(n,r);if(null===i)throw new Error("Failed to decrypt");return St(i,Dr)}({symKey:this.getSymKey(e),encoded:t});return os(i)},this.getPayloadType=e=>Fr(Wr(e).type),this.getPayloadSenderPublicKey=e=>{const t=Wr(e);return t.senderPublicKey?St(t.senderPublicKey,Ur):void 0},this.core=e,this.logger=qi.generateChildLogger(t,this.name),this.keychain=r||new mc(this.core,this.logger)}get context(){return qi.getLoggerContext(this.logger)}async setPrivateKey(e,t){return await this.keychain.set(e,t),e}getPrivateKey(e){return this.keychain.get(e)}async getClientSeed(){let e="";try{e=this.keychain.get(za)}catch{e=Vr(),await this.keychain.set(za,e)}return function(e,t="utf8"){const r=La[t];if(!r)throw new Error(`Unsupported encoding "${t}"`);return"utf8"!==t&&"utf-8"!==t||null==globalThis.Buffer||null==globalThis.Buffer.from?r.decoder.decode(`${r.prefix}${e}`):Ca(globalThis.Buffer.from(e,"utf-8"))}(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=zn("NOT_INITIALIZED",this.name);throw new Error(e)}}}class bc extends Ji{constructor(e,t){super(e,t),this.logger=e,this.core=t,this.messages=new Map,this.name="messages",this.version="0.3",this.initialized=!1,this.storagePrefix=Ma,this.init=async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const e=await this.getRelayerMessages();typeof e<"u"&&(this.messages=e),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e)}finally{this.initialized=!0}}},this.set=async(e,t)=>{this.isInitialized();const r=Br(t);let n=this.messages.get(e);return typeof n>"u"&&(n={}),typeof n[r]<"u"||(n[r]=t,this.messages.set(e,n),await this.persist()),r},this.get=e=>{this.isInitialized();let t=this.messages.get(e);return typeof t>"u"&&(t={}),t},this.has=(e,t)=>{this.isInitialized();return typeof this.get(e)[Br(t)]<"u"},this.del=async e=>{this.isInitialized(),this.messages.delete(e),await this.persist()},this.logger=qi.generateChildLogger(e,this.name),this.core=t}get context(){return qi.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,dn(e))}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?gn(e):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){const{message:e}=zn("NOT_INITIALIZED",this.name);throw new Error(e)}}}class Ec extends Xi{constructor(t,r){super(t,r),this.relayer=t,this.logger=r,this.events=new e.EventEmitter,this.name="publisher",this.queue=new Map,this.publishTimeout=Mt.toMiliseconds(Mt.TEN_SECONDS),this.queueTimeout=Mt.toMiliseconds(Mt.FIVE_SECONDS),this.needsTransportRestart=!1,this.publish=async(e,t,r)=>{this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:e,message:t,opts:r}});try{const n=r?.ttl||qa,i=In(r),s=r?.prompt||!1,o=r?.tag||0,a=r?.id||Ds().toString(),c={topic:e,message:t,opts:{ttl:n,relay:i,prompt:s,tag:o,id:a}},u=setTimeout((()=>this.queue.set(a,c)),this.queueTimeout);try{await await vn(this.rpcPublish(e,t,n,i,s,o,a),this.publishTimeout),clearTimeout(u),this.relayer.events.emit(Xa,c)}catch{return this.logger.debug("Publishing Payload stalled"),void(this.needsTransportRestart=!0)}this.logger.debug("Successfully Published Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:e,message:t,opts:r}})}catch(e){throw this.logger.debug("Failed to Publish Payload"),this.logger.error(e),e}},this.on=(e,t)=>{this.events.on(e,t)},this.once=(e,t)=>{this.events.once(e,t)},this.off=(e,t)=>{this.events.off(e,t)},this.removeListener=(e,t)=>{this.events.removeListener(e,t)},this.relayer=t,this.logger=qi.generateChildLogger(r,this.name),this.registerEventListeners()}get context(){return qi.getLoggerContext(this.logger)}rpcPublish(e,t,r,n,i,s,o){var a,c,u,h;const l={method:On(n.protocol).publish,params:{topic:e,message:t,ttl:r,prompt:i,tag:s},id:o};return Kn(null==(a=l.params)?void 0:a.prompt)&&(null==(c=l.params)||delete c.prompt),Kn(null==(u=l.params)?void 0:u.tag)&&(null==(h=l.params)||delete h.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:l}),this.relayer.request(l)}onPublish(e){this.queue.delete(e)}checkQueue(){this.queue.forEach((async e=>{const{topic:t,message:r,opts:n}=e;await this.publish(t,r,n)}))}registerEventListeners(){this.relayer.core.heartbeat.on(bi.HEARTBEAT_EVENTS.pulse,(()=>{if(this.needsTransportRestart)return this.needsTransportRestart=!1,void this.relayer.events.emit(Ya);this.checkQueue()})),this.relayer.on(Ba,(e=>{this.onPublish(e.id.toString())}))}}class Sc{constructor(){this.map=new Map,this.set=(e,t)=>{const r=this.get(e);this.exists(e,t)||this.map.set(e,[...r,t])},this.get=e=>this.map.get(e)||[],this.exists=(e,t)=>this.get(e).includes(t),this.delete=(e,t)=>{if(typeof t>"u")return void this.map.delete(e);if(!this.map.has(e))return;const r=this.get(e);if(!this.exists(e,t))return;const n=r.filter((e=>e!==t));n.length?this.map.set(e,n):this.map.delete(e)},this.clear=()=>{this.map.clear()}}get topics(){return Array.from(this.map.keys())}}var Ic=Object.defineProperty,Oc=Object.defineProperties,Pc=Object.getOwnPropertyDescriptors,Nc=Object.getOwnPropertySymbols,Ac=Object.prototype.hasOwnProperty,xc=Object.prototype.propertyIsEnumerable,Cc=(e,t,r)=>t in e?Ic(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Tc=(e,t)=>{for(var r in t||(t={}))Ac.call(t,r)&&Cc(e,r,t[r]);if(Nc)for(var r of Nc(t))xc.call(t,r)&&Cc(e,r,t[r]);return e},Rc=(e,t)=>Oc(e,Pc(t));class jc extends es{constructor(t,r){super(t,r),this.relayer=t,this.logger=r,this.subscriptions=new Map,this.topicMap=new Sc,this.events=new e.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=Ma,this.subscribeTimeout=1e4,this.restartInProgress=!1,this.batchSubscribeTopicsLimit=500,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restart(),this.registerEventListeners(),this.onEnable(),this.clientId=await this.relayer.core.crypto.getClientId())},this.subscribe=async(e,t)=>{await this.restartToComplete(),this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:e,opts:t}});try{const r=In(t),n={topic:e,relay:r};this.pending.set(e,n);const i=await this.rpcSubscribe(e,r);return this.onSubscribe(i,n),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:e,opts:t}}),i}catch(e){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(e),e}},this.unsubscribe=async(e,t)=>{await this.restartToComplete(),this.isInitialized(),typeof t?.id<"u"?await this.unsubscribeById(e,t.id,t):await this.unsubscribeByTopic(e,t)},this.isSubscribed=async e=>!!this.topics.includes(e)||await new Promise(((t,r)=>{const n=new Mt.Watch;n.start(this.pendingSubscriptionWatchLabel);const i=setInterval((()=>{!this.pending.has(e)&&this.topics.includes(e)&&(clearInterval(i),n.stop(this.pendingSubscriptionWatchLabel),t(!0)),n.elapsed(this.pendingSubscriptionWatchLabel)>=ac&&(clearInterval(i),n.stop(this.pendingSubscriptionWatchLabel),r(new Error("Subscription resolution timeout")))}),this.pollingInterval)})).catch((()=>!1)),this.on=(e,t)=>{this.events.on(e,t)},this.once=(e,t)=>{this.events.once(e,t)},this.off=(e,t)=>{this.events.off(e,t)},this.removeListener=(e,t)=>{this.events.removeListener(e,t)},this.restart=async()=>{this.restartInProgress=!0,await this.restore(),await this.reset(),this.restartInProgress=!1},this.relayer=t,this.logger=qi.generateChildLogger(r,this.name),this.clientId=""}get context(){return qi.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}hasSubscription(e,t){let r=!1;try{r=this.getSubscription(e).topic===t}catch{}return r}onEnable(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(e,t){const r=this.topicMap.get(e);await Promise.all(r.map((async r=>await this.unsubscribeById(e,r,t))))}async unsubscribeById(e,t,r){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:r}});try{const n=In(r);await this.rpcUnsubscribe(e,t,n);const i=$n("USER_DISCONNECTED",`${this.name}, ${e}`);await this.onUnsubscribe(e,t,i),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:r}})}catch(e){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(e),e}}async rpcSubscribe(e,t){const r={method:On(t.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:r});try{await await vn(this.relayer.request(r),this.subscribeTimeout)}catch{this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(Ya)}return Br(e+this.clientId)}async rpcBatchSubscribe(e){if(!e.length)return;const t={method:On(e[0].relay.protocol).batchSubscribe,params:{topics:e.map((e=>e.topic))}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:t});try{return await await vn(this.relayer.request(t),this.subscribeTimeout)}catch{this.logger.debug("Outgoing Relay Payload stalled"),this.relayer.events.emit(Ya)}}rpcUnsubscribe(e,t,r){const n={method:On(r.protocol).unsubscribe,params:{topic:e,id:t}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n}),this.relayer.request(n)}onSubscribe(e,t){this.setSubscription(e,Rc(Tc({},t),{id:e})),this.pending.delete(t.topic)}onBatchSubscribe(e){e.length&&e.forEach((e=>{this.setSubscription(e.id,Tc({},e)),this.pending.delete(e.topic)}))}async onUnsubscribe(e,t,r){this.events.removeAllListeners(t),this.hasSubscription(t,e)&&this.deleteSubscription(t,r),await this.relayer.messages.del(e)}async setRelayerSubscriptions(e){await this.relayer.core.storage.setItem(this.storageKey,e)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(e,t){this.subscriptions.has(e)||(this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:e,subscription:t}),this.addSubscription(e,t))}addSubscription(e,t){this.subscriptions.set(e,Tc({},t)),this.topicMap.set(t.topic,e),this.events.emit(nc,t)}getSubscription(e){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});const t=this.subscriptions.get(e);if(!t){const{message:t}=zn("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(t)}return t}deleteSubscription(e,t){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:t});const r=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(r.topic,e),this.events.emit(ic,Rc(Tc({},r),{reason:t}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(sc)}async reset(){if(this.cached.length){const e=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let t=0;t<e;t++){const e=this.cached.splice(0,this.batchSubscribeTopicsLimit);await this.batchSubscribe(e)}}this.events.emit(oc)}async restore(){try{const e=await this.getRelayerSubscriptions();if(typeof e>"u"||!e.length)return;if(this.subscriptions.size){const{message:e}=zn("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(e)}this.cached=e,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values})}catch(e){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(e)}}async batchSubscribe(e){if(!e.length)return;const t=await this.rpcBatchSubscribe(e);qn(t)&&this.onBatchSubscribe(t.map(((t,r)=>Rc(Tc({},e[r]),{id:t}))))}async onConnect(){this.restartInProgress||(await this.restart(),this.onEnable())}onDisconnect(){this.onDisable()}async checkPending(){if(this.relayer.transportExplicitlyClosed)return;const e=[];this.pending.forEach((t=>{e.push(t)})),await this.batchSubscribe(e)}registerEventListeners(){this.relayer.core.heartbeat.on(bi.HEARTBEAT_EVENTS.pulse,(async()=>{await this.checkPending()})),this.relayer.on(Fa,(async()=>{await this.onConnect()})),this.relayer.on(Ga,(()=>{this.onDisconnect()})),this.events.on(nc,(async e=>{const t=nc;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist()})),this.events.on(ic,(async e=>{const t=ic;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist()}))}isInitialized(){if(!this.initialized){const{message:e}=zn("NOT_INITIALIZED",this.name);throw new Error(e)}}async restartToComplete(){this.restartInProgress&&await new Promise((e=>{const t=setInterval((()=>{this.restartInProgress||(clearInterval(t),e())}),this.pollingInterval)}))}}var Lc=Object.defineProperty,Uc=Object.getOwnPropertySymbols,Mc=Object.prototype.hasOwnProperty,Dc=Object.prototype.propertyIsEnumerable,kc=(e,t,r)=>t in e?Lc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;class zc extends Zi{constructor(t){super(t),this.protocol="wc",this.version=2,this.events=new e.EventEmitter,this.name="relayer",this.transportExplicitlyClosed=!1,this.initialized=!1,this.reconnecting=!1,this.connectionStatusPollingInterval=20,this.staleConnectionErrors=["socket hang up","socket stalled"],this.request=async e=>{this.logger.debug("Publishing Request Payload");try{return await this.toEstablishConnection(),await this.provider.request(e)}catch(e){throw this.logger.debug("Failed to Publish Request"),this.logger.error(e),e}},this.core=t.core,this.logger=typeof t.logger<"u"&&"string"!=typeof t.logger?qi.generateChildLogger(t.logger,this.name):qi.pino(qi.getDefaultLoggerOptions({level:t.logger||"error"})),this.messages=new bc(this.logger,t.core),this.subscriber=new jc(this,this.logger),this.publisher=new Ec(this,this.logger),this.relayUrl=t?.relayUrl||Ha,this.projectId=t.projectId,this.provider={}}async init(){this.logger.trace("Initialized"),await this.createProvider(),await Promise.all([this.messages.init(),this.subscriber.init()]);try{await this.transportOpen()}catch{this.logger.warn(`Connection via ${this.relayUrl} failed, attempting to connect via failover domain ${Ka}...`),await this.restartTransport(Ka)}this.registerEventListeners(),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 qi.getLoggerContext(this.logger)}get connected(){return this.provider.connection.connected}get connecting(){return this.provider.connection.connecting}async publish(e,t,r){this.isInitialized(),await this.publisher.publish(e,t,r),await this.recordMessageEvent({topic:e,message:t,publishedAt:Date.now()})}async subscribe(e,t){var r;this.isInitialized();let n=(null==(r=this.subscriber.topicMap.get(e))?void 0:r[0])||"";return n||(await Promise.all([new Promise((t=>{this.subscriber.once(nc,(r=>{r.topic===e&&t()}))})),new Promise((async r=>{n=await this.subscriber.subscribe(e,t),r()}))]),n)}async unsubscribe(e,t){this.isInitialized(),await this.subscriber.unsubscribe(e,t)}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async transportClose(){this.transportExplicitlyClosed=!0,this.connected&&(await this.provider.disconnect(),this.events.emit(Ja))}async transportOpen(e){if(this.transportExplicitlyClosed=!1,!this.reconnecting){this.relayUrl=e||this.relayUrl,this.reconnecting=!0;try{await Promise.all([new Promise((e=>{this.initialized||e(),this.subscriber.once(oc,(()=>{e()}))})),await Promise.race([new Promise((async(e,t)=>{await vn(this.provider.connect(),5e3,`Socket stalled when trying to connect to ${this.relayUrl}`).catch((e=>t(e))).then((()=>e())).finally((()=>this.removeListener(Ja,this.rejectTransportOpen)))})),new Promise((e=>this.once(Ja,this.rejectTransportOpen)))])])}catch(e){this.logger.error(e);const t=e;if(!this.isConnectionStalled(t.message))throw e;this.events.emit(Ja)}finally{this.reconnecting=!1}}}async restartTransport(e){this.transportExplicitlyClosed||this.reconnecting||(this.relayUrl=e||this.relayUrl,this.connected&&await Promise.all([new Promise((e=>{this.provider.once(ec,(()=>{e()}))})),this.transportClose()]),await this.createProvider(),await this.transportOpen())}isConnectionStalled(e){return this.staleConnectionErrors.some((t=>e.includes(t)))}rejectTransportOpen(){throw new Error("Attempt to connect to relay via `transportOpen` has stalled. Retrying...")}async createProvider(){const e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new eo(new no(fn({sdkVersion:"2.9.0",protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e,useOnCloseEvent:!0}))),this.registerProviderListeners()}async recordMessageEvent(e){const{topic:t,message:r}=e;await this.messages.set(t,r)}async shouldIgnoreMessageEvent(e){const{topic:t,message:r}=e;return!await this.subscriber.isSubscribed(t)||this.messages.has(t,r)}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),Js(e)){if(!e.method.endsWith("_subscription"))return;const t=e.params,{topic:r,message:n,publishedAt:i}=t.data,s={topic:r,message:n,publishedAt:i};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(((e,t)=>{for(var r in t||(t={}))Mc.call(t,r)&&kc(e,r,t[r]);if(Uc)for(var r of Uc(t))Dc.call(t,r)&&kc(e,r,t[r]);return e})({type:"event",event:t.id},s)),this.events.emit(t.id,s),await this.acknowledgePayload(e),await this.onMessageEvent(s)}else Xs(e)&&this.events.emit(Ba,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(this.events.emit(Va,e),await this.recordMessageEvent(e))}async acknowledgePayload(e){const t=zs(e.id,!0);await this.provider.connection.send(t)}registerProviderListeners(){this.provider.on(Za,(e=>this.onProviderPayload(e))),this.provider.on(Qa,(()=>{this.events.emit(Fa)})),this.provider.on(ec,(()=>{this.onProviderDisconnect()})),this.provider.on(tc,(e=>{this.logger.error(e),this.events.emit(Wa,e)}))}registerEventListeners(){this.events.on(Ya,(async()=>{await this.restartTransport()}))}onProviderDisconnect(){this.events.emit(Ga),this.attemptToReconnect()}attemptToReconnect(){this.transportExplicitlyClosed||setTimeout((async()=>{await this.restartTransport()}),Mt.toMiliseconds(rc))}isInitialized(){if(!this.initialized){const{message:e}=zn("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){if(!this.connected){if(this.connecting)return await new Promise((e=>{const t=setInterval((()=>{this.connected&&(clearInterval(t),e())}),this.connectionStatusPollingInterval)}));await this.restartTransport()}}}var $c=Object.defineProperty,qc=Object.getOwnPropertySymbols,Hc=Object.prototype.hasOwnProperty,Kc=Object.prototype.propertyIsEnumerable,Vc=(e,t,r)=>t in e?$c(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Bc=(e,t)=>{for(var r in t||(t={}))Hc.call(t,r)&&Vc(e,r,t[r]);if(qc)for(var r of qc(t))Kc.call(t,r)&&Vc(e,r,t[r]);return e};class Fc extends Qi{constructor(e,t,r,n=Ma,i=void 0){super(e,t,r,n),this.core=e,this.logger=t,this.name=r,this.map=new Map,this.version="0.3",this.cached=[],this.initialized=!1,this.storagePrefix=Ma,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach((e=>{this.getKey&&null!==e&&!Kn(e)?this.map.set(this.getKey(e),e):function(e){var t;return null==(t=e?.proposer)?void 0:t.publicKey}(e)?this.map.set(e.id,e):function(e){return e?.topic}(e)&&this.map.set(e.topic,e)})),this.cached=[],this.initialized=!0)},this.set=async(e,t)=>{this.isInitialized(),this.map.has(e)?await this.update(e,t):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:e,value:t}),this.map.set(e,t),await this.persist())},this.get=e=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:e}),this.getData(e)),this.getAll=e=>(this.isInitialized(),e?this.values.filter((t=>Object.keys(e).every((r=>so(t[r],e[r]))))):this.values),this.update=async(e,t)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:e,update:t});const r=Bc(Bc({},this.getData(e)),t);this.map.set(e,r),await this.persist()},this.delete=async(e,t)=>{this.isInitialized(),this.map.has(e)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:e,reason:t}),this.map.delete(e),await this.persist())},this.logger=qi.generateChildLogger(t,this.name),this.storagePrefix=n,this.getKey=i}get context(){return qi.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}async setDataStore(e){await this.core.storage.setItem(this.storageKey,e)}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(e){const t=this.map.get(e);if(!t){const{message:t}=zn("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(t),new Error(t)}return t}async persist(){await this.setDataStore(this.values)}async restore(){try{const e=await this.getDataStore();if(typeof e>"u"||!e.length)return;if(this.map.size){const{message:e}=zn("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),new Error(e)}this.cached=e,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values})}catch(e){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(e)}}isInitialized(){if(!this.initialized){const{message:e}=zn("NOT_INITIALIZED",this.name);throw new Error(e)}}}class Gc{constructor(e,t){this.core=e,this.logger=t,this.name="pairing",this.version="0.3",this.events=new i.default,this.initialized=!1,this.storagePrefix=Ma,this.ignoredPayloadTypes=[zr],this.registeredMethods=[],this.init=async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))},this.register=({methods:e})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...e])]},this.create=async()=>{this.isInitialized();const e=Vr(),t=await this.core.crypto.setSymKey(e),r=wn(Mt.FIVE_MINUTES),n={protocol:"irn"},i={topic:t,expiry:r,relay:n,active:!1},s=jn({protocol:this.core.protocol,version:this.core.version,topic:t,symKey:e,relay:n});return await this.pairings.set(t,i),await this.core.relayer.subscribe(t),this.core.expirer.set(t,r),{topic:t,uri:s}},this.pair=async e=>{this.isInitialized(),this.isValidPair(e);const{topic:t,symKey:r,relay:n}=function(e){const t=e.indexOf(":"),r=-1!==e.indexOf("?")?e.indexOf("?"):void 0,n=e.substring(0,t),i=e.substring(t+1,r).split("@"),s=typeof r<"u"?e.substring(r):"",o=Er.parse(s);return{protocol:n,topic:Rn(i[0]),version:parseInt(i[1],10),symKey:o.symKey,relay:Tn(o)}}(e.uri);if(this.pairings.keys.includes(t))throw new Error(`Pairing already exists: ${t}`);if(this.core.crypto.hasKeys(t))throw new Error(`Keychain already exists: ${t}`);const i=wn(Mt.FIVE_MINUTES),s={topic:t,relay:n,expiry:i,active:!1};return await this.pairings.set(t,s),await this.core.crypto.setSymKey(r,t),await this.core.relayer.subscribe(t,{relay:n}),this.core.expirer.set(t,i),e.activatePairing&&await this.activate({topic:t}),s},this.activate=async({topic:e})=>{this.isInitialized();const t=wn(Mt.THIRTY_DAYS);await this.pairings.update(e,{active:!0,expiry:t}),this.core.expirer.set(e,t)},this.ping=async e=>{this.isInitialized(),await this.isValidPing(e);const{topic:t}=e;if(this.pairings.keys.includes(t)){const e=await this.sendRequest(t,"wc_pairingPing",{}),{done:r,resolve:n,reject:i}=yn();this.events.once(En("pairing_ping",e),(({error:e})=>{e?i(e):n()})),await r()}},this.updateExpiry=async({topic:e,expiry:t})=>{this.isInitialized(),await this.pairings.update(e,{expiry:t})},this.updateMetadata=async({topic:e,metadata:t})=>{this.isInitialized(),await this.pairings.update(e,{peerMetadata:t})},this.getPairings=()=>(this.isInitialized(),this.pairings.values),this.disconnect=async e=>{this.isInitialized(),await this.isValidDisconnect(e);const{topic:t}=e;this.pairings.keys.includes(t)&&(await this.sendRequest(t,"wc_pairingDelete",$n("USER_DISCONNECTED")),await this.deletePairing(t))},this.sendRequest=async(e,t,r)=>{const n=ks(t,r),i=await this.core.crypto.encode(e,n),s=cc[t].req;return this.core.history.set(e,n),this.core.relayer.publish(e,i,s),n.id},this.sendResult=async(e,t,r)=>{const n=zs(e,r),i=await this.core.crypto.encode(t,n),s=await this.core.history.get(t,e),o=cc[s.request.method].res;await this.core.relayer.publish(t,i,o),await this.core.history.resolve(n)},this.sendError=async(e,t,r)=>{const n=$s(e,r),i=await this.core.crypto.encode(t,n),s=await this.core.history.get(t,e),o=cc[s.request.method]?cc[s.request.method].res:cc.unregistered_method.res;await this.core.relayer.publish(t,i,o),await this.core.history.resolve(n)},this.deletePairing=async(e,t)=>{await this.core.relayer.unsubscribe(e),await Promise.all([this.pairings.delete(e,$n("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(e),t?Promise.resolve():this.core.expirer.del(e)])},this.cleanup=async()=>{const e=this.pairings.getAll().filter((e=>bn(e.expiry)));await Promise.all(e.map((e=>this.deletePairing(e.topic))))},this.onRelayEventRequest=e=>{const{topic:t,payload:r}=e,n=r.method;if(this.pairings.keys.includes(t))switch(n){case"wc_pairingPing":return this.onPairingPingRequest(t,r);case"wc_pairingDelete":return this.onPairingDeleteRequest(t,r);default:return this.onUnknownRpcMethodRequest(t,r)}},this.onRelayEventResponse=async e=>{const{topic:t,payload:r}=e,n=(await this.core.history.get(t,r.id)).request.method;if(this.pairings.keys.includes(t)){if("wc_pairingPing"===n)return this.onPairingPingResponse(t,r);return this.onUnknownRpcMethodResponse(n)}},this.onPairingPingRequest=async(e,t)=>{const{id:r}=t;try{this.isValidPing({topic:e}),await this.sendResult(r,e,!0),this.events.emit("pairing_ping",{id:r,topic:e})}catch(t){await this.sendError(r,e,t),this.logger.error(t)}},this.onPairingPingResponse=(e,t)=>{const{id:r}=t;setTimeout((()=>{Zs(t)?this.events.emit(En("pairing_ping",r),{}):Qs(t)&&this.events.emit(En("pairing_ping",r),{error:t.error})}),500)},this.onPairingDeleteRequest=async(e,t)=>{const{id:r}=t;try{this.isValidDisconnect({topic:e}),await this.deletePairing(e),this.events.emit("pairing_delete",{id:r,topic:e})}catch(t){await this.sendError(r,e,t),this.logger.error(t)}},this.onUnknownRpcMethodRequest=async(e,t)=>{const{id:r,method:n}=t;try{if(this.registeredMethods.includes(n))return;const t=$n("WC_METHOD_UNSUPPORTED",n);await this.sendError(r,e,t),this.logger.error(t)}catch(t){await this.sendError(r,e,t),this.logger.error(t)}},this.onUnknownRpcMethodResponse=e=>{this.registeredMethods.includes(e)||this.logger.error($n("WC_METHOD_UNSUPPORTED",e))},this.isValidPair=e=>{if(!Qn(e)){const{message:t}=zn("MISSING_OR_INVALID",`pair() params: ${e}`);throw new Error(t)}if(!function(e){if(Vn(e,!1))try{return typeof new URL(e)<"u"}catch{return!1}return!1}(e.uri)){const{message:t}=zn("MISSING_OR_INVALID",`pair() uri: ${e.uri}`);throw new Error(t)}},this.isValidPing=async e=>{if(!Qn(e)){const{message:t}=zn("MISSING_OR_INVALID",`ping() params: ${e}`);throw new Error(t)}const{topic:t}=e;await this.isValidPairingTopic(t)},this.isValidDisconnect=async e=>{if(!Qn(e)){const{message:t}=zn("MISSING_OR_INVALID",`disconnect() params: ${e}`);throw new Error(t)}const{topic:t}=e;await this.isValidPairingTopic(t)},this.isValidPairingTopic=async e=>{if(!Vn(e,!1)){const{message:t}=zn("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(t)}if(!this.pairings.keys.includes(e)){const{message:t}=zn("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(t)}if(bn(this.pairings.get(e).expiry)){await this.deletePairing(e);const{message:t}=zn("EXPIRED",`pairing topic: ${e}`);throw new Error(t)}},this.core=e,this.logger=qi.generateChildLogger(t,this.name),this.pairings=new Fc(this.core,this.logger,this.name,this.storagePrefix)}get context(){return qi.getLoggerContext(this.logger)}isInitialized(){if(!this.initialized){const{message:e}=zn("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(Va,(async e=>{const{topic:t,message:r}=e;if(this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(r)))return;const n=await this.core.crypto.decode(t,r);Js(n)?(this.core.history.set(t,n),this.onRelayEventRequest({topic:t,payload:n})):Xs(n)&&(await this.core.history.resolve(n),await this.onRelayEventResponse({topic:t,payload:n}),this.core.history.delete(t,n.id))}))}registerExpirerEvents(){this.core.expirer.on(gc,(async e=>{const{topic:t}=mn(e.target);t&&this.pairings.keys.includes(t)&&(await this.deletePairing(t,!0),this.events.emit("pairing_expire",{topic:t}))}))}}class Wc extends Yi{constructor(t,r){super(t,r),this.core=t,this.logger=r,this.records=new Map,this.events=new e.EventEmitter,this.name="history",this.version="0.3",this.cached=[],this.initialized=!1,this.storagePrefix=Ma,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach((e=>this.records.set(e.id,e))),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.set=(e,t,r)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:e,request:t,chainId:r}),this.records.has(t.id))return;const n={id:t.id,topic:e,request:{method:t.method,params:t.params||null},chainId:r,expiry:wn(Mt.THIRTY_DAYS)};this.records.set(n.id,n),this.events.emit(uc,n)},this.resolve=async e=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:e}),!this.records.has(e.id))return;const t=await this.getRecord(e.id);typeof t.response>"u"&&(t.response=Qs(e)?{error:e.error}:{result:e.result},this.records.set(t.id,t),this.events.emit(hc,t))},this.get=async(e,t)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:e,id:t}),await this.getRecord(t)),this.delete=(e,t)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:t}),this.values.forEach((r=>{if(r.topic===e){if(typeof t<"u"&&r.id!==t)return;this.records.delete(r.id),this.events.emit(lc,r)}}))},this.exists=async(e,t)=>(this.isInitialized(),!!this.records.has(t)&&(await this.getRecord(t)).topic===e),this.on=(e,t)=>{this.events.on(e,t)},this.once=(e,t)=>{this.events.once(e,t)},this.off=(e,t)=>{this.events.off(e,t)},this.removeListener=(e,t)=>{this.events.removeListener(e,t)},this.logger=qi.generateChildLogger(r,this.name)}get context(){return qi.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){const e=[];return this.values.forEach((t=>{if(typeof t.response<"u")return;const r={topic:t.topic,request:ks(t.request.method,t.request.params,t.id),chainId:t.chainId};return e.push(r)})),e}async setJsonRpcRecords(e){await this.core.storage.setItem(this.storageKey,e)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(e){this.isInitialized();const t=this.records.get(e);if(!t){const{message:t}=zn("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(t)}return t}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(fc)}async restore(){try{const e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){const{message:e}=zn("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),new Error(e)}this.cached=e,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values})}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e)}}registerEventListeners(){this.events.on(uc,(e=>{const t=uc;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e}),this.persist()})),this.events.on(hc,(e=>{const t=hc;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e}),this.persist()})),this.events.on(lc,(e=>{const t=lc;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e}),this.persist()})),this.core.heartbeat.on(bi.HEARTBEAT_EVENTS.pulse,(()=>{this.cleanup()}))}cleanup(){try{this.records.forEach((e=>{Mt.toMiliseconds(e.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${e.id}`),this.delete(e.topic,e.id))}))}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){const{message:e}=zn("NOT_INITIALIZED",this.name);throw new Error(e)}}}class Yc extends ts{constructor(t,r){super(t,r),this.core=t,this.logger=r,this.expirations=new Map,this.events=new e.EventEmitter,this.name="expirer",this.version="0.3",this.cached=[],this.initialized=!1,this.storagePrefix=Ma,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach((e=>this.expirations.set(e.target,e))),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.has=e=>{try{const t=this.formatTarget(e);return typeof this.getExpiration(t)<"u"}catch{return!1}},this.set=(e,t)=>{this.isInitialized();const r=this.formatTarget(e),n={target:r,expiry:t};this.expirations.set(r,n),this.checkExpiry(r,n),this.events.emit(pc,{target:r,expiration:n})},this.get=e=>{this.isInitialized();const t=this.formatTarget(e);return this.getExpiration(t)},this.del=e=>{if(this.isInitialized(),this.has(e)){const t=this.formatTarget(e),r=this.getExpiration(t);this.expirations.delete(t),this.events.emit(dc,{target:t,expiration:r})}},this.on=(e,t)=>{this.events.on(e,t)},this.once=(e,t)=>{this.events.once(e,t)},this.off=(e,t)=>{this.events.off(e,t)},this.removeListener=(e,t)=>{this.events.removeListener(e,t)},this.logger=qi.generateChildLogger(r,this.name)}get context(){return qi.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(e){if("string"==typeof e)return function(e){return _n("topic",e)}(e);if("number"==typeof e)return function(e){return _n("id",e)}(e);const{message:t}=zn("UNKNOWN_TYPE","Target type: "+typeof e);throw new Error(t)}async setExpirations(e){await this.core.storage.setItem(this.storageKey,e)}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit(yc)}async restore(){try{const e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){const{message:e}=zn("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),new Error(e)}this.cached=e,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(e){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(e)}}getExpiration(e){const t=this.expirations.get(e);if(!t){const{message:t}=zn("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(t),new Error(t)}return t}checkExpiry(e,t){const{expiry:r}=t;Mt.toMiliseconds(r)-Date.now()<=0&&this.expire(e,t)}expire(e,t){this.expirations.delete(e),this.events.emit(gc,{target:e,expiration:t})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach(((e,t)=>this.checkExpiry(t,e)))}registerEventListeners(){this.core.heartbeat.on(bi.HEARTBEAT_EVENTS.pulse,(()=>this.checkExpirations())),this.events.on(pc,(e=>{const t=pc;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()})),this.events.on(gc,(e=>{const t=gc;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()})),this.events.on(dc,(e=>{const t=dc;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}))}isInitialized(){if(!this.initialized){const{message:e}=zn("NOT_INITIALIZED",this.name);throw new Error(e)}}}class Jc extends rs{constructor(e,t){super(e,t),this.projectId=e,this.logger=t,this.name=vc,this.initialized=!1,this.init=async e=>{cn()||!un()||(this.verifyUrl=e?.verifyUrl||_c,await this.createIframe())},this.register=async e=>{var t;if(this.initialized||await this.init(),this.iframe)try{null==(t=this.iframe.contentWindow)||t.postMessage(e.attestationId,this.verifyUrl),this.logger.info(`postMessage sent: ${e.attestationId} ${this.verifyUrl}`)}catch{}},this.resolve=async e=>{var t;if(this.isDevEnv)return"";this.logger.info(`resolving attestation: ${e.attestationId}`);const r=this.startAbortTimer(Mt.FIVE_SECONDS),n=await fetch(`${this.verifyUrl}/attestation/${e.attestationId}`,{signal:this.abortController.signal});return clearTimeout(r),200===n.status?null==(t=await n.json())?void 0:t.origin:""},this.createIframe=async()=>{try{await Promise.race([new Promise(((e,t)=>{if(document.getElementById(vc))return e();const r=document.createElement("iframe");r.setAttribute("id",vc),r.setAttribute("src",`${this.verifyUrl}/${this.projectId}`),r.style.display="none",r.addEventListener("load",(()=>{this.initialized=!0,e()})),r.addEventListener("error",(e=>{t(e)})),document.body.append(r),this.iframe=r})),new Promise((e=>{setTimeout((()=>e("iframe load timeout")),Mt.toMiliseconds(Mt.ONE_SECOND/2))}))])}catch(e){this.logger.error(`Verify iframe failed to load: ${this.verifyUrl}`),this.logger.error(e)}},this.logger=qi.generateChildLogger(t,this.name),this.verifyUrl=_c,this.abortController=new AbortController,this.isDevEnv=an()&&process.env.IS_VITEST}get context(){return qi.getLoggerContext(this.logger)}startAbortTimer(e){return setTimeout((()=>this.abortController.abort()),Mt.toMiliseconds(e))}}var Xc=Object.defineProperty,Zc=Object.getOwnPropertySymbols,Qc=Object.prototype.hasOwnProperty,eu=Object.prototype.propertyIsEnumerable,tu=(e,t,r)=>t in e?Xc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ru=(e,t)=>{for(var r in t||(t={}))Qc.call(t,r)&&tu(e,r,t[r]);if(Zc)for(var r of Zc(t))eu.call(t,r)&&tu(e,r,t[r]);return e};class nu extends Wi{constructor(t){super(t),this.protocol="wc",this.version=2,this.name=Ua,this.events=new e.EventEmitter,this.initialized=!1,this.on=(e,t)=>this.events.on(e,t),this.once=(e,t)=>this.events.once(e,t),this.off=(e,t)=>this.events.off(e,t),this.removeListener=(e,t)=>this.events.removeListener(e,t),this.projectId=t?.projectId,this.relayUrl=t?.relayUrl||Ha;const r=typeof t?.logger<"u"&&"string"!=typeof t?.logger?t.logger:qi.pino(qi.getDefaultLoggerOptions({level:t?.logger||Da}));this.logger=qi.generateChildLogger(r,this.name),this.heartbeat=new bi.HeartBeat,this.crypto=new wc(this,this.logger,t?.keychain),this.history=new Wc(this,this.logger),this.expirer=new Yc(this,this.logger),this.storage=null!=t&&t.storage?t.storage:new wi(ru(ru({},ka),t?.storageOptions)),this.relayer=new zc({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new Gc(this,this.logger),this.verify=new Jc(this.projectId||"",this.logger)}static async init(e){const t=new nu(e);await t.initialize();const r=await t.crypto.getClientId();return await t.storage.setItem("WALLETCONNECT_CLIENT_ID",r),t}get context(){return qi.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(e){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,e),this.logger.error(e.message),e}}}const iu=nu,su="client",ou=`wc@2:${su}:`,au=su,cu="error",uu="Proposal expired",hu=Mt.SEVEN_DAYS,lu={wc_sessionPropose:{req:{ttl:Mt.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:Mt.FIVE_MINUTES,prompt:!1,tag:1101}},wc_sessionSettle:{req:{ttl:Mt.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:Mt.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:Mt.ONE_DAY,prompt:!1,tag:1104},res:{ttl:Mt.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:Mt.ONE_DAY,prompt:!1,tag:1106},res:{ttl:Mt.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:Mt.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:Mt.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:Mt.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:Mt.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:Mt.ONE_DAY,prompt:!1,tag:1112},res:{ttl:Mt.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:Mt.THIRTY_SECONDS,prompt:!1,tag:1114},res:{ttl:Mt.THIRTY_SECONDS,prompt:!1,tag:1115}}},fu={min:Mt.FIVE_MINUTES,max:Mt.SEVEN_DAYS},pu=["wc_sessionPropose","wc_sessionRequest","wc_authRequest"];var du=Object.defineProperty,gu=Object.defineProperties,yu=Object.getOwnPropertyDescriptors,vu=Object.getOwnPropertySymbols,_u=Object.prototype.hasOwnProperty,mu=Object.prototype.propertyIsEnumerable,wu=(e,t,r)=>t in e?du(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,bu=(e,t)=>{for(var r in t||(t={}))_u.call(t,r)&&wu(e,r,t[r]);if(vu)for(var r of vu(t))mu.call(t,r)&&wu(e,r,t[r]);return e},Eu=(e,t)=>gu(e,yu(t));class Su extends is{constructor(e){super(e),this.name="engine",this.events=new i.default,this.initialized=!1,this.ignoredPayloadTypes=[zr],this.init=async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.client.core.pairing.register({methods:Object.keys(lu)}),this.initialized=!0)},this.connect=async e=>{this.isInitialized();const t=Eu(bu({},e),{requiredNamespaces:e.requiredNamespaces||{},optionalNamespaces:e.optionalNamespaces||{}});await this.isValidConnect(t);const{pairingTopic:r,requiredNamespaces:n,optionalNamespaces:i,sessionProperties:s,relays:o}=t;let a,c=r,u=!1;if(c&&(u=this.client.core.pairing.pairings.get(c).active),!c||!u){const{topic:e,uri:t}=await this.client.core.pairing.create();c=e,a=t}const h=await this.client.core.crypto.generateKeyPair(),l=bu({requiredNamespaces:n,optionalNamespaces:i,relays:o??[{protocol:"irn"}],proposer:{publicKey:h,metadata:this.client.metadata}},s&&{sessionProperties:s}),{reject:f,resolve:p,done:d}=yn(Mt.FIVE_MINUTES,uu);if(this.events.once(En("session_connect"),(async({error:e,session:t})=>{if(e)f(e);else if(t){t.self.publicKey=h;const e=Eu(bu({},t),{requiredNamespaces:t.requiredNamespaces,optionalNamespaces:t.optionalNamespaces});await this.client.session.set(t.topic,e),await this.setExpiry(t.topic,t.expiry),c&&await this.client.core.pairing.updateMetadata({topic:c,metadata:t.peer.metadata}),p(e)}})),!c){const{message:e}=zn("NO_MATCHING_KEY",`connect() pairing topic: ${c}`);throw new Error(e)}const g=await this.sendRequest(c,"wc_sessionPropose",l),y=wn(Mt.FIVE_MINUTES);return await this.setProposal(g,bu({id:g,expiry:y},l)),{uri:a,approval:d}},this.pair=async e=>(this.isInitialized(),await this.client.core.pairing.pair(e)),this.approve=async e=>{this.isInitialized(),await this.isValidApprove(e);const{id:t,relayProtocol:r,namespaces:n,sessionProperties:i}=e,s=this.client.proposal.get(t);let{pairingTopic:o,proposer:a,requiredNamespaces:c,optionalNamespaces:u}=s;o=o||"",Hn(c)||(c=function(e,t){const r=Xn(e,t);if(r)throw new Error(r.message);const n={};for(const[t,r]of Object.entries(e))n[t]={methods:r.methods,events:r.events,chains:r.accounts.map((e=>`${e.split(":")[0]}:${e.split(":")[1]}`))};return n}(n,"approve()"));const h=await this.client.core.crypto.generateKeyPair(),l=a.publicKey,f=await this.client.core.crypto.generateSharedKey(h,l);o&&t&&(await this.client.core.pairing.updateMetadata({topic:o,metadata:a.metadata}),await this.sendResult(t,o,{relay:{protocol:r??"irn"},responderPublicKey:h}),await this.client.proposal.delete(t,$n("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:o}));const p=bu({relay:{protocol:r??"irn"},namespaces:n,requiredNamespaces:c,optionalNamespaces:u,pairingTopic:o,controller:{publicKey:h,metadata:this.client.metadata},expiry:wn(hu)},i&&{sessionProperties:i});await this.client.core.relayer.subscribe(f),await this.sendRequest(f,"wc_sessionSettle",p);const d=Eu(bu({},p),{topic:f,pairingTopic:o,acknowledged:!1,self:p.controller,peer:{publicKey:a.publicKey,metadata:a.metadata},controller:h});return await this.client.session.set(f,d),await this.setExpiry(f,wn(hu)),{topic:f,acknowledged:()=>new Promise((e=>setTimeout((()=>e(this.client.session.get(f))),500)))}},this.reject=async e=>{this.isInitialized(),await this.isValidReject(e);const{id:t,reason:r}=e,{pairingTopic:n}=this.client.proposal.get(t);n&&(await this.sendError(t,n,r),await this.client.proposal.delete(t,$n("USER_DISCONNECTED")))},this.update=async e=>{this.isInitialized(),await this.isValidUpdate(e);const{topic:t,namespaces:r}=e,n=await this.sendRequest(t,"wc_sessionUpdate",{namespaces:r}),{done:i,resolve:s,reject:o}=yn();return this.events.once(En("session_update",n),(({error:e})=>{e?o(e):s()})),await this.client.session.update(t,{namespaces:r}),{acknowledged:i}},this.extend=async e=>{this.isInitialized(),await this.isValidExtend(e);const{topic:t}=e,r=await this.sendRequest(t,"wc_sessionExtend",{}),{done:n,resolve:i,reject:s}=yn();return this.events.once(En("session_extend",r),(({error:e})=>{e?s(e):i()})),await this.setExpiry(t,wn(hu)),{acknowledged:n}},this.request=async e=>{this.isInitialized(),await this.isValidRequest(e);const{chainId:t,request:r,topic:n,expiry:i}=e,s=await this.sendRequest(n,"wc_sessionRequest",{request:r,chainId:t},i),{done:o,resolve:a,reject:c}=yn(i);this.events.once(En("session_request",s),(({error:e,result:t})=>{e?c(e):a(t)})),this.client.events.emit("session_request_sent",{topic:n,request:r,chainId:t,id:s});return async function({id:e,topic:t,wcDeepLink:r}){try{if(!r)return;const n="string"==typeof r?JSON.parse(r):r;let i=n?.href;if("string"!=typeof i)return;i.endsWith("/")&&(i=i.slice(0,-1));const s=`${i}/wc?requestId=${e}&sessionTopic=${t}`,o=hn();o===sn.browser?s.startsWith("https://")?window.open(s,"_blank","noreferrer noopener"):window.open(s,"_self","noreferrer noopener"):o===sn.reactNative&&typeof(null==global?void 0:global.Linking)<"u"&&await global.Linking.openURL(s)}catch(e){console.error(e)}}({id:s,topic:n,wcDeepLink:await this.client.core.storage.getItem("WALLETCONNECT_DEEPLINK_CHOICE")}),await o()},this.respond=async e=>{this.isInitialized(),await this.isValidRespond(e);const{topic:t,response:r}=e,{id:n}=r;Zs(r)?await this.sendResult(n,t,r.result):Qs(r)&&await this.sendError(n,t,r.error),this.deletePendingSessionRequest(e.response.id,{message:"fulfilled",code:0})},this.ping=async e=>{this.isInitialized(),await this.isValidPing(e);const{topic:t}=e;if(this.client.session.keys.includes(t)){const e=await this.sendRequest(t,"wc_sessionPing",{}),{done:r,resolve:n,reject:i}=yn();this.events.once(En("session_ping",e),(({error:e})=>{e?i(e):n()})),await r()}else this.client.core.pairing.pairings.keys.includes(t)&&await this.client.core.pairing.ping({topic:t})},this.emit=async e=>{this.isInitialized(),await this.isValidEmit(e);const{topic:t,event:r,chainId:n}=e;await this.sendRequest(t,"wc_sessionEvent",{event:r,chainId:n})},this.disconnect=async e=>{this.isInitialized(),await this.isValidDisconnect(e);const{topic:t}=e;if(this.client.session.keys.includes(t)){const e=Ds().toString();let r;const n=t=>{t?.id.toString()===e&&(this.client.core.relayer.events.removeListener(Ba,n),r())};await Promise.all([new Promise((e=>{r=e,this.client.core.relayer.on(Ba,n)})),this.sendRequest(t,"wc_sessionDelete",$n("USER_DISCONNECTED"),void 0,e)]),await this.deleteSession(t)}else await this.client.core.pairing.disconnect({topic:t})},this.find=e=>(this.isInitialized(),this.client.session.getAll().filter((t=>function(e,t){const{requiredNamespaces:r}=t,n=Object.keys(e.namespaces),i=Object.keys(r);let s=!0;return!!pn(i,n)&&(n.forEach((t=>{const{accounts:n,methods:i,events:o}=e.namespaces[t],a=Ln(n),c=r[t];pn(jr(t,c),a)&&pn(c.methods,i)&&pn(c.events,o)||(s=!1)})),s)}(t,e)))),this.getPendingSessionRequests=()=>(this.isInitialized(),this.client.pendingRequest.getAll()),this.cleanupDuplicatePairings=async e=>{if(e.pairingTopic)try{const t=this.client.core.pairing.pairings.get(e.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)===e.peer.metadata.url&&r.topic&&r.topic!==t.topic}));if(0===r.length)return;this.client.logger.info(`Cleaning up ${r.length} duplicate pairing(s)`),await Promise.all(r.map((e=>this.client.core.pairing.disconnect({topic:e.topic})))),this.client.logger.info("Duplicate pairings clean up finished")}catch(e){this.client.logger.error(e)}},this.deleteSession=async(e,t)=>{const{self:r}=this.client.session.get(e);await this.client.core.relayer.unsubscribe(e),this.client.session.delete(e,$n("USER_DISCONNECTED")),this.client.core.crypto.keychain.has(r.publicKey)&&await this.client.core.crypto.deleteKeyPair(r.publicKey),this.client.core.crypto.keychain.has(e)&&await this.client.core.crypto.deleteSymKey(e),t||this.client.core.expirer.del(e)},this.deleteProposal=async(e,t)=>{await Promise.all([this.client.proposal.delete(e,$n("USER_DISCONNECTED")),t?Promise.resolve():this.client.core.expirer.del(e)])},this.deletePendingSessionRequest=async(e,t,r=!1)=>{await Promise.all([this.client.pendingRequest.delete(e,t),r?Promise.resolve():this.client.core.expirer.del(e)])},this.setExpiry=async(e,t)=>{this.client.session.keys.includes(e)&&await this.client.session.update(e,{expiry:t}),this.client.core.expirer.set(e,t)},this.setProposal=async(e,t)=>{await this.client.proposal.set(e,t),this.client.core.expirer.set(e,t.expiry)},this.setPendingSessionRequest=async e=>{const t=lu.wc_sessionRequest.req.ttl,{id:r,topic:n,params:i}=e;await this.client.pendingRequest.set(r,{id:r,topic:n,params:i}),t&&this.client.core.expirer.set(r,wn(t))},this.sendRequest=async(e,t,r,n,i)=>{const s=ks(t,r);if(un()&&pu.includes(t)){const e=Br(JSON.stringify(s));await this.client.core.verify.register({attestationId:e})}const o=await this.client.core.crypto.encode(e,s),a=lu[t].req;return n&&(a.ttl=n),i&&(a.id=i),this.client.core.history.set(e,s),this.client.core.relayer.publish(e,o,a),s.id},this.sendResult=async(e,t,r)=>{const n=zs(e,r),i=await this.client.core.crypto.encode(t,n),s=await this.client.core.history.get(t,e),o=lu[s.request.method].res;this.client.core.relayer.publish(t,i,o),await this.client.core.history.resolve(n)},this.sendError=async(e,t,r)=>{const n=$s(e,r),i=await this.client.core.crypto.encode(t,n),s=await this.client.core.history.get(t,e),o=lu[s.request.method].res;this.client.core.relayer.publish(t,i,o),await this.client.core.history.resolve(n)},this.cleanup=async()=>{const e=[],t=[];this.client.session.getAll().forEach((t=>{bn(t.expiry)&&e.push(t.topic)})),this.client.proposal.getAll().forEach((e=>{bn(e.expiry)&&t.push(e.id)})),await Promise.all([...e.map((e=>this.deleteSession(e))),...t.map((e=>this.deleteProposal(e)))])},this.onRelayEventRequest=e=>{const{topic:t,payload:r}=e,n=r.method;switch(n){case"wc_sessionPropose":return this.onSessionProposeRequest(t,r);case"wc_sessionSettle":return this.onSessionSettleRequest(t,r);case"wc_sessionUpdate":return this.onSessionUpdateRequest(t,r);case"wc_sessionExtend":return this.onSessionExtendRequest(t,r);case"wc_sessionPing":return this.onSessionPingRequest(t,r);case"wc_sessionDelete":return this.onSessionDeleteRequest(t,r);case"wc_sessionRequest":return this.onSessionRequest(t,r);case"wc_sessionEvent":return this.onSessionEventRequest(t,r);default:return this.client.logger.info(`Unsupported request method ${n}`)}},this.onRelayEventResponse=async e=>{const{topic:t,payload:r}=e,n=(await this.client.core.history.get(t,r.id)).request.method;switch(n){case"wc_sessionPropose":return this.onSessionProposeResponse(t,r);case"wc_sessionSettle":return this.onSessionSettleResponse(t,r);case"wc_sessionUpdate":return this.onSessionUpdateResponse(t,r);case"wc_sessionExtend":return this.onSessionExtendResponse(t,r);case"wc_sessionPing":return this.onSessionPingResponse(t,r);case"wc_sessionRequest":return this.onSessionRequestResponse(t,r);default:return this.client.logger.info(`Unsupported response method ${n}`)}},this.onRelayEventUnknownPayload=e=>{const{topic:t}=e,{message:r}=zn("MISSING_OR_INVALID",`Decoded payload on topic ${t} is not identifiable as a JSON-RPC request or a response.`);throw new Error(r)},this.onSessionProposeRequest=async(e,t)=>{const{params:r,id:n}=t;try{this.isValidConnect(bu({},t.params));const i=wn(Mt.FIVE_MINUTES),s=bu({id:n,pairingTopic:e,expiry:i},r);await this.setProposal(n,s);const o=Br(JSON.stringify(t)),a=await this.getVerifyContext(o,s.proposer.metadata);this.client.events.emit("session_proposal",{id:n,params:s,verifyContext:a})}catch(t){await this.sendError(n,e,t),this.client.logger.error(t)}},this.onSessionProposeResponse=async(e,t)=>{const{id:r}=t;if(Zs(t)){const{result:n}=t;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:e})}else Qs(t)&&(await this.client.proposal.delete(r,$n("USER_DISCONNECTED")),this.events.emit(En("session_connect"),{error:t.error}))},this.onSessionSettleRequest=async(e,t)=>{const{id:r,params:n}=t;try{this.isValidSessionSettleRequest(n);const{relay:r,controller:i,expiry:s,namespaces:o,requiredNamespaces:a,optionalNamespaces:c,sessionProperties:u,pairingTopic:h}=t.params,l=bu({topic:e,relay:r,expiry:s,namespaces:o,acknowledged:!0,pairingTopic:h,requiredNamespaces:a,optionalNamespaces:c,controller:i.publicKey,self:{publicKey:"",metadata:this.client.metadata},peer:{publicKey:i.publicKey,metadata:i.metadata}},u&&{sessionProperties:u});await this.sendResult(t.id,e,!0),this.events.emit(En("session_connect"),{session:l}),this.cleanupDuplicatePairings(l)}catch(t){await this.sendError(r,e,t),this.client.logger.error(t)}},this.onSessionSettleResponse=async(e,t)=>{const{id:r}=t;Zs(t)?(await this.client.session.update(e,{acknowledged:!0}),this.events.emit(En("session_approve",r),{})):Qs(t)&&(await this.client.session.delete(e,$n("USER_DISCONNECTED")),this.events.emit(En("session_approve",r),{error:t.error}))},this.onSessionUpdateRequest=async(e,t)=>{const{params:r,id:n}=t;try{this.isValidUpdate(bu({topic:e},r)),await this.client.session.update(e,{namespaces:r.namespaces}),await this.sendResult(n,e,!0),this.client.events.emit("session_update",{id:n,topic:e,params:r})}catch(t){await this.sendError(n,e,t),this.client.logger.error(t)}},this.onSessionUpdateResponse=(e,t)=>{const{id:r}=t;Zs(t)?this.events.emit(En("session_update",r),{}):Qs(t)&&this.events.emit(En("session_update",r),{error:t.error})},this.onSessionExtendRequest=async(e,t)=>{const{id:r}=t;try{this.isValidExtend({topic:e}),await this.setExpiry(e,wn(hu)),await this.sendResult(r,e,!0),this.client.events.emit("session_extend",{id:r,topic:e})}catch(t){await this.sendError(r,e,t),this.client.logger.error(t)}},this.onSessionExtendResponse=(e,t)=>{const{id:r}=t;Zs(t)?this.events.emit(En("session_extend",r),{}):Qs(t)&&this.events.emit(En("session_extend",r),{error:t.error})},this.onSessionPingRequest=async(e,t)=>{const{id:r}=t;try{this.isValidPing({topic:e}),await this.sendResult(r,e,!0),this.client.events.emit("session_ping",{id:r,topic:e})}catch(t){await this.sendError(r,e,t),this.client.logger.error(t)}},this.onSessionPingResponse=(e,t)=>{const{id:r}=t;setTimeout((()=>{Zs(t)?this.events.emit(En("session_ping",r),{}):Qs(t)&&this.events.emit(En("session_ping",r),{error:t.error})}),500)},this.onSessionDeleteRequest=async(e,t)=>{const{id:r}=t;try{this.isValidDisconnect({topic:e,reason:t.params}),await Promise.all([new Promise((t=>{this.client.core.relayer.once(Xa,(async()=>{t(await this.deleteSession(e))}))})),this.sendResult(r,e,!0)]),this.client.events.emit("session_delete",{id:r,topic:e})}catch(e){this.client.logger.error(e)}},this.onSessionRequest=async(e,t)=>{const{id:r,params:n}=t;try{this.isValidRequest(bu({topic:e},n)),await this.setPendingSessionRequest({id:r,topic:e,params:n});const i=Br(JSON.stringify(t)),s=this.client.session.get(e),o=await this.getVerifyContext(i,s.peer.metadata);this.client.events.emit("session_request",{id:r,topic:e,params:n,verifyContext:o})}catch(t){await this.sendError(r,e,t),this.client.logger.error(t)}},this.onSessionRequestResponse=(e,t)=>{const{id:r}=t;Zs(t)?this.events.emit(En("session_request",r),{result:t.result}):Qs(t)&&this.events.emit(En("session_request",r),{error:t.error})},this.onSessionEventRequest=async(e,t)=>{const{id:r,params:n}=t;try{this.isValidEmit(bu({topic:e},n)),this.client.events.emit("session_event",{id:r,topic:e,params:n})}catch(t){await this.sendError(r,e,t),this.client.logger.error(t)}},this.isValidConnect=async e=>{if(!Qn(e)){const{message:t}=zn("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(e)}`);throw new Error(t)}const{pairingTopic:t,requiredNamespaces:r,optionalNamespaces:n,sessionProperties:i,relays:s}=e;if(Kn(t)||await this.isValidPairingTopic(t),!function(e,t){let r=!1;return t&&!e?r=!0:e&&qn(e)&&e.length&&e.forEach((e=>{r=Zn(e)})),r}(s,!0)){const{message:e}=zn("MISSING_OR_INVALID",`connect() relays: ${s}`);throw new Error(e)}!Kn(r)&&0!==Hn(r)&&this.validateNamespaces(r,"requiredNamespaces"),!Kn(n)&&0!==Hn(n)&&this.validateNamespaces(n,"optionalNamespaces"),Kn(i)||this.validateSessionProps(i,"sessionProperties")},this.validateNamespaces=(e,t)=>{const r=function(e,t,r){let n=null;if(e&&Hn(e)){const i=Jn(e,t);i&&(n=i);const s=Wn(e,t,r);s&&(n=s)}else n=zn("MISSING_OR_INVALID",`${t}, ${r} should be an object with data`);return n}(e,"connect()",t);if(r)throw new Error(r.message)},this.isValidApprove=async e=>{if(!Qn(e))throw new Error(zn("MISSING_OR_INVALID",`approve() params: ${e}`).message);const{id:t,namespaces:r,relayProtocol:n,sessionProperties:i}=e;await this.isValidProposalId(t);const s=this.client.proposal.get(t),o=Xn(r,"approve()");if(o)throw new Error(o.message);const a=ni(s.requiredNamespaces,r,"approve()");if(a)throw new Error(a.message);if(!Vn(n,!0)){const{message:e}=zn("MISSING_OR_INVALID",`approve() relayProtocol: ${n}`);throw new Error(e)}Kn(i)||this.validateSessionProps(i,"sessionProperties")},this.isValidReject=async e=>{if(!Qn(e)){const{message:t}=zn("MISSING_OR_INVALID",`reject() params: ${e}`);throw new Error(t)}const{id:t,reason:r}=e;if(await this.isValidProposalId(t),!function(e){return!!(e&&"object"==typeof e&&e.code&&Bn(e.code,!1)&&e.message&&Vn(e.message,!1))}(r)){const{message:e}=zn("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(r)}`);throw new Error(e)}},this.isValidSessionSettleRequest=e=>{if(!Qn(e)){const{message:t}=zn("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${e}`);throw new Error(t)}const{relay:t,controller:r,namespaces:n,expiry:i}=e;if(!Zn(t)){const{message:e}=zn("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(e)}const s=function(e,t){let r=null;return Vn(e?.publicKey,!1)||(r=zn("MISSING_OR_INVALID",`${t} controller public key should be a string`)),r}(r,"onSessionSettleRequest()");if(s)throw new Error(s.message);const o=Xn(n,"onSessionSettleRequest()");if(o)throw new Error(o.message);if(bn(i)){const{message:e}=zn("EXPIRED","onSessionSettleRequest()");throw new Error(e)}},this.isValidUpdate=async e=>{if(!Qn(e)){const{message:t}=zn("MISSING_OR_INVALID",`update() params: ${e}`);throw new Error(t)}const{topic:t,namespaces:r}=e;await this.isValidSessionTopic(t);const n=this.client.session.get(t),i=Xn(r,"update()");if(i)throw new Error(i.message);const s=ni(n.requiredNamespaces,r,"update()");if(s)throw new Error(s.message)},this.isValidExtend=async e=>{if(!Qn(e)){const{message:t}=zn("MISSING_OR_INVALID",`extend() params: ${e}`);throw new Error(t)}const{topic:t}=e;await this.isValidSessionTopic(t)},this.isValidRequest=async e=>{if(!Qn(e)){const{message:t}=zn("MISSING_OR_INVALID",`request() params: ${e}`);throw new Error(t)}const{topic:t,request:r,chainId:n,expiry:i}=e;await this.isValidSessionTopic(t);const{namespaces:s}=this.client.session.get(t);if(!ei(s,n)){const{message:e}=zn("MISSING_OR_INVALID",`request() chainId: ${n}`);throw new Error(e)}if(!function(e){return!(Kn(e)||!Vn(e.method,!1))}(r)){const{message:e}=zn("MISSING_OR_INVALID",`request() ${JSON.stringify(r)}`);throw new Error(e)}if(!ti(s,n,r.method)){const{message:e}=zn("MISSING_OR_INVALID",`request() method: ${r.method}`);throw new Error(e)}if(i&&!function(e,t){return Bn(e,!1)&&e<=t.max&&e>=t.min}(i,fu)){const{message:e}=zn("MISSING_OR_INVALID",`request() expiry: ${i}. Expiry must be a number (in seconds) between ${fu.min} and ${fu.max}`);throw new Error(e)}},this.isValidRespond=async e=>{if(!Qn(e)){const{message:t}=zn("MISSING_OR_INVALID",`respond() params: ${e}`);throw new Error(t)}const{topic:t,response:r}=e;if(await this.isValidSessionTopic(t),!function(e){return!(Kn(e)||Kn(e.result)&&Kn(e.error)||!Bn(e.id,!1)||!Vn(e.jsonrpc,!1))}(r)){const{message:e}=zn("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(r)}`);throw new Error(e)}},this.isValidPing=async e=>{if(!Qn(e)){const{message:t}=zn("MISSING_OR_INVALID",`ping() params: ${e}`);throw new Error(t)}const{topic:t}=e;await this.isValidSessionOrPairingTopic(t)},this.isValidEmit=async e=>{if(!Qn(e)){const{message:t}=zn("MISSING_OR_INVALID",`emit() params: ${e}`);throw new Error(t)}const{topic:t,event:r,chainId:n}=e;await this.isValidSessionTopic(t);const{namespaces:i}=this.client.session.get(t);if(!ei(i,n)){const{message:e}=zn("MISSING_OR_INVALID",`emit() chainId: ${n}`);throw new Error(e)}if(!function(e){return!(Kn(e)||!Vn(e.name,!1))}(r)){const{message:e}=zn("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(r)}`);throw new Error(e)}if(!ri(i,n,r.name)){const{message:e}=zn("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(r)}`);throw new Error(e)}},this.isValidDisconnect=async e=>{if(!Qn(e)){const{message:t}=zn("MISSING_OR_INVALID",`disconnect() params: ${e}`);throw new Error(t)}const{topic:t}=e;await this.isValidSessionOrPairingTopic(t)},this.getVerifyContext=async(e,t)=>{const r={verified:{verifyUrl:t.verifyUrl||"",validation:"UNKNOWN",origin:t.url||""}};try{const n=await this.client.core.verify.resolve({attestationId:e,verifyUrl:t.verifyUrl});n&&(r.verified.origin=n,r.verified.validation=n===t.url?"VALID":"INVALID")}catch(e){this.client.logger.error(e)}return this.client.logger.info(`Verify context: ${JSON.stringify(r)}`),r},this.validateSessionProps=(e,t)=>{Object.values(e).forEach((e=>{if(!Vn(e,!1)){const{message:r}=zn("MISSING_OR_INVALID",`${t} must be in Record<string, string> format. Received: ${JSON.stringify(e)}`);throw new Error(r)}}))}}isInitialized(){if(!this.initialized){const{message:e}=zn("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.client.core.relayer.on(Va,(async e=>{const{topic:t,message:r}=e;if(this.ignoredPayloadTypes.includes(this.client.core.crypto.getPayloadType(r)))return;const n=await this.client.core.crypto.decode(t,r);Js(n)?(this.client.core.history.set(t,n),this.onRelayEventRequest({topic:t,payload:n})):Xs(n)?(await this.client.core.history.resolve(n),await this.onRelayEventResponse({topic:t,payload:n}),this.client.core.history.delete(t,n.id)):this.onRelayEventUnknownPayload({topic:t,payload:n})}))}registerExpirerEvents(){this.client.core.expirer.on(gc,(async e=>{const{topic:t,id:r}=mn(e.target);if(r&&this.client.pendingRequest.keys.includes(r))return await this.deletePendingSessionRequest(r,zn("EXPIRED"),!0);t?this.client.session.keys.includes(t)&&(await this.deleteSession(t,!0),this.client.events.emit("session_expire",{topic:t})):r&&(await this.deleteProposal(r,!0),this.client.events.emit("proposal_expire",{id:r}))}))}isValidPairingTopic(e){if(!Vn(e,!1)){const{message:t}=zn("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(t)}if(!this.client.core.pairing.pairings.keys.includes(e)){const{message:t}=zn("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(t)}if(bn(this.client.core.pairing.pairings.get(e).expiry)){const{message:t}=zn("EXPIRED",`pairing topic: ${e}`);throw new Error(t)}}async isValidSessionTopic(e){if(!Vn(e,!1)){const{message:t}=zn("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw new Error(t)}if(!this.client.session.keys.includes(e)){const{message:t}=zn("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(t)}if(bn(this.client.session.get(e).expiry)){await this.deleteSession(e);const{message:t}=zn("EXPIRED",`session topic: ${e}`);throw new Error(t)}}async isValidSessionOrPairingTopic(e){if(this.client.session.keys.includes(e))await this.isValidSessionTopic(e);else{if(!this.client.core.pairing.pairings.keys.includes(e)){if(Vn(e,!1)){const{message:t}=zn("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(t)}{const{message:t}=zn("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(t)}}this.isValidPairingTopic(e)}}async isValidProposalId(e){if("number"!=typeof e){const{message:t}=zn("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(t)}if(!this.client.proposal.keys.includes(e)){const{message:t}=zn("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(t)}if(bn(this.client.proposal.get(e).expiry)){await this.deleteProposal(e);const{message:t}=zn("EXPIRED",`proposal id: ${e}`);throw new Error(t)}}}class Iu extends Fc{constructor(e,t){super(e,t,"proposal",ou),this.core=e,this.logger=t}}class Ou extends Fc{constructor(e,t){super(e,t,"session",ou),this.core=e,this.logger=t}}class Pu extends Fc{constructor(e,t){super(e,t,"request",ou,(e=>e.id)),this.core=e,this.logger=t}}class Nu extends ns{constructor(t){super(t),this.protocol="wc",this.version=2,this.name=au,this.events=new e.EventEmitter,this.on=(e,t)=>this.events.on(e,t),this.once=(e,t)=>this.events.once(e,t),this.off=(e,t)=>this.events.off(e,t),this.removeListener=(e,t)=>this.events.removeListener(e,t),this.removeAllListeners=e=>this.events.removeAllListeners(e),this.connect=async e=>{try{return await this.engine.connect(e)}catch(e){throw this.logger.error(e.message),e}},this.pair=async e=>{try{return await this.engine.pair(e)}catch(e){throw this.logger.error(e.message),e}},this.approve=async e=>{try{return await this.engine.approve(e)}catch(e){throw this.logger.error(e.message),e}},this.reject=async e=>{try{return await this.engine.reject(e)}catch(e){throw this.logger.error(e.message),e}},this.update=async e=>{try{return await this.engine.update(e)}catch(e){throw this.logger.error(e.message),e}},this.extend=async e=>{try{return await this.engine.extend(e)}catch(e){throw this.logger.error(e.message),e}},this.request=async e=>{try{return await this.engine.request(e)}catch(e){throw this.logger.error(e.message),e}},this.respond=async e=>{try{return await this.engine.respond(e)}catch(e){throw this.logger.error(e.message),e}},this.ping=async e=>{try{return await this.engine.ping(e)}catch(e){throw this.logger.error(e.message),e}},this.emit=async e=>{try{return await this.engine.emit(e)}catch(e){throw this.logger.error(e.message),e}},this.disconnect=async e=>{try{return await this.engine.disconnect(e)}catch(e){throw this.logger.error(e.message),e}},this.find=e=>{try{return this.engine.find(e)}catch(e){throw this.logger.error(e.message),e}},this.getPendingSessionRequests=()=>{try{return this.engine.getPendingSessionRequests()}catch(e){throw this.logger.error(e.message),e}},this.name=t?.name||au,this.metadata=t?.metadata||wr()||{name:"",description:"",url:"",icons:[""]};const r=typeof t?.logger<"u"&&"string"!=typeof t?.logger?t.logger:qi.pino(qi.getDefaultLoggerOptions({level:t?.logger||cu}));this.core=t?.core||new iu(t),this.logger=qi.generateChildLogger(r,this.name),this.session=new Ou(this.core,this.logger),this.proposal=new Iu(this.core,this.logger),this.pendingRequest=new Pu(this.core,this.logger),this.engine=new Su(this)}static async init(e){const t=new Nu(e);return await t.initialize(),t}get context(){return qi.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(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}}const Au={headers:{Accept:"application/json","Content-Type":"application/json"},method:"POST"};class xu{constructor(t,r=!1){if(this.url=t,this.disableProviderPing=r,this.events=new e.EventEmitter,this.isAvailable=!1,this.registering=!1,!Fs(t))throw new Error(`Provided URL is not compatible with HTTP connection: ${t}`);this.url=t,this.disableProviderPing=r}get connected(){return this.isAvailable}get connecting(){return this.registering}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async open(e=this.url){await this.register(e)}async close(){if(!this.isAvailable)throw new Error("Connection already closed");this.onClose()}async send(e,t){this.isAvailable||await this.register();try{const t=as(e),n=await r.m(this.url,Object.assign(Object.assign({},Au),{body:t})),i=await n.json();this.onPayload({data:i})}catch(t){this.onError(e.id,t)}}async register(e=this.url){if(!Fs(e))throw new Error(`Provided URL is not compatible with HTTP connection: ${e}`);if(this.registering){const e=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=e||this.events.listenerCount("open")>=e)&&this.events.setMaxListeners(e+1),new Promise(((e,t)=>{this.events.once("register_error",(e=>{this.resetMaxListeners(),t(e)})),this.events.once("open",(()=>{if(this.resetMaxListeners(),void 0===this.isAvailable)return t(new Error("HTTP connection is missing or invalid"));e()}))}))}this.url=e,this.registering=!0;try{if(!this.disableProviderPing){const t=as({id:1,jsonrpc:"2.0",method:"test",params:[]});await r.m(e,Object.assign(Object.assign({},Au),{body:t}))}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(e){if(void 0===e.data)return;const t="string"==typeof e.data?os(e.data):e.data;this.events.emit("payload",t)}onError(e,t){const r=this.parseError(t),n=$s(e,r.message||r.toString());this.events.emit("payload",n)}parseError(e,t=this.url){return Cs(e,t,"HTTP")}resetMaxListeners(){this.events.getMaxListeners()>10&&this.events.setMaxListeners(10)}}const Cu="error",Tu="wc@2:universal_provider:",Ru="default_chain_changed";var ju=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Lu={exports:{}};
|
|
2
2
|
/**
|
|
3
3
|
* @license
|
|
4
4
|
* Lodash <https://lodash.com/>
|