@multiversx/sdk-dapp-liquidity 1.0.12 → 1.0.14

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 (302) hide show
  1. package/ConstantsUtil-BinYIDR2.mjs +8 -0
  2. package/ConstantsUtil-CbnVdQ5P.js +8 -0
  3. package/add-D-ECcdUh.mjs +19 -0
  4. package/add-Diz8heiY.js +20 -0
  5. package/all-wallets-_iOQf3bl.js +11 -0
  6. package/all-wallets-puIIQy3Y.mjs +10 -0
  7. package/app-store-BGTKFL27.js +22 -0
  8. package/app-store-Bsf7w3pv.mjs +21 -0
  9. package/apple-Cw8e8IGH.mjs +22 -0
  10. package/apple-DF7n_Yzl.js +23 -0
  11. package/arrow-bottom-Cp2C4fQv.mjs +12 -0
  12. package/arrow-bottom-DTvIR3s3.js +13 -0
  13. package/arrow-bottom-circle-CN6i5mHz.mjs +15 -0
  14. package/arrow-bottom-circle-CzPwiwWH.js +16 -0
  15. package/arrow-left-9VFYHQSW.js +13 -0
  16. package/arrow-left-BDQHoEvX.mjs +12 -0
  17. package/arrow-right-BxkuSpWU.mjs +12 -0
  18. package/arrow-right-DBLQ6w92.js +13 -0
  19. package/arrow-top-BiQd5Aey.js +13 -0
  20. package/arrow-top-BrLVX4Rj.mjs +12 -0
  21. package/bank-B7EC6Kdz.mjs +18 -0
  22. package/bank-CvPn9sfV.js +19 -0
  23. package/{bignumber-CKZkoo0g.mjs → bignumber-2Z7uapuD.mjs} +6 -6
  24. package/{bignumber-B8vjg9qn.js → bignumber-D1Wl54dL.js} +6 -6
  25. package/bin-BXO1kNZh.js +9 -0
  26. package/bin-CwiYVJ1L.mjs +8 -0
  27. package/bitcoin-C3kBVar_.mjs +17 -0
  28. package/bitcoin-DAvQGpeP.js +3251 -0
  29. package/bitcoin-dNBGbS2B.mjs +3251 -0
  30. package/bitcoin-k6bvmzMA.js +18 -0
  31. package/browser-ShRLuKKz.mjs +18 -0
  32. package/browser-t7nfT7HL.js +19 -0
  33. package/card-BJg5bdoM.mjs +18 -0
  34. package/card-hxUDXttT.js +19 -0
  35. package/checkmark-BpR0Yy93.mjs +15 -0
  36. package/checkmark-D9AVWgl5.js +16 -0
  37. package/checkmark-bold-D3Xcby1U.mjs +12 -0
  38. package/checkmark-bold-De02hde8.js +13 -0
  39. package/chevron-bottom-DcBf7T5F.js +13 -0
  40. package/chevron-bottom-DfGpWIz7.mjs +12 -0
  41. package/chevron-left-BKvYVnUo.js +13 -0
  42. package/chevron-left-DGSG9WJQ.mjs +12 -0
  43. package/chevron-right-BLgYIEeO.js +13 -0
  44. package/chevron-right-C2nsTx_Y.mjs +12 -0
  45. package/chevron-top-CwFOEFy8.js +13 -0
  46. package/chevron-top-vk-9DvUU.mjs +12 -0
  47. package/chrome-store-4H_ie3vA.mjs +65 -0
  48. package/chrome-store-BWarxVMl.js +66 -0
  49. package/circle-BtqWJU0_.mjs +8 -0
  50. package/circle-DYjG6o7-.js +9 -0
  51. package/clock-Ba5SM-pl.mjs +12 -0
  52. package/clock-DPzNREdU.js +13 -0
  53. package/close-CJHKFOyp.mjs +12 -0
  54. package/close-DDWnJdJe.js +13 -0
  55. package/coinPlaceholder-Cbba3D1H.mjs +12 -0
  56. package/coinPlaceholder-DdxQIc2D.js +13 -0
  57. package/compass-CugCxeSC.js +13 -0
  58. package/compass-DbN5DkTl.mjs +12 -0
  59. package/copy-CHSZprYJ.mjs +19 -0
  60. package/copy-En5h5Uhu.js +20 -0
  61. package/cursor-DCRkvEhr.mjs +7 -0
  62. package/cursor-DnEQtrUK.js +8 -0
  63. package/cursor-transparent-CU8lk-xg.js +17 -0
  64. package/cursor-transparent-CliETg4d.mjs +16 -0
  65. package/desktop-BgD7aypB.js +14 -0
  66. package/desktop-Cg5I32-p.mjs +13 -0
  67. package/disconnect-CCyMbAdw.js +13 -0
  68. package/disconnect-Cp2vRWB2.mjs +12 -0
  69. package/discord-B1d-qeSk.mjs +21 -0
  70. package/discord-BEB5klec.js +22 -0
  71. package/email-CorlePKz.js +873 -0
  72. package/email-Znno7H8_.mjs +878 -0
  73. package/embedded-wallet-B9ro9Tel.js +549 -0
  74. package/embedded-wallet-CnTWeseG.mjs +552 -0
  75. package/ethereum-BRcsRjUU.mjs +14 -0
  76. package/ethereum-CZ_xe09e.js +15 -0
  77. package/etherscan-BZKGpKp8.mjs +10 -0
  78. package/etherscan-DtLi-C3z.js +11 -0
  79. package/exclamation-triangle-BLNnBLEc.js +9 -0
  80. package/exclamation-triangle-CFThXxRT.mjs +8 -0
  81. package/extension-CwUepr-W.mjs +12 -0
  82. package/extension-DOD67G1k.js +13 -0
  83. package/external-link-CZkQS5XK.js +13 -0
  84. package/external-link-ClYNKSPt.mjs +12 -0
  85. package/facebook-CFjrd4my.mjs +30 -0
  86. package/facebook-CbE6K6AK.js +31 -0
  87. package/farcaster-Ba7_C-Vm.js +17 -0
  88. package/farcaster-DyVJtVS9.mjs +16 -0
  89. package/filters-CpHaFNjT.mjs +12 -0
  90. package/filters-w5LC-r6e.js +13 -0
  91. package/github-CeO70C3E.mjs +22 -0
  92. package/github-uLFBWAa5.js +23 -0
  93. package/google-CyOdUlbw.mjs +22 -0
  94. package/google-ILGK-opP.js +23 -0
  95. package/help-circle-Dh3dRNoB.mjs +16 -0
  96. package/help-circle-HUMbz_KN.js +17 -0
  97. package/id-Cy3Qkrvb.js +17 -0
  98. package/id-D-Q0uPFM.mjs +16 -0
  99. package/if-defined-CJ5EZLw2.js +815 -0
  100. package/if-defined-DjC5UMfF.mjs +815 -0
  101. package/image-BTGOf8bb.mjs +8 -0
  102. package/image-WFQO5bWa.js +9 -0
  103. package/index--O5ypTeK.mjs +70 -0
  104. package/index--Vg7VI9t.js +173 -0
  105. package/index-2iRSO1sa.mjs +9964 -0
  106. package/index-42Rpweo5.mjs +95 -0
  107. package/index-70kjE43k.mjs +90 -0
  108. package/index-8VyNYS01.js +273 -0
  109. package/index-B-dx8l0g.mjs +82 -0
  110. package/index-BB0nW9RB.mjs +198 -0
  111. package/index-BBwuv2SS.js +97 -0
  112. package/index-BIe-kofv.mjs +273 -0
  113. package/index-BQf6VHil.js +278 -0
  114. package/index-BWIZXhFv.mjs +630 -0
  115. package/index-BXkamf-I.js +337 -0
  116. package/index-BYTxCmKH.js +64 -0
  117. package/index-BYoOxo0S.js +218 -0
  118. package/index-Ba0tVdql.js +200 -0
  119. package/index-BdOAPWyt.mjs +210 -0
  120. package/index-BirWzf8c.mjs +71 -0
  121. package/index-BnCJUHtW.mjs +346 -0
  122. package/index-BuL2FC61.mjs +216 -0
  123. package/index-BxSUTfaY.js +88 -0
  124. package/index-C49C5Rxf.js +743 -0
  125. package/index-CNMDBpW7.js +346 -0
  126. package/index-CP0CGjqQ.mjs +263 -0
  127. package/index-CQaHcTZM.mjs +86 -0
  128. package/index-CRGXQei1.js +178 -0
  129. package/index-CSykUIfV.mjs +176 -0
  130. package/index-CWIHaLkQ.mjs +101 -0
  131. package/index-CZSDJd0P.mjs +1070 -0
  132. package/index-CZaV8JgR.mjs +49 -0
  133. package/index-CZjdy6QP.js +101 -0
  134. package/index-C_lIGGlC.js +632 -0
  135. package/index-CcgeRPs2.mjs +57 -0
  136. package/index-CeY_DRuc.js +566 -0
  137. package/index-ChFNkSxT.js +92 -0
  138. package/index-CkjZc20w.js +677 -0
  139. package/index-CtFcWwAd.js +72 -0
  140. package/index-D0mOfznC.mjs +362 -0
  141. package/index-DAtWLY21.js +84 -0
  142. package/index-DEs8H3w2.js +262 -0
  143. package/index-DLnxotbC.mjs +566 -0
  144. package/index-DN4fGDgg.mjs +743 -0
  145. package/index-DT_mc1hV.mjs +335 -0
  146. package/index-DZEwxUMS.js +59 -0
  147. package/index-DaRH_4bD.js +9939 -0
  148. package/index-Daok2ZKn.js +73 -0
  149. package/index-DomzHmwk.js +210 -0
  150. package/index-Dx7NyDyv.mjs +101 -0
  151. package/index-DyGir6_2.mjs +675 -0
  152. package/index-GglJmM2C.js +2237 -0
  153. package/index-H5b7UTeJ.mjs +173 -0
  154. package/index-NNZ1lNuc.mjs +168 -0
  155. package/index-RJd-gQcv.mjs +2235 -0
  156. package/index-dnFzVpGy.js +103 -0
  157. package/index-kwVLu8EV.js +168 -0
  158. package/index-miQwZPmn.js +51 -0
  159. package/index-oCj_SpOa.mjs +62 -0
  160. package/index-pNK-h_x9.js +1069 -0
  161. package/index-r6Kre1rx.js +362 -0
  162. package/index-xBD0nXoB.mjs +276 -0
  163. package/index.js +3 -3
  164. package/index.mjs +3 -3
  165. package/info-BKNAiN0k.js +8 -0
  166. package/info-DQE0s-A4.mjs +7 -0
  167. package/info-circle-C3uTocjH.js +17 -0
  168. package/info-circle-CIn6yeQo.mjs +16 -0
  169. package/lightbulb-CB-BmIop.js +8 -0
  170. package/lightbulb-Gv7IbnzO.mjs +7 -0
  171. package/mail-CFYm95wn.mjs +12 -0
  172. package/mail-GEwk-Fzr.js +13 -0
  173. package/mobile-CZ7ZBfa5.js +14 -0
  174. package/mobile-OIbnpFsU.mjs +13 -0
  175. package/more-C8N_RV55.mjs +15 -0
  176. package/more-CiQpPZwq.js +16 -0
  177. package/network-placeholder-CxEcczEx.mjs +18 -0
  178. package/network-placeholder-DwR8E8hP.js +19 -0
  179. package/nftPlaceholder-BFexVcGX.js +13 -0
  180. package/nftPlaceholder-MiYL110I.mjs +12 -0
  181. package/off-BNiMlpUU.mjs +8 -0
  182. package/off-iJHSK3Z7.js +9 -0
  183. package/onramp-Bs8HHFFY.js +1474 -0
  184. package/onramp-C6fuQfX7.mjs +1480 -0
  185. package/package.json +11 -11
  186. package/play-store-B4ssIYUA.js +37 -0
  187. package/play-store-D6nmQXhX.mjs +36 -0
  188. package/plus-Bh7z7Oc0.js +18 -0
  189. package/plus-C8ioZuCD.mjs +17 -0
  190. package/qr-code-CSVwaBLf.mjs +10 -0
  191. package/qr-code-YgtXPokK.js +11 -0
  192. package/react-BWxe90Ar.mjs +6342 -0
  193. package/react-BzZcQig5.js +6342 -0
  194. package/react-C_wTMVq_.js +23003 -0
  195. package/react-M-DnxvZl.mjs +23003 -0
  196. package/reactjs/components/BridgeForm/BridgeForm.js +2 -1
  197. package/reactjs/components/BridgeForm/BridgeForm.mjs +2 -1
  198. package/reactjs/components/Connect/BridgeAccountDisplay.js +3 -2
  199. package/reactjs/components/Connect/BridgeAccountDisplay.mjs +3 -2
  200. package/reactjs/components/Connect/CustomConnectButton.js +3 -2
  201. package/reactjs/components/Connect/CustomConnectButton.mjs +3 -2
  202. package/reactjs/components/Connect/SwitchChainButton.js +4 -3
  203. package/reactjs/components/Connect/SwitchChainButton.mjs +4 -3
  204. package/reactjs/components/DisplayAmount/DisplayAmount.js +1 -1
  205. package/reactjs/components/DisplayAmount/DisplayAmount.mjs +1 -1
  206. package/reactjs/components/TokenSelector/components/TokenItem.js +1 -1
  207. package/reactjs/components/TokenSelector/components/TokenItem.mjs +1 -1
  208. package/reactjs/hooks/useAccount.d.ts +4 -4
  209. package/reactjs/hooks/useAccount.js +3 -2
  210. package/reactjs/hooks/useAccount.mjs +3 -2
  211. package/reactjs/hooks/useGetChainId.js +1 -1
  212. package/reactjs/hooks/useGetChainId.mjs +1 -1
  213. package/reactjs/index.js +3 -3
  214. package/reactjs/index.mjs +3 -3
  215. package/reactjs/init/init.js +4 -3
  216. package/reactjs/init/init.mjs +4 -3
  217. package/reactjs/init/tests/init.spec.js +2 -2
  218. package/reactjs/init/tests/init.spec.mjs +2 -2
  219. package/reactjs/queries/useGetEvmTokensBalances.query.js +3 -2
  220. package/reactjs/queries/useGetEvmTokensBalances.query.mjs +3 -2
  221. package/reactjs/reexports.js +3 -3
  222. package/reactjs/reexports.mjs +3 -3
  223. package/reactjs/utils/getCleanStringAmount.js +1 -1
  224. package/reactjs/utils/getCleanStringAmount.mjs +1 -1
  225. package/reactjs/utils/hasEnoughFunds.js +1 -1
  226. package/reactjs/utils/hasEnoughFunds.mjs +1 -1
  227. package/reactjs/utils/isStringFloat.js +1 -1
  228. package/reactjs/utils/isStringFloat.mjs +1 -1
  229. package/reactjs/utils/roundAmount.js +1 -1
  230. package/reactjs/utils/roundAmount.mjs +1 -1
  231. package/receive-CK0hRQPr.js +212 -0
  232. package/receive-CQcD6bZf.mjs +212 -0
  233. package/recycle-horizontal--x5cMoTE.js +14 -0
  234. package/recycle-horizontal-QI0xtDHK.mjs +13 -0
  235. package/ref-CqxfRkBm.mjs +41 -0
  236. package/ref-FGI2cUQB.js +41 -0
  237. package/refresh-CFNHjhDi.js +13 -0
  238. package/refresh-CSOC1NUY.mjs +12 -0
  239. package/reown-logo-BfU5xFX5.js +17 -0
  240. package/reown-logo-CZAEp1jU.mjs +16 -0
  241. package/search-Do_rb-9-.mjs +12 -0
  242. package/search-V9CGMHkm.js +13 -0
  243. package/send-D-5G7tDL.mjs +1204 -0
  244. package/send-D4yYsIHV.mjs +19 -0
  245. package/send-DoiSHLsX.js +1202 -0
  246. package/send-_jfNFrys.js +20 -0
  247. package/socials-BL7-97fT.mjs +758 -0
  248. package/socials-DF0CK9cN.js +756 -0
  249. package/solana-BQ0Jh8lh.js +18 -0
  250. package/solana-YAkDp6j_.mjs +17 -0
  251. package/swapHorizontal-DOIo-Ccx.mjs +12 -0
  252. package/swapHorizontal-OHKtz4Gu.js +13 -0
  253. package/swapHorizontalBold-D7QmFj-c.js +13 -0
  254. package/swapHorizontalBold-DDroA0Af.mjs +12 -0
  255. package/swapHorizontalMedium-CU_v0kFz.mjs +20 -0
  256. package/swapHorizontalMedium-D-yMmtml.js +21 -0
  257. package/swapHorizontalRoundedBold-CHvbmnjw.js +13 -0
  258. package/swapHorizontalRoundedBold-DXMH0sgK.mjs +12 -0
  259. package/swapVertical-CH7fTK6w.js +13 -0
  260. package/swapVertical-HJZ6rFcr.mjs +12 -0
  261. package/swaps-CETflhdU.js +1952 -0
  262. package/swaps-DRUV6d3p.mjs +1954 -0
  263. package/telegram-CsCauOwj.mjs +20 -0
  264. package/telegram-DKEcF_Tq.js +21 -0
  265. package/three-dots-B-7hr8Nl.js +10 -0
  266. package/three-dots-LNZ_fjP7.mjs +9 -0
  267. package/transactions-BTTsGV2W.mjs +37 -0
  268. package/transactions-mpNNlClw.js +37 -0
  269. package/twitch-CCWVT2ij.js +23 -0
  270. package/twitch-Dg1CCQvd.mjs +22 -0
  271. package/twitterIcon-BjR09Cj9.mjs +10 -0
  272. package/twitterIcon-CeEs0iDJ.js +11 -0
  273. package/verify-B8WZq7kt.mjs +12 -0
  274. package/verify-filled-BeqC1imk.mjs +12 -0
  275. package/verify-filled-C-mv3ApD.js +13 -0
  276. package/verify-yATdPqt-.js +13 -0
  277. package/w3m-modal-3GziKj7h.js +1254 -0
  278. package/w3m-modal-81Z5PngE.mjs +1255 -0
  279. package/wallet-BMXEH23x.js +13 -0
  280. package/wallet-CNAVQCfm.mjs +12 -0
  281. package/wallet-placeholder-CQ-7CmVN.mjs +18 -0
  282. package/wallet-placeholder-CdoQy2e6.js +19 -0
  283. package/walletconnect-ACr-R1QZ.mjs +38 -0
  284. package/walletconnect-BWSkiS2F.js +39 -0
  285. package/warning-circle-CYnuYwpt.js +17 -0
  286. package/warning-circle-HV2lOiCj.mjs +16 -0
  287. package/x-CW5dozRj.js +17 -0
  288. package/x-Cgm2OFpL.mjs +16 -0
  289. package/x-mark-CR8SpZvu.js +8 -0
  290. package/x-mark-u0KJjUJ1.mjs +7 -0
  291. package/index-B4Eq5P3w.mjs +0 -91
  292. package/index-C4WV9nam.js +0 -329
  293. package/index-CWMcKi_X.js +0 -107
  294. package/index-D8E0O3qL.mjs +0 -68744
  295. package/index-DJ8CdHSw.mjs +0 -107
  296. package/index-nigVQYBu.js +0 -68665
  297. package/react-C43nEIqn.js +0 -3133
  298. package/react-DKUsVej7.js +0 -50
  299. package/react-Dp0H8q2z.mjs +0 -50
  300. package/react-wMhOUFOm.mjs +0 -3133
  301. package/w3m-modal-DLyg7Voy.js +0 -356
  302. package/w3m-modal-hC-B8qZP.mjs +0 -356
@@ -0,0 +1,1952 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
+ const bitcoin = require("./bitcoin-DAvQGpeP.js");
5
+ const ifDefined = require("./if-defined-CJ5EZLw2.js");
6
+ require("./index-BXkamf-I.js");
7
+ const index$1 = require("./index-CZjdy6QP.js");
8
+ require("./index-kwVLu8EV.js");
9
+ const react = require("./react-BzZcQig5.js");
10
+ const index = require("./index-C49C5Rxf.js");
11
+ require("./index-DAtWLY21.js");
12
+ require("./index-BQf6VHil.js");
13
+ require("./index-CtFcWwAd.js");
14
+ const InputUtil = {
15
+ numericInputKeyDown(event, currentValue, onChange) {
16
+ const allowedKeys = [
17
+ "Backspace",
18
+ "Meta",
19
+ "Ctrl",
20
+ "a",
21
+ "A",
22
+ "c",
23
+ "C",
24
+ "x",
25
+ "X",
26
+ "v",
27
+ "V",
28
+ "ArrowLeft",
29
+ "ArrowRight",
30
+ "Tab"
31
+ ];
32
+ const controlPressed = event.metaKey || event.ctrlKey;
33
+ const eventKey = event.key;
34
+ const lowercaseEventKey = eventKey.toLocaleLowerCase();
35
+ const selectAll = lowercaseEventKey === "a";
36
+ const copyKey = lowercaseEventKey === "c";
37
+ const pasteKey = lowercaseEventKey === "v";
38
+ const cutKey = lowercaseEventKey === "x";
39
+ const isComma = eventKey === ",";
40
+ const isDot = eventKey === ".";
41
+ const isNumericKey = eventKey >= "0" && eventKey <= "9";
42
+ if (!controlPressed && (selectAll || copyKey || pasteKey || cutKey)) {
43
+ event.preventDefault();
44
+ }
45
+ if (currentValue === "0" && !isComma && !isDot && eventKey === "0") {
46
+ event.preventDefault();
47
+ }
48
+ if (currentValue === "0" && isNumericKey) {
49
+ onChange(eventKey);
50
+ event.preventDefault();
51
+ }
52
+ if (isComma || isDot) {
53
+ if (!currentValue) {
54
+ onChange("0.");
55
+ event.preventDefault();
56
+ }
57
+ if ((currentValue == null ? void 0 : currentValue.includes(".")) || (currentValue == null ? void 0 : currentValue.includes(","))) {
58
+ event.preventDefault();
59
+ }
60
+ }
61
+ if (!isNumericKey && !allowedKeys.includes(eventKey) && !isDot && !isComma) {
62
+ event.preventDefault();
63
+ }
64
+ }
65
+ };
66
+ const styles$6 = bitcoin.i`
67
+ :host {
68
+ width: 100%;
69
+ }
70
+
71
+ .details-container > wui-flex {
72
+ background: var(--wui-color-gray-glass-002);
73
+ border-radius: var(--wui-border-radius-xxs);
74
+ width: 100%;
75
+ }
76
+
77
+ .details-container > wui-flex > button {
78
+ border: none;
79
+ background: none;
80
+ padding: var(--wui-spacing-s);
81
+ border-radius: var(--wui-border-radius-xxs);
82
+ cursor: pointer;
83
+ }
84
+
85
+ .details-content-container {
86
+ padding: var(--wui-spacing-1xs);
87
+ padding-top: 0px;
88
+ display: flex;
89
+ align-items: center;
90
+ justify-content: center;
91
+ }
92
+
93
+ .details-content-container > wui-flex {
94
+ width: 100%;
95
+ }
96
+
97
+ .details-row {
98
+ width: 100%;
99
+ padding: var(--wui-spacing-s);
100
+ padding-left: var(--wui-spacing-s);
101
+ padding-right: var(--wui-spacing-1xs);
102
+ border-radius: calc(var(--wui-border-radius-5xs) + var(--wui-border-radius-4xs));
103
+ background: var(--wui-color-gray-glass-002);
104
+ }
105
+
106
+ .details-row-title {
107
+ white-space: nowrap;
108
+ }
109
+
110
+ .details-row.provider-free-row {
111
+ padding-right: var(--wui-spacing-xs);
112
+ }
113
+ `;
114
+ var __decorate$6 = function(decorators, target, key, desc) {
115
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
116
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
117
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
118
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
119
+ };
120
+ const slippageRate = react.ConstantsUtil.CONVERT_SLIPPAGE_TOLERANCE;
121
+ let WuiSwapDetails = class WuiSwapDetails2 extends bitcoin.i$1 {
122
+ constructor() {
123
+ var _a;
124
+ super();
125
+ this.unsubscribe = [];
126
+ this.networkName = (_a = react.ChainController.state.activeCaipNetwork) == null ? void 0 : _a.name;
127
+ this.detailsOpen = false;
128
+ this.sourceToken = index.SwapController.state.sourceToken;
129
+ this.toToken = index.SwapController.state.toToken;
130
+ this.toTokenAmount = index.SwapController.state.toTokenAmount;
131
+ this.sourceTokenPriceInUSD = index.SwapController.state.sourceTokenPriceInUSD;
132
+ this.toTokenPriceInUSD = index.SwapController.state.toTokenPriceInUSD;
133
+ this.priceImpact = index.SwapController.state.priceImpact;
134
+ this.maxSlippage = index.SwapController.state.maxSlippage;
135
+ this.networkTokenSymbol = index.SwapController.state.networkTokenSymbol;
136
+ this.inputError = index.SwapController.state.inputError;
137
+ this.unsubscribe.push(...[
138
+ index.SwapController.subscribe((newState) => {
139
+ this.sourceToken = newState.sourceToken;
140
+ this.toToken = newState.toToken;
141
+ this.toTokenAmount = newState.toTokenAmount;
142
+ this.priceImpact = newState.priceImpact;
143
+ this.maxSlippage = newState.maxSlippage;
144
+ this.sourceTokenPriceInUSD = newState.sourceTokenPriceInUSD;
145
+ this.toTokenPriceInUSD = newState.toTokenPriceInUSD;
146
+ this.inputError = newState.inputError;
147
+ })
148
+ ]);
149
+ }
150
+ render() {
151
+ const minReceivedAmount = this.toTokenAmount && this.maxSlippage ? react.NumberUtil.bigNumber(this.toTokenAmount).minus(this.maxSlippage).toString() : null;
152
+ if (!this.sourceToken || !this.toToken || this.inputError) {
153
+ return null;
154
+ }
155
+ const toTokenSwappedAmount = this.sourceTokenPriceInUSD && this.toTokenPriceInUSD ? 1 / this.toTokenPriceInUSD * this.sourceTokenPriceInUSD : 0;
156
+ return bitcoin.x`
157
+ <wui-flex flexDirection="column" alignItems="center" gap="1xs" class="details-container">
158
+ <wui-flex flexDirection="column">
159
+ <button @click=${this.toggleDetails.bind(this)}>
160
+ <wui-flex justifyContent="space-between" .padding=${["0", "xs", "0", "xs"]}>
161
+ <wui-flex justifyContent="flex-start" flexGrow="1" gap="xs">
162
+ <wui-text variant="small-400" color="fg-100">
163
+ 1 ${this.sourceToken.symbol} =
164
+ ${ifDefined.UiHelperUtil.formatNumberToLocalString(toTokenSwappedAmount, 3)}
165
+ ${this.toToken.symbol}
166
+ </wui-text>
167
+ <wui-text variant="small-400" color="fg-200">
168
+ $${ifDefined.UiHelperUtil.formatNumberToLocalString(this.sourceTokenPriceInUSD)}
169
+ </wui-text>
170
+ </wui-flex>
171
+ <wui-icon name="chevronBottom"></wui-icon>
172
+ </wui-flex>
173
+ </button>
174
+ ${this.detailsOpen ? bitcoin.x`
175
+ <wui-flex flexDirection="column" gap="xs" class="details-content-container">
176
+ ${this.priceImpact ? bitcoin.x` <wui-flex flexDirection="column" gap="xs">
177
+ <wui-flex
178
+ justifyContent="space-between"
179
+ alignItems="center"
180
+ class="details-row"
181
+ >
182
+ <wui-flex alignItems="center" gap="xs">
183
+ <wui-text class="details-row-title" variant="small-400" color="fg-150">
184
+ Price impact
185
+ </wui-text>
186
+ <w3m-tooltip-trigger
187
+ text="Price impact reflects the change in market price due to your trade"
188
+ >
189
+ <wui-icon size="xs" color="fg-250" name="infoCircle"></wui-icon>
190
+ </w3m-tooltip-trigger>
191
+ </wui-flex>
192
+ <wui-flex>
193
+ <wui-text variant="small-400" color="fg-200">
194
+ ${ifDefined.UiHelperUtil.formatNumberToLocalString(this.priceImpact, 3)}%
195
+ </wui-text>
196
+ </wui-flex>
197
+ </wui-flex>
198
+ </wui-flex>` : null}
199
+ ${this.maxSlippage && this.sourceToken.symbol ? bitcoin.x`<wui-flex flexDirection="column" gap="xs">
200
+ <wui-flex
201
+ justifyContent="space-between"
202
+ alignItems="center"
203
+ class="details-row"
204
+ >
205
+ <wui-flex alignItems="center" gap="xs">
206
+ <wui-text class="details-row-title" variant="small-400" color="fg-150">
207
+ Max. slippage
208
+ </wui-text>
209
+ <w3m-tooltip-trigger
210
+ text=${`Max slippage sets the minimum amount you must receive for the transaction to proceed. ${minReceivedAmount ? `Transaction will be reversed if you receive less than ${ifDefined.UiHelperUtil.formatNumberToLocalString(minReceivedAmount, 6)} ${this.toToken.symbol} due to price changes.` : ""}`}
211
+ >
212
+ <wui-icon size="xs" color="fg-250" name="infoCircle"></wui-icon>
213
+ </w3m-tooltip-trigger>
214
+ </wui-flex>
215
+ <wui-flex>
216
+ <wui-text variant="small-400" color="fg-200">
217
+ ${ifDefined.UiHelperUtil.formatNumberToLocalString(this.maxSlippage, 6)}
218
+ ${this.toToken.symbol} ${slippageRate}%
219
+ </wui-text>
220
+ </wui-flex>
221
+ </wui-flex>
222
+ </wui-flex>` : null}
223
+ <wui-flex flexDirection="column" gap="xs">
224
+ <wui-flex
225
+ justifyContent="space-between"
226
+ alignItems="center"
227
+ class="details-row provider-free-row"
228
+ >
229
+ <wui-flex alignItems="center" gap="xs">
230
+ <wui-text class="details-row-title" variant="small-400" color="fg-150">
231
+ Provider fee
232
+ </wui-text>
233
+ </wui-flex>
234
+ <wui-flex>
235
+ <wui-text variant="small-400" color="fg-200">0.85%</wui-text>
236
+ </wui-flex>
237
+ </wui-flex>
238
+ </wui-flex>
239
+ </wui-flex>
240
+ ` : null}
241
+ </wui-flex>
242
+ </wui-flex>
243
+ `;
244
+ }
245
+ toggleDetails() {
246
+ this.detailsOpen = !this.detailsOpen;
247
+ }
248
+ };
249
+ WuiSwapDetails.styles = [styles$6];
250
+ __decorate$6([
251
+ ifDefined.r()
252
+ ], WuiSwapDetails.prototype, "networkName", void 0);
253
+ __decorate$6([
254
+ ifDefined.n()
255
+ ], WuiSwapDetails.prototype, "detailsOpen", void 0);
256
+ __decorate$6([
257
+ ifDefined.r()
258
+ ], WuiSwapDetails.prototype, "sourceToken", void 0);
259
+ __decorate$6([
260
+ ifDefined.r()
261
+ ], WuiSwapDetails.prototype, "toToken", void 0);
262
+ __decorate$6([
263
+ ifDefined.r()
264
+ ], WuiSwapDetails.prototype, "toTokenAmount", void 0);
265
+ __decorate$6([
266
+ ifDefined.r()
267
+ ], WuiSwapDetails.prototype, "sourceTokenPriceInUSD", void 0);
268
+ __decorate$6([
269
+ ifDefined.r()
270
+ ], WuiSwapDetails.prototype, "toTokenPriceInUSD", void 0);
271
+ __decorate$6([
272
+ ifDefined.r()
273
+ ], WuiSwapDetails.prototype, "priceImpact", void 0);
274
+ __decorate$6([
275
+ ifDefined.r()
276
+ ], WuiSwapDetails.prototype, "maxSlippage", void 0);
277
+ __decorate$6([
278
+ ifDefined.r()
279
+ ], WuiSwapDetails.prototype, "networkTokenSymbol", void 0);
280
+ __decorate$6([
281
+ ifDefined.r()
282
+ ], WuiSwapDetails.prototype, "inputError", void 0);
283
+ WuiSwapDetails = __decorate$6([
284
+ ifDefined.customElement("w3m-swap-details")
285
+ ], WuiSwapDetails);
286
+ const styles$5 = bitcoin.i`
287
+ :host {
288
+ width: 100%;
289
+ }
290
+
291
+ :host > wui-flex {
292
+ display: flex;
293
+ flex-direction: row;
294
+ justify-content: space-between;
295
+ align-items: center;
296
+ border-radius: var(--wui-border-radius-s);
297
+ padding: var(--wui-spacing-xl);
298
+ padding-right: var(--wui-spacing-s);
299
+ background-color: var(--wui-color-gray-glass-002);
300
+ box-shadow: inset 0px 0px 0px 1px var(--wui-color-gray-glass-002);
301
+ width: 100%;
302
+ height: 100px;
303
+ box-sizing: border-box;
304
+ position: relative;
305
+ }
306
+
307
+ wui-shimmer.market-value {
308
+ opacity: 0;
309
+ }
310
+
311
+ :host > wui-flex > svg.input_mask {
312
+ position: absolute;
313
+ inset: 0;
314
+ z-index: 5;
315
+ }
316
+
317
+ :host wui-flex .input_mask__border,
318
+ :host wui-flex .input_mask__background {
319
+ transition: fill var(--wui-duration-md) var(--wui-ease-out-power-1);
320
+ will-change: fill;
321
+ }
322
+
323
+ :host wui-flex .input_mask__border {
324
+ fill: var(--wui-color-gray-glass-020);
325
+ }
326
+
327
+ :host wui-flex .input_mask__background {
328
+ fill: var(--wui-color-gray-glass-002);
329
+ }
330
+ `;
331
+ var __decorate$5 = function(decorators, target, key, desc) {
332
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
333
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
334
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
335
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
336
+ };
337
+ let W3mSwapInputSkeleton = class W3mSwapInputSkeleton2 extends bitcoin.i$1 {
338
+ constructor() {
339
+ super(...arguments);
340
+ this.target = "sourceToken";
341
+ }
342
+ render() {
343
+ return bitcoin.x`
344
+ <wui-flex class justifyContent="space-between">
345
+ <wui-flex
346
+ flex="1"
347
+ flexDirection="column"
348
+ alignItems="flex-start"
349
+ justifyContent="center"
350
+ class="swap-input"
351
+ gap="xxs"
352
+ >
353
+ <wui-shimmer width="80px" height="40px" borderRadius="xxs" variant="light"></wui-shimmer>
354
+ </wui-flex>
355
+ ${this.templateTokenSelectButton()}
356
+ </wui-flex>
357
+ `;
358
+ }
359
+ templateTokenSelectButton() {
360
+ return bitcoin.x`
361
+ <wui-flex
362
+ class="swap-token-button"
363
+ flexDirection="column"
364
+ alignItems="flex-end"
365
+ justifyContent="center"
366
+ gap="xxs"
367
+ >
368
+ <wui-shimmer width="80px" height="40px" borderRadius="3xl" variant="light"></wui-shimmer>
369
+ </wui-flex>
370
+ `;
371
+ }
372
+ };
373
+ W3mSwapInputSkeleton.styles = [styles$5];
374
+ __decorate$5([
375
+ ifDefined.n()
376
+ ], W3mSwapInputSkeleton.prototype, "target", void 0);
377
+ W3mSwapInputSkeleton = __decorate$5([
378
+ ifDefined.customElement("w3m-swap-input-skeleton")
379
+ ], W3mSwapInputSkeleton);
380
+ const styles$4 = bitcoin.i`
381
+ :host > wui-flex {
382
+ display: flex;
383
+ flex-direction: row;
384
+ justify-content: space-between;
385
+ align-items: center;
386
+ border-radius: var(--wui-border-radius-s);
387
+ background-color: var(--wui-color-gray-glass-002);
388
+ padding: var(--wui-spacing-xl);
389
+ padding-right: var(--wui-spacing-s);
390
+ width: 100%;
391
+ height: 100px;
392
+ box-sizing: border-box;
393
+ box-shadow: inset 0px 0px 0px 1px var(--wui-color-gray-glass-002);
394
+ position: relative;
395
+ transition: box-shadow var(--wui-ease-out-power-1) var(--wui-duration-lg);
396
+ will-change: background-color;
397
+ }
398
+
399
+ :host wui-flex.focus {
400
+ box-shadow: inset 0px 0px 0px 1px var(--wui-color-gray-glass-005);
401
+ }
402
+
403
+ :host > wui-flex .swap-input,
404
+ :host > wui-flex .swap-token-button {
405
+ z-index: 10;
406
+ }
407
+
408
+ :host > wui-flex .swap-input {
409
+ -webkit-mask-image: linear-gradient(
410
+ 270deg,
411
+ transparent 0px,
412
+ transparent 8px,
413
+ black 24px,
414
+ black 25px,
415
+ black 32px,
416
+ black 100%
417
+ );
418
+ mask-image: linear-gradient(
419
+ 270deg,
420
+ transparent 0px,
421
+ transparent 8px,
422
+ black 24px,
423
+ black 25px,
424
+ black 32px,
425
+ black 100%
426
+ );
427
+ }
428
+
429
+ :host > wui-flex .swap-input input {
430
+ background: none;
431
+ border: none;
432
+ height: 42px;
433
+ width: 100%;
434
+ font-size: 32px;
435
+ font-style: normal;
436
+ font-weight: 400;
437
+ line-height: 130%;
438
+ letter-spacing: -1.28px;
439
+ outline: none;
440
+ caret-color: var(--wui-color-accent-100);
441
+ color: var(--wui-color-fg-100);
442
+ padding: 0px;
443
+ }
444
+
445
+ :host > wui-flex .swap-input input:focus-visible {
446
+ outline: none;
447
+ }
448
+
449
+ :host > wui-flex .swap-input input::-webkit-outer-spin-button,
450
+ :host > wui-flex .swap-input input::-webkit-inner-spin-button {
451
+ -webkit-appearance: none;
452
+ margin: 0;
453
+ }
454
+
455
+ .max-value-button {
456
+ background-color: transparent;
457
+ border: none;
458
+ cursor: pointer;
459
+ color: var(--wui-color-gray-glass-020);
460
+ padding-left: 0px;
461
+ }
462
+
463
+ .market-value {
464
+ min-height: 18px;
465
+ }
466
+ `;
467
+ var __decorate$4 = function(decorators, target, key, desc) {
468
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
469
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
470
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
471
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
472
+ };
473
+ const MINIMUM_USD_VALUE_TO_CONVERT = 5e-5;
474
+ let W3mSwapInput = class W3mSwapInput2 extends bitcoin.i$1 {
475
+ constructor() {
476
+ super(...arguments);
477
+ this.focused = false;
478
+ this.price = 0;
479
+ this.target = "sourceToken";
480
+ this.onSetAmount = null;
481
+ this.onSetMaxValue = null;
482
+ }
483
+ render() {
484
+ const marketValue = this.marketValue || "0";
485
+ const isMarketValueGreaterThanZero = react.NumberUtil.bigNumber(marketValue).gt("0");
486
+ return bitcoin.x`
487
+ <wui-flex class="${this.focused ? "focus" : ""}" justifyContent="space-between">
488
+ <wui-flex
489
+ flex="1"
490
+ flexDirection="column"
491
+ alignItems="flex-start"
492
+ justifyContent="center"
493
+ class="swap-input"
494
+ >
495
+ <input
496
+ data-testid="swap-input-${this.target}"
497
+ @focusin=${() => this.onFocusChange(true)}
498
+ @focusout=${() => this.onFocusChange(false)}
499
+ ?disabled=${this.disabled}
500
+ .value=${this.value}
501
+ @input=${this.dispatchInputChangeEvent}
502
+ @keydown=${this.handleKeydown}
503
+ placeholder="0"
504
+ type="text"
505
+ inputmode="decimal"
506
+ />
507
+ <wui-text class="market-value" variant="small-400" color="fg-200">
508
+ ${isMarketValueGreaterThanZero ? `$${ifDefined.UiHelperUtil.formatNumberToLocalString(this.marketValue, 2)}` : null}
509
+ </wui-text>
510
+ </wui-flex>
511
+ ${this.templateTokenSelectButton()}
512
+ </wui-flex>
513
+ `;
514
+ }
515
+ handleKeydown(event) {
516
+ return InputUtil.numericInputKeyDown(event, this.value, (value) => {
517
+ var _a;
518
+ return (_a = this.onSetAmount) == null ? void 0 : _a.call(this, this.target, value);
519
+ });
520
+ }
521
+ dispatchInputChangeEvent(event) {
522
+ if (!this.onSetAmount) {
523
+ return;
524
+ }
525
+ const value = event.target.value.replace(/[^0-9.]/gu, "");
526
+ if (value === "," || value === ".") {
527
+ this.onSetAmount(this.target, "0.");
528
+ } else if (value.endsWith(",")) {
529
+ this.onSetAmount(this.target, value.replace(",", "."));
530
+ } else {
531
+ this.onSetAmount(this.target, value);
532
+ }
533
+ }
534
+ setMaxValueToInput() {
535
+ var _a;
536
+ (_a = this.onSetMaxValue) == null ? void 0 : _a.call(this, this.target, this.balance);
537
+ }
538
+ templateTokenSelectButton() {
539
+ if (!this.token) {
540
+ return bitcoin.x` <wui-button
541
+ data-testid="swap-select-token-button-${this.target}"
542
+ class="swap-token-button"
543
+ size="md"
544
+ variant="accent"
545
+ @click=${this.onSelectToken.bind(this)}
546
+ >
547
+ Select token
548
+ </wui-button>`;
549
+ }
550
+ return bitcoin.x`
551
+ <wui-flex
552
+ class="swap-token-button"
553
+ flexDirection="column"
554
+ alignItems="flex-end"
555
+ justifyContent="center"
556
+ gap="xxs"
557
+ >
558
+ <wui-token-button
559
+ data-testid="swap-input-token-${this.target}"
560
+ text=${this.token.symbol}
561
+ imageSrc=${this.token.logoUri}
562
+ @click=${this.onSelectToken.bind(this)}
563
+ >
564
+ </wui-token-button>
565
+ <wui-flex alignItems="center" gap="xxs"> ${this.tokenBalanceTemplate()} </wui-flex>
566
+ </wui-flex>
567
+ `;
568
+ }
569
+ tokenBalanceTemplate() {
570
+ const balanceValueInUSD = react.NumberUtil.multiply(this.balance, this.price);
571
+ const haveBalance = balanceValueInUSD ? balanceValueInUSD == null ? void 0 : balanceValueInUSD.gt(MINIMUM_USD_VALUE_TO_CONVERT) : false;
572
+ return bitcoin.x`
573
+ ${haveBalance ? bitcoin.x`<wui-text variant="small-400" color="fg-200">
574
+ ${ifDefined.UiHelperUtil.formatNumberToLocalString(this.balance, 2)}
575
+ </wui-text>` : null}
576
+ ${this.target === "sourceToken" ? this.tokenActionButtonTemplate(haveBalance) : null}
577
+ `;
578
+ }
579
+ tokenActionButtonTemplate(haveBalance) {
580
+ if (haveBalance) {
581
+ return bitcoin.x` <button class="max-value-button" @click=${this.setMaxValueToInput.bind(this)}>
582
+ <wui-text color="accent-100" variant="small-600">Max</wui-text>
583
+ </button>`;
584
+ }
585
+ return bitcoin.x` <button class="max-value-button" @click=${this.onBuyToken.bind(this)}>
586
+ <wui-text color="accent-100" variant="small-600">Buy</wui-text>
587
+ </button>`;
588
+ }
589
+ onFocusChange(state) {
590
+ this.focused = state;
591
+ }
592
+ onSelectToken() {
593
+ react.EventsController.sendEvent({ type: "track", event: "CLICK_SELECT_TOKEN_TO_SWAP" });
594
+ react.RouterController.push("SwapSelectToken", {
595
+ target: this.target
596
+ });
597
+ }
598
+ onBuyToken() {
599
+ react.RouterController.push("OnRampProviders");
600
+ }
601
+ };
602
+ W3mSwapInput.styles = [styles$4];
603
+ __decorate$4([
604
+ ifDefined.n()
605
+ ], W3mSwapInput.prototype, "focused", void 0);
606
+ __decorate$4([
607
+ ifDefined.n()
608
+ ], W3mSwapInput.prototype, "balance", void 0);
609
+ __decorate$4([
610
+ ifDefined.n()
611
+ ], W3mSwapInput.prototype, "value", void 0);
612
+ __decorate$4([
613
+ ifDefined.n()
614
+ ], W3mSwapInput.prototype, "price", void 0);
615
+ __decorate$4([
616
+ ifDefined.n()
617
+ ], W3mSwapInput.prototype, "marketValue", void 0);
618
+ __decorate$4([
619
+ ifDefined.n()
620
+ ], W3mSwapInput.prototype, "disabled", void 0);
621
+ __decorate$4([
622
+ ifDefined.n()
623
+ ], W3mSwapInput.prototype, "target", void 0);
624
+ __decorate$4([
625
+ ifDefined.n()
626
+ ], W3mSwapInput.prototype, "token", void 0);
627
+ __decorate$4([
628
+ ifDefined.n()
629
+ ], W3mSwapInput.prototype, "onSetAmount", void 0);
630
+ __decorate$4([
631
+ ifDefined.n()
632
+ ], W3mSwapInput.prototype, "onSetMaxValue", void 0);
633
+ W3mSwapInput = __decorate$4([
634
+ ifDefined.customElement("w3m-swap-input")
635
+ ], W3mSwapInput);
636
+ const styles$3 = bitcoin.i`
637
+ :host > wui-flex:first-child {
638
+ overflow-y: auto;
639
+ overflow-x: hidden;
640
+ scrollbar-width: none;
641
+ }
642
+
643
+ :host > wui-flex:first-child::-webkit-scrollbar {
644
+ display: none;
645
+ }
646
+
647
+ wui-loading-hexagon {
648
+ position: absolute;
649
+ }
650
+
651
+ .action-button {
652
+ width: 100%;
653
+ border-radius: var(--wui-border-radius-xs);
654
+ }
655
+
656
+ .action-button:disabled {
657
+ border-color: 1px solid var(--wui-color-gray-glass-005);
658
+ }
659
+
660
+ .swap-inputs-container {
661
+ position: relative;
662
+ }
663
+
664
+ .replace-tokens-button-container {
665
+ display: flex;
666
+ justify-content: center;
667
+ align-items: center;
668
+ position: absolute;
669
+ top: 50%;
670
+ left: 50%;
671
+ transform: translate(-50%, -50%);
672
+ gap: var(--wui-spacing-1xs);
673
+ border-radius: var(--wui-border-radius-xs);
674
+ background-color: var(--wui-color-modal-bg-base);
675
+ padding: var(--wui-spacing-xxs);
676
+ }
677
+
678
+ .replace-tokens-button-container > button {
679
+ display: flex;
680
+ justify-content: center;
681
+ align-items: center;
682
+ height: 40px;
683
+ width: 40px;
684
+ padding: var(--wui-spacing-xs);
685
+ border: none;
686
+ border-radius: var(--wui-border-radius-xxs);
687
+ background: var(--wui-color-gray-glass-002);
688
+ transition: background-color var(--wui-duration-md) var(--wui-ease-out-power-1);
689
+ will-change: background-color;
690
+ z-index: 20;
691
+ }
692
+
693
+ .replace-tokens-button-container > button:hover {
694
+ background: var(--wui-color-gray-glass-005);
695
+ }
696
+
697
+ .details-container > wui-flex {
698
+ background: var(--wui-color-gray-glass-002);
699
+ border-radius: var(--wui-border-radius-xxs);
700
+ width: 100%;
701
+ }
702
+
703
+ .details-container > wui-flex > button {
704
+ border: none;
705
+ background: none;
706
+ padding: var(--wui-spacing-s);
707
+ border-radius: var(--wui-border-radius-xxs);
708
+ transition: background 0.2s linear;
709
+ }
710
+
711
+ .details-container > wui-flex > button:hover {
712
+ background: var(--wui-color-gray-glass-002);
713
+ }
714
+
715
+ .details-content-container {
716
+ padding: var(--wui-spacing-1xs);
717
+ display: flex;
718
+ align-items: center;
719
+ justify-content: center;
720
+ }
721
+
722
+ .details-content-container > wui-flex {
723
+ width: 100%;
724
+ }
725
+
726
+ .details-row {
727
+ width: 100%;
728
+ padding: var(--wui-spacing-s) var(--wui-spacing-xl);
729
+ border-radius: var(--wui-border-radius-xxs);
730
+ background: var(--wui-color-gray-glass-002);
731
+ }
732
+ `;
733
+ var __decorate$3 = function(decorators, target, key, desc) {
734
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
735
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
736
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
737
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
738
+ };
739
+ exports.W3mSwapView = class W3mSwapView extends bitcoin.i$1 {
740
+ constructor() {
741
+ var _a, _b;
742
+ super();
743
+ this.unsubscribe = [];
744
+ this.initialParams = (_a = react.RouterController.state.data) == null ? void 0 : _a.swap;
745
+ this.detailsOpen = false;
746
+ this.caipAddress = react.AccountController.state.caipAddress;
747
+ this.caipNetworkId = (_b = react.ChainController.state.activeCaipNetwork) == null ? void 0 : _b.caipNetworkId;
748
+ this.initialized = index.SwapController.state.initialized;
749
+ this.loadingQuote = index.SwapController.state.loadingQuote;
750
+ this.loadingPrices = index.SwapController.state.loadingPrices;
751
+ this.loadingTransaction = index.SwapController.state.loadingTransaction;
752
+ this.sourceToken = index.SwapController.state.sourceToken;
753
+ this.sourceTokenAmount = index.SwapController.state.sourceTokenAmount;
754
+ this.sourceTokenPriceInUSD = index.SwapController.state.sourceTokenPriceInUSD;
755
+ this.toToken = index.SwapController.state.toToken;
756
+ this.toTokenAmount = index.SwapController.state.toTokenAmount;
757
+ this.toTokenPriceInUSD = index.SwapController.state.toTokenPriceInUSD;
758
+ this.inputError = index.SwapController.state.inputError;
759
+ this.fetchError = index.SwapController.state.fetchError;
760
+ this.onDebouncedGetSwapCalldata = react.CoreHelperUtil.debounce(async () => {
761
+ await index.SwapController.swapTokens();
762
+ }, 200);
763
+ react.ChainController.subscribeKey("activeCaipNetwork", (newCaipNetwork) => this.onCaipNetworkChange({
764
+ newCaipNetwork,
765
+ resetSwapState: true,
766
+ initializeSwapState: false
767
+ }));
768
+ react.AccountController.subscribeKey("caipAddress", (newCaipAddress) => this.onCaipAddressChange({
769
+ newCaipAddress,
770
+ resetSwapState: true,
771
+ initializeSwapState: false
772
+ }));
773
+ this.unsubscribe.push(...[
774
+ react.ChainController.subscribeKey("activeCaipNetwork", (newCaipNetwork) => this.onCaipNetworkChange({
775
+ newCaipNetwork,
776
+ resetSwapState: false,
777
+ initializeSwapState: true
778
+ })),
779
+ react.AccountController.subscribeKey("caipAddress", (newCaipAddress) => this.onCaipAddressChange({
780
+ newCaipAddress,
781
+ resetSwapState: false,
782
+ initializeSwapState: true
783
+ })),
784
+ react.ModalController.subscribeKey("open", (isOpen) => {
785
+ if (!isOpen) {
786
+ index.SwapController.resetState();
787
+ }
788
+ }),
789
+ react.RouterController.subscribeKey("view", (newRoute) => {
790
+ if (!newRoute.includes("Swap")) {
791
+ index.SwapController.resetValues();
792
+ }
793
+ }),
794
+ index.SwapController.subscribe((newState) => {
795
+ this.initialized = newState.initialized;
796
+ this.loadingQuote = newState.loadingQuote;
797
+ this.loadingPrices = newState.loadingPrices;
798
+ this.loadingTransaction = newState.loadingTransaction;
799
+ this.sourceToken = newState.sourceToken;
800
+ this.sourceTokenAmount = newState.sourceTokenAmount;
801
+ this.sourceTokenPriceInUSD = newState.sourceTokenPriceInUSD;
802
+ this.toToken = newState.toToken;
803
+ this.toTokenAmount = newState.toTokenAmount;
804
+ this.toTokenPriceInUSD = newState.toTokenPriceInUSD;
805
+ this.inputError = newState.inputError;
806
+ this.fetchError = newState.fetchError;
807
+ })
808
+ ]);
809
+ }
810
+ async firstUpdated() {
811
+ index.SwapController.initializeState();
812
+ this.watchTokensAndValues();
813
+ await this.handleSwapParameters();
814
+ }
815
+ disconnectedCallback() {
816
+ this.unsubscribe.forEach((unsubscribe) => unsubscribe == null ? void 0 : unsubscribe());
817
+ clearInterval(this.interval);
818
+ }
819
+ render() {
820
+ return bitcoin.x`
821
+ <wui-flex flexDirection="column" .padding=${["0", "l", "l", "l"]} gap="s">
822
+ ${this.initialized ? this.templateSwap() : this.templateLoading()}
823
+ </wui-flex>
824
+ `;
825
+ }
826
+ watchTokensAndValues() {
827
+ this.interval = setInterval(() => {
828
+ index.SwapController.getNetworkTokenPrice();
829
+ index.SwapController.getMyTokensWithBalance();
830
+ index.SwapController.swapTokens();
831
+ }, 1e4);
832
+ }
833
+ templateSwap() {
834
+ return bitcoin.x`
835
+ <wui-flex flexDirection="column" gap="s">
836
+ <wui-flex flexDirection="column" alignItems="center" gap="xs" class="swap-inputs-container">
837
+ ${this.templateTokenInput("sourceToken", this.sourceToken)}
838
+ ${this.templateTokenInput("toToken", this.toToken)} ${this.templateReplaceTokensButton()}
839
+ </wui-flex>
840
+ ${this.templateDetails()} ${this.templateActionButton()}
841
+ </wui-flex>
842
+ `;
843
+ }
844
+ actionButtonLabel() {
845
+ if (this.fetchError) {
846
+ return "Swap";
847
+ }
848
+ if (!this.sourceToken || !this.toToken) {
849
+ return "Select token";
850
+ }
851
+ if (!this.sourceTokenAmount) {
852
+ return "Enter amount";
853
+ }
854
+ if (this.inputError) {
855
+ return this.inputError;
856
+ }
857
+ return "Review swap";
858
+ }
859
+ templateReplaceTokensButton() {
860
+ return bitcoin.x`
861
+ <wui-flex class="replace-tokens-button-container">
862
+ <button @click=${this.onSwitchTokens.bind(this)}>
863
+ <wui-icon name="recycleHorizontal" color="fg-250" size="lg"></wui-icon>
864
+ </button>
865
+ </wui-flex>
866
+ `;
867
+ }
868
+ templateLoading() {
869
+ return bitcoin.x`
870
+ <wui-flex flexDirection="column" gap="l">
871
+ <wui-flex flexDirection="column" alignItems="center" gap="xs" class="swap-inputs-container">
872
+ <w3m-swap-input-skeleton target="sourceToken"></w3m-swap-input-skeleton>
873
+ <w3m-swap-input-skeleton target="toToken"></w3m-swap-input-skeleton>
874
+ ${this.templateReplaceTokensButton()}
875
+ </wui-flex>
876
+ ${this.templateActionButton()}
877
+ </wui-flex>
878
+ `;
879
+ }
880
+ templateTokenInput(target, token) {
881
+ var _a, _b;
882
+ const myToken = (_a = index.SwapController.state.myTokensWithBalance) == null ? void 0 : _a.find((ct) => (ct == null ? void 0 : ct.address) === (token == null ? void 0 : token.address));
883
+ const amount = target === "toToken" ? this.toTokenAmount : this.sourceTokenAmount;
884
+ const price = target === "toToken" ? this.toTokenPriceInUSD : this.sourceTokenPriceInUSD;
885
+ const marketValue = react.NumberUtil.parseLocalStringToNumber(amount) * price;
886
+ return bitcoin.x`<w3m-swap-input
887
+ .value=${target === "toToken" ? this.toTokenAmount : this.sourceTokenAmount}
888
+ .disabled=${target === "toToken"}
889
+ .onSetAmount=${this.handleChangeAmount.bind(this)}
890
+ target=${target}
891
+ .token=${token}
892
+ .balance=${(_b = myToken == null ? void 0 : myToken.quantity) == null ? void 0 : _b.numeric}
893
+ .price=${myToken == null ? void 0 : myToken.price}
894
+ .marketValue=${marketValue}
895
+ .onSetMaxValue=${this.onSetMaxValue.bind(this)}
896
+ ></w3m-swap-input>`;
897
+ }
898
+ onSetMaxValue(target, balance) {
899
+ const maxValue = react.NumberUtil.bigNumber(balance || "0");
900
+ this.handleChangeAmount(target, maxValue.gt(0) ? maxValue.toFixed(20) : "0");
901
+ }
902
+ templateDetails() {
903
+ if (!this.sourceToken || !this.toToken || this.inputError) {
904
+ return null;
905
+ }
906
+ return bitcoin.x`<w3m-swap-details .detailsOpen=${this.detailsOpen}></w3m-swap-details>`;
907
+ }
908
+ handleChangeAmount(target, value) {
909
+ index.SwapController.clearError();
910
+ if (target === "sourceToken") {
911
+ index.SwapController.setSourceTokenAmount(value);
912
+ } else {
913
+ index.SwapController.setToTokenAmount(value);
914
+ }
915
+ this.onDebouncedGetSwapCalldata();
916
+ }
917
+ templateActionButton() {
918
+ const haveNoTokenSelected = !this.toToken || !this.sourceToken;
919
+ const haveNoAmount = !this.sourceTokenAmount;
920
+ const loading = this.loadingQuote || this.loadingPrices || this.loadingTransaction;
921
+ const disabled = loading || haveNoTokenSelected || haveNoAmount || this.inputError;
922
+ return bitcoin.x` <wui-flex gap="xs">
923
+ <wui-button
924
+ data-testid="swap-action-button"
925
+ class="action-button"
926
+ fullWidth
927
+ size="lg"
928
+ borderRadius="xs"
929
+ variant=${haveNoTokenSelected ? "neutral" : "main"}
930
+ .loading=${loading}
931
+ .disabled=${disabled}
932
+ @click=${this.onSwapPreview.bind(this)}
933
+ >
934
+ ${this.actionButtonLabel()}
935
+ </wui-button>
936
+ </wui-flex>`;
937
+ }
938
+ onSwitchTokens() {
939
+ index.SwapController.switchTokens();
940
+ }
941
+ async onSwapPreview() {
942
+ var _a, _b;
943
+ const activeChainNamespace = react.ChainController.state.activeChain;
944
+ if (this.fetchError) {
945
+ await index.SwapController.swapTokens();
946
+ }
947
+ react.EventsController.sendEvent({
948
+ type: "track",
949
+ event: "INITIATE_SWAP",
950
+ properties: {
951
+ network: this.caipNetworkId || "",
952
+ swapFromToken: ((_a = this.sourceToken) == null ? void 0 : _a.symbol) || "",
953
+ swapToToken: ((_b = this.toToken) == null ? void 0 : _b.symbol) || "",
954
+ swapFromAmount: this.sourceTokenAmount || "",
955
+ swapToAmount: this.toTokenAmount || "",
956
+ isSmartAccount: react.getPreferredAccountType(activeChainNamespace) === react.W3mFrameRpcConstants.ACCOUNT_TYPES.SMART_ACCOUNT
957
+ }
958
+ });
959
+ react.RouterController.push("SwapPreview");
960
+ }
961
+ async handleSwapParameters() {
962
+ if (!this.initialParams) {
963
+ return;
964
+ }
965
+ if (!index.SwapController.state.initialized) {
966
+ const waitForInitialization = new Promise((resolve) => {
967
+ const unsubscribe = index.SwapController.subscribeKey("initialized", (initialized) => {
968
+ if (initialized) {
969
+ unsubscribe == null ? void 0 : unsubscribe();
970
+ resolve();
971
+ }
972
+ });
973
+ });
974
+ await waitForInitialization;
975
+ }
976
+ await this.setSwapParameters(this.initialParams);
977
+ }
978
+ async setSwapParameters({ amount, fromToken, toToken }) {
979
+ if (!index.SwapController.state.tokens || !index.SwapController.state.myTokensWithBalance) {
980
+ const waitForTokens = new Promise((resolve) => {
981
+ const unsubscribe = index.SwapController.subscribeKey("myTokensWithBalance", (tokens) => {
982
+ if (tokens && tokens.length > 0) {
983
+ unsubscribe == null ? void 0 : unsubscribe();
984
+ resolve();
985
+ }
986
+ });
987
+ setTimeout(() => {
988
+ unsubscribe == null ? void 0 : unsubscribe();
989
+ resolve();
990
+ }, 5e3);
991
+ });
992
+ await waitForTokens;
993
+ }
994
+ const allTokens = [
995
+ ...index.SwapController.state.tokens || [],
996
+ ...index.SwapController.state.myTokensWithBalance || []
997
+ ];
998
+ if (fromToken) {
999
+ const token = allTokens.find((t) => t.symbol.toLowerCase() === fromToken.toLowerCase());
1000
+ if (token) {
1001
+ index.SwapController.setSourceToken(token);
1002
+ }
1003
+ }
1004
+ if (toToken) {
1005
+ const token = allTokens.find((t) => t.symbol.toLowerCase() === toToken.toLowerCase());
1006
+ if (token) {
1007
+ index.SwapController.setToToken(token);
1008
+ }
1009
+ }
1010
+ if (amount && !isNaN(Number(amount))) {
1011
+ index.SwapController.setSourceTokenAmount(amount);
1012
+ }
1013
+ }
1014
+ onCaipAddressChange({ newCaipAddress, resetSwapState, initializeSwapState }) {
1015
+ if (this.caipAddress !== newCaipAddress) {
1016
+ this.caipAddress = newCaipAddress;
1017
+ if (resetSwapState) {
1018
+ index.SwapController.resetState();
1019
+ }
1020
+ if (initializeSwapState) {
1021
+ index.SwapController.initializeState();
1022
+ }
1023
+ }
1024
+ }
1025
+ onCaipNetworkChange({ newCaipNetwork, resetSwapState, initializeSwapState }) {
1026
+ if (this.caipNetworkId !== (newCaipNetwork == null ? void 0 : newCaipNetwork.caipNetworkId)) {
1027
+ this.caipNetworkId = newCaipNetwork == null ? void 0 : newCaipNetwork.caipNetworkId;
1028
+ if (resetSwapState) {
1029
+ index.SwapController.resetState();
1030
+ }
1031
+ if (initializeSwapState) {
1032
+ index.SwapController.initializeState();
1033
+ }
1034
+ }
1035
+ }
1036
+ };
1037
+ exports.W3mSwapView.styles = styles$3;
1038
+ __decorate$3([
1039
+ ifDefined.n({ type: Object })
1040
+ ], exports.W3mSwapView.prototype, "initialParams", void 0);
1041
+ __decorate$3([
1042
+ ifDefined.r()
1043
+ ], exports.W3mSwapView.prototype, "interval", void 0);
1044
+ __decorate$3([
1045
+ ifDefined.r()
1046
+ ], exports.W3mSwapView.prototype, "detailsOpen", void 0);
1047
+ __decorate$3([
1048
+ ifDefined.r()
1049
+ ], exports.W3mSwapView.prototype, "caipAddress", void 0);
1050
+ __decorate$3([
1051
+ ifDefined.r()
1052
+ ], exports.W3mSwapView.prototype, "caipNetworkId", void 0);
1053
+ __decorate$3([
1054
+ ifDefined.r()
1055
+ ], exports.W3mSwapView.prototype, "initialized", void 0);
1056
+ __decorate$3([
1057
+ ifDefined.r()
1058
+ ], exports.W3mSwapView.prototype, "loadingQuote", void 0);
1059
+ __decorate$3([
1060
+ ifDefined.r()
1061
+ ], exports.W3mSwapView.prototype, "loadingPrices", void 0);
1062
+ __decorate$3([
1063
+ ifDefined.r()
1064
+ ], exports.W3mSwapView.prototype, "loadingTransaction", void 0);
1065
+ __decorate$3([
1066
+ ifDefined.r()
1067
+ ], exports.W3mSwapView.prototype, "sourceToken", void 0);
1068
+ __decorate$3([
1069
+ ifDefined.r()
1070
+ ], exports.W3mSwapView.prototype, "sourceTokenAmount", void 0);
1071
+ __decorate$3([
1072
+ ifDefined.r()
1073
+ ], exports.W3mSwapView.prototype, "sourceTokenPriceInUSD", void 0);
1074
+ __decorate$3([
1075
+ ifDefined.r()
1076
+ ], exports.W3mSwapView.prototype, "toToken", void 0);
1077
+ __decorate$3([
1078
+ ifDefined.r()
1079
+ ], exports.W3mSwapView.prototype, "toTokenAmount", void 0);
1080
+ __decorate$3([
1081
+ ifDefined.r()
1082
+ ], exports.W3mSwapView.prototype, "toTokenPriceInUSD", void 0);
1083
+ __decorate$3([
1084
+ ifDefined.r()
1085
+ ], exports.W3mSwapView.prototype, "inputError", void 0);
1086
+ __decorate$3([
1087
+ ifDefined.r()
1088
+ ], exports.W3mSwapView.prototype, "fetchError", void 0);
1089
+ exports.W3mSwapView = __decorate$3([
1090
+ ifDefined.customElement("w3m-swap-view")
1091
+ ], exports.W3mSwapView);
1092
+ const styles$2 = bitcoin.i`
1093
+ :host > wui-flex:first-child {
1094
+ overflow-y: auto;
1095
+ overflow-x: hidden;
1096
+ scrollbar-width: none;
1097
+ }
1098
+
1099
+ :host > wui-flex:first-child::-webkit-scrollbar {
1100
+ display: none;
1101
+ }
1102
+
1103
+ .preview-container,
1104
+ .details-container {
1105
+ width: 100%;
1106
+ }
1107
+
1108
+ .token-image {
1109
+ width: 24px;
1110
+ height: 24px;
1111
+ box-shadow: 0 0 0 2px var(--wui-color-gray-glass-005);
1112
+ border-radius: 12px;
1113
+ }
1114
+
1115
+ wui-loading-hexagon {
1116
+ position: absolute;
1117
+ }
1118
+
1119
+ .token-item {
1120
+ display: flex;
1121
+ align-items: center;
1122
+ justify-content: center;
1123
+ gap: var(--wui-spacing-xxs);
1124
+ padding: var(--wui-spacing-xs);
1125
+ height: 40px;
1126
+ border: none;
1127
+ border-radius: 80px;
1128
+ background: var(--wui-color-gray-glass-002);
1129
+ box-shadow: inset 0 0 0 1px var(--wui-color-gray-glass-002);
1130
+ cursor: pointer;
1131
+ transition: background 0.2s linear;
1132
+ }
1133
+
1134
+ .token-item:hover {
1135
+ background: var(--wui-color-gray-glass-005);
1136
+ }
1137
+
1138
+ .preview-token-details-container {
1139
+ width: 100%;
1140
+ }
1141
+
1142
+ .details-row {
1143
+ width: 100%;
1144
+ padding: var(--wui-spacing-s) var(--wui-spacing-xl);
1145
+ border-radius: var(--wui-border-radius-xxs);
1146
+ background: var(--wui-color-gray-glass-002);
1147
+ }
1148
+
1149
+ .action-buttons-container {
1150
+ width: 100%;
1151
+ gap: var(--wui-spacing-xs);
1152
+ }
1153
+
1154
+ .action-buttons-container > button {
1155
+ display: flex;
1156
+ align-items: center;
1157
+ justify-content: center;
1158
+ background: transparent;
1159
+ height: 48px;
1160
+ border-radius: var(--wui-border-radius-xs);
1161
+ border: none;
1162
+ box-shadow: inset 0 0 0 1px var(--wui-color-gray-glass-010);
1163
+ }
1164
+
1165
+ .action-buttons-container > button:disabled {
1166
+ opacity: 0.8;
1167
+ cursor: not-allowed;
1168
+ }
1169
+
1170
+ .action-button > wui-loading-spinner {
1171
+ display: inline-block;
1172
+ }
1173
+
1174
+ .cancel-button:hover,
1175
+ .action-button:hover {
1176
+ cursor: pointer;
1177
+ }
1178
+
1179
+ .action-buttons-container > wui-button.cancel-button {
1180
+ flex: 2;
1181
+ }
1182
+
1183
+ .action-buttons-container > wui-button.action-button {
1184
+ flex: 4;
1185
+ }
1186
+
1187
+ .action-buttons-container > button.action-button > wui-text {
1188
+ color: white;
1189
+ }
1190
+
1191
+ .details-container > wui-flex {
1192
+ background: var(--wui-color-gray-glass-002);
1193
+ border-radius: var(--wui-border-radius-xxs);
1194
+ width: 100%;
1195
+ }
1196
+
1197
+ .details-container > wui-flex > button {
1198
+ border: none;
1199
+ background: none;
1200
+ padding: var(--wui-spacing-s);
1201
+ border-radius: var(--wui-border-radius-xxs);
1202
+ transition: background 0.2s linear;
1203
+ }
1204
+
1205
+ .details-container > wui-flex > button:hover {
1206
+ background: var(--wui-color-gray-glass-002);
1207
+ }
1208
+
1209
+ .details-content-container {
1210
+ padding: var(--wui-spacing-1xs);
1211
+ display: flex;
1212
+ align-items: center;
1213
+ justify-content: center;
1214
+ }
1215
+
1216
+ .details-content-container > wui-flex {
1217
+ width: 100%;
1218
+ }
1219
+
1220
+ .details-row {
1221
+ width: 100%;
1222
+ padding: var(--wui-spacing-s) var(--wui-spacing-xl);
1223
+ border-radius: var(--wui-border-radius-xxs);
1224
+ background: var(--wui-color-gray-glass-002);
1225
+ }
1226
+ `;
1227
+ var __decorate$2 = function(decorators, target, key, desc) {
1228
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1229
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1230
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1231
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1232
+ };
1233
+ exports.W3mSwapPreviewView = class W3mSwapPreviewView extends bitcoin.i$1 {
1234
+ constructor() {
1235
+ super();
1236
+ this.unsubscribe = [];
1237
+ this.detailsOpen = true;
1238
+ this.approvalTransaction = index.SwapController.state.approvalTransaction;
1239
+ this.swapTransaction = index.SwapController.state.swapTransaction;
1240
+ this.sourceToken = index.SwapController.state.sourceToken;
1241
+ this.sourceTokenAmount = index.SwapController.state.sourceTokenAmount ?? "";
1242
+ this.sourceTokenPriceInUSD = index.SwapController.state.sourceTokenPriceInUSD;
1243
+ this.toToken = index.SwapController.state.toToken;
1244
+ this.toTokenAmount = index.SwapController.state.toTokenAmount ?? "";
1245
+ this.toTokenPriceInUSD = index.SwapController.state.toTokenPriceInUSD;
1246
+ this.caipNetwork = react.ChainController.state.activeCaipNetwork;
1247
+ this.balanceSymbol = react.AccountController.state.balanceSymbol;
1248
+ this.inputError = index.SwapController.state.inputError;
1249
+ this.loadingQuote = index.SwapController.state.loadingQuote;
1250
+ this.loadingApprovalTransaction = index.SwapController.state.loadingApprovalTransaction;
1251
+ this.loadingBuildTransaction = index.SwapController.state.loadingBuildTransaction;
1252
+ this.loadingTransaction = index.SwapController.state.loadingTransaction;
1253
+ this.unsubscribe.push(...[
1254
+ react.AccountController.subscribeKey("balanceSymbol", (newBalanceSymbol) => {
1255
+ if (this.balanceSymbol !== newBalanceSymbol) {
1256
+ react.RouterController.goBack();
1257
+ }
1258
+ }),
1259
+ react.ChainController.subscribeKey("activeCaipNetwork", (newCaipNetwork) => {
1260
+ if (this.caipNetwork !== newCaipNetwork) {
1261
+ this.caipNetwork = newCaipNetwork;
1262
+ }
1263
+ }),
1264
+ index.SwapController.subscribe((newState) => {
1265
+ this.approvalTransaction = newState.approvalTransaction;
1266
+ this.swapTransaction = newState.swapTransaction;
1267
+ this.sourceToken = newState.sourceToken;
1268
+ this.toToken = newState.toToken;
1269
+ this.toTokenPriceInUSD = newState.toTokenPriceInUSD;
1270
+ this.sourceTokenAmount = newState.sourceTokenAmount ?? "";
1271
+ this.toTokenAmount = newState.toTokenAmount ?? "";
1272
+ this.inputError = newState.inputError;
1273
+ if (newState.inputError) {
1274
+ react.RouterController.goBack();
1275
+ }
1276
+ this.loadingQuote = newState.loadingQuote;
1277
+ this.loadingApprovalTransaction = newState.loadingApprovalTransaction;
1278
+ this.loadingBuildTransaction = newState.loadingBuildTransaction;
1279
+ this.loadingTransaction = newState.loadingTransaction;
1280
+ })
1281
+ ]);
1282
+ }
1283
+ firstUpdated() {
1284
+ index.SwapController.getTransaction();
1285
+ this.refreshTransaction();
1286
+ }
1287
+ disconnectedCallback() {
1288
+ this.unsubscribe.forEach((unsubscribe) => unsubscribe == null ? void 0 : unsubscribe());
1289
+ clearInterval(this.interval);
1290
+ }
1291
+ render() {
1292
+ return bitcoin.x`
1293
+ <wui-flex flexDirection="column" .padding=${["0", "l", "l", "l"]} gap="s">
1294
+ ${this.templateSwap()}
1295
+ </wui-flex>
1296
+ `;
1297
+ }
1298
+ refreshTransaction() {
1299
+ this.interval = setInterval(() => {
1300
+ if (!index.SwapController.getApprovalLoadingState()) {
1301
+ index.SwapController.getTransaction();
1302
+ }
1303
+ }, 1e4);
1304
+ }
1305
+ templateSwap() {
1306
+ var _a, _b, _c, _d;
1307
+ const sourceTokenText = `${ifDefined.UiHelperUtil.formatNumberToLocalString(parseFloat(this.sourceTokenAmount))} ${(_a = this.sourceToken) == null ? void 0 : _a.symbol}`;
1308
+ const toTokenText = `${ifDefined.UiHelperUtil.formatNumberToLocalString(parseFloat(this.toTokenAmount))} ${(_b = this.toToken) == null ? void 0 : _b.symbol}`;
1309
+ const sourceTokenValue = parseFloat(this.sourceTokenAmount) * this.sourceTokenPriceInUSD;
1310
+ const toTokenValue = parseFloat(this.toTokenAmount) * this.toTokenPriceInUSD;
1311
+ const sentPrice = ifDefined.UiHelperUtil.formatNumberToLocalString(sourceTokenValue);
1312
+ const receivePrice = ifDefined.UiHelperUtil.formatNumberToLocalString(toTokenValue);
1313
+ const loading = this.loadingQuote || this.loadingBuildTransaction || this.loadingTransaction || this.loadingApprovalTransaction;
1314
+ return bitcoin.x`
1315
+ <wui-flex flexDirection="column" alignItems="center" gap="l">
1316
+ <wui-flex class="preview-container" flexDirection="column" alignItems="flex-start" gap="l">
1317
+ <wui-flex
1318
+ class="preview-token-details-container"
1319
+ alignItems="center"
1320
+ justifyContent="space-between"
1321
+ gap="l"
1322
+ >
1323
+ <wui-flex flexDirection="column" alignItems="flex-start" gap="4xs">
1324
+ <wui-text variant="small-400" color="fg-150">Send</wui-text>
1325
+ <wui-text variant="paragraph-400" color="fg-100">$${sentPrice}</wui-text>
1326
+ </wui-flex>
1327
+ <wui-token-button
1328
+ flexDirection="row-reverse"
1329
+ text=${sourceTokenText}
1330
+ imageSrc=${(_c = this.sourceToken) == null ? void 0 : _c.logoUri}
1331
+ >
1332
+ </wui-token-button>
1333
+ </wui-flex>
1334
+ <wui-icon name="recycleHorizontal" color="fg-200" size="md"></wui-icon>
1335
+ <wui-flex
1336
+ class="preview-token-details-container"
1337
+ alignItems="center"
1338
+ justifyContent="space-between"
1339
+ gap="l"
1340
+ >
1341
+ <wui-flex flexDirection="column" alignItems="flex-start" gap="4xs">
1342
+ <wui-text variant="small-400" color="fg-150">Receive</wui-text>
1343
+ <wui-text variant="paragraph-400" color="fg-100">$${receivePrice}</wui-text>
1344
+ </wui-flex>
1345
+ <wui-token-button
1346
+ flexDirection="row-reverse"
1347
+ text=${toTokenText}
1348
+ imageSrc=${(_d = this.toToken) == null ? void 0 : _d.logoUri}
1349
+ >
1350
+ </wui-token-button>
1351
+ </wui-flex>
1352
+ </wui-flex>
1353
+
1354
+ ${this.templateDetails()}
1355
+
1356
+ <wui-flex flexDirection="row" alignItems="center" justifyContent="center" gap="xs">
1357
+ <wui-icon size="sm" color="fg-200" name="infoCircle"></wui-icon>
1358
+ <wui-text variant="small-400" color="fg-200">Review transaction carefully</wui-text>
1359
+ </wui-flex>
1360
+
1361
+ <wui-flex
1362
+ class="action-buttons-container"
1363
+ flexDirection="row"
1364
+ alignItems="center"
1365
+ justifyContent="space-between"
1366
+ gap="xs"
1367
+ >
1368
+ <wui-button
1369
+ class="cancel-button"
1370
+ fullWidth
1371
+ size="lg"
1372
+ borderRadius="xs"
1373
+ variant="neutral"
1374
+ @click=${this.onCancelTransaction.bind(this)}
1375
+ >
1376
+ <wui-text variant="paragraph-600" color="fg-200">Cancel</wui-text>
1377
+ </wui-button>
1378
+ <wui-button
1379
+ class="action-button"
1380
+ fullWidth
1381
+ size="lg"
1382
+ borderRadius="xs"
1383
+ variant="main"
1384
+ ?loading=${loading}
1385
+ ?disabled=${loading}
1386
+ @click=${this.onSendTransaction.bind(this)}
1387
+ >
1388
+ <wui-text variant="paragraph-600" color="inverse-100">
1389
+ ${this.actionButtonLabel()}
1390
+ </wui-text>
1391
+ </wui-button>
1392
+ </wui-flex>
1393
+ </wui-flex>
1394
+ `;
1395
+ }
1396
+ templateDetails() {
1397
+ if (!this.sourceToken || !this.toToken || this.inputError) {
1398
+ return null;
1399
+ }
1400
+ return bitcoin.x`<w3m-swap-details .detailsOpen=${this.detailsOpen}></w3m-swap-details>`;
1401
+ }
1402
+ actionButtonLabel() {
1403
+ if (this.loadingApprovalTransaction) {
1404
+ return "Approving...";
1405
+ }
1406
+ if (this.approvalTransaction) {
1407
+ return "Approve";
1408
+ }
1409
+ return "Swap";
1410
+ }
1411
+ onCancelTransaction() {
1412
+ react.RouterController.goBack();
1413
+ }
1414
+ onSendTransaction() {
1415
+ if (this.approvalTransaction) {
1416
+ index.SwapController.sendTransactionForApproval(this.approvalTransaction);
1417
+ } else {
1418
+ index.SwapController.sendTransactionForSwap(this.swapTransaction);
1419
+ }
1420
+ }
1421
+ };
1422
+ exports.W3mSwapPreviewView.styles = styles$2;
1423
+ __decorate$2([
1424
+ ifDefined.r()
1425
+ ], exports.W3mSwapPreviewView.prototype, "interval", void 0);
1426
+ __decorate$2([
1427
+ ifDefined.r()
1428
+ ], exports.W3mSwapPreviewView.prototype, "detailsOpen", void 0);
1429
+ __decorate$2([
1430
+ ifDefined.r()
1431
+ ], exports.W3mSwapPreviewView.prototype, "approvalTransaction", void 0);
1432
+ __decorate$2([
1433
+ ifDefined.r()
1434
+ ], exports.W3mSwapPreviewView.prototype, "swapTransaction", void 0);
1435
+ __decorate$2([
1436
+ ifDefined.r()
1437
+ ], exports.W3mSwapPreviewView.prototype, "sourceToken", void 0);
1438
+ __decorate$2([
1439
+ ifDefined.r()
1440
+ ], exports.W3mSwapPreviewView.prototype, "sourceTokenAmount", void 0);
1441
+ __decorate$2([
1442
+ ifDefined.r()
1443
+ ], exports.W3mSwapPreviewView.prototype, "sourceTokenPriceInUSD", void 0);
1444
+ __decorate$2([
1445
+ ifDefined.r()
1446
+ ], exports.W3mSwapPreviewView.prototype, "toToken", void 0);
1447
+ __decorate$2([
1448
+ ifDefined.r()
1449
+ ], exports.W3mSwapPreviewView.prototype, "toTokenAmount", void 0);
1450
+ __decorate$2([
1451
+ ifDefined.r()
1452
+ ], exports.W3mSwapPreviewView.prototype, "toTokenPriceInUSD", void 0);
1453
+ __decorate$2([
1454
+ ifDefined.r()
1455
+ ], exports.W3mSwapPreviewView.prototype, "caipNetwork", void 0);
1456
+ __decorate$2([
1457
+ ifDefined.r()
1458
+ ], exports.W3mSwapPreviewView.prototype, "balanceSymbol", void 0);
1459
+ __decorate$2([
1460
+ ifDefined.r()
1461
+ ], exports.W3mSwapPreviewView.prototype, "inputError", void 0);
1462
+ __decorate$2([
1463
+ ifDefined.r()
1464
+ ], exports.W3mSwapPreviewView.prototype, "loadingQuote", void 0);
1465
+ __decorate$2([
1466
+ ifDefined.r()
1467
+ ], exports.W3mSwapPreviewView.prototype, "loadingApprovalTransaction", void 0);
1468
+ __decorate$2([
1469
+ ifDefined.r()
1470
+ ], exports.W3mSwapPreviewView.prototype, "loadingBuildTransaction", void 0);
1471
+ __decorate$2([
1472
+ ifDefined.r()
1473
+ ], exports.W3mSwapPreviewView.prototype, "loadingTransaction", void 0);
1474
+ exports.W3mSwapPreviewView = __decorate$2([
1475
+ ifDefined.customElement("w3m-swap-preview-view")
1476
+ ], exports.W3mSwapPreviewView);
1477
+ const styles$1 = bitcoin.i`
1478
+ :host {
1479
+ height: 60px;
1480
+ min-height: 60px;
1481
+ }
1482
+
1483
+ :host > wui-flex {
1484
+ cursor: pointer;
1485
+ height: 100%;
1486
+ display: flex;
1487
+ column-gap: var(--wui-spacing-s);
1488
+ padding: var(--wui-spacing-xs);
1489
+ padding-right: var(--wui-spacing-l);
1490
+ width: 100%;
1491
+ background-color: transparent;
1492
+ border-radius: var(--wui-border-radius-xs);
1493
+ color: var(--wui-color-fg-250);
1494
+ transition:
1495
+ background-color var(--wui-ease-out-power-1) var(--wui-duration-lg),
1496
+ opacity var(--wui-ease-out-power-1) var(--wui-duration-lg);
1497
+ will-change: background-color, opacity;
1498
+ }
1499
+
1500
+ @media (hover: hover) and (pointer: fine) {
1501
+ :host > wui-flex:hover {
1502
+ background-color: var(--wui-color-gray-glass-002);
1503
+ }
1504
+
1505
+ :host > wui-flex:active {
1506
+ background-color: var(--wui-color-gray-glass-005);
1507
+ }
1508
+ }
1509
+
1510
+ :host([disabled]) > wui-flex {
1511
+ opacity: 0.6;
1512
+ }
1513
+
1514
+ :host([disabled]) > wui-flex:hover {
1515
+ background-color: transparent;
1516
+ }
1517
+
1518
+ :host > wui-flex > wui-flex {
1519
+ flex: 1;
1520
+ }
1521
+
1522
+ :host > wui-flex > wui-image,
1523
+ :host > wui-flex > .token-item-image-placeholder {
1524
+ width: 40px;
1525
+ max-width: 40px;
1526
+ height: 40px;
1527
+ border-radius: var(--wui-border-radius-3xl);
1528
+ position: relative;
1529
+ }
1530
+
1531
+ :host > wui-flex > .token-item-image-placeholder {
1532
+ display: flex;
1533
+ align-items: center;
1534
+ justify-content: center;
1535
+ }
1536
+
1537
+ :host > wui-flex > wui-image::after,
1538
+ :host > wui-flex > .token-item-image-placeholder::after {
1539
+ position: absolute;
1540
+ content: '';
1541
+ inset: 0;
1542
+ box-shadow: inset 0 0 0 1px var(--wui-color-gray-glass-010);
1543
+ border-radius: var(--wui-border-radius-l);
1544
+ }
1545
+
1546
+ button > wui-icon-box[data-variant='square-blue'] {
1547
+ border-radius: var(--wui-border-radius-3xs);
1548
+ position: relative;
1549
+ border: none;
1550
+ width: 36px;
1551
+ height: 36px;
1552
+ }
1553
+ `;
1554
+ var __decorate$1 = function(decorators, target, key, desc) {
1555
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1556
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1557
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1558
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1559
+ };
1560
+ let WuiTokenListItem = class WuiTokenListItem2 extends bitcoin.i$1 {
1561
+ constructor() {
1562
+ super();
1563
+ this.observer = new IntersectionObserver(() => void 0);
1564
+ this.imageSrc = void 0;
1565
+ this.name = void 0;
1566
+ this.symbol = void 0;
1567
+ this.price = void 0;
1568
+ this.amount = void 0;
1569
+ this.visible = false;
1570
+ this.imageError = false;
1571
+ this.observer = new IntersectionObserver((entries) => {
1572
+ entries.forEach((entry) => {
1573
+ if (entry.isIntersecting) {
1574
+ this.visible = true;
1575
+ } else {
1576
+ this.visible = false;
1577
+ }
1578
+ });
1579
+ }, { threshold: 0.1 });
1580
+ }
1581
+ firstUpdated() {
1582
+ this.observer.observe(this);
1583
+ }
1584
+ disconnectedCallback() {
1585
+ this.observer.disconnect();
1586
+ }
1587
+ render() {
1588
+ var _a;
1589
+ if (!this.visible) {
1590
+ return null;
1591
+ }
1592
+ const value = this.amount && this.price ? (_a = react.NumberUtil.multiply(this.price, this.amount)) == null ? void 0 : _a.toFixed(3) : null;
1593
+ return bitcoin.x`
1594
+ <wui-flex alignItems="center">
1595
+ ${this.visualTemplate()}
1596
+ <wui-flex flexDirection="column" gap="3xs">
1597
+ <wui-flex justifyContent="space-between">
1598
+ <wui-text variant="paragraph-500" color="fg-100" lineClamp="1">${this.name}</wui-text>
1599
+ ${value ? bitcoin.x`
1600
+ <wui-text variant="paragraph-500" color="fg-100">
1601
+ $${ifDefined.UiHelperUtil.formatNumberToLocalString(value, 3)}
1602
+ </wui-text>
1603
+ ` : null}
1604
+ </wui-flex>
1605
+ <wui-flex justifyContent="space-between">
1606
+ <wui-text variant="small-400" color="fg-200" lineClamp="1">${this.symbol}</wui-text>
1607
+ ${this.amount ? bitcoin.x`<wui-text variant="small-400" color="fg-200">
1608
+ ${ifDefined.UiHelperUtil.formatNumberToLocalString(this.amount, 4)}
1609
+ </wui-text>` : null}
1610
+ </wui-flex>
1611
+ </wui-flex>
1612
+ </wui-flex>
1613
+ `;
1614
+ }
1615
+ visualTemplate() {
1616
+ if (this.imageError) {
1617
+ return bitcoin.x`<wui-flex class="token-item-image-placeholder">
1618
+ <wui-icon name="image" color="inherit"></wui-icon>
1619
+ </wui-flex>`;
1620
+ }
1621
+ if (this.imageSrc) {
1622
+ return bitcoin.x`<wui-image
1623
+ width="40"
1624
+ height="40"
1625
+ src=${this.imageSrc}
1626
+ @onLoadError=${this.imageLoadError}
1627
+ ></wui-image>`;
1628
+ }
1629
+ return null;
1630
+ }
1631
+ imageLoadError() {
1632
+ this.imageError = true;
1633
+ }
1634
+ };
1635
+ WuiTokenListItem.styles = [bitcoin.resetStyles, bitcoin.elementStyles, styles$1];
1636
+ __decorate$1([
1637
+ ifDefined.n()
1638
+ ], WuiTokenListItem.prototype, "imageSrc", void 0);
1639
+ __decorate$1([
1640
+ ifDefined.n()
1641
+ ], WuiTokenListItem.prototype, "name", void 0);
1642
+ __decorate$1([
1643
+ ifDefined.n()
1644
+ ], WuiTokenListItem.prototype, "symbol", void 0);
1645
+ __decorate$1([
1646
+ ifDefined.n()
1647
+ ], WuiTokenListItem.prototype, "price", void 0);
1648
+ __decorate$1([
1649
+ ifDefined.n()
1650
+ ], WuiTokenListItem.prototype, "amount", void 0);
1651
+ __decorate$1([
1652
+ ifDefined.r()
1653
+ ], WuiTokenListItem.prototype, "visible", void 0);
1654
+ __decorate$1([
1655
+ ifDefined.r()
1656
+ ], WuiTokenListItem.prototype, "imageError", void 0);
1657
+ WuiTokenListItem = __decorate$1([
1658
+ ifDefined.customElement("wui-token-list-item")
1659
+ ], WuiTokenListItem);
1660
+ const styles = bitcoin.i`
1661
+ :host {
1662
+ --tokens-scroll--top-opacity: 0;
1663
+ --tokens-scroll--bottom-opacity: 1;
1664
+ --suggested-tokens-scroll--left-opacity: 0;
1665
+ --suggested-tokens-scroll--right-opacity: 1;
1666
+ }
1667
+
1668
+ :host > wui-flex:first-child {
1669
+ overflow-y: hidden;
1670
+ overflow-x: hidden;
1671
+ scrollbar-width: none;
1672
+ scrollbar-height: none;
1673
+ }
1674
+
1675
+ :host > wui-flex:first-child::-webkit-scrollbar {
1676
+ display: none;
1677
+ }
1678
+
1679
+ wui-loading-hexagon {
1680
+ position: absolute;
1681
+ }
1682
+
1683
+ .suggested-tokens-container {
1684
+ overflow-x: auto;
1685
+ mask-image: linear-gradient(
1686
+ to right,
1687
+ rgba(0, 0, 0, calc(1 - var(--suggested-tokens-scroll--left-opacity))) 0px,
1688
+ rgba(200, 200, 200, calc(1 - var(--suggested-tokens-scroll--left-opacity))) 1px,
1689
+ black 50px,
1690
+ black 90px,
1691
+ black calc(100% - 90px),
1692
+ black calc(100% - 50px),
1693
+ rgba(155, 155, 155, calc(1 - var(--suggested-tokens-scroll--right-opacity))) calc(100% - 1px),
1694
+ rgba(0, 0, 0, calc(1 - var(--suggested-tokens-scroll--right-opacity))) 100%
1695
+ );
1696
+ }
1697
+
1698
+ .suggested-tokens-container::-webkit-scrollbar {
1699
+ display: none;
1700
+ }
1701
+
1702
+ .tokens-container {
1703
+ border-top: 1px solid var(--wui-color-gray-glass-005);
1704
+ height: 100%;
1705
+ max-height: 390px;
1706
+ }
1707
+
1708
+ .tokens {
1709
+ width: 100%;
1710
+ overflow-y: auto;
1711
+ mask-image: linear-gradient(
1712
+ to bottom,
1713
+ rgba(0, 0, 0, calc(1 - var(--tokens-scroll--top-opacity))) 0px,
1714
+ rgba(200, 200, 200, calc(1 - var(--tokens-scroll--top-opacity))) 1px,
1715
+ black 50px,
1716
+ black 90px,
1717
+ black calc(100% - 90px),
1718
+ black calc(100% - 50px),
1719
+ rgba(155, 155, 155, calc(1 - var(--tokens-scroll--bottom-opacity))) calc(100% - 1px),
1720
+ rgba(0, 0, 0, calc(1 - var(--tokens-scroll--bottom-opacity))) 100%
1721
+ );
1722
+ }
1723
+
1724
+ .network-search-input,
1725
+ .select-network-button {
1726
+ height: 40px;
1727
+ }
1728
+
1729
+ .select-network-button {
1730
+ border: none;
1731
+ display: flex;
1732
+ flex-direction: row;
1733
+ align-items: center;
1734
+ justify-content: center;
1735
+ gap: var(--wui-spacing-xs);
1736
+ box-shadow: inset 0 0 0 1px var(--wui-color-gray-glass-005);
1737
+ background-color: transparent;
1738
+ border-radius: var(--wui-border-radius-xxs);
1739
+ padding: var(--wui-spacing-xs);
1740
+ align-items: center;
1741
+ transition: background-color 0.2s linear;
1742
+ }
1743
+
1744
+ .select-network-button:hover {
1745
+ background-color: var(--wui-color-gray-glass-002);
1746
+ }
1747
+
1748
+ .select-network-button > wui-image {
1749
+ width: 26px;
1750
+ height: 26px;
1751
+ border-radius: var(--wui-border-radius-xs);
1752
+ box-shadow: inset 0 0 0 1px var(--wui-color-gray-glass-010);
1753
+ }
1754
+ `;
1755
+ var __decorate = function(decorators, target, key, desc) {
1756
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1757
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1758
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1759
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1760
+ };
1761
+ exports.W3mSwapSelectTokenView = class W3mSwapSelectTokenView extends bitcoin.i$1 {
1762
+ constructor() {
1763
+ var _a;
1764
+ super();
1765
+ this.unsubscribe = [];
1766
+ this.targetToken = (_a = react.RouterController.state.data) == null ? void 0 : _a.target;
1767
+ this.sourceToken = index.SwapController.state.sourceToken;
1768
+ this.sourceTokenAmount = index.SwapController.state.sourceTokenAmount;
1769
+ this.toToken = index.SwapController.state.toToken;
1770
+ this.myTokensWithBalance = index.SwapController.state.myTokensWithBalance;
1771
+ this.popularTokens = index.SwapController.state.popularTokens;
1772
+ this.searchValue = "";
1773
+ this.unsubscribe.push(...[
1774
+ index.SwapController.subscribe((newState) => {
1775
+ this.sourceToken = newState.sourceToken;
1776
+ this.toToken = newState.toToken;
1777
+ this.myTokensWithBalance = newState.myTokensWithBalance;
1778
+ })
1779
+ ]);
1780
+ }
1781
+ updated() {
1782
+ var _a, _b;
1783
+ const suggestedTokensContainer = (_a = this.renderRoot) == null ? void 0 : _a.querySelector(".suggested-tokens-container");
1784
+ suggestedTokensContainer == null ? void 0 : suggestedTokensContainer.addEventListener("scroll", this.handleSuggestedTokensScroll.bind(this));
1785
+ const tokensList = (_b = this.renderRoot) == null ? void 0 : _b.querySelector(".tokens");
1786
+ tokensList == null ? void 0 : tokensList.addEventListener("scroll", this.handleTokenListScroll.bind(this));
1787
+ }
1788
+ disconnectedCallback() {
1789
+ var _a, _b;
1790
+ super.disconnectedCallback();
1791
+ const suggestedTokensContainer = (_a = this.renderRoot) == null ? void 0 : _a.querySelector(".suggested-tokens-container");
1792
+ const tokensList = (_b = this.renderRoot) == null ? void 0 : _b.querySelector(".tokens");
1793
+ suggestedTokensContainer == null ? void 0 : suggestedTokensContainer.removeEventListener("scroll", this.handleSuggestedTokensScroll.bind(this));
1794
+ tokensList == null ? void 0 : tokensList.removeEventListener("scroll", this.handleTokenListScroll.bind(this));
1795
+ clearInterval(this.interval);
1796
+ }
1797
+ render() {
1798
+ return bitcoin.x`
1799
+ <wui-flex flexDirection="column" gap="s">
1800
+ ${this.templateSearchInput()} ${this.templateSuggestedTokens()} ${this.templateTokens()}
1801
+ </wui-flex>
1802
+ `;
1803
+ }
1804
+ onSelectToken(token) {
1805
+ if (this.targetToken === "sourceToken") {
1806
+ index.SwapController.setSourceToken(token);
1807
+ } else {
1808
+ index.SwapController.setToToken(token);
1809
+ if (this.sourceToken && this.sourceTokenAmount) {
1810
+ index.SwapController.swapTokens();
1811
+ }
1812
+ }
1813
+ react.RouterController.goBack();
1814
+ }
1815
+ templateSearchInput() {
1816
+ return bitcoin.x`
1817
+ <wui-flex .padding=${["3xs", "s", "0", "s"]} gap="xs">
1818
+ <wui-input-text
1819
+ data-testid="swap-select-token-search-input"
1820
+ class="network-search-input"
1821
+ size="sm"
1822
+ placeholder="Search token"
1823
+ icon="search"
1824
+ .value=${this.searchValue}
1825
+ @inputChange=${this.onSearchInputChange.bind(this)}
1826
+ ></wui-input-text>
1827
+ </wui-flex>
1828
+ `;
1829
+ }
1830
+ templateTokens() {
1831
+ const yourTokens = this.myTokensWithBalance ? Object.values(this.myTokensWithBalance) : [];
1832
+ const tokens = this.popularTokens ? this.popularTokens : [];
1833
+ const filteredYourTokens = this.filterTokensWithText(yourTokens, this.searchValue);
1834
+ const filteredTokens = this.filterTokensWithText(tokens, this.searchValue);
1835
+ return bitcoin.x`
1836
+ <wui-flex class="tokens-container">
1837
+ <wui-flex class="tokens" .padding=${["0", "s", "s", "s"]} flexDirection="column">
1838
+ ${(filteredYourTokens == null ? void 0 : filteredYourTokens.length) > 0 ? bitcoin.x`
1839
+ <wui-flex justifyContent="flex-start" padding="s">
1840
+ <wui-text variant="paragraph-500" color="fg-200">Your tokens</wui-text>
1841
+ </wui-flex>
1842
+ ${filteredYourTokens.map((token) => {
1843
+ var _a, _b, _c;
1844
+ const selected = token.symbol === ((_a = this.sourceToken) == null ? void 0 : _a.symbol) || token.symbol === ((_b = this.toToken) == null ? void 0 : _b.symbol);
1845
+ return bitcoin.x`
1846
+ <wui-token-list-item
1847
+ data-testid="swap-select-token-item-${token.symbol}"
1848
+ name=${token.name}
1849
+ ?disabled=${selected}
1850
+ symbol=${token.symbol}
1851
+ price=${token == null ? void 0 : token.price}
1852
+ amount=${(_c = token == null ? void 0 : token.quantity) == null ? void 0 : _c.numeric}
1853
+ imageSrc=${token.logoUri}
1854
+ @click=${() => {
1855
+ if (!selected) {
1856
+ this.onSelectToken(token);
1857
+ }
1858
+ }}
1859
+ >
1860
+ </wui-token-list-item>
1861
+ `;
1862
+ })}
1863
+ ` : null}
1864
+
1865
+ <wui-flex justifyContent="flex-start" padding="s">
1866
+ <wui-text variant="paragraph-500" color="fg-200">Tokens</wui-text>
1867
+ </wui-flex>
1868
+ ${(filteredTokens == null ? void 0 : filteredTokens.length) > 0 ? filteredTokens.map((token) => bitcoin.x`
1869
+ <wui-token-list-item
1870
+ data-testid="swap-select-token-item-${token.symbol}"
1871
+ name=${token.name}
1872
+ symbol=${token.symbol}
1873
+ imageSrc=${token.logoUri}
1874
+ @click=${() => this.onSelectToken(token)}
1875
+ >
1876
+ </wui-token-list-item>
1877
+ `) : null}
1878
+ </wui-flex>
1879
+ </wui-flex>
1880
+ `;
1881
+ }
1882
+ templateSuggestedTokens() {
1883
+ const tokens = index.SwapController.state.suggestedTokens ? index.SwapController.state.suggestedTokens.slice(0, 8) : null;
1884
+ if (!tokens) {
1885
+ return null;
1886
+ }
1887
+ return bitcoin.x`
1888
+ <wui-flex class="suggested-tokens-container" .padding=${["0", "s", "0", "s"]} gap="xs">
1889
+ ${tokens.map((token) => bitcoin.x`
1890
+ <wui-token-button
1891
+ text=${token.symbol}
1892
+ imageSrc=${token.logoUri}
1893
+ @click=${() => this.onSelectToken(token)}
1894
+ >
1895
+ </wui-token-button>
1896
+ `)}
1897
+ </wui-flex>
1898
+ `;
1899
+ }
1900
+ onSearchInputChange(event) {
1901
+ this.searchValue = event.detail;
1902
+ }
1903
+ handleSuggestedTokensScroll() {
1904
+ var _a;
1905
+ const container = (_a = this.renderRoot) == null ? void 0 : _a.querySelector(".suggested-tokens-container");
1906
+ if (!container) {
1907
+ return;
1908
+ }
1909
+ container.style.setProperty("--suggested-tokens-scroll--left-opacity", index$1.MathUtil.interpolate([0, 100], [0, 1], container.scrollLeft).toString());
1910
+ container.style.setProperty("--suggested-tokens-scroll--right-opacity", index$1.MathUtil.interpolate([0, 100], [0, 1], container.scrollWidth - container.scrollLeft - container.offsetWidth).toString());
1911
+ }
1912
+ handleTokenListScroll() {
1913
+ var _a;
1914
+ const container = (_a = this.renderRoot) == null ? void 0 : _a.querySelector(".tokens");
1915
+ if (!container) {
1916
+ return;
1917
+ }
1918
+ container.style.setProperty("--tokens-scroll--top-opacity", index$1.MathUtil.interpolate([0, 100], [0, 1], container.scrollTop).toString());
1919
+ container.style.setProperty("--tokens-scroll--bottom-opacity", index$1.MathUtil.interpolate([0, 100], [0, 1], container.scrollHeight - container.scrollTop - container.offsetHeight).toString());
1920
+ }
1921
+ filterTokensWithText(tokens, text) {
1922
+ return tokens.filter((token) => `${token.symbol} ${token.name} ${token.address}`.toLowerCase().includes(text.toLowerCase()));
1923
+ }
1924
+ };
1925
+ exports.W3mSwapSelectTokenView.styles = styles;
1926
+ __decorate([
1927
+ ifDefined.r()
1928
+ ], exports.W3mSwapSelectTokenView.prototype, "interval", void 0);
1929
+ __decorate([
1930
+ ifDefined.r()
1931
+ ], exports.W3mSwapSelectTokenView.prototype, "targetToken", void 0);
1932
+ __decorate([
1933
+ ifDefined.r()
1934
+ ], exports.W3mSwapSelectTokenView.prototype, "sourceToken", void 0);
1935
+ __decorate([
1936
+ ifDefined.r()
1937
+ ], exports.W3mSwapSelectTokenView.prototype, "sourceTokenAmount", void 0);
1938
+ __decorate([
1939
+ ifDefined.r()
1940
+ ], exports.W3mSwapSelectTokenView.prototype, "toToken", void 0);
1941
+ __decorate([
1942
+ ifDefined.r()
1943
+ ], exports.W3mSwapSelectTokenView.prototype, "myTokensWithBalance", void 0);
1944
+ __decorate([
1945
+ ifDefined.r()
1946
+ ], exports.W3mSwapSelectTokenView.prototype, "popularTokens", void 0);
1947
+ __decorate([
1948
+ ifDefined.r()
1949
+ ], exports.W3mSwapSelectTokenView.prototype, "searchValue", void 0);
1950
+ exports.W3mSwapSelectTokenView = __decorate([
1951
+ ifDefined.customElement("w3m-swap-select-token-view")
1952
+ ], exports.W3mSwapSelectTokenView);