"use client"; import { FolderOpen, MessageSquare, PenSquare } 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, PageUsage, SearchSpace, User } from "../../types/layout.types"; import { ChatListItem } from "./ChatListItem"; import { NavSection } from "./NavSection"; 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[]; sharedChats?: ChatItem[]; activeChatId?: number | null; onNewChat: () => void; onChatSelect: (chat: ChatItem) => void; onChatDelete?: (chat: ChatItem) => void; onViewAllSharedChats?: () => void; onViewAllPrivateChats?: () => void; user: User; onSettings?: () => void; onManageMembers?: () => void; onUserSettings?: () => void; onLogout?: () => void; pageUsage?: PageUsage; className?: string; } export function Sidebar({ searchSpace, isCollapsed = false, onToggleCollapse, navItems, onNavItemClick, chats, sharedChats = [], activeChatId, onNewChat, onChatSelect, onChatDelete, onViewAllSharedChats, onViewAllPrivateChats, user, onSettings, onManageMembers, 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")} ) : ( )}
{/* Scrollable content */} {isCollapsed ? (
{(chats.length > 0 || sharedChats.length > 0) && ( {t("chats")} ({chats.length + sharedChats.length}) )}
) : (
{/* Shared Chats Section */} {t("view_all_shared_chats") || "View all shared chats"} ) : undefined } > {sharedChats.length > 0 ? (
{sharedChats.map((chat) => ( onChatSelect(chat)} onDelete={() => onChatDelete?.(chat)} /> ))}
) : (

{t("no_shared_chats")}

)}
{/* Private Chats Section */} {t("view_all_private_chats") || "View all private chats"} ) : undefined } > {chats.length > 0 ? (
{chats.map((chat) => ( onChatSelect(chat)} onDelete={() => onChatDelete?.(chat)} /> ))}
) : (

{t("no_chats")}

)}
)}
{/* Footer */}
{/* Platform navigation */} {navItems.length > 0 && ( )} {pageUsage && !isCollapsed && ( )}
); }