@dodoex/wallet-web3 0.0.29-6 → 0.0.29-7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. package/dist/blocto-d6293657.js +1 -0
  2. package/dist/cjs/blocto-e9bf58fa.cjs +1 -0
  3. package/dist/cjs/index-1354d7e8.cjs +1 -0
  4. package/dist/cjs/index-63d300ec.cjs +1 -0
  5. package/dist/cjs/index-8c700a55.cjs +1 -0
  6. package/dist/cjs/index-989416c1.cjs +1 -0
  7. package/dist/cjs/index-c2c42732.cjs +1 -0
  8. package/dist/cjs/index-d8fc3c99.cjs +1 -0
  9. package/dist/cjs/index-ef71c3c8.cjs +1 -0
  10. package/dist/cjs/index.cjs +1 -1
  11. package/dist/cjs/portis-467ef4c7.cjs +1 -0
  12. package/dist/cjs/provider-ee630d25.cjs +1 -0
  13. package/dist/cjs/providers/connector/types.d.ts +1 -3
  14. package/dist/cjs/rainbow-38b97031.cjs +1 -0
  15. package/dist/cjs/uAuth-e5a47064.cjs +1 -0
  16. package/dist/cjs/walletConnect-e87d9be4.cjs +1 -0
  17. package/dist/cjs/walletLink-16846665.cjs +1 -0
  18. package/dist/index-537a5554.js +1 -0
  19. package/dist/index-6c1eb673.js +1 -0
  20. package/dist/index-7895b777.js +1 -0
  21. package/dist/index-818478a2.js +1 -0
  22. package/dist/index-884930de.js +1 -0
  23. package/dist/index-96e33e44.js +1 -0
  24. package/dist/index-af95d75e.js +1 -0
  25. package/dist/index.js +1 -1
  26. package/dist/portis-ba0969b7.js +1 -0
  27. package/dist/provider-b3484da8.js +1 -0
  28. package/dist/providers/connector/types.d.ts +1 -3
  29. package/dist/rainbow-dee60896.js +1 -0
  30. package/dist/uAuth-4769b415.js +1 -0
  31. package/dist/walletConnect-165d0a6c.js +1 -0
  32. package/dist/walletLink-d5953c50.js +1 -0
  33. package/package.json +3 -2
  34. package/dist/__node-resolve_empty-1bb86108.js +0 -1
  35. package/dist/__tslib-6f859a10.js +0 -1
  36. package/dist/_commonjs-dynamic-modules-7cfc9805.js +0 -1
  37. package/dist/blocto-6fdd2522.js +0 -7
  38. package/dist/bn-3c1372bb.js +0 -1
  39. package/dist/browser-ponyfill-e86d50ae.js +0 -1
  40. package/dist/cjs/__node-resolve_empty-b9b68f61.cjs +0 -1
  41. package/dist/cjs/__tslib-5e95569a.cjs +0 -1
  42. package/dist/cjs/_commonjs-dynamic-modules-f09a98c7.cjs +0 -1
  43. package/dist/cjs/blocto-a9a7429a.cjs +0 -7
  44. package/dist/cjs/bn-f79633bb.cjs +0 -1
  45. package/dist/cjs/browser-ponyfill-262b9a1d.cjs +0 -1
  46. package/dist/cjs/ethers-2e33277b.cjs +0 -1
  47. package/dist/cjs/hash-282034e6.cjs +0 -1
  48. package/dist/cjs/id-ce261f66.cjs +0 -1
  49. package/dist/cjs/index-040d72a4.cjs +0 -1
  50. package/dist/cjs/index-269c7834.cjs +0 -1
  51. package/dist/cjs/index-46767b56.cjs +0 -9
  52. package/dist/cjs/index-6286567d.cjs +0 -66
  53. package/dist/cjs/index-70269942.cjs +0 -1
  54. package/dist/cjs/index-839d2b51.cjs +0 -1
  55. package/dist/cjs/index-8bbd780e.cjs +0 -1
  56. package/dist/cjs/index-92dad595.cjs +0 -1
  57. package/dist/cjs/index-a7b876c9.cjs +0 -1
  58. package/dist/cjs/index-b300045d.cjs +0 -15
  59. package/dist/cjs/index-b7400738.cjs +0 -1
  60. package/dist/cjs/index-c59c8727.cjs +0 -72
  61. package/dist/cjs/index-cf3bf3b5.cjs +0 -3
  62. package/dist/cjs/index-d72d2161.cjs +0 -6
  63. package/dist/cjs/index-de2a5091.cjs +0 -1
  64. package/dist/cjs/index.es-eeb7e818.cjs +0 -9
  65. package/dist/cjs/inherits_browser-f88a000a.cjs +0 -1
  66. package/dist/cjs/interface-770bfae7.cjs +0 -1
  67. package/dist/cjs/portis-b2b50bfb.cjs +0 -24
  68. package/dist/cjs/provider-b83497b2.cjs +0 -1
  69. package/dist/cjs/rainbow-10b0c861.cjs +0 -1
  70. package/dist/cjs/typed-data-63d8e9ee.cjs +0 -1
  71. package/dist/cjs/uAuth-b8c6a947.cjs +0 -1
  72. package/dist/cjs/walletConnect-be645a80.cjs +0 -1
  73. package/dist/cjs/walletLink-3f05b2ee.cjs +0 -1
  74. package/dist/ethers-e9ea7b62.js +0 -1
  75. package/dist/hash-a9ebd52a.js +0 -1
  76. package/dist/id-4394eafb.js +0 -1
  77. package/dist/index-3e230de4.js +0 -1
  78. package/dist/index-4f115893.js +0 -1
  79. package/dist/index-5a901c0e.js +0 -2
  80. package/dist/index-5ef7c2c6.js +0 -6
  81. package/dist/index-6be6f872.js +0 -1
  82. package/dist/index-71412a35.js +0 -1
  83. package/dist/index-71e104e3.js +0 -1
  84. package/dist/index-853c105c.js +0 -15
  85. package/dist/index-9cb93da4.js +0 -1
  86. package/dist/index-9e75afb9.js +0 -1
  87. package/dist/index-aa70a2b2.js +0 -66
  88. package/dist/index-b12d1c2b.js +0 -1
  89. package/dist/index-bef3992a.js +0 -9
  90. package/dist/index-f4e58da8.js +0 -72
  91. package/dist/index-faabf409.js +0 -1
  92. package/dist/index.es-c2f702fd.js +0 -9
  93. package/dist/inherits_browser-06ba108b.js +0 -1
  94. package/dist/interface-e24b9dc3.js +0 -1
  95. package/dist/portis-7a5843d0.js +0 -24
  96. package/dist/provider-3276289c.js +0 -1
  97. package/dist/rainbow-028e417a.js +0 -1
  98. package/dist/typed-data-4ee2951a.js +0 -1
  99. package/dist/uAuth-1775a01d.js +0 -1
  100. package/dist/walletConnect-4d5928fe.js +0 -1
  101. package/dist/walletLink-4295f7ca.js +0 -1
@@ -1,9 +0,0 @@
1
- import e,{EventEmitter as t}from"events";import{c as r}from"./_commonjs-dynamic-modules-7cfc9805.js";import{r as n}from"./__node-resolve_empty-1bb86108.js";import{r as i}from"./__tslib-6f859a10.js";import{g as s,c as o}from"./index-bef3992a.js";import{c as a}from"./browser-ponyfill-e86d50ae.js";import"@ethersproject/providers";import"zustand";import"@ethersproject/address";import"@ethersproject/constants";import"@ethersproject/contracts";import"@ethersproject/properties";import"@ethersproject/transactions";import"@ethersproject/bytes";var c,h={},u={},l={},f={};c=f,Object.defineProperty(c,"__esModule",{value:!0}),c.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},c.add=function(e,t){return e+t|0},c.sub=function(e,t){return e-t|0},c.rotl=function(e,t){return e<<t|e>>>32-t},c.rotr=function(e,t){return e<<32-t|e>>>t},c.isInteger=Number.isInteger||function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e},c.MAX_SAFE_INTEGER=9007199254740991,c.isSafeInteger=function(e){return c.isInteger(e)&&e>=-c.MAX_SAFE_INTEGER&&e<=c.MAX_SAFE_INTEGER},Object.defineProperty(l,"__esModule",{value:!0});var p=f;function d(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 g(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 y(e,t){return void 0===t&&(t=0),e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function v(e,t){return void 0===t&&(t=0),(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}function m(e,t){return void 0===t&&(t=0),e[t+3]<<24|e[t+2]<<16|e[t+1]<<8|e[t]}function w(e,t){return void 0===t&&(t=0),(e[t+3]<<24|e[t+2]<<16|e[t+1]<<8|e[t])>>>0}function _(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 b(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(e,t,r){return void 0===t&&(t=new Uint8Array(8)),void 0===r&&(r=0),_(e/4294967296>>>0,t,r),_(e>>>0,t,r+4),t}function I(e,t,r){return void 0===t&&(t=new Uint8Array(8)),void 0===r&&(r=0),b(e>>>0,t,r),b(e/4294967296>>>0,t,r+4),t}l.readInt16BE=function(e,t){return void 0===t&&(t=0),(e[t+0]<<8|e[t+1])<<16>>16},l.readUint16BE=function(e,t){return void 0===t&&(t=0),(e[t+0]<<8|e[t+1])>>>0},l.readInt16LE=function(e,t){return void 0===t&&(t=0),(e[t+1]<<8|e[t])<<16>>16},l.readUint16LE=function(e,t){return void 0===t&&(t=0),(e[t+1]<<8|e[t])>>>0},l.writeUint16BE=d,l.writeInt16BE=d,l.writeUint16LE=g,l.writeInt16LE=g,l.readInt32BE=y,l.readUint32BE=v,l.readInt32LE=m,l.readUint32LE=w,l.writeUint32BE=_,l.writeInt32BE=_,l.writeUint32LE=b,l.writeInt32LE=b,l.readInt64BE=function(e,t){void 0===t&&(t=0);var r=y(e,t),n=y(e,t+4);return 4294967296*r+n-4294967296*(n>>31)},l.readUint64BE=function(e,t){return void 0===t&&(t=0),4294967296*v(e,t)+v(e,t+4)},l.readInt64LE=function(e,t){void 0===t&&(t=0);var r=m(e,t);return 4294967296*m(e,t+4)+r-4294967296*(r>>31)},l.readUint64LE=function(e,t){void 0===t&&(t=0);var r=w(e,t);return 4294967296*w(e,t+4)+r},l.writeUint64BE=E,l.writeInt64BE=E,l.writeUint64LE=I,l.writeInt64LE=I,l.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},l.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},l.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(!p.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},l.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(!p.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},l.readFloat32BE=function(e,t){return void 0===t&&(t=0),new DataView(e.buffer,e.byteOffset,e.byteLength).getFloat32(t)},l.readFloat32LE=function(e,t){return void 0===t&&(t=0),new DataView(e.buffer,e.byteOffset,e.byteLength).getFloat32(t,!0)},l.readFloat64BE=function(e,t){return void 0===t&&(t=0),new DataView(e.buffer,e.byteOffset,e.byteLength).getFloat64(t)},l.readFloat64LE=function(e,t){return void 0===t&&(t=0),new DataView(e.buffer,e.byteOffset,e.byteLength).getFloat64(t,!0)},l.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},l.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},l.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},l.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 S={};Object.defineProperty(S,"__esModule",{value:!0}),S.wipe=function(e){for(var t=0;t<e.length;t++)e[t]=0;return e},Object.defineProperty(u,"__esModule",{value:!0});var P=l,O=S,N=20;function A(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],h=r[11]<<24|r[10]<<16|r[9]<<8|r[8],u=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],m=t[15]<<24|t[14]<<16|t[13]<<8|t[12],w=n,_=i,b=s,E=o,I=a,S=c,O=h,A=u,C=l,R=f,x=p,T=d,L=g,U=y,j=v,M=m,D=0;D<N;D+=2)I=(I^=C=C+(L=(L^=w=w+I|0)>>>16|L<<16)|0)>>>20|I<<12,S=(S^=R=R+(U=(U^=_=_+S|0)>>>16|U<<16)|0)>>>20|S<<12,O=(O^=x=x+(j=(j^=b=b+O|0)>>>16|j<<16)|0)>>>20|O<<12,A=(A^=T=T+(M=(M^=E=E+A|0)>>>16|M<<16)|0)>>>20|A<<12,O=(O^=x=x+(j=(j^=b=b+O|0)>>>24|j<<8)|0)>>>25|O<<7,A=(A^=T=T+(M=(M^=E=E+A|0)>>>24|M<<8)|0)>>>25|A<<7,S=(S^=R=R+(U=(U^=_=_+S|0)>>>24|U<<8)|0)>>>25|S<<7,I=(I^=C=C+(L=(L^=w=w+I|0)>>>24|L<<8)|0)>>>25|I<<7,S=(S^=x=x+(M=(M^=w=w+S|0)>>>16|M<<16)|0)>>>20|S<<12,O=(O^=T=T+(L=(L^=_=_+O|0)>>>16|L<<16)|0)>>>20|O<<12,A=(A^=C=C+(U=(U^=b=b+A|0)>>>16|U<<16)|0)>>>20|A<<12,I=(I^=R=R+(j=(j^=E=E+I|0)>>>16|j<<16)|0)>>>20|I<<12,A=(A^=C=C+(U=(U^=b=b+A|0)>>>24|U<<8)|0)>>>25|A<<7,I=(I^=R=R+(j=(j^=E=E+I|0)>>>24|j<<8)|0)>>>25|I<<7,O=(O^=T=T+(L=(L^=_=_+O|0)>>>24|L<<8)|0)>>>25|O<<7,S=(S^=x=x+(M=(M^=w=w+S|0)>>>24|M<<8)|0)>>>25|S<<7;P.writeUint32LE(w+n|0,e,0),P.writeUint32LE(_+i|0,e,4),P.writeUint32LE(b+s|0,e,8),P.writeUint32LE(E+o|0,e,12),P.writeUint32LE(I+a|0,e,16),P.writeUint32LE(S+c|0,e,20),P.writeUint32LE(O+h|0,e,24),P.writeUint32LE(A+u|0,e,28),P.writeUint32LE(C+l|0,e,32),P.writeUint32LE(R+f|0,e,36),P.writeUint32LE(x+p|0,e,40),P.writeUint32LE(T+d|0,e,44),P.writeUint32LE(L+g|0,e,48),P.writeUint32LE(U+y|0,e,52),P.writeUint32LE(j+v|0,e,56),P.writeUint32LE(M+m|0,e,60)}function C(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){A(a,s,e);for(var h=c;h<c+64&&h<r.length;h++)n[h]=r[h]^a[h-c];R(s,0,o)}return O.wipe(a),0===i&&O.wipe(s),n}function R(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")}u.streamXOR=C,u.stream=function(e,t,r,n){return void 0===n&&(n=0),O.wipe(r),C(e,t,r,r,n)};var x={},T={};function L(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(T,"__esModule",{value:!0}),T.select=function(e,t,r){return~(e-1)&t|e-1&r},T.lessOrEqual=function(e,t){return(0|e)-(0|t)-1>>>31&1},T.compare=L,T.equal=function(e,t){return 0!==e.length&&0!==t.length&&0!==L(e,t)},function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=T,r=S;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 h=t[14]|t[15]<<8;this._r[8]=8191&(c>>>8|h<<8),this._r[9]=h>>>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],h=this._h[5],u=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],m=this._r[4],w=this._r[5],_=this._r[6],b=this._r[7],E=this._r[8],I=this._r[9];r>=16;){var S=e[t+0]|e[t+1]<<8;i+=8191&S;var P=e[t+2]|e[t+3]<<8;s+=8191&(S>>>13|P<<3);var O=e[t+4]|e[t+5]<<8;o+=8191&(P>>>10|O<<6);var N=e[t+6]|e[t+7]<<8;a+=8191&(O>>>7|N<<9);var A=e[t+8]|e[t+9]<<8;c+=8191&(N>>>4|A<<12),h+=A>>>1&8191;var C=e[t+10]|e[t+11]<<8;u+=8191&(A>>>14|C<<2);var R=e[t+12]|e[t+13]<<8;l+=8191&(C>>>11|R<<5);var x=e[t+14]|e[t+15]<<8,T=0,L=T;L+=i*d,L+=s*(5*I),L+=o*(5*E),L+=a*(5*b),T=(L+=c*(5*_))>>>13,L&=8191,L+=h*(5*w),L+=u*(5*m),L+=l*(5*v),L+=(f+=8191&(R>>>8|x<<8))*(5*y);var U=T+=(L+=(p+=x>>>5|n)*(5*g))>>>13;U+=i*g,U+=s*d,U+=o*(5*I),U+=a*(5*E),T=(U+=c*(5*b))>>>13,U&=8191,U+=h*(5*_),U+=u*(5*w),U+=l*(5*m),U+=f*(5*v),T+=(U+=p*(5*y))>>>13,U&=8191;var j=T;j+=i*y,j+=s*g,j+=o*d,j+=a*(5*I),T=(j+=c*(5*E))>>>13,j&=8191,j+=h*(5*b),j+=u*(5*_),j+=l*(5*w),j+=f*(5*m);var M=T+=(j+=p*(5*v))>>>13;M+=i*v,M+=s*y,M+=o*g,M+=a*d,T=(M+=c*(5*I))>>>13,M&=8191,M+=h*(5*E),M+=u*(5*b),M+=l*(5*_),M+=f*(5*w);var D=T+=(M+=p*(5*m))>>>13;D+=i*m,D+=s*v,D+=o*y,D+=a*g,T=(D+=c*d)>>>13,D&=8191,D+=h*(5*I),D+=u*(5*E),D+=l*(5*b),D+=f*(5*_);var k=T+=(D+=p*(5*w))>>>13;k+=i*w,k+=s*m,k+=o*v,k+=a*y,T=(k+=c*g)>>>13,k&=8191,k+=h*d,k+=u*(5*I),k+=l*(5*E),k+=f*(5*b);var $=T+=(k+=p*(5*_))>>>13;$+=i*_,$+=s*w,$+=o*m,$+=a*v,T=($+=c*y)>>>13,$&=8191,$+=h*g,$+=u*d,$+=l*(5*I),$+=f*(5*E);var z=T+=($+=p*(5*b))>>>13;z+=i*b,z+=s*_,z+=o*w,z+=a*m,T=(z+=c*v)>>>13,z&=8191,z+=h*y,z+=u*g,z+=l*d,z+=f*(5*I);var q=T+=(z+=p*(5*E))>>>13;q+=i*E,q+=s*b,q+=o*_,q+=a*w,T=(q+=c*m)>>>13,q&=8191,q+=h*v,q+=u*y,q+=l*g,q+=f*d;var H=T+=(q+=p*(5*I))>>>13;H+=i*I,H+=s*E,H+=o*b,H+=a*_,T=(H+=c*w)>>>13,H&=8191,H+=h*m,H+=u*v,H+=l*y,H+=f*g,i=L=8191&(T=(T=((T+=(H+=p*d)>>>13)<<2)+T|0)+(L&=8191)|0),s=U+=T>>>=13,o=j&=8191,a=M&=8191,c=D&=8191,h=k&=8191,u=$&=8191,l=z&=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]=h,this._h[6]=u,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)}}(x),function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=u,r=x,n=S,i=l,s=T;e.KEY_LENGTH=32,e.NONCE_LENGTH=12,e.TAG_LENGTH=16;var o=new Uint8Array(16),a=function(){function a(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 a.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,h=r.length+this.tagLength;if(s){if(s.length!==h)throw new Error("ChaCha20Poly1305: incorrect destination length");c=s}else c=new Uint8Array(h);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},a.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 h=new Uint8Array(this.tagLength);if(this._authenticate(h,c,r.subarray(0,r.length-this.tagLength),i),!s.equal(h,r.subarray(r.length-this.tagLength,r.length)))return null;var u,l=r.length-this.tagLength;if(o){if(o.length!==l)throw new Error("ChaCha20Poly1305: incorrect destination length");u=o}else u=new Uint8Array(l);return t.streamXOR(this._key,a,r.subarray(0,r.length-this.tagLength),u,4),n.wipe(a),u},a.prototype.clean=function(){return n.wipe(this._key),this},a.prototype._authenticate=function(e,t,s,a){var c=new r.Poly1305(t);a&&(c.update(a),a.length%16>0&&c.update(o.subarray(a.length%16))),c.update(s),s.length%16>0&&c.update(o.subarray(s.length%16));var h=new Uint8Array(8);a&&i.writeUint64LE(a.length,h),c.update(h),i.writeUint64LE(s.length,h),c.update(h);for(var u=c.digest(),l=0;l<u.length;l++)e[l]=u[l];c.clean(),n.wipe(u),n.wipe(h)},a}();e.ChaCha20Poly1305=a}(h);var U={},j={},M={};Object.defineProperty(M,"__esModule",{value:!0}),M.isSerializableHash=function(e){return void 0!==e.saveState&&void 0!==e.restoreState&&void 0!==e.cleanSavedState},Object.defineProperty(j,"__esModule",{value:!0});var D=M,k=T,$=S,z=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),D.isSerializableHash(this._inner)&&D.isSerializableHash(this._outer)&&(this._innerKeyedState=this._inner.saveState(),this._outerKeyedState=this._outer.saveState()),$.wipe(r)}return e.prototype.reset=function(){if(!D.isSerializableHash(this._inner)||!D.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(){D.isSerializableHash(this._inner)&&this._inner.cleanSavedState(this._innerKeyedState),D.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(!D.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(!D.isSerializableHash(this._inner)||!D.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(!D.isSerializableHash(this._inner))throw new Error("hmac: can't cleanSavedState() because hash doesn't implement it");this._inner.cleanSavedState(e)},e}();j.HMAC=z,j.hmac=function(e,t,r){var n=new z(e,t);n.update(r);var i=n.digest();return n.clean(),i},j.equal=k.equal,Object.defineProperty(U,"__esModule",{value:!0});var q=j,H=S,K=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=q.hmac(this._hash,r,t);this._hmac=new q.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(),H.wipe(this._buffer),H.wipe(this._counter),this._bufpos=0},e}(),V=U.HKDF=K,B={},F={},W={};Object.defineProperty(W,"__esModule",{value:!0}),W.BrowserRandomSource=void 0;W.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 G={};Object.defineProperty(G,"__esModule",{value:!0}),G.NodeRandomSource=void 0;const Y=S;G.NodeRandomSource=class{constructor(){if(this.isAvailable=!1,this.isInstantiated=!1,void 0!==r){const e=n;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,Y.wipe)(t),r}},Object.defineProperty(F,"__esModule",{value:!0}),F.SystemRandomSource=void 0;const Q=W,J=G;F.SystemRandomSource=class{constructor(){return this.isAvailable=!1,this.name="",this._source=new Q.BrowserRandomSource,this._source.isAvailable?(this.isAvailable=!0,void(this.name="Browser")):(this._source=new J.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=F,r=l,n=S;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,h=256-256%c;for(;t>0;){const e=i(Math.ceil(256*t/h),o);for(let n=0;n<e.length&&t>0;n++){const i=e[n];i<h&&(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)}}(B);var X={};!function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=l,r=S;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],h=r[2],u=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],m=(v>>>17|v<<15)^(v>>>19|v<<13)^v>>>10,w=((v=e[g-15])>>>7|v<<25)^(v>>>18|v<<14)^v>>>3;e[g]=(m+e[g-7]|0)+(w+e[g-16]|0)}for(g=0;g<64;g++){m=(((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,w=((a>>>2|a<<30)^(a>>>13|a<<19)^(a>>>22|a<<10))+(a&c^a&h^c&h)|0;d=p,p=f,f=l,l=u+m|0,u=h,h=c,c=a,a=m+w|0}r[0]+=a,r[1]+=c,r[2]+=h,r[3]+=u,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}}(X);var Z={};function ee(e){return null!=globalThis.Buffer?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e}function te(e=0){return null!=globalThis.Buffer&&null!=globalThis.Buffer.allocUnsafe?ee(globalThis.Buffer.allocUnsafe(e)):new Uint8Array(e)}function re(e,t){t||(t=e.reduce(((e,t)=>e+t.length),0));const r=te(t);let n=0;for(const t of e)r.set(t,n),n+=t.length;return ee(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=B,r=S;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 h(e,t,r){for(let n=0;n<16;n++)e[n]=t[n]-r[n]}function u(e,t,r){let n,i,s=0,o=0,a=0,c=0,h=0,u=0,l=0,f=0,p=0,d=0,g=0,y=0,v=0,m=0,w=0,_=0,b=0,E=0,I=0,S=0,P=0,O=0,N=0,A=0,C=0,R=0,x=0,T=0,L=0,U=0,j=0,M=r[0],D=r[1],k=r[2],$=r[3],z=r[4],q=r[5],H=r[6],K=r[7],V=r[8],B=r[9],F=r[10],W=r[11],G=r[12],Y=r[13],Q=r[14],J=r[15];n=t[0],s+=n*M,o+=n*D,a+=n*k,c+=n*$,h+=n*z,u+=n*q,l+=n*H,f+=n*K,p+=n*V,d+=n*B,g+=n*F,y+=n*W,v+=n*G,m+=n*Y,w+=n*Q,_+=n*J,n=t[1],o+=n*M,a+=n*D,c+=n*k,h+=n*$,u+=n*z,l+=n*q,f+=n*H,p+=n*K,d+=n*V,g+=n*B,y+=n*F,v+=n*W,m+=n*G,w+=n*Y,_+=n*Q,b+=n*J,n=t[2],a+=n*M,c+=n*D,h+=n*k,u+=n*$,l+=n*z,f+=n*q,p+=n*H,d+=n*K,g+=n*V,y+=n*B,v+=n*F,m+=n*W,w+=n*G,_+=n*Y,b+=n*Q,E+=n*J,n=t[3],c+=n*M,h+=n*D,u+=n*k,l+=n*$,f+=n*z,p+=n*q,d+=n*H,g+=n*K,y+=n*V,v+=n*B,m+=n*F,w+=n*W,_+=n*G,b+=n*Y,E+=n*Q,I+=n*J,n=t[4],h+=n*M,u+=n*D,l+=n*k,f+=n*$,p+=n*z,d+=n*q,g+=n*H,y+=n*K,v+=n*V,m+=n*B,w+=n*F,_+=n*W,b+=n*G,E+=n*Y,I+=n*Q,S+=n*J,n=t[5],u+=n*M,l+=n*D,f+=n*k,p+=n*$,d+=n*z,g+=n*q,y+=n*H,v+=n*K,m+=n*V,w+=n*B,_+=n*F,b+=n*W,E+=n*G,I+=n*Y,S+=n*Q,P+=n*J,n=t[6],l+=n*M,f+=n*D,p+=n*k,d+=n*$,g+=n*z,y+=n*q,v+=n*H,m+=n*K,w+=n*V,_+=n*B,b+=n*F,E+=n*W,I+=n*G,S+=n*Y,P+=n*Q,O+=n*J,n=t[7],f+=n*M,p+=n*D,d+=n*k,g+=n*$,y+=n*z,v+=n*q,m+=n*H,w+=n*K,_+=n*V,b+=n*B,E+=n*F,I+=n*W,S+=n*G,P+=n*Y,O+=n*Q,N+=n*J,n=t[8],p+=n*M,d+=n*D,g+=n*k,y+=n*$,v+=n*z,m+=n*q,w+=n*H,_+=n*K,b+=n*V,E+=n*B,I+=n*F,S+=n*W,P+=n*G,O+=n*Y,N+=n*Q,A+=n*J,n=t[9],d+=n*M,g+=n*D,y+=n*k,v+=n*$,m+=n*z,w+=n*q,_+=n*H,b+=n*K,E+=n*V,I+=n*B,S+=n*F,P+=n*W,O+=n*G,N+=n*Y,A+=n*Q,C+=n*J,n=t[10],g+=n*M,y+=n*D,v+=n*k,m+=n*$,w+=n*z,_+=n*q,b+=n*H,E+=n*K,I+=n*V,S+=n*B,P+=n*F,O+=n*W,N+=n*G,A+=n*Y,C+=n*Q,R+=n*J,n=t[11],y+=n*M,v+=n*D,m+=n*k,w+=n*$,_+=n*z,b+=n*q,E+=n*H,I+=n*K,S+=n*V,P+=n*B,O+=n*F,N+=n*W,A+=n*G,C+=n*Y,R+=n*Q,x+=n*J,n=t[12],v+=n*M,m+=n*D,w+=n*k,_+=n*$,b+=n*z,E+=n*q,I+=n*H,S+=n*K,P+=n*V,O+=n*B,N+=n*F,A+=n*W,C+=n*G,R+=n*Y,x+=n*Q,T+=n*J,n=t[13],m+=n*M,w+=n*D,_+=n*k,b+=n*$,E+=n*z,I+=n*q,S+=n*H,P+=n*K,O+=n*V,N+=n*B,A+=n*F,C+=n*W,R+=n*G,x+=n*Y,T+=n*Q,L+=n*J,n=t[14],w+=n*M,_+=n*D,b+=n*k,E+=n*$,I+=n*z,S+=n*q,P+=n*H,O+=n*K,N+=n*V,A+=n*B,C+=n*F,R+=n*W,x+=n*G,T+=n*Y,L+=n*Q,U+=n*J,n=t[15],_+=n*M,b+=n*D,E+=n*k,I+=n*$,S+=n*z,P+=n*q,O+=n*H,N+=n*K,A+=n*V,C+=n*B,R+=n*F,x+=n*W,T+=n*G,L+=n*Y,U+=n*Q,j+=n*J,s+=38*b,o+=38*E,a+=38*I,c+=38*S,h+=38*P,u+=38*O,l+=38*N,f+=38*A,p+=38*C,d+=38*R,g+=38*x,y+=38*T,v+=38*L,m+=38*U,w+=38*j,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=h+i+65535,i=Math.floor(n/65536),h=n-65536*i,n=u+i+65535,i=Math.floor(n/65536),u=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=m+i+65535,i=Math.floor(n/65536),m=n-65536*i,n=w+i+65535,i=Math.floor(n/65536),w=n-65536*i,n=_+i+65535,i=Math.floor(n/65536),_=n-65536*i,s+=i-1+37*(i-1),i=1,n=s+i+65535,i=Math.floor(n/65536),s=n-65536*i,n=o+i+65535,i=Math.floor(n/65536),o=n-65536*i,n=a+i+65535,i=Math.floor(n/65536),a=n-65536*i,n=c+i+65535,i=Math.floor(n/65536),c=n-65536*i,n=h+i+65535,i=Math.floor(n/65536),h=n-65536*i,n=u+i+65535,i=Math.floor(n/65536),u=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=m+i+65535,i=Math.floor(n/65536),m=n-65536*i,n=w+i+65535,i=Math.floor(n/65536),w=n-65536*i,n=_+i+65535,i=Math.floor(n/65536),_=n-65536*i,s+=i-1+37*(i-1),e[0]=s,e[1]=o,e[2]=a,e[3]=c,e[4]=h,e[5]=u,e[6]=l,e[7]=f,e[8]=p,e[9]=d,e[10]=g,e[11]=y,e[12]=v,e[13]=m,e[14]=w,e[15]=_}function l(e,t){u(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),h(f,f,d),c(d,p,g),h(p,p,g),l(g,y),l(v,f),u(f,d,f),u(d,p,y),c(y,f,d),h(f,f,d),l(p,f),h(d,g,v),u(f,d,s),c(f,f,g),u(d,d,f),u(f,g,v),u(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 m=i.subarray(32),w=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&&u(r,r,t);for(let t=0;t<16;t++)e[t]=r[t]}(m,m),u(w,w,m);const _=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),_}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}}(Z);var ne=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),h=Math.log(a)/Math.log(256),u=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)*h+1>>>0,o=new Uint8Array(s);e[t];){var u=r[e.charCodeAt(t)];if(255===u)return;for(var l=0,f=s-1;(0!==u||l<i)&&-1!==f;f--,l++)u+=a*o[f]>>>0,o[f]=u%256>>>0,u=u/256>>>0;if(0!==u)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)*u+1>>>0,h=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*h[p]>>>0,h[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===h[d];)d++;for(var g=c.repeat(r);d<o;++d)g+=e.charAt(h[d]);return g},decodeUnsafe:l,decode:function(e){var r=l(e);if(r)return r;throw new Error(`Non-${t} character`)}}},ie=ne;const se=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 oe{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 ae{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 he(this,e)}}class ce{constructor(e){this.decoders=e}or(e){return he(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 he=(e,t)=>new ce({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}});class ue{constructor(e,t,r,n){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new oe(e,t,r),this.decoder=new ae(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const le=({name:e,prefix:t,encode:r,decode:n})=>new ue(e,t,r,n),fe=({prefix:e,name:t,alphabet:r})=>{const{encode:n,decode:i}=ie(r,t);return le({prefix:e,name:t,encode:n,decode:e=>se(i(e))})},pe=({name:e,prefix:t,bitsPerChar:r,alphabet:n})=>le({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,h=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[h++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o})(t,n,r,e)}),de=le({prefix:"\0",name:"identity",encode:e=>(e=>(new TextDecoder).decode(e))(e),decode:e=>(e=>(new TextEncoder).encode(e))(e)});var ge=Object.freeze({__proto__:null,identity:de});const ye=pe({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var ve=Object.freeze({__proto__:null,base2:ye});const me=pe({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var we=Object.freeze({__proto__:null,base8:me});const _e=fe({prefix:"9",name:"base10",alphabet:"0123456789"});var be=Object.freeze({__proto__:null,base10:_e});const Ee=pe({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Ie=pe({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Se=Object.freeze({__proto__:null,base16:Ee,base16upper:Ie});const Pe=pe({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Oe=pe({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Ne=pe({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Ae=pe({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Ce=pe({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Re=pe({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),xe=pe({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Te=pe({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Le=pe({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Ue=Object.freeze({__proto__:null,base32:Pe,base32upper:Oe,base32pad:Ne,base32padupper:Ae,base32hex:Ce,base32hexupper:Re,base32hexpad:xe,base32hexpadupper:Te,base32z:Le});const je=fe({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Me=fe({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var De=Object.freeze({__proto__:null,base36:je,base36upper:Me});const ke=fe({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),$e=fe({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var ze=Object.freeze({__proto__:null,base58btc:ke,base58flickr:$e});const qe=pe({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),He=pe({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Ke=pe({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Ve=pe({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Be=Object.freeze({__proto__:null,base64:qe,base64pad:He,base64url:Ke,base64urlpad:Ve});const Fe=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),We=Fe.reduce(((e,t,r)=>(e[r]=t,e)),[]),Ge=Fe.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const Ye=le({prefix:"🚀",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=We[t]),"")},decode:function(e){const t=[];for(const r of e){const e=Ge[r.codePointAt(0)];if(void 0===e)throw new Error(`Non-base256emoji character: ${r}`);t.push(e)}return new Uint8Array(t)}});var Qe=Object.freeze({__proto__:null,base256emoji:Ye}),Je=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=et;)r[n++]=255&t|Xe,t/=128;for(;t&Ze;)r[n++]=255&t|Xe,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},Xe=128,Ze=-128,et=Math.pow(2,31);var tt=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&nt)<<s:(n&nt)*Math.pow(2,s),s+=7}while(n>=rt);return e.bytes=o-r,i},rt=128,nt=127;var it=Math.pow(2,7),st=Math.pow(2,14),ot=Math.pow(2,21),at=Math.pow(2,28),ct=Math.pow(2,35),ht=Math.pow(2,42),ut=Math.pow(2,49),lt=Math.pow(2,56),ft=Math.pow(2,63),pt={encode:Je,decode:tt,encodingLength:function(e){return e<it?1:e<st?2:e<ot?3:e<at?4:e<ct?5:e<ht?6:e<ut?7:e<lt?8:e<ft?9:10}};const dt=(e,t,r=0)=>(pt.encode(e,t,r),t),gt=e=>pt.encodingLength(e),yt=(e,t)=>{const r=t.byteLength,n=gt(e),i=n+gt(r),s=new Uint8Array(i+r);return dt(e,s,0),dt(r,s,n),s.set(t,i),new vt(e,r,t,s)};class vt{constructor(e,t,r,n){this.code=e,this.size=t,this.digest=r,this.bytes=n}}const mt=({name:e,code:t,encode:r})=>new wt(e,t,r);class wt{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?yt(this.code,t):t.then((e=>yt(this.code,e)))}throw Error("Unknown type, must be binary type")}}const _t=e=>async t=>new Uint8Array(await crypto.subtle.digest(e,t));mt({name:"sha2-256",code:18,encode:_t("SHA-256")}),mt({name:"sha2-512",code:19,encode:_t("SHA-512")});new TextEncoder,new TextDecoder;const bt={...ge,...ve,...we,...be,...Se,...Ue,...De,...ze,...Be,...Qe};function Et(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}const It=Et("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),St=Et("ascii","a",(e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t}),(e=>{const t=te((e=e.substring(1)).length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t})),Pt={utf8:It,"utf-8":It,hex:bt.base16,latin1:St,ascii:St,binary:St,...bt};function Ot(e,t="utf8"){const r=Pt[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}`):ee(globalThis.Buffer.from(e,"utf-8"))}function Nt(e,t="utf8"){const r=Pt[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 At=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))},Ct=function(e,t,r){this.name=e,this.version=t,this.os=r,this.type="browser"},Rt=function(e){this.version=e,this.type="node",this.name="node",this.os=process.platform},xt=function(e,t,r,n){this.name=e,this.version=t,this.os=r,this.bot=n,this.type="bot-device"},Tt=function(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null},Lt=function(){this.type="react-native",this.name="react-native",this.version=null,this.os=null},Ut=/(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,jt=3,Mt=[["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/]],Dt=[["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 kt(e){return e?$t(e):"undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"===navigator.product?new Lt:"undefined"!=typeof navigator?$t(navigator.userAgent):"undefined"!=typeof process&&process.version?new Rt(process.version.slice(1)):null}function $t(e){var t=function(e){return""!==e&&Mt.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 Tt;var i=n[1]&&n[1].split(".").join("_").split("_").slice(0,3);i?i.length<jt&&(i=At(At([],i,!0),function(e){for(var t=[],r=0;r<e;r++)t.push("0");return t}(jt-i.length),!0)):i=[];var s=i.join("."),o=function(e){for(var t=0,r=Dt.length;t<r;t++){var n=Dt[t],i=n[0];if(n[1].exec(e))return i}return null}(e),a=Ut.exec(e);return a&&a[1]?new xt(r,s,o,a[1]):new Ct(r,s,o)}var zt,qt={},Ht={},Kt={};var Vt,Bt={},Ft={},Wt={};var Gt,Yt,Qt,Jt,Xt={};function Zt(){return Yt||(Yt=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});const t=i;t.__exportStar((Vt||(Vt=1,Object.defineProperty(Wt,"__esModule",{value:!0}),Wt.ONE_THOUSAND=Wt.ONE_HUNDRED=void 0,Wt.ONE_HUNDRED=100,Wt.ONE_THOUSAND=1e3),Wt),e),t.__exportStar((Gt||(Gt=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}(Xt)),Xt),e)}(Ft)),Ft}function er(){return Jt||(Jt=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});const t=i;t.__exportStar((zt||(zt=1,Object.defineProperty(Kt,"__esModule",{value:!0}),Kt.delay=void 0,Kt.delay=function(e){return new Promise((t=>{setTimeout((()=>{t(!0)}),e)}))}),Kt),e),t.__exportStar(function(){if(Qt)return Bt;Qt=1,Object.defineProperty(Bt,"__esModule",{value:!0}),Bt.fromMiliseconds=Bt.toMiliseconds=void 0;const e=Zt();return Bt.toMiliseconds=function(t){return t*e.ONE_THOUSAND},Bt.fromMiliseconds=function(t){return Math.floor(t/e.ONE_THOUSAND)},Bt}(),e)}(Ht)),Ht}var tr,rr={};var nr,ir,sr={},or={};function ar(){return ir||(ir=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});i.__exportStar((nr||(nr=1,Object.defineProperty(or,"__esModule",{value:!0}),or.IWatch=void 0,or.IWatch=class{}),or),e)}(sr)),sr}!function(e){Object.defineProperty(e,"__esModule",{value:!0});const t=i;t.__exportStar(er(),e),t.__exportStar(function(){if(tr)return rr;tr=1,Object.defineProperty(rr,"__esModule",{value:!0}),rr.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 rr.Watch=e,rr.default=e,rr}(),e),t.__exportStar(ar(),e),t.__exportStar(Zt(),e)}(qt);var cr={};function hr(e){let t;return"undefined"!=typeof window&&void 0!==window[e]&&(t=window[e]),t}function ur(e){const t=hr(e);if(!t)throw new Error(`${e} is not defined in Window`);return t}Object.defineProperty(cr,"__esModule",{value:!0}),cr.getLocalStorage=cr.getLocalStorageOrThrow=cr.getCrypto=cr.getCryptoOrThrow=pr=cr.getLocation=cr.getLocationOrThrow=fr=cr.getNavigator=cr.getNavigatorOrThrow=lr=cr.getDocument=cr.getDocumentOrThrow=cr.getFromWindowOrThrow=cr.getFromWindow=void 0,cr.getFromWindow=hr,cr.getFromWindowOrThrow=ur,cr.getDocumentOrThrow=function(){return ur("document")};var lr=cr.getDocument=function(){return hr("document")};cr.getNavigatorOrThrow=function(){return ur("navigator")};var fr=cr.getNavigator=function(){return hr("navigator")};cr.getLocationOrThrow=function(){return ur("location")};var pr=cr.getLocation=function(){return hr("location")};cr.getCryptoOrThrow=function(){return ur("crypto")},cr.getCrypto=function(){return hr("crypto")},cr.getLocalStorageOrThrow=function(){return ur("localStorage")},cr.getLocalStorage=function(){return hr("localStorage")};var dr={};Object.defineProperty(dr,"__esModule",{value:!0});var gr=dr.getWindowMetadata=void 0;const yr=cr;gr=dr.getWindowMetadata=function(){let e,t;try{e=yr.getDocumentOrThrow(),t=yr.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 vr={},mr=e=>encodeURIComponent(e).replace(/[!'()*]/g,(e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`)),wr="%[a-f0-9]{2}",_r=new RegExp("("+wr+")|([^%]+?)","gi"),br=new RegExp("("+wr+")+","gi");function Er(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([],Er(r),Er(n))}function Ir(e){try{return decodeURIComponent(e)}catch(n){for(var t=e.match(_r)||[],r=1;r<t.length;r++)t=(e=Er(t,r).join("")).match(_r)||[];return e}}var Sr=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=br.exec(e);r;){try{t[r[0]]=decodeURIComponent(r[0])}catch(e){var n=Ir(r[0]);n!==r[0]&&(t[r[0]]=n)}r=br.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)}},Pr=(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)]},Or=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=mr,r=Sr,n=Pr,i=Or,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 h(e){return Array.isArray(e)?e.sort():"object"==typeof e?h(Object.keys(e)).sort(((e,t)=>Number(e)-Number(t))).map((t=>e[t])):e}function u(e){const t=e.indexOf("#");return-1!==t&&(e=e.slice(0,t)),e}function l(e){const t=(e=u(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]=h(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=u(t.url).split("?")[0]||"",i=e.extract(t.url),o=e.parse(i,{sort:!1}),c=Object.assign(o,t.query);let h=e.stringify(c,r);h&&(h=`?${h}`);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}${h}${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)}}(vr);const Nr={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"}},Ar=":";function Cr(e,t){return e.includes(":")?[e]:t.chains||[]}const Rr="base10",xr="base16",Tr="base64pad",Lr="utf8",Ur=0,jr=1,Mr=0,Dr=1,kr=12,$r=32;function zr(){return Nt(B.randomBytes($r),xr)}function qr(e){return Nt(X.hash(Ot(e,Lr)),xr)}function Hr(e){return Number(Nt(e,Rr))}function Kr(e){const t=function(e){return Ot(`${e}`,Rr)}(typeof e.type<"u"?e.type:Ur);if(Hr(t)===jr&&typeof e.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const r=typeof e.senderPublicKey<"u"?Ot(e.senderPublicKey,xr):void 0,n=typeof e.iv<"u"?Ot(e.iv,xr):B.randomBytes(kr);return function(e){if(Hr(e.type)===jr){if(typeof e.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return Nt(re([e.type,e.senderPublicKey,e.iv,e.sealed]),Tr)}return Nt(re([e.type,e.iv,e.sealed]),Tr)}({type:t,sealed:new h.ChaCha20Poly1305(Ot(e.symKey,xr)).seal(n,Ot(e.message,Lr)),iv:n,senderPublicKey:r})}function Vr(e){const t=Ot(e,Tr),r=t.slice(Mr,Dr),n=Dr;if(Hr(r)===jr){const e=n+$r,i=e+kr,s=t.slice(n,e),o=t.slice(e,i);return{type:r,sealed:t.slice(i),iv:o,senderPublicKey:s}}const i=n+kr,s=t.slice(n,i);return{type:r,sealed:t.slice(i),iv:s}}function Br(e){const t=e?.type||Ur;if(t===jr){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 Fr(e){return e.type===jr&&"string"==typeof e.senderPublicKey&&"string"==typeof e.receiverPublicKey}var Wr=Object.defineProperty,Gr=Object.getOwnPropertySymbols,Yr=Object.prototype.hasOwnProperty,Qr=Object.prototype.propertyIsEnumerable,Jr=(e,t,r)=>t in e?Wr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Xr=(e,t)=>{for(var r in t||(t={}))Yr.call(t,r)&&Jr(e,r,t[r]);if(Gr)for(var r of Gr(t))Qr.call(t,r)&&Jr(e,r,t[r]);return e};const Zr="ReactNative",en={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},tn="js";function rn(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function nn(){return!lr()&&!!fr()&&navigator.product===Zr}function sn(){return!rn()&&!!fr()}function on(){return nn()?en.reactNative:rn()?en.node:sn()?en.browser:en.unknown}function an(e,t,r){const n=function(){if(on()===en.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=kt();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=on();return t===en.browser?[t,(null==(e=pr())?void 0:e.host)||"unknown"].join(":"):t}();return[[e,t].join("-"),[tn,r].join("-"),n,i].join("/")}function cn({protocol:e,version:t,relayUrl:r,sdkVersion:n,auth:i,projectId:s,useOnCloseEvent:o,bundleId:a}){const c=r.split("?"),h={auth:i,ua:an(e,t,n),projectId:s,useOnCloseEvent:o||void 0,origin:a||void 0},u=function(e,t){let r=vr.parse(e);return r=Xr(Xr({},r),t),vr.stringify(r)}(c[1]||"",h);return c[0]+"?"+u}function hn(e,t){return e.filter((e=>t.includes(e))).length===e.length}function un(e){return Object.fromEntries(e.entries())}function ln(e){return new Map(Object.entries(e))}function fn(e=qt.FIVE_MINUTES,t){const r=qt.toMiliseconds(e||qt.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 pn(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 dn(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 gn(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 yn(e,t){return qt.fromMiliseconds((t||Date.now())+qt.toMiliseconds(e))}function vn(e){return Date.now()>=qt.toMiliseconds(e)}function mn(e,t){return`${e}${t?`:${t}`:""}`}function wn(e=[],t=[]){return[...new Set([...e,...t])]}function _n(e){return e?.relay||{protocol:"irn"}}function bn(e){const t=Nr[e];if(typeof t>"u")throw new Error(`Relay Protocol not supported: ${e}`);return t}var En=Object.defineProperty,In=Object.getOwnPropertySymbols,Sn=Object.prototype.hasOwnProperty,Pn=Object.prototype.propertyIsEnumerable,On=(e,t,r)=>t in e?En(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;function Nn(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 An(e){const t=(e=(e=e.includes("wc://")?e.replace("wc://",""):e).includes("wc:")?e.replace("wc:",""):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=vr.parse(s);return{protocol:n,topic:Cn(i[0]),version:parseInt(i[1],10),symKey:o.symKey,relay:Nn(o)}}function Cn(e){return e.startsWith("//")?e.substring(2):e}function Rn(e){return`${e.protocol}:${e.topic}@${e.version}?`+vr.stringify(((e,t)=>{for(var r in t||(t={}))Sn.call(t,r)&&On(e,r,t[r]);if(In)for(var r of In(t))Pn.call(t,r)&&On(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 xn(e){const t=[];return e.forEach((e=>{const[r,n]=e.split(":");t.push(`${r}:${n}`)})),t}function Tn(e){return e.includes(":")}function Ln(e){return Tn(e)?e.split(":")[0]:e}const Un={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}},jn={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 Mn(e,t){const{message:r,code:n}=jn[e];return{message:t?`${r} ${t}`:r,code:n}}function Dn(e,t){const{message:r,code:n}=Un[e];return{message:t?`${r} ${t}`:r,code:n}}function kn(e,t){return!!Array.isArray(e)&&(!(typeof t<"u"&&e.length)||e.every(t))}function $n(e){return Object.getPrototypeOf(e)===Object.prototype&&Object.keys(e).length}function zn(e){return typeof e>"u"}function qn(e,t){return!(!t||!zn(e))||"string"==typeof e&&!!e.trim().length}function Hn(e,t){return!(!t||!zn(e))||"number"==typeof e&&!isNaN(e)}function Kn(e){return!(!qn(e,!1)||!e.includes(":"))&&2===e.split(":").length}function Vn(e){let t=!0;return kn(e)?e.length&&(t=e.every((e=>qn(e,!1)))):t=!1,t}function Bn(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 kn(t)&&t.length?t.forEach((e=>{n||Kn(e)||(n=Dn("UNSUPPORTED_CHAINS",`${r}, chain ${e} should be a string and conform to "namespace:chainId" format`))})):Kn(e)||(n=Dn("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,Cr(e,i),`${t} ${r}`);s&&(n=s)})),n}function Fn(e,t){let r=null;return kn(e)?e.forEach((e=>{r||function(e){if(qn(e,!1)&&e.includes(":")){const t=e.split(":");if(3===t.length){const e=t[0]+":"+t[1];return!!t[2]&&Kn(e)}}return!1}(e)||(r=Dn("UNSUPPORTED_ACCOUNTS",`${t}, account ${e} should be a string and conform to "namespace:chainId:address" format`))})):r=Dn("UNSUPPORTED_ACCOUNTS",`${t}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),r}function Wn(e,t){let r=null;return Object.values(e).forEach((e=>{if(r)return;const n=function(e,t){let r=null;return Vn(e?.methods)?Vn(e?.events)||(r=Dn("UNSUPPORTED_EVENTS",`${t}, events should be an array of strings or empty array for no events`)):r=Dn("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 Gn(e,t){let r=null;if(e&&$n(e)){const n=Wn(e,t);n&&(r=n);const i=function(e,t){let r=null;return Object.values(e).forEach((e=>{if(r)return;const n=Fn(e?.accounts,`${t} namespace`);n&&(r=n)})),r}(e,t);i&&(r=i)}else r=Mn("MISSING_OR_INVALID",`${t}, namespaces should be an object with data`);return r}function Yn(e){return qn(e.protocol,!0)}function Qn(e){return typeof e<"u"&&null!==typeof e}function Jn(e,t){return!(!Kn(t)||!function(e){const t=[];return Object.values(e).forEach((e=>{t.push(...xn(e.accounts))})),t}(e).includes(t))}function Xn(e,t,r){return!!qn(r,!1)&&function(e,t){const r=[];return Object.values(e).forEach((e=>{xn(e.accounts).includes(t)&&r.push(...e.methods)})),r}(e,t).includes(r)}function Zn(e,t,r){return!!qn(r,!1)&&function(e,t){const r=[];return Object.values(e).forEach((e=>{xn(e.accounts).includes(t)&&r.push(...e.events)})),r}(e,t).includes(r)}function ei(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=xn(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=ti(Object.keys(e)),h=ti(Object.keys(t)),u=c.filter((e=>!h.includes(e)));return u.length&&(n=Mn("NON_CONFORMING_NAMESPACES",`${r} namespaces keys don't satisfy requiredNamespaces.\n Required: ${u.toString()}\n Received: ${Object.keys(t).toString()}`)),hn(o,a)||(n=Mn("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=xn(t[e].accounts);i.includes(e)||(n=Mn("NON_CONFORMING_NAMESPACES",`${r} namespaces accounts don't satisfy namespace accounts for ${e}\n Required: ${e}\n Approved: ${i.toString()}`))})),o.forEach((e=>{n||(hn(i[e].methods,s[e].methods)?hn(i[e].events,s[e].events)||(n=Mn("NON_CONFORMING_NAMESPACES",`${r} namespaces events don't satisfy namespace events for ${e}`)):n=Mn("NON_CONFORMING_NAMESPACES",`${r} namespaces methods don't satisfy namespace methods for ${e}`))})),n}function ti(e){return[...new Set(e.map((e=>e.includes(":")?e.split(":")[0]:e)))]}function ri(){const e=on();return new Promise((t=>{switch(e){case en.browser:t(sn()&&navigator?.onLine);break;case en.reactNative:t(async function(){if(nn()&&typeof global<"u"&&null!=global&&global.NetInfo){const e=await(null==global?void 0:global.NetInfo.fetch());return e?.isConnected}return!0}());break;case en.node:default:t(!0)}}))}function ni(e){switch(on()){case en.browser:!function(e){!nn()&&sn()&&(window.addEventListener("online",(()=>e(!0))),window.addEventListener("offline",(()=>e(!1))))}(e);break;case en.reactNative:!function(e){nn()&&typeof global<"u"&&null!=global&&global.NetInfo&&global?.NetInfo.addEventListener((t=>e(t?.isConnected)))}(e)}}const ii={};class si{static get(e){return ii[e]}static set(e,t){ii[e]=t}static delete(e){delete ii[e]}}const oi=/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,ai=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,ci=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;function hi(e,t){if(!("__proto__"===e||"constructor"===e&&t&&"object"==typeof t&&"prototype"in t))return t;!function(e){console.warn(`[destr] Dropping "${e}" key to prevent prototype pollution.`)}(e)}function ui(e,t={}){if("string"!=typeof e)return e;const r=e.trim();if('"'===e[0]&&'"'===e.at(-1)&&!e.includes("\\"))return r.slice(1,-1);if(r.length<=9){const e=r.toLowerCase();if("true"===e)return!0;if("false"===e)return!1;if("undefined"===e)return;if("null"===e)return null;if("nan"===e)return Number.NaN;if("infinity"===e)return Number.POSITIVE_INFINITY;if("-infinity"===e)return Number.NEGATIVE_INFINITY}if(!ci.test(e)){if(t.strict)throw new SyntaxError("[destr] Invalid JSON");return e}try{if(oi.test(e)||ai.test(e)){if(t.strict)throw new Error("[destr] Possible prototype pollution");return JSON.parse(e,hi)}return JSON.parse(e)}catch(r){if(t.strict)throw r;return e}}function li(e,...t){try{return(r=e(...t))&&"function"==typeof r.then?r:Promise.resolve(r)}catch(e){return Promise.reject(e)}var r}function fi(e){if(function(e){const t=typeof e;return null===e||"object"!==t&&"function"!==t}(e))return String(e);if(function(e){const t=Object.getPrototypeOf(e);return!t||t.isPrototypeOf(Object)}(e)||Array.isArray(e))return JSON.stringify(e);if("function"==typeof e.toJSON)return fi(e.toJSON());throw new Error("[unstorage] Cannot stringify value!")}function pi(){if(void 0===typeof Buffer)throw new TypeError("[unstorage] Buffer is not supported!")}const di="base64:";function gi(e){return e?e.split("?")[0].replace(/[/\\]/g,":").replace(/:+/g,":").replace(/^:|:$/g,""):""}function yi(...e){return gi(e.join(":"))}function vi(e){return(e=gi(e))?e+":":""}const mi=()=>{const e=new Map;return{name:"memory",options:{},hasItem:t=>e.has(t),getItem:t=>e.get(t)??null,getItemRaw:t=>e.get(t)??null,setItem(t,r){e.set(t,r)},setItemRaw(t,r){e.set(t,r)},removeItem(t){e.delete(t)},getKeys:()=>Array.from(e.keys()),clear(){e.clear()},dispose(){e.clear()}}};function wi(e={}){const t={mounts:{"":e.driver||mi()},mountpoints:[""],watching:!1,watchListeners:[],unwatch:{}},r=e=>{for(const r of t.mountpoints)if(e.startsWith(r))return{base:r,relativeKey:e.slice(r.length),driver:t.mounts[r]};return{base:"",relativeKey:e,driver:t.mounts[""]}},n=(e,r)=>t.mountpoints.filter((t=>t.startsWith(e)||r&&e.startsWith(t))).map((r=>({relativeBase:e.length>r.length?e.slice(r.length):void 0,mountpoint:r,driver:t.mounts[r]}))),i=(e,r)=>{if(t.watching){r=gi(r);for(const n of t.watchListeners)n(e,r)}},s=async()=>{if(t.watching){for(const e in t.unwatch)await t.unwatch[e]();t.unwatch={},t.watching=!1}},o=(e,t,n)=>{const i=new Map,s=e=>{let t=i.get(e.base);return t||(t={driver:e.driver,base:e.base,items:[]},i.set(e.base,t)),t};for(const n of e){const e="string"==typeof n,i=gi(e?n:n.key),o=e?void 0:n.value,a=e||!n.options?t:{...t,...n.options},c=r(i);s(c).items.push({key:i,value:o,relativeKey:c.relativeKey,options:a})}return Promise.all([...i.values()].map((e=>n(e)))).then((e=>e.flat()))},a={hasItem(e,t={}){e=gi(e);const{relativeKey:n,driver:i}=r(e);return li(i.hasItem,n,t)},getItem(e,t={}){e=gi(e);const{relativeKey:n,driver:i}=r(e);return li(i.getItem,n,t).then((e=>ui(e)))},getItems:(e,t)=>o(e,t,(e=>e.driver.getItems?li(e.driver.getItems,e.items.map((e=>({key:e.relativeKey,options:e.options}))),t).then((t=>t.map((t=>({key:yi(e.base,t.key),value:ui(t.value)}))))):Promise.all(e.items.map((t=>li(e.driver.getItem,t.relativeKey,t.options).then((e=>({key:t.key,value:ui(e)})))))))),getItemRaw(e,t={}){e=gi(e);const{relativeKey:n,driver:i}=r(e);return i.getItemRaw?li(i.getItemRaw,n,t):li(i.getItem,n,t).then((e=>function(e){return"string"!=typeof e?e:e.startsWith(di)?(pi(),Buffer.from(e.slice(di.length),"base64")):e}(e)))},async setItem(e,t,n={}){if(void 0===t)return a.removeItem(e);e=gi(e);const{relativeKey:s,driver:o}=r(e);o.setItem&&(await li(o.setItem,s,fi(t),n),o.watch||i("update",e))},async setItems(e,t){await o(e,t,(async e=>{e.driver.setItems&&await li(e.driver.setItems,e.items.map((e=>({key:e.relativeKey,value:fi(e.value),options:e.options}))),t),e.driver.setItem&&await Promise.all(e.items.map((t=>li(e.driver.setItem,t.relativeKey,fi(t.value),t.options))))}))},async setItemRaw(e,t,n={}){if(void 0===t)return a.removeItem(e,n);e=gi(e);const{relativeKey:s,driver:o}=r(e);if(o.setItemRaw)await li(o.setItemRaw,s,t,n);else{if(!o.setItem)return;await li(o.setItem,s,function(e){if("string"==typeof e)return e;pi();const t=Buffer.from(e).toString("base64");return di+t}(t),n)}o.watch||i("update",e)},async removeItem(e,t={}){"boolean"==typeof t&&(t={removeMeta:t}),e=gi(e);const{relativeKey:n,driver:s}=r(e);s.removeItem&&(await li(s.removeItem,n,t),(t.removeMeta||t.removeMata)&&await li(s.removeItem,n+"$",t),s.watch||i("remove",e))},async getMeta(e,t={}){"boolean"==typeof t&&(t={nativeOnly:t}),e=gi(e);const{relativeKey:n,driver:i}=r(e),s=Object.create(null);if(i.getMeta&&Object.assign(s,await li(i.getMeta,n,t)),!t.nativeOnly){const e=await li(i.getItem,n+"$",t).then((e=>ui(e)));e&&"object"==typeof e&&("string"==typeof e.atime&&(e.atime=new Date(e.atime)),"string"==typeof e.mtime&&(e.mtime=new Date(e.mtime)),Object.assign(s,e))}return s},setMeta(e,t,r={}){return this.setItem(e+"$",t,r)},removeMeta(e,t={}){return this.removeItem(e+"$",t)},async getKeys(e,t={}){e=vi(e);const r=n(e,!0);let i=[];const s=[];for(const e of r){const r=(await li(e.driver.getKeys,e.relativeBase,t)).map((t=>e.mountpoint+gi(t))).filter((e=>!i.some((t=>e.startsWith(t)))));s.push(...r),i=[e.mountpoint,...i.filter((t=>!t.startsWith(e.mountpoint)))]}return e?s.filter((t=>t.startsWith(e)&&!t.endsWith("$"))):s.filter((e=>!e.endsWith("$")))},async clear(e,t={}){e=vi(e),await Promise.all(n(e,!1).map((async e=>{if(e.driver.clear)return li(e.driver.clear,e.relativeBase,t);if(e.driver.removeItem){const r=await e.driver.getKeys(e.relativeBase||"",t);return Promise.all(r.map((r=>e.driver.removeItem(r,t))))}})))},async dispose(){await Promise.all(Object.values(t.mounts).map((e=>bi(e))))},watch:async e=>(await(async()=>{if(!t.watching){t.watching=!0;for(const e in t.mounts)t.unwatch[e]=await _i(t.mounts[e],i,e)}})(),t.watchListeners.push(e),async()=>{t.watchListeners=t.watchListeners.filter((t=>t!==e)),0===t.watchListeners.length&&await s()}),async unwatch(){t.watchListeners=[],await s()},mount(e,r){if((e=vi(e))&&t.mounts[e])throw new Error(`already mounted at ${e}`);return e&&(t.mountpoints.push(e),t.mountpoints.sort(((e,t)=>t.length-e.length))),t.mounts[e]=r,t.watching&&Promise.resolve(_i(r,i,e)).then((r=>{t.unwatch[e]=r})).catch(console.error),a},async unmount(e,r=!0){(e=vi(e))&&t.mounts[e]&&(t.watching&&e in t.unwatch&&(t.unwatch[e](),delete t.unwatch[e]),r&&await bi(t.mounts[e]),t.mountpoints=t.mountpoints.filter((t=>t!==e)),delete t.mounts[e])},getMount(e=""){e=gi(e)+":";const t=r(e);return{driver:t.driver,base:t.base}},getMounts(e="",t={}){e=gi(e);return n(e,t.parents).map((e=>({driver:e.driver,base:e.mountpoint})))}};return a}function _i(e,t,r){return e.watch?e.watch(((e,n)=>t(e,r+n))):()=>{}}async function bi(e){"function"==typeof e.dispose&&await li(e.dispose)}function Ei(e){return new Promise(((t,r)=>{e.oncomplete=e.onsuccess=()=>t(e.result),e.onabort=e.onerror=()=>r(e.error)}))}function Ii(e,t){const r=indexedDB.open(e);r.onupgradeneeded=()=>r.result.createObjectStore(t);const n=Ei(r);return(e,r)=>n.then((n=>r(n.transaction(t,e).objectStore(t))))}let Si;function Pi(){return Si||(Si=Ii("keyval-store","keyval")),Si}function Oi(e,t=Pi()){return t("readonly",(t=>Ei(t.get(e))))}function Ni(e=Pi()){return e("readonly",(e=>{if(e.getAllKeys)return Ei(e.getAllKeys());const t=[];return function(e,t){return e.openCursor().onsuccess=function(){this.result&&(t(this.result),this.result.continue())},Ei(e.transaction)}(e,(e=>t.push(e.key))).then((()=>t))}))}const Ai=e=>JSON.stringify(e,((e,t)=>"bigint"==typeof t?t.toString()+"n":t)),Ci=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))};function Ri(e){if("string"!=typeof e)throw new Error("Cannot safe json parse value of type "+typeof e);try{return Ci(e)}catch(t){return e}}function xi(e){return"string"==typeof e?e:Ai(e)||""}var Ti=(e={})=>{const t=e.base&&e.base.length>0?`${e.base}:`:"",r=e=>t+e;let n;return e.dbName&&e.storeName&&(n=Ii(e.dbName,e.storeName)),{name:"idb-keyval",options:e,hasItem:async e=>!(typeof await Oi(r(e),n)>"u"),getItem:async e=>await Oi(r(e),n)??null,setItem:(e,t)=>function(e,t,r=Pi()){return r("readwrite",(r=>(r.put(t,e),Ei(r.transaction))))}(r(e),t,n),removeItem:e=>function(e,t=Pi()){return t("readwrite",(t=>(t.delete(e),Ei(t.transaction))))}(r(e),n),getKeys:()=>Ni(n),clear:()=>function(e=Pi()){return e("readwrite",(e=>(e.clear(),Ei(e.transaction))))}(n)}};class Li{constructor(){this.indexedDb=wi({driver:Ti({dbName:"WALLET_CONNECT_V2_INDEXED_DB",storeName:"keyvaluestorage"})})}async getKeys(){return this.indexedDb.getKeys()}async getEntries(){return(await this.indexedDb.getItems(await this.indexedDb.getKeys())).map((e=>[e.key,e.value]))}async getItem(e){const t=await this.indexedDb.getItem(e);if(null!==t)return t}async setItem(e,t){await this.indexedDb.setItem(e,xi(t))}async removeItem(e){await this.indexedDb.removeItem(e)}}var Ui=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},ji={exports:{}};function Mi(e){var t;return[e[0],Ri(null!=(t=e[1])?t:"")]}!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})),typeof Ui<"u"&&Ui.localStorage?ji.exports=Ui.localStorage:typeof window<"u"&&window.localStorage?ji.exports=window.localStorage:ji.exports=new t}();class Di{constructor(){this.localStorage=ji.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(Mi)}async getItem(e){const t=this.localStorage.getItem(e);if(null!==t)return Ri(t)}async setItem(e,t){this.localStorage.setItem(e,xi(t))}async removeItem(e){this.localStorage.removeItem(e)}}const ki=async(e,t)=>{t.length&&t.forEach((async t=>{await e.removeItem(t)}))};class $i{constructor(){this.initialized=!1,this.setInitialized=e=>{this.storage=e,this.initialized=!0};const e=new Di;this.storage=e;try{(async(e,t,r)=>{const n="wc_storage_version",i=await t.getItem(n);if(i&&i>=1)return void r(t);const s=await e.getKeys();if(!s.length)return void r(t);const o=[];for(;s.length;){const r=s.shift();if(!r)continue;const n=r.toLowerCase();if(n.includes("wc@")||n.includes("walletconnect")||n.includes("wc_")||n.includes("wallet_connect")){const n=await e.getItem(r);await t.setItem(r,n),o.push(r)}}await t.setItem(n,1),r(t),ki(e,o)})(e,new Li,this.setInitialized)}catch{this.initialized=!0}}async getKeys(){return await this.initialize(),this.storage.getKeys()}async getEntries(){return await this.initialize(),this.storage.getEntries()}async getItem(e){return await this.initialize(),this.storage.getItem(e)}async setItem(e,t){return await this.initialize(),this.storage.setItem(e,t)}async removeItem(e){return await this.initialize(),this.storage.removeItem(e)}async initialize(){this.initialized||await new Promise((e=>{const t=setInterval((()=>{this.initialized&&(clearInterval(t),e())}),20)}))}}var zi={},qi={},Hi={},Ki={};class Vi{}var Bi,Fi,Wi=s(Object.freeze({__proto__:null,IEvents:Vi}));function Gi(){return Fi||(Fi=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});i.__exportStar(function(){if(Bi)return Ki;Bi=1,Object.defineProperty(Ki,"__esModule",{value:!0}),Ki.IHeartBeat=void 0;const e=Wi;class t extends e.IEvents{constructor(e){super()}}return Ki.IHeartBeat=t,Ki}(),e)}(Hi)),Hi}var Yi,Qi,Ji,Xi={},Zi={};function es(){return Qi||(Qi=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});i.__exportStar(function(){if(Yi)return Zi;Yi=1,Object.defineProperty(Zi,"__esModule",{value:!0}),Zi.HEARTBEAT_EVENTS=Zi.HEARTBEAT_INTERVAL=void 0;const e=qt;return Zi.HEARTBEAT_INTERVAL=e.FIVE_SECONDS,Zi.HEARTBEAT_EVENTS={pulse:"heartbeat_pulse"},Zi}(),e)}(Xi)),Xi}!function(t){Object.defineProperty(t,"__esModule",{value:!0});const r=i;r.__exportStar(function(){if(Ji)return qi;Ji=1,Object.defineProperty(qi,"__esModule",{value:!0}),qi.HeartBeat=void 0;const t=i,r=e,n=qt,s=Gi(),o=es();class a extends s.IHeartBeat{constructor(e){super(e),this.events=new r.EventEmitter,this.interval=o.HEARTBEAT_INTERVAL,this.interval=(null==e?void 0:e.interval)||o.HEARTBEAT_INTERVAL}static init(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=new a(e);return yield t.init(),t}))}init(){return t.__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 t.__awaiter(this,void 0,void 0,(function*(){this.intervalRef=setInterval((()=>this.pulse()),n.toMiliseconds(this.interval))}))}pulse(){this.events.emit(o.HEARTBEAT_EVENTS.pulse)}}return qi.HeartBeat=a,qi}(),t),r.__exportStar(Gi(),t),r.__exportStar(es(),t)}(zi);var ts,rs,ns,is,ss={};function os(){if(is)return ns;is=1;const e=function(){if(rs)return ts;function e(e){try{return JSON.stringify(e)}catch(e){return'"[Circular]"'}}return rs=1,ts=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 h="",u=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(u>=c)break;if(null==r[u])break;l<p&&(h+=t.slice(l,p)),h+=Number(r[u]),l=p+2,p++;break;case 105:if(u>=c)break;if(null==r[u])break;l<p&&(h+=t.slice(l,p)),h+=Math.floor(Number(r[u])),l=p+2,p++;break;case 79:case 111:case 106:if(u>=c)break;if(void 0===r[u])break;l<p&&(h+=t.slice(l,p));var d=typeof r[u];if("string"===d){h+="'"+r[u]+"'",l=p+2,p++;break}if("function"===d){h+=r[u].name||"<anonymous>",l=p+2,p++;break}h+=i(r[u]),l=p+2,p++;break;case 115:if(u>=c)break;l<p&&(h+=t.slice(l,p)),h+=String(r[u]),l=p+2,p++;break;case 37:l<p&&(h+=t.slice(l,p)),h+="%",l=p+2,p++,u--}++u}++p}return-1===l?t:(l<f&&(h+=t.slice(l)),h)},ts}();ns=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:h,mapHttpResponse:h,wrapRequestSerializer:u,wrapResponseSerializer:u,wrapErrorSerializer:u,req:h,res:h,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 h=e.browser.write||t;e.browser.write&&(e.browser.asObject=!0);const u=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,u);let p=e.browser.serialize;Array.isArray(e.browser.serialize)&&e.browser.serialize.indexOf("!stdSerializers.err")>-1&&(p=!1);"function"==typeof h&&(h.error=h.fatal=h.warn=h.info=h.debug=h.trace=h),!1===e.enabled&&(e.level="silent");const d=e.level||"info",g=Object.create(h);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=u,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({},u,i),h=!0===e.browser.serialize?Object.keys(c):f;delete t.serializers,s([t],h,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=h),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 h=Object.getPrototypeOf(i);i[o]=i.levelVal>i.levels.values[o]?l:h[o]?h[o]:t[o]||t[c]||l,function(r,i,o){if(!r.transmit&&i[o]===l)return;i[o]=(c=i[o],function(){const h=r.timestamp(),u=new Array(arguments.length),l=Object.getPrototypeOf&&Object.getPrototypeOf(this)===t?t:this;for(var f=0;f<u.length;f++)u[f]=arguments[f];if(r.serialize&&!r.asObject&&s(u,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 h={};o&&(h.time=o),h.level=n.levels.values[r];let u=1+(0|t._childLevel);if(u<1&&(u=1),null!==c&&"object"==typeof c){for(;u--&&"object"==typeof a[0];)Object.assign(h,a.shift());c=a.length?e(a.shift(),a):void 0}else"string"==typeof c&&(c=e(a.shift(),a));return void 0!==c&&(h.msg=c),h}(this,o,u,h)):c.apply(l,u),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,h=t.val,u=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===u.indexOf(e)})),e._logEvent.level.label=o,e._logEvent.level.value=c,n(o,e._logEvent,h),e._logEvent=a(u)}(this,{ts:h,methodLevel:o,methodValue:c,transmitLevel:e,transmitValue:n.levels.values[r.transmit.level||i.level],send:r.transmit.send,val:i.levelVal},u)}});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 h(){return{}}function u(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()}}),ns}var as,cs={};function hs(){return as||(as=1,Object.defineProperty(cs,"__esModule",{value:!0}),cs.PINO_CUSTOM_CONTEXT_KEY=cs.PINO_LOGGER_DEFAULTS=void 0,cs.PINO_LOGGER_DEFAULTS={level:"info"},cs.PINO_CUSTOM_CONTEXT_KEY="custom_context"),cs}var us,ls={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.pino=void 0;const t=i,r=t.__importDefault(os());Object.defineProperty(e,"pino",{enumerable:!0,get:function(){return r.default}}),t.__exportStar(hs(),e),t.__exportStar(function(){if(us)return ls;us=1,Object.defineProperty(ls,"__esModule",{value:!0}),ls.generateChildLogger=ls.formatChildLoggerContext=ls.getLoggerContext=ls.setBrowserLoggerContext=ls.getBrowserLoggerContext=ls.getDefaultLoggerOptions=void 0;const e=hs();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 ls.getDefaultLoggerOptions=function(t){return Object.assign(Object.assign({},t),{level:(null==t?void 0:t.level)||e.PINO_LOGGER_DEFAULTS.level})},ls.getBrowserLoggerContext=t,ls.setBrowserLoggerContext=r,ls.getLoggerContext=n,ls.formatChildLoggerContext=i,ls.generateChildLogger=function(t,n,s=e.PINO_CUSTOM_CONTEXT_KEY){const o=i(t,n,s);return r(t.child({context:o}),o,s)},ls}(),e)}(ss);class fs extends Vi{constructor(e){super(),this.opts=e,this.protocol="wc",this.version=2}}class ps extends Vi{constructor(e,t){super(),this.core=e,this.logger=t,this.records=new Map}}class ds{constructor(e,t){this.logger=e,this.core=t}}class gs extends Vi{constructor(e,t){super(),this.relayer=e,this.logger=t}}class ys extends Vi{constructor(e){super()}}class vs{constructor(e,t,r,n){this.core=e,this.logger=t,this.name=r}}class ms extends Vi{constructor(e,t){super(),this.relayer=e,this.logger=t}}class ws extends Vi{constructor(e,t){super(),this.core=e,this.logger=t}}class _s{constructor(e,t){this.projectId=e,this.logger=t}}class bs{constructor(e){this.opts=e,this.protocol="wc",this.version=2}}class Es{constructor(e){this.client=e}}var Is={},Ss={};!function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=l,r=S;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 h,u,l,f,p,d,g,y,v=n[0],m=n[1],w=n[2],_=n[3],b=n[4],E=n[5],I=n[6],S=n[7],P=s[0],O=s[1],N=s[2],A=s[3],C=s[4],R=s[5],x=s[6],T=s[7];c>=128;){for(var L=0;L<16;L++){var U=8*L+a;e[L]=t.readUint32BE(o,U),r[L]=t.readUint32BE(o,U+4)}for(L=0;L<80;L++){var j,M,D=v,k=m,$=w,z=_,q=b,H=E,K=I,V=P,B=O,F=N,W=A,G=C,Y=R,Q=x;if(p=65535&(u=T),d=u>>>16,g=65535&(h=S),y=h>>>16,p+=65535&(u=(C>>>14|b<<18)^(C>>>18|b<<14)^(b>>>9|C<<23)),d+=u>>>16,g+=65535&(h=(b>>>14|C<<18)^(b>>>18|C<<14)^(C>>>9|b<<23)),y+=h>>>16,p+=65535&(u=C&R^~C&x),d+=u>>>16,g+=65535&(h=b&E^~b&I),y+=h>>>16,h=i[2*L],p+=65535&(u=i[2*L+1]),d+=u>>>16,g+=65535&h,y+=h>>>16,h=e[L%16],d+=(u=r[L%16])>>>16,g+=65535&h,y+=h>>>16,g+=(d+=(p+=65535&u)>>>16)>>>16,p=65535&(u=f=65535&p|d<<16),d=u>>>16,g=65535&(h=l=65535&g|(y+=g>>>16)<<16),y=h>>>16,p+=65535&(u=(P>>>28|v<<4)^(v>>>2|P<<30)^(v>>>7|P<<25)),d+=u>>>16,g+=65535&(h=(v>>>28|P<<4)^(P>>>2|v<<30)^(P>>>7|v<<25)),y+=h>>>16,d+=(u=P&O^P&N^O&N)>>>16,g+=65535&(h=v&m^v&w^m&w),y+=h>>>16,j=65535&(g+=(d+=(p+=65535&u)>>>16)>>>16)|(y+=g>>>16)<<16,M=65535&p|d<<16,p=65535&(u=W),d=u>>>16,g=65535&(h=z),y=h>>>16,d+=(u=f)>>>16,g+=65535&(h=l),y+=h>>>16,m=D,w=k,_=$,b=z=65535&(g+=(d+=(p+=65535&u)>>>16)>>>16)|(y+=g>>>16)<<16,E=q,I=H,S=K,v=j,O=V,N=B,A=F,C=W=65535&p|d<<16,R=G,x=Y,T=Q,P=M,L%16==15)for(U=0;U<16;U++)h=e[U],p=65535&(u=r[U]),d=u>>>16,g=65535&h,y=h>>>16,h=e[(U+9)%16],p+=65535&(u=r[(U+9)%16]),d+=u>>>16,g+=65535&h,y+=h>>>16,l=e[(U+1)%16],p+=65535&(u=((f=r[(U+1)%16])>>>1|l<<31)^(f>>>8|l<<24)^(f>>>7|l<<25)),d+=u>>>16,g+=65535&(h=(l>>>1|f<<31)^(l>>>8|f<<24)^l>>>7),y+=h>>>16,l=e[(U+14)%16],d+=(u=((f=r[(U+14)%16])>>>19|l<<13)^(l>>>29|f<<3)^(f>>>6|l<<26))>>>16,g+=65535&(h=(l>>>19|f<<13)^(f>>>29|l<<3)^l>>>6),y+=h>>>16,y+=(g+=(d+=(p+=65535&u)>>>16)>>>16)>>>16,e[U]=65535&g|y<<16,r[U]=65535&p|d<<16}p=65535&(u=P),d=u>>>16,g=65535&(h=v),y=h>>>16,h=n[0],d+=(u=s[0])>>>16,g+=65535&h,y+=h>>>16,y+=(g+=(d+=(p+=65535&u)>>>16)>>>16)>>>16,n[0]=v=65535&g|y<<16,s[0]=P=65535&p|d<<16,p=65535&(u=O),d=u>>>16,g=65535&(h=m),y=h>>>16,h=n[1],d+=(u=s[1])>>>16,g+=65535&h,y+=h>>>16,y+=(g+=(d+=(p+=65535&u)>>>16)>>>16)>>>16,n[1]=m=65535&g|y<<16,s[1]=O=65535&p|d<<16,p=65535&(u=N),d=u>>>16,g=65535&(h=w),y=h>>>16,h=n[2],d+=(u=s[2])>>>16,g+=65535&h,y+=h>>>16,y+=(g+=(d+=(p+=65535&u)>>>16)>>>16)>>>16,n[2]=w=65535&g|y<<16,s[2]=N=65535&p|d<<16,p=65535&(u=A),d=u>>>16,g=65535&(h=_),y=h>>>16,h=n[3],d+=(u=s[3])>>>16,g+=65535&h,y+=h>>>16,y+=(g+=(d+=(p+=65535&u)>>>16)>>>16)>>>16,n[3]=_=65535&g|y<<16,s[3]=A=65535&p|d<<16,p=65535&(u=C),d=u>>>16,g=65535&(h=b),y=h>>>16,h=n[4],d+=(u=s[4])>>>16,g+=65535&h,y+=h>>>16,y+=(g+=(d+=(p+=65535&u)>>>16)>>>16)>>>16,n[4]=b=65535&g|y<<16,s[4]=C=65535&p|d<<16,p=65535&(u=R),d=u>>>16,g=65535&(h=E),y=h>>>16,h=n[5],d+=(u=s[5])>>>16,g+=65535&h,y+=h>>>16,y+=(g+=(d+=(p+=65535&u)>>>16)>>>16)>>>16,n[5]=E=65535&g|y<<16,s[5]=R=65535&p|d<<16,p=65535&(u=x),d=u>>>16,g=65535&(h=I),y=h>>>16,h=n[6],d+=(u=s[6])>>>16,g+=65535&h,y+=h>>>16,y+=(g+=(d+=(p+=65535&u)>>>16)>>>16)>>>16,n[6]=I=65535&g|y<<16,s[6]=x=65535&p|d<<16,p=65535&(u=T),d=u>>>16,g=65535&(h=S),y=h>>>16,h=n[7],d+=(u=s[7])>>>16,g+=65535&h,y+=h>>>16,y+=(g+=(d+=(p+=65535&u)>>>16)>>>16)>>>16,n[7]=S=65535&g|y<<16,s[7]=T=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}}(Ss),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=B,r=Ss,n=S;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]),h=i([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),u=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 m(e){const t=new Uint8Array(32);return g(t,e),1&t[0]}function w(e,t,r){for(let n=0;n<16;n++)e[n]=t[n]+r[n]}function _(e,t,r){for(let n=0;n<16;n++)e[n]=t[n]-r[n]}function b(e,t,r){let n,i,s=0,o=0,a=0,c=0,h=0,u=0,l=0,f=0,p=0,d=0,g=0,y=0,v=0,m=0,w=0,_=0,b=0,E=0,I=0,S=0,P=0,O=0,N=0,A=0,C=0,R=0,x=0,T=0,L=0,U=0,j=0,M=r[0],D=r[1],k=r[2],$=r[3],z=r[4],q=r[5],H=r[6],K=r[7],V=r[8],B=r[9],F=r[10],W=r[11],G=r[12],Y=r[13],Q=r[14],J=r[15];n=t[0],s+=n*M,o+=n*D,a+=n*k,c+=n*$,h+=n*z,u+=n*q,l+=n*H,f+=n*K,p+=n*V,d+=n*B,g+=n*F,y+=n*W,v+=n*G,m+=n*Y,w+=n*Q,_+=n*J,n=t[1],o+=n*M,a+=n*D,c+=n*k,h+=n*$,u+=n*z,l+=n*q,f+=n*H,p+=n*K,d+=n*V,g+=n*B,y+=n*F,v+=n*W,m+=n*G,w+=n*Y,_+=n*Q,b+=n*J,n=t[2],a+=n*M,c+=n*D,h+=n*k,u+=n*$,l+=n*z,f+=n*q,p+=n*H,d+=n*K,g+=n*V,y+=n*B,v+=n*F,m+=n*W,w+=n*G,_+=n*Y,b+=n*Q,E+=n*J,n=t[3],c+=n*M,h+=n*D,u+=n*k,l+=n*$,f+=n*z,p+=n*q,d+=n*H,g+=n*K,y+=n*V,v+=n*B,m+=n*F,w+=n*W,_+=n*G,b+=n*Y,E+=n*Q,I+=n*J,n=t[4],h+=n*M,u+=n*D,l+=n*k,f+=n*$,p+=n*z,d+=n*q,g+=n*H,y+=n*K,v+=n*V,m+=n*B,w+=n*F,_+=n*W,b+=n*G,E+=n*Y,I+=n*Q,S+=n*J,n=t[5],u+=n*M,l+=n*D,f+=n*k,p+=n*$,d+=n*z,g+=n*q,y+=n*H,v+=n*K,m+=n*V,w+=n*B,_+=n*F,b+=n*W,E+=n*G,I+=n*Y,S+=n*Q,P+=n*J,n=t[6],l+=n*M,f+=n*D,p+=n*k,d+=n*$,g+=n*z,y+=n*q,v+=n*H,m+=n*K,w+=n*V,_+=n*B,b+=n*F,E+=n*W,I+=n*G,S+=n*Y,P+=n*Q,O+=n*J,n=t[7],f+=n*M,p+=n*D,d+=n*k,g+=n*$,y+=n*z,v+=n*q,m+=n*H,w+=n*K,_+=n*V,b+=n*B,E+=n*F,I+=n*W,S+=n*G,P+=n*Y,O+=n*Q,N+=n*J,n=t[8],p+=n*M,d+=n*D,g+=n*k,y+=n*$,v+=n*z,m+=n*q,w+=n*H,_+=n*K,b+=n*V,E+=n*B,I+=n*F,S+=n*W,P+=n*G,O+=n*Y,N+=n*Q,A+=n*J,n=t[9],d+=n*M,g+=n*D,y+=n*k,v+=n*$,m+=n*z,w+=n*q,_+=n*H,b+=n*K,E+=n*V,I+=n*B,S+=n*F,P+=n*W,O+=n*G,N+=n*Y,A+=n*Q,C+=n*J,n=t[10],g+=n*M,y+=n*D,v+=n*k,m+=n*$,w+=n*z,_+=n*q,b+=n*H,E+=n*K,I+=n*V,S+=n*B,P+=n*F,O+=n*W,N+=n*G,A+=n*Y,C+=n*Q,R+=n*J,n=t[11],y+=n*M,v+=n*D,m+=n*k,w+=n*$,_+=n*z,b+=n*q,E+=n*H,I+=n*K,S+=n*V,P+=n*B,O+=n*F,N+=n*W,A+=n*G,C+=n*Y,R+=n*Q,x+=n*J,n=t[12],v+=n*M,m+=n*D,w+=n*k,_+=n*$,b+=n*z,E+=n*q,I+=n*H,S+=n*K,P+=n*V,O+=n*B,N+=n*F,A+=n*W,C+=n*G,R+=n*Y,x+=n*Q,T+=n*J,n=t[13],m+=n*M,w+=n*D,_+=n*k,b+=n*$,E+=n*z,I+=n*q,S+=n*H,P+=n*K,O+=n*V,N+=n*B,A+=n*F,C+=n*W,R+=n*G,x+=n*Y,T+=n*Q,L+=n*J,n=t[14],w+=n*M,_+=n*D,b+=n*k,E+=n*$,I+=n*z,S+=n*q,P+=n*H,O+=n*K,N+=n*V,A+=n*B,C+=n*F,R+=n*W,x+=n*G,T+=n*Y,L+=n*Q,U+=n*J,n=t[15],_+=n*M,b+=n*D,E+=n*k,I+=n*$,S+=n*z,P+=n*q,O+=n*H,N+=n*K,A+=n*V,C+=n*B,R+=n*F,x+=n*W,T+=n*G,L+=n*Y,U+=n*Q,j+=n*J,s+=38*b,o+=38*E,a+=38*I,c+=38*S,h+=38*P,u+=38*O,l+=38*N,f+=38*A,p+=38*C,d+=38*R,g+=38*x,y+=38*T,v+=38*L,m+=38*U,w+=38*j,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=h+i+65535,i=Math.floor(n/65536),h=n-65536*i,n=u+i+65535,i=Math.floor(n/65536),u=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=m+i+65535,i=Math.floor(n/65536),m=n-65536*i,n=w+i+65535,i=Math.floor(n/65536),w=n-65536*i,n=_+i+65535,i=Math.floor(n/65536),_=n-65536*i,s+=i-1+37*(i-1),i=1,n=s+i+65535,i=Math.floor(n/65536),s=n-65536*i,n=o+i+65535,i=Math.floor(n/65536),o=n-65536*i,n=a+i+65535,i=Math.floor(n/65536),a=n-65536*i,n=c+i+65535,i=Math.floor(n/65536),c=n-65536*i,n=h+i+65535,i=Math.floor(n/65536),h=n-65536*i,n=u+i+65535,i=Math.floor(n/65536),u=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=m+i+65535,i=Math.floor(n/65536),m=n-65536*i,n=w+i+65535,i=Math.floor(n/65536),w=n-65536*i,n=_+i+65535,i=Math.floor(n/65536),_=n-65536*i,s+=i-1+37*(i-1),e[0]=s,e[1]=o,e[2]=a,e[3]=c,e[4]=h,e[5]=u,e[6]=l,e[7]=f,e[8]=p,e[9]=d,e[10]=g,e[11]=y,e[12]=v,e[13]=m,e[14]=w,e[15]=_}function E(e,t){b(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--)E(r,r),2!==n&&4!==n&&b(r,r,t);for(n=0;n<16;n++)e[n]=r[n]}function P(e,t){const r=i(),n=i(),s=i(),o=i(),a=i(),h=i(),u=i(),l=i(),f=i();_(r,e[1],e[0]),_(f,t[1],t[0]),b(r,r,f),w(n,e[0],e[1]),w(f,t[0],t[1]),b(n,n,f),b(s,e[3],t[3]),b(s,s,c),b(o,e[2],t[2]),w(o,o,o),_(a,n,r),_(h,o,s),w(u,o,s),w(l,n,r),b(e[0],a,h),b(e[1],l,u),b(e[2],u,h),b(e[3],a,l)}function O(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]),b(r,t[0],s),b(n,t[1],s),g(e,n),e[31]^=m(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;O(e,t,i),P(t,e),P(e,e),O(e,t,i)}}function C(e,t){const r=[i(),i(),i(),i()];f(r[0],h),f(r[1],u),f(r[2],o),b(r[3],h,u),A(e,r,t)}function R(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()];C(o,n),N(s,o);const a=new Uint8Array(64);return a.set(t),a.set(s,32),{publicKey:s,secretKey:a}}e.generateKeyPairFromSeed=R,e.generateKeyPair=function(e){const r=(0,t.randomBytes)(32,e),i=R(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 x=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 T(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]*x[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)*x[i],r=t[i]>>8,t[i]&=255;for(i=0;i<32;i++)t[i]-=r*x[i];for(n=0;n<32;n++)t[n+1]+=t[n]>>8,e[n]=255&t[n]}function L(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;T(e,t)}function U(e,t){const r=i(),n=i(),c=i(),h=i(),u=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),E(c,e[1]),b(h,c,a),_(c,c,e[2]),w(h,e[2],h),E(u,h),E(p,u),b(d,p,u),b(r,d,c),b(r,r,h),function(e,t){const r=i();let n;for(n=0;n<16;n++)r[n]=t[n];for(n=250;n>=0;n--)E(r,r),1!==n&&b(r,r,t);for(n=0;n<16;n++)e[n]=r[n]}(r,r),b(r,r,c),b(r,r,h),b(r,r,h),b(e[0],r,h),E(n,e[0]),b(n,n,h),v(n,c)&&b(e[0],e[0],l),E(n,e[0]),b(n,n,h),v(n,c)?-1:(m(e[0])===t[31]>>7&&_(e[0],s,e[0]),b(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 h=c.digest();c.clean(),L(h),C(s,h),N(a,s),c.reset(),c.update(a.subarray(0,32)),c.update(e.subarray(32)),c.update(t);const u=c.digest();L(u);for(let e=0;e<32;e++)n[e]=h[e];for(let e=0;e<32;e++)for(let t=0;t<32;t++)n[e+t]+=u[e]*o[t];return T(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(U(c,t))return!1;const h=new r.SHA512;h.update(s.subarray(0,32)),h.update(t),h.update(n);const u=h.digest();return L(u),A(a,c,u),C(c,s.subarray(32)),P(a,c),N(o,a),!y(s,o)},e.convertPublicKeyToX25519=function(e){let t=[i(),i(),i(),i()];if(U(t,e))throw new Error("Ed25519: invalid public key");let r=i(),n=i(),s=t[1];w(r,o,s),_(n,o,s),I(n,n),b(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}}(Is);const Ps=".",Os="base64url",Ns="utf8",As="utf8",Cs=":",Rs="did",xs="key",Ts="base58btc",Ls="z",Us="K36";function js(e){return Nt(Ot(xi(e),Ns),Os)}function Ms(e){const t=Ot(Us,Ts),r=Ls+Nt(re([t,e]),Ts);return[Rs,xs,r].join(Cs)}function Ds(e=B.randomBytes(32)){return Is.generateKeyPairFromSeed(e)}async function ks(e,t,r,n,i=qt.fromMiliseconds(Date.now())){const s={alg:"EdDSA",typ:"JWT"},o={iss:Ms(n.publicKey),sub:e,aud:t,iat:i,exp:i+r},a=Ot([js((c={header:s,payload:o}).header),js(c.payload)].join(Ps),As);var c;return function(e){return[js(e.header),js(e.payload),(t=e.signature,Nt(t,Os))].join(Ps);var t}({header:s,payload:o,signature:Is.sign(n.secretKey,a)})}const $s="INTERNAL_ERROR",zs="SERVER_ERROR",qs=[-32700,-32600,-32601,-32602,-32603],Hs={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"},[$s]:{code:-32603,message:"Internal error"},[zs]:{code:-32e3,message:"Server error"}},Ks=zs;function Vs(e){return Object.keys(Hs).includes(e)?Hs[e]:Hs[Ks]}function Bs(e,t,r){return e.message.includes("getaddrinfo ENOTFOUND")||e.message.includes("connect ECONNREFUSED")?new Error(`Unavailable ${r} RPC url at ${t}`):e}var Fs,Ws={},Gs={};var Ys,Qs={};function Js(e=3){return Date.now()*Math.pow(10,e)+Math.floor(Math.random()*Math.pow(10,e))}function Xs(e=6){return BigInt(Js(e))}function Zs(e,t,r){return{id:r||Js(),jsonrpc:"2.0",method:e,params:t}}function eo(e,t){return{id:e,jsonrpc:"2.0",result:t}}function to(e,t,r){return{id:e,jsonrpc:"2.0",error:ro(t,r)}}function ro(e,t){return void 0===e?Vs($s):("string"==typeof e&&(e=Object.assign(Object.assign({},Vs(zs)),{message:e})),void 0!==t&&(e.data=t),function(e){return qs.includes(e)}(e.code)&&(e=function(e){const t=Object.values(Hs).find((t=>t.code===e));return t||Hs[Ks]}(e.code)),e)}!function(e){Object.defineProperty(e,"__esModule",{value:!0});const t=i;t.__exportStar(function(){if(Fs)return Gs;function e(){return(null==o?void 0:o.crypto)||(null==o?void 0:o.msCrypto)||{}}function t(){const t=e();return t.subtle||t.webkitSubtle}return Fs=1,Object.defineProperty(Gs,"__esModule",{value:!0}),Gs.isBrowserCryptoAvailable=Gs.getSubtleCrypto=Gs.getBrowerCrypto=void 0,Gs.getBrowerCrypto=e,Gs.getSubtleCrypto=t,Gs.isBrowserCryptoAvailable=function(){return!!e()&&!!t()},Gs}(),e),t.__exportStar(function(){if(Ys)return Qs;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 Ys=1,Object.defineProperty(Qs,"__esModule",{value:!0}),Qs.isBrowser=Qs.isNode=Qs.isReactNative=void 0,Qs.isReactNative=e,Qs.isNode=t,Qs.isBrowser=function(){return!e()&&!t()},Qs}(),e)}(Ws);class no{}class io extends no{constructor(){super()}}class so extends io{constructor(e){super()}}function oo(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 ao(e){return oo(e,"^https?:")}function co(e){return oo(e,"^wss?:")}function ho(e){return"object"==typeof e&&"id"in e&&"jsonrpc"in e&&"2.0"===e.jsonrpc}function uo(e){return ho(e)&&"method"in e}function lo(e){return ho(e)&&(fo(e)||po(e))}function fo(e){return"result"in e}function po(e){return"error"in e}class go extends so{constructor(e){super(e),this.events=new t,this.hasRegisteredEventListeners=!1,this.connection=this.setConnection(e),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(Zs(e.method,e.params||[],e.id||Xs().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=>{po(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),lo(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 yo=e=>e.split("?")[0],vo=typeof WebSocket<"u"?WebSocket:typeof global<"u"&&typeof global.WebSocket<"u"?global.WebSocket:typeof window<"u"&&typeof window.WebSocket<"u"?window.WebSocket:typeof self<"u"&&typeof self.WebSocket<"u"?self.WebSocket:require("ws");class mo{constructor(e){if(this.url=e,this.events=new t,this.registering=!1,!co(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);this.url=e}get connected(){return typeof this.socket<"u"}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)=>{typeof this.socket>"u"?t(new Error("Connection already closed")):(this.socket.onclose=t=>{this.onClose(t),e()},this.socket.close())}))}async send(e){typeof this.socket>"u"&&(this.socket=await this.register());try{this.socket.send(xi(e))}catch(t){this.onError(e.id,t)}}register(e=this.url){if(!co(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(),typeof this.socket>"u")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=new URLSearchParams(e).get("origin"),i=Ws.isReactNative()?{headers:{origin:n}}:{rejectUnauthorized:(o=e,!new RegExp("wss?://localhost(:d{2,5})?").test(o))},s=new vo(e,[],i);var o;typeof WebSocket<"u"||typeof global<"u"&&typeof global.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof self<"u"&&typeof self.WebSocket<"u"?s.onerror=e=>{const t=e;r(this.emitError(t.error))}:s.on("error",(e=>{r(this.emitError(e))})),s.onopen=()=>{this.onOpen(s),t(s)}}))}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(typeof e.data>"u")return;const t="string"==typeof e.data?Ri(e.data):e.data;this.events.emit("payload",t)}onError(e,t){const r=this.parseError(t),n=to(e,r.message||r.toString());this.events.emit("payload",n)}parseError(e,t=this.url){return Bs(e,yo(t),"WS")}resetMaxListeners(){this.events.getMaxListeners()>10&&this.events.setMaxListeners(10)}emitError(e){const t=this.parseError(new Error(e?.message||`WebSocket connection failed for host: ${yo(this.url)}`));return this.events.emit("register_error",t),t}}var wo={exports:{}};!function(e,t){var r="__lodash_hash_undefined__",n=1,i=2,s=9007199254740991,a="[object Arguments]",c="[object Array]",h="[object AsyncFunction]",u="[object Boolean]",l="[object Date]",f="[object Error]",p="[object Function]",d="[object GeneratorFunction]",g="[object Map]",y="[object Number]",v="[object Null]",m="[object Object]",w="[object Promise]",_="[object Proxy]",b="[object RegExp]",E="[object Set]",I="[object String]",S="[object Symbol]",P="[object Undefined]",O="[object WeakMap]",N="[object ArrayBuffer]",A="[object DataView]",C=/^\[object .+?Constructor\]$/,R=/^(?:0|[1-9]\d*)$/,x={};x["[object Float32Array]"]=x["[object Float64Array]"]=x["[object Int8Array]"]=x["[object Int16Array]"]=x["[object Int32Array]"]=x["[object Uint8Array]"]=x["[object Uint8ClampedArray]"]=x["[object Uint16Array]"]=x["[object Uint32Array]"]=!0,x[a]=x[c]=x[N]=x[u]=x[A]=x[l]=x[f]=x[p]=x[g]=x[y]=x[m]=x[b]=x[E]=x[I]=x[O]=!1;var T="object"==typeof o&&o&&o.Object===Object&&o,L="object"==typeof self&&self&&self.Object===Object&&self,U=T||L||Function("return this")(),j=t&&!t.nodeType&&t,M=j&&e&&!e.nodeType&&e,D=M&&M.exports===j,k=D&&T.process,$=function(){try{return k&&k.binding&&k.binding("util")}catch(e){}}(),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,W=Array.prototype,G=Function.prototype,Y=Object.prototype,Q=U["__core-js_shared__"],J=G.toString,X=Y.hasOwnProperty,Z=(V=/[^.]+$/.exec(Q&&Q.keys&&Q.keys.IE_PROTO||""))?"Symbol(src)_1."+V:"",ee=Y.toString,te=RegExp("^"+J.call(X).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),re=D?U.Buffer:void 0,ne=U.Symbol,ie=U.Uint8Array,se=Y.propertyIsEnumerable,oe=W.splice,ae=ne?ne.toStringTag:void 0,ce=Object.getOwnPropertySymbols,he=re?re.isBuffer:void 0,ue=(B=Object.keys,F=Object,function(e){return B(F(e))}),le=$e(U,"DataView"),fe=$e(U,"Map"),pe=$e(U,"Promise"),de=$e(U,"Set"),ge=$e(U,"WeakMap"),ye=$e(Object,"create"),ve=Ke(le),me=Ke(fe),we=Ke(pe),_e=Ke(de),be=Ke(ge),Ee=ne?ne.prototype:void 0,Ie=Ee?Ee.valueOf:void 0;function Se(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 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 Ne(e){var t=-1,r=null==e?0:e.length;for(this.__data__=new Oe;++t<r;)this.add(e[t])}function Ae(e){var t=this.__data__=new Pe(e);this.size=t.size}function Ce(e,t){var r=Fe(e),n=!r&&Be(e),i=!r&&!n&&We(e),s=!r&&!n&&!i&&Xe(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 h in e)!t&&!X.call(e,h)||o&&("length"==h||i&&("offset"==h||"parent"==h)||s&&("buffer"==h||"byteLength"==h||"byteOffset"==h)||He(h,c))||a.push(h);return a}function Re(e,t){for(var r=e.length;r--;)if(Ve(e[r][0],t))return r;return-1}function xe(e){return null==e?void 0===e?P:v:ae&&ae in Object(e)?function(e){var t=X.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 Te(e){return Je(e)&&xe(e)==a}function Le(e,t,r,s,o){return e===t||(null==e||null==t||!Je(e)&&!Je(t)?e!=e&&t!=t:function(e,t,r,s,o,h){var p=Fe(e),d=Fe(t),v=p?c:qe(e),w=d?c:qe(t),_=(v=v==a?m:v)==m,P=(w=w==a?m:w)==m,O=v==w;if(O&&We(e)){if(!We(t))return!1;p=!0,_=!1}if(O&&!_)return h||(h=new Ae),p||Xe(e)?Me(e,t,r,s,o,h):function(e,t,r,s,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 u:case l:case y:return Ve(+e,+t);case f:return e.name==t.name&&e.message==t.message;case b:case I:return e==t+"";case g:var h=H;case E:var p=s&n;if(h||(h=K),e.size!=t.size&&!p)return!1;var d=c.get(e);if(d)return d==t;s|=i,c.set(e,t);var v=Me(h(e),h(t),s,o,a,c);return c.delete(e),v;case S:if(Ie)return Ie.call(e)==Ie.call(t)}return!1}(e,t,v,r,s,o,h);if(!(r&n)){var C=_&&X.call(e,"__wrapped__"),R=P&&X.call(t,"__wrapped__");if(C||R){var x=C?e.value():e,T=R?t.value():t;return h||(h=new Ae),o(x,T,r,s,h)}}if(!O)return!1;return h||(h=new Ae),function(e,t,r,i,s,o){var a=r&n,c=De(e),h=c.length,u=De(t),l=u.length;if(h!=l&&!a)return!1;var f=h;for(;f--;){var p=c[f];if(!(a?p in t:X.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<h;){var v=e[p=c[f]],m=t[p];if(i)var w=a?i(m,v,p,t,e,o):i(v,m,p,e,t,o);if(!(void 0===w?v===m||s(v,m,r,i,o):w)){g=!1;break}y||(y="constructor"==p)}if(g&&!y){var _=e.constructor,b=t.constructor;_==b||!("constructor"in e)||!("constructor"in t)||"function"==typeof _&&_ instanceof _&&"function"==typeof b&&b instanceof b||(g=!1)}return o.delete(e),o.delete(t),g}(e,t,r,s,o,h)}(e,t,r,s,Le,o))}function Ue(e){return!(!Qe(e)||function(e){return!!Z&&Z in e}(e))&&(Ge(e)?te:C).test(Ke(e))}function je(e){if(r=(t=e)&&t.constructor,n="function"==typeof r&&r.prototype||Y,t!==n)return ue(e);var t,r,n,i=[];for(var s in Object(e))X.call(e,s)&&"constructor"!=s&&i.push(s);return i}function Me(e,t,r,s,o,a){var c=r&n,h=e.length,u=t.length;if(h!=u&&!(c&&u>h))return!1;var l=a.get(e);if(l&&a.get(t))return l==t;var f=-1,p=!0,d=r&i?new Ne:void 0;for(a.set(e,t),a.set(t,e);++f<h;){var g=e[f],y=t[f];if(s)var v=c?s(y,g,f,t,e,a):s(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(n=t,!d.has(n)&&(g===e||o(g,e,r,s,a)))return d.push(t);var n}))){p=!1;break}}else if(g!==y&&!o(g,y,r,s,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,Ze,ze)}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 $e(e,t){var r=function(e,t){return null==e?void 0:e[t]}(e,t);return Ue(r)?r:void 0}Se.prototype.clear=function(){this.__data__=ye?ye(null):{},this.size=0},Se.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},Se.prototype.get=function(e){var t=this.__data__;if(ye){var n=t[e];return n===r?void 0:n}return X.call(t,e)?t[e]:void 0},Se.prototype.has=function(e){var t=this.__data__;return ye?void 0!==t[e]:X.call(t,e)},Se.prototype.set=function(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=ye&&void 0===t?r:t,this},Pe.prototype.clear=function(){this.__data__=[],this.size=0},Pe.prototype.delete=function(e){var t=this.__data__,r=Re(t,e);return!(r<0)&&(r==t.length-1?t.pop():oe.call(t,r,1),--this.size,!0)},Pe.prototype.get=function(e){var t=this.__data__,r=Re(t,e);return r<0?void 0:t[r][1]},Pe.prototype.has=function(e){return Re(this.__data__,e)>-1},Pe.prototype.set=function(e,t){var r=this.__data__,n=Re(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this},Oe.prototype.clear=function(){this.size=0,this.__data__={hash:new Se,map:new(fe||Pe),string:new Se}},Oe.prototype.delete=function(e){var t=ke(this,e).delete(e);return this.size-=t?1:0,t},Oe.prototype.get=function(e){return ke(this,e).get(e)},Oe.prototype.has=function(e){return ke(this,e).has(e)},Oe.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,r),this},Ne.prototype.has=function(e){return this.__data__.has(e)},Ae.prototype.clear=function(){this.__data__=new Pe,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 Pe){var n=r.__data__;if(!fe||n.length<199)return n.push([e,t]),this.size=++r.size,this;r=this.__data__=new Oe(n)}return r.set(e,t),this.size=r.size,this};var ze=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=xe;function He(e,t){return!!(t=null==t?s:t)&&("number"==typeof e||R.test(e))&&e>-1&&e%1==0&&e<t}function Ke(e){if(null!=e){try{return J.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())!=w||de&&qe(new de)!=E||ge&&qe(new ge)!=O)&&(qe=function(e){var t=xe(e),r=t==m?e.constructor:void 0,n=r?Ke(r):"";if(n)switch(n){case ve:return A;case me:return g;case we:return w;case _e:return E;case be:return O}return t});var Be=Te(function(){return arguments}())?Te:function(e){return Je(e)&&X.call(e,"callee")&&!se.call(e,"callee")},Fe=Array.isArray;var We=he||function(){return!1};function Ge(e){if(!Qe(e))return!1;var t=xe(e);return t==p||t==d||t==h||t==_}function Ye(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=s}function Qe(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function Je(e){return null!=e&&"object"==typeof e}var Xe=z?function(e){return function(t){return e(t)}}(z):function(e){return Je(e)&&Ye(e.length)&&!!x[xe(e)]};function Ze(e){return null!=(t=e)&&Ye(t.length)&&!Ge(t)?Ce(e):je(e);var t}e.exports=function(e,t){return Le(e,t)}}(wo,wo.exports);var _o=wo.exports;var bo=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),h=Math.log(a)/Math.log(256),u=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)*h+1>>>0,o=new Uint8Array(s);e[t];){var u=r[e.charCodeAt(t)];if(255===u)return;for(var l=0,f=s-1;(0!==u||l<i)&&-1!==f;f--,l++)u+=a*o[f]>>>0,o[f]=u%256>>>0,u=u/256>>>0;if(0!==u)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)*u+1>>>0,h=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*h[p]>>>0,h[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===h[d];)d++;for(var g=c.repeat(r);d<o;++d)g+=e.charAt(h[d]);return g},decodeUnsafe:l,decode:function(e){var r=l(e);if(r)return r;throw new Error(`Non-${t} character`)}}},Eo=bo;const Io=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 So{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 Po{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 No(this,e)}}class Oo{constructor(e){this.decoders=e}or(e){return No(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 No=(e,t)=>new Oo({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}});class Ao{constructor(e,t,r,n){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new So(e,t,r),this.decoder=new Po(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const Co=({name:e,prefix:t,encode:r,decode:n})=>new Ao(e,t,r,n),Ro=({prefix:e,name:t,alphabet:r})=>{const{encode:n,decode:i}=Eo(r,t);return Co({prefix:e,name:t,encode:n,decode:e=>Io(i(e))})},xo=({name:e,prefix:t,bitsPerChar:r,alphabet:n})=>Co({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,h=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[h++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o})(t,n,r,e)}),To=Co({prefix:"\0",name:"identity",encode:e=>(e=>(new TextDecoder).decode(e))(e),decode:e=>(e=>(new TextEncoder).encode(e))(e)});var Lo=Object.freeze({__proto__:null,identity:To});const Uo=xo({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var jo=Object.freeze({__proto__:null,base2:Uo});const Mo=xo({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Do=Object.freeze({__proto__:null,base8:Mo});const ko=Ro({prefix:"9",name:"base10",alphabet:"0123456789"});var $o=Object.freeze({__proto__:null,base10:ko});const zo=xo({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),qo=xo({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Ho=Object.freeze({__proto__:null,base16:zo,base16upper:qo});const Ko=xo({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Vo=xo({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Bo=xo({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Fo=xo({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Wo=xo({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Go=xo({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Yo=xo({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Qo=xo({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Jo=xo({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Xo=Object.freeze({__proto__:null,base32:Ko,base32upper:Vo,base32pad:Bo,base32padupper:Fo,base32hex:Wo,base32hexupper:Go,base32hexpad:Yo,base32hexpadupper:Qo,base32z:Jo});const Zo=Ro({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),ea=Ro({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var ta=Object.freeze({__proto__:null,base36:Zo,base36upper:ea});const ra=Ro({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),na=Ro({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var ia=Object.freeze({__proto__:null,base58btc:ra,base58flickr:na});const sa=xo({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),oa=xo({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),aa=xo({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),ca=xo({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var ha=Object.freeze({__proto__:null,base64:sa,base64pad:oa,base64url:aa,base64urlpad:ca});const ua=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),la=ua.reduce(((e,t,r)=>(e[r]=t,e)),[]),fa=ua.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const pa=Co({prefix:"🚀",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=la[t]),"")},decode:function(e){const t=[];for(const r of e){const e=fa[r.codePointAt(0)];if(void 0===e)throw new Error(`Non-base256emoji character: ${r}`);t.push(e)}return new Uint8Array(t)}});var da=Object.freeze({__proto__:null,base256emoji:pa}),ga=function e(t,r,n){r=r||[];for(var i=n=n||0;t>=ma;)r[n++]=255&t|ya,t/=128;for(;t&va;)r[n++]=255&t|ya,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},ya=128,va=-128,ma=Math.pow(2,31);var wa=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&ba)<<s:(n&ba)*Math.pow(2,s),s+=7}while(n>=_a);return e.bytes=o-r,i},_a=128,ba=127;var Ea=Math.pow(2,7),Ia=Math.pow(2,14),Sa=Math.pow(2,21),Pa=Math.pow(2,28),Oa=Math.pow(2,35),Na=Math.pow(2,42),Aa=Math.pow(2,49),Ca=Math.pow(2,56),Ra=Math.pow(2,63),xa={encode:ga,decode:wa,encodingLength:function(e){return e<Ea?1:e<Ia?2:e<Sa?3:e<Pa?4:e<Oa?5:e<Na?6:e<Aa?7:e<Ca?8:e<Ra?9:10}};const Ta=(e,t,r=0)=>(xa.encode(e,t,r),t),La=e=>xa.encodingLength(e),Ua=(e,t)=>{const r=t.byteLength,n=La(e),i=n+La(r),s=new Uint8Array(i+r);return Ta(e,s,0),Ta(r,s,n),s.set(t,i),new ja(e,r,t,s)};class ja{constructor(e,t,r,n){this.code=e,this.size=t,this.digest=r,this.bytes=n}}const Ma=({name:e,code:t,encode:r})=>new Da(e,t,r);class Da{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?Ua(this.code,t):t.then((e=>Ua(this.code,e)))}throw Error("Unknown type, must be binary type")}}const ka=e=>async t=>new Uint8Array(await crypto.subtle.digest(e,t)),$a=Ma({name:"sha2-256",code:18,encode:ka("SHA-256")}),za=Ma({name:"sha2-512",code:19,encode:ka("SHA-512")});Object.freeze({__proto__:null,sha256:$a,sha512:za});const qa=Io,Ha={code:0,name:"identity",encode:qa,digest:e=>Ua(0,qa(e))};Object.freeze({__proto__:null,identity:Ha});new TextEncoder,new TextDecoder;const Ka={...Lo,...jo,...Do,...$o,...Ho,...Xo,...ta,...ia,...ha,...da};function Va(e){return null!=globalThis.Buffer?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e}function Ba(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}const Fa=Ba("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),Wa=Ba("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?Va(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})),Ga={utf8:Fa,"utf-8":Fa,hex:Ka.base16,latin1:Wa,ascii:Wa,binary:Wa,...Ka};const Ya="core",Qa=`wc@2:${Ya}:`,Ja="error",Xa={database:":memory:"},Za="client_ed25519_seed",ec=qt.ONE_DAY,tc=qt.SIX_HOURS,rc="wss://relay.walletconnect.com",nc="wss://relay.walletconnect.org",ic="relayer_message",sc="relayer_message_ack",oc="relayer_connect",ac="relayer_disconnect",cc="relayer_error",hc="relayer_connection_stalled",uc="relayer_publish",lc="payload",fc="connect",pc="disconnect",dc="error",gc=qt.ONE_SECOND,yc="subscription_created",vc="subscription_deleted",mc="subscription_sync",wc="subscription_resubscribed",_c=1e3*qt.FIVE_SECONDS,bc={wc_pairingDelete:{req:{ttl:qt.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:qt.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:qt.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:qt.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:qt.ONE_DAY,prompt:!1,tag:0},res:{ttl:qt.ONE_DAY,prompt:!1,tag:0}}},Ec="pairing_create",Ic="pairing_expire",Sc="pairing_delete",Pc="pairing_ping",Oc="history_created",Nc="history_updated",Ac="history_deleted",Cc="history_sync",Rc="expirer_created",xc="expirer_deleted",Tc="expirer_expired",Lc="expirer_sync",Uc="verify-api",jc="https://verify.walletconnect.com",Mc="https://verify.walletconnect.org",Dc=[jc,Mc];class kc{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=Qa,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}=Mn("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=ss.generateChildLogger(t,this.name)}get context(){return ss.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,un(e))}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?ln(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:e}=Mn("NOT_INITIALIZED",this.name);throw new Error(e)}}}class $c{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 Ms(Ds(await this.getClientSeed()).publicKey)},this.generateKeyPair=()=>{this.isInitialized();const e=function(){const e=Z.generateKeyPair();return{privateKey:Nt(e.secretKey,xr),publicKey:Nt(e.publicKey,xr)}}();return this.setPrivateKey(e.publicKey,e.privateKey)},this.signJWT=async e=>{this.isInitialized();const t=Ds(await this.getClientSeed()),r=zr(),n=ec;return await ks(r,e,n,t)},this.generateSharedKey=(e,t,r)=>{this.isInitialized();const n=function(e,t){const r=Z.sharedKey(Ot(e,xr),Ot(t,xr),!0);return Nt(new V(X.SHA256,r).expand($r),xr)}(this.getPrivateKey(e),t);return this.setSymKey(n,r)},this.setSymKey=async(e,t)=>{this.isInitialized();const r=t||function(e){return Nt(X.hash(Ot(e,xr)),xr)}(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=Br(r),i=xi(t);if(Fr(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 Kr({type:o,symKey:s,message:i,senderPublicKey:a})},this.decode=async(e,t,r)=>{this.isInitialized();const n=function(e,t){const r=Vr(e);return Br({type:Hr(r.type),senderPublicKey:typeof r.senderPublicKey<"u"?Nt(r.senderPublicKey,xr):void 0,receiverPublicKey:t?.receiverPublicKey})}(t,r);if(Fr(n)){const t=n.receiverPublicKey,r=n.senderPublicKey;e=await this.generateSharedKey(t,r)}try{const r=function(e){const t=new h.ChaCha20Poly1305(Ot(e.symKey,xr)),{sealed:r,iv:n}=Vr(e.encoded),i=t.open(n,r);if(null===i)throw new Error("Failed to decrypt");return Nt(i,Lr)}({symKey:this.getSymKey(e),encoded:t});return Ri(r)}catch(t){this.logger.error(`Failed to decode message from topic: '${e}', clientId: '${await this.getClientId()}'`),this.logger.error(t)}},this.getPayloadType=e=>Hr(Vr(e).type),this.getPayloadSenderPublicKey=e=>{const t=Vr(e);return t.senderPublicKey?Nt(t.senderPublicKey,xr):void 0},this.core=e,this.logger=ss.generateChildLogger(t,this.name),this.keychain=r||new kc(this.core,this.logger)}get context(){return ss.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=zr(),await this.keychain.set(Za,e)}return function(e,t="utf8"){const r=Ga[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}`):Va(globalThis.Buffer.from(e,"utf-8"))}(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=Mn("NOT_INITIALIZED",this.name);throw new Error(e)}}}class zc extends ds{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=Qa,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=qr(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)[qr(t)]<"u"},this.del=async e=>{this.isInitialized(),this.messages.delete(e),await this.persist()},this.logger=ss.generateChildLogger(e,this.name),this.core=t}get context(){return ss.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,un(e))}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?ln(e):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){const{message:e}=Mn("NOT_INITIALIZED",this.name);throw new Error(e)}}}class qc extends gs{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,this.events=new t,this.name="publisher",this.queue=new Map,this.publishTimeout=qt.toMiliseconds(qt.TEN_SECONDS),this.needsTransportRestart=!1,this.publish=async(e,t,r)=>{var n;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:e,message:t,opts:r}});try{const i=r?.ttl||tc,s=_n(r),o=r?.prompt||!1,a=r?.tag||0,c=r?.id||Xs().toString(),h={topic:e,message:t,opts:{ttl:i,relay:s,prompt:o,tag:a,id:c}},u=setTimeout((()=>this.queue.set(c,h)),this.publishTimeout);try{await await pn(this.rpcPublish(e,t,i,s,o,a,c),this.publishTimeout,"Failed to publish payload, please try again."),this.removeRequestFromQueue(c),this.relayer.events.emit(uc,h)}catch(e){if(this.logger.debug("Publishing Payload stalled"),this.needsTransportRestart=!0,null!=(n=r?.internal)&&n.throwOnFailedPublish)throw this.removeRequestFromQueue(c),e;return}finally{clearTimeout(u)}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=e,this.logger=ss.generateChildLogger(r,this.name),this.registerEventListeners()}get context(){return ss.getLoggerContext(this.logger)}rpcPublish(e,t,r,n,i,s,o){var a,c,h,u;const l={method:bn(n.protocol).publish,params:{topic:e,message:t,ttl:r,prompt:i,tag:s},id:o};return zn(null==(a=l.params)?void 0:a.prompt)&&(null==(c=l.params)||delete c.prompt),zn(null==(h=l.params)?void 0:h.tag)&&(null==(u=l.params)||delete u.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:l}),this.relayer.request(l)}removeRequestFromQueue(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(zi.HEARTBEAT_EVENTS.pulse,(()=>{if(this.needsTransportRestart)return this.needsTransportRestart=!1,void this.relayer.events.emit(hc);this.checkQueue()})),this.relayer.on(sc,(e=>{this.removeRequestFromQueue(e.id.toString())}))}}class Hc{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 Kc=Object.defineProperty,Vc=Object.defineProperties,Bc=Object.getOwnPropertyDescriptors,Fc=Object.getOwnPropertySymbols,Wc=Object.prototype.hasOwnProperty,Gc=Object.prototype.propertyIsEnumerable,Yc=(e,t,r)=>t in e?Kc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Qc=(e,t)=>{for(var r in t||(t={}))Wc.call(t,r)&&Yc(e,r,t[r]);if(Fc)for(var r of Fc(t))Gc.call(t,r)&&Yc(e,r,t[r]);return e},Jc=(e,t)=>Vc(e,Bc(t));class Xc extends ms{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,this.subscriptions=new Map,this.topicMap=new Hc,this.events=new t,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=Qa,this.subscribeTimeout=1e4,this.restartInProgress=!1,this.batchSubscribeTopicsLimit=500,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),this.clientId=await this.relayer.core.crypto.getClientId())},this.subscribe=async(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=_n(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 qt.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)>=_c&&(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=e,this.logger=ss.generateChildLogger(r,this.name),this.clientId=""}get context(){return ss.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.relayer.core.customStoragePrefix+"//"+this.name}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}hasSubscription(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=_n(r);await this.rpcUnsubscribe(e,t,n);const i=Dn("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:bn(t.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:r});try{await await pn(this.relayer.request(r),this.subscribeTimeout)}catch{this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(hc)}return qr(e+this.clientId)}async rpcBatchSubscribe(e){if(!e.length)return;const t={method:bn(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 pn(this.relayer.request(t),this.subscribeTimeout)}catch{this.logger.debug("Outgoing Relay Payload stalled"),this.relayer.events.emit(hc)}}rpcUnsubscribe(e,t,r){const n={method:bn(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,Jc(Qc({},t),{id:e})),this.pending.delete(t.topic)}onBatchSubscribe(e){e.length&&e.forEach((e=>{this.setSubscription(e.id,Qc({},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,Qc({},t)),this.topicMap.set(t.topic,e),this.events.emit(yc,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}=Mn("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(vc,Jc(Qc({},r),{reason:t}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(mc)}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(wc)}async restore(){try{const e=await this.getRelayerSubscriptions();if(typeof e>"u"||!e.length)return;if(this.subscriptions.size){const{message:e}=Mn("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);kn(t)&&this.onBatchSubscribe(t.map(((t,r)=>Jc(Qc({},e[r]),{id:t}))))}async onConnect(){this.restartInProgress||(await this.restart(),this.onEnable())}onDisconnect(){this.onDisable()}async checkPending(){if(!this.initialized||this.relayer.transportExplicitlyClosed)return;const e=[];this.pending.forEach((t=>{e.push(t)})),await this.batchSubscribe(e)}registerEventListeners(){this.relayer.core.heartbeat.on(zi.HEARTBEAT_EVENTS.pulse,(async()=>{await this.checkPending()})),this.relayer.on(oc,(async()=>{await this.onConnect()})),this.relayer.on(ac,(()=>{this.onDisconnect()})),this.events.on(yc,(async e=>{const t=yc;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist()})),this.events.on(vc,(async e=>{const t=vc;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist()}))}isInitialized(){if(!this.initialized){const{message:e}=Mn("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 Zc=Object.defineProperty,eh=Object.getOwnPropertySymbols,th=Object.prototype.hasOwnProperty,rh=Object.prototype.propertyIsEnumerable,nh=(e,t,r)=>t in e?Zc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;class ih extends ys{constructor(e){super(e),this.protocol="wc",this.version=2,this.events=new t,this.name="relayer",this.transportExplicitlyClosed=!1,this.initialized=!1,this.connectionAttemptInProgress=!1,this.connectionStatusPollingInterval=20,this.staleConnectionErrors=["socket hang up","socket stalled"],this.hasExperiencedNetworkDisruption=!1,this.request=async 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.onPayloadHandler=e=>{this.onProviderPayload(e)},this.onConnectHandler=()=>{this.events.emit(oc)},this.onDisconnectHandler=()=>{this.onProviderDisconnect()},this.onProviderErrorHandler=e=>{this.logger.error(e),this.events.emit(cc,e),this.logger.info("Fatal socket error received, closing transport"),this.transportClose()},this.registerProviderListeners=()=>{this.provider.on(lc,this.onPayloadHandler),this.provider.on(fc,this.onConnectHandler),this.provider.on(pc,this.onDisconnectHandler),this.provider.on(dc,this.onProviderErrorHandler)},this.core=e.core,this.logger=typeof e.logger<"u"&&"string"!=typeof e.logger?ss.generateChildLogger(e.logger,this.name):ss.pino(ss.getDefaultLoggerOptions({level:e.logger||"error"})),this.messages=new zc(this.logger,e.core),this.subscriber=new Xc(this,this.logger),this.publisher=new qc(this,this.logger),this.relayUrl=e?.relayUrl||rc,this.projectId=e.projectId,this.bundleId=function(){var e;try{return nn()&&typeof global<"u"&&typeof(null==global?void 0:global.Application)<"u"?null==(e=global.Application)?void 0:e.applicationId:void 0}catch{return}}(),this.provider={}}async init(){this.logger.trace("Initialized"),this.registerEventListeners(),await this.createProvider(),await Promise.all([this.messages.init(),this.subscriber.init()]);try{await this.transportOpen()}catch{this.logger.warn(`Connection via ${this.relayUrl} failed, attempting to connect via failover domain ${nc}...`),await this.restartTransport(nc)}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 ss.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,i=(null==(r=this.subscriber.topicMap.get(e))?void 0:r[0])||"";if(i)return i;const s=t=>{t.topic===e&&(this.subscriber.off(yc,s),n())};return await Promise.all([new Promise((e=>{n=e,this.subscriber.on(yc,s)})),new Promise((async r=>{i=await this.subscriber.subscribe(e,t),r()}))]),i}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.hasExperiencedNetworkDisruption&&this.connected?await pn(this.provider.disconnect(),1e3,"provider.disconnect()").catch((()=>this.onProviderDisconnect())):this.connected&&await this.provider.disconnect()}async transportOpen(e){if(this.transportExplicitlyClosed=!1,await this.confirmOnlineStateOrThrow(),!this.connectionAttemptInProgress){e&&e!==this.relayUrl&&(this.relayUrl=e,await this.transportClose(),await this.createProvider()),this.connectionAttemptInProgress=!0;try{await Promise.all([new Promise((e=>{if(!this.initialized)return e();this.subscriber.once(wc,(()=>{e()}))})),new Promise((async(e,t)=>{try{await pn(this.provider.connect(),1e4,`Socket stalled when trying to connect to ${this.relayUrl}`)}catch(e){return void t(e)}e()}))])}catch(e){this.logger.error(e);const t=e;if(!this.isConnectionStalled(t.message))throw e;this.provider.events.emit(pc)}finally{this.connectionAttemptInProgress=!1,this.hasExperiencedNetworkDisruption=!1}}}async restartTransport(e){await this.confirmOnlineStateOrThrow(),!this.connectionAttemptInProgress&&(this.relayUrl=e||this.relayUrl,await this.transportClose(),await this.createProvider(),await this.transportOpen())}async confirmOnlineStateOrThrow(){if(!await ri())throw new Error("No internet connection detected. Please restart your network and try again.")}isConnectionStalled(e){return this.staleConnectionErrors.some((t=>e.includes(t)))}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();const e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new go(new mo(cn({sdkVersion:"2.10.6",protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e,useOnCloseEvent:!0,bundleId:this.bundleId}))),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;if(!r||0===r.length)return this.logger.debug(`Ignoring invalid/empty message: ${r}`),!0;if(!await this.subscriber.isSubscribed(t))return this.logger.debug(`Ignoring message for non-subscribed topic ${t}`),!0;const n=this.messages.has(t,r);return n&&this.logger.debug(`Ignoring duplicate message: ${r}`),n}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),uo(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={}))th.call(t,r)&&nh(e,r,t[r]);if(eh)for(var r of eh(t))rh.call(t,r)&&nh(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 lo(e)&&this.events.emit(sc,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(this.events.emit(ic,e),await this.recordMessageEvent(e))}async acknowledgePayload(e){const t=eo(e.id,!0);await this.provider.connection.send(t)}unregisterProviderListeners(){this.provider.off(lc,this.onPayloadHandler),this.provider.off(fc,this.onConnectHandler),this.provider.off(pc,this.onDisconnectHandler),this.provider.off(dc,this.onProviderErrorHandler)}async registerEventListeners(){this.events.on(hc,(()=>{this.restartTransport().catch((e=>this.logger.error(e)))}));let e=await ri();ni((async t=>{this.initialized&&e!==t&&(e=t,t?await this.restartTransport().catch((e=>this.logger.error(e))):(this.hasExperiencedNetworkDisruption=!0,await this.transportClose().catch((e=>this.logger.error(e)))))}))}onProviderDisconnect(){this.events.emit(ac),this.attemptToReconnect()}attemptToReconnect(){this.transportExplicitlyClosed||(this.logger.info("attemptToReconnect called. Connecting..."),setTimeout((async()=>{await this.restartTransport().catch((e=>this.logger.error(e)))}),qt.toMiliseconds(gc)))}isInitialized(){if(!this.initialized){const{message:e}=Mn("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){if(await this.confirmOnlineStateOrThrow(),!this.connected){if(this.connectionAttemptInProgress)return await new Promise((e=>{const t=setInterval((()=>{this.connected&&(clearInterval(t),e())}),this.connectionStatusPollingInterval)}));await this.restartTransport()}}}var sh=Object.defineProperty,oh=Object.getOwnPropertySymbols,ah=Object.prototype.hasOwnProperty,ch=Object.prototype.propertyIsEnumerable,hh=(e,t,r)=>t in e?sh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,uh=(e,t)=>{for(var r in t||(t={}))ah.call(t,r)&&hh(e,r,t[r]);if(oh)for(var r of oh(t))ch.call(t,r)&&hh(e,r,t[r]);return e};class lh extends vs{constructor(e,t,r,n=Qa,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=Qa,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach((e=>{this.getKey&&null!==e&&!zn(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=>_o(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=uh(uh({},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=ss.generateChildLogger(t,this.name),this.storagePrefix=n,this.getKey=i}get context(){return ss.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}async setDataStore(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}=Mn("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}=Mn("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}=Mn("NOT_INITIALIZED",this.name);throw new Error(e)}}}class fh{constructor(t,r){this.core=t,this.logger=r,this.name="pairing",this.version="0.3",this.events=new e,this.initialized=!1,this.storagePrefix=Qa,this.ignoredPayloadTypes=[jr],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=zr(),t=await this.core.crypto.setSymKey(e),r=yn(qt.FIVE_MINUTES),n={protocol:"irn"},i={topic:t,expiry:r,relay:n,active:!1},s=Rn({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}=An(e.uri);let i;if(this.pairings.keys.includes(t)&&(i=this.pairings.get(t),i.active))throw new Error(`Pairing already exists: ${t}. Please try again with a new connection URI.`);const s=yn(qt.FIVE_MINUTES),o={topic:t,relay:n,expiry:s,active:!1};return await this.pairings.set(t,o),this.core.expirer.set(t,s),e.activatePairing&&await this.activate({topic:t}),this.events.emit(Ec,o),this.core.crypto.keychain.has(t)||(await this.core.crypto.setSymKey(r,t),await this.core.relayer.subscribe(t,{relay:n})),o},this.activate=async({topic:e})=>{this.isInitialized();const t=yn(qt.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}=fn();this.events.once(mn("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",Dn("USER_DISCONNECTED")),await this.deletePairing(t))},this.sendRequest=async(e,t,r)=>{const n=Zs(t,r),i=await this.core.crypto.encode(e,n),s=bc[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=eo(e,r),i=await this.core.crypto.encode(t,n),s=await this.core.history.get(t,e),o=bc[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=to(e,r),i=await this.core.crypto.encode(t,n),s=await this.core.history.get(t,e),o=bc[s.request.method]?bc[s.request.method].res:bc.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,Dn("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=>vn(e.expiry)));await Promise.all(e.map((e=>this.deletePairing(e.topic))))},this.onRelayEventRequest=e=>{const{topic:t,payload:r}=e;switch(r.method){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;return"wc_pairingPing"===n?this.onPairingPingResponse(t,r):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(Pc,{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((()=>{fo(t)?this.events.emit(mn("pairing_ping",r),{}):po(t)&&this.events.emit(mn("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(Sc,{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=Dn("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(Dn("WC_METHOD_UNSUPPORTED",e))},this.isValidPair=e=>{var t;if(!Qn(e)){const{message:t}=Mn("MISSING_OR_INVALID",`pair() params: ${e}`);throw new Error(t)}if(!function(e){if(qn(e,!1))try{return typeof new URL(e)<"u"}catch{return!1}return!1}(e.uri)){const{message:t}=Mn("MISSING_OR_INVALID",`pair() uri: ${e.uri}`);throw new Error(t)}const r=An(e.uri);if(null==(t=r?.relay)||!t.protocol){const{message:e}=Mn("MISSING_OR_INVALID","pair() uri#relay-protocol");throw new Error(e)}if(null==r||!r.symKey){const{message:e}=Mn("MISSING_OR_INVALID","pair() uri#symKey");throw new Error(e)}},this.isValidPing=async e=>{if(!Qn(e)){const{message:t}=Mn("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}=Mn("MISSING_OR_INVALID",`disconnect() params: ${e}`);throw new Error(t)}const{topic:t}=e;await this.isValidPairingTopic(t)},this.isValidPairingTopic=async e=>{if(!qn(e,!1)){const{message:t}=Mn("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(t)}if(!this.pairings.keys.includes(e)){const{message:t}=Mn("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(t)}if(vn(this.pairings.get(e).expiry)){await this.deletePairing(e);const{message:t}=Mn("EXPIRED",`pairing topic: ${e}`);throw new Error(t)}},this.core=t,this.logger=ss.generateChildLogger(r,this.name),this.pairings=new lh(this.core,this.logger,this.name,this.storagePrefix)}get context(){return ss.getLoggerContext(this.logger)}isInitialized(){if(!this.initialized){const{message:e}=Mn("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(ic,(async e=>{const{topic:t,message:r}=e;if(!this.pairings.keys.includes(t)||this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(r)))return;const n=await this.core.crypto.decode(t,r);try{uo(n)?(this.core.history.set(t,n),this.onRelayEventRequest({topic:t,payload:n})):lo(n)&&(await this.core.history.resolve(n),await this.onRelayEventResponse({topic:t,payload:n}),this.core.history.delete(t,n.id))}catch(e){this.logger.error(e)}}))}registerExpirerEvents(){this.core.expirer.on(Tc,(async e=>{const{topic:t}=gn(e.target);t&&this.pairings.keys.includes(t)&&(await this.deletePairing(t,!0),this.events.emit(Ic,{topic:t}))}))}}class ph extends ps{constructor(e,r){super(e,r),this.core=e,this.logger=r,this.records=new Map,this.events=new t,this.name="history",this.version="0.3",this.cached=[],this.initialized=!1,this.storagePrefix=Qa,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:yn(qt.THIRTY_DAYS)};this.records.set(n.id,n),this.events.emit(Oc,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=po(e)?{error:e.error}:{result:e.result},this.records.set(t.id,t),this.events.emit(Nc,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(Ac,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=ss.generateChildLogger(r,this.name)}get context(){return ss.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){const e=[];return this.values.forEach((t=>{if(typeof t.response<"u")return;const r={topic:t.topic,request:Zs(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}=Mn("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(t)}return t}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(Cc)}async restore(){try{const e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){const{message:e}=Mn("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(Oc,(e=>{const t=Oc;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e}),this.persist()})),this.events.on(Nc,(e=>{const t=Nc;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e}),this.persist()})),this.events.on(Ac,(e=>{const t=Ac;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e}),this.persist()})),this.core.heartbeat.on(zi.HEARTBEAT_EVENTS.pulse,(()=>{this.cleanup()}))}cleanup(){try{this.records.forEach((e=>{qt.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}=Mn("NOT_INITIALIZED",this.name);throw new Error(e)}}}class dh extends ws{constructor(e,r){super(e,r),this.core=e,this.logger=r,this.expirations=new Map,this.events=new t,this.name="expirer",this.version="0.3",this.cached=[],this.initialized=!1,this.storagePrefix=Qa,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(Rc,{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(xc,{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=ss.generateChildLogger(r,this.name)}get context(){return ss.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(e){if("string"==typeof e)return function(e){return dn("topic",e)}(e);if("number"==typeof e)return function(e){return dn("id",e)}(e);const{message:t}=Mn("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(Lc)}async restore(){try{const e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){const{message:e}=Mn("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}=Mn("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(t),new Error(t)}return t}checkExpiry(e,t){const{expiry:r}=t;qt.toMiliseconds(r)-Date.now()<=0&&this.expire(e,t)}expire(e,t){this.expirations.delete(e),this.events.emit(Tc,{target:e,expiration:t})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach(((e,t)=>this.checkExpiry(t,e)))}registerEventListeners(){this.core.heartbeat.on(zi.HEARTBEAT_EVENTS.pulse,(()=>this.checkExpirations())),this.events.on(Rc,(e=>{const t=Rc;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()})),this.events.on(Tc,(e=>{const t=Tc;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()})),this.events.on(xc,(e=>{const t=xc;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}))}isInitialized(){if(!this.initialized){const{message:e}=Mn("NOT_INITIALIZED",this.name);throw new Error(e)}}}class gh extends _s{constructor(e,t){super(e,t),this.projectId=e,this.logger=t,this.name=Uc,this.initialized=!1,this.queue=[],this.verifyDisabled=!1,this.init=async e=>{if(this.verifyDisabled||nn()||!sn())return;const t=this.getVerifyUrl(e?.verifyUrl);this.verifyUrl!==t&&this.removeIframe(),this.verifyUrl=t;try{await this.createIframe()}catch(e){this.logger.info(`Verify iframe failed to load: ${this.verifyUrl}`),this.logger.info(e)}if(!this.initialized){this.removeIframe(),this.verifyUrl=Mc;try{await this.createIframe()}catch(e){this.logger.info(`Verify iframe failed to load: ${this.verifyUrl}`),this.logger.info(e),this.verifyDisabled=!0}}},this.register=async e=>{this.initialized?this.sendPost(e.attestationId):(this.addToQueue(e.attestationId),await this.init())},this.resolve=async e=>{if(this.isDevEnv)return"";const t=this.getVerifyUrl(e?.verifyUrl);let r;try{r=await this.fetchAttestation(e.attestationId,t)}catch(n){this.logger.info(`failed to resolve attestation: ${e.attestationId} from url: ${t}`),this.logger.info(n),r=await this.fetchAttestation(e.attestationId,Mc)}return r},this.fetchAttestation=async(e,t)=>{this.logger.info(`resolving attestation: ${e} from url: ${t}`);const r=this.startAbortTimer(2*qt.ONE_SECOND),n=await fetch(`${t}/attestation/${e}`,{signal:this.abortController.signal});return clearTimeout(r),200===n.status?await n.json():void 0},this.addToQueue=e=>{this.queue.push(e)},this.processQueue=()=>{0!==this.queue.length&&(this.queue.forEach((e=>this.sendPost(e))),this.queue=[])},this.sendPost=e=>{var t;try{if(!this.iframe)return;null==(t=this.iframe.contentWindow)||t.postMessage(e,"*"),this.logger.info(`postMessage sent: ${e} ${this.verifyUrl}`)}catch{}},this.createIframe=async()=>{let e;const t=r=>{"verify_ready"===r.data&&(this.initialized=!0,this.processQueue(),window.removeEventListener("message",t),e())};await Promise.race([new Promise((r=>{if(document.getElementById(Uc))return r();window.addEventListener("message",t);const n=document.createElement("iframe");n.id=Uc,n.src=`${this.verifyUrl}/${this.projectId}`,n.style.display="none",document.body.append(n),this.iframe=n,e=r})),new Promise(((e,r)=>setTimeout((()=>{window.removeEventListener("message",t),r("verify iframe load timeout")}),qt.toMiliseconds(qt.FIVE_SECONDS))))])},this.removeIframe=()=>{this.iframe&&(this.iframe.remove(),this.iframe=void 0,this.initialized=!1)},this.getVerifyUrl=e=>{let t=e||jc;return Dc.includes(t)||(this.logger.info(`verify url: ${t}, not included in trusted list, assigning default: ${jc}`),t=jc),t},this.logger=ss.generateChildLogger(t,this.name),this.verifyUrl=jc,this.abortController=new AbortController,this.isDevEnv=rn()&&process.env.IS_VITEST}get context(){return ss.getLoggerContext(this.logger)}startAbortTimer(e){return this.abortController=new AbortController,setTimeout((()=>this.abortController.abort()),qt.toMiliseconds(e))}}var yh=Object.defineProperty,vh=Object.getOwnPropertySymbols,mh=Object.prototype.hasOwnProperty,wh=Object.prototype.propertyIsEnumerable,_h=(e,t,r)=>t in e?yh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,bh=(e,t)=>{for(var r in t||(t={}))mh.call(t,r)&&_h(e,r,t[r]);if(vh)for(var r of vh(t))wh.call(t,r)&&_h(e,r,t[r]);return e};class Eh extends fs{constructor(e){super(e),this.protocol="wc",this.version=2,this.name=Ya,this.events=new t,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=e?.projectId,this.relayUrl=e?.relayUrl||rc,this.customStoragePrefix=null!=e&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";const r=typeof e?.logger<"u"&&"string"!=typeof e?.logger?e.logger:ss.pino(ss.getDefaultLoggerOptions({level:e?.logger||Ja}));this.logger=ss.generateChildLogger(r,this.name),this.heartbeat=new zi.HeartBeat,this.crypto=new $c(this,this.logger,e?.keychain),this.history=new ph(this,this.logger),this.expirer=new dh(this,this.logger),this.storage=null!=e&&e.storage?e.storage:new $i(bh(bh({},Xa),e?.storageOptions)),this.relayer=new ih({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new fh(this,this.logger),this.verify=new gh(this.projectId||"",this.logger)}static async init(e){const t=new Eh(e);await t.initialize();const r=await t.crypto.getClientId();return await t.storage.setItem("WALLETCONNECT_CLIENT_ID",r),t}get context(){return ss.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 Ih=Eh,Sh="client",Ph=`wc@2:${Sh}:`,Oh=Sh,Nh="error",Ah="WALLETCONNECT_DEEPLINK_CHOICE",Ch="Proposal expired",Rh=qt.SEVEN_DAYS,xh={wc_sessionPropose:{req:{ttl:qt.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:qt.FIVE_MINUTES,prompt:!1,tag:1101}},wc_sessionSettle:{req:{ttl:qt.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:qt.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:qt.ONE_DAY,prompt:!1,tag:1104},res:{ttl:qt.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:qt.ONE_DAY,prompt:!1,tag:1106},res:{ttl:qt.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:qt.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:qt.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:qt.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:qt.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:qt.ONE_DAY,prompt:!1,tag:1112},res:{ttl:qt.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:qt.THIRTY_SECONDS,prompt:!1,tag:1114},res:{ttl:qt.THIRTY_SECONDS,prompt:!1,tag:1115}}},Th={min:qt.FIVE_MINUTES,max:qt.SEVEN_DAYS},Lh="IDLE",Uh="ACTIVE",jh=["wc_sessionPropose","wc_sessionRequest","wc_authRequest"];var Mh=Object.defineProperty,Dh=Object.defineProperties,kh=Object.getOwnPropertyDescriptors,$h=Object.getOwnPropertySymbols,zh=Object.prototype.hasOwnProperty,qh=Object.prototype.propertyIsEnumerable,Hh=(e,t,r)=>t in e?Mh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Kh=(e,t)=>{for(var r in t||(t={}))zh.call(t,r)&&Hh(e,r,t[r]);if($h)for(var r of $h(t))qh.call(t,r)&&Hh(e,r,t[r]);return e},Vh=(e,t)=>Dh(e,kh(t));class Bh extends Es{constructor(t){super(t),this.name="engine",this.events=new e,this.initialized=!1,this.ignoredPayloadTypes=[jr],this.requestQueue={state:Lh,queue:[]},this.sessionRequestQueue={state:Lh,queue:[]},this.requestQueueDelay=qt.ONE_SECOND,this.init=async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.registerPairingEvents(),this.client.core.pairing.register({methods:Object.keys(xh)}),this.initialized=!0,setTimeout((()=>{this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()}),qt.toMiliseconds(this.requestQueueDelay)))},this.connect=async e=>{await this.isInitialized();const t=Vh(Kh({},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,h=!1;if(c&&(h=this.client.core.pairing.pairings.get(c).active),!c||!h){const{topic:e,uri:t}=await this.client.core.pairing.create();c=e,a=t}const u=await this.client.core.crypto.generateKeyPair(),l=Kh({requiredNamespaces:n,optionalNamespaces:i,relays:o??[{protocol:"irn"}],proposer:{publicKey:u,metadata:this.client.metadata}},s&&{sessionProperties:s}),{reject:f,resolve:p,done:d}=fn(qt.FIVE_MINUTES,Ch);if(this.events.once(mn("session_connect"),(async({error:e,session:t})=>{if(e)f(e);else if(t){t.self.publicKey=u;const e=Vh(Kh({},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}=Mn("NO_MATCHING_KEY",`connect() pairing topic: ${c}`);throw new Error(e)}const g=await this.sendRequest({topic:c,method:"wc_sessionPropose",params:l}),y=yn(qt.FIVE_MINUTES);return await this.setProposal(g,Kh({id:g,expiry:y},l)),{uri:a,approval:d}},this.pair=async e=>(await this.isInitialized(),await this.client.core.pairing.pair(e)),this.approve=async e=>{await 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:h}=s;o=o||"",$n(c)||(c=function(e,t){const r=Gn(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 u=await this.client.core.crypto.generateKeyPair(),l=a.publicKey,f=await this.client.core.crypto.generateSharedKey(u,l);o&&t&&(await this.client.core.pairing.updateMetadata({topic:o,metadata:a.metadata}),await this.sendResult({id:t,topic:o,result:{relay:{protocol:r??"irn"},responderPublicKey:u}}),await this.client.proposal.delete(t,Dn("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:o}));const p=Kh({relay:{protocol:r??"irn"},namespaces:n,requiredNamespaces:c,optionalNamespaces:h,pairingTopic:o,controller:{publicKey:u,metadata:this.client.metadata},expiry:yn(Rh)},i&&{sessionProperties:i});await this.client.core.relayer.subscribe(f),await this.sendRequest({topic:f,method:"wc_sessionSettle",params:p,throwOnFailedPublish:!0});const d=Vh(Kh({},p),{topic:f,pairingTopic:o,acknowledged:!1,self:p.controller,peer:{publicKey:a.publicKey,metadata:a.metadata},controller:u});return await this.client.session.set(f,d),await this.setExpiry(f,yn(Rh)),{topic:f,acknowledged:()=>new Promise((e=>setTimeout((()=>e(this.client.session.get(f))),500)))}},this.reject=async e=>{await 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,Dn("USER_DISCONNECTED")))},this.update=async e=>{await this.isInitialized(),await this.isValidUpdate(e);const{topic:t,namespaces:r}=e,n=await this.sendRequest({topic:t,method:"wc_sessionUpdate",params:{namespaces:r}}),{done:i,resolve:s,reject:o}=fn();return this.events.once(mn("session_update",n),(({error:e})=>{e?o(e):s()})),await this.client.session.update(t,{namespaces:r}),{acknowledged:i}},this.extend=async e=>{await this.isInitialized(),await this.isValidExtend(e);const{topic:t}=e,r=await this.sendRequest({topic:t,method:"wc_sessionExtend",params:{}}),{done:n,resolve:i,reject:s}=fn();return this.events.once(mn("session_extend",r),(({error:e})=>{e?s(e):i()})),await this.setExpiry(t,yn(Rh)),{acknowledged:n}},this.request=async e=>{await this.isInitialized(),await this.isValidRequest(e);const{chainId:t,request:r,topic:n,expiry:i}=e,s=Js(),{done:o,resolve:a,reject:c}=fn(i,"Request expired. Please try again.");return this.events.once(mn("session_request",s),(({error:e,result:t})=>{e?c(e):a(t)})),await Promise.all([new Promise((async e=>{await this.sendRequest({clientRpcId:s,topic:n,method:"wc_sessionRequest",params:{request:r,chainId:t},expiry:i,throwOnFailedPublish:!0}).catch((e=>c(e))),this.client.events.emit("session_request_sent",{topic:n,request:r,chainId:t,id:s}),e()})),new Promise((async e=>{const t=await async function(e,t){try{return await e.getItem(t)||(sn()?localStorage.getItem(t):void 0)}catch(e){console.error(e)}}(this.client.core.storage,Ah);(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=on();o===en.browser?s.startsWith("https://")?window.open(s,"_blank","noreferrer noopener"):window.open(s,"_self","noreferrer noopener"):o===en.reactNative&&typeof(null==global?void 0:global.Linking)<"u"&&await global.Linking.openURL(s)}catch(e){console.error(e)}})({id:s,topic:n,wcDeepLink:t}),e()})),o()]).then((e=>e[2]))},this.respond=async e=>{await this.isInitialized(),await this.isValidRespond(e);const{topic:t,response:r}=e,{id:n}=r;fo(r)?await this.sendResult({id:n,topic:t,result:r.result,throwOnFailedPublish:!0}):po(r)&&await this.sendError(n,t,r.error),this.cleanupAfterResponse(e)},this.ping=async e=>{await this.isInitialized(),await this.isValidPing(e);const{topic:t}=e;if(this.client.session.keys.includes(t)){const e=await this.sendRequest({topic:t,method:"wc_sessionPing",params:{}}),{done:r,resolve:n,reject:i}=fn();this.events.once(mn("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=>{await this.isInitialized(),await this.isValidEmit(e);const{topic:t,event:r,chainId:n}=e;await this.sendRequest({topic:t,method:"wc_sessionEvent",params:{event:r,chainId:n}})},this.disconnect=async e=>{await this.isInitialized(),await this.isValidDisconnect(e);const{topic:t}=e;this.client.session.keys.includes(t)?(await this.sendRequest({topic:t,method:"wc_sessionDelete",params:Dn("USER_DISCONNECTED"),throwOnFailedPublish:!0}),await this.deleteSession(t)):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!!hn(i,n)&&(n.forEach((t=>{const{accounts:n,methods:i,events:o}=e.namespaces[t],a=xn(n),c=r[t];hn(Cr(t,c),a)&&hn(c.methods,i)&&hn(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,Dn("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.client.core.storage.removeItem(Ah).catch((e=>this.client.logger.warn(e)))},this.deleteProposal=async(e,t)=>{await Promise.all([this.client.proposal.delete(e,Dn("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.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter((t=>t.id!==e)),r&&(this.sessionRequestQueue.state=Lh)},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=xh.wc_sessionRequest.req.ttl,{id:r,topic:n,params:i,verifyContext:s}=e;await this.client.pendingRequest.set(r,{id:r,topic:n,params:i,verifyContext:s}),t&&this.client.core.expirer.set(r,yn(t))},this.sendRequest=async e=>{const{topic:t,method:r,params:n,expiry:i,relayRpcId:s,clientRpcId:o,throwOnFailedPublish:a}=e,c=Zs(r,n,o);if(sn()&&jh.includes(r)){const e=qr(JSON.stringify(c));this.client.core.verify.register({attestationId:e})}const h=await this.client.core.crypto.encode(t,c),u=xh[r].req;return i&&(u.ttl=i),s&&(u.id=s),this.client.core.history.set(t,c),a?(u.internal=Vh(Kh({},u.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(t,h,u)):this.client.core.relayer.publish(t,h,u).catch((e=>this.client.logger.error(e))),c.id},this.sendResult=async e=>{const{id:t,topic:r,result:n,throwOnFailedPublish:i}=e,s=eo(t,n),o=await this.client.core.crypto.encode(r,s),a=await this.client.core.history.get(r,t),c=xh[a.request.method].res;i?(c.internal=Vh(Kh({},c.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(r,o,c)):this.client.core.relayer.publish(r,o,c).catch((e=>this.client.logger.error(e))),await this.client.core.history.resolve(s)},this.sendError=async(e,t,r)=>{const n=to(e,r),i=await this.client.core.crypto.encode(t,n),s=await this.client.core.history.get(t,e),o=xh[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=>{vn(t.expiry)&&e.push(t.topic)})),this.client.proposal.getAll().forEach((e=>{vn(e.expiry)&&t.push(e.id)})),await Promise.all([...e.map((e=>this.deleteSession(e))),...t.map((e=>this.deleteProposal(e)))])},this.onRelayEventRequest=async e=>{this.requestQueue.queue.push(e),await this.processRequestsQueue()},this.processRequestsQueue=async()=>{if(this.requestQueue.state!==Uh){for(this.client.logger.info(`Request queue starting with ${this.requestQueue.queue.length} requests`);this.requestQueue.queue.length>0;){this.requestQueue.state=Uh;const e=this.requestQueue.queue.shift();if(e)try{this.processRequest(e),await new Promise((e=>setTimeout(e,300)))}catch(e){this.client.logger.warn(e)}}this.requestQueue.state=Lh}else this.client.logger.info("Request queue already active, skipping...")},this.processRequest=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}=Mn("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(Kh({},t.params));const i=yn(qt.FIVE_MINUTES),s=Kh({id:n,pairingTopic:e,expiry:i},r);await this.setProposal(n,s);const o=qr(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(fo(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 po(t)&&(await this.client.proposal.delete(r,Dn("USER_DISCONNECTED")),this.events.emit(mn("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:h,pairingTopic:u}=t.params,l=Kh({topic:e,relay:r,expiry:s,namespaces:o,acknowledged:!0,pairingTopic:u,requiredNamespaces:a,optionalNamespaces:c,controller:i.publicKey,self:{publicKey:"",metadata:this.client.metadata},peer:{publicKey:i.publicKey,metadata:i.metadata}},h&&{sessionProperties:h});await this.sendResult({id:t.id,topic:e,result:!0}),this.events.emit(mn("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;fo(t)?(await this.client.session.update(e,{acknowledged:!0}),this.events.emit(mn("session_approve",r),{})):po(t)&&(await this.client.session.delete(e,Dn("USER_DISCONNECTED")),this.events.emit(mn("session_approve",r),{error:t.error}))},this.onSessionUpdateRequest=async(e,t)=>{const{params:r,id:n}=t;try{const t=`${e}_session_update`,i=si.get(t);if(i&&this.isRequestOutOfSync(i,n))return void this.client.logger.info(`Discarding out of sync request - ${n}`);this.isValidUpdate(Kh({topic:e},r)),await this.client.session.update(e,{namespaces:r.namespaces}),await this.sendResult({id:n,topic:e,result:!0}),this.client.events.emit("session_update",{id:n,topic:e,params:r}),si.set(t,n)}catch(t){await this.sendError(n,e,t),this.client.logger.error(t)}},this.isRequestOutOfSync=(e,t)=>parseInt(t.toString().slice(0,-3))<=parseInt(e.toString().slice(0,-3)),this.onSessionUpdateResponse=(e,t)=>{const{id:r}=t;fo(t)?this.events.emit(mn("session_update",r),{}):po(t)&&this.events.emit(mn("session_update",r),{error:t.error})},this.onSessionExtendRequest=async(e,t)=>{const{id:r}=t;try{this.isValidExtend({topic:e}),await this.setExpiry(e,yn(Rh)),await this.sendResult({id:r,topic:e,result:!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;fo(t)?this.events.emit(mn("session_extend",r),{}):po(t)&&this.events.emit(mn("session_extend",r),{error:t.error})},this.onSessionPingRequest=async(e,t)=>{const{id:r}=t;try{this.isValidPing({topic:e}),await this.sendResult({id:r,topic:e,result:!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((()=>{fo(t)?this.events.emit(mn("session_ping",r),{}):po(t)&&this.events.emit(mn("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(uc,(async()=>{t(await this.deleteSession(e))}))})),this.sendResult({id:r,topic:e,result:!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(Kh({topic:e},n));const t=qr(JSON.stringify(Zs("wc_sessionRequest",n,r))),i=this.client.session.get(e),s={id:r,topic:e,params:n,verifyContext:await this.getVerifyContext(t,i.peer.metadata)};await this.setPendingSessionRequest(s),this.addSessionRequestToSessionRequestQueue(s),this.processSessionRequestQueue()}catch(t){await this.sendError(r,e,t),this.client.logger.error(t)}},this.onSessionRequestResponse=(e,t)=>{const{id:r}=t;fo(t)?this.events.emit(mn("session_request",r),{result:t.result}):po(t)&&this.events.emit(mn("session_request",r),{error:t.error})},this.onSessionEventRequest=async(e,t)=>{const{id:r,params:n}=t;try{const t=`${e}_session_event_${n.event.name}`,i=si.get(t);if(i&&this.isRequestOutOfSync(i,r))return void this.client.logger.info(`Discarding out of sync request - ${r}`);this.isValidEmit(Kh({topic:e},n)),this.client.events.emit("session_event",{id:r,topic:e,params:n}),si.set(t,r)}catch(t){await this.sendError(r,e,t),this.client.logger.error(t)}},this.addSessionRequestToSessionRequestQueue=e=>{this.sessionRequestQueue.queue.push(e)},this.cleanupAfterResponse=e=>{this.deletePendingSessionRequest(e.response.id,{message:"fulfilled",code:0}),setTimeout((()=>{this.sessionRequestQueue.state=Lh,this.processSessionRequestQueue()}),qt.toMiliseconds(this.requestQueueDelay))},this.processSessionRequestQueue=()=>{if(this.sessionRequestQueue.state===Uh)return void this.client.logger.info("session request queue is already active.");const e=this.sessionRequestQueue.queue[0];if(e)try{this.sessionRequestQueue.state=Uh,this.client.events.emit("session_request",e)}catch(e){this.client.logger.error(e)}else this.client.logger.info("session request queue is empty.")},this.onPairingCreated=e=>{if(e.active)return;const t=this.client.proposal.getAll().find((t=>t.pairingTopic===e.topic));t&&this.onSessionProposeRequest(e.topic,Zs("wc_sessionPropose",{requiredNamespaces:t.requiredNamespaces,optionalNamespaces:t.optionalNamespaces,relays:t.relays,proposer:t.proposer,sessionProperties:t.sessionProperties},t.id))},this.isValidConnect=async e=>{if(!Qn(e)){const{message:t}=Mn("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(zn(t)||await this.isValidPairingTopic(t),!function(e,t){let r=!1;return t&&!e?r=!0:e&&kn(e)&&e.length&&e.forEach((e=>{r=Yn(e)})),r}(s,!0)){const{message:e}=Mn("MISSING_OR_INVALID",`connect() relays: ${s}`);throw new Error(e)}!zn(r)&&0!==$n(r)&&this.validateNamespaces(r,"requiredNamespaces"),!zn(n)&&0!==$n(n)&&this.validateNamespaces(n,"optionalNamespaces"),zn(i)||this.validateSessionProps(i,"sessionProperties")},this.validateNamespaces=(e,t)=>{const r=function(e,t,r){let n=null;if(e&&$n(e)){const i=Wn(e,t);i&&(n=i);const s=Bn(e,t,r);s&&(n=s)}else n=Mn("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(Mn("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=Gn(r,"approve()");if(o)throw new Error(o.message);const a=ei(s.requiredNamespaces,r,"approve()");if(a)throw new Error(a.message);if(!qn(n,!0)){const{message:e}=Mn("MISSING_OR_INVALID",`approve() relayProtocol: ${n}`);throw new Error(e)}zn(i)||this.validateSessionProps(i,"sessionProperties")},this.isValidReject=async e=>{if(!Qn(e)){const{message:t}=Mn("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&&Hn(e.code,!1)&&e.message&&qn(e.message,!1))}(r)){const{message:e}=Mn("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(r)}`);throw new Error(e)}},this.isValidSessionSettleRequest=e=>{if(!Qn(e)){const{message:t}=Mn("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${e}`);throw new Error(t)}const{relay:t,controller:r,namespaces:n,expiry:i}=e;if(!Yn(t)){const{message:e}=Mn("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(e)}const s=function(e,t){let r=null;return qn(e?.publicKey,!1)||(r=Mn("MISSING_OR_INVALID",`${t} controller public key should be a string`)),r}(r,"onSessionSettleRequest()");if(s)throw new Error(s.message);const o=Gn(n,"onSessionSettleRequest()");if(o)throw new Error(o.message);if(vn(i)){const{message:e}=Mn("EXPIRED","onSessionSettleRequest()");throw new Error(e)}},this.isValidUpdate=async e=>{if(!Qn(e)){const{message:t}=Mn("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=Gn(r,"update()");if(i)throw new Error(i.message);const s=ei(n.requiredNamespaces,r,"update()");if(s)throw new Error(s.message)},this.isValidExtend=async e=>{if(!Qn(e)){const{message:t}=Mn("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}=Mn("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(!Jn(s,n)){const{message:e}=Mn("MISSING_OR_INVALID",`request() chainId: ${n}`);throw new Error(e)}if(!function(e){return!(zn(e)||!qn(e.method,!1))}(r)){const{message:e}=Mn("MISSING_OR_INVALID",`request() ${JSON.stringify(r)}`);throw new Error(e)}if(!Xn(s,n,r.method)){const{message:e}=Mn("MISSING_OR_INVALID",`request() method: ${r.method}`);throw new Error(e)}if(i&&!function(e,t){return Hn(e,!1)&&e<=t.max&&e>=t.min}(i,Th)){const{message:e}=Mn("MISSING_OR_INVALID",`request() expiry: ${i}. Expiry must be a number (in seconds) between ${Th.min} and ${Th.max}`);throw new Error(e)}},this.isValidRespond=async e=>{if(!Qn(e)){const{message:t}=Mn("MISSING_OR_INVALID",`respond() params: ${e}`);throw new Error(t)}const{topic:t,response:r}=e;if(await this.isValidSessionTopic(t),!function(e){return!(zn(e)||zn(e.result)&&zn(e.error)||!Hn(e.id,!1)||!qn(e.jsonrpc,!1))}(r)){const{message:e}=Mn("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(r)}`);throw new Error(e)}},this.isValidPing=async e=>{if(!Qn(e)){const{message:t}=Mn("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}=Mn("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(!Jn(i,n)){const{message:e}=Mn("MISSING_OR_INVALID",`emit() chainId: ${n}`);throw new Error(e)}if(!function(e){return!(zn(e)||!qn(e.name,!1))}(r)){const{message:e}=Mn("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(r)}`);throw new Error(e)}if(!Zn(i,n,r.name)){const{message:e}=Mn("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(r)}`);throw new Error(e)}},this.isValidDisconnect=async e=>{if(!Qn(e)){const{message:t}=Mn("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||jc,validation:"UNKNOWN",origin:t.url||""}};try{const n=await this.client.core.verify.resolve({attestationId:e,verifyUrl:t.verifyUrl});n&&(r.verified.origin=n.origin,r.verified.isScam=n.isScam,r.verified.validation=n.origin===new URL(t.url).origin?"VALID":"INVALID")}catch(e){this.client.logger.info(e)}return this.client.logger.info(`Verify context: ${JSON.stringify(r)}`),r},this.validateSessionProps=(e,t)=>{Object.values(e).forEach((e=>{if(!qn(e,!1)){const{message:r}=Mn("MISSING_OR_INVALID",`${t} must be in Record<string, string> format. Received: ${JSON.stringify(e)}`);throw new Error(r)}}))}}async isInitialized(){if(!this.initialized){const{message:e}=Mn("NOT_INITIALIZED",this.name);throw new Error(e)}await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(ic,(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);try{uo(n)?(this.client.core.history.set(t,n),this.onRelayEventRequest({topic:t,payload:n})):lo(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})}catch(e){this.client.logger.error(e)}}))}registerExpirerEvents(){this.client.core.expirer.on(Tc,(async e=>{const{topic:t,id:r}=gn(e.target);if(r&&this.client.pendingRequest.keys.includes(r))return await this.deletePendingSessionRequest(r,Mn("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}))}))}registerPairingEvents(){this.client.core.pairing.events.on(Ec,(e=>this.onPairingCreated(e)))}isValidPairingTopic(e){if(!qn(e,!1)){const{message:t}=Mn("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}=Mn("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(t)}if(vn(this.client.core.pairing.pairings.get(e).expiry)){const{message:t}=Mn("EXPIRED",`pairing topic: ${e}`);throw new Error(t)}}async isValidSessionTopic(e){if(!qn(e,!1)){const{message:t}=Mn("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw new Error(t)}if(!this.client.session.keys.includes(e)){const{message:t}=Mn("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(t)}if(vn(this.client.session.get(e).expiry)){await this.deleteSession(e);const{message:t}=Mn("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(qn(e,!1)){const{message:t}=Mn("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(t)}{const{message:t}=Mn("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}=Mn("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(t)}if(!this.client.proposal.keys.includes(e)){const{message:t}=Mn("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(t)}if(vn(this.client.proposal.get(e).expiry)){await this.deleteProposal(e);const{message:t}=Mn("EXPIRED",`proposal id: ${e}`);throw new Error(t)}}}class Fh extends lh{constructor(e,t){super(e,t,"proposal",Ph),this.core=e,this.logger=t}}class Wh extends lh{constructor(e,t){super(e,t,"session",Ph),this.core=e,this.logger=t}}class Gh extends lh{constructor(e,t){super(e,t,"request",Ph,(e=>e.id)),this.core=e,this.logger=t}}class Yh extends bs{constructor(e){super(e),this.protocol="wc",this.version=2,this.name=Oh,this.events=new t,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=e?.name||Oh,this.metadata=e?.metadata||gr()||{name:"",description:"",url:"",icons:[""]};const r=typeof e?.logger<"u"&&"string"!=typeof e?.logger?e.logger:ss.pino(ss.getDefaultLoggerOptions({level:e?.logger||Nh}));this.core=e?.core||new Ih(e),this.logger=ss.generateChildLogger(r,this.name),this.session=new Wh(this.core,this.logger),this.proposal=new Fh(this.core,this.logger),this.pendingRequest=new Gh(this.core,this.logger),this.engine=new Bh(this)}static async init(e){const t=new Yh(e);return await t.initialize(),t}get context(){return ss.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 Qh={headers:{Accept:"application/json","Content-Type":"application/json"},method:"POST"};class Jh{constructor(e,r=!1){if(this.url=e,this.disableProviderPing=r,this.events=new t,this.isAvailable=!1,this.registering=!1,!ao(e))throw new Error(`Provided URL is not compatible with HTTP connection: ${e}`);this.url=e,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=xi(e),r=await a(this.url,Object.assign(Object.assign({},Qh),{body:t})),n=await r.json();this.onPayload({data:n})}catch(t){this.onError(e.id,t)}}async register(e=this.url){if(!ao(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=xi({id:1,jsonrpc:"2.0",method:"test",params:[]});await a(e,Object.assign(Object.assign({},Qh),{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?Ri(e.data):e.data;this.events.emit("payload",t)}onError(e,t){const r=this.parseError(t),n=to(e,r.message||r.toString());this.events.emit("payload",n)}parseError(e,t=this.url){return Bs(e,t,"HTTP")}resetMaxListeners(){this.events.getMaxListeners()>10&&this.events.setMaxListeners(10)}}const Xh="error",Zh="wc@2:universal_provider:",eu="default_chain_changed";var tu=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},ru={exports:{}};
2
- /**
3
- * @license
4
- * Lodash <https://lodash.com/>
5
- * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
6
- * Released under MIT license <https://lodash.com/license>
7
- * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
8
- * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
9
- */!function(e,t){(function(){var r,n="Expected a function",i="__lodash_hash_undefined__",s="__lodash_placeholder__",o=16,a=32,c=64,h=128,u=256,l=1/0,f=9007199254740991,p=NaN,d=4294967295,g=[["ary",h],["bind",1],["bindKey",2],["curry",8],["curryRight",o],["flip",512],["partial",a],["partialRight",c],["rearg",u]],y="[object Arguments]",v="[object Array]",m="[object Boolean]",w="[object Date]",_="[object Error]",b="[object Function]",E="[object GeneratorFunction]",I="[object Map]",S="[object Number]",P="[object Object]",O="[object Promise]",N="[object RegExp]",A="[object Set]",C="[object String]",R="[object Symbol]",x="[object WeakMap]",T="[object ArrayBuffer]",L="[object DataView]",U="[object Float32Array]",j="[object Float64Array]",M="[object Int8Array]",D="[object Int16Array]",k="[object Int32Array]",$="[object Uint8Array]",z="[object Uint8ClampedArray]",q="[object Uint16Array]",H="[object Uint32Array]",K=/\b__p \+= '';/g,V=/\b(__p \+=) '' \+/g,B=/(__e\(.*?\)|\b__t\)) \+\n'';/g,F=/&(?:amp|lt|gt|quot|#39);/g,W=/[&<>"']/g,G=RegExp(F.source),Y=RegExp(W.source),Q=/<%-([\s\S]+?)%>/g,J=/<%([\s\S]+?)%>/g,X=/<%=([\s\S]+?)%>/g,Z=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,ee=/^\w*$/,te=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,re=/[\\^$.*+?()[\]{}|]/g,ne=RegExp(re.source),ie=/^\s+/,se=/\s/,oe=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,ae=/\{\n\/\* \[wrapped with (.+)\] \*/,ce=/,? & /,he=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,ue=/[()=,{}\[\]\/\s]/,le=/\\(\\)?/g,fe=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,pe=/\w*$/,de=/^[-+]0x[0-9a-f]+$/i,ge=/^0b[01]+$/i,ye=/^\[object .+?Constructor\]$/,ve=/^0o[0-7]+$/i,me=/^(?:0|[1-9]\d*)$/,we=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,_e=/($^)/,be=/['\n\r\u2028\u2029\\]/g,Ee="\\ud800-\\udfff",Ie="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",Se="\\u2700-\\u27bf",Pe="a-z\\xdf-\\xf6\\xf8-\\xff",Oe="A-Z\\xc0-\\xd6\\xd8-\\xde",Ne="\\ufe0e\\ufe0f",Ae="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Ce="['’]",Re="["+Ee+"]",xe="["+Ae+"]",Te="["+Ie+"]",Le="\\d+",Ue="["+Se+"]",je="["+Pe+"]",Me="[^"+Ee+Ae+Le+Se+Pe+Oe+"]",De="\\ud83c[\\udffb-\\udfff]",ke="[^"+Ee+"]",$e="(?:\\ud83c[\\udde6-\\uddff]){2}",ze="[\\ud800-\\udbff][\\udc00-\\udfff]",qe="["+Oe+"]",He="\\u200d",Ke="(?:"+je+"|"+Me+")",Ve="(?:"+qe+"|"+Me+")",Be="(?:['’](?:d|ll|m|re|s|t|ve))?",Fe="(?:['’](?:D|LL|M|RE|S|T|VE))?",We="(?:"+Te+"|"+De+")"+"?",Ge="["+Ne+"]?",Ye=Ge+We+("(?:"+He+"(?:"+[ke,$e,ze].join("|")+")"+Ge+We+")*"),Qe="(?:"+[Ue,$e,ze].join("|")+")"+Ye,Je="(?:"+[ke+Te+"?",Te,$e,ze,Re].join("|")+")",Xe=RegExp(Ce,"g"),Ze=RegExp(Te,"g"),et=RegExp(De+"(?="+De+")|"+Je+Ye,"g"),tt=RegExp([qe+"?"+je+"+"+Be+"(?="+[xe,qe,"$"].join("|")+")",Ve+"+"+Fe+"(?="+[xe,qe+Ke,"$"].join("|")+")",qe+"?"+Ke+"+"+Be,qe+"+"+Fe,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Le,Qe].join("|"),"g"),rt=RegExp("["+He+Ee+Ie+Ne+"]"),nt=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,it=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],st=-1,ot={};ot[U]=ot[j]=ot[M]=ot[D]=ot[k]=ot[$]=ot[z]=ot[q]=ot[H]=!0,ot[y]=ot[v]=ot[T]=ot[m]=ot[L]=ot[w]=ot[_]=ot[b]=ot[I]=ot[S]=ot[P]=ot[N]=ot[A]=ot[C]=ot[x]=!1;var at={};at[y]=at[v]=at[T]=at[L]=at[m]=at[w]=at[U]=at[j]=at[M]=at[D]=at[k]=at[I]=at[S]=at[P]=at[N]=at[A]=at[C]=at[R]=at[$]=at[z]=at[q]=at[H]=!0,at[_]=at[b]=at[x]=!1;var ct={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},ht=parseFloat,ut=parseInt,lt="object"==typeof tu&&tu&&tu.Object===Object&&tu,ft="object"==typeof self&&self&&self.Object===Object&&self,pt=lt||ft||Function("return this")(),dt=t&&!t.nodeType&&t,gt=dt&&e&&!e.nodeType&&e,yt=gt&&gt.exports===dt,vt=yt&&lt.process,mt=function(){try{return gt&&gt.require&&gt.require("util").types||vt&&vt.binding&&vt.binding("util")}catch{}}(),wt=mt&&mt.isArrayBuffer,_t=mt&&mt.isDate,bt=mt&&mt.isMap,Et=mt&&mt.isRegExp,It=mt&&mt.isSet,St=mt&&mt.isTypedArray;function Pt(e,t,r){switch(r.length){case 0:return e.call(t);case 1:return e.call(t,r[0]);case 2:return e.call(t,r[0],r[1]);case 3:return e.call(t,r[0],r[1],r[2])}return e.apply(t,r)}function Ot(e,t,r,n){for(var i=-1,s=null==e?0:e.length;++i<s;){var o=e[i];t(n,o,r(o),e)}return n}function Nt(e,t){for(var r=-1,n=null==e?0:e.length;++r<n&&!1!==t(e[r],r,e););return e}function At(e,t){for(var r=null==e?0:e.length;r--&&!1!==t(e[r],r,e););return e}function Ct(e,t){for(var r=-1,n=null==e?0:e.length;++r<n;)if(!t(e[r],r,e))return!1;return!0}function Rt(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}function xt(e,t){return!!(null==e?0:e.length)&&qt(e,t,0)>-1}function Tt(e,t,r){for(var n=-1,i=null==e?0:e.length;++n<i;)if(r(t,e[n]))return!0;return!1}function Lt(e,t){for(var r=-1,n=null==e?0:e.length,i=Array(n);++r<n;)i[r]=t(e[r],r,e);return i}function Ut(e,t){for(var r=-1,n=t.length,i=e.length;++r<n;)e[i+r]=t[r];return e}function jt(e,t,r,n){var i=-1,s=null==e?0:e.length;for(n&&s&&(r=e[++i]);++i<s;)r=t(r,e[i],i,e);return r}function Mt(e,t,r,n){var i=null==e?0:e.length;for(n&&i&&(r=e[--i]);i--;)r=t(r,e[i],i,e);return r}function Dt(e,t){for(var r=-1,n=null==e?0:e.length;++r<n;)if(t(e[r],r,e))return!0;return!1}var kt=Bt("length");function $t(e,t,r){var n;return r(e,(function(e,r,i){if(t(e,r,i))return n=r,!1})),n}function zt(e,t,r,n){for(var i=e.length,s=r+(n?1:-1);n?s--:++s<i;)if(t(e[s],s,e))return s;return-1}function qt(e,t,r){return t==t?function(e,t,r){for(var n=r-1,i=e.length;++n<i;)if(e[n]===t)return n;return-1}(e,t,r):zt(e,Kt,r)}function Ht(e,t,r,n){for(var i=r-1,s=e.length;++i<s;)if(n(e[i],t))return i;return-1}function Kt(e){return e!=e}function Vt(e,t){var r=null==e?0:e.length;return r?Gt(e,t)/r:p}function Bt(e){return function(t){return null==t?r:t[e]}}function Ft(e){return function(t){return null==e?r:e[t]}}function Wt(e,t,r,n,i){return i(e,(function(e,i,s){r=n?(n=!1,e):t(r,e,i,s)})),r}function Gt(e,t){for(var n,i=-1,s=e.length;++i<s;){var o=t(e[i]);o!==r&&(n=n===r?o:n+o)}return n}function Yt(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}function Qt(e){return e&&e.slice(0,fr(e)+1).replace(ie,"")}function Jt(e){return function(t){return e(t)}}function Xt(e,t){return Lt(t,(function(t){return e[t]}))}function Zt(e,t){return e.has(t)}function er(e,t){for(var r=-1,n=e.length;++r<n&&qt(t,e[r],0)>-1;);return r}function tr(e,t){for(var r=e.length;r--&&qt(t,e[r],0)>-1;);return r}var rr=Ft({"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss","Ā":"A","Ă":"A","Ą":"A","ā":"a","ă":"a","ą":"a","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","ć":"c","ĉ":"c","ċ":"c","č":"c","Ď":"D","Đ":"D","ď":"d","đ":"d","Ē":"E","Ĕ":"E","Ė":"E","Ę":"E","Ě":"E","ē":"e","ĕ":"e","ė":"e","ę":"e","ě":"e","Ĝ":"G","Ğ":"G","Ġ":"G","Ģ":"G","ĝ":"g","ğ":"g","ġ":"g","ģ":"g","Ĥ":"H","Ħ":"H","ĥ":"h","ħ":"h","Ĩ":"I","Ī":"I","Ĭ":"I","Į":"I","İ":"I","ĩ":"i","ī":"i","ĭ":"i","į":"i","ı":"i","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","Ļ":"L","Ľ":"L","Ŀ":"L","Ł":"L","ĺ":"l","ļ":"l","ľ":"l","ŀ":"l","ł":"l","Ń":"N","Ņ":"N","Ň":"N","Ŋ":"N","ń":"n","ņ":"n","ň":"n","ŋ":"n","Ō":"O","Ŏ":"O","Ő":"O","ō":"o","ŏ":"o","ő":"o","Ŕ":"R","Ŗ":"R","Ř":"R","ŕ":"r","ŗ":"r","ř":"r","Ś":"S","Ŝ":"S","Ş":"S","Š":"S","ś":"s","ŝ":"s","ş":"s","š":"s","Ţ":"T","Ť":"T","Ŧ":"T","ţ":"t","ť":"t","ŧ":"t","Ũ":"U","Ū":"U","Ŭ":"U","Ů":"U","Ű":"U","Ų":"U","ũ":"u","ū":"u","ŭ":"u","ů":"u","ű":"u","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","Ż":"Z","Ž":"Z","ź":"z","ż":"z","ž":"z","IJ":"IJ","ij":"ij","Œ":"Oe","œ":"oe","ʼn":"'n","ſ":"s"}),nr=Ft({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"});function ir(e){return"\\"+ct[e]}function sr(e){return rt.test(e)}function or(e){var t=-1,r=Array(e.size);return e.forEach((function(e,n){r[++t]=[n,e]})),r}function ar(e,t){return function(r){return e(t(r))}}function cr(e,t){for(var r=-1,n=e.length,i=0,o=[];++r<n;){var a=e[r];(a===t||a===s)&&(e[r]=s,o[i++]=r)}return o}function hr(e){var t=-1,r=Array(e.size);return e.forEach((function(e){r[++t]=e})),r}function ur(e){return sr(e)?function(e){for(var t=et.lastIndex=0;et.test(e);)++t;return t}(e):kt(e)}function lr(e){return sr(e)?function(e){return e.match(et)||[]}(e):function(e){return e.split("")}(e)}function fr(e){for(var t=e.length;t--&&se.test(e.charAt(t)););return t}var pr=Ft({"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"});var dr=function e(t){var se=(t=null==t?pt:dr.defaults(pt.Object(),t,dr.pick(pt,it))).Array,Ee=t.Date,Ie=t.Error,Se=t.Function,Pe=t.Math,Oe=t.Object,Ne=t.RegExp,Ae=t.String,Ce=t.TypeError,Re=se.prototype,xe=Se.prototype,Te=Oe.prototype,Le=t["__core-js_shared__"],Ue=xe.toString,je=Te.hasOwnProperty,Me=0,De=function(){var e=/[^.]+$/.exec(Le&&Le.keys&&Le.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),ke=Te.toString,$e=Ue.call(Oe),ze=pt._,qe=Ne("^"+Ue.call(je).replace(re,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),He=yt?t.Buffer:r,Ke=t.Symbol,Ve=t.Uint8Array,Be=He?He.allocUnsafe:r,Fe=ar(Oe.getPrototypeOf,Oe),We=Oe.create,Ge=Te.propertyIsEnumerable,Ye=Re.splice,Qe=Ke?Ke.isConcatSpreadable:r,Je=Ke?Ke.iterator:r,et=Ke?Ke.toStringTag:r,rt=function(){try{var e=us(Oe,"defineProperty");return e({},"",{}),e}catch{}}(),ct=t.clearTimeout!==pt.clearTimeout&&t.clearTimeout,lt=Ee&&Ee.now!==pt.Date.now&&Ee.now,ft=t.setTimeout!==pt.setTimeout&&t.setTimeout,dt=Pe.ceil,gt=Pe.floor,vt=Oe.getOwnPropertySymbols,mt=He?He.isBuffer:r,kt=t.isFinite,Ft=Re.join,gr=ar(Oe.keys,Oe),yr=Pe.max,vr=Pe.min,mr=Ee.now,wr=t.parseInt,_r=Pe.random,br=Re.reverse,Er=us(t,"DataView"),Ir=us(t,"Map"),Sr=us(t,"Promise"),Pr=us(t,"Set"),Or=us(t,"WeakMap"),Nr=us(Oe,"create"),Ar=Or&&new Or,Cr={},Rr=Ms(Er),xr=Ms(Ir),Tr=Ms(Sr),Lr=Ms(Pr),Ur=Ms(Or),jr=Ke?Ke.prototype:r,Mr=jr?jr.valueOf:r,Dr=jr?jr.toString:r;function kr(e){if(ea(e)&&!Ko(e)&&!(e instanceof Hr)){if(e instanceof qr)return e;if(je.call(e,"__wrapped__"))return Ds(e)}return new qr(e)}var $r=function(){function e(){}return function(t){if(!Zo(t))return{};if(We)return We(t);e.prototype=t;var n=new e;return e.prototype=r,n}}();function zr(){}function qr(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=r}function Hr(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=d,this.__views__=[]}function Kr(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 Vr(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 Br(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 Fr(e){var t=-1,r=null==e?0:e.length;for(this.__data__=new Br;++t<r;)this.add(e[t])}function Wr(e){var t=this.__data__=new Vr(e);this.size=t.size}function Gr(e,t){var r=Ko(e),n=!r&&Ho(e),i=!r&&!n&&Wo(e),s=!r&&!n&&!i&&ca(e),o=r||n||i||s,a=o?Yt(e.length,Ae):[],c=a.length;for(var h in e)(t||je.call(e,h))&&(!o||!("length"==h||i&&("offset"==h||"parent"==h)||s&&("buffer"==h||"byteLength"==h||"byteOffset"==h)||vs(h,c)))&&a.push(h);return a}function Yr(e){var t=e.length;return t?e[Wn(0,t-1)]:r}function Qr(e,t){return Ls(Ai(e),on(t,0,e.length))}function Jr(e){return Ls(Ai(e))}function Xr(e,t,n){(n!==r&&!$o(e[t],n)||n===r&&!(t in e))&&nn(e,t,n)}function Zr(e,t,n){var i=e[t];(!je.call(e,t)||!$o(i,n)||n===r&&!(t in e))&&nn(e,t,n)}function en(e,t){for(var r=e.length;r--;)if($o(e[r][0],t))return r;return-1}function tn(e,t,r,n){return ln(e,(function(e,i,s){t(n,e,r(e),s)})),n}function rn(e,t){return e&&Ci(t,Ra(t),e)}function nn(e,t,r){"__proto__"==t&&rt?rt(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r}function sn(e,t){for(var n=-1,i=t.length,s=se(i),o=null==e;++n<i;)s[n]=o?r:Pa(e,t[n]);return s}function on(e,t,n){return e==e&&(n!==r&&(e=e<=n?e:n),t!==r&&(e=e>=t?e:t)),e}function an(e,t,n,i,s,o){var a,c=1&t,h=2&t,u=4&t;if(n&&(a=s?n(e,i,s,o):n(e)),a!==r)return a;if(!Zo(e))return e;var l=Ko(e);if(l){if(a=function(e){var t=e.length,r=new e.constructor(t);return t&&"string"==typeof e[0]&&je.call(e,"index")&&(r.index=e.index,r.input=e.input),r}(e),!c)return Ai(e,a)}else{var f=ps(e),p=f==b||f==E;if(Wo(e))return Ei(e,c);if(f==P||f==y||p&&!s){if(a=h||p?{}:gs(e),!c)return h?function(e,t){return Ci(e,fs(e),t)}(e,function(e,t){return e&&Ci(t,xa(t),e)}(a,e)):function(e,t){return Ci(e,ls(e),t)}(e,rn(a,e))}else{if(!at[f])return s?e:{};a=function(e,t,r){var n=e.constructor;switch(t){case T:return Ii(e);case m:case w:return new n(+e);case L:return function(e,t){var r=t?Ii(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}(e,r);case U:case j:case M:case D:case k:case $:case z:case q:case H:return Si(e,r);case I:return new n;case S:case C:return new n(e);case N:return function(e){var t=new e.constructor(e.source,pe.exec(e));return t.lastIndex=e.lastIndex,t}(e);case A:return new n;case R:return function(e){return Mr?Oe(Mr.call(e)):{}}(e)}}(e,f,c)}}o||(o=new Wr);var d=o.get(e);if(d)return d;o.set(e,a),sa(e)?e.forEach((function(r){a.add(an(r,t,n,r,e,o))})):ta(e)&&e.forEach((function(r,i){a.set(i,an(r,t,n,i,e,o))}));var g=l?r:(u?h?ns:rs:h?xa:Ra)(e);return Nt(g||e,(function(r,i){g&&(r=e[i=r]),Zr(a,i,an(r,t,n,i,e,o))})),a}function cn(e,t,n){var i=n.length;if(null==e)return!i;for(e=Oe(e);i--;){var s=n[i],o=t[s],a=e[s];if(a===r&&!(s in e)||!o(a))return!1}return!0}function hn(e,t,i){if("function"!=typeof e)throw new Ce(n);return Cs((function(){e.apply(r,i)}),t)}function un(e,t,r,n){var i=-1,s=xt,o=!0,a=e.length,c=[],h=t.length;if(!a)return c;r&&(t=Lt(t,Jt(r))),n?(s=Tt,o=!1):t.length>=200&&(s=Zt,o=!1,t=new Fr(t));e:for(;++i<a;){var u=e[i],l=null==r?u:r(u);if(u=n||0!==u?u:0,o&&l==l){for(var f=h;f--;)if(t[f]===l)continue e;c.push(u)}else s(t,l,n)||c.push(u)}return c}kr.templateSettings={escape:Q,evaluate:J,interpolate:X,variable:"",imports:{_:kr}},kr.prototype=zr.prototype,kr.prototype.constructor=kr,qr.prototype=$r(zr.prototype),qr.prototype.constructor=qr,Hr.prototype=$r(zr.prototype),Hr.prototype.constructor=Hr,Kr.prototype.clear=function(){this.__data__=Nr?Nr(null):{},this.size=0},Kr.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},Kr.prototype.get=function(e){var t=this.__data__;if(Nr){var n=t[e];return n===i?r:n}return je.call(t,e)?t[e]:r},Kr.prototype.has=function(e){var t=this.__data__;return Nr?t[e]!==r:je.call(t,e)},Kr.prototype.set=function(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=Nr&&t===r?i:t,this},Vr.prototype.clear=function(){this.__data__=[],this.size=0},Vr.prototype.delete=function(e){var t=this.__data__,r=en(t,e);return!(r<0)&&(r==t.length-1?t.pop():Ye.call(t,r,1),--this.size,!0)},Vr.prototype.get=function(e){var t=this.__data__,n=en(t,e);return n<0?r:t[n][1]},Vr.prototype.has=function(e){return en(this.__data__,e)>-1},Vr.prototype.set=function(e,t){var r=this.__data__,n=en(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this},Br.prototype.clear=function(){this.size=0,this.__data__={hash:new Kr,map:new(Ir||Vr),string:new Kr}},Br.prototype.delete=function(e){var t=cs(this,e).delete(e);return this.size-=t?1:0,t},Br.prototype.get=function(e){return cs(this,e).get(e)},Br.prototype.has=function(e){return cs(this,e).has(e)},Br.prototype.set=function(e,t){var r=cs(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this},Fr.prototype.add=Fr.prototype.push=function(e){return this.__data__.set(e,i),this},Fr.prototype.has=function(e){return this.__data__.has(e)},Wr.prototype.clear=function(){this.__data__=new Vr,this.size=0},Wr.prototype.delete=function(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r},Wr.prototype.get=function(e){return this.__data__.get(e)},Wr.prototype.has=function(e){return this.__data__.has(e)},Wr.prototype.set=function(e,t){var r=this.__data__;if(r instanceof Vr){var n=r.__data__;if(!Ir||n.length<199)return n.push([e,t]),this.size=++r.size,this;r=this.__data__=new Br(n)}return r.set(e,t),this.size=r.size,this};var ln=Ti(wn),fn=Ti(_n,!0);function pn(e,t){var r=!0;return ln(e,(function(e,n,i){return r=!!t(e,n,i)})),r}function dn(e,t,n){for(var i=-1,s=e.length;++i<s;){var o=e[i],a=t(o);if(null!=a&&(c===r?a==a&&!aa(a):n(a,c)))var c=a,h=o}return h}function gn(e,t){var r=[];return ln(e,(function(e,n,i){t(e,n,i)&&r.push(e)})),r}function yn(e,t,r,n,i){var s=-1,o=e.length;for(r||(r=ys),i||(i=[]);++s<o;){var a=e[s];t>0&&r(a)?t>1?yn(a,t-1,r,n,i):Ut(i,a):n||(i[i.length]=a)}return i}var vn=Li(),mn=Li(!0);function wn(e,t){return e&&vn(e,t,Ra)}function _n(e,t){return e&&mn(e,t,Ra)}function bn(e,t){return Rt(t,(function(t){return Qo(e[t])}))}function En(e,t){for(var n=0,i=(t=mi(t,e)).length;null!=e&&n<i;)e=e[js(t[n++])];return n&&n==i?e:r}function In(e,t,r){var n=t(e);return Ko(e)?n:Ut(n,r(e))}function Sn(e){return null==e?e===r?"[object Undefined]":"[object Null]":et&&et in Oe(e)?function(e){var t=je.call(e,et),n=e[et];try{e[et]=r;var i=!0}catch{}var s=ke.call(e);return i&&(t?e[et]=n:delete e[et]),s}(e):function(e){return ke.call(e)}(e)}function Pn(e,t){return e>t}function On(e,t){return null!=e&&je.call(e,t)}function Nn(e,t){return null!=e&&t in Oe(e)}function An(e,t,n){for(var i=n?Tt:xt,s=e[0].length,o=e.length,a=o,c=se(o),h=1/0,u=[];a--;){var l=e[a];a&&t&&(l=Lt(l,Jt(t))),h=vr(l.length,h),c[a]=!n&&(t||s>=120&&l.length>=120)?new Fr(a&&l):r}l=e[0];var f=-1,p=c[0];e:for(;++f<s&&u.length<h;){var d=l[f],g=t?t(d):d;if(d=n||0!==d?d:0,!(p?Zt(p,g):i(u,g,n))){for(a=o;--a;){var y=c[a];if(!(y?Zt(y,g):i(e[a],g,n)))continue e}p&&p.push(g),u.push(d)}}return u}function Cn(e,t,n){var i=null==(e=Os(e,t=mi(t,e)))?e:e[js(Gs(t))];return null==i?r:Pt(i,e,n)}function Rn(e){return ea(e)&&Sn(e)==y}function xn(e,t,n,i,s){return e===t||(null==e||null==t||!ea(e)&&!ea(t)?e!=e&&t!=t:function(e,t,n,i,s,o){var a=Ko(e),c=Ko(t),h=a?v:ps(e),u=c?v:ps(t);h=h==y?P:h,u=u==y?P:u;var l=h==P,f=u==P,p=h==u;if(p&&Wo(e)){if(!Wo(t))return!1;a=!0,l=!1}if(p&&!l)return o||(o=new Wr),a||ca(e)?es(e,t,n,i,s,o):function(e,t,r,n,i,s,o){switch(r){case L:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case T:return!(e.byteLength!=t.byteLength||!s(new Ve(e),new Ve(t)));case m:case w:case S:return $o(+e,+t);case _:return e.name==t.name&&e.message==t.message;case N:case C:return e==t+"";case I:var a=or;case A:var c=1&n;if(a||(a=hr),e.size!=t.size&&!c)return!1;var h=o.get(e);if(h)return h==t;n|=2,o.set(e,t);var u=es(a(e),a(t),n,i,s,o);return o.delete(e),u;case R:if(Mr)return Mr.call(e)==Mr.call(t)}return!1}(e,t,h,n,i,s,o);if(!(1&n)){var d=l&&je.call(e,"__wrapped__"),g=f&&je.call(t,"__wrapped__");if(d||g){var b=d?e.value():e,E=g?t.value():t;return o||(o=new Wr),s(b,E,n,i,o)}}return!!p&&(o||(o=new Wr),function(e,t,n,i,s,o){var a=1&n,c=rs(e),h=c.length,u=rs(t),l=u.length;if(h!=l&&!a)return!1;for(var f=h;f--;){var p=c[f];if(!(a?p in t:je.call(t,p)))return!1}var d=o.get(e),g=o.get(t);if(d&&g)return d==t&&g==e;var y=!0;o.set(e,t),o.set(t,e);for(var v=a;++f<h;){var m=e[p=c[f]],w=t[p];if(i)var _=a?i(w,m,p,t,e,o):i(m,w,p,e,t,o);if(!(_===r?m===w||s(m,w,n,i,o):_)){y=!1;break}v||(v="constructor"==p)}if(y&&!v){var b=e.constructor,E=t.constructor;b!=E&&"constructor"in e&&"constructor"in t&&!("function"==typeof b&&b instanceof b&&"function"==typeof E&&E instanceof E)&&(y=!1)}return o.delete(e),o.delete(t),y}(e,t,n,i,s,o))}(e,t,n,i,xn,s))}function Tn(e,t,n,i){var s=n.length,o=s,a=!i;if(null==e)return!o;for(e=Oe(e);s--;){var c=n[s];if(a&&c[2]?c[1]!==e[c[0]]:!(c[0]in e))return!1}for(;++s<o;){var h=(c=n[s])[0],u=e[h],l=c[1];if(a&&c[2]){if(u===r&&!(h in e))return!1}else{var f=new Wr;if(i)var p=i(u,l,h,e,t,f);if(!(p===r?xn(l,u,3,i,f):p))return!1}}return!0}function Ln(e){return!(!Zo(e)||function(e){return!!De&&De in e}(e))&&(Qo(e)?qe:ye).test(Ms(e))}function Un(e){return"function"==typeof e?e:null==e?rc:"object"==typeof e?Ko(e)?zn(e[0],e[1]):$n(e):lc(e)}function jn(e){if(!Es(e))return gr(e);var t=[];for(var r in Oe(e))je.call(e,r)&&"constructor"!=r&&t.push(r);return t}function Mn(e){if(!Zo(e))return function(e){var t=[];if(null!=e)for(var r in Oe(e))t.push(r);return t}(e);var t=Es(e),r=[];for(var n in e)"constructor"==n&&(t||!je.call(e,n))||r.push(n);return r}function Dn(e,t){return e<t}function kn(e,t){var r=-1,n=Bo(e)?se(e.length):[];return ln(e,(function(e,i,s){n[++r]=t(e,i,s)})),n}function $n(e){var t=hs(e);return 1==t.length&&t[0][2]?Ss(t[0][0],t[0][1]):function(r){return r===e||Tn(r,e,t)}}function zn(e,t){return ws(e)&&Is(t)?Ss(js(e),t):function(n){var i=Pa(n,e);return i===r&&i===t?Oa(n,e):xn(t,i,3)}}function qn(e,t,n,i,s){e!==t&&vn(t,(function(o,a){if(s||(s=new Wr),Zo(o))!function(e,t,n,i,s,o,a){var c=Ns(e,n),h=Ns(t,n),u=a.get(h);if(u)return void Xr(e,n,u);var l=o?o(c,h,n+"",e,t,a):r,f=l===r;if(f){var p=Ko(h),d=!p&&Wo(h),g=!p&&!d&&ca(h);l=h,p||d||g?Ko(c)?l=c:Fo(c)?l=Ai(c):d?(f=!1,l=Ei(h,!0)):g?(f=!1,l=Si(h,!0)):l=[]:na(h)||Ho(h)?(l=c,Ho(c)?l=ya(c):(!Zo(c)||Qo(c))&&(l=gs(h))):f=!1}f&&(a.set(h,l),s(l,h,i,o,a),a.delete(h)),Xr(e,n,l)}(e,t,a,n,qn,i,s);else{var c=i?i(Ns(e,a),o,a+"",e,t,s):r;c===r&&(c=o),Xr(e,a,c)}}),xa)}function Hn(e,t){var n=e.length;if(n)return vs(t+=t<0?n:0,n)?e[t]:r}function Kn(e,t,r){t=t.length?Lt(t,(function(e){return Ko(e)?function(t){return En(t,1===e.length?e[0]:e)}:e})):[rc];var n=-1;t=Lt(t,Jt(as()));var i=kn(e,(function(e,r,i){var s=Lt(t,(function(t){return t(e)}));return{criteria:s,index:++n,value:e}}));return function(e,t){var r=e.length;for(e.sort(t);r--;)e[r]=e[r].value;return e}(i,(function(e,t){return function(e,t,r){for(var n=-1,i=e.criteria,s=t.criteria,o=i.length,a=r.length;++n<o;){var c=Pi(i[n],s[n]);if(c)return n>=a?c:c*("desc"==r[n]?-1:1)}return e.index-t.index}(e,t,r)}))}function Vn(e,t,r){for(var n=-1,i=t.length,s={};++n<i;){var o=t[n],a=En(e,o);r(a,o)&&Xn(s,mi(o,e),a)}return s}function Bn(e,t,r,n){var i=n?Ht:qt,s=-1,o=t.length,a=e;for(e===t&&(t=Ai(t)),r&&(a=Lt(e,Jt(r)));++s<o;)for(var c=0,h=t[s],u=r?r(h):h;(c=i(a,u,c,n))>-1;)a!==e&&Ye.call(a,c,1),Ye.call(e,c,1);return e}function Fn(e,t){for(var r=e?t.length:0,n=r-1;r--;){var i=t[r];if(r==n||i!==s){var s=i;vs(i)?Ye.call(e,i,1):ui(e,i)}}return e}function Wn(e,t){return e+gt(_r()*(t-e+1))}function Gn(e,t){var r="";if(!e||t<1||t>f)return r;do{t%2&&(r+=e),(t=gt(t/2))&&(e+=e)}while(t);return r}function Yn(e,t){return Rs(Ps(e,t,rc),e+"")}function Qn(e){return Yr($a(e))}function Jn(e,t){var r=$a(e);return Ls(r,on(t,0,r.length))}function Xn(e,t,n,i){if(!Zo(e))return e;for(var s=-1,o=(t=mi(t,e)).length,a=o-1,c=e;null!=c&&++s<o;){var h=js(t[s]),u=n;if("__proto__"===h||"constructor"===h||"prototype"===h)return e;if(s!=a){var l=c[h];(u=i?i(l,h,c):r)===r&&(u=Zo(l)?l:vs(t[s+1])?[]:{})}Zr(c,h,u),c=c[h]}return e}var Zn=Ar?function(e,t){return Ar.set(e,t),e}:rc,ei=rt?function(e,t){return rt(e,"toString",{configurable:!0,enumerable:!1,value:Za(t),writable:!0})}:rc;function ti(e){return Ls($a(e))}function ri(e,t,r){var n=-1,i=e.length;t<0&&(t=-t>i?0:i+t),(r=r>i?i:r)<0&&(r+=i),i=t>r?0:r-t>>>0,t>>>=0;for(var s=se(i);++n<i;)s[n]=e[n+t];return s}function ni(e,t){var r;return ln(e,(function(e,n,i){return!(r=t(e,n,i))})),!!r}function ii(e,t,r){var n=0,i=null==e?n:e.length;if("number"==typeof t&&t==t&&i<=2147483647){for(;n<i;){var s=n+i>>>1,o=e[s];null!==o&&!aa(o)&&(r?o<=t:o<t)?n=s+1:i=s}return i}return si(e,t,rc,r)}function si(e,t,n,i){var s=0,o=null==e?0:e.length;if(0===o)return 0;for(var a=(t=n(t))!=t,c=null===t,h=aa(t),u=t===r;s<o;){var l=gt((s+o)/2),f=n(e[l]),p=f!==r,d=null===f,g=f==f,y=aa(f);if(a)var v=i||g;else v=u?g&&(i||p):c?g&&p&&(i||!d):h?g&&p&&!d&&(i||!y):!d&&!y&&(i?f<=t:f<t);v?s=l+1:o=l}return vr(o,4294967294)}function oi(e,t){for(var r=-1,n=e.length,i=0,s=[];++r<n;){var o=e[r],a=t?t(o):o;if(!r||!$o(a,c)){var c=a;s[i++]=0===o?0:o}}return s}function ai(e){return"number"==typeof e?e:aa(e)?p:+e}function ci(e){if("string"==typeof e)return e;if(Ko(e))return Lt(e,ci)+"";if(aa(e))return Dr?Dr.call(e):"";var t=e+"";return"0"==t&&1/e==-l?"-0":t}function hi(e,t,r){var n=-1,i=xt,s=e.length,o=!0,a=[],c=a;if(r)o=!1,i=Tt;else if(s>=200){var h=t?null:Gi(e);if(h)return hr(h);o=!1,i=Zt,c=new Fr}else c=t?[]:a;e:for(;++n<s;){var u=e[n],l=t?t(u):u;if(u=r||0!==u?u:0,o&&l==l){for(var f=c.length;f--;)if(c[f]===l)continue e;t&&c.push(l),a.push(u)}else i(c,l,r)||(c!==a&&c.push(l),a.push(u))}return a}function ui(e,t){return null==(e=Os(e,t=mi(t,e)))||delete e[js(Gs(t))]}function li(e,t,r,n){return Xn(e,t,r(En(e,t)),n)}function fi(e,t,r,n){for(var i=e.length,s=n?i:-1;(n?s--:++s<i)&&t(e[s],s,e););return r?ri(e,n?0:s,n?s+1:i):ri(e,n?s+1:0,n?i:s)}function pi(e,t){var r=e;return r instanceof Hr&&(r=r.value()),jt(t,(function(e,t){return t.func.apply(t.thisArg,Ut([e],t.args))}),r)}function di(e,t,r){var n=e.length;if(n<2)return n?hi(e[0]):[];for(var i=-1,s=se(n);++i<n;)for(var o=e[i],a=-1;++a<n;)a!=i&&(s[i]=un(s[i]||o,e[a],t,r));return hi(yn(s,1),t,r)}function gi(e,t,n){for(var i=-1,s=e.length,o=t.length,a={};++i<s;){var c=i<o?t[i]:r;n(a,e[i],c)}return a}function yi(e){return Fo(e)?e:[]}function vi(e){return"function"==typeof e?e:rc}function mi(e,t){return Ko(e)?e:ws(e,t)?[e]:Us(va(e))}var wi=Yn;function _i(e,t,n){var i=e.length;return n=n===r?i:n,!t&&n>=i?e:ri(e,t,n)}var bi=ct||function(e){return pt.clearTimeout(e)};function Ei(e,t){if(t)return e.slice();var r=e.length,n=Be?Be(r):new e.constructor(r);return e.copy(n),n}function Ii(e){var t=new e.constructor(e.byteLength);return new Ve(t).set(new Ve(e)),t}function Si(e,t){var r=t?Ii(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}function Pi(e,t){if(e!==t){var n=e!==r,i=null===e,s=e==e,o=aa(e),a=t!==r,c=null===t,h=t==t,u=aa(t);if(!c&&!u&&!o&&e>t||o&&a&&h&&!c&&!u||i&&a&&h||!n&&h||!s)return 1;if(!i&&!o&&!u&&e<t||u&&n&&s&&!i&&!o||c&&n&&s||!a&&s||!h)return-1}return 0}function Oi(e,t,r,n){for(var i=-1,s=e.length,o=r.length,a=-1,c=t.length,h=yr(s-o,0),u=se(c+h),l=!n;++a<c;)u[a]=t[a];for(;++i<o;)(l||i<s)&&(u[r[i]]=e[i]);for(;h--;)u[a++]=e[i++];return u}function Ni(e,t,r,n){for(var i=-1,s=e.length,o=-1,a=r.length,c=-1,h=t.length,u=yr(s-a,0),l=se(u+h),f=!n;++i<u;)l[i]=e[i];for(var p=i;++c<h;)l[p+c]=t[c];for(;++o<a;)(f||i<s)&&(l[p+r[o]]=e[i++]);return l}function Ai(e,t){var r=-1,n=e.length;for(t||(t=se(n));++r<n;)t[r]=e[r];return t}function Ci(e,t,n,i){var s=!n;n||(n={});for(var o=-1,a=t.length;++o<a;){var c=t[o],h=i?i(n[c],e[c],c,n,e):r;h===r&&(h=e[c]),s?nn(n,c,h):Zr(n,c,h)}return n}function Ri(e,t){return function(r,n){var i=Ko(r)?Ot:tn,s=t?t():{};return i(r,e,as(n,2),s)}}function xi(e){return Yn((function(t,n){var i=-1,s=n.length,o=s>1?n[s-1]:r,a=s>2?n[2]:r;for(o=e.length>3&&"function"==typeof o?(s--,o):r,a&&ms(n[0],n[1],a)&&(o=s<3?r:o,s=1),t=Oe(t);++i<s;){var c=n[i];c&&e(t,c,i,o)}return t}))}function Ti(e,t){return function(r,n){if(null==r)return r;if(!Bo(r))return e(r,n);for(var i=r.length,s=t?i:-1,o=Oe(r);(t?s--:++s<i)&&!1!==n(o[s],s,o););return r}}function Li(e){return function(t,r,n){for(var i=-1,s=Oe(t),o=n(t),a=o.length;a--;){var c=o[e?a:++i];if(!1===r(s[c],c,s))break}return t}}function Ui(e){return function(t){var n=sr(t=va(t))?lr(t):r,i=n?n[0]:t.charAt(0),s=n?_i(n,1).join(""):t.slice(1);return i[e]()+s}}function ji(e){return function(t){return jt(Qa(Ha(t).replace(Xe,"")),e,"")}}function Mi(e){return function(){var t=arguments;switch(t.length){case 0:return new e;case 1:return new e(t[0]);case 2:return new e(t[0],t[1]);case 3:return new e(t[0],t[1],t[2]);case 4:return new e(t[0],t[1],t[2],t[3]);case 5:return new e(t[0],t[1],t[2],t[3],t[4]);case 6:return new e(t[0],t[1],t[2],t[3],t[4],t[5]);case 7:return new e(t[0],t[1],t[2],t[3],t[4],t[5],t[6])}var r=$r(e.prototype),n=e.apply(r,t);return Zo(n)?n:r}}function Di(e){return function(t,n,i){var s=Oe(t);if(!Bo(t)){var o=as(n,3);t=Ra(t),n=function(e){return o(s[e],e,s)}}var a=e(t,n,i);return a>-1?s[o?t[a]:a]:r}}function ki(e){return ts((function(t){var i=t.length,s=i,o=qr.prototype.thru;for(e&&t.reverse();s--;){var a=t[s];if("function"!=typeof a)throw new Ce(n);if(o&&!c&&"wrapper"==ss(a))var c=new qr([],!0)}for(s=c?s:i;++s<i;){var h=ss(a=t[s]),u="wrapper"==h?is(a):r;c=u&&_s(u[0])&&424==u[1]&&!u[4].length&&1==u[9]?c[ss(u[0])].apply(c,u[3]):1==a.length&&_s(a)?c[h]():c.thru(a)}return function(){var e=arguments,r=e[0];if(c&&1==e.length&&Ko(r))return c.plant(r).value();for(var n=0,s=i?t[n].apply(this,e):r;++n<i;)s=t[n].call(this,s);return s}}))}function $i(e,t,n,i,s,o,a,c,u,l){var f=t&h,p=1&t,d=2&t,g=24&t,y=512&t,v=d?r:Mi(e);return function h(){for(var m=arguments.length,w=se(m),_=m;_--;)w[_]=arguments[_];if(g)var b=os(h),E=function(e,t){for(var r=e.length,n=0;r--;)e[r]===t&&++n;return n}(w,b);if(i&&(w=Oi(w,i,s,g)),o&&(w=Ni(w,o,a,g)),m-=E,g&&m<l){var I=cr(w,b);return Fi(e,t,$i,h.placeholder,n,w,I,c,u,l-m)}var S=p?n:this,P=d?S[e]:e;return m=w.length,c?w=function(e,t){for(var n=e.length,i=vr(t.length,n),s=Ai(e);i--;){var o=t[i];e[i]=vs(o,n)?s[o]:r}return e}(w,c):y&&m>1&&w.reverse(),f&&u<m&&(w.length=u),this&&this!==pt&&this instanceof h&&(P=v||Mi(P)),P.apply(S,w)}}function zi(e,t){return function(r,n){return function(e,t,r,n){return wn(e,(function(e,i,s){t(n,r(e),i,s)})),n}(r,e,t(n),{})}}function qi(e,t){return function(n,i){var s;if(n===r&&i===r)return t;if(n!==r&&(s=n),i!==r){if(s===r)return i;"string"==typeof n||"string"==typeof i?(n=ci(n),i=ci(i)):(n=ai(n),i=ai(i)),s=e(n,i)}return s}}function Hi(e){return ts((function(t){return t=Lt(t,Jt(as())),Yn((function(r){var n=this;return e(t,(function(e){return Pt(e,n,r)}))}))}))}function Ki(e,t){var n=(t=t===r?" ":ci(t)).length;if(n<2)return n?Gn(t,e):t;var i=Gn(t,dt(e/ur(t)));return sr(t)?_i(lr(i),0,e).join(""):i.slice(0,e)}function Vi(e){return function(t,n,i){return i&&"number"!=typeof i&&ms(t,n,i)&&(n=i=r),t=fa(t),n===r?(n=t,t=0):n=fa(n),function(e,t,r,n){for(var i=-1,s=yr(dt((t-e)/(r||1)),0),o=se(s);s--;)o[n?s:++i]=e,e+=r;return o}(t,n,i=i===r?t<n?1:-1:fa(i),e)}}function Bi(e){return function(t,r){return"string"==typeof t&&"string"==typeof r||(t=ga(t),r=ga(r)),e(t,r)}}function Fi(e,t,n,i,s,o,h,u,l,f){var p=8&t;t|=p?a:c,4&(t&=~(p?c:a))||(t&=-4);var d=[e,t,s,p?o:r,p?h:r,p?r:o,p?r:h,u,l,f],g=n.apply(r,d);return _s(e)&&As(g,d),g.placeholder=i,xs(g,e,t)}function Wi(e){var t=Pe[e];return function(e,r){if(e=ga(e),(r=null==r?0:vr(pa(r),292))&&kt(e)){var n=(va(e)+"e").split("e");return+((n=(va(t(n[0]+"e"+(+n[1]+r)))+"e").split("e"))[0]+"e"+(+n[1]-r))}return t(e)}}var Gi=Pr&&1/hr(new Pr([,-0]))[1]==l?function(e){return new Pr(e)}:ac;function Yi(e){return function(t){var r=ps(t);return r==I?or(t):r==A?function(e){var t=-1,r=Array(e.size);return e.forEach((function(e){r[++t]=[e,e]})),r}(t):function(e,t){return Lt(t,(function(t){return[t,e[t]]}))}(t,e(t))}}function Qi(e,t,i,l,f,p,d,g){var y=2&t;if(!y&&"function"!=typeof e)throw new Ce(n);var v=l?l.length:0;if(v||(t&=-97,l=f=r),d=d===r?d:yr(pa(d),0),g=g===r?g:pa(g),v-=f?f.length:0,t&c){var m=l,w=f;l=f=r}var _=y?r:is(e),b=[e,t,i,l,f,m,w,p,d,g];if(_&&function(e,t){var r=e[1],n=t[1],i=r|n,o=i<131,a=n==h&&8==r||n==h&&r==u&&e[7].length<=t[8]||384==n&&t[7].length<=t[8]&&8==r;if(!o&&!a)return e;1&n&&(e[2]=t[2],i|=1&r?0:4);var c=t[3];if(c){var l=e[3];e[3]=l?Oi(l,c,t[4]):c,e[4]=l?cr(e[3],s):t[4]}c=t[5],c&&(l=e[5],e[5]=l?Ni(l,c,t[6]):c,e[6]=l?cr(e[5],s):t[6]),c=t[7],c&&(e[7]=c),n&h&&(e[8]=null==e[8]?t[8]:vr(e[8],t[8])),null==e[9]&&(e[9]=t[9]),e[0]=t[0],e[1]=i}(b,_),e=b[0],t=b[1],i=b[2],l=b[3],f=b[4],!(g=b[9]=b[9]===r?y?0:e.length:yr(b[9]-v,0))&&24&t&&(t&=-25),t&&1!=t)E=8==t||t==o?function(e,t,n){var i=Mi(e);return function s(){for(var o=arguments.length,a=se(o),c=o,h=os(s);c--;)a[c]=arguments[c];var u=o<3&&a[0]!==h&&a[o-1]!==h?[]:cr(a,h);return(o-=u.length)<n?Fi(e,t,$i,s.placeholder,r,a,u,r,r,n-o):Pt(this&&this!==pt&&this instanceof s?i:e,this,a)}}(e,t,g):t!=a&&33!=t||f.length?$i.apply(r,b):function(e,t,r,n){var i=1&t,s=Mi(e);return function t(){for(var o=-1,a=arguments.length,c=-1,h=n.length,u=se(h+a),l=this&&this!==pt&&this instanceof t?s:e;++c<h;)u[c]=n[c];for(;a--;)u[c++]=arguments[++o];return Pt(l,i?r:this,u)}}(e,t,i,l);else var E=function(e,t,r){var n=1&t,i=Mi(e);return function t(){return(this&&this!==pt&&this instanceof t?i:e).apply(n?r:this,arguments)}}(e,t,i);return xs((_?Zn:As)(E,b),e,t)}function Ji(e,t,n,i){return e===r||$o(e,Te[n])&&!je.call(i,n)?t:e}function Xi(e,t,n,i,s,o){return Zo(e)&&Zo(t)&&(o.set(t,e),qn(e,t,r,Xi,o),o.delete(t)),e}function Zi(e){return na(e)?r:e}function es(e,t,n,i,s,o){var a=1&n,c=e.length,h=t.length;if(c!=h&&!(a&&h>c))return!1;var u=o.get(e),l=o.get(t);if(u&&l)return u==t&&l==e;var f=-1,p=!0,d=2&n?new Fr:r;for(o.set(e,t),o.set(t,e);++f<c;){var g=e[f],y=t[f];if(i)var v=a?i(y,g,f,t,e,o):i(g,y,f,e,t,o);if(v!==r){if(v)continue;p=!1;break}if(d){if(!Dt(t,(function(e,t){if(!Zt(d,t)&&(g===e||s(g,e,n,i,o)))return d.push(t)}))){p=!1;break}}else if(g!==y&&!s(g,y,n,i,o)){p=!1;break}}return o.delete(e),o.delete(t),p}function ts(e){return Rs(Ps(e,r,Ks),e+"")}function rs(e){return In(e,Ra,ls)}function ns(e){return In(e,xa,fs)}var is=Ar?function(e){return Ar.get(e)}:ac;function ss(e){for(var t=e.name+"",r=Cr[t],n=je.call(Cr,t)?r.length:0;n--;){var i=r[n],s=i.func;if(null==s||s==e)return i.name}return t}function os(e){return(je.call(kr,"placeholder")?kr:e).placeholder}function as(){var e=kr.iteratee||nc;return e=e===nc?Un:e,arguments.length?e(arguments[0],arguments[1]):e}function cs(e,t){var r=e.__data__;return function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}(t)?r["string"==typeof t?"string":"hash"]:r.map}function hs(e){for(var t=Ra(e),r=t.length;r--;){var n=t[r],i=e[n];t[r]=[n,i,Is(i)]}return t}function us(e,t){var n=function(e,t){return null==e?r:e[t]}(e,t);return Ln(n)?n:r}var ls=vt?function(e){return null==e?[]:(e=Oe(e),Rt(vt(e),(function(t){return Ge.call(e,t)})))}:dc,fs=vt?function(e){for(var t=[];e;)Ut(t,ls(e)),e=Fe(e);return t}:dc,ps=Sn;function ds(e,t,r){for(var n=-1,i=(t=mi(t,e)).length,s=!1;++n<i;){var o=js(t[n]);if(!(s=null!=e&&r(e,o)))break;e=e[o]}return s||++n!=i?s:!!(i=null==e?0:e.length)&&Xo(i)&&vs(o,i)&&(Ko(e)||Ho(e))}function gs(e){return"function"!=typeof e.constructor||Es(e)?{}:$r(Fe(e))}function ys(e){return Ko(e)||Ho(e)||!!(Qe&&e&&e[Qe])}function vs(e,t){var r=typeof e;return!!(t=t??f)&&("number"==r||"symbol"!=r&&me.test(e))&&e>-1&&e%1==0&&e<t}function ms(e,t,r){if(!Zo(r))return!1;var n=typeof t;return!!("number"==n?Bo(r)&&vs(t,r.length):"string"==n&&t in r)&&$o(r[t],e)}function ws(e,t){if(Ko(e))return!1;var r=typeof e;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=e&&!aa(e))||(ee.test(e)||!Z.test(e)||null!=t&&e in Oe(t))}function _s(e){var t=ss(e),r=kr[t];if("function"!=typeof r||!(t in Hr.prototype))return!1;if(e===r)return!0;var n=is(r);return!!n&&e===n[0]}(Er&&ps(new Er(new ArrayBuffer(1)))!=L||Ir&&ps(new Ir)!=I||Sr&&ps(Sr.resolve())!=O||Pr&&ps(new Pr)!=A||Or&&ps(new Or)!=x)&&(ps=function(e){var t=Sn(e),n=t==P?e.constructor:r,i=n?Ms(n):"";if(i)switch(i){case Rr:return L;case xr:return I;case Tr:return O;case Lr:return A;case Ur:return x}return t});var bs=Le?Qo:gc;function Es(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||Te)}function Is(e){return e==e&&!Zo(e)}function Ss(e,t){return function(n){return null!=n&&(n[e]===t&&(t!==r||e in Oe(n)))}}function Ps(e,t,n){return t=yr(t===r?e.length-1:t,0),function(){for(var r=arguments,i=-1,s=yr(r.length-t,0),o=se(s);++i<s;)o[i]=r[t+i];i=-1;for(var a=se(t+1);++i<t;)a[i]=r[i];return a[t]=n(o),Pt(e,this,a)}}function Os(e,t){return t.length<2?e:En(e,ri(t,0,-1))}function Ns(e,t){if(("constructor"!==t||"function"!=typeof e[t])&&"__proto__"!=t)return e[t]}var As=Ts(Zn),Cs=ft||function(e,t){return pt.setTimeout(e,t)},Rs=Ts(ei);function xs(e,t,r){var n=t+"";return Rs(e,function(e,t){var r=t.length;if(!r)return e;var n=r-1;return t[n]=(r>1?"& ":"")+t[n],t=t.join(r>2?", ":" "),e.replace(oe,"{\n/* [wrapped with "+t+"] */\n")}(n,function(e,t){return Nt(g,(function(r){var n="_."+r[0];t&r[1]&&!xt(e,n)&&e.push(n)})),e.sort()}(function(e){var t=e.match(ae);return t?t[1].split(ce):[]}(n),r)))}function Ts(e){var t=0,n=0;return function(){var i=mr(),s=16-(i-n);if(n=i,s>0){if(++t>=800)return arguments[0]}else t=0;return e.apply(r,arguments)}}function Ls(e,t){var n=-1,i=e.length,s=i-1;for(t=t===r?i:t;++n<t;){var o=Wn(n,s),a=e[o];e[o]=e[n],e[n]=a}return e.length=t,e}var Us=function(e){var t=Lo(e,(function(e){return 500===r.size&&r.clear(),e})),r=t.cache;return t}((function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace(te,(function(e,r,n,i){t.push(n?i.replace(le,"$1"):r||e)})),t}));function js(e){if("string"==typeof e||aa(e))return e;var t=e+"";return"0"==t&&1/e==-l?"-0":t}function Ms(e){if(null!=e){try{return Ue.call(e)}catch{}try{return e+""}catch{}}return""}function Ds(e){if(e instanceof Hr)return e.clone();var t=new qr(e.__wrapped__,e.__chain__);return t.__actions__=Ai(e.__actions__),t.__index__=e.__index__,t.__values__=e.__values__,t}var ks=Yn((function(e,t){return Fo(e)?un(e,yn(t,1,Fo,!0)):[]})),$s=Yn((function(e,t){var n=Gs(t);return Fo(n)&&(n=r),Fo(e)?un(e,yn(t,1,Fo,!0),as(n,2)):[]})),zs=Yn((function(e,t){var n=Gs(t);return Fo(n)&&(n=r),Fo(e)?un(e,yn(t,1,Fo,!0),r,n):[]}));function qs(e,t,r){var n=null==e?0:e.length;if(!n)return-1;var i=null==r?0:pa(r);return i<0&&(i=yr(n+i,0)),zt(e,as(t,3),i)}function Hs(e,t,n){var i=null==e?0:e.length;if(!i)return-1;var s=i-1;return n!==r&&(s=pa(n),s=n<0?yr(i+s,0):vr(s,i-1)),zt(e,as(t,3),s,!0)}function Ks(e){return(null==e?0:e.length)?yn(e,1):[]}function Vs(e){return e&&e.length?e[0]:r}var Bs=Yn((function(e){var t=Lt(e,yi);return t.length&&t[0]===e[0]?An(t):[]})),Fs=Yn((function(e){var t=Gs(e),n=Lt(e,yi);return t===Gs(n)?t=r:n.pop(),n.length&&n[0]===e[0]?An(n,as(t,2)):[]})),Ws=Yn((function(e){var t=Gs(e),n=Lt(e,yi);return(t="function"==typeof t?t:r)&&n.pop(),n.length&&n[0]===e[0]?An(n,r,t):[]}));function Gs(e){var t=null==e?0:e.length;return t?e[t-1]:r}var Ys=Yn(Qs);function Qs(e,t){return e&&e.length&&t&&t.length?Bn(e,t):e}var Js=ts((function(e,t){var r=null==e?0:e.length,n=sn(e,t);return Fn(e,Lt(t,(function(e){return vs(e,r)?+e:e})).sort(Pi)),n}));function Xs(e){return null==e?e:br.call(e)}var Zs=Yn((function(e){return hi(yn(e,1,Fo,!0))})),eo=Yn((function(e){var t=Gs(e);return Fo(t)&&(t=r),hi(yn(e,1,Fo,!0),as(t,2))})),to=Yn((function(e){var t=Gs(e);return t="function"==typeof t?t:r,hi(yn(e,1,Fo,!0),r,t)}));function ro(e){if(!e||!e.length)return[];var t=0;return e=Rt(e,(function(e){if(Fo(e))return t=yr(e.length,t),!0})),Yt(t,(function(t){return Lt(e,Bt(t))}))}function no(e,t){if(!e||!e.length)return[];var n=ro(e);return null==t?n:Lt(n,(function(e){return Pt(t,r,e)}))}var io=Yn((function(e,t){return Fo(e)?un(e,t):[]})),so=Yn((function(e){return di(Rt(e,Fo))})),oo=Yn((function(e){var t=Gs(e);return Fo(t)&&(t=r),di(Rt(e,Fo),as(t,2))})),ao=Yn((function(e){var t=Gs(e);return t="function"==typeof t?t:r,di(Rt(e,Fo),r,t)})),co=Yn(ro);var ho=Yn((function(e){var t=e.length,n=t>1?e[t-1]:r;return n="function"==typeof n?(e.pop(),n):r,no(e,n)}));function uo(e){var t=kr(e);return t.__chain__=!0,t}function lo(e,t){return t(e)}var fo=ts((function(e){var t=e.length,n=t?e[0]:0,i=this.__wrapped__,s=function(t){return sn(t,e)};return!(t>1||this.__actions__.length)&&i instanceof Hr&&vs(n)?((i=i.slice(n,+n+(t?1:0))).__actions__.push({func:lo,args:[s],thisArg:r}),new qr(i,this.__chain__).thru((function(e){return t&&!e.length&&e.push(r),e}))):this.thru(s)}));var po=Ri((function(e,t,r){je.call(e,r)?++e[r]:nn(e,r,1)}));var go=Di(qs),yo=Di(Hs);function vo(e,t){return(Ko(e)?Nt:ln)(e,as(t,3))}function mo(e,t){return(Ko(e)?At:fn)(e,as(t,3))}var wo=Ri((function(e,t,r){je.call(e,r)?e[r].push(t):nn(e,r,[t])}));var _o=Yn((function(e,t,r){var n=-1,i="function"==typeof t,s=Bo(e)?se(e.length):[];return ln(e,(function(e){s[++n]=i?Pt(t,e,r):Cn(e,t,r)})),s})),bo=Ri((function(e,t,r){nn(e,r,t)}));function Eo(e,t){return(Ko(e)?Lt:kn)(e,as(t,3))}var Io=Ri((function(e,t,r){e[r?0:1].push(t)}),(function(){return[[],[]]}));var So=Yn((function(e,t){if(null==e)return[];var r=t.length;return r>1&&ms(e,t[0],t[1])?t=[]:r>2&&ms(t[0],t[1],t[2])&&(t=[t[0]]),Kn(e,yn(t,1),[])})),Po=lt||function(){return pt.Date.now()};function Oo(e,t,n){return t=n?r:t,t=e&&null==t?e.length:t,Qi(e,h,r,r,r,r,t)}function No(e,t){var i;if("function"!=typeof t)throw new Ce(n);return e=pa(e),function(){return--e>0&&(i=t.apply(this,arguments)),e<=1&&(t=r),i}}var Ao=Yn((function(e,t,r){var n=1;if(r.length){var i=cr(r,os(Ao));n|=a}return Qi(e,n,t,r,i)})),Co=Yn((function(e,t,r){var n=3;if(r.length){var i=cr(r,os(Co));n|=a}return Qi(t,n,e,r,i)}));function Ro(e,t,i){var s,o,a,c,h,u,l=0,f=!1,p=!1,d=!0;if("function"!=typeof e)throw new Ce(n);function g(t){var n=s,i=o;return s=o=r,l=t,c=e.apply(i,n)}function y(e){var n=e-u;return u===r||n>=t||n<0||p&&e-l>=a}function v(){var e=Po();if(y(e))return m(e);h=Cs(v,function(e){var r=t-(e-u);return p?vr(r,a-(e-l)):r}(e))}function m(e){return h=r,d&&s?g(e):(s=o=r,c)}function w(){var e=Po(),n=y(e);if(s=arguments,o=this,u=e,n){if(h===r)return function(e){return l=e,h=Cs(v,t),f?g(e):c}(u);if(p)return bi(h),h=Cs(v,t),g(u)}return h===r&&(h=Cs(v,t)),c}return t=ga(t)||0,Zo(i)&&(f=!!i.leading,a=(p="maxWait"in i)?yr(ga(i.maxWait)||0,t):a,d="trailing"in i?!!i.trailing:d),w.cancel=function(){h!==r&&bi(h),l=0,s=u=o=h=r},w.flush=function(){return h===r?c:m(Po())},w}var xo=Yn((function(e,t){return hn(e,1,t)})),To=Yn((function(e,t,r){return hn(e,ga(t)||0,r)}));function Lo(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new Ce(n);var r=function(){var n=arguments,i=t?t.apply(this,n):n[0],s=r.cache;if(s.has(i))return s.get(i);var o=e.apply(this,n);return r.cache=s.set(i,o)||s,o};return r.cache=new(Lo.Cache||Br),r}function Uo(e){if("function"!=typeof e)throw new Ce(n);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}Lo.Cache=Br;var jo=wi((function(e,t){var r=(t=1==t.length&&Ko(t[0])?Lt(t[0],Jt(as())):Lt(yn(t,1),Jt(as()))).length;return Yn((function(n){for(var i=-1,s=vr(n.length,r);++i<s;)n[i]=t[i].call(this,n[i]);return Pt(e,this,n)}))})),Mo=Yn((function(e,t){var n=cr(t,os(Mo));return Qi(e,a,r,t,n)})),Do=Yn((function(e,t){var n=cr(t,os(Do));return Qi(e,c,r,t,n)})),ko=ts((function(e,t){return Qi(e,u,r,r,r,t)}));function $o(e,t){return e===t||e!=e&&t!=t}var zo=Bi(Pn),qo=Bi((function(e,t){return e>=t})),Ho=Rn(function(){return arguments}())?Rn:function(e){return ea(e)&&je.call(e,"callee")&&!Ge.call(e,"callee")},Ko=se.isArray,Vo=wt?Jt(wt):function(e){return ea(e)&&Sn(e)==T};function Bo(e){return null!=e&&Xo(e.length)&&!Qo(e)}function Fo(e){return ea(e)&&Bo(e)}var Wo=mt||gc,Go=_t?Jt(_t):function(e){return ea(e)&&Sn(e)==w};function Yo(e){if(!ea(e))return!1;var t=Sn(e);return t==_||"[object DOMException]"==t||"string"==typeof e.message&&"string"==typeof e.name&&!na(e)}function Qo(e){if(!Zo(e))return!1;var t=Sn(e);return t==b||t==E||"[object AsyncFunction]"==t||"[object Proxy]"==t}function Jo(e){return"number"==typeof e&&e==pa(e)}function Xo(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=f}function Zo(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function ea(e){return null!=e&&"object"==typeof e}var ta=bt?Jt(bt):function(e){return ea(e)&&ps(e)==I};function ra(e){return"number"==typeof e||ea(e)&&Sn(e)==S}function na(e){if(!ea(e)||Sn(e)!=P)return!1;var t=Fe(e);if(null===t)return!0;var r=je.call(t,"constructor")&&t.constructor;return"function"==typeof r&&r instanceof r&&Ue.call(r)==$e}var ia=Et?Jt(Et):function(e){return ea(e)&&Sn(e)==N};var sa=It?Jt(It):function(e){return ea(e)&&ps(e)==A};function oa(e){return"string"==typeof e||!Ko(e)&&ea(e)&&Sn(e)==C}function aa(e){return"symbol"==typeof e||ea(e)&&Sn(e)==R}var ca=St?Jt(St):function(e){return ea(e)&&Xo(e.length)&&!!ot[Sn(e)]};var ha=Bi(Dn),ua=Bi((function(e,t){return e<=t}));function la(e){if(!e)return[];if(Bo(e))return oa(e)?lr(e):Ai(e);if(Je&&e[Je])return function(e){for(var t,r=[];!(t=e.next()).done;)r.push(t.value);return r}(e[Je]());var t=ps(e);return(t==I?or:t==A?hr:$a)(e)}function fa(e){return e?(e=ga(e))===l||e===-l?17976931348623157e292*(e<0?-1:1):e==e?e:0:0===e?e:0}function pa(e){var t=fa(e),r=t%1;return t==t?r?t-r:t:0}function da(e){return e?on(pa(e),0,d):0}function ga(e){if("number"==typeof e)return e;if(aa(e))return p;if(Zo(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=Zo(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=Qt(e);var r=ge.test(e);return r||ve.test(e)?ut(e.slice(2),r?2:8):de.test(e)?p:+e}function ya(e){return Ci(e,xa(e))}function va(e){return null==e?"":ci(e)}var ma=xi((function(e,t){if(Es(t)||Bo(t))Ci(t,Ra(t),e);else for(var r in t)je.call(t,r)&&Zr(e,r,t[r])})),wa=xi((function(e,t){Ci(t,xa(t),e)})),_a=xi((function(e,t,r,n){Ci(t,xa(t),e,n)})),ba=xi((function(e,t,r,n){Ci(t,Ra(t),e,n)})),Ea=ts(sn);var Ia=Yn((function(e,t){e=Oe(e);var n=-1,i=t.length,s=i>2?t[2]:r;for(s&&ms(t[0],t[1],s)&&(i=1);++n<i;)for(var o=t[n],a=xa(o),c=-1,h=a.length;++c<h;){var u=a[c],l=e[u];(l===r||$o(l,Te[u])&&!je.call(e,u))&&(e[u]=o[u])}return e})),Sa=Yn((function(e){return e.push(r,Xi),Pt(La,r,e)}));function Pa(e,t,n){var i=null==e?r:En(e,t);return i===r?n:i}function Oa(e,t){return null!=e&&ds(e,t,Nn)}var Na=zi((function(e,t,r){null!=t&&"function"!=typeof t.toString&&(t=ke.call(t)),e[t]=r}),Za(rc)),Aa=zi((function(e,t,r){null!=t&&"function"!=typeof t.toString&&(t=ke.call(t)),je.call(e,t)?e[t].push(r):e[t]=[r]}),as),Ca=Yn(Cn);function Ra(e){return Bo(e)?Gr(e):jn(e)}function xa(e){return Bo(e)?Gr(e,!0):Mn(e)}var Ta=xi((function(e,t,r){qn(e,t,r)})),La=xi((function(e,t,r,n){qn(e,t,r,n)})),Ua=ts((function(e,t){var r={};if(null==e)return r;var n=!1;t=Lt(t,(function(t){return t=mi(t,e),n||(n=t.length>1),t})),Ci(e,ns(e),r),n&&(r=an(r,7,Zi));for(var i=t.length;i--;)ui(r,t[i]);return r}));var ja=ts((function(e,t){return null==e?{}:function(e,t){return Vn(e,t,(function(t,r){return Oa(e,r)}))}(e,t)}));function Ma(e,t){if(null==e)return{};var r=Lt(ns(e),(function(e){return[e]}));return t=as(t),Vn(e,r,(function(e,r){return t(e,r[0])}))}var Da=Yi(Ra),ka=Yi(xa);function $a(e){return null==e?[]:Xt(e,Ra(e))}var za=ji((function(e,t,r){return t=t.toLowerCase(),e+(r?qa(t):t)}));function qa(e){return Ya(va(e).toLowerCase())}function Ha(e){return(e=va(e))&&e.replace(we,rr).replace(Ze,"")}var Ka=ji((function(e,t,r){return e+(r?"-":"")+t.toLowerCase()})),Va=ji((function(e,t,r){return e+(r?" ":"")+t.toLowerCase()})),Ba=Ui("toLowerCase");var Fa=ji((function(e,t,r){return e+(r?"_":"")+t.toLowerCase()}));var Wa=ji((function(e,t,r){return e+(r?" ":"")+Ya(t)}));var Ga=ji((function(e,t,r){return e+(r?" ":"")+t.toUpperCase()})),Ya=Ui("toUpperCase");function Qa(e,t,n){return e=va(e),(t=n?r:t)===r?function(e){return nt.test(e)}(e)?function(e){return e.match(tt)||[]}(e):function(e){return e.match(he)||[]}(e):e.match(t)||[]}var Ja=Yn((function(e,t){try{return Pt(e,r,t)}catch(e){return Yo(e)?e:new Ie(e)}})),Xa=ts((function(e,t){return Nt(t,(function(t){t=js(t),nn(e,t,Ao(e[t],e))})),e}));function Za(e){return function(){return e}}var ec=ki(),tc=ki(!0);function rc(e){return e}function nc(e){return Un("function"==typeof e?e:an(e,1))}var ic=Yn((function(e,t){return function(r){return Cn(r,e,t)}})),sc=Yn((function(e,t){return function(r){return Cn(e,r,t)}}));function oc(e,t,r){var n=Ra(t),i=bn(t,n);null==r&&(!Zo(t)||!i.length&&n.length)&&(r=t,t=e,e=this,i=bn(t,Ra(t)));var s=!(Zo(r)&&"chain"in r&&!r.chain),o=Qo(e);return Nt(i,(function(r){var n=t[r];e[r]=n,o&&(e.prototype[r]=function(){var t=this.__chain__;if(s||t){var r=e(this.__wrapped__);return(r.__actions__=Ai(this.__actions__)).push({func:n,args:arguments,thisArg:e}),r.__chain__=t,r}return n.apply(e,Ut([this.value()],arguments))})})),e}function ac(){}var cc=Hi(Lt),hc=Hi(Ct),uc=Hi(Dt);function lc(e){return ws(e)?Bt(js(e)):function(e){return function(t){return En(t,e)}}(e)}var fc=Vi(),pc=Vi(!0);function dc(){return[]}function gc(){return!1}var yc=qi((function(e,t){return e+t}),0),vc=Wi("ceil"),mc=qi((function(e,t){return e/t}),1),wc=Wi("floor");var _c=qi((function(e,t){return e*t}),1),bc=Wi("round"),Ec=qi((function(e,t){return e-t}),0);return kr.after=function(e,t){if("function"!=typeof t)throw new Ce(n);return e=pa(e),function(){if(--e<1)return t.apply(this,arguments)}},kr.ary=Oo,kr.assign=ma,kr.assignIn=wa,kr.assignInWith=_a,kr.assignWith=ba,kr.at=Ea,kr.before=No,kr.bind=Ao,kr.bindAll=Xa,kr.bindKey=Co,kr.castArray=function(){if(!arguments.length)return[];var e=arguments[0];return Ko(e)?e:[e]},kr.chain=uo,kr.chunk=function(e,t,n){t=(n?ms(e,t,n):t===r)?1:yr(pa(t),0);var i=null==e?0:e.length;if(!i||t<1)return[];for(var s=0,o=0,a=se(dt(i/t));s<i;)a[o++]=ri(e,s,s+=t);return a},kr.compact=function(e){for(var t=-1,r=null==e?0:e.length,n=0,i=[];++t<r;){var s=e[t];s&&(i[n++]=s)}return i},kr.concat=function(){var e=arguments.length;if(!e)return[];for(var t=se(e-1),r=arguments[0],n=e;n--;)t[n-1]=arguments[n];return Ut(Ko(r)?Ai(r):[r],yn(t,1))},kr.cond=function(e){var t=null==e?0:e.length,r=as();return e=t?Lt(e,(function(e){if("function"!=typeof e[1])throw new Ce(n);return[r(e[0]),e[1]]})):[],Yn((function(r){for(var n=-1;++n<t;){var i=e[n];if(Pt(i[0],this,r))return Pt(i[1],this,r)}}))},kr.conforms=function(e){return function(e){var t=Ra(e);return function(r){return cn(r,e,t)}}(an(e,1))},kr.constant=Za,kr.countBy=po,kr.create=function(e,t){var r=$r(e);return null==t?r:rn(r,t)},kr.curry=function e(t,n,i){var s=Qi(t,8,r,r,r,r,r,n=i?r:n);return s.placeholder=e.placeholder,s},kr.curryRight=function e(t,n,i){var s=Qi(t,o,r,r,r,r,r,n=i?r:n);return s.placeholder=e.placeholder,s},kr.debounce=Ro,kr.defaults=Ia,kr.defaultsDeep=Sa,kr.defer=xo,kr.delay=To,kr.difference=ks,kr.differenceBy=$s,kr.differenceWith=zs,kr.drop=function(e,t,n){var i=null==e?0:e.length;return i?ri(e,(t=n||t===r?1:pa(t))<0?0:t,i):[]},kr.dropRight=function(e,t,n){var i=null==e?0:e.length;return i?ri(e,0,(t=i-(t=n||t===r?1:pa(t)))<0?0:t):[]},kr.dropRightWhile=function(e,t){return e&&e.length?fi(e,as(t,3),!0,!0):[]},kr.dropWhile=function(e,t){return e&&e.length?fi(e,as(t,3),!0):[]},kr.fill=function(e,t,n,i){var s=null==e?0:e.length;return s?(n&&"number"!=typeof n&&ms(e,t,n)&&(n=0,i=s),function(e,t,n,i){var s=e.length;for((n=pa(n))<0&&(n=-n>s?0:s+n),(i=i===r||i>s?s:pa(i))<0&&(i+=s),i=n>i?0:da(i);n<i;)e[n++]=t;return e}(e,t,n,i)):[]},kr.filter=function(e,t){return(Ko(e)?Rt:gn)(e,as(t,3))},kr.flatMap=function(e,t){return yn(Eo(e,t),1)},kr.flatMapDeep=function(e,t){return yn(Eo(e,t),l)},kr.flatMapDepth=function(e,t,n){return n=n===r?1:pa(n),yn(Eo(e,t),n)},kr.flatten=Ks,kr.flattenDeep=function(e){return(null==e?0:e.length)?yn(e,l):[]},kr.flattenDepth=function(e,t){return(null==e?0:e.length)?yn(e,t=t===r?1:pa(t)):[]},kr.flip=function(e){return Qi(e,512)},kr.flow=ec,kr.flowRight=tc,kr.fromPairs=function(e){for(var t=-1,r=null==e?0:e.length,n={};++t<r;){var i=e[t];n[i[0]]=i[1]}return n},kr.functions=function(e){return null==e?[]:bn(e,Ra(e))},kr.functionsIn=function(e){return null==e?[]:bn(e,xa(e))},kr.groupBy=wo,kr.initial=function(e){return(null==e?0:e.length)?ri(e,0,-1):[]},kr.intersection=Bs,kr.intersectionBy=Fs,kr.intersectionWith=Ws,kr.invert=Na,kr.invertBy=Aa,kr.invokeMap=_o,kr.iteratee=nc,kr.keyBy=bo,kr.keys=Ra,kr.keysIn=xa,kr.map=Eo,kr.mapKeys=function(e,t){var r={};return t=as(t,3),wn(e,(function(e,n,i){nn(r,t(e,n,i),e)})),r},kr.mapValues=function(e,t){var r={};return t=as(t,3),wn(e,(function(e,n,i){nn(r,n,t(e,n,i))})),r},kr.matches=function(e){return $n(an(e,1))},kr.matchesProperty=function(e,t){return zn(e,an(t,1))},kr.memoize=Lo,kr.merge=Ta,kr.mergeWith=La,kr.method=ic,kr.methodOf=sc,kr.mixin=oc,kr.negate=Uo,kr.nthArg=function(e){return e=pa(e),Yn((function(t){return Hn(t,e)}))},kr.omit=Ua,kr.omitBy=function(e,t){return Ma(e,Uo(as(t)))},kr.once=function(e){return No(2,e)},kr.orderBy=function(e,t,n,i){return null==e?[]:(Ko(t)||(t=null==t?[]:[t]),Ko(n=i?r:n)||(n=null==n?[]:[n]),Kn(e,t,n))},kr.over=cc,kr.overArgs=jo,kr.overEvery=hc,kr.overSome=uc,kr.partial=Mo,kr.partialRight=Do,kr.partition=Io,kr.pick=ja,kr.pickBy=Ma,kr.property=lc,kr.propertyOf=function(e){return function(t){return null==e?r:En(e,t)}},kr.pull=Ys,kr.pullAll=Qs,kr.pullAllBy=function(e,t,r){return e&&e.length&&t&&t.length?Bn(e,t,as(r,2)):e},kr.pullAllWith=function(e,t,n){return e&&e.length&&t&&t.length?Bn(e,t,r,n):e},kr.pullAt=Js,kr.range=fc,kr.rangeRight=pc,kr.rearg=ko,kr.reject=function(e,t){return(Ko(e)?Rt:gn)(e,Uo(as(t,3)))},kr.remove=function(e,t){var r=[];if(!e||!e.length)return r;var n=-1,i=[],s=e.length;for(t=as(t,3);++n<s;){var o=e[n];t(o,n,e)&&(r.push(o),i.push(n))}return Fn(e,i),r},kr.rest=function(e,t){if("function"!=typeof e)throw new Ce(n);return Yn(e,t=t===r?t:pa(t))},kr.reverse=Xs,kr.sampleSize=function(e,t,n){return t=(n?ms(e,t,n):t===r)?1:pa(t),(Ko(e)?Qr:Jn)(e,t)},kr.set=function(e,t,r){return null==e?e:Xn(e,t,r)},kr.setWith=function(e,t,n,i){return i="function"==typeof i?i:r,null==e?e:Xn(e,t,n,i)},kr.shuffle=function(e){return(Ko(e)?Jr:ti)(e)},kr.slice=function(e,t,n){var i=null==e?0:e.length;return i?(n&&"number"!=typeof n&&ms(e,t,n)?(t=0,n=i):(t=null==t?0:pa(t),n=n===r?i:pa(n)),ri(e,t,n)):[]},kr.sortBy=So,kr.sortedUniq=function(e){return e&&e.length?oi(e):[]},kr.sortedUniqBy=function(e,t){return e&&e.length?oi(e,as(t,2)):[]},kr.split=function(e,t,n){return n&&"number"!=typeof n&&ms(e,t,n)&&(t=n=r),(n=n===r?d:n>>>0)?(e=va(e))&&("string"==typeof t||null!=t&&!ia(t))&&(!(t=ci(t))&&sr(e))?_i(lr(e),0,n):e.split(t,n):[]},kr.spread=function(e,t){if("function"!=typeof e)throw new Ce(n);return t=null==t?0:yr(pa(t),0),Yn((function(r){var n=r[t],i=_i(r,0,t);return n&&Ut(i,n),Pt(e,this,i)}))},kr.tail=function(e){var t=null==e?0:e.length;return t?ri(e,1,t):[]},kr.take=function(e,t,n){return e&&e.length?ri(e,0,(t=n||t===r?1:pa(t))<0?0:t):[]},kr.takeRight=function(e,t,n){var i=null==e?0:e.length;return i?ri(e,(t=i-(t=n||t===r?1:pa(t)))<0?0:t,i):[]},kr.takeRightWhile=function(e,t){return e&&e.length?fi(e,as(t,3),!1,!0):[]},kr.takeWhile=function(e,t){return e&&e.length?fi(e,as(t,3)):[]},kr.tap=function(e,t){return t(e),e},kr.throttle=function(e,t,r){var i=!0,s=!0;if("function"!=typeof e)throw new Ce(n);return Zo(r)&&(i="leading"in r?!!r.leading:i,s="trailing"in r?!!r.trailing:s),Ro(e,t,{leading:i,maxWait:t,trailing:s})},kr.thru=lo,kr.toArray=la,kr.toPairs=Da,kr.toPairsIn=ka,kr.toPath=function(e){return Ko(e)?Lt(e,js):aa(e)?[e]:Ai(Us(va(e)))},kr.toPlainObject=ya,kr.transform=function(e,t,r){var n=Ko(e),i=n||Wo(e)||ca(e);if(t=as(t,4),null==r){var s=e&&e.constructor;r=i?n?new s:[]:Zo(e)&&Qo(s)?$r(Fe(e)):{}}return(i?Nt:wn)(e,(function(e,n,i){return t(r,e,n,i)})),r},kr.unary=function(e){return Oo(e,1)},kr.union=Zs,kr.unionBy=eo,kr.unionWith=to,kr.uniq=function(e){return e&&e.length?hi(e):[]},kr.uniqBy=function(e,t){return e&&e.length?hi(e,as(t,2)):[]},kr.uniqWith=function(e,t){return t="function"==typeof t?t:r,e&&e.length?hi(e,r,t):[]},kr.unset=function(e,t){return null==e||ui(e,t)},kr.unzip=ro,kr.unzipWith=no,kr.update=function(e,t,r){return null==e?e:li(e,t,vi(r))},kr.updateWith=function(e,t,n,i){return i="function"==typeof i?i:r,null==e?e:li(e,t,vi(n),i)},kr.values=$a,kr.valuesIn=function(e){return null==e?[]:Xt(e,xa(e))},kr.without=io,kr.words=Qa,kr.wrap=function(e,t){return Mo(vi(t),e)},kr.xor=so,kr.xorBy=oo,kr.xorWith=ao,kr.zip=co,kr.zipObject=function(e,t){return gi(e||[],t||[],Zr)},kr.zipObjectDeep=function(e,t){return gi(e||[],t||[],Xn)},kr.zipWith=ho,kr.entries=Da,kr.entriesIn=ka,kr.extend=wa,kr.extendWith=_a,oc(kr,kr),kr.add=yc,kr.attempt=Ja,kr.camelCase=za,kr.capitalize=qa,kr.ceil=vc,kr.clamp=function(e,t,n){return n===r&&(n=t,t=r),n!==r&&(n=(n=ga(n))==n?n:0),t!==r&&(t=(t=ga(t))==t?t:0),on(ga(e),t,n)},kr.clone=function(e){return an(e,4)},kr.cloneDeep=function(e){return an(e,5)},kr.cloneDeepWith=function(e,t){return an(e,5,t="function"==typeof t?t:r)},kr.cloneWith=function(e,t){return an(e,4,t="function"==typeof t?t:r)},kr.conformsTo=function(e,t){return null==t||cn(e,t,Ra(t))},kr.deburr=Ha,kr.defaultTo=function(e,t){return null==e||e!=e?t:e},kr.divide=mc,kr.endsWith=function(e,t,n){e=va(e),t=ci(t);var i=e.length,s=n=n===r?i:on(pa(n),0,i);return(n-=t.length)>=0&&e.slice(n,s)==t},kr.eq=$o,kr.escape=function(e){return(e=va(e))&&Y.test(e)?e.replace(W,nr):e},kr.escapeRegExp=function(e){return(e=va(e))&&ne.test(e)?e.replace(re,"\\$&"):e},kr.every=function(e,t,n){var i=Ko(e)?Ct:pn;return n&&ms(e,t,n)&&(t=r),i(e,as(t,3))},kr.find=go,kr.findIndex=qs,kr.findKey=function(e,t){return $t(e,as(t,3),wn)},kr.findLast=yo,kr.findLastIndex=Hs,kr.findLastKey=function(e,t){return $t(e,as(t,3),_n)},kr.floor=wc,kr.forEach=vo,kr.forEachRight=mo,kr.forIn=function(e,t){return null==e?e:vn(e,as(t,3),xa)},kr.forInRight=function(e,t){return null==e?e:mn(e,as(t,3),xa)},kr.forOwn=function(e,t){return e&&wn(e,as(t,3))},kr.forOwnRight=function(e,t){return e&&_n(e,as(t,3))},kr.get=Pa,kr.gt=zo,kr.gte=qo,kr.has=function(e,t){return null!=e&&ds(e,t,On)},kr.hasIn=Oa,kr.head=Vs,kr.identity=rc,kr.includes=function(e,t,r,n){e=Bo(e)?e:$a(e),r=r&&!n?pa(r):0;var i=e.length;return r<0&&(r=yr(i+r,0)),oa(e)?r<=i&&e.indexOf(t,r)>-1:!!i&&qt(e,t,r)>-1},kr.indexOf=function(e,t,r){var n=null==e?0:e.length;if(!n)return-1;var i=null==r?0:pa(r);return i<0&&(i=yr(n+i,0)),qt(e,t,i)},kr.inRange=function(e,t,n){return t=fa(t),n===r?(n=t,t=0):n=fa(n),function(e,t,r){return e>=vr(t,r)&&e<yr(t,r)}(e=ga(e),t,n)},kr.invoke=Ca,kr.isArguments=Ho,kr.isArray=Ko,kr.isArrayBuffer=Vo,kr.isArrayLike=Bo,kr.isArrayLikeObject=Fo,kr.isBoolean=function(e){return!0===e||!1===e||ea(e)&&Sn(e)==m},kr.isBuffer=Wo,kr.isDate=Go,kr.isElement=function(e){return ea(e)&&1===e.nodeType&&!na(e)},kr.isEmpty=function(e){if(null==e)return!0;if(Bo(e)&&(Ko(e)||"string"==typeof e||"function"==typeof e.splice||Wo(e)||ca(e)||Ho(e)))return!e.length;var t=ps(e);if(t==I||t==A)return!e.size;if(Es(e))return!jn(e).length;for(var r in e)if(je.call(e,r))return!1;return!0},kr.isEqual=function(e,t){return xn(e,t)},kr.isEqualWith=function(e,t,n){var i=(n="function"==typeof n?n:r)?n(e,t):r;return i===r?xn(e,t,r,n):!!i},kr.isError=Yo,kr.isFinite=function(e){return"number"==typeof e&&kt(e)},kr.isFunction=Qo,kr.isInteger=Jo,kr.isLength=Xo,kr.isMap=ta,kr.isMatch=function(e,t){return e===t||Tn(e,t,hs(t))},kr.isMatchWith=function(e,t,n){return n="function"==typeof n?n:r,Tn(e,t,hs(t),n)},kr.isNaN=function(e){return ra(e)&&e!=+e},kr.isNative=function(e){if(bs(e))throw new Ie("Unsupported core-js use. Try https://npms.io/search?q=ponyfill.");return Ln(e)},kr.isNil=function(e){return null==e},kr.isNull=function(e){return null===e},kr.isNumber=ra,kr.isObject=Zo,kr.isObjectLike=ea,kr.isPlainObject=na,kr.isRegExp=ia,kr.isSafeInteger=function(e){return Jo(e)&&e>=-f&&e<=f},kr.isSet=sa,kr.isString=oa,kr.isSymbol=aa,kr.isTypedArray=ca,kr.isUndefined=function(e){return e===r},kr.isWeakMap=function(e){return ea(e)&&ps(e)==x},kr.isWeakSet=function(e){return ea(e)&&"[object WeakSet]"==Sn(e)},kr.join=function(e,t){return null==e?"":Ft.call(e,t)},kr.kebabCase=Ka,kr.last=Gs,kr.lastIndexOf=function(e,t,n){var i=null==e?0:e.length;if(!i)return-1;var s=i;return n!==r&&(s=(s=pa(n))<0?yr(i+s,0):vr(s,i-1)),t==t?function(e,t,r){for(var n=r+1;n--;)if(e[n]===t)return n;return n}(e,t,s):zt(e,Kt,s,!0)},kr.lowerCase=Va,kr.lowerFirst=Ba,kr.lt=ha,kr.lte=ua,kr.max=function(e){return e&&e.length?dn(e,rc,Pn):r},kr.maxBy=function(e,t){return e&&e.length?dn(e,as(t,2),Pn):r},kr.mean=function(e){return Vt(e,rc)},kr.meanBy=function(e,t){return Vt(e,as(t,2))},kr.min=function(e){return e&&e.length?dn(e,rc,Dn):r},kr.minBy=function(e,t){return e&&e.length?dn(e,as(t,2),Dn):r},kr.stubArray=dc,kr.stubFalse=gc,kr.stubObject=function(){return{}},kr.stubString=function(){return""},kr.stubTrue=function(){return!0},kr.multiply=_c,kr.nth=function(e,t){return e&&e.length?Hn(e,pa(t)):r},kr.noConflict=function(){return pt._===this&&(pt._=ze),this},kr.noop=ac,kr.now=Po,kr.pad=function(e,t,r){e=va(e);var n=(t=pa(t))?ur(e):0;if(!t||n>=t)return e;var i=(t-n)/2;return Ki(gt(i),r)+e+Ki(dt(i),r)},kr.padEnd=function(e,t,r){e=va(e);var n=(t=pa(t))?ur(e):0;return t&&n<t?e+Ki(t-n,r):e},kr.padStart=function(e,t,r){e=va(e);var n=(t=pa(t))?ur(e):0;return t&&n<t?Ki(t-n,r)+e:e},kr.parseInt=function(e,t,r){return r||null==t?t=0:t&&(t=+t),wr(va(e).replace(ie,""),t||0)},kr.random=function(e,t,n){if(n&&"boolean"!=typeof n&&ms(e,t,n)&&(t=n=r),n===r&&("boolean"==typeof t?(n=t,t=r):"boolean"==typeof e&&(n=e,e=r)),e===r&&t===r?(e=0,t=1):(e=fa(e),t===r?(t=e,e=0):t=fa(t)),e>t){var i=e;e=t,t=i}if(n||e%1||t%1){var s=_r();return vr(e+s*(t-e+ht("1e-"+((s+"").length-1))),t)}return Wn(e,t)},kr.reduce=function(e,t,r){var n=Ko(e)?jt:Wt,i=arguments.length<3;return n(e,as(t,4),r,i,ln)},kr.reduceRight=function(e,t,r){var n=Ko(e)?Mt:Wt,i=arguments.length<3;return n(e,as(t,4),r,i,fn)},kr.repeat=function(e,t,n){return t=(n?ms(e,t,n):t===r)?1:pa(t),Gn(va(e),t)},kr.replace=function(){var e=arguments,t=va(e[0]);return e.length<3?t:t.replace(e[1],e[2])},kr.result=function(e,t,n){var i=-1,s=(t=mi(t,e)).length;for(s||(s=1,e=r);++i<s;){var o=null==e?r:e[js(t[i])];o===r&&(i=s,o=n),e=Qo(o)?o.call(e):o}return e},kr.round=bc,kr.runInContext=e,kr.sample=function(e){return(Ko(e)?Yr:Qn)(e)},kr.size=function(e){if(null==e)return 0;if(Bo(e))return oa(e)?ur(e):e.length;var t=ps(e);return t==I||t==A?e.size:jn(e).length},kr.snakeCase=Fa,kr.some=function(e,t,n){var i=Ko(e)?Dt:ni;return n&&ms(e,t,n)&&(t=r),i(e,as(t,3))},kr.sortedIndex=function(e,t){return ii(e,t)},kr.sortedIndexBy=function(e,t,r){return si(e,t,as(r,2))},kr.sortedIndexOf=function(e,t){var r=null==e?0:e.length;if(r){var n=ii(e,t);if(n<r&&$o(e[n],t))return n}return-1},kr.sortedLastIndex=function(e,t){return ii(e,t,!0)},kr.sortedLastIndexBy=function(e,t,r){return si(e,t,as(r,2),!0)},kr.sortedLastIndexOf=function(e,t){if(null==e?0:e.length){var r=ii(e,t,!0)-1;if($o(e[r],t))return r}return-1},kr.startCase=Wa,kr.startsWith=function(e,t,r){return e=va(e),r=null==r?0:on(pa(r),0,e.length),t=ci(t),e.slice(r,r+t.length)==t},kr.subtract=Ec,kr.sum=function(e){return e&&e.length?Gt(e,rc):0},kr.sumBy=function(e,t){return e&&e.length?Gt(e,as(t,2)):0},kr.template=function(e,t,n){var i=kr.templateSettings;n&&ms(e,t,n)&&(t=r),e=va(e),t=_a({},t,i,Ji);var s,o,a=_a({},t.imports,i.imports,Ji),c=Ra(a),h=Xt(a,c),u=0,l=t.interpolate||_e,f="__p += '",p=Ne((t.escape||_e).source+"|"+l.source+"|"+(l===X?fe:_e).source+"|"+(t.evaluate||_e).source+"|$","g"),d="//# sourceURL="+(je.call(t,"sourceURL")?(t.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++st+"]")+"\n";e.replace(p,(function(t,r,n,i,a,c){return n||(n=i),f+=e.slice(u,c).replace(be,ir),r&&(s=!0,f+="' +\n__e("+r+") +\n'"),a&&(o=!0,f+="';\n"+a+";\n__p += '"),n&&(f+="' +\n((__t = ("+n+")) == null ? '' : __t) +\n'"),u=c+t.length,t})),f+="';\n";var g=je.call(t,"variable")&&t.variable;if(g){if(ue.test(g))throw new Ie("Invalid `variable` option passed into `_.template`")}else f="with (obj) {\n"+f+"\n}\n";f=(o?f.replace(K,""):f).replace(V,"$1").replace(B,"$1;"),f="function("+(g||"obj")+") {\n"+(g?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(s?", __e = _.escape":"")+(o?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+f+"return __p\n}";var y=Ja((function(){return Se(c,d+"return "+f).apply(r,h)}));if(y.source=f,Yo(y))throw y;return y},kr.times=function(e,t){if((e=pa(e))<1||e>f)return[];var r=d,n=vr(e,d);t=as(t),e-=d;for(var i=Yt(n,t);++r<e;)t(r);return i},kr.toFinite=fa,kr.toInteger=pa,kr.toLength=da,kr.toLower=function(e){return va(e).toLowerCase()},kr.toNumber=ga,kr.toSafeInteger=function(e){return e?on(pa(e),-f,f):0===e?e:0},kr.toString=va,kr.toUpper=function(e){return va(e).toUpperCase()},kr.trim=function(e,t,n){if((e=va(e))&&(n||t===r))return Qt(e);if(!e||!(t=ci(t)))return e;var i=lr(e),s=lr(t);return _i(i,er(i,s),tr(i,s)+1).join("")},kr.trimEnd=function(e,t,n){if((e=va(e))&&(n||t===r))return e.slice(0,fr(e)+1);if(!e||!(t=ci(t)))return e;var i=lr(e);return _i(i,0,tr(i,lr(t))+1).join("")},kr.trimStart=function(e,t,n){if((e=va(e))&&(n||t===r))return e.replace(ie,"");if(!e||!(t=ci(t)))return e;var i=lr(e);return _i(i,er(i,lr(t))).join("")},kr.truncate=function(e,t){var n=30,i="...";if(Zo(t)){var s="separator"in t?t.separator:s;n="length"in t?pa(t.length):n,i="omission"in t?ci(t.omission):i}var o=(e=va(e)).length;if(sr(e)){var a=lr(e);o=a.length}if(n>=o)return e;var c=n-ur(i);if(c<1)return i;var h=a?_i(a,0,c).join(""):e.slice(0,c);if(s===r)return h+i;if(a&&(c+=h.length-c),ia(s)){if(e.slice(c).search(s)){var u,l=h;for(s.global||(s=Ne(s.source,va(pe.exec(s))+"g")),s.lastIndex=0;u=s.exec(l);)var f=u.index;h=h.slice(0,f===r?c:f)}}else if(e.indexOf(ci(s),c)!=c){var p=h.lastIndexOf(s);p>-1&&(h=h.slice(0,p))}return h+i},kr.unescape=function(e){return(e=va(e))&&G.test(e)?e.replace(F,pr):e},kr.uniqueId=function(e){var t=++Me;return va(e)+t},kr.upperCase=Ga,kr.upperFirst=Ya,kr.each=vo,kr.eachRight=mo,kr.first=Vs,oc(kr,function(){var e={};return wn(kr,(function(t,r){je.call(kr.prototype,r)||(e[r]=t)})),e}(),{chain:!1}),kr.VERSION="4.17.21",Nt(["bind","bindKey","curry","curryRight","partial","partialRight"],(function(e){kr[e].placeholder=kr})),Nt(["drop","take"],(function(e,t){Hr.prototype[e]=function(n){n=n===r?1:yr(pa(n),0);var i=this.__filtered__&&!t?new Hr(this):this.clone();return i.__filtered__?i.__takeCount__=vr(n,i.__takeCount__):i.__views__.push({size:vr(n,d),type:e+(i.__dir__<0?"Right":"")}),i},Hr.prototype[e+"Right"]=function(t){return this.reverse()[e](t).reverse()}})),Nt(["filter","map","takeWhile"],(function(e,t){var r=t+1,n=1==r||3==r;Hr.prototype[e]=function(e){var t=this.clone();return t.__iteratees__.push({iteratee:as(e,3),type:r}),t.__filtered__=t.__filtered__||n,t}})),Nt(["head","last"],(function(e,t){var r="take"+(t?"Right":"");Hr.prototype[e]=function(){return this[r](1).value()[0]}})),Nt(["initial","tail"],(function(e,t){var r="drop"+(t?"":"Right");Hr.prototype[e]=function(){return this.__filtered__?new Hr(this):this[r](1)}})),Hr.prototype.compact=function(){return this.filter(rc)},Hr.prototype.find=function(e){return this.filter(e).head()},Hr.prototype.findLast=function(e){return this.reverse().find(e)},Hr.prototype.invokeMap=Yn((function(e,t){return"function"==typeof e?new Hr(this):this.map((function(r){return Cn(r,e,t)}))})),Hr.prototype.reject=function(e){return this.filter(Uo(as(e)))},Hr.prototype.slice=function(e,t){e=pa(e);var n=this;return n.__filtered__&&(e>0||t<0)?new Hr(n):(e<0?n=n.takeRight(-e):e&&(n=n.drop(e)),t!==r&&(n=(t=pa(t))<0?n.dropRight(-t):n.take(t-e)),n)},Hr.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},Hr.prototype.toArray=function(){return this.take(d)},wn(Hr.prototype,(function(e,t){var n=/^(?:filter|find|map|reject)|While$/.test(t),i=/^(?:head|last)$/.test(t),s=kr[i?"take"+("last"==t?"Right":""):t],o=i||/^find/.test(t);s&&(kr.prototype[t]=function(){var t=this.__wrapped__,a=i?[1]:arguments,c=t instanceof Hr,h=a[0],u=c||Ko(t),l=function(e){var t=s.apply(kr,Ut([e],a));return i&&f?t[0]:t};u&&n&&"function"==typeof h&&1!=h.length&&(c=u=!1);var f=this.__chain__,p=!!this.__actions__.length,d=o&&!f,g=c&&!p;if(!o&&u){t=g?t:new Hr(this);var y=e.apply(t,a);return y.__actions__.push({func:lo,args:[l],thisArg:r}),new qr(y,f)}return d&&g?e.apply(this,a):(y=this.thru(l),d?i?y.value()[0]:y.value():y)})})),Nt(["pop","push","shift","sort","splice","unshift"],(function(e){var t=Re[e],r=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",n=/^(?:pop|shift)$/.test(e);kr.prototype[e]=function(){var e=arguments;if(n&&!this.__chain__){var i=this.value();return t.apply(Ko(i)?i:[],e)}return this[r]((function(r){return t.apply(Ko(r)?r:[],e)}))}})),wn(Hr.prototype,(function(e,t){var r=kr[t];if(r){var n=r.name+"";je.call(Cr,n)||(Cr[n]=[]),Cr[n].push({name:t,func:r})}})),Cr[$i(r,2).name]=[{name:"wrapper",func:r}],Hr.prototype.clone=function(){var e=new Hr(this.__wrapped__);return e.__actions__=Ai(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=Ai(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=Ai(this.__views__),e},Hr.prototype.reverse=function(){if(this.__filtered__){var e=new Hr(this);e.__dir__=-1,e.__filtered__=!0}else(e=this.clone()).__dir__*=-1;return e},Hr.prototype.value=function(){var e=this.__wrapped__.value(),t=this.__dir__,r=Ko(e),n=t<0,i=r?e.length:0,s=function(e,t,r){for(var n=-1,i=r.length;++n<i;){var s=r[n],o=s.size;switch(s.type){case"drop":e+=o;break;case"dropRight":t-=o;break;case"take":t=vr(t,e+o);break;case"takeRight":e=yr(e,t-o)}}return{start:e,end:t}}(0,i,this.__views__),o=s.start,a=s.end,c=a-o,h=n?a:o-1,u=this.__iteratees__,l=u.length,f=0,p=vr(c,this.__takeCount__);if(!r||!n&&i==c&&p==c)return pi(e,this.__actions__);var d=[];e:for(;c--&&f<p;){for(var g=-1,y=e[h+=t];++g<l;){var v=u[g],m=v.iteratee,w=v.type,_=m(y);if(2==w)y=_;else if(!_){if(1==w)continue e;break e}}d[f++]=y}return d},kr.prototype.at=fo,kr.prototype.chain=function(){return uo(this)},kr.prototype.commit=function(){return new qr(this.value(),this.__chain__)},kr.prototype.next=function(){this.__values__===r&&(this.__values__=la(this.value()));var e=this.__index__>=this.__values__.length;return{done:e,value:e?r:this.__values__[this.__index__++]}},kr.prototype.plant=function(e){for(var t,n=this;n instanceof zr;){var i=Ds(n);i.__index__=0,i.__values__=r,t?s.__wrapped__=i:t=i;var s=i;n=n.__wrapped__}return s.__wrapped__=e,t},kr.prototype.reverse=function(){var e=this.__wrapped__;if(e instanceof Hr){var t=e;return this.__actions__.length&&(t=new Hr(this)),(t=t.reverse()).__actions__.push({func:lo,args:[Xs],thisArg:r}),new qr(t,this.__chain__)}return this.thru(Xs)},kr.prototype.toJSON=kr.prototype.valueOf=kr.prototype.value=function(){return pi(this.__wrapped__,this.__actions__)},kr.prototype.first=kr.prototype.head,Je&&(kr.prototype[Je]=function(){return this}),kr}();gt?((gt.exports=dr)._=dr,dt._=dr):pt._=dr}).call(tu)}(ru,ru.exports);var nu=Object.defineProperty,iu=Object.defineProperties,su=Object.getOwnPropertyDescriptors,ou=Object.getOwnPropertySymbols,au=Object.prototype.hasOwnProperty,cu=Object.prototype.propertyIsEnumerable,hu=(e,t,r)=>t in e?nu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,uu=(e,t)=>{for(var r in t||(t={}))au.call(t,r)&&hu(e,r,t[r]);if(ou)for(var r of ou(t))cu.call(t,r)&&hu(e,r,t[r]);return e},lu=(e,t)=>iu(e,su(t));function fu(e,t,r){var n;const i=function(e){const[t,r]=e.split(Ar);return{namespace:t,reference:r}}(e);return(null==(n=t.rpcMap)?void 0:n[i.reference])||`https://rpc.walletconnect.com/v1/?chainId=${i.namespace}:${i.reference}&projectId=${r}`}function pu(e){return e.includes(":")?e.split(":")[1]:e}function du(e){return e.map((e=>`${e.split(":")[0]}:${e.split(":")[1]}`))}function gu(e){var t,r,n,i;const s={};if(!$n(e))return s;for(const[o,a]of Object.entries(e)){const e=Tn(o)?[o]:a.chains,c=a.methods||[],h=a.events||[],u=a.rpcMap||{},l=Ln(o);s[l]=lu(uu(uu({},s[l]),a),{chains:wn(e,null==(t=s[l])?void 0:t.chains),methods:wn(c,null==(r=s[l])?void 0:r.methods),events:wn(h,null==(n=s[l])?void 0:n.events),rpcMap:uu(uu({},u),null==(i=s[l])?void 0:i.rpcMap)})}return s}function yu(e){return e.includes(":")?e.split(":")[2]:e}function vu(e){const t={};for(const[r,n]of Object.entries(e)){const e=n.methods||[],i=n.events||[],s=n.accounts||[],o=Tn(r)?[r]:n.chains?n.chains:du(n.accounts);t[r]={chains:o,methods:e,events:i,accounts:s}}return t}function mu(e){return"number"==typeof e?e:e.includes("0x")?parseInt(e,16):e.includes(":")?Number(e.split(":")[1]):Number(e)}const wu={},_u=e=>wu[e],bu=(e,t)=>{wu[e]=t};class Eu{constructor(e){this.name="polkadot",this.namespace=e.namespace,this.events=_u("events"),this.client=_u("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(eu,`${this.name}:${e}`)}getAccounts(){const e=this.namespace.accounts;return e&&e.filter((e=>e.split(":")[1]===this.chainId.toString())).map((e=>e.split(":")[2]))||[]}createHttpProviders(){const e={};return this.namespace.chains.forEach((t=>{var r;const n=pu(t);e[n]=this.createHttpProvider(n,null==(r=this.namespace.rpcMap)?void 0:r[t])})),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const r=this.createHttpProvider(e,t);r&&(this.httpProviders[e]=r)}createHttpProvider(e,t){const r=t||fu(e,this.namespace,this.client.core.projectId);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);return new go(new Jh(r,_u("disableProviderPing")))}}class Iu{constructor(e){this.name="eip155",this.namespace=e.namespace,this.events=_u("events"),this.client=_u("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain())}async request(e){switch(e.request.method){case"eth_requestAccounts":case"eth_accounts":return this.getAccounts();case"wallet_switchEthereumChain":return await this.handleSwitchChain(e);case"eth_chainId":return parseInt(this.getDefaultChain())}return this.namespace.methods.includes(e.request.method)?await this.client.request(e):this.getHttpProvider().request(e.request)}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(parseInt(e),t),this.chainId=parseInt(e),this.events.emit(eu,`${this.name}:${e}`)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}createHttpProvider(e,t){const r=t||fu(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);return new go(new Jh(r,_u("disableProviderPing")))}setHttpProvider(e,t){const r=this.createHttpProvider(e,t);r&&(this.httpProviders[e]=r)}createHttpProviders(){const e={};return this.namespace.chains.forEach((t=>{var r;const n=parseInt(pu(t));e[n]=this.createHttpProvider(n,null==(r=this.namespace.rpcMap)?void 0:r[t])})),e}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter((e=>e.split(":")[1]===this.chainId.toString())).map((e=>e.split(":")[2])))]:[]}getHttpProvider(){const e=this.chainId,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}async handleSwitchChain(e){var t,r;let n=e.request.params?null==(t=e.request.params[0])?void 0:t.chainId:"0x0";n=n.startsWith("0x")?n:`0x${n}`;const i=parseInt(n,16);if(this.isChainApproved(i))this.setDefaultChain(`${i}`);else{if(!this.namespace.methods.includes("wallet_switchEthereumChain"))throw new Error(`Failed to switch to chain 'eip155:${i}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);await this.client.request({topic:e.topic,request:{method:e.request.method,params:[{chainId:n}]},chainId:null==(r=this.namespace.chains)?void 0:r[0]}),this.setDefaultChain(`${i}`)}return null}isChainApproved(e){return this.namespace.chains.includes(`${this.name}:${e}`)}}class Su{constructor(e){this.name="solana",this.namespace=e.namespace,this.events=_u("events"),this.client=_u("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(eu,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter((e=>e.split(":")[1]===this.chainId.toString())).map((e=>e.split(":")[2])))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach((t=>{var r;const n=pu(t);e[n]=this.createHttpProvider(n,null==(r=this.namespace.rpcMap)?void 0:r[t])})),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const r=this.createHttpProvider(e,t);r&&(this.httpProviders[e]=r)}createHttpProvider(e,t){const r=t||fu(e,this.namespace,this.client.core.projectId);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);return new go(new Jh(r,_u("disableProviderPing")))}}class Pu{constructor(e){this.name="cosmos",this.namespace=e.namespace,this.events=_u("events"),this.client=_u("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(eu,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter((e=>e.split(":")[1]===this.chainId.toString())).map((e=>e.split(":")[2])))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach((t=>{var r;const n=pu(t);e[n]=this.createHttpProvider(n,null==(r=this.namespace.rpcMap)?void 0:r[t])})),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const r=this.createHttpProvider(e,t);r&&(this.httpProviders[e]=r)}createHttpProvider(e,t){const r=t||fu(e,this.namespace,this.client.core.projectId);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);return new go(new Jh(r,_u("disableProviderPing")))}}class Ou{constructor(e){this.name="cip34",this.namespace=e.namespace,this.events=_u("events"),this.client=_u("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(eu,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter((e=>e.split(":")[1]===this.chainId.toString())).map((e=>e.split(":")[2])))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach((t=>{const r=this.getCardanoRPCUrl(t),n=pu(t);e[n]=this.createHttpProvider(n,r)})),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}getCardanoRPCUrl(e){const t=this.namespace.rpcMap;if(t)return t[e]}setHttpProvider(e,t){const r=this.createHttpProvider(e,t);r&&(this.httpProviders[e]=r)}createHttpProvider(e,t){const r=t||this.getCardanoRPCUrl(e);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);return new go(new Jh(r,_u("disableProviderPing")))}}class Nu{constructor(e){this.name="elrond",this.namespace=e.namespace,this.events=_u("events"),this.client=_u("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(eu,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter((e=>e.split(":")[1]===this.chainId.toString())).map((e=>e.split(":")[2])))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach((t=>{var r;const n=pu(t);e[n]=this.createHttpProvider(n,null==(r=this.namespace.rpcMap)?void 0:r[t])})),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const r=this.createHttpProvider(e,t);r&&(this.httpProviders[e]=r)}createHttpProvider(e,t){const r=t||fu(e,this.namespace,this.client.core.projectId);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);return new go(new Jh(r,_u("disableProviderPing")))}}class Au{constructor(e){this.name="multiversx",this.namespace=e.namespace,this.events=_u("events"),this.client=_u("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(eu,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter((e=>e.split(":")[1]===this.chainId.toString())).map((e=>e.split(":")[2])))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach((t=>{var r;const n=pu(t);e[n]=this.createHttpProvider(n,null==(r=this.namespace.rpcMap)?void 0:r[t])})),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const r=this.createHttpProvider(e,t);r&&(this.httpProviders[e]=r)}createHttpProvider(e,t){const r=t||fu(e,this.namespace,this.client.core.projectId);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);return new go(new Jh(r,_u("disableProviderPing")))}}class Cu{constructor(e){this.name="near",this.namespace=e.namespace,this.events=_u("events"),this.client=_u("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(this.chainId=e,!this.httpProviders[e]){const r=t||fu(`${this.name}:${e}`,this.namespace);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,r)}this.events.emit(eu,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e&&e.filter((e=>e.split(":")[1]===this.chainId.toString())).map((e=>e.split(":")[2]))||[]}createHttpProviders(){const e={};return this.namespace.chains.forEach((t=>{var r;e[t]=this.createHttpProvider(t,null==(r=this.namespace.rpcMap)?void 0:r[t])})),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const r=this.createHttpProvider(e,t);r&&(this.httpProviders[e]=r)}createHttpProvider(e,t){const r=t||fu(e,this.namespace);return typeof r>"u"?void 0:new go(new Jh(r,_u("disableProviderPing")))}}var Ru=Object.defineProperty,xu=Object.defineProperties,Tu=Object.getOwnPropertyDescriptors,Lu=Object.getOwnPropertySymbols,Uu=Object.prototype.hasOwnProperty,ju=Object.prototype.propertyIsEnumerable,Mu=(e,t,r)=>t in e?Ru(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Du=(e,t)=>{for(var r in t||(t={}))Uu.call(t,r)&&Mu(e,r,t[r]);if(Lu)for(var r of Lu(t))ju.call(t,r)&&Mu(e,r,t[r]);return e},ku=(e,t)=>xu(e,Tu(t));class $u{constructor(t){this.events=new e,this.rpcProviders={},this.shouldAbortPairingAttempt=!1,this.maxPairingAttempts=10,this.disableProviderPing=!1,this.providerOpts=t,this.logger=typeof t?.logger<"u"&&"string"!=typeof t?.logger?t.logger:ss.pino(ss.getDefaultLoggerOptions({level:t?.logger||Xh})),this.disableProviderPing=t?.disableProviderPing||!1}static async init(e){const t=new $u(e);return await t.initialize(),t}async request(e,t){const[r,n]=this.validateChain(t);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(r).request({request:Du({},e),chainId:`${r}:${n}`,topic:this.session.topic})}sendAsync(e,t,r){this.request(e,r).then((e=>t(null,e))).catch((e=>t(e,void 0)))}async enable(){if(!this.client)throw new Error("Sign Client not initialized");return this.session||await this.connect({namespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties}),await this.requestAccounts()}async disconnect(){var e;if(!this.session)throw new Error("Please call connect() before enable()");await this.client.disconnect({topic:null==(e=this.session)?void 0:e.topic,reason:Dn("USER_DISCONNECTED")}),await this.cleanup()}async connect(e){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces(e),await this.cleanupPendingPairings(),!e.skipPairing)return await this.pair(e.pairingTopic)}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}removeListener(e,t){this.events.removeListener(e,t)}off(e,t){this.events.off(e,t)}get isWalletConnect(){return!0}async pair(e){this.shouldAbortPairingAttempt=!1;let t=0;do{if(this.shouldAbortPairingAttempt)throw new Error("Pairing aborted");if(t>=this.maxPairingAttempts)throw new Error("Max auto pairing attempts reached");const{uri:r,approval:n}=await this.client.connect({pairingTopic:e,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties});r&&(this.uri=r,this.events.emit("display_uri",r)),await n().then((e=>{this.session=e,this.namespaces||(this.namespaces=vu(e.namespaces),this.persist("namespaces",this.namespaces))})).catch((e=>{if(e.message!==Ch)throw e;t++}))}while(!this.session);return this.onConnect(),this.session}setDefaultChain(e,t){try{if(!this.session)return;const[r,n]=this.validateChain(e);this.getProvider(r).setDefaultChain(n,t)}catch(e){if(!/Please call connect/.test(e.message))throw e}}async cleanupPendingPairings(e={}){this.logger.info("Cleaning up inactive pairings...");const t=this.client.pairing.getAll();if(kn(t)){for(const r of t)e.deletePairings?this.client.core.expirer.set(r.topic,0):await this.client.core.relayer.subscriber.unsubscribe(r.topic);this.logger.info(`Inactive pairings cleared: ${t.length}`)}}abortPairingAttempt(){this.shouldAbortPairingAttempt=!0}async checkStorage(){if(this.namespaces=await this.getFromStore("namespaces"),this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.client.session.length){const e=this.client.session.keys.length-1;this.session=this.client.session.get(this.client.session.keys[e]),this.createProviders()}}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners()}async createClient(){this.client=this.providerOpts.client||await Yh.init({logger:this.providerOpts.logger||Xh,relayUrl:this.providerOpts.relayUrl||"wss://relay.walletconnect.com",projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,storage:this.providerOpts.storage,name:this.providerOpts.name}),this.logger.trace("SignClient Initialized")}createProviders(){if(!this.client)throw new Error("Sign Client not initialized");if(!this.session)throw new Error("Session not initialized. Please call connect() before enable()");const e=[...new Set(Object.keys(this.session.namespaces).map((e=>Ln(e))))];bu("client",this.client),bu("events",this.events),bu("disableProviderPing",this.disableProviderPing),e.forEach((e=>{if(!this.session)return;const t=function(e,t){const r=Object.keys(t.namespaces).filter((t=>t.includes(e)));if(!r.length)return[];const n=[];return r.forEach((e=>{const r=t.namespaces[e].accounts;n.push(...r)})),n}(e,this.session),r=du(t),n=function(e={},t={}){const r=gu(e),n=gu(t);return ru.exports.merge(r,n)}(this.namespaces,this.optionalNamespaces),i=ku(Du({},n[e]),{accounts:t,chains:r});switch(e){case"eip155":this.rpcProviders[e]=new Iu({namespace:i});break;case"solana":this.rpcProviders[e]=new Su({namespace:i});break;case"cosmos":this.rpcProviders[e]=new Pu({namespace:i});break;case"polkadot":this.rpcProviders[e]=new Eu({namespace:i});break;case"cip34":this.rpcProviders[e]=new Ou({namespace:i});break;case"elrond":this.rpcProviders[e]=new Nu({namespace:i});break;case"multiversx":this.rpcProviders[e]=new Au({namespace:i});break;case"near":this.rpcProviders[e]=new Cu({namespace:i})}}))}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",(e=>{this.events.emit("session_ping",e)})),this.client.on("session_event",(e=>{const{params:t}=e,{event:r}=t;if("accountsChanged"===r.name){const e=r.data;e&&kn(e)&&this.events.emit("accountsChanged",e.map(yu))}else if("chainChanged"===r.name){const e=t.chainId,r=t.event.data,n=Ln(e),i=mu(e)!==mu(r)?`${n}:${mu(r)}`:e;this.onChainChanged(i)}else this.events.emit(r.name,r.data);this.events.emit("session_event",e)})),this.client.on("session_update",(({topic:e,params:t})=>{var r;const{namespaces:n}=t,i=null==(r=this.client)?void 0:r.session.get(e);this.session=ku(Du({},i),{namespaces:n}),this.onSessionUpdate(),this.events.emit("session_update",{topic:e,params:t})})),this.client.on("session_delete",(async e=>{await this.cleanup(),this.events.emit("session_delete",e),this.events.emit("disconnect",ku(Du({},Dn("USER_DISCONNECTED")),{data:e.topic}))})),this.on(eu,(e=>{this.onChainChanged(e,!0)}))}getProvider(e){if(!this.rpcProviders[e])throw new Error(`Provider not found: ${e}`);return this.rpcProviders[e]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach((e=>{var t;this.getProvider(e).updateNamespace(null==(t=this.session)?void 0:t.namespaces[e])}))}setNamespaces(e){const{namespaces:t,optionalNamespaces:r,sessionProperties:n}=e;t&&Object.keys(t).length&&(this.namespaces=t),r&&Object.keys(r).length&&(this.optionalNamespaces=r),this.sessionProperties=n,this.persist("namespaces",t),this.persist("optionalNamespaces",r)}validateChain(e){const[t,r]=e?.split(":")||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[t,r];if(t&&!Object.keys(this.namespaces||{}).map((e=>Ln(e))).includes(t))throw new Error(`Namespace '${t}' is not configured. Please call connect() first with namespace config.`);if(t&&r)return[t,r];const n=Ln(Object.keys(this.namespaces)[0]);return[n,this.rpcProviders[n].getDefaultChain()]}async requestAccounts(){const[e]=this.validateChain();return await this.getProvider(e).requestAccounts()}onChainChanged(e,t=!1){var r;if(!this.namespaces)return;const[n,i]=this.validateChain(e);t||this.getProvider(n).setDefaultChain(i),(null!=(r=this.namespaces[n])?r:this.namespaces[`${n}:${i}`]).defaultChain=i,this.persist("namespaces",this.namespaces),this.events.emit("chainChanged",i)}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session})}async cleanup(){this.session=void 0,this.namespaces=void 0,this.optionalNamespaces=void 0,this.sessionProperties=void 0,this.persist("namespaces",void 0),this.persist("optionalNamespaces",void 0),this.persist("sessionProperties",void 0),await this.cleanupPendingPairings({deletePairings:!0})}persist(e,t){this.client.core.storage.setItem(`${Zh}/${e}`,t)}async getFromStore(e){return await this.client.core.storage.getItem(`${Zh}/${e}`)}}const zu=$u,qu=["eth_sendTransaction","personal_sign"],Hu=["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sendTransaction","personal_sign","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode"],Ku=["chainChanged","accountsChanged"],Vu=["chainChanged","accountsChanged","message","disconnect","connect"];var Bu=Object.defineProperty,Fu=Object.defineProperties,Wu=Object.getOwnPropertyDescriptors,Gu=Object.getOwnPropertySymbols,Yu=Object.prototype.hasOwnProperty,Qu=Object.prototype.propertyIsEnumerable,Ju=(e,t,r)=>t in e?Bu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Xu=(e,t)=>{for(var r in t||(t={}))Yu.call(t,r)&&Ju(e,r,t[r]);if(Gu)for(var r of Gu(t))Qu.call(t,r)&&Ju(e,r,t[r]);return e},Zu=(e,t)=>Fu(e,Wu(t));function el(e){return Number(e[0].split(":")[1])}function tl(e){return`0x${e.toString(16)}`}class rl{constructor(){this.events=new t,this.namespace="eip155",this.accounts=[],this.chainId=1,this.STORAGE_KEY="wc@2:ethereum_provider:",this.on=(e,t)=>(this.events.on(e,t),this),this.once=(e,t)=>(this.events.once(e,t),this),this.removeListener=(e,t)=>(this.events.removeListener(e,t),this),this.off=(e,t)=>(this.events.off(e,t),this),this.parseAccount=e=>this.isCompatibleChainId(e)?this.parseAccountId(e).address:e,this.signer={},this.rpc={}}static async init(e){const t=new rl;return await t.initialize(e),t}async request(e){return await this.signer.request(e,this.formatChainId(this.chainId))}sendAsync(e,t){this.signer.sendAsync(e,t,this.formatChainId(this.chainId))}get connected(){return!!this.signer.client&&this.signer.client.core.relayer.connected}get connecting(){return!!this.signer.client&&this.signer.client.core.relayer.connecting}async enable(){return this.session||await this.connect(),await this.request({method:"eth_requestAccounts"})}async connect(e){if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts(e);const{required:t,optional:r}=function(e){const{chains:t,optionalChains:r,methods:n,optionalMethods:i,events:s,optionalEvents:o,rpcMap:a}=e;if(!kn(t))throw new Error("Invalid chains");const c={chains:t,methods:n||qu,events:s||Ku,rpcMap:Xu({},t.length?{[el(t)]:a[el(t)]}:{})},h=s?.filter((e=>!Ku.includes(e))),u=n?.filter((e=>!qu.includes(e)));if(!(r||o||i||null!=h&&h.length||null!=u&&u.length))return{required:t.length?c:void 0};const l={chains:[...new Set(h?.length&&u?.length||!r?c.chains.concat(r||[]):r)],methods:[...new Set(c.methods.concat(null!=i&&i.length?i:Hu))],events:[...new Set(c.events.concat(null!=o&&o.length?o:Vu))],rpcMap:a};return{required:t.length?c:void 0,optional:r.length?l:void 0}}(this.rpc);try{const n=await new Promise((async(n,i)=>{var s;this.rpc.showQrModal&&(null==(s=this.modal)||s.subscribeModal((e=>{!e.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),i(new Error("Connection request reset. Please try again.")))}))),await this.signer.connect(Zu(Xu({namespaces:Xu({},t&&{[this.namespace]:t})},r&&{optionalNamespaces:{[this.namespace]:r}}),{pairingTopic:e?.pairingTopic})).then((e=>{n(e)})).catch((e=>{i(new Error(e.message))}))}));if(!n)return;const i=function(e,t=[]){const r=[];return Object.keys(e).forEach((n=>{if(t.length&&!t.includes(n))return;const i=e[n];r.push(...i.accounts)})),r}(n.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:i),this.setAccounts(i),this.events.emit("connect",{chainId:tl(this.chainId)})}catch(e){throw this.signer.logger.error(e),e}finally{this.modal&&this.modal.closeModal()}}async disconnect(){this.session&&await this.signer.disconnect(),this.reset()}get isWalletConnect(){return!0}get session(){return this.signer.session}registerEventListeners(){this.signer.on("session_event",(e=>{const{params:t}=e,{event:r}=t;"accountsChanged"===r.name?(this.accounts=this.parseAccounts(r.data),this.events.emit("accountsChanged",this.accounts)):"chainChanged"===r.name?this.setChainId(this.formatChainId(r.data)):this.events.emit(r.name,r.data),this.events.emit("session_event",e)})),this.signer.on("chainChanged",(e=>{const t=parseInt(e);this.chainId=t,this.events.emit("chainChanged",tl(this.chainId)),this.persist()})),this.signer.on("session_update",(e=>{this.events.emit("session_update",e)})),this.signer.on("session_delete",(e=>{this.reset(),this.events.emit("session_delete",e),this.events.emit("disconnect",Zu(Xu({},Dn("USER_DISCONNECTED")),{data:e.topic,name:"USER_DISCONNECTED"}))})),this.signer.on("display_uri",(e=>{var t,r;this.rpc.showQrModal&&(null==(t=this.modal)||t.closeModal(),null==(r=this.modal)||r.openModal({uri:e})),this.events.emit("display_uri",e)}))}switchEthereumChain(e){this.request({method:"wallet_switchEthereumChain",params:[{chainId:e.toString(16)}]})}isCompatibleChainId(e){return"string"==typeof e&&e.startsWith(`${this.namespace}:`)}formatChainId(e){return`${this.namespace}:${e}`}parseChainId(e){return Number(e.split(":")[1])}setChainIds(e){const t=e.filter((e=>this.isCompatibleChainId(e))).map((e=>this.parseChainId(e)));t.length&&(this.chainId=t[0],this.events.emit("chainChanged",tl(this.chainId)),this.persist())}setChainId(e){if(this.isCompatibleChainId(e)){const t=this.parseChainId(e);this.chainId=t,this.switchEthereumChain(t)}}parseAccountId(e){const[t,r,n]=e.split(":");return{chainId:`${t}:${r}`,address:n}}setAccounts(e){this.accounts=e.filter((e=>this.parseChainId(this.parseAccountId(e).chainId)===this.chainId)).map((e=>this.parseAccountId(e).address)),this.events.emit("accountsChanged",this.accounts)}getRpcConfig(e){var t,r;const n=null!=(t=e?.chains)?t:[],i=null!=(r=e?.optionalChains)?r:[],s=n.concat(i);if(!s.length)throw new Error("No chains specified in either `chains` or `optionalChains`");const o=n.length?e?.methods||qu:[],a=n.length?e?.events||Ku:[],c=e?.optionalMethods||[],h=e?.optionalEvents||[],u=e?.rpcMap||this.buildRpcMap(s,e.projectId),l=e?.qrModalOptions||void 0;return{chains:n?.map((e=>this.formatChainId(e))),optionalChains:i.map((e=>this.formatChainId(e))),methods:o,events:a,optionalMethods:c,optionalEvents:h,rpcMap:u,showQrModal:!(null==e||!e.showQrModal),qrModalOptions:l,projectId:e.projectId,metadata:e.metadata}}buildRpcMap(e,t){const r={};return e.forEach((e=>{r[e]=this.getRpcUrl(e,t)})),r}async initialize(e){if(this.rpc=this.getRpcConfig(e),this.chainId=this.rpc.chains.length?el(this.rpc.chains):el(this.rpc.optionalChains),this.signer=await zu.init({projectId:this.rpc.projectId,metadata:this.rpc.metadata,disableProviderPing:e.disableProviderPing,relayUrl:e.relayUrl,storageOptions:e.storageOptions}),this.registerEventListeners(),await this.loadPersistedSession(),this.rpc.showQrModal){let e;try{const{WalletConnectModal:t}=await import("./index-71e104e3.js").then((function(e){return e.i}));e=t}catch{throw new Error("To use QR modal, please install @walletconnect/modal package")}if(e)try{this.modal=new e(Xu({walletConnectVersion:2,projectId:this.rpc.projectId,standaloneChains:this.rpc.chains},this.rpc.qrModalOptions))}catch(e){throw this.signer.logger.error(e),new Error("Could not generate WalletConnectModal Instance")}}}loadConnectOpts(e){if(!e)return;const{chains:t,optionalChains:r,rpcMap:n}=e;t&&kn(t)&&(this.rpc.chains=t.map((e=>this.formatChainId(e))),t.forEach((e=>{this.rpc.rpcMap[e]=n?.[e]||this.getRpcUrl(e)}))),r&&kn(r)&&(this.rpc.optionalChains=[],this.rpc.optionalChains=r?.map((e=>this.formatChainId(e))),r.forEach((e=>{this.rpc.rpcMap[e]=n?.[e]||this.getRpcUrl(e)})))}getRpcUrl(e,t){var r;return(null==(r=this.rpc.rpcMap)?void 0:r[e])||`https://rpc.walletconnect.com/v1/?chainId=eip155:${e}&projectId=${t||this.rpc.projectId}`}async loadPersistedSession(){if(!this.session)return;const e=await this.signer.client.core.storage.getItem(`${this.STORAGE_KEY}/chainId`),t=this.session.namespaces[`${this.namespace}:${e}`]?this.session.namespaces[`${this.namespace}:${e}`]:this.session.namespaces[this.namespace];this.setChainIds(e?[this.formatChainId(e)]:t?.accounts),this.setAccounts(t?.accounts)}reset(){this.chainId=1,this.accounts=[]}persist(){this.session&&this.signer.client.core.storage.setItem(`${this.STORAGE_KEY}/chainId`,this.chainId)}parseAccounts(e){return"string"==typeof e||e instanceof String?[this.parseAccount(e)]:e.map((e=>this.parseAccount(e)))}}const nl=rl;export{nl as EthereumProvider,Vu as OPTIONAL_EVENTS,Hu as OPTIONAL_METHODS,Ku as REQUIRED_EVENTS,qu as REQUIRED_METHODS,rl as default};