{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "illustration-04",
  "title": "Prompt to team",
  "description": "A request that types itself and is sent, then connectors draw down from it and three agent cards branch out, each filling its role, its model and its tools.",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "https://ui.ndekocode.dev/r/agent-run.json",
    "https://ui.ndekocode.dev/r/brand-logos.json",
    "https://ui.ndekocode.dev/r/brand-tile.json",
    "https://ui.ndekocode.dev/r/demonstration.json",
    "https://ui.ndekocode.dev/r/icons.json",
    "https://ui.ndekocode.dev/r/mesh-tile.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-prefers-reduced-motion.json",
    "https://ui.ndekocode.dev/r/utils.json"
  ],
  "files": [
    {
      "path": "registry/ndeko/components/illustration/illustration-04.tsx",
      "content": "'use client';\n\nimport { useMemo } from 'react';\n\nimport { seriesColorOf, type SeriesSlot } from '@/registry/ndeko/lib/agent-run';\nimport type { BrandSlug } from '@/registry/ndeko/lib/brand-logos';\nimport { prefixesOf } from '@/registry/ndeko/lib/demonstration';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { BrandTile } from '@/registry/ndeko/ui/brand-tile';\nimport { MeshTile } from '@/registry/ndeko/ui/mesh-tile';\n\nimport { delayWhile } from './_parts/delay';\nimport {\n  CHATGPT,\n  CLAUDE,\n  DEEPSEEK,\n  GEMINI,\n  MISTRAL,\n  type SceneModel,\n} from './_parts/models';\nimport { PromptField } from './_parts/prompt-field';\nimport { keyHoldOf } from './_parts/typing';\nimport { useSceneFrames, type SceneFrame } from './_parts/use-scene-frames';\nimport { useScenePlay } from './_parts/use-scene-play';\n\nexport type TeamTool = {\n  name: string;\n  brand: BrandSlug;\n};\n\nexport type TeamAgent = {\n  role: string;\n  series: SeriesSlot;\n  model: SceneModel;\n  tools: TeamTool[];\n};\n\nexport type TeamPlay = {\n  prompt: string;\n  agents: TeamAgent[];\n};\n\n/** How much of the team shows: nothing, the connectors, the cards with their roles, then their models and tools. */\ntype Reveal = 0 | 1 | 2 | 3;\n\ntype Beat = {\n  playIndex: number;\n  typed: string;\n  isSending: boolean;\n  reveal: Reveal;\n};\n\nconst REST_MS = 2800;\n\nconst LEAVE_MS = 260;\n\nconst CLEAR_MS = 620;\n\nconst CHARACTER_MS = 44;\n\nconst BEFORE_SEND_MS = 340;\n\nconst SEND_MS = 220;\n\nconst BRANCH_MS = 520;\n\nconst CARDS_MS = 640;\n\nconst CARD_STAGGER_MS = 90;\n\nconst TOOLS_AFTER_MODEL_MS = 140;\n\nconst CARD_GAP_REM = 0.5;\n\nconst TYPING_SEED = 3;\n\nfunction beatsOfPlay(playIndex: number, prompt: string) {\n  const prefixes = prefixesOf(prompt);\n  const beats: SceneFrame<Beat>[] = [];\n  const empty: Beat = { playIndex, typed: '', isSending: false, reveal: 0 };\n  const whole: Beat = { ...empty, typed: prompt };\n  beats.push({ state: empty, holdMs: CLEAR_MS });\n  prefixes.forEach((typed, index) => {\n    const holdMs = keyHoldOf(index, CHARACTER_MS, TYPING_SEED);\n    beats.push({ state: { ...empty, typed }, holdMs });\n  });\n  beats.push({ state: whole, holdMs: BEFORE_SEND_MS });\n  beats.push({ state: { ...whole, isSending: true }, holdMs: SEND_MS });\n  beats.push({ state: { ...whole, reveal: 1 }, holdMs: BRANCH_MS });\n  beats.push({ state: { ...whole, reveal: 2 }, holdMs: CARDS_MS });\n  beats.push({ state: restOf(playIndex, prompt), holdMs: REST_MS });\n  return beats;\n}\n\nfunction restOf(playIndex: number, prompt: string): Beat {\n  return { playIndex, typed: prompt, isSending: false, reveal: 3 };\n}\n\n/**\n * The book opens on the first team at rest. Every play is then typed, sent and branched in turn, and\n * the round ends on the beats that bring the first play back, so the loop closes on its first frame.\n * Before a play, the team on stage leaves: the cards fade out while they still hold their own content.\n */\nfunction beatsOf(plays: TeamPlay[]) {\n  const first = plays[0];\n  if (!first) {\n    const blank: Beat = {\n      playIndex: 0,\n      typed: '',\n      isSending: false,\n      reveal: 0,\n    };\n    return [{ state: blank, holdMs: REST_MS }];\n  }\n  let leaving = restOf(0, first.prompt);\n  const beats: SceneFrame<Beat>[] = [{ state: leaving, holdMs: REST_MS }];\n  for (let offset = 1; offset <= plays.length; offset += 1) {\n    const playIndex = offset % plays.length;\n    const play = plays[playIndex];\n    beats.push({ state: { ...leaving, reveal: 0 }, holdMs: LEAVE_MS });\n    beats.push(...beatsOfPlay(playIndex, play.prompt));\n    leaving = restOf(playIndex, play.prompt);\n  }\n  beats.pop();\n  return beats;\n}\n\n/** A card is a seat, not an agent: it stays mounted when the team changes, so it can fade out and in. */\nfunction seatKeyOf(index: number) {\n  return `seat-${index}`;\n}\n\nfunction isRevealed(reveal: Reveal, level: Reveal) {\n  return reveal >= level;\n}\n\nfunction columnsOf(count: number) {\n  return { gridTemplateColumns: `repeat(${count}, minmax(0, 1fr))` };\n}\n\nfunction labelOf(play: TeamPlay) {\n  const roles = play.agents.map((agent) => agent.role);\n  const team = roles.join(', ');\n  return `The request \"${play.prompt}\" becomes a team: ${team}`;\n}\n\nconst LINE = 'bg-foreground/15 absolute';\n\nconst DETAIL =\n  'flex min-w-0 items-center opacity-0 transition-opacity duration-150 data-[shown=true]:opacity-100 data-[shown=true]:duration-300';\n\ntype ConnectorsProps = {\n  count: number;\n  isDrawn: boolean;\n};\n\nfunction Connectors({ count, isDrawn }: ConnectorsProps) {\n  const gaps = (count - 1) * CARD_GAP_REM;\n  const halves = count * 2;\n  const halfColumn = `calc((100% - ${gaps}rem) / ${halves})`;\n  const drops = Array.from({ length: count }, (_, index) => index);\n\n  return (\n    <div className='relative h-7'>\n      <span\n        data-drawn={isDrawn}\n        className={cn(\n          LINE,\n          'top-0 left-1/2 h-3 w-px origin-top scale-y-0 transition-transform duration-200 ease-(--ease-out-strong) data-[drawn=true]:scale-y-100'\n        )}\n      />\n      <span\n        data-drawn={isDrawn}\n        style={{ left: halfColumn, right: halfColumn }}\n        className={cn(\n          LINE,\n          'top-3 h-px scale-x-0 transition-transform duration-300 ease-(--ease-out-strong) data-[drawn=true]:scale-x-100 data-[drawn=true]:delay-150'\n        )}\n      />\n      <div\n        style={columnsOf(count)}\n        className='absolute inset-x-0 top-3 grid h-4 gap-2'\n      >\n        {drops.map((drop) => (\n          <span key={drop} className='relative'>\n            <span\n              data-drawn={isDrawn}\n              className={cn(\n                LINE,\n                'inset-y-0 left-1/2 w-px origin-top scale-y-0 transition-transform duration-200 ease-(--ease-out-strong) data-[drawn=true]:scale-y-100 data-[drawn=true]:delay-300'\n              )}\n            />\n          </span>\n        ))}\n      </div>\n    </div>\n  );\n}\n\ntype AgentCardProps = {\n  agent: TeamAgent;\n  order: number;\n  reveal: Reveal;\n};\n\nfunction AgentCard({ agent, order, reveal }: AgentCardProps) {\n  const isShown = isRevealed(reveal, 2);\n  const hasDetails = isRevealed(reveal, 3);\n  const cardDelayMs = order * CARD_STAGGER_MS;\n  const toolsDelayMs = cardDelayMs + TOOLS_AFTER_MODEL_MS;\n\n  return (\n    <div\n      data-shown={isShown}\n      style={delayWhile(isShown, cardDelayMs)}\n      className='bg-card hairline-ring ring-border flex min-w-0 -translate-y-1.5 flex-col gap-1.5 rounded-lg p-2 opacity-0 shadow-[0_1px_2px_rgb(0_0_0/0.04)] transition-[opacity,translate] duration-150 ease-(--ease-out-strong) data-[shown=true]:translate-y-0 data-[shown=true]:opacity-100 data-[shown=true]:duration-300 @sm:p-2.5'\n    >\n      <MeshTile\n        seed={agent.role}\n        color={seriesColorOf(agent.series)}\n        className='block'\n      />\n      <p className='truncate text-xs leading-4 font-medium'>{agent.role}</p>\n      <p\n        data-shown={hasDetails}\n        style={delayWhile(hasDetails, cardDelayMs)}\n        className={cn(DETAIL, 'gap-1.5')}\n      >\n        <BrandTile brand={agent.model.brand} size='sm' />\n        <span className='text-muted-foreground truncate text-[11px] leading-4'>\n          {agent.model.name}\n        </span>\n      </p>\n      <p\n        data-shown={hasDetails}\n        style={delayWhile(hasDetails, toolsDelayMs)}\n        className={cn(DETAIL, 'gap-1')}\n      >\n        {agent.tools.map((tool) => (\n          <BrandTile key={tool.name} brand={tool.brand} />\n        ))}\n      </p>\n    </div>\n  );\n}\n\nexport type PromptToTeamProps = {\n  /** The requests the scene types in turn, each with the team it becomes. */\n  plays: TeamPlay[];\n  className?: string;\n};\n\nexport function PromptToTeam({ plays, className }: PromptToTeamProps) {\n  const { ref, isPlaying, isStill } = useScenePlay();\n  const beats = useMemo(() => beatsOf(plays), [plays]);\n  const beat = useSceneFrames(beats, { isPlaying, isStill });\n  const play = plays[beat.playIndex];\n\n  if (!play) {\n    return null;\n  }\n\n  const count = Math.max(play.agents.length, 1);\n  const isTyping = beat.reveal === 0;\n  const isBranched = isRevealed(beat.reveal, 1);\n\n  return (\n    <div\n      ref={ref}\n      role='img'\n      aria-label={labelOf(play)}\n      className={cn('@container flex w-full max-w-[26rem] flex-col', className)}\n    >\n      <PromptField\n        typed={beat.typed}\n        isSending={beat.isSending}\n        isTyping={isTyping}\n      />\n      <Connectors count={count} isDrawn={isBranched} />\n      <div style={columnsOf(count)} className='grid gap-2'>\n        {play.agents.map((agent, index) => (\n          <AgentCard\n            key={seatKeyOf(index)}\n            agent={agent}\n            order={index}\n            reveal={beat.reveal}\n          />\n        ))}\n      </div>\n    </div>\n  );\n}\n\nconst PLAYS: TeamPlay[] = [\n  {\n    prompt: 'Find why signups dropped last week',\n    agents: [\n      {\n        role: 'Researcher',\n        series: 2,\n        model: CLAUDE,\n        tools: [\n          { name: 'Notion', brand: 'notion' },\n          { name: 'Google Drive', brand: 'googledrive' },\n        ],\n      },\n      {\n        role: 'Analyst',\n        series: 3,\n        model: GEMINI,\n        tools: [\n          { name: 'PostgreSQL', brand: 'postgresql' },\n          { name: 'Stripe', brand: 'stripe' },\n        ],\n      },\n      {\n        role: 'Writer',\n        series: 4,\n        model: CHATGPT,\n        tools: [\n          { name: 'Google Docs', brand: 'googledocs' },\n          { name: 'Gmail', brand: 'gmail' },\n        ],\n      },\n    ],\n  },\n  {\n    prompt: 'Fix the failing checkout tests',\n    agents: [\n      {\n        role: 'Planner',\n        series: 1,\n        model: MISTRAL,\n        tools: [\n          { name: 'Linear', brand: 'linear' },\n          { name: 'Sentry', brand: 'sentry' },\n        ],\n      },\n      {\n        role: 'Coder',\n        series: 5,\n        model: CLAUDE,\n        tools: [\n          { name: 'GitHub', brand: 'github' },\n          { name: 'Vercel', brand: 'vercel' },\n        ],\n      },\n      {\n        role: 'Reviewer',\n        series: 4,\n        model: DEEPSEEK,\n        tools: [\n          { name: 'GitHub', brand: 'github' },\n          { name: 'Linear', brand: 'linear' },\n        ],\n      },\n    ],\n  },\n];\n\nexport default function Illustration04() {\n  return <PromptToTeam plays={PLAYS} />;\n}\n",
      "type": "registry:component",
      "target": "components/illustration/illustration-04.tsx"
    },
    {
      "path": "registry/ndeko/components/illustration/_parts/delay.ts",
      "content": "/**\n * A stagger belongs to an entrance. On the way out everything leaves together, so the delay only\n * applies while its element is shown.\n */\nexport function delayWhile(isShown: boolean, delayMs: number) {\n  if (isShown) {\n    return { transitionDelay: `${delayMs}ms` };\n  }\n  return { transitionDelay: '0ms' };\n}\n",
      "type": "registry:component",
      "target": "components/illustration/_parts/delay.ts"
    },
    {
      "path": "registry/ndeko/components/illustration/_parts/models.ts",
      "content": "import type { BrandSlug } from '@/registry/ndeko/lib/brand-logos';\n\nexport type SceneModel = {\n  id: string;\n  /** The name people call the model by, without a version number. */\n  name: string;\n  brand: BrandSlug;\n};\n\nexport const CLAUDE: SceneModel = {\n  id: 'claude',\n  name: 'Claude',\n  brand: 'claude',\n};\n\nexport const CHATGPT: SceneModel = {\n  id: 'chatgpt',\n  name: 'ChatGPT',\n  brand: 'openai',\n};\n\nexport const GEMINI: SceneModel = {\n  id: 'gemini',\n  name: 'Gemini',\n  brand: 'gemini',\n};\n\nexport const MISTRAL: SceneModel = {\n  id: 'mistral',\n  name: 'Mistral',\n  brand: 'mistral',\n};\n\nexport const DEEPSEEK: SceneModel = {\n  id: 'deepseek',\n  name: 'DeepSeek',\n  brand: 'deepseek',\n};\n\nexport const LLAMA: SceneModel = {\n  id: 'llama',\n  name: 'Llama',\n  brand: 'meta',\n};\n\nexport const GROK: SceneModel = {\n  id: 'grok',\n  name: 'Grok',\n  brand: 'grok',\n};\n\nexport const QWEN: SceneModel = {\n  id: 'qwen',\n  name: 'Qwen',\n  brand: 'qwen',\n};\n\nexport const COMMAND: SceneModel = {\n  id: 'command',\n  name: 'Command',\n  brand: 'cohere',\n};\n\nexport const SONAR: SceneModel = {\n  id: 'sonar',\n  name: 'Sonar',\n  brand: 'perplexity',\n};\n",
      "type": "registry:component",
      "target": "components/illustration/_parts/models.ts"
    },
    {
      "path": "registry/ndeko/components/illustration/_parts/prompt-field.tsx",
      "content": "import { pressedSolidOf } from '@/registry/ndeko/lib/demonstration';\nimport { ArrowUpIcon } from '@/registry/ndeko/lib/icons';\nimport { cn } from '@/registry/ndeko/lib/utils';\n\ntype PromptFieldProps = {\n  typed: string;\n  /** Shows the caret after the text. */\n  isTyping: boolean;\n  /** Holds the send key down. */\n  isSending: boolean;\n  /** The line leaves upwards, as a request that has just been sent. */\n  isSent?: boolean;\n  /** A new key starts the next line in place, so it does not come back down the way the last one left. */\n  lineKey?: number;\n};\n\n/** The drawing of a prompt field for a scene: a line that a script types, and a send key it presses. */\nexport function PromptField({\n  typed,\n  isTyping,\n  isSending,\n  isSent = false,\n  lineKey = 0,\n}: PromptFieldProps) {\n  return (\n    <div className='bg-card hairline-ring ring-border flex h-10 items-center gap-2 rounded-xl ps-3.5 pe-1.5 shadow-[0_1px_2px_rgb(0_0_0/0.05)]'>\n      <p\n        key={lineKey}\n        data-sent={isSent}\n        className='min-w-0 flex-1 truncate text-[13px] leading-5 transition-[opacity,translate] duration-200 ease-(--ease-out-strong) data-[sent=true]:-translate-y-2 data-[sent=true]:opacity-0'\n      >\n        {typed}\n        {isTyping && (\n          <span className='bg-foreground ms-px inline-block h-4 w-px align-text-bottom' />\n        )}\n      </p>\n      <span\n        className={cn(\n          'bg-primary text-primary-foreground flex size-7 shrink-0 items-center justify-center rounded-full transition-[scale,background-color] duration-150 ease-(--ease-out-strong)',\n          pressedSolidOf(isSending)\n        )}\n      >\n        <ArrowUpIcon className='size-4' />\n      </span>\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/illustration/_parts/prompt-field.tsx"
    },
    {
      "path": "registry/ndeko/components/illustration/_parts/typing.ts",
      "content": "import { noiseAt } from '@/registry/ndeko/lib/speech-envelope';\n\nconst SHORTEST_STRETCH = 0.55;\n\nconst STRETCH_SPAN = 0.95;\n\n/**\n * A person does not type at a steady pace: the wait after each key stretches or shrinks around\n * `characterMs`, the same way on every round. A scene picks its own `seed` so two scenes do not type\n * in step.\n */\nexport function keyHoldOf(index: number, characterMs: number, seed: number) {\n  const noise = noiseAt(index, seed);\n  const stretch = SHORTEST_STRETCH + noise * STRETCH_SPAN;\n  return characterMs * stretch;\n}\n",
      "type": "registry:component",
      "target": "components/illustration/_parts/typing.ts"
    },
    {
      "path": "registry/ndeko/components/illustration/_parts/use-scene-frames.ts",
      "content": "'use client';\n\nimport { useEffect, useState } from 'react';\n\nimport type { ScenePlay } from './use-scene-play';\n\nexport type SceneFrame<State> = {\n  state: State;\n  /** Milliseconds the scene stays in this state before the next one. */\n  holdMs: number;\n};\n\nfunction nextIndexOf(index: number, count: number) {\n  const next = index + 1;\n  return next % count;\n}\n\n/**\n * A scene told as a flipbook: whole states, each held for a while, played in a loop. The first frame\n * is the resting picture: it shows before the scene plays and under reduced motion. While the scene\n * does not play the book stays on its page and no timer is left. `frames` holds at least one frame.\n */\nexport function useSceneFrames<State>(\n  frames: readonly SceneFrame<State>[],\n  { isPlaying, isStill }: ScenePlay\n) {\n  const [index, setIndex] = useState(0);\n  const frameCount = frames.length;\n  const shownIndex = index % frameCount;\n  const frame = frames[shownIndex];\n  const holdMs = frame.holdMs;\n\n  useEffect(() => {\n    if (!isPlaying) {\n      return;\n    }\n    const timer = window.setTimeout(() => {\n      setIndex(nextIndexOf(shownIndex, frameCount));\n    }, holdMs);\n    return () => window.clearTimeout(timer);\n  }, [isPlaying, shownIndex, frameCount, holdMs]);\n\n  if (isStill) {\n    return frames[0].state;\n  }\n  return frame.state;\n}\n",
      "type": "registry:component",
      "target": "components/illustration/_parts/use-scene-frames.ts"
    },
    {
      "path": "registry/ndeko/components/illustration/_parts/use-scene-play.ts",
      "content": "'use client';\n\nimport { useInView } from 'motion/react';\nimport { useRef } from 'react';\n\nimport { useDocumentVisible } from '@/registry/ndeko/hooks/use-agent-run';\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\n\nconst IN_VIEW_SHARE = 0.3;\n\nexport type ScenePlay = {\n  /** True while a visitor can see the scene move: on screen, in a visible tab, without reduced motion. */\n  isPlaying: boolean;\n  /** True under reduced motion: the scene rests on its still frame. */\n  isStill: boolean;\n};\n\n/**\n * An illustration moves only while someone can see it. Everything that loops in a scene hangs on\n * `isPlaying`, so nothing runs off screen, in a hidden tab or under reduced motion.\n */\nexport function useScenePlay<Element extends HTMLElement = HTMLDivElement>() {\n  const ref = useRef<Element>(null);\n  const isInView = useInView(ref, { amount: IN_VIEW_SHARE });\n  const isTabVisible = useDocumentVisible();\n  const isStill = usePrefersReducedMotion();\n  const isOnScreen = isInView && isTabVisible;\n  const isPlaying = isOnScreen && !isStill;\n\n  return { ref, isPlaying, isStill };\n}\n",
      "type": "registry:component",
      "target": "components/illustration/_parts/use-scene-play.ts"
    }
  ],
  "categories": [
    "components",
    "illustration"
  ],
  "type": "registry:component"
}