{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "fable-ui",
  "title": "Fable UI",
  "description": "Generative UI for AI agents: 24 blocks, 3 layouts, a streaming renderer, the render_ui AI SDK tool and its system prompt.",
  "dependencies": [
    "ai@^7",
    "zod@^4",
    "react-markdown@^10",
    "remark-gfm@^4",
    "recharts@^3",
    "lucide-react"
  ],
  "registryDependencies": [
    "accordion",
    "badge",
    "button",
    "chart",
    "checkbox",
    "dialog",
    "input",
    "label",
    "radio-group",
    "select",
    "switch",
    "tabs",
    "textarea",
    "tooltip"
  ],
  "files": [
    {
      "path": "components/fable-ui/index.ts",
      "content": "// Client entry. Server code imports from \"./tool\", \"./prompt\" and \"./schema\" directly.\nexport { FableProvider, FableScope, useFable, useFableState } from \"./provider\"\nexport type { FableConfig, FableHostAction } from \"./provider\"\nexport { FableRenderer } from \"./renderer\"\nexport type { FableRendererProps } from \"./renderer\"\nexport { FableToolPart, isFableToolPart } from \"./tool-part\"\nexport type { FableToolPartLike } from \"./tool-part\"\nexport { specToMarkdown } from \"./to-markdown\"\nexport { resolveSpec } from \"./resolve\"\nexport type * from \"./schema\"\n",
      "type": "registry:component",
      "target": "components/fable-ui/index.ts"
    },
    {
      "path": "components/fable-ui/schema.ts",
      "content": "import { z } from \"zod\"\n\n/**\n * The Fable catalog: every block the model may write, with hard bounds.\n *\n * Server-safe (no React). Objects strip unknown keys instead of failing so a\n * slightly-off model still renders; bounds are strict so a runaway model\n * cannot render unbounded content. Layout blocks contain content blocks and\n * never nest, which keeps the JSON Schema non-recursive for every provider.\n */\n\nconst text = (max: number) => z.string().max(max)\nconst label = (max = 80) => z.string().min(1).max(max)\nconst markdown = (max = 12_000) =>\n  z.string().max(max).describe(\"GitHub-flavored Markdown. No HTML, no images.\")\n\nconst tone = z.enum([\"neutral\", \"info\", \"success\", \"warning\", \"danger\"])\nconst scalar = z.union([z.string().max(400), z.number(), z.boolean(), z.null()])\n\nexport const FABLE_ICONS = [\n  \"arrow-right\",\n  \"calendar\",\n  \"check\",\n  \"copy\",\n  \"download\",\n  \"edit\",\n  \"external-link\",\n  \"file\",\n  \"heart\",\n  \"info\",\n  \"mail\",\n  \"map-pin\",\n  \"phone\",\n  \"play\",\n  \"plus\",\n  \"refresh\",\n  \"search\",\n  \"send\",\n  \"share\",\n  \"sparkles\",\n  \"star\",\n] as const\n\nexport const FABLE_DOWNLOAD_TYPES = [\n  \"text/plain\",\n  \"text/markdown\",\n  \"text/csv\",\n  \"application/json\",\n  \"text/calendar\",\n] as const\n\nconst icon = z.enum(FABLE_ICONS)\nconst buttonStyle = z.enum([\"primary\", \"secondary\", \"outline\", \"ghost\"])\n\n// ---------------------------------------------------------------- actions\n\nconst actionBase = {\n  label: label(48),\n  style: buttonStyle.optional(),\n  icon: icon.optional(),\n}\n\nexport const ActionSchema = z.discriminatedUnion(\"type\", [\n  z.object({\n    ...actionBase,\n    type: z.literal(\"reply\"),\n    message: label(600).describe(\"Sent as the user's next message.\"),\n  }),\n  z.object({\n    ...actionBase,\n    type: z.literal(\"link\"),\n    url: label(2048).describe(\"https:// or mailto: only.\"),\n  }),\n  z.object({\n    ...actionBase,\n    type: z.literal(\"copy\"),\n    text: label(20_000),\n  }),\n  z.object({\n    ...actionBase,\n    type: z.literal(\"download\"),\n    filename: label(100),\n    mimeType: z.enum(FABLE_DOWNLOAD_TYPES).optional(),\n    content: label(60_000),\n  }),\n  z.object({\n    ...actionBase,\n    type: z.literal(\"host\"),\n    action: z\n      .string()\n      .regex(/^[a-z][a-z0-9_.-]{0,63}$/)\n      .describe(\"Name of an action the app registered. Never invent names.\"),\n    payload: z.record(z.string().max(64), scalar).optional(),\n  }),\n])\n\n// ---------------------------------------------------------------- media\n\nexport const ImageSchema = z.object({\n  src: label(2048).describe(\"Absolute https URL of an image.\"),\n  alt: text(240),\n  caption: text(240).optional(),\n  credit: text(120).optional(),\n})\n\n// ---------------------------------------------------------------- content blocks\n\nconst MarkdownBlock = z.object({\n  type: z.literal(\"markdown\"),\n  text: markdown(),\n})\n\nconst HeadingBlock = z.object({\n  type: z.literal(\"heading\"),\n  text: label(160),\n  eyebrow: text(60).optional(),\n  description: text(400).optional(),\n  level: z.union([z.literal(1), z.literal(2), z.literal(3)]).optional(),\n})\n\nconst CalloutBlock = z.object({\n  type: z.literal(\"callout\"),\n  tone: z.enum([\"info\", \"success\", \"warning\", \"danger\", \"tip\"]),\n  title: text(120).optional(),\n  text: markdown(2_000),\n})\n\nconst MetricsBlock = z.object({\n  type: z.literal(\"metrics\"),\n  items: z\n    .array(\n      z.object({\n        label: label(60),\n        value: z.union([z.number(), z.string().max(40)]),\n        format: z.enum([\"number\", \"currency\", \"percent\", \"compact\"]).optional(),\n        currency: z.string().regex(/^[A-Z]{3}$/).optional(),\n        delta: z.number().optional().describe(\"Change, in percent.\"),\n        deltaLabel: text(40).optional(),\n        invertDelta: z.boolean().optional().describe(\"True when lower is better.\"),\n        hint: text(80).optional(),\n      })\n    )\n    .min(1)\n    .max(8),\n})\n\nconst columnType = z.enum([\n  \"text\",\n  \"number\",\n  \"currency\",\n  \"percent\",\n  \"date\",\n  \"badge\",\n  \"link\",\n])\n\nconst TableBlock = z.object({\n  type: z.literal(\"table\"),\n  title: text(120).optional(),\n  description: text(300).optional(),\n  columns: z\n    .array(\n      z.object({\n        key: z.string().min(1).max(40),\n        label: label(60),\n        type: columnType.optional(),\n        currency: z.string().regex(/^[A-Z]{3}$/).optional(),\n        align: z.enum([\"start\", \"end\", \"center\"]).optional(),\n      })\n    )\n    .min(1)\n    .max(12),\n  rows: z.array(z.record(z.string().max(40), scalar)).max(200),\n  footer: z.record(z.string().max(40), scalar).optional(),\n  sortable: z.boolean().optional(),\n  searchable: z.boolean().optional(),\n  downloadable: z.boolean().optional().describe(\"Shows a CSV download button.\"),\n})\n\nconst ChartBlock = z.object({\n  type: z.literal(\"chart\"),\n  kind: z.enum([\"bar\", \"line\", \"area\", \"pie\", \"donut\"]),\n  title: text(120).optional(),\n  description: text(300).optional(),\n  xKey: z.string().min(1).max(40).describe(\"Key of the category field in data.\"),\n  series: z\n    .array(z.object({ key: z.string().min(1).max(40), label: label(60) }))\n    .min(1)\n    .max(5),\n  data: z.array(z.record(z.string().max(40), z.union([z.string().max(60), z.number(), z.null()]))).min(1).max(60),\n  format: z.enum([\"number\", \"currency\", \"percent\", \"compact\"]).optional(),\n  currency: z.string().regex(/^[A-Z]{3}$/).optional(),\n  stacked: z.boolean().optional(),\n  horizontal: z.boolean().optional(),\n})\n\nconst DetailsBlock = z.object({\n  type: z.literal(\"details\"),\n  title: text(120).optional(),\n  items: z\n    .array(z.object({ label: label(60), value: text(400), tone: tone.optional() }))\n    .min(1)\n    .max(24),\n  columns: z.union([z.literal(1), z.literal(2)]).optional(),\n})\n\nconst ListBlock = z.object({\n  type: z.literal(\"list\"),\n  title: text(120).optional(),\n  style: z.enum([\"bullet\", \"numbered\", \"check\", \"steps\", \"timeline\"]),\n  items: z\n    .array(\n      z.object({\n        title: label(160),\n        description: text(600).optional(),\n        meta: text(60).optional().describe(\"Date for timelines, duration for steps.\"),\n        status: z.enum([\"done\", \"current\", \"upcoming\"]).optional(),\n      })\n    )\n    .min(1)\n    .max(30),\n})\n\nconst ChecklistBlock = z.object({\n  type: z.literal(\"checklist\"),\n  title: text(120).optional(),\n  items: z\n    .array(z.object({ label: label(200), checked: z.boolean().optional(), note: text(200).optional() }))\n    .min(1)\n    .max(40),\n})\n\nconst CodeBlock = z.object({\n  type: z.literal(\"code\"),\n  code: label(20_000),\n  language: z.string().regex(/^[A-Za-z0-9+#.-]{1,24}$/).optional(),\n  filename: text(100).optional(),\n})\n\nconst QuoteBlock = z.object({\n  type: z.literal(\"quote\"),\n  text: label(800),\n  author: text(80).optional(),\n  source: text(120).optional(),\n})\n\nconst ImageBlock = z.object({\n  type: z.literal(\"image\"),\n  image: ImageSchema,\n  aspect: z.enum([\"auto\", \"square\", \"landscape\", \"portrait\", \"wide\"]).optional(),\n})\n\nconst GalleryBlock = z.object({\n  type: z.literal(\"gallery\"),\n  title: text(120).optional(),\n  layout: z\n    .enum([\"grid\", \"featured\", \"masonry\", \"carousel\"])\n    .describe(\"grid: even tiles. featured: one large + small. masonry: mixed heights. carousel: swipeable row.\"),\n  images: z.array(ImageSchema).min(1).max(24),\n})\n\nconst CardsBlock = z.object({\n  type: z.literal(\"cards\"),\n  title: text(120).optional(),\n  columns: z.union([z.literal(1), z.literal(2), z.literal(3)]).optional(),\n  items: z\n    .array(\n      z.object({\n        title: label(120),\n        description: text(400).optional(),\n        image: ImageSchema.optional(),\n        badge: text(32).optional(),\n        meta: text(80).optional(),\n        action: ActionSchema.optional(),\n      })\n    )\n    .min(1)\n    .max(12),\n})\n\nconst HeroBlock = z.object({\n  type: z.literal(\"hero\"),\n  variant: z\n    .enum([\"split\", \"cover\", \"editorial\", \"spotlight\"])\n    .describe(\"split: text beside image. cover: text over image. editorial: big type, no image. spotlight: centered, accent background.\"),\n  eyebrow: text(60).optional(),\n  title: label(160),\n  description: text(600).optional(),\n  image: ImageSchema.optional(),\n  stats: z.array(z.object({ label: label(40), value: label(24) })).max(4).optional(),\n  actions: z.array(ActionSchema).max(3).optional(),\n})\n\nconst ArticleBlock = z.object({\n  type: z.literal(\"article\"),\n  title: label(200),\n  subtitle: text(400).optional(),\n  byline: text(120).optional(),\n  readingTime: text(32).optional(),\n  cover: ImageSchema.optional(),\n  sections: z\n    .array(z.object({ heading: text(160).optional(), body: markdown(8_000) }))\n    .min(1)\n    .max(20),\n})\n\nconst fieldType = z.enum([\n  \"text\",\n  \"textarea\",\n  \"email\",\n  \"number\",\n  \"date\",\n  \"select\",\n  \"radio\",\n  \"checkbox\",\n  \"toggle\",\n])\n\nconst FormBlock = z.object({\n  type: z.literal(\"form\"),\n  title: text(120).optional(),\n  description: text(400).optional(),\n  fields: z\n    .array(\n      z.object({\n        name: z.string().regex(/^[A-Za-z][A-Za-z0-9_]{0,39}$/),\n        label: label(80),\n        type: fieldType,\n        placeholder: text(120).optional(),\n        helper: text(200).optional(),\n        required: z.boolean().optional(),\n        options: z.array(label(80)).max(20).optional().describe(\"For select and radio.\"),\n        defaultValue: z.union([z.string().max(400), z.number(), z.boolean()]).optional(),\n      })\n    )\n    .min(1)\n    .max(16),\n  submitLabel: text(40).optional(),\n})\n\nconst TemplateBlock = z.object({\n  type: z.literal(\"template\"),\n  title: text(120).optional(),\n  description: text(300).optional(),\n  body: label(20_000).describe(\"Text with {{variable}} placeholders the user can fill.\"),\n  variables: z\n    .array(z.object({ name: z.string().regex(/^[A-Za-z][A-Za-z0-9_]{0,39}$/), label: label(60), value: text(200).optional() }))\n    .max(20)\n    .optional(),\n  filename: text(100).optional(),\n})\n\nconst EmailBlock = z.object({\n  type: z.literal(\"email\"),\n  to: z.array(z.string().max(254)).max(10).optional(),\n  cc: z.array(z.string().max(254)).max(10).optional(),\n  subject: text(200),\n  body: label(20_000),\n  sendAction: z\n    .string()\n    .regex(/^[a-z][a-z0-9_.-]{0,63}$/)\n    .optional()\n    .describe(\"Host action that sends the email, only if the app registered one.\"),\n})\n\nconst ActionsBlock = z.object({\n  type: z.literal(\"actions\"),\n  items: z.array(ActionSchema).min(1).max(6),\n})\n\nconst FileBlock = z.object({\n  type: z.literal(\"file\"),\n  filename: label(100),\n  description: text(200).optional(),\n  mimeType: z.enum(FABLE_DOWNLOAD_TYPES).optional(),\n  content: label(60_000),\n})\n\nconst SourcesBlock = z.object({\n  type: z.literal(\"sources\"),\n  items: z\n    .array(z.object({ title: label(200), url: label(2048), publisher: text(80).optional(), snippet: text(300).optional() }))\n    .min(1)\n    .max(12),\n})\n\nconst FaqBlock = z.object({\n  type: z.literal(\"faq\"),\n  title: text(120).optional(),\n  items: z.array(z.object({ question: label(200), answer: markdown(3_000) })).min(1).max(20),\n})\n\nconst DividerBlock = z.object({\n  type: z.literal(\"divider\"),\n  label: text(60).optional(),\n})\n\nexport const CONTENT_BLOCKS = {\n  markdown: MarkdownBlock,\n  heading: HeadingBlock,\n  callout: CalloutBlock,\n  metrics: MetricsBlock,\n  table: TableBlock,\n  chart: ChartBlock,\n  details: DetailsBlock,\n  list: ListBlock,\n  checklist: ChecklistBlock,\n  code: CodeBlock,\n  quote: QuoteBlock,\n  image: ImageBlock,\n  gallery: GalleryBlock,\n  cards: CardsBlock,\n  hero: HeroBlock,\n  article: ArticleBlock,\n  form: FormBlock,\n  template: TemplateBlock,\n  email: EmailBlock,\n  actions: ActionsBlock,\n  file: FileBlock,\n  sources: SourcesBlock,\n  faq: FaqBlock,\n  divider: DividerBlock,\n} as const\n\nexport type ContentBlockType = keyof typeof CONTENT_BLOCKS\nexport type LayoutBlockType = \"columns\" | \"section\" | \"tabs\"\nexport type FableBlockType = ContentBlockType | LayoutBlockType\n\n/**\n * Blocks whose partial content is meaningful while streaming. Others show a\n * size-reserving skeleton until they close, so a half-written image URL or\n * a form without all its fields never renders.\n */\nexport const STREAMABLE_BLOCKS = new Set<FableBlockType>([\n  \"markdown\",\n  \"heading\",\n  \"callout\",\n  \"metrics\",\n  \"table\",\n  \"details\",\n  \"list\",\n  \"code\",\n  \"quote\",\n  \"article\",\n  \"faq\",\n  \"sources\",\n  \"divider\",\n  \"columns\",\n  \"section\",\n  \"tabs\",\n])\n\nexport const LAYOUT_BLOCKS = new Set<FableBlockType>([\"columns\", \"section\", \"tabs\"])\n\nconst ALL_CONTENT = [\n  MarkdownBlock, HeadingBlock, CalloutBlock, MetricsBlock, TableBlock, ChartBlock, DetailsBlock, ListBlock,\n  ChecklistBlock, CodeBlock, QuoteBlock, ImageBlock, GalleryBlock, CardsBlock, HeroBlock, ArticleBlock,\n  FormBlock, TemplateBlock, EmailBlock, ActionsBlock, FileBlock, SourcesBlock, FaqBlock, DividerBlock,\n] as const\n\nfunction buildSchemas(include?: readonly ContentBlockType[], mode: \"strict\" | \"model\" = \"strict\") {\n  const entries = ALL_CONTENT.filter((schema) => !include || include.includes(schema.shape.type.value))\n  if (entries.length === 0) throw new Error(\"Fable catalog needs at least one block.\")\n\n  // A subset is still one of these shapes at runtime; the static type is the full union.\n  const content = z.discriminatedUnion(\"type\", entries as unknown as typeof ALL_CONTENT)\n  const names = entries.map((schema) => schema.shape.type.value) as [ContentBlockType, ...ContentBlockType[]]\n\n  // The model-facing schema describes layout children by reference to the\n  // top-level shapes instead of repeating the whole union three more times\n  // (that would quadruple the tool definition). Children are still validated\n  // strictly, one by one, before they render.\n  const child =\n    mode === \"model\"\n      ? (z\n          .looseObject({ type: z.enum(names) })\n          .describe(\"A content block with exactly the same shape as a top-level block of this type.\") as unknown as typeof content)\n      : content\n  const children = z.array(child).min(1).max(12)\n\n  const layout = z.discriminatedUnion(\"type\", [\n    z.object({\n      type: z.literal(\"columns\"),\n      ratio: z\n        .enum([\"equal\", \"wide-left\", \"wide-right\"])\n        .optional()\n        .describe(\"Column width ratio. Two or three columns; stacks on phones.\"),\n      columns: z.array(z.object({ blocks: children })).min(2).max(3),\n    }),\n    z.object({\n      type: z.literal(\"section\"),\n      title: text(120).optional(),\n      description: text(300).optional(),\n      variant: z.enum([\"plain\", \"card\", \"muted\"]).optional(),\n      blocks: children,\n    }),\n    z.object({\n      type: z.literal(\"tabs\"),\n      tabs: z.array(z.object({ label: label(40), blocks: children })).min(2).max(6),\n    }),\n  ])\n\n  const block = z.union([content, layout])\n  const spec = z.object({\n    title: text(120).optional().describe(\"Short title used for copy/export. Not displayed.\"),\n    blocks: z.array(block).min(1).max(24),\n  })\n\n  return { content, layout, block, spec }\n}\n\nconst defaultSchemas = buildSchemas()\n\nexport const ContentBlockSchema = defaultSchemas.content\nexport const LayoutBlockSchema = defaultSchemas.layout\nexport const BlockSchema = defaultSchemas.block\n/** Strict: every nested block is validated. Use it to check a spec. */\nexport const FableSpecSchema = defaultSchemas.spec\n\n/**\n * The compact schema sent to the model as the tool input. Smaller catalogs\n * (`include`) mean a shorter definition and fewer wrong picks.\n */\nexport function createFableToolSchema(include?: readonly ContentBlockType[]) {\n  return buildSchemas(include, \"model\").spec\n}\n\n/** Strict schema for a subset of blocks. */\nexport function createFableSpecSchema(include?: readonly ContentBlockType[]) {\n  return include ? buildSchemas(include).spec : FableSpecSchema\n}\n\nexport type FableAction = z.infer<typeof ActionSchema>\nexport type FableImage = z.infer<typeof ImageSchema>\nexport type ContentBlock = z.infer<typeof ContentBlockSchema>\nexport type LayoutBlock = z.infer<typeof LayoutBlockSchema>\nexport type FableBlock = z.infer<typeof BlockSchema>\nexport type FableSpec = z.infer<typeof FableSpecSchema>\nexport type BlockOf<T extends FableBlockType> = Extract<FableBlock, { type: T }>\n",
      "type": "registry:lib",
      "target": "components/fable-ui/schema.ts"
    },
    {
      "path": "components/fable-ui/protocol.ts",
      "content": "/** Shared wire constants. Safe to import from clients without initializing a model tool. */\nexport const FABLE_TOOL_NAME = \"render_ui\"\n",
      "type": "registry:lib",
      "target": "components/fable-ui/protocol.ts"
    },
    {
      "path": "components/fable-ui/prompt.ts",
      "content": "import type { ContentBlockType } from \"./schema\"\n\nexport interface FablePromptOptions {\n  /** Name of the render tool. Defaults to \"render_ui\". */\n  toolName?: string\n  /** Blocks the tool accepts; the guide only mentions these. */\n  include?: readonly ContentBlockType[]\n  /** Host actions the app registered, with what they do. */\n  hostActions?: Record<string, string>\n  /**\n   * Where images may come from. Without a source, the model is told not to\n   * use image blocks, because invented URLs are always broken.\n   */\n  imageSource?: string\n}\n\nconst guide: Partial<Record<ContentBlockType, string>> = {\n  markdown: \"markdown — prose, the default. Short paragraphs, bold key terms, lists.\",\n  heading: \"heading — titles a multi-part answer. Optional eyebrow and one-line description.\",\n  callout: \"callout — one warning, tip, or key takeaway. Never more than two per answer.\",\n  metrics: \"metrics — 1–8 headline numbers with optional % delta.\",\n  table: \"table — comparisons and records. Typed columns (number, currency, percent, date, badge, link). Use badge for statuses.\",\n  chart: \"chart — trends (line/area), comparisons (bar), shares of a whole (pie/donut, ≤ 6 slices).\",\n  details: \"details — label/value facts about one thing (specs, a booking, an order).\",\n  list: \"list — bullet/numbered/check items, steps (a process, with status), or a timeline (with dates in meta).\",\n  checklist: \"checklist — tasks the user will tick off themselves.\",\n  code: \"code — code or commands, with language.\",\n  quote: \"quote — a notable quotation with attribution.\",\n  image: \"image — one photo or illustration.\",\n  gallery: \"gallery — several images: grid, featured, masonry, or carousel.\",\n  cards: \"cards — 2–12 options to compare or pick from (places, products, plans), optionally with an image and an action each.\",\n  hero: \"hero — a striking opener for a plan, guide, or recommendation: split, cover (needs image), editorial (type-led, no image), spotlight.\",\n  article: \"article — long-form writing (articles, essays, reports, guides) in headed sections; gets a table of contents and export.\",\n  form: \"form — ask for missing details instead of guessing. Submitting sends the answers to you.\",\n  template: \"template — reusable text with {{placeholders}} the user fills in (messages, posts, status updates). Up to 20 variables.\",\n  email: \"email — any email draft: to, subject, body. The user edits and sends it.\",\n  actions: \"actions — 1–4 next steps. reply sends a follow-up message; link opens a URL; copy/download hand over text.\",\n  file: \"file — a downloadable text file (csv, md, json, ics, txt) with its full content.\",\n  sources: \"sources — where facts came from. Only real URLs you were given.\",\n  faq: \"faq — collapsible questions and answers.\",\n  divider: \"divider — separates major parts.\",\n}\n\n/**\n * The system prompt that teaches a model to answer with Fable. Keep it next\n * to your own instructions; it only covers presentation.\n */\nexport function fableSystemPrompt(options: FablePromptOptions = {}) {\n  const tool = options.toolName ?? \"render_ui\"\n  const blocks = (Object.keys(guide) as ContentBlockType[]).filter((name) => !options.include || options.include.includes(name))\n  const images = blocks.some((name) => name === \"image\" || name === \"gallery\" || name === \"hero\" || name === \"cards\" || name === \"article\")\n  const actions = Object.entries(options.hostActions ?? {})\n\n  return [\n    `You can answer with rich, interactive UI by calling the \\`${tool}\\` tool with a list of blocks.`,\n    \"\",\n    \"When to use it:\",\n    `- Use \\`${tool}\\` for any answer with structure or substance: articles and essays, guides and how-tos, steps, code, comparisons, data, plans, drafts to edit (emails, posts, templates), media, choices, or anything the user will act on.`,\n    \"- Answer in plain text only for greetings, quick conversational replies, opinions, or a single fact in a sentence or two.\",\n    \"- The requested output decides the block: an email is an email block, an article is an article block, a template is a template block, a file or CSV is a file block.\",\n    `- When you call \\`${tool}\\`, put the whole answer in it, including the prose. Do not repeat it in text before or after the call.`,\n    \"\",\n    \"How to compose:\",\n    \"- Lead with the answer. The first block states the conclusion in one or two sentences; detail follows.\",\n    \"- Pick the block that fits each idea, not one format for the whole reply. Mix prose with at most a few rich blocks.\",\n    \"- Prefer one strong block over several weak ones. No filler headings, no decorative callouts.\",\n    \"- Use columns only for things that belong side by side (e.g. a chart and its key facts). Use tabs for alternatives the user picks between.\",\n    \"- End with an actions block of 2–3 specific next steps when there is an obvious follow-up.\",\n    \"- If you need information to give a good answer, give the best default answer first, then a short form for the missing details.\",\n    \"- Write labels in sentence case. Buttons say exactly what happens (\\\"Plan day 4\\\", not \\\"Submit\\\").\",\n    \"\",\n    \"Blocks:\",\n    ...blocks.map((name) => `- ${guide[name]}`),\n    \"\",\n    \"Rules:\",\n    \"- Never invent facts, numbers, or URLs. Tables and charts show data you have, from the conversation or tools.\",\n    images\n      ? options.imageSource\n        ? `- Images: ${options.imageSource} Never invent image URLs.`\n        : \"- Do not use image, gallery, cover images, or card images: you have no image source and invented URLs are broken.\"\n      : \"\",\n    \"- Markdown cannot contain HTML or images.\",\n    actions.length\n      ? `- Host actions you may use (type \\\"host\\\"): ${actions.map(([name, description]) => `\\`${name}\\` (${description})`).join(\", \")}. Never invent others.`\n      : \"- Do not use host actions; this app has none.\",\n  ]\n    .filter((line) => line !== \"\")\n    .join(\"\\n\")\n    .replace(/\\n(When to use it:|How to compose:|Blocks:|Rules:)/g, \"\\n\\n$1\")\n}\n",
      "type": "registry:lib",
      "target": "components/fable-ui/prompt.ts"
    },
    {
      "path": "components/fable-ui/tool.ts",
      "content": "import { tool } from \"ai\"\n\nimport { listIssues, resolveSpec } from \"./resolve\"\nimport { createFableToolSchema, type ContentBlockType } from \"./schema\"\n\nexport { FABLE_TOOL_NAME } from \"./protocol\"\n\nexport interface FableToolOptions {\n  /** Restrict the catalog. Fewer blocks: shorter schema, better picks. */\n  include?: readonly ContentBlockType[]\n  description?: string\n}\n\n/**\n * The AI SDK tool the model calls to answer with UI. It has no side effects:\n * execute only acknowledges, so the conversation history stays valid and the\n * client renders the (streamed) input.\n *\n *   streamText({ tools: { render_ui: createFableTool() }, stopWhen: hasToolCall(\"render_ui\") })\n */\nexport function createFableTool(options: FableToolOptions = {}) {\n  return tool({\n    description:\n      options.description ??\n      \"Show the answer to the user as rich UI built from blocks (text, tables, charts, media, forms, drafts, actions). The user sees it immediately.\",\n    inputSchema: createFableToolSchema(options.include),\n    // Tells the model which blocks were skipped, so a follow-up turn can fix them.\n    execute: async (input) => {\n      const skipped = listIssues(resolveSpec(input).items).slice(0, 5)\n      return { status: \"displayed\" as const, blocks: input.blocks.length, ...(skipped.length ? { skipped } : {}) }\n    },\n  })\n}\n\nexport const fableTool = createFableTool()\n",
      "type": "registry:lib",
      "target": "components/fable-ui/tool.ts"
    },
    {
      "path": "components/fable-ui/safety.ts",
      "content": "import { FABLE_DOWNLOAD_TYPES } from \"./schema\"\n\n/**\n * Pure policy functions. Everything the model writes passes through one of\n * these before it can become a link, an image request, or a file.\n */\n\nexport type FableDownloadType = (typeof FABLE_DOWNLOAD_TYPES)[number]\n\nexport interface FableImagePolicy {\n  /**\n   * Hostnames whose images load immediately, e.g. [\"images.unsplash.com\"].\n   * A leading \"*.\" matches subdomains. Other https images wait for a click.\n   */\n  allowedHosts?: string[]\n  /** \"ask\" (default) shows a click-to-load card; \"block\" never loads them. */\n  otherHosts?: \"ask\" | \"block\"\n}\n\nfunction parseUrl(value: string): URL | null {\n  try {\n    return new URL(value.trim())\n  } catch {\n    return null\n  }\n}\n\n/** Links: https, http and mailto only; no embedded credentials. */\nexport function safeLinkUrl(value: string | undefined | null): string | null {\n  if (!value) return null\n  const url = parseUrl(value)\n  if (!url) return null\n  if (url.protocol === \"mailto:\") return url.href\n  if (url.protocol !== \"https:\" && url.protocol !== \"http:\") return null\n  if (url.username || url.password) return null\n  return url.href\n}\n\n/** Images: https only, no credentials. Returns null when the URL can never load. */\nexport function safeImageUrl(value: string | undefined | null): URL | null {\n  if (!value) return null\n  const url = parseUrl(value)\n  if (!url || url.protocol !== \"https:\" || url.username || url.password) return null\n  return url\n}\n\nexport function isHostAllowed(hostname: string, allowedHosts: readonly string[] = []) {\n  const host = hostname.toLowerCase()\n  return allowedHosts.some((entry) => {\n    const rule = entry.toLowerCase().trim()\n    if (rule.startsWith(\"*.\")) return host.endsWith(rule.slice(1)) && host !== rule.slice(2)\n    return host === rule\n  })\n}\n\nexport type ImageDecision =\n  | { status: \"load\"; src: string }\n  | { status: \"ask\"; src: string; host: string }\n  | { status: \"blocked\" }\n\nexport function decideImage(src: string | undefined, policy: FableImagePolicy = {}): ImageDecision {\n  const url = safeImageUrl(src)\n  if (!url) return { status: \"blocked\" }\n  if (isHostAllowed(url.hostname, policy.allowedHosts)) return { status: \"load\", src: url.href }\n  if (policy.otherHosts === \"block\") return { status: \"blocked\" }\n  return { status: \"ask\", src: url.href, host: url.hostname }\n}\n\nconst EXTENSIONS: Record<FableDownloadType, string> = {\n  \"text/plain\": \"txt\",\n  \"text/markdown\": \"md\",\n  \"text/csv\": \"csv\",\n  \"application/json\": \"json\",\n  \"text/calendar\": \"ics\",\n}\n\nexport function inferDownloadType(filename: string): FableDownloadType {\n  const ext = filename.split(\".\").pop()?.toLowerCase()\n  const match = (Object.entries(EXTENSIONS) as [FableDownloadType, string][]).find(([, e]) => e === ext)\n  return match?.[0] ?? \"text/plain\"\n}\n\n/**\n * Strips path separators and control characters, and forces an extension\n * that matches the (allowlisted) MIME type so a file can never arrive as\n * `.html`, `.svg`, `.exe` or similar.\n */\nexport function safeFilename(filename: string, mimeType?: FableDownloadType) {\n  const type = mimeType ?? inferDownloadType(filename)\n  const ext = EXTENSIONS[type]\n  const base =\n    filename\n      .replace(/[\\u0000-\\u001f\\u007f<>:\"/\\\\|?*]+/g, \"-\")\n      .replace(/\\.{2,}/g, \"\")\n      .replace(/^[.-]+/, \"\")\n      .replace(/\\.[A-Za-z0-9]{1,8}$/, \"\")\n      .trim()\n      .slice(0, 80) || \"download\"\n  return { filename: `${base}.${ext}`, mimeType: type }\n}\n\n/** Saves model-written text as a file in the browser. */\nexport function downloadText(filename: string, content: string, mimeType?: FableDownloadType) {\n  const safe = safeFilename(filename, mimeType)\n  const blob = new Blob([content], { type: `${safe.mimeType};charset=utf-8` })\n  const href = URL.createObjectURL(blob)\n  const anchor = document.createElement(\"a\")\n  anchor.href = href\n  anchor.download = safe.filename\n  anchor.rel = \"noopener\"\n  document.body.appendChild(anchor)\n  anchor.click()\n  anchor.remove()\n  setTimeout(() => URL.revokeObjectURL(href), 1000)\n  return safe.filename\n}\n\n/** Neutralizes spreadsheet formula injection in CSV cells. */\nexport function toCsv(columns: { key: string; label: string }[], rows: Record<string, unknown>[]) {\n  const cell = (value: unknown) => {\n    let text = value === null || value === undefined ? \"\" : String(value)\n    if (/^[=+\\-@\\t\\r]/.test(text)) text = `'${text}`\n    return /[\",\\n\\r]/.test(text) ? `\"${text.replace(/\"/g, '\"\"')}\"` : text\n  }\n  return [\n    columns.map((column) => cell(column.label)).join(\",\"),\n    ...rows.map((row) => columns.map((column) => cell(row[column.key])).join(\",\")),\n  ].join(\"\\n\")\n}\n\nexport function hostLabel(url: string) {\n  const parsed = parseUrl(url)\n  return parsed ? parsed.hostname.replace(/^www\\./, \"\") : url\n}\n",
      "type": "registry:lib",
      "target": "components/fable-ui/safety.ts"
    },
    {
      "path": "components/fable-ui/format.ts",
      "content": "export type FableNumberFormat = \"number\" | \"currency\" | \"percent\" | \"compact\"\n\nexport interface FormatOptions {\n  format?: FableNumberFormat\n  currency?: string\n  locale?: string\n}\n\n/** Server and client must agree, so the default is fixed. Pass `locale` to FableProvider to change it. */\nexport const DEFAULT_LOCALE = \"en-US\"\n\nconst cache = new Map<string, Intl.NumberFormat>()\n\nfunction numberFormat(locale: string | undefined = DEFAULT_LOCALE, options: Intl.NumberFormatOptions) {\n  const key = `${locale ?? \"\"}|${JSON.stringify(options)}`\n  let formatter = cache.get(key)\n  if (!formatter) {\n    try {\n      formatter = new Intl.NumberFormat(locale, options)\n    } catch {\n      formatter = new Intl.NumberFormat(DEFAULT_LOCALE, options)\n    }\n    cache.set(key, formatter)\n  }\n  return formatter\n}\n\n/**\n * Percent values are written as percentages (12.5 means 12.5%), which is\n * what models produce naturally.\n */\nexport function formatNumber(value: number, { format = \"number\", currency, locale }: FormatOptions = {}) {\n  if (!Number.isFinite(value)) return \"—\"\n  switch (format) {\n    case \"currency\":\n      return numberFormat(locale, {\n        style: \"currency\",\n        currency: currency ?? \"USD\",\n        maximumFractionDigits: Math.abs(value) >= 1000 ? 0 : 2,\n      }).format(value)\n    case \"percent\":\n      return numberFormat(locale, { style: \"percent\", maximumFractionDigits: 1 }).format(value / 100)\n    case \"compact\":\n      return numberFormat(locale, { notation: \"compact\", maximumFractionDigits: 1 }).format(value)\n    default:\n      return numberFormat(locale, { maximumFractionDigits: 2 }).format(value)\n  }\n}\n\nexport function formatValue(value: unknown, options: FormatOptions = {}) {\n  if (typeof value === \"number\") return formatNumber(value, options)\n  if (value === null || value === undefined || value === \"\") return \"—\"\n  if (typeof value === \"boolean\") return value ? \"Yes\" : \"No\"\n  return String(value)\n}\n\nexport function formatDate(value: unknown, locale?: string) {\n  if (typeof value !== \"string\" && typeof value !== \"number\") return formatValue(value)\n  const date = new Date(value)\n  if (Number.isNaN(date.getTime())) return String(value)\n  const dateOnly = typeof value === \"string\" && /^\\d{4}-\\d{2}-\\d{2}$/.test(value)\n  return new Intl.DateTimeFormat(locale ?? DEFAULT_LOCALE, {\n    dateStyle: \"medium\",\n    timeZone: dateOnly ? \"UTC\" : undefined,\n  }).format(date)\n}\n\nexport function formatDelta(delta: number, locale?: string) {\n  const sign = delta > 0 ? \"+\" : delta < 0 ? \"−\" : \"\"\n  return `${sign}${numberFormat(locale, { maximumFractionDigits: 1 }).format(Math.abs(delta))}%`\n}\n",
      "type": "registry:lib",
      "target": "components/fable-ui/format.ts"
    },
    {
      "path": "components/fable-ui/resolve.ts",
      "content": "import { z } from \"zod\"\n\nimport {\n  ContentBlockSchema,\n  LAYOUT_BLOCKS,\n  STREAMABLE_BLOCKS,\n  type ContentBlock,\n  type FableBlockType,\n} from \"./schema\"\n\n/**\n * Turns a possibly-partial spec (from a streaming tool call) into a tree the\n * renderer can draw without guessing:\n *\n * - closed blocks are validated on their own; a bad block never takes the\n *   rest of the answer down with it;\n * - the one open block streams its content when that is meaningful, or\n *   becomes a skeleton that reserves its footprint;\n * - keys are positional, so local state survives every new chunk.\n */\n\nexport type Resolved =\n  | { kind: \"content\"; key: string; block: ContentBlock; open: boolean }\n  | { kind: \"pending\"; key: string; type?: string }\n  | { kind: \"invalid\"; key: string; type?: string; issue: string }\n  | {\n      kind: \"columns\"\n      key: string\n      ratio: \"equal\" | \"wide-left\" | \"wide-right\"\n      columns: Resolved[][]\n    }\n  | {\n      kind: \"section\"\n      key: string\n      title?: string\n      description?: string\n      variant: \"plain\" | \"card\" | \"muted\"\n      children: Resolved[]\n    }\n  | { kind: \"tabs\"; key: string; tabs: { label: string; children: Resolved[] }[] }\n\nexport interface ResolvedSpec {\n  title?: string\n  items: Resolved[]\n  /** Blocks dropped because they failed validation. */\n  invalidCount: number\n}\n\nconst MAX_TOP_LEVEL = 24\nconst MAX_CHILDREN = 12\n\nconst str = (max: number) =>\n  z\n    .string()\n    .transform((value) => value.slice(0, max))\n    .optional()\n    .catch(undefined)\n\nconst sectionHeader = z.object({\n  title: str(120),\n  description: str(300),\n  variant: z.enum([\"plain\", \"card\", \"muted\"]).optional().catch(undefined),\n})\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n  return typeof value === \"object\" && value !== null && !Array.isArray(value)\n}\n\n/** Removes the trailing, most deeply nested array element (the one still being written). */\nexport function dropOpenTail(value: unknown): unknown {\n  if (Array.isArray(value)) {\n    if (value.length === 0) return undefined\n    const last = value[value.length - 1]\n    const trimmed = typeof last === \"object\" && last !== null ? dropOpenTail(last) : undefined\n    return trimmed === undefined ? value.slice(0, -1) : [...value.slice(0, -1), trimmed]\n  }\n  if (isRecord(value)) {\n    const keys = Object.keys(value)\n    for (let index = keys.length - 1; index >= 0; index--) {\n      const child = value[keys[index]]\n      if (typeof child === \"object\" && child !== null) {\n        const trimmed = dropOpenTail(child)\n        if (trimmed !== undefined) return { ...value, [keys[index]]: trimmed }\n      }\n    }\n  }\n  return undefined\n}\n\n/**\n * Trims strings and arrays that are over their limit, which is the most\n * common way a good block fails (a button label a few characters too long).\n * Returns null when nothing could be repaired.\n */\nfunction trimOversized(raw: unknown, issues: z.core.$ZodIssue[]): unknown {\n  const fixable = issues.filter((issue) => issue.code === \"too_big\" && typeof issue.maximum === \"number\")\n  if (!fixable.length || fixable.length !== issues.length) return null\n  const copy = structuredClone(raw)\n  for (const issue of fixable) {\n    const parentPath = issue.path.slice(0, -1)\n    const last = issue.path[issue.path.length - 1]\n    let parent: unknown = copy\n    for (const segment of parentPath) parent = (parent as Record<PropertyKey, unknown>)?.[segment as PropertyKey]\n    if (!parent || typeof parent !== \"object\" || last === undefined) return null\n    const record = parent as Record<PropertyKey, unknown>\n    const value = record[last as PropertyKey]\n    const max = Number((issue as { maximum: number | bigint }).maximum)\n    if (typeof value === \"string\") record[last as PropertyKey] = `${value.slice(0, Math.max(0, max - 1)).trimEnd()}…`.slice(0, max)\n    else if (Array.isArray(value)) record[last as PropertyKey] = value.slice(0, max)\n    else return null\n  }\n  return copy\n}\n\nfunction parseContent(raw: unknown) {\n  let parsed = ContentBlockSchema.safeParse(raw)\n  for (let attempt = 0; attempt < 2 && !parsed.success; attempt++) {\n    const repaired = trimOversized(raw, parsed.error.issues)\n    if (repaired === null) break\n    raw = repaired\n    parsed = ContentBlockSchema.safeParse(raw)\n  }\n  return parsed\n}\n\nfunction parseOpen(raw: unknown) {\n  let candidate: unknown = raw\n  for (let attempt = 0; attempt < 4 && candidate !== undefined; attempt++) {\n    const parsed = parseContent(candidate)\n    if (parsed.success) return parsed.data\n    candidate = dropOpenTail(candidate)\n  }\n  return null\n}\n\nfunction typeOf(raw: unknown): string | undefined {\n  return isRecord(raw) && typeof raw.type === \"string\" ? raw.type : undefined\n}\n\nfunction resolveContent(raw: unknown, key: string, open: boolean): Resolved {\n  const type = typeOf(raw)\n\n  if (open) {\n    if (!type || !STREAMABLE_BLOCKS.has(type as FableBlockType)) return { kind: \"pending\", key, type }\n    const block = parseOpen(raw)\n    return block ? { kind: \"content\", key, block, open: true } : { kind: \"pending\", key, type }\n  }\n\n  const parsed = parseContent(raw)\n  if (parsed.success) return { kind: \"content\", key, block: parsed.data, open: false }\n  const issue = parsed.error.issues[0]\n  return {\n    kind: \"invalid\",\n    key,\n    type,\n    issue: issue ? `${issue.path.join(\".\") || \"block\"}: ${issue.message}` : \"invalid block\",\n  }\n}\n\nfunction resolveChildren(raw: unknown, key: string, open: boolean): Resolved[] {\n  if (!Array.isArray(raw)) return open ? [{ kind: \"pending\", key: `${key}.0` }] : []\n  const list = raw.slice(0, MAX_CHILDREN)\n  return list.map((child, index) =>\n    resolveContent(child, `${key}.${index}`, open && index === list.length - 1)\n  )\n}\n\nfunction resolveBlock(raw: unknown, key: string, open: boolean): Resolved {\n  const type = typeOf(raw)\n  if (!type || !LAYOUT_BLOCKS.has(type as FableBlockType) || !isRecord(raw)) {\n    return resolveContent(raw, key, open)\n  }\n\n  if (type === \"columns\") {\n    const columns = Array.isArray(raw.columns) ? raw.columns.slice(0, 3) : []\n    const ratio = raw.ratio === \"wide-left\" || raw.ratio === \"wide-right\" ? raw.ratio : \"equal\"\n    if (columns.length === 0) {\n      return open ? { kind: \"pending\", key, type } : { kind: \"invalid\", key, type, issue: \"columns: empty\" }\n    }\n    return {\n      kind: \"columns\",\n      key,\n      ratio,\n      columns: columns.map((column, index) =>\n        resolveChildren(\n          isRecord(column) ? column.blocks : undefined,\n          `${key}.${index}`,\n          open && index === columns.length - 1\n        )\n      ),\n    }\n  }\n\n  if (type === \"section\") {\n    const header = sectionHeader.parse(raw)\n    return {\n      kind: \"section\",\n      key,\n      title: header.title,\n      description: header.description,\n      variant: header.variant ?? \"plain\",\n      children: resolveChildren(raw.blocks, key, open),\n    }\n  }\n\n  const tabs = Array.isArray(raw.tabs) ? raw.tabs.slice(0, 6) : []\n  const usable = tabs\n    .map((tab, index) => ({ tab, index }))\n    .filter(({ tab }) => isRecord(tab) && typeof tab.label === \"string\" && tab.label.length > 0)\n  if (usable.length === 0) {\n    return open ? { kind: \"pending\", key, type } : { kind: \"invalid\", key, type, issue: \"tabs: empty\" }\n  }\n  return {\n    kind: \"tabs\",\n    key,\n    tabs: usable.map(({ tab, index }) => {\n      const record = tab as Record<string, unknown>\n      return {\n        label: String(record.label).slice(0, 40),\n        children: resolveChildren(record.blocks, `${key}.${index}`, open && index === tabs.length - 1),\n      }\n    }),\n  }\n}\n\n/** Every skipped block with its position, e.g. \"block 2.1 (table): rows: Required\". */\nexport function listIssues(items: Resolved[]): string[] {\n  return items.flatMap((item) => {\n    if (item.kind === \"invalid\") return [`block ${item.key} (${item.type ?? \"unknown\"}): ${item.issue}`]\n    if (item.kind === \"columns\") return item.columns.flatMap(listIssues)\n    if (item.kind === \"section\") return listIssues(item.children)\n    if (item.kind === \"tabs\") return item.tabs.flatMap((tab) => listIssues(tab.children))\n    return []\n  })\n}\n\nfunction countInvalid(items: Resolved[]): number {\n  return items.reduce((total, item) => {\n    if (item.kind === \"invalid\") return total + 1\n    if (item.kind === \"columns\") return total + item.columns.reduce((sum, column) => sum + countInvalid(column), 0)\n    if (item.kind === \"section\") return total + countInvalid(item.children)\n    if (item.kind === \"tabs\") return total + item.tabs.reduce((sum, tab) => sum + countInvalid(tab.children), 0)\n    return total\n  }, 0)\n}\n\nexport function resolveSpec(input: unknown, streaming = false): ResolvedSpec {\n  const spec = isRecord(input) ? input : {}\n  const blocks = Array.isArray(spec.blocks) ? spec.blocks.slice(0, MAX_TOP_LEVEL) : []\n  const items = blocks.map((block, index) =>\n    resolveBlock(block, String(index), streaming && index === blocks.length - 1)\n  )\n  if (streaming && items.length === 0) items.push({ kind: \"pending\", key: \"0\" })\n  return {\n    title: typeof spec.title === \"string\" ? spec.title.slice(0, 120) : undefined,\n    items,\n    invalidCount: countInvalid(items),\n  }\n}\n",
      "type": "registry:lib",
      "target": "components/fable-ui/resolve.ts"
    },
    {
      "path": "components/fable-ui/to-markdown.ts",
      "content": "import { formatValue } from \"./format\"\nimport { FableSpecSchema, type ContentBlock, type FableBlock, type FableSpec } from \"./schema\"\n\n/**\n * Deterministic Markdown for any spec: used for \"copy response\", exports,\n * emails, and clients that cannot render Fable blocks.\n */\n\nconst escapeCell = (value: unknown) => formatValue(value).replace(/\\|/g, \"\\\\|\").replace(/\\n/g, \" \")\n\nfunction content(block: ContentBlock): string {\n  switch (block.type) {\n    case \"markdown\":\n      return block.text\n    case \"heading\":\n      return [\n        block.eyebrow ? `_${block.eyebrow}_` : \"\",\n        `${\"#\".repeat(block.level ?? 2)} ${block.text}`,\n        block.description ?? \"\",\n      ]\n        .filter(Boolean)\n        .join(\"\\n\\n\")\n    case \"callout\":\n      return `> **${block.title ?? block.tone.toUpperCase()}**\\n> ${block.text.replace(/\\n/g, \"\\n> \")}`\n    case \"metrics\":\n      return block.items\n        .map((item) => {\n          const value = typeof item.value === \"number\" ? formatValue(item.value, { format: item.format, currency: item.currency }) : item.value\n          const delta = item.delta !== undefined ? ` (${item.delta > 0 ? \"+\" : \"\"}${item.delta}%${item.deltaLabel ? ` ${item.deltaLabel}` : \"\"})` : \"\"\n          return `- **${item.label}:** ${value}${delta}`\n        })\n        .join(\"\\n\")\n    case \"table\": {\n      const head = `| ${block.columns.map((column) => escapeCell(column.label)).join(\" | \")} |`\n      const rule = `| ${block.columns.map(() => \"---\").join(\" | \")} |`\n      const cell = (column: (typeof block.columns)[number], value: unknown) =>\n        escapeCell(\n          typeof value === \"number\" && (column.type === \"currency\" || column.type === \"percent\")\n            ? formatValue(value, { format: column.type, currency: column.currency })\n            : value\n        )\n      const rows = block.rows.map((row) => `| ${block.columns.map((column) => cell(column, row[column.key])).join(\" | \")} |`)\n      return [block.title ? `**${block.title}**` : \"\", [head, rule, ...rows].join(\"\\n\")].filter(Boolean).join(\"\\n\\n\")\n    }\n    case \"chart\": {\n      const head = `| ${[block.xKey, ...block.series.map((series) => series.label)].join(\" | \")} |`\n      const rule = `| ${[block.xKey, ...block.series].map(() => \"---\").join(\" | \")} |`\n      const rows = block.data.map((row) => `| ${[block.xKey, ...block.series.map((series) => series.key)].map((key) => escapeCell(row[key])).join(\" | \")} |`)\n      return [`**${block.title ?? \"Chart\"}**`, [head, rule, ...rows].join(\"\\n\")].join(\"\\n\\n\")\n    }\n    case \"details\":\n      return [block.title ? `**${block.title}**` : \"\", block.items.map((item) => `- **${item.label}:** ${item.value}`).join(\"\\n\")]\n        .filter(Boolean)\n        .join(\"\\n\\n\")\n    case \"list\": {\n      const marker = (index: number) =>\n        block.style === \"numbered\" || block.style === \"steps\" ? `${index + 1}.` : block.style === \"check\" ? \"- [x]\" : \"-\"\n      return [\n        block.title ? `**${block.title}**` : \"\",\n        block.items\n          .map((item, index) => `${marker(index)} ${item.meta && block.style === \"timeline\" ? `${item.meta} — ` : \"\"}**${item.title}**${item.description ? ` — ${item.description}` : \"\"}`)\n          .join(\"\\n\"),\n      ]\n        .filter(Boolean)\n        .join(\"\\n\\n\")\n    }\n    case \"checklist\":\n      return [block.title ? `**${block.title}**` : \"\", block.items.map((item) => `- [${item.checked ? \"x\" : \" \"}] ${item.label}`).join(\"\\n\")]\n        .filter(Boolean)\n        .join(\"\\n\\n\")\n    case \"code\":\n      return `\\`\\`\\`${block.language ?? \"\"}\\n${block.code}\\n\\`\\`\\``\n    case \"quote\":\n      return `> ${block.text}${block.author ? `\\n>\\n> — ${block.author}${block.source ? `, ${block.source}` : \"\"}` : \"\"}`\n    case \"image\":\n      return `[Image: ${block.image.alt}](${block.image.src})`\n    case \"gallery\":\n      return block.images.map((image) => `- [Image: ${image.alt}](${image.src})`).join(\"\\n\")\n    case \"cards\":\n      return block.items.map((item) => `- **${item.title}**${item.description ? ` — ${item.description}` : \"\"}`).join(\"\\n\")\n    case \"hero\":\n      return [block.eyebrow ? `_${block.eyebrow}_` : \"\", `## ${block.title}`, block.description ?? \"\"].filter(Boolean).join(\"\\n\\n\")\n    case \"article\":\n      return [\n        `# ${block.title}`,\n        block.subtitle ?? \"\",\n        ...block.sections.map((section) => [section.heading ? `## ${section.heading}` : \"\", section.body].filter(Boolean).join(\"\\n\\n\")),\n      ]\n        .filter(Boolean)\n        .join(\"\\n\\n\")\n    case \"form\":\n      return [block.title ? `**${block.title}**` : \"\", block.fields.map((field) => `- ${field.label}${field.required ? \" (required)\" : \"\"}`).join(\"\\n\")]\n        .filter(Boolean)\n        .join(\"\\n\\n\")\n    case \"template\":\n      return block.body\n    case \"email\":\n      return [`**To:** ${(block.to ?? []).join(\", \")}`, `**Subject:** ${block.subject}`, \"\", block.body].join(\"\\n\")\n    case \"actions\":\n      return block.items.map((action) => `- ${action.label}`).join(\"\\n\")\n    case \"file\":\n      return `📄 ${block.filename}${block.description ? ` — ${block.description}` : \"\"}`\n    case \"sources\":\n      return block.items.map((item, index) => `${index + 1}. [${item.title}](${item.url})`).join(\"\\n\")\n    case \"faq\":\n      return block.items.map((item) => `**${item.question}**\\n\\n${item.answer}`).join(\"\\n\\n\")\n    case \"divider\":\n      return \"---\"\n  }\n}\n\nfunction block(item: FableBlock): string {\n  if (item.type === \"columns\") return item.columns.map((column) => column.blocks.map(content).join(\"\\n\\n\")).join(\"\\n\\n\")\n  if (item.type === \"section\") return [item.title ? `### ${item.title}` : \"\", ...item.blocks.map(content)].filter(Boolean).join(\"\\n\\n\")\n  if (item.type === \"tabs\") return item.tabs.map((tab) => [`### ${tab.label}`, ...tab.blocks.map(content)].join(\"\\n\\n\")).join(\"\\n\\n\")\n  return content(item)\n}\n\nexport function specToMarkdown(input: FableSpec | unknown): string {\n  const parsed = FableSpecSchema.safeParse(input)\n  if (!parsed.success) return \"\"\n  return parsed.data.blocks.map(block).filter(Boolean).join(\"\\n\\n\")\n}\n",
      "type": "registry:lib",
      "target": "components/fable-ui/to-markdown.ts"
    },
    {
      "path": "components/fable-ui/provider.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\n\nimport type { FableImagePolicy } from \"./safety\"\n\ntype Scalar = string | number | boolean | null\n\nexport interface FableHostAction {\n  /** Shown in the confirmation step, e.g. \"Send this email to 3 people?\" */\n  confirm?: string\n  /** Runs the side effect. Throw to show an error; return a string to show a success note. */\n  run: (payload: Record<string, Scalar>) => Promise<string | void> | string | void\n}\n\nexport interface FableConfig {\n  /** Sends a message as the user. Powers `reply` actions and form submits. */\n  onReply?: (message: string) => void\n  /** Side effects your app allows the model to request by name. */\n  actions?: Record<string, FableHostAction>\n  images?: FableImagePolicy\n  locale?: string\n  /** Disables every interactive control, e.g. while a response is streaming. */\n  readOnly?: boolean\n}\n\ninterface FableContextValue extends FableConfig {\n  store: Map<string, unknown>\n}\n\nconst FableContext = React.createContext<FableContextValue>({ store: new Map() })\nconst ScopeContext = React.createContext(\"fable\")\n\nexport function FableProvider({ children, ...config }: FableConfig & { children: React.ReactNode }) {\n  const [store] = React.useState(() => new Map<string, unknown>())\n  const { onReply, actions, images, locale, readOnly } = config\n  const value = React.useMemo(\n    () => ({ onReply, actions, images, locale, readOnly, store }),\n    [onReply, actions, images, locale, readOnly, store]\n  )\n  return <FableContext.Provider value={value}>{children}</FableContext.Provider>\n}\n\n/** Scopes widget state to one response (usually the tool call id). */\nexport function FableScope({ id, children }: { id: string; children: React.ReactNode }) {\n  // Changing a scope must switch the entire widget subtree to that scope's\n  // stored values. The keyed fragment remounts descendants when an embedding\n  // reuses the same component tree for a different surface id.\n  return (\n    <ScopeContext.Provider value={id}>\n      <React.Fragment key={id}>{children}</React.Fragment>\n    </ScopeContext.Provider>\n  )\n}\n\nexport function useFable() {\n  return React.useContext(FableContext)\n}\n\n/**\n * Like useState, but the value outlives remounts (tab switches, list\n * virtualization, re-renders of a streaming message) for this provider.\n */\nexport function useFableState<T>(key: string, initial: T | (() => T)) {\n  const { store } = useFable()\n  const scope = React.useContext(ScopeContext)\n  const fullKey = `${scope}:${key}`\n  const [value, setValue] = React.useState<T>(() =>\n    store.has(fullKey) ? (store.get(fullKey) as T) : typeof initial === \"function\" ? (initial as () => T)() : initial\n  )\n  const update = React.useCallback(\n    (next: React.SetStateAction<T>) => {\n      setValue((current) => {\n        const resolved = typeof next === \"function\" ? (next as (value: T) => T)(current) : next\n        store.set(fullKey, resolved)\n        return resolved\n      })\n    },\n    [store, fullKey]\n  )\n  return [value, update] as const\n}\n",
      "type": "registry:component",
      "target": "components/fable-ui/provider.tsx"
    },
    {
      "path": "components/fable-ui/renderer.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\n\nimport { Tabs, TabsContent, TabsList, TabsTrigger } from \"@/components/ui/tabs\"\nimport { TooltipProvider } from \"@/components/ui/tooltip\"\nimport { cn } from \"@/lib/utils\"\n\nimport { ActionsBlock } from \"./blocks/actions\"\nimport { ChartBlock } from \"./blocks/chart\"\nimport { ArticleBlock, ChecklistBlock, FaqBlock, FileBlock, ListBlock, SourcesBlock } from \"./blocks/content\"\nimport { DetailsBlock, MetricsBlock } from \"./blocks/data\"\nimport { EmailBlock, FormBlock, TemplateBlock } from \"./blocks/interactive\"\nimport { GalleryBlock, ImageBlock } from \"./blocks/media\"\nimport { enter, surface } from \"./blocks/shared\"\nimport { CardsBlock, HeroBlock } from \"./blocks/showcase\"\nimport { BlockSkeleton } from \"./blocks/skeleton\"\nimport { TableBlock } from \"./blocks/table\"\nimport { CalloutBlock, CodeBlock, DividerBlock, HeadingBlock, MarkdownBlock, QuoteBlock } from \"./blocks/text\"\nimport { FableScope, useFableState } from \"./provider\"\nimport { resolveSpec, type Resolved } from \"./resolve\"\nimport type { ContentBlock } from \"./schema\"\n\nexport interface FableRendererProps {\n  /** The spec, complete or partial. Validated here; never trusted as-is. */\n  spec: unknown\n  /** True while the tool input is still streaming. */\n  streaming?: boolean\n  /** Scopes widget state; use a stable surface or tool call id. */\n  id?: string\n  /** Show why a block was dropped. Off by default; enable in your host's development UI. */\n  debug?: boolean\n  className?: string\n}\n\n/** Keeps one broken block from taking the whole answer down. */\nclass BlockBoundary extends React.Component<{ children: React.ReactNode; debug?: boolean; type: string }, { failed: boolean }> {\n  state = { failed: false }\n  static getDerivedStateFromError() {\n    return { failed: true }\n  }\n  render() {\n    if (!this.state.failed) return this.props.children\n    return this.props.debug ? <Notice>{`The ${this.props.type} block failed to render.`}</Notice> : null\n  }\n}\n\nfunction Notice({ children }: { children: React.ReactNode }) {\n  return (\n    <p role=\"status\" className=\"rounded-lg border border-dashed border-border px-3 py-2 font-mono text-xs text-muted-foreground\">\n      {children}\n    </p>\n  )\n}\n\nfunction Content({ block, stateKey, open }: { block: ContentBlock; stateKey: string; open: boolean }) {\n  switch (block.type) {\n    case \"markdown\":\n      return <MarkdownBlock block={block} />\n    case \"heading\":\n      return <HeadingBlock block={block} />\n    case \"callout\":\n      return <CalloutBlock block={block} />\n    case \"metrics\":\n      return <MetricsBlock block={block} />\n    case \"table\":\n      return <TableBlock block={block} open={open} />\n    case \"chart\":\n      return <ChartBlock block={block} />\n    case \"details\":\n      return <DetailsBlock block={block} />\n    case \"list\":\n      return <ListBlock block={block} />\n    case \"checklist\":\n      return <ChecklistBlock block={block} />\n    case \"code\":\n      return <CodeBlock block={block} />\n    case \"quote\":\n      return <QuoteBlock block={block} />\n    case \"image\":\n      return <ImageBlock block={block} />\n    case \"gallery\":\n      return <GalleryBlock block={block} />\n    case \"cards\":\n      return <CardsBlock block={block} stateKey={stateKey} />\n    case \"hero\":\n      return <HeroBlock block={block} stateKey={stateKey} />\n    case \"article\":\n      return <ArticleBlock block={block} stateKey={stateKey} open={open} />\n    case \"form\":\n      return <FormBlock block={block} />\n    case \"template\":\n      return <TemplateBlock block={block} stateKey={stateKey} />\n    case \"email\":\n      return <EmailBlock block={block} stateKey={stateKey} />\n    case \"actions\":\n      return <ActionsBlock block={block} stateKey={stateKey} />\n    case \"file\":\n      return <FileBlock block={block} stateKey={stateKey} />\n    case \"sources\":\n      return <SourcesBlock block={block} />\n    case \"faq\":\n      return <FaqBlock block={block} />\n    case \"divider\":\n      return <DividerBlock block={block} />\n  }\n}\n\nconst RootScope = React.createContext(\"fable\")\n\n/** Gives each block its own state namespace inside the response. Keys are positional paths. */\nfunction BlockScope({ stateKey, children }: { stateKey: string; children: React.ReactNode }) {\n  const root = React.useContext(RootScope)\n  return <FableScope id={`${root}/${stateKey}`}>{children}</FableScope>\n}\n\nfunction TabsLayout({ item, debug }: { item: Extract<Resolved, { kind: \"tabs\" }>; debug?: boolean }) {\n  const [value, setValue] = useFableState(\"tab\", \"0\")\n  const active = Number(value) < item.tabs.length ? value : \"0\"\n  return (\n    <Tabs value={active} onValueChange={setValue} className=\"gap-4\">\n      <div className=\"-mx-1 overflow-x-auto px-1 pb-0.5\">\n        <TabsList>\n          {item.tabs.map((tab, index) => (\n            <TabsTrigger key={index} value={String(index)}>\n              {tab.label}\n            </TabsTrigger>\n          ))}\n        </TabsList>\n      </div>\n      {item.tabs.map((tab, index) => (\n        <TabsContent key={index} value={String(index)} className=\"space-y-5 outline-none\">\n          <Items items={tab.children} debug={debug} />\n        </TabsContent>\n      ))}\n    </Tabs>\n  )\n}\n\nfunction Node({ item, debug }: { item: Resolved; debug?: boolean }) {\n  switch (item.kind) {\n    case \"pending\":\n      return <BlockSkeleton type={item.type} />\n    case \"invalid\":\n      return debug ? <Notice>{`Skipped ${item.type ?? \"unknown\"} block — ${item.issue}`}</Notice> : null\n    case \"content\":\n      return (\n        <BlockBoundary debug={debug} type={item.block.type}>\n          <BlockScope stateKey={item.key}>\n            <div className={cn(\"@container min-w-0\", !item.open && enter)} data-fable-block={item.block.type}>\n              <Content block={item.block} stateKey={item.key} open={item.open} />\n            </div>\n          </BlockScope>\n        </BlockBoundary>\n      )\n    case \"columns\":\n      return (\n        <div\n          data-fable-block=\"columns\"\n          className={cn(\n            \"grid min-w-0 gap-5\",\n            item.columns.length === 3 && \"@2xl/fable:grid-cols-3\",\n            item.columns.length === 2 && item.ratio === \"equal\" && \"@2xl/fable:grid-cols-2\",\n            item.columns.length === 2 && item.ratio === \"wide-left\" && \"@2xl/fable:grid-cols-[minmax(0,1.6fr)_minmax(0,1fr)]\",\n            item.columns.length === 2 && item.ratio === \"wide-right\" && \"@2xl/fable:grid-cols-[minmax(0,1fr)_minmax(0,1.6fr)]\"\n          )}\n        >\n          {item.columns.map((column, index) => (\n            <div key={index} className=\"min-w-0 space-y-5\">\n              <Items items={column} debug={debug} />\n            </div>\n          ))}\n        </div>\n      )\n    case \"section\":\n      return (\n        <section\n          data-fable-block=\"section\"\n          aria-label={item.title}\n          className={cn(\n            \"min-w-0 space-y-4\",\n            item.variant === \"card\" && cn(surface, \"p-4 @lg/fable:p-6\"),\n            item.variant === \"muted\" && \"rounded-xl bg-muted/50 p-4 @lg/fable:p-6\"\n          )}\n        >\n          {item.title || item.description ? (\n            <header className=\"space-y-1\">\n              {item.title ? <h3 className=\"font-heading text-lg font-semibold tracking-tight text-balance\">{item.title}</h3> : null}\n              {item.description ? <p className=\"text-sm text-pretty text-muted-foreground\">{item.description}</p> : null}\n            </header>\n          ) : null}\n          <Items items={item.children} debug={debug} />\n        </section>\n      )\n    case \"tabs\":\n      return (\n        <BlockScope stateKey={item.key}>\n          <TabsLayout item={item} debug={debug} />\n        </BlockScope>\n      )\n  }\n}\n\nfunction Items({ items, debug }: { items: Resolved[]; debug?: boolean }) {\n  return items.map((item) => <Node key={item.key} item={item} debug={debug} />)\n}\n\n/**\n * Renders a Fable spec. Accepts partial input while streaming: finished\n * blocks render as they close, the open block streams or holds its space.\n */\nexport function FableRenderer({ spec, streaming = false, id, debug, className }: FableRendererProps) {\n  const instanceId = React.useId()\n  const rootId = id ?? `fable-${instanceId}`\n  const resolved = React.useMemo(() => resolveSpec(spec, streaming), [spec, streaming])\n  const showDebug = debug ?? false\n\n  return (\n    <TooltipProvider delayDuration={300}>\n      <RootScope.Provider value={rootId} key={rootId}>\n        <div\n          data-fable-ui=\"\"\n          data-streaming={streaming || undefined}\n          aria-busy={streaming || undefined}\n          className={cn(\"@container/fable flex min-w-0 flex-col gap-5 text-foreground\", className)}\n        >\n          <Items items={resolved.items} debug={showDebug} />\n        </div>\n      </RootScope.Provider>\n    </TooltipProvider>\n  )\n}\n",
      "type": "registry:component",
      "target": "components/fable-ui/renderer.tsx"
    },
    {
      "path": "components/fable-ui/tool-part.tsx",
      "content": "\"use client\"\n\nimport { AlertCircleIcon } from \"lucide-react\"\n\nimport { FableRenderer } from \"./renderer\"\nimport { FABLE_TOOL_NAME } from \"./protocol\"\n\n/** The subset of an AI SDK tool UI part that Fable reads. */\nexport interface FableToolPartLike {\n  type: string\n  toolCallId: string\n  state: string\n  input?: unknown\n  errorText?: string\n}\n\nexport function isFableToolPart(part: { type: string }, toolName = FABLE_TOOL_NAME): part is FableToolPartLike {\n  return part.type === `tool-${toolName}`\n}\n\n/**\n * Drop-in renderer for `tool-render_ui` parts from `useChat`:\n *\n *   message.parts.map((part) => isFableToolPart(part) ? <FableToolPart part={part} active={isActiveResponse} /> : …)\n */\nexport function FableToolPart({\n  part,\n  active = true,\n  debug,\n  className,\n}: {\n  part: FableToolPartLike\n  /**\n   * Whether the response is still streaming. Pass false once the chat is\n   * idle: a part left in \"input-streaming\" (stopped, cut off, network drop)\n   * then renders its finished blocks and drops the half-written one.\n   */\n  active?: boolean\n  debug?: boolean\n  className?: string\n}) {\n  if (part.state === \"output-error\" && !part.input) {\n    return (\n      <p role=\"alert\" className=\"flex items-center gap-2 text-sm text-muted-foreground\">\n        <AlertCircleIcon className=\"size-4\" aria-hidden />\n        This answer could not be displayed.\n      </p>\n    )\n  }\n  const interrupted = part.state === \"input-streaming\" && !active\n  return (\n    <>\n      <FableRenderer\n        id={part.toolCallId}\n        spec={part.input}\n        streaming={part.state === \"input-streaming\" && active}\n        debug={debug}\n        className={className}\n      />\n      {interrupted ? (\n        <p role=\"status\" className=\"mt-3 flex items-center gap-1.5 text-xs text-muted-foreground\">\n          <AlertCircleIcon className=\"size-3.5\" aria-hidden />\n          This answer stopped before it finished.\n        </p>\n      ) : null}\n    </>\n  )\n}\n",
      "type": "registry:component",
      "target": "components/fable-ui/tool-part.tsx"
    },
    {
      "path": "components/fable-ui/blocks/shared.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport {\n  ArrowRightIcon,\n  CalendarIcon,\n  CheckIcon,\n  CopyIcon,\n  DownloadIcon,\n  ExternalLinkIcon,\n  FileTextIcon,\n  HeartIcon,\n  InfoIcon,\n  MailIcon,\n  MapPinIcon,\n  PencilIcon,\n  PhoneIcon,\n  PlayIcon,\n  PlusIcon,\n  RefreshCwIcon,\n  SearchIcon,\n  SendIcon,\n  Share2Icon,\n  SparklesIcon,\n  StarIcon,\n  type LucideIcon,\n} from \"lucide-react\"\n\nimport { Button } from \"@/components/ui/button\"\nimport { Tooltip, TooltipContent, TooltipTrigger } from \"@/components/ui/tooltip\"\nimport { cn } from \"@/lib/utils\"\n\nimport type { FABLE_ICONS } from \"../schema\"\n\nexport const ICONS: Record<(typeof FABLE_ICONS)[number], LucideIcon> = {\n  \"arrow-right\": ArrowRightIcon,\n  calendar: CalendarIcon,\n  check: CheckIcon,\n  copy: CopyIcon,\n  download: DownloadIcon,\n  edit: PencilIcon,\n  \"external-link\": ExternalLinkIcon,\n  file: FileTextIcon,\n  heart: HeartIcon,\n  info: InfoIcon,\n  mail: MailIcon,\n  \"map-pin\": MapPinIcon,\n  phone: PhoneIcon,\n  play: PlayIcon,\n  plus: PlusIcon,\n  refresh: RefreshCwIcon,\n  search: SearchIcon,\n  send: SendIcon,\n  share: Share2Icon,\n  sparkles: SparklesIcon,\n  star: StarIcon,\n}\n\n/**\n * The one surface every framed block uses. A hairline ring plus a soft\n * shadow reads as depth on any background, in any preset.\n */\nexport const surface =\n  \"rounded-xl bg-card text-card-foreground ring-1 ring-foreground/[0.07] shadow-[0_1px_2px_rgb(0_0_0/0.04),0_4px_16px_-8px_rgb(0_0_0/0.08)] dark:ring-foreground/10 dark:shadow-none\"\n\n/** Image edge: pure black/white at 10%, never a tinted neutral. */\nexport const imageOutline =\n  \"outline outline-1 -outline-offset-1 outline-black/10 dark:outline-white/10\"\n\nexport const enter =\n  \"motion-safe:animate-in motion-safe:fade-in-0 motion-safe:slide-in-from-bottom-1 motion-safe:duration-300 motion-safe:ease-out\"\n\nexport function BlockHeader({\n  title,\n  description,\n  actions,\n  className,\n}: {\n  title?: React.ReactNode\n  description?: React.ReactNode\n  actions?: React.ReactNode\n  className?: string\n}) {\n  if (!title && !description && !actions) return null\n  return (\n    <div className={cn(\"flex items-start justify-between gap-3\", className)}>\n      <div className=\"min-w-0 space-y-0.5\">\n        {title ? (\n          <h3 className=\"font-heading text-[0.9375rem] leading-6 font-semibold tracking-tight text-balance text-foreground\">\n            {title}\n          </h3>\n        ) : null}\n        {description ? (\n          <p className=\"text-sm leading-5 text-pretty text-muted-foreground\">{description}</p>\n        ) : null}\n      </div>\n      {actions ? <div className=\"-me-1 -mt-0.5 flex shrink-0 items-center gap-0.5\">{actions}</div> : null}\n    </div>\n  )\n}\n\nexport function useCopy(timeout = 1600) {\n  const [copied, setCopied] = React.useState(false)\n  const timer = React.useRef<ReturnType<typeof setTimeout>>(undefined)\n  React.useEffect(() => () => clearTimeout(timer.current), [])\n  const copy = React.useCallback(\n    async (text: string) => {\n      try {\n        await navigator.clipboard.writeText(text)\n        setCopied(true)\n        clearTimeout(timer.current)\n        timer.current = setTimeout(() => setCopied(false), timeout)\n        return true\n      } catch {\n        return false\n      }\n    },\n    [timeout]\n  )\n  return { copied, copy }\n}\n\n/** Two icons stay mounted and cross-fade, so the swap has an enter and an exit. */\nexport function SwapIcon({ swapped, from, to }: { swapped: boolean; from: LucideIcon; to: LucideIcon }) {\n  const From = from\n  const To = to\n  const transition = \"transition-[opacity,scale,filter] duration-200 ease-[cubic-bezier(0.2,0,0,1)]\"\n  return (\n    <span className=\"relative inline-grid size-4 place-items-center\" aria-hidden>\n      <From className={cn(\"col-start-1 row-start-1 size-4\", transition, swapped && \"scale-25 opacity-0 blur-[4px]\")} />\n      <To className={cn(\"col-start-1 row-start-1 size-4\", transition, !swapped && \"scale-25 opacity-0 blur-[4px]\")} />\n    </span>\n  )\n}\n\nexport function IconAction({\n  label,\n  onClick,\n  children,\n  disabled,\n}: {\n  label: string\n  onClick: () => void\n  children: React.ReactNode\n  disabled?: boolean\n}) {\n  return (\n    <Tooltip>\n      <TooltipTrigger asChild>\n        <Button\n          type=\"button\"\n          variant=\"ghost\"\n          size=\"icon-sm\"\n          aria-label={label}\n          disabled={disabled}\n          onClick={onClick}\n          className=\"text-muted-foreground hover:text-foreground\"\n        >\n          {children}\n        </Button>\n      </TooltipTrigger>\n      <TooltipContent>{label}</TooltipContent>\n    </Tooltip>\n  )\n}\n\nexport function CopyAction({ text, label = \"Copy\" }: { text: string; label?: string }) {\n  const { copied, copy } = useCopy()\n  return (\n    <IconAction label={copied ? \"Copied\" : label} onClick={() => void copy(text)}>\n      <SwapIcon swapped={copied} from={CopyIcon} to={CheckIcon} />\n    </IconAction>\n  )\n}\n\n/** Polite live region for confirmations that have no visible change. */\nexport function useAnnounce() {\n  const [message, setMessage] = React.useState(\"\")\n  const node = (\n    <span className=\"sr-only\" role=\"status\" aria-live=\"polite\">\n      {message}\n    </span>\n  )\n  return { announce: setMessage, node }\n}\n",
      "type": "registry:component",
      "target": "components/fable-ui/blocks/shared.tsx"
    },
    {
      "path": "components/fable-ui/blocks/prose.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport Markdown, { type Components } from \"react-markdown\"\nimport remarkGfm from \"remark-gfm\"\n\nimport { cn } from \"@/lib/utils\"\n\nimport { safeLinkUrl } from \"../safety\"\n\nconst components: Components = {\n  h1: ({ children }) => (\n    <h2 className=\"mt-8 mb-3 font-heading text-2xl font-semibold tracking-tight text-balance first:mt-0\">{children}</h2>\n  ),\n  h2: ({ children }) => (\n    <h3 className=\"mt-7 mb-2.5 font-heading text-xl font-semibold tracking-tight text-balance first:mt-0\">{children}</h3>\n  ),\n  h3: ({ children }) => (\n    <h4 className=\"mt-6 mb-2 font-heading text-base font-semibold tracking-tight text-balance first:mt-0\">{children}</h4>\n  ),\n  h4: ({ children }) => <h5 className=\"mt-5 mb-2 text-sm font-semibold first:mt-0\">{children}</h5>,\n  p: ({ children }) => <p className=\"my-3 leading-7 text-pretty first:mt-0 last:mb-0\">{children}</p>,\n  a: ({ href, children }) => {\n    const safe = safeLinkUrl(href)\n    if (!safe) return <span>{children}</span>\n    return (\n      <a\n        href={safe}\n        target=\"_blank\"\n        rel=\"noopener noreferrer nofollow\"\n        className=\"font-medium text-foreground underline decoration-foreground/25 underline-offset-[3px] transition-[text-decoration-color] hover:decoration-foreground\"\n      >\n        {children}\n      </a>\n    )\n  },\n  ul: ({ children }) => (\n    <ul className=\"my-3 list-disc space-y-1.5 ps-5 marker:text-muted-foreground/70 first:mt-0 last:mb-0\">{children}</ul>\n  ),\n  ol: ({ children }) => (\n    <ol className=\"my-3 list-decimal space-y-1.5 ps-5 marker:text-muted-foreground marker:tabular-nums first:mt-0 last:mb-0\">\n      {children}\n    </ol>\n  ),\n  li: ({ children }) => <li className=\"ps-1 leading-7 [&>ol]:my-1.5 [&>ul]:my-1.5\">{children}</li>,\n  blockquote: ({ children }) => (\n    <blockquote className=\"my-4 border-s-2 border-foreground/15 ps-4 text-muted-foreground italic\">{children}</blockquote>\n  ),\n  hr: () => <hr className=\"my-6 border-border\" />,\n  strong: ({ children }) => <strong className=\"font-semibold text-foreground\">{children}</strong>,\n  code: ({ className, children }) => {\n    const block = /language-/.test(className ?? \"\") || String(children).includes(\"\\n\")\n    if (block) return <code className=\"font-mono\">{children}</code>\n    return (\n      <code className=\"rounded-md bg-muted px-[0.35em] py-[0.15em] font-mono text-[0.85em] text-foreground\">\n        {children}\n      </code>\n    )\n  },\n  pre: ({ children }) => (\n    <pre className=\"my-4 overflow-x-auto rounded-lg bg-muted/60 p-4 font-mono text-[0.8125rem] leading-6 ring-1 ring-border/60\">\n      {children}\n    </pre>\n  ),\n  table: ({ children }) => (\n    <div className=\"my-4 overflow-x-auto rounded-lg ring-1 ring-border\">\n      <table className=\"w-full border-collapse text-sm\">{children}</table>\n    </div>\n  ),\n  thead: ({ children }) => <thead className=\"bg-muted/50\">{children}</thead>,\n  th: ({ children }) => (\n    <th className=\"border-b border-border px-3 py-2 text-start text-xs font-medium text-muted-foreground\">{children}</th>\n  ),\n  td: ({ children }) => <td className=\"border-b border-border/60 px-3 py-2 align-top tabular-nums\">{children}</td>,\n  img: () => null,\n}\n\n/**\n * Markdown with GitHub extensions. Raw HTML is skipped, images are dropped\n * (use image blocks, which go through the image policy), and links pass\n * the URL policy.\n */\nexport function Prose({ children, className }: { children: string; className?: string }) {\n  return (\n    <div className={cn(\"min-w-0 text-[0.9375rem] text-foreground/90 [overflow-wrap:anywhere]\", className)}>\n      <Markdown\n        remarkPlugins={[remarkGfm]}\n        components={components}\n        skipHtml\n        urlTransform={(url) => safeLinkUrl(url) ?? \"\"}\n      >\n        {children}\n      </Markdown>\n    </div>\n  )\n}\n\nexport const MemoProse = React.memo(Prose)\n",
      "type": "registry:component",
      "target": "components/fable-ui/blocks/prose.tsx"
    },
    {
      "path": "components/fable-ui/blocks/text.tsx",
      "content": "\"use client\"\n\nimport {\n  AlertTriangleIcon,\n  CheckCircle2Icon,\n  InfoIcon,\n  LightbulbIcon,\n  OctagonAlertIcon,\n  type LucideIcon,\n} from \"lucide-react\"\n\nimport { cn } from \"@/lib/utils\"\n\nimport type { BlockOf } from \"../schema\"\nimport { MemoProse } from \"./prose\"\nimport { CopyAction } from \"./shared\"\n\nexport function MarkdownBlock({ block }: { block: BlockOf<\"markdown\"> }) {\n  return <MemoProse>{block.text}</MemoProse>\n}\n\nexport function HeadingBlock({ block }: { block: BlockOf<\"heading\"> }) {\n  const level = block.level ?? 2\n  const Tag = level === 1 ? \"h1\" : level === 2 ? \"h2\" : \"h3\"\n  return (\n    <header className=\"space-y-1.5\">\n      {block.eyebrow ? (\n        <p className=\"text-xs font-medium tracking-[0.08em] text-muted-foreground uppercase\">{block.eyebrow}</p>\n      ) : null}\n      <Tag\n        className={cn(\n          \"font-heading font-semibold tracking-tight text-balance text-foreground\",\n          level === 1 && \"text-[1.75rem] leading-tight @lg:text-[2rem]\",\n          level === 2 && \"text-xl leading-snug @lg:text-[1.375rem]\",\n          level === 3 && \"text-base leading-snug\"\n        )}\n      >\n        {block.text}\n      </Tag>\n      {block.description ? (\n        <p className=\"max-w-[62ch] text-[0.9375rem] leading-relaxed text-pretty text-muted-foreground\">\n          {block.description}\n        </p>\n      ) : null}\n    </header>\n  )\n}\n\nconst calloutTones: Record<BlockOf<\"callout\">[\"tone\"], { icon: LucideIcon; className: string; iconClass: string }> = {\n  info: { icon: InfoIcon, className: \"bg-sky-500/[0.06] ring-sky-500/20\", iconClass: \"text-sky-600 dark:text-sky-400\" },\n  tip: { icon: LightbulbIcon, className: \"bg-primary/[0.04] ring-primary/15\", iconClass: \"text-primary\" },\n  success: {\n    icon: CheckCircle2Icon,\n    className: \"bg-emerald-500/[0.06] ring-emerald-500/20\",\n    iconClass: \"text-emerald-600 dark:text-emerald-400\",\n  },\n  warning: {\n    icon: AlertTriangleIcon,\n    className: \"bg-amber-500/[0.08] ring-amber-500/25\",\n    iconClass: \"text-amber-600 dark:text-amber-400\",\n  },\n  danger: {\n    icon: OctagonAlertIcon,\n    className: \"bg-destructive/[0.06] ring-destructive/20\",\n    iconClass: \"text-destructive\",\n  },\n}\n\nexport function CalloutBlock({ block }: { block: BlockOf<\"callout\"> }) {\n  const tone = calloutTones[block.tone]\n  const Icon = tone.icon\n  return (\n    <aside\n      role={block.tone === \"danger\" || block.tone === \"warning\" ? \"note\" : undefined}\n      className={cn(\"flex gap-3 rounded-xl px-4 py-3.5 ring-1\", tone.className)}\n    >\n      <Icon className={cn(\"mt-1 size-4 shrink-0\", tone.iconClass)} aria-hidden />\n      <div className=\"min-w-0 flex-1 space-y-0.5\">\n        {block.title ? <p className=\"text-sm leading-6 font-semibold\">{block.title}</p> : null}\n        <MemoProse className=\"text-sm [&_p]:leading-6\">{block.text}</MemoProse>\n      </div>\n    </aside>\n  )\n}\n\nexport function QuoteBlock({ block }: { block: BlockOf<\"quote\"> }) {\n  return (\n    <figure className=\"relative py-1 ps-6\">\n      <span aria-hidden className=\"absolute inset-y-1 start-0 w-[3px] rounded-full bg-primary/70\" />\n      <blockquote className=\"font-heading text-lg leading-relaxed font-medium tracking-tight text-pretty text-foreground @lg:text-xl\">\n        “{block.text}”\n      </blockquote>\n      {block.author || block.source ? (\n        <figcaption className=\"mt-2.5 text-sm text-muted-foreground\">\n          {block.author ? <span className=\"font-medium text-foreground\">{block.author}</span> : null}\n          {block.author && block.source ? <span aria-hidden> · </span> : null}\n          {block.source ? <cite className=\"not-italic\">{block.source}</cite> : null}\n        </figcaption>\n      ) : null}\n    </figure>\n  )\n}\n\nexport function CodeBlock({ block }: { block: BlockOf<\"code\"> }) {\n  const label = block.filename ?? block.language\n  return (\n    <figure className=\"overflow-hidden rounded-xl bg-muted/50 ring-1 ring-border/70\">\n      <figcaption className=\"flex h-10 items-center justify-between gap-2 border-b border-border/70 ps-4 pe-1.5\">\n        <span className=\"truncate font-mono text-xs text-muted-foreground\">{label ?? \"code\"}</span>\n        <CopyAction text={block.code} label=\"Copy code\" />\n      </figcaption>\n      <pre\n        tabIndex={0}\n        aria-label={label ? `${label} code` : \"Code\"}\n        className=\"max-h-[28rem] overflow-auto p-4 font-mono text-[0.8125rem] leading-6 outline-none focus-visible:ring-2 focus-visible:ring-ring/40 focus-visible:ring-inset\"\n      >\n        <code>{block.code}</code>\n      </pre>\n    </figure>\n  )\n}\n\nexport function DividerBlock({ block }: { block: BlockOf<\"divider\"> }) {\n  if (!block.label) return <hr className=\"border-border\" />\n  return (\n    <div role=\"separator\" aria-label={block.label} className=\"flex items-center gap-3\">\n      <span className=\"h-px flex-1 bg-border\" />\n      <span className=\"text-xs font-medium tracking-[0.08em] text-muted-foreground uppercase\">{block.label}</span>\n      <span className=\"h-px flex-1 bg-border\" />\n    </div>\n  )\n}\n",
      "type": "registry:component",
      "target": "components/fable-ui/blocks/text.tsx"
    },
    {
      "path": "components/fable-ui/blocks/data.tsx",
      "content": "\"use client\"\n\nimport { ArrowDownRightIcon, ArrowUpRightIcon, MinusIcon } from \"lucide-react\"\n\nimport { cn } from \"@/lib/utils\"\n\nimport { formatDelta, formatValue } from \"../format\"\nimport { useFable } from \"../provider\"\nimport type { BlockOf } from \"../schema\"\nimport { BlockHeader, surface } from \"./shared\"\n\nexport function MetricsBlock({ block }: { block: BlockOf<\"metrics\"> }) {\n  const { locale } = useFable()\n  const count = block.items.length\n  return (\n    <dl\n      className={cn(\n        surface,\n        \"grid overflow-hidden\",\n        count === 1 && \"grid-cols-1\",\n        count === 2 && \"grid-cols-2\",\n        count === 3 && \"grid-cols-1 @lg:grid-cols-3\",\n        count >= 4 && \"grid-cols-2 @xl:grid-cols-4\"\n      )}\n    >\n      {block.items.map((item, index) => {\n        const delta = item.delta\n        const good = delta === undefined || delta === 0 ? null : (delta > 0) !== Boolean(item.invertDelta)\n        const DeltaIcon = !delta ? MinusIcon : delta > 0 ? ArrowUpRightIcon : ArrowDownRightIcon\n        return (\n          <div\n            key={index}\n            className=\"relative flex min-w-0 flex-col gap-1.5 p-4 shadow-[inset_1px_0_0_var(--color-border),inset_0_1px_0_var(--color-border)] @lg:p-5\"\n          >\n            <dt className=\"truncate text-[0.8125rem] text-muted-foreground\">{item.label}</dt>\n            <dd className=\"font-heading text-2xl leading-none font-semibold tracking-tight tabular-nums @lg:text-[1.75rem]\">\n              {typeof item.value === \"number\"\n                ? formatValue(item.value, { format: item.format, currency: item.currency, locale })\n                : item.value}\n            </dd>\n            {delta !== undefined || item.hint ? (\n              <dd className=\"flex flex-wrap items-center gap-x-1.5 gap-y-0.5 text-xs\">\n                {delta !== undefined ? (\n                  <span\n                    className={cn(\n                      \"inline-flex items-center gap-0.5 rounded-md px-1 py-0.5 font-medium tabular-nums\",\n                      good === true && \"bg-emerald-500/10 text-emerald-700 dark:text-emerald-300\",\n                      good === false && \"bg-destructive/10 text-destructive\",\n                      good === null && \"bg-muted text-muted-foreground\"\n                    )}\n                  >\n                    <DeltaIcon className=\"size-3\" aria-hidden />\n                    {formatDelta(delta, locale)}\n                  </span>\n                ) : null}\n                {item.deltaLabel ? <span className=\"text-muted-foreground\">{item.deltaLabel}</span> : null}\n                {item.hint && delta === undefined ? <span className=\"text-muted-foreground\">{item.hint}</span> : null}\n              </dd>\n            ) : null}\n          </div>\n        )\n      })}\n    </dl>\n  )\n}\n\nconst toneClass = {\n  neutral: \"\",\n  info: \"text-sky-700 dark:text-sky-300\",\n  success: \"text-emerald-700 dark:text-emerald-300\",\n  warning: \"text-amber-700 dark:text-amber-300\",\n  danger: \"text-destructive\",\n}\n\nexport function DetailsBlock({ block }: { block: BlockOf<\"details\"> }) {\n  const twoColumns = (block.columns ?? (block.items.length > 6 ? 2 : 1)) === 2\n  return (\n    <section className={cn(surface, \"p-4 @lg:p-5\")} aria-label={block.title ?? \"Details\"}>\n      <BlockHeader title={block.title} className=\"mb-3\" />\n      <dl className={cn(\"grid gap-x-8\", twoColumns && \"@lg:grid-cols-2\")}>\n        {block.items.map((item, index) => (\n          <div\n            key={index}\n            className=\"flex items-baseline justify-between gap-4 border-b border-dashed border-border py-2.5 last:border-b-0\"\n          >\n            <dt className=\"shrink-0 text-sm text-muted-foreground\">{item.label}</dt>\n            <dd className={cn(\"min-w-0 text-end text-sm font-medium text-pretty tabular-nums\", toneClass[item.tone ?? \"neutral\"])}>\n              {item.value}\n            </dd>\n          </div>\n        ))}\n      </dl>\n    </section>\n  )\n}\n",
      "type": "registry:component",
      "target": "components/fable-ui/blocks/data.tsx"
    },
    {
      "path": "components/fable-ui/blocks/table.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { ArrowDownIcon, ArrowUpDownIcon, ArrowUpIcon, DownloadIcon, SearchIcon } from \"lucide-react\"\n\nimport { Badge } from \"@/components/ui/badge\"\nimport { Button } from \"@/components/ui/button\"\nimport { cn } from \"@/lib/utils\"\n\nimport { formatDate, formatValue } from \"../format\"\nimport { useFable, useFableState } from \"../provider\"\nimport { downloadText, hostLabel, safeLinkUrl, toCsv } from \"../safety\"\nimport type { BlockOf } from \"../schema\"\nimport { BlockHeader, CopyAction, IconAction, surface } from \"./shared\"\n\ntype Column = BlockOf<\"table\">[\"columns\"][number]\ntype Row = BlockOf<\"table\">[\"rows\"][number]\n\nconst NUMERIC = new Set([\"number\", \"currency\", \"percent\"])\nconst PAGE = 12\n\nconst positive = /^(active|paid|done|complete|completed|approved|live|shipped|yes|success|healthy|on track|delivered|in stock|open)$/i\nconst negative = /^(failed|overdue|blocked|declined|cancelled|canceled|error|no|churned|at risk|out of stock|critical|rejected)$/i\nconst caution = /^(pending|draft|in progress|review|scheduled|paused|waiting|low stock|trial|medium)$/i\n\nfunction badgeTone(value: string) {\n  if (positive.test(value)) return \"bg-emerald-500/10 text-emerald-700 ring-emerald-500/20 dark:text-emerald-300\"\n  if (negative.test(value)) return \"bg-destructive/10 text-destructive ring-destructive/20\"\n  if (caution.test(value)) return \"bg-amber-500/10 text-amber-700 ring-amber-500/25 dark:text-amber-300\"\n  return \"bg-muted text-muted-foreground ring-border\"\n}\n\nfunction Cell({ column, value, locale }: { column: Column; value: Row[string]; locale?: string }) {\n  const type = column.type ?? (typeof value === \"number\" ? \"number\" : \"text\")\n  if (value === null || value === undefined || value === \"\") return <span className=\"text-muted-foreground/60\">—</span>\n  if (type === \"badge\") {\n    return (\n      <Badge variant=\"outline\" className={cn(\"border-0 font-medium ring-1 ring-inset\", badgeTone(String(value)))}>\n        {String(value)}\n      </Badge>\n    )\n  }\n  if (type === \"link\") {\n    const href = safeLinkUrl(String(value))\n    if (!href) return <span>{String(value)}</span>\n    return (\n      <a\n        href={href}\n        target=\"_blank\"\n        rel=\"noopener noreferrer nofollow\"\n        className=\"font-medium underline decoration-foreground/25 underline-offset-[3px] hover:decoration-foreground\"\n      >\n        {hostLabel(href)}\n      </a>\n    )\n  }\n  if (type === \"date\") return <span className=\"whitespace-nowrap\">{formatDate(value, locale)}</span>\n  if (NUMERIC.has(type) && typeof value === \"number\") {\n    return (\n      <span className=\"tabular-nums\">\n        {formatValue(value, { format: type as \"number\", currency: column.currency, locale })}\n      </span>\n    )\n  }\n  return <span>{formatValue(value)}</span>\n}\n\nfunction compare(a: Row[string], b: Row[string]) {\n  if (a === b) return 0\n  if (a === null || a === undefined || a === \"\") return 1\n  if (b === null || b === undefined || b === \"\") return -1\n  if (typeof a === \"number\" && typeof b === \"number\") return a - b\n  const dateA = Date.parse(String(a))\n  const dateB = Date.parse(String(b))\n  if (/^\\d{4}-\\d{2}/.test(String(a)) && !Number.isNaN(dateA) && !Number.isNaN(dateB)) return dateA - dateB\n  return String(a).localeCompare(String(b), undefined, { numeric: true, sensitivity: \"base\" })\n}\n\nexport function TableBlock({ block, open }: { block: BlockOf<\"table\">; open?: boolean }) {\n  const { locale } = useFable()\n  const [sort, setSort] = useFableState<{ key: string; dir: \"asc\" | \"desc\" } | null>(\"sort\", null)\n  const [query, setQuery] = useFableState(\"query\", \"\")\n  const [limit, setLimit] = useFableState(\"limit\", PAGE)\n  const searchId = React.useId()\n  const scrollHintId = React.useId()\n  const scroller = React.useRef<HTMLDivElement>(null)\n  const [overflow, setOverflow] = React.useState({ horizontal: false, vertical: false })\n\n  React.useEffect(() => {\n    const node = scroller.current\n    if (!node) return\n    const measure = () => {\n      const horizontal = node.scrollWidth > node.clientWidth\n      const vertical = node.scrollHeight > node.clientHeight\n      setOverflow((current) =>\n        current.horizontal === horizontal && current.vertical === vertical ? current : { horizontal, vertical }\n      )\n    }\n    measure()\n    const observer = typeof ResizeObserver === \"undefined\" ? null : new ResizeObserver(measure)\n    observer?.observe(node)\n    if (node.firstElementChild) observer?.observe(node.firstElementChild)\n    window.addEventListener(\"resize\", measure)\n    return () => {\n      observer?.disconnect()\n      window.removeEventListener(\"resize\", measure)\n    }\n  }, [])\n\n  const scrollable = overflow.horizontal || overflow.vertical\n\n  const sortable = block.sortable !== false && !open\n  const searchable = (block.searchable ?? block.rows.length > 10) && !open\n\n  const rows = React.useMemo(() => {\n    let result = block.rows\n    const needle = query.trim().toLowerCase()\n    if (needle) {\n      result = result.filter((row) =>\n        block.columns.some((column) => String(row[column.key] ?? \"\").toLowerCase().includes(needle))\n      )\n    }\n    if (sort) {\n      result = [...result].sort((a, b) => compare(a[sort.key], b[sort.key]) * (sort.dir === \"asc\" ? 1 : -1))\n    }\n    return result\n  }, [block.rows, block.columns, query, sort])\n\n  const visible = open ? rows : rows.slice(0, limit)\n  const csv = () => toCsv(block.columns, block.rows)\n  const filename = (block.title ?? \"table\").toLowerCase().replace(/[^a-z0-9]+/g, \"-\")\n\n  const toggleSort = (key: string) =>\n    setSort((current) =>\n      current?.key !== key ? { key, dir: \"asc\" } : current.dir === \"asc\" ? { key, dir: \"desc\" } : null\n    )\n\n  return (\n    <section className={cn(surface, \"overflow-hidden\")} aria-label={block.title ?? \"Table\"}>\n      {block.title || block.description || block.downloadable !== false || searchable ? (\n        <div className=\"space-y-3 px-4 pt-3.5 pb-3\">\n          <BlockHeader\n            title={block.title}\n            description={block.description}\n            actions={\n              open ? null : (\n                <>\n                  <CopyAction text={csv()} label=\"Copy as CSV\" />\n                  {block.downloadable !== false ? (\n                    <IconAction label=\"Download CSV\" onClick={() => downloadText(filename, csv(), \"text/csv\")}>\n                      <DownloadIcon className=\"size-4\" />\n                    </IconAction>\n                  ) : null}\n                </>\n              )\n            }\n          />\n          {searchable ? (\n            <div className=\"relative\">\n              <label htmlFor={searchId} className=\"sr-only\">\n                Search {block.title ?? \"table\"}\n              </label>\n              <SearchIcon className=\"pointer-events-none absolute start-2.5 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground\" />\n              <input\n                id={searchId}\n                type=\"search\"\n                value={query}\n                onChange={(event) => {\n                  setQuery(event.target.value)\n                  setLimit(PAGE)\n                }}\n                placeholder={`Search ${block.rows.length} rows`}\n                className=\"h-8 w-full rounded-lg bg-muted/60 ps-8 pe-3 text-sm outline-none placeholder:text-muted-foreground focus-visible:ring-2 focus-visible:ring-ring/40 @lg:max-w-64\"\n              />\n            </div>\n          ) : null}\n        </div>\n      ) : null}\n\n      {overflow.horizontal ? (\n        <p id={scrollHintId} className=\"border-t border-border/60 px-4 py-2 text-xs text-muted-foreground\">\n          Scroll horizontally to see all columns. Use the arrow keys when the table is focused.\n        </p>\n      ) : null}\n      <div\n        ref={scroller}\n        className=\"max-h-[34rem] overflow-auto overscroll-x-contain focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring\"\n        role={scrollable ? \"region\" : undefined}\n        aria-label={scrollable ? `${block.title ?? \"Table\"} scroll area` : undefined}\n        aria-describedby={overflow.horizontal ? scrollHintId : undefined}\n        tabIndex={scrollable ? 0 : undefined}\n      >\n        <table className=\"w-full border-separate border-spacing-0 text-sm\">\n          <thead className=\"sticky top-0 z-10 bg-card\">\n            <tr>\n              {block.columns.map((column, index) => {\n                const numeric = NUMERIC.has(column.type ?? \"\")\n                const align = column.align ?? (numeric ? \"end\" : \"start\")\n                const active = sort?.key === column.key\n                return (\n                  <th\n                    key={column.key}\n                    scope=\"col\"\n                    aria-sort={active ? (sort.dir === \"asc\" ? \"ascending\" : \"descending\") : undefined}\n                    className={cn(\n                      \"h-9 border-y border-border bg-muted/40 px-4 text-xs font-medium whitespace-nowrap text-muted-foreground\",\n                      align === \"end\" && \"text-end\",\n                      align === \"center\" && \"text-center\",\n                      align === \"start\" && \"text-start\",\n                      index === 0 && \"sticky start-0 z-10 bg-[color-mix(in_oklab,var(--card),var(--muted)_40%)]\"\n                    )}\n                  >\n                    {sortable ? (\n                      <button\n                        type=\"button\"\n                        onClick={() => toggleSort(column.key)}\n                        className={cn(\n                          \"-mx-1.5 inline-flex items-center gap-1 rounded-md px-1.5 py-1 transition-colors outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/40\",\n                          align === \"end\" && \"flex-row-reverse\",\n                          active && \"text-foreground\"\n                        )}\n                      >\n                        {column.label}\n                        {active ? (\n                          sort.dir === \"asc\" ? (\n                            <ArrowUpIcon className=\"size-3\" aria-hidden />\n                          ) : (\n                            <ArrowDownIcon className=\"size-3\" aria-hidden />\n                          )\n                        ) : (\n                          <ArrowUpDownIcon className=\"size-3 opacity-40\" aria-hidden />\n                        )}\n                      </button>\n                    ) : (\n                      column.label\n                    )}\n                  </th>\n                )\n              })}\n            </tr>\n          </thead>\n          <tbody>\n            {visible.map((row, rowIndex) => (\n              <tr key={rowIndex} className=\"group/row\">\n                {block.columns.map((column, index) => {\n                  const numeric = NUMERIC.has(column.type ?? \"\")\n                  const align = column.align ?? (numeric ? \"end\" : \"start\")\n                  return (\n                    <td\n                      key={column.key}\n                      className={cn(\n                        \"border-b border-border/60 px-4 py-2.5 align-middle transition-colors group-last/row:border-b-0 group-hover/row:bg-muted/40\",\n                        align === \"end\" && \"text-end\",\n                        align === \"center\" && \"text-center\",\n                        index === 0 && \"sticky start-0 bg-card font-medium text-foreground group-hover/row:bg-[color-mix(in_oklab,var(--card),var(--muted)_40%)]\"\n                      )}\n                    >\n                      <Cell column={column} value={row[column.key]} locale={locale} />\n                    </td>\n                  )\n                })}\n              </tr>\n            ))}\n            {visible.length === 0 && !open ? (\n              <tr>\n                <td colSpan={block.columns.length} className=\"px-4 py-8 text-center text-sm text-muted-foreground\">\n                  {query ? `No rows match “${query}”.` : \"No rows.\"}\n                </td>\n              </tr>\n            ) : null}\n          </tbody>\n          {block.footer && !open ? (\n            <tfoot>\n              <tr>\n                {block.columns.map((column, index) => {\n                  const numeric = NUMERIC.has(column.type ?? \"\")\n                  return (\n                    <td\n                      key={column.key}\n                      className={cn(\n                        \"border-t border-border bg-muted/30 px-4 py-2.5 font-semibold\",\n                        (column.align ?? (numeric ? \"end\" : \"start\")) === \"end\" && \"text-end\",\n                        index === 0 && \"sticky start-0 bg-[color-mix(in_oklab,var(--card),var(--muted)_30%)]\"\n                      )}\n                    >\n                      {block.footer?.[column.key] !== undefined ? (\n                        <Cell column={column} value={block.footer[column.key]} locale={locale} />\n                      ) : null}\n                    </td>\n                  )\n                })}\n              </tr>\n            </tfoot>\n          ) : null}\n        </table>\n      </div>\n\n      {!open && rows.length > visible.length ? (\n        <div className=\"flex items-center justify-between gap-3 border-t border-border/60 px-4 py-2\">\n          <span className=\"text-xs text-muted-foreground tabular-nums\">\n            {visible.length} of {rows.length} rows\n          </span>\n          <Button variant=\"ghost\" size=\"sm\" onClick={() => setLimit((value) => value + PAGE * 2)}>\n            Show more\n          </Button>\n        </div>\n      ) : null}\n    </section>\n  )\n}\n",
      "type": "registry:component",
      "target": "components/fable-ui/blocks/table.tsx"
    },
    {
      "path": "components/fable-ui/blocks/chart.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { ChartColumnIcon, TableIcon } from \"lucide-react\"\nimport {\n  Area,\n  AreaChart,\n  Bar,\n  BarChart,\n  CartesianGrid,\n  Cell,\n  Line,\n  LineChart,\n  Pie,\n  PieChart,\n  XAxis,\n  YAxis,\n} from \"recharts\"\n\nimport { ChartContainer, ChartTooltip, type ChartConfig } from \"@/components/ui/chart\"\nimport { cn } from \"@/lib/utils\"\n\nimport { formatNumber, type FormatOptions } from \"../format\"\nimport { useFable, useFableState } from \"../provider\"\nimport type { BlockOf } from \"../schema\"\nimport { BlockHeader, IconAction, SwapIcon, surface } from \"./shared\"\n\ntype TooltipEntry = { name?: string | number; value?: unknown; color?: string; dataKey?: string | number; payload?: Record<string, unknown> }\n\nfunction ChartTip({\n  active,\n  payload,\n  label,\n  config,\n  format,\n}: {\n  active?: boolean\n  payload?: TooltipEntry[]\n  label?: unknown\n  config: ChartConfig\n  format: FormatOptions\n}) {\n  if (!active || !payload?.length) return null\n  const heading = label ?? payload[0]?.payload?.__label\n  return (\n    <div className=\"min-w-36 rounded-lg bg-popover px-3 py-2 text-xs text-popover-foreground shadow-lg ring-1 ring-border\">\n      {heading !== undefined ? <p className=\"mb-1.5 font-medium\">{String(heading)}</p> : null}\n      <div className=\"space-y-1\">\n        {payload.map((entry, index) => {\n          const key = String(entry.dataKey ?? entry.name ?? index)\n          return (\n            <div key={key} className=\"flex items-center gap-2\">\n              <span className=\"size-2 shrink-0 rounded-[3px]\" style={{ background: entry.color ?? entry.payload?.fill as string }} />\n              <span className=\"text-muted-foreground\">{config[key]?.label ?? entry.name}</span>\n              <span className=\"ms-auto font-medium tabular-nums\">\n                {typeof entry.value === \"number\" ? formatNumber(entry.value, format) : String(entry.value ?? \"—\")}\n              </span>\n            </div>\n          )\n        })}\n      </div>\n    </div>\n  )\n}\n\nconst seriesColor = (index: number) => `var(--chart-${(index % 5) + 1})`\n\nfunction DataTable({ block, format }: { block: BlockOf<\"chart\">; format: FormatOptions }) {\n  return (\n    <div className=\"max-h-72 overflow-auto rounded-lg ring-1 ring-border\">\n      <table className=\"w-full text-sm\">\n        <thead className=\"sticky top-0 bg-muted/60 text-xs text-muted-foreground\">\n          <tr>\n            <th scope=\"col\" className=\"px-3 py-2 text-start font-medium\">\n              {block.xKey}\n            </th>\n            {block.series.map((series) => (\n              <th key={series.key} scope=\"col\" className=\"px-3 py-2 text-end font-medium\">\n                {series.label}\n              </th>\n            ))}\n          </tr>\n        </thead>\n        <tbody>\n          {block.data.map((row, index) => (\n            <tr key={index} className=\"border-t border-border/60\">\n              <th scope=\"row\" className=\"px-3 py-2 text-start font-medium\">\n                {String(row[block.xKey] ?? \"\")}\n              </th>\n              {block.series.map((series) => (\n                <td key={series.key} className=\"px-3 py-2 text-end tabular-nums\">\n                  {typeof row[series.key] === \"number\" ? formatNumber(row[series.key] as number, format) : \"—\"}\n                </td>\n              ))}\n            </tr>\n          ))}\n        </tbody>\n      </table>\n    </div>\n  )\n}\n\nexport function ChartBlock({ block }: { block: BlockOf<\"chart\"> }) {\n  const { locale } = useFable()\n  const [asTable, setAsTable] = useFableState(\"table\", false)\n  const format: FormatOptions = { format: block.format, currency: block.currency, locale }\n  const compact: FormatOptions = { ...format, format: block.format === \"percent\" ? \"percent\" : \"compact\" }\n  const gradientId = React.useId().replace(/:/g, \"\")\n\n  const config = Object.fromEntries(\n    block.series.map((series, index) => [series.key, { label: series.label, color: `var(--chart-${(index % 5) + 1})` }])\n  ) satisfies ChartConfig\n\n  const circular = block.kind === \"pie\" || block.kind === \"donut\"\n  const pieSeries = block.series[0]\n  const pieData = circular\n    ? block.data\n        .map((row, index) => ({\n          __label: String(row[block.xKey] ?? \"\"),\n          value: typeof row[pieSeries.key] === \"number\" ? (row[pieSeries.key] as number) : 0,\n          fill: `var(--chart-${(index % 5) + 1})`,\n        }))\n        .filter((entry) => entry.value > 0)\n    : []\n  const pieTotal = pieData.reduce((sum, entry) => sum + entry.value, 0)\n\n  const axis = {\n    tickLine: false,\n    axisLine: false,\n    tickMargin: 8,\n    tick: { fontSize: 12 },\n  } as const\n\n  const cartesian = (\n    <>\n      <CartesianGrid vertical={Boolean(block.horizontal)} horizontal={!block.horizontal} strokeDasharray=\"3 3\" className=\"stroke-border\" />\n      {block.horizontal ? (\n        <>\n          <YAxis dataKey={block.xKey} type=\"category\" width={96} {...axis} />\n          <XAxis type=\"number\" {...axis} tickFormatter={(value: number) => formatNumber(value, compact)} />\n        </>\n      ) : (\n        <>\n          <XAxis dataKey={block.xKey} {...axis} interval=\"preserveStartEnd\" minTickGap={16} />\n          <YAxis {...axis} width={48} tickFormatter={(value: number) => formatNumber(value, compact)} />\n        </>\n      )}\n      <ChartTooltip cursor={{ className: \"fill-muted/60 stroke-border\" }} content={<ChartTip config={config} format={format} />} />\n    </>\n  )\n\n  let chart: React.ReactElement\n  if (circular) {\n    chart = (\n      <PieChart>\n        <ChartTooltip content={<ChartTip config={{ value: { label: pieSeries.label } }} format={format} />} />\n        <Pie\n          data={pieData}\n          dataKey=\"value\"\n          nameKey=\"__label\"\n          innerRadius={block.kind === \"donut\" ? \"58%\" : 0}\n          outerRadius=\"92%\"\n          paddingAngle={block.kind === \"donut\" ? 2 : 0}\n          strokeWidth={block.kind === \"donut\" ? 0 : 2}\n          className=\"stroke-card\"\n          isAnimationActive={false}\n        >\n          {pieData.map((entry) => (\n            <Cell key={entry.__label} fill={entry.fill} />\n          ))}\n        </Pie>\n      </PieChart>\n    )\n  } else if (block.kind === \"line\") {\n    chart = (\n      <LineChart data={block.data} margin={{ top: 8, right: 8, left: 0, bottom: 0 }}>\n        {cartesian}\n        {block.series.map((series, index) => (\n          <Line\n            key={series.key}\n            dataKey={series.key}\n            type=\"monotone\"\n            stroke={seriesColor(index)}\n            strokeWidth={2}\n            dot={block.data.length <= 12 ? { r: 2.5, strokeWidth: 0, fill: seriesColor(index) } : false}\n            activeDot={{ r: 4, strokeWidth: 2, className: \"stroke-card\" }}\n            isAnimationActive={false}\n          />\n        ))}\n      </LineChart>\n    )\n  } else if (block.kind === \"area\") {\n    chart = (\n      <AreaChart data={block.data} margin={{ top: 8, right: 8, left: 0, bottom: 0 }}>\n        <defs>\n          {block.series.map((series, index) => (\n            <linearGradient key={series.key} id={`${gradientId}-${index}`} x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\">\n              <stop offset=\"0%\" stopColor={seriesColor(index)} stopOpacity={0.35} />\n              <stop offset=\"100%\" stopColor={seriesColor(index)} stopOpacity={0.02} />\n            </linearGradient>\n          ))}\n        </defs>\n        {cartesian}\n        {block.series.map((series, index) => (\n          <Area\n            key={series.key}\n            dataKey={series.key}\n            type=\"monotone\"\n            stackId={block.stacked ? \"stack\" : undefined}\n            stroke={seriesColor(index)}\n            strokeWidth={2}\n            fill={`url(#${gradientId}-${index})`}\n            isAnimationActive={false}\n          />\n        ))}\n      </AreaChart>\n    )\n  } else {\n    chart = (\n      <BarChart\n        data={block.data}\n        layout={block.horizontal ? \"vertical\" : \"horizontal\"}\n        margin={{ top: 8, right: 8, left: 0, bottom: 0 }}\n        barCategoryGap=\"22%\"\n      >\n        {cartesian}\n        {block.series.map((series, index) => (\n          <Bar\n            key={series.key}\n            dataKey={series.key}\n            stackId={block.stacked ? \"stack\" : undefined}\n            fill={seriesColor(index)}\n            radius={\n              block.stacked && index < block.series.length - 1\n                ? 0\n                : block.horizontal\n                  ? [0, 4, 4, 0]\n                  : [4, 4, 0, 0]\n            }\n            maxBarSize={44}\n            isAnimationActive={false}\n          />\n        ))}\n      </BarChart>\n    )\n  }\n\n  const height = block.horizontal ? Math.min(Math.max(block.data.length * 36 + 40, 180), 480) : 260\n\n  return (\n    <figure className={cn(surface, \"p-4 @lg:p-5\")}>\n      <BlockHeader\n        title={block.title}\n        description={block.description}\n        className=\"mb-4\"\n        actions={\n          <IconAction label={asTable ? \"Show chart\" : \"Show data table\"} onClick={() => setAsTable((value) => !value)}>\n            <SwapIcon swapped={asTable} from={TableIcon} to={ChartColumnIcon} />\n          </IconAction>\n        }\n      />\n      {asTable ? (\n        <DataTable block={block} format={format} />\n      ) : circular ? (\n        <div className=\"grid items-center gap-6 @lg:grid-cols-[minmax(0,12rem)_1fr]\">\n          <ChartContainer config={config} className=\"mx-auto aspect-square w-full max-w-60\">\n            {chart}\n          </ChartContainer>\n          <ul className=\"space-y-2\">\n            {pieData.map((entry) => (\n              <li key={entry.__label} className=\"flex items-center gap-2.5 text-sm\">\n                <span className=\"size-2.5 shrink-0 rounded-[3px]\" style={{ background: entry.fill }} />\n                <span className=\"min-w-0 flex-1 truncate\">{entry.__label}</span>\n                <span className=\"text-muted-foreground tabular-nums\">{formatNumber(entry.value, format)}</span>\n                <span className=\"w-12 text-end text-xs text-muted-foreground tabular-nums\">\n                  {pieTotal ? `${Math.round((entry.value / pieTotal) * 100)}%` : \"\"}\n                </span>\n              </li>\n            ))}\n          </ul>\n        </div>\n      ) : (\n        <>\n          <ChartContainer config={config} className=\"aspect-auto w-full\" style={{ height }}>\n            {chart}\n          </ChartContainer>\n          {block.series.length > 1 ? (\n            <ul className=\"mt-3 flex flex-wrap gap-x-4 gap-y-1.5\">\n              {block.series.map((series, index) => (\n                <li key={series.key} className=\"flex items-center gap-1.5 text-xs text-muted-foreground\">\n                  <span className=\"size-2 rounded-[3px]\" style={{ background: seriesColor(index) }} />\n                  {series.label}\n                </li>\n              ))}\n            </ul>\n          ) : null}\n        </>\n      )}\n      <figcaption className=\"sr-only\">{block.title ?? `${block.kind} chart`}</figcaption>\n    </figure>\n  )\n}\n",
      "type": "registry:component",
      "target": "components/fable-ui/blocks/chart.tsx"
    },
    {
      "path": "components/fable-ui/blocks/media.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { ChevronLeftIcon, ChevronRightIcon, ImageOffIcon, ShieldAlertIcon, XIcon } from \"lucide-react\"\n\nimport { Button } from \"@/components/ui/button\"\nimport { Dialog, DialogContent, DialogDescription, DialogTitle } from \"@/components/ui/dialog\"\nimport { cn } from \"@/lib/utils\"\n\nimport { useFable } from \"../provider\"\nimport { decideImage } from \"../safety\"\nimport type { BlockOf, FableImage } from \"../schema\"\nimport { BlockHeader, imageOutline } from \"./shared\"\n\nconst aspects = {\n  auto: \"\",\n  square: \"aspect-square\",\n  landscape: \"aspect-[4/3]\",\n  portrait: \"aspect-[3/4]\",\n  wide: \"aspect-[16/9]\",\n} as const\n\ntype Aspect = keyof typeof aspects\n\nconst approvedHosts = new Set<string>()\n\n/**\n * Every model-provided image goes through here. Allowed hosts load lazily\n * with no referrer; other https hosts wait for the user; anything else\n * never loads.\n */\nexport function FableImg({\n  image,\n  aspect = \"landscape\",\n  className,\n  rounded = \"rounded-lg\",\n  priority,\n}: {\n  image: FableImage\n  aspect?: Aspect\n  className?: string\n  rounded?: string\n  priority?: boolean\n}) {\n  const { images } = useFable()\n  const decision = decideImage(image.src, images)\n  const [approved, setApproved] = React.useState(() => decision.status === \"ask\" && approvedHosts.has(decision.host))\n  const [state, setState] = React.useState<\"loading\" | \"loaded\" | \"error\">(\"loading\")\n\n  const frame = cn(\"relative overflow-hidden bg-muted\", rounded, aspects[aspect], aspect === \"auto\" && \"min-h-40\", className)\n\n  if (decision.status === \"blocked\" || state === \"error\") {\n    return (\n      <div className={cn(frame, \"grid place-items-center\")} role=\"img\" aria-label={image.alt || \"Image unavailable\"}>\n        <div className=\"flex flex-col items-center gap-1.5 px-4 text-center text-xs text-muted-foreground\">\n          <ImageOffIcon className=\"size-5 opacity-60\" aria-hidden />\n          <span className=\"line-clamp-2\">{image.alt || \"Image unavailable\"}</span>\n        </div>\n      </div>\n    )\n  }\n\n  if (decision.status === \"ask\" && !approved) {\n    return (\n      <div className={cn(frame, \"grid place-items-center\")}>\n        <div className=\"flex max-w-60 flex-col items-center gap-2 px-4 text-center\">\n          <ShieldAlertIcon className=\"size-5 text-muted-foreground\" aria-hidden />\n          <p className=\"line-clamp-2 text-xs text-muted-foreground\">\n            {image.alt ? `“${image.alt}” from ` : \"Image from \"}\n            <span className=\"font-medium text-foreground\">{decision.host}</span>\n          </p>\n          <Button\n            size=\"xs\"\n            variant=\"outline\"\n            onClick={(event) => {\n              event.stopPropagation()\n              approvedHosts.add(decision.host)\n              setApproved(true)\n            }}\n          >\n            Load image\n          </Button>\n        </div>\n      </div>\n    )\n  }\n\n  return (\n    <div className={frame}>\n      {state === \"loading\" ? <div className=\"absolute inset-0 animate-pulse bg-muted motion-reduce:animate-none\" /> : null}\n      {/* eslint-disable-next-line @next/next/no-img-element -- remote, policy-checked, model-provided URL */}\n      <img\n        src={decision.src}\n        alt={image.alt}\n        loading={priority ? \"eager\" : \"lazy\"}\n        decoding=\"async\"\n        referrerPolicy=\"no-referrer\"\n        onLoad={() => setState(\"loaded\")}\n        onError={() => setState(\"error\")}\n        className={cn(\n          \"size-full object-cover transition-opacity duration-500\",\n          aspect === \"auto\" && \"h-auto\",\n          state === \"loaded\" ? \"opacity-100\" : \"opacity-0\"\n        )}\n      />\n      <span aria-hidden className={cn(\"pointer-events-none absolute inset-0\", rounded, imageOutline)} />\n    </div>\n  )\n}\n\nfunction Caption({ image }: { image: FableImage }) {\n  if (!image.caption && !image.credit) return null\n  return (\n    <figcaption className=\"mt-2 flex flex-wrap items-baseline justify-between gap-x-3 gap-y-0.5 text-xs text-muted-foreground\">\n      {image.caption ? <span className=\"text-pretty\">{image.caption}</span> : null}\n      {image.credit ? <span className=\"opacity-80\">{image.credit}</span> : null}\n    </figcaption>\n  )\n}\n\nexport function ImageBlock({ block }: { block: BlockOf<\"image\"> }) {\n  return (\n    <figure>\n      <FableImg image={block.image} aspect={block.aspect ?? \"wide\"} rounded=\"rounded-xl\" />\n      <Caption image={block.image} />\n    </figure>\n  )\n}\n\nfunction Lightbox({\n  images,\n  index,\n  onIndex,\n  onClose,\n}: {\n  images: FableImage[]\n  index: number | null\n  onIndex: (index: number) => void\n  onClose: () => void\n}) {\n  const image = index === null ? null : images[index]\n  const go = (step: number) => index !== null && onIndex((index + step + images.length) % images.length)\n  return (\n    <Dialog open={image !== null} onOpenChange={(open) => !open && onClose()}>\n      <DialogContent\n        showCloseButton={false}\n        className=\"max-w-[min(64rem,calc(100vw-2rem))] gap-0 overflow-hidden bg-background p-0 @lg:max-w-[min(64rem,calc(100vw-2rem))]\"\n        onKeyDown={(event) => {\n          if (event.key === \"ArrowRight\") go(1)\n          if (event.key === \"ArrowLeft\") go(-1)\n        }}\n      >\n        {image ? (\n          <>\n            <div className=\"relative bg-muted\">\n              <FableImg image={image} aspect=\"auto\" rounded=\"rounded-none\" className=\"max-h-[75vh] [&_img]:max-h-[75vh] [&_img]:object-contain\" priority />\n              <Button\n                size=\"icon-sm\"\n                variant=\"secondary\"\n                className=\"absolute end-3 top-3 bg-background/80 backdrop-blur\"\n                onClick={onClose}\n                aria-label=\"Close\"\n              >\n                <XIcon />\n              </Button>\n              {images.length > 1 ? (\n                <>\n                  <Button\n                    size=\"icon\"\n                    variant=\"secondary\"\n                    className=\"absolute start-3 top-1/2 -translate-y-1/2 bg-background/80 backdrop-blur rtl:rotate-180\"\n                    onClick={() => go(-1)}\n                    aria-label=\"Previous image\"\n                  >\n                    <ChevronLeftIcon />\n                  </Button>\n                  <Button\n                    size=\"icon\"\n                    variant=\"secondary\"\n                    className=\"absolute end-3 top-1/2 -translate-y-1/2 bg-background/80 backdrop-blur rtl:rotate-180\"\n                    onClick={() => go(1)}\n                    aria-label=\"Next image\"\n                  >\n                    <ChevronRightIcon />\n                  </Button>\n                </>\n              ) : null}\n            </div>\n            <div className=\"flex items-start justify-between gap-4 px-5 py-3.5\">\n              <div className=\"min-w-0\">\n                <DialogTitle className=\"text-sm font-medium\">{image.caption ?? image.alt ?? \"Image\"}</DialogTitle>\n                <DialogDescription className=\"text-xs\">{image.credit ?? image.alt}</DialogDescription>\n              </div>\n              {images.length > 1 ? (\n                <span className=\"shrink-0 text-xs text-muted-foreground tabular-nums\">\n                  {(index ?? 0) + 1} / {images.length}\n                </span>\n              ) : null}\n            </div>\n          </>\n        ) : null}\n      </DialogContent>\n    </Dialog>\n  )\n}\n\nfunction Tile({\n  image,\n  aspect,\n  onOpen,\n  className,\n}: {\n  image: FableImage\n  aspect: Aspect\n  onOpen: () => void\n  className?: string\n}) {\n  return (\n    <button\n      type=\"button\"\n      onClick={onOpen}\n      aria-label={`Open ${image.alt || \"image\"}`}\n      className={cn(\n        \"group/tile relative block w-full overflow-hidden rounded-lg text-start outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background\",\n        className\n      )}\n    >\n      <FableImg\n        image={image}\n        aspect={aspect}\n        className=\"h-full [&_img]:transition-[opacity,scale] [&_img]:duration-500 group-hover/tile:[&_img]:scale-[1.03]\"\n      />\n      {image.caption ? (\n        <span className=\"pointer-events-none absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/60 to-transparent px-3 pt-8 pb-2.5 text-xs font-medium text-white opacity-0 transition-opacity group-hover/tile:opacity-100 group-focus-visible/tile:opacity-100\">\n          {image.caption}\n        </span>\n      ) : null}\n    </button>\n  )\n}\n\nexport function GalleryBlock({ block }: { block: BlockOf<\"gallery\"> }) {\n  const [open, setOpen] = React.useState<number | null>(null)\n  const images = block.images\n  const scroller = React.useRef<HTMLDivElement>(null)\n\n  let body: React.ReactNode\n  if (block.layout === \"featured\" && images.length >= 3) {\n    const [first, ...rest] = images\n    const side = rest.slice(0, 4)\n    const grid = side.length === 4\n    body = (\n      <div className=\"grid gap-2 @lg:grid-cols-[1.5fr_1fr]\">\n        <Tile image={first} aspect=\"landscape\" onOpen={() => setOpen(0)} className=\"@lg:h-full @lg:[&>div]:aspect-auto @lg:[&>div]:h-full\" />\n        <div className={cn(\"grid gap-2\", grid ? \"grid-cols-2\" : \"grid-cols-2 @lg:grid-cols-1\")}>\n          {side.map((image, index) => (\n            <Tile\n              key={index}\n              image={image}\n              aspect={grid ? \"square\" : \"landscape\"}\n              onOpen={() => setOpen(index + 1)}\n              className={cn(!grid && side.length === 3 && index === 2 && \"col-span-2 @lg:col-span-1\")}\n            />\n          ))}\n        </div>\n      </div>\n    )\n  } else if (block.layout === \"masonry\") {\n    const pattern: Aspect[] = [\"portrait\", \"square\", \"landscape\", \"square\", \"portrait\", \"landscape\"]\n    body = (\n      <div className=\"columns-2 gap-2 @lg:columns-3 [&>*]:mb-2\">\n        {images.map((image, index) => (\n          <Tile key={index} image={image} aspect={pattern[index % pattern.length]} onOpen={() => setOpen(index)} className=\"break-inside-avoid\" />\n        ))}\n      </div>\n    )\n  } else if (block.layout === \"carousel\") {\n    const scrollBy = (direction: number) => {\n      const node = scroller.current\n      if (!node) return\n      const rtl = getComputedStyle(node).direction === \"rtl\"\n      const reducedMotion = window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches\n      node.scrollBy({ left: node.clientWidth * 0.8 * direction * (rtl ? -1 : 1), behavior: reducedMotion ? \"auto\" : \"smooth\" })\n    }\n    body = (\n      <div className=\"relative\">\n        <div\n          ref={scroller}\n          className=\"-mx-1 flex snap-x snap-mandatory gap-2 overflow-x-auto motion-safe:scroll-smooth px-1 pb-1 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden\"\n        >\n          {images.map((image, index) => (\n            <Tile key={index} image={image} aspect=\"portrait\" onOpen={() => setOpen(index)} className=\"w-[62%] shrink-0 snap-start @lg:w-[38%]\" />\n          ))}\n        </div>\n        {images.length > 2 ? (\n          <div className=\"mt-2 flex justify-end gap-1\">\n            <Button size=\"icon-sm\" variant=\"outline\" onClick={() => scrollBy(-1)} aria-label=\"Scroll back\" className=\"rtl:rotate-180\">\n              <ChevronLeftIcon />\n            </Button>\n            <Button size=\"icon-sm\" variant=\"outline\" onClick={() => scrollBy(1)} aria-label=\"Scroll forward\" className=\"rtl:rotate-180\">\n              <ChevronRightIcon />\n            </Button>\n          </div>\n        ) : null}\n      </div>\n    )\n  } else {\n    const columns = images.length === 1 ? \"grid-cols-1\" : images.length === 2 || images.length === 4 ? \"grid-cols-2\" : \"grid-cols-2 @lg:grid-cols-3\"\n    body = (\n      <div className={cn(\"grid gap-2\", columns)}>\n        {images.map((image, index) => (\n          <Tile key={index} image={image} aspect={images.length === 1 ? \"wide\" : \"square\"} onOpen={() => setOpen(index)} />\n        ))}\n      </div>\n    )\n  }\n\n  return (\n    <section aria-label={block.title ?? \"Image gallery\"} className=\"space-y-3\">\n      <BlockHeader title={block.title} />\n      {body}\n      <Lightbox images={images} index={open} onIndex={setOpen} onClose={() => setOpen(null)} />\n    </section>\n  )\n}\n",
      "type": "registry:component",
      "target": "components/fable-ui/blocks/media.tsx"
    },
    {
      "path": "components/fable-ui/blocks/showcase.tsx",
      "content": "\"use client\"\n\nimport { cn } from \"@/lib/utils\"\n\nimport type { BlockOf } from \"../schema\"\nimport { ActionButton } from \"./actions\"\nimport { FableImg } from \"./media\"\nimport { surface } from \"./shared\"\n\nfunction Stats({ stats, inverted }: { stats: NonNullable<BlockOf<\"hero\">[\"stats\"]>; inverted?: boolean }) {\n  return (\n    <dl className=\"flex flex-wrap gap-x-8 gap-y-3\">\n      {stats.map((stat, index) => (\n        <div key={index} className=\"min-w-0\">\n          <dt className={cn(\"text-xs\", inverted ? \"text-white/70\" : \"text-muted-foreground\")}>{stat.label}</dt>\n          <dd className=\"font-heading text-xl font-semibold tracking-tight tabular-nums\">{stat.value}</dd>\n        </div>\n      ))}\n    </dl>\n  )\n}\n\nfunction HeroActions({ block, stateKey }: { block: BlockOf<\"hero\">; stateKey: string }) {\n  if (!block.actions?.length) return null\n  return (\n    <div className=\"flex flex-wrap gap-2\">\n      {block.actions.map((action, index) => (\n        <ActionButton\n          key={index}\n          action={action}\n          stateKey={`${stateKey}.a${index}`}\n          size=\"lg\"\n          fallbackStyle={index === 0 ? \"primary\" : \"outline\"}\n        />\n      ))}\n    </div>\n  )\n}\n\n/**\n * Four compositions for an answer that deserves an opening:\n * split (text beside image), cover (text over image), editorial (type-led,\n * no image needed) and spotlight (centered on a quiet accent field).\n */\nexport function HeroBlock({ block, stateKey }: { block: BlockOf<\"hero\">; stateKey: string }) {\n  const variant = block.variant === \"cover\" && !block.image ? \"spotlight\" : block.variant\n\n  if (variant === \"cover\" && block.image) {\n    return (\n      <section className=\"relative isolate overflow-hidden rounded-2xl bg-neutral-950 text-white\">\n        <FableImg image={block.image} aspect=\"auto\" rounded=\"rounded-none\" className=\"absolute inset-0 -z-10 h-full min-h-0\" priority />\n        <div className=\"absolute inset-0 -z-10 bg-gradient-to-t from-black/85 via-black/45 to-black/10\" />\n        <div className=\"flex min-h-[22rem] flex-col justify-end gap-4 p-6 @lg:min-h-[26rem] @lg:p-8\">\n          {block.eyebrow ? (\n            <p className=\"text-xs font-medium tracking-[0.12em] text-white/75 uppercase\">{block.eyebrow}</p>\n          ) : null}\n          <h2 className=\"max-w-[20ch] font-heading text-3xl leading-[1.05] font-semibold tracking-tight text-balance @lg:text-[2.5rem]\">\n            {block.title}\n          </h2>\n          {block.description ? (\n            <p className=\"max-w-[56ch] text-[0.9375rem] leading-relaxed text-pretty text-white/80\">{block.description}</p>\n          ) : null}\n          {block.stats?.length ? <Stats stats={block.stats} inverted /> : null}\n          <div className=\"[&_[data-variant=outline]]:border-white/30 [&_[data-variant=outline]]:bg-white/10 [&_[data-variant=outline]]:text-white [&_[data-variant=outline]]:backdrop-blur [&_[data-variant=outline]:hover]:bg-white/20\">\n            <HeroActions block={block} stateKey={stateKey} />\n          </div>\n        </div>\n      </section>\n    )\n  }\n\n  if (variant === \"split\") {\n    return (\n      <section className={cn(surface, \"grid overflow-hidden @lg:grid-cols-2\")}>\n        <div className=\"flex flex-col justify-center gap-4 p-6 @lg:p-8\">\n          {block.eyebrow ? <p className=\"text-xs font-medium tracking-[0.12em] text-primary uppercase\">{block.eyebrow}</p> : null}\n          <h2 className=\"font-heading text-2xl leading-tight font-semibold tracking-tight text-balance @lg:text-3xl\">{block.title}</h2>\n          {block.description ? (\n            <p className=\"text-[0.9375rem] leading-relaxed text-pretty text-muted-foreground\">{block.description}</p>\n          ) : null}\n          {block.stats?.length ? <Stats stats={block.stats} /> : null}\n          <HeroActions block={block} stateKey={stateKey} />\n        </div>\n        {block.image ? (\n          <FableImg image={block.image} aspect=\"landscape\" rounded=\"rounded-none\" className=\"order-first h-full @lg:order-none @lg:aspect-auto\" priority />\n        ) : (\n          <div aria-hidden className=\"order-first min-h-32 bg-[radial-gradient(120%_80%_at_100%_0%,color-mix(in_oklab,var(--primary)_22%,transparent),transparent_60%),radial-gradient(80%_60%_at_0%_100%,color-mix(in_oklab,var(--chart-2)_25%,transparent),transparent_70%)] @lg:order-none\" />\n        )}\n      </section>\n    )\n  }\n\n  if (variant === \"editorial\") {\n    return (\n      <section className=\"relative grid gap-6 border-y border-foreground/80 py-7 @lg:grid-cols-[1fr_auto] @lg:py-9\">\n        <div className=\"space-y-4\">\n          {block.eyebrow ? (\n            <p className=\"flex items-center gap-2 text-xs font-medium tracking-[0.14em] text-muted-foreground uppercase\">\n              <span className=\"h-px w-6 bg-primary\" aria-hidden />\n              {block.eyebrow}\n            </p>\n          ) : null}\n          <h2 className=\"max-w-[18ch] font-heading text-[2.25rem] leading-[1.02] font-semibold tracking-[-0.025em] text-balance @lg:text-5xl\">\n            {block.title}\n          </h2>\n          {block.description ? (\n            <p className=\"max-w-[58ch] text-base leading-relaxed text-pretty text-muted-foreground\">{block.description}</p>\n          ) : null}\n          <HeroActions block={block} stateKey={stateKey} />\n        </div>\n        {block.image ? (\n          <FableImg image={block.image} aspect=\"portrait\" className=\"w-full @lg:w-52\" />\n        ) : block.stats?.length ? (\n          <dl className=\"grid content-end gap-4 @lg:min-w-40 @lg:border-s @lg:border-border @lg:ps-6\">\n            {block.stats.map((stat, index) => (\n              <div key={index}>\n                <dd className=\"font-heading text-3xl font-semibold tracking-tight tabular-nums\">{stat.value}</dd>\n                <dt className=\"text-xs text-muted-foreground\">{stat.label}</dt>\n              </div>\n            ))}\n          </dl>\n        ) : null}\n      </section>\n    )\n  }\n\n  return (\n    <section className=\"relative isolate overflow-hidden rounded-2xl bg-primary/[0.05] px-6 py-10 text-center ring-1 ring-primary/10 @lg:px-10 @lg:py-14\">\n      <div\n        aria-hidden\n        className=\"absolute inset-0 -z-10 bg-[radial-gradient(60%_80%_at_50%_0%,color-mix(in_oklab,var(--primary)_14%,transparent),transparent_70%)]\"\n      />\n      <div className=\"mx-auto flex max-w-xl flex-col items-center gap-4\">\n        {block.image ? (\n          <FableImg image={block.image} aspect=\"square\" rounded=\"rounded-2xl\" className=\"size-20 shadow-sm\" />\n        ) : null}\n        {block.eyebrow ? <p className=\"text-xs font-medium tracking-[0.12em] text-primary uppercase\">{block.eyebrow}</p> : null}\n        <h2 className=\"font-heading text-3xl leading-tight font-semibold tracking-tight text-balance @lg:text-4xl\">{block.title}</h2>\n        {block.description ? (\n          <p className=\"text-[0.9375rem] leading-relaxed text-pretty text-muted-foreground\">{block.description}</p>\n        ) : null}\n        {block.stats?.length ? (\n          <div className=\"flex justify-center\">\n            <Stats stats={block.stats} />\n          </div>\n        ) : null}\n        <div className=\"flex justify-center\">\n          <HeroActions block={block} stateKey={stateKey} />\n        </div>\n      </div>\n    </section>\n  )\n}\n\nexport function CardsBlock({ block, stateKey }: { block: BlockOf<\"cards\">; stateKey: string }) {\n  const columns = block.columns ?? (block.items.length === 1 ? 1 : block.items.length % 3 === 0 ? 3 : 2)\n  return (\n    <section aria-label={block.title ?? \"Cards\"} className=\"space-y-3\">\n      {block.title ? <h3 className=\"font-heading text-[0.9375rem] font-semibold tracking-tight\">{block.title}</h3> : null}\n      <ul\n        className={cn(\n          \"grid gap-3\",\n          columns === 2 && \"@lg:grid-cols-2\",\n          columns === 3 && \"@lg:grid-cols-2 @2xl:grid-cols-3\"\n        )}\n      >\n        {block.items.map((item, index) => (\n          <li key={index} className={cn(surface, \"group/card flex flex-col overflow-hidden\", columns === 1 && item.image && \"@lg:flex-row\")}>\n            {item.image ? (\n              <div className={cn(\"p-1.5 pb-0\", columns === 1 && \"@lg:w-2/5 @lg:pe-0 @lg:pb-1.5\")}>\n                <FableImg image={item.image} aspect=\"landscape\" className={cn(columns === 1 && \"@lg:h-full @lg:aspect-auto\")} />\n              </div>\n            ) : null}\n            <div className=\"flex flex-1 flex-col gap-1.5 p-4\">\n              <div className=\"flex items-start justify-between gap-3\">\n                <h4 className=\"font-heading text-[0.9375rem] leading-snug font-semibold tracking-tight text-balance\">{item.title}</h4>\n                {item.badge ? (\n                  <span className=\"shrink-0 rounded-full bg-primary/10 px-2 py-0.5 text-[0.6875rem] font-medium text-primary\">\n                    {item.badge}\n                  </span>\n                ) : null}\n              </div>\n              {item.meta ? <p className=\"text-xs text-muted-foreground tabular-nums\">{item.meta}</p> : null}\n              {item.description ? (\n                <p className=\"text-sm leading-6 text-pretty text-muted-foreground\">{item.description}</p>\n              ) : null}\n              {item.action ? (\n                <div className=\"mt-auto pt-2\">\n                  <ActionButton action={item.action} stateKey={`${stateKey}.${index}`} size=\"sm\" fallbackStyle=\"secondary\" />\n                </div>\n              ) : null}\n            </div>\n          </li>\n        ))}\n      </ul>\n    </section>\n  )\n}\n",
      "type": "registry:component",
      "target": "components/fable-ui/blocks/showcase.tsx"
    },
    {
      "path": "components/fable-ui/blocks/content.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { CheckIcon, ClockIcon, FileTextIcon, GlobeIcon } from \"lucide-react\"\n\nimport { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from \"@/components/ui/accordion\"\nimport { Checkbox } from \"@/components/ui/checkbox\"\nimport { cn } from \"@/lib/utils\"\n\nimport { useFableState } from \"../provider\"\nimport { hostLabel, safeFilename, safeLinkUrl } from \"../safety\"\nimport type { BlockOf } from \"../schema\"\nimport { ActionButton } from \"./actions\"\nimport { FableImg } from \"./media\"\nimport { MemoProse } from \"./prose\"\nimport { BlockHeader, CopyAction, surface } from \"./shared\"\n\nfunction slug(text: string, index: number) {\n  return `${text.toLowerCase().replace(/[^\\p{L}\\p{N}]+/gu, \"-\").replace(/^-|-$/g, \"\").slice(0, 48) || \"section\"}-${index}`\n}\n\n/**\n * Long-form answer. Three or more headed sections get a table of contents,\n * the navigation aid long mixed-format replies usually lack.\n */\nexport function ArticleBlock({ block, stateKey, open }: { block: BlockOf<\"article\">; stateKey: string; open?: boolean }) {\n  const prefix = React.useId().replace(/:/g, \"\")\n  const headed = block.sections.filter((section) => section.heading)\n  const toc = headed.length >= 3 && !open\n  const markdown = [\n    `# ${block.title}`,\n    block.subtitle,\n    ...block.sections.map((section) => [section.heading ? `## ${section.heading}` : \"\", section.body].filter(Boolean).join(\"\\n\\n\")),\n  ]\n    .filter(Boolean)\n    .join(\"\\n\\n\")\n\n  return (\n    <article className=\"space-y-6\">\n      <header className=\"space-y-3\">\n        <h2 className=\"font-heading text-[1.75rem] leading-[1.1] font-semibold tracking-[-0.02em] text-balance @lg:text-[2.125rem]\">\n          {block.title}\n        </h2>\n        {block.subtitle ? (\n          <p className=\"max-w-[60ch] text-[1.0625rem] leading-relaxed text-pretty text-muted-foreground\">{block.subtitle}</p>\n        ) : null}\n        {block.byline || block.readingTime || !open ? (\n          <div className=\"flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground\">\n            {block.byline ? <span className=\"font-medium text-foreground/80\">{block.byline}</span> : null}\n            {block.readingTime ? (\n              <span className=\"inline-flex items-center gap-1\">\n                <ClockIcon className=\"size-3\" aria-hidden />\n                {block.readingTime}\n              </span>\n            ) : null}\n            {!open ? (\n              <span className=\"ms-auto flex items-center\">\n                <CopyAction text={markdown} label=\"Copy as Markdown\" />\n                <ActionButton\n                  action={{\n                    type: \"download\",\n                    label: \"Download\",\n                    filename: block.title,\n                    mimeType: \"text/markdown\",\n                    content: markdown,\n                  }}\n                  stateKey={`${stateKey}.dl`}\n                  size=\"sm\"\n                  fallbackStyle=\"ghost\"\n                  className=\"text-muted-foreground\"\n                />\n              </span>\n            ) : null}\n          </div>\n        ) : null}\n      </header>\n\n      {block.cover ? (\n        <figure>\n          <FableImg image={block.cover} aspect=\"wide\" rounded=\"rounded-xl\" priority />\n          {block.cover.caption ? <figcaption className=\"mt-2 text-xs text-muted-foreground\">{block.cover.caption}</figcaption> : null}\n        </figure>\n      ) : null}\n\n      <div className={cn(toc && \"grid gap-8 @3xl:grid-cols-[minmax(0,1fr)_11rem]\")}>\n        <div className=\"min-w-0 space-y-7\">\n          {block.sections.map((section, index) => (\n            <section key={index} aria-labelledby={section.heading ? `${prefix}-${slug(section.heading, index)}` : undefined} className=\"scroll-mt-20\">\n              {section.heading ? (\n                <h3\n                  id={`${prefix}-${slug(section.heading, index)}`}\n                  className=\"mb-3 scroll-mt-20 font-heading text-lg font-semibold tracking-tight text-balance\"\n                >\n                  {section.heading}\n                </h3>\n              ) : null}\n              <MemoProse className=\"text-base [&_p]:leading-[1.75]\">{section.body}</MemoProse>\n            </section>\n          ))}\n        </div>\n        {toc ? (\n          <nav aria-label=\"On this article\" className=\"order-first @3xl:order-none\">\n            <div className=\"@3xl:sticky @3xl:top-4\">\n              <p className=\"mb-2 text-xs font-medium tracking-[0.08em] text-muted-foreground uppercase\">Contents</p>\n              <ol className=\"flex gap-1 overflow-x-auto border-b border-border pb-2 text-sm @3xl:flex-col @3xl:border-b-0 @3xl:border-s @3xl:pb-0\">\n                {block.sections.map((section, index) =>\n                  section.heading ? (\n                    <li key={index} className=\"shrink-0\">\n                      <a\n                        href={`#${prefix}-${slug(section.heading, index)}`}\n                        className=\"block rounded-md px-2 py-1 text-muted-foreground transition-colors hover:text-foreground @3xl:-ms-px @3xl:rounded-none @3xl:border-s @3xl:border-transparent @3xl:px-3 @3xl:hover:border-foreground/40\"\n                      >\n                        {section.heading}\n                      </a>\n                    </li>\n                  ) : null\n                )}\n              </ol>\n            </div>\n          </nav>\n        ) : null}\n      </div>\n    </article>\n  )\n}\n\nexport function ListBlock({ block }: { block: BlockOf<\"list\"> }) {\n  const header = block.title ? <BlockHeader title={block.title} className=\"mb-3\" /> : null\n\n  if (block.style === \"steps\" || block.style === \"timeline\") {\n    const timeline = block.style === \"timeline\"\n    return (\n      <section aria-label={block.title ?? (timeline ? \"Timeline\" : \"Steps\")}>\n        {header}\n        <ol className=\"relative\">\n          {block.items.map((item, index) => {\n            const status = item.status ?? (timeline ? undefined : \"upcoming\")\n            const last = index === block.items.length - 1\n            return (\n              <li key={index} className=\"relative grid grid-cols-[1.75rem_1fr] gap-x-3 pb-5 last:pb-0\">\n                {!last ? (\n                  <span\n                    aria-hidden\n                    className={cn(\n                      \"absolute start-[0.8125rem] top-8 bottom-1 w-px\",\n                      status === \"done\" ? \"bg-primary/40\" : \"bg-border\"\n                    )}\n                  />\n                ) : null}\n                <span\n                  aria-hidden\n                  className={cn(\n                    \"relative z-[1] mt-0.5 grid size-7 place-items-center rounded-full text-xs font-semibold tabular-nums ring-1\",\n                    timeline && \"mt-1.5 size-3.5 ms-[0.4375rem] rounded-full bg-background ring-2 ring-primary/60\",\n                    !timeline && status === \"done\" && \"bg-primary text-primary-foreground ring-primary\",\n                    !timeline && status === \"current\" && \"bg-background text-primary ring-2 ring-primary\",\n                    !timeline && status === \"upcoming\" && \"bg-muted text-muted-foreground ring-border\"\n                  )}\n                >\n                  {timeline ? null : status === \"done\" ? <CheckIcon className=\"size-3.5\" /> : index + 1}\n                </span>\n                <div className=\"min-w-0 space-y-0.5\">\n                  <div className=\"flex flex-wrap items-baseline gap-x-2\">\n                    {timeline && item.meta ? (\n                      <span className=\"text-xs font-medium text-primary tabular-nums\">{item.meta}</span>\n                    ) : null}\n                    <p className={cn(\"text-sm leading-7 font-semibold text-pretty\", status === \"upcoming\" && !timeline && \"text-foreground/80\")}>\n                      {item.title}\n                    </p>\n                    {!timeline && item.meta ? <span className=\"text-xs text-muted-foreground\">{item.meta}</span> : null}\n                    {status === \"current\" && !timeline ? <span className=\"sr-only\">(current step)</span> : null}\n                  </div>\n                  {item.description ? (\n                    <p className=\"text-sm leading-6 text-pretty text-muted-foreground\">{item.description}</p>\n                  ) : null}\n                </div>\n              </li>\n            )\n          })}\n        </ol>\n      </section>\n    )\n  }\n\n  const Tag = block.style === \"numbered\" ? \"ol\" : \"ul\"\n  return (\n    <section aria-label={block.title ?? \"List\"}>\n      {header}\n      <Tag className=\"space-y-2.5\">\n        {block.items.map((item, index) => (\n          <li key={index} className=\"flex gap-3\">\n            <span\n              aria-hidden\n              className={cn(\n                \"mt-[0.3rem] grid shrink-0 place-items-center\",\n                block.style === \"bullet\" && \"mt-[0.6rem] size-1.5 rounded-full bg-foreground/40\",\n                block.style === \"numbered\" && \"size-5 rounded-md bg-muted text-[0.6875rem] font-semibold text-muted-foreground tabular-nums\",\n                block.style === \"check\" && \"size-5 rounded-full bg-primary/10 text-primary\"\n              )}\n            >\n              {block.style === \"numbered\" ? index + 1 : block.style === \"check\" ? <CheckIcon className=\"size-3\" /> : null}\n            </span>\n            <div className=\"min-w-0\">\n              <p className=\"text-[0.9375rem] leading-7 text-pretty\">\n                <span className={cn(item.description && \"font-medium\")}>{item.title}</span>\n                {item.meta ? <span className=\"ms-2 text-xs text-muted-foreground\">{item.meta}</span> : null}\n              </p>\n              {item.description ? (\n                <p className=\"text-sm leading-6 text-pretty text-muted-foreground\">{item.description}</p>\n              ) : null}\n            </div>\n          </li>\n        ))}\n      </Tag>\n    </section>\n  )\n}\n\nexport function ChecklistBlock({ block }: { block: BlockOf<\"checklist\"> }) {\n  const [checked, setChecked] = useFableState<boolean[]>(\"checked\", () => block.items.map((item) => Boolean(item.checked)))\n  const id = React.useId()\n  const done = block.items.filter((_, index) => checked[index]).length\n  const progress = block.items.length ? Math.round((done / block.items.length) * 100) : 0\n\n  return (\n    <section className={cn(surface, \"p-4 @lg:p-5\")} aria-label={block.title ?? \"Checklist\"}>\n      <div className=\"mb-3 flex items-center justify-between gap-3\">\n        <h3 className=\"font-heading text-[0.9375rem] font-semibold tracking-tight\">{block.title ?? \"Checklist\"}</h3>\n        <span className=\"text-xs text-muted-foreground tabular-nums\" aria-live=\"polite\">\n          {done} of {block.items.length} done\n        </span>\n      </div>\n      <div\n        className=\"mb-3 h-1 overflow-hidden rounded-full bg-muted\"\n        role=\"progressbar\"\n        aria-valuenow={progress}\n        aria-valuemin={0}\n        aria-valuemax={100}\n        aria-label=\"Checklist progress\"\n      >\n        <div className=\"h-full rounded-full bg-primary transition-[width] duration-500 ease-out\" style={{ width: `${progress}%` }} />\n      </div>\n      <ul className=\"-mx-2\">\n        {block.items.map((item, index) => {\n          const isChecked = Boolean(checked[index])\n          return (\n            <li key={index}>\n              <label\n                htmlFor={`${id}-${index}`}\n                className=\"flex cursor-pointer items-start gap-3 rounded-lg px-2 py-2 transition-colors hover:bg-muted/50\"\n              >\n                <Checkbox\n                  id={`${id}-${index}`}\n                  checked={isChecked}\n                  onCheckedChange={(value) =>\n                    setChecked((current) => {\n                      const next = block.items.map((_, i) => Boolean(current[i]))\n                      next[index] = value === true\n                      return next\n                    })\n                  }\n                  className=\"mt-0.5\"\n                />\n                <span className=\"min-w-0 flex-1\">\n                  <span\n                    className={cn(\n                      \"block text-sm leading-5 text-pretty transition-colors\",\n                      isChecked && \"text-muted-foreground line-through decoration-foreground/30\"\n                    )}\n                  >\n                    {item.label}\n                  </span>\n                  {item.note ? <span className=\"mt-0.5 block text-xs text-muted-foreground\">{item.note}</span> : null}\n                </span>\n              </label>\n            </li>\n          )\n        })}\n      </ul>\n    </section>\n  )\n}\n\nexport function SourcesBlock({ block }: { block: BlockOf<\"sources\"> }) {\n  return (\n    <section aria-label=\"Sources\">\n      <p className=\"mb-2 text-xs font-medium tracking-[0.08em] text-muted-foreground uppercase\">Sources</p>\n      <ol className=\"grid gap-2 @lg:grid-cols-2\">\n        {block.items.map((item, index) => {\n          const href = safeLinkUrl(item.url)\n          const content = (\n            <>\n              <span className=\"flex items-center gap-1.5 text-xs text-muted-foreground\">\n                <span className=\"grid size-4 place-items-center rounded bg-muted text-[0.625rem] font-semibold tabular-nums\">\n                  {index + 1}\n                </span>\n                <GlobeIcon className=\"size-3\" aria-hidden />\n                <span className=\"truncate\">{item.publisher ?? (href ? hostLabel(href) : \"\")}</span>\n              </span>\n              <span className=\"line-clamp-2 text-sm leading-5 font-medium text-pretty\">{item.title}</span>\n              {item.snippet ? <span className=\"line-clamp-2 text-xs leading-5 text-muted-foreground\">{item.snippet}</span> : null}\n            </>\n          )\n          return (\n            <li key={index}>\n              {href ? (\n                <a\n                  href={href}\n                  target=\"_blank\"\n                  rel=\"noopener noreferrer nofollow\"\n                  className=\"flex h-full flex-col gap-1 rounded-lg bg-muted/40 p-3 ring-1 ring-border/60 transition-[background-color,box-shadow] outline-none hover:bg-muted/70 focus-visible:ring-2 focus-visible:ring-ring\"\n                >\n                  {content}\n                </a>\n              ) : (\n                <div className=\"flex h-full flex-col gap-1 rounded-lg bg-muted/40 p-3 ring-1 ring-border/60\">{content}</div>\n              )}\n            </li>\n          )\n        })}\n      </ol>\n    </section>\n  )\n}\n\nexport function FaqBlock({ block }: { block: BlockOf<\"faq\"> }) {\n  return (\n    <section aria-label={block.title ?? \"Questions\"} className=\"space-y-2\">\n      {block.title ? <h3 className=\"font-heading text-[0.9375rem] font-semibold tracking-tight\">{block.title}</h3> : null}\n      <Accordion type=\"multiple\" className={cn(surface, \"px-4\")}>\n        {block.items.map((item, index) => (\n          <AccordionItem key={index} value={String(index)} className=\"border-border/70\">\n            <AccordionTrigger className=\"text-start text-[0.9375rem] hover:no-underline\">{item.question}</AccordionTrigger>\n            <AccordionContent>\n              <MemoProse className=\"text-sm text-muted-foreground [&_p]:leading-6\">{item.answer}</MemoProse>\n            </AccordionContent>\n          </AccordionItem>\n        ))}\n      </Accordion>\n    </section>\n  )\n}\n\nexport function FileBlock({ block, stateKey }: { block: BlockOf<\"file\">; stateKey: string }) {\n  const safe = safeFilename(block.filename, block.mimeType)\n  const ext = safe.filename.split(\".\").pop()?.toUpperCase()\n  const size = new Blob([block.content]).size\n  const sizeLabel = size < 1024 ? `${size} B` : `${(size / 1024).toFixed(1)} KB`\n  return (\n    <div className={cn(surface, \"flex items-center gap-3 p-3 ps-3.5\")}>\n      <div className=\"relative grid size-10 shrink-0 place-items-center rounded-lg bg-primary/10 text-primary\">\n        <FileTextIcon className=\"size-5\" aria-hidden />\n        <span className=\"absolute -bottom-1 -end-1 rounded bg-foreground px-1 text-[0.5625rem] leading-4 font-bold text-background\">\n          {ext}\n        </span>\n      </div>\n      <div className=\"min-w-0 flex-1\">\n        <p className=\"truncate text-sm font-medium\">{safe.filename}</p>\n        <p className=\"truncate text-xs text-muted-foreground\">\n          {block.description ? `${block.description} · ` : \"\"}\n          <span className=\"tabular-nums\">{sizeLabel}</span>\n        </p>\n      </div>\n      <ActionButton\n        action={{ type: \"download\", label: \"Download\", filename: block.filename, mimeType: block.mimeType, content: block.content }}\n        stateKey={stateKey}\n        size=\"sm\"\n        fallbackStyle=\"secondary\"\n      />\n    </div>\n  )\n}\n",
      "type": "registry:component",
      "target": "components/fable-ui/blocks/content.tsx"
    },
    {
      "path": "components/fable-ui/blocks/interactive.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { CheckCircle2Icon, MailIcon, PencilIcon, RotateCcwIcon, SendIcon } from \"lucide-react\"\n\nimport { Button } from \"@/components/ui/button\"\nimport { Checkbox } from \"@/components/ui/checkbox\"\nimport { Input } from \"@/components/ui/input\"\nimport { Label } from \"@/components/ui/label\"\nimport { RadioGroup, RadioGroupItem } from \"@/components/ui/radio-group\"\nimport { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from \"@/components/ui/select\"\nimport { Switch } from \"@/components/ui/switch\"\nimport { Textarea } from \"@/components/ui/textarea\"\nimport { cn } from \"@/lib/utils\"\n\nimport { useFable, useFableState } from \"../provider\"\nimport type { BlockOf } from \"../schema\"\nimport { ActionButton } from \"./actions\"\nimport { BlockHeader, CopyAction, IconAction, surface } from \"./shared\"\n\ntype FieldValue = string | boolean\ntype Field = BlockOf<\"form\">[\"fields\"][number]\n\nconst EMAIL = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/\n\nfunction initialValue(field: Field): FieldValue {\n  if (field.type === \"checkbox\" || field.type === \"toggle\") return field.defaultValue === true\n  if (field.defaultValue === undefined || typeof field.defaultValue === \"boolean\") return \"\"\n  return String(field.defaultValue)\n}\n\nfunction describeValue(value: FieldValue) {\n  if (typeof value === \"boolean\") return value ? \"Yes\" : \"No\"\n  return value.trim() || \"—\"\n}\n\n/**\n * A form is how the model asks a clarifying question without a back-and-\n * forth. Submitting sends the answers as the user's next message.\n */\nexport function FormBlock({ block }: { block: BlockOf<\"form\"> }) {\n  const { onReply, readOnly } = useFable()\n  const id = React.useId()\n  const [values, setValues] = useFableState<Record<string, FieldValue>>(\"values\", () =>\n    Object.fromEntries(block.fields.map((field) => [field.name, initialValue(field)]))\n  )\n  const [errors, setErrors] = React.useState<Record<string, string>>({})\n  const [submitted, setSubmitted] = useFableState(\"submitted\", false)\n  const set = (name: string, value: FieldValue) => {\n    setValues((current) => ({ ...current, [name]: value }))\n    if (errors[name]) setErrors((current) => Object.fromEntries(Object.entries(current).filter(([key]) => key !== name)))\n  }\n\n  const submit = (event: React.FormEvent) => {\n    event.preventDefault()\n    const nextErrors: Record<string, string> = {}\n    for (const field of block.fields) {\n      const value = values[field.name] ?? initialValue(field)\n      if (field.required && (value === \"\" || value === false)) nextErrors[field.name] = \"Required\"\n      else if (field.type === \"email\" && typeof value === \"string\" && value && !EMAIL.test(value)) {\n        nextErrors[field.name] = \"Enter a valid email address\"\n      }\n    }\n    setErrors(nextErrors)\n    const first = Object.keys(nextErrors)[0]\n    if (first) {\n      document.getElementById(`${id}-${first}`)?.focus()\n      return\n    }\n    const lines = block.fields.map((field) => `- ${field.label}: ${describeValue(values[field.name] ?? initialValue(field))}`)\n    onReply?.([block.title ? `${block.title}:` : \"Here are my answers:\", ...lines].join(\"\\n\"))\n    setSubmitted(true)\n  }\n\n  const disabled = submitted || readOnly\n\n  return (\n    <form onSubmit={submit} noValidate className={cn(surface, \"p-4 @lg:p-5\")} aria-label={block.title ?? \"Form\"}>\n      <BlockHeader title={block.title} description={block.description} className=\"mb-4\" />\n      <fieldset disabled={disabled} className=\"grid gap-4 @lg:grid-cols-2\">\n        {block.fields.map((field) => {\n          const fieldId = `${id}-${field.name}`\n          const value = values[field.name] ?? initialValue(field)\n          const error = errors[field.name]\n          const wide = field.type === \"textarea\" || field.type === \"radio\" || field.type === \"checkbox\" || field.type === \"toggle\"\n          const describedBy = error ? `${fieldId}-error` : field.helper ? `${fieldId}-helper` : undefined\n          const labelNode = (\n            <Label htmlFor={fieldId} className=\"text-[0.8125rem] font-medium\">\n              {field.label}\n              {field.required ? <span className=\"text-muted-foreground\" aria-hidden>*</span> : null}\n            </Label>\n          )\n\n          let control: React.ReactNode\n          if (field.type === \"textarea\") {\n            control = (\n              <Textarea\n                id={fieldId}\n                value={String(value)}\n                placeholder={field.placeholder}\n                aria-invalid={Boolean(error)}\n                aria-describedby={describedBy}\n                onChange={(event) => set(field.name, event.target.value)}\n                className=\"min-h-20\"\n              />\n            )\n          } else if (field.type === \"select\") {\n            control = (\n              <Select value={String(value) || undefined} onValueChange={(next) => set(field.name, next)} disabled={disabled}>\n                <SelectTrigger id={fieldId} className=\"w-full\" aria-invalid={Boolean(error)} aria-describedby={describedBy}>\n                  <SelectValue placeholder={field.placeholder ?? \"Choose…\"} />\n                </SelectTrigger>\n                <SelectContent>\n                  {(field.options ?? []).map((option) => (\n                    <SelectItem key={option} value={option}>\n                      {option}\n                    </SelectItem>\n                  ))}\n                </SelectContent>\n              </Select>\n            )\n          } else if (field.type === \"radio\") {\n            control = (\n              <RadioGroup\n                id={fieldId}\n                value={String(value)}\n                onValueChange={(next) => set(field.name, next)}\n                aria-invalid={Boolean(error)}\n                aria-describedby={describedBy}\n                className=\"flex flex-wrap gap-2\"\n              >\n                {(field.options ?? []).map((option, index) => (\n                  <Label\n                    key={option}\n                    htmlFor={`${fieldId}-${index}`}\n                    className=\"flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm font-normal ring-1 ring-border transition-[background-color,box-shadow] has-data-[state=checked]:bg-primary/[0.06] has-data-[state=checked]:ring-primary/50\"\n                  >\n                    <RadioGroupItem id={`${fieldId}-${index}`} value={option} />\n                    {option}\n                  </Label>\n                ))}\n              </RadioGroup>\n            )\n          } else if (field.type === \"checkbox\" || field.type === \"toggle\") {\n            const Control = field.type === \"toggle\" ? Switch : Checkbox\n            return (\n              <div key={field.name} className=\"flex items-start gap-3 @lg:col-span-2\">\n                <Control\n                  id={fieldId}\n                  checked={value === true}\n                  onCheckedChange={(next: boolean | \"indeterminate\") => set(field.name, next === true)}\n                  aria-invalid={Boolean(error)}\n                  aria-describedby={describedBy}\n                  className=\"mt-0.5\"\n                />\n                <div className=\"space-y-0.5\">\n                  {labelNode}\n                  {field.helper ? (\n                    <p id={`${fieldId}-helper`} className=\"text-xs text-muted-foreground\">\n                      {field.helper}\n                    </p>\n                  ) : null}\n                  {error ? (\n                    <p id={`${fieldId}-error`} className=\"text-xs text-destructive\">\n                      {error}\n                    </p>\n                  ) : null}\n                </div>\n              </div>\n            )\n          } else {\n            control = (\n              <Input\n                id={fieldId}\n                type={field.type}\n                inputMode={field.type === \"number\" ? \"decimal\" : undefined}\n                value={String(value)}\n                placeholder={field.placeholder}\n                aria-invalid={Boolean(error)}\n                aria-describedby={describedBy}\n                onChange={(event) => set(field.name, event.target.value)}\n              />\n            )\n          }\n\n          return (\n            <div key={field.name} className={cn(\"grid content-start gap-1.5\", wide && \"@lg:col-span-2\")}>\n              {labelNode}\n              {control}\n              {error ? (\n                <p id={`${fieldId}-error`} className=\"text-xs text-destructive\">\n                  {error}\n                </p>\n              ) : field.helper ? (\n                <p id={`${fieldId}-helper`} className=\"text-xs text-muted-foreground\">\n                  {field.helper}\n                </p>\n              ) : null}\n            </div>\n          )\n        })}\n      </fieldset>\n      <div className=\"mt-5 flex flex-wrap items-center justify-end gap-2\">\n        {submitted ? (\n          <>\n            <span role=\"status\" className=\"me-auto inline-flex items-center gap-1.5 text-sm text-muted-foreground\">\n              <CheckCircle2Icon className=\"size-4 text-emerald-600 dark:text-emerald-400\" aria-hidden />\n              Answers sent\n            </span>\n            <Button type=\"button\" variant=\"ghost\" onClick={() => setSubmitted(false)} disabled={readOnly}>\n              <PencilIcon data-icon=\"inline-start\" />\n              Edit answers\n            </Button>\n          </>\n        ) : (\n          <Button type=\"submit\" disabled={!onReply || readOnly} className=\"transition-[scale] active:scale-[0.96]\">\n            {block.submitLabel ?? \"Send answers\"}\n            <SendIcon data-icon=\"inline-end\" />\n          </Button>\n        )}\n      </div>\n    </form>\n  )\n}\n\nconst PLACEHOLDER = /\\{\\{\\s*([A-Za-z][A-Za-z0-9_]{0,39})\\s*\\}\\}/g\n\nfunction fill(body: string, values: Record<string, string>) {\n  return body.replace(PLACEHOLDER, (match, name: string) => values[name]?.trim() || match)\n}\n\n/** Editable text with {{placeholders}}: fill the blanks, or edit the whole thing. */\nexport function TemplateBlock({ block, stateKey }: { block: BlockOf<\"template\">; stateKey: string }) {\n  const id = React.useId()\n  const names = React.useMemo(() => {\n    const declared = block.variables?.map((variable) => variable.name) ?? []\n    const found = [...block.body.matchAll(PLACEHOLDER)].map((match) => match[1])\n    return [...new Set([...declared, ...found])].slice(0, 20)\n  }, [block.body, block.variables])\n  const labels = Object.fromEntries((block.variables ?? []).map((variable) => [variable.name, variable.label]))\n  const [body, setBody] = useFableState(\"body\", block.body)\n  const [editing, setEditing] = useFableState(\"editing\", false)\n  const [values, setValues] = useFableState<Record<string, string>>(\"values\", () =>\n    Object.fromEntries((block.variables ?? []).map((variable) => [variable.name, variable.value ?? \"\"]))\n  )\n  const output = fill(body, values)\n  const remaining = names.filter((name) => !values[name]?.trim() && body.includes(name)).length\n\n  const preview = React.useMemo(() => {\n    const parts: React.ReactNode[] = []\n    let last = 0\n    for (const match of body.matchAll(PLACEHOLDER)) {\n      const index = match.index ?? 0\n      parts.push(body.slice(last, index))\n      const value = values[match[1]]?.trim()\n      parts.push(\n        value ? (\n          <mark key={index} className=\"rounded-[4px] bg-primary/10 px-0.5 text-foreground\">\n            {value}\n          </mark>\n        ) : (\n          <span key={index} className=\"rounded-[4px] border border-dashed border-primary/40 px-1 text-[0.85em] text-primary\">\n            {labels[match[1]] ?? match[1]}\n          </span>\n        )\n      )\n      last = index + match[0].length\n    }\n    parts.push(body.slice(last))\n    return parts\n  }, [body, values, labels])\n\n  return (\n    <section className={cn(surface, \"overflow-hidden\")} aria-label={block.title ?? \"Template\"}>\n      <div className=\"px-4 pt-3.5 pb-3 @lg:px-5\">\n        <BlockHeader\n          title={block.title ?? \"Template\"}\n          description={block.description}\n          actions={\n            <>\n              <IconAction label={editing ? \"Done editing\" : \"Edit text\"} onClick={() => setEditing((value) => !value)}>\n                {editing ? <CheckCircle2Icon className=\"size-4\" /> : <PencilIcon className=\"size-4\" />}\n              </IconAction>\n              <IconAction\n                label=\"Reset\"\n                disabled={body === block.body && Object.values(values).every((value) => !value)}\n                onClick={() => {\n                  setBody(block.body)\n                  setValues({})\n                }}\n              >\n                <RotateCcwIcon className=\"size-4\" />\n              </IconAction>\n            </>\n          }\n        />\n      </div>\n\n      {names.length > 0 ? (\n        <div className=\"grid gap-3 border-y border-border/70 bg-muted/30 px-4 py-3 @lg:grid-cols-2 @lg:px-5\">\n          {names.map((name) => (\n            <div key={name} className=\"grid gap-1\">\n              <Label htmlFor={`${id}-${name}`} className=\"text-xs font-medium text-muted-foreground\">\n                {labels[name] ?? name.replace(/_/g, \" \")}\n              </Label>\n              <Input\n                id={`${id}-${name}`}\n                value={values[name] ?? \"\"}\n                onChange={(event) => setValues((current) => ({ ...current, [name]: event.target.value }))}\n                className=\"h-8 bg-background ring-1 ring-border\"\n              />\n            </div>\n          ))}\n        </div>\n      ) : null}\n\n      <div className=\"px-4 py-4 @lg:px-5\">\n        {editing ? (\n          <Textarea\n            aria-label=\"Template text\"\n            value={body}\n            onChange={(event) => setBody(event.target.value)}\n            className=\"min-h-48 font-mono text-[0.8125rem] leading-6\"\n            autoFocus\n          />\n        ) : (\n          <div className=\"text-[0.9375rem] leading-7 whitespace-pre-wrap text-pretty [overflow-wrap:anywhere]\">{preview}</div>\n        )}\n      </div>\n\n      <div className=\"flex flex-wrap items-center justify-between gap-2 border-t border-border/70 px-4 py-2.5 @lg:px-5\">\n        <span className=\"text-xs text-muted-foreground tabular-nums\" aria-live=\"polite\">\n          {remaining > 0 ? `${remaining} blank${remaining === 1 ? \"\" : \"s\"} left` : names.length ? \"All blanks filled\" : `${output.length} characters`}\n        </span>\n        <div className=\"flex gap-1.5\">\n          <ActionButton\n            action={{ type: \"download\", label: \"Download\", filename: block.filename ?? block.title ?? \"template\", content: output }}\n            stateKey={`${stateKey}.dl`}\n            size=\"sm\"\n            fallbackStyle=\"ghost\"\n          />\n          <ActionButton action={{ type: \"copy\", label: \"Copy\", text: output }} stateKey={`${stateKey}.cp`} size=\"sm\" fallbackStyle=\"secondary\" />\n        </div>\n      </div>\n    </section>\n  )\n}\n\nfunction Recipients({ label, value, onChange }: { label: string; value: string; onChange: (value: string) => void }) {\n  const id = React.useId()\n  return (\n    <div className=\"flex items-center gap-3 border-b border-border/70 px-4 @lg:px-5\">\n      <label htmlFor={id} className=\"w-14 shrink-0 text-sm text-muted-foreground\">\n        {label}\n      </label>\n      <input\n        id={id}\n        value={value}\n        onChange={(event) => onChange(event.target.value)}\n        className=\"h-10 min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground/70\"\n        placeholder=\"name@example.com\"\n        inputMode=\"email\"\n        autoComplete=\"off\"\n      />\n    </div>\n  )\n}\n\n/** A draft the user finishes and sends from their own mail app or yours. */\nexport function EmailBlock({ block, stateKey }: { block: BlockOf<\"email\">; stateKey: string }) {\n  const [to, setTo] = useFableState(\"to\", (block.to ?? []).join(\", \"))\n  const [cc, setCc] = useFableState(\"cc\", (block.cc ?? []).join(\", \"))\n  const [subject, setSubject] = useFableState(\"subject\", block.subject)\n  const [body, setBody] = useFableState(\"body\", block.body)\n  const [showCc, setShowCc] = React.useState(Boolean(block.cc?.length))\n  const subjectId = React.useId()\n\n  const list = (value: string) => value.split(/[,;\\s]+/).map((entry) => entry.trim()).filter((entry) => EMAIL.test(entry))\n  const mailto = (() => {\n    const params = new URLSearchParams()\n    if (subject) params.set(\"subject\", subject)\n    if (body) params.set(\"body\", body.slice(0, 1800))\n    if (list(cc).length) params.set(\"cc\", list(cc).join(\",\"))\n    return `mailto:${list(to).map(encodeURIComponent).join(\",\")}?${params.toString().replace(/\\+/g, \"%20\")}`\n  })()\n  const plain = [`To: ${to}`, cc ? `Cc: ${cc}` : \"\", `Subject: ${subject}`, \"\", body].filter((line, index) => line || index > 2).join(\"\\n\")\n\n  return (\n    <section className={cn(surface, \"overflow-hidden\")} aria-label=\"Email draft\">\n      <div className=\"flex items-center justify-between gap-2 border-b border-border/70 bg-muted/30 px-4 py-2 @lg:px-5\">\n        <span className=\"inline-flex items-center gap-2 text-xs font-medium text-muted-foreground\">\n          <MailIcon className=\"size-3.5\" aria-hidden />\n          Draft\n        </span>\n        <div className=\"flex items-center\">\n          {!showCc ? (\n            <Button variant=\"ghost\" size=\"xs\" onClick={() => setShowCc(true)} className=\"text-muted-foreground\">\n              Add Cc\n            </Button>\n          ) : null}\n          <CopyAction text={plain} label=\"Copy email\" />\n        </div>\n      </div>\n      <Recipients label=\"To\" value={to} onChange={setTo} />\n      {showCc ? <Recipients label=\"Cc\" value={cc} onChange={setCc} /> : null}\n      <div className=\"flex items-center gap-3 border-b border-border/70 px-4 @lg:px-5\">\n        <label htmlFor={subjectId} className=\"w-14 shrink-0 text-sm text-muted-foreground\">\n          Subject\n        </label>\n        <input\n          id={subjectId}\n          value={subject}\n          onChange={(event) => setSubject(event.target.value)}\n          className=\"h-10 min-w-0 flex-1 bg-transparent text-sm font-medium outline-none\"\n        />\n      </div>\n      <textarea\n        aria-label=\"Email body\"\n        value={body}\n        onChange={(event) => setBody(event.target.value)}\n        className=\"field-sizing-content block max-h-[32rem] min-h-40 w-full resize-none bg-transparent px-4 py-4 text-[0.9375rem] leading-7 outline-none @lg:px-5\"\n      />\n      <div className=\"flex flex-wrap items-center justify-end gap-2 border-t border-border/70 px-4 py-2.5 @lg:px-5\">\n        <ActionButton\n          action={{ type: \"download\", label: \"Save as text\", filename: subject || \"email\", content: plain }}\n          stateKey={`${stateKey}.dl`}\n          size=\"sm\"\n          fallbackStyle=\"ghost\"\n        />\n        <ActionButton action={{ type: \"link\", label: \"Open in mail app\", url: mailto, icon: \"mail\" }} stateKey={`${stateKey}.mt`} size=\"sm\" />\n        {block.sendAction ? (\n          <ActionButton\n            action={{\n              type: \"host\",\n              label: \"Send\",\n              icon: \"send\",\n              action: block.sendAction,\n              payload: { to: list(to).join(\",\"), cc: list(cc).join(\",\"), subject, body },\n            }}\n            stateKey={`${stateKey}.send`}\n            size=\"sm\"\n            fallbackStyle=\"primary\"\n          />\n        ) : null}\n      </div>\n    </section>\n  )\n}\n",
      "type": "registry:component",
      "target": "components/fable-ui/blocks/interactive.tsx"
    },
    {
      "path": "components/fable-ui/blocks/actions.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { CheckIcon, CopyIcon, DownloadIcon, ExternalLinkIcon, Loader2Icon } from \"lucide-react\"\n\nimport { Button } from \"@/components/ui/button\"\nimport { Tooltip, TooltipContent, TooltipTrigger } from \"@/components/ui/tooltip\"\nimport { cn } from \"@/lib/utils\"\n\nimport { useFable, useFableState } from \"../provider\"\nimport { downloadText, safeLinkUrl } from \"../safety\"\nimport type { BlockOf, FableAction } from \"../schema\"\nimport { ICONS, SwapIcon, useCopy } from \"./shared\"\n\nconst variants = {\n  primary: \"default\",\n  secondary: \"secondary\",\n  outline: \"outline\",\n  ghost: \"ghost\",\n} as const\n\ntype HostState = { status: \"idle\" | \"confirm\" | \"running\" | \"done\" | \"error\"; note?: string }\n\nexport function ActionButton({\n  action,\n  stateKey,\n  size = \"default\",\n  className,\n  fallbackStyle = \"outline\",\n}: {\n  action: FableAction\n  stateKey: string\n  size?: \"sm\" | \"default\" | \"lg\"\n  className?: string\n  fallbackStyle?: keyof typeof variants\n}) {\n  const { onReply, actions, readOnly } = useFable()\n  const { copied, copy } = useCopy()\n  const [done, setDone] = React.useState(false)\n  const [host, setHost] = useFableState<HostState>(`${stateKey}:host`, { status: \"idle\" })\n  const variant = variants[action.style ?? fallbackStyle]\n  const Icon = action.icon ? ICONS[action.icon] : null\n  const icon = Icon ? <Icon data-icon=\"inline-start\" aria-hidden /> : null\n  const press = \"transition-[scale,background-color,color] active:scale-[0.96]\"\n\n  if (action.type === \"link\") {\n    const href = safeLinkUrl(action.url)\n    if (!href) return null\n    return (\n      <Button asChild variant={variant} size={size} className={cn(press, className)}>\n        <a href={href} target=\"_blank\" rel=\"noopener noreferrer nofollow\">\n          {icon}\n          {action.label}\n          {!Icon ? <ExternalLinkIcon data-icon=\"inline-end\" className=\"opacity-60\" aria-hidden /> : null}\n        </a>\n      </Button>\n    )\n  }\n\n  if (action.type === \"copy\") {\n    return (\n      <Button variant={variant} size={size} className={cn(press, className)} onClick={() => void copy(action.text)}>\n        <SwapIcon swapped={copied} from={Icon ?? CopyIcon} to={CheckIcon} />\n        {copied ? \"Copied\" : action.label}\n      </Button>\n    )\n  }\n\n  if (action.type === \"download\") {\n    return (\n      <Button\n        variant={variant}\n        size={size}\n        className={cn(press, className)}\n        onClick={() => {\n          downloadText(action.filename, action.content, action.mimeType)\n          setDone(true)\n          setTimeout(() => setDone(false), 1600)\n        }}\n      >\n        <SwapIcon swapped={done} from={Icon ?? DownloadIcon} to={CheckIcon} />\n        {done ? \"Downloaded\" : action.label}\n      </Button>\n    )\n  }\n\n  if (action.type === \"reply\") {\n    const button = (\n      <Button\n        variant={variant}\n        size={size}\n        className={cn(press, className)}\n        disabled={!onReply || readOnly}\n        onClick={() => onReply?.(action.message)}\n      >\n        {icon}\n        {action.label}\n      </Button>\n    )\n    return button\n  }\n\n  const handler = actions?.[action.action]\n  if (!handler) {\n    return (\n      <Tooltip>\n        <TooltipTrigger asChild>\n          <span tabIndex={0} className=\"inline-flex rounded-2xl outline-none focus-visible:ring-2 focus-visible:ring-ring/40\">\n            <Button variant={variant} size={size} disabled className={className}>\n              {icon}\n              {action.label}\n            </Button>\n          </span>\n        </TooltipTrigger>\n        <TooltipContent>This app has not enabled “{action.action}”.</TooltipContent>\n      </Tooltip>\n    )\n  }\n\n  const run = async () => {\n    setHost({ status: \"running\" })\n    try {\n      const note = await handler.run(action.payload ?? {})\n      setHost({ status: \"done\", note: typeof note === \"string\" ? note : \"Done\" })\n    } catch (error) {\n      setHost({ status: \"error\", note: error instanceof Error ? error.message : \"Something went wrong\" })\n    }\n  }\n\n  if (host.status === \"confirm\") {\n    return (\n      <div className=\"flex flex-wrap items-center gap-2\" role=\"group\" aria-label=\"Confirm action\">\n        <span className=\"text-sm text-muted-foreground\">{handler.confirm}</span>\n        <Button size={size} className={press} onClick={() => void run()} autoFocus>\n          Confirm\n        </Button>\n        <Button size={size} variant=\"ghost\" onClick={() => setHost({ status: \"idle\" })}>\n          Cancel\n        </Button>\n      </div>\n    )\n  }\n\n  return (\n    <span className=\"inline-flex flex-wrap items-center gap-2\">\n      <Button\n        variant={variant}\n        size={size}\n        className={cn(press, className)}\n        disabled={readOnly || host.status === \"running\" || host.status === \"done\"}\n        onClick={() => (handler.confirm ? setHost({ status: \"confirm\" }) : void run())}\n      >\n        {host.status === \"running\" ? (\n          <Loader2Icon data-icon=\"inline-start\" className=\"animate-spin\" aria-hidden />\n        ) : host.status === \"done\" ? (\n          <CheckIcon data-icon=\"inline-start\" aria-hidden />\n        ) : (\n          icon\n        )}\n        {action.label}\n      </Button>\n      {host.note ? (\n        <span\n          role=\"status\"\n          className={cn(\"text-xs\", host.status === \"error\" ? \"text-destructive\" : \"text-muted-foreground\")}\n        >\n          {host.note}\n        </span>\n      ) : null}\n    </span>\n  )\n}\n\nexport function ActionsBlock({ block, stateKey }: { block: BlockOf<\"actions\">; stateKey: string }) {\n  return (\n    <div className=\"flex flex-wrap items-center gap-2\">\n      {block.items.map((action, index) => (\n        <ActionButton\n          key={index}\n          action={action}\n          stateKey={`${stateKey}.${index}`}\n          fallbackStyle={index === 0 && block.items.length > 1 ? \"primary\" : \"outline\"}\n        />\n      ))}\n    </div>\n  )\n}\n",
      "type": "registry:component",
      "target": "components/fable-ui/blocks/actions.tsx"
    },
    {
      "path": "components/fable-ui/blocks/skeleton.tsx",
      "content": "import { cn } from \"@/lib/utils\"\n\nimport { surface } from \"./shared\"\n\nfunction Bar({ className }: { className?: string }) {\n  return <span className={cn(\"block rounded-full bg-muted motion-safe:animate-pulse\", className)} />\n}\n\nconst lines = (count: number) =>\n  Array.from({ length: count }, (_, index) => (\n    <Bar key={index} className={cn(\"h-3\", index === count - 1 ? \"w-3/5\" : index % 2 ? \"w-11/12\" : \"w-full\")} />\n  ))\n\n/**\n * Placeholders shaped like the block that is still streaming, sized to its\n * usual footprint so the answer does not jump when the block lands.\n */\nexport function BlockSkeleton({ type }: { type?: string }) {\n  const frame = cn(surface, \"p-4 @lg:p-5\")\n  let body: React.ReactNode\n\n  switch (type) {\n    case \"image\":\n      body = <span className=\"block aspect-[16/9] rounded-xl bg-muted motion-safe:animate-pulse\" />\n      break\n    case \"gallery\":\n      body = (\n        <div className=\"grid grid-cols-3 gap-2\">\n          {Array.from({ length: 6 }, (_, index) => (\n            <span key={index} className=\"aspect-square rounded-lg bg-muted motion-safe:animate-pulse\" />\n          ))}\n        </div>\n      )\n      break\n    case \"hero\":\n      body = <span className=\"block h-80 rounded-2xl bg-muted motion-safe:animate-pulse\" />\n      break\n    case \"chart\":\n      body = (\n        <div className={frame}>\n          <Bar className=\"mb-5 h-3.5 w-40\" />\n          <div className=\"flex h-56 items-end gap-3\">\n            {[40, 65, 52, 80, 58, 90, 70].map((height, index) => (\n              <span key={index} className=\"flex-1 rounded-t-md bg-muted motion-safe:animate-pulse\" style={{ height: `${height}%` }} />\n            ))}\n          </div>\n        </div>\n      )\n      break\n    case \"form\":\n    case \"email\":\n    case \"template\":\n      body = (\n        <div className={cn(frame, \"space-y-4\")}>\n          <Bar className=\"h-3.5 w-48\" />\n          {[0, 1, 2].map((index) => (\n            <div key={index} className=\"space-y-2\">\n              <Bar className=\"h-2.5 w-24\" />\n              <span className=\"block h-8 rounded-2xl bg-muted motion-safe:animate-pulse\" />\n            </div>\n          ))}\n          <span className=\"block h-24 rounded-2xl bg-muted motion-safe:animate-pulse\" />\n        </div>\n      )\n      break\n    case \"cards\":\n      body = (\n        <div className=\"grid gap-3 @lg:grid-cols-2\">\n          {[0, 1].map((index) => (\n            <div key={index} className={cn(surface, \"space-y-3 p-1.5 pb-4\")}>\n              <span className=\"block aspect-[4/3] rounded-lg bg-muted motion-safe:animate-pulse\" />\n              <div className=\"space-y-2 px-2.5\">{lines(2)}</div>\n            </div>\n          ))}\n        </div>\n      )\n      break\n    case \"metrics\":\n      body = (\n        <div className={cn(surface, \"grid grid-cols-2 gap-4 p-5 @lg:grid-cols-4\")}>\n          {[0, 1, 2, 3].map((index) => (\n            <div key={index} className=\"space-y-2.5\">\n              <Bar className=\"h-2.5 w-16\" />\n              <Bar className=\"h-6 w-24\" />\n            </div>\n          ))}\n        </div>\n      )\n      break\n    case \"table\":\n      body = (\n        <div className={cn(surface, \"space-y-3 p-4\")}>\n          <Bar className=\"h-3.5 w-40\" />\n          {Array.from({ length: 5 }, (_, index) => (\n            <div key={index} className=\"flex gap-4\">\n              <Bar className=\"h-3 flex-[2]\" />\n              <Bar className=\"h-3 flex-1\" />\n              <Bar className=\"h-3 flex-1\" />\n            </div>\n          ))}\n        </div>\n      )\n      break\n    case \"actions\":\n      body = (\n        <div className=\"flex gap-2\">\n          <span className=\"h-8 w-28 rounded-2xl bg-muted motion-safe:animate-pulse\" />\n          <span className=\"h-8 w-24 rounded-2xl bg-muted motion-safe:animate-pulse\" />\n        </div>\n      )\n      break\n    case \"file\":\n      body = <span className=\"block h-16 rounded-xl bg-muted motion-safe:animate-pulse\" />\n      break\n    default:\n      body = <div className=\"space-y-2.5 py-1\">{lines(3)}</div>\n  }\n\n  return (\n    <div role=\"status\" aria-label=\"Loading\" data-fable-skeleton={type ?? \"block\"}>\n      {body}\n    </div>\n  )\n}\n",
      "type": "registry:component",
      "target": "components/fable-ui/blocks/skeleton.tsx"
    }
  ],
  "type": "registry:block"
}