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