@wormhole-foundation/wormhole-connect 2.1.0-beta.1-development → 2.1.0-beta.2-development

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 (92) hide show
  1. package/dist/assets/{ccip-j5QHovIT.js → ccip-DfI9A4kL.js} +1 -1
  2. package/dist/assets/{evm-B5I5ieRn.js → evm-CYICYl2d.js} +3 -3
  3. package/dist/assets/index-26ve8f2n.js +531 -0
  4. package/dist/assets/index-NqsKKz5-.js +14 -0
  5. package/dist/assets/index.es-CephYdxr.js +47 -0
  6. package/dist/assets/{solana-c_vE3Ye5.js → solana-DXbD7wpn.js} +2 -2
  7. package/dist/assets/{solanaEmbed.esm-Bx0ME0S1.js → solanaEmbed.esm-CcwIvLto.js} +10 -10
  8. package/dist/main.js +3 -3
  9. package/lib/{aptos-CzT6f7Ba.js → aptos-7G9wZkGW.js} +2 -2
  10. package/lib/{aptos-wFa1-xae.mjs → aptos-BlOWGpyT.mjs} +2 -2
  11. package/lib/{aptos-CqfHXKy7.js → aptos-CYxRBLR_.js} +1 -1
  12. package/lib/{aptos-DxhN-FI3.mjs → aptos-Ckopfy7I.mjs} +5 -5
  13. package/lib/{base64-C_XWimVd.js → base64-CFR5QWTY.js} +1 -1
  14. package/lib/{base64-L1vzz0KI.mjs → base64-HSuzVIKw.mjs} +1 -1
  15. package/lib/{ccip-z81HbzxN.mjs → ccip-Bntg_vPp.mjs} +1 -1
  16. package/lib/{ccip-D6aPw5Ue.js → ccip-CVUhxB0q.js} +1 -1
  17. package/lib/{chunk-IMTC3J2M-CazR2ogu.mjs → chunk-IMTC3J2M-BADDWO3l.mjs} +3 -3
  18. package/lib/{chunk-IMTC3J2M-WMj1Jt5m.js → chunk-IMTC3J2M-ByR5Yjf4.js} +1 -1
  19. package/lib/{events-D4Mv_WYU.js → events-jATx_JnD.js} +1 -1
  20. package/lib/{events-BrdIAbQL.mjs → events-lD3LhLH0.mjs} +1 -1
  21. package/lib/{evm-CB6zu7io.mjs → evm-BW0CHBCG.mjs} +5 -5
  22. package/lib/{evm-Fk4wBAda.js → evm-Bh1Y4eUx.js} +1 -1
  23. package/lib/{evm-CULALpUt.mjs → evm-ColKfWEz.mjs} +10 -6
  24. package/lib/{evm-BJL8RjTB.js → evm-z5yFHxM9.js} +3 -3
  25. package/lib/{index-D2y7My6x.mjs → index-2fBRXVP8.mjs} +2 -2
  26. package/lib/{index-Cuov-W4s.js → index-8-70GvMi.js} +1 -1
  27. package/lib/{index-Xy8XaqU-.js → index-8JCep4IW.js} +1 -1
  28. package/lib/{index-BTmEJpYG.mjs → index-B9GU1bLs.mjs} +1 -1
  29. package/lib/{index-CS3t6bxx.mjs → index-BXkdaYu_.mjs} +1 -1
  30. package/lib/{index-DEpSdwA-.mjs → index-BZ0W_BZS.mjs} +2 -2
  31. package/lib/{index-CtpCK8QC.js → index-BcdbCktu.js} +1 -1
  32. package/lib/{index-BnVRRJvv.js → index-BhexWYVn.js} +1 -1
  33. package/lib/{index-BT_eiQVC.js → index-C-OIv0gT.js} +1 -1
  34. package/lib/{index-CAqS4koK.js → index-C6WDEDwO.js} +1 -1
  35. package/lib/{index-BqaYMlOq.mjs → index-CAUvtNGE.mjs} +3 -3
  36. package/lib/{index-DpfI-2hT.mjs → index-CBxgME-2.mjs} +2 -2
  37. package/lib/{index-Dtg6idl8.js → index-CCUy1jes.js} +1 -1
  38. package/lib/{index-DGcrnWdu.mjs → index-CYBM2IeY.mjs} +13 -12
  39. package/lib/{index-DJJ3umH8.mjs → index-CcFpkXPM.mjs} +2 -2
  40. package/lib/{index-BqCducVx.mjs → index-CfnNi3Zd.mjs} +3 -3
  41. package/lib/{index-DdRe9fUB.mjs → index-Cl6LSKsg.mjs} +1 -1
  42. package/lib/{index-DtqIOAjg.mjs → index-CxQ-swIQ.mjs} +1 -1
  43. package/lib/index-Cxw9PIcl.js +531 -0
  44. package/lib/{index-CGdGYg5B.mjs → index-D0XcjaUl.mjs} +2 -2
  45. package/lib/{index-B9FwYN90.js → index-D7IcLxQc.js} +1 -1
  46. package/lib/index-DAzDpd7U.js +14 -0
  47. package/lib/{index-jC1hUxPJ.mjs → index-DB_r424l.mjs} +1 -1
  48. package/lib/{index-C_2eG0Va.mjs → index-DECw2aR6.mjs} +1 -1
  49. package/lib/{index-CuPOodtE.js → index-DGgQSMuG.js} +1 -1
  50. package/lib/{index-BsmdxKnE.mjs → index-DIAuhm70.mjs} +3008 -3525
  51. package/lib/{index-CuWt4RaJ.js → index-DOXMkFA4.js} +1 -1
  52. package/lib/{index-BGZONAdj.js → index-DQVQrflZ.js} +1 -1
  53. package/lib/{index-GM4m48QO.js → index-DUXnbpVg.js} +1 -1
  54. package/lib/{index-DUGwXho3.js → index-DZvLy2Dr.js} +3 -3
  55. package/lib/{index-BsYhqVq_.js → index-DjkMeATf.js} +1 -1
  56. package/lib/{index-C0MgLwy8.js → index-DleO04Ea.js} +1 -1
  57. package/lib/{index-HeldZ3mJ.mjs → index-InC6In6o.mjs} +2 -2
  58. package/lib/{index-CkUMgihl.js → index-V7kxzAZX.js} +1 -1
  59. package/lib/{index-B5TOuhBB.js → index-WLqZ1uO7.js} +1 -1
  60. package/lib/{index-Cf2BEUjb.mjs → index-gd_dleYk.mjs} +1 -1
  61. package/lib/{index-CayMgbM_.js → index-l0NqjNj9.js} +1 -1
  62. package/lib/{index-wAClTIQn.mjs → index-lEBTHIqm.mjs} +2 -2
  63. package/lib/{index-DsYAlD9Y.mjs → index-lHA40g0z.mjs} +2 -2
  64. package/lib/index-oPxOJfPK.mjs +3236 -0
  65. package/lib/{index-ChzkRsG0.js → index-rFhS51F6.js} +1 -1
  66. package/lib/{index-DXIpHh2N.mjs → index-y_DeeCWD.mjs} +4 -4
  67. package/lib/index.es-Doowrf9a.js +46 -0
  68. package/lib/index.es-YqKQxHG6.mjs +7725 -0
  69. package/lib/index.js +1 -1
  70. package/lib/index.mjs +1 -1
  71. package/lib/{signer-BBJR-S7u.mjs → signer-CfU9wW3f.mjs} +1 -1
  72. package/lib/{signer-D8m72nd4.js → signer-eoVHaZz7.js} +1 -1
  73. package/lib/{solana-DB5vwgKO.mjs → solana-CHUnEnef.mjs} +4 -4
  74. package/lib/{solana-tZZpsxE8.js → solana-C_d_AKET.js} +1 -1
  75. package/lib/solana-SFHXHGL2.js +1 -0
  76. package/lib/{solana-DdLCPKF2.mjs → solana-y-l38J4U.mjs} +5 -5
  77. package/lib/{solanaEmbed.esm-TpsYEDsw.js → solanaEmbed.esm-B4tNQ7S7.js} +10 -10
  78. package/lib/{solanaEmbed.esm-ANGjgiaN.mjs → solanaEmbed.esm-DVOHg5WI.mjs} +1559 -1560
  79. package/lib/{sui-BFNsLy1t.mjs → sui-1fbLRIUL.mjs} +5 -5
  80. package/lib/{sui-UELhAZj0.js → sui-BN1m6APK.js} +1 -1
  81. package/lib/{sui-DKw9LmTC.mjs → sui-D9frS9ki.mjs} +1 -1
  82. package/lib/{sui-D9F11hKw.js → sui-K20aVxqE.js} +2 -2
  83. package/package.json +5 -1
  84. package/dist/assets/index-BUd_4Lqz.js +0 -14
  85. package/dist/assets/index-Db_i6Hbk.js +0 -531
  86. package/dist/assets/index.es-BYwyqXqm.js +0 -47
  87. package/lib/index-5EBn2EJL.mjs +0 -2709
  88. package/lib/index-CYpOkqEl.js +0 -14
  89. package/lib/index-Cst2493l.js +0 -531
  90. package/lib/index.es-DG7BWZ8R.js +0 -46
  91. package/lib/index.es-IbuqEs8_.mjs +0 -8242
  92. package/lib/solana-521ACL4P.js +0 -1
@@ -1,531 +0,0 @@
1
- import{bg as su,i as R,be as va,S as ou,j as wa,bh as L,P as au,T as cu}from"../main.js";import{d as lu}from"./dijkstra-D_NXgYpA.js";import{e as Ge,s as _a}from"./events-CWXiu-8K.js";import{c as S,a as Xe}from"./index-DDKl8WTX.js";import{r as uu,i as Pt,j as At,l as Be,m as hi,I as $t,d as Mr,c as hu,a as du,k as fu,b as pu,s as gu,g as ps,f as Oe,t as pe,F as tn,e as Ni,C as yu,h as mu,n as gs,o as vu,p as wu,q as An,u as _u,v as Tn,G as bu,E as ge,y as Ie,P as ys,Q as Eu,w as Iu,T as ba,x as Rn,z as Nn,A as Ze,_ as Su,B as _t}from"./index-BUd_4Lqz.js";import{s as Ea,a as $e,h as Ia,L as xu,d as or,l as Pu,e as $i,g as Au,i as ms,k as Tu}from"./index-Dv9aAcjK.js";let Ru=class extends uu{constructor(e){super(e),this.events=new Ge.EventEmitter,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(Pt(e.method,e.params||[],e.id||At().toString()),t)}async requestStrict(e,t){return new Promise(async(i,n)=>{if(!this.connection.connected)try{await this.open()}catch(s){n(s)}this.events.on(`${e.id}`,s=>{Be(s)?n(s.error):i(s.result)});try{await this.connection.send(e,t)}catch(s){n(s)}})}setConnection(e=this.connection){return e}onPayload(e){this.events.emit("payload",e),hi(e)?this.events.emit(`${e.id}`,e):this.events.emit("message",{type:e.method,data:e.params})}onClose(e){e&&e.code===3e3&&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(),typeof e=="string"&&(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)}};var Nu=function(){var r=document.getSelection();if(!r.rangeCount)return function(){};for(var e=document.activeElement,t=[],i=0;i<r.rangeCount;i++)t.push(r.getRangeAt(i));switch(e.tagName.toUpperCase()){case"INPUT":case"TEXTAREA":e.blur();break;default:e=null;break}return r.removeAllRanges(),function(){r.type==="Caret"&&r.removeAllRanges(),r.rangeCount||t.forEach(function(n){r.addRange(n)}),e&&e.focus()}},$u=Nu,vs={"text/plain":"Text","text/html":"Url",default:"Text"},Ou="Copy to clipboard: #{key}, Enter";function Cu(r){var e=(/mac os x/i.test(navigator.userAgent)?"⌘":"Ctrl")+"+C";return r.replace(/#{\s*key\s*}/g,e)}function ku(r,e){var t,i,n,s,o,a,l=!1;e||(e={}),t=e.debug||!1;try{n=$u(),s=document.createRange(),o=document.getSelection(),a=document.createElement("span"),a.textContent=r,a.ariaHidden="true",a.style.all="unset",a.style.position="fixed",a.style.top=0,a.style.clip="rect(0, 0, 0, 0)",a.style.whiteSpace="pre",a.style.webkitUserSelect="text",a.style.MozUserSelect="text",a.style.msUserSelect="text",a.style.userSelect="text",a.addEventListener("copy",function(u){if(u.stopPropagation(),e.format)if(u.preventDefault(),typeof u.clipboardData>"u"){t&&console.warn("unable to use e.clipboardData"),t&&console.warn("trying IE specific stuff"),window.clipboardData.clearData();var h=vs[e.format]||vs.default;window.clipboardData.setData(h,r)}else u.clipboardData.clearData(),u.clipboardData.setData(e.format,r);e.onCopy&&(u.preventDefault(),e.onCopy(u.clipboardData))}),document.body.appendChild(a),s.selectNodeContents(a),o.addRange(s);var c=document.execCommand("copy");if(!c)throw new Error("copy command was unsuccessful");l=!0}catch(u){t&&console.error("unable to copy using execCommand: ",u),t&&console.warn("trying IE specific stuff");try{window.clipboardData.setData(e.format||"text",r),e.onCopy&&e.onCopy(window.clipboardData),l=!0}catch(h){t&&console.error("unable to copy using clipboardData: ",h),t&&console.error("falling back to prompt"),i=Cu("message"in e?e.message:Ou),window.prompt(i,r)}}finally{o&&(typeof o.removeRange=="function"?o.removeRange(s):o.removeAllRanges()),a&&document.body.removeChild(a),n()}return l}var Mu=ku,Lu={}.toString,$n=Array.isArray||function(r){return Lu.call(r)=="[object Array]"},Du=su(),On={},Y={};Object.defineProperty(Y,"__esModule",{value:!0});var Sa=Y.getLocalStorage=Ma=Y.getLocalStorageOrThrow=ka=Y.getCrypto=Ca=Y.getCryptoOrThrow=Oa=Y.getLocation=$a=Y.getLocationOrThrow=Na=Y.getNavigator=Ra=Y.getNavigatorOrThrow=Ta=Y.getDocument=Aa=Y.getDocumentOrThrow=Pa=Y.getFromWindowOrThrow=xa=Y.getFromWindow=void 0;function Ot(r){let e;return typeof window<"u"&&typeof window[r]<"u"&&(e=window[r]),e}var xa=Y.getFromWindow=Ot;function Zt(r){const e=Ot(r);if(!e)throw new Error(`${r} is not defined in Window`);return e}var Pa=Y.getFromWindowOrThrow=Zt;function Fu(){return Zt("document")}var Aa=Y.getDocumentOrThrow=Fu;function qu(){return Ot("document")}var Ta=Y.getDocument=qu;function Uu(){return Zt("navigator")}var Ra=Y.getNavigatorOrThrow=Uu;function Bu(){return Ot("navigator")}var Na=Y.getNavigator=Bu;function zu(){return Zt("location")}var $a=Y.getLocationOrThrow=zu;function Ku(){return Ot("location")}var Oa=Y.getLocation=Ku;function ju(){return Zt("crypto")}var Ca=Y.getCryptoOrThrow=ju;function Vu(){return Ot("crypto")}var ka=Y.getCrypto=Vu;function Wu(){return Zt("localStorage")}var Ma=Y.getLocalStorageOrThrow=Wu;function Hu(){return Ot("localStorage")}Sa=Y.getLocalStorage=Hu;Object.defineProperty(On,"__esModule",{value:!0});var La=On.getWindowMetadata=void 0;const ws=Y;function Ju(){let r,e;try{r=ws.getDocumentOrThrow(),e=ws.getLocationOrThrow()}catch{return null}function t(){const h=r.getElementsByTagName("link"),d=[];for(let f=0;f<h.length;f++){const p=h[f],g=p.getAttribute("rel");if(g&&g.toLowerCase().indexOf("icon")>-1){const y=p.getAttribute("href");if(y)if(y.toLowerCase().indexOf("https:")===-1&&y.toLowerCase().indexOf("http:")===-1&&y.indexOf("//")!==0){let m=e.protocol+"//"+e.host;if(y.indexOf("/")===0)m+=y;else{const v=e.pathname.split("/");v.pop();const _=v.join("/");m+=_+"/"+y}d.push(m)}else if(y.indexOf("//")===0){const m=e.protocol+y;d.push(m)}else d.push(y)}}return d}function i(...h){const d=r.getElementsByTagName("meta");for(let f=0;f<d.length;f++){const p=d[f],g=["itemprop","property","name"].map(y=>p.getAttribute(y)).filter(y=>y?h.includes(y):!1);if(g.length&&g){const y=p.getAttribute("content");if(y)return y}}return""}function n(){let h=i("name","og:site_name","og:title","twitter:title");return h||(h=r.title),h}function s(){return i("description","og:description","twitter:description","keywords")}const o=n(),a=s(),l=e.origin,c=t();return{description:a,url:l,icons:c,name:o}}La=On.getWindowMetadata=Ju;var Gu=function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var i=Array(r),n=0,e=0;e<t;e++)for(var s=arguments[e],o=0,a=s.length;o<a;o++,n++)i[n]=s[o];return i},Yu=function(){function r(e,t,i){this.name=e,this.version=t,this.os=i,this.type="browser"}return r}(),Qu=function(){function r(e){this.version=e,this.type="node",this.name="node",this.os=R.process.platform}return r}(),Xu=function(){function r(e,t,i,n){this.name=e,this.version=t,this.os=i,this.bot=n,this.type="bot-device"}return r}(),Zu=function(){function r(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null}return r}(),eh=function(){function r(){this.type="react-native",this.name="react-native",this.version=null,this.os=null}return r}(),th=/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/,rh=/(nuhk|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,_s=3,ih=[["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|$)/],["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",/FBAV\/([0-9\.]+)/],["instagram",/Instagram\s([0-9\.]+)/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Mobile/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Gecko\)$/],["searchbot",th]],bs=[["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/],["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 nh(r){return r?Es(r):typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new eh:typeof navigator<"u"?Es(navigator.userAgent):ah()}function sh(r){return r!==""&&ih.reduce(function(e,t){var i=t[0],n=t[1];if(e)return e;var s=n.exec(r);return!!s&&[i,s]},!1)}function Es(r){var e=sh(r);if(!e)return null;var t=e[0],i=e[1];if(t==="searchbot")return new Zu;var n=i[1]&&i[1].split(/[._]/).slice(0,3);n?n.length<_s&&(n=Gu(n,ch(_s-n.length))):n=[];var s=n.join("."),o=oh(r),a=rh.exec(r);return a&&a[1]?new Xu(t,s,o,a[1]):new Yu(t,s,o)}function oh(r){for(var e=0,t=bs.length;e<t;e++){var i=bs[e],n=i[0],s=i[1],o=s.exec(r);if(o)return n}return null}function ah(){var r=typeof R.process<"u"&&R.process.version;return r?new Qu(R.process.version.slice(1)):null}function ch(r){for(var e=[],t=0;t<r;t++)e.push("0");return e}function Cn(r){return nh(r)}function di(){const r=Cn();return r&&r.os?r.os:void 0}function Da(){const r=di();return r?r.toLowerCase().includes("android"):!1}function Fa(){const r=di();return r?r.toLowerCase().includes("ios")||r.toLowerCase().includes("mac")&&navigator.maxTouchPoints>1:!1}function lh(){return di()?Da()||Fa():!1}function qa(){const r=Cn();return r&&r.name?r.name.toLowerCase()==="node":!1}function uh(){return!qa()&&!!Ua()}const hh=xa,dh=Pa,fh=Aa,ph=Ta,gh=Ra,Ua=Na,yh=$a,mh=Oa,vh=Ca,wh=ka,_h=Ma,fi=Sa;function bh(){return La()}function Eh(r){if(typeof r!="string")throw new Error(`Cannot safe json parse value of type ${typeof r}`);try{return JSON.parse(r)}catch{return r}}function Ih(r){return typeof r=="string"?r:JSON.stringify(r)}const Ba=Eh,za=Ih;function Ka(r,e){const t=za(e),i=fi();i&&i.setItem(r,t)}function Sh(r){let e=null,t=null;const i=fi();return i&&(t=i.getItem(r)),e=t&&Ba(t),e}function xh(r){const e=fi();e&&e.removeItem(r)}const ja="WALLETCONNECT_DEEPLINK_CHOICE";function Ph(r,e){const t=encodeURIComponent(r);return e.universalLink?`${e.universalLink}/wc?uri=${t}`:e.deepLink?`${e.deepLink}${e.deepLink.endsWith(":")?"//":"/"}wc?uri=${t}`:""}function Ah(r){const e=r.href.split("?")[0];Ka(ja,Object.assign(Object.assign({},r),{href:e}))}function Va(r,e){return r.filter(t=>t.name.toLowerCase().includes(e.toLowerCase()))[0]}function Th(r,e){let t=r;return e&&(t=e.map(i=>Va(r,i)).filter(Boolean)),t}const Wa="https://registry.walletconnect.com";function Rh(){return Wa+"/api/v2/wallets"}function Nh(){return Wa+"/api/v2/dapps"}function Ha(r,e="mobile"){var t;return{name:r.name||"",shortName:r.metadata.shortName||"",color:r.metadata.colors.primary||"",logo:(t=r.image_url.sm)!==null&&t!==void 0?t:"",universalLink:r[e].universal||"",deepLink:r[e].native||""}}function $h(r,e="mobile"){return Object.values(r).filter(t=>!!t[e].universal||!!t[e].native).map(t=>Ha(t,e))}const Oh=Object.freeze(Object.defineProperty({__proto__:null,detectEnv:Cn,detectOS:di,formatIOSMobile:Ph,formatMobileRegistry:$h,formatMobileRegistryEntry:Ha,getClientMeta:bh,getCrypto:wh,getCryptoOrThrow:vh,getDappRegistryUrl:Nh,getDocument:ph,getDocumentOrThrow:fh,getFromWindow:hh,getFromWindowOrThrow:dh,getLocal:Sh,getLocalStorage:fi,getLocalStorageOrThrow:_h,getLocation:mh,getLocationOrThrow:yh,getMobileLinkRegistry:Th,getMobileRegistryEntry:Va,getNavigator:Ua,getNavigatorOrThrow:gh,getWalletRegistryUrl:Rh,isAndroid:Da,isBrowser:uh,isIOS:Fa,isMobile:lh,isNode:qa,mobileLinkChoiceKey:ja,removeLocal:xh,safeJsonParse:Ba,safeJsonStringify:za,saveMobileLinkInfo:Ah,setLocal:Ka},Symbol.toStringTag,{value:"Module"})),Ch=va(Oh);var Pr={},kh=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then},Ja={},yt={},Mh=$n;function Lh(){try{var r=new Uint8Array(1);return r.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},r.foo()===42}catch{return!1}}z.TYPED_ARRAY_SUPPORT=Lh();var Is=z.TYPED_ARRAY_SUPPORT?2147483647:1073741823;function z(r,e,t){return!z.TYPED_ARRAY_SUPPORT&&!(this instanceof z)?new z(r,e,t):typeof r=="number"?Ga(this,r):Kh(this,r,e,t)}z.TYPED_ARRAY_SUPPORT&&(z.prototype.__proto__=Uint8Array.prototype,z.__proto__=Uint8Array,typeof Symbol<"u"&&Symbol.species&&z[Symbol.species]===z&&Object.defineProperty(z,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}));function kn(r){if(r>=Is)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Is.toString(16)+" bytes");return r|0}function Dh(r){return r!==r}function Kt(r,e){var t;return z.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e),t.__proto__=z.prototype):(t=r,t===null&&(t=new z(e)),t.length=e),t}function Ga(r,e){var t=Kt(r,e<0?0:kn(e)|0);if(!z.TYPED_ARRAY_SUPPORT)for(var i=0;i<e;++i)t[i]=0;return t}function Fh(r,e){var t=Qa(e)|0,i=Kt(r,t),n=i.write(e);return n!==t&&(i=i.slice(0,n)),i}function rn(r,e){for(var t=e.length<0?0:kn(e.length)|0,i=Kt(r,t),n=0;n<t;n+=1)i[n]=e[n]&255;return i}function qh(r,e,t,i){if(t<0||e.byteLength<t)throw new RangeError("'offset' is out of bounds");if(e.byteLength<t+(i||0))throw new RangeError("'length' is out of bounds");var n;return t===void 0&&i===void 0?n=new Uint8Array(e):i===void 0?n=new Uint8Array(e,t):n=new Uint8Array(e,t,i),z.TYPED_ARRAY_SUPPORT?n.__proto__=z.prototype:n=rn(r,n),n}function Uh(r,e){if(z.isBuffer(e)){var t=kn(e.length)|0,i=Kt(r,t);return i.length===0||e.copy(i,0,0,t),i}if(e){if(typeof ArrayBuffer<"u"&&e.buffer instanceof ArrayBuffer||"length"in e)return typeof e.length!="number"||Dh(e.length)?Kt(r,0):rn(r,e);if(e.type==="Buffer"&&Array.isArray(e.data))return rn(r,e.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function Ya(r,e){e=e||1/0;for(var t,i=r.length,n=null,s=[],o=0;o<i;++o){if(t=r.charCodeAt(o),t>55295&&t<57344){if(!n){if(t>56319){(e-=3)>-1&&s.push(239,191,189);continue}else if(o+1===i){(e-=3)>-1&&s.push(239,191,189);continue}n=t;continue}if(t<56320){(e-=3)>-1&&s.push(239,191,189),n=t;continue}t=(n-55296<<10|t-56320)+65536}else n&&(e-=3)>-1&&s.push(239,191,189);if(n=null,t<128){if((e-=1)<0)break;s.push(t)}else if(t<2048){if((e-=2)<0)break;s.push(t>>6|192,t&63|128)}else if(t<65536){if((e-=3)<0)break;s.push(t>>12|224,t>>6&63|128,t&63|128)}else if(t<1114112){if((e-=4)<0)break;s.push(t>>18|240,t>>12&63|128,t>>6&63|128,t&63|128)}else throw new Error("Invalid code point")}return s}function Qa(r){if(z.isBuffer(r))return r.length;if(typeof ArrayBuffer<"u"&&typeof ArrayBuffer.isView=="function"&&(ArrayBuffer.isView(r)||r instanceof ArrayBuffer))return r.byteLength;typeof r!="string"&&(r=""+r);var e=r.length;return e===0?0:Ya(r).length}function Bh(r,e,t,i){for(var n=0;n<i&&!(n+t>=e.length||n>=r.length);++n)e[n+t]=r[n];return n}function zh(r,e,t,i){return Bh(Ya(e,r.length-t),r,t,i)}function Kh(r,e,t,i){if(typeof e=="number")throw new TypeError('"value" argument must not be a number');return typeof ArrayBuffer<"u"&&e instanceof ArrayBuffer?qh(r,e,t,i):typeof e=="string"?Fh(r,e):Uh(r,e)}z.prototype.write=function(e,t,i){t===void 0?(i=this.length,t=0):i===void 0&&typeof t=="string"?(i=this.length,t=0):isFinite(t)&&(t=t|0,isFinite(i)?i=i|0:i=void 0);var n=this.length-t;if((i===void 0||i>n)&&(i=n),e.length>0&&(i<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");return zh(this,e,t,i)};z.prototype.slice=function(e,t){var i=this.length;e=~~e,t=t===void 0?i:~~t,e<0?(e+=i,e<0&&(e=0)):e>i&&(e=i),t<0?(t+=i,t<0&&(t=0)):t>i&&(t=i),t<e&&(t=e);var n;if(z.TYPED_ARRAY_SUPPORT)n=this.subarray(e,t),n.__proto__=z.prototype;else{var s=t-e;n=new z(s,void 0);for(var o=0;o<s;++o)n[o]=this[o+e]}return n};z.prototype.copy=function(e,t,i,n){if(i||(i=0),!n&&n!==0&&(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<i&&(n=i),n===i||e.length===0||this.length===0)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(i<0||i>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t<n-i&&(n=e.length-t+i);var s=n-i,o;if(this===e&&i<t&&t<n)for(o=s-1;o>=0;--o)e[o+t]=this[o+i];else if(s<1e3||!z.TYPED_ARRAY_SUPPORT)for(o=0;o<s;++o)e[o+t]=this[o+i];else Uint8Array.prototype.set.call(e,this.subarray(i,i+s),t);return s};z.prototype.fill=function(e,t,i){if(typeof e=="string"){if(typeof t=="string"?(t=0,i=this.length):typeof i=="string"&&(i=this.length),e.length===1){var n=e.charCodeAt(0);n<256&&(e=n)}}else typeof e=="number"&&(e=e&255);if(t<0||this.length<t||this.length<i)throw new RangeError("Out of range index");if(i<=t)return this;t=t>>>0,i=i===void 0?this.length:i>>>0,e||(e=0);var s;if(typeof e=="number")for(s=t;s<i;++s)this[s]=e;else{var o=z.isBuffer(e)?e:new z(e),a=o.length;for(s=0;s<i-t;++s)this[s+t]=o[s%a]}return this};z.concat=function(e,t){if(!Mh(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return Kt(null,0);var i;if(t===void 0)for(t=0,i=0;i<e.length;++i)t+=e[i].length;var n=Ga(null,t),s=0;for(i=0;i<e.length;++i){var o=e[i];if(!z.isBuffer(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(n,s),s+=o.length}return n};z.byteLength=Qa;z.prototype._isBuffer=!0;z.isBuffer=function(e){return!!(e!=null&&e._isBuffer)};yt.alloc=function(r){var e=new z(r);return e.fill(0),e};yt.from=function(r){return new z(r)};var Se={},Mn,jh=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];Se.getSymbolSize=function(e){if(!e)throw new Error('"version" cannot be null or undefined');if(e<1||e>40)throw new Error('"version" should be in range from 1 to 40');return e*4+17};Se.getSymbolTotalCodewords=function(e){return jh[e]};Se.getBCHDigit=function(r){for(var e=0;r!==0;)e++,r>>>=1;return e};Se.setToSJISFunction=function(e){if(typeof e!="function")throw new Error('"toSJISFunc" is not a valid function.');Mn=e};Se.isKanjiModeEnabled=function(){return typeof Mn<"u"};Se.toSJIS=function(e){return Mn(e)};var pi={};(function(r){r.L={bit:1},r.M={bit:0},r.Q={bit:3},r.H={bit:2};function e(t){if(typeof t!="string")throw new Error("Param is not a string");var i=t.toLowerCase();switch(i){case"l":case"low":return r.L;case"m":case"medium":return r.M;case"q":case"quartile":return r.Q;case"h":case"high":return r.H;default:throw new Error("Unknown EC Level: "+t)}}r.isValid=function(i){return i&&typeof i.bit<"u"&&i.bit>=0&&i.bit<4},r.from=function(i,n){if(r.isValid(i))return i;try{return e(i)}catch{return n}}})(pi);function Xa(){this.buffer=[],this.length=0}Xa.prototype={get:function(r){var e=Math.floor(r/8);return(this.buffer[e]>>>7-r%8&1)===1},put:function(r,e){for(var t=0;t<e;t++)this.putBit((r>>>e-t-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(r){var e=Math.floor(this.length/8);this.buffer.length<=e&&this.buffer.push(0),r&&(this.buffer[e]|=128>>>this.length%8),this.length++}};var Vh=Xa,Ss=yt;function Ar(r){if(!r||r<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=r,this.data=Ss.alloc(r*r),this.reservedBit=Ss.alloc(r*r)}Ar.prototype.set=function(r,e,t,i){var n=r*this.size+e;this.data[n]=t,i&&(this.reservedBit[n]=!0)};Ar.prototype.get=function(r,e){return this.data[r*this.size+e]};Ar.prototype.xor=function(r,e,t){this.data[r*this.size+e]^=t};Ar.prototype.isReserved=function(r,e){return this.reservedBit[r*this.size+e]};var Wh=Ar,Za={};(function(r){var e=Se.getSymbolSize;r.getRowColCoords=function(i){if(i===1)return[];for(var n=Math.floor(i/7)+2,s=e(i),o=s===145?26:Math.ceil((s-13)/(2*n-2))*2,a=[s-7],l=1;l<n-1;l++)a[l]=a[l-1]-o;return a.push(6),a.reverse()},r.getPositions=function(i){for(var n=[],s=r.getRowColCoords(i),o=s.length,a=0;a<o;a++)for(var l=0;l<o;l++)a===0&&l===0||a===0&&l===o-1||a===o-1&&l===0||n.push([s[a],s[l]]);return n}})(Za);var ec={},Hh=Se.getSymbolSize,xs=7;ec.getPositions=function(e){var t=Hh(e);return[[0,0],[t-xs,0],[0,t-xs]]};var tc={};(function(r){r.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};var e={N1:3,N2:3,N3:40,N4:10};r.isValid=function(n){return n!=null&&n!==""&&!isNaN(n)&&n>=0&&n<=7},r.from=function(n){return r.isValid(n)?parseInt(n,10):void 0},r.getPenaltyN1=function(n){for(var s=n.size,o=0,a=0,l=0,c=null,u=null,h=0;h<s;h++){a=l=0,c=u=null;for(var d=0;d<s;d++){var f=n.get(h,d);f===c?a++:(a>=5&&(o+=e.N1+(a-5)),c=f,a=1),f=n.get(d,h),f===u?l++:(l>=5&&(o+=e.N1+(l-5)),u=f,l=1)}a>=5&&(o+=e.N1+(a-5)),l>=5&&(o+=e.N1+(l-5))}return o},r.getPenaltyN2=function(n){for(var s=n.size,o=0,a=0;a<s-1;a++)for(var l=0;l<s-1;l++){var c=n.get(a,l)+n.get(a,l+1)+n.get(a+1,l)+n.get(a+1,l+1);(c===4||c===0)&&o++}return o*e.N2},r.getPenaltyN3=function(n){for(var s=n.size,o=0,a=0,l=0,c=0;c<s;c++){a=l=0;for(var u=0;u<s;u++)a=a<<1&2047|n.get(c,u),u>=10&&(a===1488||a===93)&&o++,l=l<<1&2047|n.get(u,c),u>=10&&(l===1488||l===93)&&o++}return o*e.N3},r.getPenaltyN4=function(n){for(var s=0,o=n.data.length,a=0;a<o;a++)s+=n.data[a];var l=Math.abs(Math.ceil(s*100/o/5)-10);return l*e.N4};function t(i,n,s){switch(i){case r.Patterns.PATTERN000:return(n+s)%2===0;case r.Patterns.PATTERN001:return n%2===0;case r.Patterns.PATTERN010:return s%3===0;case r.Patterns.PATTERN011:return(n+s)%3===0;case r.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(s/3))%2===0;case r.Patterns.PATTERN101:return n*s%2+n*s%3===0;case r.Patterns.PATTERN110:return(n*s%2+n*s%3)%2===0;case r.Patterns.PATTERN111:return(n*s%3+(n+s)%2)%2===0;default:throw new Error("bad maskPattern:"+i)}}r.applyMask=function(n,s){for(var o=s.size,a=0;a<o;a++)for(var l=0;l<o;l++)s.isReserved(l,a)||s.xor(l,a,t(n,l,a))},r.getBestMask=function(n,s){for(var o=Object.keys(r.Patterns).length,a=0,l=1/0,c=0;c<o;c++){s(c),r.applyMask(c,n);var u=r.getPenaltyN1(n)+r.getPenaltyN2(n)+r.getPenaltyN3(n)+r.getPenaltyN4(n);r.applyMask(c,n),u<l&&(l=u,a=c)}return a}})(tc);var gi={},ut=pi,Lr=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],Dr=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];gi.getBlocksCount=function(e,t){switch(t){case ut.L:return Lr[(e-1)*4+0];case ut.M:return Lr[(e-1)*4+1];case ut.Q:return Lr[(e-1)*4+2];case ut.H:return Lr[(e-1)*4+3];default:return}};gi.getTotalCodewordsCount=function(e,t){switch(t){case ut.L:return Dr[(e-1)*4+0];case ut.M:return Dr[(e-1)*4+1];case ut.Q:return Dr[(e-1)*4+2];case ut.H:return Dr[(e-1)*4+3];default:return}};var rc={},yi={},ic=yt,gr=ic.alloc(512),Xr=ic.alloc(256);(function(){for(var e=1,t=0;t<255;t++)gr[t]=e,Xr[e]=t,e<<=1,e&256&&(e^=285);for(t=255;t<512;t++)gr[t]=gr[t-255]})();yi.log=function(e){if(e<1)throw new Error("log("+e+")");return Xr[e]};yi.exp=function(e){return gr[e]};yi.mul=function(e,t){return e===0||t===0?0:gr[Xr[e]+Xr[t]]};(function(r){var e=yt,t=yi;r.mul=function(n,s){for(var o=e.alloc(n.length+s.length-1),a=0;a<n.length;a++)for(var l=0;l<s.length;l++)o[a+l]^=t.mul(n[a],s[l]);return o},r.mod=function(n,s){for(var o=e.from(n);o.length-s.length>=0;){for(var a=o[0],l=0;l<s.length;l++)o[l]^=t.mul(s[l],a);for(var c=0;c<o.length&&o[c]===0;)c++;o=o.slice(c)}return o},r.generateECPolynomial=function(n){for(var s=e.from([1]),o=0;o<n;o++)s=r.mul(s,[1,t.exp(o)]);return s}})(rc);var Ps=yt,nc=rc,Jh=ou.Buffer;function Ln(r){this.genPoly=void 0,this.degree=r,this.degree&&this.initialize(this.degree)}Ln.prototype.initialize=function(e){this.degree=e,this.genPoly=nc.generateECPolynomial(this.degree)};Ln.prototype.encode=function(e){if(!this.genPoly)throw new Error("Encoder not initialized");var t=Ps.alloc(this.degree),i=Jh.concat([e,t],e.length+this.degree),n=nc.mod(i,this.genPoly),s=this.degree-n.length;if(s>0){var o=Ps.alloc(this.degree);return n.copy(o,s),o}return n};var Gh=Ln,sc={},mt={},Dn={};Dn.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40};var Ye={},oc="[0-9]+",Yh="[A-Z $%*+\\-./:]+",_r="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";_r=_r.replace(/u/g,"\\u");var Qh="(?:(?![A-Z0-9 $%*+\\-./:]|"+_r+`)(?:.|[\r
2
- ]))+`;Ye.KANJI=new RegExp(_r,"g");Ye.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g");Ye.BYTE=new RegExp(Qh,"g");Ye.NUMERIC=new RegExp(oc,"g");Ye.ALPHANUMERIC=new RegExp(Yh,"g");var Xh=new RegExp("^"+_r+"$"),Zh=new RegExp("^"+oc+"$"),ed=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");Ye.testKanji=function(e){return Xh.test(e)};Ye.testNumeric=function(e){return Zh.test(e)};Ye.testAlphanumeric=function(e){return ed.test(e)};(function(r){var e=Dn,t=Ye;r.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},r.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},r.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},r.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},r.MIXED={bit:-1},r.getCharCountIndicator=function(s,o){if(!s.ccBits)throw new Error("Invalid mode: "+s);if(!e.isValid(o))throw new Error("Invalid version: "+o);return o>=1&&o<10?s.ccBits[0]:o<27?s.ccBits[1]:s.ccBits[2]},r.getBestModeForData=function(s){return t.testNumeric(s)?r.NUMERIC:t.testAlphanumeric(s)?r.ALPHANUMERIC:t.testKanji(s)?r.KANJI:r.BYTE},r.toString=function(s){if(s&&s.id)return s.id;throw new Error("Invalid mode")},r.isValid=function(s){return s&&s.bit&&s.ccBits};function i(n){if(typeof n!="string")throw new Error("Param is not a string");var s=n.toLowerCase();switch(s){case"numeric":return r.NUMERIC;case"alphanumeric":return r.ALPHANUMERIC;case"kanji":return r.KANJI;case"byte":return r.BYTE;default:throw new Error("Unknown mode: "+n)}}r.from=function(s,o){if(r.isValid(s))return s;try{return i(s)}catch{return o}}})(mt);(function(r){var e=Se,t=gi,i=pi,n=mt,s=Dn,o=$n,a=7973,l=e.getBCHDigit(a);function c(f,p,g){for(var y=1;y<=40;y++)if(p<=r.getCapacity(y,g,f))return y}function u(f,p){return n.getCharCountIndicator(f,p)+4}function h(f,p){var g=0;return f.forEach(function(y){var m=u(y.mode,p);g+=m+y.getBitsLength()}),g}function d(f,p){for(var g=1;g<=40;g++){var y=h(f,g);if(y<=r.getCapacity(g,p,n.MIXED))return g}}r.from=function(p,g){return s.isValid(p)?parseInt(p,10):g},r.getCapacity=function(p,g,y){if(!s.isValid(p))throw new Error("Invalid QR Code version");typeof y>"u"&&(y=n.BYTE);var m=e.getSymbolTotalCodewords(p),v=t.getTotalCodewordsCount(p,g),_=(m-v)*8;if(y===n.MIXED)return _;var w=_-u(y,p);switch(y){case n.NUMERIC:return Math.floor(w/10*3);case n.ALPHANUMERIC:return Math.floor(w/11*2);case n.KANJI:return Math.floor(w/13);case n.BYTE:default:return Math.floor(w/8)}},r.getBestVersionForData=function(p,g){var y,m=i.from(g,i.M);if(o(p)){if(p.length>1)return d(p,m);if(p.length===0)return 1;y=p[0]}else y=p;return c(y.mode,y.getLength(),m)},r.getEncodedBits=function(p){if(!s.isValid(p)||p<7)throw new Error("Invalid QR Code version");for(var g=p<<12;e.getBCHDigit(g)-l>=0;)g^=a<<e.getBCHDigit(g)-l;return p<<12|g}})(sc);var ac={},nn=Se,cc=1335,td=21522,As=nn.getBCHDigit(cc);ac.getEncodedBits=function(e,t){for(var i=e.bit<<3|t,n=i<<10;nn.getBCHDigit(n)-As>=0;)n^=cc<<nn.getBCHDigit(n)-As;return(i<<10|n)^td};var lc={},rd=mt;function jt(r){this.mode=rd.NUMERIC,this.data=r.toString()}jt.getBitsLength=function(e){return 10*Math.floor(e/3)+(e%3?e%3*3+1:0)};jt.prototype.getLength=function(){return this.data.length};jt.prototype.getBitsLength=function(){return jt.getBitsLength(this.data.length)};jt.prototype.write=function(e){var t,i,n;for(t=0;t+3<=this.data.length;t+=3)i=this.data.substr(t,3),n=parseInt(i,10),e.put(n,10);var s=this.data.length-t;s>0&&(i=this.data.substr(t),n=parseInt(i,10),e.put(n,s*3+1))};var id=jt,nd=mt,Oi=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function Vt(r){this.mode=nd.ALPHANUMERIC,this.data=r}Vt.getBitsLength=function(e){return 11*Math.floor(e/2)+6*(e%2)};Vt.prototype.getLength=function(){return this.data.length};Vt.prototype.getBitsLength=function(){return Vt.getBitsLength(this.data.length)};Vt.prototype.write=function(e){var t;for(t=0;t+2<=this.data.length;t+=2){var i=Oi.indexOf(this.data[t])*45;i+=Oi.indexOf(this.data[t+1]),e.put(i,11)}this.data.length%2&&e.put(Oi.indexOf(this.data[t]),6)};var sd=Vt,od=yt,ad=mt;function Wt(r){this.mode=ad.BYTE,this.data=od.from(r)}Wt.getBitsLength=function(e){return e*8};Wt.prototype.getLength=function(){return this.data.length};Wt.prototype.getBitsLength=function(){return Wt.getBitsLength(this.data.length)};Wt.prototype.write=function(r){for(var e=0,t=this.data.length;e<t;e++)r.put(this.data[e],8)};var cd=Wt,ld=mt,ud=Se;function Ht(r){this.mode=ld.KANJI,this.data=r}Ht.getBitsLength=function(e){return e*13};Ht.prototype.getLength=function(){return this.data.length};Ht.prototype.getBitsLength=function(){return Ht.getBitsLength(this.data.length)};Ht.prototype.write=function(r){var e;for(e=0;e<this.data.length;e++){var t=ud.toSJIS(this.data[e]);if(t>=33088&&t<=40956)t-=33088;else if(t>=57408&&t<=60351)t-=49472;else throw new Error("Invalid SJIS character: "+this.data[e]+`
3
- Make sure your charset is UTF-8`);t=(t>>>8&255)*192+(t&255),r.put(t,13)}};var hd=Ht;(function(r){var e=mt,t=id,i=sd,n=cd,s=hd,o=Ye,a=Se,l=lu;function c(m){return unescape(encodeURIComponent(m)).length}function u(m,v,_){for(var w=[],b;(b=m.exec(_))!==null;)w.push({data:b[0],index:b.index,mode:v,length:b[0].length});return w}function h(m){var v=u(o.NUMERIC,e.NUMERIC,m),_=u(o.ALPHANUMERIC,e.ALPHANUMERIC,m),w,b;a.isKanjiModeEnabled()?(w=u(o.BYTE,e.BYTE,m),b=u(o.KANJI,e.KANJI,m)):(w=u(o.BYTE_KANJI,e.BYTE,m),b=[]);var E=v.concat(_,w,b);return E.sort(function(I,x){return I.index-x.index}).map(function(I){return{data:I.data,mode:I.mode,length:I.length}})}function d(m,v){switch(v){case e.NUMERIC:return t.getBitsLength(m);case e.ALPHANUMERIC:return i.getBitsLength(m);case e.KANJI:return s.getBitsLength(m);case e.BYTE:return n.getBitsLength(m)}}function f(m){return m.reduce(function(v,_){var w=v.length-1>=0?v[v.length-1]:null;return w&&w.mode===_.mode?(v[v.length-1].data+=_.data,v):(v.push(_),v)},[])}function p(m){for(var v=[],_=0;_<m.length;_++){var w=m[_];switch(w.mode){case e.NUMERIC:v.push([w,{data:w.data,mode:e.ALPHANUMERIC,length:w.length},{data:w.data,mode:e.BYTE,length:w.length}]);break;case e.ALPHANUMERIC:v.push([w,{data:w.data,mode:e.BYTE,length:w.length}]);break;case e.KANJI:v.push([w,{data:w.data,mode:e.BYTE,length:c(w.data)}]);break;case e.BYTE:v.push([{data:w.data,mode:e.BYTE,length:c(w.data)}])}}return v}function g(m,v){for(var _={},w={start:{}},b=["start"],E=0;E<m.length;E++){for(var I=m[E],x=[],N=0;N<I.length;N++){var $=I[N],O=""+E+N;x.push(O),_[O]={node:$,lastCount:0},w[O]={};for(var D=0;D<b.length;D++){var C=b[D];_[C]&&_[C].node.mode===$.mode?(w[C][O]=d(_[C].lastCount+$.length,$.mode)-d(_[C].lastCount,$.mode),_[C].lastCount+=$.length):(_[C]&&(_[C].lastCount=$.length),w[C][O]=d($.length,$.mode)+4+e.getCharCountIndicator($.mode,v))}}b=x}for(D=0;D<b.length;D++)w[b[D]].end=0;return{map:w,table:_}}function y(m,v){var _,w=e.getBestModeForData(m);if(_=e.from(v,w),_!==e.BYTE&&_.bit<w.bit)throw new Error('"'+m+'" cannot be encoded with mode '+e.toString(_)+`.
4
- Suggested mode is: `+e.toString(w));switch(_===e.KANJI&&!a.isKanjiModeEnabled()&&(_=e.BYTE),_){case e.NUMERIC:return new t(m);case e.ALPHANUMERIC:return new i(m);case e.KANJI:return new s(m);case e.BYTE:return new n(m)}}r.fromArray=function(v){return v.reduce(function(_,w){return typeof w=="string"?_.push(y(w,null)):w.data&&_.push(y(w.data,w.mode)),_},[])},r.fromString=function(v,_){for(var w=h(v,a.isKanjiModeEnabled()),b=p(w),E=g(b,_),I=l.find_path(E.map,"start","end"),x=[],N=1;N<I.length-1;N++)x.push(E.table[I[N]].node);return r.fromArray(f(x))},r.rawSplit=function(v){return r.fromArray(h(v,a.isKanjiModeEnabled()))}})(lc);var Ts=yt,mi=Se,Ci=pi,dd=Vh,fd=Wh,pd=Za,gd=ec,sn=tc,on=gi,yd=Gh,Zr=sc,md=ac,vd=mt,ki=lc,wd=$n;function _d(r,e){for(var t=r.size,i=gd.getPositions(e),n=0;n<i.length;n++)for(var s=i[n][0],o=i[n][1],a=-1;a<=7;a++)if(!(s+a<=-1||t<=s+a))for(var l=-1;l<=7;l++)o+l<=-1||t<=o+l||(a>=0&&a<=6&&(l===0||l===6)||l>=0&&l<=6&&(a===0||a===6)||a>=2&&a<=4&&l>=2&&l<=4?r.set(s+a,o+l,!0,!0):r.set(s+a,o+l,!1,!0))}function bd(r){for(var e=r.size,t=8;t<e-8;t++){var i=t%2===0;r.set(t,6,i,!0),r.set(6,t,i,!0)}}function Ed(r,e){for(var t=pd.getPositions(e),i=0;i<t.length;i++)for(var n=t[i][0],s=t[i][1],o=-2;o<=2;o++)for(var a=-2;a<=2;a++)o===-2||o===2||a===-2||a===2||o===0&&a===0?r.set(n+o,s+a,!0,!0):r.set(n+o,s+a,!1,!0)}function Id(r,e){for(var t=r.size,i=Zr.getEncodedBits(e),n,s,o,a=0;a<18;a++)n=Math.floor(a/3),s=a%3+t-8-3,o=(i>>a&1)===1,r.set(n,s,o,!0),r.set(s,n,o,!0)}function Mi(r,e,t){var i=r.size,n=md.getEncodedBits(e,t),s,o;for(s=0;s<15;s++)o=(n>>s&1)===1,s<6?r.set(s,8,o,!0):s<8?r.set(s+1,8,o,!0):r.set(i-15+s,8,o,!0),s<8?r.set(8,i-s-1,o,!0):s<9?r.set(8,15-s-1+1,o,!0):r.set(8,15-s-1,o,!0);r.set(i-8,8,1,!0)}function Sd(r,e){for(var t=r.size,i=-1,n=t-1,s=7,o=0,a=t-1;a>0;a-=2)for(a===6&&a--;;){for(var l=0;l<2;l++)if(!r.isReserved(n,a-l)){var c=!1;o<e.length&&(c=(e[o]>>>s&1)===1),r.set(n,a-l,c),s--,s===-1&&(o++,s=7)}if(n+=i,n<0||t<=n){n-=i,i=-i;break}}}function xd(r,e,t){var i=new dd;t.forEach(function(c){i.put(c.mode.bit,4),i.put(c.getLength(),vd.getCharCountIndicator(c.mode,r)),c.write(i)});var n=mi.getSymbolTotalCodewords(r),s=on.getTotalCodewordsCount(r,e),o=(n-s)*8;for(i.getLengthInBits()+4<=o&&i.put(0,4);i.getLengthInBits()%8!==0;)i.putBit(0);for(var a=(o-i.getLengthInBits())/8,l=0;l<a;l++)i.put(l%2?17:236,8);return Pd(i,r,e)}function Pd(r,e,t){for(var i=mi.getSymbolTotalCodewords(e),n=on.getTotalCodewordsCount(e,t),s=i-n,o=on.getBlocksCount(e,t),a=i%o,l=o-a,c=Math.floor(i/o),u=Math.floor(s/o),h=u+1,d=c-u,f=new yd(d),p=0,g=new Array(o),y=new Array(o),m=0,v=Ts.from(r.buffer),_=0;_<o;_++){var w=_<l?u:h;g[_]=v.slice(p,p+w),y[_]=f.encode(g[_]),p+=w,m=Math.max(m,w)}var b=Ts.alloc(i),E=0,I,x;for(I=0;I<m;I++)for(x=0;x<o;x++)I<g[x].length&&(b[E++]=g[x][I]);for(I=0;I<d;I++)for(x=0;x<o;x++)b[E++]=y[x][I];return b}function Ad(r,e,t,i){var n;if(wd(r))n=ki.fromArray(r);else if(typeof r=="string"){var s=e;if(!s){var o=ki.rawSplit(r);s=Zr.getBestVersionForData(o,t)}n=ki.fromString(r,s||40)}else throw new Error("Invalid data");var a=Zr.getBestVersionForData(n,t);if(!a)throw new Error("The amount of data is too big to be stored in a QR Code");if(!e)e=a;else if(e<a)throw new Error(`
5
- The chosen QR Code version cannot contain this amount of data.
6
- Minimum version required to store current data is: `+a+`.
7
- `);var l=xd(e,t,n),c=mi.getSymbolSize(e),u=new fd(c);return _d(u,e),bd(u),Ed(u,e),Mi(u,t,0),e>=7&&Id(u,e),Sd(u,l),isNaN(i)&&(i=sn.getBestMask(u,Mi.bind(null,u,t))),sn.applyMask(i,u),Mi(u,t,i),{modules:u,version:e,errorCorrectionLevel:t,maskPattern:i,segments:n}}Ja.create=function(e,t){if(typeof e>"u"||e==="")throw new Error("No input text");var i=Ci.M,n,s;return typeof t<"u"&&(i=Ci.from(t.errorCorrectionLevel,Ci.M),n=Zr.from(t.version),s=sn.from(t.maskPattern),t.toSJISFunc&&mi.setToSJISFunction(t.toSJISFunc)),Ad(e,n,i,s)};var uc={},Fn={};(function(r){function e(t){if(typeof t=="number"&&(t=t.toString()),typeof t!="string")throw new Error("Color should be defined as hex string");var i=t.slice().replace("#","").split("");if(i.length<3||i.length===5||i.length>8)throw new Error("Invalid hex color: "+t);(i.length===3||i.length===4)&&(i=Array.prototype.concat.apply([],i.map(function(s){return[s,s]}))),i.length===6&&i.push("F","F");var n=parseInt(i.join(""),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:n&255,hex:"#"+i.slice(0,6).join("")}}r.getOptions=function(i){i||(i={}),i.color||(i.color={});var n=typeof i.margin>"u"||i.margin===null||i.margin<0?4:i.margin,s=i.width&&i.width>=21?i.width:void 0,o=i.scale||4;return{width:s,scale:s?4:o,margin:n,color:{dark:e(i.color.dark||"#000000ff"),light:e(i.color.light||"#ffffffff")},type:i.type,rendererOpts:i.rendererOpts||{}}},r.getScale=function(i,n){return n.width&&n.width>=i+n.margin*2?n.width/(i+n.margin*2):n.scale},r.getImageWidth=function(i,n){var s=r.getScale(i,n);return Math.floor((i+n.margin*2)*s)},r.qrToImageData=function(i,n,s){for(var o=n.modules.size,a=n.modules.data,l=r.getScale(o,s),c=Math.floor((o+s.margin*2)*l),u=s.margin*l,h=[s.color.light,s.color.dark],d=0;d<c;d++)for(var f=0;f<c;f++){var p=(d*c+f)*4,g=s.color.light;if(d>=u&&f>=u&&d<c-u&&f<c-u){var y=Math.floor((d-u)/l),m=Math.floor((f-u)/l);g=h[a[y*o+m]?1:0]}i[p++]=g.r,i[p++]=g.g,i[p++]=g.b,i[p]=g.a}}})(Fn);(function(r){var e=Fn;function t(n,s,o){n.clearRect(0,0,s.width,s.height),s.style||(s.style={}),s.height=o,s.width=o,s.style.height=o+"px",s.style.width=o+"px"}function i(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}r.render=function(s,o,a){var l=a,c=o;typeof l>"u"&&(!o||!o.getContext)&&(l=o,o=void 0),o||(c=i()),l=e.getOptions(l);var u=e.getImageWidth(s.modules.size,l),h=c.getContext("2d"),d=h.createImageData(u,u);return e.qrToImageData(d.data,s,l),t(h,c,u),h.putImageData(d,0,0),c},r.renderToDataURL=function(s,o,a){var l=a;typeof l>"u"&&(!o||!o.getContext)&&(l=o,o=void 0),l||(l={});var c=r.render(s,o,l),u=l.type||"image/png",h=l.rendererOpts||{};return c.toDataURL(u,h.quality)}})(uc);var hc={},Td=Fn;function Rs(r,e){var t=r.a/255,i=e+'="'+r.hex+'"';return t<1?i+" "+e+'-opacity="'+t.toFixed(2).slice(1)+'"':i}function Li(r,e,t){var i=r+e;return typeof t<"u"&&(i+=" "+t),i}function Rd(r,e,t){for(var i="",n=0,s=!1,o=0,a=0;a<r.length;a++){var l=Math.floor(a%e),c=Math.floor(a/e);!l&&!s&&(s=!0),r[a]?(o++,a>0&&l>0&&r[a-1]||(i+=s?Li("M",l+t,.5+c+t):Li("m",n,0),n=0,s=!1),l+1<e&&r[a+1]||(i+=Li("h",o),o=0)):n++}return i}hc.render=function(e,t,i){var n=Td.getOptions(t),s=e.modules.size,o=e.modules.data,a=s+n.margin*2,l=n.color.light.a?"<path "+Rs(n.color.light,"fill")+' d="M0 0h'+a+"v"+a+'H0z"/>':"",c="<path "+Rs(n.color.dark,"stroke")+' d="'+Rd(o,s,n.margin)+'"/>',u='viewBox="0 0 '+a+" "+a+'"',h=n.width?'width="'+n.width+'" height="'+n.width+'" ':"",d='<svg xmlns="http://www.w3.org/2000/svg" '+h+u+' shape-rendering="crispEdges">'+l+c+`</svg>
8
- `;return typeof i=="function"&&i(null,d),d};var Nd=kh,an=Ja,dc=uc,$d=hc;function qn(r,e,t,i,n){var s=[].slice.call(arguments,1),o=s.length,a=typeof s[o-1]=="function";if(!a&&!Nd())throw new Error("Callback required as last argument");if(a){if(o<2)throw new Error("Too few arguments provided");o===2?(n=t,t=e,e=i=void 0):o===3&&(e.getContext&&typeof n>"u"?(n=i,i=void 0):(n=i,i=t,t=e,e=void 0))}else{if(o<1)throw new Error("Too few arguments provided");return o===1?(t=e,e=i=void 0):o===2&&!e.getContext&&(i=t,t=e,e=void 0),new Promise(function(c,u){try{var h=an.create(t,i);c(r(h,e,i))}catch(d){u(d)}})}try{var l=an.create(t,i);n(null,r(l,e,i))}catch(c){n(c)}}Pr.create=an.create;Pr.toCanvas=qn.bind(null,dc.render);Pr.toDataURL=qn.bind(null,dc.renderToDataURL);Pr.toString=qn.bind(null,function(r,e,t){return $d.render(r,t)});var k,yr,Un,fc,Ns,Bn,pc,it={},vi=[],Od=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord/i;function rt(r,e){for(var t in e)r[t]=e[t];return r}function gc(r){var e=r.parentNode;e&&e.removeChild(r)}function st(r,e,t){var i,n=arguments,s={};for(i in e)i!=="key"&&i!=="ref"&&(s[i]=e[i]);if(arguments.length>3)for(t=[t],i=3;i<arguments.length;i++)t.push(n[i]);if(t!=null&&(s.children=t),typeof r=="function"&&r.defaultProps!=null)for(i in r.defaultProps)s[i]===void 0&&(s[i]=r.defaultProps[i]);return ei(r,s,e&&e.key,e&&e.ref,null)}function ei(r,e,t,i,n){var s={type:r,props:e,key:t,ref:i,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:n};return n==null&&(s.__v=s),k.vnode&&k.vnode(s),s}function yc(){return{}}function Tr(r){return r.children}function Ke(r,e){this.props=r,this.context=e}function br(r,e){if(e==null)return r.__?br(r.__,r.__.__k.indexOf(r)+1):null;for(var t;e<r.__k.length;e++)if((t=r.__k[e])!=null&&t.__e!=null)return t.__e;return typeof r.type=="function"?br(r):null}function mc(r){var e,t;if((r=r.__)!=null&&r.__c!=null){for(r.__e=r.__c.base=null,e=0;e<r.__k.length;e++)if((t=r.__k[e])!=null&&t.__e!=null){r.__e=r.__c.base=t.__e;break}return mc(r)}}function Kr(r){(!r.__d&&(r.__d=!0)&&yr.push(r)&&!Un++||Ns!==k.debounceRendering)&&((Ns=k.debounceRendering)||fc)(Cd)}function Cd(){for(var r;Un=yr.length;)r=yr.sort(function(e,t){return e.__v.__b-t.__v.__b}),yr=[],r.some(function(e){var t,i,n,s,o,a,l;e.__d&&(a=(o=(t=e).__v).__e,(l=t.__P)&&(i=[],(n=rt({},o)).__v=n,s=zn(l,o,n,t.__n,l.ownerSVGElement!==void 0,null,i,a??br(o)),wc(i,o),s!=a&&mc(o)))})}function vc(r,e,t,i,n,s,o,a,l){var c,u,h,d,f,p,g,y=t&&t.__k||vi,m=y.length;if(a==it&&(a=s!=null?s[0]:m?br(t,0):null),c=0,e.__k=ft(e.__k,function(v){if(v!=null){if(v.__=e,v.__b=e.__b+1,(h=y[c])===null||h&&v.key==h.key&&v.type===h.type)y[c]=void 0;else for(u=0;u<m;u++){if((h=y[u])&&v.key==h.key&&v.type===h.type){y[u]=void 0;break}h=null}if(d=zn(r,v,h=h||it,i,n,s,o,a,l),(u=v.ref)&&h.ref!=u&&(g||(g=[]),h.ref&&g.push(h.ref,null,v),g.push(u,v.__c||d,v)),d!=null){var _;if(p==null&&(p=d),v.__d!==void 0)_=v.__d,v.__d=void 0;else if(s==h||d!=a||d.parentNode==null){e:if(a==null||a.parentNode!==r)r.appendChild(d),_=null;else{for(f=a,u=0;(f=f.nextSibling)&&u<m;u+=2)if(f==d)break e;r.insertBefore(d,a),_=a}e.type=="option"&&(r.value="")}a=_!==void 0?_:d.nextSibling,typeof e.type=="function"&&(e.__d=a)}else a&&h.__e==a&&a.parentNode!=r&&(a=br(h))}return c++,v}),e.__e=p,s!=null&&typeof e.type!="function")for(c=s.length;c--;)s[c]!=null&&gc(s[c]);for(c=m;c--;)y[c]!=null&&mr(y[c],y[c]);if(g)for(c=0;c<g.length;c++)_c(g[c],g[++c],g[++c])}function ft(r,e,t){if(t==null&&(t=[]),r==null||typeof r=="boolean")e&&t.push(e(null));else if(Array.isArray(r))for(var i=0;i<r.length;i++)ft(r[i],e,t);else t.push(e?e(typeof r=="string"||typeof r=="number"?ei(null,r,null,null,r):r.__e!=null||r.__c!=null?ei(r.type,r.props,r.key,null,r.__v):r):r);return t}function kd(r,e,t,i,n){var s;for(s in t)s==="children"||s==="key"||s in e||ti(r,s,null,t[s],i);for(s in e)n&&typeof e[s]!="function"||s==="children"||s==="key"||s==="value"||s==="checked"||t[s]===e[s]||ti(r,s,e[s],t[s],i)}function $s(r,e,t){e[0]==="-"?r.setProperty(e,t):r[e]=typeof t=="number"&&Od.test(e)===!1?t+"px":t??""}function ti(r,e,t,i,n){var s,o,a,l,c;if(n?e==="className"&&(e="class"):e==="class"&&(e="className"),e==="style")if(s=r.style,typeof t=="string")s.cssText=t;else{if(typeof i=="string"&&(s.cssText="",i=null),i)for(l in i)t&&l in t||$s(s,l,"");if(t)for(c in t)i&&t[c]===i[c]||$s(s,c,t[c])}else e[0]==="o"&&e[1]==="n"?(o=e!==(e=e.replace(/Capture$/,"")),a=e.toLowerCase(),e=(a in r?a:e).slice(2),t?(i||r.addEventListener(e,Os,o),(r.l||(r.l={}))[e]=t):r.removeEventListener(e,Os,o)):e!=="list"&&e!=="tagName"&&e!=="form"&&e!=="type"&&e!=="size"&&!n&&e in r?r[e]=t??"":typeof t!="function"&&e!=="dangerouslySetInnerHTML"&&(e!==(e=e.replace(/^xlink:?/,""))?t==null||t===!1?r.removeAttributeNS("http://www.w3.org/1999/xlink",e.toLowerCase()):r.setAttributeNS("http://www.w3.org/1999/xlink",e.toLowerCase(),t):t==null||t===!1&&!/^ar/.test(e)?r.removeAttribute(e):r.setAttribute(e,t))}function Os(r){this.l[r.type](k.event?k.event(r):r)}function zn(r,e,t,i,n,s,o,a,l){var c,u,h,d,f,p,g,y,m,v,_=e.type;if(e.constructor!==void 0)return null;(c=k.__b)&&c(e);try{e:if(typeof _=="function"){if(y=e.props,m=(c=_.contextType)&&i[c.__c],v=c?m?m.props.value:c.__:i,t.__c?g=(u=e.__c=t.__c).__=u.__E:("prototype"in _&&_.prototype.render?e.__c=u=new _(y,v):(e.__c=u=new Ke(y,v),u.constructor=_,u.render=Ld),m&&m.sub(u),u.props=y,u.state||(u.state={}),u.context=v,u.__n=i,h=u.__d=!0,u.__h=[]),u.__s==null&&(u.__s=u.state),_.getDerivedStateFromProps!=null&&(u.__s==u.state&&(u.__s=rt({},u.__s)),rt(u.__s,_.getDerivedStateFromProps(y,u.__s))),d=u.props,f=u.state,h)_.getDerivedStateFromProps==null&&u.componentWillMount!=null&&u.componentWillMount(),u.componentDidMount!=null&&u.__h.push(u.componentDidMount);else{if(_.getDerivedStateFromProps==null&&y!==d&&u.componentWillReceiveProps!=null&&u.componentWillReceiveProps(y,v),!u.__e&&u.shouldComponentUpdate!=null&&u.shouldComponentUpdate(y,u.__s,v)===!1||e.__v===t.__v&&!u.__){for(u.props=y,u.state=u.__s,e.__v!==t.__v&&(u.__d=!1),u.__v=e,e.__e=t.__e,e.__k=t.__k,u.__h.length&&o.push(u),c=0;c<e.__k.length;c++)e.__k[c]&&(e.__k[c].__=e);break e}u.componentWillUpdate!=null&&u.componentWillUpdate(y,u.__s,v),u.componentDidUpdate!=null&&u.__h.push(function(){u.componentDidUpdate(d,f,p)})}u.context=v,u.props=y,u.state=u.__s,(c=k.__r)&&c(e),u.__d=!1,u.__v=e,u.__P=r,c=u.render(u.props,u.state,u.context),e.__k=c!=null&&c.type==Tr&&c.key==null?c.props.children:Array.isArray(c)?c:[c],u.getChildContext!=null&&(i=rt(rt({},i),u.getChildContext())),h||u.getSnapshotBeforeUpdate==null||(p=u.getSnapshotBeforeUpdate(d,f)),vc(r,e,t,i,n,s,o,a,l),u.base=e.__e,u.__h.length&&o.push(u),g&&(u.__E=u.__=null),u.__e=!1}else s==null&&e.__v===t.__v?(e.__k=t.__k,e.__e=t.__e):e.__e=Md(t.__e,e,t,i,n,s,o,l);(c=k.diffed)&&c(e)}catch(w){e.__v=null,k.__e(w,e,t)}return e.__e}function wc(r,e){k.__c&&k.__c(e,r),r.some(function(t){try{r=t.__h,t.__h=[],r.some(function(i){i.call(t)})}catch(i){k.__e(i,t.__v)}})}function Md(r,e,t,i,n,s,o,a){var l,c,u,h,d,f=t.props,p=e.props;if(n=e.type==="svg"||n,s!=null){for(l=0;l<s.length;l++)if((c=s[l])!=null&&((e.type===null?c.nodeType===3:c.localName===e.type)||r==c)){r=c,s[l]=null;break}}if(r==null){if(e.type===null)return document.createTextNode(p);r=n?document.createElementNS("http://www.w3.org/2000/svg",e.type):document.createElement(e.type,p.is&&{is:p.is}),s=null,a=!1}if(e.type===null)f!==p&&r.data!=p&&(r.data=p);else{if(s!=null&&(s=vi.slice.call(r.childNodes)),u=(f=t.props||it).dangerouslySetInnerHTML,h=p.dangerouslySetInnerHTML,!a){if(f===it)for(f={},d=0;d<r.attributes.length;d++)f[r.attributes[d].name]=r.attributes[d].value;(h||u)&&(h&&u&&h.__html==u.__html||(r.innerHTML=h&&h.__html||""))}kd(r,p,f,n,a),h?e.__k=[]:(e.__k=e.props.children,vc(r,e,t,i,e.type!=="foreignObject"&&n,s,o,it,a)),a||("value"in p&&(l=p.value)!==void 0&&l!==r.value&&ti(r,"value",l,f.value,!1),"checked"in p&&(l=p.checked)!==void 0&&l!==r.checked&&ti(r,"checked",l,f.checked,!1))}return r}function _c(r,e,t){try{typeof r=="function"?r(e):r.current=e}catch(i){k.__e(i,t)}}function mr(r,e,t){var i,n,s;if(k.unmount&&k.unmount(r),(i=r.ref)&&(i.current&&i.current!==r.__e||_c(i,null,e)),t||typeof r.type=="function"||(t=(n=r.__e)!=null),r.__e=r.__d=void 0,(i=r.__c)!=null){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(o){k.__e(o,e)}i.base=i.__P=null}if(i=r.__k)for(s=0;s<i.length;s++)i[s]&&mr(i[s],e,t);n!=null&&gc(n)}function Ld(r,e,t){return this.constructor(r,t)}function Er(r,e,t){var i,n,s;k.__&&k.__(r,e),n=(i=t===Bn)?null:t&&t.__k||e.__k,r=st(Tr,null,[r]),s=[],zn(e,(i?e:t||e).__k=r,n||it,it,e.ownerSVGElement!==void 0,t&&!i?[t]:n?null:vi.slice.call(e.childNodes),s,t||it,i),wc(s,r)}function bc(r,e){Er(r,e,Bn)}function Dd(r,e){var t,i;for(i in e=rt(rt({},r.props),e),arguments.length>2&&(e.children=vi.slice.call(arguments,2)),t={},e)i!=="key"&&i!=="ref"&&(t[i]=e[i]);return ei(r.type,t,e.key||r.key,e.ref||r.ref,null)}function Ec(r){var e={},t={__c:"__cC"+pc++,__:r,Consumer:function(i,n){return i.children(n)},Provider:function(i){var n,s=this;return this.getChildContext||(n=[],this.getChildContext=function(){return e[t.__c]=s,e},this.shouldComponentUpdate=function(o){s.props.value!==o.value&&n.some(function(a){a.context=o.value,Kr(a)})},this.sub=function(o){n.push(o);var a=o.componentWillUnmount;o.componentWillUnmount=function(){n.splice(n.indexOf(o),1),a&&a.call(o)}}),i.children}};return t.Consumer.contextType=t,t.Provider.__=t,t}k={__e:function(r,e){for(var t,i;e=e.__;)if((t=e.__c)&&!t.__)try{if(t.constructor&&t.constructor.getDerivedStateFromError!=null&&(i=!0,t.setState(t.constructor.getDerivedStateFromError(r))),t.componentDidCatch!=null&&(i=!0,t.componentDidCatch(r)),i)return Kr(t.__E=t)}catch(n){r=n}throw r}},Ke.prototype.setState=function(r,e){var t;t=this.__s!==this.state?this.__s:this.__s=rt({},this.state),typeof r=="function"&&(r=r(t,this.props)),r&&rt(t,r),r!=null&&this.__v&&(e&&this.__h.push(e),Kr(this))},Ke.prototype.forceUpdate=function(r){this.__v&&(this.__e=!0,r&&this.__h.push(r),Kr(this))},Ke.prototype.render=Tr,yr=[],Un=0,fc=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Bn=it,pc=0;var Ct,ve,Cs,Jt=0,cn=[],ks=k.__r,Ms=k.diffed,Ls=k.__c,Ds=k.unmount;function er(r,e){k.__h&&k.__h(ve,r,Jt||e),Jt=0;var t=ve.__H||(ve.__H={__:[],__h:[]});return r>=t.__.length&&t.__.push({}),t.__[r]}function Kn(r){return Jt=1,jn(Rc,r)}function jn(r,e,t){var i=er(Ct++,2);return i.__c||(i.__c=ve,i.__=[t?t(e):Rc(void 0,e),function(n){var s=r(i.__[0],n);i.__[0]!==s&&(i.__[0]=s,i.__c.setState({}))}]),i.__}function Ic(r,e){var t=er(Ct++,3);!k.__s&&Wn(t.__H,e)&&(t.__=r,t.__H=e,ve.__H.__h.push(t))}function Vn(r,e){var t=er(Ct++,4);!k.__s&&Wn(t.__H,e)&&(t.__=r,t.__H=e,ve.__h.push(t))}function Sc(r){return Jt=5,wi(function(){return{current:r}},[])}function xc(r,e,t){Jt=6,Vn(function(){typeof r=="function"?r(e()):r&&(r.current=e())},t==null?t:t.concat(r))}function wi(r,e){var t=er(Ct++,7);return Wn(t.__H,e)?(t.__H=e,t.__h=r,t.__=r()):t.__}function Pc(r,e){return Jt=8,wi(function(){return r},e)}function Ac(r){var e=ve.context[r.__c],t=er(Ct++,9);return t.__c=r,e?(t.__==null&&(t.__=!0,e.sub(ve)),e.props.value):r.__}function Tc(r,e){k.useDebugValue&&k.useDebugValue(e?e(r):r)}function Fd(r){var e=er(Ct++,10),t=Kn();return e.__=r,ve.componentDidCatch||(ve.componentDidCatch=function(i){e.__&&e.__(i),t[1](i)}),[t[0],function(){t[1](void 0)}]}function qd(){cn.some(function(r){if(r.__P)try{r.__H.__h.forEach(ln),r.__H.__h.forEach(un),r.__H.__h=[]}catch(e){return r.__H.__h=[],k.__e(e,r.__v),!0}}),cn=[]}function ln(r){r.t&&r.t()}function un(r){var e=r.__();typeof e=="function"&&(r.t=e)}function Wn(r,e){return!r||e.some(function(t,i){return t!==r[i]})}function Rc(r,e){return typeof e=="function"?e(r):e}k.__r=function(r){ks&&ks(r),Ct=0,(ve=r.__c).__H&&(ve.__H.__h.forEach(ln),ve.__H.__h.forEach(un),ve.__H.__h=[])},k.diffed=function(r){Ms&&Ms(r);var e=r.__c;if(e){var t=e.__H;t&&t.__h.length&&(cn.push(e)!==1&&Cs===k.requestAnimationFrame||((Cs=k.requestAnimationFrame)||function(i){var n,s=function(){clearTimeout(o),cancelAnimationFrame(n),setTimeout(i)},o=setTimeout(s,100);typeof window<"u"&&(n=requestAnimationFrame(s))})(qd))}},k.__c=function(r,e){e.some(function(t){try{t.__h.forEach(ln),t.__h=t.__h.filter(function(i){return!i.__||un(i)})}catch(i){e.some(function(n){n.__h&&(n.__h=[])}),e=[],k.__e(i,t.__v)}}),Ls&&Ls(r,e)},k.unmount=function(r){Ds&&Ds(r);var e=r.__c;if(e){var t=e.__H;if(t)try{t.__.forEach(function(i){return i.t&&i.t()})}catch(i){k.__e(i,e.__v)}}};function Hn(r,e){for(var t in e)r[t]=e[t];return r}function hn(r,e){for(var t in r)if(t!=="__source"&&!(t in e))return!0;for(var i in e)if(i!=="__source"&&r[i]!==e[i])return!0;return!1}var Nc=function(r){var e,t;function i(n){var s;return(s=r.call(this,n)||this).isPureReactComponent=!0,s}return t=r,(e=i).prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t,i.prototype.shouldComponentUpdate=function(n,s){return hn(this.props,n)||hn(this.state,s)},i}(Ke);function $c(r,e){function t(n){var s=this.props.ref,o=s==n.ref;return!o&&s&&(s.call?s(null):s.current=null),e?!e(this.props,n)||!o:hn(this.props,n)}function i(n){return this.shouldComponentUpdate=t,st(r,Hn({},n))}return i.prototype.isReactComponent=!0,i.displayName="Memo("+(r.displayName||r.name)+")",i.t=!0,i}var Fs=k.__b;function Oc(r){function e(t){var i=Hn({},t);return delete i.ref,r(i,t.ref)}return e.prototype.isReactComponent=e.t=!0,e.displayName="ForwardRef("+(r.displayName||r.name)+")",e}k.__b=function(r){r.type&&r.type.t&&r.ref&&(r.props.ref=r.ref,r.ref=null),Fs&&Fs(r)};var qs=function(r,e){return r?ft(r).reduce(function(t,i,n){return t.concat(e(i,n))},[]):null},Cc={map:qs,forEach:qs,count:function(r){return r?ft(r).length:0},only:function(r){if((r=ft(r)).length!==1)throw new Error("Children.only() expects only one child.");return r[0]},toArray:ft},Ud=k.__e;function kc(r){return r&&((r=Hn({},r)).__c=null,r.__k=r.__k&&r.__k.map(kc)),r}function ri(){this.__u=0,this.o=null,this.__b=null}function Mc(r){var e=r.__.__c;return e&&e.u&&e.u(r)}function Lc(r){var e,t,i;function n(s){if(e||(e=r()).then(function(o){t=o.default||o},function(o){i=o}),i)throw i;if(!t)throw e;return st(t,s)}return n.displayName="Lazy",n.t=!0,n}function Bt(){this.i=null,this.l=null}k.__e=function(r,e,t){if(r.then){for(var i,n=e;n=n.__;)if((i=n.__c)&&i.__c)return i.__c(r,e.__c)}Ud(r,e,t)},(ri.prototype=new Ke).__c=function(r,e){var t=this;t.o==null&&(t.o=[]),t.o.push(e);var i=Mc(t.__v),n=!1,s=function(){n||(n=!0,i?i(o):o())};e.__c=e.componentWillUnmount,e.componentWillUnmount=function(){s(),e.__c&&e.__c()};var o=function(){var a;if(!--t.__u)for(t.__v.__k[0]=t.state.u,t.setState({u:t.__b=null});a=t.o.pop();)a.forceUpdate()};t.__u++||t.setState({u:t.__b=t.__v.__k[0]}),r.then(s,s)},ri.prototype.render=function(r,e){return this.__b&&(this.__v.__k[0]=kc(this.__b),this.__b=null),[st(Ke,null,e.u?null:r.children),e.u&&r.fallback]};var Us=function(r,e,t){if(++t[1]===t[0]&&r.l.delete(e),r.props.revealOrder&&(r.props.revealOrder[0]!=="t"||!r.l.size))for(t=r.i;t;){for(;t.length>3;)t.pop()();if(t[1]<t[0])break;r.i=t=t[2]}};(Bt.prototype=new Ke).u=function(r){var e=this,t=Mc(e.__v),i=e.l.get(r);return i[0]++,function(n){var s=function(){e.props.revealOrder?(i.push(n),Us(e,r,i)):n()};t?t(s):s()}},Bt.prototype.render=function(r){this.i=null,this.l=new Map;var e=ft(r.children);r.revealOrder&&r.revealOrder[0]==="b"&&e.reverse();for(var t=e.length;t--;)this.l.set(e[t],this.i=[1,0,this.i]);return r.children},Bt.prototype.componentDidUpdate=Bt.prototype.componentDidMount=function(){var r=this;r.l.forEach(function(e,t){Us(r,t,e)})};var Bd=function(){function r(){}var e=r.prototype;return e.getChildContext=function(){return this.props.context},e.render=function(t){return t.children},r}();function zd(r){var e=this,t=r.container,i=st(Bd,{context:e.context},r.vnode);return e.s&&e.s!==t&&(e.v.parentNode&&e.s.removeChild(e.v),mr(e.h),e.p=!1),r.vnode?e.p?(t.__k=e.__k,Er(i,t),e.__k=t.__k):(e.v=document.createTextNode(""),bc("",t),t.appendChild(e.v),e.p=!0,e.s=t,Er(i,t,e.v),e.__k=e.v.__k):e.p&&(e.v.parentNode&&e.s.removeChild(e.v),mr(e.h)),e.h=i,e.componentWillUnmount=function(){e.v.parentNode&&e.s.removeChild(e.v),mr(e.h)},null}function Dc(r,e){return st(zd,{vnode:r,container:e})}var Bs=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|fill|flood|font|glyph(?!R)|horiz|marker(?!H|W|U)|overline|paint|stop|strikethrough|stroke|text(?!L)|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/;Ke.prototype.isReactComponent={};var Fc=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.element")||60103;function dn(r,e,t){if(e.__k==null)for(;e.firstChild;)e.removeChild(e.firstChild);return Er(r,e),typeof t=="function"&&t(),r?r.__c:null}function Kd(r,e,t){return bc(r,e),typeof t=="function"&&t(),r?r.__c:null}var zs=k.event;function Di(r,e){r["UNSAFE_"+e]&&!r[e]&&Object.defineProperty(r,e,{configurable:!1,get:function(){return this["UNSAFE_"+e]},set:function(t){this["UNSAFE_"+e]=t}})}k.event=function(r){zs&&(r=zs(r)),r.persist=function(){};var e=!1,t=!1,i=r.stopPropagation;r.stopPropagation=function(){i.call(r),e=!0};var n=r.preventDefault;return r.preventDefault=function(){n.call(r),t=!0},r.isPropagationStopped=function(){return e},r.isDefaultPrevented=function(){return t},r.nativeEvent=r};var Ks={configurable:!0,get:function(){return this.class}},js=k.vnode;k.vnode=function(r){r.$$typeof=Fc;var e=r.type,t=r.props;if(e){if(t.class!=t.className&&(Ks.enumerable="className"in t,t.className!=null&&(t.class=t.className),Object.defineProperty(t,"className",Ks)),typeof e!="function"){var i,n,s;for(s in t.defaultValue&&t.value!==void 0&&(t.value||t.value===0||(t.value=t.defaultValue),delete t.defaultValue),Array.isArray(t.value)&&t.multiple&&e==="select"&&(ft(t.children).forEach(function(o){t.value.indexOf(o.props.value)!=-1&&(o.props.selected=!0)}),delete t.value),t)if(i=Bs.test(s))break;if(i)for(s in n=r.props={},t)n[Bs.test(s)?s.replace(/[A-Z0-9]/,"-$&").toLowerCase():s]=t[s]}(function(o){var a=r.type,l=r.props;if(l&&typeof a=="string"){var c={};for(var u in l)/^on(Ani|Tra|Tou)/.test(u)&&(l[u.toLowerCase()]=l[u],delete l[u]),c[u.toLowerCase()]=u;if(c.ondoubleclick&&(l.ondblclick=l[c.ondoubleclick],delete l[c.ondoubleclick]),c.onbeforeinput&&(l.onbeforeinput=l[c.onbeforeinput],delete l[c.onbeforeinput]),c.onchange&&(a==="textarea"||a.toLowerCase()==="input"&&!/^fil|che|ra/i.test(l.type))){var h=c.oninput||"oninput";l[h]||(l[h]=l[c.onchange],delete l[c.onchange])}}})(),typeof e=="function"&&!e.m&&e.prototype&&(Di(e.prototype,"componentWillMount"),Di(e.prototype,"componentWillReceiveProps"),Di(e.prototype,"componentWillUpdate"),e.m=!0)}js&&js(r)};var jd="16.8.0";function qc(r){return st.bind(null,r)}function Jn(r){return!!r&&r.$$typeof===Fc}function Uc(r){return Jn(r)?Dd.apply(null,arguments):r}function Bc(r){return!!r.__k&&(Er(null,r),!0)}function zc(r){return r&&(r.base||r.nodeType===1&&r)||null}var Kc=function(r,e){return r(e)};const Vd={useState:Kn,useReducer:jn,useEffect:Ic,useLayoutEffect:Vn,useRef:Sc,useImperativeHandle:xc,useMemo:wi,useCallback:Pc,useContext:Ac,useDebugValue:Tc,version:"16.8.0",Children:Cc,render:dn,hydrate:dn,unmountComponentAtNode:Bc,createPortal:Dc,createElement:st,createContext:Ec,createFactory:qc,cloneElement:Uc,createRef:yc,Fragment:Tr,isValidElement:Jn,findDOMNode:zc,Component:Ke,PureComponent:Nc,memo:$c,forwardRef:Oc,unstable_batchedUpdates:Kc,Suspense:ri,SuspenseList:Bt,lazy:Lc},Wd=Object.freeze(Object.defineProperty({__proto__:null,Children:Cc,Component:Ke,Fragment:Tr,PureComponent:Nc,Suspense:ri,SuspenseList:Bt,cloneElement:Uc,createContext:Ec,createElement:st,createFactory:qc,createPortal:Dc,createRef:yc,default:Vd,findDOMNode:zc,forwardRef:Oc,hydrate:Kd,isValidElement:Jn,lazy:Lc,memo:$c,render:dn,unmountComponentAtNode:Bc,unstable_batchedUpdates:Kc,useCallback:Pc,useContext:Ac,useDebugValue:Tc,useEffect:Ic,useErrorBoundary:Fd,useImperativeHandle:xc,useLayoutEffect:Vn,useMemo:wi,useReducer:jn,useRef:Sc,useState:Kn,version:jd},Symbol.toStringTag,{value:"Module"})),Hd=va(Wd);function jc(r){return r&&typeof r=="object"&&"default"in r?r.default:r}var de=Ch,Vc=jc(Pr),Jd=jc(Mu),T=Hd;function Gd(r){Vc.toString(r,{type:"terminal"}).then(console.log)}var Yd=`:root {
9
- --animation-duration: 300ms;
10
- }
11
-
12
- @keyframes fadeIn {
13
- from {
14
- opacity: 0;
15
- }
16
- to {
17
- opacity: 1;
18
- }
19
- }
20
-
21
- @keyframes fadeOut {
22
- from {
23
- opacity: 1;
24
- }
25
- to {
26
- opacity: 0;
27
- }
28
- }
29
-
30
- .animated {
31
- animation-duration: var(--animation-duration);
32
- animation-fill-mode: both;
33
- }
34
-
35
- .fadeIn {
36
- animation-name: fadeIn;
37
- }
38
-
39
- .fadeOut {
40
- animation-name: fadeOut;
41
- }
42
-
43
- #walletconnect-wrapper {
44
- -webkit-user-select: none;
45
- align-items: center;
46
- display: flex;
47
- height: 100%;
48
- justify-content: center;
49
- left: 0;
50
- pointer-events: none;
51
- position: fixed;
52
- top: 0;
53
- user-select: none;
54
- width: 100%;
55
- z-index: 99999999999999;
56
- }
57
-
58
- .walletconnect-modal__headerLogo {
59
- height: 21px;
60
- }
61
-
62
- .walletconnect-modal__header p {
63
- color: #ffffff;
64
- font-size: 20px;
65
- font-weight: 600;
66
- margin: 0;
67
- align-items: flex-start;
68
- display: flex;
69
- flex: 1;
70
- margin-left: 5px;
71
- }
72
-
73
- .walletconnect-modal__close__wrapper {
74
- position: absolute;
75
- top: 0px;
76
- right: 0px;
77
- z-index: 10000;
78
- background: white;
79
- border-radius: 26px;
80
- padding: 6px;
81
- box-sizing: border-box;
82
- width: 26px;
83
- height: 26px;
84
- cursor: pointer;
85
- }
86
-
87
- .walletconnect-modal__close__icon {
88
- position: relative;
89
- top: 7px;
90
- right: 0;
91
- display: flex;
92
- align-items: center;
93
- justify-content: center;
94
- transform: rotate(45deg);
95
- }
96
-
97
- .walletconnect-modal__close__line1 {
98
- position: absolute;
99
- width: 100%;
100
- border: 1px solid rgb(48, 52, 59);
101
- }
102
-
103
- .walletconnect-modal__close__line2 {
104
- position: absolute;
105
- width: 100%;
106
- border: 1px solid rgb(48, 52, 59);
107
- transform: rotate(90deg);
108
- }
109
-
110
- .walletconnect-qrcode__base {
111
- -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
112
- background: rgba(37, 41, 46, 0.95);
113
- height: 100%;
114
- left: 0;
115
- pointer-events: auto;
116
- position: fixed;
117
- top: 0;
118
- transition: 0.4s cubic-bezier(0.19, 1, 0.22, 1);
119
- width: 100%;
120
- will-change: opacity;
121
- padding: 40px;
122
- box-sizing: border-box;
123
- }
124
-
125
- .walletconnect-qrcode__text {
126
- color: rgba(60, 66, 82, 0.6);
127
- font-size: 16px;
128
- font-weight: 600;
129
- letter-spacing: 0;
130
- line-height: 1.1875em;
131
- margin: 10px 0 20px 0;
132
- text-align: center;
133
- width: 100%;
134
- }
135
-
136
- @media only screen and (max-width: 768px) {
137
- .walletconnect-qrcode__text {
138
- font-size: 4vw;
139
- }
140
- }
141
-
142
- @media only screen and (max-width: 320px) {
143
- .walletconnect-qrcode__text {
144
- font-size: 14px;
145
- }
146
- }
147
-
148
- .walletconnect-qrcode__image {
149
- width: calc(100% - 30px);
150
- box-sizing: border-box;
151
- cursor: none;
152
- margin: 0 auto;
153
- }
154
-
155
- .walletconnect-qrcode__notification {
156
- position: absolute;
157
- bottom: 0;
158
- left: 0;
159
- right: 0;
160
- font-size: 16px;
161
- padding: 16px 20px;
162
- border-radius: 16px;
163
- text-align: center;
164
- transition: all 0.1s ease-in-out;
165
- background: white;
166
- color: black;
167
- margin-bottom: -60px;
168
- opacity: 0;
169
- }
170
-
171
- .walletconnect-qrcode__notification.notification__show {
172
- opacity: 1;
173
- }
174
-
175
- @media only screen and (max-width: 768px) {
176
- .walletconnect-modal__header {
177
- height: 130px;
178
- }
179
- .walletconnect-modal__base {
180
- overflow: auto;
181
- }
182
- }
183
-
184
- @media only screen and (min-device-width: 415px) and (max-width: 768px) {
185
- #content {
186
- max-width: 768px;
187
- box-sizing: border-box;
188
- }
189
- }
190
-
191
- @media only screen and (min-width: 375px) and (max-width: 415px) {
192
- #content {
193
- max-width: 414px;
194
- box-sizing: border-box;
195
- }
196
- }
197
-
198
- @media only screen and (min-width: 320px) and (max-width: 375px) {
199
- #content {
200
- max-width: 375px;
201
- box-sizing: border-box;
202
- }
203
- }
204
-
205
- @media only screen and (max-width: 320px) {
206
- #content {
207
- max-width: 320px;
208
- box-sizing: border-box;
209
- }
210
- }
211
-
212
- .walletconnect-modal__base {
213
- -webkit-font-smoothing: antialiased;
214
- background: #ffffff;
215
- border-radius: 24px;
216
- box-shadow: 0 10px 50px 5px rgba(0, 0, 0, 0.4);
217
- font-family: ui-rounded, "SF Pro Rounded", "SF Pro Text", medium-content-sans-serif-font,
218
- -apple-system, BlinkMacSystemFont, ui-sans-serif, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell,
219
- "Open Sans", "Helvetica Neue", sans-serif;
220
- margin-top: 41px;
221
- padding: 24px 24px 22px;
222
- pointer-events: auto;
223
- position: relative;
224
- text-align: center;
225
- transition: 0.4s cubic-bezier(0.19, 1, 0.22, 1);
226
- will-change: transform;
227
- overflow: visible;
228
- transform: translateY(-50%);
229
- top: 50%;
230
- max-width: 500px;
231
- margin: auto;
232
- }
233
-
234
- @media only screen and (max-width: 320px) {
235
- .walletconnect-modal__base {
236
- padding: 24px 12px;
237
- }
238
- }
239
-
240
- .walletconnect-modal__base .hidden {
241
- transform: translateY(150%);
242
- transition: 0.125s cubic-bezier(0.4, 0, 1, 1);
243
- }
244
-
245
- .walletconnect-modal__header {
246
- align-items: center;
247
- display: flex;
248
- height: 26px;
249
- left: 0;
250
- justify-content: space-between;
251
- position: absolute;
252
- top: -42px;
253
- width: 100%;
254
- }
255
-
256
- .walletconnect-modal__base .wc-logo {
257
- align-items: center;
258
- display: flex;
259
- height: 26px;
260
- margin-top: 15px;
261
- padding-bottom: 15px;
262
- pointer-events: auto;
263
- }
264
-
265
- .walletconnect-modal__base .wc-logo div {
266
- background-color: #3399ff;
267
- height: 21px;
268
- margin-right: 5px;
269
- mask-image: url("images/wc-logo.svg") center no-repeat;
270
- width: 32px;
271
- }
272
-
273
- .walletconnect-modal__base .wc-logo p {
274
- color: #ffffff;
275
- font-size: 20px;
276
- font-weight: 600;
277
- margin: 0;
278
- }
279
-
280
- .walletconnect-modal__base h2 {
281
- color: rgba(60, 66, 82, 0.6);
282
- font-size: 16px;
283
- font-weight: 600;
284
- letter-spacing: 0;
285
- line-height: 1.1875em;
286
- margin: 0 0 19px 0;
287
- text-align: center;
288
- width: 100%;
289
- }
290
-
291
- .walletconnect-modal__base__row {
292
- -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
293
- align-items: center;
294
- border-radius: 20px;
295
- cursor: pointer;
296
- display: flex;
297
- height: 56px;
298
- justify-content: space-between;
299
- padding: 0 15px;
300
- position: relative;
301
- margin: 0px 0px 8px;
302
- text-align: left;
303
- transition: 0.15s cubic-bezier(0.25, 0.46, 0.45, 0.94);
304
- will-change: transform;
305
- text-decoration: none;
306
- }
307
-
308
- .walletconnect-modal__base__row:hover {
309
- background: rgba(60, 66, 82, 0.06);
310
- }
311
-
312
- .walletconnect-modal__base__row:active {
313
- background: rgba(60, 66, 82, 0.06);
314
- transform: scale(0.975);
315
- transition: 0.1s cubic-bezier(0.25, 0.46, 0.45, 0.94);
316
- }
317
-
318
- .walletconnect-modal__base__row__h3 {
319
- color: #25292e;
320
- font-size: 20px;
321
- font-weight: 700;
322
- margin: 0;
323
- padding-bottom: 3px;
324
- }
325
-
326
- .walletconnect-modal__base__row__right {
327
- align-items: center;
328
- display: flex;
329
- justify-content: center;
330
- }
331
-
332
- .walletconnect-modal__base__row__right__app-icon {
333
- border-radius: 8px;
334
- height: 34px;
335
- margin: 0 11px 2px 0;
336
- width: 34px;
337
- background-size: 100%;
338
- box-shadow: 0 4px 12px 0 rgba(37, 41, 46, 0.25);
339
- }
340
-
341
- .walletconnect-modal__base__row__right__caret {
342
- height: 18px;
343
- opacity: 0.3;
344
- transition: 0.1s cubic-bezier(0.25, 0.46, 0.45, 0.94);
345
- width: 8px;
346
- will-change: opacity;
347
- }
348
-
349
- .walletconnect-modal__base__row:hover .caret,
350
- .walletconnect-modal__base__row:active .caret {
351
- opacity: 0.6;
352
- }
353
-
354
- .walletconnect-modal__mobile__toggle {
355
- width: 80%;
356
- display: flex;
357
- margin: 0 auto;
358
- position: relative;
359
- overflow: hidden;
360
- border-radius: 8px;
361
- margin-bottom: 18px;
362
- background: #d4d5d9;
363
- }
364
-
365
- .walletconnect-modal__single_wallet {
366
- display: flex;
367
- justify-content: center;
368
- margin-top: 7px;
369
- margin-bottom: 18px;
370
- }
371
-
372
- .walletconnect-modal__single_wallet a {
373
- cursor: pointer;
374
- color: rgb(64, 153, 255);
375
- font-size: 21px;
376
- font-weight: 800;
377
- text-decoration: none !important;
378
- margin: 0 auto;
379
- }
380
-
381
- .walletconnect-modal__mobile__toggle_selector {
382
- width: calc(50% - 8px);
383
- background: white;
384
- position: absolute;
385
- border-radius: 5px;
386
- height: calc(100% - 8px);
387
- top: 4px;
388
- transition: all 0.2s ease-in-out;
389
- transform: translate3d(4px, 0, 0);
390
- }
391
-
392
- .walletconnect-modal__mobile__toggle.right__selected .walletconnect-modal__mobile__toggle_selector {
393
- transform: translate3d(calc(100% + 12px), 0, 0);
394
- }
395
-
396
- .walletconnect-modal__mobile__toggle a {
397
- font-size: 12px;
398
- width: 50%;
399
- text-align: center;
400
- padding: 8px;
401
- margin: 0;
402
- font-weight: 600;
403
- z-index: 1;
404
- }
405
-
406
- .walletconnect-modal__footer {
407
- display: flex;
408
- justify-content: center;
409
- margin-top: 20px;
410
- }
411
-
412
- @media only screen and (max-width: 768px) {
413
- .walletconnect-modal__footer {
414
- margin-top: 5vw;
415
- }
416
- }
417
-
418
- .walletconnect-modal__footer a {
419
- cursor: pointer;
420
- color: #898d97;
421
- font-size: 15px;
422
- margin: 0 auto;
423
- }
424
-
425
- @media only screen and (max-width: 320px) {
426
- .walletconnect-modal__footer a {
427
- font-size: 14px;
428
- }
429
- }
430
-
431
- .walletconnect-connect__buttons__wrapper {
432
- max-height: 44vh;
433
- }
434
-
435
- .walletconnect-connect__buttons__wrapper__android {
436
- margin: 50% 0;
437
- }
438
-
439
- .walletconnect-connect__buttons__wrapper__wrap {
440
- display: grid;
441
- grid-template-columns: repeat(4, 1fr);
442
- margin: 10px 0;
443
- }
444
-
445
- @media only screen and (min-width: 768px) {
446
- .walletconnect-connect__buttons__wrapper__wrap {
447
- margin-top: 40px;
448
- }
449
- }
450
-
451
- .walletconnect-connect__button {
452
- background-color: rgb(64, 153, 255);
453
- padding: 12px;
454
- border-radius: 8px;
455
- text-decoration: none;
456
- color: rgb(255, 255, 255);
457
- font-weight: 500;
458
- }
459
-
460
- .walletconnect-connect__button__icon_anchor {
461
- cursor: pointer;
462
- display: flex;
463
- justify-content: flex-start;
464
- align-items: center;
465
- margin: 8px;
466
- width: 42px;
467
- justify-self: center;
468
- flex-direction: column;
469
- text-decoration: none !important;
470
- }
471
-
472
- @media only screen and (max-width: 320px) {
473
- .walletconnect-connect__button__icon_anchor {
474
- margin: 4px;
475
- }
476
- }
477
-
478
- .walletconnect-connect__button__icon {
479
- border-radius: 10px;
480
- height: 42px;
481
- margin: 0;
482
- width: 42px;
483
- background-size: cover !important;
484
- box-shadow: 0 4px 12px 0 rgba(37, 41, 46, 0.25);
485
- }
486
-
487
- .walletconnect-connect__button__text {
488
- color: #424952;
489
- font-size: 2.7vw;
490
- text-decoration: none !important;
491
- padding: 0;
492
- margin-top: 1.8vw;
493
- font-weight: 600;
494
- }
495
-
496
- @media only screen and (min-width: 768px) {
497
- .walletconnect-connect__button__text {
498
- font-size: 16px;
499
- margin-top: 12px;
500
- }
501
- }
502
-
503
- .walletconnect-search__input {
504
- border: none;
505
- background: #d4d5d9;
506
- border-style: none;
507
- padding: 8px 16px;
508
- outline: none;
509
- font-style: normal;
510
- font-stretch: normal;
511
- font-size: 16px;
512
- font-style: normal;
513
- font-stretch: normal;
514
- line-height: normal;
515
- letter-spacing: normal;
516
- text-align: left;
517
- border-radius: 8px;
518
- width: calc(100% - 16px);
519
- margin: 0;
520
- margin-bottom: 8px;
521
- }
522
- `;typeof Symbol<"u"&&(Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")));typeof Symbol<"u"&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator")));function Qd(r,e){try{var t=r()}catch(i){return e(i)}return t&&t.then?t.then(void 0,e):t}var Xd="data:image/svg+xml,%3Csvg height='185' viewBox='0 0 300 185' width='300' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='m61.4385429 36.2562612c48.9112241-47.8881663 128.2119871-47.8881663 177.1232091 0l5.886545 5.7634174c2.445561 2.3944081 2.445561 6.2765112 0 8.6709204l-20.136695 19.715503c-1.222781 1.1972051-3.2053 1.1972051-4.428081 0l-8.100584-7.9311479c-34.121692-33.4079817-89.443886-33.4079817-123.5655788 0l-8.6750562 8.4936051c-1.2227816 1.1972041-3.205301 1.1972041-4.4280806 0l-20.1366949-19.7155031c-2.4455612-2.3944092-2.4455612-6.2765122 0-8.6709204zm218.7677961 40.7737449 17.921697 17.546897c2.445549 2.3943969 2.445563 6.2764769.000031 8.6708899l-80.810171 79.121134c-2.445544 2.394426-6.410582 2.394453-8.85616.000062-.00001-.00001-.000022-.000022-.000032-.000032l-57.354143-56.154572c-.61139-.598602-1.60265-.598602-2.21404 0-.000004.000004-.000007.000008-.000011.000011l-57.3529212 56.154531c-2.4455368 2.394432-6.4105755 2.394472-8.8561612.000087-.0000143-.000014-.0000296-.000028-.0000449-.000044l-80.81241943-79.122185c-2.44556021-2.394408-2.44556021-6.2765115 0-8.6709197l17.92172963-17.5468673c2.4455602-2.3944082 6.4105989-2.3944082 8.8561602 0l57.3549775 56.155357c.6113908.598602 1.602649.598602 2.2140398 0 .0000092-.000009.0000174-.000017.0000265-.000024l57.3521031-56.155333c2.445505-2.3944633 6.410544-2.3945531 8.856161-.0002.000034.0000336.000068.0000673.000101.000101l57.354902 56.155432c.61139.598601 1.60265.598601 2.21404 0l57.353975-56.1543249c2.445561-2.3944092 6.410599-2.3944092 8.85616 0z' fill='%233b99fc'/%3E%3C/svg%3E",Zd="WalletConnect",ef=300,tf="rgb(64, 153, 255)",Wc="walletconnect-wrapper",Vs="walletconnect-style-sheet",Hc="walletconnect-qrcode-modal",rf="walletconnect-qrcode-close",Jc="walletconnect-qrcode-text",nf="walletconnect-connect-button";function sf(r){return T.createElement("div",{className:"walletconnect-modal__header"},T.createElement("img",{src:Xd,className:"walletconnect-modal__headerLogo"}),T.createElement("p",null,Zd),T.createElement("div",{className:"walletconnect-modal__close__wrapper",onClick:r.onClose},T.createElement("div",{id:rf,className:"walletconnect-modal__close__icon"},T.createElement("div",{className:"walletconnect-modal__close__line1"}),T.createElement("div",{className:"walletconnect-modal__close__line2"}))))}function of(r){return T.createElement("a",{className:"walletconnect-connect__button",href:r.href,id:nf+"-"+r.name,onClick:r.onClick,rel:"noopener noreferrer",style:{backgroundColor:r.color},target:"_blank"},r.name)}var af="data:image/svg+xml,%3Csvg fill='none' height='18' viewBox='0 0 8 18' width='8' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath clip-rule='evenodd' d='m.586301.213898c-.435947.33907-.5144813.967342-.175411 1.403292l4.87831 6.27212c.28087.36111.28087.86677 0 1.22788l-4.878311 6.27211c-.33907.436-.260536 1.0642.175412 1.4033.435949.3391 1.064219.2605 1.403289-.1754l4.87832-6.2721c.84259-1.08336.84259-2.60034 0-3.68367l-4.87832-6.27212c-.33907-.4359474-.96734-.514482-1.403289-.175412z' fill='%233c4252' fill-rule='evenodd'/%3E%3C/svg%3E";function cf(r){var e=r.color,t=r.href,i=r.name,n=r.logo,s=r.onClick;return T.createElement("a",{className:"walletconnect-modal__base__row",href:t,onClick:s,rel:"noopener noreferrer",target:"_blank"},T.createElement("h3",{className:"walletconnect-modal__base__row__h3"},i),T.createElement("div",{className:"walletconnect-modal__base__row__right"},T.createElement("div",{className:"walletconnect-modal__base__row__right__app-icon",style:{background:"url('"+n+"') "+e,backgroundSize:"100%"}}),T.createElement("img",{src:af,className:"walletconnect-modal__base__row__right__caret"})))}function lf(r){var e=r.color,t=r.href,i=r.name,n=r.logo,s=r.onClick,o=window.innerWidth<768?(i.length>8?2.5:2.7)+"vw":"inherit";return T.createElement("a",{className:"walletconnect-connect__button__icon_anchor",href:t,onClick:s,rel:"noopener noreferrer",target:"_blank"},T.createElement("div",{className:"walletconnect-connect__button__icon",style:{background:"url('"+n+"') "+e,backgroundSize:"100%"}}),T.createElement("div",{style:{fontSize:o},className:"walletconnect-connect__button__text"},i))}var uf=5,Fi=12;function hf(r){var e=de.isAndroid(),t=T.useState(""),i=t[0],n=t[1],s=T.useState(""),o=s[0],a=s[1],l=T.useState(1),c=l[0],u=l[1],h=o?r.links.filter(function(w){return w.name.toLowerCase().includes(o.toLowerCase())}):r.links,d=r.errorMessage,f=o||h.length>uf,p=Math.ceil(h.length/Fi),g=[(c-1)*Fi+1,c*Fi],y=h.length?h.filter(function(w,b){return b+1>=g[0]&&b+1<=g[1]}):[],m=!e&&p>1,v=void 0;function _(w){n(w.target.value),clearTimeout(v),w.target.value?v=setTimeout(function(){a(w.target.value),u(1)},1e3):(n(""),a(""),u(1))}return T.createElement("div",null,T.createElement("p",{id:Jc,className:"walletconnect-qrcode__text"},e?r.text.connect_mobile_wallet:r.text.choose_preferred_wallet),!e&&T.createElement("input",{className:"walletconnect-search__input",placeholder:"Search",value:i,onChange:_}),T.createElement("div",{className:"walletconnect-connect__buttons__wrapper"+(e?"__android":f&&h.length?"__wrap":"")},e?T.createElement(of,{name:r.text.connect,color:tf,href:r.uri,onClick:T.useCallback(function(){de.saveMobileLinkInfo({name:"Unknown",href:r.uri})},[])}):y.length?y.map(function(w){var b=w.color,E=w.name,I=w.shortName,x=w.logo,N=de.formatIOSMobile(r.uri,w),$=T.useCallback(function(){de.saveMobileLinkInfo({name:E,href:N})},[y]);return f?T.createElement(lf,{color:b,href:N,name:I||E,logo:x,onClick:$}):T.createElement(cf,{color:b,href:N,name:E,logo:x,onClick:$})}):T.createElement(T.Fragment,null,T.createElement("p",null,d.length?r.errorMessage:r.links.length&&!h.length?r.text.no_wallets_found:r.text.loading))),m&&T.createElement("div",{className:"walletconnect-modal__footer"},Array(p).fill(0).map(function(w,b){var E=b+1,I=c===E;return T.createElement("a",{style:{margin:"auto 10px",fontWeight:I?"bold":"normal"},onClick:function(){return u(E)}},E)})))}function df(r){var e=!!r.message.trim();return T.createElement("div",{className:"walletconnect-qrcode__notification"+(e?" notification__show":"")},r.message)}var ff=function(r){try{var e="";return Promise.resolve(Vc.toString(r,{margin:0,type:"svg"})).then(function(t){return typeof t=="string"&&(e=t.replace("<svg",'<svg class="walletconnect-qrcode__image"')),e})}catch(t){return Promise.reject(t)}};function pf(r){var e=T.useState(""),t=e[0],i=e[1],n=T.useState(""),s=n[0],o=n[1];T.useEffect(function(){try{return Promise.resolve(ff(r.uri)).then(function(l){o(l)})}catch(l){Promise.reject(l)}},[]);var a=function(){var l=Jd(r.uri);l?(i(r.text.copied_to_clipboard),setInterval(function(){return i("")},1200)):(i("Error"),setInterval(function(){return i("")},1200))};return T.createElement("div",null,T.createElement("p",{id:Jc,className:"walletconnect-qrcode__text"},r.text.scan_qrcode_with_wallet),T.createElement("div",{dangerouslySetInnerHTML:{__html:s}}),T.createElement("div",{className:"walletconnect-modal__footer"},T.createElement("a",{onClick:a},r.text.copy_to_clipboard)),T.createElement(df,{message:t}))}function gf(r){var e=de.isAndroid(),t=de.isMobile(),i=t?r.qrcodeModalOptions&&r.qrcodeModalOptions.mobileLinks?r.qrcodeModalOptions.mobileLinks:void 0:r.qrcodeModalOptions&&r.qrcodeModalOptions.desktopLinks?r.qrcodeModalOptions.desktopLinks:void 0,n=T.useState(!1),s=n[0],o=n[1],a=T.useState(!1),l=a[0],c=a[1],u=T.useState(!t),h=u[0],d=u[1],f={mobile:t,text:r.text,uri:r.uri,qrcodeModalOptions:r.qrcodeModalOptions},p=T.useState(""),g=p[0],y=p[1],m=T.useState(!1),v=m[0],_=m[1],w=T.useState([]),b=w[0],E=w[1],I=T.useState(""),x=I[0],N=I[1],$=function(){l||s||i&&!i.length||b.length>0||T.useEffect(function(){var D=function(){try{if(e)return Promise.resolve();o(!0);var C=Qd(function(){var q=r.qrcodeModalOptions&&r.qrcodeModalOptions.registryUrl?r.qrcodeModalOptions.registryUrl:de.getWalletRegistryUrl();return Promise.resolve(fetch(q)).then(function(F){return Promise.resolve(F.json()).then(function(B){var K=B.listings,M=t?"mobile":"desktop",A=de.getMobileLinkRegistry(de.formatMobileRegistry(K,M),i);o(!1),c(!0),N(A.length?"":r.text.no_supported_wallets),E(A);var j=A.length===1;j&&(y(de.formatIOSMobile(r.uri,A[0])),d(!0)),_(j)})})},function(q){o(!1),c(!0),N(r.text.something_went_wrong),console.error(q)});return Promise.resolve(C&&C.then?C.then(function(){}):void 0)}catch(q){return Promise.reject(q)}};D()})};$();var O=t?h:!h;return T.createElement("div",{id:Hc,className:"walletconnect-qrcode__base animated fadeIn"},T.createElement("div",{className:"walletconnect-modal__base"},T.createElement(sf,{onClose:r.onClose}),v&&h?T.createElement("div",{className:"walletconnect-modal__single_wallet"},T.createElement("a",{onClick:function(){return de.saveMobileLinkInfo({name:b[0].name,href:g})},href:g,rel:"noopener noreferrer",target:"_blank"},r.text.connect_with+" "+(v?b[0].name:"")+" ›")):e||s||!s&&b.length?T.createElement("div",{className:"walletconnect-modal__mobile__toggle"+(O?" right__selected":"")},T.createElement("div",{className:"walletconnect-modal__mobile__toggle_selector"}),t?T.createElement(T.Fragment,null,T.createElement("a",{onClick:function(){return d(!1),$()}},r.text.mobile),T.createElement("a",{onClick:function(){return d(!0)}},r.text.qrcode)):T.createElement(T.Fragment,null,T.createElement("a",{onClick:function(){return d(!0)}},r.text.qrcode),T.createElement("a",{onClick:function(){return d(!1),$()}},r.text.desktop))):null,T.createElement("div",null,h||!e&&!s&&!b.length?T.createElement(pf,Object.assign({},f)):T.createElement(hf,Object.assign({},f,{links:b,errorMessage:x})))))}var yf={choose_preferred_wallet:"Wähle bevorzugte Wallet",connect_mobile_wallet:"Verbinde mit Mobile Wallet",scan_qrcode_with_wallet:"Scanne den QR-code mit einer WalletConnect kompatiblen Wallet",connect:"Verbinden",qrcode:"QR-Code",mobile:"Mobile",desktop:"Desktop",copy_to_clipboard:"In die Zwischenablage kopieren",copied_to_clipboard:"In die Zwischenablage kopiert!",connect_with:"Verbinden mit Hilfe von",loading:"Laden...",something_went_wrong:"Etwas ist schief gelaufen",no_supported_wallets:"Es gibt noch keine unterstützten Wallet",no_wallets_found:"keine Wallet gefunden"},mf={choose_preferred_wallet:"Choose your preferred wallet",connect_mobile_wallet:"Connect to Mobile Wallet",scan_qrcode_with_wallet:"Scan QR code with a WalletConnect-compatible wallet",connect:"Connect",qrcode:"QR Code",mobile:"Mobile",desktop:"Desktop",copy_to_clipboard:"Copy to clipboard",copied_to_clipboard:"Copied to clipboard!",connect_with:"Connect with",loading:"Loading...",something_went_wrong:"Something went wrong",no_supported_wallets:"There are no supported wallets yet",no_wallets_found:"No wallets found"},vf={choose_preferred_wallet:"Elige tu billetera preferida",connect_mobile_wallet:"Conectar a billetera móvil",scan_qrcode_with_wallet:"Escanea el código QR con una billetera compatible con WalletConnect",connect:"Conectar",qrcode:"Código QR",mobile:"Móvil",desktop:"Desktop",copy_to_clipboard:"Copiar",copied_to_clipboard:"Copiado!",connect_with:"Conectar mediante",loading:"Cargando...",something_went_wrong:"Algo salió mal",no_supported_wallets:"Todavía no hay billeteras compatibles",no_wallets_found:"No se encontraron billeteras"},wf={choose_preferred_wallet:"Choisissez votre portefeuille préféré",connect_mobile_wallet:"Se connecter au portefeuille mobile",scan_qrcode_with_wallet:"Scannez le QR code avec un portefeuille compatible WalletConnect",connect:"Se connecter",qrcode:"QR Code",mobile:"Mobile",desktop:"Desktop",copy_to_clipboard:"Copier",copied_to_clipboard:"Copié!",connect_with:"Connectez-vous à l'aide de",loading:"Chargement...",something_went_wrong:"Quelque chose a mal tourné",no_supported_wallets:"Il n'y a pas encore de portefeuilles pris en charge",no_wallets_found:"Aucun portefeuille trouvé"},_f={choose_preferred_wallet:"원하는 지갑을 선택하세요",connect_mobile_wallet:"모바일 지갑과 연결",scan_qrcode_with_wallet:"WalletConnect 지원 지갑에서 QR코드를 스캔하세요",connect:"연결",qrcode:"QR 코드",mobile:"모바일",desktop:"데스크탑",copy_to_clipboard:"클립보드에 복사",copied_to_clipboard:"클립보드에 복사되었습니다!",connect_with:"와 연결하다",loading:"로드 중...",something_went_wrong:"문제가 발생했습니다.",no_supported_wallets:"아직 지원되는 지갑이 없습니다",no_wallets_found:"지갑을 찾을 수 없습니다"},bf={choose_preferred_wallet:"Escolha sua carteira preferida",connect_mobile_wallet:"Conectar-se à carteira móvel",scan_qrcode_with_wallet:"Ler o código QR com uma carteira compatível com WalletConnect",connect:"Conectar",qrcode:"Código QR",mobile:"Móvel",desktop:"Desktop",copy_to_clipboard:"Copiar",copied_to_clipboard:"Copiado!",connect_with:"Ligar por meio de",loading:"Carregamento...",something_went_wrong:"Algo correu mal",no_supported_wallets:"Ainda não há carteiras suportadas",no_wallets_found:"Nenhuma carteira encontrada"},Ef={choose_preferred_wallet:"选择你的钱包",connect_mobile_wallet:"连接至移动端钱包",scan_qrcode_with_wallet:"使用兼容 WalletConnect 的钱包扫描二维码",connect:"连接",qrcode:"二维码",mobile:"移动",desktop:"桌面",copy_to_clipboard:"复制到剪贴板",copied_to_clipboard:"复制到剪贴板成功!",connect_with:"通过以下方式连接",loading:"正在加载...",something_went_wrong:"出了问题",no_supported_wallets:"目前还没有支持的钱包",no_wallets_found:"没有找到钱包"},If={choose_preferred_wallet:"کیف پول مورد نظر خود را انتخاب کنید",connect_mobile_wallet:"به کیف پول موبایل وصل شوید",scan_qrcode_with_wallet:"کد QR را با یک کیف پول سازگار با WalletConnect اسکن کنید",connect:"اتصال",qrcode:"کد QR",mobile:"سیار",desktop:"دسکتاپ",copy_to_clipboard:"کپی به کلیپ بورد",copied_to_clipboard:"در کلیپ بورد کپی شد!",connect_with:"ارتباط با",loading:"...بارگذاری",something_went_wrong:"مشکلی پیش آمد",no_supported_wallets:"هنوز هیچ کیف پول پشتیبانی شده ای وجود ندارد",no_wallets_found:"هیچ کیف پولی پیدا نشد"},Ws={de:yf,en:mf,es:vf,fr:wf,ko:_f,pt:bf,zh:Ef,fa:If};function Sf(){var r=de.getDocumentOrThrow(),e=r.getElementById(Vs);e&&r.head.removeChild(e);var t=r.createElement("style");t.setAttribute("id",Vs),t.innerText=Yd,r.head.appendChild(t)}function xf(){var r=de.getDocumentOrThrow(),e=r.createElement("div");return e.setAttribute("id",Wc),r.body.appendChild(e),e}function Gc(){var r=de.getDocumentOrThrow(),e=r.getElementById(Hc);e&&(e.className=e.className.replace("fadeIn","fadeOut"),setTimeout(function(){var t=r.getElementById(Wc);t&&r.body.removeChild(t)},ef))}function Pf(r){return function(){Gc(),r&&r()}}function Af(){var r=de.getNavigatorOrThrow().language.split("-")[0]||"en";return Ws[r]||Ws.en}function Tf(r,e,t){Sf();var i=xf();T.render(T.createElement(gf,{text:Af(),uri:r,onClose:Pf(e),qrcodeModalOptions:t}),i)}function Rf(){Gc()}var Yc=function(){return typeof R.process<"u"&&typeof R.process.versions<"u"&&typeof R.process.versions.node<"u"};function Nf(r,e,t){console.log(r),Yc()?Gd(r):Tf(r,e,t)}function $f(){Yc()||Rf()}var Of={open:Nf,close:$f},Cf=Of;const Hs=wa(Cf);let kf=class extends $t{constructor(e){super()}};const Js=S.FIVE_SECONDS,tr={pulse:"heartbeat_pulse"};class Gn extends kf{constructor(e){super(e),this.events=new Ge.EventEmitter,this.interval=Js,this.interval=(e==null?void 0:e.interval)||Js}static async init(e){const t=new Gn(e);return await t.init(),t}async init(){await 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)}async initialize(){this.intervalRef=setInterval(()=>this.pulse(),S.toMiliseconds(this.interval))}pulse(){this.events.emit(tr.pulse)}}function Mf(r){return!r||typeof r.then!="function"?Promise.resolve(r):r}function ne(r,...e){try{return Mf(r(...e))}catch(t){return Promise.reject(t)}}function Lf(r){const e=typeof r;return r===null||e!=="object"&&e!=="function"}function Df(r){const e=Object.getPrototypeOf(r);return!e||e.isPrototypeOf(Object)}function jr(r){if(Lf(r))return String(r);if(Df(r)||Array.isArray(r))return JSON.stringify(r);if(typeof r.toJSON=="function")return jr(r.toJSON());throw new Error("[unstorage] Cannot stringify value!")}const fn="base64:";function Ff(r){return typeof r=="string"?r:fn+Bf(r)}function qf(r){return typeof r!="string"||!r.startsWith(fn)?r:Uf(r.slice(fn.length))}function Uf(r){return globalThis.Buffer?R.Buffer.from(r,"base64"):Uint8Array.from(globalThis.atob(r),e=>e.codePointAt(0))}function Bf(r){return globalThis.Buffer?R.Buffer.from(r).toString("base64"):globalThis.btoa(String.fromCodePoint(...r))}function ye(r){var e;return r&&((e=r.split("?")[0])==null?void 0:e.replace(/[/\\]/g,":").replace(/:+/g,":").replace(/^:|:$/g,""))||""}function zf(...r){return ye(r.join(":"))}function Fr(r){return r=ye(r),r?r+":":""}const Kf="memory",jf=()=>{const r=new Map;return{name:Kf,getInstance:()=>r,hasItem(e){return r.has(e)},getItem(e){return r.get(e)??null},getItemRaw(e){return r.get(e)??null},setItem(e,t){r.set(e,t)},setItemRaw(e,t){r.set(e,t)},removeItem(e){r.delete(e)},getKeys(){return[...r.keys()]},clear(){r.clear()},dispose(){r.clear()}}};function Vf(r={}){const e={mounts:{"":r.driver||jf()},mountpoints:[""],watching:!1,watchListeners:[],unwatch:{}},t=c=>{for(const u of e.mountpoints)if(c.startsWith(u))return{base:u,relativeKey:c.slice(u.length),driver:e.mounts[u]};return{base:"",relativeKey:c,driver:e.mounts[""]}},i=(c,u)=>e.mountpoints.filter(h=>h.startsWith(c)||u&&c.startsWith(h)).map(h=>({relativeBase:c.length>h.length?c.slice(h.length):void 0,mountpoint:h,driver:e.mounts[h]})),n=(c,u)=>{if(e.watching){u=ye(u);for(const h of e.watchListeners)h(c,u)}},s=async()=>{if(!e.watching){e.watching=!0;for(const c in e.mounts)e.unwatch[c]=await Gs(e.mounts[c],n,c)}},o=async()=>{if(e.watching){for(const c in e.unwatch)await e.unwatch[c]();e.unwatch={},e.watching=!1}},a=(c,u,h)=>{const d=new Map,f=p=>{let g=d.get(p.base);return g||(g={driver:p.driver,base:p.base,items:[]},d.set(p.base,g)),g};for(const p of c){const g=typeof p=="string",y=ye(g?p:p.key),m=g?void 0:p.value,v=g||!p.options?u:{...u,...p.options},_=t(y);f(_).items.push({key:y,value:m,relativeKey:_.relativeKey,options:v})}return Promise.all([...d.values()].map(p=>h(p))).then(p=>p.flat())},l={hasItem(c,u={}){c=ye(c);const{relativeKey:h,driver:d}=t(c);return ne(d.hasItem,h,u)},getItem(c,u={}){c=ye(c);const{relativeKey:h,driver:d}=t(c);return ne(d.getItem,h,u).then(f=>Mr(f))},getItems(c,u={}){return a(c,u,h=>h.driver.getItems?ne(h.driver.getItems,h.items.map(d=>({key:d.relativeKey,options:d.options})),u).then(d=>d.map(f=>({key:zf(h.base,f.key),value:Mr(f.value)}))):Promise.all(h.items.map(d=>ne(h.driver.getItem,d.relativeKey,d.options).then(f=>({key:d.key,value:Mr(f)})))))},getItemRaw(c,u={}){c=ye(c);const{relativeKey:h,driver:d}=t(c);return d.getItemRaw?ne(d.getItemRaw,h,u):ne(d.getItem,h,u).then(f=>qf(f))},async setItem(c,u,h={}){if(u===void 0)return l.removeItem(c);c=ye(c);const{relativeKey:d,driver:f}=t(c);f.setItem&&(await ne(f.setItem,d,jr(u),h),f.watch||n("update",c))},async setItems(c,u){await a(c,u,async h=>{if(h.driver.setItems)return ne(h.driver.setItems,h.items.map(d=>({key:d.relativeKey,value:jr(d.value),options:d.options})),u);h.driver.setItem&&await Promise.all(h.items.map(d=>ne(h.driver.setItem,d.relativeKey,jr(d.value),d.options)))})},async setItemRaw(c,u,h={}){if(u===void 0)return l.removeItem(c,h);c=ye(c);const{relativeKey:d,driver:f}=t(c);if(f.setItemRaw)await ne(f.setItemRaw,d,u,h);else if(f.setItem)await ne(f.setItem,d,Ff(u),h);else return;f.watch||n("update",c)},async removeItem(c,u={}){typeof u=="boolean"&&(u={removeMeta:u}),c=ye(c);const{relativeKey:h,driver:d}=t(c);d.removeItem&&(await ne(d.removeItem,h,u),(u.removeMeta||u.removeMata)&&await ne(d.removeItem,h+"$",u),d.watch||n("remove",c))},async getMeta(c,u={}){typeof u=="boolean"&&(u={nativeOnly:u}),c=ye(c);const{relativeKey:h,driver:d}=t(c),f=Object.create(null);if(d.getMeta&&Object.assign(f,await ne(d.getMeta,h,u)),!u.nativeOnly){const p=await ne(d.getItem,h+"$",u).then(g=>Mr(g));p&&typeof p=="object"&&(typeof p.atime=="string"&&(p.atime=new Date(p.atime)),typeof p.mtime=="string"&&(p.mtime=new Date(p.mtime)),Object.assign(f,p))}return f},setMeta(c,u,h={}){return this.setItem(c+"$",u,h)},removeMeta(c,u={}){return this.removeItem(c+"$",u)},async getKeys(c,u={}){c=Fr(c);const h=i(c,!0);let d=[];const f=[];for(const p of h){const g=await ne(p.driver.getKeys,p.relativeBase,u);for(const y of g){const m=p.mountpoint+ye(y);d.some(v=>m.startsWith(v))||f.push(m)}d=[p.mountpoint,...d.filter(y=>!y.startsWith(p.mountpoint))]}return c?f.filter(p=>p.startsWith(c)&&p[p.length-1]!=="$"):f.filter(p=>p[p.length-1]!=="$")},async clear(c,u={}){c=Fr(c),await Promise.all(i(c,!1).map(async h=>{if(h.driver.clear)return ne(h.driver.clear,h.relativeBase,u);if(h.driver.removeItem){const d=await h.driver.getKeys(h.relativeBase||"",u);return Promise.all(d.map(f=>h.driver.removeItem(f,u)))}}))},async dispose(){await Promise.all(Object.values(e.mounts).map(c=>Ys(c)))},async watch(c){return await s(),e.watchListeners.push(c),async()=>{e.watchListeners=e.watchListeners.filter(u=>u!==c),e.watchListeners.length===0&&await o()}},async unwatch(){e.watchListeners=[],await o()},mount(c,u){if(c=Fr(c),c&&e.mounts[c])throw new Error(`already mounted at ${c}`);return c&&(e.mountpoints.push(c),e.mountpoints.sort((h,d)=>d.length-h.length)),e.mounts[c]=u,e.watching&&Promise.resolve(Gs(u,n,c)).then(h=>{e.unwatch[c]=h}).catch(console.error),l},async unmount(c,u=!0){var h,d;c=Fr(c),!(!c||!e.mounts[c])&&(e.watching&&c in e.unwatch&&((d=(h=e.unwatch)[c])==null||d.call(h),delete e.unwatch[c]),u&&await Ys(e.mounts[c]),e.mountpoints=e.mountpoints.filter(f=>f!==c),delete e.mounts[c])},getMount(c=""){c=ye(c)+":";const u=t(c);return{driver:u.driver,base:u.base}},getMounts(c="",u={}){return c=ye(c),i(c,u.parents).map(d=>({driver:d.driver,base:d.mountpoint}))},keys:(c,u={})=>l.getKeys(c,u),get:(c,u={})=>l.getItem(c,u),set:(c,u,h={})=>l.setItem(c,u,h),has:(c,u={})=>l.hasItem(c,u),del:(c,u={})=>l.removeItem(c,u),remove:(c,u={})=>l.removeItem(c,u)};return l}function Gs(r,e,t){return r.watch?r.watch((i,n)=>e(i,t+n)):()=>{}}async function Ys(r){typeof r.dispose=="function"&&await ne(r.dispose)}const Wf=r=>JSON.stringify(r,(e,t)=>typeof t=="bigint"?t.toString()+"n":t),Hf=r=>{const e=/([\[:])?(\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,t=r.replace(e,'$1"$2n"$3');return JSON.parse(t,(i,n)=>typeof n=="string"&&n.match(/^\d+n$/)?BigInt(n.substring(0,n.length-1)):n)};function ii(r){if(typeof r!="string")throw new Error(`Cannot safe json parse value of type ${typeof r}`);try{return Hf(r)}catch{return r}}function Yn(r){return typeof r=="string"?r:Wf(r)||""}const Jf="idb-keyval";var Gf=(r={})=>{const e=r.base&&r.base.length>0?`${r.base}:`:"",t=n=>e+n;let i;return r.dbName&&r.storeName&&(i=hu(r.dbName,r.storeName)),{name:Jf,options:r,async hasItem(n){return!(typeof await ps(t(n),i)>"u")},async getItem(n){return await ps(t(n),i)??null},setItem(n,s){return gu(t(n),s,i)},removeItem(n){return pu(t(n),i)},getKeys(){return fu(i)},clear(){return du(i)}}};const Yf="WALLET_CONNECT_V2_INDEXED_DB",Qf="keyvaluestorage";let Xf=class{constructor(){this.indexedDb=Vf({driver:Gf({dbName:Yf,storeName:Qf})})}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(t!==null)return t}async setItem(e,t){await this.indexedDb.setItem(e,Yn(t))}async removeItem(e){await this.indexedDb.removeItem(e)}};var qi=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof R.global<"u"?R.global:typeof self<"u"?self:{},Vr={exports:{}};(function(){let r;function e(){}r=e,r.prototype.getItem=function(t){return this.hasOwnProperty(t)?String(this[t]):null},r.prototype.setItem=function(t,i){this[t]=String(i)},r.prototype.removeItem=function(t){delete this[t]},r.prototype.clear=function(){const t=this;Object.keys(t).forEach(function(i){t[i]=void 0,delete t[i]})},r.prototype.key=function(t){return t=t||0,Object.keys(this)[t]},r.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),typeof qi<"u"&&qi.localStorage?Vr.exports=qi.localStorage:typeof window<"u"&&window.localStorage?Vr.exports=window.localStorage:Vr.exports=new e})();function Zf(r){var e;return[r[0],ii((e=r[1])!=null?e:"")]}class ep{constructor(){this.localStorage=Vr.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(Zf)}async getItem(e){const t=this.localStorage.getItem(e);if(t!==null)return ii(t)}async setItem(e,t){this.localStorage.setItem(e,Yn(t))}async removeItem(e){this.localStorage.removeItem(e)}}const tp="wc_storage_version",Qs=1,rp=async(r,e,t)=>{const i=tp,n=await e.getItem(i);if(n&&n>=Qs){t(e);return}const s=await r.getKeys();if(!s.length){t(e);return}const o=[];for(;s.length;){const a=s.shift();if(!a)continue;const l=a.toLowerCase();if(l.includes("wc@")||l.includes("walletconnect")||l.includes("wc_")||l.includes("wallet_connect")){const c=await r.getItem(a);await e.setItem(a,c),o.push(a)}}await e.setItem(i,Qs),t(e),ip(r,o)},ip=async(r,e)=>{e.length&&e.forEach(async t=>{await r.removeItem(t)})};let np=class{constructor(){this.initialized=!1,this.setInitialized=t=>{this.storage=t,this.initialized=!0};const e=new ep;this.storage=e;try{const t=new Xf;rp(e,t,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)})}};class sp extends $t{constructor(e){super(),this.opts=e,this.protocol="wc",this.version=2}}let op=class extends $t{constructor(e,t){super(),this.core=e,this.logger=t,this.records=new Map}};class ap{constructor(e,t){this.logger=e,this.core=t}}class cp extends $t{constructor(e,t){super(),this.relayer=e,this.logger=t}}class lp extends $t{constructor(e){super()}}class up{constructor(e,t,i,n){this.core=e,this.logger=t,this.name=i}}let hp=class extends $t{constructor(e,t){super(),this.relayer=e,this.logger=t}},dp=class extends $t{constructor(e,t){super(),this.core=e,this.logger=t}};class fp{constructor(e,t,i){this.core=e,this.logger=t,this.store=i}}let pp=class{constructor(e,t){this.projectId=e,this.logger=t}},gp=class{constructor(e,t,i){this.core=e,this.logger=t,this.telemetryEnabled=i}};var Q={};Object.defineProperty(Q,"__esModule",{value:!0});Q.getLocalStorage=Q.getLocalStorageOrThrow=Q.getCrypto=Q.getCryptoOrThrow=Qc=Q.getLocation=Q.getLocationOrThrow=Qn=Q.getNavigator=Q.getNavigatorOrThrow=_i=Q.getDocument=Q.getDocumentOrThrow=Q.getFromWindowOrThrow=Q.getFromWindow=void 0;function kt(r){let e;return typeof window<"u"&&typeof window[r]<"u"&&(e=window[r]),e}Q.getFromWindow=kt;function rr(r){const e=kt(r);if(!e)throw new Error(`${r} is not defined in Window`);return e}Q.getFromWindowOrThrow=rr;function yp(){return rr("document")}Q.getDocumentOrThrow=yp;function mp(){return kt("document")}var _i=Q.getDocument=mp;function vp(){return rr("navigator")}Q.getNavigatorOrThrow=vp;function wp(){return kt("navigator")}var Qn=Q.getNavigator=wp;function _p(){return rr("location")}Q.getLocationOrThrow=_p;function bp(){return kt("location")}var Qc=Q.getLocation=bp;function Ep(){return rr("crypto")}Q.getCryptoOrThrow=Ep;function Ip(){return kt("crypto")}Q.getCrypto=Ip;function Sp(){return rr("localStorage")}Q.getLocalStorageOrThrow=Sp;function xp(){return kt("localStorage")}Q.getLocalStorage=xp;var Xn={};Object.defineProperty(Xn,"__esModule",{value:!0});var Xc=Xn.getWindowMetadata=void 0;const Xs=Q;function Pp(){let r,e;try{r=Xs.getDocumentOrThrow(),e=Xs.getLocationOrThrow()}catch{return null}function t(){const h=r.getElementsByTagName("link"),d=[];for(let f=0;f<h.length;f++){const p=h[f],g=p.getAttribute("rel");if(g&&g.toLowerCase().indexOf("icon")>-1){const y=p.getAttribute("href");if(y)if(y.toLowerCase().indexOf("https:")===-1&&y.toLowerCase().indexOf("http:")===-1&&y.indexOf("//")!==0){let m=e.protocol+"//"+e.host;if(y.indexOf("/")===0)m+=y;else{const v=e.pathname.split("/");v.pop();const _=v.join("/");m+=_+"/"+y}d.push(m)}else if(y.indexOf("//")===0){const m=e.protocol+y;d.push(m)}else d.push(y)}}return d}function i(...h){const d=r.getElementsByTagName("meta");for(let f=0;f<d.length;f++){const p=d[f],g=["itemprop","property","name"].map(y=>p.getAttribute(y)).filter(y=>y?h.includes(y):!1);if(g.length&&g){const y=p.getAttribute("content");if(y)return y}}return""}function n(){let h=i("name","og:site_name","og:title","twitter:title");return h||(h=r.title),h}function s(){return i("description","og:description","twitter:description","keywords")}const o=n(),a=s(),l=e.origin,c=t();return{description:a,url:l,icons:c,name:o}}Xc=Xn.getWindowMetadata=Pp;function ir(r,e,t){return t={path:e,exports:{},require:function(i,n){return Ap(i,n??t.path)}},r(t,t.exports),t.exports}function Ap(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}var Zn=Zc;function Zc(r,e){if(!r)throw new Error(e||"Assertion failed")}Zc.equal=function(e,t,i){if(e!=t)throw new Error(i||"Assertion failed: "+e+" != "+t)};var ze=ir(function(r,e){var t=e;function i(o,a){if(Array.isArray(o))return o.slice();if(!o)return[];var l=[];if(typeof o!="string"){for(var c=0;c<o.length;c++)l[c]=o[c]|0;return l}if(a==="hex"){o=o.replace(/[^a-z0-9]+/ig,""),o.length%2!==0&&(o="0"+o);for(var c=0;c<o.length;c+=2)l.push(parseInt(o[c]+o[c+1],16))}else for(var c=0;c<o.length;c++){var u=o.charCodeAt(c),h=u>>8,d=u&255;h?l.push(h,d):l.push(d)}return l}t.toArray=i;function n(o){return o.length===1?"0"+o:o}t.zero2=n;function s(o){for(var a="",l=0;l<o.length;l++)a+=n(o[l].toString(16));return a}t.toHex=s,t.encode=function(a,l){return l==="hex"?s(a):a}}),xe=ir(function(r,e){var t=e;t.assert=Zn,t.toArray=ze.toArray,t.zero2=ze.zero2,t.toHex=ze.toHex,t.encode=ze.encode;function i(l,c,u){var h=new Array(Math.max(l.bitLength(),u)+1);h.fill(0);for(var d=1<<c+1,f=l.clone(),p=0;p<h.length;p++){var g,y=f.andln(d-1);f.isOdd()?(y>(d>>1)-1?g=(d>>1)-y:g=y,f.isubn(g)):g=0,h[p]=g,f.iushrn(1)}return h}t.getNAF=i;function n(l,c){var u=[[],[]];l=l.clone(),c=c.clone();for(var h=0,d=0,f;l.cmpn(-h)>0||c.cmpn(-d)>0;){var p=l.andln(3)+h&3,g=c.andln(3)+d&3;p===3&&(p=-1),g===3&&(g=-1);var y;p&1?(f=l.andln(7)+h&7,(f===3||f===5)&&g===2?y=-p:y=p):y=0,u[0].push(y);var m;g&1?(f=c.andln(7)+d&7,(f===3||f===5)&&p===2?m=-g:m=g):m=0,u[1].push(m),2*h===y+1&&(h=1-h),2*d===m+1&&(d=1-d),l.iushrn(1),c.iushrn(1)}return u}t.getJSF=n;function s(l,c,u){var h="_"+c;l.prototype[c]=function(){return this[h]!==void 0?this[h]:this[h]=u.call(this)}}t.cachedProperty=s;function o(l){return typeof l=="string"?t.toArray(l,"hex"):l}t.parseBytes=o;function a(l){return new L(l,"hex","le")}t.intFromLE=a}),ni=xe.getNAF,Tp=xe.getJSF,si=xe.assert;function vt(r,e){this.type=r,this.p=new L(e.p,16),this.red=e.prime?L.red(e.prime):L.mont(this.p),this.zero=new L(0).toRed(this.red),this.one=new L(1).toRed(this.red),this.two=new L(2).toRed(this.red),this.n=e.n&&new L(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var t=this.n&&this.p.div(this.n);!t||t.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var Mt=vt;vt.prototype.point=function(){throw new Error("Not implemented")};vt.prototype.validate=function(){throw new Error("Not implemented")};vt.prototype._fixedNafMul=function(e,t){si(e.precomputed);var i=e._getDoubles(),n=ni(t,1,this._bitLength),s=(1<<i.step+1)-(i.step%2===0?2:1);s/=3;var o=[],a,l;for(a=0;a<n.length;a+=i.step){l=0;for(var c=a+i.step-1;c>=a;c--)l=(l<<1)+n[c];o.push(l)}for(var u=this.jpoint(null,null,null),h=this.jpoint(null,null,null),d=s;d>0;d--){for(a=0;a<o.length;a++)l=o[a],l===d?h=h.mixedAdd(i.points[a]):l===-d&&(h=h.mixedAdd(i.points[a].neg()));u=u.add(h)}return u.toP()};vt.prototype._wnafMul=function(e,t){var i=4,n=e._getNAFPoints(i);i=n.wnd;for(var s=n.points,o=ni(t,i,this._bitLength),a=this.jpoint(null,null,null),l=o.length-1;l>=0;l--){for(var c=0;l>=0&&o[l]===0;l--)c++;if(l>=0&&c++,a=a.dblp(c),l<0)break;var u=o[l];si(u!==0),e.type==="affine"?u>0?a=a.mixedAdd(s[u-1>>1]):a=a.mixedAdd(s[-u-1>>1].neg()):u>0?a=a.add(s[u-1>>1]):a=a.add(s[-u-1>>1].neg())}return e.type==="affine"?a.toP():a};vt.prototype._wnafMulAdd=function(e,t,i,n,s){var o=this._wnafT1,a=this._wnafT2,l=this._wnafT3,c=0,u,h,d;for(u=0;u<n;u++){d=t[u];var f=d._getNAFPoints(e);o[u]=f.wnd,a[u]=f.points}for(u=n-1;u>=1;u-=2){var p=u-1,g=u;if(o[p]!==1||o[g]!==1){l[p]=ni(i[p],o[p],this._bitLength),l[g]=ni(i[g],o[g],this._bitLength),c=Math.max(l[p].length,c),c=Math.max(l[g].length,c);continue}var y=[t[p],null,null,t[g]];t[p].y.cmp(t[g].y)===0?(y[1]=t[p].add(t[g]),y[2]=t[p].toJ().mixedAdd(t[g].neg())):t[p].y.cmp(t[g].y.redNeg())===0?(y[1]=t[p].toJ().mixedAdd(t[g]),y[2]=t[p].add(t[g].neg())):(y[1]=t[p].toJ().mixedAdd(t[g]),y[2]=t[p].toJ().mixedAdd(t[g].neg()));var m=[-3,-1,-5,-7,0,7,5,1,3],v=Tp(i[p],i[g]);for(c=Math.max(v[0].length,c),l[p]=new Array(c),l[g]=new Array(c),h=0;h<c;h++){var _=v[0][h]|0,w=v[1][h]|0;l[p][h]=m[(_+1)*3+(w+1)],l[g][h]=0,a[p]=y}}var b=this.jpoint(null,null,null),E=this._wnafT4;for(u=c;u>=0;u--){for(var I=0;u>=0;){var x=!0;for(h=0;h<n;h++)E[h]=l[h][u]|0,E[h]!==0&&(x=!1);if(!x)break;I++,u--}if(u>=0&&I++,b=b.dblp(I),u<0)break;for(h=0;h<n;h++){var N=E[h];N!==0&&(N>0?d=a[h][N-1>>1]:N<0&&(d=a[h][-N-1>>1].neg()),d.type==="affine"?b=b.mixedAdd(d):b=b.add(d))}}for(u=0;u<n;u++)a[u]=null;return s?b:b.toP()};function ke(r,e){this.curve=r,this.type=e,this.precomputed=null}vt.BasePoint=ke;ke.prototype.eq=function(){throw new Error("Not implemented")};ke.prototype.validate=function(){return this.curve.validate(this)};vt.prototype.decodePoint=function(e,t){e=xe.toArray(e,t);var i=this.p.byteLength();if((e[0]===4||e[0]===6||e[0]===7)&&e.length-1===2*i){e[0]===6?si(e[e.length-1]%2===0):e[0]===7&&si(e[e.length-1]%2===1);var n=this.point(e.slice(1,1+i),e.slice(1+i,1+2*i));return n}else if((e[0]===2||e[0]===3)&&e.length-1===i)return this.pointFromX(e.slice(1,1+i),e[0]===3);throw new Error("Unknown point format")};ke.prototype.encodeCompressed=function(e){return this.encode(e,!0)};ke.prototype._encode=function(e){var t=this.curve.p.byteLength(),i=this.getX().toArray("be",t);return e?[this.getY().isEven()?2:3].concat(i):[4].concat(i,this.getY().toArray("be",t))};ke.prototype.encode=function(e,t){return xe.encode(this._encode(t),e)};ke.prototype.precompute=function(e){if(this.precomputed)return this;var t={doubles:null,naf:null,beta:null};return t.naf=this._getNAFPoints(8),t.doubles=this._getDoubles(4,e),t.beta=this._getBeta(),this.precomputed=t,this};ke.prototype._hasDoubles=function(e){if(!this.precomputed)return!1;var t=this.precomputed.doubles;return t?t.points.length>=Math.ceil((e.bitLength()+1)/t.step):!1};ke.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var i=[this],n=this,s=0;s<t;s+=e){for(var o=0;o<e;o++)n=n.dbl();i.push(n)}return{step:e,points:i}};ke.prototype._getNAFPoints=function(e){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var t=[this],i=(1<<e)-1,n=i===1?null:this.dbl(),s=1;s<i;s++)t[s]=t[s-1].add(n);return{wnd:e,points:t}};ke.prototype._getBeta=function(){return null};ke.prototype.dblp=function(e){for(var t=this,i=0;i<e;i++)t=t.dbl();return t};var es=ir(function(r){typeof Object.create=="function"?r.exports=function(t,i){i&&(t.super_=i,t.prototype=Object.create(i.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:r.exports=function(t,i){if(i){t.super_=i;var n=function(){};n.prototype=i.prototype,t.prototype=new n,t.prototype.constructor=t}}}),Rp=xe.assert;function Me(r){Mt.call(this,"short",r),this.a=new L(r.a,16).toRed(this.red),this.b=new L(r.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=this.a.fromRed().cmpn(0)===0,this.threeA=this.a.fromRed().sub(this.p).cmpn(-3)===0,this.endo=this._getEndomorphism(r),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}es(Me,Mt);var Np=Me;Me.prototype._getEndomorphism=function(e){if(!(!this.zeroA||!this.g||!this.n||this.p.modn(3)!==1)){var t,i;if(e.beta)t=new L(e.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);t=n[0].cmp(n[1])<0?n[0]:n[1],t=t.toRed(this.red)}if(e.lambda)i=new L(e.lambda,16);else{var s=this._getEndoRoots(this.n);this.g.mul(s[0]).x.cmp(this.g.x.redMul(t))===0?i=s[0]:(i=s[1],Rp(this.g.mul(i).x.cmp(this.g.x.redMul(t))===0))}var o;return e.basis?o=e.basis.map(function(a){return{a:new L(a.a,16),b:new L(a.b,16)}}):o=this._getEndoBasis(i),{beta:t,lambda:i,basis:o}}};Me.prototype._getEndoRoots=function(e){var t=e===this.p?this.red:L.mont(e),i=new L(2).toRed(t).redInvm(),n=i.redNeg(),s=new L(3).toRed(t).redNeg().redSqrt().redMul(i),o=n.redAdd(s).fromRed(),a=n.redSub(s).fromRed();return[o,a]};Me.prototype._getEndoBasis=function(e){for(var t=this.n.ushrn(Math.floor(this.n.bitLength()/2)),i=e,n=this.n.clone(),s=new L(1),o=new L(0),a=new L(0),l=new L(1),c,u,h,d,f,p,g,y=0,m,v;i.cmpn(0)!==0;){var _=n.div(i);m=n.sub(_.mul(i)),v=a.sub(_.mul(s));var w=l.sub(_.mul(o));if(!h&&m.cmp(t)<0)c=g.neg(),u=s,h=m.neg(),d=v;else if(h&&++y===2)break;g=m,n=i,i=m,a=s,s=v,l=o,o=w}f=m.neg(),p=v;var b=h.sqr().add(d.sqr()),E=f.sqr().add(p.sqr());return E.cmp(b)>=0&&(f=c,p=u),h.negative&&(h=h.neg(),d=d.neg()),f.negative&&(f=f.neg(),p=p.neg()),[{a:h,b:d},{a:f,b:p}]};Me.prototype._endoSplit=function(e){var t=this.endo.basis,i=t[0],n=t[1],s=n.b.mul(e).divRound(this.n),o=i.b.neg().mul(e).divRound(this.n),a=s.mul(i.a),l=o.mul(n.a),c=s.mul(i.b),u=o.mul(n.b),h=e.sub(a).sub(l),d=c.add(u).neg();return{k1:h,k2:d}};Me.prototype.pointFromX=function(e,t){e=new L(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=i.redSqrt();if(n.redSqr().redSub(i).cmp(this.zero)!==0)throw new Error("invalid point");var s=n.fromRed().isOdd();return(t&&!s||!t&&s)&&(n=n.redNeg()),this.point(e,n)};Me.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,i=e.y,n=this.a.redMul(t),s=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return i.redSqr().redISub(s).cmpn(0)===0};Me.prototype._endoWnafMulAdd=function(e,t,i){for(var n=this._endoWnafT1,s=this._endoWnafT2,o=0;o<e.length;o++){var a=this._endoSplit(t[o]),l=e[o],c=l._getBeta();a.k1.negative&&(a.k1.ineg(),l=l.neg(!0)),a.k2.negative&&(a.k2.ineg(),c=c.neg(!0)),n[o*2]=l,n[o*2+1]=c,s[o*2]=a.k1,s[o*2+1]=a.k2}for(var u=this._wnafMulAdd(1,n,s,o*2,i),h=0;h<o*2;h++)n[h]=null,s[h]=null;return u};function oe(r,e,t,i){Mt.BasePoint.call(this,r,"affine"),e===null&&t===null?(this.x=null,this.y=null,this.inf=!0):(this.x=new L(e,16),this.y=new L(t,16),i&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}es(oe,Mt.BasePoint);Me.prototype.point=function(e,t,i){return new oe(this,e,t,i)};Me.prototype.pointFromJSON=function(e,t){return oe.fromJSON(this,e,t)};oe.prototype._getBeta=function(){if(this.curve.endo){var e=this.precomputed;if(e&&e.beta)return e.beta;var t=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(e){var i=this.curve,n=function(s){return i.point(s.x.redMul(i.endo.beta),s.y)};e.beta=t,t.precomputed={beta:null,naf:e.naf&&{wnd:e.naf.wnd,points:e.naf.points.map(n)},doubles:e.doubles&&{step:e.doubles.step,points:e.doubles.points.map(n)}}}return t}};oe.prototype.toJSON=function(){return this.precomputed?[this.x,this.y,this.precomputed&&{doubles:this.precomputed.doubles&&{step:this.precomputed.doubles.step,points:this.precomputed.doubles.points.slice(1)},naf:this.precomputed.naf&&{wnd:this.precomputed.naf.wnd,points:this.precomputed.naf.points.slice(1)}}]:[this.x,this.y]};oe.fromJSON=function(e,t,i){typeof t=="string"&&(t=JSON.parse(t));var n=e.point(t[0],t[1],i);if(!t[2])return n;function s(a){return e.point(a[0],a[1],i)}var o=t[2];return n.precomputed={beta:null,doubles:o.doubles&&{step:o.doubles.step,points:[n].concat(o.doubles.points.map(s))},naf:o.naf&&{wnd:o.naf.wnd,points:[n].concat(o.naf.points.map(s))}},n};oe.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+">"};oe.prototype.isInfinity=function(){return this.inf};oe.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(this.x.cmp(e.x)===0)return this.curve.point(null,null);var t=this.y.redSub(e.y);t.cmpn(0)!==0&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var i=t.redSqr().redISub(this.x).redISub(e.x),n=t.redMul(this.x.redSub(i)).redISub(this.y);return this.curve.point(i,n)};oe.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(e.cmpn(0)===0)return this.curve.point(null,null);var t=this.curve.a,i=this.x.redSqr(),n=e.redInvm(),s=i.redAdd(i).redIAdd(i).redIAdd(t).redMul(n),o=s.redSqr().redISub(this.x.redAdd(this.x)),a=s.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,a)};oe.prototype.getX=function(){return this.x.fromRed()};oe.prototype.getY=function(){return this.y.fromRed()};oe.prototype.mul=function(e){return e=new L(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)};oe.prototype.mulAdd=function(e,t,i){var n=[this,t],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s):this.curve._wnafMulAdd(1,n,s,2)};oe.prototype.jmulAdd=function(e,t,i){var n=[this,t],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s,!0):this.curve._wnafMulAdd(1,n,s,2,!0)};oe.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||this.x.cmp(e.x)===0&&this.y.cmp(e.y)===0)};oe.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var i=this.precomputed,n=function(s){return s.neg()};t.precomputed={naf:i.naf&&{wnd:i.naf.wnd,points:i.naf.points.map(n)},doubles:i.doubles&&{step:i.doubles.step,points:i.doubles.points.map(n)}}}return t};oe.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var e=this.curve.jpoint(this.x,this.y,this.curve.one);return e};function ce(r,e,t,i){Mt.BasePoint.call(this,r,"jacobian"),e===null&&t===null&&i===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new L(0)):(this.x=new L(e,16),this.y=new L(t,16),this.z=new L(i,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}es(ce,Mt.BasePoint);Me.prototype.jpoint=function(e,t,i){return new ce(this,e,t,i)};ce.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),i=this.x.redMul(t),n=this.y.redMul(t).redMul(e);return this.curve.point(i,n)};ce.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)};ce.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),i=this.z.redSqr(),n=this.x.redMul(t),s=e.x.redMul(i),o=this.y.redMul(t.redMul(e.z)),a=e.y.redMul(i.redMul(this.z)),l=n.redSub(s),c=o.redSub(a);if(l.cmpn(0)===0)return c.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var u=l.redSqr(),h=u.redMul(l),d=n.redMul(u),f=c.redSqr().redIAdd(h).redISub(d).redISub(d),p=c.redMul(d.redISub(f)).redISub(o.redMul(h)),g=this.z.redMul(e.z).redMul(l);return this.curve.jpoint(f,p,g)};ce.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),i=this.x,n=e.x.redMul(t),s=this.y,o=e.y.redMul(t).redMul(this.z),a=i.redSub(n),l=s.redSub(o);if(a.cmpn(0)===0)return l.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var c=a.redSqr(),u=c.redMul(a),h=i.redMul(c),d=l.redSqr().redIAdd(u).redISub(h).redISub(h),f=l.redMul(h.redISub(d)).redISub(s.redMul(u)),p=this.z.redMul(a);return this.curve.jpoint(d,f,p)};ce.prototype.dblp=function(e){if(e===0)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var t;if(this.curve.zeroA||this.curve.threeA){var i=this;for(t=0;t<e;t++)i=i.dbl();return i}var n=this.curve.a,s=this.curve.tinv,o=this.x,a=this.y,l=this.z,c=l.redSqr().redSqr(),u=a.redAdd(a);for(t=0;t<e;t++){var h=o.redSqr(),d=u.redSqr(),f=d.redSqr(),p=h.redAdd(h).redIAdd(h).redIAdd(n.redMul(c)),g=o.redMul(d),y=p.redSqr().redISub(g.redAdd(g)),m=g.redISub(y),v=p.redMul(m);v=v.redIAdd(v).redISub(f);var _=u.redMul(l);t+1<e&&(c=c.redMul(f)),o=y,l=_,u=v}return this.curve.jpoint(o,u.redMul(s),l)};ce.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()};ce.prototype._zeroDbl=function(){var e,t,i;if(this.zOne){var n=this.x.redSqr(),s=this.y.redSqr(),o=s.redSqr(),a=this.x.redAdd(s).redSqr().redISub(n).redISub(o);a=a.redIAdd(a);var l=n.redAdd(n).redIAdd(n),c=l.redSqr().redISub(a).redISub(a),u=o.redIAdd(o);u=u.redIAdd(u),u=u.redIAdd(u),e=c,t=l.redMul(a.redISub(c)).redISub(u),i=this.y.redAdd(this.y)}else{var h=this.x.redSqr(),d=this.y.redSqr(),f=d.redSqr(),p=this.x.redAdd(d).redSqr().redISub(h).redISub(f);p=p.redIAdd(p);var g=h.redAdd(h).redIAdd(h),y=g.redSqr(),m=f.redIAdd(f);m=m.redIAdd(m),m=m.redIAdd(m),e=y.redISub(p).redISub(p),t=g.redMul(p.redISub(e)).redISub(m),i=this.y.redMul(this.z),i=i.redIAdd(i)}return this.curve.jpoint(e,t,i)};ce.prototype._threeDbl=function(){var e,t,i;if(this.zOne){var n=this.x.redSqr(),s=this.y.redSqr(),o=s.redSqr(),a=this.x.redAdd(s).redSqr().redISub(n).redISub(o);a=a.redIAdd(a);var l=n.redAdd(n).redIAdd(n).redIAdd(this.curve.a),c=l.redSqr().redISub(a).redISub(a);e=c;var u=o.redIAdd(o);u=u.redIAdd(u),u=u.redIAdd(u),t=l.redMul(a.redISub(c)).redISub(u),i=this.y.redAdd(this.y)}else{var h=this.z.redSqr(),d=this.y.redSqr(),f=this.x.redMul(d),p=this.x.redSub(h).redMul(this.x.redAdd(h));p=p.redAdd(p).redIAdd(p);var g=f.redIAdd(f);g=g.redIAdd(g);var y=g.redAdd(g);e=p.redSqr().redISub(y),i=this.y.redAdd(this.z).redSqr().redISub(d).redISub(h);var m=d.redSqr();m=m.redIAdd(m),m=m.redIAdd(m),m=m.redIAdd(m),t=p.redMul(g.redISub(e)).redISub(m)}return this.curve.jpoint(e,t,i)};ce.prototype._dbl=function(){var e=this.curve.a,t=this.x,i=this.y,n=this.z,s=n.redSqr().redSqr(),o=t.redSqr(),a=i.redSqr(),l=o.redAdd(o).redIAdd(o).redIAdd(e.redMul(s)),c=t.redAdd(t);c=c.redIAdd(c);var u=c.redMul(a),h=l.redSqr().redISub(u.redAdd(u)),d=u.redISub(h),f=a.redSqr();f=f.redIAdd(f),f=f.redIAdd(f),f=f.redIAdd(f);var p=l.redMul(d).redISub(f),g=i.redAdd(i).redMul(n);return this.curve.jpoint(h,p,g)};ce.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var e=this.x.redSqr(),t=this.y.redSqr(),i=this.z.redSqr(),n=t.redSqr(),s=e.redAdd(e).redIAdd(e),o=s.redSqr(),a=this.x.redAdd(t).redSqr().redISub(e).redISub(n);a=a.redIAdd(a),a=a.redAdd(a).redIAdd(a),a=a.redISub(o);var l=a.redSqr(),c=n.redIAdd(n);c=c.redIAdd(c),c=c.redIAdd(c),c=c.redIAdd(c);var u=s.redIAdd(a).redSqr().redISub(o).redISub(l).redISub(c),h=t.redMul(u);h=h.redIAdd(h),h=h.redIAdd(h);var d=this.x.redMul(l).redISub(h);d=d.redIAdd(d),d=d.redIAdd(d);var f=this.y.redMul(u.redMul(c.redISub(u)).redISub(a.redMul(l)));f=f.redIAdd(f),f=f.redIAdd(f),f=f.redIAdd(f);var p=this.z.redAdd(a).redSqr().redISub(i).redISub(l);return this.curve.jpoint(d,f,p)};ce.prototype.mul=function(e,t){return e=new L(e,t),this.curve._wnafMul(this,e)};ce.prototype.eq=function(e){if(e.type==="affine")return this.eq(e.toJ());if(this===e)return!0;var t=this.z.redSqr(),i=e.z.redSqr();if(this.x.redMul(i).redISub(e.x.redMul(t)).cmpn(0)!==0)return!1;var n=t.redMul(this.z),s=i.redMul(e.z);return this.y.redMul(s).redISub(e.y.redMul(n)).cmpn(0)===0};ce.prototype.eqXToP=function(e){var t=this.z.redSqr(),i=e.toRed(this.curve.red).redMul(t);if(this.x.cmp(i)===0)return!0;for(var n=e.clone(),s=this.curve.redN.redMul(t);;){if(n.iadd(this.curve.n),n.cmp(this.curve.p)>=0)return!1;if(i.redIAdd(s),this.x.cmp(i)===0)return!0}};ce.prototype.inspect=function(){return this.isInfinity()?"<EC JPoint Infinity>":"<EC JPoint x: "+this.x.toString(16,2)+" y: "+this.y.toString(16,2)+" z: "+this.z.toString(16,2)+">"};ce.prototype.isInfinity=function(){return this.z.cmpn(0)===0};var Wr=ir(function(r,e){var t=e;t.base=Mt,t.short=Np,t.mont=null,t.edwards=null}),Hr=ir(function(r,e){var t=e,i=xe.assert;function n(a){a.type==="short"?this.curve=new Wr.short(a):a.type==="edwards"?this.curve=new Wr.edwards(a):this.curve=new Wr.mont(a),this.g=this.curve.g,this.n=this.curve.n,this.hash=a.hash,i(this.g.validate(),"Invalid curve"),i(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}t.PresetCurve=n;function s(a,l){Object.defineProperty(t,a,{configurable:!0,enumerable:!0,get:function(){var c=new n(l);return Object.defineProperty(t,a,{configurable:!0,enumerable:!0,value:c}),c}})}s("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:Xe.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),s("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:Xe.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),s("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:Xe.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),s("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:Xe.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),s("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:Xe.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),s("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:Xe.sha256,gRed:!1,g:["9"]}),s("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:Xe.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var o;try{o=null.crash()}catch{o=void 0}s("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:Xe.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",o]})});function gt(r){if(!(this instanceof gt))return new gt(r);this.hash=r.hash,this.predResist=!!r.predResist,this.outLen=this.hash.outSize,this.minEntropy=r.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=ze.toArray(r.entropy,r.entropyEnc||"hex"),t=ze.toArray(r.nonce,r.nonceEnc||"hex"),i=ze.toArray(r.pers,r.persEnc||"hex");Zn(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,t,i)}var el=gt;gt.prototype._init=function(e,t,i){var n=e.concat(t).concat(i);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var s=0;s<this.V.length;s++)this.K[s]=0,this.V[s]=1;this._update(n),this._reseed=1,this.reseedInterval=281474976710656};gt.prototype._hmac=function(){return new Xe.hmac(this.hash,this.K)};gt.prototype._update=function(e){var t=this._hmac().update(this.V).update([0]);e&&(t=t.update(e)),this.K=t.digest(),this.V=this._hmac().update(this.V).digest(),e&&(this.K=this._hmac().update(this.V).update([1]).update(e).digest(),this.V=this._hmac().update(this.V).digest())};gt.prototype.reseed=function(e,t,i,n){typeof t!="string"&&(n=i,i=t,t=null),e=ze.toArray(e,t),i=ze.toArray(i,n),Zn(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(i||[])),this._reseed=1};gt.prototype.generate=function(e,t,i,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof t!="string"&&(n=i,i=t,t=null),i&&(i=ze.toArray(i,n||"hex"),this._update(i));for(var s=[];s.length<e;)this.V=this._hmac().update(this.V).digest(),s=s.concat(this.V);var o=s.slice(0,e);return this._update(i),this._reseed++,ze.encode(o,t)};var pn=xe.assert;function ue(r,e){this.ec=r,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}var ts=ue;ue.fromPublic=function(e,t,i){return t instanceof ue?t:new ue(e,{pub:t,pubEnc:i})};ue.fromPrivate=function(e,t,i){return t instanceof ue?t:new ue(e,{priv:t,privEnc:i})};ue.prototype.validate=function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}};ue.prototype.getPublic=function(e,t){return typeof e=="string"&&(t=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),t?this.pub.encode(t,e):this.pub};ue.prototype.getPrivate=function(e){return e==="hex"?this.priv.toString(16,2):this.priv};ue.prototype._importPrivate=function(e,t){this.priv=new L(e,t||16),this.priv=this.priv.umod(this.ec.curve.n)};ue.prototype._importPublic=function(e,t){if(e.x||e.y){this.ec.curve.type==="mont"?pn(e.x,"Need x coordinate"):(this.ec.curve.type==="short"||this.ec.curve.type==="edwards")&&pn(e.x&&e.y,"Need both x and y coordinate"),this.pub=this.ec.curve.point(e.x,e.y);return}this.pub=this.ec.curve.decodePoint(e,t)};ue.prototype.derive=function(e){return e.validate()||pn(e.validate(),"public point not validated"),e.mul(this.priv).getX()};ue.prototype.sign=function(e,t,i){return this.ec.sign(e,this,t,i)};ue.prototype.verify=function(e,t){return this.ec.verify(e,t,this)};ue.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"};var $p=xe.assert;function bi(r,e){if(r instanceof bi)return r;this._importDER(r,e)||($p(r.r&&r.s,"Signature without r or s"),this.r=new L(r.r,16),this.s=new L(r.s,16),r.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=r.recoveryParam)}var Ei=bi;function Op(){this.place=0}function Ui(r,e){var t=r[e.place++];if(!(t&128))return t;var i=t&15;if(i===0||i>4)return!1;for(var n=0,s=0,o=e.place;s<i;s++,o++)n<<=8,n|=r[o],n>>>=0;return n<=127?!1:(e.place=o,n)}function Zs(r){for(var e=0,t=r.length-1;!r[e]&&!(r[e+1]&128)&&e<t;)e++;return e===0?r:r.slice(e)}bi.prototype._importDER=function(e,t){e=xe.toArray(e,t);var i=new Op;if(e[i.place++]!==48)return!1;var n=Ui(e,i);if(n===!1||n+i.place!==e.length||e[i.place++]!==2)return!1;var s=Ui(e,i);if(s===!1)return!1;var o=e.slice(i.place,s+i.place);if(i.place+=s,e[i.place++]!==2)return!1;var a=Ui(e,i);if(a===!1||e.length!==a+i.place)return!1;var l=e.slice(i.place,a+i.place);if(o[0]===0)if(o[1]&128)o=o.slice(1);else return!1;if(l[0]===0)if(l[1]&128)l=l.slice(1);else return!1;return this.r=new L(o),this.s=new L(l),this.recoveryParam=null,!0};function Bi(r,e){if(e<128){r.push(e);return}var t=1+(Math.log(e)/Math.LN2>>>3);for(r.push(t|128);--t;)r.push(e>>>(t<<3)&255);r.push(e)}bi.prototype.toDER=function(e){var t=this.r.toArray(),i=this.s.toArray();for(t[0]&128&&(t=[0].concat(t)),i[0]&128&&(i=[0].concat(i)),t=Zs(t),i=Zs(i);!i[0]&&!(i[1]&128);)i=i.slice(1);var n=[2];Bi(n,t.length),n=n.concat(t),n.push(2),Bi(n,i.length);var s=n.concat(i),o=[48];return Bi(o,s.length),o=o.concat(s),xe.encode(o,e)};var Cp=function(){throw new Error("unsupported")},tl=xe.assert;function Ce(r){if(!(this instanceof Ce))return new Ce(r);typeof r=="string"&&(tl(Object.prototype.hasOwnProperty.call(Hr,r),"Unknown curve "+r),r=Hr[r]),r instanceof Hr.PresetCurve&&(r={curve:r}),this.curve=r.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=r.curve.g,this.g.precompute(r.curve.n.bitLength()+1),this.hash=r.hash||r.curve.hash}var kp=Ce;Ce.prototype.keyPair=function(e){return new ts(this,e)};Ce.prototype.keyFromPrivate=function(e,t){return ts.fromPrivate(this,e,t)};Ce.prototype.keyFromPublic=function(e,t){return ts.fromPublic(this,e,t)};Ce.prototype.genKeyPair=function(e){e||(e={});for(var t=new el({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||Cp(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),i=this.n.byteLength(),n=this.n.sub(new L(2));;){var s=new L(t.generate(i));if(!(s.cmp(n)>0))return s.iaddn(1),this.keyFromPrivate(s)}};Ce.prototype._truncateToN=function(e,t){var i=e.byteLength()*8-this.n.bitLength();return i>0&&(e=e.ushrn(i)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e};Ce.prototype.sign=function(e,t,i,n){typeof i=="object"&&(n=i,i=null),n||(n={}),t=this.keyFromPrivate(t,i),e=this._truncateToN(new L(e,16));for(var s=this.n.byteLength(),o=t.getPrivate().toArray("be",s),a=e.toArray("be",s),l=new el({hash:this.hash,entropy:o,nonce:a,pers:n.pers,persEnc:n.persEnc||"utf8"}),c=this.n.sub(new L(1)),u=0;;u++){var h=n.k?n.k(u):new L(l.generate(this.n.byteLength()));if(h=this._truncateToN(h,!0),!(h.cmpn(1)<=0||h.cmp(c)>=0)){var d=this.g.mul(h);if(!d.isInfinity()){var f=d.getX(),p=f.umod(this.n);if(p.cmpn(0)!==0){var g=h.invm(this.n).mul(p.mul(t.getPrivate()).iadd(e));if(g=g.umod(this.n),g.cmpn(0)!==0){var y=(d.getY().isOdd()?1:0)|(f.cmp(p)!==0?2:0);return n.canonical&&g.cmp(this.nh)>0&&(g=this.n.sub(g),y^=1),new Ei({r:p,s:g,recoveryParam:y})}}}}}};Ce.prototype.verify=function(e,t,i,n){e=this._truncateToN(new L(e,16)),i=this.keyFromPublic(i,n),t=new Ei(t,"hex");var s=t.r,o=t.s;if(s.cmpn(1)<0||s.cmp(this.n)>=0||o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;var a=o.invm(this.n),l=a.mul(e).umod(this.n),c=a.mul(s).umod(this.n),u;return this.curve._maxwellTrick?(u=this.g.jmulAdd(l,i.getPublic(),c),u.isInfinity()?!1:u.eqXToP(s)):(u=this.g.mulAdd(l,i.getPublic(),c),u.isInfinity()?!1:u.getX().umod(this.n).cmp(s)===0)};Ce.prototype.recoverPubKey=function(r,e,t,i){tl((3&t)===t,"The recovery param is more than two bits"),e=new Ei(e,i);var n=this.n,s=new L(r),o=e.r,a=e.s,l=t&1,c=t>>1;if(o.cmp(this.curve.p.umod(this.curve.n))>=0&&c)throw new Error("Unable to find sencond key candinate");c?o=this.curve.pointFromX(o.add(this.curve.n),l):o=this.curve.pointFromX(o,l);var u=e.r.invm(n),h=n.sub(s).mul(u).umod(n),d=a.mul(u).umod(n);return this.g.mulAdd(h,o,d)};Ce.prototype.getKeyRecoveryParam=function(r,e,t,i){if(e=new Ei(e,i),e.recoveryParam!==null)return e.recoveryParam;for(var n=0;n<4;n++){var s;try{s=this.recoverPubKey(r,e,n)}catch{continue}if(s.eq(t))return n}throw new Error("Unable to find valid recovery factor")};var Mp=ir(function(r,e){var t=e;t.version="6.5.4",t.utils=xe,t.rand=function(){throw new Error("unsupported")},t.curve=Wr,t.curves=Hr,t.ec=kp,t.eddsa=null}),Lp=Mp.ec;const Dp="signing-key/5.7.0",gn=new xu(Dp);let zi=null;function ct(){return zi||(zi=new Lp("secp256k1")),zi}class Fp{constructor(e){or(this,"curve","secp256k1"),or(this,"privateKey",Ia(e)),Pu(this.privateKey)!==32&&gn.throwArgumentError("invalid private key","privateKey","[[ REDACTED ]]");const t=ct().keyFromPrivate($e(this.privateKey));or(this,"publicKey","0x"+t.getPublic(!1,"hex")),or(this,"compressedPublicKey","0x"+t.getPublic(!0,"hex")),or(this,"_isSigningKey",!0)}_addPoint(e){const t=ct().keyFromPublic($e(this.publicKey)),i=ct().keyFromPublic($e(e));return"0x"+t.pub.add(i.pub).encodeCompressed("hex")}signDigest(e){const t=ct().keyFromPrivate($e(this.privateKey)),i=$e(e);i.length!==32&&gn.throwArgumentError("bad digest length","digest",e);const n=t.sign(i,{canonical:!0});return Ea({recoveryParam:n.recoveryParam,r:$i("0x"+n.r.toString(16),32),s:$i("0x"+n.s.toString(16),32)})}computeSharedSecret(e){const t=ct().keyFromPrivate($e(this.privateKey)),i=ct().keyFromPublic($e(rl(e)));return $i("0x"+t.derive(i.getPublic()).toString(16),32)}static isSigningKey(e){return!!(e&&e._isSigningKey)}}function qp(r,e){const t=Ea(e),i={r:$e(t.r),s:$e(t.s)};return"0x"+ct().recoverPubKey($e(r),i,t.recoveryParam).encode("hex",!1)}function rl(r,e){const t=$e(r);return t.length===32?new Fp(t).publicKey:t.length===33?"0x"+ct().keyFromPublic(t).getPublic(!1,"hex"):t.length===65?Ia(t):gn.throwArgumentError("invalid public or private key","key","[REDACTED]")}var eo;(function(r){r[r.legacy=0]="legacy",r[r.eip2930=1]="eip2930",r[r.eip1559=2]="eip1559"})(eo||(eo={}));function Up(r){const e=rl(r);return Au(ms(Tu(ms(e,1)),12))}function Bp(r,e){return Up(qp($e(r),e))}var zp={};const il=":";function Jr(r){const[e,t]=r.split(il);return{namespace:e,reference:t}}function Kp(r){const[e,t,i]=r.split(il);return{namespace:e,reference:t,address:i}}function nl(r,e){return r.includes(":")?[r]:e.chains||[]}const jp="ReactNative",Ee={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},Vp="js";function oi(){return typeof R.process<"u"&&typeof R.process.versions<"u"&&typeof R.process.versions.node<"u"}function wt(){return!_i()&&!!Qn()&&navigator.product===jp}function Wp(){return wt()&&typeof R.global<"u"&&typeof(R.global==null?void 0:R.global.Platform)<"u"&&(R.global==null?void 0:R.global.Platform.OS)==="android"}function Hp(){return wt()&&typeof R.global<"u"&&typeof(R.global==null?void 0:R.global.Platform)<"u"&&(R.global==null?void 0:R.global.Platform.OS)==="ios"}function Rr(){return!oi()&&!!Qn()&&!!_i()}function Nr(){return wt()?Ee.reactNative:oi()?Ee.node:Rr()?Ee.browser:Ee.unknown}function to(){var r;try{return wt()&&typeof R.global<"u"&&typeof(R.global==null?void 0:R.global.Application)<"u"?(r=R.global.Application)==null?void 0:r.applicationId:void 0}catch{return}}function Jp(r,e){const t=new URLSearchParams(r);for(const i of Object.keys(e).sort())if(e.hasOwnProperty(i)){const n=e[i];n!==void 0&&t.set(i,n)}return t.toString()}function sl(){return Xc()||{name:"",description:"",url:"",icons:[""]}}function Gp(){if(Nr()===Ee.reactNative&&typeof R.global<"u"&&typeof(R.global==null?void 0:R.global.Platform)<"u"){const{OS:t,Version:i}=R.global.Platform;return[t,i].join("-")}const r=mu();if(r===null)return"unknown";const e=r.os?r.os.replace(" ","").toLowerCase():"unknown";return r.type==="browser"?[e,r.name,r.version].join("-"):[e,r.version].join("-")}function Yp(){var r;const e=Nr();return e===Ee.browser?[e,((r=Qc())==null?void 0:r.host)||"unknown"].join(":"):e}function ol(r,e,t){const i=Gp(),n=Yp();return[[r,e].join("-"),[Vp,t].join("-"),i,n].join("/")}function Qp({protocol:r,version:e,relayUrl:t,sdkVersion:i,auth:n,projectId:s,useOnCloseEvent:o,bundleId:a,packageName:l}){const c=t.split("?"),u=ol(r,e,i),h={auth:n,ua:u,projectId:s,useOnCloseEvent:o,packageName:l||void 0,bundleId:a||void 0},d=Jp(c[1]||"",h);return c[0]+"?"+d}function Tt(r,e){return r.filter(t=>e.includes(t)).length===r.length}function al(r){return Object.fromEntries(r.entries())}function cl(r){return new Map(Object.entries(r))}function It(r=S.FIVE_MINUTES,e){const t=S.toMiliseconds(r||S.FIVE_MINUTES);let i,n,s,o;return{resolve:a=>{s&&i&&(clearTimeout(s),i(a),o=Promise.resolve(a))},reject:a=>{s&&n&&(clearTimeout(s),n(a))},done:()=>new Promise((a,l)=>{if(o)return a(o);s=setTimeout(()=>{const c=new Error(e);o=Promise.reject(c),l(c)},t),i=a,n=l})}}function ht(r,e,t){return new Promise(async(i,n)=>{const s=setTimeout(()=>n(new Error(t)),e);try{const o=await r;i(o)}catch(o){n(o)}clearTimeout(s)})}function ll(r,e){if(typeof e=="string"&&e.startsWith(`${r}:`))return e;if(r.toLowerCase()==="topic"){if(typeof e!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${e}`}else if(r.toLowerCase()==="id"){if(typeof e!="number")throw new Error('Value must be "number" for expirer target type: id');return`id:${e}`}throw new Error(`Unknown expirer target type: ${r}`)}function Xp(r){return ll("topic",r)}function Zp(r){return ll("id",r)}function ul(r){const[e,t]=r.split(":"),i={id:void 0,topic:void 0};if(e==="topic"&&typeof t=="string")i.topic=t;else if(e==="id"&&Number.isInteger(Number(t)))i.id=Number(t);else throw new Error(`Invalid target, expected id:number or topic:string, got ${e}:${t}`);return i}function re(r,e){return S.fromMiliseconds(Date.now()+S.toMiliseconds(r))}function lt(r){return Date.now()>=S.toMiliseconds(r)}function U(r,e){return`${r}${e?`:${e}`:""}`}function eg(r=[],e=[]){return[...new Set([...r,...e])]}async function tg({id:r,topic:e,wcDeepLink:t}){var i;try{if(!t)return;const n=typeof t=="string"?JSON.parse(t):t,s=n==null?void 0:n.href;if(typeof s!="string")return;const o=rg(s,r,e),a=Nr();if(a===Ee.browser){if(!((i=_i())!=null&&i.hasFocus())){console.warn("Document does not have focus, skipping deeplink.");return}ig(o)}else a===Ee.reactNative&&typeof(R.global==null?void 0:R.global.Linking)<"u"&&await R.global.Linking.openURL(o)}catch(n){console.error(n)}}function rg(r,e,t){const i=`requestId=${e}&sessionTopic=${t}`;r.endsWith("/")&&(r=r.slice(0,-1));let n=`${r}`;if(r.startsWith("https://t.me")){const s=r.includes("?")?"&startapp=":"?startapp=";n=`${n}${s}${ag(i,!0)}`}else n=`${n}/wc?${i}`;return n}function ig(r){let e="_self";og()?e="_top":(sg()||r.startsWith("https://")||r.startsWith("http://"))&&(e="_blank"),window.open(r,e,"noreferrer noopener")}async function ng(r,e){let t="";try{if(Rr()&&(t=localStorage.getItem(e),t))return t;t=await r.getItem(e)}catch(i){console.error(i)}return t}function ro(r,e){if(!r.includes(e))return null;const t=r.split(/([&,?,=])/),i=t.indexOf(e);return t[i+2]}function io(){return typeof crypto<"u"&&crypto!=null&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,r=>{const e=Math.random()*16|0;return(r==="x"?e:e&3|8).toString(16)})}function rs(){return typeof R.process<"u"&&zp.IS_VITEST==="true"}function sg(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)}function og(){try{return window.self!==window.top}catch{return!1}}function ag(r,e=!1){const t=R.Buffer.from(r).toString("base64");return e?t.replace(/[=]/g,""):t}function hl(r){return R.Buffer.from(r,"base64").toString("utf-8")}function cg(r){return new Promise(e=>setTimeout(e,r))}function Ir(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function lg(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function Ii(r,...e){if(!lg(r))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(r.length))throw new Error("Uint8Array expected of length "+e+", got length="+r.length)}function is(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Ir(r.outputLen),Ir(r.blockLen)}function Gt(r,e=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(e&&r.finished)throw new Error("Hash#digest() has already been called")}function dl(r,e){Ii(r);const t=e.outputLen;if(r.length<t)throw new Error("digestInto() expects output buffer of length at least "+t)}const qr=BigInt(2**32-1),no=BigInt(32);function ug(r,e=!1){return e?{h:Number(r&qr),l:Number(r>>no&qr)}:{h:Number(r>>no&qr)|0,l:Number(r&qr)|0}}function hg(r,e=!1){let t=new Uint32Array(r.length),i=new Uint32Array(r.length);for(let n=0;n<r.length;n++){const{h:s,l:o}=ug(r[n],e);[t[n],i[n]]=[s,o]}return[t,i]}const dg=(r,e,t)=>r<<t|e>>>32-t,fg=(r,e,t)=>e<<t|r>>>32-t,pg=(r,e,t)=>e<<t-32|r>>>64-t,gg=(r,e,t)=>r<<t-32|e>>>64-t,Ft=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function yg(r){return new Uint32Array(r.buffer,r.byteOffset,Math.floor(r.byteLength/4))}function Ki(r){return new DataView(r.buffer,r.byteOffset,r.byteLength)}function Ve(r,e){return r<<32-e|r>>>e}const so=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function mg(r){return r<<24&4278190080|r<<8&16711680|r>>>8&65280|r>>>24&255}function oo(r){for(let e=0;e<r.length;e++)r[e]=mg(r[e])}function vg(r){if(typeof r!="string")throw new Error("utf8ToBytes expected string, got "+typeof r);return new Uint8Array(new TextEncoder().encode(r))}function Yt(r){return typeof r=="string"&&(r=vg(r)),Ii(r),r}let ns=class{clone(){return this._cloneInto()}};function fl(r){const e=i=>r().update(Yt(i)).digest(),t=r();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>r(),e}function $r(r=32){if(Ft&&typeof Ft.getRandomValues=="function")return Ft.getRandomValues(new Uint8Array(r));if(Ft&&typeof Ft.randomBytes=="function")return Ft.randomBytes(r);throw new Error("crypto.getRandomValues must be defined")}const pl=[],gl=[],yl=[],wg=BigInt(0),ar=BigInt(1),_g=BigInt(2),bg=BigInt(7),Eg=BigInt(256),Ig=BigInt(113);for(let r=0,e=ar,t=1,i=0;r<24;r++){[t,i]=[i,(2*t+3*i)%5],pl.push(2*(5*i+t)),gl.push((r+1)*(r+2)/2%64);let n=wg;for(let s=0;s<7;s++)e=(e<<ar^(e>>bg)*Ig)%Eg,e&_g&&(n^=ar<<(ar<<BigInt(s))-ar);yl.push(n)}const[Sg,xg]=hg(yl,!0),ao=(r,e,t)=>t>32?pg(r,e,t):dg(r,e,t),co=(r,e,t)=>t>32?gg(r,e,t):fg(r,e,t);function Pg(r,e=24){const t=new Uint32Array(10);for(let i=24-e;i<24;i++){for(let o=0;o<10;o++)t[o]=r[o]^r[o+10]^r[o+20]^r[o+30]^r[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,l=(o+2)%10,c=t[l],u=t[l+1],h=ao(c,u,1)^t[a],d=co(c,u,1)^t[a+1];for(let f=0;f<50;f+=10)r[o+f]^=h,r[o+f+1]^=d}let n=r[2],s=r[3];for(let o=0;o<24;o++){const a=gl[o],l=ao(n,s,a),c=co(n,s,a),u=pl[o];n=r[u],s=r[u+1],r[u]=l,r[u+1]=c}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)t[a]=r[o+a];for(let a=0;a<10;a++)r[o+a]^=~t[(a+2)%10]&t[(a+4)%10]}r[0]^=Sg[i],r[1]^=xg[i]}t.fill(0)}let Ag=class ml extends ns{constructor(e,t,i,n=!1,s=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=i,this.enableXOF=n,this.rounds=s,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,Ir(i),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=yg(this.state)}keccak(){so||oo(this.state32),Pg(this.state32,this.rounds),so||oo(this.state32),this.posOut=0,this.pos=0}update(e){Gt(this);const{blockLen:t,state:i}=this;e=Yt(e);const n=e.length;for(let s=0;s<n;){const o=Math.min(t-this.pos,n-s);for(let a=0;a<o;a++)i[this.pos++]^=e[s++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:i,blockLen:n}=this;e[i]^=t,t&128&&i===n-1&&this.keccak(),e[n-1]^=128,this.keccak()}writeInto(e){Gt(this,!1),Ii(e),this.finish();const t=this.state,{blockLen:i}=this;for(let n=0,s=e.length;n<s;){this.posOut>=i&&this.keccak();const o=Math.min(i-this.posOut,s-n);e.set(t.subarray(this.posOut,this.posOut+o),n),this.posOut+=o,n+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return Ir(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(dl(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:i,outputLen:n,rounds:s,enableXOF:o}=this;return e||(e=new ml(t,i,n,o,s)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=s,e.suffix=i,e.outputLen=n,e.enableXOF=o,e.destroyed=this.destroyed,e}};const Tg=(r,e,t)=>fl(()=>new Ag(e,r,t)),Rg=Tg(1,136,256/8),Ng="https://rpc.walletconnect.org/v1";function vl(r){const e=`Ethereum Signed Message:
523
- ${r.length}`,t=new TextEncoder().encode(e+r);return"0x"+R.Buffer.from(Rg(t)).toString("hex")}async function $g(r,e,t,i,n,s){switch(t.t){case"eip191":return Og(r,e,t.s);case"eip1271":return await Cg(r,e,t.s,i,n,s);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${t.t}`)}}function Og(r,e,t){return Bp(vl(e),t).toLowerCase()===r.toLowerCase()}async function Cg(r,e,t,i,n,s){const o=Jr(i);if(!o.namespace||!o.reference)throw new Error(`isValidEip1271Signature failed: chainId must be in CAIP-2 format, received: ${i}`);try{const a="0x1626ba7e",l="0000000000000000000000000000000000000000000000000000000000000040",c="0000000000000000000000000000000000000000000000000000000000000041",u=t.substring(2),h=vl(e).substring(2),d=a+h+l+c+u,f=await fetch(`${s||Ng}/?chainId=${i}&projectId=${n}`,{method:"POST",body:JSON.stringify({id:kg(),jsonrpc:"2.0",method:"eth_call",params:[{to:r,data:d},"latest"]})}),{result:p}=await f.json();return p?p.slice(0,a.length).toLowerCase()===a.toLowerCase():!1}catch(a){return console.error("isValidEip1271Signature: ",a),!1}}function kg(){return Date.now()+Math.floor(Math.random()*1e3)}var Mg=Object.defineProperty,Lg=Object.defineProperties,Dg=Object.getOwnPropertyDescriptors,lo=Object.getOwnPropertySymbols,Fg=Object.prototype.hasOwnProperty,qg=Object.prototype.propertyIsEnumerable,uo=(r,e,t)=>e in r?Mg(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Ug=(r,e)=>{for(var t in e||(e={}))Fg.call(e,t)&&uo(r,t,e[t]);if(lo)for(var t of lo(e))qg.call(e,t)&&uo(r,t,e[t]);return r},Bg=(r,e)=>Lg(r,Dg(e));const zg="did:pkh:",ss=r=>r==null?void 0:r.split(":"),Kg=r=>{const e=r&&ss(r);if(e)return r.includes(zg)?e[3]:e[1]},yn=r=>{const e=r&&ss(r);if(e)return e[2]+":"+e[3]},ai=r=>{const e=r&&ss(r);if(e)return e.pop()};async function ho(r){const{cacao:e,projectId:t}=r,{s:i,p:n}=e,s=wl(n,n.iss),o=ai(n.iss);return await $g(o,s,i,yn(n.iss),t)}const wl=(r,e)=>{const t=`${r.domain} wants you to sign in with your Ethereum account:`,i=ai(e);if(!r.aud&&!r.uri)throw new Error("Either `aud` or `uri` is required to construct the message");let n=r.statement||void 0;const s=`URI: ${r.aud||r.uri}`,o=`Version: ${r.version}`,a=`Chain ID: ${Kg(e)}`,l=`Nonce: ${r.nonce}`,c=`Issued At: ${r.iat}`,u=r.exp?`Expiration Time: ${r.exp}`:void 0,h=r.nbf?`Not Before: ${r.nbf}`:void 0,d=r.requestId?`Request ID: ${r.requestId}`:void 0,f=r.resources?`Resources:${r.resources.map(g=>`
524
- - ${g}`).join("")}`:void 0,p=Gr(r.resources);if(p){const g=Sr(p);n=Xg(n,g)}return[t,i,"",n,"",s,o,a,l,c,u,h,d,f].filter(g=>g!=null).join(`
525
- `)};function jg(r){return R.Buffer.from(JSON.stringify(r)).toString("base64")}function Vg(r){return JSON.parse(R.Buffer.from(r,"base64").toString("utf-8"))}function Rt(r){if(!r)throw new Error("No recap provided, value is undefined");if(!r.att)throw new Error("No `att` property found");const e=Object.keys(r.att);if(!(e!=null&&e.length))throw new Error("No resources found in `att` property");e.forEach(t=>{const i=r.att[t];if(Array.isArray(i))throw new Error(`Resource must be an object: ${t}`);if(typeof i!="object")throw new Error(`Resource must be an object: ${t}`);if(!Object.keys(i).length)throw new Error(`Resource object is empty: ${t}`);Object.keys(i).forEach(n=>{const s=i[n];if(!Array.isArray(s))throw new Error(`Ability limits ${n} must be an array of objects, found: ${s}`);if(!s.length)throw new Error(`Value of ${n} is empty array, must be an array with objects`);s.forEach(o=>{if(typeof o!="object")throw new Error(`Ability limits (${n}) must be an array of objects, found: ${o}`)})})})}function Wg(r,e,t,i={}){return t==null||t.sort((n,s)=>n.localeCompare(s)),{att:{[r]:Hg(e,t,i)}}}function Hg(r,e,t={}){e=e==null?void 0:e.sort((n,s)=>n.localeCompare(s));const i=e.map(n=>({[`${r}/${n}`]:[t]}));return Object.assign({},...i)}function _l(r){return Rt(r),`urn:recap:${jg(r).replace(/=/g,"")}`}function Sr(r){const e=Vg(r.replace("urn:recap:",""));return Rt(e),e}function Jg(r,e,t){const i=Wg(r,e,t);return _l(i)}function Gg(r){return r&&r.includes("urn:recap:")}function Yg(r,e){const t=Sr(r),i=Sr(e),n=Qg(t,i);return _l(n)}function Qg(r,e){Rt(r),Rt(e);const t=Object.keys(r.att).concat(Object.keys(e.att)).sort((n,s)=>n.localeCompare(s)),i={att:{}};return t.forEach(n=>{var s,o;Object.keys(((s=r.att)==null?void 0:s[n])||{}).concat(Object.keys(((o=e.att)==null?void 0:o[n])||{})).sort((a,l)=>a.localeCompare(l)).forEach(a=>{var l,c;i.att[n]=Bg(Ug({},i.att[n]),{[a]:((l=r.att[n])==null?void 0:l[a])||((c=e.att[n])==null?void 0:c[a])})})}),i}function Xg(r="",e){Rt(e);const t="I further authorize the stated URI to perform the following actions on my behalf: ";if(r.includes(t))return r;const i=[];let n=0;Object.keys(e.att).forEach(a=>{const l=Object.keys(e.att[a]).map(h=>({ability:h.split("/")[0],action:h.split("/")[1]}));l.sort((h,d)=>h.action.localeCompare(d.action));const c={};l.forEach(h=>{c[h.ability]||(c[h.ability]=[]),c[h.ability].push(h.action)});const u=Object.keys(c).map(h=>(n++,`(${n}) '${h}': '${c[h].join("', '")}' for '${a}'.`));i.push(u.join(", ").replace(".,","."))});const s=i.join(" "),o=`${t}${s}`;return`${r?r+" ":""}${o}`}function fo(r){var e;const t=Sr(r);Rt(t);const i=(e=t.att)==null?void 0:e.eip155;return i?Object.keys(i).map(n=>n.split("/")[1]):[]}function po(r){const e=Sr(r);Rt(e);const t=[];return Object.values(e.att).forEach(i=>{Object.values(i).forEach(n=>{var s;(s=n==null?void 0:n[0])!=null&&s.chains&&t.push(n[0].chains)})}),[...new Set(t.flat())]}function Gr(r){if(!r)return;const e=r==null?void 0:r[r.length-1];return Gg(e)?e:void 0}function ji(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function bl(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function be(r,...e){if(!bl(r))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(r.length))throw new Error("Uint8Array expected of length "+e+", got length="+r.length)}function go(r,e=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(e&&r.finished)throw new Error("Hash#digest() has already been called")}function Zg(r,e){be(r);const t=e.outputLen;if(r.length<t)throw new Error("digestInto() expects output buffer of length at least "+t)}function yo(r){if(typeof r!="boolean")throw new Error(`boolean expected, not ${r}`)}const pt=r=>new Uint32Array(r.buffer,r.byteOffset,Math.floor(r.byteLength/4)),ey=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),ty=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!ty)throw new Error("Non little-endian hardware is not supported");function ry(r){if(typeof r!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(r))}function mn(r){if(typeof r=="string")r=ry(r);else if(bl(r))r=vn(r);else throw new Error("Uint8Array expected, got "+typeof r);return r}function iy(r,e){if(e==null||typeof e!="object")throw new Error("options must be defined");return Object.assign(r,e)}function ny(r,e){if(r.length!==e.length)return!1;let t=0;for(let i=0;i<r.length;i++)t|=r[i]^e[i];return t===0}const sy=(r,e)=>{function t(i,...n){if(be(i),r.nonceLength!==void 0){const c=n[0];if(!c)throw new Error("nonce / iv required");r.varSizeNonce?be(c):be(c,r.nonceLength)}const s=r.tagLength;s&&n[1]!==void 0&&be(n[1]);const o=e(i,...n),a=(c,u)=>{if(u!==void 0){if(c!==2)throw new Error("cipher output not supported");be(u)}};let l=!1;return{encrypt(c,u){if(l)throw new Error("cannot encrypt() twice with same key + nonce");return l=!0,be(c),a(o.encrypt.length,u),o.encrypt(c,u)},decrypt(c,u){if(be(c),s&&c.length<s)throw new Error("invalid ciphertext length: smaller than tagLength="+s);return a(o.decrypt.length,u),o.decrypt(c,u)}}}return Object.assign(t,r),t};function mo(r,e,t=!0){if(e===void 0)return new Uint8Array(r);if(e.length!==r)throw new Error("invalid output length, expected "+r+", got: "+e.length);if(t&&!oy(e))throw new Error("invalid output, must be aligned");return e}function vo(r,e,t,i){if(typeof r.setBigUint64=="function")return r.setBigUint64(e,t,i);const n=BigInt(32),s=BigInt(4294967295),o=Number(t>>n&s),a=Number(t&s);r.setUint32(e+4,o,i),r.setUint32(e+0,a,i)}function oy(r){return r.byteOffset%4===0}function vn(r){return Uint8Array.from(r)}function Qt(...r){for(let e=0;e<r.length;e++)r[e].fill(0)}const El=r=>Uint8Array.from(r.split("").map(e=>e.charCodeAt(0))),ay=El("expand 16-byte k"),cy=El("expand 32-byte k"),ly=pt(ay),uy=pt(cy);function V(r,e){return r<<e|r>>>32-e}function wn(r){return r.byteOffset%4===0}const Ur=64,hy=16,Il=2**32-1,wo=new Uint32Array;function dy(r,e,t,i,n,s,o,a){const l=n.length,c=new Uint8Array(Ur),u=pt(c),h=wn(n)&&wn(s),d=h?pt(n):wo,f=h?pt(s):wo;for(let p=0;p<l;o++){if(r(e,t,i,u,o,a),o>=Il)throw new Error("arx: counter overflow");const g=Math.min(Ur,l-p);if(h&&g===Ur){const y=p/4;if(p%4!==0)throw new Error("arx: invalid block position");for(let m=0,v;m<hy;m++)v=y+m,f[v]=d[v]^u[m];p+=Ur;continue}for(let y=0,m;y<g;y++)m=p+y,s[m]=n[m]^c[y];p+=g}}function fy(r,e){const{allowShortKeys:t,extendNonceFn:i,counterLength:n,counterRight:s,rounds:o}=iy({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},e);if(typeof r!="function")throw new Error("core must be a function");return ji(n),ji(o),yo(s),yo(t),(a,l,c,u,h=0)=>{be(a),be(l),be(c);const d=c.length;if(u===void 0&&(u=new Uint8Array(d)),be(u),ji(h),h<0||h>=Il)throw new Error("arx: counter overflow");if(u.length<d)throw new Error(`arx: output (${u.length}) is shorter than data (${d})`);const f=[];let p=a.length,g,y;if(p===32)f.push(g=vn(a)),y=uy;else if(p===16&&t)g=new Uint8Array(32),g.set(a),g.set(a,16),y=ly,f.push(g);else throw new Error(`arx: invalid 32-byte key, got length=${p}`);wn(l)||f.push(l=vn(l));const m=pt(g);if(i){if(l.length!==24)throw new Error("arx: extended nonce must be 24 bytes");i(y,m,pt(l.subarray(0,16)),m),l=l.subarray(16)}const v=16-n;if(v!==l.length)throw new Error(`arx: nonce must be ${v} or 16 bytes`);if(v!==12){const w=new Uint8Array(12);w.set(l,s?0:12-l.length),l=w,f.push(l)}const _=pt(l);return dy(r,y,m,_,c,u,h,o),Qt(...f),u}}const ae=(r,e)=>r[e++]&255|(r[e++]&255)<<8;let py=class{constructor(e){this.blockLen=16,this.outputLen=16,this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.pos=0,this.finished=!1,e=mn(e),be(e,32);const t=ae(e,0),i=ae(e,2),n=ae(e,4),s=ae(e,6),o=ae(e,8),a=ae(e,10),l=ae(e,12),c=ae(e,14);this.r[0]=t&8191,this.r[1]=(t>>>13|i<<3)&8191,this.r[2]=(i>>>10|n<<6)&7939,this.r[3]=(n>>>7|s<<9)&8191,this.r[4]=(s>>>4|o<<12)&255,this.r[5]=o>>>1&8190,this.r[6]=(o>>>14|a<<2)&8191,this.r[7]=(a>>>11|l<<5)&8065,this.r[8]=(l>>>8|c<<8)&8191,this.r[9]=c>>>5&127;for(let u=0;u<8;u++)this.pad[u]=ae(e,16+2*u)}process(e,t,i=!1){const n=i?0:2048,{h:s,r:o}=this,a=o[0],l=o[1],c=o[2],u=o[3],h=o[4],d=o[5],f=o[6],p=o[7],g=o[8],y=o[9],m=ae(e,t+0),v=ae(e,t+2),_=ae(e,t+4),w=ae(e,t+6),b=ae(e,t+8),E=ae(e,t+10),I=ae(e,t+12),x=ae(e,t+14);let N=s[0]+(m&8191),$=s[1]+((m>>>13|v<<3)&8191),O=s[2]+((v>>>10|_<<6)&8191),D=s[3]+((_>>>7|w<<9)&8191),C=s[4]+((w>>>4|b<<12)&8191),q=s[5]+(b>>>1&8191),F=s[6]+((b>>>14|E<<2)&8191),B=s[7]+((E>>>11|I<<5)&8191),K=s[8]+((I>>>8|x<<8)&8191),M=s[9]+(x>>>5|n),A=0,j=A+N*a+$*(5*y)+O*(5*g)+D*(5*p)+C*(5*f);A=j>>>13,j&=8191,j+=q*(5*d)+F*(5*h)+B*(5*u)+K*(5*c)+M*(5*l),A+=j>>>13,j&=8191;let J=A+N*l+$*a+O*(5*y)+D*(5*g)+C*(5*p);A=J>>>13,J&=8191,J+=q*(5*f)+F*(5*d)+B*(5*h)+K*(5*u)+M*(5*c),A+=J>>>13,J&=8191;let W=A+N*c+$*l+O*a+D*(5*y)+C*(5*g);A=W>>>13,W&=8191,W+=q*(5*p)+F*(5*f)+B*(5*d)+K*(5*h)+M*(5*u),A+=W>>>13,W&=8191;let te=A+N*u+$*c+O*l+D*a+C*(5*y);A=te>>>13,te&=8191,te+=q*(5*g)+F*(5*p)+B*(5*f)+K*(5*d)+M*(5*h),A+=te>>>13,te&=8191;let we=A+N*h+$*u+O*c+D*l+C*a;A=we>>>13,we&=8191,we+=q*(5*y)+F*(5*g)+B*(5*p)+K*(5*f)+M*(5*d),A+=we>>>13,we&=8191;let Pe=A+N*d+$*h+O*u+D*c+C*l;A=Pe>>>13,Pe&=8191,Pe+=q*a+F*(5*y)+B*(5*g)+K*(5*p)+M*(5*f),A+=Pe>>>13,Pe&=8191;let Ae=A+N*f+$*d+O*h+D*u+C*c;A=Ae>>>13,Ae&=8191,Ae+=q*l+F*a+B*(5*y)+K*(5*g)+M*(5*p),A+=Ae>>>13,Ae&=8191;let Le=A+N*p+$*f+O*d+D*h+C*u;A=Le>>>13,Le&=8191,Le+=q*c+F*l+B*a+K*(5*y)+M*(5*g),A+=Le>>>13,Le&=8191;let Te=A+N*g+$*p+O*f+D*d+C*h;A=Te>>>13,Te&=8191,Te+=q*u+F*c+B*l+K*a+M*(5*y),A+=Te>>>13,Te&=8191;let je=A+N*y+$*g+O*p+D*f+C*d;A=je>>>13,je&=8191,je+=q*h+F*u+B*c+K*l+M*a,A+=je>>>13,je&=8191,A=(A<<2)+A|0,A=A+j|0,j=A&8191,A=A>>>13,J+=A,s[0]=j,s[1]=J,s[2]=W,s[3]=te,s[4]=we,s[5]=Pe,s[6]=Ae,s[7]=Le,s[8]=Te,s[9]=je}finalize(){const{h:e,pad:t}=this,i=new Uint16Array(10);let n=e[1]>>>13;e[1]&=8191;for(let a=2;a<10;a++)e[a]+=n,n=e[a]>>>13,e[a]&=8191;e[0]+=n*5,n=e[0]>>>13,e[0]&=8191,e[1]+=n,n=e[1]>>>13,e[1]&=8191,e[2]+=n,i[0]=e[0]+5,n=i[0]>>>13,i[0]&=8191;for(let a=1;a<10;a++)i[a]=e[a]+n,n=i[a]>>>13,i[a]&=8191;i[9]-=8192;let s=(n^1)-1;for(let a=0;a<10;a++)i[a]&=s;s=~s;for(let a=0;a<10;a++)e[a]=e[a]&s|i[a];e[0]=(e[0]|e[1]<<13)&65535,e[1]=(e[1]>>>3|e[2]<<10)&65535,e[2]=(e[2]>>>6|e[3]<<7)&65535,e[3]=(e[3]>>>9|e[4]<<4)&65535,e[4]=(e[4]>>>12|e[5]<<1|e[6]<<14)&65535,e[5]=(e[6]>>>2|e[7]<<11)&65535,e[6]=(e[7]>>>5|e[8]<<8)&65535,e[7]=(e[8]>>>8|e[9]<<5)&65535;let o=e[0]+t[0];e[0]=o&65535;for(let a=1;a<8;a++)o=(e[a]+t[a]|0)+(o>>>16)|0,e[a]=o&65535;Qt(i)}update(e){go(this);const{buffer:t,blockLen:i}=this;e=mn(e);const n=e.length;for(let s=0;s<n;){const o=Math.min(i-this.pos,n-s);if(o===i){for(;i<=n-s;s+=i)this.process(e,s);continue}t.set(e.subarray(s,s+o),this.pos),this.pos+=o,s+=o,this.pos===i&&(this.process(t,0,!1),this.pos=0)}return this}destroy(){Qt(this.h,this.r,this.buffer,this.pad)}digestInto(e){go(this),Zg(e,this),this.finished=!0;const{buffer:t,h:i}=this;let{pos:n}=this;if(n){for(t[n++]=1;n<16;n++)t[n]=0;this.process(t,0,!0)}this.finalize();let s=0;for(let o=0;o<8;o++)e[s++]=i[o]>>>0,e[s++]=i[o]>>>8;return e}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const i=e.slice(0,t);return this.destroy(),i}};function gy(r){const e=(i,n)=>r(n).update(mn(i)).digest(),t=r(new Uint8Array(32));return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=i=>r(i),e}const yy=gy(r=>new py(r));function my(r,e,t,i,n,s=20){let o=r[0],a=r[1],l=r[2],c=r[3],u=e[0],h=e[1],d=e[2],f=e[3],p=e[4],g=e[5],y=e[6],m=e[7],v=n,_=t[0],w=t[1],b=t[2],E=o,I=a,x=l,N=c,$=u,O=h,D=d,C=f,q=p,F=g,B=y,K=m,M=v,A=_,j=w,J=b;for(let te=0;te<s;te+=2)E=E+$|0,M=V(M^E,16),q=q+M|0,$=V($^q,12),E=E+$|0,M=V(M^E,8),q=q+M|0,$=V($^q,7),I=I+O|0,A=V(A^I,16),F=F+A|0,O=V(O^F,12),I=I+O|0,A=V(A^I,8),F=F+A|0,O=V(O^F,7),x=x+D|0,j=V(j^x,16),B=B+j|0,D=V(D^B,12),x=x+D|0,j=V(j^x,8),B=B+j|0,D=V(D^B,7),N=N+C|0,J=V(J^N,16),K=K+J|0,C=V(C^K,12),N=N+C|0,J=V(J^N,8),K=K+J|0,C=V(C^K,7),E=E+O|0,J=V(J^E,16),B=B+J|0,O=V(O^B,12),E=E+O|0,J=V(J^E,8),B=B+J|0,O=V(O^B,7),I=I+D|0,M=V(M^I,16),K=K+M|0,D=V(D^K,12),I=I+D|0,M=V(M^I,8),K=K+M|0,D=V(D^K,7),x=x+C|0,A=V(A^x,16),q=q+A|0,C=V(C^q,12),x=x+C|0,A=V(A^x,8),q=q+A|0,C=V(C^q,7),N=N+$|0,j=V(j^N,16),F=F+j|0,$=V($^F,12),N=N+$|0,j=V(j^N,8),F=F+j|0,$=V($^F,7);let W=0;i[W++]=o+E|0,i[W++]=a+I|0,i[W++]=l+x|0,i[W++]=c+N|0,i[W++]=u+$|0,i[W++]=h+O|0,i[W++]=d+D|0,i[W++]=f+C|0,i[W++]=p+q|0,i[W++]=g+F|0,i[W++]=y+B|0,i[W++]=m+K|0,i[W++]=v+M|0,i[W++]=_+A|0,i[W++]=w+j|0,i[W++]=b+J|0}const vy=fy(my,{counterRight:!1,counterLength:4,allowShortKeys:!1}),wy=new Uint8Array(16),_o=(r,e)=>{r.update(e);const t=e.length%16;t&&r.update(wy.subarray(t))},_y=new Uint8Array(32);function bo(r,e,t,i,n){const s=r(e,t,_y),o=yy.create(s);n&&_o(o,n),_o(o,i);const a=new Uint8Array(16),l=ey(a);vo(l,0,BigInt(n?n.length:0),!0),vo(l,8,BigInt(i.length),!0),o.update(a);const c=o.digest();return Qt(s,a),c}const by=r=>(e,t,i)=>({encrypt(n,s){const o=n.length;s=mo(o+16,s,!1),s.set(n);const a=s.subarray(0,-16);r(e,t,a,a,1);const l=bo(r,e,t,a,i);return s.set(l,o),Qt(l),s},decrypt(n,s){s=mo(n.length-16,s,!1);const o=n.subarray(0,-16),a=n.subarray(-16),l=bo(r,e,t,o,i);if(!ny(a,l))throw new Error("invalid tag");return s.set(n.subarray(0,-16)),r(e,t,s,s,1),Qt(l),s}}),Sl=sy({blockSize:64,nonceLength:12,tagLength:16},by(vy));class xl extends ns{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,is(e);const i=Yt(t);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const n=this.blockLen,s=new Uint8Array(n);s.set(i.length>n?e.create().update(i).digest():i);for(let o=0;o<s.length;o++)s[o]^=54;this.iHash.update(s),this.oHash=e.create();for(let o=0;o<s.length;o++)s[o]^=106;this.oHash.update(s),s.fill(0)}update(e){return Gt(this),this.iHash.update(e),this}digestInto(e){Gt(this),Ii(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:i,finished:n,destroyed:s,blockLen:o,outputLen:a}=this;return e=e,e.finished=n,e.destroyed=s,e.blockLen=o,e.outputLen=a,e.oHash=t._cloneInto(e.oHash),e.iHash=i._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const os=(r,e,t)=>new xl(r,e).update(t).digest();os.create=(r,e)=>new xl(r,e);function Ey(r,e,t){return is(r),t===void 0&&(t=new Uint8Array(r.outputLen)),os(r,Yt(t),Yt(e))}const Vi=new Uint8Array([0]),Eo=new Uint8Array;function Iy(r,e,t,i=32){if(is(r),Ir(i),i>255*r.outputLen)throw new Error("Length should be <= 255*HashLen");const n=Math.ceil(i/r.outputLen);t===void 0&&(t=Eo);const s=new Uint8Array(n*r.outputLen),o=os.create(r,e),a=o._cloneInto(),l=new Uint8Array(o.outputLen);for(let c=0;c<n;c++)Vi[0]=c+1,a.update(c===0?Eo:l).update(t).update(Vi).digestInto(l),s.set(l,r.outputLen*c),o._cloneInto(a);return o.destroy(),a.destroy(),l.fill(0),Vi.fill(0),s.slice(0,i)}const Sy=(r,e,t,i,n)=>Iy(r,Ey(r,e,t),i,n);function xy(r,e,t,i){if(typeof r.setBigUint64=="function")return r.setBigUint64(e,t,i);const n=BigInt(32),s=BigInt(4294967295),o=Number(t>>n&s),a=Number(t&s),l=i?4:0,c=i?0:4;r.setUint32(e+l,o,i),r.setUint32(e+c,a,i)}function Py(r,e,t){return r&e^~r&t}function Ay(r,e,t){return r&e^r&t^e&t}let Ty=class extends ns{constructor(e,t,i,n){super(),this.blockLen=e,this.outputLen=t,this.padOffset=i,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Ki(this.buffer)}update(e){Gt(this);const{view:t,buffer:i,blockLen:n}=this;e=Yt(e);const s=e.length;for(let o=0;o<s;){const a=Math.min(n-this.pos,s-o);if(a===n){const l=Ki(e);for(;n<=s-o;o+=n)this.process(l,o);continue}i.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===n&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Gt(this),dl(e,this),this.finished=!0;const{buffer:t,view:i,blockLen:n,isLE:s}=this;let{pos:o}=this;t[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>n-o&&(this.process(i,0),o=0);for(let h=o;h<n;h++)t[h]=0;xy(i,n-8,BigInt(this.length*8),s),this.process(i,0);const a=Ki(e),l=this.outputLen;if(l%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=l/4,u=this.get();if(c>u.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<c;h++)a.setUint32(4*h,u[h],s)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const i=e.slice(0,t);return this.destroy(),i}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:i,length:n,finished:s,destroyed:o,pos:a}=this;return e.length=n,e.pos=a,e.finished=s,e.destroyed=o,n%t&&e.buffer.set(i),e}};const Ry=new Uint32Array([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]),ot=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),at=new Uint32Array(64);let Ny=class extends Ty{constructor(){super(64,32,8,!1),this.A=ot[0]|0,this.B=ot[1]|0,this.C=ot[2]|0,this.D=ot[3]|0,this.E=ot[4]|0,this.F=ot[5]|0,this.G=ot[6]|0,this.H=ot[7]|0}get(){const{A:e,B:t,C:i,D:n,E:s,F:o,G:a,H:l}=this;return[e,t,i,n,s,o,a,l]}set(e,t,i,n,s,o,a,l){this.A=e|0,this.B=t|0,this.C=i|0,this.D=n|0,this.E=s|0,this.F=o|0,this.G=a|0,this.H=l|0}process(e,t){for(let h=0;h<16;h++,t+=4)at[h]=e.getUint32(t,!1);for(let h=16;h<64;h++){const d=at[h-15],f=at[h-2],p=Ve(d,7)^Ve(d,18)^d>>>3,g=Ve(f,17)^Ve(f,19)^f>>>10;at[h]=g+at[h-7]+p+at[h-16]|0}let{A:i,B:n,C:s,D:o,E:a,F:l,G:c,H:u}=this;for(let h=0;h<64;h++){const d=Ve(a,6)^Ve(a,11)^Ve(a,25),f=u+d+Py(a,l,c)+Ry[h]+at[h]|0,p=(Ve(i,2)^Ve(i,13)^Ve(i,22))+Ay(i,n,s)|0;u=c,c=l,l=a,a=o+f|0,o=s,s=n,n=i,i=f+p|0}i=i+this.A|0,n=n+this.B|0,s=s+this.C|0,o=o+this.D|0,a=a+this.E|0,l=l+this.F|0,c=c+this.G|0,u=u+this.H|0,this.set(i,n,s,o,a,l,c,u)}roundClean(){at.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};const Si=fl(()=>new Ny);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Pl=BigInt(0);function as(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function Al(r){if(!as(r))throw new Error("Uint8Array expected")}const $y=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function Oy(r){Al(r);let e="";for(let t=0;t<r.length;t++)e+=$y[r[t]];return e}function Cy(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return r===""?Pl:BigInt("0x"+r)}const Qe={_0:48,_9:57,A:65,F:70,a:97,f:102};function Io(r){if(r>=Qe._0&&r<=Qe._9)return r-Qe._0;if(r>=Qe.A&&r<=Qe.F)return r-(Qe.A-10);if(r>=Qe.a&&r<=Qe.f)return r-(Qe.a-10)}function Tl(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);const e=r.length,t=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const i=new Uint8Array(t);for(let n=0,s=0;n<t;n++,s+=2){const o=Io(r.charCodeAt(s)),a=Io(r.charCodeAt(s+1));if(o===void 0||a===void 0){const l=r[s]+r[s+1];throw new Error('hex string expected, got non-hex character "'+l+'" at index '+s)}i[n]=o*16+a}return i}function So(r){return Al(r),Cy(Oy(Uint8Array.from(r).reverse()))}function ky(r,e){return Tl(r.toString(16).padStart(e*2,"0"))}function My(r,e){return ky(r,e).reverse()}function xo(r,e,t){let i;if(typeof e=="string")try{i=Tl(e)}catch(s){throw new Error(r+" must be hex string or Uint8Array, cause: "+s)}else if(as(e))i=Uint8Array.from(e);else throw new Error(r+" must be hex string or Uint8Array");const n=i.length;if(typeof t=="number"&&n!==t)throw new Error(r+" of length "+t+" expected, got "+n);return i}const Wi=r=>typeof r=="bigint"&&Pl<=r;function Ly(r,e,t){return Wi(r)&&Wi(e)&&Wi(t)&&e<=r&&r<t}function Po(r,e,t,i){if(!Ly(e,t,i))throw new Error("expected valid "+r+": "+t+" <= n < "+i+", got "+e)}const Dy={bigint:r=>typeof r=="bigint",function:r=>typeof r=="function",boolean:r=>typeof r=="boolean",string:r=>typeof r=="string",stringOrUint8Array:r=>typeof r=="string"||as(r),isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,e)=>e.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function Fy(r,e,t={}){const i=(n,s,o)=>{const a=Dy[s];if(typeof a!="function")throw new Error("invalid validator function");const l=r[n];if(!(o&&l===void 0)&&!a(l,r))throw new Error("param "+String(n)+" is invalid. Expected "+s+", got "+l)};for(const[n,s]of Object.entries(e))i(n,s,!1);for(const[n,s]of Object.entries(t))i(n,s,!0);return r}const zt=BigInt(0),Br=BigInt(1);function Rl(r,e){const t=r%e;return t>=zt?t:e+t}function qy(r,e,t){if(e<zt)throw new Error("invalid exponent, negatives unsupported");if(t<=zt)throw new Error("invalid modulus");if(t===Br)return zt;let i=Br;for(;e>zt;)e&Br&&(i=i*r%t),r=r*r%t,e>>=Br;return i}function Ue(r,e,t){let i=r;for(;e-- >zt;)i*=i,i%=t;return i}BigInt(0),BigInt(1),BigInt(0),BigInt(1),BigInt(2),BigInt(8);const qt=BigInt(0),Hi=BigInt(1);function Uy(r){return Fy(r,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...r})}function By(r){const e=Uy(r),{P:t}=e,i=v=>Rl(v,t),n=e.montgomeryBits,s=Math.ceil(n/8),o=e.nByteLength,a=e.adjustScalarBytes||(v=>v),l=e.powPminus2||(v=>qy(v,t-BigInt(2),t));function c(v,_,w){const b=i(v*(_-w));return _=i(_-b),w=i(w+b),[_,w]}const u=(e.a-BigInt(2))/BigInt(4);function h(v,_){Po("u",v,qt,t),Po("scalar",_,qt,t);const w=_,b=v;let E=Hi,I=qt,x=v,N=Hi,$=qt,O;for(let C=BigInt(n-1);C>=qt;C--){const q=w>>C&Hi;$^=q,O=c($,E,x),E=O[0],x=O[1],O=c($,I,N),I=O[0],N=O[1],$=q;const F=E+I,B=i(F*F),K=E-I,M=i(K*K),A=B-M,j=x+N,J=x-N,W=i(J*F),te=i(j*K),we=W+te,Pe=W-te;x=i(we*we),N=i(b*i(Pe*Pe)),E=i(B*M),I=i(A*(B+i(u*A)))}O=c($,E,x),E=O[0],x=O[1],O=c($,I,N),I=O[0],N=O[1];const D=l(I);return i(E*D)}function d(v){return My(i(v),s)}function f(v){const _=xo("u coordinate",v,s);return o===32&&(_[31]&=127),So(_)}function p(v){const _=xo("scalar",v),w=_.length;if(w!==s&&w!==o){let b=""+s+" or "+o;throw new Error("invalid scalar, expected "+b+" bytes, got "+w)}return So(a(_))}function g(v,_){const w=f(_),b=p(v),E=h(w,b);if(E===qt)throw new Error("invalid private or public key received");return d(E)}const y=d(e.Gu);function m(v){return g(v,y)}return{scalarMult:g,scalarMultBase:m,getSharedSecret:(v,_)=>g(v,_),getPublicKey:v=>m(v),utils:{randomPrivateKey:()=>e.randomBytes(e.nByteLength)},GuBytes:y}}const _n=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949");BigInt(0);const zy=BigInt(1),Ao=BigInt(2),Ky=BigInt(3),jy=BigInt(5);BigInt(8);function Vy(r){const e=BigInt(10),t=BigInt(20),i=BigInt(40),n=BigInt(80),s=_n,o=r*r%s*r%s,a=Ue(o,Ao,s)*o%s,l=Ue(a,zy,s)*r%s,c=Ue(l,jy,s)*l%s,u=Ue(c,e,s)*c%s,h=Ue(u,t,s)*u%s,d=Ue(h,i,s)*h%s,f=Ue(d,n,s)*d%s,p=Ue(f,n,s)*d%s,g=Ue(p,e,s)*c%s;return{pow_p_5_8:Ue(g,Ao,s)*r%s,b2:o}}function Wy(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}const bn=By({P:_n,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:r=>{const e=_n,{pow_p_5_8:t,b2:i}=Vy(r);return Rl(Ue(t,Ky,e)*i,e)},adjustScalarBytes:Wy,randomBytes:$r}),Nl="base10",he="base16",dt="base64pad",cr="base64url",Or="utf8",$l=0,nt=1,Cr=2,Hy=0,To=1,vr=12,cs=32;function Jy(){const r=bn.utils.randomPrivateKey(),e=bn.getPublicKey(r);return{privateKey:pe(r,he),publicKey:pe(e,he)}}function En(){const r=$r(cs);return pe(r,he)}function Gy(r,e){const t=bn.getSharedSecret(Oe(r,he),Oe(e,he)),i=Sy(Si,t,void 0,void 0,cs);return pe(i,he)}function Yr(r){const e=Si(Oe(r,he));return pe(e,he)}function tt(r){const e=Si(Oe(r,Or));return pe(e,he)}function Ol(r){return Oe(`${r}`,Nl)}function Nt(r){return Number(pe(r,Nl))}function Yy(r){const e=Ol(typeof r.type<"u"?r.type:$l);if(Nt(e)===nt&&typeof r.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const t=typeof r.senderPublicKey<"u"?Oe(r.senderPublicKey,he):void 0,i=typeof r.iv<"u"?Oe(r.iv,he):$r(vr),n=Oe(r.symKey,he),s=Sl(n,i).encrypt(Oe(r.message,Or));return Cl({type:e,sealed:s,iv:i,senderPublicKey:t,encoding:r.encoding})}function Qy(r){const e=Oe(r.symKey,he),{sealed:t,iv:i}=xr(r),n=Sl(e,i).decrypt(t);if(n===null)throw new Error("Failed to decrypt");return pe(n,Or)}function Xy(r,e){const t=Ol(Cr),i=$r(vr),n=Oe(r,Or);return Cl({type:t,sealed:n,iv:i,encoding:e})}function Zy(r,e){const{sealed:t}=xr({encoded:r,encoding:e});return pe(t,Or)}function Cl(r){const{encoding:e=dt}=r;if(Nt(r.type)===Cr)return pe(Ni([r.type,r.sealed]),e);if(Nt(r.type)===nt){if(typeof r.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return pe(Ni([r.type,r.senderPublicKey,r.iv,r.sealed]),e)}return pe(Ni([r.type,r.iv,r.sealed]),e)}function xr(r){const{encoded:e,encoding:t=dt}=r,i=Oe(e,t),n=i.slice(Hy,To),s=To;if(Nt(n)===nt){const c=s+cs,u=c+vr,h=i.slice(s,c),d=i.slice(c,u),f=i.slice(u);return{type:n,sealed:f,iv:d,senderPublicKey:h}}if(Nt(n)===Cr){const c=i.slice(s),u=$r(vr);return{type:n,sealed:c,iv:u}}const o=s+vr,a=i.slice(s,o),l=i.slice(o);return{type:n,sealed:l,iv:a}}function em(r,e){const t=xr({encoded:r,encoding:e==null?void 0:e.encoding});return kl({type:Nt(t.type),senderPublicKey:typeof t.senderPublicKey<"u"?pe(t.senderPublicKey,he):void 0,receiverPublicKey:e==null?void 0:e.receiverPublicKey})}function kl(r){const e=(r==null?void 0:r.type)||$l;if(e===nt){if(typeof(r==null?void 0:r.senderPublicKey)>"u")throw new Error("missing sender public key");if(typeof(r==null?void 0:r.receiverPublicKey)>"u")throw new Error("missing receiver public key")}return{type:e,senderPublicKey:r==null?void 0:r.senderPublicKey,receiverPublicKey:r==null?void 0:r.receiverPublicKey}}function Ro(r){return r.type===nt&&typeof r.senderPublicKey=="string"&&typeof r.receiverPublicKey=="string"}function No(r){return r.type===Cr}function tm(r){return new Du.ec("p256").keyFromPublic({x:R.Buffer.from(r.x,"base64").toString("hex"),y:R.Buffer.from(r.y,"base64").toString("hex")},"hex")}function rm(r){let e=r.replace(/-/g,"+").replace(/_/g,"/");const t=e.length%4;return t>0&&(e+="=".repeat(4-t)),e}function im(r){return R.Buffer.from(rm(r),"base64")}function nm(r,e){const[t,i,n]=r.split("."),s=im(n);if(s.length!==64)throw new Error("Invalid signature length");const o=s.slice(0,32).toString("hex"),a=s.slice(32,64).toString("hex"),l=`${t}.${i}`,c=Si(l),u=tm(e),h=pe(c,he);if(!u.verify(h,{r:o,s:a}))throw new Error("Invalid signature");return tn(r).payload}const sm="irn";function ci(r){return(r==null?void 0:r.relay)||{protocol:sm}}function pr(r){const e=yu[r];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${r}`);return e}function om(r,e="-"){const t={},i="relay"+e;return Object.keys(r).forEach(n=>{if(n.startsWith(i)){const s=n.replace(i,""),o=r[n];t[s]=o}}),t}function $o(r){if(!r.includes("wc:")){const c=hl(r);c!=null&&c.includes("wc:")&&(r=c)}r=r.includes("wc://")?r.replace("wc://",""):r,r=r.includes("wc:")?r.replace("wc:",""):r;const e=r.indexOf(":"),t=r.indexOf("?")!==-1?r.indexOf("?"):void 0,i=r.substring(0,e),n=r.substring(e+1,t).split("@"),s=typeof t<"u"?r.substring(t):"",o=new URLSearchParams(s),a={};o.forEach((c,u)=>{a[u]=c});const l=typeof a.methods=="string"?a.methods.split(","):void 0;return{protocol:i,topic:am(n[0]),version:parseInt(n[1],10),symKey:a.symKey,relay:om(a),methods:l,expiryTimestamp:a.expiryTimestamp?parseInt(a.expiryTimestamp,10):void 0}}function am(r){return r.startsWith("//")?r.substring(2):r}function cm(r,e="-"){const t="relay",i={};return Object.keys(r).forEach(n=>{const s=t+e+n;r[n]&&(i[s]=r[n])}),i}function Oo(r){const e=new URLSearchParams,t=cm(r.relay);Object.keys(t).sort().forEach(n=>{e.set(n,t[n])}),e.set("symKey",r.symKey),r.expiryTimestamp&&e.set("expiryTimestamp",r.expiryTimestamp.toString()),r.methods&&e.set("methods",r.methods.join(","));const i=e.toString();return`${r.protocol}:${r.topic}@${r.version}?${i}`}function zr(r,e,t){return`${r}?wc_ev=${t}&topic=${e}`}function nr(r){const e=[];return r.forEach(t=>{const[i,n]=t.split(":");e.push(`${i}:${n}`)}),e}function lm(r){const e=[];return Object.values(r).forEach(t=>{e.push(...nr(t.accounts))}),e}function um(r,e){const t=[];return Object.values(r).forEach(i=>{nr(i.accounts).includes(e)&&t.push(...i.methods)}),t}function hm(r,e){const t=[];return Object.values(r).forEach(i=>{nr(i.accounts).includes(e)&&t.push(...i.events)}),t}function dm(r){const e={};return r==null||r.forEach(t=>{const[i,n]=t.split(":");e[i]||(e[i]={accounts:[],chains:[],events:[]}),e[i].accounts.push(t),e[i].chains.push(`${i}:${n}`)}),e}function Co(r,e){e=e.map(i=>i.replace("did:pkh:",""));const t=dm(e);for(const[i,n]of Object.entries(t))n.methods?n.methods=eg(n.methods,r):n.methods=r,n.events=["chainChanged","accountsChanged"];return t}const fm={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}},pm={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 P(r,e){const{message:t,code:i}=pm[r];return{message:e?`${t} ${e}`:t,code:i}}function H(r,e){const{message:t,code:i}=fm[r];return{message:e?`${t} ${e}`:t,code:i}}function xi(r,e){return!!Array.isArray(r)}function li(r){return Object.getPrototypeOf(r)===Object.prototype&&Object.keys(r).length}function fe(r){return typeof r>"u"}function ee(r,e){return e&&fe(r)?!0:typeof r=="string"&&!!r.trim().length}function ls(r,e){return e&&fe(r)?!0:typeof r=="number"&&!isNaN(r)}function gm(r,e){const{requiredNamespaces:t}=e,i=Object.keys(r.namespaces),n=Object.keys(t);let s=!0;return Tt(n,i)?(i.forEach(o=>{const{accounts:a,methods:l,events:c}=r.namespaces[o],u=nr(a),h=t[o];(!Tt(nl(o,h),u)||!Tt(h.methods,l)||!Tt(h.events,c))&&(s=!1)}),s):!1}function ui(r){return ee(r,!1)&&r.includes(":")?r.split(":").length===2:!1}function ym(r){if(ee(r,!1)&&r.includes(":")){const e=r.split(":");if(e.length===3){const t=e[0]+":"+e[1];return!!e[2]&&ui(t)}}return!1}function mm(r){function e(t){try{return typeof new URL(t)<"u"}catch{return!1}}try{if(ee(r,!1)){if(e(r))return!0;const t=hl(r);return e(t)}}catch{}return!1}function vm(r){var e;return(e=r==null?void 0:r.proposer)==null?void 0:e.publicKey}function wm(r){return r==null?void 0:r.topic}function _m(r,e){let t=null;return ee(r==null?void 0:r.publicKey,!1)||(t=P("MISSING_OR_INVALID",`${e} controller public key should be a string`)),t}function ko(r){let e=!0;return xi(r)?r.length&&(e=r.every(t=>ee(t,!1))):e=!1,e}function bm(r,e,t){let i=null;return xi(e)&&e.length?e.forEach(n=>{i||ui(n)||(i=H("UNSUPPORTED_CHAINS",`${t}, chain ${n} should be a string and conform to "namespace:chainId" format`))}):ui(r)||(i=H("UNSUPPORTED_CHAINS",`${t}, 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"] }`)),i}function Em(r,e,t){let i=null;return Object.entries(r).forEach(([n,s])=>{if(i)return;const o=bm(n,nl(n,s),`${e} ${t}`);o&&(i=o)}),i}function Im(r,e){let t=null;return xi(r)?r.forEach(i=>{t||ym(i)||(t=H("UNSUPPORTED_ACCOUNTS",`${e}, account ${i} should be a string and conform to "namespace:chainId:address" format`))}):t=H("UNSUPPORTED_ACCOUNTS",`${e}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),t}function Sm(r,e){let t=null;return Object.values(r).forEach(i=>{if(t)return;const n=Im(i==null?void 0:i.accounts,`${e} namespace`);n&&(t=n)}),t}function xm(r,e){let t=null;return ko(r==null?void 0:r.methods)?ko(r==null?void 0:r.events)||(t=H("UNSUPPORTED_EVENTS",`${e}, events should be an array of strings or empty array for no events`)):t=H("UNSUPPORTED_METHODS",`${e}, methods should be an array of strings or empty array for no methods`),t}function Ml(r,e){let t=null;return Object.values(r).forEach(i=>{if(t)return;const n=xm(i,`${e}, namespace`);n&&(t=n)}),t}function Pm(r,e,t){let i=null;if(r&&li(r)){const n=Ml(r,e);n&&(i=n);const s=Em(r,e,t);s&&(i=s)}else i=P("MISSING_OR_INVALID",`${e}, ${t} should be an object with data`);return i}function Ji(r,e){let t=null;if(r&&li(r)){const i=Ml(r,e);i&&(t=i);const n=Sm(r,e);n&&(t=n)}else t=P("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return t}function Ll(r){return ee(r.protocol,!0)}function Am(r,e){let t=!1;return r?r&&xi(r)&&r.length&&r.forEach(i=>{t=Ll(i)}):t=!0,t}function Tm(r){return typeof r=="number"}function me(r){return typeof r<"u"&&typeof r!==null}function Rm(r){return!(!r||typeof r!="object"||!r.code||!ls(r.code,!1)||!r.message||!ee(r.message,!1))}function Nm(r){return!(fe(r)||!ee(r.method,!1))}function $m(r){return!(fe(r)||fe(r.result)&&fe(r.error)||!ls(r.id,!1)||!ee(r.jsonrpc,!1))}function Om(r){return!(fe(r)||!ee(r.name,!1))}function Mo(r,e){return!(!ui(e)||!lm(r).includes(e))}function Cm(r,e,t){return ee(t,!1)?um(r,e).includes(t):!1}function km(r,e,t){return ee(t,!1)?hm(r,e).includes(t):!1}function Lo(r,e,t){let i=null;const n=Mm(r),s=Lm(e),o=Object.keys(n),a=Object.keys(s),l=Do(Object.keys(r)),c=Do(Object.keys(e)),u=l.filter(h=>!c.includes(h));return u.length&&(i=P("NON_CONFORMING_NAMESPACES",`${t} namespaces keys don't satisfy requiredNamespaces.
526
- Required: ${u.toString()}
527
- Received: ${Object.keys(e).toString()}`)),Tt(o,a)||(i=P("NON_CONFORMING_NAMESPACES",`${t} namespaces chains don't satisfy required namespaces.
528
- Required: ${o.toString()}
529
- Approved: ${a.toString()}`)),Object.keys(e).forEach(h=>{if(!h.includes(":")||i)return;const d=nr(e[h].accounts);d.includes(h)||(i=P("NON_CONFORMING_NAMESPACES",`${t} namespaces accounts don't satisfy namespace accounts for ${h}
530
- Required: ${h}
531
- Approved: ${d.toString()}`))}),o.forEach(h=>{i||(Tt(n[h].methods,s[h].methods)?Tt(n[h].events,s[h].events)||(i=P("NON_CONFORMING_NAMESPACES",`${t} namespaces events don't satisfy namespace events for ${h}`)):i=P("NON_CONFORMING_NAMESPACES",`${t} namespaces methods don't satisfy namespace methods for ${h}`))}),i}function Mm(r){const e={};return Object.keys(r).forEach(t=>{var i;t.includes(":")?e[t]=r[t]:(i=r[t].chains)==null||i.forEach(n=>{e[n]={methods:r[t].methods,events:r[t].events}})}),e}function Do(r){return[...new Set(r.map(e=>e.includes(":")?e.split(":")[0]:e))]}function Lm(r){const e={};return Object.keys(r).forEach(t=>{if(t.includes(":"))e[t]=r[t];else{const i=nr(r[t].accounts);i==null||i.forEach(n=>{e[n]={accounts:r[t].accounts.filter(s=>s.includes(`${n}:`)),methods:r[t].methods,events:r[t].events}})}}),e}function Dm(r,e){return ls(r,!1)&&r<=e.max&&r>=e.min}function Fo(){const r=Nr();return new Promise(e=>{switch(r){case Ee.browser:e(Fm());break;case Ee.reactNative:e(qm());break;case Ee.node:e(Um());break;default:e(!0)}})}function Fm(){return Rr()&&(navigator==null?void 0:navigator.onLine)}async function qm(){if(wt()&&typeof R.global<"u"&&R.global!=null&&R.global.NetInfo){const r=await(R.global==null?void 0:R.global.NetInfo.fetch());return r==null?void 0:r.isConnected}return!0}function Um(){return!0}function Bm(r){switch(Nr()){case Ee.browser:zm(r);break;case Ee.reactNative:Km(r);break}}function zm(r){!wt()&&Rr()&&(window.addEventListener("online",()=>r(!0)),window.addEventListener("offline",()=>r(!1)))}function Km(r){var e;wt()&&typeof R.global<"u"&&R.global!=null&&R.global.NetInfo&&((e=R.global)==null||e.NetInfo.addEventListener(t=>r(t==null?void 0:t.isConnected)))}const Gi={};class lr{static get(e){return Gi[e]}static set(e,t){Gi[e]=t}static delete(e){delete Gi[e]}}const jm=r=>JSON.stringify(r,(e,t)=>typeof t=="bigint"?t.toString()+"n":t),Vm=r=>{const e=/([\[:])?(\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,t=r.replace(e,'$1"$2n"$3');return JSON.parse(t,(i,n)=>typeof n=="string"&&n.match(/^\d+n$/)?BigInt(n.substring(0,n.length-1)):n)};function Wm(r){if(typeof r!="string")throw new Error(`Cannot safe json parse value of type ${typeof r}`);try{return Vm(r)}catch{return r}}function Hm(r){return typeof r=="string"?r:jm(r)||""}const Jm=()=>typeof WebSocket<"u"?WebSocket:typeof R.global<"u"&&typeof R.global.WebSocket<"u"?R.global.WebSocket:typeof window<"u"&&typeof window.WebSocket<"u"?window.WebSocket:typeof self<"u"&&typeof self.WebSocket<"u"?self.WebSocket:require("ws"),Gm=()=>typeof WebSocket<"u"||typeof R.global<"u"&&typeof R.global.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof self<"u"&&typeof self.WebSocket<"u",qo=r=>r.split("?")[0],Uo=10,Ym=Jm();class Qm{constructor(e){if(this.url=e,this.events=new Ge.EventEmitter,this.registering=!1,!gs(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)=>{if(typeof this.socket>"u"){t(new Error("Connection already closed"));return}this.socket.onclose=i=>{this.onClose(i),e()},this.socket.close()})}async send(e){typeof this.socket>"u"&&(this.socket=await this.register());try{this.socket.send(Hm(e))}catch(t){this.onError(e.id,t)}}register(e=this.url){if(!gs(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);if(this.registering){const t=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=t||this.events.listenerCount("open")>=t)&&this.events.setMaxListeners(t+1),new Promise((i,n)=>{this.events.once("register_error",s=>{this.resetMaxListeners(),n(s)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.socket>"u")return n(new Error("WebSocket connection is missing or invalid"));i(this.socket)})})}return this.url=e,this.registering=!0,new Promise((t,i)=>{const n=vu.isReactNative()?void 0:{rejectUnauthorized:!wu(e)},s=new Ym(e,[],n);Gm()?s.onerror=o=>{const a=o;i(this.emitError(a.error))}:s.on("error",o=>{i(this.emitError(o))}),s.onopen=()=>{this.onOpen(s),t(s)}})}onOpen(e){e.onmessage=t=>this.onPayload(t),e.onclose=t=>this.onClose(t),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=typeof e.data=="string"?Wm(e.data):e.data;this.events.emit("payload",t)}onError(e,t){const i=this.parseError(t),n=i.message||i.toString(),s=An(e,n);this.events.emit("payload",s)}parseError(e,t=this.url){return _u(e,qo(t),"WS")}resetMaxListeners(){this.events.getMaxListeners()>Uo&&this.events.setMaxListeners(Uo)}emitError(e){const t=this.parseError(new Error((e==null?void 0:e.message)||`WebSocket connection failed for host: ${qo(this.url)}`));return this.events.emit("register_error",t),t}}var X={};Object.defineProperty(X,"__esModule",{value:!0});X.getLocalStorage=X.getLocalStorageOrThrow=X.getCrypto=X.getCryptoOrThrow=X.getLocation=X.getLocationOrThrow=X.getNavigator=X.getNavigatorOrThrow=Dl=X.getDocument=X.getDocumentOrThrow=X.getFromWindowOrThrow=X.getFromWindow=void 0;function Lt(r){let e;return typeof window<"u"&&typeof window[r]<"u"&&(e=window[r]),e}X.getFromWindow=Lt;function sr(r){const e=Lt(r);if(!e)throw new Error(`${r} is not defined in Window`);return e}X.getFromWindowOrThrow=sr;function Xm(){return sr("document")}X.getDocumentOrThrow=Xm;function Zm(){return Lt("document")}var Dl=X.getDocument=Zm;function e0(){return sr("navigator")}X.getNavigatorOrThrow=e0;function t0(){return Lt("navigator")}X.getNavigator=t0;function r0(){return sr("location")}X.getLocationOrThrow=r0;function i0(){return Lt("location")}X.getLocation=i0;function n0(){return sr("crypto")}X.getCryptoOrThrow=n0;function s0(){return Lt("crypto")}X.getCrypto=s0;function o0(){return sr("localStorage")}X.getLocalStorageOrThrow=o0;function a0(){return Lt("localStorage")}X.getLocalStorage=a0;const Fl="wc",ql=2,In="core",Je=`${Fl}@2:${In}:`,c0={logger:"error"},l0={database:":memory:"},u0="crypto",Bo="client_ed25519_seed",h0=S.ONE_DAY,d0="keychain",f0="0.3",p0="messages",g0="0.3",zo=S.SIX_HOURS,y0="publisher",Ul="irn",m0="error",Bl="wss://relay.walletconnect.org",v0="relayer",se={message:"relayer_message",message_ack:"relayer_message_ack",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error",connection_stalled:"relayer_connection_stalled",publish:"relayer_publish"},w0="_subscription",Re={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},_0=.1,Sn="2.18.0",G={link_mode:"link_mode",relay:"relay"},b0="0.3",E0="WALLETCONNECT_CLIENT_ID",Ko="WALLETCONNECT_LINK_MODE_APPS",_e={created:"subscription_created",deleted:"subscription_deleted",sync:"subscription_sync",resubscribed:"subscription_resubscribed"},I0="subscription",S0="0.3",x0=S.FIVE_SECONDS*1e3,P0="pairing",A0="0.3",ur={wc_pairingDelete:{req:{ttl:S.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:S.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:S.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:S.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:S.ONE_DAY,prompt:!1,tag:0},res:{ttl:S.ONE_DAY,prompt:!1,tag:0}}},St={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},De={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},T0="history",R0="0.3",N0="expirer",Ne={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},$0="0.3",O0="verify-api",C0="https://verify.walletconnect.com",zl="https://verify.walletconnect.org",wr=zl,k0=`${wr}/v3`,M0=[C0,zl],L0="echo",D0="https://echo.walletconnect.com",He={pairing_started:"pairing_started",pairing_uri_validation_success:"pairing_uri_validation_success",pairing_uri_not_expired:"pairing_uri_not_expired",store_new_pairing:"store_new_pairing",subscribing_pairing_topic:"subscribing_pairing_topic",subscribe_pairing_topic_success:"subscribe_pairing_topic_success",existing_pairing:"existing_pairing",pairing_not_expired:"pairing_not_expired",emit_inactive_pairing:"emit_inactive_pairing",emit_session_proposal:"emit_session_proposal"},et={no_internet_connection:"no_internet_connection",malformed_pairing_uri:"malformed_pairing_uri",active_pairing_already_exists:"active_pairing_already_exists",subscribe_pairing_topic_failure:"subscribe_pairing_topic_failure",pairing_expired:"pairing_expired",proposal_listener_not_found:"proposal_listener_not_found"},Fe={session_approve_started:"session_approve_started",session_namespaces_validation_success:"session_namespaces_validation_success",subscribing_session_topic:"subscribing_session_topic",subscribe_session_topic_success:"subscribe_session_topic_success",publishing_session_approve:"publishing_session_approve",session_approve_publish_success:"session_approve_publish_success",store_session:"store_session",publishing_session_settle:"publishing_session_settle",session_settle_publish_success:"session_settle_publish_success"},bt={no_internet_connection:"no_internet_connection",proposal_expired:"proposal_expired",subscribe_session_topic_failure:"subscribe_session_topic_failure",session_approve_publish_failure:"session_approve_publish_failure",session_settle_publish_failure:"session_settle_publish_failure",session_approve_namespace_validation_failure:"session_approve_namespace_validation_failure",proposal_not_found:"proposal_not_found"},Et={authenticated_session_approve_started:"authenticated_session_approve_started",create_authenticated_session_topic:"create_authenticated_session_topic",cacaos_verified:"cacaos_verified",store_authenticated_session:"store_authenticated_session",subscribing_authenticated_session_topic:"subscribing_authenticated_session_topic",subscribe_authenticated_session_topic_success:"subscribe_authenticated_session_topic_success",publishing_authenticated_session_approve:"publishing_authenticated_session_approve"},hr={no_internet_connection:"no_internet_connection",invalid_cacao:"invalid_cacao",subscribe_authenticated_session_topic_failure:"subscribe_authenticated_session_topic_failure",authenticated_session_approve_publish_failure:"authenticated_session_approve_publish_failure",authenticated_session_pending_request_not_found:"authenticated_session_pending_request_not_found"},F0=.1,q0="event-client",U0=86400,B0="https://pulse.walletconnect.org/batch";function z0(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),i=0;i<t.length;i++)t[i]=255;for(var n=0;n<r.length;n++){var s=r.charAt(n),o=s.charCodeAt(0);if(t[o]!==255)throw new TypeError(s+" is ambiguous");t[o]=n}var a=r.length,l=r.charAt(0),c=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function h(p){if(p instanceof Uint8Array||(ArrayBuffer.isView(p)?p=new Uint8Array(p.buffer,p.byteOffset,p.byteLength):Array.isArray(p)&&(p=Uint8Array.from(p))),!(p instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(p.length===0)return"";for(var g=0,y=0,m=0,v=p.length;m!==v&&p[m]===0;)m++,g++;for(var _=(v-m)*u+1>>>0,w=new Uint8Array(_);m!==v;){for(var b=p[m],E=0,I=_-1;(b!==0||E<y)&&I!==-1;I--,E++)b+=256*w[I]>>>0,w[I]=b%a>>>0,b=b/a>>>0;if(b!==0)throw new Error("Non-zero carry");y=E,m++}for(var x=_-y;x!==_&&w[x]===0;)x++;for(var N=l.repeat(g);x<_;++x)N+=r.charAt(w[x]);return N}function d(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return new Uint8Array;var g=0;if(p[g]!==" "){for(var y=0,m=0;p[g]===l;)y++,g++;for(var v=(p.length-g)*c+1>>>0,_=new Uint8Array(v);p[g];){var w=t[p.charCodeAt(g)];if(w===255)return;for(var b=0,E=v-1;(w!==0||b<m)&&E!==-1;E--,b++)w+=a*_[E]>>>0,_[E]=w%256>>>0,w=w/256>>>0;if(w!==0)throw new Error("Non-zero carry");m=b,g++}if(p[g]!==" "){for(var I=v-m;I!==v&&_[I]===0;)I++;for(var x=new Uint8Array(y+(v-I)),N=y;I!==v;)x[N++]=_[I++];return x}}}function f(p){var g=d(p);if(g)return g;throw new Error(`Non-${e} character`)}return{encode:h,decodeUnsafe:d,decode:f}}var K0=z0,j0=K0;const Kl=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")},V0=r=>new TextEncoder().encode(r),W0=r=>new TextDecoder().decode(r);class H0{constructor(e,t,i){this.name=e,this.prefix=t,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class J0{constructor(e,t,i){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=i}decode(e){if(typeof e=="string"){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))}else throw Error("Can only multibase decode strings")}or(e){return jl(this,e)}}class G0{constructor(e){this.decoders=e}or(e){return jl(this,e)}decode(e){const t=e[0],i=this.decoders[t];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const jl=(r,e)=>new G0({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}});class Y0{constructor(e,t,i,n){this.name=e,this.prefix=t,this.baseEncode=i,this.baseDecode=n,this.encoder=new H0(e,t,i),this.decoder=new J0(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const Pi=({name:r,prefix:e,encode:t,decode:i})=>new Y0(r,e,t,i),kr=({prefix:r,name:e,alphabet:t})=>{const{encode:i,decode:n}=j0(t,e);return Pi({prefix:r,name:e,encode:i,decode:s=>Kl(n(s))})},Q0=(r,e,t,i)=>{const n={};for(let u=0;u<e.length;++u)n[e[u]]=u;let s=r.length;for(;r[s-1]==="=";)--s;const o=new Uint8Array(s*t/8|0);let a=0,l=0,c=0;for(let u=0;u<s;++u){const h=n[r[u]];if(h===void 0)throw new SyntaxError(`Non-${i} character`);l=l<<t|h,a+=t,a>=8&&(a-=8,o[c++]=255&l>>a)}if(a>=t||255&l<<8-a)throw new SyntaxError("Unexpected end of data");return o},X0=(r,e,t)=>{const i=e[e.length-1]==="=",n=(1<<t)-1;let s="",o=0,a=0;for(let l=0;l<r.length;++l)for(a=a<<8|r[l],o+=8;o>t;)o-=t,s+=e[n&a>>o];if(o&&(s+=e[n&a<<t-o]),i)for(;s.length*t&7;)s+="=";return s},le=({name:r,prefix:e,bitsPerChar:t,alphabet:i})=>Pi({prefix:e,name:r,encode(n){return X0(n,i,t)},decode(n){return Q0(n,i,t,r)}}),Z0=Pi({prefix:"\0",name:"identity",encode:r=>W0(r),decode:r=>V0(r)});var ev=Object.freeze({__proto__:null,identity:Z0});const tv=le({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var rv=Object.freeze({__proto__:null,base2:tv});const iv=le({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var nv=Object.freeze({__proto__:null,base8:iv});const sv=kr({prefix:"9",name:"base10",alphabet:"0123456789"});var ov=Object.freeze({__proto__:null,base10:sv});const av=le({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),cv=le({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var lv=Object.freeze({__proto__:null,base16:av,base16upper:cv});const uv=le({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),hv=le({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),dv=le({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),fv=le({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),pv=le({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),gv=le({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),yv=le({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),mv=le({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),vv=le({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var wv=Object.freeze({__proto__:null,base32:uv,base32upper:hv,base32pad:dv,base32padupper:fv,base32hex:pv,base32hexupper:gv,base32hexpad:yv,base32hexpadupper:mv,base32z:vv});const _v=kr({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),bv=kr({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Ev=Object.freeze({__proto__:null,base36:_v,base36upper:bv});const Iv=kr({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Sv=kr({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var xv=Object.freeze({__proto__:null,base58btc:Iv,base58flickr:Sv});const Pv=le({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Av=le({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Tv=le({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Rv=le({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Nv=Object.freeze({__proto__:null,base64:Pv,base64pad:Av,base64url:Tv,base64urlpad:Rv});const Vl=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),$v=Vl.reduce((r,e,t)=>(r[t]=e,r),[]),Ov=Vl.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function Cv(r){return r.reduce((e,t)=>(e+=$v[t],e),"")}function kv(r){const e=[];for(const t of r){const i=Ov[t.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(i)}return new Uint8Array(e)}const Mv=Pi({prefix:"🚀",name:"base256emoji",encode:Cv,decode:kv});var Lv=Object.freeze({__proto__:null,base256emoji:Mv}),Dv=Wl,jo=128,Fv=-128,qv=Math.pow(2,31);function Wl(r,e,t){e=e||[],t=t||0;for(var i=t;r>=qv;)e[t++]=r&255|jo,r/=128;for(;r&Fv;)e[t++]=r&255|jo,r>>>=7;return e[t]=r|0,Wl.bytes=t-i+1,e}var Uv=xn,Bv=128,Vo=127;function xn(r,i){var t=0,i=i||0,n=0,s=i,o,a=r.length;do{if(s>=a)throw xn.bytes=0,new RangeError("Could not decode varint");o=r[s++],t+=n<28?(o&Vo)<<n:(o&Vo)*Math.pow(2,n),n+=7}while(o>=Bv);return xn.bytes=s-i,t}var zv=Math.pow(2,7),Kv=Math.pow(2,14),jv=Math.pow(2,21),Vv=Math.pow(2,28),Wv=Math.pow(2,35),Hv=Math.pow(2,42),Jv=Math.pow(2,49),Gv=Math.pow(2,56),Yv=Math.pow(2,63),Qv=function(r){return r<zv?1:r<Kv?2:r<jv?3:r<Vv?4:r<Wv?5:r<Hv?6:r<Jv?7:r<Gv?8:r<Yv?9:10},Xv={encode:Dv,decode:Uv,encodingLength:Qv},Hl=Xv;const Wo=(r,e,t=0)=>(Hl.encode(r,e,t),e),Ho=r=>Hl.encodingLength(r),Pn=(r,e)=>{const t=e.byteLength,i=Ho(r),n=i+Ho(t),s=new Uint8Array(n+t);return Wo(r,s,0),Wo(t,s,i),s.set(e,n),new Zv(r,t,e,s)};class Zv{constructor(e,t,i,n){this.code=e,this.size=t,this.digest=i,this.bytes=n}}const Jl=({name:r,code:e,encode:t})=>new ew(r,e,t);class ew{constructor(e,t,i){this.name=e,this.code=t,this.encode=i}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?Pn(this.code,t):t.then(i=>Pn(this.code,i))}else throw Error("Unknown type, must be binary type")}}const Gl=r=>async e=>new Uint8Array(await crypto.subtle.digest(r,e)),tw=Jl({name:"sha2-256",code:18,encode:Gl("SHA-256")}),rw=Jl({name:"sha2-512",code:19,encode:Gl("SHA-512")});var iw=Object.freeze({__proto__:null,sha256:tw,sha512:rw});const Yl=0,nw="identity",Ql=Kl,sw=r=>Pn(Yl,Ql(r)),ow={code:Yl,name:nw,encode:Ql,digest:sw};var aw=Object.freeze({__proto__:null,identity:ow});new TextEncoder,new TextDecoder;const Jo={...ev,...rv,...nv,...ov,...lv,...wv,...Ev,...xv,...Nv,...Lv};({...iw,...aw});function cw(r=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(r):new Uint8Array(r)}function Xl(r,e,t,i){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:i}}}const Go=Xl("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Yi=Xl("ascii","a",r=>{let e="a";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return e},r=>{r=r.substring(1);const e=cw(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),lw={utf8:Go,"utf-8":Go,hex:Jo.base16,latin1:Yi,ascii:Yi,binary:Yi,...Jo};function uw(r,e="utf8"){const t=lw[e];if(!t)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r,"utf8"):t.decoder.decode(`${t.prefix}${r}`)}class hw{constructor(e,t){this.core=e,this.logger=t,this.keychain=new Map,this.name=d0,this.version=f0,this.initialized=!1,this.storagePrefix=Je,this.init=async()=>{if(!this.initialized){const i=await this.getKeyChain();typeof i<"u"&&(this.keychain=i),this.initialized=!0}},this.has=i=>(this.isInitialized(),this.keychain.has(i)),this.set=async(i,n)=>{this.isInitialized(),this.keychain.set(i,n),await this.persist()},this.get=i=>{this.isInitialized();const n=this.keychain.get(i);if(typeof n>"u"){const{message:s}=P("NO_MATCHING_KEY",`${this.name}: ${i}`);throw new Error(s)}return n},this.del=async i=>{this.isInitialized(),this.keychain.delete(i),await this.persist()},this.core=e,this.logger=ge(t,this.name)}get context(){return Ie(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,al(e))}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?cl(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:e}=P("NOT_INITIALIZED",this.name);throw new Error(e)}}}class dw{constructor(e,t,i){this.core=e,this.logger=t,this.name=u0,this.randomSessionIdentifier=En(),this.initialized=!1,this.init=async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)},this.hasKeys=n=>(this.isInitialized(),this.keychain.has(n)),this.getClientId=async()=>{this.isInitialized();const n=await this.getClientSeed(),s=ys(n);return Eu(s.publicKey)},this.generateKeyPair=()=>{this.isInitialized();const n=Jy();return this.setPrivateKey(n.publicKey,n.privateKey)},this.signJWT=async n=>{this.isInitialized();const s=await this.getClientSeed(),o=ys(s),a=this.randomSessionIdentifier;return await Iu(a,n,h0,o)},this.generateSharedKey=(n,s,o)=>{this.isInitialized();const a=this.getPrivateKey(n),l=Gy(a,s);return this.setSymKey(l,o)},this.setSymKey=async(n,s)=>{this.isInitialized();const o=s||Yr(n);return await this.keychain.set(o,n),o},this.deleteKeyPair=async n=>{this.isInitialized(),await this.keychain.del(n)},this.deleteSymKey=async n=>{this.isInitialized(),await this.keychain.del(n)},this.encode=async(n,s,o)=>{this.isInitialized();const a=kl(o),l=Yn(s);if(No(a))return Xy(l,o==null?void 0:o.encoding);if(Ro(a)){const d=a.senderPublicKey,f=a.receiverPublicKey;n=await this.generateSharedKey(d,f)}const c=this.getSymKey(n),{type:u,senderPublicKey:h}=a;return Yy({type:u,symKey:c,message:l,senderPublicKey:h,encoding:o==null?void 0:o.encoding})},this.decode=async(n,s,o)=>{this.isInitialized();const a=em(s,o);if(No(a)){const l=Zy(s,o==null?void 0:o.encoding);return ii(l)}if(Ro(a)){const l=a.receiverPublicKey,c=a.senderPublicKey;n=await this.generateSharedKey(l,c)}try{const l=this.getSymKey(n),c=Qy({symKey:l,encoded:s,encoding:o==null?void 0:o.encoding});return ii(c)}catch(l){this.logger.error(`Failed to decode message from topic: '${n}', clientId: '${await this.getClientId()}'`),this.logger.error(l)}},this.getPayloadType=(n,s=dt)=>{const o=xr({encoded:n,encoding:s});return Nt(o.type)},this.getPayloadSenderPublicKey=(n,s=dt)=>{const o=xr({encoded:n,encoding:s});return o.senderPublicKey?pe(o.senderPublicKey,he):void 0},this.core=e,this.logger=ge(t,this.name),this.keychain=i||new hw(this.core,this.logger)}get context(){return Ie(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(Bo)}catch{e=En(),await this.keychain.set(Bo,e)}return uw(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=P("NOT_INITIALIZED",this.name);throw new Error(e)}}}class fw extends ap{constructor(e,t){super(e,t),this.logger=e,this.core=t,this.messages=new Map,this.name=p0,this.version=g0,this.initialized=!1,this.storagePrefix=Je,this.init=async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const i=await this.getRelayerMessages();typeof i<"u"&&(this.messages=i),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(i){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(i)}finally{this.initialized=!0}}},this.set=async(i,n)=>{this.isInitialized();const s=tt(n);let o=this.messages.get(i);return typeof o>"u"&&(o={}),typeof o[s]<"u"||(o[s]=n,this.messages.set(i,o),await this.persist()),s},this.get=i=>{this.isInitialized();let n=this.messages.get(i);return typeof n>"u"&&(n={}),n},this.has=(i,n)=>{this.isInitialized();const s=this.get(i),o=tt(n);return typeof s[o]<"u"},this.del=async i=>{this.isInitialized(),this.messages.delete(i),await this.persist()},this.logger=ge(e,this.name),this.core=t}get context(){return Ie(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,al(e))}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?cl(e):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){const{message:e}=P("NOT_INITIALIZED",this.name);throw new Error(e)}}}var pw=Object.defineProperty,gw=Object.defineProperties,yw=Object.getOwnPropertyDescriptors,Yo=Object.getOwnPropertySymbols,mw=Object.prototype.hasOwnProperty,vw=Object.prototype.propertyIsEnumerable,Qo=(r,e,t)=>e in r?pw(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Xo=(r,e)=>{for(var t in e||(e={}))mw.call(e,t)&&Qo(r,t,e[t]);if(Yo)for(var t of Yo(e))vw.call(e,t)&&Qo(r,t,e[t]);return r},Zo=(r,e)=>gw(r,yw(e));class ww extends cp{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,this.events=new Ge.EventEmitter,this.name=y0,this.queue=new Map,this.publishTimeout=S.toMiliseconds(S.ONE_MINUTE),this.initialPublishTimeout=S.toMiliseconds(S.ONE_SECOND*15),this.needsTransportRestart=!1,this.publish=async(i,n,s)=>{var o;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:i,message:n,opts:s}});const a=(s==null?void 0:s.ttl)||zo,l=ci(s),c=(s==null?void 0:s.prompt)||!1,u=(s==null?void 0:s.tag)||0,h=(s==null?void 0:s.id)||At().toString(),d={topic:i,message:n,opts:{ttl:a,relay:l,prompt:c,tag:u,id:h,attestation:s==null?void 0:s.attestation}},f=`Failed to publish payload, please try again. id:${h} tag:${u}`;try{const p=new Promise(async g=>{const y=({id:v})=>{d.opts.id===v&&(this.removeRequestFromQueue(v),this.relayer.events.removeListener(se.publish,y),g(d))};this.relayer.events.on(se.publish,y);const m=ht(new Promise((v,_)=>{this.rpcPublish({topic:i,message:n,ttl:a,prompt:c,tag:u,id:h,attestation:s==null?void 0:s.attestation}).then(v).catch(w=>{this.logger.warn(w,w==null?void 0:w.message),_(w)})}),this.initialPublishTimeout,`Failed initial publish, retrying.... id:${h} tag:${u}`);try{await m,this.events.removeListener(se.publish,y)}catch(v){this.queue.set(h,Zo(Xo({},d),{attempt:1})),this.logger.warn(v,v==null?void 0:v.message)}});this.logger.trace({type:"method",method:"publish",params:{id:h,topic:i,message:n,opts:s}}),await ht(p,this.publishTimeout,f)}catch(p){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(p),(o=s==null?void 0:s.internal)!=null&&o.throwOnFailedPublish)throw p}finally{this.queue.delete(h)}},this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.relayer=e,this.logger=ge(t,this.name),this.registerEventListeners()}get context(){return Ie(this.logger)}async rpcPublish(e){var t,i,n,s;const{topic:o,message:a,ttl:l=zo,prompt:c,tag:u,id:h,attestation:d}=e,f={method:pr(ci().protocol).publish,params:{topic:o,message:a,ttl:l,prompt:c,tag:u,attestation:d},id:h};fe((t=f.params)==null?void 0:t.prompt)&&((i=f.params)==null||delete i.prompt),fe((n=f.params)==null?void 0:n.tag)&&((s=f.params)==null||delete s.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:f});const p=await this.relayer.request(f);return this.relayer.events.emit(se.publish,e),this.logger.debug("Successfully Published Payload"),p}removeRequestFromQueue(e){this.queue.delete(e)}checkQueue(){this.queue.forEach(async(e,t)=>{const i=e.attempt+1;this.queue.set(t,Zo(Xo({},e),{attempt:i}));const{topic:n,message:s,opts:o,attestation:a}=e;this.logger.warn({},`Publisher: queue->publishing: ${e.opts.id}, tag: ${e.opts.tag}, attempt: ${i}`),await this.rpcPublish({topic:n,message:s,ttl:o.ttl,prompt:o.prompt,tag:o.tag,id:o.id,attestation:a}),this.logger.warn({},`Publisher: queue->published: ${e.opts.id}`)})}registerEventListeners(){this.relayer.core.heartbeat.on(tr.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(se.connection_stalled);return}this.checkQueue()}),this.relayer.on(se.message_ack,e=>{this.removeRequestFromQueue(e.id.toString())})}}class _w{constructor(){this.map=new Map,this.set=(e,t)=>{const i=this.get(e);this.exists(e,t)||this.map.set(e,[...i,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"){this.map.delete(e);return}if(!this.map.has(e))return;const i=this.get(e);if(!this.exists(e,t))return;const n=i.filter(s=>s!==t);if(!n.length){this.map.delete(e);return}this.map.set(e,n)},this.clear=()=>{this.map.clear()}}get topics(){return Array.from(this.map.keys())}}var bw=Object.defineProperty,Ew=Object.defineProperties,Iw=Object.getOwnPropertyDescriptors,ea=Object.getOwnPropertySymbols,Sw=Object.prototype.hasOwnProperty,xw=Object.prototype.propertyIsEnumerable,ta=(r,e,t)=>e in r?bw(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,dr=(r,e)=>{for(var t in e||(e={}))Sw.call(e,t)&&ta(r,t,e[t]);if(ea)for(var t of ea(e))xw.call(e,t)&&ta(r,t,e[t]);return r},Qi=(r,e)=>Ew(r,Iw(e));class Pw extends hp{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,this.subscriptions=new Map,this.topicMap=new _w,this.events=new Ge.EventEmitter,this.name=I0,this.version=S0,this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pollingInterval=20,this.storagePrefix=Je,this.subscribeTimeout=S.toMiliseconds(S.ONE_MINUTE),this.initialSubscribeTimeout=S.toMiliseconds(S.ONE_SECOND*15),this.batchSubscribeTopicsLimit=500,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),this.clientId=await this.relayer.core.crypto.getClientId(),await this.restore()),this.initialized=!0},this.subscribe=async(i,n)=>{this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:n}});try{const s=ci(n),o={topic:i,relay:s,transportType:n==null?void 0:n.transportType};this.pending.set(i,o);const a=await this.rpcSubscribe(i,s,n);return typeof a=="string"&&(this.onSubscribe(a,o),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:n}})),a}catch(s){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(s),s}},this.unsubscribe=async(i,n)=>{await this.restartToComplete(),this.isInitialized(),typeof(n==null?void 0:n.id)<"u"?await this.unsubscribeById(i,n.id,n):await this.unsubscribeByTopic(i,n)},this.isSubscribed=async i=>{if(this.topics.includes(i))return!0;const n=`${this.pendingSubscriptionWatchLabel}_${i}`;return await new Promise((s,o)=>{const a=new S.Watch;a.start(n);const l=setInterval(()=>{(!this.pending.has(i)&&this.topics.includes(i)||this.cached.some(c=>c.topic===i))&&(clearInterval(l),a.stop(n),s(!0)),a.elapsed(n)>=x0&&(clearInterval(l),a.stop(n),o(new Error("Subscription resolution timeout")))},this.pollingInterval)}).catch(()=>!1)},this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.start=async()=>{await this.onConnect()},this.stop=async()=>{await this.onDisconnect()},this.restart=async()=>{await this.restore(),await this.onRestart()},this.checkPending=async()=>{if(this.pending.size===0&&(!this.initialized||!this.relayer.connected))return;const i=[];this.pending.forEach(n=>{i.push(n)}),await this.batchSubscribe(i)},this.registerEventListeners=()=>{this.relayer.core.heartbeat.on(tr.pulse,async()=>{await this.checkPending()}),this.events.on(_e.created,async i=>{const n=_e.created;this.logger.info(`Emitting ${n}`),this.logger.debug({type:"event",event:n,data:i}),await this.persist()}),this.events.on(_e.deleted,async i=>{const n=_e.deleted;this.logger.info(`Emitting ${n}`),this.logger.debug({type:"event",event:n,data:i}),await this.persist()})},this.relayer=e,this.logger=ge(t,this.name),this.clientId=""}get context(){return Ie(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 i=!1;try{i=this.getSubscription(e).topic===t}catch{}return i}reset(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(e,t){const i=this.topicMap.get(e);await Promise.all(i.map(async n=>await this.unsubscribeById(e,n,t)))}async unsubscribeById(e,t,i){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:i}});try{const n=ci(i);await this.rpcUnsubscribe(e,t,n);const s=H("USER_DISCONNECTED",`${this.name}, ${e}`);await this.onUnsubscribe(e,t,s),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:i}})}catch(n){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(n),n}}async rpcSubscribe(e,t,i){var n;(i==null?void 0:i.transportType)===G.relay&&await this.restartToComplete();const s={method:pr(t.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:s});const o=(n=i==null?void 0:i.internal)==null?void 0:n.throwOnFailedPublish;try{const a=this.getSubscriptionId(e);if((i==null?void 0:i.transportType)===G.link_mode)return setTimeout(()=>{(this.relayer.connected||this.relayer.connecting)&&this.relayer.request(s).catch(u=>this.logger.warn(u))},S.toMiliseconds(S.ONE_SECOND)),a;const l=new Promise(async u=>{const h=d=>{d.topic===e&&(this.events.removeListener(_e.created,h),u(d.id))};this.events.on(_e.created,h);try{const d=await ht(new Promise((f,p)=>{this.relayer.request(s).catch(g=>{this.logger.warn(g,g==null?void 0:g.message),p(g)}).then(f)}),this.initialSubscribeTimeout,`Subscribing to ${e} failed, please try again`);this.events.removeListener(_e.created,h),u(d)}catch{}}),c=await ht(l,this.subscribeTimeout,`Subscribing to ${e} failed, please try again`);if(!c&&o)throw new Error(`Subscribing to ${e} failed, please try again`);return c?a:null}catch(a){if(this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(se.connection_stalled),o)throw a}return null}async rpcBatchSubscribe(e){if(!e.length)return;const t=e[0].relay,i={method:pr(t.protocol).batchSubscribe,params:{topics:e.map(n=>n.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});try{await await ht(new Promise(n=>{this.relayer.request(i).catch(s=>this.logger.warn(s)).then(n)}),this.subscribeTimeout,"rpcBatchSubscribe failed, please try again")}catch{this.relayer.events.emit(se.connection_stalled)}}async rpcBatchFetchMessages(e){if(!e.length)return;const t=e[0].relay,i={method:pr(t.protocol).batchFetchMessages,params:{topics:e.map(s=>s.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});let n;try{n=await await ht(new Promise((s,o)=>{this.relayer.request(i).catch(a=>{this.logger.warn(a),o(a)}).then(s)}),this.subscribeTimeout,"rpcBatchFetchMessages failed, please try again")}catch{this.relayer.events.emit(se.connection_stalled)}return n}rpcUnsubscribe(e,t,i){const n={method:pr(i.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,Qi(dr({},t),{id:e})),this.pending.delete(t.topic)}onBatchSubscribe(e){e.length&&e.forEach(t=>{this.setSubscription(t.id,dr({},t)),this.pending.delete(t.topic)})}async onUnsubscribe(e,t,i){this.events.removeAllListeners(t),this.hasSubscription(t,e)&&this.deleteSubscription(t,i),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.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,dr({},t)),this.topicMap.set(t.topic,e),this.events.emit(_e.created,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:i}=P("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return t}deleteSubscription(e,t){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:t});const i=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(i.topic,e),this.events.emit(_e.deleted,Qi(dr({},i),{reason:t}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(_e.sync)}async onRestart(){if(this.cached.length){const e=[...this.cached],t=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let i=0;i<t;i++){const n=e.splice(0,this.batchSubscribeTopicsLimit);await this.batchSubscribe(n)}}this.events.emit(_e.resubscribed)}async restore(){try{const e=await this.getRelayerSubscriptions();if(typeof e>"u"||!e.length)return;if(this.subscriptions.size){const{message:t}=P("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(t)}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){e.length&&(await this.rpcBatchSubscribe(e),this.onBatchSubscribe(e.map(t=>Qi(dr({},t),{id:this.getSubscriptionId(t.topic)}))))}async batchFetchMessages(e){if(!e.length)return;this.logger.trace(`Fetching batch messages for ${e.length} subscriptions`);const t=await this.rpcBatchFetchMessages(e);t&&t.messages&&(await cg(S.toMiliseconds(S.ONE_SECOND)),await this.relayer.handleBatchMessageEvents(t.messages))}async onConnect(){await this.restart(),this.reset()}onDisconnect(){this.onDisable()}isInitialized(){if(!this.initialized){const{message:e}=P("NOT_INITIALIZED",this.name);throw new Error(e)}}async restartToComplete(){!this.relayer.connected&&!this.relayer.connecting&&await this.relayer.transportOpen()}getSubscriptionId(e){return tt(e+this.clientId)}}var Aw=Object.defineProperty,ra=Object.getOwnPropertySymbols,Tw=Object.prototype.hasOwnProperty,Rw=Object.prototype.propertyIsEnumerable,ia=(r,e,t)=>e in r?Aw(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,na=(r,e)=>{for(var t in e||(e={}))Tw.call(e,t)&&ia(r,t,e[t]);if(ra)for(var t of ra(e))Rw.call(e,t)&&ia(r,t,e[t]);return r};class Nw extends lp{constructor(e){super(e),this.protocol="wc",this.version=2,this.events=new Ge.EventEmitter,this.name=v0,this.transportExplicitlyClosed=!1,this.initialized=!1,this.connectionAttemptInProgress=!1,this.hasExperiencedNetworkDisruption=!1,this.heartBeatTimeout=S.toMiliseconds(S.THIRTY_SECONDS+S.FIVE_SECONDS),this.requestsInFlight=[],this.connectTimeout=S.toMiliseconds(S.ONE_SECOND*15),this.request=async t=>{var i,n;this.logger.debug("Publishing Request Payload");const s=t.id||At().toString();await this.toEstablishConnection();try{this.logger.trace({id:s,method:t.method,topic:(i=t.params)==null?void 0:i.topic},"relayer.request - publishing...");const o=`${s}:${((n=t.params)==null?void 0:n.tag)||""}`;this.requestsInFlight.push(o);const a=await this.provider.request(t);return this.requestsInFlight=this.requestsInFlight.filter(l=>l!==o),a}catch(o){throw this.logger.debug(`Failed to Publish Request: ${s}`),o}},this.resetPingTimeout=()=>{if(oi())try{clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(()=>{var t,i,n;this.logger.debug({},"pingTimeout: Connection stalled, terminating..."),(n=(i=(t=this.provider)==null?void 0:t.connection)==null?void 0:i.socket)==null||n.terminate()},this.heartBeatTimeout)}catch(t){this.logger.warn(t,t==null?void 0:t.message)}},this.onPayloadHandler=t=>{this.onProviderPayload(t),this.resetPingTimeout()},this.onConnectHandler=()=>{this.logger.warn({},"Relayer connected 🛜"),this.startPingTimeout(),this.events.emit(se.connect)},this.onDisconnectHandler=()=>{this.logger.warn({},"Relayer disconnected 🛑"),this.requestsInFlight=[],this.onProviderDisconnect()},this.onProviderErrorHandler=t=>{this.logger.fatal(t,`Fatal socket error: ${t==null?void 0:t.message}`),this.events.emit(se.error,t),this.logger.fatal("Fatal socket error received, closing transport"),this.transportClose()},this.registerProviderListeners=()=>{this.provider.on(Re.payload,this.onPayloadHandler),this.provider.on(Re.connect,this.onConnectHandler),this.provider.on(Re.disconnect,this.onDisconnectHandler),this.provider.on(Re.error,this.onProviderErrorHandler)},this.core=e.core,this.logger=typeof e.logger<"u"&&typeof e.logger!="string"?ge(e.logger,this.name):ba(Tn({level:e.logger||m0})),this.messages=new fw(this.logger,e.core),this.subscriber=new Pw(this,this.logger),this.publisher=new ww(this,this.logger),this.relayUrl=(e==null?void 0:e.relayUrl)||Bl,this.projectId=e.projectId,Wp()?this.packageName=to():Hp()&&(this.bundleId=to()),this.provider={}}async init(){if(this.logger.trace("Initialized"),this.registerEventListeners(),await Promise.all([this.messages.init(),this.subscriber.init()]),this.initialized=!0,this.subscriber.cached.length>0)try{await this.transportOpen()}catch(e){this.logger.warn(e,e==null?void 0:e.message)}}get context(){return Ie(this.logger)}get connected(){var e,t,i;return((i=(t=(e=this.provider)==null?void 0:e.connection)==null?void 0:t.socket)==null?void 0:i.readyState)===1}get connecting(){var e,t,i;return((i=(t=(e=this.provider)==null?void 0:e.connection)==null?void 0:t.socket)==null?void 0:i.readyState)===0}async publish(e,t,i){this.isInitialized(),await this.publisher.publish(e,t,i),await this.recordMessageEvent({topic:e,message:t,publishedAt:Date.now(),transportType:G.relay})}async subscribe(e,t){var i,n,s;this.isInitialized(),(!(t!=null&&t.transportType)||(t==null?void 0:t.transportType)==="relay")&&await this.toEstablishConnection();const o=typeof((i=t==null?void 0:t.internal)==null?void 0:i.throwOnFailedPublish)>"u"?!0:(n=t==null?void 0:t.internal)==null?void 0:n.throwOnFailedPublish;let a=((s=this.subscriber.topicMap.get(e))==null?void 0:s[0])||"",l;const c=u=>{u.topic===e&&(this.subscriber.off(_e.created,c),l())};return await Promise.all([new Promise(u=>{l=u,this.subscriber.on(_e.created,c)}),new Promise(async(u,h)=>{a=await this.subscriber.subscribe(e,na({internal:{throwOnFailedPublish:o}},t)).catch(d=>{o&&h(d)})||a,u()})]),a}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 transportDisconnect(){this.provider.disconnect&&(this.hasExperiencedNetworkDisruption||this.connected)?await ht(this.provider.disconnect(),2e3,"provider.disconnect()").catch(()=>this.onProviderDisconnect()):this.onProviderDisconnect()}async transportClose(){this.transportExplicitlyClosed=!0,await this.transportDisconnect()}async transportOpen(e){if(this.connectPromise?(this.logger.debug({},"Waiting for existing connection attempt to resolve..."),await this.connectPromise,this.logger.debug({},"Existing connection attempt resolved")):(this.connectPromise=new Promise(async(t,i)=>{await this.connect(e).then(t).catch(i).finally(()=>{this.connectPromise=void 0})}),await this.connectPromise),!this.connected)throw new Error(`Couldn't establish socket connection to the relay server: ${this.relayUrl}`)}async restartTransport(e){this.logger.debug({},"Restarting transport..."),!this.connectionAttemptInProgress&&(this.relayUrl=e||this.relayUrl,await this.confirmOnlineStateOrThrow(),await this.transportClose(),await this.transportOpen())}async confirmOnlineStateOrThrow(){if(!await Fo())throw new Error("No internet connection detected. Please restart your network and try again.")}async handleBatchMessageEvents(e){if((e==null?void 0:e.length)===0){this.logger.trace("Batch message events is empty. Ignoring...");return}const t=e.sort((i,n)=>i.publishedAt-n.publishedAt);this.logger.debug(`Batch of ${t.length} message events sorted`);for(const i of t)try{await this.onMessageEvent(i)}catch(n){this.logger.warn(n,"Error while processing batch message event: "+(n==null?void 0:n.message))}this.logger.trace(`Batch of ${t.length} message events processed`)}async onLinkMessageEvent(e,t){const{topic:i}=e;if(!t.sessionExists){const n=re(S.FIVE_MINUTES),s={topic:i,expiry:n,relay:{protocol:"irn"},active:!1};await this.core.pairing.pairings.set(i,s)}this.events.emit(se.message,e),await this.recordMessageEvent(e)}async connect(e){await this.confirmOnlineStateOrThrow(),e&&e!==this.relayUrl&&(this.relayUrl=e,await this.transportDisconnect()),this.connectionAttemptInProgress=!0,this.transportExplicitlyClosed=!1;let t=1;for(;t<6;){try{this.logger.debug({},`Connecting to ${this.relayUrl}, attempt: ${t}...`),await this.createProvider(),await new Promise(async(i,n)=>{const s=()=>{n(new Error("Connection interrupted while trying to subscribe"))};this.provider.once(Re.disconnect,s),await ht(new Promise((o,a)=>{this.provider.connect().then(o).catch(a)}),this.connectTimeout,`Socket stalled when trying to connect to ${this.relayUrl}`).catch(o=>{n(o)}).finally(()=>{this.provider.off(Re.disconnect,s),clearTimeout(this.reconnectTimeout),this.reconnectTimeout=void 0}),await new Promise(async(o,a)=>{const l=()=>{a(new Error("Connection interrupted while trying to subscribe"))};this.provider.once(Re.disconnect,l),await this.subscriber.start().then(o).catch(a).finally(()=>{this.provider.off(Re.disconnect,l)})}),this.hasExperiencedNetworkDisruption=!1,i()})}catch(i){await this.subscriber.stop();const n=i;this.logger.warn({},n.message),this.hasExperiencedNetworkDisruption=!0}finally{this.connectionAttemptInProgress=!1}if(this.connected){this.logger.debug({},`Connected to ${this.relayUrl} successfully on attempt: ${t}`);break}await new Promise(i=>setTimeout(i,S.toMiliseconds(t*1))),t++}}startPingTimeout(){var e,t,i,n,s;if(oi())try{(t=(e=this.provider)==null?void 0:e.connection)!=null&&t.socket&&((s=(n=(i=this.provider)==null?void 0:i.connection)==null?void 0:n.socket)==null||s.on("ping",()=>{this.resetPingTimeout()})),this.resetPingTimeout()}catch(o){this.logger.warn(o,o==null?void 0:o.message)}}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();const e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new Ru(new Qm(Qp({sdkVersion:Sn,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e,useOnCloseEvent:!0,bundleId:this.bundleId,packageName:this.packageName}))),this.registerProviderListeners()}async recordMessageEvent(e){const{topic:t,message:i}=e;await this.messages.set(t,i)}async shouldIgnoreMessageEvent(e){const{topic:t,message:i}=e;if(!i||i.length===0)return this.logger.warn(`Ignoring invalid/empty message: ${i}`),!0;if(!await this.subscriber.isSubscribed(t))return this.logger.warn(`Ignoring message for non-subscribed topic ${t}`),!0;const n=this.messages.has(t,i);return n&&this.logger.warn(`Ignoring duplicate message: ${i}`),n}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),Rn(e)){if(!e.method.endsWith(w0))return;const t=e.params,{topic:i,message:n,publishedAt:s,attestation:o}=t.data,a={topic:i,message:n,publishedAt:s,transportType:G.relay,attestation:o};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(na({type:"event",event:t.id},a)),this.events.emit(t.id,a),await this.acknowledgePayload(e),await this.onMessageEvent(a)}else hi(e)&&this.events.emit(se.message_ack,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(this.events.emit(se.message,e),await this.recordMessageEvent(e))}async acknowledgePayload(e){const t=Nn(e.id,!0);await this.provider.connection.send(t)}unregisterProviderListeners(){this.provider.off(Re.payload,this.onPayloadHandler),this.provider.off(Re.connect,this.onConnectHandler),this.provider.off(Re.disconnect,this.onDisconnectHandler),this.provider.off(Re.error,this.onProviderErrorHandler),clearTimeout(this.pingTimeout)}async registerEventListeners(){let e=await Fo();Bm(async t=>{e!==t&&(e=t,t?await this.transportOpen().catch(i=>this.logger.error(i,i==null?void 0:i.message)):(this.hasExperiencedNetworkDisruption=!0,await this.transportDisconnect(),this.transportExplicitlyClosed=!1))})}async onProviderDisconnect(){await this.subscriber.stop(),clearTimeout(this.pingTimeout),this.events.emit(se.disconnect),this.connectionAttemptInProgress=!1,!this.transportExplicitlyClosed&&(this.reconnectTimeout||this.connectPromise||(this.reconnectTimeout=setTimeout(async()=>{clearTimeout(this.reconnectTimeout),await this.transportOpen().catch(e=>this.logger.error(e,e==null?void 0:e.message))},S.toMiliseconds(_0))))}isInitialized(){if(!this.initialized){const{message:e}=P("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){await this.confirmOnlineStateOrThrow(),!this.connected&&await this.transportOpen()}}var $w=Object.defineProperty,sa=Object.getOwnPropertySymbols,Ow=Object.prototype.hasOwnProperty,Cw=Object.prototype.propertyIsEnumerable,oa=(r,e,t)=>e in r?$w(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,aa=(r,e)=>{for(var t in e||(e={}))Ow.call(e,t)&&oa(r,t,e[t]);if(sa)for(var t of sa(e))Cw.call(e,t)&&oa(r,t,e[t]);return r};class Dt extends up{constructor(e,t,i,n=Je,s=void 0){super(e,t,i,n),this.core=e,this.logger=t,this.name=i,this.map=new Map,this.version=b0,this.cached=[],this.initialized=!1,this.storagePrefix=Je,this.recentlyDeleted=[],this.recentlyDeletedLimit=200,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(o=>{this.getKey&&o!==null&&!fe(o)?this.map.set(this.getKey(o),o):vm(o)?this.map.set(o.id,o):wm(o)&&this.map.set(o.topic,o)}),this.cached=[],this.initialized=!0)},this.set=async(o,a)=>{this.isInitialized(),this.map.has(o)?await this.update(o,a):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:o,value:a}),this.map.set(o,a),await this.persist())},this.get=o=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:o}),this.getData(o)),this.getAll=o=>(this.isInitialized(),o?this.values.filter(a=>Object.keys(o).every(l=>Su(a[l],o[l]))):this.values),this.update=async(o,a)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:o,update:a});const l=aa(aa({},this.getData(o)),a);this.map.set(o,l),await this.persist()},this.delete=async(o,a)=>{this.isInitialized(),this.map.has(o)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:o,reason:a}),this.map.delete(o),this.addToRecentlyDeleted(o),await this.persist())},this.logger=ge(t,this.name),this.storagePrefix=n,this.getKey=s}get context(){return Ie(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())}addToRecentlyDeleted(e){this.recentlyDeleted.push(e),this.recentlyDeleted.length>=this.recentlyDeletedLimit&&this.recentlyDeleted.splice(0,this.recentlyDeletedLimit/2)}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){if(this.recentlyDeleted.includes(e)){const{message:n}=P("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${e}`);throw this.logger.error(n),new Error(n)}const{message:i}=P("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(i),new Error(i)}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:t}=P("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}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}=P("NOT_INITIALIZED",this.name);throw new Error(e)}}}class kw{constructor(e,t){this.core=e,this.logger=t,this.name=P0,this.version=A0,this.events=new _a,this.initialized=!1,this.storagePrefix=Je,this.ignoredPayloadTypes=[nt],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:i})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...i])]},this.create=async i=>{this.isInitialized();const n=En(),s=await this.core.crypto.setSymKey(n),o=re(S.FIVE_MINUTES),a={protocol:Ul},l={topic:s,expiry:o,relay:a,active:!1,methods:i==null?void 0:i.methods},c=Oo({protocol:this.core.protocol,version:this.core.version,topic:s,symKey:n,relay:a,expiryTimestamp:o,methods:i==null?void 0:i.methods});return this.events.emit(St.create,l),this.core.expirer.set(s,o),await this.pairings.set(s,l),await this.core.relayer.subscribe(s,{transportType:i==null?void 0:i.transportType}),{topic:s,uri:c}},this.pair=async i=>{this.isInitialized();const n=this.core.eventClient.createEvent({properties:{topic:i==null?void 0:i.uri,trace:[He.pairing_started]}});this.isValidPair(i,n);const{topic:s,symKey:o,relay:a,expiryTimestamp:l,methods:c}=$o(i.uri);n.props.properties.topic=s,n.addTrace(He.pairing_uri_validation_success),n.addTrace(He.pairing_uri_not_expired);let u;if(this.pairings.keys.includes(s)){if(u=this.pairings.get(s),n.addTrace(He.existing_pairing),u.active)throw n.setError(et.active_pairing_already_exists),new Error(`Pairing already exists: ${s}. Please try again with a new connection URI.`);n.addTrace(He.pairing_not_expired)}const h=l||re(S.FIVE_MINUTES),d={topic:s,relay:a,expiry:h,active:!1,methods:c};this.core.expirer.set(s,h),await this.pairings.set(s,d),n.addTrace(He.store_new_pairing),i.activatePairing&&await this.activate({topic:s}),this.events.emit(St.create,d),n.addTrace(He.emit_inactive_pairing),this.core.crypto.keychain.has(s)||await this.core.crypto.setSymKey(o,s),n.addTrace(He.subscribing_pairing_topic);try{await this.core.relayer.confirmOnlineStateOrThrow()}catch{n.setError(et.no_internet_connection)}try{await this.core.relayer.subscribe(s,{relay:a})}catch(f){throw n.setError(et.subscribe_pairing_topic_failure),f}return n.addTrace(He.subscribe_pairing_topic_success),d},this.activate=async({topic:i})=>{this.isInitialized();const n=re(S.FIVE_MINUTES);this.core.expirer.set(i,n),await this.pairings.update(i,{active:!0,expiry:n})},this.ping=async i=>{this.isInitialized(),await this.isValidPing(i),this.logger.warn("ping() is deprecated and will be removed in the next major release.");const{topic:n}=i;if(this.pairings.keys.includes(n)){const s=await this.sendRequest(n,"wc_pairingPing",{}),{done:o,resolve:a,reject:l}=It();this.events.once(U("pairing_ping",s),({error:c})=>{c?l(c):a()}),await o()}},this.updateExpiry=async({topic:i,expiry:n})=>{this.isInitialized(),await this.pairings.update(i,{expiry:n})},this.updateMetadata=async({topic:i,metadata:n})=>{this.isInitialized(),await this.pairings.update(i,{peerMetadata:n})},this.getPairings=()=>(this.isInitialized(),this.pairings.values),this.disconnect=async i=>{this.isInitialized(),await this.isValidDisconnect(i);const{topic:n}=i;this.pairings.keys.includes(n)&&(await this.sendRequest(n,"wc_pairingDelete",H("USER_DISCONNECTED")),await this.deletePairing(n))},this.formatUriFromPairing=i=>{this.isInitialized();const{topic:n,relay:s,expiry:o,methods:a}=i,l=this.core.crypto.keychain.get(n);return Oo({protocol:this.core.protocol,version:this.core.version,topic:n,symKey:l,relay:s,expiryTimestamp:o,methods:a})},this.sendRequest=async(i,n,s)=>{const o=Pt(n,s),a=await this.core.crypto.encode(i,o),l=ur[n].req;return this.core.history.set(i,o),this.core.relayer.publish(i,a,l),o.id},this.sendResult=async(i,n,s)=>{const o=Nn(i,s),a=await this.core.crypto.encode(n,o),l=await this.core.history.get(n,i),c=ur[l.request.method].res;await this.core.relayer.publish(n,a,c),await this.core.history.resolve(o)},this.sendError=async(i,n,s)=>{const o=An(i,s),a=await this.core.crypto.encode(n,o),l=await this.core.history.get(n,i),c=ur[l.request.method]?ur[l.request.method].res:ur.unregistered_method.res;await this.core.relayer.publish(n,a,c),await this.core.history.resolve(o)},this.deletePairing=async(i,n)=>{await this.core.relayer.unsubscribe(i),await Promise.all([this.pairings.delete(i,H("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(i),n?Promise.resolve():this.core.expirer.del(i)])},this.cleanup=async()=>{const i=this.pairings.getAll().filter(n=>lt(n.expiry));await Promise.all(i.map(n=>this.deletePairing(n.topic)))},this.onRelayEventRequest=i=>{const{topic:n,payload:s}=i;switch(s.method){case"wc_pairingPing":return this.onPairingPingRequest(n,s);case"wc_pairingDelete":return this.onPairingDeleteRequest(n,s);default:return this.onUnknownRpcMethodRequest(n,s)}},this.onRelayEventResponse=async i=>{const{topic:n,payload:s}=i,o=(await this.core.history.get(n,s.id)).request.method;switch(o){case"wc_pairingPing":return this.onPairingPingResponse(n,s);default:return this.onUnknownRpcMethodResponse(o)}},this.onPairingPingRequest=async(i,n)=>{const{id:s}=n;try{this.isValidPing({topic:i}),await this.sendResult(s,i,!0),this.events.emit(St.ping,{id:s,topic:i})}catch(o){await this.sendError(s,i,o),this.logger.error(o)}},this.onPairingPingResponse=(i,n)=>{const{id:s}=n;setTimeout(()=>{Ze(n)?this.events.emit(U("pairing_ping",s),{}):Be(n)&&this.events.emit(U("pairing_ping",s),{error:n.error})},500)},this.onPairingDeleteRequest=async(i,n)=>{const{id:s}=n;try{this.isValidDisconnect({topic:i}),await this.deletePairing(i),this.events.emit(St.delete,{id:s,topic:i})}catch(o){await this.sendError(s,i,o),this.logger.error(o)}},this.onUnknownRpcMethodRequest=async(i,n)=>{const{id:s,method:o}=n;try{if(this.registeredMethods.includes(o))return;const a=H("WC_METHOD_UNSUPPORTED",o);await this.sendError(s,i,a),this.logger.error(a)}catch(a){await this.sendError(s,i,a),this.logger.error(a)}},this.onUnknownRpcMethodResponse=i=>{this.registeredMethods.includes(i)||this.logger.error(H("WC_METHOD_UNSUPPORTED",i))},this.isValidPair=(i,n)=>{var s;if(!me(i)){const{message:a}=P("MISSING_OR_INVALID",`pair() params: ${i}`);throw n.setError(et.malformed_pairing_uri),new Error(a)}if(!mm(i.uri)){const{message:a}=P("MISSING_OR_INVALID",`pair() uri: ${i.uri}`);throw n.setError(et.malformed_pairing_uri),new Error(a)}const o=$o(i==null?void 0:i.uri);if(!((s=o==null?void 0:o.relay)!=null&&s.protocol)){const{message:a}=P("MISSING_OR_INVALID","pair() uri#relay-protocol");throw n.setError(et.malformed_pairing_uri),new Error(a)}if(!(o!=null&&o.symKey)){const{message:a}=P("MISSING_OR_INVALID","pair() uri#symKey");throw n.setError(et.malformed_pairing_uri),new Error(a)}if(o!=null&&o.expiryTimestamp&&S.toMiliseconds(o==null?void 0:o.expiryTimestamp)<Date.now()){n.setError(et.pairing_expired);const{message:a}=P("EXPIRED","pair() URI has expired. Please try again with a new connection URI.");throw new Error(a)}},this.isValidPing=async i=>{if(!me(i)){const{message:s}=P("MISSING_OR_INVALID",`ping() params: ${i}`);throw new Error(s)}const{topic:n}=i;await this.isValidPairingTopic(n)},this.isValidDisconnect=async i=>{if(!me(i)){const{message:s}=P("MISSING_OR_INVALID",`disconnect() params: ${i}`);throw new Error(s)}const{topic:n}=i;await this.isValidPairingTopic(n)},this.isValidPairingTopic=async i=>{if(!ee(i,!1)){const{message:n}=P("MISSING_OR_INVALID",`pairing topic should be a string: ${i}`);throw new Error(n)}if(!this.pairings.keys.includes(i)){const{message:n}=P("NO_MATCHING_KEY",`pairing topic doesn't exist: ${i}`);throw new Error(n)}if(lt(this.pairings.get(i).expiry)){await this.deletePairing(i);const{message:n}=P("EXPIRED",`pairing topic: ${i}`);throw new Error(n)}},this.core=e,this.logger=ge(t,this.name),this.pairings=new Dt(this.core,this.logger,this.name,this.storagePrefix)}get context(){return Ie(this.logger)}isInitialized(){if(!this.initialized){const{message:e}=P("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(se.message,async e=>{const{topic:t,message:i,transportType:n}=e;if(!this.pairings.keys.includes(t)||n===G.link_mode||this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(i)))return;const s=await this.core.crypto.decode(t,i);try{Rn(s)?(this.core.history.set(t,s),this.onRelayEventRequest({topic:t,payload:s})):hi(s)&&(await this.core.history.resolve(s),await this.onRelayEventResponse({topic:t,payload:s}),this.core.history.delete(t,s.id))}catch(o){this.logger.error(o)}})}registerExpirerEvents(){this.core.expirer.on(Ne.expired,async e=>{const{topic:t}=ul(e.target);t&&this.pairings.keys.includes(t)&&(await this.deletePairing(t,!0),this.events.emit(St.expire,{topic:t}))})}}class Mw extends op{constructor(e,t){super(e,t),this.core=e,this.logger=t,this.records=new Map,this.events=new Ge.EventEmitter,this.name=T0,this.version=R0,this.cached=[],this.initialized=!1,this.storagePrefix=Je,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(i=>this.records.set(i.id,i)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.set=(i,n,s)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:i,request:n,chainId:s}),this.records.has(n.id))return;const o={id:n.id,topic:i,request:{method:n.method,params:n.params||null},chainId:s,expiry:re(S.THIRTY_DAYS)};this.records.set(o.id,o),this.persist(),this.events.emit(De.created,o)},this.resolve=async i=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:i}),!this.records.has(i.id))return;const n=await this.getRecord(i.id);typeof n.response>"u"&&(n.response=Be(i)?{error:i.error}:{result:i.result},this.records.set(n.id,n),this.persist(),this.events.emit(De.updated,n))},this.get=async(i,n)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:i,id:n}),await this.getRecord(n)),this.delete=(i,n)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:n}),this.values.forEach(s=>{if(s.topic===i){if(typeof n<"u"&&s.id!==n)return;this.records.delete(s.id),this.events.emit(De.deleted,s)}}),this.persist()},this.exists=async(i,n)=>(this.isInitialized(),this.records.has(n)?(await this.getRecord(n)).topic===i:!1),this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.logger=ge(t,this.name)}get context(){return Ie(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 i={topic:t.topic,request:Pt(t.request.method,t.request.params,t.id),chainId:t.chainId};return e.push(i)}),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:i}=P("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return t}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(De.sync)}async restore(){try{const e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){const{message:t}=P("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}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(De.created,e=>{const t=De.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.events.on(De.updated,e=>{const t=De.updated;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.events.on(De.deleted,e=>{const t=De.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.core.heartbeat.on(tr.pulse,()=>{this.cleanup()})}cleanup(){try{this.isInitialized();let e=!1;this.records.forEach(t=>{S.toMiliseconds(t.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${t.id}`),this.records.delete(t.id),this.events.emit(De.deleted,t,!1),e=!0)}),e&&this.persist()}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){const{message:e}=P("NOT_INITIALIZED",this.name);throw new Error(e)}}}class Lw extends dp{constructor(e,t){super(e,t),this.core=e,this.logger=t,this.expirations=new Map,this.events=new Ge.EventEmitter,this.name=N0,this.version=$0,this.cached=[],this.initialized=!1,this.storagePrefix=Je,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(i=>this.expirations.set(i.target,i)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.has=i=>{try{const n=this.formatTarget(i);return typeof this.getExpiration(n)<"u"}catch{return!1}},this.set=(i,n)=>{this.isInitialized();const s=this.formatTarget(i),o={target:s,expiry:n};this.expirations.set(s,o),this.checkExpiry(s,o),this.events.emit(Ne.created,{target:s,expiration:o})},this.get=i=>{this.isInitialized();const n=this.formatTarget(i);return this.getExpiration(n)},this.del=i=>{if(this.isInitialized(),this.has(i)){const n=this.formatTarget(i),s=this.getExpiration(n);this.expirations.delete(n),this.events.emit(Ne.deleted,{target:n,expiration:s})}},this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.logger=ge(t,this.name)}get context(){return Ie(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(typeof e=="string")return Xp(e);if(typeof e=="number")return Zp(e);const{message:t}=P("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(Ne.sync)}async restore(){try{const e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){const{message:t}=P("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}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:i}=P("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.warn(i),new Error(i)}return t}checkExpiry(e,t){const{expiry:i}=t;S.toMiliseconds(i)-Date.now()<=0&&this.expire(e,t)}expire(e,t){this.expirations.delete(e),this.events.emit(Ne.expired,{target:e,expiration:t})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,t)=>this.checkExpiry(t,e))}registerEventListeners(){this.core.heartbeat.on(tr.pulse,()=>this.checkExpirations()),this.events.on(Ne.created,e=>{const t=Ne.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(Ne.expired,e=>{const t=Ne.expired;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(Ne.deleted,e=>{const t=Ne.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=P("NOT_INITIALIZED",this.name);throw new Error(e)}}}class Dw extends fp{constructor(e,t,i){super(e,t,i),this.core=e,this.logger=t,this.store=i,this.name=O0,this.verifyUrlV3=k0,this.storagePrefix=Je,this.version=ql,this.init=async()=>{var n;this.isDevEnv||(this.publicKey=await this.store.getItem(this.storeKey),this.publicKey&&S.toMiliseconds((n=this.publicKey)==null?void 0:n.expiresAt)<Date.now()&&(this.logger.debug("verify v2 public key expired"),await this.removePublicKey()))},this.register=async n=>{if(!Rr()||this.isDevEnv)return;const s=window.location.origin,{id:o,decryptedId:a}=n,l=`${this.verifyUrlV3}/attestation?projectId=${this.core.projectId}&origin=${s}&id=${o}&decryptedId=${a}`;try{const c=Dl(),u=this.startAbortTimer(S.ONE_SECOND*5),h=await new Promise((d,f)=>{const p=()=>{window.removeEventListener("message",y),c.body.removeChild(g),f("attestation aborted")};this.abortController.signal.addEventListener("abort",p);const g=c.createElement("iframe");g.src=l,g.style.display="none",g.addEventListener("error",p,{signal:this.abortController.signal});const y=m=>{if(m.data&&typeof m.data=="string")try{const v=JSON.parse(m.data);if(v.type==="verify_attestation"){if(tn(v.attestation).payload.id!==o)return;clearInterval(u),c.body.removeChild(g),this.abortController.signal.removeEventListener("abort",p),window.removeEventListener("message",y),d(v.attestation===null?"":v.attestation)}}catch(v){this.logger.warn(v)}};c.body.appendChild(g),window.addEventListener("message",y,{signal:this.abortController.signal})});return this.logger.debug("jwt attestation",h),h}catch(c){this.logger.warn(c)}return""},this.resolve=async n=>{if(this.isDevEnv)return"";const{attestationId:s,hash:o,encryptedId:a}=n;if(s===""){this.logger.debug("resolve: attestationId is empty, skipping");return}if(s){if(tn(s).payload.id!==a)return;const c=await this.isValidJwtAttestation(s);if(c){if(!c.isVerified){this.logger.warn("resolve: jwt attestation: origin url not verified");return}return c}}if(!o)return;const l=this.getVerifyUrl(n==null?void 0:n.verifyUrl);return this.fetchAttestation(o,l)},this.fetchAttestation=async(n,s)=>{this.logger.debug(`resolving attestation: ${n} from url: ${s}`);const o=this.startAbortTimer(S.ONE_SECOND*5),a=await fetch(`${s}/attestation/${n}?v2Supported=true`,{signal:this.abortController.signal});return clearTimeout(o),a.status===200?await a.json():void 0},this.getVerifyUrl=n=>{let s=n||wr;return M0.includes(s)||(this.logger.info(`verify url: ${s}, not included in trusted list, assigning default: ${wr}`),s=wr),s},this.fetchPublicKey=async()=>{try{this.logger.debug(`fetching public key from: ${this.verifyUrlV3}`);const n=this.startAbortTimer(S.FIVE_SECONDS),s=await fetch(`${this.verifyUrlV3}/public-key`,{signal:this.abortController.signal});return clearTimeout(n),await s.json()}catch(n){this.logger.warn(n)}},this.persistPublicKey=async n=>{this.logger.debug("persisting public key to local storage",n),await this.store.setItem(this.storeKey,n),this.publicKey=n},this.removePublicKey=async()=>{this.logger.debug("removing verify v2 public key from storage"),await this.store.removeItem(this.storeKey),this.publicKey=void 0},this.isValidJwtAttestation=async n=>{const s=await this.getPublicKey();try{if(s)return this.validateAttestation(n,s)}catch(a){this.logger.error(a),this.logger.warn("error validating attestation")}const o=await this.fetchAndPersistPublicKey();try{if(o)return this.validateAttestation(n,o)}catch(a){this.logger.error(a),this.logger.warn("error validating attestation")}},this.getPublicKey=async()=>this.publicKey?this.publicKey:await this.fetchAndPersistPublicKey(),this.fetchAndPersistPublicKey=async()=>{if(this.fetchPromise)return await this.fetchPromise,this.publicKey;this.fetchPromise=new Promise(async s=>{const o=await this.fetchPublicKey();o&&(await this.persistPublicKey(o),s(o))});const n=await this.fetchPromise;return this.fetchPromise=void 0,n},this.validateAttestation=(n,s)=>{const o=nm(n,s.publicKey),a={hasExpired:S.toMiliseconds(o.exp)<Date.now(),payload:o};if(a.hasExpired)throw this.logger.warn("resolve: jwt attestation expired"),new Error("JWT attestation expired");return{origin:a.payload.origin,isScam:a.payload.isScam,isVerified:a.payload.isVerified}},this.logger=ge(t,this.name),this.abortController=new AbortController,this.isDevEnv=rs(),this.init()}get storeKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//verify:public:key"}get context(){return Ie(this.logger)}startAbortTimer(e){return this.abortController=new AbortController,setTimeout(()=>this.abortController.abort(),S.toMiliseconds(e))}}class Fw extends pp{constructor(e,t){super(e,t),this.projectId=e,this.logger=t,this.context=L0,this.registerDeviceToken=async i=>{const{clientId:n,token:s,notificationType:o,enableEncrypted:a=!1}=i,l=`${D0}/${this.projectId}/clients`;await fetch(l,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:n,type:o,token:s,always_raw:a})})},this.logger=ge(t,this.context)}}var qw=Object.defineProperty,ca=Object.getOwnPropertySymbols,Uw=Object.prototype.hasOwnProperty,Bw=Object.prototype.propertyIsEnumerable,la=(r,e,t)=>e in r?qw(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,fr=(r,e)=>{for(var t in e||(e={}))Uw.call(e,t)&&la(r,t,e[t]);if(ca)for(var t of ca(e))Bw.call(e,t)&&la(r,t,e[t]);return r};class zw extends gp{constructor(e,t,i=!0){super(e,t,i),this.core=e,this.logger=t,this.context=q0,this.storagePrefix=Je,this.storageVersion=F0,this.events=new Map,this.shouldPersist=!1,this.init=async()=>{if(!rs())try{const n={eventId:io(),timestamp:Date.now(),domain:this.getAppDomain(),props:{event:"INIT",type:"",properties:{client_id:await this.core.crypto.getClientId(),user_agent:ol(this.core.relayer.protocol,this.core.relayer.version,Sn)}}};await this.sendEvent([n])}catch(n){this.logger.warn(n)}},this.createEvent=n=>{const{event:s="ERROR",type:o="",properties:{topic:a,trace:l}}=n,c=io(),u=this.core.projectId||"",h=Date.now(),d=fr({eventId:c,timestamp:h,props:{event:s,type:o,properties:{topic:a,trace:l}},bundleId:u,domain:this.getAppDomain()},this.setMethods(c));return this.telemetryEnabled&&(this.events.set(c,d),this.shouldPersist=!0),d},this.getEvent=n=>{const{eventId:s,topic:o}=n;if(s)return this.events.get(s);const a=Array.from(this.events.values()).find(l=>l.props.properties.topic===o);if(a)return fr(fr({},a),this.setMethods(a.eventId))},this.deleteEvent=n=>{const{eventId:s}=n;this.events.delete(s),this.shouldPersist=!0},this.setEventListeners=()=>{this.core.heartbeat.on(tr.pulse,async()=>{this.shouldPersist&&await this.persist(),this.events.forEach(n=>{S.fromMiliseconds(Date.now())-S.fromMiliseconds(n.timestamp)>U0&&(this.events.delete(n.eventId),this.shouldPersist=!0)})})},this.setMethods=n=>({addTrace:s=>this.addTrace(n,s),setError:s=>this.setError(n,s)}),this.addTrace=(n,s)=>{const o=this.events.get(n);o&&(o.props.properties.trace.push(s),this.events.set(n,o),this.shouldPersist=!0)},this.setError=(n,s)=>{const o=this.events.get(n);o&&(o.props.type=s,o.timestamp=Date.now(),this.events.set(n,o),this.shouldPersist=!0)},this.persist=async()=>{await this.core.storage.setItem(this.storageKey,Array.from(this.events.values())),this.shouldPersist=!1},this.restore=async()=>{try{const n=await this.core.storage.getItem(this.storageKey)||[];if(!n.length)return;n.forEach(s=>{this.events.set(s.eventId,fr(fr({},s),this.setMethods(s.eventId)))})}catch(n){this.logger.warn(n)}},this.submit=async()=>{if(!this.telemetryEnabled||this.events.size===0)return;const n=[];for(const[s,o]of this.events)o.props.type&&n.push(o);if(n.length!==0)try{if((await this.sendEvent(n)).ok)for(const s of n)this.events.delete(s.eventId),this.shouldPersist=!0}catch(s){this.logger.warn(s)}},this.sendEvent=async n=>{const s=this.getAppDomain()?"":"&sp=desktop";return await fetch(`${B0}?projectId=${this.core.projectId}&st=events_sdk&sv=js-${Sn}${s}`,{method:"POST",body:JSON.stringify(n)})},this.getAppDomain=()=>sl().url,this.logger=ge(t,this.context),this.telemetryEnabled=i,i?this.restore().then(async()=>{await this.submit(),this.setEventListeners()}):this.persist()}get storageKey(){return this.storagePrefix+this.storageVersion+this.core.customStoragePrefix+"//"+this.context}}var Kw=Object.defineProperty,ua=Object.getOwnPropertySymbols,jw=Object.prototype.hasOwnProperty,Vw=Object.prototype.propertyIsEnumerable,ha=(r,e,t)=>e in r?Kw(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,da=(r,e)=>{for(var t in e||(e={}))jw.call(e,t)&&ha(r,t,e[t]);if(ua)for(var t of ua(e))Vw.call(e,t)&&ha(r,t,e[t]);return r};let Ww=class Zl extends sp{constructor(e){var t;super(e),this.protocol=Fl,this.version=ql,this.name=In,this.events=new Ge.EventEmitter,this.initialized=!1,this.on=(o,a)=>this.events.on(o,a),this.once=(o,a)=>this.events.once(o,a),this.off=(o,a)=>this.events.off(o,a),this.removeListener=(o,a)=>this.events.removeListener(o,a),this.dispatchEnvelope=({topic:o,message:a,sessionExists:l})=>{if(!o||!a)return;const c={topic:o,message:a,publishedAt:Date.now(),transportType:G.link_mode};this.relayer.onLinkMessageEvent(c,{sessionExists:l})},this.projectId=e==null?void 0:e.projectId,this.relayUrl=(e==null?void 0:e.relayUrl)||Bl,this.customStoragePrefix=e!=null&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";const i=Tn({level:typeof(e==null?void 0:e.logger)=="string"&&e.logger?e.logger:c0.logger,name:In}),{logger:n,chunkLoggerController:s}=bu({opts:i,maxSizeInBytes:e==null?void 0:e.maxLogBlobSizeInBytes,loggerOverride:e==null?void 0:e.logger});this.logChunkController=s,(t=this.logChunkController)!=null&&t.downloadLogsBlobInBrowser&&(window.downloadLogsBlobInBrowser=async()=>{var o,a;(o=this.logChunkController)!=null&&o.downloadLogsBlobInBrowser&&((a=this.logChunkController)==null||a.downloadLogsBlobInBrowser({clientId:await this.crypto.getClientId()}))}),this.logger=ge(n,this.name),this.heartbeat=new Gn,this.crypto=new dw(this,this.logger,e==null?void 0:e.keychain),this.history=new Mw(this,this.logger),this.expirer=new Lw(this,this.logger),this.storage=e!=null&&e.storage?e.storage:new np(da(da({},l0),e==null?void 0:e.storageOptions)),this.relayer=new Nw({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new kw(this,this.logger),this.verify=new Dw(this,this.logger,this.storage),this.echoClient=new Fw(this.projectId||"",this.logger),this.linkModeSupportedApps=[],this.eventClient=new zw(this,this.logger,e==null?void 0:e.telemetryEnabled)}static async init(e){const t=new Zl(e);await t.initialize();const i=await t.crypto.getClientId();return await t.storage.setItem(E0,i),t}get context(){return Ie(this.logger)}async start(){this.initialized||await this.initialize()}async getLogsBlob(){var e;return(e=this.logChunkController)==null?void 0:e.logsToBlob({clientId:await this.crypto.getClientId()})}async addLinkModeSupportedApp(e){this.linkModeSupportedApps.includes(e)||(this.linkModeSupportedApps.push(e),await this.storage.setItem(Ko,this.linkModeSupportedApps))}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.linkModeSupportedApps=await this.storage.getItem(Ko)||[],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 Hw=Ww;class Jw{constructor(e){this.opts=e,this.protocol="wc",this.version=2}}class Gw{constructor(e){this.client=e}}const eu="wc",tu=2,ru="client",us=`${eu}@${tu}:${ru}:`,Xi={name:ru,logger:"error"},fa="WALLETCONNECT_DEEPLINK_CHOICE",Yw="proposal",Qw="Proposal expired",Xw="session",Ut=S.SEVEN_DAYS,Zw="engine",ie={wc_sessionPropose:{req:{ttl:S.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:S.FIVE_MINUTES,prompt:!1,tag:1101},reject:{ttl:S.FIVE_MINUTES,prompt:!1,tag:1120},autoReject:{ttl:S.FIVE_MINUTES,prompt:!1,tag:1121}},wc_sessionSettle:{req:{ttl:S.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:S.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:S.ONE_DAY,prompt:!1,tag:1104},res:{ttl:S.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:S.ONE_DAY,prompt:!1,tag:1106},res:{ttl:S.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:S.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:S.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:S.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:S.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:S.ONE_DAY,prompt:!1,tag:1112},res:{ttl:S.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:S.ONE_DAY,prompt:!1,tag:1114},res:{ttl:S.ONE_DAY,prompt:!1,tag:1115}},wc_sessionAuthenticate:{req:{ttl:S.ONE_HOUR,prompt:!0,tag:1116},res:{ttl:S.ONE_HOUR,prompt:!1,tag:1117},reject:{ttl:S.FIVE_MINUTES,prompt:!1,tag:1118},autoReject:{ttl:S.FIVE_MINUTES,prompt:!1,tag:1119}}},Zi={min:S.FIVE_MINUTES,max:S.SEVEN_DAYS},We={idle:"IDLE",active:"ACTIVE"},e1="request",t1=["wc_sessionPropose","wc_sessionRequest","wc_authRequest","wc_sessionAuthenticate"],r1="wc",i1="auth",n1="authKeys",s1="pairingTopics",o1="requests",Ai=`${r1}@${1.5}:${i1}:`,Qr=`${Ai}:PUB_KEY`;var a1=Object.defineProperty,c1=Object.defineProperties,l1=Object.getOwnPropertyDescriptors,pa=Object.getOwnPropertySymbols,u1=Object.prototype.hasOwnProperty,h1=Object.prototype.propertyIsEnumerable,ga=(r,e,t)=>e in r?a1(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Z=(r,e)=>{for(var t in e||(e={}))u1.call(e,t)&&ga(r,t,e[t]);if(pa)for(var t of pa(e))h1.call(e,t)&&ga(r,t,e[t]);return r},qe=(r,e)=>c1(r,l1(e));class d1 extends Gw{constructor(e){super(e),this.name=Zw,this.events=new _a,this.initialized=!1,this.requestQueue={state:We.idle,queue:[]},this.sessionRequestQueue={state:We.idle,queue:[]},this.requestQueueDelay=S.ONE_SECOND,this.expectedPairingMethodMap=new Map,this.recentlyDeletedMap=new Map,this.recentlyDeletedLimit=200,this.relayMessageCache=[],this.init=async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.registerPairingEvents(),await this.registerLinkModeListeners(),this.client.core.pairing.register({methods:Object.keys(ie)}),this.initialized=!0,setTimeout(()=>{this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},S.toMiliseconds(this.requestQueueDelay)))},this.connect=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();const i=qe(Z({},t),{requiredNamespaces:t.requiredNamespaces||{},optionalNamespaces:t.optionalNamespaces||{}});await this.isValidConnect(i);const{pairingTopic:n,requiredNamespaces:s,optionalNamespaces:o,sessionProperties:a,relays:l}=i;let c=n,u,h=!1;try{if(c){const w=this.client.core.pairing.pairings.get(c);this.client.logger.warn("connect() with existing pairing topic is deprecated and will be removed in the next major release."),h=w.active}}catch(w){throw this.client.logger.error(`connect() -> pairing.get(${c}) failed`),w}if(!c||!h){const{topic:w,uri:b}=await this.client.core.pairing.create();c=w,u=b}if(!c){const{message:w}=P("NO_MATCHING_KEY",`connect() pairing topic: ${c}`);throw new Error(w)}const d=await this.client.core.crypto.generateKeyPair(),f=ie.wc_sessionPropose.req.ttl||S.FIVE_MINUTES,p=re(f),g=Z({requiredNamespaces:s,optionalNamespaces:o,relays:l??[{protocol:Ul}],proposer:{publicKey:d,metadata:this.client.metadata},expiryTimestamp:p,pairingTopic:c},a&&{sessionProperties:a}),{reject:y,resolve:m,done:v}=It(f,Qw);this.events.once(U("session_connect"),async({error:w,session:b})=>{if(w)y(w);else if(b){b.self.publicKey=d;const E=qe(Z({},b),{pairingTopic:g.pairingTopic,requiredNamespaces:g.requiredNamespaces,optionalNamespaces:g.optionalNamespaces,transportType:G.relay});await this.client.session.set(b.topic,E),await this.setExpiry(b.topic,b.expiry),c&&await this.client.core.pairing.updateMetadata({topic:c,metadata:b.peer.metadata}),this.cleanupDuplicatePairings(E),m(E)}});const _=await this.sendRequest({topic:c,method:"wc_sessionPropose",params:g,throwOnFailedPublish:!0});return await this.setProposal(_,Z({id:_},g)),{uri:u,approval:v}},this.pair=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{return await this.client.core.pairing.pair(t)}catch(i){throw this.client.logger.error("pair() failed"),i}},this.approve=async t=>{var i,n,s;const o=this.client.core.eventClient.createEvent({properties:{topic:(i=t==null?void 0:t.id)==null?void 0:i.toString(),trace:[Fe.session_approve_started]}});try{this.isInitialized(),await this.confirmOnlineStateOrThrow()}catch(x){throw o.setError(bt.no_internet_connection),x}try{await this.isValidProposalId(t==null?void 0:t.id)}catch(x){throw this.client.logger.error(`approve() -> proposal.get(${t==null?void 0:t.id}) failed`),o.setError(bt.proposal_not_found),x}try{await this.isValidApprove(t)}catch(x){throw this.client.logger.error("approve() -> isValidApprove() failed"),o.setError(bt.session_approve_namespace_validation_failure),x}const{id:a,relayProtocol:l,namespaces:c,sessionProperties:u,sessionConfig:h}=t,d=this.client.proposal.get(a);this.client.core.eventClient.deleteEvent({eventId:o.eventId});const{pairingTopic:f,proposer:p,requiredNamespaces:g,optionalNamespaces:y}=d;let m=(n=this.client.core.eventClient)==null?void 0:n.getEvent({topic:f});m||(m=(s=this.client.core.eventClient)==null?void 0:s.createEvent({type:Fe.session_approve_started,properties:{topic:f,trace:[Fe.session_approve_started,Fe.session_namespaces_validation_success]}}));const v=await this.client.core.crypto.generateKeyPair(),_=p.publicKey,w=await this.client.core.crypto.generateSharedKey(v,_),b=Z(Z({relay:{protocol:l??"irn"},namespaces:c,controller:{publicKey:v,metadata:this.client.metadata},expiry:re(Ut)},u&&{sessionProperties:u}),h&&{sessionConfig:h}),E=G.relay;m.addTrace(Fe.subscribing_session_topic);try{await this.client.core.relayer.subscribe(w,{transportType:E})}catch(x){throw m.setError(bt.subscribe_session_topic_failure),x}m.addTrace(Fe.subscribe_session_topic_success);const I=qe(Z({},b),{topic:w,requiredNamespaces:g,optionalNamespaces:y,pairingTopic:f,acknowledged:!1,self:b.controller,peer:{publicKey:p.publicKey,metadata:p.metadata},controller:v,transportType:G.relay});await this.client.session.set(w,I),m.addTrace(Fe.store_session);try{m.addTrace(Fe.publishing_session_settle),await this.sendRequest({topic:w,method:"wc_sessionSettle",params:b,throwOnFailedPublish:!0}).catch(x=>{throw m==null||m.setError(bt.session_settle_publish_failure),x}),m.addTrace(Fe.session_settle_publish_success),m.addTrace(Fe.publishing_session_approve),await this.sendResult({id:a,topic:f,result:{relay:{protocol:l??"irn"},responderPublicKey:v},throwOnFailedPublish:!0}).catch(x=>{throw m==null||m.setError(bt.session_approve_publish_failure),x}),m.addTrace(Fe.session_approve_publish_success)}catch(x){throw this.client.logger.error(x),this.client.session.delete(w,H("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(w),x}return this.client.core.eventClient.deleteEvent({eventId:m.eventId}),await this.client.core.pairing.updateMetadata({topic:f,metadata:p.metadata}),await this.client.proposal.delete(a,H("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:f}),await this.setExpiry(w,re(Ut)),{topic:w,acknowledged:()=>Promise.resolve(this.client.session.get(w))}},this.reject=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidReject(t)}catch(o){throw this.client.logger.error("reject() -> isValidReject() failed"),o}const{id:i,reason:n}=t;let s;try{s=this.client.proposal.get(i).pairingTopic}catch(o){throw this.client.logger.error(`reject() -> proposal.get(${i}) failed`),o}s&&(await this.sendError({id:i,topic:s,error:n,rpcOpts:ie.wc_sessionPropose.reject}),await this.client.proposal.delete(i,H("USER_DISCONNECTED")))},this.update=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidUpdate(t)}catch(h){throw this.client.logger.error("update() -> isValidUpdate() failed"),h}const{topic:i,namespaces:n}=t,{done:s,resolve:o,reject:a}=It(),l=_t(),c=At().toString(),u=this.client.session.get(i).namespaces;return this.events.once(U("session_update",l),({error:h})=>{h?a(h):o()}),await this.client.session.update(i,{namespaces:n}),await this.sendRequest({topic:i,method:"wc_sessionUpdate",params:{namespaces:n},throwOnFailedPublish:!0,clientRpcId:l,relayRpcId:c}).catch(h=>{this.client.logger.error(h),this.client.session.update(i,{namespaces:u}),a(h)}),{acknowledged:s}},this.extend=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidExtend(t)}catch(l){throw this.client.logger.error("extend() -> isValidExtend() failed"),l}const{topic:i}=t,n=_t(),{done:s,resolve:o,reject:a}=It();return this.events.once(U("session_extend",n),({error:l})=>{l?a(l):o()}),await this.setExpiry(i,re(Ut)),this.sendRequest({topic:i,method:"wc_sessionExtend",params:{},clientRpcId:n,throwOnFailedPublish:!0}).catch(l=>{a(l)}),{acknowledged:s}},this.request=async t=>{this.isInitialized();try{await this.isValidRequest(t)}catch(p){throw this.client.logger.error("request() -> isValidRequest() failed"),p}const{chainId:i,request:n,topic:s,expiry:o=ie.wc_sessionRequest.req.ttl}=t,a=this.client.session.get(s);(a==null?void 0:a.transportType)===G.relay&&await this.confirmOnlineStateOrThrow();const l=_t(),c=At().toString(),{done:u,resolve:h,reject:d}=It(o,"Request expired. Please try again.");this.events.once(U("session_request",l),({error:p,result:g})=>{p?d(p):h(g)});const f=this.getAppLinkIfEnabled(a.peer.metadata,a.transportType);return f?(await this.sendRequest({clientRpcId:l,relayRpcId:c,topic:s,method:"wc_sessionRequest",params:{request:qe(Z({},n),{expiryTimestamp:re(o)}),chainId:i},expiry:o,throwOnFailedPublish:!0,appLink:f}).catch(p=>d(p)),this.client.events.emit("session_request_sent",{topic:s,request:n,chainId:i,id:l}),await u()):await Promise.all([new Promise(async p=>{await this.sendRequest({clientRpcId:l,relayRpcId:c,topic:s,method:"wc_sessionRequest",params:{request:qe(Z({},n),{expiryTimestamp:re(o)}),chainId:i},expiry:o,throwOnFailedPublish:!0}).catch(g=>d(g)),this.client.events.emit("session_request_sent",{topic:s,request:n,chainId:i,id:l}),p()}),new Promise(async p=>{var g;if(!((g=a.sessionConfig)!=null&&g.disableDeepLink)){const y=await ng(this.client.core.storage,fa);await tg({id:l,topic:s,wcDeepLink:y})}p()}),u()]).then(p=>p[2])},this.respond=async t=>{this.isInitialized(),await this.isValidRespond(t);const{topic:i,response:n}=t,{id:s}=n,o=this.client.session.get(i);o.transportType===G.relay&&await this.confirmOnlineStateOrThrow();const a=this.getAppLinkIfEnabled(o.peer.metadata,o.transportType);Ze(n)?await this.sendResult({id:s,topic:i,result:n.result,throwOnFailedPublish:!0,appLink:a}):Be(n)&&await this.sendError({id:s,topic:i,error:n.error,appLink:a}),this.cleanupAfterResponse(t)},this.ping=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidPing(t)}catch(n){throw this.client.logger.error("ping() -> isValidPing() failed"),n}const{topic:i}=t;if(this.client.session.keys.includes(i)){const n=_t(),s=At().toString(),{done:o,resolve:a,reject:l}=It();this.events.once(U("session_ping",n),({error:c})=>{c?l(c):a()}),await Promise.all([this.sendRequest({topic:i,method:"wc_sessionPing",params:{},throwOnFailedPublish:!0,clientRpcId:n,relayRpcId:s}),o()])}else this.client.core.pairing.pairings.keys.includes(i)&&(this.client.logger.warn("ping() on pairing topic is deprecated and will be removed in the next major release."),await this.client.core.pairing.ping({topic:i}))},this.emit=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidEmit(t);const{topic:i,event:n,chainId:s}=t,o=At().toString(),a=_t();await this.sendRequest({topic:i,method:"wc_sessionEvent",params:{event:n,chainId:s},throwOnFailedPublish:!0,relayRpcId:o,clientRpcId:a})},this.disconnect=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidDisconnect(t);const{topic:i}=t;if(this.client.session.keys.includes(i))await this.sendRequest({topic:i,method:"wc_sessionDelete",params:H("USER_DISCONNECTED"),throwOnFailedPublish:!0}),await this.deleteSession({topic:i,emitEvent:!1});else if(this.client.core.pairing.pairings.keys.includes(i))await this.client.core.pairing.disconnect({topic:i});else{const{message:n}=P("MISMATCHED_TOPIC",`Session or pairing topic not found: ${i}`);throw new Error(n)}},this.find=t=>(this.isInitialized(),this.client.session.getAll().filter(i=>gm(i,t))),this.getPendingSessionRequests=()=>this.client.pendingRequest.getAll(),this.authenticate=async(t,i)=>{var n;this.isInitialized(),this.isValidAuthenticate(t);const s=i&&this.client.core.linkModeSupportedApps.includes(i)&&((n=this.client.metadata.redirect)==null?void 0:n.linkMode),o=s?G.link_mode:G.relay;o===G.relay&&await this.confirmOnlineStateOrThrow();const{chains:a,statement:l="",uri:c,domain:u,nonce:h,type:d,exp:f,nbf:p,methods:g=[],expiry:y}=t,m=[...t.resources||[]],{topic:v,uri:_}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"],transportType:o});this.client.logger.info({message:"Generated new pairing",pairing:{topic:v,uri:_}});const w=await this.client.core.crypto.generateKeyPair(),b=Yr(w);if(await Promise.all([this.client.auth.authKeys.set(Qr,{responseTopic:b,publicKey:w}),this.client.auth.pairingTopics.set(b,{topic:b,pairingTopic:v})]),await this.client.core.relayer.subscribe(b,{transportType:o}),this.client.logger.info(`sending request to new pairing topic: ${v}`),g.length>0){const{namespace:M}=Jr(a[0]);let A=Jg(M,"request",g);Gr(m)&&(A=Yg(A,m.pop())),m.push(A)}const E=y&&y>ie.wc_sessionAuthenticate.req.ttl?y:ie.wc_sessionAuthenticate.req.ttl,I={authPayload:{type:d??"caip122",chains:a,statement:l,aud:c,domain:u,version:"1",nonce:h,iat:new Date().toISOString(),exp:f,nbf:p,resources:m},requester:{publicKey:w,metadata:this.client.metadata},expiryTimestamp:re(E)},x={eip155:{chains:a,methods:[...new Set(["personal_sign",...g])],events:["chainChanged","accountsChanged"]}},N={requiredNamespaces:{},optionalNamespaces:x,relays:[{protocol:"irn"}],pairingTopic:v,proposer:{publicKey:w,metadata:this.client.metadata},expiryTimestamp:re(ie.wc_sessionPropose.req.ttl)},{done:$,resolve:O,reject:D}=It(E,"Request expired"),C=async({error:M,session:A})=>{if(this.events.off(U("session_request",F),q),M)D(M);else if(A){A.self.publicKey=w,await this.client.session.set(A.topic,A),await this.setExpiry(A.topic,A.expiry),v&&await this.client.core.pairing.updateMetadata({topic:v,metadata:A.peer.metadata});const j=this.client.session.get(A.topic);await this.deleteProposal(B),O({session:j})}},q=async M=>{var A,j,J;if(await this.deletePendingAuthRequest(F,{message:"fulfilled",code:0}),M.error){const Te=H("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return M.error.code===Te.code?void 0:(this.events.off(U("session_connect"),C),D(M.error.message))}await this.deleteProposal(B),this.events.off(U("session_connect"),C);const{cacaos:W,responder:te}=M.result,we=[],Pe=[];for(const Te of W){await ho({cacao:Te,projectId:this.client.core.projectId})||(this.client.logger.error(Te,"Signature verification failed"),D(H("SESSION_SETTLEMENT_FAILED","Signature verification failed")));const{p:je}=Te,Ti=Gr(je.resources),fs=[yn(je.iss)],iu=ai(je.iss);if(Ti){const Ri=fo(Ti),nu=po(Ti);we.push(...Ri),fs.push(...nu)}for(const Ri of fs)Pe.push(`${Ri}:${iu}`)}const Ae=await this.client.core.crypto.generateSharedKey(w,te.publicKey);let Le;we.length>0&&(Le={topic:Ae,acknowledged:!0,self:{publicKey:w,metadata:this.client.metadata},peer:te,controller:te.publicKey,expiry:re(Ut),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:v,namespaces:Co([...new Set(we)],[...new Set(Pe)]),transportType:o},await this.client.core.relayer.subscribe(Ae,{transportType:o}),await this.client.session.set(Ae,Le),v&&await this.client.core.pairing.updateMetadata({topic:v,metadata:te.metadata}),Le=this.client.session.get(Ae)),(A=this.client.metadata.redirect)!=null&&A.linkMode&&(j=te.metadata.redirect)!=null&&j.linkMode&&(J=te.metadata.redirect)!=null&&J.universal&&i&&(this.client.core.addLinkModeSupportedApp(te.metadata.redirect.universal),this.client.session.update(Ae,{transportType:G.link_mode})),O({auths:W,session:Le})},F=_t(),B=_t();this.events.once(U("session_connect"),C),this.events.once(U("session_request",F),q);let K;try{if(s){const M=Pt("wc_sessionAuthenticate",I,F);this.client.core.history.set(v,M);const A=await this.client.core.crypto.encode("",M,{type:Cr,encoding:cr});K=zr(i,v,A)}else await Promise.all([this.sendRequest({topic:v,method:"wc_sessionAuthenticate",params:I,expiry:t.expiry,throwOnFailedPublish:!0,clientRpcId:F}),this.sendRequest({topic:v,method:"wc_sessionPropose",params:N,expiry:ie.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:B})])}catch(M){throw this.events.off(U("session_connect"),C),this.events.off(U("session_request",F),q),M}return await this.setProposal(B,Z({id:B},N)),await this.setAuthRequest(F,{request:qe(Z({},I),{verifyContext:{}}),pairingTopic:v,transportType:o}),{uri:K??_,response:$}},this.approveSessionAuthenticate=async t=>{const{id:i,auths:n}=t,s=this.client.core.eventClient.createEvent({properties:{topic:i.toString(),trace:[Et.authenticated_session_approve_started]}});try{this.isInitialized()}catch(y){throw s.setError(hr.no_internet_connection),y}const o=this.getPendingAuthRequest(i);if(!o)throw s.setError(hr.authenticated_session_pending_request_not_found),new Error(`Could not find pending auth request with id ${i}`);const a=o.transportType||G.relay;a===G.relay&&await this.confirmOnlineStateOrThrow();const l=o.requester.publicKey,c=await this.client.core.crypto.generateKeyPair(),u=Yr(l),h={type:nt,receiverPublicKey:l,senderPublicKey:c},d=[],f=[];for(const y of n){if(!await ho({cacao:y,projectId:this.client.core.projectId})){s.setError(hr.invalid_cacao);const b=H("SESSION_SETTLEMENT_FAILED","Signature verification failed");throw await this.sendError({id:i,topic:u,error:b,encodeOpts:h}),new Error(b.message)}s.addTrace(Et.cacaos_verified);const{p:m}=y,v=Gr(m.resources),_=[yn(m.iss)],w=ai(m.iss);if(v){const b=fo(v),E=po(v);d.push(...b),_.push(...E)}for(const b of _)f.push(`${b}:${w}`)}const p=await this.client.core.crypto.generateSharedKey(c,l);s.addTrace(Et.create_authenticated_session_topic);let g;if((d==null?void 0:d.length)>0){g={topic:p,acknowledged:!0,self:{publicKey:c,metadata:this.client.metadata},peer:{publicKey:l,metadata:o.requester.metadata},controller:l,expiry:re(Ut),authentication:n,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:o.pairingTopic,namespaces:Co([...new Set(d)],[...new Set(f)]),transportType:a},s.addTrace(Et.subscribing_authenticated_session_topic);try{await this.client.core.relayer.subscribe(p,{transportType:a})}catch(y){throw s.setError(hr.subscribe_authenticated_session_topic_failure),y}s.addTrace(Et.subscribe_authenticated_session_topic_success),await this.client.session.set(p,g),s.addTrace(Et.store_authenticated_session),await this.client.core.pairing.updateMetadata({topic:o.pairingTopic,metadata:o.requester.metadata})}s.addTrace(Et.publishing_authenticated_session_approve);try{await this.sendResult({topic:u,id:i,result:{cacaos:n,responder:{publicKey:c,metadata:this.client.metadata}},encodeOpts:h,throwOnFailedPublish:!0,appLink:this.getAppLinkIfEnabled(o.requester.metadata,a)})}catch(y){throw s.setError(hr.authenticated_session_approve_publish_failure),y}return await this.client.auth.requests.delete(i,{message:"fulfilled",code:0}),await this.client.core.pairing.activate({topic:o.pairingTopic}),this.client.core.eventClient.deleteEvent({eventId:s.eventId}),{session:g}},this.rejectSessionAuthenticate=async t=>{this.isInitialized();const{id:i,reason:n}=t,s=this.getPendingAuthRequest(i);if(!s)throw new Error(`Could not find pending auth request with id ${i}`);s.transportType===G.relay&&await this.confirmOnlineStateOrThrow();const o=s.requester.publicKey,a=await this.client.core.crypto.generateKeyPair(),l=Yr(o),c={type:nt,receiverPublicKey:o,senderPublicKey:a};await this.sendError({id:i,topic:l,error:n,encodeOpts:c,rpcOpts:ie.wc_sessionAuthenticate.reject,appLink:this.getAppLinkIfEnabled(s.requester.metadata,s.transportType)}),await this.client.auth.requests.delete(i,{message:"rejected",code:0}),await this.client.proposal.delete(i,H("USER_DISCONNECTED"))},this.formatAuthMessage=t=>{this.isInitialized();const{request:i,iss:n}=t;return wl(i,n)},this.processRelayMessageCache=()=>{setTimeout(async()=>{if(this.relayMessageCache.length!==0)for(;this.relayMessageCache.length>0;)try{const t=this.relayMessageCache.shift();t&&await this.onRelayMessage(t)}catch(t){this.client.logger.error(t)}},50)},this.cleanupDuplicatePairings=async t=>{if(t.pairingTopic)try{const i=this.client.core.pairing.pairings.get(t.pairingTopic),n=this.client.core.pairing.pairings.getAll().filter(s=>{var o,a;return((o=s.peerMetadata)==null?void 0:o.url)&&((a=s.peerMetadata)==null?void 0:a.url)===t.peer.metadata.url&&s.topic&&s.topic!==i.topic});if(n.length===0)return;this.client.logger.info(`Cleaning up ${n.length} duplicate pairing(s)`),await Promise.all(n.map(s=>this.client.core.pairing.disconnect({topic:s.topic}))),this.client.logger.info("Duplicate pairings clean up finished")}catch(i){this.client.logger.error(i)}},this.deleteSession=async t=>{var i;const{topic:n,expirerHasDeleted:s=!1,emitEvent:o=!0,id:a=0}=t,{self:l}=this.client.session.get(n);await this.client.core.relayer.unsubscribe(n),await this.client.session.delete(n,H("USER_DISCONNECTED")),this.addToRecentlyDeleted(n,"session"),this.client.core.crypto.keychain.has(l.publicKey)&&await this.client.core.crypto.deleteKeyPair(l.publicKey),this.client.core.crypto.keychain.has(n)&&await this.client.core.crypto.deleteSymKey(n),s||this.client.core.expirer.del(n),this.client.core.storage.removeItem(fa).catch(c=>this.client.logger.warn(c)),this.getPendingSessionRequests().forEach(c=>{c.topic===n&&this.deletePendingSessionRequest(c.id,H("USER_DISCONNECTED"))}),n===((i=this.sessionRequestQueue.queue[0])==null?void 0:i.topic)&&(this.sessionRequestQueue.state=We.idle),o&&this.client.events.emit("session_delete",{id:a,topic:n})},this.deleteProposal=async(t,i)=>{if(i)try{const n=this.client.proposal.get(t),s=this.client.core.eventClient.getEvent({topic:n.pairingTopic});s==null||s.setError(bt.proposal_expired)}catch{}await Promise.all([this.client.proposal.delete(t,H("USER_DISCONNECTED")),i?Promise.resolve():this.client.core.expirer.del(t)]),this.addToRecentlyDeleted(t,"proposal")},this.deletePendingSessionRequest=async(t,i,n=!1)=>{await Promise.all([this.client.pendingRequest.delete(t,i),n?Promise.resolve():this.client.core.expirer.del(t)]),this.addToRecentlyDeleted(t,"request"),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter(s=>s.id!==t),n&&(this.sessionRequestQueue.state=We.idle,this.client.events.emit("session_request_expire",{id:t}))},this.deletePendingAuthRequest=async(t,i,n=!1)=>{await Promise.all([this.client.auth.requests.delete(t,i),n?Promise.resolve():this.client.core.expirer.del(t)])},this.setExpiry=async(t,i)=>{this.client.session.keys.includes(t)&&(this.client.core.expirer.set(t,i),await this.client.session.update(t,{expiry:i}))},this.setProposal=async(t,i)=>{this.client.core.expirer.set(t,re(ie.wc_sessionPropose.req.ttl)),await this.client.proposal.set(t,i)},this.setAuthRequest=async(t,i)=>{const{request:n,pairingTopic:s,transportType:o=G.relay}=i;this.client.core.expirer.set(t,n.expiryTimestamp),await this.client.auth.requests.set(t,{authPayload:n.authPayload,requester:n.requester,expiryTimestamp:n.expiryTimestamp,id:t,pairingTopic:s,verifyContext:n.verifyContext,transportType:o})},this.setPendingSessionRequest=async t=>{const{id:i,topic:n,params:s,verifyContext:o}=t,a=s.request.expiryTimestamp||re(ie.wc_sessionRequest.req.ttl);this.client.core.expirer.set(i,a),await this.client.pendingRequest.set(i,{id:i,topic:n,params:s,verifyContext:o})},this.sendRequest=async t=>{const{topic:i,method:n,params:s,expiry:o,relayRpcId:a,clientRpcId:l,throwOnFailedPublish:c,appLink:u}=t,h=Pt(n,s,l);let d;const f=!!u;try{const y=f?cr:dt;d=await this.client.core.crypto.encode(i,h,{encoding:y})}catch(y){throw await this.cleanup(),this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${i} failed`),y}let p;if(t1.includes(n)){const y=tt(JSON.stringify(h)),m=tt(d);p=await this.client.core.verify.register({id:m,decryptedId:y})}const g=ie[n].req;if(g.attestation=p,o&&(g.ttl=o),a&&(g.id=a),this.client.core.history.set(i,h),f){const y=zr(u,i,d);await R.global.Linking.openURL(y,this.client.name)}else{const y=ie[n].req;o&&(y.ttl=o),a&&(y.id=a),c?(y.internal=qe(Z({},y.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(i,d,y)):this.client.core.relayer.publish(i,d,y).catch(m=>this.client.logger.error(m))}return h.id},this.sendResult=async t=>{const{id:i,topic:n,result:s,throwOnFailedPublish:o,encodeOpts:a,appLink:l}=t,c=Nn(i,s);let u;const h=l&&typeof(R.global==null?void 0:R.global.Linking)<"u";try{const f=h?cr:dt;u=await this.client.core.crypto.encode(n,c,qe(Z({},a||{}),{encoding:f}))}catch(f){throw await this.cleanup(),this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${n} failed`),f}let d;try{d=await this.client.core.history.get(n,i)}catch(f){throw this.client.logger.error(`sendResult() -> history.get(${n}, ${i}) failed`),f}if(h){const f=zr(l,n,u);await R.global.Linking.openURL(f,this.client.name)}else{const f=ie[d.request.method].res;o?(f.internal=qe(Z({},f.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(n,u,f)):this.client.core.relayer.publish(n,u,f).catch(p=>this.client.logger.error(p))}await this.client.core.history.resolve(c)},this.sendError=async t=>{const{id:i,topic:n,error:s,encodeOpts:o,rpcOpts:a,appLink:l}=t,c=An(i,s);let u;const h=l&&typeof(R.global==null?void 0:R.global.Linking)<"u";try{const f=h?cr:dt;u=await this.client.core.crypto.encode(n,c,qe(Z({},o||{}),{encoding:f}))}catch(f){throw await this.cleanup(),this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${n} failed`),f}let d;try{d=await this.client.core.history.get(n,i)}catch(f){throw this.client.logger.error(`sendError() -> history.get(${n}, ${i}) failed`),f}if(h){const f=zr(l,n,u);await R.global.Linking.openURL(f,this.client.name)}else{const f=a||ie[d.request.method].res;this.client.core.relayer.publish(n,u,f)}await this.client.core.history.resolve(c)},this.cleanup=async()=>{const t=[],i=[];this.client.session.getAll().forEach(n=>{let s=!1;lt(n.expiry)&&(s=!0),this.client.core.crypto.keychain.has(n.topic)||(s=!0),s&&t.push(n.topic)}),this.client.proposal.getAll().forEach(n=>{lt(n.expiryTimestamp)&&i.push(n.id)}),await Promise.all([...t.map(n=>this.deleteSession({topic:n})),...i.map(n=>this.deleteProposal(n))])},this.onRelayEventRequest=async t=>{this.requestQueue.queue.push(t),await this.processRequestsQueue()},this.processRequestsQueue=async()=>{if(this.requestQueue.state===We.active){this.client.logger.info("Request queue already active, skipping...");return}for(this.client.logger.info(`Request queue starting with ${this.requestQueue.queue.length} requests`);this.requestQueue.queue.length>0;){this.requestQueue.state=We.active;const t=this.requestQueue.queue.shift();if(t)try{await this.processRequest(t)}catch(i){this.client.logger.warn(i)}}this.requestQueue.state=We.idle},this.processRequest=async t=>{const{topic:i,payload:n,attestation:s,transportType:o,encryptedId:a}=t,l=n.method;if(!this.shouldIgnorePairingRequest({topic:i,requestMethod:l}))switch(l){case"wc_sessionPropose":return await this.onSessionProposeRequest({topic:i,payload:n,attestation:s,encryptedId:a});case"wc_sessionSettle":return await this.onSessionSettleRequest(i,n);case"wc_sessionUpdate":return await this.onSessionUpdateRequest(i,n);case"wc_sessionExtend":return await this.onSessionExtendRequest(i,n);case"wc_sessionPing":return await this.onSessionPingRequest(i,n);case"wc_sessionDelete":return await this.onSessionDeleteRequest(i,n);case"wc_sessionRequest":return await this.onSessionRequest({topic:i,payload:n,attestation:s,encryptedId:a,transportType:o});case"wc_sessionEvent":return await this.onSessionEventRequest(i,n);case"wc_sessionAuthenticate":return await this.onSessionAuthenticateRequest({topic:i,payload:n,attestation:s,encryptedId:a,transportType:o});default:return this.client.logger.info(`Unsupported request method ${l}`)}},this.onRelayEventResponse=async t=>{const{topic:i,payload:n,transportType:s}=t,o=(await this.client.core.history.get(i,n.id)).request.method;switch(o){case"wc_sessionPropose":return this.onSessionProposeResponse(i,n,s);case"wc_sessionSettle":return this.onSessionSettleResponse(i,n);case"wc_sessionUpdate":return this.onSessionUpdateResponse(i,n);case"wc_sessionExtend":return this.onSessionExtendResponse(i,n);case"wc_sessionPing":return this.onSessionPingResponse(i,n);case"wc_sessionRequest":return this.onSessionRequestResponse(i,n);case"wc_sessionAuthenticate":return this.onSessionAuthenticateResponse(i,n);default:return this.client.logger.info(`Unsupported response method ${o}`)}},this.onRelayEventUnknownPayload=t=>{const{topic:i}=t,{message:n}=P("MISSING_OR_INVALID",`Decoded payload on topic ${i} is not identifiable as a JSON-RPC request or a response.`);throw new Error(n)},this.shouldIgnorePairingRequest=t=>{const{topic:i,requestMethod:n}=t,s=this.expectedPairingMethodMap.get(i);return!s||s.includes(n)?!1:!!(s.includes("wc_sessionAuthenticate")&&this.client.events.listenerCount("session_authenticate")>0)},this.onSessionProposeRequest=async t=>{const{topic:i,payload:n,attestation:s,encryptedId:o}=t,{params:a,id:l}=n;try{const c=this.client.core.eventClient.getEvent({topic:i});this.client.events.listenerCount("session_proposal")===0&&(console.warn("No listener for session_proposal event"),c==null||c.setError(et.proposal_listener_not_found)),this.isValidConnect(Z({},n.params));const u=a.expiryTimestamp||re(ie.wc_sessionPropose.req.ttl),h=Z({id:l,pairingTopic:i,expiryTimestamp:u},a);await this.setProposal(l,h);const d=await this.getVerifyContext({attestationId:s,hash:tt(JSON.stringify(n)),encryptedId:o,metadata:h.proposer.metadata});c==null||c.addTrace(He.emit_session_proposal),this.client.events.emit("session_proposal",{id:l,params:h,verifyContext:d})}catch(c){await this.sendError({id:l,topic:i,error:c,rpcOpts:ie.wc_sessionPropose.autoReject}),this.client.logger.error(c)}},this.onSessionProposeResponse=async(t,i,n)=>{const{id:s}=i;if(Ze(i)){const{result:o}=i;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:o});const a=this.client.proposal.get(s);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:a});const l=a.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:l});const c=o.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:c});const u=await this.client.core.crypto.generateSharedKey(l,c);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",sessionTopic:u});const h=await this.client.core.relayer.subscribe(u,{transportType:n});this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:h}),await this.client.core.pairing.activate({topic:t})}else if(Be(i)){await this.client.proposal.delete(s,H("USER_DISCONNECTED"));const o=U("session_connect");if(this.events.listenerCount(o)===0)throw new Error(`emitting ${o} without any listeners, 954`);this.events.emit(U("session_connect"),{error:i.error})}},this.onSessionSettleRequest=async(t,i)=>{const{id:n,params:s}=i;try{this.isValidSessionSettleRequest(s);const{relay:o,controller:a,expiry:l,namespaces:c,sessionProperties:u,sessionConfig:h}=i.params,d=qe(Z(Z({topic:t,relay:o,expiry:l,namespaces:c,acknowledged:!0,pairingTopic:"",requiredNamespaces:{},optionalNamespaces:{},controller:a.publicKey,self:{publicKey:"",metadata:this.client.metadata},peer:{publicKey:a.publicKey,metadata:a.metadata}},u&&{sessionProperties:u}),h&&{sessionConfig:h}),{transportType:G.relay}),f=U("session_connect");if(this.events.listenerCount(f)===0)throw new Error(`emitting ${f} without any listeners 997`);this.events.emit(U("session_connect"),{session:d}),await this.sendResult({id:i.id,topic:t,result:!0,throwOnFailedPublish:!0})}catch(o){await this.sendError({id:n,topic:t,error:o}),this.client.logger.error(o)}},this.onSessionSettleResponse=async(t,i)=>{const{id:n}=i;Ze(i)?(await this.client.session.update(t,{acknowledged:!0}),this.events.emit(U("session_approve",n),{})):Be(i)&&(await this.client.session.delete(t,H("USER_DISCONNECTED")),this.events.emit(U("session_approve",n),{error:i.error}))},this.onSessionUpdateRequest=async(t,i)=>{const{params:n,id:s}=i;try{const o=`${t}_session_update`,a=lr.get(o);if(a&&this.isRequestOutOfSync(a,s)){this.client.logger.warn(`Discarding out of sync request - ${s}`),this.sendError({id:s,topic:t,error:H("INVALID_UPDATE_REQUEST")});return}this.isValidUpdate(Z({topic:t},n));try{lr.set(o,s),await this.client.session.update(t,{namespaces:n.namespaces}),await this.sendResult({id:s,topic:t,result:!0,throwOnFailedPublish:!0})}catch(l){throw lr.delete(o),l}this.client.events.emit("session_update",{id:s,topic:t,params:n})}catch(o){await this.sendError({id:s,topic:t,error:o}),this.client.logger.error(o)}},this.isRequestOutOfSync=(t,i)=>i.toString().slice(0,-3)<t.toString().slice(0,-3),this.onSessionUpdateResponse=(t,i)=>{const{id:n}=i,s=U("session_update",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);Ze(i)?this.events.emit(U("session_update",n),{}):Be(i)&&this.events.emit(U("session_update",n),{error:i.error})},this.onSessionExtendRequest=async(t,i)=>{const{id:n}=i;try{this.isValidExtend({topic:t}),await this.setExpiry(t,re(Ut)),await this.sendResult({id:n,topic:t,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_extend",{id:n,topic:t})}catch(s){await this.sendError({id:n,topic:t,error:s}),this.client.logger.error(s)}},this.onSessionExtendResponse=(t,i)=>{const{id:n}=i,s=U("session_extend",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);Ze(i)?this.events.emit(U("session_extend",n),{}):Be(i)&&this.events.emit(U("session_extend",n),{error:i.error})},this.onSessionPingRequest=async(t,i)=>{const{id:n}=i;try{this.isValidPing({topic:t}),await this.sendResult({id:n,topic:t,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_ping",{id:n,topic:t})}catch(s){await this.sendError({id:n,topic:t,error:s}),this.client.logger.error(s)}},this.onSessionPingResponse=(t,i)=>{const{id:n}=i,s=U("session_ping",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);setTimeout(()=>{Ze(i)?this.events.emit(U("session_ping",n),{}):Be(i)&&this.events.emit(U("session_ping",n),{error:i.error})},500)},this.onSessionDeleteRequest=async(t,i)=>{const{id:n}=i;try{this.isValidDisconnect({topic:t,reason:i.params}),Promise.all([new Promise(s=>{this.client.core.relayer.once(se.publish,async()=>{s(await this.deleteSession({topic:t,id:n}))})}),this.sendResult({id:n,topic:t,result:!0,throwOnFailedPublish:!0}),this.cleanupPendingSentRequestsForTopic({topic:t,error:H("USER_DISCONNECTED")})]).catch(s=>this.client.logger.error(s))}catch(s){this.client.logger.error(s)}},this.onSessionRequest=async t=>{var i,n,s;const{topic:o,payload:a,attestation:l,encryptedId:c,transportType:u}=t,{id:h,params:d}=a;try{await this.isValidRequest(Z({topic:o},d));const f=this.client.session.get(o),p=await this.getVerifyContext({attestationId:l,hash:tt(JSON.stringify(Pt("wc_sessionRequest",d,h))),encryptedId:c,metadata:f.peer.metadata,transportType:u}),g={id:h,topic:o,params:d,verifyContext:p};await this.setPendingSessionRequest(g),u===G.link_mode&&(i=f.peer.metadata.redirect)!=null&&i.universal&&this.client.core.addLinkModeSupportedApp((n=f.peer.metadata.redirect)==null?void 0:n.universal),(s=this.client.signConfig)!=null&&s.disableRequestQueue?this.emitSessionRequest(g):(this.addSessionRequestToSessionRequestQueue(g),this.processSessionRequestQueue())}catch(f){await this.sendError({id:h,topic:o,error:f}),this.client.logger.error(f)}},this.onSessionRequestResponse=(t,i)=>{const{id:n}=i,s=U("session_request",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);Ze(i)?this.events.emit(U("session_request",n),{result:i.result}):Be(i)&&this.events.emit(U("session_request",n),{error:i.error})},this.onSessionEventRequest=async(t,i)=>{const{id:n,params:s}=i;try{const o=`${t}_session_event_${s.event.name}`,a=lr.get(o);if(a&&this.isRequestOutOfSync(a,n)){this.client.logger.info(`Discarding out of sync request - ${n}`);return}this.isValidEmit(Z({topic:t},s)),this.client.events.emit("session_event",{id:n,topic:t,params:s}),lr.set(o,n)}catch(o){await this.sendError({id:n,topic:t,error:o}),this.client.logger.error(o)}},this.onSessionAuthenticateResponse=(t,i)=>{const{id:n}=i;this.client.logger.trace({type:"method",method:"onSessionAuthenticateResponse",topic:t,payload:i}),Ze(i)?this.events.emit(U("session_request",n),{result:i.result}):Be(i)&&this.events.emit(U("session_request",n),{error:i.error})},this.onSessionAuthenticateRequest=async t=>{var i;const{topic:n,payload:s,attestation:o,encryptedId:a,transportType:l}=t;try{const{requester:c,authPayload:u,expiryTimestamp:h}=s.params,d=await this.getVerifyContext({attestationId:o,hash:tt(JSON.stringify(s)),encryptedId:a,metadata:c.metadata,transportType:l}),f={requester:c,pairingTopic:n,id:s.id,authPayload:u,verifyContext:d,expiryTimestamp:h};await this.setAuthRequest(s.id,{request:f,pairingTopic:n,transportType:l}),l===G.link_mode&&(i=c.metadata.redirect)!=null&&i.universal&&this.client.core.addLinkModeSupportedApp(c.metadata.redirect.universal),this.client.events.emit("session_authenticate",{topic:n,params:s.params,id:s.id,verifyContext:d})}catch(c){this.client.logger.error(c);const u=s.params.requester.publicKey,h=await this.client.core.crypto.generateKeyPair(),d=this.getAppLinkIfEnabled(s.params.requester.metadata,l),f={type:nt,receiverPublicKey:u,senderPublicKey:h};await this.sendError({id:s.id,topic:n,error:c,encodeOpts:f,rpcOpts:ie.wc_sessionAuthenticate.autoReject,appLink:d})}},this.addSessionRequestToSessionRequestQueue=t=>{this.sessionRequestQueue.queue.push(t)},this.cleanupAfterResponse=t=>{this.deletePendingSessionRequest(t.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=We.idle,this.processSessionRequestQueue()},S.toMiliseconds(this.requestQueueDelay))},this.cleanupPendingSentRequestsForTopic=({topic:t,error:i})=>{const n=this.client.core.history.pending;n.length>0&&n.filter(s=>s.topic===t&&s.request.method==="wc_sessionRequest").forEach(s=>{const o=s.request.id,a=U("session_request",o);if(this.events.listenerCount(a)===0)throw new Error(`emitting ${a} without any listeners`);this.events.emit(U("session_request",s.request.id),{error:i})})},this.processSessionRequestQueue=()=>{if(this.sessionRequestQueue.state===We.active){this.client.logger.info("session request queue is already active.");return}const t=this.sessionRequestQueue.queue[0];if(!t){this.client.logger.info("session request queue is empty.");return}try{this.sessionRequestQueue.state=We.active,this.emitSessionRequest(t)}catch(i){this.client.logger.error(i)}},this.emitSessionRequest=t=>{this.client.events.emit("session_request",t)},this.onPairingCreated=t=>{if(t.methods&&this.expectedPairingMethodMap.set(t.topic,t.methods),t.active)return;const i=this.client.proposal.getAll().find(n=>n.pairingTopic===t.topic);i&&this.onSessionProposeRequest({topic:t.topic,payload:Pt("wc_sessionPropose",{requiredNamespaces:i.requiredNamespaces,optionalNamespaces:i.optionalNamespaces,relays:i.relays,proposer:i.proposer,sessionProperties:i.sessionProperties},i.id)})},this.isValidConnect=async t=>{if(!me(t)){const{message:l}=P("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(t)}`);throw new Error(l)}const{pairingTopic:i,requiredNamespaces:n,optionalNamespaces:s,sessionProperties:o,relays:a}=t;if(fe(i)||await this.isValidPairingTopic(i),!Am(a)){const{message:l}=P("MISSING_OR_INVALID",`connect() relays: ${a}`);throw new Error(l)}!fe(n)&&li(n)!==0&&this.validateNamespaces(n,"requiredNamespaces"),!fe(s)&&li(s)!==0&&this.validateNamespaces(s,"optionalNamespaces"),fe(o)||this.validateSessionProps(o,"sessionProperties")},this.validateNamespaces=(t,i)=>{const n=Pm(t,"connect()",i);if(n)throw new Error(n.message)},this.isValidApprove=async t=>{if(!me(t))throw new Error(P("MISSING_OR_INVALID",`approve() params: ${t}`).message);const{id:i,namespaces:n,relayProtocol:s,sessionProperties:o}=t;this.checkRecentlyDeleted(i),await this.isValidProposalId(i);const a=this.client.proposal.get(i),l=Ji(n,"approve()");if(l)throw new Error(l.message);const c=Lo(a.requiredNamespaces,n,"approve()");if(c)throw new Error(c.message);if(!ee(s,!0)){const{message:u}=P("MISSING_OR_INVALID",`approve() relayProtocol: ${s}`);throw new Error(u)}fe(o)||this.validateSessionProps(o,"sessionProperties")},this.isValidReject=async t=>{if(!me(t)){const{message:s}=P("MISSING_OR_INVALID",`reject() params: ${t}`);throw new Error(s)}const{id:i,reason:n}=t;if(this.checkRecentlyDeleted(i),await this.isValidProposalId(i),!Rm(n)){const{message:s}=P("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(n)}`);throw new Error(s)}},this.isValidSessionSettleRequest=t=>{if(!me(t)){const{message:c}=P("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${t}`);throw new Error(c)}const{relay:i,controller:n,namespaces:s,expiry:o}=t;if(!Ll(i)){const{message:c}=P("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(c)}const a=_m(n,"onSessionSettleRequest()");if(a)throw new Error(a.message);const l=Ji(s,"onSessionSettleRequest()");if(l)throw new Error(l.message);if(lt(o)){const{message:c}=P("EXPIRED","onSessionSettleRequest()");throw new Error(c)}},this.isValidUpdate=async t=>{if(!me(t)){const{message:l}=P("MISSING_OR_INVALID",`update() params: ${t}`);throw new Error(l)}const{topic:i,namespaces:n}=t;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);const s=this.client.session.get(i),o=Ji(n,"update()");if(o)throw new Error(o.message);const a=Lo(s.requiredNamespaces,n,"update()");if(a)throw new Error(a.message)},this.isValidExtend=async t=>{if(!me(t)){const{message:n}=P("MISSING_OR_INVALID",`extend() params: ${t}`);throw new Error(n)}const{topic:i}=t;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i)},this.isValidRequest=async t=>{if(!me(t)){const{message:l}=P("MISSING_OR_INVALID",`request() params: ${t}`);throw new Error(l)}const{topic:i,request:n,chainId:s,expiry:o}=t;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);const{namespaces:a}=this.client.session.get(i);if(!Mo(a,s)){const{message:l}=P("MISSING_OR_INVALID",`request() chainId: ${s}`);throw new Error(l)}if(!Nm(n)){const{message:l}=P("MISSING_OR_INVALID",`request() ${JSON.stringify(n)}`);throw new Error(l)}if(!Cm(a,s,n.method)){const{message:l}=P("MISSING_OR_INVALID",`request() method: ${n.method}`);throw new Error(l)}if(o&&!Dm(o,Zi)){const{message:l}=P("MISSING_OR_INVALID",`request() expiry: ${o}. Expiry must be a number (in seconds) between ${Zi.min} and ${Zi.max}`);throw new Error(l)}},this.isValidRespond=async t=>{var i;if(!me(t)){const{message:o}=P("MISSING_OR_INVALID",`respond() params: ${t}`);throw new Error(o)}const{topic:n,response:s}=t;try{await this.isValidSessionTopic(n)}catch(o){throw(i=t==null?void 0:t.response)!=null&&i.id&&this.cleanupAfterResponse(t),o}if(!$m(s)){const{message:o}=P("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(s)}`);throw new Error(o)}},this.isValidPing=async t=>{if(!me(t)){const{message:n}=P("MISSING_OR_INVALID",`ping() params: ${t}`);throw new Error(n)}const{topic:i}=t;await this.isValidSessionOrPairingTopic(i)},this.isValidEmit=async t=>{if(!me(t)){const{message:a}=P("MISSING_OR_INVALID",`emit() params: ${t}`);throw new Error(a)}const{topic:i,event:n,chainId:s}=t;await this.isValidSessionTopic(i);const{namespaces:o}=this.client.session.get(i);if(!Mo(o,s)){const{message:a}=P("MISSING_OR_INVALID",`emit() chainId: ${s}`);throw new Error(a)}if(!Om(n)){const{message:a}=P("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(a)}if(!km(o,s,n.name)){const{message:a}=P("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(a)}},this.isValidDisconnect=async t=>{if(!me(t)){const{message:n}=P("MISSING_OR_INVALID",`disconnect() params: ${t}`);throw new Error(n)}const{topic:i}=t;await this.isValidSessionOrPairingTopic(i)},this.isValidAuthenticate=t=>{const{chains:i,uri:n,domain:s,nonce:o}=t;if(!Array.isArray(i)||i.length===0)throw new Error("chains is required and must be a non-empty array");if(!ee(n,!1))throw new Error("uri is required parameter");if(!ee(s,!1))throw new Error("domain is required parameter");if(!ee(o,!1))throw new Error("nonce is required parameter");if([...new Set(i.map(l=>Jr(l).namespace))].length>1)throw new Error("Multi-namespace requests are not supported. Please request single namespace only.");const{namespace:a}=Jr(i[0]);if(a!=="eip155")throw new Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains.")},this.getVerifyContext=async t=>{const{attestationId:i,hash:n,encryptedId:s,metadata:o,transportType:a}=t,l={verified:{verifyUrl:o.verifyUrl||wr,validation:"UNKNOWN",origin:o.url||""}};try{if(a===G.link_mode){const u=this.getAppLinkIfEnabled(o,a);return l.verified.validation=u&&new URL(u).origin===new URL(o.url).origin?"VALID":"INVALID",l}const c=await this.client.core.verify.resolve({attestationId:i,hash:n,encryptedId:s,verifyUrl:o.verifyUrl});c&&(l.verified.origin=c.origin,l.verified.isScam=c.isScam,l.verified.validation=c.origin===new URL(o.url).origin?"VALID":"INVALID")}catch(c){this.client.logger.warn(c)}return this.client.logger.debug(`Verify context: ${JSON.stringify(l)}`),l},this.validateSessionProps=(t,i)=>{Object.values(t).forEach(n=>{if(!ee(n,!1)){const{message:s}=P("MISSING_OR_INVALID",`${i} must be in Record<string, string> format. Received: ${JSON.stringify(n)}`);throw new Error(s)}})},this.getPendingAuthRequest=t=>{const i=this.client.auth.requests.get(t);return typeof i=="object"?i:void 0},this.addToRecentlyDeleted=(t,i)=>{if(this.recentlyDeletedMap.set(t,i),this.recentlyDeletedMap.size>=this.recentlyDeletedLimit){let n=0;const s=this.recentlyDeletedLimit/2;for(const o of this.recentlyDeletedMap.keys()){if(n++>=s)break;this.recentlyDeletedMap.delete(o)}}},this.checkRecentlyDeleted=t=>{const i=this.recentlyDeletedMap.get(t);if(i){const{message:n}=P("MISSING_OR_INVALID",`Record was recently deleted - ${i}: ${t}`);throw new Error(n)}},this.isLinkModeEnabled=(t,i)=>{var n,s,o,a,l,c,u,h,d;return!t||i!==G.link_mode?!1:((s=(n=this.client.metadata)==null?void 0:n.redirect)==null?void 0:s.linkMode)===!0&&((a=(o=this.client.metadata)==null?void 0:o.redirect)==null?void 0:a.universal)!==void 0&&((c=(l=this.client.metadata)==null?void 0:l.redirect)==null?void 0:c.universal)!==""&&((u=t==null?void 0:t.redirect)==null?void 0:u.universal)!==void 0&&((h=t==null?void 0:t.redirect)==null?void 0:h.universal)!==""&&((d=t==null?void 0:t.redirect)==null?void 0:d.linkMode)===!0&&this.client.core.linkModeSupportedApps.includes(t.redirect.universal)&&typeof(R.global==null?void 0:R.global.Linking)<"u"},this.getAppLinkIfEnabled=(t,i)=>{var n;return this.isLinkModeEnabled(t,i)?(n=t==null?void 0:t.redirect)==null?void 0:n.universal:void 0},this.handleLinkModeMessage=({url:t})=>{if(!t||!t.includes("wc_ev")||!t.includes("topic"))return;const i=ro(t,"topic")||"",n=decodeURIComponent(ro(t,"wc_ev")||""),s=this.client.session.keys.includes(i);s&&this.client.session.update(i,{transportType:G.link_mode}),this.client.core.dispatchEnvelope({topic:i,message:n,sessionExists:s})},this.registerLinkModeListeners=async()=>{var t;if(rs()||wt()&&(t=this.client.metadata.redirect)!=null&&t.linkMode){const i=R.global==null?void 0:R.global.Linking;if(typeof i<"u"){i.addEventListener("url",this.handleLinkModeMessage,this.client.name);const n=await i.getInitialURL();n&&setTimeout(()=>{this.handleLinkModeMessage({url:n})},50)}}}}isInitialized(){if(!this.initialized){const{message:e}=P("NOT_INITIALIZED",this.name);throw new Error(e)}}async confirmOnlineStateOrThrow(){await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(se.message,e=>{!this.initialized||this.relayMessageCache.length>0?this.relayMessageCache.push(e):this.onRelayMessage(e)})}async onRelayMessage(e){const{topic:t,message:i,attestation:n,transportType:s}=e,{publicKey:o}=this.client.auth.authKeys.keys.includes(Qr)?this.client.auth.authKeys.get(Qr):{publicKey:void 0},a=await this.client.core.crypto.decode(t,i,{receiverPublicKey:o,encoding:s===G.link_mode?cr:dt});try{Rn(a)?(this.client.core.history.set(t,a),this.onRelayEventRequest({topic:t,payload:a,attestation:n,transportType:s,encryptedId:tt(i)})):hi(a)?(await this.client.core.history.resolve(a),await this.onRelayEventResponse({topic:t,payload:a,transportType:s}),this.client.core.history.delete(t,a.id)):this.onRelayEventUnknownPayload({topic:t,payload:a,transportType:s})}catch(l){this.client.logger.error(l)}}registerExpirerEvents(){this.client.core.expirer.on(Ne.expired,async e=>{const{topic:t,id:i}=ul(e.target);if(i&&this.client.pendingRequest.keys.includes(i))return await this.deletePendingSessionRequest(i,P("EXPIRED"),!0);if(i&&this.client.auth.requests.keys.includes(i))return await this.deletePendingAuthRequest(i,P("EXPIRED"),!0);t?this.client.session.keys.includes(t)&&(await this.deleteSession({topic:t,expirerHasDeleted:!0}),this.client.events.emit("session_expire",{topic:t})):i&&(await this.deleteProposal(i,!0),this.client.events.emit("proposal_expire",{id:i}))})}registerPairingEvents(){this.client.core.pairing.events.on(St.create,e=>this.onPairingCreated(e)),this.client.core.pairing.events.on(St.delete,e=>{this.addToRecentlyDeleted(e.topic,"pairing")})}isValidPairingTopic(e){if(!ee(e,!1)){const{message:t}=P("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}=P("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(t)}if(lt(this.client.core.pairing.pairings.get(e).expiry)){const{message:t}=P("EXPIRED",`pairing topic: ${e}`);throw new Error(t)}}async isValidSessionTopic(e){if(!ee(e,!1)){const{message:t}=P("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw new Error(t)}if(this.checkRecentlyDeleted(e),!this.client.session.keys.includes(e)){const{message:t}=P("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(t)}if(lt(this.client.session.get(e).expiry)){await this.deleteSession({topic:e});const{message:t}=P("EXPIRED",`session topic: ${e}`);throw new Error(t)}if(!this.client.core.crypto.keychain.has(e)){const{message:t}=P("MISSING_OR_INVALID",`session topic does not exist in keychain: ${e}`);throw await this.deleteSession({topic:e}),new Error(t)}}async isValidSessionOrPairingTopic(e){if(this.checkRecentlyDeleted(e),this.client.session.keys.includes(e))await this.isValidSessionTopic(e);else if(this.client.core.pairing.pairings.keys.includes(e))this.isValidPairingTopic(e);else if(ee(e,!1)){const{message:t}=P("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(t)}else{const{message:t}=P("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(t)}}async isValidProposalId(e){if(!Tm(e)){const{message:t}=P("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(t)}if(!this.client.proposal.keys.includes(e)){const{message:t}=P("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(t)}if(lt(this.client.proposal.get(e).expiryTimestamp)){await this.deleteProposal(e);const{message:t}=P("EXPIRED",`proposal id: ${e}`);throw new Error(t)}}}class f1 extends Dt{constructor(e,t){super(e,t,Yw,us),this.core=e,this.logger=t}}class p1 extends Dt{constructor(e,t){super(e,t,Xw,us),this.core=e,this.logger=t}}class g1 extends Dt{constructor(e,t){super(e,t,e1,us,i=>i.id),this.core=e,this.logger=t}}class y1 extends Dt{constructor(e,t){super(e,t,n1,Ai,()=>Qr),this.core=e,this.logger=t}}class m1 extends Dt{constructor(e,t){super(e,t,s1,Ai),this.core=e,this.logger=t}}class v1 extends Dt{constructor(e,t){super(e,t,o1,Ai,i=>i.id),this.core=e,this.logger=t}}class w1{constructor(e,t){this.core=e,this.logger=t,this.authKeys=new y1(this.core,this.logger),this.pairingTopics=new m1(this.core,this.logger),this.requests=new v1(this.core,this.logger)}async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init()}}class hs extends Jw{constructor(e){super(e),this.protocol=eu,this.version=tu,this.name=Xi.name,this.events=new Ge.EventEmitter,this.on=(i,n)=>this.events.on(i,n),this.once=(i,n)=>this.events.once(i,n),this.off=(i,n)=>this.events.off(i,n),this.removeListener=(i,n)=>this.events.removeListener(i,n),this.removeAllListeners=i=>this.events.removeAllListeners(i),this.connect=async i=>{try{return await this.engine.connect(i)}catch(n){throw this.logger.error(n.message),n}},this.pair=async i=>{try{return await this.engine.pair(i)}catch(n){throw this.logger.error(n.message),n}},this.approve=async i=>{try{return await this.engine.approve(i)}catch(n){throw this.logger.error(n.message),n}},this.reject=async i=>{try{return await this.engine.reject(i)}catch(n){throw this.logger.error(n.message),n}},this.update=async i=>{try{return await this.engine.update(i)}catch(n){throw this.logger.error(n.message),n}},this.extend=async i=>{try{return await this.engine.extend(i)}catch(n){throw this.logger.error(n.message),n}},this.request=async i=>{try{return await this.engine.request(i)}catch(n){throw this.logger.error(n.message),n}},this.respond=async i=>{try{return await this.engine.respond(i)}catch(n){throw this.logger.error(n.message),n}},this.ping=async i=>{try{return await this.engine.ping(i)}catch(n){throw this.logger.error(n.message),n}},this.emit=async i=>{try{return await this.engine.emit(i)}catch(n){throw this.logger.error(n.message),n}},this.disconnect=async i=>{try{return await this.engine.disconnect(i)}catch(n){throw this.logger.error(n.message),n}},this.find=i=>{try{return this.engine.find(i)}catch(n){throw this.logger.error(n.message),n}},this.getPendingSessionRequests=()=>{try{return this.engine.getPendingSessionRequests()}catch(i){throw this.logger.error(i.message),i}},this.authenticate=async(i,n)=>{try{return await this.engine.authenticate(i,n)}catch(s){throw this.logger.error(s.message),s}},this.formatAuthMessage=i=>{try{return this.engine.formatAuthMessage(i)}catch(n){throw this.logger.error(n.message),n}},this.approveSessionAuthenticate=async i=>{try{return await this.engine.approveSessionAuthenticate(i)}catch(n){throw this.logger.error(n.message),n}},this.rejectSessionAuthenticate=async i=>{try{return await this.engine.rejectSessionAuthenticate(i)}catch(n){throw this.logger.error(n.message),n}},this.name=(e==null?void 0:e.name)||Xi.name,this.metadata=(e==null?void 0:e.metadata)||sl(),this.signConfig=e==null?void 0:e.signConfig;const t=typeof(e==null?void 0:e.logger)<"u"&&typeof(e==null?void 0:e.logger)!="string"?e.logger:ba(Tn({level:(e==null?void 0:e.logger)||Xi.logger}));this.core=(e==null?void 0:e.core)||new Hw(e),this.logger=ge(t,this.name),this.session=new p1(this.core,this.logger),this.proposal=new f1(this.core,this.logger),this.pendingRequest=new g1(this.core,this.logger),this.engine=new d1(this),this.auth=new w1(this.core,this.logger)}static async init(e){const t=new hs(e);return await t.initialize(),t}get context(){return Ie(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.auth.init(),await this.engine.init(),this.logger.info("SignClient Initialization Success"),setTimeout(()=>{this.engine.processRelayMessageCache()},S.toMiliseconds(S.ONE_SECOND))}catch(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}}function _1(r){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),t=0;t<e.length;t++)e[t]=255;for(var i=0;i<r.length;i++){var n=r.charAt(i),s=n.charCodeAt(0);if(e[s]!==255)throw new TypeError(n+" is ambiguous");e[s]=i}var o=r.length,a=r.charAt(0),l=Math.log(o)/Math.log(256),c=Math.log(256)/Math.log(o);function u(f){if(f instanceof Uint8Array||(ArrayBuffer.isView(f)?f=new Uint8Array(f.buffer,f.byteOffset,f.byteLength):Array.isArray(f)&&(f=Uint8Array.from(f))),!(f instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(f.length===0)return"";for(var p=0,g=0,y=0,m=f.length;y!==m&&f[y]===0;)y++,p++;for(var v=(m-y)*c+1>>>0,_=new Uint8Array(v);y!==m;){for(var w=f[y],b=0,E=v-1;(w!==0||b<g)&&E!==-1;E--,b++)w+=256*_[E]>>>0,_[E]=w%o>>>0,w=w/o>>>0;if(w!==0)throw new Error("Non-zero carry");g=b,y++}for(var I=v-g;I!==v&&_[I]===0;)I++;for(var x=a.repeat(p);I<v;++I)x+=r.charAt(_[I]);return x}function h(f){if(typeof f!="string")throw new TypeError("Expected String");if(f.length===0)return new Uint8Array;for(var p=0,g=0,y=0;f[p]===a;)g++,p++;for(var m=(f.length-p)*l+1>>>0,v=new Uint8Array(m);f[p];){var _=e[f.charCodeAt(p)];if(_===255)return;for(var w=0,b=m-1;(_!==0||w<y)&&b!==-1;b--,w++)_+=o*v[b]>>>0,v[b]=_%256>>>0,_=_/256>>>0;if(_!==0)throw new Error("Non-zero carry");y=w,p++}for(var E=m-y;E!==m&&v[E]===0;)E++;for(var I=new Uint8Array(g+(m-E)),x=g;E!==m;)I[x++]=v[E++];return I}function d(f){var p=h(f);if(p)return p;throw new Error("Non-base"+o+" character")}return{encode:u,decodeUnsafe:h,decode:d}}var b1=_1;const E1=b1,I1="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";var S1=E1(I1);const en=wa(S1);class xt extends Error{constructor(){super(),Object.setPrototypeOf(this,xt.prototype)}}class ds extends Error{constructor(){super(),Object.setPrototypeOf(this,ds.prototype)}}var ya;(function(r){r.Mainnet="solana:4sGjMW1sUnHzSxGspuhpqLDx6wiyjNtZ",r.Devnet="solana:8E9rvCKLFQia2Y35HXjjpWzj8weVo44K"})(ya||(ya={}));var Xt;(function(r){r.signTransaction="solana_signTransaction",r.signMessage="solana_signMessage"})(Xt||(Xt={}));const ma=r=>({requiredNamespaces:{solana:{chains:[r],methods:[Xt.signTransaction,Xt.signMessage],events:[]}}}),x1=r=>"version"in r;class V1{constructor(e){this._options=e.options,this._network=e.network}async connect(){const e=this._client??await hs.init(this._options),t=e.find(ma(this._network)).filter(i=>i.acknowledged);if(t.length)return this._session=t[t.length-1],this._client=e,{publicKey:this.publicKey};{const{uri:i,approval:n}=await e.connect(ma(this._network));return new Promise((s,o)=>{i&&Hs.open(i,()=>{o(new ds)}),n().then(a=>{this._session=a,this._client=e,s({publicKey:this.publicKey})}).catch(o).finally(()=>{Hs.close()})})}}async disconnect(){if(this._client&&this._session)await this._client.disconnect({topic:this._session.topic,reason:H("USER_DISCONNECTED")}),this._session=void 0;else throw new xt}get client(){if(this._client)return Object.assign({},this._client,{off:this._client.removeListener});throw new xt}get publicKey(){if(this._client&&this._session){const{address:e}=Kp(this._session.namespaces.solana.accounts[0]);return new au(e)}else throw new xt}async signTransaction(e){if(this._client&&this._session){let t,i;x1(e)?(t=R.Buffer.from(e.serialize()).toString("base64"),e.version==="legacy"&&(i=cu.from(e.serialize()))):(t=e.serialize({requireAllSignatures:!1,verifySignatures:!1}).toString("base64"),i=e);const{signature:n}=await this._client.request({chainId:this._network,topic:this._session.topic,request:{method:Xt.signTransaction,params:{...i,transaction:t}}});return e.addSignature(this.publicKey,R.Buffer.from(en.decode(n))),e}else throw new xt}async signMessage(e){if(this._client&&this._session){const{signature:t}=await this._client.request({chainId:this._network,topic:this._session.topic,request:{method:Xt.signMessage,params:{pubkey:this.publicKey.toString(),message:en.encode(e)}}});return en.decode(t)}else throw new xt}}export{xt as ClientNotInitializedError,ds as QRCodeModalError,ya as WalletConnectChainID,hs as WalletConnectClient,Xt as WalletConnectRPCMethods,V1 as WalletConnectWallet};