const DSA = window.ConstruimosTuEdificioDesignSystem_3f039f;
const { SiteHeader, SiteFooter } = DSA;
const SERVICE_ROUTES = Object.keys(window.SERVICE_CONTENT);
function useReveal(dep) {
React.useEffect(() => {
const els = document.querySelectorAll(".reveal:not(.in)");
const io = new IntersectionObserver(entries => {
entries.forEach(e => { if (e.isIntersecting) { e.target.classList.add("in"); io.unobserve(e.target); } });
}, { rootMargin: "0px 0px -8% 0px", threshold: .06 });
els.forEach(el => io.observe(el));
return () => io.disconnect();
}, [dep]);
}
function App() {
const [route, setRoute] = React.useState(window.location.pathname || "/");
const go = href => {
if (!href) return;
if (href.startsWith("#")) {
const el = document.querySelector(href);
if (el) el.scrollIntoView({ behavior: "smooth" });
return;
}
const path = href.split("#")[0];
setRoute(path);
if (window.history && window.history.pushState) window.history.pushState({}, "", path);
const s = document.querySelector(".cte-scroll");
if (s) s.scrollTop = 0; else window.scrollTo(0, 0);
};
React.useEffect(() => {
const onPop = () => setRoute(window.location.pathname || "/");
window.addEventListener("popstate", onPop);
return () => window.removeEventListener("popstate", onPop);
}, []);
useReveal(route);
let page;
if (route === "/") page =