{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "agent-chat-04",
  "title": "Voice mode",
  "description": "A voice call whose disc breathes with whoever speaks while the page beside it fills in: notes as they are said, to-dos with an owner and a date, and the ones the assistant does tick themselves, with Undo.",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "https://ui.ndekocode.dev/r/avatar.json",
    "https://ui.ndekocode.dev/r/button.json",
    "https://ui.ndekocode.dev/r/chat-motion.json",
    "https://ui.ndekocode.dev/r/copy-button.json",
    "https://ui.ndekocode.dev/r/demonstration.json",
    "https://ui.ndekocode.dev/r/drawn-check.json",
    "https://ui.ndekocode.dev/r/icons.json",
    "https://ui.ndekocode.dev/r/live-duration.json",
    "https://ui.ndekocode.dev/r/live-region.json",
    "https://ui.ndekocode.dev/r/media-clock.json",
    "https://ui.ndekocode.dev/r/morph-button.json",
    "https://ui.ndekocode.dev/r/motion-presets.json",
    "https://ui.ndekocode.dev/r/replay-button.json",
    "https://ui.ndekocode.dev/r/speech-envelope.json",
    "https://ui.ndekocode.dev/r/theme.json",
    "https://ui.ndekocode.dev/r/use-prefers-reduced-motion.json",
    "https://ui.ndekocode.dev/r/use-session.json",
    "https://ui.ndekocode.dev/r/use-timeouts.json",
    "https://ui.ndekocode.dev/r/utils.json"
  ],
  "files": [
    {
      "path": "registry/ndeko/blocks/agent-chat/agent-chat-04/index.tsx",
      "content": "'use client';\n\nimport { useSession } from '@/registry/ndeko/hooks/use-session';\nimport { useTimeouts } from '@/registry/ndeko/hooks/use-timeouts';\nimport { spokenUnless } from '@/registry/ndeko/lib/demonstration';\nimport { ClockGate } from '@/registry/ndeko/ui/live-duration';\nimport { LiveRegion } from '@/registry/ndeko/ui/live-region';\nimport { ReplayButton } from '@/registry/ndeko/ui/replay-button';\n\nimport { CallPanel, discModeOf } from './call-panel';\nimport { CALL_TITLE, NOTES, TODOS, TRANSCRIPT } from './data';\nimport { NotesPage } from './notes-page';\nimport {\n  INITIAL,\n  LOOP_AFTER_MS,\n  reducer,\n  RESTING,\n  SCRIPT,\n  SHARE_MS,\n  type CallStatus,\n} from './session';\n\nconst SESSION = {\n  reducer,\n  initial: INITIAL,\n  resting: RESTING,\n  script: SCRIPT,\n  loopAfter: LOOP_AFTER_MS,\n};\n\nfunction announcementOf(status: CallStatus, latestTodo: string | undefined) {\n  if (status === 'ended') {\n    return 'Call ended. The page is now a summary you can copy or share.';\n  }\n  if (latestTodo) {\n    return `To-do added: ${latestTodo}`;\n  }\n  return '';\n}\n\nexport default function AgentChat04() {\n  const { ref, isInView, isAutoplaying, state, act, pressed, restart } =\n    useSession(SESSION);\n  const { schedule } = useTimeouts();\n  const lines = TRANSCRIPT.slice(0, state.linesShown);\n  const notes = NOTES.slice(0, state.notesShown);\n  const todos = TODOS.slice(0, state.todosShown);\n  const latestLine = lines.at(-1);\n  const speaker = latestLine?.speaker ?? null;\n  const mode = discModeOf(state.status, state.isMuted, speaker);\n  const isEnded = state.status === 'ended';\n  const latestTodo = todos.at(-1)?.text;\n  const announcement = announcementOf(state.status, latestTodo);\n  const message = spokenUnless(isAutoplaying, announcement);\n  const canCallAgain = isEnded && !isAutoplaying;\n\n  function share() {\n    act({ type: 'sharing' });\n    schedule(() => act({ type: 'shared' }), SHARE_MS);\n  }\n\n  return (\n    <ClockGate isActive={isInView}>\n      <div\n        ref={ref}\n        className='bg-background text-foreground @container min-h-dvh w-full p-3 @3xl:p-6'\n      >\n        <div className='mx-auto flex max-w-5xl flex-col gap-3 @3xl:flex-row @3xl:items-start'>\n          <div className='@3xl:w-80 @3xl:shrink-0'>\n            <CallPanel\n              title={CALL_TITLE}\n              status={state.status}\n              mode={mode}\n              isMuted={state.isMuted}\n              lines={lines}\n              startedAt={state.startedAt}\n              endedAt={state.endedAt}\n              isActive={isInView}\n              pressed={pressed}\n              onToggleMute={() => act({ type: 'muted' })}\n              onEnd={() => act({ type: 'ended' })}\n              footer={\n                <ReplayButton\n                  isShown={canCallAgain}\n                  onReplay={restart}\n                  label='Call again'\n                />\n              }\n            />\n          </div>\n          <NotesPage\n            title={CALL_TITLE}\n            notes={notes}\n            todos={todos}\n            doneBy={state.doneBy}\n            isEnded={isEnded}\n            share={state.share}\n            onToggleTodo={(id) => act({ type: 'toggled', id })}\n            onShare={share}\n          />\n        </div>\n        <LiveRegion message={message} />\n      </div>\n    </ClockGate>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/agent-chat-04/index.tsx"
    },
    {
      "path": "registry/ndeko/blocks/agent-chat/agent-chat-04/call-panel.tsx",
      "content": "'use client';\n\nimport { AnimatePresence, motion } from 'motion/react';\nimport { useEffect, useRef } from 'react';\n\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport {\n  AudioLinesIcon,\n  MicIcon,\n  MicOffIcon,\n  PhoneOffIcon,\n} from '@/registry/ndeko/lib/icons';\nimport { formatClock, spokenClockOf } from '@/registry/ndeko/lib/media-clock';\nimport { rowPresenceOf } from '@/registry/ndeko/lib/motion-presets';\nimport { speechLevelAt } from '@/registry/ndeko/lib/speech-envelope';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { Button } from '@/registry/ndeko/ui/button';\nimport { Swap } from '@/registry/ndeko/ui/chat-motion';\nimport { useLiveNow } from '@/registry/ndeko/ui/live-duration';\n\nimport type { Speaker, TranscriptLine } from './data';\nimport type { CallStatus } from './session';\n\nexport type DiscMode =\n  'connecting' | 'listening' | 'speaking' | 'muted' | 'ended';\n\nconst MODE_WORD: Record<DiscMode, string> = {\n  connecting: 'Connecting',\n  listening: 'Listening',\n  speaking: 'Speaking',\n  muted: 'Muted',\n  ended: 'Call ended',\n};\n\nconst MODE_INTENSITY: Record<DiscMode, number> = {\n  connecting: 0,\n  listening: 0.65,\n  speaking: 1,\n  muted: 0.04,\n  ended: 0,\n};\n\n/** How much of the gap to the new level is closed on each frame, so the disc breathes instead of jumping. */\nconst LEVEL_EASING = 0.16;\n\nconst HALO_REACH = 0.22;\n\nconst OUTER_REACH = 0.42;\n\nexport function discModeOf(\n  status: CallStatus,\n  isMuted: boolean,\n  speaker: Speaker | null\n): DiscMode {\n  if (status === 'ended') {\n    return 'ended';\n  }\n  if (status === 'ringing') {\n    return 'connecting';\n  }\n  if (isMuted) {\n    return 'muted';\n  }\n  if (speaker === 'assistant') {\n    return 'speaking';\n  }\n  return 'listening';\n}\n\nfunction ModeGlyph({ mode }: { mode: DiscMode }) {\n  if (mode === 'speaking') {\n    return <AudioLinesIcon className='size-7' />;\n  }\n  if (mode === 'muted') {\n    return <MicOffIcon className='size-7' />;\n  }\n  if (mode === 'ended') {\n    return <PhoneOffIcon className='size-7' />;\n  }\n  return <MicIcon className='size-7' />;\n}\n\nfunction coreToneOf(mode: DiscMode) {\n  const isQuiet = mode === 'ended' || mode === 'muted';\n  if (isQuiet) {\n    return '[--gem:var(--muted-foreground)]';\n  }\n  return '[--gem:var(--primary)]';\n}\n\ntype VoiceDiscProps = {\n  mode: DiscMode;\n  /** False while the block is off screen or the call is over: the disc stops drawing. */\n  isActive: boolean;\n};\n\n/** The level is written to the two halos on each frame, so React never re-renders for it. */\nexport function VoiceDisc({ mode, isActive }: VoiceDiscProps) {\n  const haloRef = useRef<HTMLSpanElement>(null);\n  const outerRef = useRef<HTMLSpanElement>(null);\n  const intensityRef = useRef(MODE_INTENSITY[mode]);\n  const shouldReduceMotion = usePrefersReducedMotion();\n\n  useEffect(() => {\n    intensityRef.current = MODE_INTENSITY[mode];\n  }, [mode]);\n\n  useEffect(() => {\n    const halo = haloRef.current;\n    const outer = outerRef.current;\n    const shouldDraw = isActive && !shouldReduceMotion;\n    if (!shouldDraw) {\n      return;\n    }\n    if (!halo || !outer) {\n      return;\n    }\n    const startedAt = performance.now();\n    let level = 0;\n    let frame = 0;\n\n    function draw(now: number) {\n      if (!halo || !outer) {\n        return;\n      }\n      const voice = speechLevelAt(now - startedAt, 2.4);\n      const target = voice * intensityRef.current;\n      level += (target - level) * LEVEL_EASING;\n      const haloScale = 1 + level * HALO_REACH;\n      const outerScale = 1 + level * OUTER_REACH;\n      halo.style.transform = `scale(${haloScale})`;\n      outer.style.transform = `scale(${outerScale})`;\n      frame = requestAnimationFrame(draw);\n    }\n\n    frame = requestAnimationFrame(draw);\n    return () => {\n      cancelAnimationFrame(frame);\n      halo.style.transform = '';\n      outer.style.transform = '';\n    };\n  }, [isActive, shouldReduceMotion]);\n\n  return (\n    <div className='relative flex size-32 shrink-0 items-center justify-center @3xl:size-40'>\n      <span\n        ref={outerRef}\n        aria-hidden='true'\n        className='bg-primary/[0.07] absolute inset-4 rounded-full'\n      />\n      <span\n        ref={haloRef}\n        aria-hidden='true'\n        className='bg-primary/[0.12] absolute inset-7 rounded-full'\n      />\n      <span\n        className={cn(\n          'gem-plate relative flex size-16 items-center justify-center rounded-full transition-[background-image] duration-300 @3xl:size-20',\n          coreToneOf(mode)\n        )}\n      >\n        <Swap swapKey={mode}>\n          <ModeGlyph mode={mode} />\n        </Swap>\n      </span>\n    </div>\n  );\n}\n\nfunction elapsedOfCall(\n  startedAt: number | null,\n  endedAt: number | null,\n  now: number\n) {\n  if (startedAt === null) {\n    return 0;\n  }\n  const end = endedAt ?? now;\n  return Math.max(0, end - startedAt);\n}\n\ntype CallClockProps = {\n  startedAt: number | null;\n  endedAt: number | null;\n};\n\n/** Only this text re-renders each second. */\nfunction CallClock({ startedAt, endedAt }: CallClockProps) {\n  const isRunning = startedAt !== null && endedAt === null;\n  const now = useLiveNow(1000, isRunning);\n  const elapsed = elapsedOfCall(startedAt, endedAt, now);\n\n  return (\n    <span className='text-muted-foreground inline-block w-10 text-center text-[13px] tabular-nums'>\n      <span aria-hidden='true'>{formatClock(elapsed)}</span>\n      <span className='sr-only'>{spokenClockOf(elapsed)}</span>\n    </span>\n  );\n}\n\nconst SPEAKER_WORD: Record<Speaker, string> = {\n  person: 'You',\n  assistant: 'Assistant',\n};\n\nfunction lineToneOf(isLatest: boolean) {\n  if (isLatest) {\n    return 'opacity-100';\n  }\n  return 'opacity-45';\n}\n\nfunction Transcript({ lines }: { lines: TranscriptLine[] }) {\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const rowPresence = rowPresenceOf(shouldReduceMotion);\n  const recent = lines.slice(-3);\n  const latest = recent.at(-1);\n\n  return (\n    <div className='flex h-36 w-full flex-col justify-end overflow-hidden'>\n      {recent.length === 0 && (\n        <p className='text-muted-foreground m-auto text-center text-[13px]'>\n          What is said shows up here\n        </p>\n      )}\n      <ol aria-label='Transcript' className='flex flex-col'>\n        <AnimatePresence initial={false}>\n          {recent.map((line) => (\n            <motion.li\n              key={line.id}\n              className='overflow-hidden'\n              {...rowPresence}\n            >\n              <p\n                className={cn(\n                  'pb-2 text-[13px] leading-snug transition-opacity duration-300',\n                  lineToneOf(line === latest)\n                )}\n              >\n                <span className='text-muted-foreground'>\n                  {SPEAKER_WORD[line.speaker]}\n                </span>{' '}\n                {line.text}\n              </p>\n            </motion.li>\n          ))}\n        </AnimatePresence>\n      </ol>\n    </div>\n  );\n}\n\nfunction muteLabelOf(isMuted: boolean) {\n  if (isMuted) {\n    return 'Unmute';\n  }\n  return 'Mute';\n}\n\nfunction pressedDestructiveOf(isPressed: boolean) {\n  if (isPressed) {\n    return 'scale-[0.94] bg-destructive/85';\n  }\n  return undefined;\n}\n\ntype CallPanelProps = {\n  title: string;\n  status: CallStatus;\n  mode: DiscMode;\n  isMuted: boolean;\n  lines: TranscriptLine[];\n  startedAt: number | null;\n  endedAt: number | null;\n  isActive: boolean;\n  pressed: string | null;\n  onToggleMute: () => void;\n  onEnd: () => void;\n  footer?: React.ReactNode;\n};\n\nexport function CallPanel({\n  title,\n  status,\n  mode,\n  isMuted,\n  lines,\n  startedAt,\n  endedAt,\n  isActive,\n  pressed,\n  onToggleMute,\n  onEnd,\n  footer,\n}: CallPanelProps) {\n  const isLive = status === 'live';\n  const isEnded = status === 'ended';\n  const muteLabel = muteLabelOf(isMuted);\n\n  return (\n    <section\n      aria-label='Call'\n      className='bg-card hairline-ring ring-border dark:bg-foreground/[0.03] flex flex-col items-center gap-4 rounded-xl p-4 shadow-[0_1px_2px_rgb(0_0_0/0.04)]'\n    >\n      <div className='flex w-full items-center justify-between gap-3'>\n        <h2 className='min-w-0 truncate text-sm font-medium'>{title}</h2>\n        <CallClock startedAt={startedAt} endedAt={endedAt} />\n      </div>\n      <VoiceDisc mode={mode} isActive={isActive && isLive} />\n      <Swap swapKey={mode} className='text-[13px] font-medium'>\n        {MODE_WORD[mode]}\n      </Swap>\n      <Transcript lines={lines} />\n      <div className='flex h-9 items-center gap-2'>\n        {!isEnded && (\n          <Button\n            type='button'\n            variant='outline'\n            size='lg'\n            aria-pressed={isMuted}\n            disabled={!isLive}\n            onClick={onToggleMute}\n          >\n            <Swap swapKey={muteLabel}>\n              {isMuted && <MicOffIcon />}\n              {!isMuted && <MicIcon />}\n            </Swap>\n            {muteLabel}\n          </Button>\n        )}\n        {!isEnded && (\n          <Button\n            type='button'\n            variant='destructive'\n            size='lg'\n            disabled={!isLive}\n            onClick={onEnd}\n            className={pressedDestructiveOf(pressed === 'end')}\n          >\n            <PhoneOffIcon />\n            End call\n          </Button>\n        )}\n        {isEnded && footer}\n      </div>\n    </section>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/agent-chat-04/call-panel.tsx"
    },
    {
      "path": "registry/ndeko/blocks/agent-chat/agent-chat-04/notes-page.tsx",
      "content": "'use client';\n\nimport { AnimatePresence, motion } from 'motion/react';\n\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport { CalendarIcon, FeatherIcon } from '@/registry/ndeko/lib/icons';\nimport {\n  risePresenceOf,\n  rowPresenceOf,\n} from '@/registry/ndeko/lib/motion-presets';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { Avatar } from '@/registry/ndeko/ui/avatar';\nimport { Fold, Swap } from '@/registry/ndeko/ui/chat-motion';\nimport { CopyButton } from '@/registry/ndeko/ui/copy-button';\nimport { DrawnCheck } from '@/registry/ndeko/ui/drawn-check';\nimport { MorphButton, type MorphState } from '@/registry/ndeko/ui/morph-button';\n\nimport { summaryTextOf, type Note, type Owner, type Todo } from './data';\nimport type { DoneBy } from './session';\n\nconst SHARE_LABELS: Record<MorphState, string> = {\n  idle: 'Share with the team',\n  busy: 'Sharing',\n  done: 'Shared',\n};\n\nfunction OwnerMark({ owner }: { owner: Owner }) {\n  if (owner.isAssistant) {\n    return (\n      <span\n        aria-hidden='true'\n        className='gem-plate inline-flex size-4 items-center justify-center rounded-full [--gem:var(--primary)]'\n      >\n        <FeatherIcon className='size-2.5' />\n      </span>\n    );\n  }\n  return <Avatar className='size-4' seed={owner.name} />;\n}\n\nconst PILL =\n  'bg-foreground/[0.05] inline-flex h-6 shrink-0 items-center gap-1.5 rounded-full px-2 text-xs';\n\nfunction todoTextOf(isDone: boolean) {\n  if (isDone) {\n    return 'text-muted-foreground line-through';\n  }\n  return 'text-foreground';\n}\n\ntype TodoRowProps = {\n  todo: Todo;\n  doneBy: DoneBy | undefined;\n  onToggle: (id: string) => void;\n};\n\nfunction TodoRow({ todo, doneBy, onToggle }: TodoRowProps) {\n  const isDone = doneBy !== undefined;\n  const isByAssistant = doneBy === 'assistant';\n\n  return (\n    <div className='flex flex-wrap items-start gap-x-2.5 gap-y-1 py-1.5'>\n      <button\n        type='button'\n        role='checkbox'\n        aria-checked={isDone}\n        aria-label={todo.text}\n        onClick={() => onToggle(todo.id)}\n        className='focus-visible:ring-ring/40 mt-0.5 flex size-[18px] shrink-0 cursor-pointer items-center justify-center rounded-full outline-none focus-visible:ring-[3px] active:scale-[0.97]'\n      >\n        {isDone && <DrawnCheck entrance='draw' />}\n        {!isDone && (\n          <span className='hairline-ring ring-foreground/30 hover:ring-foreground/60 size-[18px] rounded-full transition-shadow duration-150' />\n        )}\n      </button>\n      <div className='flex min-w-40 flex-1 flex-col'>\n        <span\n          className={cn(\n            'text-[13px] leading-[1.375rem] transition-colors duration-200',\n            todoTextOf(isDone)\n          )}\n        >\n          {todo.text}\n        </span>\n        <Fold open={isByAssistant}>\n          <span className='text-muted-foreground flex h-6 items-center gap-2 text-xs'>\n            Done by assistant\n            <button\n              type='button'\n              onClick={() => onToggle(todo.id)}\n              className='text-primary-ink focus-visible:ring-ring/25 cursor-pointer rounded-sm font-medium underline-offset-4 outline-none hover:underline focus-visible:ring-[3px]'\n            >\n              Undo\n            </button>\n          </span>\n        </Fold>\n      </div>\n      <div className='flex items-center gap-1.5 ps-7 @md:ps-0'>\n        <span className={PILL}>\n          <OwnerMark owner={todo.owner} />\n          {todo.owner.name}\n        </span>\n        <span className={cn(PILL, 'text-muted-foreground tabular-nums')}>\n          <CalendarIcon className='size-3' />\n          {todo.due}\n        </span>\n      </div>\n    </div>\n  );\n}\n\nfunction modeWordOf(isEnded: boolean) {\n  if (isEnded) {\n    return 'Summary of the call';\n  }\n  return 'Live notes';\n}\n\nfunction EmptyLine({ text }: { text: string }) {\n  return <p className='text-muted-foreground py-1.5 text-[13px]'>{text}</p>;\n}\n\ntype NotesPageProps = {\n  title: string;\n  notes: Note[];\n  todos: Todo[];\n  doneBy: Record<string, DoneBy>;\n  isEnded: boolean;\n  share: MorphState;\n  onToggleTodo: (id: string) => void;\n  onShare: () => void;\n};\n\nexport function NotesPage({\n  title,\n  notes,\n  todos,\n  doneBy,\n  isEnded,\n  share,\n  onToggleTodo,\n  onShare,\n}: NotesPageProps) {\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const rowPresence = rowPresenceOf(shouldReduceMotion);\n  const risePresence = risePresenceOf(shouldReduceMotion);\n  const modeWord = modeWordOf(isEnded);\n  const hasNotes = notes.length > 0;\n  const hasTodos = todos.length > 0;\n\n  return (\n    <section\n      aria-label='Notes'\n      className='bg-card hairline-ring ring-border dark:bg-foreground/[0.03] flex min-w-0 flex-1 flex-col gap-5 rounded-xl p-4 shadow-[0_1px_2px_rgb(0_0_0/0.04)] @3xl:p-6'\n    >\n      <header className='flex min-h-9 flex-wrap items-center justify-between gap-2'>\n        <div className='flex flex-col'>\n          <h2 className='text-lg leading-tight font-semibold'>{title}</h2>\n          <Swap swapKey={modeWord} className='text-muted-foreground text-xs'>\n            {modeWord}\n          </Swap>\n        </div>\n        <AnimatePresence initial={false}>\n          {isEnded && (\n            <motion.div\n              key='actions'\n              className='flex items-center gap-1.5'\n              {...risePresence}\n            >\n              <CopyButton\n                text={summaryTextOf(notes, todos)}\n                label='Copy the summary'\n              />\n              <MorphButton\n                type='button'\n                size='sm'\n                variant='outline'\n                state={share}\n                labels={SHARE_LABELS}\n                onClick={onShare}\n              />\n            </motion.div>\n          )}\n        </AnimatePresence>\n      </header>\n\n      <div className='flex flex-col gap-1'>\n        <h3 className='text-muted-foreground text-xs'>Notes</h3>\n        {!hasNotes && (\n          <EmptyLine text='Notes are written here as they are said' />\n        )}\n        <ul className='flex flex-col'>\n          <AnimatePresence initial={false}>\n            {notes.map((note) => (\n              <motion.li\n                key={note.id}\n                className='overflow-hidden'\n                {...rowPresence}\n              >\n                <p className='flex gap-2.5 py-1.5 text-[13px] leading-snug'>\n                  <span\n                    aria-hidden='true'\n                    className='bg-foreground/40 mt-[7px] size-1 shrink-0 rounded-full'\n                  />\n                  {note.text}\n                </p>\n              </motion.li>\n            ))}\n          </AnimatePresence>\n        </ul>\n      </div>\n\n      <div className='flex flex-col gap-1'>\n        <h3 className='text-muted-foreground text-xs'>To-dos</h3>\n        {!hasTodos && (\n          <EmptyLine text='To-dos get an owner and a date when they come up' />\n        )}\n        <ul className='flex flex-col'>\n          <AnimatePresence initial={false}>\n            {todos.map((todo) => (\n              <motion.li\n                key={todo.id}\n                className='-mx-1 overflow-hidden px-1'\n                {...rowPresence}\n              >\n                <TodoRow\n                  todo={todo}\n                  doneBy={doneBy[todo.id]}\n                  onToggle={onToggleTodo}\n                />\n              </motion.li>\n            ))}\n          </AnimatePresence>\n        </ul>\n      </div>\n    </section>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/agent-chat-04/notes-page.tsx"
    },
    {
      "path": "registry/ndeko/blocks/agent-chat/agent-chat-04/session.ts",
      "content": "import type { SessionStep } from '@/registry/ndeko/hooks/use-session';\n\nexport type CallStatus = 'ringing' | 'live' | 'ended';\n\nexport type DoneBy = 'assistant' | 'person';\n\nexport type VoiceState = {\n  status: CallStatus;\n  isMuted: boolean;\n  linesShown: number;\n  notesShown: number;\n  todosShown: number;\n  /** Who ticked each finished to-do. */\n  doneBy: Record<string, DoneBy>;\n  startedAt: number | null;\n  endedAt: number | null;\n  share: 'idle' | 'busy' | 'done';\n};\n\nexport type VoiceAction =\n  | { type: 'started' }\n  | { type: 'line' }\n  | { type: 'note' }\n  | { type: 'todo' }\n  | { type: 'did'; id: string }\n  | { type: 'toggled'; id: string }\n  | { type: 'muted' }\n  | { type: 'ended' }\n  | { type: 'sharing' }\n  | { type: 'shared' }\n  | { type: 'batch'; actions: VoiceAction[] };\n\ntype Step = SessionStep<VoiceState, VoiceAction>;\n\nexport const INITIAL: VoiceState = {\n  status: 'ringing',\n  isMuted: false,\n  linesShown: 0,\n  notesShown: 0,\n  todosShown: 0,\n  doneBy: {},\n  startedAt: null,\n  endedAt: null,\n  share: 'idle',\n};\n\nfunction without(doneBy: Record<string, DoneBy>, id: string) {\n  const rest = { ...doneBy };\n  delete rest[id];\n  return rest;\n}\n\nfunction toggled(state: VoiceState, id: string): VoiceState {\n  const isDone = state.doneBy[id] !== undefined;\n  if (isDone) {\n    return { ...state, doneBy: without(state.doneBy, id) };\n  }\n  return { ...state, doneBy: { ...state.doneBy, [id]: 'person' } };\n}\n\nfunction ended(state: VoiceState, now: number): VoiceState {\n  if (state.status !== 'live') {\n    return state;\n  }\n  return { ...state, status: 'ended', endedAt: now };\n}\n\nfunction shared(state: VoiceState): VoiceState {\n  if (state.share !== 'busy') {\n    return state;\n  }\n  return { ...state, share: 'done' };\n}\n\n/** Once the call has ended nothing more is said or written. */\nfunction whileLive(state: VoiceState, next: VoiceState) {\n  if (state.status === 'live') {\n    return next;\n  }\n  return state;\n}\n\nexport function applyAt(\n  state: VoiceState,\n  action: VoiceAction,\n  now: number\n): VoiceState {\n  switch (action.type) {\n    case 'started':\n      return { ...state, status: 'live', startedAt: now };\n    case 'line':\n      return whileLive(state, { ...state, linesShown: state.linesShown + 1 });\n    case 'note':\n      return whileLive(state, { ...state, notesShown: state.notesShown + 1 });\n    case 'todo':\n      return whileLive(state, { ...state, todosShown: state.todosShown + 1 });\n    case 'did': {\n      const doneBy: Record<string, DoneBy> = {\n        ...state.doneBy,\n        [action.id]: 'assistant',\n      };\n      return whileLive(state, { ...state, doneBy });\n    }\n    case 'toggled':\n      return toggled(state, action.id);\n    case 'muted':\n      return { ...state, isMuted: !state.isMuted };\n    case 'ended':\n      return ended(state, now);\n    case 'sharing':\n      return { ...state, share: 'busy' };\n    case 'shared':\n      return shared(state);\n    case 'batch': {\n      let next = state;\n      for (const inner of action.actions) {\n        next = applyAt(next, inner, now);\n      }\n      return next;\n    }\n  }\n}\n\nexport function reducer(state: VoiceState, action: VoiceAction) {\n  return applyAt(state, action, Date.now());\n}\n\nfunction frame(after: number, actions: VoiceAction[]): Step {\n  return { after, action: { type: 'batch', actions } };\n}\n\nexport const SHARE_MS = 900;\n\nexport const SCRIPT: Step[] = [\n  frame(700, [{ type: 'started' }]),\n  frame(900, [{ type: 'line' }]),\n  frame(1900, [{ type: 'note' }]),\n  frame(900, [{ type: 'line' }]),\n  frame(2000, [{ type: 'line' }]),\n  frame(1500, [{ type: 'todo' }]),\n  frame(800, [{ type: 'todo' }]),\n  frame(1100, [{ type: 'line' }, { type: 'did', id: 't2' }, { type: 'note' }]),\n  frame(2400, [{ type: 'line' }]),\n  frame(1300, [{ type: 'todo' }]),\n  frame(900, [{ type: 'note' }, { type: 'todo' }]),\n  frame(1000, [{ type: 'line' }, { type: 'did', id: 't3' }]),\n  { after: 2600, by: 'demo', press: 'end', action: { type: 'ended' } },\n];\n\nfunction restingOf() {\n  let state = INITIAL;\n  let now = 1000;\n  for (const step of SCRIPT) {\n    now += step.after;\n    state = applyAt(state, step.action, now);\n  }\n  return state;\n}\n\nexport const RESTING = restingOf();\n\nexport const LOOP_AFTER_MS = 4200;\n",
      "type": "registry:component",
      "target": "components/blocks/agent-chat-04/session.ts"
    },
    {
      "path": "registry/ndeko/blocks/agent-chat/agent-chat-04/data.ts",
      "content": "export type Speaker = 'person' | 'assistant';\n\nexport type TranscriptLine = {\n  id: string;\n  speaker: Speaker;\n  text: string;\n};\n\nexport const CALL_TITLE = 'Tallis launch plan';\n\nexport const TRANSCRIPT: TranscriptLine[] = [\n  {\n    id: 'l1',\n    speaker: 'person',\n    text: 'Let us plan the Tallis launch. The pricing page goes live on the 14th.',\n  },\n  {\n    id: 'l2',\n    speaker: 'assistant',\n    text: 'Noted. Who writes the announcement?',\n  },\n  {\n    id: 'l3',\n    speaker: 'person',\n    text: 'Maren drafts it by Friday. And book the launch review with the team.',\n  },\n  {\n    id: 'l4',\n    speaker: 'assistant',\n    text: 'Booked for Tuesday at 10. Should I send the agenda to everyone?',\n  },\n  {\n    id: 'l5',\n    speaker: 'person',\n    text: 'Yes, send it. Legal still has to check the new terms.',\n  },\n  {\n    id: 'l6',\n    speaker: 'assistant',\n    text: 'Agenda sent. I added the legal review as a to-do for Jonas.',\n  },\n];\n\nexport type Note = {\n  id: string;\n  text: string;\n};\n\nexport const NOTES: Note[] = [\n  { id: 'n1', text: 'The pricing page goes live on 14 May' },\n  { id: 'n2', text: 'Launch review on Tuesday 13 May at 10:00' },\n  { id: 'n3', text: 'Legal has to check the new terms before launch' },\n];\n\nexport type Owner = {\n  name: string;\n  isAssistant: boolean;\n};\n\nconst MAREN: Owner = { name: 'Maren Holt', isAssistant: false };\n\nconst JONAS: Owner = { name: 'Jonas Weber', isAssistant: false };\n\nexport const ASSISTANT: Owner = { name: 'Assistant', isAssistant: true };\n\nexport type Todo = {\n  id: string;\n  text: string;\n  owner: Owner;\n  due: string;\n};\n\nexport const TODOS: Todo[] = [\n  { id: 't1', text: 'Draft the announcement', owner: MAREN, due: 'Fri 9 May' },\n  {\n    id: 't2',\n    text: 'Book the launch review',\n    owner: ASSISTANT,\n    due: 'Today',\n  },\n  {\n    id: 't3',\n    text: 'Send the agenda to the team',\n    owner: ASSISTANT,\n    due: 'Today',\n  },\n  {\n    id: 't4',\n    text: 'Ask legal to review the terms',\n    owner: JONAS,\n    due: 'Mon 12 May',\n  },\n];\n\nexport function summaryTextOf(notes: Note[], todos: Todo[]) {\n  const noteLines = notes.map((note) => `- ${note.text}`);\n  const todoLines = todos.map(\n    (todo) => `- ${todo.text} (${todo.owner.name}, ${todo.due})`\n  );\n  const lines = [\n    CALL_TITLE,\n    '',\n    'Notes',\n    ...noteLines,\n    '',\n    'To-dos',\n    ...todoLines,\n  ];\n  return lines.join('\\n');\n}\n",
      "type": "registry:component",
      "target": "components/blocks/agent-chat-04/data.ts"
    }
  ],
  "categories": [
    "blocks",
    "agent-chat"
  ],
  "type": "registry:block"
}