/* Floating AI Assistant — global launcher + compact chat panel, on every app page */ (function () { const { useState, useRef, useEffect } = React; const Icon = window.Icon; const D = window.YEIDA; // lightweight reply engine (shares the spirit of the full-page assistant) function reply(text) { const t = text.toLowerCase(); const A = [ { m: ['construction', 'build', 'start'], r: "Your construction is at Step 4 — Authority Review. Next action: upload the pending Soil Test Report. Want me to open the Construction module?", a: ['construction', 'Open Construction'] }, { m: ['payment', 'due', 'pay', 'challan'], r: "You have ₹1,47,585 across 3 dues. Authority records and challans are on your Payments page.", a: ['payments', 'Open Payments'] }, { m: ['document', 'paper', 'lease', 'atl'], r: "Lease Deed: Completed. ATL: Pending — that's your next paperwork item. All documents live in the Document Center.", a: ['documents', 'Document Center'] }, { m: ['sell', 'transfer'], r: "To sell Plot B-47 you're eligible (7 years held). Estimated transfer cost ≈ ₹2.02 L. Shall I open the Transfer module?", a: ['transfer', 'Start Transfer'] }, { m: ['plan', 'design', 'tour', 'sample'], r: "I've matched 3 plans to your 300 sq.m east-facing plot, with 3D walkthroughs. Open Sample Plans?", a: ['sampleplans', 'View Plans'] }, { m: ['map', 'sector', 'location'], r: "Plot B-47 is in Sector 18, Block B — an east-facing 300 sq.m plot. I can open the interactive map.", a: ['sectormaps', 'Open Map'] }, ]; const hit = A.find(x => x.m.some(k => t.includes(k))); return hit ? { reply: hit.r, action: hit.a } : { reply: "I can help with your plot status, authority paperwork, payments, construction, sample plans and transfers. What would you like to know?" }; } function FloatingAssistant({ go }) { const [open, setOpen] = useState(false); const [msgs, setMsgs] = useState([{ role: 'bot', text: "Hi Rajeev 👋 Quick help on your plot — payments, paperwork, construction or plans. Ask away, or open the full assistant." }]); const [input, setInput] = useState(''); const [typing, setTyping] = useState(false); const scroller = useRef(null); useEffect(() => { if (scroller.current) scroller.current.scrollTop = scroller.current.scrollHeight; }, [msgs, typing, open]); const send = (text) => { if (!text.trim()) return; setMsgs(m => [...m, { role: 'user', text }]); setInput(''); setTyping(true); setTimeout(() => { const r = reply(text); setTyping(false); setMsgs(m => [...m, { role: 'bot', text: r.reply, action: r.action }]); }, 800); }; const quick = ['What payments are pending?', 'What is my ATL status?', 'Show sample plans']; return (