/* Alpago — shared UI components */
/* All shared globals exported at the bottom */
const { useState, useEffect, useRef, useMemo } = React;
const PROJECTS = window.AlpagoData.projects;
const I18N = window.AlpagoData.i18n;
const LEADERS = window.AlpagoData.leaders;
const VALUES_DATA = window.AlpagoData.values;
const PARTNERS = window.AlpagoData.partners;
const AWARDS = window.AlpagoData.awards;
function useT(lang) { return I18N[lang]; }
// ---- Logo ----
function Wordmark({ light, size = 1 }) {
const color = light ? "#FFFDF8" : "#101013";
const accent = light ? "rgba(255,253,248,.7)" : "#9C7F4E";
return (
);
}
// ---- Nav ----
function Nav({ route, setRoute, lang, setLang, onCta, transparent, withFlag }) {
const [scrolled, setScrolled] = useState(false);
useEffect(() => {
const onScroll = () => setScrolled(window.scrollY > 60);
onScroll();
window.addEventListener("scroll", onScroll, { passive: true });
return () => window.removeEventListener("scroll", onScroll);
}, []);
const t = useT(lang);
const solid = !transparent || scrolled;
return (
);
}
// ---- Footer ----
function Footer({ lang, setRoute, onCta }) {
const t = useT(lang);
return (
);
}
// ---- Register Interest Modal ----
function RegisterModal({ open, onClose, lang, defaultProject }) {
const t = useT(lang);
const [tab, setTab] = useState(0);
const [submitted, setSubmitted] = useState(false);
const [form, setForm] = useState({
first: "", last: "", email: "", phone: "", country: "",
project: defaultProject || "palm-flower",
interest: "Full-floor residence",
budget: "", message: "", consent: false
});
useEffect(() => {
if (open) {
setSubmitted(false);
setForm(f => ({ ...f, project: defaultProject || f.project }));
}
}, [open, defaultProject]);
useEffect(() => {
const onEsc = (e) => { if (e.key === "Escape") onClose(); };
window.addEventListener("keydown", onEsc);
return () => window.removeEventListener("keydown", onEsc);
}, [onClose]);
const onSubmit = (e) => { e.preventDefault(); setSubmitted(true); };
const tabKeys = ["interest","eoi","brochure","viewing"];
const titlesByTab = lang === "ar"
? ["تسجيل اهتمام","عرض شراء","تنزيل الكتيب","حجز زيارة خاصة"]
: ["Register interest","Expression of interest","Request the brochure","Book a private viewing"];
const projectImg = PROJECTS.find(p => p.slug === form.project)?.cover || "media/asset-29.webp";
return (
e.stopPropagation()}>
{t.form.eyebrow}
{t.form.sub.split(".")[0]}.
{t.form.sub}
+971 4 263 0022
info@alpagoproperties.com
Boulevard Plaza Tower 1, Downtown Dubai
{!submitted ? (
) : (
✓
{t.form.success_t}
{t.form.success_b}
)}
);
}
// ---- WhatsApp FAB ----
function WhatsAppFab({ onClick }) {
return (
);
}
// ---- Sticky bottom CTA ----
function StickyCta({ show, label, title, onPrimary, onSecondary, primaryLabel, secondaryLabel }) {
return (
{onSecondary && }
);
}
// ---- Lightbox ----
function Lightbox({ images, open, index, setIndex, onClose }) {
useEffect(() => {
if (!open) return;
const onKey = (e) => {
if (e.key === "Escape") onClose();
if (e.key === "ArrowRight") setIndex(i => (i + 1) % images.length);
if (e.key === "ArrowLeft") setIndex(i => (i - 1 + images.length) % images.length);
};
window.addEventListener("keydown", onKey);
return () => window.removeEventListener("keydown", onKey);
}, [open, images.length, onClose, setIndex]);
if (!images || images.length === 0) return null;
return (

e.stopPropagation()} />
);
}
// ---- Flag strip ----
function FlagStrip({ lang }) {
const t = useT(lang);
return (
※ {t.flag}
);
}
Object.assign(window, {
React, Wordmark, Nav, Footer, RegisterModal, WhatsAppFab, StickyCta, Lightbox, FlagStrip,
PROJECTS, I18N, LEADERS, VALUES_DATA, PARTNERS, AWARDS, useT
});