@cedros/pay-react 1.1.15 → 1.1.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (149) hide show
  1. package/dist/AISettingsSection--jn-BNmd.mjs +539 -0
  2. package/dist/AISettingsSection-BrXUD4l_.js +51 -0
  3. package/dist/AutosaveIndicator-B3T328jH.mjs +35 -0
  4. package/dist/AutosaveIndicator-BQkm3cn8.js +1 -0
  5. package/dist/{CedrosContext-D7nh5-Zh.mjs → CedrosContext-BnJ2Cf7R.mjs} +1179 -642
  6. package/dist/CedrosContext-C26DlvLF.js +6 -0
  7. package/dist/CryptoButton-B4-oJ8lF.js +1 -0
  8. package/dist/CryptoButton-Dhxnk9d7.mjs +542 -0
  9. package/dist/FAQSection-BB1wJRsR.mjs +366 -0
  10. package/dist/FAQSection-aoAz35MV.js +1 -0
  11. package/dist/MessagingSection-BG9O62ko.mjs +347 -0
  12. package/dist/MessagingSection-DId-WJdU.js +1 -0
  13. package/dist/PaymentSettingsSection-D92IO4xJ.js +1 -0
  14. package/dist/PaymentSettingsSection-c13RAUxn.mjs +94 -0
  15. package/dist/SettingsSection-DUxjXl2G.js +1 -0
  16. package/dist/SettingsSection-htem-WL3.mjs +57 -0
  17. package/dist/SingleCategorySettings-BIEs6s6Z.mjs +1421 -0
  18. package/dist/SingleCategorySettings-CQ-osdzb.js +3 -0
  19. package/dist/StorefrontSection-CKTQt255.mjs +765 -0
  20. package/dist/StorefrontSection-DcSoDx-k.js +1 -0
  21. package/dist/SubscriptionsSection-C0hYf7Hr.js +1 -0
  22. package/dist/SubscriptionsSection-CONwHhT4.mjs +616 -0
  23. package/dist/Toggle-CsPSF8Dr.js +1 -0
  24. package/dist/Toggle-DAxIdpY4.mjs +48 -0
  25. package/dist/WalletManager-D6BYTwXn.js +1 -0
  26. package/dist/{WalletManager-oEjZhaFk.mjs → WalletManager-HXXyARQ7.mjs} +36 -32
  27. package/dist/components/CedrosPay.d.ts.map +1 -1
  28. package/dist/components/CryptoSubscribeButton.d.ts.map +1 -1
  29. package/dist/components/PaymentModal.d.ts.map +1 -1
  30. package/dist/components/SubscriptionManagementPanel.d.ts.map +1 -1
  31. package/dist/components/admin/AISettingsSection.d.ts.map +1 -1
  32. package/dist/components/admin/AdminAuthManager.d.ts +2 -1
  33. package/dist/components/admin/AdminAuthManager.d.ts.map +1 -1
  34. package/dist/components/admin/AutosaveIndicator.d.ts +7 -0
  35. package/dist/components/admin/AutosaveIndicator.d.ts.map +1 -0
  36. package/dist/components/admin/CedrosPayAdminDashboard.d.ts.map +1 -1
  37. package/dist/components/admin/ConfigEditor.d.ts +0 -2
  38. package/dist/components/admin/ConfigEditor.d.ts.map +1 -1
  39. package/dist/components/admin/MessagingSection.d.ts.map +1 -1
  40. package/dist/components/admin/ProductsSection.d.ts.map +1 -1
  41. package/dist/components/admin/RefundsSection.d.ts.map +1 -1
  42. package/dist/components/admin/SecretArrayEditor.d.ts +16 -0
  43. package/dist/components/admin/SecretArrayEditor.d.ts.map +1 -0
  44. package/dist/components/admin/SingleCategorySettings.d.ts.map +1 -1
  45. package/dist/components/admin/StorefrontSection.d.ts.map +1 -1
  46. package/dist/components/admin/Toggle.d.ts +14 -0
  47. package/dist/components/admin/Toggle.d.ts.map +1 -0
  48. package/dist/components/admin/TokenMintSelector.d.ts +27 -0
  49. package/dist/components/admin/TokenMintSelector.d.ts.map +1 -0
  50. package/dist/components/admin/configApi.d.ts +5 -3
  51. package/dist/components/admin/configApi.d.ts.map +1 -1
  52. package/dist/components/admin/index.d.ts +8 -9
  53. package/dist/components/admin/index.d.ts.map +1 -1
  54. package/dist/components/admin/sections-more.d.ts +2 -9
  55. package/dist/components/admin/sections-more.d.ts.map +1 -1
  56. package/dist/context/CedrosContext.d.ts +1 -1
  57. package/dist/context/CedrosContext.d.ts.map +1 -1
  58. package/dist/crypto-only.js +1 -1
  59. package/dist/crypto-only.mjs +391 -380
  60. package/dist/ecommerce/__tests__/inventoryHooks.test.d.ts +2 -0
  61. package/dist/ecommerce/__tests__/inventoryHooks.test.d.ts.map +1 -0
  62. package/dist/ecommerce/__tests__/storage.test.d.ts +2 -0
  63. package/dist/ecommerce/__tests__/storage.test.d.ts.map +1 -0
  64. package/dist/ecommerce/adapters/CommerceAdapter.d.ts +5 -0
  65. package/dist/ecommerce/adapters/CommerceAdapter.d.ts.map +1 -1
  66. package/dist/ecommerce/adapters/mock/mockAdapter.d.ts.map +1 -1
  67. package/dist/ecommerce/adapters/paywall/paywallAdapter.d.ts.map +1 -1
  68. package/dist/ecommerce/adapters/paywall/paywallAdapter.test.d.ts +2 -0
  69. package/dist/ecommerce/adapters/paywall/paywallAdapter.test.d.ts.map +1 -0
  70. package/dist/ecommerce/components/catalog/ProductCard.d.ts.map +1 -1
  71. package/dist/ecommerce/components/catalog/QuickViewDialog.d.ts.map +1 -1
  72. package/dist/ecommerce/components/chat/ShopChatPanel.d.ts +4 -0
  73. package/dist/ecommerce/components/chat/ShopChatPanel.d.ts.map +1 -1
  74. package/dist/ecommerce/components/checkout/PaymentStep.d.ts.map +1 -1
  75. package/dist/ecommerce/components/faq/FAQItem.d.ts.map +1 -1
  76. package/dist/ecommerce/config/context.d.ts.map +1 -1
  77. package/dist/ecommerce/hooks/useAIRelatedProducts.d.ts.map +1 -1
  78. package/dist/ecommerce/hooks/useCartInventory.d.ts.map +1 -1
  79. package/dist/ecommerce/hooks/useHoldExpiry.d.ts.map +1 -1
  80. package/dist/ecommerce/hooks/useInventoryVerification.d.ts.map +1 -1
  81. package/dist/ecommerce/hooks/useProducts.d.ts.map +1 -1
  82. package/dist/ecommerce/index.d.ts +2 -0
  83. package/dist/ecommerce/index.d.ts.map +1 -1
  84. package/dist/ecommerce/integrations/cedros-pay/useCedrosPayCheckoutAdapter.d.ts.map +1 -1
  85. package/dist/ecommerce/state/cart/CartProvider.d.ts.map +1 -1
  86. package/dist/ecommerce/state/checkout/checkoutSchema.d.ts +1 -1
  87. package/dist/ecommerce/state/checkout/useCheckout.d.ts.map +1 -1
  88. package/dist/ecommerce/templates/ProductTemplate.d.ts.map +1 -1
  89. package/dist/ecommerce/utils/storage.d.ts +1 -1
  90. package/dist/ecommerce/utils/storage.d.ts.map +1 -1
  91. package/dist/hooks/useCreditsPayment.d.ts.map +1 -1
  92. package/dist/hooks/useCreditsSubscription.d.ts.map +1 -1
  93. package/dist/hooks/useCryptoSubscription.d.ts.map +1 -1
  94. package/dist/hooks/useRefundVerification.d.ts.map +1 -1
  95. package/dist/hooks/useStripeCheckout.d.ts +1 -1
  96. package/dist/hooks/useStripeCheckout.d.ts.map +1 -1
  97. package/dist/hooks/useSubscription.d.ts.map +1 -1
  98. package/dist/hooks/useSubscriptionManagement.d.ts.map +1 -1
  99. package/dist/hooks/useX402Payment.d.ts.map +1 -1
  100. package/dist/index-2N_CMVAv.js +84 -0
  101. package/dist/index-C1hbnxn0.mjs +22915 -0
  102. package/dist/index.js +1 -1
  103. package/dist/index.mjs +67 -72
  104. package/dist/managers/CreditsManager.d.ts +6 -0
  105. package/dist/managers/CreditsManager.d.ts.map +1 -1
  106. package/dist/managers/ManagerCache.d.ts.map +1 -1
  107. package/dist/managers/RouteDiscoveryManager.d.ts +3 -0
  108. package/dist/managers/RouteDiscoveryManager.d.ts.map +1 -1
  109. package/dist/managers/StripeManager.d.ts +15 -0
  110. package/dist/managers/StripeManager.d.ts.map +1 -1
  111. package/dist/managers/SubscriptionChangeManager.d.ts.map +1 -1
  112. package/dist/managers/SubscriptionManager.d.ts +7 -14
  113. package/dist/managers/SubscriptionManager.d.ts.map +1 -1
  114. package/dist/managers/WalletManager.d.ts +2 -1
  115. package/dist/managers/WalletManager.d.ts.map +1 -1
  116. package/dist/managers/X402Manager.d.ts.map +1 -1
  117. package/dist/{sections-DG4Ws13b.js → sections-D2GMJuKq.js} +1 -1
  118. package/dist/{sections-Dl8qjlql.mjs → sections-DICaHGhz.mjs} +1 -1
  119. package/dist/stripe-only.js +1 -1
  120. package/dist/stripe-only.mjs +67 -72
  121. package/dist/telemetry.js +1 -1
  122. package/dist/telemetry.mjs +23 -25
  123. package/dist/testing/index.js +1 -1
  124. package/dist/testing/index.mjs +1 -1
  125. package/dist/types/index.d.ts +13 -2
  126. package/dist/types/index.d.ts.map +1 -1
  127. package/dist/useAutosave-B2p6iwh8.js +1 -0
  128. package/dist/useAutosave-YwMqRzqy.mjs +44 -0
  129. package/dist/utils/circuitBreaker.d.ts +3 -1
  130. package/dist/utils/circuitBreaker.d.ts.map +1 -1
  131. package/dist/utils/cspHelper.d.ts +6 -0
  132. package/dist/utils/cspHelper.d.ts.map +1 -1
  133. package/dist/utils/csvHelpers.d.ts +0 -41
  134. package/dist/utils/csvHelpers.d.ts.map +1 -1
  135. package/dist/utils/errorHandling.d.ts.map +1 -1
  136. package/dist/utils/exponentialBackoff.d.ts.map +1 -1
  137. package/dist/utils/requestDeduplication.d.ts.map +1 -1
  138. package/dist/utils/telemetry.d.ts.map +1 -1
  139. package/dist/utils/validateConfig.d.ts +1 -1
  140. package/dist/utils/validateConfig.d.ts.map +1 -1
  141. package/dist/walletDetection-JZR3UCOa.mjs +27 -0
  142. package/dist/walletDetection-bNmV5ItZ.js +1 -0
  143. package/dist/{walletPool-BR6etEiq.mjs → walletPool-BV_z1lEA.mjs} +1 -1
  144. package/dist/{walletPool-BZyAG4YS.js → walletPool-DjA7J3a9.js} +1 -1
  145. package/package.json +8 -7
  146. package/dist/CedrosContext-C2v_s8cc.js +0 -6
  147. package/dist/WalletManager-B5KLZK2D.js +0 -1
  148. package/dist/index-BjxGupjw.mjs +0 -27893
  149. package/dist/index-DW6XWuRP.js +0 -136
@@ -1,41 +1,40 @@
1
- import { U as ke, F as Te, G as ue, A as Re, D as de, y as ve, z as pe, B as V, a0 as Be, a1 as Ie } from "./index-BjxGupjw.mjs";
2
- import { x as Ue, w as Ve, C as Ye, a as He, b as Je, h as Xe, a2 as Ze, E as et, f as tt, d as rt, e as at, P as nt, R as st, L as ot, S as it, g as ct, i as lt, q as ut, c as dt, Q as pt, M as mt, W as ft, v as yt, o as bt, r as gt, t as wt, O as St, T as ht, I as Ct, H as xt, N as Pt, K as Et, p as kt, s as Tt, j as Rt, m as vt, V as Bt, k as It, u as Wt, l as qt, n as _t, a3 as Mt, J as Lt } from "./index-BjxGupjw.mjs";
1
+ import { T as Te, E as ve, F as fe, A as Be, D as me, y as Ie, z as ye, B as Y, a5 as We, a6 as qe } from "./index-C1hbnxn0.mjs";
2
+ import { x as Ue, w as Ve, C as Ye, a as He, b as Je, h as Xe, f as Ze, d as et, e as tt, P as rt, R as nt, K as at, S as st, g as ot, i as it, q as ct, c as lt, O as ut, L as dt, V as pt, v as ft, o as mt, r as yt, t as gt, N as bt, Q as wt, H as St, G as ht, M as Ct, J as xt, p as Pt, s as Et, j as Rt, m as kt, U as Tt, k as vt, u as Bt, l as It, n as Wt, I as qt } from "./index-C1hbnxn0.mjs";
3
+ import { u as H, m as K, a as _e, i as y } from "./CedrosContext-BnJ2Cf7R.mjs";
4
+ import { f as Mt, C as Lt, e as At, d as Nt, E as Dt, K as zt, L as Kt, h as Ot, R as Qt, g as $t, b as Ft, j as Gt, c as jt, r as Ut, v as Vt, n as Yt } from "./CedrosContext-BnJ2Cf7R.mjs";
5
+ import { C as Jt, u as Xt } from "./CryptoButton-Dhxnk9d7.mjs";
3
6
  import { jsxs as O, jsx as x } from "react/jsx-runtime";
4
- import { useState as B, useCallback as h, useRef as me, useEffect as N, useMemo as F } from "react";
5
- import { u as Y, m as D, a as We, i as y } from "./CedrosContext-D7nh5-Zh.mjs";
6
- import { f as Nt, C as Dt, e as zt, d as Kt, K as Ot, L as Qt, h as $t, R as Ft, g as Gt, b as jt, j as Ut, c as Vt, r as Yt, v as Ht, n as Jt } from "./CedrosContext-D7nh5-Zh.mjs";
7
- import "@solana/web3.js";
8
- import "./index-BFt38o8Q.mjs";
9
- import { useWallet as H } from "@solana/wallet-adapter-react";
10
- import { WalletReadyState as fe } from "@solana/wallet-adapter-base";
11
- import { WalletIcon as qe } from "@solana/wallet-adapter-react-ui";
12
- import { WalletPool as Zt, createWalletPool as er } from "./walletPool-BR6etEiq.mjs";
13
- function _e() {
14
- const { subscriptionManager: r, x402Manager: c, walletManager: m } = Y(), { publicKey: o, signTransaction: k } = H(), [g, d] = B({
7
+ import { useState as B, useRef as z, useCallback as h, useMemo as G, useEffect as Q } from "react";
8
+ import { useWallet as J } from "@solana/wallet-adapter-react";
9
+ import { WalletReadyState as ge } from "@solana/wallet-adapter-base";
10
+ import { WalletIcon as Me } from "@solana/wallet-adapter-react-ui";
11
+ import { WalletPool as er, createWalletPool as tr } from "./walletPool-BV_z1lEA.mjs";
12
+ function Le() {
13
+ const { subscriptionManager: r, x402Manager: c, walletManager: f } = H(), { publicKey: i, signTransaction: R } = J(), [w, p] = B({
15
14
  status: "idle",
16
15
  error: null,
17
16
  sessionId: null,
18
17
  subscriptionStatus: null,
19
18
  expiresAt: null
20
- }), [P, C] = B(null), E = h(() => {
21
- if (!o) {
19
+ }), [k, P] = B(null), E = z(!1), C = h(() => {
20
+ if (!i) {
22
21
  const s = "Wallet not connected";
23
- return d((t) => ({ ...t, status: "error", error: s })), { valid: !1, error: s };
22
+ return p((t) => ({ ...t, status: "error", error: s })), { valid: !1, error: s };
24
23
  }
25
- if (!k) {
24
+ if (!R) {
26
25
  const s = "Wallet does not support signing";
27
- return d((t) => ({ ...t, status: "error", error: s })), { valid: !1, error: s };
26
+ return p((t) => ({ ...t, status: "error", error: s })), { valid: !1, error: s };
28
27
  }
29
28
  return { valid: !0 };
30
- }, [o, k]), W = h(
29
+ }, [i, R]), T = h(
31
30
  async (s) => {
32
- if (!o)
33
- return d((t) => ({
31
+ if (!i)
32
+ return p((t) => ({
34
33
  ...t,
35
34
  status: "error",
36
35
  error: "Wallet not connected"
37
36
  })), null;
38
- d((t) => ({
37
+ p((t) => ({
39
38
  ...t,
40
39
  status: "checking",
41
40
  error: null
@@ -43,333 +42,335 @@ function _e() {
43
42
  try {
44
43
  const t = await r.checkSubscriptionStatus({
45
44
  resource: s,
46
- userId: o.toString()
45
+ userId: i.toString()
47
46
  });
48
- return d((a) => ({
49
- ...a,
47
+ return p((n) => ({
48
+ ...n,
50
49
  status: t.active ? "success" : "idle",
51
50
  subscriptionStatus: t.status,
52
51
  expiresAt: t.expiresAt || t.currentPeriodEnd || null
53
52
  })), t;
54
53
  } catch (t) {
55
- const a = D(t, "Failed to check subscription status");
56
- return d((i) => ({
57
- ...i,
54
+ const n = K(t, "Failed to check subscription status");
55
+ return p((l) => ({
56
+ ...l,
58
57
  status: "error",
59
- error: a
58
+ error: n
60
59
  })), null;
61
60
  }
62
61
  },
63
- [o, r]
64
- ), T = h(
65
- async (s, t, a) => {
66
- d((i) => ({
67
- ...i,
62
+ [i, r]
63
+ ), q = h(
64
+ async (s, t, n) => {
65
+ p((l) => ({
66
+ ...l,
68
67
  status: "loading",
69
68
  error: null
70
69
  }));
71
70
  try {
72
- const i = await r.requestSubscriptionQuote(
71
+ const l = await r.requestSubscriptionQuote(
73
72
  s,
74
73
  t,
75
- a
74
+ n
76
75
  );
77
- return C(i), d((f) => ({
78
- ...f,
76
+ return P(l), p((a) => ({
77
+ ...a,
79
78
  status: "idle"
80
- })), i;
81
- } catch (i) {
82
- const f = D(i, "Failed to get subscription quote");
83
- return d((n) => ({
84
- ...n,
79
+ })), l;
80
+ } catch (l) {
81
+ const a = K(l, "Failed to get subscription quote");
82
+ return p((o) => ({
83
+ ...o,
85
84
  status: "error",
86
- error: f
85
+ error: a
87
86
  })), null;
88
87
  }
89
88
  },
90
89
  [r]
91
- ), q = h(
92
- async (s, t, a) => {
93
- const i = E();
94
- if (!i.valid)
95
- return { success: !1, error: i.error };
96
- d((f) => ({
97
- ...f,
90
+ ), g = h(
91
+ async (s, t, n) => {
92
+ if (E.current)
93
+ return { success: !1, error: "Payment already in progress" };
94
+ const l = C();
95
+ if (!l.valid)
96
+ return { success: !1, error: l.error };
97
+ E.current = !0, p((a) => ({
98
+ ...a,
98
99
  status: "loading",
99
100
  error: null
100
101
  }));
101
102
  try {
102
- const f = await r.requestSubscriptionQuote(
103
+ const a = await r.requestSubscriptionQuote(
103
104
  s,
104
105
  t,
105
- a
106
+ n
106
107
  );
107
- C(f);
108
- const n = f.requirement;
109
- if (!c.validateRequirement(n))
108
+ P(a);
109
+ const o = a.requirement;
110
+ if (!c.validateRequirement(o))
110
111
  throw new Error("Invalid subscription quote received from server");
111
- const w = !!n.extra?.feePayer;
112
- let S;
113
- if (w) {
114
- const { transaction: p, blockhash: R } = await c.buildGaslessTransaction({
112
+ const b = !!o.extra?.feePayer;
113
+ let m;
114
+ if (b) {
115
+ const { transaction: S, blockhash: _ } = await c.buildGaslessTransaction({
115
116
  resourceId: s,
116
- userWallet: o.toString(),
117
- feePayer: n.extra.feePayer,
118
- couponCode: a?.couponCode
119
- }), _ = m.deserializeTransaction(p), z = await m.partiallySignTransaction({
120
- transaction: _,
121
- signTransaction: k,
122
- blockhash: R
117
+ userWallet: i.toString(),
118
+ feePayer: o.extra.feePayer,
119
+ couponCode: n?.couponCode
120
+ }), M = f.deserializeTransaction(S), L = await f.partiallySignTransaction({
121
+ transaction: M,
122
+ signTransaction: R,
123
+ blockhash: _
123
124
  });
124
- S = await c.submitGaslessTransaction({
125
+ m = await c.submitGaslessTransaction({
125
126
  resource: s,
126
- partialTx: z,
127
- couponCode: a?.couponCode,
127
+ partialTx: L,
128
+ couponCode: n?.couponCode,
128
129
  resourceType: "regular",
129
- requirement: n
130
+ requirement: o
130
131
  });
131
132
  } else {
132
- const p = await m.buildTransaction({
133
- requirement: n,
134
- payerPublicKey: o
135
- }), R = await m.signTransaction({
136
- transaction: p,
137
- signTransaction: k
138
- }), _ = m.buildPaymentPayload({
139
- requirement: n,
140
- signedTx: R,
141
- payerPublicKey: o
133
+ const S = await f.buildTransaction({
134
+ requirement: o,
135
+ payerPublicKey: i
136
+ }), _ = await f.signTransaction({
137
+ transaction: S,
138
+ signTransaction: R
139
+ }), M = f.buildPaymentPayload({
140
+ requirement: o,
141
+ signedTx: _,
142
+ payerPublicKey: i
142
143
  });
143
- S = await c.submitPayment({
144
+ m = await c.submitPayment({
144
145
  resource: s,
145
- payload: _,
146
- couponCode: a?.couponCode,
146
+ payload: M,
147
+ couponCode: n?.couponCode,
147
148
  resourceType: "regular"
148
149
  });
149
150
  }
150
- if (S.success) {
151
- const p = await r.checkSubscriptionStatus({
151
+ if (m.success) {
152
+ const S = await r.checkSubscriptionStatus({
152
153
  resource: s,
153
- userId: o.toString()
154
+ userId: i.toString()
154
155
  });
155
- d({
156
+ p({
156
157
  status: "success",
157
158
  error: null,
158
- sessionId: S.transactionId || null,
159
- subscriptionStatus: p.status,
160
- expiresAt: p.expiresAt || p.currentPeriodEnd || null
159
+ sessionId: m.transactionId || null,
160
+ subscriptionStatus: S.status,
161
+ expiresAt: S.expiresAt || S.currentPeriodEnd || null
161
162
  });
162
163
  } else
163
- d((p) => ({
164
- ...p,
164
+ p((S) => ({
165
+ ...S,
165
166
  status: "error",
166
- error: S.error || "Subscription payment failed"
167
+ error: m.error || "Subscription payment failed"
167
168
  }));
168
- return S;
169
- } catch (f) {
170
- const n = D(f, "Subscription payment failed");
171
- return d((w) => ({
172
- ...w,
169
+ return m;
170
+ } catch (a) {
171
+ const o = K(a, "Subscription payment failed");
172
+ return p((b) => ({
173
+ ...b,
173
174
  status: "error",
174
- error: n
175
- })), { success: !1, error: n };
175
+ error: o
176
+ })), { success: !1, error: o };
177
+ } finally {
178
+ E.current = !1;
176
179
  }
177
180
  },
178
181
  [
179
- E,
182
+ C,
180
183
  r,
181
184
  c,
182
- m,
183
- o,
184
- k
185
+ f,
186
+ i,
187
+ R
185
188
  ]
186
- ), b = h(() => {
187
- d({
189
+ ), I = h(() => {
190
+ p({
188
191
  status: "idle",
189
192
  error: null,
190
193
  sessionId: null,
191
194
  subscriptionStatus: null,
192
195
  expiresAt: null
193
- }), C(null);
196
+ }), P(null);
194
197
  }, []);
195
198
  return {
196
- ...g,
197
- quote: P,
198
- checkStatus: W,
199
- requestQuote: T,
200
- processPayment: q,
201
- reset: b
199
+ ...w,
200
+ quote: k,
201
+ checkStatus: T,
202
+ requestQuote: q,
203
+ processPayment: g,
204
+ reset: I
202
205
  };
203
206
  }
204
207
  function $e({
205
208
  resource: r,
206
209
  interval: c,
207
- intervalDays: m,
208
- couponCode: o,
209
- label: k,
210
- disabled: g = !1,
211
- onAttempt: d,
212
- onSuccess: P,
213
- onError: C,
210
+ intervalDays: f,
211
+ couponCode: i,
212
+ label: R,
213
+ disabled: w = !1,
214
+ onAttempt: p,
215
+ onSuccess: k,
216
+ onError: P,
214
217
  className: E = "",
215
- testPageUrl: W,
218
+ testPageUrl: C,
216
219
  hideMessages: T = !1,
217
220
  autoCheckStatus: q = !0
218
221
  }) {
219
222
  const {
220
- connected: b,
221
- connecting: s,
222
- connect: t,
223
- disconnect: a,
224
- select: i,
225
- wallets: f,
226
- wallet: n,
227
- publicKey: w
228
- } = H(), {
229
- status: S,
230
- error: p,
231
- subscriptionStatus: R,
223
+ connected: g,
224
+ connecting: I,
225
+ connect: s,
226
+ disconnect: t,
227
+ select: n,
228
+ wallets: l,
229
+ wallet: a,
230
+ publicKey: o
231
+ } = J(), {
232
+ status: b,
233
+ error: m,
234
+ subscriptionStatus: S,
232
235
  expiresAt: _,
233
- checkStatus: z,
234
- processPayment: K
235
- } = _e(), l = We(), { solanaError: I } = Y(), { t: v, translations: J } = ke(), ye = k || v("ui.subscribe_with_crypto"), X = me(K), Z = me(z);
236
- N(() => {
237
- X.current = K, Z.current = z;
238
- }, [K, z]);
239
- const be = p && typeof p != "string" ? p?.code ?? null : null, ge = I && typeof I != "string" ? I?.code ?? null : null, ee = (e) => {
240
- if (!e || !J) return "";
241
- const u = J.errors[e];
242
- return u ? u.action ? `${u.message} ${u.action}` : u.message : "";
243
- }, te = p ? typeof p == "string" ? p : ee(be) : null, re = I ? typeof I == "string" ? I : ee(ge) : null, we = F(
244
- () => f.map((e) => `${e.adapter.name}-${e.readyState}`).join(","),
245
- [f]
246
- ), G = F(
247
- () => f.filter(
248
- ({ readyState: e }) => e === fe.Installed || e === fe.Loadable
236
+ checkStatus: M,
237
+ processPayment: L
238
+ } = Le(), u = _e(), { solanaError: W } = H(), { t: v, translations: X } = Te(), be = R || v("ui.subscribe_with_crypto"), Z = z(k), ee = z(P), te = z(L), re = z(M);
239
+ Z.current = k, ee.current = P, te.current = L, re.current = M;
240
+ const we = m && typeof m != "string" ? m?.code ?? null : null, Se = W && typeof W != "string" ? W?.code ?? null : null, ne = (e) => {
241
+ if (!e || !X) return "";
242
+ const d = X.errors[e];
243
+ return d ? d.action ? `${d.message} ${d.action}` : d.message : "";
244
+ }, ae = m ? typeof m == "string" ? m : ne(we) : null, se = W ? typeof W == "string" ? W : ne(Se) : null, he = G(
245
+ () => l.map((e) => `${e.adapter.name}-${e.readyState}`).join(","),
246
+ [l]
247
+ ), j = G(
248
+ () => l.filter(
249
+ ({ readyState: e }) => e === ge.Installed || e === ge.Loadable
249
250
  ),
250
251
  // eslint-disable-next-line react-hooks/exhaustive-deps
251
- [we]
252
+ [he]
252
253
  );
253
- N(() => {
254
- q && b && w && (y().debug("[CryptoSubscribeButton] Auto-checking subscription status"), Z.current(r));
255
- }, [q, b, w, r]), N(() => {
256
- S === "success" && R === "active" && (Te("crypto", "subscription-active", r), P && P("subscription-active"));
257
- }, [S, R, r, P]), N(() => {
258
- S === "error" && p && (ue("crypto", p, r), C && C(p));
259
- }, [S, p, r, C]);
260
- const ae = typeof window < "u" && window.top !== window.self, [ne, M] = B(!1), [se, j] = B(!1), [oe, L] = B(!1), A = I;
261
- N(() => {
254
+ Q(() => {
255
+ q && g && o && (y().debug("[CryptoSubscribeButton] Auto-checking subscription status"), re.current(r));
256
+ }, [q, g, o, r]), Q(() => {
257
+ b === "success" && S === "active" && (ve("crypto", "subscription-active", r), Z.current?.("subscription-active"));
258
+ }, [b, S, r]), Q(() => {
259
+ b === "error" && m && (fe("crypto", m, r), ee.current?.(m));
260
+ }, [b, m, r]);
261
+ const oe = typeof window < "u" && window.top !== window.self, [ie, A] = B(!1), [ce, U] = B(!1), [le, N] = B(!1), D = W;
262
+ Q(() => {
262
263
  let e = !1;
263
264
  return e || (async () => {
264
- if (se && n && !b && !s) {
265
+ if (ce && a && !g && !I) {
265
266
  y().debug(
266
267
  "[CryptoSubscribeButton] Wallet detected, attempting auto-connect:",
267
- n.adapter.name
268
- ), j(!1), pe(n.adapter.name);
268
+ a.adapter.name
269
+ ), U(!1), ye(a.adapter.name);
269
270
  try {
270
- await t(), e || y().debug("[CryptoSubscribeButton] Auto-connect successful");
271
- } catch (U) {
271
+ await s(), e || y().debug("[CryptoSubscribeButton] Auto-connect successful");
272
+ } catch (V) {
272
273
  if (!e) {
273
- y().error("[CryptoSubscribeButton] Auto-connect failed:", U);
274
- const Ee = U instanceof Error ? U.message : "Failed to connect wallet";
275
- V(Ee, n.adapter.name), L(!1);
274
+ y().error("[CryptoSubscribeButton] Auto-connect failed:", V);
275
+ const ke = V instanceof Error ? V.message : "Failed to connect wallet";
276
+ Y(ke, a.adapter.name), N(!1);
276
277
  }
277
278
  }
278
279
  }
279
280
  })(), () => {
280
281
  e = !0;
281
282
  };
282
- }, [n, se, b, s, t]), N(() => {
283
- b && oe && w && n && (Re(n.adapter.name, w.toString()), y().debug("[CryptoSubscribeButton] Processing pending subscription payment"), L(!1), M(!1), de("crypto", r), X.current(r, c, { couponCode: o, intervalDays: m }));
284
- }, [b, oe, w, n, r, c, o, m]);
285
- const ie = h(async () => {
283
+ }, [a, ce, g, I, s]), Q(() => {
284
+ g && le && o && a && (Be(a.adapter.name, o.toString()), y().debug("[CryptoSubscribeButton] Processing pending subscription payment"), N(!1), A(!1), me("crypto", r), te.current(r, c, { couponCode: i, intervalDays: f }));
285
+ }, [g, le, o, a, r, c, i, f]);
286
+ const ue = h(async () => {
286
287
  if (y().debug("[CryptoSubscribeButton] executeSubscriptionFlow called", {
287
- connected: b,
288
- wallet: n?.adapter.name,
288
+ connected: g,
289
+ wallet: a?.adapter.name,
289
290
  resource: r,
290
291
  interval: c
291
- }), ve("crypto", r), d && d("crypto"), A) {
292
- y().error("[CryptoSubscribeButton] Solana dependencies missing:", A), ue("crypto", A, r), C && C(A);
292
+ }), Ie("crypto", r), p && p("crypto"), D) {
293
+ y().error("[CryptoSubscribeButton] Solana dependencies missing:", D), fe("crypto", D, r), P && P(D);
293
294
  return;
294
295
  }
295
- if (ae) {
296
- const e = W || window.location.href;
296
+ if (oe) {
297
+ const e = C || window.location.href;
297
298
  try {
298
299
  if (new URL(e, window.location.origin).origin !== window.location.origin)
299
300
  throw y().error("[CryptoSubscribeButton] Blocked attempt to open external URL:", e), new Error("Cannot open external URLs from embedded context");
300
301
  window.open(e, "_blank", "noopener,noreferrer");
301
- } catch (u) {
302
- throw y().error("[CryptoSubscribeButton] URL validation failed:", u), u;
302
+ } catch (d) {
303
+ throw y().error("[CryptoSubscribeButton] URL validation failed:", d), d;
303
304
  }
304
305
  return;
305
306
  }
306
- if (b)
307
- de("crypto", r), await K(r, c, { couponCode: o, intervalDays: m });
307
+ if (g)
308
+ me("crypto", r), await L(r, c, { couponCode: i, intervalDays: f });
308
309
  else {
309
- L(!0);
310
+ N(!0);
310
311
  try {
311
- if (n)
312
+ if (a)
312
313
  y().debug(
313
314
  "[CryptoSubscribeButton] Wallet already selected, connecting:",
314
- n.adapter.name
315
- ), pe(n.adapter.name), await t();
315
+ a.adapter.name
316
+ ), ye(a.adapter.name), await s();
316
317
  else {
317
- if (y().debug("[CryptoSubscribeButton] No wallet selected, showing selector"), G.length === 0) {
318
- L(!1);
318
+ if (y().debug("[CryptoSubscribeButton] No wallet selected, showing selector"), j.length === 0) {
319
+ N(!1);
319
320
  const e = "No wallets available";
320
- throw V(e), new Error(e);
321
+ throw Y(e), new Error(e);
321
322
  }
322
- M(!0);
323
+ A(!0);
323
324
  }
324
325
  } catch (e) {
325
- L(!1);
326
- const u = e instanceof Error ? e.message : "Failed to connect wallet";
327
- y().error("[CryptoSubscribeButton] Connection error:", u), V(u, n?.adapter.name);
326
+ N(!1);
327
+ const d = e instanceof Error ? e.message : "Failed to connect wallet";
328
+ y().error("[CryptoSubscribeButton] Connection error:", d), Y(d, a?.adapter.name);
328
329
  }
329
330
  }
330
331
  }, [
331
- b,
332
- n,
332
+ g,
333
+ a,
333
334
  r,
334
335
  c,
335
- o,
336
- m,
337
- ae,
338
- W,
339
- G,
340
- t,
341
- K,
342
- A,
343
- d,
344
- C
345
- ]), ce = F(() => `crypto-subscribe-${r}-${c}`, [r, c]), Se = F(
346
- () => Be(ce, ie, {
336
+ i,
337
+ f,
338
+ oe,
339
+ C,
340
+ j,
341
+ s,
342
+ L,
343
+ D,
344
+ p,
345
+ P
346
+ ]), de = G(() => `crypto-subscribe-${r}-${c}`, [r, c]), Ce = G(
347
+ () => We(de, ue, {
347
348
  cooldownMs: 200,
348
349
  deduplicationWindowMs: 0
349
350
  }),
350
- [ce, ie]
351
- ), le = S === "loading" || S === "checking", Q = R === "active" || R === "trialing", he = g || le || s || !!A || Q;
352
- let $ = ye;
353
- if (le)
354
- $ = v("ui.processing");
355
- else if (Q && _) {
351
+ [de, ue]
352
+ ), pe = b === "loading" || b === "checking", $ = S === "active" || S === "trialing", xe = w || pe || I || !!D || $;
353
+ let F = be;
354
+ if (pe)
355
+ F = v("ui.processing");
356
+ else if ($ && _) {
356
357
  const e = new Date(_).toLocaleDateString();
357
- $ = `${v("ui.subscribed_until")} ${e}`;
358
- } else Q && ($ = v("ui.subscribed"));
359
- const Ce = h(async () => {
358
+ F = `${v("ui.subscribed_until")} ${e}`;
359
+ } else $ && (F = v("ui.subscribed"));
360
+ const Pe = h(async () => {
360
361
  try {
361
- j(!1), b && await a(), i(null), M(!0);
362
+ U(!1), g && await t(), n(null), A(!0);
362
363
  } catch (e) {
363
364
  y().error("Failed to change wallet:", e);
364
365
  }
365
- }, [b, a, i]), xe = h(
366
+ }, [g, t, n]), Ee = h(
366
367
  (e) => {
367
- y().debug("[CryptoSubscribeButton] Wallet clicked:", e), M(!1), i(e), j(!0);
368
+ y().debug("[CryptoSubscribeButton] Wallet clicked:", e), A(!1), n(e), U(!0);
368
369
  },
369
- [i]
370
- ), Pe = h(async () => {
370
+ [n]
371
+ ), Re = h(async () => {
371
372
  try {
372
- if (await a(), L(!1), typeof window < "u" && window.localStorage)
373
+ if (await t(), N(!1), typeof window < "u" && window.localStorage)
373
374
  try {
374
375
  window.localStorage.removeItem("walletName");
375
376
  } catch (e) {
@@ -378,24 +379,24 @@ function $e({
378
379
  } catch (e) {
379
380
  y().error("Failed to disconnect wallet:", e);
380
381
  }
381
- }, [a]);
382
+ }, [t]);
382
383
  return /* @__PURE__ */ O(
383
384
  "div",
384
385
  {
385
- className: l.unstyled ? E : `${l.className} cedros-theme__crypto-button ${E || ""}`,
386
- style: l.unstyled ? {} : l.style,
386
+ className: u.unstyled ? E : `${u.className} cedros-theme__crypto-button ${E || ""}`,
387
+ style: u.unstyled ? {} : u.style,
387
388
  children: [
388
389
  /* @__PURE__ */ x(
389
390
  "button",
390
391
  {
391
- onClick: Se,
392
- disabled: he,
393
- className: l.unstyled ? E : "cedros-theme__button cedros-theme__crypto",
392
+ onClick: Ce,
393
+ disabled: xe,
394
+ className: u.unstyled ? E : "cedros-theme__button cedros-theme__crypto",
394
395
  type: "button",
395
- children: $
396
+ children: F
396
397
  }
397
398
  ),
398
- ne && !T && /* @__PURE__ */ x(
399
+ ie && !T && /* @__PURE__ */ x(
399
400
  "div",
400
401
  {
401
402
  className: "cedros-modal-overlay",
@@ -405,26 +406,26 @@ function $e({
405
406
  left: 0,
406
407
  right: 0,
407
408
  bottom: 0,
408
- backgroundColor: l.tokens.modalOverlay,
409
+ backgroundColor: u.tokens.modalOverlay,
409
410
  display: "flex",
410
411
  alignItems: "center",
411
412
  justifyContent: "center",
412
413
  zIndex: 9999,
413
414
  padding: "1rem"
414
415
  },
415
- onClick: () => M(!1),
416
+ onClick: () => A(!1),
416
417
  children: /* @__PURE__ */ O(
417
418
  "div",
418
419
  {
419
420
  className: "cedros-modal-content",
420
421
  style: {
421
- backgroundColor: l.tokens.modalBackground,
422
+ backgroundColor: u.tokens.modalBackground,
422
423
  borderRadius: "12px",
423
424
  padding: "2rem",
424
425
  maxWidth: "400px",
425
426
  width: "100%",
426
427
  boxShadow: "0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04)",
427
- border: `1px solid ${l.tokens.modalBorder}`
428
+ border: `1px solid ${u.tokens.modalBorder}`
428
429
  },
429
430
  onClick: (e) => e.stopPropagation(),
430
431
  children: [
@@ -445,7 +446,7 @@ function $e({
445
446
  margin: 0,
446
447
  fontSize: "1.25rem",
447
448
  fontWeight: 600,
448
- color: l.tokens.surfaceText
449
+ color: u.tokens.surfaceText
449
450
  },
450
451
  children: v("wallet.select_wallet")
451
452
  }
@@ -453,8 +454,8 @@ function $e({
453
454
  /* @__PURE__ */ x(
454
455
  "button",
455
456
  {
456
- onClick: () => M(!1),
457
- style: Ie(l.tokens.surfaceText),
457
+ onClick: () => A(!1),
458
+ style: qe(u.tokens.surfaceText),
458
459
  "aria-label": "Close modal",
459
460
  type: "button",
460
461
  children: "×"
@@ -463,34 +464,34 @@ function $e({
463
464
  ]
464
465
  }
465
466
  ),
466
- /* @__PURE__ */ x("div", { style: { display: "flex", flexDirection: "column", gap: "0.75rem" }, children: G.map((e) => /* @__PURE__ */ O(
467
+ /* @__PURE__ */ x("div", { style: { display: "flex", flexDirection: "column", gap: "0.75rem" }, children: j.map((e) => /* @__PURE__ */ O(
467
468
  "button",
468
469
  {
469
- onClick: () => xe(e.adapter.name),
470
+ onClick: () => Ee(e.adapter.name),
470
471
  style: {
471
472
  width: "100%",
472
473
  padding: "1rem",
473
- backgroundColor: l.tokens.surfaceBackground,
474
- border: `1px solid ${l.tokens.surfaceBorder}`,
474
+ backgroundColor: u.tokens.surfaceBackground,
475
+ border: `1px solid ${u.tokens.surfaceBorder}`,
475
476
  borderRadius: "0.5rem",
476
477
  cursor: "pointer",
477
478
  fontSize: "1rem",
478
479
  textAlign: "left",
479
- color: l.tokens.surfaceText,
480
+ color: u.tokens.surfaceText,
480
481
  display: "flex",
481
482
  alignItems: "center",
482
483
  gap: "1rem",
483
484
  transition: "all 0.2s ease"
484
485
  },
485
- onMouseEnter: (u) => {
486
- u.currentTarget.style.backgroundColor = l.tokens.modalBackground, u.currentTarget.style.borderColor = l.tokens.surfaceText, u.currentTarget.style.transform = "translateY(-2px)";
486
+ onMouseEnter: (d) => {
487
+ d.currentTarget.style.backgroundColor = u.tokens.modalBackground, d.currentTarget.style.borderColor = u.tokens.surfaceText, d.currentTarget.style.transform = "translateY(-2px)";
487
488
  },
488
- onMouseLeave: (u) => {
489
- u.currentTarget.style.backgroundColor = l.tokens.surfaceBackground, u.currentTarget.style.borderColor = l.tokens.surfaceBorder, u.currentTarget.style.transform = "translateY(0)";
489
+ onMouseLeave: (d) => {
490
+ d.currentTarget.style.backgroundColor = u.tokens.surfaceBackground, d.currentTarget.style.borderColor = u.tokens.surfaceBorder, d.currentTarget.style.transform = "translateY(0)";
490
491
  },
491
492
  type: "button",
492
493
  children: [
493
- /* @__PURE__ */ x(qe, { wallet: e, style: { width: "24px", height: "24px" } }),
494
+ /* @__PURE__ */ x(Me, { wallet: e, style: { width: "24px", height: "24px" } }),
494
495
  /* @__PURE__ */ x("span", { style: { fontWeight: 500 }, children: e.adapter.name })
495
496
  ]
496
497
  },
@@ -501,7 +502,7 @@ function $e({
501
502
  )
502
503
  }
503
504
  ),
504
- b && !T && !ne && /* @__PURE__ */ O(
505
+ g && !T && !ie && /* @__PURE__ */ O(
505
506
  "div",
506
507
  {
507
508
  style: {
@@ -509,14 +510,14 @@ function $e({
509
510
  justifyContent: "space-between",
510
511
  marginTop: "0.5rem",
511
512
  fontSize: "0.75rem",
512
- color: l.tokens.surfaceText,
513
+ color: u.tokens.surfaceText,
513
514
  opacity: 0.7
514
515
  },
515
516
  children: [
516
517
  /* @__PURE__ */ x(
517
518
  "button",
518
519
  {
519
- onClick: Ce,
520
+ onClick: Pe,
520
521
  style: {
521
522
  background: "none",
522
523
  border: "none",
@@ -533,7 +534,7 @@ function $e({
533
534
  /* @__PURE__ */ x(
534
535
  "button",
535
536
  {
536
- onClick: Pe,
537
+ onClick: Re,
537
538
  style: {
538
539
  background: "none",
539
540
  border: "none",
@@ -550,89 +551,97 @@ function $e({
550
551
  ]
551
552
  }
552
553
  ),
553
- !T && re && /* @__PURE__ */ x("div", { className: l.unstyled ? "" : "cedros-theme__error", children: re }),
554
- !T && te && /* @__PURE__ */ x("div", { className: l.unstyled ? "" : "cedros-theme__error", children: te }),
555
- !T && Q && /* @__PURE__ */ x("div", { className: l.unstyled ? "" : "cedros-theme__success", children: v("ui.subscription_active") })
554
+ !T && se && /* @__PURE__ */ x("div", { className: u.unstyled ? "" : "cedros-theme__error", children: se }),
555
+ !T && ae && /* @__PURE__ */ x("div", { className: u.unstyled ? "" : "cedros-theme__error", children: ae }),
556
+ !T && $ && /* @__PURE__ */ x("div", { className: u.unstyled ? "" : "cedros-theme__success", children: v("ui.subscription_active") })
556
557
  ]
557
558
  }
558
559
  );
559
560
  }
560
561
  function Fe() {
561
- const { x402Manager: r, walletManager: c } = Y(), { publicKey: m, signTransaction: o } = H(), [k, g] = B({
562
+ const { x402Manager: r, walletManager: c } = H(), { publicKey: f, signTransaction: i } = J(), [R, w] = B({
562
563
  status: "idle",
563
564
  error: null,
564
565
  transactionId: null
565
- }), [d, P] = B(null), [C, E] = B(null), W = h(
566
+ }), [p, k] = B(null), [P, E] = B(null), C = z(!1), T = h(
566
567
  async (s) => {
567
568
  try {
568
- g((a) => ({ ...a, status: "loading" }));
569
+ w((n) => ({ ...n, status: "loading" }));
569
570
  const t = await r.requestQuote({ resource: s });
570
571
  if (!r.validateRequirement(t))
571
572
  throw new Error("Invalid refund requirement received from server");
572
- return P(t), g((a) => ({ ...a, status: "idle" })), t;
573
+ return k(t), w((n) => ({ ...n, status: "idle" })), t;
573
574
  } catch (t) {
574
- const a = D(t, "Failed to fetch refund requirement");
575
- throw g({
575
+ const n = K(t, "Failed to fetch refund requirement");
576
+ throw w({
576
577
  status: "error",
577
- error: a,
578
+ error: n,
578
579
  transactionId: null
579
580
  }), t;
580
581
  }
581
582
  },
582
583
  [r]
583
- ), T = h(
584
+ ), q = h(
584
585
  async (s, t) => {
585
- if (!m || !o)
586
+ if (C.current)
587
+ throw new Error("Refund already in progress");
588
+ if (!f || !i)
586
589
  throw new Error("Wallet not connected");
590
+ C.current = !0;
587
591
  try {
588
- g({
592
+ w({
589
593
  status: "loading",
590
594
  error: null,
591
595
  transactionId: null
592
596
  });
593
- const a = await r.requestQuote({ resource: s, couponCode: t });
594
- if (!r.validateRequirement(a))
597
+ const n = await r.requestQuote({ resource: s, couponCode: t });
598
+ if (!r.validateRequirement(n))
595
599
  throw new Error("Invalid refund requirement received");
596
- P(a);
597
- const i = await c.buildTransaction({
598
- requirement: a,
599
- payerPublicKey: m
600
- }), f = await c.signTransaction({
601
- transaction: i,
602
- signTransaction: o
603
- }), n = c.buildPaymentPayload({
604
- requirement: a,
605
- signedTx: f,
606
- payerPublicKey: m
607
- }), w = await r.submitPayment({
600
+ k(n);
601
+ const l = await c.buildTransaction({
602
+ requirement: n,
603
+ payerPublicKey: f
604
+ }), a = await c.signTransaction({
605
+ transaction: l,
606
+ signTransaction: i
607
+ }), o = c.buildPaymentPayload({
608
+ requirement: n,
609
+ signedTx: a,
610
+ payerPublicKey: f
611
+ }), b = await r.submitPayment({
608
612
  resource: s,
609
- payload: n,
613
+ payload: o,
610
614
  couponCode: t,
611
615
  metadata: void 0,
612
616
  // no metadata for refunds
613
617
  resourceType: "refund"
614
618
  });
615
- return w.settlement && E(w.settlement), g({
619
+ return b.settlement && E(b.settlement), w({
616
620
  status: "success",
617
621
  error: null,
618
- transactionId: w.transactionId || f.signature
619
- }), w;
620
- } catch (a) {
621
- const i = D(a, "Refund payment failed");
622
- throw g({
622
+ transactionId: b.transactionId || a.signature
623
+ }), b;
624
+ } catch (n) {
625
+ const l = K(n, "Refund payment failed");
626
+ throw w({
623
627
  status: "error",
624
- error: i,
628
+ error: l,
625
629
  transactionId: null
626
- }), a;
630
+ }), n;
631
+ } finally {
632
+ C.current = !1;
627
633
  }
628
634
  },
629
- [m, o, r, c]
630
- ), q = h(
635
+ [f, i, r, c]
636
+ ), g = h(
631
637
  async (s) => {
632
- if (!m || !o)
638
+ if (C.current)
639
+ throw new Error("Refund already in progress");
640
+ if (!f || !i)
633
641
  throw new Error("Wallet not connected");
642
+ C.current = !0;
634
643
  try {
635
- g({
644
+ w({
636
645
  status: "loading",
637
646
  error: null,
638
647
  transactionId: null
@@ -640,17 +649,17 @@ function Fe() {
640
649
  const t = await r.requestQuote({ resource: s });
641
650
  if (!r.validateRequirement(t))
642
651
  throw new Error("Invalid refund requirement received");
643
- P(t);
644
- const { transaction: a } = await r.buildGaslessTransaction({
652
+ k(t);
653
+ const { transaction: n } = await r.buildGaslessTransaction({
645
654
  resourceId: s,
646
- userWallet: m.toString(),
655
+ userWallet: f.toString(),
647
656
  feePayer: t.extra.feePayer
648
- }), i = c.deserializeTransaction(a), f = await c.partiallySignTransaction({
649
- transaction: i,
650
- signTransaction: o
651
- }), n = await r.submitGaslessTransaction({
657
+ }), l = c.deserializeTransaction(n), a = await c.partiallySignTransaction({
658
+ transaction: l,
659
+ signTransaction: i
660
+ }), o = await r.submitGaslessTransaction({
652
661
  resource: s,
653
- partialTx: f,
662
+ partialTx: a,
654
663
  couponCode: void 0,
655
664
  // no couponCode
656
665
  metadata: void 0,
@@ -658,111 +667,113 @@ function Fe() {
658
667
  resourceType: "refund",
659
668
  requirement: t
660
669
  });
661
- return n.settlement && E(n.settlement), g({
670
+ return o.settlement && E(o.settlement), w({
662
671
  status: "success",
663
672
  error: null,
664
- transactionId: n.transactionId || "gasless-refund-tx"
665
- }), n;
673
+ transactionId: o.transactionId || "gasless-refund-tx"
674
+ }), o;
666
675
  } catch (t) {
667
- const a = D(t, "Gasless refund payment failed");
668
- throw g({
676
+ const n = K(t, "Gasless refund payment failed");
677
+ throw w({
669
678
  status: "error",
670
- error: a,
679
+ error: n,
671
680
  transactionId: null
672
681
  }), t;
682
+ } finally {
683
+ C.current = !1;
673
684
  }
674
685
  },
675
- [m, o, r, c]
676
- ), b = h(() => {
677
- g({
686
+ [f, i, r, c]
687
+ ), I = h(() => {
688
+ w({
678
689
  status: "idle",
679
690
  error: null,
680
691
  transactionId: null
681
- }), P(null), E(null);
692
+ }), k(null), E(null);
682
693
  }, []);
683
694
  return {
684
- state: k,
685
- requirement: d,
686
- settlement: C,
687
- fetchRefundQuote: W,
688
- processRefund: T,
689
- processGaslessRefund: q,
690
- reset: b
695
+ state: R,
696
+ requirement: p,
697
+ settlement: P,
698
+ fetchRefundQuote: T,
699
+ processRefund: q,
700
+ processGaslessRefund: g,
701
+ reset: I
691
702
  };
692
703
  }
693
704
  export {
694
705
  Ue as CEDROS_EVENTS,
695
- Nt as CIRCUIT_BREAKER_PRESETS,
706
+ Mt as CIRCUIT_BREAKER_PRESETS,
696
707
  Ve as CSP_PRESETS,
697
708
  Ye as CedrosPay,
698
709
  He as CedrosPayAdminDashboard,
699
- Dt as CedrosProvider,
700
- zt as CircuitBreakerOpenError,
701
- Kt as CircuitState,
710
+ Lt as CedrosProvider,
711
+ At as CircuitBreakerOpenError,
712
+ Nt as CircuitState,
702
713
  Je as CreditsButton,
703
714
  Xe as CreditsSubscribeButton,
704
- Ze as CryptoButton,
715
+ Jt as CryptoButton,
705
716
  $e as CryptoSubscribeButton,
706
- et as ERROR_CATEGORIES,
707
- Ot as KNOWN_STABLECOINS,
708
- Qt as LogLevel,
709
- $t as Logger,
710
- tt as PaymentMethodBadge,
711
- rt as PaymentModal,
712
- at as ProductPrice,
713
- nt as PurchaseButton,
714
- Ft as RATE_LIMITER_PRESETS,
715
- Gt as RETRY_PRESETS,
716
- st as RPC_PROVIDERS,
717
- ot as SECURITY_RECOMMENDATIONS,
718
- it as StripeButton,
719
- ct as SubscribeButton,
720
- lt as SubscriptionManagementPanel,
721
- Zt as WalletPool,
722
- ut as calculateDiscountPercentage,
723
- dt as cedrosPayPlugin,
724
- jt as createCircuitBreaker,
725
- Ut as createLogger,
726
- Vt as createRateLimiter,
727
- pt as createTranslator,
728
- er as createWalletPool,
729
- mt as detectLocale,
730
- ft as ecommerce,
731
- ue as emitPaymentError,
732
- de as emitPaymentProcessing,
733
- ve as emitPaymentStart,
734
- Te as emitPaymentSuccess,
735
- pe as emitWalletConnect,
736
- Re as emitWalletConnected,
737
- V as emitWalletError,
738
- yt as formatCSP,
739
- bt as formatCouponCodes,
740
- gt as generateCSP,
741
- wt as generateCSPDirectives,
742
- St as getAvailableLocales,
743
- ht as getLocalizedError,
717
+ Dt as ERROR_CATEGORIES,
718
+ zt as KNOWN_STABLECOINS,
719
+ Kt as LogLevel,
720
+ Ot as Logger,
721
+ Ze as PaymentMethodBadge,
722
+ et as PaymentModal,
723
+ tt as ProductPrice,
724
+ rt as PurchaseButton,
725
+ Qt as RATE_LIMITER_PRESETS,
726
+ $t as RETRY_PRESETS,
727
+ nt as RPC_PROVIDERS,
728
+ at as SECURITY_RECOMMENDATIONS,
729
+ st as StripeButton,
730
+ ot as SubscribeButton,
731
+ it as SubscriptionManagementPanel,
732
+ er as WalletPool,
733
+ ct as calculateDiscountPercentage,
734
+ lt as cedrosPayPlugin,
735
+ Ft as createCircuitBreaker,
736
+ Gt as createLogger,
737
+ jt as createRateLimiter,
738
+ ut as createTranslator,
739
+ tr as createWalletPool,
740
+ dt as detectLocale,
741
+ pt as ecommerce,
742
+ fe as emitPaymentError,
743
+ me as emitPaymentProcessing,
744
+ Ie as emitPaymentStart,
745
+ ve as emitPaymentSuccess,
746
+ ye as emitWalletConnect,
747
+ Be as emitWalletConnected,
748
+ Y as emitWalletError,
749
+ ft as formatCSP,
750
+ mt as formatCouponCodes,
751
+ yt as generateCSP,
752
+ gt as generateCSPDirectives,
753
+ bt as getAvailableLocales,
754
+ wt as getLocalizedError,
744
755
  y as getLogger,
745
- Ct as getUserErrorMessage,
746
- xt as isRetryableError,
747
- Pt as loadLocale,
748
- Et as logSecurityReport,
749
- kt as parseCouponCodes,
750
- Yt as retryWithBackoff,
751
- Tt as stackCheckoutCoupons,
752
- Y as useCedrosContext,
753
- We as useCedrosTheme,
756
+ St as getUserErrorMessage,
757
+ ht as isRetryableError,
758
+ Ct as loadLocale,
759
+ xt as logSecurityReport,
760
+ Pt as parseCouponCodes,
761
+ Ut as retryWithBackoff,
762
+ Et as stackCheckoutCoupons,
763
+ H as useCedrosContext,
764
+ _e as useCedrosTheme,
754
765
  Rt as useCreditsPayment,
755
- vt as useCreditsSubscription,
756
- _e as useCryptoSubscription,
757
- Bt as useLocalizedError,
758
- It as usePaymentMode,
766
+ kt as useCreditsSubscription,
767
+ Le as useCryptoSubscription,
768
+ Tt as useLocalizedError,
769
+ vt as usePaymentMode,
759
770
  Fe as useRefundVerification,
760
- Wt as useStripeCheckout,
761
- qt as useSubscription,
762
- _t as useSubscriptionManagement,
763
- ke as useTranslation,
764
- Mt as useX402Payment,
765
- Ht as validateConfig,
766
- Lt as validateSecurity,
767
- Jt as validateTokenMint
771
+ Bt as useStripeCheckout,
772
+ It as useSubscription,
773
+ Wt as useSubscriptionManagement,
774
+ Te as useTranslation,
775
+ Xt as useX402Payment,
776
+ Vt as validateConfig,
777
+ qt as validateSecurity,
778
+ Yt as validateTokenMint
768
779
  };