@prohetamine/redstone 0.0.1

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 (160) hide show
  1. package/dist/PhArrowCircleDown-BR-zH4LC.js +14 -0
  2. package/dist/PhArrowCircleDown-Sb38khBy.mjs +73 -0
  3. package/dist/PhArrowClockwise-BE5j9P0Z.mjs +73 -0
  4. package/dist/PhArrowClockwise-BRaehQGe.js +14 -0
  5. package/dist/PhArrowDown-B_WmmmY9.js +14 -0
  6. package/dist/PhArrowDown-CFEyR2dR.mjs +73 -0
  7. package/dist/PhArrowLeft-CYfU7NZj.mjs +73 -0
  8. package/dist/PhArrowLeft-CkEd70hm.js +14 -0
  9. package/dist/PhArrowRight-C07Qkx86.js +14 -0
  10. package/dist/PhArrowRight-EermNu0V.mjs +73 -0
  11. package/dist/PhArrowSquareOut-BjTBfzOP.js +14 -0
  12. package/dist/PhArrowSquareOut-DZwTtw54.mjs +73 -0
  13. package/dist/PhArrowUp-DB4CCSss.js +14 -0
  14. package/dist/PhArrowUp-xTpLFQkg.mjs +73 -0
  15. package/dist/PhArrowUpRight-CQbvn6NO.mjs +73 -0
  16. package/dist/PhArrowUpRight-GpCIMsAh.js +14 -0
  17. package/dist/PhArrowsClockwise-BgcIUg-Z.js +14 -0
  18. package/dist/PhArrowsClockwise-DnUYZTVx.mjs +73 -0
  19. package/dist/PhArrowsDownUp-C8KXUqtu.js +14 -0
  20. package/dist/PhArrowsDownUp-DgoprEe2.mjs +73 -0
  21. package/dist/PhArrowsLeftRight-CahChzCj.js +14 -0
  22. package/dist/PhArrowsLeftRight-FD4AZiLh.mjs +73 -0
  23. package/dist/PhBank-DIqIL4x_.js +14 -0
  24. package/dist/PhBank-DbQOQ9zJ.mjs +73 -0
  25. package/dist/PhBrowser-BCBXK2IM.mjs +73 -0
  26. package/dist/PhBrowser-laCKtn7T.js +14 -0
  27. package/dist/PhCaretDown-CnjP-QjZ.mjs +73 -0
  28. package/dist/PhCaretDown-DDe42xDU.js +14 -0
  29. package/dist/PhCaretLeft-Cskc5OY9.js +14 -0
  30. package/dist/PhCaretLeft-DkuXxjf_.mjs +73 -0
  31. package/dist/PhCaretRight-CBWpghxt.mjs +73 -0
  32. package/dist/PhCaretRight-DNgI5w_B.js +14 -0
  33. package/dist/PhCaretUp-CQ-OztBV.mjs +73 -0
  34. package/dist/PhCaretUp-CUZ4g_Me.js +14 -0
  35. package/dist/PhCheck-BVV_Dwfo.js +14 -0
  36. package/dist/PhCheck-t515emYS.mjs +73 -0
  37. package/dist/PhCircleHalf-BuQTmrKW.mjs +73 -0
  38. package/dist/PhCircleHalf-DDC7rige.js +14 -0
  39. package/dist/PhClock-BqynEKWl.js +14 -0
  40. package/dist/PhClock-D6XkTmM_.mjs +73 -0
  41. package/dist/PhCompass-2QeeX5Ad.mjs +73 -0
  42. package/dist/PhCompass-BsuJwXAE.js +14 -0
  43. package/dist/PhCopy-CO34-_xD.mjs +73 -0
  44. package/dist/PhCopy-MVqtRS6X.js +14 -0
  45. package/dist/PhCreditCard-Dq4kdjCw.js +14 -0
  46. package/dist/PhCreditCard-bfnqYflD.mjs +73 -0
  47. package/dist/PhCurrencyDollar-6k8UWxal.js +14 -0
  48. package/dist/PhCurrencyDollar-BekVYPtC.mjs +73 -0
  49. package/dist/PhDesktop-BkNzf3rT.mjs +73 -0
  50. package/dist/PhDesktop-CfsXQ0vC.js +14 -0
  51. package/dist/PhDeviceMobile-BT3Mg_b0.mjs +73 -0
  52. package/dist/PhDeviceMobile-BnrrDrwf.js +14 -0
  53. package/dist/PhDotsThree-6LRvhAcL.js +14 -0
  54. package/dist/PhDotsThree-kpf2OKxJ.mjs +73 -0
  55. package/dist/PhEnvelope-CHsfC2e0.js +14 -0
  56. package/dist/PhEnvelope-UFKpKtwf.mjs +73 -0
  57. package/dist/PhFunnelSimple-CdAqSIhK.mjs +73 -0
  58. package/dist/PhFunnelSimple-JAk7X9Wo.js +14 -0
  59. package/dist/PhGlobe-B3RYXl8h.mjs +73 -0
  60. package/dist/PhGlobe-Tfs4MfpG.js +14 -0
  61. package/dist/PhIdentificationCard-Dqmd6eY1.js +14 -0
  62. package/dist/PhIdentificationCard-rSq59Czm.mjs +73 -0
  63. package/dist/PhImage-aEryzfCi.js +14 -0
  64. package/dist/PhImage-ynsEnFd_.mjs +73 -0
  65. package/dist/PhInfo-B7lsWl6m.mjs +73 -0
  66. package/dist/PhInfo-D6oUrWpA.js +14 -0
  67. package/dist/PhLightbulb-FQDaMMqu.mjs +73 -0
  68. package/dist/PhLightbulb-qbEduhPa.js +14 -0
  69. package/dist/PhMagnifyingGlass-COdRH2k5.js +14 -0
  70. package/dist/PhMagnifyingGlass-_NXk13-0.mjs +73 -0
  71. package/dist/PhPaperPlaneRight-BYi7SorW.mjs +73 -0
  72. package/dist/PhPaperPlaneRight-DrpVAQOZ.js +14 -0
  73. package/dist/PhPlus-25KQTPHG.mjs +73 -0
  74. package/dist/PhPlus-BhUXef08.js +14 -0
  75. package/dist/PhPower-BKl7gzsB.mjs +73 -0
  76. package/dist/PhPower-BNJf1AGQ.js +14 -0
  77. package/dist/PhPuzzlePiece-BkZeF8CX.js +14 -0
  78. package/dist/PhPuzzlePiece-BqUI4GRs.mjs +73 -0
  79. package/dist/PhQrCode-C-tqZKPP.mjs +73 -0
  80. package/dist/PhQrCode-C0v0iXQN.js +14 -0
  81. package/dist/PhQuestion-BBAiRWgt.js +14 -0
  82. package/dist/PhQuestion-CtYvffyD.mjs +73 -0
  83. package/dist/PhQuestionMark-BNbtL2yx.mjs +73 -0
  84. package/dist/PhQuestionMark-BvGUBZ1h.js +14 -0
  85. package/dist/PhSealCheck-B0TEqWpq.mjs +73 -0
  86. package/dist/PhSealCheck-BwNkuF7G.js +14 -0
  87. package/dist/PhSignOut-C1rMSNaS.js +14 -0
  88. package/dist/PhSignOut-HX2_BVsD.mjs +73 -0
  89. package/dist/PhSpinner-CoDYLYOX.mjs +73 -0
  90. package/dist/PhSpinner-nmsGWDQl.js +14 -0
  91. package/dist/PhTrash-CALlKx3e.js +14 -0
  92. package/dist/PhTrash-DeQHS8ZP.mjs +73 -0
  93. package/dist/PhUser-CA0e5OPI.js +14 -0
  94. package/dist/PhUser-Cy5EY3vX.mjs +73 -0
  95. package/dist/PhVault-DdXjVOO9.mjs +73 -0
  96. package/dist/PhVault-DqxV75cz.js +14 -0
  97. package/dist/PhWallet-CeQrfGYc.mjs +73 -0
  98. package/dist/PhWallet-CyCuEs2U.js +14 -0
  99. package/dist/PhWarning-BKaHv_wT.mjs +73 -0
  100. package/dist/PhWarning-C7oj86bY.js +14 -0
  101. package/dist/PhWarningCircle-8MWw-QgE.mjs +73 -0
  102. package/dist/PhWarningCircle-CrNPXGj4.js +14 -0
  103. package/dist/PhX-9lsrXjyl.js +14 -0
  104. package/dist/PhX-DgXr_Fb0.mjs +73 -0
  105. package/dist/ReownAuthentication-Bfv31LzI.mjs +274 -0
  106. package/dist/ReownAuthentication-d8aYgGOq.js +5 -0
  107. package/dist/SwapController-4lzoYsYr.js +1 -0
  108. package/dist/SwapController-DjzUWRyQ.mjs +462 -0
  109. package/dist/ccip-CvwbEhki.js +1 -0
  110. package/dist/ccip-TuO68NeE.mjs +150 -0
  111. package/dist/data-capture-BwdjH2vc.mjs +489 -0
  112. package/dist/data-capture-xVUNZJ2T.js +242 -0
  113. package/dist/email-BCZObJCY.js +90 -0
  114. package/dist/email-m-wo60fN.mjs +338 -0
  115. package/dist/embedded-wallet-CGSri-4g.js +410 -0
  116. package/dist/embedded-wallet-DdZmv5qP.mjs +808 -0
  117. package/dist/features-BJ8kNaE8.js +1 -0
  118. package/dist/features-CJ34oImB.mjs +6 -0
  119. package/dist/index-4lfXeo30.js +132 -0
  120. package/dist/index-B6Mg114Z.mjs +69182 -0
  121. package/dist/index-BX7gAgT3.mjs +35 -0
  122. package/dist/index-BYQqNbCe.js +1 -0
  123. package/dist/index-BmdHwtJo.js +1 -0
  124. package/dist/index-BvUx3ULC.js +78 -0
  125. package/dist/index-CD-QGO70.mjs +196 -0
  126. package/dist/index-CJtXfdoM.mjs +29621 -0
  127. package/dist/index-CMzdgE-y.mjs +215 -0
  128. package/dist/index-CjZQCcwG.js +7203 -0
  129. package/dist/index-D7VuOaCI.js +19 -0
  130. package/dist/index-DV7SQwgn.mjs +2688 -0
  131. package/dist/index-DVf4BnNh.mjs +352 -0
  132. package/dist/index-DhN9vL4k.js +138 -0
  133. package/dist/index-DvllakY0.mjs +274 -0
  134. package/dist/index-Ho06VKh2.mjs +151 -0
  135. package/dist/index-a8mS2Eh1.js +1062 -0
  136. package/dist/index-aamBi9Tu.js +1 -0
  137. package/dist/index.cjs.js +1 -0
  138. package/dist/index.es.js +14 -0
  139. package/dist/onramp-DLlhSPQg.js +422 -0
  140. package/dist/onramp-k-EAEepC.mjs +842 -0
  141. package/dist/parseSignature-D1tZHglo.js +16 -0
  142. package/dist/parseSignature-DM0lwcDr.mjs +8883 -0
  143. package/dist/pay-with-exchange---G2M1Ag.js +280 -0
  144. package/dist/pay-with-exchange-CFIcUXUe.mjs +512 -0
  145. package/dist/property-Bd8U3_QP.mjs +618 -0
  146. package/dist/property-DissjCbZ.js +27 -0
  147. package/dist/receive-B9LCljO6.mjs +228 -0
  148. package/dist/receive-E8H6GDOX.js +131 -0
  149. package/dist/send-B-AooLph.js +554 -0
  150. package/dist/send-DZd_xhsd.mjs +1155 -0
  151. package/dist/socials-ChWFLEFe.mjs +611 -0
  152. package/dist/socials-YSUYSh8o.js +250 -0
  153. package/dist/swaps-DpR9W9Ld.js +1050 -0
  154. package/dist/swaps-Du7-Ui_V.mjs +1752 -0
  155. package/dist/transactions-DhsK5-QJ.mjs +35 -0
  156. package/dist/transactions-VPsz2OLe.js +16 -0
  157. package/dist/w3m-modal-DhomfjKU.js +891 -0
  158. package/dist/w3m-modal-KuYD-zqQ.mjs +1759 -0
  159. package/package.json +51 -0
  160. package/readme.md +1 -0
@@ -0,0 +1,2688 @@
1
+ import { bR as U, bS as Ie, bT as ve, bU as x, bV as _, bW as C, cu as f, bX as l, c6 as I, cV as Se, c5 as v, cW as ke, cX as y, cc as O, cY as _e, cZ as N, cy as ce, c1 as A, c_ as me, ca as m, cs as T, c7 as M, c4 as R, cf as Ce, cz as G, cj as $e, ck as Re, cl as Oe, ci as P, c3 as z, cv as h, bZ as Ue, b$ as Le, c$ as Ne, c0 as qe, cP as ge } from "./index-B6Mg114Z.mjs";
2
+ const De = U`
3
+ :host {
4
+ position: relative;
5
+ }
6
+
7
+ button {
8
+ display: flex;
9
+ justify-content: center;
10
+ align-items: center;
11
+ background-color: transparent;
12
+ padding: ${({ spacing: t }) => t[1]};
13
+ }
14
+
15
+ /* -- Colors --------------------------------------------------- */
16
+ button[data-type='accent'] wui-icon {
17
+ color: ${({ tokens: t }) => t.core.iconAccentPrimary};
18
+ }
19
+
20
+ button[data-type='neutral'][data-variant='primary'] wui-icon {
21
+ color: ${({ tokens: t }) => t.theme.iconInverse};
22
+ }
23
+
24
+ button[data-type='neutral'][data-variant='secondary'] wui-icon {
25
+ color: ${({ tokens: t }) => t.theme.iconDefault};
26
+ }
27
+
28
+ button[data-type='success'] wui-icon {
29
+ color: ${({ tokens: t }) => t.core.iconSuccess};
30
+ }
31
+
32
+ button[data-type='error'] wui-icon {
33
+ color: ${({ tokens: t }) => t.core.iconError};
34
+ }
35
+
36
+ /* -- Sizes --------------------------------------------------- */
37
+ button[data-size='xs'] {
38
+ width: 16px;
39
+ height: 16px;
40
+
41
+ border-radius: ${({ borderRadius: t }) => t[1]};
42
+ }
43
+
44
+ button[data-size='sm'] {
45
+ width: 20px;
46
+ height: 20px;
47
+ border-radius: ${({ borderRadius: t }) => t[1]};
48
+ }
49
+
50
+ button[data-size='md'] {
51
+ width: 24px;
52
+ height: 24px;
53
+ border-radius: ${({ borderRadius: t }) => t[2]};
54
+ }
55
+
56
+ button[data-size='lg'] {
57
+ width: 28px;
58
+ height: 28px;
59
+ border-radius: ${({ borderRadius: t }) => t[2]};
60
+ }
61
+
62
+ button[data-size='xs'] wui-icon {
63
+ width: 8px;
64
+ height: 8px;
65
+ }
66
+
67
+ button[data-size='sm'] wui-icon {
68
+ width: 12px;
69
+ height: 12px;
70
+ }
71
+
72
+ button[data-size='md'] wui-icon {
73
+ width: 16px;
74
+ height: 16px;
75
+ }
76
+
77
+ button[data-size='lg'] wui-icon {
78
+ width: 20px;
79
+ height: 20px;
80
+ }
81
+
82
+ /* -- Hover --------------------------------------------------- */
83
+ @media (hover: hover) {
84
+ button[data-type='accent']:hover:enabled {
85
+ background-color: ${({ tokens: t }) => t.core.foregroundAccent010};
86
+ }
87
+
88
+ button[data-variant='primary'][data-type='neutral']:hover:enabled {
89
+ background-color: ${({ tokens: t }) => t.theme.foregroundSecondary};
90
+ }
91
+
92
+ button[data-variant='secondary'][data-type='neutral']:hover:enabled {
93
+ background-color: ${({ tokens: t }) => t.theme.foregroundSecondary};
94
+ }
95
+
96
+ button[data-type='success']:hover:enabled {
97
+ background-color: ${({ tokens: t }) => t.core.backgroundSuccess};
98
+ }
99
+
100
+ button[data-type='error']:hover:enabled {
101
+ background-color: ${({ tokens: t }) => t.core.backgroundError};
102
+ }
103
+ }
104
+
105
+ /* -- Focus --------------------------------------------------- */
106
+ button:focus-visible {
107
+ box-shadow: 0 0 0 4px ${({ tokens: t }) => t.core.foregroundAccent020};
108
+ }
109
+
110
+ /* -- Properties --------------------------------------------------- */
111
+ button[data-full-width='true'] {
112
+ width: 100%;
113
+ }
114
+
115
+ :host([fullWidth]) {
116
+ width: 100%;
117
+ }
118
+
119
+ button[disabled] {
120
+ opacity: 0.5;
121
+ cursor: not-allowed;
122
+ }
123
+ `;
124
+ var F = function(t, e, n, s) {
125
+ var i = arguments.length, a = i < 3 ? e : s === null ? s = Object.getOwnPropertyDescriptor(e, n) : s, o;
126
+ if (typeof Reflect == "object" && typeof Reflect.decorate == "function") a = Reflect.decorate(t, e, n, s);
127
+ else for (var c = t.length - 1; c >= 0; c--) (o = t[c]) && (a = (i < 3 ? o(a) : i > 3 ? o(e, n, a) : o(e, n)) || a);
128
+ return i > 3 && a && Object.defineProperty(e, n, a), a;
129
+ };
130
+ let S = class extends C {
131
+ constructor() {
132
+ super(...arguments), this.icon = "card", this.variant = "primary", this.type = "accent", this.size = "md", this.iconSize = void 0, this.fullWidth = !1, this.disabled = !1;
133
+ }
134
+ render() {
135
+ return l`<button
136
+ data-variant=${this.variant}
137
+ data-type=${this.type}
138
+ data-size=${this.size}
139
+ data-full-width=${this.fullWidth}
140
+ ?disabled=${this.disabled}
141
+ >
142
+ <wui-icon color="inherit" name=${this.icon} size=${f(this.iconSize)}></wui-icon>
143
+ </button>`;
144
+ }
145
+ };
146
+ S.styles = [Ie, ve, De];
147
+ F([
148
+ x()
149
+ ], S.prototype, "icon", void 0);
150
+ F([
151
+ x()
152
+ ], S.prototype, "variant", void 0);
153
+ F([
154
+ x()
155
+ ], S.prototype, "type", void 0);
156
+ F([
157
+ x()
158
+ ], S.prototype, "size", void 0);
159
+ F([
160
+ x()
161
+ ], S.prototype, "iconSize", void 0);
162
+ F([
163
+ x({ type: Boolean })
164
+ ], S.prototype, "fullWidth", void 0);
165
+ F([
166
+ x({ type: Boolean })
167
+ ], S.prototype, "disabled", void 0);
168
+ S = F([
169
+ _("wui-icon-button")
170
+ ], S);
171
+ const d = {
172
+ INVALID_PAYMENT_CONFIG: "INVALID_PAYMENT_CONFIG",
173
+ INVALID_RECIPIENT: "INVALID_RECIPIENT",
174
+ INVALID_ASSET: "INVALID_ASSET",
175
+ INVALID_AMOUNT: "INVALID_AMOUNT",
176
+ UNKNOWN_ERROR: "UNKNOWN_ERROR",
177
+ UNABLE_TO_INITIATE_PAYMENT: "UNABLE_TO_INITIATE_PAYMENT",
178
+ INVALID_CHAIN_NAMESPACE: "INVALID_CHAIN_NAMESPACE",
179
+ GENERIC_PAYMENT_ERROR: "GENERIC_PAYMENT_ERROR",
180
+ UNABLE_TO_GET_EXCHANGES: "UNABLE_TO_GET_EXCHANGES",
181
+ ASSET_NOT_SUPPORTED: "ASSET_NOT_SUPPORTED",
182
+ UNABLE_TO_GET_PAY_URL: "UNABLE_TO_GET_PAY_URL",
183
+ UNABLE_TO_GET_BUY_STATUS: "UNABLE_TO_GET_BUY_STATUS",
184
+ UNABLE_TO_GET_TOKEN_BALANCES: "UNABLE_TO_GET_TOKEN_BALANCES",
185
+ UNABLE_TO_GET_QUOTE: "UNABLE_TO_GET_QUOTE",
186
+ UNABLE_TO_GET_QUOTE_STATUS: "UNABLE_TO_GET_QUOTE_STATUS",
187
+ INVALID_RECIPIENT_ADDRESS_FOR_ASSET: "INVALID_RECIPIENT_ADDRESS_FOR_ASSET"
188
+ }, q = {
189
+ [d.INVALID_PAYMENT_CONFIG]: "Invalid payment configuration",
190
+ [d.INVALID_RECIPIENT]: "Invalid recipient address",
191
+ [d.INVALID_ASSET]: "Invalid asset specified",
192
+ [d.INVALID_AMOUNT]: "Invalid payment amount",
193
+ [d.INVALID_RECIPIENT_ADDRESS_FOR_ASSET]: "Invalid recipient address for the asset selected",
194
+ [d.UNKNOWN_ERROR]: "Unknown payment error occurred",
195
+ [d.UNABLE_TO_INITIATE_PAYMENT]: "Unable to initiate payment",
196
+ [d.INVALID_CHAIN_NAMESPACE]: "Invalid chain namespace",
197
+ [d.GENERIC_PAYMENT_ERROR]: "Unable to process payment",
198
+ [d.UNABLE_TO_GET_EXCHANGES]: "Unable to get exchanges",
199
+ [d.ASSET_NOT_SUPPORTED]: "Asset not supported by the selected exchange",
200
+ [d.UNABLE_TO_GET_PAY_URL]: "Unable to get payment URL",
201
+ [d.UNABLE_TO_GET_BUY_STATUS]: "Unable to get buy status",
202
+ [d.UNABLE_TO_GET_TOKEN_BALANCES]: "Unable to get token balances",
203
+ [d.UNABLE_TO_GET_QUOTE]: "Unable to get quote. Please choose a different token",
204
+ [d.UNABLE_TO_GET_QUOTE_STATUS]: "Unable to get quote status"
205
+ };
206
+ class p extends Error {
207
+ get message() {
208
+ return q[this.code];
209
+ }
210
+ constructor(e, n) {
211
+ super(q[e]), this.name = "AppKitPayError", this.code = e, this.details = n, Error.captureStackTrace && Error.captureStackTrace(this, p);
212
+ }
213
+ }
214
+ const Fe = "https://rpc.walletconnect.org/v1/json-rpc", fe = "reown_test";
215
+ function Be() {
216
+ const { chainNamespace: t } = y.parseCaipNetworkId(u.state.paymentAsset.network);
217
+ if (!O.isAddress(u.state.recipient, t))
218
+ throw new p(d.INVALID_RECIPIENT_ADDRESS_FOR_ASSET, `Provide valid recipient address for namespace "${t}"`);
219
+ }
220
+ async function We(t, e, n) {
221
+ var c;
222
+ if (e !== I.CHAIN.EVM)
223
+ throw new p(d.INVALID_CHAIN_NAMESPACE);
224
+ if (!n.fromAddress)
225
+ throw new p(d.INVALID_PAYMENT_CONFIG, "fromAddress is required for native EVM payments.");
226
+ const s = typeof n.amount == "string" ? parseFloat(n.amount) : n.amount;
227
+ if (isNaN(s))
228
+ throw new p(d.INVALID_PAYMENT_CONFIG);
229
+ const i = ((c = t.metadata) == null ? void 0 : c.decimals) ?? 18, a = v.parseUnits(s.toString(), i);
230
+ if (typeof a != "bigint")
231
+ throw new p(d.GENERIC_PAYMENT_ERROR);
232
+ return await v.sendTransaction({
233
+ chainNamespace: e,
234
+ to: n.recipient,
235
+ address: n.fromAddress,
236
+ value: a,
237
+ data: "0x"
238
+ }) ?? void 0;
239
+ }
240
+ async function je(t, e) {
241
+ if (!e.fromAddress)
242
+ throw new p(d.INVALID_PAYMENT_CONFIG, "fromAddress is required for ERC20 EVM payments.");
243
+ const n = t.asset, s = e.recipient, i = Number(t.metadata.decimals), a = v.parseUnits(e.amount.toString(), i);
244
+ if (a === void 0)
245
+ throw new p(d.GENERIC_PAYMENT_ERROR);
246
+ return await v.writeContract({
247
+ fromAddress: e.fromAddress,
248
+ tokenAddress: n,
249
+ args: [s, a],
250
+ method: "transfer",
251
+ abi: ke.getERC20Abi(n),
252
+ chainNamespace: I.CHAIN.EVM
253
+ }) ?? void 0;
254
+ }
255
+ async function Me(t, e) {
256
+ if (t !== I.CHAIN.SOLANA)
257
+ throw new p(d.INVALID_CHAIN_NAMESPACE);
258
+ if (!e.fromAddress)
259
+ throw new p(d.INVALID_PAYMENT_CONFIG, "fromAddress is required for Solana payments.");
260
+ const n = typeof e.amount == "string" ? parseFloat(e.amount) : e.amount;
261
+ if (isNaN(n) || n <= 0)
262
+ throw new p(d.INVALID_PAYMENT_CONFIG, "Invalid payment amount.");
263
+ try {
264
+ if (!Se.getProvider(t))
265
+ throw new p(d.GENERIC_PAYMENT_ERROR, "No Solana provider available.");
266
+ const i = await v.sendTransaction({
267
+ chainNamespace: I.CHAIN.SOLANA,
268
+ to: e.recipient,
269
+ value: n,
270
+ tokenMint: e.tokenMint
271
+ });
272
+ if (!i)
273
+ throw new p(d.GENERIC_PAYMENT_ERROR, "Transaction failed.");
274
+ return i;
275
+ } catch (s) {
276
+ throw s instanceof p ? s : new p(d.GENERIC_PAYMENT_ERROR, `Solana payment failed: ${s}`);
277
+ }
278
+ }
279
+ async function ze({ sourceToken: t, toToken: e, amount: n, recipient: s }) {
280
+ const i = v.parseUnits(n, t.metadata.decimals), a = v.parseUnits(n, e.metadata.decimals);
281
+ return Promise.resolve({
282
+ type: ae,
283
+ origin: {
284
+ amount: (i == null ? void 0 : i.toString()) ?? "0",
285
+ currency: t
286
+ },
287
+ destination: {
288
+ amount: (a == null ? void 0 : a.toString()) ?? "0",
289
+ currency: e
290
+ },
291
+ fees: [
292
+ {
293
+ id: "service",
294
+ label: "Service Fee",
295
+ amount: "0",
296
+ currency: e
297
+ }
298
+ ],
299
+ steps: [
300
+ {
301
+ requestId: ae,
302
+ type: "deposit",
303
+ deposit: {
304
+ amount: (i == null ? void 0 : i.toString()) ?? "0",
305
+ currency: t.asset,
306
+ receiver: s
307
+ }
308
+ }
309
+ ],
310
+ timeInSeconds: 6
311
+ });
312
+ }
313
+ function ie(t) {
314
+ if (!t)
315
+ return null;
316
+ const e = t.steps[0];
317
+ return !e || e.type !== it ? null : e;
318
+ }
319
+ function te(t, e = 0) {
320
+ if (!t)
321
+ return [];
322
+ const n = t.steps.filter((i) => i.type === at), s = n.filter((i, a) => a + 1 > e);
323
+ return n.length > 0 && n.length < 3 ? s : [];
324
+ }
325
+ const ue = new _e({ baseUrl: O.getApiUrl(), clientId: null });
326
+ class Ge extends Error {
327
+ }
328
+ function Qe() {
329
+ const t = ce.getSnapshot().projectId;
330
+ return `${Fe}?projectId=${t}`;
331
+ }
332
+ function le() {
333
+ const { projectId: t, sdkType: e, sdkVersion: n } = ce.state;
334
+ return {
335
+ projectId: t,
336
+ st: e || "appkit",
337
+ sv: n || "html-wagmi-4.2.2"
338
+ };
339
+ }
340
+ async function de(t, e) {
341
+ const n = Qe(), { sdkType: s, sdkVersion: i, projectId: a } = ce.getSnapshot(), o = {
342
+ jsonrpc: "2.0",
343
+ id: 1,
344
+ method: t,
345
+ params: {
346
+ ...e || {},
347
+ st: s,
348
+ sv: i,
349
+ projectId: a
350
+ }
351
+ }, g = await (await fetch(n, {
352
+ method: "POST",
353
+ body: JSON.stringify(o),
354
+ headers: { "Content-Type": "application/json" }
355
+ })).json();
356
+ if (g.error)
357
+ throw new Ge(g.error.message);
358
+ return g;
359
+ }
360
+ async function we(t) {
361
+ return (await de("reown_getExchanges", t)).result;
362
+ }
363
+ async function ye(t) {
364
+ return (await de("reown_getExchangePayUrl", t)).result;
365
+ }
366
+ async function Ve(t) {
367
+ return (await de("reown_getExchangeBuyStatus", t)).result;
368
+ }
369
+ async function Ye(t) {
370
+ const e = A.bigNumber(t.amount).times(10 ** t.toToken.metadata.decimals).toString(), { chainId: n, chainNamespace: s } = y.parseCaipNetworkId(t.sourceToken.network), { chainId: i, chainNamespace: a } = y.parseCaipNetworkId(t.toToken.network), o = t.sourceToken.asset === "native" ? me(s) : t.sourceToken.asset, c = t.toToken.asset === "native" ? me(a) : t.toToken.asset;
371
+ return await ue.post({
372
+ path: "/appkit/v1/transfers/quote",
373
+ body: {
374
+ user: t.address,
375
+ originChainId: n.toString(),
376
+ originCurrency: o,
377
+ destinationChainId: i.toString(),
378
+ destinationCurrency: c,
379
+ recipient: t.recipient,
380
+ amount: e
381
+ },
382
+ params: le()
383
+ });
384
+ }
385
+ async function He(t) {
386
+ const e = N.isLowerCaseMatch(t.sourceToken.network, t.toToken.network), n = N.isLowerCaseMatch(t.sourceToken.asset, t.toToken.asset);
387
+ return e && n ? ze(t) : Ye(t);
388
+ }
389
+ async function Ke(t) {
390
+ return await ue.get({
391
+ path: "/appkit/v1/transfers/status",
392
+ params: {
393
+ requestId: t.requestId,
394
+ ...le()
395
+ }
396
+ });
397
+ }
398
+ async function Xe(t) {
399
+ return await ue.get({
400
+ path: `/appkit/v1/transfers/assets/exchanges/${t}`,
401
+ params: le()
402
+ });
403
+ }
404
+ const Ze = ["eip155", "solana"], Je = {
405
+ eip155: {
406
+ native: { assetNamespace: "slip44", assetReference: "60" },
407
+ defaultTokenNamespace: "erc20"
408
+ },
409
+ solana: {
410
+ native: { assetNamespace: "slip44", assetReference: "501" },
411
+ defaultTokenNamespace: "token"
412
+ }
413
+ }, be = {
414
+ 56: "714",
415
+ 204: "714"
416
+ };
417
+ function ne(t, e) {
418
+ const { chainNamespace: n, chainId: s } = y.parseCaipNetworkId(t), i = Je[n];
419
+ if (!i)
420
+ throw new Error(`Unsupported chain namespace for CAIP-19 formatting: ${n}`);
421
+ let a = i.native.assetNamespace, o = i.native.assetReference;
422
+ return e !== "native" ? (a = i.defaultTokenNamespace, o = e) : n === "eip155" && be[s] && (o = be[s]), `${`${n}:${s}`}/${a}:${o}`;
423
+ }
424
+ function et(t) {
425
+ const { chainNamespace: e } = y.parseCaipNetworkId(t);
426
+ return Ze.includes(e);
427
+ }
428
+ function tt(t) {
429
+ const n = m.getAllRequestedCaipNetworks().find((i) => i.caipNetworkId === t.chainId);
430
+ let s = t.address;
431
+ if (!n)
432
+ throw new Error(`Target network not found for balance chainId "${t.chainId}"`);
433
+ if (N.isLowerCaseMatch(t.symbol, n.nativeCurrency.symbol))
434
+ s = "native";
435
+ else if (O.isCaipAddress(s)) {
436
+ const { address: i } = y.parseCaipAddress(s);
437
+ s = i;
438
+ } else if (!s)
439
+ throw new Error(`Balance address not found for balance symbol "${t.symbol}"`);
440
+ return {
441
+ network: n.caipNetworkId,
442
+ asset: s,
443
+ metadata: {
444
+ name: t.name,
445
+ symbol: t.symbol,
446
+ decimals: Number(t.quantity.decimals),
447
+ logoURI: t.iconUrl
448
+ },
449
+ amount: t.quantity.numeric
450
+ };
451
+ }
452
+ function nt(t) {
453
+ return {
454
+ chainId: t.network,
455
+ address: `${t.network}:${t.asset}`,
456
+ symbol: t.metadata.symbol,
457
+ name: t.metadata.name,
458
+ iconUrl: t.metadata.logoURI || "",
459
+ price: 0,
460
+ quantity: {
461
+ numeric: "0",
462
+ decimals: t.metadata.decimals.toString()
463
+ }
464
+ };
465
+ }
466
+ function X(t) {
467
+ const e = A.bigNumber(t, { safe: !0 });
468
+ return e.lt(1e-3) ? "<0.001" : e.round(4).toString();
469
+ }
470
+ function st(t) {
471
+ const n = m.getAllRequestedCaipNetworks().find((s) => s.caipNetworkId === t.network);
472
+ return n ? !!n.testnet : !1;
473
+ }
474
+ const xe = 0, se = "unknown", ae = "direct-transfer", it = "deposit", at = "transaction", r = Oe({
475
+ paymentAsset: {
476
+ network: "eip155:1",
477
+ asset: "0x0",
478
+ metadata: {
479
+ name: "0x0",
480
+ symbol: "0x0",
481
+ decimals: 0
482
+ }
483
+ },
484
+ recipient: "0x0",
485
+ amount: 0,
486
+ isConfigured: !1,
487
+ error: null,
488
+ isPaymentInProgress: !1,
489
+ exchanges: [],
490
+ isLoading: !1,
491
+ openInNewTab: !0,
492
+ redirectUrl: void 0,
493
+ payWithExchange: void 0,
494
+ currentPayment: void 0,
495
+ analyticsSet: !1,
496
+ paymentId: void 0,
497
+ choice: "pay",
498
+ tokenBalances: {
499
+ [I.CHAIN.EVM]: [],
500
+ [I.CHAIN.SOLANA]: []
501
+ },
502
+ isFetchingTokenBalances: !1,
503
+ selectedPaymentAsset: null,
504
+ quote: void 0,
505
+ quoteStatus: "waiting",
506
+ quoteError: null,
507
+ isFetchingQuote: !1,
508
+ selectedExchange: void 0,
509
+ exchangeUrlForQuote: void 0,
510
+ requestId: void 0
511
+ }), u = {
512
+ state: r,
513
+ subscribe(t) {
514
+ return Re(r, () => t(r));
515
+ },
516
+ subscribeKey(t, e) {
517
+ return $e(r, t, e);
518
+ },
519
+ async handleOpenPay(t) {
520
+ this.resetState(), this.setPaymentConfig(t), this.initializeAnalytics(), Be(), await this.prepareTokenLogo(), r.isConfigured = !0, M.sendEvent({
521
+ type: "track",
522
+ event: "PAY_MODAL_OPEN",
523
+ properties: {
524
+ exchanges: r.exchanges,
525
+ configuration: {
526
+ network: r.paymentAsset.network,
527
+ asset: r.paymentAsset.asset,
528
+ recipient: r.recipient,
529
+ amount: r.amount
530
+ }
531
+ }
532
+ }), await G.open({
533
+ view: "Pay"
534
+ });
535
+ },
536
+ resetState() {
537
+ r.paymentAsset = {
538
+ network: "eip155:1",
539
+ asset: "0x0",
540
+ metadata: { name: "0x0", symbol: "0x0", decimals: 0 }
541
+ }, r.recipient = "0x0", r.amount = 0, r.isConfigured = !1, r.error = null, r.isPaymentInProgress = !1, r.isLoading = !1, r.currentPayment = void 0, r.selectedExchange = void 0, r.exchangeUrlForQuote = void 0, r.requestId = void 0;
542
+ },
543
+ resetQuoteState() {
544
+ r.quote = void 0, r.quoteStatus = "waiting", r.quoteError = null, r.isFetchingQuote = !1, r.requestId = void 0;
545
+ },
546
+ setPaymentConfig(t) {
547
+ if (!t.paymentAsset)
548
+ throw new p(d.INVALID_PAYMENT_CONFIG);
549
+ try {
550
+ r.choice = t.choice ?? "pay", r.paymentAsset = t.paymentAsset, r.recipient = t.recipient, r.amount = t.amount, r.openInNewTab = t.openInNewTab ?? !0, r.redirectUrl = t.redirectUrl, r.payWithExchange = t.payWithExchange, r.error = null;
551
+ } catch (e) {
552
+ throw new p(d.INVALID_PAYMENT_CONFIG, e.message);
553
+ }
554
+ },
555
+ setSelectedPaymentAsset(t) {
556
+ r.selectedPaymentAsset = t;
557
+ },
558
+ setSelectedExchange(t) {
559
+ r.selectedExchange = t;
560
+ },
561
+ setRequestId(t) {
562
+ r.requestId = t;
563
+ },
564
+ setPaymentInProgress(t) {
565
+ r.isPaymentInProgress = t;
566
+ },
567
+ getPaymentAsset() {
568
+ return r.paymentAsset;
569
+ },
570
+ getExchanges() {
571
+ return r.exchanges;
572
+ },
573
+ async fetchExchanges() {
574
+ try {
575
+ r.isLoading = !0;
576
+ const t = await we({
577
+ page: xe
578
+ });
579
+ r.exchanges = t.exchanges.slice(0, 2);
580
+ } catch {
581
+ throw R.showError(q.UNABLE_TO_GET_EXCHANGES), new p(d.UNABLE_TO_GET_EXCHANGES);
582
+ } finally {
583
+ r.isLoading = !1;
584
+ }
585
+ },
586
+ async getAvailableExchanges(t) {
587
+ var e;
588
+ try {
589
+ const n = t != null && t.asset && (t != null && t.network) ? ne(t.network, t.asset) : void 0;
590
+ return await we({
591
+ page: (t == null ? void 0 : t.page) ?? xe,
592
+ asset: n,
593
+ amount: (e = t == null ? void 0 : t.amount) == null ? void 0 : e.toString()
594
+ });
595
+ } catch {
596
+ throw new p(d.UNABLE_TO_GET_EXCHANGES);
597
+ }
598
+ },
599
+ async getPayUrl(t, e, n = !1) {
600
+ try {
601
+ const s = Number(e.amount), i = await ye({
602
+ exchangeId: t,
603
+ asset: ne(e.network, e.asset),
604
+ amount: s.toString(),
605
+ recipient: `${e.network}:${e.recipient}`
606
+ });
607
+ return M.sendEvent({
608
+ type: "track",
609
+ event: "PAY_EXCHANGE_SELECTED",
610
+ properties: {
611
+ source: "pay",
612
+ exchange: {
613
+ id: t
614
+ },
615
+ configuration: {
616
+ network: e.network,
617
+ asset: e.asset,
618
+ recipient: e.recipient,
619
+ amount: s
620
+ },
621
+ currentPayment: {
622
+ type: "exchange",
623
+ exchangeId: t
624
+ },
625
+ headless: n
626
+ }
627
+ }), n && (this.initiatePayment(), M.sendEvent({
628
+ type: "track",
629
+ event: "PAY_INITIATED",
630
+ properties: {
631
+ source: "pay",
632
+ paymentId: r.paymentId || se,
633
+ configuration: {
634
+ network: e.network,
635
+ asset: e.asset,
636
+ recipient: e.recipient,
637
+ amount: s
638
+ },
639
+ currentPayment: {
640
+ type: "exchange",
641
+ exchangeId: t
642
+ }
643
+ }
644
+ })), i;
645
+ } catch (s) {
646
+ throw s instanceof Error && s.message.includes("is not supported") ? new p(d.ASSET_NOT_SUPPORTED) : new Error(s.message);
647
+ }
648
+ },
649
+ async generateExchangeUrlForQuote({ exchangeId: t, paymentAsset: e, amount: n, recipient: s }) {
650
+ const i = await ye({
651
+ exchangeId: t,
652
+ asset: ne(e.network, e.asset),
653
+ amount: n.toString(),
654
+ recipient: s
655
+ });
656
+ r.exchangeSessionId = i.sessionId, r.exchangeUrlForQuote = i.url;
657
+ },
658
+ async openPayUrl(t, e, n = !1) {
659
+ try {
660
+ const s = await this.getPayUrl(t.exchangeId, e, n);
661
+ if (!s)
662
+ throw new p(d.UNABLE_TO_GET_PAY_URL);
663
+ const a = t.openInNewTab ?? !0 ? "_blank" : "_self";
664
+ return O.openHref(s.url, a), s;
665
+ } catch (s) {
666
+ throw s instanceof p ? r.error = s.message : r.error = q.GENERIC_PAYMENT_ERROR, new p(d.UNABLE_TO_GET_PAY_URL);
667
+ }
668
+ },
669
+ async onTransfer({ chainNamespace: t, fromAddress: e, toAddress: n, amount: s, paymentAsset: i }) {
670
+ if (r.currentPayment = {
671
+ type: "wallet",
672
+ status: "IN_PROGRESS"
673
+ }, !r.isPaymentInProgress)
674
+ try {
675
+ this.initiatePayment();
676
+ const o = m.getAllRequestedCaipNetworks().find((g) => g.caipNetworkId === i.network);
677
+ if (!o)
678
+ throw new Error("Target network not found");
679
+ const c = m.state.activeCaipNetwork;
680
+ switch (N.isLowerCaseMatch(c == null ? void 0 : c.caipNetworkId, o.caipNetworkId) || await m.switchActiveNetwork(o), t) {
681
+ case I.CHAIN.EVM:
682
+ i.asset === "native" && (r.currentPayment.result = await We(i, t, {
683
+ recipient: n,
684
+ amount: s,
685
+ fromAddress: e
686
+ })), i.asset.startsWith("0x") && (r.currentPayment.result = await je(i, {
687
+ recipient: n,
688
+ amount: s,
689
+ fromAddress: e
690
+ })), r.currentPayment.status = "SUCCESS";
691
+ break;
692
+ case I.CHAIN.SOLANA:
693
+ r.currentPayment.result = await Me(t, {
694
+ recipient: n,
695
+ amount: s,
696
+ fromAddress: e,
697
+ tokenMint: i.asset === "native" ? void 0 : i.asset
698
+ }), r.currentPayment.status = "SUCCESS";
699
+ break;
700
+ default:
701
+ throw new p(d.INVALID_CHAIN_NAMESPACE);
702
+ }
703
+ } catch (a) {
704
+ throw a instanceof p ? r.error = a.message : r.error = q.GENERIC_PAYMENT_ERROR, r.currentPayment.status = "FAILED", R.showError(r.error), a;
705
+ } finally {
706
+ r.isPaymentInProgress = !1;
707
+ }
708
+ },
709
+ async onSendTransaction(t) {
710
+ try {
711
+ const { namespace: e, transactionStep: n } = t;
712
+ u.initiatePayment();
713
+ const i = m.getAllRequestedCaipNetworks().find((o) => {
714
+ var c;
715
+ return o.caipNetworkId === ((c = r.paymentAsset) == null ? void 0 : c.network);
716
+ });
717
+ if (!i)
718
+ throw new Error("Target network not found");
719
+ const a = m.state.activeCaipNetwork;
720
+ if (N.isLowerCaseMatch(a == null ? void 0 : a.caipNetworkId, i.caipNetworkId) || await m.switchActiveNetwork(i), e === I.CHAIN.EVM) {
721
+ const { from: o, to: c, data: g, value: L } = n.transaction;
722
+ await v.sendTransaction({
723
+ address: o,
724
+ to: c,
725
+ data: g,
726
+ value: BigInt(L),
727
+ chainNamespace: e
728
+ });
729
+ } else if (e === I.CHAIN.SOLANA) {
730
+ const { instructions: o } = n.transaction;
731
+ await v.writeSolanaTransaction({
732
+ instructions: o
733
+ });
734
+ }
735
+ } catch (e) {
736
+ throw e instanceof p ? r.error = e.message : r.error = q.GENERIC_PAYMENT_ERROR, R.showError(r.error), e;
737
+ } finally {
738
+ r.isPaymentInProgress = !1;
739
+ }
740
+ },
741
+ getExchangeById(t) {
742
+ return r.exchanges.find((e) => e.id === t);
743
+ },
744
+ validatePayConfig(t) {
745
+ const { paymentAsset: e, recipient: n, amount: s } = t;
746
+ if (!e)
747
+ throw new p(d.INVALID_PAYMENT_CONFIG);
748
+ if (!n)
749
+ throw new p(d.INVALID_RECIPIENT);
750
+ if (!e.asset)
751
+ throw new p(d.INVALID_ASSET);
752
+ if (s == null || s <= 0)
753
+ throw new p(d.INVALID_AMOUNT);
754
+ },
755
+ async handlePayWithExchange(t) {
756
+ try {
757
+ r.currentPayment = {
758
+ type: "exchange",
759
+ exchangeId: t
760
+ };
761
+ const { network: e, asset: n } = r.paymentAsset, s = {
762
+ network: e,
763
+ asset: n,
764
+ amount: r.amount,
765
+ recipient: r.recipient
766
+ }, i = await this.getPayUrl(t, s);
767
+ if (!i)
768
+ throw new p(d.UNABLE_TO_INITIATE_PAYMENT);
769
+ return r.currentPayment.sessionId = i.sessionId, r.currentPayment.status = "IN_PROGRESS", r.currentPayment.exchangeId = t, this.initiatePayment(), {
770
+ url: i.url,
771
+ openInNewTab: r.openInNewTab
772
+ };
773
+ } catch (e) {
774
+ return e instanceof p ? r.error = e.message : r.error = q.GENERIC_PAYMENT_ERROR, r.isPaymentInProgress = !1, R.showError(r.error), null;
775
+ }
776
+ },
777
+ async getBuyStatus(t, e) {
778
+ var n, s;
779
+ try {
780
+ const i = await Ve({ sessionId: e, exchangeId: t });
781
+ return (i.status === "SUCCESS" || i.status === "FAILED") && M.sendEvent({
782
+ type: "track",
783
+ event: i.status === "SUCCESS" ? "PAY_SUCCESS" : "PAY_ERROR",
784
+ properties: {
785
+ message: i.status === "FAILED" ? O.parseError(r.error) : void 0,
786
+ source: "pay",
787
+ paymentId: r.paymentId || se,
788
+ configuration: {
789
+ network: r.paymentAsset.network,
790
+ asset: r.paymentAsset.asset,
791
+ recipient: r.recipient,
792
+ amount: r.amount
793
+ },
794
+ currentPayment: {
795
+ type: "exchange",
796
+ exchangeId: (n = r.currentPayment) == null ? void 0 : n.exchangeId,
797
+ sessionId: (s = r.currentPayment) == null ? void 0 : s.sessionId,
798
+ result: i.txHash
799
+ }
800
+ }
801
+ }), i;
802
+ } catch {
803
+ throw new p(d.UNABLE_TO_GET_BUY_STATUS);
804
+ }
805
+ },
806
+ async fetchTokensFromEOA({ caipAddress: t, caipNetwork: e, namespace: n }) {
807
+ if (!t)
808
+ return [];
809
+ const { address: s } = y.parseCaipAddress(t);
810
+ let i = e;
811
+ return n === I.CHAIN.EVM && (i = void 0), await Ce.getMyTokensWithBalance({
812
+ address: s,
813
+ caipNetwork: i
814
+ });
815
+ },
816
+ async fetchTokensFromExchange() {
817
+ if (!r.selectedExchange)
818
+ return [];
819
+ const t = await Xe(r.selectedExchange.id), e = Object.values(t.assets).flat();
820
+ return await Promise.all(e.map(async (s) => {
821
+ const i = nt(s), { chainNamespace: a } = y.parseCaipNetworkId(i.chainId);
822
+ let o = i.address;
823
+ if (O.isCaipAddress(o)) {
824
+ const { address: g } = y.parseCaipAddress(o);
825
+ o = g;
826
+ }
827
+ const c = await T.getImageByToken(o ?? "", a).catch(() => {
828
+ });
829
+ return i.iconUrl = c ?? "", i;
830
+ }));
831
+ },
832
+ async fetchTokens({ caipAddress: t, caipNetwork: e, namespace: n }) {
833
+ try {
834
+ r.isFetchingTokenBalances = !0;
835
+ const a = await (!!r.selectedExchange ? this.fetchTokensFromExchange() : this.fetchTokensFromEOA({ caipAddress: t, caipNetwork: e, namespace: n }));
836
+ r.tokenBalances = { ...r.tokenBalances, [n]: a };
837
+ } catch (s) {
838
+ const i = s instanceof Error ? s.message : "Unable to get token balances";
839
+ R.showError(i);
840
+ } finally {
841
+ r.isFetchingTokenBalances = !1;
842
+ }
843
+ },
844
+ async fetchQuote({ amount: t, address: e, sourceToken: n, toToken: s, recipient: i }) {
845
+ try {
846
+ u.resetQuoteState(), r.isFetchingQuote = !0;
847
+ const a = await He({
848
+ amount: t,
849
+ address: r.selectedExchange ? void 0 : e,
850
+ sourceToken: n,
851
+ toToken: s,
852
+ recipient: i
853
+ });
854
+ if (r.selectedExchange) {
855
+ const o = ie(a);
856
+ if (o) {
857
+ const c = `${n.network}:${o.deposit.receiver}`, g = A.formatNumber(o.deposit.amount, {
858
+ decimals: n.metadata.decimals ?? 0,
859
+ round: 8
860
+ });
861
+ await u.generateExchangeUrlForQuote({
862
+ exchangeId: r.selectedExchange.id,
863
+ paymentAsset: n,
864
+ amount: g.toString(),
865
+ recipient: c
866
+ });
867
+ }
868
+ }
869
+ r.quote = a;
870
+ } catch (a) {
871
+ let o = q.UNABLE_TO_GET_QUOTE;
872
+ if (a instanceof Error && a.cause && a.cause instanceof Response)
873
+ try {
874
+ const c = await a.cause.json();
875
+ c.error && typeof c.error == "string" && (o = c.error);
876
+ } catch {
877
+ }
878
+ throw r.quoteError = o, R.showError(o), new p(d.UNABLE_TO_GET_QUOTE);
879
+ } finally {
880
+ r.isFetchingQuote = !1;
881
+ }
882
+ },
883
+ async fetchQuoteStatus({ requestId: t }) {
884
+ try {
885
+ if (t === ae) {
886
+ const n = r.selectedExchange, s = r.exchangeSessionId;
887
+ if (n && s) {
888
+ switch ((await this.getBuyStatus(n.id, s)).status) {
889
+ case "IN_PROGRESS":
890
+ r.quoteStatus = "waiting";
891
+ break;
892
+ case "SUCCESS":
893
+ r.quoteStatus = "success", r.isPaymentInProgress = !1;
894
+ break;
895
+ case "FAILED":
896
+ r.quoteStatus = "failure", r.isPaymentInProgress = !1;
897
+ break;
898
+ case "UNKNOWN":
899
+ r.quoteStatus = "waiting";
900
+ break;
901
+ default:
902
+ r.quoteStatus = "waiting";
903
+ break;
904
+ }
905
+ return;
906
+ }
907
+ r.quoteStatus = "success";
908
+ return;
909
+ }
910
+ const { status: e } = await Ke({ requestId: t });
911
+ r.quoteStatus = e;
912
+ } catch {
913
+ throw r.quoteStatus = "failure", new p(d.UNABLE_TO_GET_QUOTE_STATUS);
914
+ }
915
+ },
916
+ initiatePayment() {
917
+ r.isPaymentInProgress = !0, r.paymentId = crypto.randomUUID();
918
+ },
919
+ initializeAnalytics() {
920
+ r.analyticsSet || (r.analyticsSet = !0, this.subscribeKey("isPaymentInProgress", (t) => {
921
+ var e;
922
+ if ((e = r.currentPayment) != null && e.status && r.currentPayment.status !== "UNKNOWN") {
923
+ const n = {
924
+ IN_PROGRESS: "PAY_INITIATED",
925
+ SUCCESS: "PAY_SUCCESS",
926
+ FAILED: "PAY_ERROR"
927
+ }[r.currentPayment.status];
928
+ M.sendEvent({
929
+ type: "track",
930
+ event: n,
931
+ properties: {
932
+ message: r.currentPayment.status === "FAILED" ? O.parseError(r.error) : void 0,
933
+ source: "pay",
934
+ paymentId: r.paymentId || se,
935
+ configuration: {
936
+ network: r.paymentAsset.network,
937
+ asset: r.paymentAsset.asset,
938
+ recipient: r.recipient,
939
+ amount: r.amount
940
+ },
941
+ currentPayment: {
942
+ type: r.currentPayment.type,
943
+ exchangeId: r.currentPayment.exchangeId,
944
+ sessionId: r.currentPayment.sessionId,
945
+ result: r.currentPayment.result
946
+ }
947
+ }
948
+ });
949
+ }
950
+ }));
951
+ },
952
+ async prepareTokenLogo() {
953
+ if (!r.paymentAsset.metadata.logoURI)
954
+ try {
955
+ const { chainNamespace: t } = y.parseCaipNetworkId(r.paymentAsset.network), e = await T.getImageByToken(r.paymentAsset.asset, t);
956
+ r.paymentAsset.metadata.logoURI = e;
957
+ } catch {
958
+ }
959
+ }
960
+ }, rt = U`
961
+ wui-separator {
962
+ margin: var(--apkt-spacing-3) calc(var(--apkt-spacing-3) * -1) var(--apkt-spacing-2)
963
+ calc(var(--apkt-spacing-3) * -1);
964
+ width: calc(100% + var(--apkt-spacing-3) * 2);
965
+ }
966
+
967
+ .token-display {
968
+ padding: var(--apkt-spacing-3) var(--apkt-spacing-3);
969
+ border-radius: var(--apkt-borderRadius-5);
970
+ background-color: var(--apkt-tokens-theme-backgroundPrimary);
971
+ margin-top: var(--apkt-spacing-3);
972
+ margin-bottom: var(--apkt-spacing-3);
973
+ }
974
+
975
+ .token-display wui-text {
976
+ text-transform: none;
977
+ }
978
+
979
+ wui-loading-spinner {
980
+ padding: var(--apkt-spacing-2);
981
+ }
982
+
983
+ .left-image-container {
984
+ position: relative;
985
+ justify-content: center;
986
+ align-items: center;
987
+ }
988
+
989
+ .token-image {
990
+ border-radius: ${({ borderRadius: t }) => t.round};
991
+ width: 40px;
992
+ height: 40px;
993
+ }
994
+
995
+ .chain-image {
996
+ position: absolute;
997
+ width: 20px;
998
+ height: 20px;
999
+ bottom: -3px;
1000
+ right: -5px;
1001
+ border-radius: ${({ borderRadius: t }) => t.round};
1002
+ border: 2px solid ${({ tokens: t }) => t.theme.backgroundPrimary};
1003
+ }
1004
+
1005
+ .payment-methods-container {
1006
+ background-color: ${({ tokens: t }) => t.theme.foregroundPrimary};
1007
+ border-top-right-radius: ${({ borderRadius: t }) => t[8]};
1008
+ border-top-left-radius: ${({ borderRadius: t }) => t[8]};
1009
+ }
1010
+ `;
1011
+ var B = function(t, e, n, s) {
1012
+ var i = arguments.length, a = i < 3 ? e : s === null ? s = Object.getOwnPropertyDescriptor(e, n) : s, o;
1013
+ if (typeof Reflect == "object" && typeof Reflect.decorate == "function") a = Reflect.decorate(t, e, n, s);
1014
+ else for (var c = t.length - 1; c >= 0; c--) (o = t[c]) && (a = (i < 3 ? o(a) : i > 3 ? o(e, n, a) : o(e, n)) || a);
1015
+ return i > 3 && a && Object.defineProperty(e, n, a), a;
1016
+ };
1017
+ let k = class extends C {
1018
+ constructor() {
1019
+ super(), this.unsubscribe = [], this.amount = u.state.amount, this.namespace = void 0, this.paymentAsset = u.state.paymentAsset, this.activeConnectorIds = P.state.activeConnectorIds, this.caipAddress = void 0, this.exchanges = u.state.exchanges, this.isLoading = u.state.isLoading, this.initializeNamespace(), this.unsubscribe.push(u.subscribeKey("amount", (e) => this.amount = e)), this.unsubscribe.push(P.subscribeKey("activeConnectorIds", (e) => this.activeConnectorIds = e)), this.unsubscribe.push(u.subscribeKey("exchanges", (e) => this.exchanges = e)), this.unsubscribe.push(u.subscribeKey("isLoading", (e) => this.isLoading = e)), u.fetchExchanges(), u.setSelectedExchange(void 0);
1020
+ }
1021
+ disconnectedCallback() {
1022
+ this.unsubscribe.forEach((e) => e());
1023
+ }
1024
+ render() {
1025
+ return l`
1026
+ <wui-flex flexDirection="column">
1027
+ ${this.paymentDetailsTemplate()} ${this.paymentMethodsTemplate()}
1028
+ </wui-flex>
1029
+ `;
1030
+ }
1031
+ paymentMethodsTemplate() {
1032
+ return l`
1033
+ <wui-flex flexDirection="column" padding="3" gap="2" class="payment-methods-container">
1034
+ ${this.payWithWalletTemplate()} ${this.templateSeparator()}
1035
+ ${this.templateExchangeOptions()}
1036
+ </wui-flex>
1037
+ `;
1038
+ }
1039
+ initializeNamespace() {
1040
+ var n;
1041
+ const e = m.state.activeChain;
1042
+ this.namespace = e, this.caipAddress = (n = m.getAccountData(e)) == null ? void 0 : n.caipAddress, this.unsubscribe.push(m.subscribeChainProp("accountState", (s) => {
1043
+ this.caipAddress = s == null ? void 0 : s.caipAddress;
1044
+ }, e));
1045
+ }
1046
+ paymentDetailsTemplate() {
1047
+ const n = m.getAllRequestedCaipNetworks().find((s) => s.caipNetworkId === this.paymentAsset.network);
1048
+ return l`
1049
+ <wui-flex
1050
+ alignItems="center"
1051
+ justifyContent="space-between"
1052
+ .padding=${["6", "8", "6", "8"]}
1053
+ gap="2"
1054
+ >
1055
+ <wui-flex alignItems="center" gap="1">
1056
+ <wui-text variant="h1-regular" color="primary">
1057
+ ${X(this.amount || "0")}
1058
+ </wui-text>
1059
+
1060
+ <wui-flex flexDirection="column">
1061
+ <wui-text variant="h6-regular" color="secondary">
1062
+ ${this.paymentAsset.metadata.symbol || "Unknown"}
1063
+ </wui-text>
1064
+ <wui-text variant="md-medium" color="secondary"
1065
+ >on ${(n == null ? void 0 : n.name) || "Unknown"}</wui-text
1066
+ >
1067
+ </wui-flex>
1068
+ </wui-flex>
1069
+
1070
+ <wui-flex class="left-image-container">
1071
+ <wui-image
1072
+ src=${f(this.paymentAsset.metadata.logoURI)}
1073
+ class="token-image"
1074
+ ></wui-image>
1075
+ <wui-image
1076
+ src=${f(T.getNetworkImage(n))}
1077
+ class="chain-image"
1078
+ ></wui-image>
1079
+ </wui-flex>
1080
+ </wui-flex>
1081
+ `;
1082
+ }
1083
+ payWithWalletTemplate() {
1084
+ return et(this.paymentAsset.network) ? this.caipAddress ? this.connectedWalletTemplate() : this.disconnectedWalletTemplate() : l``;
1085
+ }
1086
+ connectedWalletTemplate() {
1087
+ const { name: e, image: n } = this.getWalletProperties({
1088
+ namespace: this.namespace
1089
+ });
1090
+ return l`
1091
+ <wui-flex flexDirection="column" gap="3">
1092
+ <wui-list-item
1093
+ type="secondary"
1094
+ boxColor="foregroundSecondary"
1095
+ @click=${this.onWalletPayment}
1096
+ .boxed=${!1}
1097
+ ?chevron=${!0}
1098
+ ?fullSize=${!1}
1099
+ ?rounded=${!0}
1100
+ data-testid="wallet-payment-option"
1101
+ imageSrc=${f(n)}
1102
+ imageSize="3xl"
1103
+ >
1104
+ <wui-text variant="lg-regular" color="primary">Pay with ${e}</wui-text>
1105
+ </wui-list-item>
1106
+
1107
+ <wui-list-item
1108
+ type="secondary"
1109
+ icon="power"
1110
+ iconColor="error"
1111
+ @click=${this.onDisconnect}
1112
+ data-testid="disconnect-button"
1113
+ ?chevron=${!1}
1114
+ boxColor="foregroundSecondary"
1115
+ >
1116
+ <wui-text variant="lg-regular" color="secondary">Disconnect</wui-text>
1117
+ </wui-list-item>
1118
+ </wui-flex>
1119
+ `;
1120
+ }
1121
+ disconnectedWalletTemplate() {
1122
+ return l`<wui-list-item
1123
+ type="secondary"
1124
+ boxColor="foregroundSecondary"
1125
+ variant="icon"
1126
+ iconColor="default"
1127
+ iconVariant="overlay"
1128
+ icon="wallet"
1129
+ @click=${this.onWalletPayment}
1130
+ ?chevron=${!0}
1131
+ data-testid="wallet-payment-option"
1132
+ >
1133
+ <wui-text variant="lg-regular" color="primary">Pay with wallet</wui-text>
1134
+ </wui-list-item>`;
1135
+ }
1136
+ templateExchangeOptions() {
1137
+ if (this.isLoading)
1138
+ return l`<wui-flex justifyContent="center" alignItems="center">
1139
+ <wui-loading-spinner size="md"></wui-loading-spinner>
1140
+ </wui-flex>`;
1141
+ const e = this.exchanges.filter((n) => st(this.paymentAsset) ? n.id === fe : n.id !== fe);
1142
+ return e.length === 0 ? l`<wui-flex justifyContent="center" alignItems="center">
1143
+ <wui-text variant="md-medium" color="primary">No exchanges available</wui-text>
1144
+ </wui-flex>` : e.map((n) => l`
1145
+ <wui-list-item
1146
+ type="secondary"
1147
+ boxColor="foregroundSecondary"
1148
+ @click=${() => this.onExchangePayment(n)}
1149
+ data-testid="exchange-option-${n.id}"
1150
+ ?chevron=${!0}
1151
+ imageSrc=${f(n.imageUrl)}
1152
+ >
1153
+ <wui-text flexGrow="1" variant="lg-regular" color="primary">
1154
+ Pay with ${n.name}
1155
+ </wui-text>
1156
+ </wui-list-item>
1157
+ `);
1158
+ }
1159
+ templateSeparator() {
1160
+ return l`<wui-separator text="or" bgColor="secondary"></wui-separator>`;
1161
+ }
1162
+ async onWalletPayment() {
1163
+ if (!this.namespace)
1164
+ throw new Error("Namespace not found");
1165
+ this.caipAddress ? z.push("PayQuote") : (await P.connect(), await G.open({ view: "PayQuote" }));
1166
+ }
1167
+ onExchangePayment(e) {
1168
+ u.setSelectedExchange(e), z.push("PayQuote");
1169
+ }
1170
+ async onDisconnect() {
1171
+ try {
1172
+ await v.disconnect(), await G.open({ view: "Pay" });
1173
+ } catch {
1174
+ console.error("Failed to disconnect"), R.showError("Failed to disconnect");
1175
+ }
1176
+ }
1177
+ getWalletProperties({ namespace: e }) {
1178
+ if (!e)
1179
+ return {
1180
+ name: void 0,
1181
+ image: void 0
1182
+ };
1183
+ const n = this.activeConnectorIds[e];
1184
+ if (!n)
1185
+ return {
1186
+ name: void 0,
1187
+ image: void 0
1188
+ };
1189
+ const s = P.getConnector({ id: n, namespace: e });
1190
+ if (!s)
1191
+ return {
1192
+ name: void 0,
1193
+ image: void 0
1194
+ };
1195
+ const i = T.getConnectorImage(s);
1196
+ return {
1197
+ name: s.name,
1198
+ image: i
1199
+ };
1200
+ }
1201
+ };
1202
+ k.styles = rt;
1203
+ B([
1204
+ h()
1205
+ ], k.prototype, "amount", void 0);
1206
+ B([
1207
+ h()
1208
+ ], k.prototype, "namespace", void 0);
1209
+ B([
1210
+ h()
1211
+ ], k.prototype, "paymentAsset", void 0);
1212
+ B([
1213
+ h()
1214
+ ], k.prototype, "activeConnectorIds", void 0);
1215
+ B([
1216
+ h()
1217
+ ], k.prototype, "caipAddress", void 0);
1218
+ B([
1219
+ h()
1220
+ ], k.prototype, "exchanges", void 0);
1221
+ B([
1222
+ h()
1223
+ ], k.prototype, "isLoading", void 0);
1224
+ k = B([
1225
+ _("w3m-pay-view")
1226
+ ], k);
1227
+ const ot = U`
1228
+ :host {
1229
+ display: inline-flex;
1230
+ align-items: center;
1231
+ justify-content: center;
1232
+ }
1233
+
1234
+ .pulse-container {
1235
+ position: relative;
1236
+ width: var(--pulse-size);
1237
+ height: var(--pulse-size);
1238
+ display: flex;
1239
+ align-items: center;
1240
+ justify-content: center;
1241
+ }
1242
+
1243
+ .pulse-rings {
1244
+ position: absolute;
1245
+ inset: 0;
1246
+ pointer-events: none;
1247
+ }
1248
+
1249
+ .pulse-ring {
1250
+ position: absolute;
1251
+ inset: 0;
1252
+ border-radius: 50%;
1253
+ border: 2px solid var(--pulse-color);
1254
+ opacity: 0;
1255
+ animation: pulse var(--pulse-duration, 2s) ease-out infinite;
1256
+ }
1257
+
1258
+ .pulse-content {
1259
+ position: relative;
1260
+ z-index: 1;
1261
+ display: flex;
1262
+ align-items: center;
1263
+ justify-content: center;
1264
+ }
1265
+
1266
+ @keyframes pulse {
1267
+ 0% {
1268
+ transform: scale(0.5);
1269
+ opacity: var(--pulse-opacity, 0.3);
1270
+ }
1271
+ 50% {
1272
+ opacity: calc(var(--pulse-opacity, 0.3) * 0.5);
1273
+ }
1274
+ 100% {
1275
+ transform: scale(1.2);
1276
+ opacity: 0;
1277
+ }
1278
+ }
1279
+ `;
1280
+ var j = function(t, e, n, s) {
1281
+ var i = arguments.length, a = i < 3 ? e : s === null ? s = Object.getOwnPropertyDescriptor(e, n) : s, o;
1282
+ if (typeof Reflect == "object" && typeof Reflect.decorate == "function") a = Reflect.decorate(t, e, n, s);
1283
+ else for (var c = t.length - 1; c >= 0; c--) (o = t[c]) && (a = (i < 3 ? o(a) : i > 3 ? o(e, n, a) : o(e, n)) || a);
1284
+ return i > 3 && a && Object.defineProperty(e, n, a), a;
1285
+ };
1286
+ const ct = 3, ut = 2, lt = 0.3, dt = "200px", pt = {
1287
+ "accent-primary": Ue.tokens.core.backgroundAccentPrimary
1288
+ };
1289
+ let D = class extends C {
1290
+ constructor() {
1291
+ super(...arguments), this.rings = ct, this.duration = ut, this.opacity = lt, this.size = dt, this.variant = "accent-primary";
1292
+ }
1293
+ render() {
1294
+ const e = pt[this.variant];
1295
+ this.style.cssText = `
1296
+ --pulse-size: ${this.size};
1297
+ --pulse-duration: ${this.duration}s;
1298
+ --pulse-color: ${e};
1299
+ --pulse-opacity: ${this.opacity};
1300
+ `;
1301
+ const n = Array.from({ length: this.rings }, (s, i) => this.renderRing(i, this.rings));
1302
+ return l`
1303
+ <div class="pulse-container">
1304
+ <div class="pulse-rings">${n}</div>
1305
+ <div class="pulse-content">
1306
+ <slot></slot>
1307
+ </div>
1308
+ </div>
1309
+ `;
1310
+ }
1311
+ renderRing(e, n) {
1312
+ const i = `animation-delay: ${e / n * this.duration}s;`;
1313
+ return l`<div class="pulse-ring" style=${i}></div>`;
1314
+ }
1315
+ };
1316
+ D.styles = [Ie, ot];
1317
+ j([
1318
+ x({ type: Number })
1319
+ ], D.prototype, "rings", void 0);
1320
+ j([
1321
+ x({ type: Number })
1322
+ ], D.prototype, "duration", void 0);
1323
+ j([
1324
+ x({ type: Number })
1325
+ ], D.prototype, "opacity", void 0);
1326
+ j([
1327
+ x()
1328
+ ], D.prototype, "size", void 0);
1329
+ j([
1330
+ x()
1331
+ ], D.prototype, "variant", void 0);
1332
+ D = j([
1333
+ _("wui-pulse")
1334
+ ], D);
1335
+ const Ae = [
1336
+ {
1337
+ id: "received",
1338
+ title: "Receiving funds",
1339
+ icon: "dollar"
1340
+ },
1341
+ {
1342
+ id: "processing",
1343
+ title: "Swapping asset",
1344
+ icon: "recycleHorizontal"
1345
+ },
1346
+ {
1347
+ id: "sending",
1348
+ title: "Sending asset to the recipient address",
1349
+ icon: "send"
1350
+ }
1351
+ ], Ee = [
1352
+ "success",
1353
+ "submitted",
1354
+ "failure",
1355
+ "timeout",
1356
+ "refund"
1357
+ ], ht = U`
1358
+ :host {
1359
+ display: block;
1360
+ height: 100%;
1361
+ width: 100%;
1362
+ }
1363
+
1364
+ wui-image {
1365
+ border-radius: ${({ borderRadius: t }) => t.round};
1366
+ }
1367
+
1368
+ .token-badge-container {
1369
+ position: absolute;
1370
+ bottom: 6px;
1371
+ left: 50%;
1372
+ transform: translateX(-50%);
1373
+ border-radius: ${({ borderRadius: t }) => t[4]};
1374
+ z-index: 3;
1375
+ min-width: 105px;
1376
+ }
1377
+
1378
+ .token-badge-container.loading {
1379
+ background-color: ${({ tokens: t }) => t.theme.backgroundPrimary};
1380
+ border: 3px solid ${({ tokens: t }) => t.theme.backgroundPrimary};
1381
+ }
1382
+
1383
+ .token-badge-container.success {
1384
+ background-color: ${({ tokens: t }) => t.theme.backgroundPrimary};
1385
+ border: 3px solid ${({ tokens: t }) => t.theme.backgroundPrimary};
1386
+ }
1387
+
1388
+ .token-image-container {
1389
+ position: relative;
1390
+ }
1391
+
1392
+ .token-image {
1393
+ border-radius: ${({ borderRadius: t }) => t.round};
1394
+ width: 64px;
1395
+ height: 64px;
1396
+ }
1397
+
1398
+ .token-image.success {
1399
+ background-color: ${({ tokens: t }) => t.theme.foregroundPrimary};
1400
+ }
1401
+
1402
+ .token-image.error {
1403
+ background-color: ${({ tokens: t }) => t.theme.foregroundPrimary};
1404
+ }
1405
+
1406
+ .token-image.loading {
1407
+ background: ${({ colors: t }) => t.accent010};
1408
+ }
1409
+
1410
+ .token-image wui-icon {
1411
+ width: 32px;
1412
+ height: 32px;
1413
+ }
1414
+
1415
+ .token-badge {
1416
+ background-color: ${({ tokens: t }) => t.theme.foregroundPrimary};
1417
+ border: 1px solid ${({ tokens: t }) => t.theme.foregroundSecondary};
1418
+ border-radius: ${({ borderRadius: t }) => t[4]};
1419
+ }
1420
+
1421
+ .token-badge wui-text {
1422
+ white-space: nowrap;
1423
+ }
1424
+
1425
+ .payment-lifecycle-container {
1426
+ background-color: ${({ tokens: t }) => t.theme.foregroundPrimary};
1427
+ border-top-right-radius: ${({ borderRadius: t }) => t[6]};
1428
+ border-top-left-radius: ${({ borderRadius: t }) => t[6]};
1429
+ }
1430
+
1431
+ .payment-step-badge {
1432
+ padding: ${({ spacing: t }) => t[1]} ${({ spacing: t }) => t[2]};
1433
+ border-radius: ${({ borderRadius: t }) => t[1]};
1434
+ }
1435
+
1436
+ .payment-step-badge.loading {
1437
+ background-color: ${({ tokens: t }) => t.theme.foregroundSecondary};
1438
+ }
1439
+
1440
+ .payment-step-badge.error {
1441
+ background-color: ${({ tokens: t }) => t.core.backgroundError};
1442
+ }
1443
+
1444
+ .payment-step-badge.success {
1445
+ background-color: ${({ tokens: t }) => t.core.backgroundSuccess};
1446
+ }
1447
+
1448
+ .step-icon-container {
1449
+ position: relative;
1450
+ height: 40px;
1451
+ width: 40px;
1452
+ border-radius: ${({ borderRadius: t }) => t.round};
1453
+ background-color: ${({ tokens: t }) => t.theme.foregroundSecondary};
1454
+ }
1455
+
1456
+ .step-icon-box {
1457
+ position: absolute;
1458
+ right: -4px;
1459
+ bottom: -1px;
1460
+ padding: 2px;
1461
+ border-radius: ${({ borderRadius: t }) => t.round};
1462
+ border: 2px solid ${({ tokens: t }) => t.theme.backgroundPrimary};
1463
+ background-color: ${({ tokens: t }) => t.theme.foregroundPrimary};
1464
+ }
1465
+
1466
+ .step-icon-box.success {
1467
+ background-color: ${({ tokens: t }) => t.core.backgroundSuccess};
1468
+ }
1469
+ `;
1470
+ var $ = function(t, e, n, s) {
1471
+ var i = arguments.length, a = i < 3 ? e : s === null ? s = Object.getOwnPropertyDescriptor(e, n) : s, o;
1472
+ if (typeof Reflect == "object" && typeof Reflect.decorate == "function") a = Reflect.decorate(t, e, n, s);
1473
+ else for (var c = t.length - 1; c >= 0; c--) (o = t[c]) && (a = (i < 3 ? o(a) : i > 3 ? o(e, n, a) : o(e, n)) || a);
1474
+ return i > 3 && a && Object.defineProperty(e, n, a), a;
1475
+ };
1476
+ const mt = {
1477
+ received: ["pending", "success", "submitted"],
1478
+ processing: ["success", "submitted"],
1479
+ sending: ["success", "submitted"]
1480
+ }, gt = 3e3;
1481
+ let E = class extends C {
1482
+ constructor() {
1483
+ super(), this.unsubscribe = [], this.pollingInterval = null, this.paymentAsset = u.state.paymentAsset, this.quoteStatus = u.state.quoteStatus, this.quote = u.state.quote, this.amount = u.state.amount, this.namespace = void 0, this.caipAddress = void 0, this.profileName = null, this.activeConnectorIds = P.state.activeConnectorIds, this.selectedExchange = u.state.selectedExchange, this.initializeNamespace(), this.unsubscribe.push(u.subscribeKey("quoteStatus", (e) => this.quoteStatus = e), u.subscribeKey("quote", (e) => this.quote = e), P.subscribeKey("activeConnectorIds", (e) => this.activeConnectorIds = e), u.subscribeKey("selectedExchange", (e) => this.selectedExchange = e));
1484
+ }
1485
+ connectedCallback() {
1486
+ super.connectedCallback(), this.startPolling();
1487
+ }
1488
+ disconnectedCallback() {
1489
+ super.disconnectedCallback(), this.stopPolling(), this.unsubscribe.forEach((e) => e());
1490
+ }
1491
+ render() {
1492
+ return l`
1493
+ <wui-flex flexDirection="column" .padding=${["3", "0", "0", "0"]} gap="2">
1494
+ ${this.tokenTemplate()} ${this.paymentTemplate()} ${this.paymentLifecycleTemplate()}
1495
+ </wui-flex>
1496
+ `;
1497
+ }
1498
+ tokenTemplate() {
1499
+ const e = X(this.amount || "0"), n = this.paymentAsset.metadata.symbol ?? "Unknown", i = m.getAllRequestedCaipNetworks().find((c) => c.caipNetworkId === this.paymentAsset.network), a = this.quoteStatus === "failure" || this.quoteStatus === "timeout" || this.quoteStatus === "refund";
1500
+ return this.quoteStatus === "success" || this.quoteStatus === "submitted" ? l`<wui-flex alignItems="center" justifyContent="center">
1501
+ <wui-flex justifyContent="center" alignItems="center" class="token-image success">
1502
+ <wui-icon name="checkmark" color="success" size="inherit"></wui-icon>
1503
+ </wui-flex>
1504
+ </wui-flex>` : a ? l`<wui-flex alignItems="center" justifyContent="center">
1505
+ <wui-flex justifyContent="center" alignItems="center" class="token-image error">
1506
+ <wui-icon name="close" color="error" size="inherit"></wui-icon>
1507
+ </wui-flex>
1508
+ </wui-flex>` : l`
1509
+ <wui-flex alignItems="center" justifyContent="center">
1510
+ <wui-flex class="token-image-container">
1511
+ <wui-pulse size="125px" rings="3" duration="4" opacity="0.5" variant="accent-primary">
1512
+ <wui-flex justifyContent="center" alignItems="center" class="token-image loading">
1513
+ <wui-icon name="paperPlaneTitle" color="accent-primary" size="inherit"></wui-icon>
1514
+ </wui-flex>
1515
+ </wui-pulse>
1516
+
1517
+ <wui-flex
1518
+ justifyContent="center"
1519
+ alignItems="center"
1520
+ class="token-badge-container loading"
1521
+ >
1522
+ <wui-flex
1523
+ alignItems="center"
1524
+ justifyContent="center"
1525
+ gap="01"
1526
+ padding="1"
1527
+ class="token-badge"
1528
+ >
1529
+ <wui-image
1530
+ src=${f(T.getNetworkImage(i))}
1531
+ class="chain-image"
1532
+ size="mdl"
1533
+ ></wui-image>
1534
+
1535
+ <wui-text variant="lg-regular" color="primary">${e} ${n}</wui-text>
1536
+ </wui-flex>
1537
+ </wui-flex>
1538
+ </wui-flex>
1539
+ </wui-flex>
1540
+ `;
1541
+ }
1542
+ paymentTemplate() {
1543
+ return l`
1544
+ <wui-flex flexDirection="column" gap="2" .padding=${["0", "6", "0", "6"]}>
1545
+ ${this.renderPayment()}
1546
+ <wui-separator></wui-separator>
1547
+ ${this.renderWallet()}
1548
+ </wui-flex>
1549
+ `;
1550
+ }
1551
+ paymentLifecycleTemplate() {
1552
+ const e = this.getStepsWithStatus();
1553
+ return l`
1554
+ <wui-flex flexDirection="column" padding="4" gap="2" class="payment-lifecycle-container">
1555
+ <wui-flex alignItems="center" justifyContent="space-between">
1556
+ <wui-text variant="md-regular" color="secondary">PAYMENT CYCLE</wui-text>
1557
+
1558
+ ${this.renderPaymentCycleBadge()}
1559
+ </wui-flex>
1560
+
1561
+ <wui-flex flexDirection="column" gap="5" .padding=${["2", "0", "2", "0"]}>
1562
+ ${e.map((n) => this.renderStep(n))}
1563
+ </wui-flex>
1564
+ </wui-flex>
1565
+ `;
1566
+ }
1567
+ renderPaymentCycleBadge() {
1568
+ var i;
1569
+ const e = this.quoteStatus === "failure" || this.quoteStatus === "timeout" || this.quoteStatus === "refund", n = this.quoteStatus === "success" || this.quoteStatus === "submitted";
1570
+ if (e)
1571
+ return l`
1572
+ <wui-flex
1573
+ justifyContent="center"
1574
+ alignItems="center"
1575
+ class="payment-step-badge error"
1576
+ gap="1"
1577
+ >
1578
+ <wui-icon name="close" color="error" size="xs"></wui-icon>
1579
+ <wui-text variant="sm-regular" color="error">Failed</wui-text>
1580
+ </wui-flex>
1581
+ `;
1582
+ if (n)
1583
+ return l`
1584
+ <wui-flex
1585
+ justifyContent="center"
1586
+ alignItems="center"
1587
+ class="payment-step-badge success"
1588
+ gap="1"
1589
+ >
1590
+ <wui-icon name="checkmark" color="success" size="xs"></wui-icon>
1591
+ <wui-text variant="sm-regular" color="success">Completed</wui-text>
1592
+ </wui-flex>
1593
+ `;
1594
+ const s = ((i = this.quote) == null ? void 0 : i.timeInSeconds) ?? 0;
1595
+ return l`
1596
+ <wui-flex alignItems="center" justifyContent="space-between" gap="3">
1597
+ <wui-flex
1598
+ justifyContent="center"
1599
+ alignItems="center"
1600
+ class="payment-step-badge loading"
1601
+ gap="1"
1602
+ >
1603
+ <wui-icon name="clock" color="default" size="xs"></wui-icon>
1604
+ <wui-text variant="sm-regular" color="primary">Est. ${s} sec</wui-text>
1605
+ </wui-flex>
1606
+
1607
+ <wui-icon name="chevronBottom" color="default" size="xxs"></wui-icon>
1608
+ </wui-flex>
1609
+ `;
1610
+ }
1611
+ renderPayment() {
1612
+ var o, c, g;
1613
+ const n = m.getAllRequestedCaipNetworks().find((L) => {
1614
+ var Y;
1615
+ const Q = (Y = this.quote) == null ? void 0 : Y.origin.currency.network;
1616
+ if (!Q)
1617
+ return !1;
1618
+ const { chainId: V } = y.parseCaipNetworkId(Q);
1619
+ return N.isLowerCaseMatch(L.id.toString(), V.toString());
1620
+ }), s = A.formatNumber(((o = this.quote) == null ? void 0 : o.origin.amount) || "0", {
1621
+ decimals: ((c = this.quote) == null ? void 0 : c.origin.currency.metadata.decimals) ?? 0
1622
+ }).toString(), i = X(s), a = ((g = this.quote) == null ? void 0 : g.origin.currency.metadata.symbol) ?? "Unknown";
1623
+ return l`
1624
+ <wui-flex
1625
+ alignItems="flex-start"
1626
+ justifyContent="space-between"
1627
+ .padding=${["3", "0", "3", "0"]}
1628
+ >
1629
+ <wui-text variant="lg-regular" color="secondary">Payment Method</wui-text>
1630
+
1631
+ <wui-flex flexDirection="column" alignItems="flex-end" gap="1">
1632
+ <wui-flex alignItems="center" gap="01">
1633
+ <wui-text variant="lg-regular" color="primary">${i}</wui-text>
1634
+ <wui-text variant="lg-regular" color="secondary">${a}</wui-text>
1635
+ </wui-flex>
1636
+
1637
+ <wui-flex alignItems="center" gap="1">
1638
+ <wui-text variant="md-regular" color="secondary">on</wui-text>
1639
+ <wui-image
1640
+ src=${f(T.getNetworkImage(n))}
1641
+ size="xs"
1642
+ ></wui-image>
1643
+ <wui-text variant="md-regular" color="secondary">${n == null ? void 0 : n.name}</wui-text>
1644
+ </wui-flex>
1645
+ </wui-flex>
1646
+ </wui-flex>
1647
+ `;
1648
+ }
1649
+ renderWallet() {
1650
+ return l`
1651
+ <wui-flex
1652
+ alignItems="flex-start"
1653
+ justifyContent="space-between"
1654
+ .padding=${["3", "0", "3", "0"]}
1655
+ >
1656
+ <wui-text variant="lg-regular" color="secondary">Wallet</wui-text>
1657
+
1658
+ ${this.renderWalletText()}
1659
+ </wui-flex>
1660
+ `;
1661
+ }
1662
+ renderWalletText() {
1663
+ var i;
1664
+ const { image: e } = this.getWalletProperties({ namespace: this.namespace }), { address: n } = this.caipAddress ? y.parseCaipAddress(this.caipAddress) : {}, s = (i = this.selectedExchange) == null ? void 0 : i.name;
1665
+ return this.selectedExchange ? l`
1666
+ <wui-flex alignItems="center" justifyContent="flex-end" gap="1">
1667
+ <wui-text variant="lg-regular" color="primary">${s}</wui-text>
1668
+ <wui-image src=${f(this.selectedExchange.imageUrl)} size="mdl"></wui-image>
1669
+ </wui-flex>
1670
+ ` : l`
1671
+ <wui-flex alignItems="center" justifyContent="flex-end" gap="1">
1672
+ <wui-text variant="lg-regular" color="primary">
1673
+ ${Le.getTruncateString({
1674
+ string: this.profileName || n || s || "",
1675
+ charsStart: this.profileName ? 16 : 4,
1676
+ charsEnd: this.profileName ? 0 : 6,
1677
+ truncate: this.profileName ? "end" : "middle"
1678
+ })}
1679
+ </wui-text>
1680
+
1681
+ <wui-image src=${f(e)} size="mdl"></wui-image>
1682
+ </wui-flex>
1683
+ `;
1684
+ }
1685
+ getStepsWithStatus() {
1686
+ return this.quoteStatus === "failure" || this.quoteStatus === "timeout" || this.quoteStatus === "refund" ? Ae.map((n) => ({ ...n, status: "failed" })) : Ae.map((n) => {
1687
+ const i = (mt[n.id] ?? []).includes(this.quoteStatus) ? "completed" : "pending";
1688
+ return { ...n, status: i };
1689
+ });
1690
+ }
1691
+ renderStep({ title: e, icon: n, status: s }) {
1692
+ return l`
1693
+ <wui-flex alignItems="center" gap="3">
1694
+ <wui-flex justifyContent="center" alignItems="center" class="step-icon-container">
1695
+ <wui-icon name=${n} color="default" size="mdl"></wui-icon>
1696
+
1697
+ <wui-flex alignItems="center" justifyContent="center" class=${Ne({
1698
+ "step-icon-box": !0,
1699
+ success: s === "completed"
1700
+ })}>
1701
+ ${this.renderStatusIndicator(s)}
1702
+ </wui-flex>
1703
+ </wui-flex>
1704
+
1705
+ <wui-text variant="md-regular" color="primary">${e}</wui-text>
1706
+ </wui-flex>
1707
+ `;
1708
+ }
1709
+ renderStatusIndicator(e) {
1710
+ return e === "completed" ? l`<wui-icon size="sm" color="success" name="checkmark"></wui-icon>` : e === "failed" ? l`<wui-icon size="sm" color="error" name="close"></wui-icon>` : e === "pending" ? l`<wui-loading-spinner color="accent-primary" size="sm"></wui-loading-spinner>` : null;
1711
+ }
1712
+ startPolling() {
1713
+ this.pollingInterval || (this.fetchQuoteStatus(), this.pollingInterval = setInterval(() => {
1714
+ this.fetchQuoteStatus();
1715
+ }, gt));
1716
+ }
1717
+ stopPolling() {
1718
+ this.pollingInterval && (clearInterval(this.pollingInterval), this.pollingInterval = null);
1719
+ }
1720
+ async fetchQuoteStatus() {
1721
+ const e = u.state.requestId;
1722
+ if (!e || Ee.includes(this.quoteStatus))
1723
+ this.stopPolling();
1724
+ else
1725
+ try {
1726
+ await u.fetchQuoteStatus({ requestId: e }), Ee.includes(this.quoteStatus) && this.stopPolling();
1727
+ } catch {
1728
+ this.stopPolling();
1729
+ }
1730
+ }
1731
+ initializeNamespace() {
1732
+ var n, s;
1733
+ const e = m.state.activeChain;
1734
+ this.namespace = e, this.caipAddress = (n = m.getAccountData(e)) == null ? void 0 : n.caipAddress, this.profileName = ((s = m.getAccountData(e)) == null ? void 0 : s.profileName) ?? null, this.unsubscribe.push(m.subscribeChainProp("accountState", (i) => {
1735
+ this.caipAddress = i == null ? void 0 : i.caipAddress, this.profileName = (i == null ? void 0 : i.profileName) ?? null;
1736
+ }, e));
1737
+ }
1738
+ getWalletProperties({ namespace: e }) {
1739
+ if (!e)
1740
+ return {
1741
+ name: void 0,
1742
+ image: void 0
1743
+ };
1744
+ const n = this.activeConnectorIds[e];
1745
+ if (!n)
1746
+ return {
1747
+ name: void 0,
1748
+ image: void 0
1749
+ };
1750
+ const s = P.getConnector({ id: n, namespace: e });
1751
+ if (!s)
1752
+ return {
1753
+ name: void 0,
1754
+ image: void 0
1755
+ };
1756
+ const i = T.getConnectorImage(s);
1757
+ return {
1758
+ name: s.name,
1759
+ image: i
1760
+ };
1761
+ }
1762
+ };
1763
+ E.styles = ht;
1764
+ $([
1765
+ h()
1766
+ ], E.prototype, "paymentAsset", void 0);
1767
+ $([
1768
+ h()
1769
+ ], E.prototype, "quoteStatus", void 0);
1770
+ $([
1771
+ h()
1772
+ ], E.prototype, "quote", void 0);
1773
+ $([
1774
+ h()
1775
+ ], E.prototype, "amount", void 0);
1776
+ $([
1777
+ h()
1778
+ ], E.prototype, "namespace", void 0);
1779
+ $([
1780
+ h()
1781
+ ], E.prototype, "caipAddress", void 0);
1782
+ $([
1783
+ h()
1784
+ ], E.prototype, "profileName", void 0);
1785
+ $([
1786
+ h()
1787
+ ], E.prototype, "activeConnectorIds", void 0);
1788
+ $([
1789
+ h()
1790
+ ], E.prototype, "selectedExchange", void 0);
1791
+ E = $([
1792
+ _("w3m-pay-loading-view")
1793
+ ], E);
1794
+ const ft = qe`
1795
+ :host {
1796
+ display: block;
1797
+ }
1798
+ `;
1799
+ var wt = function(t, e, n, s) {
1800
+ var i = arguments.length, a = i < 3 ? e : s === null ? s = Object.getOwnPropertyDescriptor(e, n) : s, o;
1801
+ if (typeof Reflect == "object" && typeof Reflect.decorate == "function") a = Reflect.decorate(t, e, n, s);
1802
+ else for (var c = t.length - 1; c >= 0; c--) (o = t[c]) && (a = (i < 3 ? o(a) : i > 3 ? o(e, n, a) : o(e, n)) || a);
1803
+ return i > 3 && a && Object.defineProperty(e, n, a), a;
1804
+ };
1805
+ let re = class extends C {
1806
+ render() {
1807
+ return l`
1808
+ <wui-flex flexDirection="column" gap="4">
1809
+ <wui-flex alignItems="center" justifyContent="space-between">
1810
+ <wui-text variant="md-regular" color="secondary">Pay</wui-text>
1811
+ <wui-shimmer width="60px" height="16px" borderRadius="4xs" variant="light"></wui-shimmer>
1812
+ </wui-flex>
1813
+
1814
+ <wui-flex alignItems="center" justifyContent="space-between">
1815
+ <wui-text variant="md-regular" color="secondary">Network Fee</wui-text>
1816
+
1817
+ <wui-flex flexDirection="column" alignItems="flex-end" gap="2">
1818
+ <wui-shimmer
1819
+ width="75px"
1820
+ height="16px"
1821
+ borderRadius="4xs"
1822
+ variant="light"
1823
+ ></wui-shimmer>
1824
+
1825
+ <wui-flex alignItems="center" gap="01">
1826
+ <wui-shimmer width="14px" height="14px" rounded variant="light"></wui-shimmer>
1827
+ <wui-shimmer
1828
+ width="49px"
1829
+ height="14px"
1830
+ borderRadius="4xs"
1831
+ variant="light"
1832
+ ></wui-shimmer>
1833
+ </wui-flex>
1834
+ </wui-flex>
1835
+ </wui-flex>
1836
+
1837
+ <wui-flex alignItems="center" justifyContent="space-between">
1838
+ <wui-text variant="md-regular" color="secondary">Service Fee</wui-text>
1839
+ <wui-shimmer width="75px" height="16px" borderRadius="4xs" variant="light"></wui-shimmer>
1840
+ </wui-flex>
1841
+ </wui-flex>
1842
+ `;
1843
+ }
1844
+ };
1845
+ re.styles = [ft];
1846
+ re = wt([
1847
+ _("w3m-pay-fees-skeleton")
1848
+ ], re);
1849
+ const yt = U`
1850
+ :host {
1851
+ display: block;
1852
+ }
1853
+
1854
+ wui-image {
1855
+ border-radius: ${({ borderRadius: t }) => t.round};
1856
+ }
1857
+ `;
1858
+ var Pe = function(t, e, n, s) {
1859
+ var i = arguments.length, a = i < 3 ? e : s === null ? s = Object.getOwnPropertyDescriptor(e, n) : s, o;
1860
+ if (typeof Reflect == "object" && typeof Reflect.decorate == "function") a = Reflect.decorate(t, e, n, s);
1861
+ else for (var c = t.length - 1; c >= 0; c--) (o = t[c]) && (a = (i < 3 ? o(a) : i > 3 ? o(e, n, a) : o(e, n)) || a);
1862
+ return i > 3 && a && Object.defineProperty(e, n, a), a;
1863
+ };
1864
+ let Z = class extends C {
1865
+ constructor() {
1866
+ super(), this.unsubscribe = [], this.quote = u.state.quote, this.unsubscribe.push(u.subscribeKey("quote", (e) => this.quote = e));
1867
+ }
1868
+ disconnectedCallback() {
1869
+ this.unsubscribe.forEach((e) => e());
1870
+ }
1871
+ render() {
1872
+ var n, s, i;
1873
+ const e = A.formatNumber(((n = this.quote) == null ? void 0 : n.origin.amount) || "0", {
1874
+ decimals: ((s = this.quote) == null ? void 0 : s.origin.currency.metadata.decimals) ?? 0,
1875
+ round: 6
1876
+ }).toString();
1877
+ return l`
1878
+ <wui-flex flexDirection="column" gap="4">
1879
+ <wui-flex alignItems="center" justifyContent="space-between">
1880
+ <wui-text variant="md-regular" color="secondary">Pay</wui-text>
1881
+ <wui-text variant="md-regular" color="primary">
1882
+ ${e} ${((i = this.quote) == null ? void 0 : i.origin.currency.metadata.symbol) || "Unknown"}
1883
+ </wui-text>
1884
+ </wui-flex>
1885
+
1886
+ ${this.quote && this.quote.fees.length > 0 ? this.quote.fees.map((a) => this.renderFee(a)) : null}
1887
+ </wui-flex>
1888
+ `;
1889
+ }
1890
+ renderFee(e) {
1891
+ const n = e.id === "network", s = A.formatNumber(e.amount || "0", {
1892
+ decimals: e.currency.metadata.decimals ?? 0,
1893
+ round: 6
1894
+ }).toString();
1895
+ if (n) {
1896
+ const a = m.getAllRequestedCaipNetworks().find((o) => N.isLowerCaseMatch(o.caipNetworkId, e.currency.network));
1897
+ return l`
1898
+ <wui-flex alignItems="center" justifyContent="space-between">
1899
+ <wui-text variant="md-regular" color="secondary">${e.label}</wui-text>
1900
+
1901
+ <wui-flex flexDirection="column" alignItems="flex-end" gap="2">
1902
+ <wui-text variant="md-regular" color="primary">
1903
+ ${s} ${e.currency.metadata.symbol || "Unknown"}
1904
+ </wui-text>
1905
+
1906
+ <wui-flex alignItems="center" gap="01">
1907
+ <wui-image
1908
+ src=${f(T.getNetworkImage(a))}
1909
+ size="xs"
1910
+ ></wui-image>
1911
+ <wui-text variant="sm-regular" color="secondary">
1912
+ ${(a == null ? void 0 : a.name) || "Unknown"}
1913
+ </wui-text>
1914
+ </wui-flex>
1915
+ </wui-flex>
1916
+ </wui-flex>
1917
+ `;
1918
+ }
1919
+ return l`
1920
+ <wui-flex alignItems="center" justifyContent="space-between">
1921
+ <wui-text variant="md-regular" color="secondary">${e.label}</wui-text>
1922
+ <wui-text variant="md-regular" color="primary">
1923
+ ${s} ${e.currency.metadata.symbol || "Unknown"}
1924
+ </wui-text>
1925
+ </wui-flex>
1926
+ `;
1927
+ }
1928
+ };
1929
+ Z.styles = [yt];
1930
+ Pe([
1931
+ h()
1932
+ ], Z.prototype, "quote", void 0);
1933
+ Z = Pe([
1934
+ _("w3m-pay-fees")
1935
+ ], Z);
1936
+ const bt = U`
1937
+ :host {
1938
+ display: block;
1939
+ width: 100%;
1940
+ }
1941
+
1942
+ .disabled-container {
1943
+ padding: ${({ spacing: t }) => t[2]};
1944
+ min-height: 168px;
1945
+ }
1946
+
1947
+ wui-icon {
1948
+ width: ${({ spacing: t }) => t[8]};
1949
+ height: ${({ spacing: t }) => t[8]};
1950
+ }
1951
+
1952
+ wui-flex > wui-text {
1953
+ max-width: 273px;
1954
+ }
1955
+ `;
1956
+ var Te = function(t, e, n, s) {
1957
+ var i = arguments.length, a = i < 3 ? e : s === null ? s = Object.getOwnPropertyDescriptor(e, n) : s, o;
1958
+ if (typeof Reflect == "object" && typeof Reflect.decorate == "function") a = Reflect.decorate(t, e, n, s);
1959
+ else for (var c = t.length - 1; c >= 0; c--) (o = t[c]) && (a = (i < 3 ? o(a) : i > 3 ? o(e, n, a) : o(e, n)) || a);
1960
+ return i > 3 && a && Object.defineProperty(e, n, a), a;
1961
+ };
1962
+ let J = class extends C {
1963
+ constructor() {
1964
+ super(), this.unsubscribe = [], this.selectedExchange = u.state.selectedExchange, this.unsubscribe.push(u.subscribeKey("selectedExchange", (e) => this.selectedExchange = e));
1965
+ }
1966
+ disconnectedCallback() {
1967
+ this.unsubscribe.forEach((e) => e());
1968
+ }
1969
+ render() {
1970
+ const e = !!this.selectedExchange;
1971
+ return l`
1972
+ <wui-flex
1973
+ flexDirection="column"
1974
+ alignItems="center"
1975
+ justifyContent="center"
1976
+ gap="3"
1977
+ class="disabled-container"
1978
+ >
1979
+ <wui-icon name="coins" color="default" size="inherit"></wui-icon>
1980
+
1981
+ <wui-text variant="md-regular" color="primary" align="center">
1982
+ You don't have enough funds to complete this transaction
1983
+ </wui-text>
1984
+
1985
+ ${e ? null : l`<wui-button
1986
+ size="md"
1987
+ variant="neutral-secondary"
1988
+ @click=${this.dispatchConnectOtherWalletEvent.bind(this)}
1989
+ >Connect other wallet</wui-button
1990
+ >`}
1991
+ </wui-flex>
1992
+ `;
1993
+ }
1994
+ dispatchConnectOtherWalletEvent() {
1995
+ this.dispatchEvent(new CustomEvent("connectOtherWallet", {
1996
+ detail: !0,
1997
+ bubbles: !0,
1998
+ composed: !0
1999
+ }));
2000
+ }
2001
+ };
2002
+ J.styles = [bt];
2003
+ Te([
2004
+ x({ type: Array })
2005
+ ], J.prototype, "selectedExchange", void 0);
2006
+ J = Te([
2007
+ _("w3m-pay-options-empty")
2008
+ ], J);
2009
+ const xt = U`
2010
+ :host {
2011
+ display: block;
2012
+ width: 100%;
2013
+ }
2014
+
2015
+ .pay-options-container {
2016
+ max-height: 196px;
2017
+ overflow-y: auto;
2018
+ overflow-x: hidden;
2019
+ scrollbar-width: none;
2020
+ }
2021
+
2022
+ .pay-options-container::-webkit-scrollbar {
2023
+ display: none;
2024
+ }
2025
+
2026
+ .pay-option-container {
2027
+ border-radius: ${({ borderRadius: t }) => t[4]};
2028
+ padding: ${({ spacing: t }) => t[3]};
2029
+ min-height: 60px;
2030
+ }
2031
+
2032
+ .token-images-container {
2033
+ position: relative;
2034
+ justify-content: center;
2035
+ align-items: center;
2036
+ }
2037
+
2038
+ .chain-image {
2039
+ position: absolute;
2040
+ bottom: -3px;
2041
+ right: -5px;
2042
+ border: 2px solid ${({ tokens: t }) => t.theme.foregroundSecondary};
2043
+ }
2044
+ `;
2045
+ var At = function(t, e, n, s) {
2046
+ var i = arguments.length, a = i < 3 ? e : s === null ? s = Object.getOwnPropertyDescriptor(e, n) : s, o;
2047
+ if (typeof Reflect == "object" && typeof Reflect.decorate == "function") a = Reflect.decorate(t, e, n, s);
2048
+ else for (var c = t.length - 1; c >= 0; c--) (o = t[c]) && (a = (i < 3 ? o(a) : i > 3 ? o(e, n, a) : o(e, n)) || a);
2049
+ return i > 3 && a && Object.defineProperty(e, n, a), a;
2050
+ };
2051
+ let oe = class extends C {
2052
+ render() {
2053
+ return l`
2054
+ <wui-flex flexDirection="column" gap="2" class="pay-options-container">
2055
+ ${this.renderOptionEntry()} ${this.renderOptionEntry()} ${this.renderOptionEntry()}
2056
+ </wui-flex>
2057
+ `;
2058
+ }
2059
+ renderOptionEntry() {
2060
+ return l`
2061
+ <wui-flex
2062
+ alignItems="center"
2063
+ justifyContent="space-between"
2064
+ gap="2"
2065
+ class="pay-option-container"
2066
+ >
2067
+ <wui-flex alignItems="center" gap="2">
2068
+ <wui-flex class="token-images-container">
2069
+ <wui-shimmer
2070
+ width="32px"
2071
+ height="32px"
2072
+ rounded
2073
+ variant="light"
2074
+ class="token-image"
2075
+ ></wui-shimmer>
2076
+ <wui-shimmer
2077
+ width="16px"
2078
+ height="16px"
2079
+ rounded
2080
+ variant="light"
2081
+ class="chain-image"
2082
+ ></wui-shimmer>
2083
+ </wui-flex>
2084
+
2085
+ <wui-flex flexDirection="column" gap="1">
2086
+ <wui-shimmer
2087
+ width="74px"
2088
+ height="16px"
2089
+ borderRadius="4xs"
2090
+ variant="light"
2091
+ ></wui-shimmer>
2092
+ <wui-shimmer
2093
+ width="46px"
2094
+ height="14px"
2095
+ borderRadius="4xs"
2096
+ variant="light"
2097
+ ></wui-shimmer>
2098
+ </wui-flex>
2099
+ </wui-flex>
2100
+ </wui-flex>
2101
+ `;
2102
+ }
2103
+ };
2104
+ oe.styles = [xt];
2105
+ oe = At([
2106
+ _("w3m-pay-options-skeleton")
2107
+ ], oe);
2108
+ const Et = U`
2109
+ :host {
2110
+ display: block;
2111
+ width: 100%;
2112
+ }
2113
+
2114
+ .pay-options-container {
2115
+ max-height: 196px;
2116
+ overflow-y: auto;
2117
+ overflow-x: hidden;
2118
+ scrollbar-width: none;
2119
+ mask-image: var(--options-mask-image);
2120
+ -webkit-mask-image: var(--options-mask-image);
2121
+ }
2122
+
2123
+ .pay-options-container::-webkit-scrollbar {
2124
+ display: none;
2125
+ }
2126
+
2127
+ .pay-option-container {
2128
+ cursor: pointer;
2129
+ border-radius: ${({ borderRadius: t }) => t[4]};
2130
+ padding: ${({ spacing: t }) => t[3]};
2131
+ transition: background-color ${({ durations: t }) => t.lg}
2132
+ ${({ easings: t }) => t["ease-out-power-1"]};
2133
+ will-change: background-color;
2134
+ }
2135
+
2136
+ .token-images-container {
2137
+ position: relative;
2138
+ justify-content: center;
2139
+ align-items: center;
2140
+ }
2141
+
2142
+ .token-image {
2143
+ border-radius: ${({ borderRadius: t }) => t.round};
2144
+ width: 32px;
2145
+ height: 32px;
2146
+ }
2147
+
2148
+ .chain-image {
2149
+ position: absolute;
2150
+ width: 16px;
2151
+ height: 16px;
2152
+ bottom: -3px;
2153
+ right: -5px;
2154
+ border-radius: ${({ borderRadius: t }) => t.round};
2155
+ border: 2px solid ${({ tokens: t }) => t.theme.backgroundPrimary};
2156
+ }
2157
+
2158
+ @media (hover: hover) and (pointer: fine) {
2159
+ .pay-option-container:hover {
2160
+ background-color: ${({ tokens: t }) => t.theme.foregroundPrimary};
2161
+ }
2162
+ }
2163
+ `;
2164
+ var ee = function(t, e, n, s) {
2165
+ var i = arguments.length, a = i < 3 ? e : s === null ? s = Object.getOwnPropertyDescriptor(e, n) : s, o;
2166
+ if (typeof Reflect == "object" && typeof Reflect.decorate == "function") a = Reflect.decorate(t, e, n, s);
2167
+ else for (var c = t.length - 1; c >= 0; c--) (o = t[c]) && (a = (i < 3 ? o(a) : i > 3 ? o(e, n, a) : o(e, n)) || a);
2168
+ return i > 3 && a && Object.defineProperty(e, n, a), a;
2169
+ };
2170
+ const It = 300;
2171
+ let W = class extends C {
2172
+ constructor() {
2173
+ super(), this.unsubscribe = [], this.options = [], this.selectedPaymentAsset = null;
2174
+ }
2175
+ disconnectedCallback() {
2176
+ var n, s;
2177
+ this.unsubscribe.forEach((i) => i()), (n = this.resizeObserver) == null || n.disconnect();
2178
+ const e = (s = this.shadowRoot) == null ? void 0 : s.querySelector(".pay-options-container");
2179
+ e == null || e.removeEventListener("scroll", this.handleOptionsListScroll.bind(this));
2180
+ }
2181
+ firstUpdated() {
2182
+ var n, s;
2183
+ const e = (n = this.shadowRoot) == null ? void 0 : n.querySelector(".pay-options-container");
2184
+ e && (requestAnimationFrame(this.handleOptionsListScroll.bind(this)), e == null || e.addEventListener("scroll", this.handleOptionsListScroll.bind(this)), this.resizeObserver = new ResizeObserver(() => {
2185
+ this.handleOptionsListScroll();
2186
+ }), (s = this.resizeObserver) == null || s.observe(e), this.handleOptionsListScroll());
2187
+ }
2188
+ render() {
2189
+ return l`
2190
+ <wui-flex flexDirection="column" gap="2" class="pay-options-container">
2191
+ ${this.options.map((e) => this.payOptionTemplate(e))}
2192
+ </wui-flex>
2193
+ `;
2194
+ }
2195
+ payOptionTemplate(e) {
2196
+ var pe, he;
2197
+ const { network: n, metadata: s, asset: i, amount: a = "0" } = e, c = m.getAllRequestedCaipNetworks().find((H) => H.caipNetworkId === n), g = `${n}:${i}`, L = `${(pe = this.selectedPaymentAsset) == null ? void 0 : pe.network}:${(he = this.selectedPaymentAsset) == null ? void 0 : he.asset}`, Q = g === L, V = A.bigNumber(a, { safe: !0 }), Y = V.gt(0);
2198
+ return l`
2199
+ <wui-flex
2200
+ alignItems="center"
2201
+ justifyContent="space-between"
2202
+ gap="2"
2203
+ @click=${() => {
2204
+ var H;
2205
+ return (H = this.onSelect) == null ? void 0 : H.call(this, e);
2206
+ }}
2207
+ class="pay-option-container"
2208
+ >
2209
+ <wui-flex alignItems="center" gap="2">
2210
+ <wui-flex class="token-images-container">
2211
+ <wui-image
2212
+ src=${f(s.logoURI)}
2213
+ class="token-image"
2214
+ size="3xl"
2215
+ ></wui-image>
2216
+ <wui-image
2217
+ src=${f(T.getNetworkImage(c))}
2218
+ class="chain-image"
2219
+ size="md"
2220
+ ></wui-image>
2221
+ </wui-flex>
2222
+
2223
+ <wui-flex flexDirection="column" gap="1">
2224
+ <wui-text variant="lg-regular" color="primary">${s.symbol}</wui-text>
2225
+ ${Y ? l`<wui-text variant="sm-regular" color="secondary">
2226
+ ${V.round(6).toString()} ${s.symbol}
2227
+ </wui-text>` : null}
2228
+ </wui-flex>
2229
+ </wui-flex>
2230
+
2231
+ ${Q ? l`<wui-icon name="checkmark" size="md" color="success"></wui-icon>` : null}
2232
+ </wui-flex>
2233
+ `;
2234
+ }
2235
+ handleOptionsListScroll() {
2236
+ var s;
2237
+ const e = (s = this.shadowRoot) == null ? void 0 : s.querySelector(".pay-options-container");
2238
+ if (!e)
2239
+ return;
2240
+ e.scrollHeight > It ? (e.style.setProperty("--options-mask-image", `linear-gradient(
2241
+ to bottom,
2242
+ rgba(0, 0, 0, calc(1 - var(--options-scroll--top-opacity))) 0px,
2243
+ rgba(200, 200, 200, calc(1 - var(--options-scroll--top-opacity))) 1px,
2244
+ black 50px,
2245
+ black calc(100% - 50px),
2246
+ rgba(155, 155, 155, calc(1 - var(--options-scroll--bottom-opacity))) calc(100% - 1px),
2247
+ rgba(0, 0, 0, calc(1 - var(--options-scroll--bottom-opacity))) 100%
2248
+ )`), e.style.setProperty("--options-scroll--top-opacity", ge.interpolate([0, 50], [0, 1], e.scrollTop).toString()), e.style.setProperty("--options-scroll--bottom-opacity", ge.interpolate([0, 50], [0, 1], e.scrollHeight - e.scrollTop - e.offsetHeight).toString())) : (e.style.setProperty("--options-mask-image", "none"), e.style.setProperty("--options-scroll--top-opacity", "0"), e.style.setProperty("--options-scroll--bottom-opacity", "0"));
2249
+ }
2250
+ };
2251
+ W.styles = [Et];
2252
+ ee([
2253
+ x({ type: Array })
2254
+ ], W.prototype, "options", void 0);
2255
+ ee([
2256
+ x()
2257
+ ], W.prototype, "selectedPaymentAsset", void 0);
2258
+ ee([
2259
+ x()
2260
+ ], W.prototype, "onSelect", void 0);
2261
+ W = ee([
2262
+ _("w3m-pay-options")
2263
+ ], W);
2264
+ const Nt = U`
2265
+ .payment-methods-container {
2266
+ background-color: ${({ tokens: t }) => t.theme.foregroundPrimary};
2267
+ border-top-right-radius: ${({ borderRadius: t }) => t[5]};
2268
+ border-top-left-radius: ${({ borderRadius: t }) => t[5]};
2269
+ }
2270
+
2271
+ .pay-options-container {
2272
+ background-color: ${({ tokens: t }) => t.theme.foregroundSecondary};
2273
+ border-radius: ${({ borderRadius: t }) => t[5]};
2274
+ padding: ${({ spacing: t }) => t[1]};
2275
+ }
2276
+
2277
+ w3m-tooltip-trigger {
2278
+ display: flex;
2279
+ align-items: center;
2280
+ justify-content: center;
2281
+ max-width: fit-content;
2282
+ }
2283
+
2284
+ wui-image {
2285
+ border-radius: ${({ borderRadius: t }) => t.round};
2286
+ }
2287
+
2288
+ w3m-pay-options.disabled {
2289
+ opacity: 0.5;
2290
+ pointer-events: none;
2291
+ }
2292
+ `;
2293
+ var b = function(t, e, n, s) {
2294
+ var i = arguments.length, a = i < 3 ? e : s === null ? s = Object.getOwnPropertyDescriptor(e, n) : s, o;
2295
+ if (typeof Reflect == "object" && typeof Reflect.decorate == "function") a = Reflect.decorate(t, e, n, s);
2296
+ else for (var c = t.length - 1; c >= 0; c--) (o = t[c]) && (a = (i < 3 ? o(a) : i > 3 ? o(e, n, a) : o(e, n)) || a);
2297
+ return i > 3 && a && Object.defineProperty(e, n, a), a;
2298
+ };
2299
+ const K = {
2300
+ eip155: "ethereum",
2301
+ solana: "solana",
2302
+ bip122: "bitcoin",
2303
+ ton: "ton"
2304
+ }, Pt = {
2305
+ eip155: { icon: K.eip155, label: "EVM" },
2306
+ solana: { icon: K.solana, label: "Solana" },
2307
+ bip122: { icon: K.bip122, label: "Bitcoin" },
2308
+ ton: { icon: K.ton, label: "Ton" }
2309
+ };
2310
+ let w = class extends C {
2311
+ constructor() {
2312
+ super(), this.unsubscribe = [], this.profileName = null, this.paymentAsset = u.state.paymentAsset, this.namespace = void 0, this.caipAddress = void 0, this.amount = u.state.amount, this.recipient = u.state.recipient, this.activeConnectorIds = P.state.activeConnectorIds, this.selectedPaymentAsset = u.state.selectedPaymentAsset, this.selectedExchange = u.state.selectedExchange, this.isFetchingQuote = u.state.isFetchingQuote, this.quoteError = u.state.quoteError, this.quote = u.state.quote, this.isFetchingTokenBalances = u.state.isFetchingTokenBalances, this.tokenBalances = u.state.tokenBalances, this.isPaymentInProgress = u.state.isPaymentInProgress, this.exchangeUrlForQuote = u.state.exchangeUrlForQuote, this.completedTransactionsCount = 0, this.unsubscribe.push(u.subscribeKey("paymentAsset", (e) => this.paymentAsset = e)), this.unsubscribe.push(u.subscribeKey("tokenBalances", (e) => this.onTokenBalancesChanged(e))), this.unsubscribe.push(u.subscribeKey("isFetchingTokenBalances", (e) => this.isFetchingTokenBalances = e)), this.unsubscribe.push(P.subscribeKey("activeConnectorIds", (e) => this.activeConnectorIds = e)), this.unsubscribe.push(u.subscribeKey("selectedPaymentAsset", (e) => this.selectedPaymentAsset = e)), this.unsubscribe.push(u.subscribeKey("isFetchingQuote", (e) => this.isFetchingQuote = e)), this.unsubscribe.push(u.subscribeKey("quoteError", (e) => this.quoteError = e)), this.unsubscribe.push(u.subscribeKey("quote", (e) => this.quote = e)), this.unsubscribe.push(u.subscribeKey("amount", (e) => this.amount = e)), this.unsubscribe.push(u.subscribeKey("recipient", (e) => this.recipient = e)), this.unsubscribe.push(u.subscribeKey("isPaymentInProgress", (e) => this.isPaymentInProgress = e)), this.unsubscribe.push(u.subscribeKey("selectedExchange", (e) => this.selectedExchange = e)), this.unsubscribe.push(u.subscribeKey("exchangeUrlForQuote", (e) => this.exchangeUrlForQuote = e)), this.resetQuoteState(), this.initializeNamespace(), this.fetchTokens();
2313
+ }
2314
+ disconnectedCallback() {
2315
+ super.disconnectedCallback(), this.resetAssetsState(), this.unsubscribe.forEach((e) => e());
2316
+ }
2317
+ updated(e) {
2318
+ super.updated(e), e.has("selectedPaymentAsset") && this.fetchQuote();
2319
+ }
2320
+ render() {
2321
+ return l`
2322
+ <wui-flex flexDirection="column">
2323
+ ${this.profileTemplate()}
2324
+
2325
+ <wui-flex
2326
+ flexDirection="column"
2327
+ gap="4"
2328
+ class="payment-methods-container"
2329
+ .padding=${["4", "4", "5", "4"]}
2330
+ >
2331
+ ${this.paymentOptionsViewTemplate()} ${this.amountWithFeeTemplate()}
2332
+
2333
+ <wui-flex
2334
+ alignItems="center"
2335
+ justifyContent="space-between"
2336
+ .padding=${["1", "0", "1", "0"]}
2337
+ >
2338
+ <wui-separator></wui-separator>
2339
+ </wui-flex>
2340
+
2341
+ ${this.paymentActionsTemplate()}
2342
+ </wui-flex>
2343
+ </wui-flex>
2344
+ `;
2345
+ }
2346
+ profileTemplate() {
2347
+ var o, c;
2348
+ if (this.selectedExchange) {
2349
+ const g = A.formatNumber((o = this.quote) == null ? void 0 : o.origin.amount, {
2350
+ decimals: ((c = this.quote) == null ? void 0 : c.origin.currency.metadata.decimals) ?? 0
2351
+ }).toString();
2352
+ return l`
2353
+ <wui-flex
2354
+ .padding=${["4", "3", "4", "3"]}
2355
+ alignItems="center"
2356
+ justifyContent="space-between"
2357
+ gap="2"
2358
+ >
2359
+ <wui-text variant="lg-regular" color="secondary">Paying with</wui-text>
2360
+
2361
+ ${this.quote ? l`<wui-text variant="lg-regular" color="primary">
2362
+ ${A.bigNumber(g, { safe: !0 }).round(6).toString()}
2363
+ ${this.quote.origin.currency.metadata.symbol}
2364
+ </wui-text>` : l`<wui-shimmer width="80px" height="18px" variant="light"></wui-shimmer>`}
2365
+ </wui-flex>
2366
+ `;
2367
+ }
2368
+ const e = O.getPlainAddress(this.caipAddress) ?? "", { name: n, image: s } = this.getWalletProperties({ namespace: this.namespace }), { icon: i, label: a } = Pt[this.namespace] ?? {};
2369
+ return l`
2370
+ <wui-flex
2371
+ .padding=${["4", "3", "4", "3"]}
2372
+ alignItems="center"
2373
+ justifyContent="space-between"
2374
+ gap="2"
2375
+ >
2376
+ <wui-wallet-switch
2377
+ profileName=${f(this.profileName)}
2378
+ address=${f(e)}
2379
+ imageSrc=${f(s)}
2380
+ alt=${f(n)}
2381
+ @click=${this.onConnectOtherWallet.bind(this)}
2382
+ data-testid="wui-wallet-switch"
2383
+ ></wui-wallet-switch>
2384
+
2385
+ <wui-wallet-switch
2386
+ profileName=${f(a)}
2387
+ address=${f(e)}
2388
+ icon=${f(i)}
2389
+ iconSize="xs"
2390
+ .enableGreenCircle=${!1}
2391
+ alt=${f(a)}
2392
+ @click=${this.onConnectOtherWallet.bind(this)}
2393
+ data-testid="wui-wallet-switch"
2394
+ ></wui-wallet-switch>
2395
+ </wui-flex>
2396
+ `;
2397
+ }
2398
+ initializeNamespace() {
2399
+ var n, s;
2400
+ const e = m.state.activeChain;
2401
+ this.namespace = e, this.caipAddress = (n = m.getAccountData(e)) == null ? void 0 : n.caipAddress, this.profileName = ((s = m.getAccountData(e)) == null ? void 0 : s.profileName) ?? null, this.unsubscribe.push(m.subscribeChainProp("accountState", (i) => this.onAccountStateChanged(i), e));
2402
+ }
2403
+ async fetchTokens() {
2404
+ if (this.namespace) {
2405
+ let e;
2406
+ if (this.caipAddress) {
2407
+ const { chainId: n, chainNamespace: s } = y.parseCaipAddress(this.caipAddress), i = `${s}:${n}`;
2408
+ e = m.getAllRequestedCaipNetworks().find((o) => o.caipNetworkId === i);
2409
+ }
2410
+ await u.fetchTokens({
2411
+ caipAddress: this.caipAddress,
2412
+ caipNetwork: e,
2413
+ namespace: this.namespace
2414
+ });
2415
+ }
2416
+ }
2417
+ fetchQuote() {
2418
+ if (this.amount && this.recipient && this.selectedPaymentAsset && this.paymentAsset) {
2419
+ const { address: e } = this.caipAddress ? y.parseCaipAddress(this.caipAddress) : {};
2420
+ u.fetchQuote({
2421
+ amount: this.amount.toString(),
2422
+ address: e,
2423
+ sourceToken: this.selectedPaymentAsset,
2424
+ toToken: this.paymentAsset,
2425
+ recipient: this.recipient
2426
+ });
2427
+ }
2428
+ }
2429
+ getWalletProperties({ namespace: e }) {
2430
+ if (!e)
2431
+ return {
2432
+ name: void 0,
2433
+ image: void 0
2434
+ };
2435
+ const n = this.activeConnectorIds[e];
2436
+ if (!n)
2437
+ return {
2438
+ name: void 0,
2439
+ image: void 0
2440
+ };
2441
+ const s = P.getConnector({ id: n, namespace: e });
2442
+ if (!s)
2443
+ return {
2444
+ name: void 0,
2445
+ image: void 0
2446
+ };
2447
+ const i = T.getConnectorImage(s);
2448
+ return {
2449
+ name: s.name,
2450
+ image: i
2451
+ };
2452
+ }
2453
+ paymentOptionsViewTemplate() {
2454
+ return l`
2455
+ <wui-flex flexDirection="column" gap="2">
2456
+ <wui-text variant="sm-regular" color="secondary">CHOOSE PAYMENT OPTION</wui-text>
2457
+ <wui-flex class="pay-options-container">${this.paymentOptionsTemplate()}</wui-flex>
2458
+ </wui-flex>
2459
+ `;
2460
+ }
2461
+ paymentOptionsTemplate() {
2462
+ const e = this.getPaymentAssetFromTokenBalances();
2463
+ if (this.isFetchingTokenBalances)
2464
+ return l`<w3m-pay-options-skeleton></w3m-pay-options-skeleton>`;
2465
+ if (e.length === 0)
2466
+ return l`<w3m-pay-options-empty
2467
+ @connectOtherWallet=${this.onConnectOtherWallet.bind(this)}
2468
+ ></w3m-pay-options-empty>`;
2469
+ const n = {
2470
+ disabled: this.isFetchingQuote
2471
+ };
2472
+ return l`<w3m-pay-options
2473
+ class=${Ne(n)}
2474
+ .options=${e}
2475
+ .selectedPaymentAsset=${f(this.selectedPaymentAsset)}
2476
+ .onSelect=${this.onSelectedPaymentAssetChanged.bind(this)}
2477
+ ></w3m-pay-options>`;
2478
+ }
2479
+ amountWithFeeTemplate() {
2480
+ return this.isFetchingQuote || !this.selectedPaymentAsset || this.quoteError ? l`<w3m-pay-fees-skeleton></w3m-pay-fees-skeleton>` : l`<w3m-pay-fees></w3m-pay-fees>`;
2481
+ }
2482
+ paymentActionsTemplate() {
2483
+ var i, a, o;
2484
+ const e = this.isFetchingQuote || this.isFetchingTokenBalances, n = this.isFetchingQuote || this.isFetchingTokenBalances || !this.selectedPaymentAsset || !!this.quoteError, s = A.formatNumber(((i = this.quote) == null ? void 0 : i.origin.amount) ?? 0, {
2485
+ decimals: ((a = this.quote) == null ? void 0 : a.origin.currency.metadata.decimals) ?? 0
2486
+ }).toString();
2487
+ return this.selectedExchange ? e || n ? l`
2488
+ <wui-shimmer width="100%" height="48px" variant="light" ?rounded=${!0}></wui-shimmer>
2489
+ ` : l`<wui-button
2490
+ size="lg"
2491
+ fullWidth
2492
+ variant="accent-secondary"
2493
+ @click=${this.onPayWithExchange.bind(this)}
2494
+ >
2495
+ ${`Continue in ${this.selectedExchange.name}`}
2496
+
2497
+ <wui-icon name="arrowRight" color="inherit" size="sm" slot="iconRight"></wui-icon>
2498
+ </wui-button>` : l`
2499
+ <wui-flex alignItems="center" justifyContent="space-between">
2500
+ <wui-flex flexDirection="column" gap="1">
2501
+ <wui-text variant="md-regular" color="secondary">Order Total</wui-text>
2502
+
2503
+ ${e || n ? l`<wui-shimmer width="58px" height="32px" variant="light"></wui-shimmer>` : l`<wui-flex alignItems="center" gap="01">
2504
+ <wui-text variant="h4-regular" color="primary">${X(s)}</wui-text>
2505
+
2506
+ <wui-text variant="lg-regular" color="secondary">
2507
+ ${((o = this.quote) == null ? void 0 : o.origin.currency.metadata.symbol) || "Unknown"}
2508
+ </wui-text>
2509
+ </wui-flex>`}
2510
+ </wui-flex>
2511
+
2512
+ ${this.actionButtonTemplate({ isLoading: e, isDisabled: n })}
2513
+ </wui-flex>
2514
+ `;
2515
+ }
2516
+ actionButtonTemplate(e) {
2517
+ const n = te(this.quote), { isLoading: s, isDisabled: i } = e;
2518
+ let a = "Pay";
2519
+ return n.length > 1 && this.completedTransactionsCount === 0 && (a = "Approve"), l`
2520
+ <wui-button
2521
+ size="lg"
2522
+ variant="accent-primary"
2523
+ ?loading=${s || this.isPaymentInProgress}
2524
+ ?disabled=${i || this.isPaymentInProgress}
2525
+ @click=${() => {
2526
+ n.length > 0 ? this.onSendTransactions() : this.onTransfer();
2527
+ }}
2528
+ >
2529
+ ${a}
2530
+ ${s ? null : l`<wui-icon
2531
+ name="arrowRight"
2532
+ color="inherit"
2533
+ size="sm"
2534
+ slot="iconRight"
2535
+ ></wui-icon>`}
2536
+ </wui-button>
2537
+ `;
2538
+ }
2539
+ getPaymentAssetFromTokenBalances() {
2540
+ return this.namespace ? (this.tokenBalances[this.namespace] ?? []).map((i) => {
2541
+ try {
2542
+ return tt(i);
2543
+ } catch {
2544
+ return null;
2545
+ }
2546
+ }).filter((i) => !!i).filter((i) => {
2547
+ const { chainId: a } = y.parseCaipNetworkId(i.network), { chainId: o } = y.parseCaipNetworkId(this.paymentAsset.network);
2548
+ return N.isLowerCaseMatch(i.asset, this.paymentAsset.asset) ? !0 : this.selectedExchange ? !N.isLowerCaseMatch(a.toString(), o.toString()) : !0;
2549
+ }) : [];
2550
+ }
2551
+ onTokenBalancesChanged(e) {
2552
+ this.tokenBalances = e;
2553
+ const [n] = this.getPaymentAssetFromTokenBalances();
2554
+ n && u.setSelectedPaymentAsset(n);
2555
+ }
2556
+ async onConnectOtherWallet() {
2557
+ await P.connect(), await G.open({ view: "PayQuote" });
2558
+ }
2559
+ onAccountStateChanged(e) {
2560
+ const { address: n } = this.caipAddress ? y.parseCaipAddress(this.caipAddress) : {};
2561
+ if (this.caipAddress = e == null ? void 0 : e.caipAddress, this.profileName = (e == null ? void 0 : e.profileName) ?? null, n) {
2562
+ const { address: s } = this.caipAddress ? y.parseCaipAddress(this.caipAddress) : {};
2563
+ s ? N.isLowerCaseMatch(s, n) || (this.resetAssetsState(), this.resetQuoteState(), this.fetchTokens()) : G.close();
2564
+ }
2565
+ }
2566
+ onSelectedPaymentAssetChanged(e) {
2567
+ this.isFetchingQuote || u.setSelectedPaymentAsset(e);
2568
+ }
2569
+ async onTransfer() {
2570
+ var n, s, i;
2571
+ const e = ie(this.quote);
2572
+ if (e) {
2573
+ if (!N.isLowerCaseMatch((n = this.selectedPaymentAsset) == null ? void 0 : n.asset, e.deposit.currency))
2574
+ throw new Error("Quote asset is not the same as the selected payment asset");
2575
+ const o = ((s = this.selectedPaymentAsset) == null ? void 0 : s.amount) ?? "0", c = A.formatNumber(e.deposit.amount, {
2576
+ decimals: ((i = this.selectedPaymentAsset) == null ? void 0 : i.metadata.decimals) ?? 0
2577
+ }).toString();
2578
+ if (!A.bigNumber(o).gte(c)) {
2579
+ R.showError("Insufficient funds");
2580
+ return;
2581
+ }
2582
+ if (this.quote && this.selectedPaymentAsset && this.caipAddress && this.namespace) {
2583
+ const { address: L } = y.parseCaipAddress(this.caipAddress);
2584
+ await u.onTransfer({
2585
+ chainNamespace: this.namespace,
2586
+ fromAddress: L,
2587
+ toAddress: e.deposit.receiver,
2588
+ amount: c,
2589
+ paymentAsset: this.selectedPaymentAsset
2590
+ }), u.setRequestId(e.requestId), z.push("PayLoading");
2591
+ }
2592
+ }
2593
+ }
2594
+ async onSendTransactions() {
2595
+ var o, c, g;
2596
+ const e = ((o = this.selectedPaymentAsset) == null ? void 0 : o.amount) ?? "0", n = A.formatNumber(((c = this.quote) == null ? void 0 : c.origin.amount) ?? 0, {
2597
+ decimals: ((g = this.selectedPaymentAsset) == null ? void 0 : g.metadata.decimals) ?? 0
2598
+ }).toString();
2599
+ if (!A.bigNumber(e).gte(n)) {
2600
+ R.showError("Insufficient funds");
2601
+ return;
2602
+ }
2603
+ const i = te(this.quote), [a] = te(this.quote, this.completedTransactionsCount);
2604
+ a && this.namespace && (await u.onSendTransaction({
2605
+ namespace: this.namespace,
2606
+ transactionStep: a
2607
+ }), this.completedTransactionsCount += 1, this.completedTransactionsCount === i.length && (u.setRequestId(a.requestId), z.push("PayLoading")));
2608
+ }
2609
+ onPayWithExchange() {
2610
+ if (this.exchangeUrlForQuote) {
2611
+ const e = O.returnOpenHref("", "popupWindow", "scrollbar=yes,width=480,height=720");
2612
+ if (!e)
2613
+ throw new Error("Could not create popup window");
2614
+ e.location.href = this.exchangeUrlForQuote;
2615
+ const n = ie(this.quote);
2616
+ n && u.setRequestId(n.requestId), u.initiatePayment(), z.push("PayLoading");
2617
+ }
2618
+ }
2619
+ resetAssetsState() {
2620
+ u.setSelectedPaymentAsset(null);
2621
+ }
2622
+ resetQuoteState() {
2623
+ u.resetQuoteState();
2624
+ }
2625
+ };
2626
+ w.styles = Nt;
2627
+ b([
2628
+ h()
2629
+ ], w.prototype, "profileName", void 0);
2630
+ b([
2631
+ h()
2632
+ ], w.prototype, "paymentAsset", void 0);
2633
+ b([
2634
+ h()
2635
+ ], w.prototype, "namespace", void 0);
2636
+ b([
2637
+ h()
2638
+ ], w.prototype, "caipAddress", void 0);
2639
+ b([
2640
+ h()
2641
+ ], w.prototype, "amount", void 0);
2642
+ b([
2643
+ h()
2644
+ ], w.prototype, "recipient", void 0);
2645
+ b([
2646
+ h()
2647
+ ], w.prototype, "activeConnectorIds", void 0);
2648
+ b([
2649
+ h()
2650
+ ], w.prototype, "selectedPaymentAsset", void 0);
2651
+ b([
2652
+ h()
2653
+ ], w.prototype, "selectedExchange", void 0);
2654
+ b([
2655
+ h()
2656
+ ], w.prototype, "isFetchingQuote", void 0);
2657
+ b([
2658
+ h()
2659
+ ], w.prototype, "quoteError", void 0);
2660
+ b([
2661
+ h()
2662
+ ], w.prototype, "quote", void 0);
2663
+ b([
2664
+ h()
2665
+ ], w.prototype, "isFetchingTokenBalances", void 0);
2666
+ b([
2667
+ h()
2668
+ ], w.prototype, "tokenBalances", void 0);
2669
+ b([
2670
+ h()
2671
+ ], w.prototype, "isPaymentInProgress", void 0);
2672
+ b([
2673
+ h()
2674
+ ], w.prototype, "exchangeUrlForQuote", void 0);
2675
+ b([
2676
+ h()
2677
+ ], w.prototype, "completedTransactionsCount", void 0);
2678
+ w = b([
2679
+ _("w3m-pay-quote-view")
2680
+ ], w);
2681
+ export {
2682
+ p as A,
2683
+ u as P,
2684
+ E as W,
2685
+ d as a,
2686
+ w as b,
2687
+ k as c
2688
+ };