@dcl/shop 0.1.0-29111888971.commit-e1b927a → 0.1.0-29111917255.commit-e6715c3

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 (181) hide show
  1. package/assets/{AnimatedBackground-XZF9g9Bk.js → AnimatedBackground-BYKnsBtz.js} +3 -3
  2. package/assets/{Assets-CZPTo1jO.js → Assets-ClVmauZ2.js} +1 -1
  3. package/assets/{Button-B2TDtyup.js → Button-CgZSqnGW.js} +1 -1
  4. package/assets/{Cart-DhU4_S6H.js → Cart-Up06p7ew.js} +1 -1
  5. package/assets/{CircularProgress-Cf__730y.js → CircularProgress-BbGH0RSH.js} +1 -1
  6. package/assets/{Collection-CRBxkkqX.js → Collection-DvK8DQsK.js} +1 -1
  7. package/assets/{ConstantsUtil-DrWe0yob.js → ConstantsUtil-CiDezLbv.js} +1 -1
  8. package/assets/{Creator-DO__19RD.js → Creator-ClUMhdS6.js} +1 -1
  9. package/assets/{ExchangeController-txwSQL2Z.js → ExchangeController-DdSsjFTm.js} +1 -1
  10. package/assets/{GetCredits-DS1z5pyp.js → GetCredits-7W0xZLwI.js} +2 -2
  11. package/assets/{HelpersUtil-CMysbO5y.js → HelpersUtil-CbFvbY-T.js} +1 -1
  12. package/assets/{ImportListings-ChNZ2UwM.js → ImportListings-tpyUcfqZ.js} +1 -1
  13. package/assets/ItemDetail-CZQ3QPE1.js +2 -0
  14. package/assets/{Market-Z4jp-uLb.js → Market-CRtp3AGM.js} +1 -1
  15. package/assets/{MenuItem-B4U0TYKf.js → MenuItem-BLQsL8Vh.js} +1 -1
  16. package/assets/{MyAssets-C7QdtDYF.js → MyAssets-Cp2z98Lz.js} +1 -1
  17. package/assets/{MyFavorites-Bu2IDcdJ.js → MyFavorites-_R79W8pO.js} +1 -1
  18. package/assets/{MyPurchases-CDUC3XzQ.js → MyPurchases-DJYHRbWz.js} +1 -1
  19. package/assets/{NetworkUtil-Ddexw9-U.js → NetworkUtil-DDES604E.js} +1 -1
  20. package/assets/{NotFound-D5sXjRPf.js → NotFound-6FTGg4R1.js} +1 -1
  21. package/assets/{RealCheckout-DBL3uxEj.js → RealCheckout-BemiXyZF.js} +1 -1
  22. package/assets/{ShopFooterInner-BHh4OUAv.js → ShopFooterInner-KJ2oezRg.js} +2 -2
  23. package/assets/{Success-BrvAPmP4.js → Success-CXjLiyYm.js} +1 -1
  24. package/assets/{SvgIcon-Cg5l4LDh.js → SvgIcon-DtxoFXOd.js} +1 -1
  25. package/assets/{SwapController-BDZMxnNb.js → SwapController-C07T-0ls.js} +1 -1
  26. package/assets/{TradeService-CkLYTYcJ.js → TradeService-D4PrM9vt.js} +1 -1
  27. package/assets/{W3MFrameProviderSingleton-D4DCXtQm.js → W3MFrameProviderSingleton-DXEpVsCm.js} +3 -3
  28. package/assets/{WebCryptoP256-OE37a6hF.js → WebCryptoP256-B1xyhPdr.js} +1 -1
  29. package/assets/{basic-SUHSB6nZ.js → basic-Dq4Wpic2.js} +1 -1
  30. package/assets/{biconomy-C6flCXA4.js → biconomy-BQtB5Ab0.js} +1 -1
  31. package/assets/{buy-YkuLG1h7.js → buy-6ORWjZW_.js} +1 -1
  32. package/assets/{buy-gasless-gRmZHjsE.js → buy-gasless-DL6o_Lwi.js} +1 -1
  33. package/assets/{ccip-7fqLW_t2.js → ccip-DgHj7djR.js} +1 -1
  34. package/assets/{ccip-ByQiZ_aq.js → ccip-Zo_y8Ko9.js} +1 -1
  35. package/assets/{chains-CMJ6lVMG.js → chains-Bk629xE3.js} +1 -1
  36. package/assets/{collection-2CKCNH2O.js → collection-B8w_ujSk.js} +1 -1
  37. package/assets/{common-GsSQn_vD.js → common-CEkVtB9E.js} +1 -1
  38. package/assets/{controller-BO0zre2A.js → controller-CNZZBumM.js} +2 -2
  39. package/assets/{core-D-mQUZ3X.js → core-C_RCjMc6.js} +4 -4
  40. package/assets/{custom-C6VO1Je_.js → custom-BM-_NC1p.js} +1 -1
  41. package/assets/{data-capture-DdxbO7dd.js → data-capture-Clu_u_4e.js} +1 -1
  42. package/assets/decimals-C7k-JLnD.js +1 -0
  43. package/assets/{decimals-Di7mGY-D.js → decimals-DYUDFeSV.js} +1 -1
  44. package/assets/{detectExtension-DsE82Ej6.js → detectExtension-b3FK4NnW.js} +1 -1
  45. package/assets/{email-BTEyDEk6.js → email-C0z3A7sK.js} +1 -1
  46. package/assets/{embedded-wallet-QGoIGdCB.js → embedded-wallet-COvvX2Qp.js} +1 -1
  47. package/assets/{engine-Bjifrd8K.js → engine-Cs_nlYqC.js} +1 -1
  48. package/assets/{estimate-l1-fee-Bqou6JLl.js → estimate-l1-fee-oTYMvZsv.js} +1 -1
  49. package/assets/eth_estimateGas-D2h2NKDU.js +1 -0
  50. package/assets/{eth_getStorageAt-B-cqm2CG.js → eth_getStorageAt-nxicedso.js} +1 -1
  51. package/assets/eth_getTransactionCount-CYYgSGiU.js +1 -0
  52. package/assets/{ethereum-CjiWK1L5.js → ethereum-CdeRZR9J.js} +1 -1
  53. package/assets/{ethers-DHDSyreX.js → ethers-JeCAM1sd.js} +1 -1
  54. package/assets/{extractIPFS-C5EI4cZz.js → extractIPFS-DzIizex4.js} +1 -1
  55. package/assets/{features-U-ULFF0v.js → features-Ck7HAsYI.js} +1 -1
  56. package/assets/{fetchTokenMetadata-DHc2WWGs.js → fetchTokenMetadata-CvdEl9__.js} +2 -2
  57. package/assets/{generateUtilityClasses-BAjjhm6X.js → generateUtilityClasses-C3jgMIyn.js} +1 -1
  58. package/assets/get-ecosystem-wallet-info-B4ca6uUn.js +1 -0
  59. package/assets/{getBalance-C8i1-K0c.js → getBalance-BS9M_tBF.js} +2 -2
  60. package/assets/{getInstalledModules-BXhbS0To.js → getInstalledModules-TJvbccgJ.js} +1 -1
  61. package/assets/{getNFT-CzHwZ4FU.js → getNFT-BlQFGY94.js} +2 -2
  62. package/assets/{getNFT-D3XSi6wm.js → getNFT-Xlc7XB2G.js} +1 -1
  63. package/assets/{hashTypedData-DX5YrpbP.js → hashTypedData-B7sBgfoL.js} +1 -1
  64. package/assets/{hashTypedData-BOc0w62Q.js → hashTypedData-CEYoWftx.js} +1 -1
  65. package/assets/{import-BulayqYM.js → import-J8FWHnju.js} +1 -1
  66. package/assets/{in-app-wallet-calls-BI0pU06-.js → in-app-wallet-calls-GDlqBGpw.js} +1 -1
  67. package/assets/{index-GAmNssSM.js → index-2dkhZZEZ.js} +1 -1
  68. package/assets/{index-BZ5hUBd_.js → index-6YdbHDXd.js} +1 -1
  69. package/assets/{index-CzfG6alx.js → index-B0PvzweT.js} +1 -1
  70. package/assets/{index-DQx-sY_c.js → index-B11b--Yh.js} +1 -1
  71. package/assets/{index-BKSTjS_b.js → index-B5Oqojt4.js} +1 -1
  72. package/assets/{index-D4VlTBkw.js → index-B5nwKjyJ.js} +1 -1
  73. package/assets/{index-n-cFV5ht.js → index-B6-wCRdo.js} +1 -1
  74. package/assets/{index-DIMSfymy.js → index-BA1ToKo5.js} +3 -3
  75. package/assets/{index-D3hzhbb8.js → index-BBTg_Taa.js} +1 -1
  76. package/assets/{index-CkHNiFzW.js → index-BLF3lLRE.js} +1 -1
  77. package/assets/{index--_rHc9Od.js → index-BNjQhTuO.js} +1 -1
  78. package/assets/{index-Qzch3HJ1.js → index-BNsmSCur.js} +1 -1
  79. package/assets/{index-BOQwd6ZB.js → index-BRAKTMPG.js} +1 -1
  80. package/assets/{index-BOwZsNrV.js → index-B_xrDWUL.js} +1 -1
  81. package/assets/{index-DhBdPYnK.js → index-BcvgfIV4.js} +1 -1
  82. package/assets/{index-CdfeQ7YK.js → index-BcyJUD4U.js} +1 -1
  83. package/assets/{index-ULMMROQ0.js → index-BeymNI6W.js} +1 -1
  84. package/assets/{index-DjPU0-Js.js → index-BgtBi25O.js} +1 -1
  85. package/assets/{index-CIPKmOlZ.js → index-Bj-x5N2U.js} +1 -1
  86. package/assets/{index-Pp2oEhTr.js → index-Blc7OGRU.js} +1 -1
  87. package/assets/{index-LSZxonl2.js → index-BnrCQ-kr.js} +1 -1
  88. package/assets/{index-jYazATJj.js → index-Bu2DcNS5.js} +1 -1
  89. package/assets/{index-C6FQ8I_Q.js → index-C9P6N44e.js} +2 -2
  90. package/assets/{index-C7-iTfFV.js → index-CI_HQD35.js} +25 -25
  91. package/assets/{index-C2U9pe20.js → index-CMib98th.js} +1 -1
  92. package/assets/{index-DacKA042.js → index-CPc95Sx-.js} +1 -1
  93. package/assets/{index-DShBCYos.js → index-CS7PjWbj.js} +3 -3
  94. package/assets/{index-BuKyqX4w.js → index-CSh-BHOv.js} +1 -1
  95. package/assets/{index-DV4p99KA.js → index-CZ8lEqAg.js} +2 -2
  96. package/assets/{index-CxyR8sie.js → index-ChHYiWiR.js} +1 -1
  97. package/assets/{index-CDMAFM2h.js → index-CkCZBr-g.js} +1 -1
  98. package/assets/{index-CMavzzI_.js → index-Cl4u62mB.js} +1 -1
  99. package/assets/{index-CbJmVQBN.js → index-CoACJ04N.js} +1 -1
  100. package/assets/{index-C2OMQVG4.js → index-CptRe6qL.js} +2 -2
  101. package/assets/{index-YfJF6hV4.js → index-CxQiq4b6.js} +1 -1
  102. package/assets/{index-CcQfGUgB.js → index-Cye62OPB.js} +1 -1
  103. package/assets/{index-BLQJ40Mi.js → index-D-lax9BR.js} +1 -1
  104. package/assets/{index-BlEd83Li.js → index-DA60UT_n.js} +1 -1
  105. package/assets/{index-CzFnbzvY.js → index-DFJdN6PH.js} +1 -1
  106. package/assets/{index-D5qOQwpy.js → index-DGSeBOvG.js} +1 -1
  107. package/assets/{index-DtrBN21c.js → index-DSUWwVug.js} +1 -1
  108. package/assets/{index-Eb-Zd0F2.js → index-DUnXGO0a.js} +1 -1
  109. package/assets/{index-CiIXwK1P.js → index-DWEAO5Zp.js} +1 -1
  110. package/assets/{index-BF6unOoT.js → index-DWk4e-hQ.js} +1 -1
  111. package/assets/{index-DJyoXp5I.js → index-DZ8SABwK.js} +1 -1
  112. package/assets/{index-2NUAW7ds.js → index-D_vsPbWD.js} +1 -1
  113. package/assets/{index-DlllSUoB.js → index-DjbM69kL.js} +1 -1
  114. package/assets/{index-CkVoCPEe.js → index-DnPCa8RK.js} +1 -1
  115. package/assets/{index-BNH6Xzon.js → index-DoS7CfZ4.js} +2 -2
  116. package/assets/{index-DOTYPGXa.js → index-Dv6YT5k2.js} +1 -1
  117. package/assets/{index-DIw62AgP.js → index-S-U9uSud.js} +1 -1
  118. package/assets/{index-IfYZnKCO.js → index-_AHcKVpB.js} +1 -1
  119. package/assets/{index-Bo6hVxzu.js → index-dE2OwwEn.js} +1 -1
  120. package/assets/{index-BaSqmd6J.js → index-pJLySSiV.js} +1 -1
  121. package/assets/{index-CENZ1Xjd.js → index-t3MAsdpb.js} +1 -1
  122. package/assets/{index-kxu93Of2.js → index-ulcskxUh.js} +1 -1
  123. package/assets/{index-DS8DYtub.js → index-yq7Vx7EH.js} +1 -1
  124. package/assets/{index.es-DnMpNe4m.js → index.es-BQrA1NgE.js} +4 -4
  125. package/assets/{index.es-IGCEipYb.js → index.es-CbOKB2xh.js} +1 -1
  126. package/assets/{index.es-Dk6KC5kj.js → index.es-Cz73nZm3.js} +1 -1
  127. package/assets/{localBatchGatewayRequest-BLJAP4fw.js → localBatchGatewayRequest-DVz1EzYT.js} +1 -1
  128. package/assets/{mana-rate-DkxpKYLQ.js → mana-rate-PT3JDtK4.js} +1 -1
  129. package/assets/{native-7uSYstXA.js → native-C_y7cRlS.js} +1 -1
  130. package/assets/network-Bdkbzo_l.js +1 -0
  131. package/assets/{networks-Bc_Uf_7y.js → networks-DVx7-Y5v.js} +1 -1
  132. package/assets/{onramp-DnhEoZl6.js → onramp-DWqw8mwD.js} +1 -1
  133. package/assets/{openzeppelin-DwFpqgXP.js → openzeppelin-B2NGugOR.js} +1 -1
  134. package/assets/{ownerOf-Qq7Or7yc.js → ownerOf-BoMFaGBI.js} +1 -1
  135. package/assets/{parseNft-B-POJxiL.js → parseNft-DdgcBV60.js} +2 -2
  136. package/assets/{parseSignature-ClLI6O4f.js → parseSignature-BMBhmj1o.js} +3 -3
  137. package/assets/{parseSignature-kOoafZEo.js → parseSignature-Cu4M83H5.js} +1 -1
  138. package/assets/{pay-with-exchange-BZR4RMBZ.js → pay-with-exchange-B3xXFySH.js} +1 -1
  139. package/assets/{qr-overlay-9WMDd_PO.js → qr-overlay-DXC6ldlf.js} +1 -1
  140. package/assets/{receive-CtJWuhGM.js → receive-C-M9SmxL.js} +1 -1
  141. package/assets/{resolveImplementation-BJatMhHh.js → resolveImplementation-D1Bqtnhr.js} +1 -1
  142. package/assets/{rpc-BA0W82l4.js → rpc-DE1f6rs1.js} +1 -1
  143. package/assets/{secp256k1-B82Rx-TY.js → secp256k1-B39Q-Q6x.js} +1 -1
  144. package/assets/{secp256k1-DFslM7tB.js → secp256k1-CrKymG_Q.js} +1 -1
  145. package/assets/{secp256k1-DHqlJ8nk.js → secp256k1-D1Tuv2c6.js} +1 -1
  146. package/assets/{send-DXVwWcB5.js → send-C1EU45CZ.js} +1 -1
  147. package/assets/{send-batch-transaction-D1j9aZww.js → send-batch-transaction-BTFORkZH.js} +1 -1
  148. package/assets/{send-eip712-transaction-CrryJAyV.js → send-eip712-transaction-CJ_pjExq.js} +2 -2
  149. package/assets/{send-gasless-transaction-B7YcLCGg.js → send-gasless-transaction-CHYN-ATV.js} +2 -2
  150. package/assets/{sendRawTransaction-DT-ObNx8.js → sendRawTransaction-YUhe5FDd.js} +3 -3
  151. package/assets/{serializeTransaction-DawhfTu0.js → serializeTransaction-xu35AVgP.js} +1 -1
  152. package/assets/{session-proposal-lgMupzDT.js → session-proposal-BZLBnV_x.js} +1 -1
  153. package/assets/{session-request-DacijEHD.js → session-request-mA9oQfs4.js} +2 -2
  154. package/assets/{sha256-BxR-wXll.js → sha256-De0VIEFf.js} +1 -1
  155. package/assets/{signing-CoPa7cSW.js → signing-DqVkCMNZ.js} +5 -5
  156. package/assets/{socials-CMh8u0Ej.js → socials-BImUXGbF.js} +1 -1
  157. package/assets/{swaps-B0Q00kKq.js → swaps-B8Tuo6Pt.js} +1 -1
  158. package/assets/{thirdweb-9c12J_EF.js → thirdweb-BPuxSwTj.js} +3 -3
  159. package/assets/{totalSupply-BCZn9Djj.js → totalSupply-Bbiy7170.js} +1 -1
  160. package/assets/{transactionReceipt-C2iQ3ozz.js → transactionReceipt-BcAWHNof.js} +1 -1
  161. package/assets/{transactions-Dqx74UWQ.js → transactions-N8K1pD5P.js} +1 -1
  162. package/assets/{useInfiniteGrid-DgSsqvQS.js → useInfiniteGrid-CVs5pP6I.js} +1 -1
  163. package/assets/{utils-nbkSUjEy.js → utils-BmX8TqzP.js} +1 -1
  164. package/assets/{verifyHash-BVbpPoSf.js → verifyHash-CnnSGyZz.js} +1 -1
  165. package/assets/{w3m-modal-DvCL5Oh_.js → w3m-modal-DJII43ig.js} +1 -1
  166. package/assets/{w3m-modal-CGHylzdj.js → w3m-modal-DWJdJGvu.js} +1 -1
  167. package/assets/{wait-for-tx-receipt-Dm2aAIs1.js → wait-for-tx-receipt-D0UsY_wi.js} +1 -1
  168. package/assets/{wallet-kind-vciDs8sO.js → wallet-kind-C-lIAMBM.js} +1 -1
  169. package/assets/{wallets-D8labJv_.js → wallets-KGduOTOw.js} +6 -6
  170. package/assets/{web-connector-C9MeCxtf.js → web-connector-Ca9PblTL.js} +3 -3
  171. package/assets/{writeContract-C3IzBPhR.js → writeContract-dj4TlIky.js} +1 -1
  172. package/assets/{zora-sepolia-BQEmh41Y.js → zora-sepolia-kNKNf7Kl.js} +1 -1
  173. package/assets/{zoraTestnet-CduWQC79.js → zoraTestnet-BhynxBH0.js} +1 -1
  174. package/index.html +8 -8
  175. package/package.json +2 -2
  176. package/assets/ItemDetail-Do5cjFW8.js +0 -2
  177. package/assets/decimals-ByIlBo-2.js +0 -1
  178. package/assets/eth_estimateGas-CarYiSgL.js +0 -1
  179. package/assets/eth_getTransactionCount-Dfx3JW2Q.js +0 -1
  180. package/assets/get-ecosystem-wallet-info-CWcGnKL4.js +0 -1
  181. package/assets/network-DsCGVBhE.js +0 -1
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/features-U-ULFF0v.js","assets/W3MFrameProviderSingleton-D4DCXtQm.js","assets/index-C7-iTfFV.js","assets/react-Vu6nbGi5.js","assets/ethers-DHDSyreX.js","assets/index-DCrqkiFN.css","assets/index-CdfeQ7YK.js","assets/index-C6FQ8I_Q.js","assets/browser-ponyfill-rND5WOqr.js","assets/NetworkUtil-Ddexw9-U.js","assets/embedded-wallet-QGoIGdCB.js","assets/lit-element-B3y9oplH.js","assets/class-map-CxwNmq0D.js","assets/index-BOQwd6ZB.js","assets/index--_rHc9Od.js","assets/ref-BsAZ42-h.js","assets/async-directive-BRxn_Py3.js","assets/index-CbJmVQBN.js","assets/HelpersUtil-CMysbO5y.js","assets/ConstantsUtil-DrWe0yob.js","assets/index-LSZxonl2.js","assets/index-YfJF6hV4.js","assets/index-BZ5hUBd_.js","assets/index-D3hzhbb8.js","assets/index-CDMAFM2h.js","assets/NavigationUtil-DmfK5sOV.js","assets/index-Pp2oEhTr.js","assets/index-nibyPLVP.js","assets/index-jYazATJj.js","assets/index.es-IGCEipYb.js","assets/email-BTEyDEk6.js","assets/index-DhBdPYnK.js","assets/index-ULMMROQ0.js","assets/socials-CMh8u0Ej.js","assets/index-kxu93Of2.js","assets/index-DIw62AgP.js","assets/index-Eb-Zd0F2.js","assets/browser-DHYOtFa8.js","assets/index-CMavzzI_.js","assets/swaps-B0Q00kKq.js","assets/index-D5qOQwpy.js","assets/SwapController-BDZMxnNb.js","assets/index-C2U9pe20.js","assets/MathUtil-BGCe3rZ3.js","assets/send-DXVwWcB5.js","assets/index-CzfG6alx.js","assets/index-IfYZnKCO.js","assets/index-BF6unOoT.js","assets/index-CzFnbzvY.js","assets/receive-CtJWuhGM.js","assets/onramp-DnhEoZl6.js","assets/index-BLQJ40Mi.js","assets/index-CkVoCPEe.js","assets/index-DtrBN21c.js","assets/pay-with-exchange-BZR4RMBZ.js","assets/ExchangeController-txwSQL2Z.js","assets/transactions-Dqx74UWQ.js","assets/index-2NUAW7ds.js","assets/index-DS8DYtub.js","assets/index-DlllSUoB.js","assets/index-CkHNiFzW.js","assets/data-capture-DdxbO7dd.js","assets/index-DJyoXp5I.js","assets/index-Bo6hVxzu.js","assets/w3m-modal-CGHylzdj.js"])))=>i.map(i=>d[i]);
2
- var Ud=Object.defineProperty;var Bd=(s,e,t)=>e in s?Ud(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var W=(s,e,t)=>Bd(s,typeof e!="symbol"?e+"":e,t);import{F as ie,_ as Ze}from"./index-C7-iTfFV.js";import{j as Dd,B as Lr,z as _s,ad as oh,C as O,ae as Ld,O as z,e as Md,i as qd,p as jd,af as ea,ag as ah,ah as ft,ai as pt,a1 as Ds,a8 as Fd,ac as zd,b as Oe,d as Ee,A as qe,F as je,$ as pe,l as co,o as he,t as ae,k as we,K as Kd,q as Hd,aj as La,ak as Vd,M as us,J as Ma,a7 as vn,E as Mt,_ as Wd,T as Ut,a9 as Pi,Z as Tr,y as Qe,a3 as Mr,R as Ls,al as qr,S as qa,am as Gd,u as En,W as ja,H as Yd,a5 as Zd,a6 as Jd}from"./W3MFrameProviderSingleton-D4DCXtQm.js";import{g as Q,p as Ki}from"./ethers-DHDSyreX.js";import{e as Qs,N as ta}from"./index-C6FQ8I_Q.js";import{m as fr,a as jr,s as sa,I as Si,e as Xd,g as j,h as ls,C as Qd,j as ef,k as lo,n as tf,c as qt,r as Ai,o as ia,q as sf,t as ra,u as na,b as Ji,P as Fa,Q as rf,v as nf,w as Fs,f as ch,x as Zt,y as Dt,z as ds,l as of}from"./index-Pp2oEhTr.js";import{c as af,a as cf,k as lf,d as hf,s as uf,g as za}from"./index-nibyPLVP.js";import{f as xt,t as nt,c as Hi,b as rr,a as df,d as ff}from"./index-jYazATJj.js";import"./index-CdfeQ7YK.js";import{f as lh}from"./index.es-IGCEipYb.js";import{a as Ss,r as Lt}from"./lit-element-B3y9oplH.js";import{au as J,ao as Ka,az as pf}from"./NetworkUtil-Ddexw9-U.js";const Vi={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"}]},ho={id:"USD",payment_method_limits:[{id:"card",min:"10.00",max:"7500.00"},{id:"ach_bank_account",min:"10.00",max:"25000.00"}]},gf={providers:oh,selectedProvider:null,error:null,purchaseCurrency:Vi,paymentCurrency:ho,purchaseCurrencies:[Vi],paymentCurrencies:[],quotesLoading:!1},re=jd(gf),yf={state:re,subscribe(s){return qd(re,()=>s(re))},subscribeKey(s,e){return Md(re,s,e)},setSelectedProvider(s){var e,t;if(s&&s.name==="meld"){const i=O.state.activeChain,r=i===J.CHAIN.SOLANA?"SOL":"USDC",n=i?((t=(e=O.state.chains.get(i))==null?void 0:e.accountState)==null?void 0:t.address)??"":"",o=new URL(s.url);o.searchParams.append("publicKey",Ld),o.searchParams.append("destinationCurrencyCode",r),o.searchParams.append("walletAddress",n),o.searchParams.append("externalCustomerId",z.state.projectId),re.selectedProvider={...s,url:o.toString()}}else re.selectedProvider=s},setOnrampProviders(s){if(Array.isArray(s)&&s.every(e=>typeof e=="string")){const e=s,t=oh.filter(i=>e.includes(i.name));re.providers=t}else re.providers=[]},setPurchaseCurrency(s){re.purchaseCurrency=s},setPaymentCurrency(s){re.paymentCurrency=s},setPurchaseAmount(s){uo.state.purchaseAmount=s},setPaymentAmount(s){uo.state.paymentAmount=s},async getAvailableCurrencies(){const s=await Lr.getOnrampOptions();re.purchaseCurrencies=s.purchaseCurrencies,re.paymentCurrencies=s.paymentCurrencies,re.paymentCurrency=s.paymentCurrencies[0]||ho,re.purchaseCurrency=s.purchaseCurrencies[0]||Vi,await _s.fetchCurrencyImages(s.paymentCurrencies.map(e=>e.id)),await _s.fetchTokenImages(s.purchaseCurrencies.map(e=>e.symbol))},async getQuote(){var s,e;re.quotesLoading=!0;try{const t=await Lr.getOnrampQuote({purchaseCurrency:re.purchaseCurrency,paymentCurrency:re.paymentCurrency,amount:((s=re.paymentAmount)==null?void 0:s.toString())||"0",network:(e=re.purchaseCurrency)==null?void 0:e.symbol});return re.quotesLoading=!1,re.purchaseAmount=Number(t==null?void 0:t.purchaseAmount.amount),t}catch(t){return re.error=t.message,re.quotesLoading=!1,null}finally{re.quotesLoading=!1}},resetState(){re.selectedProvider=null,re.error=null,re.purchaseCurrency=Vi,re.paymentCurrency=ho,re.purchaseCurrencies=[Vi],re.paymentCurrencies=[],re.paymentAmount=void 0,re.purchaseAmount=void 0,re.quotesLoading=!1}},uo=Dd(yf);function mf(s){return!s||typeof s.then!="function"?Promise.resolve(s):s}function _e(s,...e){try{return mf(s(...e))}catch(t){return Promise.reject(t)}}function wf(s){const e=typeof s;return s===null||e!=="object"&&e!=="function"}function bf(s){const e=Object.getPrototypeOf(s);return!e||e.isPrototypeOf(Object)}function $r(s){if(wf(s))return String(s);if(bf(s)||Array.isArray(s))return JSON.stringify(s);if(typeof s.toJSON=="function")return $r(s.toJSON());throw new Error("[unstorage] Cannot stringify value!")}const fo="base64:";function vf(s){return typeof s=="string"?s:fo+If(s)}function Ef(s){return typeof s!="string"||!s.startsWith(fo)?s:xf(s.slice(fo.length))}function xf(s){return globalThis.Buffer?ie.from(s,"base64"):Uint8Array.from(globalThis.atob(s),e=>e.codePointAt(0))}function If(s){return globalThis.Buffer?ie.from(s).toString("base64"):globalThis.btoa(String.fromCodePoint(...s))}function Je(s){var e;return s&&((e=s.split("?")[0])==null?void 0:e.replace(/[/\\]/g,":").replace(/:+/g,":").replace(/^:|:$/g,""))||""}function Sf(...s){return Je(s.join(":"))}function pr(s){return s=Je(s),s?s+":":""}function Af(s,e){if(e===void 0)return!0;let t=0,i=s.indexOf(":");for(;i>-1;)t++,i=s.indexOf(":",i+1);return t<=e}function Cf(s,e){return e?s.startsWith(e)&&s[s.length-1]!=="$":s[s.length-1]!=="$"}const _f="memory",Pf=()=>{const s=new Map;return{name:_f,getInstance:()=>s,hasItem(e){return s.has(e)},getItem(e){return s.get(e)??null},getItemRaw(e){return s.get(e)??null},setItem(e,t){s.set(e,t)},setItemRaw(e,t){s.set(e,t)},removeItem(e){s.delete(e)},getKeys(){return[...s.keys()]},clear(){s.clear()},dispose(){s.clear()}}};function Of(s={}){const e={mounts:{"":s.driver||Pf()},mountpoints:[""],watching:!1,watchListeners:[],unwatch:{}},t=l=>{for(const h of e.mountpoints)if(l.startsWith(h))return{base:h,relativeKey:l.slice(h.length),driver:e.mounts[h]};return{base:"",relativeKey:l,driver:e.mounts[""]}},i=(l,h)=>e.mountpoints.filter(u=>u.startsWith(l)||h&&l.startsWith(u)).map(u=>({relativeBase:l.length>u.length?l.slice(u.length):void 0,mountpoint:u,driver:e.mounts[u]})),r=(l,h)=>{if(e.watching){h=Je(h);for(const u of e.watchListeners)u(l,h)}},n=async()=>{if(!e.watching){e.watching=!0;for(const l in e.mounts)e.unwatch[l]=await Ha(e.mounts[l],r,l)}},o=async()=>{if(e.watching){for(const l in e.unwatch)await e.unwatch[l]();e.unwatch={},e.watching=!1}},a=(l,h,u)=>{const d=new Map,f=p=>{let g=d.get(p.base);return g||(g={driver:p.driver,base:p.base,items:[]},d.set(p.base,g)),g};for(const p of l){const g=typeof p=="string",m=Je(g?p:p.key),S=g?void 0:p.value,k=g||!p.options?h:{...h,...p.options},I=t(m);f(I).items.push({key:m,value:S,relativeKey:I.relativeKey,options:k})}return Promise.all([...d.values()].map(p=>u(p))).then(p=>p.flat())},c={hasItem(l,h={}){l=Je(l);const{relativeKey:u,driver:d}=t(l);return _e(d.hasItem,u,h)},getItem(l,h={}){l=Je(l);const{relativeKey:u,driver:d}=t(l);return _e(d.getItem,u,h).then(f=>fr(f))},getItems(l,h={}){return a(l,h,u=>u.driver.getItems?_e(u.driver.getItems,u.items.map(d=>({key:d.relativeKey,options:d.options})),h).then(d=>d.map(f=>({key:Sf(u.base,f.key),value:fr(f.value)}))):Promise.all(u.items.map(d=>_e(u.driver.getItem,d.relativeKey,d.options).then(f=>({key:d.key,value:fr(f)})))))},getItemRaw(l,h={}){l=Je(l);const{relativeKey:u,driver:d}=t(l);return d.getItemRaw?_e(d.getItemRaw,u,h):_e(d.getItem,u,h).then(f=>Ef(f))},async setItem(l,h,u={}){if(h===void 0)return c.removeItem(l);l=Je(l);const{relativeKey:d,driver:f}=t(l);f.setItem&&(await _e(f.setItem,d,$r(h),u),f.watch||r("update",l))},async setItems(l,h){await a(l,h,async u=>{if(u.driver.setItems)return _e(u.driver.setItems,u.items.map(d=>({key:d.relativeKey,value:$r(d.value),options:d.options})),h);u.driver.setItem&&await Promise.all(u.items.map(d=>_e(u.driver.setItem,d.relativeKey,$r(d.value),d.options)))})},async setItemRaw(l,h,u={}){if(h===void 0)return c.removeItem(l,u);l=Je(l);const{relativeKey:d,driver:f}=t(l);if(f.setItemRaw)await _e(f.setItemRaw,d,h,u);else if(f.setItem)await _e(f.setItem,d,vf(h),u);else return;f.watch||r("update",l)},async removeItem(l,h={}){typeof h=="boolean"&&(h={removeMeta:h}),l=Je(l);const{relativeKey:u,driver:d}=t(l);d.removeItem&&(await _e(d.removeItem,u,h),(h.removeMeta||h.removeMata)&&await _e(d.removeItem,u+"$",h),d.watch||r("remove",l))},async getMeta(l,h={}){typeof h=="boolean"&&(h={nativeOnly:h}),l=Je(l);const{relativeKey:u,driver:d}=t(l),f=Object.create(null);if(d.getMeta&&Object.assign(f,await _e(d.getMeta,u,h)),!h.nativeOnly){const p=await _e(d.getItem,u+"$",h).then(g=>fr(g));p&&typeof p=="object"&&(typeof p.atime=="string"&&(p.atime=new Date(p.atime)),typeof p.mtime=="string"&&(p.mtime=new Date(p.mtime)),Object.assign(f,p))}return f},setMeta(l,h,u={}){return this.setItem(l+"$",h,u)},removeMeta(l,h={}){return this.removeItem(l+"$",h)},async getKeys(l,h={}){var m;l=pr(l);const u=i(l,!0);let d=[];const f=[];let p=!0;for(const S of u){(m=S.driver.flags)!=null&&m.maxDepth||(p=!1);const k=await _e(S.driver.getKeys,S.relativeBase,h);for(const I of k){const E=S.mountpoint+Je(I);d.some(N=>E.startsWith(N))||f.push(E)}d=[S.mountpoint,...d.filter(I=>!I.startsWith(S.mountpoint))]}const g=h.maxDepth!==void 0&&!p;return f.filter(S=>(!g||Af(S,h.maxDepth))&&Cf(S,l))},async clear(l,h={}){l=pr(l),await Promise.all(i(l,!1).map(async u=>{if(u.driver.clear)return _e(u.driver.clear,u.relativeBase,h);if(u.driver.removeItem){const d=await u.driver.getKeys(u.relativeBase||"",h);return Promise.all(d.map(f=>u.driver.removeItem(f,h)))}}))},async dispose(){await Promise.all(Object.values(e.mounts).map(l=>Va(l)))},async watch(l){return await n(),e.watchListeners.push(l),async()=>{e.watchListeners=e.watchListeners.filter(h=>h!==l),e.watchListeners.length===0&&await o()}},async unwatch(){e.watchListeners=[],await o()},mount(l,h){if(l=pr(l),l&&e.mounts[l])throw new Error(`already mounted at ${l}`);return l&&(e.mountpoints.push(l),e.mountpoints.sort((u,d)=>d.length-u.length)),e.mounts[l]=h,e.watching&&Promise.resolve(Ha(h,r,l)).then(u=>{e.unwatch[l]=u}).catch(console.error),c},async unmount(l,h=!0){var u,d;l=pr(l),!(!l||!e.mounts[l])&&(e.watching&&l in e.unwatch&&((d=(u=e.unwatch)[l])==null||d.call(u),delete e.unwatch[l]),h&&await Va(e.mounts[l]),e.mountpoints=e.mountpoints.filter(f=>f!==l),delete e.mounts[l])},getMount(l=""){l=Je(l)+":";const h=t(l);return{driver:h.driver,base:h.base}},getMounts(l="",h={}){return l=Je(l),i(l,h.parents).map(d=>({driver:d.driver,base:d.mountpoint}))},keys:(l,h={})=>c.getKeys(l,h),get:(l,h={})=>c.getItem(l,h),set:(l,h,u={})=>c.setItem(l,h,u),has:(l,h={})=>c.hasItem(l,h),del:(l,h={})=>c.removeItem(l,h),remove:(l,h={})=>c.removeItem(l,h)};return c}function Ha(s,e,t){return s.watch?s.watch((i,r)=>e(i,t+r)):()=>{}}async function Va(s){typeof s.dispose=="function"&&await _e(s.dispose)}const Nf="idb-keyval";var Tf=(s={})=>{const e=s.base&&s.base.length>0?`${s.base}:`:"",t=r=>e+r;let i;return s.dbName&&s.storeName&&(i=af(s.dbName,s.storeName)),{name:Nf,options:s,async hasItem(r){return!(typeof await za(t(r),i)>"u")},async getItem(r){return await za(t(r),i)??null},setItem(r,n){return uf(t(r),n,i)},removeItem(r){return hf(t(r),i)},getKeys(){return lf(i)},clear(){return cf(i)}}};const $f="WALLET_CONNECT_V2_INDEXED_DB",kf="keyvaluestorage";let Rf=class{constructor(){this.indexedDb=Of({driver:Tf({dbName:$f,storeName:kf})})}async getKeys(){return this.indexedDb.getKeys()}async getEntries(){return(await this.indexedDb.getItems(await this.indexedDb.getKeys())).map(e=>[e.key,e.value])}async getItem(e){const t=await this.indexedDb.getItem(e);if(t!==null)return t}async setItem(e,t){await this.indexedDb.setItem(e,sa(t))}async removeItem(e){await this.indexedDb.removeItem(e)}};var xn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof Q<"u"?Q:typeof self<"u"?self:{},kr={exports:{}};(function(){let s;function e(){}s=e,s.prototype.getItem=function(t){return this.hasOwnProperty(t)?String(this[t]):null},s.prototype.setItem=function(t,i){this[t]=String(i)},s.prototype.removeItem=function(t){delete this[t]},s.prototype.clear=function(){const t=this;Object.keys(t).forEach(function(i){t[i]=void 0,delete t[i]})},s.prototype.key=function(t){return t=t||0,Object.keys(this)[t]},s.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),typeof xn<"u"&&xn.localStorage?kr.exports=xn.localStorage:typeof window<"u"&&window.localStorage?kr.exports=window.localStorage:kr.exports=new e})();function Uf(s){var e;return[s[0],jr((e=s[1])!=null?e:"")]}let Bf=class{constructor(){this.localStorage=kr.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(Uf)}async getItem(e){const t=this.localStorage.getItem(e);if(t!==null)return jr(t)}async setItem(e,t){this.localStorage.setItem(e,sa(t))}async removeItem(e){this.localStorage.removeItem(e)}};const Df="wc_storage_version",Wa=1,Lf=async(s,e,t)=>{const i=Df,r=await e.getItem(i);if(r&&r>=Wa){t(e);return}const n=await s.getKeys();if(!n.length){t(e);return}const o=[];for(;n.length;){const a=n.shift();if(!a)continue;const c=a.toLowerCase();if(c.includes("wc@")||c.includes("walletconnect")||c.includes("wc_")||c.includes("wallet_connect")){const l=await s.getItem(a);await e.setItem(a,l),o.push(a)}}await e.setItem(i,Wa),t(e),Mf(s,o)},Mf=async(s,e)=>{e.length&&e.forEach(async t=>{await s.removeItem(t)})};let qf=class{constructor(){this.initialized=!1,this.setInitialized=t=>{this.storage=t,this.initialized=!0};const e=new Bf;this.storage=e;try{const t=new Rf;Lf(e,t,this.setInitialized)}catch{this.initialized=!0}}async getKeys(){return await this.initialize(),this.storage.getKeys()}async getEntries(){return await this.initialize(),this.storage.getEntries()}async getItem(e){return await this.initialize(),this.storage.getItem(e)}async setItem(e,t){return await this.initialize(),this.storage.setItem(e,t)}async removeItem(e){return await this.initialize(),this.storage.removeItem(e)}async initialize(){this.initialized||await new Promise(e=>{const t=setInterval(()=>{this.initialized&&(clearInterval(t),e())},20)})}};var jf=Object.defineProperty,Ff=(s,e,t)=>e in s?jf(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Ga=(s,e,t)=>Ff(s,typeof e!="symbol"?e+"":e,t);class zf extends Si{constructor(e){super(),this.opts=e,Ga(this,"protocol","wc"),Ga(this,"version",2)}}var Kf=Object.defineProperty,Hf=(s,e,t)=>e in s?Kf(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Vf=(s,e,t)=>Hf(s,e+"",t);class Wf extends Si{constructor(e,t){super(),this.core=e,this.logger=t,Vf(this,"records",new Map)}}let Gf=class{constructor(e,t){this.logger=e,this.core=t}};class Yf extends Si{constructor(e,t){super(),this.relayer=e,this.logger=t}}let Zf=class extends Si{constructor(e){super()}},Jf=class{constructor(e,t,i,r){this.core=e,this.logger=t,this.name=i}},Xf=class extends Si{constructor(e,t){super(),this.relayer=e,this.logger=t}},Qf=class extends Si{constructor(e,t){super(),this.core=e,this.logger=t}},ep=class{constructor(e,t,i){this.core=e,this.logger=t,this.store=i}};class tp{constructor(e,t){this.projectId=e,this.logger=t}}class sp{constructor(e,t,i){this.core=e,this.logger=t,this.telemetryEnabled=i}}var ip=Object.defineProperty,rp=(s,e,t)=>e in s?ip(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Ya=(s,e,t)=>rp(s,typeof e!="symbol"?e+"":e,t);let np=class{constructor(e){this.opts=e,Ya(this,"protocol","wc"),Ya(this,"version",2)}},op=class{constructor(e){this.client=e}};const ap="0.1.1";function cp(){return ap}class me extends Error{constructor(e,t={}){const i=(()=>{var c;if(t.cause instanceof me){if(t.cause.details)return t.cause.details;if(t.cause.shortMessage)return t.cause.shortMessage}return t.cause&&"details"in t.cause&&typeof t.cause.details=="string"?t.cause.details:(c=t.cause)!=null&&c.message?t.cause.message:t.details})(),r=t.cause instanceof me&&t.cause.docsPath||t.docsPath,o=`https://oxlib.sh${r??""}`,a=[e||"An error occurred.",...t.metaMessages?["",...t.metaMessages]:[],...i||r?["",i?`Details: ${i}`:void 0,r?`See: ${o}`:void 0]:[]].filter(c=>typeof c=="string").join(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/features-Ck7HAsYI.js","assets/W3MFrameProviderSingleton-DXEpVsCm.js","assets/index-CI_HQD35.js","assets/react-Vu6nbGi5.js","assets/ethers-JeCAM1sd.js","assets/index-DCrqkiFN.css","assets/index-BcyJUD4U.js","assets/index-C9P6N44e.js","assets/browser-ponyfill-rND5WOqr.js","assets/NetworkUtil-DDES604E.js","assets/embedded-wallet-COvvX2Qp.js","assets/lit-element-B3y9oplH.js","assets/class-map-CxwNmq0D.js","assets/index-BRAKTMPG.js","assets/index-BNjQhTuO.js","assets/ref-BsAZ42-h.js","assets/async-directive-BRxn_Py3.js","assets/index-CoACJ04N.js","assets/HelpersUtil-CbFvbY-T.js","assets/ConstantsUtil-CiDezLbv.js","assets/index-BnrCQ-kr.js","assets/index-CxQiq4b6.js","assets/index-6YdbHDXd.js","assets/index-BBTg_Taa.js","assets/index-CkCZBr-g.js","assets/NavigationUtil-DmfK5sOV.js","assets/index-Blc7OGRU.js","assets/index-nibyPLVP.js","assets/index-Bu2DcNS5.js","assets/index.es-CbOKB2xh.js","assets/email-C0z3A7sK.js","assets/index-BcvgfIV4.js","assets/index-BeymNI6W.js","assets/socials-BImUXGbF.js","assets/index-ulcskxUh.js","assets/index-S-U9uSud.js","assets/index-DUnXGO0a.js","assets/browser-DHYOtFa8.js","assets/index-Cl4u62mB.js","assets/swaps-B8Tuo6Pt.js","assets/index-DGSeBOvG.js","assets/SwapController-C07T-0ls.js","assets/index-CMib98th.js","assets/MathUtil-BGCe3rZ3.js","assets/send-C1EU45CZ.js","assets/index-B0PvzweT.js","assets/index-_AHcKVpB.js","assets/index-DWk4e-hQ.js","assets/index-DFJdN6PH.js","assets/receive-C-M9SmxL.js","assets/onramp-DWqw8mwD.js","assets/index-D-lax9BR.js","assets/index-DnPCa8RK.js","assets/index-DSUWwVug.js","assets/pay-with-exchange-B3xXFySH.js","assets/ExchangeController-DdSsjFTm.js","assets/transactions-N8K1pD5P.js","assets/index-D_vsPbWD.js","assets/index-yq7Vx7EH.js","assets/index-DjbM69kL.js","assets/index-BLF3lLRE.js","assets/data-capture-Clu_u_4e.js","assets/index-DZ8SABwK.js","assets/index-dE2OwwEn.js","assets/w3m-modal-DWJdJGvu.js"])))=>i.map(i=>d[i]);
2
+ var Ud=Object.defineProperty;var Bd=(s,e,t)=>e in s?Ud(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var W=(s,e,t)=>Bd(s,typeof e!="symbol"?e+"":e,t);import{F as ie,_ as Ze}from"./index-CI_HQD35.js";import{j as Dd,B as Lr,z as _s,ad as oh,C as O,ae as Ld,O as z,e as Md,i as qd,p as jd,af as ea,ag as ah,ah as ft,ai as pt,a1 as Ds,a8 as Fd,ac as zd,b as Oe,d as Ee,A as qe,F as je,$ as pe,l as co,o as he,t as ae,k as we,K as Kd,q as Hd,aj as La,ak as Vd,M as us,J as Ma,a7 as vn,E as Mt,_ as Wd,T as Ut,a9 as Pi,Z as Tr,y as Qe,a3 as Mr,R as Ls,al as qr,S as qa,am as Gd,u as En,W as ja,H as Yd,a5 as Zd,a6 as Jd}from"./W3MFrameProviderSingleton-DXEpVsCm.js";import{g as Q,p as Ki}from"./ethers-JeCAM1sd.js";import{e as Qs,N as ta}from"./index-C9P6N44e.js";import{m as fr,a as jr,s as sa,I as Si,e as Xd,g as j,h as ls,C as Qd,j as ef,k as lo,n as tf,c as qt,r as Ai,o as ia,q as sf,t as ra,u as na,b as Ji,P as Fa,Q as rf,v as nf,w as Fs,f as ch,x as Zt,y as Dt,z as ds,l as of}from"./index-Blc7OGRU.js";import{c as af,a as cf,k as lf,d as hf,s as uf,g as za}from"./index-nibyPLVP.js";import{f as xt,t as nt,c as Hi,b as rr,a as df,d as ff}from"./index-Bu2DcNS5.js";import"./index-BcyJUD4U.js";import{f as lh}from"./index.es-CbOKB2xh.js";import{a as Ss,r as Lt}from"./lit-element-B3y9oplH.js";import{au as J,ao as Ka,az as pf}from"./NetworkUtil-DDES604E.js";const Vi={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"}]},ho={id:"USD",payment_method_limits:[{id:"card",min:"10.00",max:"7500.00"},{id:"ach_bank_account",min:"10.00",max:"25000.00"}]},gf={providers:oh,selectedProvider:null,error:null,purchaseCurrency:Vi,paymentCurrency:ho,purchaseCurrencies:[Vi],paymentCurrencies:[],quotesLoading:!1},re=jd(gf),yf={state:re,subscribe(s){return qd(re,()=>s(re))},subscribeKey(s,e){return Md(re,s,e)},setSelectedProvider(s){var e,t;if(s&&s.name==="meld"){const i=O.state.activeChain,r=i===J.CHAIN.SOLANA?"SOL":"USDC",n=i?((t=(e=O.state.chains.get(i))==null?void 0:e.accountState)==null?void 0:t.address)??"":"",o=new URL(s.url);o.searchParams.append("publicKey",Ld),o.searchParams.append("destinationCurrencyCode",r),o.searchParams.append("walletAddress",n),o.searchParams.append("externalCustomerId",z.state.projectId),re.selectedProvider={...s,url:o.toString()}}else re.selectedProvider=s},setOnrampProviders(s){if(Array.isArray(s)&&s.every(e=>typeof e=="string")){const e=s,t=oh.filter(i=>e.includes(i.name));re.providers=t}else re.providers=[]},setPurchaseCurrency(s){re.purchaseCurrency=s},setPaymentCurrency(s){re.paymentCurrency=s},setPurchaseAmount(s){uo.state.purchaseAmount=s},setPaymentAmount(s){uo.state.paymentAmount=s},async getAvailableCurrencies(){const s=await Lr.getOnrampOptions();re.purchaseCurrencies=s.purchaseCurrencies,re.paymentCurrencies=s.paymentCurrencies,re.paymentCurrency=s.paymentCurrencies[0]||ho,re.purchaseCurrency=s.purchaseCurrencies[0]||Vi,await _s.fetchCurrencyImages(s.paymentCurrencies.map(e=>e.id)),await _s.fetchTokenImages(s.purchaseCurrencies.map(e=>e.symbol))},async getQuote(){var s,e;re.quotesLoading=!0;try{const t=await Lr.getOnrampQuote({purchaseCurrency:re.purchaseCurrency,paymentCurrency:re.paymentCurrency,amount:((s=re.paymentAmount)==null?void 0:s.toString())||"0",network:(e=re.purchaseCurrency)==null?void 0:e.symbol});return re.quotesLoading=!1,re.purchaseAmount=Number(t==null?void 0:t.purchaseAmount.amount),t}catch(t){return re.error=t.message,re.quotesLoading=!1,null}finally{re.quotesLoading=!1}},resetState(){re.selectedProvider=null,re.error=null,re.purchaseCurrency=Vi,re.paymentCurrency=ho,re.purchaseCurrencies=[Vi],re.paymentCurrencies=[],re.paymentAmount=void 0,re.purchaseAmount=void 0,re.quotesLoading=!1}},uo=Dd(yf);function mf(s){return!s||typeof s.then!="function"?Promise.resolve(s):s}function _e(s,...e){try{return mf(s(...e))}catch(t){return Promise.reject(t)}}function wf(s){const e=typeof s;return s===null||e!=="object"&&e!=="function"}function bf(s){const e=Object.getPrototypeOf(s);return!e||e.isPrototypeOf(Object)}function $r(s){if(wf(s))return String(s);if(bf(s)||Array.isArray(s))return JSON.stringify(s);if(typeof s.toJSON=="function")return $r(s.toJSON());throw new Error("[unstorage] Cannot stringify value!")}const fo="base64:";function vf(s){return typeof s=="string"?s:fo+If(s)}function Ef(s){return typeof s!="string"||!s.startsWith(fo)?s:xf(s.slice(fo.length))}function xf(s){return globalThis.Buffer?ie.from(s,"base64"):Uint8Array.from(globalThis.atob(s),e=>e.codePointAt(0))}function If(s){return globalThis.Buffer?ie.from(s).toString("base64"):globalThis.btoa(String.fromCodePoint(...s))}function Je(s){var e;return s&&((e=s.split("?")[0])==null?void 0:e.replace(/[/\\]/g,":").replace(/:+/g,":").replace(/^:|:$/g,""))||""}function Sf(...s){return Je(s.join(":"))}function pr(s){return s=Je(s),s?s+":":""}function Af(s,e){if(e===void 0)return!0;let t=0,i=s.indexOf(":");for(;i>-1;)t++,i=s.indexOf(":",i+1);return t<=e}function Cf(s,e){return e?s.startsWith(e)&&s[s.length-1]!=="$":s[s.length-1]!=="$"}const _f="memory",Pf=()=>{const s=new Map;return{name:_f,getInstance:()=>s,hasItem(e){return s.has(e)},getItem(e){return s.get(e)??null},getItemRaw(e){return s.get(e)??null},setItem(e,t){s.set(e,t)},setItemRaw(e,t){s.set(e,t)},removeItem(e){s.delete(e)},getKeys(){return[...s.keys()]},clear(){s.clear()},dispose(){s.clear()}}};function Of(s={}){const e={mounts:{"":s.driver||Pf()},mountpoints:[""],watching:!1,watchListeners:[],unwatch:{}},t=l=>{for(const h of e.mountpoints)if(l.startsWith(h))return{base:h,relativeKey:l.slice(h.length),driver:e.mounts[h]};return{base:"",relativeKey:l,driver:e.mounts[""]}},i=(l,h)=>e.mountpoints.filter(u=>u.startsWith(l)||h&&l.startsWith(u)).map(u=>({relativeBase:l.length>u.length?l.slice(u.length):void 0,mountpoint:u,driver:e.mounts[u]})),r=(l,h)=>{if(e.watching){h=Je(h);for(const u of e.watchListeners)u(l,h)}},n=async()=>{if(!e.watching){e.watching=!0;for(const l in e.mounts)e.unwatch[l]=await Ha(e.mounts[l],r,l)}},o=async()=>{if(e.watching){for(const l in e.unwatch)await e.unwatch[l]();e.unwatch={},e.watching=!1}},a=(l,h,u)=>{const d=new Map,f=p=>{let g=d.get(p.base);return g||(g={driver:p.driver,base:p.base,items:[]},d.set(p.base,g)),g};for(const p of l){const g=typeof p=="string",m=Je(g?p:p.key),S=g?void 0:p.value,k=g||!p.options?h:{...h,...p.options},I=t(m);f(I).items.push({key:m,value:S,relativeKey:I.relativeKey,options:k})}return Promise.all([...d.values()].map(p=>u(p))).then(p=>p.flat())},c={hasItem(l,h={}){l=Je(l);const{relativeKey:u,driver:d}=t(l);return _e(d.hasItem,u,h)},getItem(l,h={}){l=Je(l);const{relativeKey:u,driver:d}=t(l);return _e(d.getItem,u,h).then(f=>fr(f))},getItems(l,h={}){return a(l,h,u=>u.driver.getItems?_e(u.driver.getItems,u.items.map(d=>({key:d.relativeKey,options:d.options})),h).then(d=>d.map(f=>({key:Sf(u.base,f.key),value:fr(f.value)}))):Promise.all(u.items.map(d=>_e(u.driver.getItem,d.relativeKey,d.options).then(f=>({key:d.key,value:fr(f)})))))},getItemRaw(l,h={}){l=Je(l);const{relativeKey:u,driver:d}=t(l);return d.getItemRaw?_e(d.getItemRaw,u,h):_e(d.getItem,u,h).then(f=>Ef(f))},async setItem(l,h,u={}){if(h===void 0)return c.removeItem(l);l=Je(l);const{relativeKey:d,driver:f}=t(l);f.setItem&&(await _e(f.setItem,d,$r(h),u),f.watch||r("update",l))},async setItems(l,h){await a(l,h,async u=>{if(u.driver.setItems)return _e(u.driver.setItems,u.items.map(d=>({key:d.relativeKey,value:$r(d.value),options:d.options})),h);u.driver.setItem&&await Promise.all(u.items.map(d=>_e(u.driver.setItem,d.relativeKey,$r(d.value),d.options)))})},async setItemRaw(l,h,u={}){if(h===void 0)return c.removeItem(l,u);l=Je(l);const{relativeKey:d,driver:f}=t(l);if(f.setItemRaw)await _e(f.setItemRaw,d,h,u);else if(f.setItem)await _e(f.setItem,d,vf(h),u);else return;f.watch||r("update",l)},async removeItem(l,h={}){typeof h=="boolean"&&(h={removeMeta:h}),l=Je(l);const{relativeKey:u,driver:d}=t(l);d.removeItem&&(await _e(d.removeItem,u,h),(h.removeMeta||h.removeMata)&&await _e(d.removeItem,u+"$",h),d.watch||r("remove",l))},async getMeta(l,h={}){typeof h=="boolean"&&(h={nativeOnly:h}),l=Je(l);const{relativeKey:u,driver:d}=t(l),f=Object.create(null);if(d.getMeta&&Object.assign(f,await _e(d.getMeta,u,h)),!h.nativeOnly){const p=await _e(d.getItem,u+"$",h).then(g=>fr(g));p&&typeof p=="object"&&(typeof p.atime=="string"&&(p.atime=new Date(p.atime)),typeof p.mtime=="string"&&(p.mtime=new Date(p.mtime)),Object.assign(f,p))}return f},setMeta(l,h,u={}){return this.setItem(l+"$",h,u)},removeMeta(l,h={}){return this.removeItem(l+"$",h)},async getKeys(l,h={}){var m;l=pr(l);const u=i(l,!0);let d=[];const f=[];let p=!0;for(const S of u){(m=S.driver.flags)!=null&&m.maxDepth||(p=!1);const k=await _e(S.driver.getKeys,S.relativeBase,h);for(const I of k){const E=S.mountpoint+Je(I);d.some(N=>E.startsWith(N))||f.push(E)}d=[S.mountpoint,...d.filter(I=>!I.startsWith(S.mountpoint))]}const g=h.maxDepth!==void 0&&!p;return f.filter(S=>(!g||Af(S,h.maxDepth))&&Cf(S,l))},async clear(l,h={}){l=pr(l),await Promise.all(i(l,!1).map(async u=>{if(u.driver.clear)return _e(u.driver.clear,u.relativeBase,h);if(u.driver.removeItem){const d=await u.driver.getKeys(u.relativeBase||"",h);return Promise.all(d.map(f=>u.driver.removeItem(f,h)))}}))},async dispose(){await Promise.all(Object.values(e.mounts).map(l=>Va(l)))},async watch(l){return await n(),e.watchListeners.push(l),async()=>{e.watchListeners=e.watchListeners.filter(h=>h!==l),e.watchListeners.length===0&&await o()}},async unwatch(){e.watchListeners=[],await o()},mount(l,h){if(l=pr(l),l&&e.mounts[l])throw new Error(`already mounted at ${l}`);return l&&(e.mountpoints.push(l),e.mountpoints.sort((u,d)=>d.length-u.length)),e.mounts[l]=h,e.watching&&Promise.resolve(Ha(h,r,l)).then(u=>{e.unwatch[l]=u}).catch(console.error),c},async unmount(l,h=!0){var u,d;l=pr(l),!(!l||!e.mounts[l])&&(e.watching&&l in e.unwatch&&((d=(u=e.unwatch)[l])==null||d.call(u),delete e.unwatch[l]),h&&await Va(e.mounts[l]),e.mountpoints=e.mountpoints.filter(f=>f!==l),delete e.mounts[l])},getMount(l=""){l=Je(l)+":";const h=t(l);return{driver:h.driver,base:h.base}},getMounts(l="",h={}){return l=Je(l),i(l,h.parents).map(d=>({driver:d.driver,base:d.mountpoint}))},keys:(l,h={})=>c.getKeys(l,h),get:(l,h={})=>c.getItem(l,h),set:(l,h,u={})=>c.setItem(l,h,u),has:(l,h={})=>c.hasItem(l,h),del:(l,h={})=>c.removeItem(l,h),remove:(l,h={})=>c.removeItem(l,h)};return c}function Ha(s,e,t){return s.watch?s.watch((i,r)=>e(i,t+r)):()=>{}}async function Va(s){typeof s.dispose=="function"&&await _e(s.dispose)}const Nf="idb-keyval";var Tf=(s={})=>{const e=s.base&&s.base.length>0?`${s.base}:`:"",t=r=>e+r;let i;return s.dbName&&s.storeName&&(i=af(s.dbName,s.storeName)),{name:Nf,options:s,async hasItem(r){return!(typeof await za(t(r),i)>"u")},async getItem(r){return await za(t(r),i)??null},setItem(r,n){return uf(t(r),n,i)},removeItem(r){return hf(t(r),i)},getKeys(){return lf(i)},clear(){return cf(i)}}};const $f="WALLET_CONNECT_V2_INDEXED_DB",kf="keyvaluestorage";let Rf=class{constructor(){this.indexedDb=Of({driver:Tf({dbName:$f,storeName:kf})})}async getKeys(){return this.indexedDb.getKeys()}async getEntries(){return(await this.indexedDb.getItems(await this.indexedDb.getKeys())).map(e=>[e.key,e.value])}async getItem(e){const t=await this.indexedDb.getItem(e);if(t!==null)return t}async setItem(e,t){await this.indexedDb.setItem(e,sa(t))}async removeItem(e){await this.indexedDb.removeItem(e)}};var xn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof Q<"u"?Q:typeof self<"u"?self:{},kr={exports:{}};(function(){let s;function e(){}s=e,s.prototype.getItem=function(t){return this.hasOwnProperty(t)?String(this[t]):null},s.prototype.setItem=function(t,i){this[t]=String(i)},s.prototype.removeItem=function(t){delete this[t]},s.prototype.clear=function(){const t=this;Object.keys(t).forEach(function(i){t[i]=void 0,delete t[i]})},s.prototype.key=function(t){return t=t||0,Object.keys(this)[t]},s.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),typeof xn<"u"&&xn.localStorage?kr.exports=xn.localStorage:typeof window<"u"&&window.localStorage?kr.exports=window.localStorage:kr.exports=new e})();function Uf(s){var e;return[s[0],jr((e=s[1])!=null?e:"")]}let Bf=class{constructor(){this.localStorage=kr.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(Uf)}async getItem(e){const t=this.localStorage.getItem(e);if(t!==null)return jr(t)}async setItem(e,t){this.localStorage.setItem(e,sa(t))}async removeItem(e){this.localStorage.removeItem(e)}};const Df="wc_storage_version",Wa=1,Lf=async(s,e,t)=>{const i=Df,r=await e.getItem(i);if(r&&r>=Wa){t(e);return}const n=await s.getKeys();if(!n.length){t(e);return}const o=[];for(;n.length;){const a=n.shift();if(!a)continue;const c=a.toLowerCase();if(c.includes("wc@")||c.includes("walletconnect")||c.includes("wc_")||c.includes("wallet_connect")){const l=await s.getItem(a);await e.setItem(a,l),o.push(a)}}await e.setItem(i,Wa),t(e),Mf(s,o)},Mf=async(s,e)=>{e.length&&e.forEach(async t=>{await s.removeItem(t)})};let qf=class{constructor(){this.initialized=!1,this.setInitialized=t=>{this.storage=t,this.initialized=!0};const e=new Bf;this.storage=e;try{const t=new Rf;Lf(e,t,this.setInitialized)}catch{this.initialized=!0}}async getKeys(){return await this.initialize(),this.storage.getKeys()}async getEntries(){return await this.initialize(),this.storage.getEntries()}async getItem(e){return await this.initialize(),this.storage.getItem(e)}async setItem(e,t){return await this.initialize(),this.storage.setItem(e,t)}async removeItem(e){return await this.initialize(),this.storage.removeItem(e)}async initialize(){this.initialized||await new Promise(e=>{const t=setInterval(()=>{this.initialized&&(clearInterval(t),e())},20)})}};var jf=Object.defineProperty,Ff=(s,e,t)=>e in s?jf(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Ga=(s,e,t)=>Ff(s,typeof e!="symbol"?e+"":e,t);class zf extends Si{constructor(e){super(),this.opts=e,Ga(this,"protocol","wc"),Ga(this,"version",2)}}var Kf=Object.defineProperty,Hf=(s,e,t)=>e in s?Kf(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Vf=(s,e,t)=>Hf(s,e+"",t);class Wf extends Si{constructor(e,t){super(),this.core=e,this.logger=t,Vf(this,"records",new Map)}}let Gf=class{constructor(e,t){this.logger=e,this.core=t}};class Yf extends Si{constructor(e,t){super(),this.relayer=e,this.logger=t}}let Zf=class extends Si{constructor(e){super()}},Jf=class{constructor(e,t,i,r){this.core=e,this.logger=t,this.name=i}},Xf=class extends Si{constructor(e,t){super(),this.relayer=e,this.logger=t}},Qf=class extends Si{constructor(e,t){super(),this.core=e,this.logger=t}},ep=class{constructor(e,t,i){this.core=e,this.logger=t,this.store=i}};class tp{constructor(e,t){this.projectId=e,this.logger=t}}class sp{constructor(e,t,i){this.core=e,this.logger=t,this.telemetryEnabled=i}}var ip=Object.defineProperty,rp=(s,e,t)=>e in s?ip(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Ya=(s,e,t)=>rp(s,typeof e!="symbol"?e+"":e,t);let np=class{constructor(e){this.opts=e,Ya(this,"protocol","wc"),Ya(this,"version",2)}},op=class{constructor(e){this.client=e}};const ap="0.1.1";function cp(){return ap}class me extends Error{constructor(e,t={}){const i=(()=>{var c;if(t.cause instanceof me){if(t.cause.details)return t.cause.details;if(t.cause.shortMessage)return t.cause.shortMessage}return t.cause&&"details"in t.cause&&typeof t.cause.details=="string"?t.cause.details:(c=t.cause)!=null&&c.message?t.cause.message:t.details})(),r=t.cause instanceof me&&t.cause.docsPath||t.docsPath,o=`https://oxlib.sh${r??""}`,a=[e||"An error occurred.",...t.metaMessages?["",...t.metaMessages]:[],...i||r?["",i?`Details: ${i}`:void 0,r?`See: ${o}`:void 0]:[]].filter(c=>typeof c=="string").join(`
3
3
  `);super(a,t.cause?{cause:t.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:`ox@${cp()}`}),this.cause=t.cause,this.details=i,this.docs=o,this.docsPath=r,this.shortMessage=e}walk(e){return hh(this,e)}}function hh(s,e){return e!=null&&e(s)?s:s&&typeof s=="object"&&"cause"in s&&s.cause?hh(s.cause,e):e?null:s}const ii=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function lp(s){return s instanceof Uint8Array||ArrayBuffer.isView(s)&&s.constructor.name==="Uint8Array"}function Xi(s){if(!Number.isSafeInteger(s)||s<0)throw new Error("positive integer expected, got "+s)}function Zs(s,...e){if(!lp(s))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(s.length))throw new Error("Uint8Array expected of length "+e+", got length="+s.length)}function hp(s){if(typeof s!="function"||typeof s.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");Xi(s.outputLen),Xi(s.blockLen)}function vi(s,e=!0){if(s.destroyed)throw new Error("Hash instance has been destroyed");if(e&&s.finished)throw new Error("Hash#digest() has already been called")}function uh(s,e){Zs(s);const t=e.outputLen;if(s.length<t)throw new Error("digestInto() expects output buffer of length at least "+t)}function up(s){return new Uint32Array(s.buffer,s.byteOffset,Math.floor(s.byteLength/4))}function Ei(...s){for(let e=0;e<s.length;e++)s[e].fill(0)}function In(s){return new DataView(s.buffer,s.byteOffset,s.byteLength)}function Tt(s,e){return s<<32-e|s>>>e}const dp=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function fp(s){return s<<24&4278190080|s<<8&16711680|s>>>8&65280|s>>>24&255}function pp(s){for(let e=0;e<s.length;e++)s[e]=fp(s[e]);return s}const Za=dp?s=>s:pp;function gp(s){if(typeof s!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(s))}function nn(s){return typeof s=="string"&&(s=gp(s)),Zs(s),s}function yp(...s){let e=0;for(let i=0;i<s.length;i++){const r=s[i];Zs(r),e+=r.length}const t=new Uint8Array(e);for(let i=0,r=0;i<s.length;i++){const n=s[i];t.set(n,r),r+=n.length}return t}class oa{}function dh(s){const e=i=>s().update(nn(i)).digest(),t=s();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>s(),e}function mp(s=32){if(ii&&typeof ii.getRandomValues=="function")return ii.getRandomValues(new Uint8Array(s));if(ii&&typeof ii.randomBytes=="function")return Uint8Array.from(ii.randomBytes(s));throw new Error("crypto.getRandomValues must be defined")}function wp(s,e,t,i){if(typeof s.setBigUint64=="function")return s.setBigUint64(e,t,i);const r=BigInt(32),n=BigInt(4294967295),o=Number(t>>r&n),a=Number(t&n),c=i?4:0,l=i?0:4;s.setUint32(e+c,o,i),s.setUint32(e+l,a,i)}function bp(s,e,t){return s&e^~s&t}function vp(s,e,t){return s&e^s&t^e&t}class Ep extends oa{constructor(e,t,i,r){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=t,this.padOffset=i,this.isLE=r,this.buffer=new Uint8Array(e),this.view=In(this.buffer)}update(e){vi(this),e=nn(e),Zs(e);const{view:t,buffer:i,blockLen:r}=this,n=e.length;for(let o=0;o<n;){const a=Math.min(r-this.pos,n-o);if(a===r){const c=In(e);for(;r<=n-o;o+=r)this.process(c,o);continue}i.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===r&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){vi(this),uh(e,this),this.finished=!0;const{buffer:t,view:i,blockLen:r,isLE:n}=this;let{pos:o}=this;t[o++]=128,Ei(this.buffer.subarray(o)),this.padOffset>r-o&&(this.process(i,0),o=0);for(let u=o;u<r;u++)t[u]=0;wp(i,r-8,BigInt(this.length*8),n),this.process(i,0);const a=In(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:t}=this;this.digestInto(e);const i=e.slice(0,t);return this.destroy(),i}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:i,length:r,finished:n,destroyed:o,pos:a}=this;return e.destroyed=o,e.finished=n,e.length=r,e.pos=a,r%t&&e.buffer.set(i),e}clone(){return this._cloneInto()}}const fs=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),gr=BigInt(2**32-1),Ja=BigInt(32);function xp(s,e=!1){return e?{h:Number(s&gr),l:Number(s>>Ja&gr)}:{h:Number(s>>Ja&gr)|0,l:Number(s&gr)|0}}function Ip(s,e=!1){const t=s.length;let i=new Uint32Array(t),r=new Uint32Array(t);for(let n=0;n<t;n++){const{h:o,l:a}=xp(s[n],e);[i[n],r[n]]=[o,a]}return[i,r]}const Sp=(s,e,t)=>s<<t|e>>>32-t,Ap=(s,e,t)=>e<<t|s>>>32-t,Cp=(s,e,t)=>e<<t-32|s>>>64-t,_p=(s,e,t)=>s<<t-32|e>>>64-t,Pp=BigInt(0),Oi=BigInt(1),Op=BigInt(2),Np=BigInt(7),Tp=BigInt(256),$p=BigInt(113),fh=[],ph=[],gh=[];for(let s=0,e=Oi,t=1,i=0;s<24;s++){[t,i]=[i,(2*t+3*i)%5],fh.push(2*(5*i+t)),ph.push((s+1)*(s+2)/2%64);let r=Pp;for(let n=0;n<7;n++)e=(e<<Oi^(e>>Np)*$p)%Tp,e&Op&&(r^=Oi<<(Oi<<BigInt(n))-Oi);gh.push(r)}const yh=Ip(gh,!0),kp=yh[0],Rp=yh[1],Xa=(s,e,t)=>t>32?Cp(s,e,t):Sp(s,e,t),Qa=(s,e,t)=>t>32?_p(s,e,t):Ap(s,e,t);function Up(s,e=24){const t=new Uint32Array(10);for(let i=24-e;i<24;i++){for(let o=0;o<10;o++)t[o]=s[o]^s[o+10]^s[o+20]^s[o+30]^s[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,c=(o+2)%10,l=t[c],h=t[c+1],u=Xa(l,h,1)^t[a],d=Qa(l,h,1)^t[a+1];for(let f=0;f<50;f+=10)s[o+f]^=u,s[o+f+1]^=d}let r=s[2],n=s[3];for(let o=0;o<24;o++){const a=ph[o],c=Xa(r,n,a),l=Qa(r,n,a),h=fh[o];r=s[h],n=s[h+1],s[h]=c,s[h+1]=l}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)t[a]=s[o+a];for(let a=0;a<10;a++)s[o+a]^=~t[(a+2)%10]&t[(a+4)%10]}s[0]^=kp[i],s[1]^=Rp[i]}Ei(t)}class aa extends oa{constructor(e,t,i,r=!1,n=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=e,this.suffix=t,this.outputLen=i,this.enableXOF=r,this.rounds=n,Xi(i),!(0<e&&e<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=up(this.state)}clone(){return this._cloneInto()}keccak(){Za(this.state32),Up(this.state32,this.rounds),Za(this.state32),this.posOut=0,this.pos=0}update(e){vi(this),e=nn(e),Zs(e);const{blockLen:t,state:i}=this,r=e.length;for(let n=0;n<r;){const o=Math.min(t-this.pos,r-n);for(let a=0;a<o;a++)i[this.pos++]^=e[n++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:i,blockLen:r}=this;e[i]^=t,(t&128)!==0&&i===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){vi(this,!1),Zs(e),this.finish();const t=this.state,{blockLen:i}=this;for(let r=0,n=e.length;r<n;){this.posOut>=i&&this.keccak();const o=Math.min(i-this.posOut,n-r);e.set(t.subarray(this.posOut,this.posOut+o),r),this.posOut+=o,r+=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 Xi(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(uh(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,Ei(this.state)}_cloneInto(e){const{blockLen:t,suffix:i,outputLen:r,rounds:n,enableXOF:o}=this;return e||(e=new aa(t,i,r,o,n)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=n,e.suffix=i,e.outputLen=r,e.enableXOF=o,e.destroyed=this.destroyed,e}}const Bp=(s,e,t)=>dh(()=>new aa(e,s,t)),Dp=Bp(1,136,256/8),Lp=Uint32Array.from([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]),ps=new Uint32Array(64);class Mp extends Ep{constructor(e=32){super(64,e,8,!1),this.A=fs[0]|0,this.B=fs[1]|0,this.C=fs[2]|0,this.D=fs[3]|0,this.E=fs[4]|0,this.F=fs[5]|0,this.G=fs[6]|0,this.H=fs[7]|0}get(){const{A:e,B:t,C:i,D:r,E:n,F:o,G:a,H:c}=this;return[e,t,i,r,n,o,a,c]}set(e,t,i,r,n,o,a,c){this.A=e|0,this.B=t|0,this.C=i|0,this.D=r|0,this.E=n|0,this.F=o|0,this.G=a|0,this.H=c|0}process(e,t){for(let u=0;u<16;u++,t+=4)ps[u]=e.getUint32(t,!1);for(let u=16;u<64;u++){const d=ps[u-15],f=ps[u-2],p=Tt(d,7)^Tt(d,18)^d>>>3,g=Tt(f,17)^Tt(f,19)^f>>>10;ps[u]=g+ps[u-7]+p+ps[u-16]|0}let{A:i,B:r,C:n,D:o,E:a,F:c,G:l,H:h}=this;for(let u=0;u<64;u++){const d=Tt(a,6)^Tt(a,11)^Tt(a,25),f=h+d+bp(a,c,l)+Lp[u]+ps[u]|0,g=(Tt(i,2)^Tt(i,13)^Tt(i,22))+vp(i,r,n)|0;h=l,l=c,c=a,a=o+f|0,o=n,n=r,r=i,i=f+g|0}i=i+this.A|0,r=r+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(i,r,n,o,a,c,l,h)}roundClean(){Ei(ps)}destroy(){this.set(0,0,0,0,0,0,0,0),Ei(this.buffer)}}const qp=dh(()=>new Mp);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ca=BigInt(0),po=BigInt(1);function nr(s){return s instanceof Uint8Array||ArrayBuffer.isView(s)&&s.constructor.name==="Uint8Array"}function la(s){if(!nr(s))throw new Error("Uint8Array expected")}function Qi(s,e){if(typeof e!="boolean")throw new Error(s+" boolean expected, got "+e)}function yr(s){const e=s.toString(16);return e.length&1?"0"+e:e}function mh(s){if(typeof s!="string")throw new Error("hex string expected, got "+typeof s);return s===""?ca:BigInt("0x"+s)}const wh=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",jp=Array.from({length:256},(s,e)=>e.toString(16).padStart(2,"0"));function er(s){if(la(s),wh)return s.toHex();let e="";for(let t=0;t<s.length;t++)e+=jp[s[t]];return e}const Wt={_0:48,_9:57,A:65,F:70,a:97,f:102};function ec(s){if(s>=Wt._0&&s<=Wt._9)return s-Wt._0;if(s>=Wt.A&&s<=Wt.F)return s-(Wt.A-10);if(s>=Wt.a&&s<=Wt.f)return s-(Wt.a-10)}function Fr(s){if(typeof s!="string")throw new Error("hex string expected, got "+typeof s);if(wh)return Uint8Array.fromHex(s);const e=s.length,t=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const i=new Uint8Array(t);for(let r=0,n=0;r<t;r++,n+=2){const o=ec(s.charCodeAt(n)),a=ec(s.charCodeAt(n+1));if(o===void 0||a===void 0){const c=s[n]+s[n+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+n)}i[r]=o*16+a}return i}function Ys(s){return mh(er(s))}function bh(s){return la(s),mh(er(Uint8Array.from(s).reverse()))}function or(s,e){return Fr(s.toString(16).padStart(e*2,"0"))}function vh(s,e){return or(s,e).reverse()}function vt(s,e,t){let i;if(typeof e=="string")try{i=Fr(e)}catch(n){throw new Error(s+" must be hex string or Uint8Array, cause: "+n)}else if(nr(e))i=Uint8Array.from(e);else throw new Error(s+" must be hex string or Uint8Array");const r=i.length;if(typeof t=="number"&&r!==t)throw new Error(s+" of length "+t+" expected, got "+r);return i}function zr(...s){let e=0;for(let i=0;i<s.length;i++){const r=s[i];la(r),e+=r.length}const t=new Uint8Array(e);for(let i=0,r=0;i<s.length;i++){const n=s[i];t.set(n,r),r+=n.length}return t}const Sn=s=>typeof s=="bigint"&&ca<=s;function ha(s,e,t){return Sn(s)&&Sn(e)&&Sn(t)&&e<=s&&s<t}function pi(s,e,t,i){if(!ha(e,t,i))throw new Error("expected valid "+s+": "+t+" <= n < "+i+", got "+e)}function Fp(s){let e;for(e=0;s>ca;s>>=po,e+=1);return e}const on=s=>(po<<BigInt(s))-po,An=s=>new Uint8Array(s),tc=s=>Uint8Array.from(s);function zp(s,e,t){if(typeof s!="number"||s<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 t!="function")throw new Error("hmacFn must be a function");let i=An(s),r=An(s),n=0;const o=()=>{i.fill(1),r.fill(0),n=0},a=(...u)=>t(r,i,...u),c=(u=An(0))=>{r=a(tc([0]),u),i=a(),u.length!==0&&(r=a(tc([1]),u),i=a())},l=()=>{if(n++>=1e3)throw new Error("drbg: tried 1000 values");let u=0;const d=[];for(;u<e;){i=a();const f=i.slice();d.push(f),u+=i.length}return zr(...d)};return(u,d)=>{o(),c(u);let f;for(;!(f=d(l()));)c();return o(),f}}const Kp={bigint:s=>typeof s=="bigint",function:s=>typeof s=="function",boolean:s=>typeof s=="boolean",string:s=>typeof s=="string",stringOrUint8Array:s=>typeof s=="string"||nr(s),isSafeInteger:s=>Number.isSafeInteger(s),array:s=>Array.isArray(s),field:(s,e)=>e.Fp.isValid(s),hash:s=>typeof s=="function"&&Number.isSafeInteger(s.outputLen)};function an(s,e,t={}){const i=(r,n,o)=>{const a=Kp[n];if(typeof a!="function")throw new Error("invalid validator function");const c=s[r];if(!(o&&c===void 0)&&!a(c,s))throw new Error("param "+String(r)+" is invalid. Expected "+n+", got "+c)};for(const[r,n]of Object.entries(e))i(r,n,!1);for(const[r,n]of Object.entries(t))i(r,n,!0);return s}function sc(s){const e=new WeakMap;return(t,...i)=>{const r=e.get(t);if(r!==void 0)return r;const n=s(t,...i);return e.set(t,n),n}}function Hp(s,e){if(oc(s)>e)throw new dg({givenSize:oc(s),maxSize:e})}const Gt={zero:48,nine:57,A:65,F:70,a:97,f:102};function ic(s){if(s>=Gt.zero&&s<=Gt.nine)return s-Gt.zero;if(s>=Gt.A&&s<=Gt.F)return s-(Gt.A-10);if(s>=Gt.a&&s<=Gt.f)return s-(Gt.a-10)}function Vp(s,e={}){const{dir:t,size:i=32}=e;if(i===0)return s;if(s.length>i)throw new fg({size:s.length,targetSize:i,type:"Bytes"});const r=new Uint8Array(i);for(let n=0;n<i;n++){const o=t==="right";r[o?n:i-n-1]=s[o?n:s.length-n-1]}return r}function Eh(s,e){if(Os(s)>e)throw new sg({givenSize:Os(s),maxSize:e})}function Wp(s,e){if(typeof e=="number"&&e>0&&e>Os(s)-1)throw new Sh({offset:e,position:"start",size:Os(s)})}function Gp(s,e,t){if(typeof e=="number"&&typeof t=="number"&&Os(s)!==t-e)throw new Sh({offset:t,position:"end",size:Os(s)})}function xh(s,e={}){const{dir:t,size:i=32}=e;if(i===0)return s;const r=s.replace("0x","");if(r.length>i*2)throw new ig({size:Math.ceil(r.length/2),targetSize:i,type:"Hex"});return`0x${r[t==="right"?"padEnd":"padStart"](i*2,"0")}`}const Yp="#__bigint";function ua(s,e,t){return JSON.stringify(s,(i,r)=>typeof r=="bigint"?r.toString()+Yp:r,t)}const Zp=Array.from({length:256},(s,e)=>e.toString(16).padStart(2,"0"));function Jp(s,e={}){const{strict:t=!1}=e;if(!s)throw new rc(s);if(typeof s!="string")throw new rc(s);if(t&&!/^0x[0-9a-fA-F]*$/.test(s))throw new nc(s);if(!s.startsWith("0x"))throw new nc(s)}function Xp(...s){return`0x${s.reduce((e,t)=>e+t.replace("0x",""),"")}`}function da(s){return s instanceof Uint8Array?Kr(s):Array.isArray(s)?Kr(new Uint8Array(s)):s}function Kr(s,e={}){let t="";for(let r=0;r<s.length;r++)t+=Zp[s[r]];const i=`0x${t}`;return typeof e.size=="number"?(Eh(i,e.size),Ih(i,e.size)):i}function Cn(s,e={}){const{signed:t,size:i}=e,r=BigInt(s);let n;i?t?n=(1n<<BigInt(i)*8n-1n)-1n:n=2n**(BigInt(i)*8n)-1n:typeof s=="number"&&(n=BigInt(Number.MAX_SAFE_INTEGER));const o=typeof n=="bigint"&&t?-n-1n:0;if(n&&r>n||r<o){const l=typeof s=="bigint"?"n":"";throw new tg({max:n?`${n}${l}`:void 0,min:`${o}${l}`,signed:t,size:i,value:`${s}${l}`})}const c=`0x${(t&&r<0?(1n<<BigInt(i*8))+BigInt(r):r).toString(16)}`;return i?Qp(c,i):c}function Qp(s,e){return xh(s,{dir:"left",size:e})}function Ih(s,e){return xh(s,{dir:"right",size:e})}function es(s,e,t,i={}){const{strict:r}=i;Wp(s,e);const n=`0x${s.replace("0x","").slice((e??0)*2,(t??s.length)*2)}`;return r&&Gp(n,e,t),n}function Os(s){return Math.ceil((s.length-2)/2)}function eg(s,e={}){const{strict:t=!1}=e;try{return Jp(s,{strict:t}),!0}catch{return!1}}class tg extends me{constructor({max:e,min:t,signed:i,size:r,value:n}){super(`Number \`${n}\` is not in safe${r?` ${r*8}-bit`:""}${i?" signed":" unsigned"} integer range ${e?`(\`${t}\` to \`${e}\`)`:`(above \`${t}\`)`}`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.IntegerOutOfRangeError"})}}class rc extends me{constructor(e){super(`Value \`${typeof e=="object"?ua(e):e}\` of type \`${typeof e}\` is an invalid hex type.`,{metaMessages:['Hex types must be represented as `"0x${string}"`.']}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.InvalidHexTypeError"})}}class nc extends me{constructor(e){super(`Value \`${e}\` is an invalid hex value.`,{metaMessages:['Hex values must start with `"0x"` and contain only hexadecimal characters (0-9, a-f, A-F).']}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.InvalidHexValueError"})}}let sg=class extends me{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed \`${t}\` bytes. Given size: \`${e}\` bytes.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SizeOverflowError"})}};class Sh extends me{constructor({offset:e,position:t,size:i}){super(`Slice ${t==="start"?"starting":"ending"} at offset \`${e}\` is out-of-bounds (size: \`${i}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SliceOffsetOutOfBoundsError"})}}let ig=class extends me{constructor({size:e,targetSize:t,type:i}){super(`${i.charAt(0).toUpperCase()}${i.slice(1).toLowerCase()} size (\`${e}\`) exceeds padding size (\`${t}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SizeExceedsPaddingSizeError"})}};const rg=new TextEncoder;function ng(s){if(!(s instanceof Uint8Array)){if(!s)throw new mr(s);if(typeof s!="object")throw new mr(s);if(!("BYTES_PER_ELEMENT"in s))throw new mr(s);if(s.BYTES_PER_ELEMENT!==1||s.constructor.name!=="Uint8Array")throw new mr(s)}}function og(s){return s instanceof Uint8Array?s:typeof s=="string"?cg(s):ag(s)}function ag(s){return s instanceof Uint8Array?s:new Uint8Array(s)}function cg(s,e={}){const{size:t}=e;let i=s;t&&(Eh(s,t),i=Ih(s,t));let r=i.slice(2);r.length%2&&(r=`0${r}`);const n=r.length/2,o=new Uint8Array(n);for(let a=0,c=0;a<n;a++){const l=ic(r.charCodeAt(c++)),h=ic(r.charCodeAt(c++));if(l===void 0||h===void 0)throw new me(`Invalid byte sequence ("${r[c-2]}${r[c-1]}" in "${r}").`);o[a]=l*16+h}return o}function lg(s,e={}){const{size:t}=e,i=rg.encode(s);return typeof t=="number"?(Hp(i,t),hg(i,t)):i}function hg(s,e){return Vp(s,{dir:"right",size:e})}function oc(s){return s.length}function ug(s){try{return ng(s),!0}catch{return!1}}class mr extends me{constructor(e){super(`Value \`${typeof e=="object"?ua(e):e}\` of type \`${typeof e}\` is an invalid Bytes value.`,{metaMessages:["Bytes values must be of type `Bytes`."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.InvalidBytesTypeError"})}}class dg extends me{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed \`${t}\` bytes. Given size: \`${e}\` bytes.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SizeOverflowError"})}}class fg extends me{constructor({size:e,targetSize:t,type:i}){super(`${i.charAt(0).toUpperCase()}${i.slice(1).toLowerCase()} size (\`${e}\`) exceeds padding size (\`${t}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SizeExceedsPaddingSizeError"})}}function Ah(s,e={}){const{as:t=typeof s=="string"?"Hex":"Bytes"}=e,i=Dp(og(s));return t==="Bytes"?i:Kr(i)}class pg extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const t=super.get(e);return super.has(e)&&t!==void 0&&(this.delete(e),super.set(e,t)),t}set(e,t){if(super.set(e,t),this.maxSize&&this.size>this.maxSize){const i=this.keys().next().value;i&&this.delete(i)}return this}}const gg={checksum:new pg(8192)},_n=gg.checksum;function Ch(s,e={}){const{compressed:t}=e,{prefix:i,x:r,y:n}=s;if(t===!1||typeof r=="bigint"&&typeof n=="bigint"){if(i!==4)throw new ac({prefix:i,cause:new Eg});return}if(t===!0||typeof r=="bigint"&&typeof n>"u"){if(i!==3&&i!==2)throw new ac({prefix:i,cause:new vg});return}throw new bg({publicKey:s})}function yg(s){const e=(()=>{if(eg(s))return _h(s);if(ug(s))return mg(s);const{prefix:t,x:i,y:r}=s;return typeof i=="bigint"&&typeof r=="bigint"?{prefix:t??4,x:i,y:r}:{prefix:t,x:i}})();return Ch(e),e}function mg(s){return _h(Kr(s))}function _h(s){if(s.length!==132&&s.length!==130&&s.length!==68)throw new xg({publicKey:s});if(s.length===130){const i=BigInt(es(s,0,32)),r=BigInt(es(s,32,64));return{prefix:4,x:i,y:r}}if(s.length===132){const i=Number(es(s,0,1)),r=BigInt(es(s,1,33)),n=BigInt(es(s,33,65));return{prefix:i,x:r,y:n}}const e=Number(es(s,0,1)),t=BigInt(es(s,1,33));return{prefix:e,x:t}}function wg(s,e={}){Ch(s);const{prefix:t,x:i,y:r}=s,{includePrefix:n=!0}=e;return Xp(n?Cn(t,{size:1}):"0x",Cn(i,{size:32}),typeof r=="bigint"?Cn(r,{size:32}):"0x")}class bg extends me{constructor({publicKey:e}){super(`Value \`${ua(e)}\` is not a valid public key.`,{metaMessages:["Public key must contain:","- an `x` and `prefix` value (compressed)","- an `x`, `y`, and `prefix` value (uncompressed)"]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidError"})}}class ac extends me{constructor({prefix:e,cause:t}){super(`Prefix "${e}" is invalid.`,{cause:t}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidPrefixError"})}}class vg extends me{constructor(){super("Prefix must be 2 or 3 for compressed public keys."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidCompressedPrefixError"})}}class Eg extends me{constructor(){super("Prefix must be 4 for uncompressed public keys."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidUncompressedPrefixError"})}}let xg=class extends me{constructor({publicKey:e}){super(`Value \`${e}\` is an invalid public key size.`,{metaMessages:["Expected: 33 bytes (compressed + prefix), 64 bytes (uncompressed) or 65 bytes (uncompressed + prefix).",`Received ${Os(da(e))} bytes.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidSerializedSizeError"})}};const Ig=/^0x[a-fA-F0-9]{40}$/;function Ph(s,e={}){const{strict:t=!0}=e;if(!Ig.test(s))throw new cc({address:s,cause:new Cg});if(t){if(s.toLowerCase()===s)return;if(Oh(s)!==s)throw new cc({address:s,cause:new _g})}}function Oh(s){if(_n.has(s))return _n.get(s);Ph(s,{strict:!1});const e=s.substring(2).toLowerCase(),t=Ah(lg(e),{as:"Bytes"}),i=e.split("");for(let n=0;n<40;n+=2)t[n>>1]>>4>=8&&i[n]&&(i[n]=i[n].toUpperCase()),(t[n>>1]&15)>=8&&i[n+1]&&(i[n+1]=i[n+1].toUpperCase());const r=`0x${i.join("")}`;return _n.set(s,r),r}function Sg(s,e={}){const{checksum:t=!1}=e;return Ph(s),t?Oh(s):s}function Ag(s,e={}){const t=Ah(`0x${wg(s).slice(4)}`).substring(26);return Sg(`0x${t}`,e)}class cc extends me{constructor({address:e,cause:t}){super(`Address "${e}" is invalid.`,{cause:t}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidAddressError"})}}class Cg extends me{constructor(){super("Address is not a 20 byte (40 hexadecimal character) value."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidInputError"})}}class _g extends me{constructor(){super("Address does not match its checksum counterpart."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidChecksumError"})}}class Nh extends oa{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,hp(e);const i=nn(t);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const r=this.blockLen,n=new Uint8Array(r);n.set(i.length>r?e.create().update(i).digest():i);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),Ei(n)}update(e){return vi(this),this.iHash.update(e),this}digestInto(e){vi(this),Zs(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:i,finished:r,destroyed:n,blockLen:o,outputLen:a}=this;return e=e,e.finished=r,e.destroyed=n,e.blockLen=o,e.outputLen=a,e.oHash=t._cloneInto(e.oHash),e.iHash=i._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Th=(s,e,t)=>new Nh(s,e).update(t).digest();Th.create=(s,e)=>new Nh(s,e);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const it=BigInt(0),He=BigInt(1),zs=BigInt(2),Pg=BigInt(3),$h=BigInt(4),kh=BigInt(5),Rh=BigInt(8);function et(s,e){const t=s%e;return t>=it?t:e+t}function yt(s,e,t){let i=s;for(;e-- >it;)i*=i,i%=t;return i}function go(s,e){if(s===it)throw new Error("invert: expected non-zero number");if(e<=it)throw new Error("invert: expected positive modulus, got "+e);let t=et(s,e),i=e,r=it,n=He;for(;t!==it;){const a=i/t,c=i%t,l=r-n*a;i=t,t=c,r=n,n=l}if(i!==He)throw new Error("invert: does not exist");return et(r,e)}function Uh(s,e){const t=(s.ORDER+He)/$h,i=s.pow(e,t);if(!s.eql(s.sqr(i),e))throw new Error("Cannot find square root");return i}function Og(s,e){const t=(s.ORDER-kh)/Rh,i=s.mul(e,zs),r=s.pow(i,t),n=s.mul(e,r),o=s.mul(s.mul(n,zs),r),a=s.mul(n,s.sub(o,s.ONE));if(!s.eql(s.sqr(a),e))throw new Error("Cannot find square root");return a}function Ng(s){if(s<BigInt(3))throw new Error("sqrt is not defined for small field");let e=s-He,t=0;for(;e%zs===it;)e/=zs,t++;let i=zs;const r=fa(s);for(;lc(r,i)===1;)if(i++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(t===1)return Uh;let n=r.pow(i,e);const o=(e+He)/zs;return function(c,l){if(c.is0(l))return l;if(lc(c,l)!==1)throw new Error("Cannot find square root");let h=t,u=c.mul(c.ONE,n),d=c.pow(l,e),f=c.pow(l,o);for(;!c.eql(d,c.ONE);){if(c.is0(d))return c.ZERO;let p=1,g=c.sqr(d);for(;!c.eql(g,c.ONE);)if(p++,g=c.sqr(g),p===h)throw new Error("Cannot find square root");const m=He<<BigInt(h-p-1),S=c.pow(u,m);h=p,u=c.sqr(S),d=c.mul(d,u),f=c.mul(f,S)}return f}}function Tg(s){return s%$h===Pg?Uh:s%Rh===kh?Og:Ng(s)}const $g=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function kg(s){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=$g.reduce((i,r)=>(i[r]="function",i),e);return an(s,t)}function Rg(s,e,t){if(t<it)throw new Error("invalid exponent, negatives unsupported");if(t===it)return s.ONE;if(t===He)return e;let i=s.ONE,r=e;for(;t>it;)t&He&&(i=s.mul(i,r)),r=s.sqr(r),t>>=He;return i}function Bh(s,e,t=!1){const i=new Array(e.length).fill(t?s.ZERO:void 0),r=e.reduce((o,a,c)=>s.is0(a)?o:(i[c]=o,s.mul(o,a)),s.ONE),n=s.inv(r);return e.reduceRight((o,a,c)=>s.is0(a)?o:(i[c]=s.mul(o,i[c]),s.mul(o,a)),n),i}function lc(s,e){const t=(s.ORDER-He)/zs,i=s.pow(e,t),r=s.eql(i,s.ONE),n=s.eql(i,s.ZERO),o=s.eql(i,s.neg(s.ONE));if(!r&&!n&&!o)throw new Error("invalid Legendre symbol result");return r?1:n?0:-1}function Dh(s,e){e!==void 0&&Xi(e);const t=e!==void 0?e:s.toString(2).length,i=Math.ceil(t/8);return{nBitLength:t,nByteLength:i}}function fa(s,e,t=!1,i={}){if(s<=it)throw new Error("invalid field: expected ORDER > 0, got "+s);const{nBitLength:r,nByteLength:n}=Dh(s,e);if(n>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let o;const a=Object.freeze({ORDER:s,isLE:t,BITS:r,BYTES:n,MASK:on(r),ZERO:it,ONE:He,create:c=>et(c,s),isValid:c=>{if(typeof c!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof c);return it<=c&&c<s},is0:c=>c===it,isOdd:c=>(c&He)===He,neg:c=>et(-c,s),eql:(c,l)=>c===l,sqr:c=>et(c*c,s),add:(c,l)=>et(c+l,s),sub:(c,l)=>et(c-l,s),mul:(c,l)=>et(c*l,s),pow:(c,l)=>Rg(a,c,l),div:(c,l)=>et(c*go(l,s),s),sqrN:c=>c*c,addN:(c,l)=>c+l,subN:(c,l)=>c-l,mulN:(c,l)=>c*l,inv:c=>go(c,s),sqrt:i.sqrt||(c=>(o||(o=Tg(s)),o(a,c))),toBytes:c=>t?vh(c,n):or(c,n),fromBytes:c=>{if(c.length!==n)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+c.length);return t?bh(c):Ys(c)},invertBatch:c=>Bh(a,c),cmov:(c,l,h)=>h?l:c});return Object.freeze(a)}function Lh(s){if(typeof s!="bigint")throw new Error("field order must be bigint");const e=s.toString(2).length;return Math.ceil(e/8)}function Mh(s){const e=Lh(s);return e+Math.ceil(e/2)}function Ug(s,e,t=!1){const i=s.length,r=Lh(e),n=Mh(e);if(i<16||i<n||i>1024)throw new Error("expected "+n+"-1024 bytes of input, got "+i);const o=t?bh(s):Ys(s),a=et(o,e-He)+He;return t?vh(a,r):or(a,r)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const hc=BigInt(0),yo=BigInt(1);function Pn(s,e){const t=e.negate();return s?t:e}function qh(s,e){if(!Number.isSafeInteger(s)||s<=0||s>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+s)}function On(s,e){qh(s,e);const t=Math.ceil(e/s)+1,i=2**(s-1),r=2**s,n=on(s),o=BigInt(s);return{windows:t,windowSize:i,mask:n,maxNumber:r,shiftBy:o}}function uc(s,e,t){const{windowSize:i,mask:r,maxNumber:n,shiftBy:o}=t;let a=Number(s&r),c=s>>o;a>i&&(a-=n,c+=yo);const l=e*i,h=l+Math.abs(a)-1,u=a===0,d=a<0,f=e%2!==0;return{nextN:c,offset:h,isZero:u,isNeg:d,isNegF:f,offsetF:l}}function Bg(s,e){if(!Array.isArray(s))throw new Error("array expected");s.forEach((t,i)=>{if(!(t instanceof e))throw new Error("invalid point at index "+i)})}function Dg(s,e){if(!Array.isArray(s))throw new Error("array of scalars expected");s.forEach((t,i)=>{if(!e.isValid(t))throw new Error("invalid scalar at index "+i)})}const Nn=new WeakMap,jh=new WeakMap;function Tn(s){return jh.get(s)||1}function Lg(s,e){return{constTimeNegate:Pn,hasPrecomputes(t){return Tn(t)!==1},unsafeLadder(t,i,r=s.ZERO){let n=t;for(;i>hc;)i&yo&&(r=r.add(n)),n=n.double(),i>>=yo;return r},precomputeWindow(t,i){const{windows:r,windowSize:n}=On(i,e),o=[];let a=t,c=a;for(let l=0;l<r;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(t,i,r){let n=s.ZERO,o=s.BASE;const a=On(t,e);for(let c=0;c<a.windows;c++){const{nextN:l,offset:h,isZero:u,isNeg:d,isNegF:f,offsetF:p}=uc(r,c,a);r=l,u?o=o.add(Pn(f,i[p])):n=n.add(Pn(d,i[h]))}return{p:n,f:o}},wNAFUnsafe(t,i,r,n=s.ZERO){const o=On(t,e);for(let a=0;a<o.windows&&r!==hc;a++){const{nextN:c,offset:l,isZero:h,isNeg:u}=uc(r,a,o);if(r=c,!h){const d=i[l];n=n.add(u?d.negate():d)}}return n},getPrecomputes(t,i,r){let n=Nn.get(i);return n||(n=this.precomputeWindow(i,t),t!==1&&Nn.set(i,r(n))),n},wNAFCached(t,i,r){const n=Tn(t);return this.wNAF(n,this.getPrecomputes(n,t,r),i)},wNAFCachedUnsafe(t,i,r,n){const o=Tn(t);return o===1?this.unsafeLadder(t,i,n):this.wNAFUnsafe(o,this.getPrecomputes(o,t,r),i,n)},setWindowSize(t,i){qh(i,e),jh.set(t,i),Nn.delete(t)}}}function Mg(s,e,t,i){Bg(t,s),Dg(i,e);const r=t.length,n=i.length;if(r!==n)throw new Error("arrays of points and scalars must have equal length");const o=s.ZERO,a=Fp(BigInt(r));let c=1;a>12?c=a-3:a>4?c=a-2:a>0&&(c=2);const l=on(c),h=new Array(Number(l)+1).fill(o),u=Math.floor((e.BITS-1)/c)*c;let d=o;for(let f=u;f>=0;f-=c){h.fill(o);for(let g=0;g<n;g++){const m=i[g],S=Number(m>>BigInt(f)&l);h[S]=h[S].add(t[g])}let p=o;for(let g=h.length-1,m=o;g>0;g--)m=m.add(h[g]),p=p.add(m);if(d=d.add(p),f!==0)for(let g=0;g<c;g++)d=d.double()}return d}function Fh(s){return kg(s.Fp),an(s,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Dh(s.n,s.nBitLength),...s,p:s.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function dc(s){s.lowS!==void 0&&Qi("lowS",s.lowS),s.prehash!==void 0&&Qi("prehash",s.prehash)}function qg(s){const e=Fh(s);an(e,{a:"field",b:"field"},{allowInfinityPoint:"boolean",allowedPrivateKeyLengths:"array",clearCofactor:"function",fromBytes:"function",isTorsionFree:"function",toBytes:"function",wrapPrivateKey:"boolean"});const{endo:t,Fp:i,a:r}=e;if(t){if(!i.eql(r,i.ZERO))throw new Error("invalid endo: CURVE.a must be 0");if(typeof t!="object"||typeof t.beta!="bigint"||typeof t.splitScalar!="function")throw new Error('invalid endo: expected "beta": bigint and "splitScalar": function')}return Object.freeze({...e})}class jg extends Error{constructor(e=""){super(e)}}const ss={Err:jg,_tlv:{encode:(s,e)=>{const{Err:t}=ss;if(s<0||s>256)throw new t("tlv.encode: wrong tag");if(e.length&1)throw new t("tlv.encode: unpadded data");const i=e.length/2,r=yr(i);if(r.length/2&128)throw new t("tlv.encode: long form length too big");const n=i>127?yr(r.length/2|128):"";return yr(s)+n+r+e},decode(s,e){const{Err:t}=ss;let i=0;if(s<0||s>256)throw new t("tlv.encode: wrong tag");if(e.length<2||e[i++]!==s)throw new t("tlv.decode: wrong tlv");const r=e[i++],n=!!(r&128);let o=0;if(!n)o=r;else{const c=r&127;if(!c)throw new t("tlv.decode(long): indefinite length not supported");if(c>4)throw new t("tlv.decode(long): byte length is too big");const l=e.subarray(i,i+c);if(l.length!==c)throw new t("tlv.decode: length bytes not complete");if(l[0]===0)throw new t("tlv.decode(long): zero leftmost byte");for(const h of l)o=o<<8|h;if(i+=c,o<128)throw new t("tlv.decode(long): not minimal encoding")}const a=e.subarray(i,i+o);if(a.length!==o)throw new t("tlv.decode: wrong value length");return{v:a,l:e.subarray(i+o)}}},_int:{encode(s){const{Err:e}=ss;if(s<rs)throw new e("integer: negative integers are not allowed");let t=yr(s);if(Number.parseInt(t[0],16)&8&&(t="00"+t),t.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return t},decode(s){const{Err:e}=ss;if(s[0]&128)throw new e("invalid signature integer: negative");if(s[0]===0&&!(s[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return Ys(s)}},toSig(s){const{Err:e,_int:t,_tlv:i}=ss,r=vt("signature",s),{v:n,l:o}=i.decode(48,r);if(o.length)throw new e("invalid signature: left bytes after parsing");const{v:a,l:c}=i.decode(2,n),{v:l,l:h}=i.decode(2,c);if(h.length)throw new e("invalid signature: left bytes after parsing");return{r:t.decode(a),s:t.decode(l)}},hexFromSig(s){const{_tlv:e,_int:t}=ss,i=e.encode(2,t.encode(s.r)),r=e.encode(2,t.encode(s.s)),n=i+r;return e.encode(48,n)}};function $n(s,e){return er(or(s,e))}const rs=BigInt(0),Pe=BigInt(1);BigInt(2);const kn=BigInt(3),Fg=BigInt(4);function zg(s){const e=qg(s),{Fp:t}=e,i=fa(e.n,e.nBitLength),r=e.toBytes||((I,E,N)=>{const $=E.toAffine();return zr(Uint8Array.from([4]),t.toBytes($.x),t.toBytes($.y))}),n=e.fromBytes||(I=>{const E=I.subarray(1),N=t.fromBytes(E.subarray(0,t.BYTES)),$=t.fromBytes(E.subarray(t.BYTES,2*t.BYTES));return{x:N,y:$}});function o(I){const{a:E,b:N}=e,$=t.sqr(I),U=t.mul($,I);return t.add(t.add(U,t.mul(I,E)),N)}function a(I,E){const N=t.sqr(E),$=o(I);return t.eql(N,$)}if(!a(e.Gx,e.Gy))throw new Error("bad curve params: generator point");const c=t.mul(t.pow(e.a,kn),Fg),l=t.mul(t.sqr(e.b),BigInt(27));if(t.is0(t.add(c,l)))throw new Error("bad curve params: a or b");function h(I){return ha(I,Pe,e.n)}function u(I){const{allowedPrivateKeyLengths:E,nByteLength:N,wrapPrivateKey:$,n:U}=e;if(E&&typeof I!="bigint"){if(nr(I)&&(I=er(I)),typeof I!="string"||!E.includes(I.length))throw new Error("invalid private key");I=I.padStart(N*2,"0")}let D;try{D=typeof I=="bigint"?I:Ys(vt("private key",I,N))}catch{throw new Error("invalid private key, expected hex or "+N+" bytes, got "+typeof I)}return $&&(D=et(D,U)),pi("private key",D,Pe,U),D}function d(I){if(!(I instanceof g))throw new Error("ProjectivePoint expected")}const f=sc((I,E)=>{const{px:N,py:$,pz:U}=I;if(t.eql(U,t.ONE))return{x:N,y:$};const D=I.is0();E==null&&(E=D?t.ONE:t.inv(U));const P=t.mul(N,E),B=t.mul($,E),M=t.mul(U,E);if(D)return{x:t.ZERO,y:t.ZERO};if(!t.eql(M,t.ONE))throw new Error("invZ was invalid");return{x:P,y:B}}),p=sc(I=>{if(I.is0()){if(e.allowInfinityPoint&&!t.is0(I.py))return;throw new Error("bad point: ZERO")}const{x:E,y:N}=I.toAffine();if(!t.isValid(E)||!t.isValid(N))throw new Error("bad point: x or y not FE");if(!a(E,N))throw new Error("bad point: equation left != right");if(!I.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class g{constructor(E,N,$){if(E==null||!t.isValid(E))throw new Error("x required");if(N==null||!t.isValid(N)||t.is0(N))throw new Error("y required");if($==null||!t.isValid($))throw new Error("z required");this.px=E,this.py=N,this.pz=$,Object.freeze(this)}static fromAffine(E){const{x:N,y:$}=E||{};if(!E||!t.isValid(N)||!t.isValid($))throw new Error("invalid affine point");if(E instanceof g)throw new Error("projective point not allowed");const U=D=>t.eql(D,t.ZERO);return U(N)&&U($)?g.ZERO:new g(N,$,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(E){const N=Bh(t,E.map($=>$.pz));return E.map(($,U)=>$.toAffine(N[U])).map(g.fromAffine)}static fromHex(E){const N=g.fromAffine(n(vt("pointHex",E)));return N.assertValidity(),N}static fromPrivateKey(E){return g.BASE.multiply(u(E))}static msm(E,N){return Mg(g,i,E,N)}_setWindowSize(E){k.setWindowSize(this,E)}assertValidity(){p(this)}hasEvenY(){const{y:E}=this.toAffine();if(t.isOdd)return!t.isOdd(E);throw new Error("Field doesn't support isOdd")}equals(E){d(E);const{px:N,py:$,pz:U}=this,{px:D,py:P,pz:B}=E,M=t.eql(t.mul(N,B),t.mul(D,U)),_=t.eql(t.mul($,B),t.mul(P,U));return M&&_}negate(){return new g(this.px,t.neg(this.py),this.pz)}double(){const{a:E,b:N}=e,$=t.mul(N,kn),{px:U,py:D,pz:P}=this;let B=t.ZERO,M=t.ZERO,_=t.ZERO,b=t.mul(U,U),x=t.mul(D,D),y=t.mul(P,P),w=t.mul(U,D);return w=t.add(w,w),_=t.mul(U,P),_=t.add(_,_),B=t.mul(E,_),M=t.mul($,y),M=t.add(B,M),B=t.sub(x,M),M=t.add(x,M),M=t.mul(B,M),B=t.mul(w,B),_=t.mul($,_),y=t.mul(E,y),w=t.sub(b,y),w=t.mul(E,w),w=t.add(w,_),_=t.add(b,b),b=t.add(_,b),b=t.add(b,y),b=t.mul(b,w),M=t.add(M,b),y=t.mul(D,P),y=t.add(y,y),b=t.mul(y,w),B=t.sub(B,b),_=t.mul(y,x),_=t.add(_,_),_=t.add(_,_),new g(B,M,_)}add(E){d(E);const{px:N,py:$,pz:U}=this,{px:D,py:P,pz:B}=E;let M=t.ZERO,_=t.ZERO,b=t.ZERO;const x=e.a,y=t.mul(e.b,kn);let w=t.mul(N,D),A=t.mul($,P),T=t.mul(U,B),v=t.add(N,$),C=t.add(D,P);v=t.mul(v,C),C=t.add(w,A),v=t.sub(v,C),C=t.add(N,U);let L=t.add(D,B);return C=t.mul(C,L),L=t.add(w,T),C=t.sub(C,L),L=t.add($,U),M=t.add(P,B),L=t.mul(L,M),M=t.add(A,T),L=t.sub(L,M),b=t.mul(x,C),M=t.mul(y,T),b=t.add(M,b),M=t.sub(A,b),b=t.add(A,b),_=t.mul(M,b),A=t.add(w,w),A=t.add(A,w),T=t.mul(x,T),C=t.mul(y,C),A=t.add(A,T),T=t.sub(w,T),T=t.mul(x,T),C=t.add(C,T),w=t.mul(A,C),_=t.add(_,w),w=t.mul(L,C),M=t.mul(v,M),M=t.sub(M,w),w=t.mul(v,A),b=t.mul(L,b),b=t.add(b,w),new g(M,_,b)}subtract(E){return this.add(E.negate())}is0(){return this.equals(g.ZERO)}wNAF(E){return k.wNAFCached(this,E,g.normalizeZ)}multiplyUnsafe(E){const{endo:N,n:$}=e;pi("scalar",E,rs,$);const U=g.ZERO;if(E===rs)return U;if(this.is0()||E===Pe)return this;if(!N||k.hasPrecomputes(this))return k.wNAFCachedUnsafe(this,E,g.normalizeZ);let{k1neg:D,k1:P,k2neg:B,k2:M}=N.splitScalar(E),_=U,b=U,x=this;for(;P>rs||M>rs;)P&Pe&&(_=_.add(x)),M&Pe&&(b=b.add(x)),x=x.double(),P>>=Pe,M>>=Pe;return D&&(_=_.negate()),B&&(b=b.negate()),b=new g(t.mul(b.px,N.beta),b.py,b.pz),_.add(b)}multiply(E){const{endo:N,n:$}=e;pi("scalar",E,Pe,$);let U,D;if(N){const{k1neg:P,k1:B,k2neg:M,k2:_}=N.splitScalar(E);let{p:b,f:x}=this.wNAF(B),{p:y,f:w}=this.wNAF(_);b=k.constTimeNegate(P,b),y=k.constTimeNegate(M,y),y=new g(t.mul(y.px,N.beta),y.py,y.pz),U=b.add(y),D=x.add(w)}else{const{p:P,f:B}=this.wNAF(E);U=P,D=B}return g.normalizeZ([U,D])[0]}multiplyAndAddUnsafe(E,N,$){const U=g.BASE,D=(B,M)=>M===rs||M===Pe||!B.equals(U)?B.multiplyUnsafe(M):B.multiply(M),P=D(this,N).add(D(E,$));return P.is0()?void 0:P}toAffine(E){return f(this,E)}isTorsionFree(){const{h:E,isTorsionFree:N}=e;if(E===Pe)return!0;if(N)return N(g,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:E,clearCofactor:N}=e;return E===Pe?this:N?N(g,this):this.multiplyUnsafe(e.h)}toRawBytes(E=!0){return Qi("isCompressed",E),this.assertValidity(),r(g,this,E)}toHex(E=!0){return Qi("isCompressed",E),er(this.toRawBytes(E))}}g.BASE=new g(e.Gx,e.Gy,t.ONE),g.ZERO=new g(t.ZERO,t.ONE,t.ZERO);const{endo:m,nBitLength:S}=e,k=Lg(g,m?Math.ceil(S/2):S);return{CURVE:e,ProjectivePoint:g,normPrivateKeyToScalar:u,weierstrassEquation:o,isWithinCurveOrder:h}}function Kg(s){const e=Fh(s);return an(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function Hg(s){const e=Kg(s),{Fp:t,n:i,nByteLength:r,nBitLength:n}=e,o=t.BYTES+1,a=2*t.BYTES+1;function c(y){return et(y,i)}function l(y){return go(y,i)}const{ProjectivePoint:h,normPrivateKeyToScalar:u,weierstrassEquation:d,isWithinCurveOrder:f}=zg({...e,toBytes(y,w,A){const T=w.toAffine(),v=t.toBytes(T.x),C=zr;return Qi("isCompressed",A),A?C(Uint8Array.from([w.hasEvenY()?2:3]),v):C(Uint8Array.from([4]),v,t.toBytes(T.y))},fromBytes(y){const w=y.length,A=y[0],T=y.subarray(1);if(w===o&&(A===2||A===3)){const v=Ys(T);if(!ha(v,Pe,t.ORDER))throw new Error("Point is not on curve");const C=d(v);let L;try{L=t.sqrt(C)}catch(V){const H=V instanceof Error?": "+V.message:"";throw new Error("Point is not on curve"+H)}const q=(L&Pe)===Pe;return(A&1)===1!==q&&(L=t.neg(L)),{x:v,y:L}}else if(w===a&&A===4){const v=t.fromBytes(T.subarray(0,t.BYTES)),C=t.fromBytes(T.subarray(t.BYTES,2*t.BYTES));return{x:v,y:C}}else{const v=o,C=a;throw new Error("invalid Point, expected length of "+v+", or uncompressed "+C+", got "+w)}}});function p(y){const w=i>>Pe;return y>w}function g(y){return p(y)?c(-y):y}const m=(y,w,A)=>Ys(y.slice(w,A));class S{constructor(w,A,T){pi("r",w,Pe,i),pi("s",A,Pe,i),this.r=w,this.s=A,T!=null&&(this.recovery=T),Object.freeze(this)}static fromCompact(w){const A=r;return w=vt("compactSignature",w,A*2),new S(m(w,0,A),m(w,A,2*A))}static fromDER(w){const{r:A,s:T}=ss.toSig(vt("DER",w));return new S(A,T)}assertValidity(){}addRecoveryBit(w){return new S(this.r,this.s,w)}recoverPublicKey(w){const{r:A,s:T,recovery:v}=this,C=U(vt("msgHash",w));if(v==null||![0,1,2,3].includes(v))throw new Error("recovery id invalid");const L=v===2||v===3?A+e.n:A;if(L>=t.ORDER)throw new Error("recovery id 2 or 3 invalid");const q=(v&1)===0?"02":"03",Y=h.fromHex(q+$n(L,t.BYTES)),V=l(L),H=c(-C*V),X=c(T*V),G=h.BASE.multiplyAndAddUnsafe(Y,H,X);if(!G)throw new Error("point at infinify");return G.assertValidity(),G}hasHighS(){return p(this.s)}normalizeS(){return this.hasHighS()?new S(this.r,c(-this.s),this.recovery):this}toDERRawBytes(){return Fr(this.toDERHex())}toDERHex(){return ss.hexFromSig(this)}toCompactRawBytes(){return Fr(this.toCompactHex())}toCompactHex(){const w=r;return $n(this.r,w)+$n(this.s,w)}}const k={isValidPrivateKey(y){try{return u(y),!0}catch{return!1}},normPrivateKeyToScalar:u,randomPrivateKey:()=>{const y=Mh(e.n);return Ug(e.randomBytes(y),e.n)},precompute(y=8,w=h.BASE){return w._setWindowSize(y),w.multiply(BigInt(3)),w}};function I(y,w=!0){return h.fromPrivateKey(y).toRawBytes(w)}function E(y){if(typeof y=="bigint")return!1;if(y instanceof h)return!0;const A=vt("key",y).length,T=t.BYTES,v=T+1,C=2*T+1;if(!(e.allowedPrivateKeyLengths||r===v))return A===v||A===C}function N(y,w,A=!0){if(E(y)===!0)throw new Error("first arg must be private key");if(E(w)===!1)throw new Error("second arg must be public key");return h.fromHex(w).multiply(u(y)).toRawBytes(A)}const $=e.bits2int||function(y){if(y.length>8192)throw new Error("input is too large");const w=Ys(y),A=y.length*8-n;return A>0?w>>BigInt(A):w},U=e.bits2int_modN||function(y){return c($(y))},D=on(n);function P(y){return pi("num < 2^"+n,y,rs,D),or(y,r)}function B(y,w,A=M){if(["recovered","canonical"].some(Z=>Z in A))throw new Error("sign() legacy options not supported");const{hash:T,randomBytes:v}=e;let{lowS:C,prehash:L,extraEntropy:q}=A;C==null&&(C=!0),y=vt("msgHash",y),dc(A),L&&(y=vt("prehashed msgHash",T(y)));const Y=U(y),V=u(w),H=[P(V),P(Y)];if(q!=null&&q!==!1){const Z=q===!0?v(t.BYTES):q;H.push(vt("extraEntropy",Z))}const X=zr(...H),G=Y;function ce(Z){const ue=$(Z);if(!f(ue))return;const ze=l(ue),Ge=h.BASE.multiply(ue).toAffine(),Ke=c(Ge.x);if(Ke===rs)return;const gt=c(ze*c(G+Ke*V));if(gt===rs)return;let ks=(Ge.x===Ke?0:2)|Number(Ge.y&Pe),si=gt;return C&&p(gt)&&(si=g(gt),ks^=1),new S(Ke,si,ks)}return{seed:X,k2sig:ce}}const M={lowS:e.lowS,prehash:!1},_={lowS:e.lowS,prehash:!1};function b(y,w,A=M){const{seed:T,k2sig:v}=B(y,w,A),C=e;return zp(C.hash.outputLen,C.nByteLength,C.hmac)(T,v)}h.BASE._setWindowSize(8);function x(y,w,A,T=_){var ks;const v=y;w=vt("msgHash",w),A=vt("publicKey",A);const{lowS:C,prehash:L,format:q}=T;if(dc(T),"strict"in T)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 Y=typeof v=="string"||nr(v),V=!Y&&!q&&typeof v=="object"&&v!==null&&typeof v.r=="bigint"&&typeof v.s=="bigint";if(!Y&&!V)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let H,X;try{if(V&&(H=new S(v.r,v.s)),Y){try{q!=="compact"&&(H=S.fromDER(v))}catch(si){if(!(si instanceof ss.Err))throw si}!H&&q!=="der"&&(H=S.fromCompact(v))}X=h.fromHex(A)}catch{return!1}if(!H||C&&H.hasHighS())return!1;L&&(w=e.hash(w));const{r:G,s:ce}=H,Z=U(w),ue=l(ce),ze=c(Z*ue),Ge=c(G*ue),Ke=(ks=h.BASE.multiplyAndAddUnsafe(X,ze,Ge))==null?void 0:ks.toAffine();return Ke?c(Ke.x)===G:!1}return{CURVE:e,getPublicKey:I,getSharedSecret:N,sign:b,verify:x,ProjectivePoint:h,Signature:S,utils:k}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Vg(s){return{hash:s,hmac:(e,...t)=>Th(s,e,yp(...t)),randomBytes:mp}}function Wg(s,e){const t=i=>Hg({...s,...Vg(i)});return{...t(e),create:t}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const zh=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),fc=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Gg=BigInt(0),Yg=BigInt(1),mo=BigInt(2),pc=(s,e)=>(s+e/mo)/e;function Zg(s){const e=zh,t=BigInt(3),i=BigInt(6),r=BigInt(11),n=BigInt(22),o=BigInt(23),a=BigInt(44),c=BigInt(88),l=s*s*s%e,h=l*l*s%e,u=yt(h,t,e)*h%e,d=yt(u,t,e)*h%e,f=yt(d,mo,e)*l%e,p=yt(f,r,e)*f%e,g=yt(p,n,e)*p%e,m=yt(g,a,e)*g%e,S=yt(m,c,e)*m%e,k=yt(S,a,e)*g%e,I=yt(k,t,e)*h%e,E=yt(I,o,e)*p%e,N=yt(E,i,e)*l%e,$=yt(N,mo,e);if(!wo.eql(wo.sqr($),s))throw new Error("Cannot find square root");return $}const wo=fa(zh,void 0,void 0,{sqrt:Zg}),Jg=Wg({a:Gg,b:BigInt(7),Fp:wo,n:fc,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:s=>{const e=fc,t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),i=-Yg*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),r=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),n=t,o=BigInt("0x100000000000000000000000000000000"),a=pc(n*s,e),c=pc(-i*s,e);let l=et(s-a*t-c*r,e),h=et(-a*i-c*n,e);const u=l>o,d=h>o;if(u&&(l=e-l),d&&(h=e-h),l>o||h>o)throw new Error("splitScalar: Endomorphism failed, k="+s);return{k1neg:u,k1:l,k2neg:d,k2:h}}}},qp);function Xg(s){if(s.length!==130&&s.length!==132)throw new ey({signature:s});const e=BigInt(es(s,0,32)),t=BigInt(es(s,32,64)),i=(()=>{const r=+`0x${s.slice(130)}`;if(!Number.isNaN(r))try{return Qg(r)}catch{throw new ty({value:r})}})();return typeof i>"u"?{r:e,s:t}:{r:e,s:t,yParity:i}}function Qg(s){if(s===0||s===27)return 0;if(s===1||s===28)return 1;if(s>=35)return s%2===0?1:0;throw new sy({value:s})}class ey extends me{constructor({signature:e}){super(`Value \`${e}\` is an invalid signature size.`,{metaMessages:["Expected: 64 bytes or 65 bytes.",`Received ${Os(da(e))} bytes.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidSerializedSizeError"})}}class ty extends me{constructor({value:e}){super(`Value \`${e}\` is an invalid y-parity value. Y-parity must be 0 or 1.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidYParityError"})}}class sy extends me{constructor({value:e}){super(`Value \`${e}\` is an invalid v value. v must be 27, 28 or >=35.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidVError"})}}function iy(s){return Ag(ry(s))}function ry(s){const{payload:e,signature:t}=s,{r:i,s:r,yParity:n}=t,a=new Jg.Signature(BigInt(i),BigInt(r)).addRecoveryBit(n).recoverPublicKey(da(e).substring(2));return yg(a)}function ny(s){const e=s.length;let t=0,i=0;for(;i<e;){let r=s.charCodeAt(i++);if((r&4294967168)===0){t++;continue}else if((r&4294965248)===0)t+=2;else{if(r>=55296&&r<=56319&&i<e){const n=s.charCodeAt(i);(n&64512)===56320&&(++i,r=((r&1023)<<10)+(n&1023)+65536)}(r&4294901760)===0?t+=3:t+=4}}return t}function oy(s,e,t){const i=s.length;let r=t,n=0;for(;n<i;){let o=s.charCodeAt(n++);if((o&4294967168)===0){e[r++]=o;continue}else if((o&4294965248)===0)e[r++]=o>>6&31|192;else{if(o>=55296&&o<=56319&&n<i){const a=s.charCodeAt(n);(a&64512)===56320&&(++n,o=((o&1023)<<10)+(a&1023)+65536)}(o&4294901760)===0?(e[r++]=o>>12&15|224,e[r++]=o>>6&63|128):(e[r++]=o>>18&7|240,e[r++]=o>>12&63|128,e[r++]=o>>6&63|128)}e[r++]=o&63|128}}const ay=new TextEncoder,cy=50;function ly(s,e,t){ay.encodeInto(s,e.subarray(t))}function hy(s,e,t){s.length>cy?ly(s,e,t):oy(s,e,t)}const uy=4096;function Kh(s,e,t){let i=e;const r=i+t,n=[];let o="";for(;i<r;){const a=s[i++];if((a&128)===0)n.push(a);else if((a&224)===192){const c=s[i++]&63;n.push((a&31)<<6|c)}else if((a&240)===224){const c=s[i++]&63,l=s[i++]&63;n.push((a&31)<<12|c<<6|l)}else if((a&248)===240){const c=s[i++]&63,l=s[i++]&63,h=s[i++]&63;let u=(a&7)<<18|c<<12|l<<6|h;u>65535&&(u-=65536,n.push(u>>>10&1023|55296),u=56320|u&1023),n.push(u)}else n.push(a);n.length>=uy&&(o+=String.fromCharCode(...n),n.length=0)}return n.length>0&&(o+=String.fromCharCode(...n)),o}const dy=new TextDecoder,fy=200;function py(s,e,t){const i=s.subarray(e,e+t);return dy.decode(i)}function gy(s,e,t){return t>fy?py(s,e,t):Kh(s,e,t)}class wr{constructor(e,t){W(this,"type");W(this,"data");this.type=e,this.data=t}}class lt extends Error{constructor(e){super(e);const t=Object.create(lt.prototype);Object.setPrototypeOf(this,t),Object.defineProperty(this,"name",{configurable:!0,enumerable:!1,value:lt.name})}}const Ni=4294967295;function yy(s,e,t){const i=t/4294967296,r=t;s.setUint32(e,i),s.setUint32(e+4,r)}function Hh(s,e,t){const i=Math.floor(t/4294967296),r=t;s.setUint32(e,i),s.setUint32(e+4,r)}function Vh(s,e){const t=s.getInt32(e),i=s.getUint32(e+4);return t*4294967296+i}function my(s,e){const t=s.getUint32(e),i=s.getUint32(e+4);return t*4294967296+i}const wy=-1,by=4294967296-1,vy=17179869184-1;function Ey({sec:s,nsec:e}){if(s>=0&&e>=0&&s<=vy)if(e===0&&s<=by){const t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,s),t}else{const t=s/4294967296,i=s&4294967295,r=new Uint8Array(8),n=new DataView(r.buffer);return n.setUint32(0,e<<2|t&3),n.setUint32(4,i),r}else{const t=new Uint8Array(12),i=new DataView(t.buffer);return i.setUint32(0,e),Hh(i,4,s),t}}function xy(s){const e=s.getTime(),t=Math.floor(e/1e3),i=(e-t*1e3)*1e6,r=Math.floor(i/1e9);return{sec:t+r,nsec:i-r*1e9}}function Iy(s){if(s instanceof Date){const e=xy(s);return Ey(e)}else return null}function Sy(s){const e=new DataView(s.buffer,s.byteOffset,s.byteLength);switch(s.byteLength){case 4:return{sec:e.getUint32(0),nsec:0};case 8:{const t=e.getUint32(0),i=e.getUint32(4),r=(t&3)*4294967296+i,n=t>>>2;return{sec:r,nsec:n}}case 12:{const t=Vh(e,4),i=e.getUint32(0);return{sec:t,nsec:i}}default:throw new lt(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${s.length}`)}}function Ay(s){const e=Sy(s);return new Date(e.sec*1e3+e.nsec/1e6)}const Cy={type:wy,encode:Iy,decode:Ay},rn=class rn{constructor(){W(this,"__brand");W(this,"builtInEncoders",[]);W(this,"builtInDecoders",[]);W(this,"encoders",[]);W(this,"decoders",[]);this.register(Cy)}register({type:e,encode:t,decode:i}){if(e>=0)this.encoders[e]=t,this.decoders[e]=i;else{const r=-1-e;this.builtInEncoders[r]=t,this.builtInDecoders[r]=i}}tryToEncode(e,t){for(let i=0;i<this.builtInEncoders.length;i++){const r=this.builtInEncoders[i];if(r!=null){const n=r(e,t);if(n!=null){const o=-1-i;return new wr(o,n)}}}for(let i=0;i<this.encoders.length;i++){const r=this.encoders[i];if(r!=null){const n=r(e,t);if(n!=null){const o=i;return new wr(o,n)}}}return e instanceof wr?e:null}decode(e,t,i){const r=t<0?this.builtInDecoders[-1-t]:this.decoders[t];return r?r(e,t,i):new wr(t,e)}};W(rn,"defaultCodec",new rn);let Hr=rn;function _y(s){return s instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&s instanceof SharedArrayBuffer}function bo(s){return s instanceof Uint8Array?s:ArrayBuffer.isView(s)?new Uint8Array(s.buffer,s.byteOffset,s.byteLength):_y(s)?new Uint8Array(s):Uint8Array.from(s)}const Py=100,Oy=2048;class pa{constructor(e){W(this,"extensionCodec");W(this,"context");W(this,"useBigInt64");W(this,"maxDepth");W(this,"initialBufferSize");W(this,"sortKeys");W(this,"forceFloat32");W(this,"ignoreUndefined");W(this,"forceIntegerToFloat");W(this,"pos");W(this,"view");W(this,"bytes");W(this,"entered",!1);this.extensionCodec=(e==null?void 0:e.extensionCodec)??Hr.defaultCodec,this.context=e==null?void 0:e.context,this.useBigInt64=(e==null?void 0:e.useBigInt64)??!1,this.maxDepth=(e==null?void 0:e.maxDepth)??Py,this.initialBufferSize=(e==null?void 0:e.initialBufferSize)??Oy,this.sortKeys=(e==null?void 0:e.sortKeys)??!1,this.forceFloat32=(e==null?void 0:e.forceFloat32)??!1,this.ignoreUndefined=(e==null?void 0:e.ignoreUndefined)??!1,this.forceIntegerToFloat=(e==null?void 0:e.forceIntegerToFloat)??!1,this.pos=0,this.view=new DataView(new ArrayBuffer(this.initialBufferSize)),this.bytes=new Uint8Array(this.view.buffer)}clone(){return new pa({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,maxDepth:this.maxDepth,initialBufferSize:this.initialBufferSize,sortKeys:this.sortKeys,forceFloat32:this.forceFloat32,ignoreUndefined:this.ignoreUndefined,forceIntegerToFloat:this.forceIntegerToFloat})}reinitializeState(){this.pos=0}encodeSharedRef(e){if(this.entered)return this.clone().encodeSharedRef(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.subarray(0,this.pos)}finally{this.entered=!1}}encode(e){if(this.entered)return this.clone().encode(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.slice(0,this.pos)}finally{this.entered=!1}}doEncode(e,t){if(t>this.maxDepth)throw new Error(`Too deep objects in depth ${t}`);e==null?this.encodeNil():typeof e=="boolean"?this.encodeBoolean(e):typeof e=="number"?this.forceIntegerToFloat?this.encodeNumberAsFloat(e):this.encodeNumber(e):typeof e=="string"?this.encodeString(e):this.useBigInt64&&typeof e=="bigint"?this.encodeBigInt64(e):this.encodeObject(e,t)}ensureBufferSizeToWrite(e){const t=this.pos+e;this.view.byteLength<t&&this.resizeBuffer(t*2)}resizeBuffer(e){const t=new ArrayBuffer(e),i=new Uint8Array(t),r=new DataView(t);i.set(this.bytes),this.view=r,this.bytes=i}encodeNil(){this.writeU8(192)}encodeBoolean(e){e===!1?this.writeU8(194):this.writeU8(195)}encodeNumber(e){!this.forceIntegerToFloat&&Number.isSafeInteger(e)?e>=0?e<128?this.writeU8(e):e<256?(this.writeU8(204),this.writeU8(e)):e<65536?(this.writeU8(205),this.writeU16(e)):e<4294967296?(this.writeU8(206),this.writeU32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(207),this.writeU64(e)):e>=-32?this.writeU8(224|e+32):e>=-128?(this.writeU8(208),this.writeI8(e)):e>=-32768?(this.writeU8(209),this.writeI16(e)):e>=-2147483648?(this.writeU8(210),this.writeI32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(211),this.writeI64(e)):this.encodeNumberAsFloat(e)}encodeNumberAsFloat(e){this.forceFloat32?(this.writeU8(202),this.writeF32(e)):(this.writeU8(203),this.writeF64(e))}encodeBigInt64(e){e>=BigInt(0)?(this.writeU8(207),this.writeBigUint64(e)):(this.writeU8(211),this.writeBigInt64(e))}writeStringHeader(e){if(e<32)this.writeU8(160+e);else if(e<256)this.writeU8(217),this.writeU8(e);else if(e<65536)this.writeU8(218),this.writeU16(e);else if(e<4294967296)this.writeU8(219),this.writeU32(e);else throw new Error(`Too long string: ${e} bytes in UTF-8`)}encodeString(e){const i=ny(e);this.ensureBufferSizeToWrite(5+i),this.writeStringHeader(i),hy(e,this.bytes,this.pos),this.pos+=i}encodeObject(e,t){const i=this.extensionCodec.tryToEncode(e,this.context);if(i!=null)this.encodeExtension(i);else if(Array.isArray(e))this.encodeArray(e,t);else if(ArrayBuffer.isView(e))this.encodeBinary(e);else if(typeof e=="object")this.encodeMap(e,t);else throw new Error(`Unrecognized object: ${Object.prototype.toString.apply(e)}`)}encodeBinary(e){const t=e.byteLength;if(t<256)this.writeU8(196),this.writeU8(t);else if(t<65536)this.writeU8(197),this.writeU16(t);else if(t<4294967296)this.writeU8(198),this.writeU32(t);else throw new Error(`Too large binary: ${t}`);const i=bo(e);this.writeU8a(i)}encodeArray(e,t){const i=e.length;if(i<16)this.writeU8(144+i);else if(i<65536)this.writeU8(220),this.writeU16(i);else if(i<4294967296)this.writeU8(221),this.writeU32(i);else throw new Error(`Too large array: ${i}`);for(const r of e)this.doEncode(r,t+1)}countWithoutUndefined(e,t){let i=0;for(const r of t)e[r]!==void 0&&i++;return i}encodeMap(e,t){const i=Object.keys(e);this.sortKeys&&i.sort();const r=this.ignoreUndefined?this.countWithoutUndefined(e,i):i.length;if(r<16)this.writeU8(128+r);else if(r<65536)this.writeU8(222),this.writeU16(r);else if(r<4294967296)this.writeU8(223),this.writeU32(r);else throw new Error(`Too large map object: ${r}`);for(const n of i){const o=e[n];this.ignoreUndefined&&o===void 0||(this.encodeString(n),this.doEncode(o,t+1))}}encodeExtension(e){if(typeof e.data=="function"){const i=e.data(this.pos+6),r=i.length;if(r>=4294967296)throw new Error(`Too large extension object: ${r}`);this.writeU8(201),this.writeU32(r),this.writeI8(e.type),this.writeU8a(i);return}const t=e.data.length;if(t===1)this.writeU8(212);else if(t===2)this.writeU8(213);else if(t===4)this.writeU8(214);else if(t===8)this.writeU8(215);else if(t===16)this.writeU8(216);else if(t<256)this.writeU8(199),this.writeU8(t);else if(t<65536)this.writeU8(200),this.writeU16(t);else if(t<4294967296)this.writeU8(201),this.writeU32(t);else throw new Error(`Too large extension object: ${t}`);this.writeI8(e.type),this.writeU8a(e.data)}writeU8(e){this.ensureBufferSizeToWrite(1),this.view.setUint8(this.pos,e),this.pos++}writeU8a(e){const t=e.length;this.ensureBufferSizeToWrite(t),this.bytes.set(e,this.pos),this.pos+=t}writeI8(e){this.ensureBufferSizeToWrite(1),this.view.setInt8(this.pos,e),this.pos++}writeU16(e){this.ensureBufferSizeToWrite(2),this.view.setUint16(this.pos,e),this.pos+=2}writeI16(e){this.ensureBufferSizeToWrite(2),this.view.setInt16(this.pos,e),this.pos+=2}writeU32(e){this.ensureBufferSizeToWrite(4),this.view.setUint32(this.pos,e),this.pos+=4}writeI32(e){this.ensureBufferSizeToWrite(4),this.view.setInt32(this.pos,e),this.pos+=4}writeF32(e){this.ensureBufferSizeToWrite(4),this.view.setFloat32(this.pos,e),this.pos+=4}writeF64(e){this.ensureBufferSizeToWrite(8),this.view.setFloat64(this.pos,e),this.pos+=8}writeU64(e){this.ensureBufferSizeToWrite(8),yy(this.view,this.pos,e),this.pos+=8}writeI64(e){this.ensureBufferSizeToWrite(8),Hh(this.view,this.pos,e),this.pos+=8}writeBigUint64(e){this.ensureBufferSizeToWrite(8),this.view.setBigUint64(this.pos,e),this.pos+=8}writeBigInt64(e){this.ensureBufferSizeToWrite(8),this.view.setBigInt64(this.pos,e),this.pos+=8}}function Ny(s,e){return new pa(e).encodeSharedRef(s)}function Rn(s){return`${s<0?"-":""}0x${Math.abs(s).toString(16).padStart(2,"0")}`}const Ty=16,$y=16;class ky{constructor(e=Ty,t=$y){W(this,"hit",0);W(this,"miss",0);W(this,"caches");W(this,"maxKeyLength");W(this,"maxLengthPerKey");this.maxKeyLength=e,this.maxLengthPerKey=t,this.caches=[];for(let i=0;i<this.maxKeyLength;i++)this.caches.push([])}canBeCached(e){return e>0&&e<=this.maxKeyLength}find(e,t,i){const r=this.caches[i-1];e:for(const n of r){const o=n.bytes;for(let a=0;a<i;a++)if(o[a]!==e[t+a])continue e;return n.str}return null}store(e,t){const i=this.caches[e.length-1],r={bytes:e,str:t};i.length>=this.maxLengthPerKey?i[Math.random()*i.length|0]=r:i.push(r)}decode(e,t,i){const r=this.find(e,t,i);if(r!=null)return this.hit++,r;this.miss++;const n=Kh(e,t,i),o=Uint8Array.prototype.slice.call(e,t,t+i);return this.store(o,n),n}}const vo="array",Wi="map_key",Wh="map_value",Ry=s=>{if(typeof s=="string"||typeof s=="number")return s;throw new lt("The type of key must be string or number but "+typeof s)};class Uy{constructor(){W(this,"stack",[]);W(this,"stackHeadPosition",-1)}get length(){return this.stackHeadPosition+1}top(){return this.stack[this.stackHeadPosition]}pushArrayState(e){const t=this.getUninitializedStateFromPool();t.type=vo,t.position=0,t.size=e,t.array=new Array(e)}pushMapState(e){const t=this.getUninitializedStateFromPool();t.type=Wi,t.readCount=0,t.size=e,t.map={}}getUninitializedStateFromPool(){if(this.stackHeadPosition++,this.stackHeadPosition===this.stack.length){const e={type:void 0,size:0,array:void 0,position:0,readCount:0,map:void 0,key:null};this.stack.push(e)}return this.stack[this.stackHeadPosition]}release(e){if(this.stack[this.stackHeadPosition]!==e)throw new Error("Invalid stack state. Released state is not on top of the stack.");if(e.type===vo){const i=e;i.size=0,i.array=void 0,i.position=0,i.type=void 0}if(e.type===Wi||e.type===Wh){const i=e;i.size=0,i.map=void 0,i.readCount=0,i.type=void 0}this.stackHeadPosition--}reset(){this.stack.length=0,this.stackHeadPosition=-1}}const Ti=-1,ga=new DataView(new ArrayBuffer(0)),By=new Uint8Array(ga.buffer);try{ga.getInt8(0)}catch(s){if(!(s instanceof RangeError))throw new Error("This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access")}const gc=new RangeError("Insufficient data"),Dy=new ky;class ya{constructor(e){W(this,"extensionCodec");W(this,"context");W(this,"useBigInt64");W(this,"rawStrings");W(this,"maxStrLength");W(this,"maxBinLength");W(this,"maxArrayLength");W(this,"maxMapLength");W(this,"maxExtLength");W(this,"keyDecoder");W(this,"mapKeyConverter");W(this,"totalPos",0);W(this,"pos",0);W(this,"view",ga);W(this,"bytes",By);W(this,"headByte",Ti);W(this,"stack",new Uy);W(this,"entered",!1);this.extensionCodec=(e==null?void 0:e.extensionCodec)??Hr.defaultCodec,this.context=e==null?void 0:e.context,this.useBigInt64=(e==null?void 0:e.useBigInt64)??!1,this.rawStrings=(e==null?void 0:e.rawStrings)??!1,this.maxStrLength=(e==null?void 0:e.maxStrLength)??Ni,this.maxBinLength=(e==null?void 0:e.maxBinLength)??Ni,this.maxArrayLength=(e==null?void 0:e.maxArrayLength)??Ni,this.maxMapLength=(e==null?void 0:e.maxMapLength)??Ni,this.maxExtLength=(e==null?void 0:e.maxExtLength)??Ni,this.keyDecoder=(e==null?void 0:e.keyDecoder)!==void 0?e.keyDecoder:Dy,this.mapKeyConverter=(e==null?void 0:e.mapKeyConverter)??Ry}clone(){return new ya({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,rawStrings:this.rawStrings,maxStrLength:this.maxStrLength,maxBinLength:this.maxBinLength,maxArrayLength:this.maxArrayLength,maxMapLength:this.maxMapLength,maxExtLength:this.maxExtLength,keyDecoder:this.keyDecoder})}reinitializeState(){this.totalPos=0,this.headByte=Ti,this.stack.reset()}setBuffer(e){const t=bo(e);this.bytes=t,this.view=new DataView(t.buffer,t.byteOffset,t.byteLength),this.pos=0}appendBuffer(e){if(this.headByte===Ti&&!this.hasRemaining(1))this.setBuffer(e);else{const t=this.bytes.subarray(this.pos),i=bo(e),r=new Uint8Array(t.length+i.length);r.set(t),r.set(i,t.length),this.setBuffer(r)}}hasRemaining(e){return this.view.byteLength-this.pos>=e}createExtraByteError(e){const{view:t,pos:i}=this;return new RangeError(`Extra ${t.byteLength-i} of ${t.byteLength} byte(s) found at buffer[${e}]`)}decode(e){if(this.entered)return this.clone().decode(e);try{this.entered=!0,this.reinitializeState(),this.setBuffer(e);const t=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return t}finally{this.entered=!1}}*decodeMulti(e){if(this.entered){yield*this.clone().decodeMulti(e);return}try{for(this.entered=!0,this.reinitializeState(),this.setBuffer(e);this.hasRemaining(1);)yield this.doDecodeSync()}finally{this.entered=!1}}async decodeAsync(e){if(this.entered)return this.clone().decodeAsync(e);try{this.entered=!0;let t=!1,i;for await(const a of e){if(t)throw this.entered=!1,this.createExtraByteError(this.totalPos);this.appendBuffer(a);try{i=this.doDecodeSync(),t=!0}catch(c){if(!(c instanceof RangeError))throw c}this.totalPos+=this.pos}if(t){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return i}const{headByte:r,pos:n,totalPos:o}=this;throw new RangeError(`Insufficient data in parsing ${Rn(r)} at ${o} (${n} in the current buffer)`)}finally{this.entered=!1}}decodeArrayStream(e){return this.decodeMultiAsync(e,!0)}decodeStream(e){return this.decodeMultiAsync(e,!1)}async*decodeMultiAsync(e,t){if(this.entered){yield*this.clone().decodeMultiAsync(e,t);return}try{this.entered=!0;let i=t,r=-1;for await(const n of e){if(t&&r===0)throw this.createExtraByteError(this.totalPos);this.appendBuffer(n),i&&(r=this.readArraySize(),i=!1,this.complete());try{for(;yield this.doDecodeSync(),--r!==0;);}catch(o){if(!(o instanceof RangeError))throw o}this.totalPos+=this.pos}}finally{this.entered=!1}}doDecodeSync(){e:for(;;){const e=this.readHeadByte();let t;if(e>=224)t=e-256;else if(e<192)if(e<128)t=e;else if(e<144){const r=e-128;if(r!==0){this.pushMapState(r),this.complete();continue e}else t={}}else if(e<160){const r=e-144;if(r!==0){this.pushArrayState(r),this.complete();continue e}else t=[]}else{const r=e-160;t=this.decodeString(r,0)}else if(e===192)t=null;else if(e===194)t=!1;else if(e===195)t=!0;else if(e===202)t=this.readF32();else if(e===203)t=this.readF64();else if(e===204)t=this.readU8();else if(e===205)t=this.readU16();else if(e===206)t=this.readU32();else if(e===207)this.useBigInt64?t=this.readU64AsBigInt():t=this.readU64();else if(e===208)t=this.readI8();else if(e===209)t=this.readI16();else if(e===210)t=this.readI32();else if(e===211)this.useBigInt64?t=this.readI64AsBigInt():t=this.readI64();else if(e===217){const r=this.lookU8();t=this.decodeString(r,1)}else if(e===218){const r=this.lookU16();t=this.decodeString(r,2)}else if(e===219){const r=this.lookU32();t=this.decodeString(r,4)}else if(e===220){const r=this.readU16();if(r!==0){this.pushArrayState(r),this.complete();continue e}else t=[]}else if(e===221){const r=this.readU32();if(r!==0){this.pushArrayState(r),this.complete();continue e}else t=[]}else if(e===222){const r=this.readU16();if(r!==0){this.pushMapState(r),this.complete();continue e}else t={}}else if(e===223){const r=this.readU32();if(r!==0){this.pushMapState(r),this.complete();continue e}else t={}}else if(e===196){const r=this.lookU8();t=this.decodeBinary(r,1)}else if(e===197){const r=this.lookU16();t=this.decodeBinary(r,2)}else if(e===198){const r=this.lookU32();t=this.decodeBinary(r,4)}else if(e===212)t=this.decodeExtension(1,0);else if(e===213)t=this.decodeExtension(2,0);else if(e===214)t=this.decodeExtension(4,0);else if(e===215)t=this.decodeExtension(8,0);else if(e===216)t=this.decodeExtension(16,0);else if(e===199){const r=this.lookU8();t=this.decodeExtension(r,1)}else if(e===200){const r=this.lookU16();t=this.decodeExtension(r,2)}else if(e===201){const r=this.lookU32();t=this.decodeExtension(r,4)}else throw new lt(`Unrecognized type byte: ${Rn(e)}`);this.complete();const i=this.stack;for(;i.length>0;){const r=i.top();if(r.type===vo)if(r.array[r.position]=t,r.position++,r.position===r.size)t=r.array,i.release(r);else continue e;else if(r.type===Wi){if(t==="__proto__")throw new lt("The key __proto__ is not allowed");r.key=this.mapKeyConverter(t),r.type=Wh;continue e}else if(r.map[r.key]=t,r.readCount++,r.readCount===r.size)t=r.map,i.release(r);else{r.key=null,r.type=Wi;continue e}}return t}}readHeadByte(){return this.headByte===Ti&&(this.headByte=this.readU8()),this.headByte}complete(){this.headByte=Ti}readArraySize(){const e=this.readHeadByte();switch(e){case 220:return this.readU16();case 221:return this.readU32();default:{if(e<160)return e-144;throw new lt(`Unrecognized array type byte: ${Rn(e)}`)}}}pushMapState(e){if(e>this.maxMapLength)throw new lt(`Max length exceeded: map length (${e}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.pushMapState(e)}pushArrayState(e){if(e>this.maxArrayLength)throw new lt(`Max length exceeded: array length (${e}) > maxArrayLength (${this.maxArrayLength})`);this.stack.pushArrayState(e)}decodeString(e,t){return!this.rawStrings||this.stateIsMapKey()?this.decodeUtf8String(e,t):this.decodeBinary(e,t)}decodeUtf8String(e,t){var n;if(e>this.maxStrLength)throw new lt(`Max length exceeded: UTF-8 byte length (${e}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+t+e)throw gc;const i=this.pos+t;let r;return this.stateIsMapKey()&&((n=this.keyDecoder)!=null&&n.canBeCached(e))?r=this.keyDecoder.decode(this.bytes,i,e):r=gy(this.bytes,i,e),this.pos+=t+e,r}stateIsMapKey(){return this.stack.length>0?this.stack.top().type===Wi:!1}decodeBinary(e,t){if(e>this.maxBinLength)throw new lt(`Max length exceeded: bin length (${e}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining(e+t))throw gc;const i=this.pos+t,r=this.bytes.subarray(i,i+e);return this.pos+=t+e,r}decodeExtension(e,t){if(e>this.maxExtLength)throw new lt(`Max length exceeded: ext length (${e}) > maxExtLength (${this.maxExtLength})`);const i=this.view.getInt8(this.pos+t),r=this.decodeBinary(e,t+1);return this.extensionCodec.decode(r,i,this.context)}lookU8(){return this.view.getUint8(this.pos)}lookU16(){return this.view.getUint16(this.pos)}lookU32(){return this.view.getUint32(this.pos)}readU8(){const e=this.view.getUint8(this.pos);return this.pos++,e}readI8(){const e=this.view.getInt8(this.pos);return this.pos++,e}readU16(){const e=this.view.getUint16(this.pos);return this.pos+=2,e}readI16(){const e=this.view.getInt16(this.pos);return this.pos+=2,e}readU32(){const e=this.view.getUint32(this.pos);return this.pos+=4,e}readI32(){const e=this.view.getInt32(this.pos);return this.pos+=4,e}readU64(){const e=my(this.view,this.pos);return this.pos+=8,e}readI64(){const e=Vh(this.view,this.pos);return this.pos+=8,e}readU64AsBigInt(){const e=this.view.getBigUint64(this.pos);return this.pos+=8,e}readI64AsBigInt(){const e=this.view.getBigInt64(this.pos);return this.pos+=8,e}readF32(){const e=this.view.getFloat32(this.pos);return this.pos+=4,e}readF64(){const e=this.view.getFloat64(this.pos);return this.pos+=8,e}}function Ly(s,e){return new ya(e).decode(s)}var My={};const qy=":";function os(s){const[e,t]=s.split(qy);return{namespace:e,reference:t}}function Gh(s,e){return s.includes(":")?[s]:e.chains||[]}const jy={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}},Fy={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 F(s,e){const{message:t,code:i}=Fy[s];return{message:e?`${t} ${e}`:t,code:i}}function ye(s,e){const{message:t,code:i}=jy[s];return{message:e?`${t} ${e}`:t,code:i}}var zy=Object.defineProperty,Ky=Object.defineProperties,Hy=Object.getOwnPropertyDescriptors,yc=Object.getOwnPropertySymbols,Vy=Object.prototype.hasOwnProperty,Wy=Object.prototype.propertyIsEnumerable,Eo=(s,e,t)=>e in s?zy(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,mc=(s,e)=>{for(var t in e||(e={}))Vy.call(e,t)&&Eo(s,t,e[t]);if(yc)for(var t of yc(e))Wy.call(e,t)&&Eo(s,t,e[t]);return s},Gy=(s,e)=>Ky(s,Hy(e)),wc=(s,e,t)=>Eo(s,typeof e!="symbol"?e+"":e,t);const Yy="ReactNative",dt={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},Zy="js";function Vr(){return typeof Ki<"u"&&typeof Ki.versions<"u"&&typeof Ki.versions.node<"u"}function Ts(){return!ls.getDocument()&&!!ls.getNavigator()&&navigator.product===Yy}function Jy(){return Ts()&&typeof Q<"u"&&typeof(Q==null?void 0:Q.Platform)<"u"&&(Q==null?void 0:Q.Platform.OS)==="android"}function Xy(){return Ts()&&typeof Q<"u"&&typeof(Q==null?void 0:Q.Platform)<"u"&&(Q==null?void 0:Q.Platform.OS)==="ios"}function Ci(){return!Vr()&&!!ls.getNavigator()&&!!ls.getDocument()}function ar(){return Ts()?dt.reactNative:Vr()?dt.node:Ci()?dt.browser:dt.unknown}function bc(){var s;try{return Ts()&&typeof Q<"u"&&typeof(Q==null?void 0:Q.Application)<"u"?(s=Q.Application)==null?void 0:s.applicationId:void 0}catch{return}}function Qy(s,e){const t=new URLSearchParams(s);return Object.entries(e).sort(([i],[r])=>i.localeCompare(r)).forEach(([i,r])=>{r!=null&&t.set(i,String(r))}),t.toString()}function em(s){var e,t;const i=Yh();try{return s!=null&&s.url&&i.url&&new URL(s.url).host!==new URL(i.url).host&&(console.warn(`The configured WalletConnect 'metadata.url':${s.url} differs from the actual page url:${i.url}. This is probably unintended and can lead to issues.`),s.url=i.url),(e=s==null?void 0:s.icons)!=null&&e.length&&s.icons.length>0&&(s.icons=s.icons.filter(r=>r!=="")),Gy(mc(mc({},i),s),{url:(s==null?void 0:s.url)||i.url,name:(s==null?void 0:s.name)||i.name,description:(s==null?void 0:s.description)||i.description,icons:(t=s==null?void 0:s.icons)!=null&&t.length&&s.icons.length>0?s.icons:i.icons})}catch(r){return console.warn("Error populating app metadata",r),s||i}}function Yh(){return Xd.getWindowMetadata()||{name:"",description:"",url:"",icons:[""]}}function tm(){if(ar()===dt.reactNative&&typeof Q<"u"&&typeof(Q==null?void 0:Q.Platform)<"u"){const{OS:t,Version:i}=Q.Platform;return[t,i].join("-")}const s=ef();if(s===null)return"unknown";const e=s.os?s.os.replace(" ","").toLowerCase():"unknown";return s.type==="browser"?[e,s.name,s.version].join("-"):[e,s.version].join("-")}function sm(){var s;const e=ar();return e===dt.browser?[e,((s=ls.getLocation())==null?void 0:s.host)||"unknown"].join(":"):e}function Zh(s,e,t){const i=tm(),r=sm();return[[s,e].join("-"),[Zy,t].join("-"),i,r].join("/")}function im({protocol:s,version:e,relayUrl:t,sdkVersion:i,auth:r,projectId:n,useOnCloseEvent:o,bundleId:a,packageName:c}){const l=t.split("?"),h=Zh(s,e,i),u={auth:r,ua:h,projectId:n,useOnCloseEvent:o,packageName:c||void 0,bundleId:a||void 0},d=Qy(l[1]||"",u);return l[0]+"?"+d}function Ks(s,e){return s.filter(t=>e.includes(t)).length===s.length}function xo(s){return Object.fromEntries(s.entries())}function Io(s){return new Map(Object.entries(s))}function Ms(s=j.FIVE_MINUTES,e){const t=j.toMiliseconds(s||j.FIVE_MINUTES);let i,r,n,o;return{resolve:a=>{n&&i&&(clearTimeout(n),i(a),o=Promise.resolve(a))},reject:a=>{n&&r&&(clearTimeout(n),r(a))},done:()=>new Promise((a,c)=>{if(o)return a(o);n=setTimeout(()=>{const l=F("EXPIRED"),h=new Error(e||l.message);h.code=l.code,c(h)},t),i=a,r=c})}}function Ft(s,e,t){return new Promise(async(i,r)=>{const n=setTimeout(()=>r(new Error(t)),e);try{const o=await s;i(o)}catch(o){r(o)}clearTimeout(n)})}function Jh(s,e){if(typeof e=="string"&&e.startsWith(`${s}:`))return e;if(s.toLowerCase()==="topic"){if(typeof e!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${e}`}else if(s.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: ${s}`)}function rm(s){return Jh("topic",s)}function nm(s){return Jh("id",s)}function Xh(s){const[e,t]=s.split(":"),i={id:void 0,topic:void 0};if(e==="topic"&&typeof t=="string")i.topic=t;else if(e==="id"&&Number.isInteger(Number(t)))i.id=Number(t);else throw new Error(`Invalid target, expected id:number or topic:string, got ${e}:${t}`);return i}function xe(s,e){return j.fromMiliseconds(Date.now()+j.toMiliseconds(s))}function jt(s){return Date.now()>=j.toMiliseconds(s)}function le(s,e){return`${s}${e?`:${e}`:""}`}function Kt(s=[],e=[]){return[...new Set([...s,...e])]}async function om({id:s,topic:e,wcDeepLink:t}){var i;try{if(!t)return;const r=typeof t=="string"?JSON.parse(t):t,n=r==null?void 0:r.href;if(typeof n!="string")return;const o=am(n,s,e),a=ar();if(a===dt.browser){if(!((i=ls.getDocument())!=null&&i.hasFocus())){console.warn("Document does not have focus, skipping deeplink.");return}cm(o)}else a===dt.reactNative&&typeof(Q==null?void 0:Q.Linking)<"u"&&await Q.Linking.openURL(o)}catch(r){console.error(r)}}function am(s,e,t){const i=`requestId=${e}&sessionTopic=${t}`;s.endsWith("/")&&(s=s.slice(0,-1));let r=`${s}`;if(s.startsWith("https://t.me")){const n=s.includes("?")?"&startapp=":"?startapp=";r=`${r}${n}${dm(i,!0)}`}else r=`${r}/wc?${i}`;return r}function cm(s){let e="_self";um()?e="_top":(hm()||s.startsWith("https://")||s.startsWith("http://"))&&(e="_blank"),window.open(s,e,"noreferrer noopener")}async function lm(s,e){let t="";try{if(Ci()&&(t=localStorage.getItem(e),t))return t;t=await s.getItem(e)}catch(i){console.error(i)}return t}function vc(s,e){if(!s.includes(e))return null;const t=s.split(/([&,?,=])/),i=t.indexOf(e);return t[i+2]}function Ec(){return typeof crypto<"u"&&crypto!=null&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,s=>{const e=Math.random()*16|0;return(s==="x"?e:e&3|8).toString(16)})}function ma(){return typeof Ki<"u"&&My.IS_VITEST==="true"}function hm(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)}function um(){try{return window.self!==window.top}catch{return!1}}function dm(s,e=!1){const t=ie.from(s).toString("base64");return e?t.replace(/[=]/g,""):t}function Qh(s){return ie.from(s,"base64").toString("utf-8")}function fm(s){return new Promise(e=>setTimeout(e,s))}let pm=class{constructor({limit:e}){wc(this,"limit"),wc(this,"set"),this.limit=e,this.set=new Set}add(e){if(!this.set.has(e)){if(this.set.size>=this.limit){const t=this.set.values().next().value;t&&this.set.delete(t)}this.set.add(e)}}has(e){return this.set.has(e)}};const br=BigInt(2**32-1),xc=BigInt(32);function eu(s,e=!1){return e?{h:Number(s&br),l:Number(s>>xc&br)}:{h:Number(s>>xc&br)|0,l:Number(s&br)|0}}function tu(s,e=!1){const t=s.length;let i=new Uint32Array(t),r=new Uint32Array(t);for(let n=0;n<t;n++){const{h:o,l:a}=eu(s[n],e);[i[n],r[n]]=[o,a]}return[i,r]}const Ic=(s,e,t)=>s>>>t,Sc=(s,e,t)=>s<<32-t|e>>>t,Es=(s,e,t)=>s>>>t|e<<32-t,xs=(s,e,t)=>s<<32-t|e>>>t,qi=(s,e,t)=>s<<64-t|e>>>t-32,ji=(s,e,t)=>s>>>t-32|e<<64-t,gm=(s,e)=>e,ym=(s,e)=>s,mm=(s,e,t)=>s<<t|e>>>32-t,wm=(s,e,t)=>e<<t|s>>>32-t,bm=(s,e,t)=>e<<t-32|s>>>64-t,vm=(s,e,t)=>s<<t-32|e>>>64-t;function _t(s,e,t,i){const r=(e>>>0)+(i>>>0);return{h:s+t+(r/2**32|0)|0,l:r|0}}const wa=(s,e,t)=>(s>>>0)+(e>>>0)+(t>>>0),ba=(s,e,t,i)=>e+t+i+(s/2**32|0)|0,Em=(s,e,t,i)=>(s>>>0)+(e>>>0)+(t>>>0)+(i>>>0),xm=(s,e,t,i,r)=>e+t+i+r+(s/2**32|0)|0,Im=(s,e,t,i,r)=>(s>>>0)+(e>>>0)+(t>>>0)+(i>>>0)+(r>>>0),Sm=(s,e,t,i,r,n)=>e+t+i+r+n+(s/2**32|0)|0,ri=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function cn(s){return s instanceof Uint8Array||ArrayBuffer.isView(s)&&s.constructor.name==="Uint8Array"}function hs(s){if(!Number.isSafeInteger(s)||s<0)throw new Error("positive integer expected, got "+s)}function Nt(s,...e){if(!cn(s))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(s.length))throw new Error("Uint8Array expected of length "+e+", got length="+s.length)}function ln(s){if(typeof s!="function"||typeof s.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");hs(s.outputLen),hs(s.blockLen)}function Ns(s,e=!0){if(s.destroyed)throw new Error("Hash instance has been destroyed");if(e&&s.finished)throw new Error("Hash#digest() has already been called")}function va(s,e){Nt(s);const t=e.outputLen;if(s.length<t)throw new Error("digestInto() expects output buffer of length at least "+t)}function tr(s){return new Uint32Array(s.buffer,s.byteOffset,Math.floor(s.byteLength/4))}function It(...s){for(let e=0;e<s.length;e++)s[e].fill(0)}function Un(s){return new DataView(s.buffer,s.byteOffset,s.byteLength)}function $t(s,e){return s<<32-e|s>>>e}const su=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function iu(s){return s<<24&4278190080|s<<8&16711680|s>>>8&65280|s>>>24&255}const Jt=su?s=>s:s=>iu(s);function Am(s){for(let e=0;e<s.length;e++)s[e]=iu(s[e]);return s}const Is=su?s=>s:Am,ru=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Cm=Array.from({length:256},(s,e)=>e.toString(16).padStart(2,"0"));function gi(s){if(Nt(s),ru)return s.toHex();let e="";for(let t=0;t<s.length;t++)e+=Cm[s[t]];return e}const Yt={_0:48,_9:57,A:65,F:70,a:97,f:102};function Ac(s){if(s>=Yt._0&&s<=Yt._9)return s-Yt._0;if(s>=Yt.A&&s<=Yt.F)return s-(Yt.A-10);if(s>=Yt.a&&s<=Yt.f)return s-(Yt.a-10)}function Wr(s){if(typeof s!="string")throw new Error("hex string expected, got "+typeof s);if(ru)return Uint8Array.fromHex(s);const e=s.length,t=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const i=new Uint8Array(t);for(let r=0,n=0;r<t;r++,n+=2){const o=Ac(s.charCodeAt(n)),a=Ac(s.charCodeAt(n+1));if(o===void 0||a===void 0){const c=s[n]+s[n+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+n)}i[r]=o*16+a}return i}function nu(s){if(typeof s!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(s))}function Ot(s){return typeof s=="string"&&(s=nu(s)),Nt(s),s}function As(...s){let e=0;for(let i=0;i<s.length;i++){const r=s[i];Nt(r),e+=r.length}const t=new Uint8Array(e);for(let i=0,r=0;i<s.length;i++){const n=s[i];t.set(n,r),r+=n.length}return t}let hn=class{};function cr(s){const e=i=>s().update(Ot(i)).digest(),t=s();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>s(),e}function _m(s){const e=(i,r)=>s(r).update(Ot(i)).digest(),t=s({});return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=i=>s(i),e}function ei(s=32){if(ri&&typeof ri.getRandomValues=="function")return ri.getRandomValues(new Uint8Array(s));if(ri&&typeof ri.randomBytes=="function")return Uint8Array.from(ri.randomBytes(s));throw new Error("crypto.getRandomValues must be defined")}const Pm=BigInt(0),$i=BigInt(1),Om=BigInt(2),Nm=BigInt(7),Tm=BigInt(256),$m=BigInt(113),ou=[],au=[],cu=[];for(let s=0,e=$i,t=1,i=0;s<24;s++){[t,i]=[i,(2*t+3*i)%5],ou.push(2*(5*i+t)),au.push((s+1)*(s+2)/2%64);let r=Pm;for(let n=0;n<7;n++)e=(e<<$i^(e>>Nm)*$m)%Tm,e&Om&&(r^=$i<<($i<<BigInt(n))-$i);cu.push(r)}const lu=tu(cu,!0),km=lu[0],Rm=lu[1],Cc=(s,e,t)=>t>32?bm(s,e,t):mm(s,e,t),_c=(s,e,t)=>t>32?vm(s,e,t):wm(s,e,t);function Um(s,e=24){const t=new Uint32Array(10);for(let i=24-e;i<24;i++){for(let o=0;o<10;o++)t[o]=s[o]^s[o+10]^s[o+20]^s[o+30]^s[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,c=(o+2)%10,l=t[c],h=t[c+1],u=Cc(l,h,1)^t[a],d=_c(l,h,1)^t[a+1];for(let f=0;f<50;f+=10)s[o+f]^=u,s[o+f+1]^=d}let r=s[2],n=s[3];for(let o=0;o<24;o++){const a=au[o],c=Cc(r,n,a),l=_c(r,n,a),h=ou[o];r=s[h],n=s[h+1],s[h]=c,s[h+1]=l}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)t[a]=s[o+a];for(let a=0;a<10;a++)s[o+a]^=~t[(a+2)%10]&t[(a+4)%10]}s[0]^=km[i],s[1]^=Rm[i]}It(t)}let Bm=class hu extends hn{constructor(e,t,i,r=!1,n=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=e,this.suffix=t,this.outputLen=i,this.enableXOF=r,this.rounds=n,hs(i),!(0<e&&e<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=tr(this.state)}clone(){return this._cloneInto()}keccak(){Is(this.state32),Um(this.state32,this.rounds),Is(this.state32),this.posOut=0,this.pos=0}update(e){Ns(this),e=Ot(e),Nt(e);const{blockLen:t,state:i}=this,r=e.length;for(let n=0;n<r;){const o=Math.min(t-this.pos,r-n);for(let a=0;a<o;a++)i[this.pos++]^=e[n++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:i,blockLen:r}=this;e[i]^=t,(t&128)!==0&&i===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){Ns(this,!1),Nt(e),this.finish();const t=this.state,{blockLen:i}=this;for(let r=0,n=e.length;r<n;){this.posOut>=i&&this.keccak();const o=Math.min(i-this.posOut,n-r);e.set(t.subarray(this.posOut,this.posOut+o),r),this.posOut+=o,r+=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 hs(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(va(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,It(this.state)}_cloneInto(e){const{blockLen:t,suffix:i,outputLen:r,rounds:n,enableXOF:o}=this;return e||(e=new hu(t,i,r,o,n)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=n,e.suffix=i,e.outputLen=r,e.enableXOF=o,e.destroyed=this.destroyed,e}};const Dm=(s,e,t)=>cr(()=>new Bm(e,s,t)),Lm=Dm(1,136,256/8);function Mm(s,e,t,i){if(typeof s.setBigUint64=="function")return s.setBigUint64(e,t,i);const r=BigInt(32),n=BigInt(4294967295),o=Number(t>>r&n),a=Number(t&n),c=i?4:0,l=i?0:4;s.setUint32(e+c,o,i),s.setUint32(e+l,a,i)}function qm(s,e,t){return s&e^~s&t}function jm(s,e,t){return s&e^s&t^e&t}let uu=class extends hn{constructor(e,t,i,r){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=t,this.padOffset=i,this.isLE=r,this.buffer=new Uint8Array(e),this.view=Un(this.buffer)}update(e){Ns(this),e=Ot(e),Nt(e);const{view:t,buffer:i,blockLen:r}=this,n=e.length;for(let o=0;o<n;){const a=Math.min(r-this.pos,n-o);if(a===r){const c=Un(e);for(;r<=n-o;o+=r)this.process(c,o);continue}i.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===r&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Ns(this),va(e,this),this.finished=!0;const{buffer:t,view:i,blockLen:r,isLE:n}=this;let{pos:o}=this;t[o++]=128,It(this.buffer.subarray(o)),this.padOffset>r-o&&(this.process(i,0),o=0);for(let u=o;u<r;u++)t[u]=0;Mm(i,r-8,BigInt(this.length*8),n),this.process(i,0);const a=Un(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:t}=this;this.digestInto(e);const i=e.slice(0,t);return this.destroy(),i}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:i,length:r,finished:n,destroyed:o,pos:a}=this;return e.destroyed=o,e.finished=n,e.length=r,e.pos=a,r%t&&e.buffer.set(i),e}clone(){return this._cloneInto()}};const gs=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Be=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]),De=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),Fm=Uint32Array.from([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]),ys=new Uint32Array(64);class zm extends uu{constructor(e=32){super(64,e,8,!1),this.A=gs[0]|0,this.B=gs[1]|0,this.C=gs[2]|0,this.D=gs[3]|0,this.E=gs[4]|0,this.F=gs[5]|0,this.G=gs[6]|0,this.H=gs[7]|0}get(){const{A:e,B:t,C:i,D:r,E:n,F:o,G:a,H:c}=this;return[e,t,i,r,n,o,a,c]}set(e,t,i,r,n,o,a,c){this.A=e|0,this.B=t|0,this.C=i|0,this.D=r|0,this.E=n|0,this.F=o|0,this.G=a|0,this.H=c|0}process(e,t){for(let u=0;u<16;u++,t+=4)ys[u]=e.getUint32(t,!1);for(let u=16;u<64;u++){const d=ys[u-15],f=ys[u-2],p=$t(d,7)^$t(d,18)^d>>>3,g=$t(f,17)^$t(f,19)^f>>>10;ys[u]=g+ys[u-7]+p+ys[u-16]|0}let{A:i,B:r,C:n,D:o,E:a,F:c,G:l,H:h}=this;for(let u=0;u<64;u++){const d=$t(a,6)^$t(a,11)^$t(a,25),f=h+d+qm(a,c,l)+Fm[u]+ys[u]|0,p=($t(i,2)^$t(i,13)^$t(i,22))+jm(i,r,n)|0;h=l,l=c,c=a,a=o+f|0,o=n,n=r,r=i,i=f+p|0}i=i+this.A|0,r=r+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(i,r,n,o,a,c,l,h)}roundClean(){It(ys)}destroy(){this.set(0,0,0,0,0,0,0,0),It(this.buffer)}}const du=tu(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(s=>BigInt(s))),Km=du[0],Hm=du[1],ms=new Uint32Array(80),ws=new Uint32Array(80);let Ea=class extends uu{constructor(e=64){super(128,e,16,!1),this.Ah=De[0]|0,this.Al=De[1]|0,this.Bh=De[2]|0,this.Bl=De[3]|0,this.Ch=De[4]|0,this.Cl=De[5]|0,this.Dh=De[6]|0,this.Dl=De[7]|0,this.Eh=De[8]|0,this.El=De[9]|0,this.Fh=De[10]|0,this.Fl=De[11]|0,this.Gh=De[12]|0,this.Gl=De[13]|0,this.Hh=De[14]|0,this.Hl=De[15]|0}get(){const{Ah:e,Al:t,Bh:i,Bl:r,Ch:n,Cl:o,Dh:a,Dl:c,Eh:l,El:h,Fh:u,Fl:d,Gh:f,Gl:p,Hh:g,Hl:m}=this;return[e,t,i,r,n,o,a,c,l,h,u,d,f,p,g,m]}set(e,t,i,r,n,o,a,c,l,h,u,d,f,p,g,m){this.Ah=e|0,this.Al=t|0,this.Bh=i|0,this.Bl=r|0,this.Ch=n|0,this.Cl=o|0,this.Dh=a|0,this.Dl=c|0,this.Eh=l|0,this.El=h|0,this.Fh=u|0,this.Fl=d|0,this.Gh=f|0,this.Gl=p|0,this.Hh=g|0,this.Hl=m|0}process(e,t){for(let I=0;I<16;I++,t+=4)ms[I]=e.getUint32(t),ws[I]=e.getUint32(t+=4);for(let I=16;I<80;I++){const E=ms[I-15]|0,N=ws[I-15]|0,$=Es(E,N,1)^Es(E,N,8)^Ic(E,N,7),U=xs(E,N,1)^xs(E,N,8)^Sc(E,N,7),D=ms[I-2]|0,P=ws[I-2]|0,B=Es(D,P,19)^qi(D,P,61)^Ic(D,P,6),M=xs(D,P,19)^ji(D,P,61)^Sc(D,P,6),_=Em(U,M,ws[I-7],ws[I-16]),b=xm(_,$,B,ms[I-7],ms[I-16]);ms[I]=b|0,ws[I]=_|0}let{Ah:i,Al:r,Bh:n,Bl:o,Ch:a,Cl:c,Dh:l,Dl:h,Eh:u,El:d,Fh:f,Fl:p,Gh:g,Gl:m,Hh:S,Hl:k}=this;for(let I=0;I<80;I++){const E=Es(u,d,14)^Es(u,d,18)^qi(u,d,41),N=xs(u,d,14)^xs(u,d,18)^ji(u,d,41),$=u&f^~u&g,U=d&p^~d&m,D=Im(k,N,U,Hm[I],ws[I]),P=Sm(D,S,E,$,Km[I],ms[I]),B=D|0,M=Es(i,r,28)^qi(i,r,34)^qi(i,r,39),_=xs(i,r,28)^ji(i,r,34)^ji(i,r,39),b=i&n^i&a^n&a,x=r&o^r&c^o&c;S=g|0,k=m|0,g=f|0,m=p|0,f=u|0,p=d|0,{h:u,l:d}=_t(l|0,h|0,P|0,B|0),l=a|0,h=c|0,a=n|0,c=o|0,n=i|0,o=r|0;const y=wa(B,_,x);i=ba(y,P,M,b),r=y|0}({h:i,l:r}=_t(this.Ah|0,this.Al|0,i|0,r|0)),{h:n,l:o}=_t(this.Bh|0,this.Bl|0,n|0,o|0),{h:a,l:c}=_t(this.Ch|0,this.Cl|0,a|0,c|0),{h:l,l:h}=_t(this.Dh|0,this.Dl|0,l|0,h|0),{h:u,l:d}=_t(this.Eh|0,this.El|0,u|0,d|0),{h:f,l:p}=_t(this.Fh|0,this.Fl|0,f|0,p|0),{h:g,l:m}=_t(this.Gh|0,this.Gl|0,g|0,m|0),{h:S,l:k}=_t(this.Hh|0,this.Hl|0,S|0,k|0),this.set(i,r,n,o,a,c,l,h,u,d,f,p,g,m,S,k)}roundClean(){It(ms,ws)}destroy(){It(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};class Vm extends Ea{constructor(){super(48),this.Ah=Be[0]|0,this.Al=Be[1]|0,this.Bh=Be[2]|0,this.Bl=Be[3]|0,this.Ch=Be[4]|0,this.Cl=Be[5]|0,this.Dh=Be[6]|0,this.Dl=Be[7]|0,this.Eh=Be[8]|0,this.El=Be[9]|0,this.Fh=Be[10]|0,this.Fl=Be[11]|0,this.Gh=Be[12]|0,this.Gl=Be[13]|0,this.Hh=Be[14]|0,this.Hl=Be[15]|0}}const Le=Uint32Array.from([573645204,4230739756,2673172387,3360449730,596883563,1867755857,2520282905,1497426621,2519219938,2827943907,3193839141,1401305490,721525244,746961066,246885852,2177182882]);class Wm extends Ea{constructor(){super(32),this.Ah=Le[0]|0,this.Al=Le[1]|0,this.Bh=Le[2]|0,this.Bl=Le[3]|0,this.Ch=Le[4]|0,this.Cl=Le[5]|0,this.Dh=Le[6]|0,this.Dl=Le[7]|0,this.Eh=Le[8]|0,this.El=Le[9]|0,this.Fh=Le[10]|0,this.Fl=Le[11]|0,this.Gh=Le[12]|0,this.Gl=Le[13]|0,this.Hh=Le[14]|0,this.Hl=Le[15]|0}}const un=cr(()=>new zm),Gm=cr(()=>new Ea),Ym=cr(()=>new Vm),Zm=cr(()=>new Wm),Jm=Uint8Array.from([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9]),Se=Uint32Array.from([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),K=new Uint32Array(32);function bs(s,e,t,i,r,n){const o=r[n],a=r[n+1];let c=K[2*s],l=K[2*s+1],h=K[2*e],u=K[2*e+1],d=K[2*t],f=K[2*t+1],p=K[2*i],g=K[2*i+1],m=wa(c,h,o);l=ba(m,l,u,a),c=m|0,{Dh:g,Dl:p}={Dh:g^l,Dl:p^c},{Dh:g,Dl:p}={Dh:gm(g,p),Dl:ym(g)},{h:f,l:d}=_t(f,d,g,p),{Bh:u,Bl:h}={Bh:u^f,Bl:h^d},{Bh:u,Bl:h}={Bh:Es(u,h,24),Bl:xs(u,h,24)},K[2*s]=c,K[2*s+1]=l,K[2*e]=h,K[2*e+1]=u,K[2*t]=d,K[2*t+1]=f,K[2*i]=p,K[2*i+1]=g}function vs(s,e,t,i,r,n){const o=r[n],a=r[n+1];let c=K[2*s],l=K[2*s+1],h=K[2*e],u=K[2*e+1],d=K[2*t],f=K[2*t+1],p=K[2*i],g=K[2*i+1],m=wa(c,h,o);l=ba(m,l,u,a),c=m|0,{Dh:g,Dl:p}={Dh:g^l,Dl:p^c},{Dh:g,Dl:p}={Dh:Es(g,p,16),Dl:xs(g,p,16)},{h:f,l:d}=_t(f,d,g,p),{Bh:u,Bl:h}={Bh:u^f,Bl:h^d},{Bh:u,Bl:h}={Bh:qi(u,h,63),Bl:ji(u,h,63)},K[2*s]=c,K[2*s+1]=l,K[2*e]=h,K[2*e+1]=u,K[2*t]=d,K[2*t+1]=f,K[2*i]=p,K[2*i+1]=g}function Xm(s,e={},t,i,r){if(hs(t),s<0||s>t)throw new Error("outputLen bigger than keyLen");const{key:n,salt:o,personalization:a}=e;if(n!==void 0&&(n.length<1||n.length>t))throw new Error("key length must be undefined or 1.."+t);if(o!==void 0&&o.length!==i)throw new Error("salt must be undefined or "+i);if(a!==void 0&&a.length!==r)throw new Error("personalization must be undefined or "+r)}class Qm extends hn{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,this.length=0,this.pos=0,hs(e),hs(t),this.blockLen=e,this.outputLen=t,this.buffer=new Uint8Array(e),this.buffer32=tr(this.buffer)}update(e){Ns(this),e=Ot(e),Nt(e);const{blockLen:t,buffer:i,buffer32:r}=this,n=e.length,o=e.byteOffset,a=e.buffer;for(let c=0;c<n;){this.pos===t&&(Is(r),this.compress(r,0,!1),Is(r),this.pos=0);const l=Math.min(t-this.pos,n-c),h=o+c;if(l===t&&!(h%4)&&c+l<n){const u=new Uint32Array(a,h,Math.floor((n-c)/4));Is(u);for(let d=0;c+t<n;d+=r.length,c+=t)this.length+=t,this.compress(u,d,!1);Is(u);continue}i.set(e.subarray(c,c+l),this.pos),this.pos+=l,this.length+=l,c+=l}return this}digestInto(e){Ns(this),va(e,this);const{pos:t,buffer32:i}=this;this.finished=!0,It(this.buffer.subarray(t)),Is(i),this.compress(i,0,!0),Is(i);const r=tr(e);this.get().forEach((n,o)=>r[o]=Jt(n))}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const i=e.slice(0,t);return this.destroy(),i}_cloneInto(e){const{buffer:t,length:i,finished:r,destroyed:n,outputLen:o,pos:a}=this;return e||(e=new this.constructor({dkLen:o})),e.set(...this.get()),e.buffer.set(t),e.destroyed=n,e.finished=r,e.length=i,e.pos=a,e.outputLen=o,e}clone(){return this._cloneInto()}}class ew extends Qm{constructor(e={}){const t=e.dkLen===void 0?64:e.dkLen;super(128,t),this.v0l=Se[0]|0,this.v0h=Se[1]|0,this.v1l=Se[2]|0,this.v1h=Se[3]|0,this.v2l=Se[4]|0,this.v2h=Se[5]|0,this.v3l=Se[6]|0,this.v3h=Se[7]|0,this.v4l=Se[8]|0,this.v4h=Se[9]|0,this.v5l=Se[10]|0,this.v5h=Se[11]|0,this.v6l=Se[12]|0,this.v6h=Se[13]|0,this.v7l=Se[14]|0,this.v7h=Se[15]|0,Xm(t,e,64,16,16);let{key:i,personalization:r,salt:n}=e,o=0;if(i!==void 0&&(i=Ot(i),o=i.length),this.v0l^=this.outputLen|o<<8|65536|1<<24,n!==void 0){n=Ot(n);const a=tr(n);this.v4l^=Jt(a[0]),this.v4h^=Jt(a[1]),this.v5l^=Jt(a[2]),this.v5h^=Jt(a[3])}if(r!==void 0){r=Ot(r);const a=tr(r);this.v6l^=Jt(a[0]),this.v6h^=Jt(a[1]),this.v7l^=Jt(a[2]),this.v7h^=Jt(a[3])}if(i!==void 0){const a=new Uint8Array(this.blockLen);a.set(i),this.update(a)}}get(){let{v0l:e,v0h:t,v1l:i,v1h:r,v2l:n,v2h:o,v3l:a,v3h:c,v4l:l,v4h:h,v5l:u,v5h:d,v6l:f,v6h:p,v7l:g,v7h:m}=this;return[e,t,i,r,n,o,a,c,l,h,u,d,f,p,g,m]}set(e,t,i,r,n,o,a,c,l,h,u,d,f,p,g,m){this.v0l=e|0,this.v0h=t|0,this.v1l=i|0,this.v1h=r|0,this.v2l=n|0,this.v2h=o|0,this.v3l=a|0,this.v3h=c|0,this.v4l=l|0,this.v4h=h|0,this.v5l=u|0,this.v5h=d|0,this.v6l=f|0,this.v6h=p|0,this.v7l=g|0,this.v7h=m|0}compress(e,t,i){this.get().forEach((c,l)=>K[l]=c),K.set(Se,16);let{h:r,l:n}=eu(BigInt(this.length));K[24]=Se[8]^n,K[25]=Se[9]^r,i&&(K[28]=~K[28],K[29]=~K[29]);let o=0;const a=Jm;for(let c=0;c<12;c++)bs(0,4,8,12,e,t+2*a[o++]),vs(0,4,8,12,e,t+2*a[o++]),bs(1,5,9,13,e,t+2*a[o++]),vs(1,5,9,13,e,t+2*a[o++]),bs(2,6,10,14,e,t+2*a[o++]),vs(2,6,10,14,e,t+2*a[o++]),bs(3,7,11,15,e,t+2*a[o++]),vs(3,7,11,15,e,t+2*a[o++]),bs(0,5,10,15,e,t+2*a[o++]),vs(0,5,10,15,e,t+2*a[o++]),bs(1,6,11,12,e,t+2*a[o++]),vs(1,6,11,12,e,t+2*a[o++]),bs(2,7,8,13,e,t+2*a[o++]),vs(2,7,8,13,e,t+2*a[o++]),bs(3,4,9,14,e,t+2*a[o++]),vs(3,4,9,14,e,t+2*a[o++]);this.v0l^=K[0]^K[16],this.v0h^=K[1]^K[17],this.v1l^=K[2]^K[18],this.v1h^=K[3]^K[19],this.v2l^=K[4]^K[20],this.v2h^=K[5]^K[21],this.v3l^=K[6]^K[22],this.v3h^=K[7]^K[23],this.v4l^=K[8]^K[24],this.v4h^=K[9]^K[25],this.v5l^=K[10]^K[26],this.v5h^=K[11]^K[27],this.v6l^=K[12]^K[28],this.v6h^=K[13]^K[29],this.v7l^=K[14]^K[30],this.v7h^=K[15]^K[31],It(K)}destroy(){this.destroyed=!0,It(this.buffer32),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const tw=_m(s=>new ew(s)),sw="https://rpc.walletconnect.org/v1";function fu(s){const e=`Ethereum Signed Message:
4
4
  ${s.length}`,t=new TextEncoder().encode(e+s);return"0x"+ie.from(Lm(t)).toString("hex")}async function iw(s,e,t,i,r,n){switch(t.t){case"eip191":return await rw(s,e,t.s);case"eip1271":return await nw(s,e,t.s,i,r,n);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${t.t}`)}}function rw(s,e,t){const i=Xg(t);return iy({payload:fu(e),signature:i}).toLowerCase()===s.toLowerCase()}async function nw(s,e,t,i,r,n){const o=os(i);if(!o.namespace||!o.reference)throw new Error(`isValidEip1271Signature failed: chainId must be in CAIP-2 format, received: ${i}`);try{const a="0x1626ba7e",c="0000000000000000000000000000000000000000000000000000000000000040",l=t.substring(2),h=(l.length/2).toString(16).padStart(64,"0"),u=(e.startsWith("0x")?e:fu(e)).substring(2),d=a+u+c+h+l,f=await fetch(`${n||sw}/?chainId=${i}&projectId=${r}`,{headers:{"Content-Type":"application/json"},method:"POST",body:JSON.stringify({id:ow(),jsonrpc:"2.0",method:"eth_call",params:[{to:s,data:d},"latest"]})}),{result:p}=await f.json();return p?p.slice(0,a.length).toLowerCase()===a.toLowerCase():!1}catch(a){return console.error("isValidEip1271Signature: ",a),!1}}function ow(){return Date.now()+Math.floor(Math.random()*1e3)}function aw(s){const e=atob(s),t=new Uint8Array(e.length);for(let o=0;o<e.length;o++)t[o]=e.charCodeAt(o);const i=t[0];if(i===0)throw new Error("No signatures found");const r=1+i*64;if(t.length<r)throw new Error("Transaction data too short for claimed signature count");if(t.length<100)throw new Error("Transaction too short");const n=ie.from(s,"base64").slice(1,65);return rr.encode(n)}function cw(s){const e=new Uint8Array(ie.from(s,"base64")),t=Array.from("TransactionData::").map(n=>n.charCodeAt(0)),i=new Uint8Array(t.length+e.length);i.set(t),i.set(e,t.length);const r=tw(i,{dkLen:32});return rr.encode(r)}function Pc(s){const e=new Uint8Array(un(lw(s)));return rr.encode(e)}function lw(s){if(s instanceof Uint8Array)return s;if(Array.isArray(s))return new Uint8Array(s);if(typeof s=="object"&&s!=null&&s.data)return new Uint8Array(Object.values(s.data));if(typeof s=="object"&&s)return new Uint8Array(Object.values(s));throw new Error("getNearUint8ArrayFromBytes: Unexpected result type from bytes array")}function Oc(s){const e=ie.from(s,"base64"),t=Ly(e).txn;if(!t)throw new Error("Invalid signed transaction: missing 'txn' field");const i=Ny(t),r=ie.from("TX"),n=ie.concat([r,ie.from(i)]),o=Zm(n);return df.encode(o).replace(/=+$/,"")}function Bn(s){const e=[];let t=BigInt(s);for(;t>=BigInt(128);)e.push(Number(t&BigInt(127)|BigInt(128))),t>>=BigInt(7);return e.push(Number(t)),ie.from(e)}function hw(s){const e=ie.from(s.signed.bodyBytes,"base64"),t=ie.from(s.signed.authInfoBytes,"base64"),i=ie.from(s.signature.signature,"base64"),r=[];r.push(ie.from([10])),r.push(Bn(e.length)),r.push(e),r.push(ie.from([18])),r.push(Bn(t.length)),r.push(t),r.push(ie.from([26])),r.push(Bn(i.length)),r.push(i);const n=ie.concat(r),o=un(n);return ie.from(o).toString("hex").toUpperCase()}function uw(s){var e,t;const i=[];try{if(typeof s=="string")return i.push(s),i;if(typeof s!="object")return i;s!=null&&s.id&&i.push(s.id);const r=(t=(e=s==null?void 0:s.capabilities)==null?void 0:e.caip345)==null?void 0:t.transactionHashes;r&&i.push(...r)}catch(r){console.warn("getWalletSendCallsHashes failed: ",r)}return i}var dw=Object.defineProperty,fw=Object.defineProperties,pw=Object.getOwnPropertyDescriptors,Nc=Object.getOwnPropertySymbols,gw=Object.prototype.hasOwnProperty,yw=Object.prototype.propertyIsEnumerable,Tc=(s,e,t)=>e in s?dw(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,mw=(s,e)=>{for(var t in e||(e={}))gw.call(e,t)&&Tc(s,t,e[t]);if(Nc)for(var t of Nc(e))yw.call(e,t)&&Tc(s,t,e[t]);return s},ww=(s,e)=>fw(s,pw(e));const pu="did:pkh:",bw={eip155:"Ethereum",solana:"Solana",bip122:"Bitcoin"},vw=s=>s?bw[s]||s:"",dn=s=>s==null?void 0:s.split(":"),Ew=s=>{const e=s&&dn(s);if(e)return s.includes(pu)?e[3]:e[1]},xw=s=>{const e=s&&dn(s);if(e)return s.includes(pu)?e[2]:e[0]},So=s=>{const e=s&&dn(s);if(e)return e[2]+":"+e[3]},Gr=s=>{const e=s&&dn(s);if(e)return e.pop()};async function $c(s){const{cacao:e,projectId:t}=s,{s:i,p:r}=e,n=gu(r,r.iss),o=Gr(r.iss);return await iw(o,n,i,So(r.iss),t)}const gu=(s,e)=>{const t=xw(e);if(!t)throw new Error("Invalid issuer: "+e);const i=`${s.domain} wants you to sign in with your ${vw(t)} account:`,r=Gr(e);if(!s.aud&&!s.uri)throw new Error("Either `aud` or `uri` is required to construct the message");let n=s.statement||void 0;const o=`URI: ${s.aud||s.uri}`,a=`Version: ${s.version}`,c=`Chain ID: ${Ew(e)}`,l=`Nonce: ${s.nonce}`,h=`Issued At: ${s.iat}`,u=s.exp?`Expiration Time: ${s.exp}`:void 0,d=s.nbf?`Not Before: ${s.nbf}`:void 0,f=s.requestId?`Request ID: ${s.requestId}`:void 0,p=s.resources?`Resources:${s.resources.map(m=>`
5
5
  - ${m}`).join("")}`:void 0,g=Rr(s.resources);if(g){const m=sr(g);n=Tw(n,m)}return[i,r,"",n,"",o,a,c,l,h,u,d,f,p].filter(m=>m!=null).join(`
@@ -205,4 +205,4 @@ ${s.length}`,t=new TextEncoder().encode(e+s);return"0x"+ie.from(Lm(t)).toString(
205
205
  outline: none;
206
206
  appearance: none;
207
207
  }
208
- `,zi={ERROR_CODE_UNRECOGNIZED_CHAIN_ID:4902,ERROR_CODE_DEFAULT:5e3,ERROR_INVALID_CHAIN_ID:32603};class ES extends Fd{async setUniversalProvider(e){if(!this.namespace)throw new Error("UniversalAdapter:setUniversalProvider - namespace is required");return this.addConnector(new zd({provider:e,caipNetworks:this.getCaipNetworks(),namespace:this.namespace})),Promise.resolve()}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(),this.emit("disconnect")}catch(e){console.warn("UniversalAdapter:disconnect - error",e)}return{connections:[]}}syncConnections(){return Promise.resolve()}async writeSolanaTransaction(){return Promise.resolve({hash:""})}async getAccounts({namespace:e}){var r,n,o;const t=this.provider,i=(((o=(n=(r=t==null?void 0:t.session)==null?void 0:r.namespaces)==null?void 0:n[e])==null?void 0:o.accounts)||[]).filter((a,c,l)=>l.indexOf(a)===c);return Promise.resolve({accounts:i.map(a=>Oe.createAccount({caipAddress:a,type:e==="bip122"?"payment":"eoa"}))})}async syncConnectors(){return Promise.resolve()}async getBalance(e){var o,a,c,l,h;if(!(e.caipNetwork&&Ee.BALANCE_SUPPORTED_CHAINS.includes((o=e.caipNetwork)==null?void 0:o.chainNamespace))||(a=e.caipNetwork)!=null&&a.testnet)return{balance:"0.00",symbol:((c=e.caipNetwork)==null?void 0:c.nativeCurrency.symbol)||""};const i=O.getAccountData();if(i!=null&&i.balanceLoading&&e.chainId===((l=O.state.activeCaipNetwork)==null?void 0:l.id))return{balance:(i==null?void 0:i.balance)||"0.00",symbol:(i==null?void 0:i.balanceSymbol)||""};const n=(await O.fetchTokenBalance()).find(u=>{var d,f;return u.chainId===`${(d=e.caipNetwork)==null?void 0:d.chainNamespace}:${e.chainId}`&&u.symbol===((f=e.caipNetwork)==null?void 0:f.nativeCurrency.symbol)});return{balance:(n==null?void 0:n.quantity.numeric)||"0.00",symbol:(n==null?void 0:n.symbol)||((h=e.caipNetwork)==null?void 0:h.nativeCurrency.symbol)||""}}async signMessage(e){var o,a,c;const{provider:t,message:i,address:r}=e;if(!t)throw new Error("UniversalAdapter:signMessage - provider is undefined");let n="";return((o=O.state.activeCaipNetwork)==null?void 0:o.chainNamespace)===J.CHAIN.SOLANA?n=(await t.request({method:"solana_signMessage",params:{message:of.encode(new TextEncoder().encode(i)),pubkey:r}},(a=O.state.activeCaipNetwork)==null?void 0:a.caipNetworkId)).signature:n=await t.request({method:"personal_sign",params:[i,r]},(c=O.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:""})}emitFirstAvailableConnection(){}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 r,n,o,a,c,l,h;const{caipNetwork:t}=e,i=this.getWalletConnectConnector();if(t.chainNamespace===J.CHAIN.EVM)try{await((r=i.provider)==null?void 0:r.request({method:"wallet_switchEthereumChain",params:[{chainId:Ka(t.id)}]}))}catch(u){if(u.code===zi.ERROR_CODE_UNRECOGNIZED_CHAIN_ID||u.code===zi.ERROR_INVALID_CHAIN_ID||u.code===zi.ERROR_CODE_DEFAULT||((o=(n=u==null?void 0:u.data)==null?void 0:n.originalError)==null?void 0:o.code)===zi.ERROR_CODE_UNRECOGNIZED_CHAIN_ID)try{await((l=i.provider)==null?void 0:l.request({method:"wallet_addEthereumChain",params:[{chainId:Ka(t.id),rpcUrls:[(a=t==null?void 0:t.rpcUrls.chainDefault)==null?void 0:a.http],chainName:t.name,nativeCurrency:t.nativeCurrency,blockExplorerUrls:[(c=t.blockExplorers)==null?void 0:c.default.url]}]}))}catch{throw new Error("Chain is not supported")}}(h=i.provider)==null||h.setDefaultChain(t.caipNetworkId)}getWalletConnectProvider(){const e=this.connectors.find(i=>i.type==="WALLET_CONNECT");return e==null?void 0:e.provider}}const xS=["email","socials","swaps","onramp","activity","reownBranding","multiWallet","emailCapture","payWithExchange","payments","reownAuthentication","headless"],Nr={email:{apiFeatureName:"social_login",localFeatureName:"email",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:s=>{if(!(s!=null&&s.config))return!1;const e=s.config;return!!s.isEnabled&&e.includes("email")},processFallback:s=>s===void 0?Ee.DEFAULT_REMOTE_FEATURES.email:!!s},socials:{apiFeatureName:"social_login",localFeatureName:"socials",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:s=>{if(!(s!=null&&s.config))return!1;const e=s.config;return s.isEnabled&&e.length>0?e.filter(t=>t!=="email"):!1},processFallback:s=>s===void 0?Ee.DEFAULT_REMOTE_FEATURES.socials:typeof s=="boolean"?s?Ee.DEFAULT_REMOTE_FEATURES.socials:!1:s},swaps:{apiFeatureName:"swap",localFeatureName:"swaps",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:s=>{if(!(s!=null&&s.config))return!1;const e=s.config;return s.isEnabled&&e.length>0?e:!1},processFallback:s=>s===void 0?Ee.DEFAULT_REMOTE_FEATURES.swaps:typeof s=="boolean"?s?Ee.DEFAULT_REMOTE_FEATURES.swaps:!1:s},onramp:{apiFeatureName:"onramp",localFeatureName:"onramp",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:s=>{if(!(s!=null&&s.config))return!1;const e=s.config;return s.isEnabled&&e.length>0?e:!1},processFallback:s=>s===void 0?Ee.DEFAULT_REMOTE_FEATURES.onramp:typeof s=="boolean"?s?Ee.DEFAULT_REMOTE_FEATURES.onramp:!1:s},activity:{apiFeatureName:"activity",localFeatureName:"history",returnType:!1,isLegacy:!0,isAvailableOnBasic:!1,processApi:s=>!!s.isEnabled,processFallback:s=>s===void 0?Ee.DEFAULT_REMOTE_FEATURES.activity:!!s},reownBranding:{apiFeatureName:"reown_branding",localFeatureName:"reownBranding",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:s=>!!s.isEnabled,processFallback:s=>s===void 0?Ee.DEFAULT_REMOTE_FEATURES.reownBranding:!!s},emailCapture:{apiFeatureName:"email_capture",localFeatureName:"emailCapture",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:s=>s.isEnabled&&(s.config??[]),processFallback:s=>!1},multiWallet:{apiFeatureName:"multi_wallet",localFeatureName:"multiWallet",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:s=>!!s.isEnabled,processFallback:()=>Ee.DEFAULT_REMOTE_FEATURES.multiWallet},payWithExchange:{apiFeatureName:"fund_from_exchange",localFeatureName:"payWithExchange",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:s=>!!s.isEnabled,processFallback:()=>Ee.DEFAULT_REMOTE_FEATURES.payWithExchange},payments:{apiFeatureName:"payments",localFeatureName:"payments",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:s=>!!s.isEnabled,processFallback:()=>Ee.DEFAULT_REMOTE_FEATURES.payments},reownAuthentication:{apiFeatureName:"reown_authentication",localFeatureName:"reownAuthentication",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:s=>!!s.isEnabled,processFallback:s=>typeof s>"u"?Ee.DEFAULT_REMOTE_FEATURES.reownAuthentication:!!s},headless:{apiFeatureName:"headless",localFeatureName:"headless",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:s=>!!s.isEnabled,processFallback:()=>Ee.DEFAULT_REMOTE_FEATURES.headless}},IS={localSettingsOverridden:new Set,getApiConfig(s,e){return e==null?void 0:e.find(t=>t.id===s)},addWarning(s,e){if(s!==void 0){const t=Nr[e],i=t.isLegacy?`"features.${t.localFeatureName}" (now "${e}")`:`"features.${e}"`;this.localSettingsOverridden.add(i)}},processFeature(s,e,t,i,r){const n=Nr[s],o=e[n.localFeatureName];if(r&&!n.isAvailableOnBasic)return!1;if(i){const a=this.getApiConfig(n.apiFeatureName,t);return(a==null?void 0:a.config)===null?this.processFallbackFeature(s,o):a!=null&&a.config?(o!==void 0&&this.addWarning(o,s),this.processApiFeature(s,a)):!1}return this.processFallbackFeature(s,o)},processApiFeature(s,e){return Nr[s].processApi(e)},processFallbackFeature(s,e){return Nr[s].processFallback(e)},async fetchRemoteFeatures(s){const e=s.basic??!1,t=s.features||{};this.localSettingsOverridden.clear();let i=null,r=!1;try{i=await _s.fetchProjectConfig(),r=i!=null}catch(o){console.warn("[Reown Config] Failed to fetch remote project configuration. Using local/default values.",o)}const n=r&&!e?Ee.DEFAULT_REMOTE_FEATURES:Ee.DEFAULT_REMOTE_FEATURES_DISABLED;try{for(const o of xS){const a=this.processFeature(o,t,i,r,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(r&&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.`;qe.open({debugMessage:je.ALERT_WARNINGS.LOCAL_CONFIGURATION_IGNORED.debugMessage(o)},"warning")}return n}};class SS{constructor(e){this.chainNamespaces=[],this.features={},this.remoteFeatures={},this.reportedAlertErrors={},this.getCaipNetwork=(t,i)=>{var r,n,o;if(t){const a=(r=O.getCaipNetworks(t))==null?void 0:r.find(h=>h.id===i);if(a)return a;const c=(n=O.getNetworkData(t))==null?void 0:n.caipNetwork;return c||((o=O.getRequestedCaipNetworks(t).filter(h=>h.chainNamespace===t))==null?void 0:o[0])}return O.state.activeCaipNetwork||this.defaultCaipNetwork},this.getCaipNetworkId=()=>{const t=this.getCaipNetwork();if(t)return t.id},this.getCaipNetworks=t=>O.getCaipNetworks(t),this.getActiveChainNamespace=()=>O.state.activeChain,this.setRequestedCaipNetworks=(t,i)=>{O.setRequestedCaipNetworks(t,i)},this.getApprovedCaipNetworkIds=()=>O.getAllApprovedCaipNetworkIds(),this.getCaipAddress=t=>{var i,r;return O.state.activeChain===t||!t?O.state.activeCaipAddress:(r=(i=O.state.chains.get(t))==null?void 0:i.accountState)==null?void 0:r.caipAddress},this.setClientId=t=>{Lr.setClientId(t)},this.getProvider=t=>pe.getProvider(t),this.getProviderType=t=>pe.getProviderId(t),this.getPreferredAccountType=t=>co(t),this.setCaipAddress=(t,i,r=!1)=>{if(t!==null){const n=t.split(":");if(n.length!==3||n.some(o=>!o)){console.warn(`[AppKit] setCaipAddress: invalid CAIP-10 address rejected: "${t}"`);return}}O.setAccountProp("caipAddress",t,i,r),O.setAccountProp("address",Oe.getPlainAddress(t),i,r)},this.setBalance=(t,i,r)=>{O.setAccountProp("balance",t,r),O.setAccountProp("balanceSymbol",i,r)},this.setProfileName=(t,i)=>{O.setAccountProp("profileName",t,i)},this.setProfileImage=(t,i)=>{O.setAccountProp("profileImage",t,i)},this.setUser=(t,i)=>{O.setAccountProp("user",t,i)},this.resetAccount=t=>{O.resetAccount(t)},this.setCaipNetwork=t=>{O.setActiveCaipNetwork(t)},this.setCaipNetworkOfNamespace=(t,i)=>{O.setChainNetworkData(i,{caipNetwork:t})},this.setStatus=(t,i)=>{O.setAccountProp("status",t,i),he.isConnected()?ae.setConnectionStatus("connected"):ae.setConnectionStatus("disconnected")},this.getAddressByChainNamespace=t=>{var i;return(i=O.getAccountData(t))==null?void 0:i.address},this.setConnectors=t=>{const i=[...he.state.allConnectors,...t];he.setConnectors(i)},this.setConnections=(t,i)=>{ae.setConnections(t,i),we.setConnections(t,i)},this.fetchIdentity=t=>Lr.fetchIdentity(t),this.getReownName=t=>Kd.getNamesForAddress(t),this.getConnectors=()=>he.getConnectors(),this.getConnectorImage=t=>Hd.getConnectorImage(t),this.getConnections=t=>this.remoteFeatures.multiWallet?La.getConnectionsData(t).connections:(qe.open(J.REMOTE_FEATURES_ALERTS.MULTI_WALLET_NOT_ENABLED.DEFAULT,"info"),[]),this.getRecentConnections=t=>this.remoteFeatures.multiWallet?La.getConnectionsData(t).recentConnections:(qe.open(J.REMOTE_FEATURES_ALERTS.MULTI_WALLET_NOT_ENABLED.DEFAULT,"info"),[]),this.switchConnection=async t=>{if(!this.remoteFeatures.multiWallet){qe.open(J.REMOTE_FEATURES_ALERTS.MULTI_WALLET_NOT_ENABLED.DEFAULT,"info");return}await we.switchConnection(t)},this.deleteConnection=t=>{if(!this.remoteFeatures.multiWallet){qe.open(J.REMOTE_FEATURES_ALERTS.MULTI_WALLET_NOT_ENABLED.DEFAULT,"info");return}ae.deleteAddressFromConnection(t),we.syncStorageConnections()},this.setConnectedWalletInfo=(t,i)=>{const r=pe.getProviderId(i),n=t?{...t,type:r}:void 0;O.setAccountProp("connectedWalletInfo",n,i)},this.getIsConnectedState=()=>!!O.state.activeCaipAddress,this.addAddressLabel=(t,i,r)=>{var o;const n=((o=O.getAccountData(r))==null?void 0:o.addressLabels)||{};O.setAccountProp("addressLabels",{...n,[t]:i},r)},this.removeAddressLabel=(t,i)=>{var n;const r=((n=O.getAccountData(i))==null?void 0:n.addressLabels)||{};O.setAccountProp("addressLabels",{...r,[t]:void 0},i)},this.getAddress=t=>{var r;const i=t||O.state.activeChain;return(r=O.getAccountData(i))==null?void 0:r.address},this.resetNetwork=t=>{O.resetNetwork(t)},this.addConnector=t=>{he.addConnector(t)},this.resetWcConnection=()=>{we.resetWcConnection()},this.setAddressExplorerUrl=(t,i)=>{O.setAccountProp("addressExplorerUrl",t,i)},this.setSmartAccountDeployed=(t,i)=>{O.setAccountProp("smartAccountDeployed",t,i)},this.setPreferredAccountType=(t,i)=>{O.setAccountProp("preferredAccountType",t,i)},this.setEIP6963Enabled=t=>{z.setEIP6963Enabled(t)},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,t){const i=e==null?void 0:e.map(n=>n.namespace).filter(n=>!!n);if(i!=null&&i.length)return[...new Set(i)];const r=t==null?void 0:t.map(n=>n.chainNamespace);return[...new Set(r)]}async initialize(e){var t,i,r,n,o,a;if(this.initializeProjectSettings(e),this.initControllers(e),await this.initChainAdapters(),this.sendInitializeEvent(e),(t=e.features)!=null&&t.headless&&!Vd.hasInjectedConnectors()&&_s.prefetch({fetchNetworkImages:!1,fetchConnectorImages:!1,fetchWalletRanks:!1,fetchRecommendedWallets:!0}),z.state.enableReconnect?(await this.syncExistingConnection(),await this.syncAdapterConnections()):await this.unSyncExistingConnection(),!e.basic&&!e.manualWCControl&&(this.remoteFeatures=await IS.fetchRemoteFeatures(e)),await _s.fetchUsage(),z.setRemoteFeatures(this.remoteFeatures),this.remoteFeatures.onramp&&uo.setOnrampProviders(this.remoteFeatures.onramp),((i=z.state.remoteFeatures)!=null&&i.email||Array.isArray((r=z.state.remoteFeatures)==null?void 0:r.socials)&&((n=z.state.remoteFeatures)==null?void 0:n.socials.length)>0)&&await this.checkAllowedOrigins(),(o=z.state.features)!=null&&o.reownAuthentication||(a=z.state.remoteFeatures)!=null&&a.reownAuthentication){const{ReownAuthentication:c}=await Ze(async()=>{const{ReownAuthentication:h}=await import("./features-U-ULFF0v.js");return{ReownAuthentication:h}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9])),l=z.state.siwx;l instanceof c||(l&&console.warn("ReownAuthentication option is enabled, SIWX configuration will be overridden."),z.setSIWX(new c))}}async openSend(e){var n;const t=e.namespace||O.state.activeChain,i=this.getCaipAddress(t),r=(n=this.getCaipNetwork(t))==null?void 0:n.id;if(!i)throw new Error("openSend: caipAddress not found");if((r==null?void 0:r.toString())!==e.chainId.toString()){const o=O.getCaipNetworkById(e.chainId,t);if(!o)throw new Error(`openSend: caipNetwork with chainId ${e.chainId} not found`);await this.switchNetwork(o,{throwOnFailure:!0})}try{const o=kd.getTokenSymbolByAddress(e.assetAddress);o&&await _s.fetchTokenImages([o])}catch{}return await us.open({view:"WalletSend",data:{send:e}}),new Promise((o,a)=>{const c=Ma.subscribeKey("hash",u=>{u&&(h(),o({hash:u}))}),l=us.subscribe(u=>{u.open||(h(),a(new Error("Modal closed")))}),h=this.createCleanupHandler([c,l])})}toModalOptions(){function e(i){return(i==null?void 0:i.view)==="Swap"}function t(i){return(i==null?void 0:i.view)==="WalletSend"}return{isSwap:e,isSend:t}}async checkAllowedOrigins(){try{const e=await _s.fetchAllowedOrigins();if(!Oe.isClient())return;const t=window.location.origin;vn.isOriginAllowed(t,e,J.DEFAULT_ALLOWED_ANCESTORS)||qe.open(je.ALERT_ERRORS.ORIGIN_NOT_ALLOWED,"error")}catch(e){if(!(e instanceof Error))return;switch(e.message){case"RATE_LIMITED":qe.open(je.ALERT_ERRORS.RATE_LIMITED_APP_CONFIGURATION,"error");break;case"SERVER_ERROR":{const t=e.cause instanceof Error?e.cause:e;qe.open({displayMessage:je.ALERT_ERRORS.SERVER_ERROR_APP_CONFIGURATION.displayMessage,debugMessage:je.ALERT_ERRORS.SERVER_ERROR_APP_CONFIGURATION.debugMessage(t.message)},"error");break}}}}createCleanupHandler(e){return()=>{e.forEach(t=>{try{t()}catch{}})}}sendInitializeEvent(e){var i;const{...t}=e;delete t.adapters,delete t.universalProvider,Mt.sendEvent({type:"track",event:"INITIALIZE",properties:{...t,networks:e.networks.map(r=>r.id),siweConfig:{options:((i=e.siweConfig)==null?void 0:i.options)||{}}}})}initControllers(e){this.initializeOptionsController(e),this.initializeChainController(e),this.initializeThemeController(e),this.initializeConnectionController(e),this.initializeConnectorController()}initAdapterController(){Wd.initialize(this.chainAdapters)}initializeThemeController(e){e.themeMode&&Ut.setThemeMode(e.themeMode),e.themeVariables&&Ut.setThemeVariables(e.themeVariables)}initializeChainController(e){if(!this.connectionControllerClient)throw new Error("ConnectionControllerClient must be set");O.initialize(e.adapters??[],this.caipNetworks,{connectionControllerClient:this.connectionControllerClient});const t=this.getDefaultNetwork();t&&O.setActiveCaipNetwork(t)}initializeConnectionController(e){we.initialize(e.adapters??[]),we.setWcBasic(e.basic??!1)}initializeConnectorController(){he.initialize(this.chainNamespaces)}initializeProjectSettings(e){z.setProjectId(e.projectId),z.setSdkVersion(e.sdkVersion)}initializeOptionsController(e){var r;z.setDebug(e.debug!==!1),z.setEnableWalletGuide(e.enableWalletGuide!==!1),z.setEnableWallets(e.enableWallets!==!1),z.setEIP6963Enabled(e.enableEIP6963!==!1),z.setEnableInjected(e.enableInjected!==!1),z.setEnableCoinbase(e.enableCoinbase!==!1),z.setEnableNetworkSwitch(e.enableNetworkSwitch!==!1),z.setEnableReconnect(e.enableReconnect!==!1),z.setEnableMobileFullScreen(e.enableMobileFullScreen===!0),z.setCoinbasePreference(e.coinbasePreference),z.setEnableAuthLogger(e.enableAuthLogger!==!1),z.setCustomRpcUrls(e.customRpcUrls),z.setEnableEmbedded(e.enableEmbedded),z.setAllWallets(e.allWallets),z.setIncludeWalletIds(e.includeWalletIds),z.setExcludeWalletIds(e.excludeWalletIds),z.setFeaturedWalletIds(e.featuredWalletIds),z.setTokens(e.tokens),z.setTermsConditionsUrl(e.termsConditionsUrl),z.setPrivacyPolicyUrl(e.privacyPolicyUrl),z.setCustomWallets(e.customWallets),z.setFeatures(e.features),z.setAllowUnsupportedChain(e.allowUnsupportedChain),z.setUniversalProviderConfigOverride(e.universalProviderConfigOverride),z.setPreferUniversalLinks(e.experimental_preferUniversalLinks),z.setDefaultAccountTypes(e.defaultAccountTypes);const t=this.getDefaultMetaData();if(!e.metadata&&t&&(e.metadata=t),z.setMetadata(e.metadata),z.setDisableAppend(e.disableAppend),z.setEnableEmbedded(e.enableEmbedded),z.setSIWX(e.siwx),this.features=z.state.features??{},!e.projectId){qe.open(je.ALERT_ERRORS.PROJECT_ID_NOT_CONFIGURED,"error");return}if(((r=e.adapters)==null?void 0:r.find(n=>n.namespace===J.CHAIN.EVM))&&e.siweConfig){if(e.siwx)throw new Error("Cannot set both `siweConfig` and `siwx` options");z.setSIWX(e.siweConfig.mapToSIWX())}}getDefaultMetaData(){var e,t,i,r;return Oe.isClient()?{name:((t=(e=document.getElementsByTagName("title"))==null?void 0:e[0])==null?void 0:t.textContent)||"",description:((i=document.querySelector('meta[property="og:description"]'))==null?void 0:i.content)||"",url:window.location.origin,icons:[((r=document.querySelector('link[rel~="icon"]'))==null?void 0:r.href)||""]}:null}setUnsupportedNetwork(e){const t=this.getActiveChainNamespace();if(t){const i=Pi.getUnsupportedNetwork(`${t}:${e}`);O.setActiveCaipNetwork(i)}}getDefaultNetwork(){return Pi.getCaipNetworkFromStorage(this.defaultCaipNetwork)}extendCaipNetwork(e,t){return Pi.extendCaipNetwork(e,{customNetworkImageUrls:t.chainImages,projectId:t.projectId})}extendCaipNetworks(e){return Pi.extendCaipNetworks(e.networks,{customNetworkImageUrls:e.chainImages,customRpcUrls:e.customRpcUrls,projectId:e.projectId})}extendDefaultCaipNetwork(e){const t=e.networks.find(r=>{var n;return r.id===((n=e.defaultNetwork)==null?void 0:n.id)});return t?Pi.extendCaipNetwork(t,{customNetworkImageUrls:e.chainImages,customRpcUrls:e.customRpcUrls,projectId:e.projectId}):void 0}async disconnectConnector(e,t){var i,r;try{this.setLoading(!0,e);let n={connections:[]};const o=this.getAdapter(e);return(((r=(i=O.state.chains.get(e))==null?void 0:i.accountState)==null?void 0:r.caipAddress)||!z.state.enableReconnect)&&(o!=null&&o.disconnect)&&(n=await o.disconnect({id:t})),this.setLoading(!1,e),n}catch(n){throw this.setLoading(!1,e),new Error(`Failed to disconnect chains: ${n.message}`)}}createClients(){this.connectionControllerClient={connectWalletConnect:async()=>{var l;const e=O.state.activeChain,t=this.getAdapter(e),i=(l=this.getCaipNetwork(e))==null?void 0:l.id,r=we.getConnections(e),n=this.remoteFeatures.multiWallet,o=r.length>0;if(!t)throw new Error("Adapter not found");const a=await t.connectWalletConnect(i);(!o||!n)&&this.close(),this.setClientId((a==null?void 0:a.clientId)||null),ae.setConnectedNamespaces([...O.state.chains.keys()]),await this.syncWalletConnectAccount(),await Tr.initializeIfEnabled()},connectExternal:async e=>{const t=await this.onConnectExternal(e);return await this.connectInactiveNamespaces(e,t),t?{address:t.address}:void 0},reconnectExternal:async({id:e,info:t,type:i,provider:r})=>{var a;const n=O.state.activeChain,o=this.getAdapter(n);if(!n)throw new Error("reconnectExternal: namespace not found");if(!o)throw new Error("reconnectExternal: adapter not found");o!=null&&o.reconnect&&(await(o==null?void 0:o.reconnect({id:e,info:t,type:i,provider:r,chainId:(a=this.getCaipNetwork())==null?void 0:a.id})),ae.addConnectedNamespace(n),this.syncConnectedWalletInfo(n))},disconnectConnector:async e=>{await this.disconnectConnector(e.namespace,e.id)},disconnect:async e=>{var l;const{id:t,chainNamespace:i,initialDisconnect:r}=e||{},n=i||O.state.activeChain,o=he.getConnectorId(n),a=t===J.CONNECTOR_ID.AUTH||o===J.CONNECTOR_ID.AUTH,c=t===J.CONNECTOR_ID.WALLET_CONNECT||o===J.CONNECTOR_ID.WALLET_CONNECT;try{const h=Array.from(O.state.chains.keys());let u=i?[i]:h;(c||a)&&(u=h);const d=u.map(async g=>{const m=he.getConnectorId(g),S=t||m,k=await this.disconnectConnector(g,S);k&&(a&&ae.deleteConnectedSocialProvider(),k.connections.forEach(I=>{ae.addDisconnectedConnectorId(I.connectorId,g)})),r&&this.onDisconnectNamespace({chainNamespace:g,closeModal:!1})}),f=await Promise.allSettled(d);Ma.resetSend(),we.resetWcConnection(),(l=Tr.getSIWX())!=null&&l.signOutOnDisconnect&&await Tr.clearSessions(),he.setFilterByNamespace(void 0),we.syncStorageConnections();const p=f.filter(g=>g.status==="rejected");if(p.length>0)throw new Error(p.map(g=>g.reason.message).join(", "));Mt.sendEvent({type:"track",event:"DISCONNECT_SUCCESS",properties:{namespace:i||"all"}})}catch(h){throw new Error(`Failed to disconnect chains: ${h.message}`)}},checkInstalled:e=>e?e.some(t=>{var i;return!!((i=window.ethereum)!=null&&i[String(t)])}):!!window.ethereum,signMessage:async e=>{const t=O.state.activeChain,i=this.getAdapter(O.state.activeChain);if(!t)throw new Error("signMessage: namespace not found");if(!i)throw new Error("signMessage: adapter not found");const r=this.getAddress(t);if(!r)throw new Error("signMessage: address not found");const n=await(i==null?void 0:i.signMessage({message:e,address:r,provider:pe.getProvider(t)}));return(n==null?void 0:n.signature)||""},sendTransaction:async e=>{const t=e.chainNamespace;if(!t)throw new Error("sendTransaction: namespace not found");if(Ee.SEND_SUPPORTED_NAMESPACES.includes(t)){const i=this.getAdapter(t);if(!i)throw new Error("sendTransaction: adapter not found");const r=pe.getProvider(t),n=await(i==null?void 0:i.sendTransaction({...e,caipNetwork:this.getCaipNetwork(),provider:r}));return(n==null?void 0:n.hash)||""}return""},estimateGas:async e=>{const t=e.chainNamespace;if(t===J.CHAIN.EVM){const i=this.getAdapter(t);if(!i)throw new Error("estimateGas: adapter is required but got undefined");const r=pe.getProvider(t),n=this.getCaipNetwork();if(!n)throw new Error("estimateGas: caipNetwork is required but got undefined");const o=await(i==null?void 0:i.estimateGas({...e,provider:r,caipNetwork:n}));return(o==null?void 0:o.gas)||0n}return 0n},getEnsAvatar:async()=>{var r;const e=O.state.activeChain;if(!e)throw new Error("getEnsAvatar: namespace is required but got undefined");const t=this.getAddress(e);if(!t)throw new Error("getEnsAvatar: address not found");await this.syncIdentity({address:t,chainId:Number((r=this.getCaipNetwork())==null?void 0:r.id),chainNamespace:e});const i=O.getAccountData();return(i==null?void 0:i.profileImage)||!1},getEnsAddress:async e=>await vn.resolveReownName(e),writeContract:async e=>{const t=O.state.activeChain,i=this.getAdapter(t);if(!t)throw new Error("writeContract: namespace is required but got undefined");if(!i)throw new Error("writeContract: adapter is required but got undefined");const r=this.getCaipNetwork(),n=this.getCaipAddress(),o=pe.getProvider(t);if(!r||!n)throw new Error("writeContract: caipNetwork or caipAddress is required but got undefined");const a=await(i==null?void 0:i.writeContract({...e,caipNetwork:r,provider:o,caipAddress:n}));return a==null?void 0:a.hash},writeSolanaTransaction:async e=>{const t=O.state.activeChain,i=this.getAdapter(t);if(!t)throw new Error("writeContract: namespace is required but got undefined");if(!i)throw new Error("writeContract: adapter is required but got undefined");const r=this.getCaipNetwork(),n=this.getCaipAddress(),o=pe.getProvider(t);if(!r||!n)throw new Error("writeContract: caipNetwork or caipAddress is required but got undefined");const a=await(i==null?void 0:i.writeSolanaTransaction({...e,caipNetwork:r,provider:o,caipAddress:n}));return a==null?void 0:a.hash},parseUnits:(e,t)=>{const i=this.getAdapter(O.state.activeChain);if(!i)throw new Error("parseUnits: adapter is required but got undefined");return(i==null?void 0:i.parseUnits({value:e,decimals:t}))??0n},formatUnits:(e,t)=>{const i=this.getAdapter(O.state.activeChain);if(!i)throw new Error("formatUnits: adapter is required but got undefined");return(i==null?void 0:i.formatUnits({value:e,decimals:t}))??"0"},getCapabilities:async e=>{const t=this.getAdapter(O.state.activeChain);if(!t)throw new Error("getCapabilities: adapter is required but got undefined");return await(t==null?void 0:t.getCapabilities(e))},grantPermissions:async e=>{const t=this.getAdapter(O.state.activeChain);if(!t)throw new Error("grantPermissions: adapter is required but got undefined");return await(t==null?void 0:t.grantPermissions(e))},revokePermissions:async e=>{const t=this.getAdapter(O.state.activeChain);if(!t)throw new Error("revokePermissions: adapter is required but got undefined");return t!=null&&t.revokePermissions?await t.revokePermissions(e):"0x"},walletGetAssets:async e=>{const t=this.getAdapter(O.state.activeChain);if(!t)throw new Error("walletGetAssets: adapter is required but got undefined");return await(t==null?void 0:t.walletGetAssets(e))??{}},updateBalance:e=>{const t=this.getAddress(e),i=this.getCaipNetwork(e);!i||!t||this.updateNativeBalance(t,i==null?void 0:i.id,e)}},we.setClient(this.connectionControllerClient)}async onConnectExternal(e){var l,h,u,d,f,p,g,m;const t=O.state.activeChain,i=e.chain||t,r=this.getAdapter(i);let n=!0;if(e.type===Qe.CONNECTOR_TYPE_AUTH&&J.AUTH_CONNECTOR_SUPPORTED_CHAINS.some(I=>he.getConnectorId(I)===J.CONNECTOR_ID.AUTH)&&e.chain!==t&&(n=!1),e.chain&&e.chain!==t&&!e.caipNetwork){const S=this.getCaipNetworks().find(k=>k.chainNamespace===e.chain);S&&n&&this.setCaipNetwork(S)}if(!i)throw new Error("connectExternal: namespace not found");if(!r)throw new Error("connectExternal: adapter not found");const o=this.getCaipNetwork(i),a=e.caipNetwork||o,c=await r.connect({id:e.id,address:e.address,info:e.info,type:e.type,provider:e.provider,socialUri:e.socialUri,chainId:((l=e.caipNetwork)==null?void 0:l.id)||(o==null?void 0:o.id),rpcUrl:((f=(d=(u=(h=e.caipNetwork)==null?void 0:h.rpcUrls)==null?void 0:u.default)==null?void 0:d.http)==null?void 0:f[0])||((m=(g=(p=o==null?void 0:o.rpcUrls)==null?void 0:p.default)==null?void 0:g.http)==null?void 0:m[0])});if(c)return ae.addConnectedNamespace(i),this.syncProvider({...c,chainNamespace:i}),this.setStatus("connected",i),this.syncConnectedWalletInfo(i),ae.removeDisconnectedConnectorId(e.id,i),{address:c.address,connectedCaipNetwork:a}}async connectInactiveNamespaces(e,t){var a;const i=e.type===Qe.CONNECTOR_TYPE_AUTH,r=Mr.getOtherAuthNamespaces((a=t==null?void 0:t.connectedCaipNetwork)==null?void 0:a.chainNamespace),n=O.state.activeCaipNetwork,o=this.getAdapter(n==null?void 0:n.chainNamespace);i&&(await Promise.all(r.map(async c=>{var l,h,u;try{const d=pe.getProvider(c),f=this.getCaipNetwork(c),p=this.getAdapter(c);await(p==null?void 0:p.connect({...e,provider:d,socialUri:void 0,chainId:f==null?void 0:f.id,rpcUrl:(u=(h=(l=f==null?void 0:f.rpcUrls)==null?void 0:l.default)==null?void 0:h.http)==null?void 0:u[0]}))&&(ae.addConnectedNamespace(c),ae.removeDisconnectedConnectorId(e.id,c),this.setStatus("connected",c),this.syncConnectedWalletInfo(c))}catch(d){qe.warn(je.ALERT_WARNINGS.INACTIVE_NAMESPACE_NOT_CONNECTED.displayMessage,je.ALERT_WARNINGS.INACTIVE_NAMESPACE_NOT_CONNECTED.debugMessage(c,d instanceof Error?d.message:void 0),je.ALERT_WARNINGS.INACTIVE_NAMESPACE_NOT_CONNECTED.code)}})),n&&await(o==null?void 0:o.switchNetwork({caipNetwork:n})))}getApprovedCaipNetworksData(){var t,i,r,n,o;if(pe.getProviderId(O.state.activeChain)===Qe.CONNECTOR_TYPE_WALLET_CONNECT){const a=(i=(t=this.universalProvider)==null?void 0:t.session)==null?void 0:i.namespaces;return{supportsAllNetworks:((o=(n=(r=this.universalProvider)==null?void 0:r.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){const t=e.chainNamespace;if(this.getAddressByChainNamespace(e.chainNamespace)){const r=pe.getProviderId(t);if(e.chainNamespace===O.state.activeChain){const n=this.getAdapter(t);await(n==null?void 0:n.switchNetwork({caipNetwork:e}))}else if(this.setCaipNetwork(e),r===Qe.CONNECTOR_TYPE_WALLET_CONNECT)this.syncWalletConnectAccount();else{const n=this.getAddressByChainNamespace(t);n&&this.syncAccount({address:n,chainId:e.id,chainNamespace:t})}}else this.setCaipNetwork(e)}getChainsFromNamespaces(e={}){return Object.values(e).flatMap(t=>{const i=t.chains||[],r=t.accounts.map(n=>{const{chainId:o,chainNamespace:a}=Ds.parseCaipAddress(n);return`${a}:${o}`});return Array.from(new Set([...i,...r]))})}createAdapters(e){return this.createClients(),this.chainNamespaces.reduce((t,i)=>{var n,o;const r=e==null?void 0:e.find(a=>a.namespace===i);return r?(r.construct({namespace:i,projectId:(n=this.options)==null?void 0:n.projectId,networks:(o=this.caipNetworks)==null?void 0:o.filter(({chainNamespace:a})=>a===i)}),t[i]=r):t[i]=new ES({namespace:i,networks:this.getCaipNetworks()}),t},{})}async initChainAdapter(e){this.onConnectors(e),this.listenAdapter(e);const t=this.getAdapter(e);if(!t)throw new Error("adapter not found");await t.syncConnectors(),await this.createUniversalProviderForAdapter(e)}async initChainAdapters(){await Promise.all(this.chainNamespaces.map(async e=>{await this.initChainAdapter(e)})),this.initAdapterController()}onConnectors(e){const t=this.getAdapter(e);t==null||t.on("connectors",this.setConnectors.bind(this))}listenAdapter(e){const t=this.getAdapter(e);if(!t)return;const i=ae.getConnectionStatus();z.state.enableReconnect===!1?this.setStatus("disconnected",e):i==="connected"?this.setStatus("connecting",e):i==="disconnected"?(ae.clearAddressCache(),this.setStatus(i,e)):this.setStatus(i,e),t.on("switchNetwork",({address:r,chainId:n})=>{var l,h;const o=this.getCaipNetworks().find(u=>u.id.toString()===n.toString()||u.caipNetworkId.toString()===n.toString()),a=O.state.activeChain===e,c=(h=(l=O.state.chains.get(e))==null?void 0:l.accountState)==null?void 0:h.address;if(o){const u=a&&r?r:c;u&&this.syncAccount({address:u,chainId:o.id,chainNamespace:e})}else this.setUnsupportedNetwork(n)}),t.on("disconnect",()=>{const r=this.remoteFeatures.multiWallet,n=Array.from(we.state.connections.values()).flat();this.onDisconnectNamespace({chainNamespace:e,closeModal:!r||n.length===0})}),t.on("connections",r=>{this.setConnections(r,e)}),t.on("pendingTransactions",()=>{const r=this.getAddress(e),n=O.state.activeCaipNetwork;!r||!(n!=null&&n.id)||this.updateNativeBalance(r,n.id,n.chainNamespace)}),t.on("accountChanged",({address:r,chainId:n,connector:o})=>{var h,u;this.handlePreviousConnectorConnection(o);const a=O.state.activeChain===e;o!=null&&o.provider&&(this.syncProvider({id:o.id,type:o.type,provider:o==null?void 0:o.provider,chainNamespace:e}),this.syncConnectedWalletInfo(e));const c=(u=(h=O.getNetworkData(e))==null?void 0:h.caipNetwork)==null?void 0:u.id,l=n||c;a&&l?this.syncAccount({address:r,chainId:l,chainNamespace:e}).catch(()=>null):!a&&l?(this.syncAccountInfo(r,l,e),this.syncBalance({address:r,chainId:l,chainNamespace:e}).catch(()=>null)):this.syncAccountInfo(r,n,e),ae.addConnectedNamespace(e)})}async handlePreviousConnectorConnection(e){var c;const t=e==null?void 0:e.chain,i=e==null?void 0:e.id,r=he.getConnectorId(t),n=(c=z.state.remoteFeatures)==null?void 0:c.multiWallet,a=t&&i&&r&&r!==i&&!n;try{a&&await we.disconnect({id:r,namespace:t})}catch(l){console.warn("Error disconnecting previous connector",l)}}async createUniversalProviderForAdapter(e){var t,i,r;await this.getUniversalProvider(),this.universalProvider&&await((r=(i=(t=this.chainAdapters)==null?void 0:t[e])==null?void 0:i.setUniversalProvider)==null?void 0:r.call(i,this.universalProvider))}async syncExistingConnection(){await Promise.allSettled(this.chainNamespaces.map(e=>this.syncNamespaceConnection(e)))}async unSyncExistingConnection(){try{await Promise.allSettled(this.chainNamespaces.map(e=>we.disconnect({namespace:e,initialDisconnect:!0})))}catch(e){console.error("Error disconnecting existing connections:",e)}}async reconnectWalletConnect(){await this.syncWalletConnectAccount();const e=this.getAddress();this.getCaipAddress()||ae.deleteRecentWallet();const t=ae.getRecentWallet();Mt.sendEvent({type:"track",event:"CONNECT_SUCCESS",address:e,properties:{method:Oe.isMobile()?"mobile":"qrcode",name:(t==null?void 0:t.name)||"Unknown",reconnect:!0,view:Ls.state.view,walletRank:t==null?void 0:t.order}})}async syncNamespaceConnection(e){try{e===J.CHAIN.EVM&&Oe.isSafeApp()&&he.setConnectorId(J.CONNECTOR_ID.SAFE,e);const t=he.getConnectorId(e);switch(this.setStatus("connecting",e),t){case J.CONNECTOR_ID.WALLET_CONNECT:await this.reconnectWalletConnect();break;case J.CONNECTOR_ID.AUTH:break;default:await this.syncAdapterConnection(e)}}catch(t){console.warn("AppKit couldn't sync existing connection",t),this.setStatus("disconnected",e)}}onDisconnectNamespace(e){const{chainNamespace:t,closeModal:i}=e||{};O.resetAccount(t),O.resetNetwork(t),ae.removeConnectedNamespace(t);const r=Array.from(O.state.chains.keys());(t?[t]:r).forEach(o=>ae.addDisconnectedConnectorId(he.getConnectorId(o)||"",o)),he.removeConnectorId(t),pe.resetChain(t),this.setUser(null,t),this.setStatus("disconnected",t),this.setConnectedWalletInfo(null,t),i!==!1&&us.close()}async syncAdapterConnections(){await Promise.allSettled(this.chainNamespaces.map(e=>{const t=this.getAdapter(e),i=this.getCaipAddress(e),r=this.getCaipNetwork(e);return t==null?void 0:t.syncConnections({connectToFirstConnector:!i,caipNetwork:r})}))}async syncAdapterConnection(e){var a,c,l,h,u;const t=this.getAdapter(e),i=this.getCaipNetwork(e),r=he.getConnectorId(e),o=he.getConnectors(e).find(d=>d.id===r);try{if(!t||!o)throw new Error(`Adapter or connector not found for namespace ${e}`);if(!(i!=null&&i.id))throw new Error("CaipNetwork not found");const d=await(t==null?void 0:t.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]}));d?(this.syncProvider({...d,chainNamespace:e}),await this.syncAccount({...d,chainNamespace:e}),this.setStatus("connected",e),Mt.sendEvent({type:"track",event:"CONNECT_SUCCESS",address:d.address,properties:{method:"browser",name:((h=o.info)==null?void 0:h.name)||o.name||"Unknown",reconnect:!0,view:Ls.state.view,walletRank:(u=o==null?void 0:o.explorerWallet)==null?void 0:u.order}})):this.setStatus("disconnected",e)}catch{this.onDisconnectNamespace({chainNamespace:e,closeModal:!1})}}async syncWalletConnectAccount(){var i,r;const e=Object.keys(((r=(i=this.universalProvider)==null?void 0:i.session)==null?void 0:r.namespaces)||{}),t=this.chainNamespaces.map(async n=>{var u,d,f,p,g;const o=this.getAdapter(n);if(!o)return;const a=((p=(f=(d=(u=this.universalProvider)==null?void 0:u.session)==null?void 0:d.namespaces)==null?void 0:f[n])==null?void 0:p.accounts)||[],c=(g=O.state.activeCaipNetwork)==null?void 0:g.id,l=a.find(m=>{const{chainId:S}=Ds.parseCaipAddress(m);return S===(c==null?void 0:c.toString())})||a[0];if(l){const m=Ds.validateCaipAddress(l),{chainId:S,address:k}=Ds.parseCaipAddress(m);if(pe.setProviderId(n,Qe.CONNECTOR_TYPE_WALLET_CONNECT),this.caipNetworks&&O.state.activeCaipNetwork&&o.namespace!==J.CHAIN.EVM){const I=o.getWalletConnectProvider({caipNetworks:this.getCaipNetworks(),provider:this.universalProvider,activeCaipNetwork:O.state.activeCaipNetwork});pe.setProvider(n,I)}else pe.setProvider(n,this.universalProvider);he.setConnectorId(J.CONNECTOR_ID.WALLET_CONNECT,n),ae.addConnectedNamespace(n),await this.syncAccount({address:k,chainId:S,chainNamespace:n})}else e.includes(n)&&this.setStatus("disconnected",n);const h=this.getApprovedCaipNetworksData();this.syncConnectedWalletInfo(n),O.setApprovedCaipNetworksData(n,{approvedCaipNetworkIds:h.approvedCaipNetworkIds,supportsAllNetworks:h.supportsAllNetworks})});await Promise.all(t)}syncProvider({type:e,provider:t,id:i,chainNamespace:r}){pe.setProviderId(r,e),pe.setProvider(r,t),he.setConnectorId(i,r)}async syncAccount(e){var u,d;const t=e.chainNamespace===O.state.activeChain,i=O.getCaipNetworkByNamespace(e.chainNamespace,e.chainId),{address:r,chainId:n,chainNamespace:o}=e,{chainId:a}=ae.getActiveNetworkProps(),c=(i==null?void 0:i.id)||a,l=((u=O.state.activeCaipNetwork)==null?void 0:u.name)===J.UNSUPPORTED_NETWORK_NAME,h=O.getNetworkProp("supportsAllNetworks",o);if(this.setStatus("connected",o),!(l&&!h)&&c){let f=this.getCaipNetworks().find(S=>S.id.toString()===c.toString()),p=this.getCaipNetworks().find(S=>S.chainNamespace===o);if(!h&&!f&&!p){const S=this.getApprovedCaipNetworkIds()||[],k=S.find(E=>{var N;return((N=Ds.parseCaipNetworkId(E))==null?void 0:N.chainId)===c.toString()}),I=S.find(E=>{var N;return((N=Ds.parseCaipNetworkId(E))==null?void 0:N.chainNamespace)===o});f=this.getCaipNetworks().find(E=>E.caipNetworkId===k),p=this.getCaipNetworks().find(E=>E.caipNetworkId===I||"deprecatedCaipNetworkId"in E&&E.deprecatedCaipNetworkId===I)}const g=f||p;(g==null?void 0:g.chainNamespace)===O.state.activeChain?z.state.enableNetworkSwitch&&!z.state.allowUnsupportedChain&&((d=O.state.activeCaipNetwork)==null?void 0:d.name)===J.UNSUPPORTED_NETWORK_NAME?O.showUnsupportedChainUI():this.setCaipNetwork(g):t||i&&this.setCaipNetworkOfNamespace(i,o),this.syncConnectedWalletInfo(o);const m=this.getAddress(o);Mr.isLowerCaseMatch(r,m)||this.syncAccountInfo(r,g==null?void 0:g.id,o),t?await this.syncBalance({address:r,chainId:g==null?void 0:g.id,chainNamespace:o}):await this.syncBalance({address:r,chainId:i==null?void 0:i.id,chainNamespace:o}),this.syncIdentity({address:r,chainId:n,chainNamespace:o}).catch(()=>null)}}async syncAccountInfo(e,t,i){const r=this.getCaipAddress(i),n=t||(r==null?void 0:r.split(":")[1]);if(!n)return;const o=`${i}:${n}:${e}`;this.setCaipAddress(o,i,!0),await this.syncIdentity({address:e,chainId:n,chainNamespace:i})}async syncReownName(e,t){try{const i=await this.getReownName(e);if(i[0]){const r=i[0];this.setProfileName(r.name,t)}else this.setProfileName(null,t)}catch{this.setProfileName(null,t)}}syncConnectedWalletInfo(e){var r;const t=he.getConnectorId(e),i=pe.getProviderId(e);if(i===Qe.CONNECTOR_TYPE_ANNOUNCED||i===Qe.CONNECTOR_TYPE_INJECTED){if(t){const o=this.getConnectors().find(a=>{var u,d;const c=a.id===t,l=((u=a.info)==null?void 0:u.rdns)===t,h=(d=a.connectors)==null?void 0:d.some(f=>{var p;return f.id===t||((p=f.info)==null?void 0:p.rdns)===t});return c||l||!!h});if(o){const{info:a,name:c,imageUrl:l}=o,h=l||this.getConnectorImage(o);this.setConnectedWalletInfo({name:c,icon:h,...a},e)}}}else if(i===Qe.CONNECTOR_TYPE_WALLET_CONNECT){const n=pe.getProvider(e);n!=null&&n.session&&this.setConnectedWalletInfo({...n.session.peer.metadata,name:n.session.peer.metadata.name,icon:(r=n.session.peer.metadata.icons)==null?void 0:r[0]},e)}else if(t&&(t===J.CONNECTOR_ID.COINBASE_SDK||t===J.CONNECTOR_ID.COINBASE||t===J.CONNECTOR_ID.BASE_ACCOUNT)){const n=this.getConnectors().find(h=>h.id===t),o=t===J.CONNECTOR_ID.BASE_ACCOUNT?"Base Account":"Coinbase Wallet",a=(n==null?void 0:n.name)||o,c=(n==null?void 0:n.imageUrl)||this.getConnectorImage(n),l=n==null?void 0:n.info;this.setConnectedWalletInfo({...l,name:a,icon:c},e)}}async syncBalance(e){!pf.getNetworksByNamespace(this.getCaipNetworks(),e.chainNamespace).find(i=>{var r;return i.id.toString()===((r=e.chainId)==null?void 0:r.toString())})||!e.chainId||await this.updateNativeBalance(e.address,e.chainId,e.chainNamespace)}async ready(){await this.readyPromise}async updateNativeBalance(e,t,i){const r=this.getAdapter(i),n=O.getCaipNetworkByNamespace(i,t);if(r){const o=await r.getBalance({address:e,chainId:t,caipNetwork:n,tokens:this.options.tokens});return this.setBalance(o.balance,o.symbol,i),o}}async initializeUniversalAdapter(){var r,n,o,a,c,l,h,u,d,f;const e=lS.createLogger((p,...g)=>{p&&this.handleAlertError(p),console.error(...g)}),t={projectId:(r=this.options)==null?void 0:r.projectId,metadata:{name:(n=this.options)!=null&&n.metadata?(o=this.options)==null?void 0:o.metadata.name:"",description:(a=this.options)!=null&&a.metadata?(c=this.options)==null?void 0:c.metadata.description:"",url:(l=this.options)!=null&&l.metadata?(h=this.options)==null?void 0:h.metadata.url:"",icons:(u=this.options)!=null&&u.metadata?(d=this.options)==null?void 0:d.metadata.icons:[""]},logger:e};z.setManualWCControl(!!((f=this.options)!=null&&f.manualWCControl)),this.universalProvider=this.options.universalProvider??await Ba.init(t);const i=this.universalProvider.disconnect.bind(this.universalProvider);this.universalProvider.disconnect=async()=>{try{return await i()}catch(p){if(p instanceof Error&&p.message.includes("Missing or invalid. Record was recently deleted"))return;throw p}},z.state.enableReconnect===!1&&this.universalProvider.session&&await this.universalProvider.disconnect(),this.listenWalletConnect()}listenWalletConnect(){this.universalProvider&&this.chainNamespaces.forEach(e=>{vn.listenWcProvider({universalProvider:this.universalProvider,namespace:e,onDisplayUri:t=>{we.setUri(t)},onConnect:t=>{const{address:i}=Oe.getAccount(t[0]);for(const r of this.chainNamespaces)ae.removeDisconnectedConnectorId(J.CONNECTOR_ID.WALLET_CONNECT,r);we.finalizeWcConnection(i)},onDisconnect:()=>{O.state.noAdapters&&this.resetAccount(e),we.resetWcConnection()},onChainChanged:t=>{const i=O.state.activeChain,r=i&&he.state.activeConnectorIds[i]===J.CONNECTOR_ID.WALLET_CONNECT;if(i===e&&(O.state.noAdapters||r)){const n=this.getCaipNetworks().find(a=>a.id.toString()===t.toString()||a.caipNetworkId.toString()===t.toString()),o=this.getCaipNetwork();if(!n){this.setUnsupportedNetwork(t);return}(o==null?void 0:o.id.toString())!==(n==null?void 0:n.id.toString())&&(o==null?void 0:o.chainNamespace)===(n==null?void 0:n.chainNamespace)&&this.setCaipNetwork(n)}},onAccountsChanged:t=>{const i=O.state.activeChain,r=i&&he.state.activeConnectorIds[i]===J.CONNECTOR_ID.WALLET_CONNECT;if(i===e&&(O.state.noAdapters||r)){const n=t==null?void 0:t[0];n&&this.syncAccount({address:n.address,chainId:n.chainId,chainNamespace:n.chainNamespace})}}})})}createUniversalProvider(){var e;return!this.universalProviderInitPromise&&Oe.isClient()&&((e=this.options)!=null&&e.projectId)&&(this.universalProviderInitPromise=this.initializeUniversalAdapter()),this.universalProviderInitPromise}async getUniversalProvider(){if(!this.universalProvider)try{await this.createUniversalProvider()}catch(e){Mt.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}getDisabledCaipNetworks(){const e=O.getAllApprovedCaipNetworkIds(),t=O.getAllRequestedCaipNetworks();return Oe.sortRequestedNetworks(e,t).filter(r=>O.isCaipNetworkDisabled(r))}handleAlertError(e){const t=Object.entries(je.UniversalProviderErrors).find(([,{message:a}])=>e.message.includes(a)),[i,r]=t??[],{message:n,alertErrorKey:o}=r??{};if(i&&n&&!this.reportedAlertErrors[i]){const a=je.ALERT_ERRORS[o];a&&(qe.open(a,"error"),this.reportedAlertErrors[i]=!0)}}getAdapter(e){var t;if(e)return(t=this.chainAdapters)==null?void 0:t[e]}createAdapter(e){var r,n;if(!e)return;const t=e.namespace;if(!t)return;this.createClients();const i=e;i.namespace=t,i.construct({namespace:t,projectId:(r=this.options)==null?void 0:r.projectId,networks:(n=this.caipNetworks)==null?void 0:n.filter(({chainNamespace:o})=>o===t)}),this.chainNamespaces.includes(t)||this.chainNamespaces.push(t),this.chainAdapters&&(this.chainAdapters[t]=i)}async open(e){await this.injectModalUi(),e!=null&&e.uri&&we.setUri(e.uri);const{isSwap:t,isSend:i}=this.toModalOptions();return t(e)?us.open({...e,data:{swap:e.arguments}}):i(e)&&e.arguments?this.openSend(e.arguments):us.open(e)}async close(){await this.injectModalUi(),us.close()}setLoading(e,t){us.setLoading(e,t)}async disconnect(e){await we.disconnect({namespace:e})}getSIWX(){return z.state.siwx}getError(){return""}getChainId(){var e;return(e=O.state.activeCaipNetwork)==null?void 0:e.id}async switchNetwork(e,{throwOnFailure:t=!1}={}){const i=this.getCaipNetworks().find(r=>r.id===e.id);if(!i){qe.open(je.ALERT_ERRORS.SWITCH_NETWORK_NOT_FOUND,"error");return}await O.switchActiveNetwork(i,{throwOnFailure:t})}getWalletProvider(){return O.state.activeChain?pe.state.providers[O.state.activeChain]:null}getWalletProviderType(){return pe.getProviderId(O.state.activeChain)}subscribeProviders(e){return pe.subscribeProviders(e)}getThemeMode(){return Ut.state.themeMode}getThemeVariables(){return Ut.state.themeVariables}setThemeMode(e){Ut.setThemeMode(e),Qo(Ut.state.themeMode)}setTermsConditionsUrl(e){z.setTermsConditionsUrl(e)}setPrivacyPolicyUrl(e){z.setPrivacyPolicyUrl(e)}setThemeVariables(e){Ut.setThemeVariables(e),vS(Ut.state.themeVariables)}subscribeTheme(e){return Ut.subscribe(e)}subscribeConnections(e){return this.remoteFeatures.multiWallet?we.subscribe(e):(qe.open(J.REMOTE_FEATURES_ALERTS.MULTI_WALLET_NOT_ENABLED.DEFAULT,"info"),()=>{})}getWalletInfo(e){var i,r;if(e)return(r=(i=O.state.chains.get(e))==null?void 0:i.accountState)==null?void 0:r.connectedWalletInfo;const t=O.getAccountData();return t==null?void 0:t.connectedWalletInfo}getAccount(e){const t=e||O.state.activeChain,i=he.getAuthConnector(t),r=O.getAccountData(t),n=ae.getConnectedConnectorId(O.state.activeChain),o=we.getConnections(t);if(!t)throw new Error("AppKit:getAccount - namespace is required");const a=O.getActiveCaipNetwork(t),c=o.flatMap(l=>{const h=l.caipNetwork??a;return h?l.accounts.map(({address:u,type:d,publicKey:f})=>Oe.createAccount({caipAddress:`${h.caipNetworkId}:${u}`,type:d||"eoa",publicKey:f})):[]});if(r)return{allAccounts:c,caipAddress:r.caipAddress,address:Oe.getPlainAddress(r.caipAddress),isConnected:!!r.caipAddress,status:r.status,embeddedWalletInfo:i&&n===J.CONNECTOR_ID.AUTH?{user:r.user?{...r.user,username:ae.getConnectedSocialUsername()}:void 0,authProvider:r.socialProvider||"email",accountType:co(t),isSmartAccountDeployed:!!r.smartAccountDeployed}:void 0}}subscribeAccount(e,t){const i=[],r=()=>{const o=this.getAccount(t);o&&e(o)};if(t){const o=O.subscribeChainProp("accountState",r,t);i.push(o)}else{const o=O.subscribe(r);i.push(o)}const n=he.subscribe(r);return i.push(n),()=>{i.forEach(o=>o())}}subscribeNetwork(e){return O.subscribe(({activeCaipNetwork:t,activeChain:i,chains:r})=>{var o;const n=i?(o=r.get(i))==null?void 0:o.networkState:void 0;e({caipNetwork:t,chainId:t==null?void 0:t.id,caipNetworkId:t==null?void 0:t.caipNetworkId,approvedCaipNetworkIds:n==null?void 0:n.approvedCaipNetworkIds,supportsAllNetworks:(n==null?void 0:n.supportsAllNetworks)??!0})})}subscribeWalletInfo(e,t){return t?O.subscribeChainProp("accountState",i=>e(i==null?void 0:i.connectedWalletInfo),t):O.subscribeChainProp("accountState",i=>e(i==null?void 0:i.connectedWalletInfo))}subscribeShouldUpdateToAddress(e){return O.subscribeChainProp("accountState",t=>e(t==null?void 0:t.shouldUpdateToAddress))}subscribeCaipNetworkChange(e){return O.subscribeKey("activeCaipNetwork",e)}getState(){return qr.state}getRemoteFeatures(){return z.state.remoteFeatures}subscribeState(e){return qr.subscribe(e)}subscribeRemoteFeatures(e){return z.subscribeKey("remoteFeatures",e)}showErrorMessage(e){qa.showError(e)}showSuccessMessage(e){qa.showSuccess(e)}getEvent(){return{...Mt.state}}subscribeEvents(e){return Mt.subscribe(e)}replace(e){Ls.replace(e)}redirect(e){Ls.push(e)}popTransactionStack(e){Ls.popTransactionStack(e)}isOpen(){return us.state.open}isTransactionStackEmpty(){return Ls.state.transactionStack.length===0}static getInstance(){return this.instance}updateFeatures(e){z.setFeatures(e)}updateRemoteFeatures(e){z.setRemoteFeatures(e)}updateOptions(e){const i={...z.state||{},...e};z.setOptions(i)}setConnectMethodsOrder(e){z.setConnectMethodsOrder(e)}setWalletFeaturesOrder(e){z.setWalletFeaturesOrder(e)}setCollapseWallets(e){z.setCollapseWallets(e)}setSocialsOrder(e){z.setSocialsOrder(e)}getConnectMethodsOrder(){return Gd.getConnectOrderMethod(z.state.features,he.getConnectors())}addNetwork(e,t){if(this.chainAdapters&&!this.chainAdapters[e])throw new Error(`Adapter for namespace ${e} doesn't exist`);const i=this.extendCaipNetwork(t,this.options);this.getCaipNetworks().find(r=>r.id===i.id)||O.addNetwork(i)}removeNetwork(e,t){if(this.chainAdapters&&!this.chainAdapters[e])throw new Error(`Adapter for namespace ${e} doesn't exist`);this.getCaipNetworks().find(r=>r.id===t)&&O.removeNetwork(e,t)}}let nh=!1;class Rd extends SS{async onAuthProviderConnected(e){const t=Mr.userChainIdToChainNamespace(e==null?void 0:e.chainId);if(e.message&&e.signature&&e.siwxMessage&&await Tr.addEmbeddedWalletSession({chainId:e.siwxMessage.chainId,accountAddress:e.address,notBefore:e.siwxMessage.notBefore,statement:e.siwxMessage.statement,resources:e.siwxMessage.resources,requestId:e.siwxMessage.requestId,issuedAt:e.siwxMessage.issuedAt,domain:e.siwxMessage.domain,uri:e.siwxMessage.uri,version:e.siwxMessage.version,nonce:e.siwxMessage.nonce},e.message,e.signature),!t)throw new Error("AppKit:onAuthProviderConnected - namespace is required");const i=t===J.CHAIN.EVM?`eip155:${e.chainId}:${e.address}`:`${e.chainId}:${e.address}`,r=z.state.defaultAccountTypes[t],n=co(t),o=e.preferredAccountType||n||r;this.setCaipAddress(i,t);const{signature:a,siwxMessage:c,message:l,...h}=e,u=O.getAccountData(t);this.setUser({...(u==null?void 0:u.user)||{},...h},t),this.setSmartAccountDeployed(!!e.smartAccountDeployed,t),this.setPreferredAccountType(o,t),await Promise.all([this.syncAuthConnectorTheme(this.authProvider),this.syncAccount({address:e.address,chainId:e.chainId,chainNamespace:t})]),this.setLoading(!1,t)}setupAuthConnectorListeners(e){e.onRpcRequest(t=>{En.checkIfRequestExists(t)?En.checkIfRequestIsSafe(t)||this.handleUnsafeRPCRequest():(this.open(),console.error(ja.RPC_METHOD_NOT_ALLOWED_MESSAGE,{method:t.method}),setTimeout(()=>{this.showErrorMessage(ja.RPC_METHOD_NOT_ALLOWED_UI_MESSAGE)},300),e.rejectRpcRequests())}),e.onRpcError(()=>{this.isOpen()&&(this.isTransactionStackEmpty()?this.close():this.popTransactionStack("error"))}),e.onRpcSuccess((t,i)=>{const r=En.checkIfRequestIsSafe(i),n=this.getAddress(),o=O.state.activeCaipNetwork;r||(n&&(o!=null&&o.id)&&this.updateNativeBalance(n,o.id,o.chainNamespace),this.isTransactionStackEmpty()?this.close():this.popTransactionStack("success"))}),e.onNotConnected(()=>{const t=O.state.activeChain;if(!t)throw new Error("AppKit:onNotConnected - namespace is required");he.getConnectorId(t)===J.CONNECTOR_ID.AUTH&&(this.setCaipAddress(null,t),this.setLoading(!1,t))}),e.onConnect(this.onAuthProviderConnected.bind(this)),e.onSocialConnected(this.onAuthProviderConnected.bind(this)),e.onSetPreferredAccount(({address:t,type:i})=>{const r=O.state.activeChain;if(!r)throw new Error("AppKit:onSetPreferredAccount - namespace is required");t&&this.setPreferredAccountType(i,r)})}async syncAuthConnectorTheme(e){if(!e)return;const t=Ut.getSnapshot();await e.syncTheme({themeMode:t.themeMode,themeVariables:t.themeVariables,w3mThemeVariables:Yd(t.themeVariables,t.themeMode)})}async syncAuthConnector(e,t){var h,u,d,f,p,g,m,S,k;const i=J.AUTH_CONNECTOR_SUPPORTED_CHAINS.includes(t),r=t===O.state.activeChain;if(!i)return;this.setLoading(!0,t);const n=e.getLoginEmailUsed();this.setLoading(n,t),n&&this.setStatus("connecting",t);const o=e.getEmail(),a=e.getUsername(),c=((h=O.getAccountData(t))==null?void 0:h.user)||{};this.setUser({...c,username:a,email:o},t),this.setupAuthConnectorListeners(e);const{isConnected:l}=await e.isConnected();if(t&&i&&r)if(l&&((u=this.connectionControllerClient)!=null&&u.connectExternal)){await e.init(),await this.syncAuthConnectorTheme(e),await((p=this.connectionControllerClient)==null?void 0:p.connectExternal({id:J.CONNECTOR_ID.AUTH,info:{name:J.CONNECTOR_ID.AUTH},type:Qe.CONNECTOR_TYPE_AUTH,provider:e,chainId:(f=(d=O.getNetworkData(t))==null?void 0:d.caipNetwork)==null?void 0:f.id,chain:t})),this.setStatus("connected",t);const I=ae.getConnectedSocialProvider();I?Mt.sendEvent({type:"track",event:"SOCIAL_LOGIN_SUCCESS",address:this.getAddress(),properties:{provider:I,reconnect:!0}}):Mt.sendEvent({type:"track",event:"CONNECT_SUCCESS",address:this.getAddress(),properties:{method:"email",name:((k=(S=(m=(g=this.universalProvider)==null?void 0:g.session)==null?void 0:m.peer)==null?void 0:S.metadata)==null?void 0:k.name)||"Unknown",reconnect:!0,view:Ls.state.view,walletRank:void 0}})}else he.getConnectorId(t)===J.CONNECTOR_ID.AUTH&&(this.setStatus("disconnected",t),ae.removeConnectedNamespace(t));this.setLoading(!1,t)}async checkExistingTelegramSocialConnection(e){var t;try{if(!Oe.isTelegram())return;const i=ae.getTelegramSocialProvider();if(!i||!Oe.isClient())return;const n=new URL(window.location.href).searchParams.get("result_uri");if(!n)return;i&&O.setAccountProp("socialProvider",i,e),await((t=this.authProvider)==null?void 0:t.init());const o=he.getAuthConnector();i&&o&&(this.setLoading(!0,e),await we.connectExternal({id:o.id,type:o.type,socialUri:n},o.chain),ae.setConnectedSocialProvider(i),ae.removeTelegramSocialProvider(),Mt.sendEvent({type:"track",event:"SOCIAL_LOGIN_SUCCESS",properties:{provider:i}}))}catch(i){this.setLoading(!1,e),console.error("checkExistingSTelegramocialConnection error",i)}try{const i=new URL(window.location.href);i.searchParams.delete("result_uri"),window.history.replaceState({},document.title,i.toString())}catch(i){console.error("tma social login failed",i)}}createAuthProvider(e){var l,h,u,d;if(!J.AUTH_CONNECTOR_SUPPORTED_CHAINS.includes(e))return;const i=(l=this.remoteFeatures)==null?void 0:l.email,r=Array.isArray((h=this.remoteFeatures)==null?void 0:h.socials)&&this.remoteFeatures.socials.length>0,n=i||r,a=Mr.getActiveNamespaceConnectedToAuth()||e;!this.authProvider&&((u=this.options)!=null&&u.projectId)&&n&&(this.authProvider=Zd.getInstance({projectId:this.options.projectId,enableLogger:this.options.enableAuthLogger,chainId:(d=this.getCaipNetwork(a))==null?void 0:d.caipNetworkId,abortController:je.EmbeddedWalletAbortController,onTimeout:f=>{f==="iframe_load_failed"?qe.open(je.ALERT_ERRORS.IFRAME_LOAD_FAILED,"error"):f==="iframe_request_timeout"?qe.open(je.ALERT_ERRORS.IFRAME_REQUEST_TIMEOUT,"error"):f==="unverified_domain"&&qe.open(je.ALERT_ERRORS.UNVERIFIED_DOMAIN,"error")},getActiveCaipNetwork:f=>Jd(f),getCaipNetworks:f=>O.getCaipNetworks(f)}),qr.subscribeOpen(f=>{var p;!f&&this.isTransactionStackEmpty()&&((p=this.authProvider)==null||p.rejectRpcRequests())}));const c=e===O.state.activeChain&&z.state.enableReconnect;z.state.enableReconnect===!1?this.syncAuthConnectorTheme(this.authProvider):this.authProvider&&c&&(this.syncAuthConnector(this.authProvider,e),this.checkExistingTelegramSocialConnection(e))}createAuthProviderForAdapter(e){var t,i,r;this.createAuthProvider(e),this.authProvider&&((r=(i=(t=this.chainAdapters)==null?void 0:t[e])==null?void 0:i.setAuthProvider)==null||r.call(i,this.authProvider))}initControllers(e){super.initControllers(e),this.options.excludeWalletIds&&_s.initializeExcludedWallets({ids:this.options.excludeWalletIds})}async switchCaipNetwork(e){var o,a,c;if(!e)return;const t=O.state.activeChain,i=e.chainNamespace,r=this.getAddressByChainNamespace(i);if(i===t&&((o=O.getAccountData(i))!=null&&o.caipAddress)){const l=this.getAdapter(i);await(l==null?void 0:l.switchNetwork({caipNetwork:e})),this.setCaipNetwork(e)}else{const h=pe.getProviderId(t)===Qe.CONNECTOR_TYPE_AUTH,u=pe.getProviderId(i),d=u===Qe.CONNECTOR_TYPE_AUTH,f=J.AUTH_CONNECTOR_SUPPORTED_CHAINS.includes(i);if(!i)throw new Error("AppKit:switchCaipNetwork - networkNamespace is required");if((h&&u===void 0||d)&&f)try{if(O.state.activeChain=e.chainNamespace,r){const p=this.getAdapter(i);await(p==null?void 0:p.switchNetwork({caipNetwork:e}))}else await((c=(a=this.connectionControllerClient)==null?void 0:a.connectExternal)==null?void 0:c.call(a,{id:J.CONNECTOR_ID.AUTH,provider:this.authProvider,chain:i,chainId:e.id,type:Qe.CONNECTOR_TYPE_AUTH,caipNetwork:e}));this.setCaipNetwork(e)}catch{const g=this.getAdapter(i);await(g==null?void 0:g.switchNetwork({caipNetwork:e}))}else if(u===Qe.CONNECTOR_TYPE_WALLET_CONNECT){if(!O.state.noAdapters){const p=this.getAdapter(i);await(p==null?void 0:p.switchNetwork({caipNetwork:e}))}this.setCaipNetwork(e),this.syncWalletConnectAccount()}else this.setCaipNetwork(e),r&&this.syncAccount({address:r,chainId:e.id,chainNamespace:i})}}async initialize(e){var t;await super.initialize(e),(t=this.chainNamespaces)==null||t.forEach(i=>{this.createAuthProviderForAdapter(i)}),await this.injectModalUi(),qr.set({initialized:!0})}async syncIdentity({address:e,chainId:t,chainNamespace:i}){var a;if(i!==J.CHAIN.EVM)return;const r=`${i}:${t}`,n=(a=this.caipNetworks)==null?void 0:a.find(c=>c.caipNetworkId===r);if(n!=null&&n.testnet){this.setProfileName(null,i),this.setProfileImage(null,i);return}const o=he.getConnectorId(i)===J.CONNECTOR_ID.AUTH;try{const{name:c,avatar:l}=await this.fetchIdentity({address:e});!c&&o?await this.syncReownName(e,i):(this.setProfileName(c,i),this.setProfileImage(l,i))}catch{t!==1&&this.setProfileImage(null,i)}}syncConnectedWalletInfo(e){const t=pe.getProviderId(e);if(t===Qe.CONNECTOR_TYPE_AUTH){const i=this.authProvider;if(i){const r=ae.getConnectedSocialProvider()??"email",n=i.getEmail()??i.getUsername();this.setConnectedWalletInfo({name:t,identifier:n,social:r},e)}}else super.syncConnectedWalletInfo(e)}async injectModalUi(){if(!Oe.isClient())return;const e={...Ee.DEFAULT_FEATURES,...this.options.features};if(!e.headless&&!nh)try{const t=this.remoteFeatures;if(await this.loadModalComponents(e,t),Oe.isClient()&&!document.querySelector("w3m-modal")){const r=document.createElement("w3m-modal");!z.state.disableAppend&&!z.state.enableEmbedded&&document.body.insertAdjacentElement("beforeend",r)}nh=!0}catch(t){console.error("Error injecting modal UI:",t)}}async loadModalComponents(e,t){if(!Oe.isClient())return;const i=[];(t.email||t.socials&&t.socials.length>0)&&i.push(Ze(()=>import("./embedded-wallet-QGoIGdCB.js"),__vite__mapDeps([10,11,12,13,2,3,4,5,1,6,7,8,9,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29]))),t.email&&i.push(Ze(()=>import("./email-BTEyDEk6.js"),__vite__mapDeps([30,13,11,12,2,3,4,5,31,24,17,1,6,7,8,9,23,15,16,22,32,20,26,27,28,29]))),t.socials&&i.push(Ze(()=>import("./socials-CMh8u0Ej.js"),__vite__mapDeps([33,11,12,13,2,3,4,5,34,15,16,1,6,7,8,9,35,23,19,22,17,36,14,37,38,26,27,28,29]))),t.swaps&&t.swaps.length>0&&i.push(Ze(()=>import("./swaps-B0Q00kKq.js"),__vite__mapDeps([39,11,12,13,2,3,4,5,22,17,23,40,1,6,7,8,9,41,38,42,14,43,20,15,16,26,27,28,29]))),e.send&&i.push(Ze(()=>import("./send-DXVwWcB5.js"),__vite__mapDeps([44,11,12,13,2,3,4,5,22,17,23,45,15,16,1,6,7,8,9,46,24,42,14,38,41,20,47,48,26,27,28,29]))),e.receive&&i.push(Ze(()=>import("./receive-CtJWuhGM.js"),__vite__mapDeps([49,11,12,13,2,3,4,5,14,36,37,1,6,7,8,9,26,27,28,29]))),t.onramp&&t.onramp.length>0&&i.push(Ze(()=>import("./onramp-DnhEoZl6.js"),__vite__mapDeps([50,11,12,13,2,3,4,5,51,17,34,15,16,1,6,7,8,9,14,52,53,24,22,23,20,26,27,28,29]))),t.payWithExchange&&i.push(Ze(()=>import("./pay-with-exchange-BZR4RMBZ.js"),__vite__mapDeps([54,11,12,13,2,3,4,5,14,21,51,17,38,22,46,15,16,24,1,6,7,8,9,55,23,20,47,45,26,27,28,29]))),t.activity&&i.push(Ze(()=>import("./transactions-Dqx74UWQ.js"),__vite__mapDeps([56,11,13,12,2,3,4,5,57,23,24,14,38,1,6,7,8,9,26,27,28,29]))),(e.pay||t.payments)&&i.push(Ze(()=>import("./index-DS8DYtub.js"),__vite__mapDeps([58,59,11,12,13,2,3,4,5,22,17,21,14,51,60,23,45,1,6,7,8,9,38,43,26,27,28,29]))),t.emailCapture&&i.push(Ze(()=>import("./data-capture-DdxbO7dd.js"),__vite__mapDeps([61,11,12,13,2,3,4,5,31,24,17,1,6,7,8,9,0,26,27,28,29]))),await Promise.all([...i,Ze(()=>import("./index-DJyoXp5I.js"),__vite__mapDeps([62,11,12,13,2,3,4,5,14,17,48,1,6,7,8,9,23,63,53,24,18,19,60,21,51,22,55,57,38,47,40,43,45,15,16,20,32,34,35,36,37,25,52,26,27,28,29])),Ze(()=>import("./w3m-modal-CGHylzdj.js"),__vite__mapDeps([64,11,12,13,2,3,4,5,1,6,7,8,9,59,22,17,21,14,51,60,23,45,38,43,18,19,40,63,53,24,41,26,27,28,29]))])}}const AS="1.8.21";function CS(s){return new Rd({...s,sdkVersion:Oe.generateSdkVersion(s.adapters??[],"html",AS)})}const pA=Object.freeze(Object.defineProperty({__proto__:null,AppKit:Rd,CoreHelperUtil:Oe,WcConstantsUtil:zi,createAppKit:CS},Symbol.toStringTag,{value:"Module"}));export{uo as O,oA as a,nA as b,lA as c,hA as d,fA as e,cA as f,aA as g,pA as h,uA as i,dA as r,bS as v};
208
+ `,zi={ERROR_CODE_UNRECOGNIZED_CHAIN_ID:4902,ERROR_CODE_DEFAULT:5e3,ERROR_INVALID_CHAIN_ID:32603};class ES extends Fd{async setUniversalProvider(e){if(!this.namespace)throw new Error("UniversalAdapter:setUniversalProvider - namespace is required");return this.addConnector(new zd({provider:e,caipNetworks:this.getCaipNetworks(),namespace:this.namespace})),Promise.resolve()}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(),this.emit("disconnect")}catch(e){console.warn("UniversalAdapter:disconnect - error",e)}return{connections:[]}}syncConnections(){return Promise.resolve()}async writeSolanaTransaction(){return Promise.resolve({hash:""})}async getAccounts({namespace:e}){var r,n,o;const t=this.provider,i=(((o=(n=(r=t==null?void 0:t.session)==null?void 0:r.namespaces)==null?void 0:n[e])==null?void 0:o.accounts)||[]).filter((a,c,l)=>l.indexOf(a)===c);return Promise.resolve({accounts:i.map(a=>Oe.createAccount({caipAddress:a,type:e==="bip122"?"payment":"eoa"}))})}async syncConnectors(){return Promise.resolve()}async getBalance(e){var o,a,c,l,h;if(!(e.caipNetwork&&Ee.BALANCE_SUPPORTED_CHAINS.includes((o=e.caipNetwork)==null?void 0:o.chainNamespace))||(a=e.caipNetwork)!=null&&a.testnet)return{balance:"0.00",symbol:((c=e.caipNetwork)==null?void 0:c.nativeCurrency.symbol)||""};const i=O.getAccountData();if(i!=null&&i.balanceLoading&&e.chainId===((l=O.state.activeCaipNetwork)==null?void 0:l.id))return{balance:(i==null?void 0:i.balance)||"0.00",symbol:(i==null?void 0:i.balanceSymbol)||""};const n=(await O.fetchTokenBalance()).find(u=>{var d,f;return u.chainId===`${(d=e.caipNetwork)==null?void 0:d.chainNamespace}:${e.chainId}`&&u.symbol===((f=e.caipNetwork)==null?void 0:f.nativeCurrency.symbol)});return{balance:(n==null?void 0:n.quantity.numeric)||"0.00",symbol:(n==null?void 0:n.symbol)||((h=e.caipNetwork)==null?void 0:h.nativeCurrency.symbol)||""}}async signMessage(e){var o,a,c;const{provider:t,message:i,address:r}=e;if(!t)throw new Error("UniversalAdapter:signMessage - provider is undefined");let n="";return((o=O.state.activeCaipNetwork)==null?void 0:o.chainNamespace)===J.CHAIN.SOLANA?n=(await t.request({method:"solana_signMessage",params:{message:of.encode(new TextEncoder().encode(i)),pubkey:r}},(a=O.state.activeCaipNetwork)==null?void 0:a.caipNetworkId)).signature:n=await t.request({method:"personal_sign",params:[i,r]},(c=O.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:""})}emitFirstAvailableConnection(){}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 r,n,o,a,c,l,h;const{caipNetwork:t}=e,i=this.getWalletConnectConnector();if(t.chainNamespace===J.CHAIN.EVM)try{await((r=i.provider)==null?void 0:r.request({method:"wallet_switchEthereumChain",params:[{chainId:Ka(t.id)}]}))}catch(u){if(u.code===zi.ERROR_CODE_UNRECOGNIZED_CHAIN_ID||u.code===zi.ERROR_INVALID_CHAIN_ID||u.code===zi.ERROR_CODE_DEFAULT||((o=(n=u==null?void 0:u.data)==null?void 0:n.originalError)==null?void 0:o.code)===zi.ERROR_CODE_UNRECOGNIZED_CHAIN_ID)try{await((l=i.provider)==null?void 0:l.request({method:"wallet_addEthereumChain",params:[{chainId:Ka(t.id),rpcUrls:[(a=t==null?void 0:t.rpcUrls.chainDefault)==null?void 0:a.http],chainName:t.name,nativeCurrency:t.nativeCurrency,blockExplorerUrls:[(c=t.blockExplorers)==null?void 0:c.default.url]}]}))}catch{throw new Error("Chain is not supported")}}(h=i.provider)==null||h.setDefaultChain(t.caipNetworkId)}getWalletConnectProvider(){const e=this.connectors.find(i=>i.type==="WALLET_CONNECT");return e==null?void 0:e.provider}}const xS=["email","socials","swaps","onramp","activity","reownBranding","multiWallet","emailCapture","payWithExchange","payments","reownAuthentication","headless"],Nr={email:{apiFeatureName:"social_login",localFeatureName:"email",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:s=>{if(!(s!=null&&s.config))return!1;const e=s.config;return!!s.isEnabled&&e.includes("email")},processFallback:s=>s===void 0?Ee.DEFAULT_REMOTE_FEATURES.email:!!s},socials:{apiFeatureName:"social_login",localFeatureName:"socials",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:s=>{if(!(s!=null&&s.config))return!1;const e=s.config;return s.isEnabled&&e.length>0?e.filter(t=>t!=="email"):!1},processFallback:s=>s===void 0?Ee.DEFAULT_REMOTE_FEATURES.socials:typeof s=="boolean"?s?Ee.DEFAULT_REMOTE_FEATURES.socials:!1:s},swaps:{apiFeatureName:"swap",localFeatureName:"swaps",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:s=>{if(!(s!=null&&s.config))return!1;const e=s.config;return s.isEnabled&&e.length>0?e:!1},processFallback:s=>s===void 0?Ee.DEFAULT_REMOTE_FEATURES.swaps:typeof s=="boolean"?s?Ee.DEFAULT_REMOTE_FEATURES.swaps:!1:s},onramp:{apiFeatureName:"onramp",localFeatureName:"onramp",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:s=>{if(!(s!=null&&s.config))return!1;const e=s.config;return s.isEnabled&&e.length>0?e:!1},processFallback:s=>s===void 0?Ee.DEFAULT_REMOTE_FEATURES.onramp:typeof s=="boolean"?s?Ee.DEFAULT_REMOTE_FEATURES.onramp:!1:s},activity:{apiFeatureName:"activity",localFeatureName:"history",returnType:!1,isLegacy:!0,isAvailableOnBasic:!1,processApi:s=>!!s.isEnabled,processFallback:s=>s===void 0?Ee.DEFAULT_REMOTE_FEATURES.activity:!!s},reownBranding:{apiFeatureName:"reown_branding",localFeatureName:"reownBranding",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:s=>!!s.isEnabled,processFallback:s=>s===void 0?Ee.DEFAULT_REMOTE_FEATURES.reownBranding:!!s},emailCapture:{apiFeatureName:"email_capture",localFeatureName:"emailCapture",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:s=>s.isEnabled&&(s.config??[]),processFallback:s=>!1},multiWallet:{apiFeatureName:"multi_wallet",localFeatureName:"multiWallet",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:s=>!!s.isEnabled,processFallback:()=>Ee.DEFAULT_REMOTE_FEATURES.multiWallet},payWithExchange:{apiFeatureName:"fund_from_exchange",localFeatureName:"payWithExchange",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:s=>!!s.isEnabled,processFallback:()=>Ee.DEFAULT_REMOTE_FEATURES.payWithExchange},payments:{apiFeatureName:"payments",localFeatureName:"payments",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:s=>!!s.isEnabled,processFallback:()=>Ee.DEFAULT_REMOTE_FEATURES.payments},reownAuthentication:{apiFeatureName:"reown_authentication",localFeatureName:"reownAuthentication",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:s=>!!s.isEnabled,processFallback:s=>typeof s>"u"?Ee.DEFAULT_REMOTE_FEATURES.reownAuthentication:!!s},headless:{apiFeatureName:"headless",localFeatureName:"headless",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:s=>!!s.isEnabled,processFallback:()=>Ee.DEFAULT_REMOTE_FEATURES.headless}},IS={localSettingsOverridden:new Set,getApiConfig(s,e){return e==null?void 0:e.find(t=>t.id===s)},addWarning(s,e){if(s!==void 0){const t=Nr[e],i=t.isLegacy?`"features.${t.localFeatureName}" (now "${e}")`:`"features.${e}"`;this.localSettingsOverridden.add(i)}},processFeature(s,e,t,i,r){const n=Nr[s],o=e[n.localFeatureName];if(r&&!n.isAvailableOnBasic)return!1;if(i){const a=this.getApiConfig(n.apiFeatureName,t);return(a==null?void 0:a.config)===null?this.processFallbackFeature(s,o):a!=null&&a.config?(o!==void 0&&this.addWarning(o,s),this.processApiFeature(s,a)):!1}return this.processFallbackFeature(s,o)},processApiFeature(s,e){return Nr[s].processApi(e)},processFallbackFeature(s,e){return Nr[s].processFallback(e)},async fetchRemoteFeatures(s){const e=s.basic??!1,t=s.features||{};this.localSettingsOverridden.clear();let i=null,r=!1;try{i=await _s.fetchProjectConfig(),r=i!=null}catch(o){console.warn("[Reown Config] Failed to fetch remote project configuration. Using local/default values.",o)}const n=r&&!e?Ee.DEFAULT_REMOTE_FEATURES:Ee.DEFAULT_REMOTE_FEATURES_DISABLED;try{for(const o of xS){const a=this.processFeature(o,t,i,r,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(r&&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.`;qe.open({debugMessage:je.ALERT_WARNINGS.LOCAL_CONFIGURATION_IGNORED.debugMessage(o)},"warning")}return n}};class SS{constructor(e){this.chainNamespaces=[],this.features={},this.remoteFeatures={},this.reportedAlertErrors={},this.getCaipNetwork=(t,i)=>{var r,n,o;if(t){const a=(r=O.getCaipNetworks(t))==null?void 0:r.find(h=>h.id===i);if(a)return a;const c=(n=O.getNetworkData(t))==null?void 0:n.caipNetwork;return c||((o=O.getRequestedCaipNetworks(t).filter(h=>h.chainNamespace===t))==null?void 0:o[0])}return O.state.activeCaipNetwork||this.defaultCaipNetwork},this.getCaipNetworkId=()=>{const t=this.getCaipNetwork();if(t)return t.id},this.getCaipNetworks=t=>O.getCaipNetworks(t),this.getActiveChainNamespace=()=>O.state.activeChain,this.setRequestedCaipNetworks=(t,i)=>{O.setRequestedCaipNetworks(t,i)},this.getApprovedCaipNetworkIds=()=>O.getAllApprovedCaipNetworkIds(),this.getCaipAddress=t=>{var i,r;return O.state.activeChain===t||!t?O.state.activeCaipAddress:(r=(i=O.state.chains.get(t))==null?void 0:i.accountState)==null?void 0:r.caipAddress},this.setClientId=t=>{Lr.setClientId(t)},this.getProvider=t=>pe.getProvider(t),this.getProviderType=t=>pe.getProviderId(t),this.getPreferredAccountType=t=>co(t),this.setCaipAddress=(t,i,r=!1)=>{if(t!==null){const n=t.split(":");if(n.length!==3||n.some(o=>!o)){console.warn(`[AppKit] setCaipAddress: invalid CAIP-10 address rejected: "${t}"`);return}}O.setAccountProp("caipAddress",t,i,r),O.setAccountProp("address",Oe.getPlainAddress(t),i,r)},this.setBalance=(t,i,r)=>{O.setAccountProp("balance",t,r),O.setAccountProp("balanceSymbol",i,r)},this.setProfileName=(t,i)=>{O.setAccountProp("profileName",t,i)},this.setProfileImage=(t,i)=>{O.setAccountProp("profileImage",t,i)},this.setUser=(t,i)=>{O.setAccountProp("user",t,i)},this.resetAccount=t=>{O.resetAccount(t)},this.setCaipNetwork=t=>{O.setActiveCaipNetwork(t)},this.setCaipNetworkOfNamespace=(t,i)=>{O.setChainNetworkData(i,{caipNetwork:t})},this.setStatus=(t,i)=>{O.setAccountProp("status",t,i),he.isConnected()?ae.setConnectionStatus("connected"):ae.setConnectionStatus("disconnected")},this.getAddressByChainNamespace=t=>{var i;return(i=O.getAccountData(t))==null?void 0:i.address},this.setConnectors=t=>{const i=[...he.state.allConnectors,...t];he.setConnectors(i)},this.setConnections=(t,i)=>{ae.setConnections(t,i),we.setConnections(t,i)},this.fetchIdentity=t=>Lr.fetchIdentity(t),this.getReownName=t=>Kd.getNamesForAddress(t),this.getConnectors=()=>he.getConnectors(),this.getConnectorImage=t=>Hd.getConnectorImage(t),this.getConnections=t=>this.remoteFeatures.multiWallet?La.getConnectionsData(t).connections:(qe.open(J.REMOTE_FEATURES_ALERTS.MULTI_WALLET_NOT_ENABLED.DEFAULT,"info"),[]),this.getRecentConnections=t=>this.remoteFeatures.multiWallet?La.getConnectionsData(t).recentConnections:(qe.open(J.REMOTE_FEATURES_ALERTS.MULTI_WALLET_NOT_ENABLED.DEFAULT,"info"),[]),this.switchConnection=async t=>{if(!this.remoteFeatures.multiWallet){qe.open(J.REMOTE_FEATURES_ALERTS.MULTI_WALLET_NOT_ENABLED.DEFAULT,"info");return}await we.switchConnection(t)},this.deleteConnection=t=>{if(!this.remoteFeatures.multiWallet){qe.open(J.REMOTE_FEATURES_ALERTS.MULTI_WALLET_NOT_ENABLED.DEFAULT,"info");return}ae.deleteAddressFromConnection(t),we.syncStorageConnections()},this.setConnectedWalletInfo=(t,i)=>{const r=pe.getProviderId(i),n=t?{...t,type:r}:void 0;O.setAccountProp("connectedWalletInfo",n,i)},this.getIsConnectedState=()=>!!O.state.activeCaipAddress,this.addAddressLabel=(t,i,r)=>{var o;const n=((o=O.getAccountData(r))==null?void 0:o.addressLabels)||{};O.setAccountProp("addressLabels",{...n,[t]:i},r)},this.removeAddressLabel=(t,i)=>{var n;const r=((n=O.getAccountData(i))==null?void 0:n.addressLabels)||{};O.setAccountProp("addressLabels",{...r,[t]:void 0},i)},this.getAddress=t=>{var r;const i=t||O.state.activeChain;return(r=O.getAccountData(i))==null?void 0:r.address},this.resetNetwork=t=>{O.resetNetwork(t)},this.addConnector=t=>{he.addConnector(t)},this.resetWcConnection=()=>{we.resetWcConnection()},this.setAddressExplorerUrl=(t,i)=>{O.setAccountProp("addressExplorerUrl",t,i)},this.setSmartAccountDeployed=(t,i)=>{O.setAccountProp("smartAccountDeployed",t,i)},this.setPreferredAccountType=(t,i)=>{O.setAccountProp("preferredAccountType",t,i)},this.setEIP6963Enabled=t=>{z.setEIP6963Enabled(t)},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,t){const i=e==null?void 0:e.map(n=>n.namespace).filter(n=>!!n);if(i!=null&&i.length)return[...new Set(i)];const r=t==null?void 0:t.map(n=>n.chainNamespace);return[...new Set(r)]}async initialize(e){var t,i,r,n,o,a;if(this.initializeProjectSettings(e),this.initControllers(e),await this.initChainAdapters(),this.sendInitializeEvent(e),(t=e.features)!=null&&t.headless&&!Vd.hasInjectedConnectors()&&_s.prefetch({fetchNetworkImages:!1,fetchConnectorImages:!1,fetchWalletRanks:!1,fetchRecommendedWallets:!0}),z.state.enableReconnect?(await this.syncExistingConnection(),await this.syncAdapterConnections()):await this.unSyncExistingConnection(),!e.basic&&!e.manualWCControl&&(this.remoteFeatures=await IS.fetchRemoteFeatures(e)),await _s.fetchUsage(),z.setRemoteFeatures(this.remoteFeatures),this.remoteFeatures.onramp&&uo.setOnrampProviders(this.remoteFeatures.onramp),((i=z.state.remoteFeatures)!=null&&i.email||Array.isArray((r=z.state.remoteFeatures)==null?void 0:r.socials)&&((n=z.state.remoteFeatures)==null?void 0:n.socials.length)>0)&&await this.checkAllowedOrigins(),(o=z.state.features)!=null&&o.reownAuthentication||(a=z.state.remoteFeatures)!=null&&a.reownAuthentication){const{ReownAuthentication:c}=await Ze(async()=>{const{ReownAuthentication:h}=await import("./features-Ck7HAsYI.js");return{ReownAuthentication:h}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9])),l=z.state.siwx;l instanceof c||(l&&console.warn("ReownAuthentication option is enabled, SIWX configuration will be overridden."),z.setSIWX(new c))}}async openSend(e){var n;const t=e.namespace||O.state.activeChain,i=this.getCaipAddress(t),r=(n=this.getCaipNetwork(t))==null?void 0:n.id;if(!i)throw new Error("openSend: caipAddress not found");if((r==null?void 0:r.toString())!==e.chainId.toString()){const o=O.getCaipNetworkById(e.chainId,t);if(!o)throw new Error(`openSend: caipNetwork with chainId ${e.chainId} not found`);await this.switchNetwork(o,{throwOnFailure:!0})}try{const o=kd.getTokenSymbolByAddress(e.assetAddress);o&&await _s.fetchTokenImages([o])}catch{}return await us.open({view:"WalletSend",data:{send:e}}),new Promise((o,a)=>{const c=Ma.subscribeKey("hash",u=>{u&&(h(),o({hash:u}))}),l=us.subscribe(u=>{u.open||(h(),a(new Error("Modal closed")))}),h=this.createCleanupHandler([c,l])})}toModalOptions(){function e(i){return(i==null?void 0:i.view)==="Swap"}function t(i){return(i==null?void 0:i.view)==="WalletSend"}return{isSwap:e,isSend:t}}async checkAllowedOrigins(){try{const e=await _s.fetchAllowedOrigins();if(!Oe.isClient())return;const t=window.location.origin;vn.isOriginAllowed(t,e,J.DEFAULT_ALLOWED_ANCESTORS)||qe.open(je.ALERT_ERRORS.ORIGIN_NOT_ALLOWED,"error")}catch(e){if(!(e instanceof Error))return;switch(e.message){case"RATE_LIMITED":qe.open(je.ALERT_ERRORS.RATE_LIMITED_APP_CONFIGURATION,"error");break;case"SERVER_ERROR":{const t=e.cause instanceof Error?e.cause:e;qe.open({displayMessage:je.ALERT_ERRORS.SERVER_ERROR_APP_CONFIGURATION.displayMessage,debugMessage:je.ALERT_ERRORS.SERVER_ERROR_APP_CONFIGURATION.debugMessage(t.message)},"error");break}}}}createCleanupHandler(e){return()=>{e.forEach(t=>{try{t()}catch{}})}}sendInitializeEvent(e){var i;const{...t}=e;delete t.adapters,delete t.universalProvider,Mt.sendEvent({type:"track",event:"INITIALIZE",properties:{...t,networks:e.networks.map(r=>r.id),siweConfig:{options:((i=e.siweConfig)==null?void 0:i.options)||{}}}})}initControllers(e){this.initializeOptionsController(e),this.initializeChainController(e),this.initializeThemeController(e),this.initializeConnectionController(e),this.initializeConnectorController()}initAdapterController(){Wd.initialize(this.chainAdapters)}initializeThemeController(e){e.themeMode&&Ut.setThemeMode(e.themeMode),e.themeVariables&&Ut.setThemeVariables(e.themeVariables)}initializeChainController(e){if(!this.connectionControllerClient)throw new Error("ConnectionControllerClient must be set");O.initialize(e.adapters??[],this.caipNetworks,{connectionControllerClient:this.connectionControllerClient});const t=this.getDefaultNetwork();t&&O.setActiveCaipNetwork(t)}initializeConnectionController(e){we.initialize(e.adapters??[]),we.setWcBasic(e.basic??!1)}initializeConnectorController(){he.initialize(this.chainNamespaces)}initializeProjectSettings(e){z.setProjectId(e.projectId),z.setSdkVersion(e.sdkVersion)}initializeOptionsController(e){var r;z.setDebug(e.debug!==!1),z.setEnableWalletGuide(e.enableWalletGuide!==!1),z.setEnableWallets(e.enableWallets!==!1),z.setEIP6963Enabled(e.enableEIP6963!==!1),z.setEnableInjected(e.enableInjected!==!1),z.setEnableCoinbase(e.enableCoinbase!==!1),z.setEnableNetworkSwitch(e.enableNetworkSwitch!==!1),z.setEnableReconnect(e.enableReconnect!==!1),z.setEnableMobileFullScreen(e.enableMobileFullScreen===!0),z.setCoinbasePreference(e.coinbasePreference),z.setEnableAuthLogger(e.enableAuthLogger!==!1),z.setCustomRpcUrls(e.customRpcUrls),z.setEnableEmbedded(e.enableEmbedded),z.setAllWallets(e.allWallets),z.setIncludeWalletIds(e.includeWalletIds),z.setExcludeWalletIds(e.excludeWalletIds),z.setFeaturedWalletIds(e.featuredWalletIds),z.setTokens(e.tokens),z.setTermsConditionsUrl(e.termsConditionsUrl),z.setPrivacyPolicyUrl(e.privacyPolicyUrl),z.setCustomWallets(e.customWallets),z.setFeatures(e.features),z.setAllowUnsupportedChain(e.allowUnsupportedChain),z.setUniversalProviderConfigOverride(e.universalProviderConfigOverride),z.setPreferUniversalLinks(e.experimental_preferUniversalLinks),z.setDefaultAccountTypes(e.defaultAccountTypes);const t=this.getDefaultMetaData();if(!e.metadata&&t&&(e.metadata=t),z.setMetadata(e.metadata),z.setDisableAppend(e.disableAppend),z.setEnableEmbedded(e.enableEmbedded),z.setSIWX(e.siwx),this.features=z.state.features??{},!e.projectId){qe.open(je.ALERT_ERRORS.PROJECT_ID_NOT_CONFIGURED,"error");return}if(((r=e.adapters)==null?void 0:r.find(n=>n.namespace===J.CHAIN.EVM))&&e.siweConfig){if(e.siwx)throw new Error("Cannot set both `siweConfig` and `siwx` options");z.setSIWX(e.siweConfig.mapToSIWX())}}getDefaultMetaData(){var e,t,i,r;return Oe.isClient()?{name:((t=(e=document.getElementsByTagName("title"))==null?void 0:e[0])==null?void 0:t.textContent)||"",description:((i=document.querySelector('meta[property="og:description"]'))==null?void 0:i.content)||"",url:window.location.origin,icons:[((r=document.querySelector('link[rel~="icon"]'))==null?void 0:r.href)||""]}:null}setUnsupportedNetwork(e){const t=this.getActiveChainNamespace();if(t){const i=Pi.getUnsupportedNetwork(`${t}:${e}`);O.setActiveCaipNetwork(i)}}getDefaultNetwork(){return Pi.getCaipNetworkFromStorage(this.defaultCaipNetwork)}extendCaipNetwork(e,t){return Pi.extendCaipNetwork(e,{customNetworkImageUrls:t.chainImages,projectId:t.projectId})}extendCaipNetworks(e){return Pi.extendCaipNetworks(e.networks,{customNetworkImageUrls:e.chainImages,customRpcUrls:e.customRpcUrls,projectId:e.projectId})}extendDefaultCaipNetwork(e){const t=e.networks.find(r=>{var n;return r.id===((n=e.defaultNetwork)==null?void 0:n.id)});return t?Pi.extendCaipNetwork(t,{customNetworkImageUrls:e.chainImages,customRpcUrls:e.customRpcUrls,projectId:e.projectId}):void 0}async disconnectConnector(e,t){var i,r;try{this.setLoading(!0,e);let n={connections:[]};const o=this.getAdapter(e);return(((r=(i=O.state.chains.get(e))==null?void 0:i.accountState)==null?void 0:r.caipAddress)||!z.state.enableReconnect)&&(o!=null&&o.disconnect)&&(n=await o.disconnect({id:t})),this.setLoading(!1,e),n}catch(n){throw this.setLoading(!1,e),new Error(`Failed to disconnect chains: ${n.message}`)}}createClients(){this.connectionControllerClient={connectWalletConnect:async()=>{var l;const e=O.state.activeChain,t=this.getAdapter(e),i=(l=this.getCaipNetwork(e))==null?void 0:l.id,r=we.getConnections(e),n=this.remoteFeatures.multiWallet,o=r.length>0;if(!t)throw new Error("Adapter not found");const a=await t.connectWalletConnect(i);(!o||!n)&&this.close(),this.setClientId((a==null?void 0:a.clientId)||null),ae.setConnectedNamespaces([...O.state.chains.keys()]),await this.syncWalletConnectAccount(),await Tr.initializeIfEnabled()},connectExternal:async e=>{const t=await this.onConnectExternal(e);return await this.connectInactiveNamespaces(e,t),t?{address:t.address}:void 0},reconnectExternal:async({id:e,info:t,type:i,provider:r})=>{var a;const n=O.state.activeChain,o=this.getAdapter(n);if(!n)throw new Error("reconnectExternal: namespace not found");if(!o)throw new Error("reconnectExternal: adapter not found");o!=null&&o.reconnect&&(await(o==null?void 0:o.reconnect({id:e,info:t,type:i,provider:r,chainId:(a=this.getCaipNetwork())==null?void 0:a.id})),ae.addConnectedNamespace(n),this.syncConnectedWalletInfo(n))},disconnectConnector:async e=>{await this.disconnectConnector(e.namespace,e.id)},disconnect:async e=>{var l;const{id:t,chainNamespace:i,initialDisconnect:r}=e||{},n=i||O.state.activeChain,o=he.getConnectorId(n),a=t===J.CONNECTOR_ID.AUTH||o===J.CONNECTOR_ID.AUTH,c=t===J.CONNECTOR_ID.WALLET_CONNECT||o===J.CONNECTOR_ID.WALLET_CONNECT;try{const h=Array.from(O.state.chains.keys());let u=i?[i]:h;(c||a)&&(u=h);const d=u.map(async g=>{const m=he.getConnectorId(g),S=t||m,k=await this.disconnectConnector(g,S);k&&(a&&ae.deleteConnectedSocialProvider(),k.connections.forEach(I=>{ae.addDisconnectedConnectorId(I.connectorId,g)})),r&&this.onDisconnectNamespace({chainNamespace:g,closeModal:!1})}),f=await Promise.allSettled(d);Ma.resetSend(),we.resetWcConnection(),(l=Tr.getSIWX())!=null&&l.signOutOnDisconnect&&await Tr.clearSessions(),he.setFilterByNamespace(void 0),we.syncStorageConnections();const p=f.filter(g=>g.status==="rejected");if(p.length>0)throw new Error(p.map(g=>g.reason.message).join(", "));Mt.sendEvent({type:"track",event:"DISCONNECT_SUCCESS",properties:{namespace:i||"all"}})}catch(h){throw new Error(`Failed to disconnect chains: ${h.message}`)}},checkInstalled:e=>e?e.some(t=>{var i;return!!((i=window.ethereum)!=null&&i[String(t)])}):!!window.ethereum,signMessage:async e=>{const t=O.state.activeChain,i=this.getAdapter(O.state.activeChain);if(!t)throw new Error("signMessage: namespace not found");if(!i)throw new Error("signMessage: adapter not found");const r=this.getAddress(t);if(!r)throw new Error("signMessage: address not found");const n=await(i==null?void 0:i.signMessage({message:e,address:r,provider:pe.getProvider(t)}));return(n==null?void 0:n.signature)||""},sendTransaction:async e=>{const t=e.chainNamespace;if(!t)throw new Error("sendTransaction: namespace not found");if(Ee.SEND_SUPPORTED_NAMESPACES.includes(t)){const i=this.getAdapter(t);if(!i)throw new Error("sendTransaction: adapter not found");const r=pe.getProvider(t),n=await(i==null?void 0:i.sendTransaction({...e,caipNetwork:this.getCaipNetwork(),provider:r}));return(n==null?void 0:n.hash)||""}return""},estimateGas:async e=>{const t=e.chainNamespace;if(t===J.CHAIN.EVM){const i=this.getAdapter(t);if(!i)throw new Error("estimateGas: adapter is required but got undefined");const r=pe.getProvider(t),n=this.getCaipNetwork();if(!n)throw new Error("estimateGas: caipNetwork is required but got undefined");const o=await(i==null?void 0:i.estimateGas({...e,provider:r,caipNetwork:n}));return(o==null?void 0:o.gas)||0n}return 0n},getEnsAvatar:async()=>{var r;const e=O.state.activeChain;if(!e)throw new Error("getEnsAvatar: namespace is required but got undefined");const t=this.getAddress(e);if(!t)throw new Error("getEnsAvatar: address not found");await this.syncIdentity({address:t,chainId:Number((r=this.getCaipNetwork())==null?void 0:r.id),chainNamespace:e});const i=O.getAccountData();return(i==null?void 0:i.profileImage)||!1},getEnsAddress:async e=>await vn.resolveReownName(e),writeContract:async e=>{const t=O.state.activeChain,i=this.getAdapter(t);if(!t)throw new Error("writeContract: namespace is required but got undefined");if(!i)throw new Error("writeContract: adapter is required but got undefined");const r=this.getCaipNetwork(),n=this.getCaipAddress(),o=pe.getProvider(t);if(!r||!n)throw new Error("writeContract: caipNetwork or caipAddress is required but got undefined");const a=await(i==null?void 0:i.writeContract({...e,caipNetwork:r,provider:o,caipAddress:n}));return a==null?void 0:a.hash},writeSolanaTransaction:async e=>{const t=O.state.activeChain,i=this.getAdapter(t);if(!t)throw new Error("writeContract: namespace is required but got undefined");if(!i)throw new Error("writeContract: adapter is required but got undefined");const r=this.getCaipNetwork(),n=this.getCaipAddress(),o=pe.getProvider(t);if(!r||!n)throw new Error("writeContract: caipNetwork or caipAddress is required but got undefined");const a=await(i==null?void 0:i.writeSolanaTransaction({...e,caipNetwork:r,provider:o,caipAddress:n}));return a==null?void 0:a.hash},parseUnits:(e,t)=>{const i=this.getAdapter(O.state.activeChain);if(!i)throw new Error("parseUnits: adapter is required but got undefined");return(i==null?void 0:i.parseUnits({value:e,decimals:t}))??0n},formatUnits:(e,t)=>{const i=this.getAdapter(O.state.activeChain);if(!i)throw new Error("formatUnits: adapter is required but got undefined");return(i==null?void 0:i.formatUnits({value:e,decimals:t}))??"0"},getCapabilities:async e=>{const t=this.getAdapter(O.state.activeChain);if(!t)throw new Error("getCapabilities: adapter is required but got undefined");return await(t==null?void 0:t.getCapabilities(e))},grantPermissions:async e=>{const t=this.getAdapter(O.state.activeChain);if(!t)throw new Error("grantPermissions: adapter is required but got undefined");return await(t==null?void 0:t.grantPermissions(e))},revokePermissions:async e=>{const t=this.getAdapter(O.state.activeChain);if(!t)throw new Error("revokePermissions: adapter is required but got undefined");return t!=null&&t.revokePermissions?await t.revokePermissions(e):"0x"},walletGetAssets:async e=>{const t=this.getAdapter(O.state.activeChain);if(!t)throw new Error("walletGetAssets: adapter is required but got undefined");return await(t==null?void 0:t.walletGetAssets(e))??{}},updateBalance:e=>{const t=this.getAddress(e),i=this.getCaipNetwork(e);!i||!t||this.updateNativeBalance(t,i==null?void 0:i.id,e)}},we.setClient(this.connectionControllerClient)}async onConnectExternal(e){var l,h,u,d,f,p,g,m;const t=O.state.activeChain,i=e.chain||t,r=this.getAdapter(i);let n=!0;if(e.type===Qe.CONNECTOR_TYPE_AUTH&&J.AUTH_CONNECTOR_SUPPORTED_CHAINS.some(I=>he.getConnectorId(I)===J.CONNECTOR_ID.AUTH)&&e.chain!==t&&(n=!1),e.chain&&e.chain!==t&&!e.caipNetwork){const S=this.getCaipNetworks().find(k=>k.chainNamespace===e.chain);S&&n&&this.setCaipNetwork(S)}if(!i)throw new Error("connectExternal: namespace not found");if(!r)throw new Error("connectExternal: adapter not found");const o=this.getCaipNetwork(i),a=e.caipNetwork||o,c=await r.connect({id:e.id,address:e.address,info:e.info,type:e.type,provider:e.provider,socialUri:e.socialUri,chainId:((l=e.caipNetwork)==null?void 0:l.id)||(o==null?void 0:o.id),rpcUrl:((f=(d=(u=(h=e.caipNetwork)==null?void 0:h.rpcUrls)==null?void 0:u.default)==null?void 0:d.http)==null?void 0:f[0])||((m=(g=(p=o==null?void 0:o.rpcUrls)==null?void 0:p.default)==null?void 0:g.http)==null?void 0:m[0])});if(c)return ae.addConnectedNamespace(i),this.syncProvider({...c,chainNamespace:i}),this.setStatus("connected",i),this.syncConnectedWalletInfo(i),ae.removeDisconnectedConnectorId(e.id,i),{address:c.address,connectedCaipNetwork:a}}async connectInactiveNamespaces(e,t){var a;const i=e.type===Qe.CONNECTOR_TYPE_AUTH,r=Mr.getOtherAuthNamespaces((a=t==null?void 0:t.connectedCaipNetwork)==null?void 0:a.chainNamespace),n=O.state.activeCaipNetwork,o=this.getAdapter(n==null?void 0:n.chainNamespace);i&&(await Promise.all(r.map(async c=>{var l,h,u;try{const d=pe.getProvider(c),f=this.getCaipNetwork(c),p=this.getAdapter(c);await(p==null?void 0:p.connect({...e,provider:d,socialUri:void 0,chainId:f==null?void 0:f.id,rpcUrl:(u=(h=(l=f==null?void 0:f.rpcUrls)==null?void 0:l.default)==null?void 0:h.http)==null?void 0:u[0]}))&&(ae.addConnectedNamespace(c),ae.removeDisconnectedConnectorId(e.id,c),this.setStatus("connected",c),this.syncConnectedWalletInfo(c))}catch(d){qe.warn(je.ALERT_WARNINGS.INACTIVE_NAMESPACE_NOT_CONNECTED.displayMessage,je.ALERT_WARNINGS.INACTIVE_NAMESPACE_NOT_CONNECTED.debugMessage(c,d instanceof Error?d.message:void 0),je.ALERT_WARNINGS.INACTIVE_NAMESPACE_NOT_CONNECTED.code)}})),n&&await(o==null?void 0:o.switchNetwork({caipNetwork:n})))}getApprovedCaipNetworksData(){var t,i,r,n,o;if(pe.getProviderId(O.state.activeChain)===Qe.CONNECTOR_TYPE_WALLET_CONNECT){const a=(i=(t=this.universalProvider)==null?void 0:t.session)==null?void 0:i.namespaces;return{supportsAllNetworks:((o=(n=(r=this.universalProvider)==null?void 0:r.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){const t=e.chainNamespace;if(this.getAddressByChainNamespace(e.chainNamespace)){const r=pe.getProviderId(t);if(e.chainNamespace===O.state.activeChain){const n=this.getAdapter(t);await(n==null?void 0:n.switchNetwork({caipNetwork:e}))}else if(this.setCaipNetwork(e),r===Qe.CONNECTOR_TYPE_WALLET_CONNECT)this.syncWalletConnectAccount();else{const n=this.getAddressByChainNamespace(t);n&&this.syncAccount({address:n,chainId:e.id,chainNamespace:t})}}else this.setCaipNetwork(e)}getChainsFromNamespaces(e={}){return Object.values(e).flatMap(t=>{const i=t.chains||[],r=t.accounts.map(n=>{const{chainId:o,chainNamespace:a}=Ds.parseCaipAddress(n);return`${a}:${o}`});return Array.from(new Set([...i,...r]))})}createAdapters(e){return this.createClients(),this.chainNamespaces.reduce((t,i)=>{var n,o;const r=e==null?void 0:e.find(a=>a.namespace===i);return r?(r.construct({namespace:i,projectId:(n=this.options)==null?void 0:n.projectId,networks:(o=this.caipNetworks)==null?void 0:o.filter(({chainNamespace:a})=>a===i)}),t[i]=r):t[i]=new ES({namespace:i,networks:this.getCaipNetworks()}),t},{})}async initChainAdapter(e){this.onConnectors(e),this.listenAdapter(e);const t=this.getAdapter(e);if(!t)throw new Error("adapter not found");await t.syncConnectors(),await this.createUniversalProviderForAdapter(e)}async initChainAdapters(){await Promise.all(this.chainNamespaces.map(async e=>{await this.initChainAdapter(e)})),this.initAdapterController()}onConnectors(e){const t=this.getAdapter(e);t==null||t.on("connectors",this.setConnectors.bind(this))}listenAdapter(e){const t=this.getAdapter(e);if(!t)return;const i=ae.getConnectionStatus();z.state.enableReconnect===!1?this.setStatus("disconnected",e):i==="connected"?this.setStatus("connecting",e):i==="disconnected"?(ae.clearAddressCache(),this.setStatus(i,e)):this.setStatus(i,e),t.on("switchNetwork",({address:r,chainId:n})=>{var l,h;const o=this.getCaipNetworks().find(u=>u.id.toString()===n.toString()||u.caipNetworkId.toString()===n.toString()),a=O.state.activeChain===e,c=(h=(l=O.state.chains.get(e))==null?void 0:l.accountState)==null?void 0:h.address;if(o){const u=a&&r?r:c;u&&this.syncAccount({address:u,chainId:o.id,chainNamespace:e})}else this.setUnsupportedNetwork(n)}),t.on("disconnect",()=>{const r=this.remoteFeatures.multiWallet,n=Array.from(we.state.connections.values()).flat();this.onDisconnectNamespace({chainNamespace:e,closeModal:!r||n.length===0})}),t.on("connections",r=>{this.setConnections(r,e)}),t.on("pendingTransactions",()=>{const r=this.getAddress(e),n=O.state.activeCaipNetwork;!r||!(n!=null&&n.id)||this.updateNativeBalance(r,n.id,n.chainNamespace)}),t.on("accountChanged",({address:r,chainId:n,connector:o})=>{var h,u;this.handlePreviousConnectorConnection(o);const a=O.state.activeChain===e;o!=null&&o.provider&&(this.syncProvider({id:o.id,type:o.type,provider:o==null?void 0:o.provider,chainNamespace:e}),this.syncConnectedWalletInfo(e));const c=(u=(h=O.getNetworkData(e))==null?void 0:h.caipNetwork)==null?void 0:u.id,l=n||c;a&&l?this.syncAccount({address:r,chainId:l,chainNamespace:e}).catch(()=>null):!a&&l?(this.syncAccountInfo(r,l,e),this.syncBalance({address:r,chainId:l,chainNamespace:e}).catch(()=>null)):this.syncAccountInfo(r,n,e),ae.addConnectedNamespace(e)})}async handlePreviousConnectorConnection(e){var c;const t=e==null?void 0:e.chain,i=e==null?void 0:e.id,r=he.getConnectorId(t),n=(c=z.state.remoteFeatures)==null?void 0:c.multiWallet,a=t&&i&&r&&r!==i&&!n;try{a&&await we.disconnect({id:r,namespace:t})}catch(l){console.warn("Error disconnecting previous connector",l)}}async createUniversalProviderForAdapter(e){var t,i,r;await this.getUniversalProvider(),this.universalProvider&&await((r=(i=(t=this.chainAdapters)==null?void 0:t[e])==null?void 0:i.setUniversalProvider)==null?void 0:r.call(i,this.universalProvider))}async syncExistingConnection(){await Promise.allSettled(this.chainNamespaces.map(e=>this.syncNamespaceConnection(e)))}async unSyncExistingConnection(){try{await Promise.allSettled(this.chainNamespaces.map(e=>we.disconnect({namespace:e,initialDisconnect:!0})))}catch(e){console.error("Error disconnecting existing connections:",e)}}async reconnectWalletConnect(){await this.syncWalletConnectAccount();const e=this.getAddress();this.getCaipAddress()||ae.deleteRecentWallet();const t=ae.getRecentWallet();Mt.sendEvent({type:"track",event:"CONNECT_SUCCESS",address:e,properties:{method:Oe.isMobile()?"mobile":"qrcode",name:(t==null?void 0:t.name)||"Unknown",reconnect:!0,view:Ls.state.view,walletRank:t==null?void 0:t.order}})}async syncNamespaceConnection(e){try{e===J.CHAIN.EVM&&Oe.isSafeApp()&&he.setConnectorId(J.CONNECTOR_ID.SAFE,e);const t=he.getConnectorId(e);switch(this.setStatus("connecting",e),t){case J.CONNECTOR_ID.WALLET_CONNECT:await this.reconnectWalletConnect();break;case J.CONNECTOR_ID.AUTH:break;default:await this.syncAdapterConnection(e)}}catch(t){console.warn("AppKit couldn't sync existing connection",t),this.setStatus("disconnected",e)}}onDisconnectNamespace(e){const{chainNamespace:t,closeModal:i}=e||{};O.resetAccount(t),O.resetNetwork(t),ae.removeConnectedNamespace(t);const r=Array.from(O.state.chains.keys());(t?[t]:r).forEach(o=>ae.addDisconnectedConnectorId(he.getConnectorId(o)||"",o)),he.removeConnectorId(t),pe.resetChain(t),this.setUser(null,t),this.setStatus("disconnected",t),this.setConnectedWalletInfo(null,t),i!==!1&&us.close()}async syncAdapterConnections(){await Promise.allSettled(this.chainNamespaces.map(e=>{const t=this.getAdapter(e),i=this.getCaipAddress(e),r=this.getCaipNetwork(e);return t==null?void 0:t.syncConnections({connectToFirstConnector:!i,caipNetwork:r})}))}async syncAdapterConnection(e){var a,c,l,h,u;const t=this.getAdapter(e),i=this.getCaipNetwork(e),r=he.getConnectorId(e),o=he.getConnectors(e).find(d=>d.id===r);try{if(!t||!o)throw new Error(`Adapter or connector not found for namespace ${e}`);if(!(i!=null&&i.id))throw new Error("CaipNetwork not found");const d=await(t==null?void 0:t.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]}));d?(this.syncProvider({...d,chainNamespace:e}),await this.syncAccount({...d,chainNamespace:e}),this.setStatus("connected",e),Mt.sendEvent({type:"track",event:"CONNECT_SUCCESS",address:d.address,properties:{method:"browser",name:((h=o.info)==null?void 0:h.name)||o.name||"Unknown",reconnect:!0,view:Ls.state.view,walletRank:(u=o==null?void 0:o.explorerWallet)==null?void 0:u.order}})):this.setStatus("disconnected",e)}catch{this.onDisconnectNamespace({chainNamespace:e,closeModal:!1})}}async syncWalletConnectAccount(){var i,r;const e=Object.keys(((r=(i=this.universalProvider)==null?void 0:i.session)==null?void 0:r.namespaces)||{}),t=this.chainNamespaces.map(async n=>{var u,d,f,p,g;const o=this.getAdapter(n);if(!o)return;const a=((p=(f=(d=(u=this.universalProvider)==null?void 0:u.session)==null?void 0:d.namespaces)==null?void 0:f[n])==null?void 0:p.accounts)||[],c=(g=O.state.activeCaipNetwork)==null?void 0:g.id,l=a.find(m=>{const{chainId:S}=Ds.parseCaipAddress(m);return S===(c==null?void 0:c.toString())})||a[0];if(l){const m=Ds.validateCaipAddress(l),{chainId:S,address:k}=Ds.parseCaipAddress(m);if(pe.setProviderId(n,Qe.CONNECTOR_TYPE_WALLET_CONNECT),this.caipNetworks&&O.state.activeCaipNetwork&&o.namespace!==J.CHAIN.EVM){const I=o.getWalletConnectProvider({caipNetworks:this.getCaipNetworks(),provider:this.universalProvider,activeCaipNetwork:O.state.activeCaipNetwork});pe.setProvider(n,I)}else pe.setProvider(n,this.universalProvider);he.setConnectorId(J.CONNECTOR_ID.WALLET_CONNECT,n),ae.addConnectedNamespace(n),await this.syncAccount({address:k,chainId:S,chainNamespace:n})}else e.includes(n)&&this.setStatus("disconnected",n);const h=this.getApprovedCaipNetworksData();this.syncConnectedWalletInfo(n),O.setApprovedCaipNetworksData(n,{approvedCaipNetworkIds:h.approvedCaipNetworkIds,supportsAllNetworks:h.supportsAllNetworks})});await Promise.all(t)}syncProvider({type:e,provider:t,id:i,chainNamespace:r}){pe.setProviderId(r,e),pe.setProvider(r,t),he.setConnectorId(i,r)}async syncAccount(e){var u,d;const t=e.chainNamespace===O.state.activeChain,i=O.getCaipNetworkByNamespace(e.chainNamespace,e.chainId),{address:r,chainId:n,chainNamespace:o}=e,{chainId:a}=ae.getActiveNetworkProps(),c=(i==null?void 0:i.id)||a,l=((u=O.state.activeCaipNetwork)==null?void 0:u.name)===J.UNSUPPORTED_NETWORK_NAME,h=O.getNetworkProp("supportsAllNetworks",o);if(this.setStatus("connected",o),!(l&&!h)&&c){let f=this.getCaipNetworks().find(S=>S.id.toString()===c.toString()),p=this.getCaipNetworks().find(S=>S.chainNamespace===o);if(!h&&!f&&!p){const S=this.getApprovedCaipNetworkIds()||[],k=S.find(E=>{var N;return((N=Ds.parseCaipNetworkId(E))==null?void 0:N.chainId)===c.toString()}),I=S.find(E=>{var N;return((N=Ds.parseCaipNetworkId(E))==null?void 0:N.chainNamespace)===o});f=this.getCaipNetworks().find(E=>E.caipNetworkId===k),p=this.getCaipNetworks().find(E=>E.caipNetworkId===I||"deprecatedCaipNetworkId"in E&&E.deprecatedCaipNetworkId===I)}const g=f||p;(g==null?void 0:g.chainNamespace)===O.state.activeChain?z.state.enableNetworkSwitch&&!z.state.allowUnsupportedChain&&((d=O.state.activeCaipNetwork)==null?void 0:d.name)===J.UNSUPPORTED_NETWORK_NAME?O.showUnsupportedChainUI():this.setCaipNetwork(g):t||i&&this.setCaipNetworkOfNamespace(i,o),this.syncConnectedWalletInfo(o);const m=this.getAddress(o);Mr.isLowerCaseMatch(r,m)||this.syncAccountInfo(r,g==null?void 0:g.id,o),t?await this.syncBalance({address:r,chainId:g==null?void 0:g.id,chainNamespace:o}):await this.syncBalance({address:r,chainId:i==null?void 0:i.id,chainNamespace:o}),this.syncIdentity({address:r,chainId:n,chainNamespace:o}).catch(()=>null)}}async syncAccountInfo(e,t,i){const r=this.getCaipAddress(i),n=t||(r==null?void 0:r.split(":")[1]);if(!n)return;const o=`${i}:${n}:${e}`;this.setCaipAddress(o,i,!0),await this.syncIdentity({address:e,chainId:n,chainNamespace:i})}async syncReownName(e,t){try{const i=await this.getReownName(e);if(i[0]){const r=i[0];this.setProfileName(r.name,t)}else this.setProfileName(null,t)}catch{this.setProfileName(null,t)}}syncConnectedWalletInfo(e){var r;const t=he.getConnectorId(e),i=pe.getProviderId(e);if(i===Qe.CONNECTOR_TYPE_ANNOUNCED||i===Qe.CONNECTOR_TYPE_INJECTED){if(t){const o=this.getConnectors().find(a=>{var u,d;const c=a.id===t,l=((u=a.info)==null?void 0:u.rdns)===t,h=(d=a.connectors)==null?void 0:d.some(f=>{var p;return f.id===t||((p=f.info)==null?void 0:p.rdns)===t});return c||l||!!h});if(o){const{info:a,name:c,imageUrl:l}=o,h=l||this.getConnectorImage(o);this.setConnectedWalletInfo({name:c,icon:h,...a},e)}}}else if(i===Qe.CONNECTOR_TYPE_WALLET_CONNECT){const n=pe.getProvider(e);n!=null&&n.session&&this.setConnectedWalletInfo({...n.session.peer.metadata,name:n.session.peer.metadata.name,icon:(r=n.session.peer.metadata.icons)==null?void 0:r[0]},e)}else if(t&&(t===J.CONNECTOR_ID.COINBASE_SDK||t===J.CONNECTOR_ID.COINBASE||t===J.CONNECTOR_ID.BASE_ACCOUNT)){const n=this.getConnectors().find(h=>h.id===t),o=t===J.CONNECTOR_ID.BASE_ACCOUNT?"Base Account":"Coinbase Wallet",a=(n==null?void 0:n.name)||o,c=(n==null?void 0:n.imageUrl)||this.getConnectorImage(n),l=n==null?void 0:n.info;this.setConnectedWalletInfo({...l,name:a,icon:c},e)}}async syncBalance(e){!pf.getNetworksByNamespace(this.getCaipNetworks(),e.chainNamespace).find(i=>{var r;return i.id.toString()===((r=e.chainId)==null?void 0:r.toString())})||!e.chainId||await this.updateNativeBalance(e.address,e.chainId,e.chainNamespace)}async ready(){await this.readyPromise}async updateNativeBalance(e,t,i){const r=this.getAdapter(i),n=O.getCaipNetworkByNamespace(i,t);if(r){const o=await r.getBalance({address:e,chainId:t,caipNetwork:n,tokens:this.options.tokens});return this.setBalance(o.balance,o.symbol,i),o}}async initializeUniversalAdapter(){var r,n,o,a,c,l,h,u,d,f;const e=lS.createLogger((p,...g)=>{p&&this.handleAlertError(p),console.error(...g)}),t={projectId:(r=this.options)==null?void 0:r.projectId,metadata:{name:(n=this.options)!=null&&n.metadata?(o=this.options)==null?void 0:o.metadata.name:"",description:(a=this.options)!=null&&a.metadata?(c=this.options)==null?void 0:c.metadata.description:"",url:(l=this.options)!=null&&l.metadata?(h=this.options)==null?void 0:h.metadata.url:"",icons:(u=this.options)!=null&&u.metadata?(d=this.options)==null?void 0:d.metadata.icons:[""]},logger:e};z.setManualWCControl(!!((f=this.options)!=null&&f.manualWCControl)),this.universalProvider=this.options.universalProvider??await Ba.init(t);const i=this.universalProvider.disconnect.bind(this.universalProvider);this.universalProvider.disconnect=async()=>{try{return await i()}catch(p){if(p instanceof Error&&p.message.includes("Missing or invalid. Record was recently deleted"))return;throw p}},z.state.enableReconnect===!1&&this.universalProvider.session&&await this.universalProvider.disconnect(),this.listenWalletConnect()}listenWalletConnect(){this.universalProvider&&this.chainNamespaces.forEach(e=>{vn.listenWcProvider({universalProvider:this.universalProvider,namespace:e,onDisplayUri:t=>{we.setUri(t)},onConnect:t=>{const{address:i}=Oe.getAccount(t[0]);for(const r of this.chainNamespaces)ae.removeDisconnectedConnectorId(J.CONNECTOR_ID.WALLET_CONNECT,r);we.finalizeWcConnection(i)},onDisconnect:()=>{O.state.noAdapters&&this.resetAccount(e),we.resetWcConnection()},onChainChanged:t=>{const i=O.state.activeChain,r=i&&he.state.activeConnectorIds[i]===J.CONNECTOR_ID.WALLET_CONNECT;if(i===e&&(O.state.noAdapters||r)){const n=this.getCaipNetworks().find(a=>a.id.toString()===t.toString()||a.caipNetworkId.toString()===t.toString()),o=this.getCaipNetwork();if(!n){this.setUnsupportedNetwork(t);return}(o==null?void 0:o.id.toString())!==(n==null?void 0:n.id.toString())&&(o==null?void 0:o.chainNamespace)===(n==null?void 0:n.chainNamespace)&&this.setCaipNetwork(n)}},onAccountsChanged:t=>{const i=O.state.activeChain,r=i&&he.state.activeConnectorIds[i]===J.CONNECTOR_ID.WALLET_CONNECT;if(i===e&&(O.state.noAdapters||r)){const n=t==null?void 0:t[0];n&&this.syncAccount({address:n.address,chainId:n.chainId,chainNamespace:n.chainNamespace})}}})})}createUniversalProvider(){var e;return!this.universalProviderInitPromise&&Oe.isClient()&&((e=this.options)!=null&&e.projectId)&&(this.universalProviderInitPromise=this.initializeUniversalAdapter()),this.universalProviderInitPromise}async getUniversalProvider(){if(!this.universalProvider)try{await this.createUniversalProvider()}catch(e){Mt.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}getDisabledCaipNetworks(){const e=O.getAllApprovedCaipNetworkIds(),t=O.getAllRequestedCaipNetworks();return Oe.sortRequestedNetworks(e,t).filter(r=>O.isCaipNetworkDisabled(r))}handleAlertError(e){const t=Object.entries(je.UniversalProviderErrors).find(([,{message:a}])=>e.message.includes(a)),[i,r]=t??[],{message:n,alertErrorKey:o}=r??{};if(i&&n&&!this.reportedAlertErrors[i]){const a=je.ALERT_ERRORS[o];a&&(qe.open(a,"error"),this.reportedAlertErrors[i]=!0)}}getAdapter(e){var t;if(e)return(t=this.chainAdapters)==null?void 0:t[e]}createAdapter(e){var r,n;if(!e)return;const t=e.namespace;if(!t)return;this.createClients();const i=e;i.namespace=t,i.construct({namespace:t,projectId:(r=this.options)==null?void 0:r.projectId,networks:(n=this.caipNetworks)==null?void 0:n.filter(({chainNamespace:o})=>o===t)}),this.chainNamespaces.includes(t)||this.chainNamespaces.push(t),this.chainAdapters&&(this.chainAdapters[t]=i)}async open(e){await this.injectModalUi(),e!=null&&e.uri&&we.setUri(e.uri);const{isSwap:t,isSend:i}=this.toModalOptions();return t(e)?us.open({...e,data:{swap:e.arguments}}):i(e)&&e.arguments?this.openSend(e.arguments):us.open(e)}async close(){await this.injectModalUi(),us.close()}setLoading(e,t){us.setLoading(e,t)}async disconnect(e){await we.disconnect({namespace:e})}getSIWX(){return z.state.siwx}getError(){return""}getChainId(){var e;return(e=O.state.activeCaipNetwork)==null?void 0:e.id}async switchNetwork(e,{throwOnFailure:t=!1}={}){const i=this.getCaipNetworks().find(r=>r.id===e.id);if(!i){qe.open(je.ALERT_ERRORS.SWITCH_NETWORK_NOT_FOUND,"error");return}await O.switchActiveNetwork(i,{throwOnFailure:t})}getWalletProvider(){return O.state.activeChain?pe.state.providers[O.state.activeChain]:null}getWalletProviderType(){return pe.getProviderId(O.state.activeChain)}subscribeProviders(e){return pe.subscribeProviders(e)}getThemeMode(){return Ut.state.themeMode}getThemeVariables(){return Ut.state.themeVariables}setThemeMode(e){Ut.setThemeMode(e),Qo(Ut.state.themeMode)}setTermsConditionsUrl(e){z.setTermsConditionsUrl(e)}setPrivacyPolicyUrl(e){z.setPrivacyPolicyUrl(e)}setThemeVariables(e){Ut.setThemeVariables(e),vS(Ut.state.themeVariables)}subscribeTheme(e){return Ut.subscribe(e)}subscribeConnections(e){return this.remoteFeatures.multiWallet?we.subscribe(e):(qe.open(J.REMOTE_FEATURES_ALERTS.MULTI_WALLET_NOT_ENABLED.DEFAULT,"info"),()=>{})}getWalletInfo(e){var i,r;if(e)return(r=(i=O.state.chains.get(e))==null?void 0:i.accountState)==null?void 0:r.connectedWalletInfo;const t=O.getAccountData();return t==null?void 0:t.connectedWalletInfo}getAccount(e){const t=e||O.state.activeChain,i=he.getAuthConnector(t),r=O.getAccountData(t),n=ae.getConnectedConnectorId(O.state.activeChain),o=we.getConnections(t);if(!t)throw new Error("AppKit:getAccount - namespace is required");const a=O.getActiveCaipNetwork(t),c=o.flatMap(l=>{const h=l.caipNetwork??a;return h?l.accounts.map(({address:u,type:d,publicKey:f})=>Oe.createAccount({caipAddress:`${h.caipNetworkId}:${u}`,type:d||"eoa",publicKey:f})):[]});if(r)return{allAccounts:c,caipAddress:r.caipAddress,address:Oe.getPlainAddress(r.caipAddress),isConnected:!!r.caipAddress,status:r.status,embeddedWalletInfo:i&&n===J.CONNECTOR_ID.AUTH?{user:r.user?{...r.user,username:ae.getConnectedSocialUsername()}:void 0,authProvider:r.socialProvider||"email",accountType:co(t),isSmartAccountDeployed:!!r.smartAccountDeployed}:void 0}}subscribeAccount(e,t){const i=[],r=()=>{const o=this.getAccount(t);o&&e(o)};if(t){const o=O.subscribeChainProp("accountState",r,t);i.push(o)}else{const o=O.subscribe(r);i.push(o)}const n=he.subscribe(r);return i.push(n),()=>{i.forEach(o=>o())}}subscribeNetwork(e){return O.subscribe(({activeCaipNetwork:t,activeChain:i,chains:r})=>{var o;const n=i?(o=r.get(i))==null?void 0:o.networkState:void 0;e({caipNetwork:t,chainId:t==null?void 0:t.id,caipNetworkId:t==null?void 0:t.caipNetworkId,approvedCaipNetworkIds:n==null?void 0:n.approvedCaipNetworkIds,supportsAllNetworks:(n==null?void 0:n.supportsAllNetworks)??!0})})}subscribeWalletInfo(e,t){return t?O.subscribeChainProp("accountState",i=>e(i==null?void 0:i.connectedWalletInfo),t):O.subscribeChainProp("accountState",i=>e(i==null?void 0:i.connectedWalletInfo))}subscribeShouldUpdateToAddress(e){return O.subscribeChainProp("accountState",t=>e(t==null?void 0:t.shouldUpdateToAddress))}subscribeCaipNetworkChange(e){return O.subscribeKey("activeCaipNetwork",e)}getState(){return qr.state}getRemoteFeatures(){return z.state.remoteFeatures}subscribeState(e){return qr.subscribe(e)}subscribeRemoteFeatures(e){return z.subscribeKey("remoteFeatures",e)}showErrorMessage(e){qa.showError(e)}showSuccessMessage(e){qa.showSuccess(e)}getEvent(){return{...Mt.state}}subscribeEvents(e){return Mt.subscribe(e)}replace(e){Ls.replace(e)}redirect(e){Ls.push(e)}popTransactionStack(e){Ls.popTransactionStack(e)}isOpen(){return us.state.open}isTransactionStackEmpty(){return Ls.state.transactionStack.length===0}static getInstance(){return this.instance}updateFeatures(e){z.setFeatures(e)}updateRemoteFeatures(e){z.setRemoteFeatures(e)}updateOptions(e){const i={...z.state||{},...e};z.setOptions(i)}setConnectMethodsOrder(e){z.setConnectMethodsOrder(e)}setWalletFeaturesOrder(e){z.setWalletFeaturesOrder(e)}setCollapseWallets(e){z.setCollapseWallets(e)}setSocialsOrder(e){z.setSocialsOrder(e)}getConnectMethodsOrder(){return Gd.getConnectOrderMethod(z.state.features,he.getConnectors())}addNetwork(e,t){if(this.chainAdapters&&!this.chainAdapters[e])throw new Error(`Adapter for namespace ${e} doesn't exist`);const i=this.extendCaipNetwork(t,this.options);this.getCaipNetworks().find(r=>r.id===i.id)||O.addNetwork(i)}removeNetwork(e,t){if(this.chainAdapters&&!this.chainAdapters[e])throw new Error(`Adapter for namespace ${e} doesn't exist`);this.getCaipNetworks().find(r=>r.id===t)&&O.removeNetwork(e,t)}}let nh=!1;class Rd extends SS{async onAuthProviderConnected(e){const t=Mr.userChainIdToChainNamespace(e==null?void 0:e.chainId);if(e.message&&e.signature&&e.siwxMessage&&await Tr.addEmbeddedWalletSession({chainId:e.siwxMessage.chainId,accountAddress:e.address,notBefore:e.siwxMessage.notBefore,statement:e.siwxMessage.statement,resources:e.siwxMessage.resources,requestId:e.siwxMessage.requestId,issuedAt:e.siwxMessage.issuedAt,domain:e.siwxMessage.domain,uri:e.siwxMessage.uri,version:e.siwxMessage.version,nonce:e.siwxMessage.nonce},e.message,e.signature),!t)throw new Error("AppKit:onAuthProviderConnected - namespace is required");const i=t===J.CHAIN.EVM?`eip155:${e.chainId}:${e.address}`:`${e.chainId}:${e.address}`,r=z.state.defaultAccountTypes[t],n=co(t),o=e.preferredAccountType||n||r;this.setCaipAddress(i,t);const{signature:a,siwxMessage:c,message:l,...h}=e,u=O.getAccountData(t);this.setUser({...(u==null?void 0:u.user)||{},...h},t),this.setSmartAccountDeployed(!!e.smartAccountDeployed,t),this.setPreferredAccountType(o,t),await Promise.all([this.syncAuthConnectorTheme(this.authProvider),this.syncAccount({address:e.address,chainId:e.chainId,chainNamespace:t})]),this.setLoading(!1,t)}setupAuthConnectorListeners(e){e.onRpcRequest(t=>{En.checkIfRequestExists(t)?En.checkIfRequestIsSafe(t)||this.handleUnsafeRPCRequest():(this.open(),console.error(ja.RPC_METHOD_NOT_ALLOWED_MESSAGE,{method:t.method}),setTimeout(()=>{this.showErrorMessage(ja.RPC_METHOD_NOT_ALLOWED_UI_MESSAGE)},300),e.rejectRpcRequests())}),e.onRpcError(()=>{this.isOpen()&&(this.isTransactionStackEmpty()?this.close():this.popTransactionStack("error"))}),e.onRpcSuccess((t,i)=>{const r=En.checkIfRequestIsSafe(i),n=this.getAddress(),o=O.state.activeCaipNetwork;r||(n&&(o!=null&&o.id)&&this.updateNativeBalance(n,o.id,o.chainNamespace),this.isTransactionStackEmpty()?this.close():this.popTransactionStack("success"))}),e.onNotConnected(()=>{const t=O.state.activeChain;if(!t)throw new Error("AppKit:onNotConnected - namespace is required");he.getConnectorId(t)===J.CONNECTOR_ID.AUTH&&(this.setCaipAddress(null,t),this.setLoading(!1,t))}),e.onConnect(this.onAuthProviderConnected.bind(this)),e.onSocialConnected(this.onAuthProviderConnected.bind(this)),e.onSetPreferredAccount(({address:t,type:i})=>{const r=O.state.activeChain;if(!r)throw new Error("AppKit:onSetPreferredAccount - namespace is required");t&&this.setPreferredAccountType(i,r)})}async syncAuthConnectorTheme(e){if(!e)return;const t=Ut.getSnapshot();await e.syncTheme({themeMode:t.themeMode,themeVariables:t.themeVariables,w3mThemeVariables:Yd(t.themeVariables,t.themeMode)})}async syncAuthConnector(e,t){var h,u,d,f,p,g,m,S,k;const i=J.AUTH_CONNECTOR_SUPPORTED_CHAINS.includes(t),r=t===O.state.activeChain;if(!i)return;this.setLoading(!0,t);const n=e.getLoginEmailUsed();this.setLoading(n,t),n&&this.setStatus("connecting",t);const o=e.getEmail(),a=e.getUsername(),c=((h=O.getAccountData(t))==null?void 0:h.user)||{};this.setUser({...c,username:a,email:o},t),this.setupAuthConnectorListeners(e);const{isConnected:l}=await e.isConnected();if(t&&i&&r)if(l&&((u=this.connectionControllerClient)!=null&&u.connectExternal)){await e.init(),await this.syncAuthConnectorTheme(e),await((p=this.connectionControllerClient)==null?void 0:p.connectExternal({id:J.CONNECTOR_ID.AUTH,info:{name:J.CONNECTOR_ID.AUTH},type:Qe.CONNECTOR_TYPE_AUTH,provider:e,chainId:(f=(d=O.getNetworkData(t))==null?void 0:d.caipNetwork)==null?void 0:f.id,chain:t})),this.setStatus("connected",t);const I=ae.getConnectedSocialProvider();I?Mt.sendEvent({type:"track",event:"SOCIAL_LOGIN_SUCCESS",address:this.getAddress(),properties:{provider:I,reconnect:!0}}):Mt.sendEvent({type:"track",event:"CONNECT_SUCCESS",address:this.getAddress(),properties:{method:"email",name:((k=(S=(m=(g=this.universalProvider)==null?void 0:g.session)==null?void 0:m.peer)==null?void 0:S.metadata)==null?void 0:k.name)||"Unknown",reconnect:!0,view:Ls.state.view,walletRank:void 0}})}else he.getConnectorId(t)===J.CONNECTOR_ID.AUTH&&(this.setStatus("disconnected",t),ae.removeConnectedNamespace(t));this.setLoading(!1,t)}async checkExistingTelegramSocialConnection(e){var t;try{if(!Oe.isTelegram())return;const i=ae.getTelegramSocialProvider();if(!i||!Oe.isClient())return;const n=new URL(window.location.href).searchParams.get("result_uri");if(!n)return;i&&O.setAccountProp("socialProvider",i,e),await((t=this.authProvider)==null?void 0:t.init());const o=he.getAuthConnector();i&&o&&(this.setLoading(!0,e),await we.connectExternal({id:o.id,type:o.type,socialUri:n},o.chain),ae.setConnectedSocialProvider(i),ae.removeTelegramSocialProvider(),Mt.sendEvent({type:"track",event:"SOCIAL_LOGIN_SUCCESS",properties:{provider:i}}))}catch(i){this.setLoading(!1,e),console.error("checkExistingSTelegramocialConnection error",i)}try{const i=new URL(window.location.href);i.searchParams.delete("result_uri"),window.history.replaceState({},document.title,i.toString())}catch(i){console.error("tma social login failed",i)}}createAuthProvider(e){var l,h,u,d;if(!J.AUTH_CONNECTOR_SUPPORTED_CHAINS.includes(e))return;const i=(l=this.remoteFeatures)==null?void 0:l.email,r=Array.isArray((h=this.remoteFeatures)==null?void 0:h.socials)&&this.remoteFeatures.socials.length>0,n=i||r,a=Mr.getActiveNamespaceConnectedToAuth()||e;!this.authProvider&&((u=this.options)!=null&&u.projectId)&&n&&(this.authProvider=Zd.getInstance({projectId:this.options.projectId,enableLogger:this.options.enableAuthLogger,chainId:(d=this.getCaipNetwork(a))==null?void 0:d.caipNetworkId,abortController:je.EmbeddedWalletAbortController,onTimeout:f=>{f==="iframe_load_failed"?qe.open(je.ALERT_ERRORS.IFRAME_LOAD_FAILED,"error"):f==="iframe_request_timeout"?qe.open(je.ALERT_ERRORS.IFRAME_REQUEST_TIMEOUT,"error"):f==="unverified_domain"&&qe.open(je.ALERT_ERRORS.UNVERIFIED_DOMAIN,"error")},getActiveCaipNetwork:f=>Jd(f),getCaipNetworks:f=>O.getCaipNetworks(f)}),qr.subscribeOpen(f=>{var p;!f&&this.isTransactionStackEmpty()&&((p=this.authProvider)==null||p.rejectRpcRequests())}));const c=e===O.state.activeChain&&z.state.enableReconnect;z.state.enableReconnect===!1?this.syncAuthConnectorTheme(this.authProvider):this.authProvider&&c&&(this.syncAuthConnector(this.authProvider,e),this.checkExistingTelegramSocialConnection(e))}createAuthProviderForAdapter(e){var t,i,r;this.createAuthProvider(e),this.authProvider&&((r=(i=(t=this.chainAdapters)==null?void 0:t[e])==null?void 0:i.setAuthProvider)==null||r.call(i,this.authProvider))}initControllers(e){super.initControllers(e),this.options.excludeWalletIds&&_s.initializeExcludedWallets({ids:this.options.excludeWalletIds})}async switchCaipNetwork(e){var o,a,c;if(!e)return;const t=O.state.activeChain,i=e.chainNamespace,r=this.getAddressByChainNamespace(i);if(i===t&&((o=O.getAccountData(i))!=null&&o.caipAddress)){const l=this.getAdapter(i);await(l==null?void 0:l.switchNetwork({caipNetwork:e})),this.setCaipNetwork(e)}else{const h=pe.getProviderId(t)===Qe.CONNECTOR_TYPE_AUTH,u=pe.getProviderId(i),d=u===Qe.CONNECTOR_TYPE_AUTH,f=J.AUTH_CONNECTOR_SUPPORTED_CHAINS.includes(i);if(!i)throw new Error("AppKit:switchCaipNetwork - networkNamespace is required");if((h&&u===void 0||d)&&f)try{if(O.state.activeChain=e.chainNamespace,r){const p=this.getAdapter(i);await(p==null?void 0:p.switchNetwork({caipNetwork:e}))}else await((c=(a=this.connectionControllerClient)==null?void 0:a.connectExternal)==null?void 0:c.call(a,{id:J.CONNECTOR_ID.AUTH,provider:this.authProvider,chain:i,chainId:e.id,type:Qe.CONNECTOR_TYPE_AUTH,caipNetwork:e}));this.setCaipNetwork(e)}catch{const g=this.getAdapter(i);await(g==null?void 0:g.switchNetwork({caipNetwork:e}))}else if(u===Qe.CONNECTOR_TYPE_WALLET_CONNECT){if(!O.state.noAdapters){const p=this.getAdapter(i);await(p==null?void 0:p.switchNetwork({caipNetwork:e}))}this.setCaipNetwork(e),this.syncWalletConnectAccount()}else this.setCaipNetwork(e),r&&this.syncAccount({address:r,chainId:e.id,chainNamespace:i})}}async initialize(e){var t;await super.initialize(e),(t=this.chainNamespaces)==null||t.forEach(i=>{this.createAuthProviderForAdapter(i)}),await this.injectModalUi(),qr.set({initialized:!0})}async syncIdentity({address:e,chainId:t,chainNamespace:i}){var a;if(i!==J.CHAIN.EVM)return;const r=`${i}:${t}`,n=(a=this.caipNetworks)==null?void 0:a.find(c=>c.caipNetworkId===r);if(n!=null&&n.testnet){this.setProfileName(null,i),this.setProfileImage(null,i);return}const o=he.getConnectorId(i)===J.CONNECTOR_ID.AUTH;try{const{name:c,avatar:l}=await this.fetchIdentity({address:e});!c&&o?await this.syncReownName(e,i):(this.setProfileName(c,i),this.setProfileImage(l,i))}catch{t!==1&&this.setProfileImage(null,i)}}syncConnectedWalletInfo(e){const t=pe.getProviderId(e);if(t===Qe.CONNECTOR_TYPE_AUTH){const i=this.authProvider;if(i){const r=ae.getConnectedSocialProvider()??"email",n=i.getEmail()??i.getUsername();this.setConnectedWalletInfo({name:t,identifier:n,social:r},e)}}else super.syncConnectedWalletInfo(e)}async injectModalUi(){if(!Oe.isClient())return;const e={...Ee.DEFAULT_FEATURES,...this.options.features};if(!e.headless&&!nh)try{const t=this.remoteFeatures;if(await this.loadModalComponents(e,t),Oe.isClient()&&!document.querySelector("w3m-modal")){const r=document.createElement("w3m-modal");!z.state.disableAppend&&!z.state.enableEmbedded&&document.body.insertAdjacentElement("beforeend",r)}nh=!0}catch(t){console.error("Error injecting modal UI:",t)}}async loadModalComponents(e,t){if(!Oe.isClient())return;const i=[];(t.email||t.socials&&t.socials.length>0)&&i.push(Ze(()=>import("./embedded-wallet-COvvX2Qp.js"),__vite__mapDeps([10,11,12,13,2,3,4,5,1,6,7,8,9,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29]))),t.email&&i.push(Ze(()=>import("./email-C0z3A7sK.js"),__vite__mapDeps([30,13,11,12,2,3,4,5,31,24,17,1,6,7,8,9,23,15,16,22,32,20,26,27,28,29]))),t.socials&&i.push(Ze(()=>import("./socials-BImUXGbF.js"),__vite__mapDeps([33,11,12,13,2,3,4,5,34,15,16,1,6,7,8,9,35,23,19,22,17,36,14,37,38,26,27,28,29]))),t.swaps&&t.swaps.length>0&&i.push(Ze(()=>import("./swaps-B8Tuo6Pt.js"),__vite__mapDeps([39,11,12,13,2,3,4,5,22,17,23,40,1,6,7,8,9,41,38,42,14,43,20,15,16,26,27,28,29]))),e.send&&i.push(Ze(()=>import("./send-C1EU45CZ.js"),__vite__mapDeps([44,11,12,13,2,3,4,5,22,17,23,45,15,16,1,6,7,8,9,46,24,42,14,38,41,20,47,48,26,27,28,29]))),e.receive&&i.push(Ze(()=>import("./receive-C-M9SmxL.js"),__vite__mapDeps([49,11,12,13,2,3,4,5,14,36,37,1,6,7,8,9,26,27,28,29]))),t.onramp&&t.onramp.length>0&&i.push(Ze(()=>import("./onramp-DWqw8mwD.js"),__vite__mapDeps([50,11,12,13,2,3,4,5,51,17,34,15,16,1,6,7,8,9,14,52,53,24,22,23,20,26,27,28,29]))),t.payWithExchange&&i.push(Ze(()=>import("./pay-with-exchange-B3xXFySH.js"),__vite__mapDeps([54,11,12,13,2,3,4,5,14,21,51,17,38,22,46,15,16,24,1,6,7,8,9,55,23,20,47,45,26,27,28,29]))),t.activity&&i.push(Ze(()=>import("./transactions-N8K1pD5P.js"),__vite__mapDeps([56,11,13,12,2,3,4,5,57,23,24,14,38,1,6,7,8,9,26,27,28,29]))),(e.pay||t.payments)&&i.push(Ze(()=>import("./index-yq7Vx7EH.js"),__vite__mapDeps([58,59,11,12,13,2,3,4,5,22,17,21,14,51,60,23,45,1,6,7,8,9,38,43,26,27,28,29]))),t.emailCapture&&i.push(Ze(()=>import("./data-capture-Clu_u_4e.js"),__vite__mapDeps([61,11,12,13,2,3,4,5,31,24,17,1,6,7,8,9,0,26,27,28,29]))),await Promise.all([...i,Ze(()=>import("./index-DZ8SABwK.js"),__vite__mapDeps([62,11,12,13,2,3,4,5,14,17,48,1,6,7,8,9,23,63,53,24,18,19,60,21,51,22,55,57,38,47,40,43,45,15,16,20,32,34,35,36,37,25,52,26,27,28,29])),Ze(()=>import("./w3m-modal-DWJdJGvu.js"),__vite__mapDeps([64,11,12,13,2,3,4,5,1,6,7,8,9,59,22,17,21,14,51,60,23,45,38,43,18,19,40,63,53,24,41,26,27,28,29]))])}}const AS="1.8.21";function CS(s){return new Rd({...s,sdkVersion:Oe.generateSdkVersion(s.adapters??[],"html",AS)})}const pA=Object.freeze(Object.defineProperty({__proto__:null,AppKit:Rd,CoreHelperUtil:Oe,WcConstantsUtil:zi,createAppKit:CS},Symbol.toStringTag,{value:"Module"}));export{uo as O,oA as a,nA as b,lA as c,hA as d,fA as e,cA as f,aA as g,pA as h,uA as i,dA as r,bS as v};