{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "task-detail-03",
  "title": "Task with work tabs",
  "description": "A task page whose sub-tasks, comments and activity share one card behind a segmented switch, each count rolling as you check, add and comment",
  "dependencies": [
    "date-fns",
    "motion"
  ],
  "registryDependencies": [
    "https://ui.ndekocode.dev/r/animated-size.json",
    "https://ui.ndekocode.dev/r/avatar.json",
    "https://ui.ndekocode.dev/r/button.json",
    "https://ui.ndekocode.dev/r/checkbox.json",
    "https://ui.ndekocode.dev/r/icons.json",
    "https://ui.ndekocode.dev/r/kbd.json",
    "https://ui.ndekocode.dev/r/tabs.json",
    "https://ui.ndekocode.dev/r/textarea.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/task-detail/task-detail-03/index.tsx",
      "content": "'use client';\n\nimport { AnimatePresence, motion } from 'motion/react';\nimport { useState } from 'react';\n\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport { ChevronRightIcon } from '@/registry/ndeko/lib/icons';\nimport { AnimatedSize } from '@/registry/ndeko/ui/animated-size';\nimport { Tabs, TabsList, TabsPanel, TabsTab } from '@/registry/ndeko/ui/tabs';\n\nimport { ActivityPanel } from './activity-panel';\nimport { CommentComposer } from './comment-composer';\nimport { CommentPanel } from './comment-panel';\nimport { COMMENTS, EVENTS, SUBTASKS, TASK } from './data';\nimport { heightPresenceOf, RollingCount } from './motion-parts';\nimport { SubtaskPanel } from './subtask-panel';\nimport {\n  PeopleStack,\n  ProgressRing,\n  STATUS_NAME,\n  StatusGlyph,\n} from './work-glyphs';\nimport {\n  addedSubtask,\n  doneCountOf,\n  dueLabelOf,\n  personOf,\n  postedComment,\n  toggledSubtask,\n  type WorkState,\n} from './work-model';\n\ntype WorkTab = 'subtasks' | 'comments' | 'activity';\n\nconst FIRST_STATE: WorkState = {\n  subtasks: SUBTASKS,\n  comments: COMMENTS,\n  events: EVENTS,\n};\n\nfunction isWorkTab(value: unknown): value is WorkTab {\n  const isSubtasks = value === 'subtasks';\n  const isComments = value === 'comments';\n  const isActivity = value === 'activity';\n  return isSubtasks || isComments || isActivity;\n}\n\nfunction TaskHeader() {\n  const people = TASK.assigneeIds.map(personOf);\n  const firstNames = people.map((person) => person.firstName);\n  const assigneeNames = firstNames.join(' and ');\n  return (\n    <header>\n      <nav\n        aria-label='Breadcrumb'\n        className='text-muted-foreground flex items-center gap-1 text-xs'\n      >\n        <span>{TASK.project}</span>\n        <ChevronRightIcon className='size-3' />\n        <span className='tabular-nums'>{TASK.key}</span>\n      </nav>\n      <h1 className='mt-2 text-xl font-semibold text-balance sm:text-2xl'>\n        {TASK.title}\n      </h1>\n      <div className='text-muted-foreground mt-3 flex flex-wrap items-center gap-x-4 gap-y-2 text-[13px]'>\n        <span className='text-foreground inline-flex items-center gap-1.5'>\n          <StatusGlyph status={TASK.status} />\n          {STATUS_NAME[TASK.status]}\n        </span>\n        <span className='inline-flex items-center gap-2'>\n          <PeopleStack people={people} />\n          {assigneeNames}\n        </span>\n        <span className='tabular-nums'>{dueLabelOf(TASK.due)}</span>\n      </div>\n      <p className='mt-4 text-[13px] leading-relaxed'>{TASK.description}</p>\n    </header>\n  );\n}\n\nexport default function TaskDetail03() {\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const [work, setWork] = useState<WorkState>(FIRST_STATE);\n  const [tab, setTab] = useState<WorkTab>('subtasks');\n  const doneCount = doneCountOf(work.subtasks);\n  const total = work.subtasks.length;\n  const isCommentsTab = tab === 'comments';\n\n  function change(value: unknown) {\n    if (isWorkTab(value)) {\n      setTab(value);\n    }\n  }\n\n  return (\n    <div className='bg-background text-foreground min-h-svh px-4 py-6 sm:px-8 sm:py-10'>\n      <div className='mx-auto max-w-2xl'>\n        <TaskHeader />\n        <div className='bg-card hairline-ring ring-border mt-6 rounded-xl shadow-[0_1px_2px_rgb(0_0_0/0.04)]'>\n          <Tabs value={tab} onValueChange={change} className='gap-0'>\n            <div className='px-3 pt-3 sm:px-4 sm:pt-4'>\n              <TabsList\n                variant='segmented'\n                aria-label='Work on this task'\n                className='max-w-full'\n              >\n                <TabsTab value='subtasks'>\n                  <span className='hidden sm:inline-flex'>\n                    <ProgressRing done={doneCount} total={total} />\n                  </span>\n                  Sub-tasks\n                  <span className='text-muted-foreground flex text-xs tabular-nums'>\n                    <RollingCount value={doneCount} />/\n                    <RollingCount value={total} />\n                  </span>\n                </TabsTab>\n                <TabsTab value='comments'>\n                  Comments\n                  <RollingCount\n                    value={work.comments.length}\n                    className='text-muted-foreground text-xs'\n                  />\n                </TabsTab>\n                <TabsTab value='activity'>\n                  Activity\n                  <RollingCount\n                    value={work.events.length}\n                    className='text-muted-foreground text-xs'\n                  />\n                </TabsTab>\n              </TabsList>\n            </div>\n            <AnimatedSize>\n              <div className='px-3 py-3 sm:px-4'>\n                <TabsPanel value='subtasks'>\n                  <SubtaskPanel\n                    subtasks={work.subtasks}\n                    onToggle={(subtaskId) =>\n                      setWork((current) => toggledSubtask(current, subtaskId))\n                    }\n                    onAdd={(title) =>\n                      setWork((current) => addedSubtask(current, title))\n                    }\n                  />\n                </TabsPanel>\n                <TabsPanel value='comments'>\n                  <CommentPanel comments={work.comments} />\n                </TabsPanel>\n                <TabsPanel value='activity'>\n                  <ActivityPanel events={work.events} />\n                </TabsPanel>\n              </div>\n            </AnimatedSize>\n            <AnimatePresence initial={false}>\n              {isCommentsTab && (\n                <motion.div\n                  key='composer'\n                  {...heightPresenceOf(shouldReduceMotion)}\n                  className='overflow-hidden'\n                >\n                  <CommentComposer\n                    onSubmit={(body) =>\n                      setWork((current) => postedComment(current, body))\n                    }\n                    className='px-3 pb-3 sm:px-4 sm:pb-4'\n                  />\n                </motion.div>\n              )}\n            </AnimatePresence>\n          </Tabs>\n        </div>\n      </div>\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/task-detail-03/index.tsx"
    },
    {
      "path": "registry/ndeko/blocks/task-detail/task-detail-03/subtask-panel.tsx",
      "content": "'use client';\n\nimport { AnimatePresence, motion } from 'motion/react';\nimport { useState } from 'react';\n\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport { PlusIcon } from '@/registry/ndeko/lib/icons';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { Checkbox } from '@/registry/ndeko/ui/checkbox';\nimport { Kbd } from '@/registry/ndeko/ui/kbd';\n\nimport type { Subtask } from './data';\nimport { heightPresenceOf } from './motion-parts';\nimport { PersonAvatar, StrikeTitle } from './work-glyphs';\nimport { keyOf, personOf } from './work-model';\n\nfunction SubtaskRow({\n  subtask,\n  onToggle,\n}: {\n  subtask: Subtask;\n  onToggle: () => void;\n}) {\n  const shouldReduceMotion = usePrefersReducedMotion();\n\n  return (\n    <motion.li\n      {...heightPresenceOf(shouldReduceMotion)}\n      className='overflow-hidden'\n    >\n      <label className='hover:bg-foreground/[0.03] flex h-9 cursor-pointer items-center gap-3 rounded-lg px-2'>\n        <Checkbox checked={subtask.isDone} onCheckedChange={onToggle} />\n        <span className='text-muted-foreground hidden w-16 shrink-0 text-xs tabular-nums sm:inline'>\n          {keyOf(subtask.number)}\n        </span>\n        <StrikeTitle\n          title={subtask.title}\n          isDone={subtask.isDone}\n          className='flex-1'\n        />\n        {subtask.assigneeId && (\n          <PersonAvatar\n            person={personOf(subtask.assigneeId)}\n            className='size-5 text-[9px]'\n          />\n        )}\n      </label>\n    </motion.li>\n  );\n}\n\ntype SubtaskPanelProps = {\n  subtasks: Subtask[];\n  onToggle: (subtaskId: string) => void;\n  onAdd: (title: string) => void;\n};\n\nexport function SubtaskPanel({ subtasks, onToggle, onAdd }: SubtaskPanelProps) {\n  const [title, setTitle] = useState('');\n  const trimmed = title.trim();\n  const canAdd = trimmed.length > 0;\n\n  function add(event: React.FormEvent<HTMLFormElement>) {\n    event.preventDefault();\n    if (!canAdd) {\n      return;\n    }\n    onAdd(trimmed);\n    setTitle('');\n  }\n\n  function handleKeyDown(event: React.KeyboardEvent<HTMLInputElement>) {\n    if (event.key === 'Escape') {\n      setTitle('');\n    }\n  }\n\n  return (\n    <div className='flex flex-col gap-1'>\n      <ul>\n        <AnimatePresence initial={false}>\n          {subtasks.map((subtask) => (\n            <SubtaskRow\n              key={subtask.id}\n              subtask={subtask}\n              onToggle={() => onToggle(subtask.id)}\n            />\n          ))}\n        </AnimatePresence>\n      </ul>\n      <form\n        onSubmit={add}\n        className='hairline-border border-foreground/20 focus-within:border-foreground/35 flex h-9 items-center gap-3 rounded-lg border-dashed ps-2 pe-1.5 transition-colors'\n      >\n        <PlusIcon className='text-muted-foreground size-4 shrink-0' />\n        <input\n          value={title}\n          onChange={(event) => setTitle(event.target.value)}\n          onKeyDown={handleKeyDown}\n          aria-label='New sub-task title'\n          placeholder='Add a sub-task'\n          className='placeholder:text-muted-foreground/75 h-8 min-w-0 flex-1 bg-transparent text-base outline-none md:text-[13px]'\n        />\n        <Kbd\n          aria-hidden='true'\n          className={cn(\n            'transition-opacity duration-150',\n            !canAdd && 'opacity-0'\n          )}\n        >\n          Enter\n        </Kbd>\n        <button type='submit' className='sr-only'>\n          Add sub-task\n        </button>\n      </form>\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/task-detail-03/subtask-panel.tsx"
    },
    {
      "path": "registry/ndeko/blocks/task-detail/task-detail-03/comment-panel.tsx",
      "content": "'use client';\n\nimport { AnimatePresence, motion } from 'motion/react';\n\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\n\nimport type { TaskComment } from './data';\nimport { heightPresenceOf } from './motion-parts';\nimport { CommentText, PersonAvatar } from './work-glyphs';\nimport { actorNameOf, personOf, relativeTimeOf } from './work-model';\n\nfunction CommentRow({ comment }: { comment: TaskComment }) {\n  const shouldReduceMotion = usePrefersReducedMotion();\n\n  return (\n    <motion.li\n      {...heightPresenceOf(shouldReduceMotion)}\n      className='overflow-hidden'\n    >\n      <div className='flex gap-3 py-2'>\n        <PersonAvatar\n          person={personOf(comment.authorId)}\n          className='size-7 text-[10px]'\n        />\n        <div className='min-w-0 flex-1'>\n          <p className='flex min-h-7 items-center gap-1.5 text-[13px]'>\n            <span className='truncate font-medium'>\n              {actorNameOf(comment.authorId)}\n            </span>\n            <span aria-hidden='true' className='text-muted-foreground'>\n              ·\n            </span>\n            <time\n              dateTime={comment.at}\n              className='text-muted-foreground shrink-0 text-xs tabular-nums'\n            >\n              {relativeTimeOf(comment.at)}\n            </time>\n          </p>\n          <CommentText body={comment.body} />\n        </div>\n      </div>\n    </motion.li>\n  );\n}\n\nexport function CommentPanel({ comments }: { comments: TaskComment[] }) {\n  const isEmpty = comments.length === 0;\n\n  return (\n    <div>\n      {isEmpty && (\n        <p className='text-muted-foreground py-4 text-center text-[13px]'>\n          No comments yet. Write the first one below\n        </p>\n      )}\n      <ul>\n        <AnimatePresence initial={false}>\n          {comments.map((comment) => (\n            <CommentRow key={comment.id} comment={comment} />\n          ))}\n        </AnimatePresence>\n      </ul>\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/task-detail-03/comment-panel.tsx"
    },
    {
      "path": "registry/ndeko/blocks/task-detail/task-detail-03/activity-panel.tsx",
      "content": "import type { WorkEvent } from './data';\nimport { EventGlyph } from './work-glyphs';\nimport { actorNameOf, clockOf, eventDaysOf } from './work-model';\n\nfunction EventRow({ event }: { event: WorkEvent }) {\n  return (\n    <li className='flex gap-3 py-1.5'>\n      <EventGlyph kind={event.kind} />\n      <p className='text-muted-foreground min-w-0 flex-1 pt-0.5 text-[13px] leading-5'>\n        <span className='text-foreground font-medium'>\n          {actorNameOf(event.actorId)}\n        </span>{' '}\n        {event.text}\n        <time dateTime={event.at} className='ms-2 text-xs tabular-nums'>\n          {clockOf(event.at)}\n        </time>\n      </p>\n    </li>\n  );\n}\n\nexport function ActivityPanel({ events }: { events: WorkEvent[] }) {\n  const days = eventDaysOf(events);\n\n  return (\n    <div className='flex flex-col gap-2'>\n      {days.map((day) => (\n        <section key={day.key} aria-label={day.label}>\n          <h4 className='text-muted-foreground pb-1 text-xs font-medium'>\n            {day.label}\n          </h4>\n          <ul>\n            {day.events.map((event) => (\n              <EventRow key={event.id} event={event} />\n            ))}\n          </ul>\n        </section>\n      ))}\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/task-detail-03/activity-panel.tsx"
    },
    {
      "path": "registry/ndeko/blocks/task-detail/task-detail-03/comment-composer.tsx",
      "content": "'use client';\n\nimport { useState } from 'react';\n\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { Button } from '@/registry/ndeko/ui/button';\nimport { Textarea } from '@/registry/ndeko/ui/textarea';\n\nimport { PersonAvatar } from './work-glyphs';\nimport { currentUser } from './work-model';\n\ntype CommentComposerProps = {\n  onSubmit: (body: string) => void;\n  placeholder?: string;\n  className?: string;\n};\n\nfunction isSendKey(event: React.KeyboardEvent<HTMLTextAreaElement>) {\n  const isCommand = event.metaKey || event.ctrlKey;\n  return isCommand && event.key === 'Enter';\n}\n\nexport function CommentComposer({\n  onSubmit,\n  placeholder = 'Leave a comment',\n  className,\n}: CommentComposerProps) {\n  const [body, setBody] = useState('');\n  const me = currentUser();\n  const trimmed = body.trim();\n  const canSend = trimmed.length > 0;\n\n  function submit() {\n    if (!canSend) {\n      return;\n    }\n    onSubmit(trimmed);\n    setBody('');\n  }\n\n  function handleSubmit(event: React.FormEvent<HTMLFormElement>) {\n    event.preventDefault();\n    submit();\n  }\n\n  function handleKeyDown(event: React.KeyboardEvent<HTMLTextAreaElement>) {\n    if (isSendKey(event)) {\n      event.preventDefault();\n      submit();\n      return;\n    }\n    if (event.key === 'Escape') {\n      event.stopPropagation();\n      event.currentTarget.blur();\n    }\n  }\n\n  return (\n    <form\n      onSubmit={handleSubmit}\n      className={cn('flex items-start gap-3', className)}\n    >\n      <PersonAvatar person={me} className='mt-1 size-7 text-[10px]' />\n      <div className='relative min-w-0 flex-1'>\n        <Textarea\n          value={body}\n          onChange={(event) => setBody(event.target.value)}\n          onKeyDown={handleKeyDown}\n          rows={1}\n          aria-label={`Comment as ${me.name}`}\n          placeholder={placeholder}\n          className='min-h-9 py-2 pe-24'\n        />\n        <Button\n          type='submit'\n          size='sm'\n          disabled={!canSend}\n          className='absolute end-1 bottom-1'\n        >\n          Comment\n        </Button>\n      </div>\n    </form>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/task-detail-03/comment-composer.tsx"
    },
    {
      "path": "registry/ndeko/blocks/task-detail/task-detail-03/work-glyphs.tsx",
      "content": "import {\n  CheckIcon,\n  CircleDashedIcon,\n  ClockIcon,\n  ListTreeIcon,\n  MessageCircleIcon,\n  PlusIcon,\n  UserIcon,\n  type Icon,\n} from '@/registry/ndeko/lib/icons';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { Avatar } from '@/registry/ndeko/ui/avatar';\n\nimport type { Person, StatusId, WorkEventKind } from './data';\nimport { segmentsOf } from './work-model';\n\nconst STATUS_COLOR: Record<StatusId, string> = {\n  backlog: 'var(--muted-foreground)',\n  todo: 'var(--muted-foreground)',\n  in_progress: 'var(--warning)',\n  in_review: 'var(--primary)',\n  done: 'var(--success)',\n};\n\nexport const STATUS_NAME: Record<StatusId, string> = {\n  backlog: 'Backlog',\n  todo: 'Todo',\n  in_progress: 'In progress',\n  in_review: 'In review',\n  done: 'Done',\n};\n\nconst PIE_RADIUS = 2;\n\nconst PIE_CIRCUMFERENCE = 2 * Math.PI * PIE_RADIUS;\n\nfunction StartedShape({ share }: { share: number }) {\n  const filled = share * PIE_CIRCUMFERENCE;\n  return (\n    <>\n      <circle cx='7' cy='7' r='6' stroke='currentColor' strokeWidth='1.5' />\n      <circle\n        cx='7'\n        cy='7'\n        r={PIE_RADIUS}\n        stroke='currentColor'\n        strokeWidth={PIE_RADIUS * 2}\n        strokeDasharray={`${filled} ${PIE_CIRCUMFERENCE}`}\n        transform='rotate(-90 7 7)'\n      />\n    </>\n  );\n}\n\nfunction statusShapeOf(status: StatusId) {\n  if (status === 'backlog') {\n    return (\n      <circle\n        cx='7'\n        cy='7'\n        r='6'\n        stroke='currentColor'\n        strokeWidth='1.5'\n        strokeDasharray='1.6 1.9'\n      />\n    );\n  }\n  if (status === 'todo') {\n    return (\n      <circle cx='7' cy='7' r='6' stroke='currentColor' strokeWidth='1.5' />\n    );\n  }\n  if (status === 'in_progress') {\n    return <StartedShape share={0.5} />;\n  }\n  if (status === 'in_review') {\n    return <StartedShape share={0.75} />;\n  }\n  return (\n    <>\n      <circle cx='7' cy='7' r='7' fill='currentColor' />\n      <path\n        d='M4.4 7.2 6.2 9l3.4-3.8'\n        stroke='var(--card)'\n        strokeWidth='1.6'\n        strokeLinecap='round'\n        strokeLinejoin='round'\n      />\n    </>\n  );\n}\n\nexport function StatusGlyph({\n  status,\n  className,\n}: {\n  status: StatusId;\n  className?: string;\n}) {\n  const glyphStyle = { color: STATUS_COLOR[status] } as React.CSSProperties;\n  return (\n    <svg\n      viewBox='0 0 14 14'\n      fill='none'\n      aria-hidden='true'\n      style={glyphStyle}\n      className={cn('size-3.5 shrink-0', className)}\n    >\n      {statusShapeOf(status)}\n    </svg>\n  );\n}\n\nexport function PersonAvatar({\n  person,\n  className,\n}: {\n  person: Person;\n  className?: string;\n}) {\n  return (\n    <Avatar\n      className={cn('size-6 text-[10px]', className)}\n      seed={person.name}\n    />\n  );\n}\n\nexport function PeopleStack({\n  people,\n  ringClassName = 'ring-background',\n}: {\n  people: Person[];\n  ringClassName?: string;\n}) {\n  return (\n    <span className='flex items-center -space-x-1.5'>\n      {people.map((person) => (\n        <PersonAvatar\n          key={person.id}\n          person={person}\n          className={cn('size-5 text-[9px] ring-2', ringClassName)}\n        />\n      ))}\n    </span>\n  );\n}\n\nconst RING_RADIUS = 6.5;\n\nconst RING_LENGTH = 2 * Math.PI * RING_RADIUS;\n\nfunction shareOf(done: number, total: number) {\n  if (total === 0) {\n    return 0;\n  }\n  return done / total;\n}\n\nexport function ProgressRing({ done, total }: { done: number; total: number }) {\n  const share = shareOf(done, total);\n  const isComplete = total > 0 && done === total;\n  const dashOffset = RING_LENGTH * (1 - share);\n  return (\n    <svg viewBox='0 0 16 16' aria-hidden='true' className='size-4 -rotate-90'>\n      <circle\n        cx='8'\n        cy='8'\n        r={RING_RADIUS}\n        fill='none'\n        strokeWidth='2'\n        className='stroke-foreground/10'\n      />\n      <circle\n        cx='8'\n        cy='8'\n        r={RING_RADIUS}\n        fill='none'\n        strokeWidth='2'\n        strokeLinecap='round'\n        strokeDasharray={RING_LENGTH}\n        strokeDashoffset={dashOffset}\n        className={cn(\n          'stroke-primary transition-[stroke-dashoffset,stroke] duration-300 ease-(--ease-out-strong)',\n          isComplete && 'stroke-success'\n        )}\n      />\n    </svg>\n  );\n}\n\n/** A title struck from left to right when its sub-task is done. */\nexport function StrikeTitle({\n  title,\n  isDone,\n  className,\n}: {\n  title: string;\n  isDone: boolean;\n  className?: string;\n}) {\n  return (\n    <span\n      className={cn(\n        'relative min-w-0 truncate text-[13px] transition-colors duration-200',\n        isDone && 'text-muted-foreground',\n        className\n      )}\n    >\n      {title}\n      <span\n        aria-hidden='true'\n        className={cn(\n          'bg-foreground/35 pointer-events-none absolute inset-x-0 top-1/2 h-px origin-left scale-x-0 transition-transform duration-200 ease-(--ease-out-strong)',\n          isDone && 'scale-x-100'\n        )}\n      />\n    </span>\n  );\n}\n\nconst EVENT_ICON: Record<WorkEventKind, Icon> = {\n  created: PlusIcon,\n  status: CircleDashedIcon,\n  assignee: UserIcon,\n  estimate: ClockIcon,\n  subtask: ListTreeIcon,\n  comment: MessageCircleIcon,\n};\n\nexport function EventGlyph({\n  kind,\n  className,\n}: {\n  kind: WorkEventKind;\n  className?: string;\n}) {\n  const Glyph = EVENT_ICON[kind];\n  return (\n    <span\n      className={cn(\n        'keycap-3d text-muted-foreground relative flex size-6 shrink-0 items-center justify-center rounded-full [&_svg]:size-3',\n        className\n      )}\n    >\n      <Glyph />\n    </span>\n  );\n}\n\nexport function DoneMark() {\n  return (\n    <span className='bg-success/15 text-success-foreground flex size-4 items-center justify-center rounded-full'>\n      <CheckIcon strokeWidth={3} className='size-2.5' />\n    </span>\n  );\n}\n\nexport function CommentText({\n  body,\n  className,\n}: {\n  body: string;\n  className?: string;\n}) {\n  const segments = segmentsOf(body);\n  return (\n    <p\n      className={cn(\n        'text-[13px] leading-5 [overflow-wrap:anywhere] whitespace-pre-wrap',\n        className\n      )}\n    >\n      {segments.map((segment, index) => {\n        const key = `${index}-${segment.text}`;\n        if (segment.isMention) {\n          return (\n            <span\n              key={key}\n              className='bg-primary/10 text-primary-ink dark:bg-primary/20 rounded-[4px] px-0.5 font-medium'\n            >\n              {segment.text}\n            </span>\n          );\n        }\n        return <span key={key}>{segment.text}</span>;\n      })}\n    </p>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/task-detail-03/work-glyphs.tsx"
    },
    {
      "path": "registry/ndeko/blocks/task-detail/task-detail-03/motion-parts.tsx",
      "content": "'use client';\n\nimport {\n  AnimatePresence,\n  motion,\n  type MotionProps,\n  type Transition,\n  type Variants,\n} from 'motion/react';\nimport { useState } from 'react';\n\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport { cn } from '@/registry/ndeko/lib/utils';\n\nexport const EASE_OUT_STRONG: [number, number, number, number] = [\n  0.23, 1, 0.32, 1,\n];\n\nexport const ENTER: Transition = { duration: 0.2, ease: EASE_OUT_STRONG };\n\nexport const EXIT: Transition = { duration: 0.15, ease: EASE_OUT_STRONG };\n\nexport type PresenceProps = Pick<\n  MotionProps,\n  'initial' | 'animate' | 'exit' | 'transition'\n>;\n\nconst HEIGHT_PRESENCE: PresenceProps = {\n  initial: { height: 0, opacity: 0 },\n  animate: { height: 'auto', opacity: 1 },\n  exit: { height: 0, opacity: 0, transition: EXIT },\n  transition: ENTER,\n};\n\nconst FADE_PRESENCE: PresenceProps = {\n  initial: { opacity: 0 },\n  animate: { opacity: 1 },\n  exit: { opacity: 0, transition: EXIT },\n  transition: ENTER,\n};\n\n/** Rows that arrive or leave a list: their height opens and closes so the rows after them slide. */\nexport function heightPresenceOf(shouldReduceMotion: boolean | null) {\n  if (shouldReduceMotion) {\n    return FADE_PRESENCE;\n  }\n  return HEIGHT_PRESENCE;\n}\n\nconst SWAP_TRANSITION: Transition = { duration: 0.15, ease: EASE_OUT_STRONG };\n\nconst SWAP_VARIANTS: Variants = {\n  hidden: { opacity: 0, scale: 0.6, filter: 'blur(2px)' },\n  shown: { opacity: 1, scale: 1, filter: 'blur(0px)' },\n};\n\nconst FADE_VARIANTS: Variants = {\n  hidden: { opacity: 0 },\n  shown: { opacity: 1 },\n};\n\nfunction swapVariantsOf(shouldReduceMotion: boolean | null) {\n  if (shouldReduceMotion) {\n    return FADE_VARIANTS;\n  }\n  return SWAP_VARIANTS;\n}\n\ntype SwapProps = {\n  swapKey: string;\n  children: React.ReactNode;\n  className?: string;\n};\n\n/** An icon or a short label that becomes another one in place. */\nexport function Swap({ swapKey, children, className }: SwapProps) {\n  const shouldReduceMotion = usePrefersReducedMotion();\n\n  return (\n    <span className={cn('relative inline-flex', className)}>\n      <AnimatePresence mode='popLayout' initial={false}>\n        <motion.span\n          key={swapKey}\n          variants={swapVariantsOf(shouldReduceMotion)}\n          initial='hidden'\n          animate='shown'\n          exit='hidden'\n          transition={SWAP_TRANSITION}\n          className='inline-flex'\n        >\n          {children}\n        </motion.span>\n      </AnimatePresence>\n    </span>\n  );\n}\n\nconst COUNT_SLIDE = 8;\n\nconst COUNT_TRANSITION: Transition = { duration: 0.18, ease: EASE_OUT_STRONG };\n\nconst COUNT_VARIANTS: Variants = {\n  enter: (offset: number) => ({ y: offset, opacity: 0 }),\n  center: { y: 0, opacity: 1 },\n  leave: (offset: number) => ({ y: -offset, opacity: 0 }),\n};\n\nfunction directionOf(previous: number, next: number) {\n  if (next < previous) {\n    return -1;\n  }\n  return 1;\n}\n\nfunction offsetOf(direction: number, shouldReduceMotion: boolean | null) {\n  if (shouldReduceMotion) {\n    return 0;\n  }\n  return direction * COUNT_SLIDE;\n}\n\ntype RollingCountProps = {\n  value: number;\n  /** Writes the value, such as a duration; the digits still roll on the number. */\n  format?: (value: number) => string;\n  className?: string;\n};\n\nfunction plainNumber(value: number) {\n  return String(value);\n}\n\n/** A figure the person just changed: the new digits slide in from the side of the change. */\nexport function RollingCount({\n  value,\n  format = plainNumber,\n  className,\n}: RollingCountProps) {\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const [previous, setPrevious] = useState(value);\n  const [direction, setDirection] = useState(1);\n\n  if (previous !== value) {\n    setDirection(directionOf(previous, value));\n    setPrevious(value);\n  }\n\n  const offset = offsetOf(direction, shouldReduceMotion);\n\n  return (\n    <span\n      className={cn(\n        'relative inline-flex overflow-hidden tabular-nums',\n        className\n      )}\n    >\n      <AnimatePresence mode='popLayout' initial={false} custom={offset}>\n        <motion.span\n          key={value}\n          custom={offset}\n          variants={COUNT_VARIANTS}\n          initial='enter'\n          animate='center'\n          exit='leave'\n          transition={COUNT_TRANSITION}\n          className='inline-block'\n        >\n          {format(value)}\n        </motion.span>\n      </AnimatePresence>\n    </span>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/task-detail-03/motion-parts.tsx"
    },
    {
      "path": "registry/ndeko/blocks/task-detail/task-detail-03/work-model.ts",
      "content": "import {\n  differenceInCalendarDays,\n  differenceInMinutes,\n  format,\n  parseISO,\n} from 'date-fns';\n\nimport {\n  CURRENT_USER_ID,\n  NOW,\n  PEOPLE,\n  TEAM_KEY,\n  type Subtask,\n  type TaskComment,\n  type WorkEvent,\n} from './data';\n\nexport type WorkState = {\n  subtasks: Subtask[];\n  comments: TaskComment[];\n  events: WorkEvent[];\n};\n\nexport type EventDay = {\n  key: string;\n  label: string;\n  events: WorkEvent[];\n};\n\nconst MINUTES_PER_HOUR = 60;\n\nconst FIRST_FREE_NUMBER = 230;\n\nlet createdCount = 0;\n\nexport function nextSeq() {\n  createdCount += 1;\n  return createdCount;\n}\n\nfunction nextIdOf(prefix: string) {\n  return `${prefix}-${nextSeq()}`;\n}\n\nexport function personOf(id: string) {\n  const found = PEOPLE.find((person) => person.id === id);\n  if (found) {\n    return found;\n  }\n  return PEOPLE[0];\n}\n\nexport function currentUser() {\n  return personOf(CURRENT_USER_ID);\n}\n\nexport function actorNameOf(id: string) {\n  if (id === CURRENT_USER_ID) {\n    return 'You';\n  }\n  return personOf(id).name;\n}\n\nexport function keyOf(number: number) {\n  return `${TEAM_KEY}-${number}`;\n}\n\nexport function countLabel(count: number, singular: string, plural: string) {\n  if (count === 1) {\n    return `${count} ${singular}`;\n  }\n  return `${count} ${plural}`;\n}\n\nexport function doneCountOf(subtasks: Subtask[]) {\n  return subtasks.filter((subtask) => subtask.isDone).length;\n}\n\nfunction daysBeforeNow(iso: string) {\n  return differenceInCalendarDays(parseISO(NOW), parseISO(iso));\n}\n\nexport function relativeTimeOf(iso: string) {\n  const minutes = differenceInMinutes(parseISO(NOW), parseISO(iso));\n  if (minutes < 1) {\n    return 'Just now';\n  }\n  if (minutes < MINUTES_PER_HOUR) {\n    return `${minutes}m ago`;\n  }\n  const days = daysBeforeNow(iso);\n  if (days === 0) {\n    const hours = Math.floor(minutes / MINUTES_PER_HOUR);\n    return `${hours}h ago`;\n  }\n  if (days === 1) {\n    return 'Yesterday';\n  }\n  return format(parseISO(iso), 'MMM d');\n}\n\nexport function clockOf(iso: string) {\n  return format(parseISO(iso), 'HH:mm');\n}\n\nexport function dueLabelOf(iso: string) {\n  const days = -daysBeforeNow(iso);\n  if (days === 0) {\n    return 'Due today';\n  }\n  if (days === 1) {\n    return 'Due tomorrow';\n  }\n  if (days > 1) {\n    return `Due in ${days} days`;\n  }\n  return `${Math.abs(days)} days late`;\n}\n\nfunction dayLabelOf(iso: string) {\n  const days = daysBeforeNow(iso);\n  if (days === 0) {\n    return 'Today';\n  }\n  if (days === 1) {\n    return 'Yesterday';\n  }\n  return format(parseISO(iso), 'EEEE, MMM d');\n}\n\n/** Newest day first, newest event first inside each day. */\nexport function eventDaysOf(events: WorkEvent[]) {\n  const sorted = [...events].sort((first, second) =>\n    second.at.localeCompare(first.at)\n  );\n  const days: EventDay[] = [];\n  for (const event of sorted) {\n    const key = event.at.slice(0, 10);\n    const last = days.at(-1);\n    const isSameDay = last?.key === key;\n    if (isSameDay) {\n      last.events.push(event);\n      continue;\n    }\n    days.push({ key, label: dayLabelOf(event.at), events: [event] });\n  }\n  return days;\n}\n\nfunction toggleEventOf(subtask: Subtask): WorkEvent {\n  let verb = 'reopened';\n  if (subtask.isDone) {\n    verb = 'completed';\n  }\n  return {\n    id: `toggle-${subtask.id}`,\n    kind: 'subtask',\n    actorId: CURRENT_USER_ID,\n    at: NOW,\n    text: `${verb} ${keyOf(subtask.number)} ${subtask.title}`,\n    seq: nextSeq(),\n  };\n}\n\n/** A sub-task checked then unchecked in the same visit leaves one line in the log, not two. */\nfunction withEvent(events: WorkEvent[], event: WorkEvent) {\n  const others = events.filter((item) => item.id !== event.id);\n  return [...others, event];\n}\n\nexport function toggledSubtask(state: WorkState, subtaskId: string) {\n  const target = state.subtasks.find((subtask) => subtask.id === subtaskId);\n  if (!target) {\n    return state;\n  }\n  const toggled: Subtask = { ...target, isDone: !target.isDone };\n  const subtasks = state.subtasks.map((subtask) => {\n    if (subtask.id !== subtaskId) {\n      return subtask;\n    }\n    return toggled;\n  });\n  const events = withEvent(state.events, toggleEventOf(toggled));\n  const next: WorkState = { ...state, subtasks, events };\n  return next;\n}\n\nfunction nextNumberOf(subtasks: Subtask[]) {\n  const numbers = subtasks.map((subtask) => subtask.number);\n  return Math.max(FIRST_FREE_NUMBER, ...numbers) + 1;\n}\n\nexport function addedSubtask(state: WorkState, title: string) {\n  const number = nextNumberOf(state.subtasks);\n  const subtask: Subtask = {\n    id: nextIdOf('subtask'),\n    number,\n    title,\n    isDone: false,\n  };\n  const event: WorkEvent = {\n    id: nextIdOf('event'),\n    kind: 'subtask',\n    actorId: CURRENT_USER_ID,\n    at: NOW,\n    text: `added ${keyOf(number)} ${title}`,\n    seq: nextSeq(),\n  };\n  const next: WorkState = {\n    ...state,\n    subtasks: [...state.subtasks, subtask],\n    events: [...state.events, event],\n  };\n  return next;\n}\n\nexport function postedComment(state: WorkState, body: string) {\n  const comment: TaskComment = {\n    id: nextIdOf('comment'),\n    authorId: CURRENT_USER_ID,\n    at: NOW,\n    body,\n    seq: nextSeq(),\n  };\n  return withComment(state, comment);\n}\n\nexport function withComment(state: WorkState, comment: TaskComment) {\n  const event: WorkEvent = {\n    id: nextIdOf('event'),\n    kind: 'comment',\n    actorId: comment.authorId,\n    at: comment.at,\n    text: 'commented',\n    seq: comment.seq,\n  };\n  const next: WorkState = {\n    ...state,\n    comments: [...state.comments, comment],\n    events: [...state.events, event],\n  };\n  return next;\n}\n\nexport type Segment = {\n  text: string;\n  isMention: boolean;\n};\n\nconst MENTION_TOKENS = PEOPLE.map((person) => `@${person.name}`);\n\nfunction pushPlain(segments: Segment[], text: string) {\n  if (text.length === 0) {\n    return;\n  }\n  segments.push({ text, isMention: false });\n}\n\n/** Splits a comment into plain text and mentions of known people, written \"@First Last\". */\nexport function segmentsOf(text: string) {\n  const segments: Segment[] = [];\n  let plain = '';\n  let index = 0;\n  while (index < text.length) {\n    const token = MENTION_TOKENS.find((candidate) =>\n      text.startsWith(candidate, index)\n    );\n    if (token) {\n      pushPlain(segments, plain);\n      segments.push({ text: token, isMention: true });\n      plain = '';\n      index += token.length;\n      continue;\n    }\n    plain += text[index];\n    index += 1;\n  }\n  pushPlain(segments, plain);\n  return segments;\n}\n",
      "type": "registry:component",
      "target": "components/blocks/task-detail-03/work-model.ts"
    },
    {
      "path": "registry/ndeko/blocks/task-detail/task-detail-03/data.ts",
      "content": "export type StatusId =\n  'backlog' | 'todo' | 'in_progress' | 'in_review' | 'done';\n\nexport type Person = {\n  id: string;\n  name: string;\n  firstName: string;\n};\n\nexport type Subtask = {\n  id: string;\n  number: number;\n  title: string;\n  isDone: boolean;\n  assigneeId?: string;\n};\n\nexport type TaskComment = {\n  id: string;\n  authorId: string;\n  at: string;\n  body: string;\n  /** Order of what was added during the visit, which all shares the same time. */\n  seq?: number;\n};\n\nexport type WorkEventKind =\n  'created' | 'status' | 'assignee' | 'estimate' | 'subtask' | 'comment';\n\nexport type WorkEvent = {\n  id: string;\n  kind: WorkEventKind;\n  actorId: string;\n  at: string;\n  text: string;\n  seq?: number;\n};\n\nexport type Task = {\n  key: string;\n  title: string;\n  project: string;\n  status: StatusId;\n  assigneeIds: string[];\n  due: string;\n  description: string;\n};\n\n/** The previews read every time against one fixed moment, so the server and the browser print the same labels. */\nexport const NOW = '2026-11-05T11:00:00';\n\nexport const TEAM_KEY = 'MOS';\n\nexport const CURRENT_USER_ID = 'amara';\n\nexport const PEOPLE: Person[] = [\n  {\n    id: 'amara',\n    name: 'Amara Okafor',\n    firstName: 'Amara',\n  },\n  {\n    id: 'leo',\n    name: 'Léo Martin',\n    firstName: 'Léo',\n  },\n  {\n    id: 'sana',\n    name: 'Sana Iqbal',\n    firstName: 'Sana',\n  },\n  {\n    id: 'tomas',\n    name: 'Tomás Rivera',\n    firstName: 'Tomás',\n  },\n  {\n    id: 'mei',\n    name: 'Mei Lin',\n    firstName: 'Mei',\n  },\n];\n\nexport const TASK: Task = {\n  key: 'MOS-214',\n  title: 'Export invoices as CSV',\n  project: 'Billing',\n  status: 'in_progress',\n  assigneeIds: ['leo', 'tomas'],\n  due: '2026-11-07',\n  description:\n    'Finance copies invoices into the ledger by hand every month. Add an export on the invoices page that writes the filtered range to a CSV file finance can import as it is.',\n};\n\nexport const SUBTASKS: Subtask[] = [\n  {\n    id: 'mos-215',\n    number: 215,\n    title: 'Pick the columns finance needs',\n    isDone: true,\n    assigneeId: 'leo',\n  },\n  {\n    id: 'mos-216',\n    number: 216,\n    title: 'Write the CSV writer with escaped fields',\n    isDone: true,\n    assigneeId: 'leo',\n  },\n  {\n    id: 'mos-218',\n    number: 218,\n    title: 'Add the totals row',\n    isDone: false,\n    assigneeId: 'leo',\n  },\n  {\n    id: 'mos-219',\n    number: 219,\n    title: 'Dates in the account time zone',\n    isDone: false,\n    assigneeId: 'tomas',\n  },\n  {\n    id: 'mos-220',\n    number: 220,\n    title: 'Download button on the invoices page',\n    isDone: false,\n    assigneeId: 'mei',\n  },\n];\n\nexport const COMMENTS: TaskComment[] = [\n  {\n    id: 'c1',\n    authorId: 'sana',\n    at: '2026-11-04T15:20:00',\n    body: 'Should the export include voided invoices? Finance filters them out by hand today.',\n  },\n  {\n    id: 'c2',\n    authorId: 'leo',\n    at: '2026-11-04T16:05:00',\n    body: 'I would keep them with a Status column, so the totals still match the ledger.',\n  },\n  {\n    id: 'c3',\n    authorId: 'tomas',\n    at: '2026-11-05T10:05:00',\n    body: '@Amara Okafor the time zone part is in review. Dates now follow the account setting.',\n  },\n];\n\nexport const EVENTS: WorkEvent[] = [\n  {\n    id: 'e1',\n    kind: 'created',\n    actorId: 'sana',\n    at: '2026-11-03T09:12:00',\n    text: 'created the task',\n  },\n  {\n    id: 'e2',\n    kind: 'assignee',\n    actorId: 'mei',\n    at: '2026-11-04T10:05:00',\n    text: 'assigned Léo and Tomás',\n  },\n  {\n    id: 'e3',\n    kind: 'estimate',\n    actorId: 'leo',\n    at: '2026-11-04T10:20:00',\n    text: 'set the estimate to 6h',\n  },\n  {\n    id: 'e4',\n    kind: 'status',\n    actorId: 'leo',\n    at: '2026-11-04T14:02:00',\n    text: 'moved the task to In progress',\n  },\n  {\n    id: 'e5',\n    kind: 'subtask',\n    actorId: 'leo',\n    at: '2026-11-05T09:40:00',\n    text: 'completed MOS-216 Write the CSV writer with escaped fields',\n  },\n];\n",
      "type": "registry:component",
      "target": "components/blocks/task-detail-03/data.ts"
    }
  ],
  "categories": [
    "blocks",
    "task-detail"
  ],
  "type": "registry:block"
}