{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "snapshot-progress",
  "type": "registry:block",
  "title": "Snapshot, progress",
  "description": "The live narration of a snapshot: the site being read and its status, the newest line pulsing (motion-safe) and older lines ticked, at most eight in view with the rest under a native \"Show all\". One polite live region holds only the newest line, so a re-render never re-announces the list. Queued shows the note; done shows a done line.",
  "categories": [
    "snapshot"
  ],
  "dependencies": [
    "lucide-react@^1.49.0",
    "zod@^4.6.5"
  ],
  "registryDependencies": [
    "https://ui.klarhimmel.com/r/badge.json",
    "https://ui.klarhimmel.com/r/block-kit.json",
    "https://ui.klarhimmel.com/r/editing.json",
    "https://ui.klarhimmel.com/r/kit-snapshot.json",
    "https://ui.klarhimmel.com/r/utils.json"
  ],
  "files": [
    {
      "path": "src/blocks/snapshot-progress/spec.ts",
      "type": "registry:file",
      "target": "components/klarhimmel/blocks/snapshot-progress/spec.ts",
      "content": "import { z } from 'zod';\nimport { defineSpec, req, t } from '../_shared/schema';\n\nconst schema = z.object({\n  /** The address being researched, as the person typed it. */\n  site: req(300),\n  status: z.enum(['queued', 'running', 'done']),\n  /** Said while the job waits (status 'queued'), for example when the day's budget is used up. */\n  queuedNote: t(400),\n  /** The live narration, oldest first. A re-render with one more line changes only the announcement. */\n  lines: z.array(z.object({\n    /** ISO time of the line; shown as HH:MM when it parses. */\n    at: t(40),\n    /** A module id (competitors, audience, seo_aeo, growth) or empty for the research as a whole. */\n    module: t(40).optional(),\n    text: req(400),\n  })).max(300),\n  /** Fixed words; a missing one uses the English default. `modules` names the module ids. */\n  words: z.object({ heading: t(60), queued: t(60), running: t(60), done: t(60), showAll: t(60), latest: t(60) }).partial().optional(),\n  moduleWords: z.object({ competitors: t(40), audience: t(40), seo_aeo: t(60), growth: t(40) }).partial().optional(),\n});\n\nexport const spec = defineSpec({\n  type: 'snapshot-progress',\n  headingSlot: 'site',\n  aliases: ['snapshot/progress'],\n  name: 'Snapshot, progress',\n  category: 'snapshot',\n  role: 'body',\n  description: 'The live narration of a snapshot: the site being read and its status, the newest line pulsing (motion-safe) and older lines ticked, at most eight in view with the rest under a native \"Show all\". One polite live region holds only the newest line, so a re-render never re-announces the list. Queued shows the note; done shows a done line.',\n  schema,\n  defaults: {\n    site: 'yoursite.example',\n    status: 'running',\n    queuedNote: '',\n    lines: [\n      { at: '2026-10-10T09:12:00Z', text: 'Say what it reads' },\n      { at: '2026-10-10T09:12:04Z', text: 'Say what it reads next' },\n      { at: '2026-10-10T09:12:09Z', module: 'competitors', text: 'Say what it searches for' },\n      { at: '2026-10-10T09:12:15Z', module: 'seo_aeo', text: 'Say what it asks an AI assistant, as the question itself' },\n    ],\n    words: { heading: 'Reading', queued: 'Queued', running: 'Working', done: 'Done', showAll: 'Show all', latest: 'Latest' },\n    moduleWords: { competitors: 'Competitors', audience: 'Audience', seo_aeo: 'Search and AI answers', growth: 'Growth' },\n  },\n});\n"
    },
    {
      "path": "src/blocks/snapshot-progress/index.tsx",
      "type": "registry:file",
      "target": "components/klarhimmel/blocks/snapshot-progress/index.tsx",
      "content": "import { useId } from 'react';\nimport { Check } from 'lucide-react';\nimport { Text, withHeadingLevel } from '../../editing';\nimport { cn } from '../../lib/utils';\nimport { Badge } from '../../ui/badge';\nimport { Container, Opt, Section, useEditing } from '../_shared/kit';\nimport { WRAP, clockOf } from '../_shared/snapshot-kit';\nimport { spec } from './spec';\nimport type { BlockProps } from '../types';\nimport type { z } from 'zod';\n\nexport { spec };\ntype Props = z.infer<typeof spec.schema>;\nconst WORDS = { heading: 'Reading', queued: 'Queued', running: 'Working', done: 'Done', showAll: 'Show all', latest: 'Latest' };\nconst MODULES: Record<string, string> = { competitors: 'Competitors', audience: 'Audience', seo_aeo: 'Search and AI answers', growth: 'Growth' };\nconst VISIBLE = 8;\n\nfunction SnapshotProgress({ props }: BlockProps<Props>) {\n  const id = useId();\n  const editing = useEditing();\n  const words = { ...WORDS, ...props.words };\n  const modules: Record<string, string> = { ...MODULES, ...props.moduleWords };\n  const done = props.status === 'done';\n  const queued = props.status === 'queued';\n  const lines = props.lines;\n  const hidden = Math.max(0, lines.length - VISIBLE);\n  const older = lines.slice(0, hidden);\n  const shown = lines.slice(hidden);\n  // The one live region: only the newest line (or the state when there is none), so a re-render never re-announces the list.\n  const newest = done ? words.done : queued ? props.queuedNote || words.queued : lines.at(-1)?.text ?? '';\n  const row = (l: Props['lines'][number], i: number, newestRow: boolean) => (\n    <li key={i} className={cn('flex min-w-0 items-start gap-3 py-2 text-kh-small', WRAP)}>\n      {newestRow ? (\n        <span aria-hidden className=\"mt-1.5 inline-flex size-3 shrink-0 items-center justify-center\"><span className=\"size-2.5 rounded-kh-pill bg-kh-accent motion-safe:animate-pulse\" /></span>\n      ) : (\n        <Check aria-hidden strokeWidth={2} className=\"mt-0.5 size-4 shrink-0 text-kh-accent-ink\" />\n      )}\n      <span className=\"min-w-0 flex-1\">\n        <Text path={['lines', lines.indexOf(l), 'text']} value={l.text} as=\"span\" className={newestRow ? 'font-medium text-kh-ink' : 'text-kh-ink-2'} />\n        {(l.module || clockOf(l.at)) && (\n          <span className=\"mt-0.5 flex flex-wrap items-center gap-x-3 gap-y-1 text-kh-caption text-kh-muted\">\n            {clockOf(l.at) && <time dateTime={l.at}>{clockOf(l.at)}</time>}\n            {l.module && <Badge tone=\"outline\">{modules[l.module] ?? l.module}</Badge>}\n          </span>\n        )}\n      </span>\n    </li>\n  );\n  return (\n    <Section labelledBy={id} className=\"py-6 @3xl:py-8\">\n      <Container width=\"narrow\">\n        <div className={cn('rounded-kh-xl border border-kh-line bg-kh-surface p-5 shadow-kh-1 @2xl:p-7', WRAP)}>\n          <p className=\"text-kh-small text-kh-muted\"><Text path={['words', done ? 'done' : queued ? 'queued' : 'heading']} value={done ? words.done : queued ? words.queued : words.heading} as=\"span\" /></p>\n          <div id={id}>\n            <Text path={['site']} value={props.site} as=\"h2\" className=\"mt-1 text-kh-heading font-semibold\" />\n          </div>\n          {(queued || editing) && <Opt path={['queuedNote']} value={props.queuedNote} className=\"mt-3 text-kh-body text-kh-ink-2\" placeholder=\"Why it waits\" />}\n          <p aria-live=\"polite\" role=\"status\" className=\"sr-only\">{newest}</p>\n          {editing && (\n            <p className=\"mt-2 flex flex-wrap gap-3 text-kh-caption text-kh-muted\">\n              {(['queued', 'running', 'done', 'showAll', 'latest'] as const).map((k) => <Text key={k} path={['words', k]} value={words[k]} as=\"span\" />)}\n              {Object.keys(MODULES).map((k) => <Text key={k} path={['moduleWords', k]} value={modules[k] ?? k} as=\"span\" />)}\n            </p>\n          )}\n          {!queued && (shown.length > 0 || done) && (\n            <div className=\"mt-4\">\n              {older.length > 0 && (\n                <details className=\"mb-1\">\n                  <summary className=\"inline-flex min-h-6 cursor-pointer items-center text-kh-small text-kh-muted underline underline-offset-4\">\n                    <Text path={['words', 'showAll']} value={words.showAll} as=\"span\" /> ({older.length})\n                  </summary>\n                  <ol className=\"divide-y divide-kh-line\">{older.map((l, i) => row(l, i, false))}</ol>\n                </details>\n              )}\n              <ol className=\"divide-y divide-kh-line border-t border-kh-line\">\n                {shown.map((l, i) => row(l, hidden + i, !done && i === shown.length - 1))}\n                {done && (\n                  <li className=\"flex items-center gap-3 py-2 text-kh-small font-medium\">\n                    <Check aria-hidden strokeWidth={2} className=\"size-4 shrink-0 text-kh-accent-ink\" />\n                    <Text path={['words', 'done']} value={words.done} as=\"span\" />\n                  </li>\n                )}\n              </ol>\n            </div>\n          )}\n        </div>\n      </Container>\n    </Section>\n  );\n}\n\nexport default withHeadingLevel(SnapshotProgress, 'site');\n"
    }
  ]
}
