{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "dashboards-02",
  "title": "Weekly report",
  "description": "Hours by day as rounded bars that move to the new week, days ahead as empty slots, and the projects ranked by share with rows that travel to their new place.",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "https://ui.ndekocode.dev/r/avatar.json",
    "https://ui.ndekocode.dev/r/button.json",
    "https://ui.ndekocode.dev/r/icons.json",
    "https://ui.ndekocode.dev/r/motion-number.json",
    "https://ui.ndekocode.dev/r/select.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"
  ],
  "files": [
    {
      "path": "registry/ndeko/blocks/dashboards/dashboards-02/index.tsx",
      "content": "'use client';\n\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { Avatar } from '@/registry/ndeko/ui/avatar';\nimport { Button } from '@/registry/ndeko/ui/button';\nimport {\n  Select,\n  SelectContent,\n  SelectItem,\n  SelectTrigger,\n  SelectValue,\n} from '@/registry/ndeko/ui/select';\nimport { Skeleton } from '@/registry/ndeko/ui/skeleton';\n\nimport { MEMBERS, TEAM_NAME, WEEKS, type Member, type Week } from './data';\nimport { DayBars } from './day-bars';\nimport { DurationFigure } from './duration-figure';\nimport {\n  averageWorkdayMinutesOf,\n  csvRowsOf,\n  dayBarsOf,\n  memberOf,\n  rankingOf,\n  totalMinutesOf,\n  weekOf,\n  workingDaysSoFarOf,\n  type Scope,\n  type WeekQuery,\n} from './figures';\nimport { ProjectRanking } from './project-ranking';\nimport {\n  ExportButton,\n  PeriodSwitch,\n  REPORT_SURFACE,\n  ReportToolbar,\n  downloadCsv,\n  useSimulatedLoad,\n  type PeriodOption,\n} from './report-frame';\n\ntype ScopeOption = { value: Scope; label: string; member: Member | null };\n\nconst WEEK_OPTIONS: PeriodOption<Week['id']>[] = WEEKS.map((week) => ({\n  id: week.id,\n  label: `Week ${week.number}`,\n}));\n\nconst SCOPE_OPTIONS: ScopeOption[] = [\n  { value: 'everyone', label: 'Everyone', member: null },\n  ...MEMBERS.map((member) => ({\n    value: member.id,\n    label: member.name,\n    member,\n  })),\n];\n\nconst INITIAL_QUERY: WeekQuery = { weekId: 'w45', scope: 'everyone' };\n\nconst SKELETON_ROWS = ['first', 'second', 'third', 'fourth'];\n\nfunction queryKeyOf(query: WeekQuery) {\n  return `${query.weekId}:${query.scope}`;\n}\n\nfunction dayCountLabelOf(count: number, singular: string, plural: string) {\n  if (count === 1) {\n    return `1 ${singular}`;\n  }\n  return `${count} ${plural}`;\n}\n\nfunction dayNoteOf(week: Week) {\n  if (week.todayIndex === null) {\n    return 'Monday to Sunday';\n  }\n  const today = week.days[week.todayIndex];\n  const lastIndex = week.days.length - 1;\n  const aheadCount = lastIndex - week.todayIndex;\n  const aheadLabel = dayCountLabelOf(aheadCount, 'day', 'days');\n  return `${today.name} so far, ${aheadLabel} ahead`;\n}\n\nfunction scopeLabelOf(member: Member | null) {\n  if (member) {\n    return member.name;\n  }\n  return TEAM_NAME;\n}\n\nfunction firstNameOf(member: Member | null) {\n  if (!member) {\n    return 'the team';\n  }\n  const [firstName] = member.name.split(' ');\n  return firstName;\n}\n\nfunction MemberFace({ member }: { member: Member }) {\n  return <Avatar className='size-5' seed={member.name} />;\n}\n\nfunction WeekSkeleton() {\n  return (\n    <div\n      aria-hidden='true'\n      className='grid gap-4 lg:grid-cols-[minmax(0,1.6fr)_minmax(0,1fr)]'\n    >\n      <div className={cn(REPORT_SURFACE, 'flex flex-col gap-5 p-5')}>\n        <Skeleton className='h-3.5 w-28' />\n        <div className='flex gap-8'>\n          <Skeleton className='h-9 w-24' />\n          <Skeleton className='h-9 w-24' />\n        </div>\n        <Skeleton className='h-[204px] w-full rounded-lg' />\n      </div>\n      <div className={cn(REPORT_SURFACE, 'flex flex-col gap-4 p-5')}>\n        <Skeleton className='h-3.5 w-36' />\n        {SKELETON_ROWS.map((row) => (\n          <div key={row} className='flex flex-col gap-2'>\n            <Skeleton className='h-3 w-full' />\n            <Skeleton className='h-1 w-3/4' />\n          </div>\n        ))}\n      </div>\n    </div>\n  );\n}\n\nexport default function Dashboards02() {\n  const load = useSimulatedLoad<WeekQuery>(INITIAL_QUERY, queryKeyOf);\n  const shownQuery = load.loaded ?? load.requested;\n  const week = weekOf(shownQuery.weekId);\n  const member = memberOf(shownQuery.scope);\n  const bars = dayBarsOf(shownQuery);\n  const totalMinutes = totalMinutesOf(bars);\n  const averageMinutes = averageWorkdayMinutesOf(bars, week);\n  const workingDays = workingDaysSoFarOf(week);\n  const ranking = rankingOf(shownQuery);\n  const isEmptyWeek = totalMinutes === 0;\n  const scopeLabel = scopeLabelOf(member);\n  const title = `Week ${week.number}`;\n  const meta = `${week.rangeLabel} · ${scopeLabel}`;\n  const dayNote = dayNoteOf(week);\n  const workingDaysLabel = dayCountLabelOf(\n    workingDays,\n    'working day',\n    'working days'\n  );\n  const projectCountLabel = dayCountLabelOf(\n    ranking.projectCount,\n    'project',\n    'projects'\n  );\n  const chartTitle = `Hours by day in week ${week.number}, ${scopeLabel}`;\n  const firstName = firstNameOf(member);\n  const emptyLine = `Nothing to rank for ${firstName} in week ${week.number}`;\n\n  function changeWeek(weekId: Week['id']) {\n    load.request((previous) => ({ ...previous, weekId }));\n  }\n\n  function changeScope(value: unknown) {\n    const option = SCOPE_OPTIONS.find((candidate) => candidate.value === value);\n    if (!option) {\n      return;\n    }\n    load.request((previous) => ({ ...previous, scope: option.value }));\n  }\n\n  function showEveryone() {\n    load.request((previous) => ({ ...previous, scope: 'everyone' }));\n  }\n\n  function exportWeek() {\n    const rows = csvRowsOf(bars);\n    const fileName = `tidewell-week-${week.number}-${shownQuery.scope}.csv`;\n    downloadCsv(fileName, rows);\n  }\n\n  return (\n    <div className='bg-background text-foreground min-h-dvh w-full'>\n      <ReportToolbar title={title} meta={meta}>\n        <Select\n          items={SCOPE_OPTIONS}\n          value={load.requested.scope}\n          onValueChange={changeScope}\n        >\n          <SelectTrigger aria-label='Whose time' className='w-40 sm:w-44'>\n            <SelectValue />\n          </SelectTrigger>\n          <SelectContent align='end'>\n            {SCOPE_OPTIONS.map((option) => (\n              <SelectItem key={option.value} value={option.value}>\n                {option.member && <MemberFace member={option.member} />}\n                {option.label}\n              </SelectItem>\n            ))}\n          </SelectContent>\n        </Select>\n        <ExportButton disabled={load.isFirstLoad} onExport={exportWeek} />\n      </ReportToolbar>\n      <div className='mx-auto flex w-full max-w-5xl flex-col gap-4 px-4 py-5 md:px-6'>\n        <PeriodSwitch\n          label='Week'\n          options={WEEK_OPTIONS}\n          value={load.requested.weekId}\n          isUpdating={load.isUpdating}\n          onValueChange={changeWeek}\n        />\n        {load.isFirstLoad && <WeekSkeleton />}\n        {!load.isFirstLoad && (\n          <div\n            aria-busy={load.isUpdating}\n            className='grid items-start gap-4 lg:grid-cols-[minmax(0,1.6fr)_minmax(0,1fr)]'\n          >\n            <section\n              aria-label='Hours by day'\n              className={cn(REPORT_SURFACE, 'flex flex-col gap-5 p-5')}\n            >\n              <div className='flex flex-wrap items-baseline justify-between gap-x-3 gap-y-1'>\n                <div className='flex flex-col gap-0.5'>\n                  <h2 className='text-sm font-medium'>Hours by day</h2>\n                  <p className='text-muted-foreground text-xs'>{dayNote}</p>\n                </div>\n                <span className='text-muted-foreground text-xs'>\n                  Illustrative figures\n                </span>\n              </div>\n              <div className='flex flex-wrap gap-x-10 gap-y-3'>\n                <div className='flex flex-col gap-0.5'>\n                  <span className='text-muted-foreground text-xs'>Tracked</span>\n                  <DurationFigure\n                    minutes={totalMinutes}\n                    className='text-lg leading-7 font-semibold'\n                  />\n                </div>\n                <div className='flex flex-col gap-0.5'>\n                  <span className='text-muted-foreground text-xs'>\n                    Average a working day\n                  </span>\n                  <DurationFigure\n                    minutes={averageMinutes}\n                    className='text-lg leading-7 font-semibold'\n                  />\n                  <span className='text-muted-foreground text-xs'>\n                    {`Over ${workingDaysLabel}`}\n                  </span>\n                </div>\n              </div>\n              <DayBars\n                title={chartTitle}\n                bars={bars}\n                emptyState={\n                  isEmptyWeek && (\n                    <div className='bg-card flex flex-col items-center gap-3 rounded-lg px-3 py-2'>\n                      <p className='text-[13px] font-medium text-balance'>\n                        {`${scopeLabel} has no time in week ${week.number}`}\n                      </p>\n                      <Button\n                        variant='outline'\n                        size='sm'\n                        onClick={showEveryone}\n                      >\n                        Show everyone\n                      </Button>\n                    </div>\n                  )\n                }\n              />\n            </section>\n            <section\n              aria-label='Where the time went'\n              className={cn(REPORT_SURFACE, 'flex flex-col gap-3 p-5')}\n            >\n              <div className='flex items-baseline justify-between gap-3'>\n                <h2 className='text-sm font-medium'>Where the time went</h2>\n                <span className='text-muted-foreground text-xs tabular-nums'>\n                  {projectCountLabel}\n                </span>\n              </div>\n              <ProjectRanking\n                rows={ranking.rows}\n                other={ranking.other}\n                emptyLine={emptyLine}\n              />\n            </section>\n          </div>\n        )}\n      </div>\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/dashboards-02/index.tsx"
    },
    {
      "path": "registry/ndeko/blocks/dashboards/dashboards-02/day-bars.tsx",
      "content": "'use client';\n\nimport { motion, type Transition } from 'motion/react';\n\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport { cn } from '@/registry/ndeko/lib/utils';\n\nimport {\n  ChartBubble,\n  bubbleAlignOf,\n  columnCenterOf,\n  niceScale,\n  percentOf,\n  useActiveIndex,\n} from './chart-kit';\nimport { formatDuration, type DayBar } from './figures';\n\nconst PLOT_HEIGHT = 180;\n\nconst MAX_LINES = 4;\n\nconst EMPTY_SCALE_HOURS = 8;\n\nconst STUB_PX = 3;\n\nconst BUBBLE_GAP_PX = 8;\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\nfunction moveTransitionOf(shouldReduceMotion: boolean | null) {\n  if (shouldReduceMotion) {\n    return INSTANT;\n  }\n  return MOVE_TRANSITION;\n}\n\nfunction scaleHoursOf(bars: DayBar[]) {\n  const minutes = bars.map((bar) => bar.minutes);\n  const maxMinutes = Math.max(...minutes);\n  if (maxMinutes === 0) {\n    return EMPTY_SCALE_HOURS;\n  }\n  return maxMinutes / 60;\n}\n\nfunction filledRatioOf(bar: DayBar, topMinutes: number) {\n  if (bar.minutes === 0) {\n    return STUB_PX / PLOT_HEIGHT;\n  }\n  return bar.minutes / topMinutes;\n}\n\nfunction hiddenShareOf(ratio: number) {\n  const hidden = 1 - ratio;\n  return percentOf(hidden);\n}\n\nfunction tickTopOf(tickHours: number, topHours: number) {\n  const ratio = tickHours / topHours;\n  const fromBottom = ratio * PLOT_HEIGHT;\n  return PLOT_HEIGHT - fromBottom;\n}\n\nfunction bubbleTopOf(bar: DayBar, topMinutes: number) {\n  if (bar.isAhead) {\n    const middle = PLOT_HEIGHT / 2;\n    return middle - BUBBLE_GAP_PX;\n  }\n  const ratio = filledRatioOf(bar, topMinutes);\n  const barHeight = ratio * PLOT_HEIGHT;\n  const barTop = PLOT_HEIGHT - barHeight;\n  return barTop - BUBBLE_GAP_PX;\n}\n\nfunction bubbleValueOf(bar: DayBar) {\n  if (bar.isAhead) {\n    return 'Day ahead';\n  }\n  return formatDuration(bar.minutes);\n}\n\nfunction bubbleLabelOf(bar: DayBar) {\n  if (bar.isToday) {\n    return `${bar.label}, so far`;\n  }\n  return bar.label;\n}\n\nfunction tableValueOf(bar: DayBar) {\n  if (bar.isAhead) {\n    return 'Day ahead';\n  }\n  return formatDuration(bar.minutes);\n}\n\ntype DayBarsProps = {\n  title: string;\n  bars: DayBar[];\n  /** Shown over the empty plot, which keeps its hour lines and day slots. */\n  emptyState?: React.ReactNode;\n};\n\n/** Hours per day as rounded bars. Bars move to their new height when the data changes, never on mount. */\nexport function DayBars({ title, bars, emptyState }: DayBarsProps) {\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const transition = moveTransitionOf(shouldReduceMotion);\n  const count = bars.length;\n  const scaleHours = scaleHoursOf(bars);\n  const scale = niceScale(scaleHours, MAX_LINES);\n  const topMinutes = scale.top * 60;\n  const defaultIndex = defaultIndexOf(bars);\n  const reading = useActiveIndex(count, defaultIndex);\n  const shownBar = bars[reading.shownIndex];\n  const shownCenter = columnCenterOf(reading.shownIndex, count);\n  const shownLeft = percentOf(shownCenter);\n  const bubbleTop = bubbleTopOf(shownBar, topMinutes);\n  const bubbleAlign = bubbleAlignOf(reading.shownIndex, count);\n  const bubbleLabel = bubbleLabelOf(shownBar);\n  const bubbleValue = bubbleValueOf(shownBar);\n  const readingText = `${bubbleLabel}: ${bubbleValue}`;\n  const plotHeight = { height: PLOT_HEIGHT };\n\n  return (\n    <div className='flex flex-col'>\n      <div className='grid grid-cols-[2.5rem_minmax(0,1fr)]'>\n        <div aria-hidden='true' className='relative' style={plotHeight}>\n          {scale.ticks.map((tick) => {\n            const top = tickTopOf(tick, scale.top);\n\n            return (\n              <span\n                key={tick}\n                className='text-muted-foreground absolute right-2.5 -translate-y-1/2 text-[11px] tabular-nums'\n                style={{ top }}\n              >\n                {`${tick}h`}\n              </span>\n            );\n          })}\n        </div>\n        <div\n          role='group'\n          tabIndex={0}\n          aria-label={`${title}. Use the arrow keys to read each day.`}\n          className='focus-visible:ring-ring/25 relative touch-pan-y rounded-md outline-none focus-visible:ring-[3px]'\n          style={plotHeight}\n          {...reading.handlers}\n        >\n          {scale.ticks.map((tick) => {\n            const top = tickTopOf(tick, scale.top);\n\n            return (\n              <span\n                key={tick}\n                aria-hidden='true'\n                className='hairline-t border-border absolute inset-x-0'\n                style={{ top }}\n              />\n            );\n          })}\n          <div aria-hidden='true' className='absolute inset-0 flex'>\n            {bars.map((bar, index) => {\n              const isShown = index === reading.shownIndex;\n              const isDimmed = reading.isActive && !isShown;\n              const isEmptyDay = bar.minutes === 0;\n              const ratio = filledRatioOf(bar, topMinutes);\n              const offset = hiddenShareOf(ratio);\n\n              return (\n                <div key={bar.label} className='flex flex-1 justify-center'>\n                  {bar.isAhead && (\n                    <span className='hairline-border border-foreground/15 h-full w-[56%] max-w-10 rounded-md border-dashed' />\n                  )}\n                  {!bar.isAhead && (\n                    <span className='relative h-full w-[56%] max-w-10 overflow-hidden'>\n                      <motion.span\n                        initial={false}\n                        animate={{ y: offset }}\n                        transition={transition}\n                        className={cn(\n                          'absolute inset-0 rounded-t-[5px] transition-opacity duration-150',\n                          isEmptyDay && 'bg-foreground/15',\n                          !isEmptyDay && 'bg-primary',\n                          isDimmed && 'opacity-55'\n                        )}\n                      />\n                    </span>\n                  )}\n                </div>\n              );\n            })}\n          </div>\n          {emptyState && (\n            <div className='pointer-events-none absolute inset-0 flex items-center justify-center px-4 text-center *:pointer-events-auto'>\n              {emptyState}\n            </div>\n          )}\n          <ChartBubble\n            left={shownLeft}\n            top={bubbleTop}\n            align={bubbleAlign}\n            isVisible={reading.isActive}\n          >\n            <span className='text-muted-foreground'>{bubbleLabel}</span>\n            <span className='text-[13px] font-medium tabular-nums'>\n              {bubbleValue}\n            </span>\n          </ChartBubble>\n        </div>\n        <span aria-hidden='true' />\n        <div aria-hidden='true' className='mt-2 flex'>\n          {bars.map((bar) => (\n            <span\n              key={bar.label}\n              className={cn(\n                'text-muted-foreground flex-1 text-center text-[11px] whitespace-nowrap tabular-nums',\n                bar.isToday && 'text-foreground font-medium'\n              )}\n            >\n              {bar.axisLabel}\n            </span>\n          ))}\n        </div>\n      </div>\n      <span aria-live='polite' className='sr-only'>\n        {reading.isReadingByKeys && readingText}\n      </span>\n      <div className='sr-only'>\n        <table>\n          <caption>{title}</caption>\n          <thead>\n            <tr>\n              <th scope='col'>Day</th>\n              <th scope='col'>Tracked time</th>\n            </tr>\n          </thead>\n          <tbody>\n            {bars.map((bar) => (\n              <tr key={bar.label}>\n                <th scope='row'>{bubbleLabelOf(bar)}</th>\n                <td>{tableValueOf(bar)}</td>\n              </tr>\n            ))}\n          </tbody>\n        </table>\n      </div>\n    </div>\n  );\n}\n\n/** The bubble opens on today, or on the last day with time when the week is over. */\nfunction defaultIndexOf(bars: DayBar[]) {\n  const todayIndex = bars.findIndex((bar) => bar.isToday);\n  if (todayIndex >= 0) {\n    return todayIndex;\n  }\n  let lastWorkedIndex = 0;\n  bars.forEach((bar, index) => {\n    if (bar.minutes > 0) {\n      lastWorkedIndex = index;\n    }\n  });\n  return lastWorkedIndex;\n}\n",
      "type": "registry:component",
      "target": "components/blocks/dashboards-02/day-bars.tsx"
    },
    {
      "path": "registry/ndeko/blocks/dashboards/dashboards-02/project-ranking.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';\n\nimport { DurationFigure } from './duration-figure';\nimport type { OtherProjects, RankedProject } from './figures';\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 meterToneOf(rank: number) {\n  if (rank === 0) {\n    return 'bg-primary';\n  }\n  return 'bg-foreground/25';\n}\n\nfunction otherLabelOf(count: number) {\n  if (count === 1) {\n    return '1 other project';\n  }\n  return `${count} other projects`;\n}\n\nfunction percentAmountOf(share: number) {\n  const percent = share * 100;\n  return Math.round(percent);\n}\n\ntype ShareMeterProps = {\n  share: number;\n  tone: string;\n  transition: Transition;\n};\n\n/** A thin meter whose fill slides into place, so its rounded end never stretches. */\nfunction ShareMeter({ share, tone, transition }: ShareMeterProps) {\n  const hiddenShare = 1 - share;\n  const hiddenPercent = hiddenShare * 100;\n  const offset = `-${hiddenPercent}%`;\n\n  return (\n    <span className='bg-foreground/[0.06] relative block h-1 overflow-hidden rounded-full'>\n      <motion.span\n        initial={false}\n        animate={{ x: offset }}\n        transition={transition}\n        className={cn('absolute inset-0 rounded-full', tone)}\n      />\n    </span>\n  );\n}\n\ntype RankRowProps = {\n  label: string;\n  minutes: number;\n  share: number;\n  tone: string;\n  transition: Transition;\n  isMuted?: boolean;\n};\n\nfunction RankRow({\n  label,\n  minutes,\n  share,\n  tone,\n  transition,\n  isMuted,\n}: RankRowProps) {\n  const shareAmount = percentAmountOf(share);\n\n  return (\n    <div className='grid grid-cols-[2.5rem_minmax(0,1fr)_auto] items-baseline gap-x-2 gap-y-1.5 py-2'>\n      <MotionNumber\n        value={shareAmount}\n        suffix='%'\n        className='text-muted-foreground text-xs'\n      />\n      <span\n        className={cn(\n          'truncate text-[13px] font-medium',\n          isMuted && 'text-muted-foreground font-normal'\n        )}\n      >\n        {label}\n      </span>\n      <DurationFigure minutes={minutes} className='text-[13px]' />\n      <span className='col-start-2 col-end-4'>\n        <ShareMeter share={share} tone={tone} transition={transition} />\n      </span>\n    </div>\n  );\n}\n\ntype ProjectRankingProps = {\n  rows: RankedProject[];\n  other: OtherProjects | null;\n  emptyLine: string;\n};\n\n/** Shares read as text first: percentage, name, a thin meter, the time. Rows travel when the ranking changes. */\nexport function ProjectRanking({\n  rows,\n  other,\n  emptyLine,\n}: ProjectRankingProps) {\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const rowVariants = rowVariantsOf(shouldReduceMotion);\n  const moveTransition = moveTransitionOf(shouldReduceMotion);\n  const isEmpty = rows.length === 0;\n  const rowTransition = { layout: moveTransition };\n\n  return (\n    <div className='flex flex-col'>\n      {isEmpty && (\n        <p className='text-muted-foreground py-6 text-center text-[13px] text-balance'>\n          {emptyLine}\n        </p>\n      )}\n      <ol className='flex flex-col'>\n        <AnimatePresence initial={false}>\n          {rows.map((row, rank) => (\n            <motion.li\n              key={row.id}\n              layout='position'\n              variants={rowVariants}\n              initial='hidden'\n              animate='shown'\n              exit='hidden'\n              transition={rowTransition}\n            >\n              <RankRow\n                label={row.name}\n                minutes={row.minutes}\n                share={row.share}\n                tone={meterToneOf(rank)}\n                transition={moveTransition}\n              />\n            </motion.li>\n          ))}\n        </AnimatePresence>\n      </ol>\n      <AnimatePresence initial={false}>\n        {other && (\n          <motion.div\n            key='other'\n            layout='position'\n            variants={rowVariants}\n            initial='hidden'\n            animate='shown'\n            exit='hidden'\n            transition={rowTransition}\n          >\n            <RankRow\n              label={otherLabelOf(other.count)}\n              minutes={other.minutes}\n              share={other.share}\n              tone='bg-foreground/15'\n              transition={moveTransition}\n              isMuted\n            />\n          </motion.div>\n        )}\n      </AnimatePresence>\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/dashboards-02/project-ranking.tsx"
    },
    {
      "path": "registry/ndeko/blocks/dashboards/dashboards-02/duration-figure.tsx",
      "content": "import { MotionNumber } from '@/components/core/motion-number';\nimport { cn } from '@/registry/ndeko/lib/utils';\n\nimport { durationPartsOf, formatDuration } from './figures';\n\nconst TWO_DIGITS: Intl.NumberFormatOptions = { minimumIntegerDigits: 2 };\n\ntype DurationFigureProps = {\n  minutes: number;\n  className?: string;\n};\n\n/** Hours and minutes roll as two numbers, but a screen reader hears the duration once. */\nexport function DurationFigure({ minutes, className }: DurationFigureProps) {\n  const parts = durationPartsOf(minutes);\n  const text = formatDuration(minutes);\n\n  return (\n    <span\n      className={cn(\n        'inline-flex items-baseline whitespace-nowrap tabular-nums',\n        className\n      )}\n    >\n      <span className='sr-only'>{text}</span>\n      <span aria-hidden='true'>\n        <MotionNumber value={parts.hours} suffix='h' />{' '}\n        <MotionNumber value={parts.minutes} format={TWO_DIGITS} suffix='m' />\n      </span>\n    </span>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/dashboards-02/duration-figure.tsx"
    },
    {
      "path": "registry/ndeko/blocks/dashboards/dashboards-02/chart-kit.tsx",
      "content": "'use client';\n\nimport { useState } from 'react';\n\nimport { cn } from '@/registry/ndeko/lib/utils';\n\nconst NICE_FACTORS = [1, 2, 5, 10];\n\nexport function niceScale(maxValue: number, maxLines: number) {\n  const safeMax = Math.max(maxValue, 1);\n  const roughStep = safeMax / maxLines;\n  const logarithm = Math.log10(roughStep);\n  const exponent = Math.floor(logarithm);\n  const magnitude = 10 ** exponent;\n  const factor = NICE_FACTORS.find((candidate) => {\n    const candidateStep = candidate * magnitude;\n    return candidateStep >= roughStep;\n  });\n  const safeFactor = factor ?? 10;\n  const step = safeFactor * magnitude;\n  const lineCount = Math.ceil(safeMax / step);\n  const top = lineCount * step;\n  const tickCount = lineCount + 1;\n  const ticks = Array.from({ length: tickCount }, (_, index) => {\n    return index * step;\n  });\n  return { top, ticks };\n}\n\nexport function columnCenterOf(index: number, count: number) {\n  const center = index + 0.5;\n  return center / count;\n}\n\nexport function percentOf(share: number) {\n  const percent = share * 100;\n  return `${percent}%`;\n}\n\nfunction columnIndexAt(event: React.PointerEvent<HTMLElement>, count: number) {\n  const box = event.currentTarget.getBoundingClientRect();\n  const offset = event.clientX - box.left;\n  const share = offset / box.width;\n  const rawIndex = Math.floor(share * count);\n  const lastIndex = count - 1;\n  const clampedHigh = Math.min(rawIndex, lastIndex);\n  return Math.max(clampedHigh, 0);\n}\n\nfunction steppedIndexOf(key: string, current: number, count: number) {\n  const lastIndex = count - 1;\n  if (key === 'ArrowRight') {\n    const next = current + 1;\n    return Math.min(next, lastIndex);\n  }\n  if (key === 'ArrowLeft') {\n    const previous = current - 1;\n    return Math.max(previous, 0);\n  }\n  if (key === 'Home') {\n    return 0;\n  }\n  if (key === 'End') {\n    return lastIndex;\n  }\n  return null;\n}\n\n/**\n * One reading position for a chart: the pointer column wins while it is over the plot,\n * the arrow keys move it while the plot has keyboard focus.\n */\nexport function useActiveIndex(count: number, defaultIndex: number) {\n  const [pointerIndex, setPointerIndex] = useState<number | null>(null);\n  const [keyIndex, setKeyIndex] = useState<number | null>(null);\n  const [lastIndex, setLastIndex] = useState(defaultIndex);\n  const activeIndex = pointerIndex ?? keyIndex;\n  const isActive = activeIndex !== null;\n  const isReadingByKeys = keyIndex !== null;\n  const wantedIndex = activeIndex ?? lastIndex;\n  const lastColumn = count - 1;\n  const highestIndex = Math.max(lastColumn, 0);\n  const shownIndex = Math.min(wantedIndex, highestIndex);\n\n  function pointAt(event: React.PointerEvent<HTMLElement>) {\n    const index = columnIndexAt(event, count);\n    setPointerIndex(index);\n    setLastIndex(index);\n  }\n\n  function leave(event: React.PointerEvent<HTMLElement>) {\n    if (event.pointerType === 'mouse') {\n      setPointerIndex(null);\n    }\n  }\n\n  function focus(event: React.FocusEvent<HTMLElement>) {\n    const isKeyboardFocus = event.currentTarget.matches(':focus-visible');\n    if (isKeyboardFocus) {\n      setKeyIndex(lastIndex);\n    }\n  }\n\n  function blur() {\n    setKeyIndex(null);\n    setPointerIndex(null);\n  }\n\n  function step(event: React.KeyboardEvent<HTMLElement>) {\n    if (event.key === 'Escape') {\n      setKeyIndex(null);\n      return;\n    }\n    const current = keyIndex ?? lastIndex;\n    const next = steppedIndexOf(event.key, current, count);\n    if (next === null) {\n      return;\n    }\n    event.preventDefault();\n    setPointerIndex(null);\n    setKeyIndex(next);\n    setLastIndex(next);\n  }\n\n  const handlers = {\n    onPointerMove: pointAt,\n    onPointerDown: pointAt,\n    onPointerLeave: leave,\n    onFocus: focus,\n    onBlur: blur,\n    onKeyDown: step,\n  };\n\n  return { shownIndex, isActive, isReadingByKeys, handlers };\n}\n\ntype BubbleAlign = 'start' | 'center' | 'end';\n\nconst BUBBLE_ALIGN: Record<BubbleAlign, string> = {\n  start: '-translate-x-3',\n  center: '-translate-x-1/2',\n  end: '-translate-x-[calc(100%-0.75rem)]',\n};\n\n/** A point in the first or last third of the plot keeps its bubble inside the plot on a phone. */\nconst START_SHARE = 1 / 3;\nconst END_SHARE = 2 / 3;\n\nexport function bubbleAlignOf(index: number, count: number): BubbleAlign {\n  const lastIndex = Math.max(count - 1, 1);\n  const share = index / lastIndex;\n  if (share < START_SHARE) {\n    return 'start';\n  }\n  if (share > END_SHARE) {\n    return 'end';\n  }\n  return 'center';\n}\n\ntype ChartBubbleProps = {\n  left: string;\n  top: number;\n  align: BubbleAlign;\n  isVisible: boolean;\n  children: React.ReactNode;\n};\n\n/** The one value bubble of a chart. It stays mounted so it can fade out where it was. */\nexport function ChartBubble({\n  left,\n  top,\n  align,\n  isVisible,\n  children,\n}: ChartBubbleProps) {\n  const position = { left, top };\n\n  return (\n    <div\n      aria-hidden='true'\n      className='pointer-events-none absolute z-10 w-0'\n      style={position}\n    >\n      <div\n        className={cn(\n          'surface-raised flex w-max -translate-y-full flex-col gap-0.5 rounded-lg px-2.5 py-1.5 text-xs whitespace-nowrap',\n          'origin-bottom transition-[opacity,scale] duration-[125ms] ease-(--ease-out-strong)',\n          BUBBLE_ALIGN[align],\n          !isVisible && 'scale-[0.97] opacity-0'\n        )}\n      >\n        {children}\n      </div>\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/dashboards-02/chart-kit.tsx"
    },
    {
      "path": "registry/ndeko/blocks/dashboards/dashboards-02/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-02/report-frame.tsx"
    },
    {
      "path": "registry/ndeko/blocks/dashboards/dashboards-02/figures.ts",
      "content": "import {\n  MEMBERS,\n  MEMBER_WEEKS,\n  PROJECTS,\n  WEEKS,\n  type Member,\n  type MemberId,\n  type ProjectId,\n  type Week,\n  type WeekId,\n} from './data';\n\nexport type Scope = 'everyone' | MemberId;\n\nexport type WeekQuery = { weekId: WeekId; scope: Scope };\n\nexport type DayBar = {\n  axisLabel: string;\n  label: string;\n  minutes: number;\n  isToday: boolean;\n  isAhead: boolean;\n};\n\nexport type RankedProject = {\n  id: ProjectId;\n  name: string;\n  minutes: number;\n  share: number;\n};\n\nexport type OtherProjects = {\n  count: number;\n  minutes: number;\n  share: number;\n};\n\nconst RANKED_ROWS = 4;\n\nconst WORKING_DAYS = 5;\n\nexport function weekOf(weekId: WeekId) {\n  const week = WEEKS.find((candidate) => candidate.id === weekId);\n  if (week) {\n    return week;\n  }\n  return WEEKS[0];\n}\n\nexport function memberOf(scope: Scope): Member | null {\n  const member = MEMBERS.find((candidate) => candidate.id === scope);\n  if (member) {\n    return member;\n  }\n  return null;\n}\n\nfunction membersIn(scope: Scope): MemberId[] {\n  if (scope === 'everyone') {\n    return MEMBERS.map((member) => member.id);\n  }\n  return [scope];\n}\n\nfunction sumOf(values: number[]) {\n  return values.reduce((total, value) => total + value, 0);\n}\n\nfunction isAheadOf(week: Week, index: number) {\n  if (week.todayIndex === null) {\n    return false;\n  }\n  return index > week.todayIndex;\n}\n\nexport function dayBarsOf(query: WeekQuery): DayBar[] {\n  const week = weekOf(query.weekId);\n  const memberIds = membersIn(query.scope);\n  return week.days.map((day, index) => {\n    const dayMinutes = memberIds.map(\n      (memberId) => MEMBER_WEEKS[memberId][query.weekId].days[index]\n    );\n    const minutes = sumOf(dayMinutes);\n    const isToday = week.todayIndex === index;\n    const isAhead = isAheadOf(week, index);\n    return {\n      axisLabel: `${day.short} ${day.date}`,\n      label: `${day.name} ${day.date} ${day.month}`,\n      minutes,\n      isToday,\n      isAhead,\n    };\n  });\n}\n\nexport function totalMinutesOf(bars: DayBar[]) {\n  const minutes = bars.map((bar) => bar.minutes);\n  return sumOf(minutes);\n}\n\n/** Monday to Friday, counted up to today while the week is running. */\nexport function workingDaysSoFarOf(week: Week) {\n  if (week.todayIndex === null) {\n    return WORKING_DAYS;\n  }\n  const daysSoFar = week.todayIndex + 1;\n  return Math.min(daysSoFar, WORKING_DAYS);\n}\n\n/** Weekend time stays in the total but not in the average of a working day. */\nexport function averageWorkdayMinutesOf(bars: DayBar[], week: Week) {\n  const workingDays = workingDaysSoFarOf(week);\n  const weekdayBars = bars.slice(0, WORKING_DAYS);\n  const weekdayMinutes = totalMinutesOf(weekdayBars);\n  const average = weekdayMinutes / workingDays;\n  return Math.round(average);\n}\n\nfunction addMinutes(\n  totals: Map<ProjectId, number>,\n  projectId: ProjectId,\n  minutes: number\n) {\n  const current = totals.get(projectId) ?? 0;\n  const next = current + minutes;\n  totals.set(projectId, next);\n}\n\nfunction addMemberWeek(\n  totals: Map<ProjectId, number>,\n  memberId: MemberId,\n  weekId: WeekId\n) {\n  const memberWeek = MEMBER_WEEKS[memberId][weekId];\n  const weekTotal = sumOf(memberWeek.days);\n  const lastMixIndex = memberWeek.mix.length - 1;\n  let allocated = 0;\n  memberWeek.mix.forEach((entry, index) => {\n    const isLast = index === lastMixIndex;\n    if (isLast) {\n      const remainder = weekTotal - allocated;\n      addMinutes(totals, entry.projectId, remainder);\n      return;\n    }\n    const rawMinutes = weekTotal * entry.share;\n    const minutes = Math.round(rawMinutes);\n    allocated += minutes;\n    addMinutes(totals, entry.projectId, minutes);\n  });\n}\n\nfunction projectNameOf(projectId: ProjectId) {\n  const project = PROJECTS.find((candidate) => candidate.id === projectId);\n  if (project) {\n    return project.name;\n  }\n  return projectId;\n}\n\nfunction shareOf(minutes: number, totalMinutes: number) {\n  if (totalMinutes === 0) {\n    return 0;\n  }\n  return minutes / totalMinutes;\n}\n\nfunction byMinutesThenName(first: RankedProject, second: RankedProject) {\n  const difference = second.minutes - first.minutes;\n  if (difference !== 0) {\n    return difference;\n  }\n  return first.name.localeCompare(second.name);\n}\n\nexport function rankingOf(query: WeekQuery) {\n  const totals = new Map<ProjectId, number>();\n  const memberIds = membersIn(query.scope);\n  memberIds.forEach((memberId) =>\n    addMemberWeek(totals, memberId, query.weekId)\n  );\n  const allMinutes = Array.from(totals.values());\n  const totalMinutes = sumOf(allMinutes);\n  const entries = Array.from(totals.entries());\n  const projects = entries.map(([projectId, minutes]) => ({\n    id: projectId,\n    name: projectNameOf(projectId),\n    minutes,\n    share: shareOf(minutes, totalMinutes),\n  }));\n  const sorted = [...projects].sort(byMinutesThenName);\n  const rows = sorted.slice(0, RANKED_ROWS);\n  const rest = sorted.slice(RANKED_ROWS);\n  const restEach = rest.map((project) => project.minutes);\n  const restMinutes = sumOf(restEach);\n  const other = otherOf(rest.length, restMinutes, totalMinutes);\n  return { rows, other, projectCount: sorted.length };\n}\n\nfunction otherOf(\n  count: number,\n  minutes: number,\n  totalMinutes: number\n): OtherProjects | null {\n  if (count === 0) {\n    return null;\n  }\n  const share = shareOf(minutes, totalMinutes);\n  return { count, minutes, share };\n}\n\nexport function durationPartsOf(totalMinutes: number) {\n  const rawHours = totalMinutes / 60;\n  const hours = Math.floor(rawHours);\n  const minutes = totalMinutes % 60;\n  return { hours, minutes };\n}\n\nexport function formatDuration(totalMinutes: number) {\n  const { hours, minutes } = durationPartsOf(totalMinutes);\n  const paddedMinutes = String(minutes).padStart(2, '0');\n  return `${hours}h ${paddedMinutes}m`;\n}\n\nexport function csvRowsOf(bars: DayBar[]) {\n  const header = ['Day', 'Tracked time', 'Minutes'];\n  const rows = bars.map((bar) => {\n    const duration = formatDuration(bar.minutes);\n    const minutes = String(bar.minutes);\n    return [bar.label, duration, minutes];\n  });\n  return [header, ...rows];\n}\n",
      "type": "registry:component",
      "target": "components/blocks/dashboards-02/figures.ts"
    },
    {
      "path": "registry/ndeko/blocks/dashboards/dashboards-02/data.ts",
      "content": "export type WeekId = 'w43' | 'w44' | 'w45';\n\nexport type MemberId = 'amara' | 'lucas' | 'priya' | 'mateo' | 'jonas';\n\nexport type ProjectId =\n  'harbor' | 'billing' | 'design' | 'support' | 'research' | 'hiring';\n\nexport type WeekDay = {\n  name: string;\n  short: string;\n  date: number;\n  month: string;\n};\n\nexport type Week = {\n  id: WeekId;\n  number: number;\n  rangeLabel: string;\n  days: WeekDay[];\n  /** Index of today in `days`, or null when the week is over. Days after it are ahead. */\n  todayIndex: number | null;\n};\n\nexport type Member = {\n  id: MemberId;\n  name: string;\n};\n\nexport type Project = { id: ProjectId; name: string };\n\nexport type ProjectShare = { projectId: ProjectId; share: number };\n\nexport type MemberWeek = {\n  /** Minutes tracked from Monday to Sunday. */\n  days: number[];\n  mix: ProjectShare[];\n};\n\nexport const TEAM_NAME = 'Product team';\n\nconst DAY_NAMES = [\n  { name: 'Monday', short: 'Mon' },\n  { name: 'Tuesday', short: 'Tue' },\n  { name: 'Wednesday', short: 'Wed' },\n  { name: 'Thursday', short: 'Thu' },\n  { name: 'Friday', short: 'Fri' },\n  { name: 'Saturday', short: 'Sat' },\n  { name: 'Sunday', short: 'Sun' },\n];\n\n/** The seven days of a week that stays inside one month. */\nfunction weekDays(month: string, firstDate: number): WeekDay[] {\n  return DAY_NAMES.map((day, index) => {\n    const date = firstDate + index;\n    return { name: day.name, short: day.short, date, month };\n  });\n}\n\nexport const WEEKS: Week[] = [\n  {\n    id: 'w43',\n    number: 43,\n    rangeLabel: '19 to 25 October 2026',\n    days: weekDays('October', 19),\n    todayIndex: null,\n  },\n  {\n    id: 'w44',\n    number: 44,\n    rangeLabel: '26 October to 1 November 2026',\n    days: [\n      { name: 'Monday', short: 'Mon', date: 26, month: 'October' },\n      { name: 'Tuesday', short: 'Tue', date: 27, month: 'October' },\n      { name: 'Wednesday', short: 'Wed', date: 28, month: 'October' },\n      { name: 'Thursday', short: 'Thu', date: 29, month: 'October' },\n      { name: 'Friday', short: 'Fri', date: 30, month: 'October' },\n      { name: 'Saturday', short: 'Sat', date: 31, month: 'October' },\n      { name: 'Sunday', short: 'Sun', date: 1, month: 'November' },\n    ],\n    todayIndex: null,\n  },\n  {\n    id: 'w45',\n    number: 45,\n    rangeLabel: '2 to 8 November 2026',\n    days: weekDays('November', 2),\n    todayIndex: 3,\n  },\n];\n\nexport const MEMBERS: Member[] = [\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: 'jonas', name: 'Jonas Weber' },\n];\n\nexport const PROJECTS: Project[] = [\n  { id: 'harbor', name: 'Harbor mobile app' },\n  { id: 'billing', name: 'Billing revamp' },\n  { id: 'design', name: 'Design system' },\n  { id: 'support', name: 'Support rotation' },\n  { id: 'research', name: 'Customer interviews' },\n  { id: 'hiring', name: 'Hiring loop' },\n];\n\nexport const MEMBER_WEEKS: Record<MemberId, Record<WeekId, MemberWeek>> = {\n  amara: {\n    w43: {\n      days: [450, 480, 420, 510, 390, 0, 0],\n      mix: [\n        { projectId: 'harbor', share: 0.45 },\n        { projectId: 'design', share: 0.35 },\n        { projectId: 'research', share: 0.2 },\n      ],\n    },\n    w44: {\n      days: [465, 500, 480, 455, 420, 0, 0],\n      mix: [\n        { projectId: 'harbor', share: 0.5 },\n        { projectId: 'design', share: 0.3 },\n        { projectId: 'research', share: 0.2 },\n      ],\n    },\n    w45: {\n      days: [470, 455, 490, 245, 0, 0, 0],\n      mix: [\n        { projectId: 'harbor', share: 0.55 },\n        { projectId: 'design', share: 0.3 },\n        { projectId: 'hiring', share: 0.15 },\n      ],\n    },\n  },\n  lucas: {\n    w43: {\n      days: [480, 465, 500, 440, 360, 60, 0],\n      mix: [\n        { projectId: 'billing', share: 0.4 },\n        { projectId: 'harbor', share: 0.3 },\n        { projectId: 'hiring', share: 0.2 },\n        { projectId: 'support', share: 0.1 },\n      ],\n    },\n    w44: {\n      days: [500, 470, 485, 510, 390, 0, 0],\n      mix: [\n        { projectId: 'billing', share: 0.45 },\n        { projectId: 'harbor', share: 0.3 },\n        { projectId: 'hiring', share: 0.15 },\n        { projectId: 'support', share: 0.1 },\n      ],\n    },\n    w45: {\n      days: [485, 500, 470, 260, 0, 0, 0],\n      mix: [\n        { projectId: 'billing', share: 0.5 },\n        { projectId: 'harbor', share: 0.25 },\n        { projectId: 'hiring', share: 0.25 },\n      ],\n    },\n  },\n  priya: {\n    w43: {\n      days: [420, 450, 435, 480, 405, 0, 0],\n      mix: [\n        { projectId: 'harbor', share: 0.6 },\n        { projectId: 'design', share: 0.4 },\n      ],\n    },\n    w44: {\n      days: [440, 470, 455, 0, 0, 0, 0],\n      mix: [\n        { projectId: 'harbor', share: 0.7 },\n        { projectId: 'design', share: 0.3 },\n      ],\n    },\n    w45: {\n      days: [450, 465, 480, 230, 0, 0, 0],\n      mix: [\n        { projectId: 'harbor', share: 0.65 },\n        { projectId: 'design', share: 0.25 },\n        { projectId: 'support', share: 0.1 },\n      ],\n    },\n  },\n  mateo: {\n    w43: {\n      days: [390, 410, 0, 455, 430, 0, 0],\n      mix: [\n        { projectId: 'billing', share: 0.7 },\n        { projectId: 'support', share: 0.3 },\n      ],\n    },\n    w44: {\n      days: [420, 445, 430, 460, 410, 90, 0],\n      mix: [\n        { projectId: 'billing', share: 0.6 },\n        { projectId: 'support', share: 0.25 },\n        { projectId: 'harbor', share: 0.15 },\n      ],\n    },\n    w45: {\n      days: [430, 410, 445, 215, 0, 0, 0],\n      mix: [\n        { projectId: 'billing', share: 0.75 },\n        { projectId: 'support', share: 0.25 },\n      ],\n    },\n  },\n  jonas: {\n    w43: {\n      days: [400, 420, 410, 380, 300, 0, 0],\n      mix: [\n        { projectId: 'harbor', share: 0.5 },\n        { projectId: 'billing', share: 0.3 },\n        { projectId: 'support', share: 0.2 },\n      ],\n    },\n    w44: {\n      days: [380, 410, 395, 420, 280, 0, 0],\n      mix: [\n        { projectId: 'harbor', share: 0.55 },\n        { projectId: 'billing', share: 0.35 },\n        { projectId: 'support', share: 0.1 },\n      ],\n    },\n    w45: {\n      days: [0, 0, 0, 0, 0, 0, 0],\n      mix: [],\n    },\n  },\n};\n",
      "type": "registry:component",
      "target": "components/blocks/dashboards-02/data.ts"
    }
  ],
  "categories": [
    "blocks",
    "dashboards"
  ],
  "type": "registry:block"
}