@dev.sail.money/sailor 0.0.2-19 → 0.0.2-20

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 (172) hide show
  1. package/package.json +1 -1
  2. package/packages/cli/dist/index.cjs +14 -14
  3. package/packages/cli/dist/server.cjs +139 -948
  4. package/packages/sdk/dist/intelligence.d.ts +1 -1
  5. package/packages/sdk/dist/intelligence.js +1 -1
  6. package/packages/ui/dist/assets/Arc-VDBY7LNS-BChRXCXW.js +1 -0
  7. package/packages/ui/dist/assets/Brave-BRAKJXDS-mq-Xo37j.js +1 -0
  8. package/packages/ui/dist/assets/Browser-76IHF3Y2-BMhRaC5Z.js +1 -0
  9. package/packages/ui/dist/assets/Chrome-65Q5P54Y-DR9MQEVr.js +1 -0
  10. package/packages/ui/dist/assets/Edge-XSPUTORV-DEoZslQE.js +1 -0
  11. package/packages/ui/dist/assets/Firefox-AAHGJQIP-Bp_Hm04m.js +1 -0
  12. package/packages/ui/dist/assets/Linux-OO4TNCLJ-B0aw93n9.js +1 -0
  13. package/packages/ui/dist/assets/Macos-MW4AE7LN-Vvm8Drw3.js +1 -0
  14. package/packages/ui/dist/assets/Opera-KQZLSACL-Cwv5MDFy.js +1 -0
  15. package/packages/ui/dist/assets/Safari-ZPL37GXR-C4Ggg6rz.js +1 -0
  16. package/packages/ui/dist/assets/Windows-PPTHQER6-BlyV2p7Y.js +1 -0
  17. package/packages/ui/dist/assets/add-BrylwREe.js +15 -0
  18. package/packages/ui/dist/assets/all-wallets-DGR35dSU.js +6 -0
  19. package/packages/ui/dist/assets/apechain-SX5YFU6N-q5qBv-mp.js +1 -0
  20. package/packages/ui/dist/assets/app-store-BpM1x6bI.js +17 -0
  21. package/packages/ui/dist/assets/apple-xvs7JX23.js +18 -0
  22. package/packages/ui/dist/assets/ar_AR-LIPSOZP5-BQrIDibT.js +1519 -0
  23. package/packages/ui/dist/assets/arbitrum-WURIBY6W-CqVkHBr5.js +1 -0
  24. package/packages/ui/dist/assets/arrow-bottom-CF6xPQbH.js +8 -0
  25. package/packages/ui/dist/assets/arrow-bottom-circle-r0A6jlRF.js +11 -0
  26. package/packages/ui/dist/assets/arrow-left-Ce6MJKC0.js +8 -0
  27. package/packages/ui/dist/assets/arrow-right-CiCNIsI0.js +8 -0
  28. package/packages/ui/dist/assets/arrow-top-TI5RQSIc.js +8 -0
  29. package/packages/ui/dist/assets/assets-Q6ZU7ZJ5-P8HioiAD.js +1 -0
  30. package/packages/ui/dist/assets/avalanche-KOMJD3XY-Dsn_JPR4.js +1 -0
  31. package/packages/ui/dist/assets/bank-CmrK2TRa.js +14 -0
  32. package/packages/ui/dist/assets/base-OAXLRA4F-CoYTVIiL.js +1 -0
  33. package/packages/ui/dist/assets/base-QS6CYWIN-CsjdbWCf.js +1 -0
  34. package/packages/ui/dist/assets/basic-BhoXad_6.js +2128 -0
  35. package/packages/ui/dist/assets/berachain-NJECWIVC-DumxnFvf.js +1 -0
  36. package/packages/ui/dist/assets/blast-V555OVXZ-BbhJh1tj.js +1 -0
  37. package/packages/ui/dist/assets/browser-BWCT-XSy.js +14 -0
  38. package/packages/ui/dist/assets/bsc-N647EYR2-B2nLKXWV.js +1 -0
  39. package/packages/ui/dist/assets/card-v1fl0QNj.js +14 -0
  40. package/packages/ui/dist/assets/ccip-BkGqsEgG.js +1 -0
  41. package/packages/ui/dist/assets/celo-GEP4TUHG-CenIBYLU.js +1 -0
  42. package/packages/ui/dist/assets/checkmark-CiQnNFee.js +11 -0
  43. package/packages/ui/dist/assets/checkmark-bold-B63f9SW6.js +8 -0
  44. package/packages/ui/dist/assets/chevron-bottom-DpBpDiYb.js +8 -0
  45. package/packages/ui/dist/assets/chevron-left-o_G-ctyg.js +8 -0
  46. package/packages/ui/dist/assets/chevron-right-I9LAJ9De.js +8 -0
  47. package/packages/ui/dist/assets/chevron-top-JRwGHMKH.js +8 -0
  48. package/packages/ui/dist/assets/chrome-store-Cw9skzSt.js +61 -0
  49. package/packages/ui/dist/assets/clock-BK_Lu0EB.js +8 -0
  50. package/packages/ui/dist/assets/close-DWFjOyu7.js +8 -0
  51. package/packages/ui/dist/assets/coinPlaceholder-gi3wDlPb.js +8 -0
  52. package/packages/ui/dist/assets/compass-Dlpsn_k-.js +8 -0
  53. package/packages/ui/dist/assets/connect-UA7M4XW6-IY3X6Bmr.js +1 -0
  54. package/packages/ui/dist/assets/copy-BzNKdXeG.js +15 -0
  55. package/packages/ui/dist/assets/core-BN9UnMip.js +907 -0
  56. package/packages/ui/dist/assets/create-FASO7PVG-D_rvSpre.js +1 -0
  57. package/packages/ui/dist/assets/cronos-HJPAQTAE-BEOvlOC4.js +1 -0
  58. package/packages/ui/dist/assets/cursor-BWdjWDLC.js +3 -0
  59. package/packages/ui/dist/assets/cursor-transparent-B3RZ6Udt.js +12 -0
  60. package/packages/ui/dist/assets/de_DE-YE3KOFHU-BRt5ztUe.js +1519 -0
  61. package/packages/ui/dist/assets/degen-FQQ4XGHB-CeHTs88l.js +1 -0
  62. package/packages/ui/dist/assets/desktop-rngwE1T9.js +9 -0
  63. package/packages/ui/dist/assets/disconnect-_DzDsvsZ.js +8 -0
  64. package/packages/ui/dist/assets/discord-B9qQB66m.js +17 -0
  65. package/packages/ui/dist/assets/es_419-7LMPU7G4-DH7rM0yQ.js +1519 -0
  66. package/packages/ui/dist/assets/ethereum-RGGVA4PY-SWGOlkuk.js +1 -0
  67. package/packages/ui/dist/assets/etherscan-D7hlQ8Z3.js +6 -0
  68. package/packages/ui/dist/assets/events-DrkgavVp.js +1 -0
  69. package/packages/ui/dist/assets/exclamation-triangle-iCvLVoM-.js +4 -0
  70. package/packages/ui/dist/assets/extension-CjGcOeuB.js +8 -0
  71. package/packages/ui/dist/assets/external-link-DTkyjOr4.js +8 -0
  72. package/packages/ui/dist/assets/facebook-DoO2uCiE.js +26 -0
  73. package/packages/ui/dist/assets/fallback-Y8-BiCNG.js +1 -0
  74. package/packages/ui/dist/assets/farcaster-Dyz6wiZi.js +12 -0
  75. package/packages/ui/dist/assets/filters-Bd5PxMiz.js +8 -0
  76. package/packages/ui/dist/assets/flow-5FQJFCTK-CUie2reO.js +1 -0
  77. package/packages/ui/dist/assets/fr_FR-VBJP3ZLL-B-_ocunw.js +1519 -0
  78. package/packages/ui/dist/assets/github-CmqSJCq6.js +18 -0
  79. package/packages/ui/dist/assets/gnosis-37ZC4RBL-B137OtHZ.js +1 -0
  80. package/packages/ui/dist/assets/google-i_MKKqQP.js +18 -0
  81. package/packages/ui/dist/assets/gravity-J5YQHTYH-Bj6B0uod.js +1 -0
  82. package/packages/ui/dist/assets/hardhat-TX56IT5N-CV1FY-wE.js +1 -0
  83. package/packages/ui/dist/assets/help-circle-_ER8-V35.js +12 -0
  84. package/packages/ui/dist/assets/hi_IN-WBVD5XYI-D73g2UFs.js +1519 -0
  85. package/packages/ui/dist/assets/hyperevm-VKPAA4SA-CHwraEsx.js +1 -0
  86. package/packages/ui/dist/assets/id-D2adRwvh.js +12 -0
  87. package/packages/ui/dist/assets/id_ID-SBYANJ7G-Cjpa4ay6.js +1519 -0
  88. package/packages/ui/dist/assets/image-q_rpi7cn.js +4 -0
  89. package/packages/ui/dist/assets/index-B6Wb3mjQ.js +1 -0
  90. package/packages/ui/dist/assets/index-BLD08Nrb.js +1 -0
  91. package/packages/ui/dist/assets/index-Bdl623mb.js +395 -0
  92. package/packages/ui/dist/assets/index-BwoSt5mL.js +1 -0
  93. package/packages/ui/dist/assets/index-CzevBC-K.js +16 -0
  94. package/packages/ui/dist/assets/index-DDKDa0s2.css +1 -0
  95. package/packages/ui/dist/assets/index-DJQDBPts.js +1775 -0
  96. package/packages/ui/dist/assets/index.es-D6UPoR2j.js +26 -0
  97. package/packages/ui/dist/assets/info-Ck7GYYmo.js +3 -0
  98. package/packages/ui/dist/assets/info-circle-DtA5FQXd.js +12 -0
  99. package/packages/ui/dist/assets/ink-FZMYZWHG-62p-5IK5.js +1 -0
  100. package/packages/ui/dist/assets/ja_JP-ZRMWJV3I-DXbifiMm.js +1519 -0
  101. package/packages/ui/dist/assets/kaia-65D2U3PU-JmuLQ4gC.js +1 -0
  102. package/packages/ui/dist/assets/ko_KR-FR54RFUG-upinSHjQ.js +1519 -0
  103. package/packages/ui/dist/assets/lightbulb-DR3jyzkK.js +3 -0
  104. package/packages/ui/dist/assets/linea-QRMVQ5DY-DuI3vv0d.js +1 -0
  105. package/packages/ui/dist/assets/login-UP3DZBGS-Db_wM5oQ.js +1 -0
  106. package/packages/ui/dist/assets/mail-BK_pW_tL.js +8 -0
  107. package/packages/ui/dist/assets/manta-SI27YFEJ-CpVOKa06.js +1 -0
  108. package/packages/ui/dist/assets/mantle-CKIUT334-DR2WgqzU.js +1 -0
  109. package/packages/ui/dist/assets/metaMaskWallet-EI6MED72-D5HFOsnz.js +1 -0
  110. package/packages/ui/dist/assets/metamask-sdk-IZbe4GJ_.js +542 -0
  111. package/packages/ui/dist/assets/mobile-CLG-4Yut.js +9 -0
  112. package/packages/ui/dist/assets/monad-4KWC6TSS-DVXSkpiz.js +1 -0
  113. package/packages/ui/dist/assets/more-BBqkkVbe.js +11 -0
  114. package/packages/ui/dist/assets/ms_MY-EZSGYYYQ-4cPLK-3L.js +1519 -0
  115. package/packages/ui/dist/assets/native-CJ5et6AR.js +1 -0
  116. package/packages/ui/dist/assets/network-placeholder-kf7EWfmj.js +14 -0
  117. package/packages/ui/dist/assets/nftPlaceholder-BEFwtFPl.js +8 -0
  118. package/packages/ui/dist/assets/off-DKjJt-l0.js +8 -0
  119. package/packages/ui/dist/assets/optimism-HAF2GUT7-ec6Nqxs9.js +1 -0
  120. package/packages/ui/dist/assets/parseSignature-KWl5TpQf.js +1 -0
  121. package/packages/ui/dist/assets/play-store-DBVkWbwG.js +32 -0
  122. package/packages/ui/dist/assets/plus-BQzagKUL.js +13 -0
  123. package/packages/ui/dist/assets/polygon-WW6ZI7PM-DXlmm4L1.js +1 -0
  124. package/packages/ui/dist/assets/pt_BR-JQFQ3P4L-DOHfdcA2.js +1519 -0
  125. package/packages/ui/dist/assets/qr-code-DVwEgFEM.js +6 -0
  126. package/packages/ui/dist/assets/rainbowWallet-O26YNBMX-DUhYus-9.js +1 -0
  127. package/packages/ui/dist/assets/recycle-horizontal-D2E6B1Kh.js +9 -0
  128. package/packages/ui/dist/assets/refresh-CUavEsqn.js +8 -0
  129. package/packages/ui/dist/assets/refresh-S4T5V5GX-CwqIaaxK.js +1 -0
  130. package/packages/ui/dist/assets/reown-logo-mAAAaf4E.js +12 -0
  131. package/packages/ui/dist/assets/ronin-EMCPYXZT-N-QBHZdV.js +1 -0
  132. package/packages/ui/dist/assets/ru_RU-Z42UEJBP-Cvb2oWxQ.js +1519 -0
  133. package/packages/ui/dist/assets/safeWallet-5MNKTR5Z-D-5imDLD.js +1 -0
  134. package/packages/ui/dist/assets/sanko-RHQYXGM5-OX010CbN.js +1 -0
  135. package/packages/ui/dist/assets/scan-4UYSQ56Q-CjMz6-XC.js +1 -0
  136. package/packages/ui/dist/assets/scroll-5OBGQVOV-DJFECiai.js +1 -0
  137. package/packages/ui/dist/assets/search-BAnb6iT_.js +8 -0
  138. package/packages/ui/dist/assets/secp256k1-CBUZgsE-.js +1 -0
  139. package/packages/ui/dist/assets/send-BYjfitxS.js +15 -0
  140. package/packages/ui/dist/assets/sign-A7IJEUT5-CGsRnPrd.js +1 -0
  141. package/packages/ui/dist/assets/superposition-HG6MMR2Y-bRkgatRO.js +1 -0
  142. package/packages/ui/dist/assets/swapHorizontal-C-4qjxwd.js +8 -0
  143. package/packages/ui/dist/assets/swapHorizontalBold-zA-cWlfT.js +8 -0
  144. package/packages/ui/dist/assets/swapHorizontalMedium-gIIVXh3I.js +16 -0
  145. package/packages/ui/dist/assets/swapHorizontalRoundedBold-CwtQpc9E.js +8 -0
  146. package/packages/ui/dist/assets/swapVertical-wrdYsAkk.js +8 -0
  147. package/packages/ui/dist/assets/telegram-3aqbBSMX.js +16 -0
  148. package/packages/ui/dist/assets/th_TH-4YB4VSB2-BUipNP-V.js +1519 -0
  149. package/packages/ui/dist/assets/three-dots-BNRpZX3L.js +5 -0
  150. package/packages/ui/dist/assets/tr_TR-5FKHPPIO-D5jTpIm9.js +1519 -0
  151. package/packages/ui/dist/assets/twitch-Bya9c1W1.js +18 -0
  152. package/packages/ui/dist/assets/twitterIcon-1thOj_Z5.js +6 -0
  153. package/packages/ui/dist/assets/uk_UA-ZD4IBC52-DgnQrpzl.js +1519 -0
  154. package/packages/ui/dist/assets/unichain-C5BWO2ZY-BfguYsnu.js +1 -0
  155. package/packages/ui/dist/assets/verify-D8ggGSfI.js +8 -0
  156. package/packages/ui/dist/assets/verify-filled-CeZM7920.js +8 -0
  157. package/packages/ui/dist/assets/vi_VN-5EVRZKLY-x078672g.js +1519 -0
  158. package/packages/ui/dist/assets/w3m-modal-CUwD6iiA.js +642 -0
  159. package/packages/ui/dist/assets/wallet-Baz0DeMJ.js +8 -0
  160. package/packages/ui/dist/assets/wallet-placeholder-3yAnyuC4.js +14 -0
  161. package/packages/ui/dist/assets/walletConnectWallet-YHWKVTDY-D3lyiczV.js +1 -0
  162. package/packages/ui/dist/assets/walletconnect-CfkgbqAq.js +30 -0
  163. package/packages/ui/dist/assets/warning-circle-BfOqu3HN.js +12 -0
  164. package/packages/ui/dist/assets/x-CxAcJv-O.js +12 -0
  165. package/packages/ui/dist/assets/xdc-KJ3TDBYO-DNV6zchh.js +1 -0
  166. package/packages/ui/dist/assets/zetachain-TLDS5IPW-Udhyw16T.js +1 -0
  167. package/packages/ui/dist/assets/zh_CN-4XK5YJPR-Bt6Yz5Ek.js +1519 -0
  168. package/packages/ui/dist/assets/zh_HK-N4YN2WSI-Cvzl1V16.js +1519 -0
  169. package/packages/ui/dist/assets/zh_TW-CNCRXH6Z-BNelatfN.js +1519 -0
  170. package/packages/ui/dist/assets/zksync-DH7HK5U4-Dt4usFw6.js +1 -0
  171. package/packages/ui/dist/assets/zora-FYL5H3IO-iB4wygST.js +1 -0
  172. package/packages/ui/dist/index.html +14 -0
@@ -0,0 +1,907 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/basic-BhoXad_6.js","assets/index-Bdl623mb.js","assets/index-DJQDBPts.js","assets/index-DDKDa0s2.css","assets/events-DrkgavVp.js","assets/index.es-D6UPoR2j.js","assets/fallback-Y8-BiCNG.js","assets/w3m-modal-CUwD6iiA.js"])))=>i.map(i=>d[i]);
2
+ import{cF as Xh,db as qi,fV as na,bk as oa}from"./index-DJQDBPts.js";import{e as Ys,N as qo}from"./events-DrkgavVp.js";import{I as qr,v as Qh,q as St,W as ht,g as U,s as Or,C as eu,u as gl,k as tu,t as su,h as ai,U as no,f as ml,N as ru,G as Si,A as wl,E as st,x as iu,w as nu,Y as bt,o as Bs,L as jr,O as jo,J as Pt,l as ou,B as Fo,D as Wo,p as mn,P as aa,Q as au,a as cu,T as lu,S as ca,r as Cr,n as yl,F as ts,z as Wt,K as as,m as Lt}from"./index.es-D6UPoR2j.js";import{f as la}from"./fallback-Y8-BiCNG.js";var ha={};const z={WC_NAME_SUFFIX:".reown.id",WC_NAME_SUFFIX_LEGACY:".wcn.id",BLOCKCHAIN_API_RPC_URL:"https://rpc.walletconnect.org",PULSE_API_URL:"https://pulse.walletconnect.org",W3M_API_URL:"https://api.web3modal.org",CONNECTOR_ID:{WALLET_CONNECT:"walletConnect",INJECTED:"injected",WALLET_STANDARD:"announced",COINBASE:"coinbaseWallet",COINBASE_SDK:"coinbaseWalletSDK",SAFE:"safe",LEDGER:"ledger",OKX:"okx",EIP6963:"eip6963",AUTH:"ID_AUTH"},CONNECTOR_NAMES:{AUTH:"Auth"},AUTH_CONNECTOR_SUPPORTED_CHAINS:["eip155","solana"],LIMITS:{PENDING_TRANSACTIONS:99},CHAIN:{EVM:"eip155",SOLANA:"solana",POLKADOT:"polkadot",BITCOIN:"bip122"},CHAIN_NAME_MAP:{eip155:"EVM Networks",solana:"Solana",polkadot:"Polkadot",bip122:"Bitcoin",cosmos:"Cosmos"},ADAPTER_TYPES:{BITCOIN:"bitcoin",SOLANA:"solana",WAGMI:"wagmi",ETHERS:"ethers",ETHERS5:"ethers5"},USDT_CONTRACT_ADDRESSES:["0xdac17f958d2ee523a2206206994597c13d831ec7","0xc2132d05d31c914a87c6611c10748aeb04b58e8f","0x9702230a8ea53601f5cd2dc00fdbc13d4df4a8c7","0x919C1c267BC06a7039e03fcc2eF738525769109c","0x48065fbBE25f71C9282ddf5e1cD6D6A887483D5e","0x55d398326f99059fF775485246999027B3197955","0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9"],HTTP_STATUS_CODES:{SERVICE_UNAVAILABLE:503,FORBIDDEN:403},UNSUPPORTED_NETWORK_NAME:"Unknown Network",SECURE_SITE_SDK_ORIGIN:(typeof process<"u"&&typeof ha<"u"?ha.NEXT_PUBLIC_SECURE_SITE_ORIGIN:void 0)||"https://secure.walletconnect.org"},bl={caipNetworkIdToNumber(t){return t?Number(t.split(":")[1]):void 0},parseEvmChainId(t){return typeof t=="string"?this.caipNetworkIdToNumber(t):t},getNetworksByNamespace(t,e){return(t==null?void 0:t.filter(s=>s.chainNamespace===e))||[]},getFirstNetworkByNamespace(t,e){return this.getNetworksByNamespace(t,e)[0]},getNetworkNameByCaipNetworkId(t,e){var i;if(!e)return;const s=t.find(n=>n.caipNetworkId===e);if(s)return s.name;const[r]=e.split(":");return((i=z.CHAIN_NAME_MAP)==null?void 0:i[r])||void 0}};var hu=20,uu=1,zs=1e6,ua=1e6,du=-7,pu=21,fu=!1,Pi="[big.js] ",Zs=Pi+"Invalid ",wn=Zs+"decimal places",gu=Zs+"rounding mode",vl=Pi+"Division by zero",ge={},Vt=void 0,mu=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function El(){function t(e){var s=this;if(!(s instanceof t))return e===Vt?El():new t(e);if(e instanceof t)s.s=e.s,s.e=e.e,s.c=e.c.slice();else{if(typeof e!="string"){if(t.strict===!0&&typeof e!="bigint")throw TypeError(Zs+"value");e=e===0&&1/e<0?"-0":String(e)}wu(s,e)}s.constructor=t}return t.prototype=ge,t.DP=hu,t.RM=uu,t.NE=du,t.PE=pu,t.strict=fu,t.roundDown=0,t.roundHalfUp=1,t.roundHalfEven=2,t.roundUp=3,t}function wu(t,e){var s,r,i;if(!mu.test(e))throw Error(Zs+"number");for(t.s=e.charAt(0)=="-"?(e=e.slice(1),-1):1,(s=e.indexOf("."))>-1&&(e=e.replace(".","")),(r=e.search(/e/i))>0?(s<0&&(s=r),s+=+e.slice(r+1),e=e.substring(0,r)):s<0&&(s=e.length),i=e.length,r=0;r<i&&e.charAt(r)=="0";)++r;if(r==i)t.c=[t.e=0];else{for(;i>0&&e.charAt(--i)=="0";);for(t.e=s-r-1,t.c=[],s=0;r<=i;)t.c[s++]=+e.charAt(r++)}return t}function Xs(t,e,s,r){var i=t.c;if(s===Vt&&(s=t.constructor.RM),s!==0&&s!==1&&s!==2&&s!==3)throw Error(gu);if(e<1)r=s===3&&(r||!!i[0])||e===0&&(s===1&&i[0]>=5||s===2&&(i[0]>5||i[0]===5&&(r||i[1]!==Vt))),i.length=1,r?(t.e=t.e-e+1,i[0]=1):i[0]=t.e=0;else if(e<i.length){if(r=s===1&&i[e]>=5||s===2&&(i[e]>5||i[e]===5&&(r||i[e+1]!==Vt||i[e-1]&1))||s===3&&(r||!!i[0]),i.length=e,r){for(;++i[--e]>9;)if(i[e]=0,e===0){++t.e,i.unshift(1);break}}for(e=i.length;!i[--e];)i.pop()}return t}function Qs(t,e,s){var r=t.e,i=t.c.join(""),n=i.length;if(e)i=i.charAt(0)+(n>1?"."+i.slice(1):"")+(r<0?"e":"e+")+r;else if(r<0){for(;++r;)i="0"+i;i="0."+i}else if(r>0)if(++r>n)for(r-=n;r--;)i+="0";else r<n&&(i=i.slice(0,r)+"."+i.slice(r));else n>1&&(i=i.charAt(0)+"."+i.slice(1));return t.s<0&&s?"-"+i:i}ge.abs=function(){var t=new this.constructor(this);return t.s=1,t};ge.cmp=function(t){var e,s=this,r=s.c,i=(t=new s.constructor(t)).c,n=s.s,o=t.s,a=s.e,c=t.e;if(!r[0]||!i[0])return r[0]?n:i[0]?-o:0;if(n!=o)return n;if(e=n<0,a!=c)return a>c^e?1:-1;for(o=(a=r.length)<(c=i.length)?a:c,n=-1;++n<o;)if(r[n]!=i[n])return r[n]>i[n]^e?1:-1;return a==c?0:a>c^e?1:-1};ge.div=function(t){var e=this,s=e.constructor,r=e.c,i=(t=new s(t)).c,n=e.s==t.s?1:-1,o=s.DP;if(o!==~~o||o<0||o>zs)throw Error(wn);if(!i[0])throw Error(vl);if(!r[0])return t.s=n,t.c=[t.e=0],t;var a,c,l,h,u,d=i.slice(),g=a=i.length,w=r.length,f=r.slice(0,a),m=f.length,y=t,b=y.c=[],E=0,A=o+(y.e=e.e-t.e)+1;for(y.s=n,n=A<0?0:A,d.unshift(0);m++<a;)f.push(0);do{for(l=0;l<10;l++){if(a!=(m=f.length))h=a>m?1:-1;else for(u=-1,h=0;++u<a;)if(i[u]!=f[u]){h=i[u]>f[u]?1:-1;break}if(h<0){for(c=m==a?i:d;m;){if(f[--m]<c[m]){for(u=m;u&&!f[--u];)f[u]=9;--f[u],f[m]+=10}f[m]-=c[m]}for(;!f[0];)f.shift()}else break}b[E++]=h?l:++l,f[0]&&h?f[m]=r[g]||0:f=[r[g]]}while((g++<w||f[0]!==Vt)&&n--);return!b[0]&&E!=1&&(b.shift(),y.e--,A--),E>A&&Xs(y,A,s.RM,f[0]!==Vt),y};ge.eq=function(t){return this.cmp(t)===0};ge.gt=function(t){return this.cmp(t)>0};ge.gte=function(t){return this.cmp(t)>-1};ge.lt=function(t){return this.cmp(t)<0};ge.lte=function(t){return this.cmp(t)<1};ge.minus=ge.sub=function(t){var e,s,r,i,n=this,o=n.constructor,a=n.s,c=(t=new o(t)).s;if(a!=c)return t.s=-c,n.plus(t);var l=n.c.slice(),h=n.e,u=t.c,d=t.e;if(!l[0]||!u[0])return u[0]?t.s=-c:l[0]?t=new o(n):t.s=1,t;if(a=h-d){for((i=a<0)?(a=-a,r=l):(d=h,r=u),r.reverse(),c=a;c--;)r.push(0);r.reverse()}else for(s=((i=l.length<u.length)?l:u).length,a=c=0;c<s;c++)if(l[c]!=u[c]){i=l[c]<u[c];break}if(i&&(r=l,l=u,u=r,t.s=-t.s),(c=(s=u.length)-(e=l.length))>0)for(;c--;)l[e++]=0;for(c=e;s>a;){if(l[--s]<u[s]){for(e=s;e&&!l[--e];)l[e]=9;--l[e],l[s]+=10}l[s]-=u[s]}for(;l[--c]===0;)l.pop();for(;l[0]===0;)l.shift(),--d;return l[0]||(t.s=1,l=[d=0]),t.c=l,t.e=d,t};ge.mod=function(t){var e,s=this,r=s.constructor,i=s.s,n=(t=new r(t)).s;if(!t.c[0])throw Error(vl);return s.s=t.s=1,e=t.cmp(s)==1,s.s=i,t.s=n,e?new r(s):(i=r.DP,n=r.RM,r.DP=r.RM=0,s=s.div(t),r.DP=i,r.RM=n,this.minus(s.times(t)))};ge.neg=function(){var t=new this.constructor(this);return t.s=-t.s,t};ge.plus=ge.add=function(t){var e,s,r,i=this,n=i.constructor;if(t=new n(t),i.s!=t.s)return t.s=-t.s,i.minus(t);var o=i.e,a=i.c,c=t.e,l=t.c;if(!a[0]||!l[0])return l[0]||(a[0]?t=new n(i):t.s=i.s),t;if(a=a.slice(),e=o-c){for(e>0?(c=o,r=l):(e=-e,r=a),r.reverse();e--;)r.push(0);r.reverse()}for(a.length-l.length<0&&(r=l,l=a,a=r),e=l.length,s=0;e;a[e]%=10)s=(a[--e]=a[e]+l[e]+s)/10|0;for(s&&(a.unshift(s),++c),e=a.length;a[--e]===0;)a.pop();return t.c=a,t.e=c,t};ge.pow=function(t){var e=this,s=new e.constructor("1"),r=s,i=t<0;if(t!==~~t||t<-ua||t>ua)throw Error(Zs+"exponent");for(i&&(t=-t);t&1&&(r=r.times(e)),t>>=1,!!t;)e=e.times(e);return i?s.div(r):r};ge.prec=function(t,e){if(t!==~~t||t<1||t>zs)throw Error(Zs+"precision");return Xs(new this.constructor(this),t,e)};ge.round=function(t,e){if(t===Vt)t=0;else if(t!==~~t||t<-zs||t>zs)throw Error(wn);return Xs(new this.constructor(this),t+this.e+1,e)};ge.sqrt=function(){var t,e,s,r=this,i=r.constructor,n=r.s,o=r.e,a=new i("0.5");if(!r.c[0])return new i(r);if(n<0)throw Error(Pi+"No square root");n=Math.sqrt(+Qs(r,!0,!0)),n===0||n===1/0?(e=r.c.join(""),e.length+o&1||(e+="0"),n=Math.sqrt(e),o=((o+1)/2|0)-(o<0||o&1),t=new i((n==1/0?"5e":(n=n.toExponential()).slice(0,n.indexOf("e")+1))+o)):t=new i(n+""),o=t.e+(i.DP+=4);do s=t,t=a.times(s.plus(r.div(s)));while(s.c.slice(0,o).join("")!==t.c.slice(0,o).join(""));return Xs(t,(i.DP-=4)+t.e+1,i.RM)};ge.times=ge.mul=function(t){var e,s=this,r=s.constructor,i=s.c,n=(t=new r(t)).c,o=i.length,a=n.length,c=s.e,l=t.e;if(t.s=s.s==t.s?1:-1,!i[0]||!n[0])return t.c=[t.e=0],t;for(t.e=c+l,o<a&&(e=i,i=n,n=e,l=o,o=a,a=l),e=new Array(l=o+a);l--;)e[l]=0;for(c=a;c--;){for(a=0,l=o+c;l>c;)a=e[l]+n[c]*i[l-c-1]+a,e[l--]=a%10,a=a/10|0;e[l]=a}for(a?++t.e:e.shift(),c=e.length;!e[--c];)e.pop();return t.c=e,t};ge.toExponential=function(t,e){var s=this,r=s.c[0];if(t!==Vt){if(t!==~~t||t<0||t>zs)throw Error(wn);for(s=Xs(new s.constructor(s),++t,e);s.c.length<t;)s.c.push(0)}return Qs(s,!0,!!r)};ge.toFixed=function(t,e){var s=this,r=s.c[0];if(t!==Vt){if(t!==~~t||t<0||t>zs)throw Error(wn);for(s=Xs(new s.constructor(s),t+s.e+1,e),t=t+s.e+1;s.c.length<t;)s.c.push(0)}return Qs(s,!1,!!r)};ge[Symbol.for("nodejs.util.inspect.custom")]=ge.toJSON=ge.toString=function(){var t=this,e=t.constructor;return Qs(t,t.e<=e.NE||t.e>=e.PE,!!t.c[0])};ge.toNumber=function(){var t=+Qs(this,!0,!0);if(this.constructor.strict===!0&&!this.eq(t.toString()))throw Error(Pi+"Imprecise conversion");return t};ge.toPrecision=function(t,e){var s=this,r=s.constructor,i=s.c[0];if(t!==Vt){if(t!==~~t||t<1||t>zs)throw Error(Zs+"precision");for(s=Xs(new r(s),t,e);s.c.length<t;)s.c.push(0)}return Qs(s,t<=s.e||s.e<=r.NE||s.e>=r.PE,!!i)};ge.valueOf=function(){var t=this,e=t.constructor;if(e.strict===!0)throw Error(Pi+"valueOf disallowed");return Qs(t,t.e<=e.NE||t.e>=e.PE,!0)};var Vr=El();const yu={bigNumber(t){return t?new Vr(t):new Vr(0)},multiply(t,e){if(t===void 0||e===void 0)return new Vr(0);const s=new Vr(t),r=new Vr(e);return s.times(r)},formatNumberToLocalString(t,e=2){return t===void 0?"0.00":typeof t=="number"?t.toLocaleString("en-US",{maximumFractionDigits:e,minimumFractionDigits:e}):parseFloat(t).toLocaleString("en-US",{maximumFractionDigits:e,minimumFractionDigits:e})},parseLocalStringToNumber(t){return t===void 0?0:parseFloat(t.replace(/,/gu,""))}},bu=[{type:"function",name:"transfer",stateMutability:"nonpayable",inputs:[{name:"_to",type:"address"},{name:"_value",type:"uint256"}],outputs:[{name:"",type:"bool"}]},{type:"function",name:"transferFrom",stateMutability:"nonpayable",inputs:[{name:"_from",type:"address"},{name:"_to",type:"address"},{name:"_value",type:"uint256"}],outputs:[{name:"",type:"bool"}]}],vu=[{type:"function",name:"approve",stateMutability:"nonpayable",inputs:[{name:"spender",type:"address"},{name:"amount",type:"uint256"}],outputs:[{type:"bool"}]}],Eu=[{type:"function",name:"transfer",stateMutability:"nonpayable",inputs:[{name:"recipient",type:"address"},{name:"amount",type:"uint256"}],outputs:[]},{type:"function",name:"transferFrom",stateMutability:"nonpayable",inputs:[{name:"sender",type:"address"},{name:"recipient",type:"address"},{name:"amount",type:"uint256"}],outputs:[{name:"",type:"bool"}]}],Cu={getERC20Abi:t=>z.USDT_CONTRACT_ADDRESSES.includes(t)?Eu:bu,getSwapAbi:()=>vu},cs={validateCaipAddress(t){var e;if(((e=t.split(":"))==null?void 0:e.length)!==3)throw new Error("Invalid CAIP Address");return t},parseCaipAddress(t){const e=t.split(":");if(e.length!==3)throw new Error(`Invalid CAIP-10 address: ${t}`);const[s,r,i]=e;if(!s||!r||!i)throw new Error(`Invalid CAIP-10 address: ${t}`);return{chainNamespace:s,chainId:r,address:i}},parseCaipNetworkId(t){const e=t.split(":");if(e.length!==2)throw new Error(`Invalid CAIP-2 network id: ${t}`);const[s,r]=e;if(!s||!r)throw new Error(`Invalid CAIP-2 network id: ${t}`);return{chainNamespace:s,chainId:r}}},ee={WALLET_ID:"@appkit/wallet_id",WALLET_NAME:"@appkit/wallet_name",SOLANA_WALLET:"@appkit/solana_wallet",SOLANA_CAIP_CHAIN:"@appkit/solana_caip_chain",ACTIVE_CAIP_NETWORK_ID:"@appkit/active_caip_network_id",CONNECTED_SOCIAL:"@appkit/connected_social",CONNECTED_SOCIAL_USERNAME:"@appkit-wallet/SOCIAL_USERNAME",RECENT_WALLETS:"@appkit/recent_wallets",DEEPLINK_CHOICE:"WALLETCONNECT_DEEPLINK_CHOICE",ACTIVE_NAMESPACE:"@appkit/active_namespace",CONNECTED_NAMESPACES:"@appkit/connected_namespaces",CONNECTION_STATUS:"@appkit/connection_status",SIWX_AUTH_TOKEN:"@appkit/siwx-auth-token",SIWX_NONCE_TOKEN:"@appkit/siwx-nonce-token",TELEGRAM_SOCIAL_PROVIDER:"@appkit/social_provider",NATIVE_BALANCE_CACHE:"@appkit/native_balance_cache",PORTFOLIO_CACHE:"@appkit/portfolio_cache",ENS_CACHE:"@appkit/ens_cache",IDENTITY_CACHE:"@appkit/identity_cache",PREFERRED_ACCOUNT_TYPES:"@appkit/preferred_account_types",CONNECTIONS:"@appkit/connections"};function Sn(t){if(!t)throw new Error("Namespace is required for CONNECTED_CONNECTOR_ID");return`@appkit/${t}:connected_connector_id`}const X={setItem(t,e){ti()&&e!==void 0&&localStorage.setItem(t,e)},getItem(t){if(ti())return localStorage.getItem(t)||void 0},removeItem(t){ti()&&localStorage.removeItem(t)},clear(){ti()&&localStorage.clear()}};function ti(){return typeof window<"u"&&typeof localStorage<"u"}function ys(t,e){return e==="light"?{"--w3m-accent":(t==null?void 0:t["--w3m-accent"])||"hsla(231, 100%, 70%, 1)","--w3m-background":"#fff"}:{"--w3m-accent":(t==null?void 0:t["--w3m-accent"])||"hsla(230, 100%, 67%, 1)","--w3m-background":"#121313"}}const Iu=Symbol(),da=Object.getPrototypeOf,oo=new WeakMap,Au=t=>t&&(oo.has(t)?oo.get(t):da(t)===Object.prototype||da(t)===Array.prototype),Nu=t=>Au(t)&&t[Iu]||null,pa=(t,e=!0)=>{oo.set(t,e)},cn={},Pn=t=>typeof t=="object"&&t!==null,fs=new WeakMap,si=new WeakSet,_u=(t=Object.is,e=(l,h)=>new Proxy(l,h),s=l=>Pn(l)&&!si.has(l)&&(Array.isArray(l)||!(Symbol.iterator in l))&&!(l instanceof WeakMap)&&!(l instanceof WeakSet)&&!(l instanceof Error)&&!(l instanceof Number)&&!(l instanceof Date)&&!(l instanceof String)&&!(l instanceof RegExp)&&!(l instanceof ArrayBuffer),r=l=>{switch(l.status){case"fulfilled":return l.value;case"rejected":throw l.reason;default:throw l}},i=new WeakMap,n=(l,h,u=r)=>{const d=i.get(l);if((d==null?void 0:d[0])===h)return d[1];const g=Array.isArray(l)?[]:Object.create(Object.getPrototypeOf(l));return pa(g,!0),i.set(l,[h,g]),Reflect.ownKeys(l).forEach(w=>{if(Object.getOwnPropertyDescriptor(g,w))return;const f=Reflect.get(l,w),{enumerable:m}=Reflect.getOwnPropertyDescriptor(l,w),y={value:f,enumerable:m,configurable:!0};if(si.has(f))pa(f,!1);else if(f instanceof Promise)delete y.value,y.get=()=>u(f);else if(fs.has(f)){const[b,E]=fs.get(f);y.value=n(b,E(),u)}Object.defineProperty(g,w,y)}),Object.preventExtensions(g)},o=new WeakMap,a=[1,1],c=l=>{if(!Pn(l))throw new Error("object required");const h=o.get(l);if(h)return h;let u=a[0];const d=new Set,g=(v,x=++a[0])=>{u!==x&&(u=x,d.forEach(C=>C(v,x)))};let w=a[1];const f=(v=++a[1])=>(w!==v&&!d.size&&(w=v,y.forEach(([x])=>{const C=x[1](v);C>u&&(u=C)})),u),m=v=>(x,C)=>{const L=[...x];L[1]=[v,...L[1]],g(L,C)},y=new Map,b=(v,x)=>{if((cn?"production":void 0)!=="production"&&y.has(v))throw new Error("prop listener already exists");if(d.size){const C=x[3](m(v));y.set(v,[x,C])}else y.set(v,[x])},E=v=>{var x;const C=y.get(v);C&&(y.delete(v),(x=C[1])==null||x.call(C))},A=v=>(d.add(v),d.size===1&&y.forEach(([C,L],H)=>{if((cn?"production":void 0)!=="production"&&L)throw new Error("remove already exists");const I=C[3](m(H));y.set(H,[C,I])}),()=>{d.delete(v),d.size===0&&y.forEach(([C,L],H)=>{L&&(L(),y.set(H,[C]))})}),$=Array.isArray(l)?[]:Object.create(Object.getPrototypeOf(l)),S=e($,{deleteProperty(v,x){const C=Reflect.get(v,x);E(x);const L=Reflect.deleteProperty(v,x);return L&&g(["delete",[x],C]),L},set(v,x,C,L){const H=Reflect.has(v,x),I=Reflect.get(v,x,L);if(H&&(t(I,C)||o.has(C)&&t(I,o.get(C))))return!0;E(x),Pn(C)&&(C=Nu(C)||C);let T=C;if(C instanceof Promise)C.then(_=>{C.status="fulfilled",C.value=_,g(["resolve",[x],_])}).catch(_=>{C.status="rejected",C.reason=_,g(["reject",[x],_])});else{!fs.has(C)&&s(C)&&(T=c(C));const _=!si.has(T)&&fs.get(T);_&&b(x,_)}return Reflect.set(v,x,T,L),g(["set",[x],C,I]),!0}});o.set(l,S);const D=[$,f,n,A];return fs.set(S,D),Reflect.ownKeys(l).forEach(v=>{const x=Object.getOwnPropertyDescriptor(l,v);"value"in x&&(S[v]=l[v],delete x.value,delete x.writable),Object.defineProperty($,v,x)}),S})=>[c,fs,si,t,e,s,r,i,n,o,a],[Su]=_u();function _e(t={}){return Su(t)}function Xe(t,e,s){const r=fs.get(t);(cn?"production":void 0)!=="production"&&!r&&console.warn("Please use proxy object");let i;const n=[],o=r[3];let a=!1;const l=o(h=>{n.push(h),i||(i=Promise.resolve().then(()=>{i=void 0,a&&e(n.splice(0))}))});return a=!0,()=>{a=!1,l()}}function yi(t,e){const s=fs.get(t);(cn?"production":void 0)!=="production"&&!s&&console.warn("Please use proxy object");const[r,i,n]=s;return n(r,i(),e)}function Hs(t){return si.add(t),t}function Qe(t,e,s,r){let i=t[e];return Xe(t,()=>{const n=t[e];Object.is(i,n)||s(i=n)})}function Pu(t){const e=_e({data:Array.from([]),has(s){return this.data.some(r=>r[0]===s)},set(s,r){const i=this.data.find(n=>n[0]===s);return i?i[1]=r:this.data.push([s,r]),this},get(s){var r;return(r=this.data.find(i=>i[0]===s))==null?void 0:r[1]},delete(s){const r=this.data.findIndex(i=>i[0]===s);return r===-1?!1:(this.data.splice(r,1),!0)},clear(){this.data.splice(0)},get size(){return this.data.length},toJSON(){return new Map(this.data)},forEach(s){this.data.forEach(r=>{s(r[1],r[0],this)})},keys(){return this.data.map(s=>s[0]).values()},values(){return this.data.map(s=>s[1]).values()},entries(){return new Map(this.data).entries()},get[Symbol.toStringTag](){return"Map"},[Symbol.iterator](){return this.entries()}});return Object.defineProperties(e,{data:{enumerable:!1},size:{enumerable:!1},toJSON:{enumerable:!1}}),Object.seal(e),e}const Cl=[{label:"Coinbase",name:"coinbase",feeRange:"1-2%",url:"",supportedChains:["eip155"]},{label:"Meld.io",name:"meld",feeRange:"1-2%",url:"https://meldcrypto.com",supportedChains:["eip155","solana"]}],Ou="WXETMuFUQmqqybHuRkSgxv:25B8LJHSfpG6LVjR2ytU5Cwh7Z4Sch2ocoU",Ee={FOUR_MINUTES_MS:24e4,TEN_SEC_MS:1e4,ONE_SEC_MS:1e3,BALANCE_SUPPORTED_CHAINS:["eip155","solana"],NAMES_SUPPORTED_CHAIN_NAMESPACES:["eip155"],NATIVE_TOKEN_ADDRESS:{eip155:"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",solana:"So11111111111111111111111111111111111111111",polkadot:"0x",bip122:"0x",cosmos:"0x"},CONVERT_SLIPPAGE_TOLERANCE:1,CONNECT_LABELS:{MOBILE:"Open and continue in the wallet app"},SEND_SUPPORTED_NAMESPACES:["eip155","solana"],DEFAULT_REMOTE_FEATURES:{swaps:["1inch"],onramp:["coinbase","meld"],email:!0,socials:["google","x","discord","farcaster","github","apple","facebook"],activity:!0,reownBranding:!0},DEFAULT_REMOTE_FEATURES_DISABLED:{email:!1,socials:!1,swaps:!1,onramp:!1,activity:!1,reownBranding:!1},DEFAULT_FEATURES:{receive:!0,send:!0,emailShowWallets:!0,connectorTypeOrder:["walletConnect","recent","injected","featured","custom","external","recommended"],analytics:!0,allWallets:!0,legalCheckbox:!1,smartSessions:!1,collapseWallets:!1,walletFeaturesOrder:["onramp","swaps","receive","send"],connectMethodsOrder:void 0,pay:!1},DEFAULT_ACCOUNT_TYPES:{bip122:"payment",eip155:"smartAccount",polkadot:"eoa",solana:"eoa"},ADAPTER_TYPES:{UNIVERSAL:"universal"}},F={cacheExpiry:{portfolio:3e4,nativeBalance:3e4,ens:3e5,identity:3e5},isCacheExpired(t,e){return Date.now()-t>e},getActiveNetworkProps(){const t=F.getActiveNamespace(),e=F.getActiveCaipNetworkId(),s=e?e.split(":")[1]:void 0,r=s?isNaN(Number(s))?s:Number(s):void 0;return{namespace:t,caipNetworkId:e,chainId:r}},setWalletConnectDeepLink({name:t,href:e}){try{X.setItem(ee.DEEPLINK_CHOICE,JSON.stringify({href:e,name:t}))}catch{console.info("Unable to set WalletConnect deep link")}},getWalletConnectDeepLink(){try{const t=X.getItem(ee.DEEPLINK_CHOICE);if(t)return JSON.parse(t)}catch{console.info("Unable to get WalletConnect deep link")}},deleteWalletConnectDeepLink(){try{X.removeItem(ee.DEEPLINK_CHOICE)}catch{console.info("Unable to delete WalletConnect deep link")}},setActiveNamespace(t){try{X.setItem(ee.ACTIVE_NAMESPACE,t)}catch{console.info("Unable to set active namespace")}},setActiveCaipNetworkId(t){try{X.setItem(ee.ACTIVE_CAIP_NETWORK_ID,t),F.setActiveNamespace(t.split(":")[0])}catch{console.info("Unable to set active caip network id")}},getActiveCaipNetworkId(){try{return X.getItem(ee.ACTIVE_CAIP_NETWORK_ID)}catch{console.info("Unable to get active caip network id");return}},deleteActiveCaipNetworkId(){try{X.removeItem(ee.ACTIVE_CAIP_NETWORK_ID)}catch{console.info("Unable to delete active caip network id")}},deleteConnectedConnectorId(t){try{const e=Sn(t);X.removeItem(e)}catch{console.info("Unable to delete connected connector id")}},setAppKitRecent(t){try{const e=F.getRecentWallets();e.find(r=>r.id===t.id)||(e.unshift(t),e.length>2&&e.pop(),X.setItem(ee.RECENT_WALLETS,JSON.stringify(e)))}catch{console.info("Unable to set AppKit recent")}},getRecentWallets(){try{const t=X.getItem(ee.RECENT_WALLETS);return t?JSON.parse(t):[]}catch{console.info("Unable to get AppKit recent")}return[]},setConnectedConnectorId(t,e){try{const s=Sn(t);X.setItem(s,e)}catch{console.info("Unable to set Connected Connector Id")}},getActiveNamespace(){try{return X.getItem(ee.ACTIVE_NAMESPACE)}catch{console.info("Unable to get active namespace")}},getConnectedConnectorId(t){if(t)try{const e=Sn(t);return X.getItem(e)}catch{console.info("Unable to get connected connector id in namespace ",t)}},setConnectedSocialProvider(t){try{X.setItem(ee.CONNECTED_SOCIAL,t)}catch{console.info("Unable to set connected social provider")}},getConnectedSocialProvider(){try{return X.getItem(ee.CONNECTED_SOCIAL)}catch{console.info("Unable to get connected social provider")}},deleteConnectedSocialProvider(){try{X.removeItem(ee.CONNECTED_SOCIAL)}catch{console.info("Unable to delete connected social provider")}},getConnectedSocialUsername(){try{return X.getItem(ee.CONNECTED_SOCIAL_USERNAME)}catch{console.info("Unable to get connected social username")}},getStoredActiveCaipNetworkId(){var s;const t=X.getItem(ee.ACTIVE_CAIP_NETWORK_ID);return(s=t==null?void 0:t.split(":"))==null?void 0:s[1]},setConnectionStatus(t){try{X.setItem(ee.CONNECTION_STATUS,t)}catch{console.info("Unable to set connection status")}},getConnectionStatus(){try{return X.getItem(ee.CONNECTION_STATUS)}catch{return}},getConnectedNamespaces(){try{const t=X.getItem(ee.CONNECTED_NAMESPACES);return t!=null&&t.length?t.split(","):[]}catch{return[]}},setConnectedNamespaces(t){try{const e=Array.from(new Set(t));X.setItem(ee.CONNECTED_NAMESPACES,e.join(","))}catch{console.info("Unable to set namespaces in storage")}},addConnectedNamespace(t){try{const e=F.getConnectedNamespaces();e.includes(t)||(e.push(t),F.setConnectedNamespaces(e))}catch{console.info("Unable to add connected namespace")}},removeConnectedNamespace(t){try{const e=F.getConnectedNamespaces(),s=e.indexOf(t);s>-1&&(e.splice(s,1),F.setConnectedNamespaces(e))}catch{console.info("Unable to remove connected namespace")}},getTelegramSocialProvider(){try{return X.getItem(ee.TELEGRAM_SOCIAL_PROVIDER)}catch{return console.info("Unable to get telegram social provider"),null}},setTelegramSocialProvider(t){try{X.setItem(ee.TELEGRAM_SOCIAL_PROVIDER,t)}catch{console.info("Unable to set telegram social provider")}},removeTelegramSocialProvider(){try{X.removeItem(ee.TELEGRAM_SOCIAL_PROVIDER)}catch{console.info("Unable to remove telegram social provider")}},getBalanceCache(){let t={};try{const e=X.getItem(ee.PORTFOLIO_CACHE);t=e?JSON.parse(e):{}}catch{console.info("Unable to get balance cache")}return t},removeAddressFromBalanceCache(t){try{const e=F.getBalanceCache();X.setItem(ee.PORTFOLIO_CACHE,JSON.stringify({...e,[t]:void 0}))}catch{console.info("Unable to remove address from balance cache",t)}},getBalanceCacheForCaipAddress(t){try{const s=F.getBalanceCache()[t];if(s&&!this.isCacheExpired(s.timestamp,this.cacheExpiry.portfolio))return s.balance;F.removeAddressFromBalanceCache(t)}catch{console.info("Unable to get balance cache for address",t)}},updateBalanceCache(t){try{const e=F.getBalanceCache();e[t.caipAddress]=t,X.setItem(ee.PORTFOLIO_CACHE,JSON.stringify(e))}catch{console.info("Unable to update balance cache",t)}},getNativeBalanceCache(){let t={};try{const e=X.getItem(ee.NATIVE_BALANCE_CACHE);t=e?JSON.parse(e):{}}catch{console.info("Unable to get balance cache")}return t},removeAddressFromNativeBalanceCache(t){try{const e=F.getBalanceCache();X.setItem(ee.NATIVE_BALANCE_CACHE,JSON.stringify({...e,[t]:void 0}))}catch{console.info("Unable to remove address from balance cache",t)}},getNativeBalanceCacheForCaipAddress(t){try{const s=F.getNativeBalanceCache()[t];if(s&&!this.isCacheExpired(s.timestamp,this.cacheExpiry.nativeBalance))return s;console.info("Discarding cache for address",t),F.removeAddressFromBalanceCache(t)}catch{console.info("Unable to get balance cache for address",t)}},updateNativeBalanceCache(t){try{const e=F.getNativeBalanceCache();e[t.caipAddress]=t,X.setItem(ee.NATIVE_BALANCE_CACHE,JSON.stringify(e))}catch{console.info("Unable to update balance cache",t)}},getEnsCache(){let t={};try{const e=X.getItem(ee.ENS_CACHE);t=e?JSON.parse(e):{}}catch{console.info("Unable to get ens name cache")}return t},getEnsFromCacheForAddress(t){try{const s=F.getEnsCache()[t];if(s&&!this.isCacheExpired(s.timestamp,this.cacheExpiry.ens))return s.ens;F.removeEnsFromCache(t)}catch{console.info("Unable to get ens name from cache",t)}},updateEnsCache(t){try{const e=F.getEnsCache();e[t.address]=t,X.setItem(ee.ENS_CACHE,JSON.stringify(e))}catch{console.info("Unable to update ens name cache",t)}},removeEnsFromCache(t){try{const e=F.getEnsCache();X.setItem(ee.ENS_CACHE,JSON.stringify({...e,[t]:void 0}))}catch{console.info("Unable to remove ens name from cache",t)}},getIdentityCache(){let t={};try{const e=X.getItem(ee.IDENTITY_CACHE);t=e?JSON.parse(e):{}}catch{console.info("Unable to get identity cache")}return t},getIdentityFromCacheForAddress(t){try{const s=F.getIdentityCache()[t];if(s&&!this.isCacheExpired(s.timestamp,this.cacheExpiry.identity))return s.identity;F.removeIdentityFromCache(t)}catch{console.info("Unable to get identity from cache",t)}},updateIdentityCache(t){try{const e=F.getIdentityCache();e[t.address]={identity:t.identity,timestamp:t.timestamp},X.setItem(ee.IDENTITY_CACHE,JSON.stringify(e))}catch{console.info("Unable to update identity cache",t)}},removeIdentityFromCache(t){try{const e=F.getIdentityCache();X.setItem(ee.IDENTITY_CACHE,JSON.stringify({...e,[t]:void 0}))}catch{console.info("Unable to remove identity from cache",t)}},clearAddressCache(){try{X.removeItem(ee.PORTFOLIO_CACHE),X.removeItem(ee.NATIVE_BALANCE_CACHE),X.removeItem(ee.ENS_CACHE),X.removeItem(ee.IDENTITY_CACHE)}catch{console.info("Unable to clear address cache")}},setPreferredAccountTypes(t){try{X.setItem(ee.PREFERRED_ACCOUNT_TYPES,JSON.stringify(t))}catch{console.info("Unable to set preferred account types",t)}},getPreferredAccountTypes(){try{const t=X.getItem(ee.PREFERRED_ACCOUNT_TYPES);return t?JSON.parse(t):{}}catch{console.info("Unable to get preferred account types")}return{}},setConnections(t,e){try{const s={...F.getConnections(),[e]:t};X.setItem(ee.CONNECTIONS,JSON.stringify(s))}catch(s){console.error("Unable to sync connections to storage",s)}},getConnections(){try{const t=X.getItem(ee.CONNECTIONS);return t?JSON.parse(t):{}}catch(t){return console.error("Unable to get connections from storage",t),{}}}},Z={isMobile(){var t;return this.isClient()?!!(typeof(window==null?void 0:window.matchMedia)=="function"&&((t=window==null?void 0:window.matchMedia("(pointer:coarse)"))!=null&&t.matches)||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)):!1},checkCaipNetwork(t,e=""){return t==null?void 0:t.caipNetworkId.toLocaleLowerCase().includes(e.toLowerCase())},isAndroid(){if(!this.isMobile())return!1;const t=window==null?void 0:window.navigator.userAgent.toLowerCase();return Z.isMobile()&&t.includes("android")},isIos(){if(!this.isMobile())return!1;const t=window==null?void 0:window.navigator.userAgent.toLowerCase();return t.includes("iphone")||t.includes("ipad")},isSafari(){return this.isClient()?(window==null?void 0:window.navigator.userAgent.toLowerCase()).includes("safari"):!1},isClient(){return typeof window<"u"},isPairingExpired(t){return t?t-Date.now()<=Ee.TEN_SEC_MS:!0},isAllowedRetry(t,e=Ee.ONE_SEC_MS){return Date.now()-t>=e},copyToClopboard(t){navigator.clipboard.writeText(t)},isIframe(){try{return(window==null?void 0:window.self)!==(window==null?void 0:window.top)}catch{return!1}},isSafeApp(){var t,e;if(Z.isClient()&&window.self!==window.top)try{const s=(e=(t=window==null?void 0:window.location)==null?void 0:t.ancestorOrigins)==null?void 0:e[0],r="https://app.safe.global";if(s){const i=new URL(s),n=new URL(r);return i.hostname===n.hostname}}catch{return!1}return!1},getPairingExpiry(){return Date.now()+Ee.FOUR_MINUTES_MS},getNetworkId(t){return t==null?void 0:t.split(":")[1]},getPlainAddress(t){return t==null?void 0:t.split(":")[2]},async wait(t){return new Promise(e=>{setTimeout(e,t)})},debounce(t,e=500){let s;return(...r)=>{function i(){t(...r)}s&&clearTimeout(s),s=setTimeout(i,e)}},isHttpUrl(t){return t.startsWith("http://")||t.startsWith("https://")},formatNativeUrl(t,e,s=null){if(Z.isHttpUrl(t))return this.formatUniversalUrl(t,e);let r=t,i=s;r.includes("://")||(r=t.replaceAll("/","").replaceAll(":",""),r=`${r}://`),r.endsWith("/")||(r=`${r}/`),i&&!(i!=null&&i.endsWith("/"))&&(i=`${i}/`),this.isTelegram()&&this.isAndroid()&&(e=encodeURIComponent(e));const n=encodeURIComponent(e);return{redirect:`${r}wc?uri=${n}`,redirectUniversalLink:i?`${i}wc?uri=${n}`:void 0,href:r}},formatUniversalUrl(t,e){if(!Z.isHttpUrl(t))return this.formatNativeUrl(t,e);let s=t;s.endsWith("/")||(s=`${s}/`);const r=encodeURIComponent(e);return{redirect:`${s}wc?uri=${r}`,href:s}},getOpenTargetForPlatform(t){return t==="popupWindow"?t:this.isTelegram()?F.getTelegramSocialProvider()?"_top":"_blank":t},openHref(t,e,s){window==null||window.open(t,this.getOpenTargetForPlatform(e),s||"noreferrer noopener")},returnOpenHref(t,e,s){return window==null?void 0:window.open(t,this.getOpenTargetForPlatform(e),s||"noreferrer noopener")},isTelegram(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)},isPWA(){var s,r,i;if(typeof window>"u")return!1;const t=(r=(s=window.matchMedia)==null?void 0:s.call(window,"(display-mode: standalone)"))==null?void 0:r.matches,e=(i=window==null?void 0:window.navigator)==null?void 0:i.standalone;return!!(t||e)},async preloadImage(t){const e=new Promise((s,r)=>{const i=new Image;i.onload=s,i.onerror=r,i.crossOrigin="anonymous",i.src=t});return Promise.race([e,Z.wait(2e3)])},formatBalance(t,e){let s="0.000";if(typeof t=="string"){const r=Number(t);if(r){const i=Math.floor(r*1e3)/1e3;i&&(s=i.toString())}}return`${s}${e?` ${e}`:""}`},formatBalance2(t,e){var r;let s;if(t==="0")s="0";else if(typeof t=="string"){const i=Number(t);i&&(s=(r=i.toString().match(/^-?\d+(?:\.\d{0,3})?/u))==null?void 0:r[0])}return{value:s??"0",rest:s==="0"?"000":"",symbol:e}},getApiUrl(){return z.W3M_API_URL},getBlockchainApiUrl(){return z.BLOCKCHAIN_API_RPC_URL},getAnalyticsUrl(){return z.PULSE_API_URL},getUUID(){return crypto!=null&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,t=>{const e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)})},parseError(t){var e,s;return typeof t=="string"?t:typeof((s=(e=t==null?void 0:t.issues)==null?void 0:e[0])==null?void 0:s.message)=="string"?t.issues[0].message:t instanceof Error?t.message:"Unknown error"},sortRequestedNetworks(t,e=[]){const s={};return e&&t&&(t.forEach((r,i)=>{s[r]=i}),e.sort((r,i)=>{const n=s[r.id],o=s[i.id];return n!==void 0&&o!==void 0?n-o:n!==void 0?-1:o!==void 0?1:0})),e},calculateBalance(t){let e=0;for(const s of t)e+=s.value??0;return e},formatTokenBalance(t){const e=t.toFixed(2),[s,r]=e.split(".");return{dollars:s,pennies:r}},isAddress(t,e="eip155"){switch(e){case"eip155":if(/^(?:0x)?[0-9a-f]{40}$/iu.test(t)){if(/^(?:0x)?[0-9a-f]{40}$/iu.test(t)||/^(?:0x)?[0-9A-F]{40}$/iu.test(t))return!0}else return!1;return!1;case"solana":return/[1-9A-HJ-NP-Za-km-z]{32,44}$/iu.test(t);default:return!1}},uniqueBy(t,e){const s=new Set;return t.filter(r=>{const i=r[e];return s.has(i)?!1:(s.add(i),!0)})},generateSdkVersion(t,e,s){const i=t.length===0?Ee.ADAPTER_TYPES.UNIVERSAL:t.map(n=>n.adapterType).join(",");return`${e}-${i}-${s}`},createAccount(t,e,s,r,i){return{namespace:t,address:e,type:s,publicKey:r,path:i}},isCaipAddress(t){if(typeof t!="string")return!1;const e=t.split(":"),s=e[0];return e.filter(Boolean).length===3&&s in z.CHAIN_NAME_MAP},isMac(){const t=window==null?void 0:window.navigator.userAgent.toLowerCase();return t.includes("macintosh")&&!t.includes("safari")},formatTelegramSocialLoginUrl(t){const e=`--${encodeURIComponent(window==null?void 0:window.location.href)}`,s="state=";if(new URL(t).host==="auth.magic.link"){const i="provider_authorization_url=",n=t.substring(t.indexOf(i)+i.length),o=this.injectIntoUrl(decodeURIComponent(n),s,e);return t.replace(n,encodeURIComponent(o))}return this.injectIntoUrl(t,s,e)},injectIntoUrl(t,e,s){const r=t.indexOf(e);if(r===-1)throw new Error(`${e} parameter not found in the URL: ${t}`);const i=t.indexOf("&",r),n=e.length,o=i!==-1?i:t.length,a=t.substring(0,r+n),c=t.substring(r+n,o),l=t.substring(i),h=c+s;return a+h+l}};async function Kr(...t){const e=await fetch(...t);if(!e.ok)throw new Error(`HTTP status code: ${e.status}`,{cause:e});return e}class Oi{constructor({baseUrl:e,clientId:s}){this.baseUrl=e,this.clientId=s}async get({headers:e,signal:s,cache:r,...i}){const n=this.createUrl(i);return(await Kr(n,{method:"GET",headers:e,signal:s,cache:r})).json()}async getBlob({headers:e,signal:s,...r}){const i=this.createUrl(r);return(await Kr(i,{method:"GET",headers:e,signal:s})).blob()}async post({body:e,headers:s,signal:r,...i}){const n=this.createUrl(i);return(await Kr(n,{method:"POST",headers:s,body:e?JSON.stringify(e):void 0,signal:r})).json()}async put({body:e,headers:s,signal:r,...i}){const n=this.createUrl(i);return(await Kr(n,{method:"PUT",headers:s,body:e?JSON.stringify(e):void 0,signal:r})).json()}async delete({body:e,headers:s,signal:r,...i}){const n=this.createUrl(i);return(await Kr(n,{method:"DELETE",headers:s,body:e?JSON.stringify(e):void 0,signal:r})).json()}createUrl({path:e,params:s}){const r=new URL(e,this.baseUrl);return s&&Object.entries(s).forEach(([i,n])=>{n&&r.searchParams.append(i,n)}),this.clientId&&r.searchParams.append("clientId",this.clientId),r}}const Tu={getFeatureValue(t,e){const s=e==null?void 0:e[t];return s===void 0?Ee.DEFAULT_FEATURES[t]:s},filterSocialsByPlatform(t){if(!t||!t.length)return t;if(Z.isTelegram()){if(Z.isIos())return t.filter(e=>e!=="google");if(Z.isMac())return t.filter(e=>e!=="x");if(Z.isAndroid())return t.filter(e=>!["facebook","x"].includes(e))}return t}},K=_e({features:Ee.DEFAULT_FEATURES,projectId:"",sdkType:"appkit",sdkVersion:"html-wagmi-undefined",defaultAccountTypes:Ee.DEFAULT_ACCOUNT_TYPES,enableNetworkSwitch:!0,experimental_preferUniversalLinks:!1,remoteFeatures:{}}),O={state:K,subscribeKey(t,e){return Qe(K,t,e)},setOptions(t){Object.assign(K,t)},setRemoteFeatures(t){var s;if(!t)return;const e={...K.remoteFeatures,...t};K.remoteFeatures=e,(s=K.remoteFeatures)!=null&&s.socials&&(K.remoteFeatures.socials=Tu.filterSocialsByPlatform(K.remoteFeatures.socials))},setFeatures(t){if(!t)return;K.features||(K.features=Ee.DEFAULT_FEATURES);const e={...K.features,...t};K.features=e},setProjectId(t){K.projectId=t},setCustomRpcUrls(t){K.customRpcUrls=t},setAllWallets(t){K.allWallets=t},setIncludeWalletIds(t){K.includeWalletIds=t},setExcludeWalletIds(t){K.excludeWalletIds=t},setFeaturedWalletIds(t){K.featuredWalletIds=t},setTokens(t){K.tokens=t},setTermsConditionsUrl(t){K.termsConditionsUrl=t},setPrivacyPolicyUrl(t){K.privacyPolicyUrl=t},setCustomWallets(t){K.customWallets=t},setIsSiweEnabled(t){K.isSiweEnabled=t},setIsUniversalProvider(t){K.isUniversalProvider=t},setSdkVersion(t){K.sdkVersion=t},setMetadata(t){K.metadata=t},setDisableAppend(t){K.disableAppend=t},setEIP6963Enabled(t){K.enableEIP6963=t},setDebug(t){K.debug=t},setEnableWalletConnect(t){K.enableWalletConnect=t},setEnableWalletGuide(t){K.enableWalletGuide=t},setEnableAuthLogger(t){K.enableAuthLogger=t},setEnableWallets(t){K.enableWallets=t},setPreferUniversalLinks(t){K.experimental_preferUniversalLinks=t},setHasMultipleAddresses(t){K.hasMultipleAddresses=t},setSIWX(t){K.siwx=t},setConnectMethodsOrder(t){K.features={...K.features,connectMethodsOrder:t}},setWalletFeaturesOrder(t){K.features={...K.features,walletFeaturesOrder:t}},setSocialsOrder(t){K.remoteFeatures={...K.remoteFeatures,socials:t}},setCollapseWallets(t){K.features={...K.features,collapseWallets:t}},setEnableEmbedded(t){K.enableEmbedded=t},setAllowUnsupportedChain(t){K.allowUnsupportedChain=t},setManualWCControl(t){K.manualWCControl=t},setEnableNetworkSwitch(t){K.enableNetworkSwitch=t},setDefaultAccountTypes(t={}){Object.entries(t).forEach(([e,s])=>{s&&(K.defaultAccountTypes[e]=s)})},setUniversalProviderConfigOverride(t){K.universalProviderConfigOverride=t},getUniversalProviderConfigOverride(){return K.universalProviderConfigOverride},getSnapshot(){return yi(K)}},ku=Object.freeze({enabled:!0,events:[]}),$u=new Oi({baseUrl:Z.getAnalyticsUrl(),clientId:null}),xu=5,Ru=60*1e3,ls=_e({...ku}),Uu={state:ls,subscribeKey(t,e){return Qe(ls,t,e)},async sendError(t,e){if(!ls.enabled)return;const s=Date.now();if(ls.events.filter(n=>{const o=new Date(n.properties.timestamp||"").getTime();return s-o<Ru}).length>=xu)return;const i={type:"error",event:e,properties:{errorType:t.name,errorMessage:t.message,stackTrace:t.stack,timestamp:new Date().toISOString()}};ls.events.push(i);try{if(typeof window>"u")return;const{projectId:n,sdkType:o,sdkVersion:a}=O.state;await $u.post({path:"/e",params:{projectId:n,st:o,sv:a||"html-wagmi-4.2.2"},body:{eventId:Z.getUUID(),url:window.location.href,domain:window.location.hostname,timestamp:new Date().toISOString(),props:{type:"error",event:e,errorType:t.name,errorMessage:t.message,stackTrace:t.stack}}})}catch{}},enable(){ls.enabled=!0},disable(){ls.enabled=!1},clearEvents(){ls.events=[]}};class Tr extends Error{constructor(e,s,r){super(e),this.name="AppKitError",this.category=s,this.originalError=r,Object.setPrototypeOf(this,Tr.prototype);let i=!1;if(r instanceof Error&&typeof r.stack=="string"&&r.stack){const n=r.stack,o=n.indexOf(`
3
+ `);if(o>-1){const a=n.substring(o+1);this.stack=`${this.name}: ${this.message}
4
+ ${a}`,i=!0}}i||(Error.captureStackTrace?Error.captureStackTrace(this,Tr):this.stack||(this.stack=`${this.name}: ${this.message}`))}}function fa(t,e){const s=t instanceof Tr?t:new Tr(t instanceof Error?t.message:String(t),e,t);throw Uu.sendError(s,s.category),s}function vt(t,e="INTERNAL_SDK_ERROR"){const s={};return Object.keys(t).forEach(r=>{const i=t[r];if(typeof i=="function"){let n=i;i.constructor.name==="AsyncFunction"?n=async(...o)=>{try{return await i(...o)}catch(a){return fa(a,e)}}:n=(...o)=>{try{return i(...o)}catch(a){return fa(a,e)}},s[r]=n}else s[r]=i}),s}const zt={PHANTOM:{id:"a797aa35c0fadbfc1a53e7f675162ed5226968b44a19ee3d24385c64d1d3c393",url:"https://phantom.app"},SOLFLARE:{id:"1ca0bdd4747578705b1939af023d120677c64fe6ca76add81fda36e350605e79",url:"https://solflare.com"},COINBASE:{id:"fd20dc426fb37566d803205b19bbc1d4096b248ac04548e3cfb6b3a38bd033aa",url:"https://go.cb-w.com"}},Du={handleMobileDeeplinkRedirect(t,e){const s=window.location.href,r=encodeURIComponent(s);if(t===zt.PHANTOM.id&&!("phantom"in window)){const i=s.startsWith("https")?"https":"http",n=s.split("/")[2],o=encodeURIComponent(`${i}://${n}`);window.location.href=`${zt.PHANTOM.url}/ul/browse/${r}?ref=${o}`}t===zt.SOLFLARE.id&&!("solflare"in window)&&(window.location.href=`${zt.SOLFLARE.url}/ul/v1/browse/${r}?ref=${r}`),e===z.CHAIN.SOLANA&&t===zt.COINBASE.id&&!("coinbaseSolana"in window)&&(window.location.href=`${zt.COINBASE.url}/dapp?cb_url=${r}`)}},ut=_e({walletImages:{},networkImages:{},chainImages:{},connectorImages:{},tokenImages:{},currencyImages:{}}),Lu={state:ut,subscribeNetworkImages(t){return Xe(ut.networkImages,()=>t(ut.networkImages))},subscribeKey(t,e){return Qe(ut,t,e)},subscribe(t){return Xe(ut,()=>t(ut))},setWalletImage(t,e){ut.walletImages[t]=e},setNetworkImage(t,e){ut.networkImages[t]=e},setChainImage(t,e){ut.chainImages[t]=e},setConnectorImage(t,e){ut.connectorImages={...ut.connectorImages,[t]:e}},setTokenImage(t,e){ut.tokenImages[t]=e},setCurrencyImage(t,e){ut.currencyImages[t]=e}},Rt=vt(Lu),Mu={eip155:"ba0ba0cd-17c6-4806-ad93-f9d174f17900",solana:"a1b58899-f671-4276-6a5e-56ca5bd59700",polkadot:"",bip122:"0b4838db-0161-4ffe-022d-532bf03dba00",cosmos:""},On=_e({networkImagePromises:{}}),Il={async fetchWalletImage(t){if(t)return await V._fetchWalletImage(t),this.getWalletImageById(t)},async fetchNetworkImage(t){if(!t)return;const e=this.getNetworkImageById(t);return e||(On.networkImagePromises[t]||(On.networkImagePromises[t]=V._fetchNetworkImage(t)),await On.networkImagePromises[t],this.getNetworkImageById(t))},getWalletImageById(t){if(t)return Rt.state.walletImages[t]},getWalletImage(t){if(t!=null&&t.image_url)return t==null?void 0:t.image_url;if(t!=null&&t.image_id)return Rt.state.walletImages[t.image_id]},getNetworkImage(t){var e,s,r;if((e=t==null?void 0:t.assets)!=null&&e.imageUrl)return(s=t==null?void 0:t.assets)==null?void 0:s.imageUrl;if((r=t==null?void 0:t.assets)!=null&&r.imageId)return Rt.state.networkImages[t.assets.imageId]},getNetworkImageById(t){if(t)return Rt.state.networkImages[t]},getConnectorImage(t){if(t!=null&&t.imageUrl)return t.imageUrl;if(t!=null&&t.imageId)return Rt.state.connectorImages[t.imageId]},getChainImage(t){return Rt.state.networkImages[Mu[t]]}},hs=_e({message:"",variant:"info",open:!1}),Bu={state:hs,subscribeKey(t,e){return Qe(hs,t,e)},open(t,e){const{debug:s}=O.state,{shortMessage:r,longMessage:i}=t;s&&(hs.message=r,hs.variant=e,hs.open=!0),i&&console.error(typeof i=="function"?i():i)},close(){hs.open=!1,hs.message="",hs.variant="info"}},Us=vt(Bu),qu=Z.getAnalyticsUrl(),ju=new Oi({baseUrl:qu,clientId:null}),Fu=["MODAL_CREATED"],Xt=_e({timestamp:Date.now(),reportedErrors:{},data:{type:"track",event:"MODAL_CREATED"}}),Pe={state:Xt,subscribe(t){return Xe(Xt,()=>t(Xt))},getSdkProperties(){const{projectId:t,sdkType:e,sdkVersion:s}=O.state;return{projectId:t,st:e,sv:s||"html-wagmi-4.2.2"}},async _sendAnalyticsEvent(t){try{const e=W.state.address;if(Fu.includes(t.data.event)||typeof window>"u")return;await ju.post({path:"/e",params:Pe.getSdkProperties(),body:{eventId:Z.getUUID(),url:window.location.href,domain:window.location.hostname,timestamp:t.timestamp,props:{...t.data,address:e}}}),Xt.reportedErrors.FORBIDDEN=!1}catch(e){e instanceof Error&&e.cause instanceof Response&&e.cause.status===z.HTTP_STATUS_CODES.FORBIDDEN&&!Xt.reportedErrors.FORBIDDEN&&(Us.open({shortMessage:"Invalid App Configuration",longMessage:`Origin ${ti()?window.origin:"uknown"} not found on Allowlist - update configuration on cloud.reown.com`},"error"),Xt.reportedErrors.FORBIDDEN=!0)}},sendEvent(t){var e;Xt.timestamp=Date.now(),Xt.data=t,(e=O.state.features)!=null&&e.analytics&&Pe._sendAnalyticsEvent(Xt)}},Wu=Z.getApiUrl(),rt=new Oi({baseUrl:Wu,clientId:null}),zu=40,ga=4,Hu=20,te=_e({promises:{},page:1,count:0,featured:[],allFeatured:[],recommended:[],allRecommended:[],wallets:[],filteredWallets:[],search:[],isAnalyticsEnabled:!1,excludedWallets:[],isFetchingRecommendedWallets:!1}),V={state:te,subscribeKey(t,e){return Qe(te,t,e)},_getSdkProperties(){const{projectId:t,sdkType:e,sdkVersion:s}=O.state;return{projectId:t,st:e||"appkit",sv:s||"html-wagmi-4.2.2"}},_filterOutExtensions(t){return O.state.isUniversalProvider?t.filter(e=>!!(e.mobile_link||e.desktop_link||e.webapp_link)):t},async _fetchWalletImage(t){const e=`${rt.baseUrl}/getWalletImage/${t}`,s=await rt.getBlob({path:e,params:V._getSdkProperties()});Rt.setWalletImage(t,URL.createObjectURL(s))},async _fetchNetworkImage(t){const e=`${rt.baseUrl}/public/getAssetImage/${t}`,s=await rt.getBlob({path:e,params:V._getSdkProperties()});Rt.setNetworkImage(t,URL.createObjectURL(s))},async _fetchConnectorImage(t){const e=`${rt.baseUrl}/public/getAssetImage/${t}`,s=await rt.getBlob({path:e,params:V._getSdkProperties()});Rt.setConnectorImage(t,URL.createObjectURL(s))},async _fetchCurrencyImage(t){const e=`${rt.baseUrl}/public/getCurrencyImage/${t}`,s=await rt.getBlob({path:e,params:V._getSdkProperties()});Rt.setCurrencyImage(t,URL.createObjectURL(s))},async _fetchTokenImage(t){const e=`${rt.baseUrl}/public/getTokenImage/${t}`,s=await rt.getBlob({path:e,params:V._getSdkProperties()});Rt.setTokenImage(t,URL.createObjectURL(s))},_filterWalletsByPlatform(t){return Z.isMobile()?t==null?void 0:t.filter(s=>s.mobile_link||s.id===zt.COINBASE.id?!0:p.state.activeChain==="solana"&&(s.id===zt.SOLFLARE.id||s.id===zt.PHANTOM.id)):t},async fetchProjectConfig(){return(await rt.get({path:"/appkit/v1/config",params:V._getSdkProperties()})).features},async fetchAllowedOrigins(){try{const{allowedOrigins:t}=await rt.get({path:"/projects/v1/origins",params:V._getSdkProperties()});return t}catch{return[]}},async fetchNetworkImages(){const t=p.getAllRequestedCaipNetworks(),e=t==null?void 0:t.map(({assets:s})=>s==null?void 0:s.imageId).filter(Boolean).filter(s=>!Il.getNetworkImageById(s));e&&await Promise.allSettled(e.map(s=>V._fetchNetworkImage(s)))},async fetchConnectorImages(){const{connectors:t}=q.state,e=t.map(({imageId:s})=>s).filter(Boolean);await Promise.allSettled(e.map(s=>V._fetchConnectorImage(s)))},async fetchCurrencyImages(t=[]){await Promise.allSettled(t.map(e=>V._fetchCurrencyImage(e)))},async fetchTokenImages(t=[]){await Promise.allSettled(t.map(e=>V._fetchTokenImage(e)))},async fetchWallets(t){var n;const e=t.exclude??[];V._getSdkProperties().sv.startsWith("html-core-")&&e.push(...Object.values(zt).map(o=>o.id));const r=await rt.get({path:"/getWallets",params:{...V._getSdkProperties(),...t,page:String(t.page),entries:String(t.entries),include:(n=t.include)==null?void 0:n.join(","),exclude:e.join(",")}});return{data:V._filterWalletsByPlatform(r==null?void 0:r.data)||[],count:r==null?void 0:r.count}},async fetchFeaturedWallets(){const{featuredWalletIds:t}=O.state;if(t!=null&&t.length){const e={...V._getSdkProperties(),page:1,entries:(t==null?void 0:t.length)??ga,include:t},{data:s}=await V.fetchWallets(e),r=[...s].sort((n,o)=>t.indexOf(n.id)-t.indexOf(o.id)),i=r.map(n=>n.image_id).filter(Boolean);await Promise.allSettled(i.map(n=>V._fetchWalletImage(n))),te.featured=r,te.allFeatured=r}},async fetchRecommendedWallets(){try{te.isFetchingRecommendedWallets=!0;const{includeWalletIds:t,excludeWalletIds:e,featuredWalletIds:s}=O.state,r=[...e??[],...s??[]].filter(Boolean),i=p.getRequestedCaipNetworkIds().join(","),n={page:1,entries:ga,include:t,exclude:r,chains:i},{data:o,count:a}=await V.fetchWallets(n),c=F.getRecentWallets(),l=o.map(u=>u.image_id).filter(Boolean),h=c.map(u=>u.image_id).filter(Boolean);await Promise.allSettled([...l,...h].map(u=>V._fetchWalletImage(u))),te.recommended=o,te.allRecommended=o,te.count=a??0}catch{}finally{te.isFetchingRecommendedWallets=!1}},async fetchWalletsByPage({page:t}){const{includeWalletIds:e,excludeWalletIds:s,featuredWalletIds:r}=O.state,i=p.getRequestedCaipNetworkIds().join(","),n=[...te.recommended.map(({id:h})=>h),...s??[],...r??[]].filter(Boolean),o={page:t,entries:zu,include:e,exclude:n,chains:i},{data:a,count:c}=await V.fetchWallets(o),l=a.slice(0,Hu).map(h=>h.image_id).filter(Boolean);await Promise.allSettled(l.map(h=>V._fetchWalletImage(h))),te.wallets=Z.uniqueBy([...te.wallets,...V._filterOutExtensions(a)],"id").filter(h=>{var u;return(u=h.chains)==null?void 0:u.some(d=>i.includes(d))}),te.count=c>te.count?c:te.count,te.page=t},async initializeExcludedWallets({ids:t}){const e={page:1,entries:t.length,include:t},{data:s}=await V.fetchWallets(e);s&&s.forEach(r=>{te.excludedWallets.push({rdns:r.rdns,name:r.name})})},async searchWallet({search:t,badge:e}){const{includeWalletIds:s,excludeWalletIds:r}=O.state,i=p.getRequestedCaipNetworkIds().join(",");te.search=[];const n={page:1,entries:100,search:t==null?void 0:t.trim(),badge_type:e,include:s,exclude:r,chains:i},{data:o}=await V.fetchWallets(n);Pe.sendEvent({type:"track",event:"SEARCH_WALLET",properties:{badge:e??"",search:t??""}});const a=o.map(c=>c.image_id).filter(Boolean);await Promise.allSettled([...a.map(c=>V._fetchWalletImage(c)),Z.wait(300)]),te.search=V._filterOutExtensions(o)},initPromise(t,e){const s=te.promises[t];return s||(te.promises[t]=e())},prefetch({fetchConnectorImages:t=!0,fetchFeaturedWallets:e=!0,fetchRecommendedWallets:s=!0,fetchNetworkImages:r=!0}={}){const i=[t&&V.initPromise("connectorImages",V.fetchConnectorImages),e&&V.initPromise("featuredWallets",V.fetchFeaturedWallets),s&&V.initPromise("recommendedWallets",V.fetchRecommendedWallets),r&&V.initPromise("networkImages",V.fetchNetworkImages)].filter(Boolean);return Promise.allSettled(i)},prefetchAnalyticsConfig(){var t;(t=O.state.features)!=null&&t.analytics&&V.fetchAnalyticsConfig()},async fetchAnalyticsConfig(){try{const{isAnalyticsEnabled:t}=await rt.get({path:"/getAnalyticsConfig",params:V._getSdkProperties()});O.setFeatures({analytics:t})}catch{O.setFeatures({analytics:!1})}},filterByNamespaces(t){if(!(t!=null&&t.length)){te.featured=te.allFeatured,te.recommended=te.allRecommended;return}const e=p.getRequestedCaipNetworkIds().join(",");te.featured=te.allFeatured.filter(s=>{var r;return(r=s.chains)==null?void 0:r.some(i=>e.includes(i))}),te.recommended=te.allRecommended.filter(s=>{var r;return(r=s.chains)==null?void 0:r.some(i=>e.includes(i))}),te.filteredWallets=te.wallets.filter(s=>{var r;return(r=s.chains)==null?void 0:r.some(i=>e.includes(i))})},clearFilterByNamespaces(){te.filteredWallets=[]},setFilterByNamespace(t){if(!t){te.featured=te.allFeatured,te.recommended=te.allRecommended;return}const e=p.getRequestedCaipNetworkIds().join(",");te.featured=te.allFeatured.filter(s=>{var r;return(r=s.chains)==null?void 0:r.some(i=>e.includes(i))}),te.recommended=te.allRecommended.filter(s=>{var r;return(r=s.chains)==null?void 0:r.some(i=>e.includes(i))}),te.filteredWallets=te.wallets.filter(s=>{var r;return(r=s.chains)==null?void 0:r.some(i=>e.includes(i))})}},me=_e({view:"Connect",history:["Connect"],transactionStack:[]}),Vu={state:me,subscribeKey(t,e){return Qe(me,t,e)},pushTransactionStack(t){me.transactionStack.push(t)},popTransactionStack(t){const e=me.transactionStack.pop();if(!e)return;const{onSuccess:s,onError:r,onCancel:i}=e;switch(t){case"success":s==null||s();break;case"error":r==null||r(),re.goBack();break;case"cancel":i==null||i(),re.goBack();break}},push(t,e){t!==me.view&&(me.view=t,me.history.push(t),me.data=e)},reset(t,e){me.view=t,me.history=[t],me.data=e},replace(t,e){me.history.at(-1)===t||(me.view=t,me.history[me.history.length-1]=t,me.data=e)},goBack(){var r;const t=p.state.activeCaipAddress,e=re.state.view==="ConnectingFarcaster",s=!t&&e;if(me.history.length>1){me.history.pop();const[i]=me.history.slice(-1);i&&(t&&i==="Connect"?me.view="Account":me.view=i)}else We.close();(r=me.data)!=null&&r.wallet&&(me.data.wallet=void 0),setTimeout(()=>{var i,n,o;if(s){W.setFarcasterUrl(void 0,p.state.activeChain);const a=q.getAuthConnector();(i=a==null?void 0:a.provider)==null||i.reload();const c=yi(O.state);(o=(n=a==null?void 0:a.provider)==null?void 0:n.syncDappData)==null||o.call(n,{metadata:c.metadata,sdkVersion:c.sdkVersion,projectId:c.projectId,sdkType:c.sdkType})}},100)},goBackToIndex(t){if(me.history.length>1){me.history=me.history.slice(0,t+1);const[e]=me.history.slice(-1);e&&(me.view=e)}},goBackOrCloseModal(){re.state.history.length>1?re.goBack():We.close()}},re=vt(Vu),Qt=_e({themeMode:"dark",themeVariables:{},w3mThemeVariables:void 0}),ao={state:Qt,subscribe(t){return Xe(Qt,()=>t(Qt))},setThemeMode(t){Qt.themeMode=t;try{const e=q.getAuthConnector();if(e){const s=ao.getSnapshot().themeVariables;e.provider.syncTheme({themeMode:t,themeVariables:s,w3mThemeVariables:ys(s,t)})}}catch{console.info("Unable to sync theme to auth connector")}},setThemeVariables(t){Qt.themeVariables={...Qt.themeVariables,...t};try{const e=q.getAuthConnector();if(e){const s=ao.getSnapshot().themeVariables;e.provider.syncTheme({themeVariables:s,w3mThemeVariables:ys(Qt.themeVariables,Qt.themeMode)})}}catch{console.info("Unable to sync theme to auth connector")}},getSnapshot(){return yi(Qt)}},ft=vt(ao),Al={eip155:void 0,solana:void 0,polkadot:void 0,bip122:void 0,cosmos:void 0},ae=_e({allConnectors:[],connectors:[],activeConnector:void 0,filterByNamespace:void 0,activeConnectorIds:{...Al},filterByNamespaceMap:{eip155:!0,solana:!0,polkadot:!0,bip122:!0,cosmos:!0}}),Ku={state:ae,subscribe(t){return Xe(ae,()=>{t(ae)})},subscribeKey(t,e){return Qe(ae,t,e)},initialize(t){t.forEach(e=>{const s=F.getConnectedConnectorId(e);s&&q.setConnectorId(s,e)})},setActiveConnector(t){t&&(ae.activeConnector=Hs(t))},setConnectors(t){t.filter(i=>!ae.allConnectors.some(n=>n.id===i.id&&q.getConnectorName(n.name)===q.getConnectorName(i.name)&&n.chain===i.chain)).forEach(i=>{i.type!=="MULTI_CHAIN"&&ae.allConnectors.push(Hs(i))});const s=q.getEnabledNamespaces(),r=q.getEnabledConnectors(s);ae.connectors=q.mergeMultiChainConnectors(r)},filterByNamespaces(t){Object.keys(ae.filterByNamespaceMap).forEach(e=>{ae.filterByNamespaceMap[e]=!1}),t.forEach(e=>{ae.filterByNamespaceMap[e]=!0}),q.updateConnectorsForEnabledNamespaces()},filterByNamespace(t,e){ae.filterByNamespaceMap[t]=e,q.updateConnectorsForEnabledNamespaces()},updateConnectorsForEnabledNamespaces(){const t=q.getEnabledNamespaces(),e=q.getEnabledConnectors(t),s=q.areAllNamespacesEnabled();ae.connectors=q.mergeMultiChainConnectors(e),s?V.clearFilterByNamespaces():V.filterByNamespaces(t)},getEnabledNamespaces(){return Object.entries(ae.filterByNamespaceMap).filter(([t,e])=>e).map(([t])=>t)},getEnabledConnectors(t){return ae.allConnectors.filter(e=>t.includes(e.chain))},areAllNamespacesEnabled(){return Object.values(ae.filterByNamespaceMap).every(t=>t)},mergeMultiChainConnectors(t){const e=q.generateConnectorMapByName(t),s=[];return e.forEach(r=>{const i=r[0],n=(i==null?void 0:i.id)===z.CONNECTOR_ID.AUTH;r.length>1&&i?s.push({name:i.name,imageUrl:i.imageUrl,imageId:i.imageId,connectors:[...r],type:n?"AUTH":"MULTI_CHAIN",chain:"eip155",id:(i==null?void 0:i.id)||""}):i&&s.push(i)}),s},generateConnectorMapByName(t){const e=new Map;return t.forEach(s=>{const{name:r}=s,i=q.getConnectorName(r);if(!i)return;const n=e.get(i)||[];n.find(a=>a.chain===s.chain)||n.push(s),e.set(i,n)}),e},getConnectorName(t){return t&&({"Trust Wallet":"Trust"}[t]||t)},getUniqueConnectorsByName(t){const e=[];return t.forEach(s=>{e.find(r=>r.chain===s.chain)||e.push(s)}),e},addConnector(t){var e,s,r;if(t.id===z.CONNECTOR_ID.AUTH){const i=t,n=yi(O.state),o=ft.getSnapshot().themeMode,a=ft.getSnapshot().themeVariables;(s=(e=i==null?void 0:i.provider)==null?void 0:e.syncDappData)==null||s.call(e,{metadata:n.metadata,sdkVersion:n.sdkVersion,projectId:n.projectId,sdkType:n.sdkType}),(r=i==null?void 0:i.provider)==null||r.syncTheme({themeMode:o,themeVariables:a,w3mThemeVariables:ys(a,o)}),q.setConnectors([t])}else q.setConnectors([t])},getAuthConnector(t){var r;const e=t||p.state.activeChain,s=ae.connectors.find(i=>i.id===z.CONNECTOR_ID.AUTH);if(s)return(r=s==null?void 0:s.connectors)!=null&&r.length?s.connectors.find(n=>n.chain===e):s},getAnnouncedConnectorRdns(){return ae.connectors.filter(t=>t.type==="ANNOUNCED").map(t=>{var e;return(e=t.info)==null?void 0:e.rdns})},getConnectorById(t){return ae.allConnectors.find(e=>e.id===t)},getConnector(t,e){return ae.allConnectors.filter(r=>r.chain===p.state.activeChain).find(r=>{var i;return r.explorerId===t||((i=r.info)==null?void 0:i.rdns)===e})},syncIfAuthConnector(t){var n,o;if(t.id!=="ID_AUTH")return;const e=t,s=yi(O.state),r=ft.getSnapshot().themeMode,i=ft.getSnapshot().themeVariables;(o=(n=e==null?void 0:e.provider)==null?void 0:n.syncDappData)==null||o.call(n,{metadata:s.metadata,sdkVersion:s.sdkVersion,sdkType:s.sdkType,projectId:s.projectId}),e.provider.syncTheme({themeMode:r,themeVariables:i,w3mThemeVariables:ys(i,r)})},getConnectorsByNamespace(t){const e=ae.allConnectors.filter(s=>s.chain===t);return q.mergeMultiChainConnectors(e)},selectWalletConnector(t){const e=q.getConnector(t.id,t.rdns),s=p.state.activeChain;Du.handleMobileDeeplinkRedirect((e==null?void 0:e.explorerId)||t.id,s),e?re.push("ConnectingExternal",{connector:e}):re.push("ConnectingWalletConnect",{wallet:t})},getConnectors(t){return t?q.getConnectorsByNamespace(t):q.mergeMultiChainConnectors(ae.allConnectors)},setFilterByNamespace(t){ae.filterByNamespace=t,ae.connectors=q.getConnectors(t),V.setFilterByNamespace(t)},setConnectorId(t,e){t&&(ae.activeConnectorIds={...ae.activeConnectorIds,[e]:t},F.setConnectedConnectorId(e,t))},removeConnectorId(t){ae.activeConnectorIds={...ae.activeConnectorIds,[t]:void 0},F.deleteConnectedConnectorId(t)},getConnectorId(t){if(t)return ae.activeConnectorIds[t]},isConnected(t){return t?!!ae.activeConnectorIds[t]:Object.values(ae.activeConnectorIds).some(e=>!!e)},resetConnectorIds(){ae.activeConnectorIds={...Al}}},q=vt(Ku),ci={ACCOUNT_TYPES:{SMART_ACCOUNT:"smartAccount"}},xs=Object.freeze({message:"",variant:"success",svg:void 0,open:!1,autoClose:!0}),Ue=_e({...xs}),Gu={state:Ue,subscribeKey(t,e){return Qe(Ue,t,e)},showLoading(t,e={}){this._showMessage({message:t,variant:"loading",...e})},showSuccess(t){this._showMessage({message:t,variant:"success"})},showSvg(t,e){this._showMessage({message:t,svg:e})},showError(t){const e=Z.parseError(t);this._showMessage({message:e,variant:"error"})},hide(){Ue.message=xs.message,Ue.variant=xs.variant,Ue.svg=xs.svg,Ue.open=xs.open,Ue.autoClose=xs.autoClose},_showMessage({message:t,svg:e,variant:s="success",autoClose:r=xs.autoClose}){Ue.open?(Ue.open=!1,setTimeout(()=>{Ue.message=t,Ue.variant=s,Ue.svg=e,Ue.open=!0,Ue.autoClose=r},150)):(Ue.message=t,Ue.variant=s,Ue.svg=e,Ue.open=!0,Ue.autoClose=r)}},Ut=Gu,Ie=_e({transactions:[],coinbaseTransactions:{},transactionsByYear:{},lastNetworkInView:void 0,loading:!1,empty:!1,next:void 0}),Ju={state:Ie,subscribe(t){return Xe(Ie,()=>t(Ie))},setLastNetworkInView(t){Ie.lastNetworkInView=t},async fetchTransactions(t,e){var s,r;if(!t)throw new Error("Transactions can't be fetched without an accountAddress");Ie.loading=!0;try{const i=await J.fetchTransactions({account:t,cursor:Ie.next,onramp:e,cache:e==="coinbase"?"no-cache":void 0,chainId:(s=p.state.activeCaipNetwork)==null?void 0:s.caipNetworkId}),n=ri.filterSpamTransactions(i.data),o=ri.filterByConnectedChain(n),a=[...Ie.transactions,...o];Ie.loading=!1,e==="coinbase"?Ie.coinbaseTransactions=ri.groupTransactionsByYearAndMonth(Ie.coinbaseTransactions,i.data):(Ie.transactions=a,Ie.transactionsByYear=ri.groupTransactionsByYearAndMonth(Ie.transactionsByYear,o)),Ie.empty=a.length===0,Ie.next=i.next?i.next:void 0}catch{const n=p.state.activeChain;Pe.sendEvent({type:"track",event:"ERROR_FETCH_TRANSACTIONS",properties:{address:t,projectId:O.state.projectId,cursor:Ie.next,isSmartAccount:((r=W.state.preferredAccountTypes)==null?void 0:r[n])===ci.ACCOUNT_TYPES.SMART_ACCOUNT}}),Ut.showError("Failed to fetch transactions"),Ie.loading=!1,Ie.empty=!0,Ie.next=void 0}},groupTransactionsByYearAndMonth(t={},e=[]){const s=t;return e.forEach(r=>{const i=new Date(r.metadata.minedAt).getFullYear(),n=new Date(r.metadata.minedAt).getMonth(),o=s[i]??{},c=(o[n]??[]).filter(l=>l.id!==r.id);s[i]={...o,[n]:[...c,r].sort((l,h)=>new Date(h.metadata.minedAt).getTime()-new Date(l.metadata.minedAt).getTime())}}),s},filterSpamTransactions(t){return t.filter(e=>!e.transfers.every(r=>{var i;return((i=r.nft_info)==null?void 0:i.flags.is_spam)===!0}))},filterByConnectedChain(t){var r;const e=(r=p.state.activeCaipNetwork)==null?void 0:r.caipNetworkId;return t.filter(i=>i.metadata.chain===e)},clearCursor(){Ie.next=void 0},resetTransactions(){Ie.transactions=[],Ie.transactionsByYear={},Ie.lastNetworkInView=void 0,Ie.loading=!1,Ie.empty=!1,Ie.next=void 0}},ri=vt(Ju,"API_ERROR"),ye=_e({connections:new Map,wcError:!1,buffering:!1,status:"disconnected"});let Os;const Yu={state:ye,subscribeKey(t,e){return Qe(ye,t,e)},_getClient(){return ye._client},setClient(t){ye._client=Hs(t)},async connectWalletConnect(){var t,e,s,r;if(Z.isTelegram()||Z.isSafari()&&Z.isIos()){if(Os){await Os,Os=void 0;return}if(!Z.isPairingExpired(ye==null?void 0:ye.wcPairingExpiry)){const i=ye.wcUri;ye.wcUri=i;return}Os=(e=(t=Y._getClient())==null?void 0:t.connectWalletConnect)==null?void 0:e.call(t).catch(()=>{}),Y.state.status="connecting",await Os,Os=void 0,ye.wcPairingExpiry=void 0,Y.state.status="connected"}else await((r=(s=Y._getClient())==null?void 0:s.connectWalletConnect)==null?void 0:r.call(s))},async connectExternal(t,e,s=!0){var r,i;await((i=(r=Y._getClient())==null?void 0:r.connectExternal)==null?void 0:i.call(r,t)),s&&p.setActiveNamespace(e)},async reconnectExternal(t){var s,r;await((r=(s=Y._getClient())==null?void 0:s.reconnectExternal)==null?void 0:r.call(s,t));const e=t.chain||p.state.activeChain;e&&q.setConnectorId(t.id,e)},async setPreferredAccountType(t,e){var r;We.setLoading(!0,p.state.activeChain);const s=q.getAuthConnector();s&&(W.setPreferredAccountType(t,e),await s.provider.setPreferredAccount(t),F.setPreferredAccountTypes(W.state.preferredAccountTypes??{[e]:t}),await Y.reconnectExternal(s),We.setLoading(!1,p.state.activeChain),Pe.sendEvent({type:"track",event:"SET_PREFERRED_ACCOUNT_TYPE",properties:{accountType:t,network:((r=p.state.activeCaipNetwork)==null?void 0:r.caipNetworkId)||""}}))},async signMessage(t){var e;return(e=Y._getClient())==null?void 0:e.signMessage(t)},parseUnits(t,e){var s;return(s=Y._getClient())==null?void 0:s.parseUnits(t,e)},formatUnits(t,e){var s;return(s=Y._getClient())==null?void 0:s.formatUnits(t,e)},async sendTransaction(t){var e;return(e=Y._getClient())==null?void 0:e.sendTransaction(t)},async getCapabilities(t){var e;return(e=Y._getClient())==null?void 0:e.getCapabilities(t)},async grantPermissions(t){var e;return(e=Y._getClient())==null?void 0:e.grantPermissions(t)},async walletGetAssets(t){var e;return((e=Y._getClient())==null?void 0:e.walletGetAssets(t))??{}},async estimateGas(t){var e;return(e=Y._getClient())==null?void 0:e.estimateGas(t)},async writeContract(t){var e;return(e=Y._getClient())==null?void 0:e.writeContract(t)},async getEnsAddress(t){var e;return(e=Y._getClient())==null?void 0:e.getEnsAddress(t)},async getEnsAvatar(t){var e;return(e=Y._getClient())==null?void 0:e.getEnsAvatar(t)},checkInstalled(t){var e,s;return((s=(e=Y._getClient())==null?void 0:e.checkInstalled)==null?void 0:s.call(e,t))||!1},resetWcConnection(){ye.wcUri=void 0,ye.wcPairingExpiry=void 0,ye.wcLinking=void 0,ye.recentWallet=void 0,ye.status="disconnected",ri.resetTransactions(),F.deleteWalletConnectDeepLink()},resetUri(){ye.wcUri=void 0,ye.wcPairingExpiry=void 0,Os=void 0},finalizeWcConnection(){var s,r;const{wcLinking:t,recentWallet:e}=Y.state;t&&F.setWalletConnectDeepLink(t),e&&F.setAppKitRecent(e),Pe.sendEvent({type:"track",event:"CONNECT_SUCCESS",properties:{method:t?"mobile":"qrcode",name:((r=(s=re.state.data)==null?void 0:s.wallet)==null?void 0:r.name)||"Unknown"}})},setWcBasic(t){ye.wcBasic=t},setUri(t){ye.wcUri=t,ye.wcPairingExpiry=Z.getPairingExpiry()},setWcLinking(t){ye.wcLinking=t},setWcError(t){ye.wcError=t,ye.buffering=!1},setRecentWallet(t){ye.recentWallet=t},setBuffering(t){ye.buffering=t},setStatus(t){ye.status=t},async disconnect(t){var e;try{await((e=Y._getClient())==null?void 0:e.disconnect(t))}catch(s){throw new Tr("Failed to disconnect","INTERNAL_SDK_ERROR",s)}},setConnections(t,e){ye.connections.set(e,t)},switchAccount({connection:t,address:e,namespace:s}){if(q.state.activeConnectorIds[s]===t.connectorId){const n=p.state.activeCaipNetwork;if(n){const o=`${s}:${n.id}:${e}`;W.setCaipAddress(o,s)}else console.warn(`No current network found for namespace "${s}"`)}else{const n=q.getConnector(t.connectorId);n?Y.connectExternal(n,s):console.warn(`No connector found for namespace "${s}"`)}}},Y=vt(Yu),sr=_e({loading:!1,open:!1,selectedNetworkId:void 0,activeChain:void 0,initialized:!1}),vs={state:sr,subscribe(t){return Xe(sr,()=>t(sr))},subscribeOpen(t){return Qe(sr,"open",t)},set(t){Object.assign(sr,{...sr,...t})}},Tn={createBalance(t,e){const s={name:t.metadata.name||"",symbol:t.metadata.symbol||"",decimals:t.metadata.decimals||0,value:t.metadata.value||0,price:t.metadata.price||0,iconUrl:t.metadata.iconUrl||""};return{name:s.name,symbol:s.symbol,chainId:e,address:t.address==="native"?void 0:this.convertAddressToCAIP10Address(t.address,e),value:s.value,price:s.price,quantity:{decimals:s.decimals.toString(),numeric:this.convertHexToBalance({hex:t.balance,decimals:s.decimals})},iconUrl:s.iconUrl}},convertHexToBalance({hex:t,decimals:e}){return Xh(BigInt(t),e)},convertAddressToCAIP10Address(t,e){return`${e}:${t}`},createCAIP2ChainId(t,e){return`${e}:${parseInt(t,16)}`},getChainIdHexFromCAIP2ChainId(t){const e=t.split(":");if(e.length<2||!e[1])return"0x0";const s=e[1],r=parseInt(s,10);return isNaN(r)?"0x0":`0x${r.toString(16)}`},isWalletGetAssetsResponse(t){return typeof t!="object"||t===null?!1:Object.values(t).every(e=>Array.isArray(e)&&e.every(s=>this.isValidAsset(s)))},isValidAsset(t){return typeof t=="object"&&t!==null&&typeof t.address=="string"&&typeof t.balance=="string"&&(t.type==="ERC20"||t.type==="NATIVE")&&typeof t.metadata=="object"&&t.metadata!==null&&typeof t.metadata.name=="string"&&typeof t.metadata.symbol=="string"&&typeof t.metadata.decimals=="number"&&typeof t.metadata.price=="number"&&typeof t.metadata.iconUrl=="string"}},ma={async getMyTokensWithBalance(t){const e=W.state.address,s=p.state.activeCaipNetwork;if(!e||!s)return[];if(s.chainNamespace==="eip155"){const i=await this.getEIP155Balances(e,s);if(i)return this.filterLowQualityTokens(i)}const r=await J.getBalance(e,s.caipNetworkId,t);return this.filterLowQualityTokens(r.balances)},async getEIP155Balances(t,e){var s,r;try{const i=Tn.getChainIdHexFromCAIP2ChainId(e.caipNetworkId),n=await Y.getCapabilities(t);if(!((r=(s=n==null?void 0:n[i])==null?void 0:s.assetDiscovery)!=null&&r.supported))return null;const o=await Y.walletGetAssets({account:t,chainFilter:[i]});return Tn.isWalletGetAssetsResponse(o)?(o[i]||[]).map(c=>Tn.createBalance(c,e.caipNetworkId)):null}catch{return null}},filterLowQualityTokens(t){return t.filter(e=>e.quantity.decimals!=="0")},mapBalancesToSwapTokens(t){return(t==null?void 0:t.map(e=>({...e,address:e!=null&&e.address?e.address:p.getActiveNetworkTokenAddress(),decimals:parseInt(e.quantity.decimals,10),logoUri:e.iconUrl,eip2612:!1})))||[]}},fe=_e({tokenBalances:[],loading:!1}),Zu={state:fe,subscribe(t){return Xe(fe,()=>t(fe))},subscribeKey(t,e){return Qe(fe,t,e)},setToken(t){t&&(fe.token=Hs(t))},setTokenAmount(t){fe.sendTokenAmount=t},setReceiverAddress(t){fe.receiverAddress=t},setReceiverProfileImageUrl(t){fe.receiverProfileImageUrl=t},setReceiverProfileName(t){fe.receiverProfileName=t},setNetworkBalanceInUsd(t){fe.networkBalanceInUSD=t},setLoading(t){fe.loading=t},async sendToken(){var t;try{switch(ue.setLoading(!0),(t=p.state.activeCaipNetwork)==null?void 0:t.chainNamespace){case"eip155":await ue.sendEvmToken();return;case"solana":await ue.sendSolanaToken();return;default:throw new Error("Unsupported chain")}}finally{ue.setLoading(!1)}},async sendEvmToken(){var s,r,i,n;const t=p.state.activeChain,e=(s=W.state.preferredAccountTypes)==null?void 0:s[t];if(!ue.state.sendTokenAmount||!ue.state.receiverAddress)throw new Error("An amount and receiver address are required");if(!ue.state.token)throw new Error("A token is required");(r=ue.state.token)!=null&&r.address?(Pe.sendEvent({type:"track",event:"SEND_INITIATED",properties:{isSmartAccount:e===ci.ACCOUNT_TYPES.SMART_ACCOUNT,token:ue.state.token.address,amount:ue.state.sendTokenAmount,network:((i=p.state.activeCaipNetwork)==null?void 0:i.caipNetworkId)||""}}),await ue.sendERC20Token({receiverAddress:ue.state.receiverAddress,tokenAddress:ue.state.token.address,sendTokenAmount:ue.state.sendTokenAmount,decimals:ue.state.token.quantity.decimals})):(Pe.sendEvent({type:"track",event:"SEND_INITIATED",properties:{isSmartAccount:e===ci.ACCOUNT_TYPES.SMART_ACCOUNT,token:ue.state.token.symbol||"",amount:ue.state.sendTokenAmount,network:((n=p.state.activeCaipNetwork)==null?void 0:n.caipNetworkId)||""}}),await ue.sendNativeToken({receiverAddress:ue.state.receiverAddress,sendTokenAmount:ue.state.sendTokenAmount,decimals:ue.state.token.quantity.decimals}))},async fetchTokenBalance(t){var n,o;fe.loading=!0;const e=(n=p.state.activeCaipNetwork)==null?void 0:n.caipNetworkId,s=(o=p.state.activeCaipNetwork)==null?void 0:o.chainNamespace,r=p.state.activeCaipAddress,i=r?Z.getPlainAddress(r):void 0;if(fe.lastRetry&&!Z.isAllowedRetry(fe.lastRetry,30*Ee.ONE_SEC_MS))return fe.loading=!1,[];try{if(i&&e&&s){const a=await ma.getMyTokensWithBalance();return fe.tokenBalances=a,fe.lastRetry=void 0,a}}catch(a){fe.lastRetry=Date.now(),t==null||t(a),Ut.showError("Token Balance Unavailable")}finally{fe.loading=!1}return[]},fetchNetworkBalance(){if(fe.tokenBalances.length===0)return;const t=ma.mapBalancesToSwapTokens(fe.tokenBalances);if(!t)return;const e=t.find(s=>s.address===p.getActiveNetworkTokenAddress());e&&(fe.networkBalanceInUSD=e?yu.multiply(e.quantity.numeric,e.price).toString():"0")},async sendNativeToken(t){var n,o,a,c;re.pushTransactionStack({});const e=t.receiverAddress,s=W.state.address,r=Y.parseUnits(t.sendTokenAmount.toString(),Number(t.decimals));await Y.sendTransaction({chainNamespace:"eip155",to:e,address:s,data:"0x",value:r??BigInt(0)}),Pe.sendEvent({type:"track",event:"SEND_SUCCESS",properties:{isSmartAccount:((n=W.state.preferredAccountTypes)==null?void 0:n.eip155)===ci.ACCOUNT_TYPES.SMART_ACCOUNT,token:((o=ue.state.token)==null?void 0:o.symbol)||"",amount:t.sendTokenAmount,network:((a=p.state.activeCaipNetwork)==null?void 0:a.caipNetworkId)||""}}),(c=Y._getClient())==null||c.updateBalance("eip155"),ue.resetSend()},async sendERC20Token(t){re.pushTransactionStack({onSuccess(){re.replace("Account")}});const e=Y.parseUnits(t.sendTokenAmount.toString(),Number(t.decimals));if(W.state.address&&t.sendTokenAmount&&t.receiverAddress&&t.tokenAddress){const s=Z.getPlainAddress(t.tokenAddress);await Y.writeContract({fromAddress:W.state.address,tokenAddress:s,args:[t.receiverAddress,e??BigInt(0)],method:"transfer",abi:Cu.getERC20Abi(s),chainNamespace:"eip155"}),ue.resetSend()}},async sendSolanaToken(){var t;if(!ue.state.sendTokenAmount||!ue.state.receiverAddress)throw new Error("An amount and receiver address are required");re.pushTransactionStack({onSuccess(){re.replace("Account")}}),await Y.sendTransaction({chainNamespace:"solana",to:ue.state.receiverAddress,value:ue.state.sendTokenAmount}),(t=Y._getClient())==null||t.updateBalance("solana"),ue.resetSend()},resetSend(){fe.token=void 0,fe.sendTokenAmount=void 0,fe.receiverAddress=void 0,fe.receiverProfileImageUrl=void 0,fe.receiverProfileName=void 0,fe.loading=!1,fe.tokenBalances=[]}},ue=vt(Zu),kn={currentTab:0,tokenBalance:[],smartAccountDeployed:!1,addressLabels:new Map,allAccounts:[],user:void 0},ji={caipNetwork:void 0,supportsAllNetworks:!0,smartAccountEnabledNetworks:[]},M=_e({chains:Pu(),activeCaipAddress:void 0,activeChain:void 0,activeCaipNetwork:void 0,noAdapters:!1,universalAdapter:{networkControllerClient:void 0,connectionControllerClient:void 0},isSwitchingNamespace:!1}),Xu={state:M,subscribe(t){return Xe(M,()=>{t(M)})},subscribeKey(t,e){return Qe(M,t,e)},subscribeChainProp(t,e,s){let r;return Xe(M.chains,()=>{var n;const i=s||M.activeChain;if(i){const o=(n=M.chains.get(i))==null?void 0:n[t];r!==o&&(r=o,e(o))}})},initialize(t,e,s){const{chainId:r,namespace:i}=F.getActiveNetworkProps(),n=e==null?void 0:e.find(h=>h.id.toString()===(r==null?void 0:r.toString())),a=t.find(h=>(h==null?void 0:h.namespace)===i)||(t==null?void 0:t[0]),c=t.map(h=>h.namespace).filter(h=>h!==void 0),l=O.state.enableEmbedded?new Set([...c]):new Set([...(e==null?void 0:e.map(h=>h.chainNamespace))??[]]);((t==null?void 0:t.length)===0||!a)&&(M.noAdapters=!0),M.noAdapters||(M.activeChain=a==null?void 0:a.namespace,M.activeCaipNetwork=n,p.setChainNetworkData(a==null?void 0:a.namespace,{caipNetwork:n}),M.activeChain&&vs.set({activeChain:a==null?void 0:a.namespace})),l.forEach(h=>{const u=e==null?void 0:e.filter(d=>d.chainNamespace===h);p.state.chains.set(h,{namespace:h,networkState:_e({...ji,caipNetwork:u==null?void 0:u[0]}),accountState:_e(kn),caipNetworks:u??[],...s}),p.setRequestedCaipNetworks(u??[],h)})},removeAdapter(t){var e,s;if(M.activeChain===t){const r=Array.from(M.chains.entries()).find(([i])=>i!==t);if(r){const i=(s=(e=r[1])==null?void 0:e.caipNetworks)==null?void 0:s[0];i&&p.setActiveCaipNetwork(i)}}M.chains.delete(t)},addAdapter(t,{networkControllerClient:e,connectionControllerClient:s},r){M.chains.set(t.namespace,{namespace:t.namespace,networkState:{...ji,caipNetwork:r[0]},accountState:kn,caipNetworks:r,connectionControllerClient:s,networkControllerClient:e}),p.setRequestedCaipNetworks((r==null?void 0:r.filter(i=>i.chainNamespace===t.namespace))??[],t.namespace)},addNetwork(t){var s;const e=M.chains.get(t.chainNamespace);if(e){const r=[...e.caipNetworks||[]];(s=e.caipNetworks)!=null&&s.find(i=>i.id===t.id)||r.push(t),M.chains.set(t.chainNamespace,{...e,caipNetworks:r}),p.setRequestedCaipNetworks(r,t.chainNamespace),q.filterByNamespace(t.chainNamespace,!0)}},removeNetwork(t,e){var r,i,n;const s=M.chains.get(t);if(s){const o=((r=M.activeCaipNetwork)==null?void 0:r.id)===e,a=[...((i=s.caipNetworks)==null?void 0:i.filter(c=>c.id!==e))||[]];o&&((n=s==null?void 0:s.caipNetworks)!=null&&n[0])&&p.setActiveCaipNetwork(s.caipNetworks[0]),M.chains.set(t,{...s,caipNetworks:a}),p.setRequestedCaipNetworks(a||[],t),a.length===0&&q.filterByNamespace(t,!1)}},setAdapterNetworkState(t,e){const s=M.chains.get(t);s&&(s.networkState={...s.networkState||ji,...e},M.chains.set(t,s))},setChainAccountData(t,e,s=!0){if(!t)throw new Error("Chain is required to update chain account data");const r=M.chains.get(t);if(r){const i={...r.accountState||kn,...e};M.chains.set(t,{...r,accountState:i}),(M.chains.size===1||M.activeChain===t)&&(e.caipAddress&&(M.activeCaipAddress=e.caipAddress),W.replaceState(i))}},setChainNetworkData(t,e){if(!t)return;const s=M.chains.get(t);if(s){const r={...s.networkState||ji,...e};M.chains.set(t,{...s,networkState:r})}},setAccountProp(t,e,s,r=!0){p.setChainAccountData(s,{[t]:e},r),t==="status"&&e==="disconnected"&&s&&q.removeConnectorId(s)},setActiveNamespace(t){var r,i;M.activeChain=t;const e=t?M.chains.get(t):void 0,s=(r=e==null?void 0:e.networkState)==null?void 0:r.caipNetwork;s!=null&&s.id&&t&&(M.activeCaipAddress=(i=e==null?void 0:e.accountState)==null?void 0:i.caipAddress,M.activeCaipNetwork=s,p.setChainNetworkData(t,{caipNetwork:s}),F.setActiveCaipNetworkId(s==null?void 0:s.caipNetworkId),vs.set({activeChain:t,selectedNetworkId:s==null?void 0:s.caipNetworkId}))},setActiveCaipNetwork(t){var r,i,n;if(!t)return;M.activeChain!==t.chainNamespace&&p.setIsSwitchingNamespace(!0);const e=M.chains.get(t.chainNamespace);M.activeChain=t.chainNamespace,M.activeCaipNetwork=t,p.setChainNetworkData(t.chainNamespace,{caipNetwork:t}),(r=e==null?void 0:e.accountState)!=null&&r.address?M.activeCaipAddress=`${t.chainNamespace}:${t.id}:${(i=e==null?void 0:e.accountState)==null?void 0:i.address}`:M.activeCaipAddress=void 0,p.setAccountProp("caipAddress",M.activeCaipAddress,t.chainNamespace),e&&W.replaceState(e.accountState),ue.resetSend(),vs.set({activeChain:M.activeChain,selectedNetworkId:(n=M.activeCaipNetwork)==null?void 0:n.caipNetworkId}),F.setActiveCaipNetworkId(t.caipNetworkId),!p.checkIfSupportedNetwork(t.chainNamespace)&&O.state.enableNetworkSwitch&&!O.state.allowUnsupportedChain&&!Y.state.wcBasic&&p.showUnsupportedChainUI()},addCaipNetwork(t){var s;if(!t)return;const e=M.chains.get(t.chainNamespace);e&&((s=e==null?void 0:e.caipNetworks)==null||s.push(t))},async switchActiveNamespace(t){var i;if(!t)return;const e=t!==p.state.activeChain,s=(i=p.getNetworkData(t))==null?void 0:i.caipNetwork,r=p.getCaipNetworkByNamespace(t,s==null?void 0:s.id);e&&r&&await p.switchActiveNetwork(r)},async switchActiveNetwork(t){var i;const e=p.state.chains.get(p.state.activeChain),s=!((i=e==null?void 0:e.caipNetworks)!=null&&i.some(n=>{var o;return n.id===((o=M.activeCaipNetwork)==null?void 0:o.id)})),r=p.getNetworkControllerClient(t.chainNamespace);if(r){try{await r.switchCaipNetwork(t),s&&We.close()}catch{re.goBack()}Pe.sendEvent({type:"track",event:"SWITCH_NETWORK",properties:{network:t.caipNetworkId}})}},getNetworkControllerClient(t){const e=t||M.activeChain,s=M.chains.get(e);if(!s)throw new Error("Chain adapter not found");if(!s.networkControllerClient)throw new Error("NetworkController client not set");return s.networkControllerClient},getConnectionControllerClient(t){const e=t||M.activeChain;if(!e)throw new Error("Chain is required to get connection controller client");const s=M.chains.get(e);if(!(s!=null&&s.connectionControllerClient))throw new Error("ConnectionController client not set");return s.connectionControllerClient},getAccountProp(t,e){var i;let s=M.activeChain;if(e&&(s=e),!s)return;const r=(i=M.chains.get(s))==null?void 0:i.accountState;if(r)return r[t]},getNetworkProp(t,e){var r;const s=(r=M.chains.get(e))==null?void 0:r.networkState;if(s)return s[t]},getRequestedCaipNetworks(t){const e=M.chains.get(t),{approvedCaipNetworkIds:s=[],requestedCaipNetworks:r=[]}=(e==null?void 0:e.networkState)||{};return Z.sortRequestedNetworks(s,r)},getAllRequestedCaipNetworks(){const t=[];return M.chains.forEach(e=>{const s=p.getRequestedCaipNetworks(e.namespace);t.push(...s)}),t},setRequestedCaipNetworks(t,e){p.setAdapterNetworkState(e,{requestedCaipNetworks:t});const r=p.getAllRequestedCaipNetworks().map(n=>n.chainNamespace),i=Array.from(new Set(r));q.filterByNamespaces(i)},getAllApprovedCaipNetworkIds(){const t=[];return M.chains.forEach(e=>{const s=p.getApprovedCaipNetworkIds(e.namespace);t.push(...s)}),t},getActiveCaipNetwork(){return M.activeCaipNetwork},getActiveCaipAddress(){return M.activeCaipAddress},getApprovedCaipNetworkIds(t){var r;const e=M.chains.get(t);return((r=e==null?void 0:e.networkState)==null?void 0:r.approvedCaipNetworkIds)||[]},async setApprovedCaipNetworksData(t){const e=p.getNetworkControllerClient(),s=await(e==null?void 0:e.getApprovedCaipNetworksData());p.setAdapterNetworkState(t,{approvedCaipNetworkIds:s==null?void 0:s.approvedCaipNetworkIds,supportsAllNetworks:s==null?void 0:s.supportsAllNetworks})},checkIfSupportedNetwork(t,e){const s=e||M.activeCaipNetwork,r=p.getRequestedCaipNetworks(t);return r.length?r==null?void 0:r.some(i=>i.id===(s==null?void 0:s.id)):!0},checkIfSupportedChainId(t){if(!M.activeChain)return!0;const e=p.getRequestedCaipNetworks(M.activeChain);return e==null?void 0:e.some(s=>s.id===t)},setSmartAccountEnabledNetworks(t,e){p.setAdapterNetworkState(e,{smartAccountEnabledNetworks:t})},checkIfSmartAccountEnabled(){var r;const t=bl.caipNetworkIdToNumber((r=M.activeCaipNetwork)==null?void 0:r.caipNetworkId),e=M.activeChain;if(!e||!t)return!1;const s=p.getNetworkProp("smartAccountEnabledNetworks",e);return!!(s!=null&&s.includes(Number(t)))},getActiveNetworkTokenAddress(){var r,i;const t=((r=M.activeCaipNetwork)==null?void 0:r.chainNamespace)||"eip155",e=((i=M.activeCaipNetwork)==null?void 0:i.id)||1,s=Ee.NATIVE_TOKEN_ADDRESS[t];return`${t}:${e}:${s}`},showUnsupportedChainUI(){We.open({view:"UnsupportedChain"})},checkIfNamesSupported(){const t=M.activeCaipNetwork;return!!(t!=null&&t.chainNamespace&&Ee.NAMES_SUPPORTED_CHAIN_NAMESPACES.includes(t.chainNamespace))},resetNetwork(t){p.setAdapterNetworkState(t,{approvedCaipNetworkIds:void 0,supportsAllNetworks:!0,smartAccountEnabledNetworks:[]})},resetAccount(t){const e=t;if(!e)throw new Error("Chain is required to set account prop");M.activeCaipAddress=void 0,p.setChainAccountData(e,{smartAccountDeployed:!1,currentTab:0,caipAddress:void 0,address:void 0,balance:void 0,balanceSymbol:void 0,profileName:void 0,profileImage:void 0,addressExplorerUrl:void 0,tokenBalance:[],connectedWalletInfo:void 0,preferredAccountTypes:void 0,socialProvider:void 0,socialWindow:void 0,farcasterUrl:void 0,allAccounts:[],user:void 0,status:"disconnected"}),q.removeConnectorId(e)},setIsSwitchingNamespace(t){M.isSwitchingNamespace=t},getFirstCaipNetworkSupportsAuthConnector(){var s,r;const t=[];let e;if(M.chains.forEach(i=>{z.AUTH_CONNECTOR_SUPPORTED_CHAINS.find(n=>n===i.namespace)&&i.namespace&&t.push(i.namespace)}),t.length>0){const i=t[0];return e=i?(r=(s=M.chains.get(i))==null?void 0:s.caipNetworks)==null?void 0:r[0]:void 0,e}},getAccountData(t){var e;return t?(e=p.state.chains.get(t))==null?void 0:e.accountState:W.state},getNetworkData(t){var s;const e=t||M.activeChain;if(e)return(s=p.state.chains.get(e))==null?void 0:s.networkState},getCaipNetworkByNamespace(t,e){var i,n,o;if(!t)return;const s=p.state.chains.get(t),r=(i=s==null?void 0:s.caipNetworks)==null?void 0:i.find(a=>a.id===e);return r||((n=s==null?void 0:s.networkState)==null?void 0:n.caipNetwork)||((o=s==null?void 0:s.caipNetworks)==null?void 0:o[0])},getRequestedCaipNetworkIds(){const t=q.state.filterByNamespace;return(t?[M.chains.get(t)]:Array.from(M.chains.values())).flatMap(s=>(s==null?void 0:s.caipNetworks)||[]).map(s=>s.caipNetworkId)},getCaipNetworks(t){return t?p.getRequestedCaipNetworks(t):p.getAllRequestedCaipNetworks()}},p=vt(Xu),Qu={purchaseCurrencies:[{id:"2b92315d-eab7-5bef-84fa-089a131333f5",name:"USD Coin",symbol:"USDC",networks:[{name:"ethereum-mainnet",display_name:"Ethereum",chain_id:"1",contract_address:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"},{name:"polygon-mainnet",display_name:"Polygon",chain_id:"137",contract_address:"0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174"}]},{id:"2b92315d-eab7-5bef-84fa-089a131333f5",name:"Ether",symbol:"ETH",networks:[{name:"ethereum-mainnet",display_name:"Ethereum",chain_id:"1",contract_address:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"},{name:"polygon-mainnet",display_name:"Polygon",chain_id:"137",contract_address:"0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174"}]}],paymentCurrencies:[{id:"USD",payment_method_limits:[{id:"card",min:"10.00",max:"7500.00"},{id:"ach_bank_account",min:"10.00",max:"25000.00"}]},{id:"EUR",payment_method_limits:[{id:"card",min:"10.00",max:"7500.00"},{id:"ach_bank_account",min:"10.00",max:"25000.00"}]}]},Nl=Z.getBlockchainApiUrl(),it=_e({clientId:null,api:new Oi({baseUrl:Nl,clientId:null}),supportedChains:{http:[],ws:[]}}),J={state:it,async get(t){const{st:e,sv:s}=J.getSdkProperties(),r=O.state.projectId,i={...t.params||{},st:e,sv:s,projectId:r};return it.api.get({...t,params:i})},getSdkProperties(){const{sdkType:t,sdkVersion:e}=O.state;return{st:t||"unknown",sv:e||"unknown"}},async isNetworkSupported(t){if(!t)return!1;try{it.supportedChains.http.length||await J.getSupportedNetworks()}catch{return!1}return it.supportedChains.http.includes(t)},async getSupportedNetworks(){try{const t=await J.get({path:"v1/supported-chains"});return it.supportedChains=t,t}catch{return it.supportedChains}},async fetchIdentity({address:t,caipNetworkId:e}){if(!await J.isNetworkSupported(e))return{avatar:"",name:""};const r=F.getIdentityFromCacheForAddress(t);if(r)return r;const i=await J.get({path:`/v1/identity/${t}`,params:{sender:p.state.activeCaipAddress?Z.getPlainAddress(p.state.activeCaipAddress):void 0}});return F.updateIdentityCache({address:t,identity:i,timestamp:Date.now()}),i},async fetchTransactions({account:t,cursor:e,onramp:s,signal:r,cache:i,chainId:n}){var a;return await J.isNetworkSupported((a=p.state.activeCaipNetwork)==null?void 0:a.caipNetworkId)?J.get({path:`/v1/account/${t}/history`,params:{cursor:e,onramp:s,chainId:n},signal:r,cache:i}):{data:[],next:void 0}},async fetchSwapQuote({amount:t,userAddress:e,from:s,to:r,gasPrice:i}){var o;return await J.isNetworkSupported((o=p.state.activeCaipNetwork)==null?void 0:o.caipNetworkId)?J.get({path:"/v1/convert/quotes",headers:{"Content-Type":"application/json"},params:{amount:t,userAddress:e,from:s,to:r,gasPrice:i}}):{quotes:[]}},async fetchSwapTokens({chainId:t}){var s;return await J.isNetworkSupported((s=p.state.activeCaipNetwork)==null?void 0:s.caipNetworkId)?J.get({path:"/v1/convert/tokens",params:{chainId:t}}):{tokens:[]}},async fetchTokenPrice({addresses:t}){var s;return await J.isNetworkSupported((s=p.state.activeCaipNetwork)==null?void 0:s.caipNetworkId)?it.api.post({path:"/v1/fungible/price",body:{currency:"usd",addresses:t,projectId:O.state.projectId},headers:{"Content-Type":"application/json"}}):{fungibles:[]}},async fetchSwapAllowance({tokenAddress:t,userAddress:e}){var r;return await J.isNetworkSupported((r=p.state.activeCaipNetwork)==null?void 0:r.caipNetworkId)?J.get({path:"/v1/convert/allowance",params:{tokenAddress:t,userAddress:e},headers:{"Content-Type":"application/json"}}):{allowance:"0"}},async fetchGasPrice({chainId:t}){var i;const{st:e,sv:s}=J.getSdkProperties();if(!await J.isNetworkSupported((i=p.state.activeCaipNetwork)==null?void 0:i.caipNetworkId))throw new Error("Network not supported for Gas Price");return J.get({path:"/v1/convert/gas-price",headers:{"Content-Type":"application/json"},params:{chainId:t,st:e,sv:s}})},async generateSwapCalldata({amount:t,from:e,to:s,userAddress:r,disableEstimate:i}){var o;if(!await J.isNetworkSupported((o=p.state.activeCaipNetwork)==null?void 0:o.caipNetworkId))throw new Error("Network not supported for Swaps");return it.api.post({path:"/v1/convert/build-transaction",headers:{"Content-Type":"application/json"},body:{amount:t,eip155:{slippage:Ee.CONVERT_SLIPPAGE_TOLERANCE},projectId:O.state.projectId,from:e,to:s,userAddress:r,disableEstimate:i}})},async generateApproveCalldata({from:t,to:e,userAddress:s}){var o;const{st:r,sv:i}=J.getSdkProperties();if(!await J.isNetworkSupported((o=p.state.activeCaipNetwork)==null?void 0:o.caipNetworkId))throw new Error("Network not supported for Swaps");return J.get({path:"/v1/convert/build-approve",headers:{"Content-Type":"application/json"},params:{userAddress:s,from:t,to:e,st:r,sv:i}})},async getBalance(t,e,s){var l;const{st:r,sv:i}=J.getSdkProperties();if(!await J.isNetworkSupported((l=p.state.activeCaipNetwork)==null?void 0:l.caipNetworkId))return Ut.showError("Token Balance Unavailable"),{balances:[]};const o=`${e}:${t}`,a=F.getBalanceCacheForCaipAddress(o);if(a)return a;const c=await J.get({path:`/v1/account/${t}/balance`,params:{currency:"usd",chainId:e,forceUpdate:s,st:r,sv:i}});return F.updateBalanceCache({caipAddress:o,balance:c,timestamp:Date.now()}),c},async lookupEnsName(t){var s;return await J.isNetworkSupported((s=p.state.activeCaipNetwork)==null?void 0:s.caipNetworkId)?J.get({path:`/v1/profile/account/${t}`,params:{apiVersion:"2"}}):{addresses:{},attributes:[]}},async reverseLookupEnsName({address:t}){var s;return await J.isNetworkSupported((s=p.state.activeCaipNetwork)==null?void 0:s.caipNetworkId)?J.get({path:`/v1/profile/reverse/${t}`,params:{sender:W.state.address,apiVersion:"2"}}):[]},async getEnsNameSuggestions(t){var s;return await J.isNetworkSupported((s=p.state.activeCaipNetwork)==null?void 0:s.caipNetworkId)?J.get({path:`/v1/profile/suggestions/${t}`,params:{zone:"reown.id"}}):{suggestions:[]}},async registerEnsName({coinType:t,address:e,message:s,signature:r}){var n;return await J.isNetworkSupported((n=p.state.activeCaipNetwork)==null?void 0:n.caipNetworkId)?it.api.post({path:"/v1/profile/account",body:{coin_type:t,address:e,message:s,signature:r},headers:{"Content-Type":"application/json"}}):{success:!1}},async generateOnRampURL({destinationWallets:t,partnerUserId:e,defaultNetwork:s,purchaseAmount:r,paymentAmount:i}){var a;return await J.isNetworkSupported((a=p.state.activeCaipNetwork)==null?void 0:a.caipNetworkId)?(await it.api.post({path:"/v1/generators/onrampurl",params:{projectId:O.state.projectId},body:{destinationWallets:t,defaultNetwork:s,partnerUserId:e,defaultExperience:"buy",presetCryptoAmount:r,presetFiatAmount:i}})).url:""},async getOnrampOptions(){var e;if(!await J.isNetworkSupported((e=p.state.activeCaipNetwork)==null?void 0:e.caipNetworkId))return{paymentCurrencies:[],purchaseCurrencies:[]};try{return await J.get({path:"/v1/onramp/options"})}catch{return Qu}},async getOnrampQuote({purchaseCurrency:t,paymentCurrency:e,amount:s,network:r}){var i;try{return await J.isNetworkSupported((i=p.state.activeCaipNetwork)==null?void 0:i.caipNetworkId)?await it.api.post({path:"/v1/onramp/quote",params:{projectId:O.state.projectId},body:{purchaseCurrency:t,paymentCurrency:e,amount:s,network:r}}):null}catch{return{coinbaseFee:{amount:s,currency:e.id},networkFee:{amount:s,currency:e.id},paymentSubtotal:{amount:s,currency:e.id},paymentTotal:{amount:s,currency:e.id},purchaseAmount:{amount:s,currency:e.id},quoteId:"mocked-quote-id"}}},async getSmartSessions(t){var s;return await J.isNetworkSupported((s=p.state.activeCaipNetwork)==null?void 0:s.caipNetworkId)?J.get({path:`/v1/sessions/${t}`}):[]},async revokeSmartSession(t,e,s){var i;return await J.isNetworkSupported((i=p.state.activeCaipNetwork)==null?void 0:i.caipNetworkId)?it.api.post({path:`/v1/sessions/${t}/revoke`,params:{projectId:O.state.projectId},body:{pci:e,signature:s}}):{success:!1}},setClientId(t){it.clientId=t,it.api=new Oi({baseUrl:Nl,clientId:t})}},Et=_e({currentTab:0,tokenBalance:[],smartAccountDeployed:!1,addressLabels:new Map,allAccounts:[]}),ed={state:Et,replaceState(t){t&&Object.assign(Et,Hs(t))},subscribe(t){return p.subscribeChainProp("accountState",e=>{if(e)return t(e)})},subscribeKey(t,e,s){let r;return p.subscribeChainProp("accountState",i=>{if(i){const n=i[t];r!==n&&(r=n,e(n))}},s)},setStatus(t,e){p.setAccountProp("status",t,e)},getCaipAddress(t){return p.getAccountProp("caipAddress",t)},setCaipAddress(t,e){const s=t?Z.getPlainAddress(t):void 0;e===p.state.activeChain&&(p.state.activeCaipAddress=t),p.setAccountProp("caipAddress",t,e),p.setAccountProp("address",s,e)},setBalance(t,e,s){p.setAccountProp("balance",t,s),p.setAccountProp("balanceSymbol",e,s)},setProfileName(t,e){p.setAccountProp("profileName",t,e)},setProfileImage(t,e){p.setAccountProp("profileImage",t,e)},setUser(t,e){p.setAccountProp("user",t,e)},setAddressExplorerUrl(t,e){p.setAccountProp("addressExplorerUrl",t,e)},setSmartAccountDeployed(t,e){p.setAccountProp("smartAccountDeployed",t,e)},setCurrentTab(t){p.setAccountProp("currentTab",t,p.state.activeChain)},setTokenBalance(t,e){t&&p.setAccountProp("tokenBalance",t,e)},setShouldUpdateToAddress(t,e){p.setAccountProp("shouldUpdateToAddress",t,e)},setAllAccounts(t,e){p.setAccountProp("allAccounts",t,e)},addAddressLabel(t,e,s){const r=p.getAccountProp("addressLabels",s)||new Map;r.set(t,e),p.setAccountProp("addressLabels",r,s)},removeAddressLabel(t,e){const s=p.getAccountProp("addressLabels",e)||new Map;s.delete(t),p.setAccountProp("addressLabels",s,e)},setConnectedWalletInfo(t,e){p.setAccountProp("connectedWalletInfo",t,e,!1)},setPreferredAccountType(t,e){p.setAccountProp("preferredAccountTypes",{...Et.preferredAccountTypes,[e]:t},e)},setPreferredAccountTypes(t){Et.preferredAccountTypes=t},setSocialProvider(t,e){t&&p.setAccountProp("socialProvider",t,e)},setSocialWindow(t,e){p.setAccountProp("socialWindow",t?Hs(t):void 0,e)},setFarcasterUrl(t,e){p.setAccountProp("farcasterUrl",t,e)},async fetchTokenBalance(t){var n,o;Et.balanceLoading=!0;const e=(n=p.state.activeCaipNetwork)==null?void 0:n.caipNetworkId,s=(o=p.state.activeCaipNetwork)==null?void 0:o.chainNamespace,r=p.state.activeCaipAddress,i=r?Z.getPlainAddress(r):void 0;if(Et.lastRetry&&!Z.isAllowedRetry(Et.lastRetry,30*Ee.ONE_SEC_MS))return Et.balanceLoading=!1,[];try{if(i&&e&&s){const c=(await J.getBalance(i,e)).balances.filter(l=>l.quantity.decimals!=="0");return W.setTokenBalance(c,s),Et.lastRetry=void 0,Et.balanceLoading=!1,c}}catch(a){Et.lastRetry=Date.now(),t==null||t(a),Ut.showError("Token Balance Unavailable")}finally{Et.balanceLoading=!1}return[]},resetAccount(t){p.resetAccount(t)}},W=vt(ed),td={onSwitchNetwork({network:t,ignoreSwitchConfirmation:e=!1}){const s=p.state.activeCaipNetwork,r=re.state.data;if(t.id===(s==null?void 0:s.id))return;const n=W.getCaipAddress(p.state.activeChain),o=t.chainNamespace!==p.state.activeChain,a=W.getCaipAddress(t.chainNamespace),l=q.getConnectorId(p.state.activeChain)===z.CONNECTOR_ID.AUTH,h=z.AUTH_CONNECTOR_SUPPORTED_CHAINS.find(u=>u===t.chainNamespace);e||l&&h?re.push("SwitchNetwork",{...r,network:t}):n&&o&&!a?re.push("SwitchActiveChain",{switchToChain:t.chainNamespace,navigateTo:"Connect",navigateWithReplace:!0,network:t}):re.push("SwitchNetwork",{...r,network:t})}},nt=_e({loading:!1,loadingNamespaceMap:new Map,open:!1,shake:!1,namespace:void 0}),sd={state:nt,subscribe(t){return Xe(nt,()=>t(nt))},subscribeKey(t,e){return Qe(nt,t,e)},async open(t){var o,a;const e=W.state.status==="connected",s=t==null?void 0:t.namespace,r=p.state.activeChain,i=s&&s!==r,n=(o=p.getAccountData(t==null?void 0:t.namespace))==null?void 0:o.caipAddress;if(Y.state.wcBasic?V.prefetch({fetchNetworkImages:!1,fetchConnectorImages:!1}):await V.prefetch({fetchConnectorImages:!e,fetchFeaturedWallets:!e,fetchRecommendedWallets:!e}),q.setFilterByNamespace(t==null?void 0:t.namespace),We.setLoading(!0,s),s&&i){const c=((a=p.getNetworkData(s))==null?void 0:a.caipNetwork)||p.getRequestedCaipNetworks(s)[0];c&&td.onSwitchNetwork({network:c,ignoreSwitchConfirmation:!0})}else{const c=p.state.noAdapters;O.state.manualWCControl||c&&!n?Z.isMobile()?re.reset("AllWallets"):re.reset("ConnectingWalletConnectBasic"):t!=null&&t.view?re.reset(t.view,t.data):n?re.reset("Account"):re.reset("Connect")}nt.open=!0,vs.set({open:!0}),Pe.sendEvent({type:"track",event:"MODAL_OPEN",properties:{connected:!!n}})},close(){const t=O.state.enableEmbedded,e=!!p.state.activeCaipAddress;nt.open&&Pe.sendEvent({type:"track",event:"MODAL_CLOSE",properties:{connected:e}}),nt.open=!1,re.reset("Connect"),We.clearLoading(),t?e?re.replace("Account"):re.push("Connect"):vs.set({open:!1}),Y.resetUri()},setLoading(t,e){e&&nt.loadingNamespaceMap.set(e,t),nt.loading=t,vs.set({loading:t})},clearLoading(){nt.loadingNamespaceMap.clear(),nt.loading=!1},shake(){nt.shake||(nt.shake=!0,setTimeout(()=>{nt.shake=!1},500))}},We=vt(sd),li={id:"2b92315d-eab7-5bef-84fa-089a131333f5",name:"USD Coin",symbol:"USDC",networks:[{name:"ethereum-mainnet",display_name:"Ethereum",chain_id:"1",contract_address:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"},{name:"polygon-mainnet",display_name:"Polygon",chain_id:"137",contract_address:"0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174"}]},co={id:"USD",payment_method_limits:[{id:"card",min:"10.00",max:"7500.00"},{id:"ach_bank_account",min:"10.00",max:"25000.00"}]},rd={providers:Cl,selectedProvider:null,error:null,purchaseCurrency:li,paymentCurrency:co,purchaseCurrencies:[li],paymentCurrencies:[],quotesLoading:!1},oe=_e(rd),id={state:oe,subscribe(t){return Xe(oe,()=>t(oe))},subscribeKey(t,e){return Qe(oe,t,e)},setSelectedProvider(t){if(t&&t.name==="meld"){const e=p.state.activeChain===z.CHAIN.SOLANA?"SOL":"USDC",s=W.state.address??"",r=new URL(t.url);r.searchParams.append("publicKey",Ou),r.searchParams.append("destinationCurrencyCode",e),r.searchParams.append("walletAddress",s),r.searchParams.append("externalCustomerId",O.state.projectId),oe.selectedProvider={...t,url:r.toString()}}else oe.selectedProvider=t},setOnrampProviders(t){if(Array.isArray(t)&&t.every(e=>typeof e=="string")){const e=t,s=Cl.filter(r=>e.includes(r.name));oe.providers=s}else oe.providers=[]},setPurchaseCurrency(t){oe.purchaseCurrency=t},setPaymentCurrency(t){oe.paymentCurrency=t},setPurchaseAmount(t){lo.state.purchaseAmount=t},setPaymentAmount(t){lo.state.paymentAmount=t},async getAvailableCurrencies(){const t=await J.getOnrampOptions();oe.purchaseCurrencies=t.purchaseCurrencies,oe.paymentCurrencies=t.paymentCurrencies,oe.paymentCurrency=t.paymentCurrencies[0]||co,oe.purchaseCurrency=t.purchaseCurrencies[0]||li,await V.fetchCurrencyImages(t.paymentCurrencies.map(e=>e.id)),await V.fetchTokenImages(t.purchaseCurrencies.map(e=>e.symbol))},async getQuote(){var t,e;oe.quotesLoading=!0;try{const s=await J.getOnrampQuote({purchaseCurrency:oe.purchaseCurrency,paymentCurrency:oe.paymentCurrency,amount:((t=oe.paymentAmount)==null?void 0:t.toString())||"0",network:(e=oe.purchaseCurrency)==null?void 0:e.symbol});return oe.quotesLoading=!1,oe.purchaseAmount=Number(s==null?void 0:s.purchaseAmount.amount),s}catch(s){return oe.error=s.message,oe.quotesLoading=!1,null}finally{oe.quotesLoading=!1}},resetState(){oe.selectedProvider=null,oe.error=null,oe.purchaseCurrency=li,oe.paymentCurrency=co,oe.purchaseCurrencies=[li],oe.paymentCurrencies=[],oe.paymentAmount=void 0,oe.purchaseAmount=void 0,oe.quotesLoading=!1}},lo=vt(id),wa=2147483648,nd={convertEVMChainIdToCoinType(t){if(t>=wa)throw new Error("Invalid chainId");return(wa|t)>>>0}},Ct=_e({suggestions:[],loading:!1}),od={state:Ct,subscribe(t){return Xe(Ct,()=>t(Ct))},subscribeKey(t,e){return Qe(Ct,t,e)},async resolveName(t){var e,s;try{return await J.lookupEnsName(t)}catch(r){const i=r;throw new Error(((s=(e=i==null?void 0:i.reasons)==null?void 0:e[0])==null?void 0:s.description)||"Error resolving name")}},async isNameRegistered(t){try{return await J.lookupEnsName(t),!0}catch{return!1}},async getSuggestions(t){try{Ct.loading=!0,Ct.suggestions=[];const e=await J.getEnsNameSuggestions(t);return Ct.suggestions=e.suggestions.map(s=>({...s,name:s.name}))||[],Ct.suggestions}catch(e){const s=hi.parseEnsApiError(e,"Error fetching name suggestions");throw new Error(s)}finally{Ct.loading=!1}},async getNamesForAddress(t){try{if(!p.state.activeCaipNetwork)return[];const s=F.getEnsFromCacheForAddress(t);if(s)return s;const r=await J.reverseLookupEnsName({address:t});return F.updateEnsCache({address:t,ens:r,timestamp:Date.now()}),r}catch(e){const s=hi.parseEnsApiError(e,"Error fetching names for address");throw new Error(s)}},async registerName(t){const e=p.state.activeCaipNetwork;if(!e)throw new Error("Network not found");const s=W.state.address,r=q.getAuthConnector();if(!s||!r)throw new Error("Address or auth connector not found");Ct.loading=!0;try{const i=JSON.stringify({name:t,attributes:{},timestamp:Math.floor(Date.now()/1e3)});re.pushTransactionStack({onCancel(){re.replace("RegisterAccountName")}});const n=await Y.signMessage(i);Ct.loading=!1;const o=e.id;if(!o)throw new Error("Network not found");const a=nd.convertEVMChainIdToCoinType(Number(o));await J.registerEnsName({coinType:a,address:s,signature:n,message:i}),W.setProfileName(t,e.chainNamespace),re.replace("RegisterAccountNameSuccess")}catch(i){const n=hi.parseEnsApiError(i,`Error registering name ${t}`);throw re.replace("RegisterAccountName"),new Error(n)}finally{Ct.loading=!1}},validateName(t){return/^[a-zA-Z0-9-]{4,}$/u.test(t)},parseEnsApiError(t,e){var r,i;const s=t;return((i=(r=s==null?void 0:s.reasons)==null?void 0:r[0])==null?void 0:i.description)||e}},hi=vt(od);var ad=Object.defineProperty,cd=(t,e,s)=>e in t?ad(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,ya=(t,e,s)=>cd(t,typeof e!="symbol"?e+"":e,s);let ld=class extends qr{constructor(e){super(),this.opts=e,ya(this,"protocol","wc"),ya(this,"version",2)}};var hd=Object.defineProperty,ud=(t,e,s)=>e in t?hd(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,dd=(t,e,s)=>ud(t,e+"",s);let pd=class extends qr{constructor(e,s){super(),this.core=e,this.logger=s,dd(this,"records",new Map)}},fd=class{constructor(e,s){this.logger=e,this.core=s}},gd=class extends qr{constructor(e,s){super(),this.relayer=e,this.logger=s}},md=class extends qr{constructor(e){super()}},wd=class{constructor(e,s,r,i){this.core=e,this.logger=s,this.name=r}},yd=class extends qr{constructor(e,s){super(),this.relayer=e,this.logger=s}},bd=class extends qr{constructor(e,s){super(),this.core=e,this.logger=s}},vd=class{constructor(e,s,r){this.core=e,this.logger=s,this.store=r}},Ed=class{constructor(e,s){this.projectId=e,this.logger=s}},Cd=class{constructor(e,s,r){this.core=e,this.logger=s,this.telemetryEnabled=r}};var Id=Object.defineProperty,Ad=(t,e,s)=>e in t?Id(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,ba=(t,e,s)=>Ad(t,typeof e!="symbol"?e+"":e,s);let Nd=class{constructor(e){this.opts=e,ba(this,"protocol","wc"),ba(this,"version",2)}},_d=class{constructor(e){this.client=e}};var Sd={};const Pd=":";function _r(t){const[e,s]=t.split(Pd);return{namespace:e,reference:s}}function _l(t,e){return t.includes(":")?[t]:e.chains||[]}var Od=Object.defineProperty,Td=Object.defineProperties,kd=Object.getOwnPropertyDescriptors,va=Object.getOwnPropertySymbols,$d=Object.prototype.hasOwnProperty,xd=Object.prototype.propertyIsEnumerable,Ea=(t,e,s)=>e in t?Od(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Ca=(t,e)=>{for(var s in e||(e={}))$d.call(e,s)&&Ea(t,s,e[s]);if(va)for(var s of va(e))xd.call(e,s)&&Ea(t,s,e[s]);return t},Rd=(t,e)=>Td(t,kd(e));const Ud="ReactNative",wt={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},Dd="js";function ln(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function Ss(){return!Or()&&!!gl()&&navigator.product===Ud}function Ld(){return Ss()&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"&&(global==null?void 0:global.Platform.OS)==="android"}function Md(){return Ss()&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"&&(global==null?void 0:global.Platform.OS)==="ios"}function Fr(){return!ln()&&!!gl()&&!!Or()}function Ti(){return Ss()?wt.reactNative:ln()?wt.node:Fr()?wt.browser:wt.unknown}function Ia(){var t;try{return Ss()&&typeof global<"u"&&typeof(global==null?void 0:global.Application)<"u"?(t=global.Application)==null?void 0:t.applicationId:void 0}catch{return}}function Bd(t,e){const s=new URLSearchParams(t);for(const r of Object.keys(e).sort())if(e.hasOwnProperty(r)){const i=e[r];i!==void 0&&s.set(r,i)}return s.toString()}function qd(t){var e,s;const r=Sl();try{return t!=null&&t.url&&r.url&&new URL(t.url).host!==new URL(r.url).host&&(console.warn(`The configured WalletConnect 'metadata.url':${t.url} differs from the actual page url:${r.url}. This is probably unintended and can lead to issues.`),t.url=r.url),(e=t==null?void 0:t.icons)!=null&&e.length&&t.icons.length>0&&(t.icons=t.icons.filter(i=>i!=="")),Rd(Ca(Ca({},r),t),{url:(t==null?void 0:t.url)||r.url,name:(t==null?void 0:t.name)||r.name,description:(t==null?void 0:t.description)||r.description,icons:(s=t==null?void 0:t.icons)!=null&&s.length&&t.icons.length>0?t.icons:r.icons})}catch(i){return console.warn("Error populating app metadata",i),t||r}}function Sl(){return Qh()||{name:"",description:"",url:"",icons:[""]}}function jd(){if(Ti()===wt.reactNative&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"){const{OS:s,Version:r}=global.Platform;return[s,r].join("-")}const t=tu();if(t===null)return"unknown";const e=t.os?t.os.replace(" ","").toLowerCase():"unknown";return t.type==="browser"?[e,t.name,t.version].join("-"):[e,t.version].join("-")}function Fd(){var t;const e=Ti();return e===wt.browser?[e,((t=su())==null?void 0:t.host)||"unknown"].join(":"):e}function Pl(t,e,s){const r=jd(),i=Fd();return[[t,e].join("-"),[Dd,s].join("-"),r,i].join("/")}function Wd({protocol:t,version:e,relayUrl:s,sdkVersion:r,auth:i,projectId:n,useOnCloseEvent:o,bundleId:a,packageName:c}){const l=s.split("?"),h=Pl(t,e,r),u={auth:i,ua:h,projectId:n,useOnCloseEvent:o,packageName:c||void 0,bundleId:a||void 0},d=Bd(l[1]||"",u);return l[0]+"?"+d}function qs(t,e){return t.filter(s=>e.includes(s)).length===t.length}function ho(t){return Object.fromEntries(t.entries())}function uo(t){return new Map(Object.entries(t))}function Rs(t=U.FIVE_MINUTES,e){const s=U.toMiliseconds(t||U.FIVE_MINUTES);let r,i,n,o;return{resolve:a=>{n&&r&&(clearTimeout(n),r(a),o=Promise.resolve(a))},reject:a=>{n&&i&&(clearTimeout(n),i(a))},done:()=>new Promise((a,c)=>{if(o)return a(o);n=setTimeout(()=>{const l=new Error(e);o=Promise.reject(l),c(l)},s),r=a,i=c})}}function bs(t,e,s){return new Promise(async(r,i)=>{const n=setTimeout(()=>i(new Error(s)),e);try{const o=await t;r(o)}catch(o){i(o)}clearTimeout(n)})}function Ol(t,e){if(typeof e=="string"&&e.startsWith(`${t}:`))return e;if(t.toLowerCase()==="topic"){if(typeof e!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${e}`}else if(t.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: ${t}`)}function zd(t){return Ol("topic",t)}function Hd(t){return Ol("id",t)}function Tl(t){const[e,s]=t.split(":"),r={id:void 0,topic:void 0};if(e==="topic"&&typeof s=="string")r.topic=s;else if(e==="id"&&Number.isInteger(Number(s)))r.id=Number(s);else throw new Error(`Invalid target, expected id:number or topic:string, got ${e}:${s}`);return r}function De(t,e){return U.fromMiliseconds(Date.now()+U.toMiliseconds(t))}function gs(t){return Date.now()>=U.toMiliseconds(t)}function pe(t,e){return`${t}${e?`:${e}`:""}`}function Kt(t=[],e=[]){return[...new Set([...t,...e])]}async function Vd({id:t,topic:e,wcDeepLink:s}){var r;try{if(!s)return;const i=typeof s=="string"?JSON.parse(s):s,n=i==null?void 0:i.href;if(typeof n!="string")return;const o=Kd(n,t,e),a=Ti();if(a===wt.browser){if(!((r=Or())!=null&&r.hasFocus())){console.warn("Document does not have focus, skipping deeplink.");return}Gd(o)}else a===wt.reactNative&&typeof(global==null?void 0:global.Linking)<"u"&&await global.Linking.openURL(o)}catch(i){console.error(i)}}function Kd(t,e,s){const r=`requestId=${e}&sessionTopic=${s}`;t.endsWith("/")&&(t=t.slice(0,-1));let i=`${t}`;if(t.startsWith("https://t.me")){const n=t.includes("?")?"&startapp=":"?startapp=";i=`${i}${n}${Xd(r,!0)}`}else i=`${i}/wc?${r}`;return i}function Gd(t){let e="_self";Zd()?e="_top":(Yd()||t.startsWith("https://")||t.startsWith("http://"))&&(e="_blank"),window.open(t,e,"noreferrer noopener")}async function Jd(t,e){let s="";try{if(Fr()&&(s=localStorage.getItem(e),s))return s;s=await t.getItem(e)}catch(r){console.error(r)}return s}function Aa(t,e){if(!t.includes(e))return null;const s=t.split(/([&,?,=])/),r=s.indexOf(e);return s[r+2]}function Na(){return typeof crypto<"u"&&crypto!=null&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,t=>{const e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)})}function zo(){return typeof process<"u"&&Sd.IS_VITEST==="true"}function Yd(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)}function Zd(){try{return window.self!==window.top}catch{return!1}}function Xd(t,e=!1){const s=Buffer.from(t).toString("base64");return e?s.replace(/[=]/g,""):s}function kl(t){return Buffer.from(t,"base64").toString("utf-8")}function Qd(t){return new Promise(e=>setTimeout(e,t))}function bi(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function ep(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function ki(t,...e){if(!ep(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function Ho(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");bi(t.outputLen),bi(t.blockLen)}function kr(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function $l(t,e){ki(t);const s=e.outputLen;if(t.length<s)throw new Error("digestInto() expects output buffer of length at least "+s)}const Fi=BigInt(2**32-1),_a=BigInt(32);function tp(t,e=!1){return e?{h:Number(t&Fi),l:Number(t>>_a&Fi)}:{h:Number(t>>_a&Fi)|0,l:Number(t&Fi)|0}}function sp(t,e=!1){let s=new Uint32Array(t.length),r=new Uint32Array(t.length);for(let i=0;i<t.length;i++){const{h:n,l:o}=tp(t[i],e);[s[i],r[i]]=[n,o]}return[s,r]}const rp=(t,e,s)=>t<<s|e>>>32-s,ip=(t,e,s)=>e<<s|t>>>32-s,np=(t,e,s)=>e<<s-32|t>>>64-s,op=(t,e,s)=>t<<s-32|e>>>64-s,rr=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function ap(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function $n(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function Bt(t,e){return t<<32-e|t>>>e}const Sa=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function cp(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function Pa(t){for(let e=0;e<t.length;e++)t[e]=cp(t[e])}function lp(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))}function $r(t){return typeof t=="string"&&(t=lp(t)),ki(t),t}function hp(...t){let e=0;for(let r=0;r<t.length;r++){const i=t[r];ki(i),e+=i.length}const s=new Uint8Array(e);for(let r=0,i=0;r<t.length;r++){const n=t[r];s.set(n,i),i+=n.length}return s}let Vo=class{clone(){return this._cloneInto()}};function xl(t){const e=r=>t().update($r(r)).digest(),s=t();return e.outputLen=s.outputLen,e.blockLen=s.blockLen,e.create=()=>t(),e}function Wr(t=32){if(rr&&typeof rr.getRandomValues=="function")return rr.getRandomValues(new Uint8Array(t));if(rr&&typeof rr.randomBytes=="function")return rr.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}const Rl=[],Ul=[],Dl=[],up=BigInt(0),Gr=BigInt(1),dp=BigInt(2),pp=BigInt(7),fp=BigInt(256),gp=BigInt(113);for(let t=0,e=Gr,s=1,r=0;t<24;t++){[s,r]=[r,(2*s+3*r)%5],Rl.push(2*(5*r+s)),Ul.push((t+1)*(t+2)/2%64);let i=up;for(let n=0;n<7;n++)e=(e<<Gr^(e>>pp)*gp)%fp,e&dp&&(i^=Gr<<(Gr<<BigInt(n))-Gr);Dl.push(i)}const[mp,wp]=sp(Dl,!0),Oa=(t,e,s)=>s>32?np(t,e,s):rp(t,e,s),Ta=(t,e,s)=>s>32?op(t,e,s):ip(t,e,s);function yp(t,e=24){const s=new Uint32Array(10);for(let r=24-e;r<24;r++){for(let o=0;o<10;o++)s[o]=t[o]^t[o+10]^t[o+20]^t[o+30]^t[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,c=(o+2)%10,l=s[c],h=s[c+1],u=Oa(l,h,1)^s[a],d=Ta(l,h,1)^s[a+1];for(let g=0;g<50;g+=10)t[o+g]^=u,t[o+g+1]^=d}let i=t[2],n=t[3];for(let o=0;o<24;o++){const a=Ul[o],c=Oa(i,n,a),l=Ta(i,n,a),h=Rl[o];i=t[h],n=t[h+1],t[h]=c,t[h+1]=l}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)s[a]=t[o+a];for(let a=0;a<10;a++)t[o+a]^=~s[(a+2)%10]&s[(a+4)%10]}t[0]^=mp[r],t[1]^=wp[r]}s.fill(0)}let bp=class Ll extends Vo{constructor(e,s,r,i=!1,n=24){if(super(),this.blockLen=e,this.suffix=s,this.outputLen=r,this.enableXOF=i,this.rounds=n,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,bi(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=ap(this.state)}keccak(){Sa||Pa(this.state32),yp(this.state32,this.rounds),Sa||Pa(this.state32),this.posOut=0,this.pos=0}update(e){kr(this);const{blockLen:s,state:r}=this;e=$r(e);const i=e.length;for(let n=0;n<i;){const o=Math.min(s-this.pos,i-n);for(let a=0;a<o;a++)r[this.pos++]^=e[n++];this.pos===s&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:s,pos:r,blockLen:i}=this;e[r]^=s,s&128&&r===i-1&&this.keccak(),e[i-1]^=128,this.keccak()}writeInto(e){kr(this,!1),ki(e),this.finish();const s=this.state,{blockLen:r}=this;for(let i=0,n=e.length;i<n;){this.posOut>=r&&this.keccak();const o=Math.min(r-this.posOut,n-i);e.set(s.subarray(this.posOut,this.posOut+o),i),this.posOut+=o,i+=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 bi(e),this.xofInto(new Uint8Array(e))}digestInto(e){if($l(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:s,suffix:r,outputLen:i,rounds:n,enableXOF:o}=this;return e||(e=new Ll(s,r,i,o,n)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=n,e.suffix=r,e.outputLen=i,e.enableXOF=o,e.destroyed=this.destroyed,e}};const vp=(t,e,s)=>xl(()=>new bp(e,t,s)),Ep=vp(1,136,256/8),Cp="https://rpc.walletconnect.org/v1";function Ml(t){const e=`Ethereum Signed Message:
5
+ ${t.length}`,s=new TextEncoder().encode(e+t);return"0x"+Buffer.from(Ep(s)).toString("hex")}async function Ip(t,e,s,r,i,n){switch(s.t){case"eip191":return await Ap(t,e,s.s);case"eip1271":return await Np(t,e,s.s,r,i,n);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${s.t}`)}}async function Ap(t,e,s){return(await ru({hash:Ml(e),signature:s})).toLowerCase()===t.toLowerCase()}async function Np(t,e,s,r,i,n){const o=_r(r);if(!o.namespace||!o.reference)throw new Error(`isValidEip1271Signature failed: chainId must be in CAIP-2 format, received: ${r}`);try{const a="0x1626ba7e",c="0000000000000000000000000000000000000000000000000000000000000040",l="0000000000000000000000000000000000000000000000000000000000000041",h=s.substring(2),u=Ml(e).substring(2),d=a+u+c+l+h,g=await fetch(`${n||Cp}/?chainId=${r}&projectId=${i}`,{method:"POST",body:JSON.stringify({id:_p(),jsonrpc:"2.0",method:"eth_call",params:[{to:t,data:d},"latest"]})}),{result:w}=await g.json();return w?w.slice(0,a.length).toLowerCase()===a.toLowerCase():!1}catch(a){return console.error("isValidEip1271Signature: ",a),!1}}function _p(){return Date.now()+Math.floor(Math.random()*1e3)}function Sp(t){const e=atob(t),s=new Uint8Array(e.length);for(let o=0;o<e.length;o++)s[o]=e.charCodeAt(o);const r=s[0];if(r===0)throw new Error("No signatures found");const i=1+r*64;if(s.length<i)throw new Error("Transaction data too short for claimed signature count");if(s.length<100)throw new Error("Transaction too short");const n=Buffer.from(t,"base64").slice(1,65);return ml.encode(n)}var Pp=Object.defineProperty,Op=Object.defineProperties,Tp=Object.getOwnPropertyDescriptors,ka=Object.getOwnPropertySymbols,kp=Object.prototype.hasOwnProperty,$p=Object.prototype.propertyIsEnumerable,$a=(t,e,s)=>e in t?Pp(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,xp=(t,e)=>{for(var s in e||(e={}))kp.call(e,s)&&$a(t,s,e[s]);if(ka)for(var s of ka(e))$p.call(e,s)&&$a(t,s,e[s]);return t},Rp=(t,e)=>Op(t,Tp(e));const Up="did:pkh:",Ko=t=>t==null?void 0:t.split(":"),Dp=t=>{const e=t&&Ko(t);if(e)return t.includes(Up)?e[3]:e[1]},po=t=>{const e=t&&Ko(t);if(e)return e[2]+":"+e[3]},hn=t=>{const e=t&&Ko(t);if(e)return e.pop()};async function xa(t){const{cacao:e,projectId:s}=t,{s:r,p:i}=e,n=Bl(i,i.iss),o=hn(i.iss);return await Ip(o,n,r,po(i.iss),s)}const Bl=(t,e)=>{const s=`${t.domain} wants you to sign in with your Ethereum account:`,r=hn(e);if(!t.aud&&!t.uri)throw new Error("Either `aud` or `uri` is required to construct the message");let i=t.statement||void 0;const n=`URI: ${t.aud||t.uri}`,o=`Version: ${t.version}`,a=`Chain ID: ${Dp(e)}`,c=`Nonce: ${t.nonce}`,l=`Issued At: ${t.iat}`,h=t.exp?`Expiration Time: ${t.exp}`:void 0,u=t.nbf?`Not Before: ${t.nbf}`:void 0,d=t.requestId?`Request ID: ${t.requestId}`:void 0,g=t.resources?`Resources:${t.resources.map(f=>`
6
+ - ${f}`).join("")}`:void 0,w=Qi(t.resources);if(w){const f=vi(w);i=Hp(i,f)}return[s,r,"",i,"",n,o,a,c,l,h,u,d,g].filter(f=>f!=null).join(`
7
+ `)};function Lp(t){return Buffer.from(JSON.stringify(t)).toString("base64")}function Mp(t){return JSON.parse(Buffer.from(t,"base64").toString("utf-8"))}function Vs(t){if(!t)throw new Error("No recap provided, value is undefined");if(!t.att)throw new Error("No `att` property found");const e=Object.keys(t.att);if(!(e!=null&&e.length))throw new Error("No resources found in `att` property");e.forEach(s=>{const r=t.att[s];if(Array.isArray(r))throw new Error(`Resource must be an object: ${s}`);if(typeof r!="object")throw new Error(`Resource must be an object: ${s}`);if(!Object.keys(r).length)throw new Error(`Resource object is empty: ${s}`);Object.keys(r).forEach(i=>{const n=r[i];if(!Array.isArray(n))throw new Error(`Ability limits ${i} must be an array of objects, found: ${n}`);if(!n.length)throw new Error(`Value of ${i} is empty array, must be an array with objects`);n.forEach(o=>{if(typeof o!="object")throw new Error(`Ability limits (${i}) must be an array of objects, found: ${o}`)})})})}function Bp(t,e,s,r={}){return s==null||s.sort((i,n)=>i.localeCompare(n)),{att:{[t]:qp(e,s,r)}}}function qp(t,e,s={}){e=e==null?void 0:e.sort((i,n)=>i.localeCompare(n));const r=e.map(i=>({[`${t}/${i}`]:[s]}));return Object.assign({},...r)}function ql(t){return Vs(t),`urn:recap:${Lp(t).replace(/=/g,"")}`}function vi(t){const e=Mp(t.replace("urn:recap:",""));return Vs(e),e}function jp(t,e,s){const r=Bp(t,e,s);return ql(r)}function Fp(t){return t&&t.includes("urn:recap:")}function Wp(t,e){const s=vi(t),r=vi(e),i=zp(s,r);return ql(i)}function zp(t,e){Vs(t),Vs(e);const s=Object.keys(t.att).concat(Object.keys(e.att)).sort((i,n)=>i.localeCompare(n)),r={att:{}};return s.forEach(i=>{var n,o;Object.keys(((n=t.att)==null?void 0:n[i])||{}).concat(Object.keys(((o=e.att)==null?void 0:o[i])||{})).sort((a,c)=>a.localeCompare(c)).forEach(a=>{var c,l;r.att[i]=Rp(xp({},r.att[i]),{[a]:((c=t.att[i])==null?void 0:c[a])||((l=e.att[i])==null?void 0:l[a])})})}),r}function Hp(t="",e){Vs(e);const s="I further authorize the stated URI to perform the following actions on my behalf: ";if(t.includes(s))return t;const r=[];let i=0;Object.keys(e.att).forEach(a=>{const c=Object.keys(e.att[a]).map(u=>({ability:u.split("/")[0],action:u.split("/")[1]}));c.sort((u,d)=>u.action.localeCompare(d.action));const l={};c.forEach(u=>{l[u.ability]||(l[u.ability]=[]),l[u.ability].push(u.action)});const h=Object.keys(l).map(u=>(i++,`(${i}) '${u}': '${l[u].join("', '")}' for '${a}'.`));r.push(h.join(", ").replace(".,","."))});const n=r.join(" "),o=`${s}${n}`;return`${t?t+" ":""}${o}`}function Ra(t){var e;const s=vi(t);Vs(s);const r=(e=s.att)==null?void 0:e.eip155;return r?Object.keys(r).map(i=>i.split("/")[1]):[]}function Ua(t){const e=vi(t);Vs(e);const s=[];return Object.values(e.att).forEach(r=>{Object.values(r).forEach(i=>{var n;(n=i==null?void 0:i[0])!=null&&n.chains&&s.push(i[0].chains)})}),[...new Set(s.flat())]}function Qi(t){if(!t)return;const e=t==null?void 0:t[t.length-1];return Fp(e)?e:void 0}function xn(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function jl(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function mt(t,...e){if(!jl(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function Da(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Vp(t,e){mt(t);const s=e.outputLen;if(t.length<s)throw new Error("digestInto() expects output buffer of length at least "+s)}function La(t){if(typeof t!="boolean")throw new Error(`boolean expected, not ${t}`)}const Es=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4)),Kp=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),Gp=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!Gp)throw new Error("Non little-endian hardware is not supported");function Jp(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function fo(t){if(typeof t=="string")t=Jp(t);else if(jl(t))t=go(t);else throw new Error("Uint8Array expected, got "+typeof t);return t}function Yp(t,e){if(e==null||typeof e!="object")throw new Error("options must be defined");return Object.assign(t,e)}function Zp(t,e){if(t.length!==e.length)return!1;let s=0;for(let r=0;r<t.length;r++)s|=t[r]^e[r];return s===0}const Xp=(t,e)=>{function s(r,...i){if(mt(r),t.nonceLength!==void 0){const l=i[0];if(!l)throw new Error("nonce / iv required");t.varSizeNonce?mt(l):mt(l,t.nonceLength)}const n=t.tagLength;n&&i[1]!==void 0&&mt(i[1]);const o=e(r,...i),a=(l,h)=>{if(h!==void 0){if(l!==2)throw new Error("cipher output not supported");mt(h)}};let c=!1;return{encrypt(l,h){if(c)throw new Error("cannot encrypt() twice with same key + nonce");return c=!0,mt(l),a(o.encrypt.length,h),o.encrypt(l,h)},decrypt(l,h){if(mt(l),n&&l.length<n)throw new Error("invalid ciphertext length: smaller than tagLength="+n);return a(o.decrypt.length,h),o.decrypt(l,h)}}}return Object.assign(s,t),s};function Ma(t,e,s=!0){if(e===void 0)return new Uint8Array(t);if(e.length!==t)throw new Error("invalid output length, expected "+t+", got: "+e.length);if(s&&!Qp(e))throw new Error("invalid output, must be aligned");return e}function Ba(t,e,s,r){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,s,r);const i=BigInt(32),n=BigInt(4294967295),o=Number(s>>i&n),a=Number(s&n);t.setUint32(e+4,o,r),t.setUint32(e+0,a,r)}function Qp(t){return t.byteOffset%4===0}function go(t){return Uint8Array.from(t)}function xr(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}const Fl=t=>Uint8Array.from(t.split("").map(e=>e.charCodeAt(0))),ef=Fl("expand 16-byte k"),tf=Fl("expand 32-byte k"),sf=Es(ef),rf=Es(tf);function ce(t,e){return t<<e|t>>>32-e}function mo(t){return t.byteOffset%4===0}const Wi=64,nf=16,Wl=2**32-1,qa=new Uint32Array;function of(t,e,s,r,i,n,o,a){const c=i.length,l=new Uint8Array(Wi),h=Es(l),u=mo(i)&&mo(n),d=u?Es(i):qa,g=u?Es(n):qa;for(let w=0;w<c;o++){if(t(e,s,r,h,o,a),o>=Wl)throw new Error("arx: counter overflow");const f=Math.min(Wi,c-w);if(u&&f===Wi){const m=w/4;if(w%4!==0)throw new Error("arx: invalid block position");for(let y=0,b;y<nf;y++)b=m+y,g[b]=d[b]^h[y];w+=Wi;continue}for(let m=0,y;m<f;m++)y=w+m,n[y]=i[y]^l[m];w+=f}}function af(t,e){const{allowShortKeys:s,extendNonceFn:r,counterLength:i,counterRight:n,rounds:o}=Yp({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},e);if(typeof t!="function")throw new Error("core must be a function");return xn(i),xn(o),La(n),La(s),(a,c,l,h,u=0)=>{mt(a),mt(c),mt(l);const d=l.length;if(h===void 0&&(h=new Uint8Array(d)),mt(h),xn(u),u<0||u>=Wl)throw new Error("arx: counter overflow");if(h.length<d)throw new Error(`arx: output (${h.length}) is shorter than data (${d})`);const g=[];let w=a.length,f,m;if(w===32)g.push(f=go(a)),m=rf;else if(w===16&&s)f=new Uint8Array(32),f.set(a),f.set(a,16),m=sf,g.push(f);else throw new Error(`arx: invalid 32-byte key, got length=${w}`);mo(c)||g.push(c=go(c));const y=Es(f);if(r){if(c.length!==24)throw new Error("arx: extended nonce must be 24 bytes");r(m,y,Es(c.subarray(0,16)),y),c=c.subarray(16)}const b=16-i;if(b!==c.length)throw new Error(`arx: nonce must be ${b} or 16 bytes`);if(b!==12){const A=new Uint8Array(12);A.set(c,n?0:12-c.length),c=A,g.push(c)}const E=Es(c);return of(t,m,y,E,l,h,u,o),xr(...g),h}}const He=(t,e)=>t[e++]&255|(t[e++]&255)<<8;class cf{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=fo(e),mt(e,32);const s=He(e,0),r=He(e,2),i=He(e,4),n=He(e,6),o=He(e,8),a=He(e,10),c=He(e,12),l=He(e,14);this.r[0]=s&8191,this.r[1]=(s>>>13|r<<3)&8191,this.r[2]=(r>>>10|i<<6)&7939,this.r[3]=(i>>>7|n<<9)&8191,this.r[4]=(n>>>4|o<<12)&255,this.r[5]=o>>>1&8190,this.r[6]=(o>>>14|a<<2)&8191,this.r[7]=(a>>>11|c<<5)&8065,this.r[8]=(c>>>8|l<<8)&8191,this.r[9]=l>>>5&127;for(let h=0;h<8;h++)this.pad[h]=He(e,16+2*h)}process(e,s,r=!1){const i=r?0:2048,{h:n,r:o}=this,a=o[0],c=o[1],l=o[2],h=o[3],u=o[4],d=o[5],g=o[6],w=o[7],f=o[8],m=o[9],y=He(e,s+0),b=He(e,s+2),E=He(e,s+4),A=He(e,s+6),$=He(e,s+8),P=He(e,s+10),S=He(e,s+12),D=He(e,s+14);let v=n[0]+(y&8191),x=n[1]+((y>>>13|b<<3)&8191),C=n[2]+((b>>>10|E<<6)&8191),L=n[3]+((E>>>7|A<<9)&8191),H=n[4]+((A>>>4|$<<12)&8191),I=n[5]+($>>>1&8191),T=n[6]+(($>>>14|P<<2)&8191),_=n[7]+((P>>>11|S<<5)&8191),B=n[8]+((S>>>8|D<<8)&8191),j=n[9]+(D>>>5|i),k=0,G=k+v*a+x*(5*m)+C*(5*f)+L*(5*w)+H*(5*g);k=G>>>13,G&=8191,G+=I*(5*d)+T*(5*u)+_*(5*h)+B*(5*l)+j*(5*c),k+=G>>>13,G&=8191;let Q=k+v*c+x*a+C*(5*m)+L*(5*f)+H*(5*w);k=Q>>>13,Q&=8191,Q+=I*(5*g)+T*(5*d)+_*(5*u)+B*(5*h)+j*(5*l),k+=Q>>>13,Q&=8191;let se=k+v*l+x*c+C*a+L*(5*m)+H*(5*f);k=se>>>13,se&=8191,se+=I*(5*w)+T*(5*g)+_*(5*d)+B*(5*u)+j*(5*h),k+=se>>>13,se&=8191;let Ce=k+v*h+x*l+C*c+L*a+H*(5*m);k=Ce>>>13,Ce&=8191,Ce+=I*(5*f)+T*(5*w)+_*(5*g)+B*(5*d)+j*(5*u),k+=Ce>>>13,Ce&=8191;let de=k+v*u+x*h+C*l+L*c+H*a;k=de>>>13,de&=8191,de+=I*(5*m)+T*(5*f)+_*(5*w)+B*(5*g)+j*(5*d),k+=de>>>13,de&=8191;let Te=k+v*d+x*u+C*h+L*l+H*c;k=Te>>>13,Te&=8191,Te+=I*a+T*(5*m)+_*(5*f)+B*(5*w)+j*(5*g),k+=Te>>>13,Te&=8191;let Le=k+v*g+x*d+C*u+L*h+H*l;k=Le>>>13,Le&=8191,Le+=I*c+T*a+_*(5*m)+B*(5*f)+j*(5*w),k+=Le>>>13,Le&=8191;let Ye=k+v*w+x*g+C*d+L*u+H*h;k=Ye>>>13,Ye&=8191,Ye+=I*l+T*c+_*a+B*(5*m)+j*(5*f),k+=Ye>>>13,Ye&=8191;let xe=k+v*f+x*w+C*g+L*d+H*u;k=xe>>>13,xe&=8191,xe+=I*h+T*l+_*c+B*a+j*(5*m),k+=xe>>>13,xe&=8191;let Re=k+v*m+x*f+C*w+L*g+H*d;k=Re>>>13,Re&=8191,Re+=I*u+T*h+_*l+B*c+j*a,k+=Re>>>13,Re&=8191,k=(k<<2)+k|0,k=k+G|0,G=k&8191,k=k>>>13,Q+=k,n[0]=G,n[1]=Q,n[2]=se,n[3]=Ce,n[4]=de,n[5]=Te,n[6]=Le,n[7]=Ye,n[8]=xe,n[9]=Re}finalize(){const{h:e,pad:s}=this,r=new Uint16Array(10);let i=e[1]>>>13;e[1]&=8191;for(let a=2;a<10;a++)e[a]+=i,i=e[a]>>>13,e[a]&=8191;e[0]+=i*5,i=e[0]>>>13,e[0]&=8191,e[1]+=i,i=e[1]>>>13,e[1]&=8191,e[2]+=i,r[0]=e[0]+5,i=r[0]>>>13,r[0]&=8191;for(let a=1;a<10;a++)r[a]=e[a]+i,i=r[a]>>>13,r[a]&=8191;r[9]-=8192;let n=(i^1)-1;for(let a=0;a<10;a++)r[a]&=n;n=~n;for(let a=0;a<10;a++)e[a]=e[a]&n|r[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]+s[0];e[0]=o&65535;for(let a=1;a<8;a++)o=(e[a]+s[a]|0)+(o>>>16)|0,e[a]=o&65535;xr(r)}update(e){Da(this);const{buffer:s,blockLen:r}=this;e=fo(e);const i=e.length;for(let n=0;n<i;){const o=Math.min(r-this.pos,i-n);if(o===r){for(;r<=i-n;n+=r)this.process(e,n);continue}s.set(e.subarray(n,n+o),this.pos),this.pos+=o,n+=o,this.pos===r&&(this.process(s,0,!1),this.pos=0)}return this}destroy(){xr(this.h,this.r,this.buffer,this.pad)}digestInto(e){Da(this),Vp(e,this),this.finished=!0;const{buffer:s,h:r}=this;let{pos:i}=this;if(i){for(s[i++]=1;i<16;i++)s[i]=0;this.process(s,0,!0)}this.finalize();let n=0;for(let o=0;o<8;o++)e[n++]=r[o]>>>0,e[n++]=r[o]>>>8;return e}digest(){const{buffer:e,outputLen:s}=this;this.digestInto(e);const r=e.slice(0,s);return this.destroy(),r}}function lf(t){const e=(r,i)=>t(i).update(fo(r)).digest(),s=t(new Uint8Array(32));return e.outputLen=s.outputLen,e.blockLen=s.blockLen,e.create=r=>t(r),e}const hf=lf(t=>new cf(t));function uf(t,e,s,r,i,n=20){let o=t[0],a=t[1],c=t[2],l=t[3],h=e[0],u=e[1],d=e[2],g=e[3],w=e[4],f=e[5],m=e[6],y=e[7],b=i,E=s[0],A=s[1],$=s[2],P=o,S=a,D=c,v=l,x=h,C=u,L=d,H=g,I=w,T=f,_=m,B=y,j=b,k=E,G=A,Q=$;for(let Ce=0;Ce<n;Ce+=2)P=P+x|0,j=ce(j^P,16),I=I+j|0,x=ce(x^I,12),P=P+x|0,j=ce(j^P,8),I=I+j|0,x=ce(x^I,7),S=S+C|0,k=ce(k^S,16),T=T+k|0,C=ce(C^T,12),S=S+C|0,k=ce(k^S,8),T=T+k|0,C=ce(C^T,7),D=D+L|0,G=ce(G^D,16),_=_+G|0,L=ce(L^_,12),D=D+L|0,G=ce(G^D,8),_=_+G|0,L=ce(L^_,7),v=v+H|0,Q=ce(Q^v,16),B=B+Q|0,H=ce(H^B,12),v=v+H|0,Q=ce(Q^v,8),B=B+Q|0,H=ce(H^B,7),P=P+C|0,Q=ce(Q^P,16),_=_+Q|0,C=ce(C^_,12),P=P+C|0,Q=ce(Q^P,8),_=_+Q|0,C=ce(C^_,7),S=S+L|0,j=ce(j^S,16),B=B+j|0,L=ce(L^B,12),S=S+L|0,j=ce(j^S,8),B=B+j|0,L=ce(L^B,7),D=D+H|0,k=ce(k^D,16),I=I+k|0,H=ce(H^I,12),D=D+H|0,k=ce(k^D,8),I=I+k|0,H=ce(H^I,7),v=v+x|0,G=ce(G^v,16),T=T+G|0,x=ce(x^T,12),v=v+x|0,G=ce(G^v,8),T=T+G|0,x=ce(x^T,7);let se=0;r[se++]=o+P|0,r[se++]=a+S|0,r[se++]=c+D|0,r[se++]=l+v|0,r[se++]=h+x|0,r[se++]=u+C|0,r[se++]=d+L|0,r[se++]=g+H|0,r[se++]=w+I|0,r[se++]=f+T|0,r[se++]=m+_|0,r[se++]=y+B|0,r[se++]=b+j|0,r[se++]=E+k|0,r[se++]=A+G|0,r[se++]=$+Q|0}const df=af(uf,{counterRight:!1,counterLength:4,allowShortKeys:!1}),pf=new Uint8Array(16),ja=(t,e)=>{t.update(e);const s=e.length%16;s&&t.update(pf.subarray(s))},ff=new Uint8Array(32);function Fa(t,e,s,r,i){const n=t(e,s,ff),o=hf.create(n);i&&ja(o,i),ja(o,r);const a=new Uint8Array(16),c=Kp(a);Ba(c,0,BigInt(i?i.length:0),!0),Ba(c,8,BigInt(r.length),!0),o.update(a);const l=o.digest();return xr(n,a),l}const gf=t=>(e,s,r)=>({encrypt(i,n){const o=i.length;n=Ma(o+16,n,!1),n.set(i);const a=n.subarray(0,-16);t(e,s,a,a,1);const c=Fa(t,e,s,a,r);return n.set(c,o),xr(c),n},decrypt(i,n){n=Ma(i.length-16,n,!1);const o=i.subarray(0,-16),a=i.subarray(-16),c=Fa(t,e,s,o,r);if(!Zp(a,c))throw new Error("invalid tag");return n.set(i.subarray(0,-16)),t(e,s,n,n,1),xr(c),n}}),zl=Xp({blockSize:64,nonceLength:12,tagLength:16},gf(df));let Hl=class extends Vo{constructor(e,s){super(),this.finished=!1,this.destroyed=!1,Ho(e);const r=$r(s);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 i=this.blockLen,n=new Uint8Array(i);n.set(r.length>i?e.create().update(r).digest():r);for(let o=0;o<n.length;o++)n[o]^=54;this.iHash.update(n),this.oHash=e.create();for(let o=0;o<n.length;o++)n[o]^=106;this.oHash.update(n),n.fill(0)}update(e){return kr(this),this.iHash.update(e),this}digestInto(e){kr(this),ki(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:s,iHash:r,finished:i,destroyed:n,blockLen:o,outputLen:a}=this;return e=e,e.finished=i,e.destroyed=n,e.blockLen=o,e.outputLen=a,e.oHash=s._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}};const yn=(t,e,s)=>new Hl(t,e).update(s).digest();yn.create=(t,e)=>new Hl(t,e);function mf(t,e,s){return Ho(t),s===void 0&&(s=new Uint8Array(t.outputLen)),yn(t,$r(s),$r(e))}const Rn=new Uint8Array([0]),Wa=new Uint8Array;function wf(t,e,s,r=32){if(Ho(t),bi(r),r>255*t.outputLen)throw new Error("Length should be <= 255*HashLen");const i=Math.ceil(r/t.outputLen);s===void 0&&(s=Wa);const n=new Uint8Array(i*t.outputLen),o=yn.create(t,e),a=o._cloneInto(),c=new Uint8Array(o.outputLen);for(let l=0;l<i;l++)Rn[0]=l+1,a.update(l===0?Wa:c).update(s).update(Rn).digestInto(c),n.set(c,t.outputLen*l),o._cloneInto(a);return o.destroy(),a.destroy(),c.fill(0),Rn.fill(0),n.slice(0,r)}const yf=(t,e,s,r,i)=>wf(t,mf(t,e,s),r,i);function bf(t,e,s,r){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,s,r);const i=BigInt(32),n=BigInt(4294967295),o=Number(s>>i&n),a=Number(s&n),c=r?4:0,l=r?0:4;t.setUint32(e+c,o,r),t.setUint32(e+l,a,r)}function vf(t,e,s){return t&e^~t&s}function Ef(t,e,s){return t&e^t&s^e&s}let Cf=class extends Vo{constructor(e,s,r,i){super(),this.blockLen=e,this.outputLen=s,this.padOffset=r,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=$n(this.buffer)}update(e){kr(this);const{view:s,buffer:r,blockLen:i}=this;e=$r(e);const n=e.length;for(let o=0;o<n;){const a=Math.min(i-this.pos,n-o);if(a===i){const c=$n(e);for(;i<=n-o;o+=i)this.process(c,o);continue}r.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===i&&(this.process(s,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){kr(this),$l(e,this),this.finished=!0;const{buffer:s,view:r,blockLen:i,isLE:n}=this;let{pos:o}=this;s[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>i-o&&(this.process(r,0),o=0);for(let u=o;u<i;u++)s[u]=0;bf(r,i-8,BigInt(this.length*8),n),this.process(r,0);const a=$n(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=c/4,h=this.get();if(l>h.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<l;u++)a.setUint32(4*u,h[u],n)}digest(){const{buffer:e,outputLen:s}=this;this.digestInto(e);const r=e.slice(0,s);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:s,buffer:r,length:i,finished:n,destroyed:o,pos:a}=this;return e.length=i,e.pos=a,e.finished=n,e.destroyed=o,i%s&&e.buffer.set(r),e}};const If=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]),us=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),ds=new Uint32Array(64);class Af extends Cf{constructor(){super(64,32,8,!1),this.A=us[0]|0,this.B=us[1]|0,this.C=us[2]|0,this.D=us[3]|0,this.E=us[4]|0,this.F=us[5]|0,this.G=us[6]|0,this.H=us[7]|0}get(){const{A:e,B:s,C:r,D:i,E:n,F:o,G:a,H:c}=this;return[e,s,r,i,n,o,a,c]}set(e,s,r,i,n,o,a,c){this.A=e|0,this.B=s|0,this.C=r|0,this.D=i|0,this.E=n|0,this.F=o|0,this.G=a|0,this.H=c|0}process(e,s){for(let u=0;u<16;u++,s+=4)ds[u]=e.getUint32(s,!1);for(let u=16;u<64;u++){const d=ds[u-15],g=ds[u-2],w=Bt(d,7)^Bt(d,18)^d>>>3,f=Bt(g,17)^Bt(g,19)^g>>>10;ds[u]=f+ds[u-7]+w+ds[u-16]|0}let{A:r,B:i,C:n,D:o,E:a,F:c,G:l,H:h}=this;for(let u=0;u<64;u++){const d=Bt(a,6)^Bt(a,11)^Bt(a,25),g=h+d+vf(a,c,l)+If[u]+ds[u]|0,w=(Bt(r,2)^Bt(r,13)^Bt(r,22))+Ef(r,i,n)|0;h=l,l=c,c=a,a=o+g|0,o=n,n=i,i=r,r=g+w|0}r=r+this.A|0,i=i+this.B|0,n=n+this.C|0,o=o+this.D|0,a=a+this.E|0,c=c+this.F|0,l=l+this.G|0,h=h+this.H|0,this.set(r,i,n,o,a,c,l,h)}roundClean(){ds.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const $i=xl(()=>new Af);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const bn=BigInt(0),vn=BigInt(1),Nf=BigInt(2);function Ks(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function xi(t){if(!Ks(t))throw new Error("Uint8Array expected")}function Rr(t,e){if(typeof e!="boolean")throw new Error(t+" boolean expected, got "+e)}const _f=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Ur(t){xi(t);let e="";for(let s=0;s<t.length;s++)e+=_f[t[s]];return e}function Ir(t){const e=t.toString(16);return e.length&1?"0"+e:e}function Go(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?bn:BigInt("0x"+t)}const es={_0:48,_9:57,A:65,F:70,a:97,f:102};function za(t){if(t>=es._0&&t<=es._9)return t-es._0;if(t>=es.A&&t<=es.F)return t-(es.A-10);if(t>=es.a&&t<=es.f)return t-(es.a-10)}function Dr(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);const e=t.length,s=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const r=new Uint8Array(s);for(let i=0,n=0;i<s;i++,n+=2){const o=za(t.charCodeAt(n)),a=za(t.charCodeAt(n+1));if(o===void 0||a===void 0){const c=t[n]+t[n+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+n)}r[i]=o*16+a}return r}function Fs(t){return Go(Ur(t))}function Ei(t){return xi(t),Go(Ur(Uint8Array.from(t).reverse()))}function Lr(t,e){return Dr(t.toString(16).padStart(e*2,"0"))}function En(t,e){return Lr(t,e).reverse()}function Sf(t){return Dr(Ir(t))}function gt(t,e,s){let r;if(typeof e=="string")try{r=Dr(e)}catch(n){throw new Error(t+" must be hex string or Uint8Array, cause: "+n)}else if(Ks(e))r=Uint8Array.from(e);else throw new Error(t+" must be hex string or Uint8Array");const i=r.length;if(typeof s=="number"&&i!==s)throw new Error(t+" of length "+s+" expected, got "+i);return r}function Ci(...t){let e=0;for(let r=0;r<t.length;r++){const i=t[r];xi(i),e+=i.length}const s=new Uint8Array(e);for(let r=0,i=0;r<t.length;r++){const n=t[r];s.set(n,i),i+=n.length}return s}function Pf(t,e){if(t.length!==e.length)return!1;let s=0;for(let r=0;r<t.length;r++)s|=t[r]^e[r];return s===0}function Of(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}const Un=t=>typeof t=="bigint"&&bn<=t;function Cn(t,e,s){return Un(t)&&Un(e)&&Un(s)&&e<=t&&t<s}function ns(t,e,s,r){if(!Cn(e,s,r))throw new Error("expected valid "+t+": "+s+" <= n < "+r+", got "+e)}function Vl(t){let e;for(e=0;t>bn;t>>=vn,e+=1);return e}function Tf(t,e){return t>>BigInt(e)&vn}function kf(t,e,s){return t|(s?vn:bn)<<BigInt(e)}const Jo=t=>(Nf<<BigInt(t-1))-vn,Dn=t=>new Uint8Array(t),Ha=t=>Uint8Array.from(t);function Kl(t,e,s){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof s!="function")throw new Error("hmacFn must be a function");let r=Dn(t),i=Dn(t),n=0;const o=()=>{r.fill(1),i.fill(0),n=0},a=(...h)=>s(i,r,...h),c=(h=Dn())=>{i=a(Ha([0]),h),r=a(),h.length!==0&&(i=a(Ha([1]),h),r=a())},l=()=>{if(n++>=1e3)throw new Error("drbg: tried 1000 values");let h=0;const u=[];for(;h<e;){r=a();const d=r.slice();u.push(d),h+=r.length}return Ci(...u)};return(h,u)=>{o(),c(h);let d;for(;!(d=u(l()));)c();return o(),d}}const $f={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||Ks(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function zr(t,e,s={}){const r=(i,n,o)=>{const a=$f[n];if(typeof a!="function")throw new Error("invalid validator function");const c=t[i];if(!(o&&c===void 0)&&!a(c,t))throw new Error("param "+String(i)+" is invalid. Expected "+n+", got "+c)};for(const[i,n]of Object.entries(e))r(i,n,!1);for(const[i,n]of Object.entries(s))r(i,n,!0);return t}const xf=()=>{throw new Error("not implemented")};function wo(t){const e=new WeakMap;return(s,...r)=>{const i=e.get(s);if(i!==void 0)return i;const n=t(s,...r);return e.set(s,n),n}}var Rf=Object.freeze({__proto__:null,isBytes:Ks,abytes:xi,abool:Rr,bytesToHex:Ur,numberToHexUnpadded:Ir,hexToNumber:Go,hexToBytes:Dr,bytesToNumberBE:Fs,bytesToNumberLE:Ei,numberToBytesBE:Lr,numberToBytesLE:En,numberToVarBytesBE:Sf,ensureBytes:gt,concatBytes:Ci,equalBytes:Pf,utf8ToBytes:Of,inRange:Cn,aInRange:ns,bitLen:Vl,bitGet:Tf,bitSet:kf,bitMask:Jo,createHmacDrbg:Kl,validateObject:zr,notImplemented:xf,memoized:wo});const ze=BigInt(0),Oe=BigInt(1),Ds=BigInt(2),Uf=BigInt(3),yo=BigInt(4),Va=BigInt(5),Ka=BigInt(8);function lt(t,e){const s=t%e;return s>=ze?s:e+s}function Gl(t,e,s){if(e<ze)throw new Error("invalid exponent, negatives unsupported");if(s<=ze)throw new Error("invalid modulus");if(s===Oe)return ze;let r=Oe;for(;e>ze;)e&Oe&&(r=r*t%s),t=t*t%s,e>>=Oe;return r}function xt(t,e,s){let r=t;for(;e-- >ze;)r*=r,r%=s;return r}function bo(t,e){if(t===ze)throw new Error("invert: expected non-zero number");if(e<=ze)throw new Error("invert: expected positive modulus, got "+e);let s=lt(t,e),r=e,i=ze,n=Oe;for(;s!==ze;){const o=r/s,a=r%s,c=i-n*o;r=s,s=a,i=n,n=c}if(r!==Oe)throw new Error("invert: does not exist");return lt(i,e)}function Df(t){const e=(t-Oe)/Ds;let s,r,i;for(s=t-Oe,r=0;s%Ds===ze;s/=Ds,r++);for(i=Ds;i<t&&Gl(i,e,t)!==t-Oe;i++)if(i>1e3)throw new Error("Cannot find square root: likely non-prime P");if(r===1){const o=(t+Oe)/yo;return function(a,c){const l=a.pow(c,o);if(!a.eql(a.sqr(l),c))throw new Error("Cannot find square root");return l}}const n=(s+Oe)/Ds;return function(o,a){if(o.pow(a,e)===o.neg(o.ONE))throw new Error("Cannot find square root");let c=r,l=o.pow(o.mul(o.ONE,i),s),h=o.pow(a,n),u=o.pow(a,s);for(;!o.eql(u,o.ONE);){if(o.eql(u,o.ZERO))return o.ZERO;let d=1;for(let w=o.sqr(u);d<c&&!o.eql(w,o.ONE);d++)w=o.sqr(w);const g=o.pow(l,Oe<<BigInt(c-d-1));l=o.sqr(g),h=o.mul(h,g),u=o.mul(u,l),c=d}return h}}function Lf(t){if(t%yo===Uf){const e=(t+Oe)/yo;return function(s,r){const i=s.pow(r,e);if(!s.eql(s.sqr(i),r))throw new Error("Cannot find square root");return i}}if(t%Ka===Va){const e=(t-Va)/Ka;return function(s,r){const i=s.mul(r,Ds),n=s.pow(i,e),o=s.mul(r,n),a=s.mul(s.mul(o,Ds),n),c=s.mul(o,s.sub(a,s.ONE));if(!s.eql(s.sqr(c),r))throw new Error("Cannot find square root");return c}}return Df(t)}const Mf=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Bf(t){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},s=Mf.reduce((r,i)=>(r[i]="function",r),e);return zr(t,s)}function qf(t,e,s){if(s<ze)throw new Error("invalid exponent, negatives unsupported");if(s===ze)return t.ONE;if(s===Oe)return e;let r=t.ONE,i=e;for(;s>ze;)s&Oe&&(r=t.mul(r,i)),i=t.sqr(i),s>>=Oe;return r}function jf(t,e){const s=new Array(e.length),r=e.reduce((n,o,a)=>t.is0(o)?n:(s[a]=n,t.mul(n,o)),t.ONE),i=t.inv(r);return e.reduceRight((n,o,a)=>t.is0(o)?n:(s[a]=t.mul(n,s[a]),t.mul(n,o)),i),s}function Jl(t,e){const s=e!==void 0?e:t.toString(2).length,r=Math.ceil(s/8);return{nBitLength:s,nByteLength:r}}function Yl(t,e,s=!1,r={}){if(t<=ze)throw new Error("invalid field: expected ORDER > 0, got "+t);const{nBitLength:i,nByteLength:n}=Jl(t,e);if(n>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let o;const a=Object.freeze({ORDER:t,isLE:s,BITS:i,BYTES:n,MASK:Jo(i),ZERO:ze,ONE:Oe,create:c=>lt(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof c);return ze<=c&&c<t},is0:c=>c===ze,isOdd:c=>(c&Oe)===Oe,neg:c=>lt(-c,t),eql:(c,l)=>c===l,sqr:c=>lt(c*c,t),add:(c,l)=>lt(c+l,t),sub:(c,l)=>lt(c-l,t),mul:(c,l)=>lt(c*l,t),pow:(c,l)=>qf(a,c,l),div:(c,l)=>lt(c*bo(l,t),t),sqrN:c=>c*c,addN:(c,l)=>c+l,subN:(c,l)=>c-l,mulN:(c,l)=>c*l,inv:c=>bo(c,t),sqrt:r.sqrt||(c=>(o||(o=Lf(t)),o(a,c))),invertBatch:c=>jf(a,c),cmov:(c,l,h)=>h?l:c,toBytes:c=>s?En(c,n):Lr(c,n),fromBytes:c=>{if(c.length!==n)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+c.length);return s?Ei(c):Fs(c)}});return Object.freeze(a)}function Zl(t){if(typeof t!="bigint")throw new Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function Xl(t){const e=Zl(t);return e+Math.ceil(e/2)}function Ff(t,e,s=!1){const r=t.length,i=Zl(e),n=Xl(e);if(r<16||r<n||r>1024)throw new Error("expected "+n+"-1024 bytes of input, got "+r);const o=s?Ei(t):Fs(t),a=lt(o,e-Oe)+Oe;return s?En(a,i):Lr(a,i)}const Ga=BigInt(0),zi=BigInt(1);function Ln(t,e){const s=e.negate();return t?s:e}function Ql(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function Mn(t,e){Ql(t,e);const s=Math.ceil(e/t)+1,r=2**(t-1);return{windows:s,windowSize:r}}function Wf(t,e){if(!Array.isArray(t))throw new Error("array expected");t.forEach((s,r)=>{if(!(s instanceof e))throw new Error("invalid point at index "+r)})}function zf(t,e){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((s,r)=>{if(!e.isValid(s))throw new Error("invalid scalar at index "+r)})}const Bn=new WeakMap,eh=new WeakMap;function qn(t){return eh.get(t)||1}function Hf(t,e){return{constTimeNegate:Ln,hasPrecomputes(s){return qn(s)!==1},unsafeLadder(s,r,i=t.ZERO){let n=s;for(;r>Ga;)r&zi&&(i=i.add(n)),n=n.double(),r>>=zi;return i},precomputeWindow(s,r){const{windows:i,windowSize:n}=Mn(r,e),o=[];let a=s,c=a;for(let l=0;l<i;l++){c=a,o.push(c);for(let h=1;h<n;h++)c=c.add(a),o.push(c);a=c.double()}return o},wNAF(s,r,i){const{windows:n,windowSize:o}=Mn(s,e);let a=t.ZERO,c=t.BASE;const l=BigInt(2**s-1),h=2**s,u=BigInt(s);for(let d=0;d<n;d++){const g=d*o;let w=Number(i&l);i>>=u,w>o&&(w-=h,i+=zi);const f=g,m=g+Math.abs(w)-1,y=d%2!==0,b=w<0;w===0?c=c.add(Ln(y,r[f])):a=a.add(Ln(b,r[m]))}return{p:a,f:c}},wNAFUnsafe(s,r,i,n=t.ZERO){const{windows:o,windowSize:a}=Mn(s,e),c=BigInt(2**s-1),l=2**s,h=BigInt(s);for(let u=0;u<o;u++){const d=u*a;if(i===Ga)break;let g=Number(i&c);if(i>>=h,g>a&&(g-=l,i+=zi),g===0)continue;let w=r[d+Math.abs(g)-1];g<0&&(w=w.negate()),n=n.add(w)}return n},getPrecomputes(s,r,i){let n=Bn.get(r);return n||(n=this.precomputeWindow(r,s),s!==1&&Bn.set(r,i(n))),n},wNAFCached(s,r,i){const n=qn(s);return this.wNAF(n,this.getPrecomputes(n,s,i),r)},wNAFCachedUnsafe(s,r,i,n){const o=qn(s);return o===1?this.unsafeLadder(s,r,n):this.wNAFUnsafe(o,this.getPrecomputes(o,s,i),r,n)},setWindowSize(s,r){Ql(r,e),eh.set(s,r),Bn.delete(s)}}}function Vf(t,e,s,r){if(Wf(s,t),zf(r,e),s.length!==r.length)throw new Error("arrays of points and scalars must have equal length");const i=t.ZERO,n=Vl(BigInt(s.length)),o=n>12?n-3:n>4?n-2:n?2:1,a=(1<<o)-1,c=new Array(a+1).fill(i),l=Math.floor((e.BITS-1)/o)*o;let h=i;for(let u=l;u>=0;u-=o){c.fill(i);for(let g=0;g<r.length;g++){const w=r[g],f=Number(w>>BigInt(u)&BigInt(a));c[f]=c[f].add(s[g])}let d=i;for(let g=c.length-1,w=i;g>0;g--)w=w.add(c[g]),d=d.add(w);if(h=h.add(d),u!==0)for(let g=0;g<o;g++)h=h.double()}return h}function th(t){return Bf(t.Fp),zr(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Jl(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}BigInt(0),BigInt(1),BigInt(2),BigInt(8);const ir=BigInt(0),jn=BigInt(1);function Kf(t){return zr(t,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...t})}function Gf(t){const e=Kf(t),{P:s}=e,r=b=>lt(b,s),i=e.montgomeryBits,n=Math.ceil(i/8),o=e.nByteLength,a=e.adjustScalarBytes||(b=>b),c=e.powPminus2||(b=>Gl(b,s-BigInt(2),s));function l(b,E,A){const $=r(b*(E-A));return E=r(E-$),A=r(A+$),[E,A]}const h=(e.a-BigInt(2))/BigInt(4);function u(b,E){ns("u",b,ir,s),ns("scalar",E,ir,s);const A=E,$=b;let P=jn,S=ir,D=b,v=jn,x=ir,C;for(let H=BigInt(i-1);H>=ir;H--){const I=A>>H&jn;x^=I,C=l(x,P,D),P=C[0],D=C[1],C=l(x,S,v),S=C[0],v=C[1],x=I;const T=P+S,_=r(T*T),B=P-S,j=r(B*B),k=_-j,G=D+v,Q=D-v,se=r(Q*T),Ce=r(G*B),de=se+Ce,Te=se-Ce;D=r(de*de),v=r($*r(Te*Te)),P=r(_*j),S=r(k*(_+r(h*k)))}C=l(x,P,D),P=C[0],D=C[1],C=l(x,S,v),S=C[0],v=C[1];const L=c(S);return r(P*L)}function d(b){return En(r(b),n)}function g(b){const E=gt("u coordinate",b,n);return o===32&&(E[31]&=127),Ei(E)}function w(b){const E=gt("scalar",b),A=E.length;if(A!==n&&A!==o){let $=""+n+" or "+o;throw new Error("invalid scalar, expected "+$+" bytes, got "+A)}return Ei(a(E))}function f(b,E){const A=g(E),$=w(b),P=u(A,$);if(P===ir)throw new Error("invalid private or public key received");return d(P)}const m=d(e.Gu);function y(b){return f(b,m)}return{scalarMult:f,scalarMultBase:y,getSharedSecret:(b,E)=>f(b,E),getPublicKey:b=>y(b),utils:{randomPrivateKey:()=>e.randomBytes(e.nByteLength)},GuBytes:m}}const vo=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949");BigInt(0);const Jf=BigInt(1),Ja=BigInt(2),Yf=BigInt(3),Zf=BigInt(5);BigInt(8);function Xf(t){const e=BigInt(10),s=BigInt(20),r=BigInt(40),i=BigInt(80),n=vo,o=t*t%n*t%n,a=xt(o,Ja,n)*o%n,c=xt(a,Jf,n)*t%n,l=xt(c,Zf,n)*c%n,h=xt(l,e,n)*l%n,u=xt(h,s,n)*h%n,d=xt(u,r,n)*u%n,g=xt(d,i,n)*d%n,w=xt(g,i,n)*d%n,f=xt(w,e,n)*l%n;return{pow_p_5_8:xt(f,Ja,n)*t%n,b2:o}}function Qf(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}const Eo=Gf({P:vo,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:t=>{const e=vo,{pow_p_5_8:s,b2:r}=Xf(t);return lt(xt(s,Yf,e)*r,e)},adjustScalarBytes:Qf,randomBytes:Wr});function Ya(t){t.lowS!==void 0&&Rr("lowS",t.lowS),t.prehash!==void 0&&Rr("prehash",t.prehash)}function eg(t){const e=th(t);zr(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:s,Fp:r,a:i}=e;if(s){if(!r.eql(i,r.ZERO))throw new Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");if(typeof s!="object"||typeof s.beta!="bigint"||typeof s.splitScalar!="function")throw new Error("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...e})}const{bytesToNumberBE:tg,hexToBytes:sg}=Rf;class rg extends Error{constructor(e=""){super(e)}}const rs={Err:rg,_tlv:{encode:(t,e)=>{const{Err:s}=rs;if(t<0||t>256)throw new s("tlv.encode: wrong tag");if(e.length&1)throw new s("tlv.encode: unpadded data");const r=e.length/2,i=Ir(r);if(i.length/2&128)throw new s("tlv.encode: long form length too big");const n=r>127?Ir(i.length/2|128):"";return Ir(t)+n+i+e},decode(t,e){const{Err:s}=rs;let r=0;if(t<0||t>256)throw new s("tlv.encode: wrong tag");if(e.length<2||e[r++]!==t)throw new s("tlv.decode: wrong tlv");const i=e[r++],n=!!(i&128);let o=0;if(!n)o=i;else{const c=i&127;if(!c)throw new s("tlv.decode(long): indefinite length not supported");if(c>4)throw new s("tlv.decode(long): byte length is too big");const l=e.subarray(r,r+c);if(l.length!==c)throw new s("tlv.decode: length bytes not complete");if(l[0]===0)throw new s("tlv.decode(long): zero leftmost byte");for(const h of l)o=o<<8|h;if(r+=c,o<128)throw new s("tlv.decode(long): not minimal encoding")}const a=e.subarray(r,r+o);if(a.length!==o)throw new s("tlv.decode: wrong value length");return{v:a,l:e.subarray(r+o)}}},_int:{encode(t){const{Err:e}=rs;if(t<is)throw new e("integer: negative integers are not allowed");let s=Ir(t);if(Number.parseInt(s[0],16)&8&&(s="00"+s),s.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return s},decode(t){const{Err:e}=rs;if(t[0]&128)throw new e("invalid signature integer: negative");if(t[0]===0&&!(t[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return tg(t)}},toSig(t){const{Err:e,_int:s,_tlv:r}=rs,i=typeof t=="string"?sg(t):t;xi(i);const{v:n,l:o}=r.decode(48,i);if(o.length)throw new e("invalid signature: left bytes after parsing");const{v:a,l:c}=r.decode(2,n),{v:l,l:h}=r.decode(2,c);if(h.length)throw new e("invalid signature: left bytes after parsing");return{r:s.decode(a),s:s.decode(l)}},hexFromSig(t){const{_tlv:e,_int:s}=rs,r=e.encode(2,s.encode(t.r)),i=e.encode(2,s.encode(t.s)),n=r+i;return e.encode(48,n)}},is=BigInt(0),qe=BigInt(1);BigInt(2);const Za=BigInt(3);BigInt(4);function ig(t){const e=eg(t),{Fp:s}=e,r=Yl(e.n,e.nBitLength),i=e.toBytes||((f,m,y)=>{const b=m.toAffine();return Ci(Uint8Array.from([4]),s.toBytes(b.x),s.toBytes(b.y))}),n=e.fromBytes||(f=>{const m=f.subarray(1),y=s.fromBytes(m.subarray(0,s.BYTES)),b=s.fromBytes(m.subarray(s.BYTES,2*s.BYTES));return{x:y,y:b}});function o(f){const{a:m,b:y}=e,b=s.sqr(f),E=s.mul(b,f);return s.add(s.add(E,s.mul(f,m)),y)}if(!s.eql(s.sqr(e.Gy),o(e.Gx)))throw new Error("bad generator point: equation left != right");function a(f){return Cn(f,qe,e.n)}function c(f){const{allowedPrivateKeyLengths:m,nByteLength:y,wrapPrivateKey:b,n:E}=e;if(m&&typeof f!="bigint"){if(Ks(f)&&(f=Ur(f)),typeof f!="string"||!m.includes(f.length))throw new Error("invalid private key");f=f.padStart(y*2,"0")}let A;try{A=typeof f=="bigint"?f:Fs(gt("private key",f,y))}catch{throw new Error("invalid private key, expected hex or "+y+" bytes, got "+typeof f)}return b&&(A=lt(A,E)),ns("private key",A,qe,E),A}function l(f){if(!(f instanceof d))throw new Error("ProjectivePoint expected")}const h=wo((f,m)=>{const{px:y,py:b,pz:E}=f;if(s.eql(E,s.ONE))return{x:y,y:b};const A=f.is0();m==null&&(m=A?s.ONE:s.inv(E));const $=s.mul(y,m),P=s.mul(b,m),S=s.mul(E,m);if(A)return{x:s.ZERO,y:s.ZERO};if(!s.eql(S,s.ONE))throw new Error("invZ was invalid");return{x:$,y:P}}),u=wo(f=>{if(f.is0()){if(e.allowInfinityPoint&&!s.is0(f.py))return;throw new Error("bad point: ZERO")}const{x:m,y}=f.toAffine();if(!s.isValid(m)||!s.isValid(y))throw new Error("bad point: x or y not FE");const b=s.sqr(y),E=o(m);if(!s.eql(b,E))throw new Error("bad point: equation left != right");if(!f.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class d{constructor(m,y,b){if(this.px=m,this.py=y,this.pz=b,m==null||!s.isValid(m))throw new Error("x required");if(y==null||!s.isValid(y))throw new Error("y required");if(b==null||!s.isValid(b))throw new Error("z required");Object.freeze(this)}static fromAffine(m){const{x:y,y:b}=m||{};if(!m||!s.isValid(y)||!s.isValid(b))throw new Error("invalid affine point");if(m instanceof d)throw new Error("projective point not allowed");const E=A=>s.eql(A,s.ZERO);return E(y)&&E(b)?d.ZERO:new d(y,b,s.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(m){const y=s.invertBatch(m.map(b=>b.pz));return m.map((b,E)=>b.toAffine(y[E])).map(d.fromAffine)}static fromHex(m){const y=d.fromAffine(n(gt("pointHex",m)));return y.assertValidity(),y}static fromPrivateKey(m){return d.BASE.multiply(c(m))}static msm(m,y){return Vf(d,r,m,y)}_setWindowSize(m){w.setWindowSize(this,m)}assertValidity(){u(this)}hasEvenY(){const{y:m}=this.toAffine();if(s.isOdd)return!s.isOdd(m);throw new Error("Field doesn't support isOdd")}equals(m){l(m);const{px:y,py:b,pz:E}=this,{px:A,py:$,pz:P}=m,S=s.eql(s.mul(y,P),s.mul(A,E)),D=s.eql(s.mul(b,P),s.mul($,E));return S&&D}negate(){return new d(this.px,s.neg(this.py),this.pz)}double(){const{a:m,b:y}=e,b=s.mul(y,Za),{px:E,py:A,pz:$}=this;let P=s.ZERO,S=s.ZERO,D=s.ZERO,v=s.mul(E,E),x=s.mul(A,A),C=s.mul($,$),L=s.mul(E,A);return L=s.add(L,L),D=s.mul(E,$),D=s.add(D,D),P=s.mul(m,D),S=s.mul(b,C),S=s.add(P,S),P=s.sub(x,S),S=s.add(x,S),S=s.mul(P,S),P=s.mul(L,P),D=s.mul(b,D),C=s.mul(m,C),L=s.sub(v,C),L=s.mul(m,L),L=s.add(L,D),D=s.add(v,v),v=s.add(D,v),v=s.add(v,C),v=s.mul(v,L),S=s.add(S,v),C=s.mul(A,$),C=s.add(C,C),v=s.mul(C,L),P=s.sub(P,v),D=s.mul(C,x),D=s.add(D,D),D=s.add(D,D),new d(P,S,D)}add(m){l(m);const{px:y,py:b,pz:E}=this,{px:A,py:$,pz:P}=m;let S=s.ZERO,D=s.ZERO,v=s.ZERO;const x=e.a,C=s.mul(e.b,Za);let L=s.mul(y,A),H=s.mul(b,$),I=s.mul(E,P),T=s.add(y,b),_=s.add(A,$);T=s.mul(T,_),_=s.add(L,H),T=s.sub(T,_),_=s.add(y,E);let B=s.add(A,P);return _=s.mul(_,B),B=s.add(L,I),_=s.sub(_,B),B=s.add(b,E),S=s.add($,P),B=s.mul(B,S),S=s.add(H,I),B=s.sub(B,S),v=s.mul(x,_),S=s.mul(C,I),v=s.add(S,v),S=s.sub(H,v),v=s.add(H,v),D=s.mul(S,v),H=s.add(L,L),H=s.add(H,L),I=s.mul(x,I),_=s.mul(C,_),H=s.add(H,I),I=s.sub(L,I),I=s.mul(x,I),_=s.add(_,I),L=s.mul(H,_),D=s.add(D,L),L=s.mul(B,_),S=s.mul(T,S),S=s.sub(S,L),L=s.mul(T,H),v=s.mul(B,v),v=s.add(v,L),new d(S,D,v)}subtract(m){return this.add(m.negate())}is0(){return this.equals(d.ZERO)}wNAF(m){return w.wNAFCached(this,m,d.normalizeZ)}multiplyUnsafe(m){const{endo:y,n:b}=e;ns("scalar",m,is,b);const E=d.ZERO;if(m===is)return E;if(this.is0()||m===qe)return this;if(!y||w.hasPrecomputes(this))return w.wNAFCachedUnsafe(this,m,d.normalizeZ);let{k1neg:A,k1:$,k2neg:P,k2:S}=y.splitScalar(m),D=E,v=E,x=this;for(;$>is||S>is;)$&qe&&(D=D.add(x)),S&qe&&(v=v.add(x)),x=x.double(),$>>=qe,S>>=qe;return A&&(D=D.negate()),P&&(v=v.negate()),v=new d(s.mul(v.px,y.beta),v.py,v.pz),D.add(v)}multiply(m){const{endo:y,n:b}=e;ns("scalar",m,qe,b);let E,A;if(y){const{k1neg:$,k1:P,k2neg:S,k2:D}=y.splitScalar(m);let{p:v,f:x}=this.wNAF(P),{p:C,f:L}=this.wNAF(D);v=w.constTimeNegate($,v),C=w.constTimeNegate(S,C),C=new d(s.mul(C.px,y.beta),C.py,C.pz),E=v.add(C),A=x.add(L)}else{const{p:$,f:P}=this.wNAF(m);E=$,A=P}return d.normalizeZ([E,A])[0]}multiplyAndAddUnsafe(m,y,b){const E=d.BASE,A=(P,S)=>S===is||S===qe||!P.equals(E)?P.multiplyUnsafe(S):P.multiply(S),$=A(this,y).add(A(m,b));return $.is0()?void 0:$}toAffine(m){return h(this,m)}isTorsionFree(){const{h:m,isTorsionFree:y}=e;if(m===qe)return!0;if(y)return y(d,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:m,clearCofactor:y}=e;return m===qe?this:y?y(d,this):this.multiplyUnsafe(e.h)}toRawBytes(m=!0){return Rr("isCompressed",m),this.assertValidity(),i(d,this,m)}toHex(m=!0){return Rr("isCompressed",m),Ur(this.toRawBytes(m))}}d.BASE=new d(e.Gx,e.Gy,s.ONE),d.ZERO=new d(s.ZERO,s.ONE,s.ZERO);const g=e.nBitLength,w=Hf(d,e.endo?Math.ceil(g/2):g);return{CURVE:e,ProjectivePoint:d,normPrivateKeyToScalar:c,weierstrassEquation:o,isWithinCurveOrder:a}}function ng(t){const e=th(t);return zr(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function og(t){const e=ng(t),{Fp:s,n:r}=e,i=s.BYTES+1,n=2*s.BYTES+1;function o(I){return lt(I,r)}function a(I){return bo(I,r)}const{ProjectivePoint:c,normPrivateKeyToScalar:l,weierstrassEquation:h,isWithinCurveOrder:u}=ig({...e,toBytes(I,T,_){const B=T.toAffine(),j=s.toBytes(B.x),k=Ci;return Rr("isCompressed",_),_?k(Uint8Array.from([T.hasEvenY()?2:3]),j):k(Uint8Array.from([4]),j,s.toBytes(B.y))},fromBytes(I){const T=I.length,_=I[0],B=I.subarray(1);if(T===i&&(_===2||_===3)){const j=Fs(B);if(!Cn(j,qe,s.ORDER))throw new Error("Point is not on curve");const k=h(j);let G;try{G=s.sqrt(k)}catch(se){const Ce=se instanceof Error?": "+se.message:"";throw new Error("Point is not on curve"+Ce)}const Q=(G&qe)===qe;return(_&1)===1!==Q&&(G=s.neg(G)),{x:j,y:G}}else if(T===n&&_===4){const j=s.fromBytes(B.subarray(0,s.BYTES)),k=s.fromBytes(B.subarray(s.BYTES,2*s.BYTES));return{x:j,y:k}}else{const j=i,k=n;throw new Error("invalid Point, expected length of "+j+", or uncompressed "+k+", got "+T)}}}),d=I=>Ur(Lr(I,e.nByteLength));function g(I){const T=r>>qe;return I>T}function w(I){return g(I)?o(-I):I}const f=(I,T,_)=>Fs(I.slice(T,_));class m{constructor(T,_,B){this.r=T,this.s=_,this.recovery=B,this.assertValidity()}static fromCompact(T){const _=e.nByteLength;return T=gt("compactSignature",T,_*2),new m(f(T,0,_),f(T,_,2*_))}static fromDER(T){const{r:_,s:B}=rs.toSig(gt("DER",T));return new m(_,B)}assertValidity(){ns("r",this.r,qe,r),ns("s",this.s,qe,r)}addRecoveryBit(T){return new m(this.r,this.s,T)}recoverPublicKey(T){const{r:_,s:B,recovery:j}=this,k=P(gt("msgHash",T));if(j==null||![0,1,2,3].includes(j))throw new Error("recovery id invalid");const G=j===2||j===3?_+e.n:_;if(G>=s.ORDER)throw new Error("recovery id 2 or 3 invalid");const Q=j&1?"03":"02",se=c.fromHex(Q+d(G)),Ce=a(G),de=o(-k*Ce),Te=o(B*Ce),Le=c.BASE.multiplyAndAddUnsafe(se,de,Te);if(!Le)throw new Error("point at infinify");return Le.assertValidity(),Le}hasHighS(){return g(this.s)}normalizeS(){return this.hasHighS()?new m(this.r,o(-this.s),this.recovery):this}toDERRawBytes(){return Dr(this.toDERHex())}toDERHex(){return rs.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Dr(this.toCompactHex())}toCompactHex(){return d(this.r)+d(this.s)}}const y={isValidPrivateKey(I){try{return l(I),!0}catch{return!1}},normPrivateKeyToScalar:l,randomPrivateKey:()=>{const I=Xl(e.n);return Ff(e.randomBytes(I),e.n)},precompute(I=8,T=c.BASE){return T._setWindowSize(I),T.multiply(BigInt(3)),T}};function b(I,T=!0){return c.fromPrivateKey(I).toRawBytes(T)}function E(I){const T=Ks(I),_=typeof I=="string",B=(T||_)&&I.length;return T?B===i||B===n:_?B===2*i||B===2*n:I instanceof c}function A(I,T,_=!0){if(E(I))throw new Error("first arg must be private key");if(!E(T))throw new Error("second arg must be public key");return c.fromHex(T).multiply(l(I)).toRawBytes(_)}const $=e.bits2int||function(I){if(I.length>8192)throw new Error("input is too large");const T=Fs(I),_=I.length*8-e.nBitLength;return _>0?T>>BigInt(_):T},P=e.bits2int_modN||function(I){return o($(I))},S=Jo(e.nBitLength);function D(I){return ns("num < 2^"+e.nBitLength,I,is,S),Lr(I,e.nByteLength)}function v(I,T,_=x){if(["recovered","canonical"].some(xe=>xe in _))throw new Error("sign() legacy options not supported");const{hash:B,randomBytes:j}=e;let{lowS:k,prehash:G,extraEntropy:Q}=_;k==null&&(k=!0),I=gt("msgHash",I),Ya(_),G&&(I=gt("prehashed msgHash",B(I)));const se=P(I),Ce=l(T),de=[D(Ce),D(se)];if(Q!=null&&Q!==!1){const xe=Q===!0?j(s.BYTES):Q;de.push(gt("extraEntropy",xe))}const Te=Ci(...de),Le=se;function Ye(xe){const Re=$(xe);if(!u(Re))return;const Ps=a(Re),Jt=c.BASE.multiply(Re).toAffine(),Mt=o(Jt.x);if(Mt===is)return;const Yt=o(Ps*o(Le+Mt*Ce));if(Yt===is)return;let Zt=(Jt.x===Mt?0:2)|Number(Jt.y&qe),Bi=Yt;return k&&g(Yt)&&(Bi=w(Yt),Zt^=1),new m(Mt,Bi,Zt)}return{seed:Te,k2sig:Ye}}const x={lowS:e.lowS,prehash:!1},C={lowS:e.lowS,prehash:!1};function L(I,T,_=x){const{seed:B,k2sig:j}=v(I,T,_),k=e;return Kl(k.hash.outputLen,k.nByteLength,k.hmac)(B,j)}c.BASE._setWindowSize(8);function H(I,T,_,B=C){var Yt;const j=I;T=gt("msgHash",T),_=gt("publicKey",_);const{lowS:k,prehash:G,format:Q}=B;if(Ya(B),"strict"in B)throw new Error("options.strict was renamed to lowS");if(Q!==void 0&&Q!=="compact"&&Q!=="der")throw new Error("format must be compact or der");const se=typeof j=="string"||Ks(j),Ce=!se&&!Q&&typeof j=="object"&&j!==null&&typeof j.r=="bigint"&&typeof j.s=="bigint";if(!se&&!Ce)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let de,Te;try{if(Ce&&(de=new m(j.r,j.s)),se){try{Q!=="compact"&&(de=m.fromDER(j))}catch(Zt){if(!(Zt instanceof rs.Err))throw Zt}!de&&Q!=="der"&&(de=m.fromCompact(j))}Te=c.fromHex(_)}catch{return!1}if(!de||k&&de.hasHighS())return!1;G&&(T=e.hash(T));const{r:Le,s:Ye}=de,xe=P(T),Re=a(Ye),Ps=o(xe*Re),Jt=o(Le*Re),Mt=(Yt=c.BASE.multiplyAndAddUnsafe(Te,Ps,Jt))==null?void 0:Yt.toAffine();return Mt?o(Mt.x)===Le:!1}return{CURVE:e,getPublicKey:b,getSharedSecret:A,sign:L,verify:H,ProjectivePoint:c,Signature:m,utils:y}}function ag(t){return{hash:t,hmac:(e,...s)=>yn(t,e,hp(...s)),randomBytes:Wr}}function cg(t,e){const s=r=>og({...t,...ag(r)});return{...s(e),create:s}}const sh=Yl(BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff")),lg=sh.create(BigInt("-3")),hg=BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),ug=cg({a:lg,b:hg,Fp:sh,n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"),h:BigInt(1),lowS:!1},$i),rh="base10",tt="base16",Dt="base64pad",ms="base64url",Ri="utf8",ih=0,os=1,Ui=2,dg=0,Xa=1,ui=12,Yo=32;function pg(){const t=Eo.utils.randomPrivateKey(),e=Eo.getPublicKey(t);return{privateKey:ht(t,tt),publicKey:ht(e,tt)}}function Co(){const t=Wr(Yo);return ht(t,tt)}function fg(t,e){const s=Eo.getSharedSecret(St(t,tt),St(e,tt)),r=yf($i,s,void 0,void 0,Yo);return ht(r,tt)}function en(t){const e=$i(St(t,tt));return ht(e,tt)}function Ht(t){const e=$i(St(t,Ri));return ht(e,tt)}function nh(t){return St(`${t}`,rh)}function Gs(t){return Number(ht(t,rh))}function oh(t){return t.replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function ah(t){const e=t.replace(/-/g,"+").replace(/_/g,"/"),s=(4-e.length%4)%4;return e+"=".repeat(s)}function gg(t){const e=nh(typeof t.type<"u"?t.type:ih);if(Gs(e)===os&&typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const s=typeof t.senderPublicKey<"u"?St(t.senderPublicKey,tt):void 0,r=typeof t.iv<"u"?St(t.iv,tt):Wr(ui),i=St(t.symKey,tt),n=zl(i,r).encrypt(St(t.message,Ri)),o=ch({type:e,sealed:n,iv:r,senderPublicKey:s});return t.encoding===ms?oh(o):o}function mg(t){const e=St(t.symKey,tt),{sealed:s,iv:r}=Ii({encoded:t.encoded,encoding:t.encoding}),i=zl(e,r).decrypt(s);if(i===null)throw new Error("Failed to decrypt");return ht(i,Ri)}function wg(t,e){const s=nh(Ui),r=Wr(ui),i=St(t,Ri),n=ch({type:s,sealed:i,iv:r});return e===ms?oh(n):n}function yg(t,e){const{sealed:s}=Ii({encoded:t,encoding:e});return ht(s,Ri)}function ch(t){if(Gs(t.type)===Ui)return ht(ai([t.type,t.sealed]),Dt);if(Gs(t.type)===os){if(typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return ht(ai([t.type,t.senderPublicKey,t.iv,t.sealed]),Dt)}return ht(ai([t.type,t.iv,t.sealed]),Dt)}function Ii(t){const e=(t.encoding||Dt)===ms?ah(t.encoded):t.encoded,s=St(e,Dt),r=s.slice(dg,Xa),i=Xa;if(Gs(r)===os){const c=i+Yo,l=c+ui,h=s.slice(i,c),u=s.slice(c,l),d=s.slice(l);return{type:r,sealed:d,iv:u,senderPublicKey:h}}if(Gs(r)===Ui){const c=s.slice(i),l=Wr(ui);return{type:r,sealed:c,iv:l}}const n=i+ui,o=s.slice(i,n),a=s.slice(n);return{type:r,sealed:a,iv:o}}function bg(t,e){const s=Ii({encoded:t,encoding:e==null?void 0:e.encoding});return lh({type:Gs(s.type),senderPublicKey:typeof s.senderPublicKey<"u"?ht(s.senderPublicKey,tt):void 0,receiverPublicKey:e==null?void 0:e.receiverPublicKey})}function lh(t){const e=(t==null?void 0:t.type)||ih;if(e===os){if(typeof(t==null?void 0:t.senderPublicKey)>"u")throw new Error("missing sender public key");if(typeof(t==null?void 0:t.receiverPublicKey)>"u")throw new Error("missing receiver public key")}return{type:e,senderPublicKey:t==null?void 0:t.senderPublicKey,receiverPublicKey:t==null?void 0:t.receiverPublicKey}}function Qa(t){return t.type===os&&typeof t.senderPublicKey=="string"&&typeof t.receiverPublicKey=="string"}function ec(t){return t.type===Ui}function vg(t){const e=Buffer.from(t.x,"base64"),s=Buffer.from(t.y,"base64");return ai([new Uint8Array([4]),e,s])}function Eg(t,e){const[s,r,i]=t.split("."),n=Buffer.from(ah(i),"base64");if(n.length!==64)throw new Error("Invalid signature length");const o=n.slice(0,32),a=n.slice(32,64),c=`${s}.${r}`,l=$i(c),h=vg(e);if(!ug.verify(ai([o,a]),l,h))throw new Error("Invalid signature");return no(t).payload}const Cg="irn";function un(t){return(t==null?void 0:t.relay)||{protocol:Cg}}function ii(t){const e=eu[t];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${t}`);return e}function Ig(t,e="-"){const s={},r="relay"+e;return Object.keys(t).forEach(i=>{if(i.startsWith(r)){const n=i.replace(r,""),o=t[i];s[n]=o}}),s}function tc(t){if(!t.includes("wc:")){const l=kl(t);l!=null&&l.includes("wc:")&&(t=l)}t=t.includes("wc://")?t.replace("wc://",""):t,t=t.includes("wc:")?t.replace("wc:",""):t;const e=t.indexOf(":"),s=t.indexOf("?")!==-1?t.indexOf("?"):void 0,r=t.substring(0,e),i=t.substring(e+1,s).split("@"),n=typeof s<"u"?t.substring(s):"",o=new URLSearchParams(n),a={};o.forEach((l,h)=>{a[h]=l});const c=typeof a.methods=="string"?a.methods.split(","):void 0;return{protocol:r,topic:Ag(i[0]),version:parseInt(i[1],10),symKey:a.symKey,relay:Ig(a),methods:c,expiryTimestamp:a.expiryTimestamp?parseInt(a.expiryTimestamp,10):void 0}}function Ag(t){return t.startsWith("//")?t.substring(2):t}function Ng(t,e="-"){const s="relay",r={};return Object.keys(t).forEach(i=>{const n=i,o=s+e+n;t[n]&&(r[o]=t[n])}),r}function sc(t){const e=new URLSearchParams,s=Ng(t.relay);Object.keys(s).sort().forEach(i=>{e.set(i,s[i])}),e.set("symKey",t.symKey),t.expiryTimestamp&&e.set("expiryTimestamp",t.expiryTimestamp.toString()),t.methods&&e.set("methods",t.methods.join(","));const r=e.toString();return`${t.protocol}:${t.topic}@${t.version}?${r}`}function Hi(t,e,s){return`${t}?wc_ev=${s}&topic=${e}`}var _g=Object.defineProperty,Sg=Object.defineProperties,Pg=Object.getOwnPropertyDescriptors,rc=Object.getOwnPropertySymbols,Og=Object.prototype.hasOwnProperty,Tg=Object.prototype.propertyIsEnumerable,ic=(t,e,s)=>e in t?_g(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,kg=(t,e)=>{for(var s in e||(e={}))Og.call(e,s)&&ic(t,s,e[s]);if(rc)for(var s of rc(e))Tg.call(e,s)&&ic(t,s,e[s]);return t},$g=(t,e)=>Sg(t,Pg(e));function Hr(t){const e=[];return t.forEach(s=>{const[r,i]=s.split(":");e.push(`${r}:${i}`)}),e}function xg(t){const e=[];return Object.values(t).forEach(s=>{e.push(...Hr(s.accounts))}),e}function Rg(t,e){const s=[];return Object.values(t).forEach(r=>{Hr(r.accounts).includes(e)&&s.push(...r.methods)}),s}function Ug(t,e){const s=[];return Object.values(t).forEach(r=>{Hr(r.accounts).includes(e)&&s.push(...r.events)}),s}function In(t){return t.includes(":")}function Ar(t){return In(t)?t.split(":")[0]:t}function nc(t){var e,s,r;const i={};if(!Is(t))return i;for(const[n,o]of Object.entries(t)){const a=In(n)?[n]:o.chains,c=o.methods||[],l=o.events||[],h=Ar(n);i[h]=$g(kg({},i[h]),{chains:Kt(a,(e=i[h])==null?void 0:e.chains),methods:Kt(c,(s=i[h])==null?void 0:s.methods),events:Kt(l,(r=i[h])==null?void 0:r.events)})}return i}function Dg(t){const e={};return t==null||t.forEach(s=>{var r;const[i,n]=s.split(":");e[i]||(e[i]={accounts:[],chains:[],events:[],methods:[]}),e[i].accounts.push(s),(r=e[i].chains)==null||r.push(`${i}:${n}`)}),e}function oc(t,e){e=e.map(r=>r.replace("did:pkh:",""));const s=Dg(e);for(const[r,i]of Object.entries(s))i.methods?i.methods=Kt(i.methods,t):i.methods=t,i.events=["chainChanged","accountsChanged"];return s}function Lg(t,e){var s,r,i,n,o,a;const c=nc(t),l=nc(e),h={},u=Object.keys(c).concat(Object.keys(l));for(const d of u)h[d]={chains:Kt((s=c[d])==null?void 0:s.chains,(r=l[d])==null?void 0:r.chains),methods:Kt((i=c[d])==null?void 0:i.methods,(n=l[d])==null?void 0:n.methods),events:Kt((o=c[d])==null?void 0:o.events,(a=l[d])==null?void 0:a.events)};return h}const Mg={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}},Bg={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 R(t,e){const{message:s,code:r}=Bg[t];return{message:e?`${s} ${e}`:s,code:r}}function we(t,e){const{message:s,code:r}=Mg[t];return{message:e?`${s} ${e}`:s,code:r}}function Cs(t,e){return!!Array.isArray(t)}function Is(t){return Object.getPrototypeOf(t)===Object.prototype&&Object.keys(t).length}function Ge(t){return typeof t>"u"}function $e(t,e){return e&&Ge(t)?!0:typeof t=="string"&&!!t.trim().length}function Zo(t,e){return e&&Ge(t)?!0:typeof t=="number"&&!isNaN(t)}function qg(t,e){const{requiredNamespaces:s}=e,r=Object.keys(t.namespaces),i=Object.keys(s);let n=!0;return qs(i,r)?(r.forEach(o=>{const{accounts:a,methods:c,events:l}=t.namespaces[o],h=Hr(a),u=s[o];(!qs(_l(o,u),h)||!qs(u.methods,c)||!qs(u.events,l))&&(n=!1)}),n):!1}function dn(t){return $e(t,!1)&&t.includes(":")?t.split(":").length===2:!1}function jg(t){if($e(t,!1)&&t.includes(":")){const e=t.split(":");if(e.length===3){const s=e[0]+":"+e[1];return!!e[2]&&dn(s)}}return!1}function Fg(t){function e(s){try{return typeof new URL(s)<"u"}catch{return!1}}try{if($e(t,!1)){if(e(t))return!0;const s=kl(t);return e(s)}}catch{}return!1}function Wg(t){var e;return(e=t==null?void 0:t.proposer)==null?void 0:e.publicKey}function zg(t){return t==null?void 0:t.topic}function Hg(t,e){let s=null;return $e(t==null?void 0:t.publicKey,!1)||(s=R("MISSING_OR_INVALID",`${e} controller public key should be a string`)),s}function ac(t){let e=!0;return Cs(t)?t.length&&(e=t.every(s=>$e(s,!1))):e=!1,e}function Vg(t,e,s){let r=null;return Cs(e)&&e.length?e.forEach(i=>{r||dn(i)||(r=we("UNSUPPORTED_CHAINS",`${s}, chain ${i} should be a string and conform to "namespace:chainId" format`))}):dn(t)||(r=we("UNSUPPORTED_CHAINS",`${s}, 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"] }`)),r}function Kg(t,e,s){let r=null;return Object.entries(t).forEach(([i,n])=>{if(r)return;const o=Vg(i,_l(i,n),`${e} ${s}`);o&&(r=o)}),r}function Gg(t,e){let s=null;return Cs(t)?t.forEach(r=>{s||jg(r)||(s=we("UNSUPPORTED_ACCOUNTS",`${e}, account ${r} should be a string and conform to "namespace:chainId:address" format`))}):s=we("UNSUPPORTED_ACCOUNTS",`${e}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),s}function Jg(t,e){let s=null;return Object.values(t).forEach(r=>{if(s)return;const i=Gg(r==null?void 0:r.accounts,`${e} namespace`);i&&(s=i)}),s}function Yg(t,e){let s=null;return ac(t==null?void 0:t.methods)?ac(t==null?void 0:t.events)||(s=we("UNSUPPORTED_EVENTS",`${e}, events should be an array of strings or empty array for no events`)):s=we("UNSUPPORTED_METHODS",`${e}, methods should be an array of strings or empty array for no methods`),s}function hh(t,e){let s=null;return Object.values(t).forEach(r=>{if(s)return;const i=Yg(r,`${e}, namespace`);i&&(s=i)}),s}function Zg(t,e,s){let r=null;if(t&&Is(t)){const i=hh(t,e);i&&(r=i);const n=Kg(t,e,s);n&&(r=n)}else r=R("MISSING_OR_INVALID",`${e}, ${s} should be an object with data`);return r}function Fn(t,e){let s=null;if(t&&Is(t)){const r=hh(t,e);r&&(s=r);const i=Jg(t,e);i&&(s=i)}else s=R("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return s}function uh(t){return $e(t.protocol,!0)}function Xg(t,e){let s=!1;return t?t&&Cs(t)&&t.length&&t.forEach(r=>{s=uh(r)}):s=!0,s}function Qg(t){return typeof t=="number"}function ct(t){return typeof t<"u"&&typeof t!==null}function em(t){return!(!t||typeof t!="object"||!t.code||!Zo(t.code,!1)||!t.message||!$e(t.message,!1))}function tm(t){return!(Ge(t)||!$e(t.method,!1))}function sm(t){return!(Ge(t)||Ge(t.result)&&Ge(t.error)||!Zo(t.id,!1)||!$e(t.jsonrpc,!1))}function rm(t){return!(Ge(t)||!$e(t.name,!1))}function cc(t,e){return!(!dn(e)||!xg(t).includes(e))}function im(t,e,s){return $e(s,!1)?Rg(t,e).includes(s):!1}function nm(t,e,s){return $e(s,!1)?Ug(t,e).includes(s):!1}function lc(t,e,s){let r=null;const i=om(t),n=am(e),o=Object.keys(i),a=Object.keys(n),c=hc(Object.keys(t)),l=hc(Object.keys(e)),h=c.filter(u=>!l.includes(u));return h.length&&(r=R("NON_CONFORMING_NAMESPACES",`${s} namespaces keys don't satisfy requiredNamespaces.
8
+ Required: ${h.toString()}
9
+ Received: ${Object.keys(e).toString()}`)),qs(o,a)||(r=R("NON_CONFORMING_NAMESPACES",`${s} namespaces chains don't satisfy required namespaces.
10
+ Required: ${o.toString()}
11
+ Approved: ${a.toString()}`)),Object.keys(e).forEach(u=>{if(!u.includes(":")||r)return;const d=Hr(e[u].accounts);d.includes(u)||(r=R("NON_CONFORMING_NAMESPACES",`${s} namespaces accounts don't satisfy namespace accounts for ${u}
12
+ Required: ${u}
13
+ Approved: ${d.toString()}`))}),o.forEach(u=>{r||(qs(i[u].methods,n[u].methods)?qs(i[u].events,n[u].events)||(r=R("NON_CONFORMING_NAMESPACES",`${s} namespaces events don't satisfy namespace events for ${u}`)):r=R("NON_CONFORMING_NAMESPACES",`${s} namespaces methods don't satisfy namespace methods for ${u}`))}),r}function om(t){const e={};return Object.keys(t).forEach(s=>{var r;s.includes(":")?e[s]=t[s]:(r=t[s].chains)==null||r.forEach(i=>{e[i]={methods:t[s].methods,events:t[s].events}})}),e}function hc(t){return[...new Set(t.map(e=>e.includes(":")?e.split(":")[0]:e))]}function am(t){const e={};return Object.keys(t).forEach(s=>{if(s.includes(":"))e[s]=t[s];else{const r=Hr(t[s].accounts);r==null||r.forEach(i=>{e[i]={accounts:t[s].accounts.filter(n=>n.includes(`${i}:`)),methods:t[s].methods,events:t[s].events}})}}),e}function cm(t,e){return Zo(t,!1)&&t<=e.max&&t>=e.min}function uc(){const t=Ti();return new Promise(e=>{switch(t){case wt.browser:e(lm());break;case wt.reactNative:e(hm());break;case wt.node:e(um());break;default:e(!0)}})}function lm(){return Fr()&&(navigator==null?void 0:navigator.onLine)}async function hm(){if(Ss()&&typeof global<"u"&&global!=null&&global.NetInfo){const t=await(global==null?void 0:global.NetInfo.fetch());return t==null?void 0:t.isConnected}return!0}function um(){return!0}function dm(t){switch(Ti()){case wt.browser:pm(t);break;case wt.reactNative:fm(t);break}}function pm(t){!Ss()&&Fr()&&(window.addEventListener("online",()=>t(!0)),window.addEventListener("offline",()=>t(!1)))}function fm(t){Ss()&&typeof global<"u"&&global!=null&&global.NetInfo&&(global==null||global.NetInfo.addEventListener(e=>t(e==null?void 0:e.isConnected)))}function gm(){var t;return Fr()&&Or()?((t=Or())==null?void 0:t.visibilityState)==="visible":!0}const Wn={};class Jr{static get(e){return Wn[e]}static set(e,s){Wn[e]=s}static delete(e){delete Wn[e]}}var mm={};const dh="wc",ph=2,Io="core",Gt=`${dh}@2:${Io}:`,wm={logger:"error"},ym={database:":memory:"},bm="crypto",dc="client_ed25519_seed",vm=U.ONE_DAY,Em="keychain",Cm="0.3",Im="messages",Am="0.3",pc=U.SIX_HOURS,Nm="publisher",fh="irn",_m="error",gh="wss://relay.walletconnect.org",Sm="relayer",je={message:"relayer_message",message_ack:"relayer_message_ack",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error",connection_stalled:"relayer_connection_stalled",transport_closed:"relayer_transport_closed",publish:"relayer_publish"},Pm="_subscription",It={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},Om=.1,Ao="2.21.0",Ne={link_mode:"link_mode",relay:"relay"},tn={inbound:"inbound",outbound:"outbound"},Tm="0.3",km="WALLETCONNECT_CLIENT_ID",fc="WALLETCONNECT_LINK_MODE_APPS",pt={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"},$m="subscription",xm="0.3",Rm="pairing",Um="0.3",Yr={wc_pairingDelete:{req:{ttl:U.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:U.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:U.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:U.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:U.ONE_DAY,prompt:!1,tag:0},res:{ttl:U.ONE_DAY,prompt:!1,tag:0}}},Ls={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},Tt={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},Dm="history",Lm="0.3",Mm="expirer",_t={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},Bm="0.3",qm="verify-api",jm="https://verify.walletconnect.com",mh="https://verify.walletconnect.org",di=mh,Fm=`${di}/v3`,Wm=[jm,mh],zm="echo",Hm="https://echo.walletconnect.com",Ft={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",subscribing_to_pairing_topic:"subscribing_to_pairing_topic"},ss={no_wss_connection:"no_wss_connection",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_expired:"proposal_expired",proposal_listener_not_found:"proposal_listener_not_found"},kt={session_approve_started:"session_approve_started",proposal_not_expired:"proposal_not_expired",session_namespaces_validation_success:"session_namespaces_validation_success",create_session_topic:"create_session_topic",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"},Ts={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_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"},ks={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"},Zr={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"},Vm=.1,Km="event-client",Gm=86400,Jm="https://pulse.walletconnect.org/batch";function Ym(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var s=new Uint8Array(256),r=0;r<s.length;r++)s[r]=255;for(var i=0;i<t.length;i++){var n=t.charAt(i),o=n.charCodeAt(0);if(s[o]!==255)throw new TypeError(n+" is ambiguous");s[o]=i}var a=t.length,c=t.charAt(0),l=Math.log(a)/Math.log(256),h=Math.log(256)/Math.log(a);function u(w){if(w instanceof Uint8Array||(ArrayBuffer.isView(w)?w=new Uint8Array(w.buffer,w.byteOffset,w.byteLength):Array.isArray(w)&&(w=Uint8Array.from(w))),!(w instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(w.length===0)return"";for(var f=0,m=0,y=0,b=w.length;y!==b&&w[y]===0;)y++,f++;for(var E=(b-y)*h+1>>>0,A=new Uint8Array(E);y!==b;){for(var $=w[y],P=0,S=E-1;($!==0||P<m)&&S!==-1;S--,P++)$+=256*A[S]>>>0,A[S]=$%a>>>0,$=$/a>>>0;if($!==0)throw new Error("Non-zero carry");m=P,y++}for(var D=E-m;D!==E&&A[D]===0;)D++;for(var v=c.repeat(f);D<E;++D)v+=t.charAt(A[D]);return v}function d(w){if(typeof w!="string")throw new TypeError("Expected String");if(w.length===0)return new Uint8Array;var f=0;if(w[f]!==" "){for(var m=0,y=0;w[f]===c;)m++,f++;for(var b=(w.length-f)*l+1>>>0,E=new Uint8Array(b);w[f];){var A=s[w.charCodeAt(f)];if(A===255)return;for(var $=0,P=b-1;(A!==0||$<y)&&P!==-1;P--,$++)A+=a*E[P]>>>0,E[P]=A%256>>>0,A=A/256>>>0;if(A!==0)throw new Error("Non-zero carry");y=$,f++}if(w[f]!==" "){for(var S=b-y;S!==b&&E[S]===0;)S++;for(var D=new Uint8Array(m+(b-S)),v=m;S!==b;)D[v++]=E[S++];return D}}}function g(w){var f=d(w);if(f)return f;throw new Error(`Non-${e} character`)}return{encode:u,decodeUnsafe:d,decode:g}}var Zm=Ym,Xm=Zm;const wh=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")},Qm=t=>new TextEncoder().encode(t),ew=t=>new TextDecoder().decode(t);class tw{constructor(e,s,r){this.name=e,this.prefix=s,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class sw{constructor(e,s,r){if(this.name=e,this.prefix=s,s.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=s.codePointAt(0),this.baseDecode=r}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 yh(this,e)}}class rw{constructor(e){this.decoders=e}or(e){return yh(this,e)}decode(e){const s=e[0],r=this.decoders[s];if(r)return r.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const yh=(t,e)=>new rw({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});class iw{constructor(e,s,r,i){this.name=e,this.prefix=s,this.baseEncode=r,this.baseDecode=i,this.encoder=new tw(e,s,r),this.decoder=new sw(e,s,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const An=({name:t,prefix:e,encode:s,decode:r})=>new iw(t,e,s,r),Di=({prefix:t,name:e,alphabet:s})=>{const{encode:r,decode:i}=Xm(s,e);return An({prefix:t,name:e,encode:r,decode:n=>wh(i(n))})},nw=(t,e,s,r)=>{const i={};for(let h=0;h<e.length;++h)i[e[h]]=h;let n=t.length;for(;t[n-1]==="=";)--n;const o=new Uint8Array(n*s/8|0);let a=0,c=0,l=0;for(let h=0;h<n;++h){const u=i[t[h]];if(u===void 0)throw new SyntaxError(`Non-${r} character`);c=c<<s|u,a+=s,a>=8&&(a-=8,o[l++]=255&c>>a)}if(a>=s||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o},ow=(t,e,s)=>{const r=e[e.length-1]==="=",i=(1<<s)-1;let n="",o=0,a=0;for(let c=0;c<t.length;++c)for(a=a<<8|t[c],o+=8;o>s;)o-=s,n+=e[i&a>>o];if(o&&(n+=e[i&a<<s-o]),r)for(;n.length*s&7;)n+="=";return n},Je=({name:t,prefix:e,bitsPerChar:s,alphabet:r})=>An({prefix:e,name:t,encode(i){return ow(i,r,s)},decode(i){return nw(i,r,s,t)}}),aw=An({prefix:"\0",name:"identity",encode:t=>ew(t),decode:t=>Qm(t)});var cw=Object.freeze({__proto__:null,identity:aw});const lw=Je({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var hw=Object.freeze({__proto__:null,base2:lw});const uw=Je({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var dw=Object.freeze({__proto__:null,base8:uw});const pw=Di({prefix:"9",name:"base10",alphabet:"0123456789"});var fw=Object.freeze({__proto__:null,base10:pw});const gw=Je({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),mw=Je({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var ww=Object.freeze({__proto__:null,base16:gw,base16upper:mw});const yw=Je({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),bw=Je({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),vw=Je({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Ew=Je({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Cw=Je({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Iw=Je({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Aw=Je({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Nw=Je({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),_w=Je({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Sw=Object.freeze({__proto__:null,base32:yw,base32upper:bw,base32pad:vw,base32padupper:Ew,base32hex:Cw,base32hexupper:Iw,base32hexpad:Aw,base32hexpadupper:Nw,base32z:_w});const Pw=Di({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Ow=Di({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Tw=Object.freeze({__proto__:null,base36:Pw,base36upper:Ow});const kw=Di({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),$w=Di({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var xw=Object.freeze({__proto__:null,base58btc:kw,base58flickr:$w});const Rw=Je({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Uw=Je({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Dw=Je({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Lw=Je({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Mw=Object.freeze({__proto__:null,base64:Rw,base64pad:Uw,base64url:Dw,base64urlpad:Lw});const bh=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),Bw=bh.reduce((t,e,s)=>(t[s]=e,t),[]),qw=bh.reduce((t,e,s)=>(t[e.codePointAt(0)]=s,t),[]);function jw(t){return t.reduce((e,s)=>(e+=Bw[s],e),"")}function Fw(t){const e=[];for(const s of t){const r=qw[s.codePointAt(0)];if(r===void 0)throw new Error(`Non-base256emoji character: ${s}`);e.push(r)}return new Uint8Array(e)}const Ww=An({prefix:"🚀",name:"base256emoji",encode:jw,decode:Fw});var zw=Object.freeze({__proto__:null,base256emoji:Ww}),Hw=vh,gc=128,Vw=-128,Kw=Math.pow(2,31);function vh(t,e,s){e=e||[],s=s||0;for(var r=s;t>=Kw;)e[s++]=t&255|gc,t/=128;for(;t&Vw;)e[s++]=t&255|gc,t>>>=7;return e[s]=t|0,vh.bytes=s-r+1,e}var Gw=No,Jw=128,mc=127;function No(t,r){var s=0,r=r||0,i=0,n=r,o,a=t.length;do{if(n>=a)throw No.bytes=0,new RangeError("Could not decode varint");o=t[n++],s+=i<28?(o&mc)<<i:(o&mc)*Math.pow(2,i),i+=7}while(o>=Jw);return No.bytes=n-r,s}var Yw=Math.pow(2,7),Zw=Math.pow(2,14),Xw=Math.pow(2,21),Qw=Math.pow(2,28),ey=Math.pow(2,35),ty=Math.pow(2,42),sy=Math.pow(2,49),ry=Math.pow(2,56),iy=Math.pow(2,63),ny=function(t){return t<Yw?1:t<Zw?2:t<Xw?3:t<Qw?4:t<ey?5:t<ty?6:t<sy?7:t<ry?8:t<iy?9:10},oy={encode:Hw,decode:Gw,encodingLength:ny},Eh=oy;const wc=(t,e,s=0)=>(Eh.encode(t,e,s),e),yc=t=>Eh.encodingLength(t),_o=(t,e)=>{const s=e.byteLength,r=yc(t),i=r+yc(s),n=new Uint8Array(i+s);return wc(t,n,0),wc(s,n,r),n.set(e,i),new ay(t,s,e,n)};class ay{constructor(e,s,r,i){this.code=e,this.size=s,this.digest=r,this.bytes=i}}const Ch=({name:t,code:e,encode:s})=>new cy(t,e,s);class cy{constructor(e,s,r){this.name=e,this.code=s,this.encode=r}digest(e){if(e instanceof Uint8Array){const s=this.encode(e);return s instanceof Uint8Array?_o(this.code,s):s.then(r=>_o(this.code,r))}else throw Error("Unknown type, must be binary type")}}const Ih=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),ly=Ch({name:"sha2-256",code:18,encode:Ih("SHA-256")}),hy=Ch({name:"sha2-512",code:19,encode:Ih("SHA-512")});var uy=Object.freeze({__proto__:null,sha256:ly,sha512:hy});const Ah=0,dy="identity",Nh=wh,py=t=>_o(Ah,Nh(t)),fy={code:Ah,name:dy,encode:Nh,digest:py};var gy=Object.freeze({__proto__:null,identity:fy});new TextEncoder,new TextDecoder;const bc={...cw,...hw,...dw,...fw,...ww,...Sw,...Tw,...xw,...Mw,...zw};({...uy,...gy});function my(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(t):new Uint8Array(t)}function _h(t,e,s,r){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:s},decoder:{decode:r}}}const vc=_h("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),zn=_h("ascii","a",t=>{let e="a";for(let s=0;s<t.length;s++)e+=String.fromCharCode(t[s]);return e},t=>{t=t.substring(1);const e=my(t.length);for(let s=0;s<t.length;s++)e[s]=t.charCodeAt(s);return e}),wy={utf8:vc,"utf-8":vc,hex:bc.base16,latin1:zn,ascii:zn,binary:zn,...bc};function yy(t,e="utf8"){const s=wy[e];if(!s)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t,"utf8"):s.decoder.decode(`${s.prefix}${t}`)}var by=Object.defineProperty,vy=(t,e,s)=>e in t?by(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,qt=(t,e,s)=>vy(t,typeof e!="symbol"?e+"":e,s);class Ey{constructor(e,s){this.core=e,this.logger=s,qt(this,"keychain",new Map),qt(this,"name",Em),qt(this,"version",Cm),qt(this,"initialized",!1),qt(this,"storagePrefix",Gt),qt(this,"init",async()=>{if(!this.initialized){const r=await this.getKeyChain();typeof r<"u"&&(this.keychain=r),this.initialized=!0}}),qt(this,"has",r=>(this.isInitialized(),this.keychain.has(r))),qt(this,"set",async(r,i)=>{this.isInitialized(),this.keychain.set(r,i),await this.persist()}),qt(this,"get",r=>{this.isInitialized();const i=this.keychain.get(r);if(typeof i>"u"){const{message:n}=R("NO_MATCHING_KEY",`${this.name}: ${r}`);throw new Error(n)}return i}),qt(this,"del",async r=>{this.isInitialized(),this.keychain.delete(r),await this.persist()}),this.core=e,this.logger=st(s,this.name)}get context(){return bt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,ho(e))}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?uo(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:e}=R("NOT_INITIALIZED",this.name);throw new Error(e)}}}var Cy=Object.defineProperty,Iy=(t,e,s)=>e in t?Cy(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Ve=(t,e,s)=>Iy(t,typeof e!="symbol"?e+"":e,s);class Ay{constructor(e,s,r){this.core=e,this.logger=s,Ve(this,"name",bm),Ve(this,"keychain"),Ve(this,"randomSessionIdentifier",Co()),Ve(this,"initialized",!1),Ve(this,"init",async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)}),Ve(this,"hasKeys",i=>(this.isInitialized(),this.keychain.has(i))),Ve(this,"getClientId",async()=>{this.isInitialized();const i=await this.getClientSeed(),n=aa(i);return au(n.publicKey)}),Ve(this,"generateKeyPair",()=>{this.isInitialized();const i=pg();return this.setPrivateKey(i.publicKey,i.privateKey)}),Ve(this,"signJWT",async i=>{this.isInitialized();const n=await this.getClientSeed(),o=aa(n),a=this.randomSessionIdentifier;return await cu(a,i,vm,o)}),Ve(this,"generateSharedKey",(i,n,o)=>{this.isInitialized();const a=this.getPrivateKey(i),c=fg(a,n);return this.setSymKey(c,o)}),Ve(this,"setSymKey",async(i,n)=>{this.isInitialized();const o=n||en(i);return await this.keychain.set(o,i),o}),Ve(this,"deleteKeyPair",async i=>{this.isInitialized(),await this.keychain.del(i)}),Ve(this,"deleteSymKey",async i=>{this.isInitialized(),await this.keychain.del(i)}),Ve(this,"encode",async(i,n,o)=>{this.isInitialized();const a=lh(o),c=lu(n);if(ec(a))return wg(c,o==null?void 0:o.encoding);if(Qa(a)){const d=a.senderPublicKey,g=a.receiverPublicKey;i=await this.generateSharedKey(d,g)}const l=this.getSymKey(i),{type:h,senderPublicKey:u}=a;return gg({type:h,symKey:l,message:c,senderPublicKey:u,encoding:o==null?void 0:o.encoding})}),Ve(this,"decode",async(i,n,o)=>{this.isInitialized();const a=bg(n,o);if(ec(a)){const c=yg(n,o==null?void 0:o.encoding);return ca(c)}if(Qa(a)){const c=a.receiverPublicKey,l=a.senderPublicKey;i=await this.generateSharedKey(c,l)}try{const c=this.getSymKey(i),l=mg({symKey:c,encoded:n,encoding:o==null?void 0:o.encoding});return ca(l)}catch(c){this.logger.error(`Failed to decode message from topic: '${i}', clientId: '${await this.getClientId()}'`),this.logger.error(c)}}),Ve(this,"getPayloadType",(i,n=Dt)=>{const o=Ii({encoded:i,encoding:n});return Gs(o.type)}),Ve(this,"getPayloadSenderPublicKey",(i,n=Dt)=>{const o=Ii({encoded:i,encoding:n});return o.senderPublicKey?ht(o.senderPublicKey,tt):void 0}),this.core=e,this.logger=st(s,this.name),this.keychain=r||new Ey(this.core,this.logger)}get context(){return bt(this.logger)}async setPrivateKey(e,s){return await this.keychain.set(e,s),e}getPrivateKey(e){return this.keychain.get(e)}async getClientSeed(){let e="";try{e=this.keychain.get(dc)}catch{e=Co(),await this.keychain.set(dc,e)}return yy(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=R("NOT_INITIALIZED",this.name);throw new Error(e)}}}var Ny=Object.defineProperty,_y=Object.defineProperties,Sy=Object.getOwnPropertyDescriptors,Ec=Object.getOwnPropertySymbols,Py=Object.prototype.hasOwnProperty,Oy=Object.prototype.propertyIsEnumerable,So=(t,e,s)=>e in t?Ny(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Ty=(t,e)=>{for(var s in e||(e={}))Py.call(e,s)&&So(t,s,e[s]);if(Ec)for(var s of Ec(e))Oy.call(e,s)&&So(t,s,e[s]);return t},ky=(t,e)=>_y(t,Sy(e)),dt=(t,e,s)=>So(t,typeof e!="symbol"?e+"":e,s);class $y extends fd{constructor(e,s){super(e,s),this.logger=e,this.core=s,dt(this,"messages",new Map),dt(this,"messagesWithoutClientAck",new Map),dt(this,"name",Im),dt(this,"version",Am),dt(this,"initialized",!1),dt(this,"storagePrefix",Gt),dt(this,"init",async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const r=await this.getRelayerMessages();typeof r<"u"&&(this.messages=r);const i=await this.getRelayerMessagesWithoutClientAck();typeof i<"u"&&(this.messagesWithoutClientAck=i),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(r){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(r)}finally{this.initialized=!0}}}),dt(this,"set",async(r,i,n)=>{this.isInitialized();const o=Ht(i);let a=this.messages.get(r);if(typeof a>"u"&&(a={}),typeof a[o]<"u")return o;if(a[o]=i,this.messages.set(r,a),n===tn.inbound){const c=this.messagesWithoutClientAck.get(r)||{};this.messagesWithoutClientAck.set(r,ky(Ty({},c),{[o]:i}))}return await this.persist(),o}),dt(this,"get",r=>{this.isInitialized();let i=this.messages.get(r);return typeof i>"u"&&(i={}),i}),dt(this,"getWithoutAck",r=>{this.isInitialized();const i={};for(const n of r){const o=this.messagesWithoutClientAck.get(n)||{};i[n]=Object.values(o)}return i}),dt(this,"has",(r,i)=>{this.isInitialized();const n=this.get(r),o=Ht(i);return typeof n[o]<"u"}),dt(this,"ack",async(r,i)=>{this.isInitialized();const n=this.messagesWithoutClientAck.get(r);if(typeof n>"u")return;const o=Ht(i);delete n[o],Object.keys(n).length===0?this.messagesWithoutClientAck.delete(r):this.messagesWithoutClientAck.set(r,n),await this.persist()}),dt(this,"del",async r=>{this.isInitialized(),this.messages.delete(r),this.messagesWithoutClientAck.delete(r),await this.persist()}),this.logger=st(e,this.name),this.core=s}get context(){return bt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get storageKeyWithoutClientAck(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name+"_withoutClientAck"}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,ho(e))}async setRelayerMessagesWithoutClientAck(e){await this.core.storage.setItem(this.storageKeyWithoutClientAck,ho(e))}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?uo(e):void 0}async getRelayerMessagesWithoutClientAck(){const e=await this.core.storage.getItem(this.storageKeyWithoutClientAck);return typeof e<"u"?uo(e):void 0}async persist(){await this.setRelayerMessages(this.messages),await this.setRelayerMessagesWithoutClientAck(this.messagesWithoutClientAck)}isInitialized(){if(!this.initialized){const{message:e}=R("NOT_INITIALIZED",this.name);throw new Error(e)}}}var xy=Object.defineProperty,Ry=Object.defineProperties,Uy=Object.getOwnPropertyDescriptors,Cc=Object.getOwnPropertySymbols,Dy=Object.prototype.hasOwnProperty,Ly=Object.prototype.propertyIsEnumerable,Po=(t,e,s)=>e in t?xy(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Vi=(t,e)=>{for(var s in e||(e={}))Dy.call(e,s)&&Po(t,s,e[s]);if(Cc)for(var s of Cc(e))Ly.call(e,s)&&Po(t,s,e[s]);return t},Hn=(t,e)=>Ry(t,Uy(e)),$t=(t,e,s)=>Po(t,typeof e!="symbol"?e+"":e,s);class My extends gd{constructor(e,s){super(e,s),this.relayer=e,this.logger=s,$t(this,"events",new Ys.EventEmitter),$t(this,"name",Nm),$t(this,"queue",new Map),$t(this,"publishTimeout",U.toMiliseconds(U.ONE_MINUTE)),$t(this,"initialPublishTimeout",U.toMiliseconds(U.ONE_SECOND*15)),$t(this,"needsTransportRestart",!1),$t(this,"publish",async(r,i,n)=>{var o;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:r,message:i,opts:n}});const a=(n==null?void 0:n.ttl)||pc,c=un(n),l=(n==null?void 0:n.prompt)||!1,h=(n==null?void 0:n.tag)||0,u=(n==null?void 0:n.id)||Cr().toString(),d={topic:r,message:i,opts:{ttl:a,relay:c,prompt:l,tag:h,id:u,attestation:n==null?void 0:n.attestation,tvf:n==null?void 0:n.tvf}},g=`Failed to publish payload, please try again. id:${u} tag:${h}`;try{const w=new Promise(async f=>{const m=({id:b})=>{d.opts.id===b&&(this.removeRequestFromQueue(b),this.relayer.events.removeListener(je.publish,m),f(d))};this.relayer.events.on(je.publish,m);const y=bs(new Promise((b,E)=>{this.rpcPublish({topic:r,message:i,ttl:a,prompt:l,tag:h,id:u,attestation:n==null?void 0:n.attestation,tvf:n==null?void 0:n.tvf}).then(b).catch(A=>{this.logger.warn(A,A==null?void 0:A.message),E(A)})}),this.initialPublishTimeout,`Failed initial publish, retrying.... id:${u} tag:${h}`);try{await y,this.events.removeListener(je.publish,m)}catch(b){this.queue.set(u,Hn(Vi({},d),{attempt:1})),this.logger.warn(b,b==null?void 0:b.message)}});this.logger.trace({type:"method",method:"publish",params:{id:u,topic:r,message:i,opts:n}}),await bs(w,this.publishTimeout,g)}catch(w){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(w),(o=n==null?void 0:n.internal)!=null&&o.throwOnFailedPublish)throw w}finally{this.queue.delete(u)}}),$t(this,"on",(r,i)=>{this.events.on(r,i)}),$t(this,"once",(r,i)=>{this.events.once(r,i)}),$t(this,"off",(r,i)=>{this.events.off(r,i)}),$t(this,"removeListener",(r,i)=>{this.events.removeListener(r,i)}),this.relayer=e,this.logger=st(s,this.name),this.registerEventListeners()}get context(){return bt(this.logger)}async rpcPublish(e){var s,r,i,n;const{topic:o,message:a,ttl:c=pc,prompt:l,tag:h,id:u,attestation:d,tvf:g}=e,w={method:ii(un().protocol).publish,params:Vi({topic:o,message:a,ttl:c,prompt:l,tag:h,attestation:d},g),id:u};Ge((s=w.params)==null?void 0:s.prompt)&&((r=w.params)==null||delete r.prompt),Ge((i=w.params)==null?void 0:i.tag)&&((n=w.params)==null||delete n.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:w});const f=await this.relayer.request(w);return this.relayer.events.emit(je.publish,e),this.logger.debug("Successfully Published Payload"),f}removeRequestFromQueue(e){this.queue.delete(e)}checkQueue(){this.queue.forEach(async(e,s)=>{const r=e.attempt+1;this.queue.set(s,Hn(Vi({},e),{attempt:r}));const{topic:i,message:n,opts:o,attestation:a}=e;this.logger.warn({},`Publisher: queue->publishing: ${e.opts.id}, tag: ${e.opts.tag}, attempt: ${r}`),await this.rpcPublish(Hn(Vi({},e),{topic:i,message:n,ttl:o.ttl,prompt:o.prompt,tag:o.tag,id:o.id,attestation:a,tvf:o.tvf})),this.logger.warn({},`Publisher: queue->published: ${e.opts.id}`)})}registerEventListeners(){this.relayer.core.heartbeat.on(jr.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(je.connection_stalled);return}this.checkQueue()}),this.relayer.on(je.message_ack,e=>{this.removeRequestFromQueue(e.id.toString())})}}var By=Object.defineProperty,qy=(t,e,s)=>e in t?By(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,nr=(t,e,s)=>qy(t,typeof e!="symbol"?e+"":e,s);class jy{constructor(){nr(this,"map",new Map),nr(this,"set",(e,s)=>{const r=this.get(e);this.exists(e,s)||this.map.set(e,[...r,s])}),nr(this,"get",e=>this.map.get(e)||[]),nr(this,"exists",(e,s)=>this.get(e).includes(s)),nr(this,"delete",(e,s)=>{if(typeof s>"u"){this.map.delete(e);return}if(!this.map.has(e))return;const r=this.get(e);if(!this.exists(e,s))return;const i=r.filter(n=>n!==s);if(!i.length){this.map.delete(e);return}this.map.set(e,i)}),nr(this,"clear",()=>{this.map.clear()})}get topics(){return Array.from(this.map.keys())}}var Fy=Object.defineProperty,Wy=Object.defineProperties,zy=Object.getOwnPropertyDescriptors,Ic=Object.getOwnPropertySymbols,Hy=Object.prototype.hasOwnProperty,Vy=Object.prototype.propertyIsEnumerable,Oo=(t,e,s)=>e in t?Fy(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Xr=(t,e)=>{for(var s in e||(e={}))Hy.call(e,s)&&Oo(t,s,e[s]);if(Ic)for(var s of Ic(e))Vy.call(e,s)&&Oo(t,s,e[s]);return t},Vn=(t,e)=>Wy(t,zy(e)),be=(t,e,s)=>Oo(t,typeof e!="symbol"?e+"":e,s);class Ky extends yd{constructor(e,s){super(e,s),this.relayer=e,this.logger=s,be(this,"subscriptions",new Map),be(this,"topicMap",new jy),be(this,"events",new Ys.EventEmitter),be(this,"name",$m),be(this,"version",xm),be(this,"pending",new Map),be(this,"cached",[]),be(this,"initialized",!1),be(this,"storagePrefix",Gt),be(this,"subscribeTimeout",U.toMiliseconds(U.ONE_MINUTE)),be(this,"initialSubscribeTimeout",U.toMiliseconds(U.ONE_SECOND*15)),be(this,"clientId"),be(this,"batchSubscribeTopicsLimit",500),be(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),await this.restore()),this.initialized=!0}),be(this,"subscribe",async(r,i)=>{this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:r,opts:i}});try{const n=un(i),o={topic:r,relay:n,transportType:i==null?void 0:i.transportType};this.pending.set(r,o);const a=await this.rpcSubscribe(r,n,i);return typeof a=="string"&&(this.onSubscribe(a,o),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:r,opts:i}})),a}catch(n){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(n),n}}),be(this,"unsubscribe",async(r,i)=>{this.isInitialized(),typeof(i==null?void 0:i.id)<"u"?await this.unsubscribeById(r,i.id,i):await this.unsubscribeByTopic(r,i)}),be(this,"isSubscribed",r=>new Promise(i=>{i(this.topicMap.topics.includes(r))})),be(this,"isKnownTopic",r=>new Promise(i=>{i(this.topicMap.topics.includes(r)||this.pending.has(r)||this.cached.some(n=>n.topic===r))})),be(this,"on",(r,i)=>{this.events.on(r,i)}),be(this,"once",(r,i)=>{this.events.once(r,i)}),be(this,"off",(r,i)=>{this.events.off(r,i)}),be(this,"removeListener",(r,i)=>{this.events.removeListener(r,i)}),be(this,"start",async()=>{await this.onConnect()}),be(this,"stop",async()=>{await this.onDisconnect()}),be(this,"restart",async()=>{await this.restore(),await this.onRestart()}),be(this,"checkPending",async()=>{if(this.pending.size===0&&(!this.initialized||!this.relayer.connected))return;const r=[];this.pending.forEach(i=>{r.push(i)}),await this.batchSubscribe(r)}),be(this,"registerEventListeners",()=>{this.relayer.core.heartbeat.on(jr.pulse,async()=>{await this.checkPending()}),this.events.on(pt.created,async r=>{const i=pt.created;this.logger.info(`Emitting ${i}`),this.logger.debug({type:"event",event:i,data:r}),await this.persist()}),this.events.on(pt.deleted,async r=>{const i=pt.deleted;this.logger.info(`Emitting ${i}`),this.logger.debug({type:"event",event:i,data:r}),await this.persist()})}),this.relayer=e,this.logger=st(s,this.name),this.clientId=""}get context(){return bt(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}get hasAnyTopics(){return this.topicMap.topics.length>0||this.pending.size>0||this.cached.length>0||this.subscriptions.size>0}hasSubscription(e,s){let r=!1;try{r=this.getSubscription(e).topic===s}catch{}return r}reset(){this.cached=[],this.initialized=!0}onDisable(){this.values.length>0&&(this.cached=this.values),this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(e,s){const r=this.topicMap.get(e);await Promise.all(r.map(async i=>await this.unsubscribeById(e,i,s)))}async unsubscribeById(e,s,r){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:s,opts:r}});try{const i=un(r);await this.restartToComplete({topic:e,id:s,relay:i}),await this.rpcUnsubscribe(e,s,i);const n=we("USER_DISCONNECTED",`${this.name}, ${e}`);await this.onUnsubscribe(e,s,n),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:s,opts:r}})}catch(i){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(i),i}}async rpcSubscribe(e,s,r){var i;(!r||(r==null?void 0:r.transportType)===Ne.relay)&&await this.restartToComplete({topic:e,id:e,relay:s});const n={method:ii(s.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n});const o=(i=r==null?void 0:r.internal)==null?void 0:i.throwOnFailedPublish;try{const a=await this.getSubscriptionId(e);if((r==null?void 0:r.transportType)===Ne.link_mode)return setTimeout(()=>{(this.relayer.connected||this.relayer.connecting)&&this.relayer.request(n).catch(h=>this.logger.warn(h))},U.toMiliseconds(U.ONE_SECOND)),a;const c=new Promise(async h=>{const u=d=>{d.topic===e&&(this.events.removeListener(pt.created,u),h(d.id))};this.events.on(pt.created,u);try{const d=await bs(new Promise((g,w)=>{this.relayer.request(n).catch(f=>{this.logger.warn(f,f==null?void 0:f.message),w(f)}).then(g)}),this.initialSubscribeTimeout,`Subscribing to ${e} failed, please try again`);this.events.removeListener(pt.created,u),h(d)}catch{}}),l=await bs(c,this.subscribeTimeout,`Subscribing to ${e} failed, please try again`);if(!l&&o)throw new Error(`Subscribing to ${e} failed, please try again`);return l?a:null}catch(a){if(this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(je.connection_stalled),o)throw a}return null}async rpcBatchSubscribe(e){if(!e.length)return;const s=e[0].relay,r={method:ii(s.protocol).batchSubscribe,params:{topics:e.map(i=>i.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:r});try{await await bs(new Promise(i=>{this.relayer.request(r).catch(n=>this.logger.warn(n)).then(i)}),this.subscribeTimeout,"rpcBatchSubscribe failed, please try again")}catch{this.relayer.events.emit(je.connection_stalled)}}async rpcBatchFetchMessages(e){if(!e.length)return;const s=e[0].relay,r={method:ii(s.protocol).batchFetchMessages,params:{topics:e.map(n=>n.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:r});let i;try{i=await await bs(new Promise((n,o)=>{this.relayer.request(r).catch(a=>{this.logger.warn(a),o(a)}).then(n)}),this.subscribeTimeout,"rpcBatchFetchMessages failed, please try again")}catch{this.relayer.events.emit(je.connection_stalled)}return i}rpcUnsubscribe(e,s,r){const i={method:ii(r.protocol).unsubscribe,params:{topic:e,id:s}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i}),this.relayer.request(i)}onSubscribe(e,s){this.setSubscription(e,Vn(Xr({},s),{id:e})),this.pending.delete(s.topic)}onBatchSubscribe(e){e.length&&e.forEach(s=>{this.setSubscription(s.id,Xr({},s)),this.pending.delete(s.topic)})}async onUnsubscribe(e,s,r){this.events.removeAllListeners(s),this.hasSubscription(s,e)&&this.deleteSubscription(s,r),await this.relayer.messages.del(e)}async setRelayerSubscriptions(e){await this.relayer.core.storage.setItem(this.storageKey,e)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(e,s){this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:e,subscription:s}),this.addSubscription(e,s)}addSubscription(e,s){this.subscriptions.set(e,Xr({},s)),this.topicMap.set(s.topic,e),this.events.emit(pt.created,s)}getSubscription(e){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});const s=this.subscriptions.get(e);if(!s){const{message:r}=R("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(r)}return s}deleteSubscription(e,s){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:s});const r=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(r.topic,e),this.events.emit(pt.deleted,Vn(Xr({},r),{reason:s}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(pt.sync)}async onRestart(){if(this.cached.length){const e=[...this.cached],s=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let r=0;r<s;r++){const i=e.splice(0,this.batchSubscribeTopicsLimit);await this.batchSubscribe(i)}}this.events.emit(pt.resubscribed)}async restore(){try{const e=await this.getRelayerSubscriptions();if(typeof e>"u"||!e.length)return;if(this.subscriptions.size){const{message:s}=R("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(s),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(s)}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(await Promise.all(e.map(async s=>Vn(Xr({},s),{id:await this.getSubscriptionId(s.topic)})))))}async batchFetchMessages(e){if(!e.length)return;this.logger.trace(`Fetching batch messages for ${e.length} subscriptions`);const s=await this.rpcBatchFetchMessages(e);s&&s.messages&&(await Qd(U.toMiliseconds(U.ONE_SECOND)),await this.relayer.handleBatchMessageEvents(s.messages))}async onConnect(){await this.restart(),this.reset()}onDisconnect(){this.onDisable()}isInitialized(){if(!this.initialized){const{message:e}=R("NOT_INITIALIZED",this.name);throw new Error(e)}}async restartToComplete(e){!this.relayer.connected&&!this.relayer.connecting&&(this.cached.push(e),await this.relayer.transportOpen())}async getClientId(){return this.clientId||(this.clientId=await this.relayer.core.crypto.getClientId()),this.clientId}async getSubscriptionId(e){return Ht(e+await this.getClientId())}}var Gy=Object.defineProperty,Ac=Object.getOwnPropertySymbols,Jy=Object.prototype.hasOwnProperty,Yy=Object.prototype.propertyIsEnumerable,To=(t,e,s)=>e in t?Gy(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Nc=(t,e)=>{for(var s in e||(e={}))Jy.call(e,s)&&To(t,s,e[s]);if(Ac)for(var s of Ac(e))Yy.call(e,s)&&To(t,s,e[s]);return t},le=(t,e,s)=>To(t,typeof e!="symbol"?e+"":e,s);class Zy extends md{constructor(e){super(e),le(this,"protocol","wc"),le(this,"version",2),le(this,"core"),le(this,"logger"),le(this,"events",new Ys.EventEmitter),le(this,"provider"),le(this,"messages"),le(this,"subscriber"),le(this,"publisher"),le(this,"name",Sm),le(this,"transportExplicitlyClosed",!1),le(this,"initialized",!1),le(this,"connectionAttemptInProgress",!1),le(this,"relayUrl"),le(this,"projectId"),le(this,"packageName"),le(this,"bundleId"),le(this,"hasExperiencedNetworkDisruption",!1),le(this,"pingTimeout"),le(this,"heartBeatTimeout",U.toMiliseconds(U.THIRTY_SECONDS+U.FIVE_SECONDS)),le(this,"reconnectTimeout"),le(this,"connectPromise"),le(this,"reconnectInProgress",!1),le(this,"requestsInFlight",[]),le(this,"connectTimeout",U.toMiliseconds(U.ONE_SECOND*15)),le(this,"request",async s=>{var r,i;this.logger.debug("Publishing Request Payload");const n=s.id||Cr().toString();await this.toEstablishConnection();try{this.logger.trace({id:n,method:s.method,topic:(r=s.params)==null?void 0:r.topic},"relayer.request - publishing...");const o=`${n}:${((i=s.params)==null?void 0:i.tag)||""}`;this.requestsInFlight.push(o);const a=await this.provider.request(s);return this.requestsInFlight=this.requestsInFlight.filter(c=>c!==o),a}catch(o){throw this.logger.debug(`Failed to Publish Request: ${n}`),o}}),le(this,"resetPingTimeout",()=>{ln()&&(clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(()=>{var s,r,i,n;try{this.logger.debug({},"pingTimeout: Connection stalled, terminating..."),(n=(i=(r=(s=this.provider)==null?void 0:s.connection)==null?void 0:r.socket)==null?void 0:i.terminate)==null||n.call(i)}catch(o){this.logger.warn(o,o==null?void 0:o.message)}},this.heartBeatTimeout))}),le(this,"onPayloadHandler",s=>{this.onProviderPayload(s),this.resetPingTimeout()}),le(this,"onConnectHandler",()=>{this.logger.warn({},"Relayer connected 🛜"),this.startPingTimeout(),this.events.emit(je.connect)}),le(this,"onDisconnectHandler",()=>{this.logger.warn({},"Relayer disconnected 🛑"),this.requestsInFlight=[],this.onProviderDisconnect()}),le(this,"onProviderErrorHandler",s=>{this.logger.fatal(`Fatal socket error: ${s.message}`),this.events.emit(je.error,s),this.logger.fatal("Fatal socket error received, closing transport"),this.transportClose()}),le(this,"registerProviderListeners",()=>{this.provider.on(It.payload,this.onPayloadHandler),this.provider.on(It.connect,this.onConnectHandler),this.provider.on(It.disconnect,this.onDisconnectHandler),this.provider.on(It.error,this.onProviderErrorHandler)}),this.core=e.core,this.logger=typeof e.logger<"u"&&typeof e.logger!="string"?st(e.logger,this.name):jo(Si({level:e.logger||_m})),this.messages=new $y(this.logger,e.core),this.subscriber=new Ky(this,this.logger),this.publisher=new My(this,this.logger),this.relayUrl=(e==null?void 0:e.relayUrl)||gh,this.projectId=e.projectId,Ld()?this.packageName=Ia():Md()&&(this.bundleId=Ia()),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.hasAnyTopics)try{await this.transportOpen()}catch(e){this.logger.warn(e,e==null?void 0:e.message)}}get context(){return bt(this.logger)}get connected(){var e,s,r;return((r=(s=(e=this.provider)==null?void 0:e.connection)==null?void 0:s.socket)==null?void 0:r.readyState)===1||!1}get connecting(){var e,s,r;return((r=(s=(e=this.provider)==null?void 0:e.connection)==null?void 0:s.socket)==null?void 0:r.readyState)===0||this.connectPromise!==void 0||!1}async publish(e,s,r){this.isInitialized(),await this.publisher.publish(e,s,r),await this.recordMessageEvent({topic:e,message:s,publishedAt:Date.now(),transportType:Ne.relay},tn.outbound)}async subscribe(e,s){var r,i,n;this.isInitialized(),(!(s!=null&&s.transportType)||(s==null?void 0:s.transportType)==="relay")&&await this.toEstablishConnection();const o=typeof((r=s==null?void 0:s.internal)==null?void 0:r.throwOnFailedPublish)>"u"?!0:(i=s==null?void 0:s.internal)==null?void 0:i.throwOnFailedPublish;let a=((n=this.subscriber.topicMap.get(e))==null?void 0:n[0])||"",c;const l=h=>{h.topic===e&&(this.subscriber.off(pt.created,l),c())};return await Promise.all([new Promise(h=>{c=h,this.subscriber.on(pt.created,l)}),new Promise(async(h,u)=>{a=await this.subscriber.subscribe(e,Nc({internal:{throwOnFailedPublish:o}},s)).catch(d=>{o&&u(d)})||a,h()})]),a}async unsubscribe(e,s){this.isInitialized(),await this.subscriber.unsubscribe(e,s)}on(e,s){this.events.on(e,s)}once(e,s){this.events.once(e,s)}off(e,s){this.events.off(e,s)}removeListener(e,s){this.events.removeListener(e,s)}async transportDisconnect(){this.provider.disconnect&&(this.hasExperiencedNetworkDisruption||this.connected)?await bs(this.provider.disconnect(),2e3,"provider.disconnect()").catch(()=>this.onProviderDisconnect()):this.onProviderDisconnect()}async transportClose(){this.transportExplicitlyClosed=!0,await this.transportDisconnect()}async transportOpen(e){if(!this.subscriber.hasAnyTopics){this.logger.warn("Starting WS connection skipped because the client has no topics to work with.");return}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(s,r)=>{await this.connect(e).then(s).catch(r).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 uc())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 s=e.sort((r,i)=>r.publishedAt-i.publishedAt);this.logger.debug(`Batch of ${s.length} message events sorted`);for(const r of s)try{await this.onMessageEvent(r)}catch(i){this.logger.warn(i,"Error while processing batch message event: "+(i==null?void 0:i.message))}this.logger.trace(`Batch of ${s.length} message events processed`)}async onLinkMessageEvent(e,s){const{topic:r}=e;if(!s.sessionExists){const i=De(U.FIVE_MINUTES),n={topic:r,expiry:i,relay:{protocol:"irn"},active:!1};await this.core.pairing.pairings.set(r,n)}this.events.emit(je.message,e),await this.recordMessageEvent(e,tn.inbound)}async connect(e){await this.confirmOnlineStateOrThrow(),e&&e!==this.relayUrl&&(this.relayUrl=e,await this.transportDisconnect()),this.connectionAttemptInProgress=!0,this.transportExplicitlyClosed=!1;let s=1;for(;s<6;){try{if(this.transportExplicitlyClosed)break;this.logger.debug({},`Connecting to ${this.relayUrl}, attempt: ${s}...`),await this.createProvider(),await new Promise(async(r,i)=>{const n=()=>{i(new Error("Connection interrupted while trying to subscribe"))};this.provider.once(It.disconnect,n),await bs(new Promise((o,a)=>{this.provider.connect().then(o).catch(a)}),this.connectTimeout,`Socket stalled when trying to connect to ${this.relayUrl}`).catch(o=>{i(o)}).finally(()=>{this.provider.off(It.disconnect,n),clearTimeout(this.reconnectTimeout)}),await new Promise(async(o,a)=>{const c=()=>{a(new Error("Connection interrupted while trying to subscribe"))};this.provider.once(It.disconnect,c),await this.subscriber.start().then(o).catch(a).finally(()=>{this.provider.off(It.disconnect,c)})}),this.hasExperiencedNetworkDisruption=!1,r()})}catch(r){await this.subscriber.stop();const i=r;this.logger.warn({},i.message),this.hasExperiencedNetworkDisruption=!0}finally{this.connectionAttemptInProgress=!1}if(this.connected){this.logger.debug({},`Connected to ${this.relayUrl} successfully on attempt: ${s}`);break}await new Promise(r=>setTimeout(r,U.toMiliseconds(s*1))),s++}}startPingTimeout(){var e,s,r,i,n;if(ln())try{(s=(e=this.provider)==null?void 0:e.connection)!=null&&s.socket&&((n=(i=(r=this.provider)==null?void 0:r.connection)==null?void 0:i.socket)==null||n.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 Pt(new ou(Wd({sdkVersion:Ao,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,s){const{topic:r,message:i}=e;await this.messages.set(r,i,s)}async shouldIgnoreMessageEvent(e){const{topic:s,message:r}=e;if(!r||r.length===0)return this.logger.warn(`Ignoring invalid/empty message: ${r}`),!0;if(!await this.subscriber.isKnownTopic(s))return this.logger.warn(`Ignoring message for unknown topic ${s}`),!0;const i=this.messages.has(s,r);return i&&this.logger.warn(`Ignoring duplicate message: ${r}`),i}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),Fo(e)){if(!e.method.endsWith(Pm))return;const s=e.params,{topic:r,message:i,publishedAt:n,attestation:o}=s.data,a={topic:r,message:i,publishedAt:n,transportType:Ne.relay,attestation:o};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(Nc({type:"event",event:s.id},a)),this.events.emit(s.id,a),await this.acknowledgePayload(e),await this.onMessageEvent(a)}else Wo(e)&&this.events.emit(je.message_ack,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(await this.recordMessageEvent(e,tn.inbound),this.events.emit(je.message,e))}async acknowledgePayload(e){const s=mn(e.id,!0);await this.provider.connection.send(s)}unregisterProviderListeners(){this.provider.off(It.payload,this.onPayloadHandler),this.provider.off(It.connect,this.onConnectHandler),this.provider.off(It.disconnect,this.onDisconnectHandler),this.provider.off(It.error,this.onProviderErrorHandler),clearTimeout(this.pingTimeout)}async registerEventListeners(){let e=await uc();dm(async s=>{e!==s&&(e=s,s?await this.transportOpen().catch(r=>this.logger.error(r,r==null?void 0:r.message)):(this.hasExperiencedNetworkDisruption=!0,await this.transportDisconnect(),this.transportExplicitlyClosed=!1))}),this.core.heartbeat.on(jr.pulse,async()=>{if(!this.transportExplicitlyClosed&&!this.connected&&gm())try{await this.confirmOnlineStateOrThrow(),await this.transportOpen()}catch(s){this.logger.warn(s,s==null?void 0:s.message)}})}async onProviderDisconnect(){clearTimeout(this.pingTimeout),this.events.emit(je.disconnect),this.connectionAttemptInProgress=!1,!this.reconnectInProgress&&(this.reconnectInProgress=!0,await this.subscriber.stop(),this.subscriber.hasAnyTopics&&(this.transportExplicitlyClosed||(this.reconnectTimeout=setTimeout(async()=>{await this.transportOpen().catch(e=>this.logger.error(e,e==null?void 0:e.message)),this.reconnectTimeout=void 0,this.reconnectInProgress=!1},U.toMiliseconds(Om)))))}isInitialized(){if(!this.initialized){const{message:e}=R("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){if(await this.confirmOnlineStateOrThrow(),!this.connected){if(this.connectPromise){await this.connectPromise;return}await this.connect()}}}function Xy(){}function _c(t){if(!t||typeof t!="object")return!1;const e=Object.getPrototypeOf(t);return e===null||e===Object.prototype||Object.getPrototypeOf(e)===null?Object.prototype.toString.call(t)==="[object Object]":!1}function Sc(t){return Object.getOwnPropertySymbols(t).filter(e=>Object.prototype.propertyIsEnumerable.call(t,e))}function Pc(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const Qy="[object RegExp]",eb="[object String]",tb="[object Number]",sb="[object Boolean]",Oc="[object Arguments]",rb="[object Symbol]",ib="[object Date]",nb="[object Map]",ob="[object Set]",ab="[object Array]",cb="[object Function]",lb="[object ArrayBuffer]",Kn="[object Object]",hb="[object Error]",ub="[object DataView]",db="[object Uint8Array]",pb="[object Uint8ClampedArray]",fb="[object Uint16Array]",gb="[object Uint32Array]",mb="[object BigUint64Array]",wb="[object Int8Array]",yb="[object Int16Array]",bb="[object Int32Array]",vb="[object BigInt64Array]",Eb="[object Float32Array]",Cb="[object Float64Array]";function Ib(t,e){return t===e||Number.isNaN(t)&&Number.isNaN(e)}function Ab(t,e,s){return ni(t,e,void 0,void 0,void 0,void 0,s)}function ni(t,e,s,r,i,n,o){const a=o(t,e,s,r,i,n);if(a!==void 0)return a;if(typeof t==typeof e)switch(typeof t){case"bigint":case"string":case"boolean":case"symbol":case"undefined":return t===e;case"number":return t===e||Object.is(t,e);case"function":return t===e;case"object":return pi(t,e,n,o)}return pi(t,e,n,o)}function pi(t,e,s,r){if(Object.is(t,e))return!0;let i=Pc(t),n=Pc(e);if(i===Oc&&(i=Kn),n===Oc&&(n=Kn),i!==n)return!1;switch(i){case eb:return t.toString()===e.toString();case tb:{const c=t.valueOf(),l=e.valueOf();return Ib(c,l)}case sb:case ib:case rb:return Object.is(t.valueOf(),e.valueOf());case Qy:return t.source===e.source&&t.flags===e.flags;case cb:return t===e}s=s??new Map;const o=s.get(t),a=s.get(e);if(o!=null&&a!=null)return o===e;s.set(t,e),s.set(e,t);try{switch(i){case nb:{if(t.size!==e.size)return!1;for(const[c,l]of t.entries())if(!e.has(c)||!ni(l,e.get(c),c,t,e,s,r))return!1;return!0}case ob:{if(t.size!==e.size)return!1;const c=Array.from(t.values()),l=Array.from(e.values());for(let h=0;h<c.length;h++){const u=c[h],d=l.findIndex(g=>ni(u,g,void 0,t,e,s,r));if(d===-1)return!1;l.splice(d,1)}return!0}case ab:case db:case pb:case fb:case gb:case mb:case wb:case yb:case bb:case vb:case Eb:case Cb:{if(typeof Buffer<"u"&&Buffer.isBuffer(t)!==Buffer.isBuffer(e)||t.length!==e.length)return!1;for(let c=0;c<t.length;c++)if(!ni(t[c],e[c],c,t,e,s,r))return!1;return!0}case lb:return t.byteLength!==e.byteLength?!1:pi(new Uint8Array(t),new Uint8Array(e),s,r);case ub:return t.byteLength!==e.byteLength||t.byteOffset!==e.byteOffset?!1:pi(new Uint8Array(t),new Uint8Array(e),s,r);case hb:return t.name===e.name&&t.message===e.message;case Kn:{if(!(pi(t.constructor,e.constructor,s,r)||_c(t)&&_c(e)))return!1;const c=[...Object.keys(t),...Sc(t)],l=[...Object.keys(e),...Sc(e)];if(c.length!==l.length)return!1;for(let h=0;h<c.length;h++){const u=c[h],d=t[u];if(!Object.hasOwn(e,u))return!1;const g=e[u];if(!ni(d,g,u,t,e,s,r))return!1}return!0}default:return!1}}finally{s.delete(t),s.delete(e)}}function Nb(t,e){return Ab(t,e,Xy)}var _b=Object.defineProperty,Tc=Object.getOwnPropertySymbols,Sb=Object.prototype.hasOwnProperty,Pb=Object.prototype.propertyIsEnumerable,ko=(t,e,s)=>e in t?_b(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,kc=(t,e)=>{for(var s in e||(e={}))Sb.call(e,s)&&ko(t,s,e[s]);if(Tc)for(var s of Tc(e))Pb.call(e,s)&&ko(t,s,e[s]);return t},ot=(t,e,s)=>ko(t,typeof e!="symbol"?e+"":e,s);class er extends wd{constructor(e,s,r,i=Gt,n=void 0){super(e,s,r,i),this.core=e,this.logger=s,this.name=r,ot(this,"map",new Map),ot(this,"version",Tm),ot(this,"cached",[]),ot(this,"initialized",!1),ot(this,"getKey"),ot(this,"storagePrefix",Gt),ot(this,"recentlyDeleted",[]),ot(this,"recentlyDeletedLimit",200),ot(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(o=>{this.getKey&&o!==null&&!Ge(o)?this.map.set(this.getKey(o),o):Wg(o)?this.map.set(o.id,o):zg(o)&&this.map.set(o.topic,o)}),this.cached=[],this.initialized=!0)}),ot(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())}),ot(this,"get",o=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:o}),this.getData(o))),ot(this,"getAll",o=>(this.isInitialized(),o?this.values.filter(a=>Object.keys(o).every(c=>Nb(a[c],o[c]))):this.values)),ot(this,"update",async(o,a)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:o,update:a});const c=kc(kc({},this.getData(o)),a);this.map.set(o,c),await this.persist()}),ot(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=st(s,this.name),this.storagePrefix=i,this.getKey=n}get context(){return bt(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 s=this.map.get(e);if(!s){if(this.recentlyDeleted.includes(e)){const{message:i}=R("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${e}`);throw this.logger.error(i),new Error(i)}const{message:r}=R("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(r),new Error(r)}return s}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:s}=R("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(s),new Error(s)}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}=R("NOT_INITIALIZED",this.name);throw new Error(e)}}}var Ob=Object.defineProperty,Tb=(t,e,s)=>e in t?Ob(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,ie=(t,e,s)=>Tb(t,typeof e!="symbol"?e+"":e,s);class kb{constructor(e,s){this.core=e,this.logger=s,ie(this,"name",Rm),ie(this,"version",Um),ie(this,"events",new qo),ie(this,"pairings"),ie(this,"initialized",!1),ie(this,"storagePrefix",Gt),ie(this,"ignoredPayloadTypes",[os]),ie(this,"registeredMethods",[]),ie(this,"init",async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))}),ie(this,"register",({methods:r})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...r])]}),ie(this,"create",async r=>{this.isInitialized();const i=Co(),n=await this.core.crypto.setSymKey(i),o=De(U.FIVE_MINUTES),a={protocol:fh},c={topic:n,expiry:o,relay:a,active:!1,methods:r==null?void 0:r.methods},l=sc({protocol:this.core.protocol,version:this.core.version,topic:n,symKey:i,relay:a,expiryTimestamp:o,methods:r==null?void 0:r.methods});return this.events.emit(Ls.create,c),this.core.expirer.set(n,o),await this.pairings.set(n,c),await this.core.relayer.subscribe(n,{transportType:r==null?void 0:r.transportType}),{topic:n,uri:l}}),ie(this,"pair",async r=>{this.isInitialized();const i=this.core.eventClient.createEvent({properties:{topic:r==null?void 0:r.uri,trace:[Ft.pairing_started]}});this.isValidPair(r,i);const{topic:n,symKey:o,relay:a,expiryTimestamp:c,methods:l}=tc(r.uri);i.props.properties.topic=n,i.addTrace(Ft.pairing_uri_validation_success),i.addTrace(Ft.pairing_uri_not_expired);let h;if(this.pairings.keys.includes(n)){if(h=this.pairings.get(n),i.addTrace(Ft.existing_pairing),h.active)throw i.setError(ss.active_pairing_already_exists),new Error(`Pairing already exists: ${n}. Please try again with a new connection URI.`);i.addTrace(Ft.pairing_not_expired)}const u=c||De(U.FIVE_MINUTES),d={topic:n,relay:a,expiry:u,active:!1,methods:l};this.core.expirer.set(n,u),await this.pairings.set(n,d),i.addTrace(Ft.store_new_pairing),r.activatePairing&&await this.activate({topic:n}),this.events.emit(Ls.create,d),i.addTrace(Ft.emit_inactive_pairing),this.core.crypto.keychain.has(n)||await this.core.crypto.setSymKey(o,n),i.addTrace(Ft.subscribing_pairing_topic);try{await this.core.relayer.confirmOnlineStateOrThrow()}catch{i.setError(ss.no_internet_connection)}try{await this.core.relayer.subscribe(n,{relay:a})}catch(g){throw i.setError(ss.subscribe_pairing_topic_failure),g}return i.addTrace(Ft.subscribe_pairing_topic_success),d}),ie(this,"activate",async({topic:r})=>{this.isInitialized();const i=De(U.FIVE_MINUTES);this.core.expirer.set(r,i),await this.pairings.update(r,{active:!0,expiry:i})}),ie(this,"ping",async r=>{this.isInitialized(),await this.isValidPing(r),this.logger.warn("ping() is deprecated and will be removed in the next major release.");const{topic:i}=r;if(this.pairings.keys.includes(i)){const n=await this.sendRequest(i,"wc_pairingPing",{}),{done:o,resolve:a,reject:c}=Rs();this.events.once(pe("pairing_ping",n),({error:l})=>{l?c(l):a()}),await o()}}),ie(this,"updateExpiry",async({topic:r,expiry:i})=>{this.isInitialized(),await this.pairings.update(r,{expiry:i})}),ie(this,"updateMetadata",async({topic:r,metadata:i})=>{this.isInitialized(),await this.pairings.update(r,{peerMetadata:i})}),ie(this,"getPairings",()=>(this.isInitialized(),this.pairings.values)),ie(this,"disconnect",async r=>{this.isInitialized(),await this.isValidDisconnect(r);const{topic:i}=r;this.pairings.keys.includes(i)&&(await this.sendRequest(i,"wc_pairingDelete",we("USER_DISCONNECTED")),await this.deletePairing(i))}),ie(this,"formatUriFromPairing",r=>{this.isInitialized();const{topic:i,relay:n,expiry:o,methods:a}=r,c=this.core.crypto.keychain.get(i);return sc({protocol:this.core.protocol,version:this.core.version,topic:i,symKey:c,relay:n,expiryTimestamp:o,methods:a})}),ie(this,"sendRequest",async(r,i,n)=>{const o=Bs(i,n),a=await this.core.crypto.encode(r,o),c=Yr[i].req;return this.core.history.set(r,o),this.core.relayer.publish(r,a,c),o.id}),ie(this,"sendResult",async(r,i,n)=>{const o=mn(r,n),a=await this.core.crypto.encode(i,o),c=(await this.core.history.get(i,r)).request.method,l=Yr[c].res;await this.core.relayer.publish(i,a,l),await this.core.history.resolve(o)}),ie(this,"sendError",async(r,i,n)=>{const o=yl(r,n),a=await this.core.crypto.encode(i,o),c=(await this.core.history.get(i,r)).request.method,l=Yr[c]?Yr[c].res:Yr.unregistered_method.res;await this.core.relayer.publish(i,a,l),await this.core.history.resolve(o)}),ie(this,"deletePairing",async(r,i)=>{await this.core.relayer.unsubscribe(r),await Promise.all([this.pairings.delete(r,we("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(r),i?Promise.resolve():this.core.expirer.del(r)])}),ie(this,"cleanup",async()=>{const r=this.pairings.getAll().filter(i=>gs(i.expiry));await Promise.all(r.map(i=>this.deletePairing(i.topic)))}),ie(this,"onRelayEventRequest",async r=>{const{topic:i,payload:n}=r;switch(n.method){case"wc_pairingPing":return await this.onPairingPingRequest(i,n);case"wc_pairingDelete":return await this.onPairingDeleteRequest(i,n);default:return await this.onUnknownRpcMethodRequest(i,n)}}),ie(this,"onRelayEventResponse",async r=>{const{topic:i,payload:n}=r,o=(await this.core.history.get(i,n.id)).request.method;switch(o){case"wc_pairingPing":return this.onPairingPingResponse(i,n);default:return this.onUnknownRpcMethodResponse(o)}}),ie(this,"onPairingPingRequest",async(r,i)=>{const{id:n}=i;try{this.isValidPing({topic:r}),await this.sendResult(n,r,!0),this.events.emit(Ls.ping,{id:n,topic:r})}catch(o){await this.sendError(n,r,o),this.logger.error(o)}}),ie(this,"onPairingPingResponse",(r,i)=>{const{id:n}=i;setTimeout(()=>{ts(i)?this.events.emit(pe("pairing_ping",n),{}):Wt(i)&&this.events.emit(pe("pairing_ping",n),{error:i.error})},500)}),ie(this,"onPairingDeleteRequest",async(r,i)=>{const{id:n}=i;try{this.isValidDisconnect({topic:r}),await this.deletePairing(r),this.events.emit(Ls.delete,{id:n,topic:r})}catch(o){await this.sendError(n,r,o),this.logger.error(o)}}),ie(this,"onUnknownRpcMethodRequest",async(r,i)=>{const{id:n,method:o}=i;try{if(this.registeredMethods.includes(o))return;const a=we("WC_METHOD_UNSUPPORTED",o);await this.sendError(n,r,a),this.logger.error(a)}catch(a){await this.sendError(n,r,a),this.logger.error(a)}}),ie(this,"onUnknownRpcMethodResponse",r=>{this.registeredMethods.includes(r)||this.logger.error(we("WC_METHOD_UNSUPPORTED",r))}),ie(this,"isValidPair",(r,i)=>{var n;if(!ct(r)){const{message:a}=R("MISSING_OR_INVALID",`pair() params: ${r}`);throw i.setError(ss.malformed_pairing_uri),new Error(a)}if(!Fg(r.uri)){const{message:a}=R("MISSING_OR_INVALID",`pair() uri: ${r.uri}`);throw i.setError(ss.malformed_pairing_uri),new Error(a)}const o=tc(r==null?void 0:r.uri);if(!((n=o==null?void 0:o.relay)!=null&&n.protocol)){const{message:a}=R("MISSING_OR_INVALID","pair() uri#relay-protocol");throw i.setError(ss.malformed_pairing_uri),new Error(a)}if(!(o!=null&&o.symKey)){const{message:a}=R("MISSING_OR_INVALID","pair() uri#symKey");throw i.setError(ss.malformed_pairing_uri),new Error(a)}if(o!=null&&o.expiryTimestamp&&U.toMiliseconds(o==null?void 0:o.expiryTimestamp)<Date.now()){i.setError(ss.pairing_expired);const{message:a}=R("EXPIRED","pair() URI has expired. Please try again with a new connection URI.");throw new Error(a)}}),ie(this,"isValidPing",async r=>{if(!ct(r)){const{message:n}=R("MISSING_OR_INVALID",`ping() params: ${r}`);throw new Error(n)}const{topic:i}=r;await this.isValidPairingTopic(i)}),ie(this,"isValidDisconnect",async r=>{if(!ct(r)){const{message:n}=R("MISSING_OR_INVALID",`disconnect() params: ${r}`);throw new Error(n)}const{topic:i}=r;await this.isValidPairingTopic(i)}),ie(this,"isValidPairingTopic",async r=>{if(!$e(r,!1)){const{message:i}=R("MISSING_OR_INVALID",`pairing topic should be a string: ${r}`);throw new Error(i)}if(!this.pairings.keys.includes(r)){const{message:i}=R("NO_MATCHING_KEY",`pairing topic doesn't exist: ${r}`);throw new Error(i)}if(gs(this.pairings.get(r).expiry)){await this.deletePairing(r);const{message:i}=R("EXPIRED",`pairing topic: ${r}`);throw new Error(i)}}),this.core=e,this.logger=st(s,this.name),this.pairings=new er(this.core,this.logger,this.name,this.storagePrefix)}get context(){return bt(this.logger)}isInitialized(){if(!this.initialized){const{message:e}=R("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(je.message,async e=>{const{topic:s,message:r,transportType:i}=e;if(this.pairings.keys.includes(s)&&i!==Ne.link_mode&&!this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(r)))try{const n=await this.core.crypto.decode(s,r);Fo(n)?(this.core.history.set(s,n),await this.onRelayEventRequest({topic:s,payload:n})):Wo(n)&&(await this.core.history.resolve(n),await this.onRelayEventResponse({topic:s,payload:n}),this.core.history.delete(s,n.id)),await this.core.relayer.messages.ack(s,r)}catch(n){this.logger.error(n)}})}registerExpirerEvents(){this.core.expirer.on(_t.expired,async e=>{const{topic:s}=Tl(e.target);s&&this.pairings.keys.includes(s)&&(await this.deletePairing(s,!0),this.events.emit(Ls.expire,{topic:s}))})}}var $b=Object.defineProperty,xb=(t,e,s)=>e in t?$b(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Ke=(t,e,s)=>xb(t,typeof e!="symbol"?e+"":e,s);class Rb extends pd{constructor(e,s){super(e,s),this.core=e,this.logger=s,Ke(this,"records",new Map),Ke(this,"events",new Ys.EventEmitter),Ke(this,"name",Dm),Ke(this,"version",Lm),Ke(this,"cached",[]),Ke(this,"initialized",!1),Ke(this,"storagePrefix",Gt),Ke(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(r=>this.records.set(r.id,r)),this.cached=[],this.registerEventListeners(),this.initialized=!0)}),Ke(this,"set",(r,i,n)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:r,request:i,chainId:n}),this.records.has(i.id))return;const o={id:i.id,topic:r,request:{method:i.method,params:i.params||null},chainId:n,expiry:De(U.THIRTY_DAYS)};this.records.set(o.id,o),this.persist(),this.events.emit(Tt.created,o)}),Ke(this,"resolve",async r=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:r}),!this.records.has(r.id))return;const i=await this.getRecord(r.id);typeof i.response>"u"&&(i.response=Wt(r)?{error:r.error}:{result:r.result},this.records.set(i.id,i),this.persist(),this.events.emit(Tt.updated,i))}),Ke(this,"get",async(r,i)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:r,id:i}),await this.getRecord(i))),Ke(this,"delete",(r,i)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:i}),this.values.forEach(n=>{if(n.topic===r){if(typeof i<"u"&&n.id!==i)return;this.records.delete(n.id),this.events.emit(Tt.deleted,n)}}),this.persist()}),Ke(this,"exists",async(r,i)=>(this.isInitialized(),this.records.has(i)?(await this.getRecord(i)).topic===r:!1)),Ke(this,"on",(r,i)=>{this.events.on(r,i)}),Ke(this,"once",(r,i)=>{this.events.once(r,i)}),Ke(this,"off",(r,i)=>{this.events.off(r,i)}),Ke(this,"removeListener",(r,i)=>{this.events.removeListener(r,i)}),this.logger=st(s,this.name)}get context(){return bt(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(s=>{if(typeof s.response<"u")return;const r={topic:s.topic,request:Bs(s.request.method,s.request.params,s.id),chainId:s.chainId};return e.push(r)}),e}async setJsonRpcRecords(e){await this.core.storage.setItem(this.storageKey,e)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(e){this.isInitialized();const s=this.records.get(e);if(!s){const{message:r}=R("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(r)}return s}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(Tt.sync)}async restore(){try{const e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){const{message:s}=R("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(s),new Error(s)}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(Tt.created,e=>{const s=Tt.created;this.logger.info(`Emitting ${s}`),this.logger.debug({type:"event",event:s,record:e})}),this.events.on(Tt.updated,e=>{const s=Tt.updated;this.logger.info(`Emitting ${s}`),this.logger.debug({type:"event",event:s,record:e})}),this.events.on(Tt.deleted,e=>{const s=Tt.deleted;this.logger.info(`Emitting ${s}`),this.logger.debug({type:"event",event:s,record:e})}),this.core.heartbeat.on(jr.pulse,()=>{this.cleanup()})}cleanup(){try{this.isInitialized();let e=!1;this.records.forEach(s=>{U.toMiliseconds(s.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${s.id}`),this.records.delete(s.id),this.events.emit(Tt.deleted,s,!1),e=!0)}),e&&this.persist()}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){const{message:e}=R("NOT_INITIALIZED",this.name);throw new Error(e)}}}var Ub=Object.defineProperty,Db=(t,e,s)=>e in t?Ub(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Ze=(t,e,s)=>Db(t,typeof e!="symbol"?e+"":e,s);class Lb extends bd{constructor(e,s){super(e,s),this.core=e,this.logger=s,Ze(this,"expirations",new Map),Ze(this,"events",new Ys.EventEmitter),Ze(this,"name",Mm),Ze(this,"version",Bm),Ze(this,"cached",[]),Ze(this,"initialized",!1),Ze(this,"storagePrefix",Gt),Ze(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(r=>this.expirations.set(r.target,r)),this.cached=[],this.registerEventListeners(),this.initialized=!0)}),Ze(this,"has",r=>{try{const i=this.formatTarget(r);return typeof this.getExpiration(i)<"u"}catch{return!1}}),Ze(this,"set",(r,i)=>{this.isInitialized();const n=this.formatTarget(r),o={target:n,expiry:i};this.expirations.set(n,o),this.checkExpiry(n,o),this.events.emit(_t.created,{target:n,expiration:o})}),Ze(this,"get",r=>{this.isInitialized();const i=this.formatTarget(r);return this.getExpiration(i)}),Ze(this,"del",r=>{if(this.isInitialized(),this.has(r)){const i=this.formatTarget(r),n=this.getExpiration(i);this.expirations.delete(i),this.events.emit(_t.deleted,{target:i,expiration:n})}}),Ze(this,"on",(r,i)=>{this.events.on(r,i)}),Ze(this,"once",(r,i)=>{this.events.once(r,i)}),Ze(this,"off",(r,i)=>{this.events.off(r,i)}),Ze(this,"removeListener",(r,i)=>{this.events.removeListener(r,i)}),this.logger=st(s,this.name)}get context(){return bt(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 zd(e);if(typeof e=="number")return Hd(e);const{message:s}=R("UNKNOWN_TYPE",`Target type: ${typeof e}`);throw new Error(s)}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(_t.sync)}async restore(){try{const e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){const{message:s}=R("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(s),new Error(s)}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 s=this.expirations.get(e);if(!s){const{message:r}=R("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.warn(r),new Error(r)}return s}checkExpiry(e,s){const{expiry:r}=s;U.toMiliseconds(r)-Date.now()<=0&&this.expire(e,s)}expire(e,s){this.expirations.delete(e),this.events.emit(_t.expired,{target:e,expiration:s})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,s)=>this.checkExpiry(s,e))}registerEventListeners(){this.core.heartbeat.on(jr.pulse,()=>this.checkExpirations()),this.events.on(_t.created,e=>{const s=_t.created;this.logger.info(`Emitting ${s}`),this.logger.debug({type:"event",event:s,data:e}),this.persist()}),this.events.on(_t.expired,e=>{const s=_t.expired;this.logger.info(`Emitting ${s}`),this.logger.debug({type:"event",event:s,data:e}),this.persist()}),this.events.on(_t.deleted,e=>{const s=_t.deleted;this.logger.info(`Emitting ${s}`),this.logger.debug({type:"event",event:s,data:e}),this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=R("NOT_INITIALIZED",this.name);throw new Error(e)}}}var Mb=Object.defineProperty,Bb=(t,e,s)=>e in t?Mb(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,ke=(t,e,s)=>Bb(t,typeof e!="symbol"?e+"":e,s);class qb extends vd{constructor(e,s,r){super(e,s,r),this.core=e,this.logger=s,this.store=r,ke(this,"name",qm),ke(this,"abortController"),ke(this,"isDevEnv"),ke(this,"verifyUrlV3",Fm),ke(this,"storagePrefix",Gt),ke(this,"version",ph),ke(this,"publicKey"),ke(this,"fetchPromise"),ke(this,"init",async()=>{var i;this.isDevEnv||(this.publicKey=await this.store.getItem(this.storeKey),this.publicKey&&U.toMiliseconds((i=this.publicKey)==null?void 0:i.expiresAt)<Date.now()&&(this.logger.debug("verify v2 public key expired"),await this.removePublicKey()))}),ke(this,"register",async i=>{if(!Fr()||this.isDevEnv)return;const n=window.location.origin,{id:o,decryptedId:a}=i,c=`${this.verifyUrlV3}/attestation?projectId=${this.core.projectId}&origin=${n}&id=${o}&decryptedId=${a}`;try{const l=Or(),h=this.startAbortTimer(U.ONE_SECOND*5),u=await new Promise((d,g)=>{const w=()=>{window.removeEventListener("message",m),l.body.removeChild(f),g("attestation aborted")};this.abortController.signal.addEventListener("abort",w);const f=l.createElement("iframe");f.src=c,f.style.display="none",f.addEventListener("error",w,{signal:this.abortController.signal});const m=y=>{if(y.data&&typeof y.data=="string")try{const b=JSON.parse(y.data);if(b.type==="verify_attestation"){if(no(b.attestation).payload.id!==o)return;clearInterval(h),l.body.removeChild(f),this.abortController.signal.removeEventListener("abort",w),window.removeEventListener("message",m),d(b.attestation===null?"":b.attestation)}}catch(b){this.logger.warn(b)}};l.body.appendChild(f),window.addEventListener("message",m,{signal:this.abortController.signal})});return this.logger.debug("jwt attestation",u),u}catch(l){this.logger.warn(l)}return""}),ke(this,"resolve",async i=>{if(this.isDevEnv)return"";const{attestationId:n,hash:o,encryptedId:a}=i;if(n===""){this.logger.debug("resolve: attestationId is empty, skipping");return}if(n){if(no(n).payload.id!==a)return;const l=await this.isValidJwtAttestation(n);if(l){if(!l.isVerified){this.logger.warn("resolve: jwt attestation: origin url not verified");return}return l}}if(!o)return;const c=this.getVerifyUrl(i==null?void 0:i.verifyUrl);return this.fetchAttestation(o,c)}),ke(this,"fetchAttestation",async(i,n)=>{this.logger.debug(`resolving attestation: ${i} from url: ${n}`);const o=this.startAbortTimer(U.ONE_SECOND*5),a=await fetch(`${n}/attestation/${i}?v2Supported=true`,{signal:this.abortController.signal});return clearTimeout(o),a.status===200?await a.json():void 0}),ke(this,"getVerifyUrl",i=>{let n=i||di;return Wm.includes(n)||(this.logger.info(`verify url: ${n}, not included in trusted list, assigning default: ${di}`),n=di),n}),ke(this,"fetchPublicKey",async()=>{try{this.logger.debug(`fetching public key from: ${this.verifyUrlV3}`);const i=this.startAbortTimer(U.FIVE_SECONDS),n=await fetch(`${this.verifyUrlV3}/public-key`,{signal:this.abortController.signal});return clearTimeout(i),await n.json()}catch(i){this.logger.warn(i)}}),ke(this,"persistPublicKey",async i=>{this.logger.debug("persisting public key to local storage",i),await this.store.setItem(this.storeKey,i),this.publicKey=i}),ke(this,"removePublicKey",async()=>{this.logger.debug("removing verify v2 public key from storage"),await this.store.removeItem(this.storeKey),this.publicKey=void 0}),ke(this,"isValidJwtAttestation",async i=>{const n=await this.getPublicKey();try{if(n)return this.validateAttestation(i,n)}catch(a){this.logger.error(a),this.logger.warn("error validating attestation")}const o=await this.fetchAndPersistPublicKey();try{if(o)return this.validateAttestation(i,o)}catch(a){this.logger.error(a),this.logger.warn("error validating attestation")}}),ke(this,"getPublicKey",async()=>this.publicKey?this.publicKey:await this.fetchAndPersistPublicKey()),ke(this,"fetchAndPersistPublicKey",async()=>{if(this.fetchPromise)return await this.fetchPromise,this.publicKey;this.fetchPromise=new Promise(async n=>{const o=await this.fetchPublicKey();o&&(await this.persistPublicKey(o),n(o))});const i=await this.fetchPromise;return this.fetchPromise=void 0,i}),ke(this,"validateAttestation",(i,n)=>{const o=Eg(i,n.publicKey),a={hasExpired:U.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=st(s,this.name),this.abortController=new AbortController,this.isDevEnv=zo(),this.init()}get storeKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//verify:public:key"}get context(){return bt(this.logger)}startAbortTimer(e){return this.abortController=new AbortController,setTimeout(()=>this.abortController.abort(),U.toMiliseconds(e))}}var jb=Object.defineProperty,Fb=(t,e,s)=>e in t?jb(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,$c=(t,e,s)=>Fb(t,typeof e!="symbol"?e+"":e,s);class Wb extends Ed{constructor(e,s){super(e,s),this.projectId=e,this.logger=s,$c(this,"context",zm),$c(this,"registerDeviceToken",async r=>{const{clientId:i,token:n,notificationType:o,enableEncrypted:a=!1}=r,c=`${Hm}/${this.projectId}/clients`;await fetch(c,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:i,type:o,token:n,always_raw:a})})}),this.logger=st(s,this.context)}}var zb=Object.defineProperty,xc=Object.getOwnPropertySymbols,Hb=Object.prototype.hasOwnProperty,Vb=Object.prototype.propertyIsEnumerable,$o=(t,e,s)=>e in t?zb(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Qr=(t,e)=>{for(var s in e||(e={}))Hb.call(e,s)&&$o(t,s,e[s]);if(xc)for(var s of xc(e))Vb.call(e,s)&&$o(t,s,e[s]);return t},Me=(t,e,s)=>$o(t,typeof e!="symbol"?e+"":e,s);class Kb extends Cd{constructor(e,s,r=!0){super(e,s,r),this.core=e,this.logger=s,Me(this,"context",Km),Me(this,"storagePrefix",Gt),Me(this,"storageVersion",Vm),Me(this,"events",new Map),Me(this,"shouldPersist",!1),Me(this,"init",async()=>{if(!zo())try{const i={eventId:Na(),timestamp:Date.now(),domain:this.getAppDomain(),props:{event:"INIT",type:"",properties:{client_id:await this.core.crypto.getClientId(),user_agent:Pl(this.core.relayer.protocol,this.core.relayer.version,Ao)}}};await this.sendEvent([i])}catch(i){this.logger.warn(i)}}),Me(this,"createEvent",i=>{const{event:n="ERROR",type:o="",properties:{topic:a,trace:c}}=i,l=Na(),h=this.core.projectId||"",u=Date.now(),d=Qr({eventId:l,timestamp:u,props:{event:n,type:o,properties:{topic:a,trace:c}},bundleId:h,domain:this.getAppDomain()},this.setMethods(l));return this.telemetryEnabled&&(this.events.set(l,d),this.shouldPersist=!0),d}),Me(this,"getEvent",i=>{const{eventId:n,topic:o}=i;if(n)return this.events.get(n);const a=Array.from(this.events.values()).find(c=>c.props.properties.topic===o);if(a)return Qr(Qr({},a),this.setMethods(a.eventId))}),Me(this,"deleteEvent",i=>{const{eventId:n}=i;this.events.delete(n),this.shouldPersist=!0}),Me(this,"setEventListeners",()=>{this.core.heartbeat.on(jr.pulse,async()=>{this.shouldPersist&&await this.persist(),this.events.forEach(i=>{U.fromMiliseconds(Date.now())-U.fromMiliseconds(i.timestamp)>Gm&&(this.events.delete(i.eventId),this.shouldPersist=!0)})})}),Me(this,"setMethods",i=>({addTrace:n=>this.addTrace(i,n),setError:n=>this.setError(i,n)})),Me(this,"addTrace",(i,n)=>{const o=this.events.get(i);o&&(o.props.properties.trace.push(n),this.events.set(i,o),this.shouldPersist=!0)}),Me(this,"setError",(i,n)=>{const o=this.events.get(i);o&&(o.props.type=n,o.timestamp=Date.now(),this.events.set(i,o),this.shouldPersist=!0)}),Me(this,"persist",async()=>{await this.core.storage.setItem(this.storageKey,Array.from(this.events.values())),this.shouldPersist=!1}),Me(this,"restore",async()=>{try{const i=await this.core.storage.getItem(this.storageKey)||[];if(!i.length)return;i.forEach(n=>{this.events.set(n.eventId,Qr(Qr({},n),this.setMethods(n.eventId)))})}catch(i){this.logger.warn(i)}}),Me(this,"submit",async()=>{if(!this.telemetryEnabled||this.events.size===0)return;const i=[];for(const[n,o]of this.events)o.props.type&&i.push(o);if(i.length!==0)try{if((await this.sendEvent(i)).ok)for(const n of i)this.events.delete(n.eventId),this.shouldPersist=!0}catch(n){this.logger.warn(n)}}),Me(this,"sendEvent",async i=>{const n=this.getAppDomain()?"":"&sp=desktop";return await fetch(`${Jm}?projectId=${this.core.projectId}&st=events_sdk&sv=js-${Ao}${n}`,{method:"POST",body:JSON.stringify(i)})}),Me(this,"getAppDomain",()=>Sl().url),this.logger=st(s,this.context),this.telemetryEnabled=r,r?this.restore().then(async()=>{await this.submit(),this.setEventListeners()}):this.persist()}get storageKey(){return this.storagePrefix+this.storageVersion+this.core.customStoragePrefix+"//"+this.context}}var Gb=Object.defineProperty,Rc=Object.getOwnPropertySymbols,Jb=Object.prototype.hasOwnProperty,Yb=Object.prototype.propertyIsEnumerable,xo=(t,e,s)=>e in t?Gb(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Uc=(t,e)=>{for(var s in e||(e={}))Jb.call(e,s)&&xo(t,s,e[s]);if(Rc)for(var s of Rc(e))Yb.call(e,s)&&xo(t,s,e[s]);return t},Ae=(t,e,s)=>xo(t,typeof e!="symbol"?e+"":e,s);let Zb=class Sh extends ld{constructor(e){var s;super(e),Ae(this,"protocol",dh),Ae(this,"version",ph),Ae(this,"name",Io),Ae(this,"relayUrl"),Ae(this,"projectId"),Ae(this,"customStoragePrefix"),Ae(this,"events",new Ys.EventEmitter),Ae(this,"logger"),Ae(this,"heartbeat"),Ae(this,"relayer"),Ae(this,"crypto"),Ae(this,"storage"),Ae(this,"history"),Ae(this,"expirer"),Ae(this,"pairing"),Ae(this,"verify"),Ae(this,"echoClient"),Ae(this,"linkModeSupportedApps"),Ae(this,"eventClient"),Ae(this,"initialized",!1),Ae(this,"logChunkController"),Ae(this,"on",(a,c)=>this.events.on(a,c)),Ae(this,"once",(a,c)=>this.events.once(a,c)),Ae(this,"off",(a,c)=>this.events.off(a,c)),Ae(this,"removeListener",(a,c)=>this.events.removeListener(a,c)),Ae(this,"dispatchEnvelope",({topic:a,message:c,sessionExists:l})=>{if(!a||!c)return;const h={topic:a,message:c,publishedAt:Date.now(),transportType:Ne.link_mode};this.relayer.onLinkMessageEvent(h,{sessionExists:l})});const r=this.getGlobalCore(e==null?void 0:e.customStoragePrefix);if(r)try{return this.customStoragePrefix=r.customStoragePrefix,this.logger=r.logger,this.heartbeat=r.heartbeat,this.crypto=r.crypto,this.history=r.history,this.expirer=r.expirer,this.storage=r.storage,this.relayer=r.relayer,this.pairing=r.pairing,this.verify=r.verify,this.echoClient=r.echoClient,this.linkModeSupportedApps=r.linkModeSupportedApps,this.eventClient=r.eventClient,this.initialized=r.initialized,this.logChunkController=r.logChunkController,r}catch(a){console.warn("Failed to copy global core",a)}this.projectId=e==null?void 0:e.projectId,this.relayUrl=(e==null?void 0:e.relayUrl)||gh,this.customStoragePrefix=e!=null&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";const i=Si({level:typeof(e==null?void 0:e.logger)=="string"&&e.logger?e.logger:wm.logger,name:Io}),{logger:n,chunkLoggerController:o}=wl({opts:i,maxSizeInBytes:e==null?void 0:e.maxLogBlobSizeInBytes,loggerOverride:e==null?void 0:e.logger});this.logChunkController=o,(s=this.logChunkController)!=null&&s.downloadLogsBlobInBrowser&&(window.downloadLogsBlobInBrowser=async()=>{var a,c;(a=this.logChunkController)!=null&&a.downloadLogsBlobInBrowser&&((c=this.logChunkController)==null||c.downloadLogsBlobInBrowser({clientId:await this.crypto.getClientId()}))}),this.logger=st(n,this.name),this.heartbeat=new iu,this.crypto=new Ay(this,this.logger,e==null?void 0:e.keychain),this.history=new Rb(this,this.logger),this.expirer=new Lb(this,this.logger),this.storage=e!=null&&e.storage?e.storage:new nu(Uc(Uc({},ym),e==null?void 0:e.storageOptions)),this.relayer=new Zy({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new kb(this,this.logger),this.verify=new qb(this,this.logger,this.storage),this.echoClient=new Wb(this.projectId||"",this.logger),this.linkModeSupportedApps=[],this.eventClient=new Kb(this,this.logger,e==null?void 0:e.telemetryEnabled),this.setGlobalCore(this)}static async init(e){const s=new Sh(e);await s.initialize();const r=await s.crypto.getClientId();return await s.storage.setItem(km,r),s}get context(){return bt(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(fc,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(fc)||[],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}}getGlobalCore(e=""){try{if(this.isGlobalCoreDisabled())return;const s=`_walletConnectCore_${e}`,r=`${s}_count`;return globalThis[r]=(globalThis[r]||0)+1,globalThis[r]>1&&console.warn(`WalletConnect Core is already initialized. This is probably a mistake and can lead to unexpected behavior. Init() was called ${globalThis[r]} times.`),globalThis[s]}catch(s){console.warn("Failed to get global WalletConnect core",s);return}}setGlobalCore(e){var s;try{if(this.isGlobalCoreDisabled())return;const r=`_walletConnectCore_${((s=e.opts)==null?void 0:s.customStoragePrefix)||""}`;globalThis[r]=e}catch(r){console.warn("Failed to set global WalletConnect core",r)}}isGlobalCoreDisabled(){try{return typeof process<"u"&&mm.DISABLE_GLOBAL_CORE==="true"}catch{return!0}}};const Xb=Zb,Ph="wc",Oh=2,Th="client",Xo=`${Ph}@${Oh}:${Th}:`,Gn={name:Th,logger:"error"},Dc="WALLETCONNECT_DEEPLINK_CHOICE",Qb="proposal",Lc="Proposal expired",ev="session",or=U.SEVEN_DAYS,tv="engine",Be={wc_sessionPropose:{req:{ttl:U.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:U.FIVE_MINUTES,prompt:!1,tag:1101},reject:{ttl:U.FIVE_MINUTES,prompt:!1,tag:1120},autoReject:{ttl:U.FIVE_MINUTES,prompt:!1,tag:1121}},wc_sessionSettle:{req:{ttl:U.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:U.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:U.ONE_DAY,prompt:!1,tag:1104},res:{ttl:U.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:U.ONE_DAY,prompt:!1,tag:1106},res:{ttl:U.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:U.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:U.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:U.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:U.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:U.ONE_DAY,prompt:!1,tag:1112},res:{ttl:U.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:U.ONE_DAY,prompt:!1,tag:1114},res:{ttl:U.ONE_DAY,prompt:!1,tag:1115}},wc_sessionAuthenticate:{req:{ttl:U.ONE_HOUR,prompt:!0,tag:1116},res:{ttl:U.ONE_HOUR,prompt:!1,tag:1117},reject:{ttl:U.FIVE_MINUTES,prompt:!1,tag:1118},autoReject:{ttl:U.FIVE_MINUTES,prompt:!1,tag:1119}}},Jn={min:U.FIVE_MINUTES,max:U.SEVEN_DAYS},jt={idle:"IDLE",active:"ACTIVE"},Mc={eth_sendTransaction:{key:""},eth_sendRawTransaction:{key:""},wallet_sendCalls:{key:""},solana_signTransaction:{key:"signature"},solana_signAllTransactions:{key:"transactions"},solana_signAndSendTransaction:{key:"signature"}},sv="request",rv=["wc_sessionPropose","wc_sessionRequest","wc_authRequest","wc_sessionAuthenticate"],iv="wc",nv="auth",ov="authKeys",av="pairingTopics",cv="requests",Nn=`${iv}@${1.5}:${nv}:`,sn=`${Nn}:PUB_KEY`;var lv=Object.defineProperty,hv=Object.defineProperties,uv=Object.getOwnPropertyDescriptors,Bc=Object.getOwnPropertySymbols,dv=Object.prototype.hasOwnProperty,pv=Object.prototype.propertyIsEnumerable,Ro=(t,e,s)=>e in t?lv(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,ve=(t,e)=>{for(var s in e||(e={}))dv.call(e,s)&&Ro(t,s,e[s]);if(Bc)for(var s of Bc(e))pv.call(e,s)&&Ro(t,s,e[s]);return t},et=(t,e)=>hv(t,uv(e)),N=(t,e,s)=>Ro(t,typeof e!="symbol"?e+"":e,s);class fv extends _d{constructor(e){super(e),N(this,"name",tv),N(this,"events",new qo),N(this,"initialized",!1),N(this,"requestQueue",{state:jt.idle,queue:[]}),N(this,"sessionRequestQueue",{state:jt.idle,queue:[]}),N(this,"requestQueueDelay",U.ONE_SECOND),N(this,"expectedPairingMethodMap",new Map),N(this,"recentlyDeletedMap",new Map),N(this,"recentlyDeletedLimit",200),N(this,"relayMessageCache",[]),N(this,"pendingSessions",new Map),N(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(Be)}),this.initialized=!0,setTimeout(async()=>{await this.processPendingMessageEvents(),this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},U.toMiliseconds(this.requestQueueDelay)))}),N(this,"connect",async s=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();const r=et(ve({},s),{requiredNamespaces:s.requiredNamespaces||{},optionalNamespaces:s.optionalNamespaces||{}});await this.isValidConnect(r),r.optionalNamespaces=Lg(r.requiredNamespaces,r.optionalNamespaces),r.requiredNamespaces={};const{pairingTopic:i,requiredNamespaces:n,optionalNamespaces:o,sessionProperties:a,scopedProperties:c,relays:l}=r;let h=i,u,d=!1;try{if(h){const P=this.client.core.pairing.pairings.get(h);this.client.logger.warn("connect() with existing pairing topic is deprecated and will be removed in the next major release."),d=P.active}}catch(P){throw this.client.logger.error(`connect() -> pairing.get(${h}) failed`),P}if(!h||!d){const{topic:P,uri:S}=await this.client.core.pairing.create();h=P,u=S}if(!h){const{message:P}=R("NO_MATCHING_KEY",`connect() pairing topic: ${h}`);throw new Error(P)}const g=await this.client.core.crypto.generateKeyPair(),w=Be.wc_sessionPropose.req.ttl||U.FIVE_MINUTES,f=De(w),m=et(ve(ve({requiredNamespaces:n,optionalNamespaces:o,relays:l??[{protocol:fh}],proposer:{publicKey:g,metadata:this.client.metadata},expiryTimestamp:f,pairingTopic:h},a&&{sessionProperties:a}),c&&{scopedProperties:c}),{id:as()}),y=pe("session_connect",m.id),{reject:b,resolve:E,done:A}=Rs(w,Lc),$=({id:P})=>{P===m.id&&(this.client.events.off("proposal_expire",$),this.pendingSessions.delete(m.id),this.events.emit(y,{error:{message:Lc,code:0}}))};return this.client.events.on("proposal_expire",$),this.events.once(y,({error:P,session:S})=>{this.client.events.off("proposal_expire",$),P?b(P):S&&E(S)}),await this.sendRequest({topic:h,method:"wc_sessionPropose",params:m,throwOnFailedPublish:!0,clientRpcId:m.id}),await this.setProposal(m.id,m),{uri:u,approval:A}}),N(this,"pair",async s=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{return await this.client.core.pairing.pair(s)}catch(r){throw this.client.logger.error("pair() failed"),r}}),N(this,"approve",async s=>{var r,i,n;const o=this.client.core.eventClient.createEvent({properties:{topic:(r=s==null?void 0:s.id)==null?void 0:r.toString(),trace:[kt.session_approve_started]}});try{this.isInitialized(),await this.confirmOnlineStateOrThrow()}catch(v){throw o.setError(Ts.no_internet_connection),v}try{await this.isValidProposalId(s==null?void 0:s.id)}catch(v){throw this.client.logger.error(`approve() -> proposal.get(${s==null?void 0:s.id}) failed`),o.setError(Ts.proposal_not_found),v}try{await this.isValidApprove(s)}catch(v){throw this.client.logger.error("approve() -> isValidApprove() failed"),o.setError(Ts.session_approve_namespace_validation_failure),v}const{id:a,relayProtocol:c,namespaces:l,sessionProperties:h,scopedProperties:u,sessionConfig:d}=s,g=this.client.proposal.get(a);this.client.core.eventClient.deleteEvent({eventId:o.eventId});const{pairingTopic:w,proposer:f,requiredNamespaces:m,optionalNamespaces:y}=g;let b=(i=this.client.core.eventClient)==null?void 0:i.getEvent({topic:w});b||(b=(n=this.client.core.eventClient)==null?void 0:n.createEvent({type:kt.session_approve_started,properties:{topic:w,trace:[kt.session_approve_started,kt.session_namespaces_validation_success]}}));const E=await this.client.core.crypto.generateKeyPair(),A=f.publicKey,$=await this.client.core.crypto.generateSharedKey(E,A),P=ve(ve(ve({relay:{protocol:c??"irn"},namespaces:l,controller:{publicKey:E,metadata:this.client.metadata},expiry:De(or)},h&&{sessionProperties:h}),u&&{scopedProperties:u}),d&&{sessionConfig:d}),S=Ne.relay;b.addTrace(kt.subscribing_session_topic);try{await this.client.core.relayer.subscribe($,{transportType:S})}catch(v){throw b.setError(Ts.subscribe_session_topic_failure),v}b.addTrace(kt.subscribe_session_topic_success);const D=et(ve({},P),{topic:$,requiredNamespaces:m,optionalNamespaces:y,pairingTopic:w,acknowledged:!1,self:P.controller,peer:{publicKey:f.publicKey,metadata:f.metadata},controller:E,transportType:Ne.relay});await this.client.session.set($,D),b.addTrace(kt.store_session);try{b.addTrace(kt.publishing_session_settle),await this.sendRequest({topic:$,method:"wc_sessionSettle",params:P,throwOnFailedPublish:!0}).catch(v=>{throw b==null||b.setError(Ts.session_settle_publish_failure),v}),b.addTrace(kt.session_settle_publish_success),b.addTrace(kt.publishing_session_approve),await this.sendResult({id:a,topic:w,result:{relay:{protocol:c??"irn"},responderPublicKey:E},throwOnFailedPublish:!0}).catch(v=>{throw b==null||b.setError(Ts.session_approve_publish_failure),v}),b.addTrace(kt.session_approve_publish_success)}catch(v){throw this.client.logger.error(v),this.client.session.delete($,we("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe($),v}return this.client.core.eventClient.deleteEvent({eventId:b.eventId}),await this.client.core.pairing.updateMetadata({topic:w,metadata:f.metadata}),await this.client.proposal.delete(a,we("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:w}),await this.setExpiry($,De(or)),{topic:$,acknowledged:()=>Promise.resolve(this.client.session.get($))}}),N(this,"reject",async s=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidReject(s)}catch(o){throw this.client.logger.error("reject() -> isValidReject() failed"),o}const{id:r,reason:i}=s;let n;try{n=this.client.proposal.get(r).pairingTopic}catch(o){throw this.client.logger.error(`reject() -> proposal.get(${r}) failed`),o}n&&(await this.sendError({id:r,topic:n,error:i,rpcOpts:Be.wc_sessionPropose.reject}),await this.client.proposal.delete(r,we("USER_DISCONNECTED")))}),N(this,"update",async s=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidUpdate(s)}catch(u){throw this.client.logger.error("update() -> isValidUpdate() failed"),u}const{topic:r,namespaces:i}=s,{done:n,resolve:o,reject:a}=Rs(),c=as(),l=Cr().toString(),h=this.client.session.get(r).namespaces;return this.events.once(pe("session_update",c),({error:u})=>{u?a(u):o()}),await this.client.session.update(r,{namespaces:i}),await this.sendRequest({topic:r,method:"wc_sessionUpdate",params:{namespaces:i},throwOnFailedPublish:!0,clientRpcId:c,relayRpcId:l}).catch(u=>{this.client.logger.error(u),this.client.session.update(r,{namespaces:h}),a(u)}),{acknowledged:n}}),N(this,"extend",async s=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidExtend(s)}catch(c){throw this.client.logger.error("extend() -> isValidExtend() failed"),c}const{topic:r}=s,i=as(),{done:n,resolve:o,reject:a}=Rs();return this.events.once(pe("session_extend",i),({error:c})=>{c?a(c):o()}),await this.setExpiry(r,De(or)),this.sendRequest({topic:r,method:"wc_sessionExtend",params:{},clientRpcId:i,throwOnFailedPublish:!0}).catch(c=>{a(c)}),{acknowledged:n}}),N(this,"request",async s=>{this.isInitialized();try{await this.isValidRequest(s)}catch(y){throw this.client.logger.error("request() -> isValidRequest() failed"),y}const{chainId:r,request:i,topic:n,expiry:o=Be.wc_sessionRequest.req.ttl}=s,a=this.client.session.get(n);(a==null?void 0:a.transportType)===Ne.relay&&await this.confirmOnlineStateOrThrow();const c=as(),l=Cr().toString(),{done:h,resolve:u,reject:d}=Rs(o,"Request expired. Please try again.");this.events.once(pe("session_request",c),({error:y,result:b})=>{y?d(y):u(b)});const g="wc_sessionRequest",w=this.getAppLinkIfEnabled(a.peer.metadata,a.transportType);if(w)return await this.sendRequest({clientRpcId:c,relayRpcId:l,topic:n,method:g,params:{request:et(ve({},i),{expiryTimestamp:De(o)}),chainId:r},expiry:o,throwOnFailedPublish:!0,appLink:w}).catch(y=>d(y)),this.client.events.emit("session_request_sent",{topic:n,request:i,chainId:r,id:c}),await h();const f={request:et(ve({},i),{expiryTimestamp:De(o)}),chainId:r},m=this.shouldSetTVF(g,f);return await Promise.all([new Promise(async y=>{await this.sendRequest(ve({clientRpcId:c,relayRpcId:l,topic:n,method:g,params:f,expiry:o,throwOnFailedPublish:!0},m&&{tvf:this.getTVFParams(c,f)})).catch(b=>d(b)),this.client.events.emit("session_request_sent",{topic:n,request:i,chainId:r,id:c}),y()}),new Promise(async y=>{var b;if(!((b=a.sessionConfig)!=null&&b.disableDeepLink)){const E=await Jd(this.client.core.storage,Dc);await Vd({id:c,topic:n,wcDeepLink:E})}y()}),h()]).then(y=>y[2])}),N(this,"respond",async s=>{this.isInitialized(),await this.isValidRespond(s);const{topic:r,response:i}=s,{id:n}=i,o=this.client.session.get(r);o.transportType===Ne.relay&&await this.confirmOnlineStateOrThrow();const a=this.getAppLinkIfEnabled(o.peer.metadata,o.transportType);ts(i)?await this.sendResult({id:n,topic:r,result:i.result,throwOnFailedPublish:!0,appLink:a}):Wt(i)&&await this.sendError({id:n,topic:r,error:i.error,appLink:a}),this.cleanupAfterResponse(s)}),N(this,"ping",async s=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidPing(s)}catch(i){throw this.client.logger.error("ping() -> isValidPing() failed"),i}const{topic:r}=s;if(this.client.session.keys.includes(r)){const i=as(),n=Cr().toString(),{done:o,resolve:a,reject:c}=Rs();this.events.once(pe("session_ping",i),({error:l})=>{l?c(l):a()}),await Promise.all([this.sendRequest({topic:r,method:"wc_sessionPing",params:{},throwOnFailedPublish:!0,clientRpcId:i,relayRpcId:n}),o()])}else this.client.core.pairing.pairings.keys.includes(r)&&(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:r}))}),N(this,"emit",async s=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidEmit(s);const{topic:r,event:i,chainId:n}=s,o=Cr().toString(),a=as();await this.sendRequest({topic:r,method:"wc_sessionEvent",params:{event:i,chainId:n},throwOnFailedPublish:!0,relayRpcId:o,clientRpcId:a})}),N(this,"disconnect",async s=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidDisconnect(s);const{topic:r}=s;if(this.client.session.keys.includes(r))await this.sendRequest({topic:r,method:"wc_sessionDelete",params:we("USER_DISCONNECTED"),throwOnFailedPublish:!0}),await this.deleteSession({topic:r,emitEvent:!1});else if(this.client.core.pairing.pairings.keys.includes(r))await this.client.core.pairing.disconnect({topic:r});else{const{message:i}=R("MISMATCHED_TOPIC",`Session or pairing topic not found: ${r}`);throw new Error(i)}}),N(this,"find",s=>(this.isInitialized(),this.client.session.getAll().filter(r=>qg(r,s)))),N(this,"getPendingSessionRequests",()=>this.client.pendingRequest.getAll()),N(this,"authenticate",async(s,r)=>{var i;this.isInitialized(),this.isValidAuthenticate(s);const n=r&&this.client.core.linkModeSupportedApps.includes(r)&&((i=this.client.metadata.redirect)==null?void 0:i.linkMode),o=n?Ne.link_mode:Ne.relay;o===Ne.relay&&await this.confirmOnlineStateOrThrow();const{chains:a,statement:c="",uri:l,domain:h,nonce:u,type:d,exp:g,nbf:w,methods:f=[],expiry:m}=s,y=[...s.resources||[]],{topic:b,uri:E}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"],transportType:o});this.client.logger.info({message:"Generated new pairing",pairing:{topic:b,uri:E}});const A=await this.client.core.crypto.generateKeyPair(),$=en(A);if(await Promise.all([this.client.auth.authKeys.set(sn,{responseTopic:$,publicKey:A}),this.client.auth.pairingTopics.set($,{topic:$,pairingTopic:b})]),await this.client.core.relayer.subscribe($,{transportType:o}),this.client.logger.info(`sending request to new pairing topic: ${b}`),f.length>0){const{namespace:k}=_r(a[0]);let G=jp(k,"request",f);Qi(y)&&(G=Wp(G,y.pop())),y.push(G)}const P=m&&m>Be.wc_sessionAuthenticate.req.ttl?m:Be.wc_sessionAuthenticate.req.ttl,S={authPayload:{type:d??"caip122",chains:a,statement:c,aud:l,domain:h,version:"1",nonce:u,iat:new Date().toISOString(),exp:g,nbf:w,resources:y},requester:{publicKey:A,metadata:this.client.metadata},expiryTimestamp:De(P)},D={eip155:{chains:a,methods:[...new Set(["personal_sign",...f])],events:["chainChanged","accountsChanged"]}},v={requiredNamespaces:{},optionalNamespaces:D,relays:[{protocol:"irn"}],pairingTopic:b,proposer:{publicKey:A,metadata:this.client.metadata},expiryTimestamp:De(Be.wc_sessionPropose.req.ttl),id:as()},{done:x,resolve:C,reject:L}=Rs(P,"Request expired"),H=as(),I=pe("session_connect",v.id),T=pe("session_request",H),_=async({error:k,session:G})=>{this.events.off(T,B),k?L(k):G&&C({session:G})},B=async k=>{var G,Q,se;if(await this.deletePendingAuthRequest(H,{message:"fulfilled",code:0}),k.error){const Re=we("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return k.error.code===Re.code?void 0:(this.events.off(I,_),L(k.error.message))}await this.deleteProposal(v.id),this.events.off(I,_);const{cacaos:Ce,responder:de}=k.result,Te=[],Le=[];for(const Re of Ce){await xa({cacao:Re,projectId:this.client.core.projectId})||(this.client.logger.error(Re,"Signature verification failed"),L(we("SESSION_SETTLEMENT_FAILED","Signature verification failed")));const{p:Ps}=Re,Jt=Qi(Ps.resources),Mt=[po(Ps.iss)],Yt=hn(Ps.iss);if(Jt){const Zt=Ra(Jt),Bi=Ua(Jt);Te.push(...Zt),Mt.push(...Bi)}for(const Zt of Mt)Le.push(`${Zt}:${Yt}`)}const Ye=await this.client.core.crypto.generateSharedKey(A,de.publicKey);let xe;Te.length>0&&(xe={topic:Ye,acknowledged:!0,self:{publicKey:A,metadata:this.client.metadata},peer:de,controller:de.publicKey,expiry:De(or),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:b,namespaces:oc([...new Set(Te)],[...new Set(Le)]),transportType:o},await this.client.core.relayer.subscribe(Ye,{transportType:o}),await this.client.session.set(Ye,xe),b&&await this.client.core.pairing.updateMetadata({topic:b,metadata:de.metadata}),xe=this.client.session.get(Ye)),(G=this.client.metadata.redirect)!=null&&G.linkMode&&(Q=de.metadata.redirect)!=null&&Q.linkMode&&(se=de.metadata.redirect)!=null&&se.universal&&r&&(this.client.core.addLinkModeSupportedApp(de.metadata.redirect.universal),this.client.session.update(Ye,{transportType:Ne.link_mode})),C({auths:Ce,session:xe})};this.events.once(I,_),this.events.once(T,B);let j;try{if(n){const k=Bs("wc_sessionAuthenticate",S,H);this.client.core.history.set(b,k);const G=await this.client.core.crypto.encode("",k,{type:Ui,encoding:ms});j=Hi(r,b,G)}else await Promise.all([this.sendRequest({topic:b,method:"wc_sessionAuthenticate",params:S,expiry:s.expiry,throwOnFailedPublish:!0,clientRpcId:H}),this.sendRequest({topic:b,method:"wc_sessionPropose",params:v,expiry:Be.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:v.id})])}catch(k){throw this.events.off(I,_),this.events.off(T,B),k}return await this.setProposal(v.id,v),await this.setAuthRequest(H,{request:et(ve({},S),{verifyContext:{}}),pairingTopic:b,transportType:o}),{uri:j??E,response:x}}),N(this,"approveSessionAuthenticate",async s=>{const{id:r,auths:i}=s,n=this.client.core.eventClient.createEvent({properties:{topic:r.toString(),trace:[ks.authenticated_session_approve_started]}});try{this.isInitialized()}catch(m){throw n.setError(Zr.no_internet_connection),m}const o=this.getPendingAuthRequest(r);if(!o)throw n.setError(Zr.authenticated_session_pending_request_not_found),new Error(`Could not find pending auth request with id ${r}`);const a=o.transportType||Ne.relay;a===Ne.relay&&await this.confirmOnlineStateOrThrow();const c=o.requester.publicKey,l=await this.client.core.crypto.generateKeyPair(),h=en(c),u={type:os,receiverPublicKey:c,senderPublicKey:l},d=[],g=[];for(const m of i){if(!await xa({cacao:m,projectId:this.client.core.projectId})){n.setError(Zr.invalid_cacao);const $=we("SESSION_SETTLEMENT_FAILED","Signature verification failed");throw await this.sendError({id:r,topic:h,error:$,encodeOpts:u}),new Error($.message)}n.addTrace(ks.cacaos_verified);const{p:y}=m,b=Qi(y.resources),E=[po(y.iss)],A=hn(y.iss);if(b){const $=Ra(b),P=Ua(b);d.push(...$),E.push(...P)}for(const $ of E)g.push(`${$}:${A}`)}const w=await this.client.core.crypto.generateSharedKey(l,c);n.addTrace(ks.create_authenticated_session_topic);let f;if((d==null?void 0:d.length)>0){f={topic:w,acknowledged:!0,self:{publicKey:l,metadata:this.client.metadata},peer:{publicKey:c,metadata:o.requester.metadata},controller:c,expiry:De(or),authentication:i,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:o.pairingTopic,namespaces:oc([...new Set(d)],[...new Set(g)]),transportType:a},n.addTrace(ks.subscribing_authenticated_session_topic);try{await this.client.core.relayer.subscribe(w,{transportType:a})}catch(m){throw n.setError(Zr.subscribe_authenticated_session_topic_failure),m}n.addTrace(ks.subscribe_authenticated_session_topic_success),await this.client.session.set(w,f),n.addTrace(ks.store_authenticated_session),await this.client.core.pairing.updateMetadata({topic:o.pairingTopic,metadata:o.requester.metadata})}n.addTrace(ks.publishing_authenticated_session_approve);try{await this.sendResult({topic:h,id:r,result:{cacaos:i,responder:{publicKey:l,metadata:this.client.metadata}},encodeOpts:u,throwOnFailedPublish:!0,appLink:this.getAppLinkIfEnabled(o.requester.metadata,a)})}catch(m){throw n.setError(Zr.authenticated_session_approve_publish_failure),m}return await this.client.auth.requests.delete(r,{message:"fulfilled",code:0}),await this.client.core.pairing.activate({topic:o.pairingTopic}),this.client.core.eventClient.deleteEvent({eventId:n.eventId}),{session:f}}),N(this,"rejectSessionAuthenticate",async s=>{this.isInitialized();const{id:r,reason:i}=s,n=this.getPendingAuthRequest(r);if(!n)throw new Error(`Could not find pending auth request with id ${r}`);n.transportType===Ne.relay&&await this.confirmOnlineStateOrThrow();const o=n.requester.publicKey,a=await this.client.core.crypto.generateKeyPair(),c=en(o),l={type:os,receiverPublicKey:o,senderPublicKey:a};await this.sendError({id:r,topic:c,error:i,encodeOpts:l,rpcOpts:Be.wc_sessionAuthenticate.reject,appLink:this.getAppLinkIfEnabled(n.requester.metadata,n.transportType)}),await this.client.auth.requests.delete(r,{message:"rejected",code:0}),await this.client.proposal.delete(r,we("USER_DISCONNECTED"))}),N(this,"formatAuthMessage",s=>{this.isInitialized();const{request:r,iss:i}=s;return Bl(r,i)}),N(this,"processRelayMessageCache",()=>{setTimeout(async()=>{if(this.relayMessageCache.length!==0)for(;this.relayMessageCache.length>0;)try{const s=this.relayMessageCache.shift();s&&await this.onRelayMessage(s)}catch(s){this.client.logger.error(s)}},50)}),N(this,"cleanupDuplicatePairings",async s=>{if(s.pairingTopic)try{const r=this.client.core.pairing.pairings.get(s.pairingTopic),i=this.client.core.pairing.pairings.getAll().filter(n=>{var o,a;return((o=n.peerMetadata)==null?void 0:o.url)&&((a=n.peerMetadata)==null?void 0:a.url)===s.peer.metadata.url&&n.topic&&n.topic!==r.topic});if(i.length===0)return;this.client.logger.info(`Cleaning up ${i.length} duplicate pairing(s)`),await Promise.all(i.map(n=>this.client.core.pairing.disconnect({topic:n.topic}))),this.client.logger.info("Duplicate pairings clean up finished")}catch(r){this.client.logger.error(r)}}),N(this,"deleteSession",async s=>{var r;const{topic:i,expirerHasDeleted:n=!1,emitEvent:o=!0,id:a=0}=s,{self:c}=this.client.session.get(i);await this.client.core.relayer.unsubscribe(i),await this.client.session.delete(i,we("USER_DISCONNECTED")),this.addToRecentlyDeleted(i,"session"),this.client.core.crypto.keychain.has(c.publicKey)&&await this.client.core.crypto.deleteKeyPair(c.publicKey),this.client.core.crypto.keychain.has(i)&&await this.client.core.crypto.deleteSymKey(i),n||this.client.core.expirer.del(i),this.client.core.storage.removeItem(Dc).catch(l=>this.client.logger.warn(l)),this.getPendingSessionRequests().forEach(l=>{l.topic===i&&this.deletePendingSessionRequest(l.id,we("USER_DISCONNECTED"))}),i===((r=this.sessionRequestQueue.queue[0])==null?void 0:r.topic)&&(this.sessionRequestQueue.state=jt.idle),o&&this.client.events.emit("session_delete",{id:a,topic:i})}),N(this,"deleteProposal",async(s,r)=>{if(r)try{const i=this.client.proposal.get(s),n=this.client.core.eventClient.getEvent({topic:i.pairingTopic});n==null||n.setError(Ts.proposal_expired)}catch{}await Promise.all([this.client.proposal.delete(s,we("USER_DISCONNECTED")),r?Promise.resolve():this.client.core.expirer.del(s)]),this.addToRecentlyDeleted(s,"proposal")}),N(this,"deletePendingSessionRequest",async(s,r,i=!1)=>{await Promise.all([this.client.pendingRequest.delete(s,r),i?Promise.resolve():this.client.core.expirer.del(s)]),this.addToRecentlyDeleted(s,"request"),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter(n=>n.id!==s),i&&(this.sessionRequestQueue.state=jt.idle,this.client.events.emit("session_request_expire",{id:s}))}),N(this,"deletePendingAuthRequest",async(s,r,i=!1)=>{await Promise.all([this.client.auth.requests.delete(s,r),i?Promise.resolve():this.client.core.expirer.del(s)])}),N(this,"setExpiry",async(s,r)=>{this.client.session.keys.includes(s)&&(this.client.core.expirer.set(s,r),await this.client.session.update(s,{expiry:r}))}),N(this,"setProposal",async(s,r)=>{this.client.core.expirer.set(s,De(Be.wc_sessionPropose.req.ttl)),await this.client.proposal.set(s,r)}),N(this,"setAuthRequest",async(s,r)=>{const{request:i,pairingTopic:n,transportType:o=Ne.relay}=r;this.client.core.expirer.set(s,i.expiryTimestamp),await this.client.auth.requests.set(s,{authPayload:i.authPayload,requester:i.requester,expiryTimestamp:i.expiryTimestamp,id:s,pairingTopic:n,verifyContext:i.verifyContext,transportType:o})}),N(this,"setPendingSessionRequest",async s=>{const{id:r,topic:i,params:n,verifyContext:o}=s,a=n.request.expiryTimestamp||De(Be.wc_sessionRequest.req.ttl);this.client.core.expirer.set(r,a),await this.client.pendingRequest.set(r,{id:r,topic:i,params:n,verifyContext:o})}),N(this,"sendRequest",async s=>{const{topic:r,method:i,params:n,expiry:o,relayRpcId:a,clientRpcId:c,throwOnFailedPublish:l,appLink:h,tvf:u}=s,d=Bs(i,n,c);let g;const w=!!h;try{const y=w?ms:Dt;g=await this.client.core.crypto.encode(r,d,{encoding:y})}catch(y){throw await this.cleanup(),this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${r} failed`),y}let f;if(rv.includes(i)){const y=Ht(JSON.stringify(d)),b=Ht(g);f=await this.client.core.verify.register({id:b,decryptedId:y})}const m=Be[i].req;if(m.attestation=f,o&&(m.ttl=o),a&&(m.id=a),this.client.core.history.set(r,d),w){const y=Hi(h,r,g);await global.Linking.openURL(y,this.client.name)}else{const y=Be[i].req;o&&(y.ttl=o),a&&(y.id=a),y.tvf=et(ve({},u),{correlationId:d.id}),l?(y.internal=et(ve({},y.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(r,g,y)):this.client.core.relayer.publish(r,g,y).catch(b=>this.client.logger.error(b))}return d.id}),N(this,"sendResult",async s=>{const{id:r,topic:i,result:n,throwOnFailedPublish:o,encodeOpts:a,appLink:c}=s,l=mn(r,n);let h;const u=c&&typeof(global==null?void 0:global.Linking)<"u";try{const w=u?ms:Dt;h=await this.client.core.crypto.encode(i,l,et(ve({},a||{}),{encoding:w}))}catch(w){throw await this.cleanup(),this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${i} failed`),w}let d,g;try{d=await this.client.core.history.get(i,r);const w=d.request;try{this.shouldSetTVF(w.method,w.params)&&(g=this.getTVFParams(r,w.params,n))}catch(f){this.client.logger.warn("sendResult() -> getTVFParams() failed",f)}}catch(w){throw this.client.logger.error(`sendResult() -> history.get(${i}, ${r}) failed`),w}if(u){const w=Hi(c,i,h);await global.Linking.openURL(w,this.client.name)}else{const w=d.request.method,f=Be[w].res;f.tvf=et(ve({},g),{correlationId:r}),o?(f.internal=et(ve({},f.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(i,h,f)):this.client.core.relayer.publish(i,h,f).catch(m=>this.client.logger.error(m))}await this.client.core.history.resolve(l)}),N(this,"sendError",async s=>{const{id:r,topic:i,error:n,encodeOpts:o,rpcOpts:a,appLink:c}=s,l=yl(r,n);let h;const u=c&&typeof(global==null?void 0:global.Linking)<"u";try{const g=u?ms:Dt;h=await this.client.core.crypto.encode(i,l,et(ve({},o||{}),{encoding:g}))}catch(g){throw await this.cleanup(),this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${i} failed`),g}let d;try{d=await this.client.core.history.get(i,r)}catch(g){throw this.client.logger.error(`sendError() -> history.get(${i}, ${r}) failed`),g}if(u){const g=Hi(c,i,h);await global.Linking.openURL(g,this.client.name)}else{const g=d.request.method,w=a||Be[g].res;this.client.core.relayer.publish(i,h,w)}await this.client.core.history.resolve(l)}),N(this,"cleanup",async()=>{const s=[],r=[];this.client.session.getAll().forEach(i=>{let n=!1;gs(i.expiry)&&(n=!0),this.client.core.crypto.keychain.has(i.topic)||(n=!0),n&&s.push(i.topic)}),this.client.proposal.getAll().forEach(i=>{gs(i.expiryTimestamp)&&r.push(i.id)}),await Promise.all([...s.map(i=>this.deleteSession({topic:i})),...r.map(i=>this.deleteProposal(i))])}),N(this,"onProviderMessageEvent",async s=>{!this.initialized||this.relayMessageCache.length>0?this.relayMessageCache.push(s):await this.onRelayMessage(s)}),N(this,"onRelayEventRequest",async s=>{this.requestQueue.queue.push(s),await this.processRequestsQueue()}),N(this,"processRequestsQueue",async()=>{if(this.requestQueue.state===jt.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=jt.active;const s=this.requestQueue.queue.shift();if(s)try{await this.processRequest(s)}catch(r){this.client.logger.warn(r)}}this.requestQueue.state=jt.idle}),N(this,"processRequest",async s=>{const{topic:r,payload:i,attestation:n,transportType:o,encryptedId:a}=s,c=i.method;if(!this.shouldIgnorePairingRequest({topic:r,requestMethod:c}))switch(c){case"wc_sessionPropose":return await this.onSessionProposeRequest({topic:r,payload:i,attestation:n,encryptedId:a});case"wc_sessionSettle":return await this.onSessionSettleRequest(r,i);case"wc_sessionUpdate":return await this.onSessionUpdateRequest(r,i);case"wc_sessionExtend":return await this.onSessionExtendRequest(r,i);case"wc_sessionPing":return await this.onSessionPingRequest(r,i);case"wc_sessionDelete":return await this.onSessionDeleteRequest(r,i);case"wc_sessionRequest":return await this.onSessionRequest({topic:r,payload:i,attestation:n,encryptedId:a,transportType:o});case"wc_sessionEvent":return await this.onSessionEventRequest(r,i);case"wc_sessionAuthenticate":return await this.onSessionAuthenticateRequest({topic:r,payload:i,attestation:n,encryptedId:a,transportType:o});default:return this.client.logger.info(`Unsupported request method ${c}`)}}),N(this,"onRelayEventResponse",async s=>{const{topic:r,payload:i,transportType:n}=s,o=(await this.client.core.history.get(r,i.id)).request.method;switch(o){case"wc_sessionPropose":return this.onSessionProposeResponse(r,i,n);case"wc_sessionSettle":return this.onSessionSettleResponse(r,i);case"wc_sessionUpdate":return this.onSessionUpdateResponse(r,i);case"wc_sessionExtend":return this.onSessionExtendResponse(r,i);case"wc_sessionPing":return this.onSessionPingResponse(r,i);case"wc_sessionRequest":return this.onSessionRequestResponse(r,i);case"wc_sessionAuthenticate":return this.onSessionAuthenticateResponse(r,i);default:return this.client.logger.info(`Unsupported response method ${o}`)}}),N(this,"onRelayEventUnknownPayload",s=>{const{topic:r}=s,{message:i}=R("MISSING_OR_INVALID",`Decoded payload on topic ${r} is not identifiable as a JSON-RPC request or a response.`);throw new Error(i)}),N(this,"shouldIgnorePairingRequest",s=>{const{topic:r,requestMethod:i}=s,n=this.expectedPairingMethodMap.get(r);return!n||n.includes(i)?!1:!!(n.includes("wc_sessionAuthenticate")&&this.client.events.listenerCount("session_authenticate")>0)}),N(this,"onSessionProposeRequest",async s=>{const{topic:r,payload:i,attestation:n,encryptedId:o}=s,{params:a,id:c}=i;try{const l=this.client.core.eventClient.getEvent({topic:r});this.client.events.listenerCount("session_proposal")===0&&(console.warn("No listener for session_proposal event"),l==null||l.setError(ss.proposal_listener_not_found)),this.isValidConnect(ve({},i.params));const h=a.expiryTimestamp||De(Be.wc_sessionPropose.req.ttl),u=ve({id:c,pairingTopic:r,expiryTimestamp:h},a);await this.setProposal(c,u);const d=await this.getVerifyContext({attestationId:n,hash:Ht(JSON.stringify(i)),encryptedId:o,metadata:u.proposer.metadata});l==null||l.addTrace(Ft.emit_session_proposal),this.client.events.emit("session_proposal",{id:c,params:u,verifyContext:d})}catch(l){await this.sendError({id:c,topic:r,error:l,rpcOpts:Be.wc_sessionPropose.autoReject}),this.client.logger.error(l)}}),N(this,"onSessionProposeResponse",async(s,r,i)=>{const{id:n}=r;if(ts(r)){const{result:o}=r;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:o});const a=this.client.proposal.get(n);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:a});const c=a.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:c});const l=o.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:l});const h=await this.client.core.crypto.generateSharedKey(c,l);this.pendingSessions.set(n,{sessionTopic:h,pairingTopic:s,proposalId:n,publicKey:c});const u=await this.client.core.relayer.subscribe(h,{transportType:i});this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:u}),await this.client.core.pairing.activate({topic:s})}else if(Wt(r)){await this.client.proposal.delete(n,we("USER_DISCONNECTED"));const o=pe("session_connect",n);if(this.events.listenerCount(o)===0)throw new Error(`emitting ${o} without any listeners, 954`);this.events.emit(o,{error:r.error})}}),N(this,"onSessionSettleRequest",async(s,r)=>{const{id:i,params:n}=r;try{this.isValidSessionSettleRequest(n);const{relay:o,controller:a,expiry:c,namespaces:l,sessionProperties:h,scopedProperties:u,sessionConfig:d}=r.params,g=[...this.pendingSessions.values()].find(m=>m.sessionTopic===s);if(!g)return this.client.logger.error(`Pending session not found for topic ${s}`);const w=this.client.proposal.get(g.proposalId),f=et(ve(ve(ve({topic:s,relay:o,expiry:c,namespaces:l,acknowledged:!0,pairingTopic:g.pairingTopic,requiredNamespaces:w.requiredNamespaces,optionalNamespaces:w.optionalNamespaces,controller:a.publicKey,self:{publicKey:g.publicKey,metadata:this.client.metadata},peer:{publicKey:a.publicKey,metadata:a.metadata}},h&&{sessionProperties:h}),u&&{scopedProperties:u}),d&&{sessionConfig:d}),{transportType:Ne.relay});await this.client.session.set(f.topic,f),await this.setExpiry(f.topic,f.expiry),await this.client.core.pairing.updateMetadata({topic:g.pairingTopic,metadata:f.peer.metadata}),this.client.events.emit("session_connect",{session:f}),this.events.emit(pe("session_connect",g.proposalId),{session:f}),this.pendingSessions.delete(g.proposalId),this.deleteProposal(g.proposalId,!1),this.cleanupDuplicatePairings(f),await this.sendResult({id:r.id,topic:s,result:!0,throwOnFailedPublish:!0})}catch(o){await this.sendError({id:i,topic:s,error:o}),this.client.logger.error(o)}}),N(this,"onSessionSettleResponse",async(s,r)=>{const{id:i}=r;ts(r)?(await this.client.session.update(s,{acknowledged:!0}),this.events.emit(pe("session_approve",i),{})):Wt(r)&&(await this.client.session.delete(s,we("USER_DISCONNECTED")),this.events.emit(pe("session_approve",i),{error:r.error}))}),N(this,"onSessionUpdateRequest",async(s,r)=>{const{params:i,id:n}=r;try{const o=`${s}_session_update`,a=Jr.get(o);if(a&&this.isRequestOutOfSync(a,n)){this.client.logger.warn(`Discarding out of sync request - ${n}`),this.sendError({id:n,topic:s,error:we("INVALID_UPDATE_REQUEST")});return}this.isValidUpdate(ve({topic:s},i));try{Jr.set(o,n),await this.client.session.update(s,{namespaces:i.namespaces}),await this.sendResult({id:n,topic:s,result:!0,throwOnFailedPublish:!0})}catch(c){throw Jr.delete(o),c}this.client.events.emit("session_update",{id:n,topic:s,params:i})}catch(o){await this.sendError({id:n,topic:s,error:o}),this.client.logger.error(o)}}),N(this,"isRequestOutOfSync",(s,r)=>r.toString().slice(0,-3)<s.toString().slice(0,-3)),N(this,"onSessionUpdateResponse",(s,r)=>{const{id:i}=r,n=pe("session_update",i);if(this.events.listenerCount(n)===0)throw new Error(`emitting ${n} without any listeners`);ts(r)?this.events.emit(pe("session_update",i),{}):Wt(r)&&this.events.emit(pe("session_update",i),{error:r.error})}),N(this,"onSessionExtendRequest",async(s,r)=>{const{id:i}=r;try{this.isValidExtend({topic:s}),await this.setExpiry(s,De(or)),await this.sendResult({id:i,topic:s,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_extend",{id:i,topic:s})}catch(n){await this.sendError({id:i,topic:s,error:n}),this.client.logger.error(n)}}),N(this,"onSessionExtendResponse",(s,r)=>{const{id:i}=r,n=pe("session_extend",i);if(this.events.listenerCount(n)===0)throw new Error(`emitting ${n} without any listeners`);ts(r)?this.events.emit(pe("session_extend",i),{}):Wt(r)&&this.events.emit(pe("session_extend",i),{error:r.error})}),N(this,"onSessionPingRequest",async(s,r)=>{const{id:i}=r;try{this.isValidPing({topic:s}),await this.sendResult({id:i,topic:s,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_ping",{id:i,topic:s})}catch(n){await this.sendError({id:i,topic:s,error:n}),this.client.logger.error(n)}}),N(this,"onSessionPingResponse",(s,r)=>{const{id:i}=r,n=pe("session_ping",i);setTimeout(()=>{if(this.events.listenerCount(n)===0)throw new Error(`emitting ${n} without any listeners 2176`);ts(r)?this.events.emit(pe("session_ping",i),{}):Wt(r)&&this.events.emit(pe("session_ping",i),{error:r.error})},500)}),N(this,"onSessionDeleteRequest",async(s,r)=>{const{id:i}=r;try{this.isValidDisconnect({topic:s,reason:r.params}),Promise.all([new Promise(n=>{this.client.core.relayer.once(je.publish,async()=>{n(await this.deleteSession({topic:s,id:i}))})}),this.sendResult({id:i,topic:s,result:!0,throwOnFailedPublish:!0}),this.cleanupPendingSentRequestsForTopic({topic:s,error:we("USER_DISCONNECTED")})]).catch(n=>this.client.logger.error(n))}catch(n){this.client.logger.error(n)}}),N(this,"onSessionRequest",async s=>{var r,i,n;const{topic:o,payload:a,attestation:c,encryptedId:l,transportType:h}=s,{id:u,params:d}=a;try{await this.isValidRequest(ve({topic:o},d));const g=this.client.session.get(o),w=await this.getVerifyContext({attestationId:c,hash:Ht(JSON.stringify(Bs("wc_sessionRequest",d,u))),encryptedId:l,metadata:g.peer.metadata,transportType:h}),f={id:u,topic:o,params:d,verifyContext:w};await this.setPendingSessionRequest(f),h===Ne.link_mode&&(r=g.peer.metadata.redirect)!=null&&r.universal&&this.client.core.addLinkModeSupportedApp((i=g.peer.metadata.redirect)==null?void 0:i.universal),(n=this.client.signConfig)!=null&&n.disableRequestQueue?this.emitSessionRequest(f):(this.addSessionRequestToSessionRequestQueue(f),this.processSessionRequestQueue())}catch(g){await this.sendError({id:u,topic:o,error:g}),this.client.logger.error(g)}}),N(this,"onSessionRequestResponse",(s,r)=>{const{id:i}=r,n=pe("session_request",i);if(this.events.listenerCount(n)===0)throw new Error(`emitting ${n} without any listeners`);ts(r)?this.events.emit(pe("session_request",i),{result:r.result}):Wt(r)&&this.events.emit(pe("session_request",i),{error:r.error})}),N(this,"onSessionEventRequest",async(s,r)=>{const{id:i,params:n}=r;try{const o=`${s}_session_event_${n.event.name}`,a=Jr.get(o);if(a&&this.isRequestOutOfSync(a,i)){this.client.logger.info(`Discarding out of sync request - ${i}`);return}this.isValidEmit(ve({topic:s},n)),this.client.events.emit("session_event",{id:i,topic:s,params:n}),Jr.set(o,i)}catch(o){await this.sendError({id:i,topic:s,error:o}),this.client.logger.error(o)}}),N(this,"onSessionAuthenticateResponse",(s,r)=>{const{id:i}=r;this.client.logger.trace({type:"method",method:"onSessionAuthenticateResponse",topic:s,payload:r}),ts(r)?this.events.emit(pe("session_request",i),{result:r.result}):Wt(r)&&this.events.emit(pe("session_request",i),{error:r.error})}),N(this,"onSessionAuthenticateRequest",async s=>{var r;const{topic:i,payload:n,attestation:o,encryptedId:a,transportType:c}=s;try{const{requester:l,authPayload:h,expiryTimestamp:u}=n.params,d=await this.getVerifyContext({attestationId:o,hash:Ht(JSON.stringify(n)),encryptedId:a,metadata:l.metadata,transportType:c}),g={requester:l,pairingTopic:i,id:n.id,authPayload:h,verifyContext:d,expiryTimestamp:u};await this.setAuthRequest(n.id,{request:g,pairingTopic:i,transportType:c}),c===Ne.link_mode&&(r=l.metadata.redirect)!=null&&r.universal&&this.client.core.addLinkModeSupportedApp(l.metadata.redirect.universal),this.client.events.emit("session_authenticate",{topic:i,params:n.params,id:n.id,verifyContext:d})}catch(l){this.client.logger.error(l);const h=n.params.requester.publicKey,u=await this.client.core.crypto.generateKeyPair(),d=this.getAppLinkIfEnabled(n.params.requester.metadata,c),g={type:os,receiverPublicKey:h,senderPublicKey:u};await this.sendError({id:n.id,topic:i,error:l,encodeOpts:g,rpcOpts:Be.wc_sessionAuthenticate.autoReject,appLink:d})}}),N(this,"addSessionRequestToSessionRequestQueue",s=>{this.sessionRequestQueue.queue.push(s)}),N(this,"cleanupAfterResponse",s=>{this.deletePendingSessionRequest(s.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=jt.idle,this.processSessionRequestQueue()},U.toMiliseconds(this.requestQueueDelay))}),N(this,"cleanupPendingSentRequestsForTopic",({topic:s,error:r})=>{const i=this.client.core.history.pending;i.length>0&&i.filter(n=>n.topic===s&&n.request.method==="wc_sessionRequest").forEach(n=>{const o=n.request.id,a=pe("session_request",o);if(this.events.listenerCount(a)===0)throw new Error(`emitting ${a} without any listeners`);this.events.emit(pe("session_request",n.request.id),{error:r})})}),N(this,"processSessionRequestQueue",()=>{if(this.sessionRequestQueue.state===jt.active){this.client.logger.info("session request queue is already active.");return}const s=this.sessionRequestQueue.queue[0];if(!s){this.client.logger.info("session request queue is empty.");return}try{this.sessionRequestQueue.state=jt.active,this.emitSessionRequest(s)}catch(r){this.client.logger.error(r)}}),N(this,"emitSessionRequest",s=>{this.client.events.emit("session_request",s)}),N(this,"onPairingCreated",s=>{if(s.methods&&this.expectedPairingMethodMap.set(s.topic,s.methods),s.active)return;const r=this.client.proposal.getAll().find(i=>i.pairingTopic===s.topic);r&&this.onSessionProposeRequest({topic:s.topic,payload:Bs("wc_sessionPropose",et(ve({},r),{requiredNamespaces:r.requiredNamespaces,optionalNamespaces:r.optionalNamespaces,relays:r.relays,proposer:r.proposer,sessionProperties:r.sessionProperties,scopedProperties:r.scopedProperties}),r.id)})}),N(this,"isValidConnect",async s=>{if(!ct(s)){const{message:l}=R("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(s)}`);throw new Error(l)}const{pairingTopic:r,requiredNamespaces:i,optionalNamespaces:n,sessionProperties:o,scopedProperties:a,relays:c}=s;if(Ge(r)||await this.isValidPairingTopic(r),!Xg(c)){const{message:l}=R("MISSING_OR_INVALID",`connect() relays: ${c}`);throw new Error(l)}if(!Ge(i)&&Is(i)!==0){const l="requiredNamespaces are deprecated and are automatically assigned to optionalNamespaces";["fatal","error","silent"].includes(this.client.logger.level)?console.warn(l):this.client.logger.warn(l),this.validateNamespaces(i,"requiredNamespaces")}if(!Ge(n)&&Is(n)!==0&&this.validateNamespaces(n,"optionalNamespaces"),Ge(o)||this.validateSessionProps(o,"sessionProperties"),!Ge(a)){this.validateSessionProps(a,"scopedProperties");const l=Object.keys(i||{}).concat(Object.keys(n||{}));if(!Object.keys(a).every(h=>l.includes(h)))throw new Error(`Scoped properties must be a subset of required/optional namespaces, received: ${JSON.stringify(a)}, required/optional namespaces: ${JSON.stringify(l)}`)}}),N(this,"validateNamespaces",(s,r)=>{const i=Zg(s,"connect()",r);if(i)throw new Error(i.message)}),N(this,"isValidApprove",async s=>{if(!ct(s))throw new Error(R("MISSING_OR_INVALID",`approve() params: ${s}`).message);const{id:r,namespaces:i,relayProtocol:n,sessionProperties:o,scopedProperties:a}=s;this.checkRecentlyDeleted(r),await this.isValidProposalId(r);const c=this.client.proposal.get(r),l=Fn(i,"approve()");if(l)throw new Error(l.message);const h=lc(c.requiredNamespaces,i,"approve()");if(h)throw new Error(h.message);if(!$e(n,!0)){const{message:u}=R("MISSING_OR_INVALID",`approve() relayProtocol: ${n}`);throw new Error(u)}if(Ge(o)||this.validateSessionProps(o,"sessionProperties"),!Ge(a)){this.validateSessionProps(a,"scopedProperties");const u=new Set(Object.keys(i));if(!Object.keys(a).every(d=>u.has(d)))throw new Error(`Scoped properties must be a subset of approved namespaces, received: ${JSON.stringify(a)}, approved namespaces: ${Array.from(u).join(", ")}`)}}),N(this,"isValidReject",async s=>{if(!ct(s)){const{message:n}=R("MISSING_OR_INVALID",`reject() params: ${s}`);throw new Error(n)}const{id:r,reason:i}=s;if(this.checkRecentlyDeleted(r),await this.isValidProposalId(r),!em(i)){const{message:n}=R("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(i)}`);throw new Error(n)}}),N(this,"isValidSessionSettleRequest",s=>{if(!ct(s)){const{message:l}=R("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${s}`);throw new Error(l)}const{relay:r,controller:i,namespaces:n,expiry:o}=s;if(!uh(r)){const{message:l}=R("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(l)}const a=Hg(i,"onSessionSettleRequest()");if(a)throw new Error(a.message);const c=Fn(n,"onSessionSettleRequest()");if(c)throw new Error(c.message);if(gs(o)){const{message:l}=R("EXPIRED","onSessionSettleRequest()");throw new Error(l)}}),N(this,"isValidUpdate",async s=>{if(!ct(s)){const{message:c}=R("MISSING_OR_INVALID",`update() params: ${s}`);throw new Error(c)}const{topic:r,namespaces:i}=s;this.checkRecentlyDeleted(r),await this.isValidSessionTopic(r);const n=this.client.session.get(r),o=Fn(i,"update()");if(o)throw new Error(o.message);const a=lc(n.requiredNamespaces,i,"update()");if(a)throw new Error(a.message)}),N(this,"isValidExtend",async s=>{if(!ct(s)){const{message:i}=R("MISSING_OR_INVALID",`extend() params: ${s}`);throw new Error(i)}const{topic:r}=s;this.checkRecentlyDeleted(r),await this.isValidSessionTopic(r)}),N(this,"isValidRequest",async s=>{if(!ct(s)){const{message:c}=R("MISSING_OR_INVALID",`request() params: ${s}`);throw new Error(c)}const{topic:r,request:i,chainId:n,expiry:o}=s;this.checkRecentlyDeleted(r),await this.isValidSessionTopic(r);const{namespaces:a}=this.client.session.get(r);if(!cc(a,n)){const{message:c}=R("MISSING_OR_INVALID",`request() chainId: ${n}`);throw new Error(c)}if(!tm(i)){const{message:c}=R("MISSING_OR_INVALID",`request() ${JSON.stringify(i)}`);throw new Error(c)}if(!im(a,n,i.method)){const{message:c}=R("MISSING_OR_INVALID",`request() method: ${i.method}`);throw new Error(c)}if(o&&!cm(o,Jn)){const{message:c}=R("MISSING_OR_INVALID",`request() expiry: ${o}. Expiry must be a number (in seconds) between ${Jn.min} and ${Jn.max}`);throw new Error(c)}}),N(this,"isValidRespond",async s=>{var r;if(!ct(s)){const{message:o}=R("MISSING_OR_INVALID",`respond() params: ${s}`);throw new Error(o)}const{topic:i,response:n}=s;try{await this.isValidSessionTopic(i)}catch(o){throw(r=s==null?void 0:s.response)!=null&&r.id&&this.cleanupAfterResponse(s),o}if(!sm(n)){const{message:o}=R("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(n)}`);throw new Error(o)}}),N(this,"isValidPing",async s=>{if(!ct(s)){const{message:i}=R("MISSING_OR_INVALID",`ping() params: ${s}`);throw new Error(i)}const{topic:r}=s;await this.isValidSessionOrPairingTopic(r)}),N(this,"isValidEmit",async s=>{if(!ct(s)){const{message:a}=R("MISSING_OR_INVALID",`emit() params: ${s}`);throw new Error(a)}const{topic:r,event:i,chainId:n}=s;await this.isValidSessionTopic(r);const{namespaces:o}=this.client.session.get(r);if(!cc(o,n)){const{message:a}=R("MISSING_OR_INVALID",`emit() chainId: ${n}`);throw new Error(a)}if(!rm(i)){const{message:a}=R("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(i)}`);throw new Error(a)}if(!nm(o,n,i.name)){const{message:a}=R("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(i)}`);throw new Error(a)}}),N(this,"isValidDisconnect",async s=>{if(!ct(s)){const{message:i}=R("MISSING_OR_INVALID",`disconnect() params: ${s}`);throw new Error(i)}const{topic:r}=s;await this.isValidSessionOrPairingTopic(r)}),N(this,"isValidAuthenticate",s=>{const{chains:r,uri:i,domain:n,nonce:o}=s;if(!Array.isArray(r)||r.length===0)throw new Error("chains is required and must be a non-empty array");if(!$e(i,!1))throw new Error("uri is required parameter");if(!$e(n,!1))throw new Error("domain is required parameter");if(!$e(o,!1))throw new Error("nonce is required parameter");if([...new Set(r.map(c=>_r(c).namespace))].length>1)throw new Error("Multi-namespace requests are not supported. Please request single namespace only.");const{namespace:a}=_r(r[0]);if(a!=="eip155")throw new Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains.")}),N(this,"getVerifyContext",async s=>{const{attestationId:r,hash:i,encryptedId:n,metadata:o,transportType:a}=s,c={verified:{verifyUrl:o.verifyUrl||di,validation:"UNKNOWN",origin:o.url||""}};try{if(a===Ne.link_mode){const h=this.getAppLinkIfEnabled(o,a);return c.verified.validation=h&&new URL(h).origin===new URL(o.url).origin?"VALID":"INVALID",c}const l=await this.client.core.verify.resolve({attestationId:r,hash:i,encryptedId:n,verifyUrl:o.verifyUrl});l&&(c.verified.origin=l.origin,c.verified.isScam=l.isScam,c.verified.validation=l.origin===new URL(o.url).origin?"VALID":"INVALID")}catch(l){this.client.logger.warn(l)}return this.client.logger.debug(`Verify context: ${JSON.stringify(c)}`),c}),N(this,"validateSessionProps",(s,r)=>{Object.values(s).forEach((i,n)=>{if(i==null){const{message:o}=R("MISSING_OR_INVALID",`${r} must contain an existing value for each key. Received: ${i} for key ${Object.keys(s)[n]}`);throw new Error(o)}})}),N(this,"getPendingAuthRequest",s=>{const r=this.client.auth.requests.get(s);return typeof r=="object"?r:void 0}),N(this,"addToRecentlyDeleted",(s,r)=>{if(this.recentlyDeletedMap.set(s,r),this.recentlyDeletedMap.size>=this.recentlyDeletedLimit){let i=0;const n=this.recentlyDeletedLimit/2;for(const o of this.recentlyDeletedMap.keys()){if(i++>=n)break;this.recentlyDeletedMap.delete(o)}}}),N(this,"checkRecentlyDeleted",s=>{const r=this.recentlyDeletedMap.get(s);if(r){const{message:i}=R("MISSING_OR_INVALID",`Record was recently deleted - ${r}: ${s}`);throw new Error(i)}}),N(this,"isLinkModeEnabled",(s,r)=>{var i,n,o,a,c,l,h,u,d;return!s||r!==Ne.link_mode?!1:((n=(i=this.client.metadata)==null?void 0:i.redirect)==null?void 0:n.linkMode)===!0&&((a=(o=this.client.metadata)==null?void 0:o.redirect)==null?void 0:a.universal)!==void 0&&((l=(c=this.client.metadata)==null?void 0:c.redirect)==null?void 0:l.universal)!==""&&((h=s==null?void 0:s.redirect)==null?void 0:h.universal)!==void 0&&((u=s==null?void 0:s.redirect)==null?void 0:u.universal)!==""&&((d=s==null?void 0:s.redirect)==null?void 0:d.linkMode)===!0&&this.client.core.linkModeSupportedApps.includes(s.redirect.universal)&&typeof(global==null?void 0:global.Linking)<"u"}),N(this,"getAppLinkIfEnabled",(s,r)=>{var i;return this.isLinkModeEnabled(s,r)?(i=s==null?void 0:s.redirect)==null?void 0:i.universal:void 0}),N(this,"handleLinkModeMessage",({url:s})=>{if(!s||!s.includes("wc_ev")||!s.includes("topic"))return;const r=Aa(s,"topic")||"",i=decodeURIComponent(Aa(s,"wc_ev")||""),n=this.client.session.keys.includes(r);n&&this.client.session.update(r,{transportType:Ne.link_mode}),this.client.core.dispatchEnvelope({topic:r,message:i,sessionExists:n})}),N(this,"registerLinkModeListeners",async()=>{var s;if(zo()||Ss()&&(s=this.client.metadata.redirect)!=null&&s.linkMode){const r=global==null?void 0:global.Linking;if(typeof r<"u"){r.addEventListener("url",this.handleLinkModeMessage,this.client.name);const i=await r.getInitialURL();i&&setTimeout(()=>{this.handleLinkModeMessage({url:i})},50)}}}),N(this,"shouldSetTVF",(s,r)=>{if(!r||s!=="wc_sessionRequest")return!1;const{request:i}=r;return Object.keys(Mc).includes(i.method)}),N(this,"getTVFParams",(s,r,i)=>{var n,o;try{const a=r.request.method,c=this.extractTxHashesFromResult(a,i);return et(ve({correlationId:s,rpcMethods:[a],chainId:r.chainId},this.isValidContractData(r.request.params)&&{contractAddresses:[(o=(n=r.request.params)==null?void 0:n[0])==null?void 0:o.to]}),{txHashes:c})}catch(a){this.client.logger.warn("Error getting TVF params",a)}return{}}),N(this,"isValidContractData",s=>{var r;if(!s)return!1;try{const i=(s==null?void 0:s.data)||((r=s==null?void 0:s[0])==null?void 0:r.data);if(!i.startsWith("0x"))return!1;const n=i.slice(2);return/^[0-9a-fA-F]*$/.test(n)?n.length%2===0:!1}catch{}return!1}),N(this,"extractTxHashesFromResult",(s,r)=>{try{const i=Mc[s];if(typeof r=="string")return[r];const n=r[i.key];if(Cs(n))return s==="solana_signAllTransactions"?n.map(o=>Sp(o)):n;if(typeof n=="string")return[n]}catch(i){this.client.logger.warn("Error extracting tx hashes from result",i)}return[]})}async processPendingMessageEvents(){try{const e=this.client.session.keys,s=this.client.core.relayer.messages.getWithoutAck(e);for(const[r,i]of Object.entries(s))for(const n of i)try{await this.onProviderMessageEvent({topic:r,message:n,publishedAt:Date.now()})}catch{this.client.logger.warn(`Error processing pending message event for topic: ${r}, message: ${n}`)}}catch(e){this.client.logger.warn("processPendingMessageEvents failed",e)}}isInitialized(){if(!this.initialized){const{message:e}=R("NOT_INITIALIZED",this.name);throw new Error(e)}}async confirmOnlineStateOrThrow(){await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(je.message,e=>{this.onProviderMessageEvent(e)})}async onRelayMessage(e){const{topic:s,message:r,attestation:i,transportType:n}=e,{publicKey:o}=this.client.auth.authKeys.keys.includes(sn)?this.client.auth.authKeys.get(sn):{publicKey:void 0};try{const a=await this.client.core.crypto.decode(s,r,{receiverPublicKey:o,encoding:n===Ne.link_mode?ms:Dt});Fo(a)?(this.client.core.history.set(s,a),await this.onRelayEventRequest({topic:s,payload:a,attestation:i,transportType:n,encryptedId:Ht(r)})):Wo(a)?(await this.client.core.history.resolve(a),await this.onRelayEventResponse({topic:s,payload:a,transportType:n}),this.client.core.history.delete(s,a.id)):await this.onRelayEventUnknownPayload({topic:s,payload:a,transportType:n}),await this.client.core.relayer.messages.ack(s,r)}catch(a){this.client.logger.error(a)}}registerExpirerEvents(){this.client.core.expirer.on(_t.expired,async e=>{const{topic:s,id:r}=Tl(e.target);if(r&&this.client.pendingRequest.keys.includes(r))return await this.deletePendingSessionRequest(r,R("EXPIRED"),!0);if(r&&this.client.auth.requests.keys.includes(r))return await this.deletePendingAuthRequest(r,R("EXPIRED"),!0);s?this.client.session.keys.includes(s)&&(await this.deleteSession({topic:s,expirerHasDeleted:!0}),this.client.events.emit("session_expire",{topic:s})):r&&(await this.deleteProposal(r,!0),this.client.events.emit("proposal_expire",{id:r}))})}registerPairingEvents(){this.client.core.pairing.events.on(Ls.create,e=>this.onPairingCreated(e)),this.client.core.pairing.events.on(Ls.delete,e=>{this.addToRecentlyDeleted(e.topic,"pairing")})}isValidPairingTopic(e){if(!$e(e,!1)){const{message:s}=R("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(s)}if(!this.client.core.pairing.pairings.keys.includes(e)){const{message:s}=R("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(s)}if(gs(this.client.core.pairing.pairings.get(e).expiry)){const{message:s}=R("EXPIRED",`pairing topic: ${e}`);throw new Error(s)}}async isValidSessionTopic(e){if(!$e(e,!1)){const{message:s}=R("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw new Error(s)}if(this.checkRecentlyDeleted(e),!this.client.session.keys.includes(e)){const{message:s}=R("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(s)}if(gs(this.client.session.get(e).expiry)){await this.deleteSession({topic:e});const{message:s}=R("EXPIRED",`session topic: ${e}`);throw new Error(s)}if(!this.client.core.crypto.keychain.has(e)){const{message:s}=R("MISSING_OR_INVALID",`session topic does not exist in keychain: ${e}`);throw await this.deleteSession({topic:e}),new Error(s)}}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($e(e,!1)){const{message:s}=R("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(s)}else{const{message:s}=R("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(s)}}async isValidProposalId(e){if(!Qg(e)){const{message:s}=R("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(s)}if(!this.client.proposal.keys.includes(e)){const{message:s}=R("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(s)}if(gs(this.client.proposal.get(e).expiryTimestamp)){await this.deleteProposal(e);const{message:s}=R("EXPIRED",`proposal id: ${e}`);throw new Error(s)}}}class gv extends er{constructor(e,s){super(e,s,Qb,Xo),this.core=e,this.logger=s}}let mv=class extends er{constructor(e,s){super(e,s,ev,Xo),this.core=e,this.logger=s}};class wv extends er{constructor(e,s){super(e,s,sv,Xo,r=>r.id),this.core=e,this.logger=s}}class yv extends er{constructor(e,s){super(e,s,ov,Nn,()=>sn),this.core=e,this.logger=s}}class bv extends er{constructor(e,s){super(e,s,av,Nn),this.core=e,this.logger=s}}class vv extends er{constructor(e,s){super(e,s,cv,Nn,r=>r.id),this.core=e,this.logger=s}}var Ev=Object.defineProperty,Cv=(t,e,s)=>e in t?Ev(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Yn=(t,e,s)=>Cv(t,typeof e!="symbol"?e+"":e,s);class Iv{constructor(e,s){this.core=e,this.logger=s,Yn(this,"authKeys"),Yn(this,"pairingTopics"),Yn(this,"requests"),this.authKeys=new yv(this.core,this.logger),this.pairingTopics=new bv(this.core,this.logger),this.requests=new vv(this.core,this.logger)}async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init()}}var Av=Object.defineProperty,Nv=(t,e,s)=>e in t?Av(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,ne=(t,e,s)=>Nv(t,typeof e!="symbol"?e+"":e,s);let _v=class kh extends Nd{constructor(e){super(e),ne(this,"protocol",Ph),ne(this,"version",Oh),ne(this,"name",Gn.name),ne(this,"metadata"),ne(this,"core"),ne(this,"logger"),ne(this,"events",new Ys.EventEmitter),ne(this,"engine"),ne(this,"session"),ne(this,"proposal"),ne(this,"pendingRequest"),ne(this,"auth"),ne(this,"signConfig"),ne(this,"on",(r,i)=>this.events.on(r,i)),ne(this,"once",(r,i)=>this.events.once(r,i)),ne(this,"off",(r,i)=>this.events.off(r,i)),ne(this,"removeListener",(r,i)=>this.events.removeListener(r,i)),ne(this,"removeAllListeners",r=>this.events.removeAllListeners(r)),ne(this,"connect",async r=>{try{return await this.engine.connect(r)}catch(i){throw this.logger.error(i.message),i}}),ne(this,"pair",async r=>{try{return await this.engine.pair(r)}catch(i){throw this.logger.error(i.message),i}}),ne(this,"approve",async r=>{try{return await this.engine.approve(r)}catch(i){throw this.logger.error(i.message),i}}),ne(this,"reject",async r=>{try{return await this.engine.reject(r)}catch(i){throw this.logger.error(i.message),i}}),ne(this,"update",async r=>{try{return await this.engine.update(r)}catch(i){throw this.logger.error(i.message),i}}),ne(this,"extend",async r=>{try{return await this.engine.extend(r)}catch(i){throw this.logger.error(i.message),i}}),ne(this,"request",async r=>{try{return await this.engine.request(r)}catch(i){throw this.logger.error(i.message),i}}),ne(this,"respond",async r=>{try{return await this.engine.respond(r)}catch(i){throw this.logger.error(i.message),i}}),ne(this,"ping",async r=>{try{return await this.engine.ping(r)}catch(i){throw this.logger.error(i.message),i}}),ne(this,"emit",async r=>{try{return await this.engine.emit(r)}catch(i){throw this.logger.error(i.message),i}}),ne(this,"disconnect",async r=>{try{return await this.engine.disconnect(r)}catch(i){throw this.logger.error(i.message),i}}),ne(this,"find",r=>{try{return this.engine.find(r)}catch(i){throw this.logger.error(i.message),i}}),ne(this,"getPendingSessionRequests",()=>{try{return this.engine.getPendingSessionRequests()}catch(r){throw this.logger.error(r.message),r}}),ne(this,"authenticate",async(r,i)=>{try{return await this.engine.authenticate(r,i)}catch(n){throw this.logger.error(n.message),n}}),ne(this,"formatAuthMessage",r=>{try{return this.engine.formatAuthMessage(r)}catch(i){throw this.logger.error(i.message),i}}),ne(this,"approveSessionAuthenticate",async r=>{try{return await this.engine.approveSessionAuthenticate(r)}catch(i){throw this.logger.error(i.message),i}}),ne(this,"rejectSessionAuthenticate",async r=>{try{return await this.engine.rejectSessionAuthenticate(r)}catch(i){throw this.logger.error(i.message),i}}),this.name=(e==null?void 0:e.name)||Gn.name,this.metadata=qd(e==null?void 0:e.metadata),this.signConfig=e==null?void 0:e.signConfig;const s=typeof(e==null?void 0:e.logger)<"u"&&typeof(e==null?void 0:e.logger)!="string"?e.logger:jo(Si({level:(e==null?void 0:e.logger)||Gn.logger}));this.core=(e==null?void 0:e.core)||new Xb(e),this.logger=st(s,this.name),this.session=new mv(this.core,this.logger),this.proposal=new gv(this.core,this.logger),this.pendingRequest=new wv(this.core,this.logger),this.engine=new fv(this),this.auth=new Iv(this.core,this.logger)}static async init(e){const s=new kh(e);return await s.initialize(),s}get context(){return bt(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()},U.toMiliseconds(U.ONE_SECOND))}catch(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}};const qc="error",Sv="wss://relay.walletconnect.org",Pv="wc",Ov="universal_provider",Ki=`${Pv}@2:${Ov}:`,$h="https://rpc.walletconnect.org/v1/",br="generic",Tv=`${$h}bundler`,Ot={DEFAULT_CHAIN_CHANGED:"default_chain_changed"};function kv(){}function Qo(t){return t==null||typeof t!="object"&&typeof t!="function"}function ea(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function $v(t){if(Qo(t))return t;if(Array.isArray(t)||ea(t)||t instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer)return t.slice(0);const e=Object.getPrototypeOf(t),s=e.constructor;if(t instanceof Date||t instanceof Map||t instanceof Set)return new s(t);if(t instanceof RegExp){const r=new s(t);return r.lastIndex=t.lastIndex,r}if(t instanceof DataView)return new s(t.buffer.slice(0));if(t instanceof Error){const r=new s(t.message);return r.stack=t.stack,r.name=t.name,r.cause=t.cause,r}if(typeof File<"u"&&t instanceof File)return new s([t],t.name,{type:t.type,lastModified:t.lastModified});if(typeof t=="object"){const r=Object.create(e);return Object.assign(r,t)}return t}function jc(t){return typeof t=="object"&&t!==null}function xh(t){return Object.getOwnPropertySymbols(t).filter(e=>Object.prototype.propertyIsEnumerable.call(t,e))}function Rh(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const xv="[object RegExp]",Uh="[object String]",Dh="[object Number]",Lh="[object Boolean]",Mh="[object Arguments]",Rv="[object Symbol]",Uv="[object Date]",Dv="[object Map]",Lv="[object Set]",Mv="[object Array]",Bv="[object ArrayBuffer]",qv="[object Object]",jv="[object DataView]",Fv="[object Uint8Array]",Wv="[object Uint8ClampedArray]",zv="[object Uint16Array]",Hv="[object Uint32Array]",Vv="[object Int8Array]",Kv="[object Int16Array]",Gv="[object Int32Array]",Jv="[object Float32Array]",Yv="[object Float64Array]";function Zv(t,e){return Nr(t,void 0,t,new Map,e)}function Nr(t,e,s,r=new Map,i=void 0){const n=i==null?void 0:i(t,e,s,r);if(n!=null)return n;if(Qo(t))return t;if(r.has(t))return r.get(t);if(Array.isArray(t)){const o=new Array(t.length);r.set(t,o);for(let a=0;a<t.length;a++)o[a]=Nr(t[a],a,s,r,i);return Object.hasOwn(t,"index")&&(o.index=t.index),Object.hasOwn(t,"input")&&(o.input=t.input),o}if(t instanceof Date)return new Date(t.getTime());if(t instanceof RegExp){const o=new RegExp(t.source,t.flags);return o.lastIndex=t.lastIndex,o}if(t instanceof Map){const o=new Map;r.set(t,o);for(const[a,c]of t)o.set(a,Nr(c,a,s,r,i));return o}if(t instanceof Set){const o=new Set;r.set(t,o);for(const a of t)o.add(Nr(a,void 0,s,r,i));return o}if(typeof Buffer<"u"&&Buffer.isBuffer(t))return t.subarray();if(ea(t)){const o=new(Object.getPrototypeOf(t)).constructor(t.length);r.set(t,o);for(let a=0;a<t.length;a++)o[a]=Nr(t[a],a,s,r,i);return o}if(t instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer)return t.slice(0);if(t instanceof DataView){const o=new DataView(t.buffer.slice(0),t.byteOffset,t.byteLength);return r.set(t,o),Ms(o,t,s,r,i),o}if(typeof File<"u"&&t instanceof File){const o=new File([t],t.name,{type:t.type});return r.set(t,o),Ms(o,t,s,r,i),o}if(t instanceof Blob){const o=new Blob([t],{type:t.type});return r.set(t,o),Ms(o,t,s,r,i),o}if(t instanceof Error){const o=new t.constructor;return r.set(t,o),o.message=t.message,o.name=t.name,o.stack=t.stack,o.cause=t.cause,Ms(o,t,s,r,i),o}if(typeof t=="object"&&Xv(t)){const o=Object.create(Object.getPrototypeOf(t));return r.set(t,o),Ms(o,t,s,r,i),o}return t}function Ms(t,e,s=t,r,i){const n=[...Object.keys(e),...xh(e)];for(let o=0;o<n.length;o++){const a=n[o],c=Object.getOwnPropertyDescriptor(t,a);(c==null||c.writable)&&(t[a]=Nr(e[a],a,s,r,i))}}function Xv(t){switch(Rh(t)){case Mh:case Mv:case Bv:case jv:case Lh:case Uv:case Jv:case Yv:case Vv:case Kv:case Gv:case Dv:case Dh:case qv:case xv:case Lv:case Uh:case Rv:case Fv:case Wv:case zv:case Hv:return!0;default:return!1}}function Qv(t,e){return Zv(t,(s,r,i,n)=>{if(typeof t=="object")switch(Object.prototype.toString.call(t)){case Dh:case Uh:case Lh:{const o=new t.constructor(t==null?void 0:t.valueOf());return Ms(o,t),o}case Mh:{const o={};return Ms(o,t),o.length=t.length,o[Symbol.iterator]=t[Symbol.iterator],o}default:return}})}function Fc(t){return Qv(t)}function Wc(t){return t!==null&&typeof t=="object"&&Rh(t)==="[object Arguments]"}function e0(t){return ea(t)}function t0(t){var s;if(typeof t!="object"||t==null)return!1;if(Object.getPrototypeOf(t)===null)return!0;if(Object.prototype.toString.call(t)!=="[object Object]"){const r=t[Symbol.toStringTag];return r==null||!((s=Object.getOwnPropertyDescriptor(t,Symbol.toStringTag))!=null&&s.writable)?!1:t.toString()===`[object ${r}]`}let e=t;for(;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}function s0(t,...e){const s=e.slice(0,-1),r=e[e.length-1];let i=t;for(let n=0;n<s.length;n++){const o=s[n];i=Uo(i,o,r,new Map)}return i}function Uo(t,e,s,r){if(Qo(t)&&(t=Object(t)),e==null||typeof e!="object")return t;if(r.has(e))return $v(r.get(e));if(r.set(e,t),Array.isArray(e)){e=e.slice();for(let n=0;n<e.length;n++)e[n]=e[n]??void 0}const i=[...Object.keys(e),...xh(e)];for(let n=0;n<i.length;n++){const o=i[n];let a=e[o],c=t[o];if(Wc(a)&&(a={...a}),Wc(c)&&(c={...c}),typeof Buffer<"u"&&Buffer.isBuffer(a)&&(a=Fc(a)),Array.isArray(a))if(typeof c=="object"&&c!=null){const h=[],u=Reflect.ownKeys(c);for(let d=0;d<u.length;d++){const g=u[d];h[g]=c[g]}c=h}else c=[];const l=s(c,a,o,t,e,r);l!=null?t[o]=l:Array.isArray(a)||jc(c)&&jc(a)?t[o]=Uo(c,a,s,r):c==null&&t0(a)?t[o]=Uo({},a,s,r):c==null&&e0(a)?t[o]=Fc(a):(c===void 0||a!==void 0)&&(t[o]=a)}return t}function r0(t,...e){return s0(t,...e,kv)}var i0=Object.defineProperty,n0=Object.defineProperties,o0=Object.getOwnPropertyDescriptors,zc=Object.getOwnPropertySymbols,a0=Object.prototype.hasOwnProperty,c0=Object.prototype.propertyIsEnumerable,Hc=(t,e,s)=>e in t?i0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Gi=(t,e)=>{for(var s in e||(e={}))a0.call(e,s)&&Hc(t,s,e[s]);if(zc)for(var s of zc(e))c0.call(e,s)&&Hc(t,s,e[s]);return t},l0=(t,e)=>n0(t,o0(e));function yt(t,e,s){var r;const i=_r(t);return((r=e.rpcMap)==null?void 0:r[i.reference])||`${$h}?chainId=${i.namespace}:${i.reference}&projectId=${s}`}function tr(t){return t.includes(":")?t.split(":")[1]:t}function Bh(t){return t.map(e=>`${e.split(":")[0]}:${e.split(":")[1]}`)}function h0(t,e){const s=Object.keys(e.namespaces).filter(i=>i.includes(t));if(!s.length)return[];const r=[];return s.forEach(i=>{const n=e.namespaces[i].accounts;r.push(...n)}),r}function Ji(t={},e={}){const s=Vc(t),r=Vc(e);return r0(s,r)}function Vc(t){var e,s,r,i,n;const o={};if(!Is(t))return o;for(const[a,c]of Object.entries(t)){const l=In(a)?[a]:c.chains,h=c.methods||[],u=c.events||[],d=c.rpcMap||{},g=Ar(a);o[g]=l0(Gi(Gi({},o[g]),c),{chains:Kt(l,(e=o[g])==null?void 0:e.chains),methods:Kt(h,(s=o[g])==null?void 0:s.methods),events:Kt(u,(r=o[g])==null?void 0:r.events)}),(Is(d)||Is(((i=o[g])==null?void 0:i.rpcMap)||{}))&&(o[g].rpcMap=Gi(Gi({},d),(n=o[g])==null?void 0:n.rpcMap))}return o}function Kc(t){return t.includes(":")?t.split(":")[2]:t}function Gc(t){const e={};for(const[s,r]of Object.entries(t)){const i=r.methods||[],n=r.events||[],o=r.accounts||[],a=In(s)?[s]:r.chains?r.chains:Bh(r.accounts);e[s]={chains:a,methods:i,events:n,accounts:o}}return e}function Zn(t){return typeof t=="number"?t:t.includes("0x")?parseInt(t,16):(t=t.includes(":")?t.split(":")[1]:t,isNaN(Number(t))?t:Number(t))}const qh={},he=t=>qh[t],Xn=(t,e)=>{qh[t]=e};var u0=Object.defineProperty,d0=(t,e,s)=>e in t?u0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,ar=(t,e,s)=>d0(t,typeof e!="symbol"?e+"":e,s);class p0{constructor(e){ar(this,"name","polkadot"),ar(this,"client"),ar(this,"httpProviders"),ar(this,"events"),ar(this,"namespace"),ar(this,"chainId"),this.namespace=e.namespace,this.events=he("events"),this.client=he("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,s){this.httpProviders[e]||this.setHttpProvider(e,s),this.chainId=e,this.events.emit(Ot.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(s=>s.split(":")[1]===this.chainId.toString()).map(s=>s.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(s=>{var r;const i=tr(s);e[i]=this.createHttpProvider(i,(r=this.namespace.rpcMap)==null?void 0:r[s])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,s=this.httpProviders[e];if(typeof s>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return s}setHttpProvider(e,s){const r=this.createHttpProvider(e,s);r&&(this.httpProviders[e]=r)}createHttpProvider(e,s){const r=s||yt(e,this.namespace,this.client.core.projectId);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);return new Pt(new Lt(r,he("disableProviderPing")))}}var f0=Object.defineProperty,g0=Object.defineProperties,m0=Object.getOwnPropertyDescriptors,Jc=Object.getOwnPropertySymbols,w0=Object.prototype.hasOwnProperty,y0=Object.prototype.propertyIsEnumerable,Do=(t,e,s)=>e in t?f0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Yc=(t,e)=>{for(var s in e||(e={}))w0.call(e,s)&&Do(t,s,e[s]);if(Jc)for(var s of Jc(e))y0.call(e,s)&&Do(t,s,e[s]);return t},Zc=(t,e)=>g0(t,m0(e)),cr=(t,e,s)=>Do(t,typeof e!="symbol"?e+"":e,s);class b0{constructor(e){cr(this,"name","eip155"),cr(this,"client"),cr(this,"chainId"),cr(this,"namespace"),cr(this,"httpProviders"),cr(this,"events"),this.namespace=e.namespace,this.events=he("events"),this.client=he("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain())}async request(e){switch(e.request.method){case"eth_requestAccounts":return this.getAccounts();case"eth_accounts":return this.getAccounts();case"wallet_switchEthereumChain":return await this.handleSwitchChain(e);case"eth_chainId":return parseInt(this.getDefaultChain());case"wallet_getCapabilities":return await this.getCapabilities(e);case"wallet_getCallsStatus":return await this.getCallStatus(e)}return this.namespace.methods.includes(e.request.method)?await this.client.request(e):this.getHttpProvider().request(e.request)}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}setDefaultChain(e,s){this.httpProviders[e]||this.setHttpProvider(parseInt(e),s),this.chainId=parseInt(e),this.events.emit(Ot.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}createHttpProvider(e,s){const r=s||yt(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);return new Pt(new Lt(r,he("disableProviderPing")))}setHttpProvider(e,s){const r=this.createHttpProvider(e,s);r&&(this.httpProviders[e]=r)}createHttpProviders(){const e={};return this.namespace.chains.forEach(s=>{var r;const i=parseInt(tr(s));e[i]=this.createHttpProvider(i,(r=this.namespace.rpcMap)==null?void 0:r[s])}),e}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(s=>s.split(":")[1]===this.chainId.toString()).map(s=>s.split(":")[2]))]:[]}getHttpProvider(){const e=this.chainId,s=this.httpProviders[e];if(typeof s>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return s}async handleSwitchChain(e){var s,r;let i=e.request.params?(s=e.request.params[0])==null?void 0:s.chainId:"0x0";i=i.startsWith("0x")?i:`0x${i}`;const n=parseInt(i,16);if(this.isChainApproved(n))this.setDefaultChain(`${n}`);else if(this.namespace.methods.includes("wallet_switchEthereumChain"))await this.client.request({topic:e.topic,request:{method:e.request.method,params:[{chainId:i}]},chainId:(r=this.namespace.chains)==null?void 0:r[0]}),this.setDefaultChain(`${n}`);else throw new Error(`Failed to switch to chain 'eip155:${n}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);return null}isChainApproved(e){return this.namespace.chains.includes(`${this.name}:${e}`)}async getCapabilities(e){var s,r,i,n,o;const a=(r=(s=e.request)==null?void 0:s.params)==null?void 0:r[0],c=((n=(i=e.request)==null?void 0:i.params)==null?void 0:n[1])||[],l=`${a}${c.join(",")}`;if(!a)throw new Error("Missing address parameter in `wallet_getCapabilities` request");const h=this.client.session.get(e.topic),u=((o=h==null?void 0:h.sessionProperties)==null?void 0:o.capabilities)||{};if(u!=null&&u[l])return u==null?void 0:u[l];const d=await this.client.request(e);try{await this.client.session.update(e.topic,{sessionProperties:Zc(Yc({},h.sessionProperties||{}),{capabilities:Zc(Yc({},u||{}),{[l]:d})})})}catch(g){console.warn("Failed to update session with capabilities",g)}return d}async getCallStatus(e){var s,r;const i=this.client.session.get(e.topic),n=(s=i.sessionProperties)==null?void 0:s.bundler_name;if(n){const a=this.getBundlerUrl(e.chainId,n);try{return await this.getUserOperationReceipt(a,e)}catch(c){console.warn("Failed to fetch call status from bundler",c,a)}}const o=(r=i.sessionProperties)==null?void 0:r.bundler_url;if(o)try{return await this.getUserOperationReceipt(o,e)}catch(a){console.warn("Failed to fetch call status from custom bundler",a,o)}if(this.namespace.methods.includes(e.request.method))return await this.client.request(e);throw new Error("Fetching call status not approved by the wallet.")}async getUserOperationReceipt(e,s){var r;const i=new URL(e),n=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Bs("eth_getUserOperationReceipt",[(r=s.request.params)==null?void 0:r[0]]))});if(!n.ok)throw new Error(`Failed to fetch user operation receipt - ${n.status}`);return await n.json()}getBundlerUrl(e,s){return`${Tv}?projectId=${this.client.core.projectId}&chainId=${e}&bundler=${s}`}}var v0=Object.defineProperty,E0=(t,e,s)=>e in t?v0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,lr=(t,e,s)=>E0(t,typeof e!="symbol"?e+"":e,s);class C0{constructor(e){lr(this,"name","solana"),lr(this,"client"),lr(this,"httpProviders"),lr(this,"events"),lr(this,"namespace"),lr(this,"chainId"),this.namespace=e.namespace,this.events=he("events"),this.client=he("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,s){this.httpProviders[e]||this.setHttpProvider(e,s),this.chainId=e,this.events.emit(Ot.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(s=>s.split(":")[1]===this.chainId.toString()).map(s=>s.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(s=>{var r;const i=tr(s);e[i]=this.createHttpProvider(i,(r=this.namespace.rpcMap)==null?void 0:r[s])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,s=this.httpProviders[e];if(typeof s>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return s}setHttpProvider(e,s){const r=this.createHttpProvider(e,s);r&&(this.httpProviders[e]=r)}createHttpProvider(e,s){const r=s||yt(e,this.namespace,this.client.core.projectId);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);return new Pt(new Lt(r,he("disableProviderPing")))}}var I0=Object.defineProperty,A0=(t,e,s)=>e in t?I0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,hr=(t,e,s)=>A0(t,typeof e!="symbol"?e+"":e,s);class N0{constructor(e){hr(this,"name","cosmos"),hr(this,"client"),hr(this,"httpProviders"),hr(this,"events"),hr(this,"namespace"),hr(this,"chainId"),this.namespace=e.namespace,this.events=he("events"),this.client=he("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,s){this.httpProviders[e]||this.setHttpProvider(e,s),this.chainId=e,this.events.emit(Ot.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(s=>s.split(":")[1]===this.chainId.toString()).map(s=>s.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(s=>{var r;const i=tr(s);e[i]=this.createHttpProvider(i,(r=this.namespace.rpcMap)==null?void 0:r[s])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,s=this.httpProviders[e];if(typeof s>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return s}setHttpProvider(e,s){const r=this.createHttpProvider(e,s);r&&(this.httpProviders[e]=r)}createHttpProvider(e,s){const r=s||yt(e,this.namespace,this.client.core.projectId);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);return new Pt(new Lt(r,he("disableProviderPing")))}}var _0=Object.defineProperty,S0=(t,e,s)=>e in t?_0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,ur=(t,e,s)=>S0(t,typeof e!="symbol"?e+"":e,s);class P0{constructor(e){ur(this,"name","algorand"),ur(this,"client"),ur(this,"httpProviders"),ur(this,"events"),ur(this,"namespace"),ur(this,"chainId"),this.namespace=e.namespace,this.events=he("events"),this.client=he("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,s){if(!this.httpProviders[e]){const r=s||yt(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,r)}this.chainId=e,this.events.emit(Ot.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(s=>s.split(":")[1]===this.chainId.toString()).map(s=>s.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(s=>{var r;e[s]=this.createHttpProvider(s,(r=this.namespace.rpcMap)==null?void 0:r[s])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,s=this.httpProviders[e];if(typeof s>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return s}setHttpProvider(e,s){const r=this.createHttpProvider(e,s);r&&(this.httpProviders[e]=r)}createHttpProvider(e,s){const r=s||yt(e,this.namespace,this.client.core.projectId);return typeof r>"u"?void 0:new Pt(new Lt(r,he("disableProviderPing")))}}var O0=Object.defineProperty,T0=(t,e,s)=>e in t?O0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,dr=(t,e,s)=>T0(t,typeof e!="symbol"?e+"":e,s);class k0{constructor(e){dr(this,"name","cip34"),dr(this,"client"),dr(this,"httpProviders"),dr(this,"events"),dr(this,"namespace"),dr(this,"chainId"),this.namespace=e.namespace,this.events=he("events"),this.client=he("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,s){this.httpProviders[e]||this.setHttpProvider(e,s),this.chainId=e,this.events.emit(Ot.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(s=>s.split(":")[1]===this.chainId.toString()).map(s=>s.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(s=>{const r=this.getCardanoRPCUrl(s),i=tr(s);e[i]=this.createHttpProvider(i,r)}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,s=this.httpProviders[e];if(typeof s>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return s}getCardanoRPCUrl(e){const s=this.namespace.rpcMap;if(s)return s[e]}setHttpProvider(e,s){const r=this.createHttpProvider(e,s);r&&(this.httpProviders[e]=r)}createHttpProvider(e,s){const r=s||this.getCardanoRPCUrl(e);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);return new Pt(new Lt(r,he("disableProviderPing")))}}var $0=Object.defineProperty,x0=(t,e,s)=>e in t?$0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,pr=(t,e,s)=>x0(t,typeof e!="symbol"?e+"":e,s);class R0{constructor(e){pr(this,"name","elrond"),pr(this,"client"),pr(this,"httpProviders"),pr(this,"events"),pr(this,"namespace"),pr(this,"chainId"),this.namespace=e.namespace,this.events=he("events"),this.client=he("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,s){this.httpProviders[e]||this.setHttpProvider(e,s),this.chainId=e,this.events.emit(Ot.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(s=>s.split(":")[1]===this.chainId.toString()).map(s=>s.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(s=>{var r;const i=tr(s);e[i]=this.createHttpProvider(i,(r=this.namespace.rpcMap)==null?void 0:r[s])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,s=this.httpProviders[e];if(typeof s>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return s}setHttpProvider(e,s){const r=this.createHttpProvider(e,s);r&&(this.httpProviders[e]=r)}createHttpProvider(e,s){const r=s||yt(e,this.namespace,this.client.core.projectId);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);return new Pt(new Lt(r,he("disableProviderPing")))}}var U0=Object.defineProperty,D0=(t,e,s)=>e in t?U0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,fr=(t,e,s)=>D0(t,typeof e!="symbol"?e+"":e,s);class L0{constructor(e){fr(this,"name","multiversx"),fr(this,"client"),fr(this,"httpProviders"),fr(this,"events"),fr(this,"namespace"),fr(this,"chainId"),this.namespace=e.namespace,this.events=he("events"),this.client=he("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,s){this.httpProviders[e]||this.setHttpProvider(e,s),this.chainId=e,this.events.emit(Ot.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(s=>s.split(":")[1]===this.chainId.toString()).map(s=>s.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(s=>{var r;const i=tr(s);e[i]=this.createHttpProvider(i,(r=this.namespace.rpcMap)==null?void 0:r[s])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,s=this.httpProviders[e];if(typeof s>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return s}setHttpProvider(e,s){const r=this.createHttpProvider(e,s);r&&(this.httpProviders[e]=r)}createHttpProvider(e,s){const r=s||yt(e,this.namespace,this.client.core.projectId);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);return new Pt(new Lt(r,he("disableProviderPing")))}}var M0=Object.defineProperty,B0=(t,e,s)=>e in t?M0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,gr=(t,e,s)=>B0(t,typeof e!="symbol"?e+"":e,s);class q0{constructor(e){gr(this,"name","near"),gr(this,"client"),gr(this,"httpProviders"),gr(this,"events"),gr(this,"namespace"),gr(this,"chainId"),this.namespace=e.namespace,this.events=he("events"),this.client=he("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,s){if(this.chainId=e,!this.httpProviders[e]){const r=s||yt(`${this.name}:${e}`,this.namespace);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,r)}this.events.emit(Ot.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(s=>s.split(":")[1]===this.chainId.toString()).map(s=>s.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(s=>{var r;e[s]=this.createHttpProvider(s,(r=this.namespace.rpcMap)==null?void 0:r[s])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,s=this.httpProviders[e];if(typeof s>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return s}setHttpProvider(e,s){const r=this.createHttpProvider(e,s);r&&(this.httpProviders[e]=r)}createHttpProvider(e,s){const r=s||yt(e,this.namespace);return typeof r>"u"?void 0:new Pt(new Lt(r,he("disableProviderPing")))}}var j0=Object.defineProperty,F0=(t,e,s)=>e in t?j0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,mr=(t,e,s)=>F0(t,typeof e!="symbol"?e+"":e,s);class W0{constructor(e){mr(this,"name","tezos"),mr(this,"client"),mr(this,"httpProviders"),mr(this,"events"),mr(this,"namespace"),mr(this,"chainId"),this.namespace=e.namespace,this.events=he("events"),this.client=he("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,s){if(this.chainId=e,!this.httpProviders[e]){const r=s||yt(`${this.name}:${e}`,this.namespace);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,r)}this.events.emit(Ot.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(s=>s.split(":")[1]===this.chainId.toString()).map(s=>s.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(s=>{e[s]=this.createHttpProvider(s)}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,s=this.httpProviders[e];if(typeof s>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return s}setHttpProvider(e,s){const r=this.createHttpProvider(e,s);r&&(this.httpProviders[e]=r)}createHttpProvider(e,s){const r=s||yt(e,this.namespace);return typeof r>"u"?void 0:new Pt(new Lt(r))}}var z0=Object.defineProperty,H0=(t,e,s)=>e in t?z0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,wr=(t,e,s)=>H0(t,typeof e!="symbol"?e+"":e,s);class V0{constructor(e){wr(this,"name",br),wr(this,"client"),wr(this,"httpProviders"),wr(this,"events"),wr(this,"namespace"),wr(this,"chainId"),this.namespace=e.namespace,this.events=he("events"),this.client=he("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace.chains=[...new Set((this.namespace.chains||[]).concat(e.chains||[]))],this.namespace.accounts=[...new Set((this.namespace.accounts||[]).concat(e.accounts||[]))],this.namespace.methods=[...new Set((this.namespace.methods||[]).concat(e.methods||[]))],this.namespace.events=[...new Set((this.namespace.events||[]).concat(e.events||[]))],this.httpProviders=this.createHttpProviders()}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider(e.chainId).request(e.request)}setDefaultChain(e,s){this.httpProviders[e]||this.setHttpProvider(e,s),this.chainId=e,this.events.emit(Ot.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(s=>s.split(":")[1]===this.chainId.toString()).map(s=>s.split(":")[2]))]:[]}createHttpProviders(){var e,s;const r={};return(s=(e=this.namespace)==null?void 0:e.accounts)==null||s.forEach(i=>{const n=_r(i);r[`${n.namespace}:${n.reference}`]=this.createHttpProvider(i)}),r}getHttpProvider(e){const s=this.httpProviders[e];if(typeof s>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return s}setHttpProvider(e,s){const r=this.createHttpProvider(e,s);r&&(this.httpProviders[e]=r)}createHttpProvider(e,s){const r=s||yt(e,this.namespace,this.client.core.projectId);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);return new Pt(new Lt(r,he("disableProviderPing")))}}var K0=Object.defineProperty,G0=Object.defineProperties,J0=Object.getOwnPropertyDescriptors,Xc=Object.getOwnPropertySymbols,Y0=Object.prototype.hasOwnProperty,Z0=Object.prototype.propertyIsEnumerable,Lo=(t,e,s)=>e in t?K0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Yi=(t,e)=>{for(var s in e||(e={}))Y0.call(e,s)&&Lo(t,s,e[s]);if(Xc)for(var s of Xc(e))Z0.call(e,s)&&Lo(t,s,e[s]);return t},Qn=(t,e)=>G0(t,J0(e)),At=(t,e,s)=>Lo(t,typeof e!="symbol"?e+"":e,s);let X0=class jh{constructor(e){At(this,"client"),At(this,"namespaces"),At(this,"optionalNamespaces"),At(this,"sessionProperties"),At(this,"scopedProperties"),At(this,"events",new qo),At(this,"rpcProviders",{}),At(this,"session"),At(this,"providerOpts"),At(this,"logger"),At(this,"uri"),At(this,"disableProviderPing",!1),this.providerOpts=e,this.logger=typeof(e==null?void 0:e.logger)<"u"&&typeof(e==null?void 0:e.logger)!="string"?e.logger:jo(Si({level:(e==null?void 0:e.logger)||qc})),this.disableProviderPing=(e==null?void 0:e.disableProviderPing)||!1}static async init(e){const s=new jh(e);return await s.initialize(),s}async request(e,s,r){const[i,n]=this.validateChain(s);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(i).request({request:Yi({},e),chainId:`${i}:${n}`,topic:this.session.topic,expiry:r})}sendAsync(e,s,r,i){const n=new Date().getTime();this.request(e,r,i).then(o=>s(null,mn(n,o))).catch(o=>s(o,void 0))}async enable(){if(!this.client)throw new Error("Sign Client not initialized");return this.session||await this.connect({namespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties,scopedProperties:this.scopedProperties}),await this.requestAccounts()}async disconnect(){var e;if(!this.session)throw new Error("Please call connect() before enable()");await this.client.disconnect({topic:(e=this.session)==null?void 0:e.topic,reason:we("USER_DISCONNECTED")}),await this.cleanup()}async connect(e){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces(e),await this.cleanupPendingPairings(),!e.skipPairing)return await this.pair(e.pairingTopic)}async authenticate(e,s){if(!this.client)throw new Error("Sign Client not initialized");this.setNamespaces(e),await this.cleanupPendingPairings();const{uri:r,response:i}=await this.client.authenticate(e,s);r&&(this.uri=r,this.events.emit("display_uri",r));const n=await i();if(this.session=n.session,this.session){const o=Gc(this.session.namespaces);this.namespaces=Ji(this.namespaces,o),await this.persist("namespaces",this.namespaces),this.onConnect()}return n}on(e,s){this.events.on(e,s)}once(e,s){this.events.once(e,s)}removeListener(e,s){this.events.removeListener(e,s)}off(e,s){this.events.off(e,s)}get isWalletConnect(){return!0}async pair(e){const{uri:s,approval:r}=await this.client.connect({pairingTopic:e,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties,scopedProperties:this.scopedProperties});s&&(this.uri=s,this.events.emit("display_uri",s));const i=await r();this.session=i;const n=Gc(i.namespaces);return this.namespaces=Ji(this.namespaces,n),await this.persist("namespaces",this.namespaces),await this.persist("optionalNamespaces",this.optionalNamespaces),this.onConnect(),this.session}setDefaultChain(e,s){try{if(!this.session)return;const[r,i]=this.validateChain(e),n=this.getProvider(r);n.name===br?n.setDefaultChain(`${r}:${i}`,s):n.setDefaultChain(i,s)}catch(r){if(!/Please call connect/.test(r.message))throw r}}async cleanupPendingPairings(e={}){this.logger.info("Cleaning up inactive pairings...");const s=this.client.pairing.getAll();if(Cs(s)){for(const r of s)e.deletePairings?this.client.core.expirer.set(r.topic,0):await this.client.core.relayer.subscriber.unsubscribe(r.topic);this.logger.info(`Inactive pairings cleared: ${s.length}`)}}abortPairingAttempt(){this.logger.warn("abortPairingAttempt is deprecated. This is now a no-op.")}async checkStorage(){this.namespaces=await this.getFromStore("namespaces")||{},this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.session&&this.createProviders()}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners()}async createClient(){var e,s;if(this.client=this.providerOpts.client||await _v.init({core:this.providerOpts.core,logger:this.providerOpts.logger||qc,relayUrl:this.providerOpts.relayUrl||Sv,projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,storage:this.providerOpts.storage,name:this.providerOpts.name,customStoragePrefix:this.providerOpts.customStoragePrefix,telemetryEnabled:this.providerOpts.telemetryEnabled}),this.providerOpts.session)try{this.session=this.client.session.get(this.providerOpts.session.topic)}catch(r){throw this.logger.error("Failed to get session",r),new Error(`The provided session: ${(s=(e=this.providerOpts)==null?void 0:e.session)==null?void 0:s.topic} doesn't exist in the Sign client`)}else{const r=this.client.session.getAll();this.session=r[0]}this.logger.trace("SignClient Initialized")}createProviders(){if(!this.client)throw new Error("Sign Client not initialized");if(!this.session)throw new Error("Session not initialized. Please call connect() before enable()");const e=[...new Set(Object.keys(this.session.namespaces).map(s=>Ar(s)))];Xn("client",this.client),Xn("events",this.events),Xn("disableProviderPing",this.disableProviderPing),e.forEach(s=>{if(!this.session)return;const r=h0(s,this.session),i=Bh(r),n=Ji(this.namespaces,this.optionalNamespaces),o=Qn(Yi({},n[s]),{accounts:r,chains:i});switch(s){case"eip155":this.rpcProviders[s]=new b0({namespace:o});break;case"algorand":this.rpcProviders[s]=new P0({namespace:o});break;case"solana":this.rpcProviders[s]=new C0({namespace:o});break;case"cosmos":this.rpcProviders[s]=new N0({namespace:o});break;case"polkadot":this.rpcProviders[s]=new p0({namespace:o});break;case"cip34":this.rpcProviders[s]=new k0({namespace:o});break;case"elrond":this.rpcProviders[s]=new R0({namespace:o});break;case"multiversx":this.rpcProviders[s]=new L0({namespace:o});break;case"near":this.rpcProviders[s]=new q0({namespace:o});break;case"tezos":this.rpcProviders[s]=new W0({namespace:o});break;default:this.rpcProviders[br]?this.rpcProviders[br].updateNamespace(o):this.rpcProviders[br]=new V0({namespace:o})}})}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",e=>{var s;const{topic:r}=e;r===((s=this.session)==null?void 0:s.topic)&&this.events.emit("session_ping",e)}),this.client.on("session_event",e=>{var s;const{params:r,topic:i}=e;if(i!==((s=this.session)==null?void 0:s.topic))return;const{event:n}=r;if(n.name==="accountsChanged"){const o=n.data;o&&Cs(o)&&this.events.emit("accountsChanged",o.map(Kc))}else if(n.name==="chainChanged"){const o=r.chainId,a=r.event.data,c=Ar(o),l=Zn(o)!==Zn(a)?`${c}:${Zn(a)}`:o;this.onChainChanged(l)}else this.events.emit(n.name,n.data);this.events.emit("session_event",e)}),this.client.on("session_update",({topic:e,params:s})=>{var r,i;if(e!==((r=this.session)==null?void 0:r.topic))return;const{namespaces:n}=s,o=(i=this.client)==null?void 0:i.session.get(e);this.session=Qn(Yi({},o),{namespaces:n}),this.onSessionUpdate(),this.events.emit("session_update",{topic:e,params:s})}),this.client.on("session_delete",async e=>{var s;e.topic===((s=this.session)==null?void 0:s.topic)&&(await this.cleanup(),this.events.emit("session_delete",e),this.events.emit("disconnect",Qn(Yi({},we("USER_DISCONNECTED")),{data:e.topic})))}),this.on(Ot.DEFAULT_CHAIN_CHANGED,e=>{this.onChainChanged(e,!0)})}getProvider(e){return this.rpcProviders[e]||this.rpcProviders[br]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach(e=>{var s;this.getProvider(e).updateNamespace((s=this.session)==null?void 0:s.namespaces[e])})}setNamespaces(e){const{namespaces:s={},optionalNamespaces:r={},sessionProperties:i,scopedProperties:n}=e;this.optionalNamespaces=Ji(s,r),this.sessionProperties=i,this.scopedProperties=n}validateChain(e){const[s,r]=(e==null?void 0:e.split(":"))||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[s,r];if(s&&!Object.keys(this.namespaces||{}).map(o=>Ar(o)).includes(s))throw new Error(`Namespace '${s}' is not configured. Please call connect() first with namespace config.`);if(s&&r)return[s,r];const i=Ar(Object.keys(this.namespaces)[0]),n=this.rpcProviders[i].getDefaultChain();return[i,n]}async requestAccounts(){const[e]=this.validateChain();return await this.getProvider(e).requestAccounts()}async onChainChanged(e,s=!1){if(!this.namespaces)return;const[r,i]=this.validateChain(e);if(!i)return;this.updateNamespaceChain(r,i),this.events.emit("chainChanged",i);const n=this.getProvider(r).getDefaultChain();s||this.getProvider(r).setDefaultChain(i),this.emitAccountsChangedOnChainChange({namespace:r,previousChainId:n,newChainId:e}),await this.persist("namespaces",this.namespaces)}emitAccountsChangedOnChainChange({namespace:e,previousChainId:s,newChainId:r}){var i,n;try{if(s===r)return;const o=(n=(i=this.session)==null?void 0:i.namespaces[e])==null?void 0:n.accounts;if(!o)return;const a=o.filter(c=>c.includes(`${r}:`)).map(Kc);if(!Cs(a))return;this.events.emit("accountsChanged",a)}catch(o){this.logger.warn("Failed to emit accountsChanged on chain change",o)}}updateNamespaceChain(e,s){if(!this.namespaces)return;const r=this.namespaces[e]?e:`${e}:${s}`,i={chains:[],methods:[],events:[],defaultChain:s};this.namespaces[r]?this.namespaces[r]&&(this.namespaces[r].defaultChain=s):this.namespaces[r]=i}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session})}async cleanup(){this.namespaces=void 0,this.optionalNamespaces=void 0,this.sessionProperties=void 0,await this.deleteFromStore("namespaces"),await this.deleteFromStore("optionalNamespaces"),await this.deleteFromStore("sessionProperties"),this.session=void 0,await this.cleanupPendingPairings({deletePairings:!0}),await this.cleanupStorage()}async persist(e,s){var r;const i=((r=this.session)==null?void 0:r.topic)||"";await this.client.core.storage.setItem(`${Ki}/${e}${i}`,s)}async getFromStore(e){var s;const r=((s=this.session)==null?void 0:s.topic)||"";return await this.client.core.storage.getItem(`${Ki}/${e}${r}`)}async deleteFromStore(e){var s;const r=((s=this.session)==null?void 0:s.topic)||"";await this.client.core.storage.removeItem(`${Ki}/${e}${r}`)}async cleanupStorage(){var e;try{if(((e=this.client)==null?void 0:e.session.length)>0)return;const s=await this.client.core.storage.getKeys();for(const r of s)r.startsWith(Ki)&&await this.client.core.storage.removeItem(r)}catch(s){this.logger.warn("Failed to cleanup storage",s)}}};const fi={getSIWX(){return O.state.siwx},async initializeIfEnabled(){var n;const t=O.state.siwx,e=p.getActiveCaipAddress();if(!(t&&e))return;const[s,r,i]=e.split(":");if(p.checkIfSupportedNetwork(s))try{if((await t.getSessions(`${s}:${r}`,i)).length)return;await We.open({view:"SIWXSignMessage"})}catch(o){console.error("SIWXUtil:initializeIfEnabled",o),Pe.sendEvent({type:"track",event:"SIWX_AUTH_ERROR",properties:this.getSIWXEventProperties()}),await((n=Y._getClient())==null?void 0:n.disconnect().catch(console.error)),re.reset("Connect"),Ut.showError("A problem occurred while trying initialize authentication")}},async requestSignMessage(){const t=O.state.siwx,e=Z.getPlainAddress(p.getActiveCaipAddress()),s=p.getActiveCaipNetwork(),r=Y._getClient();if(!t)throw new Error("SIWX is not enabled");if(!e)throw new Error("No ActiveCaipAddress found");if(!s)throw new Error("No ActiveCaipNetwork or client found");if(!r)throw new Error("No ConnectionController client found");try{const i=await t.createMessage({chainId:s.caipNetworkId,accountAddress:e}),n=i.toString();q.getConnectorId(s.chainNamespace)===z.CONNECTOR_ID.AUTH&&re.pushTransactionStack({});const a=await r.signMessage(n);await t.addSession({data:i,message:n,signature:a}),We.close(),Pe.sendEvent({type:"track",event:"SIWX_AUTH_SUCCESS",properties:this.getSIWXEventProperties()})}catch(i){const n=this.getSIWXEventProperties();(!We.state.open||re.state.view==="ApproveTransaction")&&await We.open({view:"SIWXSignMessage"}),n.isSmartAccount?Ut.showError("This application might not support Smart Accounts"):Ut.showError("Signature declined"),Pe.sendEvent({type:"track",event:"SIWX_AUTH_ERROR",properties:n}),console.error("SWIXUtil:requestSignMessage",i)}},async cancelSignMessage(){var t;try{const e=this.getSIWX();((t=e==null?void 0:e.getRequired)==null?void 0:t.call(e))?await Y.disconnect():We.close(),re.reset("Connect"),Pe.sendEvent({event:"CLICK_CANCEL_SIWX",type:"track",properties:this.getSIWXEventProperties()})}catch(e){console.error("SIWXUtil:cancelSignMessage",e)}},async getSessions(){const t=O.state.siwx,e=Z.getPlainAddress(p.getActiveCaipAddress()),s=p.getActiveCaipNetwork();return t&&e&&s?t.getSessions(s.caipNetworkId,e):[]},async isSIWXCloseDisabled(){var e;const t=this.getSIWX();if(t){const s=re.state.view==="ApproveTransaction",r=re.state.view==="SIWXSignMessage";if(s||r)return((e=t.getRequired)==null?void 0:e.call(t))&&(await this.getSessions()).length===0}return!1},async universalProviderAuthenticate({universalProvider:t,chains:e,methods:s}){var a,c,l;const r=fi.getSIWX(),i=new Set(e.map(h=>h.split(":")[0]));if(!r||i.size!==1||!i.has("eip155"))return!1;const n=await r.createMessage({chainId:((a=p.getActiveCaipNetwork())==null?void 0:a.caipNetworkId)||"",accountAddress:""}),o=await t.authenticate({nonce:n.nonce,domain:n.domain,uri:n.uri,exp:n.expirationTime,iat:n.issuedAt,nbf:n.notBefore,requestId:n.requestId,version:n.version,resources:n.resources,statement:n.statement,chainId:n.chainId,methods:s,chains:[n.chainId,...e.filter(h=>h!==n.chainId)]});if(Ut.showLoading("Authenticating...",{autoClose:!1}),W.setConnectedWalletInfo({...o.session.peer.metadata,name:o.session.peer.metadata.name,icon:(c=o.session.peer.metadata.icons)==null?void 0:c[0],type:"WALLET_CONNECT"},Array.from(i)[0]),(l=o==null?void 0:o.auths)!=null&&l.length){const h=o.auths.map(u=>{const d=t.client.formatAuthMessage({request:u.p,iss:u.p.iss});return{data:{...u.p,accountAddress:u.p.iss.split(":").slice(-1).join(""),chainId:u.p.iss.split(":").slice(2,4).join(":"),uri:u.p.aud,version:u.p.version||n.version,expirationTime:u.p.exp,issuedAt:u.p.iat,notBefore:u.p.nbf},message:d,signature:u.s.s,cacao:u}});try{await r.setSessions(h),Pe.sendEvent({type:"track",event:"SIWX_AUTH_SUCCESS",properties:fi.getSIWXEventProperties()})}catch(u){throw console.error("SIWX:universalProviderAuth - failed to set sessions",u),Pe.sendEvent({type:"track",event:"SIWX_AUTH_ERROR",properties:fi.getSIWXEventProperties()}),await t.disconnect().catch(console.error),u}finally{Ut.hide()}}return!0},getSIWXEventProperties(){var e,s;const t=p.state.activeChain;return{network:((e=p.state.activeCaipNetwork)==null?void 0:e.caipNetworkId)||"",isSmartAccount:((s=W.state.preferredAccountTypes)==null?void 0:s[t])===ci.ACCOUNT_TYPES.SMART_ACCOUNT}},async clearSessions(){const t=this.getSIWX();t&&await t.setSessions([])}};function Zi(t,e){return q.getConnectorId(t)===e}function Q0(t){const e=Array.from(p.state.chains.keys());let s=[];return t?(s.push([t,p.state.chains.get(t)]),Zi(t,z.CONNECTOR_ID.WALLET_CONNECT)?e.forEach(r=>{r!==t&&Zi(r,z.CONNECTOR_ID.WALLET_CONNECT)&&s.push([r,p.state.chains.get(r)])}):Zi(t,z.CONNECTOR_ID.AUTH)&&e.forEach(r=>{r!==t&&Zi(r,z.CONNECTOR_ID.AUTH)&&s.push([r,p.state.chains.get(r)])})):s=Array.from(p.state.chains.entries()),s}const ps={EIP155:"eip155",CONNECTOR_TYPE_WALLET_CONNECT:"WALLET_CONNECT",CONNECTOR_TYPE_INJECTED:"INJECTED",CONNECTOR_TYPE_ANNOUNCED:"ANNOUNCED"},pn={NetworkImageIds:{1:"ba0ba0cd-17c6-4806-ad93-f9d174f17900",42161:"3bff954d-5cb0-47a0-9a23-d20192e74600",43114:"30c46e53-e989-45fb-4549-be3bd4eb3b00",56:"93564157-2e8e-4ce7-81df-b264dbee9b00",250:"06b26297-fe0c-4733-5d6b-ffa5498aac00",10:"ab9c186a-c52f-464b-2906-ca59d760a400",137:"41d04d42-da3b-4453-8506-668cc0727900",5e3:"e86fae9b-b770-4eea-e520-150e12c81100",295:"6a97d510-cac8-4e58-c7ce-e8681b044c00",11155111:"e909ea0a-f92a-4512-c8fc-748044ea6800",84532:"a18a7ecd-e307-4360-4746-283182228e00",1301:"4eeea7ef-0014-4649-5d1d-07271a80f600",130:"2257980a-3463-48c6-cbac-a42d2a956e00",10143:"0a728e83-bacb-46db-7844-948f05434900",100:"02b53f6a-e3d4-479e-1cb4-21178987d100",9001:"f926ff41-260d-4028-635e-91913fc28e00",324:"b310f07f-4ef7-49f3-7073-2a0a39685800",314:"5a73b3dd-af74-424e-cae0-0de859ee9400",4689:"34e68754-e536-40da-c153-6ef2e7188a00",1088:"3897a66d-40b9-4833-162f-a2c90531c900",1284:"161038da-44ae-4ec7-1208-0ea569454b00",1285:"f1d73bb6-5450-4e18-38f7-fb6484264a00",7777777:"845c60df-d429-4991-e687-91ae45791600",42220:"ab781bbc-ccc6-418d-d32d-789b15da1f00",8453:"7289c336-3981-4081-c5f4-efc26ac64a00",1313161554:"3ff73439-a619-4894-9262-4470c773a100",2020:"b8101fc0-9c19-4b6f-ec65-f6dfff106e00",2021:"b8101fc0-9c19-4b6f-ec65-f6dfff106e00",80094:"e329c2c9-59b0-4a02-83e4-212ff3779900",2741:"fc2427d1-5af9-4a9c-8da5-6f94627cd900","5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp":"a1b58899-f671-4276-6a5e-56ca5bd59700","4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z":"a1b58899-f671-4276-6a5e-56ca5bd59700",EtWTRABZaYq6iMfeYKouRu166VU2xqa1:"a1b58899-f671-4276-6a5e-56ca5bd59700","000000000019d6689c085ae165831e93":"0b4838db-0161-4ffe-022d-532bf03dba00","000000000933ea01ad0ee984209779ba":"39354064-d79b-420b-065d-f980c4b78200"},ConnectorImageIds:{[z.CONNECTOR_ID.COINBASE]:"0c2840c3-5b04-4c44-9661-fbd4b49e1800",[z.CONNECTOR_ID.COINBASE_SDK]:"0c2840c3-5b04-4c44-9661-fbd4b49e1800",[z.CONNECTOR_ID.SAFE]:"461db637-8616-43ce-035a-d89b8a1d5800",[z.CONNECTOR_ID.LEDGER]:"54a1aa77-d202-4f8d-0fb2-5d2bb6db0300",[z.CONNECTOR_ID.WALLET_CONNECT]:"ef1a1fcf-7fe8-4d69-bd6d-fda1345b4400",[z.CONNECTOR_ID.INJECTED]:"07ba87ed-43aa-4adf-4540-9e6a2b9cae00"},ConnectorNamesMap:{[z.CONNECTOR_ID.INJECTED]:"Browser Wallet",[z.CONNECTOR_ID.WALLET_CONNECT]:"WalletConnect",[z.CONNECTOR_ID.COINBASE]:"Coinbase",[z.CONNECTOR_ID.COINBASE_SDK]:"Coinbase",[z.CONNECTOR_ID.LEDGER]:"Ledger",[z.CONNECTOR_ID.SAFE]:"Safe"}},ta={getCaipTokens(t){if(!t)return;const e={};return Object.entries(t).forEach(([s,r])=>{e[`${ps.EIP155}:${s}`]=r}),e},isLowerCaseMatch(t,e){return(t==null?void 0:t.toLowerCase())===(e==null?void 0:e.toLowerCase())}};new AbortController;const yr={UniversalProviderErrors:{UNAUTHORIZED_DOMAIN_NOT_ALLOWED:{message:"Unauthorized: origin not allowed",alertErrorKey:"INVALID_APP_CONFIGURATION"},JWT_VALIDATION_ERROR:{message:"JWT validation error: JWT Token is not yet valid",alertErrorKey:"JWT_TOKEN_NOT_VALID"},INVALID_KEY:{message:"Unauthorized: invalid key",alertErrorKey:"INVALID_PROJECT_ID"}},ALERT_ERRORS:{SWITCH_NETWORK_NOT_FOUND:{shortMessage:"Network Not Found",longMessage:"Network not found - please make sure it is included in 'networks' array in createAppKit function"},INVALID_APP_CONFIGURATION:{shortMessage:"Invalid App Configuration",longMessage:()=>`Origin ${eE()?window.origin:"unknown"} not found on Allowlist - update configuration on cloud.reown.com`},IFRAME_LOAD_FAILED:{shortMessage:"Network Error - Could not load embedded wallet",longMessage:()=>"There was an issue loading the embedded wallet. Please try again later."},IFRAME_REQUEST_TIMEOUT:{shortMessage:"Embedded Wallet Request Timed Out",longMessage:()=>"There was an issue doing the request to the embedded wallet. Please try again later."},UNVERIFIED_DOMAIN:{shortMessage:"Invalid App Configuration",longMessage:()=>"There was an issue loading the embedded wallet. Please verify that your domain is allowed at cloud.reown.com"},JWT_TOKEN_NOT_VALID:{shortMessage:"Session Expired",longMessage:"Invalid session found on UniversalProvider - please check your time settings and connect again"},INVALID_PROJECT_ID:{shortMessage:"Invalid App Configuration",longMessage:"Invalid Project ID - update configuration"},PROJECT_ID_NOT_CONFIGURED:{shortMessage:"Project ID Not Configured",longMessage:"Project ID Not Configured - update configuration on cloud.reown.com"}}};function eE(){return typeof window<"u"}const tE={createLogger(t,e="error"){const s=Si({level:e}),{logger:r}=wl({opts:s});return r.error=(...i)=>{for(const n of i)if(n instanceof Error){t(n,...i);return}t(void 0,...i)},r}},sE="rpc.walletconnect.org";function Qc(t,e){const s=new URL("https://rpc.walletconnect.org/v1/");return s.searchParams.set("chainId",t),s.searchParams.set("projectId",e),s.toString()}const eo=["near:mainnet","solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp","eip155:1101","eip155:56","eip155:42161","eip155:7777777","eip155:59144","eip155:324","solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1","eip155:5000","solana:4sgjmw1sunhzsxgspuhpqldx6wiyjntz","eip155:80084","eip155:5003","eip155:100","eip155:8453","eip155:42220","eip155:1313161555","eip155:17000","eip155:1","eip155:300","eip155:1313161554","eip155:1329","eip155:84532","eip155:421614","eip155:11155111","eip155:8217","eip155:43114","solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z","eip155:999999999","eip155:11155420","eip155:80002","eip155:97","eip155:43113","eip155:137","eip155:10","eip155:1301","bip122:000000000019d6689c085ae165831e93","bip122:000000000933ea01ad0ee984209779ba"],vr={extendRpcUrlWithProjectId(t,e){let s=!1;try{s=new URL(t).host===sE}catch{s=!1}if(s){const r=new URL(t);return r.searchParams.has("projectId")||r.searchParams.set("projectId",e),r.toString()}return t},isCaipNetwork(t){return"chainNamespace"in t&&"caipNetworkId"in t},getChainNamespace(t){return this.isCaipNetwork(t)?t.chainNamespace:z.CHAIN.EVM},getCaipNetworkId(t){return this.isCaipNetwork(t)?t.caipNetworkId:`${z.CHAIN.EVM}:${t.id}`},getDefaultRpcUrl(t,e,s){var i,n,o;const r=(o=(n=(i=t.rpcUrls)==null?void 0:i.default)==null?void 0:n.http)==null?void 0:o[0];return eo.includes(e)?Qc(e,s):r||""},extendCaipNetwork(t,{customNetworkImageUrls:e,projectId:s,customRpcUrls:r}){var d,g,w,f,m;const i=this.getChainNamespace(t),n=this.getCaipNetworkId(t),o=(d=t.rpcUrls.default.http)==null?void 0:d[0],a=this.getDefaultRpcUrl(t,n,s),c=((f=(w=(g=t==null?void 0:t.rpcUrls)==null?void 0:g.chainDefault)==null?void 0:w.http)==null?void 0:f[0])||o,l=((m=r==null?void 0:r[n])==null?void 0:m.map(y=>y.url))||[],h=[...l,a],u=[...l];return c&&!u.includes(c)&&u.push(c),{...t,chainNamespace:i,caipNetworkId:n,assets:{imageId:pn.NetworkImageIds[t.id],imageUrl:e==null?void 0:e[t.id]},rpcUrls:{...t.rpcUrls,default:{http:h},chainDefault:{http:u}}}},extendCaipNetworks(t,{customNetworkImageUrls:e,projectId:s,customRpcUrls:r}){return t.map(i=>vr.extendCaipNetwork(i,{customNetworkImageUrls:e,customRpcUrls:r,projectId:s}))},getViemTransport(t,e,s){var i,n,o;const r=[];return s==null||s.forEach(a=>{r.push(qi(a.url,a.config))}),eo.includes(t.caipNetworkId)&&r.push(qi(Qc(t.caipNetworkId,e),{fetchOptions:{headers:{"Content-Type":"text/plain"}}})),(o=(n=(i=t==null?void 0:t.rpcUrls)==null?void 0:i.default)==null?void 0:n.http)==null||o.forEach(a=>{r.push(qi(a))}),la(r)},extendWagmiTransports(t,e,s){if(eo.includes(t.caipNetworkId)){const r=this.getDefaultRpcUrl(t,t.caipNetworkId,e);return la([s,qi(r)])}return s},getUnsupportedNetwork(t){return{id:t.split(":")[1],caipNetworkId:t,name:z.UNSUPPORTED_NETWORK_NAME,chainNamespace:t.split(":")[0],nativeCurrency:{name:"",decimals:0,symbol:""},rpcUrls:{default:{http:[]}}}},getCaipNetworkFromStorage(t){var c;const e=F.getActiveCaipNetworkId(),s=p.getAllRequestedCaipNetworks(),r=Array.from(((c=p.state.chains)==null?void 0:c.keys())||[]),i=e==null?void 0:e.split(":")[0],n=i?r.includes(i):!1,o=s==null?void 0:s.find(l=>l.caipNetworkId===e);return n&&!o&&e?this.getUnsupportedNetwork(e):o||t||(s==null?void 0:s[0])}},fn={eip155:void 0,solana:void 0,polkadot:void 0,bip122:void 0,cosmos:void 0},at=_e({providers:{...fn},providerIds:{...fn}}),Se={state:at,subscribeKey(t,e){return Qe(at,t,e)},subscribe(t){return Xe(at,()=>{t(at)})},subscribeProviders(t){return Xe(at.providers,()=>t(at.providers))},setProvider(t,e){e&&(at.providers[t]=Hs(e))},getProvider(t){return at.providers[t]},setProviderId(t,e){e&&(at.providerIds[t]=e)},getProviderId(t){if(t)return at.providerIds[t]},reset(){at.providers={...fn},at.providerIds={...fn}},resetChain(t){at.providers[t]=void 0,at.providerIds[t]=void 0}},rE={VIEW_DIRECTION:{Next:"next",Prev:"prev"},DEFAULT_CONNECT_METHOD_ORDER:["email","social","wallet"],ANIMATION_DURATIONS:{HeaderText:120,ModalHeight:150,ViewTransition:150}},Mo={filterOutDuplicatesByRDNS(t){const e=O.state.enableEIP6963?q.state.connectors:[],s=F.getRecentWallets(),r=e.map(a=>{var c;return(c=a.info)==null?void 0:c.rdns}).filter(Boolean),i=s.map(a=>a.rdns).filter(Boolean),n=r.concat(i);if(n.includes("io.metamask.mobile")&&Z.isMobile()){const a=n.indexOf("io.metamask.mobile");n[a]="io.metamask"}return t.filter(a=>!n.includes(String(a==null?void 0:a.rdns)))},filterOutDuplicatesByIds(t){const e=q.state.connectors.filter(a=>a.type==="ANNOUNCED"||a.type==="INJECTED"),s=F.getRecentWallets(),r=e.map(a=>a.explorerId),i=s.map(a=>a.id),n=r.concat(i);return t.filter(a=>!n.includes(a==null?void 0:a.id))},filterOutDuplicateWallets(t){const e=this.filterOutDuplicatesByRDNS(t);return this.filterOutDuplicatesByIds(e)},markWalletsAsInstalled(t){const{connectors:e}=q.state,{featuredWalletIds:s}=O.state,r=e.filter(o=>o.type==="ANNOUNCED").reduce((o,a)=>{var c;return(c=a.info)!=null&&c.rdns&&(o[a.info.rdns]=!0),o},{});return t.map(o=>({...o,installed:!!o.rdns&&!!r[o.rdns??""]})).sort((o,a)=>{const c=Number(a.installed)-Number(o.installed);if(c!==0)return c;if(s!=null&&s.length){const l=s.indexOf(o.id),h=s.indexOf(a.id);if(l!==-1&&h!==-1)return l-h;if(l!==-1)return-1;if(h!==-1)return 1}return 0})},getConnectOrderMethod(t,e){var c;const s=(t==null?void 0:t.connectMethodsOrder)||((c=O.state.features)==null?void 0:c.connectMethodsOrder),r=e||q.state.connectors;if(s)return s;const{injected:i,announced:n}=rn.getConnectorsByType(r,V.state.recommended,V.state.featured),o=i.filter(rn.showConnector),a=n.filter(rn.showConnector);return o.length||a.length?["wallet","email","social"]:rE.DEFAULT_CONNECT_METHOD_ORDER},isExcluded(t){const e=!!t.rdns&&V.state.excludedWallets.some(r=>r.rdns===t.rdns),s=!!t.name&&V.state.excludedWallets.some(r=>ta.isLowerCaseMatch(r.name,t.name));return e||s}},rn={getConnectorsByType(t,e,s){const{customWallets:r}=O.state,i=F.getRecentWallets(),n=Mo.filterOutDuplicateWallets(e),o=Mo.filterOutDuplicateWallets(s),a=t.filter(u=>u.type==="MULTI_CHAIN"),c=t.filter(u=>u.type==="ANNOUNCED"),l=t.filter(u=>u.type==="INJECTED"),h=t.filter(u=>u.type==="EXTERNAL");return{custom:r,recent:i,external:h,multiChain:a,announced:c,injected:l,recommended:n,featured:o}},showConnector(t){var i;const e=(i=t.info)==null?void 0:i.rdns,s=!!e&&V.state.excludedWallets.some(n=>!!n.rdns&&n.rdns===e),r=!!t.name&&V.state.excludedWallets.some(n=>ta.isLowerCaseMatch(n.name,t.name));return!(t.type==="INJECTED"&&(t.name==="Browser Wallet"&&(!Z.isMobile()||Z.isMobile()&&!e&&!Y.checkInstalled())||s||r)||(t.type==="ANNOUNCED"||t.type==="EXTERNAL")&&(s||r))},getIsConnectedWithWC(){return Array.from(p.state.chains.values()).some(s=>q.getConnectorId(s.namespace)===z.CONNECTOR_ID.WALLET_CONNECT)},getConnectorTypeOrder({recommended:t,featured:e,custom:s,recent:r,announced:i,injected:n,multiChain:o,external:a,overriddenConnectors:c=(l=>(l=O.state.features)==null?void 0:l.connectorTypeOrder)()??[]}){const h=rn.getIsConnectedWithWC(),g=[{type:"walletConnect",isEnabled:O.state.enableWalletConnect&&!h},{type:"recent",isEnabled:r.length>0},{type:"injected",isEnabled:[...n,...i,...o].length>0},{type:"featured",isEnabled:e.length>0},{type:"custom",isEnabled:s&&s.length>0},{type:"external",isEnabled:a.length>0},{type:"recommended",isEnabled:t.length>0}].filter(y=>y.isEnabled),w=new Set(g.map(y=>y.type)),f=c.filter(y=>w.has(y)).map(y=>({type:y,isEnabled:!0})),m=g.filter(({type:y})=>!f.some(({type:E})=>E===y));return Array.from(new Set([...f,...m].map(({type:y})=>y)))}};/**
14
+ * @license
15
+ * Copyright 2019 Google LLC
16
+ * SPDX-License-Identifier: BSD-3-Clause
17
+ */const nn=globalThis,sa=nn.ShadowRoot&&(nn.ShadyCSS===void 0||nn.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,ra=Symbol(),el=new WeakMap;let Fh=class{constructor(e,s,r){if(this._$cssResult$=!0,r!==ra)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=s}get styleSheet(){let e=this.o;const s=this.t;if(sa&&e===void 0){const r=s!==void 0&&s.length===1;r&&(e=el.get(s)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),r&&el.set(s,e))}return e}toString(){return this.cssText}};const Nt=t=>new Fh(typeof t=="string"?t:t+"",void 0,ra),Sr=(t,...e)=>{const s=t.length===1?t[0]:e.reduce((r,i,n)=>r+(o=>{if(o._$cssResult$===!0)return o.cssText;if(typeof o=="number")return o;throw Error("Value passed to 'css' function must be a 'css' function result: "+o+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+t[n+1],t[0]);return new Fh(s,t,ra)},iE=(t,e)=>{if(sa)t.adoptedStyleSheets=e.map(s=>s instanceof CSSStyleSheet?s:s.styleSheet);else for(const s of e){const r=document.createElement("style"),i=nn.litNonce;i!==void 0&&r.setAttribute("nonce",i),r.textContent=s.cssText,t.appendChild(r)}},tl=sa?t=>t:t=>t instanceof CSSStyleSheet?(e=>{let s="";for(const r of e.cssRules)s+=r.cssText;return Nt(s)})(t):t;/**
18
+ * @license
19
+ * Copyright 2017 Google LLC
20
+ * SPDX-License-Identifier: BSD-3-Clause
21
+ */const{is:nE,defineProperty:oE,getOwnPropertyDescriptor:aE,getOwnPropertyNames:cE,getOwnPropertySymbols:lE,getPrototypeOf:hE}=Object,As=globalThis,sl=As.trustedTypes,uE=sl?sl.emptyScript:"",to=As.reactiveElementPolyfillSupport,gi=(t,e)=>t,Bo={toAttribute(t,e){switch(e){case Boolean:t=t?uE:null;break;case Object:case Array:t=t==null?t:JSON.stringify(t)}return t},fromAttribute(t,e){let s=t;switch(e){case Boolean:s=t!==null;break;case Number:s=t===null?null:Number(t);break;case Object:case Array:try{s=JSON.parse(t)}catch{s=null}}return s}},Wh=(t,e)=>!nE(t,e),rl={attribute:!0,type:String,converter:Bo,reflect:!1,useDefault:!1,hasChanged:Wh};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),As.litPropertyMetadata??(As.litPropertyMetadata=new WeakMap);let Er=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??(this.l=[])).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,s=rl){if(s.state&&(s.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((s=Object.create(s)).wrapped=!0),this.elementProperties.set(e,s),!s.noAccessor){const r=Symbol(),i=this.getPropertyDescriptor(e,r,s);i!==void 0&&oE(this.prototype,e,i)}}static getPropertyDescriptor(e,s,r){const{get:i,set:n}=aE(this.prototype,e)??{get(){return this[s]},set(o){this[s]=o}};return{get:i,set(o){const a=i==null?void 0:i.call(this);n==null||n.call(this,o),this.requestUpdate(e,a,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??rl}static _$Ei(){if(this.hasOwnProperty(gi("elementProperties")))return;const e=hE(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(gi("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(gi("properties"))){const s=this.properties,r=[...cE(s),...lE(s)];for(const i of r)this.createProperty(i,s[i])}const e=this[Symbol.metadata];if(e!==null){const s=litPropertyMetadata.get(e);if(s!==void 0)for(const[r,i]of s)this.elementProperties.set(r,i)}this._$Eh=new Map;for(const[s,r]of this.elementProperties){const i=this._$Eu(s,r);i!==void 0&&this._$Eh.set(i,s)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){const s=[];if(Array.isArray(e)){const r=new Set(e.flat(1/0).reverse());for(const i of r)s.unshift(tl(i))}else e!==void 0&&s.push(tl(e));return s}static _$Eu(e,s){const r=s.attribute;return r===!1?void 0:typeof r=="string"?r:typeof e=="string"?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var e;this._$ES=new Promise(s=>this.enableUpdating=s),this._$AL=new Map,this._$E_(),this.requestUpdate(),(e=this.constructor.l)==null||e.forEach(s=>s(this))}addController(e){var s;(this._$EO??(this._$EO=new Set)).add(e),this.renderRoot!==void 0&&this.isConnected&&((s=e.hostConnected)==null||s.call(e))}removeController(e){var s;(s=this._$EO)==null||s.delete(e)}_$E_(){const e=new Map,s=this.constructor.elementProperties;for(const r of s.keys())this.hasOwnProperty(r)&&(e.set(r,this[r]),delete this[r]);e.size>0&&(this._$Ep=e)}createRenderRoot(){const e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return iE(e,this.constructor.elementStyles),e}connectedCallback(){var e;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(e=this._$EO)==null||e.forEach(s=>{var r;return(r=s.hostConnected)==null?void 0:r.call(s)})}enableUpdating(e){}disconnectedCallback(){var e;(e=this._$EO)==null||e.forEach(s=>{var r;return(r=s.hostDisconnected)==null?void 0:r.call(s)})}attributeChangedCallback(e,s,r){this._$AK(e,r)}_$ET(e,s){var n;const r=this.constructor.elementProperties.get(e),i=this.constructor._$Eu(e,r);if(i!==void 0&&r.reflect===!0){const o=(((n=r.converter)==null?void 0:n.toAttribute)!==void 0?r.converter:Bo).toAttribute(s,r.type);this._$Em=e,o==null?this.removeAttribute(i):this.setAttribute(i,o),this._$Em=null}}_$AK(e,s){var n,o;const r=this.constructor,i=r._$Eh.get(e);if(i!==void 0&&this._$Em!==i){const a=r.getPropertyOptions(i),c=typeof a.converter=="function"?{fromAttribute:a.converter}:((n=a.converter)==null?void 0:n.fromAttribute)!==void 0?a.converter:Bo;this._$Em=i;const l=c.fromAttribute(s,a.type);this[i]=l??((o=this._$Ej)==null?void 0:o.get(i))??l,this._$Em=null}}requestUpdate(e,s,r,i=!1,n){var o;if(e!==void 0){const a=this.constructor;if(i===!1&&(n=this[e]),r??(r=a.getPropertyOptions(e)),!((r.hasChanged??Wh)(n,s)||r.useDefault&&r.reflect&&n===((o=this._$Ej)==null?void 0:o.get(e))&&!this.hasAttribute(a._$Eu(e,r))))return;this.C(e,s,r)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(e,s,{useDefault:r,reflect:i,wrapped:n},o){r&&!(this._$Ej??(this._$Ej=new Map)).has(e)&&(this._$Ej.set(e,o??s??this[e]),n!==!0||o!==void 0)||(this._$AL.has(e)||(this.hasUpdated||r||(s=void 0),this._$AL.set(e,s)),i===!0&&this._$Em!==e&&(this._$Eq??(this._$Eq=new Set)).add(e))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(s){Promise.reject(s)}const e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var r;if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(const[n,o]of this._$Ep)this[n]=o;this._$Ep=void 0}const i=this.constructor.elementProperties;if(i.size>0)for(const[n,o]of i){const{wrapped:a}=o,c=this[n];a!==!0||this._$AL.has(n)||c===void 0||this.C(n,void 0,o,c)}}let e=!1;const s=this._$AL;try{e=this.shouldUpdate(s),e?(this.willUpdate(s),(r=this._$EO)==null||r.forEach(i=>{var n;return(n=i.hostUpdate)==null?void 0:n.call(i)}),this.update(s)):this._$EM()}catch(i){throw e=!1,this._$EM(),i}e&&this._$AE(s)}willUpdate(e){}_$AE(e){var s;(s=this._$EO)==null||s.forEach(r=>{var i;return(i=r.hostUpdated)==null?void 0:i.call(r)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Eq&&(this._$Eq=this._$Eq.forEach(s=>this._$ET(s,this[s]))),this._$EM()}updated(e){}firstUpdated(e){}};Er.elementStyles=[],Er.shadowRootOptions={mode:"open"},Er[gi("elementProperties")]=new Map,Er[gi("finalized")]=new Map,to==null||to({ReactiveElement:Er}),(As.reactiveElementVersions??(As.reactiveElementVersions=[])).push("2.1.2");/**
22
+ * @license
23
+ * Copyright 2017 Google LLC
24
+ * SPDX-License-Identifier: BSD-3-Clause
25
+ */const mi=globalThis,il=t=>t,gn=mi.trustedTypes,nl=gn?gn.createPolicy("lit-html",{createHTML:t=>t}):void 0,zh="$lit$",ws=`lit$${Math.random().toFixed(9).slice(2)}$`,Hh="?"+ws,dE=`<${Hh}>`,Js=document,Ai=()=>Js.createComment(""),Ni=t=>t===null||typeof t!="object"&&typeof t!="function",ia=Array.isArray,pE=t=>ia(t)||typeof(t==null?void 0:t[Symbol.iterator])=="function",so=`[
26
+ \f\r]`,ei=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,ol=/-->/g,al=/>/g,$s=RegExp(`>|${so}(?:([^\\s"'>=/]+)(${so}*=${so}*(?:[^
27
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),cl=/'/g,ll=/"/g,Vh=/^(?:script|style|textarea|title)$/i,Kh=t=>(e,...s)=>({_$litType$:t,strings:e,values:s}),eC=Kh(1),tC=Kh(2),Mr=Symbol.for("lit-noChange"),Fe=Symbol.for("lit-nothing"),hl=new WeakMap,js=Js.createTreeWalker(Js,129);function Gh(t,e){if(!ia(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return nl!==void 0?nl.createHTML(e):e}const fE=(t,e)=>{const s=t.length-1,r=[];let i,n=e===2?"<svg>":e===3?"<math>":"",o=ei;for(let a=0;a<s;a++){const c=t[a];let l,h,u=-1,d=0;for(;d<c.length&&(o.lastIndex=d,h=o.exec(c),h!==null);)d=o.lastIndex,o===ei?h[1]==="!--"?o=ol:h[1]!==void 0?o=al:h[2]!==void 0?(Vh.test(h[2])&&(i=RegExp("</"+h[2],"g")),o=$s):h[3]!==void 0&&(o=$s):o===$s?h[0]===">"?(o=i??ei,u=-1):h[1]===void 0?u=-2:(u=o.lastIndex-h[2].length,l=h[1],o=h[3]===void 0?$s:h[3]==='"'?ll:cl):o===ll||o===cl?o=$s:o===ol||o===al?o=ei:(o=$s,i=void 0);const g=o===$s&&t[a+1].startsWith("/>")?" ":"";n+=o===ei?c+dE:u>=0?(r.push(l),c.slice(0,u)+zh+c.slice(u)+ws+g):c+ws+(u===-2?a:g)}return[Gh(t,n+(t[s]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),r]};class _i{constructor({strings:e,_$litType$:s},r){let i;this.parts=[];let n=0,o=0;const a=e.length-1,c=this.parts,[l,h]=fE(e,s);if(this.el=_i.createElement(l,r),js.currentNode=this.el.content,s===2||s===3){const u=this.el.content.firstChild;u.replaceWith(...u.childNodes)}for(;(i=js.nextNode())!==null&&c.length<a;){if(i.nodeType===1){if(i.hasAttributes())for(const u of i.getAttributeNames())if(u.endsWith(zh)){const d=h[o++],g=i.getAttribute(u).split(ws),w=/([.?@])?(.*)/.exec(d);c.push({type:1,index:n,name:w[2],strings:g,ctor:w[1]==="."?mE:w[1]==="?"?wE:w[1]==="@"?yE:_n}),i.removeAttribute(u)}else u.startsWith(ws)&&(c.push({type:6,index:n}),i.removeAttribute(u));if(Vh.test(i.tagName)){const u=i.textContent.split(ws),d=u.length-1;if(d>0){i.textContent=gn?gn.emptyScript:"";for(let g=0;g<d;g++)i.append(u[g],Ai()),js.nextNode(),c.push({type:2,index:++n});i.append(u[d],Ai())}}}else if(i.nodeType===8)if(i.data===Hh)c.push({type:2,index:n});else{let u=-1;for(;(u=i.data.indexOf(ws,u+1))!==-1;)c.push({type:7,index:n}),u+=ws.length-1}n++}}static createElement(e,s){const r=Js.createElement("template");return r.innerHTML=e,r}}function Br(t,e,s=t,r){var o,a;if(e===Mr)return e;let i=r!==void 0?(o=s._$Co)==null?void 0:o[r]:s._$Cl;const n=Ni(e)?void 0:e._$litDirective$;return(i==null?void 0:i.constructor)!==n&&((a=i==null?void 0:i._$AO)==null||a.call(i,!1),n===void 0?i=void 0:(i=new n(t),i._$AT(t,s,r)),r!==void 0?(s._$Co??(s._$Co=[]))[r]=i:s._$Cl=i),i!==void 0&&(e=Br(t,i._$AS(t,e.values),i,r)),e}class gE{constructor(e,s){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=s}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){const{el:{content:s},parts:r}=this._$AD,i=((e==null?void 0:e.creationScope)??Js).importNode(s,!0);js.currentNode=i;let n=js.nextNode(),o=0,a=0,c=r[0];for(;c!==void 0;){if(o===c.index){let l;c.type===2?l=new Li(n,n.nextSibling,this,e):c.type===1?l=new c.ctor(n,c.name,c.strings,this,e):c.type===6&&(l=new bE(n,this,e)),this._$AV.push(l),c=r[++a]}o!==(c==null?void 0:c.index)&&(n=js.nextNode(),o++)}return js.currentNode=Js,i}p(e){let s=0;for(const r of this._$AV)r!==void 0&&(r.strings!==void 0?(r._$AI(e,r,s),s+=r.strings.length-2):r._$AI(e[s])),s++}}class Li{get _$AU(){var e;return((e=this._$AM)==null?void 0:e._$AU)??this._$Cv}constructor(e,s,r,i){this.type=2,this._$AH=Fe,this._$AN=void 0,this._$AA=e,this._$AB=s,this._$AM=r,this.options=i,this._$Cv=(i==null?void 0:i.isConnected)??!0}get parentNode(){let e=this._$AA.parentNode;const s=this._$AM;return s!==void 0&&(e==null?void 0:e.nodeType)===11&&(e=s.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,s=this){e=Br(this,e,s),Ni(e)?e===Fe||e==null||e===""?(this._$AH!==Fe&&this._$AR(),this._$AH=Fe):e!==this._$AH&&e!==Mr&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):pE(e)?this.k(e):this._(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==Fe&&Ni(this._$AH)?this._$AA.nextSibling.data=e:this.T(Js.createTextNode(e)),this._$AH=e}$(e){var n;const{values:s,_$litType$:r}=e,i=typeof r=="number"?this._$AC(e):(r.el===void 0&&(r.el=_i.createElement(Gh(r.h,r.h[0]),this.options)),r);if(((n=this._$AH)==null?void 0:n._$AD)===i)this._$AH.p(s);else{const o=new gE(i,this),a=o.u(this.options);o.p(s),this.T(a),this._$AH=o}}_$AC(e){let s=hl.get(e.strings);return s===void 0&&hl.set(e.strings,s=new _i(e)),s}k(e){ia(this._$AH)||(this._$AH=[],this._$AR());const s=this._$AH;let r,i=0;for(const n of e)i===s.length?s.push(r=new Li(this.O(Ai()),this.O(Ai()),this,this.options)):r=s[i],r._$AI(n),i++;i<s.length&&(this._$AR(r&&r._$AB.nextSibling,i),s.length=i)}_$AR(e=this._$AA.nextSibling,s){var r;for((r=this._$AP)==null?void 0:r.call(this,!1,!0,s);e!==this._$AB;){const i=il(e).nextSibling;il(e).remove(),e=i}}setConnected(e){var s;this._$AM===void 0&&(this._$Cv=e,(s=this._$AP)==null||s.call(this,e))}}class _n{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,s,r,i,n){this.type=1,this._$AH=Fe,this._$AN=void 0,this.element=e,this.name=s,this._$AM=i,this.options=n,r.length>2||r[0]!==""||r[1]!==""?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=Fe}_$AI(e,s=this,r,i){const n=this.strings;let o=!1;if(n===void 0)e=Br(this,e,s,0),o=!Ni(e)||e!==this._$AH&&e!==Mr,o&&(this._$AH=e);else{const a=e;let c,l;for(e=n[0],c=0;c<n.length-1;c++)l=Br(this,a[r+c],s,c),l===Mr&&(l=this._$AH[c]),o||(o=!Ni(l)||l!==this._$AH[c]),l===Fe?e=Fe:e!==Fe&&(e+=(l??"")+n[c+1]),this._$AH[c]=l}o&&!i&&this.j(e)}j(e){e===Fe?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}}class mE extends _n{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===Fe?void 0:e}}class wE extends _n{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==Fe)}}class yE extends _n{constructor(e,s,r,i,n){super(e,s,r,i,n),this.type=5}_$AI(e,s=this){if((e=Br(this,e,s,0)??Fe)===Mr)return;const r=this._$AH,i=e===Fe&&r!==Fe||e.capture!==r.capture||e.once!==r.once||e.passive!==r.passive,n=e!==Fe&&(r===Fe||i);i&&this.element.removeEventListener(this.name,this,r),n&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var s;typeof this._$AH=="function"?this._$AH.call(((s=this.options)==null?void 0:s.host)??this.element,e):this._$AH.handleEvent(e)}}class bE{constructor(e,s,r){this.element=e,this.type=6,this._$AN=void 0,this._$AM=s,this.options=r}get _$AU(){return this._$AM._$AU}_$AI(e){Br(this,e)}}const ro=mi.litHtmlPolyfillSupport;ro==null||ro(_i,Li),(mi.litHtmlVersions??(mi.litHtmlVersions=[])).push("3.3.3");const vE=(t,e,s)=>{const r=(s==null?void 0:s.renderBefore)??e;let i=r._$litPart$;if(i===void 0){const n=(s==null?void 0:s.renderBefore)??null;r._$litPart$=i=new Li(e.insertBefore(Ai(),n),n,void 0,s??{})}return i._$AI(t),i};/**
28
+ * @license
29
+ * Copyright 2017 Google LLC
30
+ * SPDX-License-Identifier: BSD-3-Clause
31
+ */const Ws=globalThis;class on extends Er{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var s;const e=super.createRenderRoot();return(s=this.renderOptions).renderBefore??(s.renderBefore=e.firstChild),e}update(e){const s=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=vE(s,this.renderRoot,this.renderOptions)}connectedCallback(){var e;super.connectedCallback(),(e=this._$Do)==null||e.setConnected(!0)}disconnectedCallback(){var e;super.disconnectedCallback(),(e=this._$Do)==null||e.setConnected(!1)}render(){return Mr}}var fl;on._$litElement$=!0,on.finalized=!0,(fl=Ws.litElementHydrateSupport)==null||fl.call(Ws,{LitElement:on});const io=Ws.litElementPolyfillSupport;io==null||io({LitElement:on});(Ws.litElementVersions??(Ws.litElementVersions=[])).push("4.2.2");let wi,Ns,_s;function sC(t,e){wi=document.createElement("style"),Ns=document.createElement("style"),_s=document.createElement("style"),wi.textContent=Pr(t).core.cssText,Ns.textContent=Pr(t).dark.cssText,_s.textContent=Pr(t).light.cssText,document.head.appendChild(wi),document.head.appendChild(Ns),document.head.appendChild(_s),Jh(e)}function Jh(t){Ns&&_s&&(t==="light"?(Ns.removeAttribute("media"),_s.media="enabled"):(_s.removeAttribute("media"),Ns.media="enabled"))}function EE(t){wi&&Ns&&_s&&(wi.textContent=Pr(t).core.cssText,Ns.textContent=Pr(t).dark.cssText,_s.textContent=Pr(t).light.cssText)}function Pr(t){return{core:Sr`
32
+ @import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');
33
+ @keyframes w3m-shake {
34
+ 0% {
35
+ transform: scale(1) rotate(0deg);
36
+ }
37
+ 20% {
38
+ transform: scale(1) rotate(-1deg);
39
+ }
40
+ 40% {
41
+ transform: scale(1) rotate(1.5deg);
42
+ }
43
+ 60% {
44
+ transform: scale(1) rotate(-1.5deg);
45
+ }
46
+ 80% {
47
+ transform: scale(1) rotate(1deg);
48
+ }
49
+ 100% {
50
+ transform: scale(1) rotate(0deg);
51
+ }
52
+ }
53
+ @keyframes w3m-iframe-fade-out {
54
+ 0% {
55
+ opacity: 1;
56
+ }
57
+ 100% {
58
+ opacity: 0;
59
+ }
60
+ }
61
+ @keyframes w3m-iframe-zoom-in {
62
+ 0% {
63
+ transform: translateY(50px);
64
+ opacity: 0;
65
+ }
66
+ 100% {
67
+ transform: translateY(0px);
68
+ opacity: 1;
69
+ }
70
+ }
71
+ @keyframes w3m-iframe-zoom-in-mobile {
72
+ 0% {
73
+ transform: scale(0.95);
74
+ opacity: 0;
75
+ }
76
+ 100% {
77
+ transform: scale(1);
78
+ opacity: 1;
79
+ }
80
+ }
81
+ :root {
82
+ --w3m-modal-width: 360px;
83
+ --w3m-color-mix-strength: ${Nt(t!=null&&t["--w3m-color-mix-strength"]?`${t["--w3m-color-mix-strength"]}%`:"0%")};
84
+ --w3m-font-family: ${Nt((t==null?void 0:t["--w3m-font-family"])||"Inter, Segoe UI, Roboto, Oxygen, Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif;")};
85
+ --w3m-font-size-master: ${Nt((t==null?void 0:t["--w3m-font-size-master"])||"10px")};
86
+ --w3m-border-radius-master: ${Nt((t==null?void 0:t["--w3m-border-radius-master"])||"4px")};
87
+ --w3m-z-index: ${Nt((t==null?void 0:t["--w3m-z-index"])||999)};
88
+
89
+ --wui-font-family: var(--w3m-font-family);
90
+
91
+ --wui-font-size-mini: calc(var(--w3m-font-size-master) * 0.8);
92
+ --wui-font-size-micro: var(--w3m-font-size-master);
93
+ --wui-font-size-tiny: calc(var(--w3m-font-size-master) * 1.2);
94
+ --wui-font-size-small: calc(var(--w3m-font-size-master) * 1.4);
95
+ --wui-font-size-paragraph: calc(var(--w3m-font-size-master) * 1.6);
96
+ --wui-font-size-medium: calc(var(--w3m-font-size-master) * 1.8);
97
+ --wui-font-size-large: calc(var(--w3m-font-size-master) * 2);
98
+ --wui-font-size-title-6: calc(var(--w3m-font-size-master) * 2.2);
99
+ --wui-font-size-medium-title: calc(var(--w3m-font-size-master) * 2.4);
100
+ --wui-font-size-2xl: calc(var(--w3m-font-size-master) * 4);
101
+
102
+ --wui-border-radius-5xs: var(--w3m-border-radius-master);
103
+ --wui-border-radius-4xs: calc(var(--w3m-border-radius-master) * 1.5);
104
+ --wui-border-radius-3xs: calc(var(--w3m-border-radius-master) * 2);
105
+ --wui-border-radius-xxs: calc(var(--w3m-border-radius-master) * 3);
106
+ --wui-border-radius-xs: calc(var(--w3m-border-radius-master) * 4);
107
+ --wui-border-radius-s: calc(var(--w3m-border-radius-master) * 5);
108
+ --wui-border-radius-m: calc(var(--w3m-border-radius-master) * 7);
109
+ --wui-border-radius-l: calc(var(--w3m-border-radius-master) * 9);
110
+ --wui-border-radius-3xl: calc(var(--w3m-border-radius-master) * 20);
111
+
112
+ --wui-font-weight-light: 400;
113
+ --wui-font-weight-regular: 500;
114
+ --wui-font-weight-medium: 600;
115
+ --wui-font-weight-bold: 700;
116
+
117
+ --wui-letter-spacing-2xl: -1.6px;
118
+ --wui-letter-spacing-medium-title: -0.96px;
119
+ --wui-letter-spacing-title-6: -0.88px;
120
+ --wui-letter-spacing-large: -0.8px;
121
+ --wui-letter-spacing-medium: -0.72px;
122
+ --wui-letter-spacing-paragraph: -0.64px;
123
+ --wui-letter-spacing-small: -0.56px;
124
+ --wui-letter-spacing-tiny: -0.48px;
125
+ --wui-letter-spacing-micro: -0.2px;
126
+ --wui-letter-spacing-mini: -0.16px;
127
+
128
+ --wui-spacing-0: 0px;
129
+ --wui-spacing-4xs: 2px;
130
+ --wui-spacing-3xs: 4px;
131
+ --wui-spacing-xxs: 6px;
132
+ --wui-spacing-2xs: 7px;
133
+ --wui-spacing-xs: 8px;
134
+ --wui-spacing-1xs: 10px;
135
+ --wui-spacing-s: 12px;
136
+ --wui-spacing-m: 14px;
137
+ --wui-spacing-l: 16px;
138
+ --wui-spacing-2l: 18px;
139
+ --wui-spacing-xl: 20px;
140
+ --wui-spacing-xxl: 24px;
141
+ --wui-spacing-2xl: 32px;
142
+ --wui-spacing-3xl: 40px;
143
+ --wui-spacing-4xl: 90px;
144
+ --wui-spacing-5xl: 95px;
145
+
146
+ --wui-icon-box-size-xxs: 14px;
147
+ --wui-icon-box-size-xs: 20px;
148
+ --wui-icon-box-size-sm: 24px;
149
+ --wui-icon-box-size-md: 32px;
150
+ --wui-icon-box-size-mdl: 36px;
151
+ --wui-icon-box-size-lg: 40px;
152
+ --wui-icon-box-size-2lg: 48px;
153
+ --wui-icon-box-size-xl: 64px;
154
+
155
+ --wui-icon-size-inherit: inherit;
156
+ --wui-icon-size-xxs: 10px;
157
+ --wui-icon-size-xs: 12px;
158
+ --wui-icon-size-sm: 14px;
159
+ --wui-icon-size-md: 16px;
160
+ --wui-icon-size-mdl: 18px;
161
+ --wui-icon-size-lg: 20px;
162
+ --wui-icon-size-xl: 24px;
163
+ --wui-icon-size-xxl: 28px;
164
+
165
+ --wui-wallet-image-size-inherit: inherit;
166
+ --wui-wallet-image-size-sm: 40px;
167
+ --wui-wallet-image-size-md: 56px;
168
+ --wui-wallet-image-size-lg: 80px;
169
+
170
+ --wui-visual-size-size-inherit: inherit;
171
+ --wui-visual-size-sm: 40px;
172
+ --wui-visual-size-md: 55px;
173
+ --wui-visual-size-lg: 80px;
174
+
175
+ --wui-box-size-md: 100px;
176
+ --wui-box-size-lg: 120px;
177
+
178
+ --wui-ease-out-power-2: cubic-bezier(0, 0, 0.22, 1);
179
+ --wui-ease-out-power-1: cubic-bezier(0, 0, 0.55, 1);
180
+
181
+ --wui-ease-in-power-3: cubic-bezier(0.66, 0, 1, 1);
182
+ --wui-ease-in-power-2: cubic-bezier(0.45, 0, 1, 1);
183
+ --wui-ease-in-power-1: cubic-bezier(0.3, 0, 1, 1);
184
+
185
+ --wui-ease-inout-power-1: cubic-bezier(0.45, 0, 0.55, 1);
186
+
187
+ --wui-duration-lg: 200ms;
188
+ --wui-duration-md: 125ms;
189
+ --wui-duration-sm: 75ms;
190
+
191
+ --wui-path-network-sm: path(
192
+ 'M15.4 2.1a5.21 5.21 0 0 1 5.2 0l11.61 6.7a5.21 5.21 0 0 1 2.61 4.52v13.4c0 1.87-1 3.59-2.6 4.52l-11.61 6.7c-1.62.93-3.6.93-5.22 0l-11.6-6.7a5.21 5.21 0 0 1-2.61-4.51v-13.4c0-1.87 1-3.6 2.6-4.52L15.4 2.1Z'
193
+ );
194
+
195
+ --wui-path-network-md: path(
196
+ 'M43.4605 10.7248L28.0485 1.61089C25.5438 0.129705 22.4562 0.129705 19.9515 1.61088L4.53951 10.7248C2.03626 12.2051 0.5 14.9365 0.5 17.886V36.1139C0.5 39.0635 2.03626 41.7949 4.53951 43.2752L19.9515 52.3891C22.4562 53.8703 25.5438 53.8703 28.0485 52.3891L43.4605 43.2752C45.9637 41.7949 47.5 39.0635 47.5 36.114V17.8861C47.5 14.9365 45.9637 12.2051 43.4605 10.7248Z'
197
+ );
198
+
199
+ --wui-path-network-lg: path(
200
+ 'M78.3244 18.926L50.1808 2.45078C45.7376 -0.150261 40.2624 -0.150262 35.8192 2.45078L7.6756 18.926C3.23322 21.5266 0.5 26.3301 0.5 31.5248V64.4752C0.5 69.6699 3.23322 74.4734 7.6756 77.074L35.8192 93.5492C40.2624 96.1503 45.7376 96.1503 50.1808 93.5492L78.3244 77.074C82.7668 74.4734 85.5 69.6699 85.5 64.4752V31.5248C85.5 26.3301 82.7668 21.5266 78.3244 18.926Z'
201
+ );
202
+
203
+ --wui-width-network-sm: 36px;
204
+ --wui-width-network-md: 48px;
205
+ --wui-width-network-lg: 86px;
206
+
207
+ --wui-height-network-sm: 40px;
208
+ --wui-height-network-md: 54px;
209
+ --wui-height-network-lg: 96px;
210
+
211
+ --wui-icon-size-network-xs: 12px;
212
+ --wui-icon-size-network-sm: 16px;
213
+ --wui-icon-size-network-md: 24px;
214
+ --wui-icon-size-network-lg: 42px;
215
+
216
+ --wui-color-inherit: inherit;
217
+
218
+ --wui-color-inverse-100: #fff;
219
+ --wui-color-inverse-000: #000;
220
+
221
+ --wui-cover: rgba(20, 20, 20, 0.8);
222
+
223
+ --wui-color-modal-bg: var(--wui-color-modal-bg-base);
224
+
225
+ --wui-color-accent-100: var(--wui-color-accent-base-100);
226
+ --wui-color-accent-090: var(--wui-color-accent-base-090);
227
+ --wui-color-accent-080: var(--wui-color-accent-base-080);
228
+
229
+ --wui-color-success-100: var(--wui-color-success-base-100);
230
+ --wui-color-success-125: var(--wui-color-success-base-125);
231
+
232
+ --wui-color-warning-100: var(--wui-color-warning-base-100);
233
+
234
+ --wui-color-error-100: var(--wui-color-error-base-100);
235
+ --wui-color-error-125: var(--wui-color-error-base-125);
236
+
237
+ --wui-color-blue-100: var(--wui-color-blue-base-100);
238
+ --wui-color-blue-90: var(--wui-color-blue-base-90);
239
+
240
+ --wui-icon-box-bg-error-100: var(--wui-icon-box-bg-error-base-100);
241
+ --wui-icon-box-bg-blue-100: var(--wui-icon-box-bg-blue-base-100);
242
+ --wui-icon-box-bg-success-100: var(--wui-icon-box-bg-success-base-100);
243
+ --wui-icon-box-bg-inverse-100: var(--wui-icon-box-bg-inverse-base-100);
244
+
245
+ --wui-all-wallets-bg-100: var(--wui-all-wallets-bg-100);
246
+
247
+ --wui-avatar-border: var(--wui-avatar-border-base);
248
+
249
+ --wui-thumbnail-border: var(--wui-thumbnail-border-base);
250
+
251
+ --wui-wallet-button-bg: var(--wui-wallet-button-bg-base);
252
+
253
+ --wui-box-shadow-blue: var(--wui-color-accent-glass-020);
254
+ }
255
+
256
+ @supports (background: color-mix(in srgb, white 50%, black)) {
257
+ :root {
258
+ --wui-color-modal-bg: color-mix(
259
+ in srgb,
260
+ var(--w3m-color-mix) var(--w3m-color-mix-strength),
261
+ var(--wui-color-modal-bg-base)
262
+ );
263
+
264
+ --wui-box-shadow-blue: color-mix(in srgb, var(--wui-color-accent-100) 20%, transparent);
265
+
266
+ --wui-color-accent-100: color-mix(
267
+ in srgb,
268
+ var(--wui-color-accent-base-100) 100%,
269
+ transparent
270
+ );
271
+ --wui-color-accent-090: color-mix(
272
+ in srgb,
273
+ var(--wui-color-accent-base-100) 90%,
274
+ transparent
275
+ );
276
+ --wui-color-accent-080: color-mix(
277
+ in srgb,
278
+ var(--wui-color-accent-base-100) 80%,
279
+ transparent
280
+ );
281
+ --wui-color-accent-glass-090: color-mix(
282
+ in srgb,
283
+ var(--wui-color-accent-base-100) 90%,
284
+ transparent
285
+ );
286
+ --wui-color-accent-glass-080: color-mix(
287
+ in srgb,
288
+ var(--wui-color-accent-base-100) 80%,
289
+ transparent
290
+ );
291
+ --wui-color-accent-glass-020: color-mix(
292
+ in srgb,
293
+ var(--wui-color-accent-base-100) 20%,
294
+ transparent
295
+ );
296
+ --wui-color-accent-glass-015: color-mix(
297
+ in srgb,
298
+ var(--wui-color-accent-base-100) 15%,
299
+ transparent
300
+ );
301
+ --wui-color-accent-glass-010: color-mix(
302
+ in srgb,
303
+ var(--wui-color-accent-base-100) 10%,
304
+ transparent
305
+ );
306
+ --wui-color-accent-glass-005: color-mix(
307
+ in srgb,
308
+ var(--wui-color-accent-base-100) 5%,
309
+ transparent
310
+ );
311
+ --wui-color-accent-002: color-mix(
312
+ in srgb,
313
+ var(--wui-color-accent-base-100) 2%,
314
+ transparent
315
+ );
316
+
317
+ --wui-color-fg-100: color-mix(
318
+ in srgb,
319
+ var(--w3m-color-mix) var(--w3m-color-mix-strength),
320
+ var(--wui-color-fg-100)
321
+ );
322
+ --wui-color-fg-125: color-mix(
323
+ in srgb,
324
+ var(--w3m-color-mix) var(--w3m-color-mix-strength),
325
+ var(--wui-color-fg-125)
326
+ );
327
+ --wui-color-fg-150: color-mix(
328
+ in srgb,
329
+ var(--w3m-color-mix) var(--w3m-color-mix-strength),
330
+ var(--wui-color-fg-150)
331
+ );
332
+ --wui-color-fg-175: color-mix(
333
+ in srgb,
334
+ var(--w3m-color-mix) var(--w3m-color-mix-strength),
335
+ var(--wui-color-fg-175)
336
+ );
337
+ --wui-color-fg-200: color-mix(
338
+ in srgb,
339
+ var(--w3m-color-mix) var(--w3m-color-mix-strength),
340
+ var(--wui-color-fg-200)
341
+ );
342
+ --wui-color-fg-225: color-mix(
343
+ in srgb,
344
+ var(--w3m-color-mix) var(--w3m-color-mix-strength),
345
+ var(--wui-color-fg-225)
346
+ );
347
+ --wui-color-fg-250: color-mix(
348
+ in srgb,
349
+ var(--w3m-color-mix) var(--w3m-color-mix-strength),
350
+ var(--wui-color-fg-250)
351
+ );
352
+ --wui-color-fg-275: color-mix(
353
+ in srgb,
354
+ var(--w3m-color-mix) var(--w3m-color-mix-strength),
355
+ var(--wui-color-fg-275)
356
+ );
357
+ --wui-color-fg-300: color-mix(
358
+ in srgb,
359
+ var(--w3m-color-mix) var(--w3m-color-mix-strength),
360
+ var(--wui-color-fg-300)
361
+ );
362
+ --wui-color-fg-325: color-mix(
363
+ in srgb,
364
+ var(--w3m-color-mix) var(--w3m-color-mix-strength),
365
+ var(--wui-color-fg-325)
366
+ );
367
+ --wui-color-fg-350: color-mix(
368
+ in srgb,
369
+ var(--w3m-color-mix) var(--w3m-color-mix-strength),
370
+ var(--wui-color-fg-350)
371
+ );
372
+
373
+ --wui-color-bg-100: color-mix(
374
+ in srgb,
375
+ var(--w3m-color-mix) var(--w3m-color-mix-strength),
376
+ var(--wui-color-bg-100)
377
+ );
378
+ --wui-color-bg-125: color-mix(
379
+ in srgb,
380
+ var(--w3m-color-mix) var(--w3m-color-mix-strength),
381
+ var(--wui-color-bg-125)
382
+ );
383
+ --wui-color-bg-150: color-mix(
384
+ in srgb,
385
+ var(--w3m-color-mix) var(--w3m-color-mix-strength),
386
+ var(--wui-color-bg-150)
387
+ );
388
+ --wui-color-bg-175: color-mix(
389
+ in srgb,
390
+ var(--w3m-color-mix) var(--w3m-color-mix-strength),
391
+ var(--wui-color-bg-175)
392
+ );
393
+ --wui-color-bg-200: color-mix(
394
+ in srgb,
395
+ var(--w3m-color-mix) var(--w3m-color-mix-strength),
396
+ var(--wui-color-bg-200)
397
+ );
398
+ --wui-color-bg-225: color-mix(
399
+ in srgb,
400
+ var(--w3m-color-mix) var(--w3m-color-mix-strength),
401
+ var(--wui-color-bg-225)
402
+ );
403
+ --wui-color-bg-250: color-mix(
404
+ in srgb,
405
+ var(--w3m-color-mix) var(--w3m-color-mix-strength),
406
+ var(--wui-color-bg-250)
407
+ );
408
+ --wui-color-bg-275: color-mix(
409
+ in srgb,
410
+ var(--w3m-color-mix) var(--w3m-color-mix-strength),
411
+ var(--wui-color-bg-275)
412
+ );
413
+ --wui-color-bg-300: color-mix(
414
+ in srgb,
415
+ var(--w3m-color-mix) var(--w3m-color-mix-strength),
416
+ var(--wui-color-bg-300)
417
+ );
418
+ --wui-color-bg-325: color-mix(
419
+ in srgb,
420
+ var(--w3m-color-mix) var(--w3m-color-mix-strength),
421
+ var(--wui-color-bg-325)
422
+ );
423
+ --wui-color-bg-350: color-mix(
424
+ in srgb,
425
+ var(--w3m-color-mix) var(--w3m-color-mix-strength),
426
+ var(--wui-color-bg-350)
427
+ );
428
+
429
+ --wui-color-success-100: color-mix(
430
+ in srgb,
431
+ var(--w3m-color-mix) var(--w3m-color-mix-strength),
432
+ var(--wui-color-success-base-100)
433
+ );
434
+ --wui-color-success-125: color-mix(
435
+ in srgb,
436
+ var(--w3m-color-mix) var(--w3m-color-mix-strength),
437
+ var(--wui-color-success-base-125)
438
+ );
439
+
440
+ --wui-color-warning-100: color-mix(
441
+ in srgb,
442
+ var(--w3m-color-mix) var(--w3m-color-mix-strength),
443
+ var(--wui-color-warning-base-100)
444
+ );
445
+
446
+ --wui-color-error-100: color-mix(
447
+ in srgb,
448
+ var(--w3m-color-mix) var(--w3m-color-mix-strength),
449
+ var(--wui-color-error-base-100)
450
+ );
451
+ --wui-color-blue-100: color-mix(
452
+ in srgb,
453
+ var(--w3m-color-mix) var(--w3m-color-mix-strength),
454
+ var(--wui-color-blue-base-100)
455
+ );
456
+ --wui-color-blue-90: color-mix(
457
+ in srgb,
458
+ var(--w3m-color-mix) var(--w3m-color-mix-strength),
459
+ var(--wui-color-blue-base-90)
460
+ );
461
+ --wui-color-error-125: color-mix(
462
+ in srgb,
463
+ var(--w3m-color-mix) var(--w3m-color-mix-strength),
464
+ var(--wui-color-error-base-125)
465
+ );
466
+
467
+ --wui-icon-box-bg-error-100: color-mix(
468
+ in srgb,
469
+ var(--w3m-color-mix) var(--w3m-color-mix-strength),
470
+ var(--wui-icon-box-bg-error-base-100)
471
+ );
472
+ --wui-icon-box-bg-accent-100: color-mix(
473
+ in srgb,
474
+ var(--w3m-color-mix) var(--w3m-color-mix-strength),
475
+ var(--wui-icon-box-bg-blue-base-100)
476
+ );
477
+ --wui-icon-box-bg-success-100: color-mix(
478
+ in srgb,
479
+ var(--w3m-color-mix) var(--w3m-color-mix-strength),
480
+ var(--wui-icon-box-bg-success-base-100)
481
+ );
482
+ --wui-icon-box-bg-inverse-100: color-mix(
483
+ in srgb,
484
+ var(--w3m-color-mix) var(--w3m-color-mix-strength),
485
+ var(--wui-icon-box-bg-inverse-base-100)
486
+ );
487
+
488
+ --wui-all-wallets-bg-100: color-mix(
489
+ in srgb,
490
+ var(--w3m-color-mix) var(--w3m-color-mix-strength),
491
+ var(--wui-all-wallets-bg-100)
492
+ );
493
+
494
+ --wui-avatar-border: color-mix(
495
+ in srgb,
496
+ var(--w3m-color-mix) var(--w3m-color-mix-strength),
497
+ var(--wui-avatar-border-base)
498
+ );
499
+
500
+ --wui-thumbnail-border: color-mix(
501
+ in srgb,
502
+ var(--w3m-color-mix) var(--w3m-color-mix-strength),
503
+ var(--wui-thumbnail-border-base)
504
+ );
505
+
506
+ --wui-wallet-button-bg: color-mix(
507
+ in srgb,
508
+ var(--w3m-color-mix) var(--w3m-color-mix-strength),
509
+ var(--wui-wallet-button-bg-base)
510
+ );
511
+ }
512
+ }
513
+ `,light:Sr`
514
+ :root {
515
+ --w3m-color-mix: ${Nt((t==null?void 0:t["--w3m-color-mix"])||"#fff")};
516
+ --w3m-accent: ${Nt(ys(t,"dark")["--w3m-accent"])};
517
+ --w3m-default: #fff;
518
+
519
+ --wui-color-modal-bg-base: ${Nt(ys(t,"dark")["--w3m-background"])};
520
+ --wui-color-accent-base-100: var(--w3m-accent);
521
+
522
+ --wui-color-blueberry-100: hsla(230, 100%, 67%, 1);
523
+ --wui-color-blueberry-090: hsla(231, 76%, 61%, 1);
524
+ --wui-color-blueberry-080: hsla(230, 59%, 55%, 1);
525
+ --wui-color-blueberry-050: hsla(231, 100%, 70%, 0.1);
526
+
527
+ --wui-color-fg-100: #e4e7e7;
528
+ --wui-color-fg-125: #d0d5d5;
529
+ --wui-color-fg-150: #a8b1b1;
530
+ --wui-color-fg-175: #a8b0b0;
531
+ --wui-color-fg-200: #949e9e;
532
+ --wui-color-fg-225: #868f8f;
533
+ --wui-color-fg-250: #788080;
534
+ --wui-color-fg-275: #788181;
535
+ --wui-color-fg-300: #6e7777;
536
+ --wui-color-fg-325: #9a9a9a;
537
+ --wui-color-fg-350: #363636;
538
+
539
+ --wui-color-bg-100: #141414;
540
+ --wui-color-bg-125: #191a1a;
541
+ --wui-color-bg-150: #1e1f1f;
542
+ --wui-color-bg-175: #222525;
543
+ --wui-color-bg-200: #272a2a;
544
+ --wui-color-bg-225: #2c3030;
545
+ --wui-color-bg-250: #313535;
546
+ --wui-color-bg-275: #363b3b;
547
+ --wui-color-bg-300: #3b4040;
548
+ --wui-color-bg-325: #252525;
549
+ --wui-color-bg-350: #ffffff;
550
+
551
+ --wui-color-success-base-100: #26d962;
552
+ --wui-color-success-base-125: #30a46b;
553
+
554
+ --wui-color-warning-base-100: #f3a13f;
555
+
556
+ --wui-color-error-base-100: #f25a67;
557
+ --wui-color-error-base-125: #df4a34;
558
+
559
+ --wui-color-blue-base-100: rgba(102, 125, 255, 1);
560
+ --wui-color-blue-base-90: rgba(102, 125, 255, 0.9);
561
+
562
+ --wui-color-success-glass-001: rgba(38, 217, 98, 0.01);
563
+ --wui-color-success-glass-002: rgba(38, 217, 98, 0.02);
564
+ --wui-color-success-glass-005: rgba(38, 217, 98, 0.05);
565
+ --wui-color-success-glass-010: rgba(38, 217, 98, 0.1);
566
+ --wui-color-success-glass-015: rgba(38, 217, 98, 0.15);
567
+ --wui-color-success-glass-020: rgba(38, 217, 98, 0.2);
568
+ --wui-color-success-glass-025: rgba(38, 217, 98, 0.25);
569
+ --wui-color-success-glass-030: rgba(38, 217, 98, 0.3);
570
+ --wui-color-success-glass-060: rgba(38, 217, 98, 0.6);
571
+ --wui-color-success-glass-080: rgba(38, 217, 98, 0.8);
572
+
573
+ --wui-color-success-glass-reown-020: rgba(48, 164, 107, 0.2);
574
+
575
+ --wui-color-warning-glass-reown-020: rgba(243, 161, 63, 0.2);
576
+
577
+ --wui-color-error-glass-001: rgba(242, 90, 103, 0.01);
578
+ --wui-color-error-glass-002: rgba(242, 90, 103, 0.02);
579
+ --wui-color-error-glass-005: rgba(242, 90, 103, 0.05);
580
+ --wui-color-error-glass-010: rgba(242, 90, 103, 0.1);
581
+ --wui-color-error-glass-015: rgba(242, 90, 103, 0.15);
582
+ --wui-color-error-glass-020: rgba(242, 90, 103, 0.2);
583
+ --wui-color-error-glass-025: rgba(242, 90, 103, 0.25);
584
+ --wui-color-error-glass-030: rgba(242, 90, 103, 0.3);
585
+ --wui-color-error-glass-060: rgba(242, 90, 103, 0.6);
586
+ --wui-color-error-glass-080: rgba(242, 90, 103, 0.8);
587
+
588
+ --wui-color-error-glass-reown-020: rgba(223, 74, 52, 0.2);
589
+
590
+ --wui-color-gray-glass-001: rgba(255, 255, 255, 0.01);
591
+ --wui-color-gray-glass-002: rgba(255, 255, 255, 0.02);
592
+ --wui-color-gray-glass-005: rgba(255, 255, 255, 0.05);
593
+ --wui-color-gray-glass-010: rgba(255, 255, 255, 0.1);
594
+ --wui-color-gray-glass-015: rgba(255, 255, 255, 0.15);
595
+ --wui-color-gray-glass-020: rgba(255, 255, 255, 0.2);
596
+ --wui-color-gray-glass-025: rgba(255, 255, 255, 0.25);
597
+ --wui-color-gray-glass-030: rgba(255, 255, 255, 0.3);
598
+ --wui-color-gray-glass-060: rgba(255, 255, 255, 0.6);
599
+ --wui-color-gray-glass-080: rgba(255, 255, 255, 0.8);
600
+ --wui-color-gray-glass-090: rgba(255, 255, 255, 0.9);
601
+
602
+ --wui-color-dark-glass-100: rgba(42, 42, 42, 1);
603
+
604
+ --wui-icon-box-bg-error-base-100: #3c2426;
605
+ --wui-icon-box-bg-blue-base-100: #20303f;
606
+ --wui-icon-box-bg-success-base-100: #1f3a28;
607
+ --wui-icon-box-bg-inverse-base-100: #243240;
608
+
609
+ --wui-all-wallets-bg-100: #222b35;
610
+
611
+ --wui-avatar-border-base: #252525;
612
+
613
+ --wui-thumbnail-border-base: #252525;
614
+
615
+ --wui-wallet-button-bg-base: var(--wui-color-bg-125);
616
+
617
+ --w3m-card-embedded-shadow-color: rgb(17 17 18 / 25%);
618
+ }
619
+ `,dark:Sr`
620
+ :root {
621
+ --w3m-color-mix: ${Nt((t==null?void 0:t["--w3m-color-mix"])||"#000")};
622
+ --w3m-accent: ${Nt(ys(t,"light")["--w3m-accent"])};
623
+ --w3m-default: #000;
624
+
625
+ --wui-color-modal-bg-base: ${Nt(ys(t,"light")["--w3m-background"])};
626
+ --wui-color-accent-base-100: var(--w3m-accent);
627
+
628
+ --wui-color-blueberry-100: hsla(231, 100%, 70%, 1);
629
+ --wui-color-blueberry-090: hsla(231, 97%, 72%, 1);
630
+ --wui-color-blueberry-080: hsla(231, 92%, 74%, 1);
631
+
632
+ --wui-color-fg-100: #141414;
633
+ --wui-color-fg-125: #2d3131;
634
+ --wui-color-fg-150: #474d4d;
635
+ --wui-color-fg-175: #636d6d;
636
+ --wui-color-fg-200: #798686;
637
+ --wui-color-fg-225: #828f8f;
638
+ --wui-color-fg-250: #8b9797;
639
+ --wui-color-fg-275: #95a0a0;
640
+ --wui-color-fg-300: #9ea9a9;
641
+ --wui-color-fg-325: #9a9a9a;
642
+ --wui-color-fg-350: #d0d0d0;
643
+
644
+ --wui-color-bg-100: #ffffff;
645
+ --wui-color-bg-125: #f5fafa;
646
+ --wui-color-bg-150: #f3f8f8;
647
+ --wui-color-bg-175: #eef4f4;
648
+ --wui-color-bg-200: #eaf1f1;
649
+ --wui-color-bg-225: #e5eded;
650
+ --wui-color-bg-250: #e1e9e9;
651
+ --wui-color-bg-275: #dce7e7;
652
+ --wui-color-bg-300: #d8e3e3;
653
+ --wui-color-bg-325: #f3f3f3;
654
+ --wui-color-bg-350: #202020;
655
+
656
+ --wui-color-success-base-100: #26b562;
657
+ --wui-color-success-base-125: #30a46b;
658
+
659
+ --wui-color-warning-base-100: #f3a13f;
660
+
661
+ --wui-color-error-base-100: #f05142;
662
+ --wui-color-error-base-125: #df4a34;
663
+
664
+ --wui-color-blue-base-100: rgba(102, 125, 255, 1);
665
+ --wui-color-blue-base-90: rgba(102, 125, 255, 0.9);
666
+
667
+ --wui-color-success-glass-001: rgba(38, 181, 98, 0.01);
668
+ --wui-color-success-glass-002: rgba(38, 181, 98, 0.02);
669
+ --wui-color-success-glass-005: rgba(38, 181, 98, 0.05);
670
+ --wui-color-success-glass-010: rgba(38, 181, 98, 0.1);
671
+ --wui-color-success-glass-015: rgba(38, 181, 98, 0.15);
672
+ --wui-color-success-glass-020: rgba(38, 181, 98, 0.2);
673
+ --wui-color-success-glass-025: rgba(38, 181, 98, 0.25);
674
+ --wui-color-success-glass-030: rgba(38, 181, 98, 0.3);
675
+ --wui-color-success-glass-060: rgba(38, 181, 98, 0.6);
676
+ --wui-color-success-glass-080: rgba(38, 181, 98, 0.8);
677
+
678
+ --wui-color-success-glass-reown-020: rgba(48, 164, 107, 0.2);
679
+
680
+ --wui-color-warning-glass-reown-020: rgba(243, 161, 63, 0.2);
681
+
682
+ --wui-color-error-glass-001: rgba(240, 81, 66, 0.01);
683
+ --wui-color-error-glass-002: rgba(240, 81, 66, 0.02);
684
+ --wui-color-error-glass-005: rgba(240, 81, 66, 0.05);
685
+ --wui-color-error-glass-010: rgba(240, 81, 66, 0.1);
686
+ --wui-color-error-glass-015: rgba(240, 81, 66, 0.15);
687
+ --wui-color-error-glass-020: rgba(240, 81, 66, 0.2);
688
+ --wui-color-error-glass-025: rgba(240, 81, 66, 0.25);
689
+ --wui-color-error-glass-030: rgba(240, 81, 66, 0.3);
690
+ --wui-color-error-glass-060: rgba(240, 81, 66, 0.6);
691
+ --wui-color-error-glass-080: rgba(240, 81, 66, 0.8);
692
+
693
+ --wui-color-error-glass-reown-020: rgba(223, 74, 52, 0.2);
694
+
695
+ --wui-icon-box-bg-error-base-100: #f4dfdd;
696
+ --wui-icon-box-bg-blue-base-100: #d9ecfb;
697
+ --wui-icon-box-bg-success-base-100: #daf0e4;
698
+ --wui-icon-box-bg-inverse-base-100: #dcecfc;
699
+
700
+ --wui-all-wallets-bg-100: #e8f1fa;
701
+
702
+ --wui-avatar-border-base: #f3f4f4;
703
+
704
+ --wui-thumbnail-border-base: #eaefef;
705
+
706
+ --wui-wallet-button-bg-base: var(--wui-color-bg-125);
707
+
708
+ --wui-color-gray-glass-001: rgba(0, 0, 0, 0.01);
709
+ --wui-color-gray-glass-002: rgba(0, 0, 0, 0.02);
710
+ --wui-color-gray-glass-005: rgba(0, 0, 0, 0.05);
711
+ --wui-color-gray-glass-010: rgba(0, 0, 0, 0.1);
712
+ --wui-color-gray-glass-015: rgba(0, 0, 0, 0.15);
713
+ --wui-color-gray-glass-020: rgba(0, 0, 0, 0.2);
714
+ --wui-color-gray-glass-025: rgba(0, 0, 0, 0.25);
715
+ --wui-color-gray-glass-030: rgba(0, 0, 0, 0.3);
716
+ --wui-color-gray-glass-060: rgba(0, 0, 0, 0.6);
717
+ --wui-color-gray-glass-080: rgba(0, 0, 0, 0.8);
718
+ --wui-color-gray-glass-090: rgba(0, 0, 0, 0.9);
719
+
720
+ --wui-color-dark-glass-100: rgba(233, 233, 233, 1);
721
+
722
+ --w3m-card-embedded-shadow-color: rgb(224 225 233 / 25%);
723
+ }
724
+ `}}const rC=Sr`
725
+ *,
726
+ *::after,
727
+ *::before,
728
+ :host {
729
+ margin: 0;
730
+ padding: 0;
731
+ box-sizing: border-box;
732
+ font-style: normal;
733
+ text-rendering: optimizeSpeed;
734
+ -webkit-font-smoothing: antialiased;
735
+ -moz-osx-font-smoothing: grayscale;
736
+ -webkit-tap-highlight-color: transparent;
737
+ font-family: var(--wui-font-family);
738
+ backface-visibility: hidden;
739
+ }
740
+ `,iC=Sr`
741
+ button,
742
+ a {
743
+ cursor: pointer;
744
+ display: flex;
745
+ justify-content: center;
746
+ align-items: center;
747
+ position: relative;
748
+ transition:
749
+ color var(--wui-duration-lg) var(--wui-ease-out-power-1),
750
+ background-color var(--wui-duration-lg) var(--wui-ease-out-power-1),
751
+ border var(--wui-duration-lg) var(--wui-ease-out-power-1),
752
+ border-radius var(--wui-duration-lg) var(--wui-ease-out-power-1),
753
+ box-shadow var(--wui-duration-lg) var(--wui-ease-out-power-1);
754
+ will-change: background-color, color, border, box-shadow, border-radius;
755
+ outline: none;
756
+ border: none;
757
+ column-gap: var(--wui-spacing-3xs);
758
+ background-color: transparent;
759
+ text-decoration: none;
760
+ }
761
+
762
+ wui-flex {
763
+ transition: border-radius var(--wui-duration-lg) var(--wui-ease-out-power-1);
764
+ will-change: border-radius;
765
+ }
766
+
767
+ button:disabled > wui-wallet-image,
768
+ button:disabled > wui-all-wallets-image,
769
+ button:disabled > wui-network-image,
770
+ button:disabled > wui-image,
771
+ button:disabled > wui-transaction-visual,
772
+ button:disabled > wui-logo {
773
+ filter: grayscale(1);
774
+ }
775
+
776
+ @media (hover: hover) and (pointer: fine) {
777
+ button:hover:enabled {
778
+ background-color: var(--wui-color-gray-glass-005);
779
+ }
780
+
781
+ button:active:enabled {
782
+ background-color: var(--wui-color-gray-glass-010);
783
+ }
784
+ }
785
+
786
+ button:disabled > wui-icon-box {
787
+ opacity: 0.5;
788
+ }
789
+
790
+ input {
791
+ border: none;
792
+ outline: none;
793
+ appearance: none;
794
+ }
795
+ `,nC=Sr`
796
+ .wui-color-inherit {
797
+ color: var(--wui-color-inherit);
798
+ }
799
+
800
+ .wui-color-accent-100 {
801
+ color: var(--wui-color-accent-100);
802
+ }
803
+
804
+ .wui-color-error-100 {
805
+ color: var(--wui-color-error-100);
806
+ }
807
+
808
+ .wui-color-blue-100 {
809
+ color: var(--wui-color-blue-100);
810
+ }
811
+
812
+ .wui-color-blue-90 {
813
+ color: var(--wui-color-blue-90);
814
+ }
815
+
816
+ .wui-color-error-125 {
817
+ color: var(--wui-color-error-125);
818
+ }
819
+
820
+ .wui-color-success-100 {
821
+ color: var(--wui-color-success-100);
822
+ }
823
+
824
+ .wui-color-success-125 {
825
+ color: var(--wui-color-success-125);
826
+ }
827
+
828
+ .wui-color-inverse-100 {
829
+ color: var(--wui-color-inverse-100);
830
+ }
831
+
832
+ .wui-color-inverse-000 {
833
+ color: var(--wui-color-inverse-000);
834
+ }
835
+
836
+ .wui-color-fg-100 {
837
+ color: var(--wui-color-fg-100);
838
+ }
839
+
840
+ .wui-color-fg-200 {
841
+ color: var(--wui-color-fg-200);
842
+ }
843
+
844
+ .wui-color-fg-300 {
845
+ color: var(--wui-color-fg-300);
846
+ }
847
+
848
+ .wui-color-fg-325 {
849
+ color: var(--wui-color-fg-325);
850
+ }
851
+
852
+ .wui-color-fg-350 {
853
+ color: var(--wui-color-fg-350);
854
+ }
855
+
856
+ .wui-bg-color-inherit {
857
+ background-color: var(--wui-color-inherit);
858
+ }
859
+
860
+ .wui-bg-color-blue-100 {
861
+ background-color: var(--wui-color-accent-100);
862
+ }
863
+
864
+ .wui-bg-color-error-100 {
865
+ background-color: var(--wui-color-error-100);
866
+ }
867
+
868
+ .wui-bg-color-error-125 {
869
+ background-color: var(--wui-color-error-125);
870
+ }
871
+
872
+ .wui-bg-color-success-100 {
873
+ background-color: var(--wui-color-success-100);
874
+ }
875
+
876
+ .wui-bg-color-success-125 {
877
+ background-color: var(--wui-color-success-100);
878
+ }
879
+
880
+ .wui-bg-color-inverse-100 {
881
+ background-color: var(--wui-color-inverse-100);
882
+ }
883
+
884
+ .wui-bg-color-inverse-000 {
885
+ background-color: var(--wui-color-inverse-000);
886
+ }
887
+
888
+ .wui-bg-color-fg-100 {
889
+ background-color: var(--wui-color-fg-100);
890
+ }
891
+
892
+ .wui-bg-color-fg-200 {
893
+ background-color: var(--wui-color-fg-200);
894
+ }
895
+
896
+ .wui-bg-color-fg-300 {
897
+ background-color: var(--wui-color-fg-300);
898
+ }
899
+
900
+ .wui-color-fg-325 {
901
+ background-color: var(--wui-color-fg-325);
902
+ }
903
+
904
+ .wui-color-fg-350 {
905
+ background-color: var(--wui-color-fg-350);
906
+ }
907
+ `,oi={ERROR_CODE_UNRECOGNIZED_CHAIN_ID:4902,ERROR_CODE_DEFAULT:5e3,ERROR_INVALID_CHAIN_ID:32603,DEFAULT_ALLOWED_ANCESTORS:["http://localhost:*","https://*.pages.dev","https://*.vercel.app","https://*.ngrok-free.app","https://secure-mobile.walletconnect.com","https://secure-mobile.walletconnect.org"]};function Mi(t){return{formatters:void 0,fees:void 0,serializers:void 0,...t}}const ul=Mi({id:"5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",name:"Solana",network:"solana-mainnet",nativeCurrency:{name:"Solana",symbol:"SOL",decimals:9},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}},blockExplorers:{default:{name:"Solscan",url:"https://solscan.io"}},testnet:!1,chainNamespace:"solana",caipNetworkId:"solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",deprecatedCaipNetworkId:"solana:4sGjMW1sUnHzSxGspuhpqLDx6wiyjNtZ"}),dl=Mi({id:"EtWTRABZaYq6iMfeYKouRu166VU2xqa1",name:"Solana Devnet",network:"solana-devnet",nativeCurrency:{name:"Solana",symbol:"SOL",decimals:9},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}},blockExplorers:{default:{name:"Solscan",url:"https://solscan.io"}},testnet:!0,chainNamespace:"solana",caipNetworkId:"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1",deprecatedCaipNetworkId:"solana:8E9rvCKLFQia2Y35HXjjpWzj8weVo44K"});Mi({id:"4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z",name:"Solana Testnet",network:"solana-testnet",nativeCurrency:{name:"Solana",symbol:"SOL",decimals:9},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}},blockExplorers:{default:{name:"Solscan",url:"https://solscan.io"}},testnet:!0,chainNamespace:"solana",caipNetworkId:"solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z"});Mi({id:"000000000019d6689c085ae165831e93",caipNetworkId:"bip122:000000000019d6689c085ae165831e93",chainNamespace:"bip122",name:"Bitcoin",nativeCurrency:{name:"Bitcoin",symbol:"BTC",decimals:8},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}}});Mi({id:"000000000933ea01ad0ee984209779ba",caipNetworkId:"bip122:000000000933ea01ad0ee984209779ba",chainNamespace:"bip122",name:"Bitcoin Testnet",nativeCurrency:{name:"Bitcoin",symbol:"BTC",decimals:8},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}},testnet:!0});const CE={solana:["solana_signMessage","solana_signTransaction","solana_requestAccounts","solana_getAccounts","solana_signAllTransactions","solana_signAndSendTransaction"],eip155:["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sendTransaction","personal_sign","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode","wallet_getCallsStatus","wallet_showCallsStatus","wallet_sendCalls","wallet_getCapabilities","wallet_grantPermissions","wallet_revokePermissions","wallet_getAssets"],bip122:["sendTransfer","signMessage","signPsbt","getAccountAddresses"]},an={getMethodsByChainNamespace(t){return CE[t]||[]},createDefaultNamespace(t){return{methods:this.getMethodsByChainNamespace(t),events:["accountsChanged","chainChanged"],chains:[],rpcMap:{}}},applyNamespaceOverrides(t,e){if(!e)return{...t};const s={...t},r=new Set;if(e.methods&&Object.keys(e.methods).forEach(i=>r.add(i)),e.chains&&Object.keys(e.chains).forEach(i=>r.add(i)),e.events&&Object.keys(e.events).forEach(i=>r.add(i)),e.rpcMap&&Object.keys(e.rpcMap).forEach(i=>{const[n]=i.split(":");n&&r.add(n)}),r.forEach(i=>{s[i]||(s[i]=this.createDefaultNamespace(i))}),e.methods&&Object.entries(e.methods).forEach(([i,n])=>{s[i]&&(s[i].methods=n)}),e.chains&&Object.entries(e.chains).forEach(([i,n])=>{s[i]&&(s[i].chains=n)}),e.events&&Object.entries(e.events).forEach(([i,n])=>{s[i]&&(s[i].events=n)}),e.rpcMap){const i=new Set;Object.entries(e.rpcMap).forEach(([n,o])=>{const[a,c]=n.split(":");!a||!c||!s[a]||(s[a].rpcMap||(s[a].rpcMap={}),i.has(a)||(s[a].rpcMap={},i.add(a)),s[a].rpcMap[c]=o)})}return s},createNamespaces(t,e){const s=t.reduce((r,i)=>{const{id:n,chainNamespace:o,rpcUrls:a}=i,c=a.default.http[0];r[o]||(r[o]=this.createDefaultNamespace(o));const l=`${o}:${n}`,h=r[o];switch(h.chains.push(l),l){case ul.caipNetworkId:h.chains.push(ul.deprecatedCaipNetworkId);break;case dl.caipNetworkId:h.chains.push(dl.deprecatedCaipNetworkId);break}return h!=null&&h.rpcMap&&c&&(h.rpcMap[n]=c),r},{});return this.applyNamespaceOverrides(s,e)},resolveReownName:async t=>{var r;const e=await hi.resolveName(t);return((r=(Object.values(e==null?void 0:e.addresses)||[])[0])==null?void 0:r.address)||!1},getChainsFromNamespaces(t={}){return Object.values(t).flatMap(e=>{const s=e.chains||[],r=e.accounts.map(i=>{const[n,o]=i.split(":");return`${n}:${o}`});return Array.from(new Set([...s,...r]))})},isSessionEventData(t){return typeof t=="object"&&t!==null&&"id"in t&&"topic"in t&&"params"in t&&typeof t.params=="object"&&t.params!==null&&"chainId"in t.params&&"event"in t.params&&typeof t.params.event=="object"&&t.params.event!==null},isOriginAllowed(t,e,s){for(const r of[...e,...s])if(r.includes("*")){const n=`^${r.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&").replace(/\\\*/gu,".*")}$`;if(new RegExp(n,"u").test(t))return!0}else try{if(new URL(r).origin===t)return!0}catch{if(r===t)return!0}return!1}};class Yh{constructor({provider:e,namespace:s}){this.id=z.CONNECTOR_ID.WALLET_CONNECT,this.name=pn.ConnectorNamesMap[z.CONNECTOR_ID.WALLET_CONNECT],this.type="WALLET_CONNECT",this.imageId=pn.ConnectorImageIds[z.CONNECTOR_ID.WALLET_CONNECT],this.getCaipNetworks=p.getCaipNetworks.bind(p),this.caipNetworks=this.getCaipNetworks(),this.provider=e,this.chain=s}get chains(){return this.getCaipNetworks()}async connectWalletConnect(){if(!await this.authenticate()){const s=this.getCaipNetworks(),r=O.state.universalProviderConfigOverride,i=an.createNamespaces(s,r);await this.provider.connect({optionalNamespaces:i})}return{clientId:await this.provider.client.core.crypto.getClientId(),session:this.provider.session}}async disconnect(){await this.provider.disconnect()}async authenticate(){const e=this.chains.map(s=>s.caipNetworkId);return fi.universalProviderAuthenticate({universalProvider:this.provider,chains:e,methods:IE})}}const IE=["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sendTransaction","personal_sign","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode","wallet_getCallsStatus","wallet_sendCalls","wallet_getCapabilities","wallet_grantPermissions","wallet_revokePermissions","wallet_getAssets"];class AE{constructor(e){this.availableConnectors=[],this.eventListeners=new Map,this.getCaipNetworks=s=>p.getCaipNetworks(s),e&&this.construct(e)}construct(e){this.projectId=e.projectId,this.namespace=e.namespace,this.adapterType=e.adapterType}get connectors(){return this.availableConnectors}get networks(){return this.getCaipNetworks(this.namespace)}setAuthProvider(e){this.addConnector({id:z.CONNECTOR_ID.AUTH,type:"AUTH",name:z.CONNECTOR_NAMES.AUTH,provider:e,imageId:pn.ConnectorImageIds[z.CONNECTOR_ID.AUTH],chain:this.namespace,chains:[]})}addConnector(...e){const s=new Set;this.availableConnectors=[...e,...this.availableConnectors].filter(r=>s.has(r.id)?!1:(s.add(r.id),!0)),this.emit("connectors",this.availableConnectors)}setStatus(e,s){W.setStatus(e,s)}on(e,s){var r;this.eventListeners.has(e)||this.eventListeners.set(e,new Set),(r=this.eventListeners.get(e))==null||r.add(s)}off(e,s){const r=this.eventListeners.get(e);r&&r.delete(s)}removeAllEventListeners(){this.eventListeners.forEach(e=>{e.clear()})}emit(e,s){const r=this.eventListeners.get(e);r&&r.forEach(i=>i(s))}async connectWalletConnect(e){return{clientId:(await this.getWalletConnectConnector().connectWalletConnect()).clientId}}async switchNetwork(e){var n;const{caipNetwork:s,providerType:r}=e;if(!e.provider)return;const i="provider"in e.provider?e.provider.provider:e.provider;if(r==="WALLET_CONNECT"){i.setDefaultChain(s.caipNetworkId);return}if(i&&r==="AUTH"){const o=i,a=(n=W.state.preferredAccountTypes)==null?void 0:n[s.chainNamespace];await o.switchNetwork(s.caipNetworkId);const c=await o.getUser({chainId:s.caipNetworkId,preferredAccountType:a});this.emit("switchNetwork",c)}}getWalletConnectConnector(){const e=this.connectors.find(s=>s instanceof Yh);if(!e)throw new Error("WalletConnectConnector not found");return e}}class NE extends AE{setUniversalProvider(e){this.addConnector(new Yh({provider:e,caipNetworks:this.getCaipNetworks(),namespace:this.namespace}))}async connect(e){return Promise.resolve({id:"WALLET_CONNECT",type:"WALLET_CONNECT",chainId:Number(e.chainId),provider:this.provider,address:""})}async disconnect(){try{await this.getWalletConnectConnector().disconnect()}catch(e){console.warn("UniversalAdapter:disconnect - error",e)}}async getAccounts({namespace:e}){var i,n,o,a;const s=this.provider,r=((a=(o=(n=(i=s==null?void 0:s.session)==null?void 0:i.namespaces)==null?void 0:n[e])==null?void 0:o.accounts)==null?void 0:a.map(c=>{const[,,l]=c.split(":");return l}).filter((c,l,h)=>h.indexOf(c)===l))||[];return Promise.resolve({accounts:r.map(c=>Z.createAccount(e,c,e==="bip122"?"payment":"eoa"))})}async syncConnectors(){return Promise.resolve()}async getBalance(e){var n,o,a,c,l;if(!(e.caipNetwork&&Ee.BALANCE_SUPPORTED_CHAINS.includes((n=e.caipNetwork)==null?void 0:n.chainNamespace))||(o=e.caipNetwork)!=null&&o.testnet)return{balance:"0.00",symbol:((a=e.caipNetwork)==null?void 0:a.nativeCurrency.symbol)||""};if(W.state.balanceLoading&&e.chainId===((c=p.state.activeCaipNetwork)==null?void 0:c.id))return{balance:W.state.balance||"0.00",symbol:W.state.balanceSymbol||""};const i=(await W.fetchTokenBalance()).find(h=>{var u,d;return h.chainId===`${(u=e.caipNetwork)==null?void 0:u.chainNamespace}:${e.chainId}`&&h.symbol===((d=e.caipNetwork)==null?void 0:d.nativeCurrency.symbol)});return{balance:(i==null?void 0:i.quantity.numeric)||"0.00",symbol:(i==null?void 0:i.symbol)||((l=e.caipNetwork)==null?void 0:l.nativeCurrency.symbol)||""}}async signMessage(e){var o,a,c;const{provider:s,message:r,address:i}=e;if(!s)throw new Error("UniversalAdapter:signMessage - provider is undefined");let n="";return((o=p.state.activeCaipNetwork)==null?void 0:o.chainNamespace)===z.CHAIN.SOLANA?n=(await s.request({method:"solana_signMessage",params:{message:ml.encode(new TextEncoder().encode(r)),pubkey:i}},(a=p.state.activeCaipNetwork)==null?void 0:a.caipNetworkId)).signature:n=await s.request({method:"personal_sign",params:[r,i]},(c=p.state.activeCaipNetwork)==null?void 0:c.caipNetworkId),{signature:n}}async estimateGas(){return Promise.resolve({gas:BigInt(0)})}async sendTransaction(){return Promise.resolve({hash:""})}walletGetAssets(e){return Promise.resolve({})}async writeContract(){return Promise.resolve({hash:""})}parseUnits(){return 0n}formatUnits(){return"0"}async getCapabilities(){return Promise.resolve({})}async grantPermissions(){return Promise.resolve({})}async revokePermissions(){return Promise.resolve("0x")}async syncConnection(){return Promise.resolve({id:"WALLET_CONNECT",type:"WALLET_CONNECT",chainId:1,provider:this.provider,address:""})}async switchNetwork(e){var i,n,o,a,c,l;const{caipNetwork:s}=e,r=this.getWalletConnectConnector();if(s.chainNamespace===z.CHAIN.EVM)try{await((i=r.provider)==null?void 0:i.request({method:"wallet_switchEthereumChain",params:[{chainId:na(s.id)}]}))}catch(h){if(h.code===oi.ERROR_CODE_UNRECOGNIZED_CHAIN_ID||h.code===oi.ERROR_INVALID_CHAIN_ID||h.code===oi.ERROR_CODE_DEFAULT||((o=(n=h==null?void 0:h.data)==null?void 0:n.originalError)==null?void 0:o.code)===oi.ERROR_CODE_UNRECOGNIZED_CHAIN_ID)try{await((l=r.provider)==null?void 0:l.request({method:"wallet_addEthereumChain",params:[{chainId:na(s.id),rpcUrls:[(a=s==null?void 0:s.rpcUrls.chainDefault)==null?void 0:a.http],chainName:s.name,nativeCurrency:s.nativeCurrency,blockExplorerUrls:[(c=s.blockExplorers)==null?void 0:c.default.url]}]}))}catch{throw new Error("Chain is not supported")}}r.provider.setDefaultChain(s.caipNetworkId)}getWalletConnectProvider(){const e=this.connectors.find(r=>r.type==="WALLET_CONNECT");return e==null?void 0:e.provider}}const _E=["email","socials","swaps","onramp","activity","reownBranding"],Xi={email:{apiFeatureName:"social_login",localFeatureName:"email",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:t=>{if(!(t!=null&&t.config))return!1;const e=t.config;return!!t.isEnabled&&e.includes("email")},processFallback:t=>t===void 0?Ee.DEFAULT_REMOTE_FEATURES.email:!!t},socials:{apiFeatureName:"social_login",localFeatureName:"socials",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:t=>{if(!(t!=null&&t.config))return!1;const e=t.config;return t.isEnabled&&e.length>0?e.filter(s=>s!=="email"):!1},processFallback:t=>t===void 0?Ee.DEFAULT_REMOTE_FEATURES.socials:typeof t=="boolean"?t?Ee.DEFAULT_REMOTE_FEATURES.socials:!1:t},swaps:{apiFeatureName:"swap",localFeatureName:"swaps",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:t=>{if(!(t!=null&&t.config))return!1;const e=t.config;return t.isEnabled&&e.length>0?e:!1},processFallback:t=>t===void 0?Ee.DEFAULT_REMOTE_FEATURES.swaps:typeof t=="boolean"?t?Ee.DEFAULT_REMOTE_FEATURES.swaps:!1:t},onramp:{apiFeatureName:"onramp",localFeatureName:"onramp",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:t=>{if(!(t!=null&&t.config))return!1;const e=t.config;return t.isEnabled&&e.length>0?e:!1},processFallback:t=>t===void 0?Ee.DEFAULT_REMOTE_FEATURES.onramp:typeof t=="boolean"?t?Ee.DEFAULT_REMOTE_FEATURES.onramp:!1:t},activity:{apiFeatureName:"activity",localFeatureName:"history",returnType:!1,isLegacy:!0,isAvailableOnBasic:!1,processApi:t=>!!t.isEnabled,processFallback:t=>t===void 0?Ee.DEFAULT_REMOTE_FEATURES.activity:!!t},reownBranding:{apiFeatureName:"reown_branding",localFeatureName:"reownBranding",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:t=>!!t.isEnabled,processFallback:t=>t===void 0?Ee.DEFAULT_REMOTE_FEATURES.reownBranding:!!t}},SE={localSettingsOverridden:new Set,getApiConfig(t,e){return e==null?void 0:e.find(s=>s.id===t)},addWarning(t,e){if(t!==void 0){const s=Xi[e],r=s.isLegacy?`"features.${s.localFeatureName}" (now "${e}")`:`"features.${e}"`;this.localSettingsOverridden.add(r)}},processFeature(t,e,s,r,i){const n=Xi[t],o=e[n.localFeatureName];if(i&&!n.isAvailableOnBasic)return!1;if(r){const a=this.getApiConfig(n.apiFeatureName,s);return(a==null?void 0:a.config)===null?this.processFallbackFeature(t,o):a!=null&&a.config?(o!==void 0&&this.addWarning(o,t),this.processApiFeature(t,a)):!1}return this.processFallbackFeature(t,o)},processApiFeature(t,e){return Xi[t].processApi(e)},processFallbackFeature(t,e){return Xi[t].processFallback(e)},async fetchRemoteFeatures(t){const e=t.basic??!1,s=t.features||{};this.localSettingsOverridden.clear();let r=null,i=!1;try{r=await V.fetchProjectConfig(),i=r!=null}catch(o){console.warn("[Reown Config] Failed to fetch remote project configuration. Using local/default values.",o)}const n=i&&!e?Ee.DEFAULT_REMOTE_FEATURES:Ee.DEFAULT_REMOTE_FEATURES_DISABLED;try{for(const o of _E){const a=this.processFeature(o,s,r,i,e);Object.assign(n,{[o]:a})}}catch(o){return console.warn("[Reown Config] Failed to process the configuration from Cloud. Using default values.",o),Ee.DEFAULT_REMOTE_FEATURES}if(i&&this.localSettingsOverridden.size>0){const o=`Your local configuration for ${Array.from(this.localSettingsOverridden).join(", ")} was ignored because a remote configuration was successfully fetched. Please manage these features via your project dashboard on dashboard.reown.com.`;Us.open({shortMessage:"Local configuration ignored",longMessage:`[Reown Config Notice] ${o}`},"warning")}return n}};class PE{constructor(e){this.chainNamespaces=[],this.remoteFeatures={},this.reportedAlertErrors={},this.getCaipNetwork=(s,r)=>{var i,n,o,a;if(s){const c=(n=(i=p.getNetworkData(s))==null?void 0:i.requestedCaipNetworks)==null?void 0:n.find(u=>u.id===r);if(c)return c;const l=(o=p.getNetworkData(s))==null?void 0:o.caipNetwork;return l||((a=p.getRequestedCaipNetworks(s).filter(u=>u.chainNamespace===s))==null?void 0:a[0])}return p.state.activeCaipNetwork||this.defaultCaipNetwork},this.getCaipNetworkId=()=>{const s=this.getCaipNetwork();if(s)return s.id},this.getCaipNetworks=s=>p.getCaipNetworks(s),this.getActiveChainNamespace=()=>p.state.activeChain,this.setRequestedCaipNetworks=(s,r)=>{p.setRequestedCaipNetworks(s,r)},this.getApprovedCaipNetworkIds=()=>p.getAllApprovedCaipNetworkIds(),this.getCaipAddress=s=>p.state.activeChain===s||!s?p.state.activeCaipAddress:p.getAccountProp("caipAddress",s),this.setClientId=s=>{J.setClientId(s)},this.getProvider=s=>Se.getProvider(s),this.getProviderType=s=>Se.getProviderId(s),this.getPreferredAccountType=s=>{var r;return(r=W.state.preferredAccountTypes)==null?void 0:r[s]},this.setCaipAddress=(s,r)=>{W.setCaipAddress(s,r),s&&O.state.enableEmbedded&&this.close()},this.setBalance=(s,r,i)=>{W.setBalance(s,r,i)},this.setProfileName=(s,r)=>{W.setProfileName(s,r)},this.setProfileImage=(s,r)=>{W.setProfileImage(s,r)},this.setUser=(s,r)=>{W.setUser(s,r)},this.resetAccount=s=>{W.resetAccount(s)},this.setCaipNetwork=s=>{p.setActiveCaipNetwork(s)},this.setCaipNetworkOfNamespace=(s,r)=>{p.setChainNetworkData(r,{caipNetwork:s})},this.setAllAccounts=(s,r)=>{W.setAllAccounts(s,r),O.setHasMultipleAddresses((s==null?void 0:s.length)>1)},this.setStatus=(s,r)=>{W.setStatus(s,r),q.isConnected()?F.setConnectionStatus("connected"):F.setConnectionStatus("disconnected")},this.getAddressByChainNamespace=s=>p.getAccountProp("address",s),this.setConnectors=s=>{const r=[...q.state.allConnectors,...s];q.setConnectors(r)},this.setConnections=(s,r)=>{Y.setConnections(s,r)},this.fetchIdentity=s=>J.fetchIdentity(s),this.getReownName=s=>hi.getNamesForAddress(s),this.getConnectors=()=>q.getConnectors(),this.getConnectorImage=s=>Il.getConnectorImage(s),this.setConnectedWalletInfo=(s,r)=>{const i=Se.getProviderId(r),n=s?{...s,type:i}:void 0;W.setConnectedWalletInfo(n,r)},this.getIsConnectedState=()=>!!p.state.activeCaipAddress,this.addAddressLabel=(s,r,i)=>{W.addAddressLabel(s,r,i)},this.removeAddressLabel=(s,r)=>{W.removeAddressLabel(s,r)},this.getAddress=s=>p.state.activeChain===s||!s?W.state.address:p.getAccountProp("address",s),this.setApprovedCaipNetworksData=s=>p.setApprovedCaipNetworksData(s),this.resetNetwork=s=>{p.resetNetwork(s)},this.addConnector=s=>{q.addConnector(s)},this.resetWcConnection=()=>{Y.resetWcConnection()},this.setAddressExplorerUrl=(s,r)=>{W.setAddressExplorerUrl(s,r)},this.setSmartAccountDeployed=(s,r)=>{W.setSmartAccountDeployed(s,r)},this.setSmartAccountEnabledNetworks=(s,r)=>{p.setSmartAccountEnabledNetworks(s,r)},this.setPreferredAccountType=(s,r)=>{W.setPreferredAccountType(s,r)},this.setEIP6963Enabled=s=>{O.setEIP6963Enabled(s)},this.handleUnsafeRPCRequest=()=>{if(this.isOpen()){if(this.isTransactionStackEmpty())return;this.redirect("ApproveTransaction")}else this.open({view:"ApproveTransaction"})},this.options=e,this.version=e.sdkVersion,this.caipNetworks=this.extendCaipNetworks(e),this.chainNamespaces=this.getChainNamespacesSet(e.adapters,this.caipNetworks),this.defaultCaipNetwork=this.extendDefaultCaipNetwork(e),this.chainAdapters=this.createAdapters(e.adapters),this.readyPromise=this.initialize(e)}getChainNamespacesSet(e,s){const r=e==null?void 0:e.map(n=>n.namespace).filter(n=>!!n);if(r!=null&&r.length)return[...new Set(r)];const i=s==null?void 0:s.map(n=>n.chainNamespace);return[...new Set(i)]}async initialize(e){var s,r,i;this.initializeProjectSettings(e),this.initControllers(e),await this.initChainAdapters(),this.sendInitializeEvent(e),await this.syncExistingConnection(),this.remoteFeatures=await SE.fetchRemoteFeatures(e),O.setRemoteFeatures(this.remoteFeatures),this.remoteFeatures.onramp&&lo.setOnrampProviders(this.remoteFeatures.onramp),((s=O.state.remoteFeatures)!=null&&s.email||Array.isArray((r=O.state.remoteFeatures)==null?void 0:r.socials)&&((i=O.state.remoteFeatures)==null?void 0:i.socials.length)>0)&&await this.checkAllowedOrigins()}async checkAllowedOrigins(){const e=await V.fetchAllowedOrigins();if(e&&Z.isClient()){const s=window.location.origin;an.isOriginAllowed(s,e,oi.DEFAULT_ALLOWED_ANCESTORS)||Us.open(yr.ALERT_ERRORS.INVALID_APP_CONFIGURATION,"error")}else Us.open(yr.ALERT_ERRORS.PROJECT_ID_NOT_CONFIGURED,"error")}sendInitializeEvent(e){var r;const{...s}=e;delete s.adapters,delete s.universalProvider,Pe.sendEvent({type:"track",event:"INITIALIZE",properties:{...s,networks:e.networks.map(i=>i.id),siweConfig:{options:((r=e.siweConfig)==null?void 0:r.options)||{}}}})}initControllers(e){this.initializeOptionsController(e),this.initializeChainController(e),this.initializeThemeController(e),this.initializeConnectionController(e),this.initializeConnectorController()}initializeThemeController(e){e.themeMode&&ft.setThemeMode(e.themeMode),e.themeVariables&&ft.setThemeVariables(e.themeVariables)}initializeChainController(e){if(!this.connectionControllerClient||!this.networkControllerClient)throw new Error("ConnectionControllerClient and NetworkControllerClient must be set");p.initialize(e.adapters??[],this.caipNetworks,{connectionControllerClient:this.connectionControllerClient,networkControllerClient:this.networkControllerClient});const s=this.getDefaultNetwork();s&&p.setActiveCaipNetwork(s)}initializeConnectionController(e){Y.setWcBasic(e.basic??!1)}initializeConnectorController(){q.initialize(this.chainNamespaces)}initializeProjectSettings(e){O.setProjectId(e.projectId),O.setSdkVersion(e.sdkVersion)}initializeOptionsController(e){var o;O.setDebug(e.debug!==!1),O.setEnableWalletConnect(e.enableWalletConnect!==!1),O.setEnableWalletGuide(e.enableWalletGuide!==!1),O.setEnableWallets(e.enableWallets!==!1),O.setEIP6963Enabled(e.enableEIP6963!==!1),O.setEnableNetworkSwitch(e.enableNetworkSwitch!==!1),O.setEnableAuthLogger(e.enableAuthLogger!==!1),O.setCustomRpcUrls(e.customRpcUrls),O.setEnableEmbedded(e.enableEmbedded),O.setAllWallets(e.allWallets),O.setIncludeWalletIds(e.includeWalletIds),O.setExcludeWalletIds(e.excludeWalletIds),O.setFeaturedWalletIds(e.featuredWalletIds),O.setTokens(e.tokens),O.setTermsConditionsUrl(e.termsConditionsUrl),O.setPrivacyPolicyUrl(e.privacyPolicyUrl),O.setCustomWallets(e.customWallets),O.setFeatures(e.features),O.setAllowUnsupportedChain(e.allowUnsupportedChain),O.setUniversalProviderConfigOverride(e.universalProviderConfigOverride),O.setPreferUniversalLinks(e.experimental_preferUniversalLinks),O.setDefaultAccountTypes(e.defaultAccountTypes);const s=F.getPreferredAccountTypes()||{},r={...O.state.defaultAccountTypes,...s};W.setPreferredAccountTypes(r);const i=this.getDefaultMetaData();if(!e.metadata&&i&&(e.metadata=i),O.setMetadata(e.metadata),O.setDisableAppend(e.disableAppend),O.setEnableEmbedded(e.enableEmbedded),O.setSIWX(e.siwx),!e.projectId){Us.open(yr.ALERT_ERRORS.PROJECT_ID_NOT_CONFIGURED,"error");return}if(((o=e.adapters)==null?void 0:o.find(a=>a.namespace===z.CHAIN.EVM))&&e.siweConfig){if(e.siwx)throw new Error("Cannot set both `siweConfig` and `siwx` options");O.setSIWX(e.siweConfig.mapToSIWX())}}getDefaultMetaData(){var e,s,r,i;return Z.isClient()?{name:((s=(e=document.getElementsByTagName("title"))==null?void 0:e[0])==null?void 0:s.textContent)||"",description:((r=document.querySelector('meta[property="og:description"]'))==null?void 0:r.content)||"",url:window.location.origin,icons:[((i=document.querySelector('link[rel~="icon"]'))==null?void 0:i.href)||""]}:null}setUnsupportedNetwork(e){const s=this.getActiveChainNamespace();if(s){const r=vr.getUnsupportedNetwork(`${s}:${e}`);p.setActiveCaipNetwork(r)}}getDefaultNetwork(){return vr.getCaipNetworkFromStorage(this.defaultCaipNetwork)}extendCaipNetwork(e,s){return vr.extendCaipNetwork(e,{customNetworkImageUrls:s.chainImages,projectId:s.projectId})}extendCaipNetworks(e){return vr.extendCaipNetworks(e.networks,{customNetworkImageUrls:e.chainImages,customRpcUrls:e.customRpcUrls,projectId:e.projectId})}extendDefaultCaipNetwork(e){const s=e.networks.find(i=>{var n;return i.id===((n=e.defaultNetwork)==null?void 0:n.id)});return s?vr.extendCaipNetwork(s,{customNetworkImageUrls:e.chainImages,customRpcUrls:e.customRpcUrls,projectId:e.projectId}):void 0}async disconnectNamespace(e){try{const s=this.getAdapter(e),r=Se.getProvider(e),i=Se.getProviderId(e),{caipAddress:n}=p.getAccountData(e)||{};this.setLoading(!0,e),n&&(s!=null&&s.disconnect)&&await s.disconnect({provider:r,providerType:i}),F.removeConnectedNamespace(e),Se.resetChain(e),this.setUser(void 0,e),this.setStatus("disconnected",e),this.setConnectedWalletInfo(void 0,e),q.removeConnectorId(e),p.resetAccount(e),p.resetNetwork(e),this.setLoading(!1,e)}catch(s){throw this.setLoading(!1,e),new Error(`Failed to disconnect chain ${e}: ${s.message}`)}}createClients(){this.connectionControllerClient={connectWalletConnect:async()=>{var n;const e=p.state.activeChain,s=this.getAdapter(e),r=(n=this.getCaipNetwork(e))==null?void 0:n.id;if(!s)throw new Error("Adapter not found");const i=await s.connectWalletConnect(r);this.close(),this.setClientId((i==null?void 0:i.clientId)||null),F.setConnectedNamespaces([...p.state.chains.keys()]),this.chainNamespaces.forEach(o=>{q.setConnectorId(ps.CONNECTOR_TYPE_WALLET_CONNECT,o)}),await this.syncWalletConnectAccount()},connectExternal:async({id:e,info:s,type:r,provider:i,chain:n,caipNetwork:o,socialUri:a})=>{var f,m,y,b,E,A;const c=p.state.activeChain,l=n||c,h=this.getAdapter(l);if(n&&n!==c&&!o){const $=this.getCaipNetworks().find(P=>P.chainNamespace===n);$&&this.setCaipNetwork($)}if(!h)throw new Error("Adapter not found");const u=this.getCaipNetwork(l),d=await h.connect({id:e,info:s,type:r,provider:i,socialUri:a,chainId:(o==null?void 0:o.id)||(u==null?void 0:u.id),rpcUrl:((y=(m=(f=o==null?void 0:o.rpcUrls)==null?void 0:f.default)==null?void 0:m.http)==null?void 0:y[0])||((A=(E=(b=u==null?void 0:u.rpcUrls)==null?void 0:b.default)==null?void 0:E.http)==null?void 0:A[0])});if(!d)return;F.addConnectedNamespace(l),this.syncProvider({...d,chainNamespace:l});const g=W.state.allAccounts,{accounts:w}=(g==null?void 0:g.length)>0?{accounts:[...g]}:await h.getAccounts({namespace:l,id:e});this.setAllAccounts(w,l),this.setStatus("connected",l),this.syncConnectedWalletInfo(l)},reconnectExternal:async({id:e,info:s,type:r,provider:i})=>{var a;const n=p.state.activeChain,o=this.getAdapter(n);o!=null&&o.reconnect&&(await(o==null?void 0:o.reconnect({id:e,info:s,type:r,provider:i,chainId:(a=this.getCaipNetwork())==null?void 0:a.id})),F.addConnectedNamespace(n),this.syncConnectedWalletInfo(n))},disconnect:async e=>{const s=Q0(e);try{const r=await Promise.allSettled(s.map(async([n])=>this.disconnectNamespace(n)));ue.resetSend(),Y.resetWcConnection(),await fi.clearSessions(),q.setFilterByNamespace(void 0);const i=r.filter(n=>n.status==="rejected");if(i.length>0)throw new Error(i.map(n=>n.reason.message).join(", "));F.deleteConnectedSocialProvider(),Pe.sendEvent({type:"track",event:"DISCONNECT_SUCCESS",properties:{namespace:e||"all"}})}catch(r){throw new Error(`Failed to disconnect chains: ${r.message}`)}},checkInstalled:e=>e?e.some(s=>{var r;return!!((r=window.ethereum)!=null&&r[String(s)])}):!!window.ethereum,signMessage:async e=>{const s=this.getAdapter(p.state.activeChain),r=await(s==null?void 0:s.signMessage({message:e,address:W.state.address,provider:Se.getProvider(p.state.activeChain)}));return(r==null?void 0:r.signature)||""},sendTransaction:async e=>{const s=e.chainNamespace;if(Ee.SEND_SUPPORTED_NAMESPACES.includes(s)){const r=this.getAdapter(p.state.activeChain),i=Se.getProvider(s),n=await(r==null?void 0:r.sendTransaction({...e,caipNetwork:this.getCaipNetwork(),provider:i}));return(n==null?void 0:n.hash)||""}return""},estimateGas:async e=>{if(e.chainNamespace===z.CHAIN.EVM){const s=this.getAdapter(p.state.activeChain),r=Se.getProvider(p.state.activeChain),i=this.getCaipNetwork();if(!i)throw new Error("CaipNetwork is undefined");const n=await(s==null?void 0:s.estimateGas({...e,provider:r,caipNetwork:i}));return(n==null?void 0:n.gas)||0n}return 0n},getEnsAvatar:async()=>{var e;return await this.syncIdentity({address:W.state.address,chainId:Number((e=this.getCaipNetwork())==null?void 0:e.id),chainNamespace:p.state.activeChain}),W.state.profileImage||!1},getEnsAddress:async e=>await an.resolveReownName(e),writeContract:async e=>{const s=this.getAdapter(p.state.activeChain),r=this.getCaipNetwork(),i=this.getCaipAddress(),n=Se.getProvider(p.state.activeChain);if(!r||!i)throw new Error("CaipNetwork or CaipAddress is undefined");const o=await(s==null?void 0:s.writeContract({...e,caipNetwork:r,provider:n,caipAddress:i}));return o==null?void 0:o.hash},parseUnits:(e,s)=>{const r=this.getAdapter(p.state.activeChain);return(r==null?void 0:r.parseUnits({value:e,decimals:s}))??0n},formatUnits:(e,s)=>{const r=this.getAdapter(p.state.activeChain);return(r==null?void 0:r.formatUnits({value:e,decimals:s}))??"0"},getCapabilities:async e=>{const s=this.getAdapter(p.state.activeChain);return await(s==null?void 0:s.getCapabilities(e))},grantPermissions:async e=>{const s=this.getAdapter(p.state.activeChain);return await(s==null?void 0:s.grantPermissions(e))},revokePermissions:async e=>{const s=this.getAdapter(p.state.activeChain);return s!=null&&s.revokePermissions?await s.revokePermissions(e):"0x"},walletGetAssets:async e=>{const s=this.getAdapter(p.state.activeChain);return await(s==null?void 0:s.walletGetAssets(e))??{}},updateBalance:e=>{const s=this.getCaipNetwork(e);!s||!W.state.address||this.updateNativeBalance(W.state.address,s==null?void 0:s.id,e)}},this.networkControllerClient={switchCaipNetwork:async e=>await this.switchCaipNetwork(e),getApprovedCaipNetworksData:async()=>this.getApprovedCaipNetworksData()},Y.setClient(this.connectionControllerClient)}getApprovedCaipNetworksData(){var s,r,i,n,o;if(Se.getProviderId(p.state.activeChain)===ps.CONNECTOR_TYPE_WALLET_CONNECT){const a=(r=(s=this.universalProvider)==null?void 0:s.session)==null?void 0:r.namespaces;return{supportsAllNetworks:((o=(n=(i=this.universalProvider)==null?void 0:i.session)==null?void 0:n.peer)==null?void 0:o.metadata.name)==="MetaMask Wallet",approvedCaipNetworkIds:this.getChainsFromNamespaces(a)}}return{supportsAllNetworks:!0,approvedCaipNetworkIds:[]}}async switchCaipNetwork(e){if(!e)return;const s=e.chainNamespace;if(this.getAddressByChainNamespace(e.chainNamespace)){const i=Se.getProvider(s),n=Se.getProviderId(s);if(e.chainNamespace===p.state.activeChain){const o=this.getAdapter(s);await(o==null?void 0:o.switchNetwork({caipNetwork:e,provider:i,providerType:n}))}else if(this.setCaipNetwork(e),n===ps.CONNECTOR_TYPE_WALLET_CONNECT)this.syncWalletConnectAccount();else{const o=this.getAddressByChainNamespace(s);o&&this.syncAccount({address:o,chainId:e.id,chainNamespace:s})}}else this.setCaipNetwork(e)}getChainsFromNamespaces(e={}){return Object.values(e).flatMap(s=>{const r=s.chains||[],i=s.accounts.map(n=>{const{chainId:o,chainNamespace:a}=cs.parseCaipAddress(n);return`${a}:${o}`});return Array.from(new Set([...r,...i]))})}createAdapters(e){return this.createClients(),this.chainNamespaces.reduce((s,r)=>{var n;const i=e==null?void 0:e.find(o=>o.namespace===r);return i?(i.construct({namespace:r,projectId:(n=this.options)==null?void 0:n.projectId,networks:this.getCaipNetworks()}),s[r]=i):s[r]=new NE({namespace:r,networks:this.getCaipNetworks()}),s},{})}async initChainAdapter(e){var s;this.onConnectors(e),this.listenAdapter(e),await((s=this.chainAdapters)==null?void 0:s[e].syncConnectors(this.options,this)),await this.createUniversalProviderForAdapter(e)}async initChainAdapters(){await Promise.all(this.chainNamespaces.map(async e=>{await this.initChainAdapter(e)}))}onConnectors(e){const s=this.getAdapter(e);s==null||s.on("connectors",this.setConnectors.bind(this))}listenAdapter(e){const s=this.getAdapter(e);if(!s)return;const r=F.getConnectionStatus();r==="connected"?this.setStatus("connecting",e):r==="disconnected"?(F.clearAddressCache(),this.setStatus(r,e)):this.setStatus(r,e),s.on("switchNetwork",({address:i,chainId:n})=>{const o=this.getCaipNetworks().find(l=>l.id===n||l.caipNetworkId===n),a=p.state.activeChain===e,c=p.getAccountProp("address",e);if(o){const l=a&&i?i:c;l&&this.syncAccount({address:l,chainId:o.id,chainNamespace:e})}else this.setUnsupportedNetwork(n)}),s.on("disconnect",this.disconnect.bind(this,e)),s.on("connections",i=>{this.setConnections(i,e)}),s.on("pendingTransactions",()=>{const i=W.state.address,n=p.state.activeCaipNetwork;!i||!(n!=null&&n.id)||this.updateNativeBalance(i,n.id,n.chainNamespace)}),s.on("accountChanged",({address:i,chainId:n})=>{var a,c;const o=p.state.activeChain===e;o&&n?this.syncAccount({address:i,chainId:n,chainNamespace:e}):o&&((a=p.state.activeCaipNetwork)!=null&&a.id)?this.syncAccount({address:i,chainId:(c=p.state.activeCaipNetwork)==null?void 0:c.id,chainNamespace:e}):this.syncAccountInfo(i,n,e),this.syncAllAccounts(e)})}async createUniversalProviderForAdapter(e){var s,r,i;await this.getUniversalProvider(),this.universalProvider&&((i=(r=(s=this.chainAdapters)==null?void 0:s[e])==null?void 0:r.setUniversalProvider)==null||i.call(r,this.universalProvider))}async syncExistingConnection(){await Promise.allSettled(this.chainNamespaces.map(e=>this.syncNamespaceConnection(e)))}async syncNamespaceConnection(e){try{e===z.CHAIN.EVM&&Z.isSafeApp()&&q.setConnectorId(z.CONNECTOR_ID.SAFE,e);const s=q.getConnectorId(e);switch(this.setStatus("connecting",e),s){case z.CONNECTOR_ID.WALLET_CONNECT:await this.syncWalletConnectAccount();break;case z.CONNECTOR_ID.AUTH:break;default:await this.syncAdapterConnection(e)}}catch(s){console.warn("AppKit couldn't sync existing connection",s),this.setStatus("disconnected",e)}}async syncAdapterConnection(e){var a,c,l;const s=this.getAdapter(e),r=q.getConnectorId(e),i=this.getCaipNetwork(e),o=q.getConnectors(e).find(h=>h.id===r);try{if(!s||!o)throw new Error(`Adapter or connector not found for namespace ${e}`);if(!(i!=null&&i.id))throw new Error("CaipNetwork not found");const h=await(s==null?void 0:s.syncConnection({namespace:e,id:o.id,chainId:i.id,rpcUrl:(l=(c=(a=i==null?void 0:i.rpcUrls)==null?void 0:a.default)==null?void 0:c.http)==null?void 0:l[0]}));if(h){const u=await(s==null?void 0:s.getAccounts({namespace:e,id:o.id}));u&&u.accounts.length>0?this.setAllAccounts(u.accounts,e):this.setAllAccounts([Z.createAccount(e,h.address,"eoa")],e),this.syncProvider({...h,chainNamespace:e}),await this.syncAccount({...h,chainNamespace:e}),this.setStatus("connected",e)}else this.setStatus("disconnected",e)}catch{this.setStatus("disconnected",e)}}async syncWalletConnectAccount(){const e=this.chainNamespaces.map(async s=>{var a,c,l,h,u;const r=this.getAdapter(s),i=((h=(l=(c=(a=this.universalProvider)==null?void 0:a.session)==null?void 0:c.namespaces)==null?void 0:l[s])==null?void 0:h.accounts)||[],n=(u=p.state.activeCaipNetwork)==null?void 0:u.id,o=i.find(d=>{const{chainId:g}=cs.parseCaipAddress(d);return g===(n==null?void 0:n.toString())})||i[0];if(o){const d=cs.validateCaipAddress(o),{chainId:g,address:w}=cs.parseCaipAddress(d);if(Se.setProviderId(s,ps.CONNECTOR_TYPE_WALLET_CONNECT),this.caipNetworks&&p.state.activeCaipNetwork&&(r==null?void 0:r.namespace)!==z.CHAIN.EVM){const f=r==null?void 0:r.getWalletConnectProvider({caipNetworks:this.getCaipNetworks(),provider:this.universalProvider,activeCaipNetwork:p.state.activeCaipNetwork});Se.setProvider(s,f)}else Se.setProvider(s,this.universalProvider);q.setConnectorId(z.CONNECTOR_ID.WALLET_CONNECT,s),F.addConnectedNamespace(s),this.syncWalletConnectAccounts(s),await this.syncAccount({address:w,chainId:g,chainNamespace:s})}else this.setStatus("disconnected",s);this.syncConnectedWalletInfo(s),await p.setApprovedCaipNetworksData(s)});await Promise.all(e)}syncWalletConnectAccounts(e){var r,i,n,o,a;const s=(a=(o=(n=(i=(r=this.universalProvider)==null?void 0:r.session)==null?void 0:i.namespaces)==null?void 0:n[e])==null?void 0:o.accounts)==null?void 0:a.map(c=>{const{address:l}=cs.parseCaipAddress(c);return l}).filter((c,l,h)=>h.indexOf(c)===l);s&&this.setAllAccounts(s.map(c=>Z.createAccount(e,c,e==="bip122"?"payment":"eoa")),e)}syncProvider({type:e,provider:s,id:r,chainNamespace:i}){Se.setProviderId(i,e),Se.setProvider(i,s),q.setConnectorId(r,i)}async syncAllAccounts(e){const s=q.getConnectorId(e);if(!s)return;const r=this.getAdapter(e),i=await(r==null?void 0:r.getAccounts({namespace:e,id:s}));i&&i.accounts.length>0&&this.setAllAccounts(i.accounts,e)}async syncAccount(e){var u,d;const s=e.chainNamespace===p.state.activeChain,r=p.getCaipNetworkByNamespace(e.chainNamespace,e.chainId),{address:i,chainId:n,chainNamespace:o}=e,{chainId:a}=F.getActiveNetworkProps(),c=n||a,l=((u=p.state.activeCaipNetwork)==null?void 0:u.name)===z.UNSUPPORTED_NETWORK_NAME,h=p.getNetworkProp("supportsAllNetworks",o);if(this.setStatus("connected",o),!(l&&!h)&&c){let g=this.getCaipNetworks().find(m=>m.id.toString()===c.toString()),w=this.getCaipNetworks().find(m=>m.chainNamespace===o);if(!h&&!g&&!w){const m=this.getApprovedCaipNetworkIds()||[],y=m.find(E=>{var A;return((A=cs.parseCaipNetworkId(E))==null?void 0:A.chainId)===c.toString()}),b=m.find(E=>{var A;return((A=cs.parseCaipNetworkId(E))==null?void 0:A.chainNamespace)===o});g=this.getCaipNetworks().find(E=>E.caipNetworkId===y),w=this.getCaipNetworks().find(E=>E.caipNetworkId===b||"deprecatedCaipNetworkId"in E&&E.deprecatedCaipNetworkId===b)}const f=g||w;(f==null?void 0:f.chainNamespace)===p.state.activeChain?O.state.enableNetworkSwitch&&!O.state.allowUnsupportedChain&&((d=p.state.activeCaipNetwork)==null?void 0:d.name)===z.UNSUPPORTED_NETWORK_NAME?p.showUnsupportedChainUI():this.setCaipNetwork(f):s||r&&this.setCaipNetworkOfNamespace(r,o),this.syncConnectedWalletInfo(o),ta.isLowerCaseMatch(i,W.state.address)||this.syncAccountInfo(i,f==null?void 0:f.id,o),s?await this.syncBalance({address:i,chainId:f==null?void 0:f.id,chainNamespace:o}):await this.syncBalance({address:i,chainId:r==null?void 0:r.id,chainNamespace:o})}}async syncAccountInfo(e,s,r){const i=this.getCaipAddress(r),n=s||(i==null?void 0:i.split(":")[1]);if(!n)return;const o=`${r}:${n}:${e}`;this.setCaipAddress(o,r),await this.syncIdentity({address:e,chainId:n,chainNamespace:r})}async syncReownName(e,s){try{const r=await this.getReownName(e);if(r[0]){const i=r[0];this.setProfileName(i.name,s)}else this.setProfileName(null,s)}catch{this.setProfileName(null,s)}}syncConnectedWalletInfo(e){var i;const s=q.getConnectorId(e),r=Se.getProviderId(e);if(r===ps.CONNECTOR_TYPE_ANNOUNCED||r===ps.CONNECTOR_TYPE_INJECTED){if(s){const n=this.getConnectors().find(o=>o.id===s);if(n){const{info:o,name:a,imageUrl:c}=n,l=c||this.getConnectorImage(n);this.setConnectedWalletInfo({name:a,icon:l,...o},e)}}}else if(r===ps.CONNECTOR_TYPE_WALLET_CONNECT){const n=Se.getProvider(e);n!=null&&n.session&&this.setConnectedWalletInfo({...n.session.peer.metadata,name:n.session.peer.metadata.name,icon:(i=n.session.peer.metadata.icons)==null?void 0:i[0]},e)}else if(s&&s===z.CONNECTOR_ID.COINBASE){const n=this.getConnectors().find(o=>o.id===z.CONNECTOR_ID.COINBASE);this.setConnectedWalletInfo({name:"Coinbase Wallet",icon:this.getConnectorImage(n)},e)}}async syncBalance(e){!bl.getNetworksByNamespace(this.getCaipNetworks(),e.chainNamespace).find(r=>{var i;return r.id.toString()===((i=e.chainId)==null?void 0:i.toString())})||!e.chainId||await this.updateNativeBalance(e.address,e.chainId,e.chainNamespace)}async ready(){await this.readyPromise}async updateNativeBalance(e,s,r){const i=this.getAdapter(r),n=p.getCaipNetworkByNamespace(r,s);if(i){const o=await i.getBalance({address:e,chainId:s,caipNetwork:n,tokens:this.options.tokens});return this.setBalance(o.balance,o.symbol,r),o}}async initializeUniversalAdapter(){var r,i,n,o,a,c,l,h,u,d;const e=tE.createLogger((g,...w)=>{g&&this.handleAlertError(g),console.error(...w)}),s={projectId:(r=this.options)==null?void 0:r.projectId,metadata:{name:(i=this.options)!=null&&i.metadata?(n=this.options)==null?void 0:n.metadata.name:"",description:(o=this.options)!=null&&o.metadata?(a=this.options)==null?void 0:a.metadata.description:"",url:(c=this.options)!=null&&c.metadata?(l=this.options)==null?void 0:l.metadata.url:"",icons:(h=this.options)!=null&&h.metadata?(u=this.options)==null?void 0:u.metadata.icons:[""]},logger:e};O.setManualWCControl(!!((d=this.options)!=null&&d.manualWCControl)),this.universalProvider=this.options.universalProvider??await X0.init(s),this.listenWalletConnect()}listenWalletConnect(){this.universalProvider&&(this.universalProvider.on("display_uri",e=>{Y.setUri(e)}),this.universalProvider.on("connect",Y.finalizeWcConnection),this.universalProvider.on("disconnect",()=>{this.chainNamespaces.forEach(e=>{this.resetAccount(e)}),Y.resetWcConnection()}),this.universalProvider.on("chainChanged",e=>{const s=this.getCaipNetworks().find(i=>i.id==e),r=this.getCaipNetwork();if(!s){this.setUnsupportedNetwork(e);return}(r==null?void 0:r.id)!==(s==null?void 0:s.id)&&this.setCaipNetwork(s)}),this.universalProvider.on("session_event",e=>{if(an.isSessionEventData(e)){const{name:s,data:r}=e.params.event;s==="accountsChanged"&&Array.isArray(r)&&Z.isCaipAddress(r[0])&&this.syncAccount(cs.parseCaipAddress(r[0]))}}))}createUniversalProvider(){var e;return!this.universalProviderInitPromise&&Z.isClient()&&((e=this.options)!=null&&e.projectId)&&(this.universalProviderInitPromise=this.initializeUniversalAdapter()),this.universalProviderInitPromise}async getUniversalProvider(){if(!this.universalProvider)try{await this.createUniversalProvider()}catch(e){Pe.sendEvent({type:"error",event:"INTERNAL_SDK_ERROR",properties:{errorType:"UniversalProviderInitError",errorMessage:e instanceof Error?e.message:"Unknown",uncaught:!1}}),console.error("AppKit:getUniversalProvider - Cannot create provider",e)}return this.universalProvider}handleAlertError(e){const s=Object.entries(yr.UniversalProviderErrors).find(([,{message:a}])=>e.message.includes(a)),[r,i]=s??[],{message:n,alertErrorKey:o}=i??{};if(r&&n&&!this.reportedAlertErrors[r]){const a=yr.ALERT_ERRORS[o];a&&(Us.open(a,"error"),this.reportedAlertErrors[r]=!0)}}getAdapter(e){var s;if(e)return(s=this.chainAdapters)==null?void 0:s[e]}createAdapter(e){var i;if(!e)return;const s=e.namespace;if(!s)return;this.createClients();const r=e;r.namespace=s,r.construct({namespace:s,projectId:(i=this.options)==null?void 0:i.projectId,networks:this.getCaipNetworks()}),this.chainNamespaces.includes(s)||this.chainNamespaces.push(s),this.chainAdapters&&(this.chainAdapters[s]=r)}async open(e){if(await this.injectModalUi(),e!=null&&e.uri&&Y.setUri(e.uri),e!=null&&e.arguments)switch(e==null?void 0:e.view){case"Swap":return We.open({...e,data:{swap:e.arguments}})}return We.open(e)}async close(){await this.injectModalUi(),We.close()}setLoading(e,s){We.setLoading(e,s)}async disconnect(e){await Y.disconnect(e)}getSIWX(){return O.state.siwx}getError(){return""}getChainId(){var e;return(e=p.state.activeCaipNetwork)==null?void 0:e.id}async switchNetwork(e){const s=this.getCaipNetworks().find(r=>r.id===e.id);if(!s){Us.open(yr.ALERT_ERRORS.SWITCH_NETWORK_NOT_FOUND,"error");return}await p.switchActiveNetwork(s)}getWalletProvider(){return p.state.activeChain?Se.state.providers[p.state.activeChain]:null}getWalletProviderType(){return Se.getProviderId(p.state.activeChain)}subscribeProviders(e){return Se.subscribeProviders(e)}getThemeMode(){return ft.state.themeMode}getThemeVariables(){return ft.state.themeVariables}setThemeMode(e){ft.setThemeMode(e),Jh(ft.state.themeMode)}setTermsConditionsUrl(e){O.setTermsConditionsUrl(e)}setPrivacyPolicyUrl(e){O.setPrivacyPolicyUrl(e)}setThemeVariables(e){ft.setThemeVariables(e),EE(ft.state.themeVariables)}subscribeTheme(e){return ft.subscribe(e)}getWalletInfo(){return W.state.connectedWalletInfo}getAccount(e){var o;const s=q.getAuthConnector(e),r=p.getAccountData(e),i=p.state.activeChain,n=F.getConnectedConnectorId(e||i);if(r)return{allAccounts:r.allAccounts,caipAddress:r.caipAddress,address:Z.getPlainAddress(r.caipAddress),isConnected:!!r.caipAddress,status:r.status,embeddedWalletInfo:s&&n===z.CONNECTOR_ID.AUTH?{user:r.user?{...r.user,username:F.getConnectedSocialUsername()}:void 0,authProvider:r.socialProvider||"email",accountType:(o=r.preferredAccountTypes)==null?void 0:o[e||i],isSmartAccountDeployed:!!r.smartAccountDeployed}:void 0}}subscribeAccount(e,s){const r=()=>{const i=this.getAccount(s);i&&e(i)};s?p.subscribeChainProp("accountState",r,s):p.subscribe(r),q.subscribe(r)}subscribeNetwork(e){return p.subscribe(({activeCaipNetwork:s})=>{e({caipNetwork:s,chainId:s==null?void 0:s.id,caipNetworkId:s==null?void 0:s.caipNetworkId})})}subscribeWalletInfo(e){return W.subscribeKey("connectedWalletInfo",e)}subscribeShouldUpdateToAddress(e){W.subscribeKey("shouldUpdateToAddress",e)}subscribeCaipNetworkChange(e){p.subscribeKey("activeCaipNetwork",e)}getState(){return vs.state}subscribeState(e){return vs.subscribe(e)}showErrorMessage(e){Ut.showError(e)}showSuccessMessage(e){Ut.showSuccess(e)}getEvent(){return{...Pe.state}}subscribeEvents(e){return Pe.subscribe(e)}replace(e){re.replace(e)}redirect(e){re.push(e)}popTransactionStack(e){re.popTransactionStack(e)}isOpen(){return We.state.open}isTransactionStackEmpty(){return re.state.transactionStack.length===0}static getInstance(){return this.instance}updateFeatures(e){O.setFeatures(e)}updateRemoteFeatures(e){O.setRemoteFeatures(e)}updateOptions(e){const r={...O.state||{},...e};O.setOptions(r)}setConnectMethodsOrder(e){O.setConnectMethodsOrder(e)}setWalletFeaturesOrder(e){O.setWalletFeaturesOrder(e)}setCollapseWallets(e){O.setCollapseWallets(e)}setSocialsOrder(e){O.setSocialsOrder(e)}getConnectMethodsOrder(){return Mo.getConnectOrderMethod(O.state.features,q.getConnectors())}addNetwork(e,s){if(this.chainAdapters&&!this.chainAdapters[e])throw new Error(`Adapter for namespace ${e} doesn't exist`);const r=this.extendCaipNetwork(s,this.options);this.getCaipNetworks().find(i=>i.id===r.id)||p.addNetwork(r)}removeNetwork(e,s){if(this.chainAdapters&&!this.chainAdapters[e])throw new Error(`Adapter for namespace ${e} doesn't exist`);this.getCaipNetworks().find(i=>i.id===s)&&p.removeNetwork(e,s)}}let pl=!1;class Zh extends PE{async open(e){q.isConnected()||await super.open(e)}async close(){await super.close(),this.options.manualWCControl&&Y.finalizeWcConnection()}async syncIdentity(e){return Promise.resolve()}async syncBalance(e){return Promise.resolve()}async injectModalUi(){if(!pl&&Z.isClient()){if(await oa(()=>import("./basic-BhoXad_6.js"),__vite__mapDeps([0,1,2,3,4,5,6])),await oa(()=>import("./w3m-modal-CUwD6iiA.js"),__vite__mapDeps([7,1,2,3,4,5,6])),!document.querySelector("w3m-modal")){const s=document.createElement("w3m-modal");!O.state.disableAppend&&!O.state.enableEmbedded&&document.body.insertAdjacentElement("beforeend",s)}pl=!0}}}const OE="1.7.8";function TE(t){return new Zh({...t,basic:!0,sdkVersion:`html-core-${OE}`})}const oC=Object.freeze(Object.defineProperty({__proto__:null,AppKit:Zh,createAppKit:TE},Symbol.toStringTag,{value:"Module"}));export{Fe as A,Qe as B,p as C,Bo as D,Mr as E,tC as F,vt as G,We as M,O,re as R,fi as S,ft as T,Mo as W,W as a,Us as b,V as c,Rt as d,Il as e,Y as f,q as g,rn as h,rE as i,z as j,Ee as k,Z as l,Pe as m,Ut as n,F as o,eC as p,nC as q,oC as r,iC as s,Wh as t,Sr as u,on as v,sC as w,_e as x,rC as y,Xe as z};