import { useRef, useEffect } from 'preact/hooks'; export default function ChatInput({ onSend, disabled }) { const textareaRef = useRef(null); useEffect(() => { if (!disabled) textareaRef.current?.focus(); }, [disabled]); function handleSend() { const text = textareaRef.current?.value.trim(); if (!text || disabled) return; onSend(text); textareaRef.current.value = ''; textareaRef.current.style.height = '38px'; } function handleKeyDown(e) { if (e.key === 'Enter' && !e.shiftKey && !disabled) { e.preventDefault(); handleSend(); } } function handleInput() { const el = textareaRef.current; el.style.height = '38px'; if (el.scrollHeight > 38) { el.style.height = el.scrollHeight + 'px'; } } return (