{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "hero-prompt",
  "type": "registry:block",
  "title": "Hero, prompt",
  "description": "Centred headline with a prompt input as the call to action and suggestion chips. For AI products.",
  "categories": [
    "hero"
  ],
  "dependencies": [
    "lucide-react@^1.49.0",
    "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/kit-b-directory.json",
    "https://ui.klarhimmel.com/r/kit-form.json",
    "https://ui.klarhimmel.com/r/utils.json"
  ],
  "files": [
    {
      "path": "src/blocks/hero-prompt/spec.ts",
      "type": "registry:file",
      "target": "components/klarhimmel/blocks/hero-prompt/spec.ts",
      "content": "import { z } from 'zod';\nimport { defineSpec, formErrors, formFields, formStatus, t, req } from '../_shared/schema';\n\nconst schema = z.object({\n  eyebrow: t(60),\n  title: t(120),\n  description: t(300),\n  /** Where the lead paragraph sits: under the title (default) or under the reassurance note below the form. */\n  descriptionPlacement: z.enum(['under-title', 'under-note']).optional(),\n  placeholder: req(120),\n  submit: req(20),\n  /** Example prompts as small chips under the box: up to three show (Felix 13:4x \"make smaller stick to max 3\"); the schema still\n   *  accepts five so pages written before stay valid. */\n  suggestions: z.array(req(60)).max(5).optional(),\n  note: t(80),\n  /** The field's form name, so a native submit carries it (`?prompt=…` with method get). Default \"prompt\". */\n  inputName: t(40).optional(),\n  /** false: a one-line field (a site address, a search) instead of the three-row text area. Default true. */\n  multiline: z.boolean().optional(),\n  /** A one-line field's type: text accepts anything (a free prompt); url needs https://; domain takes what owners type (yourcompany.se or a full address) with the url keyboard and autofill. Default text. */\n  inputType: z.enum(['text', 'url', 'domain']).optional(),\n  /** A one-line text field that grows to two lines while a sentence is typed, so the whole sentence shows on a phone (a one-row text area). Enter sends where the block is hydrated; a host that serves it as static markup wires Enter to requestSubmit itself, or Enter types a new line. Only with multiline false and inputType text: url and domain keep their pattern-checked input. Default false. */\n  grow: z.boolean().optional(),\n  /** The field's accessible name (\"Your site's address\"), not shown. Without it the name is the placeholder text, which is often an example. */\n  inputLabel: t(80).optional(),\n  /** A plain link under the main field for people who cannot answer it (\"I don't have a website\" → /start/?nosite=1). Drawn only with a label and an href. */\n  escape: z.object({ label: t(40).optional(), href: t(300).optional() }).optional(),\n  /** Where `escape` sits: inside the card under the field (default) or below the card, outside it. */\n  escapePlacement: z.enum(['inside', 'below']).optional(),\n  /**\n   * An optional second, visible field under the prompt (kh-website: \"What should work better?\" plus \"Your website\"). Not drawn\n   * unless it has a label; an emptied or missing label leaves it out. It submits under `name` (default \"site\") with the prompt. Default not required.\n   */\n  field: z.object({\n    label: t(60).optional(),\n    name: t(40).optional(),\n    placeholder: t(120).optional(),\n    type: z.enum(['text', 'url', 'domain']).optional(),\n    required: z.boolean().optional(),\n    /** A plain link beside the field's label for people who have none (\"I don't have a website\" → /start/?nosite=1). Drawn only with a label and an href. */\n    escape: z.object({ label: t(40).optional(), href: t(300).optional() }).optional(),\n  }).optional(),\n  /** Form wiring like contact-form: with `action` and `method` the prompt submits natively, no JavaScript needed. See formFields. */\n  ...formFields,\n  ...formStatus,\n  /** What the field says under itself when the browser's own validation fails (see formErrors). Optional: English defaults. */\n  errors: formErrors,\n  /** No band of its own: the page's background shows behind it, and the focused field's glow and shadow are not clipped. */\n  bare: z.boolean().optional(),\n  /**\n   * A file button in the box's bottom row, left of send (multiline only; klarbuilder 13:36 for Felix 13:2x \"it's missing file\n   * upload\"). A real file input, so it posts without script (the form becomes multipart); hydrated, each chosen file shows as a\n   * chip with a remove button. label names the button (it shows as a paperclip). Drawn only with a label.\n   */\n  attach: z.object({ label: t(40).optional(), accept: t(200).optional(), name: t(40).optional(), multiple: z.boolean().optional() }).optional(),\n  /** Up to two quiet pills beside the file button: a toggle (a checkbox posted under name, e.g. \"This is my website\") or a link\n   *  (e.g. \"Use your AI agent\"). Each is drawn only with a label (and a link only with an href). */\n  tools: z.array(z.object({\n    label: t(40),\n    icon: z.enum(['globe', 'bot', 'sparkles', 'image', 'link']).optional(),\n    kind: z.enum(['toggle', 'link']),\n    name: t(40).optional(),\n    href: t(300).optional(),\n  })).max(2).optional(),\n  /** 'screen': the block fills the first screen below a sticky navbar of height --kh-nav-height (0 if unset) and centres its content\n   *  vertically, as hero-minimal does (Felix 13:1x on the Builder: \"the nav + hero should be 100svh\"). Default 'auto'. */\n  height: z.enum(['auto', 'screen']).optional(),\n});\n\nexport const spec = defineSpec({\n  type: 'hero-prompt',\n  aliases: ['hero/prompt'],\n  name: 'Hero, prompt',\n  category: 'hero',\n  role: 'body',\n  // A chip fills the field by script; a static row would show chips that do nothing (KB-425).\n  rowOmit: ['suggestions'],\n  description: 'Centred headline with a prompt input as the call to action and suggestion chips. For AI products.',\n  schema,\n  defaults: {\n    eyebrow: 'Name what this is',\n    title: 'Say what the visitor gets in one line',\n    description: 'Say in one or two sentences what it does, who it is for and what the visitor can do next, in plain words.',\n    placeholder: 'Describe what you want, in a line…',\n    submit: 'Send',\n    suggestions: ['Give a first example request', 'Give a second example request', 'Give a third example request'],\n    note: 'Say what makes starting easy.',\n    messages: { sent: 'Confirm that the request arrived and what happens next.', error: 'Say that it failed and ask them to try again.' },\n  },\n});\n"
    },
    {
      "path": "src/blocks/hero-prompt/index.tsx",
      "type": "registry:file",
      "target": "components/klarhimmel/blocks/hero-prompt/index.tsx",
      "content": "import { useId, useRef, useState } from 'react';\nimport { cn } from '../../lib/utils';\nimport { ArrowRight, ArrowUp, Bot, Globe, ImageIcon, Link2, Paperclip, Sparkles, X } from 'lucide-react';\nimport { Text, withHeadingLevel } from '../../editing';\nimport { Container, Eyebrow, Opt, Section, useEditing, useNamed } from '../_shared/kit';\nimport { SlotField } from '../_shared/b-directory-kit';\nimport { Button, safeHref } from '../../ui/button';\nimport { DOMAIN_PATTERN, ERROR_WORDS, FieldError, FormExtras, FormStatus, URL_PATTERN, useFieldErrors, useFormProps } from '../_shared/form-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>;\n\nconst TOOL_ICONS = { globe: Globe, bot: Bot, sparkles: Sparkles, image: ImageIcon, link: Link2 } as const;\nconst pillBase = 'inline-flex min-h-9 items-center gap-1.5 rounded-kh-pill border border-kh-line px-3 text-kh-small text-kh-ink-2 transition-colors duration-(--kh-dur) pointer-coarse:min-h-11';\nconst pill = `${pillBase} hover:bg-kh-surface-2 hover:text-kh-ink`;\nconst ring = 'focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--kh-focus)';\n\n/** The prompt box's tools, left of send: a file button (a real file input; chips once chosen) and up to two quiet pills. */\nfunction ToolRow({ props, editing }: { props: Props; editing: boolean }) {\n  const input = useRef<HTMLInputElement>(null);\n  const [files, setFiles] = useState<File[]>([]);\n  const attach = props.attach?.label?.trim() ? props.attach : undefined;\n  const tools = (props.tools ?? []).map((tool, i) => ({ tool, i })).filter(({ tool }) => (tool.label && (tool.kind === 'toggle' || tool.href)) || editing);\n  if (!attach && tools.length === 0) return null;\n  const remove = (k: number) => {\n    const el = input.current;\n    if (!el) return;\n    const keep = new DataTransfer();\n    files.forEach((f, j) => j !== k && keep.items.add(f));\n    el.files = keep.files;\n    setFiles([...keep.files]);\n  };\n  return (\n    <>\n      {files.length > 0 && (\n        <ul aria-label={attach!.label} className=\"flex flex-wrap gap-2 px-1 pt-2\">\n          {files.map((f, k) => (\n            <li key={`${f.name}-${k}`} className=\"inline-flex min-h-8 max-w-full items-center gap-1 rounded-kh-pill bg-kh-surface-2 pl-3 text-kh-caption text-kh-ink-2\">\n              <span className=\"truncate\">{f.name}</span>\n              <button type=\"button\" onClick={() => remove(k)} aria-label={`Remove ${f.name}`} className={cn('inline-flex size-8 shrink-0 items-center justify-center rounded-kh-pill hover:bg-kh-surface-3 hover:text-kh-ink', ring)}>\n                <X aria-hidden className=\"size-3.5\" />\n              </button>\n            </li>\n          ))}\n        </ul>\n      )}\n      <div className=\"flex flex-wrap items-center gap-2\">\n        {attach && (\n          <label className={cn(pill, 'w-9 cursor-pointer justify-center px-0 pointer-coarse:w-11 has-[:focus-visible]:outline-2 has-[:focus-visible]:outline-offset-2 has-[:focus-visible]:outline-(--kh-focus)')}>\n            <Paperclip aria-hidden className=\"size-4\" />\n            <span className=\"sr-only\"><Text path={['attach', 'label']} value={attach.label!} as=\"span\" /></span>\n            <input\n              ref={input}\n              type=\"file\"\n              name={attach.name || 'files'}\n              accept={attach.accept || undefined}\n              multiple={attach.multiple || undefined}\n              onChange={(e) => setFiles([...(e.currentTarget.files ?? [])])}\n              className=\"sr-only\"\n            />\n          </label>\n        )}\n        {tools.map(({ tool, i }) => {\n          const Icon = tool.icon ? TOOL_ICONS[tool.icon] : null;\n          const body = <>{Icon && <Icon aria-hidden className=\"size-4\" />}<Text path={['tools', i, 'label']} value={tool.label} as=\"span\" /></>;\n          return tool.kind === 'link' ? (\n            <a key={i} href={safeHref(tool.href ?? '')} className={cn(pill, ring)}>{body}</a>\n          ) : (\n            <label key={i} className={cn(pillBase, 'cursor-pointer not-has-[:checked]:hover:bg-kh-surface-2 not-has-[:checked]:hover:text-kh-ink has-[:checked]:border-kh-ink has-[:checked]:bg-kh-ink has-[:checked]:text-kh-on-ink has-[:focus-visible]:outline-2 has-[:focus-visible]:outline-offset-2 has-[:focus-visible]:outline-(--kh-focus)')}>\n              <input type=\"checkbox\" name={tool.name || `tool-${i}`} className=\"sr-only\" />\n              {body}\n            </label>\n          );\n        })}\n      </div>\n    </>\n  );\n}\n\nfunction HeroPrompt({ props }: BlockProps<Props>) {\n  const fieldNamed = useNamed(props.placeholder || props.inputLabel);\n  const id = useId();\n  const formProps0 = useFormProps(props);\n  const hasTools = !!(props.attach?.label?.trim() || props.tools?.length);\n  // A file posts only in a multipart body.\n  const formProps = hasTools && props.attach?.label?.trim() && formProps0.method === 'post' ? { ...formProps0, encType: 'multipart/form-data' } : formProps0;\n  const multiline = props.multiline ?? true;\n  const editing = useEditing();\n  const words = { ...ERROR_WORDS, ...props.errors };\n  const { errs, fieldProps } = useFieldErrors(words, (n) => `${id}-${n}`);\n  const sent = props.status === 'sent' && !editing;\n  const kind = !multiline && (props.inputType === 'domain' || props.inputType === 'url') ? props.inputType : 'text';\n  const grow = !multiline && kind === 'text' && !!props.grow;\n  const extra = props.field?.label?.trim() ? props.field : undefined;\n  const extraKind = extra?.type ?? 'text';\n  const submit = multiline ? (\n    <Button type=\"submit\" size=\"md\" iconEnd={<ArrowUp aria-hidden className=\"size-4\" />}>\n      <Text path={['submit']} value={props.submit} as=\"span\" />\n    </Button>\n  ) : (\n    <Button type=\"submit\" size=\"md\" icon={<ArrowRight aria-hidden className=\"size-4\" />} aria-label={props.submit} className=\"min-w-11 shrink-0 px-0\">\n      <Text path={['submit']} value={props.submit} as=\"span\" className=\"sr-only\" />\n    </Button>\n  );\n  const submitWrap = (className: string) => <div className={className} data-kh-submit>{submit}</div>;\n  const descUnderNote = props.descriptionPlacement === 'under-note';\n  const description = (\n    <Text\n      path={['description']}\n      value={props.description}\n      as=\"p\"\n      multiline\n      className={cn('mx-auto max-w-kh-lead text-kh-lead text-kh-muted text-center', descUnderNote ? 'mt-4' : 'mt-6')}\n    />\n  );\n  return (\n    <Section labelledBy={id} bare={props.bare} className={props.height === 'screen' ? 'flex min-h-[calc(100svh-var(--kh-nav-height,0px))] flex-col justify-center py-16' : 'pt-16 @3xl:pt-28'}>\n      <Container>\n        <div className=\"mx-auto max-w-kh-narrow text-center\">\n          <Eyebrow path={['eyebrow']} value={props.eyebrow} />\n          <div id={id}>\n            <Text path={['title']} value={props.title} as=\"h1\" className=\"text-kh-display font-semibold\" />\n          </div>\n          {!descUnderNote && description}\n        </div>\n        {fieldNamed && (\n        <form {...formProps} data-kh-submit-reveal={multiline ? undefined : '1'} className={cn('mx-auto mt-10 max-w-2xl rounded-kh-xl border border-kh-line-strong bg-kh-surface p-4 text-left shadow-kh-2 transition-[border-color] duration-(--kh-dur) focus-within:border-kh-muted has-[:is(input,textarea):focus-visible]:outline-2 has-[:is(input,textarea):focus-visible]:outline-offset-2 has-[:is(input,textarea):focus-visible]:outline-(--kh-focus)', !multiline && '[&:has(.peer:placeholder-shown)_[data-kh-submit]]:invisible [&:has(.peer:placeholder-shown)_[data-kh-submit]]:pointer-events-none [&:has(.peer:placeholder-shown)_[data-kh-submit]]:w-0 [&:has(.peer:placeholder-shown)_[data-kh-submit]]:min-w-0 [&:has(.peer:placeholder-shown)_[data-kh-submit]]:overflow-hidden [&:has(.peer:placeholder-shown)_[data-kh-submit]]:opacity-0')}>\n          <FormStatus status={props.status} messages={props.messages} />\n          <Opt path={['inputLabel']} value={props.inputLabel} as=\"span\" className={editing ? 'mb-2 block text-kh-caption text-kh-muted' : 'sr-only'} placeholder=\"Field name for assistive tech\" />\n          <div hidden={sent}>\n          <div className={cn(!multiline && 'flex items-center gap-3 transition-[gap] duration-(--kh-dur) has-[.peer:placeholder-shown]:gap-0')}>\n          <SlotField\n            path={['placeholder']}\n            value={props.placeholder}\n            multiline={multiline}\n            grow={grow}\n            name={props.inputName || 'prompt'}\n            required={!!formProps.action}\n            inputType={multiline ? undefined : props.inputType === 'url' ? 'url' : 'text'}\n            inputProps={{\n              ...(kind === 'domain' ? { pattern: DOMAIN_PATTERN, title: words.domain, inputMode: 'url', autoComplete: 'url', autoCapitalize: 'none', spellCheck: false } : kind === 'url' ? { pattern: URL_PATTERN, title: words.url } : {}),\n              id: `${id}-f`,\n              ...fieldProps('f', kind),\n            }}\n            ariaLabel={props.inputLabel || undefined}\n            className={cn('px-1', !multiline && 'min-w-0 flex-1')}\n            fieldClassName={multiline ? 'min-h-20 pt-1' : undefined}\n          />\n          {!extra && multiline && hasTools ? (\n            // The box's bottom row: tools at the start, send at the end; on a phone the tools wrap above send.\n            <div className=\"mt-2 flex flex-wrap items-end justify-between gap-2\">\n              <div className=\"flex min-w-0 flex-col\"><ToolRow props={props} editing={editing} /></div>\n              {submitWrap('ml-auto flex')}\n            </div>\n          ) : !extra && submitWrap(cn(multiline ? 'mt-2 flex justify-end' : 'shrink-0 transition-[width,opacity] duration-(--kh-dur)'))}\n          </div>\n          <FieldError id={`${id}-f`} text={errs.f} />\n          {props.escapePlacement !== 'below' && <EscapeLink escape={props.escape} path={['escape', 'label']} editing={editing} wrap=\"mt-1 px-1\" />}\n          {extra && (\n            <div className=\"mt-3 border-t border-kh-line px-1 pt-3\">\n              <div className=\"flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1\">\n                <Text path={['field', 'label']} value={extra.label!} as=\"p\" className=\"text-kh-small font-medium text-kh-ink-2\" />\n                <EscapeLink escape={extra.escape} path={['field', 'escape', 'label']} editing={editing} />\n              </div>\n              <SlotField\n                path={['field', 'placeholder']}\n                value={extra.placeholder ?? ''}\n                name={extra.name || 'site'}\n                required={!!extra.required && !!formProps.action}\n                inputType={extraKind === 'url' ? 'url' : 'text'}\n                ariaLabel={extra.label!}\n                inputProps={{\n                  ...(extraKind === 'domain' ? { pattern: DOMAIN_PATTERN, title: words.domain, inputMode: 'url', autoComplete: 'url', autoCapitalize: 'none', spellCheck: false } : extraKind === 'url' ? { pattern: URL_PATTERN, title: words.url } : {}),\n                  id: `${id}-g`,\n                  ...fieldProps('g', extraKind),\n                }}\n                className=\"mt-1\"\n              />\n              <FieldError id={`${id}-g`} text={errs.g} />\n              {/* with a second field the button comes after it, so both are filled before sending */}\n              {submitWrap('mt-3 flex justify-end')}\n            </div>\n          )}\n          <FormExtras {...props} />\n          </div>\n        </form>\n        )}\n        {fieldNamed && !sent && props.escapePlacement === 'below' && (\n          <EscapeLink escape={props.escape} path={['escape', 'label']} editing={editing} wrap=\"mx-auto mt-3 max-w-2xl px-1 text-center @3xl:text-left\" />\n        )}\n        {/* A chip puts its example in the field, so it needs script; a library row leaves the chips out (spec.rowOmit, KB-425). */}\n        {(props.suggestions ?? []).length > 0 && (\n          <ul aria-label=\"Suggestions\" className=\"mx-auto mt-5 flex max-w-2xl flex-wrap justify-center gap-2\">\n            {(props.suggestions ?? []).slice(0, 3).map((s, i) => (\n              <li key={i}>\n                <button\n                  type=\"button\"\n                  onClick={() => fillField(`${id}-f`, s)}\n                  className=\"inline-flex min-h-8 items-center rounded-kh-pill border border-kh-line-strong bg-kh-surface px-3 text-kh-caption text-kh-ink-2 pointer-coarse:min-h-11 transition-colors duration-(--kh-dur) hover:bg-kh-surface-2 hover:text-kh-ink focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--kh-focus)\"\n                >\n                  <Text path={['suggestions', i]} value={s} as=\"span\" />\n                </button>\n              </li>\n            ))}\n          </ul>\n        )}\n        {!sent && (\n          <Opt path={['note']} value={props.note} className=\"mt-5 text-center text-kh-small text-kh-muted\" placeholder=\"Reassurance line\" />\n        )}\n        {!sent && descUnderNote && description}\n      </Container>\n    </Section>\n  );\n}\n\n/** Put an example in the prompt field and focus it at its end, as if the visitor had typed it. */\nfunction fillField(fieldId: string, text: string) {\n  const el = document.getElementById(fieldId) as HTMLTextAreaElement | HTMLInputElement | null;\n  if (!el) return;\n  el.value = text;\n  el.dispatchEvent(new Event('input', { bubbles: true }));\n  el.focus();\n  el.setSelectionRange(text.length, text.length);\n}\n\n/** A plain link for people who cannot fill a field (\"I don't have a website\"): no JS, a 24px target, drawn only with a label and an href. */\nfunction EscapeLink({ escape, path, editing, wrap }: { escape?: { label?: string; href?: string }; path: (string | number)[]; editing: boolean; wrap?: string }) {\n  if (!escape || !(editing || (escape.label?.trim() && escape.href?.trim()))) return null;\n  const link = (\n    <a href={safeHref(escape.href)} className=\"inline-flex min-h-6 items-center rounded-kh-sm text-kh-small text-kh-muted underline underline-offset-2 hover:text-kh-ink focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--kh-focus)\">\n      <Text path={path} value={escape.label ?? ''} as=\"span\" />\n    </a>\n  );\n  return wrap ? <div className={wrap}>{link}</div> : link;\n}\n\nexport default withHeadingLevel(HeroPrompt);\n"
    }
  ]
}
