import React, { useState, useCallback, useRef, useEffect } from 'react'; import { Send, Sparkles, X } from 'lucide-react'; import { useApp } from '../../context/AppContext'; const sampleQueries = [ "What is the main topic of my documents?", "Summarize the key findings", "Extract important dates and events", ]; export const QueryInput: React.FC = () => { const { state, handleQuery, dispatch, clearResults } = useApp(); const [showSamples, setShowSamples] = useState(true); const textareaRef = useRef(null); const handleKeyDown = useCallback( (e: React.KeyboardEvent) => { if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); handleQuery(); } }, [handleQuery] ); const handleSubmit = useCallback(() => { handleQuery(); }, [handleQuery]); const autoResize = useCallback(() => { const textarea = textareaRef.current; if (textarea) { textarea.style.height = 'auto'; textarea.style.height = `${Math.min(textarea.scrollHeight, 200)}px`; } }, []); useEffect(() => { autoResize(); }, [state.currentQuery, autoResize]); const handleClear = () => { clearResults(); setShowSamples(true); }; return (