@nextblock-cms/ecom 0.8.6 → 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 (277) hide show
  1. package/index.cjs.js +1 -1
  2. package/index.es.js +136 -533
  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/{cart-store.es.js → lib/cart-store.es.js} +13 -13
  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/{AddToCartButton-ffE0DhHu.js → lib/components/AddToCartButton.es.js} +14 -13
  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/{components → lib/components}/CartDrawer.es.js +15 -14
  15. package/{components → lib/components}/CartIcon.cjs.js +1 -1
  16. package/{components → lib/components}/CartIcon.es.js +1 -0
  17. package/lib/components/Checkout.cjs.js +1 -0
  18. package/{components → lib/components}/Checkout.es.js +330 -363
  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/{components → lib/components}/CurrencySwitcher.es.js +5 -4
  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/{components → lib/components}/FeaturedProduct.es.js +9 -8
  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/SubscriptionSelector.cjs.js +1 -0
  42. package/lib/components/SubscriptionSelector.es.js +140 -0
  43. package/lib/countries.cjs.js +1 -0
  44. package/lib/countries.es.js +77 -0
  45. package/lib/coupon-server.cjs.js +1 -0
  46. package/{coupon-server-DUKVtyYs.js → lib/coupon-server.es.js} +68 -82
  47. package/lib/coupons.cjs.js +1 -0
  48. package/lib/coupons.es.js +17 -0
  49. package/lib/currency-store.cjs.js +1 -0
  50. package/lib/currency-store.es.js +27 -0
  51. package/lib/currency-sync.cjs.js +1 -0
  52. package/lib/currency-sync.es.js +180 -0
  53. package/lib/customer-addresses.cjs.js +1 -0
  54. package/lib/customer-addresses.es.js +116 -0
  55. package/lib/customer-orders.cjs.js +1 -0
  56. package/lib/customer-orders.es.js +45 -0
  57. package/lib/customer.cjs.js +1 -0
  58. package/{customer-C3xccjUg.js → lib/customer.es.js} +15 -14
  59. package/lib/export-helpers.cjs.js +1 -0
  60. package/lib/export-helpers.es.js +56 -0
  61. package/lib/factory.cjs.js +1 -0
  62. package/lib/factory.es.js +8 -0
  63. package/lib/freemius-coupons.cjs.js +1 -0
  64. package/lib/freemius-coupons.es.js +272 -0
  65. package/lib/freemius-order-sync.cjs.js +1 -0
  66. package/lib/freemius-order-sync.es.js +284 -0
  67. package/lib/inventory-settings.cjs.js +1 -0
  68. package/lib/inventory-settings.es.js +86 -0
  69. package/lib/invoice-server.cjs.js +33 -0
  70. package/lib/invoice-server.es.js +141 -0
  71. package/lib/invoice-ui.cjs.js +1 -0
  72. package/lib/invoice-ui.es.js +71 -0
  73. package/lib/invoice.cjs.js +1 -0
  74. package/lib/invoice.es.js +102 -0
  75. package/lib/order-inventory.cjs.js +61 -0
  76. package/lib/order-inventory.es.js +128 -0
  77. package/lib/order-tax-details.cjs.js +1 -0
  78. package/lib/order-tax-details.es.js +164 -0
  79. package/lib/pages/cms/coupons/CouponEditorForm.cjs.js +1 -0
  80. package/lib/pages/cms/coupons/CouponEditorForm.es.js +189 -0
  81. package/lib/pages/cms/coupons/CouponsPage.cjs.js +5 -0
  82. package/lib/pages/cms/coupons/CouponsPage.es.js +171 -0
  83. package/lib/pages/cms/coupons/CreateCouponDialog.cjs.js +1 -0
  84. package/lib/pages/cms/coupons/CreateCouponDialog.es.js +35 -0
  85. package/lib/pages/cms/coupons/EditCouponPage.cjs.js +1 -0
  86. package/lib/pages/cms/coupons/EditCouponPage.es.js +48 -0
  87. package/lib/pages/cms/coupons/ProductScopePicker.cjs.js +1 -0
  88. package/lib/pages/cms/coupons/ProductScopePicker.es.js +120 -0
  89. package/lib/pages/cms/coupons/actions.cjs.js +1 -0
  90. package/lib/pages/cms/coupons/actions.es.js +128 -0
  91. package/lib/pages/cms/coupons/product-options.cjs.js +1 -0
  92. package/lib/pages/cms/coupons/product-options.es.js +27 -0
  93. package/lib/pages/cms/orders/ExportReportsDialog.cjs.js +1 -0
  94. package/lib/pages/cms/orders/ExportReportsDialog.es.js +130 -0
  95. package/lib/pages/cms/orders/OrderDetailPage.cjs.js +1 -0
  96. package/lib/pages/cms/orders/OrderDetailPage.es.js +137 -0
  97. package/lib/pages/cms/orders/OrderPrintButton.cjs.js +1 -0
  98. package/lib/pages/cms/orders/OrderPrintButton.es.js +22 -0
  99. package/lib/pages/cms/orders/OrderStatusForm.cjs.js +1 -0
  100. package/lib/pages/cms/orders/OrderStatusForm.es.js +71 -0
  101. package/lib/pages/cms/orders/OrdersPage.cjs.js +1 -0
  102. package/lib/pages/cms/orders/OrdersPage.es.js +104 -0
  103. package/lib/pages/cms/orders/actions.cjs.js +7 -0
  104. package/lib/pages/cms/orders/actions.es.js +71 -0
  105. package/lib/pages/cms/orders/export-actions.cjs.js +1 -0
  106. package/lib/pages/cms/orders/export-actions.es.js +27 -0
  107. package/lib/pages/cms/orders/server-actions.cjs.js +1 -0
  108. package/lib/pages/cms/orders/server-actions.es.js +55 -0
  109. package/lib/pages/cms/payments/PaymentsClient.cjs.js +1 -0
  110. package/lib/pages/cms/payments/PaymentsClient.es.js +188 -0
  111. package/lib/pages/cms/payments/PaymentsPage.cjs.js +1 -0
  112. package/lib/pages/cms/payments/PaymentsPage.es.js +29 -0
  113. package/lib/pages/cms/payments/actions.cjs.js +1 -0
  114. package/lib/pages/cms/payments/actions.es.js +23 -0
  115. package/lib/pages/cms/payments/queries.cjs.js +1 -0
  116. package/lib/pages/cms/payments/queries.es.js +30 -0
  117. package/lib/pages/cms/products/ProductsPage.cjs.js +1 -0
  118. package/lib/pages/cms/products/ProductsPage.es.js +46 -0
  119. package/lib/pages/cms/products/_id_/edit/EditProductPage.cjs.js +1 -0
  120. package/lib/pages/cms/products/_id_/edit/EditProductPage.es.js +156 -0
  121. package/lib/pages/cms/products/actions.cjs.js +44 -0
  122. package/lib/pages/cms/products/actions.es.js +175 -0
  123. package/lib/pages/cms/products/attributes/AttributeManagementPage.cjs.js +1 -0
  124. package/lib/pages/cms/products/attributes/AttributeManagementPage.es.js +48 -0
  125. package/lib/pages/cms/products/attributes/components/AttributeManager.cjs.js +1 -0
  126. package/lib/pages/cms/products/attributes/components/AttributeManager.es.js +291 -0
  127. package/lib/pages/cms/products/categories/CategoryManagementPage.cjs.js +1 -0
  128. package/lib/pages/cms/products/categories/CategoryManagementPage.es.js +36 -0
  129. package/lib/pages/cms/products/categories/components/CategoryManager.cjs.js +1 -0
  130. package/lib/pages/cms/products/categories/components/CategoryManager.es.js +263 -0
  131. package/lib/pages/cms/products/components/CopyProductFromLanguage.cjs.js +1 -0
  132. package/lib/pages/cms/products/components/CopyProductFromLanguage.es.js +114 -0
  133. package/lib/pages/cms/products/components/CurrencyPriceFields.cjs.js +1 -0
  134. package/lib/pages/cms/products/components/CurrencyPriceFields.es.js +107 -0
  135. package/lib/pages/cms/products/components/DeleteProductButton.cjs.js +1 -0
  136. package/lib/pages/cms/products/components/DeleteProductButton.es.js +48 -0
  137. package/lib/pages/cms/products/components/FreemiusPricingDashboard.cjs.js +1 -0
  138. package/lib/pages/cms/products/components/FreemiusPricingDashboard.es.js +86 -0
  139. package/lib/pages/cms/products/components/ProductCategorySelector.cjs.js +1 -0
  140. package/lib/pages/cms/products/components/ProductCategorySelector.es.js +160 -0
  141. package/lib/pages/cms/products/components/ProductForm.cjs.js +1 -0
  142. package/lib/pages/cms/products/components/ProductForm.es.js +702 -0
  143. package/lib/pages/cms/products/components/ProductMediaManager.cjs.js +1 -0
  144. package/lib/pages/cms/products/components/ProductMediaManager.es.js +104 -0
  145. package/lib/pages/cms/products/components/ProductsBulkTable.cjs.js +1 -0
  146. package/lib/pages/cms/products/components/ProductsBulkTable.es.js +228 -0
  147. package/lib/pages/cms/products/components/SaleScheduleFields.cjs.js +1 -0
  148. package/lib/pages/cms/products/components/SaleScheduleFields.es.js +137 -0
  149. package/lib/pages/cms/products/components/SyncFreemiusButton.cjs.js +1 -0
  150. package/lib/pages/cms/products/components/SyncFreemiusButton.es.js +36 -0
  151. package/lib/pages/cms/products/components/SyncFreemiusPricingButton.cjs.js +1 -0
  152. package/lib/pages/cms/products/components/SyncFreemiusPricingButton.es.js +40 -0
  153. package/lib/pages/cms/products/components/VariationsEditor.cjs.js +1 -0
  154. package/lib/pages/cms/products/components/VariationsEditor.es.js +408 -0
  155. package/lib/pages/cms/products/inventory/InventoryPage.cjs.js +1 -0
  156. package/lib/pages/cms/products/inventory/InventoryPage.es.js +16 -0
  157. package/lib/pages/cms/products/inventory/InventoryTableClient.cjs.js +2 -0
  158. package/lib/pages/cms/products/inventory/InventoryTableClient.es.js +214 -0
  159. package/lib/pages/cms/products/inventory/actions.cjs.js +3 -0
  160. package/lib/pages/cms/products/inventory/actions.es.js +95 -0
  161. package/lib/pages/cms/products/new/NewProductPage.cjs.js +1 -0
  162. package/lib/pages/cms/products/new/NewProductPage.es.js +76 -0
  163. package/lib/pages/cms/products/product-price-sync.cjs.js +1 -0
  164. package/lib/pages/cms/products/product-price-sync.es.js +98 -0
  165. package/lib/pages/cms/products/server-actions.cjs.js +1 -0
  166. package/lib/pages/cms/products/server-actions.es.js +193 -0
  167. package/lib/pages/cms/shipping/ShippingPage.cjs.js +5 -0
  168. package/lib/pages/cms/shipping/ShippingPage.es.js +211 -0
  169. package/lib/pages/cms/shipping/components/RateForm.cjs.js +1 -0
  170. package/lib/pages/cms/shipping/components/RateForm.es.js +441 -0
  171. package/lib/pages/cms/shipping/components/ZoneForm.cjs.js +1 -0
  172. package/lib/pages/cms/shipping/components/ZoneForm.es.js +228 -0
  173. package/lib/pages/cms/shipping/server-actions.cjs.js +1 -0
  174. package/lib/pages/cms/shipping/server-actions.es.js +159 -0
  175. package/lib/pages/cms/taxes/TaxesPage.cjs.js +1 -0
  176. package/lib/pages/cms/taxes/TaxesPage.es.js +172 -0
  177. package/lib/pages/cms/taxes/actions.cjs.js +1 -0
  178. package/lib/pages/cms/taxes/actions.es.js +57 -0
  179. package/lib/pages/cms/taxes/components/TaxRateForm.cjs.js +1 -0
  180. package/lib/pages/cms/taxes/components/TaxRateForm.es.js +100 -0
  181. package/lib/product-actions.cjs.js +237 -0
  182. package/lib/product-actions.es.js +524 -0
  183. package/lib/product-context.cjs.js +1 -0
  184. package/lib/product-context.es.js +16 -0
  185. package/lib/product-schema.cjs.js +1 -0
  186. package/lib/product-schema.es.js +134 -0
  187. package/lib/providers/freemius.cjs.js +5 -0
  188. package/lib/providers/freemius.es.js +538 -0
  189. package/lib/providers/stripe.cjs.js +1 -0
  190. package/lib/providers/stripe.es.js +473 -0
  191. package/lib/server-actions/coupon-actions.cjs.js +1 -0
  192. package/lib/server-actions/coupon-actions.es.js +23 -0
  193. package/lib/server-actions/customer-actions.cjs.js +1 -0
  194. package/lib/server-actions/customer-actions.es.js +30 -0
  195. package/lib/server-actions/product-actions.cjs.js +1 -0
  196. package/{server-actions → lib/server-actions}/product-actions.es.js +5 -4
  197. package/lib/server-actions/shipping-actions.cjs.js +1 -0
  198. package/{shipping-actions-BnHjlo2q.js → lib/server-actions/shipping-actions.es.js} +9 -7
  199. package/lib/server-actions/tax-actions.cjs.js +1 -0
  200. package/lib/server-actions/tax-actions.es.js +40 -0
  201. package/lib/shared-inventory.cjs.js +15 -0
  202. package/lib/shared-inventory.es.js +171 -0
  203. package/lib/shipping/resolver.cjs.js +7 -0
  204. package/lib/shipping/resolver.es.js +62 -0
  205. package/lib/shipping-rate-currency.cjs.js +1 -0
  206. package/lib/shipping-rate-currency.es.js +72 -0
  207. package/lib/states.cjs.js +1 -0
  208. package/{states-DlHJezQ1.js → lib/states.es.js} +27 -100
  209. package/lib/stripe/checkout.cjs.js +1 -0
  210. package/lib/stripe/checkout.es.js +182 -0
  211. package/lib/stripe/client.cjs.js +1 -0
  212. package/lib/stripe/client.es.js +7 -0
  213. package/lib/stripe/order-sync.cjs.js +1 -0
  214. package/lib/stripe/order-sync.es.js +130 -0
  215. package/lib/stripe/webhooks.cjs.js +1 -0
  216. package/lib/stripe/webhooks.es.js +30 -0
  217. package/lib/tax-calculation.cjs.js +1 -0
  218. package/lib/tax-calculation.es.js +101 -0
  219. package/lib/trials.cjs.js +1 -0
  220. package/{trials-RDcRAZKx.js → lib/trials.es.js} +9 -9
  221. package/{use-cart.es.js → lib/use-cart.es.js} +1 -0
  222. package/lib/zod-config.cjs.js +1 -0
  223. package/lib/zod-config.es.js +6 -0
  224. package/package.json +4 -4
  225. package/server.cjs.js +1 -110
  226. package/server.es.js +178 -6052
  227. package/AddToCartButton-DsSEH9yp.cjs +0 -1
  228. package/CouponForm-BI_5SBHQ.js +0 -152
  229. package/CouponForm-D_uu2bLP.cjs +0 -1
  230. package/CurrencyProvider-Cg-Q6ucj.cjs +0 -1
  231. package/CurrencyProvider-OzlRN96V.js +0 -120
  232. package/CurrencyProvider.cjs.js +0 -1
  233. package/CurrencyProvider.es.js +0 -10
  234. package/ProductDetailsLayout-BxJH_BxR.cjs +0 -1
  235. package/ProductDetailsLayout-Dg8dRTYp.js +0 -530
  236. package/ProductGrid-BdL7iglO.cjs +0 -1
  237. package/ProductGrid-D3AWM8sr.js +0 -130
  238. package/actions-AHmBrS5e.cjs +0 -48
  239. package/actions-j5fuSZX-.js +0 -820
  240. package/cart-store.cjs.js +0 -1
  241. package/components/Cart.cjs.js +0 -1
  242. package/components/Cart.es.js +0 -259
  243. package/components/CartDrawer.cjs.js +0 -1
  244. package/components/Checkout.cjs.js +0 -1
  245. package/components/CurrencySwitcher.cjs.js +0 -1
  246. package/components/FeaturedProduct.cjs.js +0 -1
  247. package/components/ProductDetailsLayout.cjs.js +0 -1
  248. package/components/ProductDetailsLayout.es.js +0 -19
  249. package/components/ProductGrid.cjs.js +0 -1
  250. package/components/ProductGrid.es.js +0 -6
  251. package/coupon-server-C9ySm3I5.cjs +0 -1
  252. package/customer-C-UPvrYN.cjs +0 -1
  253. package/invoice-ui-CAnJPu6n.cjs +0 -29
  254. package/invoice-ui-DtpbTJE1.js +0 -2886
  255. package/product-actions-CONBF8i6.cjs +0 -251
  256. package/product-actions-DjlIWCMH.js +0 -691
  257. package/resolver-Fz_FKsfX.cjs +0 -7
  258. package/resolver-cfrCaHpE.js +0 -128
  259. package/server-actions/product-actions.cjs.js +0 -1
  260. package/shipping-actions-D6zt20gg.cjs +0 -1
  261. package/states-CWYRxV4B.cjs +0 -1
  262. package/tax-calculation-Dab89aHd.js +0 -181
  263. package/tax-calculation-MkDKOEkL.cjs +0 -1
  264. package/trials-DvZaOtNy.cjs +0 -1
  265. /package/{components → lib/components}/SimpleTiptapRenderer.cjs.js +0 -0
  266. /package/{components → lib/components}/SimpleTiptapRenderer.es.js +0 -0
  267. /package/{currency-constants.cjs.js → lib/currency-constants.cjs.js} +0 -0
  268. /package/{currency-constants.es.js → lib/currency-constants.es.js} +0 -0
  269. /package/{currency-rest-client-uolJxUkL.cjs → lib/currency-rest-client.cjs.js} +0 -0
  270. /package/{currency-rest-client-CwoqdgAP.js → lib/currency-rest-client.es.js} +0 -0
  271. /package/{currency.cjs.js → lib/currency.cjs.js} +0 -0
  272. /package/{currency.es.js → lib/currency.es.js} +0 -0
  273. /package/{types.cjs.js → lib/types.cjs.js} +0 -0
  274. /package/{types.es.js → lib/types.es.js} +0 -0
  275. /package/{use-cart.cjs.js → lib/use-cart.cjs.js} +0 -0
  276. /package/{variation-utils.cjs.js → lib/variation-utils.cjs.js} +0 -0
  277. /package/{variation-utils.es.js → lib/variation-utils.es.js} +0 -0
@@ -0,0 +1,361 @@
1
+ 'use client';
2
+ import { jsxs as a, jsx as t } from "react/jsx-runtime";
3
+ import Q, { useState as B, useEffect as R, useMemo as T } from "react";
4
+ import { Download as Y, Package as Z, ShieldCheck as ee } from "lucide-react";
5
+ import { Badge as I } from "@nextblock-cms/ui/badge";
6
+ import { Button as te } from "@nextblock-cms/ui/button";
7
+ import { Label as re } from "@nextblock-cms/ui/label";
8
+ import { Separator as se } from "@nextblock-cms/ui/separator";
9
+ import { useTranslations as ae, formatPrice as D } from "@nextblock-cms/utils";
10
+ import { useProduct as ie } from "../product-context.es.js";
11
+ import { ProductGallery as ce } from "./ProductGallery.es.js";
12
+ import { AddToCartButton as ne } from "./AddToCartButton.es.js";
13
+ import { SubscriptionSelector as le } from "./SubscriptionSelector.es.js";
14
+ import { SimpleTiptapRenderer as oe } from "./SimpleTiptapRenderer.es.js";
15
+ import { chooseInitialVariantSelections as F, normalizeSelectionsToAvailableVariants as J, findMatchingVariant as de, resolveTranslatedText as me, getAvailableTermIdsForAttribute as pe } from "../variation-utils.es.js";
16
+ import { useCurrency as ue } from "../CurrencyProvider.es.js";
17
+ import { resolveEffectivePriceForCurrency as M } from "../currency.es.js";
18
+ import { isDigitalProduct as fe } from "../types.es.js";
19
+ import { getTrialSummary as ge } from "../trials.es.js";
20
+ function A(o, x, e, d) {
21
+ const y = {
22
+ kind: "product-field",
23
+ field: x,
24
+ input: e,
25
+ label: d
26
+ }, u = typeof window < "u" ? window.location.origin : process.env.NEXT_PUBLIC_URL || process.env.TARGET_URL || (process.env.VERCEL_URL ? `https://${process.env.VERCEL_URL}` : "") || "http://localhost:3000";
27
+ let f = (typeof window < "u" ? window.location.origin : process.env.NEXT_PUBLIC_URL || process.env.TARGET_URL || (process.env.VERCEL_URL ? `https://${process.env.VERCEL_URL}` : "") || "http://localhost:3000").replace(/\/+$/, "");
28
+ try {
29
+ (f.startsWith("http://") || f.startsWith("https://")) && (f = new URL(f).hostname);
30
+ } catch {
31
+ }
32
+ const k = process.env.NEXTBLOCK_VERCEL_PROJECT_ID || process.env.VERCEL_PROJECT_ID, w = process.env.NEXTBLOCK_VERCEL_WORKSPACE_ID || process.env.VERCEL_ORG_ID, l = {
33
+ origin: f,
34
+ editUrl: `${u}/cms/products/${o.id}/edit`,
35
+ data: {
36
+ parentType: "product",
37
+ parentId: o.id,
38
+ slug: o.slug,
39
+ languageId: o.language_id,
40
+ draftId: null,
41
+ target: y
42
+ }
43
+ };
44
+ return k && (l.projectId = k), w && (l.workspaceId = w), {
45
+ "data-vercel-edit-info": JSON.stringify(l),
46
+ "data-vercel-edit-target": JSON.stringify(y),
47
+ "data-nextblock-visual-edit": `product:${x}`
48
+ };
49
+ }
50
+ const Ve = ({
51
+ visualEditingEnabled: o = !1,
52
+ descriptionNode: x
53
+ }) => {
54
+ const e = ie(), { t: d, lang: y } = ae(), { activeCurrencyCode: u, currencies: P } = ue(), f = o ? A(
55
+ e,
56
+ "title",
57
+ "plain-text",
58
+ "Product title"
59
+ ) : void 0, k = o ? A(
60
+ e,
61
+ "short_description",
62
+ "plain-text",
63
+ "Short description"
64
+ ) : void 0, w = o ? A(
65
+ e,
66
+ "description_json",
67
+ "tiptap",
68
+ "Product description"
69
+ ) : void 0, l = (s, p, c) => {
70
+ const $ = d(s, c);
71
+ return $ === s ? p : $;
72
+ }, C = e.images && e.images.length > 0 ? e.images : e.image_url ? [{ url: e.image_url, alt: e.title }] : [], v = e.custom_props?.provider === "freemius" || fe(e), V = ge(e), i = !v && !!(e.has_variants && e.attributes?.length && e.variants?.length), g = e.attributes || [], m = e.variants || [], [_, L] = B(() => F(g, m)), [S, E] = B(1);
73
+ R(() => {
74
+ E(1);
75
+ }, [e.id]), R(() => {
76
+ i && L(F(g, m));
77
+ }, [g, i, e.id, m]);
78
+ const h = T(() => i ? J(
79
+ g,
80
+ m,
81
+ _
82
+ ) : _, [g, i, _, m]);
83
+ R(() => {
84
+ JSON.stringify(h) !== JSON.stringify(_) && L(h);
85
+ }, [h, _]);
86
+ const r = T(() => i ? de(m, h) : null, [i, h, m]), O = M({
87
+ prices: e.prices,
88
+ salePrices: e.sale_prices,
89
+ fallbackPrice: e.price,
90
+ fallbackSalePrice: e.sale_price,
91
+ saleStartAt: e.sale_start_at,
92
+ saleEndAt: e.sale_end_at,
93
+ scheduledPrice: e.scheduled_price,
94
+ scheduledPrices: e.scheduled_prices,
95
+ scheduledPriceAt: e.scheduled_price_at,
96
+ currencyCode: u,
97
+ currencies: P
98
+ }), U = i && r ? M({
99
+ prices: r.prices,
100
+ salePrices: r.sale_prices,
101
+ fallbackPrice: r.price,
102
+ fallbackSalePrice: r.sale_price,
103
+ saleStartAt: r.sale_start_at,
104
+ saleEndAt: r.sale_end_at,
105
+ scheduledPrice: r.scheduled_price,
106
+ scheduledPrices: r.scheduled_prices,
107
+ scheduledPriceAt: r.scheduled_price_at,
108
+ currencyCode: u,
109
+ currencies: P
110
+ }) : null, b = U?.price ?? O.price, N = U?.sale_price ?? O.sale_price, n = i ? r?.stock_quantity ?? 0 : e.stock ?? 0, G = T(() => {
111
+ if (!r?.image_url)
112
+ return C;
113
+ const s = {
114
+ url: r.image_url,
115
+ alt: `${e.title} ${r.label}`
116
+ }, p = C.filter(
117
+ (c) => c.url !== r.image_url
118
+ );
119
+ return [s, ...p];
120
+ }, [C, e.title, r]), K = typeof N == "number" && b > 0 ? Math.round(
121
+ (b - N) / b * 100
122
+ ) : 0, X = i && r ? {
123
+ ...e,
124
+ sku: r.sku,
125
+ price: r.price,
126
+ prices: r.prices,
127
+ sale_price: typeof r.sale_price == "number" ? r.sale_price : null,
128
+ sale_prices: r.sale_prices,
129
+ image_url: r.image_url || e.image_url,
130
+ stock: r.stock_quantity,
131
+ variant_id: r.id,
132
+ variant_label: r.label,
133
+ selected_options: r.selected_options,
134
+ currency_code: u
135
+ } : {
136
+ ...e,
137
+ currency_code: u
138
+ }, q = (s, p) => {
139
+ L(
140
+ (c) => J(g, m, {
141
+ ...c,
142
+ [s]: p
143
+ })
144
+ );
145
+ }, W = l(
146
+ "ecommerce.in_stock",
147
+ `${n} in stock`,
148
+ { count: String(n) }
149
+ ), j = l(
150
+ "ecommerce.out_of_stock",
151
+ "Out of stock"
152
+ ), z = l(
153
+ "ecommerce.select_options",
154
+ "Select Options"
155
+ ), H = l(
156
+ "ecommerce.variant_selection_required",
157
+ "Select one term from every dropdown to resolve a variation."
158
+ );
159
+ return /* @__PURE__ */ a("div", { className: "w-full animate-in fade-in slide-in-from-bottom-4 duration-700 ease-out", children: [
160
+ /* @__PURE__ */ t("div", { className: "container mx-auto px-4 md:px-6 py-12", children: /* @__PURE__ */ a("div", { className: "grid gap-12 lg:grid-cols-[2fr_3fr] items-start", children: [
161
+ /* @__PURE__ */ t("div", { className: "w-full max-w-2xl mx-auto lg:max-w-none", children: /* @__PURE__ */ t(ce, { images: G, className: "w-full" }) }),
162
+ /* @__PURE__ */ a("div", { className: "flex flex-col gap-4 pb-2 max-w-xl mx-auto lg:mx-0 lg:max-w-none", children: [
163
+ /* @__PURE__ */ t("div", { className: "space-y-6", children: /* @__PURE__ */ a("div", { className: "space-y-4", children: [
164
+ /* @__PURE__ */ t(
165
+ "h1",
166
+ {
167
+ className: "text-3xl sm:text-4xl lg:text-5xl font-extrabold tracking-tight text-foreground leading-[1.1] lg:mt-0",
168
+ ...f,
169
+ children: e.title
170
+ }
171
+ ),
172
+ e.categories && e.categories.length > 0 && /* @__PURE__ */ t("div", { className: "flex flex-wrap items-center gap-1.5 text-xs font-bold uppercase tracking-widest text-amber-600 dark:text-amber-400", children: e.categories.map((s, p) => {
173
+ const c = me(
174
+ s.name,
175
+ s.name_translations,
176
+ y
177
+ );
178
+ return /* @__PURE__ */ a(Q.Fragment, { children: [
179
+ p > 0 && /* @__PURE__ */ t("span", { className: "text-muted-foreground/30", children: "•" }),
180
+ /* @__PURE__ */ t("span", { children: c })
181
+ ] }, s.id);
182
+ }) }),
183
+ /* @__PURE__ */ t(
184
+ "div",
185
+ {
186
+ className: "prose prose-neutral dark:prose-invert max-w-none text-muted-foreground leading-relaxed text-left",
187
+ ...k,
188
+ children: e.short_description ? /* @__PURE__ */ t(
189
+ "div",
190
+ {
191
+ className: "text-lg mb-4 leading-relaxed",
192
+ dangerouslySetInnerHTML: {
193
+ __html: e.short_description
194
+ }
195
+ }
196
+ ) : o ? /* @__PURE__ */ t("p", { className: "text-lg mb-4 italic text-muted-foreground", children: "Add a short product description." }) : null
197
+ }
198
+ ),
199
+ /* @__PURE__ */ a("div", { className: "flex items-center gap-3", children: [
200
+ typeof N == "number" && /* @__PURE__ */ t(
201
+ I,
202
+ {
203
+ variant: "destructive",
204
+ className: "px-2.5 py-1 text-xs font-bold uppercase tracking-wide animate-pulse shadow-sm",
205
+ children: d("ecommerce.sale_badge", {
206
+ percent: String(K)
207
+ })
208
+ }
209
+ ),
210
+ !v && n > 0 && n < 10 && /* @__PURE__ */ t(
211
+ I,
212
+ {
213
+ variant: "outline",
214
+ className: "text-amber-600 border-amber-200 bg-amber-50",
215
+ children: d("ecommerce.low_stock", {
216
+ count: String(n)
217
+ })
218
+ }
219
+ ),
220
+ V && /* @__PURE__ */ t(
221
+ I,
222
+ {
223
+ variant: "secondary",
224
+ className: "border border-emerald-200 bg-emerald-50 text-emerald-800",
225
+ children: V.label
226
+ }
227
+ )
228
+ ] })
229
+ ] }) }),
230
+ /* @__PURE__ */ a("div", { className: "p-5 rounded-2xl bg-card/60 border border-border/80 shadow-md backdrop-blur-md space-y-4", children: [
231
+ v ? /* @__PURE__ */ t(le, { product: e }) : /* @__PURE__ */ a("div", { className: "space-y-3.5", children: [
232
+ /* @__PURE__ */ a("div", { className: "flex items-center justify-between gap-4", children: [
233
+ /* @__PURE__ */ a("div", { className: "space-y-1", children: [
234
+ /* @__PURE__ */ t("span", { className: "text-[10px] font-bold text-muted-foreground uppercase tracking-widest", children: l("ecommerce.price", "Price") }),
235
+ /* @__PURE__ */ a("div", { className: "flex items-baseline gap-2.5", children: [
236
+ /* @__PURE__ */ t("span", { className: "text-3xl font-extrabold text-foreground", children: D(
237
+ N ?? b,
238
+ u
239
+ ) }),
240
+ typeof N == "number" && /* @__PURE__ */ t("span", { className: "text-lg text-muted-foreground line-through decoration-destructive/20 decoration-1", children: D(b, u) })
241
+ ] })
242
+ ] }),
243
+ !v && (r || !i) && /* @__PURE__ */ a("div", { className: "text-right space-y-1", children: [
244
+ /* @__PURE__ */ a("span", { className: "text-[10px] font-bold text-muted-foreground uppercase tracking-widest block", children: [
245
+ !i && e.sku && /* @__PURE__ */ a("span", { className: "mr-2 font-normal lowercase normal-case text-muted-foreground/70", children: [
246
+ "SKU: ",
247
+ e.sku
248
+ ] }),
249
+ l("ecommerce.status", "Status")
250
+ ] }),
251
+ /* @__PURE__ */ t("div", { className: (n ?? 0) > 0 ? "text-emerald-600 dark:text-emerald-400 font-semibold text-sm" : "text-destructive font-semibold text-sm", children: (n ?? 0) > 0 ? W : j })
252
+ ] })
253
+ ] }),
254
+ i && /* @__PURE__ */ t("div", { className: "space-y-3", children: /* @__PURE__ */ t("div", { className: "grid gap-3 sm:grid-cols-2", children: g.map((s) => {
255
+ const p = pe(
256
+ m,
257
+ s.id,
258
+ h
259
+ );
260
+ return /* @__PURE__ */ a("div", { className: "space-y-1", children: [
261
+ /* @__PURE__ */ a("div", { className: "flex items-center justify-between", children: [
262
+ /* @__PURE__ */ t(
263
+ re,
264
+ {
265
+ htmlFor: `attribute-${s.id}`,
266
+ className: "text-[11px] font-semibold text-muted-foreground uppercase tracking-wider",
267
+ children: s.name
268
+ }
269
+ ),
270
+ r?.sku && /* @__PURE__ */ t("span", { className: "text-[10px] text-muted-foreground font-mono", children: r.sku })
271
+ ] }),
272
+ /* @__PURE__ */ t(
273
+ "select",
274
+ {
275
+ id: `attribute-${s.id}`,
276
+ className: "flex h-9 w-full rounded-md border border-input bg-background px-3 py-1 text-sm focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
277
+ value: h[s.id] || "",
278
+ onChange: (c) => q(
279
+ s.id,
280
+ c.target.value
281
+ ),
282
+ children: s.terms.map((c) => /* @__PURE__ */ t(
283
+ "option",
284
+ {
285
+ value: c.id,
286
+ disabled: !p.has(c.id),
287
+ children: c.value
288
+ },
289
+ c.id
290
+ ))
291
+ }
292
+ )
293
+ ] }, s.id);
294
+ }) }) }),
295
+ i && !r && /* @__PURE__ */ t("p", { className: "text-xs text-muted-foreground italic pt-1", children: H }),
296
+ /* @__PURE__ */ a("div", { className: "flex items-center gap-3 pt-1", children: [
297
+ !v && (n ?? 0) > 0 && /* @__PURE__ */ a("div", { className: "flex items-center border rounded-lg h-12 bg-background border-input select-none", children: [
298
+ /* @__PURE__ */ t(
299
+ "button",
300
+ {
301
+ type: "button",
302
+ onClick: () => E((s) => Math.max(1, s - 1)),
303
+ className: "px-3 h-full flex items-center justify-center text-muted-foreground hover:text-foreground active:scale-95 transition-all text-lg font-medium",
304
+ disabled: S <= 1,
305
+ children: "-"
306
+ }
307
+ ),
308
+ /* @__PURE__ */ t("span", { className: "w-8 text-center text-sm font-semibold", children: S }),
309
+ /* @__PURE__ */ t(
310
+ "button",
311
+ {
312
+ type: "button",
313
+ onClick: () => E(
314
+ (s) => n !== null && s >= n ? s : s + 1
315
+ ),
316
+ className: "px-3 h-full flex items-center justify-center text-muted-foreground hover:text-foreground active:scale-95 transition-all text-lg font-medium",
317
+ disabled: n !== null && S >= n,
318
+ children: "+"
319
+ }
320
+ )
321
+ ] }),
322
+ i && (!r || (n ?? 0) <= 0) ? /* @__PURE__ */ t(
323
+ te,
324
+ {
325
+ disabled: !0,
326
+ className: "flex-1 h-12 text-md font-bold shadow-md",
327
+ children: r ? j : z
328
+ }
329
+ ) : /* @__PURE__ */ t(
330
+ ne,
331
+ {
332
+ product: X,
333
+ quantity: S,
334
+ className: "flex-1 h-12 text-md font-bold shadow-md transition-all hover:shadow-lg active:scale-[0.98]"
335
+ }
336
+ )
337
+ ] })
338
+ ] }),
339
+ /* @__PURE__ */ t(se, { className: "opacity-60 my-0.5" }),
340
+ /* @__PURE__ */ a("div", { className: "grid grid-cols-2 gap-4 text-center text-[11px] font-medium text-muted-foreground pt-1", children: [
341
+ /* @__PURE__ */ t("div", { className: "flex items-center justify-center gap-2", children: v ? /* @__PURE__ */ a("span", { className: "inline-flex items-center gap-1.5", children: [
342
+ /* @__PURE__ */ t(Y, { className: "h-3.5 w-3.5" }),
343
+ d("ecommerce.instant_digital_delivery")
344
+ ] }) : /* @__PURE__ */ a("span", { className: "inline-flex items-center gap-1.5", children: [
345
+ /* @__PURE__ */ t(Z, { className: "h-3.5 w-3.5" }),
346
+ d("ecommerce.free_shipping")
347
+ ] }) }),
348
+ /* @__PURE__ */ t("div", { className: "flex items-center justify-center gap-2", children: /* @__PURE__ */ a("span", { className: "inline-flex items-center gap-1.5", children: [
349
+ /* @__PURE__ */ t(ee, { className: "h-3.5 w-3.5" }),
350
+ d("ecommerce.secure_checkout")
351
+ ] }) })
352
+ ] })
353
+ ] })
354
+ ] })
355
+ ] }) }),
356
+ /* @__PURE__ */ t("div", { className: "min-w-0 w-full", ...x ? void 0 : w, children: x || (e.description_json ? /* @__PURE__ */ t("div", { className: "container mx-auto px-4 md:px-6 pb-12 prose prose-neutral dark:prose-invert max-w-none leading-relaxed", children: /* @__PURE__ */ t(oe, { content: e.description_json }) }) : /* @__PURE__ */ t("div", { className: "container mx-auto px-4 md:px-6 pb-12", children: /* @__PURE__ */ t("p", { className: "italic text-sm text-muted-foreground", children: d("ecommerce.no_description") }) })) })
357
+ ] });
358
+ };
359
+ export {
360
+ Ve as ProductDetailsLayout
361
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),c=require("@nextblock-cms/utils"),a=require("react"),d=({images:r=[],className:s})=>{const[l,n]=a.useState(0);return a.useEffect(()=>{n(0)},[r]),r.length?e.jsxs("div",{className:c.cn("flex flex-col gap-4",s),children:[e.jsx("div",{className:"relative aspect-square w-full overflow-hidden rounded-lg border bg-white",children:e.jsx("img",{src:r[l].url,alt:r[l].alt,className:"h-full w-full object-cover object-center"})}),r.length>1&&e.jsx("div",{className:"flex gap-4 overflow-x-auto pb-2",children:r.map((o,t)=>e.jsx("button",{onClick:()=>n(t),className:c.cn("relative aspect-square w-20 flex-shrink-0 overflow-hidden rounded-md border",l===t?"ring-2 ring-primary":"ring-1 ring-transparent hover:ring-primary/50"),children:e.jsx("img",{src:o.url,alt:o.alt,className:"h-full w-full object-cover object-center"})},t))})]}):e.jsx("div",{className:c.cn("relative aspect-square w-full overflow-hidden rounded-lg bg-secondary",s),children:e.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:"No Image"})})};exports.ProductGallery=d;
@@ -0,0 +1,41 @@
1
+ 'use client';
2
+ import { jsx as e, jsxs as d } from "react/jsx-runtime";
3
+ import { cn as c } from "@nextblock-cms/utils";
4
+ import { useState as s, useEffect as i } from "react";
5
+ const m = ({ images: r = [], className: o }) => {
6
+ const [l, n] = s(0);
7
+ return i(() => {
8
+ n(0);
9
+ }, [r]), r.length ? /* @__PURE__ */ d("div", { className: c("flex flex-col gap-4", o), children: [
10
+ /* @__PURE__ */ e("div", { className: "relative aspect-square w-full overflow-hidden rounded-lg border bg-white", children: /* @__PURE__ */ e(
11
+ "img",
12
+ {
13
+ src: r[l].url,
14
+ alt: r[l].alt,
15
+ className: "h-full w-full object-cover object-center"
16
+ }
17
+ ) }),
18
+ r.length > 1 && /* @__PURE__ */ e("div", { className: "flex gap-4 overflow-x-auto pb-2", children: r.map((a, t) => /* @__PURE__ */ e(
19
+ "button",
20
+ {
21
+ onClick: () => n(t),
22
+ className: c(
23
+ "relative aspect-square w-20 flex-shrink-0 overflow-hidden rounded-md border",
24
+ l === t ? "ring-2 ring-primary" : "ring-1 ring-transparent hover:ring-primary/50"
25
+ ),
26
+ children: /* @__PURE__ */ e(
27
+ "img",
28
+ {
29
+ src: a.url,
30
+ alt: a.alt,
31
+ className: "h-full w-full object-cover object-center"
32
+ }
33
+ )
34
+ },
35
+ t
36
+ )) })
37
+ ] }) : /* @__PURE__ */ e("div", { className: c("relative aspect-square w-full overflow-hidden rounded-lg bg-secondary", o), children: /* @__PURE__ */ e("div", { className: "flex h-full items-center justify-center text-muted-foreground", children: "No Image" }) });
38
+ };
39
+ export {
40
+ m as ProductGallery
41
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),s=require("./ProductCard.cjs.js"),c=require("@nextblock-cms/utils"),o=({products:e,columns:t=3,className:i})=>e.length?r.jsx("div",{className:c.cn("grid gap-6 sm:grid-cols-2",t===3&&"lg:grid-cols-3",t===4&&"lg:grid-cols-4",i),children:e.map(d=>r.jsx(s.ProductCard,{product:d},d.id))}):r.jsx("div",{className:"py-12 text-center text-muted-foreground",children:"No products found."});exports.ProductGrid=o;
@@ -0,0 +1,19 @@
1
+ 'use client';
2
+ import { jsx as r } from "react/jsx-runtime";
3
+ import { ProductCard as i } from "./ProductCard.es.js";
4
+ import { cn as c } from "@nextblock-cms/utils";
5
+ const n = ({ products: d, columns: o = 3, className: e }) => d.length ? /* @__PURE__ */ r(
6
+ "div",
7
+ {
8
+ className: c(
9
+ "grid gap-6 sm:grid-cols-2",
10
+ o === 3 && "lg:grid-cols-3",
11
+ o === 4 && "lg:grid-cols-4",
12
+ e
13
+ ),
14
+ children: d.map((t) => /* @__PURE__ */ r(i, { product: t }, t.id))
15
+ }
16
+ ) : /* @__PURE__ */ r("div", { className: "py-12 text-center text-muted-foreground", children: "No products found." });
17
+ export {
18
+ n as ProductGrid
19
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("react"),L=require("@nextblock-cms/ui/button"),E=require("@nextblock-cms/ui/input"),m=require("@nextblock-cms/ui/label"),i=require("lucide-react"),R=require("../countries.cjs.js"),T=require("../server-actions/shipping-actions.cjs.js"),N=require("@nextblock-cms/utils"),x=require("../states.cjs.js"),O=require("../CurrencyProvider.cjs.js"),I=({physicalSubtotal:y})=>{const[c,S]=a.useState("CA"),[n,p]=a.useState(""),[h,C]=a.useState(""),[g,j]=a.useState(!1),[r,b]=a.useState(null),[d,v]=a.useState(null),{t:s,lang:_}=N.useTranslations(),{activeCurrencyCode:f}=O.useCurrency(),u=(t,o)=>{const l=s(t);return l===t?o:l},q=x.getStatesForCountry(c),w=x.countryUsesStructuredStates(c),k=u("select_an_option","Select an option"),F=u("state_province","State / Province"),P=async()=>{j(!0),v(null),b(null);const t=await T.getShippingEstimates(y,{country:c,state:n||void 0,postal_code:h},_,f);t.success&&t.methods?b(t.methods):v(t.errorKey?u(t.errorKey,t.error||s("ecommerce.no_rates_found")):t.error||s("ecommerce.no_rates_found")),j(!1)};return e.jsxs("div",{className:"space-y-4 rounded-lg border bg-muted/30 p-4 mt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 font-semibold text-sm",children:[e.jsx(i.Truck,{className:"h-4 w-4"}),e.jsx("span",{children:s("ecommerce.estimate_shipping")})]}),e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(m.Label,{htmlFor:"estimate-country",className:"text-xs uppercase tracking-wider text-muted-foreground",children:s("ecommerce.country")}),e.jsx("select",{id:"estimate-country",value:c,onChange:t=>{const o=t.target.value,l=x.getStatesForCountry(o);S(o),p(l.some(A=>A.code===n)?n:"")},className:"flex h-9 w-full rounded-md border border-input bg-background px-3 py-2 text-sm",children:R.countries.map(t=>e.jsx("option",{value:t.code,children:t.name},t.code))})]}),w&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(m.Label,{htmlFor:"estimate-state",className:"text-xs uppercase tracking-wider text-muted-foreground",children:s("state_province")}),e.jsxs("select",{id:"estimate-state",value:n,onChange:t=>p(t.target.value),className:"flex h-9 w-full rounded-md border border-input bg-background px-3 py-2 text-sm",children:[e.jsx("option",{value:"",children:`${k}: ${F}`}),q.map(t=>e.jsx("option",{value:t.code,children:t.name},t.code))]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(m.Label,{htmlFor:"estimate-postal",className:"text-xs uppercase tracking-wider text-muted-foreground",children:s("ecommerce.postal_code")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(E.Input,{id:"estimate-postal",placeholder:"A1A 1A1",value:h,onChange:t=>C(t.target.value),className:"h-9 text-sm bg-background"}),e.jsxs(L.Button,{size:"sm",variant:"secondary",onClick:P,disabled:g,className:"shrink-0",children:[g?e.jsx(i.Loader2,{className:"h-4 w-4 animate-spin"}):e.jsx(i.Calculator,{className:"h-4 w-4 mr-1.5"}),s("ecommerce.calculate")]})]})]})]}),d&&e.jsx("p",{className:"text-xs text-destructive mt-2",children:d}),r&&r.length>0&&e.jsxs("div",{className:"mt-4 space-y-2 border-t pt-3",children:[e.jsxs("p",{className:"text-xs font-medium text-muted-foreground uppercase",children:[s("ecommerce.available_rates"),":"]}),r.map(t=>e.jsxs("div",{className:"flex justify-between items-center p-3 border rounded-lg bg-muted/30",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(i.Truck,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium",children:t.name})]}),e.jsx("span",{className:"text-sm font-bold",children:t.amount===0?s("ecommerce.free"):N.formatPrice(t.amount,f)})]},t.id))]}),r&&r.length===0&&!d&&e.jsx("p",{className:"text-xs text-muted-foreground mt-2 italic",children:s("ecommerce.no_rates_found")})]})};exports.ShippingEstimator=I;
@@ -0,0 +1,125 @@
1
+ 'use client';
2
+ import { jsxs as s, jsx as t } from "react/jsx-runtime";
3
+ import { useState as r } from "react";
4
+ import { Button as L } from "@nextblock-cms/ui/button";
5
+ import { Input as I } from "@nextblock-cms/ui/input";
6
+ import { Label as u } from "@nextblock-cms/ui/label";
7
+ import { Truck as b, Loader2 as K, Calculator as O } from "lucide-react";
8
+ import { countries as T } from "../countries.es.js";
9
+ import { getShippingEstimates as $ } from "../server-actions/shipping-actions.es.js";
10
+ import { useTranslations as z, formatPrice as B } from "@nextblock-cms/utils";
11
+ import { getStatesForCountry as y, countryUsesStructuredStates as R } from "../states.es.js";
12
+ import { useCurrency as U } from "../CurrencyProvider.es.js";
13
+ const Z = ({ physicalSubtotal: C }) => {
14
+ const [c, _] = r("CA"), [n, p] = r(""), [h, S] = r(""), [g, f] = r(!1), [o, x] = r(null), [i, v] = r(null), { t: a, lang: w } = z(), { activeCurrencyCode: N } = U(), d = (e, l) => {
15
+ const m = a(e);
16
+ return m === e ? l : m;
17
+ }, k = y(c), F = R(c), A = d("select_an_option", "Select an option"), P = d("state_province", "State / Province"), j = async () => {
18
+ f(!0), v(null), x(null);
19
+ const e = await $(
20
+ C,
21
+ {
22
+ country: c,
23
+ state: n || void 0,
24
+ postal_code: h
25
+ },
26
+ w,
27
+ N
28
+ );
29
+ e.success && e.methods ? x(e.methods) : v(
30
+ e.errorKey ? d(
31
+ e.errorKey,
32
+ e.error || a("ecommerce.no_rates_found")
33
+ ) : e.error || a("ecommerce.no_rates_found")
34
+ ), f(!1);
35
+ };
36
+ return /* @__PURE__ */ s("div", { className: "space-y-4 rounded-lg border bg-muted/30 p-4 mt-6", children: [
37
+ /* @__PURE__ */ s("div", { className: "flex items-center gap-2 font-semibold text-sm", children: [
38
+ /* @__PURE__ */ t(b, { className: "h-4 w-4" }),
39
+ /* @__PURE__ */ t("span", { children: a("ecommerce.estimate_shipping") })
40
+ ] }),
41
+ /* @__PURE__ */ s("div", { className: "grid gap-3", children: [
42
+ /* @__PURE__ */ s("div", { className: "space-y-1.5", children: [
43
+ /* @__PURE__ */ t(u, { htmlFor: "estimate-country", className: "text-xs uppercase tracking-wider text-muted-foreground", children: a("ecommerce.country") }),
44
+ /* @__PURE__ */ t(
45
+ "select",
46
+ {
47
+ id: "estimate-country",
48
+ value: c,
49
+ onChange: (e) => {
50
+ const l = e.target.value, m = y(l);
51
+ _(l), p(
52
+ m.some((E) => E.code === n) ? n : ""
53
+ );
54
+ },
55
+ className: "flex h-9 w-full rounded-md border border-input bg-background px-3 py-2 text-sm",
56
+ children: T.map((e) => /* @__PURE__ */ t("option", { value: e.code, children: e.name }, e.code))
57
+ }
58
+ )
59
+ ] }),
60
+ F && /* @__PURE__ */ s("div", { className: "space-y-1.5", children: [
61
+ /* @__PURE__ */ t(u, { htmlFor: "estimate-state", className: "text-xs uppercase tracking-wider text-muted-foreground", children: a("state_province") }),
62
+ /* @__PURE__ */ s(
63
+ "select",
64
+ {
65
+ id: "estimate-state",
66
+ value: n,
67
+ onChange: (e) => p(e.target.value),
68
+ className: "flex h-9 w-full rounded-md border border-input bg-background px-3 py-2 text-sm",
69
+ children: [
70
+ /* @__PURE__ */ t("option", { value: "", children: `${A}: ${P}` }),
71
+ k.map((e) => /* @__PURE__ */ t("option", { value: e.code, children: e.name }, e.code))
72
+ ]
73
+ }
74
+ )
75
+ ] }),
76
+ /* @__PURE__ */ s("div", { className: "space-y-1.5", children: [
77
+ /* @__PURE__ */ t(u, { htmlFor: "estimate-postal", className: "text-xs uppercase tracking-wider text-muted-foreground", children: a("ecommerce.postal_code") }),
78
+ /* @__PURE__ */ s("div", { className: "flex gap-2", children: [
79
+ /* @__PURE__ */ t(
80
+ I,
81
+ {
82
+ id: "estimate-postal",
83
+ placeholder: "A1A 1A1",
84
+ value: h,
85
+ onChange: (e) => S(e.target.value),
86
+ className: "h-9 text-sm bg-background"
87
+ }
88
+ ),
89
+ /* @__PURE__ */ s(
90
+ L,
91
+ {
92
+ size: "sm",
93
+ variant: "secondary",
94
+ onClick: j,
95
+ disabled: g,
96
+ className: "shrink-0",
97
+ children: [
98
+ g ? /* @__PURE__ */ t(K, { className: "h-4 w-4 animate-spin" }) : /* @__PURE__ */ t(O, { className: "h-4 w-4 mr-1.5" }),
99
+ a("ecommerce.calculate")
100
+ ]
101
+ }
102
+ )
103
+ ] })
104
+ ] })
105
+ ] }),
106
+ i && /* @__PURE__ */ t("p", { className: "text-xs text-destructive mt-2", children: i }),
107
+ o && o.length > 0 && /* @__PURE__ */ s("div", { className: "mt-4 space-y-2 border-t pt-3", children: [
108
+ /* @__PURE__ */ s("p", { className: "text-xs font-medium text-muted-foreground uppercase", children: [
109
+ a("ecommerce.available_rates"),
110
+ ":"
111
+ ] }),
112
+ o.map((e) => /* @__PURE__ */ s("div", { className: "flex justify-between items-center p-3 border rounded-lg bg-muted/30", children: [
113
+ /* @__PURE__ */ s("div", { className: "flex items-center gap-2", children: [
114
+ /* @__PURE__ */ t(b, { className: "h-4 w-4 text-muted-foreground" }),
115
+ /* @__PURE__ */ t("span", { className: "text-sm font-medium", children: e.name })
116
+ ] }),
117
+ /* @__PURE__ */ t("span", { className: "text-sm font-bold", children: e.amount === 0 ? a("ecommerce.free") : B(e.amount, N) })
118
+ ] }, e.id))
119
+ ] }),
120
+ o && o.length === 0 && !i && /* @__PURE__ */ t("p", { className: "text-xs text-muted-foreground mt-2 italic", children: a("ecommerce.no_rates_found") })
121
+ ] });
122
+ };
123
+ export {
124
+ Z as ShippingEstimator
125
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),_=require("react"),$=require("@nextblock-cms/ui/button"),S=require("@nextblock-cms/ui/Skeleton"),L=require("../use-cart.cjs.js"),F=require("lucide-react"),N=require("sonner"),I=require("../pages/cms/products/actions.cjs.js"),a=require("@nextblock-cms/utils"),B=require("../CurrencyProvider.cjs.js"),g=require("../currency.cjs.js"),E=require("../trials.cjs.js"),O=({product:e})=>{const y=L.useCart(l=>l),{t:o}=a.useTranslations(),{activeCurrencyCode:s,currencies:u,defaultCurrency:i}=B.useCurrency(),[q,M]=_.useState([]),[k,w]=_.useState(!0),[t,d]=_.useState("annual");if(_.useEffect(()=>{async function l(){try{if(!e.id)return;const c=await I.getPublicFreemiusPricing(e.id);M(c)}catch(c){console.error("Failed to load pricing:",c)}finally{w(!1)}}l()},[e.id]),!y)return r.jsx(S.Skeleton,{className:"h-14 w-full"});const{addItem:A}=y,m=q[0],n=m?.pricing?.[0],P=()=>{let l=e.price,c=e.freemius_plan_id;n&&(t==="monthly"&&n.monthly_price!=null&&(l=a.majorUnitAmountToMinor(n.monthly_price,i.code)),t==="annual"&&n.annual_price!=null&&(l=a.majorUnitAmountToMinor(n.annual_price,i.code)),t==="lifetime"&&n.lifetime_price!=null&&(l=a.majorUnitAmountToMinor(n.lifetime_price,i.code)));const C=u.reduce((j,v)=>(j[v.code]=g.convertMinorUnitAmount({amount:l,fromCurrencyCode:i.code,toCurrencyCode:v.code,currencies:u,applyRounding:!0}),j),{}),T=C[s]??l;m&&m.id&&(c=m.id);const{success:U,error:R}=A({id:e.id,product_id:e.id,title:e.title,price:T,prices:C,image_url:e.image_url,slug:e.slug,sku:e.sku,language_id:e.language_id,translation_group_id:e.translation_group_id,product_type:"digital",payment_provider:"freemius",provider:"freemius",billing_cycle:t,freemius_product_id:e.freemius_product_id,freemius_plan_id:c,trial_period_days:e.trial_period_days??0,trial_requires_payment_method:e.trial_requires_payment_method??!1,is_taxable:e.is_taxable,currency_code:s});U?N.toast.success(o("ecommerce.added_to_cart_success",{item:e.title})):N.toast.error(R||o("ecommerce.added_to_cart_error"))};if(k)return r.jsx(S.Skeleton,{className:"h-32 w-full"});if(!m||!n)return r.jsx("div",{className:"p-4 border border-dashed rounded-lg text-center text-muted-foreground",children:o("ecommerce.pricing_unavailable")});const h=n.monthly_price!=null,p=n.annual_price!=null,b=n.lifetime_price!=null;t==="annual"&&!p&&(h?d("monthly"):b&&d("lifetime"));const f=E.getTrialSummary(e);let x=e.price;return t==="monthly"&&n.monthly_price!=null&&(x=g.convertMinorUnitAmount({amount:a.majorUnitAmountToMinor(n.monthly_price,i.code),fromCurrencyCode:i.code,toCurrencyCode:s,currencies:u,applyRounding:!0})),t==="annual"&&n.annual_price!=null&&(x=g.convertMinorUnitAmount({amount:a.majorUnitAmountToMinor(n.annual_price,i.code),fromCurrencyCode:i.code,toCurrencyCode:s,currencies:u,applyRounding:!0})),t==="lifetime"&&n.lifetime_price!=null&&(x=g.convertMinorUnitAmount({amount:a.majorUnitAmountToMinor(n.lifetime_price,i.code),fromCurrencyCode:i.code,toCurrencyCode:s,currencies:u,applyRounding:!0})),r.jsxs("div",{className:"flex flex-col gap-4",children:[r.jsxs("div",{className:"flex bg-secondary/35 p-1 rounded-lg w-full max-w-sm mx-auto shadow-inner",children:[h&&r.jsx("button",{onClick:()=>d("monthly"),className:`flex-1 py-1.5 text-xs font-semibold rounded-md transition-all ${t==="monthly"?"bg-background shadow-sm text-foreground":"text-muted-foreground hover:text-foreground"}`,children:o("ecommerce.monthly")}),p&&r.jsx("button",{onClick:()=>d("annual"),className:`flex-1 py-1.5 text-xs font-semibold rounded-md transition-all ${t==="annual"?"bg-background shadow-sm text-foreground":"text-muted-foreground hover:text-foreground"}`,children:o("ecommerce.annual")}),b&&r.jsx("button",{onClick:()=>d("lifetime"),className:`flex-1 py-1.5 text-xs font-semibold rounded-md transition-all ${t==="lifetime"?"bg-background shadow-sm text-foreground":"text-muted-foreground hover:text-foreground"}`,children:o("ecommerce.lifetime")})]}),r.jsxs("div",{className:"text-center",children:[r.jsx("span",{className:"text-3xl font-extrabold text-foreground",children:a.formatPrice(x,s)}),t!=="lifetime"&&r.jsxs("span",{className:"text-muted-foreground text-sm ml-1.5",children:["/ ",o(t==="annual"?"ecommerce.year":"ecommerce.month")]}),f&&r.jsxs("div",{className:"mt-1 text-xs font-medium text-emerald-600 dark:text-emerald-400",children:[f.label,r.jsx("span",{className:"mx-2 text-muted-foreground/50",children:"|"}),r.jsx("span",{className:"text-muted-foreground",children:f.paymentRequirementLabel})]})]}),r.jsxs($.Button,{onClick:P,className:"w-full h-12 text-md font-bold shadow-md transition-all hover:shadow-lg active:scale-[0.98]",children:[r.jsx(F.ShoppingCart,{className:"mr-2 h-4 w-4"}),f?.label?`Start ${f.label}`:o("ecommerce.get_license")]})]})};exports.SubscriptionSelector=O;