@mercurjs/admin 2.3.6-canary.1 → 2.3.6-canary.11

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 (273) hide show
  1. package/dist/{add-campaign-promotions-PBGDZSCD.js → add-campaign-promotions-EIQFBRHD.js} +13 -8
  2. package/dist/{adjust-inventory-BBAU3NMM.js → adjust-inventory-H46YCNLT.js} +8 -3
  3. package/dist/{api-key-management-detail-ZGGQBQAM.js → api-key-management-detail-Z4KSJHUC.js} +6 -8
  4. package/dist/{api-key-management-list-T2WHT6MT.js → api-key-management-list-QZIRPINF.js} +5 -5
  5. package/dist/{api-key-management-sales-channels-FS3KXQQ6.js → api-key-management-sales-channels-RGZ3QITG.js} +9 -7
  6. package/dist/{attribute-create-C435ZHB2.js → attribute-create-7I5GNYFM.js} +6 -5
  7. package/dist/{attribute-detail-SPYDB3I5.js → attribute-detail-GP4PEFJ7.js} +17 -11
  8. package/dist/{attribute-edit-AAEAOP5B.js → attribute-edit-YNKCBXLU.js} +2 -2
  9. package/dist/{attribute-edit-possible-value-BJSQCTNO.js → attribute-edit-possible-value-XY7W42FB.js} +2 -2
  10. package/dist/{attribute-list-SCFBKH4L.js → attribute-list-ZC3CG5LS.js} +7 -7
  11. package/dist/{campaign-detail-BHRCOKL3.js → campaign-detail-OZWTK26Z.js} +11 -11
  12. package/dist/{campaign-list-GIMU2QVW.js → campaign-list-XCO4FJDZ.js} +5 -5
  13. package/dist/{categories-metadata-MJAYSCTW.js → categories-metadata-QYH5U77W.js} +3 -3
  14. package/dist/{category-detail-GVEDFNM7.js → category-detail-V2QUSUF3.js} +11 -12
  15. package/dist/{category-list-J7XYQDJU.js → category-list-XDOYTQ4X.js} +6 -6
  16. package/dist/{category-products-VVF5NXCE.js → category-products-DL4KV6NX.js} +16 -9
  17. package/dist/{chunk-NIDM2VQO.js → chunk-23CSVCQK.js} +28 -17
  18. package/dist/{chunk-DUFGVZ6H.js → chunk-25TWJMWE.js} +2 -2
  19. package/dist/{chunk-VTXMQTXK.js → chunk-26REB3B6.js} +4 -3
  20. package/dist/{chunk-ZH6TIKKW.js → chunk-2MOTQNEG.js} +1 -0
  21. package/dist/{chunk-M6X7KIBW.js → chunk-2XBNM6TM.js} +4 -4
  22. package/dist/{chunk-BQZ5P3IA.js → chunk-36KEGXUQ.js} +112 -75
  23. package/dist/{chunk-475XGX3J.js → chunk-3BKRMIWA.js} +24 -13
  24. package/dist/{chunk-NCDKLTDP.js → chunk-3H3BJSIK.js} +34 -12
  25. package/dist/chunk-3UOYBH5O.js +8 -0
  26. package/dist/{chunk-GFHUI2QK.js → chunk-473QGQSA.js} +9 -6
  27. package/dist/{chunk-3XS5ADKJ.js → chunk-4AOVNA5G.js} +31 -20
  28. package/dist/{chunk-IKAUNMRC.js → chunk-4J74G7N2.js} +15 -3
  29. package/dist/{chunk-WIDHYDJQ.js → chunk-4JQDYQSX.js} +20 -10
  30. package/dist/{chunk-RW3NEG36.js → chunk-4W77EUYY.js} +9 -7
  31. package/dist/{chunk-6UYV7B42.js → chunk-4Y7SBHXE.js} +10 -8
  32. package/dist/{chunk-VVIJHBKM.js → chunk-5MXEKSK4.js} +1 -1
  33. package/dist/{chunk-AGO4ROOR.js → chunk-5OIFUF7R.js} +1 -1
  34. package/dist/{chunk-S4WDCOQD.js → chunk-5QW3GY37.js} +27 -14
  35. package/dist/{chunk-5TIADRZ7.js → chunk-63JSBXD5.js} +8 -6
  36. package/dist/{chunk-5ENOJFDI.js → chunk-7CGMFCSU.js} +1 -1
  37. package/dist/{chunk-7QZFRDTU.js → chunk-7GCMYYFL.js} +7 -4
  38. package/dist/{chunk-OWWE5Y6T.js → chunk-7URQCA3H.js} +8 -6
  39. package/dist/{chunk-R2ODJ3D3.js → chunk-A3LCORSK.js} +11 -7
  40. package/dist/{chunk-IZ77JV46.js → chunk-AUCCE46Q.js} +6 -3
  41. package/dist/{chunk-PFQO7UQG.js → chunk-AW4RL2SA.js} +60 -33
  42. package/dist/{chunk-2NOIR4BR.js → chunk-AZV22U4V.js} +20 -2
  43. package/dist/{chunk-VYSTJIAD.js → chunk-CX5XB56X.js} +4 -3
  44. package/dist/{chunk-VWPX7GLC.js → chunk-DBGBLXBS.js} +1 -1
  45. package/dist/{chunk-J4SYK3RT.js → chunk-DGRHDZQO.js} +15 -5
  46. package/dist/{chunk-6AQYZWOC.js → chunk-DL5J4DV2.js} +2 -2
  47. package/dist/{chunk-7UHN2CW7.js → chunk-DM52HEOD.js} +1 -1
  48. package/dist/{chunk-EJGGX3ON.js → chunk-DMLXILXG.js} +12 -10
  49. package/dist/chunk-DQ6RPO6N.js +2954 -0
  50. package/dist/{chunk-VBHKRUON.js → chunk-DUKOOIQD.js} +6 -5
  51. package/dist/{chunk-BLU2WLIJ.js → chunk-DWPBJEEM.js} +21 -8
  52. package/dist/{chunk-6P7HBAUM.js → chunk-E4CMR4T2.js} +21 -13
  53. package/dist/{chunk-QEBISX7V.js → chunk-EBAFVGM3.js} +1 -1
  54. package/dist/{chunk-J34YB5R4.js → chunk-EHLCUND7.js} +12 -10
  55. package/dist/{chunk-DBCNRZZE.js → chunk-EIPTLSNT.js} +3 -1
  56. package/dist/{chunk-KWFSBUD6.js → chunk-ESRIX7ZH.js} +1485 -1411
  57. package/dist/{chunk-YM5X7CQL.js → chunk-FCAJQFYT.js} +32 -12
  58. package/dist/{chunk-437KXVGO.js → chunk-G63BL5AB.js} +8 -5
  59. package/dist/{chunk-BZPOERWW.js → chunk-GIV6KSQX.js} +18 -9
  60. package/dist/{chunk-G2KWNZV6.js → chunk-GMJLK3IK.js} +2 -2
  61. package/dist/{chunk-P2KYQNXQ.js → chunk-GQYB3OOC.js} +108 -65
  62. package/dist/{chunk-4FAYO6UJ.js → chunk-GZUXEIEB.js} +3 -3
  63. package/dist/{chunk-7ASAC2FM.js → chunk-H4TJZB26.js} +26 -18
  64. package/dist/{chunk-5SNW2DCY.js → chunk-HXDCSVQP.js} +42 -18
  65. package/dist/{chunk-NQEXDESI.js → chunk-IBTEL5KA.js} +32 -14
  66. package/dist/{chunk-Q732RWRD.js → chunk-IQRFJO4N.js} +7 -5
  67. package/dist/{chunk-LBFX6AVE.js → chunk-JFRYC6GK.js} +17 -10
  68. package/dist/{chunk-7YBZ2PEZ.js → chunk-JQ7GOJK6.js} +135 -58
  69. package/dist/{chunk-FOWWGEP7.js → chunk-JS2DAWKO.js} +9 -6
  70. package/dist/{chunk-IHCKU5FR.js → chunk-K6OBX6ZR.js} +8 -7
  71. package/dist/{chunk-RSDTHO3I.js → chunk-KB3BTLIB.js} +6 -4
  72. package/dist/{chunk-VIHLAFDA.js → chunk-KYOZ4CCY.js} +61 -29
  73. package/dist/{chunk-D6WRJZPH.js → chunk-LCUAIH7P.js} +7 -5
  74. package/dist/{chunk-F5EZQMOA.js → chunk-M7VHCFCW.js} +10 -8
  75. package/dist/{chunk-EVCAR6GP.js → chunk-MAEUKXZ4.js} +8 -5
  76. package/dist/{chunk-HFCJJJKP.js → chunk-MKKOAF2W.js} +26 -12
  77. package/dist/{chunk-MQFPD5J4.js → chunk-MNKJHZZT.js} +10 -6
  78. package/dist/{chunk-YUL4ES52.js → chunk-MSJ2QS4Y.js} +6 -4
  79. package/dist/{chunk-VE5FQQTG.js → chunk-MTP3MDAA.js} +10 -7
  80. package/dist/{chunk-24JEBPKI.js → chunk-NJ2NRKAJ.js} +57 -14
  81. package/dist/{chunk-XMIDY45X.js → chunk-NRRSESP2.js} +32 -13
  82. package/dist/{chunk-B7QLJF77.js → chunk-NUE5ZL5N.js} +11 -5
  83. package/dist/{chunk-B6KT5U7W.js → chunk-NZIDSNBJ.js} +10 -8
  84. package/dist/{chunk-PAG3PYAQ.js → chunk-O5W5DCKH.js} +1 -1
  85. package/dist/{chunk-CFQX7HAW.js → chunk-OCDZIJBM.js} +11 -5
  86. package/dist/{chunk-KTO2WJ75.js → chunk-OGTWBHJC.js} +2 -2
  87. package/dist/{chunk-3KRUGI6C.js → chunk-ONTZADVX.js} +1 -1
  88. package/dist/{chunk-W62DN2I2.js → chunk-OWSAXYGH.js} +1 -1
  89. package/dist/{chunk-ESNSDIEC.js → chunk-PDPCFFFH.js} +1 -1
  90. package/dist/{chunk-Q6M2TNLO.js → chunk-PGOJH3NS.js} +61 -329
  91. package/dist/{chunk-LXW3L56Z.js → chunk-Q2XWHI6K.js} +6 -3
  92. package/dist/{chunk-ENKVW7JW.js → chunk-QKW6ZECR.js} +29 -14
  93. package/dist/{chunk-JBT2FR4K.js → chunk-QPDL77XZ.js} +21 -10
  94. package/dist/{chunk-D7E6HL5O.js → chunk-QPXGSVW4.js} +10 -8
  95. package/dist/{chunk-M336ZIRO.js → chunk-QQ2UM2KH.js} +9 -7
  96. package/dist/{chunk-YWZQKODL.js → chunk-R55XYG6Y.js} +28 -15
  97. package/dist/{chunk-AOLP2YDZ.js → chunk-RAD3UMQ3.js} +7 -5
  98. package/dist/{chunk-HFM6N7R3.js → chunk-RLF7ADLP.js} +21 -13
  99. package/dist/{chunk-A2UTT4YX.js → chunk-SLXOKSG4.js} +58 -28
  100. package/dist/{chunk-ZOU25JF6.js → chunk-SU36MZXC.js} +11 -3
  101. package/dist/{chunk-F644YFJZ.js → chunk-SZSAJHN7.js} +7 -6
  102. package/dist/{chunk-GR7S7WTT.js → chunk-TPWSE5HE.js} +16 -11
  103. package/dist/{chunk-7ECQXPOG.js → chunk-TVCHVG2A.js} +3 -3
  104. package/dist/{chunk-HJACC6KV.js → chunk-UKQ6FES4.js} +6 -3
  105. package/dist/{chunk-JL3NKSLJ.js → chunk-USO2SWZV.js} +9 -4
  106. package/dist/chunk-USY2322P.js +17 -0
  107. package/dist/{chunk-6ASLWQB3.js → chunk-V3UQOU5W.js} +4 -2
  108. package/dist/{chunk-XXYVUV5F.js → chunk-VD2CKAYG.js} +21 -10
  109. package/dist/{chunk-C4XKPQ6T.js → chunk-VLNTJXXO.js} +16 -3
  110. package/dist/{chunk-D3RDR3D3.js → chunk-W3LCOK3O.js} +153 -124
  111. package/dist/{chunk-MXM5ZD4Y.js → chunk-W5U6NPSN.js} +10 -25
  112. package/dist/{chunk-MM5RRCPX.js → chunk-WVHNOE7Y.js} +1 -1
  113. package/dist/{chunk-RFENVF7Y.js → chunk-XUOGIKEE.js} +3 -3
  114. package/dist/{chunk-R22UAHRF.js → chunk-YDESULL7.js} +3 -1
  115. package/dist/{chunk-7I7G5ZJE.js → chunk-YIXWAK3A.js} +12 -7
  116. package/dist/{chunk-ZFPASY4R.js → chunk-Z2FX5GG4.js} +24 -12
  117. package/dist/chunk-ZNFBP5CQ.js +268 -0
  118. package/dist/{chunk-JQEAWWRP.js → chunk-ZPJOSHV7.js} +23 -12
  119. package/dist/{chunk-U2RBSUMY.js → chunk-ZU76OTV3.js} +2 -2
  120. package/dist/{collection-add-products-HCY2YT3W.js → collection-add-products-FWEVXBYC.js} +16 -9
  121. package/dist/{collection-detail-QAEPOJZX.js → collection-detail-U4AW4QJ3.js} +11 -12
  122. package/dist/{collection-list-AWLZYMWL.js → collection-list-PFXGNWL7.js} +15 -15
  123. package/dist/{collection-metadata-XM2EBCWF.js → collection-metadata-IKYBHHEU.js} +3 -3
  124. package/dist/{commission-rule-create-CDLLQIY4.js → commission-rule-create-QDNXXBTV.js} +64 -30
  125. package/dist/{commission-rule-detail-LFEZ5U6V.js → commission-rule-detail-QYJIK375.js} +3 -5
  126. package/dist/{commission-rule-edit-5CFKPI7U.js → commission-rule-edit-HICDPDLK.js} +58 -24
  127. package/dist/{commissions-list-MUKIEJWZ.js → commissions-list-AQUW636T.js} +6 -6
  128. package/dist/{customer-detail-XO7RBVUC.js → customer-detail-TBGKTNQQ.js} +9 -9
  129. package/dist/{customer-group-add-customers-XYWJSXKS.js → customer-group-add-customers-RWJOA2NJ.js} +3 -3
  130. package/dist/{customer-group-detail-4G53UKOS.js → customer-group-detail-47IPD337.js} +7 -8
  131. package/dist/{customer-group-list-5VA7HGD5.js → customer-group-list-Q2AYIVO4.js} +7 -8
  132. package/dist/{customer-group-metadata-FUJFFWCO.js → customer-group-metadata-T3WFBL7U.js} +3 -3
  133. package/dist/{customer-list-NEPELR3R.js → customer-list-JOPTF4QB.js} +5 -6
  134. package/dist/{customer-metadata-GWZC456X.js → customer-metadata-YSMWL4L3.js} +3 -3
  135. package/dist/{customers-add-customer-group-MYC76YGW.js → customers-add-customer-group-AVRYBS6Q.js} +14 -7
  136. package/dist/{edit-inventory-item-ZSV4WF6G.js → edit-inventory-item-7M7Q6HL4.js} +2 -2
  137. package/dist/{edit-inventory-item-attributes-NWSAQMKX.js → edit-inventory-item-attributes-E7J2WFPF.js} +2 -2
  138. package/dist/{edit-reservation-W3THLKKK.js → edit-reservation-S3QTQRPY.js} +11 -3
  139. package/dist/{edit-rules-RJC3AYJN.js → edit-rules-NRF7U4AT.js} +2 -2
  140. package/dist/extension-targets.d.ts +27 -0
  141. package/dist/home-4BDQXC4T.js +64 -0
  142. package/dist/index.css +226 -9
  143. package/dist/index.d.ts +10 -30
  144. package/dist/index.js +631 -3918
  145. package/dist/{inventory-detail-7HB5QEL4.js → inventory-detail-U6TRGZRY.js} +8 -8
  146. package/dist/{inventory-list-FN7FCI4W.js → inventory-list-JWA7U2LB.js} +4 -5
  147. package/dist/{inventory-metadata-FGHOW3YG.js → inventory-metadata-KO622YEI.js} +3 -3
  148. package/dist/{inventory-stock-PZ2ENOGF.js → inventory-stock-WWXYVFK2.js} +21 -11
  149. package/dist/{location-detail-B2BWLVAD.js → location-detail-27FBZML7.js} +5 -7
  150. package/dist/{location-fulfillment-providers-XIYMIEFN.js → location-fulfillment-providers-WT72L5JS.js} +21 -13
  151. package/dist/{location-list-VIAP63HV.js → location-list-RMHT36AO.js} +5 -7
  152. package/dist/{location-sales-channels-TNP3C7UW.js → location-sales-channels-JB5OIMXE.js} +13 -6
  153. package/dist/{location-service-zone-create-KPM4RSCF.js → location-service-zone-create-JKAKZCZ2.js} +3 -3
  154. package/dist/{location-service-zone-manage-areas-NW5JUTCH.js → location-service-zone-manage-areas-K2BMFI5Y.js} +3 -3
  155. package/dist/{location-service-zone-shipping-option-create-6O2JXV6I.js → location-service-zone-shipping-option-create-WJOLO6A3.js} +4 -4
  156. package/dist/{location-service-zone-shipping-option-edit-UUIR7B5S.js → location-service-zone-shipping-option-edit-I7BJGH76.js} +23 -10
  157. package/dist/{location-service-zone-shipping-option-pricing-Z5HCXRHG.js → location-service-zone-shipping-option-pricing-47Y3CP4U.js} +36 -12
  158. package/dist/{login-TZHRVYA5.js → login-ISNIWXU2.js} +3 -3
  159. package/dist/{manage-locations-ZFIRHMNH.js → manage-locations-5FKFNJQN.js} +158 -36
  160. package/dist/{marketplace-add-currencies-Z6FUIAU5.js → marketplace-add-currencies-34XKWMI7.js} +33 -9
  161. package/dist/{marketplace-detail-4IP5HIEW.js → marketplace-detail-A76FTENH.js} +7 -7
  162. package/dist/{marketplace-edit-G7YNGABC.js → marketplace-edit-KXKUECZQ.js} +61 -30
  163. package/dist/{marketplace-metadata-EGDXYKCE.js → marketplace-metadata-364KJG43.js} +3 -3
  164. package/dist/{offer-detail-page-WWEUCEFC.js → offer-detail-page-BDDDZSPL.js} +36 -13
  165. package/dist/{offer-variant-detail-page-FVJE5WLV.js → offer-variant-detail-page-HQU4HMZH.js} +4 -5
  166. package/dist/{offers-VG334CFD.js → offers-2JDCFVN4.js} +10 -11
  167. package/dist/{order-create-claim-4CIL76V5.js → order-create-claim-4ERPSGPD.js} +105 -61
  168. package/dist/{order-create-edit-BFE4N7RN.js → order-create-edit-BGLNMKKI.js} +17 -10
  169. package/dist/{order-create-exchange-CC7CQECO.js → order-create-exchange-TOPPZZGS.js} +107 -63
  170. package/dist/{order-create-refund-FJLL4CUD.js → order-create-refund-M3K5MZDM.js} +39 -24
  171. package/dist/{order-create-return-USO7AS7R.js → order-create-return-64GZ2LCL.js} +109 -70
  172. package/dist/{order-detail-3ODC5NOT.js → order-detail-DIUKR6ZJ.js} +9 -9
  173. package/dist/{order-edit-billing-address-SBVWRA25.js → order-edit-billing-address-ZAR5DETE.js} +3 -3
  174. package/dist/{order-edit-email-BREEW246.js → order-edit-email-V45SEUCO.js} +2 -2
  175. package/dist/{order-edit-shipping-address-XUG74AFY.js → order-edit-shipping-address-45Z6TNHL.js} +2 -2
  176. package/dist/{order-list-I6JZT6JK.js → order-list-KZHROLY3.js} +7 -7
  177. package/dist/{order-metadata-VIG5MGYV.js → order-metadata-7245QRUQ.js} +3 -3
  178. package/dist/{order-request-transfer-RYVK4WYW.js → order-request-transfer-JYPDXCY2.js} +28 -14
  179. package/dist/pages/index.d.ts +2 -2
  180. package/dist/pages/index.js +99 -98
  181. package/dist/{payout-list-WZ6QMJJY.js → payout-list-KILGQ4XP.js} +3 -3
  182. package/dist/{price-list-create-JFXLTNOJ.js → price-list-create-H3KJPUF4.js} +12 -12
  183. package/dist/{price-list-customer-availability-WU2OGO37.js → price-list-customer-availability-CQY55U4O.js} +31 -14
  184. package/dist/{price-list-detail-5YTX66KF.js → price-list-detail-I44VTKE6.js} +10 -11
  185. package/dist/{price-list-list-5CNSLAUF.js → price-list-list-TD5JIO7L.js} +5 -5
  186. package/dist/{price-list-prices-add-HVTEQOWQ.js → price-list-prices-add-XEJKCRTM.js} +11 -11
  187. package/dist/{price-list-prices-edit-OVHIDATP.js → price-list-prices-edit-WELHT4O4.js} +19 -10
  188. package/dist/{product-add-existing-attributes-2UFTXE2N.js → product-add-existing-attributes-5B6HD2M3.js} +10 -8
  189. package/dist/{product-create-SHIGHLQN.js → product-create-DTITIXGY.js} +12 -11
  190. package/dist/{product-create-attribute-QYRCPUFC.js → product-create-attribute-7TV3OHW7.js} +1 -1
  191. package/dist/{product-create-variant-MZLHG5JF.js → product-create-variant-S3UJRMMJ.js} +3 -3
  192. package/dist/{product-detail-UGSTCK7J.js → product-detail-2MYEE5AM.js} +9 -10
  193. package/dist/{product-edit-2CMVTDWT.js → product-edit-TAVV5CWR.js} +8 -3
  194. package/dist/{product-edit-attribute-W3AS47FM.js → product-edit-attribute-URHTZ2EQ.js} +9 -3
  195. package/dist/{product-list-XDJB3HX7.js → product-list-QYZXPM4I.js} +11 -12
  196. package/dist/{product-media-CO3F57JT.js → product-media-MFDAEXNQ.js} +3 -3
  197. package/dist/{product-metadata-5CRGB7TR.js → product-metadata-SC5BXN66.js} +3 -3
  198. package/dist/{product-organization-TNS7GBKN.js → product-organization-GCIGER6X.js} +87 -43
  199. package/dist/{product-sales-channels-PJNEIY4J.js → product-sales-channels-MNAFJKAI.js} +10 -5
  200. package/dist/{product-shipping-profile-SWB5FK7S.js → product-shipping-profile-G4NCDKSR.js} +25 -11
  201. package/dist/{product-tag-create-QORH6X2D.js → product-tag-create-PX7Q2AXU.js} +2 -2
  202. package/dist/{product-tag-detail-CDSYBTAM.js → product-tag-detail-4CGCZVSL.js} +18 -18
  203. package/dist/{product-tag-edit-JWYVCPCC.js → product-tag-edit-PXSZMCCT.js} +2 -2
  204. package/dist/{product-tag-list-RKLCU3UE.js → product-tag-list-2S6PHBIB.js} +18 -18
  205. package/dist/{product-tag-metadata-BCUPIIJ5.js → product-tag-metadata-2SO7ICOZ.js} +3 -3
  206. package/dist/{product-type-detail-IY7TWXUQ.js → product-type-detail-M4QLNFSG.js} +11 -12
  207. package/dist/{product-type-list-N3E5HQFW.js → product-type-list-JXU3446J.js} +5 -5
  208. package/dist/{product-type-metadata-DKBBQB6R.js → product-type-metadata-7D3J3NSO.js} +3 -3
  209. package/dist/{product-variant-detail-XHMS2UT5.js → product-variant-detail-VQ55W7PD.js} +4 -6
  210. package/dist/{product-variant-edit-4DPXTYPT.js → product-variant-edit-XEC7BR5G.js} +4 -4
  211. package/dist/{product-variant-metadata-ETVJBXSW.js → product-variant-metadata-KFLIOCU2.js} +3 -3
  212. package/dist/{profile-detail-KFLXUGQ5.js → profile-detail-SQZ6JFAN.js} +3 -5
  213. package/dist/{profile-edit-4FDALFG5.js → profile-edit-IVU3SBQA.js} +3 -3
  214. package/dist/{promotion-add-campaign-VAF3HTLK.js → promotion-add-campaign-SWTS4TM5.js} +2 -1
  215. package/dist/{promotion-create-7ZUJ4W2J.js → promotion-create-6TMK6PEP.js} +5 -4
  216. package/dist/{promotion-detail-SWO4PZDC.js → promotion-detail-YRWEIXY7.js} +7 -9
  217. package/dist/{promotion-list-S4B6SVD6.js → promotion-list-NFVGSR23.js} +9 -9
  218. package/dist/{refund-reason-create-P5FUFEGK.js → refund-reason-create-HZOBFOPB.js} +2 -2
  219. package/dist/{refund-reason-edit-AKOTWXCE.js → refund-reason-edit-KS6NMC22.js} +2 -2
  220. package/dist/{refund-reason-list-ABRFC3OQ.js → refund-reason-list-RL7WOHKC.js} +11 -12
  221. package/dist/{region-add-countries-4CTAVHYW.js → region-add-countries-47QLUMX7.js} +2 -2
  222. package/dist/{region-create-S2WUJ4RA.js → region-create-7DI3QEPU.js} +25 -11
  223. package/dist/{region-detail-IBLHFR57.js → region-detail-S5OT2PGL.js} +4 -5
  224. package/dist/{region-edit-NUMG2V5L.js → region-edit-IXCS3MRH.js} +32 -14
  225. package/dist/{region-list-JTR3SEWI.js → region-list-2MWAGD2D.js} +4 -5
  226. package/dist/{region-metadata-Q6HEMCHD.js → region-metadata-ADPG7OLJ.js} +3 -3
  227. package/dist/{reservation-create-H3T3AHTK.js → reservation-create-YEICXID2.js} +67 -44
  228. package/dist/{reservation-detail-5GYGVM3M.js → reservation-detail-EBIDXEVF.js} +4 -6
  229. package/dist/{reservation-list-VRRSKQ4W.js → reservation-list-5QNXC2WU.js} +4 -5
  230. package/dist/{reservation-metadata-P4G3JEDW.js → reservation-metadata-TWJE777O.js} +3 -3
  231. package/dist/{reset-password-VJY5CXJU.js → reset-password-FIZYJ2R4.js} +1 -1
  232. package/dist/{return-reason-list-6MQKG72S.js → return-reason-list-VDX6CFJL.js} +10 -10
  233. package/dist/{review-detail-K555FECH.js → review-detail-NPB3OKCE.js} +2 -4
  234. package/dist/{review-list-E56WE7VS.js → review-list-NXBVRP5T.js} +4 -5
  235. package/dist/{sales-channel-add-products-MPJ7UCEJ.js → sales-channel-add-products-MBSSIGYE.js} +19 -10
  236. package/dist/{sales-channel-detail-F37LBP6R.js → sales-channel-detail-R2BCF7TA.js} +11 -12
  237. package/dist/{sales-channel-list-XAWN5OKC.js → sales-channel-list-246V7NV3.js} +5 -7
  238. package/dist/{sales-channel-metadata-NBWFH4QX.js → sales-channel-metadata-PMLMQIKU.js} +3 -3
  239. package/dist/settings-XTXDKZEO.js +63 -0
  240. package/dist/{shipping-option-type-create-M23CI42D.js → shipping-option-type-create-NOFP2DOM.js} +2 -2
  241. package/dist/{shipping-option-type-detail-QIJZQ5WW.js → shipping-option-type-detail-47AZVCFP.js} +5 -7
  242. package/dist/{shipping-option-type-edit-WXTEQM32.js → shipping-option-type-edit-42JILKHX.js} +2 -2
  243. package/dist/{shipping-option-type-list-PRXZQSPR.js → shipping-option-type-list-TTAA63ZN.js} +8 -8
  244. package/dist/{shipping-profile-detail-KPRFJE4V.js → shipping-profile-detail-RGB67K3C.js} +2 -4
  245. package/dist/{shipping-profile-metadata-S7Z3IC6I.js → shipping-profile-metadata-GXMY5E57.js} +3 -3
  246. package/dist/{shipping-profiles-list-LK5ZXRJG.js → shipping-profiles-list-DD3G2THE.js} +4 -5
  247. package/dist/{store-bulk-edit-NBWZMDP7.js → store-bulk-edit-RRNJZEOU.js} +2 -2
  248. package/dist/{store-create-J4SL6SY3.js → store-create-UQ333C5F.js} +37 -15
  249. package/dist/{store-details-ITYKAZSI.js → store-details-D7RUCH5Y.js} +13 -14
  250. package/dist/{store-edit-NZMI7PNS.js → store-edit-RCNV5XI4.js} +3 -3
  251. package/dist/{store-list-RXPN3VVO.js → store-list-BMPOSAAE.js} +13 -14
  252. package/dist/{store-member-invite-IEUG54XA.js → store-member-invite-ALW6E3XA.js} +15 -6
  253. package/dist/{tax-region-create-PIDKQEWT.js → tax-region-create-3B6FWGWS.js} +3 -3
  254. package/dist/{tax-region-detail-7RNNZ4UE.js → tax-region-detail-PU4Q42KO.js} +8 -9
  255. package/dist/{tax-region-edit-I27QZZPB.js → tax-region-edit-P4L2CUFV.js} +2 -2
  256. package/dist/{tax-region-list-BXLYIYQT.js → tax-region-list-PUNXDH34.js} +5 -6
  257. package/dist/{tax-region-metadata-6YIZSRLO.js → tax-region-metadata-EDZ7YGYR.js} +3 -3
  258. package/dist/{tax-region-province-detail-AHS5SRP5.js → tax-region-province-detail-3ZQOCKZ2.js} +7 -8
  259. package/dist/{tax-region-tax-override-create-Z6S43XQ6.js → tax-region-tax-override-create-J5ZUAELL.js} +15 -15
  260. package/dist/{tax-region-tax-override-edit-4EOURL2M.js → tax-region-tax-override-edit-HDVKIL5P.js} +46 -26
  261. package/dist/{user-detail-5LOE6QGK.js → user-detail-4H37KBIP.js} +3 -5
  262. package/dist/{user-edit-O2M5II52.js → user-edit-42A2VX5E.js} +1 -1
  263. package/dist/{user-invite-SZIUG2WK.js → user-invite-5EJ3CIQZ.js} +35 -134
  264. package/dist/{user-list-6YRC6HYX.js → user-list-EZ56HFI3.js} +5 -6
  265. package/dist/{user-metadata-2PEU2IJE.js → user-metadata-3GENWLUS.js} +3 -3
  266. package/package.json +14 -14
  267. package/dist/chunk-4F6SHS7A.js +0 -83
  268. package/dist/chunk-BDGZ4EQO.js +0 -86
  269. package/dist/chunk-WMA3WTCM.js +0 -117
  270. package/dist/home-I3OILW5Z.js +0 -16
  271. package/dist/settings-AVE3VCCM.js +0 -19
  272. package/dist/{customer-edit-5EH2AUGN.js → customer-edit-LDKAXHZ6.js} +3 -3
  273. package/dist/{invite-6WUERQLW.js → invite-IZ2YTVPF.js} +1 -1
@@ -0,0 +1,2954 @@
1
+ import {
2
+ isClientError
3
+ } from "./chunk-C6SUTRP2.js";
4
+ import {
5
+ ConditionalTooltip
6
+ } from "./chunk-LAVHRER2.js";
7
+ import {
8
+ Thumbnail
9
+ } from "./chunk-U3I6S3RO.js";
10
+ import {
11
+ useProductTags
12
+ } from "./chunk-W5U6NPSN.js";
13
+ import {
14
+ useLogout
15
+ } from "./chunk-DSQRFZCO.js";
16
+ import {
17
+ useProductTypes
18
+ } from "./chunk-AEBQQ2EG.js";
19
+ import {
20
+ useMe
21
+ } from "./chunk-AZV22U4V.js";
22
+ import {
23
+ usePriceLists
24
+ } from "./chunk-56XMCNDS.js";
25
+ import {
26
+ useCollections
27
+ } from "./chunk-I4WBDDWN.js";
28
+ import {
29
+ useStore
30
+ } from "./chunk-3JN6NCCN.js";
31
+ import {
32
+ useCampaigns,
33
+ usePromotions
34
+ } from "./chunk-E5PC2WDZ.js";
35
+ import {
36
+ useStockLocations
37
+ } from "./chunk-H5E3CGD7.js";
38
+ import {
39
+ useOrders
40
+ } from "./chunk-DYCCRR7B.js";
41
+ import {
42
+ useCustomers
43
+ } from "./chunk-XWOFQSGH.js";
44
+ import {
45
+ useSellers
46
+ } from "./chunk-HRMANL53.js";
47
+ import {
48
+ useProductCategories
49
+ } from "./chunk-SQ7J4KTS.js";
50
+ import {
51
+ useDocumentDirection
52
+ } from "./chunk-Y7QKP6QU.js";
53
+ import {
54
+ Skeleton
55
+ } from "./chunk-INNFZYX2.js";
56
+ import {
57
+ useInventoryItems,
58
+ useProducts
59
+ } from "./chunk-Z476HUMI.js";
60
+ import {
61
+ queryClient
62
+ } from "./chunk-RHKRREUU.js";
63
+
64
+ // src/providers/theme-provider/theme-provider.tsx
65
+ import { useEffect, useState } from "react";
66
+
67
+ // src/providers/theme-provider/theme-context.tsx
68
+ import { createContext } from "react";
69
+ var ThemeContext = createContext(null);
70
+
71
+ // src/providers/theme-provider/theme-provider.tsx
72
+ import { jsx } from "react/jsx-runtime";
73
+ var THEME_KEY = "medusa_admin_theme";
74
+ function getDefaultValue() {
75
+ const persisted = localStorage?.getItem(THEME_KEY);
76
+ if (persisted) {
77
+ return persisted;
78
+ }
79
+ return "system";
80
+ }
81
+ function getThemeValue(selected) {
82
+ if (selected === "system") {
83
+ if (window !== void 0) {
84
+ return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
85
+ }
86
+ return "light";
87
+ }
88
+ return selected;
89
+ }
90
+ var ThemeProvider = ({ children }) => {
91
+ const [state, setState] = useState(getDefaultValue());
92
+ const [value, setValue] = useState(getThemeValue(state));
93
+ const setTheme = (theme) => {
94
+ localStorage.setItem(THEME_KEY, theme);
95
+ const themeValue = getThemeValue(theme);
96
+ setState(theme);
97
+ setValue(themeValue);
98
+ };
99
+ useEffect(() => {
100
+ const html = document.querySelector("html");
101
+ if (html) {
102
+ const css = document.createElement("style");
103
+ css.appendChild(
104
+ document.createTextNode(
105
+ `* {
106
+ -webkit-transition: none !important;
107
+ -moz-transition: none !important;
108
+ -o-transition: none !important;
109
+ -ms-transition: none !important;
110
+ transition: none !important;
111
+ }`
112
+ )
113
+ );
114
+ document.head.appendChild(css);
115
+ html.classList.remove(value === "light" ? "dark" : "light");
116
+ html.classList.add(value);
117
+ html.style.colorScheme = value;
118
+ void window.getComputedStyle(css).opacity;
119
+ document.head.removeChild(css);
120
+ }
121
+ }, [value]);
122
+ return /* @__PURE__ */ jsx(ThemeContext.Provider, { value: { theme: state, setTheme }, children });
123
+ };
124
+
125
+ // src/components/utilities/error-boundary/error-boundary.tsx
126
+ import { ExclamationCircle } from "@medusajs/icons";
127
+ import { Text } from "@medusajs/ui";
128
+ import { useTranslation } from "react-i18next";
129
+ import { Navigate, useLocation, useRouteError } from "react-router-dom";
130
+ import { jsx as jsx2, jsxs } from "react/jsx-runtime";
131
+ var ErrorBoundary = () => {
132
+ const error = useRouteError();
133
+ const location = useLocation();
134
+ const { t } = useTranslation();
135
+ let code = null;
136
+ if (isClientError(error)) {
137
+ if (error.status === 401) {
138
+ return /* @__PURE__ */ jsx2(Navigate, { to: "/login", state: { from: location }, replace: true });
139
+ }
140
+ code = error.status ?? null;
141
+ }
142
+ if (process.env.NODE_ENV === "development") {
143
+ console.error(error);
144
+ }
145
+ let title;
146
+ let message;
147
+ switch (code) {
148
+ case 400:
149
+ title = t("errorBoundary.badRequestTitle");
150
+ message = t("errorBoundary.badRequestMessage");
151
+ break;
152
+ case 404:
153
+ title = t("errorBoundary.notFoundTitle");
154
+ message = t("errorBoundary.notFoundMessage");
155
+ break;
156
+ case 500:
157
+ title = t("errorBoundary.internalServerErrorTitle");
158
+ message = t("errorBoundary.internalServerErrorMessage");
159
+ break;
160
+ default:
161
+ title = t("errorBoundary.defaultTitle");
162
+ message = t("errorBoundary.defaultMessage");
163
+ break;
164
+ }
165
+ return /* @__PURE__ */ jsx2("div", { className: "flex size-full min-h-[calc(100vh-57px-24px)] items-center justify-center", children: /* @__PURE__ */ jsx2("div", { className: "flex flex-col gap-y-6", children: /* @__PURE__ */ jsxs("div", { className: "text-ui-fg-subtle flex flex-col items-center gap-y-3", children: [
166
+ /* @__PURE__ */ jsx2(ExclamationCircle, {}),
167
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center gap-y-1", children: [
168
+ /* @__PURE__ */ jsx2(Text, { size: "small", leading: "compact", weight: "plus", children: title }),
169
+ /* @__PURE__ */ jsx2(
170
+ Text,
171
+ {
172
+ size: "small",
173
+ className: "text-ui-fg-muted text-balance text-center",
174
+ children: message
175
+ }
176
+ )
177
+ ] })
178
+ ] }) }) });
179
+ };
180
+
181
+ // src/utils/routes.ts
182
+ var createBranchRoute = (segment) => ({
183
+ path: segment,
184
+ children: []
185
+ });
186
+ var hoistBreadcrumb = (branch, handle, isIndex) => {
187
+ const branchHandle = branch.handle;
188
+ if (!isIndex || !handle?.breadcrumb || branchHandle?.breadcrumb) {
189
+ return handle;
190
+ }
191
+ branch.handle = { ...branchHandle, breadcrumb: handle.breadcrumb };
192
+ const { breadcrumb: _breadcrumb, ...rest } = handle;
193
+ return Object.keys(rest).length ? rest : void 0;
194
+ };
195
+ var createLeafRoute = (Component, loader, handle, path = "") => ({
196
+ path,
197
+ ErrorBoundary,
198
+ async lazy() {
199
+ const result = { Component };
200
+ if (loader) {
201
+ result.loader = loader;
202
+ }
203
+ if (handle) {
204
+ result.handle = handle;
205
+ }
206
+ return result;
207
+ }
208
+ });
209
+ var createParallelRoute = (path, Component, loader, handle) => ({
210
+ path,
211
+ async lazy() {
212
+ const result = { Component };
213
+ if (loader) {
214
+ result.loader = loader;
215
+ }
216
+ if (handle) {
217
+ result.handle = handle;
218
+ }
219
+ return result;
220
+ }
221
+ });
222
+ var processParallelRoutes = (parallelRoutes, currentFullPath) => {
223
+ return parallelRoutes?.map(({ path, Component, loader, handle }) => {
224
+ const childPath = path?.replace(currentFullPath, "").replace(/^\/+/, "");
225
+ if (!childPath) {
226
+ return null;
227
+ }
228
+ return createParallelRoute(childPath, Component, loader, handle);
229
+ }).filter(Boolean);
230
+ };
231
+ var addRoute = (pathSegments, Component, currentLevel, loader, handle, parallelRoutes, fullPath, componentPath) => {
232
+ if (!pathSegments.length) {
233
+ return;
234
+ }
235
+ const [currentSegment, ...remainingSegments] = pathSegments;
236
+ let route = currentLevel.find((r) => r.path === currentSegment);
237
+ if (!route) {
238
+ route = createBranchRoute(currentSegment);
239
+ currentLevel.push(route);
240
+ }
241
+ const currentFullPath = fullPath ? `${fullPath}/${currentSegment}` : currentSegment;
242
+ const isComponentSegment = currentFullPath === componentPath;
243
+ if (isComponentSegment || remainingSegments.length === 0) {
244
+ route.children || (route.children = []);
245
+ if (loader) {
246
+ route.loader = loader;
247
+ }
248
+ if (currentSegment === "*?" || currentSegment === "*") {
249
+ const leaf = createLeafRoute(Component, loader, handle, currentSegment);
250
+ leaf.children = processParallelRoutes(parallelRoutes, currentFullPath);
251
+ Object.assign(route, leaf);
252
+ } else {
253
+ const leafHandle = hoistBreadcrumb(route, handle, remainingSegments.length === 0);
254
+ const leaf = createLeafRoute(Component, loader, leafHandle);
255
+ leaf.children = processParallelRoutes(parallelRoutes, currentFullPath);
256
+ route.children.push(leaf);
257
+ }
258
+ if (remainingSegments.length > 0) {
259
+ addRoute(
260
+ remainingSegments,
261
+ Component,
262
+ route.children,
263
+ void 0,
264
+ void 0,
265
+ void 0,
266
+ currentFullPath
267
+ );
268
+ }
269
+ } else {
270
+ route.children || (route.children = []);
271
+ addRoute(
272
+ remainingSegments,
273
+ Component,
274
+ route.children,
275
+ loader,
276
+ handle,
277
+ parallelRoutes,
278
+ currentFullPath,
279
+ componentPath
280
+ );
281
+ }
282
+ };
283
+ var createRouteMap = (routes, ignore) => {
284
+ const root = [];
285
+ routes.forEach(({ path, Component, loader, handle, children }) => {
286
+ const cleanedPath = ignore ? path.replace(ignore, "").replace(/^\/+/, "") : path.replace(/^\/+/, "");
287
+ const pathSegments = cleanedPath.split("/").filter(Boolean);
288
+ addRoute(
289
+ pathSegments,
290
+ Component,
291
+ root,
292
+ loader,
293
+ handle,
294
+ children,
295
+ void 0,
296
+ path
297
+ );
298
+ });
299
+ return root;
300
+ };
301
+ var settingsRouteRegex = /^\/settings\//;
302
+ var getRoutesByType = (routes, type) => {
303
+ return routes.filter((route) => {
304
+ if (type === "public") {
305
+ return route.isPublic === true;
306
+ }
307
+ if (type === "settings") {
308
+ return !route.isPublic && settingsRouteRegex.test(route.path);
309
+ }
310
+ return !route.isPublic && !settingsRouteRegex.test(route.path);
311
+ });
312
+ };
313
+ var getMenuItemsByType = (menuItems, type) => {
314
+ return menuItems.filter((item) => {
315
+ if (item.nested) {
316
+ return false;
317
+ }
318
+ if (type === "settings") {
319
+ return settingsRouteRegex.test(item.path);
320
+ }
321
+ return !settingsRouteRegex.test(item.path);
322
+ });
323
+ };
324
+ var filterMenuItemsByPermissions = (menuItems, { hasAnyPermission, hasAllPermissions }) => {
325
+ return menuItems.filter((item) => {
326
+ if (!item.permissions?.length) {
327
+ return true;
328
+ }
329
+ return item.requireAll ? hasAllPermissions(item.permissions) : hasAnyPermission(item.permissions);
330
+ });
331
+ };
332
+ var getNestedMenuItems = (menuItems, parentPath) => {
333
+ return menuItems.filter((item) => item.nested === parentPath).sort((a, b) => (a.rank ?? 0) - (b.rank ?? 0));
334
+ };
335
+
336
+ // src/components/layout/main-layout/main-layout.tsx
337
+ import {
338
+ BuildingStorefront,
339
+ Buildings,
340
+ CogSixTooth,
341
+ CreditCardRefresh,
342
+ CurrencyDollar,
343
+ EllipsisHorizontal as EllipsisHorizontal2,
344
+ MagnifyingGlass as MagnifyingGlass2,
345
+ MinusMini,
346
+ OpenRectArrowOut as OpenRectArrowOut2,
347
+ ReceiptPercent,
348
+ ShoppingCart,
349
+ Tag,
350
+ Users
351
+ } from "@medusajs/icons";
352
+ import {
353
+ Avatar as Avatar2,
354
+ Divider,
355
+ DropdownMenu as DropdownMenu3,
356
+ IconButton as IconButton4,
357
+ Text as Text5,
358
+ clx as clx5
359
+ } from "@medusajs/ui";
360
+ import { Fragment as Fragment2, useMemo as useMemo4 } from "react";
361
+ import { Collapsible as RadixCollapsible2 } from "radix-ui";
362
+ import { useTranslation as useTranslation8 } from "react-i18next";
363
+ import { Link as Link3, useLocation as useLocation5, useNavigate as useNavigate4 } from "react-router-dom";
364
+
365
+ // src/providers/search-provider/search-provider.tsx
366
+ import { useEffect as useEffect5, useState as useState5 } from "react";
367
+
368
+ // src/components/search/search.tsx
369
+ import {
370
+ Badge,
371
+ Button,
372
+ clx,
373
+ DropdownMenu,
374
+ IconButton,
375
+ Kbd,
376
+ Text as Text2
377
+ } from "@medusajs/ui";
378
+ import { Command } from "cmdk";
379
+ import { Dialog as RadixDialog } from "radix-ui";
380
+ import {
381
+ Children,
382
+ forwardRef,
383
+ Fragment,
384
+ useCallback as useCallback4,
385
+ useEffect as useEffect4,
386
+ useImperativeHandle,
387
+ useMemo as useMemo2,
388
+ useRef,
389
+ useState as useState4
390
+ } from "react";
391
+ import { useTranslation as useTranslation4 } from "react-i18next";
392
+ import { useLocation as useLocation2, useNavigate as useNavigate2 } from "react-router-dom";
393
+ import {
394
+ ArrowUturnLeft,
395
+ MagnifyingGlass,
396
+ Plus,
397
+ Spinner,
398
+ TriangleDownMini
399
+ } from "@medusajs/icons";
400
+ import { matchSorter } from "match-sorter";
401
+
402
+ // src/components/search/constants.ts
403
+ var SEARCH_AREAS = [
404
+ "all",
405
+ "order",
406
+ "product",
407
+ "collection",
408
+ "category",
409
+ "inventory",
410
+ "customer",
411
+ "seller",
412
+ "promotion",
413
+ "campaign",
414
+ "priceList",
415
+ "productType",
416
+ "productTag",
417
+ "location",
418
+ "command",
419
+ "navigation"
420
+ ];
421
+ var SEARCH_AREA_PERMISSIONS = {
422
+ order: "orders",
423
+ product: "products",
424
+ collection: "product_collections",
425
+ category: "product_categories",
426
+ inventory: "inventory_items",
427
+ customer: "customers",
428
+ seller: "sellers",
429
+ promotion: "promotions",
430
+ campaign: "campaigns",
431
+ priceList: "price_lists",
432
+ productType: "product_types",
433
+ productTag: "product_tags",
434
+ location: "stock_locations"
435
+ };
436
+ var DEFAULT_SEARCH_LIMIT = 3;
437
+ var SEARCH_LIMIT_INCREMENT = 20;
438
+
439
+ // src/components/search/use-search-area-access.tsx
440
+ import { usePermissions } from "@mercurjs/dashboard-shared";
441
+ import { useCallback } from "react";
442
+ var useSearchAreaAccess = () => {
443
+ const { can } = usePermissions();
444
+ return useCallback(
445
+ (area) => {
446
+ const key = SEARCH_AREA_PERMISSIONS[area];
447
+ return !key || can(key, "view");
448
+ },
449
+ [can]
450
+ );
451
+ };
452
+
453
+ // src/components/search/use-search-results.tsx
454
+ import { keepPreviousData } from "@tanstack/react-query";
455
+ import { useCallback as useCallback3, useEffect as useEffect3, useMemo, useState as useState3 } from "react";
456
+ import { useTranslation as useTranslation3 } from "react-i18next";
457
+
458
+ // src/providers/keybind-provider/hooks.tsx
459
+ import { default as debounceFn } from "lodash.debounce";
460
+ import { useCallback as useCallback2, useContext, useEffect as useEffect2, useState as useState2 } from "react";
461
+ import { useTranslation as useTranslation2 } from "react-i18next";
462
+ import { useNavigate } from "react-router-dom";
463
+ import { PermissionsContext } from "@mercurjs/dashboard-shared";
464
+
465
+ // src/lib/permissions/can-reach-route.ts
466
+ import { isPermitted } from "@mercurjs/dashboard-shared";
467
+
468
+ // src/lib/permissions/route-permissions.ts
469
+ var ROUTE_PERMISSIONS = {
470
+ "/orders": "orders:view",
471
+ "/products": "products:view",
472
+ // An offer is always shown with its master product.
473
+ "/offers": ["offers:view", "products:view"],
474
+ "/collections": "product_collections:view",
475
+ "/categories": "product_categories:view",
476
+ "/inventory": "inventory_items:view",
477
+ "/reservations": "reservations:view",
478
+ "/customers": "customers:view",
479
+ "/customer-groups": "customer_groups:view",
480
+ "/promotions": "promotions:view",
481
+ "/campaigns": "campaigns:view",
482
+ "/price-lists": "price_lists:view",
483
+ "/stores": "sellers:view",
484
+ "/reviews": "reviews:view",
485
+ "/payouts": "payouts:view",
486
+ "/settings/regions": "regions:view",
487
+ "/settings/marketplace": "store:view",
488
+ "/settings/commissions": "commission_rates:view",
489
+ "/settings/users": "users:view",
490
+ "/settings/sales-channels": "sales_channels:view",
491
+ "/settings/locations": "stock_locations:view",
492
+ "/settings/product-tags": "product_tags:view",
493
+ "/settings/product-types": "product_types:view",
494
+ "/settings/attributes": "product_attributes:view",
495
+ "/settings/shipping-profiles": "shipping_profiles:view",
496
+ "/settings/shipping-option-types": "shipping_options:view",
497
+ "/settings/return-reasons": "return_reasons:view",
498
+ "/settings/refund-reasons": "refund_reasons:view",
499
+ "/settings/tax-regions": "tax_regions:view",
500
+ "/settings/publishable-api-keys": "api_keys:view",
501
+ "/settings/secret-api-keys": "api_keys:view"
502
+ };
503
+ var getRoutePermission = (path) => ROUTE_PERMISSIONS[path];
504
+
505
+ // src/lib/permissions/can-reach-route.ts
506
+ var canReachRoute = (checks, path) => isPermitted(checks, getRoutePermission(path), true);
507
+
508
+ // src/providers/keybind-provider/keybind-context.tsx
509
+ import { createContext as createContext2 } from "react";
510
+ var KeybindContext = createContext2(null);
511
+
512
+ // src/providers/keybind-provider/utils.ts
513
+ var findFirstPlatformMatch = (keys) => {
514
+ const match = Object.entries(keys).filter(
515
+ ([, value]) => value.length > 0
516
+ )[0] ?? [];
517
+ return match.length ? {
518
+ platform: match[0],
519
+ keys: match[1]
520
+ } : null;
521
+ };
522
+ var getShortcutKeys = (shortcut) => {
523
+ const platform = "Mac";
524
+ const keys = shortcut.keys[platform];
525
+ if (!keys) {
526
+ const defaultPlatform = findFirstPlatformMatch(shortcut.keys);
527
+ console.warn(
528
+ `No keys found for platform "${platform}" in "${shortcut.label}" ${defaultPlatform ? `using keys for platform "${defaultPlatform.platform}"` : ""}`
529
+ );
530
+ return defaultPlatform ? defaultPlatform.keys : [];
531
+ }
532
+ return keys;
533
+ };
534
+ var keysMatch = (keys1, keys2) => {
535
+ return keys1.length === keys2.length && keys1.every(
536
+ (key, index) => key.toLowerCase() === keys2[index].toLowerCase()
537
+ );
538
+ };
539
+ var findShortcutIndex = (shortcuts, keys) => {
540
+ if (!keys.length) {
541
+ return -1;
542
+ }
543
+ let index = 0;
544
+ for (const shortcut of shortcuts) {
545
+ const shortcutKeys = getShortcutKeys(shortcut);
546
+ if (keysMatch(shortcutKeys, keys)) {
547
+ return index;
548
+ }
549
+ index++;
550
+ }
551
+ return -1;
552
+ };
553
+ var findShortcut = (shortcuts, keys) => {
554
+ const shortcutIndex = findShortcutIndex(shortcuts, keys);
555
+ return shortcutIndex > -1 ? shortcuts[shortcutIndex] : null;
556
+ };
557
+ var getShortcutWithDefaultValues = (shortcut, platform = "Mac") => {
558
+ const platforms = ["Mac", "Windows", "Linux"];
559
+ const defaultKeys = Object.values(shortcut.keys)[0] ?? shortcut.keys[platform];
560
+ const keys = platforms.reduce((acc, curr) => {
561
+ return {
562
+ ...acc,
563
+ [curr]: shortcut.keys[curr] ?? defaultKeys
564
+ };
565
+ }, {});
566
+ return {
567
+ ...shortcut,
568
+ keys,
569
+ _defaultKeys: shortcut.keys
570
+ };
571
+ };
572
+
573
+ // src/providers/keybind-provider/hooks.tsx
574
+ var useShortcuts = ({
575
+ shortcuts = [],
576
+ debounce
577
+ }) => {
578
+ const [keys, setKeys] = useState2([]);
579
+ const navigate = useNavigate();
580
+ const removeKeys = useCallback2(
581
+ debounceFn(() => setKeys([]), debounce),
582
+ []
583
+ );
584
+ const invokeShortcut = useCallback2(
585
+ debounceFn((shortcut) => {
586
+ if (shortcut && shortcut.callback) {
587
+ shortcut.callback();
588
+ setKeys([]);
589
+ return;
590
+ }
591
+ if (shortcut && shortcut.to) {
592
+ navigate(shortcut.to);
593
+ setKeys([]);
594
+ return;
595
+ }
596
+ }, debounce / 2),
597
+ []
598
+ );
599
+ useEffect2(() => {
600
+ if (keys.length > 0 && shortcuts.length > 0) {
601
+ const shortcut = findShortcut(shortcuts, keys);
602
+ invokeShortcut(shortcut);
603
+ }
604
+ return () => invokeShortcut.cancel();
605
+ }, [keys, shortcuts, invokeShortcut]);
606
+ useEffect2(() => {
607
+ const listener = (event) => {
608
+ const target = event.target;
609
+ if (target.tagName === "INPUT" || target.tagName === "TEXTAREA" || target.contentEditable === "true") {
610
+ removeKeys();
611
+ return;
612
+ }
613
+ setKeys((oldKeys) => [...oldKeys, event.key]);
614
+ removeKeys();
615
+ };
616
+ window.addEventListener("keydown", listener);
617
+ return () => {
618
+ window.removeEventListener("keydown", listener);
619
+ };
620
+ }, [removeKeys]);
621
+ };
622
+ var useGlobalShortcuts = () => {
623
+ const { t } = useTranslation2();
624
+ const navigate = useNavigate();
625
+ const { mutateAsync } = useLogout();
626
+ const permissions = useContext(PermissionsContext);
627
+ const handleLogout = async () => {
628
+ await mutateAsync(void 0, {
629
+ onSuccess: () => {
630
+ queryClient.clear();
631
+ navigate("/login");
632
+ }
633
+ });
634
+ };
635
+ const globalShortcuts = [
636
+ // Pages
637
+ {
638
+ keys: {
639
+ Mac: ["G", "O"]
640
+ },
641
+ label: t("app.keyboardShortcuts.navigation.goToOrders"),
642
+ type: "pageShortcut",
643
+ to: "/orders"
644
+ },
645
+ {
646
+ keys: {
647
+ Mac: ["G", "P"]
648
+ },
649
+ label: t("app.keyboardShortcuts.navigation.goToProducts"),
650
+ type: "pageShortcut",
651
+ to: "/products"
652
+ },
653
+ {
654
+ keys: {
655
+ Mac: ["G", "C"]
656
+ },
657
+ label: t("app.keyboardShortcuts.navigation.goToCollections"),
658
+ type: "pageShortcut",
659
+ to: "/collections"
660
+ },
661
+ {
662
+ keys: {
663
+ Mac: ["G", "A"]
664
+ },
665
+ label: t("app.keyboardShortcuts.navigation.goToCategories"),
666
+ type: "pageShortcut",
667
+ to: "/categories"
668
+ },
669
+ {
670
+ keys: {
671
+ Mac: ["G", "U"]
672
+ },
673
+ label: t("app.keyboardShortcuts.navigation.goToCustomers"),
674
+ type: "pageShortcut",
675
+ to: "/customers"
676
+ },
677
+ {
678
+ keys: {
679
+ Mac: ["G", "I"]
680
+ },
681
+ label: t("app.keyboardShortcuts.navigation.goToInventory"),
682
+ type: "pageShortcut",
683
+ to: "/inventory"
684
+ },
685
+ {
686
+ keys: {
687
+ Mac: ["G", "L"]
688
+ },
689
+ label: t("app.keyboardShortcuts.navigation.goToPriceLists"),
690
+ type: "pageShortcut",
691
+ to: "/price-lists"
692
+ },
693
+ {
694
+ keys: {
695
+ Mac: ["G", "M"]
696
+ },
697
+ label: t("app.keyboardShortcuts.navigation.goToPromotions"),
698
+ type: "pageShortcut",
699
+ to: "/promotions"
700
+ },
701
+ {
702
+ keys: {
703
+ Mac: ["G", "K"]
704
+ },
705
+ label: t("app.keyboardShortcuts.navigation.goToCampaigns"),
706
+ type: "pageShortcut",
707
+ to: "/campaigns"
708
+ },
709
+ {
710
+ keys: {
711
+ Mac: ["G", "S"]
712
+ },
713
+ label: t("app.keyboardShortcuts.navigation.goToSellers"),
714
+ type: "pageShortcut",
715
+ to: "/stores"
716
+ },
717
+ {
718
+ keys: {
719
+ Mac: ["G", "Y"]
720
+ },
721
+ label: t("app.keyboardShortcuts.navigation.goToPayouts"),
722
+ type: "pageShortcut",
723
+ to: "/payouts"
724
+ },
725
+ // Settings
726
+ {
727
+ keys: {
728
+ Mac: ["G", ","]
729
+ },
730
+ label: t("app.keyboardShortcuts.settings.goToSettings"),
731
+ type: "settingShortcut",
732
+ to: "/settings"
733
+ },
734
+ {
735
+ keys: {
736
+ Mac: ["G", ",", "P"]
737
+ },
738
+ label: t("app.keyboardShortcuts.settings.goToProductTypes"),
739
+ type: "settingShortcut",
740
+ to: "/settings/product-types"
741
+ },
742
+ {
743
+ keys: {
744
+ Mac: ["G", ",", "L"]
745
+ },
746
+ label: t("app.keyboardShortcuts.settings.goToLocations"),
747
+ type: "settingShortcut",
748
+ to: "/settings/locations"
749
+ },
750
+ // Commands
751
+ {
752
+ keys: {
753
+ Mac: ["B", "Y", "E"]
754
+ },
755
+ label: t("actions.logout"),
756
+ type: "commandShortcut",
757
+ callback: () => handleLogout()
758
+ }
759
+ ];
760
+ return globalShortcuts.filter(
761
+ (shortcut) => !shortcut.to || canReachRoute(permissions, shortcut.to)
762
+ );
763
+ };
764
+
765
+ // src/components/search/use-search-results.tsx
766
+ var useSearchResults = ({
767
+ q,
768
+ limit,
769
+ area = "all"
770
+ }) => {
771
+ const staticResults = useStaticSearchResults(area);
772
+ const { dynamicResults, isFetching } = useDynamicSearchResults(area, limit, q);
773
+ return {
774
+ staticResults,
775
+ dynamicResults,
776
+ isFetching
777
+ };
778
+ };
779
+ var useStaticSearchResults = (currentArea) => {
780
+ const globalCommands = useGlobalShortcuts();
781
+ const results = useMemo(() => {
782
+ const groups = /* @__PURE__ */ new Map();
783
+ globalCommands.forEach((command) => {
784
+ const group = groups.get(command.type) || [];
785
+ group.push(command);
786
+ groups.set(command.type, group);
787
+ });
788
+ let filteredGroups;
789
+ switch (currentArea) {
790
+ case "all":
791
+ filteredGroups = Array.from(groups);
792
+ break;
793
+ case "navigation":
794
+ filteredGroups = Array.from(groups).filter(
795
+ ([type]) => type === "pageShortcut" || type === "settingShortcut"
796
+ );
797
+ break;
798
+ case "command":
799
+ filteredGroups = Array.from(groups).filter(
800
+ ([type]) => type === "commandShortcut"
801
+ );
802
+ break;
803
+ default:
804
+ filteredGroups = [];
805
+ }
806
+ return filteredGroups.map(([title, items]) => ({
807
+ title,
808
+ items
809
+ }));
810
+ }, [globalCommands, currentArea]);
811
+ return results;
812
+ };
813
+ var useDynamicSearchResults = (currentArea, limit, q) => {
814
+ const { t } = useTranslation3();
815
+ const debouncedSearch = useDebouncedSearch(q, 300);
816
+ const { open } = useSearch();
817
+ const canSearchArea = useSearchAreaAccess();
818
+ const isQueryEnabled = (area) => open && Boolean(debouncedSearch) && isAreaEnabled(currentArea, area) && canSearchArea(area);
819
+ const orderResponse = useOrders(
820
+ {
821
+ q: debouncedSearch?.replace(/^#/, ""),
822
+ // Since we display the ID with a # prefix, it's natural for the user to include it in the search. This will however cause no results to be returned, so we remove the # prefix from the search query.
823
+ limit,
824
+ fields: "id,display_id,email"
825
+ },
826
+ {
827
+ enabled: isQueryEnabled("order"),
828
+ placeholderData: keepPreviousData
829
+ }
830
+ );
831
+ const productResponse = useProducts(
832
+ {
833
+ q: debouncedSearch,
834
+ limit,
835
+ // TODO: Remove exclusion once we avoid including unnecessary relations by default in the query config
836
+ fields: "id,title,thumbnail,-type,-collection,-options,-tags,-images,-variants,-sales_channels"
837
+ },
838
+ {
839
+ enabled: isQueryEnabled("product"),
840
+ placeholderData: keepPreviousData
841
+ }
842
+ );
843
+ const categoryResponse = useProductCategories(
844
+ {
845
+ // TODO: Remove the OR condition once the list endpoint does not throw when q equals an empty string
846
+ q: debouncedSearch || void 0,
847
+ limit,
848
+ fields: "id,name"
849
+ },
850
+ {
851
+ enabled: isQueryEnabled("category"),
852
+ placeholderData: keepPreviousData
853
+ }
854
+ );
855
+ const collectionResponse = useCollections(
856
+ {
857
+ q: debouncedSearch,
858
+ limit,
859
+ fields: "id,title"
860
+ },
861
+ {
862
+ enabled: isQueryEnabled("collection"),
863
+ placeholderData: keepPreviousData
864
+ }
865
+ );
866
+ const customerResponse = useCustomers(
867
+ {
868
+ q: debouncedSearch,
869
+ limit,
870
+ fields: "id,email,first_name,last_name"
871
+ },
872
+ {
873
+ enabled: isQueryEnabled("customer"),
874
+ placeholderData: keepPreviousData
875
+ }
876
+ );
877
+ const sellerResponse = useSellers(
878
+ {
879
+ q: debouncedSearch,
880
+ limit,
881
+ fields: "id,name"
882
+ },
883
+ {
884
+ enabled: isQueryEnabled("seller"),
885
+ placeholderData: keepPreviousData
886
+ }
887
+ );
888
+ const inventoryResponse = useInventoryItems(
889
+ {
890
+ q: debouncedSearch,
891
+ limit,
892
+ fields: "id,title,sku"
893
+ },
894
+ {
895
+ enabled: isQueryEnabled("inventory"),
896
+ placeholderData: keepPreviousData
897
+ }
898
+ );
899
+ const promotionResponse = usePromotions(
900
+ {
901
+ q: debouncedSearch,
902
+ limit,
903
+ fields: "id,code,status"
904
+ },
905
+ {
906
+ enabled: isQueryEnabled("promotion"),
907
+ placeholderData: keepPreviousData
908
+ }
909
+ );
910
+ const campaignResponse = useCampaigns(
911
+ {
912
+ q: debouncedSearch,
913
+ limit,
914
+ fields: "id,name"
915
+ },
916
+ {
917
+ enabled: isQueryEnabled("campaign"),
918
+ placeholderData: keepPreviousData
919
+ }
920
+ );
921
+ const priceListResponse = usePriceLists(
922
+ {
923
+ q: debouncedSearch,
924
+ limit,
925
+ fields: "id,title"
926
+ },
927
+ {
928
+ enabled: isQueryEnabled("priceList"),
929
+ placeholderData: keepPreviousData
930
+ }
931
+ );
932
+ const productTypeResponse = useProductTypes(
933
+ {
934
+ q: debouncedSearch,
935
+ limit,
936
+ fields: "id,value"
937
+ },
938
+ {
939
+ enabled: isQueryEnabled("productType"),
940
+ placeholderData: keepPreviousData
941
+ }
942
+ );
943
+ const productTagResponse = useProductTags(
944
+ {
945
+ q: debouncedSearch,
946
+ limit,
947
+ fields: "id,value"
948
+ },
949
+ {
950
+ enabled: isQueryEnabled("productTag"),
951
+ placeholderData: keepPreviousData
952
+ }
953
+ );
954
+ const locationResponse = useStockLocations(
955
+ {
956
+ q: debouncedSearch,
957
+ limit,
958
+ fields: "id,name"
959
+ },
960
+ {
961
+ enabled: isQueryEnabled("location"),
962
+ placeholderData: keepPreviousData
963
+ }
964
+ );
965
+ const responseMap = useMemo(
966
+ () => ({
967
+ order: orderResponse,
968
+ product: productResponse,
969
+ collection: collectionResponse,
970
+ category: categoryResponse,
971
+ inventory: inventoryResponse,
972
+ customer: customerResponse,
973
+ seller: sellerResponse,
974
+ promotion: promotionResponse,
975
+ campaign: campaignResponse,
976
+ priceList: priceListResponse,
977
+ productType: productTypeResponse,
978
+ productTag: productTagResponse,
979
+ location: locationResponse
980
+ }),
981
+ [
982
+ orderResponse,
983
+ productResponse,
984
+ inventoryResponse,
985
+ categoryResponse,
986
+ collectionResponse,
987
+ customerResponse,
988
+ sellerResponse,
989
+ promotionResponse,
990
+ campaignResponse,
991
+ priceListResponse,
992
+ productTypeResponse,
993
+ productTagResponse,
994
+ locationResponse
995
+ ]
996
+ );
997
+ const results = useMemo(() => {
998
+ const groups = Object.entries(responseMap).map(([key, response]) => {
999
+ const area = key;
1000
+ if (canSearchArea(area) && (isAreaEnabled(currentArea, area) || currentArea === "all")) {
1001
+ return transformDynamicSearchResults(area, limit, t, response);
1002
+ }
1003
+ return null;
1004
+ }).filter(Boolean);
1005
+ return groups;
1006
+ }, [responseMap, currentArea, limit, t, canSearchArea]);
1007
+ const isAreaFetching = useCallback3(
1008
+ (area) => {
1009
+ if (area === "all") {
1010
+ return Object.values(responseMap).some(
1011
+ (response) => response.isFetching
1012
+ );
1013
+ }
1014
+ return isAreaEnabled(currentArea, area) && responseMap[area]?.isFetching;
1015
+ },
1016
+ [currentArea, responseMap]
1017
+ );
1018
+ const isFetching = useMemo(() => {
1019
+ return isAreaFetching(currentArea);
1020
+ }, [currentArea, isAreaFetching]);
1021
+ const dynamicResults = q ? results.filter(
1022
+ (group) => !!group && group.items.length > 0
1023
+ ) : [];
1024
+ return {
1025
+ dynamicResults,
1026
+ isFetching
1027
+ };
1028
+ };
1029
+ var useDebouncedSearch = (value, delay) => {
1030
+ const [debouncedValue, setDebouncedValue] = useState3(value);
1031
+ useEffect3(() => {
1032
+ const handler = setTimeout(() => {
1033
+ setDebouncedValue(value);
1034
+ }, delay);
1035
+ return () => {
1036
+ clearTimeout(handler);
1037
+ };
1038
+ }, [value, delay]);
1039
+ return debouncedValue;
1040
+ };
1041
+ function isAreaEnabled(area, currentArea) {
1042
+ if (area === "all") {
1043
+ return true;
1044
+ }
1045
+ if (area === currentArea) {
1046
+ return true;
1047
+ }
1048
+ return false;
1049
+ }
1050
+ var transformMap = {
1051
+ order: {
1052
+ dataKey: "orders",
1053
+ transform: (order) => ({
1054
+ id: order.id,
1055
+ title: `#${order.display_id}`,
1056
+ subtitle: order.email ?? void 0,
1057
+ to: `/orders/${order.id}`,
1058
+ value: `order:${order.id}`
1059
+ })
1060
+ },
1061
+ product: {
1062
+ dataKey: "products",
1063
+ transform: (product) => ({
1064
+ id: product.id,
1065
+ title: product.title,
1066
+ to: `/products/${product.id}`,
1067
+ thumbnail: product.thumbnail ?? void 0,
1068
+ value: `product:${product.id}`
1069
+ })
1070
+ },
1071
+ category: {
1072
+ dataKey: "product_categories",
1073
+ transform: (category) => ({
1074
+ id: category.id,
1075
+ title: category.name,
1076
+ to: `/categories/${category.id}`,
1077
+ value: `category:${category.id}`
1078
+ })
1079
+ },
1080
+ inventory: {
1081
+ dataKey: "inventory_items",
1082
+ transform: (inventory) => ({
1083
+ id: inventory.id,
1084
+ title: inventory.title ?? "",
1085
+ subtitle: inventory.sku ?? void 0,
1086
+ to: `/inventory/${inventory.id}`,
1087
+ value: `inventory:${inventory.id}`
1088
+ })
1089
+ },
1090
+ customer: {
1091
+ dataKey: "customers",
1092
+ transform: (customer) => {
1093
+ const name = [customer.first_name, customer.last_name].filter(Boolean).join(" ");
1094
+ return {
1095
+ id: customer.id,
1096
+ title: name || customer.email,
1097
+ subtitle: name ? customer.email : void 0,
1098
+ to: `/customers/${customer.id}`,
1099
+ value: `customer:${customer.id}`
1100
+ };
1101
+ }
1102
+ },
1103
+ seller: {
1104
+ dataKey: "sellers",
1105
+ transform: (seller) => ({
1106
+ id: seller.id,
1107
+ title: seller.name,
1108
+ to: `/stores/${seller.id}`,
1109
+ value: `seller:${seller.id}`
1110
+ })
1111
+ },
1112
+ collection: {
1113
+ dataKey: "collections",
1114
+ transform: (collection) => ({
1115
+ id: collection.id,
1116
+ title: collection.title,
1117
+ to: `/collections/${collection.id}`,
1118
+ value: `collection:${collection.id}`
1119
+ })
1120
+ },
1121
+ promotion: {
1122
+ dataKey: "promotions",
1123
+ transform: (promotion) => ({
1124
+ id: promotion.id,
1125
+ title: promotion.code,
1126
+ to: `/promotions/${promotion.id}`,
1127
+ value: `promotion:${promotion.id}`
1128
+ })
1129
+ },
1130
+ campaign: {
1131
+ dataKey: "campaigns",
1132
+ transform: (campaign) => ({
1133
+ id: campaign.id,
1134
+ title: campaign.name,
1135
+ to: `/campaigns/${campaign.id}`,
1136
+ value: `campaign:${campaign.id}`
1137
+ })
1138
+ },
1139
+ priceList: {
1140
+ dataKey: "price_lists",
1141
+ transform: (priceList) => ({
1142
+ id: priceList.id,
1143
+ title: priceList.title,
1144
+ to: `/price-lists/${priceList.id}`,
1145
+ value: `priceList:${priceList.id}`
1146
+ })
1147
+ },
1148
+ productType: {
1149
+ dataKey: "product_types",
1150
+ transform: (productType) => ({
1151
+ id: productType.id,
1152
+ title: productType.value,
1153
+ to: `/product-types/${productType.id}`,
1154
+ value: `productType:${productType.id}`
1155
+ })
1156
+ },
1157
+ productTag: {
1158
+ dataKey: "product_tags",
1159
+ transform: (productTag) => ({
1160
+ id: productTag.id,
1161
+ title: productTag.value,
1162
+ to: `/product-tags/${productTag.id}`,
1163
+ value: `productTag:${productTag.id}`
1164
+ })
1165
+ },
1166
+ location: {
1167
+ dataKey: "stock_locations",
1168
+ transform: (location) => ({
1169
+ id: location.id,
1170
+ title: location.name,
1171
+ to: `/locations/${location.id}`,
1172
+ value: `location:${location.id}`
1173
+ })
1174
+ }
1175
+ };
1176
+ function transformDynamicSearchResults(type, limit, t, response) {
1177
+ if (!response || !transformMap[type]) {
1178
+ return void 0;
1179
+ }
1180
+ const { dataKey, transform } = transformMap[type];
1181
+ const data = response[dataKey];
1182
+ if (!data || !Array.isArray(data)) {
1183
+ return void 0;
1184
+ }
1185
+ return {
1186
+ title: t(`app.search.groups.${type}`),
1187
+ area: type,
1188
+ hasMore: response.count > limit,
1189
+ count: response.count,
1190
+ items: data.map(transform)
1191
+ };
1192
+ }
1193
+
1194
+ // src/components/search/search.tsx
1195
+ import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
1196
+ var Search = () => {
1197
+ const [area, setArea] = useState4("all");
1198
+ const [search, setSearch] = useState4("");
1199
+ const [limit, setLimit] = useState4(DEFAULT_SEARCH_LIMIT);
1200
+ const { open, onOpenChange } = useSearch();
1201
+ const location = useLocation2();
1202
+ const { t } = useTranslation4();
1203
+ const navigate = useNavigate2();
1204
+ const inputRef = useRef(null);
1205
+ const listRef = useRef(null);
1206
+ const { staticResults, dynamicResults, isFetching } = useSearchResults({
1207
+ area,
1208
+ limit,
1209
+ q: search
1210
+ });
1211
+ const handleReset = useCallback4(() => {
1212
+ setArea("all");
1213
+ setSearch("");
1214
+ setLimit(DEFAULT_SEARCH_LIMIT);
1215
+ }, [setLimit]);
1216
+ const handleBack = () => {
1217
+ handleReset();
1218
+ inputRef.current?.focus();
1219
+ };
1220
+ const handleOpenChange = useCallback4(
1221
+ (open2) => {
1222
+ if (!open2) {
1223
+ handleReset();
1224
+ }
1225
+ onOpenChange(open2);
1226
+ },
1227
+ [onOpenChange, handleReset]
1228
+ );
1229
+ useEffect4(() => {
1230
+ handleOpenChange(false);
1231
+ }, [location.pathname, handleOpenChange]);
1232
+ const handleSelect = (item) => {
1233
+ handleOpenChange(false);
1234
+ if (item.to) {
1235
+ navigate(item.to);
1236
+ return;
1237
+ }
1238
+ if (item.callback) {
1239
+ item.callback();
1240
+ return;
1241
+ }
1242
+ };
1243
+ const handleShowMore = (area2) => {
1244
+ if (area2 === "all") {
1245
+ setLimit(DEFAULT_SEARCH_LIMIT);
1246
+ } else {
1247
+ setLimit(SEARCH_LIMIT_INCREMENT);
1248
+ }
1249
+ setArea(area2);
1250
+ inputRef.current?.focus();
1251
+ };
1252
+ const handleLoadMore = () => {
1253
+ setLimit((l) => l + SEARCH_LIMIT_INCREMENT);
1254
+ };
1255
+ const filteredStaticResults = useMemo2(() => {
1256
+ const filteredResults = [];
1257
+ staticResults.forEach((group) => {
1258
+ const filteredItems = matchSorter(group.items, search, {
1259
+ keys: ["label"]
1260
+ });
1261
+ if (filteredItems.length === 0) {
1262
+ return;
1263
+ }
1264
+ filteredResults.push({
1265
+ ...group,
1266
+ items: filteredItems
1267
+ });
1268
+ });
1269
+ return filteredResults;
1270
+ }, [staticResults, search]);
1271
+ const handleSearch = (q) => {
1272
+ setSearch(q);
1273
+ listRef.current?.scrollTo({ top: 0 });
1274
+ };
1275
+ const showLoading = useMemo2(() => {
1276
+ return isFetching && !dynamicResults.length && !filteredStaticResults.length;
1277
+ }, [isFetching, dynamicResults, filteredStaticResults]);
1278
+ return /* @__PURE__ */ jsxs2(CommandDialog, { open, onOpenChange: handleOpenChange, children: [
1279
+ /* @__PURE__ */ jsx3(
1280
+ CommandInput,
1281
+ {
1282
+ isFetching,
1283
+ ref: inputRef,
1284
+ area,
1285
+ setArea,
1286
+ value: search,
1287
+ onValueChange: handleSearch,
1288
+ onBack: area !== "all" ? handleBack : void 0,
1289
+ placeholder: t("app.search.placeholder")
1290
+ }
1291
+ ),
1292
+ /* @__PURE__ */ jsxs2(CommandList, { ref: listRef, children: [
1293
+ showLoading && /* @__PURE__ */ jsx3(CommandLoading, {}),
1294
+ dynamicResults.map((group) => {
1295
+ return /* @__PURE__ */ jsxs2(CommandGroup, { heading: group.title, children: [
1296
+ group.items.map((item) => {
1297
+ return /* @__PURE__ */ jsx3(
1298
+ CommandItem,
1299
+ {
1300
+ onSelect: () => handleSelect(item),
1301
+ value: item.value,
1302
+ className: "flex items-center justify-between",
1303
+ children: /* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-x-3", children: [
1304
+ item.thumbnail && /* @__PURE__ */ jsx3(
1305
+ Thumbnail,
1306
+ {
1307
+ alt: item.title,
1308
+ src: item.thumbnail,
1309
+ size: "small"
1310
+ }
1311
+ ),
1312
+ /* @__PURE__ */ jsx3("span", { children: item.title }),
1313
+ item.subtitle && /* @__PURE__ */ jsx3("span", { className: "text-ui-fg-muted", children: item.subtitle })
1314
+ ] })
1315
+ },
1316
+ item.id
1317
+ );
1318
+ }),
1319
+ group.hasMore && area === "all" && /* @__PURE__ */ jsx3(
1320
+ CommandItem,
1321
+ {
1322
+ onSelect: () => handleShowMore(group.area),
1323
+ hidden: true,
1324
+ value: `${group.title}:show:more`,
1325
+ children: /* @__PURE__ */ jsxs2("div", { className: "text-ui-fg-muted flex items-center gap-x-3", children: [
1326
+ /* @__PURE__ */ jsx3(Plus, {}),
1327
+ /* @__PURE__ */ jsx3(Text2, { size: "small", leading: "compact", weight: "plus", children: t("app.search.showMore") })
1328
+ ] })
1329
+ }
1330
+ ),
1331
+ group.hasMore && area === group.area && /* @__PURE__ */ jsx3(
1332
+ CommandItem,
1333
+ {
1334
+ onSelect: handleLoadMore,
1335
+ hidden: true,
1336
+ value: `${group.title}:load:more`,
1337
+ children: /* @__PURE__ */ jsxs2("div", { className: "text-ui-fg-muted flex items-center gap-x-3", children: [
1338
+ /* @__PURE__ */ jsx3(Plus, {}),
1339
+ /* @__PURE__ */ jsx3(Text2, { size: "small", leading: "compact", weight: "plus", children: t("app.search.loadMore", {
1340
+ count: Math.min(
1341
+ SEARCH_LIMIT_INCREMENT,
1342
+ group.count - limit
1343
+ )
1344
+ }) })
1345
+ ] })
1346
+ }
1347
+ )
1348
+ ] }, group.title);
1349
+ }),
1350
+ filteredStaticResults.map((group) => {
1351
+ return /* @__PURE__ */ jsx3(
1352
+ CommandGroup,
1353
+ {
1354
+ heading: t(`app.keyboardShortcuts.${group.title}`),
1355
+ children: group.items.map((item) => {
1356
+ return /* @__PURE__ */ jsxs2(
1357
+ CommandItem,
1358
+ {
1359
+ onSelect: () => handleSelect(item),
1360
+ className: "flex items-center justify-between",
1361
+ children: [
1362
+ /* @__PURE__ */ jsx3("span", { children: item.label }),
1363
+ /* @__PURE__ */ jsx3("div", { className: "flex items-center gap-x-1.5", children: item.keys.Mac?.map((key, index) => {
1364
+ return /* @__PURE__ */ jsxs2(
1365
+ "div",
1366
+ {
1367
+ className: "flex items-center gap-x-1",
1368
+ children: [
1369
+ /* @__PURE__ */ jsx3(Kbd, { children: key }),
1370
+ index < (item.keys.Mac?.length || 0) - 1 && /* @__PURE__ */ jsx3("span", { className: "txt-compact-xsmall text-ui-fg-subtle", children: t("app.keyboardShortcuts.then") })
1371
+ ]
1372
+ },
1373
+ index
1374
+ );
1375
+ }) })
1376
+ ]
1377
+ },
1378
+ item.label
1379
+ );
1380
+ })
1381
+ },
1382
+ group.title
1383
+ );
1384
+ }),
1385
+ !showLoading && /* @__PURE__ */ jsx3(CommandEmpty, { q: search })
1386
+ ] })
1387
+ ] });
1388
+ };
1389
+ var CommandPalette = forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx3(
1390
+ Command,
1391
+ {
1392
+ shouldFilter: false,
1393
+ ref,
1394
+ className: clx(
1395
+ "bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md",
1396
+ className
1397
+ ),
1398
+ ...props
1399
+ }
1400
+ ));
1401
+ CommandPalette.displayName = Command.displayName;
1402
+ var CommandDialog = ({ children, ...props }) => {
1403
+ const { t } = useTranslation4();
1404
+ const preserveHeight = useMemo2(() => {
1405
+ return props.isLoading && Children.count(children) === 0;
1406
+ }, [props.isLoading, children]);
1407
+ return /* @__PURE__ */ jsx3(RadixDialog.Root, { ...props, children: /* @__PURE__ */ jsxs2(RadixDialog.Portal, { children: [
1408
+ /* @__PURE__ */ jsx3(RadixDialog.Overlay, { className: "bg-ui-bg-overlay fixed inset-0" }),
1409
+ /* @__PURE__ */ jsxs2(
1410
+ RadixDialog.Content,
1411
+ {
1412
+ className: clx(
1413
+ "bg-ui-bg-base shadow-elevation-modal fixed left-[50%] top-[50%] flex max-h-[calc(100%-16px)] w-[calc(100%-16px)] min-w-0 max-w-2xl translate-x-[-50%] translate-y-[-50%] flex-col overflow-hidden rounded-xl p-0",
1414
+ {
1415
+ "h-[300px]": preserveHeight
1416
+ // Prevents the dialog from collapsing when loading async results and before the no results message is displayed
1417
+ }
1418
+ ),
1419
+ children: [
1420
+ /* @__PURE__ */ jsx3(RadixDialog.Title, { className: "sr-only", children: t("app.search.title") }),
1421
+ /* @__PURE__ */ jsx3(RadixDialog.Description, { className: "sr-only", children: t("app.search.description") }),
1422
+ /* @__PURE__ */ jsx3(CommandPalette, { className: "[&_[cmdk-group-heading]]:text-muted-foreground flex h-full flex-col overflow-hidden [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0", children }),
1423
+ /* @__PURE__ */ jsx3("div", { className: "bg-ui-bg-field text-ui-fg-subtle flex items-center justify-end border-t px-4 py-3", children: /* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-x-3", children: [
1424
+ /* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-x-2", children: [
1425
+ /* @__PURE__ */ jsx3(Text2, { size: "xsmall", leading: "compact", children: t("app.search.navigation") }),
1426
+ /* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-x-1", children: [
1427
+ /* @__PURE__ */ jsx3(Kbd, { className: "bg-ui-bg-field-component", children: "\u2193" }),
1428
+ /* @__PURE__ */ jsx3(Kbd, { className: "bg-ui-bg-field-component", children: "\u2191" })
1429
+ ] })
1430
+ ] }),
1431
+ /* @__PURE__ */ jsx3("div", { className: "bg-ui-border-strong h-3 w-px" }),
1432
+ /* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-x-2", children: [
1433
+ /* @__PURE__ */ jsx3(Text2, { size: "xsmall", leading: "compact", children: t("app.search.openResult") }),
1434
+ /* @__PURE__ */ jsx3(Kbd, { className: "bg-ui-bg-field-component", children: "\u21B5" })
1435
+ ] })
1436
+ ] }) })
1437
+ ]
1438
+ }
1439
+ )
1440
+ ] }) });
1441
+ };
1442
+ var CommandInput = forwardRef(
1443
+ ({
1444
+ className,
1445
+ value,
1446
+ onValueChange,
1447
+ area,
1448
+ setArea,
1449
+ isFetching,
1450
+ onBack,
1451
+ ...props
1452
+ }, ref) => {
1453
+ const { t } = useTranslation4();
1454
+ const innerRef = useRef(null);
1455
+ const direction = useDocumentDirection();
1456
+ const canSearchArea = useSearchAreaAccess();
1457
+ useImperativeHandle(
1458
+ ref,
1459
+ () => innerRef.current
1460
+ );
1461
+ return /* @__PURE__ */ jsxs2("div", { className: "flex flex-col border-b", children: [
1462
+ /* @__PURE__ */ jsx3("div", { className: "px-4 pt-4", children: /* @__PURE__ */ jsxs2(DropdownMenu, { dir: direction, children: [
1463
+ /* @__PURE__ */ jsx3(DropdownMenu.Trigger, { asChild: true, children: /* @__PURE__ */ jsxs2(
1464
+ Badge,
1465
+ {
1466
+ size: "2xsmall",
1467
+ className: "hover:bg-ui-bg-base-pressed transition-fg cursor-pointer",
1468
+ children: [
1469
+ t(`app.search.groups.${area}`),
1470
+ /* @__PURE__ */ jsx3(TriangleDownMini, { className: "text-ui-fg-muted" })
1471
+ ]
1472
+ }
1473
+ ) }),
1474
+ /* @__PURE__ */ jsx3(
1475
+ DropdownMenu.Content,
1476
+ {
1477
+ align: "start",
1478
+ className: "h-full max-h-[360px] overflow-auto",
1479
+ onCloseAutoFocus: (e) => {
1480
+ e.preventDefault();
1481
+ innerRef.current?.focus();
1482
+ },
1483
+ children: /* @__PURE__ */ jsx3(
1484
+ DropdownMenu.RadioGroup,
1485
+ {
1486
+ value: area,
1487
+ onValueChange: (v) => setArea(v),
1488
+ children: SEARCH_AREAS.filter(canSearchArea).map((area2) => /* @__PURE__ */ jsxs2(Fragment, { children: [
1489
+ area2 === "command" && /* @__PURE__ */ jsx3(DropdownMenu.Separator, {}),
1490
+ /* @__PURE__ */ jsx3(DropdownMenu.RadioItem, { value: area2, children: t(`app.search.groups.${area2}`) }),
1491
+ area2 === "all" && /* @__PURE__ */ jsx3(DropdownMenu.Separator, {})
1492
+ ] }, area2))
1493
+ }
1494
+ )
1495
+ }
1496
+ )
1497
+ ] }) }),
1498
+ /* @__PURE__ */ jsxs2("div", { className: "relative flex items-center gap-x-2 px-4 py-3", children: [
1499
+ onBack && /* @__PURE__ */ jsx3(
1500
+ IconButton,
1501
+ {
1502
+ type: "button",
1503
+ size: "small",
1504
+ variant: "transparent",
1505
+ onClick: onBack,
1506
+ children: /* @__PURE__ */ jsx3(ArrowUturnLeft, { className: "text-ui-fg-muted" })
1507
+ }
1508
+ ),
1509
+ /* @__PURE__ */ jsx3(
1510
+ Command.Input,
1511
+ {
1512
+ ref: innerRef,
1513
+ value,
1514
+ onValueChange,
1515
+ className: clx(
1516
+ "placeholder:text-ui-fg-muted flex !h-6 w-full rounded-md bg-transparent text-sm outline-none disabled:cursor-not-allowed disabled:opacity-50",
1517
+ className
1518
+ ),
1519
+ ...props
1520
+ }
1521
+ ),
1522
+ /* @__PURE__ */ jsxs2("div", { className: "absolute end-4 top-1/2 flex -translate-y-1/2 items-center justify-end gap-x-2", children: [
1523
+ isFetching && /* @__PURE__ */ jsx3(Spinner, { className: "text-ui-fg-muted animate-spin" }),
1524
+ value && /* @__PURE__ */ jsx3(
1525
+ Button,
1526
+ {
1527
+ variant: "transparent",
1528
+ size: "small",
1529
+ className: "text-ui-fg-muted hover:text-ui-fg-subtle",
1530
+ type: "button",
1531
+ onClick: () => {
1532
+ onValueChange?.("");
1533
+ innerRef.current?.focus();
1534
+ },
1535
+ children: t("actions.clear")
1536
+ }
1537
+ )
1538
+ ] })
1539
+ ] })
1540
+ ] });
1541
+ }
1542
+ );
1543
+ CommandInput.displayName = Command.Input.displayName;
1544
+ var CommandList = forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx3(
1545
+ Command.List,
1546
+ {
1547
+ ref,
1548
+ className: clx(
1549
+ "max-h-[300px] flex-1 overflow-y-auto overflow-x-hidden px-2 pb-4",
1550
+ className
1551
+ ),
1552
+ ...props
1553
+ }
1554
+ ));
1555
+ CommandList.displayName = Command.List.displayName;
1556
+ var CommandEmpty = forwardRef((props, ref) => {
1557
+ const { t } = useTranslation4();
1558
+ return /* @__PURE__ */ jsx3(Command.Empty, { ref, className: "py-6 text-center text-sm", ...props, children: /* @__PURE__ */ jsxs2("div", { className: "text-ui-fg-subtle flex min-h-[236px] flex-col items-center justify-center gap-y-3", children: [
1559
+ /* @__PURE__ */ jsx3(MagnifyingGlass, { className: "text-ui-fg-subtle" }),
1560
+ /* @__PURE__ */ jsxs2("div", { className: "flex flex-col items-center justify-center gap-y-1", children: [
1561
+ /* @__PURE__ */ jsx3(Text2, { size: "small", weight: "plus", leading: "compact", children: props.q ? t("app.search.noResultsTitle") : t("app.search.emptySearchTitle") }),
1562
+ /* @__PURE__ */ jsx3(Text2, { size: "small", className: "text-ui-fg-muted", children: props.q ? t("app.search.noResultsMessage") : t("app.search.emptySearchMessage") })
1563
+ ] })
1564
+ ] }) });
1565
+ });
1566
+ CommandEmpty.displayName = Command.Empty.displayName;
1567
+ var CommandLoading = forwardRef((props, ref) => {
1568
+ return /* @__PURE__ */ jsxs2(
1569
+ Command.Loading,
1570
+ {
1571
+ ref,
1572
+ ...props,
1573
+ className: "bg-ui-bg-base flex flex-col",
1574
+ children: [
1575
+ /* @__PURE__ */ jsx3("div", { className: "w-full px-2 pb-1 pt-3", children: /* @__PURE__ */ jsx3(Skeleton, { className: "h-5 w-10" }) }),
1576
+ Array.from({ length: 7 }).map((_, index) => /* @__PURE__ */ jsx3("div", { className: "w-full p-2", children: /* @__PURE__ */ jsx3(Skeleton, { className: "h-5 w-full" }) }, index))
1577
+ ]
1578
+ }
1579
+ );
1580
+ });
1581
+ CommandLoading.displayName = Command.Loading.displayName;
1582
+ var CommandGroup = forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx3(
1583
+ Command.Group,
1584
+ {
1585
+ ref,
1586
+ className: clx(
1587
+ "text-ui-fg-base [&_[cmdk-group-heading]]:text-ui-fg-muted [&_[cmdk-group-heading]]:txt-compact-xsmall-plus overflow-hidden [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:pb-1 [&_[cmdk-group-heading]]:pt-3 [&_[cmdk-item]]:py-2",
1588
+ className
1589
+ ),
1590
+ ...props
1591
+ }
1592
+ ));
1593
+ CommandGroup.displayName = Command.Group.displayName;
1594
+ var CommandSeparator = forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx3(
1595
+ Command.Separator,
1596
+ {
1597
+ ref,
1598
+ className: clx("bg-border -mx-1 h-px", className),
1599
+ ...props
1600
+ }
1601
+ ));
1602
+ CommandSeparator.displayName = Command.Separator.displayName;
1603
+ var CommandItem = forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx3(
1604
+ Command.Item,
1605
+ {
1606
+ ref,
1607
+ className: clx(
1608
+ "aria-selected:bg-ui-bg-base-hover focus-visible:bg-ui-bg-base-hover txt-compact-small [&>svg]:text-ui-fg-subtle relative flex cursor-pointer select-none items-center gap-x-3 rounded-md p-2 outline-none data-[disabled=true]:pointer-events-none data-[disabled=true]:cursor-not-allowed data-[disabled=true]:opacity-50",
1609
+ className
1610
+ ),
1611
+ ...props
1612
+ }
1613
+ ));
1614
+ CommandItem.displayName = Command.Item.displayName;
1615
+
1616
+ // src/providers/sidebar-provider/index.ts
1617
+ import {
1618
+ SIDEBAR_MENU_CONTENT,
1619
+ SIDEBAR_RAIL_FADE,
1620
+ SidebarProvider,
1621
+ useCollapsedSidebar,
1622
+ useExpandedSidebar,
1623
+ useSidebar,
1624
+ useSidebarMenuPlacement
1625
+ } from "@mercurjs/dashboard-shared";
1626
+
1627
+ // src/providers/search-provider/search-context.tsx
1628
+ import { createContext as createContext3 } from "react";
1629
+ var SearchContext = createContext3(null);
1630
+
1631
+ // src/providers/search-provider/search-provider.tsx
1632
+ import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
1633
+ var SearchProvider = ({ children }) => {
1634
+ const [open, setOpen] = useState5(false);
1635
+ const { mobile, toggle } = useSidebar();
1636
+ const toggleSearch = () => {
1637
+ const update = !open;
1638
+ if (update && mobile) {
1639
+ toggle("mobile");
1640
+ }
1641
+ setOpen(update);
1642
+ };
1643
+ useEffect5(() => {
1644
+ const onKeyDown = (e) => {
1645
+ if (e.key === "k" && (e.metaKey || e.ctrlKey)) {
1646
+ setOpen((prev) => !prev);
1647
+ }
1648
+ };
1649
+ document.addEventListener("keydown", onKeyDown);
1650
+ return () => {
1651
+ document.removeEventListener("keydown", onKeyDown);
1652
+ };
1653
+ }, []);
1654
+ return /* @__PURE__ */ jsxs3(
1655
+ SearchContext.Provider,
1656
+ {
1657
+ value: {
1658
+ open,
1659
+ onOpenChange: setOpen,
1660
+ toggleSearch
1661
+ },
1662
+ children: [
1663
+ children,
1664
+ /* @__PURE__ */ jsx4(Search, {})
1665
+ ]
1666
+ }
1667
+ );
1668
+ };
1669
+
1670
+ // src/providers/search-provider/use-search.tsx
1671
+ import { useContext as useContext2 } from "react";
1672
+ var useSearch = () => {
1673
+ const context = useContext2(SearchContext);
1674
+ if (!context) {
1675
+ throw new Error("useSearch must be used within a SearchProvider");
1676
+ }
1677
+ return context;
1678
+ };
1679
+
1680
+ // src/components/layout/nav-item/nav-item.tsx
1681
+ import {
1682
+ useCallback as useCallback5,
1683
+ useEffect as useEffect6,
1684
+ useState as useState6
1685
+ } from "react";
1686
+ import { Kbd as Kbd2, Text as Text3, Tooltip, clx as clx2 } from "@medusajs/ui";
1687
+ import { Collapsible as RadixCollapsible } from "radix-ui";
1688
+ import { useTranslation as useTranslation5 } from "react-i18next";
1689
+ import { NavLink, useLocation as useLocation3 } from "react-router-dom";
1690
+ import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
1691
+ var NestedNavLabel = ({
1692
+ label,
1693
+ translationNs
1694
+ }) => {
1695
+ const { t } = useTranslation5(translationNs);
1696
+ return /* @__PURE__ */ jsx5(Text3, { size: "small", weight: "plus", leading: "compact", children: translationNs ? t(label) : label });
1697
+ };
1698
+ var BASE_NAV_LINK_CLASSES = "text-ui-fg-subtle transition-fg hover:bg-ui-bg-subtle-hover flex items-center gap-x-2 rounded-md py-0.5 pl-0.5 pr-2 outline-none [&>svg]:text-ui-fg-subtle focus-visible:shadow-borders-focus";
1699
+ var ACTIVE_NAV_LINK_CLASSES = "bg-ui-bg-base shadow-elevation-card-rest text-ui-fg-base hover:bg-ui-bg-base";
1700
+ var NESTED_NAV_LINK_CLASSES = "pl-[34px] pr-2 py-1 w-full text-ui-fg-muted";
1701
+ var SETTING_NAV_LINK_CLASSES = "pl-2 py-1";
1702
+ var getIsOpen = (to, items, pathname) => {
1703
+ return [to, ...items?.map((i) => i.to) ?? []].some(
1704
+ (p) => pathname.startsWith(p)
1705
+ );
1706
+ };
1707
+ var NavItemTooltip = ({
1708
+ to,
1709
+ label,
1710
+ children
1711
+ }) => {
1712
+ const { t } = useTranslation5();
1713
+ const { state } = useSidebar();
1714
+ const globalShortcuts = useGlobalShortcuts();
1715
+ const shortcut = globalShortcuts.find((s) => s.to === to);
1716
+ if (state === "collapsed" && label) {
1717
+ return /* @__PURE__ */ jsx5(Tooltip, { content: label, side: "right", delayDuration: 0, children: /* @__PURE__ */ jsx5("div", { className: "w-full", children }) });
1718
+ }
1719
+ return /* @__PURE__ */ jsx5(
1720
+ ConditionalTooltip,
1721
+ {
1722
+ showTooltip: !!shortcut,
1723
+ maxWidth: 9999,
1724
+ content: /* @__PURE__ */ jsxs4("div", { className: "txt-compact-xsmall flex h-5 items-center justify-between gap-x-2 whitespace-nowrap", children: [
1725
+ /* @__PURE__ */ jsx5("span", { children: shortcut?.label }),
1726
+ /* @__PURE__ */ jsx5("div", { className: "flex items-center gap-x-1", children: shortcut?.keys.Mac?.map((key, index) => /* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-x-1", children: [
1727
+ /* @__PURE__ */ jsx5(Kbd2, { children: key }, key),
1728
+ index < (shortcut.keys.Mac?.length || 0) - 1 && /* @__PURE__ */ jsx5("span", { className: "txt-compact-xsmall text-ui-fg-muted", children: t("app.keyboardShortcuts.then") })
1729
+ ] }, index)) })
1730
+ ] }),
1731
+ side: "right",
1732
+ delayDuration: 1500,
1733
+ children: /* @__PURE__ */ jsx5("div", { className: "w-full", children })
1734
+ }
1735
+ );
1736
+ };
1737
+ var NavItem = ({
1738
+ icon,
1739
+ label,
1740
+ to,
1741
+ items,
1742
+ type = "core",
1743
+ from,
1744
+ translationNs
1745
+ }) => {
1746
+ const { t } = useTranslation5(translationNs);
1747
+ const { pathname } = useLocation3();
1748
+ const displayLabel = translationNs ? t(label) : label;
1749
+ const [open, setOpen] = useState6(getIsOpen(to, items, pathname));
1750
+ useEffect6(() => {
1751
+ setOpen(getIsOpen(to, items, pathname));
1752
+ }, [pathname, to, items]);
1753
+ const navLinkClassNames = useCallback5(
1754
+ ({
1755
+ to: to2,
1756
+ isActive,
1757
+ isNested = false,
1758
+ isSetting: isSetting2 = false
1759
+ }) => {
1760
+ if (["core", "setting"].includes(type)) {
1761
+ isActive = pathname.startsWith(to2);
1762
+ if (isActive && !isNested && items?.length) {
1763
+ const nestedIsActive = items.some(
1764
+ (item) => pathname.startsWith(item.to)
1765
+ );
1766
+ if (nestedIsActive) {
1767
+ isActive = false;
1768
+ }
1769
+ }
1770
+ }
1771
+ return clx2(BASE_NAV_LINK_CLASSES, {
1772
+ [NESTED_NAV_LINK_CLASSES]: isNested,
1773
+ [ACTIVE_NAV_LINK_CLASSES]: isActive,
1774
+ [SETTING_NAV_LINK_CLASSES]: isSetting2
1775
+ });
1776
+ },
1777
+ [type, pathname, items]
1778
+ );
1779
+ const isSetting = type === "setting";
1780
+ return /* @__PURE__ */ jsxs4(
1781
+ "div",
1782
+ {
1783
+ className: "px-3",
1784
+ "data-testid": `sidebar-nav-item-${to.replace(/\//g, "-").replace(/^-/, "")}`,
1785
+ children: [
1786
+ /* @__PURE__ */ jsx5(NavItemTooltip, { to, label: displayLabel, children: /* @__PURE__ */ jsxs4(
1787
+ NavLink,
1788
+ {
1789
+ to,
1790
+ end: items?.some((i) => i.to === pathname),
1791
+ state: from ? {
1792
+ from
1793
+ } : void 0,
1794
+ className: ({ isActive }) => {
1795
+ return clx2(navLinkClassNames({ isActive, isSetting, to }), {
1796
+ "max-lg:hidden": !!items?.length
1797
+ });
1798
+ },
1799
+ "data-testid": `sidebar-nav-link-${to.replace(/\//g, "-").replace(/^-/, "")}`,
1800
+ children: [
1801
+ type !== "setting" && /* @__PURE__ */ jsx5("div", { className: "flex size-6 shrink-0 items-center justify-center", children: /* @__PURE__ */ jsx5(Icon, { icon, type }) }),
1802
+ /* @__PURE__ */ jsx5(
1803
+ Text3,
1804
+ {
1805
+ size: "small",
1806
+ weight: "plus",
1807
+ leading: "compact",
1808
+ className: clx2("shrink-0 whitespace-nowrap", SIDEBAR_RAIL_FADE),
1809
+ children: displayLabel
1810
+ }
1811
+ )
1812
+ ]
1813
+ }
1814
+ ) }),
1815
+ items && items.length > 0 && /* @__PURE__ */ jsxs4(
1816
+ RadixCollapsible.Root,
1817
+ {
1818
+ open,
1819
+ onOpenChange: setOpen,
1820
+ className: "group-data-[state=collapsed]/sidebar:hidden",
1821
+ children: [
1822
+ /* @__PURE__ */ jsxs4(
1823
+ RadixCollapsible.Trigger,
1824
+ {
1825
+ className: clx2(
1826
+ "flex w-full items-center gap-x-2 rounded-md py-0.5 pl-0.5 pr-2 text-ui-fg-subtle outline-none transition-fg hover:bg-ui-bg-subtle-hover hover:text-ui-fg-base lg:hidden",
1827
+ { "pl-2": isSetting }
1828
+ ),
1829
+ children: [
1830
+ /* @__PURE__ */ jsx5("div", { className: "flex size-6 items-center justify-center", children: /* @__PURE__ */ jsx5(Icon, { icon, type }) }),
1831
+ /* @__PURE__ */ jsx5(Text3, { size: "small", weight: "plus", leading: "compact", children: displayLabel })
1832
+ ]
1833
+ }
1834
+ ),
1835
+ /* @__PURE__ */ jsx5(RadixCollapsible.Content, { children: /* @__PURE__ */ jsx5(
1836
+ "div",
1837
+ {
1838
+ className: "flex flex-col gap-y-0.5 pb-2 pt-0.5",
1839
+ "data-testid": `sidebar-nav-nested-items-${to.replace(/\//g, "-").replace(/^-/, "")}`,
1840
+ children: /* @__PURE__ */ jsxs4("ul", { className: "flex flex-col gap-y-0.5", children: [
1841
+ /* @__PURE__ */ jsx5("li", { className: "flex w-full items-center gap-x-1 lg:hidden", children: /* @__PURE__ */ jsx5(NavItemTooltip, { to, children: /* @__PURE__ */ jsx5(
1842
+ NavLink,
1843
+ {
1844
+ to,
1845
+ end: true,
1846
+ className: ({ isActive }) => {
1847
+ return clx2(
1848
+ navLinkClassNames({
1849
+ to,
1850
+ isActive,
1851
+ isSetting,
1852
+ isNested: true
1853
+ })
1854
+ );
1855
+ },
1856
+ "data-testid": `sidebar-nav-link-nested-${to.replace(/\//g, "-").replace(/^-/, "")}`,
1857
+ children: /* @__PURE__ */ jsx5(Text3, { size: "small", weight: "plus", leading: "compact", children: displayLabel })
1858
+ }
1859
+ ) }) }),
1860
+ items.map((item) => {
1861
+ return /* @__PURE__ */ jsx5("li", { className: "flex h-7 items-center", children: /* @__PURE__ */ jsx5(NavItemTooltip, { to: item.to, children: /* @__PURE__ */ jsx5(
1862
+ NavLink,
1863
+ {
1864
+ to: item.to,
1865
+ end: true,
1866
+ className: ({ isActive }) => {
1867
+ return clx2(
1868
+ navLinkClassNames({
1869
+ to: item.to,
1870
+ isActive,
1871
+ isSetting,
1872
+ isNested: true
1873
+ })
1874
+ );
1875
+ },
1876
+ "data-testid": `sidebar-nav-link-nested-${item.to.replace(/\//g, "-").replace(/^-/, "")}`,
1877
+ children: /* @__PURE__ */ jsx5(
1878
+ NestedNavLabel,
1879
+ {
1880
+ label: item.label,
1881
+ translationNs: item.translationNs
1882
+ }
1883
+ )
1884
+ }
1885
+ ) }) }, item.to);
1886
+ })
1887
+ ] })
1888
+ }
1889
+ ) })
1890
+ ]
1891
+ }
1892
+ )
1893
+ ]
1894
+ }
1895
+ );
1896
+ };
1897
+ var Icon = ({ icon, type }) => {
1898
+ if (!icon) {
1899
+ return null;
1900
+ }
1901
+ return type === "extension" ? /* @__PURE__ */ jsx5("div", { className: "flex h-5 w-5 items-center justify-center rounded-[4px] bg-ui-bg-base shadow-borders-base", children: /* @__PURE__ */ jsx5("div", { className: "h-[15px] w-[15px] overflow-hidden rounded-sm", children: icon }) }) : icon;
1902
+ };
1903
+
1904
+ // src/components/layout/shell/shell.tsx
1905
+ import { SidebarLeft, TriangleRightMini, XMark } from "@medusajs/icons";
1906
+ import { IconButton as IconButton2, clx as clx3 } from "@medusajs/ui";
1907
+ import { AnimatePresence } from "motion/react";
1908
+ import { Dialog as RadixDialog2 } from "radix-ui";
1909
+ import { useEffect as useEffect7, useState as useState8 } from "react";
1910
+ import { useTranslation as useTranslation6 } from "react-i18next";
1911
+ import {
1912
+ Link,
1913
+ Outlet,
1914
+ useMatches,
1915
+ useNavigation
1916
+ } from "react-router-dom";
1917
+ import { WidgetZone } from "@mercurjs/dashboard-shared";
1918
+
1919
+ // src/providers/keybind-provider/keybind-provider.tsx
1920
+ import { useCallback as useCallback6, useMemo as useMemo3, useState as useState7 } from "react";
1921
+ import { jsx as jsx6 } from "react/jsx-runtime";
1922
+ var KeybindProvider = ({
1923
+ shortcuts,
1924
+ debounce = 500,
1925
+ children
1926
+ }) => {
1927
+ const [storeShortcuts, setStoreCommands] = useState7(
1928
+ shortcuts.map((shr) => getShortcutWithDefaultValues(shr))
1929
+ );
1930
+ const registerShortcut = useCallback6(
1931
+ (shortcut) => {
1932
+ setStoreCommands((prevShortcuts) => {
1933
+ const idx = findShortcutIndex(shortcuts, getShortcutKeys(shortcut));
1934
+ const newShortcuts = [...prevShortcuts];
1935
+ if (idx > -1) {
1936
+ newShortcuts[idx] = getShortcutWithDefaultValues(shortcut);
1937
+ return prevShortcuts;
1938
+ }
1939
+ return [...prevShortcuts, getShortcutWithDefaultValues(shortcut)];
1940
+ });
1941
+ },
1942
+ [shortcuts]
1943
+ );
1944
+ const getKeysByPlatform = useCallback6((command) => {
1945
+ return findFirstPlatformMatch(command.keys);
1946
+ }, []);
1947
+ useShortcuts({ shortcuts: storeShortcuts, debounce });
1948
+ const commandsContext = useMemo3(
1949
+ () => ({
1950
+ shortcuts: storeShortcuts,
1951
+ registerShortcut,
1952
+ getKeysByPlatform
1953
+ }),
1954
+ [storeShortcuts, registerShortcut, getKeysByPlatform]
1955
+ );
1956
+ return /* @__PURE__ */ jsx6(KeybindContext.Provider, { value: commandsContext, children });
1957
+ };
1958
+
1959
+ // src/components/common/progress-bar/progress-bar.tsx
1960
+ import { motion } from "motion/react";
1961
+ import { jsx as jsx7 } from "react/jsx-runtime";
1962
+ var ProgressBar = ({ duration = 2 }) => {
1963
+ return /* @__PURE__ */ jsx7(
1964
+ motion.div,
1965
+ {
1966
+ className: "bg-ui-fg-subtle size-full",
1967
+ initial: {
1968
+ width: "0%"
1969
+ },
1970
+ transition: {
1971
+ delay: 0.2,
1972
+ duration,
1973
+ ease: "linear"
1974
+ },
1975
+ animate: {
1976
+ width: "90%"
1977
+ },
1978
+ exit: {
1979
+ width: "100%",
1980
+ transition: { duration: 0.2, ease: "linear" }
1981
+ }
1982
+ }
1983
+ );
1984
+ };
1985
+
1986
+ // src/components/layout/shell/shell.tsx
1987
+ import { jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
1988
+ var Shell = ({ children, rail = true }) => {
1989
+ const globalShortcuts = useGlobalShortcuts();
1990
+ const navigation = useNavigation();
1991
+ const loading = navigation.state === "loading";
1992
+ return /* @__PURE__ */ jsx8(KeybindProvider, { shortcuts: globalShortcuts, children: /* @__PURE__ */ jsxs5("div", { className: "relative flex h-screen flex-col items-start overflow-hidden lg:flex-row", children: [
1993
+ /* @__PURE__ */ jsx8(NavigationBar, { loading }),
1994
+ /* @__PURE__ */ jsxs5("div", { children: [
1995
+ /* @__PURE__ */ jsx8(MobileSidebarContainer, { children }),
1996
+ /* @__PURE__ */ jsx8(DesktopSidebarContainer, { rail, children })
1997
+ ] }),
1998
+ /* @__PURE__ */ jsxs5("div", { className: "flex h-screen w-full flex-col overflow-auto", children: [
1999
+ /* @__PURE__ */ jsx8(Topbar, {}),
2000
+ /* @__PURE__ */ jsx8(
2001
+ "main",
2002
+ {
2003
+ className: clx3(
2004
+ "flex h-full w-full flex-col items-center overflow-y-auto transition-opacity delay-200 duration-200",
2005
+ {
2006
+ "opacity-25": loading
2007
+ }
2008
+ ),
2009
+ children: /* @__PURE__ */ jsx8(Gutter, { children: /* @__PURE__ */ jsx8(Outlet, {}) })
2010
+ }
2011
+ )
2012
+ ] })
2013
+ ] }) });
2014
+ };
2015
+ var NavigationBar = ({ loading }) => {
2016
+ const [showBar, setShowBar] = useState8(false);
2017
+ useEffect7(() => {
2018
+ let timeout;
2019
+ if (loading) {
2020
+ timeout = setTimeout(() => {
2021
+ setShowBar(true);
2022
+ }, 200);
2023
+ } else {
2024
+ setShowBar(false);
2025
+ }
2026
+ return () => {
2027
+ clearTimeout(timeout);
2028
+ };
2029
+ }, [loading]);
2030
+ return /* @__PURE__ */ jsx8("div", { className: "fixed inset-x-0 top-0 z-50 h-1", children: /* @__PURE__ */ jsx8(AnimatePresence, { children: showBar ? /* @__PURE__ */ jsx8(ProgressBar, {}) : null }) });
2031
+ };
2032
+ var Gutter = ({ children }) => {
2033
+ return /* @__PURE__ */ jsx8("div", { className: "flex w-full max-w-[1600px] flex-col gap-y-2 p-3", children });
2034
+ };
2035
+ var Breadcrumbs = () => {
2036
+ const matches = useMatches();
2037
+ const crumbs = matches.filter((match) => match.handle?.breadcrumb).map((match) => {
2038
+ const handle = match.handle;
2039
+ let label = void 0;
2040
+ try {
2041
+ label = handle.breadcrumb?.(match);
2042
+ } catch {
2043
+ }
2044
+ if (!label) {
2045
+ return null;
2046
+ }
2047
+ return {
2048
+ label,
2049
+ path: match.pathname
2050
+ };
2051
+ }).filter(Boolean);
2052
+ return /* @__PURE__ */ jsx8(
2053
+ "ol",
2054
+ {
2055
+ className: clx3(
2056
+ "text-ui-fg-muted txt-compact-small-plus flex select-none items-center"
2057
+ ),
2058
+ children: crumbs.map((crumb, index) => {
2059
+ const isLast = index === crumbs.length - 1;
2060
+ const isSingle = crumbs.length === 1;
2061
+ return /* @__PURE__ */ jsxs5("li", { className: clx3("flex items-center"), children: [
2062
+ !isLast ? /* @__PURE__ */ jsx8(
2063
+ Link,
2064
+ {
2065
+ className: "transition-fg hover:text-ui-fg-subtle",
2066
+ to: crumb.path,
2067
+ children: crumb.label
2068
+ }
2069
+ ) : /* @__PURE__ */ jsxs5("div", { children: [
2070
+ !isSingle && /* @__PURE__ */ jsx8("span", { className: "block lg:hidden", children: "..." }),
2071
+ /* @__PURE__ */ jsx8(
2072
+ "span",
2073
+ {
2074
+ className: clx3({
2075
+ "hidden lg:block": !isSingle
2076
+ }),
2077
+ children: crumb.label
2078
+ },
2079
+ index
2080
+ )
2081
+ ] }),
2082
+ !isLast && /* @__PURE__ */ jsx8("span", { className: "mx-2", children: /* @__PURE__ */ jsx8(TriangleRightMini, { className: "rtl:rotate-180" }) })
2083
+ ] }, index);
2084
+ })
2085
+ }
2086
+ );
2087
+ };
2088
+ var ToggleSidebar = () => {
2089
+ const { toggle, state } = useSidebar();
2090
+ return /* @__PURE__ */ jsxs5("div", { children: [
2091
+ /* @__PURE__ */ jsx8(
2092
+ IconButton2,
2093
+ {
2094
+ className: "hidden lg:flex",
2095
+ variant: "transparent",
2096
+ onClick: () => toggle("desktop"),
2097
+ size: "small",
2098
+ "aria-expanded": state === "expanded",
2099
+ children: /* @__PURE__ */ jsx8(SidebarLeft, { className: "text-ui-fg-muted rtl:rotate-180" })
2100
+ }
2101
+ ),
2102
+ /* @__PURE__ */ jsx8(
2103
+ IconButton2,
2104
+ {
2105
+ className: "hidden max-lg:flex",
2106
+ variant: "transparent",
2107
+ onClick: () => toggle("mobile"),
2108
+ size: "small",
2109
+ children: /* @__PURE__ */ jsx8(SidebarLeft, { className: "text-ui-fg-muted rtl:rotate-180" })
2110
+ }
2111
+ )
2112
+ ] });
2113
+ };
2114
+ var Topbar = () => {
2115
+ return /* @__PURE__ */ jsxs5("div", { className: "grid w-full grid-cols-2 border-b p-3", children: [
2116
+ /* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-x-1.5", children: [
2117
+ /* @__PURE__ */ jsx8(ToggleSidebar, {}),
2118
+ /* @__PURE__ */ jsx8(Breadcrumbs, {})
2119
+ ] }),
2120
+ /* @__PURE__ */ jsx8("div", { className: "flex items-center justify-end gap-x-3", children: /* @__PURE__ */ jsx8(WidgetZone, { id: "topbar" }) })
2121
+ ] });
2122
+ };
2123
+ var DesktopSidebarContainer = ({
2124
+ children,
2125
+ rail
2126
+ }) => {
2127
+ const { state } = useSidebar();
2128
+ return /* @__PURE__ */ jsx8(
2129
+ "div",
2130
+ {
2131
+ "data-state": state,
2132
+ className: clx3(
2133
+ "group/sidebar hidden h-screen w-[220px] shrink-0 overflow-x-hidden border-e lg:flex",
2134
+ "transition-[width] duration-200 ease-sidebar motion-reduce:transition-none",
2135
+ rail ? "data-[state=collapsed]:w-[52px]" : "data-[state=collapsed]:w-0 data-[state=collapsed]:border-e-0"
2136
+ ),
2137
+ children: rail ? children : /* @__PURE__ */ jsx8("div", { className: "flex w-[220px] shrink-0", children })
2138
+ }
2139
+ );
2140
+ };
2141
+ var MobileSidebarContainer = ({ children }) => {
2142
+ const { t } = useTranslation6();
2143
+ const { mobile, toggle } = useSidebar();
2144
+ return /* @__PURE__ */ jsx8(RadixDialog2.Root, { open: mobile, onOpenChange: () => toggle("mobile"), children: /* @__PURE__ */ jsxs5(RadixDialog2.Portal, { children: [
2145
+ /* @__PURE__ */ jsx8(
2146
+ RadixDialog2.Overlay,
2147
+ {
2148
+ className: clx3(
2149
+ "bg-ui-bg-overlay fixed inset-0",
2150
+ "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0"
2151
+ )
2152
+ }
2153
+ ),
2154
+ /* @__PURE__ */ jsxs5(
2155
+ RadixDialog2.Content,
2156
+ {
2157
+ className: clx3(
2158
+ "bg-ui-bg-subtle shadow-elevation-modal fixed inset-y-2 start-2 flex w-full max-w-[304px] flex-col overflow-hidden rounded-lg border-r",
2159
+ "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:slide-out-to-start-1/2 data-[state=open]:slide-in-from-start-1/2 duration-200"
2160
+ ),
2161
+ children: [
2162
+ /* @__PURE__ */ jsxs5("div", { className: "p-3", children: [
2163
+ /* @__PURE__ */ jsx8(RadixDialog2.Close, { asChild: true, children: /* @__PURE__ */ jsx8(
2164
+ IconButton2,
2165
+ {
2166
+ size: "small",
2167
+ variant: "transparent",
2168
+ className: "text-ui-fg-subtle",
2169
+ children: /* @__PURE__ */ jsx8(XMark, {})
2170
+ }
2171
+ ) }),
2172
+ /* @__PURE__ */ jsx8(RadixDialog2.Title, { className: "sr-only", children: t("app.nav.accessibility.title") }),
2173
+ /* @__PURE__ */ jsx8(RadixDialog2.Description, { className: "sr-only", children: t("app.nav.accessibility.description") })
2174
+ ] }),
2175
+ children
2176
+ ]
2177
+ }
2178
+ )
2179
+ ] }) });
2180
+ };
2181
+
2182
+ // src/components/layout/user-menu/user-menu.tsx
2183
+ import {
2184
+ BookOpen,
2185
+ CircleHalfSolid,
2186
+ EllipsisHorizontal,
2187
+ Keyboard,
2188
+ OpenRectArrowOut,
2189
+ TimelineVertical,
2190
+ User as UserIcon,
2191
+ XMark as XMark2
2192
+ } from "@medusajs/icons";
2193
+ import {
2194
+ Avatar,
2195
+ DropdownMenu as DropdownMenu2,
2196
+ Heading,
2197
+ IconButton as IconButton3,
2198
+ Input,
2199
+ Kbd as Kbd3,
2200
+ Text as Text4,
2201
+ clx as clx4
2202
+ } from "@medusajs/ui";
2203
+ import { Dialog as RadixDialog3 } from "radix-ui";
2204
+ import { useTranslation as useTranslation7 } from "react-i18next";
2205
+ import { useState as useState9 } from "react";
2206
+ import { Link as Link2, useLocation as useLocation4, useNavigate as useNavigate3 } from "react-router-dom";
2207
+
2208
+ // src/providers/theme-provider/use-theme.tsx
2209
+ import { useContext as useContext3 } from "react";
2210
+ var useTheme = () => {
2211
+ const context = useContext3(ThemeContext);
2212
+ if (!context) {
2213
+ throw new Error("useTheme must be used within a ThemeProvider");
2214
+ }
2215
+ return context;
2216
+ };
2217
+
2218
+ // src/components/layout/user-menu/user-menu.tsx
2219
+ import { jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
2220
+ var UserMenu = () => {
2221
+ const { t } = useTranslation7();
2222
+ const location = useLocation4();
2223
+ const direction = useDocumentDirection();
2224
+ const menuPlacement = useSidebarMenuPlacement("end");
2225
+ const [openMenu, setOpenMenu] = useState9(false);
2226
+ const [openModal, setOpenModal] = useState9(false);
2227
+ const toggleModal = () => {
2228
+ setOpenMenu(false);
2229
+ setOpenModal(!openModal);
2230
+ };
2231
+ return /* @__PURE__ */ jsxs6("div", { "data-testid": "sidebar-user-menu", children: [
2232
+ /* @__PURE__ */ jsxs6(DropdownMenu2, { dir: direction, open: openMenu, onOpenChange: setOpenMenu, "data-testid": "sidebar-user-menu-dropdown", children: [
2233
+ /* @__PURE__ */ jsx9(UserBadge, {}),
2234
+ /* @__PURE__ */ jsxs6(DropdownMenu2.Content, { ...menuPlacement, className: SIDEBAR_MENU_CONTENT, "data-testid": "sidebar-user-menu-content", children: [
2235
+ /* @__PURE__ */ jsx9(UserItem, {}),
2236
+ /* @__PURE__ */ jsx9(DropdownMenu2.Separator, { "data-testid": "sidebar-user-menu-separator-1" }),
2237
+ /* @__PURE__ */ jsx9(DropdownMenu2.Item, { asChild: true, "data-testid": "sidebar-user-menu-profile-settings", children: /* @__PURE__ */ jsxs6(Link2, { to: "/settings/profile", state: { from: location.pathname }, children: [
2238
+ /* @__PURE__ */ jsx9(UserIcon, { className: "text-ui-fg-subtle me-2" }),
2239
+ t("app.menus.user.profileSettings")
2240
+ ] }) }),
2241
+ /* @__PURE__ */ jsx9(DropdownMenu2.Separator, { "data-testid": "sidebar-user-menu-separator-2" }),
2242
+ /* @__PURE__ */ jsx9(DropdownMenu2.Item, { asChild: true, "data-testid": "sidebar-user-menu-documentation", children: /* @__PURE__ */ jsxs6(Link2, { to: "https://docs.mercurjs.com/welcome", target: "_blank", children: [
2243
+ /* @__PURE__ */ jsx9(BookOpen, { className: "text-ui-fg-subtle me-2" }),
2244
+ t("app.menus.user.documentation")
2245
+ ] }) }),
2246
+ /* @__PURE__ */ jsx9(DropdownMenu2.Item, { asChild: true, "data-testid": "sidebar-user-menu-changelog", children: /* @__PURE__ */ jsxs6(Link2, { to: "https://www.mercurjs.com/updates", target: "_blank", children: [
2247
+ /* @__PURE__ */ jsx9(TimelineVertical, { className: "text-ui-fg-subtle me-2" }),
2248
+ t("app.menus.user.changelog")
2249
+ ] }) }),
2250
+ /* @__PURE__ */ jsx9(DropdownMenu2.Separator, { "data-testid": "sidebar-user-menu-separator-3" }),
2251
+ /* @__PURE__ */ jsxs6(DropdownMenu2.Item, { onClick: toggleModal, "data-testid": "sidebar-user-menu-shortcuts", children: [
2252
+ /* @__PURE__ */ jsx9(Keyboard, { className: "text-ui-fg-subtle me-2" }),
2253
+ t("app.menus.user.shortcuts")
2254
+ ] }),
2255
+ /* @__PURE__ */ jsx9(ThemeToggle, {}),
2256
+ /* @__PURE__ */ jsx9(DropdownMenu2.Separator, { "data-testid": "sidebar-user-menu-separator-4" }),
2257
+ /* @__PURE__ */ jsx9(Logout, {})
2258
+ ] })
2259
+ ] }),
2260
+ /* @__PURE__ */ jsx9(GlobalKeybindsModal, { open: openModal, onOpenChange: setOpenModal })
2261
+ ] });
2262
+ };
2263
+ var UserBadge = () => {
2264
+ const { user, isPending, isError, error } = useMe();
2265
+ const name = [user?.first_name, user?.last_name].filter(Boolean).join(" ");
2266
+ const displayName = name || user?.email;
2267
+ const fallback = displayName ? displayName[0].toUpperCase() : null;
2268
+ if (isPending) {
2269
+ return /* @__PURE__ */ jsxs6("button", { className: "shadow-borders-base flex max-w-[192px] select-none items-center gap-x-2 overflow-hidden text-ellipsis whitespace-nowrap rounded-full py-1 ps-1 pe-2.5", children: [
2270
+ /* @__PURE__ */ jsx9(Skeleton, { className: "h-5 w-5 rounded-full" }),
2271
+ /* @__PURE__ */ jsx9(Skeleton, { className: "h-[9px] w-[70px]" })
2272
+ ] });
2273
+ }
2274
+ if (isError) {
2275
+ throw error;
2276
+ }
2277
+ return /* @__PURE__ */ jsx9("div", { className: "p-3", "data-testid": "sidebar-user-menu-badge", children: /* @__PURE__ */ jsxs6(
2278
+ DropdownMenu2.Trigger,
2279
+ {
2280
+ disabled: !user,
2281
+ className: clx4(
2282
+ "bg-ui-bg-subtle grid w-full cursor-pointer grid-cols-[24px_1fr_15px] items-center gap-2 rounded-md py-1 ps-0.5 pe-2 outline-none",
2283
+ "hover:bg-ui-bg-subtle-hover",
2284
+ "data-[state=open]:bg-ui-bg-subtle-hover",
2285
+ "focus-visible:shadow-borders-focus"
2286
+ ),
2287
+ "data-testid": "sidebar-user-menu-trigger",
2288
+ children: [
2289
+ /* @__PURE__ */ jsx9("div", { className: "flex size-6 shrink-0 items-center justify-center", "data-testid": "sidebar-user-menu-avatar-container", children: fallback ? /* @__PURE__ */ jsx9(Avatar, { size: "xsmall", fallback, "data-testid": "sidebar-user-menu-avatar" }) : /* @__PURE__ */ jsx9(Skeleton, { className: "h-6 w-6 rounded-full" }) }),
2290
+ /* @__PURE__ */ jsx9("div", { className: clx4("flex items-center overflow-hidden whitespace-nowrap", SIDEBAR_RAIL_FADE), "data-testid": "sidebar-user-menu-name-container", children: displayName ? /* @__PURE__ */ jsx9(
2291
+ Text4,
2292
+ {
2293
+ size: "xsmall",
2294
+ weight: "plus",
2295
+ leading: "compact",
2296
+ className: "truncate",
2297
+ "data-testid": "sidebar-user-menu-name",
2298
+ children: displayName
2299
+ }
2300
+ ) : /* @__PURE__ */ jsx9(Skeleton, { className: "h-[9px] w-[70px]" }) }),
2301
+ /* @__PURE__ */ jsx9(EllipsisHorizontal, { className: clx4("text-ui-fg-muted", SIDEBAR_RAIL_FADE) })
2302
+ ]
2303
+ }
2304
+ ) });
2305
+ };
2306
+ var ThemeToggle = () => {
2307
+ const { t } = useTranslation7();
2308
+ const { theme, setTheme } = useTheme();
2309
+ return /* @__PURE__ */ jsxs6(DropdownMenu2.SubMenu, { "data-testid": "sidebar-user-menu-theme-toggle", children: [
2310
+ /* @__PURE__ */ jsxs6(DropdownMenu2.SubMenuTrigger, { dir: "ltr", className: "rounded-md rtl:rotate-180", "data-testid": "sidebar-user-menu-theme-trigger", children: [
2311
+ /* @__PURE__ */ jsx9(CircleHalfSolid, { className: "text-ui-fg-subtle me-2" }),
2312
+ /* @__PURE__ */ jsx9("span", { className: "rtl:rotate-180", children: t("app.menus.user.theme.label") })
2313
+ ] }),
2314
+ /* @__PURE__ */ jsx9(DropdownMenu2.SubMenuContent, { "data-testid": "sidebar-user-menu-theme-content", children: /* @__PURE__ */ jsxs6(DropdownMenu2.RadioGroup, { value: theme, "data-testid": "sidebar-user-menu-theme-radio-group", children: [
2315
+ /* @__PURE__ */ jsx9(
2316
+ DropdownMenu2.RadioItem,
2317
+ {
2318
+ value: "system",
2319
+ onClick: (e) => {
2320
+ e.preventDefault();
2321
+ setTheme("system");
2322
+ },
2323
+ "data-testid": "sidebar-user-menu-theme-system",
2324
+ children: t("app.menus.user.theme.system")
2325
+ }
2326
+ ),
2327
+ /* @__PURE__ */ jsx9(
2328
+ DropdownMenu2.RadioItem,
2329
+ {
2330
+ value: "light",
2331
+ onClick: (e) => {
2332
+ e.preventDefault();
2333
+ setTheme("light");
2334
+ },
2335
+ "data-testid": "sidebar-user-menu-theme-light",
2336
+ children: t("app.menus.user.theme.light")
2337
+ }
2338
+ ),
2339
+ /* @__PURE__ */ jsx9(
2340
+ DropdownMenu2.RadioItem,
2341
+ {
2342
+ value: "dark",
2343
+ onClick: (e) => {
2344
+ e.preventDefault();
2345
+ setTheme("dark");
2346
+ },
2347
+ "data-testid": "sidebar-user-menu-theme-dark",
2348
+ children: t("app.menus.user.theme.dark")
2349
+ }
2350
+ )
2351
+ ] }) })
2352
+ ] });
2353
+ };
2354
+ var Logout = () => {
2355
+ const { t } = useTranslation7();
2356
+ const navigate = useNavigate3();
2357
+ const { mutateAsync: logoutMutation } = useLogout();
2358
+ const handleLogout = async () => {
2359
+ await logoutMutation(void 0, {
2360
+ onSuccess: () => {
2361
+ queryClient.clear();
2362
+ navigate("/login");
2363
+ }
2364
+ });
2365
+ };
2366
+ return /* @__PURE__ */ jsx9(DropdownMenu2.Item, { onClick: handleLogout, "data-testid": "sidebar-user-menu-logout", children: /* @__PURE__ */ jsxs6("div", { className: "flex items-center gap-x-2", children: [
2367
+ /* @__PURE__ */ jsx9(OpenRectArrowOut, { className: "text-ui-fg-subtle" }),
2368
+ /* @__PURE__ */ jsx9("span", { children: t("app.menus.actions.logout") })
2369
+ ] }) });
2370
+ };
2371
+ var GlobalKeybindsModal = (props) => {
2372
+ const { t } = useTranslation7();
2373
+ const globalShortcuts = useGlobalShortcuts();
2374
+ const [searchValue, onSearchValueChange] = useState9("");
2375
+ const searchResults = searchValue ? globalShortcuts.filter((shortcut) => {
2376
+ return shortcut.label.toLowerCase().includes(searchValue?.toLowerCase());
2377
+ }) : globalShortcuts;
2378
+ return /* @__PURE__ */ jsx9(RadixDialog3.Root, { ...props, "data-testid": "shortcuts-modal", children: /* @__PURE__ */ jsxs6(RadixDialog3.Portal, { children: [
2379
+ /* @__PURE__ */ jsx9(RadixDialog3.Overlay, { className: "bg-ui-bg-overlay fixed inset-0", "data-testid": "shortcuts-modal-overlay" }),
2380
+ /* @__PURE__ */ jsxs6(RadixDialog3.Content, { className: "bg-ui-bg-subtle shadow-elevation-modal fixed left-[50%] top-[50%] flex h-full max-h-[612px] w-full max-w-[560px] translate-x-[-50%] translate-y-[-50%] flex-col divide-y overflow-hidden rounded-lg", "data-testid": "shortcuts-modal-content", children: [
2381
+ /* @__PURE__ */ jsxs6("div", { className: "flex flex-col gap-y-3 px-6 py-4", "data-testid": "shortcuts-modal-header", children: [
2382
+ /* @__PURE__ */ jsxs6("div", { className: "flex items-center justify-between", "data-testid": "shortcuts-modal-header-top", children: [
2383
+ /* @__PURE__ */ jsxs6("div", { "data-testid": "shortcuts-modal-title-container", children: [
2384
+ /* @__PURE__ */ jsx9(RadixDialog3.Title, { asChild: true, children: /* @__PURE__ */ jsx9(Heading, { "data-testid": "shortcuts-modal-title", children: t("app.menus.user.shortcuts") }) }),
2385
+ /* @__PURE__ */ jsx9(RadixDialog3.Description, { className: "sr-only", "data-testid": "shortcuts-modal-description" })
2386
+ ] }),
2387
+ /* @__PURE__ */ jsxs6("div", { className: "flex items-center gap-x-2", "data-testid": "shortcuts-modal-close-container", children: [
2388
+ /* @__PURE__ */ jsx9(Kbd3, { "data-testid": "shortcuts-modal-close-hint", children: "esc" }),
2389
+ /* @__PURE__ */ jsx9(RadixDialog3.Close, { asChild: true, children: /* @__PURE__ */ jsx9(IconButton3, { variant: "transparent", size: "small", "data-testid": "shortcuts-modal-close-button", children: /* @__PURE__ */ jsx9(XMark2, {}) }) })
2390
+ ] })
2391
+ ] }),
2392
+ /* @__PURE__ */ jsx9("div", { "data-testid": "shortcuts-modal-search-container", children: /* @__PURE__ */ jsx9(
2393
+ Input,
2394
+ {
2395
+ type: "search",
2396
+ value: searchValue,
2397
+ onChange: (e) => onSearchValueChange(e.target.value),
2398
+ "data-testid": "shortcuts-modal-search"
2399
+ }
2400
+ ) })
2401
+ ] }),
2402
+ /* @__PURE__ */ jsx9("div", { className: "flex flex-col divide-y overflow-y-auto", "data-testid": "shortcuts-modal-list", children: searchResults.map((shortcut, index) => {
2403
+ return /* @__PURE__ */ jsxs6(
2404
+ "div",
2405
+ {
2406
+ className: "text-ui-fg-subtle flex items-center justify-between px-6 py-3",
2407
+ "data-testid": `shortcut-item-${shortcut.label.toLowerCase().replace(/\s/g, "-")}`,
2408
+ children: [
2409
+ /* @__PURE__ */ jsx9(Text4, { size: "small", "data-testid": `shortcut-item-${shortcut.label.toLowerCase().replace(/\s/g, "-")}-label`, children: shortcut.label }),
2410
+ /* @__PURE__ */ jsx9("div", { className: "flex items-center gap-x-1", "data-testid": `shortcut-item-${shortcut.label.toLowerCase().replace(/\s/g, "-")}-keys`, children: shortcut.keys.Mac?.map((key, index2) => {
2411
+ return /* @__PURE__ */ jsxs6("div", { className: "flex items-center gap-x-1", "data-testid": `shortcut-item-${shortcut.label.toLowerCase().replace(/\s/g, "-")}-key-${index2}`, children: [
2412
+ /* @__PURE__ */ jsx9(Kbd3, { "data-testid": `shortcut-item-${shortcut.label.toLowerCase().replace(/\s/g, "-")}-kbd-${index2}`, children: key }),
2413
+ index2 < (shortcut.keys.Mac?.length || 0) - 1 && /* @__PURE__ */ jsx9("span", { className: "txt-compact-xsmall text-ui-fg-subtle", "data-testid": `shortcut-item-${shortcut.label.toLowerCase().replace(/\s/g, "-")}-separator-${index2}`, children: t("app.keyboardShortcuts.then") })
2414
+ ] }, index2);
2415
+ }) })
2416
+ ]
2417
+ },
2418
+ index
2419
+ );
2420
+ }) })
2421
+ ] })
2422
+ ] }) });
2423
+ };
2424
+ var UserItem = () => {
2425
+ const { user, isPending, isError, error } = useMe();
2426
+ const loaded = !isPending && !!user;
2427
+ if (!loaded) {
2428
+ return /* @__PURE__ */ jsx9("div", {});
2429
+ }
2430
+ const name = [user.first_name, user.last_name].filter(Boolean).join(" ");
2431
+ const email = user.email;
2432
+ const fallback = name ? name[0].toUpperCase() : email[0].toUpperCase();
2433
+ const avatar = user.avatar_url;
2434
+ if (isError) {
2435
+ throw error;
2436
+ }
2437
+ return /* @__PURE__ */ jsxs6("div", { className: "flex items-center gap-x-3 overflow-hidden px-2 py-1", "data-testid": "sidebar-user-menu-item", children: [
2438
+ /* @__PURE__ */ jsx9(
2439
+ Avatar,
2440
+ {
2441
+ size: "small",
2442
+ variant: "rounded",
2443
+ src: avatar || void 0,
2444
+ fallback,
2445
+ "data-testid": "sidebar-user-menu-item-avatar"
2446
+ }
2447
+ ),
2448
+ /* @__PURE__ */ jsxs6("div", { className: "block w-full min-w-0 max-w-[187px] overflow-hidden whitespace-nowrap", "data-testid": "sidebar-user-menu-item-details", children: [
2449
+ /* @__PURE__ */ jsx9(
2450
+ Text4,
2451
+ {
2452
+ size: "small",
2453
+ weight: "plus",
2454
+ leading: "compact",
2455
+ className: "overflow-hidden text-ellipsis whitespace-nowrap",
2456
+ "data-testid": "sidebar-user-menu-item-name",
2457
+ children: name || email
2458
+ }
2459
+ ),
2460
+ !!name && /* @__PURE__ */ jsx9(
2461
+ Text4,
2462
+ {
2463
+ size: "xsmall",
2464
+ leading: "compact",
2465
+ className: "text-ui-fg-subtle overflow-hidden text-ellipsis whitespace-nowrap",
2466
+ "data-testid": "sidebar-user-menu-item-email",
2467
+ children: email
2468
+ }
2469
+ )
2470
+ ] })
2471
+ ] });
2472
+ };
2473
+
2474
+ // src/components/layout/main-layout/main-layout.tsx
2475
+ import menuItemsModule from "virtual:mercur/menu-items";
2476
+ import {
2477
+ applyNavOverrides,
2478
+ groupNavItems,
2479
+ useExtension,
2480
+ usePermissions as usePermissions2
2481
+ } from "@mercurjs/dashboard-shared";
2482
+ import { jsx as jsx10, jsxs as jsxs7 } from "react/jsx-runtime";
2483
+ var navId = (to) => to.replace(/^\//, "");
2484
+ var toCoreNavItem = (route) => ({
2485
+ id: navId(route.to),
2486
+ label: route.label,
2487
+ to: route.to,
2488
+ icon: route.icon,
2489
+ items: route.items?.map((item) => ({
2490
+ id: navId(item.to),
2491
+ label: item.label,
2492
+ to: item.to
2493
+ }))
2494
+ });
2495
+ var MainLayout = () => {
2496
+ return /* @__PURE__ */ jsx10(Shell, { children: /* @__PURE__ */ jsx10(MainSidebar, {}) });
2497
+ };
2498
+ var allMenuItems = menuItemsModule.menuItems ?? [];
2499
+ var addNestedItems = (to, menuItems, items) => {
2500
+ const nestedItems = getNestedMenuItems(menuItems, to);
2501
+ if (nestedItems.length === 0) {
2502
+ return items;
2503
+ }
2504
+ const nestedNavItems = nestedItems.map((item) => ({
2505
+ label: item.label,
2506
+ to: item.path,
2507
+ translationNs: item.translationNs
2508
+ }));
2509
+ return [...items ?? [], ...nestedNavItems];
2510
+ };
2511
+ var useSidebarRoutes = () => {
2512
+ const coreRoutes = useCoreRoutes();
2513
+ const extension = useExtension();
2514
+ const navOverrides = extension.getNavOverrides();
2515
+ const permissions = usePermissions2();
2516
+ const { hasAnyPermission, hasAllPermissions } = permissions;
2517
+ const canReach = ({ to }) => canReachRoute(permissions, to);
2518
+ const visibleMenuItems = useMemo4(
2519
+ () => filterMenuItemsByPermissions(allMenuItems, {
2520
+ hasAnyPermission,
2521
+ hasAllPermissions
2522
+ }),
2523
+ [hasAnyPermission, hasAllPermissions]
2524
+ );
2525
+ const customMenuItems = getMenuItemsByType(visibleMenuItems, "main");
2526
+ const routesWithNested = applyNavOverrides(
2527
+ coreRoutes.map(toCoreNavItem),
2528
+ navOverrides
2529
+ ).filter(canReach).map((route) => ({
2530
+ ...route,
2531
+ items: addNestedItems(route.to, visibleMenuItems, route.items)?.filter(
2532
+ canReach
2533
+ )
2534
+ }));
2535
+ const customRoutesWithNested = customMenuItems.sort((a, b) => (a.rank ?? 0) - (b.rank ?? 0)).map((item) => ({
2536
+ label: item.label,
2537
+ to: item.path,
2538
+ icon: item.icon ? /* @__PURE__ */ jsx10(item.icon, {}) : void 0,
2539
+ translationNs: item.translationNs,
2540
+ group: item.group,
2541
+ items: addNestedItems(item.path, visibleMenuItems)
2542
+ }));
2543
+ const groupById = new Map(
2544
+ navOverrides.map((o) => [o.id, o.group])
2545
+ );
2546
+ return groupNavItems(
2547
+ [
2548
+ ...routesWithNested.map((route) => ({
2549
+ ...route,
2550
+ group: groupById.get(route.id)
2551
+ })),
2552
+ ...customRoutesWithNested
2553
+ ],
2554
+ extension.getNavGroups()
2555
+ );
2556
+ };
2557
+ var useLandingRoute = () => {
2558
+ const { ungrouped, groups } = useSidebarRoutes();
2559
+ const first = [...ungrouped, ...groups.flatMap((group) => group.items)][0];
2560
+ return first?.to ?? "/settings/profile";
2561
+ };
2562
+ var MainSidebar = () => {
2563
+ const { ungrouped, groups } = useSidebarRoutes();
2564
+ return /* @__PURE__ */ jsx10(
2565
+ "aside",
2566
+ {
2567
+ className: "flex flex-1 flex-col justify-between overflow-y-auto overflow-x-hidden",
2568
+ "data-testid": "sidebar",
2569
+ children: /* @__PURE__ */ jsxs7("div", { className: "flex flex-1 flex-col", children: [
2570
+ /* @__PURE__ */ jsxs7(
2571
+ "div",
2572
+ {
2573
+ className: "sticky top-0 bg-ui-bg-subtle",
2574
+ "data-testid": "sidebar-header-section",
2575
+ children: [
2576
+ /* @__PURE__ */ jsx10(Header, {}),
2577
+ /* @__PURE__ */ jsx10("div", { className: "px-3", children: /* @__PURE__ */ jsx10(Divider, { variant: "dashed" }) })
2578
+ ]
2579
+ }
2580
+ ),
2581
+ /* @__PURE__ */ jsxs7("div", { className: "flex flex-1 flex-col justify-between", children: [
2582
+ /* @__PURE__ */ jsxs7("div", { className: "flex flex-1 flex-col", children: [
2583
+ /* @__PURE__ */ jsxs7(
2584
+ "nav",
2585
+ {
2586
+ className: "flex flex-col gap-y-1 py-3",
2587
+ "data-testid": "sidebar-core-routes",
2588
+ children: [
2589
+ /* @__PURE__ */ jsx10(Searchbar, {}),
2590
+ ungrouped.map((route) => /* @__PURE__ */ jsx10(NavItem, { ...route }, route.to))
2591
+ ]
2592
+ }
2593
+ ),
2594
+ groups.map((group) => /* @__PURE__ */ jsxs7(Fragment2, { children: [
2595
+ /* @__PURE__ */ jsx10("div", { className: "px-3", children: /* @__PURE__ */ jsx10(Divider, { variant: "dashed" }) }),
2596
+ /* @__PURE__ */ jsx10(SidebarGroup, { group })
2597
+ ] }, group.id))
2598
+ ] }),
2599
+ /* @__PURE__ */ jsx10(UtilitySection, {})
2600
+ ] }),
2601
+ /* @__PURE__ */ jsx10(
2602
+ "div",
2603
+ {
2604
+ className: "sticky bottom-0 bg-ui-bg-subtle",
2605
+ "data-testid": "sidebar-user-section",
2606
+ children: /* @__PURE__ */ jsx10(UserSection, {})
2607
+ }
2608
+ )
2609
+ ] })
2610
+ }
2611
+ );
2612
+ };
2613
+ var SidebarGroup = ({ group }) => {
2614
+ const { t } = useTranslation8(group.translationNs);
2615
+ return /* @__PURE__ */ jsxs7(
2616
+ RadixCollapsible2.Root,
2617
+ {
2618
+ defaultOpen: true,
2619
+ className: "py-3",
2620
+ "data-testid": `sidebar-group-${group.id}`,
2621
+ children: [
2622
+ /* @__PURE__ */ jsx10("div", { className: "px-3", children: /* @__PURE__ */ jsxs7(
2623
+ "div",
2624
+ {
2625
+ className: clx5(
2626
+ "flex h-7 items-center justify-between overflow-hidden whitespace-nowrap px-2 text-ui-fg-muted",
2627
+ SIDEBAR_RAIL_FADE
2628
+ ),
2629
+ children: [
2630
+ /* @__PURE__ */ jsx10(Text5, { size: "small", leading: "compact", children: group.translationNs ? t(group.label) : group.label }),
2631
+ /* @__PURE__ */ jsx10(RadixCollapsible2.Trigger, { asChild: true, children: /* @__PURE__ */ jsx10(
2632
+ IconButton4,
2633
+ {
2634
+ size: "2xsmall",
2635
+ variant: "transparent",
2636
+ className: "static",
2637
+ "data-testid": `sidebar-group-${group.id}-toggle`,
2638
+ children: /* @__PURE__ */ jsx10(MinusMini, { className: "text-ui-fg-muted" })
2639
+ }
2640
+ ) })
2641
+ ]
2642
+ }
2643
+ ) }),
2644
+ /* @__PURE__ */ jsx10(RadixCollapsible2.Content, { children: /* @__PURE__ */ jsx10("div", { className: "pt-0.5", children: /* @__PURE__ */ jsx10("nav", { className: "flex flex-col gap-y-1", children: group.items.map((route) => /* @__PURE__ */ jsx10(NavItem, { ...route }, route.to)) }) }) })
2645
+ ]
2646
+ }
2647
+ );
2648
+ };
2649
+ var Logout2 = () => {
2650
+ const { t } = useTranslation8();
2651
+ const navigate = useNavigate4();
2652
+ const { mutateAsync: logoutMutation } = useLogout();
2653
+ const handleLogout = async () => {
2654
+ await logoutMutation(void 0, {
2655
+ onSuccess: () => {
2656
+ queryClient.clear();
2657
+ navigate("/login");
2658
+ }
2659
+ });
2660
+ };
2661
+ return /* @__PURE__ */ jsx10(
2662
+ DropdownMenu3.Item,
2663
+ {
2664
+ onClick: handleLogout,
2665
+ "data-testid": "sidebar-header-dropdown-logout",
2666
+ children: /* @__PURE__ */ jsxs7("div", { className: "flex items-center gap-x-2", children: [
2667
+ /* @__PURE__ */ jsx10(OpenRectArrowOut2, { className: "text-ui-fg-subtle" }),
2668
+ /* @__PURE__ */ jsx10("span", { children: t("app.menus.actions.logout") })
2669
+ ] })
2670
+ }
2671
+ );
2672
+ };
2673
+ var Header = () => {
2674
+ const { t } = useTranslation8();
2675
+ const { store, isPending, isError, error } = useStore();
2676
+ const direction = useDocumentDirection();
2677
+ const menuPlacement = useSidebarMenuPlacement("start");
2678
+ const name = store?.name;
2679
+ const fallback = store?.name?.slice(0, 1).toUpperCase();
2680
+ const isLoaded = !isPending && !!store && !!name && !!fallback;
2681
+ if (isError) {
2682
+ throw error;
2683
+ }
2684
+ return /* @__PURE__ */ jsx10("div", { className: "w-full p-3", "data-testid": "sidebar-header-dropdown", children: /* @__PURE__ */ jsxs7(DropdownMenu3, { dir: direction, "data-testid": "sidebar-header-dropdown-menu", children: [
2685
+ /* @__PURE__ */ jsxs7(
2686
+ DropdownMenu3.Trigger,
2687
+ {
2688
+ disabled: !isLoaded,
2689
+ className: clx5(
2690
+ "grid w-full grid-cols-[24px_1fr_15px] items-center gap-x-3 rounded-md bg-ui-bg-subtle p-0.5 pe-2 outline-none transition-fg",
2691
+ "hover:bg-ui-bg-subtle-hover",
2692
+ "data-[state=open]:bg-ui-bg-subtle-hover",
2693
+ "focus-visible:shadow-borders-focus"
2694
+ ),
2695
+ "data-testid": "sidebar-header-dropdown-trigger",
2696
+ children: [
2697
+ fallback ? /* @__PURE__ */ jsx10(
2698
+ Avatar2,
2699
+ {
2700
+ variant: "squared",
2701
+ size: "xsmall",
2702
+ fallback,
2703
+ "data-testid": "sidebar-header-dropdown-avatar"
2704
+ }
2705
+ ) : /* @__PURE__ */ jsx10(Skeleton, { className: "h-6 w-6 rounded-md" }),
2706
+ /* @__PURE__ */ jsx10(
2707
+ "div",
2708
+ {
2709
+ className: clx5("block overflow-hidden whitespace-nowrap text-start", SIDEBAR_RAIL_FADE),
2710
+ "data-testid": "sidebar-header-dropdown-store-name",
2711
+ children: name ? /* @__PURE__ */ jsx10(
2712
+ Text5,
2713
+ {
2714
+ size: "small",
2715
+ weight: "plus",
2716
+ leading: "compact",
2717
+ className: "truncate",
2718
+ children: store.name
2719
+ }
2720
+ ) : /* @__PURE__ */ jsx10(Skeleton, { className: "h-[9px] w-[120px]" })
2721
+ }
2722
+ ),
2723
+ /* @__PURE__ */ jsx10(EllipsisHorizontal2, { className: clx5("text-ui-fg-muted", SIDEBAR_RAIL_FADE) })
2724
+ ]
2725
+ }
2726
+ ),
2727
+ isLoaded && /* @__PURE__ */ jsxs7(
2728
+ DropdownMenu3.Content,
2729
+ {
2730
+ ...menuPlacement,
2731
+ className: SIDEBAR_MENU_CONTENT,
2732
+ "data-testid": "sidebar-header-dropdown-content",
2733
+ children: [
2734
+ /* @__PURE__ */ jsxs7(
2735
+ "div",
2736
+ {
2737
+ className: "flex items-center gap-x-3 px-2 py-1",
2738
+ "data-testid": "sidebar-header-dropdown-user-info",
2739
+ children: [
2740
+ /* @__PURE__ */ jsx10(
2741
+ Avatar2,
2742
+ {
2743
+ variant: "squared",
2744
+ size: "small",
2745
+ fallback,
2746
+ "data-testid": "sidebar-header-dropdown-user-avatar"
2747
+ }
2748
+ ),
2749
+ /* @__PURE__ */ jsxs7(
2750
+ "div",
2751
+ {
2752
+ className: "flex flex-col overflow-hidden",
2753
+ "data-testid": "sidebar-header-dropdown-user-details",
2754
+ children: [
2755
+ /* @__PURE__ */ jsx10(
2756
+ Text5,
2757
+ {
2758
+ size: "small",
2759
+ weight: "plus",
2760
+ leading: "compact",
2761
+ className: "truncate",
2762
+ "data-testid": "sidebar-header-dropdown-user-name",
2763
+ children: name
2764
+ }
2765
+ ),
2766
+ /* @__PURE__ */ jsx10(
2767
+ Text5,
2768
+ {
2769
+ size: "xsmall",
2770
+ leading: "compact",
2771
+ className: "text-ui-fg-subtle",
2772
+ "data-testid": "sidebar-header-dropdown-store-label",
2773
+ children: t("app.nav.main.marketplace")
2774
+ }
2775
+ )
2776
+ ]
2777
+ }
2778
+ )
2779
+ ]
2780
+ }
2781
+ ),
2782
+ /* @__PURE__ */ jsx10(DropdownMenu3.Separator, { "data-testid": "sidebar-header-dropdown-separator-1" }),
2783
+ /* @__PURE__ */ jsx10(
2784
+ DropdownMenu3.Item,
2785
+ {
2786
+ className: "gap-x-2",
2787
+ asChild: true,
2788
+ "data-testid": "sidebar-header-dropdown-store-settings",
2789
+ children: /* @__PURE__ */ jsxs7(Link3, { to: "/settings/marketplace", children: [
2790
+ /* @__PURE__ */ jsx10(BuildingStorefront, { className: "text-ui-fg-subtle" }),
2791
+ t("app.nav.main.marketplaceSettings")
2792
+ ] })
2793
+ }
2794
+ ),
2795
+ /* @__PURE__ */ jsx10(DropdownMenu3.Separator, { "data-testid": "sidebar-header-dropdown-separator-2" }),
2796
+ /* @__PURE__ */ jsx10(Logout2, {})
2797
+ ]
2798
+ }
2799
+ )
2800
+ ] }) });
2801
+ };
2802
+ var useCoreRoutes = () => {
2803
+ const { t } = useTranslation8();
2804
+ return [
2805
+ {
2806
+ icon: /* @__PURE__ */ jsx10(ShoppingCart, {}),
2807
+ label: t("orders.domain"),
2808
+ to: "/orders",
2809
+ items: [
2810
+ // TODO: Enable when domin is introduced
2811
+ // {
2812
+ // label: t("draftOrders.domain"),
2813
+ // to: "/draft-orders",
2814
+ // },
2815
+ ]
2816
+ },
2817
+ {
2818
+ icon: /* @__PURE__ */ jsx10(Tag, {}),
2819
+ label: t("products.domain"),
2820
+ to: "/products",
2821
+ items: [
2822
+ {
2823
+ label: t("offers.domain"),
2824
+ to: "/offers"
2825
+ },
2826
+ {
2827
+ label: t("collections.domain"),
2828
+ to: "/collections"
2829
+ },
2830
+ {
2831
+ label: t("categories.domain"),
2832
+ to: "/categories"
2833
+ }
2834
+ // TODO: Enable when domin is introduced
2835
+ // {
2836
+ // label: t("giftCards.domain"),
2837
+ // to: "/gift-cards",
2838
+ // },
2839
+ ]
2840
+ },
2841
+ {
2842
+ icon: /* @__PURE__ */ jsx10(Buildings, {}),
2843
+ label: t("inventory.domain"),
2844
+ to: "/inventory",
2845
+ items: [
2846
+ {
2847
+ label: t("reservations.domain"),
2848
+ to: "/reservations"
2849
+ }
2850
+ ]
2851
+ },
2852
+ {
2853
+ icon: /* @__PURE__ */ jsx10(Users, {}),
2854
+ label: t("customers.domain"),
2855
+ to: "/customers",
2856
+ items: [
2857
+ {
2858
+ label: t("customerGroups.domain"),
2859
+ to: "/customer-groups"
2860
+ }
2861
+ ]
2862
+ },
2863
+ {
2864
+ icon: /* @__PURE__ */ jsx10(ReceiptPercent, {}),
2865
+ label: t("promotions.domain"),
2866
+ to: "/promotions",
2867
+ items: [
2868
+ {
2869
+ label: t("campaigns.domain"),
2870
+ to: "/campaigns"
2871
+ }
2872
+ ]
2873
+ },
2874
+ {
2875
+ icon: /* @__PURE__ */ jsx10(CurrencyDollar, {}),
2876
+ label: t("priceLists.domain"),
2877
+ to: "/price-lists"
2878
+ },
2879
+ {
2880
+ icon: /* @__PURE__ */ jsx10(BuildingStorefront, {}),
2881
+ label: t("stores.domain"),
2882
+ to: "/stores",
2883
+ items: [
2884
+ {
2885
+ label: t("reviews.domain"),
2886
+ to: "/reviews"
2887
+ }
2888
+ ]
2889
+ },
2890
+ {
2891
+ icon: /* @__PURE__ */ jsx10(CreditCardRefresh, {}),
2892
+ label: t("payouts.domain"),
2893
+ to: "/payouts"
2894
+ }
2895
+ ];
2896
+ };
2897
+ var Searchbar = () => {
2898
+ const { t } = useTranslation8();
2899
+ const { toggleSearch } = useSearch();
2900
+ return /* @__PURE__ */ jsx10("div", { className: "px-3", "data-testid": "sidebar-search", children: /* @__PURE__ */ jsxs7(
2901
+ "button",
2902
+ {
2903
+ onClick: toggleSearch,
2904
+ className: clx5(
2905
+ "flex w-full items-center gap-x-2.5 rounded-md bg-ui-bg-subtle px-2 py-1 text-ui-fg-subtle outline-none transition-[padding] duration-200 ease-sidebar motion-reduce:transition-none group-data-[state=collapsed]/sidebar:px-1",
2906
+ "hover:bg-ui-bg-subtle-hover",
2907
+ "focus-visible:shadow-borders-focus"
2908
+ ),
2909
+ "data-testid": "sidebar-search-button",
2910
+ children: [
2911
+ /* @__PURE__ */ jsx10(MagnifyingGlass2, { className: "shrink-0" }),
2912
+ /* @__PURE__ */ jsx10("div", { className: clx5("flex-1 whitespace-nowrap text-start", SIDEBAR_RAIL_FADE), children: /* @__PURE__ */ jsx10(Text5, { size: "small", leading: "compact", weight: "plus", children: t("app.search.label") }) }),
2913
+ /* @__PURE__ */ jsx10(Text5, { size: "small", leading: "compact", className: clx5("text-ui-fg-muted", SIDEBAR_RAIL_FADE), children: "\u2318K" })
2914
+ ]
2915
+ }
2916
+ ) });
2917
+ };
2918
+ var UtilitySection = () => {
2919
+ const location = useLocation5();
2920
+ const { t } = useTranslation8();
2921
+ return /* @__PURE__ */ jsx10("div", { className: "flex flex-col gap-y-0.5 py-3", children: /* @__PURE__ */ jsx10(
2922
+ NavItem,
2923
+ {
2924
+ label: t("app.nav.settings.header"),
2925
+ to: "/settings",
2926
+ from: location.pathname,
2927
+ icon: /* @__PURE__ */ jsx10(CogSixTooth, {})
2928
+ }
2929
+ ) });
2930
+ };
2931
+ var UserSection = () => {
2932
+ return /* @__PURE__ */ jsxs7("div", { children: [
2933
+ /* @__PURE__ */ jsx10("div", { className: "px-3", children: /* @__PURE__ */ jsx10(Divider, { variant: "dashed" }) }),
2934
+ /* @__PURE__ */ jsx10(UserMenu, {})
2935
+ ] });
2936
+ };
2937
+
2938
+ export {
2939
+ ThemeProvider,
2940
+ SidebarProvider,
2941
+ useExpandedSidebar,
2942
+ canReachRoute,
2943
+ SearchProvider,
2944
+ NavItem,
2945
+ Shell,
2946
+ UserMenu,
2947
+ ErrorBoundary,
2948
+ createRouteMap,
2949
+ getRoutesByType,
2950
+ getMenuItemsByType,
2951
+ filterMenuItemsByPermissions,
2952
+ MainLayout,
2953
+ useLandingRoute
2954
+ };