/* global React, ReactDOM, HomePage, ServicesPage, ProcessPage, LookbookPage, AtelierPage, AppointmentsPage, ContactPage, Navbar, Footer */ const { useState, useEffect, useCallback, useMemo } = React; const ROUTES = ["home", "services", "process", "lookbook", "atelier", "appointments", "contact"]; const TWEAK_DEFAULTS = /*EDITMODE-BEGIN*/{ "locale": "en", "callConfirmed": false, "waConfirmed": false, "palette": "sand-sage-brass", "showFlags": true, "displayFont": "Cormorant Garamond" }/*EDITMODE-END*/; function App() { const [t, setTweak] = window.useTweaks ? window.useTweaks(TWEAK_DEFAULTS) : [TWEAK_DEFAULTS, () => {}]; const [route, setRoute] = useState(() => { const h = (window.location.hash || "").replace(/^#\/?/, ""); return ROUTES.includes(h) ? h : "home"; }); const [toastMsg, setToastMsg] = useState(null); // hash routing useEffect(() => { const onHash = () => { const h = (window.location.hash || "").replace(/^#\/?/, ""); setRoute(ROUTES.includes(h) ? h : "home"); window.scrollTo({ top: 0, behavior: "instant" }); }; window.addEventListener("hashchange", onHash); return () => window.removeEventListener("hashchange", onHash); }, []); const nav = useCallback((to) => { window.location.hash = "#/" + to; setRoute(to); window.scrollTo({ top: 0, behavior: "smooth" }); }, []); const toast = useCallback((m) => { setToastMsg(m); setTimeout(() => setToastMsg(null), 3600); }, []); // locale + direction const locale = t.locale || "en"; useEffect(() => { document.documentElement.lang = locale; document.body.dir = locale === "ar" ? "rtl" : "ltr"; }, [locale]); // Hide flags toggle useEffect(() => { document.body.classList.toggle("hide-flags", !t.showFlags); }, [t.showFlags]); // Display font tweak useEffect(() => { document.documentElement.style.setProperty("--font-display", `'${t.displayFont || "Cormorant Garamond"}', Georgia, serif`); }, [t.displayFont]); // Palette tweak useEffect(() => { const root = document.documentElement.style; if (t.palette === "ink-ivory") { root.setProperty("--bg", "#F5F2EC"); root.setProperty("--surface", "#FFFDF8"); root.setProperty("--text", "#1A1916"); root.setProperty("--primary", "#7A8A82"); root.setProperty("--secondary", "#8E6F3A"); root.setProperty("--border", "#E6DFCE"); } else if (t.palette === "midnight-sage") { root.setProperty("--bg", "#1B1F1C"); root.setProperty("--surface", "#252A26"); root.setProperty("--surface-2", "#1F2521"); root.setProperty("--text", "#EFEAE0"); root.setProperty("--muted", "#9B9486"); root.setProperty("--primary", "#A8BCB1"); root.setProperty("--secondary", "#C9A465"); root.setProperty("--border", "#33392F"); root.setProperty("--border-strong", "#454B40"); root.setProperty("--ink", "#EFEAE0"); } else { // sand-sage-brass (default) root.setProperty("--bg", "#F4EFE7"); root.setProperty("--surface", "#FBF8F2"); root.setProperty("--surface-2", "#EFE8DA"); root.setProperty("--text", "#26241F"); root.setProperty("--muted", "#6E665A"); root.setProperty("--primary", "#8FA398"); root.setProperty("--secondary", "#A8884E"); root.setProperty("--border", "#E4DCCD"); root.setProperty("--border-strong", "#C9BFAA"); root.setProperty("--ink", "#1A1916"); } }, [t.palette]); const PageComponent = useMemo(() => ({ home: HomePage, services: ServicesPage, process: ProcessPage, lookbook: LookbookPage, atelier: AtelierPage, appointments: AppointmentsPage, contact: ContactPage, })[route] || HomePage, [route]); const pageProps = { onNav: nav, locale, callConfirmed: !!t.callConfirmed, waConfirmed: !!t.waConfirmed, toast, }; return ( setTweak("locale", l)} />