import React, { useState, useEffect, useRef } from 'react'; import { MessageSquare, X, Send, Loader2 } from 'lucide-react'; import { ChatMessage } from '../types'; interface Props { isOpen: boolean; onClose: () => void; messages: ChatMessage[]; onSendMessage: (text: string) => void; isProcessing: boolean; } const ChatBot: React.FC = ({ isOpen, onClose, messages, onSendMessage, isProcessing }) => { const [input, setInput] = useState(''); const scrollRef = useRef(null); useEffect(() => { if (scrollRef.current) { scrollRef.current.scrollTop = scrollRef.current.scrollHeight; } }, [messages, isOpen]); const handleSubmit = (e: React.FormEvent) => { e.preventDefault(); if (!input.trim() || isProcessing) return; onSendMessage(input); setInput(''); }; if (!isOpen) return null; return (
{/* Header */}

Paper Assistant

{/* Messages */}
{messages.length === 0 && (
Ask me anything about the paper!
)} {messages.map((msg) => (
{msg.text}
))} {isProcessing && (
)}
{/* Input */}
setInput(e.target.value)} placeholder="Type a question..." className="w-full bg-white dark:bg-black/30 border border-gray-200 dark:border-gray-700 rounded-xl pl-4 pr-10 py-3 text-sm focus:outline-none focus:ring-2 focus:ring-brand-500/50" />
); }; export default ChatBot;