@mercurjs/vendor 2.0.0-canary.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 (290) hide show
  1. package/dist/[id]-23D3HY3G.js +444 -0
  2. package/dist/[id]-2VBOAZM4.js +1215 -0
  3. package/dist/[id]-A4FSDRER.js +325 -0
  4. package/dist/[id]-E45G2SDA.js +213 -0
  5. package/dist/[id]-FXKSI52D.js +477 -0
  6. package/dist/[id]-HHZ3BSXV.js +1166 -0
  7. package/dist/[id]-MIV4U5UW.js +137 -0
  8. package/dist/[id]-QSRIPPIP.js +612 -0
  9. package/dist/[id]-RGDXOC7T.js +499 -0
  10. package/dist/[id]-TI2MOR2C.js +377 -0
  11. package/dist/[id]-U5DT2ZLS.js +301 -0
  12. package/dist/[id]-UMFGLDM2.js +354 -0
  13. package/dist/[id]-VTFOP3BF.js +97 -0
  14. package/dist/[id]-ZYF75L6G.js +479 -0
  15. package/dist/[location_id]-4UIEW5KM.js +685 -0
  16. package/dist/[province_id]-ZCHPXXQN.js +205 -0
  17. package/dist/add-KNDQL6YN.js +660 -0
  18. package/dist/add-customer-groups-JA346MTF.js +275 -0
  19. package/dist/add-products-2VB57KXV.js +273 -0
  20. package/dist/add-promotions-KVKEP6EO.js +260 -0
  21. package/dist/add-to-campaign-V6D7JKRS.js +44 -0
  22. package/dist/additional-attributes-E36EZX4V.js +219 -0
  23. package/dist/adjust-inventory-P7AB7VIB.js +228 -0
  24. package/dist/allocate-items-QAS5PZLR.js +529 -0
  25. package/dist/areas-Y7VDWH7G.js +151 -0
  26. package/dist/attributes-UEM2VJKV.js +277 -0
  27. package/dist/breadcrumb-3QTVWXZB.js +27 -0
  28. package/dist/breadcrumb-5OTOCYNL.js +38 -0
  29. package/dist/breadcrumb-6NAAOPIY.js +11 -0
  30. package/dist/breadcrumb-ASB2YCNV.js +25 -0
  31. package/dist/breadcrumb-CIGKLKKS.js +28 -0
  32. package/dist/breadcrumb-EOYLR3IQ.js +22 -0
  33. package/dist/breadcrumb-LENACUAA.js +22 -0
  34. package/dist/breadcrumb-LIXGWUQF.js +44 -0
  35. package/dist/breadcrumb-MOQ7GI3Z.js +27 -0
  36. package/dist/breadcrumb-NCBGPQML.js +23 -0
  37. package/dist/breadcrumb-OVMEC5OZ.js +33 -0
  38. package/dist/breadcrumb-RIXJ5QSX.js +45 -0
  39. package/dist/breadcrumb-TZB6EWNC.js +31 -0
  40. package/dist/breadcrumb-WP34OXGQ.js +23 -0
  41. package/dist/campaigns-PMVKUFEA.js +28 -0
  42. package/dist/categories-CKKIUMYG.js +27 -0
  43. package/dist/chunk-26OOAKQ6.js +18 -0
  44. package/dist/chunk-2C3HUJ3Z.js +222 -0
  45. package/dist/chunk-2F3H6ORE.js +36 -0
  46. package/dist/chunk-2ZFELO2L.js +13 -0
  47. package/dist/chunk-3CK6OINO.js +448 -0
  48. package/dist/chunk-3EF54XFY.js +64 -0
  49. package/dist/chunk-3LPVUPZZ.js +74 -0
  50. package/dist/chunk-3QSRE5LS.js +161 -0
  51. package/dist/chunk-3SIDRPKT.js +185 -0
  52. package/dist/chunk-4F5GP7J7.js +45 -0
  53. package/dist/chunk-4GPAS5GW.js +36 -0
  54. package/dist/chunk-4MFMCZEJ.js +70 -0
  55. package/dist/chunk-4TBDDMFP.js +425 -0
  56. package/dist/chunk-4TLP3TAA.js +34 -0
  57. package/dist/chunk-54TMLQH3.js +9 -0
  58. package/dist/chunk-5NF4OTVV.js +169 -0
  59. package/dist/chunk-66V3GFSW.js +138 -0
  60. package/dist/chunk-6EYGH3TB.js +26 -0
  61. package/dist/chunk-6IJMSVC6.js +16 -0
  62. package/dist/chunk-6YA3C4NB.js +55 -0
  63. package/dist/chunk-7AV5EJJ5.js +29 -0
  64. package/dist/chunk-7RPRNVBS.js +45 -0
  65. package/dist/chunk-A2SY5L5G.js +183 -0
  66. package/dist/chunk-A5DJIOHN.js +4 -0
  67. package/dist/chunk-AIFLEWO2.js +56 -0
  68. package/dist/chunk-ASVMGV2B.js +80 -0
  69. package/dist/chunk-AW77UWCZ.js +363 -0
  70. package/dist/chunk-AYUG34XF.js +84 -0
  71. package/dist/chunk-AYVH6Q5O.js +31 -0
  72. package/dist/chunk-B2RVONU7.js +160 -0
  73. package/dist/chunk-BCU3FKP2.js +18 -0
  74. package/dist/chunk-BDGZ4EQO.js +86 -0
  75. package/dist/chunk-BDZOSMAX.js +23 -0
  76. package/dist/chunk-C6SUTRP2.js +13 -0
  77. package/dist/chunk-CDIZEXFJ.js +145 -0
  78. package/dist/chunk-CFETU5BI.js +261 -0
  79. package/dist/chunk-CMHI2RPL.js +20 -0
  80. package/dist/chunk-CP5IL4P6.js +98 -0
  81. package/dist/chunk-CUO22GTM.js +96 -0
  82. package/dist/chunk-CVVYQI5F.js +41 -0
  83. package/dist/chunk-DARJTN4I.js +60 -0
  84. package/dist/chunk-DB6ANJBO.js +35 -0
  85. package/dist/chunk-DC2K6CFQ.js +86 -0
  86. package/dist/chunk-DDEIH66R.js +123 -0
  87. package/dist/chunk-DY3XQPHC.js +31 -0
  88. package/dist/chunk-DYUTYBAQ.js +67 -0
  89. package/dist/chunk-E3MNEQID.js +24 -0
  90. package/dist/chunk-FBZHM2QZ.js +247 -0
  91. package/dist/chunk-FDZC3TFZ.js +717 -0
  92. package/dist/chunk-FGCKXH45.js +263 -0
  93. package/dist/chunk-FMFVTERD.js +0 -0
  94. package/dist/chunk-FOMEBUX6.js +89 -0
  95. package/dist/chunk-FQERBIVS.js +0 -0
  96. package/dist/chunk-GC33DBKG.js +143 -0
  97. package/dist/chunk-GDMNHL7E.js +144 -0
  98. package/dist/chunk-GTUR4HSV.js +53 -0
  99. package/dist/chunk-H35HHFTB.js +225 -0
  100. package/dist/chunk-HB3BP55W.js +25 -0
  101. package/dist/chunk-HHD2VUED.js +29 -0
  102. package/dist/chunk-HUNGNEPY.js +312 -0
  103. package/dist/chunk-HUZG6A3X.js +127 -0
  104. package/dist/chunk-INNFZYX2.js +183 -0
  105. package/dist/chunk-IQPN4PZJ.js +749 -0
  106. package/dist/chunk-IZ5RG5XI.js +72 -0
  107. package/dist/chunk-J2XP7VRG.js +1080 -0
  108. package/dist/chunk-JHIMVLB2.js +42 -0
  109. package/dist/chunk-JKXAL7WR.js +92 -0
  110. package/dist/chunk-JRTZWK77.js +1764 -0
  111. package/dist/chunk-JVBLYMY2.js +268 -0
  112. package/dist/chunk-JXP5YZ77.js +86 -0
  113. package/dist/chunk-KAZ5BYTQ.js +132 -0
  114. package/dist/chunk-KHHY7EEM.js +267 -0
  115. package/dist/chunk-LAVHRER2.js +17 -0
  116. package/dist/chunk-LQSLDDPT.js +67 -0
  117. package/dist/chunk-LWVBKUUL.js +77 -0
  118. package/dist/chunk-LYUCDASZ.js +115 -0
  119. package/dist/chunk-LZ7QV42C.js +37 -0
  120. package/dist/chunk-MAEP2UCK.js +110 -0
  121. package/dist/chunk-MG4GKUJW.js +31 -0
  122. package/dist/chunk-N2TQXB44.js +1280 -0
  123. package/dist/chunk-N3T24SEK.js +32 -0
  124. package/dist/chunk-NANYVBFI.js +106 -0
  125. package/dist/chunk-NCMUZ6BQ.js +0 -0
  126. package/dist/chunk-NCYTM57J.js +160 -0
  127. package/dist/chunk-NX26QE2O.js +47 -0
  128. package/dist/chunk-NYDJTWRL.js +389 -0
  129. package/dist/chunk-O5LRZEG6.js +253 -0
  130. package/dist/chunk-O6PRBSFL.js +115 -0
  131. package/dist/chunk-OJCDB3N5.js +539 -0
  132. package/dist/chunk-OSFOX7MG.js +176 -0
  133. package/dist/chunk-OVPAOBZB.js +110 -0
  134. package/dist/chunk-PADOWAXM.js +118 -0
  135. package/dist/chunk-PHOCVOZ5.js +9 -0
  136. package/dist/chunk-PKBMQBKP.js +7 -0
  137. package/dist/chunk-PLSJ74T2.js +298 -0
  138. package/dist/chunk-PVZBDWLK.js +41 -0
  139. package/dist/chunk-PWZKFTJS.js +247 -0
  140. package/dist/chunk-PXYDR7WQ.js +48 -0
  141. package/dist/chunk-PYQJ5N25.js +191 -0
  142. package/dist/chunk-Q4UVXS46.js +14 -0
  143. package/dist/chunk-QDPLZDMX.js +17 -0
  144. package/dist/chunk-QSGR43JM.js +30 -0
  145. package/dist/chunk-QUNDGPF7.js +92801 -0
  146. package/dist/chunk-R65A4P4H.js +136 -0
  147. package/dist/chunk-RE7YXVFG.js +128 -0
  148. package/dist/chunk-RETT6WME.js +37 -0
  149. package/dist/chunk-RHKRREUU.js +15 -0
  150. package/dist/chunk-RIILGKYR.js +32 -0
  151. package/dist/chunk-RM5RSDYP.js +353 -0
  152. package/dist/chunk-RNC4NFVK.js +170 -0
  153. package/dist/chunk-RSMZHZI2.js +2078 -0
  154. package/dist/chunk-RXM4B6HR.js +8 -0
  155. package/dist/chunk-S2WEYEQR.js +14 -0
  156. package/dist/chunk-S3PQKKNV.js +49 -0
  157. package/dist/chunk-S5GQ2SES.js +276 -0
  158. package/dist/chunk-SECZTXSU.js +31 -0
  159. package/dist/chunk-SI4ALL7W.js +180 -0
  160. package/dist/chunk-SID3COTK.js +21 -0
  161. package/dist/chunk-SMQT3ZNO.js +8 -0
  162. package/dist/chunk-SOZMJA7V.js +61 -0
  163. package/dist/chunk-TG3TCIL6.js +207 -0
  164. package/dist/chunk-THHRRYRS.js +16 -0
  165. package/dist/chunk-TKGWSUEI.js +0 -0
  166. package/dist/chunk-TTFCO5HU.js +173 -0
  167. package/dist/chunk-TXEPCJEQ.js +430 -0
  168. package/dist/chunk-U2EI2ZLM.js +32 -0
  169. package/dist/chunk-U2ZFCAPX.js +34 -0
  170. package/dist/chunk-U3X4DNV6.js +179 -0
  171. package/dist/chunk-UXKKD4AD.js +437 -0
  172. package/dist/chunk-UYJ65N46.js +261 -0
  173. package/dist/chunk-VDWGP2U6.js +71 -0
  174. package/dist/chunk-VGJTARSA.js +89 -0
  175. package/dist/chunk-VHMGJUYN.js +28 -0
  176. package/dist/chunk-VKC3XKFF.js +283 -0
  177. package/dist/chunk-VKOE5J66.js +31 -0
  178. package/dist/chunk-VOHEQ7B5.js +31 -0
  179. package/dist/chunk-VW56KWO2.js +9 -0
  180. package/dist/chunk-W4KHJ4D6.js +74 -0
  181. package/dist/chunk-W6Y3PPU5.js +73 -0
  182. package/dist/chunk-W6ZVQJYB.js +311 -0
  183. package/dist/chunk-WA3IVAUC.js +123 -0
  184. package/dist/chunk-WHTS4G5K.js +1551 -0
  185. package/dist/chunk-WIYFXWRI.js +30 -0
  186. package/dist/chunk-WPFTRRWV.js +455 -0
  187. package/dist/chunk-WQZ4ONQV.js +6 -0
  188. package/dist/chunk-WS652CCV.js +893 -0
  189. package/dist/chunk-XG4PTPRM.js +0 -0
  190. package/dist/chunk-XRNDVICA.js +85 -0
  191. package/dist/chunk-XXZJISPX.js +48 -0
  192. package/dist/chunk-Y224F4UU.js +81 -0
  193. package/dist/chunk-Y3FR5JC7.js +437 -0
  194. package/dist/chunk-Y4VBOHAP.js +111 -0
  195. package/dist/chunk-Y7QKP6QU.js +35 -0
  196. package/dist/chunk-YVCBMOJG.js +50 -0
  197. package/dist/chunk-Z2WPXJ6J.js +146 -0
  198. package/dist/chunk-ZA2KFUFR.js +19 -0
  199. package/dist/chunk-ZEKV7LGF.js +6 -0
  200. package/dist/chunk-ZFFA36DB.js +186 -0
  201. package/dist/chunk-ZPGWTLF2.js +499 -0
  202. package/dist/chunk-ZVT2QSWR.js +263 -0
  203. package/dist/chunk-ZZ7VKT2S.js +4113 -0
  204. package/dist/collections-TREF67TO.js +63 -0
  205. package/dist/configuration-KWAL2QZ5.js +152 -0
  206. package/dist/configuration-RNWBTRAH.js +205 -0
  207. package/dist/create-7UEEO5TM.js +125 -0
  208. package/dist/create-DTCDJMIT.js +634 -0
  209. package/dist/create-DYDRAY6V.js +622 -0
  210. package/dist/create-EJM5C2XP.js +27 -0
  211. package/dist/create-F7OMPGZV.js +853 -0
  212. package/dist/create-G4UJOJJ6.js +69 -0
  213. package/dist/create-IE6MYOIY.js +170 -0
  214. package/dist/create-L23TGTBH.js +225 -0
  215. package/dist/create-LOBCFTCT.js +583 -0
  216. package/dist/create-MKBBF2V3.js +150 -0
  217. package/dist/create-TFDUNJSI.js +163 -0
  218. package/dist/create-TMTZDKII.js +711 -0
  219. package/dist/create-XGF6DB5F.js +239 -0
  220. package/dist/create-YAAK7JQ3.js +1052 -0
  221. package/dist/create-YPCVTXAK.js +194 -0
  222. package/dist/create-ZU362U3B.js +310 -0
  223. package/dist/customers-4QWR5UOL.js +27 -0
  224. package/dist/edit-2QA5BVOY.js +735 -0
  225. package/dist/edit-47I7VVNB.js +167 -0
  226. package/dist/edit-5BUGSOTL.js +255 -0
  227. package/dist/edit-7LQATDUD.js +193 -0
  228. package/dist/edit-AQAPYMDY.js +260 -0
  229. package/dist/edit-BQLSTFTQ.js +138 -0
  230. package/dist/edit-BYXHU3IG.js +308 -0
  231. package/dist/edit-DG3MY3ZH.js +244 -0
  232. package/dist/edit-J3LD76JS.js +192 -0
  233. package/dist/edit-J6WCPHDS.js +205 -0
  234. package/dist/edit-KCZVZLSZ.js +131 -0
  235. package/dist/edit-LOKLQGM2.js +181 -0
  236. package/dist/edit-MDTTTB33.js +104 -0
  237. package/dist/edit-NFSU2K3O.js +413 -0
  238. package/dist/edit-RHNZWNXD.js +89 -0
  239. package/dist/edit-XU33IVZH.js +204 -0
  240. package/dist/edit-ZMINDMGM.js +116 -0
  241. package/dist/edit-budget-Z5USV462.js +145 -0
  242. package/dist/edit-inventory-item-YFW2AFRD.js +128 -0
  243. package/dist/edit-inventory-item-attributes-IYAMJDTB.js +278 -0
  244. package/dist/fulfillment-SKXAF3BZ.js +545 -0
  245. package/dist/fulfillment-providers-ACERVITQ.js +279 -0
  246. package/dist/home-PP7YYCSB.js +16 -0
  247. package/dist/index.css +6 -0
  248. package/dist/index.d.ts +39 -0
  249. package/dist/index.js +3656 -0
  250. package/dist/inventory-AIRQ2KNS.js +26 -0
  251. package/dist/locations-SQKM7JWN.js +23 -0
  252. package/dist/login-LKFCRHXN.js +35 -0
  253. package/dist/manage-locations-4PQS4QY7.js +195 -0
  254. package/dist/media-PL477QJO.js +703 -0
  255. package/dist/metadata-42MU3H7T.js +60 -0
  256. package/dist/metadata-DIJTVDF7.js +45 -0
  257. package/dist/metadata-NX3LEEB3.js +64 -0
  258. package/dist/metadata-RBDSM567.js +65 -0
  259. package/dist/metadata-VZTWNZPG.js +66 -0
  260. package/dist/metadata-X3XGQ563.js +67 -0
  261. package/dist/no-match-BO2NNLCM.js +33 -0
  262. package/dist/orders-2KHCHNO5.js +59 -0
  263. package/dist/organization-VQXCKHCN.js +233 -0
  264. package/dist/organize-3F5ZUIGB.js +23 -0
  265. package/dist/organize-WPWEPCF7.js +23 -0
  266. package/dist/pages/index.d.ts +1153 -0
  267. package/dist/pages/index.js +198 -0
  268. package/dist/payouts-3BY73LZ3.js +27 -0
  269. package/dist/price-lists-G256JJN7.js +34 -0
  270. package/dist/prices-EW7KBY6R.js +269 -0
  271. package/dist/pricing-3PUJDOZN.js +313 -0
  272. package/dist/product-tags-PI3RENEX.js +80 -0
  273. package/dist/product-types-WJPLJI7H.js +32 -0
  274. package/dist/product-variant-detail-EYTE7PHL.js +377 -0
  275. package/dist/product-variant-edit-PW7W5J5E.js +402 -0
  276. package/dist/products-GSN4I7BT.js +272 -0
  277. package/dist/products-RFYNEY57.js +85 -0
  278. package/dist/promotions-CIZIDQ64.js +31 -0
  279. package/dist/reset-password-OFUSH363.js +299 -0
  280. package/dist/return-reasons-4V2KVSRI.js +52 -0
  281. package/dist/sales-channels-MBWVM3X2.js +184 -0
  282. package/dist/sales-channels-ZKA62EAW.js +156 -0
  283. package/dist/seller-ZFDLKF5Y.js +36 -0
  284. package/dist/settings-NP2IAID5.js +111 -0
  285. package/dist/shipping-profile-7FTHSPY2.js +145 -0
  286. package/dist/shipping-profiles-7R6L65WG.js +43 -0
  287. package/dist/stock-ENMBCZRY.js +502 -0
  288. package/dist/stock-VYDJY46S.js +278 -0
  289. package/dist/tax-regions-V6G6244H.js +87 -0
  290. package/package.json +87 -0
@@ -0,0 +1,1080 @@
1
+ import {
2
+ getLocaleAmount
3
+ } from "./chunk-PXYDR7WQ.js";
4
+ import {
5
+ DataGrid,
6
+ DataGridCellContainer,
7
+ IncludesTaxTooltip,
8
+ createDataGridHelper,
9
+ useCombinedRefs,
10
+ useDataGridCell,
11
+ useDataGridCellError
12
+ } from "./chunk-ZZ7VKT2S.js";
13
+ import {
14
+ currencies
15
+ } from "./chunk-IQPN4PZJ.js";
16
+ import {
17
+ castNumber
18
+ } from "./chunk-SMQT3ZNO.js";
19
+ import {
20
+ KeyboundForm
21
+ } from "./chunk-U2ZFCAPX.js";
22
+ import {
23
+ StackedFocusModal
24
+ } from "./chunk-3CK6OINO.js";
25
+ import {
26
+ Form
27
+ } from "./chunk-3QSRE5LS.js";
28
+
29
+ // src/pages/settings/locations/_common/schema.ts
30
+ import { t } from "i18next";
31
+ import { z } from "zod";
32
+ var ConditionalPriceSchema = z.object({
33
+ amount: z.union([z.string(), z.number()]),
34
+ gte: z.union([z.string(), z.number()]).nullish(),
35
+ lte: z.union([z.string(), z.number()]).nullish(),
36
+ lt: z.number().nullish(),
37
+ gt: z.number().nullish(),
38
+ eq: z.number().nullish()
39
+ }).refine((data) => data.amount !== "", {
40
+ message: t(
41
+ "stockLocations.shippingOptions.conditionalPrices.errors.amountRequired"
42
+ ),
43
+ path: ["amount"]
44
+ }).refine(
45
+ (data) => {
46
+ const hasEqLtGt = data.eq !== void 0 || data.lt !== void 0 || data.gt !== void 0;
47
+ if (hasEqLtGt) {
48
+ return true;
49
+ }
50
+ return data.gte !== void 0 && data.gte !== "" || data.lte !== void 0 && data.lte !== "";
51
+ },
52
+ {
53
+ message: t(
54
+ "stockLocations.shippingOptions.conditionalPrices.errors.minOrMaxRequired"
55
+ ),
56
+ path: ["gte"]
57
+ }
58
+ ).refine(
59
+ (data) => {
60
+ if (data.gte != null && data.gte !== "" && data.lte != null && data.lte !== "") {
61
+ const gte = castNumber(data.gte);
62
+ const lte = castNumber(data.lte);
63
+ return gte <= lte;
64
+ }
65
+ return true;
66
+ },
67
+ {
68
+ message: t(
69
+ "stockLocations.shippingOptions.conditionalPrices.errors.minGreaterThanMax"
70
+ ),
71
+ path: ["gte"]
72
+ }
73
+ );
74
+ var UpdateConditionalPriceSchema = ConditionalPriceSchema.and(
75
+ z.object({
76
+ id: z.string().optional()
77
+ })
78
+ );
79
+ function refineDuplicates(data, ctx) {
80
+ const prices = data.prices;
81
+ for (let i = 0; i < prices.length; i++) {
82
+ for (let j = i + 1; j < prices.length; j++) {
83
+ const price1 = prices[i];
84
+ const price2 = prices[j];
85
+ if (price1.amount === "" || price2.amount === "") {
86
+ continue;
87
+ }
88
+ const price1Amount = castNumber(price1.amount);
89
+ const price2Amount = castNumber(price2.amount);
90
+ if (price1Amount === price2Amount) {
91
+ addDuplicateAmountError(ctx, j);
92
+ }
93
+ const conditions = [
94
+ { value: price1.gte, type: "gte" },
95
+ { value: price1.lte, type: "lte" },
96
+ { value: price1.eq, type: "eq" },
97
+ { value: price1.lt, type: "lt" },
98
+ { value: price1.gt, type: "gt" }
99
+ ];
100
+ conditions.forEach((condition1) => {
101
+ if (!condition1.value && condition1.value !== 0) {
102
+ return;
103
+ }
104
+ const conditions2 = [
105
+ { value: price2.gte, type: "gte" },
106
+ { value: price2.lte, type: "lte" },
107
+ { value: price2.eq, type: "eq" },
108
+ { value: price2.lt, type: "lt" },
109
+ { value: price2.gt, type: "gt" }
110
+ ];
111
+ conditions2.forEach((condition2) => {
112
+ if (!condition2.value && condition2.value !== 0) {
113
+ return;
114
+ }
115
+ const condition1Value = castNumber(
116
+ condition1.value
117
+ );
118
+ const condition2Value = castNumber(
119
+ condition2.value
120
+ );
121
+ if (condition1Value === condition2Value) {
122
+ addOverlappingConditionError(ctx, j, condition2.type);
123
+ }
124
+ });
125
+ });
126
+ }
127
+ }
128
+ }
129
+ var CondtionalPriceRuleSchema = z.object({
130
+ prices: z.array(ConditionalPriceSchema)
131
+ }).superRefine(refineDuplicates);
132
+ var UpdateConditionalPriceRuleSchema = z.object({
133
+ prices: z.array(UpdateConditionalPriceSchema)
134
+ }).superRefine(refineDuplicates);
135
+ var addDuplicateAmountError = (ctx, index) => {
136
+ ctx.addIssue({
137
+ code: z.ZodIssueCode.custom,
138
+ message: t(
139
+ "stockLocations.shippingOptions.conditionalPrices.errors.duplicateAmount"
140
+ ),
141
+ path: ["prices", index, "amount"]
142
+ });
143
+ };
144
+ var addOverlappingConditionError = (ctx, index, type) => {
145
+ ctx.addIssue({
146
+ code: z.ZodIssueCode.custom,
147
+ message: t(
148
+ "stockLocations.shippingOptions.conditionalPrices.errors.overlappingConditions"
149
+ ),
150
+ path: ["prices", index, type]
151
+ });
152
+ };
153
+
154
+ // src/pages/settings/locations/_common/components/shipping-option-price-context.tsx
155
+ import { createContext } from "react";
156
+ var ShippingOptionPriceContext = createContext(null);
157
+
158
+ // src/pages/settings/locations/_common/components/use-shipping-option-price.tsx
159
+ import { useContext } from "react";
160
+ var useShippingOptionPrice = () => {
161
+ const context = useContext(ShippingOptionPriceContext);
162
+ if (!context) {
163
+ throw new Error(
164
+ "useShippingOptionPrice must be used within a ShippingOptionPriceProvider"
165
+ );
166
+ }
167
+ return context;
168
+ };
169
+
170
+ // src/pages/settings/locations/_common/components/shipping-option-price-provider.tsx
171
+ import { jsx } from "react/jsx-runtime";
172
+ var ShippingOptionPriceProvider = ({
173
+ children,
174
+ onOpenConditionalPricesModal,
175
+ onCloseConditionalPricesModal
176
+ }) => {
177
+ return /* @__PURE__ */ jsx(
178
+ ShippingOptionPriceContext.Provider,
179
+ {
180
+ value: { onOpenConditionalPricesModal, onCloseConditionalPricesModal },
181
+ children
182
+ }
183
+ );
184
+ };
185
+
186
+ // src/pages/settings/locations/_common/components/conditional-price-form/conditional-price-form.tsx
187
+ import { zodResolver } from "@hookform/resolvers/zod";
188
+ import {
189
+ InformationCircleSolid,
190
+ Plus,
191
+ TriangleDownMini,
192
+ XMark,
193
+ XMarkMini
194
+ } from "@medusajs/icons";
195
+ import {
196
+ Badge,
197
+ Button,
198
+ clx,
199
+ CurrencyInput,
200
+ Divider,
201
+ Heading,
202
+ IconButton,
203
+ Label,
204
+ Text,
205
+ Tooltip
206
+ } from "@medusajs/ui";
207
+ import { Accordion as RadixAccordion } from "radix-ui";
208
+ import { Fragment, useRef, useState } from "react";
209
+ import {
210
+ useFieldArray,
211
+ useForm,
212
+ useFormContext,
213
+ useWatch
214
+ } from "react-hook-form";
215
+ import { Trans, useTranslation } from "react-i18next";
216
+ import { formatValue } from "react-currency-input-field";
217
+
218
+ // src/pages/settings/locations/_common/utils/get-custom-shipping-option-price-field-info.ts
219
+ var getCustomShippingOptionPriceFieldName = (field, type) => {
220
+ const prefix = type === "region" ? "region_prices" : "currency_prices";
221
+ const customPrefix = type === "region" ? "conditional_region_prices" : "conditional_currency_prices";
222
+ const name = field.replace(
223
+ prefix,
224
+ customPrefix
225
+ );
226
+ return name;
227
+ };
228
+
229
+ // src/pages/settings/locations/_common/components/conditional-price-form/conditional-price-form.tsx
230
+ import { jsx as jsx2, jsxs } from "react/jsx-runtime";
231
+ var RULE_ITEM_PREFIX = "rule-item";
232
+ var getRuleValue = (index) => `${RULE_ITEM_PREFIX}-${index}`;
233
+ var ConditionalPriceForm = ({
234
+ info,
235
+ variant
236
+ }) => {
237
+ const { t: t2 } = useTranslation();
238
+ const { getValues, setValue: setFormValue } = useFormContext();
239
+ const { onCloseConditionalPricesModal } = useShippingOptionPrice();
240
+ const [value, setValue] = useState([getRuleValue(0)]);
241
+ const { field, type, currency, name: header } = info;
242
+ const name = getCustomShippingOptionPriceFieldName(field, type);
243
+ const conditionalPriceForm = useForm({
244
+ defaultValues: {
245
+ prices: getValues(name) || [
246
+ {
247
+ amount: "",
248
+ gte: "",
249
+ lte: null
250
+ }
251
+ ]
252
+ },
253
+ resolver: zodResolver(
254
+ variant === "create" ? CondtionalPriceRuleSchema : UpdateConditionalPriceRuleSchema
255
+ )
256
+ });
257
+ const { fields, append, remove } = useFieldArray({
258
+ control: conditionalPriceForm.control,
259
+ name: "prices"
260
+ });
261
+ const handleAdd = () => {
262
+ append({
263
+ amount: "",
264
+ gte: "",
265
+ lte: null
266
+ });
267
+ setValue([...value, getRuleValue(fields.length)]);
268
+ };
269
+ const handleRemove = (index) => {
270
+ remove(index);
271
+ };
272
+ const handleOnSubmit = conditionalPriceForm.handleSubmit(
273
+ (values) => {
274
+ setFormValue(name, values.prices, {
275
+ shouldDirty: true,
276
+ shouldValidate: true,
277
+ shouldTouch: true
278
+ });
279
+ onCloseConditionalPricesModal();
280
+ },
281
+ (e) => {
282
+ const indexesWithErrors = Object.keys(e.prices || {});
283
+ setValue((prev) => {
284
+ const values = new Set(prev);
285
+ indexesWithErrors.forEach((index) => {
286
+ values.add(getRuleValue(Number(index)));
287
+ });
288
+ return Array.from(values);
289
+ });
290
+ }
291
+ );
292
+ const handleOnKeyDown = (event) => {
293
+ if (event.key === "Enter" && (event.metaKey || event.ctrlKey)) {
294
+ event.preventDefault();
295
+ event.stopPropagation();
296
+ handleOnSubmit();
297
+ }
298
+ };
299
+ return /* @__PURE__ */ jsx2(Form, { ...conditionalPriceForm, children: /* @__PURE__ */ jsx2(
300
+ KeyboundForm,
301
+ {
302
+ onSubmit: handleOnSubmit,
303
+ onKeyDown: handleOnKeyDown,
304
+ className: "flex h-full flex-col",
305
+ children: /* @__PURE__ */ jsxs(StackedFocusModal.Content, { children: [
306
+ /* @__PURE__ */ jsx2(StackedFocusModal.Header, {}),
307
+ /* @__PURE__ */ jsx2(StackedFocusModal.Body, { className: "size-full overflow-hidden", children: /* @__PURE__ */ jsx2("div", { className: "flex size-full flex-1 flex-col items-center overflow-y-auto", children: /* @__PURE__ */ jsx2("div", { className: "flex w-full max-w-[720px] flex-col gap-y-8 px-6 py-16", children: /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-col gap-y-6", children: [
308
+ /* @__PURE__ */ jsxs("div", { children: [
309
+ /* @__PURE__ */ jsx2(StackedFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx2(Heading, { children: t2(
310
+ "stockLocations.shippingOptions.conditionalPrices.header",
311
+ {
312
+ name: header
313
+ }
314
+ ) }) }),
315
+ /* @__PURE__ */ jsx2(StackedFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx2(Text, { size: "small", className: "text-ui-fg-subtle", children: t2(
316
+ "stockLocations.shippingOptions.conditionalPrices.description"
317
+ ) }) })
318
+ ] }),
319
+ /* @__PURE__ */ jsx2(ConditionalPriceList, { value, onValueChange: setValue, children: fields.map((field2, index) => /* @__PURE__ */ jsx2(
320
+ ConditionalPriceItem,
321
+ {
322
+ index,
323
+ onRemove: handleRemove,
324
+ currency,
325
+ control: conditionalPriceForm.control
326
+ },
327
+ field2.id
328
+ )) }),
329
+ /* @__PURE__ */ jsx2("div", { className: "flex items-center justify-end", children: /* @__PURE__ */ jsx2(
330
+ Button,
331
+ {
332
+ variant: "secondary",
333
+ size: "small",
334
+ type: "button",
335
+ onClick: handleAdd,
336
+ children: t2(
337
+ "stockLocations.shippingOptions.conditionalPrices.actions.addPrice"
338
+ )
339
+ }
340
+ ) })
341
+ ] }) }) }) }),
342
+ /* @__PURE__ */ jsx2(StackedFocusModal.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-2", children: [
343
+ /* @__PURE__ */ jsx2(StackedFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx2(Button, { variant: "secondary", size: "small", type: "button", children: t2("actions.cancel") }) }),
344
+ /* @__PURE__ */ jsx2(Button, { size: "small", type: "button", onClick: handleOnSubmit, children: t2("actions.save") })
345
+ ] }) })
346
+ ] })
347
+ }
348
+ ) });
349
+ };
350
+ var ConditionalPriceList = ({
351
+ children,
352
+ value,
353
+ onValueChange
354
+ }) => {
355
+ return /* @__PURE__ */ jsx2(
356
+ RadixAccordion.Root,
357
+ {
358
+ type: "multiple",
359
+ defaultValue: [getRuleValue(0)],
360
+ value,
361
+ onValueChange,
362
+ className: "flex flex-col gap-y-3",
363
+ children
364
+ }
365
+ );
366
+ };
367
+ var ConditionalPriceItem = ({
368
+ index,
369
+ currency,
370
+ onRemove,
371
+ control
372
+ }) => {
373
+ const { t: t2 } = useTranslation();
374
+ const handleRemove = (e) => {
375
+ e.stopPropagation();
376
+ onRemove(index);
377
+ };
378
+ return /* @__PURE__ */ jsxs(
379
+ RadixAccordion.Item,
380
+ {
381
+ value: getRuleValue(index),
382
+ className: clx(
383
+ "bg-ui-bg-component shadow-elevation-card-rest rounded-lg"
384
+ ),
385
+ children: [
386
+ /* @__PURE__ */ jsx2(RadixAccordion.Trigger, { asChild: true, children: /* @__PURE__ */ jsxs("div", { className: "group/trigger flex w-full cursor-pointer items-start justify-between gap-x-2 p-3", children: [
387
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-1 flex-wrap items-center justify-between gap-2", children: [
388
+ /* @__PURE__ */ jsx2("div", { className: "flex h-7 items-center", children: /* @__PURE__ */ jsx2(
389
+ AmountDisplay,
390
+ {
391
+ index,
392
+ currency,
393
+ control
394
+ }
395
+ ) }),
396
+ /* @__PURE__ */ jsx2("div", { className: "flex min-h-7 items-center", children: /* @__PURE__ */ jsx2(
397
+ ConditionDisplay,
398
+ {
399
+ index,
400
+ currency,
401
+ control
402
+ }
403
+ ) })
404
+ ] }),
405
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2", children: [
406
+ /* @__PURE__ */ jsx2(
407
+ IconButton,
408
+ {
409
+ size: "small",
410
+ variant: "transparent",
411
+ className: "text-ui-fg-muted hover:text-ui-fg-subtle focus-visible:text-ui-fg-subtle",
412
+ onClick: handleRemove,
413
+ children: /* @__PURE__ */ jsx2(XMarkMini, {})
414
+ }
415
+ ),
416
+ /* @__PURE__ */ jsx2(
417
+ IconButton,
418
+ {
419
+ size: "small",
420
+ variant: "transparent",
421
+ className: "text-ui-fg-muted hover:text-ui-fg-subtle focus-visible:text-ui-fg-subtle",
422
+ children: /* @__PURE__ */ jsx2(TriangleDownMini, { className: "transition-transform group-data-[state=open]/trigger:rotate-180" })
423
+ }
424
+ )
425
+ ] })
426
+ ] }) }),
427
+ /* @__PURE__ */ jsxs(RadixAccordion.Content, { className: "text-ui-fg-subtle", children: [
428
+ /* @__PURE__ */ jsx2(Divider, { variant: "dashed" }),
429
+ /* @__PURE__ */ jsx2(
430
+ Form.Field,
431
+ {
432
+ control,
433
+ name: `prices.${index}.amount`,
434
+ render: ({ field: { value, onChange, ...props } }) => {
435
+ return /* @__PURE__ */ jsx2(Form.Item, { children: /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 items-start gap-x-2 p-3", children: [
436
+ /* @__PURE__ */ jsx2("div", { className: "flex h-8 items-center", children: /* @__PURE__ */ jsx2(Form.Label, { children: t2(
437
+ "stockLocations.shippingOptions.conditionalPrices.rules.amount"
438
+ ) }) }),
439
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-1", children: [
440
+ /* @__PURE__ */ jsx2(Form.Control, { children: /* @__PURE__ */ jsx2(
441
+ CurrencyInput,
442
+ {
443
+ className: "bg-ui-bg-field-component hover:bg-ui-bg-field-component-hover focus-visible:bg-ui-bg-field-component-hover",
444
+ placeholder: formatValue({
445
+ value: "0",
446
+ decimalScale: currency.decimal_digits
447
+ }),
448
+ decimalScale: currency.decimal_digits,
449
+ symbol: currency.symbol_native,
450
+ code: currency.code,
451
+ value,
452
+ onValueChange: (_value, _name, values) => onChange(values?.value ? values?.value : ""),
453
+ ...props
454
+ }
455
+ ) }),
456
+ /* @__PURE__ */ jsx2(Form.ErrorMessage, {})
457
+ ] })
458
+ ] }) });
459
+ }
460
+ }
461
+ ),
462
+ /* @__PURE__ */ jsx2(Divider, { variant: "dashed" }),
463
+ /* @__PURE__ */ jsx2(
464
+ Form.Field,
465
+ {
466
+ control,
467
+ name: `prices.${index}.gte`,
468
+ render: ({ field }) => {
469
+ return /* @__PURE__ */ jsx2(
470
+ OperatorInput,
471
+ {
472
+ field,
473
+ label: t2(
474
+ "stockLocations.shippingOptions.conditionalPrices.rules.gte"
475
+ ),
476
+ currency,
477
+ placeholder: "1000"
478
+ }
479
+ );
480
+ }
481
+ }
482
+ ),
483
+ /* @__PURE__ */ jsx2(Divider, { variant: "dashed" }),
484
+ /* @__PURE__ */ jsx2(
485
+ Form.Field,
486
+ {
487
+ control,
488
+ name: `prices.${index}.lte`,
489
+ render: ({ field }) => {
490
+ return /* @__PURE__ */ jsx2(
491
+ OperatorInput,
492
+ {
493
+ field,
494
+ label: t2(
495
+ "stockLocations.shippingOptions.conditionalPrices.rules.lte"
496
+ ),
497
+ currency,
498
+ placeholder: "1000"
499
+ }
500
+ );
501
+ }
502
+ }
503
+ ),
504
+ /* @__PURE__ */ jsx2(
505
+ ReadOnlyConditions,
506
+ {
507
+ index,
508
+ control,
509
+ currency
510
+ }
511
+ )
512
+ ] })
513
+ ]
514
+ }
515
+ );
516
+ };
517
+ var OperatorInput = ({
518
+ field,
519
+ label,
520
+ currency,
521
+ placeholder
522
+ }) => {
523
+ const innerRef = useRef(null);
524
+ const { value, onChange, ref, ...props } = field;
525
+ const refs = useCombinedRefs(innerRef, ref);
526
+ const action = () => {
527
+ if (value === null) {
528
+ onChange("");
529
+ requestAnimationFrame(() => {
530
+ innerRef.current?.focus();
531
+ });
532
+ return;
533
+ }
534
+ onChange(null);
535
+ };
536
+ const isNull = value === null;
537
+ return /* @__PURE__ */ jsx2(Form.Item, { children: /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 items-start gap-x-2 p-3", children: [
538
+ /* @__PURE__ */ jsxs("div", { className: "flex h-8 items-center gap-x-1", children: [
539
+ /* @__PURE__ */ jsx2(IconButton, { size: "2xsmall", variant: "transparent", onClick: action, children: isNull ? /* @__PURE__ */ jsx2(Plus, {}) : /* @__PURE__ */ jsx2(XMark, {}) }),
540
+ /* @__PURE__ */ jsx2(Form.Label, { children: label })
541
+ ] }),
542
+ !isNull && /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-1", children: [
543
+ /* @__PURE__ */ jsx2(Form.Control, { children: /* @__PURE__ */ jsx2(
544
+ CurrencyInput,
545
+ {
546
+ className: "bg-ui-bg-field-component hover:bg-ui-bg-field-component-hover focus-visible:bg-ui-bg-field-component-hover",
547
+ placeholder: formatValue({
548
+ value: placeholder,
549
+ decimalScale: currency.decimal_digits
550
+ }),
551
+ decimalScale: currency.decimal_digits,
552
+ symbol: currency.symbol_native,
553
+ code: currency.code,
554
+ value,
555
+ ref: refs,
556
+ onValueChange: (_value, _name, values) => onChange(values?.value ? values?.value : ""),
557
+ ...props
558
+ }
559
+ ) }),
560
+ /* @__PURE__ */ jsx2(Form.ErrorMessage, {})
561
+ ] })
562
+ ] }) });
563
+ };
564
+ var ReadOnlyConditions = ({
565
+ index,
566
+ control,
567
+ currency
568
+ }) => {
569
+ const { t: t2 } = useTranslation();
570
+ const item = useWatch({
571
+ control,
572
+ name: `prices.${index}`
573
+ });
574
+ if (item.eq == null && item.gt == null && item.lt == null) {
575
+ return null;
576
+ }
577
+ return /* @__PURE__ */ jsxs("div", { children: [
578
+ /* @__PURE__ */ jsx2(Divider, { variant: "dashed" }),
579
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-1 px-3 pt-3", children: [
580
+ /* @__PURE__ */ jsx2(Text, { size: "small", leading: "compact", weight: "plus", children: t2(
581
+ "stockLocations.shippingOptions.conditionalPrices.customRules.label"
582
+ ) }),
583
+ /* @__PURE__ */ jsx2(
584
+ Tooltip,
585
+ {
586
+ content: t2(
587
+ "stockLocations.shippingOptions.conditionalPrices.customRules.tooltip"
588
+ ),
589
+ children: /* @__PURE__ */ jsx2(InformationCircleSolid, { className: "text-ui-fg-muted" })
590
+ }
591
+ )
592
+ ] }),
593
+ /* @__PURE__ */ jsxs("div", { children: [
594
+ item.eq != null && /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 items-start gap-x-2 p-3", children: [
595
+ /* @__PURE__ */ jsx2("div", { className: "flex h-8 items-center", children: /* @__PURE__ */ jsx2(Label, { weight: "plus", size: "small", children: t2(
596
+ "stockLocations.shippingOptions.conditionalPrices.customRules.eq"
597
+ ) }) }),
598
+ /* @__PURE__ */ jsx2(
599
+ CurrencyInput,
600
+ {
601
+ className: "bg-ui-bg-field-component hover:bg-ui-bg-field-component-hover focus-visible:bg-ui-bg-field-component-hover",
602
+ symbol: currency.symbol_native,
603
+ code: currency.code,
604
+ value: item.eq,
605
+ disabled: true
606
+ }
607
+ )
608
+ ] }),
609
+ item.gt != null && /* @__PURE__ */ jsxs(Fragment, { children: [
610
+ /* @__PURE__ */ jsx2(Divider, { variant: "dashed" }),
611
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 items-start gap-x-2 p-3", children: [
612
+ /* @__PURE__ */ jsx2("div", { className: "flex h-8 items-center", children: /* @__PURE__ */ jsx2(Label, { weight: "plus", size: "small", children: t2(
613
+ "stockLocations.shippingOptions.conditionalPrices.customRules.gt"
614
+ ) }) }),
615
+ /* @__PURE__ */ jsx2(
616
+ CurrencyInput,
617
+ {
618
+ className: "bg-ui-bg-field-component hover:bg-ui-bg-field-component-hover focus-visible:bg-ui-bg-field-component-hover",
619
+ symbol: currency.symbol_native,
620
+ code: currency.code,
621
+ value: item.gt,
622
+ disabled: true
623
+ }
624
+ )
625
+ ] })
626
+ ] }),
627
+ item.lt != null && /* @__PURE__ */ jsxs(Fragment, { children: [
628
+ /* @__PURE__ */ jsx2(Divider, { variant: "dashed" }),
629
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 items-start gap-x-2 p-3", children: [
630
+ /* @__PURE__ */ jsx2("div", { className: "flex h-8 items-center", children: /* @__PURE__ */ jsx2(Label, { weight: "plus", size: "small", children: t2(
631
+ "stockLocations.shippingOptions.conditionalPrices.customRules.lt"
632
+ ) }) }),
633
+ /* @__PURE__ */ jsx2(
634
+ CurrencyInput,
635
+ {
636
+ className: "bg-ui-bg-field-component hover:bg-ui-bg-field-component-hover focus-visible:bg-ui-bg-field-component-hover",
637
+ symbol: currency.symbol_native,
638
+ code: currency.code,
639
+ value: item.lt,
640
+ disabled: true
641
+ }
642
+ )
643
+ ] })
644
+ ] })
645
+ ] })
646
+ ] });
647
+ };
648
+ var AmountDisplay = ({
649
+ index,
650
+ currency,
651
+ control
652
+ }) => {
653
+ const amount = useWatch({
654
+ control,
655
+ name: `prices.${index}.amount`
656
+ });
657
+ if (amount === "" || amount === void 0) {
658
+ return /* @__PURE__ */ jsx2(Text, { size: "small", weight: "plus", children: "-" });
659
+ }
660
+ const castAmount = castNumber(amount);
661
+ return /* @__PURE__ */ jsx2(Text, { size: "small", weight: "plus", children: getLocaleAmount(castAmount, currency.code) });
662
+ };
663
+ var ConditionContainer = ({ children }) => /* @__PURE__ */ jsx2("div", { className: "text-ui-fg-subtle txt-small flex flex-wrap items-center gap-1.5", children });
664
+ var ConditionDisplay = ({
665
+ index,
666
+ currency,
667
+ control
668
+ }) => {
669
+ const { t: t2, i18n } = useTranslation();
670
+ const gte = useWatch({
671
+ control,
672
+ name: `prices.${index}.gte`
673
+ });
674
+ const lte = useWatch({
675
+ control,
676
+ name: `prices.${index}.lte`
677
+ });
678
+ const renderCondition = () => {
679
+ const castGte = gte ? castNumber(gte) : void 0;
680
+ const castLte = lte ? castNumber(lte) : void 0;
681
+ if (!castGte && !castLte) {
682
+ return null;
683
+ }
684
+ if (castGte && !castLte) {
685
+ return /* @__PURE__ */ jsx2(ConditionContainer, { children: /* @__PURE__ */ jsx2(
686
+ Trans,
687
+ {
688
+ i18n,
689
+ i18nKey: "stockLocations.shippingOptions.conditionalPrices.summaries.greaterThan",
690
+ components: [
691
+ /* @__PURE__ */ jsx2(Badge, { size: "2xsmall" }, "attribute"),
692
+ /* @__PURE__ */ jsx2(Badge, { size: "2xsmall" }, "gte")
693
+ ],
694
+ values: {
695
+ attribute: t2(
696
+ "stockLocations.shippingOptions.conditionalPrices.attributes.cartItemTotal"
697
+ ),
698
+ gte: getLocaleAmount(castGte, currency.code)
699
+ }
700
+ }
701
+ ) });
702
+ }
703
+ if (!castGte && castLte) {
704
+ return /* @__PURE__ */ jsx2(ConditionContainer, { children: /* @__PURE__ */ jsx2(
705
+ Trans,
706
+ {
707
+ i18n,
708
+ i18nKey: "stockLocations.shippingOptions.conditionalPrices.summaries.lessThan",
709
+ components: [
710
+ /* @__PURE__ */ jsx2(Badge, { size: "2xsmall" }, "attribute"),
711
+ /* @__PURE__ */ jsx2(Badge, { size: "2xsmall" }, "lte")
712
+ ],
713
+ values: {
714
+ attribute: t2(
715
+ "stockLocations.shippingOptions.conditionalPrices.attributes.cartItemTotal"
716
+ ),
717
+ lte: getLocaleAmount(castLte, currency.code)
718
+ }
719
+ }
720
+ ) });
721
+ }
722
+ if (castGte && castLte) {
723
+ return /* @__PURE__ */ jsx2(ConditionContainer, { children: /* @__PURE__ */ jsx2(
724
+ Trans,
725
+ {
726
+ i18n,
727
+ i18nKey: "stockLocations.shippingOptions.conditionalPrices.summaries.range",
728
+ components: [
729
+ /* @__PURE__ */ jsx2(Badge, { size: "2xsmall" }, "attribute"),
730
+ /* @__PURE__ */ jsx2(Badge, { size: "2xsmall" }, "gte"),
731
+ /* @__PURE__ */ jsx2(Badge, { size: "2xsmall" }, "lte")
732
+ ],
733
+ values: {
734
+ attribute: t2(
735
+ "stockLocations.shippingOptions.conditionalPrices.attributes.cartItemTotal"
736
+ ),
737
+ gte: getLocaleAmount(castGte, currency.code),
738
+ lte: getLocaleAmount(castLte, currency.code)
739
+ }
740
+ }
741
+ ) });
742
+ }
743
+ return null;
744
+ };
745
+ return renderCondition();
746
+ };
747
+
748
+ // src/pages/settings/locations/_common/hooks/use-shipping-option-price-columns.tsx
749
+ import { useMemo } from "react";
750
+ import { useTranslation as useTranslation2 } from "react-i18next";
751
+
752
+ // src/pages/settings/locations/_common/components/shipping-option-price-cell.tsx
753
+ import { ArrowsPointingOut, CircleSliders } from "@medusajs/icons";
754
+ import { clx as clx2 } from "@medusajs/ui";
755
+ import { useCallback, useEffect, useRef as useRef2, useState as useState2 } from "react";
756
+ import CurrencyInput2, {
757
+ formatValue as formatValue2
758
+ } from "react-currency-input-field";
759
+ import {
760
+ Controller,
761
+ useWatch as useWatch2
762
+ } from "react-hook-form";
763
+ import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
764
+ var ShippingOptionPriceCell = ({
765
+ context,
766
+ code,
767
+ header,
768
+ type
769
+ }) => {
770
+ const [symbolWidth, setSymbolWidth] = useState2(0);
771
+ const measuredRef = useCallback((node) => {
772
+ if (node) {
773
+ const width = node.offsetWidth;
774
+ setSymbolWidth(width);
775
+ }
776
+ }, []);
777
+ const { field, control, renderProps } = useDataGridCell({
778
+ context
779
+ });
780
+ const errorProps = useDataGridCellError({ context });
781
+ const { container, input } = renderProps;
782
+ const { isAnchor } = container;
783
+ const currency = currencies[code.toUpperCase()];
784
+ return /* @__PURE__ */ jsx3(
785
+ Controller,
786
+ {
787
+ control,
788
+ name: field,
789
+ render: ({ field: props }) => {
790
+ return /* @__PURE__ */ jsx3(
791
+ DataGridCellContainer,
792
+ {
793
+ ...container,
794
+ ...errorProps,
795
+ outerComponent: /* @__PURE__ */ jsx3(
796
+ OuterComponent,
797
+ {
798
+ header,
799
+ isAnchor,
800
+ field,
801
+ control,
802
+ symbolWidth,
803
+ type,
804
+ currency
805
+ }
806
+ ),
807
+ children: /* @__PURE__ */ jsx3(
808
+ Inner,
809
+ {
810
+ field: props,
811
+ inputProps: input,
812
+ currencyInfo: currency,
813
+ onMeasureSymbol: measuredRef
814
+ }
815
+ )
816
+ }
817
+ );
818
+ }
819
+ }
820
+ );
821
+ };
822
+ var OuterComponent = ({
823
+ isAnchor,
824
+ header,
825
+ field,
826
+ control,
827
+ symbolWidth,
828
+ type,
829
+ currency
830
+ }) => {
831
+ const { onOpenConditionalPricesModal } = useShippingOptionPrice();
832
+ const buttonRef = useRef2(null);
833
+ const name = getCustomShippingOptionPriceFieldName(field, type);
834
+ const price = useWatch2({ control, name });
835
+ useEffect(() => {
836
+ const handleKeyDown = (e) => {
837
+ if (isAnchor && (e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "b") {
838
+ e.preventDefault();
839
+ buttonRef.current?.click();
840
+ }
841
+ };
842
+ document.addEventListener("keydown", handleKeyDown);
843
+ return () => document.removeEventListener("keydown", handleKeyDown);
844
+ }, [isAnchor]);
845
+ return /* @__PURE__ */ jsxs2(
846
+ "div",
847
+ {
848
+ className: "absolute inset-y-0 z-[3] flex w-fit items-center justify-center",
849
+ style: {
850
+ left: symbolWidth ? `${symbolWidth + 16 + 4}px` : void 0
851
+ },
852
+ children: [
853
+ price?.length > 0 && !isAnchor && /* @__PURE__ */ jsx3("div", { className: "flex size-[15px] items-center justify-center group-hover/container:hidden", children: /* @__PURE__ */ jsx3(CircleSliders, { className: "text-ui-fg-interactive" }) }),
854
+ /* @__PURE__ */ jsx3(
855
+ "button",
856
+ {
857
+ ref: buttonRef,
858
+ type: "button",
859
+ className: clx2(
860
+ "hover:text-ui-fg-subtle text-ui-fg-muted transition-fg hidden size-[15px] items-center justify-center rounded-md bg-transparent group-hover/container:flex",
861
+ { flex: isAnchor }
862
+ ),
863
+ onClick: () => onOpenConditionalPricesModal({
864
+ type,
865
+ field,
866
+ currency,
867
+ name: header
868
+ }),
869
+ children: /* @__PURE__ */ jsx3(ArrowsPointingOut, {})
870
+ }
871
+ )
872
+ ]
873
+ }
874
+ );
875
+ };
876
+ var Inner = ({
877
+ field,
878
+ onMeasureSymbol,
879
+ inputProps,
880
+ currencyInfo
881
+ }) => {
882
+ const { value, onChange: _, onBlur, ref, ...rest } = field;
883
+ const {
884
+ ref: inputRef,
885
+ onBlur: onInputBlur,
886
+ onFocus,
887
+ onChange,
888
+ ...attributes
889
+ } = inputProps;
890
+ const formatter = useCallback(
891
+ (value2) => {
892
+ const ensuredValue = typeof value2 === "number" ? value2.toString() : value2 || "";
893
+ return formatValue2({
894
+ value: ensuredValue,
895
+ decimalScale: currencyInfo.decimal_digits,
896
+ disableGroupSeparators: true,
897
+ decimalSeparator: "."
898
+ });
899
+ },
900
+ [currencyInfo]
901
+ );
902
+ const [localValue, setLocalValue] = useState2(value || "");
903
+ const handleValueChange = (value2, _name, _values) => {
904
+ if (!value2) {
905
+ setLocalValue("");
906
+ return;
907
+ }
908
+ setLocalValue(value2);
909
+ };
910
+ useEffect(() => {
911
+ let update = value;
912
+ if (!isNaN(Number(value))) {
913
+ update = formatter(update);
914
+ }
915
+ setLocalValue(update);
916
+ }, [value, formatter]);
917
+ const combinedRed = useCombinedRefs(inputRef, ref);
918
+ return /* @__PURE__ */ jsxs2("div", { className: "relative flex size-full items-center", children: [
919
+ /* @__PURE__ */ jsx3(
920
+ "span",
921
+ {
922
+ className: "txt-compact-small text-ui-fg-muted pointer-events-none absolute left-0 w-fit min-w-4",
923
+ "aria-hidden": true,
924
+ ref: onMeasureSymbol,
925
+ children: currencyInfo.symbol_native
926
+ }
927
+ ),
928
+ /* @__PURE__ */ jsx3(
929
+ CurrencyInput2,
930
+ {
931
+ ...rest,
932
+ ...attributes,
933
+ ref: combinedRed,
934
+ className: "txt-compact-small w-full flex-1 cursor-default appearance-none bg-transparent pl-[60px] text-right outline-none",
935
+ value: localValue || void 0,
936
+ onValueChange: handleValueChange,
937
+ formatValueOnBlur: true,
938
+ onBlur: () => {
939
+ onBlur();
940
+ onInputBlur();
941
+ onChange(localValue, value);
942
+ },
943
+ onFocus,
944
+ decimalScale: currencyInfo.decimal_digits,
945
+ decimalsLimit: currencyInfo.decimal_digits,
946
+ autoComplete: "off",
947
+ tabIndex: -1
948
+ }
949
+ )
950
+ ] });
951
+ };
952
+
953
+ // src/pages/settings/locations/_common/hooks/use-shipping-option-price-columns.tsx
954
+ import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
955
+ var columnHelper = createDataGridHelper();
956
+ var useShippingOptionPriceColumns = ({
957
+ name,
958
+ currencies: currencies2 = [],
959
+ regions = [],
960
+ pricePreferences = []
961
+ }) => {
962
+ const { t: t2 } = useTranslation2();
963
+ return useMemo(() => {
964
+ return [
965
+ columnHelper.column({
966
+ id: "name",
967
+ name: t2("fields.name"),
968
+ disableHiding: true,
969
+ header: t2("fields.name"),
970
+ cell: (context) => {
971
+ return /* @__PURE__ */ jsx4(DataGrid.ReadonlyCell, { context, children: name });
972
+ }
973
+ }),
974
+ ...createDataGridPriceColumns({
975
+ currencies: currencies2,
976
+ regions,
977
+ pricePreferences,
978
+ getFieldName: (context, value) => {
979
+ if (context.column.id?.startsWith("currency_prices")) {
980
+ return `currency_prices.${value}`;
981
+ }
982
+ return `region_prices.${value}`;
983
+ },
984
+ t: t2
985
+ })
986
+ ];
987
+ }, [t2, currencies2, regions, pricePreferences, name]);
988
+ };
989
+ var createDataGridPriceColumns = ({
990
+ currencies: currencies2,
991
+ regions,
992
+ pricePreferences,
993
+ getFieldName,
994
+ t: t2
995
+ }) => {
996
+ const columnHelper2 = createDataGridHelper();
997
+ return [
998
+ // ...(currencies?.map((currency) => {
999
+ // const preference = pricePreferences?.find(
1000
+ // (p) => p.attribute === "currency_code" && p.value === currency
1001
+ // )
1002
+ // const translatedCurrencyName = t("fields.priceTemplate", {
1003
+ // regionOrCurrency: currency.toUpperCase(),
1004
+ // })
1005
+ // return columnHelper.column({
1006
+ // id: `currency_prices.${currency}`,
1007
+ // name: t("fields.priceTemplate", {
1008
+ // regionOrCurrency: currency.toUpperCase(),
1009
+ // }),
1010
+ // field: (context) => {
1011
+ // return getFieldName(context, currency)
1012
+ // },
1013
+ // type: "number",
1014
+ // header: () => (
1015
+ // <div className="flex w-full items-center justify-between gap-3">
1016
+ // <span className="truncate" title={translatedCurrencyName}>
1017
+ // {translatedCurrencyName}
1018
+ // </span>
1019
+ // <IncludesTaxTooltip includesTax={preference?.is_tax_inclusive} />
1020
+ // </div>
1021
+ // ),
1022
+ // cell: (context) => {
1023
+ // return (
1024
+ // <ShippingOptionPriceCell
1025
+ // type="currency"
1026
+ // header={translatedCurrencyName}
1027
+ // code={currency}
1028
+ // context={context}
1029
+ // />
1030
+ // )
1031
+ // },
1032
+ // })
1033
+ // }) ?? []),
1034
+ ...regions?.map((region) => {
1035
+ const preference = pricePreferences?.find(
1036
+ (p) => p.attribute === "region_id" && p.value === region.id
1037
+ );
1038
+ const translatedRegionName = t2("fields.priceTemplate", {
1039
+ regionOrCurrency: region.name
1040
+ });
1041
+ return columnHelper2.column({
1042
+ id: `region_prices.${region.id}`,
1043
+ name: t2("fields.priceTemplate", {
1044
+ regionOrCurrency: region.name
1045
+ }),
1046
+ field: (context) => {
1047
+ return getFieldName(context, region.id);
1048
+ },
1049
+ type: "number",
1050
+ header: () => /* @__PURE__ */ jsxs3("div", { className: "flex w-full items-center justify-between gap-3", children: [
1051
+ /* @__PURE__ */ jsx4("span", { className: "truncate", title: translatedRegionName, children: translatedRegionName }),
1052
+ /* @__PURE__ */ jsx4(IncludesTaxTooltip, { includesTax: preference?.is_tax_inclusive })
1053
+ ] }),
1054
+ cell: (context) => {
1055
+ const currency = currencies2?.find((c) => c === region.currency_code);
1056
+ if (!currency) {
1057
+ return null;
1058
+ }
1059
+ return /* @__PURE__ */ jsx4(
1060
+ ShippingOptionPriceCell,
1061
+ {
1062
+ type: "region",
1063
+ header: translatedRegionName,
1064
+ code: region.currency_code,
1065
+ context
1066
+ }
1067
+ );
1068
+ }
1069
+ });
1070
+ }) ?? []
1071
+ ];
1072
+ };
1073
+
1074
+ export {
1075
+ ConditionalPriceSchema,
1076
+ UpdateConditionalPriceSchema,
1077
+ ShippingOptionPriceProvider,
1078
+ ConditionalPriceForm,
1079
+ useShippingOptionPriceColumns
1080
+ };