@nextblock-cms/ecom 0.20.1 → 0.21.0

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 (317) hide show
  1. package/_virtual/_rolldown/runtime.cjs.js +1 -0
  2. package/index.cjs.js +1 -1
  3. package/index.es.js +38 -146
  4. package/lib/CurrencyProvider.cjs.js +1 -1
  5. package/lib/CurrencyProvider.d.ts +1 -1
  6. package/lib/CurrencyProvider.es.js +85 -95
  7. package/lib/PaymentReadinessProvider.cjs.js +1 -1
  8. package/lib/PaymentReadinessProvider.d.ts +1 -1
  9. package/lib/PaymentReadinessProvider.es.js +24 -27
  10. package/lib/cart-store.cjs.js +1 -1
  11. package/lib/cart-store.es.js +109 -121
  12. package/lib/components/AccountNavigationMenu.cjs.js +1 -1
  13. package/lib/components/AccountNavigationMenu.d.ts +1 -1
  14. package/lib/components/AccountNavigationMenu.es.js +36 -50
  15. package/lib/components/AddToCartButton.cjs.js +1 -1
  16. package/lib/components/AddToCartButton.d.ts +1 -1
  17. package/lib/components/AddToCartButton.es.js +94 -89
  18. package/lib/components/Cart.cjs.js +1 -1
  19. package/lib/components/Cart.d.ts +1 -1
  20. package/lib/components/Cart.es.js +261 -180
  21. package/lib/components/CartDrawer.cjs.js +1 -1
  22. package/lib/components/CartDrawer.d.ts +1 -1
  23. package/lib/components/CartDrawer.es.js +218 -148
  24. package/lib/components/CartIcon.cjs.js +1 -1
  25. package/lib/components/CartIcon.d.ts +1 -1
  26. package/lib/components/CartIcon.es.js +33 -35
  27. package/lib/components/Checkout.cjs.js +1 -1
  28. package/lib/components/Checkout.d.ts +1 -1
  29. package/lib/components/Checkout.es.js +1092 -1108
  30. package/lib/components/CouponForm.cjs.js +1 -1
  31. package/lib/components/CouponForm.d.ts +1 -1
  32. package/lib/components/CouponForm.es.js +136 -148
  33. package/lib/components/CurrencySwitcher.cjs.js +1 -1
  34. package/lib/components/CurrencySwitcher.d.ts +1 -1
  35. package/lib/components/CurrencySwitcher.es.js +22 -18
  36. package/lib/components/CustomerProfileForm.cjs.js +1 -1
  37. package/lib/components/CustomerProfileForm.es.js +454 -313
  38. package/lib/components/FeaturedProduct.cjs.js +1 -1
  39. package/lib/components/FeaturedProduct.d.ts +1 -1
  40. package/lib/components/FeaturedProduct.es.js +98 -83
  41. package/lib/components/FreemiusLicensePanel.cjs.js +1 -1
  42. package/lib/components/FreemiusLicensePanel.d.ts +1 -1
  43. package/lib/components/FreemiusLicensePanel.es.js +70 -65
  44. package/lib/components/InvoiceDocument.cjs.js +1 -1
  45. package/lib/components/InvoiceDocument.es.js +256 -192
  46. package/lib/components/InvoiceViewerShell.cjs.js +2 -2
  47. package/lib/components/InvoiceViewerShell.d.ts +1 -1
  48. package/lib/components/InvoiceViewerShell.es.js +75 -106
  49. package/lib/components/ProductCard.cjs.js +1 -1
  50. package/lib/components/ProductCard.d.ts +1 -1
  51. package/lib/components/ProductCard.es.js +186 -171
  52. package/lib/components/ProductDetailsLayout.cjs.js +1 -1
  53. package/lib/components/ProductDetailsLayout.es.js +405 -404
  54. package/lib/components/ProductGallery.cjs.js +1 -1
  55. package/lib/components/ProductGallery.d.ts +1 -1
  56. package/lib/components/ProductGallery.es.js +51 -54
  57. package/lib/components/ProductGrid.cjs.js +1 -1
  58. package/lib/components/ProductGrid.d.ts +1 -1
  59. package/lib/components/ProductGrid.es.js +23 -25
  60. package/lib/components/ShippingEstimator.cjs.js +1 -1
  61. package/lib/components/ShippingEstimator.d.ts +1 -1
  62. package/lib/components/ShippingEstimator.es.js +158 -153
  63. package/lib/components/ShortDescription.cjs.js +1 -1
  64. package/lib/components/ShortDescription.es.js +17 -17
  65. package/lib/components/SimpleTiptapRenderer.cjs.js +1 -1
  66. package/lib/components/SimpleTiptapRenderer.es.js +238 -211
  67. package/lib/components/SubscriptionSelector.cjs.js +1 -1
  68. package/lib/components/SubscriptionSelector.es.js +159 -154
  69. package/lib/countries.cjs.js +1 -1
  70. package/lib/countries.es.js +232 -75
  71. package/lib/coupon-server.cjs.js +1 -1
  72. package/lib/coupon-server.es.js +180 -224
  73. package/lib/coupons.cjs.js +1 -1
  74. package/lib/coupons.es.js +12 -14
  75. package/lib/currency-constants.cjs.js +1 -1
  76. package/lib/currency-constants.es.js +4 -4
  77. package/lib/currency-rest-client.cjs.js +1 -1
  78. package/lib/currency-rest-client.es.js +15 -22
  79. package/lib/currency-store.cjs.js +1 -1
  80. package/lib/currency-store.es.js +20 -27
  81. package/lib/currency-sync.cjs.js +1 -1
  82. package/lib/currency-sync.es.js +124 -170
  83. package/lib/currency.cjs.js +1 -1
  84. package/lib/currency.es.js +242 -310
  85. package/lib/customer-addresses.cjs.js +1 -1
  86. package/lib/customer-addresses.es.js +80 -109
  87. package/lib/customer-orders.cjs.js +1 -1
  88. package/lib/customer-orders.es.js +31 -43
  89. package/lib/customer.cjs.js +1 -1
  90. package/lib/customer.es.js +43 -52
  91. package/lib/export-helpers.cjs.js +1 -1
  92. package/lib/export-helpers.es.js +53 -52
  93. package/lib/factory.cjs.js +1 -1
  94. package/lib/factory.es.js +10 -7
  95. package/lib/freemius-coupons.cjs.js +1 -1
  96. package/lib/freemius-coupons.es.js +245 -262
  97. package/lib/freemius-license-claim.cjs.js +1 -1
  98. package/lib/freemius-license-claim.es.js +87 -71
  99. package/lib/freemius-license.cjs.js +1 -1
  100. package/lib/freemius-license.es.js +32 -39
  101. package/lib/freemius-order-sync.cjs.js +1 -1
  102. package/lib/freemius-order-sync.es.js +226 -290
  103. package/lib/freemius-trial-provision.cjs.js +1 -1
  104. package/lib/freemius-trial-provision.es.js +136 -130
  105. package/lib/inventory-settings.cjs.js +1 -1
  106. package/lib/inventory-settings.es.js +69 -77
  107. package/lib/invoice-server.cjs.js +3 -3
  108. package/lib/invoice-server.es.js +94 -141
  109. package/lib/invoice-ui.cjs.js +1 -1
  110. package/lib/invoice-ui.es.js +50 -66
  111. package/lib/invoice.cjs.js +1 -1
  112. package/lib/invoice.es.js +85 -94
  113. package/lib/order-inventory.cjs.js +25 -25
  114. package/lib/order-inventory.es.js +67 -79
  115. package/lib/order-tax-details.cjs.js +1 -1
  116. package/lib/order-tax-details.es.js +142 -153
  117. package/lib/pages/cms/coupons/CouponEditorForm.cjs.js +1 -1
  118. package/lib/pages/cms/coupons/CouponEditorForm.d.ts +1 -1
  119. package/lib/pages/cms/coupons/CouponEditorForm.es.js +227 -185
  120. package/lib/pages/cms/coupons/CouponsPage.cjs.js +2 -2
  121. package/lib/pages/cms/coupons/CouponsPage.d.ts +1 -1
  122. package/lib/pages/cms/coupons/CouponsPage.es.js +235 -166
  123. package/lib/pages/cms/coupons/CreateCouponDialog.cjs.js +1 -1
  124. package/lib/pages/cms/coupons/CreateCouponDialog.d.ts +1 -1
  125. package/lib/pages/cms/coupons/CreateCouponDialog.es.js +35 -34
  126. package/lib/pages/cms/coupons/EditCouponPage.cjs.js +1 -1
  127. package/lib/pages/cms/coupons/EditCouponPage.d.ts +1 -1
  128. package/lib/pages/cms/coupons/EditCouponPage.es.js +47 -47
  129. package/lib/pages/cms/coupons/ProductScopePicker.cjs.js +1 -1
  130. package/lib/pages/cms/coupons/ProductScopePicker.d.ts +1 -1
  131. package/lib/pages/cms/coupons/ProductScopePicker.es.js +128 -117
  132. package/lib/pages/cms/coupons/actions.cjs.js +1 -1
  133. package/lib/pages/cms/coupons/actions.es.js +112 -115
  134. package/lib/pages/cms/coupons/index.cjs.js +1 -0
  135. package/lib/pages/cms/coupons/index.es.js +3 -0
  136. package/lib/pages/cms/coupons/product-options.cjs.js +1 -1
  137. package/lib/pages/cms/coupons/product-options.es.js +21 -23
  138. package/lib/pages/cms/orders/ExportReportsDialog.cjs.js +1 -1
  139. package/lib/pages/cms/orders/ExportReportsDialog.es.js +135 -129
  140. package/lib/pages/cms/orders/MarkPaidButton.d.ts +1 -1
  141. package/lib/pages/cms/orders/OrderDetailPage.cjs.js +1 -1
  142. package/lib/pages/cms/orders/OrderDetailPage.d.ts +1 -1
  143. package/lib/pages/cms/orders/OrderDetailPage.es.js +186 -134
  144. package/lib/pages/cms/orders/OrderPrintButton.cjs.js +1 -1
  145. package/lib/pages/cms/orders/OrderPrintButton.d.ts +1 -1
  146. package/lib/pages/cms/orders/OrderPrintButton.es.js +15 -21
  147. package/lib/pages/cms/orders/OrderStatusForm.cjs.js +1 -1
  148. package/lib/pages/cms/orders/OrderStatusForm.d.ts +1 -1
  149. package/lib/pages/cms/orders/OrderStatusForm.es.js +85 -69
  150. package/lib/pages/cms/orders/OrdersPage.cjs.js +1 -1
  151. package/lib/pages/cms/orders/OrdersPage.d.ts +1 -1
  152. package/lib/pages/cms/orders/OrdersPage.es.js +170 -102
  153. package/lib/pages/cms/orders/actions.cjs.js +3 -3
  154. package/lib/pages/cms/orders/actions.es.js +53 -69
  155. package/lib/pages/cms/orders/export-actions.cjs.js +1 -1
  156. package/lib/pages/cms/orders/export-actions.es.js +23 -26
  157. package/lib/pages/cms/orders/index.cjs.js +1 -0
  158. package/lib/pages/cms/orders/index.es.js +6 -0
  159. package/lib/pages/cms/orders/server-actions.cjs.js +1 -1
  160. package/lib/pages/cms/orders/server-actions.es.js +60 -51
  161. package/lib/pages/cms/payments/PaymentsClient.cjs.js +1 -1
  162. package/lib/pages/cms/payments/PaymentsClient.d.ts +1 -1
  163. package/lib/pages/cms/payments/PaymentsClient.es.js +316 -346
  164. package/lib/pages/cms/payments/PaymentsPage.cjs.js +1 -1
  165. package/lib/pages/cms/payments/PaymentsPage.d.ts +1 -1
  166. package/lib/pages/cms/payments/PaymentsPage.es.js +29 -32
  167. package/lib/pages/cms/payments/actions.cjs.js +1 -1
  168. package/lib/pages/cms/payments/actions.es.js +38 -48
  169. package/lib/pages/cms/payments/index.cjs.js +1 -0
  170. package/lib/pages/cms/payments/index.es.js +3 -0
  171. package/lib/pages/cms/payments/queries.cjs.js +1 -1
  172. package/lib/pages/cms/payments/queries.es.js +38 -48
  173. package/lib/pages/cms/products/ProductsPage.cjs.js +1 -1
  174. package/lib/pages/cms/products/ProductsPage.d.ts +1 -1
  175. package/lib/pages/cms/products/ProductsPage.es.js +63 -66
  176. package/lib/pages/cms/products/[id]/edit/EditProductPage.d.ts +1 -1
  177. package/lib/pages/cms/products/_id_/edit/EditProductPage.cjs.js +1 -1
  178. package/lib/pages/cms/products/_id_/edit/EditProductPage.es.js +138 -155
  179. package/lib/pages/cms/products/actions.cjs.js +4 -4
  180. package/lib/pages/cms/products/actions.es.js +121 -162
  181. package/lib/pages/cms/products/attributes/AttributeManagementPage.cjs.js +1 -1
  182. package/lib/pages/cms/products/attributes/AttributeManagementPage.d.ts +1 -1
  183. package/lib/pages/cms/products/attributes/AttributeManagementPage.es.js +55 -47
  184. package/lib/pages/cms/products/attributes/components/AttributeManager.cjs.js +1 -1
  185. package/lib/pages/cms/products/attributes/components/AttributeManager.d.ts +1 -1
  186. package/lib/pages/cms/products/attributes/components/AttributeManager.es.js +285 -290
  187. package/lib/pages/cms/products/categories/CategoryManagementPage.cjs.js +1 -1
  188. package/lib/pages/cms/products/categories/CategoryManagementPage.d.ts +1 -1
  189. package/lib/pages/cms/products/categories/CategoryManagementPage.es.js +43 -35
  190. package/lib/pages/cms/products/categories/components/CategoryManager.cjs.js +1 -1
  191. package/lib/pages/cms/products/categories/components/CategoryManager.es.js +315 -262
  192. package/lib/pages/cms/products/components/CopyProductFromLanguage.cjs.js +1 -1
  193. package/lib/pages/cms/products/components/CopyProductFromLanguage.es.js +115 -113
  194. package/lib/pages/cms/products/components/CurrencyPriceFields.cjs.js +1 -1
  195. package/lib/pages/cms/products/components/CurrencyPriceFields.d.ts +1 -1
  196. package/lib/pages/cms/products/components/CurrencyPriceFields.es.js +136 -145
  197. package/lib/pages/cms/products/components/DeleteProductButton.cjs.js +1 -1
  198. package/lib/pages/cms/products/components/DeleteProductButton.d.ts +1 -1
  199. package/lib/pages/cms/products/components/DeleteProductButton.es.js +35 -47
  200. package/lib/pages/cms/products/components/FreemiusPricingDashboard.cjs.js +1 -1
  201. package/lib/pages/cms/products/components/FreemiusPricingDashboard.d.ts +1 -1
  202. package/lib/pages/cms/products/components/FreemiusPricingDashboard.es.js +106 -84
  203. package/lib/pages/cms/products/components/ProductCategorySelector.cjs.js +1 -1
  204. package/lib/pages/cms/products/components/ProductCategorySelector.es.js +156 -159
  205. package/lib/pages/cms/products/components/ProductForm.cjs.js +1 -1
  206. package/lib/pages/cms/products/components/ProductForm.es.js +872 -693
  207. package/lib/pages/cms/products/components/ProductMediaManager.cjs.js +1 -1
  208. package/lib/pages/cms/products/components/ProductMediaManager.es.js +106 -103
  209. package/lib/pages/cms/products/components/ProductsBulkTable.cjs.js +1 -1
  210. package/lib/pages/cms/products/components/ProductsBulkTable.d.ts +1 -1
  211. package/lib/pages/cms/products/components/ProductsBulkTable.es.js +303 -294
  212. package/lib/pages/cms/products/components/SaleScheduleFields.cjs.js +1 -1
  213. package/lib/pages/cms/products/components/SaleScheduleFields.d.ts +1 -1
  214. package/lib/pages/cms/products/components/SaleScheduleFields.es.js +111 -134
  215. package/lib/pages/cms/products/components/SyncFreemiusButton.cjs.js +1 -1
  216. package/lib/pages/cms/products/components/SyncFreemiusButton.d.ts +1 -1
  217. package/lib/pages/cms/products/components/SyncFreemiusButton.es.js +29 -35
  218. package/lib/pages/cms/products/components/SyncFreemiusPricingButton.cjs.js +2 -2
  219. package/lib/pages/cms/products/components/SyncFreemiusPricingButton.d.ts +1 -1
  220. package/lib/pages/cms/products/components/SyncFreemiusPricingButton.es.js +36 -48
  221. package/lib/pages/cms/products/components/SyncProductForm.d.ts +1 -1
  222. package/lib/pages/cms/products/components/VariationsEditor.cjs.js +1 -1
  223. package/lib/pages/cms/products/components/VariationsEditor.d.ts +1 -1
  224. package/lib/pages/cms/products/components/VariationsEditor.es.js +396 -405
  225. package/lib/pages/cms/products/index.cjs.js +1 -0
  226. package/lib/pages/cms/products/index.es.js +8 -0
  227. package/lib/pages/cms/products/inventory/InventoryPage.cjs.js +1 -1
  228. package/lib/pages/cms/products/inventory/InventoryPage.d.ts +1 -1
  229. package/lib/pages/cms/products/inventory/InventoryPage.es.js +21 -15
  230. package/lib/pages/cms/products/inventory/InventoryTableClient.cjs.js +2 -2
  231. package/lib/pages/cms/products/inventory/InventoryTableClient.d.ts +1 -1
  232. package/lib/pages/cms/products/inventory/InventoryTableClient.es.js +230 -209
  233. package/lib/pages/cms/products/inventory/actions.cjs.js +3 -3
  234. package/lib/pages/cms/products/inventory/actions.es.js +83 -91
  235. package/lib/pages/cms/products/new/NewProductPage.cjs.js +1 -1
  236. package/lib/pages/cms/products/new/NewProductPage.d.ts +1 -1
  237. package/lib/pages/cms/products/new/NewProductPage.es.js +58 -74
  238. package/lib/pages/cms/products/product-price-sync.cjs.js +1 -1
  239. package/lib/pages/cms/products/product-price-sync.es.js +74 -89
  240. package/lib/pages/cms/products/server-actions.cjs.js +1 -1
  241. package/lib/pages/cms/products/server-actions.es.js +250 -233
  242. package/lib/pages/cms/shipping/ShippingPage.cjs.js +2 -2
  243. package/lib/pages/cms/shipping/ShippingPage.es.js +287 -209
  244. package/lib/pages/cms/shipping/components/RateForm.cjs.js +1 -1
  245. package/lib/pages/cms/shipping/components/RateForm.d.ts +1 -1
  246. package/lib/pages/cms/shipping/components/RateForm.es.js +439 -436
  247. package/lib/pages/cms/shipping/components/ZoneForm.cjs.js +1 -1
  248. package/lib/pages/cms/shipping/components/ZoneForm.es.js +245 -224
  249. package/lib/pages/cms/shipping/index.cjs.js +1 -0
  250. package/lib/pages/cms/shipping/index.es.js +3 -0
  251. package/lib/pages/cms/shipping/server-actions.cjs.js +1 -1
  252. package/lib/pages/cms/shipping/server-actions.es.js +131 -149
  253. package/lib/pages/cms/taxes/TaxesPage.cjs.js +1 -1
  254. package/lib/pages/cms/taxes/TaxesPage.d.ts +1 -1
  255. package/lib/pages/cms/taxes/TaxesPage.es.js +211 -169
  256. package/lib/pages/cms/taxes/actions.cjs.js +1 -1
  257. package/lib/pages/cms/taxes/actions.es.js +41 -53
  258. package/lib/pages/cms/taxes/components/TaxRateForm.cjs.js +1 -1
  259. package/lib/pages/cms/taxes/components/TaxRateForm.d.ts +1 -1
  260. package/lib/pages/cms/taxes/components/TaxRateForm.es.js +112 -99
  261. package/lib/pages/cms/taxes/index.cjs.js +1 -0
  262. package/lib/pages/cms/taxes/index.es.js +3 -0
  263. package/lib/payment-config.cjs.js +1 -1
  264. package/lib/payment-config.es.js +110 -126
  265. package/lib/product-actions.cjs.js +4 -4
  266. package/lib/product-actions.es.js +289 -544
  267. package/lib/product-context.cjs.js +1 -1
  268. package/lib/product-context.es.js +13 -15
  269. package/lib/product-schema.cjs.js +1 -1
  270. package/lib/product-schema.es.js +99 -134
  271. package/lib/providers/freemius.cjs.js +1 -5
  272. package/lib/providers/freemius.es.js +446 -530
  273. package/lib/providers/stripe.cjs.js +1 -1
  274. package/lib/providers/stripe.es.js +417 -477
  275. package/lib/server-actions/coupon-actions.cjs.js +1 -1
  276. package/lib/server-actions/coupon-actions.es.js +22 -22
  277. package/lib/server-actions/customer-actions.cjs.js +1 -1
  278. package/lib/server-actions/customer-actions.es.js +26 -28
  279. package/lib/server-actions/product-actions.cjs.js +1 -1
  280. package/lib/server-actions/product-actions.es.js +9 -15
  281. package/lib/server-actions/shipping-actions.cjs.js +1 -1
  282. package/lib/server-actions/shipping-actions.es.js +27 -24
  283. package/lib/server-actions/tax-actions.cjs.js +1 -1
  284. package/lib/server-actions/tax-actions.es.js +33 -39
  285. package/lib/shared-inventory.cjs.js +2 -2
  286. package/lib/shared-inventory.es.js +111 -160
  287. package/lib/shipping/resolver.cjs.js +2 -2
  288. package/lib/shipping/resolver.es.js +44 -61
  289. package/lib/shipping-rate-currency.cjs.js +1 -1
  290. package/lib/shipping-rate-currency.es.js +52 -67
  291. package/lib/states.cjs.js +1 -1
  292. package/lib/states.es.js +333 -154
  293. package/lib/stripe/checkout.cjs.js +1 -1
  294. package/lib/stripe/checkout.es.js +125 -181
  295. package/lib/stripe/client.cjs.js +1 -1
  296. package/lib/stripe/client.es.js +14 -19
  297. package/lib/stripe/order-sync.cjs.js +1 -1
  298. package/lib/stripe/order-sync.es.js +106 -126
  299. package/lib/stripe/webhooks.cjs.js +1 -1
  300. package/lib/stripe/webhooks.es.js +37 -31
  301. package/lib/tax-calculation.cjs.js +1 -1
  302. package/lib/tax-calculation.es.js +84 -98
  303. package/lib/trials.cjs.js +1 -1
  304. package/lib/trials.es.js +24 -30
  305. package/lib/types.cjs.js +1 -1
  306. package/lib/types.es.js +21 -27
  307. package/lib/use-cart.cjs.js +1 -1
  308. package/lib/use-cart.es.js +38 -40
  309. package/lib/use-price-formatter.cjs.js +1 -1
  310. package/lib/use-price-formatter.es.js +10 -11
  311. package/lib/variation-utils.cjs.js +1 -1
  312. package/lib/variation-utils.es.js +199 -261
  313. package/lib/zod-config.cjs.js +1 -1
  314. package/lib/zod-config.es.js +5 -6
  315. package/package.json +16 -16
  316. package/server.cjs.js +1 -1
  317. package/server.es.js +56 -211
@@ -1,700 +1,879 @@
1
- 'use client';
2
- import { jsxs as s, jsx as e, Fragment as Fe } from "react/jsx-runtime";
3
- import U, { useState as V, useRef as Me, useEffect as P, useCallback as $ } from "react";
4
- import { zodResolver as er } from "@hookform/resolvers/zod";
5
- import { AlertCircle as Ve, CheckCircle2 as rr, Info as tr } from "lucide-react";
6
- import { Select as sr, SelectTrigger as ir, SelectValue as ar, SelectContent as dr, SelectItem as Te, Badge as H, Label as w, Input as x, Button as Ae } from "@nextblock-cms/ui";
7
- import { productSchema as or } from "../../../../product-schema.es.js";
8
- import { useForm as nr } from "react-hook-form";
9
- import { ProductMediaManager as lr } from "./ProductMediaManager.es.js";
10
- import { SyncFreemiusPricingButton as cr } from "./SyncFreemiusPricingButton.es.js";
11
- import { VariationsEditor as ur } from "./VariationsEditor.es.js";
12
- import { CurrencyPriceFields as Ie } from "./CurrencyPriceFields.es.js";
13
- import { SaleScheduleFields as Re } from "./SaleScheduleFields.es.js";
14
- import { ProductCategorySelector as mr } from "./ProductCategorySelector.es.js";
15
- import { getStoreManagedPriceCurrencyCodes as pr, resolveEditorCurrencyPriceMaps as hr, sanitizeProductFormValuesForStoreManagedCurrencies as Be } from "../product-price-sync.es.js";
16
- import { derivePaymentProviderFromProductType as fr } from "../../../../types.es.js";
17
- import { convertMinorUnitAmount as je } from "../../../../currency.es.js";
18
- import { majorUnitAmountToMinor as Oe, minorUnitAmountToMajor as Ue } from "@nextblock-cms/utils";
19
- function J({ title: r, description: i, action: y, children: m, hideHeader: C }) {
20
- return /* @__PURE__ */ s("section", { className: "rounded-lg border bg-card p-3 shadow-sm space-y-3", children: [
21
- !C && /* @__PURE__ */ s("div", { className: "flex items-start justify-between gap-4 flex-wrap border-b border-muted/50 pb-2 mb-1", children: [
22
- /* @__PURE__ */ s("div", { className: "space-y-0.5", children: [
23
- /* @__PURE__ */ e("h2", { className: "text-sm font-bold tracking-tight", children: r }),
24
- i ? /* @__PURE__ */ e("p", { className: "text-[11px] text-muted-foreground leading-none", children: i }) : null
25
- ] }),
26
- y
27
- ] }),
28
- /* @__PURE__ */ e("div", { className: C ? "" : "pt-1", children: m })
29
- ] });
1
+ "use client";
2
+ import { derivePaymentProviderFromProductType as e } from "../../../../types.es.js";
3
+ import { convertMinorUnitAmount as t } from "../../../../currency.es.js";
4
+ import { productSchema as n } from "../../../../product-schema.es.js";
5
+ import { ProductMediaManager as r } from "./ProductMediaManager.es.js";
6
+ import { SyncFreemiusPricingButton as i } from "./SyncFreemiusPricingButton.es.js";
7
+ import { CurrencyPriceFields as a } from "./CurrencyPriceFields.es.js";
8
+ import { SaleScheduleFields as o } from "./SaleScheduleFields.es.js";
9
+ import { getStoreManagedPriceCurrencyCodes as ee, resolveEditorCurrencyPriceMaps as te, sanitizeProductFormValuesForStoreManagedCurrencies as ne } from "../product-price-sync.es.js";
10
+ import { VariationsEditor as s } from "./VariationsEditor.es.js";
11
+ import { ProductCategorySelector as c } from "./ProductCategorySelector.es.js";
12
+ import l, { useCallback as u, useEffect as d, useRef as re, useState as f } from "react";
13
+ import { AlertCircle as ie, CheckCircle2 as ae, Info as oe } from "lucide-react";
14
+ import { majorUnitAmountToMinor as se, minorUnitAmountToMajor as ce } from "@nextblock-cms/utils";
15
+ import { Fragment as le, jsx as p, jsxs as m } from "react/jsx-runtime";
16
+ import { useForm as ue } from "react-hook-form";
17
+ import { zodResolver as de } from "@hookform/resolvers/zod";
18
+ import { Badge as h, Button as fe, Input as g, Label as _, Select as pe, SelectContent as me, SelectItem as he, SelectTrigger as ge, SelectValue as _e } from "@nextblock-cms/ui";
19
+ //#region libs/ecommerce/src/lib/pages/cms/products/components/ProductForm.tsx
20
+ function v({ title: e, description: t, action: n, children: r, hideHeader: i }) {
21
+ return /* @__PURE__ */ m("section", {
22
+ className: "rounded-lg border bg-card p-3 shadow-sm space-y-3",
23
+ children: [!i && /* @__PURE__ */ m("div", {
24
+ className: "flex items-start justify-between gap-4 flex-wrap border-b border-muted/50 pb-2 mb-1",
25
+ children: [/* @__PURE__ */ m("div", {
26
+ className: "space-y-0.5",
27
+ children: [/* @__PURE__ */ p("h2", {
28
+ className: "text-sm font-bold tracking-tight",
29
+ children: e
30
+ }), t ? /* @__PURE__ */ p("p", {
31
+ className: "text-[11px] text-muted-foreground leading-none",
32
+ children: t
33
+ }) : null]
34
+ }), n]
35
+ }), /* @__PURE__ */ p("div", {
36
+ className: i ? "" : "pt-1",
37
+ children: r
38
+ })]
39
+ });
30
40
  }
31
- function gr(r, i, y) {
32
- const m = i ? Number.parseInt(i, 10) : void 0;
33
- return r?.language_id || (Number.isFinite(m) ? m : void 0) || y.find((C) => C.is_default)?.id || y[0]?.id || 1;
41
+ function y(e, t, n) {
42
+ let r = t ? Number.parseInt(t, 10) : void 0;
43
+ return e?.language_id || (Number.isFinite(r) ? r : void 0) || n.find((e) => e.is_default)?.id || n[0]?.id || 1;
34
44
  }
35
- function qe(r, i, y, m, C) {
36
- const T = (m.find((b) => b.is_default) ?? m[0])?.code || "USD", j = r?.prices && Object.keys(r.prices).length > 0 ? r.prices : {
37
- [T]: typeof r?.price == "number" ? r.price / 100 : 0
38
- }, q = r?.sale_prices && Object.keys(r.sale_prices).length > 0 ? r.sale_prices : typeof r?.sale_price == "number" ? {
39
- [T]: r.sale_price / 100
40
- } : {}, z = r?.product_type || "", A = r?.payment_provider || (r?.product_type ? fr(r.product_type) : "stripe");
41
- return {
42
- ...Be({
43
- product_type: z || "physical",
44
- payment_provider: A,
45
- title: r?.title || "",
46
- slug: r?.slug || "",
47
- sku: r?.sku || "",
48
- upc: r?.upc || "",
49
- is_taxable: r?.is_taxable ?? !0,
50
- price: typeof r?.price == "number" ? r.price / 100 : 0,
51
- prices: j,
52
- sale_price: typeof r?.sale_price == "number" ? r.sale_price / 100 : null,
53
- sale_prices: q,
54
- stock: r?.stock || 0,
55
- meta_title: r?.meta_title || "",
56
- meta_description: r?.meta_description || "",
57
- custom_canonical: r?.custom_canonical || "",
58
- short_description: r?.short_description || "",
59
- description_json: r?.description_json || {
60
- type: "doc",
61
- content: [{ type: "paragraph" }]
62
- },
63
- freemius_product_id: r?.freemius_product_id || "",
64
- freemius_plan_id: r?.freemius_plan_id || "",
65
- trial_period_days: r?.trial_period_days ?? 0,
66
- trial_requires_payment_method: r?.trial_requires_payment_method ?? !1,
67
- status: r?.status || "draft",
68
- language_id: gr(
69
- r,
70
- i,
71
- y
72
- ),
73
- translation_group_id: r?.translation_group_id || C || void 0,
74
- product_media: r?.product_media?.map((b) => ({
75
- media_id: b.media_id
76
- })) || [],
77
- category_ids: r?.category_ids || [],
78
- variation_attributes: r?.variation_attributes || [],
79
- variants: r?.variants?.map((b) => ({
80
- ...b,
81
- prices: b.prices || {},
82
- sale_prices: b.sale_prices || {}
83
- })) || []
84
- }, m),
85
- product_type: z,
86
- payment_provider: A
87
- };
45
+ function ve(t, n, r, i, a) {
46
+ let o = (i.find((e) => e.is_default) ?? i[0])?.code || "USD", ee = t?.prices && Object.keys(t.prices).length > 0 ? t.prices : { [o]: typeof t?.price == "number" ? t.price / 100 : 0 }, te = t?.sale_prices && Object.keys(t.sale_prices).length > 0 ? t.sale_prices : typeof t?.sale_price == "number" ? { [o]: t.sale_price / 100 } : {}, s = t?.product_type || "", c = t?.payment_provider || (t?.product_type ? e(t.product_type) : "stripe");
47
+ return {
48
+ ...ne({
49
+ product_type: s || "physical",
50
+ payment_provider: c,
51
+ title: t?.title || "",
52
+ slug: t?.slug || "",
53
+ sku: t?.sku || "",
54
+ upc: t?.upc || "",
55
+ is_taxable: t?.is_taxable ?? !0,
56
+ price: typeof t?.price == "number" ? t.price / 100 : 0,
57
+ prices: ee,
58
+ sale_price: typeof t?.sale_price == "number" ? t.sale_price / 100 : null,
59
+ sale_prices: te,
60
+ stock: t?.stock || 0,
61
+ meta_title: t?.meta_title || "",
62
+ meta_description: t?.meta_description || "",
63
+ custom_canonical: t?.custom_canonical || "",
64
+ short_description: t?.short_description || "",
65
+ description_json: t?.description_json || {
66
+ type: "doc",
67
+ content: [{ type: "paragraph" }]
68
+ },
69
+ freemius_product_id: t?.freemius_product_id || "",
70
+ freemius_plan_id: t?.freemius_plan_id || "",
71
+ trial_period_days: t?.trial_period_days ?? 0,
72
+ trial_requires_payment_method: t?.trial_requires_payment_method ?? !1,
73
+ status: t?.status || "draft",
74
+ language_id: y(t, n, r),
75
+ translation_group_id: t?.translation_group_id || a || void 0,
76
+ product_media: t?.product_media?.map((e) => ({ media_id: e.media_id })) || [],
77
+ category_ids: t?.category_ids || [],
78
+ variation_attributes: t?.variation_attributes || [],
79
+ variants: t?.variants?.map((e) => ({
80
+ ...e,
81
+ prices: e.prices || {},
82
+ sale_prices: e.sale_prices || {}
83
+ })) || []
84
+ }, i),
85
+ product_type: s,
86
+ payment_provider: c
87
+ };
88
88
  }
89
- function ze(r) {
90
- return r ? r.map((i) => ({
91
- id: i.id || i.media_id,
92
- media_id: i.media_id,
93
- file_path: i.media?.file_path || i.media?.object_key || "",
94
- alt: i.media?.alt_text || "",
95
- sort_order: i.sort_order ?? 0
96
- })).sort((i, y) => i.sort_order - y.sort_order) : [];
89
+ function ye(e) {
90
+ return e ? e.map((e) => ({
91
+ id: e.id || e.media_id,
92
+ media_id: e.media_id,
93
+ file_path: e.media?.file_path || e.media?.object_key || "",
94
+ alt: e.media?.alt_text || "",
95
+ sort_order: e.sort_order ?? 0
96
+ })).sort((e, t) => e.sort_order - t.sort_order) : [];
97
97
  }
98
- function _r(r) {
99
- return r.map((i) => ({ media_id: i.media_id }));
98
+ function be(e) {
99
+ return e.map((e) => ({ media_id: e.media_id }));
100
100
  }
101
- function xr(r) {
102
- return r.map((i) => ({
103
- media_id: i.media_id,
104
- file_path: i.file_path,
105
- alt: i.alt
106
- }));
101
+ function xe(e) {
102
+ return e.map((e) => ({
103
+ media_id: e.media_id,
104
+ file_path: e.file_path,
105
+ alt: e.alt
106
+ }));
107
107
  }
108
- const yr = (r) => r.toString().toLowerCase().trim().replace(/\s+/g, "-").replace(/[^\w-]+/g, "").replace(/--+/g, "-").replace(/^-+/, "").replace(/-+$/, "");
109
- function Ur({
110
- initialData: r,
111
- isEdit: i = !1,
112
- mediaPickerNode: y,
113
- availableLanguagesProp: m,
114
- globalAttributesProp: C,
115
- currenciesProp: L,
116
- translationGroupId: T,
117
- targetLanguageId: j,
118
- freemiusDashboardNode: q,
119
- enabledProviders: z,
120
- configStatus: A,
121
- createAction: X,
122
- updateAction: b,
123
- availableCategoriesProp: Ee = [],
124
- hasOpenDraft: Ke = !1,
125
- onSeoChange: ae
126
- }) {
127
- const [B, Y] = V(!1), [Q, W] = V(() => !!r?.variants?.length), c = U.useMemo(
128
- () => L.filter((t) => t.is_active !== !1).sort((t, d) => t.is_default !== d.is_default ? t.is_default ? -1 : 1 : t.code.localeCompare(d.code)),
129
- [L]
130
- ), o = U.useMemo(
131
- () => c.find((t) => t.is_default) ?? c[0],
132
- [c]
133
- ), E = U.useMemo(
134
- () => pr(c),
135
- [c]
136
- ), de = nr({
137
- resolver: er(or),
138
- defaultValues: qe(
139
- r,
140
- j,
141
- m,
142
- c,
143
- T
144
- )
145
- }), {
146
- register: n,
147
- handleSubmit: Z,
148
- setValue: a,
149
- reset: oe,
150
- watch: l,
151
- setError: G,
152
- formState: { errors: p, dirtyFields: ne }
153
- } = de, le = Me(!0), D = Me(null), [$e, ee] = V(!1), [ce, re] = V(null), [ue, He] = V(null), I = l(), me = de.formState.isDirty, pe = I.title, he = I.meta_title, fe = I.meta_description;
154
- P(() => {
155
- ae?.({
156
- title: pe,
157
- meta_title: he,
158
- meta_description: fe
159
- });
160
- }, [pe, he, fe, ae]), P(() => {
161
- if (!i) return;
162
- if (le.current) {
163
- le.current = !1, D.current = JSON.stringify(I);
164
- return;
165
- }
166
- if (!me) return;
167
- const t = JSON.stringify(I);
168
- if (t === D.current) return;
169
- const d = setTimeout(() => {
170
- B || (D.current = t, Z(Ce)());
171
- }, 400);
172
- return () => clearTimeout(d);
173
- }, [I, i, me, B, Z]);
174
- const ge = l("title"), O = l("product_type"), h = O === "digital" ? "freemius" : O === "physical" ? "stripe" : void 0, v = O === "physical", _e = O === "digital", xe = h ? z[h] : !1, ye = h ? A[h].hasKeys : !1, Je = !!l("freemius_product_id"), be = Number(l("trial_period_days") || 0), ve = !!l("trial_requires_payment_method"), Le = l("variants") || [], F = l("price"), R = l("sale_price"), N = l("prices") || {}, M = l("sale_prices") || {}, S = (Le?.length || 0) > 0, Xe = l("language_id"), Ye = m.find((t) => t.id === Xe)?.code || m.find((t) => t.is_default)?.code || m[0]?.code, K = U.useMemo(
175
- () => hr({
176
- currencies: c,
177
- prices: N,
178
- salePrices: M,
179
- fallbackPrice: F,
180
- fallbackSalePrice: R
181
- }),
182
- [F, R, c, N, M]
183
- ), Qe = U.useMemo(
184
- () => r?.variants?.map((t) => ({
185
- ...t,
186
- prices: t.prices || {},
187
- sale_prices: t.sale_prices || {}
188
- })),
189
- [r?.variants]
190
- );
191
- P(() => {
192
- if (ne.title && !i) {
193
- const t = yr(ge);
194
- a("slug", t, { shouldValidate: !0 });
195
- }
196
- }, [ge, ne.title, a, i]);
197
- const [te, Ne] = V(
198
- () => ze(r?.product_media)
199
- ), [se, Pe] = V(/* @__PURE__ */ new Set());
200
- P(() => {
201
- oe(
202
- qe(
203
- r,
204
- j,
205
- m,
206
- c,
207
- T
208
- )
209
- ), Ne(ze(r?.product_media)), Pe(/* @__PURE__ */ new Set()), W(!!r?.variants?.length);
210
- }, [
211
- m,
212
- c,
213
- r,
214
- oe,
215
- j,
216
- T
217
- ]);
218
- const We = (t) => {
219
- const d = new Set(t.map((_) => _.id)), u = te.filter((_) => !d.has(_.id)), f = new Set(se);
220
- u.forEach((_) => {
221
- _.media_id && f.add(_.media_id);
222
- }), Pe(f), Ne(t), a("product_media", _r(t), { shouldDirty: !0 }), a("explicitly_removed_media_ids", Array.from(f), {
223
- shouldDirty: !0
224
- });
225
- };
226
- P(() => {
227
- a("explicitly_removed_media_ids", Array.from(se));
228
- }, [se, a]), P(() => {
229
- S && W(!0);
230
- }, [S]), P(() => {
231
- n("is_taxable"), n("price"), n("sale_price"), n("payment_provider"), n("trial_requires_payment_method");
232
- }, [n]), P(() => {
233
- if (!_e) {
234
- a("trial_period_days", 0, { shouldDirty: !1, shouldValidate: !0 }), a("trial_requires_payment_method", !1, {
235
- shouldDirty: !1,
236
- shouldValidate: !0
237
- });
238
- return;
239
- }
240
- be <= 0 && a("trial_requires_payment_method", !1, {
241
- shouldDirty: !1,
242
- shouldValidate: !0
243
- });
244
- }, [_e, a, be]), P(() => {
245
- h && a("payment_provider", h, {
246
- shouldDirty: !1,
247
- shouldValidate: !0
248
- });
249
- }, [h, a]), P(() => {
250
- o && N[o.code] === void 0 && a(
251
- "prices",
252
- {
253
- ...N,
254
- [o.code]: F || 0
255
- },
256
- { shouldDirty: !1 }
257
- );
258
- }, [F, o, N, a]);
259
- const we = $(
260
- (t, d) => {
261
- const u = {
262
- ...N,
263
- [t]: d
264
- };
265
- a("prices", u, { shouldDirty: !0, shouldValidate: !0 }), t === o?.code && a("price", d, { shouldDirty: !0, shouldValidate: !0 });
266
- },
267
- [o?.code, N, a]
268
- ), Se = $(
269
- (t, d) => {
270
- const u = {
271
- ...M,
272
- [t]: d
273
- };
274
- a("sale_prices", u, {
275
- shouldDirty: !0,
276
- shouldValidate: !0
277
- }), t === o?.code && a("sale_price", d, { shouldDirty: !0, shouldValidate: !0 });
278
- },
279
- [o?.code, M, a]
280
- ), ke = $(() => {
281
- if (!o)
282
- return;
283
- const t = new Set(E), d = N[o.code] ?? F ?? 0, u = M[o.code] ?? R ?? null, f = c.reduce((k, g) => {
284
- if (g.code !== o.code && t.has(g.code))
285
- return k;
286
- const ie = je({
287
- amount: Oe(d, o.code),
288
- fromCurrencyCode: o.code,
289
- toCurrencyCode: g.code,
290
- currencies: c,
291
- applyRounding: !0
292
- });
293
- return k[g.code] = Ue(ie, g.code), k;
294
- }, {}), _ = c.reduce(
295
- (k, g) => {
296
- if (g.code !== o.code && t.has(g.code))
297
- return k;
298
- if (typeof u != "number")
299
- return (g.code === o.code || !t.has(g.code)) && (k[g.code] = null), k;
300
- const ie = je({
301
- amount: Oe(u, o.code),
302
- fromCurrencyCode: o.code,
303
- toCurrencyCode: g.code,
304
- currencies: c,
305
- applyRounding: !0
306
- });
307
- return k[g.code] = Ue(ie, g.code), k;
308
- },
309
- {}
310
- );
311
- a("prices", f, { shouldDirty: !0, shouldValidate: !0 }), a("sale_prices", _, {
312
- shouldDirty: !0,
313
- shouldValidate: !0
314
- }), a("price", f[o.code] ?? d, {
315
- shouldDirty: !0,
316
- shouldValidate: !0
317
- }), a("sale_price", _[o.code] ?? null, {
318
- shouldDirty: !0,
319
- shouldValidate: !0
320
- });
321
- }, [
322
- c,
323
- o,
324
- N,
325
- M,
326
- a,
327
- E,
328
- F,
329
- R
330
- ]), Ze = $(
331
- ({
332
- variationAttributes: t,
333
- variants: d
334
- }) => {
335
- a("variation_attributes", t, { shouldDirty: !0 }), a("variants", d, { shouldDirty: !0, shouldValidate: !0 });
336
- },
337
- [a]
338
- ), Ce = async (t) => {
339
- Y(!0), ee(!0), re(null);
340
- try {
341
- if (!h) {
342
- const _ = "Select whether this product is physical or digital before saving.";
343
- G("product_type", {
344
- type: "manual",
345
- message: _
346
- }), i ? re(_) : alert(_), Y(!1), ee(!1);
347
- return;
348
- }
349
- const d = v ? 0 : Math.max(0, Number(t.trial_period_days || 0)), u = {
350
- ...t,
351
- product_type: t.product_type,
352
- payment_provider: h,
353
- freemius_product_id: v ? "" : t.freemius_product_id,
354
- freemius_plan_id: v ? "" : t.freemius_plan_id,
355
- trial_period_days: d,
356
- trial_requires_payment_method: !v && d > 0 ? t.trial_requires_payment_method : !1,
357
- upc: v ? t.upc : null,
358
- is_taxable: v ? t.is_taxable : !1,
359
- variation_attributes: v ? t.variation_attributes : [],
360
- variants: v ? t.variants : []
361
- }, f = Be(
362
- u,
363
- c
364
- );
365
- if (i && b)
366
- await b(f), He(/* @__PURE__ */ new Date());
367
- else if (X)
368
- await X(f);
369
- else
370
- throw new Error("Product form action is not configured.");
371
- } catch (d) {
372
- if (console.error(d), d.message === "NEXT_REDIRECT")
373
- return;
374
- let u = d.message || "An error occurred while saving.";
375
- if (d.code === "23505") {
376
- const f = d.message?.toLowerCase() || "";
377
- f.includes("products_slug_key") || f.includes("slug") ? (u = "This slug is already in use. Please choose another one.", G("slug", {
378
- type: "manual",
379
- message: u
380
- })) : (f.includes("products_sku_key") || f.includes("sku")) && (u = "This SKU is already in use.", G("sku", {
381
- type: "manual",
382
- message: u
383
- }));
384
- }
385
- i ? re(u) : alert(u);
386
- } finally {
387
- Y(!1), ee(!1);
388
- }
389
- }, Ge = S ? "bg-muted/60 text-muted-foreground opacity-70" : "", De = xr(te);
390
- return /* @__PURE__ */ s("form", { onSubmit: Z(Ce), className: "space-y-2.5 pb-4", children: [
391
- /* @__PURE__ */ e("input", { type: "hidden", ...n("translation_group_id") }),
392
- /* @__PURE__ */ e("input", { type: "hidden", ...n("payment_provider") }),
393
- /* @__PURE__ */ s("div", { className: "space-y-2.5 w-full", children: [
394
- /* @__PURE__ */ s("div", { className: "rounded-lg border bg-card p-2.5 px-4 shadow-sm flex items-center justify-between gap-3 flex-wrap", children: [
395
- /* @__PURE__ */ s("div", { className: "flex items-center gap-6", children: [
396
- /* @__PURE__ */ s("div", { className: "flex h-9 items-center gap-2", children: [
397
- /* @__PURE__ */ e("span", { className: "text-sm font-bold whitespace-nowrap leading-none pt-0.5", children: "Product Type" }),
398
- p.product_type && /* @__PURE__ */ e(Ve, { className: "h-4 w-4 text-destructive" })
399
- ] }),
400
- /* @__PURE__ */ e("div", { className: "flex h-9 items-center", children: /* @__PURE__ */ s(
401
- sr,
402
- {
403
- onValueChange: (t) => a("product_type", t, {
404
- shouldDirty: !0,
405
- shouldValidate: !0
406
- }),
407
- value: O || void 0,
408
- children: [
409
- /* @__PURE__ */ e(ir, { className: "w-[160px] h-9 text-xs", children: /* @__PURE__ */ e(ar, { placeholder: "Select Type" }) }),
410
- /* @__PURE__ */ s(dr, { children: [
411
- /* @__PURE__ */ e(Te, { value: "physical", children: "Physical Product" }),
412
- /* @__PURE__ */ e(Te, { value: "digital", children: "Digital Product" })
413
- ] })
414
- ]
415
- }
416
- ) })
417
- ] }),
418
- /* @__PURE__ */ s("div", { className: "flex items-center gap-6", children: [
419
- /* @__PURE__ */ s("div", { className: "flex h-9 items-center gap-3", children: [
420
- /* @__PURE__ */ e("span", { className: "text-[11px] font-semibold text-muted-foreground uppercase tracking-wider leading-none", children: "Payment Provider" }),
421
- /* @__PURE__ */ e(H, { variant: "outline", className: "text-xs py-1 font-bold bg-muted/30 leading-none", children: h ? h === "stripe" ? "Stripe" : "Freemius" : "—" })
422
- ] }),
423
- h && /* @__PURE__ */ e("div", { className: "flex h-9 items-center gap-2", children: xe && ye ? /* @__PURE__ */ s("span", { className: "flex items-center gap-1.5 text-emerald-600 text-[10px] font-bold bg-emerald-50 px-2 py-1 rounded-full border border-emerald-100 uppercase leading-none", children: [
424
- /* @__PURE__ */ e(rr, { className: "h-3 w-3" }),
425
- "Ready"
426
- ] }) : /* @__PURE__ */ s("span", { className: "flex items-center gap-1.5 text-amber-600 text-[10px] font-bold bg-amber-50 px-2 py-1 rounded-full border border-amber-100 uppercase leading-none", children: [
427
- /* @__PURE__ */ e(Ve, { className: "h-3 w-3" }),
428
- xe ? "Keys Missing" : "Disabled"
429
- ] }) }),
430
- !ye && h && A[h].missing.length > 0 && /* @__PURE__ */ s(
431
- "a",
432
- {
433
- href: "/cms/payments",
434
- className: "hidden xl:flex h-9 items-center gap-1 text-[10px] text-muted-foreground bg-muted/50 px-2 py-1 rounded border border-dashed leading-none hover:text-foreground hover:border-solid",
435
- children: [
436
- /* @__PURE__ */ e(tr, { className: "h-3 w-3" }),
437
- "Missing: ",
438
- A[h].missing.join(", "),
439
- " — set up payments"
440
- ]
441
- }
442
- )
443
- ] })
444
- ] }),
445
- /* @__PURE__ */ s(
446
- J,
447
- {
448
- title: "Product Information",
449
- hideHeader: !0,
450
- children: [
451
- i && /* @__PURE__ */ s("div", { className: "flex items-center justify-between text-xs text-muted-foreground pb-2 border-b border-border/40 mb-2.5", children: [
452
- /* @__PURE__ */ e("span", { className: "font-semibold text-[11px] uppercase tracking-wider text-muted-foreground/80", children: "Product Settings" }),
453
- /* @__PURE__ */ e("div", { className: "flex items-center gap-1.5 min-h-[16px]", children: $e ? /* @__PURE__ */ s(Fe, { children: [
454
- /* @__PURE__ */ s("div", { className: "relative flex h-2 w-2", children: [
455
- /* @__PURE__ */ e("span", { className: "animate-ping absolute inline-flex h-full w-full rounded-full bg-amber-400 opacity-75" }),
456
- /* @__PURE__ */ e("span", { className: "relative inline-flex rounded-full h-2 w-2 bg-amber-500" })
457
- ] }),
458
- /* @__PURE__ */ e("span", { className: "text-amber-600 dark:text-amber-400 font-medium", children: "Autosaving settings..." })
459
- ] }) : ce ? /* @__PURE__ */ s("span", { className: "text-red-500 font-medium", children: [
460
- "Error saving settings: ",
461
- ce
462
- ] }) : ue ? /* @__PURE__ */ s("span", { className: "text-emerald-600 dark:text-emerald-400 font-medium", children: [
463
- "Settings autosaved at ",
464
- ue.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit", second: "2-digit" })
465
- ] }) : /* @__PURE__ */ e("span", { className: "text-muted-foreground/60", children: "Settings autosave in draft mode" }) })
466
- ] }),
467
- /* @__PURE__ */ s("div", { className: "grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-2.5", children: [
468
- /* @__PURE__ */ s("div", { className: "col-span-2 space-y-1", children: [
469
- /* @__PURE__ */ e(w, { htmlFor: "title", className: "text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none", children: "Title" }),
470
- /* @__PURE__ */ e(x, { id: "title", placeholder: "Product title", ...n("title"), className: "h-8 text-sm" }),
471
- p.title && /* @__PURE__ */ e("p", { className: "text-destructive text-[11px] leading-none", children: p.title.message })
472
- ] }),
473
- /* @__PURE__ */ s("div", { className: "col-span-2 space-y-1", children: [
474
- /* @__PURE__ */ e(w, { htmlFor: "slug", className: "text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none", children: "Slug" }),
475
- /* @__PURE__ */ e(x, { id: "slug", placeholder: "product-slug", ...n("slug"), className: "h-8 text-sm" }),
476
- p.slug && /* @__PURE__ */ e("p", { className: "text-destructive text-[11px] leading-none", children: p.slug.message })
477
- ] }),
478
- /* @__PURE__ */ s("div", { className: "col-span-1 space-y-1", children: [
479
- /* @__PURE__ */ e(w, { htmlFor: "sku", className: "text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none", children: "SKU" }),
480
- /* @__PURE__ */ e(x, { id: "sku", placeholder: "SKU", ...n("sku"), className: "h-8 text-sm font-mono" }),
481
- p.sku && /* @__PURE__ */ e("p", { className: "text-destructive text-[11px] leading-none", children: p.sku.message })
482
- ] }),
483
- /* @__PURE__ */ s("div", { className: "col-span-1 space-y-1", children: [
484
- /* @__PURE__ */ e(w, { htmlFor: "upc_ean", className: "text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none", children: "UPC / EAN" }),
485
- /* @__PURE__ */ e(x, { id: "upc_ean", placeholder: "000000000", ...n("upc"), className: "h-8 text-sm font-mono", readOnly: S })
486
- ] })
487
- ] }),
488
- /* @__PURE__ */ s("div", { className: "grid grid-cols-2 md:grid-cols-3 lg:grid-cols-12 gap-2.5 mt-2", children: [
489
- /* @__PURE__ */ s("div", { className: `${i ? "lg:col-span-3" : "lg:col-span-4"} col-span-2 space-y-1`, children: [
490
- /* @__PURE__ */ e(w, { htmlFor: "meta_title", className: "text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none", children: "Meta Title" }),
491
- /* @__PURE__ */ e(x, { id: "meta_title", ...n("meta_title"), placeholder: "SEO page title (50-60 chars)", className: "h-8 text-sm" })
492
- ] }),
493
- /* @__PURE__ */ s("div", { className: "lg:col-span-4 col-span-2 space-y-1", children: [
494
- /* @__PURE__ */ e(w, { htmlFor: "meta_description", className: "text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none", children: "Meta Description" }),
495
- /* @__PURE__ */ e(x, { id: "meta_description", ...n("meta_description"), placeholder: "SEO description (150-160 chars)", className: "h-8 text-sm" })
496
- ] }),
497
- /* @__PURE__ */ s("div", { className: `${i ? "lg:col-span-3" : "lg:col-span-4"} col-span-2 space-y-1`, children: [
498
- /* @__PURE__ */ e(w, { htmlFor: "custom_canonical", className: "text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none", children: "Canonical URL (optional)" }),
499
- /* @__PURE__ */ e(x, { id: "custom_canonical", ...n("custom_canonical"), placeholder: "Blank = self-referencing. Absolute https://… URL or /relative path to override.", className: "h-8 text-sm" })
500
- ] })
501
- ] })
502
- ]
503
- }
504
- ),
505
- /* @__PURE__ */ e(
506
- J,
507
- {
508
- title: "Product Categories",
509
- description: "Assign this product to one or more categories.",
510
- children: /* @__PURE__ */ e(
511
- mr,
512
- {
513
- categories: Ee,
514
- selectedIds: l("category_ids") || [],
515
- onChange: (t) => a("category_ids", t, { shouldDirty: !0, shouldValidate: !0 })
516
- }
517
- )
518
- }
519
- ),
520
- /* @__PURE__ */ s("section", { className: "rounded-lg border bg-card p-3 shadow-sm space-y-3", children: [
521
- v && /* @__PURE__ */ s("div", { className: "flex items-center justify-between gap-4 flex-wrap border-b border-muted/50 pb-2", children: [
522
- /* @__PURE__ */ e("div", { className: "flex items-center gap-4", children: /* @__PURE__ */ s("div", { className: "space-y-0.5", children: [
523
- /* @__PURE__ */ e("h2", { className: "text-sm font-bold tracking-tight", children: "Pricing & Inventory" }),
524
- /* @__PURE__ */ e("p", { className: "text-[11px] text-muted-foreground leading-none", children: "Manage simple or variant pricing." })
525
- ] }) }),
526
- /* @__PURE__ */ s("div", { className: "flex items-center gap-3", children: [
527
- /* @__PURE__ */ s("div", { className: "flex items-center gap-2 bg-muted/40 rounded-md px-2.5 py-1.5", children: [
528
- /* @__PURE__ */ e("span", { className: "text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none", children: "Stock" }),
529
- /* @__PURE__ */ e(
530
- x,
531
- {
532
- id: "stock",
533
- type: "number",
534
- min: "0",
535
- ...n("stock", { valueAsNumber: !0 }),
536
- placeholder: "0",
537
- readOnly: S,
538
- className: `${Ge} h-8 w-20 text-sm text-center font-mono bg-background`
539
- }
540
- )
541
- ] }),
542
- S ? /* @__PURE__ */ e(H, { variant: "secondary", className: "text-[11px] py-0 px-2 h-5", children: "Variant pricing" }) : null
543
- ] })
544
- ] }),
545
- v ? /* @__PURE__ */ s("div", { className: "space-y-3", children: [
546
- /* @__PURE__ */ s("div", { className: "w-full", children: [
547
- /* @__PURE__ */ e(
548
- Ie,
549
- {
550
- idPrefix: "product",
551
- currencies: c,
552
- prices: K.prices,
553
- salePrices: K.salePrices,
554
- managedCurrencyCodes: E,
555
- onPriceChange: we,
556
- onSalePriceChange: Se,
557
- onAutoFill: ke,
558
- readOnly: S,
559
- helperText: S ? "Parent prices stay as a fallback, but active variants define the live shopper price." : void 0,
560
- trailing: /* @__PURE__ */ e(
561
- Re,
562
- {
563
- idPrefix: "product",
564
- startAt: l("sale_start_at"),
565
- endAt: l("sale_end_at"),
566
- onChange: (t, d) => a(t, d, { shouldDirty: !0, shouldValidate: !0 }),
567
- error: p.sale_end_at?.message,
568
- bare: !0
569
- }
570
- )
571
- }
572
- ),
573
- p.price && /* @__PURE__ */ e("p", { className: "text-destructive text-sm mt-1", children: p.price.message }),
574
- p.sale_price && /* @__PURE__ */ e("p", { className: "text-destructive text-sm mt-1", children: p.sale_price.message }),
575
- p.stock && /* @__PURE__ */ e("p", { className: "text-destructive text-[10px] font-medium leading-none mt-1", children: p.stock.message })
576
- ] }),
577
- /* @__PURE__ */ s("div", { className: "flex items-center justify-between gap-3 rounded border border-dashed p-2.5 bg-muted/5", children: [
578
- /* @__PURE__ */ e("span", { className: "text-xs font-bold uppercase tracking-wider text-muted-foreground", children: S ? "Variations Active" : "Variations" }),
579
- /* @__PURE__ */ e(
580
- Ae,
581
- {
582
- type: "button",
583
- variant: Q ? "outline" : "default",
584
- onClick: () => W((t) => !t),
585
- size: "sm",
586
- className: "h-7 text-xs px-3",
587
- children: Q ? "Hide" : "Manage"
588
- }
589
- )
590
- ] }),
591
- Q && /* @__PURE__ */ e("div", { className: "border-t pt-3", children: /* @__PURE__ */ e(
592
- ur,
593
- {
594
- globalAttributes: C,
595
- currentLanguageCode: Ye,
596
- baseSku: l("sku") || "",
597
- basePrice: F || 0,
598
- basePrices: N,
599
- baseSalePrice: typeof R == "number" ? R : null,
600
- baseSalePrices: M,
601
- currencies: c,
602
- availableVariantImages: De,
603
- initialVariationAttributes: r?.variation_attributes,
604
- initialVariants: Qe,
605
- onChange: Ze
606
- }
607
- ) })
608
- ] }) : /* @__PURE__ */ s(Fe, { children: [
609
- /* @__PURE__ */ s("div", { className: "space-y-4", children: [
610
- /* @__PURE__ */ s("div", { className: "flex items-end gap-4 w-full", children: [
611
- /* @__PURE__ */ s("div", { className: "flex-1", children: [
612
- /* @__PURE__ */ e(w, { htmlFor: "freemius_product_id", className: "text-[11px] uppercase tracking-wider text-muted-foreground font-bold mb-1.5 block", children: "Freemius Product ID" }),
613
- /* @__PURE__ */ e(x, { id: "freemius_product_id", ...n("freemius_product_id"), className: "h-9" })
614
- ] }),
615
- /* @__PURE__ */ s("div", { className: "flex-1", children: [
616
- /* @__PURE__ */ e(w, { htmlFor: "freemius_plan_id", className: "text-[11px] uppercase tracking-wider text-muted-foreground font-bold mb-1.5 block", children: "Freemius Plan ID" }),
617
- /* @__PURE__ */ e(x, { id: "freemius_plan_id", ...n("freemius_plan_id"), className: "h-9" })
618
- ] }),
619
- Je ? /* @__PURE__ */ e(
620
- cr,
621
- {
622
- productId: l("freemius_product_id"),
623
- hasOpenDraft: Ke
624
- }
625
- ) : null
626
- ] }),
627
- /* @__PURE__ */ s("div", { className: "bg-muted/10 border rounded-md overflow-hidden", children: [
628
- /* @__PURE__ */ s("div", { className: "flex flex-wrap items-center gap-6 bg-muted/20 border-b p-2.5 px-4", children: [
629
- /* @__PURE__ */ s("div", { className: "flex items-center gap-2", children: [
630
- /* @__PURE__ */ e("span", { className: "text-[11px] font-bold uppercase tracking-wider text-muted-foreground", children: "Free Trial" }),
631
- /* @__PURE__ */ s(H, { variant: "outline", className: "font-mono text-xs shadow-sm bg-background", children: [
632
- String(l("trial_period_days") || 0),
633
- " Days"
634
- ] })
635
- ] }),
636
- /* @__PURE__ */ s("div", { className: "flex items-center gap-2", children: [
637
- /* @__PURE__ */ e("span", { className: "text-[11px] font-bold uppercase tracking-wider text-muted-foreground", children: "Card Required" }),
638
- /* @__PURE__ */ e(H, { variant: ve ? "default" : "secondary", className: "text-xs shadow-sm", children: ve ? "Yes" : "No" })
639
- ] }),
640
- /* @__PURE__ */ e("span", { className: "text-[10px] text-muted-foreground ml-auto", children: "Managed in Freemius dashboard" }),
641
- /* @__PURE__ */ e("input", { type: "hidden", ...n("trial_period_days", { valueAsNumber: !0 }) })
642
- ] }),
643
- /* @__PURE__ */ s("div", { className: "w-full p-4 pt-3 space-y-2", children: [
644
- /* @__PURE__ */ e(
645
- Ie,
646
- {
647
- idPrefix: "product",
648
- currencies: c,
649
- prices: K.prices,
650
- salePrices: K.salePrices,
651
- managedCurrencyCodes: E,
652
- onPriceChange: we,
653
- onSalePriceChange: Se,
654
- onAutoFill: ke,
655
- readOnly: !0,
656
- trailing: /* @__PURE__ */ e(
657
- Re,
658
- {
659
- idPrefix: "product",
660
- startAt: l("sale_start_at"),
661
- endAt: l("sale_end_at"),
662
- onChange: (t, d) => a(t, d, { shouldDirty: !0, shouldValidate: !0 }),
663
- error: p.sale_end_at?.message,
664
- bare: !0
665
- }
666
- )
667
- }
668
- ),
669
- /* @__PURE__ */ e("p", { className: "text-[10px] leading-snug text-muted-foreground", children: "Scheduling a sale on a Freemius product generates a time-bounded Freemius coupon so the discount is enforced at Freemius checkout." })
670
- ] })
671
- ] })
672
- ] }),
673
- q && /* @__PURE__ */ e("div", { className: "pt-2 border-t", children: q })
674
- ] })
675
- ] }),
676
- /* @__PURE__ */ e(J, { title: "Product Description", hideHeader: !0, children: /* @__PURE__ */ e("div", { className: "space-y-2", children: /* @__PURE__ */ s("div", { className: "space-y-1", children: [
677
- /* @__PURE__ */ e(w, { htmlFor: "short_description", className: "text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none", children: "Short Description" }),
678
- /* @__PURE__ */ e(x, { id: "short_description", ...n("short_description"), placeholder: "Brief summary for product cards...", className: "h-8 text-sm" })
679
- ] }) }) }),
680
- /* @__PURE__ */ s(J, { title: "Media Gallery", description: "Drag to reorder. First image is the hero.", children: [
681
- /* @__PURE__ */ e(
682
- lr,
683
- {
684
- initialMedia: te,
685
- onUpdate: We,
686
- mediaPickerNode: y
687
- }
688
- ),
689
- /* @__PURE__ */ e("input", { type: "hidden", ...n("product_media") })
690
- ] }),
691
- !i && /* @__PURE__ */ s("div", { className: "rounded-lg border bg-card p-3 px-4 shadow-sm flex items-center justify-between gap-3 flex-wrap", children: [
692
- /* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground", children: "New products start as a draft. Publish it from the top bar once it's ready." }),
693
- /* @__PURE__ */ e(Ae, { disabled: B, type: "submit", size: "sm", className: "h-8 text-sm px-5", children: B ? "Saving..." : "Save Changes" })
694
- ] })
695
- ] })
696
- ] });
108
+ var Se = (e) => e.toString().toLowerCase().trim().replace(/\s+/g, "-").replace(/[^\w-]+/g, "").replace(/--+/g, "-").replace(/^-+/, "").replace(/-+$/, "");
109
+ function Ce({ initialData: e, isEdit: y = !1, mediaPickerNode: Ce, availableLanguagesProp: b, globalAttributesProp: we, currenciesProp: Te, translationGroupId: x, targetLanguageId: S, freemiusDashboardNode: Ee, enabledProviders: De, configStatus: C, createAction: Oe, updateAction: ke, availableCategoriesProp: Ae = [], hasOpenDraft: je = !1, onSeoChange: Me }) {
110
+ let [w, T] = f(!1), [E, D] = f(() => !!e?.variants?.length), O = l.useMemo(() => Te.filter((e) => e.is_active !== !1).sort((e, t) => e.is_default === t.is_default ? e.code.localeCompare(t.code) : e.is_default ? -1 : 1), [Te]), k = l.useMemo(() => O.find((e) => e.is_default) ?? O[0], [O]), A = l.useMemo(() => ee(O), [O]), Ne = ue({
111
+ resolver: de(n),
112
+ defaultValues: ve(e, S, b, O, x)
113
+ }), { register: j, handleSubmit: M, setValue: N, reset: Pe, watch: P, setError: F, formState: { errors: I, dirtyFields: Fe } } = Ne, Ie = re(!0), L = re(null), [Le, R] = f(!1), [Re, z] = f(null), [ze, Be] = f(null), B = P(), Ve = Ne.formState.isDirty, He = B.title, Ue = B.meta_title, V = B.meta_description;
114
+ d(() => {
115
+ Me?.({
116
+ title: He,
117
+ meta_title: Ue,
118
+ meta_description: V
119
+ });
120
+ }, [
121
+ He,
122
+ Ue,
123
+ V,
124
+ Me
125
+ ]), d(() => {
126
+ if (!y) return;
127
+ if (Ie.current) {
128
+ Ie.current = !1, L.current = JSON.stringify(B);
129
+ return;
130
+ }
131
+ if (!Ve) return;
132
+ let e = JSON.stringify(B);
133
+ if (e === L.current) return;
134
+ let t = setTimeout(() => {
135
+ w || (L.current = e, M($)());
136
+ }, 400);
137
+ return () => clearTimeout(t);
138
+ }, [
139
+ B,
140
+ y,
141
+ Ve,
142
+ w,
143
+ M
144
+ ]);
145
+ let We = P("title"), H = P("product_type"), U = H === "digital" ? "freemius" : H === "physical" ? "stripe" : void 0, W = H === "physical", Ge = H === "digital", Ke = U ? De[U] : !1, qe = U ? C[U].hasKeys : !1, Je = !!P("freemius_product_id"), Ye = Number(P("trial_period_days") || 0), Xe = !!P("trial_requires_payment_method"), Ze = P("variants") || [], G = P("price"), K = P("sale_price"), q = P("prices") || {}, J = P("sale_prices") || {}, Y = (Ze?.length || 0) > 0, Qe = P("language_id"), $e = b.find((e) => e.id === Qe)?.code || b.find((e) => e.is_default)?.code || b[0]?.code, X = l.useMemo(() => te({
146
+ currencies: O,
147
+ prices: q,
148
+ salePrices: J,
149
+ fallbackPrice: G,
150
+ fallbackSalePrice: K
151
+ }), [
152
+ G,
153
+ K,
154
+ O,
155
+ q,
156
+ J
157
+ ]), et = l.useMemo(() => e?.variants?.map((e) => ({
158
+ ...e,
159
+ prices: e.prices || {},
160
+ sale_prices: e.sale_prices || {}
161
+ })), [e?.variants]);
162
+ d(() => {
163
+ if (Fe.title && !y) {
164
+ let e = Se(We);
165
+ N("slug", e, { shouldValidate: !0 });
166
+ }
167
+ }, [
168
+ We,
169
+ Fe.title,
170
+ N,
171
+ y
172
+ ]);
173
+ let [Z, tt] = f(() => ye(e?.product_media)), [Q, nt] = f(/* @__PURE__ */ new Set());
174
+ d(() => {
175
+ Pe(ve(e, S, b, O, x)), tt(ye(e?.product_media)), nt(/* @__PURE__ */ new Set()), D(!!e?.variants?.length);
176
+ }, [
177
+ b,
178
+ O,
179
+ e,
180
+ Pe,
181
+ S,
182
+ x
183
+ ]);
184
+ let rt = (e) => {
185
+ let t = new Set(e.map((e) => e.id)), n = Z.filter((e) => !t.has(e.id)), r = new Set(Q);
186
+ n.forEach((e) => {
187
+ e.media_id && r.add(e.media_id);
188
+ }), nt(r), tt(e), N("product_media", be(e), { shouldDirty: !0 }), N("explicitly_removed_media_ids", Array.from(r), { shouldDirty: !0 });
189
+ };
190
+ d(() => {
191
+ N("explicitly_removed_media_ids", Array.from(Q));
192
+ }, [Q, N]), d(() => {
193
+ Y && D(!0);
194
+ }, [Y]), d(() => {
195
+ j("is_taxable"), j("price"), j("sale_price"), j("payment_provider"), j("trial_requires_payment_method");
196
+ }, [j]), d(() => {
197
+ if (!Ge) {
198
+ N("trial_period_days", 0, {
199
+ shouldDirty: !1,
200
+ shouldValidate: !0
201
+ }), N("trial_requires_payment_method", !1, {
202
+ shouldDirty: !1,
203
+ shouldValidate: !0
204
+ });
205
+ return;
206
+ }
207
+ Ye <= 0 && N("trial_requires_payment_method", !1, {
208
+ shouldDirty: !1,
209
+ shouldValidate: !0
210
+ });
211
+ }, [
212
+ Ge,
213
+ N,
214
+ Ye
215
+ ]), d(() => {
216
+ U && N("payment_provider", U, {
217
+ shouldDirty: !1,
218
+ shouldValidate: !0
219
+ });
220
+ }, [U, N]), d(() => {
221
+ k && q[k.code] === void 0 && N("prices", {
222
+ ...q,
223
+ [k.code]: G || 0
224
+ }, { shouldDirty: !1 });
225
+ }, [
226
+ G,
227
+ k,
228
+ q,
229
+ N
230
+ ]);
231
+ let it = u((e, t) => {
232
+ let n = {
233
+ ...q,
234
+ [e]: t
235
+ };
236
+ N("prices", n, {
237
+ shouldDirty: !0,
238
+ shouldValidate: !0
239
+ }), e === k?.code && N("price", t, {
240
+ shouldDirty: !0,
241
+ shouldValidate: !0
242
+ });
243
+ }, [
244
+ k?.code,
245
+ q,
246
+ N
247
+ ]), at = u((e, t) => {
248
+ let n = {
249
+ ...J,
250
+ [e]: t
251
+ };
252
+ N("sale_prices", n, {
253
+ shouldDirty: !0,
254
+ shouldValidate: !0
255
+ }), e === k?.code && N("sale_price", t, {
256
+ shouldDirty: !0,
257
+ shouldValidate: !0
258
+ });
259
+ }, [
260
+ k?.code,
261
+ J,
262
+ N
263
+ ]), ot = u(() => {
264
+ if (!k) return;
265
+ let e = new Set(A), n = q[k.code] ?? G ?? 0, r = J[k.code] ?? K ?? null, i = O.reduce((r, i) => {
266
+ if (i.code !== k.code && e.has(i.code)) return r;
267
+ let a = t({
268
+ amount: se(n, k.code),
269
+ fromCurrencyCode: k.code,
270
+ toCurrencyCode: i.code,
271
+ currencies: O,
272
+ applyRounding: !0
273
+ });
274
+ return r[i.code] = ce(a, i.code), r;
275
+ }, {}), a = O.reduce((n, i) => {
276
+ if (i.code !== k.code && e.has(i.code)) return n;
277
+ if (typeof r != "number") return (i.code === k.code || !e.has(i.code)) && (n[i.code] = null), n;
278
+ let a = t({
279
+ amount: se(r, k.code),
280
+ fromCurrencyCode: k.code,
281
+ toCurrencyCode: i.code,
282
+ currencies: O,
283
+ applyRounding: !0
284
+ });
285
+ return n[i.code] = ce(a, i.code), n;
286
+ }, {});
287
+ N("prices", i, {
288
+ shouldDirty: !0,
289
+ shouldValidate: !0
290
+ }), N("sale_prices", a, {
291
+ shouldDirty: !0,
292
+ shouldValidate: !0
293
+ }), N("price", i[k.code] ?? n, {
294
+ shouldDirty: !0,
295
+ shouldValidate: !0
296
+ }), N("sale_price", a[k.code] ?? null, {
297
+ shouldDirty: !0,
298
+ shouldValidate: !0
299
+ });
300
+ }, [
301
+ O,
302
+ k,
303
+ q,
304
+ J,
305
+ N,
306
+ A,
307
+ G,
308
+ K
309
+ ]), st = u(({ variationAttributes: e, variants: t }) => {
310
+ N("variation_attributes", e, { shouldDirty: !0 }), N("variants", t, {
311
+ shouldDirty: !0,
312
+ shouldValidate: !0
313
+ });
314
+ }, [N]), $ = async (e) => {
315
+ T(!0), R(!0), z(null);
316
+ try {
317
+ if (!U) {
318
+ let e = "Select whether this product is physical or digital before saving.";
319
+ F("product_type", {
320
+ type: "manual",
321
+ message: e
322
+ }), y ? z(e) : alert(e), T(!1), R(!1);
323
+ return;
324
+ }
325
+ let t = W ? 0 : Math.max(0, Number(e.trial_period_days || 0)), n = {
326
+ ...e,
327
+ product_type: e.product_type,
328
+ payment_provider: U,
329
+ freemius_product_id: W ? "" : e.freemius_product_id,
330
+ freemius_plan_id: W ? "" : e.freemius_plan_id,
331
+ trial_period_days: t,
332
+ trial_requires_payment_method: !W && t > 0 && e.trial_requires_payment_method,
333
+ upc: W ? e.upc : null,
334
+ is_taxable: W ? e.is_taxable : !1,
335
+ variation_attributes: W ? e.variation_attributes : [],
336
+ variants: W ? e.variants : []
337
+ }, r = ne(n, O);
338
+ if (y && ke) await ke(r), Be(/* @__PURE__ */ new Date());
339
+ else if (Oe) await Oe(r);
340
+ else throw Error("Product form action is not configured.");
341
+ } catch (e) {
342
+ if (console.error(e), e.message === "NEXT_REDIRECT") return;
343
+ let t = e.message || "An error occurred while saving.";
344
+ if (e.code === "23505") {
345
+ let n = e.message?.toLowerCase() || "";
346
+ n.includes("products_slug_key") || n.includes("slug") ? (t = "This slug is already in use. Please choose another one.", F("slug", {
347
+ type: "manual",
348
+ message: t
349
+ })) : (n.includes("products_sku_key") || n.includes("sku")) && (t = "This SKU is already in use.", F("sku", {
350
+ type: "manual",
351
+ message: t
352
+ }));
353
+ }
354
+ y ? z(t) : alert(t);
355
+ } finally {
356
+ T(!1), R(!1);
357
+ }
358
+ }, ct = Y ? "bg-muted/60 text-muted-foreground opacity-70" : "", lt = xe(Z);
359
+ return /* @__PURE__ */ m("form", {
360
+ onSubmit: M($),
361
+ className: "space-y-2.5 pb-4",
362
+ children: [
363
+ /* @__PURE__ */ p("input", {
364
+ type: "hidden",
365
+ ...j("translation_group_id")
366
+ }),
367
+ /* @__PURE__ */ p("input", {
368
+ type: "hidden",
369
+ ...j("payment_provider")
370
+ }),
371
+ /* @__PURE__ */ m("div", {
372
+ className: "space-y-2.5 w-full",
373
+ children: [
374
+ /* @__PURE__ */ m("div", {
375
+ className: "rounded-lg border bg-card p-2.5 px-4 shadow-sm flex items-center justify-between gap-3 flex-wrap",
376
+ children: [/* @__PURE__ */ m("div", {
377
+ className: "flex items-center gap-6",
378
+ children: [/* @__PURE__ */ m("div", {
379
+ className: "flex h-9 items-center gap-2",
380
+ children: [/* @__PURE__ */ p("span", {
381
+ className: "text-sm font-bold whitespace-nowrap leading-none pt-0.5",
382
+ children: "Product Type"
383
+ }), I.product_type && /* @__PURE__ */ p(ie, { className: "h-4 w-4 text-destructive" })]
384
+ }), /* @__PURE__ */ p("div", {
385
+ className: "flex h-9 items-center",
386
+ children: /* @__PURE__ */ m(pe, {
387
+ onValueChange: (e) => N("product_type", e, {
388
+ shouldDirty: !0,
389
+ shouldValidate: !0
390
+ }),
391
+ value: H || void 0,
392
+ children: [/* @__PURE__ */ p(ge, {
393
+ className: "w-[160px] h-9 text-xs",
394
+ children: /* @__PURE__ */ p(_e, { placeholder: "Select Type" })
395
+ }), /* @__PURE__ */ m(me, { children: [/* @__PURE__ */ p(he, {
396
+ value: "physical",
397
+ children: "Physical Product"
398
+ }), /* @__PURE__ */ p(he, {
399
+ value: "digital",
400
+ children: "Digital Product"
401
+ })] })]
402
+ })
403
+ })]
404
+ }), /* @__PURE__ */ m("div", {
405
+ className: "flex items-center gap-6",
406
+ children: [
407
+ /* @__PURE__ */ m("div", {
408
+ className: "flex h-9 items-center gap-3",
409
+ children: [/* @__PURE__ */ p("span", {
410
+ className: "text-[11px] font-semibold text-muted-foreground uppercase tracking-wider leading-none",
411
+ children: "Payment Provider"
412
+ }), /* @__PURE__ */ p(h, {
413
+ variant: "outline",
414
+ className: "text-xs py-1 font-bold bg-muted/30 leading-none",
415
+ children: U ? U === "stripe" ? "Stripe" : "Freemius" : "—"
416
+ })]
417
+ }),
418
+ U && /* @__PURE__ */ p("div", {
419
+ className: "flex h-9 items-center gap-2",
420
+ children: Ke && qe ? /* @__PURE__ */ m("span", {
421
+ className: "flex items-center gap-1.5 text-emerald-600 text-[10px] font-bold bg-emerald-50 px-2 py-1 rounded-full border border-emerald-100 uppercase leading-none",
422
+ children: [/* @__PURE__ */ p(ae, { className: "h-3 w-3" }), "Ready"]
423
+ }) : /* @__PURE__ */ m("span", {
424
+ className: "flex items-center gap-1.5 text-amber-600 text-[10px] font-bold bg-amber-50 px-2 py-1 rounded-full border border-amber-100 uppercase leading-none",
425
+ children: [/* @__PURE__ */ p(ie, { className: "h-3 w-3" }), Ke ? "Keys Missing" : "Disabled"]
426
+ })
427
+ }),
428
+ !qe && U && C[U].missing.length > 0 && /* @__PURE__ */ m("a", {
429
+ href: "/cms/payments",
430
+ className: "hidden xl:flex h-9 items-center gap-1 text-[10px] text-muted-foreground bg-muted/50 px-2 py-1 rounded border border-dashed leading-none hover:text-foreground hover:border-solid",
431
+ children: [
432
+ /* @__PURE__ */ p(oe, { className: "h-3 w-3" }),
433
+ "Missing: ",
434
+ C[U].missing.join(", "),
435
+ " — set up payments"
436
+ ]
437
+ })
438
+ ]
439
+ })]
440
+ }),
441
+ /* @__PURE__ */ m(v, {
442
+ title: "Product Information",
443
+ hideHeader: !0,
444
+ children: [
445
+ y && /* @__PURE__ */ m("div", {
446
+ className: "flex items-center justify-between text-xs text-muted-foreground pb-2 border-b border-border/40 mb-2.5",
447
+ children: [/* @__PURE__ */ p("span", {
448
+ className: "font-semibold text-[11px] uppercase tracking-wider text-muted-foreground/80",
449
+ children: "Product Settings"
450
+ }), /* @__PURE__ */ p("div", {
451
+ className: "flex items-center gap-1.5 min-h-[16px]",
452
+ children: Le ? /* @__PURE__ */ m(le, { children: [/* @__PURE__ */ m("div", {
453
+ className: "relative flex h-2 w-2",
454
+ children: [/* @__PURE__ */ p("span", { className: "animate-ping absolute inline-flex h-full w-full rounded-full bg-amber-400 opacity-75" }), /* @__PURE__ */ p("span", { className: "relative inline-flex rounded-full h-2 w-2 bg-amber-500" })]
455
+ }), /* @__PURE__ */ p("span", {
456
+ className: "text-amber-600 dark:text-amber-400 font-medium",
457
+ children: "Autosaving settings..."
458
+ })] }) : Re ? /* @__PURE__ */ m("span", {
459
+ className: "text-red-500 font-medium",
460
+ children: ["Error saving settings: ", Re]
461
+ }) : ze ? /* @__PURE__ */ m("span", {
462
+ className: "text-emerald-600 dark:text-emerald-400 font-medium",
463
+ children: ["Settings autosaved at ", ze.toLocaleTimeString([], {
464
+ hour: "2-digit",
465
+ minute: "2-digit",
466
+ second: "2-digit"
467
+ })]
468
+ }) : /* @__PURE__ */ p("span", {
469
+ className: "text-muted-foreground/60",
470
+ children: "Settings autosave in draft mode"
471
+ })
472
+ })]
473
+ }),
474
+ /* @__PURE__ */ m("div", {
475
+ className: "grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-2.5",
476
+ children: [
477
+ /* @__PURE__ */ m("div", {
478
+ className: "col-span-2 space-y-1",
479
+ children: [
480
+ /* @__PURE__ */ p(_, {
481
+ htmlFor: "title",
482
+ className: "text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none",
483
+ children: "Title"
484
+ }),
485
+ /* @__PURE__ */ p(g, {
486
+ id: "title",
487
+ placeholder: "Product title",
488
+ ...j("title"),
489
+ className: "h-8 text-sm"
490
+ }),
491
+ I.title && /* @__PURE__ */ p("p", {
492
+ className: "text-destructive text-[11px] leading-none",
493
+ children: I.title.message
494
+ })
495
+ ]
496
+ }),
497
+ /* @__PURE__ */ m("div", {
498
+ className: "col-span-2 space-y-1",
499
+ children: [
500
+ /* @__PURE__ */ p(_, {
501
+ htmlFor: "slug",
502
+ className: "text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none",
503
+ children: "Slug"
504
+ }),
505
+ /* @__PURE__ */ p(g, {
506
+ id: "slug",
507
+ placeholder: "product-slug",
508
+ ...j("slug"),
509
+ className: "h-8 text-sm"
510
+ }),
511
+ I.slug && /* @__PURE__ */ p("p", {
512
+ className: "text-destructive text-[11px] leading-none",
513
+ children: I.slug.message
514
+ })
515
+ ]
516
+ }),
517
+ /* @__PURE__ */ m("div", {
518
+ className: "col-span-1 space-y-1",
519
+ children: [
520
+ /* @__PURE__ */ p(_, {
521
+ htmlFor: "sku",
522
+ className: "text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none",
523
+ children: "SKU"
524
+ }),
525
+ /* @__PURE__ */ p(g, {
526
+ id: "sku",
527
+ placeholder: "SKU",
528
+ ...j("sku"),
529
+ className: "h-8 text-sm font-mono"
530
+ }),
531
+ I.sku && /* @__PURE__ */ p("p", {
532
+ className: "text-destructive text-[11px] leading-none",
533
+ children: I.sku.message
534
+ })
535
+ ]
536
+ }),
537
+ /* @__PURE__ */ m("div", {
538
+ className: "col-span-1 space-y-1",
539
+ children: [/* @__PURE__ */ p(_, {
540
+ htmlFor: "upc_ean",
541
+ className: "text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none",
542
+ children: "UPC / EAN"
543
+ }), /* @__PURE__ */ p(g, {
544
+ id: "upc_ean",
545
+ placeholder: "000000000",
546
+ ...j("upc"),
547
+ className: "h-8 text-sm font-mono",
548
+ readOnly: Y
549
+ })]
550
+ })
551
+ ]
552
+ }),
553
+ /* @__PURE__ */ m("div", {
554
+ className: "grid grid-cols-2 md:grid-cols-3 lg:grid-cols-12 gap-2.5 mt-2",
555
+ children: [
556
+ /* @__PURE__ */ m("div", {
557
+ className: `${y ? "lg:col-span-3" : "lg:col-span-4"} col-span-2 space-y-1`,
558
+ children: [/* @__PURE__ */ p(_, {
559
+ htmlFor: "meta_title",
560
+ className: "text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none",
561
+ children: "Meta Title"
562
+ }), /* @__PURE__ */ p(g, {
563
+ id: "meta_title",
564
+ ...j("meta_title"),
565
+ placeholder: "SEO page title (50-60 chars)",
566
+ className: "h-8 text-sm"
567
+ })]
568
+ }),
569
+ /* @__PURE__ */ m("div", {
570
+ className: "lg:col-span-4 col-span-2 space-y-1",
571
+ children: [/* @__PURE__ */ p(_, {
572
+ htmlFor: "meta_description",
573
+ className: "text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none",
574
+ children: "Meta Description"
575
+ }), /* @__PURE__ */ p(g, {
576
+ id: "meta_description",
577
+ ...j("meta_description"),
578
+ placeholder: "SEO description (150-160 chars)",
579
+ className: "h-8 text-sm"
580
+ })]
581
+ }),
582
+ /* @__PURE__ */ m("div", {
583
+ className: `${y ? "lg:col-span-3" : "lg:col-span-4"} col-span-2 space-y-1`,
584
+ children: [/* @__PURE__ */ p(_, {
585
+ htmlFor: "custom_canonical",
586
+ className: "text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none",
587
+ children: "Canonical URL (optional)"
588
+ }), /* @__PURE__ */ p(g, {
589
+ id: "custom_canonical",
590
+ ...j("custom_canonical"),
591
+ placeholder: "Blank = self-referencing. Absolute https://… URL or /relative path to override.",
592
+ className: "h-8 text-sm"
593
+ })]
594
+ })
595
+ ]
596
+ })
597
+ ]
598
+ }),
599
+ /* @__PURE__ */ p(v, {
600
+ title: "Product Categories",
601
+ description: "Assign this product to one or more categories.",
602
+ children: /* @__PURE__ */ p(c, {
603
+ categories: Ae,
604
+ selectedIds: P("category_ids") || [],
605
+ onChange: (e) => N("category_ids", e, {
606
+ shouldDirty: !0,
607
+ shouldValidate: !0
608
+ })
609
+ })
610
+ }),
611
+ /* @__PURE__ */ m("section", {
612
+ className: "rounded-lg border bg-card p-3 shadow-sm space-y-3",
613
+ children: [W && /* @__PURE__ */ m("div", {
614
+ className: "flex items-center justify-between gap-4 flex-wrap border-b border-muted/50 pb-2",
615
+ children: [/* @__PURE__ */ p("div", {
616
+ className: "flex items-center gap-4",
617
+ children: /* @__PURE__ */ m("div", {
618
+ className: "space-y-0.5",
619
+ children: [/* @__PURE__ */ p("h2", {
620
+ className: "text-sm font-bold tracking-tight",
621
+ children: "Pricing & Inventory"
622
+ }), /* @__PURE__ */ p("p", {
623
+ className: "text-[11px] text-muted-foreground leading-none",
624
+ children: "Manage simple or variant pricing."
625
+ })]
626
+ })
627
+ }), /* @__PURE__ */ m("div", {
628
+ className: "flex items-center gap-3",
629
+ children: [/* @__PURE__ */ m("div", {
630
+ className: "flex items-center gap-2 bg-muted/40 rounded-md px-2.5 py-1.5",
631
+ children: [/* @__PURE__ */ p("span", {
632
+ className: "text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none",
633
+ children: "Stock"
634
+ }), /* @__PURE__ */ p(g, {
635
+ id: "stock",
636
+ type: "number",
637
+ min: "0",
638
+ ...j("stock", { valueAsNumber: !0 }),
639
+ placeholder: "0",
640
+ readOnly: Y,
641
+ className: `${ct} h-8 w-20 text-sm text-center font-mono bg-background`
642
+ })]
643
+ }), Y ? /* @__PURE__ */ p(h, {
644
+ variant: "secondary",
645
+ className: "text-[11px] py-0 px-2 h-5",
646
+ children: "Variant pricing"
647
+ }) : null]
648
+ })]
649
+ }), W ? /* @__PURE__ */ m("div", {
650
+ className: "space-y-3",
651
+ children: [
652
+ /* @__PURE__ */ m("div", {
653
+ className: "w-full",
654
+ children: [
655
+ /* @__PURE__ */ p(a, {
656
+ idPrefix: "product",
657
+ currencies: O,
658
+ prices: X.prices,
659
+ salePrices: X.salePrices,
660
+ managedCurrencyCodes: A,
661
+ onPriceChange: it,
662
+ onSalePriceChange: at,
663
+ onAutoFill: ot,
664
+ readOnly: Y,
665
+ helperText: Y ? "Parent prices stay as a fallback, but active variants define the live shopper price." : void 0,
666
+ trailing: /* @__PURE__ */ p(o, {
667
+ idPrefix: "product",
668
+ startAt: P("sale_start_at"),
669
+ endAt: P("sale_end_at"),
670
+ onChange: (e, t) => N(e, t, {
671
+ shouldDirty: !0,
672
+ shouldValidate: !0
673
+ }),
674
+ error: I.sale_end_at?.message,
675
+ bare: !0
676
+ })
677
+ }),
678
+ I.price && /* @__PURE__ */ p("p", {
679
+ className: "text-destructive text-sm mt-1",
680
+ children: I.price.message
681
+ }),
682
+ I.sale_price && /* @__PURE__ */ p("p", {
683
+ className: "text-destructive text-sm mt-1",
684
+ children: I.sale_price.message
685
+ }),
686
+ I.stock && /* @__PURE__ */ p("p", {
687
+ className: "text-destructive text-[10px] font-medium leading-none mt-1",
688
+ children: I.stock.message
689
+ })
690
+ ]
691
+ }),
692
+ /* @__PURE__ */ m("div", {
693
+ className: "flex items-center justify-between gap-3 rounded border border-dashed p-2.5 bg-muted/5",
694
+ children: [/* @__PURE__ */ p("span", {
695
+ className: "text-xs font-bold uppercase tracking-wider text-muted-foreground",
696
+ children: Y ? "Variations Active" : "Variations"
697
+ }), /* @__PURE__ */ p(fe, {
698
+ type: "button",
699
+ variant: E ? "outline" : "default",
700
+ onClick: () => D((e) => !e),
701
+ size: "sm",
702
+ className: "h-7 text-xs px-3",
703
+ children: E ? "Hide" : "Manage"
704
+ })]
705
+ }),
706
+ E && /* @__PURE__ */ p("div", {
707
+ className: "border-t pt-3",
708
+ children: /* @__PURE__ */ p(s, {
709
+ globalAttributes: we,
710
+ currentLanguageCode: $e,
711
+ baseSku: P("sku") || "",
712
+ basePrice: G || 0,
713
+ basePrices: q,
714
+ baseSalePrice: typeof K == "number" ? K : null,
715
+ baseSalePrices: J,
716
+ currencies: O,
717
+ availableVariantImages: lt,
718
+ initialVariationAttributes: e?.variation_attributes,
719
+ initialVariants: et,
720
+ onChange: st
721
+ })
722
+ })
723
+ ]
724
+ }) : /* @__PURE__ */ m(le, { children: [/* @__PURE__ */ m("div", {
725
+ className: "space-y-4",
726
+ children: [/* @__PURE__ */ m("div", {
727
+ className: "flex items-end gap-4 w-full",
728
+ children: [
729
+ /* @__PURE__ */ m("div", {
730
+ className: "flex-1",
731
+ children: [/* @__PURE__ */ p(_, {
732
+ htmlFor: "freemius_product_id",
733
+ className: "text-[11px] uppercase tracking-wider text-muted-foreground font-bold mb-1.5 block",
734
+ children: "Freemius Product ID"
735
+ }), /* @__PURE__ */ p(g, {
736
+ id: "freemius_product_id",
737
+ ...j("freemius_product_id"),
738
+ className: "h-9"
739
+ })]
740
+ }),
741
+ /* @__PURE__ */ m("div", {
742
+ className: "flex-1",
743
+ children: [/* @__PURE__ */ p(_, {
744
+ htmlFor: "freemius_plan_id",
745
+ className: "text-[11px] uppercase tracking-wider text-muted-foreground font-bold mb-1.5 block",
746
+ children: "Freemius Plan ID"
747
+ }), /* @__PURE__ */ p(g, {
748
+ id: "freemius_plan_id",
749
+ ...j("freemius_plan_id"),
750
+ className: "h-9"
751
+ })]
752
+ }),
753
+ Je ? /* @__PURE__ */ p(i, {
754
+ productId: P("freemius_product_id"),
755
+ hasOpenDraft: je
756
+ }) : null
757
+ ]
758
+ }), /* @__PURE__ */ m("div", {
759
+ className: "bg-muted/10 border rounded-md overflow-hidden",
760
+ children: [/* @__PURE__ */ m("div", {
761
+ className: "flex flex-wrap items-center gap-6 bg-muted/20 border-b p-2.5 px-4",
762
+ children: [
763
+ /* @__PURE__ */ m("div", {
764
+ className: "flex items-center gap-2",
765
+ children: [/* @__PURE__ */ p("span", {
766
+ className: "text-[11px] font-bold uppercase tracking-wider text-muted-foreground",
767
+ children: "Free Trial"
768
+ }), /* @__PURE__ */ m(h, {
769
+ variant: "outline",
770
+ className: "font-mono text-xs shadow-sm bg-background",
771
+ children: [String(P("trial_period_days") || 0), " Days"]
772
+ })]
773
+ }),
774
+ /* @__PURE__ */ m("div", {
775
+ className: "flex items-center gap-2",
776
+ children: [/* @__PURE__ */ p("span", {
777
+ className: "text-[11px] font-bold uppercase tracking-wider text-muted-foreground",
778
+ children: "Card Required"
779
+ }), /* @__PURE__ */ p(h, {
780
+ variant: Xe ? "default" : "secondary",
781
+ className: "text-xs shadow-sm",
782
+ children: Xe ? "Yes" : "No"
783
+ })]
784
+ }),
785
+ /* @__PURE__ */ p("span", {
786
+ className: "text-[10px] text-muted-foreground ml-auto",
787
+ children: "Managed in Freemius dashboard"
788
+ }),
789
+ /* @__PURE__ */ p("input", {
790
+ type: "hidden",
791
+ ...j("trial_period_days", { valueAsNumber: !0 })
792
+ })
793
+ ]
794
+ }), /* @__PURE__ */ m("div", {
795
+ className: "w-full p-4 pt-3 space-y-2",
796
+ children: [/* @__PURE__ */ p(a, {
797
+ idPrefix: "product",
798
+ currencies: O,
799
+ prices: X.prices,
800
+ salePrices: X.salePrices,
801
+ managedCurrencyCodes: A,
802
+ onPriceChange: it,
803
+ onSalePriceChange: at,
804
+ onAutoFill: ot,
805
+ readOnly: !0,
806
+ trailing: /* @__PURE__ */ p(o, {
807
+ idPrefix: "product",
808
+ startAt: P("sale_start_at"),
809
+ endAt: P("sale_end_at"),
810
+ onChange: (e, t) => N(e, t, {
811
+ shouldDirty: !0,
812
+ shouldValidate: !0
813
+ }),
814
+ error: I.sale_end_at?.message,
815
+ bare: !0
816
+ })
817
+ }), /* @__PURE__ */ p("p", {
818
+ className: "text-[10px] leading-snug text-muted-foreground",
819
+ children: "Scheduling a sale on a Freemius product generates a time-bounded Freemius coupon so the discount is enforced at Freemius checkout."
820
+ })]
821
+ })]
822
+ })]
823
+ }), Ee && /* @__PURE__ */ p("div", {
824
+ className: "pt-2 border-t",
825
+ children: Ee
826
+ })] })]
827
+ }),
828
+ /* @__PURE__ */ p(v, {
829
+ title: "Product Description",
830
+ hideHeader: !0,
831
+ children: /* @__PURE__ */ p("div", {
832
+ className: "space-y-2",
833
+ children: /* @__PURE__ */ m("div", {
834
+ className: "space-y-1",
835
+ children: [/* @__PURE__ */ p(_, {
836
+ htmlFor: "short_description",
837
+ className: "text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none",
838
+ children: "Short Description"
839
+ }), /* @__PURE__ */ p(g, {
840
+ id: "short_description",
841
+ ...j("short_description"),
842
+ placeholder: "Brief summary for product cards...",
843
+ className: "h-8 text-sm"
844
+ })]
845
+ })
846
+ })
847
+ }),
848
+ /* @__PURE__ */ m(v, {
849
+ title: "Media Gallery",
850
+ description: "Drag to reorder. First image is the hero.",
851
+ children: [/* @__PURE__ */ p(r, {
852
+ initialMedia: Z,
853
+ onUpdate: rt,
854
+ mediaPickerNode: Ce
855
+ }), /* @__PURE__ */ p("input", {
856
+ type: "hidden",
857
+ ...j("product_media")
858
+ })]
859
+ }),
860
+ !y && /* @__PURE__ */ m("div", {
861
+ className: "rounded-lg border bg-card p-3 px-4 shadow-sm flex items-center justify-between gap-3 flex-wrap",
862
+ children: [/* @__PURE__ */ p("p", {
863
+ className: "text-xs text-muted-foreground",
864
+ children: "New products start as a draft. Publish it from the top bar once it's ready."
865
+ }), /* @__PURE__ */ p(fe, {
866
+ disabled: w,
867
+ type: "submit",
868
+ size: "sm",
869
+ className: "h-8 text-sm px-5",
870
+ children: w ? "Saving..." : "Save Changes"
871
+ })]
872
+ })
873
+ ]
874
+ })
875
+ ]
876
+ });
697
877
  }
698
- export {
699
- Ur as ProductForm
700
- };
878
+ //#endregion
879
+ export { Ce as ProductForm };