'use client'; /** * Input bar «+» — меню: режимы, источники, Learn, Create, Model Council */ import { Plus, Zap, Sliders, Star, Globe, GraduationCap, Network, BookOpen, Users } from 'lucide-react'; import { cn } from '@/lib/utils'; import { Popover, PopoverButton, PopoverPanel } from '@headlessui/react'; import { useChat } from '@/lib/hooks/useChat'; import { AnimatePresence, motion } from 'motion/react'; import { useCallback, useEffect, useState } from 'react'; const MODES = [ { key: 'speed', label: 'Quick', icon: Zap }, { key: 'balanced', label: 'Pro', icon: Sliders }, { key: 'quality', label: 'Deep', icon: Star }, ] as const; const SOURCES = [ { key: 'web', label: 'Web', icon: Globe }, { key: 'academic', label: 'Academic', icon: GraduationCap }, { key: 'discussions', label: 'Social', icon: Network }, ] as const; const InputBarPlus = () => { const { optimizationMode, setOptimizationMode, sources, setSources } = useChat(); const [learningMode, setLearningModeState] = useState(false); const [modelCouncil, setModelCouncilState] = useState(false); useEffect(() => { setLearningModeState(typeof window !== 'undefined' && localStorage.getItem('learningMode') === 'true'); setModelCouncilState(typeof window !== 'undefined' && localStorage.getItem('modelCouncil') === 'true'); const handler = () => { setLearningModeState(localStorage.getItem('learningMode') === 'true'); setModelCouncilState(localStorage.getItem('modelCouncil') === 'true'); }; window.addEventListener('client-config-changed', handler); return () => window.removeEventListener('client-config-changed', handler); }, []); const setLearningMode = useCallback((v: boolean) => { localStorage.setItem('learningMode', String(v)); setLearningModeState(v); window.dispatchEvent(new Event('client-config-changed')); }, []); const setModelCouncil = useCallback((v: boolean) => { localStorage.setItem('modelCouncil', String(v)); setModelCouncilState(v); window.dispatchEvent(new Event('client-config-changed')); }, []); const toggleSource = useCallback( (key: string) => { if (sources.includes(key)) { setSources(sources.filter((s) => s !== key)); } else { setSources([...sources, key]); } }, [sources, setSources] ); return ( {({ open }) => ( <> {open && (

Mode

{MODES.map((m) => { const Icon = m.icon; const isActive = optimizationMode === m.key; return ( ); })}

Sources

{SOURCES.map((s) => { const Icon = s.icon; const checked = sources.includes(s.key); return ( ); })}

Create

Ask in chat: "Create a table about..." or "Generate an image of..."

)}
)}
); }; export default InputBarPlus;