@salla.sa/twilight-theme-engine 1.0.207 → 1.0.208

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 (257) hide show
  1. package/dist/{AddToCartForm-RSZHHCOS.js → AddToCartForm-FLSMTYQ4.js} +3 -3
  2. package/dist/{AddToCartForm-RSZHHCOS.js.map → AddToCartForm-FLSMTYQ4.js.map} +1 -1
  3. package/dist/{BlogAuthorPage-ALMTZ3TF.js → BlogAuthorPage-PCA6Z5FA.js} +19 -19
  4. package/dist/{BlogAuthorPage-ALMTZ3TF.js.map → BlogAuthorPage-PCA6Z5FA.js.map} +1 -1
  5. package/dist/{BlogCategoryPage-VIXBXUQV.js → BlogCategoryPage-V5OOLDO7.js} +19 -19
  6. package/dist/{BlogCategoryPage-VIXBXUQV.js.map → BlogCategoryPage-V5OOLDO7.js.map} +1 -1
  7. package/dist/{BlogPage-3TWE7ZHP.js → BlogPage-3BWT5L66.js} +17 -17
  8. package/dist/{BlogPage-3TWE7ZHP.js.map → BlogPage-3BWT5L66.js.map} +1 -1
  9. package/dist/{BlogSinglePage-SC3ESA7V.js → BlogSinglePage-5I5KYA3A.js} +17 -17
  10. package/dist/{BlogSinglePage-SC3ESA7V.js.map → BlogSinglePage-5I5KYA3A.js.map} +1 -1
  11. package/dist/{BlogTagPage-DS7RFXLX.js → BlogTagPage-ZOXJ2ZL7.js} +19 -19
  12. package/dist/{BlogTagPage-DS7RFXLX.js.map → BlogTagPage-ZOXJ2ZL7.js.map} +1 -1
  13. package/dist/{BrandsPage-UZ7LSXC7.js → BrandsPage-OJL72GRV.js} +18 -18
  14. package/dist/{BrandsPage-UZ7LSXC7.js.map → BrandsPage-OJL72GRV.js.map} +1 -1
  15. package/dist/{Breadcrumb-NMSPOKZC.js → Breadcrumb-GY5KGEKR.js} +17 -17
  16. package/dist/{Breadcrumb-NMSPOKZC.js.map → Breadcrumb-GY5KGEKR.js.map} +1 -1
  17. package/dist/{CanvasOverlay-F64M22YD.js → CanvasOverlay-AT6M5A2U.js} +3 -3
  18. package/dist/{CanvasOverlay-F64M22YD.js.map → CanvasOverlay-AT6M5A2U.js.map} +1 -1
  19. package/dist/{CartItem-SZZQW53E.js → CartItem-S4BD6EHA.js} +17 -17
  20. package/dist/{CartItem-SZZQW53E.js.map → CartItem-S4BD6EHA.js.map} +1 -1
  21. package/dist/{CartSummary-A3GRFQVN.js → CartSummary-JREM7MQD.js} +17 -17
  22. package/dist/{CartSummary-A3GRFQVN.js.map → CartSummary-JREM7MQD.js.map} +1 -1
  23. package/dist/{Copyright-2AQ5UTMJ.js → Copyright-XX3HG3ZI.js} +3 -3
  24. package/dist/{Copyright-2AQ5UTMJ.js.map → Copyright-XX3HG3ZI.js.map} +1 -1
  25. package/dist/{CustomerLayout-YX5RLRJ6.js → CustomerLayout-NWSFIJO6.js} +17 -17
  26. package/dist/{CustomerLayout-YX5RLRJ6.js.map → CustomerLayout-NWSFIJO6.js.map} +1 -1
  27. package/dist/{Footer-RGUHNCXE.js → Footer-AANE2FAE.js} +3 -3
  28. package/dist/{Footer-RGUHNCXE.js.map → Footer-AANE2FAE.js.map} +1 -1
  29. package/dist/GoogleTag-L5HYN3QT.js +15 -0
  30. package/dist/{GoogleTag-PM23J7UJ.js.map → GoogleTag-L5HYN3QT.js.map} +1 -1
  31. package/dist/{Header-EUHFF564.js → Header-XTU4UI7Z.js} +8 -8
  32. package/dist/{Header-EUHFF564.js.map → Header-XTU4UI7Z.js.map} +1 -1
  33. package/dist/{LatestProducts-5GW3LWNF.js → LatestProducts-7JE23JAG.js} +19 -19
  34. package/dist/{LatestProducts-5GW3LWNF.js.map → LatestProducts-7JE23JAG.js.map} +1 -1
  35. package/dist/{LoyaltyPage-FSBFMMDK.js → LoyaltyPage-ZN57ZJSO.js} +17 -17
  36. package/dist/{LoyaltyPage-FSBFMMDK.js.map → LoyaltyPage-ZN57ZJSO.js.map} +1 -1
  37. package/dist/{LoyaltyPointsPage-MPZPTC5W.js → LoyaltyPointsPage-XHKQJLKS.js} +6 -6
  38. package/dist/{LoyaltyPointsPage-MPZPTC5W.js.map → LoyaltyPointsPage-XHKQJLKS.js.map} +1 -1
  39. package/dist/{MainMenu-3FRRSA75.js → MainMenu-5FWCLNGA.js} +5 -5
  40. package/dist/{MainMenu-3FRRSA75.js.map → MainMenu-5FWCLNGA.js.map} +1 -1
  41. package/dist/{MasterLayout-BZHQD3HJ.js → MasterLayout-6NE5WERV.js} +17 -17
  42. package/dist/{MasterLayout-BZHQD3HJ.js.map → MasterLayout-6NE5WERV.js.map} +1 -1
  43. package/dist/{MobileMenu-FEUDYZ42.js → MobileMenu-FJGYJSBC.js} +18 -18
  44. package/dist/{MobileMenu-FEUDYZ42.js.map → MobileMenu-FJGYJSBC.js.map} +1 -1
  45. package/dist/{NotificationsPage-G3DQBWML.js → NotificationsPage-3Y3MKZK6.js} +17 -17
  46. package/dist/{NotificationsPage-G3DQBWML.js.map → NotificationsPage-3Y3MKZK6.js.map} +1 -1
  47. package/dist/{OrderSinglePage-73G5GUJJ.js → OrderSinglePage-6YBCBFNO.js} +18 -18
  48. package/dist/{OrderSinglePage-73G5GUJJ.js.map → OrderSinglePage-6YBCBFNO.js.map} +1 -1
  49. package/dist/{OrdersPage-BY5EKZDD.js → OrdersPage-GPIWRVZG.js} +17 -17
  50. package/dist/{OrdersPage-BY5EKZDD.js.map → OrdersPage-GPIWRVZG.js.map} +1 -1
  51. package/dist/{PageSingle-UNS2BYHY.js → PageSingle-NZPCT2XG.js} +3 -3
  52. package/dist/{PageSingle-UNS2BYHY.js.map → PageSingle-NZPCT2XG.js.map} +1 -1
  53. package/dist/{ProductDetails-JCD5BW76.js → ProductDetails-3YGL2QGH.js} +5 -5
  54. package/dist/{ProductDetails-JCD5BW76.js.map → ProductDetails-3YGL2QGH.js.map} +1 -1
  55. package/dist/{ProfilePage-KICJ57GW.js → ProfilePage-RCMMC7OG.js} +17 -17
  56. package/dist/{ProfilePage-KICJ57GW.js.map → ProfilePage-RCMMC7OG.js.map} +1 -1
  57. package/dist/{ReviewsPage-DTPR4TD4.js → ReviewsPage-FVGX7INF.js} +3 -3
  58. package/dist/{ReviewsPage-DTPR4TD4.js.map → ReviewsPage-FVGX7INF.js.map} +1 -1
  59. package/dist/{SeoCartWidget-MNGAOTET.js → SeoCartWidget-S4PEITSP.js} +17 -17
  60. package/dist/{SeoCartWidget-MNGAOTET.js.map → SeoCartWidget-S4PEITSP.js.map} +1 -1
  61. package/dist/{SettingsPage-IILCN4S6.js → SettingsPage-2OZA647W.js} +17 -17
  62. package/dist/{SettingsPage-IILCN4S6.js.map → SettingsPage-2OZA647W.js.map} +1 -1
  63. package/dist/{StoreClosedNotification-BFJHP22E.js → StoreClosedNotification-XIVWDEEQ.js} +18 -18
  64. package/dist/{StoreClosedNotification-BFJHP22E.js.map → StoreClosedNotification-XIVWDEEQ.js.map} +1 -1
  65. package/dist/{TestimonialsPage-R4QD6ZZG.js → TestimonialsPage-EA3N7W56.js} +3 -3
  66. package/dist/{TestimonialsPage-R4QD6ZZG.js.map → TestimonialsPage-EA3N7W56.js.map} +1 -1
  67. package/dist/{ThankYouPage-UIGRVDUY.js → ThankYouPage-4SRPOE65.js} +17 -17
  68. package/dist/{ThankYouPage-UIGRVDUY.js.map → ThankYouPage-4SRPOE65.js.map} +1 -1
  69. package/dist/{WalletPage-DSUVR6M5.js → WalletPage-IBMF5AQ7.js} +18 -18
  70. package/dist/{WalletPage-DSUVR6M5.js.map → WalletPage-IBMF5AQ7.js.map} +1 -1
  71. package/dist/{WebMcpTools-UQF5UD7W.js → WebMcpTools-7ILPBGW4.js} +5 -5
  72. package/dist/{WebMcpTools-UQF5UD7W.js.map → WebMcpTools-7ILPBGW4.js.map} +1 -1
  73. package/dist/{WishlistPage-ILCHKMFE.js → WishlistPage-KVLEDTXR.js} +19 -19
  74. package/dist/{WishlistPage-ILCHKMFE.js.map → WishlistPage-KVLEDTXR.js.map} +1 -1
  75. package/dist/api/advertisement.js +2 -2
  76. package/dist/api/apps.js +2 -2
  77. package/dist/api/blog.js +3 -3
  78. package/dist/api/brands.js +3 -3
  79. package/dist/api/cart.js +3 -3
  80. package/dist/api/category.js +3 -3
  81. package/dist/api/client.js +1 -1
  82. package/dist/api/custom-url.js +2 -2
  83. package/dist/api/home.js +2 -2
  84. package/dist/api/loyalty.js +3 -3
  85. package/dist/api/menu.js +2 -2
  86. package/dist/api/notification.js +2 -2
  87. package/dist/api/order.js +3 -3
  88. package/dist/api/page.js +3 -3
  89. package/dist/api/product.js +3 -3
  90. package/dist/api/profile.js +1 -1
  91. package/dist/api/store.js +2 -2
  92. package/dist/api/translations.js +2 -2
  93. package/dist/api/user.js +2 -2
  94. package/dist/api/wallet.js +2 -2
  95. package/dist/api/wishlist.js +4 -4
  96. package/dist/{chunk-QFJ3K74X.js → chunk-2RYMYLXS.js} +3 -3
  97. package/dist/{chunk-QFJ3K74X.js.map → chunk-2RYMYLXS.js.map} +1 -1
  98. package/dist/{chunk-F5CBGBXC.js → chunk-3LSW57HE.js} +3 -3
  99. package/dist/{chunk-F5CBGBXC.js.map → chunk-3LSW57HE.js.map} +1 -1
  100. package/dist/{chunk-5TECTHHK.js → chunk-3MHZVWRI.js} +9 -8
  101. package/dist/chunk-3MHZVWRI.js.map +1 -0
  102. package/dist/{chunk-WNWIZIM2.js → chunk-3W42UZSQ.js} +3 -3
  103. package/dist/{chunk-WNWIZIM2.js.map → chunk-3W42UZSQ.js.map} +1 -1
  104. package/dist/{chunk-6U2R3COR.js → chunk-42FFGD7O.js} +6 -6
  105. package/dist/{chunk-6U2R3COR.js.map → chunk-42FFGD7O.js.map} +1 -1
  106. package/dist/{chunk-VXWBXATO.js → chunk-4QK6FO3U.js} +4 -4
  107. package/dist/{chunk-VXWBXATO.js.map → chunk-4QK6FO3U.js.map} +1 -1
  108. package/dist/{chunk-Q5WFMQB5.js → chunk-4VQ2XUVG.js} +3 -3
  109. package/dist/{chunk-Q5WFMQB5.js.map → chunk-4VQ2XUVG.js.map} +1 -1
  110. package/dist/{chunk-7NEJCQQ3.js → chunk-54VGFM4I.js} +3 -3
  111. package/dist/{chunk-7NEJCQQ3.js.map → chunk-54VGFM4I.js.map} +1 -1
  112. package/dist/{chunk-WBJOEOTV.js → chunk-7N5EUEMK.js} +4 -4
  113. package/dist/{chunk-WBJOEOTV.js.map → chunk-7N5EUEMK.js.map} +1 -1
  114. package/dist/{chunk-MIXZNLOC.js → chunk-7ORMPMZL.js} +4 -4
  115. package/dist/{chunk-MIXZNLOC.js.map → chunk-7ORMPMZL.js.map} +1 -1
  116. package/dist/{chunk-VZA6B566.js → chunk-7P6CX5CM.js} +4 -4
  117. package/dist/{chunk-VZA6B566.js.map → chunk-7P6CX5CM.js.map} +1 -1
  118. package/dist/{chunk-AIBTJH3U.js → chunk-ABQXES25.js} +5 -5
  119. package/dist/{chunk-AIBTJH3U.js.map → chunk-ABQXES25.js.map} +1 -1
  120. package/dist/{chunk-5LQ6OAAH.js → chunk-BOB2BDLK.js} +4 -4
  121. package/dist/{chunk-5LQ6OAAH.js.map → chunk-BOB2BDLK.js.map} +1 -1
  122. package/dist/{chunk-4D4AAOP6.js → chunk-BRX23CR2.js} +3 -3
  123. package/dist/{chunk-4D4AAOP6.js.map → chunk-BRX23CR2.js.map} +1 -1
  124. package/dist/{chunk-MSL3DEDB.js → chunk-BXUX5FHW.js} +3 -3
  125. package/dist/{chunk-MSL3DEDB.js.map → chunk-BXUX5FHW.js.map} +1 -1
  126. package/dist/{chunk-S6EGQM36.js → chunk-CBLSUXTP.js} +3 -3
  127. package/dist/{chunk-S6EGQM36.js.map → chunk-CBLSUXTP.js.map} +1 -1
  128. package/dist/{chunk-WV2V3RVP.js → chunk-D4J3KPGI.js} +4 -4
  129. package/dist/{chunk-WV2V3RVP.js.map → chunk-D4J3KPGI.js.map} +1 -1
  130. package/dist/{chunk-TT3RMAWV.js → chunk-DWLEKQ3A.js} +3 -3
  131. package/dist/{chunk-TT3RMAWV.js.map → chunk-DWLEKQ3A.js.map} +1 -1
  132. package/dist/{chunk-VNX4SSBX.js → chunk-EKBM77K4.js} +3 -3
  133. package/dist/{chunk-VNX4SSBX.js.map → chunk-EKBM77K4.js.map} +1 -1
  134. package/dist/{chunk-PRAMCUB3.js → chunk-F7HINVWX.js} +19 -19
  135. package/dist/{chunk-PRAMCUB3.js.map → chunk-F7HINVWX.js.map} +1 -1
  136. package/dist/{chunk-FJF6YEHY.js → chunk-FK4SQURQ.js} +7 -7
  137. package/dist/{chunk-FJF6YEHY.js.map → chunk-FK4SQURQ.js.map} +1 -1
  138. package/dist/{chunk-IUHIUV26.js → chunk-FSCJ2VXL.js} +5 -5
  139. package/dist/{chunk-IUHIUV26.js.map → chunk-FSCJ2VXL.js.map} +1 -1
  140. package/dist/{chunk-4QJJA3I3.js → chunk-GGMWJJFB.js} +3 -3
  141. package/dist/{chunk-4QJJA3I3.js.map → chunk-GGMWJJFB.js.map} +1 -1
  142. package/dist/{chunk-AGQAFP7M.js → chunk-HI5OUST4.js} +3 -3
  143. package/dist/{chunk-AGQAFP7M.js.map → chunk-HI5OUST4.js.map} +1 -1
  144. package/dist/{chunk-PCD3PFHR.js → chunk-IAPLCMKH.js} +4 -4
  145. package/dist/{chunk-PCD3PFHR.js.map → chunk-IAPLCMKH.js.map} +1 -1
  146. package/dist/{chunk-KI7K5S5Q.js → chunk-IPFX3GQO.js} +4 -4
  147. package/dist/{chunk-KI7K5S5Q.js.map → chunk-IPFX3GQO.js.map} +1 -1
  148. package/dist/{chunk-PXFFPKSW.js → chunk-K5EHQI7U.js} +4 -4
  149. package/dist/{chunk-PXFFPKSW.js.map → chunk-K5EHQI7U.js.map} +1 -1
  150. package/dist/{chunk-OFKVQZYA.js → chunk-LHCCAJXH.js} +3 -3
  151. package/dist/{chunk-OFKVQZYA.js.map → chunk-LHCCAJXH.js.map} +1 -1
  152. package/dist/{chunk-MF74MEOT.js → chunk-LUXNURXU.js} +4 -4
  153. package/dist/{chunk-MF74MEOT.js.map → chunk-LUXNURXU.js.map} +1 -1
  154. package/dist/{chunk-TFHTXAY4.js → chunk-MFLYX5OS.js} +4 -4
  155. package/dist/{chunk-TFHTXAY4.js.map → chunk-MFLYX5OS.js.map} +1 -1
  156. package/dist/chunk-MHBWYHS5.js +22 -0
  157. package/dist/chunk-MHBWYHS5.js.map +1 -0
  158. package/dist/{chunk-NPRMYIY4.js → chunk-MQ35BIJL.js} +3 -3
  159. package/dist/{chunk-NPRMYIY4.js.map → chunk-MQ35BIJL.js.map} +1 -1
  160. package/dist/{chunk-H6FKLBCS.js → chunk-MSKSTXPM.js} +4 -4
  161. package/dist/{chunk-H6FKLBCS.js.map → chunk-MSKSTXPM.js.map} +1 -1
  162. package/dist/{chunk-A7FCCVN4.js → chunk-O3OSW5KZ.js} +3 -3
  163. package/dist/{chunk-A7FCCVN4.js.map → chunk-O3OSW5KZ.js.map} +1 -1
  164. package/dist/{chunk-IPF6LCPB.js → chunk-OXPVKKJP.js} +7 -7
  165. package/dist/{chunk-IPF6LCPB.js.map → chunk-OXPVKKJP.js.map} +1 -1
  166. package/dist/{chunk-KIGPESAH.js → chunk-PJXTRHQN.js} +4 -4
  167. package/dist/{chunk-KIGPESAH.js.map → chunk-PJXTRHQN.js.map} +1 -1
  168. package/dist/{chunk-Q5YDLJTE.js → chunk-Q4RVSULH.js} +3 -3
  169. package/dist/{chunk-Q5YDLJTE.js.map → chunk-Q4RVSULH.js.map} +1 -1
  170. package/dist/{chunk-EES7CISM.js → chunk-SFZBBDO5.js} +3 -3
  171. package/dist/{chunk-EES7CISM.js.map → chunk-SFZBBDO5.js.map} +1 -1
  172. package/dist/{chunk-IOSJKP7Y.js → chunk-SHUCELQ5.js} +3 -3
  173. package/dist/{chunk-IOSJKP7Y.js.map → chunk-SHUCELQ5.js.map} +1 -1
  174. package/dist/{chunk-B2VDGIS6.js → chunk-SWLIW4O7.js} +2 -2
  175. package/dist/{chunk-B2VDGIS6.js.map → chunk-SWLIW4O7.js.map} +1 -1
  176. package/dist/{chunk-H2ABV6TH.js → chunk-TJDFO67J.js} +3 -3
  177. package/dist/{chunk-H2ABV6TH.js.map → chunk-TJDFO67J.js.map} +1 -1
  178. package/dist/{chunk-KGNT2I5N.js → chunk-TUZU2FUP.js} +4 -4
  179. package/dist/{chunk-KGNT2I5N.js.map → chunk-TUZU2FUP.js.map} +1 -1
  180. package/dist/{chunk-4QSG6MWL.js → chunk-TZBXOHSS.js} +14 -14
  181. package/dist/{chunk-4QSG6MWL.js.map → chunk-TZBXOHSS.js.map} +1 -1
  182. package/dist/{chunk-QP7AVGLQ.js → chunk-VNX6EXCN.js} +7 -7
  183. package/dist/{chunk-QP7AVGLQ.js.map → chunk-VNX6EXCN.js.map} +1 -1
  184. package/dist/{chunk-VMZCTYR4.js → chunk-WEBVRLRB.js} +3 -3
  185. package/dist/{chunk-VMZCTYR4.js.map → chunk-WEBVRLRB.js.map} +1 -1
  186. package/dist/{chunk-NCBRZRAP.js → chunk-WFXFO222.js} +3 -3
  187. package/dist/{chunk-NCBRZRAP.js.map → chunk-WFXFO222.js.map} +1 -1
  188. package/dist/{chunk-2WLFUHGI.js → chunk-WHIIVRZF.js} +4 -4
  189. package/dist/{chunk-2WLFUHGI.js.map → chunk-WHIIVRZF.js.map} +1 -1
  190. package/dist/{chunk-QKQVXVC5.js → chunk-XN4FAL4G.js} +4 -4
  191. package/dist/{chunk-QKQVXVC5.js.map → chunk-XN4FAL4G.js.map} +1 -1
  192. package/dist/{chunk-SGJDENMI.js → chunk-XRBYWXFG.js} +3 -3
  193. package/dist/{chunk-SGJDENMI.js.map → chunk-XRBYWXFG.js.map} +1 -1
  194. package/dist/{chunk-RSZPZRTD.js → chunk-XRUCBGMT.js} +4 -4
  195. package/dist/{chunk-RSZPZRTD.js.map → chunk-XRUCBGMT.js.map} +1 -1
  196. package/dist/{chunk-5ZFU7LTC.js → chunk-YUWM5AU7.js} +5 -5
  197. package/dist/{chunk-5ZFU7LTC.js.map → chunk-YUWM5AU7.js.map} +1 -1
  198. package/dist/components/cart/index.js +1 -1
  199. package/dist/components/common/index.js +1 -1
  200. package/dist/components/drawer/index.js +15 -15
  201. package/dist/components/home/index.js +20 -20
  202. package/dist/components/layout/index.js +4 -4
  203. package/dist/components/product/index.js +17 -17
  204. package/dist/components/store/index.js +16 -16
  205. package/dist/components/tracking/index.js +6 -6
  206. package/dist/{custom-urls-PIQDXCXN.js → custom-urls-XGNEF3FO.js} +7 -7
  207. package/dist/{custom-urls-PIQDXCXN.js.map → custom-urls-XGNEF3FO.js.map} +1 -1
  208. package/dist/dev/editor/index.js +1 -1
  209. package/dist/dev/index.js +1 -1
  210. package/dist/{document-class-4IX3ARNH.js → document-class-VGMESCGP.js} +17 -17
  211. package/dist/{document-class-4IX3ARNH.js.map → document-class-VGMESCGP.js.map} +1 -1
  212. package/dist/hooks/index.js +15 -15
  213. package/dist/hooks/useGtm.js +15 -15
  214. package/dist/hooks/useMoney.js +15 -15
  215. package/dist/hooks/useStore.js +15 -15
  216. package/dist/hooks/useUser.js +3 -3
  217. package/dist/index.js +15 -15
  218. package/dist/{navigation-FNSXWOVU.js → navigation-3RCZRME5.js} +4 -4
  219. package/dist/{navigation-FNSXWOVU.js.map → navigation-3RCZRME5.js.map} +1 -1
  220. package/dist/{navigation-HVGJE3F6.js → navigation-HCIKY36A.js} +5 -5
  221. package/dist/{navigation-HVGJE3F6.js.map → navigation-HCIKY36A.js.map} +1 -1
  222. package/dist/{not-found-ROFGDF26.js → not-found-MAYML5V7.js} +18 -18
  223. package/dist/{not-found-ROFGDF26.js.map → not-found-MAYML5V7.js.map} +1 -1
  224. package/dist/providers/index.js +15 -15
  225. package/dist/routes/account/orders.js +4 -4
  226. package/dist/routes/account.js +13 -13
  227. package/dist/routes/blog/index.d.ts.map +1 -1
  228. package/dist/routes/blog/types.d.ts +4 -0
  229. package/dist/routes/blog/types.d.ts.map +1 -1
  230. package/dist/routes/blog.js +22 -16
  231. package/dist/routes/blog.js.map +1 -1
  232. package/dist/routes/brands.js +4 -4
  233. package/dist/routes/cart.js +26 -25
  234. package/dist/routes/cart.js.map +1 -1
  235. package/dist/routes/home/index.d.ts.map +1 -1
  236. package/dist/routes/home.js +22 -21
  237. package/dist/routes/index.js +8 -8
  238. package/dist/routes/loyalty.js +5 -5
  239. package/dist/routes/page.js +4 -4
  240. package/dist/routes/product-listing.js +25 -25
  241. package/dist/routes/product.js +24 -24
  242. package/dist/routes/seo-redirects.js +8 -8
  243. package/dist/routes/testimonials.js +2 -2
  244. package/dist/routes/thank-you.js +4 -4
  245. package/dist/skeleton.js +24 -23
  246. package/dist/{store-lookup-WUMF73WT.js → store-lookup-653RQUCV.js} +8 -8
  247. package/dist/{store-lookup-WUMF73WT.js.map → store-lookup-653RQUCV.js.map} +1 -1
  248. package/dist/tanstack.js +17 -17
  249. package/dist/utils/index.js +2 -2
  250. package/dist/utils/seo-text.d.ts +23 -0
  251. package/dist/utils/seo-text.d.ts.map +1 -0
  252. package/package.json +1 -1
  253. package/tailwind/routes/blog/index.tsx.txt +15 -8
  254. package/tailwind/routes/blog/types.ts.txt +4 -0
  255. package/tailwind/routes/home/index.tsx.txt +5 -3
  256. package/dist/GoogleTag-PM23J7UJ.js +0 -15
  257. package/dist/chunk-5TECTHHK.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { api } from '../chunk-S6EGQM36.js';
1
+ import { api } from '../chunk-CBLSUXTP.js';
2
2
  import '../chunk-Z5M4YYWT.js';
3
3
  import '../chunk-MZPX4EPS.js';
4
4
  import '../chunk-4OZIBANF.js';
package/dist/api/store.js CHANGED
@@ -1,6 +1,6 @@
1
- export { store } from '../chunk-WNWIZIM2.js';
1
+ export { store } from '../chunk-3W42UZSQ.js';
2
2
  import '../chunk-O7JTXTGP.js';
3
- import '../chunk-S6EGQM36.js';
3
+ import '../chunk-CBLSUXTP.js';
4
4
  import '../chunk-Z5M4YYWT.js';
5
5
  import '../chunk-MZPX4EPS.js';
6
6
  export { resolveStoreIdentifier } from '../chunk-4OZIBANF.js';
@@ -1,5 +1,5 @@
1
- export { commonTranslationsPath, storeTranslationsPath, translations } from '../chunk-7NEJCQQ3.js';
2
- import '../chunk-S6EGQM36.js';
1
+ export { commonTranslationsPath, storeTranslationsPath, translations } from '../chunk-54VGFM4I.js';
2
+ import '../chunk-CBLSUXTP.js';
3
3
  import '../chunk-Z5M4YYWT.js';
4
4
  import '../chunk-MZPX4EPS.js';
5
5
  import '../chunk-4OZIBANF.js';
package/dist/api/user.js CHANGED
@@ -1,5 +1,5 @@
1
- export { user } from '../chunk-VMZCTYR4.js';
2
- import '../chunk-S6EGQM36.js';
1
+ export { user } from '../chunk-WEBVRLRB.js';
2
+ import '../chunk-CBLSUXTP.js';
3
3
  import '../chunk-Z5M4YYWT.js';
4
4
  import '../chunk-MZPX4EPS.js';
5
5
  import '../chunk-4OZIBANF.js';
@@ -1,5 +1,5 @@
1
- export { wallet } from '../chunk-H2ABV6TH.js';
2
- import '../chunk-S6EGQM36.js';
1
+ export { wallet } from '../chunk-TJDFO67J.js';
2
+ import '../chunk-CBLSUXTP.js';
3
3
  import '../chunk-Z5M4YYWT.js';
4
4
  import '../chunk-MZPX4EPS.js';
5
5
  import '../chunk-4OZIBANF.js';
@@ -1,8 +1,8 @@
1
- export { wishlist } from '../chunk-QKQVXVC5.js';
2
- import '../chunk-VXWBXATO.js';
3
- import '../chunk-OFKVQZYA.js';
1
+ export { wishlist } from '../chunk-XN4FAL4G.js';
2
+ import '../chunk-4QK6FO3U.js';
3
+ import '../chunk-LHCCAJXH.js';
4
4
  import '../chunk-OUW6WESU.js';
5
- import '../chunk-S6EGQM36.js';
5
+ import '../chunk-CBLSUXTP.js';
6
6
  import '../chunk-Z5M4YYWT.js';
7
7
  import '../chunk-BZ2QSBXM.js';
8
8
  import '../chunk-MZPX4EPS.js';
@@ -1,4 +1,4 @@
1
- import { configureNavigation, UnauthorizedError, NavigationProvider, resolveRelativePath } from './chunk-OFKVQZYA.js';
1
+ import { configureNavigation, UnauthorizedError, NavigationProvider, resolveRelativePath } from './chunk-LHCCAJXH.js';
2
2
  import { LinkProvider } from './chunk-EDCNCBSC.js';
3
3
  import { useIsNativeApp } from './chunk-BZ2QSBXM.js';
4
4
  import { onSallaEvent } from './chunk-MZPX4EPS.js';
@@ -214,5 +214,5 @@ function TanStackNavigationProvider({ children }) {
214
214
  }
215
215
 
216
216
  export { NavigationSetup, TanStackLinkAdapter, TanStackNavigationProvider, createTanStackLinkAdapter, documentRedirectHref, requestHostOf };
217
- //# sourceMappingURL=chunk-QFJ3K74X.js.map
218
- //# sourceMappingURL=chunk-QFJ3K74X.js.map
217
+ //# sourceMappingURL=chunk-2RYMYLXS.js.map
218
+ //# sourceMappingURL=chunk-2RYMYLXS.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/tanstack/link.tsx","../src/tanstack/native-app-events.tsx","../src/utils/request-host.ts","../src/tanstack/navigation.tsx"],"names":["TanStackLink","tanstackNotFound","tanstackRedirect","useParams","jsx"],"mappings":";;;;;;;;;;;;AAWO,SAAS,mBAAA,CAAoB,aAAqB,MAAA,EAAiB;AAExE,EAAA,IAAI,CAAC,QAAA,CAAS,MAAM,CAAA,IAAK,CAAC,WAAA,CAAY,UAAA,CAAW,GAAG,CAAA,IAAK,WAAA,CAAY,UAAA,CAAW,IAAI,CAAA,EAAG;AACrF,IAAA,OAAO,WAAA;AAAA,EACT;AACA,EAAA,MAAM,YAAA,GAAe,WAAA,CAAY,KAAA,CAAM,GAAG,CAAA,CAAE,CAAC,CAAA,EAAG,KAAA,CAAM,MAAM,CAAA,CAAE,CAAC,CAAA;AAC/D,EAAA,IAAI,QAAA,CAAS,YAAY,CAAA,EAAG,OAAO,WAAA;AACnC,EAAA,OAAO,WAAA,KAAgB,MAAM,CAAA,CAAA,EAAI,MAAM,KAAK,CAAA,CAAA,EAAI,MAAM,GAAG,WAAW,CAAA,CAAA;AACtE;AAMO,IAAM,mBAAA,GAAsB,UAAA;AAAA,EACjC,CACE;AAAA,IACE,EAAA;AAAA,IACA,IAAA;AA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,mBAAgB,MAAA,EAAgB,CAAA;AAAA,oBACjCA,GAAAA,CAAC,YAAA,EAAA,EAAa,OAAA,EAAS,qBAAsB,QAAA,EAAS;AAAA,GAAA,EACxD,CAAA;AAEJ;AAGO,SAAS,0BAAA,CAA2B,EAAE,QAAA,EAAS,EAA4B;AAChF,EAAA,MAAM,WAAW,WAAA,EAAY;AAC7B,EAAA,uBACEA,GAAAA;AAAA,IAAC,kBAAA;AAAA,IAAA;AAAA,MACC,QAAA,EAAU,CAAC,EAAA,EAAY,IAAA,KAA2B,QAAA,CAAS,EAAE,EAAA,EAAI,OAAA,EAAS,IAAA,EAAM,OAAA,EAAS,CAAA;AAAA,MAEzF,QAAA,kBAAAA,GAAAA,CAAC,YAAA,EAAA,EAAa,OAAA,EAAS,qBAAsB,QAAA,EAAS;AAAA;AAAA,GACxD;AAEJ","file":"chunk-QFJ3K74X.js","sourcesContent":["import { forwardRef, createElement } from 'react';\nimport { Link as TanStackLink, useParams } from '@tanstack/react-router';\nimport { isLocale } from '../providers/locale-constants';\nimport type { BaseLinkProps } from '../components/common/Link.types';\n\n/**\n * Routes live under an optional `/{-$locale}` param, so a bare `to=\"/brands\"`\n * resolves with the locale omitted and the $locale loader bounces the user to\n * the fallback locale. Prefix the current locale onto internal paths that\n * don't already carry one.\n */\nexport function localizeDestination(destination: string, locale?: string) {\n // On the not-found page a first segment that is no language binds as the locale (`/p1-x`).\n if (!isLocale(locale) || !destination.startsWith('/') || destination.startsWith('//')) {\n return destination;\n }\n const firstSegment = destination.split('/')[1]?.split(/[?#]/)[0];\n if (isLocale(firstSegment)) return destination;\n return destination === '/' ? `/${locale}` : `/${locale}${destination}`;\n}\n\n/**\n * TanStack Router Link adapter.\n * Translates framework-agnostic props to TanStack Router Link props.\n */\nexport const TanStackLinkAdapter = forwardRef<HTMLAnchorElement, BaseLinkProps>(\n (\n {\n to,\n href,\n children,\n className,\n style,\n title,\n target,\n rel,\n onClick,\n preload,\n replace,\n 'aria-label': ariaLabel,\n ...rest\n },\n ref\n ) => {\n const { locale } = useParams({ strict: false }) as { locale?: string };\n const destination = localizeDestination(to ?? href ?? '/', locale);\n\n // `#` is how a block says it has nowhere to go, such as a banner with no URL. An anchor with\n // no href keeps the theme's `a` styles, and the router can neither preload nor follow it.\n if (destination === '#') {\n return createElement(\n 'a',\n { ref, className, style, title, onClick, 'aria-label': ariaLabel, ...rest },\n children\n );\n }\n\n return createElement(\n TanStackLink,\n {\n ref,\n to: destination,\n className,\n style,\n title,\n target,\n rel,\n onClick,\n preload: preload === 'intent' || preload === false ? preload : undefined,\n replace,\n 'aria-label': ariaLabel,\n ...(rest as Record<string, unknown>),\n },\n children\n );\n }\n);\n\nTanStackLinkAdapter.displayName = 'TanStackLinkAdapter';\n\n/**\n * Create a TanStack Router Link adapter component.\n */\nexport function createTanStackLinkAdapter() {\n return TanStackLinkAdapter;\n}\n","import { useEffect } from 'react';\nimport { useRouter } from '@tanstack/react-router';\nimport { resolveRelativePath } from '../providers/NavigationProvider';\nimport { useTwilight } from '../providers/twilight-context';\nimport { isLocale } from '../providers/locale-constants';\nimport { getTwilightContext } from '../twilight/context';\nimport { useIsNativeApp } from '../native-app';\nimport { onSallaEvent } from '../utils/sdk-helpers';\nimport { hasStoreUrlBase } from '../utils/store-base';\nimport { localizeDestination } from './link';\n\nconst UI_UPDATE_EVENT = 'mobile::ui.update';\nconst OPEN_ORDER_EVENT = 'mobile::open.order';\nconst NAVIGATE_TO_EVENT = 'mobile::navigate.to';\n\n/**\n * Events the native app sends into its webview. `NavigationSetup` mounts this once, so a\n * theme adds no listener of its own:\n *\n * - `mobile::ui.update` re-runs the route loaders and refetches what is on screen.\n * - `mobile::open.order` `{ id }` opens that order, with a fresh cart.\n * - `mobile::navigate.to` `{ url }` opens a notification deep link in-app. Only a link to\n * this store is followed (`deepLinkPath`), so `javascript:`, off-site and other stores'\n * URLs are dropped.\n *\n * Nothing is mounted outside the app (`useIsNativeApp()`), so a browser runs none of it.\n */\nexport function NativeAppEvents({ locale }: { locale?: string }) {\n return useIsNativeApp() ? <Listeners locale={locale} /> : null;\n}\n\nfunction Listeners({ locale }: { locale?: string }) {\n useNativeAppEvents(locale);\n return null;\n}\n\n/** The listeners themselves. `NativeAppEvents` mounts them inside the app only. */\nexport function useNativeAppEvents(locale?: string): void {\n const router = useRouter();\n const { store } = useTwilight();\n const storeUrl = store?.url;\n const username = store?.username;\n\n useEffect(() => {\n // `href`, not `to`: the router parses the query and the hash out of it.\n const open = (path: string) =>\n void router.navigate({ href: localizeDestination(path, locale) });\n\n const refresh = () => {\n void Promise.allSettled([\n router.invalidate(),\n getTwilightContext().queryClient?.refetchQueries({ type: 'active' }),\n ]);\n };\n const openOrder = (data?: unknown) => {\n const rawId = (data as { id?: unknown } | undefined)?.id;\n if (typeof rawId !== 'string' && typeof rawId !== 'number') return;\n\n const id = String(rawId).trim();\n if (!id) return;\n\n void getTwilightContext().queryClient?.invalidateQueries({ queryKey: ['cart'] });\n open(`/account/orders/${encodeURIComponent(id)}`);\n };\n const navigateTo = (data?: unknown) => {\n const url = (data as { url?: unknown } | undefined)?.url;\n if (typeof url !== 'string' || !url.trim() || !storeUrl) return;\n\n const path = deepLinkPath(url.trim(), storeUrl, username);\n if (path) void router.navigate({ href: inLocale(path, locale) });\n };\n\n const offs = [\n onSallaEvent(UI_UPDATE_EVENT, refresh),\n onSallaEvent(OPEN_ORDER_EVENT, openOrder),\n onSallaEvent(NAVIGATE_TO_EVENT, navigateTo),\n ];\n return () => offs.forEach((off) => off());\n }, [router, locale, storeUrl, username]);\n}\n\n/** A URL that names its host: `https://…` or `//…`. Anything else is a path of this app. */\nfunction isAbsoluteUrl(url: string): boolean {\n if (url.startsWith('//')) return true;\n try {\n // Without a base, only a URL with its own scheme parses.\n new URL(url);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * The application path of a deep link to this store, or null for any other link.\n *\n * It passes the test a tapped link does (`resolveRelativePath`: the store's origin, the\n * username taken off), and one more. On a shared host that origin is every store's, so\n * an absolute link has to carry this store's username: without it, another store's\n * `/ar/offers` would open this store's offers.\n */\nfunction deepLinkPath(url: string, storeUrl: string, username?: string): string | null {\n const path = resolveRelativePath(url, storeUrl, username);\n if (!path || !isAbsoluteUrl(url)) return path;\n\n // Both parse: `resolveRelativePath` returns null when either does not.\n const { pathname } = new URL(url, window.location.href);\n return hasStoreUrlBase(pathname, new URL(storeUrl).pathname, username) ? path : null;\n}\n\n/**\n * A deep link in the locale the visitor is browsing in. A notification is written in one\n * language and opened in whichever is on screen, so the link's own locale gives way.\n *\n * The prefix is written here, not by `localizeDestination`: that one leaves a path alone\n * when it already starts with a locale, and would take the slug of `/ar/en/p456` for one.\n */\nfunction inLocale(path: string, locale?: string): string {\n const first = path.split('/')[1]?.split(/[?#]/)[0];\n const own = isLocale(first) ? path.slice(first.length + 1) : path;\n const rest = own.startsWith('/') ? own : `/${own}`;\n\n if (!locale) return rest;\n return rest === '/' ? `/${locale}` : `/${locale}${rest}`;\n}\n","/**\n * What the request itself is enough to describe: its host.\n *\n * Small, and deliberately its own module rather than a helper inside the\n * middleware. This value decides two things — which store a live storefront is,\n * and whether the request is allowed to name a store at all — so it is worth\n * testing directly instead of only through the wiring that calls it.\n */\nimport { isLoopback } from './cookies';\n\n/** The part of a `Request` this needs, so a test does not have to build a whole one. */\nexport interface HostSource {\n url: string;\n headers: { get(name: string): string | null };\n}\n\n/**\n * The host this request arrived on, with its port when it has one.\n *\n * Taken from the request URL, which in a Worker is the address the platform\n * actually routed on, and from the `Host` header only when that fails.\n *\n * **`X-Forwarded-Host` is deliberately not consulted.** A client can set it, and\n * this value gates `allowsRequestStoreId` — so honouring it would be a way to\n * talk a merchant's own domain into behaving like the preview host, and from\n * there into serving a stranger's shop. The dispatcher strips that header today;\n * a theme must not be one edit to another repository's allowlist away from a\n * spoofable identity.\n */\nexport function requestHostOf(request: HostSource): string | null {\n try {\n const fromUrl = new URL(request.url).host;\n if (fromUrl) return fromUrl;\n } catch {\n /* an unparseable URL falls through to the header */\n }\n\n return request.headers.get('Host')?.trim() || null;\n}\n\n/** The origin a browser reached this host on: `http` for a dev server, `https` otherwise. */\nexport function requestOriginOf(host: string): string {\n return `${isLoopback(host.replace(/:\\d+$/, '')) ? 'http' : 'https'}://${host}`;\n}\n","import {\n useNavigate,\n useParams,\n redirect as tanstackRedirect,\n notFound as tanstackNotFound,\n} from '@tanstack/react-router';\nimport {\n NavigationProvider,\n configureNavigation,\n type NavigateOptions,\n} from '../providers/NavigationProvider';\nimport { LinkProvider } from '../providers/LinkProvider';\nimport { TanStackLinkAdapter, localizeDestination } from './link';\nimport { NativeAppEvents } from './native-app-events';\nimport { useCallback, type ReactNode } from 'react';\nimport { UnauthorizedError, type RedirectOptions } from '../providers/NavigationProvider';\nimport { getRequestStore, getTwilightContext } from '../twilight/context';\nimport { resolveStoreBase, resolveStoreBaseFollowsLocale } from '../utils/store-identity';\nimport { loginRedirectHref } from '../utils/store-base';\nimport { requestOriginOf } from '../utils/request-host';\n\n/**\n * Where a document redirect (`reloadDocument`) may go: an http(s) URL, or a path on this host. A\n * protocol-relative `//host` or any other scheme is refused here, as an error the caller made:\n * the router throws on those too, and a page that cannot redirect safely must not try.\n */\nexport function documentRedirectHref(target: string): string {\n if (target.startsWith('/') && !target.startsWith('//')) return target;\n const url = new URL(target);\n if (url.protocol !== 'http:' && url.protocol !== 'https:') {\n throw new Error(`A document redirect needs an http(s) URL, not ${url.protocol}`);\n }\n return url.href;\n}\n\nfunction currentOrigin(): string | null {\n if (typeof window !== 'undefined') return window.location.origin;\n const host = getRequestStore().requestHost;\n return host ? requestOriginOf(host) : null;\n}\n\nconfigureNavigation({\n notFound: (message?: string) => {\n throw tanstackNotFound({ data: message });\n },\n redirect: (path: string, opts?: RedirectOptions) => {\n if (opts?.reloadDocument) {\n // `href`, not `to`: the router neither matches it nor adds the store base to it.\n const href = documentRedirectHref(path);\n throw tanstackRedirect({\n href,\n reloadDocument: true,\n replace: opts.replace,\n statusCode: opts.statusCode,\n });\n }\n throw tanstackRedirect({ to: path, replace: opts?.replace, statusCode: opts?.statusCode });\n },\n unauthorized: (message?: string) => {\n const origin = currentOrigin();\n const { pathname, searchStr } = getTwilightContext().location;\n const href =\n origin &&\n loginRedirectHref({\n pathname,\n searchStr,\n origin,\n base: resolveStoreBase(),\n baseFollowsLocale: resolveStoreBaseFollowsLocale(),\n });\n // A full load, because the SDK only reads `intended_to` when a page starts.\n if (href) throw tanstackRedirect({ href, reloadDocument: true, replace: true });\n throw new UnauthorizedError(message);\n },\n});\n\n/**\n * TanStack navigation setup - wraps children with NavigationProvider and LinkProvider.\n * Called by TwilightProvider when client.framework === 'tanstack'.\n */\nexport function NavigationSetup({ children }: { children: ReactNode }) {\n const navigate = useNavigate();\n const { locale } = useParams({ strict: false }) as { locale?: string };\n const navigateFn = useCallback(\n (to: string, opts?: NavigateOptions) =>\n navigate({ to: localizeDestination(to, locale), replace: opts?.replace }),\n [navigate, locale]\n );\n\n return (\n <NavigationProvider navigate={navigateFn}>\n <NativeAppEvents locale={locale} />\n <LinkProvider adapter={TanStackLinkAdapter}>{children}</LinkProvider>\n </NavigationProvider>\n );\n}\n\n/** @deprecated Use NavigationSetup instead */\nexport function TanStackNavigationProvider({ children }: { children: ReactNode }) {\n const navigate = useNavigate();\n return (\n <NavigationProvider\n navigate={(to: string, opts?: NavigateOptions) => navigate({ to, replace: opts?.replace })}\n >\n <LinkProvider adapter={TanStackLinkAdapter}>{children}</LinkProvider>\n </NavigationProvider>\n );\n}\n"]}
1
+ {"version":3,"sources":["../src/tanstack/link.tsx","../src/tanstack/native-app-events.tsx","../src/utils/request-host.ts","../src/tanstack/navigation.tsx"],"names":["TanStackLink","tanstackNotFound","tanstackRedirect","useParams","jsx"],"mappings":";;;;;;;;;;;;AAWO,SAAS,mBAAA,CAAoB,aAAqB,MAAA,EAAiB;AAExE,EAAA,IAAI,CAAC,QAAA,CAAS,MAAM,CAAA,IAAK,CAAC,WAAA,CAAY,UAAA,CAAW,GAAG,CAAA,IAAK,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AAS,EAA4B;AACrE,EAAA,MAAM,WAAW,WAAA,EAAY;AAC7B,EAAA,MAAM,EAAE,MAAA,EAAO,GAAIC,UAAU,EAAE,MAAA,EAAQ,OAAO,CAAA;AAC9C,EAAA,MAAM,UAAA,GAAa,WAAA;AAAA,IACjB,CAAC,EAAA,EAAY,IAAA,KACX,QAAA,CAAS,EAAE,EAAA,EAAI,mBAAA,CAAoB,EAAA,EAAI,MAAM,CAAA,EAAG,OAAA,EAAS,IAAA,EAAM,SAAS,CAAA;AAAA,IAC1E,CAAC,UAAU,MAAM;AAAA,GACnB;AAEA,EAAA,uBACE,IAAA,CAAC,kBAAA,EAAA,EAAmB,QAAA,EAAU,UAAA,EAC5B,QAAA,EAAA;AAAA,oBAAAC,GAAAA,CAAC,mBAAgB,MAAA,EAAgB,CAAA;AAAA,oBACjCA,GAAAA,CAAC,YAAA,EAAA,EAAa,OAAA,EAAS,qBAAsB,QAAA,EAAS;AAAA,GAAA,EACxD,CAAA;AAEJ;AAGO,SAAS,0BAAA,CAA2B,EAAE,QAAA,EAAS,EAA4B;AAChF,EAAA,MAAM,WAAW,WAAA,EAAY;AAC7B,EAAA,uBACEA,GAAAA;AAAA,IAAC,kBAAA;AAAA,IAAA;AAAA,MACC,QAAA,EAAU,CAAC,EAAA,EAAY,IAAA,KAA2B,QAAA,CAAS,EAAE,EAAA,EAAI,OAAA,EAAS,IAAA,EAAM,OAAA,EAAS,CAAA;AAAA,MAEzF,QAAA,kBAAAA,GAAAA,CAAC,YAAA,EAAA,EAAa,OAAA,EAAS,qBAAsB,QAAA,EAAS;AAAA;AAAA,GACxD;AAEJ","file":"chunk-2RYMYLXS.js","sourcesContent":["import { forwardRef, createElement } from 'react';\nimport { Link as TanStackLink, useParams } from '@tanstack/react-router';\nimport { isLocale } from '../providers/locale-constants';\nimport type { BaseLinkProps } from '../components/common/Link.types';\n\n/**\n * Routes live under an optional `/{-$locale}` param, so a bare `to=\"/brands\"`\n * resolves with the locale omitted and the $locale loader bounces the user to\n * the fallback locale. Prefix the current locale onto internal paths that\n * don't already carry one.\n */\nexport function localizeDestination(destination: string, locale?: string) {\n // On the not-found page a first segment that is no language binds as the locale (`/p1-x`).\n if (!isLocale(locale) || !destination.startsWith('/') || destination.startsWith('//')) {\n return destination;\n }\n const firstSegment = destination.split('/')[1]?.split(/[?#]/)[0];\n if (isLocale(firstSegment)) return destination;\n return destination === '/' ? `/${locale}` : `/${locale}${destination}`;\n}\n\n/**\n * TanStack Router Link adapter.\n * Translates framework-agnostic props to TanStack Router Link props.\n */\nexport const TanStackLinkAdapter = forwardRef<HTMLAnchorElement, BaseLinkProps>(\n (\n {\n to,\n href,\n children,\n className,\n style,\n title,\n target,\n rel,\n onClick,\n preload,\n replace,\n 'aria-label': ariaLabel,\n ...rest\n },\n ref\n ) => {\n const { locale } = useParams({ strict: false }) as { locale?: string };\n const destination = localizeDestination(to ?? href ?? '/', locale);\n\n // `#` is how a block says it has nowhere to go, such as a banner with no URL. An anchor with\n // no href keeps the theme's `a` styles, and the router can neither preload nor follow it.\n if (destination === '#') {\n return createElement(\n 'a',\n { ref, className, style, title, onClick, 'aria-label': ariaLabel, ...rest },\n children\n );\n }\n\n return createElement(\n TanStackLink,\n {\n ref,\n to: destination,\n className,\n style,\n title,\n target,\n rel,\n onClick,\n preload: preload === 'intent' || preload === false ? preload : undefined,\n replace,\n 'aria-label': ariaLabel,\n ...(rest as Record<string, unknown>),\n },\n children\n );\n }\n);\n\nTanStackLinkAdapter.displayName = 'TanStackLinkAdapter';\n\n/**\n * Create a TanStack Router Link adapter component.\n */\nexport function createTanStackLinkAdapter() {\n return TanStackLinkAdapter;\n}\n","import { useEffect } from 'react';\nimport { useRouter } from '@tanstack/react-router';\nimport { resolveRelativePath } from '../providers/NavigationProvider';\nimport { useTwilight } from '../providers/twilight-context';\nimport { isLocale } from '../providers/locale-constants';\nimport { getTwilightContext } from '../twilight/context';\nimport { useIsNativeApp } from '../native-app';\nimport { onSallaEvent } from '../utils/sdk-helpers';\nimport { hasStoreUrlBase } from '../utils/store-base';\nimport { localizeDestination } from './link';\n\nconst UI_UPDATE_EVENT = 'mobile::ui.update';\nconst OPEN_ORDER_EVENT = 'mobile::open.order';\nconst NAVIGATE_TO_EVENT = 'mobile::navigate.to';\n\n/**\n * Events the native app sends into its webview. `NavigationSetup` mounts this once, so a\n * theme adds no listener of its own:\n *\n * - `mobile::ui.update` re-runs the route loaders and refetches what is on screen.\n * - `mobile::open.order` `{ id }` opens that order, with a fresh cart.\n * - `mobile::navigate.to` `{ url }` opens a notification deep link in-app. Only a link to\n * this store is followed (`deepLinkPath`), so `javascript:`, off-site and other stores'\n * URLs are dropped.\n *\n * Nothing is mounted outside the app (`useIsNativeApp()`), so a browser runs none of it.\n */\nexport function NativeAppEvents({ locale }: { locale?: string }) {\n return useIsNativeApp() ? <Listeners locale={locale} /> : null;\n}\n\nfunction Listeners({ locale }: { locale?: string }) {\n useNativeAppEvents(locale);\n return null;\n}\n\n/** The listeners themselves. `NativeAppEvents` mounts them inside the app only. */\nexport function useNativeAppEvents(locale?: string): void {\n const router = useRouter();\n const { store } = useTwilight();\n const storeUrl = store?.url;\n const username = store?.username;\n\n useEffect(() => {\n // `href`, not `to`: the router parses the query and the hash out of it.\n const open = (path: string) =>\n void router.navigate({ href: localizeDestination(path, locale) });\n\n const refresh = () => {\n void Promise.allSettled([\n router.invalidate(),\n getTwilightContext().queryClient?.refetchQueries({ type: 'active' }),\n ]);\n };\n const openOrder = (data?: unknown) => {\n const rawId = (data as { id?: unknown } | undefined)?.id;\n if (typeof rawId !== 'string' && typeof rawId !== 'number') return;\n\n const id = String(rawId).trim();\n if (!id) return;\n\n void getTwilightContext().queryClient?.invalidateQueries({ queryKey: ['cart'] });\n open(`/account/orders/${encodeURIComponent(id)}`);\n };\n const navigateTo = (data?: unknown) => {\n const url = (data as { url?: unknown } | undefined)?.url;\n if (typeof url !== 'string' || !url.trim() || !storeUrl) return;\n\n const path = deepLinkPath(url.trim(), storeUrl, username);\n if (path) void router.navigate({ href: inLocale(path, locale) });\n };\n\n const offs = [\n onSallaEvent(UI_UPDATE_EVENT, refresh),\n onSallaEvent(OPEN_ORDER_EVENT, openOrder),\n onSallaEvent(NAVIGATE_TO_EVENT, navigateTo),\n ];\n return () => offs.forEach((off) => off());\n }, [router, locale, storeUrl, username]);\n}\n\n/** A URL that names its host: `https://…` or `//…`. Anything else is a path of this app. */\nfunction isAbsoluteUrl(url: string): boolean {\n if (url.startsWith('//')) return true;\n try {\n // Without a base, only a URL with its own scheme parses.\n new URL(url);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * The application path of a deep link to this store, or null for any other link.\n *\n * It passes the test a tapped link does (`resolveRelativePath`: the store's origin, the\n * username taken off), and one more. On a shared host that origin is every store's, so\n * an absolute link has to carry this store's username: without it, another store's\n * `/ar/offers` would open this store's offers.\n */\nfunction deepLinkPath(url: string, storeUrl: string, username?: string): string | null {\n const path = resolveRelativePath(url, storeUrl, username);\n if (!path || !isAbsoluteUrl(url)) return path;\n\n // Both parse: `resolveRelativePath` returns null when either does not.\n const { pathname } = new URL(url, window.location.href);\n return hasStoreUrlBase(pathname, new URL(storeUrl).pathname, username) ? path : null;\n}\n\n/**\n * A deep link in the locale the visitor is browsing in. A notification is written in one\n * language and opened in whichever is on screen, so the link's own locale gives way.\n *\n * The prefix is written here, not by `localizeDestination`: that one leaves a path alone\n * when it already starts with a locale, and would take the slug of `/ar/en/p456` for one.\n */\nfunction inLocale(path: string, locale?: string): string {\n const first = path.split('/')[1]?.split(/[?#]/)[0];\n const own = isLocale(first) ? path.slice(first.length + 1) : path;\n const rest = own.startsWith('/') ? own : `/${own}`;\n\n if (!locale) return rest;\n return rest === '/' ? `/${locale}` : `/${locale}${rest}`;\n}\n","/**\n * What the request itself is enough to describe: its host.\n *\n * Small, and deliberately its own module rather than a helper inside the\n * middleware. This value decides two things — which store a live storefront is,\n * and whether the request is allowed to name a store at all — so it is worth\n * testing directly instead of only through the wiring that calls it.\n */\nimport { isLoopback } from './cookies';\n\n/** The part of a `Request` this needs, so a test does not have to build a whole one. */\nexport interface HostSource {\n url: string;\n headers: { get(name: string): string | null };\n}\n\n/**\n * The host this request arrived on, with its port when it has one.\n *\n * Taken from the request URL, which in a Worker is the address the platform\n * actually routed on, and from the `Host` header only when that fails.\n *\n * **`X-Forwarded-Host` is deliberately not consulted.** A client can set it, and\n * this value gates `allowsRequestStoreId` — so honouring it would be a way to\n * talk a merchant's own domain into behaving like the preview host, and from\n * there into serving a stranger's shop. The dispatcher strips that header today;\n * a theme must not be one edit to another repository's allowlist away from a\n * spoofable identity.\n */\nexport function requestHostOf(request: HostSource): string | null {\n try {\n const fromUrl = new URL(request.url).host;\n if (fromUrl) return fromUrl;\n } catch {\n /* an unparseable URL falls through to the header */\n }\n\n return request.headers.get('Host')?.trim() || null;\n}\n\n/** The origin a browser reached this host on: `http` for a dev server, `https` otherwise. */\nexport function requestOriginOf(host: string): string {\n return `${isLoopback(host.replace(/:\\d+$/, '')) ? 'http' : 'https'}://${host}`;\n}\n","import {\n useNavigate,\n useParams,\n redirect as tanstackRedirect,\n notFound as tanstackNotFound,\n} from '@tanstack/react-router';\nimport {\n NavigationProvider,\n configureNavigation,\n type NavigateOptions,\n} from '../providers/NavigationProvider';\nimport { LinkProvider } from '../providers/LinkProvider';\nimport { TanStackLinkAdapter, localizeDestination } from './link';\nimport { NativeAppEvents } from './native-app-events';\nimport { useCallback, type ReactNode } from 'react';\nimport { UnauthorizedError, type RedirectOptions } from '../providers/NavigationProvider';\nimport { getRequestStore, getTwilightContext } from '../twilight/context';\nimport { resolveStoreBase, resolveStoreBaseFollowsLocale } from '../utils/store-identity';\nimport { loginRedirectHref } from '../utils/store-base';\nimport { requestOriginOf } from '../utils/request-host';\n\n/**\n * Where a document redirect (`reloadDocument`) may go: an http(s) URL, or a path on this host. A\n * protocol-relative `//host` or any other scheme is refused here, as an error the caller made:\n * the router throws on those too, and a page that cannot redirect safely must not try.\n */\nexport function documentRedirectHref(target: string): string {\n if (target.startsWith('/') && !target.startsWith('//')) return target;\n const url = new URL(target);\n if (url.protocol !== 'http:' && url.protocol !== 'https:') {\n throw new Error(`A document redirect needs an http(s) URL, not ${url.protocol}`);\n }\n return url.href;\n}\n\nfunction currentOrigin(): string | null {\n if (typeof window !== 'undefined') return window.location.origin;\n const host = getRequestStore().requestHost;\n return host ? requestOriginOf(host) : null;\n}\n\nconfigureNavigation({\n notFound: (message?: string) => {\n throw tanstackNotFound({ data: message });\n },\n redirect: (path: string, opts?: RedirectOptions) => {\n if (opts?.reloadDocument) {\n // `href`, not `to`: the router neither matches it nor adds the store base to it.\n const href = documentRedirectHref(path);\n throw tanstackRedirect({\n href,\n reloadDocument: true,\n replace: opts.replace,\n statusCode: opts.statusCode,\n });\n }\n throw tanstackRedirect({ to: path, replace: opts?.replace, statusCode: opts?.statusCode });\n },\n unauthorized: (message?: string) => {\n const origin = currentOrigin();\n const { pathname, searchStr } = getTwilightContext().location;\n const href =\n origin &&\n loginRedirectHref({\n pathname,\n searchStr,\n origin,\n base: resolveStoreBase(),\n baseFollowsLocale: resolveStoreBaseFollowsLocale(),\n });\n // A full load, because the SDK only reads `intended_to` when a page starts.\n if (href) throw tanstackRedirect({ href, reloadDocument: true, replace: true });\n throw new UnauthorizedError(message);\n },\n});\n\n/**\n * TanStack navigation setup - wraps children with NavigationProvider and LinkProvider.\n * Called by TwilightProvider when client.framework === 'tanstack'.\n */\nexport function NavigationSetup({ children }: { children: ReactNode }) {\n const navigate = useNavigate();\n const { locale } = useParams({ strict: false }) as { locale?: string };\n const navigateFn = useCallback(\n (to: string, opts?: NavigateOptions) =>\n navigate({ to: localizeDestination(to, locale), replace: opts?.replace }),\n [navigate, locale]\n );\n\n return (\n <NavigationProvider navigate={navigateFn}>\n <NativeAppEvents locale={locale} />\n <LinkProvider adapter={TanStackLinkAdapter}>{children}</LinkProvider>\n </NavigationProvider>\n );\n}\n\n/** @deprecated Use NavigationSetup instead */\nexport function TanStackNavigationProvider({ children }: { children: ReactNode }) {\n const navigate = useNavigate();\n return (\n <NavigationProvider\n navigate={(to: string, opts?: NavigateOptions) => navigate({ to, replace: opts?.replace })}\n >\n <LinkProvider adapter={TanStackLinkAdapter}>{children}</LinkProvider>\n </NavigationProvider>\n );\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import { RouteId } from './chunk-OUW6WESU.js';
2
- import { getActiveCurrency } from './chunk-S6EGQM36.js';
2
+ import { getActiveCurrency } from './chunk-CBLSUXTP.js';
3
3
 
4
4
  // src/lib/analytics/gtm.ts
5
5
  function gtmEnabled(settings) {
@@ -301,5 +301,5 @@ function servicesInitEvents(externalServices, snippetServices) {
301
301
  }
302
302
 
303
303
  export { DATA_LAYER_PROXY_SCRIPT, gtmCartCheckout, gtmCustomer, gtmDetail, gtmEnabled, gtmImpressions, gtmPage, gtmPurchase, gtmStore, pushToDataLayer, servicesInitEvents };
304
- //# sourceMappingURL=chunk-F5CBGBXC.js.map
305
- //# sourceMappingURL=chunk-F5CBGBXC.js.map
304
+ //# sourceMappingURL=chunk-3LSW57HE.js.map
305
+ //# sourceMappingURL=chunk-3LSW57HE.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/lib/analytics/gtm.ts"],"names":[],"mappings":";;;;AAoBO,SAAS,WAAW,QAAA,EAA6C;AACtE,EAAA,OAAO,QAAQ,QAAA,EAAU,KAAA,EAAO,QAAA,EAAU,IAAA,EAAM,KAAK,MAAM,CAAA;AAC7D;AAEO,SAAS,gBAAgB,KAAA,EAA6B;AAC3D,EAAA,IAAI,OAAO,WAAW,WAAA,EAAa;AACnC,EAAA,MAAA,CAAO,SAAA,GAAY,MAAA,CAAO,SAAA,IAAa,EAAC;AACxC,EAAA,MAAA,CAAO,SAAA,CAAU,KAAK,KAAK,CAAA;AAC7B;AAOO,IAAM,uBAAA,GAA0B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA,CAerC,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K,IAAI,IAAI,CAAC,CAAA;AACvD,IAAA,IAAI,CAAC,OAAA,IAAW,eAAA,CAAgB,GAAA,CAAI,OAAO,GAAG,OAAO,KAAA;AACrD,IAAA,OAAO,CAAC,QAAA,CAAS,GAAA,CAAI,OAAO,CAAA,IAAK,0BAAA,CAA2B,IAAI,OAAO,CAAA;AAAA,EACzE,CAAC,CAAA;AACH","file":"chunk-F5CBGBXC.js","sourcesContent":["/**\n * The data a Twig storefront hands Google Tag Manager, built in the browser.\n *\n * On Twig the Store writes it on the server (the `Salla\\GoogleTags` package): each page opens\n * with one `dataLayer.push` naming the page, the store and the customer, plus the page's own\n * ecommerce block (a product's `detail`, the cart's `checkout`, an order's `purchase`). Salla's\n * container and the merchants' own containers read these exact keys, so every builder here\n * copies a PHP one, named beside it. A list's `impressions` copies `<salla-products-list>`\n * instead, which pushes them itself on Twig.\n */\nimport type { Cart, CartItem, Money, Product, User } from '../../types';\nimport type { Order, OrderItem } from '../../routes/account/types';\nimport type { StoreContext } from '../../api/store';\nimport type { PageContext } from '../../twilight/context';\nimport { getActiveCurrency } from '../../api/client';\nimport { RouteId } from '../../router/route-ids';\n\nexport type DataLayerEntry = Record<string, unknown>;\n\n/** True when the store loads a Tag Manager container; without one nothing reads the data layer. */\nexport function gtmEnabled(settings: StoreContext | undefined): boolean {\n return Boolean(settings?.store?.settings?.keys?.gtm?.length);\n}\n\nexport function pushToDataLayer(entry: DataLayerEntry): void {\n if (typeof window === 'undefined') return;\n window.dataLayer = window.dataLayer ?? [];\n window.dataLayer.push(entry);\n}\n\n/**\n * Twig's `dataLayer` proxy (`googletagmanager::head`): it drops request, payment and form\n * fields from every object pushed after it. The root head runs it before anything is pushed;\n * GTM's own script runs it too, for a theme that loads GTM by hand. Once per page.\n */\nexport const DATA_LAYER_PROXY_SCRIPT = `\nwindow.dataLayer = window.dataLayer || [];\nif (!window.__sallaDataLayerProxy) {\n window.__sallaDataLayerProxy = true;\n window.dataLayer = new Proxy(window.dataLayer, {\n set(target, property, value) {\n target[property] = value;\n if (typeof value === 'object') {\n ['form_data', 'data', 'gateway', 'config', 'request', 'headers']\n .forEach(function(key) { value && value.hasOwnProperty(key) && delete value[key]; });\n }\n return true;\n }\n });\n}\n`.trim();\n\n// ─── page ────────────────────────────────────────────────────────────────────\n\n/**\n * `page.pageName`: the Laravel route that renders the page on Twig, camel-cased without\n * `store` (`RequestResolver::getPageName`). The containers compare it: `productShow`,\n * `catShow`, `cartShow`, `search`, `brandsShow`, `thankyou`.\n */\nconst PAGE_NAMES: Record<string, string> = {\n [RouteId.INDEX]: 'home', // store.home\n [RouteId.PRODUCT_SINGLE]: 'productShow', // product.showWithSlug → product.show\n [RouteId.PRODUCT_INDEX]: 'catShow', // cat.showWithSlug → cat.show\n [RouteId.SEARCH]: 'search', // store.search\n [RouteId.PRODUCT_INDEX_LATEST]: 'latestProducts', // store.latest-products\n [RouteId.PRODUCT_INDEX_OFFERS]: 'productOffers', // product.offers\n [RouteId.BRANDS_INDEX]: 'brands', // store.brands\n [RouteId.BRANDS_SINGLE]: 'brandsShow', // store.brands.show\n [RouteId.CART]: 'cartShow', // cart.show\n [RouteId.THANK_YOU]: 'thankyou', // store.thankyou\n [RouteId.BLOG_INDEX]: 'blogIndex', // blog.index\n [RouteId.BLOG_SINGLE]: 'articlesShow', // articles.show\n [RouteId.BLOG_INDEX_CATEGORY]: 'articlesCategoryShow', // articles.category.show\n [RouteId.BLOG_INDEX_TAG]: 'articlesTagShow', // articles.tag.show\n [RouteId.PAGE_SINGLE]: 'pagesSlugShow', // pages.slug.show\n [RouteId.CUSTOMER_PROFILE]: 'userIndex', // user.index\n [RouteId.CUSTOMER_ORDERS_INDEX]: 'myorders', // store.myorders\n [RouteId.CUSTOMER_ORDERS_INDEX_PENDING]: 'myPendingOrders', // store.my_pending_orders\n [RouteId.CUSTOMER_ORDERS_SINGLE]: 'myOrder', // store.my_order\n [RouteId.CUSTOMER_WISHLIST]: 'myWishes', // store.my_wishes\n [RouteId.CUSTOMER_NOTIFICATIONS]: 'userNotificationsIndex', // user.notifications.index\n [RouteId.CUSTOMER_WALLET]: 'wallet', // wallet\n [RouteId.CUSTOMER_LOYALTY_POINTS]: 'customerLoyaltyPoints', // customer.loyalty_points\n [RouteId.LOYALTY]: 'loyaltyProgram', // store.loyalty_program\n [RouteId.TESTIMONIALS]: 'reviewsIndex', // store.reviews.index\n};\n\n/** A page with no known Twig route is named after its slug, camel-cased the same way. */\nexport function gtmPageName(slug: string): string {\n return (\n PAGE_NAMES[slug] ??\n slug.replace(/[._-]+([a-z0-9])/gi, (_, letter: string) => letter.toUpperCase())\n );\n}\n\n/** A fresh 40-hex id, as Twig's `sha1(… now()->timestamp)` gives each page and event one. */\nexport function gtmEventId(): string {\n const bytes = new Uint8Array(20);\n globalThis.crypto.getRandomValues(bytes);\n return Array.from(bytes, (byte) => byte.toString(16).padStart(2, '0')).join('');\n}\n\n/** `config('theme.name')`: a number on Salla's themes. */\nfunction themeName(settings: StoreContext | undefined): string | number | undefined {\n const name = settings?.theme?.name;\n return name && /^\\d+$/.test(name) ? Number(name) : name;\n}\n\nexport interface GtmPageInput {\n slug: string;\n referrer: string;\n /** Inside the Salla app's webview (`mobileAgent()->is()`). */\n mobileApp: boolean;\n}\n\n/** `RequestResolver::getData`. */\nexport function gtmPage(input: GtmPageInput, settings: StoreContext | undefined): DataLayerEntry {\n return {\n fingerprint: gtmEventId(),\n pageName: gtmPageName(input.slug),\n mobileApp: input.mobileApp ? 1 : 0,\n referrer: input.referrer,\n theme: themeName(settings),\n };\n}\n\n/**\n * `StoreResolver::getData`. The settings API sends none of the legacy built-in pixel ids\n * (`facebook_pixel_id`, …), so they are null, as Twig sends them for a store that set none.\n */\nexport function gtmStore(settings: StoreContext | undefined): DataLayerEntry {\n return {\n store: settings?.store?.username ?? '',\n facebook_pixel_id: null,\n google_analytics_id: null,\n snapchat_pixel_id: null,\n };\n}\n\n// ─── customer ────────────────────────────────────────────────────────────────\n\nasync function sha256(value: string): Promise<string | null> {\n const subtle = globalThis.crypto?.subtle;\n if (!subtle) return null;\n const digest = await subtle.digest('SHA-256', new TextEncoder().encode(value));\n return Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, '0')).join('');\n}\n\n/** Lower-cased, no whitespace, and only a valid address (Twig: `FILTER_VALIDATE_EMAIL`). */\nfunction cleanEmail(email: string | undefined): string | null {\n const clean = email?.replace(/\\s+/g, '').toLowerCase();\n return clean && /^[^@]+@[^@]+\\.[^@]+$/.test(clean) ? clean : null;\n}\n\n/** E.164 without the plus (`966501234567`), as `fullMobileFormat(false)`; null when it isn't one. */\nfunction cleanPhone(mobile: string | undefined): string | null {\n const compact = mobile?.replace(/[\\s()-]+/g, '') ?? '';\n const digits = compact.startsWith('+')\n ? compact.slice(1)\n : compact.startsWith('00')\n ? compact.slice(2)\n : compact;\n return /^[1-9]\\d{7,14}$/.test(digits) ? digits : null;\n}\n\n/** `Store\\CustomerResolver::getData`: a guest is `{ isGuest: true }`. */\nexport async function gtmCustomer(\n user: User | null | undefined,\n settings: StoreContext | undefined\n): Promise<DataLayerEntry> {\n if (!user) return { isGuest: true };\n const email = cleanEmail(user.email);\n const phone = cleanPhone(user.mobile);\n const phoneWithPlus = phone ? `+${phone}` : null;\n const [firstName, lastName, emailHashed, phoneHashed, phoneWithPlusHashed] = await Promise.all([\n sha256(user.first_name ?? ''),\n sha256(user.last_name ?? ''),\n email ? sha256(email) : null,\n phone ? sha256(phone) : null,\n phoneWithPlus ? sha256(phoneWithPlus) : null,\n ]);\n return {\n isGuest: false,\n name: [user.first_name, user.last_name].filter(Boolean).join(' '),\n first_name: firstName,\n last_name: lastName,\n created_at: user.created_at ?? Math.floor(Date.now() / 1000),\n email,\n phone,\n phone_with_plus: phoneWithPlus,\n phone_with_plus_hashed: phoneWithPlusHashed,\n currency: user.preferences?.currency_code ?? settings?.user?.currency_code ?? 'SAR',\n email_hashed: emailHashed,\n phone_hashed: phoneHashed,\n };\n}\n\n// ─── money ───────────────────────────────────────────────────────────────────\n\nconst amountOf = (value: number | string | Money | null | undefined): number =>\n value && typeof value === 'object' ? Number(value.amount) || 0 : Number(value) || 0;\n\n/**\n * The currency prices are shown in: the visitor's choice, else the market's own (settings\n * `user.currency_code`; `OMR` on an Omani market of a Saudi store), as `currency()` on Twig.\n */\nexport function gtmCurrency(settings: StoreContext | undefined, fallback?: string): string {\n return getActiveCurrency() ?? fallback ?? settings?.user?.currency_code ?? 'SAR';\n}\n\n/**\n * `getGoogleTagManagerExchangeRate`: riyals per unit of `code`, as moneyphp prints a ratio.\n * Settings give each currency's `amount` per riyal.\n */\nexport function gtmExchangeRate(code: string, settings: StoreContext | undefined): string {\n const perRiyal = Number(settings?.currencies?.[code]?.amount);\n if (code === 'SAR' || !(perRiyal > 0)) return '1';\n return String(Number((1 / perRiyal).toPrecision(14)));\n}\n\n// ─── ecommerce ───────────────────────────────────────────────────────────────\n\nexport interface GtmProduct {\n id: number | string;\n name: string;\n categories: Array<{ id?: number | string; name: string }>;\n category: string;\n price: number;\n quantity: number;\n variant: string | null;\n brand: string;\n image: string;\n}\n\n/** `IsTaggingProduct::getGoogleTagManagerData`. */\nexport function gtmProduct(product: Product): GtmProduct {\n const categories = product.category\n ? [{ id: product.category.id, name: product.category.name }]\n : [];\n return {\n id: product.id,\n name: product.name,\n categories,\n category: categories.map((category) => category.name).join('/'),\n price: amountOf(product.price),\n quantity: 1,\n variant: '',\n brand: product.brand?.name ?? '',\n image: product.image?.url ?? '',\n };\n}\n\n/** `GoogleTagManager::detail`, which the product page pushes with its page data. */\nexport function gtmDetail(product: Product, settings: StoreContext | undefined): DataLayerEntry {\n const currencyCode = gtmCurrency(settings, product.currency);\n return {\n event: 'detail',\n ecommerce: {\n currencyCode,\n exchangeRate: gtmExchangeRate(currencyCode, settings),\n event_id: gtmEventId(),\n detail: { products: [gtmProduct(product)] },\n },\n };\n}\n\n/** `CartItem::getGoogleTagManagerData`: the cart line's taxed total as its price. */\nfunction gtmCartItem(item: CartItem, currency: string): DataLayerEntry {\n return {\n id: item.product_id,\n name: item.product_name,\n categories: [],\n category: '',\n price: amountOf(item.total),\n quantity: item.quantity,\n variant: null,\n brand: '',\n image: item.product_image ?? '',\n cart_item_id: item.id,\n currency,\n };\n}\n\n/**\n * `GoogleTagManager::checkout`, from the cart page's `SeoCartWidget` (step 1). It sets no\n * `event`: on Twig it rides on the page's own push. Only the available lines, and no order\n * options, as `getAvailableItems()` and the macro leave them out.\n */\nexport function gtmCartCheckout(\n cart: Cart,\n settings: StoreContext | undefined,\n step = 1\n): DataLayerEntry {\n const currencyCode = gtmCurrency(settings);\n const total = amountOf(cart.total);\n return {\n ecommerce: {\n currencyCode,\n exchangeRate: gtmExchangeRate(currencyCode, settings),\n event_id: gtmEventId(),\n checkout: {\n actionField: {\n id: cart.id,\n total,\n revenue: total,\n currency_code: currencyCode,\n step,\n },\n products: cart.items\n .filter((item) => item.is_available !== false && String(item.type) !== 'order_option')\n .map((item) => gtmCartItem(item, currencyCode)),\n },\n },\n };\n}\n\n/** `OrderItems::getGoogleTagManagerData`: the line before its discount, tax included. */\nfunction gtmOrderItem(item: OrderItem, currency: string): DataLayerEntry | null {\n const productId = item.product_id ?? item.product?.id;\n if (productId == null) return null;\n\n const discount = item.amounts?.total_discount ?? item.amounts?.discount;\n return {\n id: productId,\n name: item.name,\n categories: [],\n category: '',\n price: amountOf(item.amounts?.total) + amountOf(discount),\n quantity: item.quantity,\n variant: null,\n brand: '',\n image: item.thumbnail ?? item.product_thumbnail ?? item.image ?? '',\n currency,\n };\n}\n\n/** `GoogleTagManager::purchase`, from the thank-you page's `SeoThankYouWidget`. */\nexport function gtmPurchase(order: Order, settings: StoreContext | undefined): DataLayerEntry {\n const currencyCode = order.currency || gtmCurrency(settings);\n const total = amountOf(order.amounts?.total);\n const grandTotal = order.amounts?.total?.amount;\n const useGtmSubtotal = settings?.store?.settings?.gtm_order_completed === true;\n return {\n event: 'purchase',\n // Salla's GTM container reads 0.subtotal. Null clears any previous order's value.\n 0: { subtotal: useGtmSubtotal && Number.isFinite(grandTotal) ? grandTotal : null },\n ecommerce: {\n currencyCode,\n exchangeRate: gtmExchangeRate(currencyCode, settings),\n event_id: order.id,\n purchase: {\n actionField: {\n id: order.id,\n total,\n revenue: total,\n currency_code: currencyCode,\n step: null,\n },\n products: (order.items ?? [])\n .map((item) => gtmOrderItem(item, currencyCode))\n .filter((item): item is DataLayerEntry => item !== null),\n },\n },\n };\n}\n\n/**\n * The `impressions` `<salla-products-list>` pushes for each page of products it fetches\n * (`appendDataLayer`), with the page's title and id where a product names no category.\n */\nexport function gtmImpressions(\n products: Product[],\n page: PageContext | undefined,\n settings: StoreContext | undefined\n): DataLayerEntry {\n return {\n event: 'impressions',\n ecommerce: {\n currencyCode: gtmCurrency(settings),\n impressions: products.map((product, index) => {\n const category = product.category?.name || page?.title;\n return {\n id: product.id,\n name: product.name,\n price: amountOf(product.price),\n brand: product.brand?.name || '',\n quantity: product.quantity,\n categories: [{ name: category, id: page?.id }],\n category,\n position: index + 1,\n };\n }),\n },\n };\n}\n\n// ─── services ────────────────────────────────────────────────────────────────\n\n/** Services Twig renders itself rather than announcing (`ExternalServicesWidget::$serviceWidgets`). */\nconst WIDGET_SERVICES = new Set([\n 'google_tags_manager',\n 'mailchimp',\n 'addon-mailchimp-marketing',\n 'klaviyo',\n]);\n\n/** Apps with a snippet that Twig still announces (`ExternalServicesWidget::$serviceTracking`). */\nconst ANNOUNCED_SNIPPET_SERVICES = new Set(['facebook_pixel', 'tiktok_pixel', 'google_analytics']);\n\n/**\n * The `services::<name>.init` events a Twig page dispatches through the SDK, which copies each\n * into the data layer, where Salla's container loads GA4, Google Ads, Clarity and the pixels\n * from them. The settings API lists every active service; Twig leaves out the ones it renders\n * as a widget and the apps whose snippet the page loads instead.\n */\nexport function servicesInitEvents(\n externalServices: StoreContext['external_services'],\n snippetServices: Iterable<string>\n): Array<[name: string, payload: unknown]> {\n const snippets = new Set(snippetServices);\n return Object.entries(externalServices ?? {}).filter(([name]) => {\n const service = /^services::(.+)\\.init$/.exec(name)?.[1];\n if (!service || WIDGET_SERVICES.has(service)) return false;\n return !snippets.has(service) || ANNOUNCED_SNIPPET_SERVICES.has(service);\n });\n}\n"]}
1
+ {"version":3,"sources":["../src/lib/analytics/gtm.ts"],"names":[],"mappings":";;;;AAoBO,SAAS,WAAW,QAAA,EAA6C;AACtE,EAAA,OAAO,QAAQ,QAAA,EAAU,KAAA,EAAO,QAAA,EAAU,IAAA,EAAM,KAAK,MAAM,CAAA;AAC7D;AAEO,SAAS,gBAAgB,KAAA,EAA6B;AAC3D,EAAA,IAAI,OAAO,WAAW,WAAA,EAAa;AACnC,EAAA,MAAA,CAAO,SAAA,GAAY,MAAA,CAAO,SAAA,IAAa,EAAC;AACxC,EAAA,MAAA,CAAO,SAAA,CAAU,KAAK,KAAK,CAAA;AAC7B;AAOO,IAAM,uBAAA,GAA0B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA,CAerC,IAAA;AASF,IAAM,UAAA,GAAqC;AAAA,EACzC,CAAC,OAAA,CAAQ,KAAK,GAAG,MAAA;AAAA;AAAA,EACjB,CAAC,OAAA,CAAQ,cAAc,GAAG,aAAA;AAAA;AAAA,EAC1B,CAAC,OAAA,CAAQ,aAAa,GAAG,SAAA;AAAA;AAAA,EACzB,CAAC,OAAA,CAAQ,MAAM,GAAG,QAAA;AAAA;AAAA,EAClB,CAAC,OAAA,CAAQ,oBAAoB,GAAG,gBAAA;AAAA;AAAA,EAChC,CAAC,OAAA,CAAQ,oBAAoB,GAAG,eAAA;AAAA;AAAA,EAChC,CAAC,OAAA,CAAQ,YAAY,GAAG,QAAA;AAAA;AAAA,EACxB,CAAC,OAAA,CAAQ,aAAa,GAAG,YAAA;AAAA;AAAA,EACzB,CAAC,OAAA,CAAQ,IAAI,GAAG,UAAA;AAAA;AAAA,EAChB,CAAC,OAAA,CAAQ,SAAS,GAAG,U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,CAAC,EAAE,IAAA,EAAM,UAAU,EAAA,EAAI,IAAA,EAAM,IAAI,CAAA;AAAA,UAC7C,QAAA;AAAA,UACA,UAAU,KAAA,GAAQ;AAAA,SACpB;AAAA,MACF,CAAC;AAAA;AACH,GACF;AACF;AAKA,IAAM,eAAA,uBAAsB,GAAA,CAAI;AAAA,EAC9B,qBAAA;AAAA,EACA,WAAA;AAAA,EACA,2BAAA;AAAA,EACA;AACF,CAAC,CAAA;AAGD,IAAM,6CAA6B,IAAI,GAAA,CAAI,CAAC,gBAAA,EAAkB,cAAA,EAAgB,kBAAkB,CAAC,CAAA;AAQ1F,SAAS,kBAAA,CACd,kBACA,eAAA,EACyC;AACzC,EAAA,MAAM,QAAA,GAAW,IAAI,GAAA,CAAI,eAAe,CAAA;AACxC,EAAA,OAAO,MAAA,CAAO,OAAA,CAAQ,gBAAA,IAAoB,EAAE,EAAE,MAAA,CAAO,CAAC,CAAC,IAAI,CAAA,KAAM;AAC/D,IAAA,MAAM,OAAA,GAAU,wBAAA,CAAyB,IAAA,CAAK,IAAI,IAAI,CAAC,CAAA;AACvD,IAAA,IAAI,CAAC,OAAA,IAAW,eAAA,CAAgB,GAAA,CAAI,OAAO,GAAG,OAAO,KAAA;AACrD,IAAA,OAAO,CAAC,QAAA,CAAS,GAAA,CAAI,OAAO,CAAA,IAAK,0BAAA,CAA2B,IAAI,OAAO,CAAA;AAAA,EACzE,CAAC,CAAA;AACH","file":"chunk-3LSW57HE.js","sourcesContent":["/**\n * The data a Twig storefront hands Google Tag Manager, built in the browser.\n *\n * On Twig the Store writes it on the server (the `Salla\\GoogleTags` package): each page opens\n * with one `dataLayer.push` naming the page, the store and the customer, plus the page's own\n * ecommerce block (a product's `detail`, the cart's `checkout`, an order's `purchase`). Salla's\n * container and the merchants' own containers read these exact keys, so every builder here\n * copies a PHP one, named beside it. A list's `impressions` copies `<salla-products-list>`\n * instead, which pushes them itself on Twig.\n */\nimport type { Cart, CartItem, Money, Product, User } from '../../types';\nimport type { Order, OrderItem } from '../../routes/account/types';\nimport type { StoreContext } from '../../api/store';\nimport type { PageContext } from '../../twilight/context';\nimport { getActiveCurrency } from '../../api/client';\nimport { RouteId } from '../../router/route-ids';\n\nexport type DataLayerEntry = Record<string, unknown>;\n\n/** True when the store loads a Tag Manager container; without one nothing reads the data layer. */\nexport function gtmEnabled(settings: StoreContext | undefined): boolean {\n return Boolean(settings?.store?.settings?.keys?.gtm?.length);\n}\n\nexport function pushToDataLayer(entry: DataLayerEntry): void {\n if (typeof window === 'undefined') return;\n window.dataLayer = window.dataLayer ?? [];\n window.dataLayer.push(entry);\n}\n\n/**\n * Twig's `dataLayer` proxy (`googletagmanager::head`): it drops request, payment and form\n * fields from every object pushed after it. The root head runs it before anything is pushed;\n * GTM's own script runs it too, for a theme that loads GTM by hand. Once per page.\n */\nexport const DATA_LAYER_PROXY_SCRIPT = `\nwindow.dataLayer = window.dataLayer || [];\nif (!window.__sallaDataLayerProxy) {\n window.__sallaDataLayerProxy = true;\n window.dataLayer = new Proxy(window.dataLayer, {\n set(target, property, value) {\n target[property] = value;\n if (typeof value === 'object') {\n ['form_data', 'data', 'gateway', 'config', 'request', 'headers']\n .forEach(function(key) { value && value.hasOwnProperty(key) && delete value[key]; });\n }\n return true;\n }\n });\n}\n`.trim();\n\n// ─── page ────────────────────────────────────────────────────────────────────\n\n/**\n * `page.pageName`: the Laravel route that renders the page on Twig, camel-cased without\n * `store` (`RequestResolver::getPageName`). The containers compare it: `productShow`,\n * `catShow`, `cartShow`, `search`, `brandsShow`, `thankyou`.\n */\nconst PAGE_NAMES: Record<string, string> = {\n [RouteId.INDEX]: 'home', // store.home\n [RouteId.PRODUCT_SINGLE]: 'productShow', // product.showWithSlug → product.show\n [RouteId.PRODUCT_INDEX]: 'catShow', // cat.showWithSlug → cat.show\n [RouteId.SEARCH]: 'search', // store.search\n [RouteId.PRODUCT_INDEX_LATEST]: 'latestProducts', // store.latest-products\n [RouteId.PRODUCT_INDEX_OFFERS]: 'productOffers', // product.offers\n [RouteId.BRANDS_INDEX]: 'brands', // store.brands\n [RouteId.BRANDS_SINGLE]: 'brandsShow', // store.brands.show\n [RouteId.CART]: 'cartShow', // cart.show\n [RouteId.THANK_YOU]: 'thankyou', // store.thankyou\n [RouteId.BLOG_INDEX]: 'blogIndex', // blog.index\n [RouteId.BLOG_SINGLE]: 'articlesShow', // articles.show\n [RouteId.BLOG_INDEX_CATEGORY]: 'articlesCategoryShow', // articles.category.show\n [RouteId.BLOG_INDEX_TAG]: 'articlesTagShow', // articles.tag.show\n [RouteId.PAGE_SINGLE]: 'pagesSlugShow', // pages.slug.show\n [RouteId.CUSTOMER_PROFILE]: 'userIndex', // user.index\n [RouteId.CUSTOMER_ORDERS_INDEX]: 'myorders', // store.myorders\n [RouteId.CUSTOMER_ORDERS_INDEX_PENDING]: 'myPendingOrders', // store.my_pending_orders\n [RouteId.CUSTOMER_ORDERS_SINGLE]: 'myOrder', // store.my_order\n [RouteId.CUSTOMER_WISHLIST]: 'myWishes', // store.my_wishes\n [RouteId.CUSTOMER_NOTIFICATIONS]: 'userNotificationsIndex', // user.notifications.index\n [RouteId.CUSTOMER_WALLET]: 'wallet', // wallet\n [RouteId.CUSTOMER_LOYALTY_POINTS]: 'customerLoyaltyPoints', // customer.loyalty_points\n [RouteId.LOYALTY]: 'loyaltyProgram', // store.loyalty_program\n [RouteId.TESTIMONIALS]: 'reviewsIndex', // store.reviews.index\n};\n\n/** A page with no known Twig route is named after its slug, camel-cased the same way. */\nexport function gtmPageName(slug: string): string {\n return (\n PAGE_NAMES[slug] ??\n slug.replace(/[._-]+([a-z0-9])/gi, (_, letter: string) => letter.toUpperCase())\n );\n}\n\n/** A fresh 40-hex id, as Twig's `sha1(… now()->timestamp)` gives each page and event one. */\nexport function gtmEventId(): string {\n const bytes = new Uint8Array(20);\n globalThis.crypto.getRandomValues(bytes);\n return Array.from(bytes, (byte) => byte.toString(16).padStart(2, '0')).join('');\n}\n\n/** `config('theme.name')`: a number on Salla's themes. */\nfunction themeName(settings: StoreContext | undefined): string | number | undefined {\n const name = settings?.theme?.name;\n return name && /^\\d+$/.test(name) ? Number(name) : name;\n}\n\nexport interface GtmPageInput {\n slug: string;\n referrer: string;\n /** Inside the Salla app's webview (`mobileAgent()->is()`). */\n mobileApp: boolean;\n}\n\n/** `RequestResolver::getData`. */\nexport function gtmPage(input: GtmPageInput, settings: StoreContext | undefined): DataLayerEntry {\n return {\n fingerprint: gtmEventId(),\n pageName: gtmPageName(input.slug),\n mobileApp: input.mobileApp ? 1 : 0,\n referrer: input.referrer,\n theme: themeName(settings),\n };\n}\n\n/**\n * `StoreResolver::getData`. The settings API sends none of the legacy built-in pixel ids\n * (`facebook_pixel_id`, …), so they are null, as Twig sends them for a store that set none.\n */\nexport function gtmStore(settings: StoreContext | undefined): DataLayerEntry {\n return {\n store: settings?.store?.username ?? '',\n facebook_pixel_id: null,\n google_analytics_id: null,\n snapchat_pixel_id: null,\n };\n}\n\n// ─── customer ────────────────────────────────────────────────────────────────\n\nasync function sha256(value: string): Promise<string | null> {\n const subtle = globalThis.crypto?.subtle;\n if (!subtle) return null;\n const digest = await subtle.digest('SHA-256', new TextEncoder().encode(value));\n return Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, '0')).join('');\n}\n\n/** Lower-cased, no whitespace, and only a valid address (Twig: `FILTER_VALIDATE_EMAIL`). */\nfunction cleanEmail(email: string | undefined): string | null {\n const clean = email?.replace(/\\s+/g, '').toLowerCase();\n return clean && /^[^@]+@[^@]+\\.[^@]+$/.test(clean) ? clean : null;\n}\n\n/** E.164 without the plus (`966501234567`), as `fullMobileFormat(false)`; null when it isn't one. */\nfunction cleanPhone(mobile: string | undefined): string | null {\n const compact = mobile?.replace(/[\\s()-]+/g, '') ?? '';\n const digits = compact.startsWith('+')\n ? compact.slice(1)\n : compact.startsWith('00')\n ? compact.slice(2)\n : compact;\n return /^[1-9]\\d{7,14}$/.test(digits) ? digits : null;\n}\n\n/** `Store\\CustomerResolver::getData`: a guest is `{ isGuest: true }`. */\nexport async function gtmCustomer(\n user: User | null | undefined,\n settings: StoreContext | undefined\n): Promise<DataLayerEntry> {\n if (!user) return { isGuest: true };\n const email = cleanEmail(user.email);\n const phone = cleanPhone(user.mobile);\n const phoneWithPlus = phone ? `+${phone}` : null;\n const [firstName, lastName, emailHashed, phoneHashed, phoneWithPlusHashed] = await Promise.all([\n sha256(user.first_name ?? ''),\n sha256(user.last_name ?? ''),\n email ? sha256(email) : null,\n phone ? sha256(phone) : null,\n phoneWithPlus ? sha256(phoneWithPlus) : null,\n ]);\n return {\n isGuest: false,\n name: [user.first_name, user.last_name].filter(Boolean).join(' '),\n first_name: firstName,\n last_name: lastName,\n created_at: user.created_at ?? Math.floor(Date.now() / 1000),\n email,\n phone,\n phone_with_plus: phoneWithPlus,\n phone_with_plus_hashed: phoneWithPlusHashed,\n currency: user.preferences?.currency_code ?? settings?.user?.currency_code ?? 'SAR',\n email_hashed: emailHashed,\n phone_hashed: phoneHashed,\n };\n}\n\n// ─── money ───────────────────────────────────────────────────────────────────\n\nconst amountOf = (value: number | string | Money | null | undefined): number =>\n value && typeof value === 'object' ? Number(value.amount) || 0 : Number(value) || 0;\n\n/**\n * The currency prices are shown in: the visitor's choice, else the market's own (settings\n * `user.currency_code`; `OMR` on an Omani market of a Saudi store), as `currency()` on Twig.\n */\nexport function gtmCurrency(settings: StoreContext | undefined, fallback?: string): string {\n return getActiveCurrency() ?? fallback ?? settings?.user?.currency_code ?? 'SAR';\n}\n\n/**\n * `getGoogleTagManagerExchangeRate`: riyals per unit of `code`, as moneyphp prints a ratio.\n * Settings give each currency's `amount` per riyal.\n */\nexport function gtmExchangeRate(code: string, settings: StoreContext | undefined): string {\n const perRiyal = Number(settings?.currencies?.[code]?.amount);\n if (code === 'SAR' || !(perRiyal > 0)) return '1';\n return String(Number((1 / perRiyal).toPrecision(14)));\n}\n\n// ─── ecommerce ───────────────────────────────────────────────────────────────\n\nexport interface GtmProduct {\n id: number | string;\n name: string;\n categories: Array<{ id?: number | string; name: string }>;\n category: string;\n price: number;\n quantity: number;\n variant: string | null;\n brand: string;\n image: string;\n}\n\n/** `IsTaggingProduct::getGoogleTagManagerData`. */\nexport function gtmProduct(product: Product): GtmProduct {\n const categories = product.category\n ? [{ id: product.category.id, name: product.category.name }]\n : [];\n return {\n id: product.id,\n name: product.name,\n categories,\n category: categories.map((category) => category.name).join('/'),\n price: amountOf(product.price),\n quantity: 1,\n variant: '',\n brand: product.brand?.name ?? '',\n image: product.image?.url ?? '',\n };\n}\n\n/** `GoogleTagManager::detail`, which the product page pushes with its page data. */\nexport function gtmDetail(product: Product, settings: StoreContext | undefined): DataLayerEntry {\n const currencyCode = gtmCurrency(settings, product.currency);\n return {\n event: 'detail',\n ecommerce: {\n currencyCode,\n exchangeRate: gtmExchangeRate(currencyCode, settings),\n event_id: gtmEventId(),\n detail: { products: [gtmProduct(product)] },\n },\n };\n}\n\n/** `CartItem::getGoogleTagManagerData`: the cart line's taxed total as its price. */\nfunction gtmCartItem(item: CartItem, currency: string): DataLayerEntry {\n return {\n id: item.product_id,\n name: item.product_name,\n categories: [],\n category: '',\n price: amountOf(item.total),\n quantity: item.quantity,\n variant: null,\n brand: '',\n image: item.product_image ?? '',\n cart_item_id: item.id,\n currency,\n };\n}\n\n/**\n * `GoogleTagManager::checkout`, from the cart page's `SeoCartWidget` (step 1). It sets no\n * `event`: on Twig it rides on the page's own push. Only the available lines, and no order\n * options, as `getAvailableItems()` and the macro leave them out.\n */\nexport function gtmCartCheckout(\n cart: Cart,\n settings: StoreContext | undefined,\n step = 1\n): DataLayerEntry {\n const currencyCode = gtmCurrency(settings);\n const total = amountOf(cart.total);\n return {\n ecommerce: {\n currencyCode,\n exchangeRate: gtmExchangeRate(currencyCode, settings),\n event_id: gtmEventId(),\n checkout: {\n actionField: {\n id: cart.id,\n total,\n revenue: total,\n currency_code: currencyCode,\n step,\n },\n products: cart.items\n .filter((item) => item.is_available !== false && String(item.type) !== 'order_option')\n .map((item) => gtmCartItem(item, currencyCode)),\n },\n },\n };\n}\n\n/** `OrderItems::getGoogleTagManagerData`: the line before its discount, tax included. */\nfunction gtmOrderItem(item: OrderItem, currency: string): DataLayerEntry | null {\n const productId = item.product_id ?? item.product?.id;\n if (productId == null) return null;\n\n const discount = item.amounts?.total_discount ?? item.amounts?.discount;\n return {\n id: productId,\n name: item.name,\n categories: [],\n category: '',\n price: amountOf(item.amounts?.total) + amountOf(discount),\n quantity: item.quantity,\n variant: null,\n brand: '',\n image: item.thumbnail ?? item.product_thumbnail ?? item.image ?? '',\n currency,\n };\n}\n\n/** `GoogleTagManager::purchase`, from the thank-you page's `SeoThankYouWidget`. */\nexport function gtmPurchase(order: Order, settings: StoreContext | undefined): DataLayerEntry {\n const currencyCode = order.currency || gtmCurrency(settings);\n const total = amountOf(order.amounts?.total);\n const grandTotal = order.amounts?.total?.amount;\n const useGtmSubtotal = settings?.store?.settings?.gtm_order_completed === true;\n return {\n event: 'purchase',\n // Salla's GTM container reads 0.subtotal. Null clears any previous order's value.\n 0: { subtotal: useGtmSubtotal && Number.isFinite(grandTotal) ? grandTotal : null },\n ecommerce: {\n currencyCode,\n exchangeRate: gtmExchangeRate(currencyCode, settings),\n event_id: order.id,\n purchase: {\n actionField: {\n id: order.id,\n total,\n revenue: total,\n currency_code: currencyCode,\n step: null,\n },\n products: (order.items ?? [])\n .map((item) => gtmOrderItem(item, currencyCode))\n .filter((item): item is DataLayerEntry => item !== null),\n },\n },\n };\n}\n\n/**\n * The `impressions` `<salla-products-list>` pushes for each page of products it fetches\n * (`appendDataLayer`), with the page's title and id where a product names no category.\n */\nexport function gtmImpressions(\n products: Product[],\n page: PageContext | undefined,\n settings: StoreContext | undefined\n): DataLayerEntry {\n return {\n event: 'impressions',\n ecommerce: {\n currencyCode: gtmCurrency(settings),\n impressions: products.map((product, index) => {\n const category = product.category?.name || page?.title;\n return {\n id: product.id,\n name: product.name,\n price: amountOf(product.price),\n brand: product.brand?.name || '',\n quantity: product.quantity,\n categories: [{ name: category, id: page?.id }],\n category,\n position: index + 1,\n };\n }),\n },\n };\n}\n\n// ─── services ────────────────────────────────────────────────────────────────\n\n/** Services Twig renders itself rather than announcing (`ExternalServicesWidget::$serviceWidgets`). */\nconst WIDGET_SERVICES = new Set([\n 'google_tags_manager',\n 'mailchimp',\n 'addon-mailchimp-marketing',\n 'klaviyo',\n]);\n\n/** Apps with a snippet that Twig still announces (`ExternalServicesWidget::$serviceTracking`). */\nconst ANNOUNCED_SNIPPET_SERVICES = new Set(['facebook_pixel', 'tiktok_pixel', 'google_analytics']);\n\n/**\n * The `services::<name>.init` events a Twig page dispatches through the SDK, which copies each\n * into the data layer, where Salla's container loads GA4, Google Ads, Clarity and the pixels\n * from them. The settings API lists every active service; Twig leaves out the ones it renders\n * as a widget and the apps whose snippet the page loads instead.\n */\nexport function servicesInitEvents(\n externalServices: StoreContext['external_services'],\n snippetServices: Iterable<string>\n): Array<[name: string, payload: unknown]> {\n const snippets = new Set(snippetServices);\n return Object.entries(externalServices ?? {}).filter(([name]) => {\n const service = /^services::(.+)\\.init$/.exec(name)?.[1];\n if (!service || WIDGET_SERVICES.has(service)) return false;\n return !snippets.has(service) || ANNOUNCED_SNIPPET_SERVICES.has(service);\n });\n}\n"]}
@@ -1,7 +1,8 @@
1
- import { HomeComponentRenderer, ReorderProducts } from './chunk-QP7AVGLQ.js';
2
- import { home } from './chunk-SGJDENMI.js';
1
+ import { seoField } from './chunk-MHBWYHS5.js';
2
+ import { HomeComponentRenderer, ReorderProducts } from './chunk-VNX6EXCN.js';
3
+ import { home } from './chunk-XRBYWXFG.js';
3
4
  import { useLiveBlockList, reorder, useLiveBlockMoves } from './chunk-TJK4DVQM.js';
4
- import { useDevHomeBlocks } from './chunk-4D4AAOP6.js';
5
+ import { useDevHomeBlocks } from './chunk-BRX23CR2.js';
5
6
  import { storePageUrl, buildHreflangAlternates } from './chunk-EUHIN5FN.js';
6
7
  import { RouteId } from './chunk-OUW6WESU.js';
7
8
  import { HookSlot } from './chunk-XZFWBF3P.js';
@@ -107,9 +108,9 @@ function loader(_ctx) {
107
108
  function head(ctx) {
108
109
  const store = ctx.settings?.store;
109
110
  if (!store) return {};
110
- const title = store.meta?.title ?? store.name;
111
- const description = store.meta?.description ?? store.description;
112
- const keywords = store.meta?.keywords;
111
+ const title = seoField(store.meta?.title, store.name);
112
+ const description = seoField(store.meta?.description, store.description);
113
+ const keywords = seoField(store.meta?.keywords, void 0);
113
114
  const url = storePageUrl(ctx.settings, ctx.location.pathname) ?? store.url;
114
115
  return {
115
116
  title,
@@ -135,5 +136,5 @@ function head(ctx) {
135
136
  var Home = { id: RouteId.INDEX, loader, head, Component: HomePage };
136
137
 
137
138
  export { Home, HomeSkeleton, homeLoader };
138
- //# sourceMappingURL=chunk-5TECTHHK.js.map
139
- //# sourceMappingURL=chunk-5TECTHHK.js.map
139
+ //# sourceMappingURL=chunk-3MHZVWRI.js.map
140
+ //# sourceMappingURL=chunk-3MHZVWRI.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/routes/home/blockList.ts","../src/routes/home/loader.ts","../src/routes/home/HomePage.tsx","../src/routes/home/index.tsx"],"names":["HomeSkeleton","HomePage"],"mappings":";;;;;;;;;;;;;;AAGO,SAAS,UAAU,MAAA,EAA8C;AACtE,EAAA,OAAO,IAAA,CAAK,SAAA,CAAU,MAAA,CAAO,GAAA,CAAI,CAAC,KAAA,KAAU,CAAC,KAAA,CAAM,IAAA,EAAM,KAAA,CAAM,GAAA,IAAO,IAAI,CAAC,CAAC,CAAA;AAC9E;;;ACYA,eAAsB,WAAW,GAAA,EAAoD;AACnF,EAAA,MAAM,EAAE,WAAA,EAAY,GAAI,kBAAA,EAAmB;AAC3C,EAAA,MAAM,aAAa,MAAM,WAAA,CAAY,gBAAgB,IAAA,CAAK,OAAA,CAAQ,YAAY,CAAA;AAC9E,EAAA,MAAM,MAAA,GAAS,UAAA,CAAW,GAAA,CAAI,CAAC,IAAA,MAAU;AAAA,IACv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AAO;AAAA,IACL,KAAA;AAAA,IACA,WAAA;AAAA,IACA,QAAA;AAAA,IACA,SAAA,EAAW,GAAA;AAAA,IACX,SAAA,EAAW;AAAA,MACT,IAAA,EAAM,SAAA;AAAA,MACN,KAAA;AAAA,MACA,WAAA;AAAA,MACA,QAAQ,KAAA,CAAM,IAAA;AAAA,MACd;AAAA,KACF;AAAA,IACA,OAAA,EAAS;AAAA,MACP,IAAA,EAAM,qBAAA;AAAA,MACN,KAAA;AAAA,MACA,WAAA;AAAA,MACA,QAAQ,KAAA,CAAM;AAAA,KAChB;AAAA,IACA,oBAAoB,uBAAA,CAAwB,GAAA,CAAI,QAAA,EAAU,GAAA,CAAI,SAAS,QAAQ;AAAA,GACjF;AACF;AAEO,IAAM,IAAA,GAAO,EAAE,EAAA,EAAI,OAAA,CAAQ,OAAO,MAAA,EAAQ,IAAA,EAAM,WAAW,QAAA","file":"chunk-3MHZVWRI.js","sourcesContent":["import type { HomeComponentData } from '../../types';\n\n/** Paths and keys of `blocks` in order: enough to tell the store's list from one a theme built. */\nexport function blockList(blocks: readonly HomeComponentData[]): string {\n return JSON.stringify(blocks.map((block) => [block.path, block.key ?? null]));\n}\n","import { getTwilightContext } from '../../twilight/context';\nimport { home } from '../../api/home';\nimport type { HomeComponentData } from '../../types';\nimport { RouteId } from '../../router/route-ids';\nimport { blockList } from './blockList';\n\nexport interface HomeLoaderData {\n locale: string;\n components: HomeComponentData[];\n page: { slug: string };\n /**\n * The store's blocks as this loader lists them (`blockList`). A theme whose own loader\n * reshapes `components` keeps this, so the page can tell its list is no longer the store's.\n */\n storeBlocks?: string;\n}\n\nexport async function homeLoader(ctx?: { locale?: string }): Promise<HomeLoaderData> {\n const { queryClient } = getTwilightContext();\n const components = await queryClient.ensureQueryData(home.queries.components());\n const blocks = components.map((comp) => ({\n ...comp,\n path: comp.path?.replace('home.', '') || comp.path,\n }));\n return {\n locale: ctx?.locale || 'ar',\n components: blocks,\n page: { slug: RouteId.INDEX },\n storeBlocks: blockList(blocks),\n };\n}\n","import { memo, useCallback, useMemo, useState } from 'react';\nimport { useDevHomeBlocks, type DevHomeBlock } from '../../dev/dev-settings-store';\nimport { HookSlot } from '../../hooks';\nimport { HomeComponentRenderer, ReorderProducts } from '../../components/home';\nimport { reorder, useLiveBlockList, useLiveBlockMoves } from '../../components/live-editor/moves';\nimport type { HomePageProps } from './types';\nimport { blockList } from './blockList';\nimport type { HomeComponentData } from '../../types';\nimport { Pulse } from '@salla.sa/twilight-components-react';\n\nexport const HomeSkeleton = memo(function HomeSkeleton() {\n return (\n <>\n <div className=\"s-block container skeleton-block-hero\">\n <Pulse className=\"h-64 sm:h-80 rounded-md\" />\n </div>\n <div className=\"s-block container skeleton-block-products\">\n <Pulse className=\"h-10 w-48 mb-4\" />\n <div className=\"grid grid-cols-2 sm:grid-cols-4 gap-4\">\n {[1, 2, 3, 4].map((i) => (\n <Pulse key={i} className=\"h-56\" />\n ))}\n </div>\n </div>\n <div className=\"s-block container skeleton-block-products\">\n <Pulse className=\"h-10 w-48 mb-4\" />\n <div className=\"grid grid-cols-2 sm:grid-cols-4 gap-4\">\n {[1, 2, 3, 4].map((i) => (\n <Pulse key={i} className=\"h-56\" />\n ))}\n </div>\n </div>\n </>\n );\n});\n\n/** As on Twig, a home page with no blocks lists the store's latest products instead. */\nconst LATEST_PRODUCTS: HomeComponentData = { path: 'latest-products' };\n\n/** The blocks' places in the store's order: 0, 1, 2… */\nconst storeOrder = (blocks: readonly unknown[]) => Array.from(blocks, (_, at) => at);\n\n// Stable, so a redraw of a page loaded without blocks is kept.\nconst NO_BLOCKS: HomeComponentData[] = [];\n\n// Catalog id (or path) plus copy number: a block drawn in or out leaves the others' state alone.\nfunction blockKeys(blocks: ReadonlyArray<DevHomeBlock<HomeComponentData>>): string[] {\n const copies = new Map<string, number>();\n return blocks.map((block) => {\n if (block.__dev_id) return block.__dev_id;\n const name = String(block.key ?? block.path);\n const copy = copies.get(name) ?? 0;\n copies.set(name, copy + 1);\n return `${name}~${copy}`;\n });\n}\n\nexport const HomePage = memo(function HomePage({\n components = NO_BLOCKS,\n storeBlocks,\n}: HomePageProps) {\n // The design studio draws the blocks again after a save, in place of the loaded\n // ones, until the page loads its blocks anew.\n const [drawn, setDrawn] = useState<{\n source: HomeComponentData[];\n blocks: HomeComponentData[];\n } | null>(null);\n const onList = useCallback(\n (blocks: HomeComponentData[]) => setDrawn({ source: components, blocks }),\n [components]\n );\n // A list the theme's own loader built (Tania's home) is not the store's: the studio reloads it instead.\n const storeList = useMemo(\n () => storeBlocks === undefined || storeBlocks === blockList(components),\n [storeBlocks, components]\n );\n useLiveBlockList(storeList ? onList : null);\n const current = drawn?.source === components ? drawn.blocks : components;\n // Dev-mode only: the dev editor's layout replaces the store's blocks while it\n // is on. No-op passthrough in production builds.\n const renderedComponents = useDevHomeBlocks(current);\n // The theme editor's preview moves blocks in place while the editor saves the\n // order; blocks from the server (a new page, a reload) start over from theirs.\n const [moved, setMoved] = useState<{ source: HomeComponentData[]; order: number[] } | null>(null);\n const order = moved?.source === renderedComponents ? moved.order : null;\n const onMove = useCallback(\n (from: number, to: number) =>\n setMoved((prev) => ({\n source: renderedComponents,\n order: reorder(\n prev?.source === renderedComponents ? prev.order : storeOrder(renderedComponents),\n from,\n to\n ),\n })),\n [renderedComponents]\n );\n useLiveBlockMoves(onMove);\n const placed = order ?? storeOrder(renderedComponents);\n const keys = useMemo(() => blockKeys(renderedComponents), [renderedComponents]);\n\n return (\n <>\n <HookSlot name=\"home:start\" />\n <HookSlot name=\"home:content\" />\n {placed.map((at, index) => {\n // A block's key stays with it when the preview moves it, so a move keeps its state.\n return <HomeComponentRenderer key={keys[at]} data={renderedComponents[at]} index={index} />;\n })}\n {!renderedComponents.length && (\n <HomeComponentRenderer data={LATEST_PRODUCTS} index={0} editable={false} />\n )}\n <HookSlot name=\"home:end\" />\n <ReorderProducts />\n </>\n );\n});\n\nexport { HomePage as default };\n","import type { HeadDescriptor } from '../../utils/head';\nimport { buildHreflangAlternates, storePageUrl } from '../../utils/baseHead';\nimport { seoField } from '../../utils/seo-text';\nimport type { HomeLoaderData } from './loader';\nimport { homeLoader } from './loader';\nimport type { TwilightContext } from '../../twilight/context';\nimport { HomePage } from './HomePage';\nimport { RouteId } from '../../router/route-ids';\n\nexport { HomeSkeleton } from './HomePage';\nexport { registerHomeComponents, DefaultHomeComponents } from '../../components/home/register';\nexport { registerHomeComponentConfig } from '../../components/home';\nexport type { HomePageProps } from './types';\nexport type { HomeLoaderData } from './loader';\nexport type {\n HomeComponentsProps,\n AnyHomeComponent,\n HomeComponentConfig,\n} from '../../components/home';\n\nfunction loader(_ctx?: { locale?: string }): Promise<HomeLoaderData> {\n return homeLoader({ locale: _ctx?.locale });\n}\n\nfunction head(ctx: TwilightContext): HeadDescriptor {\n const store = ctx.settings?.store;\n if (!store) return {};\n\n // `seoField`, not `??`: the store's unset SEO fields arrive as \"\".\n const title = seoField(store.meta?.title, store.name);\n const description = seoField(store.meta?.description, store.description);\n const keywords = seoField(store.meta?.keywords, undefined);\n // `/ar`, like Twig, where store.url reads `/ar/`.\n const url = storePageUrl(ctx.settings, ctx.location.pathname) ?? store.url;\n\n return {\n title,\n description,\n keywords,\n canonical: url,\n openGraph: {\n type: 'website',\n title,\n description,\n images: store.logo,\n url,\n },\n twitter: {\n card: 'summary_large_image',\n title,\n description,\n images: store.logo,\n },\n alternateLanguages: buildHreflangAlternates(ctx.settings, ctx.location.pathname),\n };\n}\n\nexport const Home = { id: RouteId.INDEX, loader, head, Component: HomePage } as const;\n\nexport { homeLoader };\n"]}
@@ -1,5 +1,5 @@
1
1
  import { isNotLaunchedNotice } from './chunk-O7JTXTGP.js';
2
- import { getAuthToken, getActiveScope, api, STORE_IDENTIFIER_HEADER, devSettingsFetchedAt, rememberStoreRay } from './chunk-S6EGQM36.js';
2
+ import { getAuthToken, getActiveScope, api, STORE_IDENTIFIER_HEADER, devSettingsFetchedAt, rememberStoreRay } from './chunk-CBLSUXTP.js';
3
3
  import { requestedThemeVersionId } from './chunk-MZPX4EPS.js';
4
4
  import { LANGUAGE_COOKIE_NAME, LANGUAGE_COOKIE_MAX_AGE, AUTH_TOKEN_COOKIE_NAME, resolveStoreIdentifier, extractScopeFromUrl, parseStoreId } from './chunk-4OZIBANF.js';
5
5
  import { revokeAuthToken, getTwilightContext, SettingsError } from './chunk-MWUAHDQL.js';
@@ -273,5 +273,5 @@ var store = {
273
273
  };
274
274
 
275
275
  export { persistLanguageCookie, readCookieHeader, readNativeAppHeaders, readPageSearch, store };
276
- //# sourceMappingURL=chunk-WNWIZIM2.js.map
277
- //# sourceMappingURL=chunk-WNWIZIM2.js.map
276
+ //# sourceMappingURL=chunk-3W42UZSQ.js.map
277
+ //# sourceMappingURL=chunk-3W42UZSQ.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/utils/language-cookie.ts","../src/utils/native-app-headers.ts","../src/api/store.ts"],"names":["createIsomorphicFn","setCookie"],"mappings":";;;;;;;;;;AAaA,IAAM,sBAAA,GAAyB,kBAAA,EAAmB,CAC/C,MAAA,CAAO,MAAqB;AAC3B,EAAA,IAAI;AACF,IAAA,OAAO,gBAAA,CAAiB,QAAQ,CAAA,IAAK,IAAA;AAAA,EACvC,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,IAAA;AAAA,EACT;AACF,CAAC,CAAA,CACA,MAAA,CAAO,MAAqB,IAAI,CAAA;AAEnC,IAAM,yBAAA,GAA4B,kBAAA,EAAmB,CAClD,MAAA,CAAO,CAAC,IAAA,KAAuB;AAC9B,EAAA,IAAI;AACF,IAAA,SAAA,CAAU,sBAAsB,IAAA,EAAM;AAAA,MACpC,IAAA,EAAM,GAAA;AAAA,MACN,MAAA,EAAQ,uBAAA;AAAA,MACR,QAAA,EAAU;AAAA,KACX,CAAA;AAAA,EACH,CAAA,CAAA,MAAQ;AAAA,EAER;AACF,CAAC,CAAA,CACA,OAAO,MAAY;AAAC,CAAC,CAAA;AAExB,IAAM,gBAAA,GAAmB,kBAAA,EAAm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S,GAAI,KAAA,KAAU,KAAA,GAAQ,EAAC,GAAI,CAAC,KAAK,CAAE,CAAA;AACpF,IAAA,MAAM,KAAA;AAAA,EACR;AACF;AAEO,IAAM,KAAA,GAAQ;AAAA,EACnB,QAAA,EAAU,OAAO,eAAA,KAA2D;AAC1E,IAAA,IAAI;AACF,MAAA,OAAO,MAAM,cAAc,eAAe,CAAA;AAAA,IAC5C,CAAA,CAAA,MAAQ;AAEN,MAAA,OAAO,IAAA;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-WNWIZIM2.js","sourcesContent":["/**\n * @fileoverview Reading and writing the `s-lang` cookie, on the server and in the browser.\n *\n * The server reads it from the request the framework is handling and writes it to that\n * request's response. The server-only import is stripped from the client bundle by\n * `createIsomorphicFn`, as in `routes/root/beforeLoad.ts`. The browser uses `document.cookie`.\n * Either side outside a request (a prerender, a test) has nothing to read or write and says so\n * quietly.\n */\nimport { createIsomorphicFn } from '@tanstack/react-start';\nimport { getRequestHeader, getRequestUrl, setCookie } from '@tanstack/react-start/server';\nimport { LANGUAGE_COOKIE_MAX_AGE, LANGUAGE_COOKIE_NAME } from './cookies';\n\nconst readServerCookieHeader = createIsomorphicFn()\n .server((): string | null => {\n try {\n return getRequestHeader('cookie') ?? null;\n } catch {\n return null;\n }\n })\n .client((): string | null => null);\n\nconst writeServerLanguageCookie = createIsomorphicFn()\n .server((code: string): void => {\n try {\n setCookie(LANGUAGE_COOKIE_NAME, code, {\n path: '/',\n maxAge: LANGUAGE_COOKIE_MAX_AGE,\n sameSite: 'lax',\n });\n } catch {\n // Outside a request: there is no response to write to.\n }\n })\n .client((): void => {});\n\nconst readServerSearch = createIsomorphicFn()\n .server((): string => {\n try {\n return getRequestUrl().search;\n } catch {\n return '';\n }\n })\n .client((): string => '');\n\n/**\n * The query string of the page being rendered (`?lang=en`, or `''`): the request's on the\n * server, the address bar's in the browser, so both sides read the same one.\n */\nexport function readPageSearch(): string {\n return readServerSearch() || (typeof window !== 'undefined' ? window.location.search : '');\n}\n\n/** The `Cookie` header of the request being handled, or `document.cookie` in the browser. */\nexport function readCookieHeader(): string | null {\n return readServerCookieHeader() ?? (typeof document !== 'undefined' ? document.cookie : null);\n}\n\n/** Remembers `code` as the visitor's language for every store on this host. */\nexport function persistLanguageCookie(code: string): void {\n writeServerLanguageCookie(code);\n if (typeof document !== 'undefined') {\n document.cookie = `${LANGUAGE_COOKIE_NAME}=${encodeURIComponent(code)}; path=/; max-age=${LANGUAGE_COOKIE_MAX_AGE}; SameSite=Lax`;\n }\n}\n","/** 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 * How the app's webview names itself to the Store API. On a Twig theme Laravel hands these\n * to the SDK as request headers, which is how the API tells an app order from a website one.\n */\nexport const NATIVE_APP_REQUEST_HEADERS = ['s-source', 's-app-webview'];\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, ...NATIVE_APP_REQUEST_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 { createIsomorphicFn } from '@tanstack/react-start';\nimport { setCookie } from '@tanstack/react-start/server';\nimport { isHTTPError, isNetworkError, isTimeoutError } from 'ky';\nimport {\n api,\n getActiveScope,\n getAuthToken,\n rememberStoreRay,\n STORE_IDENTIFIER_HEADER,\n} from './client';\nimport { devSettingsFetchedAt } from './dev-settings-cache';\nimport { SettingsError } from '../utils/errors';\nimport type { Store, Theme, Language, JitsuConfig, MaintenanceDetails } from '../types';\nimport { getTwilightContext, revokeAuthToken } from '../twilight/context';\nimport { resolveStoreIdentifier } from '../utils/store-identity';\nimport { AUTH_TOKEN_COOKIE_NAME, extractScopeFromUrl, parseStoreId } from '../utils/cookies';\nimport { readPageSearch } from '../utils/language-cookie';\nimport { requestedThemeVersionId } from '../utils/theme-version';\nimport { NATIVE_APP_HEADERS } from '../utils/native-app-headers';\nimport { isNotLaunchedNotice } from '../utils/maintenance';\n\nexport { resolveStoreIdentifier };\n\n// `rating` and `ratings` are left out: nothing in the engine reads them, and the API builds them by\n// aggregating every testimonial of the store, which on large stores ran past SETTINGS_TIMEOUT_MS on\n// every render (TD-17779).\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 '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 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 /** 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 * `false` while the store has not launched yet: `maintenance` is then `true` and the\n * engine's maintenance page says the store is launching soon. Absent otherwise. Not\n * from the API: read off `maintenance_details` by `store.settings`, since the\n * backend sends the merchant's \"finish launching\" notice there for every visitor,\n * which is not for a customer's eyes.\n */\n launched?: false;\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 /** Which answer of the API these settings are; see {@link SettingsAnswer}. */\n answer?: SettingsAnswer;\n /**\n * When the dev server fetched these settings from the API (epoch ms). It reuses\n * them for a while (see `dev-settings-cache.ts`) and the theme editor says how old\n * they are. Only on a dev server render; absent everywhere else.\n */\n devFetchedAt?: number;\n}\n\n/**\n * Which answer of the settings API a set of settings came from, read off the\n * response rather than the body: the API's request id, the Store's trace, and\n * whether Cloudflare served it from its cache and how old it was. A decision the\n * settings drive for every visitor alike (the maintenance page) can then be\n * traced to the exact request the backend logged, or to a cached copy of it.\n */\nexport interface SettingsAnswer {\n requestId?: string;\n traceId?: string;\n cacheStatus?: string;\n age?: string;\n}\n\nconst ANSWER_HEADERS: Record<keyof SettingsAnswer, string> = {\n requestId: 's-request-id',\n traceId: 'x-trace-id',\n cacheStatus: 'cf-cache-status',\n age: 'age',\n};\n\nfunction settingsAnswerOf(headers: Headers | undefined): SettingsAnswer | undefined {\n if (!headers) return undefined;\n const answer: SettingsAnswer = {};\n for (const [field, name] of Object.entries(ANSWER_HEADERS) as [keyof SettingsAnswer, string][]) {\n const value = headers.get(name);\n if (value) answer[field] = value;\n }\n return Object.keys(answer).length ? answer : undefined;\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 const appHeaders = requestNativeAppHeaders();\n if (!jitsu || !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) {\n delete headers[name];\n if (appHeaders[name]) headers[name] = appHeaders[name];\n }\n return {\n ...jitsu,\n context: {\n ...jitsu.context,\n extra: { ...extra, headers },\n },\n };\n}\n\n/** The app's headers on the request being rendered; null in the browser and outside the app. */\nfunction requestNativeAppHeaders(): Record<string, string> | null {\n if (typeof window !== 'undefined') return null;\n try {\n return getTwilightContext().nativeAppHeaders;\n } catch {\n return null;\n }\n}\n\n/**\n * The settings' request headers with the app's `s-source` and `s-app-webview` in them, as\n * Laravel adds them for a Twig theme: the SDK copies `headers` onto every call it makes.\n *\n * Both or neither. `s-source: mobile` without `s-app-webview` is the native app itself to\n * the API, which then answers a guest's `cart/latest` with a new cart every time.\n */\nfunction withNativeAppRequestHeaders(\n headers?: Record<string, unknown>\n): Record<string, unknown> | undefined {\n const appHeaders = requestNativeAppHeaders();\n if (appHeaders?.['s-source'] !== 'mobile' || !appHeaders['s-app-webview']) return headers;\n return { ...headers, 's-source': 'mobile', 's-app-webview': appHeaders['s-app-webview'] };\n}\n\nconst SETTINGS_TIMEOUT_MS = 5000;\n\n/**\n * Whether the page's own address switches market (`?scope=`).\n *\n * Only then does the settings request name the scope in its query string. The API\n * reads `?scope=` as a switch and lets it override the market a market's own domain\n * is pinned to, which the `s-scope-id` header never does. Sent on every request, a\n * market remembered from another visit would win over the host the shopper is on: the\n * settings, and the SDK seeded from them, would answer for that market while every\n * call without the parameter (the cart, among them) answers for the host's, and a\n * guest's cart created in one is refused by the other (TD-17588).\n */\nfunction pageSwitchesScope(): boolean {\n return extractScopeFromUrl(`http://page.invalid/${readPageSearch()}`) !== null;\n}\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 =\n scope != null && pageSwitchesScope() ? `${includeParams}&scope=${scope.id}` : includeParams;\n\n const request = 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 const json = await request.json<{ data?: SettingsApiResponse }>();\n // The same response, already settled; only its headers are read.\n const headers = (await request)?.headers;\n const answer = settingsAnswerOf(headers);\n const devFetchedAt = devSettingsFetchedAt(headers);\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 rememberStoreRay(identifier, data.headers);\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: withNativeAppRequestHeaders(data.headers),\n login: data.login,\n affiliate: data.affiliate,\n policy_url: data.policy_url,\n user: data.user,\n jitsu: withNativeAppHeaders(data.jitsu),\n maintenance: data.maintenance,\n maintenance_details: data.maintenance_details,\n ...(data.maintenance === true &&\n isNotLaunchedNotice(data.maintenance_details) && { launched: false as const }),\n ...(scope && { requestedScopeId: scope.id }),\n ...(answer && { answer }),\n ...(devFetchedAt && { devFetchedAt }),\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 * Whether the API answered that the token was signed out of all devices. `unauthorized`\n * alone: `token_invalid` is refreshed by the SDK, and a limited token (a review link)\n * gets `policy_token_not_allowed` so that its customer stays signed in.\n */\nfunction isRevokedToken(error: unknown): boolean {\n if (!isHTTPError(error) || error.response.status !== 401) return false;\n return (error.data as { error?: { code?: unknown } } | undefined)?.error?.code === 'unauthorized';\n}\n\n/**\n * Drops a token the API answered as signed out everywhere (401 `unauthorized`), for the\n * rest of this server render and from the visitor's cookie. Without it the render stopped\n * at \"Store Unavailable\" and every reload sent the same token again; the SDK, which signs\n * the customer out on that answer, never loaded to do it.\n *\n * Answers whether there was a token to drop, so the caller knows a retry can differ.\n */\nconst dropRevokedToken = createIsomorphicFn()\n .server((): boolean => {\n // An uncompiled build runs this branch in the browser too; the SDK signs out there.\n if (typeof document !== 'undefined' || !getAuthToken()) return false;\n revokeAuthToken();\n try {\n setCookie(AUTH_TOKEN_COOKIE_NAME, '', { path: '/', maxAge: 0 });\n } catch {\n // Outside a request (prerender): there is no response to write to.\n }\n return true;\n })\n .client((): boolean => false);\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 // Asked again as a guest, once: the second time there is no token left to drop.\n if (isRevokedToken(cause) && dropRevokedToken()) return fetchSettings(identifier);\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
+ {"version":3,"sources":["../src/utils/language-cookie.ts","../src/utils/native-app-headers.ts","../src/api/store.ts"],"names":["createIsomorphicFn","setCookie"],"mappings":";;;;;;;;;;AAaA,IAAM,sBAAA,GAAyB,kBAAA,EAAmB,CAC/C,MAAA,CAAO,MAAqB;AAC3B,EAAA,IAAI;AACF,IAAA,OAAO,gBAAA,CAAiB,QAAQ,CAAA,IAAK,IAAA;AAAA,EACvC,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,IAAA;AAAA,EACT;AACF,CAAC,CAAA,CACA,MAAA,CAAO,MAAqB,IAAI,CAAA;AAEnC,IAAM,yBAAA,GAA4B,kBAAA,EAAmB,CAClD,MAAA,CAAO,CAAC,IAAA,KAAuB;AAC9B,EAAA,IAAI;AACF,IAAA,SAAA,CAAU,sBAAsB,IAAA,EAAM;AAAA,MACpC,IAAA,EAAM,GAAA;AAAA,MACN,MAAA,EAAQ,uBAAA;AAAA,MACR,QAAA,EAAU;AAAA,KACX,CAAA;AAAA,EACH,CAAA,CAAA,MAAQ;AAAA,EAER;AACF,CAAC,CAAA,CACA,OAAO,MAAY;AAAC,CAAC,CAAA;AAExB,IAAM,gBAAA,GAAmB,kBAAA,EAAmB,CACzC,MAAA,CAAO,MAAc;AACpB,EAAA,IAAI;AACF,IAAA,OAAO,eAAc,CAAE,MAAA;AAAA,EACzB,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,EAAA;AAAA,EACT;AACF,CAAC,CAAA,CACA,MAAA,CAAO,MAAc,EAAE,CAAA;AAMnB,SAAS,cAAA,GAAyB;AACvC,EAAA,OAAO,kBAAiB,KAAM,OAAO,WAAW,WAAA,GAAc,MAAA,CAAO,SAAS,MAAA,GAAS,EAAA,CAAA;AACzF;AAGO,SAAS,g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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-3W42UZSQ.js","sourcesContent":["/**\n * @fileoverview Reading and writing the `s-lang` cookie, on the server and in the browser.\n *\n * The server reads it from the request the framework is handling and writes it to that\n * request's response. The server-only import is stripped from the client bundle by\n * `createIsomorphicFn`, as in `routes/root/beforeLoad.ts`. The browser uses `document.cookie`.\n * Either side outside a request (a prerender, a test) has nothing to read or write and says so\n * quietly.\n */\nimport { createIsomorphicFn } from '@tanstack/react-start';\nimport { getRequestHeader, getRequestUrl, setCookie } from '@tanstack/react-start/server';\nimport { LANGUAGE_COOKIE_MAX_AGE, LANGUAGE_COOKIE_NAME } from './cookies';\n\nconst readServerCookieHeader = createIsomorphicFn()\n .server((): string | null => {\n try {\n return getRequestHeader('cookie') ?? null;\n } catch {\n return null;\n }\n })\n .client((): string | null => null);\n\nconst writeServerLanguageCookie = createIsomorphicFn()\n .server((code: string): void => {\n try {\n setCookie(LANGUAGE_COOKIE_NAME, code, {\n path: '/',\n maxAge: LANGUAGE_COOKIE_MAX_AGE,\n sameSite: 'lax',\n });\n } catch {\n // Outside a request: there is no response to write to.\n }\n })\n .client((): void => {});\n\nconst readServerSearch = createIsomorphicFn()\n .server((): string => {\n try {\n return getRequestUrl().search;\n } catch {\n return '';\n }\n })\n .client((): string => '');\n\n/**\n * The query string of the page being rendered (`?lang=en`, or `''`): the request's on the\n * server, the address bar's in the browser, so both sides read the same one.\n */\nexport function readPageSearch(): string {\n return readServerSearch() || (typeof window !== 'undefined' ? window.location.search : '');\n}\n\n/** The `Cookie` header of the request being handled, or `document.cookie` in the browser. */\nexport function readCookieHeader(): string | null {\n return readServerCookieHeader() ?? (typeof document !== 'undefined' ? document.cookie : null);\n}\n\n/** Remembers `code` as the visitor's language for every store on this host. */\nexport function persistLanguageCookie(code: string): void {\n writeServerLanguageCookie(code);\n if (typeof document !== 'undefined') {\n document.cookie = `${LANGUAGE_COOKIE_NAME}=${encodeURIComponent(code)}; path=/; max-age=${LANGUAGE_COOKIE_MAX_AGE}; SameSite=Lax`;\n }\n}\n","/** 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 * How the app's webview names itself to the Store API. On a Twig theme Laravel hands these\n * to the SDK as request headers, which is how the API tells an app order from a website one.\n */\nexport const NATIVE_APP_REQUEST_HEADERS = ['s-source', 's-app-webview'];\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, ...NATIVE_APP_REQUEST_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 { createIsomorphicFn } from '@tanstack/react-start';\nimport { setCookie } from '@tanstack/react-start/server';\nimport { isHTTPError, isNetworkError, isTimeoutError } from 'ky';\nimport {\n api,\n getActiveScope,\n getAuthToken,\n rememberStoreRay,\n STORE_IDENTIFIER_HEADER,\n} from './client';\nimport { devSettingsFetchedAt } from './dev-settings-cache';\nimport { SettingsError } from '../utils/errors';\nimport type { Store, Theme, Language, JitsuConfig, MaintenanceDetails } from '../types';\nimport { getTwilightContext, revokeAuthToken } from '../twilight/context';\nimport { resolveStoreIdentifier } from '../utils/store-identity';\nimport { AUTH_TOKEN_COOKIE_NAME, extractScopeFromUrl, parseStoreId } from '../utils/cookies';\nimport { readPageSearch } from '../utils/language-cookie';\nimport { requestedThemeVersionId } from '../utils/theme-version';\nimport { NATIVE_APP_HEADERS } from '../utils/native-app-headers';\nimport { isNotLaunchedNotice } from '../utils/maintenance';\n\nexport { resolveStoreIdentifier };\n\n// `rating` and `ratings` are left out: nothing in the engine reads them, and the API builds them by\n// aggregating every testimonial of the store, which on large stores ran past SETTINGS_TIMEOUT_MS on\n// every render (TD-17779).\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 '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 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 /** 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 * `false` while the store has not launched yet: `maintenance` is then `true` and the\n * engine's maintenance page says the store is launching soon. Absent otherwise. Not\n * from the API: read off `maintenance_details` by `store.settings`, since the\n * backend sends the merchant's \"finish launching\" notice there for every visitor,\n * which is not for a customer's eyes.\n */\n launched?: false;\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 /** Which answer of the API these settings are; see {@link SettingsAnswer}. */\n answer?: SettingsAnswer;\n /**\n * When the dev server fetched these settings from the API (epoch ms). It reuses\n * them for a while (see `dev-settings-cache.ts`) and the theme editor says how old\n * they are. Only on a dev server render; absent everywhere else.\n */\n devFetchedAt?: number;\n}\n\n/**\n * Which answer of the settings API a set of settings came from, read off the\n * response rather than the body: the API's request id, the Store's trace, and\n * whether Cloudflare served it from its cache and how old it was. A decision the\n * settings drive for every visitor alike (the maintenance page) can then be\n * traced to the exact request the backend logged, or to a cached copy of it.\n */\nexport interface SettingsAnswer {\n requestId?: string;\n traceId?: string;\n cacheStatus?: string;\n age?: string;\n}\n\nconst ANSWER_HEADERS: Record<keyof SettingsAnswer, string> = {\n requestId: 's-request-id',\n traceId: 'x-trace-id',\n cacheStatus: 'cf-cache-status',\n age: 'age',\n};\n\nfunction settingsAnswerOf(headers: Headers | undefined): SettingsAnswer | undefined {\n if (!headers) return undefined;\n const answer: SettingsAnswer = {};\n for (const [field, name] of Object.entries(ANSWER_HEADERS) as [keyof SettingsAnswer, string][]) {\n const value = headers.get(name);\n if (value) answer[field] = value;\n }\n return Object.keys(answer).length ? answer : undefined;\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 const appHeaders = requestNativeAppHeaders();\n if (!jitsu || !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) {\n delete headers[name];\n if (appHeaders[name]) headers[name] = appHeaders[name];\n }\n return {\n ...jitsu,\n context: {\n ...jitsu.context,\n extra: { ...extra, headers },\n },\n };\n}\n\n/** The app's headers on the request being rendered; null in the browser and outside the app. */\nfunction requestNativeAppHeaders(): Record<string, string> | null {\n if (typeof window !== 'undefined') return null;\n try {\n return getTwilightContext().nativeAppHeaders;\n } catch {\n return null;\n }\n}\n\n/**\n * The settings' request headers with the app's `s-source` and `s-app-webview` in them, as\n * Laravel adds them for a Twig theme: the SDK copies `headers` onto every call it makes.\n *\n * Both or neither. `s-source: mobile` without `s-app-webview` is the native app itself to\n * the API, which then answers a guest's `cart/latest` with a new cart every time.\n */\nfunction withNativeAppRequestHeaders(\n headers?: Record<string, unknown>\n): Record<string, unknown> | undefined {\n const appHeaders = requestNativeAppHeaders();\n if (appHeaders?.['s-source'] !== 'mobile' || !appHeaders['s-app-webview']) return headers;\n return { ...headers, 's-source': 'mobile', 's-app-webview': appHeaders['s-app-webview'] };\n}\n\nconst SETTINGS_TIMEOUT_MS = 5000;\n\n/**\n * Whether the page's own address switches market (`?scope=`).\n *\n * Only then does the settings request name the scope in its query string. The API\n * reads `?scope=` as a switch and lets it override the market a market's own domain\n * is pinned to, which the `s-scope-id` header never does. Sent on every request, a\n * market remembered from another visit would win over the host the shopper is on: the\n * settings, and the SDK seeded from them, would answer for that market while every\n * call without the parameter (the cart, among them) answers for the host's, and a\n * guest's cart created in one is refused by the other (TD-17588).\n */\nfunction pageSwitchesScope(): boolean {\n return extractScopeFromUrl(`http://page.invalid/${readPageSearch()}`) !== null;\n}\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 =\n scope != null && pageSwitchesScope() ? `${includeParams}&scope=${scope.id}` : includeParams;\n\n const request = 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 const json = await request.json<{ data?: SettingsApiResponse }>();\n // The same response, already settled; only its headers are read.\n const headers = (await request)?.headers;\n const answer = settingsAnswerOf(headers);\n const devFetchedAt = devSettingsFetchedAt(headers);\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 rememberStoreRay(identifier, data.headers);\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: withNativeAppRequestHeaders(data.headers),\n login: data.login,\n affiliate: data.affiliate,\n policy_url: data.policy_url,\n user: data.user,\n jitsu: withNativeAppHeaders(data.jitsu),\n maintenance: data.maintenance,\n maintenance_details: data.maintenance_details,\n ...(data.maintenance === true &&\n isNotLaunchedNotice(data.maintenance_details) && { launched: false as const }),\n ...(scope && { requestedScopeId: scope.id }),\n ...(answer && { answer }),\n ...(devFetchedAt && { devFetchedAt }),\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 * Whether the API answered that the token was signed out of all devices. `unauthorized`\n * alone: `token_invalid` is refreshed by the SDK, and a limited token (a review link)\n * gets `policy_token_not_allowed` so that its customer stays signed in.\n */\nfunction isRevokedToken(error: unknown): boolean {\n if (!isHTTPError(error) || error.response.status !== 401) return false;\n return (error.data as { error?: { code?: unknown } } | undefined)?.error?.code === 'unauthorized';\n}\n\n/**\n * Drops a token the API answered as signed out everywhere (401 `unauthorized`), for the\n * rest of this server render and from the visitor's cookie. Without it the render stopped\n * at \"Store Unavailable\" and every reload sent the same token again; the SDK, which signs\n * the customer out on that answer, never loaded to do it.\n *\n * Answers whether there was a token to drop, so the caller knows a retry can differ.\n */\nconst dropRevokedToken = createIsomorphicFn()\n .server((): boolean => {\n // An uncompiled build runs this branch in the browser too; the SDK signs out there.\n if (typeof document !== 'undefined' || !getAuthToken()) return false;\n revokeAuthToken();\n try {\n setCookie(AUTH_TOKEN_COOKIE_NAME, '', { path: '/', maxAge: 0 });\n } catch {\n // Outside a request (prerender): there is no response to write to.\n }\n return true;\n })\n .client((): boolean => false);\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 // Asked again as a guest, once: the second time there is no token left to drop.\n if (isRevokedToken(cause) && dropRevokedToken()) return fetchSettings(identifier);\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"]}