"use client" import { useEffect } from "react" import Link from "next/link" import { useRouter } from "next/navigation" import type { LucideIcon } from "lucide-react" import { ChevronRight, HardDrive, Users } from "lucide-react" import { DRIVE_DROP_TARGET_CLASS } from "@/components/drive/drive-file-context-menu" import { DriveFolderIcon } from "@/lib/drive/drive-file-icon" import { DRIVE_ICON_BTN } from "@/lib/drive/drive-chrome-classes" import { mailNavRowClass } from "@/lib/mail-chrome-classes" import { cn } from "@/lib/utils" import type { DriveView } from "@/lib/drive/drive-url" import { folderPathFromSegments } from "@/lib/drive/drive-url" import { useDriveList, useDriveSharedWithMe } from "@/lib/api/hooks/use-drive-queries" import type { DriveFileInfo } from "@/lib/api/types" import { displayFileName } from "@/lib/drive/display-file-name" import { ancestorFolderPaths, driveFolderHref, isSharedRootSelected, normalizeDriveFolderPath, selectedFolderPath, } from "@/lib/drive/drive-sidebar-tree" import { useIsMobile } from "@/hooks/use-mobile" import { useDriveDropTarget } from "@/lib/hooks/use-drive-drop-target" import { useDriveUIStore } from "@/lib/stores/drive-ui-store" const INDENT_PX = 16 function useFolderChildren(folderPath: string, enabled: boolean, sharedRoot: boolean) { const list = useDriveList(folderPath, 1, "", enabled && !sharedRoot) const shared = useDriveSharedWithMe(1, "", enabled && sharedRoot) const active = sharedRoot ? shared : list const directories = active.data?.files.filter((file) => file.type === "directory") ?? [] return { directories } } function SidebarTreeCaret({ visible, expanded, onToggle, label, }: { visible: boolean expanded: boolean onToggle: () => void label: string }) { if (!visible) { return