@directcryptopay/sdk 0.2.1 → 0.2.3

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 (228) hide show
  1. package/dist/ExchangeController-CPMQq6Q-.js +217 -0
  2. package/dist/HelpersUtil-DfMFC7Bf.js +120 -0
  3. package/dist/NavigationUtil-kj9LEOOd.js +8 -0
  4. package/dist/PhArrowCircleDown-lsK25DCk.js +73 -0
  5. package/dist/PhArrowClockwise-NeKHZ1co.js +73 -0
  6. package/dist/PhArrowDown-C9AkNvLs.js +73 -0
  7. package/dist/PhArrowLeft-RNfIQP1X.js +73 -0
  8. package/dist/PhArrowRight-DM1tna0G.js +73 -0
  9. package/dist/PhArrowSquareOut-S5XYbAZj.js +73 -0
  10. package/dist/PhArrowUp-DmktzOWy.js +73 -0
  11. package/dist/PhArrowUpRight-BkNeW_5i.js +73 -0
  12. package/dist/PhArrowsClockwise-CQ4pG76b.js +73 -0
  13. package/dist/PhArrowsDownUp-H6gxaNM6.js +73 -0
  14. package/dist/PhArrowsLeftRight-DZSsfMR6.js +73 -0
  15. package/dist/PhBank-4_9QzqIB.js +73 -0
  16. package/dist/PhBrowser-B-JSznId.js +73 -0
  17. package/dist/PhCaretDown-vV5oHMNi.js +73 -0
  18. package/dist/PhCaretLeft-BLo6Y_f4.js +73 -0
  19. package/dist/PhCaretRight-CqQN4TT3.js +73 -0
  20. package/dist/PhCaretUp-Df7UCAHy.js +73 -0
  21. package/dist/PhCheck-gtpfK4ed.js +73 -0
  22. package/dist/PhCircleHalf-Uq7dwDYw.js +73 -0
  23. package/dist/PhClock-SDCW-NmF.js +73 -0
  24. package/dist/PhCompass-B7hgtdx-.js +73 -0
  25. package/dist/PhCopy-BcnhyXCy.js +73 -0
  26. package/dist/PhCreditCard-BJjByVgu.js +73 -0
  27. package/dist/PhCurrencyDollar-B7ZXqXBy.js +73 -0
  28. package/dist/PhDesktop-B3VKPuJx.js +73 -0
  29. package/dist/PhDeviceMobile-Bnd0TYEH.js +73 -0
  30. package/dist/PhDotsThree-yyMWyZ-R.js +73 -0
  31. package/dist/PhEnvelope-67uzHbI9.js +73 -0
  32. package/dist/PhFunnelSimple-B-DCsloI.js +73 -0
  33. package/dist/PhGlobe-TMm_6qGk.js +73 -0
  34. package/dist/PhIdentificationCard-CePPD2xc.js +73 -0
  35. package/dist/PhImage-gY96WtHR.js +73 -0
  36. package/dist/PhInfo-DRQM_ZDP.js +73 -0
  37. package/dist/PhLightbulb-B0TxPfZ1.js +73 -0
  38. package/dist/PhMagnifyingGlass-B8si5_6W.js +73 -0
  39. package/dist/PhPaperPlaneRight-DVu5PLYd.js +73 -0
  40. package/dist/PhPlus-BfTsQnUz.js +73 -0
  41. package/dist/PhPower-CxYUGOWn.js +73 -0
  42. package/dist/PhPuzzlePiece-CQ4wh0gV.js +73 -0
  43. package/dist/PhQrCode-BuJ97NYJ.js +73 -0
  44. package/dist/PhQuestion-kJoP8Mja.js +73 -0
  45. package/dist/PhQuestionMark-C46ZkFpu.js +73 -0
  46. package/dist/PhSealCheck-Eh8jVqSN.js +73 -0
  47. package/dist/PhSignOut-jk97OSVt.js +73 -0
  48. package/dist/PhSpinner-CiYOhwMg.js +73 -0
  49. package/dist/PhTrash-pxerMqzd.js +73 -0
  50. package/dist/PhUser-BMg0VV4A.js +73 -0
  51. package/dist/PhVault-DYQvx5A-.js +73 -0
  52. package/dist/PhWarning-NLC5Mj87.js +73 -0
  53. package/dist/PhWarningCircle-Ch2jU9fA.js +73 -0
  54. package/dist/PhX-Bx4wpwm3.js +73 -0
  55. package/dist/SwapController-Cti0Cyxa.js +457 -0
  56. package/dist/{ccip-BIGqktC1.js → ccip-CKZd2XJ7.js} +4 -4
  57. package/dist/data-capture-7D5CL385.js +490 -0
  58. package/dist/dcp-sdk.umd.js +7400 -6589
  59. package/dist/email-AmK0INbZ.js +344 -0
  60. package/dist/embedded-wallet-Pn0I_XLn.js +820 -0
  61. package/dist/features-x8XNprEe.js +274 -0
  62. package/dist/{hashTypedData-ZH9ZnWu3.js → hashTypedData-B50-z0AA.js} +6 -6
  63. package/dist/if-defined-CdZSZ6UL.js +10 -0
  64. package/dist/index-4ewUtPPp.js +7981 -0
  65. package/dist/{index-D6h-qfpt.js → index-51l86yqx.js} +5 -5
  66. package/dist/index-B6K56LF_.js +85 -0
  67. package/dist/index-BAmv9PxJ.js +257 -0
  68. package/dist/index-BEswjY9r.js +117 -0
  69. package/dist/index-BSKRq56S.js +355 -0
  70. package/dist/index-BaygXQxx.js +172 -0
  71. package/dist/index-BcPxaHr5.js +118 -0
  72. package/dist/index-Bjt7nGaJ.js +199 -0
  73. package/dist/{index-D5r0iSq4.js → index-BkTSyAJb.js} +1 -1
  74. package/dist/index-Bmnl7l2U.js +555 -0
  75. package/dist/index-BvPvouSq.js +56 -0
  76. package/dist/index-C-6iznUO.js +174 -0
  77. package/dist/index-C4M5s_AM.js +228 -0
  78. package/dist/index-CEqcN8QP.js +1175 -0
  79. package/dist/{index-CPTcEPbD.js → index-CM3YaYca.js} +296 -298
  80. package/dist/{index-f3LXSfM5.js → index-CclBLA5r.js} +56 -142
  81. package/dist/index-ChTxJOiF.js +46 -0
  82. package/dist/index-CmAv0Tzr.js +86 -0
  83. package/dist/index-CmvoKY4x.js +125 -0
  84. package/dist/{index-BdSIrl-R.js → index-D7PmdQ9B.js} +578 -570
  85. package/dist/{index-DobBVPe4.js → index-D7k2Pc4e.js} +481 -236
  86. package/dist/index-D7lmgqUR.js +153 -0
  87. package/dist/index-DG_-qYze.js +107 -0
  88. package/dist/{index-Dy4NyE6l.js → index-DHot9Fdb.js} +7 -7
  89. package/dist/index-DV2LrPtU.js +123 -0
  90. package/dist/index-DYBaJQ2W.js +65 -0
  91. package/dist/{index-BJ7cbG3N.js → index-D_8VUmn1.js} +36688 -40208
  92. package/dist/index-D_gLn3rT.js +100 -0
  93. package/dist/index-DqcVUSC9.js +62 -0
  94. package/dist/index-I7VDqINw.js +128 -0
  95. package/dist/index-Oz72I9VP.js +209 -0
  96. package/dist/index-UclsHkJ0.js +118 -0
  97. package/dist/index-X8zir_1j.js +110 -0
  98. package/dist/index-XvlWKGCu.js +1281 -0
  99. package/dist/index-dO97xPlt.js +171 -0
  100. package/dist/{index-5mp7WkhV.js → index-uBeF6OAB.js} +2 -2
  101. package/dist/index-zeA_RiCV.js +159 -0
  102. package/dist/index.js +1 -1
  103. package/dist/{localBatchGatewayRequest-CjGcn5nM.js → localBatchGatewayRequest-BUZHGdjw.js} +1 -1
  104. package/dist/onramp-CdnBuF0r.js +855 -0
  105. package/dist/{parseSignature-S8VEpRHC.js → parseSignature-CcyTNGr4.js} +2312 -2313
  106. package/dist/pay-with-exchange-CSM6WCOV.js +525 -0
  107. package/dist/property-Bd8U3_QP.js +618 -0
  108. package/dist/receive-DooMu4Dx.js +232 -0
  109. package/dist/ref-CpgjXAw7.js +107 -0
  110. package/dist/send-3T7CyYic.js +1166 -0
  111. package/dist/socials-Dt-iHL17.js +620 -0
  112. package/dist/swaps-CjA9Es42.js +1760 -0
  113. package/dist/{transactions-DujFkB-M.js → transactions-nRm9DVzn.js} +10 -10
  114. package/dist/w3m-modal-NV25AXhM.js +1706 -0
  115. package/package.json +3 -3
  116. package/dist/ConstantsUtil-B-_-u8aQ.js +0 -6
  117. package/dist/add-sji6scSD.js +0 -19
  118. package/dist/all-wallets-B4H-890E.js +0 -10
  119. package/dist/app-store-Z433s97G.js +0 -21
  120. package/dist/apple-b8Lxj7nb.js +0 -22
  121. package/dist/arrow-bottom-M9oWWo_9.js +0 -12
  122. package/dist/arrow-bottom-circle-N9c4CXY1.js +0 -15
  123. package/dist/arrow-left-Dw8AKfwf.js +0 -12
  124. package/dist/arrow-right-DwLQZSC_.js +0 -12
  125. package/dist/arrow-top-zhUjkBe1.js +0 -12
  126. package/dist/bank-CbQdnILK.js +0 -18
  127. package/dist/browser-xAqNwt7z.js +0 -18
  128. package/dist/card-Dr1QBmWp.js +0 -18
  129. package/dist/checkmark-BhT1dTgG.js +0 -15
  130. package/dist/checkmark-bold-CPB29wqQ.js +0 -12
  131. package/dist/chevron-bottom-BhNyx2II.js +0 -12
  132. package/dist/chevron-left-CGuEjQlY.js +0 -12
  133. package/dist/chevron-right-CvIRRsqZ.js +0 -12
  134. package/dist/chevron-top-RSzCqjBd.js +0 -12
  135. package/dist/chrome-store-Cs8dAgs0.js +0 -65
  136. package/dist/clock-fhZO5otC.js +0 -12
  137. package/dist/close-BPuztrdR.js +0 -12
  138. package/dist/coinPlaceholder-C8X2i7Kh.js +0 -12
  139. package/dist/compass-WMc5huk0.js +0 -12
  140. package/dist/copy-DVAeT17y.js +0 -19
  141. package/dist/cursor-BJ4YLXfy.js +0 -7
  142. package/dist/cursor-transparent-DN2fLQN4.js +0 -16
  143. package/dist/desktop-6avxisBw.js +0 -13
  144. package/dist/disconnect-AReVI8Gk.js +0 -12
  145. package/dist/discord-CxrI30BZ.js +0 -21
  146. package/dist/email-B8dIIaay.js +0 -696
  147. package/dist/embedded-wallet-C_5hF7rM.js +0 -468
  148. package/dist/etherscan-BnAy8cIF.js +0 -10
  149. package/dist/exclamation-triangle-Bu7nHwx9.js +0 -8
  150. package/dist/extension-F0LIhvcf.js +0 -12
  151. package/dist/external-link-CP6phyaM.js +0 -12
  152. package/dist/facebook-BtQ-Io2y.js +0 -30
  153. package/dist/farcaster-BmaN1ugd.js +0 -16
  154. package/dist/filters-DpEwoOmy.js +0 -12
  155. package/dist/github-q7qO9V-b.js +0 -22
  156. package/dist/google-DH_ZE8bW.js +0 -22
  157. package/dist/help-circle-BAQVmKas.js +0 -16
  158. package/dist/id-Cj68Zwgo.js +0 -16
  159. package/dist/if-defined-CNte9B3N.js +0 -744
  160. package/dist/image-BKJDw6N-.js +0 -8
  161. package/dist/index-7toZMdtG.js +0 -573
  162. package/dist/index-B1uKzdvN.js +0 -170
  163. package/dist/index-BHFZVF-b.js +0 -257
  164. package/dist/index-BKwa5JSA.js +0 -559
  165. package/dist/index-BP4B9VUt.js +0 -54
  166. package/dist/index-BVdzXHpO.js +0 -181
  167. package/dist/index-BYND0GJ9.js +0 -146
  168. package/dist/index-BaJ0zEbh.js +0 -97
  169. package/dist/index-Bh0MPFwP.js +0 -58
  170. package/dist/index-Bsh7_qTp.js +0 -511
  171. package/dist/index-BwnXTNNg.js +0 -199
  172. package/dist/index-C0kPDbg_.js +0 -77
  173. package/dist/index-CKikVKe2.js +0 -75
  174. package/dist/index-ChVh0Hkp.js +0 -243
  175. package/dist/index-Cle_NnnS.js +0 -305
  176. package/dist/index-CmWdvIFT.js +0 -51
  177. package/dist/index-D2AMA8Bu.js +0 -65
  178. package/dist/index-DAUM8CO4.js +0 -65
  179. package/dist/index-DGjZW6uR.js +0 -78
  180. package/dist/index-DQe94z7X.js +0 -265
  181. package/dist/index-DTo6w99t.js +0 -7864
  182. package/dist/index-DYdXjap2.js +0 -320
  183. package/dist/index-DceCxNV5.js +0 -181
  184. package/dist/index-Uw9cSw0q.js +0 -294
  185. package/dist/index-qiuyrukh.js +0 -45
  186. package/dist/index-zddvaohA.js +0 -78
  187. package/dist/info-RfPsmroW.js +0 -7
  188. package/dist/info-circle-DFKHB_ZN.js +0 -16
  189. package/dist/lightbulb-B-Bykj9X.js +0 -7
  190. package/dist/mail-mBAgGuw5.js +0 -12
  191. package/dist/mobile-Dhh3ndkf.js +0 -13
  192. package/dist/more-D1h7UTvg.js +0 -15
  193. package/dist/network-placeholder-Dqynvc-t.js +0 -18
  194. package/dist/nftPlaceholder-Df7MW4MM.js +0 -12
  195. package/dist/off-BmG3cHTX.js +0 -12
  196. package/dist/onramp-C401Aenb.js +0 -1279
  197. package/dist/play-store-4q1fzL_P.js +0 -36
  198. package/dist/plus-603Gs3yG.js +0 -17
  199. package/dist/qr-code-Dgwhf6M1.js +0 -10
  200. package/dist/receive-CYXbbEUR.js +0 -186
  201. package/dist/recycle-horizontal-Bu8zZ563.js +0 -13
  202. package/dist/ref-DpmKRWBK.js +0 -41
  203. package/dist/refresh-BMZFu0mu.js +0 -12
  204. package/dist/reown-logo-BXph7ThY.js +0 -16
  205. package/dist/search-Cm_V42Y_.js +0 -12
  206. package/dist/secp256k1-C0iX1TUr.js +0 -1510
  207. package/dist/secp256k1-DOQBqE4Z.js +0 -1302
  208. package/dist/send-BSMYxDuP.js +0 -19
  209. package/dist/send-C8EeIzRB.js +0 -1038
  210. package/dist/socials-DQrHQajs.js +0 -574
  211. package/dist/swapHorizontal-98rnJewS.js +0 -12
  212. package/dist/swapHorizontalBold-C299FjEt.js +0 -12
  213. package/dist/swapHorizontalMedium-Cqm6i4WJ.js +0 -20
  214. package/dist/swapHorizontalRoundedBold-De7hFfqZ.js +0 -12
  215. package/dist/swapVertical-DSL75l8L.js +0 -12
  216. package/dist/swaps-BuTNp65Y.js +0 -1637
  217. package/dist/telegram-cJP7hgUb.js +0 -20
  218. package/dist/three-dots-DHnEh28O.js +0 -9
  219. package/dist/twitch-CR2iGcBo.js +0 -22
  220. package/dist/twitterIcon-E5TAQjOn.js +0 -10
  221. package/dist/verify-DEukUJp0.js +0 -12
  222. package/dist/verify-filled-BXsx1i_p.js +0 -12
  223. package/dist/w3m-modal-Bm7BqVng.js +0 -1037
  224. package/dist/wallet-CzyyvdrT.js +0 -12
  225. package/dist/wallet-placeholder-BrcmyGEe.js +0 -18
  226. package/dist/walletconnect-BSYogWiE.js +0 -36
  227. package/dist/warning-circle-Cgp2BW3m.js +0 -16
  228. package/dist/x-BJinLpTw.js +0 -16
@@ -0,0 +1,1760 @@
1
+ import { cU as A, cX as D, cE as $, cN as h, cY as u, cL as V, cF as N, d0 as S, cG as M, df as K, d3 as F, d4 as Q, cV as W, cW as q } from "./index-D_8VUmn1.js";
2
+ import { r as l, n as w, c as C } from "./index-CEqcN8QP.js";
3
+ import "./index-Oz72I9VP.js";
4
+ import "./index-UclsHkJ0.js";
5
+ import { M as _ } from "./index-B6K56LF_.js";
6
+ import "./index-zeA_RiCV.js";
7
+ import { S as s } from "./SwapController-Cti0Cyxa.js";
8
+ import "./index-DqcVUSC9.js";
9
+ import "./index-Bjt7nGaJ.js";
10
+ import "./index-C4M5s_AM.js";
11
+ import "./index-I7VDqINw.js";
12
+ const H = {
13
+ numericInputKeyDown(e, t, o) {
14
+ const i = [
15
+ "Backspace",
16
+ "Meta",
17
+ "Ctrl",
18
+ "a",
19
+ "A",
20
+ "c",
21
+ "C",
22
+ "x",
23
+ "X",
24
+ "v",
25
+ "V",
26
+ "ArrowLeft",
27
+ "ArrowRight",
28
+ "Tab"
29
+ ], r = e.metaKey || e.ctrlKey, n = e.key, a = n.toLocaleLowerCase(), c = a === "a", b = a === "c", I = a === "v", U = a === "x", L = n === ",", R = n === ".", B = n >= "0" && n <= "9";
30
+ !r && (c || b || I || U) && e.preventDefault(), t === "0" && !L && !R && n === "0" && e.preventDefault(), t === "0" && B && (o(n), e.preventDefault()), (L || R) && (t || (o("0."), e.preventDefault()), (t != null && t.includes(".") || t != null && t.includes(",")) && e.preventDefault()), !B && !i.includes(n) && !R && !L && e.preventDefault();
31
+ }
32
+ }, G = A`
33
+ :host {
34
+ width: 100%;
35
+ }
36
+
37
+ .details-container > wui-flex {
38
+ background: ${({ tokens: e }) => e.theme.foregroundPrimary};
39
+ border-radius: ${({ borderRadius: e }) => e[3]};
40
+ width: 100%;
41
+ }
42
+
43
+ .details-container > wui-flex > button {
44
+ border: none;
45
+ background: none;
46
+ padding: ${({ spacing: e }) => e[3]};
47
+ border-radius: ${({ borderRadius: e }) => e[3]};
48
+ cursor: pointer;
49
+ }
50
+
51
+ .details-content-container {
52
+ padding: ${({ spacing: e }) => e[2]};
53
+ padding-top: 0px;
54
+ display: flex;
55
+ align-items: center;
56
+ justify-content: center;
57
+ }
58
+
59
+ .details-content-container > wui-flex {
60
+ width: 100%;
61
+ }
62
+
63
+ .details-row {
64
+ width: 100%;
65
+ padding: ${({ spacing: e }) => e[3]};
66
+ padding-left: ${({ spacing: e }) => e[3]};
67
+ padding-right: ${({ spacing: e }) => e[2]};
68
+ border-radius: calc(
69
+ ${({ borderRadius: e }) => e[1]} + ${({ borderRadius: e }) => e[1]}
70
+ );
71
+ background: ${({ tokens: e }) => e.theme.foregroundPrimary};
72
+ }
73
+
74
+ .details-row-title {
75
+ white-space: nowrap;
76
+ }
77
+
78
+ .details-row.provider-free-row {
79
+ padding-right: ${({ spacing: e }) => e[2]};
80
+ }
81
+ `;
82
+ var T = function(e, t, o, i) {
83
+ var r = arguments.length, n = r < 3 ? t : i === null ? i = Object.getOwnPropertyDescriptor(t, o) : i, a;
84
+ if (typeof Reflect == "object" && typeof Reflect.decorate == "function") n = Reflect.decorate(e, t, o, i);
85
+ else for (var c = e.length - 1; c >= 0; c--) (a = e[c]) && (n = (r < 3 ? a(n) : r > 3 ? a(t, o, n) : a(t, o)) || n);
86
+ return r > 3 && n && Object.defineProperty(t, o, n), n;
87
+ };
88
+ const X = V.CONVERT_SLIPPAGE_TOLERANCE;
89
+ let g = class extends D {
90
+ constructor() {
91
+ var t;
92
+ super(), this.unsubscribe = [], this.networkName = (t = $.state.activeCaipNetwork) == null ? void 0 : t.name, this.detailsOpen = !1, this.sourceToken = s.state.sourceToken, this.toToken = s.state.toToken, this.toTokenAmount = s.state.toTokenAmount, this.sourceTokenPriceInUSD = s.state.sourceTokenPriceInUSD, this.toTokenPriceInUSD = s.state.toTokenPriceInUSD, this.priceImpact = s.state.priceImpact, this.maxSlippage = s.state.maxSlippage, this.networkTokenSymbol = s.state.networkTokenSymbol, this.inputError = s.state.inputError, this.unsubscribe.push(s.subscribe((o) => {
93
+ this.sourceToken = o.sourceToken, this.toToken = o.toToken, this.toTokenAmount = o.toTokenAmount, this.priceImpact = o.priceImpact, this.maxSlippage = o.maxSlippage, this.sourceTokenPriceInUSD = o.sourceTokenPriceInUSD, this.toTokenPriceInUSD = o.toTokenPriceInUSD, this.inputError = o.inputError;
94
+ }));
95
+ }
96
+ render() {
97
+ const t = this.toTokenAmount && this.maxSlippage ? h.bigNumber(this.toTokenAmount).minus(this.maxSlippage).toString() : null;
98
+ if (!this.sourceToken || !this.toToken || this.inputError)
99
+ return null;
100
+ const o = this.sourceTokenPriceInUSD && this.toTokenPriceInUSD ? 1 / this.toTokenPriceInUSD * this.sourceTokenPriceInUSD : 0;
101
+ return u`
102
+ <wui-flex flexDirection="column" alignItems="center" gap="01" class="details-container">
103
+ <wui-flex flexDirection="column">
104
+ <button @click=${this.toggleDetails.bind(this)}>
105
+ <wui-flex justifyContent="space-between" .padding=${["0", "2", "0", "2"]}>
106
+ <wui-flex justifyContent="flex-start" flexGrow="1" gap="2">
107
+ <wui-text variant="sm-regular" color="primary">
108
+ 1 ${this.sourceToken.symbol} =
109
+ ${h.formatNumberToLocalString(o, 3)}
110
+ ${this.toToken.symbol}
111
+ </wui-text>
112
+ <wui-text variant="sm-regular" color="secondary">
113
+ $${h.formatNumberToLocalString(this.sourceTokenPriceInUSD)}
114
+ </wui-text>
115
+ </wui-flex>
116
+ <wui-icon name="chevronBottom"></wui-icon>
117
+ </wui-flex>
118
+ </button>
119
+ ${this.detailsOpen ? u`
120
+ <wui-flex flexDirection="column" gap="2" class="details-content-container">
121
+ ${this.priceImpact ? u` <wui-flex flexDirection="column" gap="2">
122
+ <wui-flex
123
+ justifyContent="space-between"
124
+ alignItems="center"
125
+ class="details-row"
126
+ >
127
+ <wui-flex alignItems="center" gap="2">
128
+ <wui-text
129
+ class="details-row-title"
130
+ variant="sm-regular"
131
+ color="secondary"
132
+ >
133
+ Price impact
134
+ </wui-text>
135
+ <w3m-tooltip-trigger
136
+ text="Price impact reflects the change in market price due to your trade"
137
+ >
138
+ <wui-icon size="sm" color="default" name="info"></wui-icon>
139
+ </w3m-tooltip-trigger>
140
+ </wui-flex>
141
+ <wui-flex>
142
+ <wui-text variant="sm-regular" color="secondary">
143
+ ${h.formatNumberToLocalString(this.priceImpact, 3)}%
144
+ </wui-text>
145
+ </wui-flex>
146
+ </wui-flex>
147
+ </wui-flex>` : null}
148
+ ${this.maxSlippage && this.sourceToken.symbol ? u`<wui-flex flexDirection="column" gap="2">
149
+ <wui-flex
150
+ justifyContent="space-between"
151
+ alignItems="center"
152
+ class="details-row"
153
+ >
154
+ <wui-flex alignItems="center" gap="2">
155
+ <wui-text
156
+ class="details-row-title"
157
+ variant="sm-regular"
158
+ color="secondary"
159
+ >
160
+ Max. slippage
161
+ </wui-text>
162
+ <w3m-tooltip-trigger
163
+ text=${`Max slippage sets the minimum amount you must receive for the transaction to proceed. ${t ? `Transaction will be reversed if you receive less than ${h.formatNumberToLocalString(t, 6)} ${this.toToken.symbol} due to price changes.` : ""}`}
164
+ >
165
+ <wui-icon size="sm" color="default" name="info"></wui-icon>
166
+ </w3m-tooltip-trigger>
167
+ </wui-flex>
168
+ <wui-flex>
169
+ <wui-text variant="sm-regular" color="secondary">
170
+ ${h.formatNumberToLocalString(this.maxSlippage, 6)}
171
+ ${this.toToken.symbol} ${X}%
172
+ </wui-text>
173
+ </wui-flex>
174
+ </wui-flex>
175
+ </wui-flex>` : null}
176
+ <wui-flex flexDirection="column" gap="2">
177
+ <wui-flex
178
+ justifyContent="space-between"
179
+ alignItems="center"
180
+ class="details-row provider-free-row"
181
+ >
182
+ <wui-flex alignItems="center" gap="2">
183
+ <wui-text class="details-row-title" variant="sm-regular" color="secondary">
184
+ Provider fee
185
+ </wui-text>
186
+ </wui-flex>
187
+ <wui-flex>
188
+ <wui-text variant="sm-regular" color="secondary">0.85%</wui-text>
189
+ </wui-flex>
190
+ </wui-flex>
191
+ </wui-flex>
192
+ </wui-flex>
193
+ ` : null}
194
+ </wui-flex>
195
+ </wui-flex>
196
+ `;
197
+ }
198
+ toggleDetails() {
199
+ this.detailsOpen = !this.detailsOpen;
200
+ }
201
+ };
202
+ g.styles = [G];
203
+ T([
204
+ l()
205
+ ], g.prototype, "networkName", void 0);
206
+ T([
207
+ w()
208
+ ], g.prototype, "detailsOpen", void 0);
209
+ T([
210
+ l()
211
+ ], g.prototype, "sourceToken", void 0);
212
+ T([
213
+ l()
214
+ ], g.prototype, "toToken", void 0);
215
+ T([
216
+ l()
217
+ ], g.prototype, "toTokenAmount", void 0);
218
+ T([
219
+ l()
220
+ ], g.prototype, "sourceTokenPriceInUSD", void 0);
221
+ T([
222
+ l()
223
+ ], g.prototype, "toTokenPriceInUSD", void 0);
224
+ T([
225
+ l()
226
+ ], g.prototype, "priceImpact", void 0);
227
+ T([
228
+ l()
229
+ ], g.prototype, "maxSlippage", void 0);
230
+ T([
231
+ l()
232
+ ], g.prototype, "networkTokenSymbol", void 0);
233
+ T([
234
+ l()
235
+ ], g.prototype, "inputError", void 0);
236
+ g = T([
237
+ C("w3m-swap-details")
238
+ ], g);
239
+ const Y = A`
240
+ :host {
241
+ width: 100%;
242
+ }
243
+
244
+ :host > wui-flex {
245
+ display: flex;
246
+ flex-direction: row;
247
+ justify-content: space-between;
248
+ align-items: center;
249
+ border-radius: ${({ borderRadius: e }) => e[5]};
250
+ padding: ${({ spacing: e }) => e[5]};
251
+ padding-right: ${({ spacing: e }) => e[3]};
252
+ background-color: ${({ tokens: e }) => e.theme.foregroundPrimary};
253
+ box-shadow: inset 0px 0px 0px 1px ${({ tokens: e }) => e.theme.foregroundPrimary};
254
+ width: 100%;
255
+ height: 100px;
256
+ box-sizing: border-box;
257
+ position: relative;
258
+ }
259
+
260
+ wui-shimmer.market-value {
261
+ opacity: 0;
262
+ }
263
+
264
+ :host > wui-flex > svg.input_mask {
265
+ position: absolute;
266
+ inset: 0;
267
+ z-index: 5;
268
+ }
269
+
270
+ :host wui-flex .input_mask__border,
271
+ :host wui-flex .input_mask__background {
272
+ transition: fill ${({ durations: e }) => e.md}
273
+ ${({ easings: e }) => e["ease-out-power-1"]};
274
+ will-change: fill;
275
+ }
276
+
277
+ :host wui-flex .input_mask__border {
278
+ fill: ${({ tokens: e }) => e.core.glass010};
279
+ }
280
+
281
+ :host wui-flex .input_mask__background {
282
+ fill: ${({ tokens: e }) => e.theme.foregroundPrimary};
283
+ }
284
+ `;
285
+ var z = function(e, t, o, i) {
286
+ var r = arguments.length, n = r < 3 ? t : i === null ? i = Object.getOwnPropertyDescriptor(t, o) : i, a;
287
+ if (typeof Reflect == "object" && typeof Reflect.decorate == "function") n = Reflect.decorate(e, t, o, i);
288
+ else for (var c = e.length - 1; c >= 0; c--) (a = e[c]) && (n = (r < 3 ? a(n) : r > 3 ? a(t, o, n) : a(t, o)) || n);
289
+ return r > 3 && n && Object.defineProperty(t, o, n), n;
290
+ };
291
+ let j = class extends D {
292
+ constructor() {
293
+ super(...arguments), this.target = "sourceToken";
294
+ }
295
+ render() {
296
+ return u`
297
+ <wui-flex class justifyContent="space-between">
298
+ <wui-flex
299
+ flex="1"
300
+ flexDirection="column"
301
+ alignItems="flex-start"
302
+ justifyContent="center"
303
+ class="swap-input"
304
+ gap="1"
305
+ >
306
+ <wui-shimmer width="80px" height="40px" rounded variant="light"></wui-shimmer>
307
+ </wui-flex>
308
+ ${this.templateTokenSelectButton()}
309
+ </wui-flex>
310
+ `;
311
+ }
312
+ templateTokenSelectButton() {
313
+ return u`
314
+ <wui-flex
315
+ class="swap-token-button"
316
+ flexDirection="column"
317
+ alignItems="flex-end"
318
+ justifyContent="center"
319
+ gap="1"
320
+ >
321
+ <wui-shimmer width="80px" height="40px" rounded variant="light"></wui-shimmer>
322
+ </wui-flex>
323
+ `;
324
+ }
325
+ };
326
+ j.styles = [Y];
327
+ z([
328
+ w()
329
+ ], j.prototype, "target", void 0);
330
+ j = z([
331
+ C("w3m-swap-input-skeleton")
332
+ ], j);
333
+ const Z = A`
334
+ :host > wui-flex {
335
+ display: flex;
336
+ flex-direction: row;
337
+ justify-content: space-between;
338
+ align-items: center;
339
+ border-radius: ${({ borderRadius: e }) => e[5]};
340
+ background-color: ${({ tokens: e }) => e.theme.foregroundPrimary};
341
+ padding: ${({ spacing: e }) => e[5]};
342
+ padding-right: ${({ spacing: e }) => e[3]};
343
+ width: 100%;
344
+ height: 100px;
345
+ box-sizing: border-box;
346
+ box-shadow: inset 0px 0px 0px 1px ${({ tokens: e }) => e.theme.foregroundPrimary};
347
+ position: relative;
348
+ transition: box-shadow ${({ easings: e }) => e["ease-out-power-1"]}
349
+ ${({ durations: e }) => e.lg};
350
+ will-change: background-color;
351
+ }
352
+
353
+ :host wui-flex.focus {
354
+ box-shadow: inset 0px 0px 0px 1px ${({ tokens: e }) => e.core.glass010};
355
+ }
356
+
357
+ :host > wui-flex .swap-input,
358
+ :host > wui-flex .swap-token-button {
359
+ z-index: 10;
360
+ }
361
+
362
+ :host > wui-flex .swap-input {
363
+ -webkit-mask-image: linear-gradient(
364
+ 270deg,
365
+ transparent 0px,
366
+ transparent 8px,
367
+ black 24px,
368
+ black 25px,
369
+ black 32px,
370
+ black 100%
371
+ );
372
+ mask-image: linear-gradient(
373
+ 270deg,
374
+ transparent 0px,
375
+ transparent 8px,
376
+ black 24px,
377
+ black 25px,
378
+ black 32px,
379
+ black 100%
380
+ );
381
+ }
382
+
383
+ :host > wui-flex .swap-input input {
384
+ background: none;
385
+ border: none;
386
+ height: 42px;
387
+ width: 100%;
388
+ font-size: 32px;
389
+ font-style: normal;
390
+ font-weight: 400;
391
+ line-height: 130%;
392
+ letter-spacing: -1.28px;
393
+ outline: none;
394
+ caret-color: ${({ tokens: e }) => e.core.textAccentPrimary};
395
+ color: ${({ tokens: e }) => e.theme.textPrimary};
396
+ padding: 0px;
397
+ }
398
+
399
+ :host > wui-flex .swap-input input:focus-visible {
400
+ outline: none;
401
+ }
402
+
403
+ :host > wui-flex .swap-input input::-webkit-outer-spin-button,
404
+ :host > wui-flex .swap-input input::-webkit-inner-spin-button {
405
+ -webkit-appearance: none;
406
+ margin: 0;
407
+ }
408
+
409
+ .max-value-button {
410
+ background-color: transparent;
411
+ border: none;
412
+ cursor: pointer;
413
+ color: ${({ tokens: e }) => e.core.glass010};
414
+ padding-left: 0px;
415
+ }
416
+
417
+ .market-value {
418
+ min-height: 18px;
419
+ }
420
+ `;
421
+ var y = function(e, t, o, i) {
422
+ var r = arguments.length, n = r < 3 ? t : i === null ? i = Object.getOwnPropertyDescriptor(t, o) : i, a;
423
+ if (typeof Reflect == "object" && typeof Reflect.decorate == "function") n = Reflect.decorate(e, t, o, i);
424
+ else for (var c = e.length - 1; c >= 0; c--) (a = e[c]) && (n = (r < 3 ? a(n) : r > 3 ? a(t, o, n) : a(t, o)) || n);
425
+ return r > 3 && n && Object.defineProperty(t, o, n), n;
426
+ };
427
+ const J = 5e-5;
428
+ let k = class extends D {
429
+ constructor() {
430
+ super(...arguments), this.focused = !1, this.price = 0, this.target = "sourceToken", this.onSetAmount = null, this.onSetMaxValue = null;
431
+ }
432
+ render() {
433
+ const t = this.marketValue || "0", o = h.bigNumber(t).gt("0");
434
+ return u`
435
+ <wui-flex
436
+ class="${this.focused ? "focus" : ""}"
437
+ justifyContent="space-between"
438
+ alignItems="center"
439
+ >
440
+ <wui-flex
441
+ flex="1"
442
+ flexDirection="column"
443
+ alignItems="flex-start"
444
+ justifyContent="center"
445
+ class="swap-input"
446
+ >
447
+ <input
448
+ data-testid="swap-input-${this.target}"
449
+ @focusin=${() => this.onFocusChange(!0)}
450
+ @focusout=${() => this.onFocusChange(!1)}
451
+ ?disabled=${this.disabled}
452
+ value=${this.value || ""}
453
+ @input=${this.dispatchInputChangeEvent}
454
+ @keydown=${this.handleKeydown}
455
+ placeholder="0"
456
+ type="text"
457
+ inputmode="decimal"
458
+ pattern="[0-9,.]*"
459
+ />
460
+ <wui-text class="market-value" variant="sm-regular" color="secondary">
461
+ ${o ? `$${h.formatNumberToLocalString(this.marketValue, 2)}` : null}
462
+ </wui-text>
463
+ </wui-flex>
464
+ ${this.templateTokenSelectButton()}
465
+ </wui-flex>
466
+ `;
467
+ }
468
+ handleKeydown(t) {
469
+ return H.numericInputKeyDown(t, this.value, (o) => {
470
+ var i;
471
+ return (i = this.onSetAmount) == null ? void 0 : i.call(this, this.target, o);
472
+ });
473
+ }
474
+ dispatchInputChangeEvent(t) {
475
+ if (!this.onSetAmount)
476
+ return;
477
+ const o = t.target.value.replace(/[^0-9.]/gu, "");
478
+ o === "," || o === "." ? this.onSetAmount(this.target, "0.") : o.endsWith(",") ? this.onSetAmount(this.target, o.replace(",", ".")) : this.onSetAmount(this.target, o);
479
+ }
480
+ setMaxValueToInput() {
481
+ var t;
482
+ (t = this.onSetMaxValue) == null || t.call(this, this.target, this.balance);
483
+ }
484
+ templateTokenSelectButton() {
485
+ return this.token ? u`
486
+ <wui-flex
487
+ class="swap-token-button"
488
+ flexDirection="column"
489
+ alignItems="flex-end"
490
+ justifyContent="center"
491
+ gap="1"
492
+ >
493
+ <wui-token-button
494
+ data-testid="swap-input-token-${this.target}"
495
+ text=${this.token.symbol}
496
+ imageSrc=${this.token.logoUri}
497
+ @click=${this.onSelectToken.bind(this)}
498
+ >
499
+ </wui-token-button>
500
+ <wui-flex alignItems="center" gap="1"> ${this.tokenBalanceTemplate()} </wui-flex>
501
+ </wui-flex>
502
+ ` : u` <wui-button
503
+ data-testid="swap-select-token-button-${this.target}"
504
+ class="swap-token-button"
505
+ size="md"
506
+ variant="neutral-secondary"
507
+ @click=${this.onSelectToken.bind(this)}
508
+ >
509
+ Select token
510
+ </wui-button>`;
511
+ }
512
+ tokenBalanceTemplate() {
513
+ const t = h.multiply(this.balance, this.price), o = t ? t == null ? void 0 : t.gt(J) : !1;
514
+ return u`
515
+ ${o ? u`<wui-text variant="sm-regular" color="secondary">
516
+ ${h.formatNumberToLocalString(this.balance, 2)}
517
+ </wui-text>` : null}
518
+ ${this.target === "sourceToken" ? this.tokenActionButtonTemplate(o) : null}
519
+ `;
520
+ }
521
+ tokenActionButtonTemplate(t) {
522
+ return t ? u` <button class="max-value-button" @click=${this.setMaxValueToInput.bind(this)}>
523
+ <wui-text color="accent-primary" variant="sm-medium">Max</wui-text>
524
+ </button>` : u` <button class="max-value-button" @click=${this.onBuyToken.bind(this)}>
525
+ <wui-text color="accent-primary" variant="sm-medium">Buy</wui-text>
526
+ </button>`;
527
+ }
528
+ onFocusChange(t) {
529
+ this.focused = t;
530
+ }
531
+ onSelectToken() {
532
+ N.sendEvent({ type: "track", event: "CLICK_SELECT_TOKEN_TO_SWAP" }), S.push("SwapSelectToken", {
533
+ target: this.target
534
+ });
535
+ }
536
+ onBuyToken() {
537
+ S.push("OnRampProviders");
538
+ }
539
+ };
540
+ k.styles = [Z];
541
+ y([
542
+ w()
543
+ ], k.prototype, "focused", void 0);
544
+ y([
545
+ w()
546
+ ], k.prototype, "balance", void 0);
547
+ y([
548
+ w()
549
+ ], k.prototype, "value", void 0);
550
+ y([
551
+ w()
552
+ ], k.prototype, "price", void 0);
553
+ y([
554
+ w()
555
+ ], k.prototype, "marketValue", void 0);
556
+ y([
557
+ w()
558
+ ], k.prototype, "disabled", void 0);
559
+ y([
560
+ w()
561
+ ], k.prototype, "target", void 0);
562
+ y([
563
+ w()
564
+ ], k.prototype, "token", void 0);
565
+ y([
566
+ w()
567
+ ], k.prototype, "onSetAmount", void 0);
568
+ y([
569
+ w()
570
+ ], k.prototype, "onSetMaxValue", void 0);
571
+ k = y([
572
+ C("w3m-swap-input")
573
+ ], k);
574
+ const ee = A`
575
+ :host > wui-flex:first-child {
576
+ overflow-y: auto;
577
+ overflow-x: hidden;
578
+ scrollbar-width: none;
579
+ }
580
+
581
+ :host > wui-flex:first-child::-webkit-scrollbar {
582
+ display: none;
583
+ }
584
+
585
+ wui-loading-hexagon {
586
+ position: absolute;
587
+ }
588
+
589
+ .action-button {
590
+ width: 100%;
591
+ border-radius: ${({ borderRadius: e }) => e[4]};
592
+ }
593
+
594
+ .action-button:disabled {
595
+ border-color: 1px solid ${({ tokens: e }) => e.core.glass010};
596
+ }
597
+
598
+ .swap-inputs-container {
599
+ position: relative;
600
+ }
601
+
602
+ wui-icon-box {
603
+ width: 32px;
604
+ height: 32px;
605
+ border-radius: ${({ borderRadius: e }) => e[10]} !important;
606
+ border: 4px solid ${({ tokens: e }) => e.theme.backgroundPrimary};
607
+ background: ${({ tokens: e }) => e.theme.foregroundPrimary};
608
+ position: absolute;
609
+ top: 50%;
610
+ left: 50%;
611
+ transform: translate(-50%, -50%);
612
+ z-index: 3;
613
+ }
614
+
615
+ .replace-tokens-button-container {
616
+ display: flex;
617
+ justify-content: center;
618
+ align-items: center;
619
+ position: absolute;
620
+ top: 50%;
621
+ left: 50%;
622
+ transform: translate(-50%, -50%);
623
+ gap: ${({ spacing: e }) => e[2]};
624
+ border-radius: ${({ borderRadius: e }) => e[4]};
625
+ background-color: ${({ tokens: e }) => e.theme.backgroundPrimary};
626
+ padding: ${({ spacing: e }) => e[2]};
627
+ }
628
+
629
+ .details-container > wui-flex {
630
+ background: ${({ tokens: e }) => e.theme.foregroundPrimary};
631
+ border-radius: ${({ borderRadius: e }) => e[3]};
632
+ width: 100%;
633
+ }
634
+
635
+ .details-container > wui-flex > button {
636
+ border: none;
637
+ background: none;
638
+ padding: ${({ spacing: e }) => e[3]};
639
+ border-radius: ${({ borderRadius: e }) => e[3]};
640
+ transition: background ${({ durations: e }) => e.lg}
641
+ ${({ easings: e }) => e["ease-out-power-2"]};
642
+ will-change: background;
643
+ }
644
+
645
+ .details-container > wui-flex > button:hover {
646
+ background: ${({ tokens: e }) => e.theme.foregroundPrimary};
647
+ }
648
+
649
+ .details-content-container {
650
+ padding: ${({ spacing: e }) => e[2]};
651
+ display: flex;
652
+ align-items: center;
653
+ justify-content: center;
654
+ }
655
+
656
+ .details-content-container > wui-flex {
657
+ width: 100%;
658
+ }
659
+
660
+ .details-row {
661
+ width: 100%;
662
+ padding: ${({ spacing: e }) => e[3]} ${({ spacing: e }) => e[5]};
663
+ border-radius: ${({ borderRadius: e }) => e[3]};
664
+ background: ${({ tokens: e }) => e.theme.foregroundPrimary};
665
+ }
666
+ `;
667
+ var m = function(e, t, o, i) {
668
+ var r = arguments.length, n = r < 3 ? t : i === null ? i = Object.getOwnPropertyDescriptor(t, o) : i, a;
669
+ if (typeof Reflect == "object" && typeof Reflect.decorate == "function") n = Reflect.decorate(e, t, o, i);
670
+ else for (var c = e.length - 1; c >= 0; c--) (a = e[c]) && (n = (r < 3 ? a(n) : r > 3 ? a(t, o, n) : a(t, o)) || n);
671
+ return r > 3 && n && Object.defineProperty(t, o, n), n;
672
+ };
673
+ let p = class extends D {
674
+ subscribe({ resetSwapState: t, initializeSwapState: o }) {
675
+ return () => {
676
+ $.subscribeKey("activeCaipNetwork", (i) => this.onCaipNetworkChange({
677
+ newCaipNetwork: i,
678
+ resetSwapState: t,
679
+ initializeSwapState: o
680
+ })), $.subscribeChainProp("accountState", (i) => {
681
+ this.onCaipAddressChange({
682
+ newCaipAddress: i == null ? void 0 : i.caipAddress,
683
+ resetSwapState: t,
684
+ initializeSwapState: o
685
+ });
686
+ });
687
+ };
688
+ }
689
+ constructor() {
690
+ var t, o, i;
691
+ super(), this.unsubscribe = [], this.initialParams = (t = S.state.data) == null ? void 0 : t.swap, this.detailsOpen = !1, this.caipAddress = (o = $.getAccountData()) == null ? void 0 : o.caipAddress, this.caipNetworkId = (i = $.state.activeCaipNetwork) == null ? void 0 : i.caipNetworkId, this.initialized = s.state.initialized, this.loadingQuote = s.state.loadingQuote, this.loadingPrices = s.state.loadingPrices, this.loadingTransaction = s.state.loadingTransaction, this.sourceToken = s.state.sourceToken, this.sourceTokenAmount = s.state.sourceTokenAmount, this.sourceTokenPriceInUSD = s.state.sourceTokenPriceInUSD, this.toToken = s.state.toToken, this.toTokenAmount = s.state.toTokenAmount, this.toTokenPriceInUSD = s.state.toTokenPriceInUSD, this.inputError = s.state.inputError, this.fetchError = s.state.fetchError, this.lastTokenPriceUpdate = 0, this.minTokenPriceUpdateInterval = 1e4, this.visibilityChangeHandler = () => {
692
+ document != null && document.hidden ? (clearInterval(this.interval), this.interval = void 0) : this.startTokenPriceInterval();
693
+ }, this.startTokenPriceInterval = () => {
694
+ this.interval && Date.now() - this.lastTokenPriceUpdate < this.minTokenPriceUpdateInterval || (this.lastTokenPriceUpdate && Date.now() - this.lastTokenPriceUpdate > this.minTokenPriceUpdateInterval && this.fetchTokensAndValues(), clearInterval(this.interval), this.interval = setInterval(() => {
695
+ this.fetchTokensAndValues();
696
+ }, this.minTokenPriceUpdateInterval));
697
+ }, this.watchTokensAndValues = () => {
698
+ !this.sourceToken || !this.toToken || (this.subscribeToVisibilityChange(), this.startTokenPriceInterval());
699
+ }, this.onDebouncedGetSwapCalldata = M.debounce(async () => {
700
+ await s.swapTokens();
701
+ }, 200), this.subscribe({ resetSwapState: !0, initializeSwapState: !1 })(), this.unsubscribe.push(this.subscribe({ resetSwapState: !1, initializeSwapState: !0 }), K.subscribeKey("open", (r) => {
702
+ r || s.resetState();
703
+ }), S.subscribeKey("view", (r) => {
704
+ r.includes("Swap") || s.resetValues();
705
+ }), s.subscribe((r) => {
706
+ this.initialized = r.initialized, this.loadingQuote = r.loadingQuote, this.loadingPrices = r.loadingPrices, this.loadingTransaction = r.loadingTransaction, this.sourceToken = r.sourceToken, this.sourceTokenAmount = r.sourceTokenAmount, this.sourceTokenPriceInUSD = r.sourceTokenPriceInUSD, this.toToken = r.toToken, this.toTokenAmount = r.toTokenAmount, this.toTokenPriceInUSD = r.toTokenPriceInUSD, this.inputError = r.inputError, this.fetchError = r.fetchError, r.sourceToken && r.toToken && this.watchTokensAndValues();
707
+ }));
708
+ }
709
+ async firstUpdated() {
710
+ s.initializeState(), this.watchTokensAndValues(), await this.handleSwapParameters();
711
+ }
712
+ disconnectedCallback() {
713
+ this.unsubscribe.forEach((t) => t == null ? void 0 : t()), clearInterval(this.interval), document == null || document.removeEventListener("visibilitychange", this.visibilityChangeHandler);
714
+ }
715
+ render() {
716
+ return u`
717
+ <wui-flex flexDirection="column" .padding=${["0", "4", "4", "4"]} gap="3">
718
+ ${this.initialized ? this.templateSwap() : this.templateLoading()}
719
+ </wui-flex>
720
+ `;
721
+ }
722
+ subscribeToVisibilityChange() {
723
+ document == null || document.removeEventListener("visibilitychange", this.visibilityChangeHandler), document == null || document.addEventListener("visibilitychange", this.visibilityChangeHandler);
724
+ }
725
+ fetchTokensAndValues() {
726
+ s.getNetworkTokenPrice(), s.getMyTokensWithBalance(), s.swapTokens(), this.lastTokenPriceUpdate = Date.now();
727
+ }
728
+ templateSwap() {
729
+ return u`
730
+ <wui-flex flexDirection="column" gap="3">
731
+ <wui-flex flexDirection="column" alignItems="center" gap="2" class="swap-inputs-container">
732
+ ${this.templateTokenInput("sourceToken", this.sourceToken)}
733
+ ${this.templateTokenInput("toToken", this.toToken)} ${this.templateReplaceTokensButton()}
734
+ </wui-flex>
735
+ ${this.templateDetails()} ${this.templateActionButton()}
736
+ </wui-flex>
737
+ `;
738
+ }
739
+ actionButtonLabel() {
740
+ const t = !this.sourceTokenAmount || this.sourceTokenAmount === "0";
741
+ return this.fetchError ? "Swap" : !this.sourceToken || !this.toToken ? "Select token" : t ? "Enter amount" : this.inputError ? this.inputError : "Review swap";
742
+ }
743
+ templateReplaceTokensButton() {
744
+ return u`
745
+ <wui-flex class="replace-tokens-button-container">
746
+ <wui-icon-box
747
+ @click=${this.onSwitchTokens.bind(this)}
748
+ icon="recycleHorizontal"
749
+ size="md"
750
+ variant="default"
751
+ ></wui-icon-box>
752
+ </wui-flex>
753
+ `;
754
+ }
755
+ templateLoading() {
756
+ return u`
757
+ <wui-flex flexDirection="column" gap="4">
758
+ <wui-flex flexDirection="column" alignItems="center" gap="2" class="swap-inputs-container">
759
+ <w3m-swap-input-skeleton target="sourceToken"></w3m-swap-input-skeleton>
760
+ <w3m-swap-input-skeleton target="toToken"></w3m-swap-input-skeleton>
761
+ ${this.templateReplaceTokensButton()}
762
+ </wui-flex>
763
+ ${this.templateActionButton()}
764
+ </wui-flex>
765
+ `;
766
+ }
767
+ templateTokenInput(t, o) {
768
+ var c, b;
769
+ const i = (c = s.state.myTokensWithBalance) == null ? void 0 : c.find((I) => (I == null ? void 0 : I.address) === (o == null ? void 0 : o.address)), r = t === "toToken" ? this.toTokenAmount : this.sourceTokenAmount, n = t === "toToken" ? this.toTokenPriceInUSD : this.sourceTokenPriceInUSD, a = h.parseLocalStringToNumber(r) * n;
770
+ return u`<w3m-swap-input
771
+ .value=${t === "toToken" ? this.toTokenAmount : this.sourceTokenAmount}
772
+ .disabled=${t === "toToken"}
773
+ .onSetAmount=${this.handleChangeAmount.bind(this)}
774
+ target=${t}
775
+ .token=${o}
776
+ .balance=${(b = i == null ? void 0 : i.quantity) == null ? void 0 : b.numeric}
777
+ .price=${i == null ? void 0 : i.price}
778
+ .marketValue=${a}
779
+ .onSetMaxValue=${this.onSetMaxValue.bind(this)}
780
+ ></w3m-swap-input>`;
781
+ }
782
+ onSetMaxValue(t, o) {
783
+ const i = h.bigNumber(o || "0");
784
+ this.handleChangeAmount(t, i.gt(0) ? i.toFixed(20) : "0");
785
+ }
786
+ templateDetails() {
787
+ return !this.sourceToken || !this.toToken || this.inputError ? null : u`<w3m-swap-details .detailsOpen=${this.detailsOpen}></w3m-swap-details>`;
788
+ }
789
+ handleChangeAmount(t, o) {
790
+ s.clearError(), t === "sourceToken" ? s.setSourceTokenAmount(o) : s.setToTokenAmount(o), this.onDebouncedGetSwapCalldata();
791
+ }
792
+ templateActionButton() {
793
+ const t = !this.toToken || !this.sourceToken, o = !this.sourceTokenAmount || this.sourceTokenAmount === "0", i = this.loadingQuote || this.loadingPrices || this.loadingTransaction, r = i || t || o || this.inputError;
794
+ return u` <wui-flex gap="2">
795
+ <wui-button
796
+ data-testid="swap-action-button"
797
+ class="action-button"
798
+ fullWidth
799
+ size="lg"
800
+ borderRadius="xs"
801
+ variant="accent-primary"
802
+ ?loading=${!!i}
803
+ ?disabled=${!!r}
804
+ @click=${this.onSwapPreview.bind(this)}
805
+ >
806
+ ${this.actionButtonLabel()}
807
+ </wui-button>
808
+ </wui-flex>`;
809
+ }
810
+ async onSwitchTokens() {
811
+ await s.switchTokens();
812
+ }
813
+ async onSwapPreview() {
814
+ var t, o;
815
+ this.fetchError && await s.swapTokens(), N.sendEvent({
816
+ type: "track",
817
+ event: "INITIATE_SWAP",
818
+ properties: {
819
+ network: this.caipNetworkId || "",
820
+ swapFromToken: ((t = this.sourceToken) == null ? void 0 : t.symbol) || "",
821
+ swapToToken: ((o = this.toToken) == null ? void 0 : o.symbol) || "",
822
+ swapFromAmount: this.sourceTokenAmount || "",
823
+ swapToAmount: this.toTokenAmount || "",
824
+ isSmartAccount: F($.state.activeChain) === Q.ACCOUNT_TYPES.SMART_ACCOUNT
825
+ }
826
+ }), S.push("SwapPreview");
827
+ }
828
+ async handleSwapParameters() {
829
+ this.initialParams && (s.state.initialized || await new Promise((o) => {
830
+ const i = s.subscribeKey("initialized", (r) => {
831
+ r && (i == null || i(), o());
832
+ });
833
+ }), await this.setSwapParameters(this.initialParams));
834
+ }
835
+ async setSwapParameters({ amount: t, fromToken: o, toToken: i }) {
836
+ (!s.state.tokens || !s.state.myTokensWithBalance) && await new Promise((a) => {
837
+ const c = s.subscribeKey("myTokensWithBalance", (b) => {
838
+ b && b.length > 0 && (c == null || c(), a());
839
+ });
840
+ setTimeout(() => {
841
+ c == null || c(), a();
842
+ }, 5e3);
843
+ });
844
+ const r = [
845
+ ...s.state.tokens || [],
846
+ ...s.state.myTokensWithBalance || []
847
+ ];
848
+ if (o) {
849
+ const n = r.find((a) => a.symbol.toLowerCase() === o.toLowerCase());
850
+ n && s.setSourceToken(n);
851
+ }
852
+ if (i) {
853
+ const n = r.find((a) => a.symbol.toLowerCase() === i.toLowerCase());
854
+ n && s.setToToken(n);
855
+ }
856
+ t && !isNaN(Number(t)) && s.setSourceTokenAmount(t);
857
+ }
858
+ onCaipAddressChange({ newCaipAddress: t, resetSwapState: o, initializeSwapState: i }) {
859
+ this.caipAddress !== t && (this.caipAddress = t, o && s.resetState(), i && s.initializeState());
860
+ }
861
+ onCaipNetworkChange({ newCaipNetwork: t, resetSwapState: o, initializeSwapState: i }) {
862
+ this.caipNetworkId !== (t == null ? void 0 : t.caipNetworkId) && (this.caipNetworkId = t == null ? void 0 : t.caipNetworkId, o && s.resetState(), i && s.initializeState());
863
+ }
864
+ };
865
+ p.styles = ee;
866
+ m([
867
+ w({ type: Object })
868
+ ], p.prototype, "initialParams", void 0);
869
+ m([
870
+ l()
871
+ ], p.prototype, "interval", void 0);
872
+ m([
873
+ l()
874
+ ], p.prototype, "detailsOpen", void 0);
875
+ m([
876
+ l()
877
+ ], p.prototype, "caipAddress", void 0);
878
+ m([
879
+ l()
880
+ ], p.prototype, "caipNetworkId", void 0);
881
+ m([
882
+ l()
883
+ ], p.prototype, "initialized", void 0);
884
+ m([
885
+ l()
886
+ ], p.prototype, "loadingQuote", void 0);
887
+ m([
888
+ l()
889
+ ], p.prototype, "loadingPrices", void 0);
890
+ m([
891
+ l()
892
+ ], p.prototype, "loadingTransaction", void 0);
893
+ m([
894
+ l()
895
+ ], p.prototype, "sourceToken", void 0);
896
+ m([
897
+ l()
898
+ ], p.prototype, "sourceTokenAmount", void 0);
899
+ m([
900
+ l()
901
+ ], p.prototype, "sourceTokenPriceInUSD", void 0);
902
+ m([
903
+ l()
904
+ ], p.prototype, "toToken", void 0);
905
+ m([
906
+ l()
907
+ ], p.prototype, "toTokenAmount", void 0);
908
+ m([
909
+ l()
910
+ ], p.prototype, "toTokenPriceInUSD", void 0);
911
+ m([
912
+ l()
913
+ ], p.prototype, "inputError", void 0);
914
+ m([
915
+ l()
916
+ ], p.prototype, "fetchError", void 0);
917
+ m([
918
+ l()
919
+ ], p.prototype, "lastTokenPriceUpdate", void 0);
920
+ p = m([
921
+ C("w3m-swap-view")
922
+ ], p);
923
+ const te = A`
924
+ :host > wui-flex:first-child {
925
+ overflow-y: auto;
926
+ overflow-x: hidden;
927
+ scrollbar-width: none;
928
+ }
929
+
930
+ :host > wui-flex:first-child::-webkit-scrollbar {
931
+ display: none;
932
+ }
933
+
934
+ .preview-container,
935
+ .details-container {
936
+ width: 100%;
937
+ }
938
+
939
+ .token-image {
940
+ width: 24px;
941
+ height: 24px;
942
+ box-shadow: 0 0 0 2px ${({ tokens: e }) => e.core.glass010};
943
+ border-radius: 12px;
944
+ }
945
+
946
+ wui-loading-hexagon {
947
+ position: absolute;
948
+ }
949
+
950
+ .token-item {
951
+ display: flex;
952
+ align-items: center;
953
+ justify-content: center;
954
+ gap: ${({ spacing: e }) => e[2]};
955
+ padding: ${({ spacing: e }) => e[2]};
956
+ height: 40px;
957
+ border: none;
958
+ border-radius: 80px;
959
+ background: ${({ tokens: e }) => e.theme.foregroundPrimary};
960
+ box-shadow: inset 0 0 0 1px ${({ tokens: e }) => e.theme.foregroundPrimary};
961
+ cursor: pointer;
962
+ transition: background ${({ durations: e }) => e.lg}
963
+ ${({ easings: e }) => e["ease-out-power-2"]};
964
+ will-change: background;
965
+ }
966
+
967
+ .token-item:hover {
968
+ background: ${({ tokens: e }) => e.core.glass010};
969
+ }
970
+
971
+ .preview-token-details-container {
972
+ width: 100%;
973
+ }
974
+
975
+ .details-row {
976
+ width: 100%;
977
+ padding: ${({ spacing: e }) => e[3]} ${({ spacing: e }) => e[5]};
978
+ border-radius: ${({ borderRadius: e }) => e[3]};
979
+ background: ${({ tokens: e }) => e.theme.foregroundPrimary};
980
+ }
981
+
982
+ .action-buttons-container {
983
+ width: 100%;
984
+ gap: ${({ spacing: e }) => e[2]};
985
+ }
986
+
987
+ .action-buttons-container > button {
988
+ display: flex;
989
+ align-items: center;
990
+ justify-content: center;
991
+ background: transparent;
992
+ height: 48px;
993
+ border-radius: ${({ borderRadius: e }) => e[4]};
994
+ border: none;
995
+ box-shadow: inset 0 0 0 1px ${({ tokens: e }) => e.core.glass010};
996
+ }
997
+
998
+ .action-buttons-container > button:disabled {
999
+ opacity: 0.8;
1000
+ cursor: not-allowed;
1001
+ }
1002
+
1003
+ .action-button > wui-loading-spinner {
1004
+ display: inline-block;
1005
+ }
1006
+
1007
+ .cancel-button:hover,
1008
+ .action-button:hover {
1009
+ cursor: pointer;
1010
+ }
1011
+
1012
+ .action-buttons-container > wui-button.cancel-button {
1013
+ flex: 2;
1014
+ }
1015
+
1016
+ .action-buttons-container > wui-button.action-button {
1017
+ flex: 4;
1018
+ }
1019
+
1020
+ .action-buttons-container > button.action-button > wui-text {
1021
+ color: white;
1022
+ }
1023
+
1024
+ .details-container > wui-flex {
1025
+ background: ${({ tokens: e }) => e.theme.foregroundPrimary};
1026
+ border-radius: ${({ borderRadius: e }) => e[3]};
1027
+ width: 100%;
1028
+ }
1029
+
1030
+ .details-container > wui-flex > button {
1031
+ border: none;
1032
+ background: none;
1033
+ padding: ${({ spacing: e }) => e[3]};
1034
+ border-radius: ${({ borderRadius: e }) => e[3]};
1035
+ transition: background ${({ durations: e }) => e.lg}
1036
+ ${({ easings: e }) => e["ease-out-power-2"]};
1037
+ will-change: background;
1038
+ }
1039
+
1040
+ .details-container > wui-flex > button:hover {
1041
+ background: ${({ tokens: e }) => e.theme.foregroundPrimary};
1042
+ }
1043
+
1044
+ .details-content-container {
1045
+ padding: ${({ spacing: e }) => e[2]};
1046
+ display: flex;
1047
+ align-items: center;
1048
+ justify-content: center;
1049
+ }
1050
+
1051
+ .details-content-container > wui-flex {
1052
+ width: 100%;
1053
+ }
1054
+
1055
+ .details-row {
1056
+ width: 100%;
1057
+ padding: ${({ spacing: e }) => e[3]} ${({ spacing: e }) => e[5]};
1058
+ border-radius: ${({ borderRadius: e }) => e[3]};
1059
+ background: ${({ tokens: e }) => e.theme.foregroundPrimary};
1060
+ }
1061
+ `;
1062
+ var f = function(e, t, o, i) {
1063
+ var r = arguments.length, n = r < 3 ? t : i === null ? i = Object.getOwnPropertyDescriptor(t, o) : i, a;
1064
+ if (typeof Reflect == "object" && typeof Reflect.decorate == "function") n = Reflect.decorate(e, t, o, i);
1065
+ else for (var c = e.length - 1; c >= 0; c--) (a = e[c]) && (n = (r < 3 ? a(n) : r > 3 ? a(t, o, n) : a(t, o)) || n);
1066
+ return r > 3 && n && Object.defineProperty(t, o, n), n;
1067
+ };
1068
+ let d = class extends D {
1069
+ constructor() {
1070
+ var t;
1071
+ super(), this.unsubscribe = [], this.detailsOpen = !0, this.approvalTransaction = s.state.approvalTransaction, this.swapTransaction = s.state.swapTransaction, this.sourceToken = s.state.sourceToken, this.sourceTokenAmount = s.state.sourceTokenAmount ?? "", this.sourceTokenPriceInUSD = s.state.sourceTokenPriceInUSD, this.balanceSymbol = (t = $.getAccountData()) == null ? void 0 : t.balanceSymbol, this.toToken = s.state.toToken, this.toTokenAmount = s.state.toTokenAmount ?? "", this.toTokenPriceInUSD = s.state.toTokenPriceInUSD, this.caipNetwork = $.state.activeCaipNetwork, this.inputError = s.state.inputError, this.loadingQuote = s.state.loadingQuote, this.loadingApprovalTransaction = s.state.loadingApprovalTransaction, this.loadingBuildTransaction = s.state.loadingBuildTransaction, this.loadingTransaction = s.state.loadingTransaction, this.unsubscribe.push($.subscribeChainProp("accountState", (o) => {
1072
+ (o == null ? void 0 : o.balanceSymbol) !== this.balanceSymbol && S.goBack();
1073
+ }), $.subscribeKey("activeCaipNetwork", (o) => {
1074
+ this.caipNetwork !== o && (this.caipNetwork = o);
1075
+ }), s.subscribe((o) => {
1076
+ this.approvalTransaction = o.approvalTransaction, this.swapTransaction = o.swapTransaction, this.sourceToken = o.sourceToken, this.toToken = o.toToken, this.toTokenPriceInUSD = o.toTokenPriceInUSD, this.sourceTokenAmount = o.sourceTokenAmount ?? "", this.toTokenAmount = o.toTokenAmount ?? "", this.inputError = o.inputError, o.inputError && S.goBack(), this.loadingQuote = o.loadingQuote, this.loadingApprovalTransaction = o.loadingApprovalTransaction, this.loadingBuildTransaction = o.loadingBuildTransaction, this.loadingTransaction = o.loadingTransaction;
1077
+ }));
1078
+ }
1079
+ firstUpdated() {
1080
+ s.getTransaction(), this.refreshTransaction();
1081
+ }
1082
+ disconnectedCallback() {
1083
+ this.unsubscribe.forEach((t) => t == null ? void 0 : t()), clearInterval(this.interval);
1084
+ }
1085
+ render() {
1086
+ return u`
1087
+ <wui-flex flexDirection="column" .padding=${["0", "4", "4", "4"]} gap="3">
1088
+ ${this.templateSwap()}
1089
+ </wui-flex>
1090
+ `;
1091
+ }
1092
+ refreshTransaction() {
1093
+ this.interval = setInterval(() => {
1094
+ s.getApprovalLoadingState() || s.getTransaction();
1095
+ }, 1e4);
1096
+ }
1097
+ templateSwap() {
1098
+ var b, I, U, L;
1099
+ const t = `${h.formatNumberToLocalString(parseFloat(this.sourceTokenAmount))} ${(b = this.sourceToken) == null ? void 0 : b.symbol}`, o = `${h.formatNumberToLocalString(parseFloat(this.toTokenAmount))} ${(I = this.toToken) == null ? void 0 : I.symbol}`, i = parseFloat(this.sourceTokenAmount) * this.sourceTokenPriceInUSD, r = parseFloat(this.toTokenAmount) * this.toTokenPriceInUSD, n = h.formatNumberToLocalString(i), a = h.formatNumberToLocalString(r), c = this.loadingQuote || this.loadingBuildTransaction || this.loadingTransaction || this.loadingApprovalTransaction;
1100
+ return u`
1101
+ <wui-flex flexDirection="column" alignItems="center" gap="4">
1102
+ <wui-flex class="preview-container" flexDirection="column" alignItems="flex-start" gap="4">
1103
+ <wui-flex
1104
+ class="preview-token-details-container"
1105
+ alignItems="center"
1106
+ justifyContent="space-between"
1107
+ gap="4"
1108
+ >
1109
+ <wui-flex flexDirection="column" alignItems="flex-start" gap="01">
1110
+ <wui-text variant="sm-regular" color="secondary">Send</wui-text>
1111
+ <wui-text variant="md-regular" color="primary">$${n}</wui-text>
1112
+ </wui-flex>
1113
+ <wui-token-button
1114
+ flexDirection="row-reverse"
1115
+ text=${t}
1116
+ imageSrc=${(U = this.sourceToken) == null ? void 0 : U.logoUri}
1117
+ >
1118
+ </wui-token-button>
1119
+ </wui-flex>
1120
+ <wui-icon name="recycleHorizontal" color="default" size="md"></wui-icon>
1121
+ <wui-flex
1122
+ class="preview-token-details-container"
1123
+ alignItems="center"
1124
+ justifyContent="space-between"
1125
+ gap="4"
1126
+ >
1127
+ <wui-flex flexDirection="column" alignItems="flex-start" gap="01">
1128
+ <wui-text variant="sm-regular" color="secondary">Receive</wui-text>
1129
+ <wui-text variant="md-regular" color="primary">$${a}</wui-text>
1130
+ </wui-flex>
1131
+ <wui-token-button
1132
+ flexDirection="row-reverse"
1133
+ text=${o}
1134
+ imageSrc=${(L = this.toToken) == null ? void 0 : L.logoUri}
1135
+ >
1136
+ </wui-token-button>
1137
+ </wui-flex>
1138
+ </wui-flex>
1139
+
1140
+ ${this.templateDetails()}
1141
+
1142
+ <wui-flex flexDirection="row" alignItems="center" justifyContent="center" gap="2">
1143
+ <wui-icon size="sm" color="default" name="info"></wui-icon>
1144
+ <wui-text variant="sm-regular" color="secondary">Review transaction carefully</wui-text>
1145
+ </wui-flex>
1146
+
1147
+ <wui-flex
1148
+ class="action-buttons-container"
1149
+ flexDirection="row"
1150
+ alignItems="center"
1151
+ justifyContent="space-between"
1152
+ gap="2"
1153
+ >
1154
+ <wui-button
1155
+ class="cancel-button"
1156
+ fullWidth
1157
+ size="lg"
1158
+ borderRadius="xs"
1159
+ variant="neutral-secondary"
1160
+ @click=${this.onCancelTransaction.bind(this)}
1161
+ >
1162
+ <wui-text variant="md-medium" color="secondary">Cancel</wui-text>
1163
+ </wui-button>
1164
+ <wui-button
1165
+ class="action-button"
1166
+ fullWidth
1167
+ size="lg"
1168
+ borderRadius="xs"
1169
+ variant="accent-primary"
1170
+ ?loading=${c}
1171
+ ?disabled=${c}
1172
+ @click=${this.onSendTransaction.bind(this)}
1173
+ >
1174
+ <wui-text variant="md-medium" color="invert"> ${this.actionButtonLabel()} </wui-text>
1175
+ </wui-button>
1176
+ </wui-flex>
1177
+ </wui-flex>
1178
+ `;
1179
+ }
1180
+ templateDetails() {
1181
+ return !this.sourceToken || !this.toToken || this.inputError ? null : u`<w3m-swap-details .detailsOpen=${this.detailsOpen}></w3m-swap-details>`;
1182
+ }
1183
+ actionButtonLabel() {
1184
+ return this.loadingApprovalTransaction ? "Approving..." : this.approvalTransaction ? "Approve" : "Swap";
1185
+ }
1186
+ onCancelTransaction() {
1187
+ S.goBack();
1188
+ }
1189
+ onSendTransaction() {
1190
+ this.approvalTransaction ? s.sendTransactionForApproval(this.approvalTransaction) : s.sendTransactionForSwap(this.swapTransaction);
1191
+ }
1192
+ };
1193
+ d.styles = te;
1194
+ f([
1195
+ l()
1196
+ ], d.prototype, "interval", void 0);
1197
+ f([
1198
+ l()
1199
+ ], d.prototype, "detailsOpen", void 0);
1200
+ f([
1201
+ l()
1202
+ ], d.prototype, "approvalTransaction", void 0);
1203
+ f([
1204
+ l()
1205
+ ], d.prototype, "swapTransaction", void 0);
1206
+ f([
1207
+ l()
1208
+ ], d.prototype, "sourceToken", void 0);
1209
+ f([
1210
+ l()
1211
+ ], d.prototype, "sourceTokenAmount", void 0);
1212
+ f([
1213
+ l()
1214
+ ], d.prototype, "sourceTokenPriceInUSD", void 0);
1215
+ f([
1216
+ l()
1217
+ ], d.prototype, "balanceSymbol", void 0);
1218
+ f([
1219
+ l()
1220
+ ], d.prototype, "toToken", void 0);
1221
+ f([
1222
+ l()
1223
+ ], d.prototype, "toTokenAmount", void 0);
1224
+ f([
1225
+ l()
1226
+ ], d.prototype, "toTokenPriceInUSD", void 0);
1227
+ f([
1228
+ l()
1229
+ ], d.prototype, "caipNetwork", void 0);
1230
+ f([
1231
+ l()
1232
+ ], d.prototype, "inputError", void 0);
1233
+ f([
1234
+ l()
1235
+ ], d.prototype, "loadingQuote", void 0);
1236
+ f([
1237
+ l()
1238
+ ], d.prototype, "loadingApprovalTransaction", void 0);
1239
+ f([
1240
+ l()
1241
+ ], d.prototype, "loadingBuildTransaction", void 0);
1242
+ f([
1243
+ l()
1244
+ ], d.prototype, "loadingTransaction", void 0);
1245
+ d = f([
1246
+ C("w3m-swap-preview-view")
1247
+ ], d);
1248
+ const oe = A`
1249
+ :host {
1250
+ width: 100%;
1251
+ height: 60px;
1252
+ min-height: 60px;
1253
+ }
1254
+
1255
+ :host > wui-flex {
1256
+ cursor: pointer;
1257
+ height: 100%;
1258
+ display: flex;
1259
+ column-gap: ${({ spacing: e }) => e[3]};
1260
+ padding: ${({ spacing: e }) => e[2]};
1261
+ padding-right: ${({ spacing: e }) => e[4]};
1262
+ width: 100%;
1263
+ background-color: transparent;
1264
+ border-radius: ${({ borderRadius: e }) => e[4]};
1265
+ color: ${({ tokens: e }) => e.theme.foregroundSecondary};
1266
+ transition:
1267
+ background-color ${({ durations: e }) => e.lg}
1268
+ ${({ easings: e }) => e["ease-out-power-2"]},
1269
+ opacity ${({ durations: e }) => e.lg} ${({ easings: e }) => e["ease-out-power-2"]};
1270
+ will-change: background-color, opacity;
1271
+ }
1272
+
1273
+ @media (hover: hover) and (pointer: fine) {
1274
+ :host > wui-flex:hover {
1275
+ background-color: ${({ tokens: e }) => e.theme.foregroundPrimary};
1276
+ }
1277
+
1278
+ :host > wui-flex:active {
1279
+ background-color: ${({ tokens: e }) => e.core.glass010};
1280
+ }
1281
+ }
1282
+
1283
+ :host([disabled]) > wui-flex {
1284
+ opacity: 0.6;
1285
+ }
1286
+
1287
+ :host([disabled]) > wui-flex:hover {
1288
+ background-color: transparent;
1289
+ }
1290
+
1291
+ :host > wui-flex > wui-flex {
1292
+ flex: 1;
1293
+ }
1294
+
1295
+ :host > wui-flex > wui-image,
1296
+ :host > wui-flex > .token-item-image-placeholder {
1297
+ width: 40px;
1298
+ max-width: 40px;
1299
+ height: 40px;
1300
+ border-radius: ${({ borderRadius: e }) => e[20]};
1301
+ position: relative;
1302
+ }
1303
+
1304
+ :host > wui-flex > .token-item-image-placeholder {
1305
+ display: flex;
1306
+ align-items: center;
1307
+ justify-content: center;
1308
+ }
1309
+
1310
+ :host > wui-flex > wui-image::after,
1311
+ :host > wui-flex > .token-item-image-placeholder::after {
1312
+ position: absolute;
1313
+ content: '';
1314
+ inset: 0;
1315
+ box-shadow: inset 0 0 0 1px ${({ tokens: e }) => e.core.glass010};
1316
+ border-radius: ${({ borderRadius: e }) => e[8]};
1317
+ }
1318
+
1319
+ button > wui-icon-box[data-variant='square-blue'] {
1320
+ border-radius: ${({ borderRadius: e }) => e[2]};
1321
+ position: relative;
1322
+ border: none;
1323
+ width: 36px;
1324
+ height: 36px;
1325
+ }
1326
+ `;
1327
+ var E = function(e, t, o, i) {
1328
+ var r = arguments.length, n = r < 3 ? t : i === null ? i = Object.getOwnPropertyDescriptor(t, o) : i, a;
1329
+ if (typeof Reflect == "object" && typeof Reflect.decorate == "function") n = Reflect.decorate(e, t, o, i);
1330
+ else for (var c = e.length - 1; c >= 0; c--) (a = e[c]) && (n = (r < 3 ? a(n) : r > 3 ? a(t, o, n) : a(t, o)) || n);
1331
+ return r > 3 && n && Object.defineProperty(t, o, n), n;
1332
+ };
1333
+ let P = class extends D {
1334
+ constructor() {
1335
+ super(), this.observer = new IntersectionObserver(() => {
1336
+ }), this.imageSrc = void 0, this.name = void 0, this.symbol = void 0, this.price = void 0, this.amount = void 0, this.visible = !1, this.imageError = !1, this.observer = new IntersectionObserver((t) => {
1337
+ t.forEach((o) => {
1338
+ o.isIntersecting ? this.visible = !0 : this.visible = !1;
1339
+ });
1340
+ }, { threshold: 0.1 });
1341
+ }
1342
+ firstUpdated() {
1343
+ this.observer.observe(this);
1344
+ }
1345
+ disconnectedCallback() {
1346
+ this.observer.disconnect();
1347
+ }
1348
+ render() {
1349
+ var o;
1350
+ if (!this.visible)
1351
+ return null;
1352
+ const t = this.amount && this.price ? (o = h.multiply(this.price, this.amount)) == null ? void 0 : o.toFixed(3) : null;
1353
+ return u`
1354
+ <wui-flex alignItems="center">
1355
+ ${this.visualTemplate()}
1356
+ <wui-flex flexDirection="column" gap="1">
1357
+ <wui-flex justifyContent="space-between">
1358
+ <wui-text variant="md-medium" color="primary" lineClamp="1">${this.name}</wui-text>
1359
+ ${t ? u`
1360
+ <wui-text variant="md-medium" color="primary">
1361
+ $${h.formatNumberToLocalString(t, 3)}
1362
+ </wui-text>
1363
+ ` : null}
1364
+ </wui-flex>
1365
+ <wui-flex justifyContent="space-between">
1366
+ <wui-text variant="sm-regular" color="secondary" lineClamp="1">${this.symbol}</wui-text>
1367
+ ${this.amount ? u`<wui-text variant="sm-regular" color="secondary">
1368
+ ${h.formatNumberToLocalString(this.amount, 5)}
1369
+ </wui-text>` : null}
1370
+ </wui-flex>
1371
+ </wui-flex>
1372
+ </wui-flex>
1373
+ `;
1374
+ }
1375
+ visualTemplate() {
1376
+ return this.imageError ? u`<wui-flex class="token-item-image-placeholder">
1377
+ <wui-icon name="image" color="inherit"></wui-icon>
1378
+ </wui-flex>` : this.imageSrc ? u`<wui-image
1379
+ width="40"
1380
+ height="40"
1381
+ src=${this.imageSrc}
1382
+ @onLoadError=${this.imageLoadError}
1383
+ ></wui-image>` : null;
1384
+ }
1385
+ imageLoadError() {
1386
+ this.imageError = !0;
1387
+ }
1388
+ };
1389
+ P.styles = [W, q, oe];
1390
+ E([
1391
+ w()
1392
+ ], P.prototype, "imageSrc", void 0);
1393
+ E([
1394
+ w()
1395
+ ], P.prototype, "name", void 0);
1396
+ E([
1397
+ w()
1398
+ ], P.prototype, "symbol", void 0);
1399
+ E([
1400
+ w()
1401
+ ], P.prototype, "price", void 0);
1402
+ E([
1403
+ w()
1404
+ ], P.prototype, "amount", void 0);
1405
+ E([
1406
+ l()
1407
+ ], P.prototype, "visible", void 0);
1408
+ E([
1409
+ l()
1410
+ ], P.prototype, "imageError", void 0);
1411
+ P = E([
1412
+ C("wui-token-list-item")
1413
+ ], P);
1414
+ const ie = A`
1415
+ :host {
1416
+ width: 100%;
1417
+ }
1418
+
1419
+ :host > wui-flex {
1420
+ cursor: pointer;
1421
+ height: 100%;
1422
+ width: 100%;
1423
+ display: flex;
1424
+ column-gap: ${({ spacing: e }) => e[3]};
1425
+ padding: ${({ spacing: e }) => e[2]};
1426
+ padding-right: ${({ spacing: e }) => e[4]};
1427
+ }
1428
+
1429
+ wui-flex {
1430
+ display: flex;
1431
+ flex: 1;
1432
+ }
1433
+ `;
1434
+ var ne = function(e, t, o, i) {
1435
+ var r = arguments.length, n = r < 3 ? t : i === null ? i = Object.getOwnPropertyDescriptor(t, o) : i, a;
1436
+ if (typeof Reflect == "object" && typeof Reflect.decorate == "function") n = Reflect.decorate(e, t, o, i);
1437
+ else for (var c = e.length - 1; c >= 0; c--) (a = e[c]) && (n = (r < 3 ? a(n) : r > 3 ? a(t, o, n) : a(t, o)) || n);
1438
+ return r > 3 && n && Object.defineProperty(t, o, n), n;
1439
+ };
1440
+ let O = class extends D {
1441
+ render() {
1442
+ return u`
1443
+ <wui-flex alignItems="center">
1444
+ <wui-shimmer width="40px" height="40px"></wui-shimmer>
1445
+ <wui-flex flexDirection="column" gap="1">
1446
+ <wui-shimmer width="72px" height="16px" borderRadius="4xs"></wui-shimmer>
1447
+ <wui-shimmer width="148px" height="14px" borderRadius="4xs"></wui-shimmer>
1448
+ </wui-flex>
1449
+ <wui-flex flexDirection="column" gap="1" alignItems="flex-end">
1450
+ <wui-shimmer width="24px" height="12px" borderRadius="4xs"></wui-shimmer>
1451
+ <wui-shimmer width="32px" height="12px" borderRadius="4xs"></wui-shimmer>
1452
+ </wui-flex>
1453
+ </wui-flex>
1454
+ `;
1455
+ }
1456
+ };
1457
+ O.styles = [W, ie];
1458
+ O = ne([
1459
+ C("wui-token-list-item-loader")
1460
+ ], O);
1461
+ const re = A`
1462
+ :host {
1463
+ --tokens-scroll--top-opacity: 0;
1464
+ --tokens-scroll--bottom-opacity: 1;
1465
+ --suggested-tokens-scroll--left-opacity: 0;
1466
+ --suggested-tokens-scroll--right-opacity: 1;
1467
+ }
1468
+
1469
+ :host > wui-flex:first-child {
1470
+ overflow-y: hidden;
1471
+ overflow-x: hidden;
1472
+ scrollbar-width: none;
1473
+ scrollbar-height: none;
1474
+ }
1475
+
1476
+ :host > wui-flex:first-child::-webkit-scrollbar {
1477
+ display: none;
1478
+ }
1479
+
1480
+ wui-loading-hexagon {
1481
+ position: absolute;
1482
+ }
1483
+
1484
+ .suggested-tokens-container {
1485
+ overflow-x: auto;
1486
+ mask-image: linear-gradient(
1487
+ to right,
1488
+ rgba(0, 0, 0, calc(1 - var(--suggested-tokens-scroll--left-opacity))) 0px,
1489
+ rgba(200, 200, 200, calc(1 - var(--suggested-tokens-scroll--left-opacity))) 1px,
1490
+ black 50px,
1491
+ black 90px,
1492
+ black calc(100% - 90px),
1493
+ black calc(100% - 50px),
1494
+ rgba(155, 155, 155, calc(1 - var(--suggested-tokens-scroll--right-opacity))) calc(100% - 1px),
1495
+ rgba(0, 0, 0, calc(1 - var(--suggested-tokens-scroll--right-opacity))) 100%
1496
+ );
1497
+ }
1498
+
1499
+ .suggested-tokens-container::-webkit-scrollbar {
1500
+ display: none;
1501
+ }
1502
+
1503
+ .tokens-container {
1504
+ border-top: 1px solid ${({ tokens: e }) => e.core.glass010};
1505
+ height: 100%;
1506
+ max-height: 390px;
1507
+ }
1508
+
1509
+ .tokens {
1510
+ width: 100%;
1511
+ overflow-y: auto;
1512
+ mask-image: linear-gradient(
1513
+ to bottom,
1514
+ rgba(0, 0, 0, calc(1 - var(--tokens-scroll--top-opacity))) 0px,
1515
+ rgba(200, 200, 200, calc(1 - var(--tokens-scroll--top-opacity))) 1px,
1516
+ black 50px,
1517
+ black 90px,
1518
+ black calc(100% - 90px),
1519
+ black calc(100% - 50px),
1520
+ rgba(155, 155, 155, calc(1 - var(--tokens-scroll--bottom-opacity))) calc(100% - 1px),
1521
+ rgba(0, 0, 0, calc(1 - var(--tokens-scroll--bottom-opacity))) 100%
1522
+ );
1523
+ }
1524
+
1525
+ .network-search-input,
1526
+ .select-network-button {
1527
+ height: 40px;
1528
+ }
1529
+
1530
+ .select-network-button {
1531
+ border: none;
1532
+ display: flex;
1533
+ flex-direction: row;
1534
+ align-items: center;
1535
+ justify-content: center;
1536
+ gap: ${({ spacing: e }) => e[2]};
1537
+ box-shadow: inset 0 0 0 1px ${({ tokens: e }) => e.core.glass010};
1538
+ background-color: transparent;
1539
+ border-radius: ${({ borderRadius: e }) => e[3]};
1540
+ padding: ${({ spacing: e }) => e[2]};
1541
+ align-items: center;
1542
+ transition: background-color ${({ durations: e }) => e.lg}
1543
+ ${({ easings: e }) => e["ease-out-power-2"]};
1544
+ will-change: background-color;
1545
+ }
1546
+
1547
+ .select-network-button:hover {
1548
+ background-color: ${({ tokens: e }) => e.theme.foregroundPrimary};
1549
+ }
1550
+
1551
+ .select-network-button > wui-image {
1552
+ width: 26px;
1553
+ height: 26px;
1554
+ border-radius: ${({ borderRadius: e }) => e[4]};
1555
+ box-shadow: inset 0 0 0 1px ${({ tokens: e }) => e.core.glass010};
1556
+ }
1557
+ `;
1558
+ var v = function(e, t, o, i) {
1559
+ var r = arguments.length, n = r < 3 ? t : i === null ? i = Object.getOwnPropertyDescriptor(t, o) : i, a;
1560
+ if (typeof Reflect == "object" && typeof Reflect.decorate == "function") n = Reflect.decorate(e, t, o, i);
1561
+ else for (var c = e.length - 1; c >= 0; c--) (a = e[c]) && (n = (r < 3 ? a(n) : r > 3 ? a(t, o, n) : a(t, o)) || n);
1562
+ return r > 3 && n && Object.defineProperty(t, o, n), n;
1563
+ };
1564
+ let x = class extends D {
1565
+ constructor() {
1566
+ var t;
1567
+ super(), this.unsubscribe = [], this.targetToken = (t = S.state.data) == null ? void 0 : t.target, this.sourceToken = s.state.sourceToken, this.sourceTokenAmount = s.state.sourceTokenAmount, this.toToken = s.state.toToken, this.myTokensWithBalance = s.state.myTokensWithBalance, this.popularTokens = s.state.popularTokens, this.suggestedTokens = s.state.suggestedTokens, this.tokensLoading = s.state.tokensLoading, this.searchValue = "", this.unsubscribe.push(s.subscribe((o) => {
1568
+ this.sourceToken = o.sourceToken, this.toToken = o.toToken, this.myTokensWithBalance = o.myTokensWithBalance, this.popularTokens = o.popularTokens, this.suggestedTokens = o.suggestedTokens, this.tokensLoading = o.tokensLoading;
1569
+ }));
1570
+ }
1571
+ async firstUpdated() {
1572
+ await s.getTokenList();
1573
+ }
1574
+ updated() {
1575
+ var i, r;
1576
+ const t = (i = this.renderRoot) == null ? void 0 : i.querySelector(".suggested-tokens-container");
1577
+ t == null || t.addEventListener("scroll", this.handleSuggestedTokensScroll.bind(this));
1578
+ const o = (r = this.renderRoot) == null ? void 0 : r.querySelector(".tokens");
1579
+ o == null || o.addEventListener("scroll", this.handleTokenListScroll.bind(this));
1580
+ }
1581
+ disconnectedCallback() {
1582
+ var i, r;
1583
+ super.disconnectedCallback();
1584
+ const t = (i = this.renderRoot) == null ? void 0 : i.querySelector(".suggested-tokens-container"), o = (r = this.renderRoot) == null ? void 0 : r.querySelector(".tokens");
1585
+ t == null || t.removeEventListener("scroll", this.handleSuggestedTokensScroll.bind(this)), o == null || o.removeEventListener("scroll", this.handleTokenListScroll.bind(this)), clearInterval(this.interval);
1586
+ }
1587
+ render() {
1588
+ return u`
1589
+ <wui-flex flexDirection="column" gap="3">
1590
+ ${this.templateSearchInput()} ${this.templateSuggestedTokens()} ${this.templateTokens()}
1591
+ </wui-flex>
1592
+ `;
1593
+ }
1594
+ onSelectToken(t) {
1595
+ this.targetToken === "sourceToken" ? s.setSourceToken(t) : (s.setToToken(t), this.sourceToken && this.sourceTokenAmount && s.swapTokens()), S.goBack();
1596
+ }
1597
+ templateSearchInput() {
1598
+ return u`
1599
+ <wui-flex .padding=${["1", "3", "0", "3"]} gap="2">
1600
+ <wui-input-text
1601
+ data-testid="swap-select-token-search-input"
1602
+ class="network-search-input"
1603
+ size="sm"
1604
+ placeholder="Search token"
1605
+ icon="search"
1606
+ .value=${this.searchValue}
1607
+ @inputChange=${this.onSearchInputChange.bind(this)}
1608
+ ></wui-input-text>
1609
+ </wui-flex>
1610
+ `;
1611
+ }
1612
+ templateMyTokens() {
1613
+ const t = this.myTokensWithBalance ? Object.values(this.myTokensWithBalance) : [], o = this.filterTokensWithText(t, this.searchValue);
1614
+ return (o == null ? void 0 : o.length) > 0 ? u`<wui-flex justifyContent="flex-start" padding="2">
1615
+ <wui-text variant="md-medium" color="secondary">Your tokens</wui-text>
1616
+ </wui-flex>
1617
+ ${o.map((i) => {
1618
+ var n, a, c;
1619
+ const r = i.symbol === ((n = this.sourceToken) == null ? void 0 : n.symbol) || i.symbol === ((a = this.toToken) == null ? void 0 : a.symbol);
1620
+ return u`
1621
+ <wui-token-list-item
1622
+ data-testid="swap-select-token-item-${i.symbol}"
1623
+ name=${i.name}
1624
+ ?disabled=${r}
1625
+ symbol=${i.symbol}
1626
+ price=${i == null ? void 0 : i.price}
1627
+ amount=${(c = i == null ? void 0 : i.quantity) == null ? void 0 : c.numeric}
1628
+ imageSrc=${i.logoUri}
1629
+ @click=${() => {
1630
+ r || this.onSelectToken(i);
1631
+ }}
1632
+ >
1633
+ </wui-token-list-item>
1634
+ `;
1635
+ })}` : null;
1636
+ }
1637
+ templateAllTokens() {
1638
+ const t = this.popularTokens ? this.popularTokens : [], o = this.filterTokensWithText(t, this.searchValue);
1639
+ return this.tokensLoading ? u`
1640
+ <wui-token-list-item-loader></wui-token-list-item-loader>
1641
+ <wui-token-list-item-loader></wui-token-list-item-loader>
1642
+ <wui-token-list-item-loader></wui-token-list-item-loader>
1643
+ <wui-token-list-item-loader></wui-token-list-item-loader>
1644
+ <wui-token-list-item-loader></wui-token-list-item-loader>
1645
+ ` : (o == null ? void 0 : o.length) > 0 ? u`
1646
+ ${o.map((i) => u`
1647
+ <wui-token-list-item
1648
+ data-testid="swap-select-token-item-${i.symbol}"
1649
+ name=${i.name}
1650
+ symbol=${i.symbol}
1651
+ imageSrc=${i.logoUri}
1652
+ @click=${() => this.onSelectToken(i)}
1653
+ >
1654
+ </wui-token-list-item>
1655
+ `)}
1656
+ ` : null;
1657
+ }
1658
+ templateTokens() {
1659
+ return u`
1660
+ <wui-flex class="tokens-container">
1661
+ <wui-flex class="tokens" .padding=${["0", "2", "2", "2"]} flexDirection="column">
1662
+ ${this.templateMyTokens()}
1663
+ <wui-flex justifyContent="flex-start" padding="3">
1664
+ <wui-text variant="md-medium" color="secondary">Tokens</wui-text>
1665
+ </wui-flex>
1666
+ ${this.templateAllTokens()}
1667
+ </wui-flex>
1668
+ </wui-flex>
1669
+ `;
1670
+ }
1671
+ templateSuggestedTokens() {
1672
+ const t = this.suggestedTokens ? this.suggestedTokens.slice(0, 8) : null;
1673
+ return this.tokensLoading ? u`
1674
+ <wui-flex
1675
+ class="suggested-tokens-container"
1676
+ .padding=${["0", "3", "0", "3"]}
1677
+ gap="2"
1678
+ >
1679
+ <wui-token-button loading></wui-token-button>
1680
+ <wui-token-button loading></wui-token-button>
1681
+ <wui-token-button loading></wui-token-button>
1682
+ <wui-token-button loading></wui-token-button>
1683
+ <wui-token-button loading></wui-token-button>
1684
+ </wui-flex>
1685
+ ` : t ? u`
1686
+ <wui-flex
1687
+ class="suggested-tokens-container"
1688
+ .padding=${["0", "3", "0", "3"]}
1689
+ gap="2"
1690
+ >
1691
+ ${t.map((o) => u`
1692
+ <wui-token-button
1693
+ text=${o.symbol}
1694
+ imageSrc=${o.logoUri}
1695
+ @click=${() => this.onSelectToken(o)}
1696
+ >
1697
+ </wui-token-button>
1698
+ `)}
1699
+ </wui-flex>
1700
+ ` : null;
1701
+ }
1702
+ onSearchInputChange(t) {
1703
+ this.searchValue = t.detail;
1704
+ }
1705
+ handleSuggestedTokensScroll() {
1706
+ var o;
1707
+ const t = (o = this.renderRoot) == null ? void 0 : o.querySelector(".suggested-tokens-container");
1708
+ t && (t.style.setProperty("--suggested-tokens-scroll--left-opacity", _.interpolate([0, 100], [0, 1], t.scrollLeft).toString()), t.style.setProperty("--suggested-tokens-scroll--right-opacity", _.interpolate([0, 100], [0, 1], t.scrollWidth - t.scrollLeft - t.offsetWidth).toString()));
1709
+ }
1710
+ handleTokenListScroll() {
1711
+ var o;
1712
+ const t = (o = this.renderRoot) == null ? void 0 : o.querySelector(".tokens");
1713
+ t && (t.style.setProperty("--tokens-scroll--top-opacity", _.interpolate([0, 100], [0, 1], t.scrollTop).toString()), t.style.setProperty("--tokens-scroll--bottom-opacity", _.interpolate([0, 100], [0, 1], t.scrollHeight - t.scrollTop - t.offsetHeight).toString()));
1714
+ }
1715
+ filterTokensWithText(t, o) {
1716
+ return t.filter((i) => `${i.symbol} ${i.name} ${i.address}`.toLowerCase().includes(o.toLowerCase())).sort((i, r) => {
1717
+ const n = `${i.symbol} ${i.name} ${i.address}`.toLowerCase(), a = `${r.symbol} ${r.name} ${r.address}`.toLowerCase(), c = n.indexOf(o.toLowerCase()), b = a.indexOf(o.toLowerCase());
1718
+ return c - b;
1719
+ });
1720
+ }
1721
+ };
1722
+ x.styles = re;
1723
+ v([
1724
+ l()
1725
+ ], x.prototype, "interval", void 0);
1726
+ v([
1727
+ l()
1728
+ ], x.prototype, "targetToken", void 0);
1729
+ v([
1730
+ l()
1731
+ ], x.prototype, "sourceToken", void 0);
1732
+ v([
1733
+ l()
1734
+ ], x.prototype, "sourceTokenAmount", void 0);
1735
+ v([
1736
+ l()
1737
+ ], x.prototype, "toToken", void 0);
1738
+ v([
1739
+ l()
1740
+ ], x.prototype, "myTokensWithBalance", void 0);
1741
+ v([
1742
+ l()
1743
+ ], x.prototype, "popularTokens", void 0);
1744
+ v([
1745
+ l()
1746
+ ], x.prototype, "suggestedTokens", void 0);
1747
+ v([
1748
+ l()
1749
+ ], x.prototype, "tokensLoading", void 0);
1750
+ v([
1751
+ l()
1752
+ ], x.prototype, "searchValue", void 0);
1753
+ x = v([
1754
+ C("w3m-swap-select-token-view")
1755
+ ], x);
1756
+ export {
1757
+ d as W3mSwapPreviewView,
1758
+ x as W3mSwapSelectTokenView,
1759
+ p as W3mSwapView
1760
+ };