@mercurjs/vendor 2.1.2 → 2.2.0-canary.2

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 (230) hide show
  1. package/dist/{[id]-H3C3ZSC6.js → [id]-3EC6HYXL.js} +25 -21
  2. package/dist/{[id]-TO6KT3ZE.js → [id]-4OBGG7OH.js} +23 -21
  3. package/dist/{[id]-6PXEWRG7.js → [id]-7BAKUHUO.js} +13 -13
  4. package/dist/{[id]-X4DDKOMQ.js → [id]-COLO4TQJ.js} +26 -22
  5. package/dist/{[id]-7RUAH3TI.js → [id]-K2CT7BXQ.js} +4 -4
  6. package/dist/{[id]-3G5G7ZFV.js → [id]-KJIQTFGE.js} +22 -20
  7. package/dist/{[id]-4VCL3MMM.js → [id]-KRLGIVLR.js} +26 -22
  8. package/dist/{[id]-B3LHVQM5.js → [id]-KVWYLDN3.js} +25 -21
  9. package/dist/{[id]-INOFZHL7.js → [id]-LTNOHLGE.js} +16 -16
  10. package/dist/{[id]-PDGHF5J2.js → [id]-LUFRJLAU.js} +35 -31
  11. package/dist/[id]-UUUQK22M.js +1442 -0
  12. package/dist/{[id]-T2ROPEGY.js → [id]-Y2ISCLUD.js} +7 -7
  13. package/dist/{[id]-Y7GAMNC5.js → [id]-ZCMSBEVM.js} +4 -4
  14. package/dist/{[id]-UTKO3VG4.js → [id]-ZWWMJAKI.js} +9 -9
  15. package/dist/{[location_id]-D55RQOXT.js → [location_id]-NUBXDDJC.js} +9 -9
  16. package/dist/{[province_id]-OFH2ZOFQ.js → [province_id]-H2QAPKVH.js} +20 -18
  17. package/dist/{add-C6OX5C54.js → add-FIWTANZX.js} +34 -30
  18. package/dist/add-PBZQCIZQ.js +392 -0
  19. package/dist/{add-customer-groups-PJRJUWS2.js → add-customer-groups-RAHCP67U.js} +16 -14
  20. package/dist/{add-products-INOLNPO6.js → add-products-N3V2MVLD.js} +23 -19
  21. package/dist/{add-promotions-AHDOP52Q.js → add-promotions-CSCAJZHV.js} +7 -7
  22. package/dist/{add-to-campaign-HL6NGRR4.js → add-to-campaign-DLP7PSQB.js} +4 -4
  23. package/dist/{address-KRENKSLP.js → address-7F5SN7PV.js} +17 -15
  24. package/dist/{adjust-inventory-H4EUP7J3.js → adjust-inventory-SZF4W7LR.js} +2 -2
  25. package/dist/{allocate-items-SUCUZU4D.js → allocate-items-SDFS5GYN.js} +6 -6
  26. package/dist/{areas-UUMZDXLX.js → areas-7Y6BVS5A.js} +8 -8
  27. package/dist/{attributes-CALEHJJG.js → attributes-MBZ76HVZ.js} +3 -3
  28. package/dist/{breadcrumb-BS7Y5OKF.js → breadcrumb-65SAGUUL.js} +2 -2
  29. package/dist/{breadcrumb-6W2VP3OZ.js → breadcrumb-7PURSRTT.js} +13 -11
  30. package/dist/{breadcrumb-M5Z5WA6I.js → breadcrumb-EDPMEN2P.js} +2 -2
  31. package/dist/breadcrumb-FLDHJRVY.js +26 -0
  32. package/dist/{breadcrumb-VNNZ3TTW.js → breadcrumb-HND5FFWC.js} +2 -2
  33. package/dist/{breadcrumb-OIGGCB3L.js → breadcrumb-QV2IAX7N.js} +8 -2
  34. package/dist/{breadcrumb-KQSFIXQ4.js → breadcrumb-VWELWDB2.js} +1 -1
  35. package/dist/{breadcrumb-IG7VZGW2.js → breadcrumb-WRG4SITG.js} +13 -11
  36. package/dist/{breadcrumb-TW5JEOYS.js → breadcrumb-ZCG2RHIU.js} +12 -10
  37. package/dist/{campaigns-HS6MIO7X.js → campaigns-L6ULR6KR.js} +5 -5
  38. package/dist/{categories-PKWR3FM3.js → categories-FUZQKBXV.js} +6 -6
  39. package/dist/{chunk-PDQSPKG5.js → chunk-2DXNJURE.js} +1 -1
  40. package/dist/{chunk-5UD4P6YL.js → chunk-2USXZSTK.js} +4 -4
  41. package/dist/chunk-35G3SZRN.js +101 -0
  42. package/dist/{chunk-6SBMVLJ2.js → chunk-36L54SQQ.js} +1 -1
  43. package/dist/chunk-432S4FGR.js +0 -0
  44. package/dist/{chunk-KQGVSLUI.js → chunk-44RQ5PTN.js} +1803 -914
  45. package/dist/{chunk-Y2QI7KWS.js → chunk-4LVP635F.js} +408 -664
  46. package/dist/{chunk-UL4O5M4S.js → chunk-4S6XGIC6.js} +1 -18
  47. package/dist/chunk-5ATEALH7.js +68 -0
  48. package/dist/{chunk-CNLP35S7.js → chunk-5L2DCA4W.js} +16 -31
  49. package/dist/{chunk-WITQNQXN.js → chunk-6BS2AVGJ.js} +3 -3
  50. package/dist/{chunk-CYTNBXWF.js → chunk-6Y53VZ3C.js} +9 -9
  51. package/dist/{chunk-ZYOXKUKZ.js → chunk-7LBY5JLV.js} +1 -1
  52. package/dist/chunk-7SLWXX6L.js +811 -0
  53. package/dist/{chunk-LQYMBSRQ.js → chunk-AIZM66CG.js} +1 -1
  54. package/dist/{chunk-IZ5RG5XI.js → chunk-AJLGY3LQ.js} +1 -21
  55. package/dist/{chunk-WFE6CT6M.js → chunk-AVOIZO63.js} +21 -77
  56. package/dist/chunk-CFRWIQIZ.js +43 -0
  57. package/dist/{chunk-WNVEMFIK.js → chunk-CNMY5HVP.js} +2 -2
  58. package/dist/{chunk-BLVJAKBA.js → chunk-DDH7ULIQ.js} +1 -1
  59. package/dist/chunk-DIW4GRTI.js +503 -0
  60. package/dist/{chunk-JQP7MOFH.js → chunk-DVEKYLPV.js} +1 -1
  61. package/dist/{chunk-ZZO3INVE.js → chunk-DZIXC7OE.js} +1428 -1325
  62. package/dist/{chunk-QX45GVAL.js → chunk-EIUYXS7E.js} +8 -8
  63. package/dist/{chunk-N7OVXN72.js → chunk-EROX26D4.js} +1 -1
  64. package/dist/{chunk-2RHAI7WK.js → chunk-EZ3JOAUS.js} +1 -1
  65. package/dist/{chunk-HFRHHT36.js → chunk-FDR22JMM.js} +63 -8
  66. package/dist/{chunk-PEKANQ3T.js → chunk-FJUUGFXL.js} +2 -2
  67. package/dist/{chunk-3CK6OINO.js → chunk-GDWBOQI5.js} +3 -5
  68. package/dist/chunk-GGWUWT55.js +95 -0
  69. package/dist/chunk-GKZHBXZK.js +426 -0
  70. package/dist/{chunk-47SXTGLN.js → chunk-GXIAIITP.js} +63 -200
  71. package/dist/{chunk-4MFMCZEJ.js → chunk-H6LZ77GX.js} +2 -2
  72. package/dist/chunk-K4X324QP.js +18 -0
  73. package/dist/{chunk-VQ5EKDA3.js → chunk-KD7RYE6R.js} +1 -1
  74. package/dist/chunk-LEWA4BPH.js +18 -0
  75. package/dist/{chunk-7Q5SDEK7.js → chunk-LNM2D2I4.js} +4 -4
  76. package/dist/{chunk-LPOAVK6Y.js → chunk-LQD232FW.js} +47 -12
  77. package/dist/{chunk-OXXL4WQU.js → chunk-M7KSRYRI.js} +5 -5
  78. package/dist/{chunk-I2IKYOZX.js → chunk-N4MVIBFM.js} +19 -19
  79. package/dist/{chunk-PCMNEUMV.js → chunk-NHFEY3EI.js} +1 -1
  80. package/dist/{chunk-RTAWYMQP.js → chunk-NJMNYS7G.js} +1 -1
  81. package/dist/{chunk-HGQTL7NX.js → chunk-NSZQERLE.js} +2 -2
  82. package/dist/{chunk-RL7SFZOF.js → chunk-NXNJQZCP.js} +1 -1
  83. package/dist/{chunk-D2MA5TAP.js → chunk-PBD36EZJ.js} +2 -2
  84. package/dist/{chunk-4ZGFODSC.js → chunk-PZ44R4AS.js} +1 -1
  85. package/dist/{chunk-ZEVYT6IX.js → chunk-QNNJN4H6.js} +116 -286
  86. package/dist/{chunk-WBI7FEGI.js → chunk-QS6RWIBL.js} +1 -1
  87. package/dist/chunk-QT7YFHCA.js +198 -0
  88. package/dist/{chunk-GYV6SKY7.js → chunk-QXLRABYH.js} +4 -6
  89. package/dist/chunk-RTBNJQOV.js +2063 -0
  90. package/dist/chunk-RXZFEFNV.js +73 -0
  91. package/dist/{chunk-RUE5BPC2.js → chunk-RZLN2Q6G.js} +1 -1
  92. package/dist/{chunk-NYDJTWRL.js → chunk-SGR4DMCW.js} +4 -4
  93. package/dist/chunk-T6LHVNWO.js +27 -0
  94. package/dist/{chunk-DKQ4XMSN.js → chunk-TNVYTMBL.js} +6 -6
  95. package/dist/{chunk-32RYSB2V.js → chunk-TODJFRLH.js} +2 -2
  96. package/dist/{chunk-P3ZTO6T2.js → chunk-UAF2S447.js} +1 -1
  97. package/dist/{chunk-J6BRLL3F.js → chunk-UCQKXXLD.js} +2 -2
  98. package/dist/chunk-UORPTGV2.js +114 -0
  99. package/dist/{chunk-X4FLOQ45.js → chunk-WBHFU3MG.js} +2 -2
  100. package/dist/chunk-WLT7K7K7.js +63 -0
  101. package/dist/{chunk-4URLUCTD.js → chunk-WUPJADSO.js} +2 -2
  102. package/dist/{chunk-5M3SL4UZ.js → chunk-X2FVFUET.js} +9 -104
  103. package/dist/{chunk-ITI54CII.js → chunk-X4INVIWL.js} +5 -5
  104. package/dist/{chunk-PTW7JNAP.js → chunk-XFQJU6FA.js} +4 -4
  105. package/dist/{collections-DJZI2RM2.js → collections-YCAAFGSW.js} +22 -19
  106. package/dist/{configuration-RHPIO2QT.js → configuration-C4IGBNXH.js} +1 -1
  107. package/dist/{configuration-GN3TO77H.js → configuration-UOSNP45I.js} +3 -3
  108. package/dist/{create-G4T2PAJH.js → create-35MYQPVM.js} +23 -21
  109. package/dist/{create-3EK5CNNX.js → create-B5ZXTK3K.js} +33 -29
  110. package/dist/{create-HKJVSFB7.js → create-BJ4OO6LS.js} +23 -21
  111. package/dist/create-FCKGCZSM.js +210 -0
  112. package/dist/{create-7S7CZWEN.js → create-GB3ZA4LH.js} +4 -4
  113. package/dist/{create-YO55Z3YD.js → create-HI5UI2EZ.js} +32 -38
  114. package/dist/create-JDGM5KXE.js +193 -0
  115. package/dist/{create-IDVCZHIX.js → create-ORXYT74H.js} +14 -12
  116. package/dist/{create-GHM7OTCR.js → create-R7K3ECN6.js} +1 -1
  117. package/dist/{create-D6EW3EWC.js → create-SFU3W3ZH.js} +1 -1
  118. package/dist/{create-33TRLASX.js → create-UPYB65PD.js} +1 -1
  119. package/dist/{create-OCFPLNNY.js → create-UQNYMVBM.js} +6 -6
  120. package/dist/{create-OGLPDVOI.js → create-XAD5NMSJ.js} +37 -35
  121. package/dist/{create-KGYL7FBM.js → create-XVHOCZHJ.js} +1 -1
  122. package/dist/{create-4AE3VTWN.js → create-YBF4YGWG.js} +2 -2
  123. package/dist/{create-3ZVXEPX5.js → create-YDDBH4VQ.js} +25 -21
  124. package/dist/{customers-6ZLE65UX.js → customers-ETXVNM3G.js} +5 -5
  125. package/dist/{edit-QBISX7D3.js → edit-2Q7TRUTL.js} +14 -12
  126. package/dist/{edit-B5B3XKDM.js → edit-522DG3BY.js} +1 -1
  127. package/dist/{edit-ATXE6CM5.js → edit-C4OCKQVU.js} +1 -1
  128. package/dist/{edit-IR6V2IDN.js → edit-FKXIQ6ZI.js} +19 -17
  129. package/dist/{edit-4HZHLYI3.js → edit-GQNIINRR.js} +1 -1
  130. package/dist/{edit-LRRJTHV2.js → edit-KAKVPHZZ.js} +1 -1
  131. package/dist/{edit-ZSOI56BQ.js → edit-L5ZZLMAY.js} +22 -22
  132. package/dist/{edit-GIJXLMC3.js → edit-O4JLGKQR.js} +2 -2
  133. package/dist/{edit-5CJZRHAA.js → edit-ORXS3A2Y.js} +1 -1
  134. package/dist/{edit-FC64DWB2.js → edit-Q3UQIOLS.js} +1 -1
  135. package/dist/{edit-7HTH2UJF.js → edit-REDDBLTA.js} +3 -3
  136. package/dist/{edit-2KRJIPRK.js → edit-SGUY2CCK.js} +19 -17
  137. package/dist/{edit-B75KK5ZX.js → edit-UGEC27HP.js} +35 -31
  138. package/dist/{edit-FNDDSSMT.js → edit-VKT62KHG.js} +37 -8
  139. package/dist/{edit-7GVP6SRA.js → edit-ZAHCMF5U.js} +1 -1
  140. package/dist/{edit-RNT555GP.js → edit-ZCXUG42Q.js} +13 -11
  141. package/dist/{edit-MYSWY6W4.js → edit-ZMERG3L7.js} +1 -1
  142. package/dist/{edit-budget-J27CSEZH.js → edit-budget-L3CCEWNF.js} +1 -1
  143. package/dist/{edit-inventory-item-US77M2FF.js → edit-inventory-item-6B7ITDGD.js} +2 -2
  144. package/dist/{edit-inventory-item-attributes-UGAE2NAZ.js → edit-inventory-item-attributes-Y7MQZLXI.js} +3 -3
  145. package/dist/{fulfillment-DCS67LTK.js → fulfillment-75Z4H23W.js} +16 -14
  146. package/dist/{fulfillment-providers-GM5PO6N3.js → fulfillment-providers-DQAU43JZ.js} +20 -17
  147. package/dist/index.css +27 -62
  148. package/dist/index.d.ts +3 -10
  149. package/dist/index.js +522 -458
  150. package/dist/{inventory-OPZ2FSEE.js → inventory-KAUVPMPZ.js} +6 -6
  151. package/dist/{invite-KEJLNXEZ.js → invite-CI2P4GF6.js} +15 -12
  152. package/dist/{invite-764K3TJS.js → invite-Q6EYDZVQ.js} +24 -21
  153. package/dist/loader-FBB5OQRT.js +31 -0
  154. package/dist/{locations-ZVPTQCQY.js → locations-INS6FTMJ.js} +4 -4
  155. package/dist/{login-OUHRNNXA.js → login-KY342RMK.js} +12 -10
  156. package/dist/{manage-locations-YUKEFCBJ.js → manage-locations-WNHEBS3A.js} +2 -2
  157. package/dist/{media-4KYFHB5V.js → media-B6ME2WXY.js} +41 -9
  158. package/dist/{metadata-NYYL26MQ.js → metadata-2CMH4I6U.js} +16 -14
  159. package/dist/{metadata-AWUKZ25V.js → metadata-5BPOBBU2.js} +3 -3
  160. package/dist/{metadata-OCE6A3JE.js → metadata-GWI6R4ES.js} +15 -13
  161. package/dist/{metadata-G7KZXVNE.js → metadata-NUXUC2JA.js} +15 -13
  162. package/dist/{metadata-XP3ZYW2M.js → metadata-TLDUF5KV.js} +17 -15
  163. package/dist/{metadata-PYY4IB7K.js → metadata-WR4RFXO5.js} +16 -14
  164. package/dist/offer-create-page-4Z6L63BU.js +743 -0
  165. package/dist/offer-detail-page-6MAHNNIO.js +488 -0
  166. package/dist/offer-edit-page-DYQFU6JU.js +151 -0
  167. package/dist/offer-inventory-batch-page-WKCWNDNK.js +290 -0
  168. package/dist/offer-pricing-edit-page-4TYGGSOE.js +195 -0
  169. package/dist/offers-ZG6OTDZ2.js +32 -0
  170. package/dist/{onboarding-WXZHW62K.js → onboarding-43LQQQGQ.js} +22 -20
  171. package/dist/{orders-LWJ472VM.js → orders-ZV4D6L2V.js} +24 -21
  172. package/dist/organization-ZTQGRJWS.js +375 -0
  173. package/dist/{organize-RFOMQCBG.js → organize-HNJUHEEG.js} +4 -4
  174. package/dist/{organize-OVKJ3HZO.js → organize-K6QMAMEN.js} +4 -4
  175. package/dist/pages/index.d.ts +415 -758
  176. package/dist/pages/index.js +81 -77
  177. package/dist/{payment-details-UVXYCTUK.js → payment-details-64US5XWD.js} +17 -15
  178. package/dist/{payouts-TR7K5I37.js → payouts-UXJDTXDL.js} +6 -6
  179. package/dist/{price-lists-S2WNELFZ.js → price-lists-KBPUVSZI.js} +8 -8
  180. package/dist/{pricing-UF27DAXA.js → pricing-DF6C5XK4.js} +35 -32
  181. package/dist/{product-tags-2CKH2M6D.js → product-tags-6MZB4W5R.js} +32 -28
  182. package/dist/{product-types-FX43JEO2.js → product-types-UUHBV4IZ.js} +5 -5
  183. package/dist/product-variant-detail-RVWEYVPC.js +220 -0
  184. package/dist/{product-variant-edit-P3DSIFE3.js → product-variant-edit-YYNPHE4L.js} +126 -66
  185. package/dist/{products-H5EMRJYS.js → products-IWKTGZS6.js} +23 -19
  186. package/dist/{products-2LHGS7X3.js → products-MZBU5MEV.js} +40 -43
  187. package/dist/{professional-details-HYKTH44B.js → professional-details-5T2VS6MM.js} +16 -14
  188. package/dist/{profile-PB27WIRW.js → profile-6XGHAT7H.js} +20 -18
  189. package/dist/{promotions-5EYPGHJP.js → promotions-O7U4BTK6.js} +8 -8
  190. package/dist/{register-4O4F6YZK.js → register-N6WOSMLA.js} +16 -14
  191. package/dist/{reset-password-GTWLBOFK.js → reset-password-EICPAY2N.js} +1 -1
  192. package/dist/{return-reasons-LOKYRGMI.js → return-reasons-IX3LIOCU.js} +16 -14
  193. package/dist/{sales-channels-7R2IY3KG.js → sales-channels-B6FULRWI.js} +8 -7
  194. package/dist/{sales-channels-Y4LRP7JC.js → sales-channels-JW3QUYR7.js} +8 -7
  195. package/dist/{settings-2XDLFYMS.js → settings-MV53ZZ53.js} +39 -35
  196. package/dist/{shipment-4GW2JFWB.js → shipment-Q33QBMXX.js} +13 -11
  197. package/dist/{shipping-profile-R3NABPQF.js → shipping-profile-Y4SNEPZX.js} +2 -2
  198. package/dist/{shipping-profiles-QVKNFLCW.js → shipping-profiles-2NWKCEJK.js} +18 -16
  199. package/dist/{stock-5RXNUPUT.js → stock-7CSVEJJU.js} +19 -17
  200. package/dist/{store-DE2RGX7T.js → store-X23G3JCJ.js} +28 -25
  201. package/dist/{store-closure-DNMCHUXD.js → store-closure-P5PD2RSV.js} +16 -14
  202. package/dist/{store-select-GZEJHRZ7.js → store-select-TREPDS3G.js} +17 -15
  203. package/dist/{tax-regions-UD6P5FVC.js → tax-regions-YXZW7UVX.js} +5 -5
  204. package/dist/{team-JXKAVRPU.js → team-SPP5OY5W.js} +25 -23
  205. package/dist/types-CtCEtTE6.d.ts +16 -0
  206. package/package.json +6 -6
  207. package/dist/[id]-BYP37PU4.js +0 -1314
  208. package/dist/add-KRAGFFBJ.js +0 -158
  209. package/dist/bulk-edit-3SMBLIOA.js +0 -244
  210. package/dist/chunk-4KX6CBJ4.js +0 -178
  211. package/dist/chunk-DLNNTQRY.js +0 -217
  212. package/dist/chunk-FX4V5JCF.js +0 -37
  213. package/dist/chunk-GC33DBKG.js +0 -143
  214. package/dist/chunk-NK4NR6MN.js +0 -173
  215. package/dist/chunk-PFU6FSXY.js +0 -430
  216. package/dist/chunk-QJEOPT2P.js +0 -330
  217. package/dist/chunk-QSGR43JM.js +0 -30
  218. package/dist/chunk-STR3NGWE.js +0 -3736
  219. package/dist/create-3DOO3RNH.js +0 -716
  220. package/dist/create-I7HV3RM6.js +0 -150
  221. package/dist/edit-K2AD335I.js +0 -237
  222. package/dist/edit-VO5XLIEL.js +0 -362
  223. package/dist/edit-stocks-and-prices-MHHQFWFA.js +0 -408
  224. package/dist/organization-LPYQRTQC.js +0 -303
  225. package/dist/prices-3OXV5RGY.js +0 -270
  226. package/dist/product-variant-detail-WV4KXVXR.js +0 -590
  227. package/dist/stock-GPC3BCL6.js +0 -500
  228. package/dist/{chunk-SDSEW72R.js → chunk-E2HQPY32.js} +3 -3
  229. package/dist/{chunk-6WY5X4PE.js → chunk-L7QKFC5N.js} +7 -7
  230. /package/dist/{chunk-CAS74NLJ.js → chunk-YV6MK4PZ.js} +0 -0
@@ -0,0 +1,503 @@
1
+ import {
2
+ optionalInt
3
+ } from "./chunk-AJLGY3LQ.js";
4
+ import {
5
+ i18n
6
+ } from "./chunk-44RQ5PTN.js";
7
+
8
+ // src/pages/products/create/constants.ts
9
+ import { z } from "zod";
10
+
11
+ // src/pages/products/create/utils.ts
12
+ var normalizeProductFormValues = (values) => {
13
+ const thumbnail = values.media?.find((media) => media.isThumbnail)?.url;
14
+ const images = values.media?.filter((media) => !media.isThumbnail).map((media) => ({ url: media.url }));
15
+ const { variantAttributes, productAttributes, attributeValues } = normalizeFormAttributes(values.attributes ?? []);
16
+ return {
17
+ is_giftcard: false,
18
+ status: values.status,
19
+ tags: values?.tags?.length ? values.tags?.map((tag) => ({ id: tag })) : void 0,
20
+ images,
21
+ collection_id: values.collection_id || void 0,
22
+ categories: values.category_id ? [{ id: values.category_id }] : void 0,
23
+ type_id: values.type_id || void 0,
24
+ handle: values.handle?.trim(),
25
+ origin_country: values.origin_country || void 0,
26
+ material: values.material || void 0,
27
+ mid_code: values.mid_code || void 0,
28
+ hs_code: values.hs_code || void 0,
29
+ thumbnail,
30
+ title: values.title.trim(),
31
+ subtitle: values.subtitle?.trim(),
32
+ description: values.description?.trim(),
33
+ discountable: values.discountable,
34
+ width: values.width ? parseFloat(values.width) : void 0,
35
+ length: values.length ? parseFloat(values.length) : void 0,
36
+ height: values.height ? parseFloat(values.height) : void 0,
37
+ weight: values.weight ? parseFloat(values.weight) : void 0,
38
+ variant_attributes: variantAttributes.length ? variantAttributes : void 0,
39
+ product_attributes: productAttributes.length ? productAttributes : void 0,
40
+ attribute_values: Object.keys(attributeValues).length ? attributeValues : void 0,
41
+ variants: normalizeVariants(
42
+ values.variants.filter((variant) => variant.should_create)
43
+ )
44
+ };
45
+ };
46
+ var normalizeVariants = (variants) => {
47
+ return variants.map((variant) => {
48
+ const attrVals = variant.attribute_values;
49
+ const hasAttrVals = attrVals && Object.keys(attrVals).length > 0;
50
+ return {
51
+ title: variant.title || (hasAttrVals ? Object.values(attrVals).join(" / ") : "Default variant"),
52
+ attribute_values: hasAttrVals ? attrVals : void 0,
53
+ sku: variant.sku || void 0,
54
+ variant_rank: variant.variant_rank
55
+ };
56
+ });
57
+ };
58
+ var normalizeFormAttributes = (attributes) => {
59
+ const variantAttributes = [];
60
+ const productAttributes = [];
61
+ const attributeValues = {};
62
+ for (const attr of attributes) {
63
+ if (attr.use_for_variants) {
64
+ if (attr.attribute_id) {
65
+ const valueNames = Array.isArray(attr.values) ? attr.values : attr.values ? [attr.values] : [];
66
+ const nameToId = new Map(
67
+ (attr.available_values ?? []).map((v) => [v.name, v.id])
68
+ );
69
+ const valueIds = valueNames.map((name) => nameToId.get(name)).filter(Boolean);
70
+ variantAttributes.push({
71
+ attribute_id: attr.attribute_id,
72
+ value_ids: valueIds.length ? valueIds : void 0
73
+ });
74
+ } else if (attr.is_custom && attr.title) {
75
+ variantAttributes.push({
76
+ name: attr.title,
77
+ type: attr.type ?? "multi_select",
78
+ values: Array.isArray(attr.values) ? attr.values : attr.values ? [attr.values] : [],
79
+ is_variant_axis: true
80
+ });
81
+ }
82
+ } else {
83
+ const key = attr.title;
84
+ if (!key) continue;
85
+ if (attr.is_custom) {
86
+ const vals = Array.isArray(attr.values) ? attr.values : attr.values ? [attr.values] : [];
87
+ if (vals.length) {
88
+ productAttributes.push({
89
+ name: attr.title,
90
+ type: attr.type ?? "text",
91
+ values: vals,
92
+ is_variant_axis: false
93
+ });
94
+ }
95
+ } else if (attr.attribute_id) {
96
+ const vals = Array.isArray(attr.values) ? attr.values : attr.values ? [attr.values] : [];
97
+ if (!vals.length || vals.every((v) => !v)) continue;
98
+ const type = attr.type;
99
+ const hasPresetValues = type === "single_select" || type === "multi_select";
100
+ if (hasPresetValues) {
101
+ const nameToId = new Map(
102
+ (attr.available_values ?? []).map((v) => [v.name, v.id])
103
+ );
104
+ const valueIds = vals.map((name) => nameToId.get(name)).filter(Boolean);
105
+ if (valueIds.length) {
106
+ productAttributes.push({
107
+ attribute_id: attr.attribute_id,
108
+ value_ids: valueIds
109
+ });
110
+ }
111
+ } else {
112
+ productAttributes.push({
113
+ attribute_id: attr.attribute_id,
114
+ values: vals
115
+ });
116
+ }
117
+ }
118
+ }
119
+ }
120
+ return { variantAttributes, productAttributes, attributeValues };
121
+ };
122
+ var decorateVariantsWithDefaultValues = (variants) => {
123
+ return variants.map((variant) => ({
124
+ ...variant,
125
+ title: variant.title || "",
126
+ sku: variant.sku || ""
127
+ }));
128
+ };
129
+ var getPermutations = (data) => {
130
+ if (data.length === 0) return [];
131
+ if (data.length === 1) {
132
+ return data[0].values.map((value) => ({ [data[0].title]: value }));
133
+ }
134
+ const [first, ...rest] = data;
135
+ return first.values.flatMap(
136
+ (value) => getPermutations(rest).map((perm) => ({ [first.title]: value, ...perm }))
137
+ );
138
+ };
139
+ var generateVariantsFromAttributes = (attributes, currentVariants) => {
140
+ const variantAxes = attributes.filter((attr) => attr.use_for_variants).map((attr) => ({
141
+ title: attr.title,
142
+ values: Array.isArray(attr.values) ? attr.values : attr.values ? [attr.values] : []
143
+ })).filter((axis) => axis.title && axis.values.length > 0);
144
+ if (variantAxes.length === 0) {
145
+ const hasDefault = currentVariants.some((v) => v.is_default);
146
+ if (hasDefault && currentVariants.length > 0) {
147
+ return currentVariants;
148
+ }
149
+ return decorateVariantsWithDefaultValues([
150
+ {
151
+ title: "Default variant",
152
+ should_create: true,
153
+ variant_rank: 0,
154
+ attribute_values: {},
155
+ is_default: true
156
+ }
157
+ ]);
158
+ }
159
+ const permutations = getPermutations(variantAxes);
160
+ const newVariants = currentVariants.reduce((acc, variant) => {
161
+ const attrVals = variant.attribute_values;
162
+ if (!attrVals || Object.keys(attrVals).length === 0) return acc;
163
+ const match = permutations.find(
164
+ (perm) => Object.keys(attrVals).every((key) => attrVals[key] === perm[key])
165
+ );
166
+ if (match) {
167
+ acc.push({
168
+ ...variant,
169
+ title: Object.values(match).join(" / "),
170
+ attribute_values: match,
171
+ is_default: false
172
+ });
173
+ }
174
+ return acc;
175
+ }, []);
176
+ const usedSet = new Set(
177
+ newVariants.map((v) => JSON.stringify(v.attribute_values))
178
+ );
179
+ for (const perm of permutations) {
180
+ if (!usedSet.has(JSON.stringify(perm))) {
181
+ newVariants.push({
182
+ title: Object.values(perm).join(" / "),
183
+ attribute_values: perm,
184
+ should_create: true,
185
+ variant_rank: newVariants.length
186
+ });
187
+ }
188
+ }
189
+ return newVariants;
190
+ };
191
+
192
+ // src/pages/products/create/constants.ts
193
+ var MediaSchema = z.object({
194
+ id: z.string().optional(),
195
+ url: z.string(),
196
+ isThumbnail: z.boolean(),
197
+ file: z.any().nullable()
198
+ // File
199
+ });
200
+ var ProductCreateVariantSchema = z.object({
201
+ should_create: z.boolean(),
202
+ is_default: z.boolean().optional(),
203
+ title: z.string(),
204
+ upc: z.string().optional(),
205
+ ean: z.string().optional(),
206
+ barcode: z.string().optional(),
207
+ mid_code: z.string().optional(),
208
+ hs_code: z.string().optional(),
209
+ width: optionalInt,
210
+ height: optionalInt,
211
+ length: optionalInt,
212
+ weight: optionalInt,
213
+ material: z.string().optional(),
214
+ origin_country: z.string().optional(),
215
+ sku: z.string().optional(),
216
+ attribute_values: z.record(z.string(), z.string()).optional(),
217
+ variant_rank: z.number()
218
+ });
219
+ var ProductCreateSchema = z.object({
220
+ title: z.string().min(1),
221
+ subtitle: z.string().optional(),
222
+ handle: z.string().optional(),
223
+ description: z.string().optional(),
224
+ discountable: z.boolean(),
225
+ type_id: z.string().optional(),
226
+ collection_id: z.string().optional(),
227
+ category_id: z.string().min(1),
228
+ tags: z.array(z.string()).optional(),
229
+ origin_country: z.string().optional(),
230
+ material: z.string().optional(),
231
+ width: z.string().optional(),
232
+ length: z.string().optional(),
233
+ height: z.string().optional(),
234
+ weight: z.string().optional(),
235
+ mid_code: z.string().optional(),
236
+ hs_code: z.string().optional(),
237
+ attributes: z.array(z.object({
238
+ attribute_id: z.string().optional(),
239
+ title: z.string().min(1),
240
+ values: z.union([z.string(), z.array(z.string())]).optional(),
241
+ is_custom: z.boolean(),
242
+ is_required: z.boolean().optional(),
243
+ use_for_variants: z.boolean(),
244
+ type: z.string().optional(),
245
+ available_values: z.array(z.object({
246
+ id: z.string(),
247
+ name: z.string()
248
+ })).optional()
249
+ })).optional(),
250
+ variants: z.array(ProductCreateVariantSchema).min(1),
251
+ media: z.array(MediaSchema).optional()
252
+ }).superRefine((data, ctx) => {
253
+ data.attributes?.forEach((attr, index) => {
254
+ if (!attr.is_required) return;
255
+ const isEmpty = attr.values === void 0 || attr.values === "" || Array.isArray(attr.values) && attr.values.length === 0;
256
+ if (isEmpty) {
257
+ ctx.addIssue({
258
+ code: z.ZodIssueCode.custom,
259
+ path: [`attributes.${index}.values`],
260
+ message: i18n.t("products.create.errors.requiredAttribute")
261
+ });
262
+ }
263
+ });
264
+ if (data.variants.every((v) => !v.should_create)) {
265
+ return ctx.addIssue({
266
+ code: z.ZodIssueCode.custom,
267
+ path: ["variants"],
268
+ message: "invalid_length"
269
+ });
270
+ }
271
+ const skus = /* @__PURE__ */ new Set();
272
+ data.variants.forEach((v, index) => {
273
+ if (v.sku) {
274
+ if (skus.has(v.sku)) {
275
+ ctx.addIssue({
276
+ code: z.ZodIssueCode.custom,
277
+ path: [`variants.${index}.sku`],
278
+ message: i18n.t("products.create.errors.uniqueSku")
279
+ });
280
+ }
281
+ skus.add(v.sku);
282
+ }
283
+ });
284
+ });
285
+ var EditProductMediaSchema = z.object({
286
+ media: z.array(MediaSchema)
287
+ });
288
+ var PRODUCT_CREATE_FORM_DEFAULTS = {
289
+ discountable: true,
290
+ tags: [],
291
+ variants: decorateVariantsWithDefaultValues([
292
+ {
293
+ title: i18n.t("products.create.defaults.variantTitle"),
294
+ should_create: true,
295
+ variant_rank: 0,
296
+ attribute_values: {},
297
+ is_default: true
298
+ }
299
+ ]),
300
+ attributes: [],
301
+ media: [],
302
+ category_id: "",
303
+ collection_id: "",
304
+ description: "",
305
+ handle: "",
306
+ height: "",
307
+ hs_code: "",
308
+ length: "",
309
+ material: "",
310
+ mid_code: "",
311
+ origin_country: "",
312
+ subtitle: "",
313
+ title: "",
314
+ type_id: "",
315
+ weight: "",
316
+ width: ""
317
+ };
318
+
319
+ // src/components/common/file-upload/file-upload.tsx
320
+ import { ArrowDownTray, XMark } from "@medusajs/icons";
321
+ import { IconButton, Text, clx } from "@medusajs/ui";
322
+ import { useRef, useState } from "react";
323
+
324
+ // src/lib/format-file-size.ts
325
+ var formatFileSize = (bytes) => {
326
+ if (bytes === 0) return "0 B";
327
+ const units = ["B", "KB", "MB", "GB"];
328
+ const i = Math.floor(Math.log(bytes) / Math.log(1024));
329
+ return `${(bytes / Math.pow(1024, i)).toFixed(2)} ${units[i]}`;
330
+ };
331
+
332
+ // src/components/common/file-upload/file-upload.tsx
333
+ import { jsx, jsxs } from "react/jsx-runtime";
334
+ var FileUpload = ({
335
+ label,
336
+ hint,
337
+ multiple = true,
338
+ hasError,
339
+ formats,
340
+ onUploaded,
341
+ onRemove,
342
+ uploadedImage = "",
343
+ fileName,
344
+ fileSize
345
+ }) => {
346
+ const [isDragOver, setIsDragOver] = useState(false);
347
+ const inputRef = useRef(null);
348
+ const dropZoneRef = useRef(null);
349
+ const handleOpenFileSelector = () => {
350
+ inputRef.current?.click();
351
+ };
352
+ const handleDragEnter = (event) => {
353
+ event.preventDefault();
354
+ event.stopPropagation();
355
+ const files = event.dataTransfer?.files;
356
+ if (!files) {
357
+ return;
358
+ }
359
+ setIsDragOver(true);
360
+ };
361
+ const handleDragLeave = (event) => {
362
+ event.preventDefault();
363
+ event.stopPropagation();
364
+ if (!dropZoneRef.current || dropZoneRef.current.contains(event.relatedTarget)) {
365
+ return;
366
+ }
367
+ setIsDragOver(false);
368
+ };
369
+ const handleUploaded = (files) => {
370
+ if (!files) {
371
+ return;
372
+ }
373
+ const fileList = Array.from(files);
374
+ const fileObj = fileList.map((file) => {
375
+ const id = Math.random().toString(36).substring(7);
376
+ const previewUrl = URL.createObjectURL(file);
377
+ return {
378
+ id,
379
+ url: previewUrl,
380
+ file
381
+ };
382
+ });
383
+ onUploaded(fileObj);
384
+ };
385
+ const handleDrop = (event) => {
386
+ event.preventDefault();
387
+ event.stopPropagation();
388
+ setIsDragOver(false);
389
+ handleUploaded(event.dataTransfer?.files);
390
+ };
391
+ const handleFileChange = async (event) => {
392
+ handleUploaded(event.target.files);
393
+ };
394
+ const showFileRow = !multiple && uploadedImage;
395
+ if (showFileRow) {
396
+ return /* @__PURE__ */ jsxs("div", { children: [
397
+ /* @__PURE__ */ jsxs("div", { className: "bg-ui-bg-component shadow-borders-base flex items-center gap-x-3 rounded-lg p-3", children: [
398
+ /* @__PURE__ */ jsx("div", { className: "flex h-10 w-[30px] shrink-0 items-center justify-center overflow-hidden rounded-md", children: /* @__PURE__ */ jsx(
399
+ "img",
400
+ {
401
+ src: uploadedImage,
402
+ alt: fileName,
403
+ className: "h-full w-full object-cover"
404
+ }
405
+ ) }),
406
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-1 flex-col", children: [
407
+ /* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", weight: "plus", children: fileName || "image" }),
408
+ fileSize != null && /* @__PURE__ */ jsx(
409
+ Text,
410
+ {
411
+ size: "small",
412
+ leading: "compact",
413
+ className: "text-ui-fg-subtle",
414
+ children: formatFileSize(fileSize)
415
+ }
416
+ )
417
+ ] }),
418
+ onRemove && /* @__PURE__ */ jsx(
419
+ IconButton,
420
+ {
421
+ type: "button",
422
+ variant: "transparent",
423
+ size: "small",
424
+ onClick: onRemove,
425
+ children: /* @__PURE__ */ jsx(XMark, {})
426
+ }
427
+ )
428
+ ] }),
429
+ /* @__PURE__ */ jsx(
430
+ "input",
431
+ {
432
+ hidden: true,
433
+ ref: inputRef,
434
+ onChange: handleFileChange,
435
+ type: "file",
436
+ accept: formats.join(","),
437
+ multiple: false
438
+ }
439
+ )
440
+ ] });
441
+ }
442
+ return /* @__PURE__ */ jsxs("div", { children: [
443
+ /* @__PURE__ */ jsxs(
444
+ "button",
445
+ {
446
+ ref: dropZoneRef,
447
+ type: "button",
448
+ onClick: handleOpenFileSelector,
449
+ onDrop: handleDrop,
450
+ onDragOver: (e) => e.preventDefault(),
451
+ onDragEnter: handleDragEnter,
452
+ onDragLeave: handleDragLeave,
453
+ className: clx(
454
+ "bg-ui-bg-component border-ui-border-strong transition-fg group flex w-full flex-col items-center gap-y-2 rounded-lg border border-dashed p-8",
455
+ "hover:border-ui-border-interactive focus:border-ui-border-interactive",
456
+ "focus:shadow-borders-focus outline-none focus:border-solid",
457
+ {
458
+ "!border-ui-border-error": hasError,
459
+ "!border-ui-border-interactive": isDragOver
460
+ }
461
+ ),
462
+ children: [
463
+ /* @__PURE__ */ jsxs("div", { className: "text-ui-fg-subtle group-disabled:text-ui-fg-disabled flex items-center gap-x-2", children: [
464
+ /* @__PURE__ */ jsx(ArrowDownTray, {}),
465
+ /* @__PURE__ */ jsx(Text, { children: label })
466
+ ] }),
467
+ !!hint && /* @__PURE__ */ jsx(
468
+ Text,
469
+ {
470
+ size: "small",
471
+ leading: "compact",
472
+ className: "text-ui-fg-muted group-disabled:text-ui-fg-disabled",
473
+ children: hint
474
+ }
475
+ )
476
+ ]
477
+ }
478
+ ),
479
+ /* @__PURE__ */ jsx(
480
+ "input",
481
+ {
482
+ hidden: true,
483
+ ref: inputRef,
484
+ onChange: handleFileChange,
485
+ type: "file",
486
+ accept: formats.join(","),
487
+ multiple
488
+ }
489
+ )
490
+ ] });
491
+ };
492
+
493
+ export {
494
+ normalizeProductFormValues,
495
+ decorateVariantsWithDefaultValues,
496
+ generateVariantsFromAttributes,
497
+ MediaSchema,
498
+ ProductCreateSchema,
499
+ EditProductMediaSchema,
500
+ PRODUCT_CREATE_FORM_DEFAULTS,
501
+ formatFileSize,
502
+ FileUpload
503
+ };
@@ -16,7 +16,7 @@ import {
16
16
  } from "./chunk-AIF2KTEE.js";
17
17
  import {
18
18
  SingleColumnPage
19
- } from "./chunk-CAS74NLJ.js";
19
+ } from "./chunk-YV6MK4PZ.js";
20
20
  import {
21
21
  useProductTypes
22
22
  } from "./chunk-VV6IKGCN.js";