import React, { useState } from 'react'
import { Link } from 'react-router'
import { ArrowRight, ArrowUpRight, BookOpen, LayoutList, ListOrdered, Compass, ChevronRight, ChevronDown, Camera, LayoutGrid } from 'lucide-react'
import { useTranslation } from '../../i18n'
import { useHelpStore, docTitle } from '../../store/helpStore'
import { ctxKey, ctxBulletKey, guideKey, guidesFor, helpMedia, docsRoute, helpContextTrail, childHelpContexts } from '../../help/registry'
import type { HelpContext, HelpGuide } from '../../help/types'
import { helpIcon } from './helpIcons'
import HelpBadge from './HelpBadge'
import HelpDocLink from './HelpDocLink'
import HelpSizeChip from './HelpSizeChip'
import { useScreenRoute } from './useScreenRoute'
/**
* The overview of a screen: what it is, what is on it, and a card per guide.
* With no registered context (a screen that has no help yet) it says so and
* leaves the search box as the way forward.
*/
export default function HelpHome({ context }: { context: HelpContext | null }): React.ReactElement {
const { t } = useTranslation()
const docIndex = useHelpStore(s => s.docIndex)
const closeHelp = useHelpStore(s => s.closeHelp)
// Folded until asked for: the guides below matter more, the tabs are one click away.
const [subScreensOpen, setSubScreensOpen] = useState(false)
const screenRoute = useScreenRoute(context?.route)
if (!context) {
return (
{/* Screens under this one (the tabs of Settings, the journal of Journey) */}
{children.length > 0 && (
{subScreensOpen && (
{children.map(child => (
))}
)}
)}
{/* The screen itself */}
{context.hero && (
{t(ctxKey(context.id, 'title'))}
)}
{/* What is on it */}
{bullets.length > 0 && (
{t('help.center.onThisScreen')}
)
}
/** One sub-screen: opens its overview in place; the one the reader is on says so. */
function SubScreenCard({ screen }: { screen: HelpContext }): React.ReactElement {
const { t } = useTranslation()
const browse = useHelpStore(s => s.browse)
const contextId = useHelpStore(s => s.contextId)
const current = screen.id === contextId
const Icon = helpIcon(screen.icon)
return (
)
}
/** The marker for the screen the reader is actually on. */
export function ThisScreenChip(): React.ReactElement {
const { t } = useTranslation()
return (
{t('help.center.thisScreen')}
)
}
export function SectionLabel({ children }: { children: React.ReactNode }): React.ReactElement {
return