@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,559 +1,304 @@
1
- import { deleteMediaFiles as F } from "@nextblock-cms/utils/server";
2
- import { syncSharedInventoryForSavedProduct as k } from "./shared-inventory.es.js";
3
- import { normalizeCurrencyCode as E } from "@nextblock-cms/utils/utils";
4
- import { buildPublishedAtOrFilter as M } from "@nextblock-cms/utils";
5
- const w = (e) => Math.round(e * 100);
6
- function q(e) {
7
- return Object.entries(e || {}).reduce(
8
- (t, [i, r]) => (typeof r == "number" && Number.isFinite(r) && r >= 0 && (t[E(i)] = w(r)), t),
9
- {}
10
- );
1
+ import { syncSharedInventoryForSavedProduct as e } from "./shared-inventory.es.js";
2
+ import { buildPublishedAtOrFilter as t } from "@nextblock-cms/utils";
3
+ import { deleteMediaFiles as n } from "@nextblock-cms/utils/server";
4
+ import { normalizeCurrencyCode as r } from "@nextblock-cms/utils/utils";
5
+ //#region src/lib/product-actions.ts
6
+ var i = (e) => Math.round(e * 100);
7
+ function a(e) {
8
+ return Object.entries(e || {}).reduce((e, [t, n]) => (typeof n == "number" && Number.isFinite(n) && n >= 0 && (e[r(t)] = i(n)), e), {});
11
9
  }
12
- function A(e) {
13
- return (e || []).map((t) => ({
14
- id: t.id,
15
- sku: t.sku,
16
- upc: t.upc ?? null,
17
- price: w(t.price),
18
- sale_price: typeof t.sale_price == "number" && !isNaN(t.sale_price) ? w(t.sale_price) : null,
19
- prices: q(t.prices),
20
- sale_prices: q(t.sale_prices),
21
- sale_start_at: t.sale_start_at ?? null,
22
- sale_end_at: t.sale_end_at ?? null,
23
- stock_quantity: t.stock_quantity,
24
- main_media_id: t.main_media_id ?? null,
25
- attribute_term_ids: t.attribute_term_ids
26
- }));
10
+ function o(e) {
11
+ return (e || []).map((e) => ({
12
+ id: e.id,
13
+ sku: e.sku,
14
+ upc: e.upc ?? null,
15
+ price: i(e.price),
16
+ sale_price: typeof e.sale_price == "number" && !isNaN(e.sale_price) ? i(e.sale_price) : null,
17
+ prices: a(e.prices),
18
+ sale_prices: a(e.sale_prices),
19
+ sale_start_at: e.sale_start_at ?? null,
20
+ sale_end_at: e.sale_end_at ?? null,
21
+ stock_quantity: e.stock_quantity,
22
+ main_media_id: e.main_media_id ?? null,
23
+ attribute_term_ids: e.attribute_term_ids
24
+ }));
27
25
  }
28
- function P(e, t) {
29
- const r = e.product_type === "digital" && e.payment_provider === "freemius" ? Math.max(0, Number(e.trial_period_days ?? 0)) : 0;
30
- return {
31
- id: t,
32
- product_type: e.product_type,
33
- payment_provider: e.payment_provider,
34
- title: e.title,
35
- slug: e.slug,
36
- sku: e.sku,
37
- upc: e.upc ?? null,
38
- stock: e.stock,
39
- status: e.status,
40
- short_description: e.short_description ?? null,
41
- description_json: e.description_json ?? null,
42
- metadata: {},
43
- price: w(e.price),
44
- sale_price: typeof e.sale_price == "number" && !isNaN(e.sale_price) ? w(e.sale_price) : null,
45
- prices: q(e.prices),
46
- sale_prices: q(e.sale_prices),
47
- sale_start_at: e.sale_start_at ?? null,
48
- sale_end_at: e.sale_end_at ?? null,
49
- freemius_plan_id: e.freemius_plan_id ?? null,
50
- freemius_product_id: e.freemius_product_id ?? null,
51
- trial_period_days: r,
52
- trial_requires_payment_method: r > 0 ? e.trial_requires_payment_method ?? !1 : !1,
53
- is_taxable: e.is_taxable,
54
- language_id: e.language_id,
55
- translation_group_id: e.translation_group_id || void 0,
56
- variants: A(e.variants)
57
- };
26
+ function s(e, t) {
27
+ let n = e.product_type === "digital" && e.payment_provider === "freemius" ? Math.max(0, Number(e.trial_period_days ?? 0)) : 0;
28
+ return {
29
+ id: t,
30
+ product_type: e.product_type,
31
+ payment_provider: e.payment_provider,
32
+ title: e.title,
33
+ slug: e.slug,
34
+ sku: e.sku,
35
+ upc: e.upc ?? null,
36
+ stock: e.stock,
37
+ status: e.status,
38
+ short_description: e.short_description ?? null,
39
+ description_json: e.description_json ?? null,
40
+ metadata: {},
41
+ price: i(e.price),
42
+ sale_price: typeof e.sale_price == "number" && !isNaN(e.sale_price) ? i(e.sale_price) : null,
43
+ prices: a(e.prices),
44
+ sale_prices: a(e.sale_prices),
45
+ sale_start_at: e.sale_start_at ?? null,
46
+ sale_end_at: e.sale_end_at ?? null,
47
+ freemius_plan_id: e.freemius_plan_id ?? null,
48
+ freemius_product_id: e.freemius_product_id ?? null,
49
+ trial_period_days: n,
50
+ trial_requires_payment_method: n > 0 ? e.trial_requires_payment_method ?? !1 : !1,
51
+ is_taxable: e.is_taxable,
52
+ language_id: e.language_id,
53
+ translation_group_id: e.translation_group_id || void 0,
54
+ variants: o(e.variants)
55
+ };
58
56
  }
59
- async function j(e, t, i) {
60
- const r = (o) => {
61
- const a = typeof o == "string" ? o.trim() : "";
62
- return a || null;
63
- }, { error: s } = await e.from("products").update({
64
- meta_title: r(i.meta_title),
65
- meta_description: r(i.meta_description),
66
- custom_canonical: r(i.custom_canonical),
67
- updated_at: (/* @__PURE__ */ new Date()).toISOString()
68
- }).eq("id", t);
69
- if (s)
70
- throw s;
57
+ async function c(e, t, n) {
58
+ let r = (e) => (typeof e == "string" ? e.trim() : "") || null, { error: i } = await e.from("products").update({
59
+ meta_title: r(n.meta_title),
60
+ meta_description: r(n.meta_description),
61
+ custom_canonical: r(n.custom_canonical),
62
+ updated_at: (/* @__PURE__ */ new Date()).toISOString()
63
+ }).eq("id", t);
64
+ if (i) throw i;
71
65
  }
72
- async function x(e, t, i) {
73
- const { error: r } = await e.from("products").update({
74
- is_taxable: i,
75
- updated_at: (/* @__PURE__ */ new Date()).toISOString()
76
- }).eq("id", t);
77
- if (r)
78
- throw r;
66
+ async function l(e, t, n) {
67
+ let { error: r } = await e.from("products").update({
68
+ is_taxable: n,
69
+ updated_at: (/* @__PURE__ */ new Date()).toISOString()
70
+ }).eq("id", t);
71
+ if (r) throw r;
79
72
  }
80
- async function S(e, t, i) {
81
- const r = (/* @__PURE__ */ new Date()).toISOString(), { data: s } = await e.from("products").select("sku, sale_price, sale_prices").eq("id", t).maybeSingle(), o = s?.sku ?? i.sku, { data: a } = await e.from("products").select("id").eq("sku", o), c = (a ?? []).map((n) => n.id);
82
- c.length === 0 && c.push(t);
83
- const { error: _ } = await e.from("products").update({
84
- sale_price: s?.sale_price ?? null,
85
- sale_prices: s?.sale_prices ?? null,
86
- sale_start_at: i.sale_start_at ?? null,
87
- sale_end_at: i.sale_end_at ?? null,
88
- updated_at: r
89
- }).in("id", c);
90
- if (_)
91
- throw _;
92
- const l = i.variants ?? [];
93
- if (l.length === 0)
94
- return;
95
- const { data: p } = await e.from("product_variants").select("sku, sale_price, sale_prices").eq("product_id", t), f = new Map(
96
- (p ?? []).map((n) => [n.sku, n])
97
- );
98
- for (const n of l) {
99
- const u = f.get(n.sku);
100
- if (!u)
101
- continue;
102
- const { error: d } = await e.from("product_variants").update({
103
- sale_price: u.sale_price ?? null,
104
- sale_prices: u.sale_prices ?? null,
105
- sale_start_at: n.sale_start_at ?? null,
106
- sale_end_at: n.sale_end_at ?? null,
107
- updated_at: r
108
- }).eq("sku", n.sku).in("product_id", c);
109
- if (d)
110
- throw d;
111
- }
73
+ async function u(e, t, n) {
74
+ let r = (/* @__PURE__ */ new Date()).toISOString(), { data: i } = await e.from("products").select("sku, sale_price, sale_prices").eq("id", t).maybeSingle(), a = i?.sku ?? n.sku, { data: o } = await e.from("products").select("id").eq("sku", a), s = (o ?? []).map((e) => e.id);
75
+ s.length === 0 && s.push(t);
76
+ let { error: c } = await e.from("products").update({
77
+ sale_price: i?.sale_price ?? null,
78
+ sale_prices: i?.sale_prices ?? null,
79
+ sale_start_at: n.sale_start_at ?? null,
80
+ sale_end_at: n.sale_end_at ?? null,
81
+ updated_at: r
82
+ }).in("id", s);
83
+ if (c) throw c;
84
+ let l = n.variants ?? [];
85
+ if (l.length === 0) return;
86
+ let { data: u } = await e.from("product_variants").select("sku, sale_price, sale_prices").eq("product_id", t), d = new Map((u ?? []).map((e) => [e.sku, e]));
87
+ for (let t of l) {
88
+ let n = d.get(t.sku);
89
+ if (!n) continue;
90
+ let { error: i } = await e.from("product_variants").update({
91
+ sale_price: n.sale_price ?? null,
92
+ sale_prices: n.sale_prices ?? null,
93
+ sale_start_at: t.sale_start_at ?? null,
94
+ sale_end_at: t.sale_end_at ?? null,
95
+ updated_at: r
96
+ }).eq("sku", t.sku).in("product_id", s);
97
+ if (i) throw i;
98
+ }
112
99
  }
113
- async function N(e, {
114
- page: t = 1,
115
- limit: i = 10,
116
- offset: r,
117
- search: s = "",
118
- languageId: o,
119
- categoryId: a,
120
- categoryIds: c,
121
- productIds: _,
122
- translationGroupIds: l,
123
- status: p = "active"
124
- } = {}) {
125
- const f = i > 0, n = typeof r == "number" ? Math.max(0, r) : (t - 1) * i, u = n + i - 1;
126
- let d = e.from("products").select(
127
- "id, title, meta_title, meta_description, average_rating, total_reviews, sku, upc, price, prices, sale_price, sale_prices, sale_start_at, sale_end_at, scheduled_price, scheduled_prices, scheduled_price_at, is_taxable, product_type, payment_provider, short_description, stock, status, slug, language_id, translation_group_id, freemius_product_id, freemius_plan_id, trial_period_days, trial_requires_payment_method, product_media(media(file_path, object_key)), product_variants(id, price, prices, sale_price, sale_prices, sale_start_at, sale_end_at, scheduled_price, scheduled_prices, scheduled_price_at), freemius_plans(id, name, title, freemius_pricing(id, license_quota, api_monthly_price, api_annual_price, api_lifetime_price, override_monthly_price, override_annual_price, override_lifetime_price, is_active)), product_categories(category:categories(id, name, slug, description, name_translations, description_translations))",
128
- { count: "exact" }
129
- ).order("created_at", { ascending: !1 });
130
- if (f && (d = d.range(n, u)), p !== "all" && (d = d.eq("status", p)), o && (d = d.eq("language_id", o)), _) {
131
- if (_.length === 0)
132
- return { data: [], error: null, count: 0 };
133
- d = d.in("id", _);
134
- }
135
- if (l) {
136
- if (l.length === 0)
137
- return { data: [], error: null, count: 0 };
138
- d = d.in("translation_group_id", l);
139
- }
140
- const g = c?.length ? c : a ? [a] : [];
141
- if (g.length > 0) {
142
- const { data: h, error: m } = await e.from("product_categories").select("product_id").in("category_id", g);
143
- if (m)
144
- return { data: [], error: m, count: 0 };
145
- const y = Array.from(
146
- new Set(
147
- (h || []).map((v) => v.product_id).filter(Boolean)
148
- )
149
- );
150
- if (y.length === 0)
151
- return { data: [], error: null, count: 0 };
152
- d = d.in("id", y);
153
- }
154
- return s && (d = d.or(`title.ilike.%${s}%,sku.ilike.%${s}%`)), d;
100
+ async function d(e, { page: t = 1, limit: n = 10, offset: r, search: i = "", languageId: a, categoryId: o, categoryIds: s, productIds: c, translationGroupIds: l, status: u = "active" } = {}) {
101
+ let d = n > 0, f = typeof r == "number" ? Math.max(0, r) : (t - 1) * n, p = f + n - 1, m = e.from("products").select("id, title, meta_title, meta_description, average_rating, total_reviews, sku, upc, price, prices, sale_price, sale_prices, sale_start_at, sale_end_at, scheduled_price, scheduled_prices, scheduled_price_at, is_taxable, product_type, payment_provider, short_description, stock, status, slug, language_id, translation_group_id, freemius_product_id, freemius_plan_id, trial_period_days, trial_requires_payment_method, product_media(media(file_path, object_key)), product_variants(id, price, prices, sale_price, sale_prices, sale_start_at, sale_end_at, scheduled_price, scheduled_prices, scheduled_price_at), freemius_plans(id, name, title, freemius_pricing(id, license_quota, api_monthly_price, api_annual_price, api_lifetime_price, override_monthly_price, override_annual_price, override_lifetime_price, is_active)), product_categories(category:categories(id, name, slug, description, name_translations, description_translations))", { count: "exact" }).order("created_at", { ascending: !1 });
102
+ if (d && (m = m.range(f, p)), u !== "all" && (m = m.eq("status", u)), a && (m = m.eq("language_id", a)), c) {
103
+ if (c.length === 0) return {
104
+ data: [],
105
+ error: null,
106
+ count: 0
107
+ };
108
+ m = m.in("id", c);
109
+ }
110
+ if (l) {
111
+ if (l.length === 0) return {
112
+ data: [],
113
+ error: null,
114
+ count: 0
115
+ };
116
+ m = m.in("translation_group_id", l);
117
+ }
118
+ let h = s?.length ? s : o ? [o] : [];
119
+ if (h.length > 0) {
120
+ let { data: t, error: n } = await e.from("product_categories").select("product_id").in("category_id", h);
121
+ if (n) return {
122
+ data: [],
123
+ error: n,
124
+ count: 0
125
+ };
126
+ let r = Array.from(new Set((t || []).map((e) => e.product_id).filter(Boolean)));
127
+ if (r.length === 0) return {
128
+ data: [],
129
+ error: null,
130
+ count: 0
131
+ };
132
+ m = m.in("id", r);
133
+ }
134
+ return i && (m = m.or(`title.ilike.%${i}%,sku.ilike.%${i}%`)), m;
155
135
  }
156
- async function $(e, t) {
157
- return e.from("products").select(
158
- `
159
- *,
160
- languages (
161
- code
162
- ),
163
- product_media (
164
- media_id,
165
- sort_order,
166
- media (
167
- id,
168
- file_path,
169
- object_key,
170
- file_name,
171
- blur_data_url,
172
- width,
173
- height
174
- )
175
- ),
176
- product_variants (
177
- id,
178
- sku,
179
- upc,
180
- main_media_id,
181
- price,
182
- prices,
183
- sale_price,
184
- sale_prices,
185
- sale_start_at,
186
- sale_end_at,
187
- scheduled_price,
188
- scheduled_prices,
189
- scheduled_price_at,
190
- stock_quantity,
191
- media:main_media_id (
192
- id,
193
- file_path,
194
- object_key,
195
- description
196
- ),
197
- variant_attribute_mapping (
198
- attribute_term_id,
199
- product_attribute_terms (
200
- id,
201
- attribute_id,
202
- value,
203
- slug,
204
- sort_order,
205
- value_translations,
206
- product_attributes (
207
- id,
208
- name,
209
- slug,
210
- name_translations
211
- )
212
- )
213
- )
214
- ),
215
- freemius_plans (
216
- id,
217
- name,
218
- title,
219
- freemius_pricing (
220
- id,
221
- license_quota,
222
- api_monthly_price,
223
- api_annual_price,
224
- api_lifetime_price,
225
- override_monthly_price,
226
- override_annual_price,
227
- override_lifetime_price,
228
- is_active
229
- )
230
- ),
231
- product_categories (
232
- category:categories (
233
- id,
234
- name,
235
- slug,
236
- description,
237
- name_translations,
238
- description_translations
239
- )
240
- )
241
- `
242
- ).eq("id", t).single();
136
+ async function f(e, t) {
137
+ return e.from("products").select("\n *,\n languages (\n code\n ),\n product_media (\n media_id,\n sort_order,\n media (\n id,\n file_path,\n object_key,\n file_name,\n blur_data_url,\n width,\n height\n )\n ),\n product_variants (\n id,\n sku,\n upc,\n main_media_id,\n price,\n prices,\n sale_price,\n sale_prices,\n sale_start_at,\n sale_end_at,\n scheduled_price,\n scheduled_prices,\n scheduled_price_at,\n stock_quantity,\n media:main_media_id (\n id,\n file_path,\n object_key,\n description\n ),\n variant_attribute_mapping (\n attribute_term_id,\n product_attribute_terms (\n id,\n attribute_id,\n value,\n slug,\n sort_order,\n value_translations,\n product_attributes (\n id,\n name,\n slug,\n name_translations\n )\n )\n )\n ),\n freemius_plans (\n id,\n name,\n title,\n freemius_pricing (\n id,\n license_quota,\n api_monthly_price,\n api_annual_price,\n api_lifetime_price,\n override_monthly_price,\n override_annual_price,\n override_lifetime_price,\n is_active\n )\n ),\n product_categories (\n category:categories (\n id,\n name,\n slug,\n description,\n name_translations,\n description_translations\n )\n )\n ").eq("id", t).single();
243
138
  }
244
- async function O(e, t, i) {
245
- const { data: r, error: s } = await e.from("products").select(
246
- `
247
- *,
248
- languages (
249
- id,
250
- code,
251
- is_default
252
- ),
253
- product_media (
254
- media_id,
255
- sort_order,
256
- media (
257
- id,
258
- file_path,
259
- object_key,
260
- file_name,
261
- blur_data_url,
262
- width,
263
- height,
264
- variants
265
- )
266
- ),
267
- product_variants (
268
- id,
269
- sku,
270
- upc,
271
- main_media_id,
272
- price,
273
- prices,
274
- sale_price,
275
- sale_prices,
276
- sale_start_at,
277
- sale_end_at,
278
- scheduled_price,
279
- scheduled_prices,
280
- scheduled_price_at,
281
- stock_quantity,
282
- media:main_media_id (
283
- id,
284
- file_path,
285
- object_key,
286
- description
287
- ),
288
- variant_attribute_mapping (
289
- attribute_term_id,
290
- product_attribute_terms (
291
- id,
292
- attribute_id,
293
- value,
294
- slug,
295
- sort_order,
296
- value_translations,
297
- product_attributes (
298
- id,
299
- name,
300
- slug,
301
- name_translations
302
- )
303
- )
304
- )
305
- ),
306
- freemius_plans (
307
- id,
308
- name,
309
- title,
310
- freemius_pricing (
311
- id,
312
- license_quota,
313
- api_monthly_price,
314
- api_annual_price,
315
- api_lifetime_price,
316
- override_monthly_price,
317
- override_annual_price,
318
- override_lifetime_price,
319
- is_active
320
- )
321
- ),
322
- product_categories (
323
- category:categories (
324
- id,
325
- name,
326
- slug,
327
- description,
328
- name_translations,
329
- description_translations
330
- )
331
- )
332
- `
333
- ).eq("slug", t);
334
- if (s)
335
- return { data: null, error: s };
336
- if (!r || r.length === 0)
337
- return { data: null, error: { message: "Product not found", code: "PGRST116" } };
338
- let o = null;
339
- return i && (o = r.find((a) => (Array.isArray(a.languages) ? a.languages[0] : a.languages)?.code === i)), o || (o = r.find((a) => (Array.isArray(a.languages) ? a.languages[0] : a.languages)?.is_default)), o || (o = r.find((a) => (Array.isArray(a.languages) ? a.languages[0] : a.languages)?.code === "en")), o || (o = r[0]), { data: o, error: null };
139
+ async function p(e, t, n) {
140
+ let { data: r, error: i } = await e.from("products").select("\n *,\n languages (\n id,\n code,\n is_default\n ),\n product_media (\n media_id,\n sort_order,\n media (\n id,\n file_path,\n object_key,\n file_name,\n blur_data_url,\n width,\n height,\n variants\n )\n ),\n product_variants (\n id,\n sku,\n upc,\n main_media_id,\n price,\n prices,\n sale_price,\n sale_prices,\n sale_start_at,\n sale_end_at,\n scheduled_price,\n scheduled_prices,\n scheduled_price_at,\n stock_quantity,\n media:main_media_id (\n id,\n file_path,\n object_key,\n description\n ),\n variant_attribute_mapping (\n attribute_term_id,\n product_attribute_terms (\n id,\n attribute_id,\n value,\n slug,\n sort_order,\n value_translations,\n product_attributes (\n id,\n name,\n slug,\n name_translations\n )\n )\n )\n ),\n freemius_plans (\n id,\n name,\n title,\n freemius_pricing (\n id,\n license_quota,\n api_monthly_price,\n api_annual_price,\n api_lifetime_price,\n override_monthly_price,\n override_annual_price,\n override_lifetime_price,\n is_active\n )\n ),\n product_categories (\n category:categories (\n id,\n name,\n slug,\n description,\n name_translations,\n description_translations\n )\n )\n ").eq("slug", t);
141
+ if (i) return {
142
+ data: null,
143
+ error: i
144
+ };
145
+ if (!r || r.length === 0) return {
146
+ data: null,
147
+ error: {
148
+ message: "Product not found",
149
+ code: "PGRST116"
150
+ }
151
+ };
152
+ let a = null;
153
+ return n && (a = r.find((e) => (Array.isArray(e.languages) ? e.languages[0] : e.languages)?.code === n)), a ||= r.find((e) => (Array.isArray(e.languages) ? e.languages[0] : e.languages)?.is_default), a ||= r.find((e) => (Array.isArray(e.languages) ? e.languages[0] : e.languages)?.code === "en"), a ||= r[0], {
154
+ data: a,
155
+ error: null
156
+ };
340
157
  }
341
- async function z(e, t) {
342
- const { data: i, error: r } = await e.rpc("upsert_product_with_variants", {
343
- product_payload: P(t)
344
- });
345
- if (r || !i) throw r || new Error("Failed to create product");
346
- if (t.product_media && t.product_media.length > 0) {
347
- const o = t.product_media.map((a, c) => ({
348
- product_id: i,
349
- media_id: a.media_id,
350
- sort_order: c
351
- }));
352
- await e.from("product_media").insert(o);
353
- } else t.media_id && await e.from("product_media").insert({
354
- product_id: i,
355
- media_id: t.media_id,
356
- sort_order: 0
357
- });
358
- await x(e, i, t.is_taxable), await j(e, i, t), await S(e, i, t), await k(i, t), t.category_ids !== void 0 && await b(e, i, t.category_ids);
359
- const { data: s } = await e.from("products").select("*").eq("id", i).single();
360
- return s;
158
+ async function m(t, n) {
159
+ let { data: r, error: i } = await t.rpc("upsert_product_with_variants", { product_payload: s(n) });
160
+ if (i || !r) throw i || /* @__PURE__ */ Error("Failed to create product");
161
+ if (n.product_media && n.product_media.length > 0) {
162
+ let e = n.product_media.map((e, t) => ({
163
+ product_id: r,
164
+ media_id: e.media_id,
165
+ sort_order: t
166
+ }));
167
+ await t.from("product_media").insert(e);
168
+ } else n.media_id && await t.from("product_media").insert({
169
+ product_id: r,
170
+ media_id: n.media_id,
171
+ sort_order: 0
172
+ });
173
+ await l(t, r, n.is_taxable), await c(t, r, n), await u(t, r, n), await e(r, n), n.category_ids !== void 0 && await y(t, r, n.category_ids);
174
+ let { data: a } = await t.from("products").select("*").eq("id", r).single();
175
+ return a;
361
176
  }
362
- async function B(e, t, i) {
363
- const { data: r } = await e.from("product_media").select("media_id").eq("product_id", t), s = r?.map((n) => n.media_id) || [], { data: o, error: a } = await e.rpc("upsert_product_with_variants", {
364
- product_payload: P(i, t)
365
- });
366
- if (a || !o) throw a || new Error("Failed to update product");
367
- if (i.product_media) {
368
- if (await e.from("product_media").delete().eq("product_id", t), i.product_media.length > 0) {
369
- const n = i.product_media.map((u, d) => ({
370
- product_id: t,
371
- media_id: u.media_id,
372
- sort_order: d
373
- }));
374
- await e.from("product_media").insert(n);
375
- }
376
- } else i.media_id && (await e.from("product_media").delete().eq("product_id", t), await e.from("product_media").insert({
377
- product_id: t,
378
- media_id: i.media_id,
379
- sort_order: 0
380
- }));
381
- await x(e, o, i.is_taxable), await j(e, o, i), await S(e, o, i);
382
- const c = i.product_media ? i.product_media.map((n) => n.media_id) : i.media_id ? [i.media_id] : [], _ = i.explicitly_removed_media_ids || [], l = s.filter((n) => !c.includes(n)), p = Array.from(/* @__PURE__ */ new Set([...l, ..._]));
383
- if (p.length > 0)
384
- for (const n of p) {
385
- const { count: u } = await e.from("product_media").select("*", { count: "exact", head: !0 }).eq("media_id", n);
386
- if (u && u > 0) continue;
387
- const { count: d } = await e.from("posts").select("*", { count: "exact", head: !0 }).eq("feature_image_id", n);
388
- if (d && d > 0) continue;
389
- const { count: g } = await e.from("logos").select("*", { count: "exact", head: !0 }).eq("media_id", n);
390
- if (g && g > 0) continue;
391
- const { count: h } = await e.from("product_variants").select("*", { count: "exact", head: !0 }).eq("main_media_id", n);
392
- if (h && h > 0) continue;
393
- const { data: m } = await e.from("media").select("object_key, variants").eq("id", n).single();
394
- if (m) {
395
- const y = [m.object_key];
396
- m.variants && Array.isArray(m.variants) && m.variants.forEach((v) => {
397
- v.objectKey && y.push(v.objectKey);
398
- }), await F(y), await e.from("media").delete().eq("id", n);
399
- }
400
- }
401
- await k(o, i), i.category_ids !== void 0 && await b(e, t, i.category_ids);
402
- const { data: f } = await e.from("products").select("*").eq("id", o).single();
403
- return f;
177
+ async function h(t, r, i) {
178
+ let { data: a } = await t.from("product_media").select("media_id").eq("product_id", r), o = a?.map((e) => e.media_id) || [], { data: d, error: f } = await t.rpc("upsert_product_with_variants", { product_payload: s(i, r) });
179
+ if (f || !d) throw f || /* @__PURE__ */ Error("Failed to update product");
180
+ if (i.product_media) {
181
+ if (await t.from("product_media").delete().eq("product_id", r), i.product_media.length > 0) {
182
+ let e = i.product_media.map((e, t) => ({
183
+ product_id: r,
184
+ media_id: e.media_id,
185
+ sort_order: t
186
+ }));
187
+ await t.from("product_media").insert(e);
188
+ }
189
+ } else i.media_id && (await t.from("product_media").delete().eq("product_id", r), await t.from("product_media").insert({
190
+ product_id: r,
191
+ media_id: i.media_id,
192
+ sort_order: 0
193
+ }));
194
+ await l(t, d, i.is_taxable), await c(t, d, i), await u(t, d, i);
195
+ let p = i.product_media ? i.product_media.map((e) => e.media_id) : i.media_id ? [i.media_id] : [], m = i.explicitly_removed_media_ids || [], h = o.filter((e) => !p.includes(e)), g = Array.from(/* @__PURE__ */ new Set([...h, ...m]));
196
+ if (g.length > 0) for (let e of g) {
197
+ let { count: r } = await t.from("product_media").select("*", {
198
+ count: "exact",
199
+ head: !0
200
+ }).eq("media_id", e);
201
+ if (r && r > 0) continue;
202
+ let { count: i } = await t.from("posts").select("*", {
203
+ count: "exact",
204
+ head: !0
205
+ }).eq("feature_image_id", e);
206
+ if (i && i > 0) continue;
207
+ let { count: a } = await t.from("logos").select("*", {
208
+ count: "exact",
209
+ head: !0
210
+ }).eq("media_id", e);
211
+ if (a && a > 0) continue;
212
+ let { count: o } = await t.from("product_variants").select("*", {
213
+ count: "exact",
214
+ head: !0
215
+ }).eq("main_media_id", e);
216
+ if (o && o > 0) continue;
217
+ let { data: s } = await t.from("media").select("object_key, variants").eq("id", e).single();
218
+ if (s) {
219
+ let r = [s.object_key];
220
+ s.variants && Array.isArray(s.variants) && s.variants.forEach((e) => {
221
+ e.objectKey && r.push(e.objectKey);
222
+ }), await n(r), await t.from("media").delete().eq("id", e);
223
+ }
224
+ }
225
+ await e(d, i), i.category_ids !== void 0 && await y(t, r, i.category_ids);
226
+ let { data: _ } = await t.from("products").select("*").eq("id", d).single();
227
+ return _;
404
228
  }
405
- async function U(e, t) {
406
- const { error: i } = await e.from("products").delete().eq("id", t);
407
- if (i) throw i;
408
- return !0;
229
+ async function g(e, t) {
230
+ let { error: n } = await e.from("products").delete().eq("id", t);
231
+ if (n) throw n;
232
+ return !0;
409
233
  }
410
- async function V(e, t, i) {
411
- const { data: r, error: s } = await e.from("products").select("*").eq("id", i).single();
412
- if (s || !r)
413
- throw new Error(s?.message || "Source product not found");
414
- const { data: o, error: a } = await e.from("products").select("language_id").eq("id", t).single();
415
- if (a || !o)
416
- throw new Error(a?.message || "Target product not found");
417
- const { error: c } = await e.from("products").update({
418
- title: r.title,
419
- short_description: r.short_description,
420
- description_json: r.description_json
421
- }).eq("id", t);
422
- if (c) throw c;
423
- const { data: _, error: l } = await e.from("blocks").select("*").eq("product_id", i).order("order", { ascending: !0 });
424
- if (l) throw l;
425
- if (await e.from("blocks").delete().eq("product_id", t), _ && _.length > 0) {
426
- const f = _.map((u) => {
427
- const { id: d, created_at: g, updated_at: h, ...m } = u;
428
- return {
429
- ...m,
430
- product_id: t,
431
- language_id: o.language_id
432
- };
433
- }), { error: n } = await e.from("blocks").insert(f);
434
- if (n) throw n;
435
- }
436
- await e.from("product_drafts").delete().eq("product_id", t), await e.from("product_media").delete().eq("product_id", t);
437
- const { data: p } = await e.from("product_media").select("media_id, sort_order").eq("product_id", i);
438
- if (p && p.length > 0) {
439
- const f = p.map((n) => ({
440
- product_id: t,
441
- media_id: n.media_id,
442
- sort_order: n.sort_order
443
- }));
444
- await e.from("product_media").insert(f);
445
- }
446
- return { success: !0 };
234
+ async function _(e, t, n) {
235
+ let { data: r, error: i } = await e.from("products").select("*").eq("id", n).single();
236
+ if (i || !r) throw Error(i?.message || "Source product not found");
237
+ let { data: a, error: o } = await e.from("products").select("language_id").eq("id", t).single();
238
+ if (o || !a) throw Error(o?.message || "Target product not found");
239
+ let { error: s } = await e.from("products").update({
240
+ title: r.title,
241
+ short_description: r.short_description,
242
+ description_json: r.description_json
243
+ }).eq("id", t);
244
+ if (s) throw s;
245
+ let { data: c, error: l } = await e.from("blocks").select("*").eq("product_id", n).order("order", { ascending: !0 });
246
+ if (l) throw l;
247
+ if (await e.from("blocks").delete().eq("product_id", t), c && c.length > 0) {
248
+ let n = c.map((e) => {
249
+ let { id: n, created_at: r, updated_at: i, ...o } = e;
250
+ return {
251
+ ...o,
252
+ product_id: t,
253
+ language_id: a.language_id
254
+ };
255
+ }), { error: r } = await e.from("blocks").insert(n);
256
+ if (r) throw r;
257
+ }
258
+ await e.from("product_drafts").delete().eq("product_id", t), await e.from("product_media").delete().eq("product_id", t);
259
+ let { data: u } = await e.from("product_media").select("media_id, sort_order").eq("product_id", n);
260
+ if (u && u.length > 0) {
261
+ let n = u.map((e) => ({
262
+ product_id: t,
263
+ media_id: e.media_id,
264
+ sort_order: e.sort_order
265
+ }));
266
+ await e.from("product_media").insert(n);
267
+ }
268
+ return { success: !0 };
447
269
  }
448
- async function K(e, t, i, r = [], s = []) {
449
- const { data: o } = await e.from("languages").select("id").eq("code", i).single();
450
- if (!o)
451
- return { data: [], error: "Language not found" };
452
- const a = [];
453
- t.length > 0 && a.push(`translation_group_id.in.(${t.join(",")})`), r.length > 0 && a.push(`sku.in.(${r.map((l) => `"${l}"`).join(",")})`), s.length > 0 && a.push(`id.in.(${s.join(",")})`);
454
- let c = e.from("products").select(`
455
- id,
456
- title,
457
- sku,
458
- price,
459
- prices,
460
- sale_price,
461
- sale_prices,
462
- sale_start_at,
463
- sale_end_at,
464
- scheduled_price,
465
- scheduled_prices,
466
- scheduled_price_at,
467
- stock,
468
- slug,
469
- language_id,
470
- product_type,
471
- payment_provider,
472
- freemius_product_id,
473
- freemius_plan_id,
474
- trial_period_days,
475
- trial_requires_payment_method,
476
- is_taxable,
477
- product_media (
478
- media (
479
- file_path,
480
- object_key
481
- )
482
- ),
483
- product_variants (
484
- id,
485
- sku,
486
- upc,
487
- main_media_id,
488
- price,
489
- prices,
490
- sale_price,
491
- sale_prices,
492
- sale_start_at,
493
- sale_end_at,
494
- scheduled_price,
495
- scheduled_prices,
496
- scheduled_price_at,
497
- stock_quantity,
498
- media:main_media_id (
499
- file_path,
500
- object_key,
501
- description
502
- ),
503
- variant_attribute_mapping (
504
- attribute_term_id,
505
- product_attribute_terms (
506
- id,
507
- attribute_id,
508
- value,
509
- slug,
510
- sort_order,
511
- value_translations,
512
- product_attributes (
513
- id,
514
- name,
515
- slug,
516
- name_translations
517
- )
518
- )
519
- )
520
- ),
521
- translation_group_id
522
- `).eq("language_id", o.id).eq("status", "active").or(M());
523
- return a.length > 0 && (c = c.or(a.join(","))), await c.order("id");
270
+ async function v(e, n, r, i = [], a = []) {
271
+ let { data: o } = await e.from("languages").select("id").eq("code", r).single();
272
+ if (!o) return {
273
+ data: [],
274
+ error: "Language not found"
275
+ };
276
+ let s = [];
277
+ n.length > 0 && s.push(`translation_group_id.in.(${n.join(",")})`), i.length > 0 && s.push(`sku.in.(${i.map((e) => `"${e}"`).join(",")})`), a.length > 0 && s.push(`id.in.(${a.join(",")})`);
278
+ let c = e.from("products").select("\n id, \n title, \n sku, \n price,\n prices,\n sale_price,\n sale_prices,\n sale_start_at,\n sale_end_at,\n scheduled_price,\n scheduled_prices,\n scheduled_price_at,\n stock,\n slug,\n language_id,\n product_type,\n payment_provider,\n freemius_product_id,\n freemius_plan_id,\n trial_period_days,\n trial_requires_payment_method,\n is_taxable,\n product_media (\n media (\n file_path,\n object_key\n )\n ),\n product_variants (\n id,\n sku,\n upc,\n main_media_id,\n price,\n prices,\n sale_price,\n sale_prices,\n sale_start_at,\n sale_end_at,\n scheduled_price,\n scheduled_prices,\n scheduled_price_at,\n stock_quantity,\n media:main_media_id (\n file_path,\n object_key,\n description\n ),\n variant_attribute_mapping (\n attribute_term_id,\n product_attribute_terms (\n id,\n attribute_id,\n value,\n slug,\n sort_order,\n value_translations,\n product_attributes (\n id,\n name,\n slug,\n name_translations\n )\n )\n )\n ),\n translation_group_id\n ").eq("language_id", o.id).eq("status", "active").or(t());
279
+ return s.length > 0 && (c = c.or(s.join(","))), await c.order("id");
524
280
  }
525
- async function b(e, t, i) {
526
- const { data: r } = await e.from("products").select("translation_group_id").eq("id", t).single();
527
- if (!r || !r.translation_group_id) {
528
- if (await e.from("product_categories").delete().eq("product_id", t), i.length > 0) {
529
- const a = i.map((c) => ({
530
- product_id: t,
531
- category_id: c
532
- }));
533
- await e.from("product_categories").insert(a);
534
- }
535
- return;
536
- }
537
- const { data: s } = await e.from("products").select("id").eq("translation_group_id", r.translation_group_id), o = s && s.length > 0 ? s.map((a) => a.id) : [t];
538
- if (await e.from("product_categories").delete().in("product_id", o), i.length > 0) {
539
- const a = [];
540
- for (const c of o)
541
- for (const _ of i)
542
- a.push({
543
- product_id: c,
544
- category_id: _
545
- });
546
- await e.from("product_categories").insert(a);
547
- }
281
+ async function y(e, t, n) {
282
+ let { data: r } = await e.from("products").select("translation_group_id").eq("id", t).single();
283
+ if (!r || !r.translation_group_id) {
284
+ if (await e.from("product_categories").delete().eq("product_id", t), n.length > 0) {
285
+ let r = n.map((e) => ({
286
+ product_id: t,
287
+ category_id: e
288
+ }));
289
+ await e.from("product_categories").insert(r);
290
+ }
291
+ return;
292
+ }
293
+ let { data: i } = await e.from("products").select("id").eq("translation_group_id", r.translation_group_id), a = i && i.length > 0 ? i.map((e) => e.id) : [t];
294
+ if (await e.from("product_categories").delete().in("product_id", a), n.length > 0) {
295
+ let t = [];
296
+ for (let e of a) for (let r of n) t.push({
297
+ product_id: e,
298
+ category_id: r
299
+ });
300
+ await e.from("product_categories").insert(t);
301
+ }
548
302
  }
549
- export {
550
- V as copyProductFromLanguage,
551
- z as createProduct,
552
- U as deleteProduct,
553
- K as fetchTranslatedProductsForCartInternal,
554
- $ as getProduct,
555
- O as getProductBySlug,
556
- N as getProducts,
557
- b as syncCategoriesForTranslationGroup,
558
- B as updateProduct
559
- };
303
+ //#endregion
304
+ export { _ as copyProductFromLanguage, m as createProduct, g as deleteProduct, v as fetchTranslatedProductsForCartInternal, f as getProduct, p as getProductBySlug, d as getProducts, y as syncCategoriesForTranslationGroup, h as updateProduct };