@nextblock-cms/ecom 0.20.3 → 0.21.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (446) hide show
  1. package/README.md +43 -0
  2. package/_virtual/_rolldown/runtime.cjs +1 -0
  3. package/index.cjs +1 -0
  4. package/index.es.js +38 -146
  5. package/lib/CurrencyProvider.cjs +1 -0
  6. package/lib/CurrencyProvider.d.ts +1 -1
  7. package/lib/CurrencyProvider.es.js +85 -95
  8. package/lib/PaymentReadinessProvider.cjs +1 -0
  9. package/lib/PaymentReadinessProvider.d.ts +1 -1
  10. package/lib/PaymentReadinessProvider.es.js +24 -27
  11. package/lib/cart-store.cjs +1 -0
  12. package/lib/cart-store.es.js +109 -121
  13. package/lib/components/AccountNavigationMenu.cjs +1 -0
  14. package/lib/components/AccountNavigationMenu.d.ts +1 -1
  15. package/lib/components/AccountNavigationMenu.es.js +36 -50
  16. package/lib/components/AddToCartButton.cjs +1 -0
  17. package/lib/components/AddToCartButton.d.ts +1 -1
  18. package/lib/components/AddToCartButton.es.js +94 -89
  19. package/lib/components/Cart.cjs +1 -0
  20. package/lib/components/Cart.d.ts +1 -1
  21. package/lib/components/Cart.es.js +261 -180
  22. package/lib/components/CartDrawer.cjs +1 -0
  23. package/lib/components/CartDrawer.d.ts +1 -1
  24. package/lib/components/CartDrawer.es.js +218 -148
  25. package/lib/components/CartIcon.cjs +1 -0
  26. package/lib/components/CartIcon.d.ts +1 -1
  27. package/lib/components/CartIcon.es.js +33 -35
  28. package/lib/components/Checkout.cjs +1 -0
  29. package/lib/components/Checkout.d.ts +1 -1
  30. package/lib/components/Checkout.es.js +1092 -1108
  31. package/lib/components/CouponForm.cjs +1 -0
  32. package/lib/components/CouponForm.d.ts +1 -1
  33. package/lib/components/CouponForm.es.js +136 -148
  34. package/lib/components/CurrencySwitcher.cjs +1 -0
  35. package/lib/components/CurrencySwitcher.d.ts +1 -1
  36. package/lib/components/CurrencySwitcher.es.js +22 -18
  37. package/lib/components/CustomerProfileForm.cjs +1 -0
  38. package/lib/components/CustomerProfileForm.es.js +454 -313
  39. package/lib/components/FeaturedProduct.cjs +1 -0
  40. package/lib/components/FeaturedProduct.d.ts +1 -1
  41. package/lib/components/FeaturedProduct.es.js +98 -83
  42. package/lib/components/FreemiusLicensePanel.cjs +1 -0
  43. package/lib/components/FreemiusLicensePanel.d.ts +1 -1
  44. package/lib/components/FreemiusLicensePanel.es.js +70 -65
  45. package/lib/components/InvoiceDocument.cjs +1 -0
  46. package/lib/components/InvoiceDocument.es.js +256 -192
  47. package/lib/components/InvoiceViewerShell.cjs +29 -0
  48. package/lib/components/InvoiceViewerShell.d.ts +1 -1
  49. package/lib/components/InvoiceViewerShell.es.js +75 -106
  50. package/lib/components/ProductCard.cjs +1 -0
  51. package/lib/components/ProductCard.d.ts +1 -1
  52. package/lib/components/ProductCard.es.js +186 -171
  53. package/lib/components/ProductDetailsLayout.cjs +1 -0
  54. package/lib/components/ProductDetailsLayout.es.js +405 -404
  55. package/lib/components/ProductGallery.cjs +1 -0
  56. package/lib/components/ProductGallery.d.ts +1 -1
  57. package/lib/components/ProductGallery.es.js +51 -54
  58. package/lib/components/ProductGrid.cjs +1 -0
  59. package/lib/components/ProductGrid.d.ts +1 -1
  60. package/lib/components/ProductGrid.es.js +23 -25
  61. package/lib/components/ShippingEstimator.cjs +1 -0
  62. package/lib/components/ShippingEstimator.d.ts +1 -1
  63. package/lib/components/ShippingEstimator.es.js +158 -153
  64. package/lib/components/ShortDescription.cjs +1 -0
  65. package/lib/components/ShortDescription.es.js +17 -17
  66. package/lib/components/SimpleTiptapRenderer.cjs +1 -0
  67. package/lib/components/SimpleTiptapRenderer.es.js +238 -211
  68. package/lib/components/SubscriptionSelector.cjs +1 -0
  69. package/lib/components/SubscriptionSelector.es.js +159 -154
  70. package/lib/countries.cjs +1 -0
  71. package/lib/countries.es.js +232 -75
  72. package/lib/coupon-server.cjs +1 -0
  73. package/lib/coupon-server.es.js +180 -224
  74. package/lib/coupons.cjs +1 -0
  75. package/lib/coupons.es.js +12 -14
  76. package/lib/currency-constants.cjs +1 -0
  77. package/lib/currency-constants.es.js +4 -4
  78. package/lib/currency-rest-client.cjs +1 -0
  79. package/lib/currency-rest-client.es.js +15 -22
  80. package/lib/currency-store.cjs +1 -0
  81. package/lib/currency-store.es.js +20 -27
  82. package/lib/currency-sync.cjs +1 -0
  83. package/lib/currency-sync.es.js +124 -170
  84. package/lib/currency.cjs +1 -0
  85. package/lib/currency.es.js +242 -310
  86. package/lib/customer-addresses.cjs +1 -0
  87. package/lib/customer-addresses.es.js +80 -109
  88. package/lib/customer-orders.cjs +1 -0
  89. package/lib/customer-orders.es.js +31 -43
  90. package/lib/customer.cjs +1 -0
  91. package/lib/customer.es.js +43 -52
  92. package/lib/export-helpers.cjs +1 -0
  93. package/lib/export-helpers.es.js +53 -52
  94. package/lib/factory.cjs +1 -0
  95. package/lib/factory.es.js +10 -7
  96. package/lib/freemius-coupons.cjs +1 -0
  97. package/lib/freemius-coupons.es.js +245 -262
  98. package/lib/freemius-license-claim.cjs +1 -0
  99. package/lib/freemius-license-claim.es.js +87 -71
  100. package/lib/freemius-license.cjs +1 -0
  101. package/lib/freemius-license.es.js +32 -39
  102. package/lib/freemius-order-sync.cjs +1 -0
  103. package/lib/freemius-order-sync.es.js +226 -290
  104. package/lib/freemius-trial-provision.cjs +1 -0
  105. package/lib/freemius-trial-provision.es.js +136 -130
  106. package/lib/inventory-settings.cjs +1 -0
  107. package/lib/inventory-settings.es.js +69 -77
  108. package/lib/invoice-server.cjs +33 -0
  109. package/lib/invoice-server.es.js +94 -141
  110. package/lib/invoice-ui.cjs +1 -0
  111. package/lib/invoice-ui.es.js +50 -66
  112. package/lib/invoice.cjs +1 -0
  113. package/lib/invoice.es.js +85 -94
  114. package/lib/order-inventory.cjs +61 -0
  115. package/lib/order-inventory.es.js +67 -79
  116. package/lib/order-tax-details.cjs +1 -0
  117. package/lib/order-tax-details.es.js +142 -153
  118. package/lib/pages/cms/coupons/CouponEditorForm.cjs +1 -0
  119. package/lib/pages/cms/coupons/CouponEditorForm.d.ts +1 -1
  120. package/lib/pages/cms/coupons/CouponEditorForm.es.js +227 -185
  121. package/lib/pages/cms/coupons/CouponsPage.cjs +5 -0
  122. package/lib/pages/cms/coupons/CouponsPage.d.ts +1 -1
  123. package/lib/pages/cms/coupons/CouponsPage.es.js +235 -166
  124. package/lib/pages/cms/coupons/CreateCouponDialog.cjs +1 -0
  125. package/lib/pages/cms/coupons/CreateCouponDialog.d.ts +1 -1
  126. package/lib/pages/cms/coupons/CreateCouponDialog.es.js +35 -34
  127. package/lib/pages/cms/coupons/EditCouponPage.cjs +1 -0
  128. package/lib/pages/cms/coupons/EditCouponPage.d.ts +1 -1
  129. package/lib/pages/cms/coupons/EditCouponPage.es.js +47 -47
  130. package/lib/pages/cms/coupons/ProductScopePicker.cjs +1 -0
  131. package/lib/pages/cms/coupons/ProductScopePicker.d.ts +1 -1
  132. package/lib/pages/cms/coupons/ProductScopePicker.es.js +128 -117
  133. package/lib/pages/cms/coupons/actions.cjs +1 -0
  134. package/lib/pages/cms/coupons/actions.es.js +112 -115
  135. package/lib/pages/cms/coupons/index.cjs +1 -0
  136. package/lib/pages/cms/coupons/index.es.js +3 -0
  137. package/lib/pages/cms/coupons/product-options.cjs +1 -0
  138. package/lib/pages/cms/coupons/product-options.es.js +21 -23
  139. package/lib/pages/cms/orders/ExportReportsDialog.cjs +1 -0
  140. package/lib/pages/cms/orders/ExportReportsDialog.es.js +135 -129
  141. package/lib/pages/cms/orders/MarkPaidButton.d.ts +1 -1
  142. package/lib/pages/cms/orders/OrderDetailPage.cjs +1 -0
  143. package/lib/pages/cms/orders/OrderDetailPage.d.ts +1 -1
  144. package/lib/pages/cms/orders/OrderDetailPage.es.js +186 -134
  145. package/lib/pages/cms/orders/OrderPrintButton.cjs +1 -0
  146. package/lib/pages/cms/orders/OrderPrintButton.d.ts +1 -1
  147. package/lib/pages/cms/orders/OrderPrintButton.es.js +15 -21
  148. package/lib/pages/cms/orders/OrderStatusForm.cjs +1 -0
  149. package/lib/pages/cms/orders/OrderStatusForm.d.ts +1 -1
  150. package/lib/pages/cms/orders/OrderStatusForm.es.js +85 -69
  151. package/lib/pages/cms/orders/OrdersPage.cjs +1 -0
  152. package/lib/pages/cms/orders/OrdersPage.d.ts +1 -1
  153. package/lib/pages/cms/orders/OrdersPage.es.js +170 -102
  154. package/lib/pages/cms/orders/actions.cjs +7 -0
  155. package/lib/pages/cms/orders/actions.es.js +53 -69
  156. package/lib/pages/cms/orders/export-actions.cjs +1 -0
  157. package/lib/pages/cms/orders/export-actions.es.js +23 -26
  158. package/lib/pages/cms/orders/index.cjs +1 -0
  159. package/lib/pages/cms/orders/index.es.js +6 -0
  160. package/lib/pages/cms/orders/server-actions.cjs +1 -0
  161. package/lib/pages/cms/orders/server-actions.es.js +60 -51
  162. package/lib/pages/cms/payments/PaymentsClient.cjs +1 -0
  163. package/lib/pages/cms/payments/PaymentsClient.d.ts +1 -1
  164. package/lib/pages/cms/payments/PaymentsClient.es.js +316 -346
  165. package/lib/pages/cms/payments/PaymentsPage.cjs +1 -0
  166. package/lib/pages/cms/payments/PaymentsPage.d.ts +1 -1
  167. package/lib/pages/cms/payments/PaymentsPage.es.js +29 -32
  168. package/lib/pages/cms/payments/actions.cjs +1 -0
  169. package/lib/pages/cms/payments/actions.es.js +38 -48
  170. package/lib/pages/cms/payments/index.cjs +1 -0
  171. package/lib/pages/cms/payments/index.es.js +3 -0
  172. package/lib/pages/cms/payments/queries.cjs +1 -0
  173. package/lib/pages/cms/payments/queries.es.js +38 -48
  174. package/lib/pages/cms/products/ProductsPage.cjs +1 -0
  175. package/lib/pages/cms/products/ProductsPage.d.ts +1 -1
  176. package/lib/pages/cms/products/ProductsPage.es.js +63 -66
  177. package/lib/pages/cms/products/[id]/edit/EditProductPage.cjs +1 -0
  178. package/lib/pages/cms/products/[id]/edit/EditProductPage.d.ts +1 -1
  179. package/lib/pages/cms/products/[id]/edit/EditProductPage.es.js +139 -0
  180. package/lib/pages/cms/products/actions.cjs +44 -0
  181. package/lib/pages/cms/products/actions.es.js +121 -162
  182. package/lib/pages/cms/products/attributes/AttributeManagementPage.cjs +1 -0
  183. package/lib/pages/cms/products/attributes/AttributeManagementPage.d.ts +1 -1
  184. package/lib/pages/cms/products/attributes/AttributeManagementPage.es.js +55 -47
  185. package/lib/pages/cms/products/attributes/components/AttributeManager.cjs +1 -0
  186. package/lib/pages/cms/products/attributes/components/AttributeManager.d.ts +1 -1
  187. package/lib/pages/cms/products/attributes/components/AttributeManager.es.js +285 -290
  188. package/lib/pages/cms/products/categories/CategoryManagementPage.cjs +1 -0
  189. package/lib/pages/cms/products/categories/CategoryManagementPage.d.ts +1 -1
  190. package/lib/pages/cms/products/categories/CategoryManagementPage.es.js +43 -35
  191. package/lib/pages/cms/products/categories/components/CategoryManager.cjs +1 -0
  192. package/lib/pages/cms/products/categories/components/CategoryManager.es.js +315 -262
  193. package/lib/pages/cms/products/components/CopyProductFromLanguage.cjs +1 -0
  194. package/lib/pages/cms/products/components/CopyProductFromLanguage.es.js +115 -113
  195. package/lib/pages/cms/products/components/CurrencyPriceFields.cjs +1 -0
  196. package/lib/pages/cms/products/components/CurrencyPriceFields.d.ts +1 -1
  197. package/lib/pages/cms/products/components/CurrencyPriceFields.es.js +136 -145
  198. package/lib/pages/cms/products/components/DeleteProductButton.cjs +1 -0
  199. package/lib/pages/cms/products/components/DeleteProductButton.d.ts +1 -1
  200. package/lib/pages/cms/products/components/DeleteProductButton.es.js +35 -47
  201. package/lib/pages/cms/products/components/FreemiusPricingDashboard.cjs +1 -0
  202. package/lib/pages/cms/products/components/FreemiusPricingDashboard.d.ts +1 -1
  203. package/lib/pages/cms/products/components/FreemiusPricingDashboard.es.js +106 -84
  204. package/lib/pages/cms/products/components/ProductCategorySelector.cjs +1 -0
  205. package/lib/pages/cms/products/components/ProductCategorySelector.es.js +156 -159
  206. package/lib/pages/cms/products/components/ProductForm.cjs +1 -0
  207. package/lib/pages/cms/products/components/ProductForm.es.js +872 -693
  208. package/lib/pages/cms/products/components/ProductMediaManager.cjs +1 -0
  209. package/lib/pages/cms/products/components/ProductMediaManager.es.js +106 -103
  210. package/lib/pages/cms/products/components/ProductsBulkTable.cjs +1 -0
  211. package/lib/pages/cms/products/components/ProductsBulkTable.d.ts +1 -1
  212. package/lib/pages/cms/products/components/ProductsBulkTable.es.js +303 -294
  213. package/lib/pages/cms/products/components/SaleScheduleFields.cjs +1 -0
  214. package/lib/pages/cms/products/components/SaleScheduleFields.d.ts +1 -1
  215. package/lib/pages/cms/products/components/SaleScheduleFields.es.js +111 -134
  216. package/lib/pages/cms/products/components/SyncFreemiusButton.cjs +1 -0
  217. package/lib/pages/cms/products/components/SyncFreemiusButton.d.ts +1 -1
  218. package/lib/pages/cms/products/components/SyncFreemiusButton.es.js +29 -35
  219. package/lib/pages/cms/products/components/SyncFreemiusPricingButton.cjs +5 -0
  220. package/lib/pages/cms/products/components/SyncFreemiusPricingButton.d.ts +1 -1
  221. package/lib/pages/cms/products/components/SyncFreemiusPricingButton.es.js +36 -48
  222. package/lib/pages/cms/products/components/SyncProductForm.d.ts +1 -1
  223. package/lib/pages/cms/products/components/VariationsEditor.cjs +1 -0
  224. package/lib/pages/cms/products/components/VariationsEditor.d.ts +1 -1
  225. package/lib/pages/cms/products/components/VariationsEditor.es.js +396 -405
  226. package/lib/pages/cms/products/index.cjs +1 -0
  227. package/lib/pages/cms/products/index.es.js +8 -0
  228. package/lib/pages/cms/products/inventory/InventoryPage.cjs +1 -0
  229. package/lib/pages/cms/products/inventory/InventoryPage.d.ts +1 -1
  230. package/lib/pages/cms/products/inventory/InventoryPage.es.js +21 -15
  231. package/lib/pages/cms/products/inventory/InventoryTableClient.cjs +2 -0
  232. package/lib/pages/cms/products/inventory/InventoryTableClient.d.ts +1 -1
  233. package/lib/pages/cms/products/inventory/InventoryTableClient.es.js +230 -209
  234. package/lib/pages/cms/products/inventory/actions.cjs +3 -0
  235. package/lib/pages/cms/products/inventory/actions.es.js +83 -91
  236. package/lib/pages/cms/products/new/NewProductPage.cjs +1 -0
  237. package/lib/pages/cms/products/new/NewProductPage.d.ts +1 -1
  238. package/lib/pages/cms/products/new/NewProductPage.es.js +58 -74
  239. package/lib/pages/cms/products/product-price-sync.cjs +1 -0
  240. package/lib/pages/cms/products/product-price-sync.es.js +74 -89
  241. package/lib/pages/cms/products/server-actions.cjs +1 -0
  242. package/lib/pages/cms/products/server-actions.es.js +250 -233
  243. package/lib/pages/cms/shipping/ShippingPage.cjs +5 -0
  244. package/lib/pages/cms/shipping/ShippingPage.es.js +287 -209
  245. package/lib/pages/cms/shipping/components/RateForm.cjs +1 -0
  246. package/lib/pages/cms/shipping/components/RateForm.d.ts +1 -1
  247. package/lib/pages/cms/shipping/components/RateForm.es.js +439 -436
  248. package/lib/pages/cms/shipping/components/ZoneForm.cjs +1 -0
  249. package/lib/pages/cms/shipping/components/ZoneForm.es.js +245 -224
  250. package/lib/pages/cms/shipping/index.cjs +1 -0
  251. package/lib/pages/cms/shipping/index.es.js +3 -0
  252. package/lib/pages/cms/shipping/server-actions.cjs +1 -0
  253. package/lib/pages/cms/shipping/server-actions.es.js +131 -149
  254. package/lib/pages/cms/taxes/TaxesPage.cjs +1 -0
  255. package/lib/pages/cms/taxes/TaxesPage.d.ts +1 -1
  256. package/lib/pages/cms/taxes/TaxesPage.es.js +211 -169
  257. package/lib/pages/cms/taxes/actions.cjs +1 -0
  258. package/lib/pages/cms/taxes/actions.es.js +41 -53
  259. package/lib/pages/cms/taxes/components/TaxRateForm.cjs +1 -0
  260. package/lib/pages/cms/taxes/components/TaxRateForm.d.ts +1 -1
  261. package/lib/pages/cms/taxes/components/TaxRateForm.es.js +112 -99
  262. package/lib/pages/cms/taxes/index.cjs +1 -0
  263. package/lib/pages/cms/taxes/index.es.js +3 -0
  264. package/lib/payment-config.cjs +1 -0
  265. package/lib/payment-config.es.js +110 -126
  266. package/lib/product-actions.cjs +238 -0
  267. package/lib/product-actions.es.js +289 -544
  268. package/lib/product-context.cjs +1 -0
  269. package/lib/product-context.es.js +13 -15
  270. package/lib/product-schema.cjs +1 -0
  271. package/lib/product-schema.es.js +99 -134
  272. package/lib/providers/freemius.cjs +1 -0
  273. package/lib/providers/freemius.es.js +446 -530
  274. package/lib/providers/stripe.cjs +1 -0
  275. package/lib/providers/stripe.es.js +417 -477
  276. package/lib/server-actions/coupon-actions.cjs +1 -0
  277. package/lib/server-actions/coupon-actions.es.js +22 -22
  278. package/lib/server-actions/customer-actions.cjs +1 -0
  279. package/lib/server-actions/customer-actions.es.js +26 -28
  280. package/lib/server-actions/product-actions.cjs +1 -0
  281. package/lib/server-actions/product-actions.es.js +9 -15
  282. package/lib/server-actions/shipping-actions.cjs +1 -0
  283. package/lib/server-actions/shipping-actions.es.js +27 -24
  284. package/lib/server-actions/tax-actions.cjs +1 -0
  285. package/lib/server-actions/tax-actions.es.js +33 -39
  286. package/lib/shared-inventory.cjs +15 -0
  287. package/lib/shared-inventory.es.js +111 -160
  288. package/lib/shipping/resolver.cjs +7 -0
  289. package/lib/shipping/resolver.es.js +44 -61
  290. package/lib/shipping-rate-currency.cjs +1 -0
  291. package/lib/shipping-rate-currency.es.js +52 -67
  292. package/lib/states.cjs +1 -0
  293. package/lib/states.es.js +333 -154
  294. package/lib/stripe/checkout.cjs +1 -0
  295. package/lib/stripe/checkout.es.js +125 -181
  296. package/lib/stripe/client.cjs +1 -0
  297. package/lib/stripe/client.es.js +14 -19
  298. package/lib/stripe/order-sync.cjs +1 -0
  299. package/lib/stripe/order-sync.es.js +106 -126
  300. package/lib/stripe/webhooks.cjs +1 -0
  301. package/lib/stripe/webhooks.es.js +37 -31
  302. package/lib/tax-calculation.cjs +1 -0
  303. package/lib/tax-calculation.es.js +84 -98
  304. package/lib/trials.cjs +1 -0
  305. package/lib/trials.es.js +24 -30
  306. package/lib/types.cjs +1 -0
  307. package/lib/types.es.js +21 -27
  308. package/lib/use-cart.cjs +1 -0
  309. package/lib/use-cart.es.js +38 -40
  310. package/lib/use-price-formatter.cjs +1 -0
  311. package/lib/use-price-formatter.es.js +10 -11
  312. package/lib/variation-utils.cjs +1 -0
  313. package/lib/variation-utils.es.js +199 -261
  314. package/lib/zod-config.cjs +1 -0
  315. package/lib/zod-config.es.js +5 -6
  316. package/package.json +22 -21
  317. package/server.cjs +1 -0
  318. package/server.es.js +56 -211
  319. package/index.cjs.js +0 -1
  320. package/lib/CurrencyProvider.cjs.js +0 -1
  321. package/lib/PaymentReadinessProvider.cjs.js +0 -1
  322. package/lib/cart-store.cjs.js +0 -1
  323. package/lib/components/AccountNavigationMenu.cjs.js +0 -1
  324. package/lib/components/AddToCartButton.cjs.js +0 -1
  325. package/lib/components/Cart.cjs.js +0 -1
  326. package/lib/components/CartDrawer.cjs.js +0 -1
  327. package/lib/components/CartIcon.cjs.js +0 -1
  328. package/lib/components/Checkout.cjs.js +0 -1
  329. package/lib/components/CouponForm.cjs.js +0 -1
  330. package/lib/components/CurrencySwitcher.cjs.js +0 -1
  331. package/lib/components/CustomerProfileForm.cjs.js +0 -1
  332. package/lib/components/FeaturedProduct.cjs.js +0 -1
  333. package/lib/components/FreemiusLicensePanel.cjs.js +0 -1
  334. package/lib/components/InvoiceDocument.cjs.js +0 -1
  335. package/lib/components/InvoiceViewerShell.cjs.js +0 -29
  336. package/lib/components/ProductCard.cjs.js +0 -1
  337. package/lib/components/ProductDetailsLayout.cjs.js +0 -1
  338. package/lib/components/ProductGallery.cjs.js +0 -1
  339. package/lib/components/ProductGrid.cjs.js +0 -1
  340. package/lib/components/ShippingEstimator.cjs.js +0 -1
  341. package/lib/components/ShortDescription.cjs.js +0 -1
  342. package/lib/components/SimpleTiptapRenderer.cjs.js +0 -1
  343. package/lib/components/SubscriptionSelector.cjs.js +0 -1
  344. package/lib/countries.cjs.js +0 -1
  345. package/lib/coupon-server.cjs.js +0 -1
  346. package/lib/coupons.cjs.js +0 -1
  347. package/lib/currency-constants.cjs.js +0 -1
  348. package/lib/currency-rest-client.cjs.js +0 -1
  349. package/lib/currency-store.cjs.js +0 -1
  350. package/lib/currency-sync.cjs.js +0 -1
  351. package/lib/currency.cjs.js +0 -1
  352. package/lib/customer-addresses.cjs.js +0 -1
  353. package/lib/customer-orders.cjs.js +0 -1
  354. package/lib/customer.cjs.js +0 -1
  355. package/lib/export-helpers.cjs.js +0 -1
  356. package/lib/factory.cjs.js +0 -1
  357. package/lib/freemius-coupons.cjs.js +0 -1
  358. package/lib/freemius-license-claim.cjs.js +0 -1
  359. package/lib/freemius-license.cjs.js +0 -1
  360. package/lib/freemius-order-sync.cjs.js +0 -1
  361. package/lib/freemius-trial-provision.cjs.js +0 -1
  362. package/lib/inventory-settings.cjs.js +0 -1
  363. package/lib/invoice-server.cjs.js +0 -33
  364. package/lib/invoice-ui.cjs.js +0 -1
  365. package/lib/invoice.cjs.js +0 -1
  366. package/lib/order-inventory.cjs.js +0 -61
  367. package/lib/order-tax-details.cjs.js +0 -1
  368. package/lib/pages/cms/coupons/CouponEditorForm.cjs.js +0 -1
  369. package/lib/pages/cms/coupons/CouponsPage.cjs.js +0 -5
  370. package/lib/pages/cms/coupons/CreateCouponDialog.cjs.js +0 -1
  371. package/lib/pages/cms/coupons/EditCouponPage.cjs.js +0 -1
  372. package/lib/pages/cms/coupons/ProductScopePicker.cjs.js +0 -1
  373. package/lib/pages/cms/coupons/actions.cjs.js +0 -1
  374. package/lib/pages/cms/coupons/product-options.cjs.js +0 -1
  375. package/lib/pages/cms/orders/ExportReportsDialog.cjs.js +0 -1
  376. package/lib/pages/cms/orders/OrderDetailPage.cjs.js +0 -1
  377. package/lib/pages/cms/orders/OrderPrintButton.cjs.js +0 -1
  378. package/lib/pages/cms/orders/OrderStatusForm.cjs.js +0 -1
  379. package/lib/pages/cms/orders/OrdersPage.cjs.js +0 -1
  380. package/lib/pages/cms/orders/actions.cjs.js +0 -7
  381. package/lib/pages/cms/orders/export-actions.cjs.js +0 -1
  382. package/lib/pages/cms/orders/server-actions.cjs.js +0 -1
  383. package/lib/pages/cms/payments/PaymentsClient.cjs.js +0 -1
  384. package/lib/pages/cms/payments/PaymentsPage.cjs.js +0 -1
  385. package/lib/pages/cms/payments/actions.cjs.js +0 -1
  386. package/lib/pages/cms/payments/queries.cjs.js +0 -1
  387. package/lib/pages/cms/products/ProductsPage.cjs.js +0 -1
  388. package/lib/pages/cms/products/_id_/edit/EditProductPage.cjs.js +0 -1
  389. package/lib/pages/cms/products/_id_/edit/EditProductPage.es.js +0 -156
  390. package/lib/pages/cms/products/actions.cjs.js +0 -44
  391. package/lib/pages/cms/products/attributes/AttributeManagementPage.cjs.js +0 -1
  392. package/lib/pages/cms/products/attributes/components/AttributeManager.cjs.js +0 -1
  393. package/lib/pages/cms/products/categories/CategoryManagementPage.cjs.js +0 -1
  394. package/lib/pages/cms/products/categories/components/CategoryManager.cjs.js +0 -1
  395. package/lib/pages/cms/products/components/CopyProductFromLanguage.cjs.js +0 -1
  396. package/lib/pages/cms/products/components/CurrencyPriceFields.cjs.js +0 -1
  397. package/lib/pages/cms/products/components/DeleteProductButton.cjs.js +0 -1
  398. package/lib/pages/cms/products/components/FreemiusPricingDashboard.cjs.js +0 -1
  399. package/lib/pages/cms/products/components/ProductCategorySelector.cjs.js +0 -1
  400. package/lib/pages/cms/products/components/ProductForm.cjs.js +0 -1
  401. package/lib/pages/cms/products/components/ProductMediaManager.cjs.js +0 -1
  402. package/lib/pages/cms/products/components/ProductsBulkTable.cjs.js +0 -1
  403. package/lib/pages/cms/products/components/SaleScheduleFields.cjs.js +0 -1
  404. package/lib/pages/cms/products/components/SyncFreemiusButton.cjs.js +0 -1
  405. package/lib/pages/cms/products/components/SyncFreemiusPricingButton.cjs.js +0 -5
  406. package/lib/pages/cms/products/components/VariationsEditor.cjs.js +0 -1
  407. package/lib/pages/cms/products/inventory/InventoryPage.cjs.js +0 -1
  408. package/lib/pages/cms/products/inventory/InventoryTableClient.cjs.js +0 -2
  409. package/lib/pages/cms/products/inventory/actions.cjs.js +0 -3
  410. package/lib/pages/cms/products/new/NewProductPage.cjs.js +0 -1
  411. package/lib/pages/cms/products/product-price-sync.cjs.js +0 -1
  412. package/lib/pages/cms/products/server-actions.cjs.js +0 -1
  413. package/lib/pages/cms/shipping/ShippingPage.cjs.js +0 -5
  414. package/lib/pages/cms/shipping/components/RateForm.cjs.js +0 -1
  415. package/lib/pages/cms/shipping/components/ZoneForm.cjs.js +0 -1
  416. package/lib/pages/cms/shipping/server-actions.cjs.js +0 -1
  417. package/lib/pages/cms/taxes/TaxesPage.cjs.js +0 -1
  418. package/lib/pages/cms/taxes/actions.cjs.js +0 -1
  419. package/lib/pages/cms/taxes/components/TaxRateForm.cjs.js +0 -1
  420. package/lib/payment-config.cjs.js +0 -1
  421. package/lib/product-actions.cjs.js +0 -238
  422. package/lib/product-context.cjs.js +0 -1
  423. package/lib/product-schema.cjs.js +0 -1
  424. package/lib/providers/freemius.cjs.js +0 -5
  425. package/lib/providers/stripe.cjs.js +0 -1
  426. package/lib/server-actions/coupon-actions.cjs.js +0 -1
  427. package/lib/server-actions/customer-actions.cjs.js +0 -1
  428. package/lib/server-actions/product-actions.cjs.js +0 -1
  429. package/lib/server-actions/shipping-actions.cjs.js +0 -1
  430. package/lib/server-actions/tax-actions.cjs.js +0 -1
  431. package/lib/shared-inventory.cjs.js +0 -15
  432. package/lib/shipping/resolver.cjs.js +0 -7
  433. package/lib/shipping-rate-currency.cjs.js +0 -1
  434. package/lib/states.cjs.js +0 -1
  435. package/lib/stripe/checkout.cjs.js +0 -1
  436. package/lib/stripe/client.cjs.js +0 -1
  437. package/lib/stripe/order-sync.cjs.js +0 -1
  438. package/lib/stripe/webhooks.cjs.js +0 -1
  439. package/lib/tax-calculation.cjs.js +0 -1
  440. package/lib/trials.cjs.js +0 -1
  441. package/lib/types.cjs.js +0 -1
  442. package/lib/use-cart.cjs.js +0 -1
  443. package/lib/use-price-formatter.cjs.js +0 -1
  444. package/lib/variation-utils.cjs.js +0 -1
  445. package/lib/zod-config.cjs.js +0 -1
  446. package/server.cjs.js +0 -1
@@ -1,312 +1,244 @@
1
- import { normalizeCurrencyCode as u, getCurrencyMinorUnitFactor as g, majorUnitAmountToMinor as x, formatPrice as _, minorUnitAmountToMajor as N } from "@nextblock-cms/utils";
2
- const R = [
3
- "none",
4
- "nearest",
5
- "up",
6
- "down",
7
- "charm"
8
- ], E = {
9
- AU: "AUD",
10
- CA: "CAD",
11
- CH: "CHF",
12
- CZ: "CZK",
13
- DE: "EUR",
14
- DK: "DKK",
15
- ES: "EUR",
16
- EU: "EUR",
17
- FI: "EUR",
18
- FR: "EUR",
19
- GB: "GBP",
20
- IE: "EUR",
21
- IN: "INR",
22
- IT: "EUR",
23
- JP: "JPY",
24
- MX: "MXN",
25
- NL: "EUR",
26
- NO: "NOK",
27
- NZ: "NZD",
28
- PL: "PLN",
29
- PT: "EUR",
30
- SE: "SEK",
31
- SG: "SGD",
32
- US: "USD"
1
+ import { formatPrice as e, getCurrencyMinorUnitFactor as t, majorUnitAmountToMinor as n, minorUnitAmountToMajor as r, normalizeCurrencyCode as i } from "@nextblock-cms/utils";
2
+ //#region src/lib/currency.ts
3
+ var a = [
4
+ "none",
5
+ "nearest",
6
+ "up",
7
+ "down",
8
+ "charm"
9
+ ], o = {
10
+ AU: "AUD",
11
+ CA: "CAD",
12
+ CH: "CHF",
13
+ CZ: "CZK",
14
+ DE: "EUR",
15
+ DK: "DKK",
16
+ ES: "EUR",
17
+ EU: "EUR",
18
+ FI: "EUR",
19
+ FR: "EUR",
20
+ GB: "GBP",
21
+ IE: "EUR",
22
+ IN: "INR",
23
+ IT: "EUR",
24
+ JP: "JPY",
25
+ MX: "MXN",
26
+ NL: "EUR",
27
+ NO: "NOK",
28
+ NZ: "NZD",
29
+ PL: "PLN",
30
+ PT: "EUR",
31
+ SE: "SEK",
32
+ SG: "SGD",
33
+ US: "USD"
33
34
  };
34
- function y(n) {
35
- return typeof n == "number" && Number.isFinite(n);
36
- }
37
- function P(n, e = 1) {
38
- const r = typeof n == "string" ? Number.parseInt(n, 10) : n;
39
- return typeof r == "number" && Number.isFinite(r) && r > 0 ? Math.max(1, Math.round(r)) : e;
40
- }
41
- function F(n) {
42
- const e = typeof n == "string" ? Number.parseInt(n, 10) : n;
43
- return typeof e == "number" && Number.isFinite(e) && e >= 0 ? Math.round(e) : null;
44
- }
45
- function z(n) {
46
- if (typeof n == "string") {
47
- const e = n.trim().toLowerCase();
48
- if (R.includes(e))
49
- return e;
50
- }
51
- return "none";
52
- }
53
- function l(n) {
54
- const e = n || {}, r = u(
55
- typeof e.code == "string" ? e.code : null
56
- ), t = e.is_default === !0;
57
- return {
58
- code: r,
59
- symbol: typeof e.symbol == "string" && e.symbol.trim() ? e.symbol.trim() : r,
60
- exchange_rate: t ? 1 : y(e.exchange_rate) && e.exchange_rate > 0 ? e.exchange_rate : 1,
61
- is_default: t,
62
- is_active: e.is_active !== !1,
63
- auto_sync_product_prices: t ? !1 : e.auto_sync_product_prices === !0,
64
- rounding_mode: z(e.rounding_mode),
65
- rounding_increment: P(e.rounding_increment, 1),
66
- rounding_charm_amount: F(e.rounding_charm_amount),
67
- auto_update_exchange_rate: t ? !1 : e.auto_update_exchange_rate !== !1,
68
- exchange_rate_source: typeof e.exchange_rate_source == "string" && e.exchange_rate_source.trim() ? e.exchange_rate_source.trim() : null,
69
- exchange_rate_updated_at: typeof e.exchange_rate_updated_at == "string" && e.exchange_rate_updated_at.trim() ? e.exchange_rate_updated_at : null
70
- };
71
- }
72
- function C(n) {
73
- return !n || typeof n != "object" || Array.isArray(n) ? {} : Object.entries(n).reduce(
74
- (e, [r, t]) => {
75
- const c = u(r), o = typeof t == "string" ? Number.parseFloat(t) : t;
76
- return y(o) && o >= 0 && (e[c] = Math.round(o)), e;
77
- },
78
- {}
79
- );
80
- }
81
- function U(n) {
82
- return !n || typeof n != "object" || Array.isArray(n) ? {} : Object.entries(n).reduce(
83
- (e, [r, t]) => {
84
- const c = u(r), o = typeof t == "string" ? Number.parseFloat(t) : t;
85
- return o === null ? (e[c] = null, e) : (y(o) && o >= 0 && (e[c] = Math.round(o)), e);
86
- },
87
- {}
88
- );
89
- }
90
- function f(n) {
91
- return n.map(l).find((e) => e.is_default) ?? l(n[0]) ?? l({
92
- code: "USD",
93
- symbol: "$",
94
- exchange_rate: 1,
95
- is_default: !0,
96
- is_active: !0
97
- });
98
- }
99
- function h(n) {
100
- return n.reduce((e, r) => {
101
- const t = l(r);
102
- return e[t.code] = t, e;
103
- }, {});
104
- }
105
- function O(n, e) {
106
- const r = u(e), t = f(n);
107
- return h(n)[r]?.exchange_rate ?? (r === t.code, 1);
108
- }
109
- function A(n) {
110
- const { amount: e, currencies: r } = n, t = u(n.fromCurrencyCode), c = u(n.toCurrencyCode);
111
- if (!Number.isFinite(e))
112
- return 0;
113
- if (t === c)
114
- return Math.round(e);
115
- const o = h(r), i = f(r), a = o[t]?.exchange_rate ?? (t === i.code ? 1 : i.exchange_rate), d = o[c]?.exchange_rate ?? (c === i.code ? 1 : i.exchange_rate), M = e / g(t) / a * d, p = x(M, c);
116
- return n.applyRounding ? S({
117
- amount: p,
118
- currencyCode: c,
119
- currencies: r
120
- }) : p;
121
- }
122
- function S(n) {
123
- const e = Math.max(0, Math.round(n.amount)), r = u(n.currencyCode), c = h(n.currencies)[r] ?? l(f(n.currencies)), o = P(c.rounding_increment, 1);
124
- if (c.rounding_mode === "nearest")
125
- return Math.round(e / o) * o;
126
- if (c.rounding_mode === "up")
127
- return Math.ceil(e / o) * o;
128
- if (c.rounding_mode === "down")
129
- return Math.floor(e / o) * o;
130
- if (c.rounding_mode === "charm") {
131
- const i = g(c.code), a = Math.min(
132
- Math.max(c.rounding_charm_amount ?? 0, 0),
133
- Math.max(i - 1, 0)
134
- );
135
- let s = Math.floor(e / i) * i + a;
136
- return s < e && (s += i), s;
137
- }
138
- return e;
35
+ function s(e) {
36
+ return typeof e == "number" && Number.isFinite(e);
37
+ }
38
+ function c(e, t = 1) {
39
+ let n = typeof e == "string" ? Number.parseInt(e, 10) : e;
40
+ return typeof n == "number" && Number.isFinite(n) && n > 0 ? Math.max(1, Math.round(n)) : t;
41
+ }
42
+ function l(e) {
43
+ let t = typeof e == "string" ? Number.parseInt(e, 10) : e;
44
+ return typeof t == "number" && Number.isFinite(t) && t >= 0 ? Math.round(t) : null;
45
+ }
46
+ function u(e) {
47
+ if (typeof e == "string") {
48
+ let t = e.trim().toLowerCase();
49
+ if (a.includes(t)) return t;
50
+ }
51
+ return "none";
52
+ }
53
+ function d(e) {
54
+ let t = e || {}, n = i(typeof t.code == "string" ? t.code : null), r = t.is_default === !0;
55
+ return {
56
+ code: n,
57
+ symbol: typeof t.symbol == "string" && t.symbol.trim() ? t.symbol.trim() : n,
58
+ exchange_rate: r ? 1 : s(t.exchange_rate) && t.exchange_rate > 0 ? t.exchange_rate : 1,
59
+ is_default: r,
60
+ is_active: t.is_active !== !1,
61
+ auto_sync_product_prices: !r && t.auto_sync_product_prices === !0,
62
+ rounding_mode: u(t.rounding_mode),
63
+ rounding_increment: c(t.rounding_increment, 1),
64
+ rounding_charm_amount: l(t.rounding_charm_amount),
65
+ auto_update_exchange_rate: !r && t.auto_update_exchange_rate !== !1,
66
+ exchange_rate_source: typeof t.exchange_rate_source == "string" && t.exchange_rate_source.trim() ? t.exchange_rate_source.trim() : null,
67
+ exchange_rate_updated_at: typeof t.exchange_rate_updated_at == "string" && t.exchange_rate_updated_at.trim() ? t.exchange_rate_updated_at : null
68
+ };
69
+ }
70
+ function f(e) {
71
+ return !e || typeof e != "object" || Array.isArray(e) ? {} : Object.entries(e).reduce((e, [t, n]) => {
72
+ let r = i(t), a = typeof n == "string" ? Number.parseFloat(n) : n;
73
+ return s(a) && a >= 0 && (e[r] = Math.round(a)), e;
74
+ }, {});
75
+ }
76
+ function p(e) {
77
+ return !e || typeof e != "object" || Array.isArray(e) ? {} : Object.entries(e).reduce((e, [t, n]) => {
78
+ let r = i(t), a = typeof n == "string" ? Number.parseFloat(n) : n;
79
+ return a === null ? (e[r] = null, e) : (s(a) && a >= 0 && (e[r] = Math.round(a)), e);
80
+ }, {});
81
+ }
82
+ function m(e) {
83
+ return e.map(d).find((e) => e.is_default) ?? d(e[0]) ?? d({
84
+ code: "USD",
85
+ symbol: "$",
86
+ exchange_rate: 1,
87
+ is_default: !0,
88
+ is_active: !0
89
+ });
90
+ }
91
+ function h(e) {
92
+ return e.reduce((e, t) => {
93
+ let n = d(t);
94
+ return e[n.code] = n, e;
95
+ }, {});
96
+ }
97
+ function g(e, t) {
98
+ let n = i(t), r = m(e);
99
+ return h(e)[n]?.exchange_rate ?? (r.code, 1);
100
+ }
101
+ function _(e) {
102
+ let { amount: r, currencies: a } = e, o = i(e.fromCurrencyCode), s = i(e.toCurrencyCode);
103
+ if (!Number.isFinite(r)) return 0;
104
+ if (o === s) return Math.round(r);
105
+ let c = h(a), l = m(a), u = c[o]?.exchange_rate ?? (o === l.code ? 1 : l.exchange_rate), d = c[s]?.exchange_rate ?? (s === l.code ? 1 : l.exchange_rate), f = r / t(o) / u * d, p = n(f, s);
106
+ return e.applyRounding ? v({
107
+ amount: p,
108
+ currencyCode: s,
109
+ currencies: a
110
+ }) : p;
111
+ }
112
+ function v(e) {
113
+ let n = Math.max(0, Math.round(e.amount)), r = i(e.currencyCode), a = h(e.currencies)[r] ?? d(m(e.currencies)), o = c(a.rounding_increment, 1);
114
+ if (a.rounding_mode === "nearest") return Math.round(n / o) * o;
115
+ if (a.rounding_mode === "up") return Math.ceil(n / o) * o;
116
+ if (a.rounding_mode === "down") return Math.floor(n / o) * o;
117
+ if (a.rounding_mode === "charm") {
118
+ let e = t(a.code), r = Math.min(Math.max(a.rounding_charm_amount ?? 0, 0), Math.max(e - 1, 0)), i = Math.floor(n / e) * e + r;
119
+ return i < n && (i += e), i;
120
+ }
121
+ return n;
139
122
  }
140
- function T(n) {
141
- const e = l(n);
142
- if (e.rounding_mode === "nearest")
143
- return `Nearest ${_(
144
- e.rounding_increment ?? 1,
145
- e.code
146
- )}`;
147
- if (e.rounding_mode === "up")
148
- return `Round up to ${_(
149
- e.rounding_increment ?? 1,
150
- e.code
151
- )}`;
152
- if (e.rounding_mode === "down")
153
- return `Round down to ${_(
154
- e.rounding_increment ?? 1,
155
- e.code
156
- )}`;
157
- if (e.rounding_mode === "charm") {
158
- const r = e.rounding_charm_amount ?? 0;
159
- return `Charm ending ${_(r, e.code)}`;
160
- }
161
- return `Exact conversion (${N(1, e.code).toFixed(
162
- g(e.code) === 1 ? 0 : 2
163
- )} step)`;
164
- }
165
- function k(n, e) {
166
- const r = f(e);
167
- return n[r.code] !== void 0 ? r.code : Object.keys(n)[0] ?? r.code;
168
- }
169
- function b(n) {
170
- const { amountMap: e, fallbackAmount: r, currencies: t } = n, c = u(n.currencyCode), o = C(e);
171
- if (o[c] !== void 0)
172
- return o[c];
173
- if (Object.keys(o).length > 0) {
174
- const i = k(o, t), a = o[i];
175
- if (a !== void 0)
176
- return A({
177
- amount: a,
178
- fromCurrencyCode: i,
179
- toCurrencyCode: c,
180
- currencies: t,
181
- applyRounding: !0
182
- });
183
- }
184
- if (typeof r == "number" && Number.isFinite(r)) {
185
- const i = f(t);
186
- return A({
187
- amount: r,
188
- fromCurrencyCode: i.code,
189
- toCurrencyCode: c,
190
- currencies: t,
191
- applyRounding: !0
192
- });
193
- }
194
- return 0;
195
- }
196
- function D(n) {
197
- const {
198
- prices: e = {},
199
- salePrices: r = {},
200
- fallbackPrice: t,
201
- fallbackSalePrice: c,
202
- currencies: o
203
- } = n, i = u(n.currencyCode), a = C(e), d = U(r), s = b({
204
- amountMap: a,
205
- fallbackAmount: t,
206
- currencyCode: i,
207
- currencies: o
208
- }), m = b({
209
- amountMap: C(d),
210
- fallbackAmount: c,
211
- currencyCode: i,
212
- currencies: o
213
- });
214
- return {
215
- currencyCode: i,
216
- price: s,
217
- sale_price: m > 0 && m <= s ? m : null
218
- };
219
- }
220
- function w(n) {
221
- const e = (n.now ?? /* @__PURE__ */ new Date()).getTime();
222
- if (n.saleStartAt) {
223
- const r = new Date(n.saleStartAt).getTime();
224
- if (Number.isFinite(r) && e < r)
225
- return !1;
226
- }
227
- if (n.saleEndAt) {
228
- const r = new Date(n.saleEndAt).getTime();
229
- if (Number.isFinite(r) && e >= r)
230
- return !1;
231
- }
232
- return !0;
233
- }
234
- function j(n) {
235
- if (!n.scheduledPriceAt)
236
- return !1;
237
- const e = new Date(n.scheduledPriceAt).getTime();
238
- return Number.isFinite(e) ? (n.now ?? /* @__PURE__ */ new Date()).getTime() >= e : !1;
239
- }
240
- function v(n) {
241
- const e = n.now ?? /* @__PURE__ */ new Date(), r = j({
242
- scheduledPriceAt: n.scheduledPriceAt,
243
- now: e
244
- }), t = r ? n.scheduledPrices : n.prices, c = r ? n.scheduledPrice : n.fallbackPrice, o = w({
245
- saleStartAt: n.saleStartAt,
246
- saleEndAt: n.saleEndAt,
247
- now: e
248
- });
249
- return D({
250
- prices: t,
251
- salePrices: o ? n.salePrices : null,
252
- fallbackPrice: c,
253
- fallbackSalePrice: o ? n.fallbackSalePrice : null,
254
- currencyCode: n.currencyCode,
255
- currencies: n.currencies
256
- });
257
- }
258
- function L(n) {
259
- const e = n.entries.map(
260
- (r) => v({
261
- prices: r.prices,
262
- salePrices: r.sale_prices,
263
- fallbackPrice: r.price,
264
- fallbackSalePrice: r.sale_price,
265
- saleStartAt: r.sale_start_at,
266
- saleEndAt: r.sale_end_at,
267
- scheduledPrice: r.scheduled_price,
268
- scheduledPrices: r.scheduled_prices,
269
- scheduledPriceAt: r.scheduled_price_at,
270
- currencyCode: n.currencyCode,
271
- currencies: n.currencies,
272
- now: n.now
273
- })
274
- ).map((r) => r.sale_price ?? r.price).filter((r) => Number.isFinite(r));
275
- return e.length ? {
276
- min: Math.min(...e),
277
- max: Math.max(...e)
278
- } : null;
279
- }
280
- function K(n, e) {
281
- const r = f(e), t = n?.trim();
282
- if (!t)
283
- return r.code;
284
- const o = t.replace("_", "-").split("-").map((d) => d.toUpperCase())[1];
285
- if (!o)
286
- return r.code;
287
- const i = E[o];
288
- return i && new Set(e.map((d) => u(d.code))).has(i) ? i : r.code;
289
- }
290
- function $(n) {
291
- return n.map(l).sort((e, r) => e.is_default !== r.is_default ? e.is_default ? -1 : 1 : u(e.code).localeCompare(u(r.code)));
292
- }
293
- export {
294
- R as CURRENCY_ROUNDING_MODES,
295
- S as applyCurrencyRounding,
296
- A as convertMinorUnitAmount,
297
- T as describeCurrencyRoundingRule,
298
- h as getCurrencyLookup,
299
- f as getDefaultCurrency,
300
- O as getExchangeRateForCurrency,
301
- K as inferCurrencyCodeFromLocale,
302
- w as isSaleWindowActive,
303
- j as isScheduledPriceDue,
304
- l as normalizeCurrencyRecord,
305
- z as normalizeCurrencyRoundingMode,
306
- C as normalizePriceMap,
307
- U as normalizeSalePriceMap,
308
- v as resolveEffectivePriceForCurrency,
309
- D as resolvePriceForCurrency,
310
- L as resolvePriceRangeForCurrency,
311
- $ as sortCurrencies
312
- };
123
+ function y(n) {
124
+ let i = d(n);
125
+ if (i.rounding_mode === "nearest") return `Nearest ${e(i.rounding_increment ?? 1, i.code)}`;
126
+ if (i.rounding_mode === "up") return `Round up to ${e(i.rounding_increment ?? 1, i.code)}`;
127
+ if (i.rounding_mode === "down") return `Round down to ${e(i.rounding_increment ?? 1, i.code)}`;
128
+ if (i.rounding_mode === "charm") {
129
+ let t = i.rounding_charm_amount ?? 0;
130
+ return `Charm ending ${e(t, i.code)}`;
131
+ }
132
+ return `Exact conversion (${r(1, i.code).toFixed(t(i.code) === 1 ? 0 : 2)} step)`;
133
+ }
134
+ function b(e, t) {
135
+ let n = m(t);
136
+ return e[n.code] === void 0 ? Object.keys(e)[0] ?? n.code : n.code;
137
+ }
138
+ function x(e) {
139
+ let { amountMap: t, fallbackAmount: n, currencies: r } = e, a = i(e.currencyCode), o = f(t);
140
+ if (o[a] !== void 0) return o[a];
141
+ if (Object.keys(o).length > 0) {
142
+ let e = b(o, r), t = o[e];
143
+ if (t !== void 0) return _({
144
+ amount: t,
145
+ fromCurrencyCode: e,
146
+ toCurrencyCode: a,
147
+ currencies: r,
148
+ applyRounding: !0
149
+ });
150
+ }
151
+ return typeof n == "number" && Number.isFinite(n) ? _({
152
+ amount: n,
153
+ fromCurrencyCode: m(r).code,
154
+ toCurrencyCode: a,
155
+ currencies: r,
156
+ applyRounding: !0
157
+ }) : 0;
158
+ }
159
+ function S(e) {
160
+ let { prices: t = {}, salePrices: n = {}, fallbackPrice: r, fallbackSalePrice: a, currencies: o } = e, s = i(e.currencyCode), c = f(t), l = p(n), u = x({
161
+ amountMap: c,
162
+ fallbackAmount: r,
163
+ currencyCode: s,
164
+ currencies: o
165
+ }), d = x({
166
+ amountMap: f(l),
167
+ fallbackAmount: a,
168
+ currencyCode: s,
169
+ currencies: o
170
+ });
171
+ return {
172
+ currencyCode: s,
173
+ price: u,
174
+ sale_price: d > 0 && d <= u ? d : null
175
+ };
176
+ }
177
+ function C(e) {
178
+ let t = (e.now ?? /* @__PURE__ */ new Date()).getTime();
179
+ if (e.saleStartAt) {
180
+ let n = new Date(e.saleStartAt).getTime();
181
+ if (Number.isFinite(n) && t < n) return !1;
182
+ }
183
+ if (e.saleEndAt) {
184
+ let n = new Date(e.saleEndAt).getTime();
185
+ if (Number.isFinite(n) && t >= n) return !1;
186
+ }
187
+ return !0;
188
+ }
189
+ function w(e) {
190
+ if (!e.scheduledPriceAt) return !1;
191
+ let t = new Date(e.scheduledPriceAt).getTime();
192
+ return Number.isFinite(t) ? (e.now ?? /* @__PURE__ */ new Date()).getTime() >= t : !1;
193
+ }
194
+ function T(e) {
195
+ let t = e.now ?? /* @__PURE__ */ new Date(), n = w({
196
+ scheduledPriceAt: e.scheduledPriceAt,
197
+ now: t
198
+ }), r = n ? e.scheduledPrices : e.prices, i = n ? e.scheduledPrice : e.fallbackPrice, a = C({
199
+ saleStartAt: e.saleStartAt,
200
+ saleEndAt: e.saleEndAt,
201
+ now: t
202
+ });
203
+ return S({
204
+ prices: r,
205
+ salePrices: a ? e.salePrices : null,
206
+ fallbackPrice: i,
207
+ fallbackSalePrice: a ? e.fallbackSalePrice : null,
208
+ currencyCode: e.currencyCode,
209
+ currencies: e.currencies
210
+ });
211
+ }
212
+ function E(e) {
213
+ let t = e.entries.map((t) => T({
214
+ prices: t.prices,
215
+ salePrices: t.sale_prices,
216
+ fallbackPrice: t.price,
217
+ fallbackSalePrice: t.sale_price,
218
+ saleStartAt: t.sale_start_at,
219
+ saleEndAt: t.sale_end_at,
220
+ scheduledPrice: t.scheduled_price,
221
+ scheduledPrices: t.scheduled_prices,
222
+ scheduledPriceAt: t.scheduled_price_at,
223
+ currencyCode: e.currencyCode,
224
+ currencies: e.currencies,
225
+ now: e.now
226
+ })).map((e) => e.sale_price ?? e.price).filter((e) => Number.isFinite(e));
227
+ return t.length ? {
228
+ min: Math.min(...t),
229
+ max: Math.max(...t)
230
+ } : null;
231
+ }
232
+ function D(e, t) {
233
+ let n = m(t), r = e?.trim();
234
+ if (!r) return n.code;
235
+ let a = r.replace("_", "-").split("-").map((e) => e.toUpperCase())[1];
236
+ if (!a) return n.code;
237
+ let s = o[a];
238
+ return s && new Set(t.map((e) => i(e.code))).has(s) ? s : n.code;
239
+ }
240
+ function O(e) {
241
+ return e.map(d).sort((e, t) => e.is_default === t.is_default ? i(e.code).localeCompare(i(t.code)) : e.is_default ? -1 : 1);
242
+ }
243
+ //#endregion
244
+ export { a as CURRENCY_ROUNDING_MODES, v as applyCurrencyRounding, _ as convertMinorUnitAmount, y as describeCurrencyRoundingRule, h as getCurrencyLookup, m as getDefaultCurrency, g as getExchangeRateForCurrency, D as inferCurrencyCodeFromLocale, C as isSaleWindowActive, w as isScheduledPriceDue, d as normalizeCurrencyRecord, u as normalizeCurrencyRoundingMode, f as normalizePriceMap, p as normalizeSalePriceMap, T as resolveEffectivePriceForCurrency, S as resolvePriceForCurrency, E as resolvePriceRangeForCurrency, O as sortCurrencies };
@@ -0,0 +1 @@
1
+ const e=require("./customer.cjs");let t=require("@nextblock-cms/db/server");function n(e){return e?.trim()||null}function r(t){return t?e.normalizeCustomerAddress({company_name:t.company_name,recipient_name:t.recipient_name,line1:t.line1,line2:t.line2,city:t.city,state:t.state,postal_code:t.postal_code,country_code:t.country_code}):null}function i(e,t){return e?.find(e=>e.address_type===t&&e.is_default)??e?.find(e=>e.address_type===t)??null}async function a(t,n,r,i){let a=e.normalizeCustomerAddress(i),{data:o,error:s}=await t.from(`user_addresses`).select(`*`).eq(`user_id`,n).eq(`address_type`,r).order(`is_default`,{ascending:!1}).order(`updated_at`,{ascending:!1});if(s)throw Error(s.message);let c=o?.[0]??null,l=(o??[]).slice(1).map(e=>e.id);if(!a){if(o?.length){let e=o.map(e=>e.id),{error:n}=await t.from(`user_addresses`).delete().in(`id`,e);if(n)throw Error(n.message)}return}let u={user_id:n,address_type:r,is_default:!0,company_name:a.company_name??null,recipient_name:a.recipient_name??null,line1:a.line1??null,line2:a.line2??null,city:a.city??null,state:a.state??null,postal_code:a.postal_code??null,country_code:a.country_code??null,updated_at:new Date().toISOString()};if(c){let{error:e}=await t.from(`user_addresses`).update(u).eq(`id`,c.id);if(e)throw Error(e.message)}else{let{error:e}=await t.from(`user_addresses`).insert(u);if(e)throw Error(e.message)}if(l.length){let{error:e}=await t.from(`user_addresses`).delete().in(`id`,l);if(e)throw Error(e.message)}}async function o(e,n){let{data:a,error:o}=await(n??(0,t.createClient)()).from(`user_addresses`).select(`*`).eq(`user_id`,e).in(`address_type`,[`billing`,`shipping`]).order(`is_default`,{ascending:!1}).order(`updated_at`,{ascending:!1});if(o)throw Error(o.message);return{billingAddress:r(i(a??[],`billing`)),shippingAddress:r(i(a??[],`shipping`))}}async function s(e){let n=e.client??(0,t.createClient)();await a(n,e.userId,`billing`,e.billingAddress??null),await a(n,e.userId,`shipping`,e.shippingAddress??null)}async function c(e){let r=e.client??(0,t.createClient)(),i=n(e.fullName),a=n(e.phone);if(!i&&!a)return;let{data:o,error:s}=await r.from(`profiles`).select(`full_name, phone`).eq(`id`,e.userId).maybeSingle();if(s)throw Error(s.message);if(!o)return;let c=n(o.full_name)||i,l=n(o.phone)||a;if(n(o.full_name)===c&&n(o.phone)===l)return;let{error:u}=await r.from(`profiles`).update({full_name:c,phone:l,updated_at:new Date().toISOString()}).eq(`id`,e.userId);if(u)throw Error(u.message)}exports.fillMissingUserProfileCheckoutDetails=c,exports.getDefaultUserAddresses=o,exports.upsertDefaultUserAddresses=s;