@salla.sa/twilight-theme-engine 1.0.148 → 1.0.150
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.
- package/dist/{AddToCartForm-WY5QEHJ4.js → AddToCartForm-P5Q4P763.js} +3 -3
- package/dist/{AddToCartForm-WY5QEHJ4.js.map → AddToCartForm-P5Q4P763.js.map} +1 -1
- package/dist/{BlogAuthorPage-E2WXK6HD.js → BlogAuthorPage-Z3R6AETN.js} +27 -27
- package/dist/{BlogAuthorPage-E2WXK6HD.js.map → BlogAuthorPage-Z3R6AETN.js.map} +1 -1
- package/dist/{BlogCategoryPage-B2JEB33A.js → BlogCategoryPage-7VROFBGI.js} +27 -27
- package/dist/{BlogCategoryPage-B2JEB33A.js.map → BlogCategoryPage-7VROFBGI.js.map} +1 -1
- package/dist/{BlogPage-CSNI6SS5.js → BlogPage-Q2NN4WTB.js} +25 -25
- package/dist/{BlogPage-CSNI6SS5.js.map → BlogPage-Q2NN4WTB.js.map} +1 -1
- package/dist/{BlogSinglePage-5ZY5EB6H.js → BlogSinglePage-ZPCSNBIX.js} +25 -25
- package/dist/{BlogSinglePage-5ZY5EB6H.js.map → BlogSinglePage-ZPCSNBIX.js.map} +1 -1
- package/dist/{BlogTagPage-QFS7AKNK.js → BlogTagPage-IGG2VEMR.js} +27 -27
- package/dist/{BlogTagPage-QFS7AKNK.js.map → BlogTagPage-IGG2VEMR.js.map} +1 -1
- package/dist/{BrandsPage-QBA2WQHF.js → BrandsPage-ZAJT6RGM.js} +26 -26
- package/dist/{BrandsPage-QBA2WQHF.js.map → BrandsPage-ZAJT6RGM.js.map} +1 -1
- package/dist/{Breadcrumb-CH35WQ6M.js → Breadcrumb-KE4EWH7L.js} +25 -25
- package/dist/{Breadcrumb-CH35WQ6M.js.map → Breadcrumb-KE4EWH7L.js.map} +1 -1
- package/dist/{CartItem-NBM3KRUH.js → CartItem-RMCXCGHT.js} +25 -25
- package/dist/{CartItem-NBM3KRUH.js.map → CartItem-RMCXCGHT.js.map} +1 -1
- package/dist/{CartSummary-OD2IJTTA.js → CartSummary-NLEAHKWF.js} +25 -25
- package/dist/{CartSummary-OD2IJTTA.js.map → CartSummary-NLEAHKWF.js.map} +1 -1
- package/dist/{Copyright-7EC2FQUB.js → Copyright-EIBPTE3B.js} +3 -3
- package/dist/{Copyright-7EC2FQUB.js.map → Copyright-EIBPTE3B.js.map} +1 -1
- package/dist/{CustomerLayout-7GEOMQ3Z.js → CustomerLayout-POGWFN6R.js} +25 -25
- package/dist/{CustomerLayout-7GEOMQ3Z.js.map → CustomerLayout-POGWFN6R.js.map} +1 -1
- package/dist/{Footer-JTQIMWSF.js → Footer-LGIUINGS.js} +4 -4
- package/dist/{Footer-JTQIMWSF.js.map → Footer-LGIUINGS.js.map} +1 -1
- package/dist/{Header-4ZW5UVTX.js → Header-4TGYO6E4.js} +11 -11
- package/dist/{Header-4ZW5UVTX.js.map → Header-4TGYO6E4.js.map} +1 -1
- package/dist/{LatestProducts-VHN2P5TE.js → LatestProducts-YYKQNL5N.js} +27 -27
- package/dist/{LatestProducts-VHN2P5TE.js.map → LatestProducts-YYKQNL5N.js.map} +1 -1
- package/dist/{LoyaltyPage-PVK7FBFE.js → LoyaltyPage-MROFMZXV.js} +25 -25
- package/dist/{LoyaltyPage-PVK7FBFE.js.map → LoyaltyPage-MROFMZXV.js.map} +1 -1
- package/dist/{LoyaltyPointsPage-WYCO453U.js → LoyaltyPointsPage-DVHJOAKP.js} +8 -8
- package/dist/{LoyaltyPointsPage-WYCO453U.js.map → LoyaltyPointsPage-DVHJOAKP.js.map} +1 -1
- package/dist/{MainMenu-Y2PAFESM.js → MainMenu-GQO5KOTU.js} +7 -7
- package/dist/{MainMenu-Y2PAFESM.js.map → MainMenu-GQO5KOTU.js.map} +1 -1
- package/dist/{MasterLayout-EBLVT53G.js → MasterLayout-ZJBJ7EHM.js} +25 -25
- package/dist/{MasterLayout-EBLVT53G.js.map → MasterLayout-ZJBJ7EHM.js.map} +1 -1
- package/dist/{MobileMenu-YIL4MEWX.js → MobileMenu-TZSFYHPW.js} +26 -26
- package/dist/{MobileMenu-YIL4MEWX.js.map → MobileMenu-TZSFYHPW.js.map} +1 -1
- package/dist/{NotificationsPage-K2CJOV2N.js → NotificationsPage-BX6OSIDY.js} +25 -25
- package/dist/{NotificationsPage-K2CJOV2N.js.map → NotificationsPage-BX6OSIDY.js.map} +1 -1
- package/dist/{OrderSinglePage-T7S7KXJ3.js → OrderSinglePage-3RQ5TJDB.js} +26 -26
- package/dist/{OrderSinglePage-T7S7KXJ3.js.map → OrderSinglePage-3RQ5TJDB.js.map} +1 -1
- package/dist/{OrdersPage-WAW3NS2E.js → OrdersPage-S4ECYNGI.js} +25 -25
- package/dist/{OrdersPage-WAW3NS2E.js.map → OrdersPage-S4ECYNGI.js.map} +1 -1
- package/dist/{PageSingle-L5EBQGWS.js → PageSingle-BZGDC4VE.js} +6 -6
- package/dist/{PageSingle-L5EBQGWS.js.map → PageSingle-BZGDC4VE.js.map} +1 -1
- package/dist/{ProductDetails-4E46ZCMQ.js → ProductDetails-ZPRWPSVK.js} +7 -7
- package/dist/{ProductDetails-4E46ZCMQ.js.map → ProductDetails-ZPRWPSVK.js.map} +1 -1
- package/dist/{ProfilePage-KN7BWYFZ.js → ProfilePage-SKAS6LFQ.js} +25 -25
- package/dist/{ProfilePage-KN7BWYFZ.js.map → ProfilePage-SKAS6LFQ.js.map} +1 -1
- package/dist/{ReviewsPage-CCTPJN76.js → ReviewsPage-NAZWXVXT.js} +3 -3
- package/dist/{ReviewsPage-CCTPJN76.js.map → ReviewsPage-NAZWXVXT.js.map} +1 -1
- package/dist/{SeoCartWidget-Q5XK5MEW.js → SeoCartWidget-6NB6LT2Z.js} +25 -25
- package/dist/{SeoCartWidget-Q5XK5MEW.js.map → SeoCartWidget-6NB6LT2Z.js.map} +1 -1
- package/dist/{SettingsPage-DQAAMJE5.js → SettingsPage-GZ2NJIUR.js} +25 -25
- package/dist/{SettingsPage-DQAAMJE5.js.map → SettingsPage-GZ2NJIUR.js.map} +1 -1
- package/dist/{StoreClosedNotification-ZSDPBM3L.js → StoreClosedNotification-V72F7HE5.js} +26 -26
- package/dist/{StoreClosedNotification-ZSDPBM3L.js.map → StoreClosedNotification-V72F7HE5.js.map} +1 -1
- package/dist/{TestimonialsPage-6LGQSJSQ.js → TestimonialsPage-L6VBZFLT.js} +6 -6
- package/dist/{TestimonialsPage-6LGQSJSQ.js.map → TestimonialsPage-L6VBZFLT.js.map} +1 -1
- package/dist/{ThankYouPage-ZI6NEGN3.js → ThankYouPage-O5U3V6J4.js} +25 -25
- package/dist/{ThankYouPage-ZI6NEGN3.js.map → ThankYouPage-O5U3V6J4.js.map} +1 -1
- package/dist/{WalletPage-R6G5BQAI.js → WalletPage-NJBBZIMM.js} +26 -26
- package/dist/{WalletPage-R6G5BQAI.js.map → WalletPage-NJBBZIMM.js.map} +1 -1
- package/dist/{WebMcpTools-2NWIVDL2.js → WebMcpTools-VAZH3S5G.js} +9 -9
- package/dist/{WebMcpTools-2NWIVDL2.js.map → WebMcpTools-VAZH3S5G.js.map} +1 -1
- package/dist/{WishlistPage-CQ62GPLC.js → WishlistPage-UKOGNFKB.js} +27 -27
- package/dist/{WishlistPage-CQ62GPLC.js.map → WishlistPage-UKOGNFKB.js.map} +1 -1
- package/dist/api/advertisement.js +4 -4
- package/dist/api/apps.js +4 -4
- package/dist/api/blog.js +6 -6
- package/dist/api/brands.js +6 -6
- package/dist/api/cart.js +6 -6
- package/dist/api/category.js +6 -6
- package/dist/api/client.js +3 -3
- package/dist/api/home.js +4 -4
- package/dist/api/loyalty.js +6 -6
- package/dist/api/menu.js +4 -4
- package/dist/api/notification.js +4 -4
- package/dist/api/order.js +6 -6
- package/dist/api/page.js +6 -6
- package/dist/api/product.js +6 -6
- package/dist/api/profile.js +3 -3
- package/dist/api/store.js +5 -5
- package/dist/api/translations.js +4 -4
- package/dist/api/user.js +4 -4
- package/dist/api/wallet.js +4 -4
- package/dist/api/wishlist.js +7 -7
- package/dist/{chunk-ELYKF67K.js → chunk-2CILV5ME.js} +5 -5
- package/dist/{chunk-ELYKF67K.js.map → chunk-2CILV5ME.js.map} +1 -1
- package/dist/{chunk-JZ54GDXO.js → chunk-2HCODIC6.js} +4 -4
- package/dist/{chunk-JZ54GDXO.js.map → chunk-2HCODIC6.js.map} +1 -1
- package/dist/{chunk-BAJBKIGI.js → chunk-2ZC5YGMI.js} +3 -3
- package/dist/{chunk-BAJBKIGI.js.map → chunk-2ZC5YGMI.js.map} +1 -1
- package/dist/{chunk-WPRJVK7K.js → chunk-34L65JGK.js} +4 -4
- package/dist/{chunk-WPRJVK7K.js.map → chunk-34L65JGK.js.map} +1 -1
- package/dist/{chunk-T2752RH7.js → chunk-4E6FD5W7.js} +60 -4
- package/dist/chunk-4E6FD5W7.js.map +1 -0
- package/dist/{chunk-M5WTY3EH.js → chunk-5EAISVPV.js} +3 -3
- package/dist/{chunk-M5WTY3EH.js.map → chunk-5EAISVPV.js.map} +1 -1
- package/dist/{chunk-5PMEGLR6.js → chunk-5LI536P6.js} +5 -5
- package/dist/{chunk-5PMEGLR6.js.map → chunk-5LI536P6.js.map} +1 -1
- package/dist/{chunk-QOC7HUYN.js → chunk-5M2AK5KE.js} +4 -4
- package/dist/{chunk-QOC7HUYN.js.map → chunk-5M2AK5KE.js.map} +1 -1
- package/dist/{chunk-33327CFA.js → chunk-5NUCGUTE.js} +4 -4
- package/dist/{chunk-33327CFA.js.map → chunk-5NUCGUTE.js.map} +1 -1
- package/dist/{chunk-3BDSQIYZ.js → chunk-5RBXCPG6.js} +3 -3
- package/dist/{chunk-3BDSQIYZ.js.map → chunk-5RBXCPG6.js.map} +1 -1
- package/dist/{chunk-6T4HGLQM.js → chunk-5T4MJAUN.js} +3 -3
- package/dist/{chunk-6T4HGLQM.js.map → chunk-5T4MJAUN.js.map} +1 -1
- package/dist/{chunk-MA3R5QON.js → chunk-6H6BVZBV.js} +3 -3
- package/dist/{chunk-MA3R5QON.js.map → chunk-6H6BVZBV.js.map} +1 -1
- package/dist/{chunk-4FFABE3P.js → chunk-6QIF6WJH.js} +3 -3
- package/dist/{chunk-4FFABE3P.js.map → chunk-6QIF6WJH.js.map} +1 -1
- package/dist/{chunk-SLBO4SEE.js → chunk-6YEE3VHL.js} +3 -3
- package/dist/{chunk-SLBO4SEE.js.map → chunk-6YEE3VHL.js.map} +1 -1
- package/dist/{chunk-XMRNYUQY.js → chunk-7XAGU6CT.js} +3 -3
- package/dist/{chunk-XMRNYUQY.js.map → chunk-7XAGU6CT.js.map} +1 -1
- package/dist/{chunk-NWQUPGB4.js → chunk-AOQZHLZZ.js} +5 -5
- package/dist/{chunk-NWQUPGB4.js.map → chunk-AOQZHLZZ.js.map} +1 -1
- package/dist/{chunk-H7LRGY7U.js → chunk-B57KIBQL.js} +3 -3
- package/dist/{chunk-H7LRGY7U.js.map → chunk-B57KIBQL.js.map} +1 -1
- package/dist/{chunk-CUURFACL.js → chunk-BYGVKW3M.js} +4 -4
- package/dist/{chunk-CUURFACL.js.map → chunk-BYGVKW3M.js.map} +1 -1
- package/dist/{chunk-T55MRK24.js → chunk-CAULDK3N.js} +6 -6
- package/dist/{chunk-T55MRK24.js.map → chunk-CAULDK3N.js.map} +1 -1
- package/dist/{chunk-EGI7F57E.js → chunk-DPQIVZ4T.js} +3 -3
- package/dist/{chunk-EGI7F57E.js.map → chunk-DPQIVZ4T.js.map} +1 -1
- package/dist/{chunk-5ABT7QLS.js → chunk-EMAAVDEK.js} +7 -7
- package/dist/{chunk-5ABT7QLS.js.map → chunk-EMAAVDEK.js.map} +1 -1
- package/dist/{chunk-DQEJV5SR.js → chunk-FCCGJ4DI.js} +7 -7
- package/dist/{chunk-DQEJV5SR.js.map → chunk-FCCGJ4DI.js.map} +1 -1
- package/dist/{chunk-ZXEJ46OF.js → chunk-FL3OK7AQ.js} +36 -16
- package/dist/chunk-FL3OK7AQ.js.map +1 -0
- package/dist/{chunk-NRMAYV4G.js → chunk-GLSRVHYJ.js} +4 -4
- package/dist/{chunk-NRMAYV4G.js.map → chunk-GLSRVHYJ.js.map} +1 -1
- package/dist/{chunk-X5W7HZNX.js → chunk-I2LK4IC2.js} +4 -4
- package/dist/{chunk-X5W7HZNX.js.map → chunk-I2LK4IC2.js.map} +1 -1
- package/dist/{chunk-LILNJBFU.js → chunk-IEKP3HYS.js} +4 -4
- package/dist/{chunk-LILNJBFU.js.map → chunk-IEKP3HYS.js.map} +1 -1
- package/dist/{chunk-IHOUADLX.js → chunk-JK45RUVV.js} +3 -3
- package/dist/{chunk-IHOUADLX.js.map → chunk-JK45RUVV.js.map} +1 -1
- package/dist/{chunk-CNTXY27A.js → chunk-JSAWLWUN.js} +4 -4
- package/dist/{chunk-CNTXY27A.js.map → chunk-JSAWLWUN.js.map} +1 -1
- package/dist/{chunk-3WA5RJGC.js → chunk-KJ7NG3ZH.js} +3 -3
- package/dist/{chunk-3WA5RJGC.js.map → chunk-KJ7NG3ZH.js.map} +1 -1
- package/dist/{chunk-W2A5AWNA.js → chunk-LBZNLTBM.js} +3 -3
- package/dist/{chunk-W2A5AWNA.js.map → chunk-LBZNLTBM.js.map} +1 -1
- package/dist/{chunk-SCWUJ5PP.js → chunk-LWAJNEIM.js} +4 -4
- package/dist/{chunk-SCWUJ5PP.js.map → chunk-LWAJNEIM.js.map} +1 -1
- package/dist/{chunk-MJHYLDXL.js → chunk-O3XMYDNC.js} +5 -5
- package/dist/{chunk-MJHYLDXL.js.map → chunk-O3XMYDNC.js.map} +1 -1
- package/dist/{chunk-HPK6GB7G.js → chunk-O63WBEAC.js} +22 -22
- package/dist/{chunk-HPK6GB7G.js.map → chunk-O63WBEAC.js.map} +1 -1
- package/dist/{chunk-KUQQJTFA.js → chunk-OOZQVX7C.js} +6 -6
- package/dist/{chunk-KUQQJTFA.js.map → chunk-OOZQVX7C.js.map} +1 -1
- package/dist/{chunk-MGG4XAJ5.js → chunk-P2PPBXHD.js} +3 -3
- package/dist/{chunk-MGG4XAJ5.js.map → chunk-P2PPBXHD.js.map} +1 -1
- package/dist/{chunk-IFKCPNDF.js → chunk-PHPOMWQ4.js} +4 -4
- package/dist/{chunk-IFKCPNDF.js.map → chunk-PHPOMWQ4.js.map} +1 -1
- package/dist/{chunk-3AIK4QGW.js → chunk-PPFD456V.js} +3 -3
- package/dist/{chunk-3AIK4QGW.js.map → chunk-PPFD456V.js.map} +1 -1
- package/dist/{chunk-CAAIQPEN.js → chunk-PVOJJ2BV.js} +7 -6
- package/dist/chunk-PVOJJ2BV.js.map +1 -0
- package/dist/{chunk-GBJK6KKM.js → chunk-PYXAPLNB.js} +3 -3
- package/dist/{chunk-GBJK6KKM.js.map → chunk-PYXAPLNB.js.map} +1 -1
- package/dist/{chunk-7R43CIG7.js → chunk-PZP3372I.js} +4 -4
- package/dist/{chunk-7R43CIG7.js.map → chunk-PZP3372I.js.map} +1 -1
- package/dist/{chunk-WH73HWTE.js → chunk-Q7Z76F7N.js} +8 -8
- package/dist/{chunk-WH73HWTE.js.map → chunk-Q7Z76F7N.js.map} +1 -1
- package/dist/{chunk-23OJW6CK.js → chunk-QKKEBQ57.js} +6 -6
- package/dist/{chunk-23OJW6CK.js.map → chunk-QKKEBQ57.js.map} +1 -1
- package/dist/{chunk-QMWP2ZP6.js → chunk-R7QCNL62.js} +3 -3
- package/dist/{chunk-QMWP2ZP6.js.map → chunk-R7QCNL62.js.map} +1 -1
- package/dist/{chunk-CXKA35FJ.js → chunk-RB7RHMKJ.js} +5 -5
- package/dist/{chunk-CXKA35FJ.js.map → chunk-RB7RHMKJ.js.map} +1 -1
- package/dist/{chunk-C7LAIXEO.js → chunk-RY6VPXG6.js} +3 -3
- package/dist/{chunk-C7LAIXEO.js.map → chunk-RY6VPXG6.js.map} +1 -1
- package/dist/{chunk-R7VWIXFX.js → chunk-TEAYGNHT.js} +3 -3
- package/dist/{chunk-R7VWIXFX.js.map → chunk-TEAYGNHT.js.map} +1 -1
- package/dist/{chunk-W3QKGF2O.js → chunk-TXYLHBUH.js} +3 -3
- package/dist/{chunk-W3QKGF2O.js.map → chunk-TXYLHBUH.js.map} +1 -1
- package/dist/{chunk-6TFM3UTF.js → chunk-ULF4LPVA.js} +3 -3
- package/dist/{chunk-6TFM3UTF.js.map → chunk-ULF4LPVA.js.map} +1 -1
- package/dist/{chunk-V6IKYNU6.js → chunk-UUHLRFXB.js} +9 -9
- package/dist/chunk-UUHLRFXB.js.map +1 -0
- package/dist/{chunk-F3QHKYS3.js → chunk-VJA4DVVT.js} +4 -4
- package/dist/{chunk-F3QHKYS3.js.map → chunk-VJA4DVVT.js.map} +1 -1
- package/dist/{chunk-JDCZWE7N.js → chunk-W7CYFPGY.js} +6 -6
- package/dist/{chunk-JDCZWE7N.js.map → chunk-W7CYFPGY.js.map} +1 -1
- package/dist/{chunk-5V4W3GBI.js → chunk-WAKCWE6P.js} +5 -5
- package/dist/{chunk-5V4W3GBI.js.map → chunk-WAKCWE6P.js.map} +1 -1
- package/dist/{chunk-R72B5P4R.js → chunk-ZUVBDALM.js} +4 -4
- package/dist/{chunk-R72B5P4R.js.map → chunk-ZUVBDALM.js.map} +1 -1
- package/dist/components/cart/index.js +1 -1
- package/dist/components/common/index.js +1 -1
- package/dist/components/drawer/index.js +23 -23
- package/dist/components/home/index.js +28 -28
- package/dist/components/layout/index.js +6 -6
- package/dist/components/product/ProductCard.d.ts.map +1 -1
- package/dist/components/product/index.js +25 -25
- package/dist/components/store/index.js +24 -24
- package/dist/components/toast/index.js +4 -4
- package/dist/dev/editor/index.js +2 -2
- package/dist/dev/index.js +2 -2
- package/dist/document-class-N7WF3WXG.js +33 -0
- package/dist/{document-class-B57F7JZW.js.map → document-class-N7WF3WXG.js.map} +1 -1
- package/dist/hooks/index.js +23 -23
- package/dist/hooks/useComments.js +3 -3
- package/dist/hooks/useGtm.js +23 -23
- package/dist/hooks/useMoney.js +23 -23
- package/dist/hooks/useProduct.js +3 -3
- package/dist/hooks/useStore.js +23 -23
- package/dist/hooks/useUser.js +5 -5
- package/dist/hooks/useWishlist.js +3 -3
- package/dist/index.js +23 -23
- package/dist/native-app/index.js +3 -3
- package/dist/{navigation-N3WBAE74.js → navigation-5DPDZQUU.js} +8 -8
- package/dist/{navigation-N3WBAE74.js.map → navigation-5DPDZQUU.js.map} +1 -1
- package/dist/{navigation-VJBIYPFD.js → navigation-FRKMKNLK.js} +7 -7
- package/dist/{navigation-VJBIYPFD.js.map → navigation-FRKMKNLK.js.map} +1 -1
- package/dist/{not-found-KDDMHTAU.js → not-found-4U2TRCLF.js} +26 -26
- package/dist/{not-found-KDDMHTAU.js.map → not-found-4U2TRCLF.js.map} +1 -1
- package/dist/providers/index.js +23 -23
- package/dist/routes/account/orders.js +8 -8
- package/dist/routes/account.js +17 -17
- package/dist/routes/blog.js +12 -12
- package/dist/routes/brands.js +8 -8
- package/dist/routes/cart.js +32 -32
- package/dist/routes/home.js +29 -29
- package/dist/routes/index.js +6 -6
- package/dist/routes/loyalty.js +9 -9
- package/dist/routes/page.js +8 -8
- package/dist/routes/product-listing.js +33 -33
- package/dist/routes/product.js +28 -28
- package/dist/routes/root/beforeLoad.d.ts.map +1 -1
- package/dist/routes/seo-redirects.js +6 -6
- package/dist/routes/testimonials.js +4 -4
- package/dist/routes/thank-you.js +8 -8
- package/dist/skeleton.js +29 -29
- package/dist/{store-lookup-WBKOYMDU.js → store-lookup-S6JUSKNH.js} +11 -11
- package/dist/{store-lookup-WBKOYMDU.js.map → store-lookup-S6JUSKNH.js.map} +1 -1
- package/dist/tanstack.js +20 -20
- package/dist/utils/baseHead.js +2 -2
- package/dist/utils/index.js +6 -6
- package/dist/utils/shared-host-language.d.ts +5 -0
- package/dist/utils/shared-host-language.d.ts.map +1 -1
- package/dist/utils/store-base.d.ts +60 -0
- package/dist/utils/store-base.d.ts.map +1 -1
- package/dist/utils/store-identity.d.ts +14 -0
- package/dist/utils/store-identity.d.ts.map +1 -1
- package/dist/vite/index.js +3 -3
- package/package.json +1 -1
- package/tailwind/components/home/FixedProducts.tsx.txt +2 -2
- package/tailwind/components/product/ProductCard.tsx.txt +2 -1
- package/tailwind/routes/root/beforeLoad.ts.txt +37 -3
- package/dist/chunk-CAAIQPEN.js.map +0 -1
- package/dist/chunk-T2752RH7.js.map +0 -1
- package/dist/chunk-V6IKYNU6.js.map +0 -1
- package/dist/chunk-ZXEJ46OF.js.map +0 -1
- package/dist/document-class-B57F7JZW.js +0 -33
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/layout/Footer.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAiBA,IAAM,YAAA,GACJ,+HAAA;AAOF,SAAS,SAAA,CAAU,EAAE,IAAA,EAAK,EAAsB;AAC9C,EAAA,MAAM,EAAE,KAAA,EAAM,GAAI,WAAA,EAAY;AAC9B,EAAA,MAAM,EAAE,CAAA,EAAE,GAAI,cAAA,EAAe;AAC7B,EAAA,MAAM,CAAC,IAAA,EAAM,OAAO,CAAA,GAAI,SAAS,KAAK,CAAA;AACtC,EAAA,MAAM,MAAA,GAAS,KAAA,CAAM,QAAA,EAAU,GAAA,EAAK,MAAA;AACpC,EAAA,MAAM,WAAA,GAAc,KAAA,CAAM,QAAA,EAAU,GAAA,EAAK,WAAA;AACzC,EAAA,IAAI,CAAC,QAAQ,OAAO,IAAA;AAEpB,EAAA,uBACE,IAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,aAAA,EAAY,kBAAA;AAAA,MACZ,SAAA,EAAU,4DAAA;AAAA,MAET,QAAA,EAAA;AAAA,QAAA,WAAA,oBACC,IAAA,CAAA,QAAA,EAAA,EACE,QAAA,EAAA;AAAA,0BAAA,GAAA;AAAA,YAAC,QAAA;AAAA,YAAA;AAAA,cACC,IAAA,EAAK,QAAA;AAAA,cACL,aAAA,EAAY,8BAAA;AAAA,cACZ,SAAA,EAAU,iCAAA;AAAA,cACV,YAAA,EAAY,CAAA,CAAE,iCAAA,EAAmC,iBAAiB,CAAA;AAAA,cAClE,eAAA,EAAc,Q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A,YAAA;AAAA,cACC,IAAA,EAAK,WAAA;AAAA,cACL,OAAA,EAAS,EAAE,SAAA,EAAW,KAAA,CAAM,IAAA,EAAK;AAAA,cACjC,0BACE,IAAA,CAAA,QAAA,EAAA,EACG,QAAA,EAAA;AAAA,gBAAA,CAAA,CAAE,2BAA2B,qBAAqB,CAAA;AAAA,gBAAG,GAAA;AAAA,oCACrD,IAAA,EAAA,EAAK,EAAA,EAAG,KAAI,SAAA,EAAU,wDAAA,EACpB,gBAAM,IAAA,EACT,CAAA;AAAA,gBAAQ,GAAA;AAAA,gBAAI,OAAA;AAAA,gBACT,IAAA;AAAA,gCACH,GAAA,CAAC,aAAA,EAAA,EAAc,SAAA,EAAU,MAAA,EAAO;AAAA,eAAA,EAClC;AAAA;AAAA,WAEJ,EACF,CAAA;AAAA,8BAEC,aAAA,EAAA,EAAc;AAAA,SAAA,EACjB,CAAA;AAAA,QAEC,CAAC,OAAA,oBAAW,GAAA,CAAC,QAAA,EAAA,EAAS,MAAK,YAAA,EAAa;AAAA;AAAA;AAAA,GAC3C;AAEJ","file":"chunk-6T4HGLQM.js","sourcesContent":["import { useState } from 'react';\nimport { SallaAppsIcons } from '@salla.sa/twilight-components-react/apps-icons';\nimport { SallaContacts } from '@salla.sa/twilight-components-react/contacts';\nimport { SallaSocial } from '@salla.sa/twilight-components-react/social';\nimport { SallaMenu } from '@salla.sa/twilight-components-react/menu';\nimport { SallaTrustBadges } from '@salla.sa/twilight-components-react/trust-badges';\nimport { SallaPayments } from '@salla.sa/twilight-components-react/payments';\nimport { useTwilight } from '../../providers/twilight-context';\nimport { useTranslation } from '../../providers/I18nProvider';\nimport { HookSlot } from '../../hooks/HookSlot';\nimport { useIsClient } from '../../hooks/useIsClient';\nimport { Link, Image } from '../common';\nimport { ImageModal } from '../modal';\nimport { MadeWithSalla } from './MadeWithSalla';\n\n/** Salla's value-added-tax badge icon (70×70, CDN-resized) — a platform\n * asset shared by every store, not specific to any one theme. */\nconst TAX_ICON_URL =\n 'https://cdn.salla.network/cdn-cgi/image/fit=scale-down,width=70,height=70,onerror=redirect,format=auto/images/tax.png?v=2.0.5';\n\n/**\n * The store's value-added-tax registration: the tax number, plus the certificate as\n * the tax icon that opens the certificate image full size in a modal. Nothing shows\n * when the store has no tax number.\n */\nfunction FooterTax({ dark }: { dark: boolean }) {\n const { store } = useTwilight();\n const { t } = useTranslation();\n const [open, setOpen] = useState(false);\n const number = store.settings?.tax?.number;\n const certificate = store.settings?.tax?.certificate;\n if (!number) return null;\n\n return (\n <div\n data-testid=\"store-footer-tax\"\n className=\"store-footer__tax flex items-end gap-2 rtl:space-x-reverse\"\n >\n {certificate && (\n <>\n <button\n type=\"button\"\n data-testid=\"store-footer-tax-certificate\"\n className=\"store-footer__tax-cert shrink-0\"\n aria-label={t('common.elements.tax_certificate', 'Tax Certificate')}\n aria-haspopup=\"dialog\"\n onClick={() => setOpen(true)}\n >\n <img\n src={TAX_ICON_URL}\n alt={t('common.elements.tax_certificate', 'Tax Certificate')}\n width={40}\n height={50}\n loading=\"lazy\"\n decoding=\"async\"\n className=\"w-10 rounded-sm transition-opacity hover:opacity-80\"\n />\n </button>\n <ImageModal\n isOpen={open}\n onClose={() => setOpen(false)}\n src={certificate}\n alt={t('common.elements.tax_certificate', 'Tax Certificate')}\n title={t('common.elements.tax_certificate', 'Tax Certificate')}\n />\n </>\n )}\n <div>\n <p className={`mb-1 text-sm opacity-70 ${dark ? 'text-white' : ''}`}>\n {t('common.elements.tax_number', 'Tax Number')}\n </p>\n <b className=\"text-sm\">{number}</b>\n </div>\n </div>\n );\n}\n\n/** Saudi Business Center (SBC) logo, CDN-versioned like the tax icon -- also a\n * platform asset, not theme-specific. */\nconst SBC_ICON_URL = 'https://cdn.salla.network/images/sbc.png?v=2.0.5';\n\n/**\n * The store's Saudi Business Center certificate: a \"Trusted by Business Platform\" badge that\n * opens the certificate's page on the SBC site so visitors can verify the merchant. Nothing\n * shows when the store has no certificate.\n */\nfunction FooterSbc({ dark }: { dark: boolean }) {\n const { store } = useTwilight();\n const { t } = useTranslation();\n const id = store.settings?.certificate?.id;\n if (!id) return null;\n\n return (\n <a\n href={`https://eauthenticate.saudibusiness.gov.sa/certificate-details/${encodeURIComponent(id)}`}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n data-testid=\"store-footer-sbc\"\n className=\"store-footer__sbc flex items-center gap-2.5 transition-opacity hover:opacity-75\"\n >\n <img\n src={SBC_ICON_URL}\n alt={`SBC ${id}`}\n width={56}\n height={40}\n loading=\"lazy\"\n decoding=\"async\"\n className=\"h-10 w-14 rounded-sm\"\n />\n <div>\n <p className={`text-xs opacity-70 ${dark ? 'text-white' : ''}`}>\n {t('blocks.footer.sbc_trusted_by', 'Trusted by')}\n </p>\n <b className=\"text-sm\">{t('blocks.footer.sbc_platform', 'Business Platform')}</b>\n </div>\n </a>\n );\n}\n\n/** Trust badges, the tax registration and the SBC badge, side by side (wrapping on narrow columns). */\nfunction FooterTrust({ dark, centered }: { dark: boolean; centered: boolean }) {\n return (\n <div\n data-testid=\"store-footer-trust\"\n className={`store-footer__trust flex flex-wrap items-end gap-x-6 gap-y-3${centered ? ' justify-center' : ''}`}\n >\n <FooterTax dark={dark} />\n <FooterSbc dark={dark} />\n <SallaTrustBadges {...(dark ? { dark: true } : {})} />\n </div>\n );\n}\n\n/**\n * The footer's own menu of (\"important\") links -- skipped entirely when\n * `inSheet`, for a theme that opens it from somewhere else of its own (a\n * mobile account sheet, a dedicated links screen, …) instead; showing it\n * again down here would just be a redundant second copy. `heading` wraps it\n * in the grid layout's own `.store-footer__links` column; the centered\n * layout's inline row has none.\n */\nfunction FooterLinksMenu({\n inSheet,\n className,\n heading,\n dark,\n}: {\n inSheet: boolean;\n className: string;\n heading?: string;\n dark: boolean;\n}) {\n if (inSheet) return null;\n\n const menu = <SallaMenu source=\"footer\" className={className} suppressHydrationWarning />;\n if (!heading) return menu;\n\n return (\n <div className=\"store-footer__links\">\n <h3 className={`mb-3 text-lg font-bold lg:mb-5 ${dark ? 'text-white' : 'text-gray-900'}`}>\n {heading}\n </h3>\n {menu}\n </div>\n );\n}\n\n/** App-store / Google-Play buttons. Nothing shows -- not even the wrapping\n * div -- when the store has neither link set. */\nfunction FooterApps({ className }: { className: string }) {\n const { store } = useTwilight();\n const { t } = useTranslation();\n // The web component fills its light DOM before React hydrates the footer, a hydration error.\n const isClient = useIsClient();\n if (!store.apps?.appstore && !store.apps?.googleplay) return null;\n\n return (\n <div data-testid=\"store-footer-apps\" className={`store-footer__apps ${className}`}>\n {isClient && (\n <SallaAppsIcons\n apps={store.apps}\n appsTitle={t('blocks.footer.download_apps', 'Get our apps')}\n />\n )}\n </div>\n );\n}\n\n/** The logo link, same shape in both layouts -- only its own spacing differs. */\nfunction FooterLogo({ className }: { className: string }) {\n const { store } = useTwilight();\n return (\n <Link\n to=\"/\"\n className={`store-footer__logo inline-flex items-center m-0 transition-opacity hover:opacity-75 ${className}`}\n >\n <Image\n src={store.logo}\n alt={store.name || 'Store'}\n width={150}\n height={44}\n objectFit=\"contain\"\n className=\"h-11 w-auto max-w-[180px]\"\n />\n </Link>\n );\n}\n\n/** Merchant-authored description HTML -- mirrors the Twig theme's\n * `store.description|raw`. Renders nothing when the store has none set. */\nfunction FooterDescription({ className }: { className: string }) {\n const { store } = useTwilight();\n if (!store.description) return null;\n return (\n <div\n className={`store-footer__desc opacity-80 ${className}`}\n dangerouslySetInnerHTML={{ __html: store.description }}\n />\n );\n}\n\n/** The store's phone and email as one \"Contact us: …\" row under the description\n * (`<salla-contacts>`'s compact `isHeader` layout, which shows only those two).\n * Renders nothing when the store has neither. */\nfunction FooterContacts({ className }: { className: string }) {\n const { store } = useTwilight();\n const { t } = useTranslation();\n // The web component fills its light DOM once the SDK is ready, which can come before\n // React hydrates the footer's Suspense boundary: a hydration error (React #418).\n const isClient = useIsClient();\n if (!store.contacts?.phone && !store.contacts?.email) return null;\n return (\n <div className={`store-footer__contacts ${className}`}>\n {isClient && (\n <SallaContacts\n contacts={store.contacts}\n contactsTitle={t('blocks.footer.social', 'Contact us')}\n isHeader\n />\n )}\n </div>\n );\n}\n\n/** Centered layout: logo, description, contacts, social, footer menu, trust\n * badges and app buttons stacked as one centered column. */\nfunction FooterCenteredBody({ inSheet, isDark }: { inSheet: boolean; isDark: boolean }) {\n return (\n <div className=\"container mx-auto flex max-w-2xl flex-col items-center gap-6 text-center\">\n <FooterLogo className=\"\" />\n <FooterDescription className=\"\" />\n <FooterContacts className=\"\" />\n <SallaSocial />\n\n <FooterLinksMenu\n inSheet={inSheet}\n className=\"store-footer__menu store-footer__menu--inline\"\n dark={isDark}\n />\n\n <FooterTrust dark={isDark} centered />\n\n <FooterApps className=\"flex flex-col items-center gap-3\" />\n </div>\n );\n}\n\n/** Columns layout: brand (logo / description / contacts / social / trust) and app\n * buttons side by side, with the footer menu as its own labeled column. */\nfunction FooterColumnsBody({ inSheet, isDark }: { inSheet: boolean; isDark: boolean }) {\n const { t } = useTranslation();\n\n return (\n <div className=\"container grid grid-cols-1 gap-10 sm:grid-cols-2 lg:grid-cols-4 lg:gap-16\">\n <div className=\"store-footer__brand rtl:lg:pl-16 ltr:lg:pr-16 sm:col-span-2\">\n <FooterLogo className=\"mb-5\" />\n <FooterDescription className=\"max-w-sm leading-6 my-5\" />\n <FooterContacts className=\"mb-6\" />\n <SallaSocial className=\"block mb-6\" />\n <FooterTrust dark={isDark} centered={false} />\n </div>\n\n <FooterLinksMenu\n inSheet={inSheet}\n className=\"store-footer__menu store-footer__menu--stacked\"\n heading={t('blocks.footer.important_links', 'Important links')}\n dark={isDark}\n />\n\n <FooterApps className=\"\" />\n </div>\n );\n}\n\nexport interface FooterProps {\n /**\n * Renders as a plain `<div>` (no second `<footer>` landmark) with the\n * `footer:start` / `footer:end` hook slots skipped -- for a theme that\n * repeats these widgets somewhere other than the page's own footer (a\n * mobile sheet, for example) rather than rendering the real page footer a\n * second time.\n */\n inSheet?: boolean;\n}\n\n/**\n * Storefront footer.\n *\n * Two layouts, chosen by the `footer_layout` theme setting:\n * - **columns** (default): logo / description / social / trust badges, the\n * footer menu (\"important links\"), and app-store buttons, side by side.\n * - **centered**: the same pieces stacked as one centered column, with the\n * footer menu laid out as an inline, pipe-separated row.\n *\n * Styling for the handful of pieces rendered by web components this owns no\n * markup for (`<salla-social>`'s `.social-link` icons, `<salla-menu>`'s\n * `.s-menu-footer-item` rows, `<salla-payments>`'s `.s-payments-list-item`\n * icons) is the consuming theme's own responsibility, the same way\n * `inSheet`'s own presentation is -- this component owns structure and data,\n * not every pixel.\n */\nexport function Footer({ inSheet = false }: FooterProps = {}) {\n const { store, theme } = useTwilight();\n const { t } = useTranslation();\n const year = new Date().getFullYear();\n const isCentered = theme.settings?.footer_layout === 'centered';\n const isDark = !!theme.settings?.footer_is_dark;\n\n const Root = inSheet ? 'div' : 'footer';\n\n return (\n <Root\n className={`store-footer store-footer--${isCentered ? 'centered' : 'columns'}${\n inSheet ? ' store-footer--sheet' : ''\n } relative mt-8 sm:mt-16 ${isDark ? 'bg-[#0E0F0F] text-white' : 'bg-[#F4F7F2] text-gray-600'}`}\n suppressHydrationWarning\n >\n {!inSheet && <HookSlot name=\"footer:start\" />}\n\n <div\n aria-label=\"footer\"\n className={`store-footer__inner border-b py-8 lg:py-16 ${\n isDark ? 'bg-[#1D1F1F] border-dashed border-white/10' : 'bg-transparent border-gray-200'\n }`}\n >\n {isCentered ? (\n <FooterCenteredBody inSheet={inSheet} isDark={isDark} />\n ) : (\n <FooterColumnsBody inSheet={inSheet} isDark={isDark} />\n )}\n </div>\n\n <div className=\"store-footer__bottom container md:flex items-center justify-between gap-4 py-4 lg:py-7 text-center\">\n <span className={`text-sm copyright-text ${isDark ? 'text-gray-400' : 'text-gray-700'}`}>\n <HookSlot\n name=\"copyright\"\n context={{ storeName: store.name }}\n fallback={\n <>\n {t('blocks.footer.copyright', 'All rights reserved')}{' '}\n <Link to=\"/\" className=\"transition-opacity hover:opacity-75 hover:text-primary\">\n {store.name}\n </Link>{' '}\n © {year}\n <MadeWithSalla className=\"ms-2\" />\n </>\n }\n />\n </span>\n\n <SallaPayments />\n </div>\n\n {!inSheet && <HookSlot name=\"footer:end\" />}\n </Root>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/components/layout/Footer.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAiBA,IAAM,YAAA,GACJ,+HAAA;AAOF,SAAS,SAAA,CAAU,EAAE,IAAA,EAAK,EAAsB;AAC9C,EAAA,MAAM,EAAE,KAAA,EAAM,GAAI,WAAA,EAAY;AAC9B,EAAA,MAAM,EAAE,CAAA,EAAE,GAAI,cAAA,EAAe;AAC7B,EAAA,MAAM,CAAC,IAAA,EAAM,OAAO,CAAA,GAAI,SAAS,KAAK,CAAA;AACtC,EAAA,MAAM,MAAA,GAAS,KAAA,CAAM,QAAA,EAAU,GAAA,EAAK,MAAA;AACpC,EAAA,MAAM,WAAA,GAAc,KAAA,CAAM,QAAA,EAAU,GAAA,EAAK,WAAA;AACzC,EAAA,IAAI,CAAC,QAAQ,OAAO,IAAA;AAEpB,EAAA,uBACE,IAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,aAAA,EAAY,kBAAA;AAAA,MACZ,SAAA,EAAU,4DAAA;AAAA,MAET,QAAA,EAAA;AAAA,QAAA,WAAA,oBACC,IAAA,CAAA,QAAA,EAAA,EACE,QAAA,EAAA;AAAA,0BAAA,GAAA;AAAA,YAAC,QAAA;AAAA,YAAA;AAAA,cACC,IAAA,EAAK,QAAA;AAAA,cACL,aAAA,EAAY,8BAAA;AAAA,cACZ,SAAA,EAAU,iCAAA;AAAA,cACV,YAAA,EAAY,CAAA,CAAE,iCAAA,EAAmC,iBAAiB,CAAA;AAAA,cAClE,eAAA,EAAc,QAAA;AAAA,cACd,OAAA,EAAS,MAAM,OAAA,CAAQ,IAAI,CAAA;AAAA,cAE3B,QAAA,kBAAA,GAAA;AAAA,gBAAC,KAAA;AAAA,gBAAA;AAAA,kBACC,GAAA,EAAK,YAA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AA,EAAA;AAAA,gBAAA,CAAA,CAAE,2BAA2B,qBAAqB,CAAA;AAAA,gBAAG,GAAA;AAAA,oCACrD,IAAA,EAAA,EAAK,EAAA,EAAG,KAAI,SAAA,EAAU,wDAAA,EACpB,gBAAM,IAAA,EACT,CAAA;AAAA,gBAAQ,GAAA;AAAA,gBAAI,OAAA;AAAA,gBACT,IAAA;AAAA,gCACH,GAAA,CAAC,aAAA,EAAA,EAAc,SAAA,EAAU,MAAA,EAAO;AAAA,eAAA,EAClC;AAAA;AAAA,WAEJ,EACF,CAAA;AAAA,8BAEC,aAAA,EAAA,EAAc;AAAA,SAAA,EACjB,CAAA;AAAA,QAEC,CAAC,OAAA,oBAAW,GAAA,CAAC,QAAA,EAAA,EAAS,MAAK,YAAA,EAAa;AAAA;AAAA;AAAA,GAC3C;AAEJ","file":"chunk-5T4MJAUN.js","sourcesContent":["import { useState } from 'react';\nimport { SallaAppsIcons } from '@salla.sa/twilight-components-react/apps-icons';\nimport { SallaContacts } from '@salla.sa/twilight-components-react/contacts';\nimport { SallaSocial } from '@salla.sa/twilight-components-react/social';\nimport { SallaMenu } from '@salla.sa/twilight-components-react/menu';\nimport { SallaTrustBadges } from '@salla.sa/twilight-components-react/trust-badges';\nimport { SallaPayments } from '@salla.sa/twilight-components-react/payments';\nimport { useTwilight } from '../../providers/twilight-context';\nimport { useTranslation } from '../../providers/I18nProvider';\nimport { HookSlot } from '../../hooks/HookSlot';\nimport { useIsClient } from '../../hooks/useIsClient';\nimport { Link, Image } from '../common';\nimport { ImageModal } from '../modal';\nimport { MadeWithSalla } from './MadeWithSalla';\n\n/** Salla's value-added-tax badge icon (70×70, CDN-resized) — a platform\n * asset shared by every store, not specific to any one theme. */\nconst TAX_ICON_URL =\n 'https://cdn.salla.network/cdn-cgi/image/fit=scale-down,width=70,height=70,onerror=redirect,format=auto/images/tax.png?v=2.0.5';\n\n/**\n * The store's value-added-tax registration: the tax number, plus the certificate as\n * the tax icon that opens the certificate image full size in a modal. Nothing shows\n * when the store has no tax number.\n */\nfunction FooterTax({ dark }: { dark: boolean }) {\n const { store } = useTwilight();\n const { t } = useTranslation();\n const [open, setOpen] = useState(false);\n const number = store.settings?.tax?.number;\n const certificate = store.settings?.tax?.certificate;\n if (!number) return null;\n\n return (\n <div\n data-testid=\"store-footer-tax\"\n className=\"store-footer__tax flex items-end gap-2 rtl:space-x-reverse\"\n >\n {certificate && (\n <>\n <button\n type=\"button\"\n data-testid=\"store-footer-tax-certificate\"\n className=\"store-footer__tax-cert shrink-0\"\n aria-label={t('common.elements.tax_certificate', 'Tax Certificate')}\n aria-haspopup=\"dialog\"\n onClick={() => setOpen(true)}\n >\n <img\n src={TAX_ICON_URL}\n alt={t('common.elements.tax_certificate', 'Tax Certificate')}\n width={40}\n height={50}\n loading=\"lazy\"\n decoding=\"async\"\n className=\"w-10 rounded-sm transition-opacity hover:opacity-80\"\n />\n </button>\n <ImageModal\n isOpen={open}\n onClose={() => setOpen(false)}\n src={certificate}\n alt={t('common.elements.tax_certificate', 'Tax Certificate')}\n title={t('common.elements.tax_certificate', 'Tax Certificate')}\n />\n </>\n )}\n <div>\n <p className={`mb-1 text-sm opacity-70 ${dark ? 'text-white' : ''}`}>\n {t('common.elements.tax_number', 'Tax Number')}\n </p>\n <b className=\"text-sm\">{number}</b>\n </div>\n </div>\n );\n}\n\n/** Saudi Business Center (SBC) logo, CDN-versioned like the tax icon -- also a\n * platform asset, not theme-specific. */\nconst SBC_ICON_URL = 'https://cdn.salla.network/images/sbc.png?v=2.0.5';\n\n/**\n * The store's Saudi Business Center certificate: a \"Trusted by Business Platform\" badge that\n * opens the certificate's page on the SBC site so visitors can verify the merchant. Nothing\n * shows when the store has no certificate.\n */\nfunction FooterSbc({ dark }: { dark: boolean }) {\n const { store } = useTwilight();\n const { t } = useTranslation();\n const id = store.settings?.certificate?.id;\n if (!id) return null;\n\n return (\n <a\n href={`https://eauthenticate.saudibusiness.gov.sa/certificate-details/${encodeURIComponent(id)}`}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n data-testid=\"store-footer-sbc\"\n className=\"store-footer__sbc flex items-center gap-2.5 transition-opacity hover:opacity-75\"\n >\n <img\n src={SBC_ICON_URL}\n alt={`SBC ${id}`}\n width={56}\n height={40}\n loading=\"lazy\"\n decoding=\"async\"\n className=\"h-10 w-14 rounded-sm\"\n />\n <div>\n <p className={`text-xs opacity-70 ${dark ? 'text-white' : ''}`}>\n {t('blocks.footer.sbc_trusted_by', 'Trusted by')}\n </p>\n <b className=\"text-sm\">{t('blocks.footer.sbc_platform', 'Business Platform')}</b>\n </div>\n </a>\n );\n}\n\n/** Trust badges, the tax registration and the SBC badge, side by side (wrapping on narrow columns). */\nfunction FooterTrust({ dark, centered }: { dark: boolean; centered: boolean }) {\n return (\n <div\n data-testid=\"store-footer-trust\"\n className={`store-footer__trust flex flex-wrap items-end gap-x-6 gap-y-3${centered ? ' justify-center' : ''}`}\n >\n <FooterTax dark={dark} />\n <FooterSbc dark={dark} />\n <SallaTrustBadges {...(dark ? { dark: true } : {})} />\n </div>\n );\n}\n\n/**\n * The footer's own menu of (\"important\") links -- skipped entirely when\n * `inSheet`, for a theme that opens it from somewhere else of its own (a\n * mobile account sheet, a dedicated links screen, …) instead; showing it\n * again down here would just be a redundant second copy. `heading` wraps it\n * in the grid layout's own `.store-footer__links` column; the centered\n * layout's inline row has none.\n */\nfunction FooterLinksMenu({\n inSheet,\n className,\n heading,\n dark,\n}: {\n inSheet: boolean;\n className: string;\n heading?: string;\n dark: boolean;\n}) {\n if (inSheet) return null;\n\n const menu = <SallaMenu source=\"footer\" className={className} suppressHydrationWarning />;\n if (!heading) return menu;\n\n return (\n <div className=\"store-footer__links\">\n <h3 className={`mb-3 text-lg font-bold lg:mb-5 ${dark ? 'text-white' : 'text-gray-900'}`}>\n {heading}\n </h3>\n {menu}\n </div>\n );\n}\n\n/** App-store / Google-Play buttons. Nothing shows -- not even the wrapping\n * div -- when the store has neither link set. */\nfunction FooterApps({ className }: { className: string }) {\n const { store } = useTwilight();\n const { t } = useTranslation();\n // The web component fills its light DOM before React hydrates the footer, a hydration error.\n const isClient = useIsClient();\n if (!store.apps?.appstore && !store.apps?.googleplay) return null;\n\n return (\n <div data-testid=\"store-footer-apps\" className={`store-footer__apps ${className}`}>\n {isClient && (\n <SallaAppsIcons\n apps={store.apps}\n appsTitle={t('blocks.footer.download_apps', 'Get our apps')}\n />\n )}\n </div>\n );\n}\n\n/** The logo link, same shape in both layouts -- only its own spacing differs. */\nfunction FooterLogo({ className }: { className: string }) {\n const { store } = useTwilight();\n return (\n <Link\n to=\"/\"\n className={`store-footer__logo inline-flex items-center m-0 transition-opacity hover:opacity-75 ${className}`}\n >\n <Image\n src={store.logo}\n alt={store.name || 'Store'}\n width={150}\n height={44}\n objectFit=\"contain\"\n className=\"h-11 w-auto max-w-[180px]\"\n />\n </Link>\n );\n}\n\n/** Merchant-authored description HTML -- mirrors the Twig theme's\n * `store.description|raw`. Renders nothing when the store has none set. */\nfunction FooterDescription({ className }: { className: string }) {\n const { store } = useTwilight();\n if (!store.description) return null;\n return (\n <div\n className={`store-footer__desc opacity-80 ${className}`}\n dangerouslySetInnerHTML={{ __html: store.description }}\n />\n );\n}\n\n/** The store's phone and email as one \"Contact us: …\" row under the description\n * (`<salla-contacts>`'s compact `isHeader` layout, which shows only those two).\n * Renders nothing when the store has neither. */\nfunction FooterContacts({ className }: { className: string }) {\n const { store } = useTwilight();\n const { t } = useTranslation();\n // The web component fills its light DOM once the SDK is ready, which can come before\n // React hydrates the footer's Suspense boundary: a hydration error (React #418).\n const isClient = useIsClient();\n if (!store.contacts?.phone && !store.contacts?.email) return null;\n return (\n <div className={`store-footer__contacts ${className}`}>\n {isClient && (\n <SallaContacts\n contacts={store.contacts}\n contactsTitle={t('blocks.footer.social', 'Contact us')}\n isHeader\n />\n )}\n </div>\n );\n}\n\n/** Centered layout: logo, description, contacts, social, footer menu, trust\n * badges and app buttons stacked as one centered column. */\nfunction FooterCenteredBody({ inSheet, isDark }: { inSheet: boolean; isDark: boolean }) {\n return (\n <div className=\"container mx-auto flex max-w-2xl flex-col items-center gap-6 text-center\">\n <FooterLogo className=\"\" />\n <FooterDescription className=\"\" />\n <FooterContacts className=\"\" />\n <SallaSocial />\n\n <FooterLinksMenu\n inSheet={inSheet}\n className=\"store-footer__menu store-footer__menu--inline\"\n dark={isDark}\n />\n\n <FooterTrust dark={isDark} centered />\n\n <FooterApps className=\"flex flex-col items-center gap-3\" />\n </div>\n );\n}\n\n/** Columns layout: brand (logo / description / contacts / social / trust) and app\n * buttons side by side, with the footer menu as its own labeled column. */\nfunction FooterColumnsBody({ inSheet, isDark }: { inSheet: boolean; isDark: boolean }) {\n const { t } = useTranslation();\n\n return (\n <div className=\"container grid grid-cols-1 gap-10 sm:grid-cols-2 lg:grid-cols-4 lg:gap-16\">\n <div className=\"store-footer__brand rtl:lg:pl-16 ltr:lg:pr-16 sm:col-span-2\">\n <FooterLogo className=\"mb-5\" />\n <FooterDescription className=\"max-w-sm leading-6 my-5\" />\n <FooterContacts className=\"mb-6\" />\n <SallaSocial className=\"block mb-6\" />\n <FooterTrust dark={isDark} centered={false} />\n </div>\n\n <FooterLinksMenu\n inSheet={inSheet}\n className=\"store-footer__menu store-footer__menu--stacked\"\n heading={t('blocks.footer.important_links', 'Important links')}\n dark={isDark}\n />\n\n <FooterApps className=\"\" />\n </div>\n );\n}\n\nexport interface FooterProps {\n /**\n * Renders as a plain `<div>` (no second `<footer>` landmark) with the\n * `footer:start` / `footer:end` hook slots skipped -- for a theme that\n * repeats these widgets somewhere other than the page's own footer (a\n * mobile sheet, for example) rather than rendering the real page footer a\n * second time.\n */\n inSheet?: boolean;\n}\n\n/**\n * Storefront footer.\n *\n * Two layouts, chosen by the `footer_layout` theme setting:\n * - **columns** (default): logo / description / social / trust badges, the\n * footer menu (\"important links\"), and app-store buttons, side by side.\n * - **centered**: the same pieces stacked as one centered column, with the\n * footer menu laid out as an inline, pipe-separated row.\n *\n * Styling for the handful of pieces rendered by web components this owns no\n * markup for (`<salla-social>`'s `.social-link` icons, `<salla-menu>`'s\n * `.s-menu-footer-item` rows, `<salla-payments>`'s `.s-payments-list-item`\n * icons) is the consuming theme's own responsibility, the same way\n * `inSheet`'s own presentation is -- this component owns structure and data,\n * not every pixel.\n */\nexport function Footer({ inSheet = false }: FooterProps = {}) {\n const { store, theme } = useTwilight();\n const { t } = useTranslation();\n const year = new Date().getFullYear();\n const isCentered = theme.settings?.footer_layout === 'centered';\n const isDark = !!theme.settings?.footer_is_dark;\n\n const Root = inSheet ? 'div' : 'footer';\n\n return (\n <Root\n className={`store-footer store-footer--${isCentered ? 'centered' : 'columns'}${\n inSheet ? ' store-footer--sheet' : ''\n } relative mt-8 sm:mt-16 ${isDark ? 'bg-[#0E0F0F] text-white' : 'bg-[#F4F7F2] text-gray-600'}`}\n suppressHydrationWarning\n >\n {!inSheet && <HookSlot name=\"footer:start\" />}\n\n <div\n aria-label=\"footer\"\n className={`store-footer__inner border-b py-8 lg:py-16 ${\n isDark ? 'bg-[#1D1F1F] border-dashed border-white/10' : 'bg-transparent border-gray-200'\n }`}\n >\n {isCentered ? (\n <FooterCenteredBody inSheet={inSheet} isDark={isDark} />\n ) : (\n <FooterColumnsBody inSheet={inSheet} isDark={isDark} />\n )}\n </div>\n\n <div className=\"store-footer__bottom container md:flex items-center justify-between gap-4 py-4 lg:py-7 text-center\">\n <span className={`text-sm copyright-text ${isDark ? 'text-gray-400' : 'text-gray-700'}`}>\n <HookSlot\n name=\"copyright\"\n context={{ storeName: store.name }}\n fallback={\n <>\n {t('blocks.footer.copyright', 'All rights reserved')}{' '}\n <Link to=\"/\" className=\"transition-opacity hover:opacity-75 hover:text-primary\">\n {store.name}\n </Link>{' '}\n © {year}\n <MadeWithSalla className=\"ms-2\" />\n </>\n }\n />\n </span>\n\n <SallaPayments />\n </div>\n\n {!inSheet && <HookSlot name=\"footer:end\" />}\n </Root>\n );\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { api } from './chunk-
|
|
1
|
+
import { api } from './chunk-RB7RHMKJ.js';
|
|
2
2
|
import { queryOptions } from '@tanstack/react-query';
|
|
3
3
|
|
|
4
4
|
var notification = {
|
|
@@ -24,5 +24,5 @@ var notification = {
|
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
export { notification };
|
|
27
|
-
//# sourceMappingURL=chunk-
|
|
28
|
-
//# sourceMappingURL=chunk-
|
|
27
|
+
//# sourceMappingURL=chunk-6H6BVZBV.js.map
|
|
28
|
+
//# sourceMappingURL=chunk-6H6BVZBV.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/api/notification.ts"],"names":[],"mappings":";;;AAcO,IAAM,YAAA,GAAe;AAAA,EAC1B,MAAM,YAAgD;AACpD,IAAA,MAAM,WAAW,MAAM,GAAA,CACpB,GAAA,CAAI,eAAe,EACnB,IAAA,EAAmF;AACtF,IAAA,OAAO;AAAA,MACL,IAAA,EAAM,QAAA,CAAS,IAAA,IAAQ,EAAC;AAAA,MACxB,QAAQ,QAAA,CAAS;AAAA,KACnB;AAAA,EACF,CAAA;AAAA,EAEA,UAAA,EAAY,OAAO,EAAA,KAA8B;AAC/C,IAAA,MAAM,IAAI,GAAA,CAAI,CAAA,cAAA,EAAiB,EAAE,CAAA,KAAA,CAAO,EAAE,IAAA,EAAK;AAAA,EACjD,CAAA;AAAA,EAEA,eAAe,YAA2B;AACxC,IAAA,MAAM,GAAA,CAAI,GAAA,CAAI,wBAAwB,CAAA,CAAE,IAAA,EAAK;AAAA,EAC/C,CAAA;AAAA,EAEA,OAAA,EAAS;AAAA,IACP,IAAA,EAAM,MACJ,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,CAAC,eAAA,EAAiB,MAAM,CAAA;AAAA,MAClC,OAAA,EAAS,MAAM,YAAA,CAAa,IAAA;AAAK,KAClC;AAAA;AAEP","file":"chunk-
|
|
1
|
+
{"version":3,"sources":["../src/api/notification.ts"],"names":[],"mappings":";;;AAcO,IAAM,YAAA,GAAe;AAAA,EAC1B,MAAM,YAAgD;AACpD,IAAA,MAAM,WAAW,MAAM,GAAA,CACpB,GAAA,CAAI,eAAe,EACnB,IAAA,EAAmF;AACtF,IAAA,OAAO;AAAA,MACL,IAAA,EAAM,QAAA,CAAS,IAAA,IAAQ,EAAC;AAAA,MACxB,QAAQ,QAAA,CAAS;AAAA,KACnB;AAAA,EACF,CAAA;AAAA,EAEA,UAAA,EAAY,OAAO,EAAA,KAA8B;AAC/C,IAAA,MAAM,IAAI,GAAA,CAAI,CAAA,cAAA,EAAiB,EAAE,CAAA,KAAA,CAAO,EAAE,IAAA,EAAK;AAAA,EACjD,CAAA;AAAA,EAEA,eAAe,YAA2B;AACxC,IAAA,MAAM,GAAA,CAAI,GAAA,CAAI,wBAAwB,CAAA,CAAE,IAAA,EAAK;AAAA,EAC/C,CAAA;AAAA,EAEA,OAAA,EAAS;AAAA,IACP,IAAA,EAAM,MACJ,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,CAAC,eAAA,EAAiB,MAAM,CAAA;AAAA,MAClC,OAAA,EAAS,MAAM,YAAA,CAAa,IAAA;AAAK,KAClC;AAAA;AAEP","file":"chunk-6H6BVZBV.js","sourcesContent":["import { queryOptions } from '@tanstack/react-query';\nimport { api } from './client';\nimport type { Notification } from '../routes/account/notifications/types';\n\nexport interface NotificationsListResponse {\n data: Notification[];\n cursor: {\n current: number;\n previous: number | null;\n next: number | null;\n count: number;\n };\n}\n\nexport const notification = {\n list: async (): Promise<NotificationsListResponse> => {\n const response = await api\n .get('notifications')\n .json<{ data: Notification[] | null; cursor: NotificationsListResponse['cursor'] }>();\n return {\n data: response.data ?? [],\n cursor: response.cursor,\n };\n },\n\n markAsRead: async (id: number): Promise<void> => {\n await api.put(`notifications/${id}/read`).json();\n },\n\n markAllAsRead: async (): Promise<void> => {\n await api.put('notifications/read-all').json();\n },\n\n queries: {\n list: () =>\n queryOptions({\n queryKey: ['notifications', 'list'],\n queryFn: () => notification.list(),\n }),\n },\n};\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { api } from './chunk-
|
|
1
|
+
import { api } from './chunk-RB7RHMKJ.js';
|
|
2
2
|
|
|
3
3
|
// src/api/wallet.ts
|
|
4
4
|
var wallet = {
|
|
@@ -20,5 +20,5 @@ var wallet = {
|
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
export { wallet };
|
|
23
|
-
//# sourceMappingURL=chunk-
|
|
24
|
-
//# sourceMappingURL=chunk-
|
|
23
|
+
//# sourceMappingURL=chunk-6QIF6WJH.js.map
|
|
24
|
+
//# sourceMappingURL=chunk-6QIF6WJH.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/api/wallet.ts"],"names":[],"mappings":";;;AAgCO,IAAM,MAAA,GAAS;AAAA,EACpB,IAAA,EAAM,OAAO,MAAA,GAA2B,EAAC,KAAiC;AACxE,IAAA,MAAM,EAAE,IAAA,GAAO,CAAA,EAAG,OAAA,GAAU,EAAA,EAAI,QAAO,GAAI,MAAA;AAE3C,IAAA,MAAM,YAAA,GAAe,IAAI,eAAA,EAAgB;AACzC,IAAA,YAAA,CAAa,GAAA,CAAI,MAAA,EAAQ,MAAA,CAAO,IAAI,CAAC,CAAA;AACrC,IAAA,YAAA,CAAa,GAAA,CAAI,UAAA,EAAY,MAAA,CAAO,OAAO,CAAC,CAAA;AAE5C,IAAA,MAAM,UAAmC,EAAC;AAC1C,IAAA,IAAI,MAAA,UAAgB,MAAA,GAAS,MAAA;AAE7B,IAAA,MAAM,QAAA,GAAW,MAAM,GAAA,CACpB,GAAA,CAAI,CAAA,eAAA,EAAkB,YAAA,CAAa,QAAA,EAAU,CAAA,CAAA,EAAI,OAAc,CAAA,CAC/D,IAAA,EAAsE;AAEzE,IAAA,MAAM,YAAA,GAAe,SAAS,IAAA,CAAK,YAAA;AAEnC,IAAA,OAAO;AAAA,MACL,KAAA,EAAO,YAAA,CAAa,IAAA,IAAQ,EAAC;AAAA,MAC7B,MAAM,YAAA,CAAa,aAAA;AAAA,MACnB,OAAA,EAAS,SAAS,IAAA,CAAK;AAAA,KACzB;AAAA,EACF;AACF","file":"chunk-
|
|
1
|
+
{"version":3,"sources":["../src/api/wallet.ts"],"names":[],"mappings":";;;AAgCO,IAAM,MAAA,GAAS;AAAA,EACpB,IAAA,EAAM,OAAO,MAAA,GAA2B,EAAC,KAAiC;AACxE,IAAA,MAAM,EAAE,IAAA,GAAO,CAAA,EAAG,OAAA,GAAU,EAAA,EAAI,QAAO,GAAI,MAAA;AAE3C,IAAA,MAAM,YAAA,GAAe,IAAI,eAAA,EAAgB;AACzC,IAAA,YAAA,CAAa,GAAA,CAAI,MAAA,EAAQ,MAAA,CAAO,IAAI,CAAC,CAAA;AACrC,IAAA,YAAA,CAAa,GAAA,CAAI,UAAA,EAAY,MAAA,CAAO,OAAO,CAAC,CAAA;AAE5C,IAAA,MAAM,UAAmC,EAAC;AAC1C,IAAA,IAAI,MAAA,UAAgB,MAAA,GAAS,MAAA;AAE7B,IAAA,MAAM,QAAA,GAAW,MAAM,GAAA,CACpB,GAAA,CAAI,CAAA,eAAA,EAAkB,YAAA,CAAa,QAAA,EAAU,CAAA,CAAA,EAAI,OAAc,CAAA,CAC/D,IAAA,EAAsE;AAEzE,IAAA,MAAM,YAAA,GAAe,SAAS,IAAA,CAAK,YAAA;AAEnC,IAAA,OAAO;AAAA,MACL,KAAA,EAAO,YAAA,CAAa,IAAA,IAAQ,EAAC;AAAA,MAC7B,MAAM,YAAA,CAAa,aAAA;AAAA,MACnB,OAAA,EAAS,SAAS,IAAA,CAAK;AAAA,KACzB;AAAA,EACF;AACF","file":"chunk-6QIF6WJH.js","sourcesContent":["import { api } from './client';\n\nexport interface TransactionItem {\n id: number;\n order_id: number;\n transaction_type: string;\n action_type: string;\n type: string;\n title: string;\n description: string;\n amount: number;\n created_at: number;\n expired_at: number;\n}\n\nexport interface WalletListParams {\n page?: number;\n perPage?: number;\n signal?: AbortSignal;\n}\n\nexport interface WalletListResponse {\n data: TransactionItem[];\n next_page_url: string | null;\n}\n\nexport interface WalletListResult {\n items: TransactionItem[];\n next: string | null;\n balance: number;\n}\n\nexport const wallet = {\n list: async (params: WalletListParams = {}): Promise<WalletListResult> => {\n const { page = 1, perPage = 10, signal } = params;\n\n const searchParams = new URLSearchParams();\n searchParams.set('page', String(page));\n searchParams.set('per_page', String(perPage));\n\n const options: Record<string, unknown> = {};\n if (signal) options.signal = signal;\n\n const response = await api\n .get(`balance/wallet?${searchParams.toString()}`, options as any)\n .json<{ data: { transactions: WalletListResponse; balance: number } }>();\n\n const transactions = response.data.transactions;\n\n return {\n items: transactions.data ?? [],\n next: transactions.next_page_url,\n balance: response.data.balance,\n };\n },\n};\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { extractTokenFromCookies, isPreviewHost } from './chunk-
|
|
1
|
+
import { extractTokenFromCookies, isPreviewHost } from './chunk-4E6FD5W7.js';
|
|
2
2
|
|
|
3
3
|
// src/utils/maintenance.ts
|
|
4
4
|
var VIEW_AS_OWNER_COOKIE_NAME = "salla_view_as";
|
|
@@ -73,5 +73,5 @@ function withOwnerMaintenanceButton(settings, buttonTitle) {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
export { MAINTENANCE_EVIDENCE_HEADER, VIEW_AS_OWNER_COOKIE_NAME, isNotLaunchedNotice, maintenanceEvidence, maintenanceEvidenceHeader, ownerCookieMatches, ownerLinkMatches, showsMaintenancePage, withOwnerMaintenanceButton, withoutMaintenanceOnPreviewHost };
|
|
76
|
-
//# sourceMappingURL=chunk-
|
|
77
|
-
//# sourceMappingURL=chunk-
|
|
76
|
+
//# sourceMappingURL=chunk-6YEE3VHL.js.map
|
|
77
|
+
//# sourceMappingURL=chunk-6YEE3VHL.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/maintenance.ts"],"names":[],"mappings":";;;AAgBO,IAAM,yBAAA,GAA4B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,EAAA,OAAO,MAAA,CAAO,QAAQ,QAAQ,CAAA,CAC3B,IAAI,CAAC,CAAC,KAAK,KAAK,CAAA,KAAM,GAAG,GAAG,CAAA,CAAA,EAAI,MAAM,OAAA,CAAQ,eAAA,EAAiB,EAAE,CAAC,CAAA,CAAE,CAAA,CACpE,IAAA,CAAK,IAAI,CAAA;AACd;AAKA,IAAM,aAAA,GAAgB,oBAAA;AAGf,IAAM,wBAAA,GAA2B,GAAG,aAAa,CAAA,2CAAA,CAAA;AAcjD,SAAS,oBAAoB,OAAA,EAAyD;AAC3F,EAAA,OAAO,OAAA,EAAS,UAAA,EAAY,OAAA,CAAQ,MAAA,EAAQ,EAAE,CAAA,KAAM,aAAA;AACtD;AAYO,SAAS,0BAAA,CAEd,UAAa,WAAA,EAAwB;AACrC,EAAA,MAAM,UAAU,QAAA,CAAS,mBAAA;AACzB,EAAA,IAAI,QAAA,CAAS,WAAA,KAAgB,IAAA,IAAQ,OAAA,EAAS,cAAc,OAAO,QAAA;AACnE,EAAA,OAAO;AAAA,IACL,GAAG,QAAA;AAAA,IACH,mBAAA,EAAqB;AAAA,MACnB,GAAG,OAAA;AAAA,MACH,YAAA,EAAc,WAAA;AAAA,MACd,iBAAA,EAAmB,WAAA;AAAA,MACnB,UAAA,EAAY;AAAA;AACd,GACF;AACF","file":"chunk-SLBO4SEE.js","sourcesContent":["import type { StoreContext } from '../api/store';\nimport type { MaintenanceDetails } from '../types';\nimport { extractTokenFromCookies, isPreviewHost } from './cookies';\n\n/**\n * Remembers that this browser is the merchant looking at their own closed store.\n *\n * The dashboard's \"view store\" link carries `?utm_source=dashboard&identifier=<store id>`\n * (`portal` for the partners portal). Twig's backend checks that once, keeps\n * `view-as: owner` in the PHP session and lets every later request through; this\n * cookie is that session entry. No `max-age`: a session cookie, as the PHP session\n * was, so closing the browser ends the owner view.\n *\n * The value is the store id the bypass was granted for, checked against the store\n * the settings answer about, so one store's cookie opens no other store.\n */\nexport const VIEW_AS_OWNER_COOKIE_NAME = 'salla_view_as';\n\nconst OWNER_SOURCES = ['dashboard', 'portal'];\n\n/** The id as the URL and the cookie spell it, or null when the settings name none. */\nfunction storeIdOf(settings: StoreContext | null | undefined): string | null {\n const id = settings?.store?.id;\n return id == null ? null : String(id);\n}\n\n/**\n * Whether `href` is the dashboard's link into the merchant's own store:\n * `utm_source` is `dashboard` or `portal`, and `identifier` is this store's id.\n * The backend's own rule, translated.\n */\nexport function ownerLinkMatches(href: string, settings: StoreContext | null | undefined): boolean {\n const storeId = storeIdOf(settings);\n if (!storeId) return false;\n let params: URLSearchParams;\n try {\n params = new URL(href, 'http://localhost').searchParams;\n } catch {\n return false;\n }\n const source = params.get('utm_source');\n return source != null && OWNER_SOURCES.includes(source) && params.get('identifier') === storeId;\n}\n\n/** Whether the cookie remembers an owner view of this store. */\nexport function ownerCookieMatches(\n cookieHeader: string | null,\n settings: StoreContext | null | undefined\n): boolean {\n const storeId = storeIdOf(settings);\n return !!storeId && extractTokenFromCookies(cookieHeader, VIEW_AS_OWNER_COOKIE_NAME) === storeId;\n}\n\n/**\n * Whether this visitor gets the maintenance page instead of the store.\n *\n * True only when the settings say the store is closed and nothing lets the visitor\n * through: neither an owner view (the link or the cookie), nor a session the\n * backend marks `theme.mode === 'preview'`, nor the hosted preview host.\n *\n * The host is what lets the dashboard's theme editor through. The editor frames\n * this storefront on the preview host, and that request has none of the other\n * three: its URL carries no owner link, the owner cookie is `SameSite=Lax` and a\n * cross-site frame neither stores nor sends it, and `theme.mode` is only ever\n * `preview` from a PHP session, which the worker's sessionless API call has not got.\n * The Twig storefront exempts its preview hosts the same way (`CheckStoreStatus`\n * skips `hasCustomDomain()`), and for the same reasons: a merchant customising a\n * store that is closed, or not launched yet, still has to see what they are\n * customising. A merchant's own domain is never a preview host, so a customer of a\n * closed store still gets the page.\n *\n * Loopback is not exempt: on a dev server a closed store shows the maintenance page\n * on purpose, so a theme author can see and test it (see `MaintenanceDevBar`).\n *\n * @param host - the host the request arrived on; see {@link isPreviewHost}. Required\n * rather than optional: a caller that forgot it would quietly bring the editor bug back.\n */\nexport function showsMaintenancePage(\n settings: StoreContext | null | undefined,\n viewAsOwner: boolean,\n host: string | null | undefined\n): boolean {\n return (\n settings?.maintenance === true &&\n !viewAsOwner &&\n settings.theme?.mode !== 'preview' &&\n !isPreviewHost(host)\n );\n}\n\n/**\n * The settings the Salla SDK is initialised with, told the store is open when the\n * page is on the preview host.\n *\n * {@link showsMaintenancePage} lets the preview host render a closed store, but the\n * settings still say `maintenance: true`, and the SDK reads that to draw its\n * merchant maintenance bar. In the theme editor that bar would sit over the very\n * page being customised, offering a \"turn off maintenance\" button to everyone who\n * looks at the preview, a reviewer included. Twig's editor shows no bar either:\n * `CheckStoreStatus` returns before it adds one. The bar is all the SDK uses the flag\n * for, and the maintenance page is decided elsewhere, so nothing else changes.\n */\nexport function withoutMaintenanceOnPreviewHost<T extends Pick<StoreContext, 'maintenance'>>(\n settings: T,\n host: string | null | undefined\n): T {\n if (settings.maintenance !== true || !isPreviewHost(host)) return settings;\n return { ...settings, maintenance: false };\n}\n\n/**\n * The response header a maintenance 503 carries saying which settings decided it.\n *\n * Theme workers write no logs, and the dispatcher's line for a 5xx records the\n * answer's own `x-trace-id` and this header, so the evidence travels on the answer.\n * The backend sets `maintenance` from store-wide state alone (closed, not launched,\n * or the market in maintenance), so `request-id` and `trace` find the settings\n * request it logged, and `cache`/`age` say whether this was a cached copy of one.\n */\nexport const MAINTENANCE_EVIDENCE_HEADER = 'x-twilight-maintenance';\n\n/**\n * What the maintenance decision rested on, as `key=value` pairs. Ids and the API's\n * own header values only: nothing a visitor typed, nothing that identifies them.\n */\nexport function maintenanceEvidence(\n settings: StoreContext | null | undefined\n): Record<string, string> {\n const evidence: Record<string, string> = {};\n if (!settings) return evidence;\n for (const [key, read] of EVIDENCE) {\n const value = read(settings);\n if (value != null && value !== '') evidence[key] = String(value);\n }\n return evidence;\n}\n\nconst EVIDENCE: [string, (settings: StoreContext) => unknown][] = [\n ['store', (s) => s.store?.id],\n ['scope', (s) => s.store?.scope?.id],\n ['requested-scope', (s) => s.requestedScopeId],\n ['mode', (s) => s.theme?.mode],\n ['request-id', (s) => s.answer?.requestId],\n ['trace', (s) => s.answer?.traceId],\n ['cache', (s) => s.answer?.cacheStatus],\n ['age', (s) => s.answer?.age],\n];\n\n/** {@link maintenanceEvidence} as one header value: `store=1; scope=2; cache=HIT`. */\nexport function maintenanceEvidenceHeader(evidence: Record<string, string>): string {\n return Object.entries(evidence)\n .map(([key, value]) => `${key}=${value.replace(/[^\\x21-\\x7e]/g, '')}`)\n .join('; ');\n}\n\n// todo:: drop both once the backend sends `dashboard_url` (or the filled `button_*`) in the\n// settings; until then this mirrors `config('salla.app.dashboard_url')` and the path Twig's\n// `StoreStatusAlertWidget` appends for the owner.\nconst DASHBOARD_URL = 'https://s.salla.sa';\n\n/** The dashboard page where the merchant turns maintenance mode off, as the backend links it. */\nexport const MAINTENANCE_SETTINGS_URL = `${DASHBOARD_URL}/channel/settings?legacy=0#maintenance-mode`;\n\n/**\n * Whether the notice is the one the backend sends for a store that has not launched yet.\n *\n * The settings carry no `launched` flag: a store whose `store::launched` setting is `0`\n * gets `maintenance: true` and `StoreStatusAlertWidget::getData(true)`, the merchant's\n * \"finish launching\" notice, whose button goes to the dashboard's root, and it goes\n * there for every visitor. A closed store's notice links nowhere for a customer and to\n * {@link MAINTENANCE_SETTINGS_URL} for the owner, so the bare dashboard URL tells them\n * apart, as Twig's `CheckStoreStatus` does by rendering `construction` instead of\n * `maintenance`.\n */\n// todo:: read the backend's own flag once the settings send one.\nexport function isNotLaunchedNotice(details: MaintenanceDetails | null | undefined): boolean {\n return details?.button_url?.replace(/\\/+$/, '') === DASHBOARD_URL;\n}\n\n/**\n * The button on the SDK's merchant maintenance bar. The API fills the `button_*`\n * fields only inside Twig's owner session, which the engine's settings request has\n * none of, so the SDK, handed the settings as they are, draws an empty button. The\n * SDK renders only in the store view, so `maintenance: true` there means the owner\n * (or a session the backend marks `theme.mode === 'preview'`, where the SDK mounts\n * no bar; the preview host never gets here, see {@link withoutMaintenanceOnPreviewHost}):\n * the three fields get what Twig's owner branch gives them. The merchant's own title\n * and message stay as they are.\n */\nexport function withOwnerMaintenanceButton<\n T extends Pick<StoreContext, 'maintenance' | 'maintenance_details'>,\n>(settings: T, buttonTitle: string): T {\n const details = settings.maintenance_details;\n if (settings.maintenance !== true || details?.button_title) return settings;\n return {\n ...settings,\n maintenance_details: {\n ...details,\n button_title: buttonTitle,\n button_full_title: buttonTitle,\n button_url: MAINTENANCE_SETTINGS_URL,\n },\n };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/utils/maintenance.ts"],"names":[],"mappings":";;;AAgBO,IAAM,yBAAA,GAA4B;AAEzC,IAAM,aAAA,GAAgB,CAAC,WAAA,EAAa,QAAQ,CAAA;AAG5C,SAAS,UAAU,QAAA,EAA0D;AAC3E,EAAA,MAAM,EAAA,GAAK,UAAU,KAAA,EAAO,EAAA;AAC5B,EAAA,OAAO,EAAA,IAAM,IAAA,GAAO,IAAA,GAAO,MAAA,CAAO,EAAE,CAAA;AACtC;AAOO,SAAS,gBAAA,CAAiB,MAAc,QAAA,EAAoD;AACjG,EAAA,MAAM,OAAA,GAAU,UAAU,QAAQ,CAAA;AAClC,EAAA,IAAI,CAAC,SAAS,OAAO,KAAA;AACrB,EAAA,IAAI,MAAA;AACJ,EAAA,IAAI;AACF,IAAA,MAAA,GAAS,IAAI,GAAA,CAAI,IAAA,EAAM,kBAAkB,CAAA,CAAE,YAAA;AAAA,EAC7C,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,KAAA;AAAA,EACT;AACA,EAAA,MAAM,MAAA,GAAS,MAAA,CAAO,GAAA,CAAI,YAAY,CAAA;AACtC,EAAA,OAAO,MAAA,IAAU,QAAQ,aAAA,CAAc,QAAA,CAAS,MAAM,CAAA,IAAK,MAAA,CAAO,GAAA,CAAI,YAAY,CAAA,KAAM,OAAA;AAC1F;AAGO,SAAS,kBAAA,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A,MACnB,UAAA,EAAY;AAAA;AACd,GACF;AACF","file":"chunk-6YEE3VHL.js","sourcesContent":["import type { StoreContext } from '../api/store';\nimport type { MaintenanceDetails } from '../types';\nimport { extractTokenFromCookies, isPreviewHost } from './cookies';\n\n/**\n * Remembers that this browser is the merchant looking at their own closed store.\n *\n * The dashboard's \"view store\" link carries `?utm_source=dashboard&identifier=<store id>`\n * (`portal` for the partners portal). Twig's backend checks that once, keeps\n * `view-as: owner` in the PHP session and lets every later request through; this\n * cookie is that session entry. No `max-age`: a session cookie, as the PHP session\n * was, so closing the browser ends the owner view.\n *\n * The value is the store id the bypass was granted for, checked against the store\n * the settings answer about, so one store's cookie opens no other store.\n */\nexport const VIEW_AS_OWNER_COOKIE_NAME = 'salla_view_as';\n\nconst OWNER_SOURCES = ['dashboard', 'portal'];\n\n/** The id as the URL and the cookie spell it, or null when the settings name none. */\nfunction storeIdOf(settings: StoreContext | null | undefined): string | null {\n const id = settings?.store?.id;\n return id == null ? null : String(id);\n}\n\n/**\n * Whether `href` is the dashboard's link into the merchant's own store:\n * `utm_source` is `dashboard` or `portal`, and `identifier` is this store's id.\n * The backend's own rule, translated.\n */\nexport function ownerLinkMatches(href: string, settings: StoreContext | null | undefined): boolean {\n const storeId = storeIdOf(settings);\n if (!storeId) return false;\n let params: URLSearchParams;\n try {\n params = new URL(href, 'http://localhost').searchParams;\n } catch {\n return false;\n }\n const source = params.get('utm_source');\n return source != null && OWNER_SOURCES.includes(source) && params.get('identifier') === storeId;\n}\n\n/** Whether the cookie remembers an owner view of this store. */\nexport function ownerCookieMatches(\n cookieHeader: string | null,\n settings: StoreContext | null | undefined\n): boolean {\n const storeId = storeIdOf(settings);\n return !!storeId && extractTokenFromCookies(cookieHeader, VIEW_AS_OWNER_COOKIE_NAME) === storeId;\n}\n\n/**\n * Whether this visitor gets the maintenance page instead of the store.\n *\n * True only when the settings say the store is closed and nothing lets the visitor\n * through: neither an owner view (the link or the cookie), nor a session the\n * backend marks `theme.mode === 'preview'`, nor the hosted preview host.\n *\n * The host is what lets the dashboard's theme editor through. The editor frames\n * this storefront on the preview host, and that request has none of the other\n * three: its URL carries no owner link, the owner cookie is `SameSite=Lax` and a\n * cross-site frame neither stores nor sends it, and `theme.mode` is only ever\n * `preview` from a PHP session, which the worker's sessionless API call has not got.\n * The Twig storefront exempts its preview hosts the same way (`CheckStoreStatus`\n * skips `hasCustomDomain()`), and for the same reasons: a merchant customising a\n * store that is closed, or not launched yet, still has to see what they are\n * customising. A merchant's own domain is never a preview host, so a customer of a\n * closed store still gets the page.\n *\n * Loopback is not exempt: on a dev server a closed store shows the maintenance page\n * on purpose, so a theme author can see and test it (see `MaintenanceDevBar`).\n *\n * @param host - the host the request arrived on; see {@link isPreviewHost}. Required\n * rather than optional: a caller that forgot it would quietly bring the editor bug back.\n */\nexport function showsMaintenancePage(\n settings: StoreContext | null | undefined,\n viewAsOwner: boolean,\n host: string | null | undefined\n): boolean {\n return (\n settings?.maintenance === true &&\n !viewAsOwner &&\n settings.theme?.mode !== 'preview' &&\n !isPreviewHost(host)\n );\n}\n\n/**\n * The settings the Salla SDK is initialised with, told the store is open when the\n * page is on the preview host.\n *\n * {@link showsMaintenancePage} lets the preview host render a closed store, but the\n * settings still say `maintenance: true`, and the SDK reads that to draw its\n * merchant maintenance bar. In the theme editor that bar would sit over the very\n * page being customised, offering a \"turn off maintenance\" button to everyone who\n * looks at the preview, a reviewer included. Twig's editor shows no bar either:\n * `CheckStoreStatus` returns before it adds one. The bar is all the SDK uses the flag\n * for, and the maintenance page is decided elsewhere, so nothing else changes.\n */\nexport function withoutMaintenanceOnPreviewHost<T extends Pick<StoreContext, 'maintenance'>>(\n settings: T,\n host: string | null | undefined\n): T {\n if (settings.maintenance !== true || !isPreviewHost(host)) return settings;\n return { ...settings, maintenance: false };\n}\n\n/**\n * The response header a maintenance 503 carries saying which settings decided it.\n *\n * Theme workers write no logs, and the dispatcher's line for a 5xx records the\n * answer's own `x-trace-id` and this header, so the evidence travels on the answer.\n * The backend sets `maintenance` from store-wide state alone (closed, not launched,\n * or the market in maintenance), so `request-id` and `trace` find the settings\n * request it logged, and `cache`/`age` say whether this was a cached copy of one.\n */\nexport const MAINTENANCE_EVIDENCE_HEADER = 'x-twilight-maintenance';\n\n/**\n * What the maintenance decision rested on, as `key=value` pairs. Ids and the API's\n * own header values only: nothing a visitor typed, nothing that identifies them.\n */\nexport function maintenanceEvidence(\n settings: StoreContext | null | undefined\n): Record<string, string> {\n const evidence: Record<string, string> = {};\n if (!settings) return evidence;\n for (const [key, read] of EVIDENCE) {\n const value = read(settings);\n if (value != null && value !== '') evidence[key] = String(value);\n }\n return evidence;\n}\n\nconst EVIDENCE: [string, (settings: StoreContext) => unknown][] = [\n ['store', (s) => s.store?.id],\n ['scope', (s) => s.store?.scope?.id],\n ['requested-scope', (s) => s.requestedScopeId],\n ['mode', (s) => s.theme?.mode],\n ['request-id', (s) => s.answer?.requestId],\n ['trace', (s) => s.answer?.traceId],\n ['cache', (s) => s.answer?.cacheStatus],\n ['age', (s) => s.answer?.age],\n];\n\n/** {@link maintenanceEvidence} as one header value: `store=1; scope=2; cache=HIT`. */\nexport function maintenanceEvidenceHeader(evidence: Record<string, string>): string {\n return Object.entries(evidence)\n .map(([key, value]) => `${key}=${value.replace(/[^\\x21-\\x7e]/g, '')}`)\n .join('; ');\n}\n\n// todo:: drop both once the backend sends `dashboard_url` (or the filled `button_*`) in the\n// settings; until then this mirrors `config('salla.app.dashboard_url')` and the path Twig's\n// `StoreStatusAlertWidget` appends for the owner.\nconst DASHBOARD_URL = 'https://s.salla.sa';\n\n/** The dashboard page where the merchant turns maintenance mode off, as the backend links it. */\nexport const MAINTENANCE_SETTINGS_URL = `${DASHBOARD_URL}/channel/settings?legacy=0#maintenance-mode`;\n\n/**\n * Whether the notice is the one the backend sends for a store that has not launched yet.\n *\n * The settings carry no `launched` flag: a store whose `store::launched` setting is `0`\n * gets `maintenance: true` and `StoreStatusAlertWidget::getData(true)`, the merchant's\n * \"finish launching\" notice, whose button goes to the dashboard's root, and it goes\n * there for every visitor. A closed store's notice links nowhere for a customer and to\n * {@link MAINTENANCE_SETTINGS_URL} for the owner, so the bare dashboard URL tells them\n * apart, as Twig's `CheckStoreStatus` does by rendering `construction` instead of\n * `maintenance`.\n */\n// todo:: read the backend's own flag once the settings send one.\nexport function isNotLaunchedNotice(details: MaintenanceDetails | null | undefined): boolean {\n return details?.button_url?.replace(/\\/+$/, '') === DASHBOARD_URL;\n}\n\n/**\n * The button on the SDK's merchant maintenance bar. The API fills the `button_*`\n * fields only inside Twig's owner session, which the engine's settings request has\n * none of, so the SDK, handed the settings as they are, draws an empty button. The\n * SDK renders only in the store view, so `maintenance: true` there means the owner\n * (or a session the backend marks `theme.mode === 'preview'`, where the SDK mounts\n * no bar; the preview host never gets here, see {@link withoutMaintenanceOnPreviewHost}):\n * the three fields get what Twig's owner branch gives them. The merchant's own title\n * and message stay as they are.\n */\nexport function withOwnerMaintenanceButton<\n T extends Pick<StoreContext, 'maintenance' | 'maintenance_details'>,\n>(settings: T, buttonTitle: string): T {\n const details = settings.maintenance_details;\n if (settings.maintenance !== true || details?.button_title) return settings;\n return {\n ...settings,\n maintenance_details: {\n ...details,\n button_title: buttonTitle,\n button_full_title: buttonTitle,\n button_url: MAINTENANCE_SETTINGS_URL,\n },\n };\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getInjectedRuntimeEnv, resolveStoreIdentifier } from './chunk-
|
|
1
|
+
import { getInjectedRuntimeEnv, resolveStoreIdentifier } from './chunk-4E6FD5W7.js';
|
|
2
2
|
import { getRequestStore, getTwilightContext } from './chunk-6K34BCUP.js';
|
|
3
3
|
|
|
4
4
|
// src/utils/theme-version.ts
|
|
@@ -121,5 +121,5 @@ function syncSdkThemeVersion(headers) {
|
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
export { getSallaSDK, getStoreIdentifier, onSallaEvent, requestedThemeVersionId, resolveThemeVersionId, syncSdkLocale, syncSdkThemeVersion, whenSallaLoaded, whenSallaReady, withSdkThemeVersion };
|
|
124
|
-
//# sourceMappingURL=chunk-
|
|
125
|
-
//# sourceMappingURL=chunk-
|
|
124
|
+
//# sourceMappingURL=chunk-7XAGU6CT.js.map
|
|
125
|
+
//# sourceMappingURL=chunk-7XAGU6CT.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/theme-version.ts","../src/utils/sdk-helpers.ts"],"names":[],"mappings":";;;;AAqCO,SAAS,uBAAA,GAAyC;AACvD,EAAA,MAAM,EAAE,SAAA,EAAU,GAAI,eAAA,EAAgB;AACtC,EAAA,IAAI,WAAW,OAAO,SAAA;AAEtB,EAAA,OAAO,qBAAA,GAAwB,SAAA,IAAa,IAAA;AAC9C;AAmCA,SAAS,YAAA,CAAa,UAA2C,aAAA,EAA8B;AAC7F,EAAA,MAAM,gBAAA,GAAmB,UAAU,gBAAA,IAAoB,IAAA;AACvD,EAAA,IAAI,aAAA,IAAiB,IAAA,EAAM,OAAO,gBAAA,IAAoB,IAAA;AACtD,EAAA,MAAM,eAAA,GAAkB,QAAA,EAAU,KAAA,EAAO,KAAA,EAAO,EAAA;AAChD,EAAA,OAAA,CAAQ,eAAA,IAAmB,IAAA,GAAO,MAAA,CAAO,eAAe,IAAI,gBAAA,MAAsB,aAAA;AACpF;AAEO,SAAS,qBAAA,CAAsB,gBAA+B,IAAA,EAAqB;AACxF,EAAA,MAAM,YAAY,uBAAA,EAAwB;AAC1C,EAAA,IAAI,WAAW,OAAO,SAAA;AAEtB,EAAA,IAAI;AACF,IAAA,MAAM,QAAA,GAAW,oBAAmB,CAAE,QAAA;AACtC,IAAA,IAAI,CAAC,YAAA,CAAa,QAAA,EAAU,aAAa,GAAG,OAAO,IAAA;AAEnD,IAAA,MAAM,SAAA,GAAY,QAAA,EAAU,KAAA,EAAO,OAAA,EAAS,EAAA;AAC5C,IAAA,OAAO,SAAA,IAAa,IAAA,GAAO,MAAA,CAAO,SAAS,CAA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A,IAAI;AACF,IAAA,GAAA,CAAI,IAAA,EAAM,YAAY,MAAM,CAAA;AAC5B,IAAA,GAAA,CAAI,GAAA,EAAK,SAAA,GAAY,iBAAA,EAAmB,MAAM,CAAA;AAG9C,IAAA,GAAA,CAAI,MAAA,EAAQ,GAAA,GAAM,oBAAA,EAAsB,MAAM,CAAA;AAAA,EAChD,CAAA,CAAA,MAAQ;AAAA,EAER;AACF;AAaA,SAAS,kBAAkB,OAAA,EAAiD;AAC1E,EAAA,MAAM,SAAA,GAAY,uBAAA,EAAwB,IAAK,OAAA,GAAU,cAAc,CAAA;AACvE,EAAA,OAAO,SAAA,IAAa,IAAA,GAAO,MAAA,CAAO,SAAS,CAAA,GAAI,IAAA;AACjD;AAWO,SAAS,oBAA6D,QAAA,EAAgB;AAC3F,EAAA,MAAM,YAAY,uBAAA,EAAwB;AAC1C,EAAA,IAAI,CAAC,WAAW,OAAO,QAAA;AACvB,EAAA,OAAO,EAAE,GAAG,QAAA,EAAU,OAAA,EAAS,EAAE,GAAG,QAAA,CAAS,OAAA,EAAS,cAAA,EAAgB,SAAA,EAAU,EAAE;AACpF;AAcO,SAAS,oBAAoB,OAAA,EAAwC;AAC1E,EAAA,MAAM,MAAM,WAAA,EAAY;AACxB,EAAA,IAAI,CAAC,GAAA,EAAK;AACV,EAAA,MAAM,SAAA,GAAY,kBAAkB,OAAO,CAAA;AAC3C,EAAA,IAAI;AACF,IAAA,IAAI,aAAa,IAAA,EAAM,GAAA,CAAI,GAAA,EAAK,SAAA,GAAY,gBAAgB,SAAS,CAAA;AAAA,gBACzD,GAAA,CAAI,GAAA,EAAK,OAAO,QAAA,EAAU,OAAA,EAAS,SAAS,cAAc,CAAA;AAAA,EACxE,CAAA,CAAA,MAAQ;AAAA,EAER;AACF","file":"chunk-XMRNYUQY.js","sourcesContent":["/**\n * @fileoverview Which version of the theme's settings to render — the one answer,\n * in one place.\n *\n * A merchant's theme settings are versioned. An ordinary storefront visit names\n * no version and gets the live one; the API decides, and reports it back as\n * `theme.profile.id`. Two surfaces need a different one, and both address it in\n * the URL of an iframe:\n *\n * - the merchant's theme editor at `s.salla.sa/themes/editor/…`, which shows a\n * draft version beside the controls that are editing it;\n * - a partner running the theme locally, whose dev server is the iframe.\n *\n * Written as a module of its own rather than inline at the one call site,\n * because `store-identity.ts` exists for exactly this reason: the identifier a\n * request resolved and the identifier it sent were two different values for\n * days, in two files, and every test passed. A second implementation of this is\n * the bug, not a refactor away from one.\n */\nimport { getRequestStore, getTwilightContext } from '../twilight/context';\nimport type { StoreContext } from '../api/store';\nimport { getInjectedRuntimeEnv } from './runtime-env';\n\n/**\n * The version this request asked for, or null when it asked for none.\n *\n * Deliberately excludes the version the *settings* name. This is the answer to\n * \"what did the caller address?\", and it has to be available before any settings\n * exist — React Query keys are built from it, and a key that means one thing\n * during SSR and another after hydration is how a page refetches everything it\n * was just handed.\n *\n * 1. what the request named, seeded by `twilightMiddleware` on a host permitted\n * to name one;\n * 2. what SSR resolved and published into the head, which is all the browser has\n * once the dispatcher has stripped `?versionId=` from the URL.\n */\nexport function requestedThemeVersionId(): string | null {\n const { versionId } = getRequestStore();\n if (versionId) return versionId;\n\n return getInjectedRuntimeEnv().versionId || null;\n}\n\n/**\n * The version every Salla API call is answered with — what goes in `s-version-id`.\n *\n * The requested version outranks the settings, because a request that named one\n * is the only reason this is ever anything but the live version: falling back to\n * the settings there would let the first answer overwrite the question.\n *\n * The settings' own `theme.profile.id` stays as the fallback, unchanged. It is\n * what this header has always carried, and on an ordinary storefront it still\n * is — it keeps the rest of a page's calls pinned to the version the settings\n * call resolved, rather than letting a version go live mid-render.\n *\n * That pin is only good for the scope the settings were requested with. Each\n * market (scope) has its own version, and the API lets a named version outrank\n * the market's: once the shopper switches market, the loaded settings still\n * describe the previous one, and replaying their version — on the settings call\n * for the new market first of all — gets the previous market's theme back, for\n * good. So the version is replayed only while the active scope is the one the\n * settings were answered for (`store.scope`), which is not always the one they\n * were requested for (`requestedScopeId`): the API falls back to another scope\n * when it does not accept the requested one, and that scope's version must not\n * ride along on the next request for the requested one. With no active scope it\n * is replayed only for settings requested without one. Otherwise nothing is\n * sent and the API picks the version of the scope on the request.\n *\n * `activeScopeId` is passed in by the caller that already resolved the scope for\n * its `s-scope-*` headers.\n *\n * Reading the settings is guarded because `getTwilightContext().settings` throws\n * a `SettingsError` when they have not loaded — which is the normal state on the\n * very first call, the settings call itself.\n */\n/** Whether `settings` were answered for `activeScopeId` (see {@link resolveThemeVersionId}). */\nfunction answersScope(settings: StoreContext | null | undefined, activeScopeId: string | null) {\n const requestedScopeId = settings?.requestedScopeId ?? null;\n if (activeScopeId == null) return requestedScopeId == null;\n const answeredScopeId = settings?.store?.scope?.id;\n return (answeredScopeId != null ? String(answeredScopeId) : requestedScopeId) === activeScopeId;\n}\n\nexport function resolveThemeVersionId(activeScopeId: string | null = null): string | null {\n const requested = requestedThemeVersionId();\n if (requested) return requested;\n\n try {\n const settings = getTwilightContext().settings;\n if (!answersScope(settings, activeScopeId)) return null;\n\n const profileId = settings?.theme?.profile?.id;\n return profileId != null ? String(profileId) : null;\n } catch {\n return null;\n }\n}\n","export type { StoreContext } from '../api/store';\nimport type { StoreContext } from '../api/store';\nimport type { SallaSDK } from '../types/salla-sdk';\nimport { resolveStoreIdentifier } from './store-identity';\nimport { requestedThemeVersionId } from './theme-version';\n\nconst isBrowser = typeof window !== 'undefined';\n\n/**\n * Which store to ask the API about — see {@link resolveStoreIdentifier}.\n *\n * A delegation, not a second implementation. This name is the one on the wire\n * (`api/client.ts` sets the `store-identifier` header from it) and the one\n * themes import from `@salla.sa/twilight-theme-engine/utils`, so it stays; what\n * it must never do again is answer differently from the resolver everything\n * else asks. It had its own copy of the order once, missing the store the\n * request names and preferring the build-time `VITE_STORE_DOMAIN` that a\n * deployed worker does not have — so every published theme sent an empty\n * identifier and rendered \"Store Unavailable\".\n */\nexport function getStoreIdentifier(explicit?: string): string {\n return resolveStoreIdentifier(explicit);\n}\n\n/**\n * Get Salla SDK instance if available\n */\nexport function getSallaSDK(): typeof window.salla | undefined {\n if (!isBrowser) return undefined;\n return window.salla;\n}\n\n/** Dispatched on `window` by the SDK as the last step of loading (twilight `src/index.js`). */\nconst SDK_CREATED_EVENT = 'salla::created';\n\nconst noop = () => {};\n\n/**\n * Whether `window.salla` is the SDK, rather than the stub that stands in for it.\n *\n * ⚠️ `window.salla` exists from the first bytes of the page. The `twilight-init`\n * head script defines it with an `onReady`, so app snippets can queue work, and\n * the SDK — a deferred module — fills it in later. React can hydrate and run\n * effects in between, and there `window.salla?.event.on(…)` passes its `?.` and\n * throws `Cannot read properties of undefined (reading 'on')`.\n *\n * The SDK defines `init` and `event` in one synchronous module evaluation and the\n * stub has neither, so either one means it has loaded.\n */\nfunction isLoaded(sdk: typeof window.salla): sdk is SallaSDK {\n return typeof sdk?.init === 'function' || typeof sdk?.event?.on === 'function';\n}\n\n/** An SDK whose event bus can take a listener — what {@link onSallaEvent} needs. */\nfunction hasEventBus(sdk: typeof window.salla): sdk is SallaSDK {\n return typeof sdk?.event?.on === 'function';\n}\n\n/**\n * Run `callback` with the SDK as soon as it has loaded: now if it has, otherwise\n * when it announces itself.\n *\n * Returns a cancel for an effect's cleanup, so a component that unmounts first\n * never has the callback run. An effect that returned early when the SDK was not\n * there yet never ran again — on a cold load, where hydration beats the SDK, the\n * engine never initialised it at all.\n */\nexport function whenSallaLoaded(callback: (sdk: SallaSDK) => void): () => void {\n return whenSalla(isLoaded, callback);\n}\n\nfunction whenSalla(\n isUsable: (sdk: typeof window.salla) => sdk is SallaSDK,\n callback: (sdk: SallaSDK) => void\n): () => void {\n if (!isBrowser) return noop;\n\n if (isUsable(window.salla)) {\n callback(window.salla);\n return noop;\n }\n\n let settled = false;\n const onCreated = () => {\n const sdk = window.salla;\n if (settled || !isUsable(sdk)) return;\n settled = true;\n window.removeEventListener(SDK_CREATED_EVENT, onCreated);\n callback(sdk);\n };\n window.addEventListener(SDK_CREATED_EVENT, onCreated);\n\n return () => {\n settled = true;\n window.removeEventListener(SDK_CREATED_EVENT, onCreated);\n };\n}\n\n/**\n * Run `callback` once the SDK has loaded **and been initialised** — for work that\n * talks to the API, which needs the store config `init` sets.\n *\n * Loaded is not enough for that: `init` finishes asynchronously, so a cart lookup\n * made the moment the SDK announces itself goes out without a store identifier\n * and is answered `Store Identifier not found`. Returns a cancel, as\n * {@link whenSallaLoaded} does.\n *\n * A rejected `onReady` still runs `callback`, as `useTwilightInit` carries on past\n * one: it means a partial initialisation, and waiting on it would leave the caller\n * waiting for good.\n */\nexport function whenSallaReady(callback: (sdk: SallaSDK) => void): () => void {\n let cancelled = false;\n const cancel = whenSallaLoaded((sdk) => {\n void new Promise((resolve) => resolve(sdk.onReady?.())).catch(noop).then(() => {\n if (!cancelled) callback(sdk);\n });\n });\n return () => {\n cancelled = true;\n cancel();\n };\n}\n\n/**\n * `salla.event.on(name, listener)` once the SDK has loaded. Returns the matching\n * unsubscribe, which also cancels a subscription still waiting for the SDK.\n *\n * Removed from the emitter it was added to, not from whatever `window.salla` is\n * by the time the component unmounts.\n *\n * Waits for an event bus specifically, not for \"loaded\": an SDK is recognised by\n * `init` alone, and subscribing on one without a bus would throw.\n */\nexport function onSallaEvent(name: string, listener: (...args: unknown[]) => void): () => void {\n let bus: SallaSDK['event'] | undefined;\n const cancel = whenSalla(hasEventBus, (sdk) => {\n bus = sdk.event;\n bus.on(name, listener);\n });\n return () => {\n cancel();\n bus?.off?.(name, listener);\n };\n}\n\n/**\n * Push the active route locale onto the Salla SDK.\n *\n * Why this is needed (and why it must run on every navigation):\n * - The SDK seeds its locale from `navigator.language` — the theme sets no `s-lang`\n * cookie or `window.locale` — so an English browser starts the SDK in `en` even on\n * an `/ar` store.\n * - The SDK fixes its axios `accept-language` header ONCE, at init. `salla.lang.setLocale`\n * only swaps UI translations (it never touches the header), and `salla.init()` is a\n * no-op after `Salla.status === 'ready'`, so the header never refreshes on its own.\n * - `profile::info.fetched` (login / profile refresh on navigation) overrides the header\n * to the *account's* language.\n *\n * Net result without this: `salla.api.*` calls (cart/product details) return data in the\n * wrong locale — e.g. English cart item names on `/ar/cart` — intermittently, depending on\n * load order and whether a profile fetch ran. Re-asserting the URL locale here keeps the\n * header correct. No-op on the server and until the SDK exposes the methods.\n */\nexport function syncSdkLocale(locale: string): void {\n const sdk = getSallaSDK();\n if (!sdk || !locale) return;\n try {\n sdk.lang?.setLocale?.(locale);\n sdk.api?.setHeader?.('accept-language', locale);\n // The localization modal swaps `/${user.language_code}/` in the URL on submit;\n // the SDK never sets this locally, so without it the switch reloads the same page.\n sdk.config?.set?.('user.language_code', locale);\n } catch {\n // SDK partially loaded — the header is re-asserted on the next navigation.\n }\n}\n\n/**\n * The `s-version-id` the SDK sends: the version the request named, else the one\n * the settings report.\n *\n * The request outranks the settings here for the reason it does in\n * `resolveThemeVersionId`. `headers['s-version-id']` is the version the API\n * *answered with*, and for a version it cannot reach it reports the live one\n * while rendering defaults. Read alone, a preview's `salla.api.*` calls asked\n * about the live version while the engine's own asked about the previewed one,\n * so one page showed two versions.\n */\nfunction sdkThemeVersionId(headers: StoreContext['headers']): string | null {\n const versionId = requestedThemeVersionId() ?? headers?.['s-version-id'];\n return versionId != null ? String(versionId) : null;\n}\n\n/**\n * Settings as the SDK's `init` should copy them: with `headers` naming the\n * version {@link sdkThemeVersionId} picks.\n *\n * `init` spreads `headers` over its axios defaults, and on a first load nothing\n * re-asserts the version afterwards: TanStack restores the root match's context\n * instead of re-running `rootBeforeLoad` in the browser, so\n * {@link syncSdkThemeVersion} first runs on a client navigation.\n */\nexport function withSdkThemeVersion<T extends Pick<StoreContext, 'headers'>>(settings: T): T {\n const versionId = requestedThemeVersionId();\n if (!versionId) return settings;\n return { ...settings, headers: { ...settings.headers, 's-version-id': versionId } };\n}\n\n/**\n * Push the theme version onto the Salla SDK: the requested one, else the one the\n * current settings name (see {@link sdkThemeVersionId}).\n *\n * The SDK copies `settings.headers` into its axios defaults ONCE, at init, and\n * `s-version-id` is one of them. Settings refetched on the client — the shopper\n * switched market, and each market has its own version — name a different one,\n * and without this every `salla.api.*` call keeps asking for the previous\n * market's version until a full page load. Settings that name no version take\n * the header off instead, so the SDK asks for the live one like the engine's own\n * client does. No-op on the server and until the SDK exposes its api.\n */\nexport function syncSdkThemeVersion(headers: StoreContext['headers']): void {\n const sdk = getSallaSDK();\n if (!sdk) return;\n const versionId = sdkThemeVersionId(headers);\n try {\n if (versionId != null) sdk.api?.setHeader?.('s-version-id', versionId);\n else delete sdk.api?.axios?.defaults?.headers?.common?.['s-version-id'];\n } catch {\n // SDK partially loaded — the header is re-asserted on the next navigation.\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/utils/theme-version.ts","../src/utils/sdk-helpers.ts"],"names":[],"mappings":";;;;AAqCO,SAAS,uBAAA,GAAyC;AACvD,EAAA,MAAM,EAAE,SAAA,EAAU,GAAI,eAAA,EAAgB;AACtC,EAAA,IAAI,WAAW,OAAO,SAAA;AAEtB,EAAA,OAAO,qBAAA,GAAwB,SAAA,IAAa,IAAA;AAC9C;AAmCA,SAAS,YAAA,CAAa,UAA2C,aAAA,EAA8B;AAC7F,EAAA,MAAM,gBAAA,GAAmB,UAAU,gBAAA,IAAoB,IAAA;AACvD,EAAA,IAAI,aAAA,IAAiB,IAAA,EAAM,OAAO,gBAAA,IAAoB,IAAA;AACtD,EAAA,MAAM,eAAA,GAAkB,QAAA,EAAU,KAAA,EAAO,KAAA,EAAO,EAAA;AAChD,EAAA,OAAA,CAAQ,eAAA,IAAmB,IAAA,GAAO,MAAA,CAAO,eAAe,IAAI,gBAAA,MAAsB,aAAA;AACpF;AAEO,SAAS,qBAAA,CAAsB,gBAA+B,IAAA,EAAqB;AACxF,EAAA,MAAM,YAAY,uBAAA,EAAwB;AAC1C,EAAA,IAAI,WAAW,OAAO,SAAA;AAEtB,EAAA,IAAI;AACF,IAAA,MAAM,QAAA,GAAW,oBAAmB,CAAE,QAAA;AACtC,IAAA,IAAI,CAAC,YAAA,CAAa,QAAA,EAAU,aAAa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,MAAQ;AAAA,EAER;AACF","file":"chunk-7XAGU6CT.js","sourcesContent":["/**\n * @fileoverview Which version of the theme's settings to render — the one answer,\n * in one place.\n *\n * A merchant's theme settings are versioned. An ordinary storefront visit names\n * no version and gets the live one; the API decides, and reports it back as\n * `theme.profile.id`. Two surfaces need a different one, and both address it in\n * the URL of an iframe:\n *\n * - the merchant's theme editor at `s.salla.sa/themes/editor/…`, which shows a\n * draft version beside the controls that are editing it;\n * - a partner running the theme locally, whose dev server is the iframe.\n *\n * Written as a module of its own rather than inline at the one call site,\n * because `store-identity.ts` exists for exactly this reason: the identifier a\n * request resolved and the identifier it sent were two different values for\n * days, in two files, and every test passed. A second implementation of this is\n * the bug, not a refactor away from one.\n */\nimport { getRequestStore, getTwilightContext } from '../twilight/context';\nimport type { StoreContext } from '../api/store';\nimport { getInjectedRuntimeEnv } from './runtime-env';\n\n/**\n * The version this request asked for, or null when it asked for none.\n *\n * Deliberately excludes the version the *settings* name. This is the answer to\n * \"what did the caller address?\", and it has to be available before any settings\n * exist — React Query keys are built from it, and a key that means one thing\n * during SSR and another after hydration is how a page refetches everything it\n * was just handed.\n *\n * 1. what the request named, seeded by `twilightMiddleware` on a host permitted\n * to name one;\n * 2. what SSR resolved and published into the head, which is all the browser has\n * once the dispatcher has stripped `?versionId=` from the URL.\n */\nexport function requestedThemeVersionId(): string | null {\n const { versionId } = getRequestStore();\n if (versionId) return versionId;\n\n return getInjectedRuntimeEnv().versionId || null;\n}\n\n/**\n * The version every Salla API call is answered with — what goes in `s-version-id`.\n *\n * The requested version outranks the settings, because a request that named one\n * is the only reason this is ever anything but the live version: falling back to\n * the settings there would let the first answer overwrite the question.\n *\n * The settings' own `theme.profile.id` stays as the fallback, unchanged. It is\n * what this header has always carried, and on an ordinary storefront it still\n * is — it keeps the rest of a page's calls pinned to the version the settings\n * call resolved, rather than letting a version go live mid-render.\n *\n * That pin is only good for the scope the settings were requested with. Each\n * market (scope) has its own version, and the API lets a named version outrank\n * the market's: once the shopper switches market, the loaded settings still\n * describe the previous one, and replaying their version — on the settings call\n * for the new market first of all — gets the previous market's theme back, for\n * good. So the version is replayed only while the active scope is the one the\n * settings were answered for (`store.scope`), which is not always the one they\n * were requested for (`requestedScopeId`): the API falls back to another scope\n * when it does not accept the requested one, and that scope's version must not\n * ride along on the next request for the requested one. With no active scope it\n * is replayed only for settings requested without one. Otherwise nothing is\n * sent and the API picks the version of the scope on the request.\n *\n * `activeScopeId` is passed in by the caller that already resolved the scope for\n * its `s-scope-*` headers.\n *\n * Reading the settings is guarded because `getTwilightContext().settings` throws\n * a `SettingsError` when they have not loaded — which is the normal state on the\n * very first call, the settings call itself.\n */\n/** Whether `settings` were answered for `activeScopeId` (see {@link resolveThemeVersionId}). */\nfunction answersScope(settings: StoreContext | null | undefined, activeScopeId: string | null) {\n const requestedScopeId = settings?.requestedScopeId ?? null;\n if (activeScopeId == null) return requestedScopeId == null;\n const answeredScopeId = settings?.store?.scope?.id;\n return (answeredScopeId != null ? String(answeredScopeId) : requestedScopeId) === activeScopeId;\n}\n\nexport function resolveThemeVersionId(activeScopeId: string | null = null): string | null {\n const requested = requestedThemeVersionId();\n if (requested) return requested;\n\n try {\n const settings = getTwilightContext().settings;\n if (!answersScope(settings, activeScopeId)) return null;\n\n const profileId = settings?.theme?.profile?.id;\n return profileId != null ? String(profileId) : null;\n } catch {\n return null;\n }\n}\n","export type { StoreContext } from '../api/store';\nimport type { StoreContext } from '../api/store';\nimport type { SallaSDK } from '../types/salla-sdk';\nimport { resolveStoreIdentifier } from './store-identity';\nimport { requestedThemeVersionId } from './theme-version';\n\nconst isBrowser = typeof window !== 'undefined';\n\n/**\n * Which store to ask the API about — see {@link resolveStoreIdentifier}.\n *\n * A delegation, not a second implementation. This name is the one on the wire\n * (`api/client.ts` sets the `store-identifier` header from it) and the one\n * themes import from `@salla.sa/twilight-theme-engine/utils`, so it stays; what\n * it must never do again is answer differently from the resolver everything\n * else asks. It had its own copy of the order once, missing the store the\n * request names and preferring the build-time `VITE_STORE_DOMAIN` that a\n * deployed worker does not have — so every published theme sent an empty\n * identifier and rendered \"Store Unavailable\".\n */\nexport function getStoreIdentifier(explicit?: string): string {\n return resolveStoreIdentifier(explicit);\n}\n\n/**\n * Get Salla SDK instance if available\n */\nexport function getSallaSDK(): typeof window.salla | undefined {\n if (!isBrowser) return undefined;\n return window.salla;\n}\n\n/** Dispatched on `window` by the SDK as the last step of loading (twilight `src/index.js`). */\nconst SDK_CREATED_EVENT = 'salla::created';\n\nconst noop = () => {};\n\n/**\n * Whether `window.salla` is the SDK, rather than the stub that stands in for it.\n *\n * ⚠️ `window.salla` exists from the first bytes of the page. The `twilight-init`\n * head script defines it with an `onReady`, so app snippets can queue work, and\n * the SDK — a deferred module — fills it in later. React can hydrate and run\n * effects in between, and there `window.salla?.event.on(…)` passes its `?.` and\n * throws `Cannot read properties of undefined (reading 'on')`.\n *\n * The SDK defines `init` and `event` in one synchronous module evaluation and the\n * stub has neither, so either one means it has loaded.\n */\nfunction isLoaded(sdk: typeof window.salla): sdk is SallaSDK {\n return typeof sdk?.init === 'function' || typeof sdk?.event?.on === 'function';\n}\n\n/** An SDK whose event bus can take a listener — what {@link onSallaEvent} needs. */\nfunction hasEventBus(sdk: typeof window.salla): sdk is SallaSDK {\n return typeof sdk?.event?.on === 'function';\n}\n\n/**\n * Run `callback` with the SDK as soon as it has loaded: now if it has, otherwise\n * when it announces itself.\n *\n * Returns a cancel for an effect's cleanup, so a component that unmounts first\n * never has the callback run. An effect that returned early when the SDK was not\n * there yet never ran again — on a cold load, where hydration beats the SDK, the\n * engine never initialised it at all.\n */\nexport function whenSallaLoaded(callback: (sdk: SallaSDK) => void): () => void {\n return whenSalla(isLoaded, callback);\n}\n\nfunction whenSalla(\n isUsable: (sdk: typeof window.salla) => sdk is SallaSDK,\n callback: (sdk: SallaSDK) => void\n): () => void {\n if (!isBrowser) return noop;\n\n if (isUsable(window.salla)) {\n callback(window.salla);\n return noop;\n }\n\n let settled = false;\n const onCreated = () => {\n const sdk = window.salla;\n if (settled || !isUsable(sdk)) return;\n settled = true;\n window.removeEventListener(SDK_CREATED_EVENT, onCreated);\n callback(sdk);\n };\n window.addEventListener(SDK_CREATED_EVENT, onCreated);\n\n return () => {\n settled = true;\n window.removeEventListener(SDK_CREATED_EVENT, onCreated);\n };\n}\n\n/**\n * Run `callback` once the SDK has loaded **and been initialised** — for work that\n * talks to the API, which needs the store config `init` sets.\n *\n * Loaded is not enough for that: `init` finishes asynchronously, so a cart lookup\n * made the moment the SDK announces itself goes out without a store identifier\n * and is answered `Store Identifier not found`. Returns a cancel, as\n * {@link whenSallaLoaded} does.\n *\n * A rejected `onReady` still runs `callback`, as `useTwilightInit` carries on past\n * one: it means a partial initialisation, and waiting on it would leave the caller\n * waiting for good.\n */\nexport function whenSallaReady(callback: (sdk: SallaSDK) => void): () => void {\n let cancelled = false;\n const cancel = whenSallaLoaded((sdk) => {\n void new Promise((resolve) => resolve(sdk.onReady?.())).catch(noop).then(() => {\n if (!cancelled) callback(sdk);\n });\n });\n return () => {\n cancelled = true;\n cancel();\n };\n}\n\n/**\n * `salla.event.on(name, listener)` once the SDK has loaded. Returns the matching\n * unsubscribe, which also cancels a subscription still waiting for the SDK.\n *\n * Removed from the emitter it was added to, not from whatever `window.salla` is\n * by the time the component unmounts.\n *\n * Waits for an event bus specifically, not for \"loaded\": an SDK is recognised by\n * `init` alone, and subscribing on one without a bus would throw.\n */\nexport function onSallaEvent(name: string, listener: (...args: unknown[]) => void): () => void {\n let bus: SallaSDK['event'] | undefined;\n const cancel = whenSalla(hasEventBus, (sdk) => {\n bus = sdk.event;\n bus.on(name, listener);\n });\n return () => {\n cancel();\n bus?.off?.(name, listener);\n };\n}\n\n/**\n * Push the active route locale onto the Salla SDK.\n *\n * Why this is needed (and why it must run on every navigation):\n * - The SDK seeds its locale from `navigator.language` — the theme sets no `s-lang`\n * cookie or `window.locale` — so an English browser starts the SDK in `en` even on\n * an `/ar` store.\n * - The SDK fixes its axios `accept-language` header ONCE, at init. `salla.lang.setLocale`\n * only swaps UI translations (it never touches the header), and `salla.init()` is a\n * no-op after `Salla.status === 'ready'`, so the header never refreshes on its own.\n * - `profile::info.fetched` (login / profile refresh on navigation) overrides the header\n * to the *account's* language.\n *\n * Net result without this: `salla.api.*` calls (cart/product details) return data in the\n * wrong locale — e.g. English cart item names on `/ar/cart` — intermittently, depending on\n * load order and whether a profile fetch ran. Re-asserting the URL locale here keeps the\n * header correct. No-op on the server and until the SDK exposes the methods.\n */\nexport function syncSdkLocale(locale: string): void {\n const sdk = getSallaSDK();\n if (!sdk || !locale) return;\n try {\n sdk.lang?.setLocale?.(locale);\n sdk.api?.setHeader?.('accept-language', locale);\n // The localization modal swaps `/${user.language_code}/` in the URL on submit;\n // the SDK never sets this locally, so without it the switch reloads the same page.\n sdk.config?.set?.('user.language_code', locale);\n } catch {\n // SDK partially loaded — the header is re-asserted on the next navigation.\n }\n}\n\n/**\n * The `s-version-id` the SDK sends: the version the request named, else the one\n * the settings report.\n *\n * The request outranks the settings here for the reason it does in\n * `resolveThemeVersionId`. `headers['s-version-id']` is the version the API\n * *answered with*, and for a version it cannot reach it reports the live one\n * while rendering defaults. Read alone, a preview's `salla.api.*` calls asked\n * about the live version while the engine's own asked about the previewed one,\n * so one page showed two versions.\n */\nfunction sdkThemeVersionId(headers: StoreContext['headers']): string | null {\n const versionId = requestedThemeVersionId() ?? headers?.['s-version-id'];\n return versionId != null ? String(versionId) : null;\n}\n\n/**\n * Settings as the SDK's `init` should copy them: with `headers` naming the\n * version {@link sdkThemeVersionId} picks.\n *\n * `init` spreads `headers` over its axios defaults, and on a first load nothing\n * re-asserts the version afterwards: TanStack restores the root match's context\n * instead of re-running `rootBeforeLoad` in the browser, so\n * {@link syncSdkThemeVersion} first runs on a client navigation.\n */\nexport function withSdkThemeVersion<T extends Pick<StoreContext, 'headers'>>(settings: T): T {\n const versionId = requestedThemeVersionId();\n if (!versionId) return settings;\n return { ...settings, headers: { ...settings.headers, 's-version-id': versionId } };\n}\n\n/**\n * Push the theme version onto the Salla SDK: the requested one, else the one the\n * current settings name (see {@link sdkThemeVersionId}).\n *\n * The SDK copies `settings.headers` into its axios defaults ONCE, at init, and\n * `s-version-id` is one of them. Settings refetched on the client — the shopper\n * switched market, and each market has its own version — name a different one,\n * and without this every `salla.api.*` call keeps asking for the previous\n * market's version until a full page load. Settings that name no version take\n * the header off instead, so the SDK asks for the live one like the engine's own\n * client does. No-op on the server and until the SDK exposes its api.\n */\nexport function syncSdkThemeVersion(headers: StoreContext['headers']): void {\n const sdk = getSallaSDK();\n if (!sdk) return;\n const versionId = sdkThemeVersionId(headers);\n try {\n if (versionId != null) sdk.api?.setHeader?.('s-version-id', versionId);\n else delete sdk.api?.axios?.defaults?.headers?.common?.['s-version-id'];\n } catch {\n // SDK partially loaded — the header is re-asserted on the next navigation.\n }\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { orThrow } from './chunk-
|
|
2
|
-
import { api } from './chunk-
|
|
3
|
-
import { getSallaSDK } from './chunk-
|
|
1
|
+
import { orThrow } from './chunk-O3XMYDNC.js';
|
|
2
|
+
import { api } from './chunk-RB7RHMKJ.js';
|
|
3
|
+
import { getSallaSDK } from './chunk-7XAGU6CT.js';
|
|
4
4
|
import { queryOptions } from '@tanstack/react-query';
|
|
5
5
|
|
|
6
6
|
function normalizeCartResponse(data) {
|
|
@@ -44,5 +44,5 @@ var cart = {
|
|
|
44
44
|
};
|
|
45
45
|
|
|
46
46
|
export { cart };
|
|
47
|
-
//# sourceMappingURL=chunk-
|
|
48
|
-
//# sourceMappingURL=chunk-
|
|
47
|
+
//# sourceMappingURL=chunk-AOQZHLZZ.js.map
|
|
48
|
+
//# sourceMappingURL=chunk-AOQZHLZZ.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/api/cart.ts"],"names":[],"mappings":";;;;;AAaA,SAAS,sBAAsB,IAAA,EAAoC;AACjE,EAAA,IAAI,CAAC,IAA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,EAAQ,MAAM,CAAA;AAAA,MACzB,OAAA,EAAS,MAAM,IAAA,CAAK,GAAA,CAAI,MAAM,CAAA;AAAA;AAAA,MAE9B,SAAA,EAAW,CAAA;AAAA,MACX,MAAA,EAAQ;AAAA,KACT,CAAA;AAAA,IACH,SAAA,EAAW,MACT,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,CAAC,MAAA,EAAQ,YAAY,CAAA;AAAA,MAC/B,OAAA,EAAS,MAAM,IAAA,CAAK,YAAA,EAAa;AAAA;AAAA,MAEjC,SAAA,EAAW,CAAA;AAAA,MACX,MAAA,EAAQ;AAAA,KACT;AAAA;AAEP","file":"chunk-AOQZHLZZ.js","sourcesContent":["import { queryOptions } from '@tanstack/react-query';\nimport { api } from './client';\nimport type { Cart } from '../types';\nimport { orThrow } from '../providers/NavigationProvider';\nimport { getSallaSDK } from '../utils/sdk-helpers';\n\nexport interface CartApiResponse {\n /** Absent once the cart was turned into an order (the body then carries a top-level `redirect`). */\n cart?: Omit<Cart, 'loyalty'>;\n loyalty?: Cart['loyalty'];\n gift?: Cart['gift'];\n}\n\nfunction normalizeCartResponse(data: CartApiResponse): Cart | null {\n if (!data.cart) return null;\n return {\n ...data.cart,\n loyalty: data.loyalty ?? null,\n // The API sends `gift` inside `cart`.\n gift: data.gift ?? data.cart.gift ?? null,\n } as Cart;\n}\n\nexport const cart = {\n get: async (cartId: number): Promise<Cart | null> => {\n const { data } = await api.get(`cart/${cartId}`).json<{ data: CartApiResponse }>();\n return normalizeCartResponse(data);\n },\n\n getOrThrow: (cartId: number): Promise<Cart | null> => orThrow(cart.get(cartId)),\n\n /** The visitor's cart id, which only the Salla SDK knows; `null` outside the browser. */\n getCurrentId: async (): Promise<number | null> => {\n const salla = getSallaSDK();\n if (!salla) return null;\n // The app bundle can run before the SDK module, when `salla` is still the head stub.\n await salla.onReady().catch(() => undefined);\n return salla.cart.api.getCurrentCartId();\n },\n\n queries: {\n detail: (cartId: number) =>\n queryOptions({\n queryKey: ['cart', cartId],\n queryFn: () => cart.get(cartId),\n // The SDK changes the cart from any page, so a cached copy is never safe to show.\n staleTime: 0,\n gcTime: 0,\n }),\n currentId: () =>\n queryOptions({\n queryKey: ['cart', 'current-id'],\n queryFn: () => cart.getCurrentId(),\n // Completing an order starts a new cart, so an earlier id is never reused.\n staleTime: 0,\n gcTime: 0,\n }),\n },\n};\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { onSallaEvent } from './chunk-
|
|
1
|
+
import { onSallaEvent } from './chunk-7XAGU6CT.js';
|
|
2
2
|
import { useState, useRef, useEffect, useCallback } from 'react';
|
|
3
3
|
|
|
4
4
|
function useProduct(initialProduct, options) {
|
|
@@ -61,5 +61,5 @@ function useProduct(initialProduct, options) {
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
export { useProduct };
|
|
64
|
-
//# sourceMappingURL=chunk-
|
|
65
|
-
//# sourceMappingURL=chunk-
|
|
64
|
+
//# sourceMappingURL=chunk-B57KIBQL.js.map
|
|
65
|
+
//# sourceMappingURL=chunk-B57KIBQL.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hooks/useProduct.ts"],"names":[],"mappings":";;;AA4DO,SAAS,UAAA,CAAW,gBAAyB,OAAA,EAA+C;AACjG,EAAA,MAAM,CAAC,OAAA,EAAS,UAAU,CAAA,GAAI,SAAkB,cAAc,CAAA;AAI9D,EAAA,MAAM,iBAAA,GAAoB,OAAgB,cAAc,CAAA;AACxD,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,iBAAA,CAAkB,OAAA,GAAU,cAAA;AAAA,EAC9B,CAAC,CAAA;AAED,EAAA,MAAM,MAAA,GAAS,YAAY,YAAY;AACrC,IAAA,MAAM,QAAQ,MAAA,CAAO,KAAA;AACrB,IAAA,IAAI,CAAC,KAAA,EAAO,GAAA,EAAK,OAAA,EAAS,UAAA,EAAY;AACtC,IAAA,IAAI;AACF,MAAA,MAAM,QAAA,GAAW,MAAM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A,EAAY,QAAA,GAAW,KAAA,GAAQ,IAAA,CAAK,UAAA;AAAA,UACpC,aAAA,EAAe,YAAA;AAAA,UACf,UAAA,EAAY,QAAA;AAAA,UACZ,cAAA,EAAgB,IAAA;AAAA,UAChB,MAAA,EAAS,KAAK,MAAA,IAAqB,EAAA;AAAA;AAAA,UAEnC,KAAK,IAAA,CAAK,GAAA,KAAQ,SAAY,IAAA,CAAK,GAAA,GAAO,KAAK,GAAA,IAAkB,EAAA;AAAA,UACjE,SAAS,IAAA,CAAK,OAAA,KAAY,SAAY,IAAA,CAAK,OAAA,GAAW,KAAK,OAAA,IAAsB,EAAA;AAAA,UACjF,eAAA,EAAiB;AAAA,SACnB;AAAA,MACF,CAAC,CAAA;AAAA,IACH,CAAA;AAEA,IAAA,MAAM,QAAA,GAAW,kBAAA;AAGjB,IAAA,OAAO,YAAA,CAAa,0BAA0B,QAAQ,CAAA;AAAA,EACxD,CAAA,EAAG,EAAE,CAAA;AAGL,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,MAAM,oBAAoB,MAAM;AAC9B,MAAA,UAAA,CAAW,CAAC,IAAA,MAAU,EAAE,GAAG,IAAA,EAAM,eAAA,EAAiB,MAAK,CAAE,CAAA;AAAA,IAC3D,CAAA;AAEA,IAAA,OAAO,YAAA,CAAa,iCAAiC,iBAAiB,CAAA;AAAA,EACxE,CAAA,EAAG,EAAE,CAAA;AAEL,EAAA,OAAO,EAAE,SAAS,MAAA,EAAO;AAC3B","file":"chunk-B57KIBQL.js","sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react';\nimport type { Product } from '../types';\nimport { onSallaEvent } from '../utils/sdk-helpers';\n\n/**\n * UseProductResult - Return type for useProduct hook\n */\nexport interface UseProductResult {\n /** Current product state (updates on option changes) */\n product: Product;\n /** Reload product data from API */\n reload: () => Promise<void>;\n}\n\nexport interface UseProductOptions {\n /**\n * True while `initialProduct` is a list-card stand-in. When it flips to false\n * (details arrived), state re-seeds. Do not infer this from `options`/`images`\n * — list payloads may include those fields.\n */\n isPreview?: boolean;\n}\n\n/**\n * useProduct - Hook for managing product state with live updates\n *\n * Provides reactive product data with automatic updates for price, stock,\n * and variant changes. Handles manual reloads (e.g., after add-to-cart)\n * and subscribes to Salla SDK events for real-time price updates.\n *\n * Stock status is reflected in `product.is_out_of_stock` which updates\n * when price calculations succeed or fail (e.g., unavailable option combinations).\n *\n * @param initialProduct - The initial product object (typically from loader/SSR).\n * @param options.isPreview - Pass true for a list-card placeholder so the hook\n * re-seeds when details for the same id arrive (`isPreview` goes false).\n *\n * @returns Object with product and reload function\n *\n * @example\n * ```tsx\n * function ProductDetails({ product }) {\n * const { product: updatedProduct, reload } = useProduct(product);\n *\n * const handleAddToCart = async () => {\n * await addToCart(updatedProduct.id);\n * await reload(); // Refresh product state after cart update\n * };\n *\n * return (\n * <div>\n * <h1>{updatedProduct.name}</h1>\n * <p>Price: {formatMoney(updatedProduct.price)}</p>\n * {updatedProduct.is_out_of_stock && <p>Currently out of stock</p>}\n * <button onClick={handleAddToCart}>Add to Cart</button>\n * </div>\n * );\n * }\n * ```\n */\nexport function useProduct(initialProduct: Product, options?: UseProductOptions): UseProductResult {\n const [product, setProduct] = useState<Product>(initialProduct);\n\n // Always keep a ref to the latest initialProduct so the re-seed effect below\n // can read it without adding the full object to the dependency array.\n const initialProductRef = useRef<Product>(initialProduct);\n useEffect(() => {\n initialProductRef.current = initialProduct;\n });\n\n const reload = useCallback(async () => {\n const salla = window.salla;\n if (!salla?.api?.product?.getDetails) return;\n try {\n const response = await salla.api.product.getDetails(String(product.id), [\n 'images',\n 'category',\n ]);\n if (response?.success && response.data) {\n setProduct(response.data as Product);\n }\n } catch {\n // silently ignore network errors during reload\n }\n }, [product.id]);\n\n // Re-seed when the loader navigates to a different product, or when a\n // list-card placeholder (`isPreview`) is replaced by details for the same id.\n // Object identity is not a dependency — that would reset live option/price state.\n useEffect(() => {\n setProduct(initialProductRef.current);\n }, [initialProduct.id, options?.isPreview]);\n\n // Subscribe to Salla option-change events so price/stock stays in sync\n useEffect(() => onSallaEvent('product:options.updated', reload), [reload]);\n\n // Subscribe to price update events (matches product.js registerEvents)\n useEffect(() => {\n const handlePriceUpdated = (res: { data?: Record<string, unknown> }) => {\n const data = res.data;\n if (!data) return;\n\n setProduct((prev) => {\n const price = (data.price as number) ?? prev.price;\n const regularPrice = (data.regular_price as number) ?? prev.regular_price;\n // The payload has no sale_price: like product.js, `price` is the payable (sale) figure.\n const isOnSale = Boolean(data.has_sale_price) && regularPrice > price;\n return {\n ...prev,\n price,\n sale_price: isOnSale ? price : prev.sale_price,\n regular_price: regularPrice,\n is_on_sale: isOnSale,\n starting_price: null,\n weight: (data.weight as string) || '',\n // An empty variant SKU/barcode blanks it; a payload without the field keeps it (product.js).\n sku: data.sku === undefined ? prev.sku : (data.sku as string) || '',\n barcode: data.barcode === undefined ? prev.barcode : (data.barcode as string) || '',\n is_out_of_stock: false,\n };\n });\n };\n\n const listener = handlePriceUpdated as (...args: unknown[]) => void;\n\n // Root on/off: onPriceUpdated registers a wrapper that salla.event.off can't match.\n return onSallaEvent('product::price.updated', listener);\n }, []);\n\n // Subscribe to price update failed events (matches product.js)\n useEffect(() => {\n const handlePriceFailed = () => {\n setProduct((prev) => ({ ...prev, is_out_of_stock: true }));\n };\n\n return onSallaEvent('product::price.updated.failed', handlePriceFailed);\n }, []);\n\n return { product, reload };\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { advertisement, advertisementsFor } from './chunk-
|
|
1
|
+
import { advertisement, advertisementsFor } from './chunk-PPFD456V.js';
|
|
2
2
|
import { useTranslation } from './chunk-TYNZ5B2B.js';
|
|
3
|
-
import { whenSallaReady } from './chunk-
|
|
3
|
+
import { whenSallaReady } from './chunk-7XAGU6CT.js';
|
|
4
4
|
import { subscribeTwilight, getTwilightContext } from './chunk-6K34BCUP.js';
|
|
5
5
|
import { useSyncExternalStore, useState, useEffect } from 'react';
|
|
6
6
|
import { useQuery } from '@tanstack/react-query';
|
|
@@ -99,5 +99,5 @@ function PageAdvertisements() {
|
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
export { PageAdvertisements };
|
|
102
|
-
//# sourceMappingURL=chunk-
|
|
103
|
-
//# sourceMappingURL=chunk-
|
|
102
|
+
//# sourceMappingURL=chunk-BYGVKW3M.js.map
|
|
103
|
+
//# sourceMappingURL=chunk-BYGVKW3M.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,CAAa,EAAE,CAAA,EAAG,WAAW,CAAA;AAAA,OAC5E;AACH,IAAA,IAAI;AACF,MAAA,MAAA,CAAO,YAAA,CAAa,QAAQ,YAAA,CAAa,EAAE,GAAG,IAAA,CAAK,SAAA,CAAU,WAAW,CAAC,CAAA;AAAA,IAC3E,CAAA,CAAA,MAAQ;AAAA,IAER;AAAA,EACF;AACF;AAeO,SAAS,kBAAA,GAAqB;AACnC,EAAA,MAAM,EAAE,CAAA,EAAE,GAAI,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,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-BYGVKW3M.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,8 +1,8 @@
|
|
|
1
1
|
import { registry } from './chunk-Y32RHCOH.js';
|
|
2
2
|
import { useTranslation } from './chunk-TYNZ5B2B.js';
|
|
3
|
-
import { Image } from './chunk-
|
|
3
|
+
import { Image } from './chunk-LBZNLTBM.js';
|
|
4
4
|
import { LazyImageModal } from './chunk-KYMWEUN2.js';
|
|
5
|
-
import { isNativeApp } from './chunk-
|
|
5
|
+
import { isNativeApp } from './chunk-ULF4LPVA.js';
|
|
6
6
|
import { useTwilight } from './chunk-DF6FBKDN.js';
|
|
7
7
|
import { lazyComponent } from './chunk-VYGA5AT5.js';
|
|
8
8
|
import { SallaSlider } from '@salla.sa/twilight-components-react/slider';
|
|
@@ -11,10 +11,10 @@ import { jsx, jsxs } from 'react/jsx-runtime';
|
|
|
11
11
|
|
|
12
12
|
// src/components/product/lazy.ts
|
|
13
13
|
var LazyProductDetails = lazyComponent(
|
|
14
|
-
() => import('./ProductDetails-
|
|
14
|
+
() => import('./ProductDetails-ZPRWPSVK.js').then((m) => ({ default: m.ProductDetails }))
|
|
15
15
|
);
|
|
16
16
|
var LazyAddToCartForm = lazyComponent(
|
|
17
|
-
() => import('./AddToCartForm-
|
|
17
|
+
() => import('./AddToCartForm-P5Q4P763.js').then((m) => ({ default: m.AddToCartForm }))
|
|
18
18
|
);
|
|
19
19
|
var PRODUCT_GALLERY_KEY = "product:gallery";
|
|
20
20
|
function legacyGalleryMedia(images) {
|
|
@@ -202,5 +202,5 @@ function ThumbSlide({ image, index }) {
|
|
|
202
202
|
}
|
|
203
203
|
|
|
204
204
|
export { LazyAddToCartForm, LazyProductDetails, ProductGallery };
|
|
205
|
-
//# sourceMappingURL=chunk-
|
|
206
|
-
//# sourceMappingURL=chunk-
|
|
205
|
+
//# sourceMappingURL=chunk-CAULDK3N.js.map
|
|
206
|
+
//# sourceMappingURL=chunk-CAULDK3N.js.map
|