import React, { useState } from 'react' import { ChevronRight, ChevronDown, Folder, FileText } from 'lucide-react' import { clsx } from 'clsx' import type { DocFile } from '@/lib/types' import { getDisplayName } from '@/lib/parser' interface DocTreeProps { files: DocFile[] selectedPath?: string onSelect: (file: DocFile) => void } interface DocTreeNodeProps { file: DocFile level: number selectedPath?: string onSelect: (file: DocFile) => void } const DocTreeNode = React.memo(({ file, level, selectedPath, onSelect }: DocTreeNodeProps) => { const [expanded, setExpanded] = useState(level === 0) const isSelected = selectedPath === file.relativePath const isDir = file.isDir const handleClick = (e: React.MouseEvent) => { e.stopPropagation() if (isDir) { setExpanded(!expanded) } else { onSelect(file) } } return (