{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "ai-product-07",
  "title": "Direction picker",
  "description": "Four visual directions drawn as small compositions: the one you pick grows into an editable brief with its palette, type pair and three keywords, then Generate turns into its own progress and the options arrive in order.",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "https://ui.ndekocode.dev/r/button.json",
    "https://ui.ndekocode.dev/r/chat-motion.json",
    "https://ui.ndekocode.dev/r/chip.json",
    "https://ui.ndekocode.dev/r/demonstration.json",
    "https://ui.ndekocode.dev/r/icons.json",
    "https://ui.ndekocode.dev/r/input.json",
    "https://ui.ndekocode.dev/r/live-region.json",
    "https://ui.ndekocode.dev/r/motion-presets.json",
    "https://ui.ndekocode.dev/r/replay-button.json",
    "https://ui.ndekocode.dev/r/settle.json",
    "https://ui.ndekocode.dev/r/theme.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/use-session.json",
    "https://ui.ndekocode.dev/r/utils.json"
  ],
  "files": [
    {
      "path": "registry/ndeko/blocks/ai-product/ai-product-07/index.tsx",
      "content": "'use client';\n\nimport { useCallback } from 'react';\n\nimport { useKeptHeight } from '@/registry/ndeko/hooks/use-kept-height';\nimport { useSession } from '@/registry/ndeko/hooks/use-session';\nimport { spokenUnless } from '@/registry/ndeko/lib/demonstration';\nimport { SwatchBookIcon } from '@/registry/ndeko/lib/icons';\nimport { LiveRegion } from '@/registry/ndeko/ui/live-region';\nimport { ReplayButton } from '@/registry/ndeko/ui/replay-button';\n\nimport { BriefPanel } from './brief-panel';\nimport { SECTION } from './data';\nimport { DirectionTiles } from './direction-tiles';\nimport { INITIAL, LOOP_AFTER_MS, reducer, RESTING, SCRIPT } from './session';\n\nconst SESSION = {\n  reducer,\n  initial: INITIAL,\n  resting: RESTING,\n  script: SCRIPT,\n  loopAfter: LOOP_AFTER_MS,\n};\n\nexport default function AiProduct07() {\n  const { ref, isAutoplaying, state, act, pressed, isFinished, restart } =\n    useSession(SESSION);\n  useKeptHeight(ref);\n  const message = spokenUnless(isAutoplaying, state.spoken);\n  const canReplay = isFinished && !isAutoplaying;\n\n  const focusLater = useCallback(\n    (selector: string) => {\n      requestAnimationFrame(() => {\n        const target = ref.current?.querySelector<HTMLElement>(selector);\n        target?.focus();\n      });\n    },\n    [ref]\n  );\n\n  /** The button leaves with the results, so the focus goes back to the first direction. */\n  function startOver() {\n    act({ type: 'startedOver' });\n    focusLater('[data-direction-tile]');\n  }\n\n  return (\n    <section ref={ref} className='@container min-h-[96rem] @3xl:min-h-[52rem]'>\n      <div className='mx-auto flex max-w-6xl flex-col gap-10 px-4 py-16 @2xl:px-6 @2xl:py-24 @5xl:px-8'>\n        <header className='flex flex-wrap items-end justify-between gap-x-6 gap-y-4'>\n          <div className='flex max-w-2xl flex-col gap-3'>\n            <p className='text-primary-ink flex items-center gap-1.5 text-[13px] font-medium'>\n              <SwatchBookIcon className='size-4' />\n              {SECTION.label}\n            </p>\n            <h2 className='text-2xl font-semibold text-balance @2xl:text-3xl'>\n              {SECTION.title}\n            </h2>\n            <p className='text-muted-foreground text-base text-pretty'>\n              {SECTION.lead}\n            </p>\n          </div>\n          <ReplayButton isShown={canReplay} onReplay={restart} label='Replay' />\n        </header>\n        <div className='grid gap-6 @3xl:grid-cols-[22rem_minmax(0,1fr)] @3xl:items-start'>\n          <DirectionTiles\n            pickedId={state.pickedId}\n            pressed={pressed}\n            onPick={(id) => act({ type: 'picked', id })}\n          />\n          <BriefPanel\n            state={state}\n            pressed={pressed}\n            onKeyword={(index, text) =>\n              act({ type: 'keywordEdited', index, text })\n            }\n            onGenerate={() => act({ type: 'generateStarted' })}\n            onStartOver={startOver}\n          />\n        </div>\n      </div>\n      <LiveRegion message={message} />\n    </section>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/ai-product-07/index.tsx"
    },
    {
      "path": "registry/ndeko/blocks/ai-product/ai-product-07/direction-tiles.tsx",
      "content": "'use client';\n\nimport { motion } from 'motion/react';\n\nimport { pressedQuietOf } from '@/registry/ndeko/lib/demonstration';\nimport { cn } from '@/registry/ndeko/lib/utils';\n\nimport { DIRECTIONS, type Direction, type DirectionId } from './data';\nimport { DirectionArt } from './direction-art';\n\nconst ART_STYLE = { borderRadius: 10 };\n\nfunction toneOf(isPicked: boolean, isSteppedBack: boolean) {\n  if (isPicked) {\n    return 'bg-foreground/[0.08]';\n  }\n  if (isSteppedBack) {\n    return 'bg-foreground/[0.03] opacity-60 scale-[0.97] hover:opacity-100';\n  }\n  return 'bg-foreground/[0.04] hover:bg-foreground/[0.07]';\n}\n\ntype TileProps = {\n  direction: Direction;\n  isPicked: boolean;\n  isSteppedBack: boolean;\n  pressed: string | null;\n  onPick: (id: DirectionId) => void;\n};\n\nfunction DirectionTile({\n  direction,\n  isPicked,\n  isSteppedBack,\n  pressed,\n  onPick,\n}: TileProps) {\n  const isPressed = pressed === `tile-${direction.id}`;\n\n  return (\n    <button\n      type='button'\n      data-direction-tile={direction.id}\n      aria-pressed={isPicked}\n      onClick={() => onPick(direction.id)}\n      className={cn(\n        'focus-visible:ring-ring/25 flex w-full cursor-pointer flex-col gap-2 rounded-xl p-2 text-start transition-[background-color,opacity,scale] duration-200 ease-(--ease-out-strong) outline-none focus-visible:ring-[3px] active:scale-[0.97]',\n        toneOf(isPicked, isSteppedBack),\n        pressedQuietOf(isPressed)\n      )}\n    >\n      <span className='block overflow-hidden rounded-[10px]'>\n        {!isPicked && (\n          <motion.span\n            layoutId={`art-${direction.id}`}\n            style={ART_STYLE}\n            className='block overflow-hidden'\n          >\n            <DirectionArt direction={direction} />\n          </motion.span>\n        )}\n        {isPicked && (\n          <span className='bg-foreground/[0.06] block aspect-[4/3] w-full' />\n        )}\n      </span>\n      <span className='px-1 text-[13px] font-medium'>{direction.name}</span>\n    </button>\n  );\n}\n\ntype DirectionTilesProps = {\n  pickedId: DirectionId | null;\n  pressed: string | null;\n  onPick: (id: DirectionId) => void;\n};\n\nexport function DirectionTiles({\n  pickedId,\n  pressed,\n  onPick,\n}: DirectionTilesProps) {\n  const hasPicked = pickedId !== null;\n\n  return (\n    <ul aria-label='Visual directions' className='grid grid-cols-2 gap-3'>\n      {DIRECTIONS.map((direction) => {\n        const isPicked = pickedId === direction.id;\n        return (\n          <li key={direction.id}>\n            <DirectionTile\n              direction={direction}\n              isPicked={isPicked}\n              isSteppedBack={hasPicked && !isPicked}\n              pressed={pressed}\n              onPick={onPick}\n            />\n          </li>\n        );\n      })}\n    </ul>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/ai-product-07/direction-tiles.tsx"
    },
    {
      "path": "registry/ndeko/blocks/ai-product/ai-product-07/direction-art.tsx",
      "content": "import type { CSSProperties } from 'react';\n\nimport { cn } from '@/registry/ndeko/lib/utils';\n\nimport { FONT_CLASS, type Direction, type ShapeKind } from './data';\n\nconst SHAPE_CLASS: Record<ShapeKind, string> = {\n  circle: 'rounded-full',\n  square: 'rounded-[12%]',\n  triangle: '',\n  arch: 'rounded-t-full',\n};\n\nconst TRIANGLE = 'polygon(50% 0, 100% 100%, 0 100%)';\n\ntype ShapeProps = {\n  kind: ShapeKind;\n  color: string;\n  className?: string;\n};\n\nfunction Shape({ kind, color, className }: ShapeProps) {\n  const style: CSSProperties = { backgroundColor: color };\n  if (kind === 'triangle') {\n    style.clipPath = TRIANGLE;\n  }\n  return (\n    <span\n      aria-hidden='true'\n      style={style}\n      className={cn('absolute', SHAPE_CLASS[kind], className)}\n    />\n  );\n}\n\ntype DirectionArtProps = {\n  direction: Direction;\n};\n\n/**\n * A small composition of one direction: its type, two shapes and its four colours. Sizes are in\n * container units, so the same drawing holds at any size and can grow from a tile into a brief.\n */\nexport function DirectionArt({ direction }: DirectionArtProps) {\n  const [paper, ink, accent, soft] = direction.swatches;\n\n  return (\n    <span\n      aria-hidden='true'\n      style={{ backgroundColor: paper.color }}\n      className='@container relative block aspect-[4/3] w-full overflow-hidden'\n    >\n      <span\n        style={{ color: ink.color }}\n        className={cn(\n          'absolute start-[8cqw] top-[6cqw] text-[30cqw] leading-none font-semibold',\n          FONT_CLASS[direction.display]\n        )}\n      >\n        Aa\n      </span>\n      <Shape\n        kind={direction.shapes[0]}\n        color={accent.color}\n        className='end-[24cqw] top-[10cqw] size-[22cqw]'\n      />\n      <Shape\n        kind={direction.shapes[1]}\n        color={soft.color}\n        className='end-[7cqw] top-[22cqw] size-[16cqw]'\n      />\n      <span className='absolute inset-x-[8cqw] bottom-[8cqw] flex h-[11cqw] gap-[2cqw]'>\n        {direction.swatches.map((swatch) => (\n          <span\n            key={swatch.name}\n            style={{ backgroundColor: swatch.color }}\n            className='hairline-ring flex-1 rounded-[2cqw] ring-black/10'\n          />\n        ))}\n      </span>\n    </span>\n  );\n}\n\ntype ResultArtProps = {\n  direction: Direction;\n};\n\nfunction ResultFrame({\n  direction,\n  children,\n}: ResultArtProps & { children: React.ReactNode }) {\n  const [paper] = direction.swatches;\n\n  return (\n    <span\n      aria-hidden='true'\n      style={{ backgroundColor: paper.color }}\n      className='@container relative block aspect-[4/3] w-full overflow-hidden'\n    >\n      {children}\n    </span>\n  );\n}\n\nfunction SplitResult({ direction }: ResultArtProps) {\n  const [, , accent, soft] = direction.swatches;\n\n  return (\n    <ResultFrame direction={direction}>\n      <span\n        style={{ backgroundColor: accent.color }}\n        className='absolute inset-y-0 end-0 w-[46%]'\n      />\n      <Shape\n        kind={direction.shapes[0]}\n        color={soft.color}\n        className='end-[10cqw] top-[22cqw] size-[28cqw]'\n      />\n    </ResultFrame>\n  );\n}\n\nfunction TypeResult({ direction }: ResultArtProps) {\n  const [, ink, accent] = direction.swatches;\n\n  return (\n    <ResultFrame direction={direction}>\n      <span\n        style={{ color: ink.color }}\n        className={cn(\n          'absolute start-[10cqw] top-[12cqw] text-[40cqw] leading-none font-semibold',\n          FONT_CLASS[direction.display]\n        )}\n      >\n        Ab\n      </span>\n      <span\n        style={{ backgroundColor: accent.color }}\n        className='absolute inset-x-[10cqw] bottom-[12cqw] h-[5cqw] rounded-full'\n      />\n    </ResultFrame>\n  );\n}\n\nfunction PosterResult({ direction }: ResultArtProps) {\n  const [, ink, accent, soft] = direction.swatches;\n\n  return (\n    <ResultFrame direction={direction}>\n      <span\n        style={{ backgroundColor: accent.color }}\n        className='absolute inset-x-[14cqw] top-[10cqw] bottom-0 rounded-t-full'\n      />\n      <span\n        style={{ backgroundColor: soft.color }}\n        className='absolute start-[26cqw] top-[34cqw] size-[22cqw] rounded-full'\n      />\n      <span\n        style={{ backgroundColor: ink.color }}\n        className='absolute inset-x-0 bottom-0 h-[10cqw]'\n      />\n    </ResultFrame>\n  );\n}\n\nfunction GridResult({ direction }: ResultArtProps) {\n  const [, ink, accent, soft] = direction.swatches;\n  const colors = [accent.color, ink.color, soft.color, accent.color];\n\n  return (\n    <ResultFrame direction={direction}>\n      <span className='absolute inset-[10cqw] grid grid-cols-2 gap-[3cqw]'>\n        {colors.map((color, index) => (\n          <span\n            key={index}\n            style={{ backgroundColor: color }}\n            className='rounded-[4cqw]'\n          />\n        ))}\n      </span>\n    </ResultFrame>\n  );\n}\n\nfunction BarsResult({ direction }: ResultArtProps) {\n  const [, ink, accent, soft] = direction.swatches;\n\n  return (\n    <ResultFrame direction={direction}>\n      <span className='absolute inset-x-[10cqw] bottom-[10cqw] flex h-[50cqw] items-end gap-[3cqw]'>\n        <span\n          style={{ backgroundColor: soft.color }}\n          className='h-[40%] flex-1 rounded-[2cqw]'\n        />\n        <span\n          style={{ backgroundColor: accent.color }}\n          className='h-[100%] flex-1 rounded-[2cqw]'\n        />\n        <span\n          style={{ backgroundColor: ink.color }}\n          className='h-[65%] flex-1 rounded-[2cqw]'\n        />\n      </span>\n    </ResultFrame>\n  );\n}\n\nfunction RingResult({ direction }: ResultArtProps) {\n  const [, ink, accent] = direction.swatches;\n\n  return (\n    <ResultFrame direction={direction}>\n      <span\n        style={{ borderColor: accent.color }}\n        className='absolute start-[28cqw] top-[10cqw] size-[44cqw] rounded-full border-[7cqw]'\n      />\n      <span\n        style={{ backgroundColor: ink.color }}\n        className='absolute start-[50cqw] top-[32cqw] size-[10cqw] rounded-full'\n      />\n    </ResultFrame>\n  );\n}\n\nconst RESULT_ARTS = [\n  SplitResult,\n  TypeResult,\n  PosterResult,\n  GridResult,\n  BarsResult,\n  RingResult,\n];\n\ntype ResultProps = {\n  direction: Direction;\n  index: number;\n};\n\nexport function ResultDrawing({ direction, index }: ResultProps) {\n  const Art = RESULT_ARTS[index % RESULT_ARTS.length];\n\n  return <Art direction={direction} />;\n}\n",
      "type": "registry:component",
      "target": "components/blocks/ai-product-07/direction-art.tsx"
    },
    {
      "path": "registry/ndeko/blocks/ai-product/ai-product-07/brief-panel.tsx",
      "content": "'use client';\n\nimport { motion, type Transition } from 'motion/react';\n\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport { EASE_OUT_STRONG } from '@/registry/ndeko/lib/motion-presets';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { Fold } from '@/registry/ndeko/ui/chat-motion';\nimport { Chip } from '@/registry/ndeko/ui/chip';\nimport { Input } from '@/registry/ndeko/ui/input';\nimport { Settle, SettleItem } from '@/registry/ndeko/ui/settle';\n\nimport {\n  directionOf,\n  FONT_CLASS,\n  FONT_LABEL,\n  RESULT_INDEXES,\n  type Direction,\n} from './data';\nimport { DirectionArt, ResultDrawing } from './direction-art';\nimport { GenerateBar } from './generate-bar';\nimport type { DirectionState } from './session';\n\nconst ART_STYLE = { borderRadius: 10 };\n\nconst REVEAL: Transition = {\n  duration: 0.3,\n  ease: EASE_OUT_STRONG,\n  delay: 0.18,\n};\n\nconst REVEAL_STILL: Transition = { duration: 0.2 };\n\nfunction revealOf(shouldReduceMotion: boolean) {\n  if (shouldReduceMotion) {\n    return {\n      initial: { opacity: 0 },\n      animate: { opacity: 1 },\n      transition: REVEAL_STILL,\n    };\n  }\n  return {\n    initial: { opacity: 0, y: 6 },\n    animate: { opacity: 1, y: 0 },\n    transition: REVEAL,\n  };\n}\n\nfunction EmptySlot() {\n  return (\n    <div className='hairline-border border-foreground/20 flex min-h-48 flex-col items-start justify-center gap-1 rounded-xl border-dashed p-6'>\n      <p className='text-sm font-medium'>No direction picked yet</p>\n      <p className='text-muted-foreground max-w-sm text-[13px] text-pretty'>\n        Its palette, type pair and three keywords land here as a brief you can\n        change\n      </p>\n    </div>\n  );\n}\n\nfunction PaletteChips({ direction }: { direction: Direction }) {\n  return (\n    <ul aria-label='Palette' className='flex flex-wrap gap-1.5'>\n      {direction.swatches.map((swatch) => (\n        <li key={swatch.name}>\n          <Chip color={swatch.color}>{swatch.name}</Chip>\n        </li>\n      ))}\n    </ul>\n  );\n}\n\nfunction TypePair({ direction }: { direction: Direction }) {\n  return (\n    <div className='flex flex-col gap-1'>\n      <p\n        className={cn(\n          'text-xl leading-tight font-semibold',\n          FONT_CLASS[direction.display]\n        )}\n      >\n        {FONT_LABEL[direction.display]} for headlines\n      </p>\n      <p className={cn('text-[13px]', FONT_CLASS[direction.text])}>\n        {FONT_LABEL[direction.text]} for the text that is read at length\n      </p>\n    </div>\n  );\n}\n\ntype KeywordsProps = {\n  keywords: string[];\n  isLocked: boolean;\n  onEdit: (index: number, text: string) => void;\n};\n\nfunction Keywords({ keywords, isLocked, onEdit }: KeywordsProps) {\n  return (\n    <ul aria-label='Keywords' className='flex flex-wrap gap-1.5'>\n      {keywords.map((keyword, index) => (\n        <li key={index}>\n          <Input\n            size='sm'\n            aria-label={`Keyword ${index + 1}`}\n            autoComplete='off'\n            maxLength={24}\n            value={keyword}\n            disabled={isLocked}\n            onChange={(event) => onEdit(index, event.target.value)}\n            className='field-sizing-content w-auto min-w-20'\n          />\n        </li>\n      ))}\n    </ul>\n  );\n}\n\nconst GRID = 'grid grid-cols-2 gap-2 @lg:grid-cols-3';\n\nconst SLOT = 'bg-foreground/[0.04] overflow-hidden rounded-lg';\n\nfunction ResultSlots() {\n  return (\n    <ul aria-hidden='true' className={GRID}>\n      {RESULT_INDEXES.map((index) => (\n        <li key={index} className={SLOT}>\n          <span className='block aspect-[4/3]' />\n        </li>\n      ))}\n    </ul>\n  );\n}\n\nfunction Results({ direction }: { direction: Direction }) {\n  return (\n    <ul aria-label='Options' className={GRID}>\n      {RESULT_INDEXES.map((index) => (\n        <li key={index} className={SLOT}>\n          <SettleItem>\n            <ResultDrawing direction={direction} index={index} />\n          </SettleItem>\n        </li>\n      ))}\n    </ul>\n  );\n}\n\ntype BriefPanelProps = {\n  state: DirectionState;\n  pressed: string | null;\n  onKeyword: (index: number, text: string) => void;\n  onGenerate: () => void;\n  onStartOver: () => void;\n};\n\nexport function BriefPanel({\n  state,\n  pressed,\n  onKeyword,\n  onGenerate,\n  onStartOver,\n}: BriefPanelProps) {\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const reveal = revealOf(shouldReduceMotion);\n  const pickedId = state.pickedId;\n  if (pickedId === null) {\n    return <EmptySlot />;\n  }\n  const direction = directionOf(pickedId);\n  const isGenerating = state.phase === 'generating';\n  const isDone = state.phase === 'done';\n  const hasResults = isGenerating || isDone;\n\n  return (\n    <section\n      aria-label={`Brief: ${direction.name}`}\n      className='bg-card hairline-ring ring-border dark:bg-foreground/[0.03] @container flex flex-col gap-5 rounded-xl p-4 shadow-[0_1px_2px_rgb(0_0_0/0.04)] @lg:p-5'\n    >\n      <div className='flex flex-col gap-4 @lg:flex-row @lg:items-start'>\n        <div className='w-full max-w-72 shrink-0'>\n          <motion.span\n            key={pickedId}\n            layoutId={`art-${pickedId}`}\n            style={ART_STYLE}\n            className='block overflow-hidden'\n          >\n            <DirectionArt direction={direction} />\n          </motion.span>\n        </div>\n        <motion.div\n          key={`${pickedId}-brief`}\n          initial={reveal.initial}\n          animate={reveal.animate}\n          transition={reveal.transition}\n          className='flex min-w-0 flex-1 flex-col gap-4'\n        >\n          <div className='flex flex-col gap-1'>\n            <h3 className='text-sm font-medium'>{direction.name}</h3>\n            <p className='text-muted-foreground text-[13px] text-pretty'>\n              {direction.line}\n            </p>\n          </div>\n          <PaletteChips direction={direction} />\n          <TypePair direction={direction} />\n        </motion.div>\n      </div>\n      <motion.div\n        key={`${pickedId}-keywords`}\n        initial={reveal.initial}\n        animate={reveal.animate}\n        transition={reveal.transition}\n        className='flex flex-col gap-2'\n      >\n        <p className='text-muted-foreground text-xs'>Keywords</p>\n        <Keywords\n          keywords={state.keywords}\n          isLocked={isGenerating}\n          onEdit={onKeyword}\n        />\n      </motion.div>\n      <GenerateBar\n        phase={state.phase}\n        progress={state.progress}\n        pressed={pressed}\n        onGenerate={onGenerate}\n        onStartOver={onStartOver}\n      />\n      <Fold open={hasResults}>\n        {isGenerating && <ResultSlots />}\n        {isDone && (\n          <Settle isShown>\n            <Results direction={direction} />\n          </Settle>\n        )}\n      </Fold>\n    </section>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/ai-product-07/brief-panel.tsx"
    },
    {
      "path": "registry/ndeko/blocks/ai-product/ai-product-07/generate-bar.tsx",
      "content": "'use client';\n\nimport { pressedSolidOf } from '@/registry/ndeko/lib/demonstration';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { Button } from '@/registry/ndeko/ui/button';\nimport { Swap } from '@/registry/ndeko/ui/chat-motion';\n\nimport { RESULT_COUNT } from './data';\nimport type { Phase } from './session';\n\nfunction fillOf(phase: Phase, progress: number) {\n  if (phase !== 'generating') {\n    return { transform: 'scaleX(0)' };\n  }\n  return { transform: `scaleX(${progress / 100})` };\n}\n\nfunction labelKeyOf(phase: Phase) {\n  if (phase === 'generating') {\n    return 'generating';\n  }\n  if (phase === 'done') {\n    return 'again';\n  }\n  return 'generate';\n}\n\ntype GenerateBarProps = {\n  phase: Phase;\n  progress: number;\n  pressed: string | null;\n  onGenerate: () => void;\n  onStartOver: () => void;\n};\n\nexport function GenerateBar({\n  phase,\n  progress,\n  pressed,\n  onGenerate,\n  onStartOver,\n}: GenerateBarProps) {\n  const labelKey = labelKeyOf(phase);\n  const isGenerating = phase === 'generating';\n  const isDone = phase === 'done';\n\n  return (\n    <div className='flex flex-wrap items-center gap-2'>\n      <Button\n        type='button'\n        size='lg'\n        disabled={isGenerating}\n        focusableWhenDisabled\n        onClick={onGenerate}\n        className={cn(\n          'relative w-full overflow-hidden disabled:opacity-100 @md:w-64',\n          pressedSolidOf(pressed === 'generate')\n        )}\n      >\n        <span\n          aria-hidden='true'\n          style={fillOf(phase, progress)}\n          className='bg-primary-foreground/25 absolute inset-0 origin-left transition-transform duration-500 ease-linear'\n        />\n        <Swap swapKey={labelKey} className='relative'>\n          {labelKey === 'generate' && `Generate ${RESULT_COUNT} options`}\n          {labelKey === 'again' && 'Generate again'}\n          {labelKey === 'generating' && (\n            <span>\n              Generating <span className='tabular-nums'>{progress}%</span>\n            </span>\n          )}\n        </Swap>\n      </Button>\n      {isDone && (\n        <Button\n          type='button'\n          variant='ghost'\n          size='lg'\n          onClick={onStartOver}\n          className='text-muted-foreground'\n        >\n          Start over\n        </Button>\n      )}\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/ai-product-07/generate-bar.tsx"
    },
    {
      "path": "registry/ndeko/blocks/ai-product/ai-product-07/session.ts",
      "content": "import type { SessionStep } from '@/registry/ndeko/hooks/use-session';\nimport { keyDelayOf, prefixesOf } from '@/registry/ndeko/lib/demonstration';\n\nimport {\n  DEMO_KEYWORD,\n  DEMO_PICK,\n  directionOf,\n  RESULT_COUNT,\n  type DirectionId,\n} from './data';\n\nexport type Phase = 'picking' | 'brief' | 'generating' | 'done';\n\nexport type DirectionState = {\n  phase: Phase;\n  pickedId: DirectionId | null;\n  keywords: string[];\n  progress: number;\n  spoken: string;\n};\n\nexport type DirectionAction =\n  | { type: 'picked'; id: DirectionId }\n  | { type: 'keywordEdited'; index: number; text: string }\n  | { type: 'generateStarted' }\n  | { type: 'progressed' }\n  | { type: 'startedOver' };\n\ntype Step = SessionStep<DirectionState, DirectionAction>;\n\nexport const INITIAL: DirectionState = {\n  phase: 'picking',\n  pickedId: null,\n  keywords: [],\n  progress: 0,\n  spoken: '',\n};\n\nconst PROGRESS_STEP = 15;\n\nfunction picked(state: DirectionState, id: DirectionId): DirectionState {\n  if (state.phase === 'generating') {\n    return state;\n  }\n  const direction = directionOf(id);\n  return {\n    phase: 'brief',\n    pickedId: id,\n    keywords: [...direction.keywords],\n    progress: 0,\n    spoken: `${direction.name} picked. Its brief is ready to edit`,\n  };\n}\n\nfunction keywordEdited(\n  state: DirectionState,\n  index: number,\n  text: string\n): DirectionState {\n  const hasBrief = state.pickedId !== null;\n  if (!hasBrief) {\n    return state;\n  }\n  const keywords = state.keywords.map((keyword, position) => {\n    if (position === index) {\n      return text;\n    }\n    return keyword;\n  });\n  return { ...state, keywords };\n}\n\nfunction generateStarted(state: DirectionState): DirectionState {\n  const canGenerate = state.phase === 'brief' || state.phase === 'done';\n  if (!canGenerate) {\n    return state;\n  }\n  return {\n    ...state,\n    phase: 'generating',\n    progress: 0,\n    spoken: 'Generating options',\n  };\n}\n\nfunction progressed(state: DirectionState): DirectionState {\n  if (state.phase !== 'generating') {\n    return state;\n  }\n  const advanced = state.progress + PROGRESS_STEP;\n  const next = Math.min(100, advanced);\n  if (next < 100) {\n    return { ...state, progress: next };\n  }\n  return {\n    ...state,\n    phase: 'done',\n    progress: 100,\n    spoken: `${RESULT_COUNT} options generated`,\n  };\n}\n\nexport function reducer(\n  state: DirectionState,\n  action: DirectionAction\n): DirectionState {\n  switch (action.type) {\n    case 'picked':\n      return picked(state, action.id);\n    case 'keywordEdited':\n      return keywordEdited(state, action.index, action.text);\n    case 'generateStarted':\n      return generateStarted(state);\n    case 'progressed':\n      return progressed(state);\n    case 'startedOver':\n      return INITIAL;\n  }\n}\n\nfunction hasPicked(state: DirectionState) {\n  return state.pickedId !== null;\n}\n\nfunction hasGenerated(state: DirectionState) {\n  const isGenerating = state.phase === 'generating';\n  const isDone = state.phase === 'done';\n  return isGenerating || isDone;\n}\n\nconst KEY_MS = 85;\n\nfunction editSteps(text: string, startAfter: number): Step[] {\n  const prefixes = ['', ...prefixesOf(text)];\n  return prefixes.map((typed, index) => ({\n    after: keyDelayOf(index, startAfter, KEY_MS),\n    by: 'demo',\n    action: { type: 'keywordEdited', index: DEMO_KEYWORD.index, text: typed },\n  }));\n}\n\nconst STEPS_TO_FULL = 100 / PROGRESS_STEP;\n\nconst PROGRESS_STEPS = Math.ceil(STEPS_TO_FULL);\n\n/** The generation is the agent's work: it goes on once a person has taken over. */\nconst GENERATION: Step[] = Array.from({ length: PROGRESS_STEPS }, () => ({\n  after: 430,\n  action: { type: 'progressed' },\n}));\n\nexport const SCRIPT: Step[] = [\n  {\n    after: 1700,\n    by: 'person',\n    press: `tile-${DEMO_PICK}`,\n    isAnswered: hasPicked,\n    action: { type: 'picked', id: DEMO_PICK },\n  },\n  ...editSteps(DEMO_KEYWORD.text, 1900),\n  {\n    after: 1300,\n    by: 'person',\n    press: 'generate',\n    isAnswered: hasGenerated,\n    action: { type: 'generateStarted' },\n  },\n  ...GENERATION,\n];\n\nfunction endOf(script: Step[]) {\n  let state = INITIAL;\n  for (const step of script) {\n    state = reducer(state, step.action);\n  }\n  return state;\n}\n\nexport const RESTING: DirectionState = { ...endOf(SCRIPT), spoken: '' };\n\nexport const LOOP_AFTER_MS = 5200;\n",
      "type": "registry:component",
      "target": "components/blocks/ai-product-07/session.ts"
    },
    {
      "path": "registry/ndeko/blocks/ai-product/ai-product-07/data.ts",
      "content": "export const SECTION = {\n  label: 'New project',\n  title: 'Start from a direction',\n  lead: 'Pick the one that feels closest. It becomes a brief you can edit before anything is generated.',\n};\n\nexport type DirectionId = 'paper' | 'signal' | 'harbour' | 'kasai';\n\nexport type ShapeKind = 'circle' | 'square' | 'triangle' | 'arch';\n\nexport type FontKind = 'serif' | 'sans' | 'mono' | 'rounded';\n\nexport type Swatch = {\n  name: string;\n  color: string;\n};\n\nexport type Direction = {\n  id: DirectionId;\n  name: string;\n  line: string;\n  /** Background, ink, accent, soft accent. They are the content of the sample, so they do not follow the theme. */\n  swatches: [Swatch, Swatch, Swatch, Swatch];\n  display: FontKind;\n  text: FontKind;\n  shapes: [ShapeKind, ShapeKind];\n  keywords: [string, string, string];\n};\n\nexport const DIRECTIONS: Direction[] = [\n  {\n    id: 'paper',\n    name: 'Quiet paper',\n    line: 'Warm paper, dark ink and one clay accent',\n    swatches: [\n      { name: 'Paper', color: 'hsl(42 38% 93%)' },\n      { name: 'Ink', color: 'hsl(25 20% 16%)' },\n      { name: 'Clay', color: 'hsl(14 52% 52%)' },\n      { name: 'Sand', color: 'hsl(38 45% 72%)' },\n    ],\n    display: 'serif',\n    text: 'sans',\n    shapes: ['circle', 'square'],\n    keywords: ['calm', 'editorial', 'warm'],\n  },\n  {\n    id: 'signal',\n    name: 'Signal',\n    line: 'Night blue, chalk text and two loud accents',\n    swatches: [\n      { name: 'Night', color: 'hsl(230 25% 10%)' },\n      { name: 'Chalk', color: 'hsl(60 15% 92%)' },\n      { name: 'Volt', color: 'hsl(72 90% 55%)' },\n      { name: 'Coral', color: 'hsl(8 85% 62%)' },\n    ],\n    display: 'mono',\n    text: 'sans',\n    shapes: ['triangle', 'square'],\n    keywords: ['sharp', 'technical', 'fast'],\n  },\n  {\n    id: 'harbour',\n    name: 'Harbour',\n    line: 'Deep water, pale foam and a bright tide',\n    swatches: [\n      { name: 'Deep', color: 'hsl(215 55% 22%)' },\n      { name: 'Foam', color: 'hsl(200 30% 94%)' },\n      { name: 'Tide', color: 'hsl(195 60% 48%)' },\n      { name: 'Shell', color: 'hsl(30 70% 80%)' },\n    ],\n    display: 'rounded',\n    text: 'sans',\n    shapes: ['arch', 'circle'],\n    keywords: ['open', 'friendly', 'steady'],\n  },\n  {\n    id: 'kasai',\n    name: 'Kasai cloth',\n    line: 'Raffia, soot and the reds of woven cloth',\n    swatches: [\n      { name: 'Raffia', color: 'hsl(38 55% 82%)' },\n      { name: 'Soot', color: 'hsl(20 18% 14%)' },\n      { name: 'Rust', color: 'hsl(12 65% 42%)' },\n      { name: 'Ochre', color: 'hsl(40 80% 50%)' },\n    ],\n    display: 'sans',\n    text: 'serif',\n    shapes: ['triangle', 'arch'],\n    keywords: ['woven', 'bold', 'rooted'],\n  },\n];\n\nexport const FONT_LABEL: Record<FontKind, string> = {\n  serif: 'Serif',\n  sans: 'Sans',\n  mono: 'Mono',\n  rounded: 'Rounded',\n};\n\nexport const FONT_CLASS: Record<FontKind, string> = {\n  serif: 'font-serif',\n  sans: 'font-sans',\n  mono: 'font-mono',\n  rounded: 'font-[ui-rounded,system-ui,sans-serif]',\n};\n\nexport const RESULT_COUNT = 6;\n\nexport const RESULT_INDEXES = Array.from(\n  { length: RESULT_COUNT },\n  (_, index) => index\n);\n\nexport const DEMO_PICK: DirectionId = 'kasai';\n\nexport const DEMO_KEYWORD = { index: 1, text: 'patterned' };\n\nconst FALLBACK_DIRECTION = DIRECTIONS[0];\n\nexport function directionOf(id: DirectionId) {\n  const direction = DIRECTIONS.find((candidate) => candidate.id === id);\n  return direction ?? FALLBACK_DIRECTION;\n}\n",
      "type": "registry:component",
      "target": "components/blocks/ai-product-07/data.ts"
    }
  ],
  "categories": [
    "blocks",
    "ai-product"
  ],
  "type": "registry:block"
}