/* Vision Demo pages — โหลดหลัง app.jsx (ใช้ navigate/NotFoundPage global) ก่อน pages-w3.jsx */
function VisionPage({ t, k, toast }) {
const html = (window.VISION_HTML || {})[k];
const ref = React.useRef(null);
React.useEffect(() => {
const el = ref.current; if (!el) return;
const on = (e) => {
const g = e.target.closest("[data-go]");
if (g) {
const v = g.getAttribute("data-go");
navigate(v === "dashboard" ? "/app" : v === "trades" ? "/app/trades" : "/app/vision/" + v);
return;
}
if (e.target.closest(".vd-btn")) toast("◆ VISION DEMO — ฟีเจอร์นี้อยู่ใน roadmap · ข้อมูลเป็นตัวอย่าง");
};
el.addEventListener("click", on);
return () => el.removeEventListener("click", on);
}, [k]);
React.useEffect(() => { window.scrollTo(0, 0); }, [k]);
React.useEffect(() => {
if (k !== "overview" || !ref.current) return;
const MAP = { "AI Insight": "insight", "Tiltmeter": "tilt", "LINE / Telegram": "notify",
"Verified Badge": "verified", "Leaderboard": "leaderboard", "Ranking": "ranking",
"รีวิว EA / Tools": "tools", "Broker Review": "broker", "Economic Calendar": "calendar" };
ref.current.querySelectorAll(".vd-card").forEach((c) => {
const titles = [...c.querySelectorAll("div")].map((d) => d.textContent.trim());
for (const t2 in MAP) {
if (titles.indexOf(t2) !== -1) { c.setAttribute("data-go", MAP[t2]); c.style.cursor = "pointer"; break; }
}
});
const tour = [...ref.current.querySelectorAll(".vd-btn")].find((b) => b.textContent.indexOf("เริ่มทัวร์") !== -1);
if (tour) tour.setAttribute("data-go", "insight");
}, [k]);
if (!html) return