{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "report-decisions",
  "type": "registry:block",
  "title": "Report, decisions",
  "description": "Numbered decisions for the reader. Each has a question, an optional recommended option, the other options and why, so the answer can be \"yes to all except 2\". With an id on a card, the reader can answer on the page (see the report kit).",
  "categories": [
    "report"
  ],
  "dependencies": [
    "zod@^4.6.5"
  ],
  "registryDependencies": [
    "https://ui.klarhimmel.com/r/block-kit.json",
    "https://ui.klarhimmel.com/r/button.json",
    "https://ui.klarhimmel.com/r/editing.json",
    "https://ui.klarhimmel.com/r/input.json",
    "https://ui.klarhimmel.com/r/kit-form.json",
    "https://ui.klarhimmel.com/r/kit-report.json",
    "https://ui.klarhimmel.com/r/radio-group.json"
  ],
  "files": [
    {
      "path": "src/blocks/report-decisions/spec.ts",
      "type": "registry:file",
      "target": "components/klarhimmel/blocks/report-decisions/spec.ts",
      "content": "import { z } from 'zod';\nimport { defineSpec, t } from '../_shared/schema';\n\nconst schema = z.object({\n  title: t(100),\n  lead: t(400),\n  items: z.array(z.object({\n    question: z.string().min(1).max(240),\n    /** The recommended option, preselected; empty: none is, and the relay never defaults the card. */\n    recommended: t(400),\n    options: z.array(t(240)).max(6),\n    why: t(700),\n    reply: t(60),\n    /** Open: the thing the card decides on (a draft, a prototype), drawn as a link under Why. */\n    href: t(300).optional(),\n    /** Kind: whose look or what class this card is (\"first look, a hotel owner\", \"money\"); only written as data-kind, for answer register (AI-46). */\n    kind: t(120).optional(),\n    /** The address (docs/answer-contract.md). A card with an id is answerable on the page; without one it is only shown. `version` is a whole number written as text. */\n    id: t(80),\n    version: t(6),\n    seat: t(60),\n    repo: t(80),\n    session: t(80),\n    askedAt: t(40),\n  })).min(1).max(12),\n  replyHint: t(200),\n});\n\nexport const spec = defineSpec({\n  type: 'report-decisions',\n  aliases: ['report/decisions'],\n  name: 'Report, decisions',\n  category: 'report',\n  role: 'body',\n  description: 'Numbered decisions for the reader. Each has a question, an optional recommended option, the other options and why, so the answer can be \"yes to all except 2\". With an id on a card, the reader can answer on the page (see the report kit).',\n  schema,\n  defaults: {\n    title: 'Name what is being asked',\n    lead: 'Say how the reader answers and sends',\n    items: [\n      { question: 'Ask the first question', recommended: 'Say the recommended option, with why', options: ['Name another option'], why: 'Say why, in a sentence or two, so the reader can decide', reply: '', id: 'D-20261010-sample-1', version: '1', seat: 'library', repo: 'ui', session: '', askedAt: '2026-10-10T14:00:00Z' },\n      { question: 'Ask the second question, as a choice', recommended: 'Say the recommended option', options: ['Name an option', 'Name another option'], why: 'Say why, in a sentence or two, so the reader can decide', reply: '', id: 'D-20261010-sample-2', version: '1', seat: 'library', repo: 'ui', session: '', askedAt: '2026-10-10T14:00:00Z' },\n    ],\n    replyHint: 'Say how to answer several cards at once, with an example',\n  },\n});\n"
    },
    {
      "path": "src/blocks/report-decisions/index.tsx",
      "type": "registry:file",
      "target": "components/klarhimmel/blocks/report-decisions/index.tsx",
      "content": "import { useId } from 'react';\nimport { Text, withHeadingLevel } from '../../editing';\nimport { Button, safeHref } from '../../ui/button';\nimport { Textarea } from '../../ui/input';\nimport { Radio, RadioGroup } from '../../ui/radio-group';\nimport { Opt } from '../_shared/kit';\nimport { useFormProps } from '../_shared/form-kit';\nimport { ReportSection, ReportTitle } from '../_shared/report-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>;\ntype Item = Props['items'][number];\n\n/**\n * The line a card copies when there is no relay (docs/answer-contract.md): `ANSWER <id> v<version> to <seat> (session <session>): <choice>, <text>`.\n * Written the same way by report-answer.js; a test keeps the two equal.\n */\nexport function answerLine(d: Pick<Item, 'id' | 'version' | 'seat' | 'session'>, choice: string, text: string): string {\n  return `ANSWER ${d.id} v${d.version || '1'} to ${d.seat || '-'} (session ${d.session || '-'}): ${[choice, text].filter(Boolean).join(', ')}`;\n}\n\nconst DOT = 'size-2.5 shrink-0 rounded-kh-pill border border-kh-line-strong bg-kh-surface data-[state=open]:bg-kh-muted data-[state=defaulted]:bg-kh-surface-2 data-[state=defaulted]:border-kh-ink data-[state=answered]:bg-kh-accent data-[state=answered]:border-kh-accent data-[state=applied]:bg-kh-ink data-[state=applied]:border-kh-ink data-[state=superseded]:bg-transparent data-[state=superseded]:border-dashed';\n\n/** The answer form of one card: the options as radios (the recommended one chosen), a free note, Send. Plain HTML; report-answer.js, inlined by kh-report, makes it send. */\nfunction AnswerForm({ d, i }: { d: Item; i: number }) {\n  const form = useFormProps({});\n  const group = useId();\n  // the recommended option once, then the others (an options list that repeats the default does not draw it twice); without a\n  // recommended option nothing is preselected and the options are drawn as they are\n  const rec = d.recommended.trim();\n  const choices = [...(rec ? [d.recommended] : []), ...d.options.filter((o) => o.trim().toLowerCase() !== rec.toLowerCase())];\n  return (\n    <form {...form} data-kh-form className=\"mt-5 flex flex-col gap-4 border-t border-kh-line pt-5 @xl:ml-10\">\n      <RadioGroup legend=\"Your answer\" name={`${group}-choice`} defaultValue={rec ? d.recommended : undefined}>\n        {choices.map((c, j) => (!c.trim() ? null : (\n          <Radio key={j} value={c} label={<><Text path={rec && j === 0 ? ['items', i, 'recommended'] : ['items', i, 'options', d.options.indexOf(c)]} value={c} as=\"span\" rich />{rec && j === 0 && <span className=\"ml-2 rounded-kh-sm bg-kh-accent-soft px-1.5 py-0.5 text-kh-caption font-semibold uppercase tracking-widest text-kh-accent-ink\">Recommended</span>}</>} />\n        )))}\n      </RadioGroup>\n      <div>\n        <label htmlFor={`${group}-text`} className=\"mb-1.5 block text-kh-small font-medium\">Your own answer, or a note on the option you pick</label>\n        <Textarea id={`${group}-text`} name=\"text\" rows={3} />\n      </div>\n      <div className=\"flex flex-wrap items-center gap-x-4 gap-y-2\">\n        <Button type=\"submit\" data-kh-send hidden>Send</Button>\n        <p data-kh-status hidden role=\"status\" aria-live=\"polite\" className=\"flex min-w-0 items-center gap-2 text-kh-small text-kh-muted\">\n          <span data-kh-dot data-state=\"open\" aria-hidden className={DOT} />\n          <span data-kh-label className=\"min-w-0 [overflow-wrap:anywhere]\" />\n        </p>\n      </div>\n      <details data-kh-copy className=\"text-kh-small text-kh-muted\">\n        <summary className=\"min-h-6 cursor-pointer rounded-kh-sm focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--kh-focus)\">Answer by copying</summary>\n        <p className=\"mt-2\">Copy this line and paste it to the agent that asked.</p>\n        <code data-kh-line className=\"mt-1 block rounded-kh-sm bg-kh-surface-2 p-2 font-kh-mono text-kh-caption text-kh-ink [overflow-wrap:anywhere]\">{answerLine(d, d.recommended, '')}</code>\n      </details>\n    </form>\n  );\n}\n\nfunction ReportDecisions({ props }: BlockProps<Props>) {\n  const id = useId();\n  return (\n    <ReportSection labelledBy={id}>\n      <ReportTitle id={id} title={props.title} lead={props.lead} />\n      <ol className=\"mt-6 flex flex-col gap-4\">\n        {props.items.map((d, i) => (\n          <li\n            key={i}\n            {...(d.id ? { 'data-kh-decision': '', 'data-id': d.id, 'data-version': d.version || '1', 'data-seat': d.seat, 'data-repo': d.repo, 'data-session': d.session, 'data-default': d.recommended, 'data-asked-at': d.askedAt, ...(d.href ? { 'data-href': safeHref(d.href) } : {}), ...(d.kind ? { 'data-kind': d.kind } : {}) } : {})}\n            className=\"rounded-kh-xl border border-kh-line bg-kh-surface p-5 @xl:p-6 print:break-inside-avoid\"\n          >\n            <div className=\"flex items-start gap-3\">\n              <span aria-hidden className=\"mt-0.5 flex size-7 shrink-0 items-center justify-center rounded-kh-pill bg-kh-ink text-kh-small font-semibold tabular-nums text-kh-canvas\">{i + 1}</span>\n              <h3 className=\"min-w-0 text-kh-heading font-semibold [overflow-wrap:anywhere]\">\n                <span className=\"sr-only\">{i + 1}. </span>\n                <Text path={['items', i, 'question']} value={d.question} as=\"span\" rich />\n              </h3>\n            </div>\n            {!d.id && d.recommended.trim() && (\n              <div className=\"mt-4 rounded-kh-lg border border-kh-accent bg-kh-accent-soft p-4 @xl:ml-10\">\n                <p className=\"text-kh-caption font-semibold uppercase tracking-widest text-kh-accent-ink\">Recommended</p>\n                <Text path={['items', i, 'recommended']} value={d.recommended} as=\"p\" rich className=\"mt-1 text-kh-body font-medium\" />\n              </div>\n            )}\n            {!d.id && d.options.length > 0 && (\n              <div className=\"mt-4 @xl:ml-10\">\n                <p className=\"text-kh-caption font-semibold uppercase tracking-widest text-kh-muted\">{d.recommended.trim() ? 'Other options' : 'Options'}</p>\n                <ul className=\"mt-1 list-disc space-y-1 pl-5 text-kh-body marker:text-kh-muted\">\n                  {d.options.map((o, j) => (\n                    <li key={j}><Text path={['items', i, 'options', j]} value={o} as=\"span\" rich /></li>\n                  ))}\n                </ul>\n              </div>\n            )}\n            <Opt path={['items', i, 'why']} value={d.why} rich className=\"mt-4 text-kh-small text-kh-muted @xl:ml-10\" placeholder=\"Why\" />\n            {d.href && <p className=\"mt-3 text-kh-small @xl:ml-10\"><a href={safeHref(d.href)} className=\"font-medium text-kh-ink underline underline-offset-4 [overflow-wrap:anywhere]\">Open what this decides on</a></p>}\n            {d.reply && !d.id && <p className=\"mt-3 text-kh-caption text-kh-muted @xl:ml-10\">Reply with <code className=\"rounded-kh-sm bg-kh-surface-2 px-1.5 py-0.5 font-kh-mono\"><Text path={['items', i, 'reply']} value={d.reply} as=\"span\" /></code></p>}\n            {d.id && <AnswerForm d={d} i={i} />}\n          </li>\n        ))}\n      </ol>\n      <Opt path={['replyHint']} value={props.replyHint} className=\"mt-5 text-kh-small text-kh-muted\" placeholder=\"How to answer\" />\n    </ReportSection>\n  );\n}\n\nexport default withHeadingLevel(ReportDecisions);\n"
    }
  ]
}
