@salla.sa/twilight-theme-engine 1.0.111 → 1.0.113

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 (267) hide show
  1. package/dist/{AddToCartForm-LQUGORMR.js → AddToCartForm-2QHYDDSR.js} +3 -3
  2. package/dist/{AddToCartForm-LQUGORMR.js.map → AddToCartForm-2QHYDDSR.js.map} +1 -1
  3. package/dist/{BlogAuthorPage-CNZRXDPQ.js → BlogAuthorPage-VYXM5U3T.js} +28 -28
  4. package/dist/{BlogAuthorPage-CNZRXDPQ.js.map → BlogAuthorPage-VYXM5U3T.js.map} +1 -1
  5. package/dist/{BlogCategoryPage-MO5XBW4Z.js → BlogCategoryPage-ZPUSHJCU.js} +28 -28
  6. package/dist/{BlogCategoryPage-MO5XBW4Z.js.map → BlogCategoryPage-ZPUSHJCU.js.map} +1 -1
  7. package/dist/{BlogPage-EJZRH3YO.js → BlogPage-DR4V5LJX.js} +26 -26
  8. package/dist/{BlogPage-EJZRH3YO.js.map → BlogPage-DR4V5LJX.js.map} +1 -1
  9. package/dist/{BlogSinglePage-LO6O2MFG.js → BlogSinglePage-3N3J245D.js} +26 -26
  10. package/dist/{BlogSinglePage-LO6O2MFG.js.map → BlogSinglePage-3N3J245D.js.map} +1 -1
  11. package/dist/{BlogTagPage-HL6HTJ4I.js → BlogTagPage-CDVZT6RU.js} +28 -28
  12. package/dist/{BlogTagPage-HL6HTJ4I.js.map → BlogTagPage-CDVZT6RU.js.map} +1 -1
  13. package/dist/{BrandsPage-T6APSLYK.js → BrandsPage-5HF3XIJL.js} +27 -27
  14. package/dist/{BrandsPage-T6APSLYK.js.map → BrandsPage-5HF3XIJL.js.map} +1 -1
  15. package/dist/{Breadcrumb-W7JBOHPB.js → Breadcrumb-E5Q5PVSO.js} +26 -26
  16. package/dist/{Breadcrumb-W7JBOHPB.js.map → Breadcrumb-E5Q5PVSO.js.map} +1 -1
  17. package/dist/{CartItem-UELEXBHU.js → CartItem-CV7PUPXD.js} +26 -26
  18. package/dist/{CartItem-UELEXBHU.js.map → CartItem-CV7PUPXD.js.map} +1 -1
  19. package/dist/{CartSummary-6L6TXZOF.js → CartSummary-JZXPVR67.js} +26 -26
  20. package/dist/{CartSummary-6L6TXZOF.js.map → CartSummary-JZXPVR67.js.map} +1 -1
  21. package/dist/{Copyright-YAIOATPE.js → Copyright-YDWUDCKS.js} +3 -3
  22. package/dist/{Copyright-YAIOATPE.js.map → Copyright-YDWUDCKS.js.map} +1 -1
  23. package/dist/{CustomerLayout-4XKCLHWW.js → CustomerLayout-7XCEWCDO.js} +26 -26
  24. package/dist/{CustomerLayout-4XKCLHWW.js.map → CustomerLayout-7XCEWCDO.js.map} +1 -1
  25. package/dist/{Footer-UHLNZNUZ.js → Footer-FANYENUN.js} +4 -4
  26. package/dist/{Footer-UHLNZNUZ.js.map → Footer-FANYENUN.js.map} +1 -1
  27. package/dist/Header-XFY3BWV2.js +22 -0
  28. package/dist/{Header-M3Q7KDF5.js.map → Header-XFY3BWV2.js.map} +1 -1
  29. package/dist/{LoyaltyPage-MUEAIXZJ.js → LoyaltyPage-HZASEZXX.js} +26 -26
  30. package/dist/{LoyaltyPage-MUEAIXZJ.js.map → LoyaltyPage-HZASEZXX.js.map} +1 -1
  31. package/dist/{LoyaltyPointsPage-GECERR3Q.js → LoyaltyPointsPage-6VPCZVUO.js} +9 -9
  32. package/dist/{LoyaltyPointsPage-GECERR3Q.js.map → LoyaltyPointsPage-6VPCZVUO.js.map} +1 -1
  33. package/dist/{MainMenu-ZQLKN43L.js → MainMenu-ZOP6ESHR.js} +8 -8
  34. package/dist/{MainMenu-ZQLKN43L.js.map → MainMenu-ZOP6ESHR.js.map} +1 -1
  35. package/dist/MaintenancePage-7Y4QA5LD.js +7 -0
  36. package/dist/{MaintenancePage-UBJ5Q3L5.js.map → MaintenancePage-7Y4QA5LD.js.map} +1 -1
  37. package/dist/MasterLayout-UR6MGE2Q.js +54 -0
  38. package/dist/{MasterLayout-KVMF2U5Z.js.map → MasterLayout-UR6MGE2Q.js.map} +1 -1
  39. package/dist/{MobileMenu-GPVASHD2.js → MobileMenu-NJUO7Y36.js} +27 -27
  40. package/dist/{MobileMenu-GPVASHD2.js.map → MobileMenu-NJUO7Y36.js.map} +1 -1
  41. package/dist/{NotificationsPage-5GQIDZH4.js → NotificationsPage-IWCKW3EV.js} +26 -26
  42. package/dist/{NotificationsPage-5GQIDZH4.js.map → NotificationsPage-IWCKW3EV.js.map} +1 -1
  43. package/dist/{OrderSinglePage-6BCHQ3YG.js → OrderSinglePage-JZWJ2GBH.js} +27 -27
  44. package/dist/{OrderSinglePage-6BCHQ3YG.js.map → OrderSinglePage-JZWJ2GBH.js.map} +1 -1
  45. package/dist/{OrdersPage-BPKE45CP.js → OrdersPage-M7UFWWH6.js} +26 -26
  46. package/dist/{OrdersPage-BPKE45CP.js.map → OrdersPage-M7UFWWH6.js.map} +1 -1
  47. package/dist/{PageSingle-7BM4FJBH.js → PageSingle-ZJCRWIBB.js} +7 -7
  48. package/dist/{PageSingle-7BM4FJBH.js.map → PageSingle-ZJCRWIBB.js.map} +1 -1
  49. package/dist/{ProductDetails-L65HAYDG.js → ProductDetails-BN36YHSM.js} +8 -8
  50. package/dist/{ProductDetails-L65HAYDG.js.map → ProductDetails-BN36YHSM.js.map} +1 -1
  51. package/dist/{ProfilePage-IYGXRJQJ.js → ProfilePage-FVHXZZQC.js} +26 -26
  52. package/dist/{ProfilePage-IYGXRJQJ.js.map → ProfilePage-FVHXZZQC.js.map} +1 -1
  53. package/dist/{ReviewsPage-6AOYLTID.js → ReviewsPage-WLKU2IPF.js} +3 -3
  54. package/dist/{ReviewsPage-6AOYLTID.js.map → ReviewsPage-WLKU2IPF.js.map} +1 -1
  55. package/dist/{SeoCartWidget-ANNRB6E7.js → SeoCartWidget-A3CJPENY.js} +26 -26
  56. package/dist/{SeoCartWidget-ANNRB6E7.js.map → SeoCartWidget-A3CJPENY.js.map} +1 -1
  57. package/dist/{SettingsPage-ZRC7YUIB.js → SettingsPage-MPJFT64A.js} +26 -26
  58. package/dist/{SettingsPage-ZRC7YUIB.js.map → SettingsPage-MPJFT64A.js.map} +1 -1
  59. package/dist/StoreClosedNotification-MCNOQKFD.js +55 -0
  60. package/dist/{StoreClosedNotification-TL32ZXVT.js.map → StoreClosedNotification-MCNOQKFD.js.map} +1 -1
  61. package/dist/{TestimonialsPage-BEMMOE3M.js → TestimonialsPage-JAJOAI7A.js} +7 -7
  62. package/dist/{TestimonialsPage-BEMMOE3M.js.map → TestimonialsPage-JAJOAI7A.js.map} +1 -1
  63. package/dist/{ThankYouPage-ZMHWJAWO.js → ThankYouPage-KS25YF2G.js} +26 -26
  64. package/dist/{ThankYouPage-ZMHWJAWO.js.map → ThankYouPage-KS25YF2G.js.map} +1 -1
  65. package/dist/{WalletPage-WSPMXC2P.js → WalletPage-ANE5FDL6.js} +27 -27
  66. package/dist/{WalletPage-WSPMXC2P.js.map → WalletPage-ANE5FDL6.js.map} +1 -1
  67. package/dist/{WishlistPage-G5O25DM5.js → WishlistPage-IG5BBBCY.js} +28 -28
  68. package/dist/{WishlistPage-G5O25DM5.js.map → WishlistPage-IG5BBBCY.js.map} +1 -1
  69. package/dist/api/advertisement.js +5 -5
  70. package/dist/api/apps.js +5 -5
  71. package/dist/api/blog.js +7 -7
  72. package/dist/api/brands.js +7 -7
  73. package/dist/api/cart.js +7 -7
  74. package/dist/api/category.js +7 -7
  75. package/dist/api/client.js +4 -4
  76. package/dist/api/home.js +5 -5
  77. package/dist/api/loyalty.js +7 -7
  78. package/dist/api/menu.js +5 -5
  79. package/dist/api/notification.js +5 -5
  80. package/dist/api/order.js +7 -7
  81. package/dist/api/page.js +7 -7
  82. package/dist/api/product.js +7 -7
  83. package/dist/api/profile.js +4 -4
  84. package/dist/api/store.d.ts.map +1 -1
  85. package/dist/api/store.js +5 -5
  86. package/dist/api/translations.js +5 -5
  87. package/dist/api/user.js +5 -5
  88. package/dist/api/wallet.js +5 -5
  89. package/dist/api/wishlist.js +8 -8
  90. package/dist/{chunk-UAMMJPLQ.js → chunk-2J5AW75K.js} +23 -23
  91. package/dist/{chunk-UAMMJPLQ.js.map → chunk-2J5AW75K.js.map} +1 -1
  92. package/dist/{chunk-X2JCU7GY.js → chunk-3GDJMMMS.js} +3 -3
  93. package/dist/{chunk-X2JCU7GY.js.map → chunk-3GDJMMMS.js.map} +1 -1
  94. package/dist/{chunk-ZBFTBK4B.js → chunk-3SYYPERF.js} +21 -18
  95. package/dist/chunk-3SYYPERF.js.map +1 -0
  96. package/dist/{chunk-ZDKQL2E4.js → chunk-4TM54PZO.js} +4 -4
  97. package/dist/{chunk-ZDKQL2E4.js.map → chunk-4TM54PZO.js.map} +1 -1
  98. package/dist/{chunk-ZRT6L6TC.js → chunk-5CEVDCMY.js} +3 -3
  99. package/dist/{chunk-ZRT6L6TC.js.map → chunk-5CEVDCMY.js.map} +1 -1
  100. package/dist/{chunk-I7WSIN27.js → chunk-5FJFN3IW.js} +3 -3
  101. package/dist/{chunk-I7WSIN27.js.map → chunk-5FJFN3IW.js.map} +1 -1
  102. package/dist/{chunk-6NV6T24C.js → chunk-5G6PD6P2.js} +4 -4
  103. package/dist/{chunk-6NV6T24C.js.map → chunk-5G6PD6P2.js.map} +1 -1
  104. package/dist/{chunk-FNM2OUPD.js → chunk-6D3OWIEC.js} +11 -6
  105. package/dist/chunk-6D3OWIEC.js.map +1 -0
  106. package/dist/{chunk-IRK7HSN6.js → chunk-6V4TKT7O.js} +7 -7
  107. package/dist/{chunk-IRK7HSN6.js.map → chunk-6V4TKT7O.js.map} +1 -1
  108. package/dist/{chunk-FMSRB2TT.js → chunk-74W2O47D.js} +4 -4
  109. package/dist/{chunk-FMSRB2TT.js.map → chunk-74W2O47D.js.map} +1 -1
  110. package/dist/{chunk-56OZRZIZ.js → chunk-75TXHISE.js} +4 -4
  111. package/dist/{chunk-56OZRZIZ.js.map → chunk-75TXHISE.js.map} +1 -1
  112. package/dist/{chunk-YYMKDBZV.js → chunk-7AIDISU2.js} +3 -3
  113. package/dist/{chunk-YYMKDBZV.js.map → chunk-7AIDISU2.js.map} +1 -1
  114. package/dist/{chunk-EJLVOWXU.js → chunk-7EZZR4WA.js} +5 -5
  115. package/dist/{chunk-EJLVOWXU.js.map → chunk-7EZZR4WA.js.map} +1 -1
  116. package/dist/{chunk-GAGTCI3J.js → chunk-7QHK77KL.js} +5 -5
  117. package/dist/{chunk-GAGTCI3J.js.map → chunk-7QHK77KL.js.map} +1 -1
  118. package/dist/{chunk-QRHXAKJ3.js → chunk-7VNVCHID.js} +8 -3
  119. package/dist/chunk-7VNVCHID.js.map +1 -0
  120. package/dist/{chunk-3ANDBTKR.js → chunk-BLTF544K.js} +4 -4
  121. package/dist/{chunk-3ANDBTKR.js.map → chunk-BLTF544K.js.map} +1 -1
  122. package/dist/{chunk-MEMJOJO4.js → chunk-BVMHRVCG.js} +3 -3
  123. package/dist/{chunk-MEMJOJO4.js.map → chunk-BVMHRVCG.js.map} +1 -1
  124. package/dist/{chunk-VFXAHTB3.js → chunk-CDOGKC7B.js} +7 -7
  125. package/dist/{chunk-VFXAHTB3.js.map → chunk-CDOGKC7B.js.map} +1 -1
  126. package/dist/{chunk-Z4UTYKKV.js → chunk-CGHCXWV2.js} +4 -4
  127. package/dist/{chunk-Z4UTYKKV.js.map → chunk-CGHCXWV2.js.map} +1 -1
  128. package/dist/{chunk-3DNVQVNY.js → chunk-D3PO3ICA.js} +3 -3
  129. package/dist/{chunk-3DNVQVNY.js.map → chunk-D3PO3ICA.js.map} +1 -1
  130. package/dist/{chunk-BGVRYEPA.js → chunk-D5EPCVPX.js} +9 -9
  131. package/dist/{chunk-BGVRYEPA.js.map → chunk-D5EPCVPX.js.map} +1 -1
  132. package/dist/{chunk-FJQD3LTR.js → chunk-DGTFJWBV.js} +4 -4
  133. package/dist/{chunk-FJQD3LTR.js.map → chunk-DGTFJWBV.js.map} +1 -1
  134. package/dist/{chunk-4INSECDW.js → chunk-EHTLXK5F.js} +5 -5
  135. package/dist/{chunk-4INSECDW.js.map → chunk-EHTLXK5F.js.map} +1 -1
  136. package/dist/{chunk-POI4G5EA.js → chunk-FHU2MXZA.js} +4 -4
  137. package/dist/{chunk-POI4G5EA.js.map → chunk-FHU2MXZA.js.map} +1 -1
  138. package/dist/{chunk-RCCVUE72.js → chunk-FQWF2V5C.js} +7 -7
  139. package/dist/{chunk-RCCVUE72.js.map → chunk-FQWF2V5C.js.map} +1 -1
  140. package/dist/{chunk-OMY65JIW.js → chunk-GFZEZQ45.js} +4 -4
  141. package/dist/{chunk-OMY65JIW.js.map → chunk-GFZEZQ45.js.map} +1 -1
  142. package/dist/{chunk-UFQY2QQ4.js → chunk-IEU7LOKW.js} +3 -3
  143. package/dist/{chunk-UFQY2QQ4.js.map → chunk-IEU7LOKW.js.map} +1 -1
  144. package/dist/{chunk-2MHMQOMJ.js → chunk-J5DGBS7Q.js} +3 -3
  145. package/dist/{chunk-2MHMQOMJ.js.map → chunk-J5DGBS7Q.js.map} +1 -1
  146. package/dist/{chunk-IAHWLUFK.js → chunk-JVAFKLXJ.js} +3 -3
  147. package/dist/{chunk-IAHWLUFK.js.map → chunk-JVAFKLXJ.js.map} +1 -1
  148. package/dist/{chunk-LZZ6EESI.js → chunk-JYV25VNZ.js} +3 -3
  149. package/dist/{chunk-LZZ6EESI.js.map → chunk-JYV25VNZ.js.map} +1 -1
  150. package/dist/chunk-KFOKCJOJ.js +14 -0
  151. package/dist/{chunk-ULC4J3PY.js.map → chunk-KFOKCJOJ.js.map} +1 -1
  152. package/dist/{chunk-E5PEYI5I.js → chunk-KXD4WUYA.js} +6 -6
  153. package/dist/{chunk-E5PEYI5I.js.map → chunk-KXD4WUYA.js.map} +1 -1
  154. package/dist/{chunk-BFA2U7P3.js → chunk-M46EKE7R.js} +5 -5
  155. package/dist/{chunk-BFA2U7P3.js.map → chunk-M46EKE7R.js.map} +1 -1
  156. package/dist/{chunk-MJ7TL42D.js → chunk-OKCNKVB5.js} +4 -4
  157. package/dist/{chunk-MJ7TL42D.js.map → chunk-OKCNKVB5.js.map} +1 -1
  158. package/dist/{chunk-TMMK2VYE.js → chunk-OM2GRPDH.js} +3 -3
  159. package/dist/{chunk-TMMK2VYE.js.map → chunk-OM2GRPDH.js.map} +1 -1
  160. package/dist/{chunk-ROTFC5YL.js → chunk-OTRQB2ZJ.js} +7 -7
  161. package/dist/{chunk-ROTFC5YL.js.map → chunk-OTRQB2ZJ.js.map} +1 -1
  162. package/dist/{chunk-CFARTPUQ.js → chunk-OU2KIHZI.js} +3 -3
  163. package/dist/{chunk-CFARTPUQ.js.map → chunk-OU2KIHZI.js.map} +1 -1
  164. package/dist/{chunk-WD576F4S.js → chunk-P7A24TSM.js} +3 -3
  165. package/dist/{chunk-WD576F4S.js.map → chunk-P7A24TSM.js.map} +1 -1
  166. package/dist/{chunk-MVBMVM22.js → chunk-PCEKL6S3.js} +7 -7
  167. package/dist/{chunk-MVBMVM22.js.map → chunk-PCEKL6S3.js.map} +1 -1
  168. package/dist/{chunk-WN35SBLD.js → chunk-QQTY4PDC.js} +3 -3
  169. package/dist/{chunk-WN35SBLD.js.map → chunk-QQTY4PDC.js.map} +1 -1
  170. package/dist/{chunk-MKCESZHW.js → chunk-RRTDXKV5.js} +4 -4
  171. package/dist/{chunk-MKCESZHW.js.map → chunk-RRTDXKV5.js.map} +1 -1
  172. package/dist/{chunk-6Z6BGS7P.js → chunk-SW4WGOLU.js} +3 -3
  173. package/dist/{chunk-6Z6BGS7P.js.map → chunk-SW4WGOLU.js.map} +1 -1
  174. package/dist/{chunk-NYXV2PES.js → chunk-T6IIPRRQ.js} +8 -8
  175. package/dist/{chunk-NYXV2PES.js.map → chunk-T6IIPRRQ.js.map} +1 -1
  176. package/dist/{chunk-2OAG7V35.js → chunk-TMSDWRCO.js} +3 -3
  177. package/dist/{chunk-2OAG7V35.js.map → chunk-TMSDWRCO.js.map} +1 -1
  178. package/dist/{chunk-PF2WSBJ7.js → chunk-UHXL4VZS.js} +4 -4
  179. package/dist/{chunk-PF2WSBJ7.js.map → chunk-UHXL4VZS.js.map} +1 -1
  180. package/dist/{chunk-E7AO2Q32.js → chunk-V3NOBNNU.js} +3 -3
  181. package/dist/{chunk-E7AO2Q32.js.map → chunk-V3NOBNNU.js.map} +1 -1
  182. package/dist/{chunk-PKJJ6Z7A.js → chunk-W6LB5TRO.js} +4 -4
  183. package/dist/{chunk-PKJJ6Z7A.js.map → chunk-W6LB5TRO.js.map} +1 -1
  184. package/dist/{chunk-K7U46BT2.js → chunk-WBL7MSKQ.js} +4 -4
  185. package/dist/{chunk-K7U46BT2.js.map → chunk-WBL7MSKQ.js.map} +1 -1
  186. package/dist/{chunk-LU5DRXS5.js → chunk-WBXIDILF.js} +4 -4
  187. package/dist/{chunk-LU5DRXS5.js.map → chunk-WBXIDILF.js.map} +1 -1
  188. package/dist/{chunk-6T7FUHJY.js → chunk-YWDMDW2K.js} +5 -5
  189. package/dist/{chunk-6T7FUHJY.js.map → chunk-YWDMDW2K.js.map} +1 -1
  190. package/dist/{chunk-CA3QVM6Y.js → chunk-ZGVBXJQO.js} +5 -5
  191. package/dist/{chunk-CA3QVM6Y.js.map → chunk-ZGVBXJQO.js.map} +1 -1
  192. package/dist/{chunk-TL256OK3.js → chunk-ZMXHQKZS.js} +4 -4
  193. package/dist/{chunk-TL256OK3.js.map → chunk-ZMXHQKZS.js.map} +1 -1
  194. package/dist/{chunk-ONRRKJWG.js → chunk-ZODMX2OQ.js} +8 -8
  195. package/dist/{chunk-ONRRKJWG.js.map → chunk-ZODMX2OQ.js.map} +1 -1
  196. package/dist/components/cart/index.js +1 -1
  197. package/dist/components/common/index.js +1 -1
  198. package/dist/components/drawer/index.js +24 -24
  199. package/dist/components/home/index.js +28 -28
  200. package/dist/components/layout/index.js +7 -7
  201. package/dist/components/product/index.js +25 -25
  202. package/dist/components/store/index.js +26 -26
  203. package/dist/components/toast/index.js +5 -5
  204. package/dist/dev/editor/index.js +3 -3
  205. package/dist/dev/index.js +3 -3
  206. package/dist/document-class-BUEFLHYC.js +29 -0
  207. package/dist/{document-class-RXOPTIM2.js.map → document-class-BUEFLHYC.js.map} +1 -1
  208. package/dist/hooks/index.js +24 -24
  209. package/dist/hooks/useComments.js +4 -4
  210. package/dist/hooks/useGtm.js +24 -24
  211. package/dist/hooks/useMoney.js +24 -24
  212. package/dist/hooks/useProduct.js +4 -4
  213. package/dist/hooks/useStore.js +24 -24
  214. package/dist/hooks/useUser.js +6 -6
  215. package/dist/hooks/useWishlist.js +4 -4
  216. package/dist/index.js +24 -24
  217. package/dist/native-app/index.js +4 -4
  218. package/dist/{navigation-NM4AO2OX.js → navigation-PALPE7RN.js} +8 -8
  219. package/dist/{navigation-NM4AO2OX.js.map → navigation-PALPE7RN.js.map} +1 -1
  220. package/dist/navigation-ZTRVRY6C.js +14 -0
  221. package/dist/{navigation-S5EUYOVI.js.map → navigation-ZTRVRY6C.js.map} +1 -1
  222. package/dist/{not-found-3XCUVPO3.js → not-found-LFQUSYZE.js} +27 -27
  223. package/dist/{not-found-3XCUVPO3.js.map → not-found-LFQUSYZE.js.map} +1 -1
  224. package/dist/providers/index.js +24 -24
  225. package/dist/routes/account/orders.js +9 -9
  226. package/dist/routes/account.js +18 -18
  227. package/dist/routes/blog.js +13 -13
  228. package/dist/routes/brands.js +9 -9
  229. package/dist/routes/cart.js +32 -32
  230. package/dist/routes/home.js +29 -29
  231. package/dist/routes/index.js +7 -7
  232. package/dist/routes/loyalty.js +10 -10
  233. package/dist/routes/page.js +9 -9
  234. package/dist/routes/product-listing.js +30 -30
  235. package/dist/routes/product.js +28 -28
  236. package/dist/routes/root/beforeLoad.d.ts.map +1 -1
  237. package/dist/routes/seo-redirects.js +7 -7
  238. package/dist/routes/testimonials.js +5 -5
  239. package/dist/routes/thank-you.js +9 -9
  240. package/dist/skeleton.js +29 -29
  241. package/dist/{store-lookup-LVKWUL6Z.js → store-lookup-6QB4WMID.js} +12 -12
  242. package/dist/{store-lookup-LVKWUL6Z.js.map → store-lookup-6QB4WMID.js.map} +1 -1
  243. package/dist/tanstack/middleware/store-not-found.d.ts +10 -0
  244. package/dist/tanstack/middleware/store-not-found.d.ts.map +1 -0
  245. package/dist/tanstack/middleware/twilight.d.ts +13 -0
  246. package/dist/tanstack/middleware/twilight.d.ts.map +1 -1
  247. package/dist/tanstack.js +99 -22
  248. package/dist/tanstack.js.map +1 -1
  249. package/dist/twilight/context.d.ts +5 -0
  250. package/dist/twilight/context.d.ts.map +1 -1
  251. package/dist/utils/baseHead.js +3 -3
  252. package/dist/utils/errors.d.ts +4 -3
  253. package/dist/utils/errors.d.ts.map +1 -1
  254. package/dist/utils/index.js +7 -7
  255. package/dist/vite/index.js +5 -5
  256. package/package.json +1 -1
  257. package/tailwind/routes/root/beforeLoad.ts.txt +12 -3
  258. package/dist/Header-M3Q7KDF5.js +0 -22
  259. package/dist/MaintenancePage-UBJ5Q3L5.js +0 -7
  260. package/dist/MasterLayout-KVMF2U5Z.js +0 -54
  261. package/dist/StoreClosedNotification-TL32ZXVT.js +0 -55
  262. package/dist/chunk-FNM2OUPD.js.map +0 -1
  263. package/dist/chunk-QRHXAKJ3.js.map +0 -1
  264. package/dist/chunk-ULC4J3PY.js +0 -14
  265. package/dist/chunk-ZBFTBK4B.js.map +0 -1
  266. package/dist/document-class-RXOPTIM2.js +0 -29
  267. package/dist/navigation-S5EUYOVI.js +0 -14
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/api/translations.ts"],"names":[],"mappings":";;;;AAiEA,IAAM,kBAAA,GAAqB,sBAAA;AAGpB,SAAS,uBAAuB,MAAA,EAAwB;AAC7D,EAAA,OAAO,uBAAuB,MAAM,CAAA,KAAA,CAAA;AACtC;AAWO,SAAS,qBAAA,CAAsB,SAA0B,MAAA,EAAwB;AACtF,EAAA,OAAO,CAAA,aAAA,EAAgB,OAAO,CAAA,CAAA,EAAI,MAAM,CAAA,KAAA,CAAA;AAC1C;AAUA,eAAe,eACb,IAAA,EACA,EAAE,aAAa,KAA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A;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAgBP,QAAA,EAAU,CAAC,MAAA,KACT,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,qBAAqB,MAAM,CAAA;AAAA,MACrC,OAAA,EAAS,MAAM,YAAA,CAAa,GAAA,CAAI,MAAM;AAAA,KACvC,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAWH,OAAA,EAAS,CAAC,OAAA,EAA0B,MAAA,KAClC,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,yBAAA,CAA0B,OAAA,EAAS,MAAM,CAAA;AAAA,MACnD,OAAA,EAAS,MAAM,YAAA,CAAa,QAAA,CAAS,SAAS,MAAM;AAAA,KACrD;AAAA;AAEP","file":"chunk-6NV6T24C.js","sourcesContent":["/**\n * @fileoverview Where a storefront's words come from.\n *\n * Two files, merged: the platform's copy for this language, and the merchant's\n * own edits for this language and this store. Both are plain JSON objects on\n * the uploader's CDN, one per language.\n *\n * ```\n * https://cdn.files.salla.network/translations/common/<locale>.json the platform's\n * https://cdn.files.salla.network/translations/<storeId>/<locale>.json the merchant's\n * ```\n *\n * **What this replaces, and why.** Until now the engine read a single global\n * file, `cdn.salla.network/js/translations.json`, holding every language keyed\n * `\"<locale>.trans\"`. Nothing publishes that file: it is an object last written\n * on 2026-03-26, carrying only `ar` and `en` where the platform has 39 locales,\n * 405 keys behind `Languages-Module` and 959 English strings textually\n * different from it. So every React storefront has been serving copy from\n * March, and a key added since has never reached one. It also carried no\n * merchant overrides at all — a merchant editing their theme's wording in the\n * Dashboard changed nothing on a React theme.\n *\n * **Merchant overrides are read, and only when there are any.** Getting here\n * took two corrections worth keeping.\n *\n * The first is the address. A merchant's own wording lives at\n * `translations/<storeId>/<locale>.json`, keyed by `store()->getRouteKey()` —\n * the Optimus-encoded numeric id. An early version addressed it with\n * `resolveStoreIdentifier()`, on the claim that the two are the same string.\n * That is true of the `store-identifier` *header*, which accepts a host, a\n * username or an id, and false of the R2 key: on a custom domain the resolver\n * returns `reefperfumes.com` and on a shared host a username like\n * `mtgr-alaatr-2`. Both 404, both then read as \"this store has no overrides\",\n * and the merchant's wording silently never appears — so the feature would have\n * worked under `?storeId=` alone, which is preview and localhost. It is\n * `settings.store.id` now, which is known only after the settings query.\n *\n * The second is when to ask at all. Most stores have never customised a word,\n * and a miss is an uncached round trip (`cf-cache-status: DYNAMIC` on the 404)\n * on the critical path of every SSR render. So the request is made only when\n * `settings.languages[<ISO>].has_custom_translations` says there is something\n * to get — a flag `Languages-Module` writes when a merchant saves a\n * translation. A store without overrides pays nothing, which is what made this\n * shippable at all.\n *\n * ⚠️ The flag is written on save, so a store whose wording predates it reads as\n * `false` until someone edits a translation or the backfill runs. That is a\n * store keeping today's behaviour, not a regression — React themes have never\n * read merchant overrides — but it does mean the feature is only as complete as\n * the backfill.\n *\n * **Rollout is by fallback, not by flag.** `translations/common/` is written by\n * a sync in the theme build service that may not have run yet, and a hard switch\n * would leave every storefront with no platform strings at all. A missing common\n * file therefore falls back to the old global one, which is exactly today's\n * behaviour — so this is safe to ship before the bucket is populated, and stops\n * using the fallback on its own once it is.\n */\nimport { queryOptions } from '@tanstack/react-query';\nimport { cdn, filesCdn } from './client';\nimport { storeTranslationsQueryKey, translationsQueryKey } from './translations-key';\nimport { composeMessages, isPlainObject, type Messages } from './messages';\nimport type { TranslationMessages } from '../providers/I18nProvider';\n\n/** The global file this used to be the only reader of. See the file comment. */\nconst LEGACY_GLOBAL_FILE = 'js/translations.json';\n\n/** One language of platform copy, shared by every store. */\nexport function commonTranslationsPath(locale: string): string {\n return `translations/common/${locale}.json`;\n}\n\n/**\n * One language of a single merchant's own wording.\n *\n * `storeId` is `settings.store.id`, which is the value `Languages-Module` names\n * the object with (`store()->getRouteKey()`, the Optimus-encoded numeric id).\n * It is **not** `resolveStoreIdentifier()`: that returns a hostname on a custom\n * domain and a username on a shared host, both of which 404 here and would read\n * as \"this merchant has no overrides\" — silently, on every store but a preview.\n */\nexport function storeTranslationsPath(storeId: string | number, locale: string): string {\n return `translations/${storeId}/${locale}.json`;\n}\n\n/**\n * Reads one language file, or `null` when there is nothing to read.\n *\n * A 404 is the ordinary answer, not a failure: most stores have never had a\n * word customised, so their file does not exist. Distinguishing it from a real\n * error matters only for the log — both end in `null` — but a warning on every\n * page load of every uncustomised store is a warning nobody will read.\n */\nasync function readLocaleFile(\n path: string,\n { failLoudly = false }: { failLoudly?: boolean } = {}\n): Promise<Messages | null> {\n /** A 404 always means \"absent\"; everything else is a failure to read. */\n const unreadable = (reason: string, cause?: unknown): null => {\n if (failLoudly) throw new Error(`[translations] ${path}: ${reason}`, { cause });\n console.warn('[translations]', reason, path, cause ?? '');\n return null;\n };\n\n try {\n const response = await filesCdn.get(path, { throwHttpErrors: false, timeout: 5000 });\n if (response.status === 404) return null;\n\n if (!response.ok) {\n return unreadable(`answered ${response.status}`);\n }\n\n const data: unknown = await response.json();\n if (!isPlainObject(data)) {\n return unreadable('is not a JSON object');\n }\n\n return data;\n } catch (error) {\n if (error instanceof Error && error.message.startsWith('[translations]')) throw error;\n return unreadable('could not be read', error);\n }\n}\n\n/**\n * The pre-CDN global file, sliced to one language.\n *\n * Only reached when `translations/common/<locale>.json` is missing, which is\n * the state of the bucket until the sync has run once.\n */\nasync function readLegacyGlobal(locale: string): Promise<Messages | null> {\n try {\n const data = await cdn.get(LEGACY_GLOBAL_FILE, { timeout: 5000 }).json<TranslationMessages>();\n const forLocale = data?.[`${locale}.trans`];\n return isPlainObject(forLocale) ? forLocale : null;\n } catch {\n console.warn('[translations] the legacy global file could not be read either');\n return null;\n }\n}\n\nexport const translations = {\n /**\n * The platform's copy for `locale`.\n *\n * One file, so one request. See the file comment for why the merchant's own\n * wording is not merged in here yet and what it is waiting on.\n */\n get: async (locale: string): Promise<TranslationMessages | null> => {\n const common = await readLocaleFile(commonTranslationsPath(locale));\n const base = common ?? (await readLegacyGlobal(locale));\n if (!base) return null;\n\n // Still wrapped in the `<locale>.trans` shape the rest of the engine reads.\n // `createI18nInstance` slices by that key and so does the SDK bridge in\n // `I18nProvider`; changing the envelope here would be a second change for\n // no gain, since one language is all any of them ever take out of it.\n return { [`${locale}.trans`]: base as Record<string, string> };\n },\n\n /**\n * This merchant's own wording for `locale`, or `null` if they have none.\n *\n * Only worth calling when `settings.languages[<ISO>].has_custom_translations`\n * says there is something to get. Most stores have never customised a word,\n * and a miss here is an uncached round trip — `cf-cache-status: DYNAMIC` on a\n * 404 — on the critical path of an SSR render. The flag is what makes this\n * free for everyone who does not use it.\n *\n * Returned unwrapped, unlike {@link translations.get}: this is merged into\n * that one's messages rather than handed to i18next on its own.\n */\n forStore: async (storeId: string | number, locale: string): Promise<Messages | null> =>\n // `failLoudly`, unlike the platform file: this is only ever called because\n // the settings said overrides exist, so a 500, a timeout or a body that is\n // not JSON is a failure to read them — not a store that has none. Returning\n // `null` there would cache \"no overrides\" as a success, skip the query's\n // retry, and serve Salla's wording in place of the merchant's until the\n // entry expired. A 404 still means absent, and `rootBeforeLoad` catches the\n // throw and keeps the platform copy, so the worst case is unchanged.\n readLocaleFile(storeTranslationsPath(storeId, locale), { failLoudly: true }),\n\n /**\n * The platform's copy for `locale` with this merchant's wording laid over it.\n *\n * Takes the two as values rather than fetching them, so the caller decides\n * whether the second request happens at all and both stay separately cached.\n */\n /**\n * The platform's copy for `locale` with this merchant's wording over it.\n *\n * Delegates to `composeMessages`, which every other reader of these two\n * entries also uses — see `api/messages.ts` for why there is exactly one.\n */\n merge: (\n common: TranslationMessages | null,\n overrides: Messages | null,\n locale: string\n ): TranslationMessages | null => composeMessages(common, overrides, locale) ?? null,\n\n queries: {\n /**\n * @param locale taken as an argument rather than read from the twilight\n * context, and that is load-bearing. This key is built on the server, on\n * hydration, and again lazily from the context accessor; if any of the\n * three read a locale the others had not been given yet, the hydrated page\n * would miss the dehydrated entry and refetch both files it was just\n * handed. Every caller already has the locale in hand.\n *\n * The store is deliberately **not** in the key. One document serves one\n * store — a request that names a different one is redirected with\n * `reloadDocument`, so the client never changes store under a live cache —\n * and adding a value that resolves from the request on the server and from\n * the injected env on the client is how a key stops matching across\n * hydration.\n */\n byLocale: (locale: string) =>\n queryOptions({\n queryKey: translationsQueryKey(locale),\n queryFn: () => translations.get(locale),\n }),\n\n /**\n * This merchant's overrides, cached apart from the platform's copy.\n *\n * Its own entry rather than a wider `byLocale` key, so the common file is\n * fetched and dehydrated once per language whatever the store does, and a\n * store with no overrides never has an entry at all. Both sides compute the\n * key from the settings payload, so the hydrated page finds what the server\n * dehydrated instead of refetching it.\n */\n byStore: (storeId: string | number, locale: string) =>\n queryOptions({\n queryKey: storeTranslationsQueryKey(storeId, locale),\n queryFn: () => translations.forStore(storeId, locale),\n }),\n },\n};\n"]}
1
+ {"version":3,"sources":["../src/api/translations.ts"],"names":[],"mappings":";;;;AAiEA,IAAM,kBAAA,GAAqB,sBAAA;AAGpB,SAAS,uBAAuB,MAAA,EAAwB;AAC7D,EAAA,OAAO,uBAAuB,MAAM,CAAA,KAAA,CAAA;AACtC;AAWO,SAAS,qBAAA,CAAsB,SAA0B,MAAA,EAAwB;AACtF,EAAA,OAAO,CAAA,aAAA,EAAgB,OAAO,CAAA,CAAA,EAAI,MAAM,CAAA,KAAA,CAAA;AAC1C;AAUA,eAAe,eACb,IAAA,EACA,EAAE,aAAa,KAAA,EAAM,GAA8B,EAAC,EAC1B;AAE1B,EAAA,MAAM,UAAA,GAAa,CAAC,MAAA,EAAgB,KAAA,KAA0B;AAC5D,IAAA,IAAI,UAAA,EAAY,MAAM,IAAI,KAAA,CAAM,CAAA,eAAA,EAAkB,IAAI,CAAA,EAAA,EAAK,MAAM,CAAA,CAAA,EAAI,EAAE,KAAA,EAAO,CAAA;AAC9E,IAAA,OAAA,CAAQ,IAAA,CAAK,gBAAA,EAAkB,MAAA,EAAQ,IAAA,EAAM,SAAS,EAAE,CAAA;AACxD,IAAA,OAAO,IAAA;AA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ClC,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,yBAAA,CAA0B,OAAA,EAAS,MAAM,CAAA;AAAA,MACnD,OAAA,EAAS,MAAM,YAAA,CAAa,QAAA,CAAS,SAAS,MAAM;AAAA,KACrD;AAAA;AAEP","file":"chunk-5G6PD6P2.js","sourcesContent":["/**\n * @fileoverview Where a storefront's words come from.\n *\n * Two files, merged: the platform's copy for this language, and the merchant's\n * own edits for this language and this store. Both are plain JSON objects on\n * the uploader's CDN, one per language.\n *\n * ```\n * https://cdn.files.salla.network/translations/common/<locale>.json the platform's\n * https://cdn.files.salla.network/translations/<storeId>/<locale>.json the merchant's\n * ```\n *\n * **What this replaces, and why.** Until now the engine read a single global\n * file, `cdn.salla.network/js/translations.json`, holding every language keyed\n * `\"<locale>.trans\"`. Nothing publishes that file: it is an object last written\n * on 2026-03-26, carrying only `ar` and `en` where the platform has 39 locales,\n * 405 keys behind `Languages-Module` and 959 English strings textually\n * different from it. So every React storefront has been serving copy from\n * March, and a key added since has never reached one. It also carried no\n * merchant overrides at all — a merchant editing their theme's wording in the\n * Dashboard changed nothing on a React theme.\n *\n * **Merchant overrides are read, and only when there are any.** Getting here\n * took two corrections worth keeping.\n *\n * The first is the address. A merchant's own wording lives at\n * `translations/<storeId>/<locale>.json`, keyed by `store()->getRouteKey()` —\n * the Optimus-encoded numeric id. An early version addressed it with\n * `resolveStoreIdentifier()`, on the claim that the two are the same string.\n * That is true of the `store-identifier` *header*, which accepts a host, a\n * username or an id, and false of the R2 key: on a custom domain the resolver\n * returns `reefperfumes.com` and on a shared host a username like\n * `mtgr-alaatr-2`. Both 404, both then read as \"this store has no overrides\",\n * and the merchant's wording silently never appears — so the feature would have\n * worked under `?storeId=` alone, which is preview and localhost. It is\n * `settings.store.id` now, which is known only after the settings query.\n *\n * The second is when to ask at all. Most stores have never customised a word,\n * and a miss is an uncached round trip (`cf-cache-status: DYNAMIC` on the 404)\n * on the critical path of every SSR render. So the request is made only when\n * `settings.languages[<ISO>].has_custom_translations` says there is something\n * to get — a flag `Languages-Module` writes when a merchant saves a\n * translation. A store without overrides pays nothing, which is what made this\n * shippable at all.\n *\n * ⚠️ The flag is written on save, so a store whose wording predates it reads as\n * `false` until someone edits a translation or the backfill runs. That is a\n * store keeping today's behaviour, not a regression — React themes have never\n * read merchant overrides — but it does mean the feature is only as complete as\n * the backfill.\n *\n * **Rollout is by fallback, not by flag.** `translations/common/` is written by\n * a sync in the theme build service that may not have run yet, and a hard switch\n * would leave every storefront with no platform strings at all. A missing common\n * file therefore falls back to the old global one, which is exactly today's\n * behaviour — so this is safe to ship before the bucket is populated, and stops\n * using the fallback on its own once it is.\n */\nimport { queryOptions } from '@tanstack/react-query';\nimport { cdn, filesCdn } from './client';\nimport { storeTranslationsQueryKey, translationsQueryKey } from './translations-key';\nimport { composeMessages, isPlainObject, type Messages } from './messages';\nimport type { TranslationMessages } from '../providers/I18nProvider';\n\n/** The global file this used to be the only reader of. See the file comment. */\nconst LEGACY_GLOBAL_FILE = 'js/translations.json';\n\n/** One language of platform copy, shared by every store. */\nexport function commonTranslationsPath(locale: string): string {\n return `translations/common/${locale}.json`;\n}\n\n/**\n * One language of a single merchant's own wording.\n *\n * `storeId` is `settings.store.id`, which is the value `Languages-Module` names\n * the object with (`store()->getRouteKey()`, the Optimus-encoded numeric id).\n * It is **not** `resolveStoreIdentifier()`: that returns a hostname on a custom\n * domain and a username on a shared host, both of which 404 here and would read\n * as \"this merchant has no overrides\" — silently, on every store but a preview.\n */\nexport function storeTranslationsPath(storeId: string | number, locale: string): string {\n return `translations/${storeId}/${locale}.json`;\n}\n\n/**\n * Reads one language file, or `null` when there is nothing to read.\n *\n * A 404 is the ordinary answer, not a failure: most stores have never had a\n * word customised, so their file does not exist. Distinguishing it from a real\n * error matters only for the log — both end in `null` — but a warning on every\n * page load of every uncustomised store is a warning nobody will read.\n */\nasync function readLocaleFile(\n path: string,\n { failLoudly = false }: { failLoudly?: boolean } = {}\n): Promise<Messages | null> {\n /** A 404 always means \"absent\"; everything else is a failure to read. */\n const unreadable = (reason: string, cause?: unknown): null => {\n if (failLoudly) throw new Error(`[translations] ${path}: ${reason}`, { cause });\n console.warn('[translations]', reason, path, cause ?? '');\n return null;\n };\n\n try {\n const response = await filesCdn.get(path, { throwHttpErrors: false, timeout: 5000 });\n if (response.status === 404) return null;\n\n if (!response.ok) {\n return unreadable(`answered ${response.status}`);\n }\n\n const data: unknown = await response.json();\n if (!isPlainObject(data)) {\n return unreadable('is not a JSON object');\n }\n\n return data;\n } catch (error) {\n if (error instanceof Error && error.message.startsWith('[translations]')) throw error;\n return unreadable('could not be read', error);\n }\n}\n\n/**\n * The pre-CDN global file, sliced to one language.\n *\n * Only reached when `translations/common/<locale>.json` is missing, which is\n * the state of the bucket until the sync has run once.\n */\nasync function readLegacyGlobal(locale: string): Promise<Messages | null> {\n try {\n const data = await cdn.get(LEGACY_GLOBAL_FILE, { timeout: 5000 }).json<TranslationMessages>();\n const forLocale = data?.[`${locale}.trans`];\n return isPlainObject(forLocale) ? forLocale : null;\n } catch {\n console.warn('[translations] the legacy global file could not be read either');\n return null;\n }\n}\n\nexport const translations = {\n /**\n * The platform's copy for `locale`.\n *\n * One file, so one request. See the file comment for why the merchant's own\n * wording is not merged in here yet and what it is waiting on.\n */\n get: async (locale: string): Promise<TranslationMessages | null> => {\n const common = await readLocaleFile(commonTranslationsPath(locale));\n const base = common ?? (await readLegacyGlobal(locale));\n if (!base) return null;\n\n // Still wrapped in the `<locale>.trans` shape the rest of the engine reads.\n // `createI18nInstance` slices by that key and so does the SDK bridge in\n // `I18nProvider`; changing the envelope here would be a second change for\n // no gain, since one language is all any of them ever take out of it.\n return { [`${locale}.trans`]: base as Record<string, string> };\n },\n\n /**\n * This merchant's own wording for `locale`, or `null` if they have none.\n *\n * Only worth calling when `settings.languages[<ISO>].has_custom_translations`\n * says there is something to get. Most stores have never customised a word,\n * and a miss here is an uncached round trip — `cf-cache-status: DYNAMIC` on a\n * 404 — on the critical path of an SSR render. The flag is what makes this\n * free for everyone who does not use it.\n *\n * Returned unwrapped, unlike {@link translations.get}: this is merged into\n * that one's messages rather than handed to i18next on its own.\n */\n forStore: async (storeId: string | number, locale: string): Promise<Messages | null> =>\n // `failLoudly`, unlike the platform file: this is only ever called because\n // the settings said overrides exist, so a 500, a timeout or a body that is\n // not JSON is a failure to read them — not a store that has none. Returning\n // `null` there would cache \"no overrides\" as a success, skip the query's\n // retry, and serve Salla's wording in place of the merchant's until the\n // entry expired. A 404 still means absent, and `rootBeforeLoad` catches the\n // throw and keeps the platform copy, so the worst case is unchanged.\n readLocaleFile(storeTranslationsPath(storeId, locale), { failLoudly: true }),\n\n /**\n * The platform's copy for `locale` with this merchant's wording laid over it.\n *\n * Takes the two as values rather than fetching them, so the caller decides\n * whether the second request happens at all and both stay separately cached.\n */\n /**\n * The platform's copy for `locale` with this merchant's wording over it.\n *\n * Delegates to `composeMessages`, which every other reader of these two\n * entries also uses — see `api/messages.ts` for why there is exactly one.\n */\n merge: (\n common: TranslationMessages | null,\n overrides: Messages | null,\n locale: string\n ): TranslationMessages | null => composeMessages(common, overrides, locale) ?? null,\n\n queries: {\n /**\n * @param locale taken as an argument rather than read from the twilight\n * context, and that is load-bearing. This key is built on the server, on\n * hydration, and again lazily from the context accessor; if any of the\n * three read a locale the others had not been given yet, the hydrated page\n * would miss the dehydrated entry and refetch both files it was just\n * handed. Every caller already has the locale in hand.\n *\n * The store is deliberately **not** in the key. One document serves one\n * store — a request that names a different one is redirected with\n * `reloadDocument`, so the client never changes store under a live cache —\n * and adding a value that resolves from the request on the server and from\n * the injected env on the client is how a key stops matching across\n * hydration.\n */\n byLocale: (locale: string) =>\n queryOptions({\n queryKey: translationsQueryKey(locale),\n queryFn: () => translations.get(locale),\n }),\n\n /**\n * This merchant's overrides, cached apart from the platform's copy.\n *\n * Its own entry rather than a wider `byLocale` key, so the common file is\n * fetched and dehydrated once per language whatever the store does, and a\n * store with no overrides never has an entry at all. Both sides compute the\n * key from the settings payload, so the hydrated page finds what the server\n * dehydrated instead of refetching it.\n */\n byStore: (storeId: string | number, locale: string) =>\n queryOptions({\n queryKey: storeTranslationsQueryKey(storeId, locale),\n queryFn: () => translations.forStore(storeId, locale),\n }),\n },\n};\n"]}
@@ -1,6 +1,6 @@
1
- import { getActiveScope, requestedThemeVersionId, api, STORE_IDENTIFIER_HEADER } from './chunk-BFA2U7P3.js';
2
- import { resolveStoreIdentifier } from './chunk-POI4G5EA.js';
3
- import { getTwilightContext, SettingsError } from './chunk-QRHXAKJ3.js';
1
+ import { getActiveScope, requestedThemeVersionId, api, STORE_IDENTIFIER_HEADER } from './chunk-M46EKE7R.js';
2
+ import { resolveStoreIdentifier, parseStoreId } from './chunk-FHU2MXZA.js';
3
+ import { getTwilightContext, SettingsError } from './chunk-7VNVCHID.js';
4
4
  import { queryOptions } from '@tanstack/react-query';
5
5
  import { isTimeoutError, isHTTPError, isNetworkError } from 'ky';
6
6
 
@@ -100,6 +100,11 @@ function apiErrorMessage(data) {
100
100
  const message = data?.error?.message;
101
101
  return typeof message === "string" && message.length > 0 && message.length <= 200 ? message : void 0;
102
102
  }
103
+ var STORE_NOT_FOUND_MESSAGE = "\u0627\u0644\u0645\u062A\u062C\u0631 \u063A\u064A\u0631 \u0645\u0648\u062C\u0648\u062F";
104
+ function isStoreNotFound(identifier, status, said) {
105
+ if (status === 410) return parseStoreId(identifier) !== null;
106
+ return status === 422 && said === STORE_NOT_FOUND_MESSAGE;
107
+ }
103
108
  function describeSettingsFailure(identifier, error) {
104
109
  if (error instanceof SettingsError) return error;
105
110
  const request = `the settings request for store "${identifier}"`;
@@ -114,7 +119,7 @@ function describeSettingsFailure(identifier, error) {
114
119
  const said = apiErrorMessage(error.data);
115
120
  return new SettingsError(
116
121
  `The Salla API answered ${request} with HTTP ${status}${said ? `: ${said}` : ""}.`,
117
- { reason: "http", status }
122
+ { reason: isStoreNotFound(identifier, status, said) ? "not-found" : "http", status }
118
123
  );
119
124
  }
120
125
  if (isNetworkError(error)) {
@@ -178,5 +183,5 @@ var store = {
178
183
  };
179
184
 
180
185
  export { readNativeAppHeaders, store };
181
- //# sourceMappingURL=chunk-FNM2OUPD.js.map
182
- //# sourceMappingURL=chunk-FNM2OUPD.js.map
186
+ //# sourceMappingURL=chunk-6D3OWIEC.js.map
187
+ //# sourceMappingURL=chunk-6D3OWIEC.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils/native-app-headers.ts","../src/api/store.ts"],"names":[],"mappings":";;;;;;;AACO,IAAM,kBAAA,GAAqB;AAAA,EAChC,UAAA;AAAA,EACA,eAAA;AAAA,EACA,oBAAA;AAAA,EACA;AACF,CAAA;AAUO,SAAS,qBAAqB,OAAA,EAAiD;AACpF,EAAA,MAAM,EAAA,GAAK,OAAA,CAAQ,GAAA,CAAI,UAAU,GAAG,WAAA,EAAY;AAChD,EAAA,IAAI,EAAA,KAAO,KAAA,IAAS,EAAA,KAAO,SAAA,EAAW,OAAO,IAAA;AAC7C,EAAA,MAAM,QAAgC,EAAC;AACvC,EAAA,KAAA,MAAW,QAAQ,kBAAA,EAAoB;AACrC,IAAA,MAAM,KAAA,GAAQ,OAAA,CAAQ,GAAA,CAAI,IAAI,CAAA;AAC9B,IAAA,IAAI,KAAA,EAAO,KAAA,CAAM,IAAI,CAAA,GAAI,KAAA;AAAA,EAC3B;AACA,EAAA,OAAO,KAAA;AACT;;;ACZA,IAAM,qBAAA,GAAwB;AAAA,EAC5B,OAAA;AAAA,EACA,UAAA;AAAA,EACA,OAAA;AAAA,EACA,gBAAA;AAAA,EACA,mBAAA;AAAA,EACA,YAAA;AAAA,EACA,WAAA;AAAA,EACA,UAAA;AAAA,EACA,iBAAA;AAAA,EACA,QAAA;AAAA,EACA,SAAA;AAAA,EACA;AACF,CAAA;AAqFA,SAAS,iBAAiB,SAAA,EAA8D;AACtF,EAAA,IAAI,CAAC,WAAW,OAAO,MAAA;AAGvB,EAAA,OAAO,MAAA,CAAO,MAAA,CAAO,SAAS,CAAA,CAA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AAAA,IACT;AAAA,EACF,CAAA;AAAA,EAEA,OAAA,EAAS;AAAA,IACP,QAAA,EAAU,CAAC,eAAA,KACT,YAAA,CAAkC;AAAA,MAChC,QAAA,EAAU;AAAA,QACR,OAAA;AAAA,QACA,UAAA;AAAA,QACA,eAAA;AAAA,QACA,oBAAmB,CAAE,MAAA;AAAA,QACrB,cAAA,EAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAQf,uBAAA;AAAwB,OAC1B;AAAA;AAAA,MAEA,OAAA,EAAS,MAAM,aAAA,CAAc,eAAe,CAAA;AAAA;AAAA;AAAA,MAG5C,KAAA,EAAO;AAAA,KACR;AAAA;AAEP","file":"chunk-6D3OWIEC.js","sourcesContent":["/** The headers the Salla native app sends with every page it loads in its webview. */\nexport const NATIVE_APP_HEADERS = [\n 's-app-os',\n 's-app-version',\n 's-app-full-version',\n 's-app-os-version',\n];\n\n/**\n * The native app's own headers on this request, or null when it is not the app.\n *\n * On a Twig theme Laravel copies them into the settings' `jitsu.context.extra.headers`,\n * where the SDK reads the app's platform and version from (`salla.config.isMobileApp()`).\n * A React theme asks for its settings from the server, through the API, so the app's\n * headers never reach that call: the request is the only place they are.\n */\nexport function readNativeAppHeaders(headers: Headers): Record<string, string> | null {\n const os = headers.get('s-app-os')?.toLowerCase();\n if (os !== 'ios' && os !== 'android') return null;\n const found: Record<string, string> = {};\n for (const name of NATIVE_APP_HEADERS) {\n const value = headers.get(name);\n if (value) found[name] = value;\n }\n return found;\n}\n","import { queryOptions } from '@tanstack/react-query';\nimport { isHTTPError, isNetworkError, isTimeoutError } from 'ky';\nimport { api, getActiveScope, STORE_IDENTIFIER_HEADER } from './client';\nimport { SettingsError } from '../utils/errors';\nimport type { Store, Theme, Language, JitsuConfig, MaintenanceDetails } from '../types';\nimport { getTwilightContext } from '../twilight/context';\nimport { resolveStoreIdentifier } from '../utils/store-identity';\nimport { parseStoreId } from '../utils/cookies';\nimport { requestedThemeVersionId } from '../utils/theme-version';\nimport { NATIVE_APP_HEADERS } from '../utils/native-app-headers';\n\nexport { resolveStoreIdentifier };\n\nconst DEFAULT_INCLUDE_ITEMS = [\n 'store',\n 'settings',\n 'theme',\n 'theme_settings',\n 'external_services',\n 'currencies',\n 'languages',\n 'payments',\n 'product_widgets',\n 'rating',\n 'ratings',\n 'user',\n];\n\n/** Twig's `salla.init({ user })` object; the endpoint ignores the token, so always the guest. */\nexport interface SettingsUser {\n type: 'guest' | 'user';\n id?: number | string | null;\n language_code?: string;\n currency_code?: string;\n country_code?: string;\n [key: string]: unknown;\n}\n\n/**\n * Raw API response for settings endpoint.\n * Languages come as object: { \"AR\": { code, name, ... }, \"EN\": {...} }\n */\ninterface SettingsApiResponse {\n store?: Store;\n theme?: Theme;\n languages?: Record<string, Language>;\n currencies?: Record<\n string,\n { code: string; name: string; symbol: string; amount: number; country_code: string }\n >;\n external_services?: Record<string, unknown>;\n headers?: Record<string, unknown>;\n login?: { url: string; turnstile_site_key: string };\n affiliate?: { utm_url: string; cta_enabled: boolean };\n debug?: boolean;\n trace_console?: boolean;\n policy_url?: string;\n user?: SettingsUser;\n swoole?: string[];\n jitsu?: JitsuConfig;\n maintenance?: boolean;\n maintenance_details?: MaintenanceDetails;\n}\n\n/**\n * Central settings context - single source of truth for all API data.\n * Contains everything from the settings endpoint response after processing.\n */\nexport interface StoreContext {\n store?: Store;\n theme?: Theme;\n /** Languages as array after conversion from API object format */\n languages?: Language[];\n currencies?: Record<\n string,\n { code: string; name: string; symbol: string; amount: number; country_code: string }\n >;\n external_services?: Record<string, unknown>;\n headers?: Record<string, unknown>;\n login?: { url: string; turnstile_site_key: string };\n affiliate?: { utm_url: string; cta_enabled: boolean };\n debug?: boolean;\n trace_console?: boolean; // todo:: remove it\n policy_url?: string;\n user?: SettingsUser;\n /** API paths the SDK sends with `s-store-api-version: swoole` */\n swoole?: string[];\n /** Where the SDK's analytics send events, and which ones; without it the SDK tracks nothing. */\n jitsu?: JitsuConfig;\n /**\n * The store is closed: by the merchant from the dashboard, by the platform, or\n * for the selected market only. The engine then renders the maintenance page\n * to everyone but the merchant; see `rootBeforeLoad`.\n */\n maintenance?: boolean;\n /** What the maintenance page says; sent beside `maintenance`. */\n maintenance_details?: MaintenanceDetails;\n /**\n * The scope these settings were requested with; absent when none was. Not from\n * the API: stamped by `store.settings`, so `resolveThemeVersionId` can tell\n * whether the version they name still answers the scope that is active now.\n */\n requestedScopeId?: string;\n}\n\n/**\n * Converts languages object from API to array format.\n * API returns: { \"AR\": { code, name, ... }, \"EN\": { ... } }\n * We need: [{ code, name, ... }, { code, name, ... }]\n * todo:: return the languages as object from the APIs to avoid this\n */\nfunction languagesToArray(languages?: Record<string, Language>): Language[] | undefined {\n if (!languages) return undefined;\n // The SDK's localization modal reads `lang.iso_code` (not `code`) when a language is\n // selected — without it the switch navigates to `/undefined/...`.\n return Object.values(languages).map((lang) => ({ iso_code: lang.code, ...lang }));\n}\n\n/**\n * The settings' analytics context with the native app's headers in it, as Laravel\n * writes it for a Twig theme: the SDK reads the app's platform and version from there.\n * The API answers a server-side call with the engine's own headers, never the app's.\n */\nfunction withNativeAppHeaders(jitsu?: JitsuConfig): JitsuConfig | undefined {\n if (!jitsu || typeof window !== 'undefined') return jitsu;\n let appHeaders: Record<string, string> | null = null;\n try {\n appHeaders = getTwilightContext().nativeAppHeaders;\n } catch {\n return jitsu;\n }\n if (!appHeaders) return jitsu;\n const extra = jitsu.context?.extra;\n // The engine's own app headers go, so an app that sends no version doesn't get the engine's.\n const headers = { ...extra?.headers };\n for (const name of NATIVE_APP_HEADERS) delete headers[name];\n return {\n ...jitsu,\n context: {\n ...jitsu.context,\n extra: { ...extra, headers: { ...headers, ...appHeaders } },\n },\n };\n}\n\nconst SETTINGS_TIMEOUT_MS = 5000;\n\nasync function requestSettings(identifier: string): Promise<StoreContext> {\n const includeParams = DEFAULT_INCLUDE_ITEMS.map((i) => `include[]=${i}`).join('&');\n const scope = getActiveScope();\n const params = scope != null ? `${includeParams}&scope=${scope.id}` : includeParams;\n\n const json = await api\n // Sent explicitly rather than left to the client's own resolution, so\n // the identifier this function checked is the identifier that travels.\n // They agree today; a caller passing one and being answered about\n // another is the failure this makes impossible rather than unlikely.\n .get(`store/settings?${params}`, {\n timeout: SETTINGS_TIMEOUT_MS,\n headers: { [STORE_IDENTIFIER_HEADER]: identifier },\n })\n .json<{ data?: SettingsApiResponse }>();\n\n const data = json?.data;\n if (!data) {\n throw new SettingsError(\n `The Salla API answered the settings request for store \"${identifier}\" without settings.`,\n { reason: 'empty' }\n );\n }\n\n // Convert languages from object to array\n const languages = languagesToArray(data.languages);\n\n return {\n store: data.store,\n theme: data.theme,\n languages,\n currencies: data.currencies,\n external_services: data.external_services,\n headers: data.headers,\n login: data.login,\n affiliate: data.affiliate,\n policy_url: data.policy_url,\n user: data.user,\n swoole: data.swoole,\n jitsu: withNativeAppHeaders(data.jitsu),\n maintenance: data.maintenance,\n maintenance_details: data.maintenance_details,\n ...(scope && { requestedScopeId: scope.id }),\n };\n}\n\n/** The message the API put in an error body, `{ error: { message } }`, when it sent one. */\nfunction apiErrorMessage(data: unknown): string | undefined {\n const message = (data as { error?: { message?: unknown } } | undefined)?.error?.message;\n return typeof message === 'string' && message.length > 0 && message.length <= 200\n ? message\n : undefined;\n}\n\n/**\n * What core's `CurrentStoreMiddleware` answers, with a 422, when no store has the\n * username or domain it was given (or the store's status is `deleted`). The lookup is\n * `loadUseUsernameOrDomain`, the same one Twig's `checkUsername` turns into its 410.\n * The literal is not translated: it reads the same whatever language was asked for.\n */\nconst STORE_NOT_FOUND_MESSAGE = 'المتجر غير موجود';\n\n/**\n * Whether the API answered that no store has this identifier. A numeric identifier\n * is looked up with `findOrFail`, which Store's exception handler answers with a 410;\n * a username or domain gets {@link STORE_NOT_FOUND_MESSAGE}. A 410 for a username is\n * not read as one: nothing on that path answers it, and a store that does exist must\n * never be told it does not.\n */\nfunction isStoreNotFound(identifier: string, status: number, said: string | undefined): boolean {\n if (status === 410) return parseStoreId(identifier) !== null;\n return status === 422 && said === STORE_NOT_FOUND_MESSAGE;\n}\n\n/**\n * Names what went wrong, because the page, the server log and Sentry all carry\n * this message. Every failure used to read \"Make sure VITE_STORE_DOMAIN is set\",\n * a local-development variable no deployed theme has, so a slow API looked like\n * a misconfigured theme.\n */\nfunction describeSettingsFailure(identifier: string, error: unknown): SettingsError {\n if (error instanceof SettingsError) return error;\n const request = `the settings request for store \"${identifier}\"`;\n if (isTimeoutError(error)) {\n return new SettingsError(\n `The Salla API did not answer ${request} within ${SETTINGS_TIMEOUT_MS} ms.`,\n { reason: 'timeout' }\n );\n }\n if (isHTTPError(error)) {\n const { status } = error.response;\n const said = apiErrorMessage(error.data);\n return new SettingsError(\n `The Salla API answered ${request} with HTTP ${status}${said ? `: ${said}` : ''}.`,\n { reason: isStoreNotFound(identifier, status, said) ? 'not-found' : 'http', status }\n );\n }\n if (isNetworkError(error)) {\n return new SettingsError(`The Salla API could not be reached for ${request}.`, {\n reason: 'network',\n });\n }\n const detail = error instanceof Error ? `: ${error.message}` : '';\n return new SettingsError(`The settings request for store \"${identifier}\" failed${detail}.`);\n}\n\n/**\n * The settings, or a {@link SettingsError} that says why there are none. The\n * query throws it so the root route can say why the store did not load;\n * `store.settings` keeps answering `null` for its own callers.\n */\nasync function fetchSettings(storeIdentifier?: string): Promise<StoreContext> {\n const identifier = storeIdentifier ?? resolveStoreIdentifier();\n\n if (!identifier) {\n const error = new SettingsError(\n 'No store is named for this request: add `?storeId=` on the preview host, or set VITE_STORE_DOMAIN in local development.',\n { reason: 'no-store' }\n );\n console.warn('[store.settings]', error.message);\n throw error;\n }\n\n try {\n return await requestSettings(identifier);\n } catch (cause) {\n const error = describeSettingsFailure(identifier, cause);\n console.error('[store.settings]', error.message, ...(cause === error ? [] : [cause]));\n throw error;\n }\n}\n\nexport const store = {\n settings: async (storeIdentifier?: string): Promise<StoreContext | null> => {\n try {\n return await fetchSettings(storeIdentifier);\n } catch {\n // Already logged, with the reason.\n return null;\n }\n },\n\n queries: {\n settings: (storeIdentifier?: string) =>\n queryOptions<StoreContext | null>({\n queryKey: [\n 'store',\n 'settings',\n storeIdentifier,\n getTwilightContext().locale,\n getActiveScope(),\n // Two versions of one store's settings are two different answers, and\n // this is the query whose answer decides what every other call is\n // pinned to. `requestedThemeVersionId` rather than the resolved one:\n // the resolved value falls back to what these settings report, so it\n // is not knowable until after this query has run — the key would be\n // one thing on the server and another on the client, and the hydrated\n // page would refetch the settings it was just handed.\n requestedThemeVersionId(),\n ],\n // Throws rather than resolving `null`, so the failure keeps its reason.\n queryFn: () => fetchSettings(storeIdentifier),\n // A null never retried, and the root route waits on this: the router's\n // default `retry: 1` would sit through the timeout twice.\n retry: 0,\n }),\n },\n};\n"]}
@@ -1,8 +1,8 @@
1
- import { useIsHome } from './chunk-E5PEYI5I.js';
2
- import { PageAdvertisements } from './chunk-GAGTCI3J.js';
1
+ import { useIsHome } from './chunk-KXD4WUYA.js';
2
+ import { PageAdvertisements } from './chunk-7QHK77KL.js';
3
3
  import { HookSlot, useIsClient } from './chunk-5XDPAKF5.js';
4
4
  import { useTranslation } from './chunk-TYNZ5B2B.js';
5
- import { Image } from './chunk-UFQY2QQ4.js';
5
+ import { Image } from './chunk-IEU7LOKW.js';
6
6
  import { useTwilight } from './chunk-DF6FBKDN.js';
7
7
  import { lazy, useState } from 'react';
8
8
  import { SallaCartSummary } from '@salla.sa/twilight-components-react/cart-summary';
@@ -13,9 +13,9 @@ import { SallaSearch } from '@salla.sa/twilight-components-react/search';
13
13
  import { SallaUserMenu } from '@salla.sa/twilight-components-react/user-menu';
14
14
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
15
15
 
16
- var LazyMainMenu = lazy(() => import('./MainMenu-ZQLKN43L.js').then((m) => ({ default: m.MainMenu })));
16
+ var LazyMainMenu = lazy(() => import('./MainMenu-ZOP6ESHR.js').then((m) => ({ default: m.MainMenu })));
17
17
  var LazyMobileMenu = lazy(
18
- () => import('./MobileMenu-GPVASHD2.js').then((m) => ({ default: m.MobileMenu }))
18
+ () => import('./MobileMenu-NJUO7Y36.js').then((m) => ({ default: m.MobileMenu }))
19
19
  );
20
20
  function HeaderContacts() {
21
21
  const { store } = useTwilight();
@@ -126,5 +126,5 @@ function Header(_props) {
126
126
  }
127
127
 
128
128
  export { Header };
129
- //# sourceMappingURL=chunk-IRK7HSN6.js.map
130
- //# sourceMappingURL=chunk-IRK7HSN6.js.map
129
+ //# sourceMappingURL=chunk-6V4TKT7O.js.map
130
+ //# sourceMappingURL=chunk-6V4TKT7O.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/navigation/lazy.ts","../src/components/layout/Header.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAMO,IAAM,YAAA,GAAe,IAAA,CAAK,MAAM,OAAO,wBAAY,CAAA,CAAE,IAAA,CAAK,CAAC,CAAA,MAAO,EAAE,OAAA,EAAS,CAAA,CAAE,QAAA,GAAW,CAAC,CAAA;AAE3F,IAAM,cAAA,GAAiB,IAAA;AAAA,EAAK,MACjC,OAAO,0BAAc,CAAA,CAAE,IAAA,CAAK,CAAC,CAAA,MAAO,EAAE,OAAA,EAAS,CAAA,CAAE,UAAA,EAAW,CAAE;AAChE,CAAA;ACcA,SAAS,cAAA,GAAiB;AACxB,EAAA,MAAM,EAAE,KAAA,EAAM,GAAI,WAAA,EAAY;AAC9B,EAAA,MAAM,WAAW,WAAA,EAAY;AAC7B,EAAA,IAAI,CAAC,UAAU,OAAO,IAAA;AACtB,EAAA,uBAAO,GAAA,CAAC,iBAAc,QAAA,EAAU,KAAA,EAAO,UAAU,aAAA,EAAc,KAAA,EAAM,UAAQ,IAAA,EAAC,CAAA;AAChF;AAEO,SAAS,OAAO,MAAA,EAAqB;AAC1C,EAAA,MAAM,EAAE,QAAA,EAAU,KAAA,EAAO,KAAA,KAAU,WAAA,EAAY;AAC/C,EAAA,MAAM,EAAE,MAAA,EAAQ,YAAA,EAAa,GAAI,cAAA,EAAe;AAChD,EAAA,MAA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Use these for code-splitting navigation sections\n */\nexport const LazyMainMenu = lazy(() => import('./MainMenu').then((m) => ({ default: m.MainMenu })));\n\nexport const LazyMobileMenu = lazy(() =>\n import('./MobileMenu').then((m) => ({ default: m.MobileMenu }))\n);\n","import { useState } from 'react';\nimport { useIsHome } from '../../providers/NavigationProvider';\nimport { SallaCartSummary } from '@salla.sa/twilight-components-react/cart-summary';\nimport { SallaContacts } from '@salla.sa/twilight-components-react/contacts';\nimport { SallaLocalizationModal } from '@salla.sa/twilight-components-react/localization-modal';\nimport { SallaMenu } from '@salla.sa/twilight-components-react/menu';\nimport { SallaSearch } from '@salla.sa/twilight-components-react/search';\nimport { SallaUserMenu } from '@salla.sa/twilight-components-react/user-menu';\nimport { useTwilight } from '../../providers/twilight-context';\nimport { useTranslation } from '../../providers/I18nProvider';\nimport { HookSlot } from '../../hooks/HookSlot';\nimport { useIsClient } from '../../hooks/useIsClient';\nimport { MainMenu, MobileMenu } from '../navigation';\nimport { Image } from '../common';\nimport { PageAdvertisements } from './PageAdvertisements';\nimport type { Cart } from '../../types';\n\ninterface HeaderProps {\n cart?: Cart;\n}\n\n/** The store's phone and email in the top nav. `<salla-contacts>` fills its light DOM\n * once the SDK is ready, which can come before React hydrates it: a hydration error\n * (React #418). So it renders after mount. */\nfunction HeaderContacts() {\n const { store } = useTwilight();\n const isClient = useIsClient();\n if (!isClient) return null;\n return <SallaContacts contacts={store?.contacts} contactsTitle=\"N/A\" isHeader />;\n}\n\nexport function Header(_props: HeaderProps) {\n const { currency, theme, store } = useTwilight();\n const { locale, languageName } = useTranslation();\n const settings = theme?.settings || {};\n const [isMobileMenuOpen, setIsMobileMenuOpen] = useState(false);\n\n // Check if we're on homepage\n const isHomepage = useIsHome();\n\n const StoreTitle = isHomepage ? 'h1' : 'span';\n\n return (\n <header className=\"store-header\" suppressHydrationWarning>\n <HookSlot name=\"header:start\" />\n <div className=\"advertisement-slot\">\n <PageAdvertisements />\n </div>\n {/* Top Nav */}\n <div className={`top-navbar${settings.topnav_is_dark ? ' top-navbar--dark' : ''}`}>\n <div className=\"container flex justify-between\">\n <div className=\"flex-1 flex items-center gap-2\">\n {/* Footer Menu */}\n {settings.important_links && <SallaMenu source=\"footer\" topnav />}\n\n {/* Language & Currency */}\n <div className=\"header-buttons\">\n {(store?.settings?.is_multilingual || store?.settings?.currencies_enabled) && (\n <>\n <button\n type=\"button\"\n onClick={() => window.salla?.event.dispatch('localization::open')}\n className=\"btn--rounded-gray basis-0\"\n >\n <span>{languageName}</span>\n <span className=\"mx-1.5\">|</span>\n <span className={`flag iti__flag iti__${store?.country.toLowerCase()}`}></span>\n\n <span>\n {store?.settings?.use_sar_symbol && currency?.code === 'SAR' ? (\n <i className=\"sicon-sar\"></i>\n ) : (\n <>{currency?.symbol}</>\n )}\n </span>\n </button>\n {/* TODO:: support switch the lang without hit the web API, by set it in the sdk and local storage */}\n {/* TODO:: Support switch the curency without hit the web API, by set it in the sdk and local storage */}\n <SallaLocalizationModal\n language={locale}\n currency={currency?.code || 'SAR'}\n suppressHydrationWarning\n />\n </>\n )}\n </div>\n\n {/* Scopes / Branches */}\n {store?.scope && (\n <button\n type=\"button\"\n className=\"btn--rounded-gray\"\n onClick={() =>\n window.salla?.event.dispatch('scopes::open', {\n mode: 'default',\n })\n }\n >\n <i className=\"sicon-location rtl:ml-1 ltr:mr-1\"></i>\n {store.scope.name}\n </button>\n )}\n\n {/* Search bar */}\n <div className=\"header-search flex-1\">\n {/* todo:: use a search icon insted with open the search popup */}\n <SallaSearch inline oval height={36} />\n </div>\n </div>\n\n <HeaderContacts />\n </div>\n </div>\n\n {/* Main Nav */}\n <div\n id=\"mainnav\"\n className={`main-nav-container shadow-default bg-white flex items-center relative z-50${settings.header_is_sticky ? ' sticky top-0' : ''}`}\n >\n <div className=\"inner bg-inherit w-full\">\n <div className=\"container\">\n <div className=\"flex items-stretch justify-between relative\">\n <div className=\"flex items-center\">\n <a\n className=\"lg:hidden mburger mburger--collapse leading-none rtl:ml-4 ltr:mr-4\"\n href=\"#mobile-menu\"\n aria-label=\"Open-menu\"\n onClick={(e) => {\n e.preventDefault();\n setIsMobileMenuOpen(true);\n }}\n >\n <i className=\"sicon-menu text-primary text-2xl\"></i>\n </a>\n <a className=\"navbar-brand\" href={store?.url || '/'}>\n <div className=\"logo-wrapper\">\n <Image\n src={store?.logo}\n alt={`${store?.name || 'Store'} logo`}\n priority\n width={120}\n height={48}\n />\n </div>\n <StoreTitle className=\"sr-only\">{store?.name || 'Store'}</StoreTitle>\n </a>\n <MainMenu />\n </div>\n <div className=\"flex items-center justify-end my-2.5\">\n <SallaUserMenu avatarOnly showHeader className=\"header-btn\" />\n <SallaCartSummary className=\"ml-4 rtl:ml-[unset] rtl:mr-4\">\n <i slot=\"icon\" className=\"header-btn__icon icon sicon-shopping-bag\"></i>\n </SallaCartSummary>\n </div>\n </div>\n </div>\n </div>\n </div>\n\n {/* Mobile Menu */}\n <MobileMenu isOpen={isMobileMenuOpen} onClose={() => setIsMobileMenuOpen(false)} />\n <HookSlot name=\"header:end\" />\n </header>\n );\n}\n"]}
1
+ {"version":3,"sources":["../src/components/navigation/lazy.ts","../src/components/layout/Header.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAMO,IAAM,YAAA,GAAe,IAAA,CAAK,MAAM,OAAO,wBAAY,CAAA,CAAE,IAAA,CAAK,CAAC,CAAA,MAAO,EAAE,OAAA,EAAS,CAAA,CAAE,QAAA,GAAW,CAAC,CAAA;AAE3F,IAAM,cAAA,GAAiB,IAAA;AAAA,EAAK,MACjC,OAAO,0BAAc,CAAA,CAAE,IAAA,CAAK,CAAC,CAAA,MAAO,EAAE,OAAA,EAAS,CAAA,CAAE,UAAA,EAAW,CAAE;AAChE,CAAA;ACcA,SAAS,cAAA,GAAiB;AACxB,EAAA,MAAM,EAAE,KAAA,EAAM,GAAI,WAAA,EAAY;AAC9B,EAAA,MAAM,WAAW,WAAA,EAAY;AAC7B,EAAA,IAAI,CAAC,UAAU,OAAO,IAAA;AACt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AA,EACF;AAAA;AAAA,KACF;AAAA,oBAGA,GAAA,CAAC,kBAAW,MAAA,EAAQ,gBAAA,EAAkB,SAAS,MAAM,mBAAA,CAAoB,KAAK,CAAA,EAAG,CAAA;AAAA,oBACjF,GAAA,CAAC,QAAA,EAAA,EAAS,IAAA,EAAK,YAAA,EAAa;AAAA,GAAA,EAC9B,CAAA;AAEJ","file":"chunk-6V4TKT7O.js","sourcesContent":["import { lazy } from 'react';\n\n/**\n * Lazy-loaded navigation components\n * Use these for code-splitting navigation sections\n */\nexport const LazyMainMenu = lazy(() => import('./MainMenu').then((m) => ({ default: m.MainMenu })));\n\nexport const LazyMobileMenu = lazy(() =>\n import('./MobileMenu').then((m) => ({ default: m.MobileMenu }))\n);\n","import { useState } from 'react';\nimport { useIsHome } from '../../providers/NavigationProvider';\nimport { SallaCartSummary } from '@salla.sa/twilight-components-react/cart-summary';\nimport { SallaContacts } from '@salla.sa/twilight-components-react/contacts';\nimport { SallaLocalizationModal } from '@salla.sa/twilight-components-react/localization-modal';\nimport { SallaMenu } from '@salla.sa/twilight-components-react/menu';\nimport { SallaSearch } from '@salla.sa/twilight-components-react/search';\nimport { SallaUserMenu } from '@salla.sa/twilight-components-react/user-menu';\nimport { useTwilight } from '../../providers/twilight-context';\nimport { useTranslation } from '../../providers/I18nProvider';\nimport { HookSlot } from '../../hooks/HookSlot';\nimport { useIsClient } from '../../hooks/useIsClient';\nimport { MainMenu, MobileMenu } from '../navigation';\nimport { Image } from '../common';\nimport { PageAdvertisements } from './PageAdvertisements';\nimport type { Cart } from '../../types';\n\ninterface HeaderProps {\n cart?: Cart;\n}\n\n/** The store's phone and email in the top nav. `<salla-contacts>` fills its light DOM\n * once the SDK is ready, which can come before React hydrates it: a hydration error\n * (React #418). So it renders after mount. */\nfunction HeaderContacts() {\n const { store } = useTwilight();\n const isClient = useIsClient();\n if (!isClient) return null;\n return <SallaContacts contacts={store?.contacts} contactsTitle=\"N/A\" isHeader />;\n}\n\nexport function Header(_props: HeaderProps) {\n const { currency, theme, store } = useTwilight();\n const { locale, languageName } = useTranslation();\n const settings = theme?.settings || {};\n const [isMobileMenuOpen, setIsMobileMenuOpen] = useState(false);\n\n // Check if we're on homepage\n const isHomepage = useIsHome();\n\n const StoreTitle = isHomepage ? 'h1' : 'span';\n\n return (\n <header className=\"store-header\" suppressHydrationWarning>\n <HookSlot name=\"header:start\" />\n <div className=\"advertisement-slot\">\n <PageAdvertisements />\n </div>\n {/* Top Nav */}\n <div className={`top-navbar${settings.topnav_is_dark ? ' top-navbar--dark' : ''}`}>\n <div className=\"container flex justify-between\">\n <div className=\"flex-1 flex items-center gap-2\">\n {/* Footer Menu */}\n {settings.important_links && <SallaMenu source=\"footer\" topnav />}\n\n {/* Language & Currency */}\n <div className=\"header-buttons\">\n {(store?.settings?.is_multilingual || store?.settings?.currencies_enabled) && (\n <>\n <button\n type=\"button\"\n onClick={() => window.salla?.event.dispatch('localization::open')}\n className=\"btn--rounded-gray basis-0\"\n >\n <span>{languageName}</span>\n <span className=\"mx-1.5\">|</span>\n <span className={`flag iti__flag iti__${store?.country.toLowerCase()}`}></span>\n\n <span>\n {store?.settings?.use_sar_symbol && currency?.code === 'SAR' ? (\n <i className=\"sicon-sar\"></i>\n ) : (\n <>{currency?.symbol}</>\n )}\n </span>\n </button>\n {/* TODO:: support switch the lang without hit the web API, by set it in the sdk and local storage */}\n {/* TODO:: Support switch the curency without hit the web API, by set it in the sdk and local storage */}\n <SallaLocalizationModal\n language={locale}\n currency={currency?.code || 'SAR'}\n suppressHydrationWarning\n />\n </>\n )}\n </div>\n\n {/* Scopes / Branches */}\n {store?.scope && (\n <button\n type=\"button\"\n className=\"btn--rounded-gray\"\n onClick={() =>\n window.salla?.event.dispatch('scopes::open', {\n mode: 'default',\n })\n }\n >\n <i className=\"sicon-location rtl:ml-1 ltr:mr-1\"></i>\n {store.scope.name}\n </button>\n )}\n\n {/* Search bar */}\n <div className=\"header-search flex-1\">\n {/* todo:: use a search icon insted with open the search popup */}\n <SallaSearch inline oval height={36} />\n </div>\n </div>\n\n <HeaderContacts />\n </div>\n </div>\n\n {/* Main Nav */}\n <div\n id=\"mainnav\"\n className={`main-nav-container shadow-default bg-white flex items-center relative z-50${settings.header_is_sticky ? ' sticky top-0' : ''}`}\n >\n <div className=\"inner bg-inherit w-full\">\n <div className=\"container\">\n <div className=\"flex items-stretch justify-between relative\">\n <div className=\"flex items-center\">\n <a\n className=\"lg:hidden mburger mburger--collapse leading-none rtl:ml-4 ltr:mr-4\"\n href=\"#mobile-menu\"\n aria-label=\"Open-menu\"\n onClick={(e) => {\n e.preventDefault();\n setIsMobileMenuOpen(true);\n }}\n >\n <i className=\"sicon-menu text-primary text-2xl\"></i>\n </a>\n <a className=\"navbar-brand\" href={store?.url || '/'}>\n <div className=\"logo-wrapper\">\n <Image\n src={store?.logo}\n alt={`${store?.name || 'Store'} logo`}\n priority\n width={120}\n height={48}\n />\n </div>\n <StoreTitle className=\"sr-only\">{store?.name || 'Store'}</StoreTitle>\n </a>\n <MainMenu />\n </div>\n <div className=\"flex items-center justify-end my-2.5\">\n <SallaUserMenu avatarOnly showHeader className=\"header-btn\" />\n <SallaCartSummary className=\"ml-4 rtl:ml-[unset] rtl:mr-4\">\n <i slot=\"icon\" className=\"header-btn__icon icon sicon-shopping-bag\"></i>\n </SallaCartSummary>\n </div>\n </div>\n </div>\n </div>\n </div>\n\n {/* Mobile Menu */}\n <MobileMenu isOpen={isMobileMenuOpen} onClose={() => setIsMobileMenuOpen(false)} />\n <HookSlot name=\"header:end\" />\n </header>\n );\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import { EMPTY_PREVIEW_STATE, DEV_LOOKUP_TIMEOUT_MS, isEditorFrame, normalizePreviewState, DEV_PREVIEW_GLOBAL, DEV_PREVIEW_EVENT, DEV_PREVIEW_ENDPOINT } from './chunk-OXMUPNMH.js';
2
- import { resolveStoreBase } from './chunk-POI4G5EA.js';
2
+ import { resolveStoreBase } from './chunk-FHU2MXZA.js';
3
3
  import { useSyncExternalStore, useRef, useEffect, useMemo } from 'react';
4
4
 
5
5
  var LEGACY_STORAGE_KEY = "twilight:dev-settings";
@@ -137,7 +137,7 @@ function listenForFrameMessages(s, signal) {
137
137
  async function answerLookup(message) {
138
138
  const { requestId, source, query } = message;
139
139
  try {
140
- const { lookupInStore } = await import('./store-lookup-LVKWUL6Z.js');
140
+ const { lookupInStore } = await import('./store-lookup-6QB4WMID.js');
141
141
  sendToEditor({ kind: "lookup-result", requestId, items: await lookupInStore(source, query) });
142
142
  } catch (error) {
143
143
  sendToEditor({
@@ -457,5 +457,5 @@ function useDevLayoutBlocks(components) {
457
457
  var useDevHomeBlocks = import.meta.env.DEV ? useDevLayoutBlocks : (components) => components;
458
458
 
459
459
  export { blockPath, devSettingsStore, useDevEditorMeta, useDevHomeBlocks, useDevSettingsOverrides, useDevSettingsState };
460
- //# sourceMappingURL=chunk-FMSRB2TT.js.map
461
- //# sourceMappingURL=chunk-FMSRB2TT.js.map
460
+ //# sourceMappingURL=chunk-74W2O47D.js.map
461
+ //# sourceMappingURL=chunk-74W2O47D.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/dev/dev-settings-store.ts"],"names":["block"],"mappings":";;;;AA4CA,IAAM,kBAAA,GAAqB,uBAAA;AAE3B,IAAM,aAAA,GAAgB,GAAA;AAEtB,IAAM,YAAA,GAAe,kBAAA;AAErB,IAAM,aAAA,GAAgB,iBAAA;AAEtB,IAAM,aAAA,GAAgB,GAAA;AACtB,IAAM,cAAA,GAAiB,IAAA;AAgBvB,IAAM,cAAA,uBAAqB,GAAA,EAA2B;AAetD,SAAS,QAAA,CAAS,QAAQ,CAAA,EAAW;AACnC,EAAA,MAAM,SAAS,UAAA,CAAW,MAAA,CAAO,gBAAgB,IAAI,UAAA,CAAW,KAAK,CAAC,CAAA;AACtE,EAAA,OAAO,KAAA,CAAM,IAAA,CAAK,MAAA,EAAQ,CAAC,MAAM,CAAA,CAAE,QAAA,CAAS,EAAE,CAAA,C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,IAAI,KAAA,CAAM,EAAA,EAAI,EAAE,MAAA,EAAQ,KAAA,CAAM,MAAA,EAAQ,MAAA,EAAQ,CAAA;AAE3D,MAAA,MAAM,KAAA,GAAQ,SAAS,CAAA,EAAG,KAAA,CAAM,EAAE,CAAA,CAAA,EAAI,MAAM,KAAK,KAAA,CAAM,EAAA;AACvD,MAAA,OAAO,EAAE,GAAG,KAAA,CAAM,MAAA,EAAQ,MAAM,KAAA,CAAM,IAAA,EAAM,UAAU,KAAA,EAAM;AAAA,IAC9D,CAAC,CAAA;AAAA,EACH,CAAA,EAAG,CAAC,UAAA,EAAY,SAAS,CAAC,CAAA;AAC5B;AAEO,IAAM,mBACX,MAAA,CAAA,IAAA,CAAY,GAAA,CAAI,GAAA,GAAM,kBAAA,GAAqB,CAAC,UAAA,KAAe","file":"chunk-FMSRB2TT.js","sourcesContent":["/**\n * Client-side store for the dev editor: theme-setting overrides and a dev-owned\n * home layout. Saved to `twilight.preview.json` through the dev server (see\n * `twilight-schema.plugin.ts`), not to localStorage, for three reasons: the\n * server render can read a file, so the page hydrates with the edited layout\n * instead of flashing the store's; the state survives a port or browser\n * change; and the developer can open, diff or delete it.\n *\n * The saved state reaches this module through `virtual:twilight/schema`, which\n * the root route imports on both sides before anything renders and which puts\n * it on `globalThis[DEV_PREVIEW_GLOBAL]`. Server snapshots read that value\n * (the server's modules are re-run after each save); the browser copies it once\n * and then owns the state.\n *\n * The theme editor (`/__twilight/editor`) frames the storefront, so two copies\n * of this store run side by side. Edits reach every copy on the origin at once\n * over a `BroadcastChannel` (the file save is debounced), and only the copy\n * that made an edit saves it. Everything else between an editor and its frame\n * (the home page's blocks, the store base, scroll-to-block) goes by\n * `postMessage` to that one window, so another storefront tab never answers.\n */\n\nimport { useEffect, useMemo, useRef, useSyncExternalStore } from 'react';\nimport {\n DEV_LOOKUP_TIMEOUT_MS,\n DEV_PREVIEW_ENDPOINT,\n DEV_PREVIEW_EVENT,\n DEV_PREVIEW_GLOBAL,\n EMPTY_PREVIEW_STATE,\n isEditorFrame,\n normalizePreviewState,\n type DevLookupItem,\n type DevLookupSource,\n type DevPreviewBlock,\n type DevPreviewState,\n type DevSchema,\n} from './schema-types';\nimport { resolveStoreBase } from '../utils/store-identity';\n\nexport type DevSettingsState = DevPreviewState;\nexport type DevSaveStatus = 'idle' | 'saving' | 'saved' | 'error';\ntype LiveBlocks = { path?: string }[];\n\n/** Where the old localStorage-backed widget kept its state; migrated once. */\nconst LEGACY_STORAGE_KEY = 'twilight:dev-settings';\n/** Batch keystrokes into one write. */\nconst SAVE_DELAY_MS = 250;\n/** Same-browser channel every copy of the store listens on, for edits. */\nconst CHANNEL_NAME = 'twilight:preview';\n/** Envelope type of the editor ↔ frame `postMessage`s. */\nconst FRAME_MESSAGE = 'twilight:editor';\n/** How long the frame keeps looking for a block that is still rendering (just added, say). */\nconst FOCUS_WAIT_MS = 2000;\nconst FOCUS_FLASH_MS = 1200;\n\n/** Editor ↔ the storefront it frames. */\ntype FrameMessage =\n | { kind: 'live-blocks'; blocks: LiveBlocks | null }\n | { kind: 'frame-info'; base: string | null }\n | { kind: 'request-live-blocks' }\n | { kind: 'focus-block'; index: number }\n | { kind: 'lookup'; requestId: string; source: DevLookupSource; query: string }\n | { kind: 'lookup-result'; requestId: string; items?: DevLookupItem[]; error?: string };\n\ninterface PendingLookup {\n resolve: (items: DevLookupItem[]) => void;\n reject: (error: Error) => void;\n timer: ReturnType<typeof setTimeout>;\n}\nconst pendingLookups = new Map<string, PendingLookup>();\n\n/** What the editor shows besides the saved state. */\nexport interface DevEditorMeta {\n /** The blocks the framed home page shows; `null` when it is not on the home page. */\n liveBlocks: LiveBlocks | null;\n saveStatus: DevSaveStatus;\n /** The frame's store segment; `undefined` until the frame has said. */\n frameBase: string | null | undefined;\n}\n\n/**\n * A short random hex id. `getRandomValues`, not `randomUUID`: the latter only\n * exists in secure contexts, and the dev server may be opened on a LAN address.\n */\nfunction randomId(bytes = 6): string {\n const values = globalThis.crypto.getRandomValues(new Uint8Array(bytes));\n return Array.from(values, (b) => b.toString(16).padStart(2, '0')).join('');\n}\n\nlet tabId: string | undefined;\n\n/**\n * Sent with every save so this tab can ignore its own broadcast. Made on first\n * use, never at module load: Cloudflare Workers refuse random values in global\n * scope, and this module is in the worker bundle (its use is dev-only, its\n * top level is not).\n */\nfunction myTabId(): string {\n tabId ??= randomId();\n return tabId;\n}\n\nlet seedSource: unknown;\nlet seedState: DevPreviewState = EMPTY_PREVIEW_STATE;\n\n/** The saved file as this page loaded it, normalized once per value so snapshots keep their identity. */\nfunction readSeed(): DevPreviewState {\n const raw = (globalThis as Record<string, unknown>)[DEV_PREVIEW_GLOBAL];\n if (raw !== seedSource) {\n seedSource = raw;\n seedState = normalizePreviewState(raw) ?? EMPTY_PREVIEW_STATE;\n }\n return seedState;\n}\n\n// The widget (bundled into the `/dev` entry) and the theme merge (bundled into\n// the engine index via `useTwilightInit`) import this module from two different\n// chunks, so each would otherwise get its OWN copy of the state — the widget\n// would enable a store the merge never reads. Back the state with a single\n// globalThis-keyed instance so every copy shares one source of truth. Dev-only,\n// so a global is acceptable (and lazy, so the module stays side-effect free and\n// tree-shakes out of production).\ninterface DevStoreSingleton {\n state: DevPreviewState;\n listeners: Set<() => void>;\n /** This page's own home blocks, when it is a storefront on its home page. Never saved. */\n ownBlocks: LiveBlocks | null;\n meta: DevEditorMeta;\n metaListeners: Set<() => void>;\n saveTimer: ReturnType<typeof setTimeout> | undefined;\n /** An edit that has not been sent yet. */\n dirty: boolean;\n /** A save request on its way; the next one waits for it, so saves land in order. */\n inFlight: boolean;\n /** The old localStorage copy is removed only once the file has the migrated values. */\n legacyPending: boolean;\n channel: BroadcastChannel | null;\n /** In the editor: the storefront frame's window. */\n getFrame: (() => Window | null) | null;\n /** Detach this copy's listeners and channel. A page keeps one copy for good; tests swap them. */\n dispose: () => void;\n}\n\nconst SINGLETON_KEY = '__twilightDevSettingsStore__';\n\nfunction singleton(): DevStoreSingleton {\n const g = globalThis as unknown as Record<string, DevStoreSingleton | undefined>;\n let s = g[SINGLETON_KEY];\n if (!s) {\n const seeded = (globalThis as Record<string, unknown>)[DEV_PREVIEW_GLOBAL] != null;\n s = {\n state: readSeed(),\n listeners: new Set(),\n ownBlocks: null,\n meta: { liveBlocks: null, saveStatus: 'idle', frameBase: undefined },\n metaListeners: new Set(),\n saveTimer: undefined,\n dirty: false,\n inFlight: false,\n legacyPending: false,\n channel: null,\n getFrame: null,\n dispose: () => {},\n };\n g[SINGLETON_KEY] = s;\n if (typeof window !== 'undefined') setUpBrowser(s, seeded);\n }\n return s;\n}\n\nfunction setUpBrowser(s: DevStoreSingleton, seeded: boolean): void {\n const listeners = new AbortController();\n const { signal } = listeners;\n if (!seeded) migrateLegacy(s);\n listenForOtherTabs();\n s.channel = openChannel();\n listenForFrameMessages(s, signal);\n window.addEventListener('pagehide', () => flushOnExit(s), { signal });\n s.dispose = () => {\n listeners.abort();\n s.channel?.close();\n clearTimeout(s.saveTimer);\n };\n if (isEditorFrame()) sendToEditor({ kind: 'frame-info', base: resolveStoreBase() });\n}\n\n/** Carry the old widget's settings over; its per-block patches don't map to a layout. */\nfunction migrateLegacy(s: DevStoreSingleton): void {\n try {\n const raw = window.localStorage.getItem(LEGACY_STORAGE_KEY);\n if (!raw) return;\n const legacy = normalizePreviewState(JSON.parse(raw));\n if (!legacy) return;\n s.state = { enabled: legacy.enabled, settings: legacy.settings, layout: null };\n s.legacyPending = true;\n scheduleSave(s);\n } catch {\n // Storage blocked or the old value is corrupt: nothing worth keeping.\n }\n}\n\n/** Vite's HMR client, typed locally: the engine's `ImportMeta` must not clash with `vite/client`. */\ninterface HotContext {\n on(event: string, cb: (payload: { state?: unknown; from?: unknown }) => void): void;\n}\n\n/**\n * Take a state another copy committed. Not while this copy has an edit of its\n * own waiting to be saved: that edit is newer, and saving it will tell the rest.\n */\nfunction receive(raw: unknown): void {\n const s = singleton();\n if (s.dirty || s.inFlight || s.saveTimer) return;\n const next = normalizePreviewState(raw);\n if (next && JSON.stringify(next) !== JSON.stringify(s.state)) emit(next);\n}\n\n/** Tabs in another browser hear about a save from the dev server. */\nfunction listenForOtherTabs(): void {\n const hot = (import.meta as ImportMeta & { hot?: HotContext }).hot;\n if (!hot) return;\n hot.on(DEV_PREVIEW_EVENT, (payload) => {\n if (payload?.from !== myTabId()) receive(payload?.state);\n });\n}\n\nfunction openChannel(): BroadcastChannel | null {\n if (typeof BroadcastChannel === 'undefined') return null;\n const channel = new BroadcastChannel(CHANNEL_NAME);\n channel.onmessage = ({ data }: MessageEvent<{ state?: unknown; from?: string }>) => {\n if (data && data.from !== myTabId()) receive(data.state);\n };\n return channel;\n}\n\nfunction sendToEditor(message: FrameMessage): void {\n if (isEditorFrame())\n window.parent.postMessage({ type: FRAME_MESSAGE, message }, window.location.origin);\n}\n\nfunction sendToFrame(message: FrameMessage): void {\n singleton().getFrame?.()?.postMessage({ type: FRAME_MESSAGE, message }, window.location.origin);\n}\n\nfunction reportToEditor(s: DevStoreSingleton): void {\n sendToEditor({ kind: 'frame-info', base: resolveStoreBase() });\n sendToEditor({ kind: 'live-blocks', blocks: s.ownBlocks });\n}\n\n/**\n * The editor ↔ frame conversation. A frame only takes requests from its own\n * parent; an editor only takes reports from the frame it shows.\n */\nfunction listenForFrameMessages(s: DevStoreSingleton, signal: AbortSignal): void {\n window.addEventListener(\n 'message',\n (event: MessageEvent) => {\n if (event.origin !== window.location.origin || event.data?.type !== FRAME_MESSAGE) return;\n const message = event.data.message as FrameMessage;\n if (window.parent !== window && event.source === window.parent) {\n if (message.kind === 'request-live-blocks') reportToEditor(s);\n else if (message.kind === 'focus-block') scrollToBlock(message.index);\n else if (message.kind === 'lookup') void answerLookup(message);\n return;\n }\n const frame = s.getFrame?.();\n if (!frame || event.source !== frame) return;\n if (message.kind === 'lookup-result') settleLookup(message);\n else if (message.kind === 'live-blocks') setMeta({ liveBlocks: message.blocks });\n else if (message.kind === 'frame-info') setMeta({ frameBase: message.base });\n },\n { signal }\n );\n}\n\n/** In the frame: look the request up in the store and send back what was found, or why not. */\nasync function answerLookup(message: Extract<FrameMessage, { kind: 'lookup' }>): Promise<void> {\n const { requestId, source, query } = message;\n try {\n const { lookupInStore } = await import('./store-lookup');\n sendToEditor({ kind: 'lookup-result', requestId, items: await lookupInStore(source, query) });\n } catch (error) {\n sendToEditor({\n kind: 'lookup-result',\n requestId,\n error: error instanceof Error ? error.message : 'lookup failed',\n });\n }\n}\n\nfunction settleLookup(message: Extract<FrameMessage, { kind: 'lookup-result' }>): void {\n const pending = pendingLookups.get(message.requestId);\n if (!pending) return;\n pendingLookups.delete(message.requestId);\n clearTimeout(pending.timer);\n if (message.items) pending.resolve(message.items);\n else pending.reject(new Error(message.error ?? 'lookup failed'));\n}\n\n/**\n * In the editor's frame: bring a home block into view and flash an outline on\n * it. Dev-only editor chrome, so it styles the element directly rather than\n * through the theme's React tree. A block added a moment ago may not be in the\n * DOM yet, so look for it for a little while.\n */\nfunction scrollToBlock(index: number): void {\n const started = Date.now();\n const find = () => {\n const el = document.querySelector<HTMLElement>(`[data-home-block=\"${index}\"]`);\n if (!el) {\n if (Date.now() - started < FOCUS_WAIT_MS) requestAnimationFrame(find);\n return;\n }\n const { outline, outlineOffset, scrollMarginTop } = el.style;\n // Clear a sticky header, which would otherwise cover the block's top.\n el.style.scrollMarginTop = '80px';\n el.scrollIntoView({ behavior: 'smooth', block: 'start' });\n el.style.outline = '2px solid #0d9488';\n el.style.outlineOffset = '-2px';\n setTimeout(() => {\n el.style.outline = outline;\n el.style.outlineOffset = outlineOffset;\n el.style.scrollMarginTop = scrollMarginTop;\n }, FOCUS_FLASH_MS);\n };\n find();\n}\n\nfunction emit(next: DevPreviewState): void {\n const s = singleton();\n s.state = next;\n s.listeners.forEach((l) => l());\n}\n\nfunction setMeta(patch: Partial<DevEditorMeta>): void {\n const s = singleton();\n s.meta = { ...s.meta, ...patch };\n s.metaListeners.forEach((l) => l());\n}\n\nfunction saveRequest(s: DevStoreSingleton, keepalive = false): Promise<Response> {\n return fetch(DEV_PREVIEW_ENDPOINT, {\n method: 'POST',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify({ state: s.state, from: myTabId() }),\n keepalive,\n });\n}\n\n/** Send the current state, one request at a time; edits made meanwhile go in the next one. */\nasync function flush(s: DevStoreSingleton): Promise<void> {\n if (s.inFlight || !s.dirty) return;\n s.inFlight = true;\n s.dirty = false;\n let failed = false;\n try {\n const res = await saveRequest(s);\n if (!res.ok) throw new Error(`HTTP ${res.status}`);\n if (s.legacyPending) {\n s.legacyPending = false;\n try {\n window.localStorage.removeItem(LEGACY_STORAGE_KEY);\n } catch {\n // Storage went away; the file has the values now either way.\n }\n }\n if (!s.dirty && !s.saveTimer) setMeta({ saveStatus: 'saved' });\n } catch (error) {\n // Still unsaved: another tab's state must not replace it, and leaving the\n // page still sends it. Edits made while this request was out are sent once\n // more; the failed one alone waits for the next edit, so nothing loops.\n failed = !s.dirty;\n s.dirty = true;\n setMeta({ saveStatus: 'error' });\n console.error('[twilight-react:preview] could not save twilight.preview.json', error);\n } finally {\n s.inFlight = false;\n if (!failed && s.dirty && !s.saveTimer) void flush(s);\n }\n}\n\nfunction scheduleSave(s: DevStoreSingleton): void {\n if (typeof window === 'undefined' || typeof fetch === 'undefined') return;\n s.dirty = true;\n clearTimeout(s.saveTimer);\n setMeta({ saveStatus: 'saving' });\n s.saveTimer = setTimeout(() => {\n s.saveTimer = undefined;\n void flush(s);\n }, SAVE_DELAY_MS);\n}\n\n/** Closing or reloading the editor must not drop the last edit: send it on the way out. */\nfunction flushOnExit(s: DevStoreSingleton): void {\n if (!s.dirty) return;\n clearTimeout(s.saveTimer);\n s.saveTimer = undefined;\n s.dirty = false;\n void saveRequest(s, true).catch(() => {});\n}\n\nfunction commit(next: DevPreviewState): void {\n const s = singleton();\n emit(next);\n try {\n s.channel?.postMessage({ state: next, from: myTabId() });\n } catch {\n // A value that can't be cloned: the other copies pick it up from the save instead.\n }\n scheduleSave(s);\n}\n\nfunction newBlockId(): string {\n return `b-${randomId()}`;\n}\n\n/** Home loader spelling of a twilight.json path. */\nexport function blockPath(path: string): string {\n return path.replace(/^home\\./, '');\n}\n\nfunction updateLayout(update: (layout: DevPreviewBlock[]) => DevPreviewBlock[]): void {\n const { state } = singleton();\n commit({ ...state, layout: update(state.layout ?? []) });\n}\n\n/** A new block for a twilight.json component, filled with its defaults. */\nfunction blockFor(schema: DevSchema, path: string): DevPreviewBlock {\n const component = schema.components.find((c) => c.path === path);\n const defaults = schema.blockDefaults?.[path] ?? schema.componentDefaults[path] ?? {};\n return {\n id: newBlockId(),\n path: blockPath(path),\n fields: { ...(component?.key ? { key: component.key } : {}), ...defaults },\n };\n}\n\nexport const devSettingsStore = {\n get: (): DevPreviewState => singleton().state,\n /** What the server rendered: the saved file as of this page load. */\n getServer: (): DevPreviewState => readSeed(),\n subscribe(listener: () => void): () => void {\n const s = singleton();\n s.listeners.add(listener);\n return () => {\n s.listeners.delete(listener);\n };\n },\n /** Turn overrides on, seeding any unset setting with its twilight.json default. */\n enable(schema: DevSchema): void {\n const { state } = singleton();\n commit({\n ...state,\n enabled: true,\n settings: { ...schema.settingsDefaults, ...state.settings },\n });\n },\n disable(): void {\n commit({ ...singleton().state, enabled: false });\n },\n setSetting(id: string, value: unknown): void {\n const { state } = singleton();\n commit({ ...state, settings: { ...state.settings, [id]: value } });\n },\n /** Restore every setting to its twilight.json default (keeps enabled and the layout). */\n resetSettings(schema: DevSchema): void {\n commit({ ...singleton().state, settings: { ...schema.settingsDefaults } });\n },\n\n // ── Editor ↔ frame ───────────────────────────────────────────────────────\n\n /** The editor tells the store which window is its storefront frame. */\n connectFrame(getFrame: () => Window | null): () => void {\n const s = singleton();\n s.getFrame = getFrame;\n return () => {\n if (s.getFrame === getFrame) s.getFrame = null;\n };\n },\n /** A storefront's home page reports its blocks (`null` when it leaves); in the editor's frame they go to the editor. Not saved. */\n setLiveBlocks(blocks: LiveBlocks | null): void {\n const s = singleton();\n s.ownBlocks = blocks;\n sendToEditor({ kind: 'live-blocks', blocks });\n },\n /** Ask the frame for its home page's blocks and its store base. */\n requestLiveBlocks(): void {\n sendToFrame({ kind: 'request-live-blocks' });\n },\n /**\n * Search the dev store through the editor's frame. Rejects when there is no\n * frame, it doesn't answer in time, or the store refuses; pickers then fall\n * back to samples.\n */\n lookup(source: DevLookupSource, query: string): Promise<DevLookupItem[]> {\n const frame = singleton().getFrame?.();\n if (!frame) return Promise.reject(new Error('no storefront frame'));\n const requestId = randomId();\n return new Promise((resolve, reject) => {\n const timer = setTimeout(() => {\n pendingLookups.delete(requestId);\n reject(new Error('the storefront did not answer'));\n }, DEV_LOOKUP_TIMEOUT_MS);\n pendingLookups.set(requestId, { resolve, reject, timer });\n sendToFrame({ kind: 'lookup', requestId, source, query });\n });\n },\n /** Scroll the editor's frame to the home block at `index`. */\n focusBlock(index: number): void {\n sendToFrame({ kind: 'focus-block', index });\n },\n getMeta: (): DevEditorMeta => singleton().meta,\n subscribeMeta(listener: () => void): () => void {\n const s = singleton();\n s.metaListeners.add(listener);\n return () => {\n s.metaListeners.delete(listener);\n };\n },\n\n // ── Home layout ──────────────────────────────────────────────────────────\n\n /**\n * Take over the home layout. Starts from the blocks the home page showed (the\n * frame's in the editor; an empty page stays empty), otherwise from every\n * twilight.json component.\n */\n customizeLayout(schema: DevSchema): void {\n const s = singleton();\n const live = s.meta.liveBlocks ?? s.ownBlocks;\n const layout: DevPreviewBlock[] =\n live !== null\n ? live\n .filter((block): block is { path: string } => typeof block.path === 'string')\n .filter((block) => block.path !== '')\n .map(({ path, ...fields }) => ({ id: newBlockId(), path: blockPath(path), fields }))\n : schema.components.map((component) => blockFor(schema, component.path));\n commit({ ...s.state, enabled: true, layout });\n },\n startEmptyLayout(): void {\n commit({ ...singleton().state, enabled: true, layout: [] });\n },\n /** Back to the store's own blocks. */\n clearLayout(): void {\n commit({ ...singleton().state, layout: null });\n },\n /** Insert a twilight.json component at `at` (default: the end); returns the new block's id. */\n addBlock(schema: DevSchema, path: string, at?: number): string {\n const block = blockFor(schema, path);\n updateLayout((layout) => {\n const next = [...layout];\n next.splice(at ?? next.length, 0, block);\n return next;\n });\n return block.id;\n },\n removeBlock(id: string): void {\n updateLayout((layout) => layout.filter((block) => block.id !== id));\n },\n duplicateBlock(id: string): void {\n updateLayout((layout) => {\n const index = layout.findIndex((block) => block.id === id);\n if (index === -1) return layout;\n const copy = { ...layout[index], id: newBlockId(), fields: { ...layout[index].fields } };\n return [...layout.slice(0, index + 1), copy, ...layout.slice(index + 1)];\n });\n },\n /** Move a block to index `to` (its position after the move). */\n moveBlock(id: string, to: number): void {\n updateLayout((layout) => {\n const from = layout.findIndex((block) => block.id === id);\n if (from === -1) return layout;\n const target = Math.max(0, Math.min(to, layout.length - 1));\n if (target === from) return layout;\n const next = [...layout];\n const [block] = next.splice(from, 1);\n next.splice(target, 0, block);\n return next;\n });\n },\n setBlockField(id: string, fieldId: string, value: unknown): void {\n updateLayout((layout) =>\n layout.map((block) =>\n block.id === id ? { ...block, fields: { ...block.fields, [fieldId]: value } } : block\n )\n );\n },\n};\n\nconst SERVER_META: DevEditorMeta = { liveBlocks: null, saveStatus: 'idle', frameBase: undefined };\n\n/** The frame's blocks and store base, and the save status, for the editor. */\nexport function useDevEditorMeta(): DevEditorMeta {\n return useSyncExternalStore(\n devSettingsStore.subscribeMeta,\n devSettingsStore.getMeta,\n () => SERVER_META\n );\n}\n\n/** Raw store subscription. */\nexport function useDevSettingsState(): DevPreviewState {\n return useSyncExternalStore(\n devSettingsStore.subscribe,\n devSettingsStore.get,\n devSettingsStore.getServer\n );\n}\n\n/**\n * Overrides for SSR-rendered consumers (the theme). The server and the first\n * browser render both read the saved file, so they agree and nothing flashes.\n *\n * Which hook this is gets decided once, when the module loads: in production\n * `import.meta.env.DEV` is a static `false`, so only the empty one survives\n * bundling and the store subscription (and the whole store module, which has\n * no other prod consumer) is dead-code-eliminated. No hook is ever called\n * conditionally.\n */\nexport const useDevSettingsOverrides: () => DevPreviewState = import.meta.env.DEV\n ? useDevSettingsState\n : () => EMPTY_PREVIEW_STATE;\n\n/** A rendered home block; `__dev_id` keys a dev-layout block across reorders. */\nexport type DevHomeBlock<T> = T & { __dev_id?: string };\n\n/**\n * Whether a list in a block's fields gained, lost or reordered items. Blocks\n * often hand their items to a web component that takes them once when it\n * starts (a slider moves its slides into its own track), so such a change\n * never reaches the page until the block mounts again. Editing an item's\n * values is not one: the nodes stay put and update in place.\n */\nexport function listsReshaped(\n before: Record<string, unknown>,\n after: Record<string, unknown>\n): boolean {\n for (const key of new Set([...Object.keys(before), ...Object.keys(after)])) {\n const a = before[key];\n const b = after[key];\n if (!Array.isArray(a) && !Array.isArray(b)) continue;\n if (!Array.isArray(a) || !Array.isArray(b) || a.length !== b.length) return true;\n const aItems = a.map((item) => JSON.stringify(item));\n const bItems = b.map((item) => JSON.stringify(item));\n const moved = aItems.some((item, i) => item !== bItems[i]);\n if (moved && [...aItems].sort().join('\\n') === [...bItems].sort().join('\\n')) return true;\n }\n return false;\n}\n\n/**\n * The home page's blocks: the dev layout when one is saved and enabled, else\n * the store's own blocks untouched. Also reports the store's blocks to the\n * editor so \"Customize\" can start from what the page showed, and withdraws\n * them when the page goes.\n *\n * Same production story as {@link useDevSettingsOverrides}: chosen once at\n * module load, so production keeps only the passthrough.\n */\nfunction useDevLayoutBlocks<T extends { path?: string }>(components: T[]): DevHomeBlock<T>[] {\n const overrides = useDevSettingsState();\n // Per block: the fields last rendered, and how often its lists were reshaped.\n const seen = useRef(new Map<string, { fields: Record<string, unknown>; mounts: number }>());\n useEffect(() => {\n devSettingsStore.setLiveBlocks(components);\n return () => devSettingsStore.setLiveBlocks(null);\n }, [components]);\n return useMemo(() => {\n if (!overrides.enabled || !overrides.layout) return components;\n return overrides.layout.map((block) => {\n const last = seen.current.get(block.id);\n const mounts =\n (last?.mounts ?? 0) + (last && listsReshaped(last.fields, block.fields) ? 1 : 0);\n seen.current.set(block.id, { fields: block.fields, mounts });\n // A new key mounts the block again, so a reshaped list reaches the page.\n const devId = mounts ? `${block.id}~${mounts}` : block.id;\n return { ...block.fields, path: block.path, __dev_id: devId } as DevHomeBlock<T>;\n });\n }, [components, overrides]);\n}\n\nexport const useDevHomeBlocks: <T extends { path?: string }>(components: T[]) => DevHomeBlock<T>[] =\n import.meta.env.DEV ? useDevLayoutBlocks : (components) => components;\n"]}
1
+ {"version":3,"sources":["../src/dev/dev-settings-store.ts"],"names":["block"],"mappings":";;;;AA4CA,IAAM,kBAAA,GAAqB,uBAAA;AAE3B,IAAM,aAAA,GAAgB,GAAA;AAEtB,IAAM,YAAA,GAAe,kBAAA;AAErB,IAAM,aAAA,GAAgB,iBAAA;AAEtB,IAAM,aAAA,GAAgB,GAAA;AACtB,IAAM,cAAA,GAAiB,IAAA;AAgBvB,IAAM,cAAA,uBAAqB,GAAA,EAA2B;AAetD,SAAS,QAAA,CAAS,QAAQ,CAAA,EAAW;AACnC,EAAA,MAAM,SAAS,UAAA,CAAW,MAAA,CAAO,gBAAgB,IAAI,UAAA,CAAW,KAAK,CAAC,CAAA;AACtE,EAAA,OAAO,KAAA,CAAM,IAAA,CAAK,MAAA,EAAQ,CAAC,MAAM,CAAA,CAAE,QAAA,CAAS,EAAE,CAAA,CAAE,SAAS,CAAA,EAAG,GAAG,CAAC,CAAA,CAAE,KAAK,EAAE,CAAA;AAC3E;AAEA,IAAI,KAAA;AAQJ,SAAS,OAAA,GAAkB;AACzB,EAAA,KAAA,KAAU,QAAA,EAAS;AACnB,EAAA,OAAO,KAAA;AACT;AAEA,IAAI,UAAA;AACJ,IAAI,SAAA,GAA6B,mBAAA;AAGjC,SAAS,QAAA,GAA4B;AACnC,EAAA,MAAM,GAAA,GAAO,WAAuC,kBAAkB,CAAA;AACtE,EAAA,IAAI,QAAQ,UAAA,EAAY;AACtB,IAAA,UAAA,GAAa,GAAA;AACb,IAAA,SAAA,GAAY,qBAAA,CAAsB,GAAG,CAAA,IAAK,mBAAA;AAAA,EAC5C;AACA,EAAA,OAAO,SAAA;AACT;AA8B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B,CAAC,UAAA,KAAe","file":"chunk-74W2O47D.js","sourcesContent":["/**\n * Client-side store for the dev editor: theme-setting overrides and a dev-owned\n * home layout. Saved to `twilight.preview.json` through the dev server (see\n * `twilight-schema.plugin.ts`), not to localStorage, for three reasons: the\n * server render can read a file, so the page hydrates with the edited layout\n * instead of flashing the store's; the state survives a port or browser\n * change; and the developer can open, diff or delete it.\n *\n * The saved state reaches this module through `virtual:twilight/schema`, which\n * the root route imports on both sides before anything renders and which puts\n * it on `globalThis[DEV_PREVIEW_GLOBAL]`. Server snapshots read that value\n * (the server's modules are re-run after each save); the browser copies it once\n * and then owns the state.\n *\n * The theme editor (`/__twilight/editor`) frames the storefront, so two copies\n * of this store run side by side. Edits reach every copy on the origin at once\n * over a `BroadcastChannel` (the file save is debounced), and only the copy\n * that made an edit saves it. Everything else between an editor and its frame\n * (the home page's blocks, the store base, scroll-to-block) goes by\n * `postMessage` to that one window, so another storefront tab never answers.\n */\n\nimport { useEffect, useMemo, useRef, useSyncExternalStore } from 'react';\nimport {\n DEV_LOOKUP_TIMEOUT_MS,\n DEV_PREVIEW_ENDPOINT,\n DEV_PREVIEW_EVENT,\n DEV_PREVIEW_GLOBAL,\n EMPTY_PREVIEW_STATE,\n isEditorFrame,\n normalizePreviewState,\n type DevLookupItem,\n type DevLookupSource,\n type DevPreviewBlock,\n type DevPreviewState,\n type DevSchema,\n} from './schema-types';\nimport { resolveStoreBase } from '../utils/store-identity';\n\nexport type DevSettingsState = DevPreviewState;\nexport type DevSaveStatus = 'idle' | 'saving' | 'saved' | 'error';\ntype LiveBlocks = { path?: string }[];\n\n/** Where the old localStorage-backed widget kept its state; migrated once. */\nconst LEGACY_STORAGE_KEY = 'twilight:dev-settings';\n/** Batch keystrokes into one write. */\nconst SAVE_DELAY_MS = 250;\n/** Same-browser channel every copy of the store listens on, for edits. */\nconst CHANNEL_NAME = 'twilight:preview';\n/** Envelope type of the editor ↔ frame `postMessage`s. */\nconst FRAME_MESSAGE = 'twilight:editor';\n/** How long the frame keeps looking for a block that is still rendering (just added, say). */\nconst FOCUS_WAIT_MS = 2000;\nconst FOCUS_FLASH_MS = 1200;\n\n/** Editor ↔ the storefront it frames. */\ntype FrameMessage =\n | { kind: 'live-blocks'; blocks: LiveBlocks | null }\n | { kind: 'frame-info'; base: string | null }\n | { kind: 'request-live-blocks' }\n | { kind: 'focus-block'; index: number }\n | { kind: 'lookup'; requestId: string; source: DevLookupSource; query: string }\n | { kind: 'lookup-result'; requestId: string; items?: DevLookupItem[]; error?: string };\n\ninterface PendingLookup {\n resolve: (items: DevLookupItem[]) => void;\n reject: (error: Error) => void;\n timer: ReturnType<typeof setTimeout>;\n}\nconst pendingLookups = new Map<string, PendingLookup>();\n\n/** What the editor shows besides the saved state. */\nexport interface DevEditorMeta {\n /** The blocks the framed home page shows; `null` when it is not on the home page. */\n liveBlocks: LiveBlocks | null;\n saveStatus: DevSaveStatus;\n /** The frame's store segment; `undefined` until the frame has said. */\n frameBase: string | null | undefined;\n}\n\n/**\n * A short random hex id. `getRandomValues`, not `randomUUID`: the latter only\n * exists in secure contexts, and the dev server may be opened on a LAN address.\n */\nfunction randomId(bytes = 6): string {\n const values = globalThis.crypto.getRandomValues(new Uint8Array(bytes));\n return Array.from(values, (b) => b.toString(16).padStart(2, '0')).join('');\n}\n\nlet tabId: string | undefined;\n\n/**\n * Sent with every save so this tab can ignore its own broadcast. Made on first\n * use, never at module load: Cloudflare Workers refuse random values in global\n * scope, and this module is in the worker bundle (its use is dev-only, its\n * top level is not).\n */\nfunction myTabId(): string {\n tabId ??= randomId();\n return tabId;\n}\n\nlet seedSource: unknown;\nlet seedState: DevPreviewState = EMPTY_PREVIEW_STATE;\n\n/** The saved file as this page loaded it, normalized once per value so snapshots keep their identity. */\nfunction readSeed(): DevPreviewState {\n const raw = (globalThis as Record<string, unknown>)[DEV_PREVIEW_GLOBAL];\n if (raw !== seedSource) {\n seedSource = raw;\n seedState = normalizePreviewState(raw) ?? EMPTY_PREVIEW_STATE;\n }\n return seedState;\n}\n\n// The widget (bundled into the `/dev` entry) and the theme merge (bundled into\n// the engine index via `useTwilightInit`) import this module from two different\n// chunks, so each would otherwise get its OWN copy of the state — the widget\n// would enable a store the merge never reads. Back the state with a single\n// globalThis-keyed instance so every copy shares one source of truth. Dev-only,\n// so a global is acceptable (and lazy, so the module stays side-effect free and\n// tree-shakes out of production).\ninterface DevStoreSingleton {\n state: DevPreviewState;\n listeners: Set<() => void>;\n /** This page's own home blocks, when it is a storefront on its home page. Never saved. */\n ownBlocks: LiveBlocks | null;\n meta: DevEditorMeta;\n metaListeners: Set<() => void>;\n saveTimer: ReturnType<typeof setTimeout> | undefined;\n /** An edit that has not been sent yet. */\n dirty: boolean;\n /** A save request on its way; the next one waits for it, so saves land in order. */\n inFlight: boolean;\n /** The old localStorage copy is removed only once the file has the migrated values. */\n legacyPending: boolean;\n channel: BroadcastChannel | null;\n /** In the editor: the storefront frame's window. */\n getFrame: (() => Window | null) | null;\n /** Detach this copy's listeners and channel. A page keeps one copy for good; tests swap them. */\n dispose: () => void;\n}\n\nconst SINGLETON_KEY = '__twilightDevSettingsStore__';\n\nfunction singleton(): DevStoreSingleton {\n const g = globalThis as unknown as Record<string, DevStoreSingleton | undefined>;\n let s = g[SINGLETON_KEY];\n if (!s) {\n const seeded = (globalThis as Record<string, unknown>)[DEV_PREVIEW_GLOBAL] != null;\n s = {\n state: readSeed(),\n listeners: new Set(),\n ownBlocks: null,\n meta: { liveBlocks: null, saveStatus: 'idle', frameBase: undefined },\n metaListeners: new Set(),\n saveTimer: undefined,\n dirty: false,\n inFlight: false,\n legacyPending: false,\n channel: null,\n getFrame: null,\n dispose: () => {},\n };\n g[SINGLETON_KEY] = s;\n if (typeof window !== 'undefined') setUpBrowser(s, seeded);\n }\n return s;\n}\n\nfunction setUpBrowser(s: DevStoreSingleton, seeded: boolean): void {\n const listeners = new AbortController();\n const { signal } = listeners;\n if (!seeded) migrateLegacy(s);\n listenForOtherTabs();\n s.channel = openChannel();\n listenForFrameMessages(s, signal);\n window.addEventListener('pagehide', () => flushOnExit(s), { signal });\n s.dispose = () => {\n listeners.abort();\n s.channel?.close();\n clearTimeout(s.saveTimer);\n };\n if (isEditorFrame()) sendToEditor({ kind: 'frame-info', base: resolveStoreBase() });\n}\n\n/** Carry the old widget's settings over; its per-block patches don't map to a layout. */\nfunction migrateLegacy(s: DevStoreSingleton): void {\n try {\n const raw = window.localStorage.getItem(LEGACY_STORAGE_KEY);\n if (!raw) return;\n const legacy = normalizePreviewState(JSON.parse(raw));\n if (!legacy) return;\n s.state = { enabled: legacy.enabled, settings: legacy.settings, layout: null };\n s.legacyPending = true;\n scheduleSave(s);\n } catch {\n // Storage blocked or the old value is corrupt: nothing worth keeping.\n }\n}\n\n/** Vite's HMR client, typed locally: the engine's `ImportMeta` must not clash with `vite/client`. */\ninterface HotContext {\n on(event: string, cb: (payload: { state?: unknown; from?: unknown }) => void): void;\n}\n\n/**\n * Take a state another copy committed. Not while this copy has an edit of its\n * own waiting to be saved: that edit is newer, and saving it will tell the rest.\n */\nfunction receive(raw: unknown): void {\n const s = singleton();\n if (s.dirty || s.inFlight || s.saveTimer) return;\n const next = normalizePreviewState(raw);\n if (next && JSON.stringify(next) !== JSON.stringify(s.state)) emit(next);\n}\n\n/** Tabs in another browser hear about a save from the dev server. */\nfunction listenForOtherTabs(): void {\n const hot = (import.meta as ImportMeta & { hot?: HotContext }).hot;\n if (!hot) return;\n hot.on(DEV_PREVIEW_EVENT, (payload) => {\n if (payload?.from !== myTabId()) receive(payload?.state);\n });\n}\n\nfunction openChannel(): BroadcastChannel | null {\n if (typeof BroadcastChannel === 'undefined') return null;\n const channel = new BroadcastChannel(CHANNEL_NAME);\n channel.onmessage = ({ data }: MessageEvent<{ state?: unknown; from?: string }>) => {\n if (data && data.from !== myTabId()) receive(data.state);\n };\n return channel;\n}\n\nfunction sendToEditor(message: FrameMessage): void {\n if (isEditorFrame())\n window.parent.postMessage({ type: FRAME_MESSAGE, message }, window.location.origin);\n}\n\nfunction sendToFrame(message: FrameMessage): void {\n singleton().getFrame?.()?.postMessage({ type: FRAME_MESSAGE, message }, window.location.origin);\n}\n\nfunction reportToEditor(s: DevStoreSingleton): void {\n sendToEditor({ kind: 'frame-info', base: resolveStoreBase() });\n sendToEditor({ kind: 'live-blocks', blocks: s.ownBlocks });\n}\n\n/**\n * The editor ↔ frame conversation. A frame only takes requests from its own\n * parent; an editor only takes reports from the frame it shows.\n */\nfunction listenForFrameMessages(s: DevStoreSingleton, signal: AbortSignal): void {\n window.addEventListener(\n 'message',\n (event: MessageEvent) => {\n if (event.origin !== window.location.origin || event.data?.type !== FRAME_MESSAGE) return;\n const message = event.data.message as FrameMessage;\n if (window.parent !== window && event.source === window.parent) {\n if (message.kind === 'request-live-blocks') reportToEditor(s);\n else if (message.kind === 'focus-block') scrollToBlock(message.index);\n else if (message.kind === 'lookup') void answerLookup(message);\n return;\n }\n const frame = s.getFrame?.();\n if (!frame || event.source !== frame) return;\n if (message.kind === 'lookup-result') settleLookup(message);\n else if (message.kind === 'live-blocks') setMeta({ liveBlocks: message.blocks });\n else if (message.kind === 'frame-info') setMeta({ frameBase: message.base });\n },\n { signal }\n );\n}\n\n/** In the frame: look the request up in the store and send back what was found, or why not. */\nasync function answerLookup(message: Extract<FrameMessage, { kind: 'lookup' }>): Promise<void> {\n const { requestId, source, query } = message;\n try {\n const { lookupInStore } = await import('./store-lookup');\n sendToEditor({ kind: 'lookup-result', requestId, items: await lookupInStore(source, query) });\n } catch (error) {\n sendToEditor({\n kind: 'lookup-result',\n requestId,\n error: error instanceof Error ? error.message : 'lookup failed',\n });\n }\n}\n\nfunction settleLookup(message: Extract<FrameMessage, { kind: 'lookup-result' }>): void {\n const pending = pendingLookups.get(message.requestId);\n if (!pending) return;\n pendingLookups.delete(message.requestId);\n clearTimeout(pending.timer);\n if (message.items) pending.resolve(message.items);\n else pending.reject(new Error(message.error ?? 'lookup failed'));\n}\n\n/**\n * In the editor's frame: bring a home block into view and flash an outline on\n * it. Dev-only editor chrome, so it styles the element directly rather than\n * through the theme's React tree. A block added a moment ago may not be in the\n * DOM yet, so look for it for a little while.\n */\nfunction scrollToBlock(index: number): void {\n const started = Date.now();\n const find = () => {\n const el = document.querySelector<HTMLElement>(`[data-home-block=\"${index}\"]`);\n if (!el) {\n if (Date.now() - started < FOCUS_WAIT_MS) requestAnimationFrame(find);\n return;\n }\n const { outline, outlineOffset, scrollMarginTop } = el.style;\n // Clear a sticky header, which would otherwise cover the block's top.\n el.style.scrollMarginTop = '80px';\n el.scrollIntoView({ behavior: 'smooth', block: 'start' });\n el.style.outline = '2px solid #0d9488';\n el.style.outlineOffset = '-2px';\n setTimeout(() => {\n el.style.outline = outline;\n el.style.outlineOffset = outlineOffset;\n el.style.scrollMarginTop = scrollMarginTop;\n }, FOCUS_FLASH_MS);\n };\n find();\n}\n\nfunction emit(next: DevPreviewState): void {\n const s = singleton();\n s.state = next;\n s.listeners.forEach((l) => l());\n}\n\nfunction setMeta(patch: Partial<DevEditorMeta>): void {\n const s = singleton();\n s.meta = { ...s.meta, ...patch };\n s.metaListeners.forEach((l) => l());\n}\n\nfunction saveRequest(s: DevStoreSingleton, keepalive = false): Promise<Response> {\n return fetch(DEV_PREVIEW_ENDPOINT, {\n method: 'POST',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify({ state: s.state, from: myTabId() }),\n keepalive,\n });\n}\n\n/** Send the current state, one request at a time; edits made meanwhile go in the next one. */\nasync function flush(s: DevStoreSingleton): Promise<void> {\n if (s.inFlight || !s.dirty) return;\n s.inFlight = true;\n s.dirty = false;\n let failed = false;\n try {\n const res = await saveRequest(s);\n if (!res.ok) throw new Error(`HTTP ${res.status}`);\n if (s.legacyPending) {\n s.legacyPending = false;\n try {\n window.localStorage.removeItem(LEGACY_STORAGE_KEY);\n } catch {\n // Storage went away; the file has the values now either way.\n }\n }\n if (!s.dirty && !s.saveTimer) setMeta({ saveStatus: 'saved' });\n } catch (error) {\n // Still unsaved: another tab's state must not replace it, and leaving the\n // page still sends it. Edits made while this request was out are sent once\n // more; the failed one alone waits for the next edit, so nothing loops.\n failed = !s.dirty;\n s.dirty = true;\n setMeta({ saveStatus: 'error' });\n console.error('[twilight-react:preview] could not save twilight.preview.json', error);\n } finally {\n s.inFlight = false;\n if (!failed && s.dirty && !s.saveTimer) void flush(s);\n }\n}\n\nfunction scheduleSave(s: DevStoreSingleton): void {\n if (typeof window === 'undefined' || typeof fetch === 'undefined') return;\n s.dirty = true;\n clearTimeout(s.saveTimer);\n setMeta({ saveStatus: 'saving' });\n s.saveTimer = setTimeout(() => {\n s.saveTimer = undefined;\n void flush(s);\n }, SAVE_DELAY_MS);\n}\n\n/** Closing or reloading the editor must not drop the last edit: send it on the way out. */\nfunction flushOnExit(s: DevStoreSingleton): void {\n if (!s.dirty) return;\n clearTimeout(s.saveTimer);\n s.saveTimer = undefined;\n s.dirty = false;\n void saveRequest(s, true).catch(() => {});\n}\n\nfunction commit(next: DevPreviewState): void {\n const s = singleton();\n emit(next);\n try {\n s.channel?.postMessage({ state: next, from: myTabId() });\n } catch {\n // A value that can't be cloned: the other copies pick it up from the save instead.\n }\n scheduleSave(s);\n}\n\nfunction newBlockId(): string {\n return `b-${randomId()}`;\n}\n\n/** Home loader spelling of a twilight.json path. */\nexport function blockPath(path: string): string {\n return path.replace(/^home\\./, '');\n}\n\nfunction updateLayout(update: (layout: DevPreviewBlock[]) => DevPreviewBlock[]): void {\n const { state } = singleton();\n commit({ ...state, layout: update(state.layout ?? []) });\n}\n\n/** A new block for a twilight.json component, filled with its defaults. */\nfunction blockFor(schema: DevSchema, path: string): DevPreviewBlock {\n const component = schema.components.find((c) => c.path === path);\n const defaults = schema.blockDefaults?.[path] ?? schema.componentDefaults[path] ?? {};\n return {\n id: newBlockId(),\n path: blockPath(path),\n fields: { ...(component?.key ? { key: component.key } : {}), ...defaults },\n };\n}\n\nexport const devSettingsStore = {\n get: (): DevPreviewState => singleton().state,\n /** What the server rendered: the saved file as of this page load. */\n getServer: (): DevPreviewState => readSeed(),\n subscribe(listener: () => void): () => void {\n const s = singleton();\n s.listeners.add(listener);\n return () => {\n s.listeners.delete(listener);\n };\n },\n /** Turn overrides on, seeding any unset setting with its twilight.json default. */\n enable(schema: DevSchema): void {\n const { state } = singleton();\n commit({\n ...state,\n enabled: true,\n settings: { ...schema.settingsDefaults, ...state.settings },\n });\n },\n disable(): void {\n commit({ ...singleton().state, enabled: false });\n },\n setSetting(id: string, value: unknown): void {\n const { state } = singleton();\n commit({ ...state, settings: { ...state.settings, [id]: value } });\n },\n /** Restore every setting to its twilight.json default (keeps enabled and the layout). */\n resetSettings(schema: DevSchema): void {\n commit({ ...singleton().state, settings: { ...schema.settingsDefaults } });\n },\n\n // ── Editor ↔ frame ───────────────────────────────────────────────────────\n\n /** The editor tells the store which window is its storefront frame. */\n connectFrame(getFrame: () => Window | null): () => void {\n const s = singleton();\n s.getFrame = getFrame;\n return () => {\n if (s.getFrame === getFrame) s.getFrame = null;\n };\n },\n /** A storefront's home page reports its blocks (`null` when it leaves); in the editor's frame they go to the editor. Not saved. */\n setLiveBlocks(blocks: LiveBlocks | null): void {\n const s = singleton();\n s.ownBlocks = blocks;\n sendToEditor({ kind: 'live-blocks', blocks });\n },\n /** Ask the frame for its home page's blocks and its store base. */\n requestLiveBlocks(): void {\n sendToFrame({ kind: 'request-live-blocks' });\n },\n /**\n * Search the dev store through the editor's frame. Rejects when there is no\n * frame, it doesn't answer in time, or the store refuses; pickers then fall\n * back to samples.\n */\n lookup(source: DevLookupSource, query: string): Promise<DevLookupItem[]> {\n const frame = singleton().getFrame?.();\n if (!frame) return Promise.reject(new Error('no storefront frame'));\n const requestId = randomId();\n return new Promise((resolve, reject) => {\n const timer = setTimeout(() => {\n pendingLookups.delete(requestId);\n reject(new Error('the storefront did not answer'));\n }, DEV_LOOKUP_TIMEOUT_MS);\n pendingLookups.set(requestId, { resolve, reject, timer });\n sendToFrame({ kind: 'lookup', requestId, source, query });\n });\n },\n /** Scroll the editor's frame to the home block at `index`. */\n focusBlock(index: number): void {\n sendToFrame({ kind: 'focus-block', index });\n },\n getMeta: (): DevEditorMeta => singleton().meta,\n subscribeMeta(listener: () => void): () => void {\n const s = singleton();\n s.metaListeners.add(listener);\n return () => {\n s.metaListeners.delete(listener);\n };\n },\n\n // ── Home layout ──────────────────────────────────────────────────────────\n\n /**\n * Take over the home layout. Starts from the blocks the home page showed (the\n * frame's in the editor; an empty page stays empty), otherwise from every\n * twilight.json component.\n */\n customizeLayout(schema: DevSchema): void {\n const s = singleton();\n const live = s.meta.liveBlocks ?? s.ownBlocks;\n const layout: DevPreviewBlock[] =\n live !== null\n ? live\n .filter((block): block is { path: string } => typeof block.path === 'string')\n .filter((block) => block.path !== '')\n .map(({ path, ...fields }) => ({ id: newBlockId(), path: blockPath(path), fields }))\n : schema.components.map((component) => blockFor(schema, component.path));\n commit({ ...s.state, enabled: true, layout });\n },\n startEmptyLayout(): void {\n commit({ ...singleton().state, enabled: true, layout: [] });\n },\n /** Back to the store's own blocks. */\n clearLayout(): void {\n commit({ ...singleton().state, layout: null });\n },\n /** Insert a twilight.json component at `at` (default: the end); returns the new block's id. */\n addBlock(schema: DevSchema, path: string, at?: number): string {\n const block = blockFor(schema, path);\n updateLayout((layout) => {\n const next = [...layout];\n next.splice(at ?? next.length, 0, block);\n return next;\n });\n return block.id;\n },\n removeBlock(id: string): void {\n updateLayout((layout) => layout.filter((block) => block.id !== id));\n },\n duplicateBlock(id: string): void {\n updateLayout((layout) => {\n const index = layout.findIndex((block) => block.id === id);\n if (index === -1) return layout;\n const copy = { ...layout[index], id: newBlockId(), fields: { ...layout[index].fields } };\n return [...layout.slice(0, index + 1), copy, ...layout.slice(index + 1)];\n });\n },\n /** Move a block to index `to` (its position after the move). */\n moveBlock(id: string, to: number): void {\n updateLayout((layout) => {\n const from = layout.findIndex((block) => block.id === id);\n if (from === -1) return layout;\n const target = Math.max(0, Math.min(to, layout.length - 1));\n if (target === from) return layout;\n const next = [...layout];\n const [block] = next.splice(from, 1);\n next.splice(target, 0, block);\n return next;\n });\n },\n setBlockField(id: string, fieldId: string, value: unknown): void {\n updateLayout((layout) =>\n layout.map((block) =>\n block.id === id ? { ...block, fields: { ...block.fields, [fieldId]: value } } : block\n )\n );\n },\n};\n\nconst SERVER_META: DevEditorMeta = { liveBlocks: null, saveStatus: 'idle', frameBase: undefined };\n\n/** The frame's blocks and store base, and the save status, for the editor. */\nexport function useDevEditorMeta(): DevEditorMeta {\n return useSyncExternalStore(\n devSettingsStore.subscribeMeta,\n devSettingsStore.getMeta,\n () => SERVER_META\n );\n}\n\n/** Raw store subscription. */\nexport function useDevSettingsState(): DevPreviewState {\n return useSyncExternalStore(\n devSettingsStore.subscribe,\n devSettingsStore.get,\n devSettingsStore.getServer\n );\n}\n\n/**\n * Overrides for SSR-rendered consumers (the theme). The server and the first\n * browser render both read the saved file, so they agree and nothing flashes.\n *\n * Which hook this is gets decided once, when the module loads: in production\n * `import.meta.env.DEV` is a static `false`, so only the empty one survives\n * bundling and the store subscription (and the whole store module, which has\n * no other prod consumer) is dead-code-eliminated. No hook is ever called\n * conditionally.\n */\nexport const useDevSettingsOverrides: () => DevPreviewState = import.meta.env.DEV\n ? useDevSettingsState\n : () => EMPTY_PREVIEW_STATE;\n\n/** A rendered home block; `__dev_id` keys a dev-layout block across reorders. */\nexport type DevHomeBlock<T> = T & { __dev_id?: string };\n\n/**\n * Whether a list in a block's fields gained, lost or reordered items. Blocks\n * often hand their items to a web component that takes them once when it\n * starts (a slider moves its slides into its own track), so such a change\n * never reaches the page until the block mounts again. Editing an item's\n * values is not one: the nodes stay put and update in place.\n */\nexport function listsReshaped(\n before: Record<string, unknown>,\n after: Record<string, unknown>\n): boolean {\n for (const key of new Set([...Object.keys(before), ...Object.keys(after)])) {\n const a = before[key];\n const b = after[key];\n if (!Array.isArray(a) && !Array.isArray(b)) continue;\n if (!Array.isArray(a) || !Array.isArray(b) || a.length !== b.length) return true;\n const aItems = a.map((item) => JSON.stringify(item));\n const bItems = b.map((item) => JSON.stringify(item));\n const moved = aItems.some((item, i) => item !== bItems[i]);\n if (moved && [...aItems].sort().join('\\n') === [...bItems].sort().join('\\n')) return true;\n }\n return false;\n}\n\n/**\n * The home page's blocks: the dev layout when one is saved and enabled, else\n * the store's own blocks untouched. Also reports the store's blocks to the\n * editor so \"Customize\" can start from what the page showed, and withdraws\n * them when the page goes.\n *\n * Same production story as {@link useDevSettingsOverrides}: chosen once at\n * module load, so production keeps only the passthrough.\n */\nfunction useDevLayoutBlocks<T extends { path?: string }>(components: T[]): DevHomeBlock<T>[] {\n const overrides = useDevSettingsState();\n // Per block: the fields last rendered, and how often its lists were reshaped.\n const seen = useRef(new Map<string, { fields: Record<string, unknown>; mounts: number }>());\n useEffect(() => {\n devSettingsStore.setLiveBlocks(components);\n return () => devSettingsStore.setLiveBlocks(null);\n }, [components]);\n return useMemo(() => {\n if (!overrides.enabled || !overrides.layout) return components;\n return overrides.layout.map((block) => {\n const last = seen.current.get(block.id);\n const mounts =\n (last?.mounts ?? 0) + (last && listsReshaped(last.fields, block.fields) ? 1 : 0);\n seen.current.set(block.id, { fields: block.fields, mounts });\n // A new key mounts the block again, so a reshaped list reaches the page.\n const devId = mounts ? `${block.id}~${mounts}` : block.id;\n return { ...block.fields, path: block.path, __dev_id: devId } as DevHomeBlock<T>;\n });\n }, [components, overrides]);\n}\n\nexport const useDevHomeBlocks: <T extends { path?: string }>(components: T[]) => DevHomeBlock<T>[] =\n import.meta.env.DEV ? useDevLayoutBlocks : (components) => components;\n"]}
@@ -1,5 +1,5 @@
1
- import { orThrow } from './chunk-E5PEYI5I.js';
2
- import { getActiveScope, api } from './chunk-BFA2U7P3.js';
1
+ import { orThrow } from './chunk-KXD4WUYA.js';
2
+ import { getActiveScope, api } from './chunk-M46EKE7R.js';
3
3
  import { queryOptions } from '@tanstack/react-query';
4
4
 
5
5
  var category = {
@@ -26,5 +26,5 @@ var category = {
26
26
  };
27
27
 
28
28
  export { category };
29
- //# sourceMappingURL=chunk-56OZRZIZ.js.map
30
- //# sourceMappingURL=chunk-56OZRZIZ.js.map
29
+ //# sourceMappingURL=chunk-75TXHISE.js.map
30
+ //# sourceMappingURL=chunk-75TXHISE.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/api/category.ts"],"names":[],"mappings":";;;;AAKO,IAAM,QAAA,GAAW;AAAA,EACtB,IAAA,EAAM,OAAO,EAAA,KAAkC;AAC7C,IAAA,MAAM,EAAE,IAAA,EAAK,GAAI,MAAM,GAAA,CAAI,IAAI,CAAA,WAAA,EAAc,EAAE,CAAA,CAAE,CAAA,CAAE,IAAA,EAAyB;AAC5E,IAAA,OAAO,IAAA;AAAA,EACT,CAAA;AAAA,EAEA,aAAa,CAAC,EAAA,KAAkC,QAAQ,QAAA,CAAS,IAAA,CAAK,EAAE,CAAC,CAAA;AAAA,EAEzE,MAAM,YAAiC;AACrC,IAAA,MAAM,EAAE,MAAK,GAAI,MAAM,IAAI,GAAA,CAAI,YAAY,EAAE,IAAA,EAA2B;AACxE,IAAA,OAAO,QAAQ,EAAC;AAAA,EAClB,CAAA;AAAA,EAEA,OAAA,EAAS;AAAA,IACP,MAAA,EAAQ,CAAC,EAAA,KACP,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,CAAC,YAAA,EAAc,QAAA,EAAU,EAAE,CAAA;AAAA,MACrC,OAAA,EAAS,MAAM,QAAA,CAAS,IAAA,CAAK,EAAE;AAAA,KAChC,CAAA;AAAA,IAEH,IAAA,EAAM,MACJ,YAAA,CAAa;AAAA;AAAA,MAEX,QAAA,EAAU,CAAC,YAAA,EAAc,MAAA,EAAQ,EAAE,KAAA,EAAO,cAAA,IAAkB,CAAA;AAAA,MAC5D,OAAA,EAAS,MAAM,QAAA,CAAS,IAAA;AAAK,KAC9B;AAAA;AAEP","file":"chunk-56OZRZIZ.js","sourcesContent":["import { queryOptions } from '@tanstack/react-query';\nimport { api, getActiveScope } from './client';\nimport type { Category } from '../types';\nimport { orThrow } from '../providers/NavigationProvider';\n\nexport const category = {\n find: async (id: string): Promise<Category> => {\n const { data } = await api.get(`categories/${id}`).json<{ data: Category }>();\n return data;\n },\n\n findOrThrow: (id: string): Promise<Category> => orThrow(category.find(id)),\n\n list: async (): Promise<Category[]> => {\n const { data } = await api.get('categories').json<{ data: Category[] }>();\n return data ?? [];\n },\n\n queries: {\n detail: (id: string) =>\n queryOptions({\n queryKey: ['categories', 'detail', id],\n queryFn: () => category.find(id),\n }),\n\n list: () =>\n queryOptions({\n // Scope (branch) varies the API response — key must include it.\n queryKey: ['categories', 'list', { scope: getActiveScope() }],\n queryFn: () => category.list(),\n }),\n },\n};\n"]}
1
+ {"version":3,"sources":["../src/api/category.ts"],"names":[],"mappings":";;;;AAKO,IAAM,QAAA,GAAW;AAAA,EACtB,IAAA,EAAM,OAAO,EAAA,KAAkC;AAC7C,IAAA,MAAM,EAAE,IAAA,EAAK,GAAI,MAAM,GAAA,CAAI,IAAI,CAAA,WAAA,EAAc,EAAE,CAAA,CAAE,CAAA,CAAE,IAAA,EAAyB;AAC5E,IAAA,OAAO,IAAA;AAAA,EACT,CAAA;AAAA,EAEA,aAAa,CAAC,EAAA,KAAkC,QAAQ,QAAA,CAAS,IAAA,CAAK,EAAE,CAAC,CAAA;AAAA,EAEzE,MAAM,YAAiC;AACrC,IAAA,MAAM,EAAE,MAAK,GAAI,MAAM,IAAI,GAAA,CAAI,YAAY,EAAE,IAAA,EAA2B;AACxE,IAAA,OAAO,QAAQ,EAAC;AAAA,EAClB,CAAA;AAAA,EAEA,OAAA,EAAS;AAAA,IACP,MAAA,EAAQ,CAAC,EAAA,KACP,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,CAAC,YAAA,EAAc,QAAA,EAAU,EAAE,CAAA;AAAA,MACrC,OAAA,EAAS,MAAM,QAAA,CAAS,IAAA,CAAK,EAAE;AAAA,KAChC,CAAA;AAAA,IAEH,IAAA,EAAM,MACJ,YAAA,CAAa;AAAA;AAAA,MAEX,QAAA,EAAU,CAAC,YAAA,EAAc,MAAA,EAAQ,EAAE,KAAA,EAAO,cAAA,IAAkB,CAAA;AAAA,MAC5D,OAAA,EAAS,MAAM,QAAA,CAAS,IAAA;AAAK,KAC9B;AAAA;AAEP","file":"chunk-75TXHISE.js","sourcesContent":["import { queryOptions } from '@tanstack/react-query';\nimport { api, getActiveScope } from './client';\nimport type { Category } from '../types';\nimport { orThrow } from '../providers/NavigationProvider';\n\nexport const category = {\n find: async (id: string): Promise<Category> => {\n const { data } = await api.get(`categories/${id}`).json<{ data: Category }>();\n return data;\n },\n\n findOrThrow: (id: string): Promise<Category> => orThrow(category.find(id)),\n\n list: async (): Promise<Category[]> => {\n const { data } = await api.get('categories').json<{ data: Category[] }>();\n return data ?? [];\n },\n\n queries: {\n detail: (id: string) =>\n queryOptions({\n queryKey: ['categories', 'detail', id],\n queryFn: () => category.find(id),\n }),\n\n list: () =>\n queryOptions({\n // Scope (branch) varies the API response — key must include it.\n queryKey: ['categories', 'list', { scope: getActiveScope() }],\n queryFn: () => category.list(),\n }),\n },\n};\n"]}
@@ -1,4 +1,4 @@
1
- import { getSallaSDK, whenSallaReady } from './chunk-X2JCU7GY.js';
1
+ import { getSallaSDK, whenSallaReady } from './chunk-3GDJMMMS.js';
2
2
  import { useState, useEffect } from 'react';
3
3
 
4
4
  function isNativeApp() {
@@ -54,5 +54,5 @@ function useNativeStatusBarColor() {
54
54
  }
55
55
 
56
56
  export { hapticImpact, isNativeApp, nativeAppVersion, openNativeBrowser, openNativeSheet, useIsNativeApp, useNativeAppVersion, useNativeStatusBarColor };
57
- //# sourceMappingURL=chunk-YYMKDBZV.js.map
58
- //# sourceMappingURL=chunk-YYMKDBZV.js.map
57
+ //# sourceMappingURL=chunk-7AIDISU2.js.map
58
+ //# sourceMappingURL=chunk-7AIDISU2.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/native-app/index.ts"],"names":[],"mappings":";;;AAQO,SAAS,WAAA,GAAuB;AACrC,EAAA,OAAO,OAAA,CA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AC/E,CAAA,EAAG,CAAC,KAAA,EAAO,OAAO,CAAC,CAAA;AAEnB,EAAA,OAAO,UAAA;AACT","file":"chunk-YYMKDBZV.js","sourcesContent":["import { useEffect, useState, type RefCallback } from 'react';\nimport { getSallaSDK, whenSallaReady } from '../utils/sdk-helpers';\n\n/**\n * True inside the Salla native app's webview, read at call time: the SDK's\n * `salla.mobile.isEnabled()`. False on the server and until the SDK has loaded, so call it\n * from an event handler or an effect, and use {@link useIsNativeApp} to decide what to render.\n */\nexport function isNativeApp(): boolean {\n return Boolean(getSallaSDK()?.mobile?.isEnabled?.());\n}\n\n/**\n * {@link isNativeApp} as state, for a render decision. False on the server and on the first\n * client render, then true once the SDK is ready inside the app: an app that identifies\n * itself through its config has not said so before `init`.\n */\nexport function useIsNativeApp(): boolean {\n const [inApp, setInApp] = useState(false);\n\n useEffect(() => whenSallaReady(() => setInApp(isNativeApp())), []);\n\n return inApp;\n}\n\n/**\n * The native app's release (`5.4.19`), the `s-app-version` it loaded the page with, or null\n * outside the app. The SDK keeps it in its analytics context, where it also learns that this\n * is the app. Read at call time like {@link isNativeApp}; render with {@link useNativeAppVersion}.\n */\nexport function nativeAppVersion(): string | null {\n if (!isNativeApp()) return null;\n const analytics = (getSallaSDK() as { analytics?: SdkAnalytics } | undefined)?.analytics;\n return analytics?.jitsuAnalytics?.getContextProperty?.('app')?.app_release_tag || null;\n}\n\ntype SdkAnalytics = {\n jitsuAnalytics?: {\n getContextProperty?: (key: 'app') => { app_release_tag?: string } | undefined;\n };\n};\n\n/** {@link nativeAppVersion} as state: null on the server and until the SDK is ready in the app. */\nexport function useNativeAppVersion(): string | null {\n const [version, setVersion] = useState<string | null>(null);\n\n useEffect(() => whenSallaReady(() => setVersion(nativeAppVersion())), []);\n\n return version;\n}\n\n/** The native app's own pickers that replace the store's web modals. */\nexport type NativeSheet = 'language' | 'currency';\n\n/**\n * Inside the Salla app, opens the app's own language or currency sheet\n * (`mobile::language.open` / `mobile::currency.open`) and returns `true`; the app\n * applies the choice and reloads. Outside the app it does nothing and returns\n * `false`, so a caller opens the web modal instead:\n *\n * ```ts\n * if (!openNativeSheet('currency')) salla.event.dispatch('localization::open');\n * ```\n */\nexport function openNativeSheet(sheet: NativeSheet): boolean {\n if (!isNativeApp()) return false;\n const sdk = getSallaSDK();\n const open = sheet === 'language' ? sdk?.mobile?.openLanguages : sdk?.mobile?.openCurrencies;\n if (typeof open === 'function') open.call(sdk?.mobile);\n // An SDK without the methods still forwards an emitted `mobile::*` event to the app.\n else sdk?.event.dispatch(`mobile::${sheet}.open`, {});\n return true;\n}\n\n/**\n * Inside the Salla app, hands `url` to the app to open in the device's browser\n * (`mobile::browser.open`) and returns `true`; a page off the store would\n * otherwise load inside the app with no way back. Outside the app it does nothing\n * and returns `false`. The engine's link interceptor calls it for every tap on a\n * link that leaves the store.\n */\nexport function openNativeBrowser(url: string): boolean {\n if (!isNativeApp()) return false;\n const sdk = getSallaSDK();\n if (typeof sdk?.mobile?.openBrowser === 'function') sdk.mobile.openBrowser(url);\n else sdk?.event.dispatch('mobile::browser.open', { url });\n return true;\n}\n\nexport type HapticImpact = 'light' | 'medium' | 'heavy';\n\n/** Asks the native app for a tap vibration. The SDK ignores it outside the app. */\nexport function hapticImpact(impact: HapticImpact): void {\n getSallaSDK()?.mobile?.action?.('haptic.impact', { impact_type: impact });\n}\n\n/**\n * `rgb(232, 245, 255)`, what `getComputedStyle` returns, as `#e8f5ff`. A partial alpha is\n * dropped. A fully transparent colour is no colour at all: an element with no background\n * of its own computes to `rgba(0, 0, 0, 0)`, which would otherwise read as black.\n */\nfunction rgbToHex(rgb: string): string | null {\n const match = rgb.match(/^rgba?\\((\\d+),\\s*(\\d+),\\s*(\\d+)(?:,\\s*([\\d.]+))?\\)/);\n if (!match || Number(match[4]) === 0) return null;\n return `#${match\n .slice(1, 4)\n .map((channel) => Number(channel).toString(16).padStart(2, '0'))\n .join('')}`;\n}\n\n/**\n * Tells the native app to paint its status bar with the rendered background of the element\n * the returned ref is attached to. The colour is read from the DOM, because a theme's tint\n * is often a relative CSS colour (`hsl(from …)`) with no hex to pass. Does nothing outside\n * the app, and for an element with no background of its own.\n *\n * The ref is a callback, kept in state, so an element that mounts after the app has been\n * recognised still reports its colour.\n */\nexport function useNativeStatusBarColor<T extends HTMLElement>(): RefCallback<T> {\n const [element, setElement] = useState<T | null>(null);\n const inApp = useIsNativeApp();\n\n useEffect(() => {\n if (!inApp || !element) return;\n const color = rgbToHex(getComputedStyle(element).backgroundColor);\n if (color) getSallaSDK()?.event.dispatch('mobile::statusbar.color', { color });\n }, [inApp, element]);\n\n return setElement;\n}\n"]}
1
+ {"version":3,"sources":["../src/native-app/index.ts"],"names":[],"mappings":";;;AAQO,SAAS,WAAA,GAAuB;AACrC,EAAA,OAAO,OAAA,CAAQ,WAAA,EAAY,EAAG,MAAA,EAAQ,aAAa,CAAA;AACrD;AAOO,SAAS,cAAA,GAA0B;AACxC,EAAA,MAAM,CAAC,KAAA,EAAO,QAAQ,CAAA,GAAI,SAAS,KAAK,CAAA;AAExC,EAAA,SAAA,CAAU,MAAM,eAAe,MAAM,QAAA,CAAS,aAAa,CAAC,CAAA,EAAG,EAAE,CAAA;AAEjE,EAAA,OAAO,KAAA;AACT;AAOO,SAAS,gBAAA,GAAkC;AAChD,EAAA,IAAI,CAAC,WAAA,EAAY,EAAG,OAAO,IAAA;AAC3B,EAAA,MAAM,SAAA,GAAa,aAAY,EAAgD,SAAA;AAC/E,EAAA,OAAO,SAAA,EAAW,cAAA,EAAgB,kBAAA,GAAqB,KAAK,GAAG,eAAA,IAAmB,IAAA;AACpF;AASO,SAAS,mBAAA,GAAqC;AACnD,EAAA,MAAM,CAAC,OAAA,EAAS,UAAU,CAAA,GAAI,SAAwB,IAAI,CAAA;AAE1D,EAAA,SAAA,CAAU,MAAM,eAAe,MAAM,UAAA,CAAW,kBAAkB,CAAC,CAAA,EAAG,EAAE,CAAA;AAExE,EAAA,OAAO,OAAA;AACT;AAeO,SAAS,gBAAgB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,QAAA,CAAS,CAAA,EAAG,GAAG,CAAC,CAAA,CAC9D,IAAA,CAAK,EAAE,CAAC,CAAA,CAAA;AACb;AAWO,SAAS,uBAAA,GAAiE;AAC/E,EAAA,MAAM,CAAC,OAAA,EAAS,UAAU,CAAA,GAAI,SAAmB,IAAI,CAAA;AACrD,EAAA,MAAM,QAAQ,cAAA,EAAe;AAE7B,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,IAAI,CAAC,KAAA,IAAS,CAAC,OAAA,EAAS;AACxB,IAAA,MAAM,KAAA,GAAQ,QAAA,CAAS,gBAAA,CAAiB,OAAO,EAAE,eAAe,CAAA;AAChE,IAAA,IAAI,KAAA,eAAmB,EAAG,KAAA,CAAM,SAAS,yBAAA,EAA2B,EAAE,OAAO,CAAA;AAAA,EAC/E,CAAA,EAAG,CAAC,KAAA,EAAO,OAAO,CAAC,CAAA;AAEnB,EAAA,OAAO,UAAA;AACT","file":"chunk-7AIDISU2.js","sourcesContent":["import { useEffect, useState, type RefCallback } from 'react';\nimport { getSallaSDK, whenSallaReady } from '../utils/sdk-helpers';\n\n/**\n * True inside the Salla native app's webview, read at call time: the SDK's\n * `salla.mobile.isEnabled()`. False on the server and until the SDK has loaded, so call it\n * from an event handler or an effect, and use {@link useIsNativeApp} to decide what to render.\n */\nexport function isNativeApp(): boolean {\n return Boolean(getSallaSDK()?.mobile?.isEnabled?.());\n}\n\n/**\n * {@link isNativeApp} as state, for a render decision. False on the server and on the first\n * client render, then true once the SDK is ready inside the app: an app that identifies\n * itself through its config has not said so before `init`.\n */\nexport function useIsNativeApp(): boolean {\n const [inApp, setInApp] = useState(false);\n\n useEffect(() => whenSallaReady(() => setInApp(isNativeApp())), []);\n\n return inApp;\n}\n\n/**\n * The native app's release (`5.4.19`), the `s-app-version` it loaded the page with, or null\n * outside the app. The SDK keeps it in its analytics context, where it also learns that this\n * is the app. Read at call time like {@link isNativeApp}; render with {@link useNativeAppVersion}.\n */\nexport function nativeAppVersion(): string | null {\n if (!isNativeApp()) return null;\n const analytics = (getSallaSDK() as { analytics?: SdkAnalytics } | undefined)?.analytics;\n return analytics?.jitsuAnalytics?.getContextProperty?.('app')?.app_release_tag || null;\n}\n\ntype SdkAnalytics = {\n jitsuAnalytics?: {\n getContextProperty?: (key: 'app') => { app_release_tag?: string } | undefined;\n };\n};\n\n/** {@link nativeAppVersion} as state: null on the server and until the SDK is ready in the app. */\nexport function useNativeAppVersion(): string | null {\n const [version, setVersion] = useState<string | null>(null);\n\n useEffect(() => whenSallaReady(() => setVersion(nativeAppVersion())), []);\n\n return version;\n}\n\n/** The native app's own pickers that replace the store's web modals. */\nexport type NativeSheet = 'language' | 'currency';\n\n/**\n * Inside the Salla app, opens the app's own language or currency sheet\n * (`mobile::language.open` / `mobile::currency.open`) and returns `true`; the app\n * applies the choice and reloads. Outside the app it does nothing and returns\n * `false`, so a caller opens the web modal instead:\n *\n * ```ts\n * if (!openNativeSheet('currency')) salla.event.dispatch('localization::open');\n * ```\n */\nexport function openNativeSheet(sheet: NativeSheet): boolean {\n if (!isNativeApp()) return false;\n const sdk = getSallaSDK();\n const open = sheet === 'language' ? sdk?.mobile?.openLanguages : sdk?.mobile?.openCurrencies;\n if (typeof open === 'function') open.call(sdk?.mobile);\n // An SDK without the methods still forwards an emitted `mobile::*` event to the app.\n else sdk?.event.dispatch(`mobile::${sheet}.open`, {});\n return true;\n}\n\n/**\n * Inside the Salla app, hands `url` to the app to open in the device's browser\n * (`mobile::browser.open`) and returns `true`; a page off the store would\n * otherwise load inside the app with no way back. Outside the app it does nothing\n * and returns `false`. The engine's link interceptor calls it for every tap on a\n * link that leaves the store.\n */\nexport function openNativeBrowser(url: string): boolean {\n if (!isNativeApp()) return false;\n const sdk = getSallaSDK();\n if (typeof sdk?.mobile?.openBrowser === 'function') sdk.mobile.openBrowser(url);\n else sdk?.event.dispatch('mobile::browser.open', { url });\n return true;\n}\n\nexport type HapticImpact = 'light' | 'medium' | 'heavy';\n\n/** Asks the native app for a tap vibration. The SDK ignores it outside the app. */\nexport function hapticImpact(impact: HapticImpact): void {\n getSallaSDK()?.mobile?.action?.('haptic.impact', { impact_type: impact });\n}\n\n/**\n * `rgb(232, 245, 255)`, what `getComputedStyle` returns, as `#e8f5ff`. A partial alpha is\n * dropped. A fully transparent colour is no colour at all: an element with no background\n * of its own computes to `rgba(0, 0, 0, 0)`, which would otherwise read as black.\n */\nfunction rgbToHex(rgb: string): string | null {\n const match = rgb.match(/^rgba?\\((\\d+),\\s*(\\d+),\\s*(\\d+)(?:,\\s*([\\d.]+))?\\)/);\n if (!match || Number(match[4]) === 0) return null;\n return `#${match\n .slice(1, 4)\n .map((channel) => Number(channel).toString(16).padStart(2, '0'))\n .join('')}`;\n}\n\n/**\n * Tells the native app to paint its status bar with the rendered background of the element\n * the returned ref is attached to. The colour is read from the DOM, because a theme's tint\n * is often a relative CSS colour (`hsl(from …)`) with no hex to pass. Does nothing outside\n * the app, and for an element with no background of its own.\n *\n * The ref is a callback, kept in state, so an element that mounts after the app has been\n * recognised still reports its colour.\n */\nexport function useNativeStatusBarColor<T extends HTMLElement>(): RefCallback<T> {\n const [element, setElement] = useState<T | null>(null);\n const inApp = useIsNativeApp();\n\n useEffect(() => {\n if (!inApp || !element) return;\n const color = rgbToHex(getComputedStyle(element).backgroundColor);\n if (color) getSallaSDK()?.event.dispatch('mobile::statusbar.color', { color });\n }, [inApp, element]);\n\n return setElement;\n}\n"]}