{"slug":"todo-list","name":"Todo List","description":"A collapsible agent task plan with morphing status marks, a completion count, compact metadata, and smooth list updates.","category":"agents","source_url":"https://beui.dev/r/todo-list/raw","detail_url":"https://beui.dev/r/todo-list","raw_url":"https://beui.dev/r/todo-list/raw","page_url":"https://beui.dev/components/agents/todo-list","markdown_url":"https://beui.dev/components/agents/todo-list.md","published_at":"2026-08-02","updated_at":"2026-11-25","dependencies":["clsx","lucide-react","motion","react","tailwind-merge"],"internal":["./action-swap","@/components/agents/clip-resize-frame","@/components/agents/todo-list","@/components/motion/action-swap-roll","@/lib/ease","@/lib/hooks/use-controllable","@/lib/hooks/use-status-open","@/lib/i18n","@/lib/utils"],"install_slugs":["todo-list"],"requires_theme":true,"props":[{"displayName":"TodoList","props":[{"name":"items","type":"TodoItem[]","required":true,"defaultValue":null,"description":"The tasks, each with a status."},{"name":"title","type":"ReactNode","required":false,"defaultValue":null,"description":"Header text. Default: \"To-dos\""},{"name":"open","type":"boolean","required":false,"defaultValue":null,"description":"Whether the list is expanded, for controlled use."},{"name":"defaultOpen","type":"boolean","required":false,"defaultValue":"true","description":"Whether the list starts expanded when uncontrolled. Default: true"},{"name":"onOpenChange","type":"((open: boolean) => void)","required":false,"defaultValue":null,"description":"Called with the new state when the list expands or collapses."},{"name":"collapseOnComplete","type":"boolean","required":false,"defaultValue":"true","description":"Collapses the list once every task is completed. Default: true"},{"name":"maxHeight","type":"number","required":false,"defaultValue":"248","description":"Height in px before the task list scrolls. Default: 248"},{"name":"labels","type":"Partial<{ title: string; label: string; progress: string; empty: string; pending: string; inProgress: string; completed: string; cancelled: string; }>","required":false,"defaultValue":null,"description":"Override any built-in string. `{completed}` and `{total}` fill `progress`."},{"name":"className","type":"string","required":false,"defaultValue":null,"description":"Classes merged onto the root element."}]}],"types":[{"name":"TodoItem","file":"components/agents/todo-list.tsx","fields":[{"name":"id","type":"string","required":true,"description":"Unique key for the row."},{"name":"title","type":"ReactNode","required":true,"description":"Task text; struck through when completed."},{"name":"status","type":"TodoItemStatus","required":false,"description":"Task state; sets the icon and text tone. Default: \"pending\""},{"name":"progress","type":"number","required":false,"description":"Ring fill from 0 to 100 while in progress; unset spins a partial ring."},{"name":"detail","type":"ReactNode","required":false,"description":"Muted text at the end of the row, such as a time or count."}]}],"files":[{"path":"components/agents/todo-list.tsx","type":"component","content":"\"use client\";\n// beui.dev/components/agents/todo-list\n\nimport { ChevronDown, ListTodo } from \"lucide-react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\nimport { type ReactNode, useId, useLayoutEffect, useRef } from \"react\";\nimport { ClipResizeFrame } from \"@/components/agents/clip-resize-frame\";\nimport { ActionSwapRollText } from \"@/components/motion/action-swap-roll\";\nimport {\n  EASE_OUT,\n  SPRING_LAYOUT,\n  SPRING_SWAP,\n} from \"@/lib/ease\";\nimport { useStatusOpen } from \"@/lib/hooks/use-status-open\";\nimport { formatNumber, useLocale, useMessages } from \"@/lib/i18n\";\nimport { cn } from \"@/lib/utils\";\n\nexport type TodoItemStatus =\n  | \"pending\"\n  | \"in-progress\"\n  | \"completed\"\n  | \"cancelled\";\n\nexport interface TodoItem {\n  /** Unique key for the row. */\n  id: string;\n  /** Task text; struck through when completed. */\n  title: ReactNode;\n  /** Task state; sets the icon and text tone. Default: \"pending\" */\n  status?: TodoItemStatus;\n  /** Ring fill from 0 to 100 while in progress; unset spins a partial ring. */\n  progress?: number;\n  /** Muted text at the end of the row, such as a time or count. */\n  detail?: ReactNode;\n}\n\n/** English defaults. Override per instance with `labels`, or app-wide with `LocaleProvider`. */\nexport const todoListMessages = {\n  title: \"To-dos\",\n  label: \"Agent task list\",\n  progress: \"{completed} of {total} tasks completed\",\n  empty: \"No tasks yet\",\n  pending: \"Pending\",\n  inProgress: \"In progress\",\n  completed: \"Completed\",\n  cancelled: \"Cancelled\",\n};\n\nexport type TodoListMessages = typeof todoListMessages;\n\nconst STATUS_MESSAGE = {\n  pending: \"pending\",\n  \"in-progress\": \"inProgress\",\n  completed: \"completed\",\n  cancelled: \"cancelled\",\n} as const satisfies Record<TodoItemStatus, keyof TodoListMessages>;\n\nexport interface TodoListProps {\n  /** The tasks, each with a status. */\n  items: TodoItem[];\n  /** Header text. Default: \"To-dos\" */\n  title?: ReactNode;\n  /** Whether the list is expanded, for controlled use. */\n  open?: boolean;\n  /** Whether the list starts expanded when uncontrolled. Default: true */\n  defaultOpen?: boolean;\n  /** Called with the new state when the list expands or collapses. */\n  onOpenChange?: (open: boolean) => void;\n  /** Collapses the list once every task is completed. Default: true */\n  collapseOnComplete?: boolean;\n  /** Height in px before the task list scrolls. Default: 248 */\n  maxHeight?: number;\n  /** Override any built-in string. `{completed}` and `{total}` fill `progress`. */\n  labels?: Partial<TodoListMessages>;\n  /** Classes merged onto the root element. */\n  className?: string;\n}\n\nfunction TodoHeaderIcon({ complete }: { complete: boolean }) {\n  const reduce = useReducedMotion() ?? false;\n\n  return (\n    <span\n      aria-hidden=\"true\"\n      className=\"relative grid size-6 shrink-0 place-items-center\"\n    >\n      <AnimatePresence initial={false} mode=\"popLayout\">\n        {complete ? (\n          <motion.svg\n            key=\"complete\"\n            viewBox=\"0 0 24 24\"\n            initial={reduce ? { opacity: 1 } : { opacity: 0, scale: 0.72 }}\n            animate={{ opacity: 1, scale: 1 }}\n            exit={{ opacity: 0 }}\n            transition={reduce ? { duration: 0 } : SPRING_SWAP}\n            className=\"absolute size-5.5 overflow-visible text-emerald-500\"\n          >\n            <circle cx=\"12\" cy=\"12\" r=\"9\" fill=\"currentColor\" />\n            <motion.path\n              d=\"M7.5 12.25 10.5 15.25 16.75 8.75\"\n              fill=\"none\"\n              stroke=\"white\"\n              strokeWidth=\"2.25\"\n              strokeLinecap=\"round\"\n              strokeLinejoin=\"round\"\n              initial={reduce ? { pathLength: 1 } : { pathLength: 0 }}\n              animate={{ pathLength: 1 }}\n              transition={\n                reduce ? { duration: 0 } : { duration: 0.24, ease: EASE_OUT }\n              }\n            />\n          </motion.svg>\n        ) : (\n          <motion.span\n            key=\"todo\"\n            initial={reduce ? { opacity: 1 } : { opacity: 0, scale: 0.8 }}\n            animate={{ opacity: 1, scale: 1 }}\n            exit={reduce ? { opacity: 0 } : { opacity: 0, scale: 0.72 }}\n            transition={reduce ? { duration: 0 } : SPRING_SWAP}\n            className=\"absolute grid place-items-center text-muted-foreground\"\n          >\n            <ListTodo className=\"size-4\" />\n          </motion.span>\n        )}\n      </AnimatePresence>\n    </span>\n  );\n}\n\nfunction TodoStatusIcon({\n  status,\n  progress,\n}: {\n  status: TodoItemStatus;\n  progress?: number;\n}) {\n  const reduce = useReducedMotion() ?? false;\n  const normalizedProgress =\n    progress === undefined ? 0.68 : Math.min(100, Math.max(0, progress)) / 100;\n\n  return (\n    <motion.svg\n      aria-hidden=\"true\"\n      viewBox=\"0 0 24 24\"\n      initial={false}\n      className={cn(\n        \"mx-0.5 size-5 shrink-0 overflow-visible text-muted-foreground\",\n        status === \"in-progress\" && \"text-foreground\",\n        status === \"cancelled\" && \"text-rose-600 dark:text-rose-400\",\n      )}\n    >\n      <motion.circle\n        cx=\"12\"\n        cy=\"12\"\n        r=\"9\"\n        fill=\"currentColor\"\n        stroke=\"currentColor\"\n        strokeWidth=\"1.5\"\n        strokeDasharray={status === \"pending\" ? \"2 3\" : undefined}\n        strokeLinecap=\"round\"\n        initial={false}\n        animate={{ fillOpacity: status === \"completed\" ? 0.06 : 0 }}\n        transition={reduce ? { duration: 0 } : { duration: 0.18, ease: EASE_OUT }}\n        className={cn(status === \"in-progress\" && \"opacity-20\")}\n      />\n      <motion.circle\n        cx=\"12\"\n        cy=\"12\"\n        r=\"9\"\n        pathLength=\"1\"\n        fill=\"none\"\n        stroke=\"currentColor\"\n        strokeWidth=\"2\"\n        strokeLinecap=\"round\"\n        initial={false}\n        animate={{\n          pathLength: status === \"in-progress\" ? normalizedProgress : 0,\n          opacity: status === \"in-progress\" ? 1 : 0,\n          rotate:\n            status === \"in-progress\" && progress === undefined && !reduce\n              ? 360\n              : -90,\n        }}\n        transition={\n          status === \"in-progress\" && progress === undefined && !reduce\n            ? { rotate: { duration: 1.1, repeat: Infinity, ease: \"linear\" } }\n            : reduce\n              ? { duration: 0 }\n              : SPRING_LAYOUT\n        }\n        style={{ transformOrigin: \"12px 12px\" }}\n      />\n      <motion.path\n        d=\"M7.5 12.25 10.5 15.25 16.75 8.75\"\n        fill=\"none\"\n        stroke=\"currentColor\"\n        strokeWidth=\"2\"\n        strokeLinecap=\"round\"\n        strokeLinejoin=\"round\"\n        initial={false}\n        animate={{\n          pathLength: status === \"completed\" ? 1 : 0,\n          opacity: status === \"completed\" ? 1 : 0,\n        }}\n        transition={reduce ? { duration: 0 } : { duration: 0.24, ease: EASE_OUT }}\n      />\n      <motion.path\n        d=\"M8.5 8.5 15.5 15.5M15.5 8.5 8.5 15.5\"\n        fill=\"none\"\n        stroke=\"currentColor\"\n        strokeWidth=\"2\"\n        strokeLinecap=\"round\"\n        initial={false}\n        animate={{\n          pathLength: status === \"cancelled\" ? 1 : 0,\n          opacity: status === \"cancelled\" ? 1 : 0,\n        }}\n        transition={reduce ? { duration: 0 } : { duration: 0.2, ease: EASE_OUT }}\n      />\n    </motion.svg>\n  );\n}\n\nexport function TodoList({\n  items,\n  title,\n  open,\n  defaultOpen = true,\n  onOpenChange,\n  collapseOnComplete = true,\n  maxHeight = 248,\n  labels,\n  className,\n}: TodoListProps) {\n  const reduce = useReducedMotion() ?? false;\n  const t = useMessages(\"todoList\", todoListMessages, labels);\n  const { locale } = useLocale();\n  const baseId = useId();\n  const triggerId = `${baseId}-trigger`;\n  const contentId = `${baseId}-content`;\n  const viewportRef = useRef<HTMLDivElement>(null);\n  const completed = items.filter((item) => item.status === \"completed\").length;\n  const allComplete = items.length > 0 && completed === items.length;\n  const itemCount = items.length;\n  // Reopens when finished work gets a new item; folds once everything is\n  // done, if asked to, including a list that mounts already complete.\n  const [currentOpen, setOpen] = useStatusOpen({\n    status: allComplete,\n    initialStatus: false,\n    open,\n    defaultOpen,\n    onOpenChange,\n    decide: (wasComplete, isComplete) => {\n      if (wasComplete && !isComplete) return true;\n      if (!wasComplete && isComplete && collapseOnComplete) return false;\n      return undefined;\n    },\n  });\n\n  useLayoutEffect(() => {\n    const viewport = viewportRef.current;\n    if (!viewport || itemCount === 0) return;\n\n    const frame = requestAnimationFrame(() => {\n      if (viewport.scrollHeight <= viewport.clientHeight) return;\n      if (typeof viewport.scrollTo === \"function\") {\n        viewport.scrollTo({\n          top: viewport.scrollHeight,\n          behavior: reduce ? \"auto\" : \"smooth\",\n        });\n      } else {\n        viewport.scrollTop = viewport.scrollHeight;\n      }\n    });\n    return () => cancelAnimationFrame(frame);\n  }, [itemCount, reduce]);\n\n  return (\n    // The card's bottom edge glides as the list folds or opens, instead of\n    // the old fold that snapped the edge up once it finished.\n    <ClipResizeFrame\n      role=\"region\"\n      aria-label={t(\"label\")}\n      className={cn(\"w-full\", className)}\n    >\n      <button\n        id={triggerId}\n        type=\"button\"\n        aria-expanded={currentOpen}\n        aria-controls={contentId}\n        onClick={() => setOpen(!currentOpen)}\n        className=\"group flex h-11 w-full items-center gap-2.5 rounded-2xl px-3.5 text-start outline-none focus-visible:ring-2 focus-visible:ring-ring\"\n      >\n        <TodoHeaderIcon complete={allComplete} />\n        <h3 className=\"min-w-0 flex-1 truncate text-sm font-medium text-foreground/90\">\n          {title ?? t(\"title\")}\n        </h3>\n        <span\n          className={cn(\n            \"shrink-0 text-xs font-medium tabular-nums text-muted-foreground\",\n            allComplete && \"text-emerald-600 dark:text-emerald-400\",\n          )}\n        >\n          <span className=\"sr-only\">\n            {t(\"progress\", { completed, total: items.length })}\n          </span>\n          <span aria-hidden=\"true\" className=\"inline-flex\">\n            <ActionSwapRollText value={String(completed)}>\n              {formatNumber(completed, locale)}\n            </ActionSwapRollText>\n            <span>/</span>\n            <span>{formatNumber(items.length, locale)}</span>\n          </span>\n        </span>\n        <motion.span\n          aria-hidden=\"true\"\n          animate={{ rotate: currentOpen ? 180 : 0 }}\n          transition={reduce ? { duration: 0 } : SPRING_SWAP}\n          className=\"text-muted-foreground/50 transition-colors group-hover:text-muted-foreground\"\n        >\n          <ChevronDown className=\"size-3.5\" />\n        </motion.span>\n      </button>\n\n      {/* The list leaves the layout at once when folding (popLayout) and\n          fades under the rising edge; opening, it fades in as the edge drops. */}\n      <AnimatePresence initial={false} mode=\"popLayout\">\n      {currentOpen ? (\n      <motion.div\n        key=\"list\"\n        id={contentId}\n        role=\"region\"\n        aria-labelledby={triggerId}\n        initial={{ opacity: 0 }}\n        animate={{ opacity: 1, transition: { duration: 0.2, ease: EASE_OUT } }}\n        exit={{ opacity: 0, transition: { duration: 0.14, ease: EASE_OUT } }}\n        className=\"w-full\"\n      >\n        <div\n          ref={viewportRef}\n          className=\"scrollbar-hide overflow-y-auto px-2 pb-2\"\n          style={{ maxHeight }}\n        >\n          {items.length ? (\n            <ol aria-live=\"polite\" className=\"space-y-0\">\n            <AnimatePresence initial={false} mode=\"popLayout\">\n              {items.map((item) => {\n                const status = item.status ?? \"pending\";\n                return (\n                  <motion.li\n                    layout=\"position\"\n                    key={item.id}\n                    initial={reduce ? { opacity: 1 } : { opacity: 0, y: 6 }}\n                    animate={{ opacity: 1, y: 0 }}\n                    exit={reduce ? { opacity: 0 } : { opacity: 0, y: -3 }}\n                    transition={\n                      reduce\n                        ? { duration: 0 }\n                        : {\n                            opacity: { duration: 0.18, ease: EASE_OUT },\n                            y: SPRING_LAYOUT,\n                            layout: SPRING_LAYOUT,\n                          }\n                    }\n                    className=\"flex min-h-9 items-center gap-2.5 rounded-xl px-1.5 py-1\"\n                  >\n                    <TodoStatusIcon status={status} progress={item.progress} />\n                    <span className=\"sr-only\">{t(STATUS_MESSAGE[status])}: </span>\n                    <span\n                      className={cn(\n                        \"min-w-0 flex-1 truncate text-sm leading-5\",\n                        status === \"pending\" && \"text-muted-foreground/65\",\n                        status === \"in-progress\" && \"text-foreground\",\n                        status === \"completed\" && \"text-muted-foreground/60\",\n                        status === \"cancelled\" && \"text-muted-foreground/55\",\n                      )}\n                    >\n                      <span className=\"relative inline-block max-w-full\">\n                        {item.title}\n                        <motion.span\n                          aria-hidden=\"true\"\n                          initial={false}\n                          animate={{\n                            scaleX: status === \"completed\" ? 1 : 0,\n                            opacity: status === \"completed\" ? 1 : 0,\n                          }}\n                          transition={\n                            reduce\n                              ? { duration: 0 }\n                              : { duration: 0.28, ease: EASE_OUT, delay: 0.06 }\n                          }\n                          className=\"absolute inset-x-0 top-1/2 h-px origin-left bg-current rtl:origin-right\"\n                        />\n                      </span>\n                    </span>\n                    {item.detail ? (\n                      <span className=\"shrink-0 text-sm text-muted-foreground/55\">\n                        {item.detail}\n                      </span>\n                    ) : null}\n                  </motion.li>\n                );\n              })}\n            </AnimatePresence>\n            </ol>\n          ) : (\n            <p className=\"px-1.5 py-2 text-sm text-muted-foreground\">\n              {t(\"empty\")}\n            </p>\n          )}\n        </div>\n      </motion.div>\n      ) : null}\n      </AnimatePresence>\n    </ClipResizeFrame>\n  );\n}\n"},{"path":"components/agents/clip-resize-frame.tsx","type":"util","content":"\"use client\";\n\nimport {\n  type AnimationPlaybackControls,\n  animate,\n  type HTMLMotionProps,\n  motion,\n  useMotionValue,\n  useReducedMotion,\n  useTransform,\n} from \"motion/react\";\nimport { type CSSProperties, type ReactNode, useLayoutEffect, useRef } from \"react\";\nimport { EASE_OUT, SPRING_MORPH } from \"@/lib/ease\";\nimport { cn } from \"@/lib/utils\";\n\n// The bottom edge glides to the new size; a little quicker when shrinking,\n// since the content inside has already gone.\nconst GROW = { duration: 0.3, ease: EASE_OUT } as const;\nconst SHRINK = { duration: 0.24, ease: EASE_OUT } as const;\n\nexport interface ClipResizeFrameProps extends Omit<HTMLMotionProps<\"div\">, \"children\" | \"style\"> {\n  style?: CSSProperties;\n  /**\n   * Which size follows the content. \"y\": the bottom edge glides as the height\n   * changes. \"x\": both ends glide in or out from the centre as the width\n   * changes, on a morph spring, for pills and chips. Default: \"y\"\n   */\n  axis?: \"x\" | \"y\";\n  /**\n   * With axis \"y\", which edge moves. \"top\" is for a panel anchored at its\n   * bottom, such as a list opening above an input: its top edge glides and its\n   * content stays against the bottom. Default: \"bottom\"\n   */\n  edge?: \"top\" | \"bottom\";\n  /** Outer corner radius in px. The surface inside uses one less. */\n  radius?: number;\n  /** Classes for the content box (padding goes here). */\n  contentClassName?: string;\n  children: ReactNode;\n}\n\n/**\n * A bordered card whose bottom edge glides when its content grows or shrinks,\n * without animating height. The layout changes at once; a clip on the card\n * hides the difference and slides it away. The border is the 1px gap between\n * two clipped layers (the frame in the border colour, the surface inside it),\n * so the bottom line travels with the edge instead of being clipped off.\n */\nexport function ClipResizeFrame({\n  axis = \"y\",\n  edge = \"bottom\",\n  radius = 16,\n  className,\n  contentClassName,\n  style,\n  children,\n  ...props\n}: ClipResizeFrameProps) {\n  const reduce = useReducedMotion() ?? false;\n  const horizontal = axis === \"x\";\n  const fromTop = !horizontal && edge === \"top\";\n  const surfaceRef = useRef<HTMLDivElement>(null);\n  const contentRef = useRef<HTMLDivElement>(null);\n  // How much of the surface (px) is hidden right now: at the moving edge, or\n  // split evenly between the two ends.\n  const gap = useMotionValue(0);\n  const clip = (value: number, round: number) =>\n    horizontal\n      ? `inset(0 ${value / 2}px 0 ${value / 2}px round ${round}px)`\n      : fromTop\n        ? `inset(${value}px 0 0 0 round ${round}px)`\n        : `inset(0 0 ${value}px 0 round ${round}px)`;\n  const frameClip = useTransform(gap, (value) =>\n    Math.abs(value) > 0.5 ? clip(value, radius) : \"none\",\n  );\n  const surfaceClip = useTransform(gap, (value) =>\n    Math.abs(value) > 0.5 ? clip(value, radius - 1) : \"none\",\n  );\n\n  useLayoutEffect(() => {\n    const surface = surfaceRef.current;\n    const content = contentRef.current;\n    if (!surface || !content || typeof ResizeObserver === \"undefined\") return;\n\n    const measure = () => (horizontal ? content.offsetWidth : content.offsetHeight);\n    const side = horizontal ? \"width\" : \"height\";\n    let last = measure();\n    // While shrinking, the surface keeps its old size so the edge has\n    // somewhere to glide from; null when the surface sizes to its content.\n    let held: number | null = null;\n    let controls: AnimationPlaybackControls | undefined;\n\n    const release = () => {\n      held = null;\n      surface.style[side] = \"\";\n      gap.set(0);\n    };\n\n    // Runs after layout and before paint, so the held size lands in the\n    // same frame as the content change: the edge never jumps.\n    const observer = new ResizeObserver(() => {\n      const next = measure();\n      if (next === last) return;\n      const visible = (held ?? last) - gap.get();\n      last = next;\n      controls?.stop();\n\n      if (reduce) {\n        release();\n        return;\n      }\n\n      const from = Math.max(next, visible);\n      held = from > next ? from : null;\n      surface.style[side] = held === null ? \"\" : `${held}px`;\n      gap.set(from - visible);\n      controls = animate(gap, from - next, {\n        ...(horizontal ? SPRING_MORPH : next < visible ? SHRINK : GROW),\n        // The edge has reached the content: hand the size back to layout.\n        onComplete: () => {\n          if (held !== null) release();\n        },\n      });\n    });\n    observer.observe(content);\n    return () => {\n      observer.disconnect();\n      controls?.stop();\n    };\n  }, [gap, reduce, horizontal]);\n\n  return (\n    <motion.div\n      {...props}\n      style={{ ...style, borderRadius: radius, clipPath: frameClip }}\n      className={cn(\"bg-border p-px\", horizontal && \"w-fit\", className)}\n    >\n      <motion.div\n        ref={surfaceRef}\n        style={{ borderRadius: radius - 1, clipPath: surfaceClip }}\n        // Held wider than its content while shrinking, the surface keeps the\n        // content centred, so the two ends close in on it evenly.\n        // Held taller than its content, a top-edge surface keeps the content\n        // against its anchored bottom.\n        className={cn(\n          \"overflow-hidden bg-background\",\n          horizontal && \"flex justify-center\",\n          fromTop && \"flex flex-col justify-end\",\n        )}\n      >\n        <div ref={contentRef} className={cn(horizontal && \"w-max shrink-0\", contentClassName)}>\n          {children}\n        </div>\n      </motion.div>\n    </motion.div>\n  );\n}\n"},{"path":"components/motion/action-swap-roll.tsx","type":"util","content":"\"use client\";\n\nimport {\n  ActionSwapButton,\n  ActionSwapIcon,\n  ActionSwapText,\n  type ActionSwapButtonProps,\n  type ActionSwapIconProps,\n  type ActionSwapTextProps,\n} from \"./action-swap\";\n\nexport type {\n  ActionSwapButtonSize,\n  ActionSwapButtonVariant,\n  ActionSwapItem,\n} from \"./action-swap\";\n\nexport type ActionSwapRollButtonProps = Omit<ActionSwapButtonProps, \"animation\">;\nexport type ActionSwapRollTextProps = Omit<ActionSwapTextProps, \"animation\">;\nexport type ActionSwapRollIconProps = Omit<ActionSwapIconProps, \"animation\">;\n\nexport function ActionSwapRollButton(props: ActionSwapRollButtonProps) {\n  return <ActionSwapButton {...props} animation=\"roll\" />;\n}\n\nexport function ActionSwapRollText(props: ActionSwapRollTextProps) {\n  return <ActionSwapText {...props} animation=\"roll\" />;\n}\n\nexport function ActionSwapRollIcon(props: ActionSwapRollIconProps) {\n  return <ActionSwapIcon {...props} animation=\"roll\" />;\n}\n"},{"path":"lib/ease.ts","type":"util","content":"// Shared motion tokens. Easing curves mirror the CSS custom properties in\n// globals.css; springs are the canonical physics used across components.\n// Strong custom variants - defaults like `ease-in`/`ease-out` feel weak.\n\nexport const EASE_OUT = [0.16, 1, 0.3, 1] as const;\n/** Accelerating curve for things that fall (a dropped ball, a toppled block). Not for UI entrances. */\nexport const EASE_IN = [0.55, 0, 1, 0.45] as const;\nexport const EASE_IN_OUT = [0.77, 0, 0.175, 1] as const;\nexport const EASE_DRAWER = [0.32, 0.72, 0, 1] as const;\n\n/** CSS string form of EASE_OUT for inline style transitions. */\nexport const EASE_OUT_CSS = \"cubic-bezier(0.16, 1, 0.3, 1)\";\n\n/** Press feedback on buttons and other tappable surfaces. */\nexport const SPRING_PRESS = {\n  type: \"spring\",\n  stiffness: 500,\n  damping: 30,\n  mass: 0.6,\n} as const;\n\n/** Content swaps - label/icon slots trading places inside a control. */\nexport const SPRING_SWAP = {\n  type: \"spring\",\n  stiffness: 460,\n  damping: 30,\n  mass: 0.55,\n} as const;\n\n/** Overlay panel entrances - modals and sheets summoned by pointer. */\nexport const SPRING_PANEL = {\n  type: \"spring\",\n  stiffness: 420,\n  damping: 40,\n  mass: 0.5,\n} as const;\n\n/** Shared-layout glides - pills, indicators and panels morphing between positions. */\nexport const SPRING_LAYOUT = {\n  type: \"spring\",\n  stiffness: 360,\n  damping: 32,\n  mass: 0.6,\n} as const;\n\n/** Cursor-follow physics for decorative mouse tracking (magnetic, tilt, dock). */\nexport const SPRING_MOUSE = {\n  stiffness: 200,\n  damping: 15,\n  mass: 0.3,\n} as const;\n\n/** Dragged handles and fills (sliders) - critically damped `useSpring` config,\n * so the value follows the pointer butterily and never rebounds off an end. */\nexport const SPRING_GLIDE = {\n  stiffness: 700,\n  damping: 50,\n  mass: 0.5,\n} as const;\n\n/** Shared-surface morphs: a trigger growing into its panel and back on one\n * weighted spring, so opening and closing travel the same path. */\nexport const SPRING_MORPH = {\n  type: \"spring\",\n  duration: 0.5,\n  bounce: 0.22,\n} as const;\n"},{"path":"lib/hooks/use-status-open.ts","type":"util","content":"\"use client\";\n\nimport { useEffect, useLayoutEffect, useRef, useState } from \"react\";\nimport { useControllable } from \"@/lib/hooks/use-controllable\";\n\n/**\n * Open state for a disclosure that opens or closes itself when a status\n * changes: a tool result that opens while it runs, a todo list that folds\n * when the work completes. Controlled through `open`, or uncontrolled from\n * `defaultOpen`.\n *\n * `decide(previous, next)` runs in the render that first sees a new status\n * and returns `true` to open, `false` to close, or `undefined` to leave it.\n * An uncontrolled panel flips in that same render, so it never shows one\n * commit in the old state. Telling the consumer through `onOpenChange` is a\n * side effect, so it waits for the commit.\n */\nexport function useStatusOpen<Status>({\n  status,\n  initialStatus = status,\n  decide,\n  open,\n  defaultOpen,\n  onOpenChange,\n}: {\n  status: Status;\n  /**\n   * The status to treat as already seen at mount. Defaults to `status`, so\n   * mounting is not a change; pass another value to let the first render\n   * count as one.\n   */\n  initialStatus?: Status;\n  decide: (previous: Status, next: Status) => boolean | undefined;\n  open?: boolean;\n  defaultOpen: boolean;\n  onOpenChange?: (open: boolean) => void;\n}) {\n  const [currentOpen, setOpen, setInternal] = useControllable(open, defaultOpen, onOpenChange);\n  const [seenStatus, setSeenStatus] = useState(initialStatus);\n  const [request, setRequest] = useState<{ open: boolean; from: boolean } | null>(null);\n\n  if (status !== seenStatus) {\n    setSeenStatus(status);\n    const wanted = decide(seenStatus, status);\n    if (wanted !== undefined) {\n      if (open === undefined) setInternal(wanted);\n      setRequest({ open: wanted, from: currentOpen });\n    }\n  }\n\n  const notify = useRef(onOpenChange);\n  useLayoutEffect(() => {\n    notify.current = onOpenChange;\n  });\n  useEffect(() => {\n    if (request && request.open !== request.from) notify.current?.(request.open);\n  }, [request]);\n\n  return [currentOpen, setOpen] as const;\n}\n"},{"path":"lib/i18n.tsx","type":"util","content":"\"use client\";\n\nimport {\n  createContext,\n  type ReactNode,\n  useCallback,\n  useContext,\n  useMemo,\n} from \"react\";\n\n/**\n * A component's messages. Plain strings with `{name}` placeholders, so a\n * dictionary stays JSON-serializable and can be passed from a server layout.\n * There are no plural forms: write messages that read correctly for any count.\n */\nexport type Messages = Record<string, string>;\n\n/** A language file: component namespace → any subset of that component's messages. */\nexport type LocaleMessages = Record<string, Partial<Messages>>;\n\ntype LocaleContextValue = {\n  locale?: string;\n  messages: LocaleMessages;\n};\n\nconst NO_MESSAGES: LocaleMessages = {};\n\nconst LocaleContext = createContext<LocaleContextValue>({ messages: NO_MESSAGES });\n\n/** Without a locale, digits stay plain so server and client render the same text. */\nexport function formatNumber(value: number, locale?: string) {\n  return locale ? new Intl.NumberFormat(locale).format(value) : String(value);\n}\n\nexport interface LocaleProviderProps {\n  /** BCP 47 tag, e.g. `de`, `pt-BR`. Drives `Intl` number formatting. */\n  locale: string;\n  /**\n   * Component namespace → translated strings. Missing keys fall back to English.\n   * Pass a stable object (a module constant, imported JSON or a memoized value):\n   * a new object each render gives every translated component a new `t`.\n   */\n  messages?: LocaleMessages;\n  children: ReactNode;\n}\n\nexport function LocaleProvider({ locale, messages = NO_MESSAGES, children }: LocaleProviderProps) {\n  const value = useMemo(() => ({ locale, messages }), [locale, messages]);\n  return <LocaleContext.Provider value={value}>{children}</LocaleContext.Provider>;\n}\n\nexport function useLocale(): { locale?: string } {\n  return { locale: useContext(LocaleContext).locale };\n}\n\n/**\n * Resolves a component's strings: `labels` prop, then the provider's\n * messages for `namespace`, then the component's English `defaults`.\n * Numbers passed as values are formatted for the provider's locale.\n */\nexport function useMessages<T extends Messages>(\n  namespace: string,\n  defaults: T,\n  labels?: Partial<T>,\n) {\n  const { locale, messages } = useContext(LocaleContext);\n  const provided = messages[namespace];\n  // Inline `labels={{ … }}` is a new object every render. Keying it by content\n  // keeps `t` one identity until a label changes, so effects and memos that\n  // depend on `t` don't re-run per render, and render-time reads never lag.\n  const labelsKey = labels ? JSON.stringify(labels) : \"\";\n  const stableLabels = useMemo(\n    () => (labelsKey ? (JSON.parse(labelsKey) as Partial<T>) : undefined),\n    [labelsKey],\n  );\n\n  return useCallback(\n    (key: keyof T & string, values?: Record<string, string | number>) => {\n      const template = stableLabels?.[key] ?? provided?.[key] ?? defaults[key];\n      if (!values) return template;\n      return template.replace(/\\{(\\w+)\\}/g, (match, name: string) => {\n        const value = values[name];\n        if (value === undefined) return match;\n        return typeof value === \"number\" ? formatNumber(value, locale) : value;\n      });\n    },\n    [defaults, stableLabels, locale, provided],\n  );\n}\n"},{"path":"lib/utils.ts","type":"util","content":"import { clsx, type ClassValue } from \"clsx\"\nimport { twMerge } from \"tailwind-merge\"\n\nexport function cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs))\n}\n"},{"path":"components/motion/action-swap.tsx","type":"util","content":"\"use client\";\n\nimport { AnimatePresence, type HTMLMotionProps, motion, useReducedMotion, type Variants } from \"motion/react\";\nimport type { ReactNode } from \"react\";\nimport { useState } from \"react\";\nimport { EASE_OUT, SPRING_LAYOUT, SPRING_PRESS, SPRING_SWAP } from \"@/lib/ease\";\nimport { cn } from \"@/lib/utils\";\n\nexport type ActionSwapItem = {\n  /** Unique key, used as the button's value. */\n  id: string;\n  /** Text shown on the button while this item is active. Hidden when `iconOnly`. */\n  label: ReactNode;\n  /** Icon shown before the label while this item is active. */\n  icon?: ReactNode;\n  /** Accessible name while active. Falls back to a string label when `iconOnly`. */\n  ariaLabel?: string;\n};\n\nexport type ActionSwapButtonVariant = \"primary\" | \"secondary\" | \"outline\" | \"ghost\";\nexport type ActionSwapButtonSize = \"sm\" | \"md\" | \"lg\" | \"icon\";\nexport type ActionSwapAnimation = \"blur\" | \"roll\" | \"cascade\";\n\n/** Animations with a single-element variant set (cascade animates per letter). */\ntype CoreAnimation = \"blur\" | \"roll\";\n\nexport interface ActionSwapButtonProps extends Omit<\n  HTMLMotionProps<\"button\">,\n  \"children\" | \"onChange\"\n> {\n  /** States the button steps through, each with a label and optional icon. */\n  items: ActionSwapItem[];\n  /** The id of the shown item, for controlled use. */\n  value?: string;\n  /** The initial item id when uncontrolled. Default: the first item. */\n  defaultValue?: string;\n  /** Called with the next item's id and the item when a press advances it. */\n  onValueChange?: (value: string, item: ActionSwapItem) => void;\n  /** Visual style of the button. Default: \"secondary\" */\n  variant?: ActionSwapButtonVariant;\n  /** Button height and padding. Default: \"md\" */\n  size?: ActionSwapButtonSize;\n  /** How the label and icon swap between items. Default: \"blur\" */\n  animation?: ActionSwapAnimation;\n  /** Show only the icon and use the label as the accessible name. Default: true for size \"icon\" */\n  iconOnly?: boolean;\n  /** Advance to the next item on each press, wrapping at the end. Default: true */\n  cycle?: boolean;\n}\n\nexport interface ActionSwapTextProps {\n  /** Key for the current text; a new value plays the swap. */\n  value: string;\n  children: ReactNode;\n  /** How the old text leaves and the new text enters. Default: \"blur\" */\n  animation?: ActionSwapAnimation;\n  /** Classes merged onto the root element. */\n  className?: string;\n}\n\nexport interface ActionSwapIconProps {\n  /** Key for the current icon; a new value plays the swap. */\n  value: string;\n  children: ReactNode;\n  /** How the old icon leaves and the new one enters. \"cascade\" plays as \"roll\". Default: \"blur\" */\n  animation?: ActionSwapAnimation;\n  /** Classes merged onto the root element. */\n  className?: string;\n}\n\n// The arriving layer springs in, so a second press mid-swap bends it toward\n// the new target instead of restarting. The leaving layer is a little quicker,\n// still long enough to cross the arrival so the swap reads as one morph.\nconst BLUR_TRANSITION = SPRING_SWAP;\nconst BLUR_EXIT_TRANSITION = { duration: 0.16, ease: EASE_OUT } as const;\nconst ROLL_TRANSITION = SPRING_SWAP;\nconst ROLL_EXIT_TRANSITION = { duration: 0.14, ease: EASE_OUT } as const;\n// A light blur softens the crossing without smearing small glyphs.\nconst SWAP_BLUR = \"blur(2px)\";\nconst ROLL_BLUR = \"blur(3px)\";\n\n// Cascade rolls the label one letter at a time, left to right. The leaving\n// and landing strings overlap as independent layers (no shared cells), so\n// proportional glyph widths never jitter. Exits cascade at half the enter\n// stagger so the tail of the old label lingers briefly.\nconst CASCADE_STAGGER = 0.025;\n\nconst CASCADE_LETTER_VARIANTS: Variants = {\n  initial: { opacity: 0, y: \"105%\", filter: ROLL_BLUR },\n  animate: (delay: number = 0) => ({\n    opacity: 1,\n    y: \"0%\",\n    filter: \"blur(0px)\",\n    transition: { ...SPRING_SWAP, delay },\n  }),\n  exit: (delay: number = 0) => ({\n    opacity: 0,\n    y: \"-105%\",\n    filter: ROLL_BLUR,\n    transition: { duration: 0.16, ease: EASE_OUT, delay: delay * 0.5 },\n  }),\n};\n\nconst TEXT_VARIANTS: Record<CoreAnimation, Variants> = {\n  blur: {\n    initial: { opacity: 0, scale: 0.9, filter: SWAP_BLUR },\n    animate: {\n      opacity: 1,\n      scale: 1,\n      filter: \"blur(0px)\",\n      transition: BLUR_TRANSITION,\n    },\n    exit: {\n      opacity: 0,\n      scale: 0.96,\n      filter: SWAP_BLUR,\n      transition: BLUR_EXIT_TRANSITION,\n    },\n  },\n  roll: {\n    initial: { opacity: 0, y: \"90%\", filter: ROLL_BLUR },\n    animate: {\n      opacity: 1,\n      y: \"0%\",\n      filter: \"blur(0px)\",\n      transition: ROLL_TRANSITION,\n    },\n    exit: {\n      opacity: 0,\n      y: \"-90%\",\n      filter: ROLL_BLUR,\n      transition: ROLL_EXIT_TRANSITION,\n    },\n  },\n};\n\nconst ICON_VARIANTS: Record<CoreAnimation, Variants> = {\n  blur: {\n    initial: { opacity: 0, scale: 0.25, filter: SWAP_BLUR },\n    animate: {\n      opacity: 1,\n      scale: 1,\n      filter: \"blur(0px)\",\n      transition: BLUR_TRANSITION,\n    },\n    exit: {\n      opacity: 0,\n      scale: 0.25,\n      filter: SWAP_BLUR,\n      transition: BLUR_EXIT_TRANSITION,\n    },\n  },\n  roll: {\n    initial: { opacity: 0, y: 12, filter: ROLL_BLUR },\n    animate: {\n      opacity: 1,\n      y: 0,\n      filter: \"blur(0px)\",\n      transition: ROLL_TRANSITION,\n    },\n    exit: {\n      opacity: 0,\n      y: -12,\n      filter: ROLL_BLUR,\n      transition: ROLL_EXIT_TRANSITION,\n    },\n  },\n};\n\nconst VARIANT_CLASS: Record<ActionSwapButtonVariant, string> = {\n  primary: \"bg-primary text-primary-foreground hover:bg-primary/90\",\n  secondary: \"border border-border bg-card text-foreground hover:border-border\",\n  outline: \"border border-border bg-transparent text-foreground hover:bg-muted/60\",\n  ghost: \"text-muted-foreground hover:bg-muted/60 hover:text-foreground\",\n};\n\nconst SIZE_CLASS: Record<ActionSwapButtonSize, string> = {\n  sm: \"h-8 gap-1.5 rounded-full px-3 text-xs\",\n  md: \"h-10 gap-2 rounded-full px-4 text-sm\",\n  lg: \"h-12 gap-2.5 rounded-full px-5 text-base\",\n  icon: \"h-10 w-10 rounded-full\",\n};\n\nexport function ActionSwapText({\n  value,\n  children,\n  animation = \"blur\",\n  className,\n}: ActionSwapTextProps) {\n  const reduce = useReducedMotion();\n\n  // Cascade needs a plain string to split into letters; non-string content\n  // and reduced motion fall back to the closest single-element animation.\n  const label = typeof children === \"string\" ? children : null;\n  const cascade = animation === \"cascade\" && label !== null && !reduce;\n  const coreAnimation: CoreAnimation =\n    animation === \"cascade\" ? \"roll\" : animation;\n\n  return (\n    <span\n      className={cn(\n        \"relative -my-[0.08em] inline-block max-w-full whitespace-nowrap py-[0.08em] align-bottom\",\n        className,\n      )}\n      style={{\n        clipPath: \"inset(0 -999px)\",\n        WebkitClipPath: \"inset(0 -999px)\",\n      }}\n    >\n      <span\n        aria-hidden\n        className=\"invisible inline-block whitespace-nowrap\"\n      >\n        {cascade\n          ? label.split(\"\").map((char, index) => (\n              <span\n                // biome-ignore lint/suspicious/noArrayIndexKey: position is the slot identity.\n                key={index}\n                className=\"inline-block whitespace-pre\"\n              >\n                {char}\n              </span>\n            ))\n          : children}\n      </span>\n      {cascade ? (\n        <>\n          {/* Letters are decorative fragments; readers get the whole label. */}\n          <span className=\"sr-only\">{label}</span>\n          <AnimatePresence initial={false}>\n            <motion.span\n              key={`cascade-${value}`}\n              aria-hidden\n              initial=\"initial\"\n              animate=\"animate\"\n              exit=\"exit\"\n              className=\"absolute left-0 top-[0.08em] inline-block whitespace-pre\"\n            >\n              {label.split(\"\").map((char, i) => (\n                <motion.span\n                  // biome-ignore lint/suspicious/noArrayIndexKey: position is the slot identity - the letter at a position is exactly what rolls.\n                  key={i}\n                  custom={i * CASCADE_STAGGER}\n                  variants={CASCADE_LETTER_VARIANTS}\n                  // Own states: a label that swaps away and straight back\n                  // re-enters mid-exit, and only owned targets are restored.\n                  initial=\"initial\"\n                  animate=\"animate\"\n                  exit=\"exit\"\n                  className=\"inline-block whitespace-pre will-change-[opacity,filter,transform]\"\n                >\n                  {char}\n                </motion.span>\n              ))}\n            </motion.span>\n          </AnimatePresence>\n        </>\n      ) : (\n        <AnimatePresence initial={false}>\n          <motion.span\n            key={`${animation}-${value}`}\n            variants={TEXT_VARIANTS[coreAnimation]}\n            initial={reduce ? false : \"initial\"}\n            animate={reduce ? { opacity: 1, filter: \"blur(0px)\", scale: 1, y: 0 } : \"animate\"}\n            exit={reduce ? undefined : \"exit\"}\n            // Truncation lives on the layer that holds the text - the layer\n            // moves as a whole, so clipping it never eats the roll.\n            className=\"absolute left-0 top-[0.08em] inline-block max-w-full truncate will-change-[opacity,filter,transform]\"\n          >\n            {children}\n          </motion.span>\n        </AnimatePresence>\n      )}\n    </span>\n  );\n}\n\nexport function ActionSwapIcon({\n  value,\n  children,\n  animation = \"blur\",\n  className,\n}: ActionSwapIconProps) {\n  const reduce = useReducedMotion();\n  // Icons are single elements - cascade maps to its closest motion, roll.\n  const coreAnimation: CoreAnimation =\n    animation === \"cascade\" ? \"roll\" : animation;\n\n  return (\n    <span className={cn(\"relative inline-grid shrink-0 place-items-center overflow-hidden\", className)}>\n      <AnimatePresence mode=\"popLayout\" initial={false}>\n        <motion.span\n          key={`${animation}-${value}`}\n          aria-hidden\n          variants={ICON_VARIANTS[coreAnimation]}\n          initial={reduce ? false : \"initial\"}\n          animate={reduce ? { opacity: 1, filter: \"blur(0px)\", scale: 1, y: 0 } : \"animate\"}\n          exit={reduce ? undefined : \"exit\"}\n          className=\"col-start-1 row-start-1 inline-flex items-center justify-center will-change-[opacity,filter,transform]\"\n        >\n          {children}\n        </motion.span>\n      </AnimatePresence>\n    </span>\n  );\n}\n\nexport function ActionSwapButton({\n  items,\n  value,\n  defaultValue,\n  onValueChange,\n  variant = \"secondary\",\n  size = \"md\",\n  animation = \"blur\",\n  iconOnly = size === \"icon\",\n  cycle = true,\n  className,\n  disabled,\n  onClick,\n  style,\n  ...rest\n}: ActionSwapButtonProps) {\n  const reduce = useReducedMotion();\n  const [internalValue, setInternalValue] = useState(defaultValue ?? items[0]?.id);\n  const currentValue = value ?? internalValue;\n  const activeIndex = Math.max(0, items.findIndex((item) => item.id === currentValue));\n  const activeItem = items[activeIndex] ?? items[0];\n  const hasIcon = items.some((item) => item.icon);\n  const nextItem = cycle && items.length > 0 ? items[(activeIndex + 1) % items.length] : undefined;\n\n  if (!activeItem) return null;\n\n  const accessibleLabel = activeItem.ariaLabel ?? (iconOnly && typeof activeItem.label === \"string\" ? activeItem.label : undefined);\n  const layoutTransition = reduce ? { duration: 0 } : SPRING_LAYOUT;\n\n  return (\n    <motion.button\n      type=\"button\"\n      disabled={disabled}\n      // A label of a different length resizes the button: glide the width on\n      // the soft layout spring, and only when the value changes, so unrelated\n      // page reflow never animates the button.\n      layout\n      layoutDependency={activeItem.id}\n      whileTap={reduce || disabled ? undefined : { scale: 0.97 }}\n      transition={{ ...SPRING_PRESS, layout: layoutTransition }}\n      // Layout animations only correct a radius set inline.\n      style={{ borderRadius: 9999, ...style }}\n      className={cn(\n        \"inline-flex items-center justify-center overflow-hidden font-medium transition-colors\",\n        \"disabled:pointer-events-none disabled:opacity-50\",\n        VARIANT_CLASS[variant],\n        SIZE_CLASS[size],\n        className,\n      )}\n      aria-label={accessibleLabel}\n      onClick={(event) => {\n        onClick?.(event);\n        if (event.defaultPrevented || disabled || !cycle || !nextItem) return;\n        if (value === undefined) setInternalValue(nextItem.id);\n        onValueChange?.(nextItem.id, nextItem);\n      }}\n      {...rest}\n    >\n      {/* Position-only layout keeps the contents from stretching with the\n          button while its width glides. */}\n      {hasIcon ? (\n        <motion.span\n          layout=\"position\"\n          layoutDependency={activeItem.id}\n          transition={layoutTransition}\n          className=\"inline-flex shrink-0\"\n        >\n          <ActionSwapIcon value={activeItem.id} animation={animation} className=\"h-4 w-4\">\n            {activeItem.icon ?? null}\n          </ActionSwapIcon>\n        </motion.span>\n      ) : null}\n      {!iconOnly ? (\n        <motion.span\n          layout=\"position\"\n          layoutDependency={activeItem.id}\n          transition={layoutTransition}\n          className=\"inline-flex min-w-0 max-w-full\"\n        >\n          <ActionSwapText value={activeItem.id} animation={animation}>\n            {activeItem.label}\n          </ActionSwapText>\n        </motion.span>\n      ) : null}\n    </motion.button>\n  );\n}\n"},{"path":"lib/hooks/use-controllable.ts","type":"util","content":"\"use client\";\n\nimport { useCallback, useLayoutEffect, useRef, useState } from \"react\";\n\n/**\n * A value that is controlled when `value` is defined and uncontrolled\n * otherwise. Returns the current value, a setter whose identity never changes,\n * and the raw internal setter for callers that resolve state during render.\n *\n * The setter calls `onChange` only when the value actually changes, so a\n * consumer is never told about a no-op.\n */\nexport function useControllable<T>(\n  value: T | undefined,\n  defaultValue: T,\n  onChange?: (next: T) => void,\n) {\n  const [internal, setInternal] = useState(defaultValue);\n  const latest = useRef({ value, internal, onChange });\n  useLayoutEffect(() => {\n    latest.current = { value, internal, onChange };\n  });\n  const set = useCallback((next: T) => {\n    const current = latest.current;\n    if (current.value === undefined) setInternal(next);\n    if ((current.value === undefined ? current.internal : current.value) !== next)\n      current.onChange?.(next);\n  }, []);\n  return [value === undefined ? internal : value, set, setInternal] as const;\n}\n"},{"path":"components/previews/agents/todo-list.preview.tsx","type":"preview","content":"\"use client\";\n\nimport { RotateCcw } from \"lucide-react\";\nimport { useEffect, useRef, useState } from \"react\";\nimport {\n  type TodoItem,\n  TodoList,\n} from \"@/components/agents/todo-list\";\n\nconst TASKS = [\n  \"Inspect the current data flow\",\n  \"Update the response schema\",\n  \"Add coverage for edge cases\",\n  \"Run checks and prepare the result\",\n];\n\nconst TICKS_PER_TASK = 4;\n\nfunction itemsAtStep(step: number): TodoItem[] {\n  return TASKS.map((title, index) => ({\n    id: `task-${index}`,\n    title,\n    status:\n      step >= (index + 1) * TICKS_PER_TASK\n        ? \"completed\"\n        : step >= index * TICKS_PER_TASK\n          ? \"in-progress\"\n          : \"pending\",\n    progress:\n      step >= index * TICKS_PER_TASK &&\n      step < (index + 1) * TICKS_PER_TASK\n        ? ((step % TICKS_PER_TASK) + 1) * 25\n        : undefined,\n    detail:\n      step >= index * TICKS_PER_TASK &&\n      step < (index + 1) * TICKS_PER_TASK\n        ? `${((step % TICKS_PER_TASK) + 1) * 25}%`\n        : undefined,\n  }));\n}\n\nfunction TodoRun() {\n  const [step, setStep] = useState(0);\n  const timer = useRef<number | undefined>(undefined);\n\n  useEffect(() => {\n    if (step >= TASKS.length * TICKS_PER_TASK) return;\n    timer.current = window.setTimeout(() => setStep((value) => value + 1), 280);\n    return () => {\n      if (timer.current) window.clearTimeout(timer.current);\n    };\n  }, [step]);\n\n  return <TodoList items={itemsAtStep(step)} title=\"Implementation plan\" />;\n}\n\nexport function TodoListPreview() {\n  const [run, setRun] = useState(0);\n\n  return (\n    <div className=\"relative h-[330px] w-full max-w-lg\">\n      <TodoRun key={run} />\n      <button\n        type=\"button\"\n        onClick={() => setRun((value) => value + 1)}\n        className=\"absolute bottom-0 left-0 inline-flex items-center gap-1.5 rounded-full px-2 py-1 text-xs font-medium text-muted-foreground outline-none transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring\"\n      >\n        <RotateCcw className=\"size-3\" />\n        Replay\n      </button>\n    </div>\n  );\n}\n"}]}