@nextblock-cms/ecom 0.8.1 → 0.8.7

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 (241) hide show
  1. package/index.cjs.js +1 -1
  2. package/index.es.js +136 -3224
  3. package/lib/CurrencyProvider.cjs.js +1 -0
  4. package/lib/CurrencyProvider.es.js +99 -0
  5. package/lib/cart-store.cjs.js +1 -0
  6. package/lib/cart-store.es.js +116 -0
  7. package/lib/components/AccountNavigationMenu.cjs.js +1 -0
  8. package/lib/components/AccountNavigationMenu.es.js +44 -0
  9. package/lib/components/AddToCartButton.cjs.js +1 -0
  10. package/lib/components/AddToCartButton.es.js +60 -0
  11. package/lib/components/Cart.cjs.js +1 -0
  12. package/lib/components/Cart.es.js +148 -0
  13. package/lib/components/CartDrawer.cjs.js +1 -0
  14. package/lib/components/CartDrawer.es.js +119 -0
  15. package/lib/components/CartIcon.cjs.js +1 -0
  16. package/lib/components/CartIcon.es.js +34 -0
  17. package/lib/components/Checkout.cjs.js +1 -0
  18. package/lib/components/Checkout.es.js +987 -0
  19. package/lib/components/CouponForm.cjs.js +1 -0
  20. package/lib/components/CouponForm.es.js +136 -0
  21. package/lib/components/CurrencySwitcher.cjs.js +1 -0
  22. package/lib/components/CurrencySwitcher.es.js +18 -0
  23. package/lib/components/CustomerProfileForm.cjs.js +1 -0
  24. package/lib/components/CustomerProfileForm.es.js +355 -0
  25. package/lib/components/FeaturedProduct.cjs.js +1 -0
  26. package/lib/components/FeaturedProduct.es.js +72 -0
  27. package/lib/components/InvoiceDocument.cjs.js +1 -0
  28. package/lib/components/InvoiceDocument.es.js +196 -0
  29. package/lib/components/InvoiceViewerShell.cjs.js +29 -0
  30. package/lib/components/InvoiceViewerShell.es.js +100 -0
  31. package/lib/components/ProductCard.cjs.js +1 -0
  32. package/lib/components/ProductCard.es.js +119 -0
  33. package/lib/components/ProductDetailsLayout.cjs.js +1 -0
  34. package/lib/components/ProductDetailsLayout.es.js +361 -0
  35. package/lib/components/ProductGallery.cjs.js +1 -0
  36. package/lib/components/ProductGallery.es.js +41 -0
  37. package/lib/components/ProductGrid.cjs.js +1 -0
  38. package/lib/components/ProductGrid.es.js +19 -0
  39. package/lib/components/ShippingEstimator.cjs.js +1 -0
  40. package/lib/components/ShippingEstimator.es.js +125 -0
  41. package/lib/components/SimpleTiptapRenderer.cjs.js +1 -0
  42. package/lib/components/SimpleTiptapRenderer.es.js +187 -0
  43. package/lib/components/SubscriptionSelector.cjs.js +1 -0
  44. package/lib/components/SubscriptionSelector.es.js +140 -0
  45. package/lib/countries.cjs.js +1 -0
  46. package/lib/countries.es.js +77 -0
  47. package/lib/coupon-server.cjs.js +1 -0
  48. package/lib/coupon-server.es.js +234 -0
  49. package/lib/coupons.cjs.js +1 -0
  50. package/lib/coupons.es.js +17 -0
  51. package/lib/currency-constants.cjs.js +1 -0
  52. package/lib/currency-constants.es.js +4 -0
  53. package/lib/currency-store.cjs.js +1 -0
  54. package/lib/currency-store.es.js +27 -0
  55. package/lib/currency-sync.cjs.js +1 -0
  56. package/lib/currency-sync.es.js +180 -0
  57. package/lib/currency.cjs.js +1 -0
  58. package/lib/currency.es.js +312 -0
  59. package/lib/customer-addresses.cjs.js +1 -0
  60. package/lib/customer-addresses.es.js +116 -0
  61. package/lib/customer-orders.cjs.js +1 -0
  62. package/lib/customer-orders.es.js +45 -0
  63. package/lib/customer.cjs.js +1 -0
  64. package/lib/customer.es.js +58 -0
  65. package/lib/export-helpers.cjs.js +1 -0
  66. package/lib/export-helpers.es.js +56 -0
  67. package/lib/factory.cjs.js +1 -0
  68. package/lib/factory.es.js +8 -0
  69. package/lib/freemius-coupons.cjs.js +1 -0
  70. package/lib/freemius-coupons.es.js +272 -0
  71. package/lib/freemius-order-sync.cjs.js +1 -0
  72. package/lib/freemius-order-sync.es.js +284 -0
  73. package/lib/inventory-settings.cjs.js +1 -0
  74. package/lib/inventory-settings.es.js +86 -0
  75. package/lib/invoice-server.cjs.js +33 -0
  76. package/lib/invoice-server.es.js +141 -0
  77. package/lib/invoice-ui.cjs.js +1 -0
  78. package/lib/invoice-ui.es.js +71 -0
  79. package/lib/invoice.cjs.js +1 -0
  80. package/lib/invoice.es.js +102 -0
  81. package/lib/order-inventory.cjs.js +61 -0
  82. package/lib/order-inventory.es.js +128 -0
  83. package/lib/order-tax-details.cjs.js +1 -0
  84. package/lib/order-tax-details.es.js +164 -0
  85. package/lib/pages/cms/coupons/CouponEditorForm.cjs.js +1 -0
  86. package/lib/pages/cms/coupons/CouponEditorForm.es.js +189 -0
  87. package/lib/pages/cms/coupons/CouponsPage.cjs.js +5 -0
  88. package/lib/pages/cms/coupons/CouponsPage.es.js +171 -0
  89. package/lib/pages/cms/coupons/CreateCouponDialog.cjs.js +1 -0
  90. package/lib/pages/cms/coupons/CreateCouponDialog.es.js +35 -0
  91. package/lib/pages/cms/coupons/EditCouponPage.cjs.js +1 -0
  92. package/lib/pages/cms/coupons/EditCouponPage.es.js +48 -0
  93. package/lib/pages/cms/coupons/ProductScopePicker.cjs.js +1 -0
  94. package/lib/pages/cms/coupons/ProductScopePicker.es.js +120 -0
  95. package/lib/pages/cms/coupons/actions.cjs.js +1 -0
  96. package/lib/pages/cms/coupons/actions.es.js +128 -0
  97. package/lib/pages/cms/coupons/product-options.cjs.js +1 -0
  98. package/lib/pages/cms/coupons/product-options.es.js +27 -0
  99. package/lib/pages/cms/orders/ExportReportsDialog.cjs.js +1 -0
  100. package/lib/pages/cms/orders/ExportReportsDialog.es.js +130 -0
  101. package/lib/pages/cms/orders/OrderDetailPage.cjs.js +1 -0
  102. package/lib/pages/cms/orders/OrderDetailPage.es.js +137 -0
  103. package/lib/pages/cms/orders/OrderPrintButton.cjs.js +1 -0
  104. package/lib/pages/cms/orders/OrderPrintButton.es.js +22 -0
  105. package/lib/pages/cms/orders/OrderStatusForm.cjs.js +1 -0
  106. package/lib/pages/cms/orders/OrderStatusForm.es.js +71 -0
  107. package/lib/pages/cms/orders/OrdersPage.cjs.js +1 -0
  108. package/lib/pages/cms/orders/OrdersPage.es.js +104 -0
  109. package/lib/pages/cms/orders/actions.cjs.js +7 -0
  110. package/lib/pages/cms/orders/actions.es.js +71 -0
  111. package/lib/pages/cms/orders/export-actions.cjs.js +1 -0
  112. package/lib/pages/cms/orders/export-actions.es.js +27 -0
  113. package/lib/pages/cms/orders/server-actions.cjs.js +1 -0
  114. package/lib/pages/cms/orders/server-actions.es.js +55 -0
  115. package/lib/pages/cms/payments/PaymentsClient.cjs.js +1 -0
  116. package/lib/pages/cms/payments/PaymentsClient.es.js +188 -0
  117. package/lib/pages/cms/payments/PaymentsPage.cjs.js +1 -0
  118. package/lib/pages/cms/payments/PaymentsPage.es.js +29 -0
  119. package/lib/pages/cms/payments/actions.cjs.js +1 -0
  120. package/lib/pages/cms/payments/actions.es.js +23 -0
  121. package/lib/pages/cms/payments/queries.cjs.js +1 -0
  122. package/lib/pages/cms/payments/queries.es.js +30 -0
  123. package/lib/pages/cms/products/ProductsPage.cjs.js +1 -0
  124. package/lib/pages/cms/products/ProductsPage.es.js +46 -0
  125. package/lib/pages/cms/products/_id_/edit/EditProductPage.cjs.js +1 -0
  126. package/lib/pages/cms/products/_id_/edit/EditProductPage.es.js +156 -0
  127. package/lib/pages/cms/products/actions.cjs.js +44 -0
  128. package/lib/pages/cms/products/actions.es.js +175 -0
  129. package/lib/pages/cms/products/attributes/AttributeManagementPage.cjs.js +1 -0
  130. package/lib/pages/cms/products/attributes/AttributeManagementPage.es.js +48 -0
  131. package/lib/pages/cms/products/attributes/components/AttributeManager.cjs.js +1 -0
  132. package/lib/pages/cms/products/attributes/components/AttributeManager.es.js +291 -0
  133. package/lib/pages/cms/products/categories/CategoryManagementPage.cjs.js +1 -0
  134. package/lib/pages/cms/products/categories/CategoryManagementPage.es.js +36 -0
  135. package/lib/pages/cms/products/categories/components/CategoryManager.cjs.js +1 -0
  136. package/lib/pages/cms/products/categories/components/CategoryManager.es.js +263 -0
  137. package/lib/pages/cms/products/components/CopyProductFromLanguage.cjs.js +1 -0
  138. package/lib/pages/cms/products/components/CopyProductFromLanguage.es.js +114 -0
  139. package/lib/pages/cms/products/components/CurrencyPriceFields.cjs.js +1 -0
  140. package/lib/pages/cms/products/components/CurrencyPriceFields.es.js +107 -0
  141. package/lib/pages/cms/products/components/DeleteProductButton.cjs.js +1 -0
  142. package/lib/pages/cms/products/components/DeleteProductButton.es.js +48 -0
  143. package/lib/pages/cms/products/components/FreemiusPricingDashboard.cjs.js +1 -0
  144. package/lib/pages/cms/products/components/FreemiusPricingDashboard.es.js +86 -0
  145. package/lib/pages/cms/products/components/ProductCategorySelector.cjs.js +1 -0
  146. package/lib/pages/cms/products/components/ProductCategorySelector.es.js +160 -0
  147. package/lib/pages/cms/products/components/ProductForm.cjs.js +1 -0
  148. package/lib/pages/cms/products/components/ProductForm.es.js +702 -0
  149. package/lib/pages/cms/products/components/ProductMediaManager.cjs.js +1 -0
  150. package/lib/pages/cms/products/components/ProductMediaManager.es.js +104 -0
  151. package/lib/pages/cms/products/components/ProductsBulkTable.cjs.js +1 -0
  152. package/lib/pages/cms/products/components/ProductsBulkTable.es.js +228 -0
  153. package/lib/pages/cms/products/components/SaleScheduleFields.cjs.js +1 -0
  154. package/lib/pages/cms/products/components/SaleScheduleFields.es.js +137 -0
  155. package/lib/pages/cms/products/components/SyncFreemiusButton.cjs.js +1 -0
  156. package/lib/pages/cms/products/components/SyncFreemiusButton.es.js +36 -0
  157. package/lib/pages/cms/products/components/SyncFreemiusPricingButton.cjs.js +1 -0
  158. package/lib/pages/cms/products/components/SyncFreemiusPricingButton.es.js +40 -0
  159. package/lib/pages/cms/products/components/VariationsEditor.cjs.js +1 -0
  160. package/lib/pages/cms/products/components/VariationsEditor.es.js +408 -0
  161. package/lib/pages/cms/products/inventory/InventoryPage.cjs.js +1 -0
  162. package/lib/pages/cms/products/inventory/InventoryPage.es.js +16 -0
  163. package/lib/pages/cms/products/inventory/InventoryTableClient.cjs.js +2 -0
  164. package/lib/pages/cms/products/inventory/InventoryTableClient.es.js +214 -0
  165. package/lib/pages/cms/products/inventory/actions.cjs.js +3 -0
  166. package/lib/pages/cms/products/inventory/actions.es.js +95 -0
  167. package/lib/pages/cms/products/new/NewProductPage.cjs.js +1 -0
  168. package/lib/pages/cms/products/new/NewProductPage.es.js +76 -0
  169. package/lib/pages/cms/products/product-price-sync.cjs.js +1 -0
  170. package/lib/pages/cms/products/product-price-sync.es.js +98 -0
  171. package/lib/pages/cms/products/server-actions.cjs.js +1 -0
  172. package/lib/pages/cms/products/server-actions.es.js +193 -0
  173. package/lib/pages/cms/shipping/ShippingPage.cjs.js +5 -0
  174. package/lib/pages/cms/shipping/ShippingPage.es.js +211 -0
  175. package/lib/pages/cms/shipping/components/RateForm.cjs.js +1 -0
  176. package/lib/pages/cms/shipping/components/RateForm.es.js +441 -0
  177. package/lib/pages/cms/shipping/components/ZoneForm.cjs.js +1 -0
  178. package/lib/pages/cms/shipping/components/ZoneForm.es.js +228 -0
  179. package/lib/pages/cms/shipping/server-actions.cjs.js +1 -0
  180. package/lib/pages/cms/shipping/server-actions.es.js +159 -0
  181. package/lib/pages/cms/taxes/TaxesPage.cjs.js +1 -0
  182. package/lib/pages/cms/taxes/TaxesPage.es.js +172 -0
  183. package/lib/pages/cms/taxes/actions.cjs.js +1 -0
  184. package/lib/pages/cms/taxes/actions.es.js +57 -0
  185. package/lib/pages/cms/taxes/components/TaxRateForm.cjs.js +1 -0
  186. package/lib/pages/cms/taxes/components/TaxRateForm.es.js +100 -0
  187. package/lib/product-actions.cjs.js +237 -0
  188. package/lib/product-actions.es.js +524 -0
  189. package/lib/product-context.cjs.js +1 -0
  190. package/lib/product-context.es.js +16 -0
  191. package/lib/product-schema.cjs.js +1 -0
  192. package/lib/product-schema.es.js +134 -0
  193. package/lib/providers/freemius.cjs.js +5 -0
  194. package/lib/providers/freemius.es.js +538 -0
  195. package/lib/providers/stripe.cjs.js +1 -0
  196. package/lib/providers/stripe.es.js +473 -0
  197. package/lib/server-actions/coupon-actions.cjs.js +1 -0
  198. package/lib/server-actions/coupon-actions.es.js +23 -0
  199. package/lib/server-actions/customer-actions.cjs.js +1 -0
  200. package/lib/server-actions/customer-actions.es.js +30 -0
  201. package/lib/server-actions/product-actions.cjs.js +1 -0
  202. package/lib/server-actions/product-actions.es.js +16 -0
  203. package/lib/server-actions/shipping-actions.cjs.js +1 -0
  204. package/lib/server-actions/shipping-actions.es.js +27 -0
  205. package/lib/server-actions/tax-actions.cjs.js +1 -0
  206. package/lib/server-actions/tax-actions.es.js +40 -0
  207. package/lib/shared-inventory.cjs.js +15 -0
  208. package/lib/shared-inventory.es.js +171 -0
  209. package/lib/shipping/resolver.cjs.js +7 -0
  210. package/lib/shipping/resolver.es.js +62 -0
  211. package/lib/shipping-rate-currency.cjs.js +1 -0
  212. package/lib/shipping-rate-currency.es.js +72 -0
  213. package/lib/states.cjs.js +1 -0
  214. package/lib/states.es.js +127 -0
  215. package/lib/stripe/checkout.cjs.js +1 -0
  216. package/lib/stripe/checkout.es.js +182 -0
  217. package/lib/stripe/client.cjs.js +1 -0
  218. package/lib/stripe/client.es.js +7 -0
  219. package/lib/stripe/order-sync.cjs.js +1 -0
  220. package/lib/stripe/order-sync.es.js +130 -0
  221. package/lib/stripe/webhooks.cjs.js +1 -0
  222. package/lib/stripe/webhooks.es.js +30 -0
  223. package/lib/tax-calculation.cjs.js +1 -0
  224. package/lib/tax-calculation.es.js +101 -0
  225. package/lib/trials.cjs.js +1 -0
  226. package/lib/trials.es.js +29 -0
  227. package/lib/types.cjs.js +1 -0
  228. package/lib/types.es.js +33 -0
  229. package/lib/use-cart.cjs.js +1 -0
  230. package/lib/use-cart.es.js +44 -0
  231. package/lib/variation-utils.cjs.js +1 -0
  232. package/lib/variation-utils.es.js +246 -0
  233. package/lib/zod-config.cjs.js +1 -0
  234. package/lib/zod-config.es.js +6 -0
  235. package/package.json +10 -5
  236. package/server.cjs.js +1 -110
  237. package/server.es.js +178 -6037
  238. package/invoice-ui-BJZfedDd.cjs +0 -332
  239. package/invoice-ui-GJ1ADAjn.js +0 -5759
  240. /package/{currency-rest-client-uolJxUkL.cjs → lib/currency-rest-client.cjs.js} +0 -0
  241. /package/{currency-rest-client-CwoqdgAP.js → lib/currency-rest-client.es.js} +0 -0
@@ -0,0 +1,987 @@
1
+ 'use client';
2
+ import { jsx as e, jsxs as r, Fragment as st } from "react/jsx-runtime";
3
+ import { Badge as Oe } from "@nextblock-cms/ui/badge";
4
+ import { Button as _e } from "@nextblock-cms/ui/button";
5
+ import { Card as Q, CardHeader as X, CardTitle as Y, CardContent as V } from "@nextblock-cms/ui/card";
6
+ import { Checkbox as lt } from "@nextblock-cms/ui/checkbox";
7
+ import { Input as j } from "@nextblock-cms/ui/input";
8
+ import { Label as v } from "@nextblock-cms/ui/label";
9
+ import { Separator as it } from "@nextblock-cms/ui/separator";
10
+ import { RadioGroup as ot, RadioGroupItem as De } from "@nextblock-cms/ui/radio-group";
11
+ import { Checkout as at } from "@freemius/checkout";
12
+ import { getCartItemActivePrice as Ne } from "../cart-store.es.js";
13
+ import { useCart as dt } from "../use-cart.es.js";
14
+ import { useState as _, useMemo as $, useEffect as ie } from "react";
15
+ import { X as mt, FlaskConical as ut, CreditCard as pt, ChevronRight as ht, Loader2 as ye, Package as ft, Download as gt, MapPin as _t } from "lucide-react";
16
+ import { useTranslations as qe, formatPrice as y } from "@nextblock-cms/utils";
17
+ import { normalizeCountryCode as yt, countries as xt } from "../countries.es.js";
18
+ import { getShippingEstimates as bt } from "../server-actions/shipping-actions.es.js";
19
+ import { getTaxEstimate as Nt } from "../server-actions/tax-actions.es.js";
20
+ import { isDigitalItem as xe } from "../types.es.js";
21
+ import { countryUsesStructuredStates as ke, getStatesForCountry as Me } from "../states.es.js";
22
+ import { addressesMatch as vt, emptyCustomerAddress as kt, normalizeCustomerAddress as ve, isCustomerAddressComplete as Le } from "../customer.es.js";
23
+ import { useCurrency as wt } from "../CurrencyProvider.es.js";
24
+ import { getTrialSummary as Re } from "../trials.es.js";
25
+ import { CouponForm as St } from "./CouponForm.es.js";
26
+ const Ct = process.env.NEXT_PUBLIC_IS_SANDBOX === "true", oe = "nextblock-checkout-draft-v1";
27
+ function ae(c, x) {
28
+ return {
29
+ ...kt(),
30
+ company_name: c?.company_name || "",
31
+ recipient_name: c?.recipient_name || x || "",
32
+ line1: c?.line1 || "",
33
+ line2: c?.line2 || "",
34
+ city: c?.city || "",
35
+ state: c?.state || "",
36
+ postal_code: c?.postal_code || "",
37
+ country_code: yt(c?.country_code) || "CA"
38
+ };
39
+ }
40
+ function Ft(c) {
41
+ const x = ve(c);
42
+ return !(!x?.country_code || !x.postal_code || ke(x.country_code) && !x.state);
43
+ }
44
+ function be(c, x, P) {
45
+ return c.reduce((l, f) => {
46
+ const { price: h, sale_price: I } = Ne(f, {
47
+ currencyCode: x,
48
+ currencies: P
49
+ });
50
+ return l + (I ?? h) * f.quantity;
51
+ }, 0);
52
+ }
53
+ function ze({
54
+ idPrefix: c,
55
+ title: x,
56
+ description: P,
57
+ value: l,
58
+ onChange: f
59
+ }) {
60
+ const { t: h } = qe(), I = h("company_name") === "company_name" ? "Company name" : h("company_name"), E = h("select_an_option") === "select_an_option" ? "Select an option" : h("select_an_option"), W = h("state_province") === "state_province" ? "State / Province" : h("state_province"), q = Me(l.country_code), K = ke(l.country_code);
61
+ return /* @__PURE__ */ r(Q, { children: [
62
+ /* @__PURE__ */ r(X, { children: [
63
+ /* @__PURE__ */ r(Y, { className: "flex items-center gap-2", children: [
64
+ /* @__PURE__ */ e(_t, { className: "w-5 h-5" }),
65
+ x
66
+ ] }),
67
+ /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: P })
68
+ ] }),
69
+ /* @__PURE__ */ r(V, { className: "space-y-4", children: [
70
+ /* @__PURE__ */ r("div", { className: "grid gap-4 sm:grid-cols-3", children: [
71
+ /* @__PURE__ */ r("div", { className: "space-y-2", children: [
72
+ /* @__PURE__ */ e(v, { htmlFor: `${c}-company`, children: I }),
73
+ /* @__PURE__ */ e(
74
+ j,
75
+ {
76
+ id: `${c}-company`,
77
+ value: l.company_name,
78
+ onChange: (a) => f({ ...l, company_name: a.target.value })
79
+ }
80
+ )
81
+ ] }),
82
+ /* @__PURE__ */ r("div", { className: "space-y-2", children: [
83
+ /* @__PURE__ */ e(v, { htmlFor: `${c}-name`, children: h("full_name") }),
84
+ /* @__PURE__ */ e(
85
+ j,
86
+ {
87
+ id: `${c}-name`,
88
+ value: l.recipient_name,
89
+ onChange: (a) => f({ ...l, recipient_name: a.target.value })
90
+ }
91
+ )
92
+ ] }),
93
+ /* @__PURE__ */ r("div", { className: "space-y-2", children: [
94
+ /* @__PURE__ */ e(v, { htmlFor: `${c}-country`, children: h("country") }),
95
+ /* @__PURE__ */ e(
96
+ "select",
97
+ {
98
+ id: `${c}-country`,
99
+ className: "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm",
100
+ value: l.country_code,
101
+ onChange: (a) => {
102
+ const U = a.target.value, de = Me(U);
103
+ f({
104
+ ...l,
105
+ country_code: U,
106
+ state: de.some((Z) => Z.code === l.state) ? l.state : ""
107
+ });
108
+ },
109
+ children: xt.map((a) => /* @__PURE__ */ e("option", { value: a.code, children: a.name }, a.code))
110
+ }
111
+ )
112
+ ] })
113
+ ] }),
114
+ /* @__PURE__ */ r("div", { className: "space-y-2", children: [
115
+ /* @__PURE__ */ e(v, { htmlFor: `${c}-line1`, children: h("address_line_1") }),
116
+ /* @__PURE__ */ e(
117
+ j,
118
+ {
119
+ id: `${c}-line1`,
120
+ value: l.line1,
121
+ onChange: (a) => f({ ...l, line1: a.target.value })
122
+ }
123
+ )
124
+ ] }),
125
+ /* @__PURE__ */ r("div", { className: "space-y-2", children: [
126
+ /* @__PURE__ */ e(v, { htmlFor: `${c}-line2`, children: h("address_line_2") }),
127
+ /* @__PURE__ */ e(
128
+ j,
129
+ {
130
+ id: `${c}-line2`,
131
+ value: l.line2,
132
+ onChange: (a) => f({ ...l, line2: a.target.value })
133
+ }
134
+ )
135
+ ] }),
136
+ /* @__PURE__ */ r("div", { className: "grid gap-4 sm:grid-cols-3", children: [
137
+ /* @__PURE__ */ r("div", { className: "space-y-2", children: [
138
+ /* @__PURE__ */ e(v, { htmlFor: `${c}-city`, children: h("city") }),
139
+ /* @__PURE__ */ e(
140
+ j,
141
+ {
142
+ id: `${c}-city`,
143
+ value: l.city,
144
+ onChange: (a) => f({ ...l, city: a.target.value })
145
+ }
146
+ )
147
+ ] }),
148
+ /* @__PURE__ */ r("div", { className: "space-y-2", children: [
149
+ /* @__PURE__ */ e(v, { htmlFor: `${c}-state`, children: h("state_province") }),
150
+ K ? /* @__PURE__ */ r(
151
+ "select",
152
+ {
153
+ id: `${c}-state`,
154
+ className: "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm",
155
+ value: l.state,
156
+ onChange: (a) => f({ ...l, state: a.target.value }),
157
+ children: [
158
+ /* @__PURE__ */ e("option", { value: "", children: `${E}: ${W}` }),
159
+ q.map((a) => /* @__PURE__ */ e("option", { value: a.code, children: a.name }, a.code))
160
+ ]
161
+ }
162
+ ) : /* @__PURE__ */ e(
163
+ j,
164
+ {
165
+ id: `${c}-state`,
166
+ value: l.state,
167
+ onChange: (a) => f({ ...l, state: a.target.value })
168
+ }
169
+ )
170
+ ] }),
171
+ /* @__PURE__ */ r("div", { className: "space-y-2", children: [
172
+ /* @__PURE__ */ e(v, { htmlFor: `${c}-postal`, children: h("postal_zip_code") }),
173
+ /* @__PURE__ */ e(
174
+ j,
175
+ {
176
+ id: `${c}-postal`,
177
+ value: l.postal_code,
178
+ onChange: (a) => f({ ...l, postal_code: a.target.value })
179
+ }
180
+ )
181
+ ] })
182
+ ] })
183
+ ] })
184
+ ] });
185
+ }
186
+ function Be({
187
+ title: c,
188
+ description: x,
189
+ badgeLabel: P,
190
+ children: l
191
+ }) {
192
+ return /* @__PURE__ */ r(Q, { children: [
193
+ /* @__PURE__ */ e(X, { children: /* @__PURE__ */ r("div", { className: "flex items-center justify-between gap-3 flex-wrap", children: [
194
+ /* @__PURE__ */ r("div", { children: [
195
+ /* @__PURE__ */ e(Y, { children: c }),
196
+ /* @__PURE__ */ e("p", { className: "mt-1 text-sm text-muted-foreground", children: x })
197
+ ] }),
198
+ P ? /* @__PURE__ */ e(Oe, { variant: "secondary", children: P }) : null
199
+ ] }) }),
200
+ /* @__PURE__ */ e(V, { className: "space-y-4", children: l })
201
+ ] });
202
+ }
203
+ const Wt = ({ initialCustomer: c }) => {
204
+ const [x, P] = _({}), [l, f] = _(null), [h, I] = _({}), [E, W] = _(c?.email || ""), [q, K] = _(""), [a, U] = _(c?.phone || ""), [de, Z] = _(!1), [Ke, we] = _(null), [Se, ee] = _(!1), [Ue, te] = _(!1), [J, re] = _([]), [b, B] = _(null), [C, ce] = _(null), [D, Je] = _(null), [A, Ce] = _(
205
+ () => ae(c?.billingAddress, c?.fullName)
206
+ ), [O, Fe] = _(
207
+ () => ae(
208
+ c?.shippingAddress ?? c?.billingAddress,
209
+ c?.fullName
210
+ )
211
+ ), [L, Ae] = _(
212
+ !c?.shippingAddress || vt(c?.billingAddress, c?.shippingAddress)
213
+ ), G = dt((t) => t), { t: s, lang: me } = qe(), { activeCurrencyCode: o, currencies: M } = wt(), N = G?.items ?? [], k = $(
214
+ () => N.filter((t) => !xe(t)),
215
+ [N]
216
+ ), w = $(
217
+ () => N.filter((t) => xe(t)),
218
+ [N]
219
+ ), R = c?.isAuthenticated ?? !1, n = (t, i, u) => {
220
+ const m = s(t, u);
221
+ if (m !== t)
222
+ return m;
223
+ if (!u)
224
+ return i;
225
+ let g = i;
226
+ return Object.entries(u).forEach(([p, d]) => {
227
+ g = g.replace(
228
+ new RegExp(`\\{${p}\\}`, "g"),
229
+ String(d)
230
+ );
231
+ }), g;
232
+ }, S = k.length > 0, Ge = $(
233
+ () => be(N, o, M),
234
+ [o, M, N]
235
+ ), ue = $(
236
+ () => be(k, o, M),
237
+ [o, M, k]
238
+ ), pe = $(
239
+ () => be(w, o, M),
240
+ [o, M, w]
241
+ ), he = D?.providerDiscounts.stripe ?? 0, fe = D?.providerDiscounts.freemius ?? 0, ne = Math.max(0, ue - he), He = Math.max(0, pe - fe), F = $(
242
+ () => L ? A : O,
243
+ [A, O, L]
244
+ ), z = $(
245
+ () => S ? F : A,
246
+ [A, S, F]
247
+ ), se = !S || Ft(F), le = $(
248
+ () => J.find((t) => t.id === b),
249
+ [J, b]
250
+ ), Te = $(
251
+ () => ne + (le?.amount ?? 0) + (C && !C.isPendingExternalCalculation ? C.amount : 0),
252
+ [ne, le, C]
253
+ ), Qe = Te + He;
254
+ if (ie(() => {
255
+ if (!(R || typeof window > "u"))
256
+ try {
257
+ const t = window.localStorage.getItem(oe);
258
+ if (!t)
259
+ return;
260
+ const i = JSON.parse(t);
261
+ i.email && W(i.email), i.phone && U(i.phone), i.billingAddress && Ce(ae(i.billingAddress)), i.shippingAddress && Fe(ae(i.shippingAddress)), typeof i.useBillingForShipping == "boolean" && Ae(i.useBillingForShipping), (typeof i.selectedMethodId == "string" || i.selectedMethodId === null) && B(i.selectedMethodId);
262
+ } catch (t) {
263
+ console.error("[Checkout] Failed to restore checkout draft:", t);
264
+ }
265
+ }, [R]), ie(() => {
266
+ if (!(typeof window > "u")) {
267
+ if (R) {
268
+ window.localStorage.removeItem(oe);
269
+ return;
270
+ }
271
+ window.localStorage.setItem(
272
+ oe,
273
+ JSON.stringify({
274
+ email: E,
275
+ phone: a,
276
+ billingAddress: A,
277
+ shippingAddress: O,
278
+ useBillingForShipping: L,
279
+ selectedMethodId: b
280
+ })
281
+ );
282
+ }
283
+ }, [
284
+ A,
285
+ E,
286
+ R,
287
+ a,
288
+ b,
289
+ O,
290
+ L
291
+ ]), ie(() => {
292
+ if (!S) {
293
+ re([]), B(null), ee(!1);
294
+ return;
295
+ }
296
+ if (!se) {
297
+ re([]), B(null), ee(!1);
298
+ return;
299
+ }
300
+ let t = !1;
301
+ const u = setTimeout(async () => {
302
+ if (!F.country_code)
303
+ return;
304
+ ee(!0);
305
+ const m = await bt(
306
+ ne,
307
+ {
308
+ country: F.country_code,
309
+ state: F.state,
310
+ postal_code: F.postal_code
311
+ },
312
+ me,
313
+ o
314
+ );
315
+ t || (m.success && m.methods ? (re(m.methods), m.methods.length > 0 && (!b || !m.methods.find((g) => g.id === b)) && B(m.methods[0].id)) : (re([]), B(null)), ee(!1));
316
+ }, 400);
317
+ return () => {
318
+ t = !0, clearTimeout(u);
319
+ };
320
+ }, [
321
+ o,
322
+ S,
323
+ se,
324
+ me,
325
+ b,
326
+ F.country_code,
327
+ F.postal_code,
328
+ F.state,
329
+ ne
330
+ ]), ie(() => {
331
+ const i = setTimeout(async () => {
332
+ if (!S || !z.country_code) {
333
+ te(!1), ce(null);
334
+ return;
335
+ }
336
+ if (ke(z.country_code) && !z.state) {
337
+ te(!1), ce(null);
338
+ return;
339
+ }
340
+ te(!0);
341
+ const u = await Nt(
342
+ k,
343
+ {
344
+ country_code: z.country_code,
345
+ state: z.state
346
+ },
347
+ o,
348
+ D?.code ?? null,
349
+ N
350
+ );
351
+ u.success && u.tax ? ce(u.tax) : ce(null), te(!1);
352
+ }, 300);
353
+ return () => clearTimeout(i);
354
+ }, [
355
+ o,
356
+ S,
357
+ k,
358
+ z.country_code,
359
+ z.state,
360
+ D?.code,
361
+ N
362
+ ]), !G)
363
+ return null;
364
+ const $e = () => {
365
+ Z(!1), we(null);
366
+ }, je = de ? /* @__PURE__ */ e(
367
+ "div",
368
+ {
369
+ className: "fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",
370
+ onClick: $e,
371
+ children: /* @__PURE__ */ r(
372
+ "div",
373
+ {
374
+ className: "relative bg-background border rounded-xl shadow-2xl p-8 max-w-md mx-4",
375
+ onClick: (t) => t.stopPropagation(),
376
+ children: [
377
+ /* @__PURE__ */ e(
378
+ "button",
379
+ {
380
+ onClick: $e,
381
+ className: "absolute top-4 right-4 text-muted-foreground hover:text-foreground transition-colors",
382
+ children: /* @__PURE__ */ e(mt, { className: "w-5 h-5" })
383
+ }
384
+ ),
385
+ /* @__PURE__ */ r("div", { className: "flex items-center gap-3 mb-4", children: [
386
+ /* @__PURE__ */ e("div", { className: "p-2 rounded-full bg-amber-100 dark:bg-amber-900/20", children: /* @__PURE__ */ e(ut, { className: "h-6 w-6 text-amber-600 dark:text-amber-400" }) }),
387
+ /* @__PURE__ */ e("h2", { className: "text-xl font-semibold", children: s("ecommerce.checkout_successful") })
388
+ ] }),
389
+ /* @__PURE__ */ e("p", { className: "text-muted-foreground mb-2", children: s("ecommerce.sandbox_notice") }),
390
+ /* @__PURE__ */ e("p", { className: "text-muted-foreground mb-2", children: Ke === "stripe" ? n(
391
+ "ecommerce.sandbox_checkout_stripe_description",
392
+ "This simulated step represents the Stripe checkout for physical products."
393
+ ) : n(
394
+ "ecommerce.sandbox_checkout_freemius_description",
395
+ "This simulated step represents the Freemius checkout for digital products."
396
+ ) }),
397
+ /* @__PURE__ */ e("p", { className: "text-muted-foreground mb-6", children: s("ecommerce.license_notice") }),
398
+ /* @__PURE__ */ e(
399
+ "a",
400
+ {
401
+ href: "https://nextblock.ca",
402
+ target: "_blank",
403
+ rel: "noopener noreferrer",
404
+ className: "block w-full text-center py-3 px-4 rounded-lg bg-primary text-primary-foreground font-semibold hover:opacity-90 transition-opacity",
405
+ children: s("ecommerce.purchase_at")
406
+ }
407
+ )
408
+ ]
409
+ }
410
+ )
411
+ }
412
+ ) : null, Xe = (t) => {
413
+ if (!R && (!E || !/^\S+@\S+\.\S+$/.test(E)))
414
+ return K(s("ecommerce.invalid_email")), null;
415
+ const i = ve(A);
416
+ if (!Le(i))
417
+ return alert(s("checkout_complete_billing_address")), null;
418
+ const u = S ? ve(L ? A : O) : null;
419
+ if (t === "stripe") {
420
+ if (!Le(u))
421
+ return alert(s("checkout_complete_shipping_address")), null;
422
+ if (!b)
423
+ return alert(
424
+ n(
425
+ "ecommerce.shipping_method_required",
426
+ "Please select a shipping method before continuing."
427
+ )
428
+ ), null;
429
+ }
430
+ return K(""), {
431
+ normalizedBillingAddress: i,
432
+ normalizedShippingAddress: u
433
+ };
434
+ }, Pe = async (t, i, u) => {
435
+ I((g) => ({
436
+ ...g,
437
+ [t]: ""
438
+ }));
439
+ const m = Xe(t);
440
+ if (m) {
441
+ if (Ct) {
442
+ const g = new Set(i.map((d) => d.id)), p = N.filter((d) => !g.has(d.id));
443
+ G.setItems(p), p.length === 0 && G.removeCoupon(), we(t), Z(!0), typeof window < "u" && p.length === 0 && window.localStorage.removeItem(oe);
444
+ return;
445
+ }
446
+ f(u);
447
+ try {
448
+ const g = await fetch("/api/checkout", {
449
+ method: "POST",
450
+ headers: { "Content-Type": "application/json" },
451
+ body: JSON.stringify({
452
+ items: i,
453
+ customerEmail: R ? void 0 : E,
454
+ customerPhone: a || null,
455
+ billingAddress: m.normalizedBillingAddress,
456
+ shippingAddress: t === "stripe" ? m.normalizedShippingAddress : null,
457
+ shippingMethodId: t === "stripe" ? b : null,
458
+ locale: me,
459
+ currencyCode: o,
460
+ couponCode: D?.code ?? G.appliedCoupon?.code ?? null,
461
+ couponContextItems: N
462
+ })
463
+ }), p = await g.json();
464
+ if (!g.ok) {
465
+ const d = p?.errorKey && typeof p.errorKey == "string" ? n(
466
+ p.errorKey,
467
+ p?.error || n("ecommerce.generic_error", "Something went wrong."),
468
+ p.errorParams
469
+ ) : p?.error || s("ecommerce.generic_error");
470
+ I((H) => ({
471
+ ...H,
472
+ [t]: d
473
+ })), f(null);
474
+ return;
475
+ }
476
+ if (p.customProps && p.customProps.provider === "freemius") {
477
+ const d = p.customProps;
478
+ let H = null;
479
+ const tt = () => {
480
+ window.location.href = `/checkout/success?session_id=${d.order_id}`;
481
+ }, Ie = (T) => (H || (H = fetch("/api/checkout/freemius/sync", {
482
+ method: "POST",
483
+ headers: { "Content-Type": "application/json" },
484
+ body: JSON.stringify({
485
+ orderId: d.order_id,
486
+ checkoutResponse: T
487
+ })
488
+ }).then(async (Ee) => {
489
+ if (!Ee.ok) {
490
+ const nt = await Ee.json().catch(() => null);
491
+ console.error("Freemius checkout sync failed:", nt);
492
+ }
493
+ })), H), rt = {
494
+ product_id: d.plugin_id,
495
+ public_key: d.public_key,
496
+ sandbox: d.sandbox
497
+ }, ct = {
498
+ name: s("ecommerce.checkout_overlay_title"),
499
+ plan_id: d.plan_id,
500
+ ...d.billing_cycle ? { billing_cycle: d.billing_cycle } : {},
501
+ ...d.trial ? { trial: d.trial } : {},
502
+ ...d.coupon ? { coupon: d.coupon } : {},
503
+ user_email: d.user_email,
504
+ user_firstname: d.user_firstname,
505
+ user_lastname: d.user_lastname,
506
+ sandbox: d.sandbox,
507
+ purchaseCompleted: function(T) {
508
+ Ie(T);
509
+ },
510
+ success: function(T) {
511
+ (async () => {
512
+ try {
513
+ await Ie(T);
514
+ } finally {
515
+ tt();
516
+ }
517
+ })();
518
+ }
519
+ };
520
+ try {
521
+ new at(rt).open(ct), f(null);
522
+ } catch (T) {
523
+ alert(
524
+ s("ecommerce.checkout_popup_blocked") + " " + (T.message || String(T))
525
+ ), p.url && (window.location.href = p.url), f(null);
526
+ }
527
+ } else p.url ? window.location.href = p.url : (I((d) => ({
528
+ ...d,
529
+ [t]: s("ecommerce.checkout_failed") + (p.error || n("ecommerce.unknown_error", "Unknown error"))
530
+ })), f(null));
531
+ } catch (g) {
532
+ console.error(g), I((p) => ({
533
+ ...p,
534
+ [t]: s("ecommerce.generic_error")
535
+ })), f(null);
536
+ }
537
+ }
538
+ };
539
+ if (N.length === 0)
540
+ return /* @__PURE__ */ r(st, { children: [
541
+ je,
542
+ /* @__PURE__ */ r("div", { className: "container mx-auto flex min-h-[50vh] flex-col items-center justify-center p-8 text-center", children: [
543
+ /* @__PURE__ */ e("h1", { className: "mb-4 text-2xl font-bold", children: s("ecommerce.cart_empty") }),
544
+ /* @__PURE__ */ e("p", { className: "mb-8 text-muted-foreground", children: s("ecommerce.cart_empty_description") }),
545
+ /* @__PURE__ */ e(_e, { asChild: !0, children: /* @__PURE__ */ e("a", { href: "/shop", children: s("ecommerce.go_to_shop") }) })
546
+ ] })
547
+ ] });
548
+ const ge = S ? se ? Se ? n(
549
+ "ecommerce.calculating_shipping",
550
+ "Calculating shipping..."
551
+ ) : b ? null : J.length > 0 ? s("ecommerce.select_rate") : s("ecommerce.no_rates_for_region") : n(
552
+ "ecommerce.waiting_on_address_info",
553
+ "Complete your shipping address to view available shipping options."
554
+ ) : null, Ye = l !== null || ge !== null, Ve = k.length === 1 ? n("ecommerce.item_count_one", "{count} item", {
555
+ count: k.length
556
+ }) : n("ecommerce.item_count_other", "{count} items", {
557
+ count: k.length
558
+ }), We = w.length === 1 ? n("ecommerce.license_count_one", "{count} license", {
559
+ count: w.length
560
+ }) : n("ecommerce.license_count_other", "{count} licenses", {
561
+ count: w.length
562
+ }), Ze = (t) => xe(t) ? n("ecommerce.digital_label", "Digital") : n("ecommerce.physical_label", "Physical"), et = (t) => t === "monthly" ? n(
563
+ "ecommerce.checkout_billing_cycle_monthly",
564
+ "Monthly subscription"
565
+ ) : t === "annual" ? n(
566
+ "ecommerce.checkout_billing_cycle_annual",
567
+ "Annual subscription"
568
+ ) : t === "lifetime" ? n(
569
+ "ecommerce.checkout_billing_cycle_lifetime",
570
+ "Lifetime subscription"
571
+ ) : null;
572
+ return /* @__PURE__ */ r("div", { className: "container mx-auto px-4 py-12 md:px-6", children: [
573
+ je,
574
+ /* @__PURE__ */ r("div", { className: "mx-auto max-w-6xl", children: [
575
+ /* @__PURE__ */ e("h1", { className: "mb-8 text-3xl font-bold", children: s("ecommerce.checkout") }),
576
+ /* @__PURE__ */ r("div", { className: "grid gap-8 lg:grid-cols-12 lg:items-start", children: [
577
+ /* @__PURE__ */ r("div", { className: "lg:col-span-8 space-y-6", children: [
578
+ /* @__PURE__ */ r(Q, { children: [
579
+ /* @__PURE__ */ e(X, { children: /* @__PURE__ */ r(Y, { className: "flex items-center gap-2", children: [
580
+ /* @__PURE__ */ e(pt, { className: "w-5 h-5" }),
581
+ s("ecommerce.contact_information")
582
+ ] }) }),
583
+ /* @__PURE__ */ r(V, { className: "space-y-4", children: [
584
+ R ? /* @__PURE__ */ e("div", { className: "rounded-xl border bg-muted/20 p-4 text-sm text-muted-foreground", children: s("checkout_prefill_notice", { email: c?.email || "" }) }) : /* @__PURE__ */ r("div", { className: "space-y-2", children: [
585
+ /* @__PURE__ */ r(v, { htmlFor: "checkout-email", children: [
586
+ s("ecommerce.email_address"),
587
+ " ",
588
+ /* @__PURE__ */ e("span", { className: "text-destructive", children: "*" })
589
+ ] }),
590
+ /* @__PURE__ */ e(
591
+ j,
592
+ {
593
+ id: "checkout-email",
594
+ type: "email",
595
+ placeholder: s("ecommerce.email_placeholder"),
596
+ value: E,
597
+ onChange: (t) => {
598
+ W(t.target.value), q && K("");
599
+ },
600
+ required: !0
601
+ }
602
+ ),
603
+ q ? /* @__PURE__ */ e("p", { className: "text-xs text-destructive mt-1", children: q }) : null
604
+ ] }),
605
+ /* @__PURE__ */ r("div", { className: "space-y-2", children: [
606
+ /* @__PURE__ */ e(v, { htmlFor: "checkout-phone", children: s("phone_number") }),
607
+ /* @__PURE__ */ e(
608
+ j,
609
+ {
610
+ id: "checkout-phone",
611
+ placeholder: s("optional"),
612
+ value: a,
613
+ onChange: (t) => U(t.target.value)
614
+ }
615
+ )
616
+ ] })
617
+ ] })
618
+ ] }),
619
+ /* @__PURE__ */ e(
620
+ ze,
621
+ {
622
+ idPrefix: "billing",
623
+ title: s("billing_address"),
624
+ description: s("checkout_billing_address_help"),
625
+ value: A,
626
+ onChange: Ce
627
+ }
628
+ ),
629
+ S ? /* @__PURE__ */ r("div", { className: "flex items-center space-x-3 rounded-xl border bg-muted/20 p-4", children: [
630
+ /* @__PURE__ */ e(
631
+ lt,
632
+ {
633
+ id: "use-billing-for-shipping",
634
+ checked: L,
635
+ onCheckedChange: (t) => Ae(!!t)
636
+ }
637
+ ),
638
+ /* @__PURE__ */ r("div", { className: "space-y-1", children: [
639
+ /* @__PURE__ */ e(v, { htmlFor: "use-billing-for-shipping", className: "cursor-pointer", children: s("use_billing_for_shipping") }),
640
+ /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: s("checkout_use_billing_for_shipping_help") })
641
+ ] })
642
+ ] }) : null,
643
+ S && !L ? /* @__PURE__ */ e(
644
+ ze,
645
+ {
646
+ idPrefix: "shipping",
647
+ title: s("shipping_address"),
648
+ description: s("checkout_shipping_address_help"),
649
+ value: O,
650
+ onChange: Fe
651
+ }
652
+ ) : null,
653
+ S ? /* @__PURE__ */ r(Q, { children: [
654
+ /* @__PURE__ */ e(X, { children: /* @__PURE__ */ r(Y, { className: "flex items-center gap-2", children: [
655
+ /* @__PURE__ */ e(ht, { className: "w-5 h-5 text-primary" }),
656
+ s("ecommerce.shipping_method")
657
+ ] }) }),
658
+ /* @__PURE__ */ e(V, { children: Se ? /* @__PURE__ */ e("div", { className: "flex items-center justify-center py-6", children: /* @__PURE__ */ e(ye, { className: "w-6 h-6 animate-spin text-muted-foreground" }) }) : J.length > 0 ? /* @__PURE__ */ e("div", { className: "space-y-3", children: J.map((t) => /* @__PURE__ */ r(
659
+ "div",
660
+ {
661
+ onClick: () => B(t.id),
662
+ className: `flex items-center justify-between p-4 rounded-lg border-2 cursor-pointer transition-all ${b === t.id ? "border-primary bg-primary/5" : "border-neutral-100 hover:border-neutral-200"}`,
663
+ children: [
664
+ /* @__PURE__ */ r("div", { className: "flex items-center gap-3", children: [
665
+ /* @__PURE__ */ e(
666
+ "div",
667
+ {
668
+ className: `w-4 h-4 rounded-full border flex items-center justify-center ${b === t.id ? "border-primary" : "border-neutral-300"}`,
669
+ children: b === t.id ? /* @__PURE__ */ e("div", { className: "w-2 h-2 rounded-full bg-primary" }) : null
670
+ }
671
+ ),
672
+ /* @__PURE__ */ e("span", { className: "font-medium", children: t.name })
673
+ ] }),
674
+ /* @__PURE__ */ e("span", { className: "font-bold", children: y(t.amount, o) })
675
+ ]
676
+ },
677
+ t.id
678
+ )) }) : /* @__PURE__ */ e("div", { className: "py-4 text-center text-muted-foreground bg-muted/30 rounded-lg italic", children: se ? s("ecommerce.no_rates_for_region") : n(
679
+ "ecommerce.waiting_on_address_info",
680
+ "Complete your shipping address to view available shipping options."
681
+ ) }) })
682
+ ] }) : null
683
+ ] }),
684
+ /* @__PURE__ */ r("div", { className: "lg:col-span-4 space-y-6", children: [
685
+ /* @__PURE__ */ r(Q, { className: "top-6", children: [
686
+ /* @__PURE__ */ e(X, { children: /* @__PURE__ */ e(Y, { children: s("ecommerce.order_summary") }) }),
687
+ /* @__PURE__ */ r(V, { className: "space-y-4", children: [
688
+ /* @__PURE__ */ e("div", { className: "space-y-3 max-h-[260px] overflow-y-auto pr-2", children: N.map((t) => {
689
+ const i = Ne(t, {
690
+ currencyCode: o,
691
+ currencies: M
692
+ }), u = Re(t);
693
+ return /* @__PURE__ */ r("div", { className: "flex items-start justify-between gap-4", children: [
694
+ /* @__PURE__ */ r("div", { className: "flex gap-3", children: [
695
+ t.image_url ? /* @__PURE__ */ e("div", { className: "h-10 w-10 shrink-0 overflow-hidden rounded border bg-neutral-100", children: /* @__PURE__ */ e("img", { src: t.image_url, alt: t.title, className: "h-full w-full object-cover" }) }) : null,
696
+ /* @__PURE__ */ r("div", { className: "grid gap-0.5", children: [
697
+ /* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
698
+ /* @__PURE__ */ e("span", { className: "font-medium text-xs line-clamp-1", children: t.title }),
699
+ /* @__PURE__ */ e(Oe, { variant: "outline", className: "text-[9px] uppercase", children: Ze(t) })
700
+ ] }),
701
+ t.variant_label ? /* @__PURE__ */ e("span", { className: "text-[10px] text-muted-foreground line-clamp-1", children: t.variant_label }) : null,
702
+ /* @__PURE__ */ r("span", { className: "text-[10px] text-muted-foreground", children: [
703
+ s("ecommerce.qty"),
704
+ ": ",
705
+ t.quantity
706
+ ] }),
707
+ u ? /* @__PURE__ */ r("span", { className: "text-[10px] font-medium text-emerald-700", children: [
708
+ u.label,
709
+ " - ",
710
+ u.paymentRequirementLabel
711
+ ] }) : null
712
+ ] })
713
+ ] }),
714
+ /* @__PURE__ */ r("div", { className: "flex flex-col items-end gap-0.5 shrink-0", children: [
715
+ /* @__PURE__ */ e("span", { className: "font-medium text-xs", children: y(
716
+ (i.sale_price ?? i.price) * t.quantity,
717
+ o
718
+ ) }),
719
+ i.sale_price ? /* @__PURE__ */ e("span", { className: "text-[9px] text-muted-foreground line-through", children: y(i.price * t.quantity, o) }) : null
720
+ ] })
721
+ ] }, `${t.id}-${t.variant_id || "base"}`);
722
+ }) }),
723
+ /* @__PURE__ */ e(it, {}),
724
+ /* @__PURE__ */ e(
725
+ St,
726
+ {
727
+ items: N,
728
+ currencyCode: o,
729
+ onQuoteChange: Je
730
+ }
731
+ ),
732
+ /* @__PURE__ */ r("div", { className: "space-y-2 text-sm", children: [
733
+ /* @__PURE__ */ r("div", { className: "flex justify-between", children: [
734
+ /* @__PURE__ */ e("span", { children: s("ecommerce.subtotal") }),
735
+ /* @__PURE__ */ e("span", { children: y(Ge, o) })
736
+ ] }),
737
+ k.length > 0 ? /* @__PURE__ */ r("div", { className: "flex justify-between text-muted-foreground", children: [
738
+ /* @__PURE__ */ e("span", { children: n(
739
+ "ecommerce.physical_products",
740
+ "Physical products"
741
+ ) }),
742
+ /* @__PURE__ */ e("span", { children: y(ue, o) })
743
+ ] }) : null,
744
+ w.length > 0 ? /* @__PURE__ */ r("div", { className: "flex justify-between text-muted-foreground", children: [
745
+ /* @__PURE__ */ e("span", { children: n(
746
+ "ecommerce.digital_products",
747
+ "Digital products"
748
+ ) }),
749
+ /* @__PURE__ */ e("span", { children: y(pe, o) })
750
+ ] }) : null,
751
+ D ? /* @__PURE__ */ r("div", { className: "flex justify-between text-emerald-600", children: [
752
+ /* @__PURE__ */ r("span", { children: [
753
+ n("ecommerce.discount", "Discount"),
754
+ " (",
755
+ D.code,
756
+ ")"
757
+ ] }),
758
+ /* @__PURE__ */ r("span", { children: [
759
+ "-",
760
+ y(D.discountTotal, o)
761
+ ] })
762
+ ] }) : null,
763
+ (k.length > 0 || w.length > 0) && /* @__PURE__ */ r("div", { className: "flex justify-between font-bold text-lg pt-2 border-t mt-2", children: [
764
+ /* @__PURE__ */ e("span", { children: n(
765
+ "ecommerce.estimated_total",
766
+ "Estimated total"
767
+ ) }),
768
+ /* @__PURE__ */ e("span", { className: "text-primary", children: y(Qe, o) })
769
+ ] })
770
+ ] })
771
+ ] })
772
+ ] }),
773
+ k.length > 0 ? /* @__PURE__ */ r(
774
+ Be,
775
+ {
776
+ title: n(
777
+ "ecommerce.stripe_checkout_title",
778
+ "Stripe Checkout"
779
+ ),
780
+ description: n(
781
+ "ecommerce.stripe_checkout_description",
782
+ "Pay for physical products in one Stripe checkout session."
783
+ ),
784
+ badgeLabel: Ve,
785
+ children: [
786
+ /* @__PURE__ */ r("div", { className: "space-y-2 text-sm", children: [
787
+ /* @__PURE__ */ r("div", { className: "flex justify-between", children: [
788
+ /* @__PURE__ */ e("span", { children: n(
789
+ "ecommerce.physical_subtotal",
790
+ "Physical subtotal"
791
+ ) }),
792
+ /* @__PURE__ */ e("span", { children: y(ue, o) })
793
+ ] }),
794
+ he > 0 ? /* @__PURE__ */ r("div", { className: "flex justify-between text-emerald-600", children: [
795
+ /* @__PURE__ */ e("span", { children: n("ecommerce.discount", "Discount") }),
796
+ /* @__PURE__ */ r("span", { children: [
797
+ "-",
798
+ y(he, o)
799
+ ] })
800
+ ] }) : null,
801
+ /* @__PURE__ */ r("div", { className: "flex justify-between", children: [
802
+ /* @__PURE__ */ e("span", { children: s("ecommerce.shipping") }),
803
+ /* @__PURE__ */ e("span", { children: le ? y(le.amount, o) : "-" })
804
+ ] }),
805
+ /* @__PURE__ */ r("div", { className: "flex justify-between", children: [
806
+ /* @__PURE__ */ e("span", { children: n("ecommerce.tax", "Tax") }),
807
+ /* @__PURE__ */ e("span", { children: Ue ? "..." : C?.isPendingExternalCalculation ? n(
808
+ "ecommerce.tax_calculated_on_stripe",
809
+ "Calculated on Stripe"
810
+ ) : C ? y(C.amount, o) : "-" })
811
+ ] }),
812
+ C && C.lines.length > 0 ? /* @__PURE__ */ e("div", { className: "rounded-lg bg-muted/20 px-3 py-2 text-xs text-muted-foreground", children: C.lines.map((t) => /* @__PURE__ */ r("div", { className: "flex justify-between gap-3", children: [
813
+ /* @__PURE__ */ r("span", { children: [
814
+ t.name,
815
+ " (",
816
+ t.rate.toFixed(4),
817
+ "%)"
818
+ ] }),
819
+ /* @__PURE__ */ e("span", { children: y(t.amount, o) })
820
+ ] }, t.id || `${t.name}-${t.rate}`)) }) : null,
821
+ /* @__PURE__ */ r("div", { className: "flex justify-between font-semibold pt-2 border-t", children: [
822
+ /* @__PURE__ */ e("span", { children: n(
823
+ "ecommerce.total_on_stripe",
824
+ "Total on Stripe"
825
+ ) }),
826
+ /* @__PURE__ */ e("span", { children: y(Te, o) })
827
+ ] })
828
+ ] }),
829
+ /* @__PURE__ */ r(
830
+ _e,
831
+ {
832
+ className: "w-full",
833
+ size: "lg",
834
+ onClick: () => Pe("stripe", k, "stripe"),
835
+ disabled: Ye,
836
+ children: [
837
+ l === "stripe" ? /* @__PURE__ */ e(ye, { className: "mr-2 h-4 w-4 animate-spin" }) : /* @__PURE__ */ e(ft, { className: "mr-2 h-4 w-4" }),
838
+ l === "stripe" ? s("ecommerce.processing") : n(
839
+ "ecommerce.checkout_physical_products",
840
+ "Checkout Physical Products"
841
+ )
842
+ ]
843
+ }
844
+ ),
845
+ ge && l === null ? /* @__PURE__ */ e("p", { className: "text-[11px] text-muted-foreground", children: ge }) : null,
846
+ h.stripe ? /* @__PURE__ */ e("div", { className: "rounded-lg border border-destructive/20 bg-destructive/10 px-3 py-2 text-xs text-destructive", children: h.stripe }) : null,
847
+ /* @__PURE__ */ e("p", { className: "text-[11px] text-muted-foreground", children: C?.isPendingExternalCalculation ? n(
848
+ "checkout_stripe_tax_finalized_notice",
849
+ "Tax will be finalized by Stripe Tax on the payment step."
850
+ ) : n(
851
+ "ecommerce.shipping_taxes_collected_on_stripe",
852
+ "Shipping and taxes are only collected during the Stripe step for physical products."
853
+ ) })
854
+ ]
855
+ }
856
+ ) : null,
857
+ w.length > 0 ? /* @__PURE__ */ r(
858
+ Be,
859
+ {
860
+ title: n(
861
+ "ecommerce.freemius_checkout_title",
862
+ "Freemius Checkout"
863
+ ),
864
+ description: n(
865
+ "ecommerce.freemius_checkout_description",
866
+ "Digital products use the Freemius checkout flow."
867
+ ),
868
+ badgeLabel: We,
869
+ children: [
870
+ /* @__PURE__ */ e("div", { className: "space-y-3", children: w.map((t) => {
871
+ const i = Ne(t, {
872
+ currencyCode: o,
873
+ currencies: M
874
+ }), u = Re(t), m = `freemius:${t.id}`, g = u ? x[m] || "paid" : void 0;
875
+ return /* @__PURE__ */ r("div", { className: "rounded-lg border p-3 space-y-3", children: [
876
+ /* @__PURE__ */ r("div", { className: "flex items-start justify-between gap-3", children: [
877
+ /* @__PURE__ */ r("div", { children: [
878
+ /* @__PURE__ */ e("p", { className: "font-medium", children: t.title }),
879
+ t.billing_cycle ? /* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground capitalize", children: et(t.billing_cycle) }) : null,
880
+ u ? /* @__PURE__ */ r("p", { className: "text-xs font-medium text-emerald-700", children: [
881
+ u.label,
882
+ " - ",
883
+ u.paymentRequirementLabel
884
+ ] }) : null
885
+ ] }),
886
+ /* @__PURE__ */ e("span", { className: "font-medium", children: y(i.sale_price ?? i.price, o) })
887
+ ] }),
888
+ u && !t.trial_requires_payment_method && /* @__PURE__ */ r("div", { className: "bg-muted/30 p-3 rounded-md border text-sm mt-2 mb-3", children: [
889
+ /* @__PURE__ */ e("p", { className: "font-medium mb-3", children: n(
890
+ "ecommerce.freemius_trial_preference_title",
891
+ "How would you like to start your trial?"
892
+ ) }),
893
+ /* @__PURE__ */ r(
894
+ ot,
895
+ {
896
+ value: x[m] || "paid",
897
+ onValueChange: (p) => P((d) => ({ ...d, [m]: p })),
898
+ className: "gap-3",
899
+ children: [
900
+ /* @__PURE__ */ r("div", { className: "flex items-start space-x-3", children: [
901
+ /* @__PURE__ */ e(De, { value: "paid", id: `${m}-paid`, className: "mt-1" }),
902
+ /* @__PURE__ */ r("div", { className: "grid gap-1.5", children: [
903
+ /* @__PURE__ */ e(v, { htmlFor: `${m}-paid`, className: "font-medium leading-none cursor-pointer", children: n(
904
+ "ecommerce.freemius_trial_with_card",
905
+ "Enter Payment Details Now (Still get full trial length free)"
906
+ ) }),
907
+ /* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground", children: n(
908
+ "ecommerce.freemius_trial_with_card_help",
909
+ "You will not be billed until the trial ends. Cancel anytime."
910
+ ) })
911
+ ] })
912
+ ] }),
913
+ /* @__PURE__ */ r("div", { className: "flex items-start space-x-3", children: [
914
+ /* @__PURE__ */ e(De, { value: "free", id: `${m}-free`, className: "mt-1" }),
915
+ /* @__PURE__ */ e("div", { className: "grid gap-1.5", children: /* @__PURE__ */ e(v, { htmlFor: `${m}-free`, className: "font-medium leading-none cursor-pointer", children: n(
916
+ "ecommerce.freemius_trial_no_card",
917
+ "Start Free Trial (No card required)"
918
+ ) }) })
919
+ ] })
920
+ ]
921
+ }
922
+ )
923
+ ] }),
924
+ /* @__PURE__ */ r(
925
+ _e,
926
+ {
927
+ className: "w-full h-auto min-h-[2.75rem] py-2",
928
+ variant: w.length > 1 ? "outline" : "default",
929
+ onClick: () => Pe(
930
+ "freemius",
931
+ [
932
+ {
933
+ ...t,
934
+ ...g ? { trial_preference: g } : {}
935
+ }
936
+ ],
937
+ m
938
+ ),
939
+ disabled: l !== null,
940
+ children: [
941
+ l === m ? /* @__PURE__ */ e(ye, { className: "mr-2 h-4 w-4 shrink-0 animate-spin" }) : /* @__PURE__ */ e(gt, { className: "mr-2 h-4 w-4 shrink-0" }),
942
+ /* @__PURE__ */ e("span", { className: "whitespace-normal text-left", children: l === m ? s("ecommerce.processing") : w.length > 1 ? n(
943
+ "ecommerce.checkout_product",
944
+ "Checkout {title}",
945
+ { title: t.title }
946
+ ) : n(
947
+ "ecommerce.checkout_digital_product",
948
+ "Checkout Digital Product"
949
+ ) })
950
+ ]
951
+ }
952
+ )
953
+ ] }, m);
954
+ }) }),
955
+ /* @__PURE__ */ r("div", { className: "flex justify-between text-sm font-semibold border-t pt-3", children: [
956
+ /* @__PURE__ */ e("span", { children: n(
957
+ "ecommerce.digital_subtotal",
958
+ "Digital subtotal"
959
+ ) }),
960
+ /* @__PURE__ */ e("span", { children: y(pe, o) })
961
+ ] }),
962
+ fe > 0 ? /* @__PURE__ */ r("div", { className: "flex justify-between text-sm font-semibold text-emerald-600", children: [
963
+ /* @__PURE__ */ e("span", { children: n("ecommerce.discount", "Discount") }),
964
+ /* @__PURE__ */ r("span", { children: [
965
+ "-",
966
+ y(fe, o)
967
+ ] })
968
+ ] }) : null,
969
+ h.freemius ? /* @__PURE__ */ e("div", { className: "rounded-lg border border-destructive/20 bg-destructive/10 px-3 py-2 text-xs text-destructive", children: h.freemius }) : null,
970
+ /* @__PURE__ */ e("p", { className: "text-[11px] text-muted-foreground", children: w.length > 1 ? n(
971
+ "ecommerce.freemius_multi_checkout_notice",
972
+ "Freemius licenses are completed one at a time, so each digital product gets its own checkout action."
973
+ ) : n(
974
+ "ecommerce.freemius_tax_notice",
975
+ "Taxes and compliance for digital products are handled inside the Freemius checkout."
976
+ ) })
977
+ ]
978
+ }
979
+ ) : null
980
+ ] })
981
+ ] })
982
+ ] })
983
+ ] });
984
+ };
985
+ export {
986
+ Wt as Checkout
987
+ };