// Main App composition with multi-page routing
const { useState: aS, useEffect: aE, useCallback: aC } = React;
const App = () => {
const [bookingOpen, setBookingOpen] = aS(false);
const [secondOpen, setSecondOpen] = aS(false);
const [searchOpen, setSearchOpen] = aS(false);
const [activeSection, setActiveSection] = aS('home');
// Determine current page from root element's data-page attribute
const root = document.getElementById('root');
const page = (root && root.dataset.page) || 'home';
// Get URL params (for doctor.html?id=..., direction.html?id=...)
const urlParams = new URLSearchParams(window.location.search);
const paramId = urlParams.get('id');
// Scroll-spy (only on home)
aE(() => {
if (page !== 'home') return;
const sections = DATA.nav
.map(n => document.getElementById(n.id))
.filter(Boolean);
if (!sections.length) return;
const observer = new IntersectionObserver(
(entries) => {
const visible = entries
.filter(e => e.isIntersecting)
.sort((a, b) => b.intersectionRatio - a.intersectionRatio);
if (visible[0]) setActiveSection(visible[0].target.id);
},
{ rootMargin: '-50% 0px -45% 0px', threshold: [0, 0.25, 0.5, 0.75, 1] }
);
sections.forEach(s => observer.observe(s));
return () => observer.disconnect();
}, [page]);
const openBooking = aC(() => setBookingOpen(true), []);
const openSecond = aC(() => setSecondOpen(true), []);
const openSearch = aC(() => setSearchOpen(true), []);
// Page content
let content;
if (page === 'doctors') {
content =