@cedros/pay-react 1.1.5 → 1.1.9
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.
- package/dist/CedrosContext-C2v_s8cc.js +6 -0
- package/dist/CedrosContext-D7nh5-Zh.mjs +2100 -0
- package/dist/WalletManager-B5KLZK2D.js +1 -0
- package/dist/WalletManager-oEjZhaFk.mjs +219 -0
- package/dist/components/CedrosPay.d.ts.map +1 -1
- package/dist/components/admin/AISettingsSection.d.ts.map +1 -1
- package/dist/components/admin/CouponsSection.d.ts.map +1 -1
- package/dist/components/admin/ErrorBanner.d.ts +11 -0
- package/dist/components/admin/ErrorBanner.d.ts.map +1 -0
- package/dist/components/admin/FAQSection.d.ts.map +1 -1
- package/dist/components/admin/MessagingSection.d.ts.map +1 -1
- package/dist/components/admin/OverviewSection.d.ts.map +1 -1
- package/dist/components/admin/ProductsSection.d.ts.map +1 -1
- package/dist/components/admin/RefundsSection.d.ts.map +1 -1
- package/dist/components/admin/SingleCategorySettings.d.ts.map +1 -1
- package/dist/components/admin/StorefrontSection.d.ts.map +1 -1
- package/dist/components/admin/SubscriptionsSection.d.ts.map +1 -1
- package/dist/components/admin/TransactionsSection.d.ts.map +1 -1
- package/dist/context/CedrosContext.d.ts +9 -3
- package/dist/context/CedrosContext.d.ts.map +1 -1
- package/dist/crypto-only.d.ts +9 -19
- package/dist/crypto-only.d.ts.map +1 -1
- package/dist/crypto-only.js +1 -1
- package/dist/crypto-only.mjs +766 -32
- package/dist/index-BFt38o8Q.mjs +88 -0
- package/dist/index-S3b2N8tp.js +136 -0
- package/dist/index-WcOlBYZJ.js +1 -0
- package/dist/{index-Bzp2srIS.mjs → index-iIxY1o71.mjs} +10413 -9402
- package/dist/index.d.ts +1 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +68 -75
- package/dist/managers/ManagerCache.d.ts +2 -2
- package/dist/managers/ManagerCache.d.ts.map +1 -1
- package/dist/pay-react.css +1 -1
- package/dist/{sections-D6R2jRAp.js → sections-bhZyRM7o.js} +1 -1
- package/dist/{sections-cz9ughWO.mjs → sections-otLBNrzu.mjs} +2 -2
- package/dist/solanaCheck-BS3QTE63.js +6 -0
- package/dist/solanaCheck-IlYsbXDd.mjs +27 -0
- package/dist/stripe-only.d.ts +4 -21
- package/dist/stripe-only.d.ts.map +1 -1
- package/dist/stripe-only.js +1 -1
- package/dist/stripe-only.mjs +71 -29
- package/dist/testing/index.js +1 -1
- package/dist/testing/index.mjs +1 -1
- package/dist/types/componentOptions.d.ts +15 -2
- package/dist/types/componentOptions.d.ts.map +1 -1
- package/dist/utils/index.d.ts +0 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/walletPool-BR6etEiq.mjs +67 -0
- package/dist/walletPool-BZyAG4YS.js +1 -0
- package/package.json +6 -1
- package/dist/CedrosContext-DUT3cLZg.mjs +0 -2474
- package/dist/CedrosContext-efFL4kQz.js +0 -11
- package/dist/index-CFzfjC82.js +0 -136
- package/dist/styles-C4-_hbgr.js +0 -1
- package/dist/styles-QcAsIVWl.mjs +0 -1909
package/dist/styles-QcAsIVWl.mjs
DELETED
|
@@ -1,1909 +0,0 @@
|
|
|
1
|
-
import { jsxs as H, jsx as S } from "react/jsx-runtime";
|
|
2
|
-
import { useState as O, useRef as te, useCallback as M, useMemo as A, useEffect as z } from "react";
|
|
3
|
-
import { g as p, u as ce, a as le, f as fe } from "./CedrosContext-DUT3cLZg.mjs";
|
|
4
|
-
import { useWallet as Me } from "@solana/wallet-adapter-react";
|
|
5
|
-
import { WalletReadyState as je } from "@solana/wallet-adapter-base";
|
|
6
|
-
import { WalletIcon as Ue } from "@solana/wallet-adapter-react-ui";
|
|
7
|
-
import "@solana/wallet-adapter-wallets";
|
|
8
|
-
function Ct(t) {
|
|
9
|
-
return !t || !t.coupon_codes ? [] : t.coupon_codes.split(",").map((e) => e.trim()).filter((e) => e.length > 0);
|
|
10
|
-
}
|
|
11
|
-
function Pt(t, e = ", ") {
|
|
12
|
-
return t.join(e);
|
|
13
|
-
}
|
|
14
|
-
function vt(t, e) {
|
|
15
|
-
return t <= 0 ? 0 : (t - e) / t * 100;
|
|
16
|
-
}
|
|
17
|
-
function kt(t, e) {
|
|
18
|
-
if (!e || e.length === 0)
|
|
19
|
-
return t;
|
|
20
|
-
let n = t, r = 0;
|
|
21
|
-
for (const o of e)
|
|
22
|
-
if (o.discountType === "percentage") {
|
|
23
|
-
const a = 1 - o.discountValue / 100;
|
|
24
|
-
n = n * a;
|
|
25
|
-
} else o.discountType === "fixed" && (r += o.discountValue);
|
|
26
|
-
return n = n - r, n < 0 && (n = 0), Math.ceil(n * 100) / 100;
|
|
27
|
-
}
|
|
28
|
-
function Ne(t) {
|
|
29
|
-
const e = Number(t);
|
|
30
|
-
if (!Number.isFinite(e) || e <= 0)
|
|
31
|
-
return 1;
|
|
32
|
-
const n = Math.floor(e);
|
|
33
|
-
return n > 0 ? n : 1;
|
|
34
|
-
}
|
|
35
|
-
function ae(t) {
|
|
36
|
-
return t.map((e) => ({
|
|
37
|
-
resource: e.resource,
|
|
38
|
-
quantity: Ne(e.quantity),
|
|
39
|
-
variantId: e.variantId,
|
|
40
|
-
metadata: e.metadata
|
|
41
|
-
}));
|
|
42
|
-
}
|
|
43
|
-
function ee(t) {
|
|
44
|
-
return t.reduce((e, n) => e + Ne(n.quantity), 0);
|
|
45
|
-
}
|
|
46
|
-
function Qe(t) {
|
|
47
|
-
return !!(t && t.length > 0 && (t.length > 1 || t.length === 1 && (t[0].quantity ?? 1) > 1));
|
|
48
|
-
}
|
|
49
|
-
const Ge = {
|
|
50
|
-
// ===== PAYMENT VERIFICATION ERRORS (402) =====
|
|
51
|
-
invalid_payment_proof: {
|
|
52
|
-
message: "Payment verification failed",
|
|
53
|
-
action: "Please try your payment again. If this continues, contact support.",
|
|
54
|
-
technicalHint: "Invalid payment proof format"
|
|
55
|
-
},
|
|
56
|
-
invalid_signature: {
|
|
57
|
-
message: "Transaction signature is invalid",
|
|
58
|
-
action: "Please approve the transaction in your wallet and try again.",
|
|
59
|
-
technicalHint: "Transaction signature verification failed"
|
|
60
|
-
},
|
|
61
|
-
invalid_transaction: {
|
|
62
|
-
message: "Transaction format is invalid",
|
|
63
|
-
action: "Please try your payment again. If this continues, try updating your wallet app.",
|
|
64
|
-
technicalHint: "Malformed transaction structure"
|
|
65
|
-
},
|
|
66
|
-
transaction_not_found: {
|
|
67
|
-
message: "Transaction not found on the blockchain",
|
|
68
|
-
action: "Your transaction may still be processing. Please wait a moment and check your wallet, or try again.",
|
|
69
|
-
technicalHint: "Transaction signature not found on-chain"
|
|
70
|
-
},
|
|
71
|
-
transaction_not_confirmed: {
|
|
72
|
-
message: "Transaction is still processing",
|
|
73
|
-
action: "Please wait a moment for the blockchain to confirm your transaction, then try again.",
|
|
74
|
-
technicalHint: "Transaction not yet confirmed"
|
|
75
|
-
},
|
|
76
|
-
transaction_failed: {
|
|
77
|
-
message: "Transaction failed on the blockchain",
|
|
78
|
-
action: "Check your wallet for details. You may need to adjust your transaction settings or add more SOL for fees.",
|
|
79
|
-
technicalHint: "On-chain transaction failure"
|
|
80
|
-
},
|
|
81
|
-
transaction_expired: {
|
|
82
|
-
message: "Transaction took too long to process",
|
|
83
|
-
action: "Please try your payment again. Consider increasing transaction priority if your wallet supports it.",
|
|
84
|
-
technicalHint: "Transaction blockhash expired"
|
|
85
|
-
},
|
|
86
|
-
invalid_recipient: {
|
|
87
|
-
message: "Payment was sent to the wrong address",
|
|
88
|
-
action: "Please try again and ensure you approve the correct transaction in your wallet.",
|
|
89
|
-
technicalHint: "Recipient address mismatch"
|
|
90
|
-
},
|
|
91
|
-
invalid_sender: {
|
|
92
|
-
message: "Payment sender wallet is invalid",
|
|
93
|
-
action: "Please reconnect your wallet and try again.",
|
|
94
|
-
technicalHint: "Sender address validation failed"
|
|
95
|
-
},
|
|
96
|
-
unauthorized_refund_issuer: {
|
|
97
|
-
message: "You are not authorized to issue refunds",
|
|
98
|
-
action: "Only authorized accounts can process refunds. Please contact support if you believe this is an error.",
|
|
99
|
-
technicalHint: "Refund issuer not in authorized list"
|
|
100
|
-
},
|
|
101
|
-
amount_below_minimum: {
|
|
102
|
-
message: "Payment amount is too low",
|
|
103
|
-
action: "Please check the required amount and try again.",
|
|
104
|
-
technicalHint: "Amount below minimum threshold"
|
|
105
|
-
},
|
|
106
|
-
amount_mismatch: {
|
|
107
|
-
message: "Payment amount does not match the quote",
|
|
108
|
-
action: "The price may have changed. Please refresh and try your payment again.",
|
|
109
|
-
technicalHint: "Amount does not match quote"
|
|
110
|
-
},
|
|
111
|
-
insufficient_funds_sol: {
|
|
112
|
-
message: "Not enough SOL for transaction fees",
|
|
113
|
-
action: "Add at least 0.001 SOL to your wallet to cover network fees, then try again.",
|
|
114
|
-
technicalHint: "Insufficient SOL balance for fees"
|
|
115
|
-
},
|
|
116
|
-
insufficient_funds_token: {
|
|
117
|
-
message: "Insufficient balance in your wallet",
|
|
118
|
-
action: "Add more funds to your wallet and try again.",
|
|
119
|
-
technicalHint: "Insufficient token balance"
|
|
120
|
-
},
|
|
121
|
-
invalid_token_mint: {
|
|
122
|
-
message: "Incorrect payment token",
|
|
123
|
-
action: "Please pay with the correct token as shown in the payment details.",
|
|
124
|
-
technicalHint: "Token mint address mismatch"
|
|
125
|
-
},
|
|
126
|
-
not_spl_transfer: {
|
|
127
|
-
message: "Transaction is not a valid token transfer",
|
|
128
|
-
action: "Please ensure you are sending the correct token type from your wallet.",
|
|
129
|
-
technicalHint: "Transaction is not an SPL token transfer"
|
|
130
|
-
},
|
|
131
|
-
missing_token_account: {
|
|
132
|
-
message: "Token account not found",
|
|
133
|
-
action: "Your wallet may need to create a token account first. Try again or use a different wallet.",
|
|
134
|
-
technicalHint: "Associated token account does not exist"
|
|
135
|
-
},
|
|
136
|
-
invalid_token_program: {
|
|
137
|
-
message: "Invalid token program",
|
|
138
|
-
action: "Please try your payment again. If this continues, try using a different wallet.",
|
|
139
|
-
technicalHint: "Token program ID mismatch"
|
|
140
|
-
},
|
|
141
|
-
missing_memo: {
|
|
142
|
-
message: "Payment memo is required but was not included",
|
|
143
|
-
action: "Please try your payment again and ensure transaction details are approved in your wallet.",
|
|
144
|
-
technicalHint: "Required memo instruction missing"
|
|
145
|
-
},
|
|
146
|
-
invalid_memo: {
|
|
147
|
-
message: "Payment memo format is invalid",
|
|
148
|
-
action: "Please try your payment again.",
|
|
149
|
-
technicalHint: "Memo does not match expected format"
|
|
150
|
-
},
|
|
151
|
-
payment_already_used: {
|
|
152
|
-
message: "This payment has already been processed",
|
|
153
|
-
action: "Check your transaction history. If you need to make another payment, please start a new transaction.",
|
|
154
|
-
technicalHint: "Payment signature already recorded"
|
|
155
|
-
},
|
|
156
|
-
signature_reused: {
|
|
157
|
-
message: "Transaction signature has already been used",
|
|
158
|
-
action: "Please create a new payment transaction.",
|
|
159
|
-
technicalHint: "Duplicate signature detected"
|
|
160
|
-
},
|
|
161
|
-
quote_expired: {
|
|
162
|
-
message: "Payment quote has expired",
|
|
163
|
-
action: "Prices are updated frequently. Please refresh and try your payment again.",
|
|
164
|
-
technicalHint: "Quote timestamp expired"
|
|
165
|
-
},
|
|
166
|
-
// ===== VALIDATION ERRORS (400) =====
|
|
167
|
-
missing_field: {
|
|
168
|
-
message: "Required information is missing",
|
|
169
|
-
action: "Please check all required fields and try again.",
|
|
170
|
-
technicalHint: "Required field not provided"
|
|
171
|
-
},
|
|
172
|
-
invalid_field: {
|
|
173
|
-
message: "Some information is invalid",
|
|
174
|
-
action: "Please check your input and try again.",
|
|
175
|
-
technicalHint: "Field validation failed"
|
|
176
|
-
},
|
|
177
|
-
invalid_amount: {
|
|
178
|
-
message: "Payment amount is invalid",
|
|
179
|
-
action: "Please check the amount and try again.",
|
|
180
|
-
technicalHint: "Amount validation failed"
|
|
181
|
-
},
|
|
182
|
-
invalid_wallet: {
|
|
183
|
-
message: "Wallet address is invalid",
|
|
184
|
-
action: "Please reconnect your wallet and try again.",
|
|
185
|
-
technicalHint: "Wallet address validation failed"
|
|
186
|
-
},
|
|
187
|
-
invalid_resource: {
|
|
188
|
-
message: "Invalid item selection",
|
|
189
|
-
action: "Please refresh the page and try again.",
|
|
190
|
-
technicalHint: "Resource ID validation failed"
|
|
191
|
-
},
|
|
192
|
-
invalid_coupon: {
|
|
193
|
-
message: "Invalid coupon code",
|
|
194
|
-
action: "Please check the coupon code and try again.",
|
|
195
|
-
technicalHint: "Coupon code format invalid"
|
|
196
|
-
},
|
|
197
|
-
invalid_cart_item: {
|
|
198
|
-
message: "One or more cart items are invalid",
|
|
199
|
-
action: "Please review your cart and try again.",
|
|
200
|
-
technicalHint: "Cart item validation failed"
|
|
201
|
-
},
|
|
202
|
-
empty_cart: {
|
|
203
|
-
message: "Your cart is empty",
|
|
204
|
-
action: "Please add items to your cart before checking out.",
|
|
205
|
-
technicalHint: "Cart contains no items"
|
|
206
|
-
},
|
|
207
|
-
// ===== RESOURCE/STATE ERRORS (404) =====
|
|
208
|
-
resource_not_found: {
|
|
209
|
-
message: "Item not found",
|
|
210
|
-
action: "This item may no longer be available. Please refresh and try again.",
|
|
211
|
-
technicalHint: "Resource not found in database"
|
|
212
|
-
},
|
|
213
|
-
cart_not_found: {
|
|
214
|
-
message: "Shopping cart not found",
|
|
215
|
-
action: "Your cart may have expired. Please start a new order.",
|
|
216
|
-
technicalHint: "Cart ID not found"
|
|
217
|
-
},
|
|
218
|
-
refund_not_found: {
|
|
219
|
-
message: "Refund not found",
|
|
220
|
-
action: "Please check your refund reference number or contact support.",
|
|
221
|
-
technicalHint: "Refund ID not found"
|
|
222
|
-
},
|
|
223
|
-
product_not_found: {
|
|
224
|
-
message: "Product not available",
|
|
225
|
-
action: "This product may no longer be available. Please browse our current selection.",
|
|
226
|
-
technicalHint: "Product ID not found"
|
|
227
|
-
},
|
|
228
|
-
coupon_not_found: {
|
|
229
|
-
message: "Coupon code not found",
|
|
230
|
-
action: "Please check the coupon code or remove it to continue.",
|
|
231
|
-
technicalHint: "Coupon code not in database"
|
|
232
|
-
},
|
|
233
|
-
session_not_found: {
|
|
234
|
-
message: "Payment session expired",
|
|
235
|
-
action: "Please start a new payment.",
|
|
236
|
-
technicalHint: "Session ID not found or expired"
|
|
237
|
-
},
|
|
238
|
-
cart_already_paid: {
|
|
239
|
-
message: "This order has already been paid",
|
|
240
|
-
action: "Check your order history. If you need to make another purchase, please start a new order.",
|
|
241
|
-
technicalHint: "Cart marked as paid"
|
|
242
|
-
},
|
|
243
|
-
refund_already_processed: {
|
|
244
|
-
message: "This refund has already been processed",
|
|
245
|
-
action: "Check your transaction history or contact support for details.",
|
|
246
|
-
technicalHint: "Refund already completed"
|
|
247
|
-
},
|
|
248
|
-
// ===== COUPON-SPECIFIC ERRORS (409) =====
|
|
249
|
-
coupon_expired: {
|
|
250
|
-
message: "Coupon has expired",
|
|
251
|
-
action: "Please remove the coupon code or use a different code.",
|
|
252
|
-
technicalHint: "Coupon expiration date passed"
|
|
253
|
-
},
|
|
254
|
-
coupon_usage_limit_reached: {
|
|
255
|
-
message: "Coupon usage limit reached",
|
|
256
|
-
action: "This coupon has been fully redeemed. Please try a different code.",
|
|
257
|
-
technicalHint: "Coupon max uses exceeded"
|
|
258
|
-
},
|
|
259
|
-
coupon_not_applicable: {
|
|
260
|
-
message: "Coupon cannot be applied to this purchase",
|
|
261
|
-
action: "Please check the coupon terms or remove it to continue.",
|
|
262
|
-
technicalHint: "Coupon conditions not met"
|
|
263
|
-
},
|
|
264
|
-
coupon_wrong_payment_method: {
|
|
265
|
-
message: "Coupon not valid for this payment method",
|
|
266
|
-
action: "Try a different payment method or remove the coupon code.",
|
|
267
|
-
technicalHint: "Coupon restricted to specific payment methods"
|
|
268
|
-
},
|
|
269
|
-
// ===== EXTERNAL SERVICE ERRORS (502) =====
|
|
270
|
-
stripe_error: {
|
|
271
|
-
message: "Card payment service temporarily unavailable",
|
|
272
|
-
action: "Please try again in a moment, or use cryptocurrency payment instead.",
|
|
273
|
-
technicalHint: "Stripe API error"
|
|
274
|
-
},
|
|
275
|
-
rpc_error: {
|
|
276
|
-
message: "Blockchain network temporarily unavailable",
|
|
277
|
-
action: "Please try again in a moment, or use card payment instead.",
|
|
278
|
-
technicalHint: "Solana RPC error"
|
|
279
|
-
},
|
|
280
|
-
network_error: {
|
|
281
|
-
message: "Network connection issue",
|
|
282
|
-
action: "Please check your internet connection and try again.",
|
|
283
|
-
technicalHint: "Network request failed"
|
|
284
|
-
},
|
|
285
|
-
// ===== INTERNAL/SYSTEM ERRORS (500) =====
|
|
286
|
-
internal_error: {
|
|
287
|
-
message: "Something went wrong on our end",
|
|
288
|
-
action: "Please try again. If this continues, contact support.",
|
|
289
|
-
technicalHint: "Internal server error"
|
|
290
|
-
},
|
|
291
|
-
database_error: {
|
|
292
|
-
message: "Service temporarily unavailable",
|
|
293
|
-
action: "Please try again in a moment.",
|
|
294
|
-
technicalHint: "Database operation failed"
|
|
295
|
-
},
|
|
296
|
-
config_error: {
|
|
297
|
-
message: "Service configuration error",
|
|
298
|
-
action: "Please contact support for assistance.",
|
|
299
|
-
technicalHint: "Server misconfiguration"
|
|
300
|
-
}
|
|
301
|
-
};
|
|
302
|
-
function se(t) {
|
|
303
|
-
return Ge[t] || {
|
|
304
|
-
message: "An unexpected error occurred",
|
|
305
|
-
action: "Please try again or contact support if this continues.",
|
|
306
|
-
technicalHint: `Unknown error code: ${t}`
|
|
307
|
-
};
|
|
308
|
-
}
|
|
309
|
-
const Be = /* @__PURE__ */ new Map(), ye = /* @__PURE__ */ new Map(), ge = /* @__PURE__ */ new Map(), Le = 200, he = 2e3;
|
|
310
|
-
function Xe(t) {
|
|
311
|
-
const e = ge.get(t);
|
|
312
|
-
return e ? Date.now() < e ? !0 : (ge.delete(t), !1) : !1;
|
|
313
|
-
}
|
|
314
|
-
function Ke(t, e = Le) {
|
|
315
|
-
const n = Date.now() + e;
|
|
316
|
-
ge.set(t, n);
|
|
317
|
-
}
|
|
318
|
-
function Ve(t, e = he) {
|
|
319
|
-
const n = Be.get(t);
|
|
320
|
-
if (!n)
|
|
321
|
-
return !1;
|
|
322
|
-
const o = Date.now() - n;
|
|
323
|
-
return o < e ? (p().debug(`[Deduplication] Duplicate request blocked: ${t} (${o}ms ago)`), !0) : !1;
|
|
324
|
-
}
|
|
325
|
-
function Ze(t) {
|
|
326
|
-
Be.set(t, Date.now());
|
|
327
|
-
}
|
|
328
|
-
function Je(t) {
|
|
329
|
-
return ye.get(t) || null;
|
|
330
|
-
}
|
|
331
|
-
function et(t, e) {
|
|
332
|
-
ye.set(t, e);
|
|
333
|
-
const n = () => {
|
|
334
|
-
ye.delete(t), Ze(t);
|
|
335
|
-
};
|
|
336
|
-
return e.then(n, n), e;
|
|
337
|
-
}
|
|
338
|
-
async function tt(t, e, n = {}) {
|
|
339
|
-
const { windowMs: r = he, throwOnDuplicate: o = !0 } = n, a = Je(t);
|
|
340
|
-
if (a)
|
|
341
|
-
return p().debug(`[Deduplication] Reusing in-flight request: ${t}`), a;
|
|
342
|
-
if (Ve(t, r)) {
|
|
343
|
-
if (o)
|
|
344
|
-
throw new Error(`Duplicate request blocked: ${t}`);
|
|
345
|
-
return p().warn(`[Deduplication] Duplicate request blocked but not throwing: ${t}`), Promise.reject(new Error("Duplicate request"));
|
|
346
|
-
}
|
|
347
|
-
const w = e();
|
|
348
|
-
return et(t, w);
|
|
349
|
-
}
|
|
350
|
-
function we(t, e, n = {}) {
|
|
351
|
-
const { cooldownMs: r = Le, deduplicationWindowMs: o = he } = n;
|
|
352
|
-
return async () => {
|
|
353
|
-
if (Xe(t)) {
|
|
354
|
-
p().debug(`[Deduplication] Button in cooldown: ${t}`);
|
|
355
|
-
return;
|
|
356
|
-
}
|
|
357
|
-
Ke(t, r);
|
|
358
|
-
try {
|
|
359
|
-
await tt(
|
|
360
|
-
t,
|
|
361
|
-
async () => {
|
|
362
|
-
const a = e();
|
|
363
|
-
a instanceof Promise && await a;
|
|
364
|
-
},
|
|
365
|
-
{ windowMs: o, throwOnDuplicate: !1 }
|
|
366
|
-
);
|
|
367
|
-
} catch (a) {
|
|
368
|
-
if (a instanceof Error && a.message.includes("Duplicate request"))
|
|
369
|
-
return;
|
|
370
|
-
throw a;
|
|
371
|
-
}
|
|
372
|
-
};
|
|
373
|
-
}
|
|
374
|
-
function He(t) {
|
|
375
|
-
return {
|
|
376
|
-
background: "none",
|
|
377
|
-
border: "none",
|
|
378
|
-
fontSize: "1.5rem",
|
|
379
|
-
cursor: "pointer",
|
|
380
|
-
color: t,
|
|
381
|
-
opacity: 0.6,
|
|
382
|
-
padding: "0.25rem",
|
|
383
|
-
lineHeight: 1
|
|
384
|
-
};
|
|
385
|
-
}
|
|
386
|
-
const Q = {
|
|
387
|
-
PAYMENT_START: "cedros:payment:start",
|
|
388
|
-
WALLET_CONNECT: "cedros:wallet:connect",
|
|
389
|
-
WALLET_CONNECTED: "cedros:wallet:connected",
|
|
390
|
-
WALLET_ERROR: "cedros:wallet:error",
|
|
391
|
-
PAYMENT_PROCESSING: "cedros:payment:processing",
|
|
392
|
-
PAYMENT_SUCCESS: "cedros:payment:success",
|
|
393
|
-
PAYMENT_ERROR: "cedros:payment:error"
|
|
394
|
-
};
|
|
395
|
-
function G(t, e) {
|
|
396
|
-
if (typeof window > "u")
|
|
397
|
-
return;
|
|
398
|
-
const n = new CustomEvent(t, {
|
|
399
|
-
detail: e,
|
|
400
|
-
bubbles: !0,
|
|
401
|
-
cancelable: !1
|
|
402
|
-
});
|
|
403
|
-
window.dispatchEvent(n);
|
|
404
|
-
}
|
|
405
|
-
function be(t, e, n) {
|
|
406
|
-
G(Q.PAYMENT_START, {
|
|
407
|
-
timestamp: Date.now(),
|
|
408
|
-
method: t,
|
|
409
|
-
resource: e,
|
|
410
|
-
itemCount: n
|
|
411
|
-
});
|
|
412
|
-
}
|
|
413
|
-
function De(t) {
|
|
414
|
-
G(Q.WALLET_CONNECT, {
|
|
415
|
-
timestamp: Date.now(),
|
|
416
|
-
wallet: t
|
|
417
|
-
});
|
|
418
|
-
}
|
|
419
|
-
function nt(t, e) {
|
|
420
|
-
G(Q.WALLET_CONNECTED, {
|
|
421
|
-
timestamp: Date.now(),
|
|
422
|
-
wallet: t,
|
|
423
|
-
publicKey: e
|
|
424
|
-
});
|
|
425
|
-
}
|
|
426
|
-
function me(t, e) {
|
|
427
|
-
G(Q.WALLET_ERROR, {
|
|
428
|
-
timestamp: Date.now(),
|
|
429
|
-
wallet: e,
|
|
430
|
-
error: t
|
|
431
|
-
});
|
|
432
|
-
}
|
|
433
|
-
function ie(t, e, n) {
|
|
434
|
-
G(Q.PAYMENT_PROCESSING, {
|
|
435
|
-
timestamp: Date.now(),
|
|
436
|
-
method: t,
|
|
437
|
-
resource: e,
|
|
438
|
-
itemCount: n
|
|
439
|
-
});
|
|
440
|
-
}
|
|
441
|
-
function _e(t, e, n, r) {
|
|
442
|
-
G(Q.PAYMENT_SUCCESS, {
|
|
443
|
-
timestamp: Date.now(),
|
|
444
|
-
method: t,
|
|
445
|
-
transactionId: e,
|
|
446
|
-
resource: n,
|
|
447
|
-
itemCount: r
|
|
448
|
-
});
|
|
449
|
-
}
|
|
450
|
-
function U(t, e, n, r) {
|
|
451
|
-
G(Q.PAYMENT_ERROR, {
|
|
452
|
-
timestamp: Date.now(),
|
|
453
|
-
method: t,
|
|
454
|
-
error: e,
|
|
455
|
-
resource: n,
|
|
456
|
-
itemCount: r
|
|
457
|
-
});
|
|
458
|
-
}
|
|
459
|
-
class F extends Error {
|
|
460
|
-
/** Machine-readable error code enum */
|
|
461
|
-
code;
|
|
462
|
-
/** Whether this error can be safely retried */
|
|
463
|
-
retryable;
|
|
464
|
-
/** Additional error context */
|
|
465
|
-
details;
|
|
466
|
-
/** HTTP status code (if from API response) */
|
|
467
|
-
httpStatus;
|
|
468
|
-
constructor(e, n, r = !1, o, a) {
|
|
469
|
-
super(n), this.name = "PaymentError", this.code = e, this.retryable = r, this.details = o, this.httpStatus = a, Object.setPrototypeOf(this, F.prototype);
|
|
470
|
-
}
|
|
471
|
-
/**
|
|
472
|
-
* Check if this error is retryable
|
|
473
|
-
*/
|
|
474
|
-
canRetry() {
|
|
475
|
-
return this.retryable;
|
|
476
|
-
}
|
|
477
|
-
/**
|
|
478
|
-
* Check if this is a specific error code
|
|
479
|
-
*/
|
|
480
|
-
is(e) {
|
|
481
|
-
return this.code === e;
|
|
482
|
-
}
|
|
483
|
-
/**
|
|
484
|
-
* Check if this error is in a specific category
|
|
485
|
-
*/
|
|
486
|
-
isInCategory(e) {
|
|
487
|
-
return e.includes(this.code);
|
|
488
|
-
}
|
|
489
|
-
/**
|
|
490
|
-
* Get a user-friendly error message
|
|
491
|
-
* Uses structured error messages with actionable guidance
|
|
492
|
-
*/
|
|
493
|
-
getUserMessage() {
|
|
494
|
-
const e = this.getErrorInfo();
|
|
495
|
-
return e.action ? `${e.message} ${e.action}` : e.message;
|
|
496
|
-
}
|
|
497
|
-
/**
|
|
498
|
-
* Get short error message without action guidance
|
|
499
|
-
*/
|
|
500
|
-
getShortMessage() {
|
|
501
|
-
return this.getErrorInfo().message;
|
|
502
|
-
}
|
|
503
|
-
/**
|
|
504
|
-
* Get actionable guidance for this error
|
|
505
|
-
*/
|
|
506
|
-
getAction() {
|
|
507
|
-
return this.getErrorInfo().action;
|
|
508
|
-
}
|
|
509
|
-
/**
|
|
510
|
-
* Get error info from error messages map
|
|
511
|
-
* @private
|
|
512
|
-
*/
|
|
513
|
-
getErrorInfo() {
|
|
514
|
-
return se(this.code);
|
|
515
|
-
}
|
|
516
|
-
/**
|
|
517
|
-
* Create PaymentError from API error response
|
|
518
|
-
*
|
|
519
|
-
* If `retryable` field is not present (Rust server), infers retryability
|
|
520
|
-
* from error codes using ERROR_CATEGORIES.RETRYABLE.
|
|
521
|
-
*/
|
|
522
|
-
static fromErrorResponse(e, n) {
|
|
523
|
-
const r = e.error.retryable ?? rt.RETRYABLE.includes(e.error.code);
|
|
524
|
-
return new F(
|
|
525
|
-
e.error.code,
|
|
526
|
-
e.error.message,
|
|
527
|
-
r,
|
|
528
|
-
e.error.details,
|
|
529
|
-
n
|
|
530
|
-
);
|
|
531
|
-
}
|
|
532
|
-
/**
|
|
533
|
-
* Create PaymentError from unknown error
|
|
534
|
-
* Useful for catch blocks where error type is unknown
|
|
535
|
-
*/
|
|
536
|
-
static fromUnknown(e) {
|
|
537
|
-
return e instanceof F ? e : e instanceof Error ? new F(
|
|
538
|
-
"internal_error",
|
|
539
|
-
e.message,
|
|
540
|
-
!1
|
|
541
|
-
) : new F(
|
|
542
|
-
"internal_error",
|
|
543
|
-
String(e),
|
|
544
|
-
!1
|
|
545
|
-
);
|
|
546
|
-
}
|
|
547
|
-
}
|
|
548
|
-
const rt = {
|
|
549
|
-
/** Insufficient funds errors requiring user to add funds */
|
|
550
|
-
INSUFFICIENT_FUNDS: [
|
|
551
|
-
"insufficient_funds_sol",
|
|
552
|
-
"insufficient_funds_token"
|
|
553
|
-
/* INSUFFICIENT_FUNDS_TOKEN */
|
|
554
|
-
],
|
|
555
|
-
/** Transaction state errors that may resolve with time */
|
|
556
|
-
TRANSACTION_PENDING: [
|
|
557
|
-
"transaction_not_confirmed",
|
|
558
|
-
"transaction_not_found"
|
|
559
|
-
/* TRANSACTION_NOT_FOUND */
|
|
560
|
-
],
|
|
561
|
-
/** Validation errors requiring input correction */
|
|
562
|
-
VALIDATION: [
|
|
563
|
-
"missing_field",
|
|
564
|
-
"invalid_field",
|
|
565
|
-
"invalid_amount",
|
|
566
|
-
"invalid_wallet",
|
|
567
|
-
"invalid_resource",
|
|
568
|
-
"invalid_cart_item",
|
|
569
|
-
"empty_cart"
|
|
570
|
-
/* EMPTY_CART */
|
|
571
|
-
],
|
|
572
|
-
/** Coupon-related errors */
|
|
573
|
-
COUPON: [
|
|
574
|
-
"invalid_coupon",
|
|
575
|
-
"coupon_not_found",
|
|
576
|
-
"coupon_expired",
|
|
577
|
-
"coupon_usage_limit_reached",
|
|
578
|
-
"coupon_not_applicable",
|
|
579
|
-
"coupon_wrong_payment_method"
|
|
580
|
-
/* COUPON_WRONG_PAYMENT_METHOD */
|
|
581
|
-
],
|
|
582
|
-
/** Retryable errors (temporary failures) */
|
|
583
|
-
RETRYABLE: [
|
|
584
|
-
"transaction_not_confirmed",
|
|
585
|
-
"rpc_error",
|
|
586
|
-
"network_error",
|
|
587
|
-
"stripe_error"
|
|
588
|
-
/* STRIPE_ERROR */
|
|
589
|
-
],
|
|
590
|
-
/** Resource not found errors */
|
|
591
|
-
NOT_FOUND: [
|
|
592
|
-
"resource_not_found",
|
|
593
|
-
"cart_not_found",
|
|
594
|
-
"refund_not_found",
|
|
595
|
-
"product_not_found",
|
|
596
|
-
"coupon_not_found",
|
|
597
|
-
"session_not_found",
|
|
598
|
-
"credits_hold_not_found"
|
|
599
|
-
/* CREDITS_HOLD_NOT_FOUND */
|
|
600
|
-
],
|
|
601
|
-
/** Credits-related errors */
|
|
602
|
-
CREDITS: [
|
|
603
|
-
"insufficient_credits",
|
|
604
|
-
"credits_hold_expired",
|
|
605
|
-
"credits_hold_not_found"
|
|
606
|
-
/* CREDITS_HOLD_NOT_FOUND */
|
|
607
|
-
],
|
|
608
|
-
/** Security/rate limit errors */
|
|
609
|
-
SECURITY: [
|
|
610
|
-
"invalid_redirect_url",
|
|
611
|
-
"rate_limit_exceeded",
|
|
612
|
-
"nonce_already_used"
|
|
613
|
-
/* NONCE_ALREADY_USED */
|
|
614
|
-
]
|
|
615
|
-
};
|
|
616
|
-
function It(t) {
|
|
617
|
-
return t instanceof F && t.canRetry();
|
|
618
|
-
}
|
|
619
|
-
function xt(t) {
|
|
620
|
-
return t instanceof F ? t.getUserMessage() : t instanceof Error ? t.message : String(t);
|
|
621
|
-
}
|
|
622
|
-
function ot() {
|
|
623
|
-
const { stripeManager: t } = ce(), [e, n] = O({
|
|
624
|
-
status: "idle",
|
|
625
|
-
error: null,
|
|
626
|
-
transactionId: null
|
|
627
|
-
}), r = te(!1), o = M(
|
|
628
|
-
async (g, I, f, m, c, u) => {
|
|
629
|
-
if (r.current)
|
|
630
|
-
return { success: !1, error: "Payment already in progress" };
|
|
631
|
-
r.current = !0, n({
|
|
632
|
-
status: "loading",
|
|
633
|
-
error: null,
|
|
634
|
-
transactionId: null
|
|
635
|
-
});
|
|
636
|
-
const h = {
|
|
637
|
-
resource: g,
|
|
638
|
-
successUrl: I,
|
|
639
|
-
cancelUrl: f,
|
|
640
|
-
metadata: m,
|
|
641
|
-
customerEmail: c,
|
|
642
|
-
couponCode: u
|
|
643
|
-
};
|
|
644
|
-
try {
|
|
645
|
-
const l = await t.processPayment(h);
|
|
646
|
-
return n({
|
|
647
|
-
status: l.success ? "success" : "error",
|
|
648
|
-
error: l.success ? null : l.error || "Payment failed",
|
|
649
|
-
transactionId: l.success && l.transactionId || null
|
|
650
|
-
}), l;
|
|
651
|
-
} catch (l) {
|
|
652
|
-
const j = l instanceof Error ? l.message : "Payment failed";
|
|
653
|
-
return n({
|
|
654
|
-
status: "error",
|
|
655
|
-
error: j,
|
|
656
|
-
transactionId: null
|
|
657
|
-
}), { success: !1, error: j };
|
|
658
|
-
} finally {
|
|
659
|
-
r.current = !1;
|
|
660
|
-
}
|
|
661
|
-
},
|
|
662
|
-
[t]
|
|
663
|
-
), a = M(
|
|
664
|
-
async (g, I, f, m, c, u) => {
|
|
665
|
-
if (r.current)
|
|
666
|
-
return { success: !1, error: "Payment already in progress" };
|
|
667
|
-
r.current = !0, n({
|
|
668
|
-
status: "loading",
|
|
669
|
-
error: null,
|
|
670
|
-
transactionId: null
|
|
671
|
-
});
|
|
672
|
-
const h = ae(g);
|
|
673
|
-
try {
|
|
674
|
-
const l = await t.processCartCheckout({
|
|
675
|
-
items: h,
|
|
676
|
-
successUrl: I,
|
|
677
|
-
cancelUrl: f,
|
|
678
|
-
metadata: m,
|
|
679
|
-
customerEmail: c,
|
|
680
|
-
couponCode: u
|
|
681
|
-
});
|
|
682
|
-
return n({
|
|
683
|
-
status: l.success ? "success" : "error",
|
|
684
|
-
error: l.success ? null : l.error || "Cart checkout failed",
|
|
685
|
-
transactionId: l.success && l.transactionId || null
|
|
686
|
-
}), l;
|
|
687
|
-
} catch (l) {
|
|
688
|
-
const j = l instanceof Error ? l.message : "Cart checkout failed";
|
|
689
|
-
return n({
|
|
690
|
-
status: "error",
|
|
691
|
-
error: j,
|
|
692
|
-
transactionId: null
|
|
693
|
-
}), { success: !1, error: j };
|
|
694
|
-
} finally {
|
|
695
|
-
r.current = !1;
|
|
696
|
-
}
|
|
697
|
-
},
|
|
698
|
-
[t]
|
|
699
|
-
), w = M(() => {
|
|
700
|
-
n({
|
|
701
|
-
status: "idle",
|
|
702
|
-
error: null,
|
|
703
|
-
transactionId: null
|
|
704
|
-
}), r.current = !1;
|
|
705
|
-
}, []);
|
|
706
|
-
return {
|
|
707
|
-
...e,
|
|
708
|
-
processPayment: o,
|
|
709
|
-
processCartCheckout: a,
|
|
710
|
-
reset: w
|
|
711
|
-
};
|
|
712
|
-
}
|
|
713
|
-
function Ce(t, e) {
|
|
714
|
-
return A(() => {
|
|
715
|
-
const n = Qe(e), r = t || (e?.length === 1 ? e[0].resource : "");
|
|
716
|
-
return {
|
|
717
|
-
isCartMode: n,
|
|
718
|
-
effectiveResource: r
|
|
719
|
-
};
|
|
720
|
-
}, [t, e]);
|
|
721
|
-
}
|
|
722
|
-
const at = (t, e, n) => {
|
|
723
|
-
const r = t[e];
|
|
724
|
-
return r ? typeof r == "function" ? r() : Promise.resolve(r) : new Promise((o, a) => {
|
|
725
|
-
(typeof queueMicrotask == "function" ? queueMicrotask : setTimeout)(a.bind(null, /* @__PURE__ */ new Error("Unknown variable dynamic import: " + e + (e.split("/").length !== n ? ". Note that variables only represent file names one level deep." : ""))));
|
|
726
|
-
});
|
|
727
|
-
}, pe = /* @__PURE__ */ new Map();
|
|
728
|
-
let oe = null;
|
|
729
|
-
async function qe(t) {
|
|
730
|
-
if (pe.has(t))
|
|
731
|
-
return pe.get(t);
|
|
732
|
-
try {
|
|
733
|
-
const e = await at(/* @__PURE__ */ Object.assign({ "./translations/ar.json": () => import("./ar-w27mU-4x.mjs"), "./translations/bn.json": () => import("./bn-Ba_k3Kex.mjs"), "./translations/de.json": () => import("./de-CoZiPFN7.mjs"), "./translations/en.json": () => import("./en-BXheDBal.mjs"), "./translations/es.json": () => import("./es-BWGIBp2f.mjs"), "./translations/fil.json": () => import("./fil-Czo27xmj.mjs"), "./translations/fr.json": () => import("./fr-DQ-2ThBv.mjs"), "./translations/he.json": () => import("./he-DpV1WnBQ.mjs"), "./translations/id.json": () => import("./id-BJMqsu19.mjs"), "./translations/in.json": () => import("./in-BxgxKLQH.mjs"), "./translations/it.json": () => import("./it-DZFFPALf.mjs"), "./translations/jp.json": () => import("./jp-ZExTrlHK.mjs"), "./translations/kr.json": () => import("./kr-DHX3i4Ht.mjs"), "./translations/ms.json": () => import("./ms-Cv1fdIi2.mjs"), "./translations/nl.json": () => import("./nl-BmGonsKb.mjs"), "./translations/pa.json": () => import("./pa-BfwcJIar.mjs"), "./translations/pl.json": () => import("./pl-DE5IB9xv.mjs"), "./translations/pt.json": () => import("./pt-CLzkqDzf.mjs"), "./translations/ru.json": () => import("./ru-DM6-oUR0.mjs"), "./translations/ta.json": () => import("./ta-A5HnrGb5.mjs"), "./translations/th.json": () => import("./th-3fbB3Ytp.mjs"), "./translations/tr.json": () => import("./tr-BrgfFFdq.mjs"), "./translations/uk.json": () => import("./uk-0hFun_g_.mjs"), "./translations/ur.json": () => import("./ur-CaOjJXai.mjs"), "./translations/vn.json": () => import("./vn-0nlIZFLP.mjs"), "./translations/zh.json": () => import("./zh-B4Endr1F.mjs") }), `./translations/${t}.json`, 3), n = e.default || e;
|
|
734
|
-
return pe.set(t, n), n;
|
|
735
|
-
} catch {
|
|
736
|
-
return null;
|
|
737
|
-
}
|
|
738
|
-
}
|
|
739
|
-
async function St() {
|
|
740
|
-
if (oe)
|
|
741
|
-
return oe;
|
|
742
|
-
const t = /* @__PURE__ */ Object.assign({ "./translations/ar.json": () => import("./ar-w27mU-4x.mjs"), "./translations/bn.json": () => import("./bn-Ba_k3Kex.mjs"), "./translations/de.json": () => import("./de-CoZiPFN7.mjs"), "./translations/en.json": () => import("./en-BXheDBal.mjs"), "./translations/es.json": () => import("./es-BWGIBp2f.mjs"), "./translations/fil.json": () => import("./fil-Czo27xmj.mjs"), "./translations/fr.json": () => import("./fr-DQ-2ThBv.mjs"), "./translations/he.json": () => import("./he-DpV1WnBQ.mjs"), "./translations/id.json": () => import("./id-BJMqsu19.mjs"), "./translations/in.json": () => import("./in-BxgxKLQH.mjs"), "./translations/it.json": () => import("./it-DZFFPALf.mjs"), "./translations/jp.json": () => import("./jp-ZExTrlHK.mjs"), "./translations/kr.json": () => import("./kr-DHX3i4Ht.mjs"), "./translations/ms.json": () => import("./ms-Cv1fdIi2.mjs"), "./translations/nl.json": () => import("./nl-BmGonsKb.mjs"), "./translations/pa.json": () => import("./pa-BfwcJIar.mjs"), "./translations/pl.json": () => import("./pl-DE5IB9xv.mjs"), "./translations/pt.json": () => import("./pt-CLzkqDzf.mjs"), "./translations/ru.json": () => import("./ru-DM6-oUR0.mjs"), "./translations/ta.json": () => import("./ta-A5HnrGb5.mjs"), "./translations/th.json": () => import("./th-3fbB3Ytp.mjs"), "./translations/tr.json": () => import("./tr-BrgfFFdq.mjs"), "./translations/uk.json": () => import("./uk-0hFun_g_.mjs"), "./translations/ur.json": () => import("./ur-CaOjJXai.mjs"), "./translations/vn.json": () => import("./vn-0nlIZFLP.mjs"), "./translations/zh.json": () => import("./zh-B4Endr1F.mjs") }), e = [];
|
|
743
|
-
for (const n in t) {
|
|
744
|
-
const r = n.match(/\.\/translations\/([a-z]{2,3}(?:-[A-Z]{2})?)\.json$/);
|
|
745
|
-
r && e.push(r[1]);
|
|
746
|
-
}
|
|
747
|
-
return oe = e.length > 0 ? e : ["en"], oe;
|
|
748
|
-
}
|
|
749
|
-
function st() {
|
|
750
|
-
return typeof navigator > "u" ? "en" : (navigator.language || navigator.userLanguage || "en").split("-")[0].toLowerCase();
|
|
751
|
-
}
|
|
752
|
-
async function it(t) {
|
|
753
|
-
let e = await qe(t);
|
|
754
|
-
if (e || (e = await qe("en"), e))
|
|
755
|
-
return e;
|
|
756
|
-
throw new Error("Critical: No translation files found, not even en.json");
|
|
757
|
-
}
|
|
758
|
-
function ct(t) {
|
|
759
|
-
return (e, n) => {
|
|
760
|
-
const r = e.split(".");
|
|
761
|
-
let o = t;
|
|
762
|
-
for (const a of r)
|
|
763
|
-
if (o && typeof o == "object" && a in o)
|
|
764
|
-
o = o[a];
|
|
765
|
-
else
|
|
766
|
-
return e;
|
|
767
|
-
return typeof o != "string" ? e : n ? Object.entries(n).reduce(
|
|
768
|
-
(a, [w, g]) => a.replace(new RegExp(`\\{${w}\\}`, "g"), g),
|
|
769
|
-
o
|
|
770
|
-
) : o;
|
|
771
|
-
};
|
|
772
|
-
}
|
|
773
|
-
function Et(t, e, n = !0) {
|
|
774
|
-
const r = e.errors[t];
|
|
775
|
-
if (!r) {
|
|
776
|
-
const o = se(t);
|
|
777
|
-
return n && o.action ? `${o.message} ${o.action}` : o.message;
|
|
778
|
-
}
|
|
779
|
-
return n && r.action ? `${r.message} ${r.action}` : r.message;
|
|
780
|
-
}
|
|
781
|
-
function ue(t) {
|
|
782
|
-
const [e, n] = O(null), [r, o] = O(!0), a = A(() => t || st(), [t]);
|
|
783
|
-
return z(() => {
|
|
784
|
-
let g = !1;
|
|
785
|
-
return (async () => {
|
|
786
|
-
o(!0);
|
|
787
|
-
try {
|
|
788
|
-
const f = await it(a);
|
|
789
|
-
g || (n(f), o(!1));
|
|
790
|
-
} catch (f) {
|
|
791
|
-
console.error("[CedrosPay] Failed to load translations:", f), g || o(!1);
|
|
792
|
-
}
|
|
793
|
-
})(), () => {
|
|
794
|
-
g = !0;
|
|
795
|
-
};
|
|
796
|
-
}, [a]), {
|
|
797
|
-
t: A(() => e ? ct(e) : (g) => ({
|
|
798
|
-
"ui.purchase": "Purchase",
|
|
799
|
-
"ui.pay_with_card": "Pay with Card",
|
|
800
|
-
"ui.pay_with_crypto": "Pay with USDC",
|
|
801
|
-
"ui.pay_with_usdc": "Pay with USDC",
|
|
802
|
-
"ui.card": "Card",
|
|
803
|
-
"ui.usdc_solana": "USDC (Solana)",
|
|
804
|
-
"ui.crypto": "Crypto",
|
|
805
|
-
"ui.processing": "Processing...",
|
|
806
|
-
"ui.loading": "Loading...",
|
|
807
|
-
"ui.connect_wallet": "Connect Wallet",
|
|
808
|
-
"ui.connecting": "Connecting..."
|
|
809
|
-
})[g] || g, [e]),
|
|
810
|
-
locale: a,
|
|
811
|
-
isLoading: r,
|
|
812
|
-
translations: e
|
|
813
|
-
};
|
|
814
|
-
}
|
|
815
|
-
function Tt(t, e = !0) {
|
|
816
|
-
const { translations: n } = ue();
|
|
817
|
-
if (!n) {
|
|
818
|
-
const o = se(t);
|
|
819
|
-
return e && o.action ? `${o.message} ${o.action}` : o.message;
|
|
820
|
-
}
|
|
821
|
-
const r = n.errors[t];
|
|
822
|
-
if (!r) {
|
|
823
|
-
const o = se(t);
|
|
824
|
-
return e && o.action ? `${o.message} ${o.action}` : o.message;
|
|
825
|
-
}
|
|
826
|
-
return e && r.action ? `${r.message} ${r.action}` : r.message;
|
|
827
|
-
}
|
|
828
|
-
function lt({
|
|
829
|
-
resource: t,
|
|
830
|
-
items: e,
|
|
831
|
-
successUrl: n,
|
|
832
|
-
cancelUrl: r,
|
|
833
|
-
metadata: o,
|
|
834
|
-
customerEmail: a,
|
|
835
|
-
couponCode: w,
|
|
836
|
-
label: g,
|
|
837
|
-
disabled: I = !1,
|
|
838
|
-
onAttempt: f,
|
|
839
|
-
onSuccess: m,
|
|
840
|
-
onError: c,
|
|
841
|
-
className: u = ""
|
|
842
|
-
}) {
|
|
843
|
-
const { status: h, error: l, transactionId: j, processPayment: E, processCartCheckout: d } = ot(), s = le(), { isCartMode: b, effectiveResource: C } = Ce(t, e), { t: _, translations: P } = ue(), N = g || _("ui.pay_with_card"), B = s.unstyled ? u : `${s.className} cedros-theme__stripe-button ${u}`.trim(), y = l && typeof l != "string" ? l?.code ?? null : null, v = l ? typeof l == "string" ? l : ((q) => {
|
|
844
|
-
if (!q || !P) return "";
|
|
845
|
-
const R = P.errors[q];
|
|
846
|
-
return R ? R.action ? `${R.message} ${R.action}` : R.message : "";
|
|
847
|
-
})(y) : null, k = M(async () => {
|
|
848
|
-
p().debug("[StripeButton] executePayment with couponCode:", w);
|
|
849
|
-
const q = b && e ? ee(e) : void 0;
|
|
850
|
-
if (be("stripe", C, q), f && f("stripe"), !b && !C) {
|
|
851
|
-
const K = "Invalid payment configuration: missing resource or items";
|
|
852
|
-
p().error("[StripeButton]", K), U("stripe", K, C, q), c && c(K);
|
|
853
|
-
return;
|
|
854
|
-
}
|
|
855
|
-
let R;
|
|
856
|
-
ie("stripe", C, q), b && e ? (p().debug("[StripeButton] Processing cart checkout with coupon:", w), R = await d(
|
|
857
|
-
e,
|
|
858
|
-
n,
|
|
859
|
-
r,
|
|
860
|
-
o,
|
|
861
|
-
a,
|
|
862
|
-
w
|
|
863
|
-
)) : C && (p().debug("[StripeButton] Processing single payment with coupon:", w), R = await E(
|
|
864
|
-
C,
|
|
865
|
-
n,
|
|
866
|
-
r,
|
|
867
|
-
o,
|
|
868
|
-
a,
|
|
869
|
-
w
|
|
870
|
-
)), R && R.success && R.transactionId ? (_e("stripe", R.transactionId, C, q), m && m(R.transactionId)) : R && !R.success && R.error && (U("stripe", R.error, C, q), c && c(R.error));
|
|
871
|
-
}, [w, b, C, e, n, r, o, a, d, E, f, m, c]), $ = A(() => b && e ? `stripe-cart-${e.map((q) => q.resource).join("-")}` : `stripe-${C || "unknown"}`, [b, e, C]), X = A(
|
|
872
|
-
() => we($, k),
|
|
873
|
-
[$, k]
|
|
874
|
-
), L = h === "loading", T = I || L;
|
|
875
|
-
return /* @__PURE__ */ H("div", { className: B, style: s.unstyled ? {} : s.style, children: [
|
|
876
|
-
/* @__PURE__ */ S(
|
|
877
|
-
"button",
|
|
878
|
-
{
|
|
879
|
-
onClick: X,
|
|
880
|
-
disabled: T,
|
|
881
|
-
className: s.unstyled ? u : "cedros-theme__button cedros-theme__stripe",
|
|
882
|
-
type: "button",
|
|
883
|
-
children: L ? _("ui.processing") : N
|
|
884
|
-
}
|
|
885
|
-
),
|
|
886
|
-
v && /* @__PURE__ */ S("div", { className: s.unstyled ? "" : "cedros-theme__error", children: v }),
|
|
887
|
-
j && /* @__PURE__ */ S("div", { className: s.unstyled ? "" : "cedros-theme__success", children: _("ui.payment_successful") })
|
|
888
|
-
] });
|
|
889
|
-
}
|
|
890
|
-
function ut() {
|
|
891
|
-
const { x402Manager: t, walletManager: e } = ce(), { publicKey: n, signTransaction: r } = Me(), [o, a] = O({
|
|
892
|
-
status: "idle",
|
|
893
|
-
error: null,
|
|
894
|
-
transactionId: null
|
|
895
|
-
}), [w, g] = O(null), [I, f] = O(null), m = te(!1), c = M(() => {
|
|
896
|
-
if (!n) {
|
|
897
|
-
const d = "Wallet not connected";
|
|
898
|
-
return a({ status: "error", error: d, transactionId: null }), { valid: !1, error: d };
|
|
899
|
-
}
|
|
900
|
-
if (!r) {
|
|
901
|
-
const d = "Wallet does not support signing";
|
|
902
|
-
return a({ status: "error", error: d, transactionId: null }), { valid: !1, error: d };
|
|
903
|
-
}
|
|
904
|
-
return { valid: !0 };
|
|
905
|
-
}, [n, r]), u = M(
|
|
906
|
-
async (d) => {
|
|
907
|
-
try {
|
|
908
|
-
a((b) => ({ ...b, status: "loading" }));
|
|
909
|
-
const s = await t.requestQuote({ resource: d });
|
|
910
|
-
if (!t.validateRequirement(s))
|
|
911
|
-
throw new Error("Invalid requirement received from server");
|
|
912
|
-
return g(s), a((b) => ({ ...b, status: "idle" })), s;
|
|
913
|
-
} catch (s) {
|
|
914
|
-
const b = fe(s, "Failed to fetch requirement");
|
|
915
|
-
throw a({
|
|
916
|
-
status: "error",
|
|
917
|
-
error: b,
|
|
918
|
-
transactionId: null
|
|
919
|
-
}), s;
|
|
920
|
-
}
|
|
921
|
-
},
|
|
922
|
-
[t]
|
|
923
|
-
), h = M(
|
|
924
|
-
async (d, s, b, C, _ = "regular") => {
|
|
925
|
-
if (!!d.extra?.feePayer) {
|
|
926
|
-
console.log("⚡ [useX402Payment] GASLESS FLOW - Backend pays fees"), console.log("🔨 [useX402Payment] Requesting backend to build gasless transaction");
|
|
927
|
-
const { transaction: N, blockhash: B } = await t.buildGaslessTransaction({
|
|
928
|
-
resourceId: s,
|
|
929
|
-
userWallet: n.toString(),
|
|
930
|
-
feePayer: d.extra.feePayer,
|
|
931
|
-
couponCode: b
|
|
932
|
-
});
|
|
933
|
-
console.log("📦 [useX402Payment] Deserializing transaction from backend");
|
|
934
|
-
const y = e.deserializeTransaction(N);
|
|
935
|
-
console.log("✍️ [useX402Payment] Requesting wallet to partially sign (transfer authority only)");
|
|
936
|
-
const D = await e.partiallySignTransaction({
|
|
937
|
-
transaction: y,
|
|
938
|
-
signTransaction: r,
|
|
939
|
-
blockhash: B
|
|
940
|
-
});
|
|
941
|
-
console.log("📤 [useX402Payment] Submitting partially-signed transaction to backend");
|
|
942
|
-
const v = await t.submitGaslessTransaction({
|
|
943
|
-
resource: s,
|
|
944
|
-
partialTx: D,
|
|
945
|
-
couponCode: b,
|
|
946
|
-
metadata: C,
|
|
947
|
-
resourceType: _,
|
|
948
|
-
requirement: d
|
|
949
|
-
});
|
|
950
|
-
return v.success && v.settlement && f(v.settlement), v;
|
|
951
|
-
} else {
|
|
952
|
-
const N = await e.buildTransaction({
|
|
953
|
-
requirement: d,
|
|
954
|
-
payerPublicKey: n
|
|
955
|
-
}), B = await e.signTransaction({
|
|
956
|
-
transaction: N,
|
|
957
|
-
signTransaction: r
|
|
958
|
-
}), y = e.buildPaymentPayload({
|
|
959
|
-
requirement: d,
|
|
960
|
-
signedTx: B,
|
|
961
|
-
payerPublicKey: n
|
|
962
|
-
}), D = await t.submitPayment({
|
|
963
|
-
resource: s,
|
|
964
|
-
payload: y,
|
|
965
|
-
couponCode: b,
|
|
966
|
-
metadata: C,
|
|
967
|
-
resourceType: _
|
|
968
|
-
});
|
|
969
|
-
return D.success && D.settlement && f(D.settlement), D;
|
|
970
|
-
}
|
|
971
|
-
},
|
|
972
|
-
[n, r, t, e]
|
|
973
|
-
), l = M(
|
|
974
|
-
async (d, s, b) => {
|
|
975
|
-
if (m.current)
|
|
976
|
-
return { success: !1, error: "Payment already in progress" };
|
|
977
|
-
const C = c();
|
|
978
|
-
if (!C.valid)
|
|
979
|
-
return { success: !1, error: C.error };
|
|
980
|
-
m.current = !0, a({
|
|
981
|
-
status: "loading",
|
|
982
|
-
error: null,
|
|
983
|
-
transactionId: null
|
|
984
|
-
});
|
|
985
|
-
try {
|
|
986
|
-
console.log("🔍 [useX402Payment] Fetching fresh quote for resource:", d);
|
|
987
|
-
const _ = await t.requestQuote({ resource: d, couponCode: s });
|
|
988
|
-
console.log("✅ [useX402Payment] Got quote:", { payTo: _.payTo, amount: _.maxAmountRequired }), g(_), console.log("⚙️ [useX402Payment] Executing payment flow with fresh requirement");
|
|
989
|
-
const P = await h(_, d, s, b, "regular");
|
|
990
|
-
return P.success ? a({
|
|
991
|
-
status: "success",
|
|
992
|
-
error: null,
|
|
993
|
-
transactionId: P.transactionId || "payment-success"
|
|
994
|
-
}) : a({
|
|
995
|
-
status: "error",
|
|
996
|
-
error: P.error || "Payment failed",
|
|
997
|
-
transactionId: null
|
|
998
|
-
}), P;
|
|
999
|
-
} catch (_) {
|
|
1000
|
-
const P = fe(_, "Payment failed");
|
|
1001
|
-
return a({
|
|
1002
|
-
status: "error",
|
|
1003
|
-
error: P,
|
|
1004
|
-
transactionId: null
|
|
1005
|
-
}), { success: !1, error: P };
|
|
1006
|
-
} finally {
|
|
1007
|
-
m.current = !1;
|
|
1008
|
-
}
|
|
1009
|
-
},
|
|
1010
|
-
[c, t, h]
|
|
1011
|
-
), j = M(
|
|
1012
|
-
async (d, s, b) => {
|
|
1013
|
-
if (m.current)
|
|
1014
|
-
return { success: !1, error: "Payment already in progress" };
|
|
1015
|
-
const C = c();
|
|
1016
|
-
if (!C.valid)
|
|
1017
|
-
return { success: !1, error: C.error };
|
|
1018
|
-
m.current = !0, a({
|
|
1019
|
-
status: "loading",
|
|
1020
|
-
error: null,
|
|
1021
|
-
transactionId: null
|
|
1022
|
-
});
|
|
1023
|
-
try {
|
|
1024
|
-
const _ = ae(d), P = await t.requestCartQuote({
|
|
1025
|
-
items: _,
|
|
1026
|
-
metadata: s,
|
|
1027
|
-
couponCode: b
|
|
1028
|
-
}), N = P.cartId, B = P.quote;
|
|
1029
|
-
if (!t.validateRequirement(B))
|
|
1030
|
-
throw new Error("Invalid cart quote received from server");
|
|
1031
|
-
g(B);
|
|
1032
|
-
const y = await h(B, N, b, s, "cart");
|
|
1033
|
-
return y.success ? a({
|
|
1034
|
-
status: "success",
|
|
1035
|
-
error: null,
|
|
1036
|
-
transactionId: y.transactionId || "cart-payment-success"
|
|
1037
|
-
}) : a({
|
|
1038
|
-
status: "error",
|
|
1039
|
-
error: y.error || "Cart payment failed",
|
|
1040
|
-
transactionId: null
|
|
1041
|
-
}), y;
|
|
1042
|
-
} catch (_) {
|
|
1043
|
-
const P = fe(_, "Cart payment failed");
|
|
1044
|
-
return a({
|
|
1045
|
-
status: "error",
|
|
1046
|
-
error: P,
|
|
1047
|
-
transactionId: null
|
|
1048
|
-
}), { success: !1, error: P };
|
|
1049
|
-
} finally {
|
|
1050
|
-
m.current = !1;
|
|
1051
|
-
}
|
|
1052
|
-
},
|
|
1053
|
-
[c, t, h]
|
|
1054
|
-
), E = M(() => {
|
|
1055
|
-
a({
|
|
1056
|
-
status: "idle",
|
|
1057
|
-
error: null,
|
|
1058
|
-
transactionId: null
|
|
1059
|
-
}), g(null), f(null), m.current = !1;
|
|
1060
|
-
}, []);
|
|
1061
|
-
return {
|
|
1062
|
-
...o,
|
|
1063
|
-
requirement: w,
|
|
1064
|
-
settlement: I,
|
|
1065
|
-
fetchQuote: u,
|
|
1066
|
-
processPayment: l,
|
|
1067
|
-
processCartPayment: j,
|
|
1068
|
-
reset: E
|
|
1069
|
-
};
|
|
1070
|
-
}
|
|
1071
|
-
function dt({
|
|
1072
|
-
resource: t,
|
|
1073
|
-
items: e,
|
|
1074
|
-
label: n,
|
|
1075
|
-
disabled: r = !1,
|
|
1076
|
-
onAttempt: o,
|
|
1077
|
-
onSuccess: a,
|
|
1078
|
-
onError: w,
|
|
1079
|
-
className: g = "",
|
|
1080
|
-
testPageUrl: I,
|
|
1081
|
-
hideMessages: f = !1,
|
|
1082
|
-
metadata: m,
|
|
1083
|
-
couponCode: c
|
|
1084
|
-
}) {
|
|
1085
|
-
const { connected: u, connecting: h, connect: l, disconnect: j, select: E, wallets: d, wallet: s, publicKey: b } = Me(), { status: C, error: _, transactionId: P, processPayment: N, processCartPayment: B } = ut(), y = le(), { solanaError: D } = ce(), { isCartMode: v, effectiveResource: k } = Ce(t, e), { t: $, translations: X } = ue(), L = n || $("ui.pay_with_crypto"), T = _ && typeof _ != "string" ? _?.code ?? null : null, q = D && typeof D != "string" ? D?.code ?? null : null, R = (i) => {
|
|
1086
|
-
if (!i || !X) return "";
|
|
1087
|
-
const x = X.errors[i];
|
|
1088
|
-
return x ? x.action ? `${x.message} ${x.action}` : x.message : "";
|
|
1089
|
-
}, K = _ ? typeof _ == "string" ? _ : R(T) : null, Pe = D ? typeof D == "string" ? D : R(q) : null, ve = te(N), ke = te(B);
|
|
1090
|
-
z(() => {
|
|
1091
|
-
ve.current = N, ke.current = B;
|
|
1092
|
-
}, [N, B]);
|
|
1093
|
-
const $e = A(
|
|
1094
|
-
() => d.map((i) => `${i.adapter.name}-${i.readyState}`).join(","),
|
|
1095
|
-
[d]
|
|
1096
|
-
), ne = A(
|
|
1097
|
-
() => d.filter(
|
|
1098
|
-
({ readyState: i }) => i === je.Installed || i === je.Loadable
|
|
1099
|
-
),
|
|
1100
|
-
// walletStateKey is derived from availableWallets, so we only need availableWallets as dependency
|
|
1101
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1102
|
-
[$e]
|
|
1103
|
-
);
|
|
1104
|
-
z(() => {
|
|
1105
|
-
if (C === "success" && P) {
|
|
1106
|
-
const i = v && e ? ee(e) : void 0;
|
|
1107
|
-
_e("crypto", P, k, i), a && a(P);
|
|
1108
|
-
}
|
|
1109
|
-
}, [C, P, a, v, e, k]), z(() => {
|
|
1110
|
-
if (C === "error" && _) {
|
|
1111
|
-
const i = v && e ? ee(e) : void 0;
|
|
1112
|
-
U("crypto", _, k, i), w && w(_);
|
|
1113
|
-
}
|
|
1114
|
-
}, [C, _, w, v, e, k]);
|
|
1115
|
-
const Ie = typeof window < "u" && window.top !== window.self, [xe, V] = O(!1), [Se, de] = O(!1), [Z, Y] = O(null), J = D;
|
|
1116
|
-
z(() => {
|
|
1117
|
-
let i = !1;
|
|
1118
|
-
return i || (async () => {
|
|
1119
|
-
if (Se && s && !u && !h) {
|
|
1120
|
-
p().debug("[CryptoButton] Wallet detected, attempting auto-connect:", s.adapter.name), de(!1), De(s.adapter.name);
|
|
1121
|
-
try {
|
|
1122
|
-
await l(), i || p().debug("[CryptoButton] Auto-connect successful");
|
|
1123
|
-
} catch (W) {
|
|
1124
|
-
if (!i) {
|
|
1125
|
-
p().error("[CryptoButton] Auto-connect failed:", W);
|
|
1126
|
-
const re = W instanceof Error ? W.message : "Failed to connect wallet";
|
|
1127
|
-
me(re, s.adapter.name), Y(null);
|
|
1128
|
-
}
|
|
1129
|
-
}
|
|
1130
|
-
}
|
|
1131
|
-
})(), () => {
|
|
1132
|
-
i = !0;
|
|
1133
|
-
};
|
|
1134
|
-
}, [s, Se, u, h, l]), z(() => {
|
|
1135
|
-
if (p().debug("[CryptoButton] Payment useEffect triggered", {
|
|
1136
|
-
connected: u,
|
|
1137
|
-
hasPendingPayment: !!Z,
|
|
1138
|
-
hasPublicKey: !!b,
|
|
1139
|
-
pendingPaymentType: Z?.type
|
|
1140
|
-
}), u && Z && b && s) {
|
|
1141
|
-
nt(s.adapter.name, b.toString()), p().debug("[CryptoButton] All conditions met! Processing pending payment:", Z);
|
|
1142
|
-
const i = Z;
|
|
1143
|
-
Y(null), V(!1);
|
|
1144
|
-
const x = i.type === "cart" && i.items ? ee(i.items) : void 0;
|
|
1145
|
-
ie("crypto", i.resource, x), i.type === "cart" && i.items ? (p().debug("[CryptoButton] Auto-processing cart payment"), ke.current(i.items, i.metadata, i.couponCode)) : i.type === "single" && i.resource && (p().debug("[CryptoButton] Auto-processing single payment"), ve.current(i.resource, i.couponCode, i.metadata));
|
|
1146
|
-
}
|
|
1147
|
-
}, [u, Z, b, s]);
|
|
1148
|
-
const Ee = M(async () => {
|
|
1149
|
-
p().debug("[CryptoButton] executePaymentFlow called", {
|
|
1150
|
-
connected: u,
|
|
1151
|
-
wallet: s?.adapter.name,
|
|
1152
|
-
couponCode: c,
|
|
1153
|
-
isCartMode: v,
|
|
1154
|
-
hasItems: !!e,
|
|
1155
|
-
effectiveResource: k
|
|
1156
|
-
});
|
|
1157
|
-
const i = v && e ? ee(e) : void 0;
|
|
1158
|
-
if (be("crypto", k, i), o && o("crypto"), J) {
|
|
1159
|
-
p().error("[CryptoButton] Solana dependencies missing:", J), U("crypto", J, k, i), w && w(J);
|
|
1160
|
-
return;
|
|
1161
|
-
}
|
|
1162
|
-
if (Ie) {
|
|
1163
|
-
const x = I || window.location.href;
|
|
1164
|
-
try {
|
|
1165
|
-
if (new URL(x, window.location.origin).origin !== window.location.origin)
|
|
1166
|
-
throw p().error("[CryptoButton] Blocked attempt to open external URL:", x), new Error("Cannot open external URLs from embedded context");
|
|
1167
|
-
window.open(x, "_blank", "noopener,noreferrer");
|
|
1168
|
-
} catch (W) {
|
|
1169
|
-
throw p().error("[CryptoButton] URL validation failed:", W), W;
|
|
1170
|
-
}
|
|
1171
|
-
return;
|
|
1172
|
-
}
|
|
1173
|
-
if (u)
|
|
1174
|
-
ie("crypto", k, i), v && e ? (p().debug("[CryptoButton] Processing cart payment with coupon:", c), await B(e, m, c)) : k && (p().debug("[CryptoButton] Processing single payment with coupon:", c), await N(k, c, m));
|
|
1175
|
-
else {
|
|
1176
|
-
let x = !1;
|
|
1177
|
-
if (v && e ? (p().debug("[CryptoButton] Setting pending cart payment with coupon:", c), Y({ type: "cart", items: e, metadata: m, couponCode: c }), x = !0) : k && (p().debug("[CryptoButton] Setting pending single payment with coupon:", c), Y({ type: "single", resource: k, metadata: m, couponCode: c }), x = !0), !x) {
|
|
1178
|
-
p().error("[CryptoButton] No valid payment to process");
|
|
1179
|
-
return;
|
|
1180
|
-
}
|
|
1181
|
-
try {
|
|
1182
|
-
if (s)
|
|
1183
|
-
p().debug("[CryptoButton] Wallet already selected, connecting:", s.adapter.name), De(s.adapter.name), await l();
|
|
1184
|
-
else {
|
|
1185
|
-
if (p().debug(
|
|
1186
|
-
"[CryptoButton] No wallet selected, showing selector. Available wallets:",
|
|
1187
|
-
ne.map((W) => W.adapter.name)
|
|
1188
|
-
), ne.length === 0) {
|
|
1189
|
-
Y(null);
|
|
1190
|
-
const W = "No wallets available";
|
|
1191
|
-
throw me(W), new Error(W);
|
|
1192
|
-
}
|
|
1193
|
-
V(!0);
|
|
1194
|
-
}
|
|
1195
|
-
} catch (W) {
|
|
1196
|
-
Y(null);
|
|
1197
|
-
const re = W instanceof Error ? W.message : "Failed to connect wallet";
|
|
1198
|
-
p().error("[CryptoButton] Connection error:", re), me(re, s?.adapter.name);
|
|
1199
|
-
}
|
|
1200
|
-
}
|
|
1201
|
-
}, [u, s, c, v, e, k, Ie, I, ne, l, m, B, N, J, o, w]), Te = A(() => v && e ? `crypto-cart-${e.map((i) => i.resource).join("-")}` : `crypto-${k || "unknown"}`, [v, e, k]), We = A(
|
|
1202
|
-
() => we(Te, Ee, {
|
|
1203
|
-
cooldownMs: 200,
|
|
1204
|
-
deduplicationWindowMs: 0
|
|
1205
|
-
// MUST be 0 for crypto - each payment needs fresh transaction
|
|
1206
|
-
}),
|
|
1207
|
-
[Te, Ee]
|
|
1208
|
-
), Re = C === "loading", Ae = r || Re || h || !!J, Oe = Re ? $("ui.processing") : L, ze = M(async () => {
|
|
1209
|
-
try {
|
|
1210
|
-
de(!1), u && await j(), E(null), V(!0);
|
|
1211
|
-
} catch (i) {
|
|
1212
|
-
p().error("Failed to change wallet:", i);
|
|
1213
|
-
}
|
|
1214
|
-
}, [u, j, E]), Fe = M((i) => {
|
|
1215
|
-
p().debug("[CryptoButton] Wallet clicked:", i), V(!1), E(i), de(!0), p().debug("[CryptoButton] Wallet selected, useEffect will auto-connect");
|
|
1216
|
-
}, [E]), Ye = M(async () => {
|
|
1217
|
-
try {
|
|
1218
|
-
if (await j(), Y(null), typeof window < "u" && window.localStorage)
|
|
1219
|
-
try {
|
|
1220
|
-
window.localStorage.removeItem("walletName");
|
|
1221
|
-
} catch (i) {
|
|
1222
|
-
i instanceof Error && i.name === "QuotaExceededError" ? p().warn("localStorage quota exceeded when removing wallet preference") : p().error("Failed to clear wallet preference from localStorage:", i);
|
|
1223
|
-
}
|
|
1224
|
-
} catch (i) {
|
|
1225
|
-
p().error("Failed to disconnect wallet:", i);
|
|
1226
|
-
}
|
|
1227
|
-
}, [j]);
|
|
1228
|
-
return /* @__PURE__ */ H("div", { className: y.unstyled ? g : `${y.className} cedros-theme__crypto-button ${g || ""}`, style: y.unstyled ? {} : y.style, children: [
|
|
1229
|
-
/* @__PURE__ */ S(
|
|
1230
|
-
"button",
|
|
1231
|
-
{
|
|
1232
|
-
onClick: We,
|
|
1233
|
-
disabled: Ae,
|
|
1234
|
-
className: y.unstyled ? g : "cedros-theme__button cedros-theme__crypto",
|
|
1235
|
-
type: "button",
|
|
1236
|
-
children: Oe
|
|
1237
|
-
}
|
|
1238
|
-
),
|
|
1239
|
-
xe && !f && /* @__PURE__ */ S(
|
|
1240
|
-
"div",
|
|
1241
|
-
{
|
|
1242
|
-
className: "cedros-modal-overlay",
|
|
1243
|
-
style: {
|
|
1244
|
-
position: "fixed",
|
|
1245
|
-
top: 0,
|
|
1246
|
-
left: 0,
|
|
1247
|
-
right: 0,
|
|
1248
|
-
bottom: 0,
|
|
1249
|
-
backgroundColor: y.tokens.modalOverlay,
|
|
1250
|
-
display: "flex",
|
|
1251
|
-
alignItems: "center",
|
|
1252
|
-
justifyContent: "center",
|
|
1253
|
-
zIndex: 9999,
|
|
1254
|
-
padding: "1rem"
|
|
1255
|
-
},
|
|
1256
|
-
onClick: () => V(!1),
|
|
1257
|
-
children: /* @__PURE__ */ H(
|
|
1258
|
-
"div",
|
|
1259
|
-
{
|
|
1260
|
-
className: "cedros-modal-content",
|
|
1261
|
-
style: {
|
|
1262
|
-
backgroundColor: y.tokens.modalBackground,
|
|
1263
|
-
borderRadius: "12px",
|
|
1264
|
-
padding: "2rem",
|
|
1265
|
-
maxWidth: "400px",
|
|
1266
|
-
width: "100%",
|
|
1267
|
-
boxShadow: "0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04)",
|
|
1268
|
-
border: `1px solid ${y.tokens.modalBorder}`
|
|
1269
|
-
},
|
|
1270
|
-
onClick: (i) => i.stopPropagation(),
|
|
1271
|
-
children: [
|
|
1272
|
-
/* @__PURE__ */ H(
|
|
1273
|
-
"div",
|
|
1274
|
-
{
|
|
1275
|
-
style: {
|
|
1276
|
-
display: "flex",
|
|
1277
|
-
justifyContent: "space-between",
|
|
1278
|
-
alignItems: "center",
|
|
1279
|
-
marginBottom: "1.5rem"
|
|
1280
|
-
},
|
|
1281
|
-
children: [
|
|
1282
|
-
/* @__PURE__ */ S(
|
|
1283
|
-
"h3",
|
|
1284
|
-
{
|
|
1285
|
-
style: {
|
|
1286
|
-
margin: 0,
|
|
1287
|
-
fontSize: "1.25rem",
|
|
1288
|
-
fontWeight: 600,
|
|
1289
|
-
color: y.tokens.surfaceText
|
|
1290
|
-
},
|
|
1291
|
-
children: $("wallet.select_wallet")
|
|
1292
|
-
}
|
|
1293
|
-
),
|
|
1294
|
-
/* @__PURE__ */ S(
|
|
1295
|
-
"button",
|
|
1296
|
-
{
|
|
1297
|
-
onClick: () => V(!1),
|
|
1298
|
-
style: He(y.tokens.surfaceText),
|
|
1299
|
-
"aria-label": "Close modal",
|
|
1300
|
-
type: "button",
|
|
1301
|
-
children: "×"
|
|
1302
|
-
}
|
|
1303
|
-
)
|
|
1304
|
-
]
|
|
1305
|
-
}
|
|
1306
|
-
),
|
|
1307
|
-
/* @__PURE__ */ S("div", { style: { display: "flex", flexDirection: "column", gap: "0.75rem" }, children: ne.map((i) => /* @__PURE__ */ H(
|
|
1308
|
-
"button",
|
|
1309
|
-
{
|
|
1310
|
-
onClick: () => Fe(i.adapter.name),
|
|
1311
|
-
style: {
|
|
1312
|
-
width: "100%",
|
|
1313
|
-
padding: "1rem",
|
|
1314
|
-
backgroundColor: y.tokens.surfaceBackground,
|
|
1315
|
-
border: `1px solid ${y.tokens.surfaceBorder}`,
|
|
1316
|
-
borderRadius: "0.5rem",
|
|
1317
|
-
cursor: "pointer",
|
|
1318
|
-
fontSize: "1rem",
|
|
1319
|
-
textAlign: "left",
|
|
1320
|
-
color: y.tokens.surfaceText,
|
|
1321
|
-
display: "flex",
|
|
1322
|
-
alignItems: "center",
|
|
1323
|
-
gap: "1rem",
|
|
1324
|
-
transition: "all 0.2s ease"
|
|
1325
|
-
},
|
|
1326
|
-
onMouseEnter: (x) => {
|
|
1327
|
-
x.currentTarget.style.backgroundColor = y.tokens.modalBackground, x.currentTarget.style.borderColor = y.tokens.surfaceText, x.currentTarget.style.transform = "translateY(-2px)";
|
|
1328
|
-
},
|
|
1329
|
-
onMouseLeave: (x) => {
|
|
1330
|
-
x.currentTarget.style.backgroundColor = y.tokens.surfaceBackground, x.currentTarget.style.borderColor = y.tokens.surfaceBorder, x.currentTarget.style.transform = "translateY(0)";
|
|
1331
|
-
},
|
|
1332
|
-
type: "button",
|
|
1333
|
-
children: [
|
|
1334
|
-
/* @__PURE__ */ S(Ue, { wallet: i, style: { width: "24px", height: "24px" } }),
|
|
1335
|
-
/* @__PURE__ */ S("span", { style: { fontWeight: 500 }, children: i.adapter.name })
|
|
1336
|
-
]
|
|
1337
|
-
},
|
|
1338
|
-
i.adapter.name
|
|
1339
|
-
)) })
|
|
1340
|
-
]
|
|
1341
|
-
}
|
|
1342
|
-
)
|
|
1343
|
-
}
|
|
1344
|
-
),
|
|
1345
|
-
u && !f && !xe && /* @__PURE__ */ H("div", { style: {
|
|
1346
|
-
display: "flex",
|
|
1347
|
-
justifyContent: "space-between",
|
|
1348
|
-
marginTop: "0.5rem",
|
|
1349
|
-
fontSize: "0.75rem",
|
|
1350
|
-
color: y.tokens.surfaceText,
|
|
1351
|
-
opacity: 0.7
|
|
1352
|
-
}, children: [
|
|
1353
|
-
/* @__PURE__ */ S(
|
|
1354
|
-
"button",
|
|
1355
|
-
{
|
|
1356
|
-
onClick: ze,
|
|
1357
|
-
style: {
|
|
1358
|
-
background: "none",
|
|
1359
|
-
border: "none",
|
|
1360
|
-
padding: 0,
|
|
1361
|
-
color: "inherit",
|
|
1362
|
-
textDecoration: "none",
|
|
1363
|
-
cursor: "pointer",
|
|
1364
|
-
fontSize: "inherit"
|
|
1365
|
-
},
|
|
1366
|
-
type: "button",
|
|
1367
|
-
children: "Change Wallet"
|
|
1368
|
-
}
|
|
1369
|
-
),
|
|
1370
|
-
/* @__PURE__ */ S(
|
|
1371
|
-
"button",
|
|
1372
|
-
{
|
|
1373
|
-
onClick: Ye,
|
|
1374
|
-
style: {
|
|
1375
|
-
background: "none",
|
|
1376
|
-
border: "none",
|
|
1377
|
-
padding: 0,
|
|
1378
|
-
color: "inherit",
|
|
1379
|
-
textDecoration: "none",
|
|
1380
|
-
cursor: "pointer",
|
|
1381
|
-
fontSize: "inherit"
|
|
1382
|
-
},
|
|
1383
|
-
type: "button",
|
|
1384
|
-
children: $("ui.disconnect")
|
|
1385
|
-
}
|
|
1386
|
-
)
|
|
1387
|
-
] }),
|
|
1388
|
-
!f && Pe && /* @__PURE__ */ S("div", { className: y.unstyled ? "" : "cedros-theme__error", children: Pe }),
|
|
1389
|
-
!f && K && /* @__PURE__ */ S("div", { className: y.unstyled ? "" : "cedros-theme__error", children: K }),
|
|
1390
|
-
!f && P && /* @__PURE__ */ S("div", { className: y.unstyled ? "" : "cedros-theme__success", children: $("ui.payment_successful") })
|
|
1391
|
-
] });
|
|
1392
|
-
}
|
|
1393
|
-
function ft() {
|
|
1394
|
-
const { creditsManager: t } = ce(), [e, n] = O({
|
|
1395
|
-
status: "idle",
|
|
1396
|
-
error: null,
|
|
1397
|
-
transactionId: null,
|
|
1398
|
-
requirement: null,
|
|
1399
|
-
holdId: null
|
|
1400
|
-
}), r = te(!1), o = M(
|
|
1401
|
-
async (f, m) => {
|
|
1402
|
-
n((c) => ({
|
|
1403
|
-
...c,
|
|
1404
|
-
status: "loading",
|
|
1405
|
-
error: null
|
|
1406
|
-
}));
|
|
1407
|
-
try {
|
|
1408
|
-
const c = await t.requestQuote(f, m);
|
|
1409
|
-
return n((u) => ({
|
|
1410
|
-
...u,
|
|
1411
|
-
status: "idle",
|
|
1412
|
-
requirement: c
|
|
1413
|
-
})), c;
|
|
1414
|
-
} catch (c) {
|
|
1415
|
-
const u = c instanceof Error ? c.message : "Failed to fetch credits quote";
|
|
1416
|
-
return n((h) => ({
|
|
1417
|
-
...h,
|
|
1418
|
-
status: "error",
|
|
1419
|
-
error: u
|
|
1420
|
-
})), null;
|
|
1421
|
-
}
|
|
1422
|
-
},
|
|
1423
|
-
[t]
|
|
1424
|
-
), a = M(
|
|
1425
|
-
async (f, m) => {
|
|
1426
|
-
n((c) => ({
|
|
1427
|
-
...c,
|
|
1428
|
-
status: "loading",
|
|
1429
|
-
error: null
|
|
1430
|
-
}));
|
|
1431
|
-
try {
|
|
1432
|
-
const c = ae(f), u = await t.requestCartQuote(c, m);
|
|
1433
|
-
return n((h) => ({
|
|
1434
|
-
...h,
|
|
1435
|
-
status: "idle"
|
|
1436
|
-
})), u;
|
|
1437
|
-
} catch (c) {
|
|
1438
|
-
const u = c instanceof Error ? c.message : "Failed to fetch cart credits quote";
|
|
1439
|
-
return n((h) => ({
|
|
1440
|
-
...h,
|
|
1441
|
-
status: "error",
|
|
1442
|
-
error: u
|
|
1443
|
-
})), null;
|
|
1444
|
-
}
|
|
1445
|
-
},
|
|
1446
|
-
[t]
|
|
1447
|
-
), w = M(
|
|
1448
|
-
async (f, m, c, u) => {
|
|
1449
|
-
if (r.current)
|
|
1450
|
-
return { success: !1, error: "Payment already in progress" };
|
|
1451
|
-
r.current = !0, n({
|
|
1452
|
-
status: "loading",
|
|
1453
|
-
error: null,
|
|
1454
|
-
transactionId: null,
|
|
1455
|
-
requirement: null,
|
|
1456
|
-
holdId: null
|
|
1457
|
-
});
|
|
1458
|
-
try {
|
|
1459
|
-
const h = await t.processPayment(f, m, c, u);
|
|
1460
|
-
return n({
|
|
1461
|
-
status: h.success ? "success" : "error",
|
|
1462
|
-
error: h.success ? null : h.error || "Credits payment failed",
|
|
1463
|
-
transactionId: h.success && h.transactionId || null,
|
|
1464
|
-
requirement: null,
|
|
1465
|
-
holdId: null
|
|
1466
|
-
}), h;
|
|
1467
|
-
} finally {
|
|
1468
|
-
r.current = !1;
|
|
1469
|
-
}
|
|
1470
|
-
},
|
|
1471
|
-
[t]
|
|
1472
|
-
), g = M(
|
|
1473
|
-
async (f, m, c, u) => {
|
|
1474
|
-
if (r.current)
|
|
1475
|
-
return { success: !1, error: "Payment already in progress" };
|
|
1476
|
-
r.current = !0, n({
|
|
1477
|
-
status: "loading",
|
|
1478
|
-
error: null,
|
|
1479
|
-
transactionId: null,
|
|
1480
|
-
requirement: null,
|
|
1481
|
-
holdId: null
|
|
1482
|
-
});
|
|
1483
|
-
try {
|
|
1484
|
-
const h = ae(f), l = await t.requestCartQuote(h, c);
|
|
1485
|
-
if (!l)
|
|
1486
|
-
return n({
|
|
1487
|
-
status: "error",
|
|
1488
|
-
error: "Credits payment not available for this cart",
|
|
1489
|
-
transactionId: null,
|
|
1490
|
-
requirement: null,
|
|
1491
|
-
holdId: null
|
|
1492
|
-
}), { success: !1, error: "Credits payment not available" };
|
|
1493
|
-
const E = (await t.createCartHold({
|
|
1494
|
-
cartId: l.cartId,
|
|
1495
|
-
authToken: m
|
|
1496
|
-
})).holdId;
|
|
1497
|
-
n((s) => ({
|
|
1498
|
-
...s,
|
|
1499
|
-
holdId: E
|
|
1500
|
-
}));
|
|
1501
|
-
const d = await t.authorizeCartPayment({
|
|
1502
|
-
cartId: l.cartId,
|
|
1503
|
-
holdId: E,
|
|
1504
|
-
authToken: m,
|
|
1505
|
-
metadata: u
|
|
1506
|
-
});
|
|
1507
|
-
return n({
|
|
1508
|
-
status: d.success ? "success" : "error",
|
|
1509
|
-
error: d.success ? null : d.error || "Cart credits payment failed",
|
|
1510
|
-
transactionId: d.success && d.transactionId || null,
|
|
1511
|
-
requirement: null,
|
|
1512
|
-
holdId: null
|
|
1513
|
-
}), {
|
|
1514
|
-
success: d.success,
|
|
1515
|
-
transactionId: d.transactionId,
|
|
1516
|
-
error: d.error
|
|
1517
|
-
};
|
|
1518
|
-
} catch (h) {
|
|
1519
|
-
const l = h instanceof Error ? h.message : "Cart credits payment failed";
|
|
1520
|
-
return n({
|
|
1521
|
-
status: "error",
|
|
1522
|
-
error: l,
|
|
1523
|
-
transactionId: null,
|
|
1524
|
-
requirement: null,
|
|
1525
|
-
holdId: null
|
|
1526
|
-
}), { success: !1, error: l };
|
|
1527
|
-
} finally {
|
|
1528
|
-
r.current = !1;
|
|
1529
|
-
}
|
|
1530
|
-
},
|
|
1531
|
-
[t]
|
|
1532
|
-
), I = M(() => {
|
|
1533
|
-
n({
|
|
1534
|
-
status: "idle",
|
|
1535
|
-
error: null,
|
|
1536
|
-
transactionId: null,
|
|
1537
|
-
requirement: null,
|
|
1538
|
-
holdId: null
|
|
1539
|
-
}), r.current = !1;
|
|
1540
|
-
}, []);
|
|
1541
|
-
return {
|
|
1542
|
-
...e,
|
|
1543
|
-
fetchQuote: o,
|
|
1544
|
-
fetchCartQuote: a,
|
|
1545
|
-
processPayment: w,
|
|
1546
|
-
processCartPayment: g,
|
|
1547
|
-
reset: I
|
|
1548
|
-
};
|
|
1549
|
-
}
|
|
1550
|
-
function mt({
|
|
1551
|
-
resource: t,
|
|
1552
|
-
items: e,
|
|
1553
|
-
authToken: n,
|
|
1554
|
-
metadata: r,
|
|
1555
|
-
couponCode: o,
|
|
1556
|
-
label: a,
|
|
1557
|
-
disabled: w = !1,
|
|
1558
|
-
onAttempt: g,
|
|
1559
|
-
onSuccess: I,
|
|
1560
|
-
onError: f,
|
|
1561
|
-
className: m = ""
|
|
1562
|
-
}) {
|
|
1563
|
-
const { status: c, error: u, transactionId: h, processPayment: l, processCartPayment: j } = ft(), E = le(), { isCartMode: d, effectiveResource: s } = Ce(t, e), { t: b, translations: C } = ue(), _ = a || b("ui.pay_with_credits") || "Pay with Credits", P = E.unstyled ? m : `${E.className} cedros-theme__credits-button ${m}`.trim(), N = u && typeof u != "string" ? u?.code ?? null : null, y = u ? typeof u == "string" ? u : ((L) => {
|
|
1564
|
-
if (!L || !C) return "";
|
|
1565
|
-
const T = C.errors[L];
|
|
1566
|
-
return T ? T.action ? `${T.message} ${T.action}` : T.message : "";
|
|
1567
|
-
})(N) : null, D = M(async () => {
|
|
1568
|
-
p().debug("[CreditsButton] executePayment");
|
|
1569
|
-
const L = d && e ? ee(e) : void 0;
|
|
1570
|
-
if (be("credits", s, L), g && g("credits"), !n) {
|
|
1571
|
-
const q = "Authentication required: please log in to pay with credits";
|
|
1572
|
-
p().error("[CreditsButton]", q), U("credits", q, s, L), f && f(q);
|
|
1573
|
-
return;
|
|
1574
|
-
}
|
|
1575
|
-
if (!d && !s) {
|
|
1576
|
-
const q = "Invalid payment configuration: missing resource";
|
|
1577
|
-
p().error("[CreditsButton]", q), U("credits", q, s, L), f && f(q);
|
|
1578
|
-
return;
|
|
1579
|
-
}
|
|
1580
|
-
let T;
|
|
1581
|
-
ie("credits", s, L), d && e ? (p().debug("[CreditsButton] Processing cart checkout"), T = await j(e, n, o, r)) : s && (p().debug("[CreditsButton] Processing single payment"), T = await l(s, n, o, r)), T && T.success && T.transactionId ? (_e("credits", T.transactionId, s, L), I && I(T.transactionId)) : T && !T.success && T.error && (U("credits", T.error, s, L), f && f(T.error));
|
|
1582
|
-
}, [
|
|
1583
|
-
n,
|
|
1584
|
-
d,
|
|
1585
|
-
s,
|
|
1586
|
-
e,
|
|
1587
|
-
o,
|
|
1588
|
-
r,
|
|
1589
|
-
l,
|
|
1590
|
-
j,
|
|
1591
|
-
g,
|
|
1592
|
-
I,
|
|
1593
|
-
f
|
|
1594
|
-
]), v = A(() => d && e ? `credits-cart-${e.map((L) => L.resource).join("-")}` : `credits-${s || "unknown"}`, [d, e, s]), k = A(
|
|
1595
|
-
() => we(v, D),
|
|
1596
|
-
[v, D]
|
|
1597
|
-
), $ = c === "loading", X = w || $;
|
|
1598
|
-
return /* @__PURE__ */ H("div", { className: P, style: E.unstyled ? {} : E.style, children: [
|
|
1599
|
-
/* @__PURE__ */ S(
|
|
1600
|
-
"button",
|
|
1601
|
-
{
|
|
1602
|
-
onClick: k,
|
|
1603
|
-
disabled: X,
|
|
1604
|
-
className: E.unstyled ? m : "cedros-theme__button cedros-theme__credits",
|
|
1605
|
-
type: "button",
|
|
1606
|
-
children: $ ? b("ui.processing") : _
|
|
1607
|
-
}
|
|
1608
|
-
),
|
|
1609
|
-
y && /* @__PURE__ */ S("div", { className: E.unstyled ? "" : "cedros-theme__error", children: y }),
|
|
1610
|
-
h && /* @__PURE__ */ S("div", { className: E.unstyled ? "" : "cedros-theme__success", children: b("ui.payment_successful") })
|
|
1611
|
-
] });
|
|
1612
|
-
}
|
|
1613
|
-
const Rt = ({
|
|
1614
|
-
isOpen: t,
|
|
1615
|
-
onClose: e,
|
|
1616
|
-
resource: n,
|
|
1617
|
-
items: r,
|
|
1618
|
-
cardLabel: o = "Card",
|
|
1619
|
-
cryptoLabel: a = "USDC (Solana)",
|
|
1620
|
-
creditsLabel: w = "Pay with Credits",
|
|
1621
|
-
showCard: g = !0,
|
|
1622
|
-
showCrypto: I = !0,
|
|
1623
|
-
showCredits: f = !1,
|
|
1624
|
-
onPaymentAttempt: m,
|
|
1625
|
-
onPaymentSuccess: c,
|
|
1626
|
-
onPaymentError: u,
|
|
1627
|
-
onStripeSuccess: h,
|
|
1628
|
-
onCryptoSuccess: l,
|
|
1629
|
-
onCreditsSuccess: j,
|
|
1630
|
-
onStripeError: E,
|
|
1631
|
-
onCryptoError: d,
|
|
1632
|
-
onCreditsError: s,
|
|
1633
|
-
customerEmail: b,
|
|
1634
|
-
successUrl: C,
|
|
1635
|
-
cancelUrl: _,
|
|
1636
|
-
metadata: P,
|
|
1637
|
-
couponCode: N,
|
|
1638
|
-
authToken: B,
|
|
1639
|
-
testPageUrl: y,
|
|
1640
|
-
hideMessages: D = !1
|
|
1641
|
-
}) => {
|
|
1642
|
-
const { tokens: v } = le();
|
|
1643
|
-
return z(() => {
|
|
1644
|
-
const k = ($) => {
|
|
1645
|
-
$.key === "Escape" && t && e();
|
|
1646
|
-
};
|
|
1647
|
-
return window.addEventListener("keydown", k), () => window.removeEventListener("keydown", k);
|
|
1648
|
-
}, [t, e]), z(() => {
|
|
1649
|
-
if (t) {
|
|
1650
|
-
const k = window.scrollY;
|
|
1651
|
-
return document.body.style.position = "fixed", document.body.style.top = `-${k}px`, document.body.style.width = "100%", document.body.style.overflowY = "scroll", () => {
|
|
1652
|
-
const $ = document.body.style.top ? Math.abs(parseInt(document.body.style.top.replace("px", ""), 10)) : 0;
|
|
1653
|
-
document.body.style.position = "", document.body.style.top = "", document.body.style.width = "", document.body.style.overflowY = "", window.scrollTo(0, $);
|
|
1654
|
-
};
|
|
1655
|
-
}
|
|
1656
|
-
}, [t]), t ? /* @__PURE__ */ S(
|
|
1657
|
-
"div",
|
|
1658
|
-
{
|
|
1659
|
-
className: "cedros-modal-overlay",
|
|
1660
|
-
style: {
|
|
1661
|
-
position: "fixed",
|
|
1662
|
-
top: 0,
|
|
1663
|
-
left: 0,
|
|
1664
|
-
right: 0,
|
|
1665
|
-
bottom: 0,
|
|
1666
|
-
backgroundColor: v.modalOverlay,
|
|
1667
|
-
display: "flex",
|
|
1668
|
-
alignItems: "center",
|
|
1669
|
-
justifyContent: "center",
|
|
1670
|
-
zIndex: 9999,
|
|
1671
|
-
padding: "1rem"
|
|
1672
|
-
},
|
|
1673
|
-
onClick: e,
|
|
1674
|
-
children: /* @__PURE__ */ H(
|
|
1675
|
-
"div",
|
|
1676
|
-
{
|
|
1677
|
-
className: "cedros-modal-content",
|
|
1678
|
-
style: {
|
|
1679
|
-
backgroundColor: v.modalBackground,
|
|
1680
|
-
borderRadius: "12px",
|
|
1681
|
-
padding: "2rem",
|
|
1682
|
-
maxWidth: "400px",
|
|
1683
|
-
width: "100%",
|
|
1684
|
-
boxShadow: "0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04)",
|
|
1685
|
-
border: `1px solid ${v.modalBorder}`
|
|
1686
|
-
},
|
|
1687
|
-
onClick: (k) => k.stopPropagation(),
|
|
1688
|
-
children: [
|
|
1689
|
-
/* @__PURE__ */ H(
|
|
1690
|
-
"div",
|
|
1691
|
-
{
|
|
1692
|
-
style: {
|
|
1693
|
-
display: "flex",
|
|
1694
|
-
justifyContent: "space-between",
|
|
1695
|
-
alignItems: "center",
|
|
1696
|
-
marginBottom: "1.5rem"
|
|
1697
|
-
},
|
|
1698
|
-
children: [
|
|
1699
|
-
/* @__PURE__ */ S(
|
|
1700
|
-
"h3",
|
|
1701
|
-
{
|
|
1702
|
-
style: {
|
|
1703
|
-
margin: 0,
|
|
1704
|
-
fontSize: "1.25rem",
|
|
1705
|
-
fontWeight: 600,
|
|
1706
|
-
color: v.surfaceText
|
|
1707
|
-
},
|
|
1708
|
-
children: "Choose Payment Method"
|
|
1709
|
-
}
|
|
1710
|
-
),
|
|
1711
|
-
/* @__PURE__ */ S(
|
|
1712
|
-
"button",
|
|
1713
|
-
{
|
|
1714
|
-
onClick: e,
|
|
1715
|
-
style: He(v.surfaceText),
|
|
1716
|
-
"aria-label": "Close modal",
|
|
1717
|
-
children: "×"
|
|
1718
|
-
}
|
|
1719
|
-
)
|
|
1720
|
-
]
|
|
1721
|
-
}
|
|
1722
|
-
),
|
|
1723
|
-
/* @__PURE__ */ H("div", { style: { display: "flex", flexDirection: "column", gap: "1rem" }, children: [
|
|
1724
|
-
g && /* @__PURE__ */ S(
|
|
1725
|
-
lt,
|
|
1726
|
-
{
|
|
1727
|
-
resource: n,
|
|
1728
|
-
items: r,
|
|
1729
|
-
label: o,
|
|
1730
|
-
onAttempt: m,
|
|
1731
|
-
onSuccess: h || c,
|
|
1732
|
-
onError: E || u,
|
|
1733
|
-
customerEmail: b,
|
|
1734
|
-
successUrl: C,
|
|
1735
|
-
cancelUrl: _,
|
|
1736
|
-
metadata: P,
|
|
1737
|
-
couponCode: N
|
|
1738
|
-
}
|
|
1739
|
-
),
|
|
1740
|
-
I && /* @__PURE__ */ S(
|
|
1741
|
-
dt,
|
|
1742
|
-
{
|
|
1743
|
-
resource: n,
|
|
1744
|
-
items: r,
|
|
1745
|
-
label: a,
|
|
1746
|
-
onAttempt: m,
|
|
1747
|
-
onSuccess: l || c,
|
|
1748
|
-
onError: d || u,
|
|
1749
|
-
testPageUrl: y,
|
|
1750
|
-
hideMessages: D,
|
|
1751
|
-
metadata: P,
|
|
1752
|
-
couponCode: N
|
|
1753
|
-
}
|
|
1754
|
-
),
|
|
1755
|
-
f && /* @__PURE__ */ S(
|
|
1756
|
-
mt,
|
|
1757
|
-
{
|
|
1758
|
-
resource: n,
|
|
1759
|
-
items: r,
|
|
1760
|
-
label: w,
|
|
1761
|
-
authToken: B,
|
|
1762
|
-
onAttempt: m ? () => m("credits") : void 0,
|
|
1763
|
-
onSuccess: j || c,
|
|
1764
|
-
onError: s || u,
|
|
1765
|
-
metadata: P,
|
|
1766
|
-
couponCode: N
|
|
1767
|
-
}
|
|
1768
|
-
)
|
|
1769
|
-
] })
|
|
1770
|
-
]
|
|
1771
|
-
}
|
|
1772
|
-
)
|
|
1773
|
-
}
|
|
1774
|
-
) : null;
|
|
1775
|
-
};
|
|
1776
|
-
function jt({
|
|
1777
|
-
product: t,
|
|
1778
|
-
paymentMethod: e,
|
|
1779
|
-
showOriginalPrice: n = !1,
|
|
1780
|
-
className: r = "",
|
|
1781
|
-
style: o = {}
|
|
1782
|
-
}) {
|
|
1783
|
-
const a = e === "stripe", w = a ? t.fiatAmount : t.cryptoAmount, g = a ? t.effectiveFiatAmount : t.effectiveCryptoAmount, I = a ? t.fiatCurrency.toUpperCase() : t.cryptoToken, f = a ? t.hasStripeCoupon : t.hasCryptoCoupon, m = a ? t.stripeDiscountPercent : t.cryptoDiscountPercent;
|
|
1784
|
-
return /* @__PURE__ */ H("div", { className: r, style: o, children: [
|
|
1785
|
-
n && f && /* @__PURE__ */ H(
|
|
1786
|
-
"span",
|
|
1787
|
-
{
|
|
1788
|
-
style: {
|
|
1789
|
-
textDecoration: "line-through",
|
|
1790
|
-
opacity: 0.6,
|
|
1791
|
-
marginRight: "0.5rem",
|
|
1792
|
-
fontSize: "0.875em"
|
|
1793
|
-
},
|
|
1794
|
-
children: [
|
|
1795
|
-
w.toFixed(2),
|
|
1796
|
-
" ",
|
|
1797
|
-
I
|
|
1798
|
-
]
|
|
1799
|
-
}
|
|
1800
|
-
),
|
|
1801
|
-
/* @__PURE__ */ H("span", { style: { fontWeight: 600 }, children: [
|
|
1802
|
-
g.toFixed(2),
|
|
1803
|
-
" ",
|
|
1804
|
-
I
|
|
1805
|
-
] }),
|
|
1806
|
-
f && m > 0 && /* @__PURE__ */ H(
|
|
1807
|
-
"span",
|
|
1808
|
-
{
|
|
1809
|
-
style: {
|
|
1810
|
-
marginLeft: "0.5rem",
|
|
1811
|
-
padding: "0.125rem 0.375rem",
|
|
1812
|
-
backgroundColor: "#10b981",
|
|
1813
|
-
color: "white",
|
|
1814
|
-
borderRadius: "0.25rem",
|
|
1815
|
-
fontSize: "0.75em",
|
|
1816
|
-
fontWeight: 600
|
|
1817
|
-
},
|
|
1818
|
-
children: [
|
|
1819
|
-
m,
|
|
1820
|
-
"% OFF"
|
|
1821
|
-
]
|
|
1822
|
-
}
|
|
1823
|
-
)
|
|
1824
|
-
] });
|
|
1825
|
-
}
|
|
1826
|
-
function Dt({
|
|
1827
|
-
product: t,
|
|
1828
|
-
paymentMethod: e,
|
|
1829
|
-
className: n = "",
|
|
1830
|
-
style: r = {}
|
|
1831
|
-
}) {
|
|
1832
|
-
const o = e === "stripe", a = o ? t.hasStripeCoupon : t.hasCryptoCoupon, w = o ? t.stripeDiscountPercent : t.cryptoDiscountPercent, g = o ? t.stripeCouponCode : t.cryptoCouponCode;
|
|
1833
|
-
if (!a || w === 0)
|
|
1834
|
-
return null;
|
|
1835
|
-
const I = o ? `${w}% off with card!` : `${w}% off with crypto!`;
|
|
1836
|
-
return /* @__PURE__ */ H(
|
|
1837
|
-
"div",
|
|
1838
|
-
{
|
|
1839
|
-
className: n,
|
|
1840
|
-
style: {
|
|
1841
|
-
display: "inline-flex",
|
|
1842
|
-
alignItems: "center",
|
|
1843
|
-
padding: "0.5rem 0.75rem",
|
|
1844
|
-
backgroundColor: o ? "#6366f1" : "#10b981",
|
|
1845
|
-
color: "white",
|
|
1846
|
-
borderRadius: "0.375rem",
|
|
1847
|
-
fontSize: "0.875rem",
|
|
1848
|
-
fontWeight: 600,
|
|
1849
|
-
...r
|
|
1850
|
-
},
|
|
1851
|
-
children: [
|
|
1852
|
-
I,
|
|
1853
|
-
g && /* @__PURE__ */ H(
|
|
1854
|
-
"span",
|
|
1855
|
-
{
|
|
1856
|
-
style: {
|
|
1857
|
-
marginLeft: "0.5rem",
|
|
1858
|
-
opacity: 0.8,
|
|
1859
|
-
fontSize: "0.75em",
|
|
1860
|
-
fontWeight: 400
|
|
1861
|
-
},
|
|
1862
|
-
children: [
|
|
1863
|
-
"(",
|
|
1864
|
-
g,
|
|
1865
|
-
")"
|
|
1866
|
-
]
|
|
1867
|
-
}
|
|
1868
|
-
)
|
|
1869
|
-
]
|
|
1870
|
-
}
|
|
1871
|
-
);
|
|
1872
|
-
}
|
|
1873
|
-
export {
|
|
1874
|
-
it as A,
|
|
1875
|
-
St as B,
|
|
1876
|
-
Q as C,
|
|
1877
|
-
ct as D,
|
|
1878
|
-
rt as E,
|
|
1879
|
-
Et as F,
|
|
1880
|
-
Tt as G,
|
|
1881
|
-
Rt as P,
|
|
1882
|
-
lt as S,
|
|
1883
|
-
jt as a,
|
|
1884
|
-
Dt as b,
|
|
1885
|
-
Ce as c,
|
|
1886
|
-
vt as d,
|
|
1887
|
-
be as e,
|
|
1888
|
-
Pt as f,
|
|
1889
|
-
ie as g,
|
|
1890
|
-
_e as h,
|
|
1891
|
-
U as i,
|
|
1892
|
-
It as j,
|
|
1893
|
-
xt as k,
|
|
1894
|
-
dt as l,
|
|
1895
|
-
ut as m,
|
|
1896
|
-
ue as n,
|
|
1897
|
-
ee as o,
|
|
1898
|
-
Ct as p,
|
|
1899
|
-
we as q,
|
|
1900
|
-
mt as r,
|
|
1901
|
-
nt as s,
|
|
1902
|
-
De as t,
|
|
1903
|
-
ot as u,
|
|
1904
|
-
me as v,
|
|
1905
|
-
He as w,
|
|
1906
|
-
ft as x,
|
|
1907
|
-
kt as y,
|
|
1908
|
-
st as z
|
|
1909
|
-
};
|