"use client"; import { FileText, FolderOpen, MessageSquare, PenSquare, Plus } from "lucide-react"; import { useTranslations } from "next-intl"; import { Button } from "@/components/ui/button"; import { ScrollArea } from "@/components/ui/scroll-area"; import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip"; import { cn } from "@/lib/utils"; import type { ChatItem, NavItem, NoteItem, PageUsage, SearchSpace, User, } from "../../types/layout.types"; import { ChatListItem } from "./ChatListItem"; import { NavSection } from "./NavSection"; import { NoteListItem } from "./NoteListItem"; import { PageUsageDisplay } from "./PageUsageDisplay"; import { SidebarCollapseButton } from "./SidebarCollapseButton"; import { SidebarHeader } from "./SidebarHeader"; import { SidebarSection } from "./SidebarSection"; import { SidebarUserProfile } from "./SidebarUserProfile"; interface SidebarProps { searchSpace: SearchSpace | null; isCollapsed?: boolean; onToggleCollapse?: () => void; navItems: NavItem[]; onNavItemClick?: (item: NavItem) => void; chats: ChatItem[]; activeChatId?: number | null; onNewChat: () => void; onChatSelect: (chat: ChatItem) => void; onChatDelete?: (chat: ChatItem) => void; onViewAllChats?: () => void; notes: NoteItem[]; activeNoteId?: number | null; onNoteSelect: (note: NoteItem) => void; onNoteDelete?: (note: NoteItem) => void; onAddNote?: () => void; onViewAllNotes?: () => void; user: User; onSettings?: () => void; onManageMembers?: () => void; onSeeAllSearchSpaces?: () => void; onUserSettings?: () => void; onLogout?: () => void; pageUsage?: PageUsage; className?: string; } export function Sidebar({ searchSpace, isCollapsed = false, onToggleCollapse, navItems, onNavItemClick, chats, activeChatId, onNewChat, onChatSelect, onChatDelete, onViewAllChats, notes, activeNoteId, onNoteSelect, onNoteDelete, onAddNote, onViewAllNotes, user, onSettings, onManageMembers, onSeeAllSearchSpaces, onUserSettings, onLogout, pageUsage, className, }: SidebarProps) { const t = useTranslations("sidebar"); return (
{/* Header - search space name or collapse button when collapsed */} {isCollapsed ? (
{})} />
) : (
{})} />
)} {/* New chat button */}
{isCollapsed ? ( {t("new_chat")} ) : ( )}
{/* Platform navigation */} {navItems.length > 0 && ( )} {/* Scrollable content */} {isCollapsed ? (
{chats.length > 0 && ( {t("recent_chats")} ({chats.length}) )} {notes.length > 0 && ( {t("notes")} ({notes.length}) )}
) : (
0 ? ( {t("view_all_chats")} ) : undefined } > {chats.length > 0 ? (
{chats.map((chat) => ( onChatSelect(chat)} onDelete={() => onChatDelete?.(chat)} /> ))}
) : (

{t("no_recent_chats")}

)}
0 ? ( {t("view_all_notes")} ) : undefined } persistentAction={ onAddNote && notes.length > 0 ? ( {t("add_note")} ) : undefined } > {notes.length > 0 ? (
{notes.map((note) => ( onNoteSelect(note)} onDelete={() => onNoteDelete?.(note)} /> ))}
) : onAddNote ? ( ) : (

{t("no_notes")}

)}
)}
{/* Footer */}
{pageUsage && !isCollapsed && ( )}
); }