@salla.sa/twilight-theme-engine 1.0.190 → 1.0.192

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 (250) hide show
  1. package/dist/{AddToCartForm-KAAJU4A2.js → AddToCartForm-X5GWZIBZ.js} +3 -3
  2. package/dist/{AddToCartForm-KAAJU4A2.js.map → AddToCartForm-X5GWZIBZ.js.map} +1 -1
  3. package/dist/{BlogAuthorPage-VHN6OZN4.js → BlogAuthorPage-CND5APOB.js} +19 -19
  4. package/dist/{BlogAuthorPage-VHN6OZN4.js.map → BlogAuthorPage-CND5APOB.js.map} +1 -1
  5. package/dist/{BlogCategoryPage-FS2AXU4F.js → BlogCategoryPage-RATUBWXD.js} +19 -19
  6. package/dist/{BlogCategoryPage-FS2AXU4F.js.map → BlogCategoryPage-RATUBWXD.js.map} +1 -1
  7. package/dist/{BlogPage-DSKNHKBP.js → BlogPage-XAYN4CIW.js} +17 -17
  8. package/dist/{BlogPage-DSKNHKBP.js.map → BlogPage-XAYN4CIW.js.map} +1 -1
  9. package/dist/{BlogSinglePage-UWLK2ZVI.js → BlogSinglePage-X34KYTDI.js} +17 -17
  10. package/dist/{BlogSinglePage-UWLK2ZVI.js.map → BlogSinglePage-X34KYTDI.js.map} +1 -1
  11. package/dist/{BlogTagPage-7B5HNL4Y.js → BlogTagPage-3QZRUZJI.js} +19 -19
  12. package/dist/{BlogTagPage-7B5HNL4Y.js.map → BlogTagPage-3QZRUZJI.js.map} +1 -1
  13. package/dist/{BrandsPage-623N44WS.js → BrandsPage-ZSRUYTDR.js} +18 -18
  14. package/dist/{BrandsPage-623N44WS.js.map → BrandsPage-ZSRUYTDR.js.map} +1 -1
  15. package/dist/{Breadcrumb-WCILVFL4.js → Breadcrumb-AEFQUSMV.js} +17 -17
  16. package/dist/{Breadcrumb-WCILVFL4.js.map → Breadcrumb-AEFQUSMV.js.map} +1 -1
  17. package/dist/{CanvasOverlay-4NHVIGXV.js → CanvasOverlay-T5W3FD4J.js} +19 -6
  18. package/dist/CanvasOverlay-T5W3FD4J.js.map +1 -0
  19. package/dist/{CartItem-S4YI6O3D.js → CartItem-DYK4TRBN.js} +17 -17
  20. package/dist/{CartItem-S4YI6O3D.js.map → CartItem-DYK4TRBN.js.map} +1 -1
  21. package/dist/{CartSummary-23I56XYM.js → CartSummary-SUQFHS5L.js} +17 -17
  22. package/dist/{CartSummary-23I56XYM.js.map → CartSummary-SUQFHS5L.js.map} +1 -1
  23. package/dist/{Copyright-WQ3QGJXA.js → Copyright-SU3MVTTD.js} +3 -3
  24. package/dist/{Copyright-WQ3QGJXA.js.map → Copyright-SU3MVTTD.js.map} +1 -1
  25. package/dist/{CustomerLayout-YDY6LCDF.js → CustomerLayout-5U7QLNYV.js} +17 -17
  26. package/dist/{CustomerLayout-YDY6LCDF.js.map → CustomerLayout-5U7QLNYV.js.map} +1 -1
  27. package/dist/{Footer-OD3OASSX.js → Footer-BEWJCPM2.js} +3 -3
  28. package/dist/{Footer-OD3OASSX.js.map → Footer-BEWJCPM2.js.map} +1 -1
  29. package/dist/GoogleTag-SQNTIZOV.js +15 -0
  30. package/dist/{GoogleTag-R65O7SU7.js.map → GoogleTag-SQNTIZOV.js.map} +1 -1
  31. package/dist/{Header-W26NSLVJ.js → Header-U5HONSOE.js} +8 -8
  32. package/dist/{Header-W26NSLVJ.js.map → Header-U5HONSOE.js.map} +1 -1
  33. package/dist/{LatestProducts-POBEIWGZ.js → LatestProducts-BR4WUER7.js} +19 -19
  34. package/dist/{LatestProducts-POBEIWGZ.js.map → LatestProducts-BR4WUER7.js.map} +1 -1
  35. package/dist/{LoyaltyPage-DMFCII37.js → LoyaltyPage-KD74ZUXR.js} +17 -17
  36. package/dist/{LoyaltyPage-DMFCII37.js.map → LoyaltyPage-KD74ZUXR.js.map} +1 -1
  37. package/dist/{LoyaltyPointsPage-5YSQZYNZ.js → LoyaltyPointsPage-IXB4RPRF.js} +6 -6
  38. package/dist/{LoyaltyPointsPage-5YSQZYNZ.js.map → LoyaltyPointsPage-IXB4RPRF.js.map} +1 -1
  39. package/dist/{MainMenu-4GTPNG6U.js → MainMenu-63355BM2.js} +5 -5
  40. package/dist/{MainMenu-4GTPNG6U.js.map → MainMenu-63355BM2.js.map} +1 -1
  41. package/dist/{MasterLayout-4SYCEUHL.js → MasterLayout-MS677JPB.js} +17 -17
  42. package/dist/{MasterLayout-4SYCEUHL.js.map → MasterLayout-MS677JPB.js.map} +1 -1
  43. package/dist/{MobileMenu-WIAETV7Y.js → MobileMenu-D7OXPXGT.js} +18 -18
  44. package/dist/{MobileMenu-WIAETV7Y.js.map → MobileMenu-D7OXPXGT.js.map} +1 -1
  45. package/dist/{NotificationsPage-WGX7XV7G.js → NotificationsPage-NN5P2MZ2.js} +17 -17
  46. package/dist/{NotificationsPage-WGX7XV7G.js.map → NotificationsPage-NN5P2MZ2.js.map} +1 -1
  47. package/dist/{OrderSinglePage-4NILJOAP.js → OrderSinglePage-727ZYJM7.js} +18 -18
  48. package/dist/{OrderSinglePage-4NILJOAP.js.map → OrderSinglePage-727ZYJM7.js.map} +1 -1
  49. package/dist/{OrdersPage-QMJQKKGN.js → OrdersPage-RSK3GGVA.js} +17 -17
  50. package/dist/{OrdersPage-QMJQKKGN.js.map → OrdersPage-RSK3GGVA.js.map} +1 -1
  51. package/dist/{PageSingle-QUTX2362.js → PageSingle-MELOQLZW.js} +3 -3
  52. package/dist/{PageSingle-QUTX2362.js.map → PageSingle-MELOQLZW.js.map} +1 -1
  53. package/dist/{ProductDetails-V5RXYS4P.js → ProductDetails-JPFSFMGK.js} +5 -5
  54. package/dist/{ProductDetails-V5RXYS4P.js.map → ProductDetails-JPFSFMGK.js.map} +1 -1
  55. package/dist/{ProfilePage-UKIOGUTD.js → ProfilePage-CPIMKSL6.js} +17 -17
  56. package/dist/{ProfilePage-UKIOGUTD.js.map → ProfilePage-CPIMKSL6.js.map} +1 -1
  57. package/dist/{ReviewsPage-S4OWAYLR.js → ReviewsPage-4O4IMGJ7.js} +3 -3
  58. package/dist/{ReviewsPage-S4OWAYLR.js.map → ReviewsPage-4O4IMGJ7.js.map} +1 -1
  59. package/dist/{SeoCartWidget-PV47GU6C.js → SeoCartWidget-VQWBHPXZ.js} +17 -17
  60. package/dist/{SeoCartWidget-PV47GU6C.js.map → SeoCartWidget-VQWBHPXZ.js.map} +1 -1
  61. package/dist/{SettingsPage-BJTJ67GK.js → SettingsPage-NBQCONOI.js} +17 -17
  62. package/dist/{SettingsPage-BJTJ67GK.js.map → SettingsPage-NBQCONOI.js.map} +1 -1
  63. package/dist/{StoreClosedNotification-LY7QRBFD.js → StoreClosedNotification-4YMQO7HR.js} +18 -18
  64. package/dist/{StoreClosedNotification-LY7QRBFD.js.map → StoreClosedNotification-4YMQO7HR.js.map} +1 -1
  65. package/dist/{TestimonialsPage-Y52XDRGH.js → TestimonialsPage-ETQ7IKFY.js} +3 -3
  66. package/dist/{TestimonialsPage-Y52XDRGH.js.map → TestimonialsPage-ETQ7IKFY.js.map} +1 -1
  67. package/dist/{ThankYouPage-TUBSFLBE.js → ThankYouPage-EHDUAG4Y.js} +17 -17
  68. package/dist/{ThankYouPage-TUBSFLBE.js.map → ThankYouPage-EHDUAG4Y.js.map} +1 -1
  69. package/dist/{WalletPage-EP5ZDLWY.js → WalletPage-Z5PNHZZK.js} +18 -18
  70. package/dist/{WalletPage-EP5ZDLWY.js.map → WalletPage-Z5PNHZZK.js.map} +1 -1
  71. package/dist/{WebMcpTools-KPAKY4SD.js → WebMcpTools-7ILM2NAG.js} +5 -5
  72. package/dist/{WebMcpTools-KPAKY4SD.js.map → WebMcpTools-7ILM2NAG.js.map} +1 -1
  73. package/dist/{WishlistPage-6HCY2FMS.js → WishlistPage-UNWRNVBI.js} +19 -19
  74. package/dist/{WishlistPage-6HCY2FMS.js.map → WishlistPage-UNWRNVBI.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.d.ts.map +1 -1
  92. package/dist/api/store.js +2 -2
  93. package/dist/api/translations.js +2 -2
  94. package/dist/api/user.js +2 -2
  95. package/dist/api/wallet.js +2 -2
  96. package/dist/api/wishlist.js +4 -4
  97. package/dist/{chunk-N2XBQN2S.js → chunk-2GWLV64H.js} +2 -2
  98. package/dist/{chunk-N2XBQN2S.js.map → chunk-2GWLV64H.js.map} +1 -1
  99. package/dist/{chunk-O7YSKG2A.js → chunk-2IOYVOCW.js} +14 -14
  100. package/dist/{chunk-O7YSKG2A.js.map → chunk-2IOYVOCW.js.map} +1 -1
  101. package/dist/{chunk-BVONGI6Z.js → chunk-5FVZR2YT.js} +4 -4
  102. package/dist/{chunk-BVONGI6Z.js.map → chunk-5FVZR2YT.js.map} +1 -1
  103. package/dist/{chunk-TXMG7FIA.js → chunk-6FDNJBYW.js} +4 -4
  104. package/dist/{chunk-TXMG7FIA.js.map → chunk-6FDNJBYW.js.map} +1 -1
  105. package/dist/{chunk-AXNUUBGZ.js → chunk-6J4ZQ7LJ.js} +6 -6
  106. package/dist/{chunk-AXNUUBGZ.js.map → chunk-6J4ZQ7LJ.js.map} +1 -1
  107. package/dist/{chunk-TBOPWHG4.js → chunk-7CSPDVSP.js} +3 -3
  108. package/dist/{chunk-TBOPWHG4.js.map → chunk-7CSPDVSP.js.map} +1 -1
  109. package/dist/{chunk-VHLRX3JJ.js → chunk-7DAM32W2.js} +4 -4
  110. package/dist/{chunk-VHLRX3JJ.js.map → chunk-7DAM32W2.js.map} +1 -1
  111. package/dist/{chunk-7J35UKLU.js → chunk-AAGWGIDP.js} +4 -4
  112. package/dist/{chunk-7J35UKLU.js.map → chunk-AAGWGIDP.js.map} +1 -1
  113. package/dist/{chunk-RZN7X72V.js → chunk-AUD7CY4G.js} +3 -3
  114. package/dist/{chunk-RZN7X72V.js.map → chunk-AUD7CY4G.js.map} +1 -1
  115. package/dist/{chunk-5IPAWSCV.js → chunk-AWRND4JA.js} +4 -4
  116. package/dist/{chunk-5IPAWSCV.js.map → chunk-AWRND4JA.js.map} +1 -1
  117. package/dist/{chunk-KSZD7ZFY.js → chunk-BU7BVPKC.js} +3 -3
  118. package/dist/{chunk-KSZD7ZFY.js.map → chunk-BU7BVPKC.js.map} +1 -1
  119. package/dist/{chunk-NOYFPIZR.js → chunk-BZP3RPDO.js} +3 -3
  120. package/dist/{chunk-NOYFPIZR.js.map → chunk-BZP3RPDO.js.map} +1 -1
  121. package/dist/{chunk-JRJZXUWY.js → chunk-CA4SXLIA.js} +3 -3
  122. package/dist/{chunk-JRJZXUWY.js.map → chunk-CA4SXLIA.js.map} +1 -1
  123. package/dist/{chunk-VHTVAZEE.js → chunk-COZDDLHH.js} +5 -5
  124. package/dist/{chunk-VHTVAZEE.js.map → chunk-COZDDLHH.js.map} +1 -1
  125. package/dist/{chunk-JQWLQIDO.js → chunk-CST6D6TK.js} +5 -5
  126. package/dist/{chunk-JQWLQIDO.js.map → chunk-CST6D6TK.js.map} +1 -1
  127. package/dist/{chunk-FLPDMPVB.js → chunk-DEUF6LFD.js} +3 -3
  128. package/dist/{chunk-FLPDMPVB.js.map → chunk-DEUF6LFD.js.map} +1 -1
  129. package/dist/{chunk-XBZIPRTK.js → chunk-DP5CJ2GI.js} +3 -3
  130. package/dist/{chunk-XBZIPRTK.js.map → chunk-DP5CJ2GI.js.map} +1 -1
  131. package/dist/{chunk-DYY7Y7DZ.js → chunk-E273CZGJ.js} +3 -3
  132. package/dist/{chunk-DYY7Y7DZ.js.map → chunk-E273CZGJ.js.map} +1 -1
  133. package/dist/{chunk-7FQHDIX5.js → chunk-EAMC5X2F.js} +7 -7
  134. package/dist/{chunk-7FQHDIX5.js.map → chunk-EAMC5X2F.js.map} +1 -1
  135. package/dist/{chunk-J76Y33NU.js → chunk-ESUQ6HE7.js} +7 -7
  136. package/dist/{chunk-J76Y33NU.js.map → chunk-ESUQ6HE7.js.map} +1 -1
  137. package/dist/{chunk-67R54ONG.js → chunk-GKKE7NGM.js} +5 -5
  138. package/dist/{chunk-67R54ONG.js.map → chunk-GKKE7NGM.js.map} +1 -1
  139. package/dist/{chunk-7UEQP3EQ.js → chunk-GU3NLSCU.js} +4 -4
  140. package/dist/{chunk-7UEQP3EQ.js.map → chunk-GU3NLSCU.js.map} +1 -1
  141. package/dist/{chunk-4IJGARZP.js → chunk-GWYKIZD3.js} +4 -4
  142. package/dist/{chunk-4IJGARZP.js.map → chunk-GWYKIZD3.js.map} +1 -1
  143. package/dist/{chunk-Q54E3MRF.js → chunk-H7ONTMRZ.js} +3 -3
  144. package/dist/{chunk-Q54E3MRF.js.map → chunk-H7ONTMRZ.js.map} +1 -1
  145. package/dist/{chunk-LRKJBY26.js → chunk-HYZTN2GL.js} +3 -3
  146. package/dist/{chunk-LRKJBY26.js.map → chunk-HYZTN2GL.js.map} +1 -1
  147. package/dist/{chunk-NTBL5QFW.js → chunk-IMWSBFOC.js} +3 -3
  148. package/dist/{chunk-NTBL5QFW.js.map → chunk-IMWSBFOC.js.map} +1 -1
  149. package/dist/{chunk-GMBOYIH5.js → chunk-IOJ4GG7Z.js} +3 -3
  150. package/dist/{chunk-GMBOYIH5.js.map → chunk-IOJ4GG7Z.js.map} +1 -1
  151. package/dist/{chunk-EYSQQR7T.js → chunk-IZJZH5WK.js} +3 -3
  152. package/dist/{chunk-EYSQQR7T.js.map → chunk-IZJZH5WK.js.map} +1 -1
  153. package/dist/{chunk-PGNAIM6L.js → chunk-JOAFEUZ5.js} +4 -4
  154. package/dist/{chunk-PGNAIM6L.js.map → chunk-JOAFEUZ5.js.map} +1 -1
  155. package/dist/{chunk-ILDV6JVU.js → chunk-KZJN75WE.js} +19 -19
  156. package/dist/{chunk-ILDV6JVU.js.map → chunk-KZJN75WE.js.map} +1 -1
  157. package/dist/{chunk-6444ZQQB.js → chunk-KZQIHYHY.js} +7 -7
  158. package/dist/{chunk-6444ZQQB.js.map → chunk-KZQIHYHY.js.map} +1 -1
  159. package/dist/{chunk-FF7FJJYG.js → chunk-L3GPCXCM.js} +4 -4
  160. package/dist/{chunk-FF7FJJYG.js.map → chunk-L3GPCXCM.js.map} +1 -1
  161. package/dist/{chunk-NQ42AV7D.js → chunk-LVJJOBAP.js} +3 -3
  162. package/dist/{chunk-NQ42AV7D.js.map → chunk-LVJJOBAP.js.map} +1 -1
  163. package/dist/{chunk-IKOLXZ72.js → chunk-M3NEABKH.js} +4 -4
  164. package/dist/{chunk-IKOLXZ72.js.map → chunk-M3NEABKH.js.map} +1 -1
  165. package/dist/{chunk-QCXWLQCL.js → chunk-MVOHDJRG.js} +4 -4
  166. package/dist/{chunk-QCXWLQCL.js.map → chunk-MVOHDJRG.js.map} +1 -1
  167. package/dist/{chunk-Q3237344.js → chunk-NTQZJXYU.js} +3 -3
  168. package/dist/{chunk-Q3237344.js.map → chunk-NTQZJXYU.js.map} +1 -1
  169. package/dist/{chunk-KE2NSE4A.js → chunk-OIQ2ESGU.js} +3 -3
  170. package/dist/{chunk-KE2NSE4A.js.map → chunk-OIQ2ESGU.js.map} +1 -1
  171. package/dist/{chunk-TP2GMZEK.js → chunk-R2XNSGZX.js} +4 -4
  172. package/dist/{chunk-TP2GMZEK.js.map → chunk-R2XNSGZX.js.map} +1 -1
  173. package/dist/{chunk-JWMLMLON.js → chunk-REFA7W55.js} +3 -3
  174. package/dist/{chunk-JWMLMLON.js.map → chunk-REFA7W55.js.map} +1 -1
  175. package/dist/{chunk-USEGCCT3.js → chunk-S2ZVONKA.js} +4 -4
  176. package/dist/{chunk-USEGCCT3.js.map → chunk-S2ZVONKA.js.map} +1 -1
  177. package/dist/{chunk-IQS7EDB3.js → chunk-UCEIFCFW.js} +4 -4
  178. package/dist/{chunk-IQS7EDB3.js.map → chunk-UCEIFCFW.js.map} +1 -1
  179. package/dist/{chunk-TQW7A42X.js → chunk-VCTBBPKU.js} +4 -4
  180. package/dist/{chunk-TQW7A42X.js.map → chunk-VCTBBPKU.js.map} +1 -1
  181. package/dist/{chunk-HPKOZDZC.js → chunk-WFLTAF4V.js} +4 -4
  182. package/dist/{chunk-HPKOZDZC.js.map → chunk-WFLTAF4V.js.map} +1 -1
  183. package/dist/{chunk-MTTKSFUF.js → chunk-WGNHY5SV.js} +3 -3
  184. package/dist/{chunk-MTTKSFUF.js.map → chunk-WGNHY5SV.js.map} +1 -1
  185. package/dist/{chunk-U5QRBIEL.js → chunk-X7QELNMF.js} +3 -3
  186. package/dist/{chunk-U5QRBIEL.js.map → chunk-X7QELNMF.js.map} +1 -1
  187. package/dist/{chunk-PSG2U2GG.js → chunk-XEBU5UBC.js} +5 -5
  188. package/dist/{chunk-PSG2U2GG.js.map → chunk-XEBU5UBC.js.map} +1 -1
  189. package/dist/{chunk-GSPD3FOY.js → chunk-XEKROZ6O.js} +3 -3
  190. package/dist/{chunk-GSPD3FOY.js.map → chunk-XEKROZ6O.js.map} +1 -1
  191. package/dist/{chunk-BM43QN4L.js → chunk-YJMUVRXD.js} +3 -3
  192. package/dist/{chunk-BM43QN4L.js.map → chunk-YJMUVRXD.js.map} +1 -1
  193. package/dist/{chunk-FF5HNVZ7.js → chunk-ZB734AWC.js} +4 -4
  194. package/dist/{chunk-FF5HNVZ7.js.map → chunk-ZB734AWC.js.map} +1 -1
  195. package/dist/{chunk-RLT3D2LR.js → chunk-ZCW7I6XA.js} +3 -5
  196. package/dist/chunk-ZCW7I6XA.js.map +1 -0
  197. package/dist/components/cart/index.js +1 -1
  198. package/dist/components/common/index.js +1 -1
  199. package/dist/components/drawer/index.js +15 -15
  200. package/dist/components/home/index.js +20 -20
  201. package/dist/components/layout/index.js +4 -4
  202. package/dist/components/live-editor/CanvasOverlay.d.ts.map +1 -1
  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-7N3FYOTY.js → custom-urls-QRGTZZ3T.js} +7 -7
  207. package/dist/{custom-urls-7N3FYOTY.js.map → custom-urls-QRGTZZ3T.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-5G7JJUGH.js → document-class-CU7HE4W4.js} +17 -17
  211. package/dist/{document-class-5G7JJUGH.js.map → document-class-CU7HE4W4.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-XKSFWNDB.js → navigation-QU56PTFS.js} +4 -4
  219. package/dist/{navigation-XKSFWNDB.js.map → navigation-QU56PTFS.js.map} +1 -1
  220. package/dist/{navigation-7MC7R6WS.js → navigation-SDO73N6D.js} +5 -5
  221. package/dist/{navigation-7MC7R6WS.js.map → navigation-SDO73N6D.js.map} +1 -1
  222. package/dist/{not-found-C7QUZLNB.js → not-found-4534JHTN.js} +18 -18
  223. package/dist/{not-found-C7QUZLNB.js.map → not-found-4534JHTN.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.js +8 -8
  228. package/dist/routes/brands.js +4 -4
  229. package/dist/routes/cart.js +25 -25
  230. package/dist/routes/home.js +21 -21
  231. package/dist/routes/index.js +8 -8
  232. package/dist/routes/loyalty.js +5 -5
  233. package/dist/routes/page.js +4 -4
  234. package/dist/routes/product-listing.js +25 -25
  235. package/dist/routes/product.js +24 -24
  236. package/dist/routes/seo-redirects.js +8 -8
  237. package/dist/routes/testimonials.js +2 -2
  238. package/dist/routes/thank-you.js +4 -4
  239. package/dist/skeleton.js +23 -23
  240. package/dist/{store-lookup-RNC4M3Q6.js → store-lookup-DNSFXMEL.js} +8 -8
  241. package/dist/{store-lookup-RNC4M3Q6.js.map → store-lookup-DNSFXMEL.js.map} +1 -1
  242. package/dist/tanstack.js +17 -17
  243. package/dist/types/index.d.ts +8 -2
  244. package/dist/types/index.d.ts.map +1 -1
  245. package/dist/utils/index.js +2 -2
  246. package/package.json +1 -1
  247. package/tailwind/components/live-editor/CanvasOverlay.tsx.txt +23 -3
  248. package/dist/CanvasOverlay-4NHVIGXV.js.map +0 -1
  249. package/dist/GoogleTag-R65O7SU7.js +0 -15
  250. package/dist/chunk-RLT3D2LR.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/lib/analytics/gtm-page.ts"],"names":["user"],"mappings":";;;;;;;;AAuCO,IAAM,qBAAA,GAAwB;AAErC,IAAI,KAAA,GAAuB,QAAQ,OAAA,EAAQ;AAC3C,IAAI,iBAAA,GAAoB,KAAA;AACxB,IAAI,WAAA,GAA6B,IAAA;AACjC,IAAI,oBAAgC,MAAM;AAAC,CAAA;AAC3C,IAAI,gBAAgB,IAAI,OAAA,CAAc,CAAC,OAAA,KAAa,oBAAoB,OAAQ,CAAA;AAChF,IAAI,eAAA,GAAuC,IAAA;AAE3C,IAAI,eAAA,uBAAsB,GAAA,EAAY;AAG/B,SAAS,eAAA,GAAiC;AAC/C,EAAA,OAAO,aAAA;AACT;AAEA,SAAS,mBAAA,GAAgD;AACvD,EAAA,IAAI;AACF,IAAA,OAAO,oBAAmB,CAAE,QAAA;AAAA,EAC9B,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,MAAA;AAAA,EACT;AACF;AAEA,SAAS,QAAQ,IAAA,EAAwC;AACvD,EAAA,KAAA,GAAQ,MAAM,IAAA,CAAK,IAAI,CAAA,CA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AAA,EAAW;AAC3E,IAAA,MAAM,WAAW,OAAA,CAAQ,IAAA;AACzB,IAAA,MAAM,WAAW,mBAAA,EAAoB;AACrC,IAAA,IAAI,CAAC,QAAA,CAAS,MAAA,IAAU,CAAC,UAAA,CAAW,QAAQ,CAAA,EAAG;AAE/C,IAAA,MAAM,cAAc,cAAA,CAAe,QAAA,EAAU,oBAAmB,CAAE,IAAA,IAAQ,QAAW,QAAQ,CAAA;AAC7F,IAAA,OAAA,CAAQ,MAAM;AACZ,MAAA,eAAA,CAAgB,EAAE,SAAA,EAAW,EAAE,WAAA,EAAa,IAAA,IAAQ,CAAA;AACpD,MAAA,eAAA,CAAgB,WAAW,CAAA;AAAA,IAC7B,CAAC,CAAA;AAAA,EACH,CAAC,CAAA;AACH","file":"chunk-USEGCCT3.js","sourcesContent":["/**\n * The order a Twig page fills the data layer in, for a storefront that loads once.\n *\n * A Twig page opens with its own data (`page`, `store`, `customer`, and the page's ecommerce\n * block), then loads the containers, then hands the SDK `twilight::init` and each\n * `services::<name>.init`, which the SDK copies into the data layer. Tags fire on those events\n * and read the data pushed before them, so the order is the contract.\n *\n * Here the first page is pushed once its customer is known (the signed-in one loads in the\n * browser) and, on the cart, once the cart has; GTM waits for that push ({@link whenGtmPageData}).\n * Every later page pushes its own `page` and ecommerce block too, after clearing the previous\n * page's ecommerce (GTM merges objects into what it holds, arrays index by index). Those pages\n * load nothing, so they announce no services again: Salla's container would load its Google\n * tags and Clarity a second time. Every push the engine makes goes through one queue, so a\n * page's data is always in before its events.\n */\nimport type { Cart, Product, User } from '../../types';\nimport type { Order } from '../../routes/account/types';\nimport { user as userApi } from '../../api/user';\nimport type { StoreContext } from '../../api/store';\nimport { getTwilightContext, type PageContext } from '../../twilight/context';\nimport { isNativeApp } from '../../native-app';\nimport { RouteId } from '../../router/route-ids';\nimport { onSallaEvent, whenSallaLoaded } from '../../utils/sdk-helpers';\nimport {\n gtmCartCheckout,\n gtmCustomer,\n gtmDetail,\n gtmEnabled,\n gtmImpressions,\n gtmPage,\n gtmPurchase,\n gtmStore,\n pushToDataLayer,\n servicesInitEvents,\n type DataLayerEntry,\n} from './gtm';\n\n/** How long the first page waits for its customer or its cart before it is pushed without. */\nexport const GTM_PAGE_DATA_WAIT_MS = 3000;\n\nlet queue: Promise<void> = Promise.resolve();\nlet firstPageReported = false;\nlet previousUrl: string | null = null;\nlet markPageDataReady: () => void = () => {};\nlet pageDataReady = new Promise<void>((resolve) => (markPageDataReady = resolve));\nlet stopImpressions: (() => void) | null = null;\n/** Orders this document has pushed a `purchase` for, whether or not GTM has taken it yet. */\nlet purchasesPushed = new Set<string>();\n\n/** Resolves once the first page's data is in the data layer, as Twig's head pushes it before GTM. */\nexport function whenGtmPageData(): Promise<void> {\n return pageDataReady;\n}\n\nfunction settingsOrUndefined(): StoreContext | undefined {\n try {\n return getTwilightContext().settings;\n } catch {\n return undefined;\n }\n}\n\nfunction enqueue(task: () => void | Promise<void>): void {\n queue = queue.then(task).catch((error: unknown) => {\n console.warn('[gtm] Could not push to the data layer:', error);\n });\n}\n\nfunction withDeadline<T>(value: T | Promise<T>, fallback: T): Promise<T> {\n let timer: ReturnType<typeof setTimeout> | undefined;\n const deadline = new Promise<T>((resolve) => {\n timer = setTimeout(() => resolve(fallback), GTM_PAGE_DATA_WAIT_MS);\n });\n return Promise.race([Promise.resolve(value), deadline])\n .catch(() => fallback)\n .finally(() => clearTimeout(timer));\n}\n\n/** The signed-in customer, from the query `useUser` already loads; a guest has no token. */\nasync function currentUser(): Promise<User | null> {\n const { authToken, queryClient } = getTwilightContext();\n if (!authToken || !queryClient) return null;\n return withDeadline(\n queryClient.ensureQueryData(userApi.queries.current()).catch(() => null),\n null\n );\n}\n\n/** The Salla app's webview: the SDK knows once loaded, the settings carry the app's headers before. */\nfunction inNativeApp(settings: StoreContext | undefined): boolean {\n const os = settings?.jitsu?.context?.extra?.headers?.['s-app-os']?.toLowerCase();\n return os === 'ios' || os === 'android' || isNativeApp();\n}\n\n/**\n * The `user` Twig's `twilight::init` carries (the SDK's own config), as far as tags read it:\n * Salla's container identifies the customer to a chat service from `user.id` when that\n * service's `services::<name>.init` arrives, which is before the SDK pushes a user of its own.\n */\nfunction initUser(settings: StoreContext | undefined, user: User | null): DataLayerEntry {\n const visitor = settings?.user;\n return {\n id: user ? (user.id ?? null) : (visitor?.id ?? null),\n type: user ? 'user' : (visitor?.type ?? 'guest'),\n country_code: user?.country_code ?? visitor?.country_code,\n language_code: visitor?.language_code,\n currency_code: visitor?.currency_code,\n };\n}\n\n/** `twilight::init`, then each `services::<name>.init`, once per document, as Twig's page does. */\nfunction announceServices(settings: StoreContext | undefined, user: User | null): void {\n const snippetServices = (getTwilightContext().appsSnippets ?? []).map((app) => app.service);\n const events = servicesInitEvents(settings?.external_services, snippetServices);\n whenSallaLoaded((sdk) => {\n // The engine calls `salla.init` itself; Twig hands it the event, which the SDK records.\n pushToDataLayer({ event: 'twilight::init', user: initUser(settings, user) });\n for (const [name, payload] of events) sdk.event.dispatch(name, payload);\n });\n}\n\nexport interface GtmPageView {\n page: PageContext;\n /** The page's ecommerce block, or a promise of it: the cart loads in the browser. */\n ecommerce?: DataLayerEntry | Promise<DataLayerEntry | null> | null;\n}\n\n/** Push a page's data, once per page view: the first opens the document's data layer. */\nexport function reportGtmPageView(view: GtmPageView): void {\n if (typeof window === 'undefined') return;\n const settings = settingsOrUndefined();\n if (!gtmEnabled(settings)) {\n markPageDataReady();\n return;\n }\n watchListImpressions();\n\n const first = !firstPageReported;\n firstPageReported = true;\n // `url()->previous()`: the page before, or the store itself when the visitor came from nowhere.\n const referrer = (first ? document.referrer : previousUrl) || window.location.origin;\n previousUrl = window.location.href;\n\n enqueue(async () => {\n const [user, ecommerce] = await Promise.all([\n currentUser(),\n withDeadline(view.ecommerce ?? null, null),\n ]);\n const customer = await gtmCustomer(user, settings);\n const page = gtmPage(\n { slug: view.page.slug, referrer, mobileApp: inNativeApp(settings) },\n settings\n );\n if (first) {\n const entry = { ...ecommerce, page, store: gtmStore(settings), customer };\n pushToDataLayer(entry);\n rememberPurchaseOnceReceived(entry);\n announceServices(settings, user);\n markPageDataReady();\n return;\n }\n // GTM merges each push into what it holds: a guest's `{ isGuest: true }` would keep the\n // signed-out customer's details, and a shorter product list the last page's extra lines.\n pushToDataLayer({ customer: null, ecommerce: null });\n pushToDataLayer({ page, customer });\n if (ecommerce) {\n pushToDataLayer(ecommerce);\n rememberPurchaseOnceReceived(ecommerce);\n }\n });\n}\n\n/** How long a browser remembers an order it reported, as `SeoThankYouWidget` caches it. */\nconst PURCHASE_REMEMBERED_MS = 24 * 60 * 60 * 1000;\n/** How often, and for how long, a pushed purchase is checked for GTM having taken it. */\nexport const PURCHASE_RECEIVED_POLL_MS = 500;\nconst PURCHASE_RECEIVED_WAIT_MS = 60_000;\nconst purchaseKey = (orderId: unknown) => `google_tagged_order_${String(orderId)}`;\n\nfunction reportedRecently(orderId: unknown): boolean {\n try {\n const at = Number(window.localStorage.getItem(purchaseKey(orderId)));\n return Boolean(at) && Date.now() - at < PURCHASE_REMEMBERED_MS;\n } catch {\n // No storage (a private window): report it, as a Twig page would the first time.\n return false;\n }\n}\n\n/**\n * Remember a pushed `purchase` once GTM has taken it (GTM stamps `gtm.uniqueEventId` on each\n * message it handles). GTM loads seconds after the page here, so a shopper who leaves before\n * then has reported nothing, and the next visit reports it. Twig renders the push and its\n * container together, so it remembers the order as it renders the page.\n */\nfunction rememberPurchaseOnceReceived(entry: DataLayerEntry): void {\n if (entry.event !== 'purchase') return;\n const orderId = (entry.ecommerce as { event_id?: unknown } | undefined)?.event_id;\n const started = Date.now();\n const check = () => {\n if ('gtm.uniqueEventId' in entry) {\n try {\n window.localStorage.setItem(purchaseKey(orderId), String(Date.now()));\n } catch {\n // No storage: nothing to remember it in.\n }\n } else if (Date.now() - started < PURCHASE_RECEIVED_WAIT_MS) {\n setTimeout(check, PURCHASE_RECEIVED_POLL_MS);\n }\n };\n check();\n}\n\n/**\n * An order's `purchase`, once: Twig caches each order it reported for a day, so a reload of\n * the thank-you page counts nothing. Not inside the Salla app, which logs the order itself.\n */\nfunction purchaseOnce(order: Order, settings: StoreContext | undefined): DataLayerEntry | null {\n const id = String(order.id);\n // A return to the page in this document waits on the first push; only a new load retries.\n if (inNativeApp(settings) || purchasesPushed.has(id) || reportedRecently(order.id)) return null;\n purchasesPushed.add(id);\n return gtmPurchase(order, settings);\n}\n\nexport interface GtmPageEcommerceInput {\n slug: string;\n product?: Product;\n order?: Order;\n /** The cart page's cart, once the page has loaded it. */\n cart?: Promise<Cart | null> | null;\n}\n\n/** A page's own ecommerce block: a product's `detail`, the cart's `checkout`, an order's `purchase`. */\nexport function gtmPageEcommerce(input: GtmPageEcommerceInput): GtmPageView['ecommerce'] {\n if (typeof window === 'undefined') return null;\n const settings = settingsOrUndefined();\n if (!gtmEnabled(settings)) return null;\n if (input.slug === RouteId.PRODUCT_SINGLE && input.product)\n return gtmDetail(input.product, settings);\n if (input.slug === RouteId.CART && input.cart)\n return input.cart.then((cart) => (cart ? gtmCartCheckout(cart, settings) : null));\n if (input.slug === RouteId.THANK_YOU && input.order) return purchaseOnce(input.order, settings);\n return null;\n}\n\n/**\n * `impressions` for each page of a product listing the engine or the theme reports through\n * `salla-products-list::products.fetched`, as `<salla-products-list>` pushes on Twig. That\n * component pushes its own before it emits the API's answer (`success`), so those are skipped.\n * Each batch first clears the last one's list (GTM merges arrays index by index), and only that:\n * the page's own block, such as the cart's `checkout`, stays for the tags still to read it.\n */\nfunction watchListImpressions(): void {\n if (stopImpressions) return;\n stopImpressions = onSallaEvent('salla-products-list::products.fetched', (payload) => {\n const fetched = payload as { data?: unknown; success?: unknown } | undefined;\n if (!Array.isArray(fetched?.data) || typeof fetched.success === 'boolean') return;\n const products = fetched.data as Product[];\n const settings = settingsOrUndefined();\n if (!products.length || !gtmEnabled(settings)) return;\n // The page the products were fetched for, not the one the queue gets to them on.\n const impressions = gtmImpressions(products, getTwilightContext().page ?? undefined, settings);\n enqueue(() => {\n pushToDataLayer({ ecommerce: { impressions: null } });\n pushToDataLayer(impressions);\n });\n });\n}\n\n/** Test seam: forget the document's first page and every listener. */\nexport function resetGtmPageTracking(): void {\n stopImpressions?.();\n stopImpressions = null;\n queue = Promise.resolve();\n firstPageReported = false;\n previousUrl = null;\n purchasesPushed = new Set();\n pageDataReady = new Promise<void>((resolve) => (markPageDataReady = resolve));\n}\n\n/** Test seam: settle every push queued so far. */\nexport function flushGtmQueue(): Promise<void> {\n return queue;\n}\n"]}
1
+ {"version":3,"sources":["../src/lib/analytics/gtm-page.ts"],"names":["user"],"mappings":";;;;;;;;AAuCO,IAAM,qBAAA,GAAwB;AAErC,IAAI,KAAA,GAAuB,QAAQ,OAAA,EAAQ;AAC3C,IAAI,iBAAA,GAAoB,KAAA;AACxB,IAAI,WAAA,GAA6B,IAAA;AACjC,IAAI,oBAAgC,MAAM;AAAC,CAAA;AAC3C,IAAI,gBAAgB,IAAI,OAAA,CAAc,CAAC,OAAA,KAAa,oBAAoB,OAAQ,CAAA;AAChF,IAAI,eAAA,GAAuC,IAAA;AAE3C,IAAI,eAAA,uBAAsB,GAAA,EAAY;AAG/B,SAAS,eAAA,GAAiC;AAC/C,EAAA,OAAO,aAAA;AACT;AAEA,SAAS,mBAAA,GAAgD;AACvD,EAAA,IAAI;AACF,IAAA,OAAO,oBAAmB,CAAE,QAAA;AAAA,EAC9B,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,MAAA;AAAA,EACT;AACF;AAEA,SAAS,QAAQ,IAAA,EAAwC;AACvD,EAAA,KAAA,GAAQ,MAAM,IAAA,CAAK,IAAI,CAAA,CAAE,KAAA,CAAM,CAAC,KAAA,KAAmB;AACjD,IAAA,OAAA,CAAQ,IAAA,CAAK,2CAA2C,KAAK,CAAA;AAAA,EAC/D,CAAC,CAAA;AACH;AAEA,SAAS,YAAA,CAAgB,OAAuB,QAAA,EAAyB;AACvE,EAAA,IAAI,KAAA;AACJ,EAAA,MAAM,QAAA,GAAW,IAAI,OAAA,CAA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AAE,IAAA,IAAQ,QAAW,QAAQ,CAAA;AAC7F,IAAA,OAAA,CAAQ,MAAM;AACZ,MAAA,eAAA,CAAgB,EAAE,SAAA,EAAW,EAAE,WAAA,EAAa,IAAA,IAAQ,CAAA;AACpD,MAAA,eAAA,CAAgB,WAAW,CAAA;AAAA,IAC7B,CAAC,CAAA;AAAA,EACH,CAAC,CAAA;AACH","file":"chunk-S2ZVONKA.js","sourcesContent":["/**\n * The order a Twig page fills the data layer in, for a storefront that loads once.\n *\n * A Twig page opens with its own data (`page`, `store`, `customer`, and the page's ecommerce\n * block), then loads the containers, then hands the SDK `twilight::init` and each\n * `services::<name>.init`, which the SDK copies into the data layer. Tags fire on those events\n * and read the data pushed before them, so the order is the contract.\n *\n * Here the first page is pushed once its customer is known (the signed-in one loads in the\n * browser) and, on the cart, once the cart has; GTM waits for that push ({@link whenGtmPageData}).\n * Every later page pushes its own `page` and ecommerce block too, after clearing the previous\n * page's ecommerce (GTM merges objects into what it holds, arrays index by index). Those pages\n * load nothing, so they announce no services again: Salla's container would load its Google\n * tags and Clarity a second time. Every push the engine makes goes through one queue, so a\n * page's data is always in before its events.\n */\nimport type { Cart, Product, User } from '../../types';\nimport type { Order } from '../../routes/account/types';\nimport { user as userApi } from '../../api/user';\nimport type { StoreContext } from '../../api/store';\nimport { getTwilightContext, type PageContext } from '../../twilight/context';\nimport { isNativeApp } from '../../native-app';\nimport { RouteId } from '../../router/route-ids';\nimport { onSallaEvent, whenSallaLoaded } from '../../utils/sdk-helpers';\nimport {\n gtmCartCheckout,\n gtmCustomer,\n gtmDetail,\n gtmEnabled,\n gtmImpressions,\n gtmPage,\n gtmPurchase,\n gtmStore,\n pushToDataLayer,\n servicesInitEvents,\n type DataLayerEntry,\n} from './gtm';\n\n/** How long the first page waits for its customer or its cart before it is pushed without. */\nexport const GTM_PAGE_DATA_WAIT_MS = 3000;\n\nlet queue: Promise<void> = Promise.resolve();\nlet firstPageReported = false;\nlet previousUrl: string | null = null;\nlet markPageDataReady: () => void = () => {};\nlet pageDataReady = new Promise<void>((resolve) => (markPageDataReady = resolve));\nlet stopImpressions: (() => void) | null = null;\n/** Orders this document has pushed a `purchase` for, whether or not GTM has taken it yet. */\nlet purchasesPushed = new Set<string>();\n\n/** Resolves once the first page's data is in the data layer, as Twig's head pushes it before GTM. */\nexport function whenGtmPageData(): Promise<void> {\n return pageDataReady;\n}\n\nfunction settingsOrUndefined(): StoreContext | undefined {\n try {\n return getTwilightContext().settings;\n } catch {\n return undefined;\n }\n}\n\nfunction enqueue(task: () => void | Promise<void>): void {\n queue = queue.then(task).catch((error: unknown) => {\n console.warn('[gtm] Could not push to the data layer:', error);\n });\n}\n\nfunction withDeadline<T>(value: T | Promise<T>, fallback: T): Promise<T> {\n let timer: ReturnType<typeof setTimeout> | undefined;\n const deadline = new Promise<T>((resolve) => {\n timer = setTimeout(() => resolve(fallback), GTM_PAGE_DATA_WAIT_MS);\n });\n return Promise.race([Promise.resolve(value), deadline])\n .catch(() => fallback)\n .finally(() => clearTimeout(timer));\n}\n\n/** The signed-in customer, from the query `useUser` already loads; a guest has no token. */\nasync function currentUser(): Promise<User | null> {\n const { authToken, queryClient } = getTwilightContext();\n if (!authToken || !queryClient) return null;\n return withDeadline(\n queryClient.ensureQueryData(userApi.queries.current()).catch(() => null),\n null\n );\n}\n\n/** The Salla app's webview: the SDK knows once loaded, the settings carry the app's headers before. */\nfunction inNativeApp(settings: StoreContext | undefined): boolean {\n const os = settings?.jitsu?.context?.extra?.headers?.['s-app-os']?.toLowerCase();\n return os === 'ios' || os === 'android' || isNativeApp();\n}\n\n/**\n * The `user` Twig's `twilight::init` carries (the SDK's own config), as far as tags read it:\n * Salla's container identifies the customer to a chat service from `user.id` when that\n * service's `services::<name>.init` arrives, which is before the SDK pushes a user of its own.\n */\nfunction initUser(settings: StoreContext | undefined, user: User | null): DataLayerEntry {\n const visitor = settings?.user;\n return {\n id: user ? (user.id ?? null) : (visitor?.id ?? null),\n type: user ? 'user' : (visitor?.type ?? 'guest'),\n country_code: user?.country_code ?? visitor?.country_code,\n language_code: visitor?.language_code,\n currency_code: visitor?.currency_code,\n };\n}\n\n/** `twilight::init`, then each `services::<name>.init`, once per document, as Twig's page does. */\nfunction announceServices(settings: StoreContext | undefined, user: User | null): void {\n const snippetServices = (getTwilightContext().appsSnippets ?? []).map((app) => app.service);\n const events = servicesInitEvents(settings?.external_services, snippetServices);\n whenSallaLoaded((sdk) => {\n // The engine calls `salla.init` itself; Twig hands it the event, which the SDK records.\n pushToDataLayer({ event: 'twilight::init', user: initUser(settings, user) });\n for (const [name, payload] of events) sdk.event.dispatch(name, payload);\n });\n}\n\nexport interface GtmPageView {\n page: PageContext;\n /** The page's ecommerce block, or a promise of it: the cart loads in the browser. */\n ecommerce?: DataLayerEntry | Promise<DataLayerEntry | null> | null;\n}\n\n/** Push a page's data, once per page view: the first opens the document's data layer. */\nexport function reportGtmPageView(view: GtmPageView): void {\n if (typeof window === 'undefined') return;\n const settings = settingsOrUndefined();\n if (!gtmEnabled(settings)) {\n markPageDataReady();\n return;\n }\n watchListImpressions();\n\n const first = !firstPageReported;\n firstPageReported = true;\n // `url()->previous()`: the page before, or the store itself when the visitor came from nowhere.\n const referrer = (first ? document.referrer : previousUrl) || window.location.origin;\n previousUrl = window.location.href;\n\n enqueue(async () => {\n const [user, ecommerce] = await Promise.all([\n currentUser(),\n withDeadline(view.ecommerce ?? null, null),\n ]);\n const customer = await gtmCustomer(user, settings);\n const page = gtmPage(\n { slug: view.page.slug, referrer, mobileApp: inNativeApp(settings) },\n settings\n );\n if (first) {\n const entry = { ...ecommerce, page, store: gtmStore(settings), customer };\n pushToDataLayer(entry);\n rememberPurchaseOnceReceived(entry);\n announceServices(settings, user);\n markPageDataReady();\n return;\n }\n // GTM merges each push into what it holds: a guest's `{ isGuest: true }` would keep the\n // signed-out customer's details, and a shorter product list the last page's extra lines.\n pushToDataLayer({ customer: null, ecommerce: null });\n pushToDataLayer({ page, customer });\n if (ecommerce) {\n pushToDataLayer(ecommerce);\n rememberPurchaseOnceReceived(ecommerce);\n }\n });\n}\n\n/** How long a browser remembers an order it reported, as `SeoThankYouWidget` caches it. */\nconst PURCHASE_REMEMBERED_MS = 24 * 60 * 60 * 1000;\n/** How often, and for how long, a pushed purchase is checked for GTM having taken it. */\nexport const PURCHASE_RECEIVED_POLL_MS = 500;\nconst PURCHASE_RECEIVED_WAIT_MS = 60_000;\nconst purchaseKey = (orderId: unknown) => `google_tagged_order_${String(orderId)}`;\n\nfunction reportedRecently(orderId: unknown): boolean {\n try {\n const at = Number(window.localStorage.getItem(purchaseKey(orderId)));\n return Boolean(at) && Date.now() - at < PURCHASE_REMEMBERED_MS;\n } catch {\n // No storage (a private window): report it, as a Twig page would the first time.\n return false;\n }\n}\n\n/**\n * Remember a pushed `purchase` once GTM has taken it (GTM stamps `gtm.uniqueEventId` on each\n * message it handles). GTM loads seconds after the page here, so a shopper who leaves before\n * then has reported nothing, and the next visit reports it. Twig renders the push and its\n * container together, so it remembers the order as it renders the page.\n */\nfunction rememberPurchaseOnceReceived(entry: DataLayerEntry): void {\n if (entry.event !== 'purchase') return;\n const orderId = (entry.ecommerce as { event_id?: unknown } | undefined)?.event_id;\n const started = Date.now();\n const check = () => {\n if ('gtm.uniqueEventId' in entry) {\n try {\n window.localStorage.setItem(purchaseKey(orderId), String(Date.now()));\n } catch {\n // No storage: nothing to remember it in.\n }\n } else if (Date.now() - started < PURCHASE_RECEIVED_WAIT_MS) {\n setTimeout(check, PURCHASE_RECEIVED_POLL_MS);\n }\n };\n check();\n}\n\n/**\n * An order's `purchase`, once: Twig caches each order it reported for a day, so a reload of\n * the thank-you page counts nothing. Not inside the Salla app, which logs the order itself.\n */\nfunction purchaseOnce(order: Order, settings: StoreContext | undefined): DataLayerEntry | null {\n const id = String(order.id);\n // A return to the page in this document waits on the first push; only a new load retries.\n if (inNativeApp(settings) || purchasesPushed.has(id) || reportedRecently(order.id)) return null;\n purchasesPushed.add(id);\n return gtmPurchase(order, settings);\n}\n\nexport interface GtmPageEcommerceInput {\n slug: string;\n product?: Product;\n order?: Order;\n /** The cart page's cart, once the page has loaded it. */\n cart?: Promise<Cart | null> | null;\n}\n\n/** A page's own ecommerce block: a product's `detail`, the cart's `checkout`, an order's `purchase`. */\nexport function gtmPageEcommerce(input: GtmPageEcommerceInput): GtmPageView['ecommerce'] {\n if (typeof window === 'undefined') return null;\n const settings = settingsOrUndefined();\n if (!gtmEnabled(settings)) return null;\n if (input.slug === RouteId.PRODUCT_SINGLE && input.product)\n return gtmDetail(input.product, settings);\n if (input.slug === RouteId.CART && input.cart)\n return input.cart.then((cart) => (cart ? gtmCartCheckout(cart, settings) : null));\n if (input.slug === RouteId.THANK_YOU && input.order) return purchaseOnce(input.order, settings);\n return null;\n}\n\n/**\n * `impressions` for each page of a product listing the engine or the theme reports through\n * `salla-products-list::products.fetched`, as `<salla-products-list>` pushes on Twig. That\n * component pushes its own before it emits the API's answer (`success`), so those are skipped.\n * Each batch first clears the last one's list (GTM merges arrays index by index), and only that:\n * the page's own block, such as the cart's `checkout`, stays for the tags still to read it.\n */\nfunction watchListImpressions(): void {\n if (stopImpressions) return;\n stopImpressions = onSallaEvent('salla-products-list::products.fetched', (payload) => {\n const fetched = payload as { data?: unknown; success?: unknown } | undefined;\n if (!Array.isArray(fetched?.data) || typeof fetched.success === 'boolean') return;\n const products = fetched.data as Product[];\n const settings = settingsOrUndefined();\n if (!products.length || !gtmEnabled(settings)) return;\n // The page the products were fetched for, not the one the queue gets to them on.\n const impressions = gtmImpressions(products, getTwilightContext().page ?? undefined, settings);\n enqueue(() => {\n pushToDataLayer({ ecommerce: { impressions: null } });\n pushToDataLayer(impressions);\n });\n });\n}\n\n/** Test seam: forget the document's first page and every listener. */\nexport function resetGtmPageTracking(): void {\n stopImpressions?.();\n stopImpressions = null;\n queue = Promise.resolve();\n firstPageReported = false;\n previousUrl = null;\n purchasesPushed = new Set();\n pageDataReady = new Promise<void>((resolve) => (markPageDataReady = resolve));\n}\n\n/** Test seam: settle every push queued so far. */\nexport function flushGtmQueue(): Promise<void> {\n return queue;\n}\n"]}
@@ -1,5 +1,5 @@
1
- import { ProductPrice } from './chunk-QCXWLQCL.js';
2
- import { getProductPreview } from './chunk-FF5HNVZ7.js';
1
+ import { ProductPrice } from './chunk-MVOHDJRG.js';
2
+ import { getProductPreview } from './chunk-ZB734AWC.js';
3
3
  import { Image } from './chunk-IVO6YRRK.js';
4
4
  export { BlogSkeleton, BreadcrumbSkeleton, CartSkeleton, CustomerLayoutSkeleton, CustomerPageSkeleton, PageSkeleton, ProductCardSkeleton, ProductDetailSkeleton, ProductGridSkeleton, SkeletonPulse } from '@salla.sa/twilight-components-react';
5
5
  import { useMemo } from 'react';
@@ -49,5 +49,5 @@ function ProductDetailPreview({ product }) {
49
49
  }
50
50
 
51
51
  export { ProductDetailPreview, ProductPendingPreview };
52
- //# sourceMappingURL=chunk-IQS7EDB3.js.map
53
- //# sourceMappingURL=chunk-IQS7EDB3.js.map
52
+ //# sourceMappingURL=chunk-UCEIFCFW.js.map
53
+ //# sourceMappingURL=chunk-UCEIFCFW.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/routes/product/ProductPendingPreview.tsx"],"names":[],"mappings":";;;;;;;;;AAsBO,SAAS,sBAAsB,EAAE,EAAA,EAAI,MAAA,EAAO,GAAqB,EAAC,EAAG;AAC1E,EAAA,MAAM,MAAA,GAAS,SAAA,CAAU,EAAE,MAAA,EAAQ,OAAO,CAAA;AAC1C,EAAA,MAAM,EAAA,GAAK,UAAU,MAAA,CAAO,EAAA;AAC5B,EAAA,MAAM,OAAA,GAAU,OAAA,CAAQ,MAAO,EAAA,GAAK,iBAAA,CAAkB,EAAE,CAAA,GAAI,MAAA,EAAY,CAAC,EAAE,CAAC,CAAA;AAE5E,EAAA,IAAI,CAAC,OAAA,EAAS,IAAA,EAAM,2BAAQ,qBAAA,EAAA,EAAsB,CAAA;AAClD,EAAA,uBAAO,GAAA,CAAC,wBAAqB,OAAA,EAA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A,sBACA,IAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAU,2BAAA,EACb,QAAA,EAAA;AAAA,wBAAA,GAAA,CAAC,IAAA,EAAA,EAAG,SAAA,EAAU,wDAAA,EACX,QAAA,EAAA,OAAA,CAAQ,IAAA,EACX,CAAA;AAAA,QACC,QAAQ,QAAA,oBACP,GAAA,CAAC,QAAG,SAAA,EAAU,0DAAA,EACX,kBAAQ,QAAA,EACX,CAAA;AAAA,wBAEF,GAAA,CAAC,gBAAa,OAAA,EAAkB,CAAA;AAAA,wBAChC,IAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAU,+BAAA,EACb,QAAA,EAAA;AAAA,0BAAA,GAAA,CAAC,aAAA,EAAA,EAAc,WAAU,2BAAA,EAA4B,CAAA;AAAA,0BACrD,GAAA,CAAC,aAAA,EAAA,EAAc,SAAA,EAAU,yBAAA,EAA0B,CAAA;AAAA,0BACnD,GAAA,CAAC,aAAA,EAAA,EAAc,SAAA,EAAU,yBAAA,EAA0B;AAAA,SAAA,EACrD,CAAA;AAAA,wBACA,GAAA,CAAC,SAAI,SAAA,EAAU,2BAAA,EACb,8BAAC,aAAA,EAAA,EAAc,SAAA,EAAU,6BAA4B,CAAA,EACvD;AAAA,OAAA,EACF;AAAA,KAAA,EACF;AAAA,GAAA,EACF,CAAA,EACF,CAAA;AAEJ","file":"chunk-IQS7EDB3.js","sourcesContent":["import { useMemo } from 'react';\nimport { useParams } from '@tanstack/react-router';\nimport {\n BreadcrumbSkeleton,\n ProductDetailSkeleton,\n SkeletonPulse,\n} from '@salla.sa/twilight-components-react/skeletons';\nimport { getProductPreview } from '../../api/product';\nimport { Image } from '../../components/common/Image';\nimport { ProductPrice } from '../../components/product/ProductDetails';\nimport type { Product } from '../../types';\n\n/**\n * Product route `pendingComponent`. When the shopper opens a product from a card, the\n * list already gave us its name, price and image (`rememberProductPreview`), so paint\n * those in the product page's layout while details load, not a blank skeleton.\n * Without a remembered card (deep link, SKU link) it is `ProductDetailSkeleton`.\n * `id` defaults to the route's `id` param.\n *\n * Only plain markup: no gallery slider, form, hook slots or `salla-*` widgets, which\n * would start (and fetch) for the stand-in and again when the real page mounts.\n */\nexport function ProductPendingPreview({ id: idProp }: { id?: string } = {}) {\n const params = useParams({ strict: false }) as { id?: string };\n const id = idProp ?? params.id;\n const product = useMemo(() => (id ? getProductPreview(id) : undefined), [id]);\n\n if (!product?.name) return <ProductDetailSkeleton />;\n return <ProductDetailPreview product={product} />;\n}\n\n/** `ProductDetailSkeleton`'s boxes, with the card's image, name and price filled in. */\nexport function ProductDetailPreview({ product }: { product: Product }) {\n const image = product.image?.url ? product.image : product.images?.[0];\n\n return (\n <div data-product-preview={product.id}>\n <div className=\"s-skeleton-detail-container\">\n <BreadcrumbSkeleton />\n <div className=\"s-skeleton-detail-layout\">\n <div className=\"s-skeleton-detail-images\">\n {image?.url ? (\n <div className=\"s-skeleton-card-image overflow-hidden bg-gray-100\">\n <Image\n src={image.url}\n alt={image.alt || product.name}\n className=\"h-full w-full object-cover\"\n aspectRatio=\"1/1\"\n priority\n noWrapper\n />\n </div>\n ) : (\n <SkeletonPulse className=\"s-skeleton-card-image\" />\n )}\n <div className=\"s-skeleton-slider-thumbs\">\n {Array.from({ length: 3 }, (_, i) => (\n <SkeletonPulse key={i} className=\"s-skeleton-slider-thumb\" />\n ))}\n </div>\n </div>\n <div className=\"s-skeleton-detail-content\">\n <h1 className=\"text-xl md:text-2xl leading-10 font-bold text-gray-800\">\n {product.name}\n </h1>\n {product.subtitle && (\n <h2 className=\"product-entry__sub-title text-sm text-gray-500 leading-6\">\n {product.subtitle}\n </h2>\n )}\n <ProductPrice product={product} />\n <div className=\"s-skeleton-detail-description\">\n <SkeletonPulse className=\"s-skeleton-text-line-full\" />\n <SkeletonPulse className=\"s-skeleton-text-line-lg\" />\n <SkeletonPulse className=\"s-skeleton-text-line-sm\" />\n </div>\n <div className=\"s-skeleton-detail-actions\">\n <SkeletonPulse className=\"s-skeleton-detail-add-btn\"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AAAA,wBACA,GAAA,CAAC,SAAI,SAAA,EAAU,2BAAA,EACb,8BAAC,aAAA,EAAA,EAAc,SAAA,EAAU,6BAA4B,CAAA,EACvD;AAAA,OAAA,EACF;AAAA,KAAA,EACF;AAAA,GAAA,EACF,CAAA,EACF,CAAA;AAEJ","file":"chunk-UCEIFCFW.js","sourcesContent":["import { useMemo } from 'react';\nimport { useParams } from '@tanstack/react-router';\nimport {\n BreadcrumbSkeleton,\n ProductDetailSkeleton,\n SkeletonPulse,\n} from '@salla.sa/twilight-components-react/skeletons';\nimport { getProductPreview } from '../../api/product';\nimport { Image } from '../../components/common/Image';\nimport { ProductPrice } from '../../components/product/ProductDetails';\nimport type { Product } from '../../types';\n\n/**\n * Product route `pendingComponent`. When the shopper opens a product from a card, the\n * list already gave us its name, price and image (`rememberProductPreview`), so paint\n * those in the product page's layout while details load, not a blank skeleton.\n * Without a remembered card (deep link, SKU link) it is `ProductDetailSkeleton`.\n * `id` defaults to the route's `id` param.\n *\n * Only plain markup: no gallery slider, form, hook slots or `salla-*` widgets, which\n * would start (and fetch) for the stand-in and again when the real page mounts.\n */\nexport function ProductPendingPreview({ id: idProp }: { id?: string } = {}) {\n const params = useParams({ strict: false }) as { id?: string };\n const id = idProp ?? params.id;\n const product = useMemo(() => (id ? getProductPreview(id) : undefined), [id]);\n\n if (!product?.name) return <ProductDetailSkeleton />;\n return <ProductDetailPreview product={product} />;\n}\n\n/** `ProductDetailSkeleton`'s boxes, with the card's image, name and price filled in. */\nexport function ProductDetailPreview({ product }: { product: Product }) {\n const image = product.image?.url ? product.image : product.images?.[0];\n\n return (\n <div data-product-preview={product.id}>\n <div className=\"s-skeleton-detail-container\">\n <BreadcrumbSkeleton />\n <div className=\"s-skeleton-detail-layout\">\n <div className=\"s-skeleton-detail-images\">\n {image?.url ? (\n <div className=\"s-skeleton-card-image overflow-hidden bg-gray-100\">\n <Image\n src={image.url}\n alt={image.alt || product.name}\n className=\"h-full w-full object-cover\"\n aspectRatio=\"1/1\"\n priority\n noWrapper\n />\n </div>\n ) : (\n <SkeletonPulse className=\"s-skeleton-card-image\" />\n )}\n <div className=\"s-skeleton-slider-thumbs\">\n {Array.from({ length: 3 }, (_, i) => (\n <SkeletonPulse key={i} className=\"s-skeleton-slider-thumb\" />\n ))}\n </div>\n </div>\n <div className=\"s-skeleton-detail-content\">\n <h1 className=\"text-xl md:text-2xl leading-10 font-bold text-gray-800\">\n {product.name}\n </h1>\n {product.subtitle && (\n <h2 className=\"product-entry__sub-title text-sm text-gray-500 leading-6\">\n {product.subtitle}\n </h2>\n )}\n <ProductPrice product={product} />\n <div className=\"s-skeleton-detail-description\">\n <SkeletonPulse className=\"s-skeleton-text-line-full\" />\n <SkeletonPulse className=\"s-skeleton-text-line-lg\" />\n <SkeletonPulse className=\"s-skeleton-text-line-sm\" />\n </div>\n <div className=\"s-skeleton-detail-actions\">\n <SkeletonPulse className=\"s-skeleton-detail-add-btn\" />\n </div>\n </div>\n </div>\n </div>\n </div>\n );\n}\n"]}
@@ -1,5 +1,5 @@
1
- import { GTM_PAGE_DATA_WAIT_MS, whenGtmPageData } from './chunk-USEGCCT3.js';
2
- import { DATA_LAYER_PROXY_SCRIPT } from './chunk-U5QRBIEL.js';
1
+ import { GTM_PAGE_DATA_WAIT_MS, whenGtmPageData } from './chunk-S2ZVONKA.js';
2
+ import { DATA_LAYER_PROXY_SCRIPT } from './chunk-X7QELNMF.js';
3
3
  import { useEffect } from 'react';
4
4
 
5
5
  function containerScript(gtmId) {
@@ -63,5 +63,5 @@ function GoogleTagBody({ gtmIds }) {
63
63
  }
64
64
 
65
65
  export { GTM_LOAD_DELAY_MS, GoogleTagBody };
66
- //# sourceMappingURL=chunk-TQW7A42X.js.map
67
- //# sourceMappingURL=chunk-TQW7A42X.js.map
66
+ //# sourceMappingURL=chunk-VCTBBPKU.js.map
67
+ //# sourceMappingURL=chunk-VCTBBPKU.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/tracking/GoogleTag.tsx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CAAe,YAAY,CAAA,EAAG,MAAA,EAAO;AAAA,IAChD,CAAA;AAAA,EACF,CAAA,EAAG,CAAC,MAAM,CAAC,CAAA;AAEX,EAAA,OAAO,IAAA;AACT","file":"chunk-TQW7A42X.js","sourcesContent":["import { useEffect } from 'react';\nimport { DATA_LAYER_PROXY_SCRIPT } from '../../lib/analytics/gtm';\nimport { GTM_PAGE_DATA_WAIT_MS, whenGtmPageData } from '../../lib/analytics/gtm-page';\n\nexport interface GoogleTagBodyProps {\n /** GTM container IDs; every one is loaded, as on Twig. Empty or missing renders nothing. */\n gtmIds?: string[];\n}\n\n/** One container's loader, Google's snippet. */\nfunction containerScript(gtmId: string): string {\n return `(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':\nnew Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],\nj=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=\n'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);\n})(window,document,'script','dataLayer',${JSON.stringify(gtmId)});`;\n}\n\n/** Every container, in the settings' order: Salla's first, then the merchant's own. */\nfunction gtmScript(gtmIds: readonly string[]): string {\n return [DATA_LAYER_PROXY_SCRIPT, ...gtmIds.map(containerScript)].join('\\n');\n}\n\nconst INTERACTION_EVENTS = ['pointerdown', 'keydown', 'touchstart', 'scroll', 'wheel'] as const;\n\n/** How long after `load` GTM waits for a visitor who never interacts. */\nexport const GTM_LOAD_DELAY_MS = 4000;\n\n/** Distinct container ids, in order. */\nfunction containerIds(gtmIds: readonly string[] | undefined): string[] {\n return [...new Set((gtmIds ?? []).map((id) => id?.trim()).filter(Boolean))];\n}\n\n/**\n * Injects GTM on the first interaction or GTM_LOAD_DELAY_MS after `load`, off the page's load\n * path, once the first page's data is in the data layer (at most GTM_PAGE_DATA_WAIT_MS later).\n */\nexport function GoogleTagBody({ gtmIds }: GoogleTagBodyProps): null {\n const ids = containerIds(gtmIds);\n const idsKey = ids.join(',');\n\n useEffect(() => {\n const containers = idsKey ? idsKey.split(',') : [];\n if (!containers.length) return;\n\n let timer: number | undefined;\n let pageDataTimer: number | undefined;\n let cancelled = false;\n const stopWaiting = () => {\n window.clearTimeout(timer);\n window.removeEventListener('load', onLoad);\n INTERACTION_EVENTS.forEach((type) => window.removeEventListener(type, inject));\n };\n function append() {\n window.clearTimeout(pageDataTimer);\n if (cancelled || document.getElementById('gtm-script')) return;\n const script = document.createElement('script');\n script.id = 'gtm-script';\n script.textContent = gtmScript(containers);\n document.head.appendChild(script);\n }\n function inject() {\n stopWaiting();\n // A container's tags read the page's data when `gtm.js` fires, as on Twig.\n pageDataTimer = window.setTimeout(append, GTM_PAGE_DATA_WAIT_MS);\n void whenGtmPageData().then(append);\n }\n function onLoad() {\n timer = window.setTimeout(inject, GTM_LOAD_DELAY_MS);\n }\n\n INTERACTION_EVENTS.forEach((type) =>\n window.addEventListener(type, inject, { once: true, passive: true })\n );\n if (document.readyState === 'complete') onLoad();\n else window.addEventListener('load', onLoad, { once: true });\n\n return () => {\n cancelled = true;\n stopWaiting();\n window.clearTimeout(pageDataTimer);\n document.getElementById('gtm-script')?.remove();\n };\n }, [idsKey]);\n\n return null;\n}\n"]}
1
+ {"version":3,"sources":["../src/components/tracking/GoogleTag.tsx"],"names":[],"mappings":";;;;AAUA,SAAS,gBAAgB,KAAA,EAAuB;AAC9C,EAAA,OAAO,CAAA;AAAA;AAAA;AAAA;AAAA,wCAAA,EAIiC,IAAA,CAAK,SAAA,CAAU,KAAK,CAAC,CAAA,EAAA,CAAA;AAC/D;AAGA,SAAS,UAAU,MAAA,EAAmC;AACpD,EAAA,OAAO,CAAC,yBAAyB,GAAG,MAAA,CAAO,IAAI,eAAe,CAAC,CAAA,CAAE,IAAA,CAAK,IAAI,CAAA;AAC5E;AAEA,IAAM,qBAAqB,CAAC,aAAA,EAAe,SAAA,EAAW,YAAA,EAAc,UAAU,OAAO,CAAA;AAG9E,IAAM,iBAAA,GAAoB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ClC;AACA,IAAA,SAAS,MAAA,GAAS;AAChB,MAAA,WAAA,EAAY;AAEZ,MAAA,aAAA,GAAgB,MAAA,CAAO,UAAA,CAAW,MAAA,EAAQ,qBAAqB,CAAA;AAC/D,MAAA,KAAK,eAAA,EAAgB,CAAE,IAAA,CAAK,MAAM,CAAA;AAAA,IACpC;AACA,IAAA,SAAS,MAAA,GAAS;AAChB,MAAA,KAAA,GAAQ,MAAA,CAAO,UAAA,CAAW,MAAA,EAAQ,iBAAiB,CAAA;AAAA,IACrD;AAEA,IAAA,kBAAA,CAAmB,OAAA;AAAA,MAAQ,CAAC,IAAA,KAC1B,MAAA,CAAO,gBAAA,CAAiB,IAAA,EAAM,MAAA,EAAQ,EAAE,IAAA,EAAM,IAAA,EAAM,OAAA,EAAS,IAAA,EAAM;AAAA,KACrE;AACA,IAAA,IAAI,QAAA,CAAS,UAAA,KAAe,UAAA,EAAY,MAAA,EAAO;AAAA,gBACnC,gBAAA,CAAiB,MAAA,EAAQ,QAAQ,EAAE,IAAA,EAAM,MAAM,CAAA;AAE3D,IAAA,OAAO,MAAM;AACX,MAAA,SAAA,GAAY,IAAA;AACZ,MAAA,WAAA,EAAY;AACZ,MAAA,MAAA,CAAO,aAAa,aAAa,CAAA;AACjC,MAAA,QAAA,CAAS,cAAA,CAAe,YAAY,CAAA,EAAG,MAAA,EAAO;AAAA,IAChD,CAAA;AAAA,EACF,CAAA,EAAG,CAAC,MAAM,CAAC,CAAA;AAEX,EAAA,OAAO,IAAA;AACT","file":"chunk-VCTBBPKU.js","sourcesContent":["import { useEffect } from 'react';\nimport { DATA_LAYER_PROXY_SCRIPT } from '../../lib/analytics/gtm';\nimport { GTM_PAGE_DATA_WAIT_MS, whenGtmPageData } from '../../lib/analytics/gtm-page';\n\nexport interface GoogleTagBodyProps {\n /** GTM container IDs; every one is loaded, as on Twig. Empty or missing renders nothing. */\n gtmIds?: string[];\n}\n\n/** One container's loader, Google's snippet. */\nfunction containerScript(gtmId: string): string {\n return `(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':\nnew Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],\nj=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=\n'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);\n})(window,document,'script','dataLayer',${JSON.stringify(gtmId)});`;\n}\n\n/** Every container, in the settings' order: Salla's first, then the merchant's own. */\nfunction gtmScript(gtmIds: readonly string[]): string {\n return [DATA_LAYER_PROXY_SCRIPT, ...gtmIds.map(containerScript)].join('\\n');\n}\n\nconst INTERACTION_EVENTS = ['pointerdown', 'keydown', 'touchstart', 'scroll', 'wheel'] as const;\n\n/** How long after `load` GTM waits for a visitor who never interacts. */\nexport const GTM_LOAD_DELAY_MS = 4000;\n\n/** Distinct container ids, in order. */\nfunction containerIds(gtmIds: readonly string[] | undefined): string[] {\n return [...new Set((gtmIds ?? []).map((id) => id?.trim()).filter(Boolean))];\n}\n\n/**\n * Injects GTM on the first interaction or GTM_LOAD_DELAY_MS after `load`, off the page's load\n * path, once the first page's data is in the data layer (at most GTM_PAGE_DATA_WAIT_MS later).\n */\nexport function GoogleTagBody({ gtmIds }: GoogleTagBodyProps): null {\n const ids = containerIds(gtmIds);\n const idsKey = ids.join(',');\n\n useEffect(() => {\n const containers = idsKey ? idsKey.split(',') : [];\n if (!containers.length) return;\n\n let timer: number | undefined;\n let pageDataTimer: number | undefined;\n let cancelled = false;\n const stopWaiting = () => {\n window.clearTimeout(timer);\n window.removeEventListener('load', onLoad);\n INTERACTION_EVENTS.forEach((type) => window.removeEventListener(type, inject));\n };\n function append() {\n window.clearTimeout(pageDataTimer);\n if (cancelled || document.getElementById('gtm-script')) return;\n const script = document.createElement('script');\n script.id = 'gtm-script';\n script.textContent = gtmScript(containers);\n document.head.appendChild(script);\n }\n function inject() {\n stopWaiting();\n // A container's tags read the page's data when `gtm.js` fires, as on Twig.\n pageDataTimer = window.setTimeout(append, GTM_PAGE_DATA_WAIT_MS);\n void whenGtmPageData().then(append);\n }\n function onLoad() {\n timer = window.setTimeout(inject, GTM_LOAD_DELAY_MS);\n }\n\n INTERACTION_EVENTS.forEach((type) =>\n window.addEventListener(type, inject, { once: true, passive: true })\n );\n if (document.readyState === 'complete') onLoad();\n else window.addEventListener('load', onLoad, { once: true });\n\n return () => {\n cancelled = true;\n stopWaiting();\n window.clearTimeout(pageDataTimer);\n document.getElementById('gtm-script')?.remove();\n };\n }, [idsKey]);\n\n return null;\n}\n"]}
@@ -1,5 +1,5 @@
1
- import { orThrow } from './chunk-FLPDMPVB.js';
2
- import { getAuthToken, api } from './chunk-BM43QN4L.js';
1
+ import { orThrow } from './chunk-DEUF6LFD.js';
2
+ import { getAuthToken, api } from './chunk-YJMUVRXD.js';
3
3
  import { queryOptions } from '@tanstack/react-query';
4
4
 
5
5
  var loyalty = {
@@ -29,5 +29,5 @@ var loyalty = {
29
29
  };
30
30
 
31
31
  export { loyalty };
32
- //# sourceMappingURL=chunk-HPKOZDZC.js.map
33
- //# sourceMappingURL=chunk-HPKOZDZC.js.map
32
+ //# sourceMappingURL=chunk-WFLTAF4V.js.map
33
+ //# sourceMappingURL=chunk-WFLTAF4V.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/api/loyalty.ts"],"names":[],"mappings":";;;;AAKO,IAAM,OAAA,GAAU;AAAA,EACrB,KAAK,YAA8B;AACjC,IAAA,MAAM,EAAE,MAAK,GAAI,MAAM,IAAI,GAAA,CAAI,SAAS,EAAE,IAAA,EAAwB;AAClE,IAAA,OAAO,IAAA;AAAA,EACT,CAAA;AAAA,EAEA,UAAA,EAAY,MAAwB,OAAA,CAAQ,OAAA,CAAQ,KAAK,CAAA;AAAA,EAEzD,kBAAkB,YAA6B;AAC7C,IAAA,MAAM,WAAW,MAAM,GAAA,CAAI,GAAA,CAAI,gBAAgB,EAAE,IAAA,EAA2B;AAC5E,IAAA,OAAO,QAAA,CAAS,OAAA;AAAA,EAClB,CAAA;AAAA,EAEA,OAAA,EAAS;AAAA,IACP,MAAA,EAAQ,MACN,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,CAAC,SAAS,CAAA;AAAA,MACpB,OAAA,EAAS,MAAM,OAAA,CAAQ,GAAA;AAAI,KAC5B,CAAA;AAAA,IACH,MAAA,EAAQ,MACN,YAAA,CAA4B;AAAA,MAC1B,QAAA,EAAU,CAAC,SAAA,EAAW,QAAQ,CAAA;AAAA,MAC9B,OAAA,EAAS,MAAM,OAAA,CAAQ,gBAAA,EAAiB;AAAA;AAAA;AAAA,MAGxC,OAAA,EAAS,CAAC,CAAC,YAAA,EAAa;AAAA,MACxB,SAAA,EAAW;AAAA,KACZ;AAAA;AAEP","file":"chunk-HPKOZDZC.js","sourcesContent":["import { queryOptions } from '@tanstack/react-query';\nimport { api, getAuthToken } from './client';\nimport type { Loyalty, PointBalanceResponse } from '../routes/loyalty/types';\nimport { orThrow } from '../providers/NavigationProvider';\n\nexport const loyalty = {\n get: async (): Promise<Loyalty> => {\n const { data } = await api.get('loyalty').json<{ data: Loyalty }>();\n return data;\n },\n\n getOrThrow: (): Promise<Loyalty> => orThrow(loyalty.get()),\n\n getPointsBalance: async (): Promise<number> => {\n const response = await api.get('balance/points').json<PointBalanceResponse>();\n return response.balance;\n },\n\n queries: {\n detail: () =>\n queryOptions({\n queryKey: ['loyalty'],\n queryFn: () => loyalty.get(),\n }),\n points: () =>\n queryOptions<number | null>({\n queryKey: ['loyalty', 'points'],\n queryFn: () => loyalty.getPointsBalance(),\n // Points are customer-scoped; skip for guests (no token) — the request would\n // otherwise 400 with `token_not_provided`.\n enabled: !!getAuthToken(),\n staleTime: 30_000,\n }),\n },\n};\n"]}
1
+ {"version":3,"sources":["../src/api/loyalty.ts"],"names":[],"mappings":";;;;AAKO,IAAM,OAAA,GAAU;AAAA,EACrB,KAAK,YAA8B;AACjC,IAAA,MAAM,EAAE,MAAK,GAAI,MAAM,IAAI,GAAA,CAAI,SAAS,EAAE,IAAA,EAAwB;AAClE,IAAA,OAAO,IAAA;AAAA,EACT,CAAA;AAAA,EAEA,UAAA,EAAY,MAAwB,OAAA,CAAQ,OAAA,CAAQ,KAAK,CAAA;AAAA,EAEzD,kBAAkB,YAA6B;AAC7C,IAAA,MAAM,WAAW,MAAM,GAAA,CAAI,GAAA,CAAI,gBAAgB,EAAE,IAAA,EAA2B;AAC5E,IAAA,OAAO,QAAA,CAAS,OAAA;AAAA,EAClB,CAAA;AAAA,EAEA,OAAA,EAAS;AAAA,IACP,MAAA,EAAQ,MACN,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,CAAC,SAAS,CAAA;AAAA,MACpB,OAAA,EAAS,MAAM,OAAA,CAAQ,GAAA;AAAI,KAC5B,CAAA;AAAA,IACH,MAAA,EAAQ,MACN,YAAA,CAA4B;AAAA,MAC1B,QAAA,EAAU,CAAC,SAAA,EAAW,QAAQ,CAAA;AAAA,MAC9B,OAAA,EAAS,MAAM,OAAA,CAAQ,gBAAA,EAAiB;AAAA;AAAA;AAAA,MAGxC,OAAA,EAAS,CAAC,CAAC,YAAA,EAAa;AAAA,MACxB,SAAA,EAAW;AAAA,KACZ;AAAA;AAEP","file":"chunk-WFLTAF4V.js","sourcesContent":["import { queryOptions } from '@tanstack/react-query';\nimport { api, getAuthToken } from './client';\nimport type { Loyalty, PointBalanceResponse } from '../routes/loyalty/types';\nimport { orThrow } from '../providers/NavigationProvider';\n\nexport const loyalty = {\n get: async (): Promise<Loyalty> => {\n const { data } = await api.get('loyalty').json<{ data: Loyalty }>();\n return data;\n },\n\n getOrThrow: (): Promise<Loyalty> => orThrow(loyalty.get()),\n\n getPointsBalance: async (): Promise<number> => {\n const response = await api.get('balance/points').json<PointBalanceResponse>();\n return response.balance;\n },\n\n queries: {\n detail: () =>\n queryOptions({\n queryKey: ['loyalty'],\n queryFn: () => loyalty.get(),\n }),\n points: () =>\n queryOptions<number | null>({\n queryKey: ['loyalty', 'points'],\n queryFn: () => loyalty.getPointsBalance(),\n // Points are customer-scoped; skip for guests (no token) — the request would\n // otherwise 400 with `token_not_provided`.\n enabled: !!getAuthToken(),\n staleTime: 30_000,\n }),\n },\n};\n"]}
@@ -1,4 +1,4 @@
1
- import { advertisement, advertisementsFor } from './chunk-DYY7Y7DZ.js';
1
+ import { advertisement, advertisementsFor } from './chunk-E273CZGJ.js';
2
2
  import { useTranslation } from './chunk-TYNZ5B2B.js';
3
3
  import { whenSallaReady } from './chunk-MZPX4EPS.js';
4
4
  import { subscribeTwilight, getTwilightContext } from './chunk-MWUAHDQL.js';
@@ -99,5 +99,5 @@ function PageAdvertisements() {
99
99
  }
100
100
 
101
101
  export { PageAdvertisements };
102
- //# sourceMappingURL=chunk-MTTKSFUF.js.map
103
- //# sourceMappingURL=chunk-MTTKSFUF.js.map
102
+ //# sourceMappingURL=chunk-WGNHY5SV.js.map
103
+ //# sourceMappingURL=chunk-WGNHY5SV.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/layout/PageAdvertisements.tsx"],"names":[],"mappings":";;;;;;;;AAOA,IAAM,eAAA,GAAkB,MAAM,kBAAA,EAAmB,CAAE,IAAA,EAAM,IAAA;AAGzD,IAAM,YAAA,GAAe,CAAC,EAAA,KAAe,CAAA,SAAA,EAAY,EAAE,CAAA,CAAA;AAGnD,IAAM,SAA0B,EAAC;AAGjC,IAAM,qBAAA,GACJ,uPAAA;AAEF,SAAS,YAAY,EAAA,EAAqB;AACxC,EAAA,IAAI;AACF,IAAA,OAAO,QAAQ,MAAA,CAAO,YAAA,CAAa,QAAQ,YAAA,CAAa,EAAE,CAAC,CAAC,CAAA;AAAA,EAC9D,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,KAAA;AAAA,EACT;AACF;AAEA,SAAS,QAAQ,EAAA,EAAkB;AACjC,EAAA,MAAM,OAAA,GAAU,OAAO,KAAA,EAAO,OAAA;AAC9B,EAAA,IAAI,OAAO,SAAS,GAAA,KAAQ,UAAA,UAAoB,GAAA,CAAI,YAAA,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,EAAA,EAAI,SAAA,EAAU,4EAAA,EACb,QAAA,EAAA;AAAA,0BAAA,IAAA,CAAC,MAAA,EAAA,EAAK,WAAU,mEAAA,EAEd,QAAA,EAAA;AAAA,4BAAA,GAAA;AAAA,cAAC,GAAA;AAAA,cAAA;AAAA,gBACC,SAAA,EAAW,CAAA,sEAAA,EAAyE,EAAA,CAAG,IAAA,IAAQ,EAAE,CAAA;AAAA;AAAA,aACnG;AAAA,YACC,GAAG,GAAA,mBACF,GAAA;AAAA,cAAC,GAAA;AAAA,cAAA;AAAA,gBACC,MAAM,EAAA,CAAG,GAAA;AAAA,gBACT,MAAA,EAAQ,GAAG,MAAA,IAAU,MAAA;AAAA,gBACrB,GAAA,EAAK,EAAA,CAAG,MAAA,KAAW,QAAA,GAAW,UAAA,GAAa,MAAA;AAAA,gBAE1C,QAAA,EAAA,EAAA,CAAG;AAAA;AAAA,gBAGN,EAAA,CAAG;AAAA,WAAA,EAEP,CAAA;AAAA,0BACA,GAAA;AAAA,YAAC,QAAA;AAAA,YAAA;AAAA,cACC,IAAA,EAAK,QAAA;AAAA,cACL,SAAA,EAAU,6BAAA;AAAA,cACV,YAAA,EAAY,CAAA,CAAE,sBAAA,EAAwB,OAAO,CAAA;AAAA,cAC7C,OAAA,EAAS,MAAM,KAAA,CAAM,EAAA,CAAG,EAAE,CAAA;AAAA,cAG1B,QAAA,kBAAA,GAAA,CAAC,GAAA,EAAA,EAAE,SAAA,EAAU,2BAAA,EAA4B;AAAA;AAAA;AAC3C,SAAA,EACF;AAAA,OAAA;AAAA,MAhCK,EAAA,CAAG;AAAA,KAkCX,CAAA;AAAA,oBACD,GAAA,CAAC,QAAA,EAAA,EAAO,wBAAA,EAAwB,IAAA,EAAE,QAAA,EAAA,qBAAA,EAAsB;AAAA,GAAA,EAC1D,CAAA;AAEJ","file":"chunk-MTTKSFUF.js","sourcesContent":["import { useEffect, useState, useSyncExternalStore } from 'react';\nimport { useQuery } from '@tanstack/react-query';\nimport { advertisement, advertisementsFor, type Advertisement } from '../../api/advertisement';\nimport { whenSallaReady } from '../../utils/sdk-helpers';\nimport { useTranslation } from '../../providers/I18nProvider';\nimport { getTwilightContext, subscribeTwilight } from '../../twilight/context';\n\nconst currentPageSlug = () => getTwilightContext().page?.slug;\n\n/** The key `<salla-advertisement>` marks a closed ad with, through `salla.storage` (store.js, JSON). */\nconst dismissedKey = (id: number) => `statusAd-${id}`;\n\n/** Stable while the query has no data, so the effect below doesn't rerun on every render. */\nconst NO_ADS: Advertisement[] = [];\n\n/** Hides the ads this visitor closed before the first paint; the effect then drops them. */\nconst HIDE_DISMISSED_SCRIPT =\n \"(function(){try{if(window.self!==window.top)return;document.currentScript.parentNode.querySelectorAll('.s-advertisement[data-id]').forEach(function(e){if(localStorage.getItem('statusAd-'+e.getAttribute('data-id')))e.hidden=true})}catch(e){}})();\";\n\nfunction isDismissed(id: number): boolean {\n try {\n return Boolean(window.localStorage.getItem(dismissedKey(id)));\n } catch {\n return false;\n }\n}\n\nfunction dismiss(id: number): void {\n const storage = window.salla?.storage;\n if (typeof storage?.set === 'function') storage.set(dismissedKey(id), 'dismissed');\n else {\n try {\n window.localStorage.setItem(dismissedKey(id), JSON.stringify('dismissed'));\n } catch {\n // Storage disabled: the ad hides for this page view only.\n }\n }\n}\n\ninterface ClientView {\n /** The theme editor's iframe, or the SDK's debug flag: every ad shows, closed or not. */\n preview: boolean;\n /** Inside the Salla mobile app, which shows no ads. */\n inApp: boolean;\n dismissed: Set<number>;\n}\n\n/**\n * The merchant's announcement bars, in place of `<salla-advertisement>`. Same data, rules and\n * markup, but rendered on the server (the ads are prefetched in the root `beforeLoad`), so the\n * bar is in the first paint instead of pushing the page down when the web component fetches it.\n */\nexport function PageAdvertisements() {\n const { t } = useTranslation();\n // The deepest route loader's `page`, the page `salla.config` reports.\n const pageSlug = useSyncExternalStore(subscribeTwilight, currentPageSlug, currentPageSlug);\n // The query's `retry: 0` only bounds the server wait; the browser may retry.\n const { data: ads = NO_ADS } = useQuery({ ...advertisement.queries.list(), retry: 2 });\n const [view, setView] = useState<ClientView | null>(null);\n\n useEffect(() => {\n const dismissed = new Set(ads.filter((ad) => isDismissed(ad.id)).map((ad) => ad.id));\n setView({ preview: window.self !== window.top, inApp: false, dismissed });\n return whenSallaReady((sdk) => {\n const config = sdk.config as { isMobileApp?: () => boolean; isDebug?: () => boolean };\n const inApp = Boolean(config?.isMobileApp?.());\n const debug = Boolean(config?.isDebug?.());\n if (inApp || debug) {\n setView((current) =>\n current ? { ...current, inApp, preview: current.preview || debug } : current\n );\n }\n });\n }, [ads]);\n\n if (view?.inApp) return null;\n const shown = view?.preview\n ? ads\n : advertisementsFor(ads, pageSlug).filter((ad) => !view?.dismissed.has(ad.id));\n if (!shown.length) return null;\n\n const close = (id: number) => {\n dismiss(id);\n setView((current) =>\n current ? { ...current, dismissed: new Set(current.dismissed).add(id) } : current\n );\n };\n\n return (\n <>\n {shown.map((ad) => (\n <div\n key={ad.id}\n className=\"s-advertisement\"\n data-id={ad.id}\n style={{ backgroundColor: ad.colors?.bg, color: ad.colors?.text }}\n >\n <div className=\"s-advertisement-content container flex justify-between items-center py-2.5\">\n <span className=\"s-advertisement-content-main flex-1 font-bold text-center text-sm\">\n {/* Rendered without an icon too, as the SDK does: its margin is part of the layout. */}\n <i\n className={`s-advertisement-content-icon inline-block align-middle me-2 text-base ${ad.icon ?? ''}`}\n />\n {ad.url ? (\n <a\n href={ad.url}\n target={ad.target ?? undefined}\n rel={ad.target === '_blank' ? 'noopener' : undefined}\n >\n {ad.description}\n </a>\n ) : (\n ad.description\n )}\n </span>\n <button\n type=\"button\"\n className=\"s-advertisement-action px-1\"\n aria-label={t('common.buttons.close', 'Close')}\n onClick={() => close(ad.id)}\n >\n {/* `inline-block`: before the icon CSS loads, an empty inline `<i>` leaves the button 0px tall. */}\n <i className=\"sicon-cancel inline-block\" />\n </button>\n </div>\n </div>\n ))}\n <script suppressHydrationWarning>{HIDE_DISMISSED_SCRIPT}</script>\n </>\n );\n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AAA,WAAA,EAEP,CAAA;AAAA,0BACA,GAAA;AAAA,YAAC,QAAA;AAAA,YAAA;AAAA,cACC,IAAA,EAAK,QAAA;AAAA,cACL,SAAA,EAAU,6BAAA;AAAA,cACV,YAAA,EAAY,CAAA,CAAE,sBAAA,EAAwB,OAAO,CAAA;AAAA,cAC7C,OAAA,EAAS,MAAM,KAAA,CAAM,EAAA,CAAG,EAAE,CAAA;AAAA,cAG1B,QAAA,kBAAA,GAAA,CAAC,GAAA,EAAA,EAAE,SAAA,EAAU,2BAAA,EAA4B;AAAA;AAAA;AAC3C,SAAA,EACF;AAAA,OAAA;AAAA,MAhCK,EAAA,CAAG;AAAA,KAkCX,CAAA;AAAA,oBACD,GAAA,CAAC,QAAA,EAAA,EAAO,wBAAA,EAAwB,IAAA,EAAE,QAAA,EAAA,qBAAA,EAAsB;AAAA,GAAA,EAC1D,CAAA;AAEJ","file":"chunk-WGNHY5SV.js","sourcesContent":["import { useEffect, useState, useSyncExternalStore } from 'react';\nimport { useQuery } from '@tanstack/react-query';\nimport { advertisement, advertisementsFor, type Advertisement } from '../../api/advertisement';\nimport { whenSallaReady } from '../../utils/sdk-helpers';\nimport { useTranslation } from '../../providers/I18nProvider';\nimport { getTwilightContext, subscribeTwilight } from '../../twilight/context';\n\nconst currentPageSlug = () => getTwilightContext().page?.slug;\n\n/** The key `<salla-advertisement>` marks a closed ad with, through `salla.storage` (store.js, JSON). */\nconst dismissedKey = (id: number) => `statusAd-${id}`;\n\n/** Stable while the query has no data, so the effect below doesn't rerun on every render. */\nconst NO_ADS: Advertisement[] = [];\n\n/** Hides the ads this visitor closed before the first paint; the effect then drops them. */\nconst HIDE_DISMISSED_SCRIPT =\n \"(function(){try{if(window.self!==window.top)return;document.currentScript.parentNode.querySelectorAll('.s-advertisement[data-id]').forEach(function(e){if(localStorage.getItem('statusAd-'+e.getAttribute('data-id')))e.hidden=true})}catch(e){}})();\";\n\nfunction isDismissed(id: number): boolean {\n try {\n return Boolean(window.localStorage.getItem(dismissedKey(id)));\n } catch {\n return false;\n }\n}\n\nfunction dismiss(id: number): void {\n const storage = window.salla?.storage;\n if (typeof storage?.set === 'function') storage.set(dismissedKey(id), 'dismissed');\n else {\n try {\n window.localStorage.setItem(dismissedKey(id), JSON.stringify('dismissed'));\n } catch {\n // Storage disabled: the ad hides for this page view only.\n }\n }\n}\n\ninterface ClientView {\n /** The theme editor's iframe, or the SDK's debug flag: every ad shows, closed or not. */\n preview: boolean;\n /** Inside the Salla mobile app, which shows no ads. */\n inApp: boolean;\n dismissed: Set<number>;\n}\n\n/**\n * The merchant's announcement bars, in place of `<salla-advertisement>`. Same data, rules and\n * markup, but rendered on the server (the ads are prefetched in the root `beforeLoad`), so the\n * bar is in the first paint instead of pushing the page down when the web component fetches it.\n */\nexport function PageAdvertisements() {\n const { t } = useTranslation();\n // The deepest route loader's `page`, the page `salla.config` reports.\n const pageSlug = useSyncExternalStore(subscribeTwilight, currentPageSlug, currentPageSlug);\n // The query's `retry: 0` only bounds the server wait; the browser may retry.\n const { data: ads = NO_ADS } = useQuery({ ...advertisement.queries.list(), retry: 2 });\n const [view, setView] = useState<ClientView | null>(null);\n\n useEffect(() => {\n const dismissed = new Set(ads.filter((ad) => isDismissed(ad.id)).map((ad) => ad.id));\n setView({ preview: window.self !== window.top, inApp: false, dismissed });\n return whenSallaReady((sdk) => {\n const config = sdk.config as { isMobileApp?: () => boolean; isDebug?: () => boolean };\n const inApp = Boolean(config?.isMobileApp?.());\n const debug = Boolean(config?.isDebug?.());\n if (inApp || debug) {\n setView((current) =>\n current ? { ...current, inApp, preview: current.preview || debug } : current\n );\n }\n });\n }, [ads]);\n\n if (view?.inApp) return null;\n const shown = view?.preview\n ? ads\n : advertisementsFor(ads, pageSlug).filter((ad) => !view?.dismissed.has(ad.id));\n if (!shown.length) return null;\n\n const close = (id: number) => {\n dismiss(id);\n setView((current) =>\n current ? { ...current, dismissed: new Set(current.dismissed).add(id) } : current\n );\n };\n\n return (\n <>\n {shown.map((ad) => (\n <div\n key={ad.id}\n className=\"s-advertisement\"\n data-id={ad.id}\n style={{ backgroundColor: ad.colors?.bg, color: ad.colors?.text }}\n >\n <div className=\"s-advertisement-content container flex justify-between items-center py-2.5\">\n <span className=\"s-advertisement-content-main flex-1 font-bold text-center text-sm\">\n {/* Rendered without an icon too, as the SDK does: its margin is part of the layout. */}\n <i\n className={`s-advertisement-content-icon inline-block align-middle me-2 text-base ${ad.icon ?? ''}`}\n />\n {ad.url ? (\n <a\n href={ad.url}\n target={ad.target ?? undefined}\n rel={ad.target === '_blank' ? 'noopener' : undefined}\n >\n {ad.description}\n </a>\n ) : (\n ad.description\n )}\n </span>\n <button\n type=\"button\"\n className=\"s-advertisement-action px-1\"\n aria-label={t('common.buttons.close', 'Close')}\n onClick={() => close(ad.id)}\n >\n {/* `inline-block`: before the icon CSS loads, an empty inline `<i>` leaves the button 0px tall. */}\n <i className=\"sicon-cancel inline-block\" />\n </button>\n </div>\n </div>\n ))}\n <script suppressHydrationWarning>{HIDE_DISMISSED_SCRIPT}</script>\n </>\n );\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import { RouteId } from './chunk-OUW6WESU.js';
2
- import { getActiveCurrency } from './chunk-BM43QN4L.js';
2
+ import { getActiveCurrency } from './chunk-YJMUVRXD.js';
3
3
 
4
4
  // src/lib/analytics/gtm.ts
5
5
  function gtmEnabled(settings) {
@@ -295,5 +295,5 @@ function servicesInitEvents(externalServices, snippetServices) {
295
295
  }
296
296
 
297
297
  export { DATA_LAYER_PROXY_SCRIPT, gtmCartCheckout, gtmCustomer, gtmDetail, gtmEnabled, gtmImpressions, gtmPage, gtmPurchase, gtmStore, pushToDataLayer, servicesInitEvents };
298
- //# sourceMappingURL=chunk-U5QRBIEL.js.map
299
- //# sourceMappingURL=chunk-U5QRBIEL.js.map
298
+ //# sourceMappingURL=chunk-X7QELNMF.js.map
299
+ //# sourceMappingURL=chunk-X7QELNMF.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/l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,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-U5QRBIEL.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 if (!item.product) return null;\n return {\n id: item.product.id,\n name: item.name,\n categories: [],\n category: '',\n price: amountOf(item.amounts?.total) + amountOf(item.amounts?.total_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 return {\n event: 'purchase',\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_S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AO,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-X7QELNMF.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 if (!item.product) return null;\n return {\n id: item.product.id,\n name: item.name,\n categories: [],\n category: '',\n price: amountOf(item.amounts?.total) + amountOf(item.amounts?.total_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 return {\n event: 'purchase',\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,7 @@
1
- import { HomeComponentRenderer, ReorderProducts } from './chunk-6444ZQQB.js';
2
- import { home } from './chunk-NTBL5QFW.js';
1
+ import { HomeComponentRenderer, ReorderProducts } from './chunk-KZQIHYHY.js';
2
+ import { home } from './chunk-IMWSBFOC.js';
3
3
  import { useLiveBlockList, reorder, useLiveBlockMoves } from './chunk-TJK4DVQM.js';
4
- import { useDevHomeBlocks } from './chunk-Q3237344.js';
4
+ import { useDevHomeBlocks } from './chunk-NTQZJXYU.js';
5
5
  import { storePageUrl, buildHreflangAlternates } from './chunk-BYA4ZF7E.js';
6
6
  import { RouteId } from './chunk-OUW6WESU.js';
7
7
  import { HookSlot } from './chunk-5XDPAKF5.js';
@@ -135,5 +135,5 @@ function head(ctx) {
135
135
  var Home = { id: RouteId.INDEX, loader, head, Component: HomePage };
136
136
 
137
137
  export { Home, HomeSkeleton, homeLoader };
138
- //# sourceMappingURL=chunk-PSG2U2GG.js.map
139
- //# sourceMappingURL=chunk-PSG2U2GG.js.map
138
+ //# sourceMappingURL=chunk-XEBU5UBC.js.map
139
+ //# sourceMappingURL=chunk-XEBU5UBC.js.map
@@ -1 +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,EA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7B,EAAA,MAAM,GAAA,GAAM,aAAa,GAAA,CAAI,QAAA,EAAU,IAAI,QAAA,CAAS,QAAQ,KAAK,KAAA,CAAM,GAAA;AAEvE,EAAA,OAAO;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-PSG2U2GG.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 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 const title = store.meta?.title ?? store.name;\n const description = store.meta?.description ?? store.description;\n const keywords = store.meta?.keywords;\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
+ {"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,G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MAAM,KAAA,GAAQ,KAAA,CAAM,IAAA,EAAM,KAAA,IAAS,KAAA,CAAM,IAAA;AACzC,EAAA,MAAM,WAAA,GAAc,KAAA,CAAM,IAAA,EAAM,WAAA,IAAe,KAAA,CAAM,WAAA;AACrD,EAAA,MAAM,QAAA,GAAW,MAAM,IAAA,EAAM,QAAA;AAE7B,EAAA,MAAM,GAAA,GAAM,aAAa,GAAA,CAAI,QAAA,EAAU,IAAI,QAAA,CAAS,QAAQ,KAAK,KAAA,CAAM,GAAA;AAEvE,EAAA,OAAO;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-XEBU5UBC.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 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 const title = store.meta?.title ?? store.name;\n const description = store.meta?.description ?? store.description;\n const keywords = store.meta?.keywords;\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 { registry } from './chunk-Y32RHCOH.js';
2
- import { useMoney, useNumber } from './chunk-ILDV6JVU.js';
2
+ import { useMoney, useNumber } from './chunk-KZJN75WE.js';
3
3
  import { useAsset } from './chunk-Z653O7MX.js';
4
4
  import { useWishlist } from './chunk-DVJGKIFQ.js';
5
5
  import { useTranslation } from './chunk-TYNZ5B2B.js';
@@ -229,5 +229,5 @@ var ProductCard = memo(function ProductCard2(props) {
229
229
  });
230
230
 
231
231
  export { ProductCard };
232
- //# sourceMappingURL=chunk-GSPD3FOY.js.map
233
- //# sourceMappingURL=chunk-GSPD3FOY.js.map
232
+ //# sourceMappingURL=chunk-XEKROZ6O.js.map
233
+ //# sourceMappingURL=chunk-XEKROZ6O.js.map