@blocklet/payment-react 1.25.10 → 1.26.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. package/es/checkout-v2/checkout-v2.d.ts +2 -0
  2. package/es/checkout-v2/checkout-v2.js +121 -0
  3. package/es/checkout-v2/components/dialogs/checkout-dialogs.d.ts +1 -0
  4. package/es/checkout-v2/components/dialogs/checkout-dialogs.js +106 -0
  5. package/es/checkout-v2/components/left/billing-toggle.d.ts +6 -0
  6. package/es/checkout-v2/components/left/billing-toggle.js +118 -0
  7. package/es/checkout-v2/components/left/cross-sell-card.d.ts +10 -0
  8. package/es/checkout-v2/components/left/cross-sell-card.js +167 -0
  9. package/es/checkout-v2/components/left/product-item-card.d.ts +26 -0
  10. package/es/checkout-v2/components/left/product-item-card.js +571 -0
  11. package/es/checkout-v2/components/left/promotion-input.d.ts +19 -0
  12. package/es/checkout-v2/components/left/promotion-input.js +178 -0
  13. package/es/checkout-v2/components/left/staking-breakdown.d.ts +9 -0
  14. package/es/checkout-v2/components/left/staking-breakdown.js +48 -0
  15. package/es/checkout-v2/components/left/trial-info.d.ts +13 -0
  16. package/es/checkout-v2/components/left/trial-info.js +48 -0
  17. package/es/checkout-v2/components/right/currency-grid.d.ts +8 -0
  18. package/es/checkout-v2/components/right/currency-grid.js +48 -0
  19. package/es/checkout-v2/components/right/customer-info-card.d.ts +17 -0
  20. package/es/checkout-v2/components/right/customer-info-card.js +156 -0
  21. package/es/checkout-v2/components/right/status-feedback.d.ts +7 -0
  22. package/es/checkout-v2/components/right/status-feedback.js +17 -0
  23. package/es/checkout-v2/components/right/submit-button.d.ts +10 -0
  24. package/es/checkout-v2/components/right/submit-button.js +29 -0
  25. package/es/checkout-v2/components/right/subscription-disclaimer.d.ts +11 -0
  26. package/es/checkout-v2/components/right/subscription-disclaimer.js +8 -0
  27. package/es/checkout-v2/components/shared/exchange-rate-footer.d.ts +23 -0
  28. package/es/checkout-v2/components/shared/exchange-rate-footer.js +182 -0
  29. package/es/checkout-v2/components/shared/scenario-badge.d.ts +6 -0
  30. package/es/checkout-v2/components/shared/scenario-badge.js +47 -0
  31. package/es/checkout-v2/components/shared/total-display.d.ts +7 -0
  32. package/es/checkout-v2/components/shared/total-display.js +84 -0
  33. package/es/checkout-v2/index.d.ts +2 -0
  34. package/es/checkout-v2/index.js +1 -0
  35. package/es/checkout-v2/layouts/checkout-layout.d.ts +7 -0
  36. package/es/checkout-v2/layouts/checkout-layout.js +226 -0
  37. package/es/checkout-v2/panels/left/composite-panel.d.ts +1 -0
  38. package/es/checkout-v2/panels/left/composite-panel.js +423 -0
  39. package/es/checkout-v2/panels/left/credit-topup-panel.d.ts +1 -0
  40. package/es/checkout-v2/panels/left/credit-topup-panel.js +611 -0
  41. package/es/checkout-v2/panels/left/scenario-router.d.ts +1 -0
  42. package/es/checkout-v2/panels/left/scenario-router.js +19 -0
  43. package/es/checkout-v2/panels/right/payment-panel.d.ts +1 -0
  44. package/es/checkout-v2/panels/right/payment-panel.js +644 -0
  45. package/es/checkout-v2/types.d.ts +15 -0
  46. package/es/checkout-v2/types.js +0 -0
  47. package/es/checkout-v2/utils/format.d.ts +59 -0
  48. package/es/checkout-v2/utils/format.js +125 -0
  49. package/es/checkout-v2/utils/scenario-detector.d.ts +3 -0
  50. package/es/checkout-v2/utils/scenario-detector.js +17 -0
  51. package/es/checkout-v2/views/error-view.d.ts +7 -0
  52. package/es/checkout-v2/views/error-view.js +269 -0
  53. package/es/checkout-v2/views/loading-view.d.ts +5 -0
  54. package/es/checkout-v2/views/loading-view.js +158 -0
  55. package/es/checkout-v2/views/success-view.d.ts +29 -0
  56. package/es/checkout-v2/views/success-view.js +614 -0
  57. package/es/components/phone-field.d.ts +14 -0
  58. package/es/components/phone-field.js +96 -0
  59. package/es/index.d.ts +3 -1
  60. package/es/index.js +3 -1
  61. package/es/locales/en.js +45 -6
  62. package/es/locales/zh.js +45 -6
  63. package/es/payment/form/index.js +10 -1
  64. package/lib/checkout-v2/checkout-v2.d.ts +2 -0
  65. package/lib/checkout-v2/checkout-v2.js +151 -0
  66. package/lib/checkout-v2/components/dialogs/checkout-dialogs.d.ts +1 -0
  67. package/lib/checkout-v2/components/dialogs/checkout-dialogs.js +131 -0
  68. package/lib/checkout-v2/components/left/billing-toggle.d.ts +6 -0
  69. package/lib/checkout-v2/components/left/billing-toggle.js +126 -0
  70. package/lib/checkout-v2/components/left/cross-sell-card.d.ts +10 -0
  71. package/lib/checkout-v2/components/left/cross-sell-card.js +257 -0
  72. package/lib/checkout-v2/components/left/product-item-card.d.ts +26 -0
  73. package/lib/checkout-v2/components/left/product-item-card.js +738 -0
  74. package/lib/checkout-v2/components/left/promotion-input.d.ts +19 -0
  75. package/lib/checkout-v2/components/left/promotion-input.js +220 -0
  76. package/lib/checkout-v2/components/left/staking-breakdown.d.ts +9 -0
  77. package/lib/checkout-v2/components/left/staking-breakdown.js +96 -0
  78. package/lib/checkout-v2/components/left/trial-info.d.ts +13 -0
  79. package/lib/checkout-v2/components/left/trial-info.js +82 -0
  80. package/lib/checkout-v2/components/right/currency-grid.d.ts +8 -0
  81. package/lib/checkout-v2/components/right/currency-grid.js +96 -0
  82. package/lib/checkout-v2/components/right/customer-info-card.d.ts +17 -0
  83. package/lib/checkout-v2/components/right/customer-info-card.js +246 -0
  84. package/lib/checkout-v2/components/right/status-feedback.d.ts +7 -0
  85. package/lib/checkout-v2/components/right/status-feedback.js +30 -0
  86. package/lib/checkout-v2/components/right/submit-button.d.ts +10 -0
  87. package/lib/checkout-v2/components/right/submit-button.js +35 -0
  88. package/lib/checkout-v2/components/right/subscription-disclaimer.d.ts +11 -0
  89. package/lib/checkout-v2/components/right/subscription-disclaimer.js +33 -0
  90. package/lib/checkout-v2/components/shared/exchange-rate-footer.d.ts +23 -0
  91. package/lib/checkout-v2/components/shared/exchange-rate-footer.js +282 -0
  92. package/lib/checkout-v2/components/shared/scenario-badge.d.ts +6 -0
  93. package/lib/checkout-v2/components/shared/scenario-badge.js +57 -0
  94. package/lib/checkout-v2/components/shared/total-display.d.ts +7 -0
  95. package/lib/checkout-v2/components/shared/total-display.js +154 -0
  96. package/lib/checkout-v2/index.d.ts +2 -0
  97. package/lib/checkout-v2/index.js +13 -0
  98. package/lib/checkout-v2/layouts/checkout-layout.d.ts +7 -0
  99. package/lib/checkout-v2/layouts/checkout-layout.js +308 -0
  100. package/lib/checkout-v2/panels/left/composite-panel.d.ts +1 -0
  101. package/lib/checkout-v2/panels/left/composite-panel.js +515 -0
  102. package/lib/checkout-v2/panels/left/credit-topup-panel.d.ts +1 -0
  103. package/lib/checkout-v2/panels/left/credit-topup-panel.js +795 -0
  104. package/lib/checkout-v2/panels/left/scenario-router.d.ts +1 -0
  105. package/lib/checkout-v2/panels/left/scenario-router.js +29 -0
  106. package/lib/checkout-v2/panels/right/payment-panel.d.ts +1 -0
  107. package/lib/checkout-v2/panels/right/payment-panel.js +906 -0
  108. package/lib/checkout-v2/types.d.ts +15 -0
  109. package/lib/checkout-v2/types.js +1 -0
  110. package/lib/checkout-v2/utils/format.d.ts +59 -0
  111. package/lib/checkout-v2/utils/format.js +158 -0
  112. package/lib/checkout-v2/utils/scenario-detector.d.ts +3 -0
  113. package/lib/checkout-v2/utils/scenario-detector.js +23 -0
  114. package/lib/checkout-v2/views/error-view.d.ts +7 -0
  115. package/lib/checkout-v2/views/error-view.js +321 -0
  116. package/lib/checkout-v2/views/loading-view.d.ts +5 -0
  117. package/lib/checkout-v2/views/loading-view.js +168 -0
  118. package/lib/checkout-v2/views/success-view.d.ts +29 -0
  119. package/lib/checkout-v2/views/success-view.js +735 -0
  120. package/lib/components/phone-field.d.ts +14 -0
  121. package/lib/components/phone-field.js +130 -0
  122. package/lib/index.d.ts +3 -1
  123. package/lib/index.js +8 -0
  124. package/lib/locales/en.js +45 -6
  125. package/lib/locales/zh.js +45 -6
  126. package/lib/payment/form/index.js +10 -1
  127. package/package.json +4 -3
  128. package/src/checkout-v2/checkout-v2.tsx +155 -0
  129. package/src/checkout-v2/components/dialogs/checkout-dialogs.tsx +134 -0
  130. package/src/checkout-v2/components/left/billing-toggle.tsx +122 -0
  131. package/src/checkout-v2/components/left/cross-sell-card.tsx +170 -0
  132. package/src/checkout-v2/components/left/product-item-card.tsx +642 -0
  133. package/src/checkout-v2/components/left/promotion-input.tsx +207 -0
  134. package/src/checkout-v2/components/left/staking-breakdown.tsx +57 -0
  135. package/src/checkout-v2/components/left/trial-info.tsx +63 -0
  136. package/src/checkout-v2/components/right/currency-grid.tsx +59 -0
  137. package/src/checkout-v2/components/right/customer-info-card.tsx +214 -0
  138. package/src/checkout-v2/components/right/status-feedback.tsx +35 -0
  139. package/src/checkout-v2/components/right/submit-button.tsx +37 -0
  140. package/src/checkout-v2/components/right/subscription-disclaimer.tsx +27 -0
  141. package/src/checkout-v2/components/shared/exchange-rate-footer.tsx +221 -0
  142. package/src/checkout-v2/components/shared/scenario-badge.tsx +51 -0
  143. package/src/checkout-v2/components/shared/total-display.tsx +112 -0
  144. package/src/checkout-v2/index.ts +2 -0
  145. package/src/checkout-v2/layouts/checkout-layout.tsx +232 -0
  146. package/src/checkout-v2/panels/left/composite-panel.tsx +465 -0
  147. package/src/checkout-v2/panels/left/credit-topup-panel.tsx +677 -0
  148. package/src/checkout-v2/panels/left/scenario-router.tsx +22 -0
  149. package/src/checkout-v2/panels/right/payment-panel.tsx +703 -0
  150. package/src/checkout-v2/types.ts +18 -0
  151. package/src/checkout-v2/utils/format.ts +205 -0
  152. package/src/checkout-v2/utils/scenario-detector.ts +30 -0
  153. package/src/checkout-v2/views/error-view.tsx +293 -0
  154. package/src/checkout-v2/views/loading-view.tsx +162 -0
  155. package/src/checkout-v2/views/success-view.tsx +770 -0
  156. package/src/components/phone-field.tsx +119 -0
  157. package/src/index.ts +3 -0
  158. package/src/locales/en.tsx +45 -4
  159. package/src/locales/zh.tsx +43 -4
  160. package/src/payment/form/index.tsx +16 -1
@@ -0,0 +1,738 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ module.exports = ProductItemCard;
7
+ var _jsxRuntime = require("react/jsx-runtime");
8
+ var _react = require("react");
9
+ var _Add = _interopRequireDefault(require("@mui/icons-material/Add"));
10
+ var _Check = _interopRequireDefault(require("@mui/icons-material/Check"));
11
+ var _LocalOffer = _interopRequireDefault(require("@mui/icons-material/LocalOffer"));
12
+ var _Remove = _interopRequireDefault(require("@mui/icons-material/Remove"));
13
+ var _ShoppingCartCheckout = _interopRequireDefault(require("@mui/icons-material/ShoppingCartCheckout"));
14
+ var _material = require("@mui/material");
15
+ var _KeyboardArrowUp = _interopRequireDefault(require("@mui/icons-material/KeyboardArrowUp"));
16
+ var _paymentReactHeadless = require("@blocklet/payment-react-headless");
17
+ var _Toast = _interopRequireDefault(require("@arcblock/ux/lib/Toast"));
18
+ var _format = require("../../utils/format");
19
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
20
+ function ProductItemCard({
21
+ item,
22
+ currency,
23
+ discounts,
24
+ exchangeRate,
25
+ onQuantityChange,
26
+ onUpsell,
27
+ onDownsell,
28
+ trialActive,
29
+ trialDays,
30
+ t,
31
+ recommended = false,
32
+ hideUpsell = false,
33
+ isRateLoading = false,
34
+ showFeatures = true,
35
+ children = void 0
36
+ }) {
37
+ const activePrice = item.upsell_price || item.price;
38
+ const product = activePrice?.product;
39
+ const name = product?.name || "Item";
40
+ const logo = product?.images?.[0] || "";
41
+ const features = product?.features || [];
42
+ const recurring = activePrice?.recurring;
43
+ const quantity = item.quantity || 1;
44
+ const isMetered = recurring?.usage_type === "metered";
45
+ const metered = isMetered ? ` ${t("common.metered")}` : "";
46
+ const perUnitFormatted = (0, _format.formatDynamicUnitPrice)(activePrice, currency, exchangeRate);
47
+ const isSubscription = !!recurring;
48
+ const typeBadgeText = isSubscription ? t("payment.checkout.typeBadge.subscription") : t("payment.checkout.typeBadge.oneTime");
49
+ const priceIntervalSuffix = recurring?.interval ? ` / ${t(`common.${recurring.interval}`)}` : "";
50
+ const subtitleText = (() => {
51
+ if (quantity > 1 && perUnitFormatted && currency) {
52
+ return `${quantity} \xD7 ${perUnitFormatted} ${currency.symbol}`;
53
+ }
54
+ if (isMetered) return metered.trim();
55
+ return "";
56
+ })();
57
+ const itemTotal = (() => {
58
+ const quoteCurrencyId = item.quote_currency_id;
59
+ if (item.custom_amount && quoteCurrencyId && quoteCurrencyId === currency?.id) {
60
+ return (0, _format.formatTokenAmount)(item.custom_amount, currency);
61
+ }
62
+ if (activePrice?.pricing_type === "dynamic" && exchangeRate && activePrice.base_amount) {
63
+ const rate = Number(exchangeRate);
64
+ if (rate > 0 && Number.isFinite(rate)) {
65
+ const baseUsd = Number(activePrice.base_amount);
66
+ if (baseUsd > 0 && Number.isFinite(baseUsd)) {
67
+ const tokenAmount = baseUsd * quantity / rate;
68
+ const abs = Math.abs(tokenAmount);
69
+ const precision = abs > 0 && abs < 0.01 ? 6 : 2;
70
+ return tokenAmount.toLocaleString("en-US", {
71
+ minimumFractionDigits: 0,
72
+ maximumFractionDigits: precision
73
+ }).replace(/(\.\d*?)0+$/, "$1").replace(/\.$/, "") || "0";
74
+ }
75
+ }
76
+ }
77
+ if (!exchangeRate && activePrice?.base_amount != null) {
78
+ const baseUsd = Number(activePrice.base_amount);
79
+ if (baseUsd >= 0 && Number.isFinite(baseUsd)) {
80
+ const total = baseUsd * quantity;
81
+ return total.toLocaleString("en-US", {
82
+ minimumFractionDigits: 2,
83
+ maximumFractionDigits: 2
84
+ });
85
+ }
86
+ }
87
+ if (activePrice && currency) {
88
+ const unitAmount = (0, _paymentReactHeadless.getPriceUnitAmountByCurrency)(activePrice, currency);
89
+ if (unitAmount && unitAmount !== "0") {
90
+ const totalUnits = BigInt(unitAmount) * BigInt(quantity);
91
+ return (0, _format.formatTokenAmount)(totalUnits.toString(), currency);
92
+ }
93
+ }
94
+ return "0";
95
+ })();
96
+ const discount = discounts?.[0];
97
+ const discountCode = discount?.promotion_code_details?.code || discount?.verification_data?.code || discount?.promotion_code || "";
98
+ const perItemDiscount = (() => {
99
+ if (!discountCode || !discount) return null;
100
+ const couponDetails = discount?.coupon_details;
101
+ if (couponDetails?.percent_off > 0) {
102
+ const numericTotal = parseFloat(String(itemTotal).replace(/,/g, ""));
103
+ if (!Number.isNaN(numericTotal) && numericTotal > 0) {
104
+ const discAmount = numericTotal * couponDetails.percent_off / 100;
105
+ const abs = Math.abs(discAmount);
106
+ const precision = abs > 0 && abs < 0.01 ? 6 : 2;
107
+ return `${discAmount.toLocaleString("en-US", {
108
+ minimumFractionDigits: 0,
109
+ maximumFractionDigits: precision
110
+ }).replace(/(\.\d*?)0+$/, "$1").replace(/\.$/, "") || "0"} ${currency?.symbol || ""}`;
111
+ }
112
+ }
113
+ if (item.discount_amounts?.length > 0 && currency) {
114
+ return `${(0, _format.formatTokenAmount)(item.discount_amounts[0].amount, currency)} ${currency.symbol}`;
115
+ }
116
+ return null;
117
+ })();
118
+ const adjustable = item.adjustable_quantity?.enabled;
119
+ const min = item.adjustable_quantity?.minimum || 1;
120
+ const max = item.adjustable_quantity?.maximum;
121
+ const [qtyInput, setQtyInput] = (0, _react.useState)(String(quantity));
122
+ const [isEditing, setIsEditing] = (0, _react.useState)(false);
123
+ const theme = (0, _material.useTheme)();
124
+ const isMobile = (0, _material.useMediaQuery)(theme.breakpoints.down("md"));
125
+ const [featuresOpen, setFeaturesOpen] = (0, _react.useState)(!isMobile);
126
+ (0, _react.useEffect)(() => {
127
+ if (!isEditing) setQtyInput(String(quantity));
128
+ }, [quantity, isEditing]);
129
+ const canUpsell = !!item.price?.upsell?.upsells_to;
130
+ const isUpselled = !!item.upsell_price;
131
+ const upsellTo = item.price?.upsell?.upsells_to;
132
+ let savingsPercent = 0;
133
+ if (canUpsell && upsellTo) {
134
+ const fromAmount = parseFloat(item.price?.base_amount || item.price?.unit_amount || "0");
135
+ const toAmount = parseFloat(upsellTo?.base_amount || upsellTo?.unit_amount || "0");
136
+ const fromInterval = item.price?.recurring?.interval;
137
+ const toInterval = upsellTo?.recurring?.interval;
138
+ if (fromAmount > 0 && toAmount > 0 && fromInterval && toInterval) {
139
+ const monthsMap = {
140
+ day: 365,
141
+ week: 52,
142
+ month: 12,
143
+ year: 1
144
+ };
145
+ const fromYearly = fromAmount * (monthsMap[fromInterval] || 1);
146
+ const toYearly = toAmount * (monthsMap[toInterval] || 1);
147
+ if (fromYearly > toYearly) {
148
+ savingsPercent = Math.round((fromYearly - toYearly) / fromYearly * 100);
149
+ }
150
+ }
151
+ }
152
+ const upsellInterval = upsellTo?.recurring?.interval;
153
+ const upsellPrice = (() => {
154
+ if (!upsellTo) return "";
155
+ const slashText = upsellInterval ? t("common.slash", {
156
+ interval: t(`common.${upsellInterval}`)
157
+ }) : "";
158
+ if (upsellTo.pricing_type === "dynamic" && upsellTo.base_amount && exchangeRate) {
159
+ const rate = Number(exchangeRate);
160
+ if (rate > 0 && Number.isFinite(rate)) {
161
+ const baseUsd = parseFloat(upsellTo.base_amount);
162
+ if (baseUsd > 0 && Number.isFinite(baseUsd)) {
163
+ const tokenAmount = baseUsd / rate;
164
+ const abs = Math.abs(tokenAmount);
165
+ const precision = abs > 0 && abs < 0.01 ? 6 : 2;
166
+ const formatted = tokenAmount.toLocaleString("en-US", {
167
+ minimumFractionDigits: 0,
168
+ maximumFractionDigits: precision
169
+ }).replace(/(\.\d*?)0+$/, "$1").replace(/\.$/, "") || "0";
170
+ return `${formatted} ${currency?.symbol || ""} ${slashText}`;
171
+ }
172
+ }
173
+ }
174
+ if (upsellTo.pricing_type === "dynamic" && upsellTo.base_amount && upsellTo.base_currency === "USD") {
175
+ const baseUsd = parseFloat(upsellTo.base_amount);
176
+ const formattedUsd = baseUsd.toLocaleString("en-US", {
177
+ minimumFractionDigits: 2,
178
+ maximumFractionDigits: 2
179
+ });
180
+ return `$${formattedUsd} ${slashText}`;
181
+ }
182
+ const upsellUnitFormatted = (0, _format.formatDynamicUnitPrice)(upsellTo, currency, exchangeRate);
183
+ return upsellUnitFormatted ? `${upsellUnitFormatted} ${currency?.symbol || ""} ${slashText}` : "";
184
+ })();
185
+ const originalInterval = item.price?.recurring?.interval;
186
+ const downsellPrice = (() => {
187
+ if (!item.price || !isUpselled) return "";
188
+ const originalPrice = item.price;
189
+ const originalSlash = originalInterval ? t("common.slash", {
190
+ interval: t(`common.${originalInterval}`)
191
+ }) : "";
192
+ if (originalPrice.pricing_type === "dynamic" && originalPrice.base_amount && exchangeRate) {
193
+ const rate = Number(exchangeRate);
194
+ if (rate > 0 && Number.isFinite(rate)) {
195
+ const baseUsd = parseFloat(originalPrice.base_amount);
196
+ if (baseUsd > 0 && Number.isFinite(baseUsd)) {
197
+ const tokenAmount = baseUsd / rate;
198
+ const abs = Math.abs(tokenAmount);
199
+ const precision = abs > 0 && abs < 0.01 ? 6 : 2;
200
+ const formatted = tokenAmount.toLocaleString("en-US", {
201
+ minimumFractionDigits: 0,
202
+ maximumFractionDigits: precision
203
+ }).replace(/(\.\d*?)0+$/, "$1").replace(/\.$/, "") || "0";
204
+ return `${formatted} ${currency?.symbol || ""} ${originalSlash}`;
205
+ }
206
+ }
207
+ }
208
+ if (originalPrice.pricing_type === "dynamic" && originalPrice.base_amount && originalPrice.base_currency === "USD") {
209
+ const baseUsd = parseFloat(originalPrice.base_amount);
210
+ const formattedUsd = baseUsd.toLocaleString("en-US", {
211
+ minimumFractionDigits: 2,
212
+ maximumFractionDigits: 2
213
+ });
214
+ return `$${formattedUsd} ${originalSlash}`;
215
+ }
216
+ const unitFormatted = (0, _format.formatDynamicUnitPrice)(originalPrice, currency, exchangeRate);
217
+ return unitFormatted ? `${unitFormatted} ${currency?.symbol || ""} ${originalSlash}` : "";
218
+ })();
219
+ const upsellToggleLabel = (() => {
220
+ if (isUpselled) {
221
+ const recurringLabel2 = originalInterval ? t(_format.INTERVAL_LOCALE_KEY[originalInterval] || "") : "";
222
+ return t("payment.checkout.upsell.revert", {
223
+ recurring: recurringLabel2
224
+ });
225
+ }
226
+ const recurringLabel = upsellInterval ? t(_format.INTERVAL_LOCALE_KEY[upsellInterval] || "") : "";
227
+ return t("payment.checkout.upsell.save", {
228
+ recurring: recurringLabel
229
+ });
230
+ })();
231
+ return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
232
+ sx: {
233
+ position: "relative"
234
+ },
235
+ children: [recommended && /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Chip, {
236
+ label: "RECOMMENDED",
237
+ size: "small",
238
+ sx: {
239
+ position: "absolute",
240
+ top: 0,
241
+ right: 40,
242
+ transform: "translateY(-50%)",
243
+ zIndex: 1,
244
+ height: 22,
245
+ fontSize: 9,
246
+ fontWeight: 900,
247
+ letterSpacing: "0.12em",
248
+ bgcolor: "primary.main",
249
+ color: "#fff",
250
+ boxShadow: "0 4px 12px rgba(45,124,243,0.2)",
251
+ "& .MuiChip-label": {
252
+ px: 1.5
253
+ }
254
+ }
255
+ }), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
256
+ sx: {
257
+ p: {
258
+ xs: 2,
259
+ md: 3
260
+ },
261
+ bgcolor: "background.paper",
262
+ borderRadius: {
263
+ xs: "16px",
264
+ md: "24px"
265
+ },
266
+ border: "1px solid",
267
+ borderColor: "divider",
268
+ boxShadow: th => th.palette.mode === "dark" ? "0 12px 40px -8px rgba(0,0,0,0.3)" : "0 12px 40px -8px rgba(0,0,0,0.06)",
269
+ transition: "all 0.3s ease",
270
+ ...(canUpsell && !hideUpsell ? {
271
+ borderRadius: {
272
+ xs: "16px 16px 0 0",
273
+ md: "24px 24px 0 0"
274
+ }
275
+ } : {}),
276
+ "&:hover": {
277
+ borderColor: th => th.palette.mode === "dark" ? "rgba(255,255,255,0.12)" : "rgba(45,124,243,0.15)"
278
+ }
279
+ },
280
+ children: [/* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
281
+ direction: "row",
282
+ spacing: {
283
+ xs: 1.5,
284
+ md: 2.5
285
+ },
286
+ sx: {
287
+ alignItems: "center",
288
+ width: "100%"
289
+ },
290
+ children: [logo ? /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Avatar, {
291
+ src: logo,
292
+ alt: name,
293
+ variant: "rounded",
294
+ sx: {
295
+ width: {
296
+ xs: 44,
297
+ md: 64
298
+ },
299
+ height: {
300
+ xs: 44,
301
+ md: 64
302
+ },
303
+ borderRadius: {
304
+ xs: "12px",
305
+ md: "16px"
306
+ },
307
+ flexShrink: 0
308
+ }
309
+ }) : /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Avatar, {
310
+ variant: "rounded",
311
+ sx: {
312
+ width: {
313
+ xs: 44,
314
+ md: 64
315
+ },
316
+ height: {
317
+ xs: 44,
318
+ md: 64
319
+ },
320
+ borderRadius: {
321
+ xs: "12px",
322
+ md: "16px"
323
+ },
324
+ bgcolor: th => th.palette.mode === "dark" ? "rgba(255,255,255,0.06)" : "#eff6ff",
325
+ flexShrink: 0
326
+ },
327
+ children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_ShoppingCartCheckout.default, {
328
+ sx: {
329
+ fontSize: {
330
+ xs: 22,
331
+ md: 28
332
+ },
333
+ color: "primary.main",
334
+ opacity: 0.45
335
+ }
336
+ })
337
+ }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
338
+ sx: {
339
+ flex: 1,
340
+ minWidth: 0,
341
+ overflow: "hidden"
342
+ },
343
+ children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
344
+ direction: "row",
345
+ justifyContent: "space-between",
346
+ alignItems: "flex-start",
347
+ sx: {
348
+ mb: 0.25
349
+ },
350
+ children: [/* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
351
+ sx: {
352
+ minWidth: 0
353
+ },
354
+ children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
355
+ sx: {
356
+ color: "text.primary",
357
+ fontWeight: 800,
358
+ fontSize: {
359
+ xs: 15,
360
+ md: 18
361
+ },
362
+ lineHeight: 1.3
363
+ },
364
+ children: name
365
+ }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
366
+ component: "span",
367
+ sx: {
368
+ display: "inline-block",
369
+ mt: 0.5,
370
+ fontSize: 10,
371
+ fontWeight: 700,
372
+ letterSpacing: "0.08em",
373
+ lineHeight: 1,
374
+ textTransform: "uppercase",
375
+ color: "primary.main",
376
+ bgcolor: th => th.palette.mode === "dark" ? `${th.palette.primary.main}1A` : `${th.palette.primary.main}0D`,
377
+ px: 0.75,
378
+ py: 0.4,
379
+ borderRadius: "3px"
380
+ },
381
+ children: typeBadgeText
382
+ }), subtitleText && /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
383
+ sx: {
384
+ color: "text.disabled",
385
+ fontSize: 13,
386
+ fontWeight: 500,
387
+ mt: 0.25
388
+ },
389
+ children: subtitleText
390
+ })]
391
+ }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Stack, {
392
+ alignItems: "flex-end",
393
+ sx: {
394
+ flexShrink: 0,
395
+ ml: 1.5
396
+ },
397
+ children: trialActive && isSubscription ? /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
398
+ sx: {
399
+ fontWeight: 800,
400
+ color: "text.primary",
401
+ whiteSpace: "nowrap",
402
+ fontSize: {
403
+ xs: 15,
404
+ md: 18
405
+ }
406
+ },
407
+ children: (0, _format.formatTrialText)(t, trialDays, recurring?.interval || "day")
408
+ }) : isRateLoading ? /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Skeleton, {
409
+ variant: "text",
410
+ width: 100,
411
+ height: 28
412
+ }) : /* @__PURE__ */(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
413
+ children: [/* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Typography, {
414
+ sx: {
415
+ fontWeight: 800,
416
+ color: "text.primary",
417
+ whiteSpace: "nowrap",
418
+ fontSize: {
419
+ xs: 15,
420
+ md: 18
421
+ },
422
+ transition: "opacity 0.3s ease"
423
+ },
424
+ children: [itemTotal, " ", currency?.symbol, priceIntervalSuffix]
425
+ }), exchangeRate && activePrice?.base_amount && /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Typography, {
426
+ sx: {
427
+ fontSize: 12,
428
+ color: "text.disabled",
429
+ fontWeight: 600,
430
+ lineHeight: 1
431
+ },
432
+ children: ["\u2248 $", (Number(activePrice.base_amount) * quantity).toFixed(2)]
433
+ })]
434
+ })
435
+ })]
436
+ })
437
+ })]
438
+ }), showFeatures && features.length > 0 && /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
439
+ sx: {
440
+ mt: {
441
+ xs: 2,
442
+ md: 2.5
443
+ },
444
+ pt: {
445
+ xs: 2,
446
+ md: 2.5
447
+ },
448
+ borderTop: "1px solid",
449
+ borderColor: th => th.palette.mode === "dark" ? "rgba(255,255,255,0.06)" : "grey.100"
450
+ },
451
+ children: [/* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
452
+ direction: "row",
453
+ alignItems: "center",
454
+ justifyContent: "space-between",
455
+ onClick: () => setFeaturesOpen(v => !v),
456
+ sx: {
457
+ cursor: "pointer",
458
+ userSelect: "none",
459
+ mb: featuresOpen ? 1.25 : 0
460
+ },
461
+ children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
462
+ sx: {
463
+ fontSize: 14,
464
+ fontWeight: 700,
465
+ color: "text.primary"
466
+ },
467
+ children: t("payment.checkout.planFeatures")
468
+ }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_KeyboardArrowUp.default, {
469
+ sx: {
470
+ fontSize: 20,
471
+ color: "text.secondary",
472
+ transition: "transform 0.2s ease",
473
+ transform: featuresOpen ? "rotate(0deg)" : "rotate(180deg)"
474
+ }
475
+ })]
476
+ }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Collapse, {
477
+ in: featuresOpen,
478
+ children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Stack, {
479
+ spacing: 1.25,
480
+ children: features.map(feature => /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
481
+ direction: "row",
482
+ spacing: 1.5,
483
+ alignItems: "center",
484
+ children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
485
+ sx: {
486
+ width: 20,
487
+ height: 20,
488
+ borderRadius: "50%",
489
+ bgcolor: th => th.palette.mode === "dark" ? "rgba(16,185,129,0.15)" : "rgba(16,185,129,0.1)",
490
+ display: "flex",
491
+ alignItems: "center",
492
+ justifyContent: "center",
493
+ flexShrink: 0
494
+ },
495
+ children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_Check.default, {
496
+ sx: {
497
+ fontSize: 14,
498
+ color: "success.main"
499
+ }
500
+ })
501
+ }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
502
+ sx: {
503
+ fontSize: 14,
504
+ fontWeight: 500,
505
+ color: "text.secondary"
506
+ },
507
+ children: feature.name
508
+ })]
509
+ }, feature.name))
510
+ })
511
+ })]
512
+ }), discountCode && perItemDiscount && /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
513
+ sx: {
514
+ mt: 1.5
515
+ },
516
+ children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Chip, {
517
+ icon: /* @__PURE__ */(0, _jsxRuntime.jsx)(_LocalOffer.default, {
518
+ sx: {
519
+ color: "warning.main",
520
+ fontSize: "small"
521
+ }
522
+ }),
523
+ label: `${discountCode} (-${perItemDiscount})`,
524
+ size: "small",
525
+ sx: {
526
+ height: 22,
527
+ borderRadius: "6px",
528
+ "& .MuiChip-label": {
529
+ fontSize: 12
530
+ }
531
+ }
532
+ })
533
+ }), adjustable && /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
534
+ direction: "row",
535
+ spacing: 1,
536
+ alignItems: "center",
537
+ sx: {
538
+ mt: 2
539
+ },
540
+ children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
541
+ sx: {
542
+ color: "text.secondary",
543
+ minWidth: "fit-content",
544
+ fontSize: 13,
545
+ fontWeight: 500
546
+ },
547
+ children: t("common.quantity")
548
+ }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.IconButton, {
549
+ size: "small",
550
+ onClick: () => onQuantityChange(item.price_id, quantity - 1),
551
+ disabled: quantity <= min,
552
+ sx: {
553
+ width: 36,
554
+ height: 36,
555
+ border: "1px solid",
556
+ borderColor: "divider",
557
+ borderRadius: "50%",
558
+ "&:hover": {
559
+ bgcolor: "action.hover"
560
+ }
561
+ },
562
+ children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_Remove.default, {
563
+ sx: {
564
+ fontSize: 20
565
+ }
566
+ })
567
+ }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.TextField, {
568
+ value: qtyInput,
569
+ size: "small",
570
+ type: "number",
571
+ slotProps: {
572
+ htmlInput: {
573
+ style: {
574
+ textAlign: "center",
575
+ padding: "6px 4px",
576
+ fontWeight: 700,
577
+ fontSize: 16,
578
+ MozAppearance: "textfield"
579
+ },
580
+ min,
581
+ max: max || void 0
582
+ }
583
+ },
584
+ sx: {
585
+ minWidth: 64,
586
+ "& input": {
587
+ textAlign: "center"
588
+ },
589
+ "& .MuiOutlinedInput-root": {
590
+ borderRadius: "12px"
591
+ },
592
+ "& input::-webkit-outer-spin-button, & input::-webkit-inner-spin-button": {
593
+ WebkitAppearance: "none",
594
+ margin: 0
595
+ },
596
+ "& input[type=number]": {
597
+ MozAppearance: "textfield"
598
+ }
599
+ },
600
+ onFocus: () => setIsEditing(true),
601
+ onChange: e => setQtyInput(e.target.value),
602
+ onKeyDown: e => {
603
+ if (e.key === "Enter") {
604
+ e.preventDefault();
605
+ e.stopPropagation();
606
+ e.target.blur();
607
+ }
608
+ },
609
+ onBlur: () => {
610
+ setIsEditing(false);
611
+ const v = parseInt(qtyInput, 10);
612
+ if (!Number.isNaN(v) && v >= min && (!max || v <= max) && v !== quantity) {
613
+ onQuantityChange(item.price_id, v);
614
+ } else {
615
+ setQtyInput(String(quantity));
616
+ }
617
+ }
618
+ }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.IconButton, {
619
+ size: "small",
620
+ onClick: () => onQuantityChange(item.price_id, quantity + 1),
621
+ disabled: max ? quantity >= max : false,
622
+ sx: {
623
+ width: 36,
624
+ height: 36,
625
+ border: "1px solid",
626
+ borderColor: "divider",
627
+ borderRadius: "50%",
628
+ "&:hover": {
629
+ bgcolor: "action.hover"
630
+ }
631
+ },
632
+ children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_Add.default, {
633
+ sx: {
634
+ fontSize: 20
635
+ }
636
+ })
637
+ })]
638
+ }), children]
639
+ }), canUpsell && !hideUpsell && /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
640
+ sx: {
641
+ px: {
642
+ xs: 2,
643
+ md: 3
644
+ },
645
+ py: 1.5,
646
+ bgcolor: "background.paper",
647
+ border: "1px solid",
648
+ borderTop: 0,
649
+ borderColor: "divider",
650
+ borderRadius: {
651
+ xs: "0 0 16px 16px",
652
+ md: "0 0 24px 24px"
653
+ },
654
+ boxShadow: th => th.palette.mode === "dark" ? "0 12px 40px -8px rgba(0,0,0,0.3)" : "0 12px 40px -8px rgba(0,0,0,0.06)"
655
+ },
656
+ children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
657
+ sx: {
658
+ borderTop: "1px solid",
659
+ borderColor: "divider",
660
+ mb: 1.5
661
+ }
662
+ }), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
663
+ direction: "row",
664
+ alignItems: "center",
665
+ justifyContent: "space-between",
666
+ children: [/* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
667
+ direction: "row",
668
+ alignItems: "center",
669
+ spacing: 1,
670
+ children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Switch, {
671
+ checked: isUpselled,
672
+ onChange: async () => {
673
+ try {
674
+ if (isUpselled) {
675
+ await onDownsell(item.upsell_price?.id || item.price.id);
676
+ } else {
677
+ await onUpsell(item.price_id, upsellTo.id);
678
+ }
679
+ } catch (err) {
680
+ _Toast.default.error(err?.response?.data?.error || err?.message || "Failed");
681
+ }
682
+ },
683
+ size: "small",
684
+ sx: {
685
+ "& .MuiSwitch-switchBase.Mui-checked": {
686
+ color: "#12b886"
687
+ },
688
+ "& .MuiSwitch-switchBase.Mui-checked + .MuiSwitch-track": {
689
+ bgcolor: "#12b886"
690
+ }
691
+ }
692
+ }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
693
+ sx: {
694
+ fontSize: 13,
695
+ color: "text.secondary",
696
+ cursor: "pointer",
697
+ fontWeight: 600
698
+ },
699
+ onClick: async () => {
700
+ try {
701
+ if (isUpselled) await onDownsell(item.upsell_price?.id || item.price.id);else await onUpsell(item.price_id, upsellTo.id);
702
+ } catch (err) {
703
+ _Toast.default.error(err?.response?.data?.error || err?.message || "Failed");
704
+ }
705
+ },
706
+ children: upsellToggleLabel
707
+ }), !isUpselled && savingsPercent > 0 && /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Chip, {
708
+ label: t("payment.checkout.upsell.off", {
709
+ saving: savingsPercent
710
+ }),
711
+ size: "small",
712
+ sx: {
713
+ height: 22,
714
+ fontSize: 11,
715
+ fontWeight: 700,
716
+ bgcolor: th => th.palette.mode === "dark" ? "rgba(18,184,134,0.1)" : "#ebfef5",
717
+ color: "#12b886",
718
+ border: "1px solid",
719
+ borderColor: th => th.palette.mode === "dark" ? "rgba(18,184,134,0.2)" : "#d3f9e8",
720
+ borderRadius: "9999px",
721
+ "& .MuiChip-label": {
722
+ px: 1
723
+ }
724
+ }
725
+ })]
726
+ }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
727
+ sx: {
728
+ fontSize: 13,
729
+ color: "text.primary",
730
+ whiteSpace: "nowrap",
731
+ fontWeight: 700
732
+ },
733
+ children: isUpselled ? downsellPrice : upsellPrice
734
+ })]
735
+ })]
736
+ })]
737
+ });
738
+ }