@cedros/pay-react 1.1.16 → 1.1.18

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 (149) hide show
  1. package/dist/AISettingsSection-C-thWh51.js +51 -0
  2. package/dist/AISettingsSection-CD9IRyR1.mjs +539 -0
  3. package/dist/AutosaveIndicator-DxemlKnX.js +1 -0
  4. package/dist/AutosaveIndicator-G2CRN8hH.mjs +35 -0
  5. package/dist/{CedrosContext-D7nh5-Zh.mjs → CedrosContext-BnJ2Cf7R.mjs} +1179 -642
  6. package/dist/CedrosContext-C26DlvLF.js +6 -0
  7. package/dist/CryptoButton-BdOtL7w-.mjs +542 -0
  8. package/dist/CryptoButton-N8kRfNDO.js +1 -0
  9. package/dist/FAQSection-CyYK9OAN.mjs +366 -0
  10. package/dist/FAQSection-_pm1ekTe.js +1 -0
  11. package/dist/MessagingSection-BHzf1Mhu.js +1 -0
  12. package/dist/MessagingSection-DO2yPTvs.mjs +347 -0
  13. package/dist/PaymentSettingsSection--Aqlne1F.mjs +94 -0
  14. package/dist/PaymentSettingsSection-DpENgoca.js +1 -0
  15. package/dist/SettingsSection-CGKKGXWz.mjs +57 -0
  16. package/dist/SettingsSection-DNoODw7i.js +1 -0
  17. package/dist/SingleCategorySettings-8DCtLcow.mjs +1421 -0
  18. package/dist/SingleCategorySettings-NLBYxM0O.js +3 -0
  19. package/dist/StorefrontSection-BEOMtSAg.js +1 -0
  20. package/dist/StorefrontSection-Mzr1H51w.mjs +765 -0
  21. package/dist/SubscriptionsSection-4b29i-41.js +1 -0
  22. package/dist/SubscriptionsSection-Dy1e15fe.mjs +616 -0
  23. package/dist/Toggle-CsPSF8Dr.js +1 -0
  24. package/dist/Toggle-DAxIdpY4.mjs +48 -0
  25. package/dist/WalletManager-D6BYTwXn.js +1 -0
  26. package/dist/{WalletManager-oEjZhaFk.mjs → WalletManager-HXXyARQ7.mjs} +36 -32
  27. package/dist/components/CedrosPay.d.ts.map +1 -1
  28. package/dist/components/CryptoSubscribeButton.d.ts.map +1 -1
  29. package/dist/components/PaymentModal.d.ts.map +1 -1
  30. package/dist/components/SubscriptionManagementPanel.d.ts.map +1 -1
  31. package/dist/components/admin/AISettingsSection.d.ts.map +1 -1
  32. package/dist/components/admin/AdminAuthManager.d.ts +2 -1
  33. package/dist/components/admin/AdminAuthManager.d.ts.map +1 -1
  34. package/dist/components/admin/AutosaveIndicator.d.ts +7 -0
  35. package/dist/components/admin/AutosaveIndicator.d.ts.map +1 -0
  36. package/dist/components/admin/CedrosPayAdminDashboard.d.ts.map +1 -1
  37. package/dist/components/admin/ConfigEditor.d.ts +0 -2
  38. package/dist/components/admin/ConfigEditor.d.ts.map +1 -1
  39. package/dist/components/admin/MessagingSection.d.ts.map +1 -1
  40. package/dist/components/admin/ProductsSection.d.ts.map +1 -1
  41. package/dist/components/admin/RefundsSection.d.ts.map +1 -1
  42. package/dist/components/admin/SecretArrayEditor.d.ts +16 -0
  43. package/dist/components/admin/SecretArrayEditor.d.ts.map +1 -0
  44. package/dist/components/admin/SingleCategorySettings.d.ts.map +1 -1
  45. package/dist/components/admin/StorefrontSection.d.ts.map +1 -1
  46. package/dist/components/admin/Toggle.d.ts +14 -0
  47. package/dist/components/admin/Toggle.d.ts.map +1 -0
  48. package/dist/components/admin/TokenMintSelector.d.ts +27 -0
  49. package/dist/components/admin/TokenMintSelector.d.ts.map +1 -0
  50. package/dist/components/admin/configApi.d.ts +5 -3
  51. package/dist/components/admin/configApi.d.ts.map +1 -1
  52. package/dist/components/admin/index.d.ts +8 -9
  53. package/dist/components/admin/index.d.ts.map +1 -1
  54. package/dist/components/admin/sections-more.d.ts +2 -9
  55. package/dist/components/admin/sections-more.d.ts.map +1 -1
  56. package/dist/context/CedrosContext.d.ts +1 -1
  57. package/dist/context/CedrosContext.d.ts.map +1 -1
  58. package/dist/crypto-only.js +1 -1
  59. package/dist/crypto-only.mjs +391 -380
  60. package/dist/ecommerce/__tests__/inventoryHooks.test.d.ts +2 -0
  61. package/dist/ecommerce/__tests__/inventoryHooks.test.d.ts.map +1 -0
  62. package/dist/ecommerce/__tests__/storage.test.d.ts +2 -0
  63. package/dist/ecommerce/__tests__/storage.test.d.ts.map +1 -0
  64. package/dist/ecommerce/adapters/CommerceAdapter.d.ts +5 -0
  65. package/dist/ecommerce/adapters/CommerceAdapter.d.ts.map +1 -1
  66. package/dist/ecommerce/adapters/mock/mockAdapter.d.ts.map +1 -1
  67. package/dist/ecommerce/adapters/paywall/paywallAdapter.d.ts.map +1 -1
  68. package/dist/ecommerce/adapters/paywall/paywallAdapter.test.d.ts +2 -0
  69. package/dist/ecommerce/adapters/paywall/paywallAdapter.test.d.ts.map +1 -0
  70. package/dist/ecommerce/components/catalog/ProductCard.d.ts.map +1 -1
  71. package/dist/ecommerce/components/catalog/QuickViewDialog.d.ts.map +1 -1
  72. package/dist/ecommerce/components/chat/ShopChatPanel.d.ts +4 -0
  73. package/dist/ecommerce/components/chat/ShopChatPanel.d.ts.map +1 -1
  74. package/dist/ecommerce/components/checkout/PaymentStep.d.ts.map +1 -1
  75. package/dist/ecommerce/components/faq/FAQItem.d.ts.map +1 -1
  76. package/dist/ecommerce/config/context.d.ts.map +1 -1
  77. package/dist/ecommerce/hooks/useAIRelatedProducts.d.ts.map +1 -1
  78. package/dist/ecommerce/hooks/useCartInventory.d.ts.map +1 -1
  79. package/dist/ecommerce/hooks/useHoldExpiry.d.ts.map +1 -1
  80. package/dist/ecommerce/hooks/useInventoryVerification.d.ts.map +1 -1
  81. package/dist/ecommerce/hooks/useProducts.d.ts.map +1 -1
  82. package/dist/ecommerce/index.d.ts +2 -0
  83. package/dist/ecommerce/index.d.ts.map +1 -1
  84. package/dist/ecommerce/integrations/cedros-pay/useCedrosPayCheckoutAdapter.d.ts.map +1 -1
  85. package/dist/ecommerce/state/cart/CartProvider.d.ts.map +1 -1
  86. package/dist/ecommerce/state/checkout/checkoutSchema.d.ts +1 -1
  87. package/dist/ecommerce/state/checkout/useCheckout.d.ts.map +1 -1
  88. package/dist/ecommerce/templates/ProductTemplate.d.ts.map +1 -1
  89. package/dist/ecommerce/utils/storage.d.ts +1 -1
  90. package/dist/ecommerce/utils/storage.d.ts.map +1 -1
  91. package/dist/hooks/useCreditsPayment.d.ts.map +1 -1
  92. package/dist/hooks/useCreditsSubscription.d.ts.map +1 -1
  93. package/dist/hooks/useCryptoSubscription.d.ts.map +1 -1
  94. package/dist/hooks/useRefundVerification.d.ts.map +1 -1
  95. package/dist/hooks/useStripeCheckout.d.ts +1 -1
  96. package/dist/hooks/useStripeCheckout.d.ts.map +1 -1
  97. package/dist/hooks/useSubscription.d.ts.map +1 -1
  98. package/dist/hooks/useSubscriptionManagement.d.ts.map +1 -1
  99. package/dist/hooks/useX402Payment.d.ts.map +1 -1
  100. package/dist/index-B-0trqeD.js +84 -0
  101. package/dist/index-bbSf3B7-.mjs +22915 -0
  102. package/dist/index.js +1 -1
  103. package/dist/index.mjs +67 -72
  104. package/dist/managers/CreditsManager.d.ts +6 -0
  105. package/dist/managers/CreditsManager.d.ts.map +1 -1
  106. package/dist/managers/ManagerCache.d.ts.map +1 -1
  107. package/dist/managers/RouteDiscoveryManager.d.ts +3 -0
  108. package/dist/managers/RouteDiscoveryManager.d.ts.map +1 -1
  109. package/dist/managers/StripeManager.d.ts +15 -0
  110. package/dist/managers/StripeManager.d.ts.map +1 -1
  111. package/dist/managers/SubscriptionChangeManager.d.ts.map +1 -1
  112. package/dist/managers/SubscriptionManager.d.ts +7 -14
  113. package/dist/managers/SubscriptionManager.d.ts.map +1 -1
  114. package/dist/managers/WalletManager.d.ts +2 -1
  115. package/dist/managers/WalletManager.d.ts.map +1 -1
  116. package/dist/managers/X402Manager.d.ts.map +1 -1
  117. package/dist/{sections-CL3lbNui.js → sections-CKwGmrzV.js} +1 -1
  118. package/dist/{sections-DnmB0qdx.mjs → sections-DpEdFL1B.mjs} +1 -1
  119. package/dist/stripe-only.js +1 -1
  120. package/dist/stripe-only.mjs +67 -72
  121. package/dist/telemetry.js +1 -1
  122. package/dist/telemetry.mjs +23 -25
  123. package/dist/testing/index.js +1 -1
  124. package/dist/testing/index.mjs +1 -1
  125. package/dist/types/index.d.ts +13 -2
  126. package/dist/types/index.d.ts.map +1 -1
  127. package/dist/useAutosave-B2p6iwh8.js +1 -0
  128. package/dist/useAutosave-YwMqRzqy.mjs +44 -0
  129. package/dist/utils/circuitBreaker.d.ts +3 -1
  130. package/dist/utils/circuitBreaker.d.ts.map +1 -1
  131. package/dist/utils/cspHelper.d.ts +6 -0
  132. package/dist/utils/cspHelper.d.ts.map +1 -1
  133. package/dist/utils/csvHelpers.d.ts +0 -41
  134. package/dist/utils/csvHelpers.d.ts.map +1 -1
  135. package/dist/utils/errorHandling.d.ts.map +1 -1
  136. package/dist/utils/exponentialBackoff.d.ts.map +1 -1
  137. package/dist/utils/requestDeduplication.d.ts.map +1 -1
  138. package/dist/utils/telemetry.d.ts.map +1 -1
  139. package/dist/utils/validateConfig.d.ts +1 -1
  140. package/dist/utils/validateConfig.d.ts.map +1 -1
  141. package/dist/walletDetection-JZR3UCOa.mjs +27 -0
  142. package/dist/walletDetection-bNmV5ItZ.js +1 -0
  143. package/dist/{walletPool-BR6etEiq.mjs → walletPool-BV_z1lEA.mjs} +1 -1
  144. package/dist/{walletPool-BZyAG4YS.js → walletPool-DjA7J3a9.js} +1 -1
  145. package/package.json +8 -7
  146. package/dist/CedrosContext-C2v_s8cc.js +0 -6
  147. package/dist/WalletManager-B5KLZK2D.js +0 -1
  148. package/dist/index-BU0vgA-7.js +0 -136
  149. package/dist/index-DWXEBUbu.mjs +0 -27912
@@ -0,0 +1,542 @@
1
+ import { jsxs as G, jsx as h } from "react/jsx-runtime";
2
+ import { useState as L, useRef as R, useCallback as P, useMemo as Y, useEffect as H } from "react";
3
+ import { useWallet as be } from "@solana/wallet-adapter-react";
4
+ import { WalletReadyState as pe } from "@solana/wallet-adapter-base";
5
+ import { WalletIcon as Te } from "@solana/wallet-adapter-react-ui";
6
+ import { u as he, m as Z, i as n, a as Ie } from "./CedrosContext-BnJ2Cf7R.mjs";
7
+ import { a3 as Ee, k as We, T as Re, a4 as J, E as _e, F as fe, A as qe, D as ge, y as ze, z as we, B as ee, a5 as Me, a6 as De } from "./index-bbSf3B7-.mjs";
8
+ function Fe() {
9
+ const { x402Manager: g, walletManager: s } = he(), { publicKey: _, signTransaction: q } = be(), [X, d] = L({
10
+ status: "idle",
11
+ error: null,
12
+ transactionId: null
13
+ }), [I, k] = L(null), [O, x] = L(null), C = R(_);
14
+ C.current = _;
15
+ const w = R(q);
16
+ w.current = q;
17
+ const u = R(0), K = 6e4, E = () => {
18
+ const o = u.current;
19
+ return o > 0 && Date.now() - o < K;
20
+ }, v = P(() => {
21
+ if (!_) {
22
+ const o = "Wallet not connected";
23
+ return d({ status: "error", error: o, transactionId: null }), { valid: !1, error: o };
24
+ }
25
+ if (!q) {
26
+ const o = "Wallet does not support signing";
27
+ return d({ status: "error", error: o, transactionId: null }), { valid: !1, error: o };
28
+ }
29
+ return { valid: !0 };
30
+ }, [_, q]), z = P(
31
+ async (o) => {
32
+ try {
33
+ d((i) => ({ ...i, status: "loading" }));
34
+ const l = await g.requestQuote({ resource: o });
35
+ if (!g.validateRequirement(l))
36
+ throw new Error("Invalid requirement received from server");
37
+ return k(l), d((i) => ({ ...i, status: "idle" })), l;
38
+ } catch (l) {
39
+ const i = Z(l, "Failed to fetch requirement");
40
+ throw d({
41
+ status: "error",
42
+ error: i,
43
+ transactionId: null
44
+ }), l;
45
+ }
46
+ },
47
+ [g]
48
+ ), B = P(
49
+ async (o, l, i, b, r = "regular") => {
50
+ const a = C.current, y = w.current;
51
+ if (!a || !y)
52
+ throw new Error("Wallet disconnected during payment flow");
53
+ if (!!o.extra?.feePayer) {
54
+ n().debug("[useX402Payment] Gasless flow enabled"), n().debug("[useX402Payment] Building gasless transaction");
55
+ const { transaction: f, blockhash: D } = await g.buildGaslessTransaction({
56
+ resourceId: l,
57
+ userWallet: a.toString(),
58
+ feePayer: o.extra.feePayer,
59
+ couponCode: i
60
+ });
61
+ n().debug("[useX402Payment] Deserializing backend transaction");
62
+ const A = s.deserializeTransaction(f);
63
+ if (C.current?.toString() !== a.toString())
64
+ throw new Error("Wallet changed during payment flow");
65
+ n().debug("[useX402Payment] Requesting partial signature");
66
+ const T = await s.partiallySignTransaction({
67
+ transaction: A,
68
+ signTransaction: y,
69
+ blockhash: D
70
+ });
71
+ n().debug("[useX402Payment] Submitting partial transaction");
72
+ const F = await g.submitGaslessTransaction({
73
+ resource: l,
74
+ partialTx: T,
75
+ couponCode: i,
76
+ metadata: b,
77
+ resourceType: r,
78
+ requirement: o
79
+ });
80
+ return F.success && F.settlement && x(F.settlement), F;
81
+ } else {
82
+ const f = await s.buildTransaction({
83
+ requirement: o,
84
+ payerPublicKey: a
85
+ });
86
+ if (C.current?.toString() !== a.toString())
87
+ throw new Error("Wallet changed during payment flow");
88
+ const D = await s.signTransaction({
89
+ transaction: f,
90
+ signTransaction: y
91
+ }), A = s.buildPaymentPayload({
92
+ requirement: o,
93
+ signedTx: D,
94
+ payerPublicKey: a
95
+ }), T = await g.submitPayment({
96
+ resource: l,
97
+ payload: A,
98
+ couponCode: i,
99
+ metadata: b,
100
+ resourceType: r
101
+ });
102
+ return T.success && T.settlement && x(T.settlement), T;
103
+ }
104
+ },
105
+ [g, s]
106
+ ), p = P(
107
+ async (o, l, i) => {
108
+ if (E())
109
+ return { success: !1, error: "Payment already in progress" };
110
+ const b = v();
111
+ if (!b.valid)
112
+ return { success: !1, error: b.error };
113
+ u.current = Date.now(), d({
114
+ status: "loading",
115
+ error: null,
116
+ transactionId: null
117
+ });
118
+ try {
119
+ n().debug("[useX402Payment] Fetching fresh quote");
120
+ const r = await g.requestQuote({ resource: o, couponCode: l });
121
+ n().debug("[useX402Payment] Received quote", {
122
+ amount: r.maxAmountRequired
123
+ }), k(r), n().debug("[useX402Payment] Executing payment flow");
124
+ const a = await B(r, o, l, i, "regular");
125
+ return a.success ? d({
126
+ status: "success",
127
+ error: null,
128
+ transactionId: a.transactionId || "payment-success"
129
+ }) : d({
130
+ status: "error",
131
+ error: a.error || "Payment failed",
132
+ transactionId: null
133
+ }), a;
134
+ } catch (r) {
135
+ const a = Z(r, "Payment failed");
136
+ return d({
137
+ status: "error",
138
+ error: a,
139
+ transactionId: null
140
+ }), { success: !1, error: a };
141
+ } finally {
142
+ u.current = 0;
143
+ }
144
+ },
145
+ [v, g, B]
146
+ ), M = P(
147
+ async (o, l, i) => {
148
+ if (E())
149
+ return { success: !1, error: "Payment already in progress" };
150
+ const b = v();
151
+ if (!b.valid)
152
+ return { success: !1, error: b.error };
153
+ u.current = Date.now(), d({
154
+ status: "loading",
155
+ error: null,
156
+ transactionId: null
157
+ });
158
+ try {
159
+ const r = Ee(o), a = await g.requestCartQuote({
160
+ items: r,
161
+ metadata: l,
162
+ couponCode: i
163
+ }), y = a.cartId, c = a.quote;
164
+ if (!g.validateRequirement(c))
165
+ throw new Error("Invalid cart quote received from server");
166
+ k(c);
167
+ const f = await B(c, y, i, l, "cart");
168
+ return f.success ? d({
169
+ status: "success",
170
+ error: null,
171
+ transactionId: f.transactionId || "cart-payment-success"
172
+ }) : d({
173
+ status: "error",
174
+ error: f.error || "Cart payment failed",
175
+ transactionId: null
176
+ }), f;
177
+ } catch (r) {
178
+ const a = Z(r, "Cart payment failed");
179
+ return d({
180
+ status: "error",
181
+ error: a,
182
+ transactionId: null
183
+ }), { success: !1, error: a };
184
+ } finally {
185
+ u.current = 0;
186
+ }
187
+ },
188
+ [v, g, B]
189
+ ), W = P(() => {
190
+ d({
191
+ status: "idle",
192
+ error: null,
193
+ transactionId: null
194
+ }), k(null), x(null), u.current = 0;
195
+ }, []);
196
+ return {
197
+ ...X,
198
+ requirement: I,
199
+ settlement: O,
200
+ fetchQuote: z,
201
+ processPayment: p,
202
+ processCartPayment: M,
203
+ reset: W
204
+ };
205
+ }
206
+ function $e({
207
+ resource: g,
208
+ items: s,
209
+ label: _,
210
+ disabled: q = !1,
211
+ onAttempt: X,
212
+ onSuccess: d,
213
+ onError: I,
214
+ className: k = "",
215
+ testPageUrl: O,
216
+ hideMessages: x = !1,
217
+ metadata: C,
218
+ couponCode: w
219
+ }) {
220
+ const { connected: u, connecting: K, connect: E, disconnect: v, select: z, wallets: B, wallet: p, publicKey: M } = be(), { status: W, error: o, transactionId: l, processPayment: i, processCartPayment: b } = Fe(), r = Ie(), { solanaError: a } = he(), { isCartMode: y, effectiveResource: c } = We(g, s), { t: f, translations: D } = Re(), A = _ || f("ui.pay_with_crypto"), T = o && typeof o != "string" ? o?.code ?? null : null, F = a && typeof a != "string" ? a?.code ?? null : null, te = (e) => {
221
+ if (!e || !D) return "";
222
+ const t = D.errors[e];
223
+ return t ? t.action ? `${t.message} ${t.action}` : t.message : "";
224
+ }, re = o ? typeof o == "string" ? o : te(T) : null, ne = a ? typeof a == "string" ? a : te(F) : null, oe = R(d), ae = R(I), se = R(i), le = R(b);
225
+ oe.current = d, ae.current = I, se.current = i, le.current = b;
226
+ const Ce = Y(
227
+ () => B.map((e) => `${e.adapter.name}-${e.readyState}`).join(","),
228
+ [B]
229
+ ), Q = Y(
230
+ () => B.filter(
231
+ ({ readyState: e }) => e === pe.Installed || e === pe.Loadable
232
+ ),
233
+ // walletStateKey is derived from availableWallets, so we only need availableWallets as dependency
234
+ // eslint-disable-next-line react-hooks/exhaustive-deps
235
+ [Ce]
236
+ );
237
+ H(() => {
238
+ if (W === "success" && l) {
239
+ const e = y && s ? J(s) : void 0;
240
+ _e("crypto", l, c, e), oe.current?.(l);
241
+ }
242
+ }, [W, l, y, s, c]), H(() => {
243
+ if (W === "error" && o) {
244
+ const e = y && s ? J(s) : void 0;
245
+ fe("crypto", o, c, e), ae.current?.(o);
246
+ }
247
+ }, [W, o, y, s, c]);
248
+ const ce = typeof window < "u" && window.top !== window.self, [ie, $] = L(!1), [ue, V] = L(!1), [N, S] = L(null), j = a;
249
+ H(() => {
250
+ let e = !1;
251
+ return e || (async () => {
252
+ if (ue && p && !u && !K) {
253
+ n().debug("[CryptoButton] Wallet detected, attempting auto-connect:", p.adapter.name), V(!1), we(p.adapter.name);
254
+ try {
255
+ await E(), e || n().debug("[CryptoButton] Auto-connect successful");
256
+ } catch (m) {
257
+ if (!e) {
258
+ n().error("[CryptoButton] Auto-connect failed:", m);
259
+ const U = m instanceof Error ? m.message : "Failed to connect wallet";
260
+ ee(U, p.adapter.name), S(null);
261
+ }
262
+ }
263
+ }
264
+ })(), () => {
265
+ e = !0;
266
+ };
267
+ }, [p, ue, u, K, E]), H(() => {
268
+ let e = !0;
269
+ if (n().debug("[CryptoButton] Payment useEffect triggered", {
270
+ connected: u,
271
+ hasPendingPayment: !!N,
272
+ hasPublicKey: !!M,
273
+ pendingPaymentType: N?.type
274
+ }), u && N && M && p && e) {
275
+ qe(p.adapter.name, M.toString()), n().debug("[CryptoButton] All conditions met! Processing pending payment:", N);
276
+ const t = N;
277
+ S(null), $(!1);
278
+ const m = t.type === "cart" && t.items ? J(t.items) : void 0;
279
+ ge("crypto", t.resource, m), t.type === "cart" && t.items ? (n().debug("[CryptoButton] Auto-processing cart payment"), le.current(t.items, t.metadata, t.couponCode)) : t.type === "single" && t.resource && (n().debug("[CryptoButton] Auto-processing single payment"), se.current(t.resource, t.couponCode, t.metadata));
280
+ }
281
+ return () => {
282
+ e = !1;
283
+ };
284
+ }, [u, N, M, p]);
285
+ const de = P(async () => {
286
+ n().debug("[CryptoButton] executePaymentFlow called", {
287
+ connected: u,
288
+ wallet: p?.adapter.name,
289
+ couponCode: w,
290
+ isCartMode: y,
291
+ hasItems: !!s,
292
+ effectiveResource: c
293
+ });
294
+ const e = y && s ? J(s) : void 0;
295
+ if (ze("crypto", c, e), X && X("crypto"), j) {
296
+ n().error("[CryptoButton] Solana dependencies missing:", j), fe("crypto", j, c, e), I && I(j);
297
+ return;
298
+ }
299
+ if (ce) {
300
+ const t = O || window.location.href;
301
+ try {
302
+ if (new URL(t, window.location.origin).origin !== window.location.origin)
303
+ throw n().error("[CryptoButton] Blocked attempt to open external URL:", t), new Error("Cannot open external URLs from embedded context");
304
+ window.open(t, "_blank", "noopener,noreferrer");
305
+ } catch (m) {
306
+ throw n().error("[CryptoButton] URL validation failed:", m), m;
307
+ }
308
+ return;
309
+ }
310
+ if (u)
311
+ ge("crypto", c, e), y && s ? (n().debug("[CryptoButton] Processing cart payment with coupon:", w), await b(s, C, w)) : c && (n().debug("[CryptoButton] Processing single payment with coupon:", w), await i(c, w, C));
312
+ else {
313
+ let t = !1;
314
+ if (y && s ? (n().debug("[CryptoButton] Setting pending cart payment with coupon:", w), S({ type: "cart", items: s, metadata: C, couponCode: w }), t = !0) : c && (n().debug("[CryptoButton] Setting pending single payment with coupon:", w), S({ type: "single", resource: c, metadata: C, couponCode: w }), t = !0), !t) {
315
+ n().error("[CryptoButton] No valid payment to process");
316
+ return;
317
+ }
318
+ try {
319
+ if (p)
320
+ n().debug("[CryptoButton] Wallet already selected, connecting:", p.adapter.name), we(p.adapter.name), await E();
321
+ else {
322
+ if (n().debug(
323
+ "[CryptoButton] No wallet selected, showing selector. Available wallets:",
324
+ Q.map((m) => m.adapter.name)
325
+ ), Q.length === 0) {
326
+ S(null);
327
+ const m = "No wallets available";
328
+ throw ee(m), new Error(m);
329
+ }
330
+ $(!0);
331
+ }
332
+ } catch (m) {
333
+ S(null);
334
+ const U = m instanceof Error ? m.message : "Failed to connect wallet";
335
+ n().error("[CryptoButton] Connection error:", U), ee(U, p?.adapter.name);
336
+ }
337
+ }
338
+ }, [u, p, w, y, s, c, ce, O, Q, E, C, b, i, j, X, I]), ye = Y(() => y && s ? `crypto-cart-${s.map((e) => e.resource).join("-")}` : `crypto-${c || "unknown"}`, [y, s, c]), Pe = Y(
339
+ () => Me(ye, de, {
340
+ cooldownMs: 200,
341
+ deduplicationWindowMs: 0
342
+ // MUST be 0 for crypto - each payment needs fresh transaction
343
+ }),
344
+ [ye, de]
345
+ ), me = W === "loading", xe = q || me || K || !!j, ve = me ? f("ui.processing") : A, Se = P(async () => {
346
+ try {
347
+ V(!1), u && await v(), z(null), $(!0);
348
+ } catch (e) {
349
+ n().error("Failed to change wallet:", e);
350
+ }
351
+ }, [u, v, z]), ke = P((e) => {
352
+ n().debug("[CryptoButton] Wallet clicked:", e), $(!1), z(e), V(!0), n().debug("[CryptoButton] Wallet selected, useEffect will auto-connect");
353
+ }, [z]), Be = P(async () => {
354
+ try {
355
+ if (await v(), S(null), typeof window < "u" && window.localStorage)
356
+ try {
357
+ window.localStorage.removeItem("walletName");
358
+ } catch (e) {
359
+ e instanceof Error && e.name === "QuotaExceededError" ? n().warn("localStorage quota exceeded when removing wallet preference") : n().error("Failed to clear wallet preference from localStorage:", e);
360
+ }
361
+ } catch (e) {
362
+ n().error("Failed to disconnect wallet:", e);
363
+ }
364
+ }, [v]);
365
+ return /* @__PURE__ */ G("div", { className: r.unstyled ? k : `${r.className} cedros-theme__crypto-button ${k || ""}`, style: r.unstyled ? {} : r.style, children: [
366
+ /* @__PURE__ */ h(
367
+ "button",
368
+ {
369
+ onClick: Pe,
370
+ disabled: xe,
371
+ className: r.unstyled ? k : "cedros-theme__button cedros-theme__crypto",
372
+ type: "button",
373
+ children: ve
374
+ }
375
+ ),
376
+ ie && !x && /* @__PURE__ */ h(
377
+ "div",
378
+ {
379
+ className: "cedros-modal-overlay",
380
+ style: {
381
+ position: "fixed",
382
+ top: 0,
383
+ left: 0,
384
+ right: 0,
385
+ bottom: 0,
386
+ backgroundColor: r.tokens.modalOverlay,
387
+ display: "flex",
388
+ alignItems: "center",
389
+ justifyContent: "center",
390
+ zIndex: 9999,
391
+ padding: "1rem"
392
+ },
393
+ onClick: () => {
394
+ $(!1), S(null);
395
+ },
396
+ children: /* @__PURE__ */ G(
397
+ "div",
398
+ {
399
+ className: "cedros-modal-content",
400
+ style: {
401
+ backgroundColor: r.tokens.modalBackground,
402
+ borderRadius: "12px",
403
+ padding: "2rem",
404
+ maxWidth: "400px",
405
+ width: "100%",
406
+ boxShadow: "0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04)",
407
+ border: `1px solid ${r.tokens.modalBorder}`
408
+ },
409
+ onClick: (e) => e.stopPropagation(),
410
+ children: [
411
+ /* @__PURE__ */ G(
412
+ "div",
413
+ {
414
+ style: {
415
+ display: "flex",
416
+ justifyContent: "space-between",
417
+ alignItems: "center",
418
+ marginBottom: "1.5rem"
419
+ },
420
+ children: [
421
+ /* @__PURE__ */ h(
422
+ "h3",
423
+ {
424
+ style: {
425
+ margin: 0,
426
+ fontSize: "1.25rem",
427
+ fontWeight: 600,
428
+ color: r.tokens.surfaceText
429
+ },
430
+ children: f("wallet.select_wallet")
431
+ }
432
+ ),
433
+ /* @__PURE__ */ h(
434
+ "button",
435
+ {
436
+ onClick: () => {
437
+ $(!1), S(null);
438
+ },
439
+ style: De(r.tokens.surfaceText),
440
+ "aria-label": "Close modal",
441
+ type: "button",
442
+ children: "×"
443
+ }
444
+ )
445
+ ]
446
+ }
447
+ ),
448
+ /* @__PURE__ */ h("div", { style: { display: "flex", flexDirection: "column", gap: "0.75rem" }, children: Q.map((e) => /* @__PURE__ */ G(
449
+ "button",
450
+ {
451
+ onClick: () => ke(e.adapter.name),
452
+ style: {
453
+ width: "100%",
454
+ padding: "1rem",
455
+ backgroundColor: r.tokens.surfaceBackground,
456
+ border: `1px solid ${r.tokens.surfaceBorder}`,
457
+ borderRadius: "0.5rem",
458
+ cursor: "pointer",
459
+ fontSize: "1rem",
460
+ textAlign: "left",
461
+ color: r.tokens.surfaceText,
462
+ display: "flex",
463
+ alignItems: "center",
464
+ gap: "1rem",
465
+ transition: "all 0.2s ease"
466
+ },
467
+ onMouseEnter: (t) => {
468
+ t.currentTarget.style.backgroundColor = r.tokens.modalBackground, t.currentTarget.style.borderColor = r.tokens.surfaceText, t.currentTarget.style.transform = "translateY(-2px)";
469
+ },
470
+ onMouseLeave: (t) => {
471
+ t.currentTarget.style.backgroundColor = r.tokens.surfaceBackground, t.currentTarget.style.borderColor = r.tokens.surfaceBorder, t.currentTarget.style.transform = "translateY(0)";
472
+ },
473
+ type: "button",
474
+ children: [
475
+ /* @__PURE__ */ h(Te, { wallet: e, style: { width: "24px", height: "24px" } }),
476
+ /* @__PURE__ */ h("span", { style: { fontWeight: 500 }, children: e.adapter.name })
477
+ ]
478
+ },
479
+ e.adapter.name
480
+ )) })
481
+ ]
482
+ }
483
+ )
484
+ }
485
+ ),
486
+ u && !x && !ie && /* @__PURE__ */ G("div", { style: {
487
+ display: "flex",
488
+ justifyContent: "space-between",
489
+ marginTop: "0.5rem",
490
+ fontSize: "0.75rem",
491
+ color: r.tokens.surfaceText,
492
+ opacity: 0.7
493
+ }, children: [
494
+ /* @__PURE__ */ h(
495
+ "button",
496
+ {
497
+ onClick: Se,
498
+ style: {
499
+ background: "none",
500
+ border: "none",
501
+ padding: 0,
502
+ color: "inherit",
503
+ textDecoration: "none",
504
+ cursor: "pointer",
505
+ fontSize: "inherit"
506
+ },
507
+ type: "button",
508
+ children: f("wallet.change")
509
+ }
510
+ ),
511
+ /* @__PURE__ */ h(
512
+ "button",
513
+ {
514
+ onClick: Be,
515
+ style: {
516
+ background: "none",
517
+ border: "none",
518
+ padding: 0,
519
+ color: "inherit",
520
+ textDecoration: "none",
521
+ cursor: "pointer",
522
+ fontSize: "inherit"
523
+ },
524
+ type: "button",
525
+ children: f("ui.disconnect")
526
+ }
527
+ )
528
+ ] }),
529
+ !x && ne && /* @__PURE__ */ h("div", { className: r.unstyled ? "" : "cedros-theme__error", children: ne }),
530
+ !x && re && /* @__PURE__ */ h("div", { className: r.unstyled ? "" : "cedros-theme__error", children: re }),
531
+ !x && l && /* @__PURE__ */ h("div", { className: r.unstyled ? "" : "cedros-theme__success", children: f("ui.payment_successful") })
532
+ ] });
533
+ }
534
+ const Oe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
535
+ __proto__: null,
536
+ CryptoButton: $e
537
+ }, Symbol.toStringTag, { value: "Module" }));
538
+ export {
539
+ $e as C,
540
+ Oe as a,
541
+ Fe as u
542
+ };
@@ -0,0 +1 @@
1
+ "use strict";const p=require("react/jsx-runtime"),a=require("react"),ce=require("@solana/wallet-adapter-react"),le=require("@solana/wallet-adapter-base"),be=require("@solana/wallet-adapter-react-ui"),t=require("./CedrosContext-C26DlvLF.js"),i=require("./index-B-0trqeD.js");function ie(){const{x402Manager:C,walletManager:l}=t.useCedrosContext(),{publicKey:W,signTransaction:j}=ce.useWallet(),[N,y]=a.useState({status:"idle",error:null,transactionId:null}),[R,L]=a.useState(null),[K,k]=a.useState(null),P=a.useRef(W);P.current=W;const h=a.useRef(j);h.current=j;const g=a.useRef(0),X=6e4,I=()=>{const o=g.current;return o>0&&Date.now()-o<X},S=a.useCallback(()=>{if(!W){const o="Wallet not connected";return y({status:"error",error:o,transactionId:null}),{valid:!1,error:o}}if(!j){const o="Wallet does not support signing";return y({status:"error",error:o,transactionId:null}),{valid:!1,error:o}}return{valid:!0}},[W,j]),q=a.useCallback(async o=>{try{y(d=>({...d,status:"loading"}));const c=await C.requestQuote({resource:o});if(!C.validateRequirement(c))throw new Error("Invalid requirement received from server");return L(c),y(d=>({...d,status:"idle"})),c}catch(c){const d=t.formatError(c,"Failed to fetch requirement");throw y({status:"error",error:d,transactionId:null}),c}},[C]),B=a.useCallback(async(o,c,d,x,n="regular")=>{const s=P.current,m=h.current;if(!s||!m)throw new Error("Wallet disconnected during payment flow");if(!!o.extra?.feePayer){t.getLogger().debug("[useX402Payment] Gasless flow enabled"),t.getLogger().debug("[useX402Payment] Building gasless transaction");const{transaction:b,blockhash:M}=await C.buildGaslessTransaction({resourceId:c,userWallet:s.toString(),feePayer:o.extra.feePayer,couponCode:d});t.getLogger().debug("[useX402Payment] Deserializing backend transaction");const A=l.deserializeTransaction(b);if(P.current?.toString()!==s.toString())throw new Error("Wallet changed during payment flow");t.getLogger().debug("[useX402Payment] Requesting partial signature");const E=await l.partiallySignTransaction({transaction:A,signTransaction:m,blockhash:M});t.getLogger().debug("[useX402Payment] Submitting partial transaction");const z=await C.submitGaslessTransaction({resource:c,partialTx:E,couponCode:d,metadata:x,resourceType:n,requirement:o});return z.success&&z.settlement&&k(z.settlement),z}else{const b=await l.buildTransaction({requirement:o,payerPublicKey:s});if(P.current?.toString()!==s.toString())throw new Error("Wallet changed during payment flow");const M=await l.signTransaction({transaction:b,signTransaction:m}),A=l.buildPaymentPayload({requirement:o,signedTx:M,payerPublicKey:s}),E=await C.submitPayment({resource:c,payload:A,couponCode:d,metadata:x,resourceType:n});return E.success&&E.settlement&&k(E.settlement),E}},[C,l]),w=a.useCallback(async(o,c,d)=>{if(I())return{success:!1,error:"Payment already in progress"};const x=S();if(!x.valid)return{success:!1,error:x.error};g.current=Date.now(),y({status:"loading",error:null,transactionId:null});try{t.getLogger().debug("[useX402Payment] Fetching fresh quote");const n=await C.requestQuote({resource:o,couponCode:c});t.getLogger().debug("[useX402Payment] Received quote",{amount:n.maxAmountRequired}),L(n),t.getLogger().debug("[useX402Payment] Executing payment flow");const s=await B(n,o,c,d,"regular");return s.success?y({status:"success",error:null,transactionId:s.transactionId||"payment-success"}):y({status:"error",error:s.error||"Payment failed",transactionId:null}),s}catch(n){const s=t.formatError(n,"Payment failed");return y({status:"error",error:s,transactionId:null}),{success:!1,error:s}}finally{g.current=0}},[S,C,B]),_=a.useCallback(async(o,c,d)=>{if(I())return{success:!1,error:"Payment already in progress"};const x=S();if(!x.valid)return{success:!1,error:x.error};g.current=Date.now(),y({status:"loading",error:null,transactionId:null});try{const n=i.normalizeCartItems(o),s=await C.requestCartQuote({items:n,metadata:c,couponCode:d}),m=s.cartId,u=s.quote;if(!C.validateRequirement(u))throw new Error("Invalid cart quote received from server");L(u);const b=await B(u,m,d,c,"cart");return b.success?y({status:"success",error:null,transactionId:b.transactionId||"cart-payment-success"}):y({status:"error",error:b.error||"Cart payment failed",transactionId:null}),b}catch(n){const s=t.formatError(n,"Cart payment failed");return y({status:"error",error:s,transactionId:null}),{success:!1,error:s}}finally{g.current=0}},[S,C,B]),T=a.useCallback(()=>{y({status:"idle",error:null,transactionId:null}),L(null),k(null),g.current=0},[]);return{...N,requirement:R,settlement:K,fetchQuote:q,processPayment:w,processCartPayment:_,reset:T}}function ue({resource:C,items:l,label:W,disabled:j=!1,onAttempt:N,onSuccess:y,onError:R,className:L="",testPageUrl:K,hideMessages:k=!1,metadata:P,couponCode:h}){const{connected:g,connecting:X,connect:I,disconnect:S,select:q,wallets:B,wallet:w,publicKey:_}=ce.useWallet(),{status:T,error:o,transactionId:c,processPayment:d,processCartPayment:x}=ie(),n=t.useCedrosTheme(),{solanaError:s}=t.useCedrosContext(),{isCartMode:m,effectiveResource:u}=i.usePaymentMode(C,l),{t:b,translations:M}=i.useTranslation(),A=W||b("ui.pay_with_crypto"),E=o&&typeof o!="string"?o?.code??null:null,z=s&&typeof s!="string"?s?.code??null:null,U=e=>{if(!e||!M)return"";const r=M.errors[e];return r?r.action?`${r.message} ${r.action}`:r.message:""},Y=o?typeof o=="string"?o:U(E):null,H=s?typeof s=="string"?s:U(z):null,J=a.useRef(y),V=a.useRef(R),Z=a.useRef(d),ee=a.useRef(x);J.current=y,V.current=R,Z.current=d,ee.current=x;const de=a.useMemo(()=>B.map(e=>`${e.adapter.name}-${e.readyState}`).join(","),[B]),G=a.useMemo(()=>B.filter(({readyState:e})=>e===le.WalletReadyState.Installed||e===le.WalletReadyState.Loadable),[de]);a.useEffect(()=>{if(T==="success"&&c){const e=m&&l?i.getCartItemCount(l):void 0;i.emitPaymentSuccess("crypto",c,u,e),J.current?.(c)}},[T,c,m,l,u]),a.useEffect(()=>{if(T==="error"&&o){const e=m&&l?i.getCartItemCount(l):void 0;i.emitPaymentError("crypto",o,u,e),V.current?.(o)}},[T,o,m,l,u]);const te=typeof window<"u"&&window.top!==window.self,[re,$]=a.useState(!1),[ne,Q]=a.useState(!1),[D,v]=a.useState(null),F=s;a.useEffect(()=>{let e=!1;return e||(async()=>{if(ne&&w&&!g&&!X){t.getLogger().debug("[CryptoButton] Wallet detected, attempting auto-connect:",w.adapter.name),Q(!1),i.emitWalletConnect(w.adapter.name);try{await I(),e||t.getLogger().debug("[CryptoButton] Auto-connect successful")}catch(f){if(!e){t.getLogger().error("[CryptoButton] Auto-connect failed:",f);const O=f instanceof Error?f.message:"Failed to connect wallet";i.emitWalletError(O,w.adapter.name),v(null)}}}})(),()=>{e=!0}},[w,ne,g,X,I]),a.useEffect(()=>{let e=!0;if(t.getLogger().debug("[CryptoButton] Payment useEffect triggered",{connected:g,hasPendingPayment:!!D,hasPublicKey:!!_,pendingPaymentType:D?.type}),g&&D&&_&&w&&e){i.emitWalletConnected(w.adapter.name,_.toString()),t.getLogger().debug("[CryptoButton] All conditions met! Processing pending payment:",D);const r=D;v(null),$(!1);const f=r.type==="cart"&&r.items?i.getCartItemCount(r.items):void 0;i.emitPaymentProcessing("crypto",r.resource,f),r.type==="cart"&&r.items?(t.getLogger().debug("[CryptoButton] Auto-processing cart payment"),ee.current(r.items,r.metadata,r.couponCode)):r.type==="single"&&r.resource&&(t.getLogger().debug("[CryptoButton] Auto-processing single payment"),Z.current(r.resource,r.couponCode,r.metadata))}return()=>{e=!1}},[g,D,_,w]);const oe=a.useCallback(async()=>{t.getLogger().debug("[CryptoButton] executePaymentFlow called",{connected:g,wallet:w?.adapter.name,couponCode:h,isCartMode:m,hasItems:!!l,effectiveResource:u});const e=m&&l?i.getCartItemCount(l):void 0;if(i.emitPaymentStart("crypto",u,e),N&&N("crypto"),F){t.getLogger().error("[CryptoButton] Solana dependencies missing:",F),i.emitPaymentError("crypto",F,u,e),R&&R(F);return}if(te){const r=K||window.location.href;try{if(new URL(r,window.location.origin).origin!==window.location.origin)throw t.getLogger().error("[CryptoButton] Blocked attempt to open external URL:",r),new Error("Cannot open external URLs from embedded context");window.open(r,"_blank","noopener,noreferrer")}catch(f){throw t.getLogger().error("[CryptoButton] URL validation failed:",f),f}return}if(g)i.emitPaymentProcessing("crypto",u,e),m&&l?(t.getLogger().debug("[CryptoButton] Processing cart payment with coupon:",h),await x(l,P,h)):u&&(t.getLogger().debug("[CryptoButton] Processing single payment with coupon:",h),await d(u,h,P));else{let r=!1;if(m&&l?(t.getLogger().debug("[CryptoButton] Setting pending cart payment with coupon:",h),v({type:"cart",items:l,metadata:P,couponCode:h}),r=!0):u&&(t.getLogger().debug("[CryptoButton] Setting pending single payment with coupon:",h),v({type:"single",resource:u,metadata:P,couponCode:h}),r=!0),!r){t.getLogger().error("[CryptoButton] No valid payment to process");return}try{if(w)t.getLogger().debug("[CryptoButton] Wallet already selected, connecting:",w.adapter.name),i.emitWalletConnect(w.adapter.name),await I();else{if(t.getLogger().debug("[CryptoButton] No wallet selected, showing selector. Available wallets:",G.map(f=>f.adapter.name)),G.length===0){v(null);const f="No wallets available";throw i.emitWalletError(f),new Error(f)}$(!0)}}catch(f){v(null);const O=f instanceof Error?f.message:"Failed to connect wallet";t.getLogger().error("[CryptoButton] Connection error:",O),i.emitWalletError(O,w?.adapter.name)}}},[g,w,h,m,l,u,te,K,G,I,P,x,d,F,N,R]),ae=a.useMemo(()=>m&&l?`crypto-cart-${l.map(e=>e.resource).join("-")}`:`crypto-${u||"unknown"}`,[m,l,u]),ge=a.useMemo(()=>i.createDedupedClickHandler(ae,oe,{cooldownMs:200,deduplicationWindowMs:0}),[ae,oe]),se=T==="loading",ye=j||se||X||!!F,me=se?b("ui.processing"):A,fe=a.useCallback(async()=>{try{Q(!1),g&&await S(),q(null),$(!0)}catch(e){t.getLogger().error("Failed to change wallet:",e)}},[g,S,q]),pe=a.useCallback(e=>{t.getLogger().debug("[CryptoButton] Wallet clicked:",e),$(!1),q(e),Q(!0),t.getLogger().debug("[CryptoButton] Wallet selected, useEffect will auto-connect")},[q]),we=a.useCallback(async()=>{try{if(await S(),v(null),typeof window<"u"&&window.localStorage)try{window.localStorage.removeItem("walletName")}catch(e){e instanceof Error&&e.name==="QuotaExceededError"?t.getLogger().warn("localStorage quota exceeded when removing wallet preference"):t.getLogger().error("Failed to clear wallet preference from localStorage:",e)}}catch(e){t.getLogger().error("Failed to disconnect wallet:",e)}},[S]);return p.jsxs("div",{className:n.unstyled?L:`${n.className} cedros-theme__crypto-button ${L||""}`,style:n.unstyled?{}:n.style,children:[p.jsx("button",{onClick:ge,disabled:ye,className:n.unstyled?L:"cedros-theme__button cedros-theme__crypto",type:"button",children:me}),re&&!k&&p.jsx("div",{className:"cedros-modal-overlay",style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:n.tokens.modalOverlay,display:"flex",alignItems:"center",justifyContent:"center",zIndex:9999,padding:"1rem"},onClick:()=>{$(!1),v(null)},children:p.jsxs("div",{className:"cedros-modal-content",style:{backgroundColor:n.tokens.modalBackground,borderRadius:"12px",padding:"2rem",maxWidth:"400px",width:"100%",boxShadow:"0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04)",border:`1px solid ${n.tokens.modalBorder}`},onClick:e=>e.stopPropagation(),children:[p.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"1.5rem"},children:[p.jsx("h3",{style:{margin:0,fontSize:"1.25rem",fontWeight:600,color:n.tokens.surfaceText},children:b("wallet.select_wallet")}),p.jsx("button",{onClick:()=>{$(!1),v(null)},style:i.getModalCloseButtonStyles(n.tokens.surfaceText),"aria-label":"Close modal",type:"button",children:"×"})]}),p.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:G.map(e=>p.jsxs("button",{onClick:()=>pe(e.adapter.name),style:{width:"100%",padding:"1rem",backgroundColor:n.tokens.surfaceBackground,border:`1px solid ${n.tokens.surfaceBorder}`,borderRadius:"0.5rem",cursor:"pointer",fontSize:"1rem",textAlign:"left",color:n.tokens.surfaceText,display:"flex",alignItems:"center",gap:"1rem",transition:"all 0.2s ease"},onMouseEnter:r=>{r.currentTarget.style.backgroundColor=n.tokens.modalBackground,r.currentTarget.style.borderColor=n.tokens.surfaceText,r.currentTarget.style.transform="translateY(-2px)"},onMouseLeave:r=>{r.currentTarget.style.backgroundColor=n.tokens.surfaceBackground,r.currentTarget.style.borderColor=n.tokens.surfaceBorder,r.currentTarget.style.transform="translateY(0)"},type:"button",children:[p.jsx(be.WalletIcon,{wallet:e,style:{width:"24px",height:"24px"}}),p.jsx("span",{style:{fontWeight:500},children:e.adapter.name})]},e.adapter.name))})]})}),g&&!k&&!re&&p.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginTop:"0.5rem",fontSize:"0.75rem",color:n.tokens.surfaceText,opacity:.7},children:[p.jsx("button",{onClick:fe,style:{background:"none",border:"none",padding:0,color:"inherit",textDecoration:"none",cursor:"pointer",fontSize:"inherit"},type:"button",children:b("wallet.change")}),p.jsx("button",{onClick:we,style:{background:"none",border:"none",padding:0,color:"inherit",textDecoration:"none",cursor:"pointer",fontSize:"inherit"},type:"button",children:b("ui.disconnect")})]}),!k&&H&&p.jsx("div",{className:n.unstyled?"":"cedros-theme__error",children:H}),!k&&Y&&p.jsx("div",{className:n.unstyled?"":"cedros-theme__error",children:Y}),!k&&c&&p.jsx("div",{className:n.unstyled?"":"cedros-theme__success",children:b("ui.payment_successful")})]})}const Ce=Object.freeze(Object.defineProperty({__proto__:null,CryptoButton:ue},Symbol.toStringTag,{value:"Module"}));exports.CryptoButton=ue;exports.CryptoButton$1=Ce;exports.useX402Payment=ie;