/* ========================================================================= Emerge Profit — Centro de Ayuda · plugin Body-only React app. Embebido entre el header y footer del sitio. ========================================================================= */ const { useState, useMemo, useEffect, useRef } = React; /* ---------------- Icons (Lucide-style, inline SVG) ---------------- */ const Ico = { Book: (p) => , Search: (p) => , X: (p) => , Plus: (p) => , Help: (p) => , Arrow: (p) => , Grid: (p) => , Trend: (p) => , Shield: (p) => , Cal: (p) => , Wallet: (p) => , Target: (p) => , Split: (p) => , Rocket: (p) => , Risk: (p) => , Op: (p) => , Ok: (p) => , Wd: (p) => , Sparkle: (p) => , Info: (p) => , Warn: (p) => , Check: (p) => , }; const KPI_ICONS = { trend: Ico.Trend, shield: Ico.Shield, calendar: Ico.Cal, wallet: Ico.Wallet, target: Ico.Target, split: Ico.Split, rocket: Ico.Rocket, }; const CAT_META = { all: { label: "Todo", icon: Ico.Grid }, operativa: { label: "Operativa", icon: Ico.Op }, riesgo: { label: "Riesgo", icon: Ico.Risk }, aprobacion: { label: "Aprobación", icon: Ico.Ok }, retiros: { label: "Retiros", icon: Ico.Wd }, }; const CAT_FAQ_ICON = { operativa: Ico.Op, riesgo: Ico.Risk, aprobacion: Ico.Ok, retiros: Ico.Wd, }; const SECTIONS = ["emergefx", "futuros", "pases"]; /* ---------------- KPI card ---------------- */ function KPI({ icon, title, value, desc }) { const Icon = KPI_ICONS[icon] || Ico.Trend; // Bold the first numeric/highlight token in desc for hierarchy const renderDesc = () => { // We accept inline by re-parsing simple markers: words ending in % or like "10 días" // For simplicity, return raw text; the design system handles colors at .ep-kpi__desc strong return desc; }; return (
{title}
{value}
{renderDesc()}
); } /* ---------------- FAQ item ---------------- */ function FAQItem({ faq, open, onToggle }) { const Icon = CAT_FAQ_ICON[faq.cat] || Ico.Op; const renderBody = () => { // Plugin renders rich HTML; static data uses plain string with \n\n separators. if (faq.aHtml) { return
; } return (faq.a || "").split(/\n\n+/).map((para, i) =>

{para}

); }; return (
{renderBody()} {faq.highlight && (
{faq.highlight.type === "info" && } {faq.highlight.type === "warn" && } {faq.highlight.type === "success" && } {faq.highlight.text}
)}
); } /* ---------------- Sidebar ---------------- */ function Sidebar({ cat, setCat, counts, ui }) { return ( ); } /* ---------------- Highlighted rules ---------------- */ function HighlightedRules({ section, onSeeAll, ui }) { // Pull highlighted from EPHC_DATA so the user can edit it from the plugin admin. const sec = (window.EPHC_DATA && window.EPHC_DATA.sections) ? window.EPHC_DATA.sections[section] : null; const items = (sec && Array.isArray(sec.highlighted)) ? sec.highlighted : []; if (items.length === 0) return null; const iconMap = { trend: Ico.Trend, shield: Ico.Shield, sparkle: Ico.Sparkle, target: Ico.Target, split: Ico.Split, rocket: Ico.Rocket, calendar: Ico.Cal, wallet: Ico.Wallet }; return (

{ui.highlighted_title || "Reglas destacadas"}

{items.map((it, i) => { const I = iconMap[it.icon] || Ico.Trend; return (

{it.title}

{it.text}

{it.pill && {it.pill}}
); })}
); } /* ---------------- App ---------------- */ function HelpCenter() { const [section, setSection] = useState("emergefx"); const [cat, setCat] = useState("all"); const [openId, setOpenId] = useState(null); const faqsRef = useRef(null); const data = (window.EPHC_DATA && window.EPHC_DATA.sections) ? window.EPHC_DATA.sections[section] : null; const UI = (window.EPHC_DATA && window.EPHC_DATA.ui) ? window.EPHC_DATA.ui : {}; if (!data) return null; const allFaqs = data.faqs || []; // Counts per category for current section const counts = useMemo(() => { const c = { all: allFaqs.length }; for (const k of Object.keys(CAT_META)) if (k !== "all") c[k] = 0; for (const f of allFaqs) c[f.cat] = (c[f.cat] || 0) + 1; return c; }, [allFaqs]); // Reset cat & open state when switching tab useEffect(() => { setCat("all"); setOpenId(null); }, [section]); // Filtered list const filtered = useMemo(() => { if (cat === "all") return allFaqs; return allFaqs.filter(f => f.cat === cat); }, [allFaqs, cat]); const scrollToFAQs = () => { if (!faqsRef.current) return; const r = faqsRef.current.getBoundingClientRect(); const y = window.pageYOffset + r.top - 24; window.scrollTo({ top: y, behavior: "smooth" }); }; return (
{/* ----- Tabs (primer elemento — sin hero) ----- */}
{SECTIONS.map(key => { const s = window.EPHC_DATA.sections[key]; return ( ); })}
{/* ----- KPIs ----- */}
{data.kpis.map((k, i) => )}
{/* ----- Body: sidebar + FAQs ----- */}
{filtered.length === 0 ? (
Sin resultados
No hay reglas en esta categoría todavía.
) : filtered.map((f, i) => { const id = section + "-" + cat + "-" + i + "-" + f.q; return ( setOpenId(openId === id ? null : id)} /> ); })}
{/* ----- Highlighted rules ----- */}
); } window.HelpCenter = HelpCenter; /* Auto-mount: render into #ephc-root (plugin) or #ep-help-root (static preview). */ (function () { const mount = function () { const targets = [document.getElementById('ephc-root'), document.getElementById('ep-help-root')].filter(Boolean); targets.forEach(el => { if (el.dataset.ephcMounted) return; el.dataset.ephcMounted = '1'; ReactDOM.createRoot(el).render(); }); }; if (document.readyState !== 'loading') { mount(); } else { document.addEventListener('DOMContentLoaded', mount); } })();