'use client'; import React, { useState, useEffect, useRef } from 'react'; import { Search, Calendar, FileText, Video, ShoppingBag, Repeat, DollarSign, Users, Activity, User, Shield, Volume2, VolumeX, X, Sparkles, Command, Scale, Lock, } from 'lucide-react'; import { Patient, StaffRole } from '@/types/clinical'; import { clinicalAudio } from '@/lib/clinical-audio'; export interface CommandItem { id: string; category: 'Patients' | 'Navigation' | 'Actions' | 'Staff Role' | 'Settings'; title: string; subtitle?: string; icon: React.ReactNode; badge?: string; action: () => void; } interface CommandPaletteProps { isOpen: boolean; onClose: () => void; patients: Patient[]; onSelectPatient: (p: Patient) => void; onNavigateTab: (tab: 'calendar' | 'charting' | 'telehealth' | 'retail' | 'memberships' | 'billing' | 'retention') => void; onOpenWaitlist: () => void; onSetStaffRole: (role: StaffRole) => void; onToggleAudio: () => void; audioEnabled: boolean; onOpenCourtVault?: () => void; onLockTerminal?: () => void; } export const CommandPalette: React.FC = ({ isOpen, onClose, patients, onSelectPatient, onNavigateTab, onOpenWaitlist, onSetStaffRole, onToggleAudio, audioEnabled, onOpenCourtVault, onLockTerminal, }) => { const [query, setQuery] = useState(''); const [selectedIndex, setSelectedIndex] = useState(0); const inputRef = useRef(null); const listRef = useRef(null); useEffect(() => { if (isOpen) { setTimeout(() => inputRef.current?.focus(), 50); setQuery(''); setSelectedIndex(0); clinicalAudio.playClick(); } }, [isOpen]); // Generate commands list const baseCommands: CommandItem[] = [ // Patients ...patients.map((p) => ({ id: `patient-${p.id}`, category: 'Patients' as const, title: `${p.firstName} ${p.lastName}`, subtitle: `${p.carePlan.targetCondition} • Visit ${p.carePlan.completedVisits}/${p.carePlan.totalVisits}`, badge: p.status === 'dropout_risk' ? 'Dropout Risk' : 'Active Patient', icon: , action: () => { onSelectPatient(p); onNavigateTab('charting'); onClose(); }, })), // Navigation { id: 'nav-calendar', category: 'Navigation', title: 'Schedule & Operatory Calendar', subtitle: 'View live provider schedules and patient arrival states', icon: , action: () => { onNavigateTab('calendar'); onClose(); }, }, { id: 'nav-charting', category: 'Navigation', title: 'Clinical SOAP Charting & Spine Visualizer', subtitle: '2D anatomical subluxation clicks and ambient AI scribe', icon: , action: () => { onNavigateTab('charting'); onClose(); }, }, { id: 'nav-telehealth', category: 'Navigation', title: 'Virtual Telehealth Consultation Suite', subtitle: 'HIPAA-compliant video consult with live side-by-side notes', icon: