@copilotkit/react-core 2.0.0-rc.43 → 2.0.0-rc.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{MarkdownRendererContext-C2J_lgqF.d.cts → MarkdownRendererContext-QFCldfW_.d.cts} +1 -1
- package/dist/{MarkdownRendererContext-C2J_lgqF.d.cts.map → MarkdownRendererContext-QFCldfW_.d.cts.map} +1 -1
- package/dist/{MarkdownRendererContext-CytkPOAJ.d.mts → MarkdownRendererContext-aK63ZFd-.d.mts} +1 -1
- package/dist/{MarkdownRendererContext-CytkPOAJ.d.mts.map → MarkdownRendererContext-aK63ZFd-.d.mts.map} +1 -1
- package/dist/{MarkdownSurfaces-DytbRzj2.cjs → MarkdownSurfaces-Do948N1P.cjs} +2 -2
- package/dist/{MarkdownSurfaces-DytbRzj2.cjs.map → MarkdownSurfaces-Do948N1P.cjs.map} +1 -1
- package/dist/{MarkdownSurfaces-DlYqJkAE.mjs → MarkdownSurfaces-rtE9wRUP.mjs} +2 -2
- package/dist/{MarkdownSurfaces-DlYqJkAE.mjs.map → MarkdownSurfaces-rtE9wRUP.mjs.map} +1 -1
- package/dist/{ProviderMarkdown-i_i2osOH.cjs → ProviderMarkdown-D0eI0aPo.cjs} +23 -1
- package/dist/ProviderMarkdown-D0eI0aPo.cjs.map +1 -0
- package/dist/{ProviderMarkdown-BZaPDROY.mjs → ProviderMarkdown-epL7F3Vt.mjs} +19 -3
- package/dist/ProviderMarkdown-epL7F3Vt.mjs.map +1 -0
- package/dist/accessibility-BLK-gE0R.mjs.map +1 -1
- package/dist/accessibility-GnodqxkH.cjs.map +1 -1
- package/dist/chat-BZ_bvAkg.d.mts +38 -0
- package/dist/chat-BZ_bvAkg.d.mts.map +1 -0
- package/dist/chat-CpZVyF_t.d.cts +38 -0
- package/dist/chat-CpZVyF_t.d.cts.map +1 -0
- package/dist/generative-ui/map.cjs +26 -0
- package/dist/generative-ui/map.cjs.map +1 -0
- package/dist/generative-ui/map.d.cts +23 -0
- package/dist/generative-ui/map.d.cts.map +1 -0
- package/dist/generative-ui/map.d.mts +23 -0
- package/dist/generative-ui/map.d.mts.map +1 -0
- package/dist/generative-ui/map.mjs +24 -0
- package/dist/generative-ui/map.mjs.map +1 -0
- package/dist/generative-ui/native.d.cts +3 -2
- package/dist/generative-ui/native.d.cts.map +1 -1
- package/dist/generative-ui/native.d.mts +3 -2
- package/dist/generative-ui/native.d.mts.map +1 -1
- package/dist/generative-ui.cjs +2 -2
- package/dist/generative-ui.d.cts +5 -4
- package/dist/generative-ui.d.cts.map +1 -1
- package/dist/generative-ui.d.mts +5 -4
- package/dist/generative-ui.d.mts.map +1 -1
- package/dist/generative-ui.mjs +2 -2
- package/dist/{hooks-DqsOIh8A.d.mts → hooks-D2H3iL0N.d.mts} +2 -2
- package/dist/{hooks-DqsOIh8A.d.mts.map → hooks-D2H3iL0N.d.mts.map} +1 -1
- package/dist/{hooks-2Ur8NQhj.d.cts → hooks-Dy8HeEdr.d.cts} +2 -2
- package/dist/{hooks-2Ur8NQhj.d.cts.map → hooks-Dy8HeEdr.d.cts.map} +1 -1
- package/dist/index.cjs +12 -26
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -3
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +4 -3
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +11 -25
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +44 -21
- package/dist/index.umd.js.map +1 -1
- package/dist/{chat-C5XWeO1M.d.mts → runtime-context-B7f4M85q.d.mts} +21 -39
- package/dist/runtime-context-B7f4M85q.d.mts.map +1 -0
- package/dist/{chat-DtHs4alO.d.cts → runtime-context-CIkZS0ap.d.cts} +21 -39
- package/dist/runtime-context-CIkZS0ap.d.cts.map +1 -0
- package/dist/{standard-s8jByRiE.mjs → standard-CSBR4FhM.mjs} +31 -15
- package/dist/standard-CSBR4FhM.mjs.map +1 -0
- package/dist/{standard-CqGTZUZy.cjs → standard-DBjcBGyd.cjs} +31 -15
- package/dist/standard-DBjcBGyd.cjs.map +1 -0
- package/package.json +14 -7
- package/dist/ProviderMarkdown-BZaPDROY.mjs.map +0 -1
- package/dist/ProviderMarkdown-i_i2osOH.cjs.map +0 -1
- package/dist/chat-C5XWeO1M.d.mts.map +0 -1
- package/dist/chat-DtHs4alO.d.cts.map +0 -1
- package/dist/standard-CqGTZUZy.cjs.map +0 -1
- package/dist/standard-s8jByRiE.mjs.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"standard-CqGTZUZy.cjs","names":["ON_ACCENT","useGenerativeUIAccessibility","BACKDROP","SHADOW_MD","noEffect","useInjectEffect","React","STANDARD_STYLE_ID","STANDARD_CSS","VISUALLY_HIDDEN","React","ProviderMarkdown","ALIGN_CSS","SHADOW_SM","INNER_PANEL_BG","useGenerativeUIAccessibility","SHADOW_MD","SHADOW_SOFT","layoutDeclarations","px","ICON_PX","IconSvg","useGenerativeUIAccessibility","ON_ACCENT","mediaDeclarations","FONT_WEIGHT","SHADOW_MD","useGenerativeUIRuntime","GenerativeUINodeContext","ACCENT","ON_ACCENT","compositeDeclarations","SHADOW_MD","CHART_CURSOR","CHART_PALETTE","React","FONT_WEIGHT","Suspense","noEffect","useInjectEffect","useInsertionEffect","useRequiredGenerativeUIRuntime","FONT_WEIGHT","FONT_WEIGHT","Caption","useGenerativeUIAccessibility","dataDeclarations","React","useGenerativeUIAccessibility","SHADOW_MD","useGenerativeUIRuntime","BACKDROP","feedbackDeclarations","FONT_WEIGHT","useGenerativeUIAccessibility","ACCENT","ON_ACCENT","SHADOW_XS","inputDeclarations","FONT_WEIGHT","useGenerativeUIAccessibility","React","ON_ACCENT","SHADOW_MD","textDeclarations","createGenerativeUI","STANDARD_CATALOG_ID"],"sources":["../src/generative-ui/standard/overlay-stack.ts","../src/generative-ui/standard/lightbox.tsx","../src/generative-ui/standard/styles.ts","../src/generative-ui/standard/markdown.tsx","../src/generative-ui/standard/layout.tsx","../src/generative-ui/standard/media.tsx","../src/generative-ui/standard/composites.tsx","../src/generative-ui/standard/Chart.tsx","../src/generative-ui/standard/Map.tsx","../src/generative-ui/standard/data.tsx","../src/generative-ui/standard/feedback.tsx","../src/generative-ui/standard/checks.ts","../src/generative-ui/standard/inputs.tsx","../src/generative-ui/standard/text.tsx","../src/generative-ui/standard/index.ts"],"sourcesContent":["import { useEffect } from \"react\";\n\n/**\n * The open overlays (Modal dialogs, Lightboxes), newest last. One document\n * listener closes the newest one on Escape, so a Lightbox inside a Modal\n * closes alone, and the Modal only on the next Escape. Each overlay used to\n * listen on `document` itself, and `stopPropagation` does not stop the\n * other listeners of the same target.\n */\nconst overlays: Array<() => void> = [];\nlet detach: (() => void) | undefined;\n\nfunction onKeyDown(event: KeyboardEvent) {\n if (event.key !== \"Escape\" || overlays.length === 0) return;\n event.stopPropagation();\n overlays[overlays.length - 1]!();\n}\n\n/**\n * Registers `close` as the newest overlay for as long as `isOpen`. The\n * overlay closes on Escape only while it is the newest.\n */\nexport function useOverlayEscape(isOpen: boolean, close: () => void) {\n useEffect(() => {\n if (!isOpen) return;\n const handler = () => close();\n overlays.push(handler);\n if (!detach) {\n document.addEventListener(\"keydown\", onKeyDown);\n detach = () => document.removeEventListener(\"keydown\", onKeyDown);\n }\n return () => {\n const index = overlays.lastIndexOf(handler);\n if (index !== -1) overlays.splice(index, 1);\n if (overlays.length === 0 && detach) {\n detach();\n detach = undefined;\n }\n };\n }, [isOpen, close]);\n}\n","import React, { useCallback, useEffect, useRef, useState } from \"react\";\nimport type { CSSProperties } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { useGenerativeUIAccessibility, wrapperAria } from \"../accessibility\";\nimport { useOverlayEscape } from \"./overlay-stack\";\nimport {\n BACKDROP,\n ON_ACCENT,\n SHADOW_MD,\n radius,\n} from \"@copilotkit/shared/generative-ui\";\n\nexport interface LightboxImage {\n src: string;\n alt?: string;\n}\n\nconst LIGHTBOX_BUTTON: CSSProperties = {\n position: \"absolute\",\n border: \"none\",\n borderRadius: 9999,\n background: \"rgba(255,255,255,.15)\",\n color: ON_ACCENT,\n cursor: \"pointer\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n};\n\n/**\n * A full-screen view of one or more images. A click, Escape or the close\n * button closes it. With several images, the arrows and the arrow keys move\n * between them. Image, ImageGrid and CarouselMediaItem open it.\n */\nexport function Lightbox({\n images,\n index = 0,\n onClose,\n}: {\n images: LightboxImage[];\n index?: number;\n onClose: () => void;\n}) {\n const [current, setCurrent] = useState(index);\n // A portal: the hidden state and the live region of the image's envelope\n // do not reach it from the engine's wrapper.\n const aria = useGenerativeUIAccessibility();\n const count = images.length;\n const step = (delta: number) =>\n setCurrent((i) => (count === 0 ? 0 : (i + delta + count) % count));\n // Escape goes through the overlay stack, so a lightbox inside a Modal\n // closes alone. The close is stable, so a re-render keeps the order.\n const closeRef = useRef(onClose);\n closeRef.current = onClose;\n const close = useCallback(() => closeRef.current(), []);\n useOverlayEscape(true, close);\n useEffect(() => {\n const onKey = (event: KeyboardEvent) => {\n if (event.key === \"ArrowRight\" && count > 1) step(1);\n else if (event.key === \"ArrowLeft\" && count > 1) step(-1);\n };\n document.addEventListener(\"keydown\", onKey);\n return () => document.removeEventListener(\"keydown\", onKey);\n }, [count]);\n if (typeof document === \"undefined\") return null;\n const image = images[Math.min(current, count - 1)];\n if (!image) return null;\n const alt = image.alt ?? \"\";\n const arrow = (delta: -1 | 1) => (\n <button\n type=\"button\"\n aria-label={delta < 0 ? \"Previous image\" : \"Next image\"}\n data-a2ui-lightbox-arrow={delta < 0 ? \"prev\" : \"next\"}\n onClick={(event) => {\n event.stopPropagation();\n step(delta);\n }}\n style={{\n ...LIGHTBOX_BUTTON,\n top: \"50%\",\n [delta < 0 ? \"left\" : \"right\"]: 16,\n transform: \"translateY(-50%)\",\n width: 44,\n height: 44,\n fontSize: 28,\n lineHeight: 1,\n }}\n >\n {delta < 0 ? \"‹\" : \"›\"}\n </button>\n );\n return createPortal(\n <div\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label={alt || \"Image\"}\n {...wrapperAria(aria)}\n data-a2ui-lightbox=\"\"\n onClick={onClose}\n style={{\n position: \"fixed\",\n inset: 0,\n zIndex: 1000,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n padding: 24,\n background: BACKDROP,\n cursor: \"zoom-out\",\n }}\n >\n <img\n key={image.src}\n src={image.src}\n alt={alt}\n style={{\n maxWidth: \"min(92vw, 1400px)\",\n maxHeight: \"92vh\",\n objectFit: \"contain\",\n borderRadius: radius(\"md\"),\n boxShadow: SHADOW_MD,\n }}\n />\n {count > 1 ? (\n <span\n data-a2ui-lightbox-counter=\"\"\n style={{\n position: \"absolute\",\n bottom: 16,\n left: \"50%\",\n transform: \"translateX(-50%)\",\n color: ON_ACCENT,\n fontSize: 13,\n opacity: 0.8,\n }}\n >\n {current + 1} / {count}\n </span>\n ) : null}\n {count > 1 ? arrow(-1) : null}\n {count > 1 ? arrow(1) : null}\n <button\n type=\"button\"\n aria-label=\"Close\"\n onClick={onClose}\n style={{\n ...LIGHTBOX_BUTTON,\n top: 16,\n right: 16,\n width: 36,\n height: 36,\n fontSize: 20,\n lineHeight: 1,\n }}\n >\n ×\n </button>\n </div>,\n document.body,\n );\n}\n\n/** Opens a URL in a new tab. An unsafe scheme (javascript:, data:) is ignored. */\nexport function openUrl(href: string | undefined) {\n if (!href || typeof window === \"undefined\") return;\n const trimmed = href.trim();\n if (!/^(https?:|mailto:)/i.test(trimmed)) return;\n window.open(trimmed, \"_blank\", \"noopener,noreferrer\");\n}\n","import React from \"react\";\nimport {\n STANDARD_CSS,\n STANDARD_STYLE_ID,\n} from \"@copilotkit/shared/generative-ui\";\n\n// There is no document on the server, so nothing is added there.\nconst noEffect: typeof React.useInsertionEffect = () => {};\nconst useInjectEffect =\n typeof document === \"undefined\" ? noEffect : React.useInsertionEffect;\n\n/**\n * Adds the standard stylesheet to the document once. Every standard\n * component calls it, so a host does not have to import a CSS file.\n */\nexport function useStandardStyles() {\n useInjectEffect(() => {\n if (document.getElementById(STANDARD_STYLE_ID)) return;\n const style = document.createElement(\"style\");\n style.id = STANDARD_STYLE_ID;\n style.textContent = STANDARD_CSS;\n document.head.appendChild(style);\n }, []);\n}\n","import React from \"react\";\nimport type { CSSProperties, ReactNode } from \"react\";\nimport { ProviderMarkdown } from \"../markdown/ProviderMarkdown\";\nimport { useStandardStyles } from \"./styles\";\n\n// ---- Links ----\n\nconst SAFE_URL = /^(https?:|mailto:)/i;\n\n/** The trimmed URL when it is http, https or mailto. Else `undefined`. */\nexport function safeHref(url: string) {\n const trimmed = url.trim();\n return SAFE_URL.test(trimmed) ? trimmed : undefined;\n}\n\n/** Hides text on screen but keeps it for screen readers. */\nconst VISUALLY_HIDDEN: CSSProperties = {\n position: \"absolute\",\n width: 1,\n height: 1,\n padding: 0,\n margin: -1,\n overflow: \"hidden\",\n clipPath: \"inset(50%)\",\n whiteSpace: \"nowrap\",\n border: 0,\n};\n\ninterface ExternalLinkProps {\n /** A safe URL. Get it from `safeHref`. */\n href: string;\n title?: string;\n style?: CSSProperties;\n children: ReactNode;\n}\n\n/**\n * A link that opens in a new tab. Screen readers also hear that it opens a\n * new tab.\n */\nexport function ExternalLink({\n href,\n title,\n style,\n children,\n}: ExternalLinkProps) {\n return (\n <a\n href={href}\n title={title}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n style={style}\n >\n {children}\n <span style={VISUALLY_HIDDEN}> (opens in a new tab)</span>\n </a>\n );\n}\n\n// ---- Inline markdown ----\n\ntype Wrap = \"strong\" | \"em\" | \"s\" | \"u\" | \"code\";\n\nconst DELIMITERS: Array<{ open: string; tag: Wrap }> = [\n { open: \"**\", tag: \"strong\" },\n { open: \"~~\", tag: \"s\" },\n { open: \"++\", tag: \"u\" },\n { open: \"`\", tag: \"code\" },\n { open: \"*\", tag: \"em\" },\n { open: \"_\", tag: \"em\" },\n];\n\n/** The link that starts at `start` (`[label](url)`), or `null`. */\nfunction matchLink(text: string, start: number) {\n if (text[start] !== \"[\") return null;\n const close = text.indexOf(\"](\", start + 1);\n if (close < 0) return null;\n const end = text.indexOf(\")\", close + 2);\n if (end < 0) return null;\n // One level of balanced parentheses can be in the URL, e.g. \"alert(1)\".\n let urlEnd = end;\n const inner = text.slice(close + 2, end);\n if (inner.includes(\"(\")) {\n const next = text.indexOf(\")\", end + 1);\n if (next < 0) return null;\n urlEnd = next;\n }\n return {\n label: text.slice(start + 1, close),\n url: text.slice(close + 2, urlEnd),\n next: urlEnd + 1,\n };\n}\n\n/**\n * Renders a small set of inline markdown: `**bold**`, `*italic*` and\n * `_italic_`, `~~strike~~`, `++underline++`, `` `code` `` and\n * `[label](url)`.\n *\n * - A marker without a closing partner stays literal text.\n * - A link is a link only for http, https and mailto URLs. For other URLs,\n * only the label shows.\n * - Marks do not nest.\n *\n * @param text - The source text.\n */\nexport function renderInlineMarkdown(text: string) {\n if (!text) return text;\n const out: ReactNode[] = [];\n let buffer = \"\";\n let key = 0;\n const flush = () => {\n if (buffer) out.push(buffer);\n buffer = \"\";\n };\n\n let index = 0;\n while (index < text.length) {\n const link = matchLink(text, index);\n if (link) {\n flush();\n const href = safeHref(link.url);\n out.push(\n href ? (\n <ExternalLink key={key++} href={href}>\n {link.label}\n </ExternalLink>\n ) : (\n <React.Fragment key={key++}>{link.label}</React.Fragment>\n ),\n );\n index = link.next;\n continue;\n }\n\n const delimiter = DELIMITERS.find((d) => text.startsWith(d.open, index));\n // An underscore inside a word (snake_case) is not emphasis.\n const isIntraWordUnderscore =\n delimiter?.open === \"_\" && /\\w/.test(text[index - 1] ?? \"\");\n if (delimiter && !isIntraWordUnderscore) {\n const start = index + delimiter.open.length;\n const end = text.indexOf(delimiter.open, start);\n const inner = end > start ? text.slice(start, end) : \"\";\n // Emphasis must touch its content (\"a * b * c\" stays literal).\n const isMark =\n inner !== \"\" && (delimiter.tag === \"code\" || inner.trim() === inner);\n if (isMark) {\n flush();\n const Tag = delimiter.tag;\n out.push(<Tag key={key++}>{inner}</Tag>);\n index = end + delimiter.open.length;\n continue;\n }\n buffer += delimiter.open;\n index = start;\n continue;\n }\n\n buffer += text[index];\n index += 1;\n }\n flush();\n return out.length === 1 && typeof out[0] === \"string\" ? out[0] : out;\n}\n\n// ---- Block markdown ----\n\ntype Block =\n | { kind: \"heading\"; level: number; text: string }\n | { kind: \"paragraph\"; text: string }\n | { kind: \"list\"; ordered: boolean; items: string[] }\n | { kind: \"quote\"; text: string }\n | { kind: \"code\"; text: string; language?: string }\n | { kind: \"rule\" };\n\nconst HEADING = /^(#{1,6})\\s+(.*)$/;\nconst BULLET = /^\\s*[-*+]\\s+(.*)$/;\nconst NUMBERED = /^\\s*\\d+[.)]\\s+(.*)$/;\nconst QUOTE = /^\\s*>\\s?(.*)$/;\nconst RULE = /^\\s*([-*_])(\\s*\\1){2,}\\s*$/;\nconst FENCE = /^\\s*```\\s*(\\S*)\\s*$/;\nconst HEADING_TAGS = [\"h1\", \"h2\", \"h3\", \"h4\", \"h5\", \"h6\"] as const;\n\nconst listItem = (line: string) => BULLET.exec(line) ?? NUMBERED.exec(line);\n\n/**\n * Splits markdown into blocks: headings, paragraphs, bullet and numbered\n * lists, block quotes, fenced code and horizontal rules. The lines of a\n * paragraph join with a space. Other markdown is paragraph text.\n *\n * @param source - The markdown source.\n */\nexport function parseBlockMarkdown(source: string) {\n const lines = source.replace(/\\r\\n?/g, \"\\n\").split(\"\\n\");\n const blocks: Block[] = [];\n const paragraph: string[] = [];\n const flushParagraph = () => {\n if (paragraph.length) {\n blocks.push({ kind: \"paragraph\", text: paragraph.join(\" \") });\n }\n paragraph.length = 0;\n };\n let index = 0;\n while (index < lines.length) {\n const line = lines[index]!;\n const fence = FENCE.exec(line);\n if (fence) {\n flushParagraph();\n const code: string[] = [];\n index++;\n while (index < lines.length && !FENCE.test(lines[index]!)) {\n code.push(lines[index++]!);\n }\n index++; // The closing fence, or the end of the input.\n blocks.push({\n kind: \"code\",\n text: code.join(\"\\n\"),\n ...(fence[1] ? { language: fence[1] } : {}),\n });\n continue;\n }\n if (line.trim() === \"\") {\n flushParagraph();\n index++;\n continue;\n }\n const heading = HEADING.exec(line);\n if (heading) {\n flushParagraph();\n blocks.push({\n kind: \"heading\",\n level: heading[1]!.length,\n text: heading[2]!,\n });\n index++;\n continue;\n }\n if (RULE.test(line)) {\n flushParagraph();\n blocks.push({ kind: \"rule\" });\n index++;\n continue;\n }\n if (listItem(line)) {\n flushParagraph();\n const ordered = NUMBERED.test(line);\n const items: string[] = [];\n while (index < lines.length) {\n const item = listItem(lines[index]!);\n if (!item || NUMBERED.test(lines[index]!) !== ordered) break;\n items.push(item[1]!);\n index++;\n }\n blocks.push({ kind: \"list\", ordered, items });\n continue;\n }\n if (QUOTE.test(line)) {\n flushParagraph();\n const quoted: string[] = [];\n let quote = QUOTE.exec(lines[index] ?? \"\");\n while (quote) {\n quoted.push(quote[1]!);\n index++;\n quote = QUOTE.exec(lines[index] ?? \"\");\n }\n blocks.push({ kind: \"quote\", text: quoted.join(\" \") });\n continue;\n }\n paragraph.push(line.trim());\n index++;\n }\n flushParagraph();\n return blocks;\n}\n\n/**\n * Renders markdown without a dependency: the blocks of\n * `parseBlockMarkdown`, with `renderInlineMarkdown` for the text in them.\n *\n * @param source - The markdown source.\n */\nexport function renderBlockMarkdown(source: string) {\n const blocks = parseBlockMarkdown(source);\n return blocks.map((block, key) => {\n switch (block.kind) {\n case \"heading\": {\n const Tag = HEADING_TAGS[block.level - 1];\n // HEADING matches 1 to 6 \"#\", so a parsed level always has a tag.\n if (Tag === undefined) {\n throw new Error(`markdown: no tag for heading level ${block.level}`);\n }\n return <Tag key={key}>{renderInlineMarkdown(block.text)}</Tag>;\n }\n case \"paragraph\":\n return <p key={key}>{renderInlineMarkdown(block.text)}</p>;\n case \"list\": {\n const Tag = block.ordered ? \"ol\" : \"ul\";\n return (\n <Tag key={key}>\n {block.items.map((item, itemKey) => (\n <li key={itemKey}>{renderInlineMarkdown(item)}</li>\n ))}\n </Tag>\n );\n }\n case \"quote\":\n return (\n <blockquote key={key}>{renderInlineMarkdown(block.text)}</blockquote>\n );\n case \"code\":\n return (\n <pre key={key}>\n <code data-language={block.language}>{block.text}</code>\n </pre>\n );\n case \"rule\":\n return <hr key={key} />;\n }\n });\n}\n\n// ---- Markdown component ----\n\ninterface MarkdownProps {\n text: string;\n streaming?: boolean;\n}\n\n/**\n * Full GitHub-flavored markdown, rendered with the same markdown renderer\n * as the chat messages. It has no typography of its own, so it reads like\n * the chat text around the surface. While `streaming` is true, the renderer\n * handles markdown that is not complete yet.\n */\nexport function Markdown({ text, streaming = false }: MarkdownProps) {\n useStandardStyles();\n return (\n <div className=\"a2ui-markdown\" data-a2ui-std=\"\">\n <ProviderMarkdown content={text} isStreaming={streaming} />\n </div>\n );\n}\n","import React, {\n createContext,\n useContext,\n useEffect,\n useId,\n useLayoutEffect,\n useRef,\n useState,\n} from \"react\";\nimport type {\n CSSProperties,\n KeyboardEvent,\n MouseEvent,\n ReactNode,\n} from \"react\";\nimport type { z } from \"zod\";\nimport type { GenerativeUIInvokeResult } from \"@copilotkit/shared/generative-ui\";\nimport {\n INNER_PANEL_BG,\n SHADOW_MD,\n SHADOW_SM,\n SHADOW_SOFT,\n backgroundColor,\n borderColor,\n layoutDeclarations,\n panelBackground,\n radius,\n spacing,\n textColor,\n withComponents,\n} from \"@copilotkit/shared/generative-ui\";\nimport type {\n ALIGN,\n CAROUSEL_MEDIA_SIZES,\n JUSTIFY,\n LayoutProps,\n NO_ARGS,\n boxSchema,\n cardSchema,\n carouselMediaItemSchema,\n carouselSchema,\n dividerSchema,\n flowItemSchema,\n flowSchema,\n gridItemSchema,\n gridSchema,\n spacerSchema,\n tabsSchema,\n} from \"@copilotkit/shared/generative-ui\";\nimport { Lightbox, openUrl } from \"./lightbox\";\nimport type { LightboxImage } from \"./lightbox\";\nimport { namedRole, useGenerativeUIAccessibility } from \"../accessibility\";\nimport { useStandardStyles } from \"./styles\";\n\ntype EventProp = (\n args: z.input<typeof NO_ARGS>,\n) => Promise<GenerativeUIInvokeResult>;\n\ntype WithEvents<Props> = Props & { onVisible?: EventProp };\n\ntype WithChildren<Props> = WithEvents<Props> & { children?: ReactNode };\n\ntype BoxProps = z.output<typeof boxSchema>;\ntype GridProps = z.output<typeof gridSchema>;\ntype GridItemProps = z.output<typeof gridItemSchema>;\ntype CardProps = z.output<typeof cardSchema>;\ntype FlowProps = z.output<typeof flowSchema>;\ntype FlowItemProps = z.output<typeof flowItemSchema>;\ntype CarouselProps = z.output<typeof carouselSchema> & {\n /** From the engine: `activeIndex` is writable. */\n setActiveIndex: (value: number) => void;\n};\ntype CarouselMediaItemProps = z.output<typeof carouselMediaItemSchema> & {\n onClick?: EventProp;\n};\n\n// ---- Style helpers ----\n\nconst ALIGN_CSS: Record<(typeof ALIGN)[number], string> = {\n start: \"flex-start\",\n end: \"flex-end\",\n center: \"center\",\n baseline: \"baseline\",\n stretch: \"stretch\",\n};\nconst JUSTIFY_CSS: Record<(typeof JUSTIFY)[number], string> = {\n start: \"flex-start\",\n end: \"flex-end\",\n center: \"center\",\n spaceBetween: \"space-between\",\n spaceAround: \"space-around\",\n spaceEvenly: \"space-evenly\",\n stretch: \"stretch\",\n};\n\n/** The CSS of a `radius` prop: one radius, or one for each corner. */\nexport function radiusStyle(value: LayoutProps[\"radius\"]) {\n if (typeof value === \"string\" || typeof value === \"number\") {\n return { borderRadius: radius(value) };\n }\n if (value === undefined) return {};\n return {\n borderTopLeftRadius: radius(value.topLeft),\n borderTopRightRadius: radius(value.topRight),\n borderBottomLeftRadius: radius(value.bottomLeft),\n borderBottomRightRadius: radius(value.bottomRight),\n };\n}\n\n/**\n * Removes the undefined entries, so a later spread never erases a value. An\n * undefined longhand next to a shorthand is a removal in React: clearing\n * `row-gap` resets the `gap` shorthand in real browsers (jsdom does not\n * model this).\n */\nexport function defined(style: CSSProperties) {\n return Object.fromEntries(\n Object.entries(style).filter(([, value]) => value !== undefined),\n );\n}\n\n/** The CSS of the shared layout props. An unset prop gives no CSS. */\nexport function layoutStyle(props: LayoutProps) {\n const overflow = props.scrollable\n ? \"auto\"\n : props.clip\n ? \"hidden\"\n : undefined;\n return defined({\n display: props.inline ? \"inline-flex\" : \"flex\",\n alignItems: props.align ? ALIGN_CSS[props.align] : undefined,\n justifyContent: props.justify ? JUSTIFY_CSS[props.justify] : undefined,\n flexWrap: props.wrap,\n gap: spacing(props.gap) ?? (props.disableAutoSpacing ? 0 : undefined),\n rowGap: spacing(props.rowGap),\n columnGap: spacing(props.columnGap),\n padding: props.flush ? 0 : spacing(props.padding),\n background: backgroundColor(props.background),\n border: props.border\n ? `1px solid ${borderColor(props.borderColor ?? \"default\")}`\n : undefined,\n ...radiusStyle(props.radius),\n width: spacing(props.width),\n height: spacing(props.height),\n // A container can shrink below its content and never gets wider than\n // its parent.\n minWidth: spacing(props.minWidth ?? props.minSize) ?? 0,\n maxWidth: spacing(props.maxWidth ?? props.maxSize) ?? \"100%\",\n minHeight: spacing(props.minHeight ?? props.minSize),\n maxHeight: spacing(props.maxHeight ?? props.maxSize),\n flex: props.flex,\n flexGrow: props.weight,\n aspectRatio: props.aspectRatio,\n overflow,\n boxShadow: props.shadow ? SHADOW_SM : undefined,\n boxSizing: \"border-box\",\n });\n}\n\n/**\n * The attributes of a container that scrolls. A keyboard user must be able\n * to focus it to scroll it.\n */\nfunction scrollAttributes(isScrollable: boolean | undefined) {\n if (!isScrollable) return {};\n return { tabIndex: 0, \"data-a2ui-scroll\": \"\" };\n}\n\nconst hasGap = (props: LayoutProps) =>\n props.gap !== undefined ||\n props.columnGap !== undefined ||\n props.rowGap !== undefined ||\n props.disableAutoSpacing === true;\n\n/**\n * Sends `onVisible` once, the first time the element scrolls into view. No\n * observer is made when the event is not bound.\n */\nexport function useVisibleOnce(\n ref: React.RefObject<HTMLElement | null>,\n onVisible: EventProp | undefined,\n) {\n const hasFired = useRef(false);\n useEffect(() => {\n const element = ref.current;\n if (!onVisible || !element || typeof IntersectionObserver === \"undefined\")\n return;\n const observer = new IntersectionObserver((entries) => {\n if (hasFired.current) return;\n if (entries.some((entry) => entry.isIntersecting)) {\n hasFired.current = true;\n void onVisible({});\n observer.disconnect();\n }\n });\n observer.observe(element);\n return () => observer.disconnect();\n }, [ref, onVisible]);\n}\n\n/**\n * True inside a Card. A surface has only one bordered level (the outer\n * Card). Everything inside it becomes borderless columns or the one\n * near-white inner panel.\n */\nexport const CardNestingContext = createContext(false);\n\n/**\n * The count of containers from the nearest Card, or `null` outside of a\n * Card. The rhythm: 16px between the groups directly inside a Card, 8px in a\n * group (label and control, caption and value).\n */\nexport const CardDistanceContext = createContext<number | null>(null);\n\nfunction defaultGap(distance: number | null) {\n return spacing(distance === null || distance === 0 ? 4 : 2);\n}\n\n/** The inner panel: 12px padding, 8px radius, no border, no shadow. */\nfunction innerPanelStyle(props: LayoutProps) {\n return {\n padding: spacing(props.padding ?? 3),\n borderRadius: radius(\"md\"),\n background: panelBackground(props.background) ?? INNER_PANEL_BG,\n border: \"none\",\n boxShadow: \"none\",\n };\n}\n\ntype ExtraStyle<Props> = (props: Props, nested: boolean) => CSSProperties;\ntype ExtraAttributes<Props> = (\n props: Props,\n) => Record<string, string | number | undefined>;\n\n/**\n * A flex container component: the layout props, the default gap of its\n * depth in a Card, and an extra style of its own.\n */\nfunction container<Props extends LayoutProps = LayoutProps>(\n extra?: ExtraStyle<Props>,\n attributes?: ExtraAttributes<Props>,\n) {\n return function Container(props: WithChildren<Props>) {\n useStandardStyles();\n const aria = useGenerativeUIAccessibility();\n const nested = useContext(CardNestingContext);\n const distance = useContext(CardDistanceContext);\n const ref = useRef<HTMLDivElement>(null);\n useVisibleOnce(ref, props.onVisible);\n // Inside a Card, background tokens use the lighter panel palette.\n const hasPanelBackground = nested && props.background !== undefined;\n return (\n <CardDistanceContext.Provider\n value={distance === null ? null : distance + 1}\n >\n <div\n ref={ref}\n data-a2ui-std=\"\"\n role={namedRole(aria, props.role)}\n {...aria}\n {...scrollAttributes(props.scrollable)}\n {...attributes?.(props)}\n style={{\n ...layoutStyle(props),\n ...(hasGap(props) ? {} : { gap: defaultGap(distance) }),\n ...(hasPanelBackground\n ? { background: panelBackground(props.background) }\n : {}),\n ...(extra ? defined(extra(props, nested)) : {}),\n }}\n >\n {props.children}\n </div>\n </CardDistanceContext.Provider>\n );\n };\n}\n\n// ---- Card ----\n\n/**\n * A Card has a border at the top level, and none inside another Card.\n * \"section\" never draws a box. \"outline\" always draws one.\n */\nfunction cardStyle(props: CardProps, nested: boolean) {\n // A section is a heading and its content: no box, no fill, no padding.\n if (props.variant === \"section\") {\n return {\n flexDirection: \"column\",\n gap: hasGap(props) ? undefined : spacing(4),\n padding: props.padding !== undefined ? spacing(props.padding) : 0,\n border: \"none\",\n boxShadow: \"none\",\n borderRadius: 0,\n background: props.background\n ? backgroundColor(props.background)\n : \"transparent\",\n } satisfies CSSProperties;\n }\n const ownBackground =\n props.background ??\n (props.variant === \"soft\" ? \"surface-secondary\" : undefined);\n // \"outline\" has a box even inside another Card.\n const isFlattened = nested && props.variant !== \"outline\";\n if (isFlattened) {\n const base: CSSProperties = {\n flexDirection: \"column\",\n gap: hasGap(props) ? undefined : spacing(3),\n border: \"none\",\n boxShadow: \"none\",\n };\n const isPanel =\n ownBackground !== undefined && ownBackground !== \"transparent\";\n if (isPanel) {\n return {\n ...base,\n ...innerPanelStyle({ ...props, background: ownBackground }),\n };\n }\n return {\n ...base,\n padding: 0,\n background: \"transparent\",\n borderRadius: 0,\n } satisfies CSSProperties;\n }\n const sizePadding = CARD_PADDING[props.size ?? \"md\"];\n return {\n flexDirection: \"column\",\n gap: hasGap(props) ? undefined : spacing(4),\n padding: props.flush ? 0 : spacing(props.padding ?? sizePadding),\n borderRadius: radius(\n typeof props.radius === \"object\" ? undefined : (props.radius ?? \"xl\"),\n ),\n border:\n props.variant === \"transparent\"\n ? \"none\"\n : `1px solid ${borderColor(props.borderColor ?? \"default\")}`,\n background: backgroundColor(\n ownBackground ??\n (props.variant === \"transparent\" ? \"transparent\" : undefined),\n ),\n boxShadow: cardShadow(props),\n } satisfies CSSProperties;\n}\n\n/** The padding of a Card by size preset, in 4px steps: 8, 16 or 24px. */\nconst CARD_PADDING = { sm: 2, md: 4, lg: 6 } as const;\n\n/** `shadowStyle` wins over the shadow of the variant. */\nfunction cardShadow(props: CardProps) {\n switch (props.shadowStyle) {\n case \"md\":\n return SHADOW_MD;\n case \"sm\":\n return SHADOW_SM;\n case \"none\":\n return \"none\";\n case undefined:\n default:\n return props.variant === \"elevated\" ? SHADOW_SOFT : undefined;\n }\n}\n\nfunction Card(props: WithChildren<CardProps> & { child?: ReactNode }) {\n useStandardStyles();\n const aria = useGenerativeUIAccessibility();\n const nested = useContext(CardNestingContext);\n const ref = useRef<HTMLDivElement>(null);\n useVisibleOnce(ref, props.onVisible);\n // A section draws no box, so its content keeps the nesting level.\n const isSection = props.variant === \"section\";\n return (\n <CardNestingContext.Provider value={isSection ? nested : true}>\n <CardDistanceContext.Provider value={0}>\n <div\n ref={ref}\n role={namedRole(aria, props.role)}\n {...aria}\n data-a2ui-std=\"\"\n data-a2ui-card={nested ? \"nested\" : \"top\"}\n data-a2ui-card-variant={props.variant}\n {...scrollAttributes(props.scrollable)}\n style={{\n ...layoutStyle(props),\n ...defined(cardStyle(props, nested)),\n }}\n >\n {props.child}\n {props.children}\n </div>\n </CardDistanceContext.Provider>\n </CardNestingContext.Provider>\n );\n}\n\n// ---- Grid ----\n\n/** The minimum width at which `columns` cards sit side by side. */\nconst GRID_MIN_TRACK_PX = 520;\n\n/**\n * The `grid-template-columns` of a Grid. A number of columns becomes an\n * auto-fit template: at most `n` columns, which collapse towards one column\n * when a track gets narrower than 520px / n (260px for two columns).\n */\nexport function gridTemplateColumns(props: {\n columns?: number | string;\n minChildWidth?: number | string;\n gap?: number | string;\n columnGap?: number | string;\n}) {\n if (typeof props.columns === \"string\") return props.columns;\n if (props.minChildWidth !== undefined) {\n return `repeat(auto-fill, minmax(min(100%, ${spacing(props.minChildWidth)}), 1fr))`;\n }\n const count = Math.max(1, Math.floor(props.columns ?? 2));\n if (count === 1) return \"minmax(0, 1fr)\";\n const gap = spacing(props.columnGap ?? props.gap ?? 4);\n const minTrack = Math.round(Math.max(120, GRID_MIN_TRACK_PX / count));\n return `repeat(auto-fit, minmax(min(100%, max(${minTrack}px, calc((100% - ${count - 1} * ${gap}) / ${count}))), 1fr))`;\n}\n\n/**\n * The count of columns that the nearest Grid renders now: the measured\n * track count when the browser gives it (auto-fit collapses columns on\n * narrow widths), else the numeric `columns` prop. `undefined` when unknown.\n */\nconst GridColumnsContext = createContext<number | undefined>(undefined);\n\n/** The count of resolved tracks of a laid-out grid (\"120px 120px\" is 2). */\nfunction measureTracks(element: HTMLElement) {\n if (typeof getComputedStyle !== \"function\") return undefined;\n const tracks = getComputedStyle(element)\n .gridTemplateColumns.split(/\\s+/)\n .filter(Boolean);\n // Only a fully resolved template is trusted (browsers report px tracks).\n const isResolved =\n tracks.length > 0 && tracks.every((track) => /^[\\d.]+px$/.test(track));\n return isResolved ? tracks.length : undefined;\n}\n\n/** The column count that the Grid props give, or `undefined` when unknown. */\nfunction declaredColumns(props: GridProps) {\n if (typeof props.columns === \"number\") {\n return Math.max(1, Math.floor(props.columns));\n }\n const isDefault =\n props.columns === undefined && props.minChildWidth === undefined;\n return isDefault ? 2 : undefined;\n}\n\nfunction Grid(props: WithChildren<GridProps>) {\n useStandardStyles();\n const ref = useRef<HTMLDivElement>(null);\n const [measured, setMeasured] = useState<number | undefined>(undefined);\n useLayoutEffect(() => {\n const element = ref.current;\n if (!element) return;\n const update = () => setMeasured(measureTracks(element));\n update();\n if (typeof ResizeObserver === \"undefined\") return;\n const observer = new ResizeObserver(update);\n observer.observe(element);\n return () => observer.disconnect();\n }, []);\n const declared = declaredColumns(props);\n return (\n <GridColumnsContext.Provider value={measured ?? declared}>\n <div\n ref={ref}\n data-a2ui-std=\"\"\n {...scrollAttributes(props.scrollable)}\n style={{\n ...layoutStyle(props),\n ...defined({\n display: \"grid\",\n gap: hasGap(props) ? undefined : spacing(4),\n gridTemplateColumns: gridTemplateColumns(props),\n gridTemplateRows:\n typeof props.rows === \"number\"\n ? `repeat(${props.rows}, auto)`\n : props.rows,\n }),\n }}\n >\n {props.children}\n </div>\n </GridColumnsContext.Provider>\n );\n}\n\n/**\n * The `grid-column` of a GridItem. A span that covers every rendered column\n * becomes `1 / -1` (the full row), so it never adds implicit tracks that\n * overflow the grid. A smaller span stays `span N`. Without a known column\n * count, the span is used as given.\n */\nexport function gridItemColumn(\n span: number | undefined,\n columns: number | undefined,\n) {\n if (!span) return undefined;\n if (columns !== undefined && span >= columns) return \"1 / -1\";\n return `span ${span}`;\n}\n\nfunction GridItem(props: WithChildren<GridItemProps>) {\n useStandardStyles();\n const columns = useContext(GridColumnsContext);\n return (\n <div\n data-a2ui-std=\"\"\n {...scrollAttributes(props.scrollable)}\n style={{\n ...layoutStyle(props),\n ...defined({\n gridColumn: gridItemColumn(props.span, columns),\n gridRow: props.rowSpan ? `span ${props.rowSpan}` : undefined,\n flexDirection: \"column\",\n }),\n }}\n >\n {props.children}\n </div>\n );\n}\n\nconst spanStyle = (props: { span?: number; rowSpan?: number }) => ({\n gridColumn: props.span ? `span ${props.span}` : undefined,\n gridRow: props.rowSpan ? `span ${props.rowSpan}` : undefined,\n});\n\n// ---- Containers ----\n\nconst Box = container((props: BoxProps, nested) => ({\n flexDirection: props.direction === \"row\" ? \"row\" : \"column\",\n // A bordered Box inside a Card becomes the inner panel, not a 1px box.\n ...(nested && props.border ? innerPanelStyle(props) : {}),\n}));\n\nconst Column = container(() => ({ flexDirection: \"column\" }));\n\n// Row children are centered on the cross axis, 8px apart.\nconst Row = container(\n (props) => ({\n flexDirection: \"row\",\n alignItems: props.align ? undefined : \"center\",\n gap: hasGap(props) ? undefined : spacing(2),\n }),\n (props) => ({ \"data-a2ui-row\": props.justify ?? \"start\" }),\n);\n\nconst Flow = container((props: FlowProps) => ({\n display: \"grid\",\n gap: spacing(props.gap ?? 4),\n gridTemplateColumns: gridTemplateColumns({\n columns: props.columns ?? 3,\n gap: props.gap ?? 4,\n }),\n gridAutoFlow: props.layout === \"fixed\" ? \"row\" : \"dense\",\n}));\n\nconst FlowItem = container((props: FlowItemProps) => ({\n ...spanStyle(props),\n flexDirection: \"column\",\n aspectRatio: props.aspectRatio ?? \"1 / 1\",\n}));\n\n/** The width of a CarouselMediaItem by size. */\nconst CAROUSEL_MEDIA_WIDTH: Record<\n (typeof CAROUSEL_MEDIA_SIZES)[number],\n number\n> = { sm: 160, md: 240, lg: 320 };\n\n/**\n * A horizontal snap scroller with previous and next arrows. A Carousel\n * always scrolls, so it can always take keyboard focus. With a `label`, it\n * is a named region for screen readers. `activeIndex` is writable: setting\n * it scrolls that slide into view, and a scroll writes the index of the\n * snapped slide back.\n */\nfunction Carousel(props: WithChildren<CarouselProps>) {\n useStandardStyles();\n const nested = useContext(CardNestingContext);\n const scroller = useRef<HTMLDivElement>(null);\n useVisibleOnce(scroller, props.onVisible);\n const [canPrev, setCanPrev] = useState(false);\n const [canNext, setCanNext] = useState(false);\n const snap = props.snap ?? \"proximity\";\n const showArrows = props.showArrows !== false;\n const hasLabel = props.label !== undefined;\n\n const slides = () =>\n Array.from(scroller.current?.children ?? []) as HTMLElement[];\n const update = () => {\n const element = scroller.current;\n if (!element) return;\n setCanPrev(element.scrollLeft > 4);\n setCanNext(\n element.scrollLeft + element.clientWidth < element.scrollWidth - 4,\n );\n };\n const scrollTo = (index: number) => {\n const element = scroller.current;\n const target = slides()[index];\n if (!element || !target) return;\n const left = target.offsetLeft - element.offsetLeft;\n // jsdom has no scrollTo on elements.\n if (typeof element.scrollTo === \"function\") {\n element.scrollTo({ left, behavior: \"smooth\" });\n } else {\n element.scrollLeft = left;\n }\n };\n /** The index of the slide nearest to the left edge. */\n const nearest = () => {\n const element = scroller.current;\n if (!element) return 0;\n let best = 0;\n let bestDistance = Infinity;\n slides().forEach((slide, index) => {\n const distance = Math.abs(\n slide.offsetLeft - element.offsetLeft - element.scrollLeft,\n );\n if (distance < bestDistance) {\n bestDistance = distance;\n best = index;\n }\n });\n return best;\n };\n\n useEffect(update, []);\n const { activeIndex, setActiveIndex } = props;\n useEffect(() => {\n if (typeof activeIndex === \"number\") scrollTo(activeIndex);\n // scrollTo reads the DOM; it does not change between renders.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [activeIndex]);\n\n const timer = useRef<ReturnType<typeof setTimeout> | null>(null);\n const onScroll = () => {\n update();\n if (timer.current) clearTimeout(timer.current);\n timer.current = setTimeout(() => {\n const index = nearest();\n if (index !== activeIndex) setActiveIndex(index);\n }, 120);\n };\n\n const arrow = (direction: -1 | 1, isEnabled: boolean, label: string) => (\n <button\n type=\"button\"\n aria-label={label}\n disabled={!isEnabled}\n data-a2ui-carousel-arrow={direction < 0 ? \"prev\" : \"next\"}\n onClick={(event) => {\n event.stopPropagation();\n scrollTo(Math.max(0, nearest() + direction));\n }}\n style={{\n position: \"absolute\",\n top: \"50%\",\n [direction < 0 ? \"left\" : \"right\"]: 4,\n transform: \"translateY(-50%)\",\n width: 32,\n height: 32,\n borderRadius: 9999,\n border: `1px solid ${borderColor(\"default\")}`,\n background: backgroundColor(\"surface-elevated\"),\n color: textColor(\"default\"),\n boxShadow: SHADOW_SM,\n cursor: isEnabled ? \"pointer\" : \"default\",\n opacity: isEnabled ? 1 : 0,\n pointerEvents: isEnabled ? \"auto\" : \"none\",\n transition: \"opacity .15s\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n fontSize: 16,\n lineHeight: 1,\n zIndex: 1,\n }}\n >\n {direction < 0 ? \"‹\" : \"›\"}\n </button>\n );\n\n return (\n <div style={{ position: \"relative\", width: \"100%\", minWidth: 0 }}>\n <div\n ref={scroller}\n data-a2ui-std=\"\"\n data-a2ui-carousel=\"\"\n {...scrollAttributes(true)}\n role={props.role ?? (hasLabel ? \"region\" : undefined)}\n aria-label={props.label}\n aria-roledescription={hasLabel ? \"carousel\" : undefined}\n onScroll={onScroll}\n style={{\n ...layoutStyle(props),\n ...(nested && props.background\n ? { background: panelBackground(props.background) }\n : {}),\n flexDirection: \"row\",\n gap: spacing(props.gap ?? 2),\n overflowX: \"auto\",\n scrollSnapType: snap === \"none\" ? undefined : `x ${snap}`,\n scrollbarWidth: \"none\",\n }}\n >\n {props.children}\n </div>\n {showArrows\n ? arrow(-1, canPrev, props.previousLabel ?? \"Previous\")\n : null}\n {showArrows ? arrow(1, canNext, props.nextLabel ?? \"Next\") : null}\n </div>\n );\n}\n\n/**\n * A slide with an image on top. A click on the image opens a lightbox over\n * every media slide of the same carousel, with the clicked one selected.\n * `href` or a bound `onClick` take over the click instead.\n */\nfunction CarouselMediaItem(props: WithChildren<CarouselMediaItemProps>) {\n useStandardStyles();\n const [open, setOpen] = useState<{\n images: LightboxImage[];\n index: number;\n } | null>(null);\n const width = CAROUSEL_MEDIA_WIDTH[props.size ?? \"md\"];\n const hasHref = typeof props.href === \"string\" && props.href !== \"\";\n const hasAction = props.onClick !== undefined;\n const showsLightbox = props.lightbox !== false && !hasHref && !hasAction;\n const isClickable = showsLightbox || hasHref || hasAction;\n const onClick = (event: MouseEvent<HTMLImageElement>) => {\n event.stopPropagation();\n if (hasHref) {\n openUrl(props.href);\n return;\n }\n if (hasAction) {\n void props.onClick?.({});\n return;\n }\n if (!showsLightbox) return;\n const own = event.currentTarget;\n const scope =\n own.closest(\"[data-a2ui-carousel]\") ?? own.parentElement?.parentElement;\n const slides = Array.from(\n scope?.querySelectorAll<HTMLImageElement>(\n \"[data-a2ui-carousel-media] > img\",\n ) ?? [],\n );\n const images = slides.map((img) => ({ src: img.src, alt: img.alt }));\n const index = Math.max(\n 0,\n slides.findIndex((img) => img === own),\n );\n setOpen(\n images.length > 0\n ? { images, index }\n : { images: [{ src: props.url, alt: props.description }], index: 0 },\n );\n };\n return (\n <div\n data-a2ui-std=\"\"\n data-a2ui-carousel-media=\"\"\n role={props.role}\n style={{\n ...layoutStyle(props),\n flex: \"0 0 auto\",\n flexDirection: \"column\",\n scrollSnapAlign: \"start\",\n width,\n gap: spacing(props.gap ?? 2),\n }}\n >\n <img\n src={props.url}\n alt={props.description ?? \"\"}\n loading=\"lazy\"\n onClick={isClickable ? onClick : undefined}\n data-a2ui-lightbox-trigger={showsLightbox ? \"\" : undefined}\n style={{\n display: \"block\",\n width: \"100%\",\n aspectRatio: props.aspectRatio ?? \"4 / 3\",\n objectFit: \"cover\",\n borderRadius: radius(\"lg\"),\n cursor: showsLightbox\n ? \"zoom-in\"\n : isClickable\n ? \"pointer\"\n : undefined,\n }}\n />\n {props.children}\n {open ? (\n <Lightbox\n images={open.images}\n index={open.index}\n onClose={() => setOpen(null)}\n />\n ) : null}\n </div>\n );\n}\n\nconst CarouselItem = container(() => ({\n flex: \"0 0 auto\",\n flexDirection: \"column\",\n scrollSnapAlign: \"start\",\n}));\n\ntype TabsProps = Omit<z.output<typeof tabsSchema>, \"tabs\"> & {\n /** The engine renders the `child` ref of each tab into a React node. */\n tabs: { title: string; child: ReactNode }[];\n setSelectedIndex?: (index: number) => void;\n};\n\n/**\n * Tabs with one panel per tab: the `child` of each entry, rendered by the\n * engine. The tab list is one tab stop: the arrow keys, Home and End move\n * between the tabs and open them.\n */\nfunction Tabs(props: TabsProps) {\n useStandardStyles();\n const id = useId();\n const [ownIndex, setOwnIndex] = useState(0);\n const tabs = props.tabs ?? [];\n const count = tabs.length;\n const selected = Math.min(\n Math.max(0, props.selectedIndex ?? ownIndex),\n Math.max(0, count - 1),\n );\n const tabRefs = useRef<Array<HTMLButtonElement | null>>([]);\n const select = (index: number, focus = false) => {\n setOwnIndex(index);\n props.setSelectedIndex?.(index);\n if (focus) tabRefs.current[index]?.focus();\n };\n const onKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n const step =\n event.key === \"ArrowRight\"\n ? 1\n : event.key === \"ArrowLeft\"\n ? -1\n : undefined;\n const next =\n step !== undefined\n ? (selected + step + count) % count\n : event.key === \"Home\"\n ? 0\n : event.key === \"End\"\n ? count - 1\n : undefined;\n if (next === undefined || count === 0) return;\n event.preventDefault();\n select(next, true);\n };\n if (count === 0) return null;\n return (\n <div\n data-a2ui-std=\"\"\n data-a2ui-tabs=\"\"\n style={{\n display: \"flex\",\n flexDirection: \"column\",\n gap: spacing(3),\n width: \"100%\",\n minWidth: 0,\n flexGrow: props.weight,\n }}\n >\n <div\n role=\"tablist\"\n onKeyDown={onKeyDown}\n style={{\n display: \"flex\",\n gap: spacing(1),\n borderBottom: `1px solid ${borderColor(\"default\")}`,\n overflowX: \"auto\",\n }}\n >\n {tabs.map((tab, index) => {\n const isSelected = index === selected;\n return (\n <button\n key={`${tab.title}-${index}`}\n ref={(element) => {\n tabRefs.current[index] = element;\n }}\n type=\"button\"\n role=\"tab\"\n id={`${id}-tab-${index}`}\n aria-selected={isSelected}\n aria-controls={`${id}-panel-${index}`}\n tabIndex={isSelected ? 0 : -1}\n data-a2ui-input=\"\"\n onClick={() => select(index)}\n style={{\n flexShrink: 0,\n padding: `${spacing(2)} ${spacing(3)}`,\n marginBottom: -1,\n border: \"none\",\n borderBottom: `2px solid ${isSelected ? textColor(\"default\") : \"transparent\"}`,\n background: \"transparent\",\n color: isSelected\n ? textColor(\"default\")\n : textColor(\"secondary\"),\n font: \"inherit\",\n fontWeight: 500,\n cursor: \"pointer\",\n }}\n >\n {tab.title}\n </button>\n );\n })}\n </div>\n {tabs.map((tab, index) =>\n index === selected ? (\n <div\n key={index}\n role=\"tabpanel\"\n id={`${id}-panel-${index}`}\n aria-labelledby={`${id}-tab-${index}`}\n style={{\n display: \"flex\",\n flexDirection: \"column\",\n gap: spacing(3),\n }}\n >\n {tab.child}\n </div>\n ) : null,\n )}\n </div>\n );\n}\n\nfunction Spacer(props: z.output<typeof spacerSchema>) {\n return (\n <div\n aria-hidden=\"true\"\n style={{\n flex: 1,\n minWidth: spacing(props.minSize ?? 2),\n minHeight: spacing(props.minSize ?? 2),\n }}\n />\n );\n}\n\nfunction Divider(props: z.output<typeof dividerSchema>) {\n const line = `${props.size ?? 1}px solid ${borderColor(props.color ?? \"subtle\")}`;\n const margin = props.flush ? 0 : spacing(props.spacing ?? 2);\n const isVertical = props.axis === \"vertical\";\n return (\n <hr\n aria-orientation={isVertical ? \"vertical\" : undefined}\n style={{\n border: 0,\n ...(isVertical\n ? { borderLeft: line, margin: `0 ${margin}`, height: \"auto\" }\n : { borderTop: line, margin: `${margin} 0`, width: \"100%\" }),\n flexShrink: 0,\n flexGrow: props.weight,\n alignSelf: \"stretch\",\n }}\n />\n );\n}\n\n/**\n * The standard layout components: containers, Spacer and Divider. Give\n * them to `createGenerativeUI({ components: { ...layoutComponents } })`.\n * Every container has a \"multiple\" `children` slot, so it takes a list of\n * child ids or a template `{ componentId, path }`.\n */\nexport const layoutComponents = withComponents(layoutDeclarations, {\n Box,\n Column,\n Row,\n Grid,\n GridItem,\n Card,\n Flow,\n FlowItem,\n Carousel,\n CarouselItem,\n CarouselMediaItem,\n Spacer,\n Divider,\n Tabs,\n});\n","import React, { useEffect, useState } from \"react\";\nimport type { CSSProperties } from \"react\";\nimport { IconSvg } from \"../../components/icons/CopilotIcon\";\nimport type { IconSvgNode } from \"../../components/icons/CopilotIcon\";\nimport type { z } from \"zod\";\nimport {\n controlAria,\n useGenerativeUIAccessibility,\n wrapperAria,\n} from \"../accessibility\";\nimport {\n ON_ACCENT,\n backgroundColor,\n borderColor,\n mediaDeclarations,\n radius,\n spacing,\n textColor,\n withComponents,\n} from \"@copilotkit/shared/generative-ui\";\nimport type {\n GenerativeUIInvokeResult,\n ICON_SIZES,\n IMAGE_VARIANTS,\n IconSize,\n NO_ARGS,\n Weight,\n audioPlayerSchema,\n faviconSchema,\n htmlViewSchema,\n iconSchema,\n imageSchema,\n svgSchema,\n videoSchema,\n} from \"@copilotkit/shared/generative-ui\";\nimport { radiusStyle } from \"./layout\";\nimport { Lightbox, openUrl } from \"./lightbox\";\n\ntype EventProp = (\n args: z.input<typeof NO_ARGS>,\n) => Promise<GenerativeUIInvokeResult>;\n\n// ---- Helpers ----\n\n/** Pixels when a number, raw CSS when a string. */\nexport function px(value: number | string | undefined) {\n if (value === undefined) return undefined;\n return typeof value === \"number\" ? `${value}px` : value;\n}\n\nconst ICON_PX: Record<(typeof ICON_SIZES)[number], number> = {\n sm: 16,\n md: 20,\n lg: 24,\n xl: 32,\n};\nconst ICON_STROKE: Record<Weight, number> = {\n normal: 2,\n medium: 2.25,\n semibold: 2.5,\n bold: 3,\n};\n\n/** \"arrow-right\" gives \"ArrowRight\". \"arrow-down-0-1\" gives \"ArrowDown01\". */\nexport function kebabToPascal(name: string) {\n return name\n .split(/[-_\\s]+/)\n .filter(Boolean)\n .map((part) => part.charAt(0).toUpperCase() + part.slice(1))\n .join(\"\");\n}\n\n/** \"ArrowRight\" gives \"arrow-right\", as Lucide names its icon classes. */\nfunction pascalToKebab(name: string) {\n return name.replace(/([a-z0-9])([A-Z])/g, \"$1-$2\").toLowerCase();\n}\n\n/** A Lucide icon as the `lucide` package stores it: `[tag, attributes]` pairs. */\ntype LucideIconData = [\n tag: string,\n attributes: Record<string, string | number>,\n][];\ntype IconMap = Record<string, LucideIconData>;\nlet lucidePromise: Promise<IconMap> | null = null;\nlet lucideIcons: IconMap | null = null;\n\nfunction loadLucideIcons() {\n lucidePromise ??= import(\"lucide\").then((module) => {\n const icons: IconMap = module.icons;\n lucideIcons = icons;\n return icons;\n });\n return lucidePromise;\n}\n\n/**\n * Lucide has about 1,500 icons. A static import of its `icons` map puts all\n * of them in every bundle and makes module load slow. So the map loads once,\n * on first use, and the icons show when it is there.\n */\nfunction useLucideIcons() {\n const [icons, setIcons] = useState(lucideIcons);\n useEffect(() => {\n if (lucideIcons) return;\n let isActive = true;\n void loadLucideIcons().then((loaded) => {\n if (isActive) setIcons(loaded);\n });\n return () => {\n isActive = false;\n };\n }, []);\n return icons;\n}\n\n/** The icon for a kebab-case or PascalCase name, or `null` when there is none. */\nfunction findLucideIcon(icons: IconMap, name: string) {\n const pascalName = kebabToPascal(name);\n const key = pascalName in icons ? pascalName : name in icons ? name : null;\n if (key === null) return null;\n const nodes: IconSvgNode[] = icons[key]!.map(([tag, attributes]) => ({\n tag,\n attributes,\n }));\n return { lucideName: pascalToKebab(key), nodes };\n}\n\n/**\n * A lucide icon by kebab-case (or PascalCase) name. An unknown name renders\n * nothing. Without a `label`, the icon is hidden from screen readers.\n *\n * @example\n * ```tsx\n * <LucideIcon name=\"arrow-right\" size=\"sm\" />\n * ```\n */\nexport function LucideIcon({\n name,\n label,\n description,\n size = \"md\",\n color,\n weight,\n inline,\n style,\n}: {\n name: string;\n label?: string;\n description?: string;\n size?: IconSize;\n color?: string;\n weight?: Weight;\n inline?: boolean;\n style?: CSSProperties;\n}) {\n const icons = useLucideIcons();\n if (!name || !icons) return null;\n const icon = findLucideIcon(icons, name);\n if (!icon) return null;\n const pixels =\n typeof size === \"number\" ? size : inline ? \"1em\" : ICON_PX[size];\n const a11y =\n label === undefined\n ? { \"aria-hidden\": true }\n : { role: \"img\", \"aria-label\": label, \"aria-description\": description };\n return (\n <IconSvg\n lucideName={icon.lucideName}\n nodes={icon.nodes}\n {...a11y}\n focusable=\"false\"\n size={pixels}\n color={textColor(color) ?? \"currentColor\"}\n strokeWidth={weight ? ICON_STROKE[weight] : undefined}\n style={{\n ...style,\n flexShrink: 0,\n display: inline ? \"inline-block\" : \"block\",\n verticalAlign: inline ? \"-0.125em\" : undefined,\n }}\n />\n );\n}\n\n// ---- Components ----\n\ntype ImageVariantStyle = Pick<\n CSSProperties,\n \"width\" | \"height\" | \"maxWidth\" | \"aspectRatio\" | \"borderRadius\"\n>;\n\n/** The size of each Image variant. \"mediumFeature\" is the natural size. */\nconst IMAGE_VARIANT_STYLE: Record<\n (typeof IMAGE_VARIANTS)[number],\n ImageVariantStyle\n> = {\n icon: { width: 24, height: 24, borderRadius: radius(\"xs\") },\n avatar: { width: 40, height: 40, borderRadius: radius(\"full\") },\n smallFeature: { width: \"100%\", maxWidth: 160 },\n mediumFeature: {},\n largeFeature: { width: \"100%\" },\n header: { width: \"100%\", aspectRatio: \"3 / 1\" },\n};\n\nconst OBJECT_FIT = {\n cover: \"cover\",\n contain: \"contain\",\n fill: \"fill\",\n none: \"none\",\n scaleDown: \"scale-down\",\n} as const;\n\ntype ImageProps = z.output<typeof imageSchema> & {\n onOverlayClick?: EventProp;\n};\n\nfunction Image(props: ImageProps) {\n const aria = useGenerativeUIAccessibility();\n const [failed, setFailed] = useState(false);\n const [isOpen, setIsOpen] = useState(false);\n const [isHovered, setIsHovered] = useState(false);\n const isHidden = failed && props.hideOnFailure;\n if (!props.url || isHidden) return null;\n const showsLightbox = props.lightbox !== false && !failed;\n const alt = props.description ?? \"\";\n const variant = IMAGE_VARIANT_STYLE[props.variant ?? \"mediumFeature\"];\n const frame: CSSProperties = {\n display: \"block\",\n ...variant,\n aspectRatio: props.aspectRatio ?? variant.aspectRatio,\n width:\n spacing(props.width) ??\n (props.aspectRatio ? \"100%\" : undefined) ??\n variant.width,\n height: spacing(props.height) ?? variant.height,\n minWidth: spacing(props.minWidth),\n minHeight: spacing(props.minHeight),\n maxWidth: spacing(props.maxWidth) ?? variant.maxWidth ?? \"100%\",\n maxHeight: spacing(props.maxHeight),\n flexGrow: props.weight,\n boxSizing: \"border-box\",\n ...radiusStyle(props.radius ?? variant.borderRadius),\n };\n if (failed && props.fallback) {\n return (\n <div\n role=\"img\"\n aria-label={alt || props.fallback}\n {...aria}\n style={{\n ...frame,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n padding: spacing(3),\n background: backgroundColor(props.background ?? \"surface-secondary\"),\n color: textColor(\"secondary\"),\n fontSize: \".875em\",\n textAlign: \"center\",\n minHeight: spacing(props.minHeight) ?? 64,\n }}\n >\n {props.fallback}\n </div>\n );\n }\n const overlay = props.actionOverlay;\n const hasWrapper = overlay !== undefined || props.hoverZoom === true;\n // With an overlay button next to it, hidden and live belong to the pair;\n // the name stays on the image, because names do not inherit.\n const image = (\n <img\n src={props.url}\n alt={alt}\n {...(hasWrapper ? controlAria(aria) : aria)}\n loading=\"lazy\"\n onError={() => setFailed(true)}\n onClick={showsLightbox ? () => setIsOpen(true) : undefined}\n data-a2ui-lightbox-trigger={showsLightbox ? \"\" : undefined}\n style={{\n ...frame,\n cursor: showsLightbox ? \"zoom-in\" : undefined,\n objectFit: OBJECT_FIT[props.fit ?? \"cover\"],\n objectPosition: props.position,\n background: backgroundColor(props.background),\n border: props.frame ? `1px solid ${borderColor(\"default\")}` : undefined,\n transform: props.hoverZoom && isHovered ? \"scale(1.03)\" : undefined,\n transition: props.hoverZoom ? \"transform .2s ease\" : undefined,\n }}\n />\n );\n return (\n <>\n {isOpen && showsLightbox ? (\n <Lightbox\n images={[{ src: props.url, alt }]}\n onClose={() => setIsOpen(false)}\n />\n ) : null}\n {hasWrapper ? (\n <div\n {...wrapperAria(aria)}\n onMouseEnter={() => setIsHovered(true)}\n onMouseLeave={() => setIsHovered(false)}\n style={{\n position: \"relative\",\n display: \"inline-block\",\n maxWidth: \"100%\",\n overflow: props.hoverZoom ? \"hidden\" : undefined,\n ...radiusStyle(props.radius),\n }}\n >\n {image}\n {overlay ? (\n <button\n type=\"button\"\n data-a2ui-input=\"\"\n onClick={(event) => {\n event.stopPropagation();\n if (overlay.href) openUrl(overlay.href);\n else void props.onOverlayClick?.({});\n }}\n style={{\n position: \"absolute\",\n right: 8,\n bottom: 8,\n display: \"inline-flex\",\n alignItems: \"center\",\n gap: 6,\n padding: \"6px 12px\",\n borderRadius: 9999,\n border: \"none\",\n background: \"var(--a2ui-color-overlay, rgba(0,0,0,.65))\",\n color: ON_ACCENT,\n font: \"inherit\",\n fontSize: \".8125em\",\n fontWeight: 500,\n cursor: \"pointer\",\n }}\n >\n {overlay.icon ? (\n <LucideIcon name={overlay.icon} size={14} />\n ) : null}\n {overlay.label}\n </button>\n ) : null}\n </div>\n ) : (\n image\n )}\n </>\n );\n}\n\n/** The A2UI basic catalog icon names, and the Lucide icon of each. */\nconst A2UI_ICONS: Record<string, string> = {\n accountCircle: \"circle-user\",\n add: \"plus\",\n arrowBack: \"arrow-left\",\n arrowForward: \"arrow-right\",\n attachFile: \"paperclip\",\n calendarToday: \"calendar\",\n call: \"phone\",\n camera: \"camera\",\n check: \"check\",\n close: \"x\",\n delete: \"trash-2\",\n download: \"download\",\n edit: \"pencil\",\n event: \"calendar-days\",\n error: \"circle-alert\",\n fastForward: \"fast-forward\",\n favorite: \"heart\",\n favoriteOff: \"heart-off\",\n folder: \"folder\",\n help: \"circle-question-mark\",\n home: \"house\",\n info: \"info\",\n locationOn: \"map-pin\",\n lock: \"lock\",\n lockOpen: \"lock-open\",\n mail: \"mail\",\n menu: \"menu\",\n moreVert: \"ellipsis-vertical\",\n moreHoriz: \"ellipsis\",\n notificationsOff: \"bell-off\",\n notifications: \"bell\",\n pause: \"pause\",\n payment: \"credit-card\",\n person: \"user\",\n phone: \"phone\",\n photo: \"image\",\n play: \"play\",\n print: \"printer\",\n refresh: \"refresh-cw\",\n rewind: \"rewind\",\n search: \"search\",\n send: \"send\",\n settings: \"settings\",\n share: \"share-2\",\n shoppingCart: \"shopping-cart\",\n skipNext: \"skip-forward\",\n skipPrevious: \"skip-back\",\n star: \"star\",\n starHalf: \"star-half\",\n starOff: \"star-off\",\n stop: \"square\",\n upload: \"upload\",\n visibility: \"eye\",\n visibilityOff: \"eye-off\",\n volumeDown: \"volume-1\",\n volumeMute: \"volume-x\",\n volumeOff: \"volume-off\",\n volumeUp: \"volume-2\",\n warning: \"triangle-alert\",\n};\n\n/** The Lucide name of an icon: an A2UI name maps, any other name passes. */\nexport function lucideNameOf(name: string) {\n return A2UI_ICONS[name] ?? name;\n}\n\nfunction Icon(props: z.output<typeof iconSchema>) {\n const aria = useGenerativeUIAccessibility();\n // The envelope names the icon like `label` does.\n const label = aria[\"aria-label\"] ?? props.label;\n const size = props.size ?? \"md\";\n const style = { flexGrow: props.weight };\n if (typeof props.name === \"object\") {\n const pixels =\n typeof size === \"number\" ? size : props.inline ? \"1em\" : ICON_PX[size];\n const a11y =\n label === undefined\n ? { \"aria-hidden\": true }\n : {\n role: \"img\",\n \"aria-label\": label,\n \"aria-description\": aria[\"aria-description\"],\n };\n return (\n <svg\n {...a11y}\n focusable=\"false\"\n viewBox=\"0 0 24 24\"\n width={pixels}\n height={pixels}\n fill={textColor(props.color) ?? \"currentColor\"}\n style={{\n ...style,\n flexShrink: 0,\n display: props.inline ? \"inline-block\" : \"block\",\n verticalAlign: props.inline ? \"-0.125em\" : undefined,\n }}\n >\n <path d={props.name.svgPath} />\n </svg>\n );\n }\n return (\n <LucideIcon\n name={lucideNameOf(props.name)}\n label={label}\n description={aria[\"aria-description\"]}\n size={size}\n color={props.color}\n weight={props.strokeWeight}\n inline={props.inline}\n style={style}\n />\n );\n}\n\nexport function hostOf(url: string) {\n try {\n return new URL(url.includes(\"://\") ? url : `https://${url}`).hostname;\n } catch {\n return undefined;\n }\n}\n\nfunction Favicon(props: z.output<typeof faviconSchema>) {\n const host = hostOf(props.url);\n if (!host) return null;\n const size = props.size ?? 16;\n return (\n <img\n src={`https://www.google.com/s2/favicons?domain=${encodeURIComponent(host)}&sz=64`}\n alt={props.alt ?? host}\n width={size}\n height={size}\n style={{\n display: props.inline ? \"inline-block\" : \"block\",\n verticalAlign: props.inline ? \"middle\" : undefined,\n borderRadius: radius(\"xs\"),\n border: props.frame ? `1px solid ${borderColor(\"default\")}` : undefined,\n padding: props.frame ? 2 : undefined,\n background: props.frame ? backgroundColor(\"surface\") : undefined,\n }}\n />\n );\n}\n\n/**\n * A vector drawing from primitive shapes only. It has no raw markup, so the\n * model cannot add scripts or event handlers. A number size is pixels (not\n * 4px steps like the layout spacing).\n */\nfunction Svg(props: z.output<typeof svgSchema>) {\n const aria = useGenerativeUIAccessibility();\n const label = aria[\"aria-label\"] ?? props.label;\n const a11y =\n label === undefined\n ? { \"aria-hidden\": true }\n : {\n role: \"img\",\n \"aria-label\": label,\n \"aria-description\": aria[\"aria-description\"],\n };\n const rects = props.rects ?? [];\n const circles = props.circles ?? [];\n const paths = props.paths ?? [];\n const lines = props.lines ?? [];\n const texts = props.texts ?? [];\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n {...a11y}\n focusable=\"false\"\n viewBox={props.viewBox}\n width={props.width ?? props.size ?? \"100%\"}\n height={props.height ?? props.size}\n fill={textColor(props.fill) ?? \"currentColor\"}\n stroke={textColor(props.stroke)}\n strokeWidth={props.strokeWidth}\n strokeLinecap={props.strokeLinecap}\n strokeLinejoin={props.strokeLinejoin}\n preserveAspectRatio={props.preserveAspectRatio}\n style={{ color: textColor(props.color ?? \"prose\"), display: \"block\" }}\n >\n {rects.map((rect, index) => (\n <rect\n key={`r${index}`}\n x={rect.x}\n y={rect.y}\n width={rect.width}\n height={rect.height}\n rx={rect.rx}\n fill={textColor(rect.fill)}\n stroke={textColor(rect.stroke)}\n />\n ))}\n {circles.map((circle, index) => (\n <circle\n key={`c${index}`}\n cx={circle.cx}\n cy={circle.cy}\n r={circle.r}\n fill={textColor(circle.fill)}\n stroke={textColor(circle.stroke)}\n />\n ))}\n {paths.map((path, index) => (\n <path\n key={`p${index}`}\n d={path.d}\n fill={textColor(path.fill)}\n stroke={textColor(path.stroke)}\n strokeWidth={path.strokeWidth}\n />\n ))}\n {lines.map((line, index) => (\n <line\n key={`l${index}`}\n x1={line.x1}\n y1={line.y1}\n x2={line.x2}\n y2={line.y2}\n stroke={textColor(line.stroke) ?? \"currentColor\"}\n />\n ))}\n {texts.map((text, index) => (\n <text\n key={`t${index}`}\n x={text.x}\n y={text.y}\n fontSize={text.size}\n fill={textColor(text.fill)}\n textAnchor={text.anchor}\n stroke=\"none\"\n >\n {text.text}\n </text>\n ))}\n </svg>\n );\n}\n\n/** A YouTube id is about 11 characters of [A-Za-z0-9_-]. Others are refused. */\nconst YOUTUBE_ID = /^[A-Za-z0-9_-]{6,20}$/;\n\n/**\n * The id of a YouTube video or short in `url`, or `undefined` for another\n * URL. Accepts watch, embed, shorts, live and youtu.be links.\n */\nexport function youTubeIdOf(url: string) {\n let parsed: URL;\n try {\n parsed = new URL(url);\n } catch {\n return undefined;\n }\n const host = parsed.hostname.replace(/^www\\.|^m\\./, \"\");\n let id: string | null | undefined;\n if (host === \"youtu.be\") {\n id = parsed.pathname.slice(1);\n } else if (host === \"youtube.com\" || host === \"youtube-nocookie.com\") {\n const match = parsed.pathname.match(/^\\/(?:embed|shorts|live|v)\\/([^/]+)/);\n id = match ? match[1] : parsed.searchParams.get(\"v\");\n }\n return id && YOUTUBE_ID.test(id) ? id : undefined;\n}\n\ntype VideoProps = z.output<typeof videoSchema>;\n\nconst VIDEO_FILE = /\\.(mp4|m4v|webm|ogv|ogg|mov|m3u8|mpd)$/i;\n/** Video sites whose pages the native player cannot play. */\nconst VIDEO_PAGE_HOSTS = [\n \"youtube.com\",\n \"youtube-nocookie.com\",\n \"youtu.be\",\n \"vimeo.com\",\n \"dailymotion.com\",\n \"twitch.tv\",\n \"tiktok.com\",\n \"loom.com\",\n \"wistia.com\",\n \"facebook.com\",\n \"instagram.com\",\n \"x.com\",\n \"twitter.com\",\n];\n\nexport type VideoSource = \"youtube\" | \"file\" | \"page\";\n\n/**\n * How to show a video URL: the YouTube embed, the native player for a file\n * (a known extension, or any URL that is not a page of a video site), or a\n * link for a page the player cannot play. A URL that does not parse is a\n * file: the player reports the failure, and the link takes its place.\n */\nexport function videoSourceOf(url: string): VideoSource {\n if (youTubeIdOf(url) !== undefined) return \"youtube\";\n let parsed: URL;\n try {\n parsed = new URL(url);\n } catch {\n return \"file\";\n }\n if (VIDEO_FILE.test(parsed.pathname)) return \"file\";\n const host = parsed.hostname.replace(/^www\\.|^m\\./, \"\");\n const isPage = VIDEO_PAGE_HOSTS.some(\n (site) => host === site || host.endsWith(`.${site}`),\n );\n return isPage ? \"page\" : \"file\";\n}\n\n/** A link to a video that cannot play here, in place of a dead player. */\nfunction VideoLink({\n url,\n title,\n box,\n aria,\n}: {\n url: string;\n title: string | undefined;\n box: CSSProperties;\n aria: ReturnType<typeof useGenerativeUIAccessibility>;\n}) {\n const href = /^https?:/i.test(url.trim()) ? url.trim() : undefined;\n const host = hostOf(url);\n const body = (\n <>\n <span\n aria-hidden=\"true\"\n style={{\n width: 40,\n height: 40,\n borderRadius: \"50%\",\n background: \"rgba(255,255,255,.15)\",\n display: \"inline-flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n fontSize: 16,\n }}\n >\n ▶\n </span>\n <span style={{ fontWeight: 500 }}>{title ?? \"Watch video\"}</span>\n {host ? (\n <span style={{ opacity: 0.7, fontSize: \".875em\" }}>{host}</span>\n ) : null}\n </>\n );\n const style: CSSProperties = {\n ...box,\n aspectRatio: undefined,\n display: \"flex\",\n flexDirection: \"column\",\n alignItems: \"center\",\n justifyContent: \"center\",\n gap: spacing(2),\n padding: spacing(6),\n boxSizing: \"border-box\",\n background: \"#000\",\n color: \"#fff\",\n textDecoration: \"none\",\n };\n if (href === undefined) {\n return (\n <span data-a2ui-video-link=\"\" {...aria} style={style}>\n {body}\n </span>\n );\n }\n return (\n <a\n data-a2ui-video-link=\"\"\n href={href}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n aria-label={`Open ${title ?? \"video\"} on ${host ?? \"its site\"}`}\n {...aria}\n style={style}\n >\n {body}\n </a>\n );\n}\n\n/*\n * The YouTube player is cross-origin (youtube-nocookie.com). So\n * allow-same-origin only lets it use its own origin. It cannot get to the\n * host page.\n */\nfunction Video(props: VideoProps) {\n const aria = useGenerativeUIAccessibility();\n const [isPlaying, setIsPlaying] = useState(false);\n const [failedUrl, setFailedUrl] = useState<string>();\n const youTubeId = youTubeIdOf(props.url);\n const box: CSSProperties = {\n display: \"block\",\n aspectRatio: props.aspectRatio ?? \"16 / 9\",\n width: spacing(props.width) ?? \"100%\",\n maxWidth: spacing(props.maxWidth) ?? \"100%\",\n flexGrow: props.weight,\n borderRadius: radius(\"lg\"),\n };\n const source = videoSourceOf(props.url);\n if (source === \"page\" || failedUrl === props.url) {\n return (\n <VideoLink url={props.url} title={props.title} box={box} aria={aria} />\n );\n }\n if (youTubeId === undefined) {\n return (\n <video\n controls\n preload=\"metadata\"\n src={props.url}\n poster={props.posterUrl}\n title={props.title}\n aria-label={props.title}\n {...aria}\n // A file that does not load leaves a dead player; a link is better.\n onError={() => setFailedUrl(props.url)}\n // Tracks load in the CORS mode of their media element; without one,\n // a caption file on another host never loads.\n crossOrigin={props.captions?.length ? \"anonymous\" : undefined}\n style={{ ...box, background: \"#000\", objectFit: \"contain\" }}\n >\n {(props.captions ?? []).map((track, index) => (\n <track\n key={`${track.url}-${index}`}\n src={track.url}\n kind={track.kind ?? \"subtitles\"}\n srcLang={track.language}\n label={track.label}\n default={index === 0 ? true : undefined}\n />\n ))}\n </video>\n );\n }\n // The poster first: no third-party script runs until the user asks to play.\n if (!isPlaying) {\n return (\n <button\n type=\"button\"\n aria-label={`Play ${props.title ?? \"video\"}`}\n {...aria}\n onClick={() => setIsPlaying(true)}\n style={{\n ...box,\n position: \"relative\",\n padding: 0,\n border: \"none\",\n overflow: \"hidden\",\n cursor: \"pointer\",\n background: \"#000\",\n }}\n >\n <img\n src={\n props.posterUrl ??\n `https://i.ytimg.com/vi/${youTubeId}/hqdefault.jpg`\n }\n alt=\"\"\n style={{\n width: \"100%\",\n height: \"100%\",\n objectFit: \"cover\",\n display: \"block\",\n }}\n />\n <span\n aria-hidden=\"true\"\n style={{\n position: \"absolute\",\n top: \"50%\",\n left: \"50%\",\n transform: \"translate(-50%, -50%)\",\n width: 56,\n height: 40,\n borderRadius: 12,\n background: \"rgba(0,0,0,.7)\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n color: \"#fff\",\n fontSize: 18,\n }}\n >\n ▶\n </span>\n </button>\n );\n }\n return (\n <iframe\n src={`https://www.youtube-nocookie.com/embed/${youTubeId}?autoplay=1`}\n title={props.title ?? \"YouTube video\"}\n {...aria}\n allow=\"accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture; fullscreen\"\n sandbox=\"allow-scripts allow-same-origin allow-presentation\"\n referrerPolicy=\"strict-origin-when-cross-origin\"\n allowFullScreen\n style={{ ...box, border: 0 }}\n />\n );\n}\n\nfunction AudioPlayer(props: z.output<typeof audioPlayerSchema>) {\n const aria = useGenerativeUIAccessibility();\n return (\n <figure\n data-a2ui-std=\"\"\n {...aria}\n style={{\n display: \"flex\",\n flexDirection: \"column\",\n gap: spacing(1),\n margin: 0,\n width: \"100%\",\n minWidth: 0,\n flexGrow: props.weight,\n }}\n >\n {props.description ? (\n <figcaption\n style={{ fontSize: \".875em\", color: textColor(\"secondary\") }}\n >\n {props.description}\n </figcaption>\n ) : null}\n <audio\n controls\n preload=\"metadata\"\n src={props.url}\n aria-label={props.description}\n style={{ display: \"block\", width: \"100%\" }}\n />\n </figure>\n );\n}\n\nfunction HtmlView(props: z.output<typeof htmlViewSchema>) {\n return (\n <iframe\n // An empty sandbox: no scripts, no same origin, no forms, no popups.\n sandbox=\"\"\n srcDoc={props.html}\n title={props.title ?? \"HTML content\"}\n style={{\n display: \"block\",\n border: `1px solid ${borderColor(\"default\")}`,\n borderRadius: radius(\"md\"),\n height: px(props.height ?? 360),\n width: px(props.width ?? \"100%\"),\n background: backgroundColor(\"surface\"),\n }}\n />\n );\n}\n\n/**\n * The standard media components. Give them to\n * `createGenerativeUI({ components: { ...mediaComponents } })`.\n */\nexport const mediaComponents = withComponents(mediaDeclarations, {\n Image,\n Icon,\n Favicon,\n Svg,\n Video,\n AudioPlayer,\n HtmlView,\n});\n","import React, { useContext, useEffect, useRef, useState } from \"react\";\nimport type { CSSProperties, KeyboardEvent, MouseEvent } from \"react\";\nimport type { z } from \"zod\";\nimport {\n GenerativeUINodeContext,\n useGenerativeUIRuntime,\n} from \"../runtime-context\";\nimport { Lightbox, openUrl } from \"./lightbox\";\nimport { safeHref } from \"./markdown\";\nimport { LucideIcon, hostOf } from \"./media\";\nimport { useStandardStyles } from \"./styles\";\nimport {\n ACCENT,\n FONT_WEIGHT,\n ON_ACCENT,\n SHADOW_MD,\n backgroundColor,\n borderColor,\n compositeDeclarations,\n radius,\n spacing,\n textColor,\n textFont,\n withComponents,\n} from \"@copilotkit/shared/generative-ui\";\nimport type {\n GenerativeUIInvokeResult,\n NO_ARGS,\n cardAction,\n citationSchema,\n entityActionArgs,\n entityCardSchema,\n followUpArgs,\n followUpSchema,\n gridImage,\n imageGridSchema,\n linkCardSchema,\n} from \"@copilotkit/shared/generative-ui\";\n\n/**\n * The composite components: the prebuilt widgets that sit next to\n * its primitives (LinkCard, Citation, FollowUp pills, entity cards, image\n * grids). Each one is a single component, so the model places it with one\n * object instead of eight primitives.\n */\n\n// ---- Schemas ----\n\ntype EventProp<Args = z.input<typeof NO_ARGS>> = (\n args: Args,\n) => Promise<GenerativeUIInvokeResult>;\n\ntype LinkCardProps = z.output<typeof linkCardSchema> & { onClick?: EventProp };\ntype CitationProps = z.output<typeof citationSchema>;\ntype FollowUpProps = z.output<typeof followUpSchema> & {\n onFollowUp?: EventProp<z.input<typeof followUpArgs>>;\n};\ntype CardActionItem = z.output<typeof cardAction>;\ntype EntityCardProps = z.output<typeof entityCardSchema> & {\n onClick?: EventProp;\n onAction?: EventProp<z.input<typeof entityActionArgs>>;\n};\ntype GridImageItem = z.output<typeof gridImage>;\ntype ImageGridProps = z.output<typeof imageGridSchema>;\n\n// ---- Helpers ----\n\nfunction FaviconImage({ host, size = 16 }: { host: string; size?: number }) {\n return (\n <img\n src={`https://www.google.com/s2/favicons?domain=${encodeURIComponent(host)}&sz=64`}\n alt=\"\"\n width={size}\n height={size}\n style={{ display: \"block\", borderRadius: 3, flex: \"none\" }}\n />\n );\n}\n\nconst CLAMP_TWO: CSSProperties = {\n display: \"-webkit-box\",\n WebkitLineClamp: 2,\n WebkitBoxOrient: \"vertical\",\n overflow: \"hidden\",\n};\n\nconst PILL_BUTTON: CSSProperties = {\n font: \"inherit\",\n ...textFont(\"sm\"),\n fontWeight: FONT_WEIGHT.medium,\n padding: \"6px 12px\",\n borderRadius: 9999,\n cursor: \"pointer\",\n textAlign: \"start\",\n};\n\n// ---- LinkCard ----\n\nfunction LinkCard(props: LinkCardProps) {\n useStandardStyles();\n const href = safeHref(props.href);\n const host = href ? hostOf(href) : undefined;\n const domain = props.domain || host || \"\";\n const body = (\n <>\n <span\n style={{\n display: \"flex\",\n flexDirection: \"column\",\n gap: 4,\n minWidth: 0,\n flex: 1,\n }}\n >\n {domain ? (\n <span\n style={{\n display: \"flex\",\n alignItems: \"center\",\n gap: 6,\n ...textFont(\"xs\"),\n color: textColor(\"secondary\"),\n }}\n >\n {props.favicon !== false && host ? (\n <FaviconImage host={host} />\n ) : null}\n <span\n style={{\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n whiteSpace: \"nowrap\",\n }}\n >\n {domain}\n </span>\n </span>\n ) : null}\n <span\n style={{\n ...textFont(\"md\"),\n fontWeight: FONT_WEIGHT.medium,\n color: textColor(\"default\"),\n ...CLAMP_TWO,\n }}\n >\n {props.title}\n </span>\n {props.description ? (\n <span\n style={{\n ...textFont(\"sm\"),\n color: textColor(\"secondary\"),\n ...CLAMP_TWO,\n }}\n >\n {props.description}\n </span>\n ) : null}\n </span>\n {props.image ? (\n <img\n src={props.image}\n alt=\"\"\n loading=\"lazy\"\n style={{\n width: 96,\n height: 96,\n objectFit: \"cover\",\n borderRadius: radius(\"md\"),\n flex: \"none\",\n }}\n />\n ) : null}\n </>\n );\n const style: CSSProperties = {\n display: \"flex\",\n gap: spacing(3),\n alignItems: \"flex-start\",\n padding: spacing(3),\n border: `1px solid ${borderColor(\"default\")}`,\n borderRadius: radius(\"xl\"),\n background: backgroundColor(\"surface\"),\n color: \"inherit\",\n textDecoration: \"none\",\n width: \"100%\",\n boxSizing: \"border-box\",\n cursor: \"pointer\",\n textAlign: \"start\",\n };\n if (props.onClick) {\n return (\n <button\n type=\"button\"\n data-a2ui-link-card=\"\"\n data-a2ui-input=\"\"\n onClick={(event) => {\n event.stopPropagation();\n void props.onClick?.({});\n }}\n style={{ ...style, font: \"inherit\" }}\n >\n {body}\n </button>\n );\n }\n return (\n <a\n data-a2ui-link-card=\"\"\n href={href}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n style={style}\n >\n {body}\n </a>\n );\n}\n\n// ---- Citation ----\n\nfunction Citation(props: CitationProps) {\n useStandardStyles();\n const [isOpen, setIsOpen] = useState(false);\n const rootRef = useRef<HTMLSpanElement>(null);\n useEffect(() => {\n if (!isOpen || typeof document === \"undefined\") return;\n const onDown = (event: globalThis.MouseEvent) => {\n const root = rootRef.current;\n if (root && !root.contains(event.target as Node)) setIsOpen(false);\n };\n document.addEventListener(\"mousedown\", onDown);\n return () => document.removeEventListener(\"mousedown\", onDown);\n }, [isOpen]);\n const url = props.url ? safeHref(props.url) : undefined;\n const host = url ? hostOf(url) : undefined;\n const source = props.source || host || \"\";\n const marker = props.label || String(props.index ?? 1);\n return (\n <span\n ref={rootRef}\n data-a2ui-citation=\"\"\n style={{\n position: \"relative\",\n display: \"inline-flex\",\n verticalAlign: \"baseline\",\n }}\n onMouseEnter={() => setIsOpen(true)}\n onMouseLeave={() => setIsOpen(false)}\n >\n <button\n type=\"button\"\n aria-expanded={isOpen}\n aria-label={`Source ${marker}`}\n data-a2ui-input=\"\"\n onClick={(event) => {\n event.stopPropagation();\n setIsOpen(!isOpen);\n }}\n style={{\n font: \"inherit\",\n fontSize: \".75em\",\n lineHeight: 1,\n fontWeight: FONT_WEIGHT.medium,\n padding: \"2px 6px\",\n margin: \"0 2px\",\n borderRadius: 9999,\n border: \"none\",\n background: backgroundColor(\"surface-secondary\"),\n color: textColor(\"secondary\"),\n cursor: \"pointer\",\n verticalAlign: \"super\",\n }}\n >\n {marker}\n </button>\n {isOpen ? (\n <span\n role=\"dialog\"\n style={{\n position: \"absolute\",\n top: \"100%\",\n left: 0,\n zIndex: 50,\n marginTop: 6,\n width: 280,\n display: \"flex\",\n flexDirection: \"column\",\n gap: 4,\n padding: spacing(3),\n background: backgroundColor(\"surface-elevated\"),\n border: `1px solid ${borderColor(\"default\")}`,\n borderRadius: radius(\"lg\"),\n boxShadow: SHADOW_MD,\n textAlign: \"start\",\n }}\n >\n {source ? (\n <span\n style={{\n display: \"flex\",\n alignItems: \"center\",\n gap: 6,\n ...textFont(\"xs\"),\n color: textColor(\"secondary\"),\n }}\n >\n {host ? <FaviconImage host={host} /> : null}\n {source}\n </span>\n ) : null}\n {props.title ? (\n <span\n style={{\n ...textFont(\"sm\"),\n fontWeight: FONT_WEIGHT.medium,\n color: textColor(\"default\"),\n }}\n >\n {props.title}\n </span>\n ) : null}\n {props.snippet ? (\n <span style={{ ...textFont(\"sm\"), color: textColor(\"secondary\") }}>\n {props.snippet}\n </span>\n ) : null}\n {url ? (\n <a\n href={url}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n style={{ ...textFont(\"xs\"), color: textColor(\"info\") }}\n >\n Open source\n </a>\n ) : null}\n </span>\n ) : null}\n </span>\n );\n}\n\n// ---- FollowUp ----\n\n/** The event a FollowUp pill sends when the model bound no onFollowUp. */\nconst FOLLOW_UP_EVENT = \"follow_up\";\n\n/**\n * A FollowUp always sends. When the model bound `onFollowUp`, that binding\n * runs. Else the pill forwards a `follow_up` event with its message, which\n * the engine turns into a visible user message with that text.\n */\nfunction useFollowUpSend(onFollowUp: FollowUpProps[\"onFollowUp\"]) {\n const runtime = useGenerativeUIRuntime();\n const node = useContext(GenerativeUINodeContext);\n return (message: string) => {\n if (onFollowUp) {\n void onFollowUp({ message });\n return;\n }\n if (!runtime || !node) return;\n const surface = runtime.manager.getSurfaceByKey(node.surfaceKey);\n void runtime.forwardEvent(\n {\n name: FOLLOW_UP_EVENT,\n surfaceId: node.surfaceId,\n componentId: node.componentId,\n userMessage: message,\n context: { message },\n },\n surface?.agentId,\n );\n };\n}\n\nfunction FollowUp(props: FollowUpProps) {\n useStandardStyles();\n const send = useFollowUpSend(props.onFollowUp);\n const items = props.items ?? [];\n if (items.length === 0) return null;\n return (\n <div\n data-a2ui-follow-up=\"\"\n data-a2ui-std=\"\"\n style={{ display: \"flex\", flexDirection: \"column\", gap: spacing(2) }}\n >\n {props.title ? (\n <span style={{ ...textFont(\"sm\"), color: textColor(\"secondary\") }}>\n {props.title}\n </span>\n ) : null}\n <div style={{ display: \"flex\", flexWrap: \"wrap\", gap: spacing(2) }}>\n {items.map((item, index) => {\n const entry = typeof item === \"string\" ? { label: item } : item;\n const message = entry.message ?? entry.label;\n return (\n <button\n key={`${entry.label}-${index}`}\n type=\"button\"\n data-a2ui-input=\"\"\n onClick={(event) => {\n event.stopPropagation();\n send(message);\n }}\n style={{\n ...PILL_BUTTON,\n border: `1px solid ${borderColor(\"default\")}`,\n background: backgroundColor(\"surface\"),\n color: textColor(\"default\"),\n }}\n >\n {entry.label}\n </button>\n );\n })}\n </div>\n </div>\n );\n}\n\n// ---- EntityCard ----\n\nfunction Stars({ value, count }: { value: number; count?: number }) {\n const clamped = Math.max(0, Math.min(5, value));\n const filled = Math.round(clamped);\n return (\n <span\n aria-label={`${clamped} out of 5`}\n style={{\n display: \"inline-flex\",\n alignItems: \"center\",\n gap: 4,\n ...textFont(\"sm\"),\n color: textColor(\"secondary\"),\n }}\n >\n <span\n aria-hidden=\"true\"\n style={{ color: \"var(--a2ui-color-rating, #f5a524)\", letterSpacing: 1 }}\n >\n {\"★\".repeat(filled)}\n <span style={{ color: borderColor(\"strong\") }}>\n {\"★\".repeat(5 - filled)}\n </span>\n </span>\n <span>{clamped.toFixed(1)}</span>\n {count !== undefined ? <span>({count})</span> : null}\n </span>\n );\n}\n\nfunction CardButton({\n item,\n onAction,\n}: {\n item: CardActionItem;\n onAction: EntityCardProps[\"onAction\"];\n}) {\n const variant = item.variant ?? (item.href || onAction ? \"outline\" : \"ghost\");\n const isSolid = variant === \"solid\";\n return (\n <button\n type=\"button\"\n data-a2ui-input=\"\"\n onClick={(event) => {\n event.stopPropagation();\n if (item.href) openUrl(item.href);\n else void onAction?.({ label: item.label });\n }}\n style={{\n ...PILL_BUTTON,\n border:\n variant === \"outline\"\n ? `1px solid ${borderColor(\"default\")}`\n : \"1px solid transparent\",\n background: isSolid\n ? ACCENT\n : variant === \"soft\"\n ? backgroundColor(\"surface-secondary\")\n : \"transparent\",\n color: isSolid ? ON_ACCENT : textColor(\"default\"),\n }}\n >\n {item.label}\n </button>\n );\n}\n\nfunction EntityCard(props: EntityCardProps) {\n useStandardStyles();\n const isHorizontal = props.layout === \"horizontal\";\n const href = props.href ? safeHref(props.href) : undefined;\n const isClickable = href !== undefined || props.onClick !== undefined;\n const onClick = isClickable\n ? (event: MouseEvent | KeyboardEvent) => {\n event.stopPropagation();\n if (props.onClick) void props.onClick({});\n else openUrl(href);\n }\n : undefined;\n const actions = (props.actions ?? []).slice(0, 3);\n const badge = props.badge;\n return (\n <div\n data-a2ui-entity-card=\"\"\n data-a2ui-std=\"\"\n role={isClickable ? \"link\" : undefined}\n tabIndex={isClickable ? 0 : undefined}\n onClick={onClick}\n onKeyDown={\n onClick\n ? (event) => {\n const isOwnKey = event.target === event.currentTarget;\n if (isOwnKey && (event.key === \"Enter\" || event.key === \" \")) {\n event.preventDefault();\n onClick(event);\n }\n }\n : undefined\n }\n style={{\n display: \"flex\",\n flexDirection: isHorizontal ? \"row\" : \"column\",\n gap: isHorizontal ? spacing(3) : 0,\n width: spacing(props.width) ?? \"100%\",\n maxWidth: \"100%\",\n minWidth: 0,\n boxSizing: \"border-box\",\n border: `1px solid ${borderColor(\"default\")}`,\n borderRadius: radius(\"xl\"),\n background: backgroundColor(\"surface\"),\n overflow: \"hidden\",\n // A horizontal card keeps its content height inside a stretched grid\n // row. The vertical card may fill the row.\n alignSelf: isHorizontal ? \"start\" : undefined,\n cursor: isClickable ? \"pointer\" : undefined,\n }}\n >\n {props.image ? (\n <img\n src={props.image}\n alt={props.title}\n loading=\"lazy\"\n style={{\n display: \"block\",\n objectFit: \"cover\",\n width: isHorizontal ? 120 : \"100%\",\n aspectRatio: isHorizontal\n ? \"1 / 1\"\n : (props.imageAspectRatio ?? \"4 / 3\"),\n alignSelf: isHorizontal ? \"start\" : undefined,\n flex: \"none\",\n }}\n />\n ) : null}\n <div\n style={{\n display: \"flex\",\n flexDirection: \"column\",\n gap: 4,\n padding: spacing(3),\n minWidth: 0,\n flex: 1,\n }}\n >\n {badge?.label || props.subtitle ? (\n <div\n style={{\n display: \"flex\",\n alignItems: \"center\",\n gap: 8,\n minWidth: 0,\n }}\n >\n {props.subtitle ? (\n <span\n style={{\n ...textFont(\"xs\"),\n color: textColor(\"secondary\"),\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n whiteSpace: \"nowrap\",\n }}\n >\n {props.subtitle}\n </span>\n ) : null}\n {badge?.label ? (\n <span\n style={{\n ...textFont(\"xs\"),\n fontWeight: FONT_WEIGHT.medium,\n padding: \"1px 8px\",\n borderRadius: 9999,\n background: backgroundColor(\n badge.color ?? \"surface-secondary\",\n ),\n color: textColor(badge.color ?? \"default\"),\n flex: \"none\",\n }}\n >\n {badge.label}\n </span>\n ) : null}\n </div>\n ) : null}\n <span\n style={{\n ...textFont(\"md\"),\n fontWeight: FONT_WEIGHT.medium,\n color: textColor(\"default\"),\n }}\n >\n {props.title}\n </span>\n {props.rating !== undefined ? (\n <Stars value={props.rating} count={props.ratingCount} />\n ) : null}\n {props.description ? (\n <span\n style={{\n ...textFont(\"sm\"),\n color: textColor(\"secondary\"),\n display: \"-webkit-box\",\n WebkitLineClamp: 3,\n WebkitBoxOrient: \"vertical\",\n overflow: \"hidden\",\n }}\n >\n {props.description}\n </span>\n ) : null}\n {props.meta ? (\n <span\n style={{\n ...textFont(\"sm\"),\n fontWeight: FONT_WEIGHT.medium,\n color: textColor(\"default\"),\n marginTop: 2,\n }}\n >\n {props.meta}\n </span>\n ) : null}\n {actions.length > 0 ? (\n <div\n style={{\n display: \"flex\",\n flexWrap: \"wrap\",\n gap: spacing(2),\n marginTop: spacing(2),\n }}\n >\n {actions.map((action, index) => (\n <CardButton\n key={`${action.label}-${index}`}\n item={action}\n onAction={props.onAction}\n />\n ))}\n </div>\n ) : null}\n </div>\n </div>\n );\n}\n\n// ---- ImageGrid ----\n\nfunction ImageGrid(props: ImageGridProps) {\n useStandardStyles();\n const images: GridImageItem[] = props.images ?? [];\n const [open, setOpen] = useState<number | null>(null);\n if (images.length === 0) return null;\n const columns = Math.max(1, Math.floor(props.columns ?? 3));\n const isBento = props.layout === \"bento\" && images.length > 1;\n return (\n <>\n {open !== null ? (\n <Lightbox\n images={images.map((image) => ({\n src: image.url,\n alt: image.description,\n }))}\n index={open}\n onClose={() => setOpen(null)}\n />\n ) : null}\n <div\n data-a2ui-image-grid=\"\"\n data-a2ui-std=\"\"\n style={{\n display: \"grid\",\n gridTemplateColumns: `repeat(${columns}, minmax(0, 1fr))`,\n gridAutoFlow: isBento ? \"dense\" : undefined,\n gap: spacing(props.gap ?? 2),\n width: \"100%\",\n }}\n >\n {images.map((image, index) => {\n const isLead = isBento && index === 0;\n return (\n <figure\n key={`${image.url}-${index}`}\n style={{\n margin: 0,\n minWidth: 0,\n gridColumn: isLead ? `span ${Math.min(2, columns)}` : undefined,\n gridRow: isLead ? \"span 2\" : undefined,\n display: \"flex\",\n flexDirection: \"column\",\n gap: 4,\n }}\n >\n <img\n src={image.url}\n alt={image.description ?? \"\"}\n loading=\"lazy\"\n onClick={() =>\n image.href ? openUrl(image.href) : setOpen(index)\n }\n style={{\n display: \"block\",\n width: \"100%\",\n height: \"100%\",\n aspectRatio: isLead\n ? undefined\n : (props.aspectRatio ?? \"1 / 1\"),\n objectFit: \"cover\",\n borderRadius: radius(\"md\"),\n cursor: image.href ? \"pointer\" : \"zoom-in\",\n }}\n />\n {image.caption ? (\n <figcaption\n style={{ ...textFont(\"xs\"), color: textColor(\"secondary\") }}\n >\n {image.caption}\n </figcaption>\n ) : null}\n </figure>\n );\n })}\n </div>\n </>\n );\n}\n\n/**\n * The standard composite components. Give them to\n * `createGenerativeUI({ components: { ...compositeComponents } })`.\n *\n * - LinkCard and EntityCard open `href`, or send `onClick` when it is bound.\n * - FollowUp sends `onFollowUp` with the message of the pill. Unbound, the\n * engine turns it into a visible user message with that text.\n * - EntityCard buttons without href send `onAction` with their label.\n */\nexport const compositeComponents = withComponents(compositeDeclarations, {\n LinkCard,\n Citation,\n FollowUp,\n EntityCard,\n ImageGrid,\n});\n","import React, { Suspense, memo, useRef } from \"react\";\nimport type { CSSProperties, ComponentType } from \"react\";\nimport type * as Recharts from \"recharts\";\nimport {\n CHART_CURSOR,\n CHART_PALETTE,\n FONT_WEIGHT,\n SHADOW_MD,\n backgroundColor,\n borderColor,\n textColor,\n textFont,\n} from \"@copilotkit/shared/generative-ui\";\nimport type { ChartProps, ChartSeries } from \"@copilotkit/shared/generative-ui\";\n\n// The schema lives in `@copilotkit/shared/generative-ui`; tests import the\n// props type from here.\nexport type { ChartProps };\n\ntype ChartData = NonNullable<ChartProps[\"data\"]>;\n\n// ---- Helpers ----\n\nconst DEFAULT_HEIGHT = 240;\n\n/** Hides an element on screen. Screen readers still read it. */\nexport const VISUALLY_HIDDEN: CSSProperties = {\n position: \"absolute\",\n width: 1,\n height: 1,\n padding: 0,\n margin: -1,\n overflow: \"hidden\",\n clip: \"rect(0 0 0 0)\",\n whiteSpace: \"nowrap\",\n border: 0,\n};\n\n/** Legend labels use the text color, not the series color. */\nfunction legendFormatter(value: string) {\n return (\n <span style={{ color: textColor(\"default\"), fontSize: 13 }}>{value}</span>\n );\n}\n\nconst LEGEND_PROPS = {\n iconType: \"circle\",\n iconSize: 8,\n formatter: legendFormatter,\n wrapperStyle: { paddingTop: 8 },\n} as const;\n\nconst TOOLTIP_PROPS = {\n contentStyle: {\n borderRadius: 10,\n border: `1px solid ${borderColor(\"subtle\")}`,\n boxShadow: SHADOW_MD,\n fontSize: 13,\n },\n cursor: { fill: CHART_CURSOR },\n};\n\ninterface NormalizedSeries {\n key: string;\n label: string;\n color: string;\n}\n\n/**\n * The series with a label and a color each. Without series, the chart shows\n * every number field of the first row, except the x key.\n */\nfunction normalizeSeries(\n series: ChartSeries[] | undefined,\n data: ChartData,\n xKey: string | undefined,\n): NormalizedSeries[] {\n const first = data[0];\n const isEmpty = series === undefined || series.length === 0;\n const list: ChartSeries[] =\n isEmpty && first !== undefined\n ? Object.keys(first).filter(\n (key) => key !== xKey && typeof first[key] === \"number\",\n )\n : (series ?? []);\n return list.map((item, index) => {\n const entry = typeof item === \"string\" ? { key: item } : item;\n return {\n key: entry.key,\n label: (\"label\" in entry && entry.label) || entry.key,\n color:\n textColor(\"color\" in entry ? entry.color : undefined) ??\n CHART_PALETTE[index % CHART_PALETTE.length]!,\n };\n });\n}\n\nfunction numberStyle(format: NonNullable<ChartProps[\"format\"]>) {\n switch (format) {\n case \"currency\":\n return \"currency\";\n case \"percent\":\n return \"percent\";\n case \"number\":\n return \"decimal\";\n }\n}\n\n/**\n * The value formatter of the axis, the tooltip and the value labels.\n * `undefined` when no `format` is set. Axis ticks must stay short (\"$1.6K\",\n * \"25%\"): en-US, no decimals, and compact from 10,000.\n */\nfunction makeFormatter(\n format: ChartProps[\"format\"],\n currency: string | undefined,\n) {\n if (!format) return undefined;\n const build = (isCompact: boolean) => {\n try {\n return new Intl.NumberFormat(\"en-US\", {\n style: numberStyle(format),\n currency: format === \"currency\" ? (currency ?? \"USD\") : undefined,\n maximumFractionDigits: format === \"percent\" ? 1 : 0,\n notation: isCompact ? \"compact\" : undefined,\n });\n } catch {\n // An unknown currency code throws. Plain numbers are a safe fallback.\n return new Intl.NumberFormat(\"en-US\");\n }\n };\n const plain = build(false);\n const compact = build(true);\n return (value: unknown) =>\n typeof value === \"number\"\n ? (Math.abs(value) >= 10_000 ? compact : plain).format(value)\n : String(value ?? \"\");\n}\n\n/**\n * The previous value while the new value has the same JSON.\n *\n * A streaming surface can give a component new props objects with the same\n * content. Recharts rebuilds its SVG nodes on each render that it sees, and\n * the chart then flashes. So `Chart` gives the memoized chart one stable\n * props object, and the chart renders only when its content changes.\n */\nexport function useStableValue<Value>(value: Value) {\n const ref = useRef<{ value: Value; key: string } | null>(null);\n const key = JSON.stringify(value);\n if (ref.current === null || ref.current.key !== key) {\n ref.current = { value, key };\n }\n return ref.current.value;\n}\n\n// ---- Recharts chart ----\n\ntype RechartsModule = typeof Recharts;\ntype ChartComponent = ComponentType<{ props: ChartProps }>;\n\nfunction cartesianChartOf(\n R: RechartsModule,\n chartType: \"bar\" | \"line\" | \"area\" | \"scatter\",\n) {\n switch (chartType) {\n case \"line\":\n return R.LineChart;\n case \"area\":\n return R.AreaChart;\n case \"scatter\":\n return R.ScatterChart;\n case \"bar\":\n return R.BarChart;\n }\n}\n\n/** The chart component, built from the recharts module after it loads. */\nfunction createRechartsChart(R: RechartsModule) {\n return memo(function RechartsChart({ props }: { props: ChartProps }) {\n const data = props.data ?? [];\n const chartType = props.chartType ?? \"bar\";\n const series = normalizeSeries(props.series, data, props.xKey);\n const format = makeFormatter(props.format, props.currency);\n const showLegend = props.showLegend ?? true;\n const showGrid = props.showGrid ?? true;\n const showTooltip = props.showTooltip ?? true;\n const height = props.height ?? DEFAULT_HEIGHT;\n const axisTick = { fontSize: 12, fill: textColor(\"secondary\") };\n const valueLabel = props.showValueLabels\n ? { position: \"top\" as const, fontSize: 11, formatter: format }\n : undefined;\n const tooltip = showTooltip ? (\n <R.Tooltip formatter={format} {...TOOLTIP_PROPS} />\n ) : null;\n\n if (chartType === \"pie\" || chartType === \"donut\") {\n const first = series[0];\n return (\n <R.ResponsiveContainer\n width=\"100%\"\n height={height}\n initialDimension={{ width: 320, height }}\n >\n <R.PieChart>\n {first ? (\n <R.Pie\n data={data}\n dataKey={first.key}\n nameKey={props.xKey ?? \"name\"}\n innerRadius={\n props.innerRadius ?? (chartType === \"donut\" ? \"55%\" : 0)\n }\n outerRadius={props.outerRadius ?? \"80%\"}\n startAngle={props.startAngle ?? 90}\n endAngle={props.endAngle ?? -270}\n cornerRadius={props.cornerRadius}\n paddingAngle={props.paddingAngle}\n label={\n props.showValueLabels\n ? format\n ? ({ value }) => format(value)\n : true\n : undefined\n }\n labelLine={\n props.showValueLabels ? (props.showLabelLines ?? true) : false\n }\n isAnimationActive={false}\n >\n {data.map((_, index) => (\n <R.Cell\n key={`cell-${index}`}\n fill={CHART_PALETTE[index % CHART_PALETTE.length]}\n />\n ))}\n </R.Pie>\n ) : null}\n {tooltip}\n {showLegend ? <R.Legend {...LEGEND_PROPS} /> : null}\n </R.PieChart>\n </R.ResponsiveContainer>\n );\n }\n\n const CartesianChart = cartesianChartOf(R, chartType);\n const stackId = props.stacked ? \"stack\" : undefined;\n const isHorizontal = props.layout === \"horizontal\";\n const xKey = props.xKey;\n // Scatter uses numeric distances when all x values are numbers. Preserve\n // category spacing for string/mixed data and for the other chart types.\n const isNumericScatter =\n chartType === \"scatter\" &&\n xKey !== undefined &&\n data.length > 0 &&\n data.every(\n (row) => typeof row[xKey] === \"number\" && Number.isFinite(row[xKey]),\n );\n const domain: [number | \"auto\", number | \"auto\"] = [\n props.yAxis?.min ?? \"auto\",\n props.yAxis?.max ?? \"auto\",\n ];\n const valueAxisLabel = props.yAxis?.label\n ? {\n value: props.yAxis.label,\n position: isHorizontal\n ? (\"insideBottom\" as const)\n : (\"insideLeft\" as const),\n angle: isHorizontal ? 0 : -90,\n fontSize: 12,\n fill: textColor(\"secondary\"),\n }\n : undefined;\n const dot = props.showDots ? { r: 3, strokeWidth: 0 } : false;\n const marks = series.map((item) => {\n const common = {\n dataKey: item.key,\n name: item.label,\n isAnimationActive: false,\n };\n switch (chartType) {\n case \"line\":\n return (\n <R.Line\n key={item.key}\n {...common}\n type=\"monotone\"\n stroke={item.color}\n strokeWidth={2}\n dot={dot ? { ...dot, fill: item.color } : false}\n label={valueLabel}\n />\n );\n case \"area\":\n return (\n <R.Area\n key={item.key}\n {...common}\n type=\"monotone\"\n stroke={item.color}\n fill={item.color}\n fillOpacity={0.2}\n stackId={stackId}\n dot={dot ? { ...dot, fill: item.color } : false}\n label={valueLabel}\n />\n );\n case \"scatter\":\n return <R.Scatter key={item.key} {...common} fill={item.color} />;\n case \"bar\":\n return (\n <R.Bar\n key={item.key}\n {...common}\n fill={item.color}\n stackId={stackId}\n radius={\n stackId\n ? 0\n : props.barRadius !== undefined\n ? props.barRadius\n : isHorizontal\n ? [0, 4, 4, 0]\n : [4, 4, 0, 0]\n }\n label={valueLabel}\n />\n );\n }\n });\n return (\n <R.ResponsiveContainer\n width=\"100%\"\n height={height}\n initialDimension={{ width: 320, height }}\n >\n <CartesianChart\n data={data}\n // recharts calls the axis layout of a horizontal bar chart \"vertical\".\n layout={isHorizontal ? \"vertical\" : \"horizontal\"}\n margin={{ top: 8, right: 8, bottom: 0, left: 0 }}\n >\n {showGrid ? (\n <R.CartesianGrid\n strokeDasharray=\"3 3\"\n stroke={borderColor(\"subtle\")}\n vertical={isHorizontal}\n horizontal={!isHorizontal}\n />\n ) : null}\n {isHorizontal ? (\n <>\n <R.XAxis\n type=\"number\"\n domain={domain}\n tick={axisTick}\n tickLine={false}\n axisLine={{ stroke: borderColor(\"default\") }}\n tickFormatter={format}\n label={valueAxisLabel}\n />\n <R.YAxis\n type={isNumericScatter ? \"number\" : \"category\"}\n dataKey={props.xKey}\n tick={axisTick}\n tickLine={false}\n axisLine={false}\n width={props.yAxis?.width ?? 96}\n />\n </>\n ) : (\n <>\n <R.XAxis\n type={isNumericScatter ? \"number\" : \"category\"}\n dataKey={props.xKey}\n tick={axisTick}\n tickLine={false}\n axisLine={{ stroke: borderColor(\"default\") }}\n />\n <R.YAxis\n domain={domain}\n tick={axisTick}\n tickLine={false}\n axisLine={false}\n tickFormatter={format}\n width={props.yAxis?.width ?? 64}\n label={valueAxisLabel}\n />\n </>\n )}\n {tooltip}\n {showLegend && series.length > 0 ? (\n <R.Legend {...LEGEND_PROPS} />\n ) : null}\n {marks}\n </CartesianChart>\n </R.ResponsiveContainer>\n );\n });\n}\n\n/**\n * The chart data as a table. Screen readers read it next to the chart. It\n * is also the visible chart when recharts cannot load.\n */\nfunction ChartDataTable({\n props,\n style,\n}: {\n props: ChartProps;\n style?: CSSProperties;\n}) {\n const data = props.data ?? [];\n const series = normalizeSeries(props.series, data, props.xKey);\n const format = makeFormatter(props.format, props.currency) ?? String;\n const xKey = props.xKey;\n const cell: CSSProperties = {\n ...textFont(\"sm\"),\n padding: \"4px 8px\",\n textAlign: \"start\",\n borderBottom: `1px solid ${borderColor(\"subtle\")}`,\n };\n return (\n <table style={{ width: \"100%\", borderCollapse: \"collapse\", ...style }}>\n <thead>\n <tr>\n {xKey ? (\n <th scope=\"col\" style={cell}>\n {xKey}\n </th>\n ) : null}\n {series.map((item) => (\n <th key={item.key} scope=\"col\" style={cell}>\n {item.label}\n </th>\n ))}\n </tr>\n </thead>\n <tbody>\n {data.map((row, index) => (\n <tr key={index}>\n {xKey ? (\n <th scope=\"row\" style={{ ...cell, fontWeight: \"normal\" }}>\n {String(row[xKey] ?? \"\")}\n </th>\n ) : null}\n {series.map((item) => (\n <td key={item.key} style={cell}>\n {format(row[item.key])}\n </td>\n ))}\n </tr>\n ))}\n </tbody>\n </table>\n );\n}\n\nfunction VisibleDataTable({ props }: { props: ChartProps }) {\n return <ChartDataTable props={props} />;\n}\n\n/**\n * recharts loads on first render, so it stays out of the main bundle. When\n * the import fails, the chart becomes a plain data table.\n */\nconst LazyRechartsChart = React.lazy(() =>\n import(\"recharts\").then(\n (R): { default: ChartComponent } => ({\n default: createRechartsChart(R),\n }),\n (): { default: ChartComponent } => ({ default: VisibleDataTable }),\n ),\n);\n\nfunction ChartPlaceholder({ height }: { height: number }) {\n return (\n <div\n aria-hidden=\"true\"\n style={{\n height,\n borderRadius: 8,\n background: backgroundColor(\"surface-secondary\"),\n }}\n />\n );\n}\n\n/**\n * A bar, line, area, scatter, pie or donut chart on recharts. The drawing\n * is hidden from screen readers. They read a data table of the same values.\n */\nexport function Chart(props: ChartProps) {\n const stable = useStableValue(props);\n const height = stable.height ?? DEFAULT_HEIGHT;\n const chartType = stable.chartType ?? \"bar\";\n return (\n <figure\n data-a2ui-std=\"\"\n style={{ position: \"relative\", margin: 0, width: \"100%\", minWidth: 0 }}\n >\n {stable.title ? (\n <figcaption\n style={{\n ...textFont(\"sm\"),\n fontWeight: FONT_WEIGHT.semibold,\n marginBottom: 8,\n }}\n >\n {stable.title}\n </figcaption>\n ) : null}\n <div\n aria-hidden=\"true\"\n data-a2ui-chart={chartType}\n style={{ minHeight: height, width: \"100%\", overflowX: \"auto\" }}\n >\n <Suspense fallback={<ChartPlaceholder height={height} />}>\n <LazyRechartsChart props={stable} />\n </Suspense>\n </div>\n <ChartDataTable props={stable} style={VISUALLY_HIDDEN} />\n </figure>\n );\n}\n","import React, { useEffect, useInsertionEffect, useRef, useState } from \"react\";\nimport type { z } from \"zod\";\nimport { useRequiredGenerativeUIRuntime } from \"../runtime-context\";\nimport { useStableValue } from \"./Chart\";\nimport {\n FONT_WEIGHT,\n backgroundColor,\n borderColor,\n radius,\n spacing,\n textColor,\n textFont,\n} from \"@copilotkit/shared/generative-ui\";\nimport type { MapMarker, mapSchema } from \"@copilotkit/shared/generative-ui\";\nimport { useStandardStyles } from \"./styles\";\n\ntype MapProps = z.output<typeof mapSchema> & {\n /** From the engine: `selected` is writable. */\n setSelected: (value: string) => void;\n};\n\n// ---- Map style ----\n\n/**\n * The default basemap: the Positron style of OpenFreeMap. It is a keyless\n * OpenStreetMap vector style with streets and labels at city zoom. A host\n * sets another style with `theme: { mapStyle: \"<style url>\" }`, and a\n * dark one with `theme: { dark: { mapStyle: \"<style url>\" } }`.\n */\nexport const DEFAULT_MAP_STYLE =\n \"https://tiles.openfreemap.org/styles/positron\";\n/** The default basemap in dark mode: the Dark style of OpenFreeMap. */\nexport const DEFAULT_DARK_MAP_STYLE =\n \"https://tiles.openfreemap.org/styles/dark\";\n\nconst ORDERING_OPS = new Set([\"<\", \"<=\", \">\", \">=\"]);\n\n/**\n * A filter expression with every numeric comparison of a feature property\n * guarded by `[\"has\", property]`.\n *\n * MapLibre adds a number assertion to `[\"get\", key]` in a comparison with a\n * number. The assertion logs a warning for each feature without the\n * property. OpenFreeMap styles compare `ref_length` on roads that mostly do\n * not have it. The comparison is false for a missing property in both\n * cases, so the guard changes no result.\n */\nexport function guardNumericFilter(filter: unknown): unknown {\n if (!Array.isArray(filter)) return filter;\n const [op, left, right] = filter;\n const isPropertyComparison =\n typeof op === \"string\" &&\n ORDERING_OPS.has(op) &&\n Array.isArray(left) &&\n left[0] === \"get\" &&\n typeof left[1] === \"string\" &&\n typeof right === \"number\";\n if (isPropertyComparison) return [\"all\", [\"has\", left[1]], filter];\n return filter.map((part) => guardNumericFilter(part));\n}\n\n/** The style with `guardNumericFilter` applied to each layer filter. */\nexport function guardStyleFilters<Style extends { layers?: readonly object[] }>(\n style: Style,\n) {\n const layers = style.layers;\n if (layers === undefined) return style;\n const guarded = layers.map((layer) =>\n \"filter\" in layer\n ? { ...layer, filter: guardNumericFilter(layer.filter) }\n : layer,\n );\n // The guard only wraps a comparison in [\"all\", [\"has\", key], comparison],\n // which is a valid filter, so each layer keeps its type.\n return { ...style, layers: guarded } as Style;\n}\n\n// ---- Styles ----\n\nconst MAP_STYLE_ID = \"a2ui-standard-map\";\nconst ROUTE_SOURCE = \"a2ui-route\";\n\n/**\n * The few maplibre-gl rules that markers and popups need, so a host does not\n * have to import maplibre-gl.css. The list of places is hidden while the map\n * shows. It shows when a keyboard user moves focus into it.\n */\nconst MAP_CSS = [\n \".maplibregl-map{position:relative;overflow:hidden}\",\n \".maplibregl-canvas{position:absolute;left:0;top:0}\",\n \".maplibregl-canvas-container{width:100%;height:100%}\",\n \".maplibregl-marker{position:absolute;top:0;left:0;will-change:transform;cursor:pointer}\",\n \".maplibregl-popup{position:absolute;top:0;left:0;display:flex;will-change:transform;pointer-events:none}\",\n \".maplibregl-popup-content{position:relative;background:var(--a2ui-color-surface-elevated, #fff);color:var(--a2ui-color-text-default, #0d0d0d);border-radius:6px;padding:6px 10px;font:12px/1.4 system-ui,sans-serif;box-shadow:var(--a2ui-shadow-sm, 0 1px 4px rgba(0,0,0,.2));pointer-events:auto}\",\n \".maplibregl-popup-tip{display:none}\",\n \".maplibregl-popup-close-button{display:none}\",\n \".maplibregl-ctrl-attrib{font:10px system-ui,sans-serif;position:absolute;right:0;bottom:0;background:color-mix(in srgb, var(--a2ui-color-surface, #fff) 70%, transparent);color:var(--a2ui-color-text-secondary, #5d5d5d);padding:0 4px}\",\n \".maplibregl-ctrl-attrib a{color:inherit}\",\n // The cooperative-gesture hint is hidden until MapLibre adds `maplibregl-show`.\n \".maplibregl-cooperative-gesture-screen{align-items:center;background:rgba(0,0,0,.4);color:#fff;display:flex;font:14px/1.3 system-ui,sans-serif;inset:0;justify-content:center;opacity:0;padding:1rem;pointer-events:none;position:absolute;text-align:center;transition:opacity 1s ease 1s;z-index:2}\",\n \".maplibregl-cooperative-gesture-screen.maplibregl-show{opacity:1;transition:opacity .05s}\",\n \".maplibregl-cooperative-gesture-screen .maplibregl-mobile-message{display:none}\",\n \"@media (hover:none){.maplibregl-cooperative-gesture-screen .maplibregl-desktop-message{display:none}.maplibregl-cooperative-gesture-screen .maplibregl-mobile-message{display:block}}\",\n \".a2ui-std-map-places[data-collapsed]:not(:focus-within){position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}\",\n].join(\"\\n\");\n\n// There is no document on the server, so nothing is added there.\nconst noEffect: typeof useInsertionEffect = () => {};\nconst useInjectEffect =\n typeof document === \"undefined\" ? noEffect : useInsertionEffect;\n\nfunction useMapStyles() {\n useInjectEffect(() => {\n if (document.getElementById(MAP_STYLE_ID)) return;\n const style = document.createElement(\"style\");\n style.id = MAP_STYLE_ID;\n style.textContent = MAP_CSS;\n document.head.appendChild(style);\n }, []);\n}\n\n// ---- MapLibre ----\n\ntype MapLibre = typeof import(\"maplibre-gl\");\n\nfunction isMapLibre(value: unknown): value is MapLibre {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"Map\" in value &&\n typeof value.Map === \"function\"\n );\n}\n\n/**\n * Imports maplibre-gl on the client. The package is an optional peer\n * dependency. The import rejects when it is not installed.\n */\nasync function loadMapLibre() {\n const module = await import(\"maplibre-gl\");\n // maplibre-gl is a UMD bundle. Some bundlers put its exports on `default`.\n const fromDefault: unknown = \"default\" in module ? module.default : undefined;\n return isMapLibre(fromDefault) ? fromDefault : module;\n}\n\nconst isValidMarker = (marker: MapMarker) =>\n Number.isFinite(marker.lat) && Number.isFinite(marker.lng);\n\ntype MapStatus = \"loading\" | \"ready\" | \"fallback\";\n\n/**\n * True when the element is in dark mode: it, or an ancestor, has the `dark`\n * class. It follows class changes anywhere in the document.\n */\nfunction useIsDark(ref: React.RefObject<HTMLElement | null>) {\n const [isDark, setIsDark] = useState(false);\n useEffect(() => {\n const check = () => setIsDark(Boolean(ref.current?.closest(\".dark\")));\n check();\n // ponytail: one observer for each map, on every class change in the document. Fine for a few maps; a shared observer when a page has many.\n const observer = new MutationObserver(check);\n observer.observe(document.documentElement, {\n attributes: true,\n attributeFilter: [\"class\"],\n subtree: true,\n });\n return () => observer.disconnect();\n }, [ref]);\n return isDark;\n}\n\n/**\n * A MapLibre map with markers. maplibre-gl loads only in the browser. When\n * it is not installed, or WebGL is not there, the component shows a list of\n * the places. A click on a place or a marker sets `selected`.\n */\nexport function MapView(props: MapProps) {\n useStandardStyles();\n useMapStyles();\n const markers = useStableValue((props.markers ?? []).filter(isValidMarker));\n const center = useStableValue(props.center);\n const { zoom, route } = props;\n const height = props.height ?? 240;\n const containerRef = useRef<HTMLDivElement>(null);\n const [status, setStatus] = useState<MapStatus>(\"loading\");\n const setSelectedRef = useRef(props.setSelected);\n setSelectedRef.current = props.setSelected;\n const { theme } = useRequiredGenerativeUIRuntime();\n const isDark = useIsDark(containerRef);\n // A top-level style applies in both modes. `dark.mapStyle` wins in dark mode.\n const styleUrl = isDark\n ? theme?.dark?.mapStyle || theme?.mapStyle || DEFAULT_DARK_MAP_STYLE\n : theme?.mapStyle || DEFAULT_MAP_STYLE;\n\n useEffect(() => {\n let isCancelled = false;\n let map: InstanceType<MapLibre[\"Map\"]> | undefined;\n\n async function mount() {\n const maplibregl = await loadMapLibre();\n const container = containerRef.current;\n if (isCancelled || !container) return;\n const first = markers[0];\n const start = center ?? first;\n const instance = new maplibregl.Map({\n container,\n center: start ? [start.lng, start.lat] : [0, 20],\n zoom: zoom ?? (markers.length === 1 ? 10 : 1),\n attributionControl: { compact: true },\n // The map is in a chat that scrolls. A plain wheel scrolls the page.\n // Ctrl or Cmd + wheel (two fingers on touch) zooms the map, and\n // MapLibre shows the hint.\n cooperativeGestures: true,\n });\n map = instance;\n // `transformStyle` is an option of setStyle, not of the constructor.\n instance.setStyle(styleUrl, {\n transformStyle: (_previous, next) => guardStyleFilters(next),\n });\n\n for (const marker of markers) {\n const pin = new maplibregl.Marker()\n .setLngLat([marker.lng, marker.lat])\n .setPopup(new maplibregl.Popup({ offset: 24 }).setText(marker.label))\n .addTo(instance);\n pin\n .getElement()\n .addEventListener(\"click\", () =>\n setSelectedRef.current(marker.label),\n );\n }\n\n // With two or more markers, the map always shows all of them. A center\n // and zoom from the model cannot know the pixel size of the map. The\n // fit needs the size of the container, and that size settles after the\n // map mounts (a streaming surface mounts hidden, the chat column\n // reflows). So the fit runs again on each resize, until the user moves\n // the map.\n let hasUserMoved = false;\n instance.on(\"dragstart\", () => {\n hasUserMoved = true;\n });\n instance.on(\"zoomstart\", (event) => {\n if (event.originalEvent) hasUserMoved = true;\n });\n const fitMarkers = () => {\n const isTooSmall =\n container.clientWidth < 10 || container.clientHeight < 10;\n if (markers.length < 2 || hasUserMoved || isTooSmall) return;\n const bounds = new maplibregl.LngLatBounds();\n for (const marker of markers) bounds.extend([marker.lng, marker.lat]);\n instance.fitBounds(bounds, {\n padding: 48,\n maxZoom: zoom ?? 14,\n duration: 0,\n });\n };\n fitMarkers();\n instance.on(\"load\", fitMarkers);\n instance.on(\"resize\", fitMarkers);\n\n if (route && markers.length > 1) {\n instance.on(\"load\", () => {\n if (instance.getSource(ROUTE_SOURCE)) return;\n instance.addSource(ROUTE_SOURCE, {\n type: \"geojson\",\n data: {\n type: \"Feature\",\n properties: {},\n geometry: {\n type: \"LineString\",\n coordinates: markers.map((marker) => [marker.lng, marker.lat]),\n },\n },\n });\n instance.addLayer({\n id: ROUTE_SOURCE,\n type: \"line\",\n source: ROUTE_SOURCE,\n paint: { \"line-color\": \"#0285ff\", \"line-width\": 3 },\n });\n });\n }\n setStatus(\"ready\");\n }\n\n mount().catch(() => {\n // maplibre-gl is not installed, or there is no WebGL.\n map?.remove();\n map = undefined;\n if (!isCancelled) setStatus(\"fallback\");\n });\n\n return () => {\n isCancelled = true;\n try {\n map?.remove();\n } catch {\n // The map is already removed.\n }\n };\n }, [markers, center, zoom, route, styleUrl]);\n\n const isFallback = status === \"fallback\";\n return (\n <div\n data-a2ui-std=\"\"\n data-a2ui-map={status}\n style={{\n position: \"relative\",\n width: \"100%\",\n border: `1px solid ${borderColor(\"default\")}`,\n borderRadius: radius(\"lg\"),\n overflow: \"hidden\",\n background: backgroundColor(\"surface-secondary\"),\n }}\n >\n <div\n ref={containerRef}\n aria-hidden=\"true\"\n style={{\n height,\n width: \"100%\",\n display: isFallback ? \"none\" : \"block\",\n }}\n />\n <ul\n className=\"a2ui-std-list a2ui-std-map-places\"\n role=\"list\"\n aria-label=\"Map places\"\n data-collapsed={isFallback ? undefined : \"\"}\n style={{\n listStyle: \"none\",\n margin: 0,\n padding: spacing(3),\n display: \"flex\",\n flexDirection: \"column\",\n gap: spacing(2),\n maxHeight: height,\n overflowY: \"auto\",\n boxSizing: \"border-box\",\n }}\n >\n {markers.map((marker, index) => {\n const isSelected = props.selected === marker.label;\n return (\n <li key={`${marker.label}-${index}`}>\n <button\n type=\"button\"\n data-a2ui-input=\"\"\n aria-pressed={isSelected}\n onClick={() => props.setSelected(marker.label)}\n style={{\n display: \"flex\",\n alignItems: \"baseline\",\n gap: spacing(2),\n width: \"100%\",\n minHeight: 24,\n textAlign: \"start\",\n border: 0,\n padding: `${spacing(1)} ${spacing(2)}`,\n borderRadius: radius(\"md\"),\n background: isSelected\n ? backgroundColor(\"info\")\n : \"transparent\",\n cursor: \"pointer\",\n color: textColor(\"default\"),\n }}\n >\n <span style={{ fontWeight: FONT_WEIGHT.medium }}>\n {marker.label}\n </span>\n <span\n style={{ ...textFont(\"xs\"), color: textColor(\"secondary\") }}\n >\n {marker.lat.toFixed(4)}, {marker.lng.toFixed(4)}\n {marker.category ? ` · ${marker.category}` : \"\"}\n </span>\n </button>\n </li>\n );\n })}\n </ul>\n </div>\n );\n}\n","import React, { createContext, isValidElement, useContext } from \"react\";\nimport type { CSSProperties, ReactNode } from \"react\";\nimport type { z } from \"zod\";\nimport {\n FONT_WEIGHT,\n backgroundColor,\n borderColor,\n dataDeclarations,\n radius,\n spacing,\n textColor,\n textFont,\n withComponents,\n} from \"@copilotkit/shared/generative-ui\";\nimport type {\n ListItemValue,\n ListMarker,\n ListSelection,\n TableColumn,\n listItemSchema,\n listSchema,\n tableCellSchema,\n tableRowSchema,\n tableSchema,\n tableSectionSchema,\n} from \"@copilotkit/shared/generative-ui\";\nimport { LucideIcon } from \"./media\";\nimport { Chart, VISUALLY_HIDDEN } from \"./Chart\";\nimport { MapView } from \"./Map\";\nimport { useGenerativeUIAccessibility } from \"../accessibility\";\nimport { useStandardStyles } from \"./styles\";\n\ntype EventProp<Args> = (args: Args) => Promise<unknown>;\n\ntype TableProps = z.output<typeof tableSchema> & {\n children?: ReactNode;\n cellComponents?: ReactNode;\n};\ntype TableSectionProps = z.output<typeof tableSectionSchema> & {\n children?: ReactNode;\n};\ntype TableRowProps = z.output<typeof tableRowSchema> & {\n children?: ReactNode;\n};\ntype TableCellProps = z.output<typeof tableCellSchema> & {\n children?: ReactNode;\n};\ntype ListProps = z.output<typeof listSchema> & {\n children?: ReactNode;\n action?: EventProp<ListSelection>;\n};\ntype ListItemProps = z.output<typeof listItemSchema> & {\n children?: ReactNode;\n action?: EventProp<Record<string, never>>;\n};\n\n// ---- Table ----\n\ninterface TableContextValue {\n dividers: boolean;\n /** True inside a TableSection. Rows there render a bare `<tr>`. */\n isInSection: boolean;\n /** True inside a header section or row. Cells there render `<th>`. */\n isHeader: boolean;\n}\n\nconst TableContext = createContext<TableContextValue | null>(null);\n\nconst V_ALIGN = { start: \"top\", center: \"middle\", end: \"bottom\" } as const;\n\n/**\n * The attributes of a cell: 14px text, 8px padding (none at the outer\n * edges), medium weight for headers, hairline row dividers. The padding,\n * edges and dividers come from the `.a2ui-std-cell` rules, so a `padding`\n * prop still wins.\n */\nfunction cellAttributes(options: {\n isHeader: boolean;\n hasDivider: boolean;\n align?: \"start\" | \"center\" | \"end\";\n vAlign?: \"start\" | \"center\" | \"end\";\n width?: number | string;\n padding?: number | string;\n}) {\n return {\n className: \"a2ui-std-cell\",\n \"data-divider\": options.hasDivider ? \"\" : undefined,\n style: {\n ...textFont(\"sm\"),\n textAlign: options.align ?? \"start\",\n verticalAlign: V_ALIGN[options.vAlign ?? \"start\"],\n padding: spacing(options.padding),\n width: spacing(options.width),\n fontWeight: options.isHeader ? FONT_WEIGHT.medium : undefined,\n color: textColor(\"default\"),\n } satisfies CSSProperties,\n };\n}\n\n/** The component id of a `{ componentId }` or `{ id }` cell, else `undefined`. */\nfunction cellComponentId(value: unknown) {\n const isObject =\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n if (!isObject) return undefined;\n if (\"componentId\" in value && typeof value.componentId === \"string\") {\n return value.componentId || undefined;\n }\n if (\"id\" in value && typeof value.id === \"string\") {\n return value.id || undefined;\n }\n return undefined;\n}\n\nfunction cellText(value: unknown) {\n if (value === undefined || value === null) return \"\";\n if (typeof value === \"object\") return JSON.stringify(value);\n return String(value);\n}\n\n/**\n * The rendered components of a \"multiple\" slot by component id. The engine\n * renders a list of ids as one element for each id, keyed by that id.\n */\nfunction elementsById(slot: ReactNode) {\n const byId = new Map<string, ReactNode>();\n const elements = Array.isArray(slot) ? slot : [];\n for (const element of elements) {\n if (isValidElement(element) && typeof element.key === \"string\") {\n byId.set(element.key, element);\n }\n }\n return byId;\n}\n\n/** A component for a `{ componentId }` cell, else the cell value as text. */\nfunction cellContent(value: unknown, components: Map<string, ReactNode>) {\n const id = cellComponentId(value);\n if (id === undefined) return cellText(value);\n return components.get(id) ?? null;\n}\n\ninterface NormalizedColumn {\n label?: string;\n align?: \"start\" | \"center\" | \"end\";\n width?: number | string;\n componentId?: string;\n}\n\nfunction normalizeColumn(column: TableColumn): NormalizedColumn {\n if (typeof column === \"string\") return { label: column };\n const componentId = cellComponentId(column);\n return \"label\" in column ? { ...column, componentId } : { componentId };\n}\n\nfunction Caption({ text }: { text: string | undefined }) {\n if (!text) return null;\n return <caption style={VISUALLY_HIDDEN}>{text}</caption>;\n}\n\nfunction Table(props: TableProps) {\n useStandardStyles();\n const dividers = props.dividers ?? true;\n const columns = (props.columns ?? []).map(normalizeColumn);\n const rows = props.rows ?? [];\n const components = elementsById(props.cellComponents);\n const tableStyle: CSSProperties = {\n width: \"100%\",\n borderCollapse: \"collapse\",\n tableLayout: props.columnSizing === \"equal\" ? \"fixed\" : \"auto\",\n };\n const wrapperStyle: CSSProperties = {\n maxHeight: props.stickyHeader ? 480 : undefined,\n overflowY: props.stickyHeader ? \"auto\" : undefined,\n };\n const isChildrenMode =\n props.children !== undefined && rows.length === 0 && columns.length === 0;\n\n if (isChildrenMode) {\n return (\n <div\n className=\"a2ui-std-table-wrap\"\n data-a2ui-std=\"\"\n style={wrapperStyle}\n >\n <TableContext.Provider\n value={{ dividers, isInSection: false, isHeader: false }}\n >\n <table className=\"a2ui-std-table\" style={tableStyle}>\n <Caption text={props.caption} />\n {props.children}\n </table>\n </TableContext.Provider>\n </div>\n );\n }\n\n const rowLengths = rows.map((row) => row.length);\n const columnCount = Math.max(columns.length, ...rowLengths, 1);\n const stickyStyle: CSSProperties = props.stickyHeader\n ? { position: \"sticky\", top: 0, background: backgroundColor(\"surface\") }\n : {};\n\n return (\n <div className=\"a2ui-std-table-wrap\" data-a2ui-std=\"\" style={wrapperStyle}>\n <table className=\"a2ui-std-table\" style={tableStyle}>\n <Caption text={props.caption} />\n {columns.length > 0 ? (\n <thead>\n <tr>\n {columns.map((column, index) => {\n const cell = cellAttributes({\n isHeader: true,\n hasDivider: true,\n align: column.align,\n width: column.width,\n });\n return (\n <th\n key={`${column.label ?? column.componentId}-${index}`}\n scope=\"col\"\n {...cell}\n style={{ ...cell.style, ...stickyStyle }}\n >\n {column.label}\n {column.componentId\n ? components.get(column.componentId)\n : null}\n </th>\n );\n })}\n </tr>\n </thead>\n ) : null}\n <tbody>\n {rows.length === 0 ? (\n <tr>\n <td\n colSpan={columnCount}\n className=\"a2ui-std-cell\"\n style={{\n ...cellAttributes({ isHeader: false, hasDivider: false })\n .style,\n color: textColor(\"tertiary\"),\n textAlign: \"center\",\n }}\n >\n {props.emptyLabel ?? \"No rows\"}\n </td>\n </tr>\n ) : (\n rows.map((row, rowIndex) => (\n <tr key={rowIndex}>\n {row.map((value, columnIndex) => (\n <td\n key={columnIndex}\n {...cellAttributes({\n isHeader: false,\n hasDivider: dividers && rowIndex < rows.length - 1,\n align: columns[columnIndex]?.align,\n })}\n >\n {cellContent(value, components)}\n </td>\n ))}\n </tr>\n ))\n )}\n </tbody>\n </table>\n </div>\n );\n}\n\nfunction TableSection(props: TableSectionProps) {\n const aria = useGenerativeUIAccessibility();\n const parent = useContext(TableContext);\n const isHeader = props.header === true;\n const Tag = isHeader ? \"thead\" : \"tbody\";\n return (\n <TableContext.Provider\n value={{\n dividers: props.rowDivider ?? parent?.dividers ?? true,\n isInSection: true,\n isHeader,\n }}\n >\n <Tag {...aria}>{props.children}</Tag>\n </TableContext.Provider>\n );\n}\n\nfunction TableRow(props: TableRowProps) {\n const aria = useGenerativeUIAccessibility();\n const parent = useContext(TableContext);\n const isHeader = props.header === true || parent?.isHeader === true;\n const dividers = parent?.dividers ?? true;\n const row = (\n <TableContext.Provider\n value={{\n dividers,\n isInSection: true,\n isHeader,\n }}\n >\n <tr {...aria}>\n {props.label ? (\n <th\n scope=\"row\"\n colSpan={props.labelColSpan}\n {...cellAttributes({\n isHeader: true,\n hasDivider: dividers,\n align: \"start\",\n })}\n >\n {props.label}\n </th>\n ) : null}\n {props.children}\n </tr>\n </TableContext.Provider>\n );\n // A row directly in a Table gets its own row group, so the DOM stays valid\n // (table > tbody > tr). A table can have many tbody elements.\n const isDirectChild = parent !== null && !parent.isInSection;\n if (!isDirectChild) return row;\n const Group = isHeader ? \"thead\" : \"tbody\";\n return <Group>{row}</Group>;\n}\n\nfunction TableCell(props: TableCellProps) {\n const aria = useGenerativeUIAccessibility();\n const parent = useContext(TableContext);\n const isHeader = props.header === true || parent?.isHeader === true;\n // A header cell in a header row names a column. Else it names its row.\n const scope = parent?.isHeader ? \"col\" : \"row\";\n const Tag = isHeader ? \"th\" : \"td\";\n return (\n <Tag\n {...aria}\n scope={isHeader ? scope : undefined}\n colSpan={props.colSpan}\n rowSpan={props.rowSpan}\n {...cellAttributes({\n isHeader,\n hasDivider: parent?.dividers ?? true,\n align: props.align,\n vAlign: props.vAlign,\n width: props.width,\n padding: props.padding,\n })}\n >\n {props.text === undefined ? null : cellText(props.text)}\n {props.children}\n </Tag>\n );\n}\n\n// ---- List ----\n\ninterface ListContextValue {\n marker: ListMarker;\n hasConnector: boolean;\n maxMarkerSize?: number;\n}\n\nconst ListContext = createContext<ListContextValue | null>(null);\n\nconst isNativeMarker = (marker: string | undefined) =>\n marker === \"bullet\" || marker === \"number\";\n\nfunction listStyle(\n marker: ListMarker,\n props: Pick<ListProps, \"gap\" | \"direction\" | \"align\" | \"weight\">,\n) {\n const listStyleType =\n marker === \"number\" ? \"decimal\" : marker === \"bullet\" ? \"disc\" : \"none\";\n const isHorizontal = props.direction === \"horizontal\";\n return {\n margin: 0,\n paddingInlineStart: isNativeMarker(marker) && !isHorizontal ? \"1.5em\" : 0,\n listStyleType: isHorizontal ? \"none\" : listStyleType,\n display: \"flex\",\n flexDirection: isHorizontal ? \"row\" : \"column\",\n alignItems: props.align ? ALIGN_CSS[props.align] : undefined,\n flexGrow: props.weight,\n overflowX: isHorizontal ? \"auto\" : undefined,\n gap: spacing(props.gap ?? (isHorizontal ? 3 : 1)),\n } satisfies CSSProperties;\n}\n\nconst ALIGN_CSS = {\n start: \"flex-start\",\n center: \"center\",\n end: \"flex-end\",\n stretch: \"stretch\",\n} as const;\n\n/** A plain button: no box, the full row is the hit area, a focus ring. */\nconst ITEM_BUTTON_STYLE: CSSProperties = {\n display: \"block\",\n width: \"100%\",\n margin: 0,\n padding: 0,\n border: 0,\n background: \"none\",\n textAlign: \"start\",\n cursor: \"pointer\",\n boxSizing: \"border-box\",\n borderRadius: radius(\"xs\"),\n};\n\nfunction ItemBody({\n label,\n value,\n description,\n icon,\n marker,\n markerSize,\n hasConnector,\n onPick,\n extra,\n}: {\n label?: string;\n value?: string | number;\n description?: string;\n icon?: string;\n marker?: string;\n markerSize?: number;\n hasConnector?: boolean;\n onPick?: () => void;\n extra?: ReactNode;\n}) {\n const hasLeading =\n icon !== undefined || (marker !== undefined && !isNativeMarker(marker));\n const leading = hasLeading ? (\n <span\n aria-hidden=\"true\"\n style={{\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n minWidth: markerSize ?? 20,\n maxWidth: markerSize,\n paddingTop: 2,\n color: textColor(\"secondary\"),\n }}\n >\n {icon ? <LucideIcon name={icon} size=\"sm\" /> : marker}\n </span>\n ) : null;\n const row = (\n <span\n style={{\n display: hasLeading ? \"flex\" : \"block\",\n gap: spacing(2),\n alignItems: \"flex-start\",\n borderInlineStart: hasConnector\n ? `2px solid ${borderColor(\"default\")}`\n : undefined,\n paddingInlineStart: hasConnector ? spacing(3) : undefined,\n }}\n >\n {leading}\n <span\n style={{\n display: \"flex\",\n flexDirection: \"column\",\n minWidth: 0,\n flex: 1,\n }}\n >\n {label || value !== undefined ? (\n <span\n style={{\n display: \"flex\",\n justifyContent: \"space-between\",\n alignItems: \"baseline\",\n gap: spacing(3),\n ...textFont(\"md\"),\n color: textColor(\"default\"),\n }}\n >\n <span>{label}</span>\n {value !== undefined ? (\n <span\n data-a2ui-list-value=\"\"\n style={{\n fontWeight: FONT_WEIGHT.medium,\n fontVariantNumeric: \"tabular-nums\",\n textAlign: \"end\",\n flex: \"none\",\n }}\n >\n {String(value)}\n </span>\n ) : null}\n </span>\n ) : null}\n {description ? (\n <span style={{ ...textFont(\"sm\"), color: textColor(\"secondary\") }}>\n {description}\n </span>\n ) : null}\n {extra}\n </span>\n </span>\n );\n if (!onPick) return row;\n return (\n <button\n type=\"button\"\n data-a2ui-input=\"\"\n onClick={(event) => {\n event.stopPropagation();\n onPick();\n }}\n style={ITEM_BUTTON_STYLE}\n >\n {row}\n </button>\n );\n}\n\nfunction itemEntry(item: ListItemValue) {\n return typeof item === \"string\" ? { label: item } : item;\n}\n\nfunction List(props: ListProps) {\n useStandardStyles();\n const marker = props.marker ?? \"bullet\";\n const hasConnector = props.connector === \"solid\";\n const Tag = marker === \"number\" ? \"ol\" : \"ul\";\n const items = props.items ?? [];\n const action = props.action;\n const body =\n items.length > 0\n ? items.map((item, index) => {\n const entry = itemEntry(item);\n const value = \"value\" in entry ? entry.value : undefined;\n const onPick = action\n ? () =>\n void action({\n index,\n label: entry.label,\n value: value === undefined ? undefined : String(value),\n })\n : undefined;\n return (\n <li key={`${entry.label}-${index}`}>\n <ItemBody\n label={entry.label}\n // With an action, the value is the payload of the pick.\n value={action ? undefined : value}\n description={\n \"description\" in entry ? entry.description : undefined\n }\n icon={\"icon\" in entry ? entry.icon : undefined}\n markerSize={props.maxMarkerSize}\n hasConnector={hasConnector}\n onPick={onPick}\n />\n </li>\n );\n })\n : props.children;\n return (\n <ListContext.Provider\n value={{ marker, hasConnector, maxMarkerSize: props.maxMarkerSize }}\n >\n <Tag\n className=\"a2ui-std-list\"\n data-a2ui-std=\"\"\n // Safari drops the list role when list-style is \"none\".\n role={\n isNativeMarker(marker) && props.direction !== \"horizontal\"\n ? undefined\n : \"list\"\n }\n start={Tag === \"ol\" ? props.start : undefined}\n style={listStyle(marker, props)}\n >\n {body}\n </Tag>\n </ListContext.Provider>\n );\n}\n\nfunction ListItem(props: ListItemProps) {\n const list = useContext(ListContext);\n const Tag = list ? \"li\" : \"div\";\n const isDisabled = props.disabled === true;\n const action = isDisabled ? undefined : props.action;\n // An own marker replaces the native bullet or number.\n const hidesNativeMarker =\n props.marker !== undefined && isNativeMarker(list?.marker);\n return (\n <Tag\n aria-disabled={isDisabled || undefined}\n style={{\n ...(hidesNativeMarker ? { listStyleType: \"none\" } : {}),\n opacity: isDisabled ? 0.5 : undefined,\n }}\n >\n <ItemBody\n label={props.label}\n value={action ? undefined : props.value}\n description={props.description}\n icon={props.icon}\n marker={props.marker}\n markerSize={props.markerSize ?? list?.maxMarkerSize}\n hasConnector={list?.hasConnector}\n onPick={action ? () => void action({}) : undefined}\n extra={props.children}\n />\n </Tag>\n );\n}\n\n/**\n * The standard data components: tables, lists, a chart and a map. Give\n * them to `createGenerativeUI({ components: { ...dataComponents } })`.\n *\n * - Table: `children` (TableSection or TableRow ids, or a template) and\n * `cellComponents` (the components that `{ componentId }` cells show).\n * - List and ListItem: an `action` event. The List event gets the index,\n * label and value of the picked item.\n * - Map: `selected` is writable, so a `{ \"@path\" }` binding gets the choice of\n * the user.\n */\nexport const dataComponents = withComponents(dataDeclarations, {\n Table,\n TableSection,\n TableRow,\n TableCell,\n List,\n ListItem,\n Chart,\n Map: MapView,\n});\n","import React, {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport type { CSSProperties, KeyboardEvent, ReactNode, RefObject } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport type { z } from \"zod\";\nimport {\n controlAria,\n useGenerativeUIAccessibility,\n wrapperAria,\n} from \"../accessibility\";\nimport { useGenerativeUIRuntime } from \"../runtime-context\";\nimport { useOverlayEscape } from \"./overlay-stack\";\nimport { useStandardStyles } from \"./styles\";\nimport {\n BACKDROP,\n backgroundColor,\n borderColor,\n feedbackDeclarations,\n radius,\n spacing,\n textColor,\n textFont,\n SHADOW_MD,\n withComponents,\n} from \"@copilotkit/shared/generative-ui\";\nimport type {\n flashcardSchema,\n modalSchema,\n popoverContentSchema,\n popoverSchema,\n popoverTriggerSchema,\n pulseIndicatorSchema,\n} from \"@copilotkit/shared/generative-ui\";\n\n// ---- Styles ----\n\nexport const FEEDBACK_STYLE_ID = \"a2ui-standard-feedback\";\n\n/**\n * The keyframes of the feedback components, and the rule for reduced\n * motion. Reduced is not none: the pulse ring keeps fading but no longer\n * grows (`data-a2ui-pulse`; `!important`, because the ring sets its\n * animation inline), because a status that does not move says nothing.\n * An element that moves has `data-a2ui-motion`.\n */\nexport const FEEDBACK_CSS = [\n \"@keyframes a2ui-pulse{0%{transform:scale(1);opacity:var(--a2ui-pulse-opacity,.6)}100%{transform:scale(var(--a2ui-pulse-scale,2.4));opacity:0}}\",\n \"@keyframes a2ui-pulse-fade{0%{opacity:var(--a2ui-pulse-opacity,.6)}100%{opacity:0}}\",\n \"[data-a2ui-feedback-button]:focus-visible{outline:2px solid var(--a2ui-color-focus, #0285ff);outline-offset:2px}\",\n \"@media (prefers-reduced-motion: reduce){[data-a2ui-pulse]{animation-name:a2ui-pulse-fade !important}}\",\n].join(\"\\n\");\n\n// There is no document on the server, so nothing is added there.\nconst noEffect: typeof React.useInsertionEffect = () => {};\nconst useInjectEffect =\n typeof document === \"undefined\" ? noEffect : React.useInsertionEffect;\n\n/** Adds the standard stylesheet and the feedback stylesheet, once each. */\nfunction useFeedbackStyles() {\n useStandardStyles();\n useInjectEffect(() => {\n if (document.getElementById(FEEDBACK_STYLE_ID)) return;\n const style = document.createElement(\"style\");\n style.id = FEEDBACK_STYLE_ID;\n style.textContent = FEEDBACK_CSS;\n document.head.appendChild(style);\n }, []);\n}\n\n/** A native button without the browser look. */\nconst BUTTON_RESET: CSSProperties = {\n margin: 0,\n padding: 0,\n border: 0,\n background: \"none\",\n font: \"inherit\",\n color: \"inherit\",\n textAlign: \"inherit\",\n cursor: \"pointer\",\n};\n\ntype WithChildren<Props> = Props & { children?: ReactNode };\ntype PulseIndicatorProps = z.output<typeof pulseIndicatorSchema>;\ntype FlashcardProps = z.output<typeof flashcardSchema>;\ntype PopoverProps = WithChildren<\n z.output<typeof popoverSchema> & { setOpen: (value: boolean) => void }\n>;\ntype PopoverTriggerProps = WithChildren<z.output<typeof popoverTriggerSchema>>;\ntype PopoverContentProps = WithChildren<z.output<typeof popoverContentSchema>>;\n\n// ---- Status ----\n\n/** A spinning ring. It is decoration: the caller names the status. */\nfunction PulseIndicator(props: PulseIndicatorProps) {\n useFeedbackStyles();\n const size = props.size ?? 12;\n const color = textColor(props.color ?? \"success\");\n const hasLabel = props.label !== undefined;\n return (\n <span\n role={hasLabel ? \"img\" : undefined}\n aria-label={props.label}\n aria-hidden={hasLabel ? undefined : \"true\"}\n data-a2ui-std=\"\"\n style={{\n position: \"relative\",\n display: \"inline-block\",\n width: size,\n height: size,\n flex: \"none\",\n }}\n >\n <span\n data-a2ui-motion=\"\"\n data-a2ui-pulse=\"\"\n style={\n {\n position: \"absolute\",\n inset: 0,\n borderRadius: \"9999px\",\n background: textColor(props.pulseColor) ?? color,\n animation: `a2ui-pulse ${props.duration ?? 1500}ms ease-out infinite`,\n \"--a2ui-pulse-scale\": props.endScale,\n \"--a2ui-pulse-opacity\": props.startOpacity,\n } as CSSProperties\n }\n />\n <span\n style={{\n position: \"absolute\",\n inset: 0,\n borderRadius: \"9999px\",\n background: color,\n }}\n />\n </span>\n );\n}\n\n// ---- FlashcardFlip ----\n\n/**\n * A native toggle button. Click, Enter and Space flip it, and\n * `aria-pressed` tells a screen reader which side shows.\n */\nfunction FlashcardFlip(props: FlashcardProps) {\n useFeedbackStyles();\n const [flipped, setFlipped] = useState(false);\n const showsHint = props.hint !== undefined && !flipped;\n return (\n <button\n type=\"button\"\n aria-pressed={flipped}\n data-a2ui-std=\"\"\n data-a2ui-feedback-button=\"\"\n onClick={() => setFlipped((current) => !current)}\n style={{\n ...BUTTON_RESET,\n display: \"flex\",\n flexDirection: \"column\",\n alignItems: \"center\",\n justifyContent: \"center\",\n gap: spacing(2),\n minHeight: 140,\n width: \"100%\",\n padding: spacing(5),\n boxSizing: \"border-box\",\n textAlign: \"center\",\n border: `1px solid ${borderColor(\"default\")}`,\n borderRadius: radius(\"xl\"),\n background: backgroundColor(flipped ? \"surface-secondary\" : \"surface\"),\n color: textColor(\"default\"),\n }}\n >\n <span style={{ ...textFont(\"lg\"), fontWeight: 600 }}>\n {flipped ? props.back : props.front}\n </span>\n {showsHint ? (\n <span style={{ ...textFont(\"sm\"), color: textColor(\"tertiary\") }}>\n {props.hint}\n </span>\n ) : null}\n </button>\n );\n}\n\n// ---- Popover ----\n\ninterface PopoverState {\n open: boolean;\n setOpen: (value: boolean) => void;\n triggerId: string;\n contentId: string;\n triggerRef: RefObject<HTMLButtonElement | null>;\n}\n\nconst PopoverContext = createContext<PopoverState | null>(null);\n\n/**\n * A non-modal overlay. It does not trap focus. Escape closes it and moves\n * focus back to the trigger. A pointer press outside of it closes it.\n * `open` is writable, so a `{ \"@path\" }` binding keeps the open state in the\n * data model.\n */\nfunction Popover(props: PopoverProps) {\n useFeedbackStyles();\n const { setOpen } = props;\n const open = props.open ?? false;\n const id = useId();\n const triggerRef = useRef<HTMLButtonElement | null>(null);\n const rootRef = useRef<HTMLDivElement>(null);\n const hoverTimer = useRef<ReturnType<typeof setTimeout> | null>(null);\n const openOnHover = () => {\n if (hoverTimer.current) clearTimeout(hoverTimer.current);\n const delay = props.hoverOpenDelay ?? 0;\n if (delay > 0) hoverTimer.current = setTimeout(() => setOpen(true), delay);\n else setOpen(true);\n };\n const closeOnLeave = () => {\n if (hoverTimer.current) clearTimeout(hoverTimer.current);\n setOpen(false);\n };\n useEffect(() => {\n if (!open) return;\n const onPointerDown = (event: PointerEvent) => {\n const root = rootRef.current;\n const isOutside =\n root !== null &&\n event.target instanceof Node &&\n !root.contains(event.target);\n if (isOutside) setOpen(false);\n };\n document.addEventListener(\"pointerdown\", onPointerDown);\n return () => document.removeEventListener(\"pointerdown\", onPointerDown);\n }, [open, setOpen]);\n const onKeyDown = (event: KeyboardEvent) => {\n if (event.key !== \"Escape\" || !open) return;\n // Escape closes only the topmost overlay.\n event.stopPropagation();\n setOpen(false);\n triggerRef.current?.focus();\n };\n return (\n <PopoverContext.Provider\n value={{\n open,\n setOpen,\n triggerId: `${id}-trigger`,\n contentId: `${id}-content`,\n triggerRef,\n }}\n >\n <div\n ref={rootRef}\n data-a2ui-std=\"\"\n onKeyDown={onKeyDown}\n onMouseEnter={props.showOnHover ? openOnHover : undefined}\n onMouseLeave={props.showOnHover ? closeOnLeave : undefined}\n style={{ position: \"relative\", display: \"inline-flex\" }}\n >\n {props.children}\n </div>\n </PopoverContext.Provider>\n );\n}\n\nfunction PopoverTrigger(props: PopoverTriggerProps) {\n const aria = useGenerativeUIAccessibility();\n useFeedbackStyles();\n const popover = useContext(PopoverContext);\n if (!popover) return <>{props.children}</>;\n return (\n <button\n {...controlAria(aria)}\n ref={popover.triggerRef}\n type=\"button\"\n id={popover.triggerId}\n aria-haspopup=\"dialog\"\n aria-expanded={popover.open}\n aria-controls={popover.open ? popover.contentId : undefined}\n data-a2ui-std=\"\"\n data-a2ui-feedback-button=\"\"\n data-a2ui-popover-trigger=\"\"\n // The capture phase: a Button child stops the propagation of its own\n // click (so it never bubbles into a Pressable), which would leave the\n // trigger without the click.\n onClickCapture={() => popover.setOpen(!popover.open)}\n style={{\n ...BUTTON_RESET,\n display: props.block ? \"flex\" : \"inline-flex\",\n width: props.block ? \"100%\" : undefined,\n alignItems: \"center\",\n minWidth: 24,\n minHeight: 24,\n borderRadius: radius(\"xs\"),\n }}\n >\n {props.children}\n </button>\n );\n}\n\ntype Side = NonNullable<PopoverContentProps[\"side\"]>;\ntype Align = NonNullable<PopoverContentProps[\"align\"]>;\n\n/** Where the content sits: on `side` of the trigger, `offset` pixels away. */\nfunction sideStyle(side: Side, offset: number): CSSProperties {\n switch (side) {\n case \"bottom\":\n return { top: \"100%\", marginTop: offset };\n case \"top\":\n return { bottom: \"100%\", marginBottom: offset };\n case \"left\":\n return { right: \"100%\", marginRight: offset };\n case \"right\":\n return { left: \"100%\", marginLeft: offset };\n }\n}\n\n/** Where the content sits along the side of the trigger. */\nfunction alignStyle(side: Side, align: Align) {\n const isVertical = side === \"top\" || side === \"bottom\";\n switch (align) {\n case \"start\":\n return isVertical ? { left: 0 } : { top: 0 };\n case \"end\":\n return isVertical ? { right: 0 } : { bottom: 0 };\n case \"center\":\n return isVertical\n ? { left: \"50%\", transform: \"translateX(-50%)\" }\n : { top: \"50%\", transform: \"translateY(-50%)\" };\n }\n}\n\nconst PANEL_STYLE: CSSProperties = {\n zIndex: 50,\n minWidth: 160,\n boxSizing: \"border-box\",\n display: \"flex\",\n flexDirection: \"column\",\n gap: spacing(2),\n padding: spacing(3),\n background: backgroundColor(\"surface-elevated\"),\n border: `1px solid ${borderColor(\"default\")}`,\n borderRadius: radius(\"lg\"),\n boxShadow: SHADOW_MD,\n};\n\n/**\n * The body of a Popover, shown only when the Popover is open. Outside of a\n * Popover, it is a plain panel that always shows.\n */\nfunction PopoverContent(props: PopoverContentProps) {\n useFeedbackStyles();\n const popover = useContext(PopoverContext);\n if (!popover) {\n return (\n <div\n data-a2ui-std=\"\"\n style={{\n ...PANEL_STYLE,\n position: \"relative\",\n width: spacing(props.width),\n }}\n >\n {props.children}\n </div>\n );\n }\n if (!popover.open) return null;\n const side = props.side ?? \"bottom\";\n return (\n <div\n role=\"dialog\"\n id={popover.contentId}\n aria-labelledby={popover.triggerId}\n data-a2ui-std=\"\"\n style={{\n ...PANEL_STYLE,\n position: \"absolute\",\n ...sideStyle(side, props.sideOffset ?? 6),\n ...alignStyle(side, props.align ?? \"center\"),\n width: spacing(props.width),\n }}\n >\n {props.children}\n </div>\n );\n}\n\ntype ModalProps = z.output<typeof modalSchema> & {\n trigger?: ReactNode;\n content?: ReactNode;\n setOpen?: (open: boolean) => void;\n};\n\nconst FOCUSABLE =\n 'a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),iframe,video[controls],audio[controls],[tabindex]:not([tabindex=\"-1\"])';\n/**\n * A control, enabled or not: a disabled Button, or a Pressable (a div with\n * the button role) is still the trigger, and the wrapper must not open the\n * dialog in its place.\n */\nconst CONTROL =\n 'a[href],button,input,select,textarea,[role=\"button\"],[tabindex]:not([tabindex=\"-1\"])';\n/** A click inside one of these never opens the dialog. */\nconst DISABLED = '[disabled],[aria-disabled=\"true\"]';\n\n/**\n * A modal dialog. The trigger is wrapped in a button when it is not one\n * itself (a click anywhere on it opens the dialog). While open, Tab cycles\n * inside the dialog, Escape closes it, and the focus returns to the trigger.\n */\nfunction Modal(props: ModalProps) {\n useFeedbackStyles();\n // The dialog is a portal, outside the wrapper the engine puts around the\n // component, so it takes the envelope itself.\n const aria = useGenerativeUIAccessibility();\n const id = useId();\n const [ownOpen, setOwnOpen] = useState(false);\n const open = props.open ?? ownOpen;\n const setOpen = (value: boolean) => {\n setOwnOpen(value);\n props.setOpen?.(value);\n };\n const triggerRef = useRef<HTMLDivElement>(null);\n const dialogRef = useRef<HTMLDivElement>(null);\n // A stable close for the overlay stack, so a re-render of this Modal does\n // not move it above an overlay that opened later.\n const closeRef = useRef(() => setOpen(false));\n closeRef.current = () => setOpen(false);\n const close = useCallback(() => closeRef.current(), []);\n useOverlayEscape(open, close);\n // A trigger that is not a control itself (a Text) gets the button role\n // and a tab stop, so the keyboard can open the dialog. A Button inside\n // keeps its own semantics: nesting buttons is invalid.\n const [isPlainTrigger, setPlainTrigger] = useState(false);\n // The trigger component can stream in after the Modal, which re-renders\n // the slot but not the Modal. So the DOM of the trigger is observed, and\n // the classification follows what is rendered in it.\n useEffect(() => {\n const trigger = triggerRef.current;\n if (!trigger) return;\n const classify = () => {\n // A disabled control is still a control: the wrapper must not open\n // the dialog in its place.\n const isPlain = trigger.querySelector(CONTROL) === null;\n setPlainTrigger((current) => (current === isPlain ? current : isPlain));\n };\n classify();\n if (typeof MutationObserver === \"undefined\") return;\n const observer = new MutationObserver(classify);\n observer.observe(trigger, { childList: true, subtree: true });\n return () => observer.disconnect();\n }, []);\n // The dialog is portaled out of the surface, so it takes the theme\n // variables and the surface style scope with it.\n const theme = useGenerativeUIRuntime()?.theme;\n const portalStyle = useMemo((): CSSProperties => {\n const { mapStyle: _mapStyle, ...variables } = theme ?? {};\n return { display: \"contents\", ...(variables as CSSProperties) };\n }, [theme]);\n useEffect(() => {\n if (!open) return;\n const dialog = dialogRef.current;\n const previous = document.activeElement;\n const focusables = () =>\n Array.from(dialog?.querySelectorAll<HTMLElement>(FOCUSABLE) ?? []);\n (focusables()[0] ?? dialog)?.focus();\n const onKey = (event: globalThis.KeyboardEvent) => {\n // Escape is handled by the overlay stack: only the newest overlay.\n if (event.key !== \"Tab\") return;\n const items = focusables();\n if (items.length === 0) return;\n const first = items[0]!;\n const last = items[items.length - 1]!;\n if (event.shiftKey && document.activeElement === first) {\n event.preventDefault();\n last.focus();\n } else if (!event.shiftKey && document.activeElement === last) {\n event.preventDefault();\n first.focus();\n }\n };\n document.addEventListener(\"keydown\", onKey);\n return () => {\n document.removeEventListener(\"keydown\", onKey);\n if (previous instanceof HTMLElement) previous.focus();\n else triggerRef.current?.querySelector<HTMLElement>(FOCUSABLE)?.focus();\n };\n // setOpen is recreated each render; the effect only needs `open`.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [open]);\n return (\n <>\n <div\n ref={triggerRef}\n data-a2ui-std=\"\"\n data-a2ui-modal-trigger=\"\"\n role={isPlainTrigger ? \"button\" : undefined}\n tabIndex={isPlainTrigger ? 0 : undefined}\n aria-haspopup={isPlainTrigger ? \"dialog\" : undefined}\n aria-expanded={isPlainTrigger ? open : undefined}\n style={{\n display: \"inline-flex\",\n flexGrow: props.weight,\n cursor: isPlainTrigger ? \"pointer\" : undefined,\n }}\n // The capture phase sees the click before a Button inside handles\n // it, and lets it through: the Button still sends its own event,\n // opens its href or copies its text.\n onClickCapture={(event) => {\n // A disabled control inside the trigger (a Pressable, a Button)\n // keeps the dialog closed, also before its own click handler.\n const target = event.target as Element | null;\n const control = target?.closest(CONTROL);\n if (control && triggerRef.current?.contains(control)) {\n if (control.matches(DISABLED)) return;\n }\n setOpen(true);\n }}\n onKeyDown={(event) => {\n if (!isPlainTrigger) return;\n if (event.key === \"Enter\" || event.key === \" \") {\n event.preventDefault();\n setOpen(true);\n }\n }}\n >\n {props.trigger}\n </div>\n {open && typeof document !== \"undefined\"\n ? // A portal: a fixed backdrop inside a transformed chat row would be\n // clipped to the row. The Lightbox does the same.\n createPortal(\n <div className=\"a2ui-surface\" style={portalStyle}>\n <div\n data-a2ui-modal-backdrop=\"\"\n onClick={() => setOpen(false)}\n style={{\n position: \"fixed\",\n inset: 0,\n zIndex: 1000,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n padding: spacing(4),\n background: BACKDROP,\n }}\n >\n <div\n ref={dialogRef}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-labelledby={\n props.title && aria[\"aria-label\"] === undefined\n ? `${id}-title`\n : undefined\n }\n aria-label={aria[\"aria-label\"]}\n aria-description={aria[\"aria-description\"]}\n {...wrapperAria(aria)}\n tabIndex={-1}\n onClick={(event) => event.stopPropagation()}\n style={{\n display: \"flex\",\n flexDirection: \"column\",\n gap: spacing(3),\n width: \"100%\",\n maxWidth: spacing(props.maxWidth ?? 480),\n maxHeight: \"90vh\",\n overflow: \"auto\",\n padding: spacing(5),\n borderRadius: radius(\"xl\"),\n background: backgroundColor(\"surface\"),\n color: textColor(\"default\"),\n boxShadow: SHADOW_MD,\n }}\n >\n <div\n style={{\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"space-between\",\n gap: spacing(3),\n }}\n >\n {props.title ? (\n <h2\n id={`${id}-title`}\n style={{\n margin: 0,\n fontSize: \"1.125em\",\n fontWeight: 600,\n }}\n >\n {props.title}\n </h2>\n ) : (\n <span />\n )}\n <button\n type=\"button\"\n aria-label=\"Close\"\n data-a2ui-input=\"\"\n onClick={() => setOpen(false)}\n style={{\n width: 32,\n height: 32,\n border: \"none\",\n borderRadius: radius(\"full\"),\n background: \"transparent\",\n color: textColor(\"secondary\"),\n fontSize: 20,\n lineHeight: 1,\n cursor: \"pointer\",\n }}\n >\n <span aria-hidden=\"true\">×</span>\n </button>\n </div>\n {props.content}\n </div>\n </div>\n </div>,\n document.body,\n )\n : null}\n </>\n );\n}\n\n/**\n * The standard feedback components: loading states, a pulse dot, a\n * a flashcard and a popover. Give them to\n * `createGenerativeUI({ components: { ...feedbackComponents } })`.\n *\n * Popover, PopoverTrigger and PopoverContent have a\n * \"multiple\" `children` slot. Popover `open` is writable, so the component\n * gets a `setOpen` prop.\n */\nexport const feedbackComponents = withComponents(feedbackDeclarations, {\n PulseIndicator,\n FlashcardFlip,\n Popover,\n PopoverTrigger,\n PopoverContent,\n Modal,\n});\n","import { useState } from \"react\";\nimport { firstFailedCheck } from \"@copilotkit/shared/generative-ui\";\nimport type { ResolvedChecks } from \"@copilotkit/shared/generative-ui\";\n\n/**\n * The check state of a control: the failed check to show, whether the\n * control is invalid, and the blur handler that marks it as touched. The\n * message shows only once the user has been in the control, or when it has\n * a value, so a fresh form does not open full of errors. A warning or an\n * info shows its message but does not make the control invalid.\n */\nexport function useChecks(checks: ResolvedChecks, value: unknown) {\n const [isTouched, setTouched] = useState(false);\n const failed = firstFailedCheck(checks);\n const hasValue =\n value !== undefined &&\n value !== null &&\n value !== \"\" &&\n value !== false &&\n !(Array.isArray(value) && value.length === 0);\n const isShown = failed !== undefined && (isTouched || hasValue);\n return {\n error: isShown ? failed : undefined,\n invalid: isShown && failed.severity === \"error\",\n onBlur: () => setTouched(true),\n };\n}\n","import React, { useEffect, useId, useRef, useState } from \"react\";\nimport type { CSSProperties, KeyboardEvent, ReactNode } from \"react\";\nimport type { z } from \"zod\";\nimport {\n ACCENT,\n FONT_WEIGHT,\n ON_ACCENT,\n SHADOW_XS,\n backgroundColor,\n borderColor,\n checkMessageStyle,\n firstFailedCheck,\n inputDeclarations,\n radius,\n spacing,\n textColor,\n textFont,\n withComponents,\n} from \"@copilotkit/shared/generative-ui\";\nimport type {\n FailedCheck,\n GenerativeUIInvokeResult,\n InputOptionList,\n InputSize,\n NO_ARGS,\n buttonSchema,\n checkBoxSchema,\n choicePickerSchema,\n dateTimeInputSchema,\n formSchema,\n pressableSchema,\n radioGroupSchema,\n radioSchema,\n segmentedControlSchema,\n selectSchema,\n sliderSchema,\n textAreaSchema,\n textFieldSchema,\n} from \"@copilotkit/shared/generative-ui\";\nimport {\n controlAria,\n useGenerativeUIAccessibility,\n wrapperAria,\n} from \"../accessibility\";\nimport { useStandardStyles } from \"./styles\";\nimport { layoutStyle, useVisibleOnce } from \"./layout\";\nimport { openUrl } from \"./lightbox\";\nimport { LucideIcon } from \"./media\";\nimport { useChecks } from \"./checks\";\n\n/** Copies text to the clipboard. False when the API is not there. */\nasync function copyText(text: string) {\n try {\n await navigator.clipboard.writeText(text);\n return true;\n } catch {\n return false;\n }\n}\n\ntype EventProp = (\n args: z.input<typeof NO_ARGS>,\n) => Promise<GenerativeUIInvokeResult>;\n\ntype OptionList = InputOptionList;\ntype Size = InputSize;\n\ntype WithChildren<Props> = Props & { children?: ReactNode };\n\n// ---- Control metrics ----\n\n/*\n * Inputs (size xl) are 40px tall, with about 18px side padding and 16px\n * text. Buttons (size lg) are 36px tall pills, with 16px side padding,\n * 14px/500 text and a 6px gap to the icon.\n */\nconst HEIGHT: Record<Size, number> = { sm: 28, md: 32, lg: 36, xl: 40 };\n/** Control text in em of the host size (13/14/14/16px at a 16px base). */\nconst FONT_SIZE: Record<Size, string> = {\n sm: \".8125em\",\n md: \".875em\",\n lg: \".875em\",\n xl: \"1em\",\n};\nconst PAD_X: Record<Size, number> = { sm: 10, md: 12, lg: 12, xl: 18 };\nconst ICON_PX: Record<Size, number> = { sm: 14, md: 16, lg: 18, xl: 18 };\n\n/** Text inputs have a slightly stronger hairline than cards. */\nconst CONTROL_BORDER = \"var(--a2ui-color-border-control, rgba(0, 0, 0, 0.15))\";\n\n/** A value as input text. `undefined` and `null` give an empty string. */\nconst asText = (value: unknown) =>\n value === undefined || value === null ? \"\" : String(value);\n\nfunction normalizeOptions(options: OptionList) {\n const list = options ?? [];\n return list.map((option) =>\n typeof option === \"string\"\n ? { value: option, label: option, description: undefined }\n : {\n value: option.value,\n label: option.label ?? option.value,\n description: option.description,\n },\n );\n}\n\n/** True when a slot got content to render. */\nfunction hasContent(children: ReactNode) {\n if (Array.isArray(children)) return children.length > 0;\n return children !== undefined && children !== null;\n}\n\nfunction controlStyle(\n props: {\n size?: Size;\n pill?: boolean;\n invalid?: boolean;\n disabled?: boolean;\n },\n defaultSize: Size,\n) {\n const controlSize = props.size ?? defaultSize;\n return {\n boxSizing: \"border-box\",\n width: \"100%\",\n minWidth: 0,\n maxWidth: \"100%\",\n minHeight: HEIGHT[controlSize],\n padding: `0 ${PAD_X[controlSize]}px`,\n fontSize: FONT_SIZE[controlSize],\n fontFamily: \"inherit\",\n color: textColor(\"default\"),\n background: backgroundColor(\"surface\"),\n border: `1px solid ${props.invalid ? borderColor(\"danger\") : CONTROL_BORDER}`,\n borderRadius: props.pill === false ? radius(\"md\") : \"9999px\",\n opacity: props.disabled ? 0.5 : undefined,\n } satisfies CSSProperties;\n}\n\n/**\n * A native select without its native look, so it takes the height,\n * padding and corners of the other fields (Safari keeps a fixed, compact\n * height otherwise), with a chevron drawn on the right. The option list\n * stays native.\n */\nconst SELECT_STYLE = {\n appearance: \"none\",\n WebkitAppearance: \"none\",\n paddingRight: 32,\n backgroundImage: `url(\"data:image/svg+xml,${encodeURIComponent(\n '<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"12\" height=\"12\" viewBox=\"0 0 12 12\" fill=\"none\" stroke=\"#8e8e93\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M3 4.5 6 7.5 9 4.5\"/></svg>',\n )}\")`,\n backgroundRepeat: \"no-repeat\",\n backgroundPosition: \"right 12px center\",\n backgroundSize: \"12px 12px\",\n} satisfies CSSProperties;\n\nconst FIELD_LABEL_STYLE = {\n ...textFont(\"sm\"),\n fontWeight: FONT_WEIGHT.medium,\n color: textColor(\"secondary\"),\n} satisfies CSSProperties;\n\n/**\n * A label above a control. With `htmlFor`, the label is a `<label>` of that\n * control. With `labelId`, it is a text that a group points to with\n * `aria-labelledby`.\n */\nfunction Field({\n label,\n htmlFor,\n labelId,\n weight,\n error,\n onBlur,\n children,\n}: {\n label?: string;\n htmlFor?: string;\n labelId?: string;\n /** The A2UI `weight`: flex-grow in a Row or Column. */\n weight?: number;\n /** The failed check, shown under the control. */\n error?: FailedCheck;\n /** Called when the focus leaves the control, to mark it as touched. */\n onBlur?: () => void;\n children: ReactNode;\n}) {\n // The envelope of the control: hidden hides label and control; a label\n // or a description names the pair as a group, and the control itself\n // takes them too (see controlAria), because ARIA names do not inherit.\n const aria = useGenerativeUIAccessibility();\n const isNamed =\n aria[\"aria-label\"] !== undefined || aria[\"aria-description\"] !== undefined;\n const labelElement =\n htmlFor !== undefined ? (\n <label htmlFor={htmlFor} style={FIELD_LABEL_STYLE}>\n {label}\n </label>\n ) : (\n <span id={labelId} style={FIELD_LABEL_STYLE}>\n {label}\n </span>\n );\n return (\n <div\n {...wrapperAria(aria)}\n role={isNamed ? \"group\" : undefined}\n aria-label={isNamed ? aria[\"aria-label\"] : undefined}\n aria-description={isNamed ? aria[\"aria-description\"] : undefined}\n style={{\n display: \"flex\",\n flexDirection: \"column\",\n gap: spacing(2),\n width: \"100%\",\n minWidth: 0,\n flexGrow: weight,\n }}\n onBlurCapture={onBlur}\n >\n {label ? labelElement : null}\n {children}\n <CheckError check={error} />\n </div>\n );\n}\n\n/**\n * The message of a failed check, under a control. Nothing when none. An\n * error is an alert; a warning or an info is a status, in its own color.\n */\nfunction CheckError({ check }: { check: FailedCheck | undefined }) {\n if (check === undefined) return null;\n return (\n <span\n role={check.severity === \"error\" ? \"alert\" : \"status\"}\n data-a2ui-check-error=\"\"\n data-a2ui-check-severity={check.severity}\n data-a2ui-check-code={check.code}\n style={checkMessageStyle(check.severity)}\n >\n {check.message}\n </span>\n );\n}\n\n// ---- Button ----\n\ntype ButtonProps = WithChildren<\n z.output<typeof buttonSchema> & { onClick?: EventProp; child?: ReactNode }\n>;\n\nfunction buttonVariantStyle(\n variant: NonNullable<ButtonProps[\"variant\"]>,\n color: ButtonProps[\"color\"],\n) {\n const accent =\n color === \"danger\"\n ? textColor(\"danger\")\n : color === \"secondary\"\n ? backgroundColor(\"surface-tertiary\")\n : ACCENT;\n const foreground =\n color === \"danger\" ? textColor(\"danger\") : textColor(\"default\");\n switch (variant) {\n case \"primary\":\n return {\n background: accent,\n color: color === \"secondary\" ? foreground : ON_ACCENT,\n border: \"1px solid transparent\",\n };\n case \"soft\":\n return {\n background: backgroundColor(\"surface-secondary\"),\n color: foreground,\n border: \"1px solid transparent\",\n };\n case \"default\":\n return {\n background: \"transparent\",\n color: foreground,\n border: `1px solid ${color === \"danger\" ? accent : borderColor(\"default\")}`,\n };\n case \"borderless\":\n return { background: \"transparent\", color: foreground, border: \"none\" };\n }\n}\n\nfunction Button(props: ButtonProps) {\n useStandardStyles();\n const aria = useGenerativeUIAccessibility();\n const [isCopied, setIsCopied] = useState(false);\n const buttonSize = props.size ?? \"lg\";\n // A warning or an info does not hold the button back.\n const failedCheck = firstFailedCheck(props.checks);\n const blockingCheck =\n failedCheck?.severity === \"error\" ? failedCheck : undefined;\n const isDisabled = Boolean(\n props.disabled || props.loading || blockingCheck !== undefined,\n );\n const style: CSSProperties = {\n display: props.block ? \"flex\" : \"inline-flex\",\n width: props.block ? \"100%\" : undefined,\n flexGrow: props.weight,\n alignItems: \"center\",\n justifyContent: \"center\",\n gap: 6,\n boxSizing: \"border-box\",\n maxWidth: \"100%\",\n minHeight: HEIGHT[buttonSize],\n minWidth: props.uniform ? HEIGHT[buttonSize] : undefined,\n padding: props.uniform ? 0 : `0 ${PAD_X[buttonSize] + 4}px`,\n fontSize: FONT_SIZE[buttonSize],\n fontFamily: \"inherit\",\n fontWeight: FONT_WEIGHT.medium,\n lineHeight: 1,\n borderRadius: props.pill === false ? radius(\"md\") : \"9999px\",\n cursor: isDisabled ? \"not-allowed\" : \"pointer\",\n opacity: isDisabled ? 0.5 : undefined,\n ...buttonVariantStyle(props.variant ?? \"default\", props.color),\n };\n return (\n <button\n data-a2ui-input=\"\"\n type={props.submit ? \"submit\" : \"button\"}\n {...aria}\n disabled={isDisabled}\n title={failedCheck?.message}\n aria-busy={props.loading ? true : undefined}\n style={style}\n onClick={(event) => {\n // Inside a Pressable, only the innermost control sends its event.\n event.stopPropagation();\n // A submit button inside a <form> lets the Form send onSubmit.\n // Outside of a form, it sends its own onClick.\n const submitsForm = props.submit && event.currentTarget.form !== null;\n if (submitsForm) return;\n // The client-side verbs (open a URL, copy text) never reach the\n // agent.\n if (props.href) {\n openUrl(props.href);\n return;\n }\n if (props.copy !== undefined && props.copy !== \"\") {\n void copyText(props.copy).then((isOk) => {\n if (!isOk) return;\n setIsCopied(true);\n setTimeout(() => setIsCopied(false), 1500);\n });\n return;\n }\n void props.onClick?.({});\n }}\n data-a2ui-copied={isCopied ? \"\" : undefined}\n >\n {isCopied ? (\n <span aria-hidden=\"true\" data-icon=\"check\" style={{ display: \"flex\" }}>\n <LucideIcon name=\"check\" size={ICON_PX[buttonSize]} />\n </span>\n ) : props.icon ? (\n <span\n aria-hidden=\"true\"\n data-icon={props.icon}\n style={{ display: \"flex\" }}\n >\n <LucideIcon name={props.icon} size={ICON_PX[buttonSize]} />\n </span>\n ) : null}\n {hasContent(props.child)\n ? props.child\n : hasContent(props.children)\n ? props.children\n : asText(props.label ?? props.text)}\n </button>\n );\n}\n\n// ---- Pressable and Form ----\n\ntype PressableProps = WithChildren<\n z.output<typeof pressableSchema> & {\n onClick?: EventProp;\n onVisible?: EventProp;\n }\n>;\n\n/**\n * A clickable container. It is a `div` with the button role, not a\n * `<button>`, because it can hold other controls, and a button cannot.\n * Enter and Space on the container itself press it.\n */\nfunction Pressable(props: PressableProps) {\n useStandardStyles();\n const aria = useGenerativeUIAccessibility();\n const isDisabled = Boolean(props.disabled);\n const [isHovered, setIsHovered] = useState(false);\n const ref = useRef<HTMLDivElement>(null);\n useVisibleOnce(ref, props.onVisible);\n const press = () => {\n if (isDisabled) return;\n if (props.href) openUrl(props.href);\n else void props.onClick?.({});\n };\n const showHoverBackground =\n isHovered && props.hoverBackground !== undefined && !isDisabled;\n return (\n <div\n ref={ref}\n role=\"button\"\n tabIndex={isDisabled ? -1 : 0}\n aria-disabled={isDisabled || undefined}\n aria-pressed={props.ariaPressed}\n title={props.tooltip}\n data-a2ui-input=\"\"\n {...aria}\n onClick={(event) => {\n event.stopPropagation();\n press();\n }}\n onKeyDown={(event) => {\n // A key on a nested control (a Button, an input) belongs to it.\n if (event.target !== event.currentTarget) return;\n if (event.key !== \"Enter\" && event.key !== \" \") return;\n event.preventDefault();\n press();\n }}\n onMouseEnter={() => setIsHovered(true)}\n onMouseLeave={() => setIsHovered(false)}\n style={{\n flexDirection: \"column\",\n ...layoutStyle(props),\n cursor: isDisabled ? \"not-allowed\" : \"pointer\",\n opacity: isDisabled ? 0.5 : undefined,\n boxShadow: props.insetBorder\n ? `inset 0 0 0 1px ${borderColor(\"default\")}`\n : undefined,\n ...(showHoverBackground\n ? { background: backgroundColor(props.hoverBackground) }\n : {}),\n }}\n >\n {props.children}\n </div>\n );\n}\n\ntype FormProps = WithChildren<\n z.output<typeof formSchema> & { onSubmit?: EventProp }\n>;\n\nfunction Form(props: FormProps) {\n useStandardStyles();\n return (\n <form\n aria-label={props.label}\n onSubmit={(event) => {\n event.preventDefault();\n void props.onSubmit?.({});\n }}\n style={{\n flexDirection: \"column\",\n ...layoutStyle(props),\n gap: spacing(props.gap ?? 4),\n }}\n >\n {props.children}\n </form>\n );\n}\n\n// ---- Text inputs ----\n\ntype TextFieldProps = z.output<typeof textFieldSchema> & {\n setValue: (value: string | number) => void;\n};\n\n/** The `type` of the input of each single-line TextField variant. */\nconst TEXT_FIELD_TYPE = {\n shortText: \"text\",\n number: \"number\",\n obscured: \"password\",\n email: \"email\",\n url: \"url\",\n tel: \"tel\",\n} as const;\n\nfunction TextField(props: TextFieldProps) {\n useStandardStyles();\n const aria = useGenerativeUIAccessibility();\n const id = useId();\n const ref = useRef<HTMLInputElement>(null);\n const variant = props.variant ?? \"shortText\";\n const check = useChecks(props.checks, props.value);\n if (variant === \"longText\") {\n return (\n <TextArea\n checks={props.checks}\n value={asText(props.value)}\n placeholder={props.placeholder}\n label={props.label}\n name={props.name}\n required={props.required}\n disabled={props.disabled}\n invalid={props.invalid}\n size={props.size}\n weight={props.weight}\n setValue={props.setValue}\n />\n );\n }\n return (\n <Field\n label={props.label}\n htmlFor={id}\n weight={props.weight}\n error={check.error}\n onBlur={check.onBlur}\n >\n <input\n ref={ref}\n id={id}\n data-a2ui-input=\"\"\n type={TEXT_FIELD_TYPE[variant]}\n name={props.name}\n placeholder={props.placeholder}\n // Without a visible label, the placeholder still names the field.\n aria-label={props.label ? undefined : props.placeholder}\n required={props.required}\n disabled={props.disabled}\n aria-invalid={props.invalid || check.invalid || undefined}\n value={asText(props.value)}\n onFocus={props.autoSelect ? () => ref.current?.select() : undefined}\n onChange={(event) => props.setValue(event.target.value)}\n style={controlStyle(props, \"xl\")}\n {...controlAria(aria)}\n />\n </Field>\n );\n}\n\ntype TextAreaProps = z.output<typeof textAreaSchema> & {\n setValue: (value: string) => void;\n};\n\nfunction TextArea(props: TextAreaProps) {\n useStandardStyles();\n const aria = useGenerativeUIAccessibility();\n const id = useId();\n const areaSize = props.size ?? \"xl\";\n const check = useChecks(props.checks, props.value);\n return (\n <Field\n label={props.label}\n htmlFor={id}\n weight={props.weight}\n error={check.error}\n onBlur={check.onBlur}\n >\n <textarea\n id={id}\n data-a2ui-input=\"\"\n name={props.name}\n placeholder={props.placeholder}\n aria-label={props.label ? undefined : props.placeholder}\n required={props.required}\n disabled={props.disabled}\n aria-invalid={props.invalid || check.invalid || undefined}\n rows={props.rows ?? 3}\n value={asText(props.value)}\n onChange={(event) => {\n props.setValue(event.target.value);\n if (!props.autoResize) return;\n const element = event.target;\n element.style.height = \"auto\";\n element.style.height = `${element.scrollHeight}px`;\n }}\n style={{\n ...controlStyle({ ...props, pill: false }, areaSize),\n padding: `${PAD_X[areaSize] / 2}px ${PAD_X[areaSize]}px`,\n resize: props.autoResize ? \"none\" : \"vertical\",\n maxHeight: props.maxRows\n ? `calc(${props.maxRows} * 1.5em + ${PAD_X[areaSize]}px)`\n : undefined,\n lineHeight: 1.5,\n }}\n {...controlAria(aria)}\n />\n </Field>\n );\n}\n\ntype DateTimeInputProps = z.output<typeof dateTimeInputSchema> & {\n setValue: (value: string) => void;\n};\n\ntype DateTimeMode = \"date\" | \"time\" | \"datetime\";\n\n/** What the user picks: a date by default, a time, or both. */\nfunction dateTimeMode(props: DateTimeInputProps): DateTimeMode {\n const hasTime = props.enableTime === true;\n const hasDate = props.enableDate ?? !hasTime;\n return hasDate && hasTime ? \"datetime\" : hasTime ? \"time\" : \"date\";\n}\n\ninterface DateTimeParts {\n /** \"YYYY-MM-DD\", or \"\" */\n date: string;\n /** \"HH:MM\" (seconds kept when given), or \"\" */\n time: string;\n}\n\n/** The date and the time of an ISO 8601 value: a date, a time, or both. */\nexport function splitDateTime(value: string): DateTimeParts {\n const [head, tail] = value.split(\"T\");\n if (head !== undefined && tail !== undefined) {\n return { date: head, time: tail };\n }\n if (/^\\d{4}-/.test(value)) return { date: value, time: \"\" };\n if (/^\\d{1,2}:\\d{2}/.test(value)) return { date: \"\", time: value };\n return { date: \"\", time: \"\" };\n}\n\n/** The value of the parts, or \"\" while a part the mode needs is missing. */\nfunction joinDateTime(parts: DateTimeParts, mode: DateTimeMode): string {\n if (mode === \"date\") return parts.date;\n if (mode === \"time\") return parts.time;\n return parts.date && parts.time ? `${parts.date}T${parts.time}` : \"\";\n}\n\n/**\n * The value in words, in the user's locale: \"Thu, Oct 23, 2026, 2:30 PM\".\n * Undefined for an incomplete or unparsable value.\n */\nexport function describeDateTime(\n parts: DateTimeParts,\n mode: DateTimeMode,\n locale?: string,\n): string | undefined {\n const date = /^(\\d{4})-(\\d{2})-(\\d{2})$/.exec(parts.date);\n const time = /^(\\d{1,2}):(\\d{2})/.exec(parts.time);\n if ((mode !== \"time\" && !date) || (mode !== \"date\" && !time)) return;\n // The value has no time zone: it is formatted as written, in UTC, so a\n // daylight-saving gap of the viewer cannot shift it.\n const at = new Date(\n Date.UTC(\n date ? Number(date[1]) : 2000,\n date ? Number(date[2]) - 1 : 0,\n date ? Number(date[3]) : 1,\n time ? Number(time[1]) : 0,\n time ? Number(time[2]) : 0,\n ),\n );\n // Date.UTC rolls an impossible value over (February 30 to March 2); such\n // a value gets no summary rather than a different one.\n const exact =\n (!date ||\n (at.getUTCFullYear() === Number(date[1]) &&\n at.getUTCMonth() === Number(date[2]) - 1 &&\n at.getUTCDate() === Number(date[3]))) &&\n (!time ||\n (at.getUTCHours() === Number(time[1]) &&\n at.getUTCMinutes() === Number(time[2])));\n if (Number.isNaN(at.getTime()) || !exact) return;\n return new Intl.DateTimeFormat(locale, {\n timeZone: \"UTC\",\n ...(mode === \"time\"\n ? {}\n : { weekday: \"short\", year: \"numeric\", month: \"short\", day: \"numeric\" }),\n ...(mode === \"date\" ? {} : { hour: \"numeric\", minute: \"2-digit\" }),\n }).format(at);\n}\n\n/** \"HH:MM\" of a minute of the day. */\nfunction minuteToTime(minute: number) {\n const pad = (n: number) => String(n).padStart(2, \"0\");\n return `${pad(Math.floor(minute / 60))}:${pad(minute % 60)}`;\n}\n\n/** \"HH:MM:SS\" of a time, seconds \"00\" when left out, so times compare as text. */\nfunction fullTime(time: string) {\n const match = /^(\\d{1,2}):(\\d{2})(?::(\\d{2}))?/.exec(time);\n if (!match) return time;\n return `${match[1]!.padStart(2, \"0\")}:${match[2]!}:${match[3] ?? \"00\"}`;\n}\n\n/** The minute of the day of a time, rounded up to a whole minute. */\nfunction timeToMinute(time: string) {\n // A missing part is NaN, the same result as math with `undefined`.\n const [hours = NaN, minutes = NaN, seconds = NaN] = fullTime(time)\n .split(\":\")\n .map(Number);\n return hours * 60 + minutes + (seconds > 0 ? 1 : 0);\n}\n\n/**\n * True when `time` lies within `min`..`max`, seconds included. A `min`\n * after `max` is a range over midnight, such as 22:00 to 02:00.\n */\nexport function timeInRange(time: string, min?: string, max?: string) {\n const at = fullTime(time);\n const from = min ? fullTime(min) : undefined;\n const to = max ? fullTime(max) : undefined;\n if (from && to && from > to) return at >= from || at <= to;\n return (!from || at >= from) && (!to || at <= to);\n}\n\n/**\n * The times `step` minutes apart from `min` (or midnight) up to `max` (or\n * the end of the day), \"HH:MM\". A range over midnight continues after\n * 23:59. `current` is added when it is set and not one of them, so the list\n * shows the value it holds even when that value is out of range.\n */\nexport function timeSlots(\n step: number,\n min?: string,\n max?: string,\n current?: string,\n): string[] {\n const day = 24 * 60;\n const start = min ? timeToMinute(min) : 0;\n let end = max\n ? timeToMinute(max) - (fullTime(max).endsWith(\":00\") ? 0 : 1)\n : day - 1;\n if (end < start) end += day;\n const slots: string[] = [];\n for (\n let minute = start;\n minute <= end && minute < start + day;\n minute += step\n ) {\n slots.push(minuteToTime(minute % day));\n }\n const shown = current?.slice(0, 5);\n if (shown && !slots.includes(shown)) {\n // In order from the start of the range.\n const offset = (time: string) => (timeToMinute(time) - start + day) % day;\n const index = slots.findIndex((slot) => offset(slot) > offset(shown));\n slots.splice(index === -1 ? slots.length : index, 0, shown);\n }\n return slots;\n}\n\n/**\n * A date, a time, or both. A date and a time are two fields under one\n * label, so each stays short and readable in every browser; the value is\n * written once both are set. Under the fields, the value in words makes the\n * date and the time (AM/PM included) unambiguous. `timeStep` shows the time\n * as a list of times instead of a typed field.\n */\nfunction DateTimeInput(props: DateTimeInputProps) {\n useStandardStyles();\n const aria = useGenerativeUIAccessibility();\n const id = useId();\n const labelId = useId();\n const summaryId = useId();\n const mode = dateTimeMode(props);\n const value = asText(props.value);\n const check = useChecks(props.checks, props.value);\n const [parts, setParts] = useState(() => splitDateTime(value));\n // The last value this control wrote. A different value comes from the\n // data model (the agent, a binding) and replaces the parts; the control's\n // own write keeps a half-filled date and time as they are.\n const written = useRef<string | undefined>(undefined);\n useEffect(() => {\n if (value === written.current) return;\n written.current = undefined;\n setParts(splitDateTime(value));\n }, [value]);\n const write = (next: DateTimeParts) => {\n setParts(next);\n const nextValue = joinDateTime(next, mode);\n written.current = nextValue;\n // Written even when unchanged: the write makes the value the user's, so\n // a later agent write does not replace a half-filled date and time.\n props.setValue(nextValue);\n };\n\n const min = splitDateTime(asText(props.min));\n const max = splitDateTime(asText(props.max));\n // A bound on the time applies on its own day only, when there is a date.\n const timeMin =\n mode === \"time\" || (min.time && parts.date === min.date)\n ? min.time || undefined\n : undefined;\n const timeMax =\n mode === \"time\" || (max.time && parts.date === max.date)\n ? max.time || undefined\n : undefined;\n\n // A list does not enforce min and max like a time field does: a time\n // left out of range (the date moved to the day of a bound) is invalid.\n const slotList = useRef<HTMLSelectElement>(null);\n const slotOutOfRange =\n props.timeStep !== undefined &&\n parts.time !== \"\" &&\n !timeInRange(parts.time, timeMin, timeMax);\n const rangeError: FailedCheck | undefined = slotOutOfRange\n ? {\n message: `Pick a time from ${\n (timeMin && describeDateTime({ date: \"\", time: timeMin }, \"time\")) ||\n \"the start of the day\"\n } to ${\n (timeMax && describeDateTime({ date: \"\", time: timeMax }, \"time\")) ||\n \"the end of the day\"\n }`,\n severity: \"error\",\n code: \"TIME_OUT_OF_RANGE\",\n }\n : undefined;\n // Half a date and time is no value: the empty field is invalid, so a\n // form does not drop what the user entered. Both empty stays valid.\n const dateField = useRef<HTMLInputElement>(null);\n const timeInput = useRef<HTMLInputElement>(null);\n const halfFilled =\n mode === \"datetime\" && (parts.date === \"\") !== (parts.time === \"\");\n const dateMessage = halfFilled && parts.date === \"\" ? \"Pick a date too\" : \"\";\n const timeMessage =\n rangeError?.message ??\n (halfFilled && parts.time === \"\" ? \"Pick a time too\" : \"\");\n useEffect(() => {\n dateField.current?.setCustomValidity(dateMessage);\n slotList.current?.setCustomValidity(timeMessage);\n timeInput.current?.setCustomValidity(timeMessage);\n }, [dateMessage, timeMessage, props.timeStep]);\n\n const summary = describeDateTime(parts, mode);\n const isSplit = mode === \"datetime\";\n const showClear = props.clearable && (parts.date !== \"\" || parts.time !== \"\");\n const style = controlStyle({ ...props, pill: false }, \"xl\");\n const common = {\n \"data-a2ui-input\": \"\",\n disabled: props.disabled,\n required: props.required,\n \"aria-invalid\": check.invalid || undefined,\n \"aria-describedby\": summary ? summaryId : undefined,\n };\n // One field names itself after the label; two fields are named \"Date\"\n // and \"Time\" inside a group the label names.\n const singleAria = isSplit ? {} : controlAria(aria);\n const singleLabel = isSplit\n ? undefined\n : (singleAria[\"aria-label\"] ??\n (props.label ? undefined : props.placeholder));\n const single = isSplit\n ? {}\n : { id, \"aria-description\": singleAria[\"aria-description\"] };\n\n const dateControl = (\n <input\n {...common}\n {...single}\n ref={dateField}\n type=\"date\"\n aria-label={isSplit ? \"Date\" : singleLabel}\n min={min.date || undefined}\n max={max.date || undefined}\n placeholder={props.placeholder}\n value={parts.date}\n onChange={(event) => write({ ...parts, date: event.target.value })}\n style={{ ...style, flex: \"1 1 10em\", width: \"auto\" }}\n />\n );\n const timeField =\n props.timeStep !== undefined ? (\n <select\n {...common}\n {...single}\n ref={slotList}\n aria-label={isSplit ? \"Time\" : singleLabel}\n aria-invalid={check.invalid || slotOutOfRange || undefined}\n value={parts.time.slice(0, 5)}\n onChange={(event) => write({ ...parts, time: event.target.value })}\n style={{ ...style, ...SELECT_STYLE, flex: \"1 1 8em\", width: \"auto\" }}\n >\n <option value=\"\">{props.placeholder ?? \"Time\"}</option>\n {timeSlots(props.timeStep, timeMin, timeMax, parts.time).map((slot) => (\n <option key={slot} value={slot}>\n {describeDateTime({ date: \"\", time: slot }, \"time\") ?? slot}\n </option>\n ))}\n </select>\n ) : (\n <input\n {...common}\n {...single}\n ref={timeInput}\n type=\"time\"\n aria-label={isSplit ? \"Time\" : singleLabel}\n min={timeMin}\n max={timeMax}\n placeholder={props.placeholder}\n value={parts.time}\n onChange={(event) => write({ ...parts, time: event.target.value })}\n style={{ ...style, flex: \"1 1 8em\", width: \"auto\" }}\n />\n );\n\n return (\n <Field\n label={props.label}\n htmlFor={isSplit ? undefined : id}\n labelId={isSplit ? labelId : undefined}\n weight={props.weight}\n error={check.error ?? rangeError}\n onBlur={check.onBlur}\n >\n <div\n role={isSplit ? \"group\" : undefined}\n aria-labelledby={isSplit && props.label ? labelId : undefined}\n {...(isSplit ? controlAria(aria) : {})}\n style={{\n display: props.block ? \"flex\" : \"inline-flex\",\n flexWrap: \"wrap\",\n width: props.block ? \"100%\" : undefined,\n maxWidth: \"100%\",\n gap: spacing(2),\n alignItems: \"center\",\n }}\n >\n {mode !== \"time\" ? dateControl : null}\n {mode !== \"date\" ? timeField : null}\n {showClear ? (\n <button\n type=\"button\"\n data-a2ui-input=\"\"\n aria-label=\"Clear\"\n onClick={() => write({ date: \"\", time: \"\" })}\n style={{\n minWidth: 24,\n minHeight: 24,\n border: \"none\",\n background: \"transparent\",\n cursor: \"pointer\",\n color: textColor(\"secondary\"),\n }}\n >\n <span aria-hidden=\"true\">×</span>\n </button>\n ) : null}\n </div>\n {summary ? (\n <span\n id={summaryId}\n data-a2ui-datetime-summary=\"\"\n style={{ ...textFont(\"sm\"), color: textColor(\"secondary\") }}\n >\n {summary}\n </span>\n ) : null}\n </Field>\n );\n}\n\n// ---- Choices ----\n\ntype ChoicePickerProps = z.output<typeof choicePickerSchema> & {\n setValue: (value: string[]) => void;\n};\n\n/**\n * One or more options from a list, as checkboxes (or radios, for one\n * choice) or as chips. The value is always a list of option values.\n */\nfunction ChoicePicker(props: ChoicePickerProps) {\n useStandardStyles();\n const labelId = useId();\n const fallbackName = useId();\n const [filter, setFilter] = useState(\"\");\n const isMultiple = props.variant === \"multipleSelection\";\n const isChips = props.displayStyle === \"chips\";\n const chosen = Array.isArray(props.value) ? props.value : [];\n const check = useChecks(props.checks, chosen);\n const options = normalizeOptions(props.options);\n const shown = filter\n ? options.filter((option) =>\n option.label.toLowerCase().includes(filter.toLowerCase()),\n )\n : options;\n const toggle = (value: string) => {\n if (!isMultiple) {\n props.setValue(chosen.includes(value) ? [] : [value]);\n return;\n }\n props.setValue(\n chosen.includes(value)\n ? chosen.filter((item) => item !== value)\n : [...chosen, value],\n );\n };\n return (\n <Field\n label={props.label}\n labelId={labelId}\n weight={props.weight}\n error={check.error}\n onBlur={check.onBlur}\n >\n {props.filterable ? (\n <input\n type=\"search\"\n data-a2ui-input=\"\"\n aria-label=\"Filter options\"\n placeholder=\"Filter…\"\n value={filter}\n disabled={props.disabled}\n onChange={(event) => setFilter(event.target.value)}\n style={controlStyle(props, \"lg\")}\n />\n ) : null}\n {props.required ? (\n // The checkboxes and chips carry no selection of their own, so this\n // sentinel makes an empty required choice fail the Form's\n // constraint validation. It is invisible and not in the tab order.\n <input\n tabIndex={-1}\n aria-hidden=\"true\"\n required\n disabled={props.disabled}\n name={undefined}\n value={chosen.join(\",\")}\n onChange={() => {}}\n style={{\n position: \"absolute\",\n opacity: 0,\n width: 1,\n height: 1,\n margin: 0,\n padding: 0,\n border: 0,\n pointerEvents: \"none\",\n }}\n />\n ) : null}\n <div\n role={isChips ? \"group\" : isMultiple ? \"group\" : \"radiogroup\"}\n aria-labelledby={props.label ? labelId : undefined}\n aria-required={props.required || undefined}\n aria-invalid={check.invalid || undefined}\n style={{\n display: \"flex\",\n flexDirection: isChips ? \"row\" : \"column\",\n flexWrap: isChips ? \"wrap\" : undefined,\n gap: spacing(2),\n opacity: props.disabled ? 0.5 : undefined,\n }}\n >\n {shown.map((option) => {\n const isSelected = chosen.includes(option.value);\n if (isChips) {\n return (\n <button\n key={option.value}\n type=\"button\"\n data-a2ui-input=\"\"\n aria-pressed={isSelected}\n disabled={props.disabled}\n onClick={() => toggle(option.value)}\n style={{\n ...radioOptionStyle(\"pills\", isSelected),\n background: isSelected\n ? backgroundColor(\"surface-secondary\")\n : \"transparent\",\n color: textColor(\"default\"),\n fontFamily: \"inherit\",\n cursor: props.disabled ? \"not-allowed\" : \"pointer\",\n }}\n >\n {option.label}\n </button>\n );\n }\n return (\n <label key={option.value} style={radioOptionStyle(\"list\", false)}>\n <input\n type={isMultiple ? \"checkbox\" : \"radio\"}\n className=\"a2ui-std-check\"\n data-a2ui-input=\"\"\n name={fallbackName}\n value={option.value}\n checked={isSelected}\n disabled={props.disabled}\n onChange={() => toggle(option.value)}\n onClick={\n // A radio does not fire onChange when it is already checked.\n !isMultiple && isSelected\n ? () => toggle(option.value)\n : undefined\n }\n />\n <span style={{ display: \"flex\", flexDirection: \"column\" }}>\n <span>{option.label}</span>\n {option.description ? (\n <span\n style={{ ...textFont(\"sm\"), color: textColor(\"secondary\") }}\n >\n {option.description}\n </span>\n ) : null}\n </span>\n </label>\n );\n })}\n </div>\n </Field>\n );\n}\n\ntype SelectProps = z.output<typeof selectSchema> & {\n setValue: (value: string) => void;\n};\n\nfunction Select(props: SelectProps) {\n useStandardStyles();\n const aria = useGenerativeUIAccessibility();\n const id = useId();\n const options = normalizeOptions(props.options);\n const value = asText(props.value);\n const check = useChecks(props.checks, props.value);\n const hasEmptyOption = Boolean(\n props.placeholder || props.clearable || value === \"\",\n );\n const select = (\n <select\n id={id}\n data-a2ui-input=\"\"\n name={props.name}\n aria-label={props.label ? undefined : props.placeholder}\n required={props.required}\n disabled={props.disabled}\n aria-invalid={check.invalid || undefined}\n value={value}\n onChange={(event) => props.setValue(event.target.value)}\n style={{\n ...controlStyle(props, \"xl\"),\n ...SELECT_STYLE,\n width: props.block === false ? undefined : \"100%\",\n paddingLeft: props.icon\n ? `${PAD_X[props.size ?? \"xl\"] + 24}px`\n : undefined,\n }}\n {...controlAria(aria)}\n >\n {hasEmptyOption ? (\n <option value=\"\">{props.clearLabel ?? props.placeholder ?? \"\"}</option>\n ) : null}\n {options.map((option) => (\n <option\n key={option.value}\n value={option.value}\n title={option.description}\n >\n {option.label}\n </option>\n ))}\n </select>\n );\n return (\n <Field\n label={props.label}\n htmlFor={id}\n error={check.error}\n onBlur={check.onBlur}\n >\n {props.icon ? (\n <span style={{ position: \"relative\", display: \"flex\", width: \"100%\" }}>\n <span\n aria-hidden=\"true\"\n style={{\n position: \"absolute\",\n left: PAD_X[props.size ?? \"xl\"],\n top: \"50%\",\n transform: \"translateY(-50%)\",\n display: \"flex\",\n pointerEvents: \"none\",\n color: textColor(\"secondary\"),\n }}\n >\n <LucideIcon name={props.icon} size={16} />\n </span>\n {select}\n </span>\n ) : (\n select\n )}\n </Field>\n );\n}\n\ntype CheckBoxProps = z.output<typeof checkBoxSchema> & {\n setValue: (value: boolean) => void;\n};\n\nfunction CheckBox(props: CheckBoxProps) {\n useStandardStyles();\n const aria = useGenerativeUIAccessibility();\n const isChecked = Boolean(props.value);\n const hasLabel = props.label !== undefined && props.label !== \"\";\n const check = useChecks(props.checks, props.value);\n return (\n <span\n {...wrapperAria(aria)}\n style={{\n display: \"inline-flex\",\n flexDirection: \"column\",\n gap: spacing(1),\n flexGrow: props.weight,\n }}\n onBlurCapture={check.onBlur}\n >\n <label\n style={{\n display: \"inline-flex\",\n alignItems: \"center\",\n flexGrow: props.weight,\n gap: spacing(2),\n cursor: props.disabled ? \"not-allowed\" : \"pointer\",\n opacity: props.disabled ? 0.5 : undefined,\n ...textFont(\"md\"),\n color: textColor(\"default\"),\n }}\n >\n <input\n type=\"checkbox\"\n className=\"a2ui-std-check\"\n data-a2ui-input=\"\"\n data-shape={props.shape ?? \"round\"}\n name={props.name}\n aria-label={hasLabel ? undefined : props.name}\n required={props.required}\n disabled={props.disabled}\n checked={isChecked}\n aria-invalid={check.invalid || undefined}\n onChange={(event) => props.setValue(event.target.checked)}\n {...controlAria(aria)}\n />\n {hasLabel ? (\n <span\n style={{\n textDecoration:\n props.lineThrough && isChecked ? \"line-through\" : undefined,\n }}\n >\n {props.label}\n </span>\n ) : null}\n </label>\n <CheckError check={check.error} />\n </span>\n );\n}\n\nfunction Radio(props: z.output<typeof radioSchema>) {\n useStandardStyles();\n const aria = useGenerativeUIAccessibility();\n return (\n <label\n {...wrapperAria(aria)}\n style={{\n display: \"inline-flex\",\n alignItems: \"center\",\n gap: spacing(2),\n ...textFont(\"md\"),\n }}\n >\n <input\n type=\"radio\"\n className=\"a2ui-std-check\"\n data-a2ui-input=\"\"\n value={props.value}\n disabled={props.disabled}\n required={props.required}\n {...controlAria(aria)}\n />\n {props.label ?? props.value}\n </label>\n );\n}\n\ntype RadioGroupProps = z.output<typeof radioGroupSchema> & {\n setValue: (value: string) => void;\n};\n\nfunction radioOptionStyle(\n variant: NonNullable<RadioGroupProps[\"variant\"]>,\n isSelected: boolean,\n) {\n const base = {\n display: \"inline-flex\",\n alignItems: variant === \"cards\" ? \"flex-start\" : \"center\",\n gap: spacing(2),\n cursor: \"pointer\",\n ...textFont(\"md\"),\n } satisfies CSSProperties;\n if (variant === \"list\") return base;\n return {\n ...base,\n padding: variant === \"cards\" ? spacing(3) : `4px ${spacing(3)}`,\n border: `1px solid ${isSelected ? ACCENT : borderColor(\"default\")}`,\n borderRadius: variant === \"pills\" ? \"9999px\" : radius(\"lg\"),\n };\n}\n\n/** Native radios in a fieldset, so the arrow keys work without extra code. */\nfunction RadioGroup(props: RadioGroupProps) {\n useStandardStyles();\n const aria = useGenerativeUIAccessibility();\n const fallbackName = useId();\n const name = props.name ?? fallbackName;\n const options = normalizeOptions(props.options);\n const value = asText(props.value);\n const variant = props.variant ?? \"list\";\n const check = useChecks(props.checks, props.value);\n return (\n <fieldset\n {...aria}\n disabled={props.disabled}\n aria-invalid={check.invalid || undefined}\n onBlurCapture={check.onBlur}\n style={{ border: 0, margin: 0, padding: 0, minWidth: 0 }}\n >\n {props.label ? (\n <legend\n style={{ ...FIELD_LABEL_STYLE, padding: 0, marginBottom: spacing(1) }}\n >\n {props.label}\n </legend>\n ) : null}\n <div\n style={{\n display: \"flex\",\n flexDirection: props.direction === \"col\" ? \"column\" : \"row\",\n flexWrap: \"wrap\",\n gap: spacing(variant === \"list\" ? 3 : 2),\n }}\n >\n {options.map((option) => {\n const isSelected = option.value === value;\n return (\n <label\n key={option.value}\n style={radioOptionStyle(variant, isSelected)}\n >\n <input\n type=\"radio\"\n data-a2ui-input=\"\"\n name={name}\n value={option.value}\n required={props.required}\n checked={isSelected}\n onChange={() => props.setValue(option.value)}\n className=\"a2ui-std-check\"\n />\n <span style={{ display: \"flex\", flexDirection: \"column\" }}>\n <span>{option.label}</span>\n {option.description ? (\n <span\n style={{ ...textFont(\"sm\"), color: textColor(\"secondary\") }}\n >\n {option.description}\n </span>\n ) : null}\n </span>\n </label>\n );\n })}\n </div>\n <CheckError check={check.error} />\n </fieldset>\n );\n}\n\ntype SegmentedControlProps = z.output<typeof segmentedControlSchema> & {\n setValue: (value: string) => void;\n};\n\n/**\n * The option that an arrow key, Home or End moves to, or `undefined` for\n * other keys. The arrow keys wrap at the ends.\n */\nfunction nextOptionIndex(key: string, index: number, count: number) {\n switch (key) {\n case \"ArrowRight\":\n case \"ArrowDown\":\n return (index + 1) % count;\n case \"ArrowLeft\":\n case \"ArrowUp\":\n return (index - 1 + count) % count;\n case \"Home\":\n return 0;\n case \"End\":\n return count - 1;\n default:\n return undefined;\n }\n}\n\nfunction segmentStyle(\n props: SegmentedControlProps,\n isSelected: boolean,\n segmentSize: Size,\n isPill: boolean,\n) {\n const isSolid = props.variant === \"solid\";\n const selectedBackground = isSolid ? ACCENT : backgroundColor(\"surface\");\n const selectedColor = isSolid ? ON_ACCENT : textColor(\"default\");\n return {\n flex: props.block ? 1 : undefined,\n minHeight: HEIGHT[segmentSize] - 4,\n padding: `0 ${PAD_X[segmentSize]}px`,\n fontSize: FONT_SIZE[segmentSize],\n fontFamily: \"inherit\",\n fontWeight: FONT_WEIGHT.medium,\n border: \"none\",\n cursor: props.disabled ? \"not-allowed\" : \"pointer\",\n borderRadius: isPill ? \"9999px\" : radius(\"sm\"),\n background: isSelected ? selectedBackground : \"transparent\",\n color: isSelected ? selectedColor : textColor(\"secondary\"),\n boxShadow: isSelected && !isSolid ? SHADOW_XS : undefined,\n } satisfies CSSProperties;\n}\n\n/**\n * A radio group drawn as buttons. It is one tab stop: the selected segment\n * (or the first one) is in the tab order, and the arrow keys, Home and End\n * move the focus and select the segment.\n */\nfunction SegmentedControl(props: SegmentedControlProps) {\n useStandardStyles();\n const labelId = useId();\n const segments = useRef<(HTMLButtonElement | null)[]>([]);\n const segmentSize = props.size ?? \"lg\";\n const options = normalizeOptions(props.options);\n const value = asText(props.value);\n const isPill = props.pill !== false;\n const check = useChecks(props.checks, props.value);\n const selectedIndex = options.findIndex((option) => option.value === value);\n const tabStopIndex = selectedIndex === -1 ? 0 : selectedIndex;\n const onKeyDown = (\n event: KeyboardEvent<HTMLButtonElement>,\n index: number,\n ) => {\n const next = nextOptionIndex(event.key, index, options.length);\n if (next === undefined) return;\n const option = options[next];\n if (option === undefined) return;\n event.preventDefault();\n props.setValue(option.value);\n segments.current[next]?.focus();\n };\n return (\n <Field\n label={props.label}\n labelId={labelId}\n error={check.error}\n onBlur={check.onBlur}\n >\n <div\n role=\"radiogroup\"\n aria-labelledby={props.label ? labelId : undefined}\n style={{\n display: props.block ? \"flex\" : \"inline-flex\",\n width: props.block ? \"100%\" : undefined,\n gap: 2,\n padding: 2,\n boxSizing: \"border-box\",\n background: backgroundColor(\"surface-secondary\"),\n border:\n props.variant === \"outline\"\n ? `1px solid ${borderColor(\"default\")}`\n : undefined,\n borderRadius: isPill ? \"9999px\" : radius(\"md\"),\n opacity: props.disabled ? 0.5 : undefined,\n }}\n >\n {options.map((option, index) => {\n const isSelected = index === selectedIndex;\n return (\n <button\n key={option.value}\n ref={(element) => {\n segments.current[index] = element;\n }}\n type=\"button\"\n role=\"radio\"\n aria-checked={isSelected}\n tabIndex={index === tabStopIndex ? 0 : -1}\n data-a2ui-input=\"\"\n disabled={props.disabled}\n onClick={(event) => {\n event.stopPropagation();\n props.setValue(option.value);\n }}\n onKeyDown={(event) => onKeyDown(event, index)}\n style={segmentStyle(props, isSelected, segmentSize, isPill)}\n >\n {option.label}\n </button>\n );\n })}\n </div>\n </Field>\n );\n}\n\n// ---- Slider ----\n\ntype SliderProps = z.output<typeof sliderSchema> & {\n setValue: (value: number) => void;\n};\n\nfunction Slider(props: SliderProps) {\n useStandardStyles();\n const aria = useGenerativeUIAccessibility();\n const id = useId();\n const listId = useId();\n const min = props.min ?? 0;\n const max = props.max ?? 100;\n const value = props.value ?? min;\n const marks = props.marks ?? [];\n const step = props.steps ? (max - min) / props.steps : (props.step ?? 1);\n const isDiscrete = props.sliderStyle === \"discrete\";\n const check = useChecks(props.checks, props.value);\n const valueText = props.unit ? `${value} ${props.unit}` : `${value}`;\n const showValue = Boolean(props.label || props.unit);\n return (\n <div\n {...wrapperAria(aria)}\n style={{\n display: \"flex\",\n flexDirection: \"column\",\n gap: spacing(2),\n width: \"100%\",\n minWidth: 0,\n flexGrow: props.weight,\n }}\n onBlurCapture={check.onBlur}\n >\n <div\n style={{\n display: \"flex\",\n justifyContent: \"space-between\",\n alignItems: \"center\",\n gap: spacing(2),\n ...textFont(\"sm\"),\n }}\n >\n {props.label ? (\n <label\n htmlFor={id}\n style={{\n fontWeight: FONT_WEIGHT.medium,\n color: textColor(\"secondary\"),\n }}\n >\n {props.label}\n </label>\n ) : (\n <span />\n )}\n <span\n style={{\n fontWeight: FONT_WEIGHT.semibold,\n fontVariantNumeric: \"tabular-nums\",\n }}\n >\n {showValue ? valueText : null}\n </span>\n </div>\n <input\n id={id}\n type=\"range\"\n className=\"a2ui-std-range\"\n data-a2ui-input=\"\"\n name={props.name}\n aria-label={props.label ? undefined : props.name}\n aria-valuetext={props.unit ? valueText : undefined}\n min={min}\n max={max}\n step={step}\n disabled={props.disabled}\n value={value}\n list={isDiscrete && marks.length > 0 ? listId : undefined}\n onChange={(event) => props.setValue(Number(event.target.value))}\n {...controlAria(aria)}\n />\n {marks.length > 0 ? (\n <>\n <datalist id={listId}>\n {marks.map((mark) => (\n <option key={mark.value} value={mark.value} label={mark.label} />\n ))}\n </datalist>\n <div\n aria-hidden=\"true\"\n style={{\n display: \"flex\",\n justifyContent: \"space-between\",\n gap: spacing(2),\n fontSize: \".875em\",\n lineHeight: 1.3,\n color: textColor(\"secondary\"),\n }}\n >\n {marks.map((mark) => (\n <span key={mark.value}>{mark.label ?? mark.value}</span>\n ))}\n </div>\n </>\n ) : null}\n <CheckError check={check.error} />\n </div>\n );\n}\n\n// ---- Catalog ----\n\n/**\n * The standard input components: Button, Pressable, Form, and the controls.\n * Give them to `createGenerativeUI({ components: { ...inputComponents } })`.\n *\n * - Button and Pressable send `onClick`. Form sends `onSubmit`. The model\n * binds an event to `{ \"event\": { \"name\", \"userMessage\"?, \"context\"? } }`\n * or `{ \"functionCall\": { \"@call\", \"args\"? } }`, or an app function with\n * the same name binds it automatically.\n * - The value of a control is writable: `value`.\n * When the model binds it to `{ \"@path\": \"/x\" }`, what the user enters goes\n * into the data model at that path, and the agent can no longer change it.\n */\nexport const inputComponents = withComponents(inputDeclarations, {\n Button,\n Pressable,\n Form,\n TextField,\n TextArea,\n Select,\n CheckBox,\n Radio,\n RadioGroup,\n Slider,\n SegmentedControl,\n ChoicePicker,\n DateTimeInput,\n});\n","import React, { useEffect, useId, useState } from \"react\";\nimport type {\n CSSProperties,\n FocusEvent,\n KeyboardEvent,\n ReactNode,\n} from \"react\";\nimport type { z } from \"zod\";\nimport {\n ExternalLink,\n Markdown,\n renderInlineMarkdown,\n safeHref,\n} from \"./markdown\";\nimport { useGenerativeUIAccessibility } from \"../accessibility\";\nimport { useStandardStyles } from \"./styles\";\nimport {\n FONT_WEIGHT,\n ON_ACCENT,\n SHADOW_MD,\n backgroundColor,\n borderColor,\n radius,\n spacing,\n textColor,\n textDeclarations,\n textFont,\n withComponents,\n} from \"@copilotkit/shared/generative-ui\";\nimport type {\n BADGE_SIZES,\n CAPTION_SIZES,\n TitleSize,\n badgeSchema,\n blockquoteSchema,\n boldSchema,\n captionSchema,\n codeSchema,\n inlineTextSchema,\n labelSchema,\n linkSchema,\n mathSchema,\n shimmerSchema,\n textSchema,\n titleSchema,\n typographySchema,\n} from \"@copilotkit/shared/generative-ui\";\n\ntype TypographyProps = z.output<typeof typographySchema>;\ntype TextProps = z.output<typeof textSchema> & { children?: ReactNode };\ntype BadgeProps = z.output<typeof badgeSchema>;\ntype BadgeSize = (typeof BADGE_SIZES)[number];\ntype CaptionSize = (typeof CAPTION_SIZES)[number];\n\n// ---- Styles ----\n\nconst FOCUS_RING = \"2px solid var(--a2ui-color-focus, #0285ff)\";\nconst TEXT_STYLE_ID = \"a2ui-standard-text\";\nconst TEXT_CSS = [\n \"@keyframes a2ui-shimmer{0%{background-position:100% 0}100%{background-position:-100% 0}}\",\n \"@media (prefers-reduced-motion:reduce){[data-a2ui-shimmer]{animation:none!important}}\",\n `[data-a2ui-tooltip-trigger]:focus-visible{outline:${FOCUS_RING};outline-offset:2px}`,\n].join(\"\\n\");\n\n/** Adds the shimmer keyframes and the tooltip focus ring once. */\nfunction useTextStyles() {\n useEffect(() => {\n if (document.getElementById(TEXT_STYLE_ID)) return;\n const style = document.createElement(\"style\");\n style.id = TEXT_STYLE_ID;\n style.textContent = TEXT_CSS;\n document.head.appendChild(style);\n }, []);\n}\n\n/** The CSS of the shared typography props. */\nfunction typographyStyle(props: TypographyProps) {\n const clamp: CSSProperties = props.truncate\n ? { whiteSpace: \"nowrap\", overflow: \"hidden\", textOverflow: \"ellipsis\" }\n : props.maxLines\n ? {\n display: \"-webkit-box\",\n WebkitLineClamp: props.maxLines,\n WebkitBoxOrient: \"vertical\",\n overflow: \"hidden\",\n }\n : {};\n return {\n color: textColor(props.color),\n fontWeight: props.fontWeight ? FONT_WEIGHT[props.fontWeight] : undefined,\n textAlign: props.textAlign,\n fontStyle: props.italic ? \"italic\" : undefined,\n fontVariantNumeric: props.tabularNums ? \"tabular-nums\" : undefined,\n width: spacing(props.width),\n ...clamp,\n } satisfies CSSProperties;\n}\n\n// ---- Title ----\n\n/**\n * The heading level of each size. The size, line height and weight come\n * from the heading styles of the host (the chat prose). `styles.ts` has\n * fallbacks for hosts without heading styles.\n */\nconst TITLE_TAG: Record<TitleSize, \"h2\" | \"h3\" | \"h4\"> = {\n sm: \"h4\",\n md: \"h3\",\n lg: \"h3\",\n xl: \"h2\",\n \"2xl\": \"h2\",\n \"3xl\": \"h2\",\n \"4xl\": \"h2\",\n \"5xl\": \"h2\",\n};\n\nfunction Title(props: z.output<typeof titleSchema>) {\n useStandardStyles();\n const size = props.size ?? \"md\";\n const Tag = TITLE_TAG[size];\n // Only what the model set is inline. The rest comes from the host.\n const fontWeight = props.fontWeight\n ? FONT_WEIGHT[props.fontWeight]\n : props.strong === false\n ? FONT_WEIGHT.normal\n : undefined;\n return (\n <Tag\n data-a2ui-std=\"\"\n data-a2ui-title={size}\n style={{ ...typographyStyle(props), fontWeight }}\n >\n {props.text}\n </Tag>\n );\n}\n\n// ---- Text ----\n\nconst HIGHLIGHT = {\n green: \"var(--a2ui-color-highlight-green, #d3f5e4)\",\n orange: \"var(--a2ui-color-highlight-orange, #ffe7c7)\",\n pink: \"var(--a2ui-color-highlight-pink, #fde0ef)\",\n};\n\nfunction Text(props: TextProps) {\n useStandardStyles();\n const aria = useGenerativeUIAccessibility();\n const highlight =\n props.highlight === true\n ? HIGHLIGHT.orange\n : props.highlight\n ? HIGHLIGHT[props.highlight]\n : undefined;\n const decoration = [\n props.underline ? \"underline\" : \"\",\n props.lineThrough ? \"line-through\" : \"\",\n ]\n .filter(Boolean)\n .join(\" \");\n const typography = typographyStyle(props);\n const fontWeight = props.fontWeight\n ? FONT_WEIGHT[props.fontWeight]\n : props.strong\n ? FONT_WEIGHT.semibold\n : undefined;\n const hasChildren = React.Children.count(props.children) > 0;\n return (\n <span\n data-a2ui-text=\"\"\n data-a2ui-std=\"\"\n {...aria}\n style={{\n display: props.inline ? \"inline\" : \"block\",\n // In a Row, text takes the width of its content, not 100%.\n flex: props.inline ? undefined : `${props.weight ?? 0} 1 auto`,\n minWidth: props.inline ? undefined : 0,\n // Without a size, text takes the size and line height of the host.\n ...(props.size ? textFont(props.size) : {}),\n ...(props.fontSize !== undefined\n ? { fontSize: px(props.fontSize) }\n : {}),\n ...(props.lineHeight !== undefined\n ? { lineHeight: props.lineHeight }\n : {}),\n minHeight: props.minLines ? `${props.minLines * 1.5}em` : undefined,\n margin: 0,\n ...typography,\n fontWeight,\n textDecoration: decoration || undefined,\n whiteSpace: props.preserveWhitespace\n ? \"pre-wrap\"\n : typography.whiteSpace,\n background: highlight,\n }}\n >\n {renderInlineMarkdown(props.text === undefined ? \"\" : String(props.text))}\n {hasChildren ? (\n <>\n {props.text ? \" \" : null}\n {props.children}\n </>\n ) : null}\n </span>\n );\n}\n\n// ---- Caption, Label, Bold ----\n\n/** Caption \"lg\" (the default) is 14px at a 16px base. */\nconst CAPTION_EM: Record<CaptionSize, string> = {\n sm: \".75em\",\n md: \".8125em\",\n lg: \".875em\",\n};\n\nfunction Caption(props: z.output<typeof captionSchema>) {\n return (\n <span\n style={{\n display: \"block\",\n fontSize: CAPTION_EM[props.size ?? \"lg\"],\n margin: 0,\n ...typographyStyle({ ...props, color: props.color ?? \"secondary\" }),\n fontWeight: FONT_WEIGHT[props.fontWeight ?? \"normal\"],\n }}\n >\n {renderInlineMarkdown(String(props.text))}\n </span>\n );\n}\n\nfunction Label(props: z.output<typeof labelSchema>) {\n return (\n <label\n htmlFor={props.htmlFor}\n style={{\n display: \"block\",\n ...textFont(props.size ?? \"sm\"),\n margin: 0,\n ...typographyStyle({ ...props, color: props.color ?? \"secondary\" }),\n fontWeight: FONT_WEIGHT[props.fontWeight ?? \"medium\"],\n }}\n >\n {props.text}\n </label>\n );\n}\n\n/** Pixels when a number, raw CSS when a string. */\nfunction px(value: number | string) {\n return typeof value === \"number\" ? `${value}px` : value;\n}\n\nfunction Italic(props: z.output<typeof inlineTextSchema>) {\n return <em>{props.text}</em>;\n}\n\nfunction Underline(props: z.output<typeof inlineTextSchema>) {\n return <u>{props.text}</u>;\n}\n\nfunction Strikethrough(props: z.output<typeof inlineTextSchema>) {\n return <s>{props.text}</s>;\n}\n\nfunction Blockquote(props: z.output<typeof blockquoteSchema>) {\n useStandardStyles();\n return (\n <blockquote\n data-a2ui-std=\"\"\n style={{\n margin: 0,\n paddingLeft: spacing(3),\n borderLeft: `3px solid ${borderColor(\"strong\")}`,\n color: textColor(\"secondary\"),\n }}\n >\n {renderInlineMarkdown(props.text)}\n </blockquote>\n );\n}\n\nfunction Bold(props: z.output<typeof boldSchema>) {\n return (\n <strong\n style={{\n fontWeight: props.fontWeight\n ? FONT_WEIGHT[props.fontWeight]\n : undefined,\n }}\n >\n {props.text}\n </strong>\n );\n}\n\n// ---- Badge ----\n\n/** Badge \"md\": a 20px pill, 12px text with weight 500 and 0.3px tracking. */\nconst BADGE_PAD: Record<BadgeSize, string> = {\n sm: \"0 5px\",\n md: \"0 6.65px\",\n lg: \"2px 8px\",\n};\nconst BADGE_FONT: Record<BadgeSize, string> = {\n sm: \".6875em\",\n md: \".75em\",\n lg: \".8125em\",\n};\nconst BADGE_HEIGHT: Record<BadgeSize, number> = { sm: 18, md: 20, lg: 24 };\nconst BADGE_NEUTRAL_BG =\n \"var(--a2ui-color-badge-secondary, rgba(0, 0, 0, 0.05))\";\n\n/** The fill of a badge: solid, none (outline), or a soft tint. */\nfunction badgeBackground(color: string, variant: string) {\n const isNeutral = color === \"secondary\";\n switch (variant) {\n case \"solid\":\n return backgroundColor(isNeutral ? \"surface-inverted\" : `${color}-solid`);\n case \"outline\":\n return \"transparent\";\n default:\n return isNeutral ? BADGE_NEUTRAL_BG : backgroundColor(color);\n }\n}\n\nfunction Badge(props: BadgeProps) {\n const color = props.color ?? \"secondary\";\n const variant = props.variant ?? \"soft\";\n const size = props.size ?? \"md\";\n const isNeutral = color === \"secondary\";\n const ink = textColor(isNeutral ? \"default\" : color);\n return (\n <span\n style={{\n display: \"inline-flex\",\n alignItems: \"center\",\n gap: 4,\n flexShrink: 0,\n boxSizing: \"border-box\",\n minHeight: BADGE_HEIGHT[size],\n verticalAlign: \"middle\",\n whiteSpace: \"nowrap\",\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n maxWidth: spacing(props.maxWidth),\n padding:\n props.padding !== undefined\n ? spacing(props.padding)\n : BADGE_PAD[size],\n fontSize: BADGE_FONT[size],\n lineHeight: \"16px\",\n letterSpacing: \"0.3px\",\n fontWeight: FONT_WEIGHT[props.fontWeight ?? \"medium\"],\n borderRadius: props.pill === false ? radius(\"sm\") : radius(\"full\"),\n background: badgeBackground(color, variant),\n color: variant === \"solid\" ? ON_ACCENT : ink,\n border:\n variant === \"outline\"\n ? `1px solid ${borderColor(isNeutral ? \"default\" : color)}`\n : undefined,\n }}\n >\n {props.label}\n </span>\n );\n}\n\n// ---- Code, Math ----\n\nfunction Code(props: z.output<typeof codeSchema>) {\n useStandardStyles();\n return (\n // The block scrolls sideways, so a keyboard user must be able to focus it.\n <pre\n tabIndex={0}\n data-a2ui-scroll=\"\"\n style={{\n margin: 0,\n padding: spacing(3),\n borderRadius: radius(\"md\"),\n background: backgroundColor(\"surface-secondary\"),\n overflowX: \"auto\",\n fontSize: \".8125em\",\n }}\n >\n <code data-language={props.language}>{props.text}</code>\n </pre>\n );\n}\n\n/**\n * Shows the TeX source as code. react-core ships no math typesetter, so a\n * formula reads as its source, which is still exact.\n */\nfunction MathFormula(props: z.output<typeof mathSchema>) {\n if (props.block === true) {\n return (\n <pre data-math=\"block\">\n <code>{props.value}</code>\n </pre>\n );\n }\n return <code data-math=\"inline\">{props.value}</code>;\n}\n\n// ---- ShimmerText ----\n\nfunction ShimmerText(props: z.output<typeof shimmerSchema>) {\n useTextStyles();\n const base = textColor(props.color ?? \"secondary\");\n return (\n <span\n data-a2ui-shimmer=\"\"\n style={{\n ...(props.size ? textFont(props.size) : {}),\n margin: 0,\n ...typographyStyle(props),\n display: \"inline-block\",\n textDecoration: props.lineThrough ? \"line-through\" : undefined,\n backgroundImage: `linear-gradient(90deg, ${base} 0%, ${base} 40%, var(--a2ui-color-shimmer, #d9d9d9) 50%, ${base} 60%, ${base} 100%)`,\n backgroundSize: \"200% 100%\",\n WebkitBackgroundClip: \"text\",\n backgroundClip: \"text\",\n color: \"transparent\",\n animation: \"a2ui-shimmer 1.5s linear infinite\",\n }}\n >\n {props.text}\n </span>\n );\n}\n\n// ---- Link ----\n\nfunction Link(props: z.output<typeof linkSchema>) {\n const href = safeHref(props.href);\n const label = props.text || props.href;\n if (!href) return <span title={props.title}>{label}</span>;\n return (\n <ExternalLink\n href={href}\n title={props.title}\n style={{ color: textColor(\"info\") }}\n >\n {label}\n </ExternalLink>\n );\n}\n\n// ---- Tooltip ----\n\ninterface TooltipProps {\n trigger?: ReactNode;\n content?: ReactNode;\n}\n\n/**\n * Shows `content` while the pointer is over `trigger` or while `trigger`\n * has keyboard focus. Escape hides it. The trigger can take focus, and\n * screen readers read the content as its description.\n */\nfunction Tooltip({ trigger, content }: TooltipProps) {\n useTextStyles();\n const id = useId();\n const [isOpen, setOpen] = useState(false);\n const close = () => setOpen(false);\n const onBlur = (event: FocusEvent<HTMLSpanElement>) => {\n const isFocusInside = event.currentTarget.contains(event.relatedTarget);\n if (!isFocusInside) close();\n };\n const onKeyDown = (event: KeyboardEvent<HTMLSpanElement>) => {\n if (event.key === \"Escape\") close();\n };\n return (\n <span\n // The wrapper hugs the trigger, so the tip centers on the trigger and\n // not on a stretched flex item.\n style={{\n position: \"relative\",\n display: \"inline-flex\",\n alignSelf: \"flex-start\",\n width: \"max-content\",\n maxWidth: \"100%\",\n }}\n onMouseEnter={() => setOpen(true)}\n onMouseLeave={close}\n >\n <span\n tabIndex={0}\n data-a2ui-tooltip-trigger=\"\"\n aria-describedby={id}\n style={{ display: \"inline-flex\" }}\n onFocus={() => setOpen(true)}\n onBlur={onBlur}\n onKeyDown={onKeyDown}\n >\n {trigger}\n </span>\n {/* The padding keeps the tooltip open while the pointer moves onto it. */}\n <span\n role=\"tooltip\"\n id={id}\n hidden={!isOpen}\n style={{\n position: \"absolute\",\n bottom: \"100%\",\n left: \"50%\",\n transform: \"translateX(-50%)\",\n paddingBottom: 6,\n zIndex: 10,\n }}\n >\n <span\n style={{\n display: \"block\",\n width: \"max-content\",\n maxWidth: 240,\n padding: \"4px 8px\",\n borderRadius: radius(\"sm\"),\n background: backgroundColor(\"surface-inverted\"),\n color: ON_ACCENT,\n boxShadow: SHADOW_MD,\n ...textFont(\"xs\"),\n }}\n >\n {content}\n </span>\n </span>\n </span>\n );\n}\n\n/**\n * The standard text components. Give them to\n * `createGenerativeUI({ components: { ...textComponents } })`.\n *\n * - Text has a \"multiple\" `children` slot. The children render inline\n * after the text.\n * - Tooltip has two \"single\" slots: `trigger` and `content`.\n * - Link is a plain link. It opens http, https and mailto URLs only.\n */\nexport const textComponents = withComponents(textDeclarations, {\n Title,\n Text,\n Caption,\n Label,\n Bold,\n Italic,\n Underline,\n Strikethrough,\n Badge,\n Blockquote,\n Code,\n Markdown,\n Math: MathFormula,\n ShimmerText,\n Link,\n Tooltip,\n});\n","import {\n STANDARD_CATALOG_ID,\n withStandardParameterOrder,\n} from \"@copilotkit/shared/generative-ui\";\nimport { createGenerativeUI } from \"../catalog\";\nimport { compositeComponents } from \"./composites\";\nimport { dataComponents } from \"./data\";\nimport { feedbackComponents } from \"./feedback\";\nimport { inputComponents } from \"./inputs\";\nimport { layoutComponents } from \"./layout\";\nimport { mediaComponents } from \"./media\";\nimport { textComponents } from \"./text\";\n\nconst orderedComponents = withStandardParameterOrder({\n ...layoutComponents,\n ...textComponents,\n ...inputComponents,\n ...feedbackComponents,\n ...dataComponents,\n ...mediaComponents,\n ...compositeComponents,\n});\n\n/**\n * Experimental. The standard components: layout, text, inputs, feedback,\n * data, media and composites. Give it to the provider as it is, or add your\n * own components on top of it with `extends`.\n *\n * Style the components with the `--a2ui-*` CSS variables. Set them with\n * the `theme` option of `generativeUI`. The components have built-in dark\n * values, which apply under a `.dark` class, like the CopilotKit chat.\n *\n * Replace the React component of a standard component with `overrides`.\n * Drop standard components with `standardUI.omit([...])`.\n *\n * @example\n * ```tsx\n * <CopilotKitProvider runtimeUrl=\"/api/copilotkit\" generativeUI={{ ui: standardUI }} />\n *\n * const ui = createGenerativeUI({\n * id: \"acme/app@1\",\n * extends: [standardUI.omit([\"Map\"])],\n * overrides: { Card: { component: MyCard } },\n * components: { ProductCard: { component: ProductCard, props: productSchema } },\n * });\n * ```\n */\nexport const standardUI = createGenerativeUI({\n id: STANDARD_CATALOG_ID,\n components: orderedComponents,\n});\n"],"mappings":";;;;;;;;;;;;;;;;;AASA,MAAM,WAA8B,EAAE;AACtC,IAAI;AAEJ,SAAS,UAAU,OAAsB;AACvC,KAAI,MAAM,QAAQ,YAAY,SAAS,WAAW,EAAG;AACrD,OAAM,iBAAiB;AACvB,UAAS,SAAS,SAAS,IAAK;;;;;;AAOlC,SAAgB,iBAAiB,QAAiB,OAAmB;AACnE,4BAAgB;AACd,MAAI,CAAC,OAAQ;EACb,MAAM,gBAAgB,OAAO;AAC7B,WAAS,KAAK,QAAQ;AACtB,MAAI,CAAC,QAAQ;AACX,YAAS,iBAAiB,WAAW,UAAU;AAC/C,kBAAe,SAAS,oBAAoB,WAAW,UAAU;;AAEnE,eAAa;GACX,MAAM,QAAQ,SAAS,YAAY,QAAQ;AAC3C,OAAI,UAAU,GAAI,UAAS,OAAO,OAAO,EAAE;AAC3C,OAAI,SAAS,WAAW,KAAK,QAAQ;AACnC,YAAQ;AACR,aAAS;;;IAGZ,CAAC,QAAQ,MAAM,CAAC;;;;;ACtBrB,MAAM,kBAAiC;CACrC,UAAU;CACV,QAAQ;CACR,cAAc;CACd,YAAY;CACZ,OAAOA;CACP,QAAQ;CACR,SAAS;CACT,YAAY;CACZ,gBAAgB;CACjB;;;;;;AAOD,SAAgB,SAAS,EACvB,QACA,QAAQ,GACR,WAKC;CACD,MAAM,CAAC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