@cedros/pay-react 1.1.24 → 1.1.26

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 (174) hide show
  1. package/dist/{AISettingsSection-Dw0ZlxMf.mjs → AISettingsSection-BlIv3CzS.mjs} +2 -2
  2. package/dist/{AISettingsSection-IXS1Wt_1.js → AISettingsSection-DELur7D2.js} +1 -1
  3. package/dist/{AutosaveIndicator-BJsg_kFZ.mjs → AutosaveIndicator-Bed0-ekg.mjs} +1 -1
  4. package/dist/{AutosaveIndicator-CY_YHM1D.js → AutosaveIndicator-Dn_qA2hK.js} +1 -1
  5. package/dist/CedrosContext-C2RjHLaQ.js +6 -0
  6. package/dist/{CedrosContext-DQUbL8yP.mjs → CedrosContext-CY6zvjvJ.mjs} +768 -617
  7. package/dist/ChatLogsSection-BH5tLA4T.js +1 -0
  8. package/dist/ChatLogsSection-v4zwzCTC.mjs +201 -0
  9. package/dist/ComplianceSection-CemgfDrL.mjs +650 -0
  10. package/dist/ComplianceSection-DP2a9-S0.js +1 -0
  11. package/dist/{CryptoButton-D1BCZBk4.mjs → CryptoButton-BV9owVe2.mjs} +2 -2
  12. package/dist/{CryptoButton-C1AAOOfj.js → CryptoButton-DpiCnyXE.js} +1 -1
  13. package/dist/CustomersSection-CBwy_waO.js +1 -0
  14. package/dist/CustomersSection-D_j7OrfS.mjs +207 -0
  15. package/dist/DisputesSection-BLjIk60n.js +1 -0
  16. package/dist/DisputesSection-BcAbXp3K.mjs +230 -0
  17. package/dist/{FAQSection-C78MnK4k.mjs → FAQSection-Dn38OhB_.mjs} +1 -1
  18. package/dist/{FAQSection-BmgmzDN5.js → FAQSection-wNeH0i6Q.js} +1 -1
  19. package/dist/ImagesSection-0ZzKlzMJ.js +1 -0
  20. package/dist/ImagesSection-Ctw9Icym.mjs +216 -0
  21. package/dist/InventorySection-DmhjUlRZ.mjs +150 -0
  22. package/dist/InventorySection-zV6lTmue.js +1 -0
  23. package/dist/{MessagingSection-De3t8bSI.mjs → MessagingSection-B1FaGxkp.mjs} +2 -2
  24. package/dist/{MessagingSection-CWLZcg11.js → MessagingSection-B_wdFR0j.js} +1 -1
  25. package/dist/{OrdersSection-_xKVzjSZ.mjs → OrdersSection-Bj8bPdg8.mjs} +6 -6
  26. package/dist/{OrdersSection-BKOxsZw0.js → OrdersSection-Dw2FX-1d.js} +1 -1
  27. package/dist/{PaymentSettingsSection-BTEn9Dxb.js → PaymentSettingsSection-BYF4D-GR.js} +1 -1
  28. package/dist/{PaymentSettingsSection-KjU_dN_d.mjs → PaymentSettingsSection-EnMxeWjv.mjs} +1 -1
  29. package/dist/ReturnsSection-BC0L8r2e.mjs +267 -0
  30. package/dist/ReturnsSection-D_pJVxuG.js +1 -0
  31. package/dist/{SettingsSection-8QHZB59k.mjs → SettingsSection-KYdEizq_.mjs} +19 -13
  32. package/dist/SettingsSection-vdYFSNxB.js +1 -0
  33. package/dist/ShippingSection-1DRSTu49.js +1 -0
  34. package/dist/ShippingSection-BOgto6_9.mjs +434 -0
  35. package/dist/{SingleCategorySettings-CRXTMTo5.js → SingleCategorySettings-DwCnBdRf.js} +1 -1
  36. package/dist/{SingleCategorySettings--LK0TZW0.mjs → SingleCategorySettings-suJ8z9d8.mjs} +4 -4
  37. package/dist/{StorefrontSection-CeCpr8hn.mjs → StorefrontSection-BRvIGBEJ.mjs} +2 -2
  38. package/dist/{StorefrontSection-C9DzCmOf.js → StorefrontSection-RumGkb3C.js} +1 -1
  39. package/dist/{SubscriptionsSection-Dn5SY6S_.js → SubscriptionsSection-C2aLLn7L.js} +1 -1
  40. package/dist/{SubscriptionsSection-C2xk8ApF.mjs → SubscriptionsSection-D60qrX9a.mjs} +7 -7
  41. package/dist/TaxSection-C7-pv-Rl.mjs +294 -0
  42. package/dist/TaxSection-Dt1DnM51.js +1 -0
  43. package/dist/Token22Section-CrHLQ0EB.mjs +2260 -0
  44. package/dist/Token22Section-DY3mUwTY.js +1 -0
  45. package/dist/{WalletManager-Bwk3rgr1.js → WalletManager-B3UdQ5pQ.js} +1 -1
  46. package/dist/{WalletManager-CXvQ0Zu9.mjs → WalletManager-BIwH8Dw_.mjs} +1 -1
  47. package/dist/WebhooksSection-CKeiJ7Py.js +1 -0
  48. package/dist/WebhooksSection-COPW4Ec0.mjs +223 -0
  49. package/dist/{configApi-Ch0Rr7TD.mjs → configApi-6XhAJGKX.mjs} +31 -0
  50. package/dist/{configApi-CxEbCAgG.js → configApi-DkduMQg1.js} +1 -1
  51. package/dist/crypto-only.js +1 -1
  52. package/dist/crypto-only.mjs +85 -83
  53. package/dist/index-C0g-JxJk.js +84 -0
  54. package/dist/{index-BHF82XBB.mjs → index-DXnuQp5x.mjs} +8643 -7678
  55. package/dist/index.js +1 -1
  56. package/dist/index.mjs +42 -40
  57. package/dist/{sections-C1rb9YRh.mjs → sections-C1NpK7hk.mjs} +2 -2
  58. package/dist/{sections-8e5Y3ukY.js → sections-DVVSZBhW.js} +1 -1
  59. package/dist/src/admin/plugin.d.ts.map +1 -1
  60. package/dist/src/components/ComplianceGatePage.d.ts +40 -0
  61. package/dist/src/components/ComplianceGatePage.d.ts.map +1 -0
  62. package/dist/src/components/SubscribeButton.d.ts +1 -5
  63. package/dist/src/components/SubscribeButton.d.ts.map +1 -1
  64. package/dist/src/components/admin/AdminAuthManager.d.ts +7 -3
  65. package/dist/src/components/admin/AdminAuthManager.d.ts.map +1 -1
  66. package/dist/src/components/admin/AssetClassesTab.d.ts.map +1 -1
  67. package/dist/src/components/admin/CedrosPayAdminDashboard.d.ts +1 -1
  68. package/dist/src/components/admin/CedrosPayAdminDashboard.d.ts.map +1 -1
  69. package/dist/src/components/admin/ChatLogsSection.d.ts +3 -0
  70. package/dist/src/components/admin/ChatLogsSection.d.ts.map +1 -0
  71. package/dist/src/components/admin/ComplianceKycTab.d.ts +3 -0
  72. package/dist/src/components/admin/ComplianceKycTab.d.ts.map +1 -0
  73. package/dist/src/components/admin/ComplianceRequirementsEditor.d.ts +8 -0
  74. package/dist/src/components/admin/ComplianceRequirementsEditor.d.ts.map +1 -0
  75. package/dist/src/components/admin/ComplianceSanctionsApi.d.ts +3 -0
  76. package/dist/src/components/admin/ComplianceSanctionsApi.d.ts.map +1 -0
  77. package/dist/src/components/admin/ComplianceSection.d.ts +3 -0
  78. package/dist/src/components/admin/ComplianceSection.d.ts.map +1 -0
  79. package/dist/src/components/admin/CustomersSection.d.ts +3 -0
  80. package/dist/src/components/admin/CustomersSection.d.ts.map +1 -0
  81. package/dist/src/components/admin/DisputesSection.d.ts +3 -0
  82. package/dist/src/components/admin/DisputesSection.d.ts.map +1 -0
  83. package/dist/src/components/admin/GiftCardAnalytics.d.ts +3 -0
  84. package/dist/src/components/admin/GiftCardAnalytics.d.ts.map +1 -0
  85. package/dist/src/components/admin/GiftCardManager.d.ts +3 -0
  86. package/dist/src/components/admin/GiftCardManager.d.ts.map +1 -0
  87. package/dist/src/components/admin/ImagesSection.d.ts +3 -0
  88. package/dist/src/components/admin/ImagesSection.d.ts.map +1 -0
  89. package/dist/src/components/admin/InventorySection.d.ts +3 -0
  90. package/dist/src/components/admin/InventorySection.d.ts.map +1 -0
  91. package/dist/src/components/admin/LiquidityPoolTab.d.ts.map +1 -1
  92. package/dist/src/components/admin/NftMetadataPreview.d.ts +20 -0
  93. package/dist/src/components/admin/NftMetadataPreview.d.ts.map +1 -0
  94. package/dist/src/components/admin/PoolManagementView.d.ts +14 -0
  95. package/dist/src/components/admin/PoolManagementView.d.ts.map +1 -0
  96. package/dist/src/components/admin/ProductsSection.d.ts.map +1 -1
  97. package/dist/src/components/admin/RefundsSection.d.ts.map +1 -1
  98. package/dist/src/components/admin/ReturnsSection.d.ts +3 -0
  99. package/dist/src/components/admin/ReturnsSection.d.ts.map +1 -0
  100. package/dist/src/components/admin/SettingsSection.d.ts.map +1 -1
  101. package/dist/src/components/admin/ShippingSection.d.ts +3 -0
  102. package/dist/src/components/admin/ShippingSection.d.ts.map +1 -0
  103. package/dist/src/components/admin/TaxSection.d.ts +3 -0
  104. package/dist/src/components/admin/TaxSection.d.ts.map +1 -0
  105. package/dist/src/components/admin/Token22Section.d.ts.map +1 -1
  106. package/dist/src/components/admin/WebhooksSection.d.ts +3 -0
  107. package/dist/src/components/admin/WebhooksSection.d.ts.map +1 -0
  108. package/dist/src/components/admin/complianceTypes.d.ts +74 -0
  109. package/dist/src/components/admin/complianceTypes.d.ts.map +1 -0
  110. package/dist/src/components/admin/configApi.d.ts.map +1 -1
  111. package/dist/src/components/admin/icons.d.ts +1 -0
  112. package/dist/src/components/admin/icons.d.ts.map +1 -1
  113. package/dist/src/components/admin/useAdminAuth.d.ts +1 -1
  114. package/dist/src/components/admin/useAdminAuth.d.ts.map +1 -1
  115. package/dist/src/context/CedrosContext.d.ts.map +1 -1
  116. package/dist/src/ecommerce/adapters/CommerceAdapter.d.ts +36 -0
  117. package/dist/src/ecommerce/adapters/CommerceAdapter.d.ts.map +1 -1
  118. package/dist/src/ecommerce/adapters/paywall/paywallAdapter.d.ts.map +1 -1
  119. package/dist/src/ecommerce/components/catalog/TokenDisplay.d.ts +36 -0
  120. package/dist/src/ecommerce/components/catalog/TokenDisplay.d.ts.map +1 -0
  121. package/dist/src/ecommerce/components/chat/ShopChatPanel.d.ts +8 -5
  122. package/dist/src/ecommerce/components/chat/ShopChatPanel.d.ts.map +1 -1
  123. package/dist/src/ecommerce/components/checkout/CheckoutForm.d.ts.map +1 -1
  124. package/dist/src/ecommerce/components/checkout/SendAsGiftSection.d.ts +15 -0
  125. package/dist/src/ecommerce/components/checkout/SendAsGiftSection.d.ts.map +1 -0
  126. package/dist/src/ecommerce/components/gift-cards/GiftCardBalanceChecker.d.ts +19 -0
  127. package/dist/src/ecommerce/components/gift-cards/GiftCardBalanceChecker.d.ts.map +1 -0
  128. package/dist/src/ecommerce/components/orders/MyRedemptionsPage.d.ts +13 -0
  129. package/dist/src/ecommerce/components/orders/MyRedemptionsPage.d.ts.map +1 -0
  130. package/dist/src/ecommerce/components/orders/MyTokensPage.d.ts +15 -0
  131. package/dist/src/ecommerce/components/orders/MyTokensPage.d.ts.map +1 -0
  132. package/dist/src/ecommerce/components/orders/OrderDetails.d.ts.map +1 -1
  133. package/dist/src/ecommerce/hooks/useCartInventory.d.ts.map +1 -1
  134. package/dist/src/ecommerce/index.d.ts +12 -2
  135. package/dist/src/ecommerce/index.d.ts.map +1 -1
  136. package/dist/src/ecommerce/state/checkout/checkoutSchema.d.ts +3 -0
  137. package/dist/src/ecommerce/state/checkout/checkoutSchema.d.ts.map +1 -1
  138. package/dist/src/ecommerce/state/checkout/useCheckout.d.ts.map +1 -1
  139. package/dist/src/ecommerce/types.d.ts +6 -0
  140. package/dist/src/ecommerce/types.d.ts.map +1 -1
  141. package/dist/src/ecommerce/utils/cartItemMetadata.d.ts.map +1 -1
  142. package/dist/src/hooks/useComplianceCheck.d.ts +30 -0
  143. package/dist/src/hooks/useComplianceCheck.d.ts.map +1 -0
  144. package/dist/src/hooks/useSubscriptionManagement.d.ts.map +1 -1
  145. package/dist/src/index.d.ts +4 -0
  146. package/dist/src/index.d.ts.map +1 -1
  147. package/dist/src/managers/CreditsManager.d.ts.map +1 -1
  148. package/dist/src/managers/ManagerCache.d.ts +2 -2
  149. package/dist/src/managers/ManagerCache.d.ts.map +1 -1
  150. package/dist/src/managers/StripeManager.d.ts +7 -1
  151. package/dist/src/managers/StripeManager.d.ts.map +1 -1
  152. package/dist/src/managers/SubscriptionChangeManager.d.ts.map +1 -1
  153. package/dist/src/managers/SubscriptionManager.d.ts.map +1 -1
  154. package/dist/src/types/index.d.ts +14 -0
  155. package/dist/src/types/index.d.ts.map +1 -1
  156. package/dist/src/types/subscription.d.ts +21 -33
  157. package/dist/src/types/subscription.d.ts.map +1 -1
  158. package/dist/src/utils/exponentialBackoff.d.ts +22 -0
  159. package/dist/src/utils/exponentialBackoff.d.ts.map +1 -1
  160. package/dist/stripe-only.js +1 -1
  161. package/dist/stripe-only.mjs +2 -2
  162. package/dist/styles-BT4bhFey.js +1 -0
  163. package/dist/{styles-Ag-7ZvAB.mjs → styles-D4SQkuV3.mjs} +606 -609
  164. package/dist/testing/index.js +1 -1
  165. package/dist/testing/index.mjs +1 -1
  166. package/dist/{walletPool-C_0P4mTw.mjs → walletPool-DE-t1wSW.mjs} +1 -1
  167. package/dist/{walletPool-Ddv33tej.js → walletPool-IS7R3MR1.js} +1 -1
  168. package/package.json +1 -1
  169. package/dist/CedrosContext-7dwmEeUY.js +0 -6
  170. package/dist/SettingsSection-cKF0tLnS.js +0 -1
  171. package/dist/Token22Section-DUUl59dZ.js +0 -1
  172. package/dist/Token22Section-HygkDNtL.mjs +0 -1685
  173. package/dist/index-OaWkrl0G.js +0 -84
  174. package/dist/styles-21F1-oqx.js +0 -1
@@ -1,6 +1,6 @@
1
- import { i as j, P as ke, u as re, o as be, j as V, m as pe } from "./CedrosContext-DQUbL8yP.mjs";
1
+ import { i as j, P as ke, u as re, o as be, j as V, m as pe } from "./CedrosContext-CY6zvjvJ.mjs";
2
2
  import { jsxs as S, jsx as f, Fragment as me } from "react/jsx-runtime";
3
- import q, { useState as Q, useRef as X, useCallback as I, useMemo as F, useEffect as te } from "react";
3
+ import U, { useState as Q, useRef as X, useCallback as R, useMemo as W, useEffect as te } from "react";
4
4
  function xt(e) {
5
5
  return !e || !e.coupon_codes ? [] : e.coupon_codes.split(",").map((t) => t.trim()).filter((t) => t.length > 0);
6
6
  }
@@ -16,8 +16,8 @@ function _t(e, t) {
16
16
  let r = e, n = 0;
17
17
  for (const s of t)
18
18
  if (s.discountType === "percentage") {
19
- const u = 1 - s.discountValue / 100;
20
- r = r * u;
19
+ const l = 1 - s.discountValue / 100;
20
+ r = r * l;
21
21
  } else s.discountType === "fixed" && (n += s.discountValue);
22
22
  return r = r - n, r < 0 && (r = 0), Math.ceil(r * 100) / 100;
23
23
  }
@@ -72,17 +72,17 @@ function Ue(e) {
72
72
  function Oe(e) {
73
73
  return we.get(e) || null;
74
74
  }
75
- function Fe(e, t) {
75
+ function We(e, t) {
76
76
  we.set(e, t);
77
77
  const r = () => {
78
78
  we.delete(e), Ue(e);
79
79
  };
80
80
  return t.then(r, r), t;
81
81
  }
82
- async function We(e, t, r = {}) {
83
- const { windowMs: n = Se, throwOnDuplicate: s = !0 } = r, u = Oe(e);
84
- if (u)
85
- return j().debug(`[Deduplication] Reusing in-flight request: ${e}`), u;
82
+ async function Fe(e, t, r = {}) {
83
+ const { windowMs: n = Se, throwOnDuplicate: s = !0 } = r, l = Oe(e);
84
+ if (l)
85
+ return j().debug(`[Deduplication] Reusing in-flight request: ${e}`), l;
86
86
  if (ze(e, n)) {
87
87
  if (s)
88
88
  throw new Error(`Duplicate request blocked: ${e}`);
@@ -90,7 +90,7 @@ async function We(e, t, r = {}) {
90
90
  return;
91
91
  }
92
92
  const g = t();
93
- return Fe(e, g);
93
+ return We(e, g);
94
94
  }
95
95
  function se(e, t, r = {}) {
96
96
  const { cooldownMs: n = Re, deduplicationWindowMs: s = Se } = r;
@@ -101,18 +101,18 @@ function se(e, t, r = {}) {
101
101
  }
102
102
  qe(e, n);
103
103
  try {
104
- await We(
104
+ await Fe(
105
105
  e,
106
106
  async () => {
107
- const u = t();
108
- u instanceof Promise && await u;
107
+ const l = t();
108
+ l instanceof Promise && await l;
109
109
  },
110
110
  { windowMs: s, throwOnDuplicate: !1 }
111
111
  );
112
- } catch (u) {
113
- if (u instanceof Error && u.message.includes("Duplicate request"))
112
+ } catch (l) {
113
+ if (l instanceof Error && l.message.includes("Duplicate request"))
114
114
  return;
115
- throw u;
115
+ throw l;
116
116
  }
117
117
  };
118
118
  }
@@ -233,34 +233,34 @@ function Ve(e = {}) {
233
233
  solanaEndpoint: r,
234
234
  customRpcProviders: n = [],
235
235
  allowUnsafeScripts: s = !1,
236
- additionalScriptSrc: u = [],
236
+ additionalScriptSrc: l = [],
237
237
  additionalConnectSrc: g = [],
238
- additionalFrameSrc: b = [],
239
- includeStripe: h = !0,
238
+ additionalFrameSrc: C = [],
239
+ includeStripe: b = !0,
240
240
  includeSolana: c = !0
241
241
  } = e;
242
242
  s && console.warn(
243
243
  "[CedrosPay] SECURITY WARNING: allowUnsafeScripts is enabled. This adds 'unsafe-inline' and 'unsafe-eval' to script-src, which significantly weakens CSP protection against XSS attacks. Only use this in development or if absolutely required by your framework."
244
244
  );
245
245
  const a = ["'self'"];
246
- s && a.push("'unsafe-inline'", "'unsafe-eval'"), h && a.push("https://js.stripe.com"), a.push(...u);
246
+ s && a.push("'unsafe-inline'", "'unsafe-eval'"), b && a.push("https://js.stripe.com"), a.push(...l);
247
247
  const o = ["'self'"];
248
- if (h && o.push("https://api.stripe.com", "https://*.stripe.com"), c) {
249
- const i = Ye(t);
250
- if (o.push(i), r) {
251
- const l = Qe(r);
252
- o.includes(l) || o.push(l);
248
+ if (b && o.push("https://api.stripe.com", "https://*.stripe.com"), c) {
249
+ const d = Ye(t);
250
+ if (o.push(d), r) {
251
+ const i = Qe(r);
252
+ o.includes(i) || o.push(i);
253
253
  }
254
- n.forEach((l) => {
255
- o.includes(l) || o.push(l);
254
+ n.forEach((i) => {
255
+ o.includes(i) || o.push(i);
256
256
  });
257
257
  }
258
258
  o.push(...g);
259
- const d = ["'self'"];
260
- return h && d.push("https://js.stripe.com", "https://checkout.stripe.com"), d.push(...b), {
259
+ const u = ["'self'"];
260
+ return b && u.push("https://js.stripe.com", "https://checkout.stripe.com"), u.push(...C), {
261
261
  scriptSrc: a,
262
262
  connectSrc: o,
263
- frameSrc: d
263
+ frameSrc: u
264
264
  };
265
265
  }
266
266
  function Ge(e, t = "header") {
@@ -270,12 +270,12 @@ function Ge(e, t = "header") {
270
270
  case "meta":
271
271
  case "nextjs":
272
272
  case "nginx": {
273
- const u = [];
274
- return r.length > 0 && u.push(`script-src ${r.join(" ")}`), n.length > 0 && u.push(`connect-src ${n.join(" ")}`), s.length > 0 && u.push(`frame-src ${s.join(" ")}`), u.join("; ");
273
+ const l = [];
274
+ return r.length > 0 && l.push(`script-src ${r.join(" ")}`), n.length > 0 && l.push(`connect-src ${n.join(" ")}`), s.length > 0 && l.push(`frame-src ${s.join(" ")}`), l.join("; ");
275
275
  }
276
276
  case "helmet": {
277
- const u = {};
278
- return r.length > 0 && (u.scriptSrc = r), n.length > 0 && (u.connectSrc = n), s.length > 0 && (u.frameSrc = s), u;
277
+ const l = {};
278
+ return r.length > 0 && (l.scriptSrc = r), n.length > 0 && (l.connectSrc = n), s.length > 0 && (l.frameSrc = s), l;
279
279
  }
280
280
  case "directives":
281
281
  return { scriptSrc: r, connectSrc: n, frameSrc: s };
@@ -340,8 +340,8 @@ function Ie() {
340
340
  status: "idle",
341
341
  error: null,
342
342
  transactionId: null
343
- }), n = X(!1), s = I(
344
- async (b, h, c, a, o, d) => {
343
+ }), n = X(!1), s = R(
344
+ async (C, b, c, a, o, u) => {
345
345
  if (n.current)
346
346
  return { success: !1, error: "Payment already in progress" };
347
347
  n.current = !0, r({
@@ -349,23 +349,23 @@ function Ie() {
349
349
  error: null,
350
350
  transactionId: null
351
351
  });
352
- const i = {
353
- resource: b,
354
- successUrl: h,
352
+ const d = {
353
+ resource: C,
354
+ successUrl: b,
355
355
  cancelUrl: c,
356
356
  metadata: a,
357
357
  customerEmail: o,
358
- couponCode: d
358
+ couponCode: u
359
359
  };
360
360
  try {
361
- const l = await e.processPayment(i);
361
+ const i = await e.processPayment(d);
362
362
  return r({
363
- status: l.success ? "success" : "error",
364
- error: l.success ? null : l.error || "Payment failed",
365
- transactionId: l.success && l.transactionId || null
366
- }), l;
367
- } catch (l) {
368
- const p = l instanceof Error ? l.message : "Payment failed";
363
+ status: i.success ? "success" : "error",
364
+ error: i.success ? null : i.error || "Payment failed",
365
+ transactionId: i.success && i.transactionId || null
366
+ }), i;
367
+ } catch (i) {
368
+ const p = i instanceof Error ? i.message : "Payment failed";
369
369
  return r({
370
370
  status: "error",
371
371
  error: p,
@@ -376,8 +376,8 @@ function Ie() {
376
376
  }
377
377
  },
378
378
  [e]
379
- ), u = I(
380
- async (b, h, c, a, o, d, i, l, p, m, w, y, k) => {
379
+ ), l = R(
380
+ async (C, b, c, a, o, u, d, i, p, m, h, y, I) => {
381
381
  if (n.current)
382
382
  return { success: !1, error: "Payment already in progress" };
383
383
  n.current = !0, r({
@@ -385,41 +385,41 @@ function Ie() {
385
385
  error: null,
386
386
  transactionId: null
387
387
  });
388
- const P = Ce(b);
388
+ const v = Ce(C);
389
389
  try {
390
- const E = await e.processCartCheckout({
391
- items: P,
392
- successUrl: h,
390
+ const P = await e.processCartCheckout({
391
+ items: v,
392
+ successUrl: b,
393
393
  cancelUrl: c,
394
394
  metadata: a,
395
395
  customerEmail: o,
396
- customerName: i,
397
- customerPhone: l,
396
+ customerName: d,
397
+ customerPhone: i,
398
398
  shippingAddress: p,
399
399
  billingAddress: m,
400
- couponCode: d,
401
- tipAmount: w,
400
+ couponCode: u,
401
+ tipAmount: h,
402
402
  shippingMethodId: y,
403
- paymentMethodId: k
403
+ paymentMethodId: I
404
404
  });
405
405
  return r({
406
- status: E.success ? "success" : "error",
407
- error: E.success ? null : E.error || "Cart checkout failed",
408
- transactionId: E.success && E.transactionId || null
409
- }), E;
410
- } catch (E) {
411
- const M = E instanceof Error ? E.message : "Cart checkout failed";
406
+ status: P.success ? "success" : "error",
407
+ error: P.success ? null : P.error || "Cart checkout failed",
408
+ transactionId: P.success && P.transactionId || null
409
+ }), P;
410
+ } catch (P) {
411
+ const N = P instanceof Error ? P.message : "Cart checkout failed";
412
412
  return r({
413
413
  status: "error",
414
- error: M,
414
+ error: N,
415
415
  transactionId: null
416
- }), { success: !1, error: M };
416
+ }), { success: !1, error: N };
417
417
  } finally {
418
418
  n.current = !1;
419
419
  }
420
420
  },
421
421
  [e]
422
- ), g = I(() => {
422
+ ), g = R(() => {
423
423
  r({
424
424
  status: "idle",
425
425
  error: null,
@@ -429,12 +429,12 @@ function Ie() {
429
429
  return {
430
430
  ...t,
431
431
  processPayment: s,
432
- processCartCheckout: u,
432
+ processCartCheckout: l,
433
433
  reset: g
434
434
  };
435
435
  }
436
436
  function he(e, t) {
437
- return F(() => {
437
+ return W(() => {
438
438
  const r = $e(t), n = e || (t?.length === 1 ? t[0].resource : "");
439
439
  return {
440
440
  isCartMode: r,
@@ -444,8 +444,8 @@ function he(e, t) {
444
444
  }
445
445
  const Ke = (e, t, r) => {
446
446
  const n = e[t];
447
- return n ? typeof n == "function" ? n() : Promise.resolve(n) : new Promise((s, u) => {
448
- (typeof queueMicrotask == "function" ? queueMicrotask : setTimeout)(u.bind(null, /* @__PURE__ */ new Error("Unknown variable dynamic import: " + t + (t.split("/").length !== r ? ". Note that variables only represent file names one level deep." : ""))));
447
+ return n ? typeof n == "function" ? n() : Promise.resolve(n) : new Promise((s, l) => {
448
+ (typeof queueMicrotask == "function" ? queueMicrotask : setTimeout)(l.bind(null, /* @__PURE__ */ new Error("Unknown variable dynamic import: " + t + (t.split("/").length !== r ? ". Note that variables only represent file names one level deep." : ""))));
449
449
  });
450
450
  }, ye = /* @__PURE__ */ new Map();
451
451
  let de = null;
@@ -482,13 +482,13 @@ function Ze(e) {
482
482
  return (t, r) => {
483
483
  const n = t.split(".");
484
484
  let s = e;
485
- for (const u of n)
486
- if (s && typeof s == "object" && u in s)
487
- s = s[u];
485
+ for (const l of n)
486
+ if (s && typeof s == "object" && l in s)
487
+ s = s[l];
488
488
  else
489
489
  return t;
490
490
  return typeof s != "string" ? t : r ? Object.entries(r).reduce(
491
- (u, [g, b]) => u.replace(new RegExp(`\\{${g}\\}`, "g"), b),
491
+ (l, [g, C]) => l.replace(new RegExp(`\\{${g}\\}`, "g"), C),
492
492
  s
493
493
  ) : s;
494
494
  };
@@ -502,22 +502,22 @@ function $t(e, t, r = !0) {
502
502
  return r && n.action ? `${n.message} ${n.action}` : n.message;
503
503
  }
504
504
  function ne(e) {
505
- const [t, r] = Q(null), [n, s] = Q(!0), u = F(() => e || Xe(), [e]);
505
+ const [t, r] = Q(null), [n, s] = Q(!0), l = W(() => e || Xe(), [e]);
506
506
  return te(() => {
507
- let b = !1;
507
+ let C = !1;
508
508
  return (async () => {
509
509
  s(!0);
510
510
  try {
511
- const c = await Je(u);
512
- b || (r(c), s(!1));
511
+ const c = await Je(l);
512
+ C || (r(c), s(!1));
513
513
  } catch (c) {
514
- console.error("[CedrosPay] Failed to load translations:", c), b || s(!1);
514
+ console.error("[CedrosPay] Failed to load translations:", c), C || s(!1);
515
515
  }
516
516
  })(), () => {
517
- b = !0;
517
+ C = !0;
518
518
  };
519
- }, [u]), {
520
- t: F(() => t ? Ze(t) : (b) => ({
519
+ }, [l]), {
520
+ t: W(() => t ? Ze(t) : (C) => ({
521
521
  "ui.purchase": "Purchase",
522
522
  "ui.pay_with_card": "Pay with Card",
523
523
  "ui.pay_with_crypto": "Pay with USDC",
@@ -529,8 +529,8 @@ function ne(e) {
529
529
  "ui.loading": "Loading...",
530
530
  "ui.connect_wallet": "Connect Wallet",
531
531
  "ui.connecting": "Connecting..."
532
- })[b] || b, [t]),
533
- locale: u,
532
+ })[C] || C, [t]),
533
+ locale: l,
534
534
  isLoading: n,
535
535
  translations: t
536
536
  };
@@ -554,60 +554,60 @@ function Me({
554
554
  successUrl: r,
555
555
  cancelUrl: n,
556
556
  metadata: s,
557
- customerEmail: u,
557
+ customerEmail: l,
558
558
  couponCode: g,
559
- label: b,
560
- disabled: h = !1,
559
+ label: C,
560
+ disabled: b = !1,
561
561
  onAttempt: c,
562
562
  onSuccess: a,
563
563
  onError: o,
564
- className: d = ""
564
+ className: u = ""
565
565
  }) {
566
- const { status: i, error: l, transactionId: p, processPayment: m, processCartCheckout: w } = Ie(), y = V(), { isCartMode: k, effectiveResource: P } = he(e, t), { t: E, translations: M } = ne(), $ = b || E("ui.pay_with_card"), z = y.unstyled ? d : `${y.className} cedros-theme__stripe-button ${d}`.trim(), U = l && typeof l != "string" ? l?.code ?? null : null, C = l ? typeof l == "string" ? l : ((x) => {
567
- if (!x || !M) return "";
568
- const R = M.errors[x];
569
- return R ? R.action ? `${R.message} ${R.action}` : R.message : "";
570
- })(U) : null, _ = I(async () => {
566
+ const { status: d, error: i, transactionId: p, processPayment: m, processCartCheckout: h } = Ie(), y = V(), { isCartMode: I, effectiveResource: v } = he(e, t), { t: P, translations: N } = ne(), A = C || P("ui.pay_with_card"), z = y.unstyled ? u : `${y.className} cedros-theme__stripe-button ${u}`.trim(), q = i && typeof i != "string" ? i?.code ?? null : null, w = i ? typeof i == "string" ? i : ((x) => {
567
+ if (!x || !N) return "";
568
+ const _ = N.errors[x];
569
+ return _ ? _.action ? `${_.message} ${_.action}` : _.message : "";
570
+ })(q) : null, E = R(async () => {
571
571
  j().debug("[StripeButton] executePayment with couponCode:", g);
572
- const x = k && t ? ge(t) : void 0;
573
- if (oe("stripe", P, x), c && c("stripe"), !k && !P) {
574
- const W = "Invalid payment configuration: missing resource or items";
575
- j().error("[StripeButton]", W), Y("stripe", W, P, x), o && o(W);
572
+ const x = I && t ? ge(t) : void 0;
573
+ if (oe("stripe", v, x), c && c("stripe"), !I && !v) {
574
+ const F = "Invalid payment configuration: missing resource or items";
575
+ j().error("[StripeButton]", F), Y("stripe", F, v, x), o && o(F);
576
576
  return;
577
577
  }
578
- let R;
579
- ae("stripe", P, x), k && t ? (j().debug("[StripeButton] Processing cart checkout with coupon:", g), R = await w(
578
+ let _;
579
+ ae("stripe", v, x), I && t ? (j().debug("[StripeButton] Processing cart checkout with coupon:", g), _ = await h(
580
580
  t,
581
581
  r,
582
582
  n,
583
583
  s,
584
- u,
584
+ l,
585
585
  g
586
- )) : P && (j().debug("[StripeButton] Processing single payment with coupon:", g), R = await m(
587
- P,
586
+ )) : v && (j().debug("[StripeButton] Processing single payment with coupon:", g), _ = await m(
587
+ v,
588
588
  r,
589
589
  n,
590
590
  s,
591
- u,
591
+ l,
592
592
  g
593
- )), R && R.success && R.transactionId ? (ie("stripe", R.transactionId, P, x), a && a(R.transactionId)) : R && !R.success && R.error && (Y("stripe", R.error, P, x), o && o(R.error));
594
- }, [g, k, P, t, r, n, s, u, w, m, c, a, o]), A = F(() => k && t ? `stripe-cart-${t.map((x) => x.resource).join("-")}` : `stripe-${P || "unknown"}`, [k, t, P]), T = F(
595
- () => se(A, _),
596
- [A, _]
597
- ), N = i === "loading", v = h || N;
593
+ )), _ && _.success && _.transactionId ? (ie("stripe", _.transactionId, v, x), a && a(_.transactionId)) : _ && !_.success && _.error && (Y("stripe", _.error, v, x), o && o(_.error));
594
+ }, [g, I, v, t, r, n, s, l, h, m, c, a, o]), $ = W(() => I && t ? `stripe-cart-${t.map((x) => x.resource).join("-")}` : `stripe-${v || "unknown"}`, [I, t, v]), k = W(
595
+ () => se($, E),
596
+ [$, E]
597
+ ), T = d === "loading", M = b || T;
598
598
  return /* @__PURE__ */ S("div", { className: z, style: y.unstyled ? {} : y.style, children: [
599
599
  /* @__PURE__ */ f(
600
600
  "button",
601
601
  {
602
- onClick: T,
603
- disabled: v,
604
- className: y.unstyled ? d : "cedros-theme__button cedros-theme__stripe",
602
+ onClick: k,
603
+ disabled: M,
604
+ className: y.unstyled ? u : "cedros-theme__button cedros-theme__stripe",
605
605
  type: "button",
606
- children: N ? E("ui.processing") : $
606
+ children: T ? P("ui.processing") : A
607
607
  }
608
608
  ),
609
- C && /* @__PURE__ */ f("div", { className: y.unstyled ? "" : "cedros-theme__error", children: C }),
610
- p && /* @__PURE__ */ f("div", { className: y.unstyled ? "" : "cedros-theme__success", children: E("ui.payment_successful") })
609
+ w && /* @__PURE__ */ f("div", { className: y.unstyled ? "" : "cedros-theme__error", children: w }),
610
+ p && /* @__PURE__ */ f("div", { className: y.unstyled ? "" : "cedros-theme__success", children: P("ui.payment_successful") })
611
611
  ] });
612
612
  }
613
613
  function et() {
@@ -617,7 +617,7 @@ function et() {
617
617
  transactionId: null,
618
618
  requirement: null,
619
619
  holdId: null
620
- }), n = X(!1), s = I(
620
+ }), n = X(!1), s = R(
621
621
  async (c, a) => {
622
622
  r((o) => ({
623
623
  ...o,
@@ -626,22 +626,22 @@ function et() {
626
626
  }));
627
627
  try {
628
628
  const o = await e.requestQuote(c, a);
629
- return r((d) => ({
630
- ...d,
629
+ return r((u) => ({
630
+ ...u,
631
631
  status: "idle",
632
632
  requirement: o
633
633
  })), o;
634
634
  } catch (o) {
635
- const d = o instanceof Error ? o.message : "Failed to fetch credits quote";
636
- return r((i) => ({
637
- ...i,
635
+ const u = o instanceof Error ? o.message : "Failed to fetch credits quote";
636
+ return r((d) => ({
637
+ ...d,
638
638
  status: "error",
639
- error: d
639
+ error: u
640
640
  })), null;
641
641
  }
642
642
  },
643
643
  [e]
644
- ), u = I(
644
+ ), l = R(
645
645
  async (c, a) => {
646
646
  r((o) => ({
647
647
  ...o,
@@ -649,23 +649,23 @@ function et() {
649
649
  error: null
650
650
  }));
651
651
  try {
652
- const o = Ce(c), d = await e.requestCartQuote(o, a);
653
- return r((i) => ({
654
- ...i,
652
+ const o = Ce(c), u = await e.requestCartQuote(o, a);
653
+ return r((d) => ({
654
+ ...d,
655
655
  status: "idle"
656
- })), d;
656
+ })), u;
657
657
  } catch (o) {
658
- const d = o instanceof Error ? o.message : "Failed to fetch cart credits quote";
659
- return r((i) => ({
660
- ...i,
658
+ const u = o instanceof Error ? o.message : "Failed to fetch cart credits quote";
659
+ return r((d) => ({
660
+ ...d,
661
661
  status: "error",
662
- error: d
662
+ error: u
663
663
  })), null;
664
664
  }
665
665
  },
666
666
  [e]
667
- ), g = I(
668
- async (c, a, o, d) => {
667
+ ), g = R(
668
+ async (c, a, o, u) => {
669
669
  if (n.current)
670
670
  return { success: !1, error: "Payment already in progress" };
671
671
  n.current = !0, r({
@@ -676,30 +676,30 @@ function et() {
676
676
  holdId: null
677
677
  });
678
678
  try {
679
- const i = await e.processPayment(c, a, o, d);
679
+ const d = await e.processPayment(c, a, o, u);
680
680
  return r({
681
- status: i.success ? "success" : "error",
682
- error: i.success ? null : i.error || "Credits payment failed",
683
- transactionId: i.success && i.transactionId || null,
681
+ status: d.success ? "success" : "error",
682
+ error: d.success ? null : d.error || "Credits payment failed",
683
+ transactionId: d.success && d.transactionId || null,
684
684
  requirement: null,
685
685
  holdId: null
686
- }), i;
687
- } catch (i) {
688
- const l = i instanceof Error ? i.message : "Credits payment failed";
686
+ }), d;
687
+ } catch (d) {
688
+ const i = d instanceof Error ? d.message : "Credits payment failed";
689
689
  return r({
690
690
  status: "error",
691
- error: l,
691
+ error: i,
692
692
  transactionId: null,
693
693
  requirement: null,
694
694
  holdId: null
695
- }), { success: !1, error: l };
695
+ }), { success: !1, error: i };
696
696
  } finally {
697
697
  n.current = !1;
698
698
  }
699
699
  },
700
700
  [e]
701
- ), b = I(
702
- async (c, a, o, d) => {
701
+ ), C = R(
702
+ async (c, a, o, u) => {
703
703
  if (n.current)
704
704
  return { success: !1, error: "Payment already in progress" };
705
705
  n.current = !0, r({
@@ -709,9 +709,9 @@ function et() {
709
709
  requirement: null,
710
710
  holdId: null
711
711
  });
712
- let i = null;
712
+ let d = null;
713
713
  try {
714
- const l = Ce(c), p = await e.requestCartQuote(l, o);
714
+ const i = Ce(c), p = await e.requestCartQuote(i, o);
715
715
  if (!p)
716
716
  return r({
717
717
  status: "error",
@@ -720,47 +720,47 @@ function et() {
720
720
  requirement: null,
721
721
  holdId: null
722
722
  }), { success: !1, error: "Credits payment not available" };
723
- i = (await e.createCartHold({
723
+ d = (await e.createCartHold({
724
724
  cartId: p.cartId,
725
725
  authToken: a
726
726
  })).holdId, r((y) => ({
727
727
  ...y,
728
- holdId: i
728
+ holdId: d
729
729
  }));
730
- const w = await e.authorizeCartPayment({
730
+ const h = await e.authorizeCartPayment({
731
731
  cartId: p.cartId,
732
- holdId: i,
732
+ holdId: d,
733
733
  authToken: a,
734
- metadata: d
734
+ metadata: u
735
735
  });
736
- if (!w.success && i)
736
+ if (!h.success && d)
737
737
  try {
738
- await e.releaseHold(i, a);
738
+ await e.releaseHold(d, a);
739
739
  } catch (y) {
740
740
  j().warn("[useCreditsPayment] Hold release failed, will expire server-side", {
741
- holdId: i,
741
+ holdId: d,
742
742
  error: y instanceof Error ? y.message : String(y)
743
743
  });
744
744
  }
745
745
  return r({
746
- status: w.success ? "success" : "error",
747
- error: w.success ? null : w.error || "Cart credits payment failed",
748
- transactionId: w.success && w.transactionId || null,
746
+ status: h.success ? "success" : "error",
747
+ error: h.success ? null : h.error || "Cart credits payment failed",
748
+ transactionId: h.success && h.transactionId || null,
749
749
  requirement: null,
750
750
  holdId: null
751
751
  }), {
752
- success: w.success,
753
- transactionId: w.transactionId,
754
- error: w.error
752
+ success: h.success,
753
+ transactionId: h.transactionId,
754
+ error: h.error
755
755
  };
756
- } catch (l) {
757
- const p = l instanceof Error ? l.message : "Cart credits payment failed";
758
- if (i)
756
+ } catch (i) {
757
+ const p = i instanceof Error ? i.message : "Cart credits payment failed";
758
+ if (d)
759
759
  try {
760
- await e.releaseHold(i, a);
760
+ await e.releaseHold(d, a);
761
761
  } catch (m) {
762
762
  j().warn("[useCreditsPayment] Hold release failed, will expire server-side", {
763
- holdId: i,
763
+ holdId: d,
764
764
  error: m instanceof Error ? m.message : String(m)
765
765
  });
766
766
  }
@@ -776,7 +776,7 @@ function et() {
776
776
  }
777
777
  },
778
778
  [e]
779
- ), h = I(() => {
779
+ ), b = R(() => {
780
780
  r({
781
781
  status: "idle",
782
782
  error: null,
@@ -788,10 +788,10 @@ function et() {
788
788
  return {
789
789
  ...t,
790
790
  fetchQuote: s,
791
- fetchCartQuote: u,
791
+ fetchCartQuote: l,
792
792
  processPayment: g,
793
- processCartPayment: b,
794
- reset: h
793
+ processCartPayment: C,
794
+ reset: b
795
795
  };
796
796
  }
797
797
  function Te({
@@ -800,106 +800,106 @@ function Te({
800
800
  authToken: r,
801
801
  metadata: n,
802
802
  couponCode: s,
803
- label: u,
803
+ label: l,
804
804
  disabled: g = !1,
805
- onAttempt: b,
806
- onSuccess: h,
805
+ onAttempt: C,
806
+ onSuccess: b,
807
807
  onError: c,
808
808
  className: a = ""
809
809
  }) {
810
- const { status: o, error: d, transactionId: i, processPayment: l, processCartPayment: p } = et(), m = V(), { isCartMode: w, effectiveResource: y } = he(e, t), { t: k, translations: P } = ne(), E = u || k("ui.pay_with_credits") || "Pay with Credits", M = m.unstyled ? a : `${m.className} cedros-theme__credits-button ${a}`.trim(), $ = d && typeof d != "string" ? d?.code ?? null : null, U = d ? typeof d == "string" ? d : ((N) => {
811
- if (!N || !P) return "";
812
- const v = P.errors[N];
813
- return v ? v.action ? `${v.message} ${v.action}` : v.message : "";
814
- })($) : null, D = I(async () => {
810
+ const { status: o, error: u, transactionId: d, processPayment: i, processCartPayment: p } = et(), m = V(), { isCartMode: h, effectiveResource: y } = he(e, t), { t: I, translations: v } = ne(), P = l || I("ui.pay_with_credits") || "Pay with Credits", N = m.unstyled ? a : `${m.className} cedros-theme__credits-button ${a}`.trim(), A = u && typeof u != "string" ? u?.code ?? null : null, q = u ? typeof u == "string" ? u : ((T) => {
811
+ if (!T || !v) return "";
812
+ const M = v.errors[T];
813
+ return M ? M.action ? `${M.message} ${M.action}` : M.message : "";
814
+ })(A) : null, D = R(async () => {
815
815
  j().debug("[CreditsButton] executePayment");
816
- const N = w && t ? ge(t) : void 0;
817
- if (oe("credits", y, N), b && b("credits"), !r) {
816
+ const T = h && t ? ge(t) : void 0;
817
+ if (oe("credits", y, T), C && C("credits"), !r) {
818
818
  const x = "Authentication required: please log in to pay with credits";
819
- j().error("[CreditsButton]", x), Y("credits", x, y, N), c && c(x);
819
+ j().error("[CreditsButton]", x), Y("credits", x, y, T), c && c(x);
820
820
  return;
821
821
  }
822
- if (!w && !y) {
822
+ if (!h && !y) {
823
823
  const x = "Invalid payment configuration: missing resource";
824
- j().error("[CreditsButton]", x), Y("credits", x, y, N), c && c(x);
824
+ j().error("[CreditsButton]", x), Y("credits", x, y, T), c && c(x);
825
825
  return;
826
826
  }
827
- let v;
828
- ae("credits", y, N), w && t ? (j().debug("[CreditsButton] Processing cart checkout"), v = await p(t, r, s, n)) : y && (j().debug("[CreditsButton] Processing single payment"), v = await l(y, r, s, n)), v && v.success && v.transactionId ? (ie("credits", v.transactionId, y, N), h && h(v.transactionId)) : v && !v.success && v.error && (Y("credits", v.error, y, N), c && c(v.error));
827
+ let M;
828
+ ae("credits", y, T), h && t ? (j().debug("[CreditsButton] Processing cart checkout"), M = await p(t, r, s, n)) : y && (j().debug("[CreditsButton] Processing single payment"), M = await i(y, r, s, n)), M && M.success && M.transactionId ? (ie("credits", M.transactionId, y, T), b && b(M.transactionId)) : M && !M.success && M.error && (Y("credits", M.error, y, T), c && c(M.error));
829
829
  }, [
830
830
  r,
831
- w,
831
+ h,
832
832
  y,
833
833
  t,
834
834
  s,
835
835
  n,
836
- l,
836
+ i,
837
837
  p,
838
+ C,
838
839
  b,
839
- h,
840
840
  c
841
- ]), C = F(() => w && t ? `credits-cart-${t.map((N) => N.resource).join("-")}` : `credits-${y || "unknown"}`, [w, t, y]), _ = F(
842
- () => se(C, D),
843
- [C, D]
844
- ), A = o === "loading", T = g || A;
845
- return /* @__PURE__ */ S("div", { className: M, style: m.unstyled ? {} : m.style, children: [
841
+ ]), w = W(() => h && t ? `credits-cart-${t.map((T) => T.resource).join("-")}` : `credits-${y || "unknown"}`, [h, t, y]), E = W(
842
+ () => se(w, D),
843
+ [w, D]
844
+ ), $ = o === "loading", k = g || $;
845
+ return /* @__PURE__ */ S("div", { className: N, style: m.unstyled ? {} : m.style, children: [
846
846
  /* @__PURE__ */ f(
847
847
  "button",
848
848
  {
849
- onClick: _,
850
- disabled: T,
849
+ onClick: E,
850
+ disabled: k,
851
851
  className: m.unstyled ? a : "cedros-theme__button cedros-theme__credits",
852
852
  type: "button",
853
- children: A ? k("ui.processing") : E
853
+ children: $ ? I("ui.processing") : P
854
854
  }
855
855
  ),
856
- U && /* @__PURE__ */ f("div", { className: m.unstyled ? "" : "cedros-theme__error", children: U }),
857
- i && /* @__PURE__ */ f("div", { className: m.unstyled ? "" : "cedros-theme__success", children: k("ui.payment_successful") })
856
+ q && /* @__PURE__ */ f("div", { className: m.unstyled ? "" : "cedros-theme__error", children: q }),
857
+ d && /* @__PURE__ */ f("div", { className: m.unstyled ? "" : "cedros-theme__success", children: I("ui.payment_successful") })
858
858
  ] });
859
859
  }
860
- const tt = q.lazy(
861
- () => import("./CryptoButton-D1BCZBk4.mjs").then((e) => e.a).then((e) => ({ default: e.CryptoButton }))
860
+ const tt = U.lazy(
861
+ () => import("./CryptoButton-BV9owVe2.mjs").then((e) => e.a).then((e) => ({ default: e.CryptoButton }))
862
862
  ), rt = ({
863
863
  isOpen: e,
864
864
  onClose: t,
865
865
  resource: r,
866
866
  items: n,
867
867
  cardLabel: s = "Card",
868
- cryptoLabel: u = "USDC (Solana)",
868
+ cryptoLabel: l = "USDC (Solana)",
869
869
  creditsLabel: g = "Pay with Credits",
870
- showCard: b = !0,
871
- showCrypto: h = !0,
870
+ showCard: C = !0,
871
+ showCrypto: b = !0,
872
872
  showCredits: c = !1,
873
873
  onPaymentAttempt: a,
874
874
  onPaymentSuccess: o,
875
- onPaymentError: d,
876
- onStripeSuccess: i,
877
- onCryptoSuccess: l,
875
+ onPaymentError: u,
876
+ onStripeSuccess: d,
877
+ onCryptoSuccess: i,
878
878
  onCreditsSuccess: p,
879
879
  onStripeError: m,
880
- onCryptoError: w,
880
+ onCryptoError: h,
881
881
  onCreditsError: y,
882
- customerEmail: k,
883
- successUrl: P,
884
- cancelUrl: E,
885
- metadata: M,
886
- couponCode: $,
882
+ customerEmail: I,
883
+ successUrl: v,
884
+ cancelUrl: P,
885
+ metadata: N,
886
+ couponCode: A,
887
887
  authToken: z,
888
- testPageUrl: U,
888
+ testPageUrl: q,
889
889
  hideMessages: D = !1
890
890
  }) => {
891
- const { tokens: C } = V();
891
+ const { tokens: w } = V();
892
892
  return te(() => {
893
- const _ = (A) => {
894
- A.key === "Escape" && e && t();
893
+ const E = ($) => {
894
+ $.key === "Escape" && e && t();
895
895
  };
896
- return window.addEventListener("keydown", _), () => window.removeEventListener("keydown", _);
896
+ return window.addEventListener("keydown", E), () => window.removeEventListener("keydown", E);
897
897
  }, [e, t]), te(() => {
898
898
  if (e) {
899
- const _ = window.scrollY;
900
- return document.body.style.position = "fixed", document.body.style.top = `-${_}px`, document.body.style.width = "100%", document.body.style.overflowY = "scroll", () => {
901
- const A = document.body.style.top ? Math.abs(parseInt(document.body.style.top.replace("px", ""), 10)) : 0;
902
- document.body.style.position = "", document.body.style.top = "", document.body.style.width = "", document.body.style.overflowY = "", window.scrollTo(0, A);
899
+ const E = window.scrollY;
900
+ return document.body.style.position = "fixed", document.body.style.top = `-${E}px`, document.body.style.width = "100%", document.body.style.overflowY = "scroll", () => {
901
+ const $ = document.body.style.top ? Math.abs(parseInt(document.body.style.top.replace("px", ""), 10)) : 0;
902
+ document.body.style.position = "", document.body.style.top = "", document.body.style.width = "", document.body.style.overflowY = "", window.scrollTo(0, $);
903
903
  };
904
904
  }
905
905
  }, [e]), e ? /* @__PURE__ */ f(
@@ -912,7 +912,7 @@ const tt = q.lazy(
912
912
  left: 0,
913
913
  right: 0,
914
914
  bottom: 0,
915
- backgroundColor: C.modalOverlay,
915
+ backgroundColor: w.modalOverlay,
916
916
  display: "flex",
917
917
  alignItems: "center",
918
918
  justifyContent: "center",
@@ -925,15 +925,15 @@ const tt = q.lazy(
925
925
  {
926
926
  className: "cedros-modal-content",
927
927
  style: {
928
- backgroundColor: C.modalBackground,
928
+ backgroundColor: w.modalBackground,
929
929
  borderRadius: "12px",
930
930
  padding: "2rem",
931
931
  maxWidth: "400px",
932
932
  width: "100%",
933
933
  boxShadow: "0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04)",
934
- border: `1px solid ${C.modalBorder}`
934
+ border: `1px solid ${w.modalBorder}`
935
935
  },
936
- onClick: (_) => _.stopPropagation(),
936
+ onClick: (E) => E.stopPropagation(),
937
937
  children: [
938
938
  /* @__PURE__ */ S(
939
939
  "div",
@@ -952,7 +952,7 @@ const tt = q.lazy(
952
952
  margin: 0,
953
953
  fontSize: "1.25rem",
954
954
  fontWeight: 600,
955
- color: C.surfaceText
955
+ color: w.surfaceText
956
956
  },
957
957
  children: "Choose Payment Method"
958
958
  }
@@ -962,7 +962,7 @@ const tt = q.lazy(
962
962
  {
963
963
  type: "button",
964
964
  onClick: t,
965
- style: He(C.surfaceText),
965
+ style: He(w.surfaceText),
966
966
  "aria-label": "Close modal",
967
967
  children: "×"
968
968
  }
@@ -971,35 +971,35 @@ const tt = q.lazy(
971
971
  }
972
972
  ),
973
973
  /* @__PURE__ */ S("div", { style: { display: "flex", flexDirection: "column", gap: "1rem" }, children: [
974
- b && /* @__PURE__ */ f(
974
+ C && /* @__PURE__ */ f(
975
975
  Me,
976
976
  {
977
977
  resource: r,
978
978
  items: n,
979
979
  label: s,
980
980
  onAttempt: a,
981
- onSuccess: i || o,
982
- onError: m || d,
983
- customerEmail: k,
984
- successUrl: P,
985
- cancelUrl: E,
986
- metadata: M,
987
- couponCode: $
981
+ onSuccess: d || o,
982
+ onError: m || u,
983
+ customerEmail: I,
984
+ successUrl: v,
985
+ cancelUrl: P,
986
+ metadata: N,
987
+ couponCode: A
988
988
  }
989
989
  ),
990
- h && /* @__PURE__ */ f(q.Suspense, { fallback: null, children: /* @__PURE__ */ f(
990
+ b && /* @__PURE__ */ f(U.Suspense, { fallback: null, children: /* @__PURE__ */ f(
991
991
  tt,
992
992
  {
993
993
  resource: r,
994
994
  items: n,
995
- label: u,
995
+ label: l,
996
996
  onAttempt: a,
997
- onSuccess: l || o,
998
- onError: w || d,
999
- testPageUrl: U,
997
+ onSuccess: i || o,
998
+ onError: h || u,
999
+ testPageUrl: q,
1000
1000
  hideMessages: D,
1001
- metadata: M,
1002
- couponCode: $
1001
+ metadata: N,
1002
+ couponCode: A
1003
1003
  }
1004
1004
  ) }),
1005
1005
  c && /* @__PURE__ */ f(
@@ -1011,9 +1011,9 @@ const tt = q.lazy(
1011
1011
  authToken: z,
1012
1012
  onAttempt: a ? () => a("credits") : void 0,
1013
1013
  onSuccess: p || o,
1014
- onError: y || d,
1015
- metadata: M,
1016
- couponCode: $
1014
+ onError: y || u,
1015
+ metadata: N,
1016
+ couponCode: A
1017
1017
  }
1018
1018
  )
1019
1019
  ] })
@@ -1028,111 +1028,111 @@ const tt = q.lazy(
1028
1028
  label: r,
1029
1029
  cardLabel: n,
1030
1030
  cryptoLabel: s,
1031
- creditsLabel: u,
1031
+ creditsLabel: l,
1032
1032
  showCard: g = !0,
1033
- showCrypto: b = !0,
1034
- showCredits: h = !1,
1033
+ showCrypto: C = !0,
1034
+ showCredits: b = !1,
1035
1035
  onPaymentAttempt: c,
1036
1036
  onPaymentSuccess: a,
1037
1037
  onPaymentError: o,
1038
- onStripeSuccess: d,
1039
- onCryptoSuccess: i,
1040
- onCreditsSuccess: l,
1038
+ onStripeSuccess: u,
1039
+ onCryptoSuccess: d,
1040
+ onCreditsSuccess: i,
1041
1041
  onStripeError: p,
1042
1042
  onCryptoError: m,
1043
- onCreditsError: w,
1043
+ onCreditsError: h,
1044
1044
  customerEmail: y,
1045
- successUrl: k,
1046
- cancelUrl: P,
1047
- metadata: E,
1048
- couponCode: M,
1049
- authToken: $,
1045
+ successUrl: I,
1046
+ cancelUrl: v,
1047
+ metadata: P,
1048
+ couponCode: N,
1049
+ authToken: A,
1050
1050
  autoDetectWallets: z = !0,
1051
- testPageUrl: U,
1051
+ testPageUrl: q,
1052
1052
  hideMessages: D = !1,
1053
- renderModal: C
1053
+ renderModal: w
1054
1054
  }) => {
1055
- const _ = V(), [A, T] = Q(!1), { status: N, processPayment: v, processCartCheckout: x } = Ie(), { isCartMode: R, effectiveResource: W } = he(e, t), { t: B } = ne(), H = r || B("ui.purchase"), De = n || B("ui.card"), je = s || B("ui.usdc_solana"), Be = u || B("ui.pay_with_credits") || "Pay with Credits", ve = I(async () => {
1055
+ const E = V(), [$, k] = Q(!1), { status: T, processPayment: M, processCartCheckout: x } = Ie(), { isCartMode: _, effectiveResource: F } = he(e, t), { t: B } = ne(), H = r || B("ui.purchase"), De = n || B("ui.card"), je = s || B("ui.usdc_solana"), Be = l || B("ui.pay_with_credits") || "Pay with Credits", ve = R(async () => {
1056
1056
  if (z && g) {
1057
1057
  const { detectSolanaWallets: L } = await import("./walletDetection-JZR3UCOa.mjs");
1058
1058
  if (!L()) {
1059
- const le = R ? void 0 : W, ue = R && t ? ge(t) : void 0;
1059
+ const le = _ ? void 0 : F, ue = _ && t ? ge(t) : void 0;
1060
1060
  oe("stripe", le, ue), c && c("stripe"), ae("stripe", le, ue);
1061
1061
  let O;
1062
- R && t ? O = await x(
1062
+ _ && t ? O = await x(
1063
1063
  t,
1064
- k,
1064
+ I,
1065
+ v,
1065
1066
  P,
1066
- E,
1067
1067
  y,
1068
- M
1069
- ) : W && (O = await v(
1070
- W,
1071
- k,
1068
+ N
1069
+ ) : F && (O = await M(
1070
+ F,
1071
+ I,
1072
+ v,
1072
1073
  P,
1073
- E,
1074
1074
  y,
1075
- M
1076
- )), O && O.success && O.transactionId ? (ie("stripe", O.transactionId, le, ue), d ? d(O.transactionId) : a && a(O.transactionId)) : O && !O.success && O.error && (Y("stripe", O.error, le, ue), p ? p(O.error) : o && o(O.error));
1075
+ N
1076
+ )), O && O.success && O.transactionId ? (ie("stripe", O.transactionId, le, ue), u ? u(O.transactionId) : a && a(O.transactionId)) : O && !O.success && O.error && (Y("stripe", O.error, le, ue), p ? p(O.error) : o && o(O.error));
1077
1077
  return;
1078
1078
  }
1079
1079
  }
1080
- T(!0);
1081
- }, [z, g, R, t, W, x, v, k, P, E, y, M, a, o, d, p, c]), Pe = F(() => R && t ? `purchase-cart-${t.map((L) => L.resource).join("-")}` : `purchase-${W || "unknown"}`, [R, t, W]), Le = F(
1080
+ k(!0);
1081
+ }, [z, g, _, t, F, x, M, I, v, P, y, N, a, o, u, p, c]), Pe = W(() => _ && t ? `purchase-cart-${t.map((L) => L.resource).join("-")}` : `purchase-${F || "unknown"}`, [_, t, F]), Le = W(
1082
1082
  () => se(Pe, ve),
1083
1083
  [Pe, ve]
1084
- ), ce = N === "loading", xe = {
1085
- isOpen: A,
1086
- onClose: () => T(!1),
1087
- resource: R ? void 0 : W,
1088
- items: R ? t : void 0,
1084
+ ), ce = T === "loading", xe = {
1085
+ isOpen: $,
1086
+ onClose: () => k(!1),
1087
+ resource: _ ? void 0 : F,
1088
+ items: _ ? t : void 0,
1089
1089
  cardLabel: De,
1090
1090
  cryptoLabel: je,
1091
1091
  creditsLabel: Be,
1092
1092
  showCard: g,
1093
- showCrypto: b,
1094
- showCredits: h,
1093
+ showCrypto: C,
1094
+ showCredits: b,
1095
1095
  onPaymentAttempt: c,
1096
1096
  onPaymentSuccess: (L) => {
1097
- T(!1), a?.(L);
1097
+ k(!1), a?.(L);
1098
1098
  },
1099
1099
  onPaymentError: (L) => {
1100
- T(!1), o?.(L);
1100
+ k(!1), o?.(L);
1101
1101
  },
1102
1102
  onStripeSuccess: (L) => {
1103
- T(!1), d?.(L);
1103
+ k(!1), u?.(L);
1104
1104
  },
1105
1105
  onCryptoSuccess: (L) => {
1106
- T(!1), i?.(L);
1106
+ k(!1), d?.(L);
1107
1107
  },
1108
1108
  onCreditsSuccess: (L) => {
1109
- T(!1), l?.(L);
1109
+ k(!1), i?.(L);
1110
1110
  },
1111
1111
  onStripeError: (L) => {
1112
- T(!1), p?.(L);
1112
+ k(!1), p?.(L);
1113
1113
  },
1114
1114
  onCryptoError: (L) => {
1115
- T(!1), m?.(L);
1115
+ k(!1), m?.(L);
1116
1116
  },
1117
1117
  onCreditsError: (L) => {
1118
- T(!1), w?.(L);
1118
+ k(!1), h?.(L);
1119
1119
  },
1120
1120
  customerEmail: y,
1121
- successUrl: k,
1122
- cancelUrl: P,
1123
- metadata: E,
1124
- couponCode: M,
1125
- authToken: $,
1126
- testPageUrl: U,
1121
+ successUrl: I,
1122
+ cancelUrl: v,
1123
+ metadata: P,
1124
+ couponCode: N,
1125
+ authToken: A,
1126
+ testPageUrl: q,
1127
1127
  hideMessages: D
1128
1128
  };
1129
- return /* @__PURE__ */ S("div", { className: _.unstyled ? "" : _.className, style: _.unstyled ? {} : _.style, children: [
1129
+ return /* @__PURE__ */ S("div", { className: E.unstyled ? "" : E.className, style: E.unstyled ? {} : E.style, children: [
1130
1130
  /* @__PURE__ */ f(
1131
1131
  "button",
1132
1132
  {
1133
1133
  onClick: Le,
1134
1134
  disabled: ce,
1135
- className: _.unstyled ? "" : "cedros-theme__button cedros-theme__stripe",
1135
+ className: E.unstyled ? "" : "cedros-theme__button cedros-theme__stripe",
1136
1136
  style: {
1137
1137
  width: "100%",
1138
1138
  cursor: ce ? "not-allowed" : "pointer",
@@ -1142,7 +1142,7 @@ const tt = q.lazy(
1142
1142
  children: ce ? B("ui.processing") : H
1143
1143
  }
1144
1144
  ),
1145
- C ? C(xe) : /* @__PURE__ */ f(rt, { ...xe })
1145
+ w ? w(xe) : /* @__PURE__ */ f(rt, { ...xe })
1146
1146
  ] });
1147
1147
  }, st = {
1148
1148
  "mainnet-beta": "https://api.mainnet-beta.solana.com",
@@ -1150,8 +1150,8 @@ const tt = q.lazy(
1150
1150
  testnet: "https://api.testnet.solana.com"
1151
1151
  };
1152
1152
  function ot() {
1153
- const [e, t] = q.useState(null);
1154
- return q.useEffect(() => {
1153
+ const [e, t] = U.useState(null);
1154
+ return U.useEffect(() => {
1155
1155
  let r = !1;
1156
1156
  return import("@solana/wallet-adapter-react").then((n) => {
1157
1157
  r || t(n);
@@ -1167,51 +1167,51 @@ function at({
1167
1167
  }) {
1168
1168
  const n = ot();
1169
1169
  if (!n) return /* @__PURE__ */ f(me, { children: r });
1170
- const { ConnectionProvider: s, WalletProvider: u } = n;
1171
- return /* @__PURE__ */ f(s, { endpoint: e, children: /* @__PURE__ */ f(u, { wallets: t, autoConnect: !1, children: r }) });
1170
+ const { ConnectionProvider: s, WalletProvider: l } = n;
1171
+ return /* @__PURE__ */ f(s, { endpoint: e, children: /* @__PURE__ */ f(l, { wallets: t, autoConnect: !1, children: r }) });
1172
1172
  }
1173
- const it = q.lazy(
1174
- () => import("./CryptoButton-D1BCZBk4.mjs").then((e) => e.a).then((e) => ({ default: e.CryptoButton }))
1173
+ const it = U.lazy(
1174
+ () => import("./CryptoButton-BV9owVe2.mjs").then((e) => e.a).then((e) => ({ default: e.CryptoButton }))
1175
1175
  );
1176
1176
  function qt(e) {
1177
- const { resource: t, items: r, checkout: n = {}, display: s = {}, callbacks: u = {}, advanced: g = {} } = e, { config: b, walletPool: h } = re(), c = V(), { isCartMode: a } = he(t, r), o = s.showCrypto ?? !0, d = q.useMemo(() => ({
1177
+ const { resource: t, items: r, checkout: n = {}, display: s = {}, callbacks: l = {}, advanced: g = {} } = e, { config: C, walletPool: b } = re(), c = V(), { isCartMode: a } = he(t, r), o = s.showCrypto ?? !0, u = U.useMemo(() => ({
1178
1178
  marginTop: "0.5rem",
1179
1179
  fontSize: "0.875rem",
1180
1180
  color: c.tokens.surfaceText,
1181
1181
  opacity: 0.7,
1182
1182
  textAlign: "center"
1183
- }), [c.tokens.surfaceText]), i = q.useMemo(
1184
- () => o ? g.wallets && g.wallets.length > 0 ? g.wallets : h.getAdapters() : [],
1185
- [g.wallets, h, o]
1186
- ), l = q.useMemo(
1183
+ }), [c.tokens.surfaceText]), d = U.useMemo(
1184
+ () => o ? g.wallets && g.wallets.length > 0 ? g.wallets : b.getAdapters() : [],
1185
+ [g.wallets, b, o]
1186
+ ), i = U.useMemo(
1187
1187
  () => r ? ge(r) : 0,
1188
1188
  [r]
1189
- ), { onPaymentSuccess: p, onPaymentError: m, onPaymentAttempt: w } = u, y = q.useCallback(
1189
+ ), { onPaymentSuccess: p, onPaymentError: m, onPaymentAttempt: h } = l, y = U.useCallback(
1190
1190
  (x) => p?.({ transactionId: x, method: "stripe" }),
1191
1191
  [p]
1192
- ), k = q.useCallback(
1192
+ ), I = U.useCallback(
1193
1193
  (x) => p?.({ transactionId: x, method: "crypto" }),
1194
1194
  [p]
1195
- ), P = q.useCallback(
1195
+ ), v = U.useCallback(
1196
1196
  (x) => m?.({ message: x, method: "stripe" }),
1197
1197
  [m]
1198
- ), E = q.useCallback(
1198
+ ), P = U.useCallback(
1199
1199
  (x) => m?.({ message: x, method: "crypto" }),
1200
1200
  [m]
1201
- ), M = q.useCallback(
1201
+ ), N = U.useCallback(
1202
1202
  (x) => p?.({ transactionId: x, method: "credits" }),
1203
1203
  [p]
1204
- ), $ = q.useCallback(
1204
+ ), A = U.useCallback(
1205
1205
  (x) => m?.({ message: x, method: "credits" }),
1206
1206
  [m]
1207
- ), z = q.useCallback(
1208
- () => w?.("credits"),
1209
- [w]
1210
- ), U = o ? b.solanaEndpoint ?? st[b.solanaCluster] : "";
1207
+ ), z = U.useCallback(
1208
+ () => h?.("credits"),
1209
+ [h]
1210
+ ), q = o ? C.solanaEndpoint ?? st[C.solanaCluster] : "";
1211
1211
  if (!t && (!r || r.length === 0))
1212
1212
  return j().error('CedrosPay: Must provide either "resource" or "items" prop'), /* @__PURE__ */ f("div", { className: s.className, style: { color: c.tokens.errorText }, children: "Configuration error: No resource or items provided" });
1213
- const D = s.showCard ?? !0, C = s.showCredits ?? !1, _ = s.showPurchaseButton ?? !1, A = s.layout ?? "vertical", T = s.hideMessages ?? !1, N = g.autoDetectWallets ?? !0, v = /* @__PURE__ */ f("div", { className: c.unstyled ? s.className : `cedros-theme__pay ${s.className || ""}`, children: /* @__PURE__ */ S("div", { className: c.unstyled ? "" : `cedros-theme__pay-content cedros-theme__pay-content--${A}`, children: [
1214
- _ ? /* @__PURE__ */ f(
1213
+ const D = s.showCard ?? !0, w = s.showCredits ?? !1, E = s.showPurchaseButton ?? !1, $ = s.layout ?? "vertical", k = s.hideMessages ?? !1, T = g.autoDetectWallets ?? !0, M = /* @__PURE__ */ f("div", { className: c.unstyled ? s.className : `cedros-theme__pay ${s.className || ""}`, children: /* @__PURE__ */ S("div", { className: c.unstyled ? "" : `cedros-theme__pay-content cedros-theme__pay-content--${$}`, children: [
1214
+ E ? /* @__PURE__ */ f(
1215
1215
  nt,
1216
1216
  {
1217
1217
  resource: a ? void 0 : t || r?.[0]?.resource,
@@ -1221,21 +1221,21 @@ function qt(e) {
1221
1221
  cryptoLabel: s.cryptoLabel,
1222
1222
  showCard: D,
1223
1223
  showCrypto: o,
1224
- onPaymentAttempt: u.onPaymentAttempt,
1224
+ onPaymentAttempt: l.onPaymentAttempt,
1225
1225
  onPaymentSuccess: y,
1226
- onPaymentError: P,
1226
+ onPaymentError: v,
1227
1227
  onStripeSuccess: y,
1228
- onCryptoSuccess: k,
1229
- onStripeError: P,
1230
- onCryptoError: E,
1228
+ onCryptoSuccess: I,
1229
+ onStripeError: v,
1230
+ onCryptoError: P,
1231
1231
  customerEmail: n.customerEmail,
1232
1232
  successUrl: n.successUrl,
1233
1233
  cancelUrl: n.cancelUrl,
1234
1234
  metadata: n.metadata,
1235
1235
  couponCode: n.couponCode,
1236
- autoDetectWallets: N,
1236
+ autoDetectWallets: T,
1237
1237
  testPageUrl: g.testPageUrl,
1238
- hideMessages: T,
1238
+ hideMessages: k,
1239
1239
  renderModal: s.renderModal
1240
1240
  }
1241
1241
  ) : /* @__PURE__ */ S(me, { children: [
@@ -1250,12 +1250,12 @@ function qt(e) {
1250
1250
  metadata: n.metadata,
1251
1251
  couponCode: n.couponCode,
1252
1252
  label: s.cardLabel,
1253
- onAttempt: u.onPaymentAttempt,
1253
+ onAttempt: l.onPaymentAttempt,
1254
1254
  onSuccess: y,
1255
- onError: P
1255
+ onError: v
1256
1256
  }
1257
1257
  ),
1258
- o && /* @__PURE__ */ f(q.Suspense, { fallback: null, children: /* @__PURE__ */ f(
1258
+ o && /* @__PURE__ */ f(U.Suspense, { fallback: null, children: /* @__PURE__ */ f(
1259
1259
  it,
1260
1260
  {
1261
1261
  resource: a ? void 0 : t || r?.[0]?.resource,
@@ -1263,14 +1263,14 @@ function qt(e) {
1263
1263
  metadata: n.metadata,
1264
1264
  couponCode: n.couponCode,
1265
1265
  label: s.cryptoLabel,
1266
- onAttempt: u.onPaymentAttempt,
1267
- onSuccess: k,
1268
- onError: E,
1266
+ onAttempt: l.onPaymentAttempt,
1267
+ onSuccess: I,
1268
+ onError: P,
1269
1269
  testPageUrl: g.testPageUrl,
1270
- hideMessages: T
1270
+ hideMessages: k
1271
1271
  }
1272
1272
  ) }),
1273
- C && /* @__PURE__ */ f(
1273
+ w && /* @__PURE__ */ f(
1274
1274
  Te,
1275
1275
  {
1276
1276
  resource: a ? void 0 : t || r?.[0]?.resource,
@@ -1280,18 +1280,18 @@ function qt(e) {
1280
1280
  couponCode: n.couponCode,
1281
1281
  label: s.creditsLabel,
1282
1282
  onAttempt: z,
1283
- onSuccess: M,
1284
- onError: $
1283
+ onSuccess: N,
1284
+ onError: A
1285
1285
  }
1286
1286
  )
1287
1287
  ] }),
1288
- a && r && r.length > 1 && !T && /* @__PURE__ */ S("div", { style: d, children: [
1288
+ a && r && r.length > 1 && !k && /* @__PURE__ */ S("div", { style: u, children: [
1289
1289
  "Checking out ",
1290
- l,
1290
+ i,
1291
1291
  " items"
1292
1292
  ] })
1293
1293
  ] }) });
1294
- return /* @__PURE__ */ f("div", { className: c.unstyled ? s.className : c.className, style: c.unstyled ? {} : c.style, children: /* @__PURE__ */ f(at, { endpoint: U || "https://api.devnet.solana.com", wallets: i, children: v }) });
1294
+ return /* @__PURE__ */ f("div", { className: c.unstyled ? s.className : c.className, style: c.unstyled ? {} : c.style, children: /* @__PURE__ */ f(at, { endpoint: q || "https://api.devnet.solana.com", wallets: d, children: M }) });
1295
1295
  }
1296
1296
  function zt({
1297
1297
  product: e,
@@ -1300,7 +1300,7 @@ function zt({
1300
1300
  className: n = "",
1301
1301
  style: s = {}
1302
1302
  }) {
1303
- const u = t === "stripe", g = u ? e.fiatAmount : e.cryptoAmount, b = u ? e.effectiveFiatAmount : e.effectiveCryptoAmount, h = u ? e.fiatCurrency.toUpperCase() : e.cryptoToken, c = u ? e.hasStripeCoupon : e.hasCryptoCoupon, a = u ? e.stripeDiscountPercent : e.cryptoDiscountPercent;
1303
+ const l = t === "stripe", g = l ? e.fiatAmount : e.cryptoAmount, C = l ? e.effectiveFiatAmount : e.effectiveCryptoAmount, b = l ? e.fiatCurrency.toUpperCase() : e.cryptoToken, c = l ? e.hasStripeCoupon : e.hasCryptoCoupon, a = l ? e.stripeDiscountPercent : e.cryptoDiscountPercent;
1304
1304
  return /* @__PURE__ */ S("div", { className: n, style: s, children: [
1305
1305
  r && c && /* @__PURE__ */ S(
1306
1306
  "span",
@@ -1314,14 +1314,14 @@ function zt({
1314
1314
  children: [
1315
1315
  g.toFixed(2),
1316
1316
  " ",
1317
- h
1317
+ b
1318
1318
  ]
1319
1319
  }
1320
1320
  ),
1321
1321
  /* @__PURE__ */ S("span", { style: { fontWeight: 600 }, children: [
1322
- b.toFixed(2),
1322
+ C.toFixed(2),
1323
1323
  " ",
1324
- h
1324
+ b
1325
1325
  ] }),
1326
1326
  c && a > 0 && /* @__PURE__ */ S(
1327
1327
  "span",
@@ -1349,10 +1349,10 @@ function Ut({
1349
1349
  className: r = "",
1350
1350
  style: n = {}
1351
1351
  }) {
1352
- const s = t === "stripe", u = s ? e.hasStripeCoupon : e.hasCryptoCoupon, g = s ? e.stripeDiscountPercent : e.cryptoDiscountPercent, b = s ? e.stripeCouponCode : e.cryptoCouponCode;
1353
- if (!u || g === 0)
1352
+ const s = t === "stripe", l = s ? e.hasStripeCoupon : e.hasCryptoCoupon, g = s ? e.stripeDiscountPercent : e.cryptoDiscountPercent, C = s ? e.stripeCouponCode : e.cryptoCouponCode;
1353
+ if (!l || g === 0)
1354
1354
  return null;
1355
- const h = s ? `${g}% off with card!` : `${g}% off with crypto!`;
1355
+ const b = s ? `${g}% off with card!` : `${g}% off with crypto!`;
1356
1356
  return /* @__PURE__ */ S(
1357
1357
  "div",
1358
1358
  {
@@ -1369,8 +1369,8 @@ function Ut({
1369
1369
  ...n
1370
1370
  },
1371
1371
  children: [
1372
- h,
1373
- b && /* @__PURE__ */ S(
1372
+ b,
1373
+ C && /* @__PURE__ */ S(
1374
1374
  "span",
1375
1375
  {
1376
1376
  style: {
@@ -1381,7 +1381,7 @@ function Ut({
1381
1381
  },
1382
1382
  children: [
1383
1383
  "(",
1384
- b,
1384
+ C,
1385
1385
  ")"
1386
1386
  ]
1387
1387
  }
@@ -1397,8 +1397,8 @@ function ct() {
1397
1397
  sessionId: null,
1398
1398
  subscriptionStatus: null,
1399
1399
  expiresAt: null
1400
- }), n = X(!1), s = I(
1401
- async (h) => {
1400
+ }), n = X(!1), s = R(
1401
+ async (b) => {
1402
1402
  if (n.current)
1403
1403
  return { success: !1, error: "Payment already in progress" };
1404
1404
  n.current = !0, r((c) => ({
@@ -1407,7 +1407,7 @@ function ct() {
1407
1407
  error: null
1408
1408
  }));
1409
1409
  try {
1410
- const c = await e.processSubscription(h);
1410
+ const c = await e.processSubscription(b);
1411
1411
  return r((a) => ({
1412
1412
  ...a,
1413
1413
  status: c.success ? "success" : "error",
@@ -1426,15 +1426,15 @@ function ct() {
1426
1426
  }
1427
1427
  },
1428
1428
  [e]
1429
- ), u = I(
1430
- async (h) => {
1429
+ ), l = R(
1430
+ async (b) => {
1431
1431
  r((c) => ({
1432
1432
  ...c,
1433
1433
  status: "checking",
1434
1434
  error: null
1435
1435
  }));
1436
1436
  try {
1437
- const c = await e.checkSubscriptionStatus(h);
1437
+ const c = await e.checkSubscriptionStatus(b);
1438
1438
  return r((a) => ({
1439
1439
  ...a,
1440
1440
  status: c.active ? "success" : "idle",
@@ -1451,8 +1451,8 @@ function ct() {
1451
1451
  }
1452
1452
  },
1453
1453
  [e]
1454
- ), g = I(
1455
- async (h, c, a) => {
1454
+ ), g = R(
1455
+ async (b, c, a) => {
1456
1456
  r((o) => ({
1457
1457
  ...o,
1458
1458
  status: "loading",
@@ -1460,25 +1460,25 @@ function ct() {
1460
1460
  }));
1461
1461
  try {
1462
1462
  const o = await e.requestSubscriptionQuote(
1463
- h,
1463
+ b,
1464
1464
  c,
1465
1465
  a
1466
1466
  );
1467
- return r((d) => ({
1468
- ...d,
1467
+ return r((u) => ({
1468
+ ...u,
1469
1469
  status: "idle"
1470
1470
  })), o;
1471
1471
  } catch (o) {
1472
- const d = o instanceof Error ? o.message : "Failed to get subscription quote";
1473
- throw r((i) => ({
1474
- ...i,
1472
+ const u = o instanceof Error ? o.message : "Failed to get subscription quote";
1473
+ throw r((d) => ({
1474
+ ...d,
1475
1475
  status: "error",
1476
- error: d
1476
+ error: u
1477
1477
  })), o;
1478
1478
  }
1479
1479
  },
1480
1480
  [e]
1481
- ), b = I(() => {
1481
+ ), C = R(() => {
1482
1482
  r({
1483
1483
  status: "idle",
1484
1484
  error: null,
@@ -1490,9 +1490,9 @@ function ct() {
1490
1490
  return {
1491
1491
  ...t,
1492
1492
  processSubscription: s,
1493
- checkStatus: u,
1493
+ checkStatus: l,
1494
1494
  requestQuote: g,
1495
- reset: b
1495
+ reset: C
1496
1496
  };
1497
1497
  }
1498
1498
  function Ot({
@@ -1501,72 +1501,65 @@ function Ot({
1501
1501
  intervalDays: r,
1502
1502
  trialDays: n,
1503
1503
  successUrl: s,
1504
- cancelUrl: u,
1505
- metadata: g,
1506
- customerEmail: b,
1507
- couponCode: h,
1508
- label: c,
1509
- disabled: a = !1,
1510
- onAttempt: o,
1511
- onSuccess: d,
1512
- onError: i,
1513
- className: l = ""
1504
+ cancelUrl: l,
1505
+ customerEmail: g,
1506
+ label: C,
1507
+ disabled: b = !1,
1508
+ onAttempt: c,
1509
+ onSuccess: a,
1510
+ onError: o,
1511
+ className: u = ""
1514
1512
  }) {
1515
- const { status: p, error: m, sessionId: w, processSubscription: y } = ct(), k = V(), { t: P, translations: E } = ne(), M = c || P("ui.subscribe"), $ = k.unstyled ? l : `${k.className} cedros-theme__stripe-button ${l}`.trim(), z = m && typeof m != "string" ? m?.code ?? null : null, D = m ? typeof m == "string" ? m : ((v) => {
1516
- if (!v || !E) return "";
1517
- const x = E.errors[v];
1518
- return x ? x.action ? `${x.message} ${x.action}` : x.message : "";
1519
- })(z) : null, C = I(async () => {
1513
+ const { status: d, error: i, sessionId: p, processSubscription: m } = ct(), h = V(), { t: y, translations: I } = ne(), v = C || y("ui.subscribe"), P = h.unstyled ? u : `${h.className} cedros-theme__stripe-button ${u}`.trim(), N = i && typeof i != "string" ? i?.code ?? null : null, z = i ? typeof i == "string" ? i : ((k) => {
1514
+ if (!k || !I) return "";
1515
+ const T = I.errors[k];
1516
+ return T ? T.action ? `${T.message} ${T.action}` : T.message : "";
1517
+ })(N) : null, q = R(async () => {
1520
1518
  j().debug("[SubscribeButton] executeSubscription:", {
1521
1519
  resource: e,
1522
1520
  interval: t,
1523
1521
  intervalDays: r,
1524
- trialDays: n,
1525
- couponCode: h
1526
- }), oe("stripe", e), o && o("stripe"), ae("stripe", e);
1527
- const v = await y({
1522
+ trialDays: n
1523
+ }), oe("stripe", e), c && c("stripe"), ae("stripe", e);
1524
+ const k = await m({
1528
1525
  resource: e,
1529
1526
  interval: t,
1530
1527
  intervalDays: r,
1531
1528
  trialDays: n,
1532
- customerEmail: b,
1533
- metadata: g,
1534
- couponCode: h,
1529
+ customerEmail: g,
1535
1530
  successUrl: s,
1536
- cancelUrl: u
1531
+ cancelUrl: l
1537
1532
  });
1538
- v.success && v.transactionId ? (ie("stripe", v.transactionId, e), d && d(v.transactionId)) : !v.success && v.error && (Y("stripe", v.error, e), i && i(v.error));
1533
+ k.success && k.transactionId ? (ie("stripe", k.transactionId, e), a && a(k.transactionId)) : !k.success && k.error && (Y("stripe", k.error, e), o && o(k.error));
1539
1534
  }, [
1540
1535
  e,
1541
1536
  t,
1542
1537
  r,
1543
1538
  n,
1544
- b,
1545
1539
  g,
1546
- h,
1547
1540
  s,
1548
- u,
1549
- y,
1550
- o,
1551
- d,
1552
- i
1553
- ]), _ = F(() => `subscribe-${e}-${t}`, [e, t]), A = F(
1554
- () => se(_, C),
1555
- [_, C]
1556
- ), T = p === "loading", N = a || T;
1557
- return /* @__PURE__ */ S("div", { className: $, style: k.unstyled ? {} : k.style, children: [
1541
+ l,
1542
+ m,
1543
+ c,
1544
+ a,
1545
+ o
1546
+ ]), D = W(() => `subscribe-${e}-${t}`, [e, t]), w = W(
1547
+ () => se(D, q),
1548
+ [D, q]
1549
+ ), E = d === "loading", $ = b || E;
1550
+ return /* @__PURE__ */ S("div", { className: P, style: h.unstyled ? {} : h.style, children: [
1558
1551
  /* @__PURE__ */ f(
1559
1552
  "button",
1560
1553
  {
1561
- onClick: A,
1562
- disabled: N,
1563
- className: k.unstyled ? l : "cedros-theme__button cedros-theme__stripe",
1554
+ onClick: w,
1555
+ disabled: $,
1556
+ className: h.unstyled ? u : "cedros-theme__button cedros-theme__stripe",
1564
1557
  type: "button",
1565
- children: T ? P("ui.processing") : M
1558
+ children: E ? y("ui.processing") : v
1566
1559
  }
1567
1560
  ),
1568
- D && /* @__PURE__ */ f("div", { className: k.unstyled ? "" : "cedros-theme__error", children: D }),
1569
- w && /* @__PURE__ */ f("div", { className: k.unstyled ? "" : "cedros-theme__success", children: P("ui.redirecting_to_checkout") })
1561
+ z && /* @__PURE__ */ f("div", { className: h.unstyled ? "" : "cedros-theme__error", children: z }),
1562
+ p && /* @__PURE__ */ f("div", { className: h.unstyled ? "" : "cedros-theme__success", children: y("ui.redirecting_to_checkout") })
1570
1563
  ] });
1571
1564
  }
1572
1565
  function lt() {
@@ -1577,7 +1570,7 @@ function lt() {
1577
1570
  subscriptionStatus: null,
1578
1571
  expiresAt: null,
1579
1572
  creditsRequirement: null
1580
- }), s = X(!1), u = I(
1573
+ }), s = X(!1), l = R(
1581
1574
  async (c, a) => {
1582
1575
  n((o) => ({
1583
1576
  ...o,
@@ -1589,98 +1582,98 @@ function lt() {
1589
1582
  resource: c,
1590
1583
  userId: a
1591
1584
  });
1592
- return n((d) => ({
1593
- ...d,
1585
+ return n((u) => ({
1586
+ ...u,
1594
1587
  status: o.active ? "success" : "idle",
1595
1588
  subscriptionStatus: o.status,
1596
1589
  expiresAt: o.expiresAt || o.currentPeriodEnd || null
1597
1590
  })), o;
1598
1591
  } catch (o) {
1599
- const d = pe(o, "Failed to check subscription status");
1600
- return n((i) => ({
1601
- ...i,
1592
+ const u = pe(o, "Failed to check subscription status");
1593
+ return n((d) => ({
1594
+ ...d,
1602
1595
  status: "error",
1603
- error: d
1596
+ error: u
1604
1597
  })), null;
1605
1598
  }
1606
1599
  },
1607
1600
  [e]
1608
- ), g = I(
1601
+ ), g = R(
1609
1602
  async (c, a, o) => {
1610
- n((d) => ({
1611
- ...d,
1603
+ n((u) => ({
1604
+ ...u,
1612
1605
  status: "loading",
1613
1606
  error: null
1614
1607
  }));
1615
1608
  try {
1616
- const d = await t.requestQuote(
1609
+ const u = await t.requestQuote(
1617
1610
  c,
1618
1611
  o?.couponCode
1619
1612
  );
1613
+ return n((d) => ({
1614
+ ...d,
1615
+ status: "idle",
1616
+ creditsRequirement: u
1617
+ })), u;
1618
+ } catch (u) {
1619
+ const d = pe(u, "Failed to get subscription quote");
1620
1620
  return n((i) => ({
1621
1621
  ...i,
1622
- status: "idle",
1623
- creditsRequirement: d
1624
- })), d;
1625
- } catch (d) {
1626
- const i = pe(d, "Failed to get subscription quote");
1627
- return n((l) => ({
1628
- ...l,
1629
1622
  status: "error",
1630
- error: i
1623
+ error: d
1631
1624
  })), null;
1632
1625
  }
1633
1626
  },
1634
1627
  [t]
1635
- ), b = I(
1636
- async (c, a, o, d) => {
1628
+ ), C = R(
1629
+ async (c, a, o, u) => {
1637
1630
  if (s.current)
1638
1631
  return { success: !1, error: "Payment already in progress" };
1639
1632
  if (!o) {
1640
- const i = "Authentication required for credits payment";
1641
- return n((l) => ({ ...l, status: "error", error: i })), { success: !1, error: i };
1633
+ const d = "Authentication required for credits payment";
1634
+ return n((i) => ({ ...i, status: "error", error: d })), { success: !1, error: d };
1642
1635
  }
1643
- s.current = !0, n((i) => ({
1644
- ...i,
1636
+ s.current = !0, n((d) => ({
1637
+ ...d,
1645
1638
  status: "loading",
1646
1639
  error: null
1647
1640
  }));
1648
1641
  try {
1649
- const i = await t.processPayment(
1642
+ const d = await t.processPayment(
1650
1643
  c,
1651
1644
  o,
1652
- d?.couponCode,
1645
+ u?.couponCode,
1653
1646
  {
1654
1647
  interval: a,
1655
- ...d?.intervalDays && { intervalDays: String(d.intervalDays) }
1648
+ ...u?.intervalDays && { intervalDays: String(u.intervalDays) }
1656
1649
  }
1657
1650
  );
1658
- return i.success ? n({
1651
+ return d.success ? n({
1659
1652
  status: "success",
1660
1653
  error: null,
1661
- sessionId: i.transactionId || null,
1654
+ sessionId: d.transactionId || null,
1662
1655
  subscriptionStatus: "active",
1663
1656
  expiresAt: null,
1664
1657
  // Will be updated on next status check
1665
1658
  creditsRequirement: null
1666
- }) : n((l) => ({
1667
- ...l,
1659
+ }) : n((i) => ({
1660
+ ...i,
1668
1661
  status: "error",
1669
- error: i.error || "Credits subscription payment failed"
1670
- })), i;
1671
- } catch (i) {
1672
- const l = pe(i, "Credits subscription payment failed");
1662
+ error: d.error || "Credits subscription payment failed"
1663
+ })), d;
1664
+ } catch (d) {
1665
+ const i = pe(d, "Credits subscription payment failed");
1673
1666
  return n((p) => ({
1674
1667
  ...p,
1675
1668
  status: "error",
1676
- error: l
1677
- })), { success: !1, error: l };
1669
+ error: i
1670
+ })), { success: !1, error: i };
1678
1671
  } finally {
1679
1672
  s.current = !1;
1680
1673
  }
1681
1674
  },
1682
1675
  [t]
1683
- ), h = I(() => {
1676
+ ), b = R(() => {
1684
1677
  n({
1685
1678
  status: "idle",
1686
1679
  error: null,
@@ -1692,59 +1685,59 @@ function lt() {
1692
1685
  }, []);
1693
1686
  return {
1694
1687
  ...r,
1695
- checkStatus: u,
1688
+ checkStatus: l,
1696
1689
  requestQuote: g,
1697
- processPayment: b,
1698
- reset: h
1690
+ processPayment: C,
1691
+ reset: b
1699
1692
  };
1700
1693
  }
1701
- function Ft({
1694
+ function Wt({
1702
1695
  resource: e,
1703
1696
  interval: t,
1704
1697
  intervalDays: r,
1705
1698
  authToken: n,
1706
1699
  userId: s,
1707
- couponCode: u,
1700
+ couponCode: l,
1708
1701
  label: g,
1709
- disabled: b = !1,
1710
- onAttempt: h,
1702
+ disabled: C = !1,
1703
+ onAttempt: b,
1711
1704
  onSuccess: c,
1712
1705
  onError: a,
1713
1706
  className: o = "",
1714
- hideMessages: d = !1,
1715
- autoCheckStatus: i = !1
1707
+ hideMessages: u = !1,
1708
+ autoCheckStatus: d = !1
1716
1709
  }) {
1717
1710
  const {
1718
- status: l,
1711
+ status: i,
1719
1712
  error: p,
1720
1713
  subscriptionStatus: m,
1721
- expiresAt: w,
1714
+ expiresAt: h,
1722
1715
  checkStatus: y,
1723
- processPayment: k
1724
- } = lt(), P = V(), { t: E, translations: M } = ne(), $ = X(y);
1716
+ processPayment: I
1717
+ } = lt(), v = V(), { t: P, translations: N } = ne(), A = X(y);
1725
1718
  te(() => {
1726
- $.current = y;
1719
+ A.current = y;
1727
1720
  }, [y]), te(() => {
1728
- i && s && (j().debug("[CreditsSubscribeButton] Auto-checking subscription status", { resource: e, userId: s }), $.current(e, s));
1729
- }, [i, s, e]);
1730
- const z = g || E("ui.subscribe_with_credits") || "Subscribe with Credits", U = p && typeof p != "string" ? p?.code ?? null : null, C = p ? typeof p == "string" ? p : ((B) => {
1731
- if (!B || !M) return "";
1732
- const H = M.errors[B];
1721
+ d && s && (j().debug("[CreditsSubscribeButton] Auto-checking subscription status", { resource: e, userId: s }), A.current(e, s));
1722
+ }, [d, s, e]);
1723
+ const z = g || P("ui.subscribe_with_credits") || "Subscribe with Credits", q = p && typeof p != "string" ? p?.code ?? null : null, w = p ? typeof p == "string" ? p : ((B) => {
1724
+ if (!B || !N) return "";
1725
+ const H = N.errors[B];
1733
1726
  return H ? H.action ? `${H.message} ${H.action}` : H.message : "";
1734
- })(U) : null, _ = I(async () => {
1727
+ })(q) : null, E = R(async () => {
1735
1728
  if (j().debug("[CreditsSubscribeButton] executeSubscriptionFlow", {
1736
1729
  resource: e,
1737
1730
  interval: t,
1738
1731
  intervalDays: r,
1739
1732
  hasAuthToken: !!n
1740
- }), oe("credits", e), h && h("credits"), !n) {
1733
+ }), oe("credits", e), b && b("credits"), !n) {
1741
1734
  const H = "Authentication required: please log in to subscribe with credits";
1742
1735
  j().error("[CreditsSubscribeButton]", H), Y("credits", H, e), a && a(H);
1743
1736
  return;
1744
1737
  }
1745
1738
  ae("credits", e);
1746
- const B = await k(e, t, n, {
1747
- couponCode: u,
1739
+ const B = await I(e, t, n, {
1740
+ couponCode: l,
1748
1741
  intervalDays: r
1749
1742
  });
1750
1743
  B.success && B.transactionId ? (ie("credits", B.transactionId, e), c && c(B.transactionId)) : !B.success && B.error && (Y("credits", B.error, e), a && a(B.error));
@@ -1753,39 +1746,39 @@ function Ft({
1753
1746
  t,
1754
1747
  r,
1755
1748
  n,
1756
- u,
1757
- k,
1758
- h,
1749
+ l,
1750
+ I,
1751
+ b,
1759
1752
  c,
1760
1753
  a
1761
- ]), A = F(() => `credits-subscribe-${e}-${t}`, [e, t]), T = F(
1762
- () => se(A, _, {
1754
+ ]), $ = W(() => `credits-subscribe-${e}-${t}`, [e, t]), k = W(
1755
+ () => se($, E, {
1763
1756
  cooldownMs: 200,
1764
1757
  deduplicationWindowMs: 0
1765
1758
  }),
1766
- [A, _]
1767
- ), N = l === "loading" || l === "checking", v = m === "active" || m === "trialing", x = b || N || v;
1768
- let R = z;
1769
- if (N)
1770
- R = E("ui.processing");
1771
- else if (v && w) {
1772
- const B = new Date(w).toLocaleDateString();
1773
- R = `${E("ui.subscribed_until")} ${B}`;
1774
- } else v && (R = E("ui.subscribed"));
1775
- const W = P.unstyled ? o : `${P.className} cedros-theme__credits-button ${o}`.trim();
1776
- return /* @__PURE__ */ S("div", { className: W, style: P.unstyled ? {} : P.style, children: [
1759
+ [$, E]
1760
+ ), T = i === "loading" || i === "checking", M = m === "active" || m === "trialing", x = C || T || M;
1761
+ let _ = z;
1762
+ if (T)
1763
+ _ = P("ui.processing");
1764
+ else if (M && h) {
1765
+ const B = new Date(h).toLocaleDateString();
1766
+ _ = `${P("ui.subscribed_until")} ${B}`;
1767
+ } else M && (_ = P("ui.subscribed"));
1768
+ const F = v.unstyled ? o : `${v.className} cedros-theme__credits-button ${o}`.trim();
1769
+ return /* @__PURE__ */ S("div", { className: F, style: v.unstyled ? {} : v.style, children: [
1777
1770
  /* @__PURE__ */ f(
1778
1771
  "button",
1779
1772
  {
1780
- onClick: T,
1773
+ onClick: k,
1781
1774
  disabled: x,
1782
- className: P.unstyled ? o : "cedros-theme__button cedros-theme__credits",
1775
+ className: v.unstyled ? o : "cedros-theme__button cedros-theme__credits",
1783
1776
  type: "button",
1784
- children: R
1777
+ children: _
1785
1778
  }
1786
1779
  ),
1787
- !d && C && /* @__PURE__ */ f("div", { className: P.unstyled ? "" : "cedros-theme__error", children: C }),
1788
- !d && v && /* @__PURE__ */ f("div", { className: P.unstyled ? "" : "cedros-theme__success", children: E("ui.subscription_active") })
1780
+ !u && w && /* @__PURE__ */ f("div", { className: v.unstyled ? "" : "cedros-theme__error", children: w }),
1781
+ !u && M && /* @__PURE__ */ f("div", { className: v.unstyled ? "" : "cedros-theme__success", children: P("ui.subscription_active") })
1789
1782
  ] });
1790
1783
  }
1791
1784
  function ut() {
@@ -1797,67 +1790,65 @@ function ut() {
1797
1790
  userId: null
1798
1791
  }), n = X(t);
1799
1792
  n.current = t;
1800
- const s = I(
1801
- async (o, d) => {
1802
- r((i) => ({ ...i, status: "loading", error: null }));
1793
+ const s = R(
1794
+ async (o, u) => {
1795
+ r((d) => ({ ...d, status: "loading", error: null }));
1803
1796
  try {
1804
- const i = await e.getDetails(o, d);
1805
- return r((l) => ({
1806
- ...l,
1797
+ const d = await e.getDetails(o, u);
1798
+ return r((i) => ({
1799
+ ...i,
1807
1800
  status: "success",
1808
- subscription: i,
1809
- userId: d
1810
- })), i;
1811
- } catch (i) {
1812
- const l = i instanceof Error ? i.message : "Failed to load subscription";
1813
- return r((p) => ({ ...p, status: "error", error: l })), null;
1801
+ subscription: d,
1802
+ userId: u
1803
+ })), d;
1804
+ } catch (d) {
1805
+ const i = d instanceof Error ? d.message : "Failed to load subscription";
1806
+ return r((p) => ({ ...p, status: "error", error: i })), null;
1814
1807
  }
1815
1808
  },
1816
1809
  [e]
1817
- ), u = I(
1818
- async (o, d, i, l) => {
1810
+ ), l = R(
1811
+ async (o, u, d, i) => {
1819
1812
  r((p) => ({ ...p, status: "loading", error: null }));
1820
1813
  try {
1821
1814
  const p = {
1822
1815
  currentResource: o,
1823
- newResource: d,
1824
- userId: i,
1825
- newInterval: l
1816
+ newResource: u,
1817
+ userId: d,
1818
+ newInterval: i
1826
1819
  }, m = await e.previewChange(p);
1827
- return r((w) => ({
1828
- ...w,
1820
+ return r((h) => ({
1821
+ ...h,
1829
1822
  status: "idle",
1830
1823
  changePreview: m
1831
1824
  })), m;
1832
1825
  } catch (p) {
1833
1826
  const m = p instanceof Error ? p.message : "Failed to preview change";
1834
- return r((w) => ({ ...w, status: "error", error: m })), null;
1827
+ return r((h) => ({ ...h, status: "error", error: m })), null;
1835
1828
  }
1836
1829
  },
1837
1830
  [e]
1838
- ), g = I(
1831
+ ), g = R(
1839
1832
  async (o) => {
1840
- const { subscription: d, userId: i } = n.current;
1841
- if (!d || !i)
1842
- return r((l) => ({ ...l, status: "error", error: "No subscription loaded" })), null;
1843
- r((l) => ({ ...l, status: "loading", error: null }));
1833
+ const { subscription: u, userId: d } = n.current;
1834
+ if (!u || !d)
1835
+ return r((i) => ({ ...i, status: "error", error: "No subscription loaded" })), null;
1836
+ r((i) => ({ ...i, status: "loading", error: null }));
1844
1837
  try {
1845
- const l = {
1846
- currentResource: d.resource,
1838
+ const i = {
1839
+ subscriptionId: u.id,
1847
1840
  newResource: o.newResource,
1848
- userId: i,
1849
- newInterval: o.newInterval,
1850
- prorationBehavior: o.prorationBehavior,
1851
- immediate: o.immediate
1852
- }, p = await e.changeSubscription(l);
1841
+ prorationBehavior: o.prorationBehavior
1842
+ }, p = await e.changeSubscription(i);
1853
1843
  return p.success ? r((m) => ({
1854
1844
  ...m,
1855
1845
  status: "success",
1856
1846
  subscription: m.subscription ? {
1857
1847
  ...m.subscription,
1858
1848
  resource: p.newResource,
1859
- interval: p.newInterval,
1860
- status: p.status
1849
+ interval: m.subscription.interval,
1850
+ status: p.status,
1851
+ currentPeriodEnd: p.currentPeriodEnd
1861
1852
  } : null,
1862
1853
  changePreview: null
1863
1854
  })) : r((m) => ({
@@ -1865,33 +1856,32 @@ function ut() {
1865
1856
  status: "error",
1866
1857
  error: p.error || "Failed to change subscription"
1867
1858
  })), p;
1868
- } catch (l) {
1869
- const p = l instanceof Error ? l.message : "Failed to change subscription";
1859
+ } catch (i) {
1860
+ const p = i instanceof Error ? i.message : "Failed to change subscription";
1870
1861
  return r((m) => ({ ...m, status: "error", error: p })), null;
1871
1862
  }
1872
1863
  },
1873
1864
  [e]
1874
- ), b = I(
1865
+ ), C = R(
1875
1866
  async (o) => {
1876
- const { subscription: d, userId: i } = n.current;
1877
- if (!d || !i)
1878
- return r((l) => ({ ...l, status: "error", error: "No subscription loaded" })), null;
1879
- r((l) => ({ ...l, status: "loading", error: null }));
1867
+ const { subscription: u, userId: d } = n.current;
1868
+ if (!u || !d)
1869
+ return r((i) => ({ ...i, status: "error", error: "No subscription loaded" })), null;
1870
+ r((i) => ({ ...i, status: "loading", error: null }));
1880
1871
  try {
1881
- const l = {
1882
- resource: d.resource,
1883
- userId: i,
1884
- immediate: o
1885
- }, p = await e.cancel(l);
1872
+ const i = {
1873
+ subscriptionId: u.id,
1874
+ atPeriodEnd: !o
1875
+ }, p = await e.cancel(i);
1886
1876
  if (p.success) {
1887
- const m = o ? "canceled" : d.status;
1888
- r((w) => ({
1889
- ...w,
1877
+ const m = p.atPeriodEnd ? u.status : "canceled";
1878
+ r((h) => ({
1879
+ ...h,
1890
1880
  status: "success",
1891
- subscription: w.subscription ? {
1892
- ...w.subscription,
1881
+ subscription: h.subscription ? {
1882
+ ...h.subscription,
1893
1883
  status: m,
1894
- cancelAtPeriodEnd: !o
1884
+ cancelAtPeriodEnd: p.atPeriodEnd
1895
1885
  } : null
1896
1886
  }));
1897
1887
  } else
@@ -1901,19 +1891,26 @@ function ut() {
1901
1891
  error: p.error || "Failed to cancel subscription"
1902
1892
  }));
1903
1893
  return p;
1904
- } catch (l) {
1905
- const p = l instanceof Error ? l.message : "Failed to cancel subscription";
1894
+ } catch (i) {
1895
+ const p = i instanceof Error ? i.message : "Failed to cancel subscription";
1906
1896
  return r((m) => ({ ...m, status: "error", error: p })), null;
1907
1897
  }
1908
1898
  },
1909
1899
  [e]
1910
- ), h = I(
1911
- async (o, d) => {
1900
+ ), b = R(
1901
+ async (o, u) => {
1902
+ const d = n.current.subscription?.customerId ?? (o.startsWith("cus_") ? o : null);
1903
+ if (!d)
1904
+ return r((i) => ({
1905
+ ...i,
1906
+ status: "error",
1907
+ error: "No Stripe customer ID available for billing portal"
1908
+ })), null;
1912
1909
  r((i) => ({ ...i, status: "loading", error: null }));
1913
1910
  try {
1914
1911
  const i = await e.getBillingPortalUrl({
1915
- userId: o,
1916
- returnUrl: d
1912
+ customerId: d,
1913
+ returnUrl: u
1917
1914
  });
1918
1915
  try {
1919
1916
  if (new URL(i.url).protocol !== "https:")
@@ -1923,14 +1920,14 @@ function ut() {
1923
1920
  }
1924
1921
  return window.location.href = i.url, i;
1925
1922
  } catch (i) {
1926
- const l = i instanceof Error ? i.message : "Failed to open billing portal";
1927
- return r((p) => ({ ...p, status: "error", error: l })), null;
1923
+ const p = i instanceof Error ? i.message : "Failed to open billing portal";
1924
+ return r((m) => ({ ...m, status: "error", error: p })), null;
1928
1925
  }
1929
1926
  },
1930
1927
  [e]
1931
- ), c = I(() => {
1928
+ ), c = R(() => {
1932
1929
  r((o) => ({ ...o, changePreview: null }));
1933
- }, []), a = I(() => {
1930
+ }, []), a = R(() => {
1934
1931
  r({
1935
1932
  status: "idle",
1936
1933
  error: null,
@@ -1942,10 +1939,10 @@ function ut() {
1942
1939
  return {
1943
1940
  ...t,
1944
1941
  loadSubscription: s,
1945
- previewChange: u,
1942
+ previewChange: l,
1946
1943
  changeSubscription: g,
1947
- cancelSubscription: b,
1948
- openBillingPortal: h,
1944
+ cancelSubscription: C,
1945
+ openBillingPortal: b,
1949
1946
  clearPreview: c,
1950
1947
  reset: a
1951
1948
  };
@@ -2231,7 +2228,7 @@ function gt({
2231
2228
  isLoading: n,
2232
2229
  styles: s
2233
2230
  }) {
2234
- const u = e.immediateAmount < 0;
2231
+ const l = e.immediateAmount < 0;
2235
2232
  return /* @__PURE__ */ S("div", { className: "cedros-proration-preview", style: s.prorationPreview, children: [
2236
2233
  /* @__PURE__ */ f("h4", { style: s.previewTitle, children: "Change Preview" }),
2237
2234
  /* @__PURE__ */ S("div", { style: s.previewDetails, children: [
@@ -2270,8 +2267,8 @@ function gt({
2270
2267
  ] })
2271
2268
  ] }),
2272
2269
  /* @__PURE__ */ S("div", { style: { ...s.previewRow, ...s.previewTotal }, children: [
2273
- /* @__PURE__ */ f("span", { children: u ? "Credit to account:" : "Amount due now:" }),
2274
- /* @__PURE__ */ f("span", { style: { color: u ? "#22c55e" : "#ef4444" }, children: K(Math.abs(e.immediateAmount), e.currency) })
2270
+ /* @__PURE__ */ f("span", { children: l ? "Credit to account:" : "Amount due now:" }),
2271
+ /* @__PURE__ */ f("span", { style: { color: l ? "#22c55e" : "#ef4444" }, children: K(Math.abs(e.immediateAmount), e.currency) })
2275
2272
  ] }),
2276
2273
  /* @__PURE__ */ S("div", { style: s.previewRow, children: [
2277
2274
  /* @__PURE__ */ f("span", { children: "Effective date:" }),
@@ -2284,55 +2281,55 @@ function gt({
2284
2281
  ] })
2285
2282
  ] });
2286
2283
  }
2287
- function Wt({
2284
+ function Ft({
2288
2285
  resource: e,
2289
2286
  userId: t,
2290
2287
  availablePlans: r = [],
2291
2288
  onSubscriptionChanged: n,
2292
2289
  onSubscriptionCanceled: s,
2293
- billingPortalReturnUrl: u,
2290
+ billingPortalReturnUrl: l,
2294
2291
  showBillingPortal: g = !1,
2295
- className: b,
2296
- style: h
2292
+ className: C,
2293
+ style: b
2297
2294
  }) {
2298
- const { mode: c } = V(), a = F(() => ft(c === "dark"), [c]), {
2295
+ const { mode: c } = V(), a = W(() => ft(c === "dark"), [c]), {
2299
2296
  subscription: o,
2300
- changePreview: d,
2301
- status: i,
2302
- error: l,
2297
+ changePreview: u,
2298
+ status: d,
2299
+ error: i,
2303
2300
  loadSubscription: p,
2304
2301
  previewChange: m,
2305
- changeSubscription: w,
2302
+ changeSubscription: h,
2306
2303
  cancelSubscription: y,
2307
- openBillingPortal: k,
2308
- clearPreview: P
2304
+ openBillingPortal: I,
2305
+ clearPreview: v
2309
2306
  } = ut();
2310
2307
  te(() => {
2311
2308
  p(e, t);
2312
2309
  }, [e, t, p]);
2313
- const E = X(null), M = I(
2314
- async (C, _) => {
2315
- E.current = { resource: C, interval: _ }, await m(e, C, t, _);
2310
+ const P = X(null), N = R(
2311
+ async (w, E) => {
2312
+ P.current = { resource: w, interval: E }, await m(e, w, t, E);
2316
2313
  },
2317
2314
  [e, t, m]
2318
- ), $ = I(async () => {
2319
- if (!d) return;
2320
- const C = E.current;
2321
- (await w({
2322
- newResource: C?.resource || e,
2323
- newInterval: C?.interval,
2315
+ ), A = R(async () => {
2316
+ if (!u) return;
2317
+ const w = P.current;
2318
+ (await h({
2319
+ newResource: w?.resource || e,
2320
+ newInterval: w?.interval,
2324
2321
  immediate: !0
2325
- }))?.success && C && C.interval && (n?.(C.resource, C.interval), E.current = null);
2326
- }, [d, e, w, n]), z = I(
2327
- async (C) => {
2328
- (await y(C))?.success && s?.();
2322
+ }))?.success && w && w.interval && (n?.(w.resource, w.interval), P.current = null);
2323
+ }, [u, e, h, n]), z = R(
2324
+ async (w) => {
2325
+ (await y(w))?.success && s?.();
2329
2326
  },
2330
2327
  [y, s]
2331
- ), U = I(() => {
2332
- k(t, u);
2333
- }, [t, u, k]), D = i === "loading";
2334
- return /* @__PURE__ */ S("div", { className: `cedros-subscription-panel ${b || ""}`, style: { ...a.container, ...h }, children: [
2335
- l && /* @__PURE__ */ f("div", { className: "cedros-subscription-error", style: a.error, children: l }),
2328
+ ), q = R(() => {
2329
+ I(t, l);
2330
+ }, [t, l, I]), D = d === "loading";
2331
+ return /* @__PURE__ */ S("div", { className: `cedros-subscription-panel ${C || ""}`, style: { ...a.container, ...b }, children: [
2332
+ i && /* @__PURE__ */ f("div", { className: "cedros-subscription-error", style: a.error, children: i }),
2336
2333
  D && !o && /* @__PURE__ */ f("div", { className: "cedros-subscription-loading", style: a.loading, children: "Loading subscription..." }),
2337
2334
  o && /* @__PURE__ */ S(me, { children: [
2338
2335
  /* @__PURE__ */ S("div", { className: "cedros-subscription-details", style: a.details, children: [
@@ -2368,52 +2365,52 @@ function Wt({
2368
2365
  ] }),
2369
2366
  o.cancelAtPeriodEnd && /* @__PURE__ */ f("div", { style: a.cancelNotice, children: "Subscription will cancel at end of current period" })
2370
2367
  ] }),
2371
- d && /* @__PURE__ */ f(
2368
+ u && /* @__PURE__ */ f(
2372
2369
  gt,
2373
2370
  {
2374
- preview: d,
2375
- onConfirm: $,
2376
- onCancel: P,
2371
+ preview: u,
2372
+ onConfirm: A,
2373
+ onCancel: v,
2377
2374
  isLoading: D,
2378
2375
  styles: a
2379
2376
  }
2380
2377
  ),
2381
- r.length > 0 && !d && /* @__PURE__ */ S("div", { className: "cedros-available-plans", style: a.plansSection, children: [
2378
+ r.length > 0 && !u && /* @__PURE__ */ S("div", { className: "cedros-available-plans", style: a.plansSection, children: [
2382
2379
  /* @__PURE__ */ f("h4", { style: a.plansTitle, children: "Available Plans" }),
2383
- /* @__PURE__ */ f("div", { style: a.plansList, children: r.map((C) => {
2384
- const _ = C.resource === o.resource;
2380
+ /* @__PURE__ */ f("div", { style: a.plansList, children: r.map((w) => {
2381
+ const E = w.resource === o.resource;
2385
2382
  return /* @__PURE__ */ S(
2386
2383
  "div",
2387
2384
  {
2388
2385
  style: {
2389
2386
  ...a.planCard,
2390
- ..._ ? a.currentPlan : {}
2387
+ ...E ? a.currentPlan : {}
2391
2388
  },
2392
2389
  children: [
2393
- /* @__PURE__ */ f("div", { style: a.planName, children: C.name }),
2390
+ /* @__PURE__ */ f("div", { style: a.planName, children: w.name }),
2394
2391
  /* @__PURE__ */ S("div", { style: a.planPrice, children: [
2395
- K(C.price, C.currency),
2392
+ K(w.price, w.currency),
2396
2393
  "/",
2397
- C.interval
2394
+ w.interval
2398
2395
  ] }),
2399
- C.description && /* @__PURE__ */ f("div", { style: a.planDescription, children: C.description }),
2400
- _ ? /* @__PURE__ */ f("span", { style: a.currentBadge, children: "Current Plan" }) : /* @__PURE__ */ f(
2396
+ w.description && /* @__PURE__ */ f("div", { style: a.planDescription, children: w.description }),
2397
+ E ? /* @__PURE__ */ f("span", { style: a.currentBadge, children: "Current Plan" }) : /* @__PURE__ */ f(
2401
2398
  "button",
2402
2399
  {
2403
- onClick: () => M(C.resource, C.interval),
2400
+ onClick: () => N(w.resource, w.interval),
2404
2401
  style: a.changePlanButton,
2405
2402
  disabled: D,
2406
- children: C.price > o.pricePerPeriod ? "Upgrade" : "Downgrade"
2403
+ children: w.price > o.pricePerPeriod ? "Upgrade" : "Downgrade"
2407
2404
  }
2408
2405
  )
2409
2406
  ]
2410
2407
  },
2411
- C.resource
2408
+ w.resource
2412
2409
  );
2413
2410
  }) })
2414
2411
  ] }),
2415
2412
  /* @__PURE__ */ S("div", { className: "cedros-subscription-actions", style: a.actions, children: [
2416
- g && o.paymentMethod === "stripe" && /* @__PURE__ */ f("button", { onClick: U, style: a.portalButton, disabled: D, children: "Manage Billing" }),
2413
+ g && o.paymentMethod === "stripe" && /* @__PURE__ */ f("button", { onClick: q, style: a.portalButton, disabled: D, children: "Manage Billing" }),
2417
2414
  o.status === "active" && !o.cancelAtPeriodEnd && /* @__PURE__ */ f(
2418
2415
  "button",
2419
2416
  {
@@ -2503,7 +2500,7 @@ function Ht() {
2503
2500
  bt(),
2504
2501
  Ct(),
2505
2502
  wt()
2506
- ], t = e.some((u) => u.severity === "error" && !u.passed), r = e.some((u) => u.severity === "warning" && !u.passed);
2503
+ ], t = e.some((l) => l.severity === "error" && !l.passed), r = e.some((l) => l.severity === "warning" && !l.passed);
2507
2504
  let n, s;
2508
2505
  return t ? (n = "vulnerable", s = "Security issues detected. Review errors and apply recommendations.") : r ? (n = "warnings", s = "Minor security warnings detected. Consider applying recommendations.") : (n = "secure", s = "All security checks passed."), {
2509
2506
  checks: e,
@@ -2552,13 +2549,13 @@ export {
2552
2549
  Bt as a,
2553
2550
  qt as b,
2554
2551
  Te as c,
2555
- Ft as d,
2552
+ Wt as d,
2556
2553
  rt as e,
2557
2554
  zt as f,
2558
2555
  nt as g,
2559
2556
  Me as h,
2560
2557
  Ot as i,
2561
- Wt as j,
2558
+ Ft as j,
2562
2559
  kt as k,
2563
2560
  Ze as l,
2564
2561
  Xe as m,