@dcl/account-site 6.8.0 → 6.9.0

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 (230) hide show
  1. package/assets/Address-BHGD07NO.js +1 -0
  2. package/assets/Authorization-DmoiysGx.js +1 -0
  3. package/assets/CoinbaseSDKConnection-C9-JnGls.js +1 -0
  4. package/assets/{ConstantsUtil-Dl5WOfjM.js → ConstantsUtil-g0AjdkOa.js} +1 -1
  5. package/assets/{ExchangeController-JD5-aj9j.js → ExchangeController-C-OE-irq.js} +1 -1
  6. package/assets/{HelpersUtil-BYRqEOLc.js → HelpersUtil-C073QcrZ.js} +1 -1
  7. package/assets/InAppWalletConnectUI-Bdxz0Bmy.js +1 -0
  8. package/assets/{NetworkUtil-CORVq-U7.js → NetworkUtil-BooKnyFI.js} +1 -1
  9. package/assets/{QRCodeRenderer-CAUMCMrQ.js → QRCodeRenderer-C2O8aJw5.js} +1 -1
  10. package/assets/Solidity-D6b-SCK0.js +1 -0
  11. package/assets/{SwapController-CENGi_f8.js → SwapController-DITN3ZmR.js} +1 -1
  12. package/assets/ThirdwebWalletManager-BUJ2S4b0.js +298 -0
  13. package/assets/TypedData-ByTQ7nLR.js +2 -0
  14. package/assets/addresses-DVWfx5EX.js +1 -0
  15. package/assets/arweave-CldmCeKB.js +1 -0
  16. package/assets/{biconomy-DURQhrK6.js → biconomy-C7JeDEA3.js} +1 -1
  17. package/assets/biconomy-C9hDxeVn.js +1 -0
  18. package/assets/{ccip-CzLewx-i.js → ccip-BtKXNXL8.js} +1 -1
  19. package/assets/{ccip-DGvrteB6.js → ccip-ByfH6Pp1.js} +1 -1
  20. package/assets/ccip-sd4F7RdI.js +1 -0
  21. package/assets/{chains-ClhAINLn.js → chains-ClhzAPRM.js} +1 -1
  22. package/assets/{common-BaZ48mbG.js → common-5Sx2Oaqw.js} +1 -1
  23. package/assets/common-DAlzQshe.js +1 -0
  24. package/assets/concat-hex-D_Hd0Y8j.js +1 -0
  25. package/assets/{controller-CgHGY4fa.js → controller-BKewv9ws.js} +2 -2
  26. package/assets/controller-CMiTdXrl.js +2 -0
  27. package/assets/{data-capture-C3H4h0ye.js → data-capture-SGXWH8uV.js} +1 -1
  28. package/assets/decimals-BkxTCZnw.js +1 -0
  29. package/assets/{decimals-wNlF21S5.js → decimals-DYCSb7r6.js} +1 -1
  30. package/assets/decimals-Den2KPun.js +1 -0
  31. package/assets/{detectExtension-ywrU3B9f.js → detectExtension-BqT-gQP6.js} +1 -1
  32. package/assets/detectExtension-DRxhZaJ-.js +1 -0
  33. package/assets/{email-EtC4Qw7k.js → email-D9PJu66O.js} +1 -1
  34. package/assets/{embedded-wallet-BLxx2nq0.js → embedded-wallet-BNJE9JJY.js} +1 -1
  35. package/assets/{engine-CbOuNdui.js → engine-BpIYDc2z.js} +1 -1
  36. package/assets/engine-CmO-qFS1.js +1 -0
  37. package/assets/estimate-l1-fee-DnqX0KQm.js +2 -0
  38. package/assets/{estimate-l1-fee-COxQ74Xh.js → estimate-l1-fee-n2GS47w0.js} +1 -1
  39. package/assets/eth_estimateGas-DVJqp0a0.js +1 -0
  40. package/assets/eth_estimateGas-ZIidgCSn.js +1 -0
  41. package/assets/{eth_getStorageAt-CLxjZO4t.js → eth_getStorageAt-DMscVfg3.js} +1 -1
  42. package/assets/eth_getTransactionCount-CMQovf3i.js +1 -0
  43. package/assets/{eth_getTransactionCount-BKcuSAaU.js → eth_getTransactionCount-h82D3bxu.js} +1 -1
  44. package/assets/{ethereum-D98w8ceQ.js → ethereum-Db4wQ8cQ.js} +1 -1
  45. package/assets/{extractIPFS-Bwmi3T5d.js → extractIPFS-446jiCiR.js} +1 -1
  46. package/assets/extractIPFS-tOg-rRc-.js +1 -0
  47. package/assets/{features-BqZGfYIj.js → features-Bya_uQnq.js} +1 -1
  48. package/assets/{fetchTokenMetadata-BrBgEOsH.js → fetchTokenMetadata-B1jhcJrg.js} +2 -2
  49. package/assets/fetchTokenMetadata-DXhdZ9jJ.js +2 -0
  50. package/assets/{fortmatic-Rdz9ucwd.js → fortmatic-DWc9CMNy.js} +1 -1
  51. package/assets/get-bytecode-FPC_G1PK.js +1 -0
  52. package/assets/get-ecosystem-wallet-info-BH812YkU.js +1 -0
  53. package/assets/{get-ecosystem-wallet-info-DfHMq1Kz.js → get-ecosystem-wallet-info-CsVSXoZ9.js} +1 -1
  54. package/assets/{getBalance-ZH0H3K3Z.js → getBalance-BJu93LMj.js} +2 -2
  55. package/assets/getBalance-BjubRO2E.js +1 -0
  56. package/assets/getCurrencyMetadata-B6uMlDub.js +2 -0
  57. package/assets/{getInstalledModules-DRhOlDcR.js → getInstalledModules-C_LJpz_7.js} +1 -1
  58. package/assets/getInstalledModules-cmepPgT8.js +1 -0
  59. package/assets/getNFT-BLT_Nrf_.js +2 -0
  60. package/assets/{getNFT-GNDwObaN.js → getNFT-Cf6D_49D.js} +1 -1
  61. package/assets/{getNFT-D6wHZRiB.js → getNFT-ClRsQ9zy.js} +2 -2
  62. package/assets/getNFT-uyJP8nm4.js +1 -0
  63. package/assets/{hashTypedData-41394cRH.js → hashTypedData-CLob9Zsk.js} +1 -1
  64. package/assets/{if-defined-DwiGupeI.js → if-defined-BfXFCfhz.js} +1 -1
  65. package/assets/in-app-wallet-calls-C0n9HjId.js +1 -0
  66. package/assets/{in-app-wallet-calls-CPU2uJ6f.js → in-app-wallet-calls-DUqkYMt1.js} +1 -1
  67. package/assets/index-1chDcRmP.js +2 -0
  68. package/assets/{index-CawWU9rF.js → index-4aItPLLW.js} +1 -1
  69. package/assets/{index-BEFVLZMS.js → index-9x3mVUYQ.js} +1 -1
  70. package/assets/{index-BR8a5etK.js → index-ACY2zvow.js} +1 -1
  71. package/assets/index-B1VBbtk9.js +1 -0
  72. package/assets/index-B4kmUY0d.js +2 -0
  73. package/assets/{index-Fv-acDXO.js → index-B6-Xobl2.js} +79 -78
  74. package/assets/{index-DIBbErfW.js → index-BGg37GBj.js} +1 -1
  75. package/assets/{index-C5zfi_7H.js → index-BQsaEzy7.js} +1 -1
  76. package/assets/{index-BOh2weBI.js → index-BRxU5H7H.js} +1 -1
  77. package/assets/{index-8zzhpxyI.js → index-BSP467IN.js} +1 -1
  78. package/assets/{index-DYQDZBEQ.js → index-BXifexJq.js} +1 -1
  79. package/assets/{index-phZWvHfL.js → index-Bi3OUhfd.js} +1 -1
  80. package/assets/{index-LZKkcZAZ.js → index-BkdqENWn.js} +1 -1
  81. package/assets/{index-BUjD0aLT.js → index-Bqkhbf-j.js} +1 -1
  82. package/assets/{index-CAfWDhIh.js → index-BrNT2tPP.js} +1 -1
  83. package/assets/index-BuLBr4CJ.js +3 -0
  84. package/assets/index-CBfD9fG_.js +3 -0
  85. package/assets/{index-Cm5owbs6.js → index-CCxvZC9z.js} +1 -1
  86. package/assets/{index-dE7qT1rS.js → index-CCzw3eWF.js} +1 -1
  87. package/assets/{index-BYXYehKA.js → index-CFnBXD-E.js} +2 -2
  88. package/assets/{index-Bi4I_eXH.js → index-CFy1Eegq.js} +1 -1
  89. package/assets/{index-vbDUNbAe.js → index-CGT2TfpK.js} +1 -1
  90. package/assets/{index-DjP1lSeJ.js → index-CLLWxWw1.js} +1 -1
  91. package/assets/{index-BjsRGW04.js → index-CMAF5KQo.js} +1 -1
  92. package/assets/{index-DDz_fX9F.js → index-CRXo5c7W.js} +1 -1
  93. package/assets/{index-C8LVWiNY.js → index-CXPEr8lr.js} +1 -1
  94. package/assets/{index-C79cRihP.js → index-C_CWRNXS.js} +1 -1
  95. package/assets/{index-B2fn3xIB.js → index-Ci26p999.js} +1 -1
  96. package/assets/{index-BkDiaE7t.js → index-Cja4UOCF.js} +1 -1
  97. package/assets/{index-C8qQNWbc.js → index-CpXrWP2a.js} +1 -1
  98. package/assets/{index-CgxIIYSr.js → index-Cv59_Dqg.js} +1 -1
  99. package/assets/{index-BbTsvCPk.js → index-CwOCLTiY.js} +1 -1
  100. package/assets/{index-C52TTugH.js → index-CxlJ-ZjW.js} +1 -1
  101. package/assets/{index-CJe1v77g.js → index-D-By2c9G.js} +1 -1
  102. package/assets/{index-CSiyIFnr.js → index-D0Jyo-s4.js} +1 -1
  103. package/assets/{index-mD5QWGsm.css → index-D2E7Umr3.css} +3 -3
  104. package/assets/{index-DLargbIn.js → index-DAGLKstf.js} +2 -2
  105. package/assets/{index-CSOxc5sc.js → index-DMZH80fA.js} +4 -4
  106. package/assets/index-DO01SzHY.js +4 -0
  107. package/assets/{index-DaWq4Nzj.js → index-DPWaLJzM.js} +1 -1
  108. package/assets/{index-DL0Eu5uz.js → index-DQt5rtxO.js} +1 -1
  109. package/assets/{index-jGki-zKe.js → index-DSqN93eC.js} +1 -1
  110. package/assets/{index-DjWVQGcv.js → index-DcZ1OZua.js} +1 -1
  111. package/assets/{index-BWZPtavh.js → index-DdD6BFNW.js} +1 -1
  112. package/assets/{index-8Zxz62OX.js → index-DftmpJ8E.js} +2 -2
  113. package/assets/{index-ZEPn8qKc.js → index-DuB7aae8.js} +1 -1
  114. package/assets/{index-rAbloVh4.js → index-TpT45Yhr.js} +4 -4
  115. package/assets/{index-B8gDkzKR.js → index-yvAPBrdI.js} +1 -1
  116. package/assets/index.es-BdGfQ9jz.js +29 -0
  117. package/assets/{index.es-BdRu1h__.js → index.es-CN4hhQIr.js} +1 -1
  118. package/assets/index.es-Cjo6uLeK.js +1 -0
  119. package/assets/{index.es-pnQCY6-7.js → index.es-LxVxXtUw.js} +1 -1
  120. package/assets/is-smart-wallet-kSShE3hl.js +1 -0
  121. package/assets/{native-CjSUDNml.js → native-CXizm-TO.js} +1 -1
  122. package/assets/{networks-B6IlNWMm.js → networks-DyswiDcL.js} +1 -1
  123. package/assets/oauth-CbK0gPlt.js +1 -0
  124. package/assets/{onramp-BTk7sVPr.js → onramp-phO3GqLV.js} +1 -1
  125. package/assets/{openzeppelin-BKxO6pj6.js → openzeppelin-CASw4uSB.js} +1 -1
  126. package/assets/openzeppelin-Dkk77Xr9.js +1 -0
  127. package/assets/ownerOf-Dn5Rvewb.js +1 -0
  128. package/assets/{ownerOf-CYvZRT99.js → ownerOf-HLFmP4SY.js} +1 -1
  129. package/assets/parse-typed-data-BSOEUDy_.js +1 -0
  130. package/assets/{parseNft-DhQFzpJp.js → parseNft-CwiONVVV.js} +2 -2
  131. package/assets/{parseSignature-DoNNAGxu.js → parseSignature-BsYIWxqL.js} +13 -13
  132. package/assets/{parseSignature-BduqmbK2.js → parseSignature-DXMGd6Bf.js} +3 -3
  133. package/assets/passkeys-tlSlZIRR.js +1 -0
  134. package/assets/{pay-with-exchange-CgOu6Uya.js → pay-with-exchange-BsYgDiHf.js} +1 -1
  135. package/assets/{qr-overlay-Bm0XTjkI.js → qr-overlay-B21EcFCK.js} +1 -1
  136. package/assets/{qr-overlay-DyMiJXUk.js → qr-overlay-CDVJkAma.js} +1 -1
  137. package/assets/read-contract-D8CQ_i-D.js +1 -0
  138. package/assets/{receive-r5RgRUWl.js → receive-CVGDvas8.js} +1 -1
  139. package/assets/{ref-Ki-jDMmv.js → ref-DeR4tBmt.js} +1 -1
  140. package/assets/resolveImplementation-2abc0dxK.js +1 -0
  141. package/assets/{resolveImplementation-B8tKI-wG.js → resolveImplementation-Cr9HN7sF.js} +1 -1
  142. package/assets/{rpc-nyXL61KJ.js → rpc-BuDu_uQE.js} +1 -1
  143. package/assets/{rpc-rFcFDQyb.js → rpc-DjXtIps7.js} +2 -2
  144. package/assets/secp256k1-BlHNYIaG.js +1 -0
  145. package/assets/{secp256k1-CPRDF0BA.js → secp256k1-CJ52XpcF.js} +1 -1
  146. package/assets/{send-DeIfSZo1.js → send-DP5QRJYD.js} +1 -1
  147. package/assets/send-batch-transaction-De71luzT.js +1 -0
  148. package/assets/{send-batch-transaction-CIuDJ271.js → send-batch-transaction-Dx0kM3Nk.js} +1 -1
  149. package/assets/{send-eip712-transaction-CknhU72d.js → send-eip712-transaction-Dm4F9s4t.js} +2 -2
  150. package/assets/send-eip712-transaction-q3anVEgs.js +2 -0
  151. package/assets/send-gasless-transaction-CQa_Dj1Y.js +2 -0
  152. package/assets/{send-gasless-transaction-yIAhbb7k.js → send-gasless-transaction-mWAyMAXy.js} +2 -2
  153. package/assets/send-transaction-B0F9brDJ.js +2 -0
  154. package/assets/{session-proposal-qDW11rpc.js → session-proposal-FRNsvDTi.js} +1 -1
  155. package/assets/session-proposal-ef7aaaHV.js +1 -0
  156. package/assets/session-request-Bz2BIU-j.js +2 -0
  157. package/assets/{session-request-By9y-Ayi.js → session-request-Cwmcu41B.js} +2 -2
  158. package/assets/sha256-BPZogG9w.js +1 -0
  159. package/assets/{sha256-_sKanFR7.js → sha256-DViOA4V5.js} +1 -1
  160. package/assets/{signing-Db0bjZpz.js → signing-D7Nlzpwh.js} +5 -5
  161. package/assets/signing-DhfHxzxy.js +2 -0
  162. package/assets/sleep-B_ShGKZF.js +1 -0
  163. package/assets/{socials-BcoSkWK5.js → socials-BZcwTEhb.js} +1 -1
  164. package/assets/{swaps-Bj8TNJkd.js → swaps-Cam24Ey2.js} +1 -1
  165. package/assets/switch-chain-YGyDlbyD.js +1 -0
  166. package/assets/thirdweb-B7gLwLri.js +27 -0
  167. package/assets/to-serializable-transaction-DAYFWHyO.js +23 -0
  168. package/assets/{totalSupply-CcNS_GzH.js → totalSupply-BZIagNGM.js} +1 -1
  169. package/assets/totalSupply-CWYDbbpl.js +1 -0
  170. package/assets/{transactionReceipt-CdsZdsdr.js → transactionReceipt-B-BG4ub0.js} +1 -1
  171. package/assets/{transactions-DuCMsSn_.js → transactions-CSAp5P5s.js} +1 -1
  172. package/assets/types-DFEAKZ3L.js +4 -0
  173. package/assets/utils-BtpzmIxp.js +2 -0
  174. package/assets/{utils-mHMkg6Kp.js → utils-Onbz2awt.js} +1 -1
  175. package/assets/{verifyHash-CboNxe2B.js → verifyHash-Bx9bP5KA.js} +3 -3
  176. package/assets/{w3m-modal-Cv35RGiT.js → w3m-modal-C63bxWaq.js} +1 -1
  177. package/assets/wait-for-tx-receipt-CuLnfaKm.js +1 -0
  178. package/assets/{wait-for-tx-receipt-Drv8Lr1P.js → wait-for-tx-receipt-DhBzWdPW.js} +1 -1
  179. package/assets/{wallets-GwhGT1dM.js → wallets-SiIK_4eu.js} +6 -6
  180. package/assets/{web-connector-bxGgXqpW.js → web-connector-BnZ6I9U8.js} +3 -3
  181. package/assets/web-connector-DJrJBk0_.js +2 -0
  182. package/assets/{zora-sepolia-Cm6nfoBw.js → zora-sepolia-5TL5obss.js} +1 -1
  183. package/index.html +2 -2
  184. package/package.json +3 -3
  185. package/assets/CoinbaseSDKConnection-BKJdrNl1.js +0 -1
  186. package/assets/InAppWalletConnectUI-BCpqJr7x.js +0 -1
  187. package/assets/ThirdwebWalletManager-C0WgXnZx.js +0 -326
  188. package/assets/biconomy-dnUC9FHi.js +0 -1
  189. package/assets/ccip-gHbZ_fY7.js +0 -1
  190. package/assets/common-DXGQjmn7.js +0 -1
  191. package/assets/concat-hex-BkDmxQZp.js +0 -1
  192. package/assets/controller-XOXJb_Xj.js +0 -2
  193. package/assets/decimals-Bk-qoHwa.js +0 -1
  194. package/assets/detectExtension-BeXqHbY8.js +0 -1
  195. package/assets/engine-BZxfKBvb.js +0 -1
  196. package/assets/estimate-l1-fee-CpxowJdJ.js +0 -2
  197. package/assets/eth_estimateGas-BI87Z6lb.js +0 -1
  198. package/assets/eth_estimateGas-D6jt3ABx.js +0 -1
  199. package/assets/eth_getTransactionCount-DX2PE6Uh.js +0 -1
  200. package/assets/extractIPFS-LV30uJp-.js +0 -1
  201. package/assets/fetchTokenMetadata-D7KlTBZU.js +0 -2
  202. package/assets/get-ecosystem-wallet-info-BpGtHQgI.js +0 -1
  203. package/assets/getBalance-B2S2mDBX.js +0 -1
  204. package/assets/getCurrencyMetadata-DO1CX_p4.js +0 -2
  205. package/assets/getInstalledModules-DQWxNwhQ.js +0 -1
  206. package/assets/getNFT-BS49C2kr.js +0 -1
  207. package/assets/getNFT-CW_k-N6S.js +0 -2
  208. package/assets/in-app-wallet-calls-C-2B-t-w.js +0 -1
  209. package/assets/index-BDODUKme.js +0 -1
  210. package/assets/index-BKKV2746.js +0 -3
  211. package/assets/index-C1yUcBr3.js +0 -2
  212. package/assets/index-DJX4jI7z.js +0 -2
  213. package/assets/index-DKiQCady.js +0 -3
  214. package/assets/index.es-DkH7OFeN.js +0 -29
  215. package/assets/index.es-anFcjT3-.js +0 -1
  216. package/assets/openzeppelin-C8E5DMGT.js +0 -1
  217. package/assets/ownerOf-CLN-nhw1.js +0 -1
  218. package/assets/resolveImplementation-YurP5AVa.js +0 -1
  219. package/assets/secp256k1-CLk510R-.js +0 -1
  220. package/assets/send-batch-transaction-BRauQRcY.js +0 -1
  221. package/assets/send-eip712-transaction-CJ8IBHyz.js +0 -2
  222. package/assets/send-gasless-transaction-Ds_GyVDO.js +0 -2
  223. package/assets/session-proposal-BOjuBppp.js +0 -1
  224. package/assets/session-request-BltijLOZ.js +0 -2
  225. package/assets/sha256-uQaZGirP.js +0 -1
  226. package/assets/signing-GXncBciP.js +0 -2
  227. package/assets/switch-chain-DXxIqQkk.js +0 -1
  228. package/assets/thirdweb-COhbCMEp.js +0 -27
  229. package/assets/totalSupply-ur_EDW6t.js +0 -1
  230. package/assets/web-connector-B0B4AGqG.js +0 -2
@@ -0,0 +1 @@
1
+ import{P as d,K as f,C as i,J as h}from"./index-B6-Xobl2.js";import{c as l}from"./types-DFEAKZ3L.js";function m(e,t={}){const{as:r=typeof e=="string"?"Hex":"Bytes"}=t,s=l(d(e));return r==="Bytes"?s:f(s)}class p extends Map{constructor(t){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=t}get(t){const r=super.get(t);return super.has(t)&&r!==void 0&&(this.delete(t),super.set(t,r)),r}set(t,r){if(super.set(t,r),this.maxSize&&this.size>this.maxSize){const s=this.keys().next().value;s&&this.delete(s)}return this}}const b={checksum:new p(8192)},a=b.checksum,x=/^0x[a-fA-F0-9]{40}$/;function u(e,t={}){const{strict:r=!0}=t;if(!x.test(e))throw new o({address:e,cause:new g});if(r){if(e.toLowerCase()===e)return;if(w(e)!==e)throw new o({address:e,cause:new y})}}function w(e){if(a.has(e))return a.get(e);u(e,{strict:!1});const t=e.substring(2).toLowerCase(),r=m(h(t),{as:"Bytes"}),s=t.split("");for(let n=0;n<40;n+=2)r[n>>1]>>4>=8&&s[n]&&(s[n]=s[n].toUpperCase()),(r[n>>1]&15)>=8&&s[n+1]&&(s[n+1]=s[n+1].toUpperCase());const c=`0x${s.join("")}`;return a.set(e,c),c}function A(e,t={}){const{strict:r=!0}=t??{};try{return u(e,{strict:r}),!0}catch{return!1}}class o extends i{constructor({address:t,cause:r}){super(`Address "${t}" is invalid.`,{cause:r}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidAddressError"})}}class g extends i{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 y extends i{constructor(){super("Address does not match its checksum counterpart."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidChecksumError"})}}export{o as I,u as a,g as b,m as k,A as v};
@@ -0,0 +1 @@
1
+ import{k as P}from"./Address-BHGD07NO.js";import{C as r,K as y,M as g,G as f,y as U,N as x,z as o,O as p,H as R,c as B}from"./index-B6-Xobl2.js";import{m as d}from"./Solidity-D6b-SCK0.js";const I={bytes:new Uint8Array,dataView:new DataView(new ArrayBuffer(0)),position:0,positionReadCount:new Map,recursiveReadCount:0,recursiveReadLimit:Number.POSITIVE_INFINITY,assertReadLimit(){if(this.recursiveReadCount>=this.recursiveReadLimit)throw new O({count:this.recursiveReadCount+1,limit:this.recursiveReadLimit})},assertPosition(t){if(t<0||t>this.bytes.length-1)throw new L({length:this.bytes.length,position:t})},decrementPosition(t){if(t<0)throw new l({offset:t});const e=this.position-t;this.assertPosition(e),this.position=e},getReadCount(t){return this.positionReadCount.get(t||this.position)||0},incrementPosition(t){if(t<0)throw new l({offset:t});const e=this.position+t;this.assertPosition(e),this.position=e},inspectByte(t){const e=t??this.position;return this.assertPosition(e),this.bytes[e]},inspectBytes(t,e){const i=e??this.position;return this.assertPosition(i+t-1),this.bytes.subarray(i,i+t)},inspectUint8(t){const e=t??this.position;return this.assertPosition(e),this.bytes[e]},inspectUint16(t){const e=t??this.position;return this.assertPosition(e+1),this.dataView.getUint16(e)},inspectUint24(t){const e=t??this.position;return this.assertPosition(e+2),(this.dataView.getUint16(e)<<8)+this.dataView.getUint8(e+2)},inspectUint32(t){const e=t??this.position;return this.assertPosition(e+3),this.dataView.getUint32(e)},pushByte(t){this.assertPosition(this.position),this.bytes[this.position]=t,this.position++},pushBytes(t){this.assertPosition(this.position+t.length-1),this.bytes.set(t,this.position),this.position+=t.length},pushUint8(t){this.assertPosition(this.position),this.bytes[this.position]=t,this.position++},pushUint16(t){this.assertPosition(this.position+1),this.dataView.setUint16(this.position,t),this.position+=2},pushUint24(t){this.assertPosition(this.position+2),this.dataView.setUint16(this.position,t>>8),this.dataView.setUint8(this.position+2,t&255),this.position+=3},pushUint32(t){this.assertPosition(this.position+3),this.dataView.setUint32(this.position,t),this.position+=4},readByte(){this.assertReadLimit(),this._touch();const t=this.inspectByte();return this.position++,t},readBytes(t,e){this.assertReadLimit(),this._touch();const i=this.inspectBytes(t);return this.position+=e??t,i},readUint8(){this.assertReadLimit(),this._touch();const t=this.inspectUint8();return this.position+=1,t},readUint16(){this.assertReadLimit(),this._touch();const t=this.inspectUint16();return this.position+=2,t},readUint24(){this.assertReadLimit(),this._touch();const t=this.inspectUint24();return this.position+=3,t},readUint32(){this.assertReadLimit(),this._touch();const t=this.inspectUint32();return this.position+=4,t},get remaining(){return this.bytes.length-this.position},setPosition(t){const e=this.position;return this.assertPosition(t),this.position=t,()=>this.position=e},_touch(){if(this.recursiveReadLimit===Number.POSITIVE_INFINITY)return;const t=this.getReadCount();this.positionReadCount.set(this.position,t+1),t>0&&this.recursiveReadCount++}};function E(t,{recursiveReadLimit:e=8192}={}){const i=Object.create(I);return i.bytes=t,i.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength),i.positionReadCount=new Map,i.recursiveReadLimit=e,i}class l extends r{constructor({offset:e}){super(`Offset \`${e}\` cannot be negative.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Cursor.NegativeOffsetError"})}}class L extends r{constructor({length:e,position:i}){super(`Position \`${i}\` is out of bounds (\`0 < position < ${e}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Cursor.PositionOutOfBoundsError"})}}class O extends r{constructor({count:e,limit:i}){super(`Recursive read limit of \`${i}\` exceeded (recursive read count: \`${e}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Cursor.RecursiveReadLimitExceededError"})}}function V(t,e){const{as:i}=e,s=m(t),n=E(new Uint8Array(s.length));return s.encode(n),i==="Hex"?y(n.bytes):n.bytes}function $(t,e={}){const{as:i="Hex"}=e;return V(t,{as:i})}function m(t){return Array.isArray(t)?S(t.map(e=>m(e))):N(t)}function S(t){const e=t.reduce((n,u)=>n+u.length,0),i=b(e);return{length:e<=55?1+e:1+i+e,encode(n){e<=55?n.pushByte(192+e):(n.pushByte(247+i),i===1?n.pushUint8(e):i===2?n.pushUint16(e):i===3?n.pushUint24(e):n.pushUint32(e));for(const{encode:u}of t)u(n)}}}function N(t){const e=typeof t=="string"?g(t):t,i=b(e.length);return{length:e.length===1&&e[0]<128?1:e.length<=55?1+e.length:1+i+e.length,encode(n){e.length===1&&e[0]<128?n.pushBytes(e):e.length<=55?(n.pushByte(128+e.length),n.pushBytes(e)):(n.pushByte(183+i),i===1?n.pushUint8(e.length):i===2?n.pushUint16(e.length):i===3?n.pushUint24(e.length):n.pushUint32(e.length),n.pushBytes(e))}}}function b(t){if(t<2**8)return 1;if(t<2**16)return 2;if(t<2**24)return 3;if(t<2**32)return 4;throw new r("Length is too large.")}function C(t,e={}){const{recovered:i}=e;if(typeof t.r>"u")throw new h({signature:t});if(typeof t.s>"u")throw new h({signature:t});if(i&&typeof t.yParity>"u")throw new h({signature:t});if(t.r<0n||t.r>d)throw new k({value:t.r});if(t.s<0n||t.s>d)throw new D({value:t.s});if(typeof t.yParity=="number"&&t.yParity!==0&&t.yParity!==1)throw new a({value:t.yParity})}function z(t){return v(y(t))}function v(t){if(t.length!==130&&t.length!==132)throw new H({signature:t});const e=BigInt(f(t,0,32)),i=BigInt(f(t,32,64)),s=(()=>{const n=+`0x${t.slice(130)}`;if(!Number.isNaN(n))try{return c(n)}catch{throw new a({value:n})}})();return typeof s>"u"?{r:e,s:i}:{r:e,s:i,yParity:s}}function _(t){if(!(typeof t.r>"u")&&!(typeof t.s>"u"))return j(t)}function j(t){const e=typeof t=="string"?v(t):t instanceof Uint8Array?z(t):typeof t.r=="string"?A(t):t.v?T(t):{r:t.r,s:t.s,...typeof t.yParity<"u"?{yParity:t.yParity}:{}};return C(e),e}function T(t){return{r:t.r,s:t.s,yParity:c(t.v)}}function A(t){const e=(()=>{const i=t.v?Number(t.v):void 0;let s=t.yParity?Number(t.yParity):void 0;if(typeof i=="number"&&typeof s!="number"&&(s=c(i)),typeof s!="number")throw new a({value:t.yParity});return s})();return{r:BigInt(t.r),s:BigInt(t.s),yParity:e}}function M(t){const{r:e,s:i,yParity:s}=t;return{r:o(e,{size:32}),s:o(i,{size:32}),yParity:s===0?"0x0":"0x1"}}function Y(t){const{r:e,s:i,yParity:s}=t;return[s?"0x01":"0x",e===0n?"0x":p(o(e)),i===0n?"0x":p(o(i))]}function c(t){if(t===0||t===27)return 0;if(t===1||t===28)return 1;if(t>=35)return t%2===0?1:0;throw new F({value:t})}function W(t){if(t===0)return 27;if(t===1)return 28;throw new a({value:t})}class H extends r{constructor({signature:e}){super(`Value \`${e}\` is an invalid signature size.`,{metaMessages:["Expected: 64 bytes or 65 bytes.",`Received ${U(x(e))} bytes.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidSerializedSizeError"})}}class h extends r{constructor({signature:e}){super(`Signature \`${R(e)}\` is missing either an \`r\`, \`s\`, or \`yParity\` property.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.MissingPropertiesError"})}}class k extends r{constructor({value:e}){super(`Value \`${e}\` is an invalid r value. r must be a positive integer less than 2^256.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidRError"})}}class D extends r{constructor({value:e}){super(`Value \`${e}\` is an invalid s value. s must be a positive integer less than 2^256.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidSError"})}}class a extends r{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 F extends r{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 X(t){return G(t)}function G(t){return P(B("0x05",$(w(t))))}function K(t){const{address:e,chainId:i,nonce:s,...n}=t;return{address:e,chainId:o(i),nonce:o(s),...M(n)}}function Z(t){return t.map(K)}function w(t){const{address:e,chainId:i,nonce:s}=t,n=_(t);return[i?o(i):"0x",e,s?o(s):"0x",...n?Y(n):[]]}function tt(t){if(!t||t.length===0)return[];const e=[];for(const i of t)e.push(w(i));return e}export{F as I,tt as a,T as b,v as c,Z as d,_ as e,$ as f,X as g,Y as t,c as v,W as y};
@@ -0,0 +1 @@
1
+ import{r as n,k as f}from"./index-B6-Xobl2.js";import{C as d}from"./ThirdwebWalletManager-BUJ2S4b0.js";import"./oauth-CbK0gPlt.js";import"./types-DFEAKZ3L.js";import"./send-transaction-B0F9brDJ.js";import"./to-serializable-transaction-DAYFWHyO.js";import"./is-smart-wallet-kSShE3hl.js";import"./get-bytecode-FPC_G1PK.js";import"./index-DO01SzHY.js";import"./utils-BtpzmIxp.js";import"./wait-for-tx-receipt-CuLnfaKm.js";import"./sleep-mAKpSMLY.js";import"./TypedData-ByTQ7nLR.js";import"./Address-BHGD07NO.js";import"./Solidity-D6b-SCK0.js";import"./parse-typed-data-BSOEUDy_.js";import"./Authorization-DmoiysGx.js";import"./store-CraP4F4Y.js";import"./addresses-DVWfx5EX.js";import"./read-contract-D8CQ_i-D.js";import"./decimals-BkxTCZnw.js";import"./passkeys-tlSlZIRR.js";import"./webauthn.min-CGpVStYZ.js";import"./arweave-CAGvOb64.js";import"./index.es-BdGfQ9jz.js";function F(t){const{onBack:m,done:i,wallet:r,walletInfo:l,onGetStarted:s,locale:e}=t,[p,c]=n.useState(!1),o=n.useCallback(()=>{c(!1),r.connect({chain:t.chain,client:t.client}).then(()=>{i()}).catch(u=>{console.error(u),c(!0)})},[t.client,r,t.chain,i]),a=n.useRef(!1);return n.useEffect(()=>{a.current||(a.current=!0,o())},[o]),f.jsx(d,{client:t.client,errorConnecting:p,locale:{failed:e.connectionScreen.failed,getStartedLink:e.getStartedLink,inProgress:e.connectionScreen.inProgress,instruction:e.connectionScreen.instruction,tryAgain:e.connectionScreen.retry},onBack:m,onGetStarted:s,onRetry:o,size:t.size,walletId:r.id,walletName:l.name})}export{F as default};
@@ -1 +1 @@
1
- import{b as t}from"./index-Fv-acDXO.js";var e={};const o={ACCOUNT_TABS:[{label:"Tokens"},{label:"Activity"}],SECURE_SITE_ORIGIN:(typeof t<"u"&&typeof e<"u"?e.NEXT_PUBLIC_SECURE_SITE_ORIGIN:void 0)||"https://secure.walletconnect.org",VIEW_DIRECTION:{Next:"next",Prev:"prev"},ANIMATION_DURATIONS:{HeaderText:120},VIEWS_WITH_LEGAL_FOOTER:["Connect","ConnectWallets","OnRampTokenSelect","OnRampFiatSelect","OnRampProviders"],VIEWS_WITH_DEFAULT_FOOTER:["Networks"]};export{o as C};
1
+ import{b as t}from"./index-B6-Xobl2.js";var e={};const o={ACCOUNT_TABS:[{label:"Tokens"},{label:"Activity"}],SECURE_SITE_ORIGIN:(typeof t<"u"&&typeof e<"u"?e.NEXT_PUBLIC_SECURE_SITE_ORIGIN:void 0)||"https://secure.walletconnect.org",VIEW_DIRECTION:{Next:"next",Prev:"prev"},ANIMATION_DURATIONS:{HeaderText:120},VIEWS_WITH_LEGAL_FOOTER:["Connect","ConnectWallets","OnRampTokenSelect","OnRampFiatSelect","OnRampProviders"],VIEWS_WITH_DEFAULT_FOOTER:["Networks"]};export{o as C};
@@ -1 +1 @@
1
- import{p as k,g as U,C as l,E as w,a as E,S as A,b as x,f as P,c as N,d as I,O as L,N as f,e as C,B as T,h as W,s as _,i as v}from"./index-rAbloVh4.js";const D=0,b={paymentAsset:null,amount:null,tokenAmount:0,priceLoading:!1,error:null,exchanges:[],isLoading:!1,currentPayment:void 0,isPaymentInProgress:!1,paymentId:"",assets:[]},e=k(b),m={state:e,subscribe(t){return v(e,()=>t(e))},subscribeKey(t,n){return _(e,t,n)},resetState(){Object.assign(e,{...b})},async getAssetsForNetwork(t){const n=W(t),s=await m.getAssetsImageAndPrice(n),r=n.map(a=>{var c,o,p,y;const u=a.asset==="native"?C():`${a.network}:${a.asset}`,i=s.find(S=>{var g,d,h;return((h=(d=(g=S.fungibles)==null?void 0:g[0])==null?void 0:d.address)==null?void 0:h.toLowerCase())===u.toLowerCase()});return{...a,price:((o=(c=i==null?void 0:i.fungibles)==null?void 0:c[0])==null?void 0:o.price)||1,metadata:{...a.metadata,iconUrl:(y=(p=i==null?void 0:i.fungibles)==null?void 0:p[0])==null?void 0:y.iconUrl}}});return e.assets=r,r},async getAssetsImageAndPrice(t){const n=t.map(r=>r.asset==="native"?C():`${r.network}:${r.asset}`);return await Promise.all(n.map(r=>T.fetchTokenPrice({addresses:[r]})))},getTokenAmount(){var s;if(!((s=e==null?void 0:e.paymentAsset)!=null&&s.price))throw new Error("Cannot get token price");const t=f.bigNumber(e.amount??0).round(8),n=f.bigNumber(e.paymentAsset.price).round(8);return t.div(n).round(8).toNumber()},setAmount(t){var n;e.amount=t,(n=e.paymentAsset)!=null&&n.price&&(e.tokenAmount=m.getTokenAmount())},setPaymentAsset(t){e.paymentAsset=t},isPayWithExchangeEnabled(){var t;return(t=L.state.remoteFeatures)==null?void 0:t.payWithExchange},isPayWithExchangeSupported(){return m.isPayWithExchangeEnabled()&&l.state.activeCaipNetwork&&I.PAY_WITH_EXCHANGE_SUPPORTED_CHAIN_NAMESPACES.includes(l.state.activeCaipNetwork.chainNamespace)},async fetchExchanges(){var t;try{const n=m.isPayWithExchangeSupported();if(!e.paymentAsset||!n){e.exchanges=[],e.isLoading=!1;return}e.isLoading=!0;const s=await N({page:D,asset:P(e.paymentAsset.network,e.paymentAsset.asset),amount:((t=e.amount)==null?void 0:t.toString())??"0"});e.exchanges=s.exchanges.slice(0,2)}catch{throw A.showError("Unable to get exchanges"),new Error("Unable to get exchanges")}finally{e.isLoading=!1}},async getPayUrl(t,n){try{const s=Number(n.amount),r=await x({exchangeId:t,asset:P(n.network,n.asset),amount:s.toString(),recipient:`${n.network}:${n.recipient}`});return w.sendEvent({type:"track",event:"PAY_EXCHANGE_SELECTED",properties:{exchange:{id:t},configuration:{network:n.network,asset:n.asset,recipient:n.recipient,amount:s},currentPayment:{type:"exchange",exchangeId:t},source:"fund-from-exchange",headless:!1}}),r}catch(s){throw s instanceof Error&&s.message.includes("is not supported")?new Error("Asset not supported"):new Error(s.message)}},async handlePayWithExchange(t){var n;try{const s=(n=l.getAccountData())==null?void 0:n.address;if(!s)throw new Error("No account connected");if(!e.paymentAsset)throw new Error("No payment asset selected");const r=E.returnOpenHref("","popupWindow","scrollbar=yes,width=480,height=720");if(!r)throw new Error("Could not create popup window");e.isPaymentInProgress=!0,e.paymentId=crypto.randomUUID(),e.currentPayment={type:"exchange",exchangeId:t};const{network:a,asset:u}=e.paymentAsset,i={network:a,asset:u,amount:e.tokenAmount,recipient:s},c=await m.getPayUrl(t,i);if(!c){try{r.close()}catch(o){console.error("Unable to close popup window",o)}throw new Error("Unable to initiate payment")}e.currentPayment.sessionId=c.sessionId,e.currentPayment.status="IN_PROGRESS",e.currentPayment.exchangeId=t,r.location.href=c.url}catch{e.error="Unable to initiate payment",A.showError(e.error)}},async waitUntilComplete({exchangeId:t,sessionId:n,paymentId:s,retries:r=20}){const a=await m.getBuyStatus(t,n,s);if(a.status==="SUCCESS"||a.status==="FAILED")return a;if(r===0)throw new Error("Unable to get deposit status");return await new Promise(u=>{setTimeout(u,5e3)}),m.waitUntilComplete({exchangeId:t,sessionId:n,paymentId:s,retries:r-1})},async getBuyStatus(t,n,s){var r,a,u,i,c;try{if(!e.currentPayment)throw new Error("No current payment");const o=await U({sessionId:n,exchangeId:t});if(e.currentPayment.status=o.status,o.status==="SUCCESS"||o.status==="FAILED"){const p=(r=l.getAccountData())==null?void 0:r.address;e.currentPayment.result=o.txHash,e.isPaymentInProgress=!1,w.sendEvent({type:"track",event:o.status==="SUCCESS"?"PAY_SUCCESS":"PAY_ERROR",properties:{message:o.status==="FAILED"?E.parseError(e.error):void 0,source:"fund-from-exchange",paymentId:s,configuration:{network:((a=e.paymentAsset)==null?void 0:a.network)||"",asset:((u=e.paymentAsset)==null?void 0:u.asset)||"",recipient:p||"",amount:e.amount??0},currentPayment:{type:"exchange",exchangeId:(i=e.currentPayment)==null?void 0:i.exchangeId,sessionId:(c=e.currentPayment)==null?void 0:c.sessionId,result:o.txHash}}})}return o}catch{return{status:"UNKNOWN",txHash:""}}},reset(){e.currentPayment=void 0,e.isPaymentInProgress=!1,e.paymentId="",e.paymentAsset=null,e.amount=0,e.tokenAmount=0,e.priceLoading=!1,e.error=null,e.exchanges=[],e.isLoading=!1}};export{m as E};
1
+ import{p as k,g as U,C as l,E as w,a as E,S as A,b as x,f as P,c as N,d as I,O as L,N as f,e as C,B as T,h as W,s as _,i as v}from"./index-TpT45Yhr.js";const D=0,b={paymentAsset:null,amount:null,tokenAmount:0,priceLoading:!1,error:null,exchanges:[],isLoading:!1,currentPayment:void 0,isPaymentInProgress:!1,paymentId:"",assets:[]},e=k(b),m={state:e,subscribe(t){return v(e,()=>t(e))},subscribeKey(t,n){return _(e,t,n)},resetState(){Object.assign(e,{...b})},async getAssetsForNetwork(t){const n=W(t),s=await m.getAssetsImageAndPrice(n),r=n.map(a=>{var c,o,p,y;const u=a.asset==="native"?C():`${a.network}:${a.asset}`,i=s.find(S=>{var g,d,h;return((h=(d=(g=S.fungibles)==null?void 0:g[0])==null?void 0:d.address)==null?void 0:h.toLowerCase())===u.toLowerCase()});return{...a,price:((o=(c=i==null?void 0:i.fungibles)==null?void 0:c[0])==null?void 0:o.price)||1,metadata:{...a.metadata,iconUrl:(y=(p=i==null?void 0:i.fungibles)==null?void 0:p[0])==null?void 0:y.iconUrl}}});return e.assets=r,r},async getAssetsImageAndPrice(t){const n=t.map(r=>r.asset==="native"?C():`${r.network}:${r.asset}`);return await Promise.all(n.map(r=>T.fetchTokenPrice({addresses:[r]})))},getTokenAmount(){var s;if(!((s=e==null?void 0:e.paymentAsset)!=null&&s.price))throw new Error("Cannot get token price");const t=f.bigNumber(e.amount??0).round(8),n=f.bigNumber(e.paymentAsset.price).round(8);return t.div(n).round(8).toNumber()},setAmount(t){var n;e.amount=t,(n=e.paymentAsset)!=null&&n.price&&(e.tokenAmount=m.getTokenAmount())},setPaymentAsset(t){e.paymentAsset=t},isPayWithExchangeEnabled(){var t;return(t=L.state.remoteFeatures)==null?void 0:t.payWithExchange},isPayWithExchangeSupported(){return m.isPayWithExchangeEnabled()&&l.state.activeCaipNetwork&&I.PAY_WITH_EXCHANGE_SUPPORTED_CHAIN_NAMESPACES.includes(l.state.activeCaipNetwork.chainNamespace)},async fetchExchanges(){var t;try{const n=m.isPayWithExchangeSupported();if(!e.paymentAsset||!n){e.exchanges=[],e.isLoading=!1;return}e.isLoading=!0;const s=await N({page:D,asset:P(e.paymentAsset.network,e.paymentAsset.asset),amount:((t=e.amount)==null?void 0:t.toString())??"0"});e.exchanges=s.exchanges.slice(0,2)}catch{throw A.showError("Unable to get exchanges"),new Error("Unable to get exchanges")}finally{e.isLoading=!1}},async getPayUrl(t,n){try{const s=Number(n.amount),r=await x({exchangeId:t,asset:P(n.network,n.asset),amount:s.toString(),recipient:`${n.network}:${n.recipient}`});return w.sendEvent({type:"track",event:"PAY_EXCHANGE_SELECTED",properties:{exchange:{id:t},configuration:{network:n.network,asset:n.asset,recipient:n.recipient,amount:s},currentPayment:{type:"exchange",exchangeId:t},source:"fund-from-exchange",headless:!1}}),r}catch(s){throw s instanceof Error&&s.message.includes("is not supported")?new Error("Asset not supported"):new Error(s.message)}},async handlePayWithExchange(t){var n;try{const s=(n=l.getAccountData())==null?void 0:n.address;if(!s)throw new Error("No account connected");if(!e.paymentAsset)throw new Error("No payment asset selected");const r=E.returnOpenHref("","popupWindow","scrollbar=yes,width=480,height=720");if(!r)throw new Error("Could not create popup window");e.isPaymentInProgress=!0,e.paymentId=crypto.randomUUID(),e.currentPayment={type:"exchange",exchangeId:t};const{network:a,asset:u}=e.paymentAsset,i={network:a,asset:u,amount:e.tokenAmount,recipient:s},c=await m.getPayUrl(t,i);if(!c){try{r.close()}catch(o){console.error("Unable to close popup window",o)}throw new Error("Unable to initiate payment")}e.currentPayment.sessionId=c.sessionId,e.currentPayment.status="IN_PROGRESS",e.currentPayment.exchangeId=t,r.location.href=c.url}catch{e.error="Unable to initiate payment",A.showError(e.error)}},async waitUntilComplete({exchangeId:t,sessionId:n,paymentId:s,retries:r=20}){const a=await m.getBuyStatus(t,n,s);if(a.status==="SUCCESS"||a.status==="FAILED")return a;if(r===0)throw new Error("Unable to get deposit status");return await new Promise(u=>{setTimeout(u,5e3)}),m.waitUntilComplete({exchangeId:t,sessionId:n,paymentId:s,retries:r-1})},async getBuyStatus(t,n,s){var r,a,u,i,c;try{if(!e.currentPayment)throw new Error("No current payment");const o=await U({sessionId:n,exchangeId:t});if(e.currentPayment.status=o.status,o.status==="SUCCESS"||o.status==="FAILED"){const p=(r=l.getAccountData())==null?void 0:r.address;e.currentPayment.result=o.txHash,e.isPaymentInProgress=!1,w.sendEvent({type:"track",event:o.status==="SUCCESS"?"PAY_SUCCESS":"PAY_ERROR",properties:{message:o.status==="FAILED"?E.parseError(e.error):void 0,source:"fund-from-exchange",paymentId:s,configuration:{network:((a=e.paymentAsset)==null?void 0:a.network)||"",asset:((u=e.paymentAsset)==null?void 0:u.asset)||"",recipient:p||"",amount:e.amount??0},currentPayment:{type:"exchange",exchangeId:(i=e.currentPayment)==null?void 0:i.exchangeId,sessionId:(c=e.currentPayment)==null?void 0:c.sessionId,result:o.txHash}}})}return o}catch{return{status:"UNKNOWN",txHash:""}}},reset(){e.currentPayment=void 0,e.isPaymentInProgress=!1,e.paymentId="",e.paymentAsset=null,e.amount=0,e.tokenAmount=0,e.priceLoading=!1,e.error=null,e.exchanges=[],e.isLoading=!1}};export{m as E};
@@ -1,4 +1,4 @@
1
- import{j as f,r as g,l as p,m as h,R as v,O as u}from"./index-rAbloVh4.js";import{n as m,c as $}from"./index-B8gDkzKR.js";import{C as c}from"./ConstantsUtil-Dl5WOfjM.js";import{C as y}from"./NetworkUtil-CORVq-U7.js";const b=f`
1
+ import{j as f,r as g,l as p,m as h,R as v,O as u}from"./index-TpT45Yhr.js";import{n as m,c as $}from"./index-yvAPBrdI.js";import{C as c}from"./ConstantsUtil-g0AjdkOa.js";import{C as y}from"./NetworkUtil-BooKnyFI.js";const b=f`
2
2
  :host {
3
3
  display: flex;
4
4
  justify-content: center;
@@ -0,0 +1 @@
1
+ import{r as y,k as n}from"./index-B6-Xobl2.js";import{u as I,q as d,M as S,I as z,r as A,t as v,S as B,w as U,T as W,x as T,y as C,z as O,A as P,L as b,O as q,E as H,W as M,G as D,H as E}from"./ThirdwebWalletManager-BUJ2S4b0.js";import"./oauth-CbK0gPlt.js";import"./types-DFEAKZ3L.js";import"./send-transaction-B0F9brDJ.js";import"./to-serializable-transaction-DAYFWHyO.js";import"./is-smart-wallet-kSShE3hl.js";import"./get-bytecode-FPC_G1PK.js";import"./index-DO01SzHY.js";import"./utils-BtpzmIxp.js";import"./wait-for-tx-receipt-CuLnfaKm.js";import"./sleep-mAKpSMLY.js";import"./TypedData-ByTQ7nLR.js";import"./Address-BHGD07NO.js";import"./Solidity-D6b-SCK0.js";import"./parse-typed-data-BSOEUDy_.js";import"./Authorization-DmoiysGx.js";import"./store-CraP4F4Y.js";import"./addresses-DVWfx5EX.js";import"./read-contract-D8CQ_i-D.js";import"./decimals-BkxTCZnw.js";import"./passkeys-tlSlZIRR.js";import"./webauthn.min-CGpVStYZ.js";import"./arweave-CAGvOb64.js";import"./index.es-BdGfQ9jz.js";function F(e){var l,g,s,L,u,x,h,f,k,w,j;const o=e.size==="compact",{initialScreen:c,screen:i}=I(),[m,t]=y.useState(!1),r=i===e.wallet&&c===e.wallet,a=r&&!e.isLinking?void 0:e.goBack;return n.jsxs(d,{animate:"fadein",flex:"column",fullHeight:!0,p:"lg",style:{minHeight:"250px"},children:[o&&(r?n.jsxs(n.Fragment,{children:[n.jsx(S,{leftAligned:!e.isLinking,onBack:a,title:n.jsxs(n.Fragment,{children:[(l=e.meta)!=null&&l.titleIconUrl?n.jsx(z,{client:e.client,height:A.md,src:(g=e.meta)==null?void 0:g.titleIconUrl,width:A.md}):null,n.jsx(v,{children:((s=e.meta)==null?void 0:s.title)??e.inAppWalletLocale.emailLoginScreen.title})]})}),n.jsx(B,{y:"lg"})]}):n.jsx(S,{onBack:a,title:e.inAppWalletLocale.signIn})),n.jsx(d,{center:"y",expand:!0,flex:"column",p:o?void 0:"lg",children:n.jsx(U,{...e,disabled:((L=e.meta)==null?void 0:L.requireApproval)&&!m,locale:e.inAppWalletLocale})}),o&&(((u=e.meta)==null?void 0:u.showThirdwebBranding)!==!1||((x=e.meta)==null?void 0:x.termsOfServiceUrl)||((h=e.meta)==null?void 0:h.privacyPolicyUrl))&&n.jsx(B,{y:"xl"}),n.jsxs(d,{flex:"column",gap:"lg",children:[n.jsx(W,{isApproved:m,locale:e.connectLocale.agreement,onApprove:()=>{t(!m)},privacyPolicyUrl:(f=e.meta)==null?void 0:f.privacyPolicyUrl,requireApproval:(k=e.meta)==null?void 0:k.requireApproval,termsOfServiceUrl:(w=e.meta)==null?void 0:w.termsOfServiceUrl}),((j=e.meta)==null?void 0:j.showThirdwebBranding)!==!1&&n.jsx(T,{})]})]})}function de(e){const o=C(),c=O(),i=o,m=e.connectLocale.id,t=P(m),{initialScreen:r}=I();if(!t)return n.jsx(b,{});const a=()=>{var s;r===e.wallet?c({}):((s=e.goBack)==null||s.call(e),c({}))},l=()=>{e.done(),c({})},g=i!=null&&i.emailLogin?{email:i.emailLogin}:i!=null&&i.phoneLogin?{phone:i.phoneLogin}:void 0;return g?n.jsx(q,{chain:e.chain,client:e.client,done:l,goBack:a,isLinking:e.isLinking,locale:t,size:e.size,userInfo:g,wallet:e.wallet}):i!=null&&i.passkeyLogin?n.jsx(H,{chain:e.chain,client:e.client,done:l,isLinking:e.isLinking,locale:e.connectLocale,onBack:a,size:e.size,wallet:e.wallet}):i!=null&&i.walletLogin?n.jsx(M,{chain:e.chain,client:e.client,done:l,inAppLocale:t,isLinking:i.walletLogin.linking,locale:e.connectLocale,meta:e.meta,onBack:a||(()=>c({})),size:e.size,wallet:e.wallet,walletConnect:e.walletConnect}):i!=null&&i.socialLogin?n.jsx(D,{chain:e.chain,client:e.client,connectLocale:e.connectLocale,done:l,goBack:a,isLinking:e.isLinking,locale:t,size:e.size,socialAuth:i.socialLogin.type,state:i,wallet:e.wallet}):i!=null&&i.guestLogin?n.jsx(E,{client:e.client,connectLocale:e.connectLocale,done:l,goBack:a,locale:t,size:e.size,state:i,wallet:e.wallet}):n.jsx(F,{chain:e.chain,client:e.client,connectLocale:e.connectLocale,done:l,goBack:e.goBack,inAppWalletLocale:t,isLinking:e.isLinking,meta:e.meta,select:()=>{},size:e.size,wallet:e.wallet})}export{de as default};
@@ -1,4 +1,4 @@
1
- import{c as Ee,H as Ne,a as Z,u as we,b as ee,d as te,t as ve,e as re,f as Oe,g as ue,r as Te,h as xe,i as Ae,j as Me,k as Re}from"./hmac-Bk4Z90TB.js";import{b as ne}from"./index-Fv-acDXO.js";const ce="2.43.5";let g={getDocsUrl:({docsBaseUrl:r,docsPath:e="",docsSlug:t})=>e?`${r??"https://viem.sh"}${e}${t?`#${t}`:""}`:void 0,version:`viem@${ce}`};class u extends Error{constructor(e,t={}){var i;const n=(()=>{var l;return t.cause instanceof u?t.cause.details:(l=t.cause)!=null&&l.message?t.cause.message:t.details})(),s=t.cause instanceof u&&t.cause.docsPath||t.docsPath,a=(i=g.getDocsUrl)==null?void 0:i.call(g,{...t,docsPath:s}),o=[e||"An error occurred.","",...t.metaMessages?[...t.metaMessages,""]:[],...a?[`Docs: ${a}`]:[],...n?[`Details: ${n}`]:[],...g.version?[`Version: ${g.version}`]:[]].join(`
1
+ import{c as Ee,H as Ne,a as Z,u as we,b as ee,d as te,t as ve,e as re,f as Oe,g as ue,r as Te,h as xe,i as Ae,j as Me,k as Re}from"./hmac-Bk4Z90TB.js";import{b as ne}from"./index-B6-Xobl2.js";const ce="2.43.5";let g={getDocsUrl:({docsBaseUrl:r,docsPath:e="",docsSlug:t})=>e?`${r??"https://viem.sh"}${e}${t?`#${t}`:""}`:void 0,version:`viem@${ce}`};class u extends Error{constructor(e,t={}){var i;const n=(()=>{var l;return t.cause instanceof u?t.cause.details:(l=t.cause)!=null&&l.message?t.cause.message:t.details})(),s=t.cause instanceof u&&t.cause.docsPath||t.docsPath,a=(i=g.getDocsUrl)==null?void 0:i.call(g,{...t,docsPath:s}),o=[e||"An error occurred.","",...t.metaMessages?[...t.metaMessages,""]:[],...a?[`Docs: ${a}`]:[],...n?[`Details: ${n}`]:[],...g.version?[`Version: ${g.version}`]:[]].join(`
2
2
  `);super(o,t.cause?{cause:t.cause}:void 0),Object.defineProperty(this,"details",{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,"metaMessages",{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,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=n,this.docsPath=s,this.metaMessages=t.metaMessages,this.name=t.name??this.name,this.shortMessage=e,this.version=ce}walk(e){return le(this,e)}}function le(r,e){return e!=null&&e(r)?r:r&&typeof r=="object"&&"cause"in r&&r.cause!==void 0?le(r.cause,e):e?null:r}class Ce extends u{constructor({max:e,min:t,signed:n,size:s,value:a}){super(`Number "${a}" is not in safe ${s?`${s*8}-bit ${n?"signed":"unsigned"} `:""}integer range ${e?`(${t} to ${e})`:`(above ${t})`}`,{name:"IntegerOutOfRangeError"})}}class ht extends u{constructor(e){super(`Bytes value "${e}" is not a valid boolean. The bytes array must contain a single byte of either a 0 or 1 value.`,{name:"InvalidBytesBooleanError"})}}class Pe extends u{constructor(e){super(`Hex value "${e}" is not a valid boolean. The hex value must be "0x0" (false) or "0x1" (true).`,{name:"InvalidHexBooleanError"})}}class Se extends u{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed ${t} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}}function Ie(r,{strict:e=!0}={}){return!r||typeof r!="string"?!1:e?/^0x[0-9a-fA-F]*$/.test(r):r.startsWith("0x")}function se(r){return Ie(r,{strict:!1})?Math.ceil((r.length-2)/2):r.length}function v(r,{dir:e="left"}={}){let t=typeof r=="string"?r.replace("0x",""):r,n=0;for(let s=0;s<t.length-1&&t[e==="left"?s:t.length-s-1].toString()==="0";s++)n++;return t=e==="left"?t.slice(n):t.slice(0,t.length-n),typeof r=="string"?(t.length===1&&e==="right"&&(t=`${t}0`),`0x${t.length%2===1?`0${t}`:t}`):t}class mt extends u{constructor({offset:e,position:t,size:n}){super(`Slice ${t==="start"?"starting":"ending"} at offset "${e}" is out-of-bounds (size: ${n}).`,{name:"SliceOffsetOutOfBoundsError"})}}class de extends u{constructor({size:e,targetSize:t,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (${e}) exceeds padding size (${t}).`,{name:"SizeExceedsPaddingSizeError"})}}class yt extends u{constructor({size:e,targetSize:t,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} is expected to be ${t} ${n} long, but is ${e} ${n} long.`,{name:"InvalidBytesLengthError"})}}function T(r,{dir:e,size:t=32}={}){return typeof r=="string"?_e(r,{dir:e,size:t}):$e(r,{dir:e,size:t})}function _e(r,{dir:e,size:t=32}={}){if(t===null)return r;const n=r.replace("0x","");if(n.length>t*2)throw new de({size:Math.ceil(n.length/2),targetSize:t,type:"hex"});return`0x${n[e==="right"?"padEnd":"padStart"](t*2,"0")}`}function $e(r,{dir:e,size:t=32}={}){if(t===null)return r;if(r.length>t)throw new de({size:r.length,targetSize:t,type:"bytes"});const n=new Uint8Array(t);for(let s=0;s<t;s++){const a=e==="right";n[a?s:t-s-1]=r[a?s:r.length-s-1]}return n}const Le=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function gt(r,e={}){return typeof r=="number"||typeof r=="bigint"?Ue(r,e):typeof r=="string"?Be(r,e):typeof r=="boolean"?je(r,e):pe(r,e)}function je(r,e={}){const t=`0x${Number(r)}`;return typeof e.size=="number"?(w(t,{size:e.size}),T(t,{size:e.size})):t}function pe(r,e={}){let t="";for(let s=0;s<r.length;s++)t+=Le[r[s]];const n=`0x${t}`;return typeof e.size=="number"?(w(n,{size:e.size}),T(n,{dir:"right",size:e.size})):n}function Ue(r,e={}){const{signed:t,size:n}=e,s=BigInt(r);let a;n?t?a=(1n<<BigInt(n)*8n-1n)-1n:a=2n**(BigInt(n)*8n)-1n:typeof r=="number"&&(a=BigInt(Number.MAX_SAFE_INTEGER));const o=typeof a=="bigint"&&t?-a-1n:0;if(a&&s>a||s<o){const l=typeof r=="bigint"?"n":"";throw new Ce({max:a?`${a}${l}`:void 0,min:`${o}${l}`,signed:t,size:n,value:`${r}${l}`})}const i=`0x${(t&&s<0?(1n<<BigInt(n*8))+BigInt(s):s).toString(16)}`;return n?T(i,{size:n}):i}const ke=new TextEncoder;function Be(r,e={}){const t=ke.encode(r);return pe(t,e)}function w(r,{size:e}){if(se(r)>e)throw new Se({givenSize:se(r),maxSize:e})}function De(r,e={}){const{signed:t}=e;e.size&&w(r,{size:e.size});const n=BigInt(r);if(!t)return n;const s=(r.length-2)/2,a=(1n<<BigInt(s)*8n-1n)-1n;return n<=a?n:n-BigInt(`0x${"f".padStart(s*2,"f")}`)-1n}function Et(r,e={}){let t=r;if(e.size&&(w(t,{size:e.size}),t=v(t)),v(t)==="0x00")return!1;if(v(t)==="0x01")return!0;throw new Pe(t)}function Nt(r,e={}){return Number(De(r,e))}const wt={gwei:9,wei:18},He={ether:-9,wei:9};function Fe(r,e){let t=r.toString();const n=t.startsWith("-");n&&(t=t.slice(1)),t=t.padStart(e,"0");let[s,a]=[t.slice(0,t.length-e),t.slice(t.length-e)];return a=a.replace(/(0+)$/,""),`${n?"-":""}${s||"0"}${a?`.${a}`:""}`}function N(r,e="wei"){return Fe(r,He[e])}class be extends u{constructor({cause:e,message:t}={}){var s;const n=(s=t==null?void 0:t.replace("execution reverted: ",""))==null?void 0:s.replace("execution reverted","");super(`Execution reverted ${n?`with reason: ${n}`:"for an unknown reason"}.`,{cause:e,name:"ExecutionRevertedError"})}}Object.defineProperty(be,"code",{enumerable:!0,configurable:!0,writable:!0,value:3});Object.defineProperty(be,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/execution reverted|gas required exceeds allowance/});class ze extends u{constructor({cause:e,maxFeePerGas:t}={}){super(`The fee cap (\`maxFeePerGas\`${t?` = ${N(t)} gwei`:""}) cannot be higher than the maximum allowed value (2^256-1).`,{cause:e,name:"FeeCapTooHighError"})}}Object.defineProperty(ze,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max fee per gas higher than 2\^256-1|fee cap higher than 2\^256-1/});class We extends u{constructor({cause:e,maxFeePerGas:t}={}){super(`The fee cap (\`maxFeePerGas\`${t?` = ${N(t)}`:""} gwei) cannot be lower than the block base fee.`,{cause:e,name:"FeeCapTooLowError"})}}Object.defineProperty(We,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max fee per gas less than block base fee|fee cap less than block base fee|transaction is outdated/});class qe extends u{constructor({cause:e,nonce:t}={}){super(`Nonce provided for the transaction ${t?`(${t}) `:""}is higher than the next one expected.`,{cause:e,name:"NonceTooHighError"})}}Object.defineProperty(qe,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too high/});class Ke extends u{constructor({cause:e,nonce:t}={}){super([`Nonce provided for the transaction ${t?`(${t}) `:""}is lower than the current nonce of the account.`,"Try increasing the nonce or find the latest nonce with `getTransactionCount`."].join(`
3
3
  `),{cause:e,name:"NonceTooLowError"})}}Object.defineProperty(Ke,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too low|transaction already imported|already known/});class Ve extends u{constructor({cause:e,nonce:t}={}){super(`Nonce provided for the transaction ${t?`(${t}) `:""}exceeds the maximum allowed nonce.`,{cause:e,name:"NonceMaxValueError"})}}Object.defineProperty(Ve,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce has max value/});class Ge extends u{constructor({cause:e}={}){super(["The total cost (gas * gas fee + value) of executing this transaction exceeds the balance of the account."].join(`
4
4
  `),{cause:e,metaMessages:["This error could arise when the account does not have enough funds to:"," - pay for the total gas fee,"," - pay for the value to send."," ","The cost of the transaction is calculated as `gas * gas fee + value`, where:"," - `gas` is the amount of gas needed for transaction to execute,"," - `gas fee` is the gas fee,"," - `value` is the amount of ether to send to the recipient."],name:"InsufficientFundsError"})}}Object.defineProperty(Ge,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/insufficient funds|exceeds transaction sender account balance/});class Xe extends u{constructor({cause:e,gas:t}={}){super(`The amount of gas ${t?`(${t}) `:""}provided for the transaction exceeds the limit allowed for the block.`,{cause:e,name:"IntrinsicGasTooHighError"})}}Object.defineProperty(Xe,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too high|gas limit reached/});class Ye extends u{constructor({cause:e,gas:t}={}){super(`The amount of gas ${t?`(${t}) `:""}provided for the transaction is too low.`,{cause:e,name:"IntrinsicGasTooLowError"})}}Object.defineProperty(Ye,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too low/});class Je extends u{constructor({cause:e}){super("The transaction type is not supported for this chain.",{cause:e,name:"TransactionTypeNotSupportedError"})}}Object.defineProperty(Je,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/transaction type not valid/});class Qe extends u{constructor({cause:e,maxPriorityFeePerGas:t,maxFeePerGas:n}={}){super([`The provided tip (\`maxPriorityFeePerGas\`${t?` = ${N(t)} gwei`:""}) cannot be higher than the fee cap (\`maxFeePerGas\`${n?` = ${N(n)} gwei`:""}).`].join(`
@@ -1 +1 @@
1
- import{r as j,j as E}from"./index-Fv-acDXO.js";var P=(s=>(s[s.Border=-1]="Border",s[s.Data=0]="Data",s[s.Function=1]="Function",s[s.Position=2]="Position",s[s.Timing=3]="Timing",s[s.Alignment=4]="Alignment",s))(P||{}),q=Object.defineProperty,X=(s,t,e)=>t in s?q(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e,z=(s,t,e)=>(X(s,typeof t!="symbol"?t+"":t,e),e);const G=[0,1],S=[1,0],O=[2,3],L=[3,2],H={L:G,M:S,Q:O,H:L},K=/^[0-9]*$/,W=/^[A-Z0-9 $%*+.\/:-]*$/,_="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:",v=1,B=40,k=3,Z=3,R=40,J=10,U=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],$=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]];class Q{constructor(t,e,n,r){if(this.version=t,this.ecc=e,z(this,"size"),z(this,"mask"),z(this,"modules",[]),z(this,"types",[]),t<v||t>B)throw new RangeError("Version value out of range");if(r<-1||r>7)throw new RangeError("Mask value out of range");this.size=t*4+17;const o=Array.from({length:this.size},()=>!1);for(let l=0;l<this.size;l++)this.modules.push(o.slice()),this.types.push(o.map(()=>0));this.drawFunctionPatterns();const i=this.addEccAndInterleave(n);if(this.drawCodewords(i),r===-1){let l=1e9;for(let c=0;c<8;c++){this.applyMask(c),this.drawFormatBits(c);const h=this.getPenaltyScore();h<l&&(r=c,l=h),this.applyMask(c)}}this.mask=r,this.applyMask(r),this.drawFormatBits(r)}getModule(t,e){return t>=0&&t<this.size&&e>=0&&e<this.size&&this.modules[e][t]}drawFunctionPatterns(){for(let n=0;n<this.size;n++)this.setFunctionModule(6,n,n%2===0,P.Timing),this.setFunctionModule(n,6,n%2===0,P.Timing);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const t=this.getAlignmentPatternPositions(),e=t.length;for(let n=0;n<e;n++)for(let r=0;r<e;r++)n===0&&r===0||n===0&&r===e-1||n===e-1&&r===0||this.drawAlignmentPattern(t[n],t[r]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(t){const e=this.ecc[1]<<3|t;let n=e;for(let o=0;o<10;o++)n=n<<1^(n>>>9)*1335;const r=(e<<10|n)^21522;for(let o=0;o<=5;o++)this.setFunctionModule(8,o,y(r,o));this.setFunctionModule(8,7,y(r,6)),this.setFunctionModule(8,8,y(r,7)),this.setFunctionModule(7,8,y(r,8));for(let o=9;o<15;o++)this.setFunctionModule(14-o,8,y(r,o));for(let o=0;o<8;o++)this.setFunctionModule(this.size-1-o,8,y(r,o));for(let o=8;o<15;o++)this.setFunctionModule(8,this.size-15+o,y(r,o));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let t=this.version;for(let n=0;n<12;n++)t=t<<1^(t>>>11)*7973;const e=this.version<<12|t;for(let n=0;n<18;n++){const r=y(e,n),o=this.size-11+n%3,i=Math.floor(n/3);this.setFunctionModule(o,i,r),this.setFunctionModule(i,o,r)}}drawFinderPattern(t,e){for(let n=-4;n<=4;n++)for(let r=-4;r<=4;r++){const o=Math.max(Math.abs(r),Math.abs(n)),i=t+r,l=e+n;i>=0&&i<this.size&&l>=0&&l<this.size&&this.setFunctionModule(i,l,o!==2&&o!==4,P.Position)}}drawAlignmentPattern(t,e){for(let n=-2;n<=2;n++)for(let r=-2;r<=2;r++)this.setFunctionModule(t+r,e+n,Math.max(Math.abs(r),Math.abs(n))!==1,P.Alignment)}setFunctionModule(t,e,n,r=P.Function){this.modules[e][t]=n,this.types[e][t]=r}addEccAndInterleave(t){const e=this.version,n=this.ecc;if(t.length!==F(e,n))throw new RangeError("Invalid argument");const r=$[n[0]][e],o=U[n[0]][e],i=Math.floor(C(e)/8),l=r-i%r,c=Math.floor(i/r),h=[],f=at(o);for(let u=0,m=0;u<r;u++){const M=t.slice(m,m+c-o+(u<l?0:1));m+=M.length;const p=ct(M,f);u<l&&M.push(0),h.push(M.concat(p))}const a=[];for(let u=0;u<h[0].length;u++)h.forEach((m,M)=>{(u!==c-o||M>=l)&&a.push(m[u])});return a}drawCodewords(t){if(t.length!==Math.floor(C(this.version)/8))throw new RangeError("Invalid argument");let e=0;for(let n=this.size-1;n>=1;n-=2){n===6&&(n=5);for(let r=0;r<this.size;r++)for(let o=0;o<2;o++){const i=n-o,c=(n+1&2)===0?this.size-1-r:r;!this.types[c][i]&&e<t.length*8&&(this.modules[c][i]=y(t[e>>>3],7-(e&7)),e++)}}}applyMask(t){if(t<0||t>7)throw new RangeError("Mask value out of range");for(let e=0;e<this.size;e++)for(let n=0;n<this.size;n++){let r;switch(t){case 0:r=(n+e)%2===0;break;case 1:r=e%2===0;break;case 2:r=n%3===0;break;case 3:r=(n+e)%3===0;break;case 4:r=(Math.floor(n/3)+Math.floor(e/2))%2===0;break;case 5:r=n*e%2+n*e%3===0;break;case 6:r=(n*e%2+n*e%3)%2===0;break;case 7:r=((n+e)%2+n*e%3)%2===0;break;default:throw new Error("Unreachable")}!this.types[e][n]&&r&&(this.modules[e][n]=!this.modules[e][n])}}getPenaltyScore(){let t=0;for(let o=0;o<this.size;o++){let i=!1,l=0;const c=[0,0,0,0,0,0,0];for(let h=0;h<this.size;h++)this.modules[o][h]===i?(l++,l===5?t+=k:l>5&&t++):(this.finderPenaltyAddHistory(l,c),i||(t+=this.finderPenaltyCountPatterns(c)*R),i=this.modules[o][h],l=1);t+=this.finderPenaltyTerminateAndCount(i,l,c)*R}for(let o=0;o<this.size;o++){let i=!1,l=0;const c=[0,0,0,0,0,0,0];for(let h=0;h<this.size;h++)this.modules[h][o]===i?(l++,l===5?t+=k:l>5&&t++):(this.finderPenaltyAddHistory(l,c),i||(t+=this.finderPenaltyCountPatterns(c)*R),i=this.modules[h][o],l=1);t+=this.finderPenaltyTerminateAndCount(i,l,c)*R}for(let o=0;o<this.size-1;o++)for(let i=0;i<this.size-1;i++){const l=this.modules[o][i];l===this.modules[o][i+1]&&l===this.modules[o+1][i]&&l===this.modules[o+1][i+1]&&(t+=Z)}let e=0;for(const o of this.modules)e=o.reduce((i,l)=>i+(l?1:0),e);const n=this.size*this.size,r=Math.ceil(Math.abs(e*20-n*10)/n)-1;return t+=r*J,t}getAlignmentPatternPositions(){if(this.version===1)return[];{const t=Math.floor(this.version/7)+2,e=this.version===32?26:Math.ceil((this.version*4+4)/(t*2-2))*2,n=[6];for(let r=this.size-7;n.length<t;r-=e)n.splice(1,0,r);return n}}finderPenaltyCountPatterns(t){const e=t[1],n=e>0&&t[2]===e&&t[3]===e*3&&t[4]===e&&t[5]===e;return(n&&t[0]>=e*4&&t[6]>=e?1:0)+(n&&t[6]>=e*4&&t[0]>=e?1:0)}finderPenaltyTerminateAndCount(t,e,n){return t&&(this.finderPenaltyAddHistory(e,n),e=0),e+=this.size,this.finderPenaltyAddHistory(e,n),this.finderPenaltyCountPatterns(n)}finderPenaltyAddHistory(t,e){e[0]===0&&(t+=this.size),e.pop(),e.unshift(t)}}function A(s,t,e){if(t<0||t>31||s>>>t)throw new RangeError("Value out of range");for(let n=t-1;n>=0;n--)e.push(s>>>n&1)}function y(s,t){return(s>>>t&1)!==0}class I{constructor(t,e,n){if(this.mode=t,this.numChars=e,this.bitData=n,e<0)throw new RangeError("Invalid argument");this.bitData=n.slice()}getData(){return this.bitData.slice()}}const tt=[1,10,12,14],et=[2,9,11,13],nt=[4,8,16,16];function D(s,t){return s[Math.floor((t+7)/17)+1]}function T(s){const t=[];for(const e of s)A(e,8,t);return new I(nt,s.length,t)}function st(s){if(!Y(s))throw new RangeError("String contains non-numeric characters");const t=[];for(let e=0;e<s.length;){const n=Math.min(s.length-e,3);A(Number.parseInt(s.substring(e,e+n),10),n*3+1,t),e+=n}return new I(tt,s.length,t)}function rt(s){if(!V(s))throw new RangeError("String contains unencodable characters in alphanumeric mode");const t=[];let e;for(e=0;e+2<=s.length;e+=2){let n=_.indexOf(s.charAt(e))*45;n+=_.indexOf(s.charAt(e+1)),A(n,11,t)}return e<s.length&&A(_.indexOf(s.charAt(e)),6,t),new I(et,s.length,t)}function ot(s){return s===""?[]:Y(s)?[st(s)]:V(s)?[rt(s)]:[T(lt(s))]}function Y(s){return K.test(s)}function V(s){return W.test(s)}function it(s,t){let e=0;for(const n of s){const r=D(n.mode,t);if(n.numChars>=1<<r)return Number.POSITIVE_INFINITY;e+=4+r+n.bitData.length}return e}function lt(s){s=encodeURI(s);const t=[];for(let e=0;e<s.length;e++)s.charAt(e)!=="%"?t.push(s.charCodeAt(e)):(t.push(Number.parseInt(s.substring(e+1,e+3),16)),e+=2);return t}function C(s){if(s<v||s>B)throw new RangeError("Version number out of range");let t=(16*s+128)*s+64;if(s>=2){const e=Math.floor(s/7)+2;t-=(25*e-10)*e-55,s>=7&&(t-=36)}return t}function F(s,t){return Math.floor(C(s)/8)-U[t[0]][s]*$[t[0]][s]}function at(s){if(s<1||s>255)throw new RangeError("Degree out of range");const t=[];for(let n=0;n<s-1;n++)t.push(0);t.push(1);let e=1;for(let n=0;n<s;n++){for(let r=0;r<t.length;r++)t[r]=N(t[r],e),r+1<t.length&&(t[r]^=t[r+1]);e=N(e,2)}return t}function ct(s,t){const e=t.map(n=>0);for(const n of s){const r=n^e.shift();e.push(0),t.forEach((o,i)=>e[i]^=N(o,r))}return e}function N(s,t){if(s>>>8||t>>>8)throw new RangeError("Byte out of range");let e=0;for(let n=7;n>=0;n--)e=e<<1^(e>>>7)*285,e^=(t>>>n&1)*s;return e}function ht(s,t,e=1,n=40,r=-1,o=!0){if(!(v<=e&&e<=n&&n<=B)||r<-1||r>7)throw new RangeError("Invalid value");let i,l;for(i=e;;i++){const a=F(i,t)*8,u=it(s,i);if(u<=a){l=u;break}if(i>=n)throw new RangeError("Data too long")}for(const a of[S,O,L])o&&l<=F(i,a)*8&&(t=a);const c=[];for(const a of s){A(a.mode[0],4,c),A(a.numChars,D(a.mode,i),c);for(const u of a.getData())c.push(u)}const h=F(i,t)*8;A(0,Math.min(4,h-c.length),c),A(0,(8-c.length%8)%8,c);for(let a=236;c.length<h;a^=253)A(a,8,c);const f=Array.from({length:Math.ceil(c.length/8)},()=>0);return c.forEach((a,u)=>f[u>>>3]|=a<<7-(u&7)),new Q(i,t,f,r)}function ft(s,t){var a;const{ecc:e="L",boostEcc:n=!1,minVersion:r=1,maxVersion:o=40,maskPattern:i=-1,border:l=1}=t||{},c=typeof s=="string"?ot(s):Array.isArray(s)?[T(s)]:void 0;if(!c)throw new Error(`uqr only supports encoding string and binary data, but got: ${typeof s}`);const h=ht(c,H[e],r,o,i,n),f=ut({version:h.version,maskPattern:h.mask,size:h.size,data:h.modules,types:h.types},l);return t!=null&&t.invert&&(f.data=f.data.map(u=>u.map(m=>!m))),(a=t==null?void 0:t.onEncoded)==null||a.call(t,f),f}function ut(s,t=1){if(!t)return s;const{size:e}=s,n=e+t*2;s.size=n,s.data.forEach(o=>{for(let i=0;i<t;i++)o.unshift(!1),o.push(!1)});for(let o=0;o<t;o++)s.data.unshift(Array.from({length:n},i=>!1)),s.data.push(Array.from({length:n},i=>!1));const r=P.Border;s.types.forEach(o=>{for(let i=0;i<t;i++)o.unshift(r),o.push(r)});for(let o=0;o<t;o++)s.types.unshift(Array.from({length:n},i=>r)),s.types.push(Array.from({length:n},i=>r));return s}function gt({ecl:s="M",size:t=200,uri:e,clearSize:n=0,image:r,imageBackground:o="transparent"}){const i=n,l=t-10*2,c=j.useMemo(()=>{const h=[],f=ft(e,{border:0,ecc:s}).data,a=l/f.length,u=[{x:0,y:0},{x:1,y:0},{x:0,y:1}];for(const{x:b,y:g}of u){const x=(f.length-7)*a*b,w=(f.length-7)*a*g;for(let d=0;d<3;d++)h.push(E.jsx("rect",{fill:d%2!==0?"var(--ck-qr-background, var(--ck-body-background))":"var(--ck-qr-dot-color)",height:a*(7-d*2),rx:(d-2)*-5+(d===0?2:3),ry:(d-2)*-5+(d===0?2:3),width:a*(7-d*2),x:x+a*d,y:w+a*d},`${d}-${b}-${g}`))}if(r){const b=(f.length-7)*a*1,g=(f.length-7)*a*1;h.push(E.jsxs(E.Fragment,{children:[E.jsx("rect",{fill:o,height:a*(7-0*2),rx:-2*-5+2,ry:-2*-5+2,width:a*(7-0*2),x:b+a*0,y:g+a*0}),E.jsx("foreignObject",{height:a*(7-0*2),width:a*(7-0*2),x:b+a*0,y:g+a*0,children:E.jsx("div",{style:{borderRadius:-2*-5+2,overflow:"hidden"},children:r})})]}))}const m=Math.floor((i+25)/a),M=f.length/2-m/2,p=f.length/2+m/2-1;return f.forEach((b,g)=>{b.forEach((x,w)=>{var d;(d=f[g])!=null&&d[w]&&(g<7&&w<7||g>f.length-8&&w<7||g<7&&w>f.length-8||(r||!(g>M&&g<p&&w>M&&w<p))&&h.push(E.jsx("circle",{cx:g*a+a/2,cy:w*a+a/2,fill:"var(--ck-qr-dot-color)",r:a/3},`circle-${g}-${w}`)))})}),h},[s,r,o,i,l,e]);return E.jsxs("svg",{height:l,role:"presentation",style:{height:l,width:l},viewBox:`0 0 ${l} ${l}`,width:l,children:[E.jsx("rect",{fill:"transparent",height:l,width:l}),c]})}export{gt as default};
1
+ import{r as q,k as E}from"./index-B6-Xobl2.js";var P=(s=>(s[s.Border=-1]="Border",s[s.Data=0]="Data",s[s.Function=1]="Function",s[s.Position=2]="Position",s[s.Timing=3]="Timing",s[s.Alignment=4]="Alignment",s))(P||{}),j=Object.defineProperty,X=(s,t,e)=>t in s?j(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e,z=(s,t,e)=>(X(s,typeof t!="symbol"?t+"":t,e),e);const G=[0,1],S=[1,0],O=[2,3],L=[3,2],H={L:G,M:S,Q:O,H:L},K=/^[0-9]*$/,W=/^[A-Z0-9 $%*+.\/:-]*$/,_="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:",v=1,B=40,k=3,Z=3,R=40,J=10,U=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],$=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]];class Q{constructor(t,e,n,r){if(this.version=t,this.ecc=e,z(this,"size"),z(this,"mask"),z(this,"modules",[]),z(this,"types",[]),t<v||t>B)throw new RangeError("Version value out of range");if(r<-1||r>7)throw new RangeError("Mask value out of range");this.size=t*4+17;const o=Array.from({length:this.size},()=>!1);for(let l=0;l<this.size;l++)this.modules.push(o.slice()),this.types.push(o.map(()=>0));this.drawFunctionPatterns();const i=this.addEccAndInterleave(n);if(this.drawCodewords(i),r===-1){let l=1e9;for(let c=0;c<8;c++){this.applyMask(c),this.drawFormatBits(c);const h=this.getPenaltyScore();h<l&&(r=c,l=h),this.applyMask(c)}}this.mask=r,this.applyMask(r),this.drawFormatBits(r)}getModule(t,e){return t>=0&&t<this.size&&e>=0&&e<this.size&&this.modules[e][t]}drawFunctionPatterns(){for(let n=0;n<this.size;n++)this.setFunctionModule(6,n,n%2===0,P.Timing),this.setFunctionModule(n,6,n%2===0,P.Timing);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const t=this.getAlignmentPatternPositions(),e=t.length;for(let n=0;n<e;n++)for(let r=0;r<e;r++)n===0&&r===0||n===0&&r===e-1||n===e-1&&r===0||this.drawAlignmentPattern(t[n],t[r]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(t){const e=this.ecc[1]<<3|t;let n=e;for(let o=0;o<10;o++)n=n<<1^(n>>>9)*1335;const r=(e<<10|n)^21522;for(let o=0;o<=5;o++)this.setFunctionModule(8,o,y(r,o));this.setFunctionModule(8,7,y(r,6)),this.setFunctionModule(8,8,y(r,7)),this.setFunctionModule(7,8,y(r,8));for(let o=9;o<15;o++)this.setFunctionModule(14-o,8,y(r,o));for(let o=0;o<8;o++)this.setFunctionModule(this.size-1-o,8,y(r,o));for(let o=8;o<15;o++)this.setFunctionModule(8,this.size-15+o,y(r,o));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let t=this.version;for(let n=0;n<12;n++)t=t<<1^(t>>>11)*7973;const e=this.version<<12|t;for(let n=0;n<18;n++){const r=y(e,n),o=this.size-11+n%3,i=Math.floor(n/3);this.setFunctionModule(o,i,r),this.setFunctionModule(i,o,r)}}drawFinderPattern(t,e){for(let n=-4;n<=4;n++)for(let r=-4;r<=4;r++){const o=Math.max(Math.abs(r),Math.abs(n)),i=t+r,l=e+n;i>=0&&i<this.size&&l>=0&&l<this.size&&this.setFunctionModule(i,l,o!==2&&o!==4,P.Position)}}drawAlignmentPattern(t,e){for(let n=-2;n<=2;n++)for(let r=-2;r<=2;r++)this.setFunctionModule(t+r,e+n,Math.max(Math.abs(r),Math.abs(n))!==1,P.Alignment)}setFunctionModule(t,e,n,r=P.Function){this.modules[e][t]=n,this.types[e][t]=r}addEccAndInterleave(t){const e=this.version,n=this.ecc;if(t.length!==F(e,n))throw new RangeError("Invalid argument");const r=$[n[0]][e],o=U[n[0]][e],i=Math.floor(C(e)/8),l=r-i%r,c=Math.floor(i/r),h=[],f=at(o);for(let u=0,m=0;u<r;u++){const M=t.slice(m,m+c-o+(u<l?0:1));m+=M.length;const p=ct(M,f);u<l&&M.push(0),h.push(M.concat(p))}const a=[];for(let u=0;u<h[0].length;u++)h.forEach((m,M)=>{(u!==c-o||M>=l)&&a.push(m[u])});return a}drawCodewords(t){if(t.length!==Math.floor(C(this.version)/8))throw new RangeError("Invalid argument");let e=0;for(let n=this.size-1;n>=1;n-=2){n===6&&(n=5);for(let r=0;r<this.size;r++)for(let o=0;o<2;o++){const i=n-o,c=(n+1&2)===0?this.size-1-r:r;!this.types[c][i]&&e<t.length*8&&(this.modules[c][i]=y(t[e>>>3],7-(e&7)),e++)}}}applyMask(t){if(t<0||t>7)throw new RangeError("Mask value out of range");for(let e=0;e<this.size;e++)for(let n=0;n<this.size;n++){let r;switch(t){case 0:r=(n+e)%2===0;break;case 1:r=e%2===0;break;case 2:r=n%3===0;break;case 3:r=(n+e)%3===0;break;case 4:r=(Math.floor(n/3)+Math.floor(e/2))%2===0;break;case 5:r=n*e%2+n*e%3===0;break;case 6:r=(n*e%2+n*e%3)%2===0;break;case 7:r=((n+e)%2+n*e%3)%2===0;break;default:throw new Error("Unreachable")}!this.types[e][n]&&r&&(this.modules[e][n]=!this.modules[e][n])}}getPenaltyScore(){let t=0;for(let o=0;o<this.size;o++){let i=!1,l=0;const c=[0,0,0,0,0,0,0];for(let h=0;h<this.size;h++)this.modules[o][h]===i?(l++,l===5?t+=k:l>5&&t++):(this.finderPenaltyAddHistory(l,c),i||(t+=this.finderPenaltyCountPatterns(c)*R),i=this.modules[o][h],l=1);t+=this.finderPenaltyTerminateAndCount(i,l,c)*R}for(let o=0;o<this.size;o++){let i=!1,l=0;const c=[0,0,0,0,0,0,0];for(let h=0;h<this.size;h++)this.modules[h][o]===i?(l++,l===5?t+=k:l>5&&t++):(this.finderPenaltyAddHistory(l,c),i||(t+=this.finderPenaltyCountPatterns(c)*R),i=this.modules[h][o],l=1);t+=this.finderPenaltyTerminateAndCount(i,l,c)*R}for(let o=0;o<this.size-1;o++)for(let i=0;i<this.size-1;i++){const l=this.modules[o][i];l===this.modules[o][i+1]&&l===this.modules[o+1][i]&&l===this.modules[o+1][i+1]&&(t+=Z)}let e=0;for(const o of this.modules)e=o.reduce((i,l)=>i+(l?1:0),e);const n=this.size*this.size,r=Math.ceil(Math.abs(e*20-n*10)/n)-1;return t+=r*J,t}getAlignmentPatternPositions(){if(this.version===1)return[];{const t=Math.floor(this.version/7)+2,e=this.version===32?26:Math.ceil((this.version*4+4)/(t*2-2))*2,n=[6];for(let r=this.size-7;n.length<t;r-=e)n.splice(1,0,r);return n}}finderPenaltyCountPatterns(t){const e=t[1],n=e>0&&t[2]===e&&t[3]===e*3&&t[4]===e&&t[5]===e;return(n&&t[0]>=e*4&&t[6]>=e?1:0)+(n&&t[6]>=e*4&&t[0]>=e?1:0)}finderPenaltyTerminateAndCount(t,e,n){return t&&(this.finderPenaltyAddHistory(e,n),e=0),e+=this.size,this.finderPenaltyAddHistory(e,n),this.finderPenaltyCountPatterns(n)}finderPenaltyAddHistory(t,e){e[0]===0&&(t+=this.size),e.pop(),e.unshift(t)}}function A(s,t,e){if(t<0||t>31||s>>>t)throw new RangeError("Value out of range");for(let n=t-1;n>=0;n--)e.push(s>>>n&1)}function y(s,t){return(s>>>t&1)!==0}class I{constructor(t,e,n){if(this.mode=t,this.numChars=e,this.bitData=n,e<0)throw new RangeError("Invalid argument");this.bitData=n.slice()}getData(){return this.bitData.slice()}}const tt=[1,10,12,14],et=[2,9,11,13],nt=[4,8,16,16];function D(s,t){return s[Math.floor((t+7)/17)+1]}function T(s){const t=[];for(const e of s)A(e,8,t);return new I(nt,s.length,t)}function st(s){if(!Y(s))throw new RangeError("String contains non-numeric characters");const t=[];for(let e=0;e<s.length;){const n=Math.min(s.length-e,3);A(Number.parseInt(s.substring(e,e+n),10),n*3+1,t),e+=n}return new I(tt,s.length,t)}function rt(s){if(!V(s))throw new RangeError("String contains unencodable characters in alphanumeric mode");const t=[];let e;for(e=0;e+2<=s.length;e+=2){let n=_.indexOf(s.charAt(e))*45;n+=_.indexOf(s.charAt(e+1)),A(n,11,t)}return e<s.length&&A(_.indexOf(s.charAt(e)),6,t),new I(et,s.length,t)}function ot(s){return s===""?[]:Y(s)?[st(s)]:V(s)?[rt(s)]:[T(lt(s))]}function Y(s){return K.test(s)}function V(s){return W.test(s)}function it(s,t){let e=0;for(const n of s){const r=D(n.mode,t);if(n.numChars>=1<<r)return Number.POSITIVE_INFINITY;e+=4+r+n.bitData.length}return e}function lt(s){s=encodeURI(s);const t=[];for(let e=0;e<s.length;e++)s.charAt(e)!=="%"?t.push(s.charCodeAt(e)):(t.push(Number.parseInt(s.substring(e+1,e+3),16)),e+=2);return t}function C(s){if(s<v||s>B)throw new RangeError("Version number out of range");let t=(16*s+128)*s+64;if(s>=2){const e=Math.floor(s/7)+2;t-=(25*e-10)*e-55,s>=7&&(t-=36)}return t}function F(s,t){return Math.floor(C(s)/8)-U[t[0]][s]*$[t[0]][s]}function at(s){if(s<1||s>255)throw new RangeError("Degree out of range");const t=[];for(let n=0;n<s-1;n++)t.push(0);t.push(1);let e=1;for(let n=0;n<s;n++){for(let r=0;r<t.length;r++)t[r]=N(t[r],e),r+1<t.length&&(t[r]^=t[r+1]);e=N(e,2)}return t}function ct(s,t){const e=t.map(n=>0);for(const n of s){const r=n^e.shift();e.push(0),t.forEach((o,i)=>e[i]^=N(o,r))}return e}function N(s,t){if(s>>>8||t>>>8)throw new RangeError("Byte out of range");let e=0;for(let n=7;n>=0;n--)e=e<<1^(e>>>7)*285,e^=(t>>>n&1)*s;return e}function ht(s,t,e=1,n=40,r=-1,o=!0){if(!(v<=e&&e<=n&&n<=B)||r<-1||r>7)throw new RangeError("Invalid value");let i,l;for(i=e;;i++){const a=F(i,t)*8,u=it(s,i);if(u<=a){l=u;break}if(i>=n)throw new RangeError("Data too long")}for(const a of[S,O,L])o&&l<=F(i,a)*8&&(t=a);const c=[];for(const a of s){A(a.mode[0],4,c),A(a.numChars,D(a.mode,i),c);for(const u of a.getData())c.push(u)}const h=F(i,t)*8;A(0,Math.min(4,h-c.length),c),A(0,(8-c.length%8)%8,c);for(let a=236;c.length<h;a^=253)A(a,8,c);const f=Array.from({length:Math.ceil(c.length/8)},()=>0);return c.forEach((a,u)=>f[u>>>3]|=a<<7-(u&7)),new Q(i,t,f,r)}function ft(s,t){var a;const{ecc:e="L",boostEcc:n=!1,minVersion:r=1,maxVersion:o=40,maskPattern:i=-1,border:l=1}=t||{},c=typeof s=="string"?ot(s):Array.isArray(s)?[T(s)]:void 0;if(!c)throw new Error(`uqr only supports encoding string and binary data, but got: ${typeof s}`);const h=ht(c,H[e],r,o,i,n),f=ut({version:h.version,maskPattern:h.mask,size:h.size,data:h.modules,types:h.types},l);return t!=null&&t.invert&&(f.data=f.data.map(u=>u.map(m=>!m))),(a=t==null?void 0:t.onEncoded)==null||a.call(t,f),f}function ut(s,t=1){if(!t)return s;const{size:e}=s,n=e+t*2;s.size=n,s.data.forEach(o=>{for(let i=0;i<t;i++)o.unshift(!1),o.push(!1)});for(let o=0;o<t;o++)s.data.unshift(Array.from({length:n},i=>!1)),s.data.push(Array.from({length:n},i=>!1));const r=P.Border;s.types.forEach(o=>{for(let i=0;i<t;i++)o.unshift(r),o.push(r)});for(let o=0;o<t;o++)s.types.unshift(Array.from({length:n},i=>r)),s.types.push(Array.from({length:n},i=>r));return s}function gt({ecl:s="M",size:t=200,uri:e,clearSize:n=0,image:r,imageBackground:o="transparent"}){const i=n,l=t-10*2,c=q.useMemo(()=>{const h=[],f=ft(e,{border:0,ecc:s}).data,a=l/f.length,u=[{x:0,y:0},{x:1,y:0},{x:0,y:1}];for(const{x:b,y:g}of u){const x=(f.length-7)*a*b,w=(f.length-7)*a*g;for(let d=0;d<3;d++)h.push(E.jsx("rect",{fill:d%2!==0?"var(--ck-qr-background, var(--ck-body-background))":"var(--ck-qr-dot-color)",height:a*(7-d*2),rx:(d-2)*-5+(d===0?2:3),ry:(d-2)*-5+(d===0?2:3),width:a*(7-d*2),x:x+a*d,y:w+a*d},`${d}-${b}-${g}`))}if(r){const b=(f.length-7)*a*1,g=(f.length-7)*a*1;h.push(E.jsxs(E.Fragment,{children:[E.jsx("rect",{fill:o,height:a*(7-0*2),rx:-2*-5+2,ry:-2*-5+2,width:a*(7-0*2),x:b+a*0,y:g+a*0}),E.jsx("foreignObject",{height:a*(7-0*2),width:a*(7-0*2),x:b+a*0,y:g+a*0,children:E.jsx("div",{style:{borderRadius:-2*-5+2,overflow:"hidden"},children:r})})]}))}const m=Math.floor((i+25)/a),M=f.length/2-m/2,p=f.length/2+m/2-1;return f.forEach((b,g)=>{b.forEach((x,w)=>{var d;(d=f[g])!=null&&d[w]&&(g<7&&w<7||g>f.length-8&&w<7||g<7&&w>f.length-8||(r||!(g>M&&g<p&&w>M&&w<p))&&h.push(E.jsx("circle",{cx:g*a+a/2,cy:w*a+a/2,fill:"var(--ck-qr-dot-color)",r:a/3},`circle-${g}-${w}`)))})}),h},[s,r,o,i,l,e]);return E.jsxs("svg",{height:l,role:"presentation",style:{height:l,width:l},viewBox:`0 0 ${l} ${l}`,width:l,children:[E.jsx("rect",{fill:"transparent",height:l,width:l}),c]})}export{gt as default};
@@ -0,0 +1 @@
1
+ const n=/^(.*)\[([0-9]*)\]$/,s=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,t=/^(u?int)(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/,e=2n**96n-1n,a=2n**256n-1n;export{n as a,s as b,e as c,t as i,a as m};
@@ -1 +1 @@
1
- import{N as T,w as O,p as x,R as A,S as g,o as B,E as D,q as M,W as F,C as w,B as v,a as L,t as N,u as z,x as R,d as _,e as H,y as V,s as q,i as $}from"./index-rAbloVh4.js";import{C as P}from"./NetworkUtil-CORVq-U7.js";const I={getGasPriceInEther(n,t){const o=t*n;return Number(o)/1e18},getGasPriceInUSD(n,t,o){const s=I.getGasPriceInEther(t,o);return T.bigNumber(n).times(s).toNumber()},getPriceImpact({sourceTokenAmount:n,sourceTokenPriceInUSD:t,toTokenPriceInUSD:o,toTokenAmount:s}){const c=T.bigNumber(n).times(t),r=T.bigNumber(s).times(o);return c.minus(r).div(c).times(100).toNumber()},getMaxSlippage(n,t){const o=T.bigNumber(n).div(100);return T.multiply(t,o).toNumber()},getProviderFee(n,t=.0085){return T.bigNumber(n).times(t).toString()},isInsufficientNetworkTokenForGas(n,t){const o=t||"0";return T.bigNumber(n).eq(0)?!0:T.bigNumber(T.bigNumber(o)).gt(n)},isInsufficientSourceTokenForSwap(n,t,o){var r,d;const s=(d=(r=o==null?void 0:o.find(l=>l.address===t))==null?void 0:r.quantity)==null?void 0:d.numeric;return T.bigNumber(s||"0").lt(n)}},G=15e4,Q=6,k={initializing:!1,initialized:!1,loadingPrices:!1,loadingQuote:!1,loadingApprovalTransaction:!1,loadingBuildTransaction:!1,loadingTransaction:!1,switchingTokens:!1,fetchError:!1,approvalTransaction:void 0,swapTransaction:void 0,transactionError:void 0,sourceToken:void 0,sourceTokenAmount:"",sourceTokenPriceInUSD:0,toToken:void 0,toTokenAmount:"",toTokenPriceInUSD:0,networkPrice:"0",networkBalanceInUSD:"0",networkTokenSymbol:"",inputError:void 0,slippage:_.CONVERT_SLIPPAGE_TOLERANCE,tokens:void 0,popularTokens:void 0,suggestedTokens:void 0,foundTokens:void 0,myTokensWithBalance:void 0,tokensPriceMap:{},gasFee:"0",gasPriceInUSD:0,priceImpact:void 0,maxSlippage:void 0,providerFee:void 0},e=x({...k}),E={state:e,subscribe(n){return $(e,()=>n(e))},subscribeKey(n,t){return q(e,n,t)},getParams(){var i,u,p,f,S,h,y,C,b;const n=w.state.activeChain,t=((i=w.getAccountData(n))==null?void 0:i.caipAddress)??w.state.activeCaipAddress,o=L.getPlainAddress(t),s=H(),c=V.getConnectorId(w.state.activeChain);if(!o)throw new Error("No address found to swap the tokens from.");const r=!((u=e.toToken)!=null&&u.address)||!((p=e.toToken)!=null&&p.decimals),d=!((f=e.sourceToken)!=null&&f.address)||!((S=e.sourceToken)!=null&&S.decimals)||!T.bigNumber(e.sourceTokenAmount).gt(0),l=!e.sourceTokenAmount;return{networkAddress:s,fromAddress:o,fromCaipAddress:t,sourceTokenAddress:(h=e.sourceToken)==null?void 0:h.address,toTokenAddress:(y=e.toToken)==null?void 0:y.address,toTokenAmount:e.toTokenAmount,toTokenDecimals:(C=e.toToken)==null?void 0:C.decimals,sourceTokenAmount:e.sourceTokenAmount,sourceTokenDecimals:(b=e.sourceToken)==null?void 0:b.decimals,invalidToToken:r,invalidSourceToken:d,invalidSourceTokenAmount:l,availableToSwap:t&&!r&&!d&&!l,isAuthConnector:c===P.CONNECTOR_ID.AUTH}},async setSourceToken(n){if(!n){e.sourceToken=n,e.sourceTokenAmount="",e.sourceTokenPriceInUSD=0;return}e.sourceToken=n,await a.setTokenPrice(n.address,"sourceToken")},setSourceTokenAmount(n){e.sourceTokenAmount=n},async setToToken(n){if(!n){e.toToken=n,e.toTokenAmount="",e.toTokenPriceInUSD=0;return}e.toToken=n,await a.setTokenPrice(n.address,"toToken")},setToTokenAmount(n){e.toTokenAmount=n?T.toFixed(n,Q):""},async setTokenPrice(n,t){let o=e.tokensPriceMap[n]||0;o||(e.loadingPrices=!0,o=await a.getAddressPrice(n)),t==="sourceToken"?e.sourceTokenPriceInUSD=o:t==="toToken"&&(e.toTokenPriceInUSD=o),e.loadingPrices&&(e.loadingPrices=!1),a.getParams().availableToSwap&&!e.switchingTokens&&a.swapTokens()},async switchTokens(){if(!(e.initializing||!e.initialized||e.switchingTokens)){e.switchingTokens=!0;try{const n=e.toToken?{...e.toToken}:void 0,t=e.sourceToken?{...e.sourceToken}:void 0,o=n&&e.toTokenAmount===""?"1":e.toTokenAmount;a.setSourceTokenAmount(o),a.setToTokenAmount(""),await a.setSourceToken(n),await a.setToToken(t),e.switchingTokens=!1,a.swapTokens()}catch(n){throw e.switchingTokens=!1,n}}},resetState(){e.myTokensWithBalance=k.myTokensWithBalance,e.tokensPriceMap=k.tokensPriceMap,e.initialized=k.initialized,e.initializing=k.initializing,e.switchingTokens=k.switchingTokens,e.sourceToken=k.sourceToken,e.sourceTokenAmount=k.sourceTokenAmount,e.sourceTokenPriceInUSD=k.sourceTokenPriceInUSD,e.toToken=k.toToken,e.toTokenAmount=k.toTokenAmount,e.toTokenPriceInUSD=k.toTokenPriceInUSD,e.networkPrice=k.networkPrice,e.networkTokenSymbol=k.networkTokenSymbol,e.networkBalanceInUSD=k.networkBalanceInUSD,e.inputError=k.inputError},resetValues(){var o;const{networkAddress:n}=a.getParams(),t=(o=e.tokens)==null?void 0:o.find(s=>s.address===n);a.setSourceToken(t),a.setToToken(void 0)},getApprovalLoadingState(){return e.loadingApprovalTransaction},clearError(){e.transactionError=void 0},async initializeState(){if(!e.initializing){if(e.initializing=!0,!e.initialized)try{await a.fetchTokens(),e.initialized=!0}catch{e.initialized=!1,g.showError("Failed to initialize swap"),A.goBack()}e.initializing=!1}},async fetchTokens(){var o;const{networkAddress:n}=a.getParams();await a.getNetworkTokenPrice(),await a.getMyTokensWithBalance();const t=(o=e.myTokensWithBalance)==null?void 0:o.find(s=>s.address===n);t&&(e.networkTokenSymbol=t.symbol,a.setSourceToken(t),a.setSourceTokenAmount("0"))},async getTokenList(){var t,o;const n=(t=w.state.activeCaipNetwork)==null?void 0:t.caipNetworkId;if(!(e.caipNetworkId===n&&e.tokens))try{e.tokensLoading=!0;const s=await N.getTokenList(n);e.tokens=s,e.caipNetworkId=n,e.popularTokens=s.sort((i,u)=>i.symbol<u.symbol?-1:i.symbol>u.symbol?1:0);const r=(n&&((o=_.SUGGESTED_TOKENS_BY_CHAIN)==null?void 0:o[n])||[]).map(i=>s.find(u=>u.symbol===i)).filter(i=>!!i),l=(_.SWAP_SUGGESTED_TOKENS||[]).map(i=>s.find(u=>u.symbol===i)).filter(i=>!!i).filter(i=>!r.some(u=>u.address===i.address));e.suggestedTokens=[...r,...l]}catch{e.tokens=[],e.popularTokens=[],e.suggestedTokens=[]}finally{e.tokensLoading=!1}},async getAddressPrice(n){var i,u;const t=e.tokensPriceMap[n];if(t)return t;const o=await v.fetchTokenPrice({addresses:[n]}),s=(o==null?void 0:o.fungibles)||[],c=[...e.tokens||[],...e.myTokensWithBalance||[]],r=(i=c==null?void 0:c.find(p=>p.address===n))==null?void 0:i.symbol,d=((u=s.find(p=>p.symbol.toLowerCase()===(r==null?void 0:r.toLowerCase())))==null?void 0:u.price)||0,l=parseFloat(d.toString());return e.tokensPriceMap[n]=l,l},async getNetworkTokenPrice(){var c;const{networkAddress:n}=a.getParams(),o=(c=(await v.fetchTokenPrice({addresses:[n]}).catch(()=>(g.showError("Failed to fetch network token price"),{fungibles:[]}))).fungibles)==null?void 0:c[0],s=(o==null?void 0:o.price.toString())||"0";e.tokensPriceMap[n]=parseFloat(s),e.networkTokenSymbol=(o==null?void 0:o.symbol)||"",e.networkPrice=s},async getMyTokensWithBalance(n){const t=await R.getMyTokensWithBalance(n),o=N.mapBalancesToSwapTokens(t);o&&(await a.getInitialGasPrice(),a.setBalances(o))},setBalances(n){const{networkAddress:t}=a.getParams(),o=w.state.activeCaipNetwork;if(!o)return;const s=n.find(c=>c.address===t);n.forEach(c=>{e.tokensPriceMap[c.address]=c.price||0}),e.myTokensWithBalance=n.filter(c=>c.address.startsWith(o.caipNetworkId)),e.networkBalanceInUSD=s?T.multiply(s.quantity.numeric,s.price).toString():"0"},async getInitialGasPrice(){var t,o;const n=await N.fetchGasPrice();if(!n)return{gasPrice:null,gasPriceInUSD:null};switch((o=(t=w.state)==null?void 0:t.activeCaipNetwork)==null?void 0:o.chainNamespace){case P.CHAIN.SOLANA:return e.gasFee=n.standard??"0",e.gasPriceInUSD=T.multiply(n.standard,e.networkPrice).div(1e9).toNumber(),{gasPrice:BigInt(e.gasFee),gasPriceInUSD:Number(e.gasPriceInUSD)};case P.CHAIN.EVM:default:const s=n.standard??"0",c=BigInt(s),r=BigInt(G),d=I.getGasPriceInUSD(e.networkPrice,r,c);return e.gasFee=s,e.gasPriceInUSD=d,{gasPrice:c,gasPriceInUSD:d}}},async swapTokens(){var r,d,l;const n=(r=w.getAccountData())==null?void 0:r.address,t=e.sourceToken,o=e.toToken,s=T.bigNumber(e.sourceTokenAmount).gt(0);if(s||a.setToTokenAmount(""),!o||!t||e.loadingPrices||!s||!n)return;e.loadingQuote=!0;const c=T.bigNumber(e.sourceTokenAmount).times(10**t.decimals).round(0);try{const i=await v.fetchSwapQuote({userAddress:n,from:t.address,to:o.address,gasPrice:e.gasFee,amount:c.toString()});e.loadingQuote=!1;const u=(l=(d=i==null?void 0:i.quotes)==null?void 0:d[0])==null?void 0:l.toAmount;if(!u){z.open({displayMessage:"Incorrect amount",debugMessage:"Please enter a valid amount"},"error");return}const p=T.bigNumber(u).div(10**o.decimals).toString();a.setToTokenAmount(p),a.hasInsufficientToken(e.sourceTokenAmount,t.address)?e.inputError="Insufficient balance":(e.inputError=void 0,a.setTransactionDetails())}catch(i){const u=await N.handleSwapError(i);e.loadingQuote=!1,e.inputError=u||"Insufficient balance"}},async getTransaction(){const{fromCaipAddress:n,availableToSwap:t}=a.getParams(),o=e.sourceToken,s=e.toToken;if(!(!n||!t||!o||!s||e.loadingQuote))try{e.loadingBuildTransaction=!0;const c=await N.fetchSwapAllowance({userAddress:n,tokenAddress:o.address,sourceTokenAmount:e.sourceTokenAmount,sourceTokenDecimals:o.decimals});let r;return c?r=await a.createSwapTransaction():r=await a.createAllowanceTransaction(),e.loadingBuildTransaction=!1,e.fetchError=!1,r}catch{A.goBack(),g.showError("Failed to check allowance"),e.loadingBuildTransaction=!1,e.approvalTransaction=void 0,e.swapTransaction=void 0,e.fetchError=!0;return}},async createAllowanceTransaction(){const{fromCaipAddress:n,sourceTokenAddress:t,toTokenAddress:o}=a.getParams();if(!(!n||!o)){if(!t)throw new Error("createAllowanceTransaction - No source token address found.");try{const s=await v.generateApproveCalldata({from:t,to:o,userAddress:n}),c=L.getPlainAddress(s.tx.from);if(!c)throw new Error("SwapController:createAllowanceTransaction - address is required");const r={data:s.tx.data,to:c,gasPrice:BigInt(s.tx.eip155.gasPrice),value:BigInt(s.tx.value),toAmount:e.toTokenAmount};return e.swapTransaction=void 0,e.approvalTransaction={data:r.data,to:r.to,gasPrice:r.gasPrice,value:r.value,toAmount:r.toAmount},{data:r.data,to:r.to,gasPrice:r.gasPrice,value:r.value,toAmount:r.toAmount}}catch{A.goBack(),g.showError("Failed to create approval transaction"),e.approvalTransaction=void 0,e.swapTransaction=void 0,e.fetchError=!0;return}}},async createSwapTransaction(){var d;const{networkAddress:n,fromCaipAddress:t,sourceTokenAmount:o}=a.getParams(),s=e.sourceToken,c=e.toToken;if(!t||!o||!s||!c)return;const r=(d=B.parseUnits(o,s.decimals))==null?void 0:d.toString();try{const l=await v.generateSwapCalldata({userAddress:t,from:s.address,to:c.address,amount:r,disableEstimate:!0}),i=s.address===n,u=BigInt(l.tx.eip155.gas),p=BigInt(l.tx.eip155.gasPrice),f=L.getPlainAddress(l.tx.to);if(!f)throw new Error("SwapController:createSwapTransaction - address is required");const S={data:l.tx.data,to:f,gas:u,gasPrice:p,value:BigInt(i?r??"0":"0"),toAmount:e.toTokenAmount};return e.gasPriceInUSD=I.getGasPriceInUSD(e.networkPrice,u,p),e.approvalTransaction=void 0,e.swapTransaction=S,S}catch{A.goBack(),g.showError("Failed to create transaction"),e.approvalTransaction=void 0,e.swapTransaction=void 0,e.fetchError=!0;return}},onEmbeddedWalletApprovalSuccess(){g.showLoading("Approve limit increase in your wallet"),A.replace("SwapPreview")},async sendTransactionForApproval(n){var c,r,d;const{fromAddress:t,isAuthConnector:o}=a.getParams();e.loadingApprovalTransaction=!0,o?A.pushTransactionStack({onSuccess:a.onEmbeddedWalletApprovalSuccess}):g.showLoading("Approve limit increase in your wallet");try{await B.sendTransaction({address:t,to:n.to,data:n.data,value:n.value,chainNamespace:P.CHAIN.EVM}),await a.swapTokens(),await a.getTransaction(),e.approvalTransaction=void 0,e.loadingApprovalTransaction=!1}catch(l){const i=l;e.transactionError=i==null?void 0:i.displayMessage,e.loadingApprovalTransaction=!1,g.showError((i==null?void 0:i.displayMessage)||"Transaction error"),D.sendEvent({type:"track",event:"SWAP_APPROVAL_ERROR",properties:{message:(i==null?void 0:i.displayMessage)||(i==null?void 0:i.message)||"Unknown",network:((c=w.state.activeCaipNetwork)==null?void 0:c.caipNetworkId)||"",swapFromToken:((r=a.state.sourceToken)==null?void 0:r.symbol)||"",swapToToken:((d=a.state.toToken)==null?void 0:d.symbol)||"",swapFromAmount:a.state.sourceTokenAmount||"",swapToAmount:a.state.toTokenAmount||"",isSmartAccount:M(P.CHAIN.EVM)===F.ACCOUNT_TYPES.SMART_ACCOUNT}})}},async sendTransactionForSwap(n){var d,l,i,u,p,f,S,h,y,C,b,W;if(!n)return;const{fromAddress:t,toTokenAmount:o,isAuthConnector:s}=a.getParams();e.loadingTransaction=!0;const c=`Swapping ${(d=e.sourceToken)==null?void 0:d.symbol} to ${T.formatNumberToLocalString(o,3)} ${(l=e.toToken)==null?void 0:l.symbol}`,r=`Swapped ${(i=e.sourceToken)==null?void 0:i.symbol} to ${T.formatNumberToLocalString(o,3)} ${(u=e.toToken)==null?void 0:u.symbol}`;s?A.pushTransactionStack({onSuccess(){A.replace("Account"),g.showLoading(c),E.resetState()}}):g.showLoading("Confirm transaction in your wallet");try{const U=[(p=e.sourceToken)==null?void 0:p.address,(f=e.toToken)==null?void 0:f.address].join(","),m=await B.sendTransaction({address:t,to:n.to,data:n.data,value:n.value,chainNamespace:P.CHAIN.EVM});return e.loadingTransaction=!1,g.showSuccess(r),D.sendEvent({type:"track",event:"SWAP_SUCCESS",properties:{network:((S=w.state.activeCaipNetwork)==null?void 0:S.caipNetworkId)||"",swapFromToken:((h=a.state.sourceToken)==null?void 0:h.symbol)||"",swapToToken:((y=a.state.toToken)==null?void 0:y.symbol)||"",swapFromAmount:a.state.sourceTokenAmount||"",swapToAmount:a.state.toTokenAmount||"",isSmartAccount:M(P.CHAIN.EVM)===F.ACCOUNT_TYPES.SMART_ACCOUNT}}),E.resetState(),s||A.replace("Account"),E.getMyTokensWithBalance(U),m}catch(U){const m=U;e.transactionError=m==null?void 0:m.displayMessage,e.loadingTransaction=!1,g.showError((m==null?void 0:m.displayMessage)||"Transaction error"),D.sendEvent({type:"track",event:"SWAP_ERROR",properties:{message:(m==null?void 0:m.displayMessage)||(m==null?void 0:m.message)||"Unknown",network:((C=w.state.activeCaipNetwork)==null?void 0:C.caipNetworkId)||"",swapFromToken:((b=a.state.sourceToken)==null?void 0:b.symbol)||"",swapToToken:((W=a.state.toToken)==null?void 0:W.symbol)||"",swapFromAmount:a.state.sourceTokenAmount||"",swapToAmount:a.state.toTokenAmount||"",isSmartAccount:M(P.CHAIN.EVM)===F.ACCOUNT_TYPES.SMART_ACCOUNT}});return}},hasInsufficientToken(n,t){return I.isInsufficientSourceTokenForSwap(n,t,e.myTokensWithBalance)},setTransactionDetails(){const{toTokenAddress:n,toTokenDecimals:t}=a.getParams();!n||!t||(e.gasPriceInUSD=I.getGasPriceInUSD(e.networkPrice,BigInt(e.gasFee),BigInt(G)),e.priceImpact=I.getPriceImpact({sourceTokenAmount:e.sourceTokenAmount,sourceTokenPriceInUSD:e.sourceTokenPriceInUSD,toTokenPriceInUSD:e.toTokenPriceInUSD,toTokenAmount:e.toTokenAmount}),e.maxSlippage=I.getMaxSlippage(e.slippage,e.toTokenAmount),e.providerFee=I.getProviderFee(e.sourceTokenAmount))}},a=O(E);export{a as S};
1
+ import{N as T,w as O,p as x,R as A,S as g,o as B,E as D,q as M,W as F,C as w,B as v,a as L,t as N,u as z,x as R,d as _,e as H,y as V,s as q,i as $}from"./index-TpT45Yhr.js";import{C as P}from"./NetworkUtil-BooKnyFI.js";const I={getGasPriceInEther(n,t){const o=t*n;return Number(o)/1e18},getGasPriceInUSD(n,t,o){const s=I.getGasPriceInEther(t,o);return T.bigNumber(n).times(s).toNumber()},getPriceImpact({sourceTokenAmount:n,sourceTokenPriceInUSD:t,toTokenPriceInUSD:o,toTokenAmount:s}){const c=T.bigNumber(n).times(t),r=T.bigNumber(s).times(o);return c.minus(r).div(c).times(100).toNumber()},getMaxSlippage(n,t){const o=T.bigNumber(n).div(100);return T.multiply(t,o).toNumber()},getProviderFee(n,t=.0085){return T.bigNumber(n).times(t).toString()},isInsufficientNetworkTokenForGas(n,t){const o=t||"0";return T.bigNumber(n).eq(0)?!0:T.bigNumber(T.bigNumber(o)).gt(n)},isInsufficientSourceTokenForSwap(n,t,o){var r,d;const s=(d=(r=o==null?void 0:o.find(l=>l.address===t))==null?void 0:r.quantity)==null?void 0:d.numeric;return T.bigNumber(s||"0").lt(n)}},G=15e4,Q=6,k={initializing:!1,initialized:!1,loadingPrices:!1,loadingQuote:!1,loadingApprovalTransaction:!1,loadingBuildTransaction:!1,loadingTransaction:!1,switchingTokens:!1,fetchError:!1,approvalTransaction:void 0,swapTransaction:void 0,transactionError:void 0,sourceToken:void 0,sourceTokenAmount:"",sourceTokenPriceInUSD:0,toToken:void 0,toTokenAmount:"",toTokenPriceInUSD:0,networkPrice:"0",networkBalanceInUSD:"0",networkTokenSymbol:"",inputError:void 0,slippage:_.CONVERT_SLIPPAGE_TOLERANCE,tokens:void 0,popularTokens:void 0,suggestedTokens:void 0,foundTokens:void 0,myTokensWithBalance:void 0,tokensPriceMap:{},gasFee:"0",gasPriceInUSD:0,priceImpact:void 0,maxSlippage:void 0,providerFee:void 0},e=x({...k}),E={state:e,subscribe(n){return $(e,()=>n(e))},subscribeKey(n,t){return q(e,n,t)},getParams(){var i,u,p,f,S,h,y,C,b;const n=w.state.activeChain,t=((i=w.getAccountData(n))==null?void 0:i.caipAddress)??w.state.activeCaipAddress,o=L.getPlainAddress(t),s=H(),c=V.getConnectorId(w.state.activeChain);if(!o)throw new Error("No address found to swap the tokens from.");const r=!((u=e.toToken)!=null&&u.address)||!((p=e.toToken)!=null&&p.decimals),d=!((f=e.sourceToken)!=null&&f.address)||!((S=e.sourceToken)!=null&&S.decimals)||!T.bigNumber(e.sourceTokenAmount).gt(0),l=!e.sourceTokenAmount;return{networkAddress:s,fromAddress:o,fromCaipAddress:t,sourceTokenAddress:(h=e.sourceToken)==null?void 0:h.address,toTokenAddress:(y=e.toToken)==null?void 0:y.address,toTokenAmount:e.toTokenAmount,toTokenDecimals:(C=e.toToken)==null?void 0:C.decimals,sourceTokenAmount:e.sourceTokenAmount,sourceTokenDecimals:(b=e.sourceToken)==null?void 0:b.decimals,invalidToToken:r,invalidSourceToken:d,invalidSourceTokenAmount:l,availableToSwap:t&&!r&&!d&&!l,isAuthConnector:c===P.CONNECTOR_ID.AUTH}},async setSourceToken(n){if(!n){e.sourceToken=n,e.sourceTokenAmount="",e.sourceTokenPriceInUSD=0;return}e.sourceToken=n,await a.setTokenPrice(n.address,"sourceToken")},setSourceTokenAmount(n){e.sourceTokenAmount=n},async setToToken(n){if(!n){e.toToken=n,e.toTokenAmount="",e.toTokenPriceInUSD=0;return}e.toToken=n,await a.setTokenPrice(n.address,"toToken")},setToTokenAmount(n){e.toTokenAmount=n?T.toFixed(n,Q):""},async setTokenPrice(n,t){let o=e.tokensPriceMap[n]||0;o||(e.loadingPrices=!0,o=await a.getAddressPrice(n)),t==="sourceToken"?e.sourceTokenPriceInUSD=o:t==="toToken"&&(e.toTokenPriceInUSD=o),e.loadingPrices&&(e.loadingPrices=!1),a.getParams().availableToSwap&&!e.switchingTokens&&a.swapTokens()},async switchTokens(){if(!(e.initializing||!e.initialized||e.switchingTokens)){e.switchingTokens=!0;try{const n=e.toToken?{...e.toToken}:void 0,t=e.sourceToken?{...e.sourceToken}:void 0,o=n&&e.toTokenAmount===""?"1":e.toTokenAmount;a.setSourceTokenAmount(o),a.setToTokenAmount(""),await a.setSourceToken(n),await a.setToToken(t),e.switchingTokens=!1,a.swapTokens()}catch(n){throw e.switchingTokens=!1,n}}},resetState(){e.myTokensWithBalance=k.myTokensWithBalance,e.tokensPriceMap=k.tokensPriceMap,e.initialized=k.initialized,e.initializing=k.initializing,e.switchingTokens=k.switchingTokens,e.sourceToken=k.sourceToken,e.sourceTokenAmount=k.sourceTokenAmount,e.sourceTokenPriceInUSD=k.sourceTokenPriceInUSD,e.toToken=k.toToken,e.toTokenAmount=k.toTokenAmount,e.toTokenPriceInUSD=k.toTokenPriceInUSD,e.networkPrice=k.networkPrice,e.networkTokenSymbol=k.networkTokenSymbol,e.networkBalanceInUSD=k.networkBalanceInUSD,e.inputError=k.inputError},resetValues(){var o;const{networkAddress:n}=a.getParams(),t=(o=e.tokens)==null?void 0:o.find(s=>s.address===n);a.setSourceToken(t),a.setToToken(void 0)},getApprovalLoadingState(){return e.loadingApprovalTransaction},clearError(){e.transactionError=void 0},async initializeState(){if(!e.initializing){if(e.initializing=!0,!e.initialized)try{await a.fetchTokens(),e.initialized=!0}catch{e.initialized=!1,g.showError("Failed to initialize swap"),A.goBack()}e.initializing=!1}},async fetchTokens(){var o;const{networkAddress:n}=a.getParams();await a.getNetworkTokenPrice(),await a.getMyTokensWithBalance();const t=(o=e.myTokensWithBalance)==null?void 0:o.find(s=>s.address===n);t&&(e.networkTokenSymbol=t.symbol,a.setSourceToken(t),a.setSourceTokenAmount("0"))},async getTokenList(){var t,o;const n=(t=w.state.activeCaipNetwork)==null?void 0:t.caipNetworkId;if(!(e.caipNetworkId===n&&e.tokens))try{e.tokensLoading=!0;const s=await N.getTokenList(n);e.tokens=s,e.caipNetworkId=n,e.popularTokens=s.sort((i,u)=>i.symbol<u.symbol?-1:i.symbol>u.symbol?1:0);const r=(n&&((o=_.SUGGESTED_TOKENS_BY_CHAIN)==null?void 0:o[n])||[]).map(i=>s.find(u=>u.symbol===i)).filter(i=>!!i),l=(_.SWAP_SUGGESTED_TOKENS||[]).map(i=>s.find(u=>u.symbol===i)).filter(i=>!!i).filter(i=>!r.some(u=>u.address===i.address));e.suggestedTokens=[...r,...l]}catch{e.tokens=[],e.popularTokens=[],e.suggestedTokens=[]}finally{e.tokensLoading=!1}},async getAddressPrice(n){var i,u;const t=e.tokensPriceMap[n];if(t)return t;const o=await v.fetchTokenPrice({addresses:[n]}),s=(o==null?void 0:o.fungibles)||[],c=[...e.tokens||[],...e.myTokensWithBalance||[]],r=(i=c==null?void 0:c.find(p=>p.address===n))==null?void 0:i.symbol,d=((u=s.find(p=>p.symbol.toLowerCase()===(r==null?void 0:r.toLowerCase())))==null?void 0:u.price)||0,l=parseFloat(d.toString());return e.tokensPriceMap[n]=l,l},async getNetworkTokenPrice(){var c;const{networkAddress:n}=a.getParams(),o=(c=(await v.fetchTokenPrice({addresses:[n]}).catch(()=>(g.showError("Failed to fetch network token price"),{fungibles:[]}))).fungibles)==null?void 0:c[0],s=(o==null?void 0:o.price.toString())||"0";e.tokensPriceMap[n]=parseFloat(s),e.networkTokenSymbol=(o==null?void 0:o.symbol)||"",e.networkPrice=s},async getMyTokensWithBalance(n){const t=await R.getMyTokensWithBalance(n),o=N.mapBalancesToSwapTokens(t);o&&(await a.getInitialGasPrice(),a.setBalances(o))},setBalances(n){const{networkAddress:t}=a.getParams(),o=w.state.activeCaipNetwork;if(!o)return;const s=n.find(c=>c.address===t);n.forEach(c=>{e.tokensPriceMap[c.address]=c.price||0}),e.myTokensWithBalance=n.filter(c=>c.address.startsWith(o.caipNetworkId)),e.networkBalanceInUSD=s?T.multiply(s.quantity.numeric,s.price).toString():"0"},async getInitialGasPrice(){var t,o;const n=await N.fetchGasPrice();if(!n)return{gasPrice:null,gasPriceInUSD:null};switch((o=(t=w.state)==null?void 0:t.activeCaipNetwork)==null?void 0:o.chainNamespace){case P.CHAIN.SOLANA:return e.gasFee=n.standard??"0",e.gasPriceInUSD=T.multiply(n.standard,e.networkPrice).div(1e9).toNumber(),{gasPrice:BigInt(e.gasFee),gasPriceInUSD:Number(e.gasPriceInUSD)};case P.CHAIN.EVM:default:const s=n.standard??"0",c=BigInt(s),r=BigInt(G),d=I.getGasPriceInUSD(e.networkPrice,r,c);return e.gasFee=s,e.gasPriceInUSD=d,{gasPrice:c,gasPriceInUSD:d}}},async swapTokens(){var r,d,l;const n=(r=w.getAccountData())==null?void 0:r.address,t=e.sourceToken,o=e.toToken,s=T.bigNumber(e.sourceTokenAmount).gt(0);if(s||a.setToTokenAmount(""),!o||!t||e.loadingPrices||!s||!n)return;e.loadingQuote=!0;const c=T.bigNumber(e.sourceTokenAmount).times(10**t.decimals).round(0);try{const i=await v.fetchSwapQuote({userAddress:n,from:t.address,to:o.address,gasPrice:e.gasFee,amount:c.toString()});e.loadingQuote=!1;const u=(l=(d=i==null?void 0:i.quotes)==null?void 0:d[0])==null?void 0:l.toAmount;if(!u){z.open({displayMessage:"Incorrect amount",debugMessage:"Please enter a valid amount"},"error");return}const p=T.bigNumber(u).div(10**o.decimals).toString();a.setToTokenAmount(p),a.hasInsufficientToken(e.sourceTokenAmount,t.address)?e.inputError="Insufficient balance":(e.inputError=void 0,a.setTransactionDetails())}catch(i){const u=await N.handleSwapError(i);e.loadingQuote=!1,e.inputError=u||"Insufficient balance"}},async getTransaction(){const{fromCaipAddress:n,availableToSwap:t}=a.getParams(),o=e.sourceToken,s=e.toToken;if(!(!n||!t||!o||!s||e.loadingQuote))try{e.loadingBuildTransaction=!0;const c=await N.fetchSwapAllowance({userAddress:n,tokenAddress:o.address,sourceTokenAmount:e.sourceTokenAmount,sourceTokenDecimals:o.decimals});let r;return c?r=await a.createSwapTransaction():r=await a.createAllowanceTransaction(),e.loadingBuildTransaction=!1,e.fetchError=!1,r}catch{A.goBack(),g.showError("Failed to check allowance"),e.loadingBuildTransaction=!1,e.approvalTransaction=void 0,e.swapTransaction=void 0,e.fetchError=!0;return}},async createAllowanceTransaction(){const{fromCaipAddress:n,sourceTokenAddress:t,toTokenAddress:o}=a.getParams();if(!(!n||!o)){if(!t)throw new Error("createAllowanceTransaction - No source token address found.");try{const s=await v.generateApproveCalldata({from:t,to:o,userAddress:n}),c=L.getPlainAddress(s.tx.from);if(!c)throw new Error("SwapController:createAllowanceTransaction - address is required");const r={data:s.tx.data,to:c,gasPrice:BigInt(s.tx.eip155.gasPrice),value:BigInt(s.tx.value),toAmount:e.toTokenAmount};return e.swapTransaction=void 0,e.approvalTransaction={data:r.data,to:r.to,gasPrice:r.gasPrice,value:r.value,toAmount:r.toAmount},{data:r.data,to:r.to,gasPrice:r.gasPrice,value:r.value,toAmount:r.toAmount}}catch{A.goBack(),g.showError("Failed to create approval transaction"),e.approvalTransaction=void 0,e.swapTransaction=void 0,e.fetchError=!0;return}}},async createSwapTransaction(){var d;const{networkAddress:n,fromCaipAddress:t,sourceTokenAmount:o}=a.getParams(),s=e.sourceToken,c=e.toToken;if(!t||!o||!s||!c)return;const r=(d=B.parseUnits(o,s.decimals))==null?void 0:d.toString();try{const l=await v.generateSwapCalldata({userAddress:t,from:s.address,to:c.address,amount:r,disableEstimate:!0}),i=s.address===n,u=BigInt(l.tx.eip155.gas),p=BigInt(l.tx.eip155.gasPrice),f=L.getPlainAddress(l.tx.to);if(!f)throw new Error("SwapController:createSwapTransaction - address is required");const S={data:l.tx.data,to:f,gas:u,gasPrice:p,value:BigInt(i?r??"0":"0"),toAmount:e.toTokenAmount};return e.gasPriceInUSD=I.getGasPriceInUSD(e.networkPrice,u,p),e.approvalTransaction=void 0,e.swapTransaction=S,S}catch{A.goBack(),g.showError("Failed to create transaction"),e.approvalTransaction=void 0,e.swapTransaction=void 0,e.fetchError=!0;return}},onEmbeddedWalletApprovalSuccess(){g.showLoading("Approve limit increase in your wallet"),A.replace("SwapPreview")},async sendTransactionForApproval(n){var c,r,d;const{fromAddress:t,isAuthConnector:o}=a.getParams();e.loadingApprovalTransaction=!0,o?A.pushTransactionStack({onSuccess:a.onEmbeddedWalletApprovalSuccess}):g.showLoading("Approve limit increase in your wallet");try{await B.sendTransaction({address:t,to:n.to,data:n.data,value:n.value,chainNamespace:P.CHAIN.EVM}),await a.swapTokens(),await a.getTransaction(),e.approvalTransaction=void 0,e.loadingApprovalTransaction=!1}catch(l){const i=l;e.transactionError=i==null?void 0:i.displayMessage,e.loadingApprovalTransaction=!1,g.showError((i==null?void 0:i.displayMessage)||"Transaction error"),D.sendEvent({type:"track",event:"SWAP_APPROVAL_ERROR",properties:{message:(i==null?void 0:i.displayMessage)||(i==null?void 0:i.message)||"Unknown",network:((c=w.state.activeCaipNetwork)==null?void 0:c.caipNetworkId)||"",swapFromToken:((r=a.state.sourceToken)==null?void 0:r.symbol)||"",swapToToken:((d=a.state.toToken)==null?void 0:d.symbol)||"",swapFromAmount:a.state.sourceTokenAmount||"",swapToAmount:a.state.toTokenAmount||"",isSmartAccount:M(P.CHAIN.EVM)===F.ACCOUNT_TYPES.SMART_ACCOUNT}})}},async sendTransactionForSwap(n){var d,l,i,u,p,f,S,h,y,C,b,W;if(!n)return;const{fromAddress:t,toTokenAmount:o,isAuthConnector:s}=a.getParams();e.loadingTransaction=!0;const c=`Swapping ${(d=e.sourceToken)==null?void 0:d.symbol} to ${T.formatNumberToLocalString(o,3)} ${(l=e.toToken)==null?void 0:l.symbol}`,r=`Swapped ${(i=e.sourceToken)==null?void 0:i.symbol} to ${T.formatNumberToLocalString(o,3)} ${(u=e.toToken)==null?void 0:u.symbol}`;s?A.pushTransactionStack({onSuccess(){A.replace("Account"),g.showLoading(c),E.resetState()}}):g.showLoading("Confirm transaction in your wallet");try{const U=[(p=e.sourceToken)==null?void 0:p.address,(f=e.toToken)==null?void 0:f.address].join(","),m=await B.sendTransaction({address:t,to:n.to,data:n.data,value:n.value,chainNamespace:P.CHAIN.EVM});return e.loadingTransaction=!1,g.showSuccess(r),D.sendEvent({type:"track",event:"SWAP_SUCCESS",properties:{network:((S=w.state.activeCaipNetwork)==null?void 0:S.caipNetworkId)||"",swapFromToken:((h=a.state.sourceToken)==null?void 0:h.symbol)||"",swapToToken:((y=a.state.toToken)==null?void 0:y.symbol)||"",swapFromAmount:a.state.sourceTokenAmount||"",swapToAmount:a.state.toTokenAmount||"",isSmartAccount:M(P.CHAIN.EVM)===F.ACCOUNT_TYPES.SMART_ACCOUNT}}),E.resetState(),s||A.replace("Account"),E.getMyTokensWithBalance(U),m}catch(U){const m=U;e.transactionError=m==null?void 0:m.displayMessage,e.loadingTransaction=!1,g.showError((m==null?void 0:m.displayMessage)||"Transaction error"),D.sendEvent({type:"track",event:"SWAP_ERROR",properties:{message:(m==null?void 0:m.displayMessage)||(m==null?void 0:m.message)||"Unknown",network:((C=w.state.activeCaipNetwork)==null?void 0:C.caipNetworkId)||"",swapFromToken:((b=a.state.sourceToken)==null?void 0:b.symbol)||"",swapToToken:((W=a.state.toToken)==null?void 0:W.symbol)||"",swapFromAmount:a.state.sourceTokenAmount||"",swapToAmount:a.state.toTokenAmount||"",isSmartAccount:M(P.CHAIN.EVM)===F.ACCOUNT_TYPES.SMART_ACCOUNT}});return}},hasInsufficientToken(n,t){return I.isInsufficientSourceTokenForSwap(n,t,e.myTokensWithBalance)},setTransactionDetails(){const{toTokenAddress:n,toTokenDecimals:t}=a.getParams();!n||!t||(e.gasPriceInUSD=I.getGasPriceInUSD(e.networkPrice,BigInt(e.gasFee),BigInt(G)),e.priceImpact=I.getPriceImpact({sourceTokenAmount:e.sourceTokenAmount,sourceTokenPriceInUSD:e.sourceTokenPriceInUSD,toTokenPriceInUSD:e.toTokenPriceInUSD,toTokenAmount:e.toTokenAmount}),e.maxSlippage=I.getMaxSlippage(e.slippage,e.toTokenAmount),e.providerFee=I.getProviderFee(e.sourceTokenAmount))}},a=O(E);export{a as S};