/* Powermieter Landingpage — interactive building blocks */
const { useState: useBS, useEffect: useBE, useRef: useBR } = React;
/* ---- Process rail (sticky top, current = Informieren) ---- */
function ProcessRail({ current = 1, onJump }) {
return (
);
}
/* ---- Browser frame wrapper for the Paula dashboard ---- */
function BrowserFrame({ url, children }) {
return (
);
}
/* ---- Floating Paula chat ---- */
function PaulaChat({ open, onOpen, onClose }) {
const [msgs, setMsgs] = useBS([
{ who: 'a', text: 'Hallo, ich bin Paula 👋 Ihre digitale Energieberaterin. Was möchten Sie wissen?' },
]);
const [typing, setTyping] = useBS(false);
const [asked, setAsked] = useBS([]);
const bodyRef = useBR(null);
const timer = useBR(null);
useBE(() => { if (bodyRef.current) bodyRef.current.scrollTop = bodyRef.current.scrollHeight; }, [msgs, typing, open]);
useBE(() => () => clearTimeout(timer.current), []);
const ask = (qa) => {
setMsgs(m => [...m, { who: 'q', text: qa.q }]);
setAsked(a => [...a, qa.q]);
setTyping(true);
timer.current = setTimeout(() => {
setTyping(false);
setMsgs(m => [...m, { who: 'a', text: qa.a }]);
}, 850);
};
const remaining = LP_CHAT_QA.filter(qa => !asked.includes(qa.q));
if (!open) {
return (
);
}
return (
Paula
Ihre Energieberaterin · online
{msgs.map((m, i) => (
{m.text}
))}
{typing &&
}
{remaining.length ? remaining.map(qa => (
)) : (
Weitere Fragen? Im echten Portal antwortet Paula auf alles rund um Ihren Strom.
)}
);
}
/* ---- Mobile sticky bottom CTA ---- */
function StickyCTA({ onClick }) {
return (
} onClick={onClick}>Jetzt Interesse anmelden
);
}
Object.assign(window, { ProcessRail, BrowserFrame, PaulaChat, StickyCTA });