"use client"; import React, { useState, useEffect } from 'react'; import { MessageCircle, Send, X, Minimize2, Maximize2, Monitor, Terminal, Cpu, HardDrive } from 'lucide-react'; import { ResizableHandle, ResizablePanel, ResizablePanelGroup, } from "@/components/ui/resizable"; const Footer = ({ className = "", shortcuts }) => { const [messages, setMessages] = useState([]); const [inputValue, setInputValue] = useState(''); const [isMobile, setIsMobile] = useState(false); const [currentTime, setCurrentTime] = useState(new Date()); useEffect(() => { const checkMobile = () => { setIsMobile(window.innerWidth < 768); }; checkMobile(); window.addEventListener('resize', checkMobile); const timer = setInterval(() => { setCurrentTime(new Date()); }, 1000); return () => { window.removeEventListener('resize', checkMobile); clearInterval(timer); }; }, []); const defaultShortcuts = [ [ { key: "F1", label: "Help", action: () => addSystemMessage("F1: Help system activated") }, { key: "F2", label: "Save", action: () => addSystemMessage("F2: Save operation") }, { key: "F3", label: "Search", action: () => addSystemMessage("F3: Search mode") }, { key: "F4", label: "Edit", action: () => addSystemMessage("F4: Edit mode") }, { key: "F5", label: "Refresh", action: () => addSystemMessage("F5: System refresh") }, { key: "F6", label: "Copy", action: () => addSystemMessage("F6: Copy operation") }, { key: "F7", label: "use client", action: () => addSystemMessage("F7: use client operation") }, { key: "F8", label: "Delete", action: () => addSystemMessage("F8: Delete operation") }, { key: "F9", label: "Menu", action: () => addSystemMessage("F9: Menu opened") }, { key: "F10", label: "Exit", action: () => addSystemMessage("F10: Exit requested") }, ], [ { key: "Ctrl+N", label: "New", action: () => addSystemMessage("New file created") }, { key: "Ctrl+O", label: "Open", action: () => addSystemMessage("Open file dialog") }, { key: "Ctrl+S", label: "Save", action: () => addSystemMessage("File saved") }, { key: "Ctrl+P", label: "Print", action: () => addSystemMessage("Print dialog") }, { key: "Ctrl+X", label: "Cut", action: () => addSystemMessage("Cut to clipboard") }, { key: "Ctrl+C", label: "Copy", action: () => addSystemMessage("Copied to clipboard") }, { key: "Ctrl+V", label: "Paste", action: () => addSystemMessage("Pasted from clipboard") }, { key: "Ctrl+Z", label: "Undo", action: () => addSystemMessage("Undo last action") }, { key: "Ctrl+Y", label: "Redo", action: () => addSystemMessage("Redo last action") }, { key: "Ctrl+A", label: "Select", action: () => addSystemMessage("Select all") }, ] ]; const shortcutGroups = shortcuts || defaultShortcuts; const addSystemMessage = (text) => { setMessages(prev => [...prev, { text, sender: 'system', timestamp: new Date() }]); }; const handleSendMessage = () => { if (inputValue.trim() !== '') { const userMessage = { text: inputValue, sender: 'user', timestamp: new Date() }; setMessages(prev => [...prev, userMessage]); setInputValue(''); setTimeout(() => { const responses = [ "SYSTEM: Command processed successfully", "ASSISTANT: Processing your request...", "BOT: I understand your query. How can I assist further?", "SYSTEM: Operation completed. Status: OK", "ASSISTANT: Ready for next command", ]; const randomResponse = responses[Math.floor(Math.random() * responses.length)]; setMessages(prev => [...prev, { text: randomResponse, sender: 'bot', timestamp: new Date() }]); }, 800); } }; const handleKeyPress = (e) => { if (e.key === 'Enter') { handleSendMessage(); } }; const formatTime = (date) => { return date.toLocaleTimeString('en-US', { hour12: false, hour: '2-digit', minute: '2-digit', second: '2-digit' }); }; const formatShortcutKey = (key) => { const parts = key.split(/(\+)/); return parts.map((part, index) => { if (part === '+') { return part; } return {part}; }); }; if (isMobile) { return (
MOBILE TERMINAL
{formatTime(currentTime)}
> setInputValue(e.target.value)} onKeyPress={handleKeyPress} />
OUTPUT
READY
{messages.length === 0 ? (
● SYSTEM READY ●
Awaiting input...
) : ( messages.map((message, index) => (
[{formatTime(message.timestamp)}] {message.sender.toUpperCase()}:
{message.text}
)) )}
); } return (
SYSTEM v3.0
{formatTime(currentTime)}
{shortcutGroups[0].map((shortcut, index) => ( ))}
{shortcutGroups[1].map((shortcut, index) => ( ))}
INPUT
CMD
COMMAND LINE INTERFACE
>