"use client"
/**
* Folder details panel — OsFolderGlyph header + aggregates (`library-inspector` helpers today).
* Reusable across list hubs that share `LibraryFolder` / `LibraryItem` shapes or adapters.
*/
import * as React from "react"
import { OsFolderGlyph } from "@/components/data-views/os-folder-glyph"
import { Button } from "@/components/ui/button"
import { Separator } from "@/components/ui/separator"
import { Tip } from "@/components/ui/tip"
import { cn } from "@/lib/utils"
import type { LibraryItem } from "@/lib/mock/library"
import type { LibraryFolder } from "@/lib/mock/library-folders"
import {
aggregateFolderQuestions,
BLOOM_LEVEL_ORDER,
questionsInFolderSubtree,
} from "@/lib/mock/library-inspector"
function DetailBreadcrumbNav({ segments }: { segments: { id: string; label: string }[] }) {
if (segments.length === 0) return null
return (
)
}
function DetailSection({
title,
children,
className,
}: {
title: string
children: React.ReactNode
className?: string
}) {
return (
{title}
{children}
{children}
) } export interface FolderDetailsShellProps { folder: LibraryFolder folders: LibraryFolder[] questions: LibraryItem[] /** Clears selection (tree inspector dismiss). */ onClearSelection?: () => void } export function FolderDetailsShell({ folder, folders, questions, onClearSelection, }: FolderDetailsShellProps) { const subtreeQuestions = questionsInFolderSubtree(folders, questions, folder.id) const agg = aggregateFolderQuestions(subtreeQuestions) const { totalQuestions, difficulty: diffAgg, bloom, avgPbi, scoredCount } = agg const diffSum = diffAgg.easy + diffAgg.medium + diffAgg.hard const maxBloomCount = Math.max(1, ...BLOOM_LEVEL_ORDER.map(level => bloom[level] ?? 0)) const breadcrumbs: LibraryFolder[] = [] let cur: LibraryFolder | undefined = folder while (cur) { breadcrumbs.unshift(cur) cur = folders.find(f => f.id === cur?.parentId) } const pathSegments = breadcrumbs.map(f => ({ id: f.id, label: f.name })) const diffHeadingId = `folder-details-difficulty-${folder.id}` const bloomHeadingId = `folder-details-bloom-${folder.id}` return ({totalQuestions} question{totalQuestions !== 1 ? "s" : ""}
Avg. pBIS:{" "} {avgPbi != null ? avgPbi.toFixed(2) : "—"}{" "} ({scoredCount} of {totalQuestions} scored)
{pathSegments.length > 0 ? ( <>