import React, { useState, useRef, useEffect } from 'react'; import type { Persona } from '@/lib/ai/types'; import { SendIcon } from './Icons'; import { Button } from '@/components/ui/button'; interface ChatInputProps { onSendMessage: (message: string) => void; isLoading: boolean; persona: Persona; isLocked?: boolean; onUnlock?: () => void; } export const ChatInput: React.FC = ({ onSendMessage, isLoading, persona, isLocked, onUnlock }) => { const [input, setInput] = useState(''); const textareaRef = useRef(null); const handleSubmit = (e?: React.FormEvent) => { e?.preventDefault(); if (input.trim() && !isLoading && !isLocked) { onSendMessage(input.trim()); setInput(''); } }; const handleKeyDown = (e: React.KeyboardEvent) => { if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); handleSubmit(); } }; useEffect(() => { if (textareaRef.current) { textareaRef.current.style.height = 'auto'; textareaRef.current.style.height = `${Math.min(textareaRef.current.scrollHeight, 150)}px`; } }, [input]); if (isLocked) { return (

Upgrade to access {persona.name}

); } return (