{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "dashboards-03",
  "title": "Project health",
  "description": "A sprint goal measured against where the team should be by today, and a short table of workstreams with their health and a filter for the ones that need attention.",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "https://ui.ndekocode.dev/r/avatar.json",
    "https://ui.ndekocode.dev/r/button.json",
    "https://ui.ndekocode.dev/r/chip.json",
    "https://ui.ndekocode.dev/r/icons.json",
    "https://ui.ndekocode.dev/r/motion-number.json",
    "https://ui.ndekocode.dev/r/skeleton.json",
    "https://ui.ndekocode.dev/r/tabs.json",
    "https://ui.ndekocode.dev/r/theme.json",
    "https://ui.ndekocode.dev/r/use-prefers-reduced-motion.json",
    "https://ui.ndekocode.dev/r/utils.json",
    "https://ui.ndekocode.dev/r/wash.json"
  ],
  "files": [
    {
      "path": "registry/ndeko/blocks/dashboards/dashboards-03/index.tsx",
      "content": "'use client';\n\nimport { useState } from 'react';\n\nimport { CircleCheckIcon } from '@/registry/ndeko/lib/icons';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { Button } from '@/registry/ndeko/ui/button';\nimport { Skeleton } from '@/registry/ndeko/ui/skeleton';\nimport { Tabs, TabsList, TabsTab } from '@/registry/ndeko/ui/tabs';\n\nimport { PROJECT, SPRINTS, type Sprint, type SprintId } from './data';\nimport {\n  csvRowsOf,\n  goalOf,\n  needsAttention,\n  rowsOf,\n  sprintOf,\n  totalsOf,\n} from './figures';\nimport { GoalCard } from './goal-card';\nimport {\n  ExportButton,\n  PeriodSwitch,\n  REPORT_SURFACE,\n  ReportToolbar,\n  downloadCsv,\n  useSimulatedLoad,\n  type PeriodOption,\n} from './report-frame';\nimport { WorkstreamTable } from './workstream-table';\n\ntype RowFilter = 'all' | 'attention';\n\nconst SPRINT_OPTIONS: PeriodOption<SprintId>[] = SPRINTS.map((sprint) => ({\n  id: sprint.id,\n  label: `Sprint ${sprint.number}`,\n}));\n\nconst CURRENT_SPRINT: SprintId = 's23';\n\nconst SKELETON_ROWS = ['first', 'second', 'third', 'fourth', 'fifth'];\n\nfunction sprintKeyOf(sprintId: SprintId) {\n  return sprintId;\n}\n\nfunction isRowFilter(value: unknown): value is RowFilter {\n  const isAll = value === 'all';\n  const isAttention = value === 'attention';\n  return isAll || isAttention;\n}\n\nfunction peopleLabelOf(count: number) {\n  if (count === 1) {\n    return '1 person';\n  }\n  return `${count} people`;\n}\n\nfunction blockedLabelOf(count: number) {\n  if (count === 0) {\n    return 'nothing blocked';\n  }\n  if (count === 1) {\n    return '1 task blocked';\n  }\n  return `${count} tasks blocked`;\n}\n\nfunction workstreamCountOf(count: number) {\n  if (count === 1) {\n    return '1 workstream';\n  }\n  return `${count} workstreams`;\n}\n\nfunction calmLineOf(sprint: Sprint) {\n  const isRunning = sprint.daysElapsed < sprint.workingDays;\n  if (isRunning) {\n    return `Every workstream is on track in sprint ${sprint.number}`;\n  }\n  return `Every workstream was on track in sprint ${sprint.number}`;\n}\n\nfunction visibleRowsOf<Row>(\n  isAttentionView: boolean,\n  rows: Row[],\n  attentionRows: Row[]\n) {\n  if (isAttentionView) {\n    return attentionRows;\n  }\n  return rows;\n}\n\nfunction totalsWhen<Value>(isShown: boolean, value: Value) {\n  if (isShown) {\n    return value;\n  }\n  return null;\n}\n\nfunction HealthSkeleton() {\n  return (\n    <div aria-hidden='true' className='flex flex-col gap-4'>\n      <div className={cn(REPORT_SURFACE, 'flex flex-col gap-4 p-5')}>\n        <Skeleton className='h-3 w-24' />\n        <Skeleton className='h-4 w-64 max-w-full' />\n        <Skeleton className='h-7 w-40' />\n        <Skeleton className='h-2 w-full rounded-full' />\n        <Skeleton className='h-3 w-56 max-w-full' />\n      </div>\n      <div className={cn(REPORT_SURFACE, 'flex flex-col gap-3 p-5')}>\n        <Skeleton className='h-3.5 w-28' />\n        {SKELETON_ROWS.map((row) => (\n          <Skeleton key={row} className='h-8 w-full' />\n        ))}\n      </div>\n    </div>\n  );\n}\n\nexport default function Dashboards03() {\n  const load = useSimulatedLoad<SprintId>(CURRENT_SPRINT, sprintKeyOf);\n  const [filter, setFilter] = useState<RowFilter>('all');\n  const shownSprintId = load.loaded ?? load.requested;\n  const sprint = sprintOf(shownSprintId);\n  const rows = rowsOf(sprint);\n  const totals = totalsOf(rows);\n  const goal = goalOf(sprint, totals);\n  const attentionRows = rows.filter(needsAttention);\n  const isAttentionView = filter === 'attention';\n  const visibleRows = visibleRowsOf(isAttentionView, rows, attentionRows);\n  const isCalm = attentionRows.length === 0;\n  const showsCalmState = isAttentionView && isCalm;\n  const showsTotals = !isAttentionView;\n  const shownTotals = totalsWhen(showsTotals, totals);\n  const peopleLabel = peopleLabelOf(PROJECT.peopleCount);\n  const meta = `${PROJECT.release} · ${sprint.rangeLabel} · ${peopleLabel}`;\n  const workstreamLabel = workstreamCountOf(rows.length);\n  const blockedLabel = blockedLabelOf(totals.blocked);\n  const calmLine = calmLineOf(sprint);\n\n  function changeFilter(value: unknown) {\n    if (isRowFilter(value)) {\n      setFilter(value);\n    }\n  }\n\n  function showAll() {\n    setFilter('all');\n  }\n\n  function exportHealth() {\n    const csvRows = csvRowsOf(rows);\n    const fileName = `${PROJECT.fileSlug}-sprint-${sprint.number}.csv`;\n    downloadCsv(fileName, csvRows);\n  }\n\n  return (\n    <div className='bg-background text-foreground min-h-dvh w-full'>\n      <ReportToolbar title={PROJECT.name} meta={meta}>\n        <ExportButton disabled={load.isFirstLoad} onExport={exportHealth} />\n      </ReportToolbar>\n      <div className='mx-auto flex w-full max-w-4xl flex-col gap-4 px-4 py-5 md:px-6'>\n        <PeriodSwitch\n          label='Sprint'\n          options={SPRINT_OPTIONS}\n          value={load.requested}\n          isUpdating={load.isUpdating}\n          onValueChange={load.request}\n        />\n        {load.isFirstLoad && <HealthSkeleton />}\n        {!load.isFirstLoad && (\n          <div aria-busy={load.isUpdating} className='flex flex-col gap-4'>\n            <GoalCard sprint={sprint} goal={goal} />\n            <section\n              aria-label='Workstreams'\n              className={cn(REPORT_SURFACE, 'flex flex-col gap-3 pt-4 pb-1')}\n            >\n              <div className='flex flex-wrap items-center justify-between gap-x-3 gap-y-2 px-4'>\n                <div className='flex flex-col gap-0.5'>\n                  <h2 className='text-sm font-medium'>Workstreams</h2>\n                  <p className='text-muted-foreground text-xs tabular-nums'>\n                    {`${workstreamLabel}, ${blockedLabel}`}\n                  </p>\n                </div>\n                <Tabs value={filter} onValueChange={changeFilter}>\n                  <TabsList\n                    variant='segmented'\n                    aria-label='Workstreams to show'\n                  >\n                    <TabsTab value='all'>All</TabsTab>\n                    <TabsTab value='attention'>\n                      Needs attention\n                      <span className='text-muted-foreground text-xs tabular-nums'>\n                        {attentionRows.length}\n                      </span>\n                    </TabsTab>\n                  </TabsList>\n                </Tabs>\n              </div>\n              <WorkstreamTable\n                rows={visibleRows}\n                totals={shownTotals}\n                emptyState={\n                  showsCalmState && (\n                    <div className='flex flex-col items-center gap-3 px-4 py-10 text-center'>\n                      <span className='keycap-3d text-success-foreground flex size-9 items-center justify-center rounded-lg'>\n                        <CircleCheckIcon />\n                      </span>\n                      <p className='text-[13px] font-medium text-balance'>\n                        {calmLine}\n                      </p>\n                      <Button variant='outline' size='sm' onClick={showAll}>\n                        Show all workstreams\n                      </Button>\n                    </div>\n                  )\n                }\n              />\n            </section>\n          </div>\n        )}\n      </div>\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/dashboards-03/index.tsx"
    },
    {
      "path": "registry/ndeko/blocks/dashboards/dashboards-03/goal-card.tsx",
      "content": "'use client';\n\nimport { AnimatePresence, motion, type Transition } from 'motion/react';\n\nimport { MotionNumber } from '@/components/core/motion-number';\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { Wash } from '@/registry/ndeko/ui/wash';\n\nimport type { Sprint } from './data';\nimport { percentAmountOf, type Goal, type GoalTone } from './figures';\n\nconst MOVE_TRANSITION: Transition = {\n  duration: 0.3,\n  ease: [0.77, 0, 0.175, 1],\n};\n\nconst MARKER_IN: Transition = { duration: 0.2, ease: [0.23, 1, 0.32, 1] };\n\nconst MARKER_OUT: Transition = { duration: 0.12, ease: [0.23, 1, 0.32, 1] };\n\nconst INSTANT: Transition = { duration: 0 };\n\nconst VERDICT_TONE: Record<GoalTone, string> = {\n  good: 'text-success-foreground',\n  behind: 'text-warning-foreground',\n  neutral: 'text-foreground',\n};\n\nfunction moveTransitionOf(shouldReduceMotion: boolean | null) {\n  if (shouldReduceMotion) {\n    return INSTANT;\n  }\n  return MOVE_TRANSITION;\n}\n\nfunction taskWordOf(count: number) {\n  if (count === 1) {\n    return 'task';\n  }\n  return 'tasks';\n}\n\nfunction percentTextOf(share: number) {\n  const percent = share * 100;\n  return `${percent}%`;\n}\n\ntype GoalMeterProps = {\n  goal: Goal;\n  transition: Transition;\n};\n\n/** Done against planned, with a marker where the team should be by today. Both slide into place. */\nfunction GoalMeter({ goal, transition }: GoalMeterProps) {\n  const hiddenShare = 1 - goal.share;\n  const hiddenText = percentTextOf(hiddenShare);\n  const fillOffset = `-${hiddenText}`;\n  const taskWord = taskWordOf(goal.planned);\n  const valueText = `${goal.done} of ${goal.planned} ${taskWord} done`;\n  const hasMarker = goal.expectedShare !== null;\n  const markerShare = goal.expectedShare ?? 0;\n  const markerOffset = percentTextOf(markerShare);\n\n  return (\n    <div\n      role='progressbar'\n      aria-label='Sprint progress'\n      aria-valuemin={0}\n      aria-valuemax={goal.planned}\n      aria-valuenow={goal.done}\n      aria-valuetext={valueText}\n      className='bg-foreground/[0.08] relative h-2 rounded-full'\n    >\n      <span className='absolute inset-0 overflow-hidden rounded-full'>\n        <motion.span\n          initial={false}\n          animate={{ x: fillOffset }}\n          transition={transition}\n          className='bg-primary absolute inset-0 rounded-full'\n        />\n      </span>\n      <AnimatePresence initial={false}>\n        {hasMarker && (\n          <motion.span\n            key='marker'\n            aria-hidden='true'\n            initial={{ opacity: 0, x: markerOffset }}\n            animate={{\n              opacity: 1,\n              x: markerOffset,\n              transition: { opacity: MARKER_IN, x: transition },\n            }}\n            exit={{ opacity: 0, transition: MARKER_OUT }}\n            className='pointer-events-none absolute -inset-y-1 left-0 w-full'\n          >\n            <span className='bg-foreground ring-card absolute inset-y-0 left-0 w-0.5 -translate-x-1/2 rounded-full ring-2' />\n          </motion.span>\n        )}\n      </AnimatePresence>\n    </div>\n  );\n}\n\ntype GoalCardProps = {\n  sprint: Sprint;\n  goal: Goal;\n};\n\nexport function GoalCard({ sprint, goal }: GoalCardProps) {\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const transition = moveTransitionOf(shouldReduceMotion);\n  const shareAmount = percentAmountOf(goal.share);\n  const hasMarker = goal.expectedShare !== null;\n  const taskWord = taskWordOf(goal.planned);\n\n  return (\n    <section\n      aria-label={`Sprint ${sprint.number} goal`}\n      className='surface-brand relative isolate flex flex-col gap-4 rounded-xl p-5'\n    >\n      <Wash />\n      <div className='flex flex-wrap items-baseline justify-between gap-x-3 gap-y-1'>\n        <p className='text-muted-foreground text-xs font-medium'>\n          {`Sprint ${sprint.number} goal`}\n        </p>\n        <span className='text-muted-foreground text-xs'>\n          Illustrative figures\n        </span>\n      </div>\n      <p className='text-base font-semibold text-balance'>{sprint.goal}</p>\n      <div className='flex flex-wrap items-baseline justify-between gap-x-6 gap-y-1'>\n        <p className='flex items-baseline gap-1.5'>\n          <MotionNumber value={goal.done} className='text-2xl font-semibold' />\n          <span className='text-muted-foreground text-[13px]'>of</span>\n          <MotionNumber\n            value={goal.planned}\n            className='text-[13px] font-medium'\n          />\n          <span className='text-muted-foreground text-[13px]'>\n            {`${taskWord} done`}\n          </span>\n        </p>\n        <MotionNumber\n          value={shareAmount}\n          suffix='%'\n          className='text-lg font-semibold'\n        />\n      </div>\n      <GoalMeter goal={goal} transition={transition} />\n      <div className='flex flex-wrap items-center justify-between gap-x-4 gap-y-1 text-xs'>\n        <span className={cn('font-medium', VERDICT_TONE[goal.tone])}>\n          {goal.verdict}\n        </span>\n        <span className='text-muted-foreground flex items-center gap-1.5'>\n          {hasMarker && (\n            <span\n              aria-hidden='true'\n              className='bg-foreground inline-block h-2.5 w-0.5 rounded-full'\n            />\n          )}\n          {goal.timeLine}\n        </span>\n      </div>\n    </section>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/dashboards-03/goal-card.tsx"
    },
    {
      "path": "registry/ndeko/blocks/dashboards/dashboards-03/workstream-table.tsx",
      "content": "'use client';\n\nimport {\n  AnimatePresence,\n  motion,\n  type Transition,\n  type Variants,\n} from 'motion/react';\n\nimport { MotionNumber } from '@/components/core/motion-number';\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { Avatar } from '@/registry/ndeko/ui/avatar';\nimport { Chip } from '@/registry/ndeko/ui/chip';\n\nimport { HEALTH_META, type Lead } from './data';\nimport { percentAmountOf, type Totals, type WorkstreamRow } from './figures';\n\nconst TABLE_GRID =\n  'grid grid-cols-[minmax(0,1fr)_auto] items-center gap-x-3 px-4 sm:grid-cols-[minmax(0,1.3fr)_minmax(0,1fr)_2.75rem_2.75rem_3.5rem_minmax(5.5rem,1fr)_6rem]';\n\nconst WIDE_CELL = 'hidden sm:flex';\n\nconst FIGURE_CELL = 'hidden justify-end text-[13px] sm:flex';\n\nconst ROW_IN: Transition = { duration: 0.2, ease: [0.23, 1, 0.32, 1] };\n\nconst ROW_OUT: Transition = { duration: 0.14, ease: [0.23, 1, 0.32, 1] };\n\nconst MOVE_TRANSITION: Transition = {\n  duration: 0.3,\n  ease: [0.77, 0, 0.175, 1],\n};\n\nconst INSTANT: Transition = { duration: 0 };\n\nconst ROW_VARIANTS: Variants = {\n  hidden: {\n    height: 0,\n    opacity: 0,\n    overflow: 'hidden',\n    transition: ROW_OUT,\n  },\n  shown: {\n    height: 'auto',\n    opacity: 1,\n    transition: ROW_IN,\n    transitionEnd: { overflow: 'visible' },\n  },\n};\n\nconst ROW_FADE: Variants = {\n  hidden: { opacity: 0, transition: ROW_OUT },\n  shown: { opacity: 1, transition: ROW_IN },\n};\n\nfunction rowVariantsOf(shouldReduceMotion: boolean | null) {\n  if (shouldReduceMotion) {\n    return ROW_FADE;\n  }\n  return ROW_VARIANTS;\n}\n\nfunction moveTransitionOf(shouldReduceMotion: boolean | null) {\n  if (shouldReduceMotion) {\n    return INSTANT;\n  }\n  return MOVE_TRANSITION;\n}\n\nfunction firstNameOf(lead: Lead) {\n  const [firstName] = lead.name.split(' ');\n  return firstName;\n}\n\ntype FigureProps = {\n  value: number;\n  isQuiet?: boolean;\n};\n\nfunction Figure({ value, isQuiet }: FigureProps) {\n  return (\n    <MotionNumber\n      value={value}\n      className={cn(isQuiet && 'text-muted-foreground')}\n    />\n  );\n}\n\ntype ProgressCellProps = {\n  share: number;\n  transition: Transition;\n};\n\nfunction ProgressCell({ share, transition }: ProgressCellProps) {\n  const hiddenShare = 1 - share;\n  const hiddenPercent = hiddenShare * 100;\n  const offset = `-${hiddenPercent}%`;\n  const shareAmount = percentAmountOf(share);\n\n  return (\n    <div role='cell' className={cn(WIDE_CELL, 'items-center gap-2')}>\n      <span className='bg-foreground/[0.08] relative block h-1 min-w-0 flex-1 overflow-hidden rounded-full'>\n        <motion.span\n          initial={false}\n          animate={{ x: offset }}\n          transition={transition}\n          className='bg-primary absolute inset-0 rounded-full'\n        />\n      </span>\n      <MotionNumber\n        value={shareAmount}\n        suffix='%'\n        className='text-muted-foreground w-9 justify-end text-xs'\n      />\n    </div>\n  );\n}\n\nfunction LeadCell({ lead }: { lead: Lead }) {\n  return (\n    <div role='cell' className={cn(WIDE_CELL, 'min-w-0 items-center gap-2')}>\n      <Avatar className='size-6' seed={lead.name} />\n      <span className='truncate text-[13px]'>{firstNameOf(lead)}</span>\n    </div>\n  );\n}\n\nfunction HealthChip({ row }: { row: WorkstreamRow }) {\n  const meta = HEALTH_META[row.health];\n\n  return (\n    <Chip color={meta.color}>\n      <span aria-hidden='true' className='size-1.5 rounded-full bg-(--chip)' />\n      {meta.label}\n    </Chip>\n  );\n}\n\ntype WorkstreamTableProps = {\n  rows: WorkstreamRow[];\n  totals: Totals | null;\n  emptyState?: React.ReactNode;\n};\n\n/** One grid for the header, the rows and the totals, so the figures line up. Rows enter and leave in place. */\nexport function WorkstreamTable({\n  rows,\n  totals,\n  emptyState,\n}: WorkstreamTableProps) {\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const rowVariants = rowVariantsOf(shouldReduceMotion);\n  const transition = moveTransitionOf(shouldReduceMotion);\n\n  return (\n    <div role='table' aria-label='Workstreams' className='flex flex-col'>\n      <div role='rowgroup'>\n        <div\n          role='row'\n          className={cn(\n            TABLE_GRID,\n            'hairline-b border-border text-muted-foreground h-9 text-xs font-medium'\n          )}\n        >\n          <span role='columnheader'>Workstream</span>\n          <span role='columnheader' className={WIDE_CELL}>\n            Lead\n          </span>\n          <span role='columnheader' className={FIGURE_CELL}>\n            Done\n          </span>\n          <span role='columnheader' className={FIGURE_CELL}>\n            Open\n          </span>\n          <span role='columnheader' className={FIGURE_CELL}>\n            Blocked\n          </span>\n          <span role='columnheader' className={WIDE_CELL}>\n            Progress\n          </span>\n          <span\n            role='columnheader'\n            className='flex justify-end sm:justify-start'\n          >\n            Health\n          </span>\n        </div>\n      </div>\n      <div role='rowgroup' className='hairline-divide-y divide-border'>\n        <AnimatePresence initial={false}>\n          {rows.map((row) => {\n            const isBlockFree = row.blocked === 0;\n            const leadFirstName = firstNameOf(row.lead);\n            const phoneLine = `${row.done} of ${row.planned} done · ${leadFirstName}`;\n\n            return (\n              <motion.div\n                key={row.id}\n                variants={rowVariants}\n                initial='hidden'\n                animate='shown'\n                exit='hidden'\n              >\n                <div role='row' className={cn(TABLE_GRID, 'min-h-12 py-2.5')}>\n                  <div role='cell' className='flex min-w-0 flex-col gap-0.5'>\n                    <span className='truncate text-[13px] font-medium'>\n                      {row.name}\n                    </span>\n                    <span className='text-muted-foreground text-xs tabular-nums sm:hidden'>\n                      {phoneLine}\n                    </span>\n                  </div>\n                  <LeadCell lead={row.lead} />\n                  <div role='cell' className={FIGURE_CELL}>\n                    <Figure value={row.done} />\n                  </div>\n                  <div role='cell' className={FIGURE_CELL}>\n                    <Figure value={row.open} />\n                  </div>\n                  <div role='cell' className={FIGURE_CELL}>\n                    <Figure value={row.blocked} isQuiet={isBlockFree} />\n                  </div>\n                  <ProgressCell share={row.share} transition={transition} />\n                  <div\n                    role='cell'\n                    className='flex justify-end sm:justify-start'\n                  >\n                    <HealthChip row={row} />\n                  </div>\n                </div>\n              </motion.div>\n            );\n          })}\n        </AnimatePresence>\n      </div>\n      {emptyState}\n      {totals && (\n        <div role='rowgroup'>\n          <div\n            role='row'\n            className={cn(\n              TABLE_GRID,\n              'hairline-t border-border min-h-11 py-2.5 font-medium'\n            )}\n          >\n            <span role='rowheader' className='text-[13px]'>\n              All workstreams\n            </span>\n            <span role='cell' className={WIDE_CELL} />\n            <div role='cell' className={FIGURE_CELL}>\n              <Figure value={totals.done} />\n            </div>\n            <div role='cell' className={FIGURE_CELL}>\n              <Figure value={totals.open} />\n            </div>\n            <div role='cell' className={FIGURE_CELL}>\n              <Figure value={totals.blocked} />\n            </div>\n            <ProgressCell share={totals.share} transition={transition} />\n            <span\n              role='cell'\n              className='text-muted-foreground flex justify-end text-xs tabular-nums sm:justify-start'\n            >\n              {`${totals.done} of ${totals.planned}`}\n            </span>\n          </div>\n        </div>\n      )}\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/dashboards-03/workstream-table.tsx"
    },
    {
      "path": "registry/ndeko/blocks/dashboards/dashboards-03/report-frame.tsx",
      "content": "'use client';\n\nimport {\n  AnimatePresence,\n  motion,\n  type Transition,\n  type Variants,\n} from 'motion/react';\nimport { useEffect, useState } from 'react';\n\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport {\n  CheckIcon,\n  DownloadIcon,\n  LoaderCircleIcon,\n} from '@/registry/ndeko/lib/icons';\nimport { Button } from '@/registry/ndeko/ui/button';\nimport { Tabs, TabsList, TabsTab } from '@/registry/ndeko/ui/tabs';\n\nexport const REPORT_SURFACE =\n  'bg-card hairline-ring ring-border rounded-xl shadow-[0_1px_2px_rgb(0_0_0/0.04)] dark:bg-foreground/[0.03]';\n\nconst FIRST_LOAD_MS = 900;\n\nconst UPDATE_MS = 450;\n\nconst EXPORTED_NOTICE_MS = 1600;\n\nconst FORMULA_PREFIXES = ['=', '+', '-', '@'];\n\nconst SWAP_TRANSITION: Transition = { duration: 0.15, ease: [0.2, 0, 0, 1] };\n\nconst NOTE_IN: Transition = { duration: 0.2, ease: [0.23, 1, 0.32, 1] };\n\nconst NOTE_OUT: Transition = { duration: 0.12, ease: [0.23, 1, 0.32, 1] };\n\nconst SWAP_VARIANTS: Variants = {\n  enter: { opacity: 0, scale: 0.6, filter: 'blur(2px)' },\n  visible: { opacity: 1, scale: 1, filter: 'blur(0px)' },\n  exit: { opacity: 0, scale: 0.6, filter: 'blur(2px)' },\n};\n\nconst NOTE_VARIANTS: Variants = {\n  enter: { opacity: 0, x: -4 },\n  visible: { opacity: 1, x: 0, transition: NOTE_IN },\n  exit: { opacity: 0, transition: NOTE_OUT },\n};\n\nconst FADE_VARIANTS: Variants = {\n  enter: { opacity: 0 },\n  visible: { opacity: 1, transition: NOTE_IN },\n  exit: { opacity: 0, transition: NOTE_OUT },\n};\n\nfunction swapVariantsOf(shouldReduceMotion: boolean | null) {\n  if (shouldReduceMotion) {\n    return FADE_VARIANTS;\n  }\n  return SWAP_VARIANTS;\n}\n\nfunction noteVariantsOf(shouldReduceMotion: boolean | null) {\n  if (shouldReduceMotion) {\n    return FADE_VARIANTS;\n  }\n  return NOTE_VARIANTS;\n}\n\nfunction loadDelayOf(isFirstLoad: boolean) {\n  if (isFirstLoad) {\n    return FIRST_LOAD_MS;\n  }\n  return UPDATE_MS;\n}\n\nfunction loadedKeyOf<Query>(\n  loaded: Query | null,\n  keyOf: (query: Query) => string\n) {\n  if (loaded === null) {\n    return null;\n  }\n  return keyOf(loaded);\n}\n\n/**\n * Stands in for a request: the first load shows a skeleton, a later change keeps the\n * previous result on screen until the next one arrives.\n */\nexport function useSimulatedLoad<Query>(\n  initialQuery: Query,\n  keyOf: (query: Query) => string\n) {\n  const [requested, setRequested] = useState(initialQuery);\n  const [loaded, setLoaded] = useState<Query | null>(null);\n  const isFirstLoad = loaded === null;\n  const delay = loadDelayOf(isFirstLoad);\n  const requestedKey = keyOf(requested);\n  const loadedKey = loadedKeyOf(loaded, keyOf);\n  const isUpdating = loadedKey !== null && loadedKey !== requestedKey;\n\n  useEffect(() => {\n    const timer = window.setTimeout(() => setLoaded(requested), delay);\n    return () => window.clearTimeout(timer);\n  }, [requested, delay]);\n\n  return { requested, loaded, isFirstLoad, isUpdating, request: setRequested };\n}\n\nexport type PeriodOption<Id extends string> = { id: Id; label: string };\n\ntype ReportToolbarProps = {\n  title: string;\n  meta: string;\n  children?: React.ReactNode;\n};\n\nexport function ReportToolbar({ title, meta, children }: ReportToolbarProps) {\n  return (\n    <div className='hairline-b border-border flex flex-wrap items-center gap-x-3 gap-y-2 px-4 py-3 md:px-6'>\n      <div className='flex min-w-0 flex-wrap items-baseline gap-x-2 gap-y-0.5'>\n        <h1 className='truncate text-lg font-semibold text-balance'>{title}</h1>\n        <span className='text-muted-foreground text-xs tabular-nums'>\n          {meta}\n        </span>\n      </div>\n      <div className='ml-auto flex items-center gap-2'>{children}</div>\n    </div>\n  );\n}\n\nfunction UpdatingNote({ isUpdating }: { isUpdating: boolean }) {\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const variants = noteVariantsOf(shouldReduceMotion);\n\n  return (\n    <span role='status' className='text-muted-foreground flex text-xs'>\n      <AnimatePresence initial={false}>\n        {isUpdating && (\n          <motion.span\n            key='updating'\n            variants={variants}\n            initial='enter'\n            animate='visible'\n            exit='exit'\n            className='flex items-center gap-1.5'\n          >\n            <LoaderCircleIcon className='size-3.5 animate-spin' />\n            Updating\n          </motion.span>\n        )}\n      </AnimatePresence>\n    </span>\n  );\n}\n\ntype PeriodSwitchProps<Id extends string> = {\n  label: string;\n  options: PeriodOption<Id>[];\n  value: Id;\n  isUpdating: boolean;\n  onValueChange: (id: Id) => void;\n};\n\nexport function PeriodSwitch<Id extends string>({\n  label,\n  options,\n  value,\n  isUpdating,\n  onValueChange,\n}: PeriodSwitchProps<Id>) {\n  function changeValue(nextValue: unknown) {\n    const option = options.find((candidate) => candidate.id === nextValue);\n    if (option) {\n      onValueChange(option.id);\n    }\n  }\n\n  return (\n    <div className='flex flex-wrap items-center gap-x-3 gap-y-2'>\n      <Tabs value={value} onValueChange={changeValue}>\n        <TabsList variant='segmented' aria-label={label}>\n          {options.map((option) => (\n            <TabsTab key={option.id} value={option.id}>\n              {option.label}\n            </TabsTab>\n          ))}\n        </TabsList>\n      </Tabs>\n      <UpdatingNote isUpdating={isUpdating} />\n    </div>\n  );\n}\n\nfunction exportGlyphOf(isExported: boolean) {\n  if (isExported) {\n    return { key: 'exported', icon: <CheckIcon /> };\n  }\n  return { key: 'export', icon: <DownloadIcon /> };\n}\n\nfunction exportLabelOf(isExported: boolean) {\n  if (isExported) {\n    return 'Downloaded';\n  }\n  return 'Export CSV';\n}\n\ntype ExportButtonProps = {\n  disabled?: boolean;\n  onExport: () => void;\n};\n\nexport function ExportButton({ disabled, onExport }: ExportButtonProps) {\n  const [isExported, setIsExported] = useState(false);\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const variants = swapVariantsOf(shouldReduceMotion);\n  const glyph = exportGlyphOf(isExported);\n  const label = exportLabelOf(isExported);\n\n  useEffect(() => {\n    if (!isExported) {\n      return;\n    }\n    const timer = window.setTimeout(\n      () => setIsExported(false),\n      EXPORTED_NOTICE_MS\n    );\n    return () => window.clearTimeout(timer);\n  }, [isExported]);\n\n  function exportReport() {\n    onExport();\n    setIsExported(true);\n  }\n\n  return (\n    <Button variant='outline' disabled={disabled} onClick={exportReport}>\n      <AnimatePresence mode='popLayout' initial={false}>\n        <motion.span\n          key={glyph.key}\n          variants={variants}\n          initial='enter'\n          animate='visible'\n          exit='exit'\n          transition={SWAP_TRANSITION}\n          className='flex'\n        >\n          {glyph.icon}\n        </motion.span>\n      </AnimatePresence>\n      <AnimatePresence mode='popLayout' initial={false}>\n        <motion.span\n          key={label}\n          variants={variants}\n          initial='enter'\n          animate='visible'\n          exit='exit'\n          transition={SWAP_TRANSITION}\n        >\n          {label}\n        </motion.span>\n      </AnimatePresence>\n    </Button>\n  );\n}\n\n/** Spreadsheet apps run a cell that starts with these characters as a formula. */\nfunction neutralizedCellOf(value: string) {\n  const startsLikeFormula = FORMULA_PREFIXES.some((prefix) =>\n    value.startsWith(prefix)\n  );\n  if (startsLikeFormula) {\n    return `'${value}`;\n  }\n  return value;\n}\n\nfunction csvCellOf(value: string) {\n  const neutralized = neutralizedCellOf(value);\n  const escaped = neutralized.replaceAll('\"', '\"\"');\n  return `\"${escaped}\"`;\n}\n\nfunction csvLineOf(row: string[]) {\n  const cells = row.map(csvCellOf);\n  return cells.join(',');\n}\n\n/** Builds the file in the browser and hands it to the download bar: nothing leaves the page. */\nexport function downloadCsv(fileName: string, rows: string[][]) {\n  const lines = rows.map(csvLineOf);\n  const text = lines.join('\\n');\n  const file = new Blob([text], { type: 'text/csv;charset=utf-8' });\n  const url = URL.createObjectURL(file);\n  const link = document.createElement('a');\n  link.href = url;\n  link.download = fileName;\n  link.click();\n  window.setTimeout(() => URL.revokeObjectURL(url), 0);\n}\n",
      "type": "registry:component",
      "target": "components/blocks/dashboards-03/report-frame.tsx"
    },
    {
      "path": "registry/ndeko/blocks/dashboards/dashboards-03/figures.ts",
      "content": "import {\n  HEALTH_META,\n  LEADS,\n  SPRINTS,\n  WORKSTREAMS,\n  type Health,\n  type Lead,\n  type Sprint,\n  type SprintId,\n} from './data';\n\nexport type WorkstreamRow = {\n  id: string;\n  name: string;\n  lead: Lead;\n  done: number;\n  open: number;\n  blocked: number;\n  planned: number;\n  share: number;\n  health: Health;\n};\n\nexport type Totals = {\n  done: number;\n  open: number;\n  blocked: number;\n  planned: number;\n  share: number;\n};\n\nexport type GoalTone = 'good' | 'behind' | 'neutral';\n\nexport type Goal = {\n  tone: GoalTone;\n  done: number;\n  planned: number;\n  share: number;\n  isFinished: boolean;\n  /** Where the team should be by today, as a share of the plan. Null once the sprint is over. */\n  expectedShare: number | null;\n  verdict: string;\n  timeLine: string;\n};\n\nexport function sprintOf(sprintId: SprintId) {\n  const sprint = SPRINTS.find((candidate) => candidate.id === sprintId);\n  if (sprint) {\n    return sprint;\n  }\n  return SPRINTS[0];\n}\n\nfunction leadOf(leadId: Lead['id']) {\n  const lead = LEADS.find((candidate) => candidate.id === leadId);\n  if (lead) {\n    return lead;\n  }\n  return LEADS[0];\n}\n\nfunction shareOf(part: number, whole: number) {\n  if (whole === 0) {\n    return 0;\n  }\n  return part / whole;\n}\n\nfunction sumOf(values: number[]) {\n  return values.reduce((total, value) => total + value, 0);\n}\n\nexport function rowsOf(sprint: Sprint): WorkstreamRow[] {\n  return WORKSTREAMS.map((workstream) => {\n    const figures = sprint.workstreams.find(\n      (candidate) => candidate.workstreamId === workstream.id\n    );\n    const done = figures?.done ?? 0;\n    const open = figures?.open ?? 0;\n    const blocked = figures?.blocked ?? 0;\n    const health = figures?.health ?? 'on-track';\n    const planned = done + open;\n    return {\n      id: workstream.id,\n      name: workstream.name,\n      lead: leadOf(workstream.leadId),\n      done,\n      open,\n      blocked,\n      planned,\n      share: shareOf(done, planned),\n      health,\n    };\n  });\n}\n\nexport function totalsOf(rows: WorkstreamRow[]): Totals {\n  const doneEach = rows.map((row) => row.done);\n  const openEach = rows.map((row) => row.open);\n  const blockedEach = rows.map((row) => row.blocked);\n  const done = sumOf(doneEach);\n  const open = sumOf(openEach);\n  const blocked = sumOf(blockedEach);\n  const planned = done + open;\n  const share = shareOf(done, planned);\n  return { done, open, blocked, planned, share };\n}\n\nfunction taskCountOf(count: number) {\n  if (count === 1) {\n    return '1 task';\n  }\n  return `${count} tasks`;\n}\n\nfunction dayCountOf(count: number) {\n  if (count === 1) {\n    return '1 working day';\n  }\n  return `${count} working days`;\n}\n\nfunction paceVerdictOf(gap: number) {\n  if (gap === 0) {\n    return 'On pace';\n  }\n  if (gap > 0) {\n    const ahead = taskCountOf(gap);\n    return `${ahead} ahead of pace`;\n  }\n  const missing = Math.abs(gap);\n  const behind = taskCountOf(missing);\n  return `${behind} behind pace`;\n}\n\nfunction paceToneOf(gap: number): GoalTone {\n  if (gap < 0) {\n    return 'behind';\n  }\n  return 'good';\n}\n\nfunction finishedToneOf(totals: Totals): GoalTone {\n  if (totals.done === totals.planned) {\n    return 'good';\n  }\n  return 'neutral';\n}\n\nfunction finishedVerdictOf(totals: Totals, sprint: Sprint) {\n  const moved = totals.planned - totals.done;\n  if (moved === 0) {\n    return 'Every planned task was done';\n  }\n  const movedTasks = taskCountOf(moved);\n  const nextSprint = sprint.number + 1;\n  return `${movedTasks} moved to sprint ${nextSprint}`;\n}\n\nexport function goalOf(sprint: Sprint, totals: Totals): Goal {\n  const isFinished = sprint.daysElapsed >= sprint.workingDays;\n  if (isFinished) {\n    return {\n      tone: finishedToneOf(totals),\n      done: totals.done,\n      planned: totals.planned,\n      share: totals.share,\n      isFinished,\n      expectedShare: null,\n      verdict: finishedVerdictOf(totals, sprint),\n      timeLine: sprint.rangeLabel,\n    };\n  }\n  const elapsedShare = shareOf(sprint.daysElapsed, sprint.workingDays);\n  const rawExpected = totals.planned * elapsedShare;\n  const expected = Math.round(rawExpected);\n  const gap = totals.done - expected;\n  const daysLeft = sprint.workingDays - sprint.daysElapsed;\n  const daysLeftLabel = dayCountOf(daysLeft);\n  return {\n    tone: paceToneOf(gap),\n    done: totals.done,\n    planned: totals.planned,\n    share: totals.share,\n    isFinished,\n    expectedShare: shareOf(expected, totals.planned),\n    verdict: paceVerdictOf(gap),\n    timeLine: `${daysLeftLabel} left, ${expected} expected done by today`,\n  };\n}\n\nexport function needsAttention(row: WorkstreamRow) {\n  return row.health !== 'on-track';\n}\n\nexport function formatShare(share: number) {\n  const percent = share * 100;\n  const rounded = Math.round(percent);\n  return `${rounded}%`;\n}\n\nexport function percentAmountOf(share: number) {\n  const percent = share * 100;\n  return Math.round(percent);\n}\n\nexport function csvRowsOf(rows: WorkstreamRow[]) {\n  const header = [\n    'Workstream',\n    'Lead',\n    'Done',\n    'Open',\n    'Blocked',\n    'Progress',\n    'Health',\n  ];\n  const lines = rows.map((row) => [\n    row.name,\n    row.lead.name,\n    String(row.done),\n    String(row.open),\n    String(row.blocked),\n    formatShare(row.share),\n    HEALTH_META[row.health].label,\n  ]);\n  return [header, ...lines];\n}\n",
      "type": "registry:component",
      "target": "components/blocks/dashboards-03/figures.ts"
    },
    {
      "path": "registry/ndeko/blocks/dashboards/dashboards-03/data.ts",
      "content": "export type SprintId = 's21' | 's22' | 's23';\n\nexport type Health = 'on-track' | 'at-risk' | 'off-track';\n\nexport type LeadId = 'amara' | 'lucas' | 'priya' | 'mateo' | 'hana';\n\nexport type Lead = {\n  id: LeadId;\n  name: string;\n};\n\nexport type WorkstreamFigures = {\n  workstreamId: string;\n  done: number;\n  open: number;\n  /** Blocked tasks are counted inside `open`. */\n  blocked: number;\n  health: Health;\n};\n\nexport type Workstream = {\n  id: string;\n  name: string;\n  leadId: LeadId;\n};\n\nexport type Sprint = {\n  id: SprintId;\n  number: number;\n  rangeLabel: string;\n  goal: string;\n  workingDays: number;\n  /** Working days already behind the team. Equal to `workingDays` once the sprint is over. */\n  daysElapsed: number;\n  workstreams: WorkstreamFigures[];\n};\n\nexport const PROJECT = {\n  name: 'Harbor mobile app',\n  release: 'Release 2.4',\n  peopleCount: 6,\n  fileSlug: 'harbor-mobile-app',\n};\n\nexport const HEALTH_META: Record<Health, { label: string; color: string }> = {\n  'on-track': { label: 'On track', color: 'var(--success)' },\n  'at-risk': { label: 'At risk', color: 'var(--warning)' },\n  'off-track': { label: 'Off track', color: 'var(--destructive)' },\n};\n\nexport const LEADS: Lead[] = [\n  {\n    id: 'amara',\n    name: 'Amara Okafor',\n  },\n  {\n    id: 'lucas',\n    name: 'Lucas Moreau',\n  },\n  {\n    id: 'priya',\n    name: 'Priya Raman',\n  },\n  {\n    id: 'mateo',\n    name: 'Mateo Silva',\n  },\n  { id: 'hana', name: 'Hana Kobayashi' },\n];\n\nexport const WORKSTREAMS: Workstream[] = [\n  { id: 'offline', name: 'Offline drafts', leadId: 'priya' },\n  { id: 'sync', name: 'Sync engine', leadId: 'mateo' },\n  { id: 'push', name: 'Push notifications', leadId: 'lucas' },\n  { id: 'a11y', name: 'Accessibility pass', leadId: 'amara' },\n  { id: 'release', name: 'Release checklist', leadId: 'hana' },\n];\n\nexport const SPRINTS: Sprint[] = [\n  {\n    id: 's21',\n    number: 21,\n    rangeLabel: '28 September to 9 October 2026',\n    goal: 'Offline drafts open without a connection',\n    workingDays: 10,\n    daysElapsed: 10,\n    workstreams: [\n      {\n        workstreamId: 'offline',\n        done: 8,\n        open: 0,\n        blocked: 0,\n        health: 'on-track',\n      },\n      {\n        workstreamId: 'sync',\n        done: 6,\n        open: 1,\n        blocked: 0,\n        health: 'on-track',\n      },\n      {\n        workstreamId: 'push',\n        done: 4,\n        open: 0,\n        blocked: 0,\n        health: 'on-track',\n      },\n      {\n        workstreamId: 'a11y',\n        done: 4,\n        open: 0,\n        blocked: 0,\n        health: 'on-track',\n      },\n      {\n        workstreamId: 'release',\n        done: 3,\n        open: 0,\n        blocked: 0,\n        health: 'on-track',\n      },\n    ],\n  },\n  {\n    id: 's22',\n    number: 22,\n    rangeLabel: '12 to 23 October 2026',\n    goal: 'Drafts sync back when the phone reconnects',\n    workingDays: 10,\n    daysElapsed: 10,\n    workstreams: [\n      {\n        workstreamId: 'offline',\n        done: 9,\n        open: 1,\n        blocked: 0,\n        health: 'on-track',\n      },\n      { workstreamId: 'sync', done: 5, open: 2, blocked: 1, health: 'at-risk' },\n      {\n        workstreamId: 'push',\n        done: 6,\n        open: 0,\n        blocked: 0,\n        health: 'on-track',\n      },\n      {\n        workstreamId: 'a11y',\n        done: 4,\n        open: 0,\n        blocked: 0,\n        health: 'on-track',\n      },\n      {\n        workstreamId: 'release',\n        done: 3,\n        open: 0,\n        blocked: 0,\n        health: 'on-track',\n      },\n    ],\n  },\n  {\n    id: 's23',\n    number: 23,\n    rangeLabel: '26 October to 6 November 2026',\n    goal: 'Offline drafts reach the beta group',\n    workingDays: 10,\n    daysElapsed: 8,\n    workstreams: [\n      {\n        workstreamId: 'offline',\n        done: 7,\n        open: 2,\n        blocked: 0,\n        health: 'on-track',\n      },\n      {\n        workstreamId: 'sync',\n        done: 4,\n        open: 4,\n        blocked: 2,\n        health: 'off-track',\n      },\n      {\n        workstreamId: 'push',\n        done: 5,\n        open: 1,\n        blocked: 0,\n        health: 'on-track',\n      },\n      { workstreamId: 'a11y', done: 3, open: 2, blocked: 1, health: 'at-risk' },\n      {\n        workstreamId: 'release',\n        done: 3,\n        open: 0,\n        blocked: 0,\n        health: 'on-track',\n      },\n    ],\n  },\n];\n",
      "type": "registry:component",
      "target": "components/blocks/dashboards-03/data.ts"
    }
  ],
  "categories": [
    "blocks",
    "dashboards"
  ],
  "type": "registry:block"
}