{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "voice-02",
  "title": "Voice note",
  "description": "A voice reply whose dots ink in as it plays, with a speed key that steps to 2x, seeking by click, drag or arrows, and a transcript that follows word by word.",
  "dependencies": [],
  "registryDependencies": [
    "https://ui.ndekocode.dev/r/button.json",
    "https://ui.ndekocode.dev/r/chat-motion.json",
    "https://ui.ndekocode.dev/r/demonstration.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/motion-word-roll.json",
    "https://ui.ndekocode.dev/r/speech-envelope.json",
    "https://ui.ndekocode.dev/r/theme.json",
    "https://ui.ndekocode.dev/r/use-agent-run.json",
    "https://ui.ndekocode.dev/r/use-autoplay.json",
    "https://ui.ndekocode.dev/r/use-kept-height.json",
    "https://ui.ndekocode.dev/r/use-prefers-reduced-motion.json",
    "https://ui.ndekocode.dev/r/utils.json"
  ],
  "files": [
    {
      "path": "registry/ndeko/components/voice/voice-02.tsx",
      "content": "'use client';\n\nimport {\n  useContext,\n  useEffect,\n  useEffectEvent,\n  useImperativeHandle,\n  useRef,\n  useState,\n} from 'react';\n\nimport { WordRoll } from '@/components/core/word-roll';\nimport { ClockGateContext } from '@/registry/ndeko/hooks/use-agent-run';\nimport {\n  useAutoplay,\n  type AutoplayStep,\n} from '@/registry/ndeko/hooks/use-autoplay';\nimport { useKeptHeight } from '@/registry/ndeko/hooks/use-kept-height';\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport {\n  hold,\n  PRESS_LEAD_MS,\n  pressedQuietOf,\n  pressedSolidOf,\n  spokenUnless,\n  usePress,\n} from '@/registry/ndeko/lib/demonstration';\nimport { PauseIcon, PlayIcon, RotateCcwIcon } from '@/registry/ndeko/lib/icons';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { Button } from '@/registry/ndeko/ui/button';\nimport { Swap } from '@/registry/ndeko/ui/chat-motion';\nimport { ClockGate } from '@/registry/ndeko/ui/live-duration';\nimport { LiveRegion } from '@/registry/ndeko/ui/live-region';\n\nimport { formatClock, spokenClockOf } from '@/registry/ndeko/lib/media-clock';\nimport { noiseAt } from '@/registry/ndeko/lib/speech-envelope';\n\nexport type TimedWord = {\n  text: string;\n  /** Milliseconds from the start of the recording. */\n  start: number;\n  end: number;\n};\n\nconst RATES = [1, 1.5, 2] as const;\n\ntype Rate = (typeof RATES)[number];\n\nconst RATE_LABELS = RATES.map((rate) => `${rate}x`);\n\nconst SEEK_STEP_MS = 5000;\n\nconst MAX_DOTS = 5;\n\ntype PlayKey = 'play' | 'pause' | 'replay';\n\nconst PLAY_LABEL: Record<PlayKey, string> = {\n  play: 'Play the voice note',\n  pause: 'Pause',\n  replay: 'Play it again',\n};\n\nfunction nextRateOf(rate: Rate): Rate {\n  const index = RATES.indexOf(rate);\n  const nextIndex = (index + 1) % RATES.length;\n  return RATES[nextIndex];\n}\n\nfunction dotsOf(level: number) {\n  const scaled = level * (MAX_DOTS - 1);\n  const rounded = Math.round(scaled);\n  return 1 + rounded;\n}\n\n/** The last word that has started: it stays lit through the breath that follows it. */\nfunction wordIndexAt(transcript: TimedWord[], position: number) {\n  let current = -1;\n  for (const [index, word] of transcript.entries()) {\n    if (word.start > position) {\n      break;\n    }\n    current = index;\n  }\n  return current;\n}\n\nfunction playKeyOf(isPlaying: boolean, isEnded: boolean): PlayKey {\n  if (isPlaying) {\n    return 'pause';\n  }\n  if (isEnded) {\n    return 'replay';\n  }\n  return 'play';\n}\n\nfunction PlayGlyph({ playKey }: { playKey: PlayKey }) {\n  if (playKey === 'pause') {\n    return <PauseIcon />;\n  }\n  if (playKey === 'replay') {\n    return <RotateCcwIcon />;\n  }\n  return <PlayIcon />;\n}\n\nfunction wordToneOf(index: number, current: number) {\n  if (index === current) {\n    return 'bg-primary/15 text-foreground dark:bg-primary/25';\n  }\n  if (index < current) {\n    return 'text-foreground hover:bg-foreground/[0.06]';\n  }\n  return 'text-muted-foreground hover:bg-foreground/[0.06] hover:text-foreground';\n}\n\nfunction inkedOf(position: number, duration: number, columnCount: number) {\n  const progress = position / duration;\n  return Math.round(progress * columnCount);\n}\n\nfunction valueTextOf(position: number, duration: number) {\n  const spokenPosition = spokenClockOf(position);\n  const spokenDuration = spokenClockOf(duration);\n  return `${spokenPosition} of ${spokenDuration}`;\n}\n\nfunction clamped(position: number, duration: number) {\n  return Math.min(duration, Math.max(0, position));\n}\n\nfunction columnsOf(element: HTMLElement | null) {\n  if (!element) {\n    return [];\n  }\n  const children = Array.from(element.children);\n  return children.filter((child) => child instanceof HTMLElement);\n}\n\n/** The position of the simulated playback: where it stood when it last started or stopped, and since when it runs. */\ntype PlaybackClock = {\n  position: number;\n  startedAt: number | null;\n};\n\ntype PositionClockHandle = {\n  show: (second: number) => void;\n};\n\ntype PositionClockProps = {\n  handleRef: React.Ref<PositionClockHandle>;\n  startSecond: number;\n  durationText: string;\n};\n\n/** The seconds tick in here, so playback re-renders this text and nothing around it. */\nfunction PositionClock({\n  handleRef,\n  startSecond,\n  durationText,\n}: PositionClockProps) {\n  const [second, setSecond] = useState(startSecond);\n  const positionText = formatClock(second * 1000);\n\n  useImperativeHandle(handleRef, () => ({ show: setSecond }));\n\n  return (\n    <p className='text-muted-foreground text-xs tabular-nums'>\n      <span aria-hidden='true'>\n        {positionText} / {durationText}\n      </span>\n    </p>\n  );\n}\n\ntype TranscriptHandle = {\n  show: (wordIndex: number) => void;\n};\n\ntype TranscriptProps = {\n  handleRef: React.Ref<TranscriptHandle>;\n  words: TimedWord[];\n  startIndex: number;\n  onSeek: (position: number) => void;\n};\n\n/** The word being said changes in here, and the lines scroll inside their own region to keep it in sight. */\nfunction Transcript({ handleRef, words, startIndex, onSeek }: TranscriptProps) {\n  const [wordIndex, setWordIndex] = useState(startIndex);\n  const containerRef = useRef<HTMLDivElement>(null);\n  const shouldReduceMotion = usePrefersReducedMotion();\n\n  useImperativeHandle(handleRef, () => ({ show: setWordIndex }));\n\n  useEffect(() => {\n    const container = containerRef.current;\n    if (!container) {\n      return;\n    }\n    const word = container.querySelector<HTMLElement>(\n      `[data-word=\"${wordIndex}\"]`\n    );\n    if (!word) {\n      return;\n    }\n    const top = word.offsetTop;\n    const bottom = top + word.offsetHeight;\n    const viewBottom = container.scrollTop + container.clientHeight;\n    const isAbove = top < container.scrollTop;\n    const isBelow = bottom > viewBottom;\n    const isHidden = isAbove || isBelow;\n    if (!isHidden) {\n      return;\n    }\n    const behavior = scrollBehaviorOf(shouldReduceMotion);\n    const target = top - container.clientHeight / 3;\n    container.scrollTo({ top: target, behavior });\n  }, [wordIndex, shouldReduceMotion]);\n\n  return (\n    <div\n      ref={containerRef}\n      className='bg-foreground/[0.03] dark:bg-foreground/[0.05] relative max-h-24 overflow-y-auto rounded-lg px-3 py-2 text-[13px] leading-6'\n    >\n      {words.map((word, index) => (\n        <span key={index}>\n          <span\n            data-word={index}\n            onClick={() => onSeek(word.start)}\n            className={cn(\n              '-mx-0.5 cursor-pointer rounded-[3px] px-0.5 transition-colors duration-150',\n              wordToneOf(index, wordIndex)\n            )}\n          >\n            {word.text}\n          </span>{' '}\n        </span>\n      ))}\n    </div>\n  );\n}\n\nexport type VoiceNotePressKey = 'play' | 'rate';\n\nexport type VoiceNoteHandle = {\n  /** Shows a key held down. */\n  press: (key: VoiceNotePressKey) => void;\n  /** Plays or pauses, as the round key does. */\n  togglePlay: () => void;\n  /** Steps to the next speed, as the speed key does. */\n  changeRate: () => void;\n  /** Back to a position in milliseconds, paused, at normal speed. */\n  reset: (position: number) => void;\n};\n\nexport type VoiceNoteProps = {\n  label: string;\n  /** Milliseconds. */\n  duration: number;\n  /** One level between 0 and 1 per column of dots. */\n  levels: number[];\n  transcript: TimedWord[];\n  /** Where the note stands before it is played, in milliseconds: a note resumed part of the way. */\n  defaultPosition?: number;\n  /** Runs what the keys do, for a demonstration or a control beside the note. */\n  handleRef?: React.Ref<VoiceNoteHandle>;\n  /** A demonstration drives the note: nothing is read aloud. */\n  isDemonstrated?: boolean;\n  className?: string;\n};\n\nexport function VoiceNote({\n  label,\n  duration,\n  levels,\n  transcript,\n  defaultPosition = 0,\n  handleRef,\n  isDemonstrated = false,\n  className,\n}: VoiceNoteProps) {\n  const [isPlaying, setIsPlaying] = useState(false);\n  const [isEnded, setIsEnded] = useState(false);\n  const [rate, setRate] = useState<Rate>(1);\n  const [announcement, setAnnouncement] = useState('');\n  const { pressed, press } = usePress<VoiceNotePressKey>();\n  const isOnScreen = useContext(ClockGateContext);\n  const startPosition = clamped(defaultPosition, duration);\n  const startSecond = Math.floor(startPosition / 1000);\n  const startInked = inkedOf(startPosition, duration, levels.length);\n  const startWord = wordIndexAt(transcript, startPosition);\n  const clock = useRef<PlaybackClock | null>(null);\n  const rateRef = useRef<Rate>(1);\n  const inkedRef = useRef<number | null>(null);\n  const secondRef = useRef<number | null>(null);\n  const wordRef = useRef<number | null>(null);\n  const isScrubbing = useRef(false);\n  const sliderRef = useRef<HTMLDivElement>(null);\n  const waveRef = useRef<HTMLDivElement>(null);\n  const positionClock = useRef<PositionClockHandle>(null);\n  const transcriptView = useRef<TranscriptHandle>(null);\n  const playKey = playKeyOf(isPlaying, isEnded);\n  const durationText = formatClock(duration);\n  const durationSeconds = Math.floor(duration / 1000);\n  // Off screen the playback holds its place: it is a clock like any other of the piece.\n  const isRunning = isPlaying && isOnScreen;\n\n  /** Until the note is played or moved, it stands where it was given to start. */\n  function savedClock(): PlaybackClock {\n    return clock.current ?? { position: startPosition, startedAt: null };\n  }\n\n  function positionAt(now: number) {\n    const saved = savedClock();\n    if (saved.startedAt === null) {\n      return saved.position;\n    }\n    const elapsed = now - saved.startedAt;\n    const travelled = elapsed * rateRef.current;\n    const position = saved.position + travelled;\n    return clamped(position, duration);\n  }\n\n  function holdAt(position: number) {\n    clock.current = { position, startedAt: null };\n  }\n\n  function runFrom(position: number) {\n    clock.current = { position, startedAt: performance.now() };\n  }\n\n  /** Moves the playback without starting or stopping it. */\n  function moveTo(position: number) {\n    const isMoving = savedClock().startedAt !== null;\n    if (isMoving) {\n      runFrom(position);\n      return;\n    }\n    holdAt(position);\n  }\n\n  function paintWave(position: number) {\n    const inked = inkedOf(position, duration, levels.length);\n    if (inked === inkedRef.current) {\n      return;\n    }\n    inkedRef.current = inked;\n    const columns = columnsOf(waveRef.current);\n    columns.forEach((column, index) => {\n      column.dataset.inked = String(index < inked);\n    });\n  }\n\n  function paintSecond(position: number) {\n    const second = Math.floor(position / 1000);\n    if (second === secondRef.current) {\n      return;\n    }\n    secondRef.current = second;\n    positionClock.current?.show(second);\n    const slider = sliderRef.current;\n    slider?.setAttribute('aria-valuenow', String(second));\n    slider?.setAttribute('aria-valuetext', valueTextOf(position, duration));\n  }\n\n  function paintWord(position: number) {\n    const wordIndex = wordIndexAt(transcript, position);\n    if (wordIndex === wordRef.current) {\n      return;\n    }\n    wordRef.current = wordIndex;\n    transcriptView.current?.show(wordIndex);\n  }\n\n  /** What a frame changes is written to the elements and to two small leaves, never to this component. */\n  function paint(position: number) {\n    paintWave(position);\n    paintSecond(position);\n    paintWord(position);\n  }\n\n  function finish() {\n    holdAt(duration);\n    paint(duration);\n    setIsPlaying(false);\n    setIsEnded(true);\n    setAnnouncement('The voice note ended');\n  }\n\n  const onFrame = useEffectEvent((now: number) => {\n    const position = positionAt(now);\n    paint(position);\n    const isAtEnd = position >= duration;\n    if (isAtEnd) {\n      finish();\n    }\n    return isAtEnd;\n  });\n\n  const startClock = useEffectEvent(() => {\n    runFrom(savedClock().position);\n  });\n\n  const stopClock = useEffectEvent(() => {\n    holdAt(positionAt(performance.now()));\n  });\n\n  useEffect(() => {\n    if (!isRunning) {\n      return;\n    }\n    startClock();\n    let frame = 0;\n    function tick(now: number) {\n      const isAtEnd = onFrame(now);\n      if (!isAtEnd) {\n        frame = requestAnimationFrame(tick);\n      }\n    }\n    frame = requestAnimationFrame(tick);\n    return () => {\n      cancelAnimationFrame(frame);\n      stopClock();\n    };\n  }, [isRunning]);\n\n  function play() {\n    let position = positionAt(performance.now());\n    if (isEnded) {\n      position = 0;\n    }\n    holdAt(position);\n    setIsEnded(false);\n    setIsPlaying(true);\n    setAnnouncement('Playing');\n  }\n\n  function pause() {\n    const position = positionAt(performance.now());\n    holdAt(position);\n    paint(position);\n    setIsPlaying(false);\n    const spokenPosition = spokenClockOf(position);\n    setAnnouncement(`Paused at ${spokenPosition}`);\n  }\n\n  function togglePlay() {\n    if (isPlaying) {\n      pause();\n      return;\n    }\n    play();\n  }\n\n  function seekTo(position: number) {\n    const bounded = clamped(position, duration);\n    moveTo(bounded);\n    paint(bounded);\n    const isBeforeEnd = bounded < duration;\n    if (isBeforeEnd) {\n      setIsEnded(false);\n    }\n  }\n\n  function seekBy(step: number) {\n    const current = positionAt(performance.now());\n    seekTo(current + step);\n  }\n\n  function changeRate() {\n    const position = positionAt(performance.now());\n    const next = nextRateOf(rate);\n    moveTo(position);\n    rateRef.current = next;\n    setRate(next);\n    setAnnouncement(`Speed ${next}x`);\n  }\n\n  function reset(position: number) {\n    const bounded = clamped(position, duration);\n    holdAt(bounded);\n    rateRef.current = 1;\n    paint(bounded);\n    setRate(1);\n    setIsPlaying(false);\n    setIsEnded(false);\n    setAnnouncement('');\n  }\n\n  function positionFromPointer(event: React.PointerEvent<HTMLDivElement>) {\n    const rect = event.currentTarget.getBoundingClientRect();\n    const offset = event.clientX - rect.left;\n    const progress = offset / rect.width;\n    return progress * duration;\n  }\n\n  function startScrub(event: React.PointerEvent<HTMLDivElement>) {\n    if (event.button !== 0) {\n      return;\n    }\n    event.currentTarget.setPointerCapture(event.pointerId);\n    isScrubbing.current = true;\n    seekTo(positionFromPointer(event));\n  }\n\n  function moveScrub(event: React.PointerEvent<HTMLDivElement>) {\n    if (!isScrubbing.current) {\n      return;\n    }\n    seekTo(positionFromPointer(event));\n  }\n\n  function endScrub() {\n    isScrubbing.current = false;\n  }\n\n  function seekFromKeys(event: React.KeyboardEvent<HTMLDivElement>) {\n    const isForward = event.key === 'ArrowRight' || event.key === 'ArrowUp';\n    const isBack = event.key === 'ArrowLeft' || event.key === 'ArrowDown';\n    if (isForward) {\n      event.preventDefault();\n      seekBy(SEEK_STEP_MS);\n      return;\n    }\n    if (isBack) {\n      event.preventDefault();\n      seekBy(-SEEK_STEP_MS);\n      return;\n    }\n    if (event.key === 'Home') {\n      event.preventDefault();\n      seekTo(0);\n      return;\n    }\n    if (event.key === 'End') {\n      event.preventDefault();\n      seekTo(duration);\n      return;\n    }\n    if (event.key === ' ') {\n      event.preventDefault();\n      togglePlay();\n    }\n  }\n\n  useImperativeHandle(handleRef, () => ({\n    press,\n    togglePlay,\n    changeRate,\n    reset,\n  }));\n\n  return (\n    <section\n      aria-label={label}\n      className={cn('flex flex-col gap-3', className)}\n    >\n      <div className='flex items-center gap-3'>\n        <Button\n          type='button'\n          size='icon-lg'\n          aria-label={PLAY_LABEL[playKey]}\n          onClick={togglePlay}\n          className={pressedSolidOf(pressed === 'play')}\n        >\n          <Swap swapKey={playKey}>\n            <PlayGlyph playKey={playKey} />\n          </Swap>\n        </Button>\n        <div className='flex min-w-0 flex-1 flex-col gap-1'>\n          <div\n            ref={sliderRef}\n            role='slider'\n            tabIndex={0}\n            aria-label='Position'\n            aria-valuemin={0}\n            aria-valuemax={durationSeconds}\n            aria-valuenow={startSecond}\n            aria-valuetext={valueTextOf(startPosition, duration)}\n            onKeyDown={seekFromKeys}\n            onPointerDown={startScrub}\n            onPointerMove={moveScrub}\n            onPointerUp={endScrub}\n            onPointerCancel={endScrub}\n            className='focus-visible:ring-ring/25 -mx-1 cursor-pointer touch-none rounded-md px-1 outline-none select-none focus-visible:ring-[3px]'\n          >\n            <div\n              ref={waveRef}\n              aria-hidden='true'\n              className='flex h-9 items-center justify-between'\n            >\n              {levels.map((level, index) => (\n                <span\n                  key={index}\n                  data-inked={String(index < startInked)}\n                  className='group/column flex w-[3px] flex-col items-center justify-center gap-[3px]'\n                >\n                  {Array.from({ length: dotsOf(level) }, (_, dot) => (\n                    <span\n                      key={dot}\n                      className='bg-foreground/20 group-data-[inked=true]/column:bg-primary size-[3px] rounded-full transition-colors duration-150'\n                    />\n                  ))}\n                </span>\n              ))}\n            </div>\n          </div>\n          <PositionClock\n            handleRef={positionClock}\n            startSecond={startSecond}\n            durationText={durationText}\n          />\n        </div>\n        <Button\n          type='button'\n          variant='outline'\n          size='sm'\n          aria-label={`Playback speed ${rate}x, change it`}\n          onClick={changeRate}\n          className={cn(\n            'w-14 tabular-nums',\n            pressedQuietOf(pressed === 'rate')\n          )}\n        >\n          <WordRoll text={`${rate}x`} labels={RATE_LABELS} value={rate} />\n        </Button>\n      </div>\n      <Transcript\n        handleRef={transcriptView}\n        words={transcript}\n        startIndex={startWord}\n        onSeek={seekTo}\n      />\n      <LiveRegion message={spokenUnless(isDemonstrated, announcement)} />\n    </section>\n  );\n}\n\nfunction scrollBehaviorOf(shouldReduceMotion: boolean | null): ScrollBehavior {\n  if (shouldReduceMotion) {\n    return 'auto';\n  }\n  return 'smooth';\n}\n\nconst NOTE_TEXT =\n  'Hi Jonas, the revised quote from Brightmoor came in this morning. The new rates are about eight percent lower, and they can ship the October order by Friday. I would say we accept, but let us ask for the credit first.';\n\nconst NOTE_DURATION = 21_000;\n\nconst LEAD_IN_MS = 400;\n\nconst TAIL_MS = 600;\n\nconst COLUMN_COUNT = 42;\n\nfunction pauseAfter(word: string) {\n  if (/[.!?]$/.test(word)) {\n    return 0.55;\n  }\n  if (/[,;:]$/.test(word)) {\n    return 0.3;\n  }\n  return 0.06;\n}\n\nfunction spokenLengthOf(word: string) {\n  return 0.16 + word.length * 0.045;\n}\n\n/** Word timings spread over the recording by word length, with breaths after commas and full stops. */\nfunction timedWordsOf(text: string, duration: number): TimedWord[] {\n  const words = text.split(' ');\n  const lengths = words.map(spokenLengthOf);\n  const pauses = words.map(pauseAfter);\n  let total = 0;\n  words.forEach((_, index) => {\n    total += lengths[index] + pauses[index];\n  });\n  const room = duration - LEAD_IN_MS - TAIL_MS;\n  const scale = room / total;\n  const timed: TimedWord[] = [];\n  let cursor = LEAD_IN_MS;\n  words.forEach((word, index) => {\n    const spoken = lengths[index] * scale;\n    const breath = pauses[index] * scale;\n    timed.push({ text: word, start: cursor, end: cursor + spoken });\n    cursor += spoken + breath;\n  });\n  return timed;\n}\n\nfunction isSpeakingAt(words: TimedWord[], time: number) {\n  return words.some((word) => {\n    const hasStarted = word.start <= time;\n    const hasEnded = time > word.end;\n    return hasStarted && !hasEnded;\n  });\n}\n\nfunction levelsOf(words: TimedWord[], duration: number, columns: number) {\n  const levels: number[] = [];\n  for (let column = 0; column < columns; column += 1) {\n    const middle = (column + 0.5) / columns;\n    const time = middle * duration;\n    if (!isSpeakingAt(words, time)) {\n      levels.push(0);\n      continue;\n    }\n    const grain = noiseAt(column, 3.7);\n    levels.push(0.3 + grain * 0.7);\n  }\n  return levels;\n}\n\nconst NOTE_WORDS = timedWordsOf(NOTE_TEXT, NOTE_DURATION);\n\nconst NOTE_LEVELS = levelsOf(NOTE_WORDS, NOTE_DURATION, COLUMN_COUNT);\n\n/** The last word of the first sentence: the note opens paused there, part of the way through. */\nconst START_WORD = 10;\n\nconst START_POSITION = NOTE_WORDS[START_WORD].end;\n\n/** How long the demonstration listens at normal speed before it steps to 1.5x. */\nconst NORMAL_SPEED_MS = 4200;\n\nconst FAST_RATE = 1.5;\n\nfunction fastPlayMsOf() {\n  const playedMs = NORMAL_SPEED_MS + PRESS_LEAD_MS;\n  const leftMs = NOTE_DURATION - START_POSITION - playedMs;\n  return leftMs / FAST_RATE;\n}\n\nconst FAST_PLAY_MS = fastPlayMsOf();\n\nexport default function Voice02() {\n  const note = useRef<VoiceNoteHandle>(null);\n\n  const steps: AutoplayStep[] = [\n    { after: 1400, run: () => note.current?.press('play') },\n    { after: PRESS_LEAD_MS, run: () => note.current?.togglePlay() },\n    { after: NORMAL_SPEED_MS, run: () => note.current?.press('rate') },\n    { after: PRESS_LEAD_MS, run: () => note.current?.changeRate() },\n    { after: FAST_PLAY_MS + 700, run: hold },\n  ];\n  const { ref, isInView, isAutoplaying } = useAutoplay(steps, {\n    loopAfter: 2600,\n    onReset: () => note.current?.reset(START_POSITION),\n  });\n\n  useKeptHeight(ref);\n\n  return (\n    <div ref={ref} className='flex w-full max-w-[26rem] flex-col gap-2'>\n      <ClockGate isActive={isInView}>\n        <div className='bg-card hairline-ring ring-border rounded-xl p-4 shadow-[0_1px_2px_rgb(0_0_0/0.04)]'>\n          <p className='text-muted-foreground mb-3 text-xs'>\n            Voice reply from the assistant\n          </p>\n          <VoiceNote\n            label='Voice reply from the assistant'\n            duration={NOTE_DURATION}\n            levels={NOTE_LEVELS}\n            transcript={NOTE_WORDS}\n            defaultPosition={START_POSITION}\n            handleRef={note}\n            isDemonstrated={isAutoplaying}\n          />\n        </div>\n        <p className='text-muted-foreground px-1 text-[11px]'>\n          Illustrative recording: the playback is simulated by a clock\n        </p>\n      </ClockGate>\n    </div>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "categories": [
    "components",
    "voice"
  ],
  "type": "registry:component"
}