@copilotkit/react-core 2.0.0-rc.7 → 2.0.0-rc.9
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-B4Us6mwL.d.cts → MarkdownRendererContext-CS35epe1.d.mts} +17 -33
- package/dist/MarkdownRendererContext-CS35epe1.d.mts.map +1 -0
- package/dist/{MarkdownRendererContext-CRKFzsEB.d.mts → MarkdownRendererContext-CfTh92vk.d.cts} +17 -33
- package/dist/MarkdownRendererContext-CfTh92vk.d.cts.map +1 -0
- package/dist/{MarkdownSurfaces-S4wfUl3J.cjs → MarkdownSurfaces-Ije2ZQh0.cjs} +111 -89
- package/dist/MarkdownSurfaces-Ije2ZQh0.cjs.map +1 -0
- package/dist/{MarkdownSurfaces-Bd--93O1.mjs → MarkdownSurfaces-iFKorV2w.mjs} +95 -80
- package/dist/MarkdownSurfaces-iFKorV2w.mjs.map +1 -0
- package/dist/context.cjs +20 -17
- package/dist/context.cjs.map +1 -1
- package/dist/context.d.cts +38 -98
- package/dist/context.d.cts.map +1 -1
- package/dist/context.d.mts +38 -98
- package/dist/context.d.mts.map +1 -1
- package/dist/context.mjs +20 -17
- package/dist/context.mjs.map +1 -1
- package/dist/generative-ui.cjs +541 -520
- package/dist/generative-ui.cjs.map +1 -1
- package/dist/generative-ui.d.cts +2137 -4178
- package/dist/generative-ui.d.cts.map +1 -1
- package/dist/generative-ui.d.mts +2137 -4178
- package/dist/generative-ui.d.mts.map +1 -1
- package/dist/generative-ui.mjs +37 -17
- package/dist/generative-ui.mjs.map +1 -1
- package/dist/headless.cjs +50 -76
- package/dist/headless.cjs.map +1 -1
- package/dist/headless.d.cts +78 -253
- package/dist/headless.d.cts.map +1 -1
- package/dist/headless.d.mts +56 -202
- package/dist/headless.d.mts.map +1 -1
- package/dist/headless.mjs +43 -74
- package/dist/headless.mjs.map +1 -1
- package/dist/index.cjs +765 -1292
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +176 -518
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +175 -517
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +469 -1251
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +867 -1375
- package/dist/index.umd.js.map +1 -1
- package/package.json +15 -16
- package/dist/MarkdownRendererContext-B4Us6mwL.d.cts.map +0 -1
- package/dist/MarkdownRendererContext-CRKFzsEB.d.mts.map +0 -1
- package/dist/MarkdownSurfaces-Bd--93O1.mjs.map +0 -1
- package/dist/MarkdownSurfaces-S4wfUl3J.cjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generative-ui.cjs","names":["z","A2UI_COMPONENT_ID_MARK","A2UI_CHILD_LIST_MARK","GENERATIVE_UI_FUNCTIONS","toJsonSchema","mapSchema","isRecord","A2UI_COMPONENT_ID_REF","A2UI_CHILD_LIST_REF","GENERATIVE_UI_MAX_TARGET_COMPONENTS","useRequiredGenerativeUIRuntime","SurfaceView","useGenerativeUIAccessibility","wrapperAria","FOCUS_RING","DARK_THEME_CSS","noEffect","useInjectEffect","React","z","NO_ARGS","ALIGN_CSS","useGenerativeUIAccessibility","namedRole","VISUALLY_HIDDEN","React","ProviderMarkdown","NO_ARGS","z","colorProp","px","ICON_PX","useGenerativeUIAccessibility","controlAria","wrapperAria","NO_ARGS","z","useGenerativeUIRuntime","GenerativeUINodeContext","z","React","Suspense","z","noEffect","useInjectEffect","useInsertionEffect","useRequiredGenerativeUIRuntime","z","Caption","useGenerativeUIAccessibility","React","z","useGenerativeUIAccessibility","controlAria","useGenerativeUIRuntime","wrapperAria","z","z","useGenerativeUIAccessibility","wrapperAria","controlAria","z","useGenerativeUIAccessibility","React","toJsonSchema","createGenerativeUI"],"sources":["../src/generative-ui/refs.ts","../src/generative-ui/catalog-export.ts","../src/generative-ui/GenerativeUISurface.tsx","../src/generative-ui/standard/overlay-stack.ts","../src/generative-ui/standard/tokens.ts","../src/generative-ui/standard/lightbox.tsx","../src/generative-ui/standard/styles.ts","../src/generative-ui/standard/layout.tsx","../src/generative-ui/standard/markdown.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/parameter-order.ts","../src/generative-ui/standard/index.ts"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport { z } from \"zod\";\nimport {\n A2UI_CHILD_LIST_MARK,\n A2UI_COMPONENT_ID_MARK,\n} from \"@copilotkit/shared\";\n\n/**\n * Schema helpers that mark a prop as a component reference, the way A2UI\n * 1.0 marks it with the `ComponentId` and `ChildList` common types. The\n * engine finds every marked prop in the props schema, at any depth, renders\n * the referenced components, and hands the component the rendered nodes in\n * place of the ids. The model sees the prop as `componentId` or as a list\n * of ids or a template.\n *\n * @example\n * ```ts\n * const tabsSchema = z.object({\n * tabs: z.array(z.object({ title: z.string(), child: child() })),\n * });\n * // The component gets `tabs: { title: string; child: ReactNode }[]`.\n * ```\n */\n\nconst toNode = (value: unknown) => value as ReactNode;\nconst mark = (prefix: string, description: string | undefined) =>\n description ? `${prefix} ${description}` : prefix;\n\n/**\n * One component id. The component receives the rendered child. Pass the\n * description here, not with `.describe()`, which would replace the mark.\n */\nexport function child(description?: string) {\n return z\n .string()\n .min(1)\n .describe(mark(A2UI_COMPONENT_ID_MARK, description))\n .transform(toNode);\n}\n\n/**\n * A list of component ids, or a template `{ componentId, path }` that\n * repeats one component for each item of the list at `path`. The\n * component receives the rendered children. Pass the description here,\n * not with `.describe()`.\n */\nexport function childList(description?: string) {\n return z\n .union([\n z.array(z.string().min(1)),\n z.object({ componentId: z.string().min(1), path: z.string().min(1) }),\n ])\n .describe(mark(A2UI_CHILD_LIST_MARK, description))\n .transform(toNode);\n}\n","import {\n A2UI_CHILD_LIST_REF,\n A2UI_COMPONENT_ID_REF,\n GENERATIVE_UI_FUNCTIONS,\n childRefKind,\n functionCallers,\n} from \"@copilotkit/shared\";\nimport type {\n A2UIAllowedCallers,\n A2UIFunctionPermissions,\n GenerativeUIComponentManifest,\n GenerativeUIJSONSchema,\n} from \"@copilotkit/shared\";\nimport type { GenerativeUI } from \"./catalog\";\nimport { toJsonSchema } from \"./json-schema\";\nimport { isRecord } from \"./is-record\";\n\nconst COMMON = \"common_types.json#/$defs/\";\nconst DATA_BINDING_REF = `${COMMON}DataBinding`;\nconst FUNCTION_CALL_REF = `${COMMON}FunctionCall`;\nconst ACTION_REF = `${COMMON}Action`;\nconst DYNAMIC_REFS: Record<string, string> = {\n string: `${COMMON}DynamicString`,\n number: `${COMMON}DynamicNumber`,\n boolean: `${COMMON}DynamicBoolean`,\n \"string[]\": `${COMMON}DynamicStringList`,\n unknown: `${COMMON}DynamicValue`,\n};\n\n/** What `exportA2UICatalog` adds at the top of the catalog. */\nexport interface ExportA2UICatalogOptions {\n /** The title of the catalog. */\n title?: string;\n /** What the catalog is for. */\n description?: string;\n /** Markdown design guidelines for a model that writes this catalog. */\n instructions?: string;\n}\n\n/**\n * The A2UI 1.0 catalog definition of a generative UI, as a JSON value that\n * follows `catalog_definition.json`: one `components` entry per component,\n * with `component` as a `const`, `functions` for the built-ins and the\n * declared functions, and `$defs.anyComponent` / `$defs.anyFunction`. Other\n * A2UI tools (a validator, another renderer, a prompt builder) read it.\n *\n * - A prop that `child()` or `childList()` marks is a `ComponentId` or a\n * `ChildList` reference; so is a slot. An event prop is an `Action`.\n * - Every other value, at any depth of a prop or of the args of a declared\n * function, takes its literal schema, a `DataBinding` or a `FunctionCall`,\n * because the renderer resolves dynamic values at any depth.\n * - Every function states `returnType` and `allowedCallers`: the built-ins\n * are `rendererOnly`, and so is a declared function without\n * `allowedCallers`, as in A2UI 1.0.\n *\n * @param ui - The generative UI to describe.\n * @param options - The title, description and instructions of the catalog.\n *\n * @example\n * ```ts\n * const catalog = exportA2UICatalog(shopUI, { title: \"Acme shop\" });\n * fs.writeFileSync(\"shop-catalog.json\", JSON.stringify(catalog, null, 2));\n * ```\n */\nexport function exportA2UICatalog(\n ui: GenerativeUI,\n options: ExportA2UICatalogOptions = {},\n) {\n const components = Object.fromEntries(\n Object.entries(ui.manifestComponents).map(([name, manifest]) => [\n name,\n toDraft2020(\n rebaseRefs(\n componentDefinition(name, manifest),\n `#/components/${pointerSegment(name)}`,\n ),\n ),\n ]),\n );\n const functions: Record<string, GenerativeUIJSONSchema> = {};\n for (const [name, info] of Object.entries(GENERATIVE_UI_FUNCTIONS)) {\n // A declared function of the same name is the app's.\n if (ui.functions.has(name)) continue;\n functions[name] = functionEntry(name, info, {\n description: info.description,\n returnType: info.returnType,\n args: argsSchemaFromSignature(info.parameters),\n });\n }\n for (const [name, fn] of ui.functions) {\n functions[name] = functionEntry(name, fn, {\n description: fn.description,\n returnType: fn.returnType ?? \"any\",\n args: toDraft2020(\n rebaseRefs(\n dynamicArgs(toJsonSchema(fn.parameters)),\n `#/functions/${pointerSegment(name)}/properties/args`,\n ),\n ),\n });\n }\n const { title, description, instructions } = options;\n return {\n $schema: \"https://json-schema.org/draft/2020-12/schema\",\n protocolVersion: \"1.0\",\n catalogId: ui.id,\n ...(title === undefined ? {} : { title }),\n ...(description === undefined ? {} : { description }),\n ...(instructions === undefined ? {} : { instructions }),\n components,\n functions,\n $defs: {\n anyComponent: {\n ...oneOfRefs(\"components\", Object.keys(components)),\n discriminator: { propertyName: \"component\" },\n },\n anyFunction: oneOfRefs(\"functions\", Object.keys(functions)),\n },\n };\n}\n\n/**\n * `oneOf` over the entries of a section. JSON Schema wants at least one\n * variant, so an empty section (a UI with no components) matches nothing.\n */\nfunction oneOfRefs(section: string, names: string[]) {\n if (names.length === 0) return { not: {} };\n return {\n oneOf: names.map((name) => ({\n $ref: `#/${section}/${pointerSegment(name)}`,\n })),\n };\n}\n\n/** A name as a JSON Pointer segment in a URI fragment: `acme/Card` is `acme~1Card`. */\nfunction pointerSegment(name: string) {\n return encodeURIComponent(name.replace(/~/g, \"~0\").replace(/\\//g, \"~1\"));\n}\n\n/** Keywords whose value is data, not a schema. */\nconst LITERAL_KEYWORDS = new Set([\"default\", \"const\", \"enum\", \"examples\"]);\n\n/**\n * A schema in the draft 2020-12 dialect that the catalog declares. The\n * converter writes draft-07, where a tuple is `items: [...]` with\n * `additionalItems`; 2020-12 spells that `prefixItems` and `items`.\n */\nfunction toDraft2020(schema: GenerativeUIJSONSchema): GenerativeUIJSONSchema {\n return mapSchema(schema, (node) => {\n const { items, additionalItems, ...rest } = node;\n if (!Array.isArray(items)) return node;\n return {\n ...rest,\n prefixItems: items,\n ...(additionalItems === undefined ? {} : { items: additionalItems }),\n };\n });\n}\n\n/** One `components` entry: the props as the model sets them, with the A2UI common types. */\nfunction componentDefinition(\n name: string,\n manifest: GenerativeUIComponentManifest,\n): GenerativeUIJSONSchema {\n const { properties, required, description, $defs, definitions } =\n manifest.props;\n const props = Object.fromEntries(\n Object.entries(isRecord(properties) ? properties : {}).map(\n ([key, schema]) => [key, dynamicProp(schema)],\n ),\n );\n const events = Object.fromEntries(\n Object.entries(manifest.events ?? {}).map(([key, event]) => [\n key,\n {\n $ref: ACTION_REF,\n ...(event.description ? { description: event.description } : {}),\n },\n ]),\n );\n const slots = Object.fromEntries(\n Object.entries(manifest.slots ?? {}).map(([key, kind]) => [\n key,\n { $ref: kind === \"single\" ? A2UI_COMPONENT_ID_REF : A2UI_CHILD_LIST_REF },\n ]),\n );\n const fields = { ...props, ...events, ...slots };\n const orderedFields =\n manifest.parameterOrder === undefined\n ? fields\n : Object.fromEntries(\n [...new Set([...manifest.parameterOrder, ...Object.keys(fields)])]\n .filter((key) => Object.hasOwn(fields, key))\n .map((key) => [key, fields[key]]),\n );\n const text = manifest.description ?? description;\n return {\n type: \"object\",\n ...(typeof text === \"string\" ? { description: text } : {}),\n properties: { component: { const: name }, ...orderedFields },\n required: [\n \"component\",\n ...(Array.isArray(required) ? required.filter(isString) : []),\n ],\n // The definitions of the props schema, when its converter made some:\n // their values are dynamic like the props, and the references to them\n // are rebased onto this entry.\n ...withDynamicChildren({\n ...(isRecord($defs) ? { $defs } : {}),\n ...(isRecord(definitions) ? { definitions } : {}),\n }),\n };\n}\n\n/**\n * The schema with its local references (`#/...`) pointing into the place\n * it is embedded at. A converter that writes `$defs` refers to them from\n * the root of its own document; inside the catalog, that root is `base`.\n */\nfunction rebaseRefs(\n schema: GenerativeUIJSONSchema,\n base: string,\n): GenerativeUIJSONSchema {\n return mapSchema(schema, (node) => {\n const ref = node.$ref;\n // \"#\" is the root of the embedded schema (a recursive one refers to it).\n if (ref === \"#\") return { ...node, $ref: base };\n if (typeof ref === \"string\" && ref.startsWith(\"#/\")) {\n return { ...node, $ref: `${base}${ref.slice(1)}` };\n }\n return node;\n });\n}\n\n/** Keywords whose value is a map from a name to a schema. */\nconst SCHEMA_MAP_KEYWORDS = new Set([\n \"properties\",\n \"patternProperties\",\n \"$defs\",\n \"definitions\",\n \"dependentSchemas\",\n]);\n\n/**\n * Walks a JSON Schema and rebuilds each schema node with `transform`, the\n * children first. The names in `properties` and the definition maps are\n * names, not keywords: a prop called `default` is a schema, while the\n * `default` of a schema is data and stays as it is.\n */\nfunction mapSchema(\n schema: GenerativeUIJSONSchema,\n transform: (node: Record<string, unknown>) => Record<string, unknown>,\n): GenerativeUIJSONSchema {\n const visitValue = (value: unknown): unknown => {\n if (Array.isArray(value)) return value.map(visitValue);\n return isRecord(value) ? visitNode(value) : value;\n };\n const visitNode = (\n node: Record<string, unknown>,\n ): Record<string, unknown> => {\n const result: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(node)) {\n if (LITERAL_KEYWORDS.has(key)) result[key] = value;\n else if (SCHEMA_MAP_KEYWORDS.has(key) && isRecord(value)) {\n result[key] = Object.fromEntries(\n Object.entries(value).map(([name, entry]) => [\n name,\n isRecord(entry) ? visitNode(entry) : entry,\n ]),\n );\n } else result[key] = visitValue(value);\n }\n return transform(result);\n };\n return visitNode(schema) as GenerativeUIJSONSchema;\n}\n\nconst isString = (value: unknown): value is string => typeof value === \"string\";\n\n/**\n * A prop as the catalog states it. A component reference stays one. Any\n * other value takes its literal schema, a data binding or a function call,\n * and so does every value inside it: the properties of an object, the\n * values of a record and the items of a list, because the renderer\n * resolves dynamic values at any depth. The variants of a union are\n * transformed in place.\n */\nfunction dynamicProp(schema: unknown): GenerativeUIJSONSchema {\n if (!isRecord(schema)) return { $ref: DYNAMIC_REFS.unknown };\n if (childRefKind(schema)) return schema;\n const { description, ...literal } = withDynamicChildren(schema);\n return {\n ...(typeof description === \"string\" ? { description } : {}),\n anyOf: [literal, { $ref: DATA_BINDING_REF }, { $ref: FUNCTION_CALL_REF }],\n };\n}\n\n/** The schema with its nested values made dynamic, itself unchanged. */\nfunction withDynamicChildren(\n schema: Record<string, unknown>,\n): Record<string, unknown> {\n const result = { ...schema };\n if (isRecord(schema.properties)) {\n result.properties = Object.fromEntries(\n Object.entries(schema.properties).map(([key, value]) => [\n key,\n dynamicProp(value),\n ]),\n );\n }\n if (isRecord(schema.items)) result.items = dynamicProp(schema.items);\n // A tuple, as the converter writes it; the catalog spells it prefixItems.\n if (Array.isArray(schema.items)) {\n result.items = schema.items.map((item) =>\n isRecord(item) ? dynamicProp(item) : item,\n );\n }\n if (isRecord(schema.additionalItems)) {\n result.additionalItems = dynamicProp(schema.additionalItems);\n }\n // The definitions a converter wrote: referenced from value positions.\n for (const key of [\"$defs\", \"definitions\"] as const) {\n const defs = schema[key];\n if (isRecord(defs)) {\n result[key] = Object.fromEntries(\n Object.entries(defs).map(([name, def]) => [\n name,\n isRecord(def) ? withDynamicChildren(def) : def,\n ]),\n );\n }\n }\n if (Array.isArray(schema.allOf)) {\n result.allOf = schema.allOf.map((part) =>\n isRecord(part) ? withDynamicChildren(part) : part,\n );\n }\n // The values of a record, by any key or by key pattern.\n if (isRecord(schema.additionalProperties)) {\n result.additionalProperties = dynamicProp(schema.additionalProperties);\n }\n if (isRecord(schema.patternProperties)) {\n result.patternProperties = Object.fromEntries(\n Object.entries(schema.patternProperties).map(([pattern, value]) => [\n pattern,\n dynamicProp(value),\n ]),\n );\n }\n for (const key of [\"anyOf\", \"oneOf\"] as const) {\n const variants = schema[key];\n if (Array.isArray(variants)) {\n result[key] = variants.map((variant) =>\n isRecord(variant) && !childRefKind(variant)\n ? withDynamicChildren(variant)\n : variant,\n );\n }\n }\n return result;\n}\n\n/**\n * The args of a declared function as the catalog states them: the object\n * stays an object, each arg takes a value, a binding or a function call.\n */\nfunction dynamicArgs(schema: GenerativeUIJSONSchema): GenerativeUIJSONSchema {\n return withDynamicChildren(schema);\n}\n\n/** One `functions` entry, in the A2UI `FunctionDefinition` shape. */\nfunction functionEntry(\n name: string,\n permissions: A2UIFunctionPermissions,\n parts: {\n description: string | undefined;\n returnType: string;\n args: GenerativeUIJSONSchema;\n },\n): GenerativeUIJSONSchema {\n const callers = functionCallers(permissions);\n const allowedCallers: A2UIAllowedCallers =\n callers.renderer && callers.agent\n ? \"rendererOrAgent\"\n : callers.agent\n ? \"agentOnly\"\n : \"rendererOnly\";\n // The metaschema's activation rule has no `required`, so it also matches\n // an entry without the key: the value is always written out.\n // `args` is required only when an arg is.\n const argsRequired = hasRequiredArgs(parts.args);\n return {\n type: \"object\",\n ...(parts.description ? { description: parts.description } : {}),\n returnType: parts.returnType,\n allowedCallers,\n requiresUserActivation: permissions.requiresUserActivation === true,\n properties: { \"@call\": { const: name }, args: parts.args },\n required: argsRequired ? [\"@call\", \"args\"] : [\"@call\"],\n };\n}\n\n/**\n * True when an empty args object fails the schema: a key is required at\n * its top, in an `allOf` part, or in every variant of an `anyOf` / `oneOf`.\n */\nfunction hasRequiredArgs(schema: unknown): boolean {\n if (!isRecord(schema)) return false;\n if (Array.isArray(schema.required) && schema.required.length > 0) return true;\n if (Array.isArray(schema.allOf) && schema.allOf.some(hasRequiredArgs)) {\n return true;\n }\n for (const key of [\"anyOf\", \"oneOf\"] as const) {\n const variants = schema[key];\n if (Array.isArray(variants) && variants.length > 0) {\n if (variants.every(hasRequiredArgs)) return true;\n }\n }\n return false;\n}\n\n/**\n * The JSON Schema of the args of a built-in function, from its short\n * TypeScript-like signature (`{ value: number; decimals?: number }`). Each\n * arg takes a literal, a binding or a function call, so a type maps to the\n * A2UI dynamic type; `[name: string]: T` becomes `additionalProperties`.\n *\n * @example\n * ```ts\n * argsSchemaFromSignature(\"{ value: string; min?: number }\");\n * // { type: \"object\", properties: { value: { $ref: \".../DynamicString\" }, min: { $ref: \".../DynamicNumber\" } }, required: [\"value\"], additionalProperties: false }\n * ```\n */\nexport function argsSchemaFromSignature(\n signature: string,\n): GenerativeUIJSONSchema {\n const body = signature.trim().replace(/^\\{/, \"\").replace(/\\}$/, \"\");\n const properties: Record<string, GenerativeUIJSONSchema> = {};\n const required: string[] = [];\n let additionalProperties: GenerativeUIJSONSchema | false = false;\n for (const part of body.split(\";\")) {\n const field = part.trim();\n if (field === \"\") continue;\n const index = field.match(/^\\[\\w+: string\\]:\\s*(.+)$/);\n if (index) {\n additionalProperties = typeSchema(index[1]);\n continue;\n }\n const named = field.match(/^(\\w+)(\\?)?:\\s*(.+)$/);\n if (!named) continue;\n properties[named[1]] = typeSchema(named[3]);\n if (!named[2]) required.push(named[1]);\n }\n return {\n type: \"object\",\n properties,\n ...(required.length > 0 ? { required } : {}),\n additionalProperties,\n };\n}\n\nfunction typeSchema(type: string): GenerativeUIJSONSchema {\n const trimmed = type.trim();\n const alternatives = trimmed.split(\"|\").map((part) => part.trim());\n if (alternatives.length > 1) return { anyOf: alternatives.map(typeSchema) };\n if (trimmed in DYNAMIC_REFS) return { $ref: DYNAMIC_REFS[trimmed] };\n if (trimmed.endsWith(\"[]\")) {\n // The whole list can be bound or computed, like any other arg.\n return {\n anyOf: [\n { type: \"array\", items: typeSchema(trimmed.slice(0, -2)) },\n { $ref: DATA_BINDING_REF },\n { $ref: FUNCTION_CALL_REF },\n ],\n };\n }\n return { $ref: DYNAMIC_REFS.unknown };\n}\n","import React, { useEffect, useLayoutEffect, useRef } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { GENERATIVE_UI_MAX_TARGET_COMPONENTS } from \"@copilotkit/shared\";\nimport type { GenerativeUI, GenerativeUIComponentName } from \"./catalog\";\nimport { useManagerVersion } from \"./hooks\";\nimport { useRequiredGenerativeUIRuntime } from \"./runtime-context\";\nimport { SurfaceView } from \"./SurfaceView\";\n\ninterface GenerativeUISurfaceBaseProps {\n /** Target id the agent renders into. */\n id: string;\n /**\n * Tells the model where this surface is and what to show in it, for\n * example \"Next to the product list. Use it for product recommendations.\"\n */\n description?: string;\n /** Shown until a surface targets this id. */\n fallback?: ReactNode;\n className?: string;\n /**\n * Scrolls the page to this surface when the agent starts to render into\n * it, unless the surface is already on screen. Defaults to `true`. With a\n * sticky header, give the surface a `scroll-margin-top`\n * (`[data-generative-ui-surface] { scroll-margin-top: 5rem }`).\n */\n autoScroll?: boolean;\n}\n\n/** Scrolls `element` into view, unless it is already fully on screen. */\nfunction scrollToSurface(element: HTMLElement) {\n const { top, bottom } = element.getBoundingClientRect();\n if (top >= 0 && bottom <= window.innerHeight) return;\n const reduceMotion = window.matchMedia?.(\n \"(prefers-reduced-motion: reduce)\",\n ).matches;\n // jsdom has no scrollIntoView.\n element.scrollIntoView?.({\n behavior: reduceMotion ? \"auto\" : \"smooth\",\n block: \"start\",\n });\n}\n\n/**\n * Props of {@link GenerativeUISurface}. `components` takes `ui`, which\n * types the component names.\n */\nexport type GenerativeUISurfaceProps<\n UI extends GenerativeUI<any> = GenerativeUI<any>,\n> = GenerativeUISurfaceBaseProps &\n (\n | {\n /**\n * The UI of the provider (`generativeUI.ui`). It types the names in\n * `components`.\n */\n ui: UI;\n /**\n * The only components that the agent can use in this surface, the\n * root included. The agent gets the list, and an operation with\n * another component is rejected. Left out, every component of the UI\n * is allowed.\n */\n components?: readonly GenerativeUIComponentName<UI>[];\n }\n | { ui?: undefined; components?: undefined }\n );\n\nconst isDevelopment = () => process.env.NODE_ENV !== \"production\";\n\n/**\n * The names of `requested` that `ui` has, without repeats, at most the\n * number that the envelope takes. `warning` tells what was dropped.\n */\nfunction allowedComponents(requested: readonly string[], ui: GenerativeUI) {\n const unique = [...new Set(requested)];\n const unknown = unique.filter((name) => !ui.components.has(name));\n const known = unique.filter((name) => ui.components.has(name));\n const names = known.slice(0, GENERATIVE_UI_MAX_TARGET_COMPONENTS);\n const problems: string[] = [];\n if (unknown.length > 0) {\n problems.push(\n `these components are not in the UI and are ignored: ${unknown.join(\", \")}`,\n );\n }\n if (known.length > names.length) {\n problems.push(\n `only the first ${GENERATIVE_UI_MAX_TARGET_COMPONENTS} components are used`,\n );\n }\n return { names, warning: problems.join(\"; \") };\n}\n\n/**\n * Experimental. A named place on the page where the agent can render UI.\n *\n * @example\n * ```tsx\n * <GenerativeUISurface\n * id=\"products\"\n * ui={storeUI}\n * description=\"The product list. Show the products that the user asks for.\"\n * components={[\"ProductRow\", \"ProductCard\"]}\n * fallback={<FeaturedProducts />}\n * />\n * ```\n */\nexport function GenerativeUISurface<\n UI extends GenerativeUI<any> = GenerativeUI<any>,\n>({\n id,\n description,\n ui,\n components,\n fallback = null,\n className,\n autoScroll = true,\n}: GenerativeUISurfaceProps<UI>) {\n const runtime = useRequiredGenerativeUIRuntime();\n useManagerVersion(runtime);\n // The agent renders only the components of the provider's UI, so the\n // names are checked against it. A different `ui` is a setup mistake.\n const otherUI = ui !== undefined && ui !== runtime.ui;\n useLayoutEffect(() => {\n if (otherUI && isDevelopment()) {\n console.warn(\n `[generativeUI] <GenerativeUISurface id=\"${id}\">: the ui prop is not the UI of the provider (generativeUI.ui). The components are checked against the UI of the provider.`,\n );\n }\n }, [otherUI, id]);\n // A new array with the same names must not register the target again.\n const componentsKey =\n components === undefined ? undefined : JSON.stringify(components);\n const warnedKey = useRef<string | undefined>(undefined);\n useLayoutEffect(() => {\n const requested: string[] | undefined =\n componentsKey === undefined ? undefined : JSON.parse(componentsKey);\n const allowed = requested && allowedComponents(requested, runtime.ui);\n const shouldWarn =\n allowed !== undefined &&\n allowed.warning !== \"\" &&\n warnedKey.current !== componentsKey &&\n isDevelopment();\n if (shouldWarn) {\n warnedKey.current = componentsKey;\n console.warn(\n `[generativeUI] <GenerativeUISurface id=\"${id}\">: ${allowed.warning}.`,\n );\n }\n return runtime.manager.registerTarget(id, {\n description,\n components: allowed?.names,\n });\n }, [runtime, id, description, componentsKey]);\n const surface = runtime.manager.getSurfaceForTarget(id);\n // Every render_ui call (and every streaming markdown fence) sets the\n // status to \"streaming\", for a new surface and for an update. The key is\n // set only while the surface streams, so each start runs the effect once.\n const generatingKey =\n surface?.status === \"streaming\" ? surface.key : undefined;\n const element = useRef<HTMLDivElement>(null);\n useEffect(() => {\n if (autoScroll && generatingKey && element.current) {\n scrollToSurface(element.current);\n }\n }, [autoScroll, generatingKey]);\n if (!surface) return <>{fallback}</>;\n return (\n <div ref={element} data-generative-ui-surface={id} className={className}>\n <SurfaceView surface={surface} />\n </div>\n );\n}\n","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","/**\n * Design tokens of the standard components. Each token is a CSS variable\n * with a literal fallback, so a host can restyle a surface with the\n * `--a2ui-*` variables. A value that is not a token passes through as raw\n * CSS.\n */\n\n/** Id of `standardUI`, the catalog id the model writes in createSurface. */\nexport const STANDARD_CATALOG_ID = \"copilotkit/standard@1\";\n\nexport const TITLE_SIZES = [\n \"sm\",\n \"md\",\n \"lg\",\n \"xl\",\n \"2xl\",\n \"3xl\",\n \"4xl\",\n \"5xl\",\n] as const;\nexport const TEXT_SIZES = [\"3xs\", \"2xs\", \"xs\", \"sm\", \"md\", \"lg\"] as const;\nexport const WEIGHTS = [\"normal\", \"medium\", \"semibold\", \"bold\"] as const;\nexport const ALIGN = [\"start\", \"center\", \"end\", \"baseline\", \"stretch\"] as const;\nexport const JUSTIFY = [\n \"start\",\n \"center\",\n \"end\",\n \"spaceBetween\",\n \"spaceAround\",\n \"spaceEvenly\",\n \"stretch\",\n] as const;\nexport const WRAP = [\"nowrap\", \"wrap\", \"wrap-reverse\"] as const;\nexport const RADII = [\n \"2xs\",\n \"xs\",\n \"sm\",\n \"md\",\n \"lg\",\n \"xl\",\n \"2xl\",\n \"3xl\",\n \"4xl\",\n \"full\",\n] as const;\nexport const TEXT_COLORS = [\n \"default\",\n \"prose\",\n \"primary\",\n \"emphasis\",\n \"secondary\",\n \"tertiary\",\n \"success\",\n \"info\",\n \"warning\",\n \"caution\",\n \"danger\",\n \"discovery\",\n] as const;\nexport const BORDER_COLORS = [\n \"default\",\n \"subtle\",\n \"strong\",\n \"info\",\n \"warning\",\n \"caution\",\n \"success\",\n \"danger\",\n \"discovery\",\n] as const;\nexport const BACKGROUNDS = [\n \"surface\",\n \"surface-secondary\",\n \"surface-tertiary\",\n \"surface-elevated\",\n \"surface-elevated-secondary\",\n \"surface-inverted\",\n \"surface-soft\",\n \"info\",\n \"warning\",\n \"caution\",\n \"success\",\n \"danger\",\n \"discovery\",\n \"info-solid\",\n \"warning-solid\",\n \"caution-solid\",\n \"success-solid\",\n \"danger-solid\",\n \"discovery-solid\",\n] as const;\n\nexport type TitleSize = (typeof TITLE_SIZES)[number];\nexport type TextSize = (typeof TEXT_SIZES)[number];\nexport type Weight = (typeof WEIGHTS)[number];\nexport type Radius = (typeof RADII)[number];\n\nconst RADIUS_PX: Record<Radius, string> = {\n \"2xs\": \"2px\",\n xs: \"4px\",\n sm: \"6px\",\n md: \"8px\",\n lg: \"12px\",\n xl: \"16px\",\n \"2xl\": \"20px\",\n \"3xl\": \"24px\",\n \"4xl\": \"32px\",\n full: \"9999px\",\n};\nconst TEXT_COLOR_FALLBACK: Record<string, string> = {\n default: \"#0d0d0d\",\n prose: \"#0d0d0d\",\n primary: \"#0d0d0d\",\n emphasis: \"#000\",\n secondary: \"#5d5d5d\",\n tertiary: \"#8e8e8e\",\n success: \"#00805d\",\n info: \"#0068bc\",\n warning: \"#946200\",\n caution: \"#946200\",\n danger: \"#c1322c\",\n discovery: \"#7040c1\",\n};\nconst BG_FALLBACK: Record<string, string> = {\n surface: \"#fff\",\n \"surface-secondary\": \"#f7f7f8\",\n \"surface-tertiary\": \"#ececec\",\n \"surface-elevated\": \"#fff\",\n \"surface-elevated-secondary\": \"#f7f7f8\",\n \"surface-inverted\": \"#0d0d0d\",\n \"surface-soft\": \"#fcfcfc\",\n // A semantic tint is a hint, not a block: the text color at low alpha.\n info: \"rgba(0, 104, 188, 0.08)\",\n warning: \"rgba(148, 98, 0, 0.08)\",\n caution: \"rgba(148, 98, 0, 0.08)\",\n success: \"rgba(0, 128, 93, 0.08)\",\n danger: \"rgba(193, 50, 44, 0.08)\",\n discovery: \"rgba(112, 64, 193, 0.08)\",\n \"info-solid\": \"#0068bc\",\n \"warning-solid\": \"#946200\",\n \"caution-solid\": \"#946200\",\n \"success-solid\": \"#00805d\",\n \"danger-solid\": \"#c1322c\",\n \"discovery-solid\": \"#7040c1\",\n};\nconst BORDER_FALLBACK: Record<string, string> = {\n default: \"rgba(0, 0, 0, 0.1)\",\n subtle: \"rgba(0, 0, 0, 0.05)\",\n strong: \"#cdcdcd\",\n info: \"#9cc4ea\",\n warning: \"#e6c98a\",\n caution: \"#e6c98a\",\n success: \"#9ad9c3\",\n danger: \"#eeaaa6\",\n discovery: \"#c8b4ea\",\n};\n\nfunction hasToken<Key extends string>(\n table: Record<Key, string>,\n key: string,\n): key is Key {\n return Object.hasOwn(table, key);\n}\n\n/** A number is a count of 4px steps. A string passes through as CSS. */\nexport function spacing(value: number | string | undefined) {\n if (value === undefined) return undefined;\n return typeof value === \"number\"\n ? `calc(var(--spacing, 0.25rem) * ${value})`\n : value;\n}\n\n/** A radius token, a number of pixels, or raw CSS. */\nexport function radius(value: string | number | undefined) {\n if (value === undefined) return undefined;\n if (typeof value === \"number\") return `${value}px`;\n if (value === \"full\") return \"9999px\";\n return hasToken(RADIUS_PX, value)\n ? `var(--a2ui-radius-${value}, ${RADIUS_PX[value]})`\n : value;\n}\n\n/** A text color token, or a raw CSS color. */\nexport function textColor(value: string | undefined) {\n if (!value) return undefined;\n return hasToken(TEXT_COLOR_FALLBACK, value)\n ? `var(--a2ui-color-text-${value}, ${TEXT_COLOR_FALLBACK[value]})`\n : value;\n}\n\n/** A background token, or a raw CSS color. */\nexport function backgroundColor(value: string | undefined) {\n if (!value) return undefined;\n return hasToken(BG_FALLBACK, value)\n ? `var(--a2ui-color-${value}, ${BG_FALLBACK[value]})`\n : value;\n}\n\n/** The one inner panel of a Card: near-white fill. */\nexport const INNER_PANEL_BG = \"var(--a2ui-color-panel, rgb(252, 252, 252))\";\nconst SOFT_TINT: Record<string, string> = {\n info: \"rgba(0, 104, 188, 0.06)\",\n warning: \"rgba(148, 98, 0, 0.06)\",\n caution: \"rgba(148, 98, 0, 0.06)\",\n success: \"rgba(0, 128, 93, 0.06)\",\n danger: \"rgba(193, 50, 44, 0.06)\",\n discovery: \"rgba(112, 64, 193, 0.06)\",\n};\n\n/**\n * The background of a panel inside a Card. A neutral surface becomes the\n * near-white inner panel. A semantic tint gets lighter (about 6% alpha).\n * Solid and raw values go through `backgroundColor`.\n */\nexport function panelBackground(value: string | undefined) {\n if (!value) return undefined;\n const isNeutral =\n value === \"surface-secondary\" ||\n value === \"surface-soft\" ||\n value === \"surface-elevated-secondary\";\n if (isNeutral) return INNER_PANEL_BG;\n return hasToken(SOFT_TINT, value)\n ? `var(--a2ui-color-${value}-soft, ${SOFT_TINT[value]})`\n : backgroundColor(value);\n}\n\n/** A border color token, or a raw CSS color. */\nexport function borderColor(value: string | undefined) {\n if (!value) return undefined;\n return hasToken(BORDER_FALLBACK, value)\n ? `var(--a2ui-color-border-${value}, ${BORDER_FALLBACK[value]})`\n : value;\n}\n\n/**\n * The type scale at a 16px base, in em, so a surface scales with the font\n * size of the host: title lg = 18/28, 2xl = 24/32; text md = 16/26,\n * sm = 14/20, xs = 12/16, 3xs = 10/12. Line heights are unitless ratios.\n */\nconst TITLE_SCALE: Record<TitleSize, [string, number]> = {\n sm: [\".875em\", 1.429],\n md: [\"1em\", 1.5],\n lg: [\"1.125em\", 1.556],\n xl: [\"1.25em\", 1.4],\n \"2xl\": [\"1.5em\", 1.333],\n \"3xl\": [\"1.875em\", 1.2],\n \"4xl\": [\"2.25em\", 1.111],\n \"5xl\": [\"3em\", 1.083],\n};\nconst TEXT_SCALE: Record<TextSize, [string, number]> = {\n \"3xs\": [\".625em\", 1.2],\n \"2xs\": [\".6875em\", 1.273],\n xs: [\".75em\", 1.333],\n sm: [\".875em\", 1.429],\n md: [\"1em\", 1.625],\n lg: [\"1.125em\", 1.556],\n};\n\n/** Text on an accent fill (solid buttons and badges, selected segments). */\nexport const ON_ACCENT = \"var(--a2ui-color-on-accent, #fff)\";\n/** The fill of a control (checkbox, radio, slider thumb, selected segment). */\nexport const CONTROL_BG = \"var(--a2ui-color-control, #fff)\";\nexport const SHADOW_XS = \"var(--a2ui-shadow-xs, 0 1px 2px rgba(0,0,0,.12))\";\nexport const SHADOW_SM = \"var(--a2ui-shadow-sm, 0 1px 3px rgba(0,0,0,.12))\";\nexport const SHADOW_SOFT = \"var(--a2ui-shadow-soft, 0 1px 3px rgba(0,0,0,.06))\";\nexport const SHADOW_MD = \"var(--a2ui-shadow-md, 0 4px 12px rgba(0,0,0,.08))\";\n/** The scrim behind a lightbox or modal. */\nexport const BACKDROP = \"var(--a2ui-color-backdrop, rgba(0,0,0,.8))\";\n/** The moving highlight of a shimmer placeholder. */\nexport const SHIMMER_HIGHLIGHT =\n \"var(--a2ui-color-shimmer, rgba(255,255,255,.55))\";\n/** The hover band behind a chart column. */\nexport const CHART_CURSOR = \"var(--a2ui-color-chart-cursor, rgba(0,0,0,.04))\";\n/**\n * Chart series colors: a soft blue family first, then muted companions, so\n * a chart with many series stays easy to read. A host can change each one\n * with `--a2ui-chart-1`, `--a2ui-chart-2`, and so on.\n */\nconst CHART_PALETTE_FALLBACK = [\n \"#7fb0f2\",\n \"#2f6fd1\",\n \"#b7cff7\",\n \"#8bb5a8\",\n \"#d9b36b\",\n \"#c08bb0\",\n];\nexport const CHART_PALETTE = CHART_PALETTE_FALLBACK.map(\n (hex, index) => `var(--a2ui-chart-${index + 1}, ${hex})`,\n);\n\n/**\n * A UI font stack. A surface inherits the font of the host. This value is\n * for hosts that want it (`font-family: var(--a2ui-font-family, ...)`).\n */\nexport const FONT_FAMILY =\n 'var(--a2ui-font-family, -apple-system, ui-sans-serif, system-ui, \"Segoe UI\", Helvetica, \"Apple Color Emoji\", Arial, sans-serif, \"Segoe UI Emoji\", \"Segoe UI Symbol\")';\n\n/** The heading scale in em. */\nexport function titleFont(size: TitleSize = \"md\") {\n const [fontSize, lineHeight] = TITLE_SCALE[size];\n return { fontSize, lineHeight, fontWeight: 600 };\n}\n\n/** The body text size, in em of the text around it. */\nexport function textFont(size: TextSize = \"md\") {\n const [fontSize, lineHeight] = TEXT_SCALE[size];\n return { fontSize, lineHeight };\n}\n\nexport const FONT_WEIGHT: Record<Weight, number> = {\n normal: 400,\n medium: 500,\n semibold: 600,\n bold: 700,\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 { BACKDROP, ON_ACCENT, SHADOW_MD, radius } from \"./tokens\";\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 { DARK_THEME_CSS } from \"../theme\";\nimport { borderColor, textColor, CONTROL_BG, SHADOW_XS } from \"./tokens\";\n\n/**\n * The stylesheet for what inline styles cannot do: pseudo-elements (slider\n * track and thumb, placeholder), `:checked` and `:first-child` states,\n * heading fallbacks, and resets for host prose styles. It is added once per\n * document.\n *\n * Typography is inherited: a surface takes the font, size, line height and\n * color of the text around it (the chat prose). Headings take the heading\n * styles of the host.\n */\n\nexport const STANDARD_STYLE_ID = \"a2ui-standard-catalog\";\nexport const ACCENT = \"var(--a2ui-color-accent, #0d0d0d)\";\n\nconst FOCUS_RING = \"2px solid var(--a2ui-color-focus, #0285ff)\";\n\nconst CHECK_SVG =\n \"url(\\\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E\\\")\";\n\nconst SLIDER_TRACK = \"var(--a2ui-color-slider-track, rgba(0, 0, 0, 0.04))\";\nconst THUMB = `width:20px;height:20px;box-sizing:border-box;border-radius:9999px;background:${CONTROL_BG};border:1px solid ${borderColor(\"default\")};box-shadow:${SHADOW_XS};cursor:pointer`;\n\nexport const STANDARD_CSS = [\n // The built-in dark values, under a `.dark` class. Every theme rule wins\n // over them.\n DARK_THEME_CSS,\n // The surface (and its root component) never gets wider than the chat column.\n \".a2ui-surface{min-width:0;max-width:100%;box-sizing:border-box}\",\n // The surface inherits the font, size, line height and ink of the host.\n \".a2ui-surface{font:inherit;color:inherit}\",\n // Heading sizes only for hosts without heading styles (zero specificity).\n \":where(.a2ui-surface) :where(h2){font-size:1.5em;font-weight:600;line-height:1.3}\",\n \":where(.a2ui-surface) :where(h3){font-size:1.25em;font-weight:600;line-height:1.3}\",\n \":where(.a2ui-surface) :where(h4){font-size:1em;font-weight:600;line-height:1.4}\",\n // Controls never fall back to the UA font.\n \"[data-a2ui-std] :is(button,input,select,textarea),[data-a2ui-input]{font:inherit;color:inherit}\",\n // Key/value rows: the last text of a space-between row sits flush right.\n '[data-a2ui-row=\"spaceBetween\"]>[data-a2ui-text]:last-child:not(:first-child){text-align:right;margin-inline-start:auto}',\n `[data-a2ui-input]:focus-visible{outline:${FOCUS_RING};outline-offset:1px}`,\n // A scrollable container can take keyboard focus, so it shows a focus ring.\n `[data-a2ui-scroll]:focus-visible{outline:${FOCUS_RING};outline-offset:2px}`,\n `[data-a2ui-input]::placeholder{color:${textColor(\"tertiary\")};opacity:1}`,\n // Slider: 24px pill track, 2px inset white thumb (no filled range).\n `.a2ui-std-range{-webkit-appearance:none;appearance:none;display:block;width:100%;height:24px;margin:0;padding:0 2px;box-sizing:border-box;border-radius:9999px;background:${SLIDER_TRACK};cursor:pointer}`,\n \".a2ui-std-range:disabled{cursor:not-allowed;opacity:.5}\",\n \".a2ui-std-range::-webkit-slider-runnable-track{height:24px;background:transparent;border:0}\",\n `.a2ui-std-range::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;margin-top:2px;${THUMB}}`,\n \".a2ui-std-range::-moz-range-track{height:24px;background:transparent;border:0}\",\n `.a2ui-std-range::-moz-range-thumb{${THUMB}}`,\n // Checkbox and radio: 20px round control, filled when checked.\n `.a2ui-std-check{-webkit-appearance:none;appearance:none;flex-shrink:0;width:20px;height:20px;margin:0;box-sizing:border-box;border:1px solid ${borderColor(\"strong\")};border-radius:9999px;background:${CONTROL_BG} center/14px 14px no-repeat;cursor:pointer}`,\n '.a2ui-std-check[data-shape=\"square\"]{border-radius:6px}',\n `.a2ui-std-check:checked{background-color:${ACCENT};border-color:${ACCENT};background-image:${CHECK_SVG}}`,\n `.a2ui-std-check[type=\"radio\"]:checked{background-image:none;background-color:${CONTROL_BG};border:6px solid ${ACCENT}}`,\n \".a2ui-std-check:disabled{cursor:not-allowed}\",\n // Hosts often wrap chat markdown in a \"prose\" stylesheet (Tailwind\n // typography) that adds margins to headings, paragraphs, lists and tables.\n // A surface is an app panel spaced by gaps, so these rules remove those\n // margins. A Markdown component keeps them, because it reads like the chat\n // prose. The selector must be stronger than `.prose :where(h2)`. Hosts\n // change the margins with `--a2ui-heading-margin` and `--a2ui-block-margin`.\n \".a2ui-surface :is(h1,h2,h3,h4,h5,h6):not(.a2ui-markdown *){margin:var(--a2ui-heading-margin,0)}\",\n \".a2ui-surface :is(p,table,figure,figcaption,blockquote,pre):not(.a2ui-markdown *){margin:var(--a2ui-block-margin,0)}\",\n \".a2ui-markdown>:first-child{margin-top:0}\",\n \".a2ui-markdown>:last-child{margin-bottom:0}\",\n // Only the List component removes native bullets. Markdown keeps them.\n \".a2ui-surface :is(.a2ui-std-list,.a2ui-std-list>li){margin:0}\",\n \".a2ui-surface .a2ui-std-table{font-size:inherit;line-height:inherit}\",\n // Table: 8px cells, flush outer edges, hairline row dividers, no outer border.\n \".a2ui-std-table-wrap{width:100%;max-width:100%;min-width:0;overflow-x:auto}\",\n \".a2ui-std-cell{padding:8px}\",\n \".a2ui-std-cell:first-child{padding-inline-start:0}\",\n \".a2ui-std-cell:last-child{padding-inline-end:0}\",\n `.a2ui-std-cell[data-divider]{border-bottom:1px solid ${borderColor(\"subtle\")}}`,\n \".a2ui-std-table>tbody:last-child>tr:last-child>.a2ui-std-cell{border-bottom:0}\",\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/**\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, {\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 { z } from \"zod\";\nimport type { GenerativeUIInvokeResult } from \"../errors\";\nimport { child } from \"../refs\";\nimport { Lightbox, openUrl } from \"./lightbox\";\nimport type { LightboxImage } from \"./lightbox\";\nimport {\n ALIGN,\n BACKGROUNDS,\n BORDER_COLORS,\n INNER_PANEL_BG,\n JUSTIFY,\n RADII,\n SHADOW_MD,\n SHADOW_SM,\n SHADOW_SOFT,\n WRAP,\n backgroundColor,\n borderColor,\n panelBackground,\n radius,\n spacing,\n textColor,\n} from \"./tokens\";\nimport { namedRole, useGenerativeUIAccessibility } from \"../accessibility\";\nimport { useStandardStyles } from \"./styles\";\n\n// ---- Shared schemas ----\n\n/** A number is a count of 4px steps. A string is raw CSS. */\nexport const sizeValue = z.union([z.number(), z.string()]);\n\n/** The A2UI `weight`: how much of the free space of a Row or Column to take. */\nexport const weightProp = z\n .number()\n .optional()\n .describe(\"flex-grow in a Row or Column\");\n\nexport const radiusValue = z.union([\n z.enum(RADII),\n z.number(),\n z.string(),\n z.object({\n topLeft: z.string().optional(),\n topRight: z.string().optional(),\n bottomLeft: z.string().optional(),\n bottomRight: z.string().optional(),\n }),\n]);\n\n/**\n * The layout props of every container. Spread them into a props schema:\n * `z.object({ ...layoutProps, variant: ... })`. The children of a container\n * are a slot, not a prop.\n */\nexport const layoutProps = {\n align: z.enum(ALIGN).optional(),\n justify: z.enum(JUSTIFY).optional(),\n wrap: z.enum(WRAP).optional(),\n gap: sizeValue.optional().describe(\"4px steps when a number\"),\n rowGap: sizeValue.optional(),\n columnGap: sizeValue.optional(),\n padding: sizeValue.optional().describe(\"4px steps when a number\"),\n background: z\n .string()\n .optional()\n .describe(\n `One of ${BACKGROUNDS.join(\"|\")} or a CSS color. Leave it unset. Only one summary panel in a Card can use \"surface-secondary\"`,\n ),\n border: z.boolean().optional(),\n borderColor: z.enum(BORDER_COLORS).optional(),\n radius: radiusValue.optional(),\n width: sizeValue.optional(),\n height: sizeValue.optional(),\n minWidth: sizeValue.optional(),\n maxWidth: sizeValue.optional(),\n minHeight: sizeValue.optional(),\n maxHeight: sizeValue.optional(),\n flex: z.number().optional(),\n weight: weightProp,\n aspectRatio: z.string().optional(),\n scrollable: z.boolean().optional(),\n clip: z.boolean().optional(),\n shadow: z.boolean().optional(),\n inline: z.boolean().optional(),\n role: z.string().optional().describe(\"ARIA role\"),\n flush: z.boolean().optional().describe(\"No padding\"),\n minSize: sizeValue.optional().describe(\"Minimum width and height\"),\n maxSize: sizeValue.optional().describe(\"Maximum width and height\"),\n disableAutoSpacing: z\n .boolean()\n .optional()\n .describe(\"No default gap between children\"),\n};\n\nconst layoutSchema = z.object(layoutProps);\n\n/** The arguments of a click or visibility event: none. */\nconst NO_ARGS = z.object({});\n\ntype EventProp = (\n args: z.input<typeof NO_ARGS>,\n) => Promise<GenerativeUIInvokeResult>;\n\n/**\n * The `onVisible` event of every container: sent once, the first time the\n * container scrolls into view.\n */\nexport const VISIBLE_EVENT = {\n onVisible: {\n description:\n \"Sent once, the first time the container scrolls into view. Use it to load more content lazily.\",\n parameters: NO_ARGS,\n },\n} as const;\n\ntype WithEvents<Props> = Props & { onVisible?: EventProp };\n\nexport type LayoutProps = z.output<typeof layoutSchema>;\n\n/** The slot of every container: a list of children or a template. */\nexport const CHILDREN_SLOT = { children: \"multiple\" } as const;\n\ntype WithChildren<Props> = WithEvents<Props> & { children?: ReactNode };\n\nconst boxSchema = z.object({\n ...layoutProps,\n direction: z.enum([\"col\", \"row\"]).optional().describe('Default \"col\"'),\n});\nconst gridSchema = z.object({\n ...layoutProps,\n columns: z\n .union([z.number(), z.string()])\n .optional()\n .describe(\"Column count or CSS template. Default 2\"),\n minChildWidth: sizeValue.optional(),\n rows: z.union([z.number(), z.string()]).optional(),\n});\nconst gridItemSchema = z.object({\n ...layoutProps,\n span: z.number().optional(),\n rowSpan: z.number().optional(),\n});\nconst cardSchema = z.object({\n ...layoutProps,\n variant: z\n .enum([\"default\", \"outline\", \"section\", \"soft\", \"elevated\", \"transparent\"])\n .optional(),\n shadowStyle: z\n .enum([\"none\", \"sm\", \"md\"])\n .optional()\n .describe(\"Overrides the shadow of the variant\"),\n size: z\n .enum([\"sm\", \"md\", \"lg\"])\n .optional()\n .describe('The padding preset: 8, 16 or 24px. Default \"md\"'),\n});\nconst flowSchema = z.object({\n ...layoutProps,\n columns: z.number().optional(),\n rows: z.number().optional(),\n layout: z.enum([\"pack\", \"fixed\"]).optional().describe('Default \"pack\"'),\n});\nconst flowItemSchema = z.object({\n ...layoutProps,\n span: z.number().optional(),\n rowSpan: z.number().optional(),\n aspectRatio: z.string().optional().describe('Default \"1 / 1\"'),\n aspectMode: z.enum([\"soft\", \"fixed\"]).optional(),\n});\nconst carouselSchema = z.object({\n ...layoutProps,\n label: z\n .string()\n .optional()\n .describe(\"A short name of the carousel for screen readers\"),\n visibleItems: z.number().optional(),\n showArrows: z.boolean().optional().describe(\"Default true\"),\n activeIndex: z\n .number()\n .optional()\n .describe(\n 'The index of the slide in view. Bind it with { \"@path\": \"/x\" } to read or set it',\n ),\n previousLabel: z.string().optional().describe('Default \"Previous\"'),\n nextLabel: z.string().optional().describe('Default \"Next\"'),\n snap: z.enum([\"none\", \"proximity\", \"mandatory\"]).optional(),\n snapAlign: z.enum([\"start\", \"center\", \"end\"]).optional(),\n});\nconst CAROUSEL_MEDIA_SIZES = [\"sm\", \"md\", \"lg\"] as const;\nconst carouselMediaItemSchema = z.object({\n ...layoutProps,\n url: z.string().describe(\"Image URL\"),\n description: z\n .string()\n .optional()\n .describe(\"What the image shows, for screen readers\"),\n size: z\n .enum(CAROUSEL_MEDIA_SIZES)\n .optional()\n .describe('The width: \"sm\" 160px, \"md\" 240px, \"lg\" 320px. Default \"md\"'),\n aspectRatio: z.string().optional().describe('Default \"4 / 3\"'),\n href: z.string().optional().describe(\"Opens this URL in a new tab\"),\n lightbox: z\n .boolean()\n .optional()\n .describe(\"Default true: a click opens all slides full-screen\"),\n});\nconst spacerSchema = z.object({ minSize: sizeValue.optional() });\nconst tabsSchema = z.object({\n tabs: z\n .array(\n z.object({\n title: z.string().describe(\"The tab title\"),\n child: child(\"The id of the panel component\"),\n }),\n )\n .describe(\"One entry per tab\"),\n selectedIndex: z\n .number()\n .optional()\n .describe(\n 'The open tab. Default 0. Bind it with { \"@path\": \"/x\" } to read it',\n ),\n weight: weightProp,\n});\nconst dividerSchema = z.object({\n axis: z\n .enum([\"horizontal\", \"vertical\"])\n .optional()\n .describe('Default \"horizontal\"'),\n weight: weightProp,\n color: z.enum(BORDER_COLORS).optional(),\n size: z.number().optional(),\n spacing: sizeValue.optional(),\n flush: z.boolean().optional(),\n});\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 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 = z.output<typeof tabsSchema> & {\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 = {\n Box: {\n component: Box,\n description:\n 'A flex container. It stacks its children in a column (direction \"row\" puts them in a row). Use it to group children with gap, padding, border, radius or background.',\n props: boxSchema,\n events: VISIBLE_EVENT,\n slots: CHILDREN_SLOT,\n },\n Column: {\n component: Column,\n description:\n \"A vertical flex container. Its default gap already separates sections, so do not add padding, background or a Spacer for space.\",\n props: layoutSchema,\n events: VISIBLE_EVENT,\n slots: CHILDREN_SLOT,\n },\n Row: {\n component: Row,\n description:\n 'A horizontal flex container. For a label and value pair, use a Row with justify \"spaceBetween\": a Caption on the left and a Text with fontWeight \"medium\" on the right. Put buttons in a Row at the bottom of a Card: one Button with variant \"primary\", and the default or \"borderless\" for the others.',\n props: layoutSchema,\n events: VISIBLE_EVENT,\n slots: CHILDREN_SLOT,\n },\n Grid: {\n component: Grid,\n description:\n \"A CSS grid container. On a narrow screen, its columns collapse towards one column.\",\n props: gridSchema,\n events: VISIBLE_EVENT,\n slots: CHILDREN_SLOT,\n },\n GridItem: {\n component: GridItem,\n description:\n \"A cell of a Grid, with an optional span. A span that covers all rendered columns fills the row.\",\n props: gridItemSchema,\n events: VISIBLE_EVENT,\n slots: CHILDREN_SLOT,\n },\n Card: {\n component: Card,\n description:\n 'A bordered, padded container, only for an interactive panel (controls, a form, a configurator). Tables, charts and text do not need one. Give it a Title and a Caption. Separate the groups in it with a Divider or the plain gap, never with a nested Card or a bordered Box. Variant \"section\" is a heading and content without a box. Variant \"outline\" always has a box. In markdown mode, a Card without controls renders as \"section\" unless it sets variant or border.',\n props: cardSchema,\n events: VISIBLE_EVENT,\n slots: { child: \"single\", children: \"multiple\" } as const,\n },\n Flow: {\n component: Flow,\n description:\n \"A masonry-like grid that packs cells of different sizes. Put FlowItem children in it.\",\n props: flowSchema,\n events: VISIBLE_EVENT,\n slots: CHILDREN_SLOT,\n },\n FlowItem: {\n component: FlowItem,\n description: \"A cell of a Flow, with an optional span.\",\n props: flowItemSchema,\n events: VISIBLE_EVENT,\n slots: CHILDREN_SLOT,\n },\n Carousel: {\n component: Carousel,\n description:\n 'A row that scrolls horizontally and snaps to its slides, with previous and next arrows. Put CarouselItem or CarouselMediaItem children in it. Bind activeIndex with { \"@path\": \"/x\" } to read or set the slide in view.',\n props: carouselSchema,\n events: VISIBLE_EVENT,\n slots: CHILDREN_SLOT,\n writable: [\"activeIndex\"] as const,\n },\n CarouselItem: {\n component: CarouselItem,\n description: \"A slide of a Carousel.\",\n props: layoutSchema,\n events: VISIBLE_EVENT,\n slots: CHILDREN_SLOT,\n },\n CarouselMediaItem: {\n component: CarouselMediaItem,\n description:\n 'A slide of a Carousel with an image on top and its children (a Caption, a Text) under it. size \"sm\" is 160px, \"md\" 240px (default), \"lg\" 320px wide. A click on the image opens all slides full-screen, unless href or onClick is set.',\n props: carouselMediaItemSchema,\n events: {\n ...VISIBLE_EVENT,\n onClick: {\n description:\n \"Sent when the user clicks the image. It replaces the full-screen view.\",\n parameters: NO_ARGS,\n },\n },\n slots: CHILDREN_SLOT,\n },\n Spacer: {\n component: Spacer,\n description:\n \"Flexible empty space. You almost never need it: use the default gap.\",\n props: spacerSchema,\n },\n Divider: {\n component: Divider,\n description:\n 'A line between two groups: horizontal, or vertical with axis \"vertical\" in a Row.',\n props: dividerSchema,\n },\n Tabs: {\n component: Tabs,\n description:\n 'Tabs that show one panel at a time. Each tab has a title and the id of its panel component: \"tabs\":[{\"title\":\"Specs\",\"child\":\"specs\"}].',\n props: tabsSchema,\n writable: [\"selectedIndex\"] as const,\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 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, { useEffect, useState } from \"react\";\nimport type { CSSProperties } from \"react\";\nimport type { LucideIcon as LucideComponent } from \"lucide-react\";\nimport { z } from \"zod\";\nimport {\n controlAria,\n useGenerativeUIAccessibility,\n wrapperAria,\n} from \"../accessibility\";\nimport type { GenerativeUIInvokeResult } from \"../errors\";\nimport { radiusStyle, radiusValue, sizeValue, weightProp } from \"./layout\";\nimport { Lightbox, openUrl } from \"./lightbox\";\nimport {\n ON_ACCENT,\n WEIGHTS,\n backgroundColor,\n borderColor,\n radius,\n spacing,\n textColor,\n} from \"./tokens\";\nimport type { Weight } from \"./tokens\";\n\nconst NO_ARGS = z.object({});\ntype EventProp = (\n args: z.input<typeof NO_ARGS>,\n) => Promise<GenerativeUIInvokeResult>;\n\n// ---- Schemas ----\n\nconst colorProp = z.string().optional();\n\nexport const ICON_SIZES = [\"sm\", \"md\", \"lg\", \"xl\"] as const;\nexport type IconSize = (typeof ICON_SIZES)[number] | number;\n\nconst IMAGE_VARIANTS = [\n \"icon\",\n \"avatar\",\n \"smallFeature\",\n \"mediumFeature\",\n \"largeFeature\",\n \"header\",\n] as const;\nconst imageSchema = z.object({\n url: z.string().describe(\"Image URL\"),\n description: z\n .string()\n .optional()\n .describe(\n \"What the image shows, for screen readers. Leave it unset only for a decorative image\",\n ),\n variant: z\n .enum(IMAGE_VARIANTS)\n .optional()\n .describe(\n 'The size: \"icon\" 24px, \"avatar\" 40px round, \"smallFeature\" 160px wide, \"largeFeature\" and \"header\" full width. Default \"mediumFeature\": the natural size',\n ),\n weight: weightProp,\n aspectRatio: z.string().optional(),\n fit: z\n .enum([\"cover\", \"contain\", \"fill\", \"none\", \"scaleDown\"])\n .optional()\n .describe('CSS object-fit. Default \"cover\"'),\n radius: radiusValue.optional(),\n width: sizeValue.optional(),\n height: sizeValue.optional(),\n maxWidth: sizeValue.optional(),\n maxHeight: sizeValue.optional(),\n minWidth: sizeValue.optional(),\n minHeight: sizeValue.optional(),\n background: z.string().optional(),\n frame: z.boolean().optional(),\n position: z\n .string()\n .optional()\n .describe('CSS object-position, for example \"top\" or \"50% 20%\"'),\n hideOnFailure: z.boolean().optional().describe(\"Default false\"),\n fallback: z\n .string()\n .optional()\n .describe(\"Text shown in place of the image when it does not load\"),\n hoverZoom: z.boolean().optional().describe(\"A slight zoom on hover\"),\n lightbox: z\n .boolean()\n .optional()\n .describe(\"Default true: a click opens the image full-screen\"),\n actionOverlay: z\n .object({\n label: z.string(),\n icon: z.string().optional().describe(\"Lucide icon name\"),\n href: z.string().optional().describe(\"Opens this URL in a new tab\"),\n })\n .optional()\n .describe(\n \"A button over the bottom-right corner of the image. Without href, it sends onOverlayClick\",\n ),\n});\nconst iconSchema = z.object({\n name: z\n .union([z.string(), z.object({ svgPath: z.string() })])\n .describe(\n 'A Lucide icon name in kebab-case (\"arrow-right\"), an A2UI icon name (\"arrowBack\"), or { \"svgPath\" } on a 24px grid',\n ),\n label: z\n .string()\n .optional()\n .describe(\n \"What the icon means, for screen readers. Leave it unset when text next to the icon says the same\",\n ),\n size: z\n .union([z.enum(ICON_SIZES), z.number()])\n .optional()\n .describe('Default \"md\"'),\n color: colorProp,\n inline: z.boolean().optional().describe(\"Default false\"),\n strokeWeight: z.enum(WEIGHTS).optional().describe(\"The stroke width\"),\n weight: weightProp,\n});\nconst faviconSchema = z.object({\n url: z.string(),\n alt: z.string().optional(),\n size: z.number().optional().describe(\"Pixels. Default 16\"),\n inline: z.boolean().optional().describe(\"Default false\"),\n frame: z.boolean().optional().describe(\"Default false\"),\n});\nconst svgSchema = z.object({\n viewBox: z.string().optional(),\n label: z\n .string()\n .optional()\n .describe(\n \"What the drawing shows, for screen readers. Leave it unset for a decorative drawing\",\n ),\n width: sizeValue.optional(),\n height: sizeValue.optional(),\n size: sizeValue.optional(),\n color: colorProp.describe('Default \"prose\"'),\n fill: colorProp.describe('Default \"currentColor\"'),\n stroke: colorProp,\n strokeWidth: z.number().optional(),\n strokeLinecap: z.enum([\"butt\", \"round\", \"square\"]).optional(),\n strokeLinejoin: z.enum([\"miter\", \"round\", \"bevel\"]).optional(),\n preserveAspectRatio: z.string().optional(),\n paths: z\n .array(\n z.object({\n d: z.string(),\n fill: colorProp,\n stroke: colorProp,\n strokeWidth: z.number().optional(),\n }),\n )\n .optional(),\n circles: z\n .array(\n z.object({\n cx: z.number(),\n cy: z.number(),\n r: z.number(),\n fill: colorProp,\n stroke: colorProp,\n }),\n )\n .optional(),\n rects: z\n .array(\n z.object({\n x: z.number(),\n y: z.number(),\n width: z.number(),\n height: z.number(),\n rx: z.number().optional(),\n fill: colorProp,\n stroke: colorProp,\n }),\n )\n .optional(),\n lines: z\n .array(\n z.object({\n x1: z.number(),\n y1: z.number(),\n x2: z.number(),\n y2: z.number(),\n stroke: colorProp,\n }),\n )\n .optional(),\n texts: z\n .array(\n z.object({\n x: z.number(),\n y: z.number(),\n text: z.string(),\n size: z.number().optional(),\n fill: colorProp,\n anchor: z.enum([\"start\", \"middle\", \"end\"]).optional(),\n }),\n )\n .optional(),\n});\nconst captionTrack = z.object({\n url: z.string().describe(\"The URL of a WebVTT file\"),\n language: z.string().optional().describe('BCP 47, for example \"en\"'),\n label: z.string().optional().describe(\"Shown in the captions menu\"),\n kind: z.enum([\"subtitles\", \"captions\", \"descriptions\"]).optional(),\n});\nconst videoSchema = z.object({\n url: z\n .string()\n .describe(\n \"The URL of a video file, or of a YouTube video or short. A page on another video site shows as a link\",\n ),\n posterUrl: z\n .string()\n .optional()\n .describe(\"The image shown before the video plays\"),\n title: z.string().optional().describe(\"Names the video for screen readers\"),\n captions: z\n .array(captionTrack)\n .optional()\n .describe(\"Caption tracks of a video file\"),\n aspectRatio: z.string().optional().describe('Default \"16 / 9\"'),\n width: sizeValue.optional().describe('Default \"100%\"'),\n maxWidth: sizeValue.optional().describe('Default \"100%\"'),\n weight: weightProp,\n});\nconst audioPlayerSchema = z.object({\n url: z.string().describe(\"The URL of the audio file\"),\n description: z\n .string()\n .optional()\n .describe(\"A title or summary of the audio, shown above the player\"),\n weight: weightProp,\n});\nconst htmlViewSchema = z.object({\n html: z.string(),\n height: sizeValue.optional().describe(\"Pixels when a number. Default 360\"),\n width: sizeValue.optional().describe('Default \"100%\"'),\n title: z.string().optional(),\n});\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\ntype IconMap = Record<string, LucideComponent>;\nlet lucidePromise: Promise<IconMap> | null = null;\nlet lucideIcons: IconMap | null = null;\n\nfunction loadLucideIcons() {\n lucidePromise ??= import(\"lucide-react\").then((module) => {\n const icons: IconMap = module.icons;\n lucideIcons = icons;\n return icons;\n });\n return lucidePromise;\n}\n\n/**\n * lucide-react has about 1,500 icons. A static import of its `icons` map\n * puts all of them in every bundle and makes module load slow. So the map\n * loads once, 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/**\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 IconComponent = icons[kebabToPascal(name)] ?? icons[name];\n if (!IconComponent) 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 <IconComponent\n {...a11y}\n focusable=\"false\"\n width={pixels}\n height={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 = {\n Image: {\n component: Image,\n description:\n \"An image from a URL. A click opens it full-screen. Set description to say what the image shows, unless it is only decoration.\",\n props: imageSchema,\n events: {\n onOverlayClick: {\n description:\n \"Sent when the user clicks the actionOverlay button and it has no href.\",\n parameters: NO_ARGS,\n },\n },\n },\n Icon: {\n component: Icon,\n description:\n 'A Lucide icon by kebab-case name (for example \"arrow-right\"), or an A2UI icon name (for example \"arrowBack\"). Set label when no text next to the icon says what it means.',\n props: iconSchema,\n },\n Favicon: {\n component: Favicon,\n description: \"The favicon of the site at a URL.\",\n props: faviconSchema,\n },\n Svg: {\n component: Svg,\n description:\n \"A vector drawing from primitive shapes (paths, circles, rects, lines, texts). Colors take text color tokens or CSS colors.\",\n props: svgSchema,\n },\n Video: {\n component: Video,\n description:\n \"A video player for a video file URL (with optional captions), or a YouTube link in privacy-enhanced mode: the poster shows first, and the player loads when the user presses play. A page on another video site shows as a link to it. Set title to name the video.\",\n props: videoSchema,\n },\n AudioPlayer: {\n component: AudioPlayer,\n description:\n \"An audio player for an audio file URL, with the description above it.\",\n props: audioPlayerSchema,\n },\n HtmlView: {\n component: HtmlView,\n description:\n \"Raw HTML in a fully sandboxed iframe: no scripts, no same-origin access. Set title to name the content.\",\n props: htmlViewSchema,\n },\n};\n","import React, { useContext, useEffect, useRef, useState } from \"react\";\nimport type { CSSProperties, KeyboardEvent, MouseEvent } from \"react\";\nimport { z } from \"zod\";\nimport type { GenerativeUIInvokeResult } from \"../errors\";\nimport {\n GenerativeUINodeContext,\n useGenerativeUIRuntime,\n} from \"../runtime-context\";\nimport { sizeValue } from \"./layout\";\nimport { Lightbox, openUrl } from \"./lightbox\";\nimport { safeHref } from \"./markdown\";\nimport { LucideIcon, hostOf } from \"./media\";\nimport { ACCENT, useStandardStyles } from \"./styles\";\nimport {\n FONT_WEIGHT,\n ON_ACCENT,\n SHADOW_MD,\n backgroundColor,\n borderColor,\n radius,\n spacing,\n textColor,\n textFont,\n} from \"./tokens\";\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\nconst NO_ARGS = z.object({});\ntype EventProp<Args = z.input<typeof NO_ARGS>> = (\n args: Args,\n) => Promise<GenerativeUIInvokeResult>;\n\nconst text = (description: string) =>\n z.string().optional().describe(description);\n\nconst linkCardSchema = z.object({\n href: z.string().describe(\"The URL (http, https)\"),\n title: z.string().describe(\"The page title\"),\n description: text(\"One or two lines\"),\n image: text(\"A thumbnail URL\"),\n domain: text(\"Shown next to the favicon. Default: the host of href\"),\n favicon: z.boolean().optional().describe(\"Default true\"),\n});\nconst citationSchema = z.object({\n index: z.number().optional().describe(\"The marker number. Default 1\"),\n label: text(\"Marker text instead of the number, for example a domain\"),\n title: text(\"The source title\"),\n url: text(\"The source URL (http, https)\"),\n snippet: text(\"The quoted passage, one or two lines\"),\n source: text(\"The publisher or domain. Default: the host of url\"),\n});\nexport const followUpItem = z.union([\n z.string(),\n z.object({\n label: z.string(),\n message: text(\"The text sent when the user clicks. Default: label\"),\n }),\n]);\nconst followUpSchema = z.object({\n items: z\n .array(followUpItem)\n .optional()\n .describe('Strings or { \"label\", \"message\"? }, or { \"@path\": \"/x\" }'),\n title: text(\"A caption above the pills\"),\n});\nconst followUpArgs = z.object({\n message: z.string().describe(\"The message of the clicked pill\"),\n});\nconst BADGE_COLORS = [\n \"secondary\",\n \"success\",\n \"danger\",\n \"warning\",\n \"info\",\n \"discovery\",\n] as const;\nexport const cardAction = z.object({\n label: z.string(),\n href: text(\"Opens this URL in a new tab\"),\n variant: z.enum([\"solid\", \"soft\", \"outline\", \"ghost\"]).optional(),\n});\nconst entityCardSchema = z.object({\n title: z.string().describe(\"The name\"),\n subtitle: text(\"A second line, for example the brand or category\"),\n description: text(\"Up to three lines\"),\n image: text(\"An image URL\"),\n imageAspectRatio: z.string().optional().describe('Default \"4 / 3\"'),\n meta: text(\n 'A short fact line, for example \"$29 / month\" or \"Open until 22:00\"',\n ),\n badge: z\n .object({ label: z.string(), color: z.enum(BADGE_COLORS).optional() })\n .optional(),\n rating: z.number().optional().describe(\"0 to 5, shown as stars\"),\n ratingCount: z.number().optional().describe(\"The number of ratings\"),\n href: text(\"Opens this URL in a new tab when the user clicks the card\"),\n actions: z\n .array(cardAction)\n .max(3)\n .optional()\n .describe(\n \"Up to three buttons. A button without href sends onAction with its label\",\n ),\n layout: z\n .enum([\"vertical\", \"horizontal\"])\n .optional()\n .describe('Default \"vertical\". \"horizontal\" puts the image on the left'),\n width: sizeValue.optional(),\n});\nconst entityActionArgs = z.object({\n label: z.string().describe(\"The label of the clicked button\"),\n});\nexport const gridImage = z.object({\n url: z.string(),\n description: z.string().optional().describe(\"What the image shows\"),\n caption: z.string().optional(),\n href: text(\"Opens this URL instead of the full-screen view\"),\n});\nconst imageGridSchema = z.object({\n images: z\n .array(gridImage)\n .optional()\n .describe(\n 'A list of { \"url\", \"description\"?, \"caption\"?, \"href\"? }, or { \"@path\": \"/x\" }',\n ),\n columns: z.number().optional().describe(\"Default 3\"),\n aspectRatio: z.string().optional().describe('Default \"1 / 1\"'),\n gap: sizeValue.optional().describe(\"Default 2\"),\n layout: z\n .enum([\"grid\", \"bento\"])\n .optional()\n .describe('Default \"grid\". \"bento\" makes the first image twice as large'),\n});\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 = {\n LinkCard: {\n component: LinkCard,\n description:\n \"A preview card of a URL: the favicon and domain, the title, a description and a thumbnail. A click opens the link in a new tab, or sends onClick when it is bound. Use it for sources, articles and products that have a page.\",\n props: linkCardSchema,\n events: {\n onClick: {\n description: \"Sent when the user clicks the card, instead of the link.\",\n parameters: NO_ARGS,\n },\n },\n },\n Citation: {\n component: Citation,\n description:\n \"An inline source marker ([1]) that shows the source on hover or click: the title, a snippet and a link. Put it inline after the sentence it supports, as a child of a Text or in a Row.\",\n props: citationSchema,\n },\n FollowUp: {\n component: FollowUp,\n description:\n \"Suggested next prompts as pills. A click sends the message of the pill as the next turn of the user, with no event binding needed. Put it at the end of a surface, with two to four short items.\",\n props: followUpSchema,\n events: {\n onFollowUp: {\n description:\n \"Sent when the user clicks a pill. The args carry the message of the pill.\",\n parameters: followUpArgs,\n },\n },\n },\n EntityCard: {\n component: EntityCard,\n description:\n \"A card for one thing (a product, place, person or listing): an image, title, subtitle, description, a price or meta line, a badge, a rating and up to three buttons. href opens a page, and onClick is sent when it is bound. Use a Grid of EntityCards for several things.\",\n props: entityCardSchema,\n events: {\n onClick: {\n description: \"Sent when the user clicks the card and it has no href.\",\n parameters: NO_ARGS,\n },\n onAction: {\n description:\n \"Sent when the user clicks a button without href. The args carry the label of the button.\",\n parameters: entityActionArgs,\n },\n },\n },\n ImageGrid: {\n component: ImageGrid,\n description:\n 'A gallery of images in a grid. A click opens the image full-screen, with arrows to the other images. layout \"bento\" makes the first image twice as large.',\n props: imageGridSchema,\n },\n};\n","import React, { Suspense, memo, useRef } from \"react\";\nimport type { CSSProperties, ComponentType } from \"react\";\nimport type * as Recharts from \"recharts\";\nimport { z } from \"zod\";\nimport {\n CHART_CURSOR,\n CHART_PALETTE,\n FONT_WEIGHT,\n SHADOW_MD,\n backgroundColor,\n borderColor,\n textColor,\n textFont,\n} from \"./tokens\";\n\n// ---- Schema ----\n\nexport const chartSeries = z.union([\n z.string(),\n z.object({\n key: z.string(),\n label: z.string().optional(),\n color: z.string().optional().describe(\"A text color token or a CSS color\"),\n }),\n]);\nexport type ChartSeries = z.output<typeof chartSeries>;\n\nexport const chartSchema = z.object({\n chartType: z\n .enum([\"bar\", \"line\", \"area\", \"scatter\", \"pie\", \"donut\"])\n .optional()\n .describe('Default \"bar\"'),\n data: z\n .array(z.record(z.string(), z.unknown()))\n .optional()\n .describe('A list of objects, or { \"@path\": \"/x\" }'),\n xKey: z.string().optional().describe(\"The field of the category axis\"),\n series: z\n .array(chartSeries)\n .optional()\n .describe(\n 'The value fields: strings or { \"key\", \"label\"?, \"color\"? }. Default: every number field except xKey',\n ),\n stacked: z.boolean().optional(),\n layout: z\n .enum([\"vertical\", \"horizontal\"])\n .optional()\n .describe(\n '\"horizontal\" draws the bars from left to right. Default \"vertical\"',\n ),\n yAxis: z\n .object({\n label: z.string().optional(),\n min: z.number().optional(),\n max: z.number().optional(),\n width: z.number().optional().describe(\"Pixels\"),\n })\n .optional()\n .describe(\n 'The value axis configuration object: {label?: string, min?: number, max?: number, width?: number}. Example: {label: \"Revenue (USD)\", min: 0, max: 100}. In horizontal charts, label, min and max apply to the horizontal value axis, and width sets the width of the category axis on the left.',\n ),\n showDots: z.boolean().optional().describe(\"Point markers on a line or area\"),\n barRadius: z\n .number()\n .optional()\n .describe(\"The corner radius of a bar, in pixels\"),\n innerRadius: z\n .union([z.number(), z.string()])\n .optional()\n .describe(\"Pie and donut\"),\n outerRadius: z\n .union([z.number(), z.string()])\n .optional()\n .describe(\"Pie and donut\"),\n startAngle: z.number().optional().describe(\"Pie and donut. Default 90\"),\n endAngle: z.number().optional().describe(\"Pie and donut. Default -270\"),\n cornerRadius: z.number().optional().describe(\"The corners of a slice\"),\n paddingAngle: z.number().optional().describe(\"The gap between slices\"),\n showLabelLines: z\n .boolean()\n .optional()\n .describe(\"Leader lines of the slice labels. Default true\"),\n height: z.number().optional().describe(\"Pixels. Default 240\"),\n showLegend: z.boolean().optional().describe(\"Default true\"),\n showGrid: z.boolean().optional().describe(\"Default true\"),\n showTooltip: z.boolean().optional().describe(\"Default true\"),\n showValueLabels: z.boolean().optional(),\n format: z\n .enum([\"number\", \"currency\", \"percent\"])\n .optional()\n .describe(\n 'Number formatting. With \"percent\", data values and axis min/max are fractions: 0.4 displays as 40%. For 0% to 10%, use min: 0 and max: 0.1.',\n ),\n currency: z.string().optional().describe('ISO code. Default \"USD\"'),\n title: z.string().optional(),\n});\nexport type ChartProps = z.output<typeof chartSchema>;\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 { 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 \"./tokens\";\nimport { useStandardStyles } from \"./styles\";\n\n// ---- Schema ----\n\nexport const mapMarker = z.object({\n label: z.string(),\n lat: z.number(),\n lng: z.number(),\n category: z.string().optional(),\n icon: z.string().optional(),\n});\nexport type MapMarker = z.output<typeof mapMarker>;\n\nexport const mapSchema = z.object({\n markers: z\n .array(mapMarker)\n .optional()\n .describe('A list of places, or { \"@path\": \"/x\" }'),\n route: z\n .boolean()\n .optional()\n .describe(\"Draws a line through the markers in order\"),\n selected: z\n .string()\n .optional()\n .describe(\n 'The label of the selected marker. Bind it with { \"@path\": \"/x\" } to read the choice of the user',\n ),\n height: z.number().optional().describe(\"Pixels. Default 240\"),\n zoom: z\n .number()\n .optional()\n .describe(\"With two or more markers, only the highest zoom of the fit\"),\n center: z.object({ lat: z.number(), lng: z.number() }).optional(),\n});\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 { z } from \"zod\";\nimport { CHILDREN_SLOT, sizeValue, weightProp } from \"./layout\";\nimport { LucideIcon } from \"./media\";\nimport { Chart, VISUALLY_HIDDEN, chartSchema } from \"./Chart\";\nimport { MapView, mapSchema } from \"./Map\";\nimport {\n FONT_WEIGHT,\n backgroundColor,\n borderColor,\n radius,\n spacing,\n textColor,\n textFont,\n} from \"./tokens\";\nimport { useGenerativeUIAccessibility } from \"../accessibility\";\nimport { useStandardStyles } from \"./styles\";\n\n// ---- Schemas ----\n\nconst cellAlign = z.enum([\"start\", \"center\", \"end\"]).optional();\n\n/**\n * A table cell or column header that shows another component. `id` is an\n * alias of `componentId`.\n */\nconst tableComponentCell = z.union([\n z.object({ componentId: z.string() }),\n z.object({ id: z.string() }),\n]);\n\nconst tableColumn = z.union([\n z.string(),\n z.object({\n label: z.string(),\n align: cellAlign,\n width: sizeValue.optional(),\n componentId: z.string().optional(),\n }),\n tableComponentCell,\n]);\ntype TableColumn = z.output<typeof tableColumn>;\n\nconst tableSchema = z.object({\n caption: z\n .string()\n .optional()\n .describe(\"A short name of the table for screen readers. It is not shown\"),\n columns: z\n .array(tableColumn)\n .optional()\n .describe(\n 'Strings, { \"label\", \"align\"?, \"width\"?, \"componentId\"? } or { \"componentId\" }, or { \"@path\": \"/x\" }. Default []',\n ),\n // A cell is `unknown`, so booleans and null from bound data are valid too.\n rows: z\n .array(z.array(z.unknown()))\n .optional()\n .describe(\n 'A list of row lists, or { \"@path\": \"/x\" }. A cell is a string, a number, or { \"componentId\": \"<id>\" } to show a component. Default []',\n ),\n columnSizing: z.enum([\"auto\", \"equal\"]).optional().describe('Default \"auto\"'),\n dividers: z.boolean().optional().describe(\"Default true\"),\n stickyHeader: z.boolean().optional().describe(\"Default false\"),\n emptyLabel: z.string().optional().describe('Default \"No rows\"'),\n});\nconst tableSectionSchema = z.object({\n header: z.boolean().optional().describe(\"Renders the rows as the header\"),\n rowDivider: z.boolean().optional(),\n});\nconst tableRowSchema = z.object({\n header: z.boolean().optional(),\n label: z\n .string()\n .optional()\n .describe(\"The text of a header cell at the start of the row\"),\n labelColSpan: z.number().optional().describe(\"Columns the label cell spans\"),\n});\nconst tableCellSchema = z.object({\n text: z.union([z.string(), z.number()]).optional(),\n header: z.boolean().optional(),\n align: cellAlign,\n vAlign: cellAlign.describe('Default \"start\"'),\n colSpan: z.number().optional(),\n rowSpan: z.number().optional(),\n width: sizeValue.optional(),\n padding: sizeValue.optional(),\n});\n\nconst listItemValue = z.union([\n z.string(),\n z.object({\n label: z.string(),\n description: z.string().optional(),\n icon: z.string().optional().describe(\"Lucide icon name\"),\n value: z\n .union([z.string(), z.number()])\n .optional()\n .describe(\n \"Without an action: shown on the right of the label, for a key and value fact. With an action: the payload of the pick, not shown\",\n ),\n }),\n]);\ntype ListItemValue = z.output<typeof listItemValue>;\n\nconst LIST_MARKERS = [\"bullet\", \"number\", \"rich\", \"none\"] as const;\ntype ListMarker = (typeof LIST_MARKERS)[number];\n\nconst listSchema = z.object({\n items: z\n .array(listItemValue)\n .optional()\n .describe(\n 'Strings or { \"label\", \"value\"?, \"description\"?, \"icon\"? }, or { \"@path\": \"/x\" }',\n ),\n direction: z\n .enum([\"vertical\", \"horizontal\"])\n .optional()\n .describe('Default \"vertical\". \"horizontal\" scrolls sideways'),\n align: z.enum([\"start\", \"center\", \"end\", \"stretch\"]).optional(),\n weight: weightProp,\n marker: z.enum(LIST_MARKERS).optional().describe('Default \"bullet\"'),\n connector: z.enum([\"none\", \"solid\"]).optional().describe('Default \"none\"'),\n gap: sizeValue.optional(),\n start: z.number().optional().describe('The first number of marker \"number\"'),\n maxMarkerSize: z\n .number()\n .optional()\n .describe(\"The width of the marker column in pixels\"),\n});\nconst listItemSchema = z.object({\n label: z.string().optional(),\n value: z\n .union([z.string(), z.number()])\n .optional()\n .describe(\n \"Without an action: shown on the right of the label, for a key and value fact\",\n ),\n description: z.string().optional(),\n icon: z.string().optional().describe(\"Lucide icon name\"),\n marker: z.string().optional().describe(\"Shows this text as the marker\"),\n markerSize: z\n .number()\n .optional()\n .describe(\"The width of the marker column in pixels\"),\n disabled: z\n .boolean()\n .optional()\n .describe(\"Greys the item out and ignores its action\"),\n});\n\nconst listSelection = z.object({\n index: z.number(),\n label: z.string(),\n value: z.string().optional(),\n});\n\ntype ListSelection = z.output<typeof listSelection>;\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 = {\n Table: {\n component: Table,\n description:\n 'A data table. Put it in a plain Column, not in a Card. Give \"columns\" and \"rows\" (a list of row lists). Or give \"children\": TableSection or TableRow ids, or a template { \"componentId\", \"path\" } that repeats a TableRow for each item of a data list. To show a component (Badge, Button, Icon, Text) in a cell or a column header, set it to { \"componentId\": \"<id>\" } and put the id in \"cellComponents\".',\n props: tableSchema,\n slots: { children: \"multiple\", cellComponents: \"multiple\" } as const,\n },\n TableSection: {\n component: TableSection,\n accessibility: \"self\" as const,\n description:\n \"A group of TableRow children in a Table. With header true, it is the header of the table.\",\n props: tableSectionSchema,\n slots: CHILDREN_SLOT,\n },\n TableRow: {\n component: TableRow,\n accessibility: \"self\" as const,\n description:\n \"A row of a Table. Its children are TableCell ids, or a template. With label, a header cell with that text starts the row.\",\n props: tableRowSchema,\n slots: CHILDREN_SLOT,\n },\n TableCell: {\n component: TableCell,\n accessibility: \"self\" as const,\n description:\n 'A cell of a TableRow. It shows \"text\", or its children. With header true, it is a header cell.',\n props: tableCellSchema,\n slots: CHILDREN_SLOT,\n },\n List: {\n component: List,\n description:\n 'A list in a Card or next to another component. A plain list of text is markdown, not a List. Give \"items\" (strings or { \"label\", \"value\"?, \"description\"?, \"icon\"? }); without an action, an item with a value is a key and value row, for facts like Price: $1,599. Or, when there are no items, give \"children\": ListItem ids or a template. With an \"action\", the user can pick an item: the event context gets \"index\", \"label\" and \"value\" of the item.',\n props: listSchema,\n events: {\n action: {\n description:\n \"Runs when the user picks an item. The args are the index, label and value of the item.\",\n parameters: listSelection,\n },\n },\n slots: CHILDREN_SLOT,\n },\n ListItem: {\n component: ListItem,\n description:\n 'An item of a List, with a label, a value on the right, a description, an icon and children. With an \"action\", the user can pick it.',\n props: listItemSchema,\n events: {\n action: {\n description: \"Runs when the user picks the item.\",\n parameters: z.object({}),\n },\n },\n slots: CHILDREN_SLOT,\n },\n Chart: {\n component: Chart,\n description:\n 'A bar, line, area, scatter, pie or donut chart. \"data\" is a list of objects. \"xKey\" is the field of the category. \"series\" are the value fields.',\n props: chartSchema,\n },\n Map: {\n component: MapView,\n description:\n 'A map with markers. With \"route\", a line connects the markers in order. Bind \"selected\" to { \"@path\": \"/x\" } to get the label of the marker that the user picks. When maps are not available, it shows a list of the places.',\n props: mapSchema,\n writable: [\"selected\"] as const,\n },\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 { z } from \"zod\";\nimport {\n controlAria,\n useGenerativeUIAccessibility,\n wrapperAria,\n} from \"../accessibility\";\nimport { useGenerativeUIRuntime } from \"../runtime-context\";\nimport { useOverlayEscape } from \"./overlay-stack\";\nimport { CHILDREN_SLOT, sizeValue, weightProp } from \"./layout\";\nimport { useStandardStyles } from \"./styles\";\nimport {\n BACKDROP,\n backgroundColor,\n borderColor,\n radius,\n spacing,\n textColor,\n textFont,\n SHADOW_MD,\n} from \"./tokens\";\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\n// ---- Schemas ----\n\nconst pulseIndicatorSchema = z.object({\n label: z\n .string()\n .optional()\n .describe(\n \"What the dot means, for screen readers. Leave it unset when text next to the dot says the same\",\n ),\n color: z.string().optional().describe('Text color token. Default \"success\"'),\n size: z.number().optional().describe(\"Pixels. Default 12\"),\n pulseColor: z.string().optional(),\n duration: z.number().optional().describe(\"Milliseconds. Default 1500\"),\n endScale: z.number().optional().describe(\"Default 2.4\"),\n startOpacity: z.number().optional().describe(\"Default 0.6\"),\n});\nconst flashcardSchema = z.object({\n front: z.string().optional().describe(\"The text on the front\"),\n back: z.string().optional().describe(\"The text on the back\"),\n hint: z\n .string()\n .optional()\n .describe('A small line under the front, for example \"Click to flip\"'),\n});\nconst popoverSchema = z.object({\n open: z.boolean().optional().describe(\"Default false\"),\n showOnHover: z.boolean().optional(),\n hoverOpenDelay: z\n .number()\n .optional()\n .describe(\"Milliseconds before a hover opens it. Default 0\"),\n});\nconst popoverTriggerSchema = z.object({\n block: z.boolean().optional().describe(\"Full width\"),\n});\nconst popoverContentSchema = z.object({\n side: z\n .enum([\"top\", \"bottom\", \"left\", \"right\"])\n .optional()\n .describe('Default \"bottom\"'),\n sideOffset: z\n .number()\n .optional()\n .describe(\"Pixels between the trigger and the content. Default 6\"),\n align: z\n .enum([\"start\", \"center\", \"end\"])\n .optional()\n .describe('Default \"center\"'),\n width: sizeValue.optional().describe(\"4px steps when a number\"),\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\nconst modalSchema = z.object({\n title: z.string().optional().describe(\"The heading of the dialog\"),\n open: z\n .boolean()\n .optional()\n .describe('Default false. Bind it with { \"@path\": \"/x\" } to read it'),\n maxWidth: sizeValue.optional().describe(\"Default 480\"),\n weight: weightProp,\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 = {\n PulseIndicator: {\n component: PulseIndicator,\n description:\n 'A small dot that pulses, for example next to the text \"Live\". Set label when no text next to the dot says what it means.',\n props: pulseIndicatorSchema,\n },\n FlashcardFlip: {\n component: FlashcardFlip,\n description:\n \"A card that shows the front text. A click or the Enter key flips it to the back text, and again to the front.\",\n props: flashcardSchema,\n },\n Popover: {\n component: Popover,\n description:\n \"A small overlay next to a trigger. Put exactly two children in it: one PopoverTrigger, then one PopoverContent. A click on the trigger opens and closes the content. Escape or a click outside closes it.\",\n props: popoverSchema,\n slots: CHILDREN_SLOT,\n writable: [\"open\"] as const,\n },\n PopoverTrigger: {\n component: PopoverTrigger,\n description:\n \"The trigger of a Popover. Its children are the label of the trigger: a Text or an Icon. Do not put a Button in it, because the trigger is already a button.\",\n props: popoverTriggerSchema,\n slots: CHILDREN_SLOT,\n },\n PopoverContent: {\n component: PopoverContent,\n description:\n \"The body of a Popover. It shows only when the Popover is open.\",\n props: popoverContentSchema,\n slots: CHILDREN_SLOT,\n },\n Modal: {\n component: Modal,\n description:\n \"A dialog over the page. A click on the trigger (a Button or a Text) opens the content in the dialog. Escape, the close button or a click on the backdrop closes it.\",\n props: modalSchema,\n slots: { trigger: \"single\", content: \"single\" } as const,\n writable: [\"open\"] as const,\n },\n};\n","import { useState } from \"react\";\nimport { z } from \"zod\";\nimport type { CSSProperties } from \"react\";\nimport { textColor, textFont } from \"./tokens\";\n\n/**\n * The `checks` of the A2UI 1.0 `Checkable` components. The model writes\n * each condition as a validator call or a boolean binding:\n * `{ \"condition\": { \"@call\": \"email\", \"args\": { \"value\": { \"@path\": \"/form/email\" } } }, \"message\": \"...\" }`.\n * The engine resolves the condition before the component renders, so a\n * component sees a boolean or a `ValidationResult`.\n */\n\nconst severity = z.enum([\"error\", \"warning\", \"info\"]);\n\nconst validationResult = z\n .object({\n valid: z.boolean(),\n message: z.string().optional(),\n code: z.string().optional(),\n severity: severity.optional(),\n })\n .passthrough();\n\n/** The first failed check of a control, as the control shows it. */\nexport interface FailedCheck {\n message: string;\n /** `\"error\"` when the result named none. Only an error blocks. */\n severity: z.output<typeof severity>;\n /** The `code` of the validation result, when it had one. */\n code?: string;\n}\n\nexport const checksProp = z\n .array(\n z.object({\n condition: z\n .union([z.boolean(), validationResult])\n .optional()\n .describe(\n 'A validator call, for example {\"@call\":\"required\",\"args\":{\"value\":{\"@path\":\"/x\"}}}, or a boolean binding',\n ),\n message: z\n .string()\n .optional()\n .describe(\"Shown when the check fails, instead of the default message\"),\n }),\n )\n .optional()\n .describe(\"Validation rules. The control shows the first failed one\");\n\nexport type ResolvedChecks = z.output<typeof checksProp>;\n\n/**\n * The failed check to show, or `undefined` when every check passes: the\n * first error, or the first warning or info when no check is an error, so\n * a warning never hides an error that comes after it. A condition that is\n * not known yet (undefined) passes. A `false` condition is an error with\n * the check's message. The check's message also wins over the message of\n * a validator result: the built-in validators always have one, and the\n * check is where the model puts its own wording.\n */\nexport function firstFailedCheck(\n checks: ResolvedChecks,\n): FailedCheck | undefined {\n let first: FailedCheck | undefined;\n for (const check of checks ?? []) {\n const { condition } = check;\n if (condition === undefined || condition === null) continue;\n let failed: FailedCheck;\n if (typeof condition === \"boolean\") {\n if (condition) continue;\n failed = { message: check.message ?? \"Invalid value\", severity: \"error\" };\n } else {\n if (condition.valid) continue;\n failed = {\n message: check.message ?? condition.message ?? \"Invalid value\",\n severity: condition.severity ?? \"error\",\n ...(condition.code === undefined ? {} : { code: condition.code }),\n };\n }\n if (failed.severity === \"error\") return failed;\n first ??= failed;\n }\n return first;\n}\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\n/** The style of a check message, by its severity. */\nexport function checkMessageStyle(\n severity: FailedCheck[\"severity\"],\n): CSSProperties {\n return {\n ...textFont(\"sm\"),\n color: textColor(\n severity === \"error\"\n ? \"danger\"\n : severity === \"warning\"\n ? \"warning\"\n : \"secondary\",\n ),\n };\n}\n","import React, { useEffect, useId, useRef, useState } from \"react\";\nimport type { CSSProperties, KeyboardEvent, ReactNode } from \"react\";\nimport { z } from \"zod\";\nimport type { GenerativeUIInvokeResult } from \"../errors\";\nimport {\n FONT_WEIGHT,\n ON_ACCENT,\n SHADOW_XS,\n backgroundColor,\n borderColor,\n radius,\n spacing,\n textColor,\n textFont,\n} from \"./tokens\";\nimport {\n controlAria,\n useGenerativeUIAccessibility,\n wrapperAria,\n} from \"../accessibility\";\nimport { ACCENT, useStandardStyles } from \"./styles\";\nimport {\n CHILDREN_SLOT,\n VISIBLE_EVENT,\n layoutProps,\n layoutStyle,\n useVisibleOnce,\n weightProp,\n} from \"./layout\";\nimport { openUrl } from \"./lightbox\";\nimport { LucideIcon } from \"./media\";\nimport {\n checkMessageStyle,\n checksProp,\n firstFailedCheck,\n useChecks,\n} from \"./checks\";\nimport type { FailedCheck } 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\n// ---- Shared schemas ----\n\n/**\n * The arguments of a click or submit event: none. The model adds values\n * with the `context` of its `{ \"event\": ... }` binding.\n */\nconst NO_ARGS = z.object({});\n\ntype EventProp = (\n args: z.input<typeof NO_ARGS>,\n) => Promise<GenerativeUIInvokeResult>;\n\n/** A list of choices: plain strings or `{ value, label, description? }`. */\nconst optionList = z\n .array(\n z.union([\n z.string(),\n z.object({\n value: z.string(),\n label: z.string().optional(),\n description: z.string().optional(),\n }),\n ]),\n )\n .optional()\n .describe('Strings or { \"value\", \"label\", \"description\"? }');\n\ntype OptionList = z.output<typeof optionList>;\n\nconst SIZES = [\"sm\", \"md\", \"lg\", \"xl\"] as const;\ntype Size = (typeof SIZES)[number];\n\nconst size = (fallback: Size) =>\n z.enum(SIZES).optional().describe(`Default \"${fallback}\"`);\nconst pill = z.boolean().optional().describe(\"Default true\");\nconst fieldLabel = z\n .string()\n .optional()\n .describe(\"The visible label of the field. Always set it\");\nconst boundValue = z\n .string()\n .optional()\n .describe('Bind it with { \"@path\": \"/x\" } to read what the user entered');\n\nconst buttonSchema = z.object({\n label: z.string().optional().describe(\"The button text\"),\n checks: checksProp,\n text: z\n .string()\n .optional()\n .describe(\"Same as label. Used when label is not set\"),\n variant: z\n .enum([\"default\", \"primary\", \"soft\", \"borderless\"])\n .optional()\n .describe(\n 'Default \"default\": outlined. \"primary\" is filled, for the one main action. \"borderless\" has no box, like a link',\n ),\n color: z\n .enum([\"primary\", \"secondary\", \"danger\"])\n .optional()\n .describe('Default \"primary\"'),\n size: z.enum([\"sm\", \"md\", \"lg\"]).optional().describe('Default \"lg\"'),\n block: z.boolean().optional().describe(\"Full width\"),\n weight: weightProp,\n pill,\n disabled: z.boolean().optional(),\n loading: z.boolean().optional(),\n submit: z\n .boolean()\n .optional()\n .describe(\"Submits the Form around it. The Form sends its onSubmit event\"),\n icon: z.string().optional().describe(\"Lucide icon name\"),\n uniform: z.boolean().optional().describe(\"A square button, for an icon\"),\n href: z\n .string()\n .optional()\n .describe(\"Opens this URL in a new tab on click, instead of onClick\"),\n copy: z\n .string()\n .optional()\n .describe(\n \"Copies this text to the clipboard on click and shows a check mark, instead of onClick\",\n ),\n});\nconst pressableSchema = z.object({\n ...layoutProps,\n disabled: z.boolean().optional(),\n hoverBackground: z.string().optional(),\n href: z\n .string()\n .optional()\n .describe(\"Opens this URL in a new tab on click, instead of onClick\"),\n tooltip: z.string().optional().describe(\"Shown on hover\"),\n ariaPressed: z.boolean().optional().describe(\"For a toggle\"),\n insetBorder: z.boolean().optional().describe(\"A 1px border inside the box\"),\n});\nconst formSchema = z.object({\n ...layoutProps,\n label: z\n .string()\n .optional()\n .describe(\"A short name of the form for screen readers\"),\n});\nconst textFieldSchema = z.object({\n checks: checksProp,\n value: z\n .union([z.string(), z.number()])\n .optional()\n .describe('Bind it with { \"@path\": \"/x\" } to read what the user typed'),\n placeholder: z.string().optional(),\n label: fieldLabel,\n variant: z\n .enum([\n \"shortText\",\n \"longText\",\n \"number\",\n \"obscured\",\n \"email\",\n \"url\",\n \"tel\",\n ])\n .optional()\n .describe(\n 'Default \"shortText\". \"longText\" is a multi-line field, \"obscured\" a password',\n ),\n weight: weightProp,\n name: z.string().optional(),\n required: z.boolean().optional(),\n disabled: z.boolean().optional(),\n invalid: z.boolean().optional(),\n size: size(\"xl\"),\n pill,\n autoSelect: z.boolean().optional(),\n mask: z.string().optional(),\n});\nconst textAreaSchema = z.object({\n checks: checksProp,\n value: boundValue,\n placeholder: z.string().optional(),\n label: fieldLabel,\n weight: weightProp,\n rows: z.number().optional().describe(\"Default 3\"),\n maxRows: z.number().optional(),\n autoResize: z.boolean().optional(),\n name: z.string().optional(),\n required: z.boolean().optional(),\n disabled: z.boolean().optional(),\n invalid: z.boolean().optional(),\n size: size(\"xl\"),\n});\nconst selectSchema = z.object({\n checks: checksProp,\n value: boundValue,\n options: optionList,\n placeholder: z.string().optional(),\n label: fieldLabel,\n name: z.string().optional(),\n required: z.boolean().optional(),\n disabled: z.boolean().optional(),\n clearable: z.boolean().optional(),\n clearLabel: z.string().optional().describe(\"The label of the empty option\"),\n searchable: z.boolean().optional(),\n icon: z.string().optional().describe(\"Lucide icon shown before the value\"),\n block: z.boolean().optional().describe(\"Full width\"),\n size: size(\"xl\"),\n pill,\n});\nconst checkBoxSchema = z.object({\n checks: checksProp,\n value: z\n .boolean()\n .optional()\n .describe(\n 'True when checked. Bind it with { \"@path\": \"/x\" } to read the state of the box',\n ),\n label: z.string().optional().describe(\"The label text. Always set it\"),\n name: z.string().optional(),\n weight: weightProp,\n disabled: z.boolean().optional(),\n required: z.boolean().optional(),\n lineThrough: z\n .boolean()\n .optional()\n .describe(\"Default false. Strikes the label when the box is checked\"),\n shape: z.enum([\"round\", \"square\"]).optional().describe('Default \"round\"'),\n});\nconst radioSchema = z.object({\n value: z.string().optional(),\n label: z.string().optional(),\n disabled: z.boolean().optional(),\n required: z.boolean().optional(),\n});\nconst radioGroupSchema = z.object({\n checks: checksProp,\n value: boundValue,\n options: optionList,\n label: fieldLabel,\n name: z.string().optional(),\n direction: z.enum([\"row\", \"col\"]).optional().describe('Default \"row\"'),\n variant: z.enum([\"list\", \"pills\", \"cards\"]).optional(),\n disabled: z.boolean().optional(),\n required: z.boolean().optional(),\n});\nconst sliderSchema = z.object({\n checks: checksProp,\n value: z\n .number()\n .optional()\n .describe('Bind it with { \"@path\": \"/x\" } to read the number'),\n min: z.number().optional().describe(\"Default 0\"),\n max: z.number().optional().describe(\"Default 100\"),\n step: z.number().optional().describe(\"Default 1\"),\n steps: z\n .number()\n .int()\n .min(1)\n .optional()\n .describe(\n \"The number of equal divisions between min and max, instead of step\",\n ),\n label: fieldLabel,\n weight: weightProp,\n unit: z.string().optional().describe('Unit after the value, for example \"%\"'),\n marks: z\n .array(z.object({ value: z.number(), label: z.string().optional() }))\n .optional(),\n sliderStyle: z\n .enum([\"continuous\", \"discrete\"])\n .optional()\n .describe('Default \"continuous\"'),\n disabled: z.boolean().optional(),\n name: z.string().optional(),\n});\nconst segmentedControlSchema = z.object({\n checks: checksProp,\n value: boundValue,\n options: optionList,\n label: fieldLabel,\n block: z.boolean().optional().describe(\"Full width\"),\n size: size(\"lg\"),\n pill,\n variant: z\n .enum([\"solid\", \"soft\", \"outline\", \"ghost\"])\n .optional()\n .describe('Default \"ghost\"'),\n disabled: z.boolean().optional(),\n});\nconst choicePickerSchema = z.object({\n checks: checksProp,\n value: z\n .array(z.string())\n .optional()\n .describe(\n 'The chosen option values. Bind it with { \"@path\": \"/x\" } to a string list',\n ),\n options: optionList,\n label: fieldLabel,\n variant: z\n .enum([\"multipleSelection\", \"mutuallyExclusive\"])\n .optional()\n .describe('Default \"mutuallyExclusive\": the user picks one option'),\n displayStyle: z\n .enum([\"checkbox\", \"chips\"])\n .optional()\n .describe('Default \"checkbox\". \"chips\" shows the options as pills'),\n filterable: z\n .boolean()\n .optional()\n .describe(\"Default false. Shows a field that filters the options\"),\n weight: weightProp,\n disabled: z.boolean().optional(),\n required: z.boolean().optional(),\n});\nconst dateTimeInputSchema = z.object({\n checks: checksProp,\n value: z\n .string()\n .optional()\n .describe(\n 'ISO 8601: \"YYYY-MM-DD\", \"HH:MM\" or \"YYYY-MM-DDTHH:MM\". Bind it with { \"@path\": \"/x\" }',\n ),\n label: fieldLabel,\n enableDate: z\n .boolean()\n .optional()\n .describe(\n \"The user picks a date. Default true unless only enableTime is set\",\n ),\n enableTime: z.boolean().optional().describe(\"The user picks a time\"),\n timeStep: z\n .number()\n .int()\n .min(1)\n .max(720)\n .optional()\n .describe(\n \"Minutes between the times the user can pick, e.g. 15 or 30. Shows the time as a list\",\n ),\n weight: weightProp,\n min: z.string().optional().describe(\"The earliest value, ISO 8601\"),\n max: z.string().optional().describe(\"The latest value, ISO 8601\"),\n placeholder: z.string().optional(),\n disabled: z.boolean().optional(),\n required: z.boolean().optional(),\n clearable: z.boolean().optional(),\n block: z.boolean().optional().describe(\"Full width\"),\n});\n\ntype WithChildren<Props> = Props & { children?: ReactNode };\n\n/** The writable list of a control that keeps its state in `value`. */\nconst VALUE_WRITABLE = [\"value\"] as const;\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 (tail !== undefined) return { date: head, time: tail };\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 const [hours, minutes, seconds] = fullTime(time).split(\":\").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 event.preventDefault();\n props.setValue(options[next].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 = {\n Button: {\n component: Button,\n description:\n 'A button that sends its onClick event. With href it opens the URL, and with copy it copies the text, both without the agent. Use variant \"primary\" for the one main Button in a Row, and the default for the others. With submit true inside a Form, it submits the Form. The child or children render instead of the label. With checks, it is disabled while a check fails.',\n props: buttonSchema,\n events: {\n onClick: {\n description: \"Sent when the user clicks the button.\",\n parameters: NO_ARGS,\n },\n },\n slots: { child: \"single\", children: \"multiple\" } as const,\n },\n Pressable: {\n component: Pressable,\n description:\n \"A layout container that the user can click or press with Enter or Space. It sends its onClick event, or opens href. A control inside it sends only its own event.\",\n props: pressableSchema,\n events: {\n ...VISIBLE_EVENT,\n onClick: {\n description: \"Sent when the user clicks or presses the container.\",\n parameters: NO_ARGS,\n },\n },\n slots: CHILDREN_SLOT,\n },\n Form: {\n component: Form,\n description:\n 'A layout container that is a form. It sends its onSubmit event when the user submits it (a Button with submit true, or Enter in a field). Put the values of its fields in the event context with { \"@path\": \"/x\" }.',\n props: formSchema,\n events: {\n onSubmit: {\n description: \"Sent when the user submits the form.\",\n parameters: NO_ARGS,\n },\n },\n slots: CHILDREN_SLOT,\n },\n TextField: {\n component: TextField,\n description:\n 'A text input, single-line unless variant is \"longText\". Bind value with { \"@path\": \"/x\" } to read what the user typed. Give it a label.',\n props: textFieldSchema,\n writable: VALUE_WRITABLE,\n },\n TextArea: {\n component: TextArea,\n description:\n 'A multi-line text input. Bind value with { \"@path\": \"/x\" } to read what the user typed. Give it a label.',\n props: textAreaSchema,\n writable: VALUE_WRITABLE,\n },\n Select: {\n component: Select,\n description:\n 'A dropdown list of options. Bind value with { \"@path\": \"/x\" } to read the chosen option. Give it a label.',\n props: selectSchema,\n writable: VALUE_WRITABLE,\n },\n CheckBox: {\n component: CheckBox,\n description:\n 'A checkbox with a label. Bind value with { \"@path\": \"/x\" } to read its state, true or false.',\n props: checkBoxSchema,\n writable: VALUE_WRITABLE,\n },\n Radio: {\n component: Radio,\n description:\n \"One radio button. Use RadioGroup instead, because it keeps the chosen value.\",\n props: radioSchema,\n },\n RadioGroup: {\n component: RadioGroup,\n description:\n 'A group of radio buttons. The user chooses one option. Bind value with { \"@path\": \"/x\" } to read it. Give it a label.',\n props: radioGroupSchema,\n writable: VALUE_WRITABLE,\n },\n Slider: {\n component: Slider,\n description:\n 'A range slider for a number between min and max. Bind value with { \"@path\": \"/x\" } to read the number. Give it a label.',\n props: sliderSchema,\n writable: VALUE_WRITABLE,\n },\n SegmentedControl: {\n component: SegmentedControl,\n description:\n 'A row of segments. The user chooses one option. Use it for 2 to 5 short options. Bind value with { \"@path\": \"/x\" } to read it.',\n props: segmentedControlSchema,\n writable: VALUE_WRITABLE,\n },\n ChoicePicker: {\n component: ChoicePicker,\n description:\n 'A list of options, as checkboxes or chips. The user picks one, or several with variant \"multipleSelection\". Bind value with { \"@path\": \"/x\" } to read the chosen values as a list. Give it a label.',\n props: choicePickerSchema,\n writable: VALUE_WRITABLE,\n },\n DateTimeInput: {\n component: DateTimeInput,\n description:\n 'A date picker, or a time picker with enableTime, or both. Set timeStep (minutes) to offer fixed times, e.g. 30 for a booking. The value is ISO 8601. Bind value with { \"@path\": \"/x\" } to read it. Give it a label.',\n props: dateTimeInputSchema,\n writable: VALUE_WRITABLE,\n },\n};\n","import React, { useEffect, useId, useState } from \"react\";\nimport type {\n CSSProperties,\n FocusEvent,\n KeyboardEvent,\n ReactNode,\n} from \"react\";\nimport { z } from \"zod\";\nimport { CHILDREN_SLOT, sizeValue, weightProp } from \"./layout\";\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 TEXT_COLORS,\n TEXT_SIZES,\n TITLE_SIZES,\n WEIGHTS,\n backgroundColor,\n borderColor,\n radius,\n spacing,\n textColor,\n textFont,\n} from \"./tokens\";\nimport type { TitleSize } from \"./tokens\";\n\n// ---- Schemas ----\n\nconst colorProp = z\n .string()\n .optional()\n .describe(`One of ${TEXT_COLORS.join(\"|\")} or a CSS color`);\nconst fontWeight = z.enum(WEIGHTS).optional();\nconst textAlign = z.enum([\"start\", \"center\", \"end\"]).optional();\n\nconst typographyProps = {\n color: colorProp,\n fontWeight,\n textAlign,\n italic: z.boolean().optional(),\n truncate: z.boolean().optional(),\n maxLines: z.number().optional(),\n tabularNums: z.boolean().optional(),\n width: sizeValue.optional(),\n};\n\nconst typographySchema = z.object(typographyProps);\nconst titleSchema = z.object({\n ...typographyProps,\n text: z.string().describe(\"Heading text\"),\n size: z.enum(TITLE_SIZES).optional().describe('Default \"md\"'),\n strong: z.boolean().optional().describe(\"Default true\"),\n});\nconst textSchema = z.object({\n ...typographyProps,\n weight: weightProp,\n text: z\n .union([z.string(), z.number()])\n .optional()\n .describe(\"Text with inline markdown. A bound number shows as text\"),\n size: z.enum(TEXT_SIZES).optional().describe('Default \"md\"'),\n fontSize: sizeValue\n .optional()\n .describe(\"Pixels when a number. Wins over size\"),\n lineHeight: z\n .union([z.number(), z.string()])\n .optional()\n .describe(\"A unitless ratio, or CSS\"),\n minLines: z\n .number()\n .optional()\n .describe(\"Reserves the height of this many lines\"),\n strong: z.boolean().optional().describe(\"Default false\"),\n underline: z.boolean().optional(),\n lineThrough: z.boolean().optional(),\n inline: z.boolean().optional(),\n preserveWhitespace: z.boolean().optional(),\n highlight: z\n .union([z.enum([\"green\", \"orange\", \"pink\"]), z.boolean()])\n .optional(),\n});\nconst CAPTION_SIZES = [\"sm\", \"md\", \"lg\"] as const;\nconst captionSchema = z.object({\n text: z.union([z.string(), z.number()]).describe(\"Caption text\"),\n color: colorProp,\n size: z.enum(CAPTION_SIZES).optional().describe('Default \"lg\"'),\n fontWeight: fontWeight.describe('Default \"normal\"'),\n textAlign,\n truncate: z.boolean().optional(),\n maxLines: z.number().optional(),\n});\nconst labelSchema = z.object({\n text: z.union([z.string(), z.number()]).describe(\"Label text\"),\n htmlFor: z.string().optional(),\n color: colorProp,\n size: z.enum(TEXT_SIZES).optional().describe('Default \"sm\"'),\n fontWeight: fontWeight.describe('Default \"medium\"'),\n textAlign,\n truncate: z.boolean().optional(),\n width: sizeValue.optional(),\n});\nconst boldSchema = z.object({ text: z.string(), fontWeight });\nconst inlineTextSchema = z.object({ text: z.string() });\nconst blockquoteSchema = z.object({\n text: z.string().describe(\"The quoted text, with inline markdown\"),\n});\nconst BADGE_SIZES = [\"sm\", \"md\", \"lg\"] as const;\nconst badgeSchema = z.object({\n label: z.string().describe(\"Badge text\"),\n color: z\n .enum([\"secondary\", \"success\", \"danger\", \"warning\", \"info\", \"discovery\"])\n .optional()\n .describe('Default \"secondary\"'),\n size: z.enum(BADGE_SIZES).optional().describe('Default \"md\"'),\n pill: z.boolean().optional().describe(\"Default true\"),\n variant: z\n .enum([\"soft\", \"solid\", \"outline\"])\n .optional()\n .describe('Default \"soft\"'),\n fontWeight: fontWeight.describe('Default \"medium\"'),\n maxWidth: sizeValue.optional(),\n padding: sizeValue.optional(),\n});\nconst codeSchema = z.object({\n text: z.string().describe(\"Source code\"),\n language: z.string().optional(),\n});\nconst markdownSchema = z.object({\n text: z.string().describe(\"Markdown source\"),\n streaming: z.boolean().optional().describe(\"Default false\"),\n});\nconst mathSchema = z.object({\n value: z.string().describe(\"TeX source\"),\n block: z.boolean().optional().describe(\"Default false\"),\n});\nconst shimmerSchema = z.object({\n ...typographyProps,\n text: z.string(),\n size: z.enum(TEXT_SIZES).optional().describe('Default \"md\"'),\n lineThrough: z.boolean().optional(),\n});\nconst linkSchema = z.object({\n text: z.string().describe(\"Link text\"),\n href: z.string().describe(\"URL\"),\n title: z.string().optional(),\n});\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 = {\n Title: {\n component: Title,\n description:\n 'A heading inside a Card or next to another component. A heading alone is markdown outside the fence. Use size \"2xl\" at most once in a surface, and \"lg\" for section headings. Size \"sm\" is an h4, \"md\" and \"lg\" are an h3 (default \"md\"), \"xl\" and larger are an h2. It is bold unless strong is false.',\n props: titleSchema,\n },\n Text: {\n component: Text,\n description:\n 'Body text inside a Card or next to another component. A paragraph alone is markdown outside the fence. Use color \"default\" or \"secondary\". `text` can have inline markdown: **bold**, *italic*, ~~strike~~, ++underline++, `code` and [link](https://example.com). The `children` ids render inline after the text, for example a Badge.',\n props: textSchema,\n slots: CHILDREN_SLOT,\n },\n Caption: {\n component: Caption,\n description:\n \"Small secondary text: a hint under a control, or a label in a Row. `text` can have inline markdown.\",\n props: captionSchema,\n },\n Label: {\n component: Label,\n description: \"The label of a form field.\",\n props: labelSchema,\n },\n Bold: {\n component: Bold,\n description: \"Bold inline text.\",\n props: boldSchema,\n },\n Italic: {\n component: Italic,\n description: \"Italic inline text.\",\n props: inlineTextSchema,\n },\n Underline: {\n component: Underline,\n description: \"Underlined inline text.\",\n props: inlineTextSchema,\n },\n Strikethrough: {\n component: Strikethrough,\n description: \"Struck-through inline text.\",\n props: inlineTextSchema,\n },\n Badge: {\n component: Badge,\n description:\n \"A small status pill. Use the colors success, danger and warning only to show a status, not for decoration.\",\n props: badgeSchema,\n },\n Blockquote: {\n component: Blockquote,\n description:\n \"A block quotation with a line on the left. `text` can have inline markdown.\",\n props: blockquoteSchema,\n },\n Code: {\n component: Code,\n description: \"A block of code in a monospace font.\",\n props: codeSchema,\n },\n Markdown: {\n component: Markdown,\n description:\n \"A block of GitHub-flavored markdown. Use it only next to other components, for example in a table cell or next to a chart. Markdown alone goes outside the fence.\",\n props: markdownSchema,\n },\n Math: {\n component: MathFormula,\n description:\n \"A TeX math formula, typeset with KaTeX. Set block to true for a centered formula on its own line.\",\n props: mathSchema,\n },\n ShimmerText: {\n component: ShimmerText,\n description:\n \"Text with a moving shimmer. It shows that something is loading or pending.\",\n props: shimmerSchema,\n },\n Link: {\n component: Link,\n description:\n \"A link. Only http, https and mailto URLs work. It opens in a new tab.\",\n props: linkSchema,\n },\n Tooltip: {\n component: Tooltip,\n description:\n \"Shows `content` when the user points at `trigger` or moves keyboard focus to it. `trigger` is one child id: a Text, Icon or Badge, not a Button or Link. `content` is one child id of short text, for example a Text. Do not put links or buttons in `content`.\",\n slots: { trigger: \"single\", content: \"single\" } as const,\n },\n};\n","import type { GenerativeUIComponentDefinition } from \"../catalog\";\nimport { toJsonSchema } from \"../json-schema\";\n\n/** CopilotKit catalog design, not an A2UI-mandated list of signatures.\n * Express maps positional arguments using the exported JSON Schema property order:\n * https://a2ui.org/specification/proposals/express/a2ui_express/#schema-driven-key-mapping\n * Keep these prefixes stable. Optional styling is best passed by name.\n */\nexport const STANDARD_ARGUMENT_PREFIXES = {\n Box: [\"children\"],\n Column: [\"children\"],\n Row: [\"children\"],\n Grid: [\"children\", \"columns\"],\n GridItem: [\"children\"],\n Card: [\"children\", \"child\"],\n Flow: [\"children\"],\n FlowItem: [\"children\"],\n Carousel: [\"children\", \"activeIndex\"],\n CarouselItem: [\"children\"],\n CarouselMediaItem: [\"url\", \"children\", \"onClick\"],\n Spacer: [\"minSize\"],\n Divider: [\"axis\"],\n Tabs: [\"tabs\", \"selectedIndex\"],\n Title: [\"text\"],\n Text: [\"text\", \"children\"],\n Caption: [\"text\"],\n Label: [\"text\", \"htmlFor\"],\n Bold: [\"text\"],\n Italic: [\"text\"],\n Underline: [\"text\"],\n Strikethrough: [\"text\"],\n Badge: [\"label\"],\n Blockquote: [\"text\"],\n Code: [\"text\", \"language\"],\n Markdown: [\"text\"],\n Math: [\"value\"],\n ShimmerText: [\"text\"],\n Link: [\"text\", \"href\"],\n Tooltip: [\"trigger\", \"content\"],\n Button: [\"label\", \"onClick\"],\n Pressable: [\"children\", \"onClick\", \"href\"],\n Form: [\"children\", \"onSubmit\"],\n TextField: [\"label\", \"value\"],\n TextArea: [\"label\", \"value\"],\n Select: [\"label\", \"options\", \"value\"],\n CheckBox: [\"label\", \"value\"],\n Radio: [\"label\", \"value\"],\n RadioGroup: [\"label\", \"options\", \"value\"],\n Slider: [\"label\", \"value\", \"min\", \"max\"],\n SegmentedControl: [\"label\", \"options\", \"value\"],\n ChoicePicker: [\"label\", \"options\", \"value\"],\n DateTimeInput: [\"label\", \"value\"],\n PulseIndicator: [\"label\"],\n FlashcardFlip: [\"front\", \"back\"],\n Popover: [\"children\", \"open\"],\n PopoverTrigger: [\"children\"],\n PopoverContent: [\"children\"],\n Modal: [\"trigger\", \"content\", \"title\"],\n Table: [\"columns\", \"rows\", \"children\"],\n TableSection: [\"children\"],\n TableRow: [\"children\", \"label\"],\n TableCell: [\"text\", \"children\"],\n List: [\"items\", \"children\", \"action\"],\n ListItem: [\"label\", \"value\", \"action\", \"children\"],\n Chart: [\"data\", \"xKey\", \"series\", \"chartType\"],\n Map: [\"markers\", \"selected\", \"route\"],\n Image: [\"url\", \"description\", \"onOverlayClick\"],\n Icon: [\"name\", \"label\"],\n Favicon: [\"url\", \"alt\"],\n Svg: [\"paths\", \"viewBox\"],\n Video: [\"url\", \"title\", \"captions\"],\n AudioPlayer: [\"url\", \"description\"],\n HtmlView: [\"html\", \"title\"],\n LinkCard: [\"href\", \"title\", \"onClick\"],\n Citation: [\"index\", \"title\", \"url\"],\n FollowUp: [\"items\", \"onFollowUp\", \"title\"],\n EntityCard: [\"title\", \"actions\", \"onAction\", \"onClick\"],\n ImageGrid: [\"images\"],\n} as const;\n\nconst PRESENTATION_PARAMETERS = new Set([\n \"align\",\n \"aspectRatio\",\n \"background\",\n \"border\",\n \"borderColor\",\n \"clip\",\n \"color\",\n \"columnGap\",\n \"disableAutoSpacing\",\n \"flex\",\n \"flush\",\n \"fontSize\",\n \"fontWeight\",\n \"gap\",\n \"height\",\n \"highlight\",\n \"hoverBackground\",\n \"inline\",\n \"insetBorder\",\n \"italic\",\n \"justify\",\n \"lineHeight\",\n \"lineThrough\",\n \"maxHeight\",\n \"maxLines\",\n \"maxSize\",\n \"maxWidth\",\n \"minHeight\",\n \"minLines\",\n \"minSize\",\n \"minWidth\",\n \"padding\",\n \"pill\",\n \"preserveWhitespace\",\n \"radius\",\n \"role\",\n \"rowGap\",\n \"scrollable\",\n \"shadow\",\n \"shadowStyle\",\n \"size\",\n \"strokeWeight\",\n \"strong\",\n \"tabularNums\",\n \"textAlign\",\n \"truncate\",\n \"underline\",\n \"weight\",\n \"width\",\n \"wrap\",\n]);\n\n/** Put content/actions before presentation, across props, slots and events. */\nexport function standardParameterOrder(\n name: keyof typeof STANDARD_ARGUMENT_PREFIXES,\n definition: GenerativeUIComponentDefinition,\n): string[] {\n const keys = [\n ...Object.keys(\n definition.props ? (toJsonSchema(definition.props).properties ?? {}) : {},\n ),\n ...Object.keys(definition.slots ?? {}),\n ...Object.keys(definition.events ?? {}),\n ];\n const prefix: readonly string[] = STANDARD_ARGUMENT_PREFIXES[name];\n const remainder = keys.filter((key) => !prefix.includes(key));\n // Keep unknown prefix keys: createGenerativeUI rejects them, catching a\n // renamed property whose calling convention was not updated.\n return [\n ...prefix,\n ...remainder.filter((key) => !PRESENTATION_PARAMETERS.has(key)),\n ...remainder.filter((key) => PRESENTATION_PARAMETERS.has(key)),\n ];\n}\n","import { 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\";\nimport {\n standardParameterOrder,\n STANDARD_ARGUMENT_PREFIXES,\n} from \"./parameter-order\";\nimport { STANDARD_CATALOG_ID } from \"./tokens\";\n\nconst components = {\n ...layoutComponents,\n ...textComponents,\n ...inputComponents,\n ...feedbackComponents,\n ...dataComponents,\n ...mediaComponents,\n ...compositeComponents,\n};\n\n// Every standard component needs an intentional positional calling convention.\nSTANDARD_ARGUMENT_PREFIXES satisfies Record<\n keyof typeof components,\n readonly string[]\n>;\n\nconst orderedComponents = Object.fromEntries(\n Object.entries(components).map(([name, definition]) => [\n name,\n {\n ...definition,\n parameterOrder: standardParameterOrder(\n name as keyof typeof components,\n definition,\n ),\n },\n ]),\n) as {\n [Name in keyof typeof components]: (typeof components)[Name] & {\n parameterOrder: string[];\n };\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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ACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;;AAGF,SAAgB,uBACd,MACA,YACU;CACV,MAAM,OAAO;EACX,GAAG,OAAO,KACR,WAAW,QAASC,sCAAa,WAAW,MAAM,CAAC,cAAc,EAAE,GAAI,EAAE,CAC1E;EACD,GAAG,OAAO,KAAK,WAAW,SAAS,EAAE,CAAC;EACtC,GAAG,OAAO,KAAK,WAAW,UAAU,EAAE,CAAC;EACxC;CACD,MAAM,SAA4B,2BAA2B;CAC7D,MAAM,YAAY,KAAK,QAAQ,QAAQ,CAAC,OAAO,SAAS,IAAI,CAAC;AAG7D,QAAO;EACL,GAAG;EACH,GAAG,UAAU,QAAQ,QAAQ,CAAC,wBAAwB,IAAI,IAAI,CAAC;EAC/D,GAAG,UAAU,QAAQ,QAAQ,wBAAwB,IAAI,IAAI,CAAC;EAC/D;;;;;AC3IH,MAAM,aAAa;CACjB,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACJ;AAQD,MAAM,oBAAoB,OAAO,YAC/B,OAAO,QAAQ,WAAW,CAAC,KAAK,CAAC,MAAM,gBAAgB,CACrD,MACA;CACE,GAAG;CACH,gBAAgB,uBACd,MACA,WACD;CACF,CACF,CAAC,CACH;;;;;;;;;;;;;;;;;;;;;;;;;AA8BD,MAAa,aAAaC,4CAAmB;CAC3C,IAAI;CACJ,YAAY;CACb,CAAC"}
|
|
1
|
+
{"version":3,"file":"generative-ui.cjs","names":["z","A2UI_COMPONENT_ID_MARK","A2UI_CHILD_LIST_MARK","GENERATIVE_UI_FUNCTIONS","toJsonSchema","mapSchema","isRecord","A2UI_COMPONENT_ID_REF","A2UI_CHILD_LIST_REF","GENERATIVE_UI_MAX_TARGET_COMPONENTS","useRequiredGenerativeUIRuntime","SurfaceView","useGenerativeUIAccessibility","wrapperAria","FOCUS_RING","DARK_THEME_CSS","noEffect","useInjectEffect","React","z","NO_ARGS","ALIGN_CSS","useGenerativeUIAccessibility","namedRole","VISUALLY_HIDDEN","React","ProviderMarkdown","NO_ARGS","z","colorProp","px","ICON_PX","IconSvg","useGenerativeUIAccessibility","controlAria","wrapperAria","NO_ARGS","z","useGenerativeUIRuntime","GenerativeUINodeContext","z","React","Suspense","z","noEffect","useInjectEffect","useInsertionEffect","useRequiredGenerativeUIRuntime","z","Caption","useGenerativeUIAccessibility","React","z","useGenerativeUIAccessibility","controlAria","useGenerativeUIRuntime","wrapperAria","z","z","useGenerativeUIAccessibility","wrapperAria","controlAria","z","useGenerativeUIAccessibility","React","toJsonSchema","createGenerativeUI"],"sources":["../src/generative-ui/refs.ts","../src/generative-ui/catalog-export.ts","../src/generative-ui/GenerativeUISurface.tsx","../src/generative-ui/standard/overlay-stack.ts","../src/generative-ui/standard/tokens.ts","../src/generative-ui/standard/lightbox.tsx","../src/generative-ui/standard/styles.ts","../src/generative-ui/standard/layout.tsx","../src/generative-ui/standard/markdown.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/parameter-order.ts","../src/generative-ui/standard/index.ts"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport * as z from \"zod\";\nimport {\n A2UI_CHILD_LIST_MARK,\n A2UI_COMPONENT_ID_MARK,\n} from \"@copilotkit/shared\";\n\n/**\n * Schema helpers that mark a prop as a component reference, the way A2UI\n * 1.0 marks it with the `ComponentId` and `ChildList` common types. The\n * engine finds every marked prop in the props schema, at any depth, renders\n * the referenced components, and hands the component the rendered nodes in\n * place of the ids. The model sees the prop as `componentId` or as a list\n * of ids or a template.\n *\n * @example\n * ```ts\n * const tabsSchema = z.object({\n * tabs: z.array(z.object({ title: z.string(), child: child() })),\n * });\n * // The component gets `tabs: { title: string; child: ReactNode }[]`.\n * ```\n */\n\nconst toNode = (value: unknown) => value as ReactNode;\nconst mark = (prefix: string, description: string | undefined) =>\n description ? `${prefix} ${description}` : prefix;\n\n/**\n * One component id. The component receives the rendered child. Pass the\n * description here, not with `.describe()`, which would replace the mark.\n */\nexport function child(description?: string) {\n return z\n .string()\n .min(1)\n .describe(mark(A2UI_COMPONENT_ID_MARK, description))\n .transform(toNode);\n}\n\n/**\n * A list of component ids, or a template `{ componentId, path }` that\n * repeats one component for each item of the list at `path`. The\n * component receives the rendered children. Pass the description here,\n * not with `.describe()`.\n */\nexport function childList(description?: string) {\n return z\n .union([\n z.array(z.string().min(1)),\n z.object({ componentId: z.string().min(1), path: z.string().min(1) }),\n ])\n .describe(mark(A2UI_CHILD_LIST_MARK, description))\n .transform(toNode);\n}\n","import {\n A2UI_CHILD_LIST_REF,\n A2UI_COMPONENT_ID_REF,\n GENERATIVE_UI_FUNCTIONS,\n childRefKind,\n functionCallers,\n} from \"@copilotkit/shared\";\nimport type {\n A2UIAllowedCallers,\n A2UIFunctionPermissions,\n GenerativeUIComponentManifest,\n GenerativeUIJSONSchema,\n} from \"@copilotkit/shared\";\nimport type { GenerativeUI } from \"./catalog\";\nimport { toJsonSchema } from \"./json-schema\";\nimport { isRecord } from \"./is-record\";\n\nconst COMMON = \"common_types.json#/$defs/\";\nconst DATA_BINDING_REF = `${COMMON}DataBinding`;\nconst FUNCTION_CALL_REF = `${COMMON}FunctionCall`;\nconst ACTION_REF = `${COMMON}Action`;\nconst DYNAMIC_REFS: Record<string, string> = {\n string: `${COMMON}DynamicString`,\n number: `${COMMON}DynamicNumber`,\n boolean: `${COMMON}DynamicBoolean`,\n \"string[]\": `${COMMON}DynamicStringList`,\n unknown: `${COMMON}DynamicValue`,\n};\n\n/** What `exportA2UICatalog` adds at the top of the catalog. */\nexport interface ExportA2UICatalogOptions {\n /** The title of the catalog. */\n title?: string;\n /** What the catalog is for. */\n description?: string;\n /** Markdown design guidelines for a model that writes this catalog. */\n instructions?: string;\n}\n\n/**\n * The A2UI 1.0 catalog definition of a generative UI, as a JSON value that\n * follows `catalog_definition.json`: one `components` entry per component,\n * with `component` as a `const`, `functions` for the built-ins and the\n * declared functions, and `$defs.anyComponent` / `$defs.anyFunction`. Other\n * A2UI tools (a validator, another renderer, a prompt builder) read it.\n *\n * - A prop that `child()` or `childList()` marks is a `ComponentId` or a\n * `ChildList` reference; so is a slot. An event prop is an `Action`.\n * - Every other value, at any depth of a prop or of the args of a declared\n * function, takes its literal schema, a `DataBinding` or a `FunctionCall`,\n * because the renderer resolves dynamic values at any depth.\n * - Every function states `returnType` and `allowedCallers`: the built-ins\n * are `rendererOnly`, and so is a declared function without\n * `allowedCallers`, as in A2UI 1.0.\n *\n * @param ui - The generative UI to describe.\n * @param options - The title, description and instructions of the catalog.\n *\n * @example\n * ```ts\n * const catalog = exportA2UICatalog(shopUI, { title: \"Acme shop\" });\n * fs.writeFileSync(\"shop-catalog.json\", JSON.stringify(catalog, null, 2));\n * ```\n */\nexport function exportA2UICatalog(\n ui: GenerativeUI,\n options: ExportA2UICatalogOptions = {},\n) {\n const components = Object.fromEntries(\n Object.entries(ui.manifestComponents).map(([name, manifest]) => [\n name,\n toDraft2020(\n rebaseRefs(\n componentDefinition(name, manifest),\n `#/components/${pointerSegment(name)}`,\n ),\n ),\n ]),\n );\n const functions: Record<string, GenerativeUIJSONSchema> = {};\n for (const [name, info] of Object.entries(GENERATIVE_UI_FUNCTIONS)) {\n // A declared function of the same name is the app's.\n if (ui.functions.has(name)) continue;\n functions[name] = functionEntry(name, info, {\n description: info.description,\n returnType: info.returnType,\n args: argsSchemaFromSignature(info.parameters),\n });\n }\n for (const [name, fn] of ui.functions) {\n functions[name] = functionEntry(name, fn, {\n description: fn.description,\n returnType: fn.returnType ?? \"any\",\n args: toDraft2020(\n rebaseRefs(\n dynamicArgs(toJsonSchema(fn.parameters)),\n `#/functions/${pointerSegment(name)}/properties/args`,\n ),\n ),\n });\n }\n const { title, description, instructions } = options;\n return {\n $schema: \"https://json-schema.org/draft/2020-12/schema\",\n protocolVersion: \"1.0\",\n catalogId: ui.id,\n ...(title === undefined ? {} : { title }),\n ...(description === undefined ? {} : { description }),\n ...(instructions === undefined ? {} : { instructions }),\n components,\n functions,\n $defs: {\n anyComponent: {\n ...oneOfRefs(\"components\", Object.keys(components)),\n discriminator: { propertyName: \"component\" },\n },\n anyFunction: oneOfRefs(\"functions\", Object.keys(functions)),\n },\n };\n}\n\n/**\n * `oneOf` over the entries of a section. JSON Schema wants at least one\n * variant, so an empty section (a UI with no components) matches nothing.\n */\nfunction oneOfRefs(section: string, names: string[]) {\n if (names.length === 0) return { not: {} };\n return {\n oneOf: names.map((name) => ({\n $ref: `#/${section}/${pointerSegment(name)}`,\n })),\n };\n}\n\n/** A name as a JSON Pointer segment in a URI fragment: `acme/Card` is `acme~1Card`. */\nfunction pointerSegment(name: string) {\n return encodeURIComponent(name.replace(/~/g, \"~0\").replace(/\\//g, \"~1\"));\n}\n\n/** Keywords whose value is data, not a schema. */\nconst LITERAL_KEYWORDS = new Set([\"default\", \"const\", \"enum\", \"examples\"]);\n\n/**\n * A schema in the draft 2020-12 dialect that the catalog declares. The\n * converter writes draft-07, where a tuple is `items: [...]` with\n * `additionalItems`; 2020-12 spells that `prefixItems` and `items`.\n */\nfunction toDraft2020(schema: GenerativeUIJSONSchema): GenerativeUIJSONSchema {\n return mapSchema(schema, (node) => {\n const { items, additionalItems, ...rest } = node;\n if (!Array.isArray(items)) return node;\n return {\n ...rest,\n prefixItems: items,\n ...(additionalItems === undefined ? {} : { items: additionalItems }),\n };\n });\n}\n\n/** One `components` entry: the props as the model sets them, with the A2UI common types. */\nfunction componentDefinition(\n name: string,\n manifest: GenerativeUIComponentManifest,\n): GenerativeUIJSONSchema {\n const { properties, required, description, $defs, definitions } =\n manifest.props;\n const props = Object.fromEntries(\n Object.entries(isRecord(properties) ? properties : {}).map(\n ([key, schema]) => [key, dynamicProp(schema)],\n ),\n );\n const events = Object.fromEntries(\n Object.entries(manifest.events ?? {}).map(([key, event]) => [\n key,\n {\n $ref: ACTION_REF,\n ...(event.description ? { description: event.description } : {}),\n },\n ]),\n );\n const slots = Object.fromEntries(\n Object.entries(manifest.slots ?? {}).map(([key, kind]) => [\n key,\n { $ref: kind === \"single\" ? A2UI_COMPONENT_ID_REF : A2UI_CHILD_LIST_REF },\n ]),\n );\n const fields = { ...props, ...events, ...slots };\n const orderedFields =\n manifest.parameterOrder === undefined\n ? fields\n : Object.fromEntries(\n [...new Set([...manifest.parameterOrder, ...Object.keys(fields)])]\n .filter((key) => Object.hasOwn(fields, key))\n .map((key) => [key, fields[key]]),\n );\n const text = manifest.description ?? description;\n return {\n type: \"object\",\n ...(typeof text === \"string\" ? { description: text } : {}),\n properties: { component: { const: name }, ...orderedFields },\n required: [\n \"component\",\n ...(Array.isArray(required) ? required.filter(isString) : []),\n ],\n // The definitions of the props schema, when its converter made some:\n // their values are dynamic like the props, and the references to them\n // are rebased onto this entry.\n ...withDynamicChildren({\n ...(isRecord($defs) ? { $defs } : {}),\n ...(isRecord(definitions) ? { definitions } : {}),\n }),\n };\n}\n\n/**\n * The schema with its local references (`#/...`) pointing into the place\n * it is embedded at. A converter that writes `$defs` refers to them from\n * the root of its own document; inside the catalog, that root is `base`.\n */\nfunction rebaseRefs(\n schema: GenerativeUIJSONSchema,\n base: string,\n): GenerativeUIJSONSchema {\n return mapSchema(schema, (node) => {\n const ref = node.$ref;\n // \"#\" is the root of the embedded schema (a recursive one refers to it).\n if (ref === \"#\") return { ...node, $ref: base };\n if (typeof ref === \"string\" && ref.startsWith(\"#/\")) {\n return { ...node, $ref: `${base}${ref.slice(1)}` };\n }\n return node;\n });\n}\n\n/** Keywords whose value is a map from a name to a schema. */\nconst SCHEMA_MAP_KEYWORDS = new Set([\n \"properties\",\n \"patternProperties\",\n \"$defs\",\n \"definitions\",\n \"dependentSchemas\",\n]);\n\n/**\n * Walks a JSON Schema and rebuilds each schema node with `transform`, the\n * children first. The names in `properties` and the definition maps are\n * names, not keywords: a prop called `default` is a schema, while the\n * `default` of a schema is data and stays as it is.\n */\nfunction mapSchema(\n schema: GenerativeUIJSONSchema,\n transform: (node: Record<string, unknown>) => Record<string, unknown>,\n): GenerativeUIJSONSchema {\n const visitValue = (value: unknown): unknown => {\n if (Array.isArray(value)) return value.map(visitValue);\n return isRecord(value) ? visitNode(value) : value;\n };\n const visitNode = (\n node: Record<string, unknown>,\n ): Record<string, unknown> => {\n const result: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(node)) {\n if (LITERAL_KEYWORDS.has(key)) result[key] = value;\n else if (SCHEMA_MAP_KEYWORDS.has(key) && isRecord(value)) {\n result[key] = Object.fromEntries(\n Object.entries(value).map(([name, entry]) => [\n name,\n isRecord(entry) ? visitNode(entry) : entry,\n ]),\n );\n } else result[key] = visitValue(value);\n }\n return transform(result);\n };\n return visitNode(schema) as GenerativeUIJSONSchema;\n}\n\nconst isString = (value: unknown): value is string => typeof value === \"string\";\n\n/**\n * A prop as the catalog states it. A component reference stays one. Any\n * other value takes its literal schema, a data binding or a function call,\n * and so does every value inside it: the properties of an object, the\n * values of a record and the items of a list, because the renderer\n * resolves dynamic values at any depth. The variants of a union are\n * transformed in place.\n */\nfunction dynamicProp(schema: unknown): GenerativeUIJSONSchema {\n if (!isRecord(schema)) return { $ref: DYNAMIC_REFS.unknown };\n if (childRefKind(schema)) return schema;\n const { description, ...literal } = withDynamicChildren(schema);\n return {\n ...(typeof description === \"string\" ? { description } : {}),\n anyOf: [literal, { $ref: DATA_BINDING_REF }, { $ref: FUNCTION_CALL_REF }],\n };\n}\n\n/** The schema with its nested values made dynamic, itself unchanged. */\nfunction withDynamicChildren(\n schema: Record<string, unknown>,\n): Record<string, unknown> {\n const result = { ...schema };\n if (isRecord(schema.properties)) {\n result.properties = Object.fromEntries(\n Object.entries(schema.properties).map(([key, value]) => [\n key,\n dynamicProp(value),\n ]),\n );\n }\n if (isRecord(schema.items)) result.items = dynamicProp(schema.items);\n // A tuple, as the converter writes it; the catalog spells it prefixItems.\n if (Array.isArray(schema.items)) {\n result.items = schema.items.map((item) =>\n isRecord(item) ? dynamicProp(item) : item,\n );\n }\n if (isRecord(schema.additionalItems)) {\n result.additionalItems = dynamicProp(schema.additionalItems);\n }\n // The definitions a converter wrote: referenced from value positions.\n for (const key of [\"$defs\", \"definitions\"] as const) {\n const defs = schema[key];\n if (isRecord(defs)) {\n result[key] = Object.fromEntries(\n Object.entries(defs).map(([name, def]) => [\n name,\n isRecord(def) ? withDynamicChildren(def) : def,\n ]),\n );\n }\n }\n if (Array.isArray(schema.allOf)) {\n result.allOf = schema.allOf.map((part) =>\n isRecord(part) ? withDynamicChildren(part) : part,\n );\n }\n // The values of a record, by any key or by key pattern.\n if (isRecord(schema.additionalProperties)) {\n result.additionalProperties = dynamicProp(schema.additionalProperties);\n }\n if (isRecord(schema.patternProperties)) {\n result.patternProperties = Object.fromEntries(\n Object.entries(schema.patternProperties).map(([pattern, value]) => [\n pattern,\n dynamicProp(value),\n ]),\n );\n }\n for (const key of [\"anyOf\", \"oneOf\"] as const) {\n const variants = schema[key];\n if (Array.isArray(variants)) {\n result[key] = variants.map((variant) =>\n isRecord(variant) && !childRefKind(variant)\n ? withDynamicChildren(variant)\n : variant,\n );\n }\n }\n return result;\n}\n\n/**\n * The args of a declared function as the catalog states them: the object\n * stays an object, each arg takes a value, a binding or a function call.\n */\nfunction dynamicArgs(schema: GenerativeUIJSONSchema): GenerativeUIJSONSchema {\n return withDynamicChildren(schema);\n}\n\n/** One `functions` entry, in the A2UI `FunctionDefinition` shape. */\nfunction functionEntry(\n name: string,\n permissions: A2UIFunctionPermissions,\n parts: {\n description: string | undefined;\n returnType: string;\n args: GenerativeUIJSONSchema;\n },\n): GenerativeUIJSONSchema {\n const callers = functionCallers(permissions);\n const allowedCallers: A2UIAllowedCallers =\n callers.renderer && callers.agent\n ? \"rendererOrAgent\"\n : callers.agent\n ? \"agentOnly\"\n : \"rendererOnly\";\n // The metaschema's activation rule has no `required`, so it also matches\n // an entry without the key: the value is always written out.\n // `args` is required only when an arg is.\n const argsRequired = hasRequiredArgs(parts.args);\n return {\n type: \"object\",\n ...(parts.description ? { description: parts.description } : {}),\n returnType: parts.returnType,\n allowedCallers,\n requiresUserActivation: permissions.requiresUserActivation === true,\n properties: { \"@call\": { const: name }, args: parts.args },\n required: argsRequired ? [\"@call\", \"args\"] : [\"@call\"],\n };\n}\n\n/**\n * True when an empty args object fails the schema: a key is required at\n * its top, in an `allOf` part, or in every variant of an `anyOf` / `oneOf`.\n */\nfunction hasRequiredArgs(schema: unknown): boolean {\n if (!isRecord(schema)) return false;\n if (Array.isArray(schema.required) && schema.required.length > 0) return true;\n if (Array.isArray(schema.allOf) && schema.allOf.some(hasRequiredArgs)) {\n return true;\n }\n for (const key of [\"anyOf\", \"oneOf\"] as const) {\n const variants = schema[key];\n if (Array.isArray(variants) && variants.length > 0) {\n if (variants.every(hasRequiredArgs)) return true;\n }\n }\n return false;\n}\n\n/**\n * The JSON Schema of the args of a built-in function, from its short\n * TypeScript-like signature (`{ value: number; decimals?: number }`). Each\n * arg takes a literal, a binding or a function call, so a type maps to the\n * A2UI dynamic type; `[name: string]: T` becomes `additionalProperties`.\n *\n * @example\n * ```ts\n * argsSchemaFromSignature(\"{ value: string; min?: number }\");\n * // { type: \"object\", properties: { value: { $ref: \".../DynamicString\" }, min: { $ref: \".../DynamicNumber\" } }, required: [\"value\"], additionalProperties: false }\n * ```\n */\nexport function argsSchemaFromSignature(\n signature: string,\n): GenerativeUIJSONSchema {\n const body = signature.trim().replace(/^\\{/, \"\").replace(/\\}$/, \"\");\n const properties: Record<string, GenerativeUIJSONSchema> = {};\n const required: string[] = [];\n let additionalProperties: GenerativeUIJSONSchema | false = false;\n for (const part of body.split(\";\")) {\n const field = part.trim();\n if (field === \"\") continue;\n const index = field.match(/^\\[\\w+: string\\]:\\s*(.+)$/);\n if (index) {\n additionalProperties = typeSchema(index[1]);\n continue;\n }\n const named = field.match(/^(\\w+)(\\?)?:\\s*(.+)$/);\n if (!named) continue;\n properties[named[1]] = typeSchema(named[3]);\n if (!named[2]) required.push(named[1]);\n }\n return {\n type: \"object\",\n properties,\n ...(required.length > 0 ? { required } : {}),\n additionalProperties,\n };\n}\n\nfunction typeSchema(type: string): GenerativeUIJSONSchema {\n const trimmed = type.trim();\n const alternatives = trimmed.split(\"|\").map((part) => part.trim());\n if (alternatives.length > 1) return { anyOf: alternatives.map(typeSchema) };\n if (trimmed in DYNAMIC_REFS) return { $ref: DYNAMIC_REFS[trimmed] };\n if (trimmed.endsWith(\"[]\")) {\n // The whole list can be bound or computed, like any other arg.\n return {\n anyOf: [\n { type: \"array\", items: typeSchema(trimmed.slice(0, -2)) },\n { $ref: DATA_BINDING_REF },\n { $ref: FUNCTION_CALL_REF },\n ],\n };\n }\n return { $ref: DYNAMIC_REFS.unknown };\n}\n","import React, { useEffect, useLayoutEffect, useRef } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { GENERATIVE_UI_MAX_TARGET_COMPONENTS } from \"@copilotkit/shared\";\nimport type { GenerativeUI, GenerativeUIComponentName } from \"./catalog\";\nimport { useManagerVersion } from \"./hooks\";\nimport { useRequiredGenerativeUIRuntime } from \"./runtime-context\";\nimport { SurfaceView } from \"./SurfaceView\";\n\ninterface GenerativeUISurfaceBaseProps {\n /** Target id the agent renders into. */\n id: string;\n /**\n * Tells the model where this surface is and what to show in it, for\n * example \"Next to the product list. Use it for product recommendations.\"\n */\n description?: string;\n /** Shown until a surface targets this id. */\n fallback?: ReactNode;\n className?: string;\n /**\n * Scrolls the page to this surface when the agent starts to render into\n * it, unless the surface is already on screen. Defaults to `true`. With a\n * sticky header, give the surface a `scroll-margin-top`\n * (`[data-generative-ui-surface] { scroll-margin-top: 5rem }`).\n */\n autoScroll?: boolean;\n}\n\n/** Scrolls `element` into view, unless it is already fully on screen. */\nfunction scrollToSurface(element: HTMLElement) {\n const { top, bottom } = element.getBoundingClientRect();\n if (top >= 0 && bottom <= window.innerHeight) return;\n const reduceMotion = window.matchMedia?.(\n \"(prefers-reduced-motion: reduce)\",\n ).matches;\n // jsdom has no scrollIntoView.\n element.scrollIntoView?.({\n behavior: reduceMotion ? \"auto\" : \"smooth\",\n block: \"start\",\n });\n}\n\n/**\n * Props of {@link GenerativeUISurface}. `components` takes `ui`, which\n * types the component names.\n */\nexport type GenerativeUISurfaceProps<\n UI extends GenerativeUI<any> = GenerativeUI<any>,\n> = GenerativeUISurfaceBaseProps &\n (\n | {\n /**\n * The UI of the provider (`generativeUI.ui`). It types the names in\n * `components`.\n */\n ui: UI;\n /**\n * The only components that the agent can use in this surface, the\n * root included. The agent gets the list, and an operation with\n * another component is rejected. Left out, every component of the UI\n * is allowed.\n */\n components?: readonly GenerativeUIComponentName<UI>[];\n }\n | { ui?: undefined; components?: undefined }\n );\n\nconst isDevelopment = () => process.env.NODE_ENV !== \"production\";\n\n/**\n * The names of `requested` that `ui` has, without repeats, at most the\n * number that the envelope takes. `warning` tells what was dropped.\n */\nfunction allowedComponents(requested: readonly string[], ui: GenerativeUI) {\n const unique = [...new Set(requested)];\n const unknown = unique.filter((name) => !ui.components.has(name));\n const known = unique.filter((name) => ui.components.has(name));\n const names = known.slice(0, GENERATIVE_UI_MAX_TARGET_COMPONENTS);\n const problems: string[] = [];\n if (unknown.length > 0) {\n problems.push(\n `these components are not in the UI and are ignored: ${unknown.join(\", \")}`,\n );\n }\n if (known.length > names.length) {\n problems.push(\n `only the first ${GENERATIVE_UI_MAX_TARGET_COMPONENTS} components are used`,\n );\n }\n return { names, warning: problems.join(\"; \") };\n}\n\n/**\n * Experimental. A named place on the page where the agent can render UI.\n *\n * @example\n * ```tsx\n * <GenerativeUISurface\n * id=\"products\"\n * ui={storeUI}\n * description=\"The product list. Show the products that the user asks for.\"\n * components={[\"ProductRow\", \"ProductCard\"]}\n * fallback={<FeaturedProducts />}\n * />\n * ```\n */\nexport function GenerativeUISurface<\n UI extends GenerativeUI<any> = GenerativeUI<any>,\n>({\n id,\n description,\n ui,\n components,\n fallback = null,\n className,\n autoScroll = true,\n}: GenerativeUISurfaceProps<UI>) {\n const runtime = useRequiredGenerativeUIRuntime();\n useManagerVersion(runtime);\n // The agent renders only the components of the provider's UI, so the\n // names are checked against it. A different `ui` is a setup mistake.\n const otherUI = ui !== undefined && ui !== runtime.ui;\n useLayoutEffect(() => {\n if (otherUI && isDevelopment()) {\n console.warn(\n `[generativeUI] <GenerativeUISurface id=\"${id}\">: the ui prop is not the UI of the provider (generativeUI.ui). The components are checked against the UI of the provider.`,\n );\n }\n }, [otherUI, id]);\n // A new array with the same names must not register the target again.\n const componentsKey =\n components === undefined ? undefined : JSON.stringify(components);\n const warnedKey = useRef<string | undefined>(undefined);\n useLayoutEffect(() => {\n const requested: string[] | undefined =\n componentsKey === undefined ? undefined : JSON.parse(componentsKey);\n const allowed = requested && allowedComponents(requested, runtime.ui);\n const shouldWarn =\n allowed !== undefined &&\n allowed.warning !== \"\" &&\n warnedKey.current !== componentsKey &&\n isDevelopment();\n if (shouldWarn) {\n warnedKey.current = componentsKey;\n console.warn(\n `[generativeUI] <GenerativeUISurface id=\"${id}\">: ${allowed.warning}.`,\n );\n }\n return runtime.manager.registerTarget(id, {\n description,\n components: allowed?.names,\n });\n }, [runtime, id, description, componentsKey]);\n const surface = runtime.manager.getSurfaceForTarget(id);\n // Every render_ui call (and every streaming markdown fence) sets the\n // status to \"streaming\", for a new surface and for an update. The key is\n // set only while the surface streams, so each start runs the effect once.\n const generatingKey =\n surface?.status === \"streaming\" ? surface.key : undefined;\n const element = useRef<HTMLDivElement>(null);\n useEffect(() => {\n if (autoScroll && generatingKey && element.current) {\n scrollToSurface(element.current);\n }\n }, [autoScroll, generatingKey]);\n if (!surface) return <>{fallback}</>;\n return (\n <div ref={element} data-generative-ui-surface={id} className={className}>\n <SurfaceView surface={surface} />\n </div>\n );\n}\n","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","/**\n * Design tokens of the standard components. Each token is a CSS variable\n * with a literal fallback, so a host can restyle a surface with the\n * `--a2ui-*` variables. A value that is not a token passes through as raw\n * CSS.\n */\n\n/** Id of `standardUI`, the catalog id the model writes in createSurface. */\nexport const STANDARD_CATALOG_ID = \"copilotkit/standard@1\";\n\nexport const TITLE_SIZES = [\n \"sm\",\n \"md\",\n \"lg\",\n \"xl\",\n \"2xl\",\n \"3xl\",\n \"4xl\",\n \"5xl\",\n] as const;\nexport const TEXT_SIZES = [\"3xs\", \"2xs\", \"xs\", \"sm\", \"md\", \"lg\"] as const;\nexport const WEIGHTS = [\"normal\", \"medium\", \"semibold\", \"bold\"] as const;\nexport const ALIGN = [\"start\", \"center\", \"end\", \"baseline\", \"stretch\"] as const;\nexport const JUSTIFY = [\n \"start\",\n \"center\",\n \"end\",\n \"spaceBetween\",\n \"spaceAround\",\n \"spaceEvenly\",\n \"stretch\",\n] as const;\nexport const WRAP = [\"nowrap\", \"wrap\", \"wrap-reverse\"] as const;\nexport const RADII = [\n \"2xs\",\n \"xs\",\n \"sm\",\n \"md\",\n \"lg\",\n \"xl\",\n \"2xl\",\n \"3xl\",\n \"4xl\",\n \"full\",\n] as const;\nexport const TEXT_COLORS = [\n \"default\",\n \"prose\",\n \"primary\",\n \"emphasis\",\n \"secondary\",\n \"tertiary\",\n \"success\",\n \"info\",\n \"warning\",\n \"caution\",\n \"danger\",\n \"discovery\",\n] as const;\nexport const BORDER_COLORS = [\n \"default\",\n \"subtle\",\n \"strong\",\n \"info\",\n \"warning\",\n \"caution\",\n \"success\",\n \"danger\",\n \"discovery\",\n] as const;\nexport const BACKGROUNDS = [\n \"surface\",\n \"surface-secondary\",\n \"surface-tertiary\",\n \"surface-elevated\",\n \"surface-elevated-secondary\",\n \"surface-inverted\",\n \"surface-soft\",\n \"info\",\n \"warning\",\n \"caution\",\n \"success\",\n \"danger\",\n \"discovery\",\n \"info-solid\",\n \"warning-solid\",\n \"caution-solid\",\n \"success-solid\",\n \"danger-solid\",\n \"discovery-solid\",\n] as const;\n\nexport type TitleSize = (typeof TITLE_SIZES)[number];\nexport type TextSize = (typeof TEXT_SIZES)[number];\nexport type Weight = (typeof WEIGHTS)[number];\nexport type Radius = (typeof RADII)[number];\n\nconst RADIUS_PX: Record<Radius, string> = {\n \"2xs\": \"2px\",\n xs: \"4px\",\n sm: \"6px\",\n md: \"8px\",\n lg: \"12px\",\n xl: \"16px\",\n \"2xl\": \"20px\",\n \"3xl\": \"24px\",\n \"4xl\": \"32px\",\n full: \"9999px\",\n};\nconst TEXT_COLOR_FALLBACK: Record<string, string> = {\n default: \"#0d0d0d\",\n prose: \"#0d0d0d\",\n primary: \"#0d0d0d\",\n emphasis: \"#000\",\n secondary: \"#5d5d5d\",\n tertiary: \"#8e8e8e\",\n success: \"#00805d\",\n info: \"#0068bc\",\n warning: \"#946200\",\n caution: \"#946200\",\n danger: \"#c1322c\",\n discovery: \"#7040c1\",\n};\nconst BG_FALLBACK: Record<string, string> = {\n surface: \"#fff\",\n \"surface-secondary\": \"#f7f7f8\",\n \"surface-tertiary\": \"#ececec\",\n \"surface-elevated\": \"#fff\",\n \"surface-elevated-secondary\": \"#f7f7f8\",\n \"surface-inverted\": \"#0d0d0d\",\n \"surface-soft\": \"#fcfcfc\",\n // A semantic tint is a hint, not a block: the text color at low alpha.\n info: \"rgba(0, 104, 188, 0.08)\",\n warning: \"rgba(148, 98, 0, 0.08)\",\n caution: \"rgba(148, 98, 0, 0.08)\",\n success: \"rgba(0, 128, 93, 0.08)\",\n danger: \"rgba(193, 50, 44, 0.08)\",\n discovery: \"rgba(112, 64, 193, 0.08)\",\n \"info-solid\": \"#0068bc\",\n \"warning-solid\": \"#946200\",\n \"caution-solid\": \"#946200\",\n \"success-solid\": \"#00805d\",\n \"danger-solid\": \"#c1322c\",\n \"discovery-solid\": \"#7040c1\",\n};\nconst BORDER_FALLBACK: Record<string, string> = {\n default: \"rgba(0, 0, 0, 0.1)\",\n subtle: \"rgba(0, 0, 0, 0.05)\",\n strong: \"#cdcdcd\",\n info: \"#9cc4ea\",\n warning: \"#e6c98a\",\n caution: \"#e6c98a\",\n success: \"#9ad9c3\",\n danger: \"#eeaaa6\",\n discovery: \"#c8b4ea\",\n};\n\nfunction hasToken<Key extends string>(\n table: Record<Key, string>,\n key: string,\n): key is Key {\n return Object.hasOwn(table, key);\n}\n\n/** A number is a count of 4px steps. A string passes through as CSS. */\nexport function spacing(value: number | string | undefined) {\n if (value === undefined) return undefined;\n return typeof value === \"number\"\n ? `calc(var(--spacing, 0.25rem) * ${value})`\n : value;\n}\n\n/** A radius token, a number of pixels, or raw CSS. */\nexport function radius(value: string | number | undefined) {\n if (value === undefined) return undefined;\n if (typeof value === \"number\") return `${value}px`;\n if (value === \"full\") return \"9999px\";\n return hasToken(RADIUS_PX, value)\n ? `var(--a2ui-radius-${value}, ${RADIUS_PX[value]})`\n : value;\n}\n\n/** A text color token, or a raw CSS color. */\nexport function textColor(value: string | undefined) {\n if (!value) return undefined;\n return hasToken(TEXT_COLOR_FALLBACK, value)\n ? `var(--a2ui-color-text-${value}, ${TEXT_COLOR_FALLBACK[value]})`\n : value;\n}\n\n/** A background token, or a raw CSS color. */\nexport function backgroundColor(value: string | undefined) {\n if (!value) return undefined;\n return hasToken(BG_FALLBACK, value)\n ? `var(--a2ui-color-${value}, ${BG_FALLBACK[value]})`\n : value;\n}\n\n/** The one inner panel of a Card: near-white fill. */\nexport const INNER_PANEL_BG = \"var(--a2ui-color-panel, rgb(252, 252, 252))\";\nconst SOFT_TINT: Record<string, string> = {\n info: \"rgba(0, 104, 188, 0.06)\",\n warning: \"rgba(148, 98, 0, 0.06)\",\n caution: \"rgba(148, 98, 0, 0.06)\",\n success: \"rgba(0, 128, 93, 0.06)\",\n danger: \"rgba(193, 50, 44, 0.06)\",\n discovery: \"rgba(112, 64, 193, 0.06)\",\n};\n\n/**\n * The background of a panel inside a Card. A neutral surface becomes the\n * near-white inner panel. A semantic tint gets lighter (about 6% alpha).\n * Solid and raw values go through `backgroundColor`.\n */\nexport function panelBackground(value: string | undefined) {\n if (!value) return undefined;\n const isNeutral =\n value === \"surface-secondary\" ||\n value === \"surface-soft\" ||\n value === \"surface-elevated-secondary\";\n if (isNeutral) return INNER_PANEL_BG;\n return hasToken(SOFT_TINT, value)\n ? `var(--a2ui-color-${value}-soft, ${SOFT_TINT[value]})`\n : backgroundColor(value);\n}\n\n/** A border color token, or a raw CSS color. */\nexport function borderColor(value: string | undefined) {\n if (!value) return undefined;\n return hasToken(BORDER_FALLBACK, value)\n ? `var(--a2ui-color-border-${value}, ${BORDER_FALLBACK[value]})`\n : value;\n}\n\n/**\n * The type scale at a 16px base, in em, so a surface scales with the font\n * size of the host: title lg = 18/28, 2xl = 24/32; text md = 16/26,\n * sm = 14/20, xs = 12/16, 3xs = 10/12. Line heights are unitless ratios.\n */\nconst TITLE_SCALE: Record<TitleSize, [string, number]> = {\n sm: [\".875em\", 1.429],\n md: [\"1em\", 1.5],\n lg: [\"1.125em\", 1.556],\n xl: [\"1.25em\", 1.4],\n \"2xl\": [\"1.5em\", 1.333],\n \"3xl\": [\"1.875em\", 1.2],\n \"4xl\": [\"2.25em\", 1.111],\n \"5xl\": [\"3em\", 1.083],\n};\nconst TEXT_SCALE: Record<TextSize, [string, number]> = {\n \"3xs\": [\".625em\", 1.2],\n \"2xs\": [\".6875em\", 1.273],\n xs: [\".75em\", 1.333],\n sm: [\".875em\", 1.429],\n md: [\"1em\", 1.625],\n lg: [\"1.125em\", 1.556],\n};\n\n/** Text on an accent fill (solid buttons and badges, selected segments). */\nexport const ON_ACCENT = \"var(--a2ui-color-on-accent, #fff)\";\n/** The fill of a control (checkbox, radio, slider thumb, selected segment). */\nexport const CONTROL_BG = \"var(--a2ui-color-control, #fff)\";\nexport const SHADOW_XS = \"var(--a2ui-shadow-xs, 0 1px 2px rgba(0,0,0,.12))\";\nexport const SHADOW_SM = \"var(--a2ui-shadow-sm, 0 1px 3px rgba(0,0,0,.12))\";\nexport const SHADOW_SOFT = \"var(--a2ui-shadow-soft, 0 1px 3px rgba(0,0,0,.06))\";\nexport const SHADOW_MD = \"var(--a2ui-shadow-md, 0 4px 12px rgba(0,0,0,.08))\";\n/** The scrim behind a lightbox or modal. */\nexport const BACKDROP = \"var(--a2ui-color-backdrop, rgba(0,0,0,.8))\";\n/** The moving highlight of a shimmer placeholder. */\nexport const SHIMMER_HIGHLIGHT =\n \"var(--a2ui-color-shimmer, rgba(255,255,255,.55))\";\n/** The hover band behind a chart column. */\nexport const CHART_CURSOR = \"var(--a2ui-color-chart-cursor, rgba(0,0,0,.04))\";\n/**\n * Chart series colors: a soft blue family first, then muted companions, so\n * a chart with many series stays easy to read. A host can change each one\n * with `--a2ui-chart-1`, `--a2ui-chart-2`, and so on.\n */\nconst CHART_PALETTE_FALLBACK = [\n \"#7fb0f2\",\n \"#2f6fd1\",\n \"#b7cff7\",\n \"#8bb5a8\",\n \"#d9b36b\",\n \"#c08bb0\",\n];\nexport const CHART_PALETTE = CHART_PALETTE_FALLBACK.map(\n (hex, index) => `var(--a2ui-chart-${index + 1}, ${hex})`,\n);\n\n/**\n * A UI font stack. A surface inherits the font of the host. This value is\n * for hosts that want it (`font-family: var(--a2ui-font-family, ...)`).\n */\nexport const FONT_FAMILY =\n 'var(--a2ui-font-family, -apple-system, ui-sans-serif, system-ui, \"Segoe UI\", Helvetica, \"Apple Color Emoji\", Arial, sans-serif, \"Segoe UI Emoji\", \"Segoe UI Symbol\")';\n\n/** The heading scale in em. */\nexport function titleFont(size: TitleSize = \"md\") {\n const [fontSize, lineHeight] = TITLE_SCALE[size];\n return { fontSize, lineHeight, fontWeight: 600 };\n}\n\n/** The body text size, in em of the text around it. */\nexport function textFont(size: TextSize = \"md\") {\n const [fontSize, lineHeight] = TEXT_SCALE[size];\n return { fontSize, lineHeight };\n}\n\nexport const FONT_WEIGHT: Record<Weight, number> = {\n normal: 400,\n medium: 500,\n semibold: 600,\n bold: 700,\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 { BACKDROP, ON_ACCENT, SHADOW_MD, radius } from \"./tokens\";\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 { DARK_THEME_CSS } from \"../theme\";\nimport { borderColor, textColor, CONTROL_BG, SHADOW_XS } from \"./tokens\";\n\n/**\n * The stylesheet for what inline styles cannot do: pseudo-elements (slider\n * track and thumb, placeholder), `:checked` and `:first-child` states,\n * heading fallbacks, and resets for host prose styles. It is added once per\n * document.\n *\n * Typography is inherited: a surface takes the font, size, line height and\n * color of the text around it (the chat prose). Headings take the heading\n * styles of the host.\n */\n\nexport const STANDARD_STYLE_ID = \"a2ui-standard-catalog\";\nexport const ACCENT = \"var(--a2ui-color-accent, #0d0d0d)\";\n\nconst FOCUS_RING = \"2px solid var(--a2ui-color-focus, #0285ff)\";\n\nconst CHECK_SVG =\n \"url(\\\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E\\\")\";\n\nconst SLIDER_TRACK = \"var(--a2ui-color-slider-track, rgba(0, 0, 0, 0.04))\";\nconst THUMB = `width:20px;height:20px;box-sizing:border-box;border-radius:9999px;background:${CONTROL_BG};border:1px solid ${borderColor(\"default\")};box-shadow:${SHADOW_XS};cursor:pointer`;\n\nexport const STANDARD_CSS = [\n // The built-in dark values, under a `.dark` class. Every theme rule wins\n // over them.\n DARK_THEME_CSS,\n // The surface (and its root component) never gets wider than the chat column.\n \".a2ui-surface{min-width:0;max-width:100%;box-sizing:border-box}\",\n // The surface inherits the font, size, line height and ink of the host.\n \".a2ui-surface{font:inherit;color:inherit}\",\n // Heading sizes only for hosts without heading styles (zero specificity).\n \":where(.a2ui-surface) :where(h2){font-size:1.5em;font-weight:600;line-height:1.3}\",\n \":where(.a2ui-surface) :where(h3){font-size:1.25em;font-weight:600;line-height:1.3}\",\n \":where(.a2ui-surface) :where(h4){font-size:1em;font-weight:600;line-height:1.4}\",\n // Controls never fall back to the UA font.\n \"[data-a2ui-std] :is(button,input,select,textarea),[data-a2ui-input]{font:inherit;color:inherit}\",\n // Key/value rows: the last text of a space-between row sits flush right.\n '[data-a2ui-row=\"spaceBetween\"]>[data-a2ui-text]:last-child:not(:first-child){text-align:right;margin-inline-start:auto}',\n `[data-a2ui-input]:focus-visible{outline:${FOCUS_RING};outline-offset:1px}`,\n // A scrollable container can take keyboard focus, so it shows a focus ring.\n `[data-a2ui-scroll]:focus-visible{outline:${FOCUS_RING};outline-offset:2px}`,\n `[data-a2ui-input]::placeholder{color:${textColor(\"tertiary\")};opacity:1}`,\n // Slider: 24px pill track, 2px inset white thumb (no filled range).\n `.a2ui-std-range{-webkit-appearance:none;appearance:none;display:block;width:100%;height:24px;margin:0;padding:0 2px;box-sizing:border-box;border-radius:9999px;background:${SLIDER_TRACK};cursor:pointer}`,\n \".a2ui-std-range:disabled{cursor:not-allowed;opacity:.5}\",\n \".a2ui-std-range::-webkit-slider-runnable-track{height:24px;background:transparent;border:0}\",\n `.a2ui-std-range::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;margin-top:2px;${THUMB}}`,\n \".a2ui-std-range::-moz-range-track{height:24px;background:transparent;border:0}\",\n `.a2ui-std-range::-moz-range-thumb{${THUMB}}`,\n // Checkbox and radio: 20px round control, filled when checked.\n `.a2ui-std-check{-webkit-appearance:none;appearance:none;flex-shrink:0;width:20px;height:20px;margin:0;box-sizing:border-box;border:1px solid ${borderColor(\"strong\")};border-radius:9999px;background:${CONTROL_BG} center/14px 14px no-repeat;cursor:pointer}`,\n '.a2ui-std-check[data-shape=\"square\"]{border-radius:6px}',\n `.a2ui-std-check:checked{background-color:${ACCENT};border-color:${ACCENT};background-image:${CHECK_SVG}}`,\n `.a2ui-std-check[type=\"radio\"]:checked{background-image:none;background-color:${CONTROL_BG};border:6px solid ${ACCENT}}`,\n \".a2ui-std-check:disabled{cursor:not-allowed}\",\n // Hosts often wrap chat markdown in a \"prose\" stylesheet (Tailwind\n // typography) that adds margins to headings, paragraphs, lists and tables.\n // A surface is an app panel spaced by gaps, so these rules remove those\n // margins. A Markdown component keeps them, because it reads like the chat\n // prose. The selector must be stronger than `.prose :where(h2)`. Hosts\n // change the margins with `--a2ui-heading-margin` and `--a2ui-block-margin`.\n \".a2ui-surface :is(h1,h2,h3,h4,h5,h6):not(.a2ui-markdown *){margin:var(--a2ui-heading-margin,0)}\",\n \".a2ui-surface :is(p,table,figure,figcaption,blockquote,pre):not(.a2ui-markdown *){margin:var(--a2ui-block-margin,0)}\",\n \".a2ui-markdown>:first-child{margin-top:0}\",\n \".a2ui-markdown>:last-child{margin-bottom:0}\",\n // Only the List component removes native bullets. Markdown keeps them.\n \".a2ui-surface :is(.a2ui-std-list,.a2ui-std-list>li){margin:0}\",\n \".a2ui-surface .a2ui-std-table{font-size:inherit;line-height:inherit}\",\n // Table: 8px cells, flush outer edges, hairline row dividers, no outer border.\n \".a2ui-std-table-wrap{width:100%;max-width:100%;min-width:0;overflow-x:auto}\",\n \".a2ui-std-cell{padding:8px}\",\n \".a2ui-std-cell:first-child{padding-inline-start:0}\",\n \".a2ui-std-cell:last-child{padding-inline-end:0}\",\n `.a2ui-std-cell[data-divider]{border-bottom:1px solid ${borderColor(\"subtle\")}}`,\n \".a2ui-std-table>tbody:last-child>tr:last-child>.a2ui-std-cell{border-bottom:0}\",\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/**\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, {\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 * as z from \"zod\";\nimport type { GenerativeUIInvokeResult } from \"../errors\";\nimport { child } from \"../refs\";\nimport { Lightbox, openUrl } from \"./lightbox\";\nimport type { LightboxImage } from \"./lightbox\";\nimport {\n ALIGN,\n BACKGROUNDS,\n BORDER_COLORS,\n INNER_PANEL_BG,\n JUSTIFY,\n RADII,\n SHADOW_MD,\n SHADOW_SM,\n SHADOW_SOFT,\n WRAP,\n backgroundColor,\n borderColor,\n panelBackground,\n radius,\n spacing,\n textColor,\n} from \"./tokens\";\nimport { namedRole, useGenerativeUIAccessibility } from \"../accessibility\";\nimport { useStandardStyles } from \"./styles\";\n\n// ---- Shared schemas ----\n\n/** A number is a count of 4px steps. A string is raw CSS. */\nexport const sizeValue = z.union([z.number(), z.string()]);\n\n/** The A2UI `weight`: how much of the free space of a Row or Column to take. */\nexport const weightProp = z\n .number()\n .optional()\n .describe(\"flex-grow in a Row or Column\");\n\nexport const radiusValue = z.union([\n z.enum(RADII),\n z.number(),\n z.string(),\n z.object({\n topLeft: z.string().optional(),\n topRight: z.string().optional(),\n bottomLeft: z.string().optional(),\n bottomRight: z.string().optional(),\n }),\n]);\n\n/**\n * The layout props of every container. Spread them into a props schema:\n * `z.object({ ...layoutProps, variant: ... })`. The children of a container\n * are a slot, not a prop.\n */\nexport const layoutProps = {\n align: z.enum(ALIGN).optional(),\n justify: z.enum(JUSTIFY).optional(),\n wrap: z.enum(WRAP).optional(),\n gap: sizeValue.optional().describe(\"4px steps when a number\"),\n rowGap: sizeValue.optional(),\n columnGap: sizeValue.optional(),\n padding: sizeValue.optional().describe(\"4px steps when a number\"),\n background: z\n .string()\n .optional()\n .describe(\n `One of ${BACKGROUNDS.join(\"|\")} or a CSS color. Leave it unset. Only one summary panel in a Card can use \"surface-secondary\"`,\n ),\n border: z.boolean().optional(),\n borderColor: z.enum(BORDER_COLORS).optional(),\n radius: radiusValue.optional(),\n width: sizeValue.optional(),\n height: sizeValue.optional(),\n minWidth: sizeValue.optional(),\n maxWidth: sizeValue.optional(),\n minHeight: sizeValue.optional(),\n maxHeight: sizeValue.optional(),\n flex: z.number().optional(),\n weight: weightProp,\n aspectRatio: z.string().optional(),\n scrollable: z.boolean().optional(),\n clip: z.boolean().optional(),\n shadow: z.boolean().optional(),\n inline: z.boolean().optional(),\n role: z.string().optional().describe(\"ARIA role\"),\n flush: z.boolean().optional().describe(\"No padding\"),\n minSize: sizeValue.optional().describe(\"Minimum width and height\"),\n maxSize: sizeValue.optional().describe(\"Maximum width and height\"),\n disableAutoSpacing: z\n .boolean()\n .optional()\n .describe(\"No default gap between children\"),\n};\n\nconst layoutSchema = z.object(layoutProps);\n\n/** The arguments of a click or visibility event: none. */\nconst NO_ARGS = z.object({});\n\ntype EventProp = (\n args: z.input<typeof NO_ARGS>,\n) => Promise<GenerativeUIInvokeResult>;\n\n/**\n * The `onVisible` event of every container: sent once, the first time the\n * container scrolls into view.\n */\nexport const VISIBLE_EVENT = {\n onVisible: {\n description:\n \"Sent once, the first time the container scrolls into view. Use it to load more content lazily.\",\n parameters: NO_ARGS,\n },\n} as const;\n\ntype WithEvents<Props> = Props & { onVisible?: EventProp };\n\nexport type LayoutProps = z.output<typeof layoutSchema>;\n\n/** The slot of every container: a list of children or a template. */\nexport const CHILDREN_SLOT = { children: \"multiple\" } as const;\n\ntype WithChildren<Props> = WithEvents<Props> & { children?: ReactNode };\n\nconst boxSchema = z.object({\n ...layoutProps,\n direction: z.enum([\"col\", \"row\"]).optional().describe('Default \"col\"'),\n});\nconst gridSchema = z.object({\n ...layoutProps,\n columns: z\n .union([z.number(), z.string()])\n .optional()\n .describe(\"Column count or CSS template. Default 2\"),\n minChildWidth: sizeValue.optional(),\n rows: z.union([z.number(), z.string()]).optional(),\n});\nconst gridItemSchema = z.object({\n ...layoutProps,\n span: z.number().optional(),\n rowSpan: z.number().optional(),\n});\nconst cardSchema = z.object({\n ...layoutProps,\n variant: z\n .enum([\"default\", \"outline\", \"section\", \"soft\", \"elevated\", \"transparent\"])\n .optional(),\n shadowStyle: z\n .enum([\"none\", \"sm\", \"md\"])\n .optional()\n .describe(\"Overrides the shadow of the variant\"),\n size: z\n .enum([\"sm\", \"md\", \"lg\"])\n .optional()\n .describe('The padding preset: 8, 16 or 24px. Default \"md\"'),\n});\nconst flowSchema = z.object({\n ...layoutProps,\n columns: z.number().optional(),\n rows: z.number().optional(),\n layout: z.enum([\"pack\", \"fixed\"]).optional().describe('Default \"pack\"'),\n});\nconst flowItemSchema = z.object({\n ...layoutProps,\n span: z.number().optional(),\n rowSpan: z.number().optional(),\n aspectRatio: z.string().optional().describe('Default \"1 / 1\"'),\n aspectMode: z.enum([\"soft\", \"fixed\"]).optional(),\n});\nconst carouselSchema = z.object({\n ...layoutProps,\n label: z\n .string()\n .optional()\n .describe(\"A short name of the carousel for screen readers\"),\n visibleItems: z.number().optional(),\n showArrows: z.boolean().optional().describe(\"Default true\"),\n activeIndex: z\n .number()\n .optional()\n .describe(\n 'The index of the slide in view. Bind it with { \"@path\": \"/x\" } to read or set it',\n ),\n previousLabel: z.string().optional().describe('Default \"Previous\"'),\n nextLabel: z.string().optional().describe('Default \"Next\"'),\n snap: z.enum([\"none\", \"proximity\", \"mandatory\"]).optional(),\n snapAlign: z.enum([\"start\", \"center\", \"end\"]).optional(),\n});\nconst CAROUSEL_MEDIA_SIZES = [\"sm\", \"md\", \"lg\"] as const;\nconst carouselMediaItemSchema = z.object({\n ...layoutProps,\n url: z.string().describe(\"Image URL\"),\n description: z\n .string()\n .optional()\n .describe(\"What the image shows, for screen readers\"),\n size: z\n .enum(CAROUSEL_MEDIA_SIZES)\n .optional()\n .describe('The width: \"sm\" 160px, \"md\" 240px, \"lg\" 320px. Default \"md\"'),\n aspectRatio: z.string().optional().describe('Default \"4 / 3\"'),\n href: z.string().optional().describe(\"Opens this URL in a new tab\"),\n lightbox: z\n .boolean()\n .optional()\n .describe(\"Default true: a click opens all slides full-screen\"),\n});\nconst spacerSchema = z.object({ minSize: sizeValue.optional() });\nconst tabsSchema = z.object({\n tabs: z\n .array(\n z.object({\n title: z.string().describe(\"The tab title\"),\n child: child(\"The id of the panel component\"),\n }),\n )\n .describe(\"One entry per tab\"),\n selectedIndex: z\n .number()\n .optional()\n .describe(\n 'The open tab. Default 0. Bind it with { \"@path\": \"/x\" } to read it',\n ),\n weight: weightProp,\n});\nconst dividerSchema = z.object({\n axis: z\n .enum([\"horizontal\", \"vertical\"])\n .optional()\n .describe('Default \"horizontal\"'),\n weight: weightProp,\n color: z.enum(BORDER_COLORS).optional(),\n size: z.number().optional(),\n spacing: sizeValue.optional(),\n flush: z.boolean().optional(),\n});\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 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 = z.output<typeof tabsSchema> & {\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 = {\n Box: {\n component: Box,\n description:\n 'A flex container. It stacks its children in a column (direction \"row\" puts them in a row). Use it to group children with gap, padding, border, radius or background.',\n props: boxSchema,\n events: VISIBLE_EVENT,\n slots: CHILDREN_SLOT,\n },\n Column: {\n component: Column,\n description:\n \"A vertical flex container. Its default gap already separates sections, so do not add padding, background or a Spacer for space.\",\n props: layoutSchema,\n events: VISIBLE_EVENT,\n slots: CHILDREN_SLOT,\n },\n Row: {\n component: Row,\n description:\n 'A horizontal flex container. For a label and value pair, use a Row with justify \"spaceBetween\": a Caption on the left and a Text with fontWeight \"medium\" on the right. Put buttons in a Row at the bottom of a Card: one Button with variant \"primary\", and the default or \"borderless\" for the others.',\n props: layoutSchema,\n events: VISIBLE_EVENT,\n slots: CHILDREN_SLOT,\n },\n Grid: {\n component: Grid,\n description:\n \"A CSS grid container. On a narrow screen, its columns collapse towards one column.\",\n props: gridSchema,\n events: VISIBLE_EVENT,\n slots: CHILDREN_SLOT,\n },\n GridItem: {\n component: GridItem,\n description:\n \"A cell of a Grid, with an optional span. A span that covers all rendered columns fills the row.\",\n props: gridItemSchema,\n events: VISIBLE_EVENT,\n slots: CHILDREN_SLOT,\n },\n Card: {\n component: Card,\n description:\n 'A bordered, padded container, only for an interactive panel (controls, a form, a configurator). Tables, charts and text do not need one. Give it a Title and a Caption. Separate the groups in it with a Divider or the plain gap, never with a nested Card or a bordered Box. Variant \"section\" is a heading and content without a box. Variant \"outline\" always has a box. In markdown mode, a Card without controls renders as \"section\" unless it sets variant or border.',\n props: cardSchema,\n events: VISIBLE_EVENT,\n slots: { child: \"single\", children: \"multiple\" } as const,\n },\n Flow: {\n component: Flow,\n description:\n \"A masonry-like grid that packs cells of different sizes. Put FlowItem children in it.\",\n props: flowSchema,\n events: VISIBLE_EVENT,\n slots: CHILDREN_SLOT,\n },\n FlowItem: {\n component: FlowItem,\n description: \"A cell of a Flow, with an optional span.\",\n props: flowItemSchema,\n events: VISIBLE_EVENT,\n slots: CHILDREN_SLOT,\n },\n Carousel: {\n component: Carousel,\n description:\n 'A row that scrolls horizontally and snaps to its slides, with previous and next arrows. Put CarouselItem or CarouselMediaItem children in it. Bind activeIndex with { \"@path\": \"/x\" } to read or set the slide in view.',\n props: carouselSchema,\n events: VISIBLE_EVENT,\n slots: CHILDREN_SLOT,\n writable: [\"activeIndex\"] as const,\n },\n CarouselItem: {\n component: CarouselItem,\n description: \"A slide of a Carousel.\",\n props: layoutSchema,\n events: VISIBLE_EVENT,\n slots: CHILDREN_SLOT,\n },\n CarouselMediaItem: {\n component: CarouselMediaItem,\n description:\n 'A slide of a Carousel with an image on top and its children (a Caption, a Text) under it. size \"sm\" is 160px, \"md\" 240px (default), \"lg\" 320px wide. A click on the image opens all slides full-screen, unless href or onClick is set.',\n props: carouselMediaItemSchema,\n events: {\n ...VISIBLE_EVENT,\n onClick: {\n description:\n \"Sent when the user clicks the image. It replaces the full-screen view.\",\n parameters: NO_ARGS,\n },\n },\n slots: CHILDREN_SLOT,\n },\n Spacer: {\n component: Spacer,\n description:\n \"Flexible empty space. You almost never need it: use the default gap.\",\n props: spacerSchema,\n },\n Divider: {\n component: Divider,\n description:\n 'A line between two groups: horizontal, or vertical with axis \"vertical\" in a Row.',\n props: dividerSchema,\n },\n Tabs: {\n component: Tabs,\n description:\n 'Tabs that show one panel at a time. Each tab has a title and the id of its panel component: \"tabs\":[{\"title\":\"Specs\",\"child\":\"specs\"}].',\n props: tabsSchema,\n writable: [\"selectedIndex\"] as const,\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 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, { useEffect, useState } from \"react\";\nimport type { CSSProperties } from \"react\";\nimport { IconSvg } from \"../../components/icons/CopilotIcon\";\nimport type { IconSvgNode } from \"../../components/icons/CopilotIcon\";\nimport * as z from \"zod\";\nimport {\n controlAria,\n useGenerativeUIAccessibility,\n wrapperAria,\n} from \"../accessibility\";\nimport type { GenerativeUIInvokeResult } from \"../errors\";\nimport { radiusStyle, radiusValue, sizeValue, weightProp } from \"./layout\";\nimport { Lightbox, openUrl } from \"./lightbox\";\nimport {\n ON_ACCENT,\n WEIGHTS,\n backgroundColor,\n borderColor,\n radius,\n spacing,\n textColor,\n} from \"./tokens\";\nimport type { Weight } from \"./tokens\";\n\nconst NO_ARGS = z.object({});\ntype EventProp = (\n args: z.input<typeof NO_ARGS>,\n) => Promise<GenerativeUIInvokeResult>;\n\n// ---- Schemas ----\n\nconst colorProp = z.string().optional();\n\nexport const ICON_SIZES = [\"sm\", \"md\", \"lg\", \"xl\"] as const;\nexport type IconSize = (typeof ICON_SIZES)[number] | number;\n\nconst IMAGE_VARIANTS = [\n \"icon\",\n \"avatar\",\n \"smallFeature\",\n \"mediumFeature\",\n \"largeFeature\",\n \"header\",\n] as const;\nconst imageSchema = z.object({\n url: z.string().describe(\"Image URL\"),\n description: z\n .string()\n .optional()\n .describe(\n \"What the image shows, for screen readers. Leave it unset only for a decorative image\",\n ),\n variant: z\n .enum(IMAGE_VARIANTS)\n .optional()\n .describe(\n 'The size: \"icon\" 24px, \"avatar\" 40px round, \"smallFeature\" 160px wide, \"largeFeature\" and \"header\" full width. Default \"mediumFeature\": the natural size',\n ),\n weight: weightProp,\n aspectRatio: z.string().optional(),\n fit: z\n .enum([\"cover\", \"contain\", \"fill\", \"none\", \"scaleDown\"])\n .optional()\n .describe('CSS object-fit. Default \"cover\"'),\n radius: radiusValue.optional(),\n width: sizeValue.optional(),\n height: sizeValue.optional(),\n maxWidth: sizeValue.optional(),\n maxHeight: sizeValue.optional(),\n minWidth: sizeValue.optional(),\n minHeight: sizeValue.optional(),\n background: z.string().optional(),\n frame: z.boolean().optional(),\n position: z\n .string()\n .optional()\n .describe('CSS object-position, for example \"top\" or \"50% 20%\"'),\n hideOnFailure: z.boolean().optional().describe(\"Default false\"),\n fallback: z\n .string()\n .optional()\n .describe(\"Text shown in place of the image when it does not load\"),\n hoverZoom: z.boolean().optional().describe(\"A slight zoom on hover\"),\n lightbox: z\n .boolean()\n .optional()\n .describe(\"Default true: a click opens the image full-screen\"),\n actionOverlay: z\n .object({\n label: z.string(),\n icon: z.string().optional().describe(\"Lucide icon name\"),\n href: z.string().optional().describe(\"Opens this URL in a new tab\"),\n })\n .optional()\n .describe(\n \"A button over the bottom-right corner of the image. Without href, it sends onOverlayClick\",\n ),\n});\nconst iconSchema = z.object({\n name: z\n .union([z.string(), z.object({ svgPath: z.string() })])\n .describe(\n 'A Lucide icon name in kebab-case (\"arrow-right\"), an A2UI icon name (\"arrowBack\"), or { \"svgPath\" } on a 24px grid',\n ),\n label: z\n .string()\n .optional()\n .describe(\n \"What the icon means, for screen readers. Leave it unset when text next to the icon says the same\",\n ),\n size: z\n .union([z.enum(ICON_SIZES), z.number()])\n .optional()\n .describe('Default \"md\"'),\n color: colorProp,\n inline: z.boolean().optional().describe(\"Default false\"),\n strokeWeight: z.enum(WEIGHTS).optional().describe(\"The stroke width\"),\n weight: weightProp,\n});\nconst faviconSchema = z.object({\n url: z.string(),\n alt: z.string().optional(),\n size: z.number().optional().describe(\"Pixels. Default 16\"),\n inline: z.boolean().optional().describe(\"Default false\"),\n frame: z.boolean().optional().describe(\"Default false\"),\n});\nconst svgSchema = z.object({\n viewBox: z.string().optional(),\n label: z\n .string()\n .optional()\n .describe(\n \"What the drawing shows, for screen readers. Leave it unset for a decorative drawing\",\n ),\n width: sizeValue.optional(),\n height: sizeValue.optional(),\n size: sizeValue.optional(),\n color: colorProp.describe('Default \"prose\"'),\n fill: colorProp.describe('Default \"currentColor\"'),\n stroke: colorProp,\n strokeWidth: z.number().optional(),\n strokeLinecap: z.enum([\"butt\", \"round\", \"square\"]).optional(),\n strokeLinejoin: z.enum([\"miter\", \"round\", \"bevel\"]).optional(),\n preserveAspectRatio: z.string().optional(),\n paths: z\n .array(\n z.object({\n d: z.string(),\n fill: colorProp,\n stroke: colorProp,\n strokeWidth: z.number().optional(),\n }),\n )\n .optional(),\n circles: z\n .array(\n z.object({\n cx: z.number(),\n cy: z.number(),\n r: z.number(),\n fill: colorProp,\n stroke: colorProp,\n }),\n )\n .optional(),\n rects: z\n .array(\n z.object({\n x: z.number(),\n y: z.number(),\n width: z.number(),\n height: z.number(),\n rx: z.number().optional(),\n fill: colorProp,\n stroke: colorProp,\n }),\n )\n .optional(),\n lines: z\n .array(\n z.object({\n x1: z.number(),\n y1: z.number(),\n x2: z.number(),\n y2: z.number(),\n stroke: colorProp,\n }),\n )\n .optional(),\n texts: z\n .array(\n z.object({\n x: z.number(),\n y: z.number(),\n text: z.string(),\n size: z.number().optional(),\n fill: colorProp,\n anchor: z.enum([\"start\", \"middle\", \"end\"]).optional(),\n }),\n )\n .optional(),\n});\nconst captionTrack = z.object({\n url: z.string().describe(\"The URL of a WebVTT file\"),\n language: z.string().optional().describe('BCP 47, for example \"en\"'),\n label: z.string().optional().describe(\"Shown in the captions menu\"),\n kind: z.enum([\"subtitles\", \"captions\", \"descriptions\"]).optional(),\n});\nconst videoSchema = z.object({\n url: z\n .string()\n .describe(\n \"The URL of a video file, or of a YouTube video or short. A page on another video site shows as a link\",\n ),\n posterUrl: z\n .string()\n .optional()\n .describe(\"The image shown before the video plays\"),\n title: z.string().optional().describe(\"Names the video for screen readers\"),\n captions: z\n .array(captionTrack)\n .optional()\n .describe(\"Caption tracks of a video file\"),\n aspectRatio: z.string().optional().describe('Default \"16 / 9\"'),\n width: sizeValue.optional().describe('Default \"100%\"'),\n maxWidth: sizeValue.optional().describe('Default \"100%\"'),\n weight: weightProp,\n});\nconst audioPlayerSchema = z.object({\n url: z.string().describe(\"The URL of the audio file\"),\n description: z\n .string()\n .optional()\n .describe(\"A title or summary of the audio, shown above the player\"),\n weight: weightProp,\n});\nconst htmlViewSchema = z.object({\n html: z.string(),\n height: sizeValue.optional().describe(\"Pixels when a number. Default 360\"),\n width: sizeValue.optional().describe('Default \"100%\"'),\n title: z.string().optional(),\n});\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 = {\n Image: {\n component: Image,\n description:\n \"An image from a URL. A click opens it full-screen. Set description to say what the image shows, unless it is only decoration.\",\n props: imageSchema,\n events: {\n onOverlayClick: {\n description:\n \"Sent when the user clicks the actionOverlay button and it has no href.\",\n parameters: NO_ARGS,\n },\n },\n },\n Icon: {\n component: Icon,\n description:\n 'A Lucide icon by kebab-case name (for example \"arrow-right\"), or an A2UI icon name (for example \"arrowBack\"). Set label when no text next to the icon says what it means.',\n props: iconSchema,\n },\n Favicon: {\n component: Favicon,\n description: \"The favicon of the site at a URL.\",\n props: faviconSchema,\n },\n Svg: {\n component: Svg,\n description:\n \"A vector drawing from primitive shapes (paths, circles, rects, lines, texts). Colors take text color tokens or CSS colors.\",\n props: svgSchema,\n },\n Video: {\n component: Video,\n description:\n \"A video player for a video file URL (with optional captions), or a YouTube link in privacy-enhanced mode: the poster shows first, and the player loads when the user presses play. A page on another video site shows as a link to it. Set title to name the video.\",\n props: videoSchema,\n },\n AudioPlayer: {\n component: AudioPlayer,\n description:\n \"An audio player for an audio file URL, with the description above it.\",\n props: audioPlayerSchema,\n },\n HtmlView: {\n component: HtmlView,\n description:\n \"Raw HTML in a fully sandboxed iframe: no scripts, no same-origin access. Set title to name the content.\",\n props: htmlViewSchema,\n },\n};\n","import React, { useContext, useEffect, useRef, useState } from \"react\";\nimport type { CSSProperties, KeyboardEvent, MouseEvent } from \"react\";\nimport * as z from \"zod\";\nimport type { GenerativeUIInvokeResult } from \"../errors\";\nimport {\n GenerativeUINodeContext,\n useGenerativeUIRuntime,\n} from \"../runtime-context\";\nimport { sizeValue } from \"./layout\";\nimport { Lightbox, openUrl } from \"./lightbox\";\nimport { safeHref } from \"./markdown\";\nimport { LucideIcon, hostOf } from \"./media\";\nimport { ACCENT, useStandardStyles } from \"./styles\";\nimport {\n FONT_WEIGHT,\n ON_ACCENT,\n SHADOW_MD,\n backgroundColor,\n borderColor,\n radius,\n spacing,\n textColor,\n textFont,\n} from \"./tokens\";\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\nconst NO_ARGS = z.object({});\ntype EventProp<Args = z.input<typeof NO_ARGS>> = (\n args: Args,\n) => Promise<GenerativeUIInvokeResult>;\n\nconst text = (description: string) =>\n z.string().optional().describe(description);\n\nconst linkCardSchema = z.object({\n href: z.string().describe(\"The URL (http, https)\"),\n title: z.string().describe(\"The page title\"),\n description: text(\"One or two lines\"),\n image: text(\"A thumbnail URL\"),\n domain: text(\"Shown next to the favicon. Default: the host of href\"),\n favicon: z.boolean().optional().describe(\"Default true\"),\n});\nconst citationSchema = z.object({\n index: z.number().optional().describe(\"The marker number. Default 1\"),\n label: text(\"Marker text instead of the number, for example a domain\"),\n title: text(\"The source title\"),\n url: text(\"The source URL (http, https)\"),\n snippet: text(\"The quoted passage, one or two lines\"),\n source: text(\"The publisher or domain. Default: the host of url\"),\n});\nexport const followUpItem = z.union([\n z.string(),\n z.object({\n label: z.string(),\n message: text(\"The text sent when the user clicks. Default: label\"),\n }),\n]);\nconst followUpSchema = z.object({\n items: z\n .array(followUpItem)\n .optional()\n .describe('Strings or { \"label\", \"message\"? }, or { \"@path\": \"/x\" }'),\n title: text(\"A caption above the pills\"),\n});\nconst followUpArgs = z.object({\n message: z.string().describe(\"The message of the clicked pill\"),\n});\nconst BADGE_COLORS = [\n \"secondary\",\n \"success\",\n \"danger\",\n \"warning\",\n \"info\",\n \"discovery\",\n] as const;\nexport const cardAction = z.object({\n label: z.string(),\n href: text(\"Opens this URL in a new tab\"),\n variant: z.enum([\"solid\", \"soft\", \"outline\", \"ghost\"]).optional(),\n});\nconst entityCardSchema = z.object({\n title: z.string().describe(\"The name\"),\n subtitle: text(\"A second line, for example the brand or category\"),\n description: text(\"Up to three lines\"),\n image: text(\"An image URL\"),\n imageAspectRatio: z.string().optional().describe('Default \"4 / 3\"'),\n meta: text(\n 'A short fact line, for example \"$29 / month\" or \"Open until 22:00\"',\n ),\n badge: z\n .object({ label: z.string(), color: z.enum(BADGE_COLORS).optional() })\n .optional(),\n rating: z.number().optional().describe(\"0 to 5, shown as stars\"),\n ratingCount: z.number().optional().describe(\"The number of ratings\"),\n href: text(\"Opens this URL in a new tab when the user clicks the card\"),\n actions: z\n .array(cardAction)\n .max(3)\n .optional()\n .describe(\n \"Up to three buttons. A button without href sends onAction with its label\",\n ),\n layout: z\n .enum([\"vertical\", \"horizontal\"])\n .optional()\n .describe('Default \"vertical\". \"horizontal\" puts the image on the left'),\n width: sizeValue.optional(),\n});\nconst entityActionArgs = z.object({\n label: z.string().describe(\"The label of the clicked button\"),\n});\nexport const gridImage = z.object({\n url: z.string(),\n description: z.string().optional().describe(\"What the image shows\"),\n caption: z.string().optional(),\n href: text(\"Opens this URL instead of the full-screen view\"),\n});\nconst imageGridSchema = z.object({\n images: z\n .array(gridImage)\n .optional()\n .describe(\n 'A list of { \"url\", \"description\"?, \"caption\"?, \"href\"? }, or { \"@path\": \"/x\" }',\n ),\n columns: z.number().optional().describe(\"Default 3\"),\n aspectRatio: z.string().optional().describe('Default \"1 / 1\"'),\n gap: sizeValue.optional().describe(\"Default 2\"),\n layout: z\n .enum([\"grid\", \"bento\"])\n .optional()\n .describe('Default \"grid\". \"bento\" makes the first image twice as large'),\n});\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 = {\n LinkCard: {\n component: LinkCard,\n description:\n \"A preview card of a URL: the favicon and domain, the title, a description and a thumbnail. A click opens the link in a new tab, or sends onClick when it is bound. Use it for sources, articles and products that have a page.\",\n props: linkCardSchema,\n events: {\n onClick: {\n description: \"Sent when the user clicks the card, instead of the link.\",\n parameters: NO_ARGS,\n },\n },\n },\n Citation: {\n component: Citation,\n description:\n \"An inline source marker ([1]) that shows the source on hover or click: the title, a snippet and a link. Put it inline after the sentence it supports, as a child of a Text or in a Row.\",\n props: citationSchema,\n },\n FollowUp: {\n component: FollowUp,\n description:\n \"Suggested next prompts as pills. A click sends the message of the pill as the next turn of the user, with no event binding needed. Put it at the end of a surface, with two to four short items.\",\n props: followUpSchema,\n events: {\n onFollowUp: {\n description:\n \"Sent when the user clicks a pill. The args carry the message of the pill.\",\n parameters: followUpArgs,\n },\n },\n },\n EntityCard: {\n component: EntityCard,\n description:\n \"A card for one thing (a product, place, person or listing): an image, title, subtitle, description, a price or meta line, a badge, a rating and up to three buttons. href opens a page, and onClick is sent when it is bound. Use a Grid of EntityCards for several things.\",\n props: entityCardSchema,\n events: {\n onClick: {\n description: \"Sent when the user clicks the card and it has no href.\",\n parameters: NO_ARGS,\n },\n onAction: {\n description:\n \"Sent when the user clicks a button without href. The args carry the label of the button.\",\n parameters: entityActionArgs,\n },\n },\n },\n ImageGrid: {\n component: ImageGrid,\n description:\n 'A gallery of images in a grid. A click opens the image full-screen, with arrows to the other images. layout \"bento\" makes the first image twice as large.',\n props: imageGridSchema,\n },\n};\n","import React, { Suspense, memo, useRef } from \"react\";\nimport type { CSSProperties, ComponentType } from \"react\";\nimport type * as Recharts from \"recharts\";\nimport * as z from \"zod\";\nimport {\n CHART_CURSOR,\n CHART_PALETTE,\n FONT_WEIGHT,\n SHADOW_MD,\n backgroundColor,\n borderColor,\n textColor,\n textFont,\n} from \"./tokens\";\n\n// ---- Schema ----\n\nexport const chartSeries = z.union([\n z.string(),\n z.object({\n key: z.string(),\n label: z.string().optional(),\n color: z.string().optional().describe(\"A text color token or a CSS color\"),\n }),\n]);\nexport type ChartSeries = z.output<typeof chartSeries>;\n\nexport const chartSchema = z.object({\n chartType: z\n .enum([\"bar\", \"line\", \"area\", \"scatter\", \"pie\", \"donut\"])\n .optional()\n .describe('Default \"bar\"'),\n data: z\n .array(z.record(z.string(), z.unknown()))\n .optional()\n .describe('A list of objects, or { \"@path\": \"/x\" }'),\n xKey: z.string().optional().describe(\"The field of the category axis\"),\n series: z\n .array(chartSeries)\n .optional()\n .describe(\n 'The value fields: strings or { \"key\", \"label\"?, \"color\"? }. Default: every number field except xKey',\n ),\n stacked: z.boolean().optional(),\n layout: z\n .enum([\"vertical\", \"horizontal\"])\n .optional()\n .describe(\n '\"horizontal\" draws the bars from left to right. Default \"vertical\"',\n ),\n yAxis: z\n .object({\n label: z.string().optional(),\n min: z.number().optional(),\n max: z.number().optional(),\n width: z.number().optional().describe(\"Pixels\"),\n })\n .optional()\n .describe(\n 'The value axis configuration object: {label?: string, min?: number, max?: number, width?: number}. Example: {label: \"Revenue (USD)\", min: 0, max: 100}. In horizontal charts, label, min and max apply to the horizontal value axis, and width sets the width of the category axis on the left.',\n ),\n showDots: z.boolean().optional().describe(\"Point markers on a line or area\"),\n barRadius: z\n .number()\n .optional()\n .describe(\"The corner radius of a bar, in pixels\"),\n innerRadius: z\n .union([z.number(), z.string()])\n .optional()\n .describe(\"Pie and donut\"),\n outerRadius: z\n .union([z.number(), z.string()])\n .optional()\n .describe(\"Pie and donut\"),\n startAngle: z.number().optional().describe(\"Pie and donut. Default 90\"),\n endAngle: z.number().optional().describe(\"Pie and donut. Default -270\"),\n cornerRadius: z.number().optional().describe(\"The corners of a slice\"),\n paddingAngle: z.number().optional().describe(\"The gap between slices\"),\n showLabelLines: z\n .boolean()\n .optional()\n .describe(\"Leader lines of the slice labels. Default true\"),\n height: z.number().optional().describe(\"Pixels. Default 240\"),\n showLegend: z.boolean().optional().describe(\"Default true\"),\n showGrid: z.boolean().optional().describe(\"Default true\"),\n showTooltip: z.boolean().optional().describe(\"Default true\"),\n showValueLabels: z.boolean().optional(),\n format: z\n .enum([\"number\", \"currency\", \"percent\"])\n .optional()\n .describe(\n 'Number formatting. With \"percent\", data values and axis min/max are fractions: 0.4 displays as 40%. For 0% to 10%, use min: 0 and max: 0.1.',\n ),\n currency: z.string().optional().describe('ISO code. Default \"USD\"'),\n title: z.string().optional(),\n});\nexport type ChartProps = z.output<typeof chartSchema>;\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 * as 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 \"./tokens\";\nimport { useStandardStyles } from \"./styles\";\n\n// ---- Schema ----\n\nexport const mapMarker = z.object({\n label: z.string(),\n lat: z.number(),\n lng: z.number(),\n category: z.string().optional(),\n icon: z.string().optional(),\n});\nexport type MapMarker = z.output<typeof mapMarker>;\n\nexport const mapSchema = z.object({\n markers: z\n .array(mapMarker)\n .optional()\n .describe('A list of places, or { \"@path\": \"/x\" }'),\n route: z\n .boolean()\n .optional()\n .describe(\"Draws a line through the markers in order\"),\n selected: z\n .string()\n .optional()\n .describe(\n 'The label of the selected marker. Bind it with { \"@path\": \"/x\" } to read the choice of the user',\n ),\n height: z.number().optional().describe(\"Pixels. Default 240\"),\n zoom: z\n .number()\n .optional()\n .describe(\"With two or more markers, only the highest zoom of the fit\"),\n center: z.object({ lat: z.number(), lng: z.number() }).optional(),\n});\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 * as z from \"zod\";\nimport { CHILDREN_SLOT, sizeValue, weightProp } from \"./layout\";\nimport { LucideIcon } from \"./media\";\nimport { Chart, VISUALLY_HIDDEN, chartSchema } from \"./Chart\";\nimport { MapView, mapSchema } from \"./Map\";\nimport {\n FONT_WEIGHT,\n backgroundColor,\n borderColor,\n radius,\n spacing,\n textColor,\n textFont,\n} from \"./tokens\";\nimport { useGenerativeUIAccessibility } from \"../accessibility\";\nimport { useStandardStyles } from \"./styles\";\n\n// ---- Schemas ----\n\nconst cellAlign = z.enum([\"start\", \"center\", \"end\"]).optional();\n\n/**\n * A table cell or column header that shows another component. `id` is an\n * alias of `componentId`.\n */\nconst tableComponentCell = z.union([\n z.object({ componentId: z.string() }),\n z.object({ id: z.string() }),\n]);\n\nconst tableColumn = z.union([\n z.string(),\n z.object({\n label: z.string(),\n align: cellAlign,\n width: sizeValue.optional(),\n componentId: z.string().optional(),\n }),\n tableComponentCell,\n]);\ntype TableColumn = z.output<typeof tableColumn>;\n\nconst tableSchema = z.object({\n caption: z\n .string()\n .optional()\n .describe(\"A short name of the table for screen readers. It is not shown\"),\n columns: z\n .array(tableColumn)\n .optional()\n .describe(\n 'Strings, { \"label\", \"align\"?, \"width\"?, \"componentId\"? } or { \"componentId\" }, or { \"@path\": \"/x\" }. Default []',\n ),\n // A cell is `unknown`, so booleans and null from bound data are valid too.\n rows: z\n .array(z.array(z.unknown()))\n .optional()\n .describe(\n 'A list of row lists, or { \"@path\": \"/x\" }. A cell is a string, a number, or { \"componentId\": \"<id>\" } to show a component. Default []',\n ),\n columnSizing: z.enum([\"auto\", \"equal\"]).optional().describe('Default \"auto\"'),\n dividers: z.boolean().optional().describe(\"Default true\"),\n stickyHeader: z.boolean().optional().describe(\"Default false\"),\n emptyLabel: z.string().optional().describe('Default \"No rows\"'),\n});\nconst tableSectionSchema = z.object({\n header: z.boolean().optional().describe(\"Renders the rows as the header\"),\n rowDivider: z.boolean().optional(),\n});\nconst tableRowSchema = z.object({\n header: z.boolean().optional(),\n label: z\n .string()\n .optional()\n .describe(\"The text of a header cell at the start of the row\"),\n labelColSpan: z.number().optional().describe(\"Columns the label cell spans\"),\n});\nconst tableCellSchema = z.object({\n text: z.union([z.string(), z.number()]).optional(),\n header: z.boolean().optional(),\n align: cellAlign,\n vAlign: cellAlign.describe('Default \"start\"'),\n colSpan: z.number().optional(),\n rowSpan: z.number().optional(),\n width: sizeValue.optional(),\n padding: sizeValue.optional(),\n});\n\nconst listItemValue = z.union([\n z.string(),\n z.object({\n label: z.string(),\n description: z.string().optional(),\n icon: z.string().optional().describe(\"Lucide icon name\"),\n value: z\n .union([z.string(), z.number()])\n .optional()\n .describe(\n \"Without an action: shown on the right of the label, for a key and value fact. With an action: the payload of the pick, not shown\",\n ),\n }),\n]);\ntype ListItemValue = z.output<typeof listItemValue>;\n\nconst LIST_MARKERS = [\"bullet\", \"number\", \"rich\", \"none\"] as const;\ntype ListMarker = (typeof LIST_MARKERS)[number];\n\nconst listSchema = z.object({\n items: z\n .array(listItemValue)\n .optional()\n .describe(\n 'Strings or { \"label\", \"value\"?, \"description\"?, \"icon\"? }, or { \"@path\": \"/x\" }',\n ),\n direction: z\n .enum([\"vertical\", \"horizontal\"])\n .optional()\n .describe('Default \"vertical\". \"horizontal\" scrolls sideways'),\n align: z.enum([\"start\", \"center\", \"end\", \"stretch\"]).optional(),\n weight: weightProp,\n marker: z.enum(LIST_MARKERS).optional().describe('Default \"bullet\"'),\n connector: z.enum([\"none\", \"solid\"]).optional().describe('Default \"none\"'),\n gap: sizeValue.optional(),\n start: z.number().optional().describe('The first number of marker \"number\"'),\n maxMarkerSize: z\n .number()\n .optional()\n .describe(\"The width of the marker column in pixels\"),\n});\nconst listItemSchema = z.object({\n label: z.string().optional(),\n value: z\n .union([z.string(), z.number()])\n .optional()\n .describe(\n \"Without an action: shown on the right of the label, for a key and value fact\",\n ),\n description: z.string().optional(),\n icon: z.string().optional().describe(\"Lucide icon name\"),\n marker: z.string().optional().describe(\"Shows this text as the marker\"),\n markerSize: z\n .number()\n .optional()\n .describe(\"The width of the marker column in pixels\"),\n disabled: z\n .boolean()\n .optional()\n .describe(\"Greys the item out and ignores its action\"),\n});\n\nconst listSelection = z.object({\n index: z.number(),\n label: z.string(),\n value: z.string().optional(),\n});\n\ntype ListSelection = z.output<typeof listSelection>;\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 = {\n Table: {\n component: Table,\n description:\n 'A data table. Put it in a plain Column, not in a Card. Give \"columns\" and \"rows\" (a list of row lists). Or give \"children\": TableSection or TableRow ids, or a template { \"componentId\", \"path\" } that repeats a TableRow for each item of a data list. To show a component (Badge, Button, Icon, Text) in a cell or a column header, set it to { \"componentId\": \"<id>\" } and put the id in \"cellComponents\".',\n props: tableSchema,\n slots: { children: \"multiple\", cellComponents: \"multiple\" } as const,\n },\n TableSection: {\n component: TableSection,\n accessibility: \"self\" as const,\n description:\n \"A group of TableRow children in a Table. With header true, it is the header of the table.\",\n props: tableSectionSchema,\n slots: CHILDREN_SLOT,\n },\n TableRow: {\n component: TableRow,\n accessibility: \"self\" as const,\n description:\n \"A row of a Table. Its children are TableCell ids, or a template. With label, a header cell with that text starts the row.\",\n props: tableRowSchema,\n slots: CHILDREN_SLOT,\n },\n TableCell: {\n component: TableCell,\n accessibility: \"self\" as const,\n description:\n 'A cell of a TableRow. It shows \"text\", or its children. With header true, it is a header cell.',\n props: tableCellSchema,\n slots: CHILDREN_SLOT,\n },\n List: {\n component: List,\n description:\n 'A list in a Card or next to another component. A plain list of text is markdown, not a List. Give \"items\" (strings or { \"label\", \"value\"?, \"description\"?, \"icon\"? }); without an action, an item with a value is a key and value row, for facts like Price: $1,599. Or, when there are no items, give \"children\": ListItem ids or a template. With an \"action\", the user can pick an item: the event context gets \"index\", \"label\" and \"value\" of the item.',\n props: listSchema,\n events: {\n action: {\n description:\n \"Runs when the user picks an item. The args are the index, label and value of the item.\",\n parameters: listSelection,\n },\n },\n slots: CHILDREN_SLOT,\n },\n ListItem: {\n component: ListItem,\n description:\n 'An item of a List, with a label, a value on the right, a description, an icon and children. With an \"action\", the user can pick it.',\n props: listItemSchema,\n events: {\n action: {\n description: \"Runs when the user picks the item.\",\n parameters: z.object({}),\n },\n },\n slots: CHILDREN_SLOT,\n },\n Chart: {\n component: Chart,\n description:\n 'A bar, line, area, scatter, pie or donut chart. \"data\" is a list of objects. \"xKey\" is the field of the category. \"series\" are the value fields.',\n props: chartSchema,\n },\n Map: {\n component: MapView,\n description:\n 'A map with markers. With \"route\", a line connects the markers in order. Bind \"selected\" to { \"@path\": \"/x\" } to get the label of the marker that the user picks. When maps are not available, it shows a list of the places.',\n props: mapSchema,\n writable: [\"selected\"] as const,\n },\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 * as z from \"zod\";\nimport {\n controlAria,\n useGenerativeUIAccessibility,\n wrapperAria,\n} from \"../accessibility\";\nimport { useGenerativeUIRuntime } from \"../runtime-context\";\nimport { useOverlayEscape } from \"./overlay-stack\";\nimport { CHILDREN_SLOT, sizeValue, weightProp } from \"./layout\";\nimport { useStandardStyles } from \"./styles\";\nimport {\n BACKDROP,\n backgroundColor,\n borderColor,\n radius,\n spacing,\n textColor,\n textFont,\n SHADOW_MD,\n} from \"./tokens\";\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\n// ---- Schemas ----\n\nconst pulseIndicatorSchema = z.object({\n label: z\n .string()\n .optional()\n .describe(\n \"What the dot means, for screen readers. Leave it unset when text next to the dot says the same\",\n ),\n color: z.string().optional().describe('Text color token. Default \"success\"'),\n size: z.number().optional().describe(\"Pixels. Default 12\"),\n pulseColor: z.string().optional(),\n duration: z.number().optional().describe(\"Milliseconds. Default 1500\"),\n endScale: z.number().optional().describe(\"Default 2.4\"),\n startOpacity: z.number().optional().describe(\"Default 0.6\"),\n});\nconst flashcardSchema = z.object({\n front: z.string().optional().describe(\"The text on the front\"),\n back: z.string().optional().describe(\"The text on the back\"),\n hint: z\n .string()\n .optional()\n .describe('A small line under the front, for example \"Click to flip\"'),\n});\nconst popoverSchema = z.object({\n open: z.boolean().optional().describe(\"Default false\"),\n showOnHover: z.boolean().optional(),\n hoverOpenDelay: z\n .number()\n .optional()\n .describe(\"Milliseconds before a hover opens it. Default 0\"),\n});\nconst popoverTriggerSchema = z.object({\n block: z.boolean().optional().describe(\"Full width\"),\n});\nconst popoverContentSchema = z.object({\n side: z\n .enum([\"top\", \"bottom\", \"left\", \"right\"])\n .optional()\n .describe('Default \"bottom\"'),\n sideOffset: z\n .number()\n .optional()\n .describe(\"Pixels between the trigger and the content. Default 6\"),\n align: z\n .enum([\"start\", \"center\", \"end\"])\n .optional()\n .describe('Default \"center\"'),\n width: sizeValue.optional().describe(\"4px steps when a number\"),\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\nconst modalSchema = z.object({\n title: z.string().optional().describe(\"The heading of the dialog\"),\n open: z\n .boolean()\n .optional()\n .describe('Default false. Bind it with { \"@path\": \"/x\" } to read it'),\n maxWidth: sizeValue.optional().describe(\"Default 480\"),\n weight: weightProp,\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 = {\n PulseIndicator: {\n component: PulseIndicator,\n description:\n 'A small dot that pulses, for example next to the text \"Live\". Set label when no text next to the dot says what it means.',\n props: pulseIndicatorSchema,\n },\n FlashcardFlip: {\n component: FlashcardFlip,\n description:\n \"A card that shows the front text. A click or the Enter key flips it to the back text, and again to the front.\",\n props: flashcardSchema,\n },\n Popover: {\n component: Popover,\n description:\n \"A small overlay next to a trigger. Put exactly two children in it: one PopoverTrigger, then one PopoverContent. A click on the trigger opens and closes the content. Escape or a click outside closes it.\",\n props: popoverSchema,\n slots: CHILDREN_SLOT,\n writable: [\"open\"] as const,\n },\n PopoverTrigger: {\n component: PopoverTrigger,\n description:\n \"The trigger of a Popover. Its children are the label of the trigger: a Text or an Icon. Do not put a Button in it, because the trigger is already a button.\",\n props: popoverTriggerSchema,\n slots: CHILDREN_SLOT,\n },\n PopoverContent: {\n component: PopoverContent,\n description:\n \"The body of a Popover. It shows only when the Popover is open.\",\n props: popoverContentSchema,\n slots: CHILDREN_SLOT,\n },\n Modal: {\n component: Modal,\n description:\n \"A dialog over the page. A click on the trigger (a Button or a Text) opens the content in the dialog. Escape, the close button or a click on the backdrop closes it.\",\n props: modalSchema,\n slots: { trigger: \"single\", content: \"single\" } as const,\n writable: [\"open\"] as const,\n },\n};\n","import { useState } from \"react\";\nimport * as z from \"zod\";\nimport type { CSSProperties } from \"react\";\nimport { textColor, textFont } from \"./tokens\";\n\n/**\n * The `checks` of the A2UI 1.0 `Checkable` components. The model writes\n * each condition as a validator call or a boolean binding:\n * `{ \"condition\": { \"@call\": \"email\", \"args\": { \"value\": { \"@path\": \"/form/email\" } } }, \"message\": \"...\" }`.\n * The engine resolves the condition before the component renders, so a\n * component sees a boolean or a `ValidationResult`.\n */\n\nconst severity = z.enum([\"error\", \"warning\", \"info\"]);\n\nconst validationResult = z\n .object({\n valid: z.boolean(),\n message: z.string().optional(),\n code: z.string().optional(),\n severity: severity.optional(),\n })\n .loose();\n\n/** The first failed check of a control, as the control shows it. */\nexport interface FailedCheck {\n message: string;\n /** `\"error\"` when the result named none. Only an error blocks. */\n severity: z.output<typeof severity>;\n /** The `code` of the validation result, when it had one. */\n code?: string;\n}\n\nexport const checksProp = z\n .array(\n z.object({\n condition: z\n .union([z.boolean(), validationResult])\n .optional()\n .describe(\n 'A validator call, for example {\"@call\":\"required\",\"args\":{\"value\":{\"@path\":\"/x\"}}}, or a boolean binding',\n ),\n message: z\n .string()\n .optional()\n .describe(\"Shown when the check fails, instead of the default message\"),\n }),\n )\n .optional()\n .describe(\"Validation rules. The control shows the first failed one\");\n\nexport type ResolvedChecks = z.output<typeof checksProp>;\n\n/**\n * The failed check to show, or `undefined` when every check passes: the\n * first error, or the first warning or info when no check is an error, so\n * a warning never hides an error that comes after it. A condition that is\n * not known yet (undefined) passes. A `false` condition is an error with\n * the check's message. The check's message also wins over the message of\n * a validator result: the built-in validators always have one, and the\n * check is where the model puts its own wording.\n */\nexport function firstFailedCheck(\n checks: ResolvedChecks,\n): FailedCheck | undefined {\n let first: FailedCheck | undefined;\n for (const check of checks ?? []) {\n const { condition } = check;\n if (condition === undefined || condition === null) continue;\n let failed: FailedCheck;\n if (typeof condition === \"boolean\") {\n if (condition) continue;\n failed = { message: check.message ?? \"Invalid value\", severity: \"error\" };\n } else {\n if (condition.valid) continue;\n failed = {\n message: check.message ?? condition.message ?? \"Invalid value\",\n severity: condition.severity ?? \"error\",\n ...(condition.code === undefined ? {} : { code: condition.code }),\n };\n }\n if (failed.severity === \"error\") return failed;\n first ??= failed;\n }\n return first;\n}\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\n/** The style of a check message, by its severity. */\nexport function checkMessageStyle(\n severity: FailedCheck[\"severity\"],\n): CSSProperties {\n return {\n ...textFont(\"sm\"),\n color: textColor(\n severity === \"error\"\n ? \"danger\"\n : severity === \"warning\"\n ? \"warning\"\n : \"secondary\",\n ),\n };\n}\n","import React, { useEffect, useId, useRef, useState } from \"react\";\nimport type { CSSProperties, KeyboardEvent, ReactNode } from \"react\";\nimport * as z from \"zod\";\nimport type { GenerativeUIInvokeResult } from \"../errors\";\nimport {\n FONT_WEIGHT,\n ON_ACCENT,\n SHADOW_XS,\n backgroundColor,\n borderColor,\n radius,\n spacing,\n textColor,\n textFont,\n} from \"./tokens\";\nimport {\n controlAria,\n useGenerativeUIAccessibility,\n wrapperAria,\n} from \"../accessibility\";\nimport { ACCENT, useStandardStyles } from \"./styles\";\nimport {\n CHILDREN_SLOT,\n VISIBLE_EVENT,\n layoutProps,\n layoutStyle,\n useVisibleOnce,\n weightProp,\n} from \"./layout\";\nimport { openUrl } from \"./lightbox\";\nimport { LucideIcon } from \"./media\";\nimport {\n checkMessageStyle,\n checksProp,\n firstFailedCheck,\n useChecks,\n} from \"./checks\";\nimport type { FailedCheck } 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\n// ---- Shared schemas ----\n\n/**\n * The arguments of a click or submit event: none. The model adds values\n * with the `context` of its `{ \"event\": ... }` binding.\n */\nconst NO_ARGS = z.object({});\n\ntype EventProp = (\n args: z.input<typeof NO_ARGS>,\n) => Promise<GenerativeUIInvokeResult>;\n\n/** A list of choices: plain strings or `{ value, label, description? }`. */\nconst optionList = z\n .array(\n z.union([\n z.string(),\n z.object({\n value: z.string(),\n label: z.string().optional(),\n description: z.string().optional(),\n }),\n ]),\n )\n .optional()\n .describe('Strings or { \"value\", \"label\", \"description\"? }');\n\ntype OptionList = z.output<typeof optionList>;\n\nconst SIZES = [\"sm\", \"md\", \"lg\", \"xl\"] as const;\ntype Size = (typeof SIZES)[number];\n\nconst size = (fallback: Size) =>\n z.enum(SIZES).optional().describe(`Default \"${fallback}\"`);\nconst pill = z.boolean().optional().describe(\"Default true\");\nconst fieldLabel = z\n .string()\n .optional()\n .describe(\"The visible label of the field. Always set it\");\nconst boundValue = z\n .string()\n .optional()\n .describe('Bind it with { \"@path\": \"/x\" } to read what the user entered');\n\nconst buttonSchema = z.object({\n label: z.string().optional().describe(\"The button text\"),\n checks: checksProp,\n text: z\n .string()\n .optional()\n .describe(\"Same as label. Used when label is not set\"),\n variant: z\n .enum([\"default\", \"primary\", \"soft\", \"borderless\"])\n .optional()\n .describe(\n 'Default \"default\": outlined. \"primary\" is filled, for the one main action. \"borderless\" has no box, like a link',\n ),\n color: z\n .enum([\"primary\", \"secondary\", \"danger\"])\n .optional()\n .describe('Default \"primary\"'),\n size: z.enum([\"sm\", \"md\", \"lg\"]).optional().describe('Default \"lg\"'),\n block: z.boolean().optional().describe(\"Full width\"),\n weight: weightProp,\n pill,\n disabled: z.boolean().optional(),\n loading: z.boolean().optional(),\n submit: z\n .boolean()\n .optional()\n .describe(\"Submits the Form around it. The Form sends its onSubmit event\"),\n icon: z.string().optional().describe(\"Lucide icon name\"),\n uniform: z.boolean().optional().describe(\"A square button, for an icon\"),\n href: z\n .string()\n .optional()\n .describe(\"Opens this URL in a new tab on click, instead of onClick\"),\n copy: z\n .string()\n .optional()\n .describe(\n \"Copies this text to the clipboard on click and shows a check mark, instead of onClick\",\n ),\n});\nconst pressableSchema = z.object({\n ...layoutProps,\n disabled: z.boolean().optional(),\n hoverBackground: z.string().optional(),\n href: z\n .string()\n .optional()\n .describe(\"Opens this URL in a new tab on click, instead of onClick\"),\n tooltip: z.string().optional().describe(\"Shown on hover\"),\n ariaPressed: z.boolean().optional().describe(\"For a toggle\"),\n insetBorder: z.boolean().optional().describe(\"A 1px border inside the box\"),\n});\nconst formSchema = z.object({\n ...layoutProps,\n label: z\n .string()\n .optional()\n .describe(\"A short name of the form for screen readers\"),\n});\nconst textFieldSchema = z.object({\n checks: checksProp,\n value: z\n .union([z.string(), z.number()])\n .optional()\n .describe('Bind it with { \"@path\": \"/x\" } to read what the user typed'),\n placeholder: z.string().optional(),\n label: fieldLabel,\n variant: z\n .enum([\n \"shortText\",\n \"longText\",\n \"number\",\n \"obscured\",\n \"email\",\n \"url\",\n \"tel\",\n ])\n .optional()\n .describe(\n 'Default \"shortText\". \"longText\" is a multi-line field, \"obscured\" a password',\n ),\n weight: weightProp,\n name: z.string().optional(),\n required: z.boolean().optional(),\n disabled: z.boolean().optional(),\n invalid: z.boolean().optional(),\n size: size(\"xl\"),\n pill,\n autoSelect: z.boolean().optional(),\n mask: z.string().optional(),\n});\nconst textAreaSchema = z.object({\n checks: checksProp,\n value: boundValue,\n placeholder: z.string().optional(),\n label: fieldLabel,\n weight: weightProp,\n rows: z.number().optional().describe(\"Default 3\"),\n maxRows: z.number().optional(),\n autoResize: z.boolean().optional(),\n name: z.string().optional(),\n required: z.boolean().optional(),\n disabled: z.boolean().optional(),\n invalid: z.boolean().optional(),\n size: size(\"xl\"),\n});\nconst selectSchema = z.object({\n checks: checksProp,\n value: boundValue,\n options: optionList,\n placeholder: z.string().optional(),\n label: fieldLabel,\n name: z.string().optional(),\n required: z.boolean().optional(),\n disabled: z.boolean().optional(),\n clearable: z.boolean().optional(),\n clearLabel: z.string().optional().describe(\"The label of the empty option\"),\n searchable: z.boolean().optional(),\n icon: z.string().optional().describe(\"Lucide icon shown before the value\"),\n block: z.boolean().optional().describe(\"Full width\"),\n size: size(\"xl\"),\n pill,\n});\nconst checkBoxSchema = z.object({\n checks: checksProp,\n value: z\n .boolean()\n .optional()\n .describe(\n 'True when checked. Bind it with { \"@path\": \"/x\" } to read the state of the box',\n ),\n label: z.string().optional().describe(\"The label text. Always set it\"),\n name: z.string().optional(),\n weight: weightProp,\n disabled: z.boolean().optional(),\n required: z.boolean().optional(),\n lineThrough: z\n .boolean()\n .optional()\n .describe(\"Default false. Strikes the label when the box is checked\"),\n shape: z.enum([\"round\", \"square\"]).optional().describe('Default \"round\"'),\n});\nconst radioSchema = z.object({\n value: z.string().optional(),\n label: z.string().optional(),\n disabled: z.boolean().optional(),\n required: z.boolean().optional(),\n});\nconst radioGroupSchema = z.object({\n checks: checksProp,\n value: boundValue,\n options: optionList,\n label: fieldLabel,\n name: z.string().optional(),\n direction: z.enum([\"row\", \"col\"]).optional().describe('Default \"row\"'),\n variant: z.enum([\"list\", \"pills\", \"cards\"]).optional(),\n disabled: z.boolean().optional(),\n required: z.boolean().optional(),\n});\nconst sliderSchema = z.object({\n checks: checksProp,\n value: z\n .number()\n .optional()\n .describe('Bind it with { \"@path\": \"/x\" } to read the number'),\n min: z.number().optional().describe(\"Default 0\"),\n max: z.number().optional().describe(\"Default 100\"),\n step: z.number().optional().describe(\"Default 1\"),\n steps: z\n .number()\n .int()\n .min(1)\n .optional()\n .describe(\n \"The number of equal divisions between min and max, instead of step\",\n ),\n label: fieldLabel,\n weight: weightProp,\n unit: z.string().optional().describe('Unit after the value, for example \"%\"'),\n marks: z\n .array(z.object({ value: z.number(), label: z.string().optional() }))\n .optional(),\n sliderStyle: z\n .enum([\"continuous\", \"discrete\"])\n .optional()\n .describe('Default \"continuous\"'),\n disabled: z.boolean().optional(),\n name: z.string().optional(),\n});\nconst segmentedControlSchema = z.object({\n checks: checksProp,\n value: boundValue,\n options: optionList,\n label: fieldLabel,\n block: z.boolean().optional().describe(\"Full width\"),\n size: size(\"lg\"),\n pill,\n variant: z\n .enum([\"solid\", \"soft\", \"outline\", \"ghost\"])\n .optional()\n .describe('Default \"ghost\"'),\n disabled: z.boolean().optional(),\n});\nconst choicePickerSchema = z.object({\n checks: checksProp,\n value: z\n .array(z.string())\n .optional()\n .describe(\n 'The chosen option values. Bind it with { \"@path\": \"/x\" } to a string list',\n ),\n options: optionList,\n label: fieldLabel,\n variant: z\n .enum([\"multipleSelection\", \"mutuallyExclusive\"])\n .optional()\n .describe('Default \"mutuallyExclusive\": the user picks one option'),\n displayStyle: z\n .enum([\"checkbox\", \"chips\"])\n .optional()\n .describe('Default \"checkbox\". \"chips\" shows the options as pills'),\n filterable: z\n .boolean()\n .optional()\n .describe(\"Default false. Shows a field that filters the options\"),\n weight: weightProp,\n disabled: z.boolean().optional(),\n required: z.boolean().optional(),\n});\nconst dateTimeInputSchema = z.object({\n checks: checksProp,\n value: z\n .string()\n .optional()\n .describe(\n 'ISO 8601: \"YYYY-MM-DD\", \"HH:MM\" or \"YYYY-MM-DDTHH:MM\". Bind it with { \"@path\": \"/x\" }',\n ),\n label: fieldLabel,\n enableDate: z\n .boolean()\n .optional()\n .describe(\n \"The user picks a date. Default true unless only enableTime is set\",\n ),\n enableTime: z.boolean().optional().describe(\"The user picks a time\"),\n timeStep: z\n .number()\n .int()\n .min(1)\n .max(720)\n .optional()\n .describe(\n \"Minutes between the times the user can pick, e.g. 15 or 30. Shows the time as a list\",\n ),\n weight: weightProp,\n min: z.string().optional().describe(\"The earliest value, ISO 8601\"),\n max: z.string().optional().describe(\"The latest value, ISO 8601\"),\n placeholder: z.string().optional(),\n disabled: z.boolean().optional(),\n required: z.boolean().optional(),\n clearable: z.boolean().optional(),\n block: z.boolean().optional().describe(\"Full width\"),\n});\n\ntype WithChildren<Props> = Props & { children?: ReactNode };\n\n/** The writable list of a control that keeps its state in `value`. */\nconst VALUE_WRITABLE = [\"value\"] as const;\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 (tail !== undefined) return { date: head, time: tail };\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 const [hours, minutes, seconds] = fullTime(time).split(\":\").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 event.preventDefault();\n props.setValue(options[next].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 = {\n Button: {\n component: Button,\n description:\n 'A button that sends its onClick event. With href it opens the URL, and with copy it copies the text, both without the agent. Use variant \"primary\" for the one main Button in a Row, and the default for the others. With submit true inside a Form, it submits the Form. The child or children render instead of the label. With checks, it is disabled while a check fails.',\n props: buttonSchema,\n events: {\n onClick: {\n description: \"Sent when the user clicks the button.\",\n parameters: NO_ARGS,\n },\n },\n slots: { child: \"single\", children: \"multiple\" } as const,\n },\n Pressable: {\n component: Pressable,\n description:\n \"A layout container that the user can click or press with Enter or Space. It sends its onClick event, or opens href. A control inside it sends only its own event.\",\n props: pressableSchema,\n events: {\n ...VISIBLE_EVENT,\n onClick: {\n description: \"Sent when the user clicks or presses the container.\",\n parameters: NO_ARGS,\n },\n },\n slots: CHILDREN_SLOT,\n },\n Form: {\n component: Form,\n description:\n 'A layout container that is a form. It sends its onSubmit event when the user submits it (a Button with submit true, or Enter in a field). Put the values of its fields in the event context with { \"@path\": \"/x\" }.',\n props: formSchema,\n events: {\n onSubmit: {\n description: \"Sent when the user submits the form.\",\n parameters: NO_ARGS,\n },\n },\n slots: CHILDREN_SLOT,\n },\n TextField: {\n component: TextField,\n description:\n 'A text input, single-line unless variant is \"longText\". Bind value with { \"@path\": \"/x\" } to read what the user typed. Give it a label.',\n props: textFieldSchema,\n writable: VALUE_WRITABLE,\n },\n TextArea: {\n component: TextArea,\n description:\n 'A multi-line text input. Bind value with { \"@path\": \"/x\" } to read what the user typed. Give it a label.',\n props: textAreaSchema,\n writable: VALUE_WRITABLE,\n },\n Select: {\n component: Select,\n description:\n 'A dropdown list of options. Bind value with { \"@path\": \"/x\" } to read the chosen option. Give it a label.',\n props: selectSchema,\n writable: VALUE_WRITABLE,\n },\n CheckBox: {\n component: CheckBox,\n description:\n 'A checkbox with a label. Bind value with { \"@path\": \"/x\" } to read its state, true or false.',\n props: checkBoxSchema,\n writable: VALUE_WRITABLE,\n },\n Radio: {\n component: Radio,\n description:\n \"One radio button. Use RadioGroup instead, because it keeps the chosen value.\",\n props: radioSchema,\n },\n RadioGroup: {\n component: RadioGroup,\n description:\n 'A group of radio buttons. The user chooses one option. Bind value with { \"@path\": \"/x\" } to read it. Give it a label.',\n props: radioGroupSchema,\n writable: VALUE_WRITABLE,\n },\n Slider: {\n component: Slider,\n description:\n 'A range slider for a number between min and max. Bind value with { \"@path\": \"/x\" } to read the number. Give it a label.',\n props: sliderSchema,\n writable: VALUE_WRITABLE,\n },\n SegmentedControl: {\n component: SegmentedControl,\n description:\n 'A row of segments. The user chooses one option. Use it for 2 to 5 short options. Bind value with { \"@path\": \"/x\" } to read it.',\n props: segmentedControlSchema,\n writable: VALUE_WRITABLE,\n },\n ChoicePicker: {\n component: ChoicePicker,\n description:\n 'A list of options, as checkboxes or chips. The user picks one, or several with variant \"multipleSelection\". Bind value with { \"@path\": \"/x\" } to read the chosen values as a list. Give it a label.',\n props: choicePickerSchema,\n writable: VALUE_WRITABLE,\n },\n DateTimeInput: {\n component: DateTimeInput,\n description:\n 'A date picker, or a time picker with enableTime, or both. Set timeStep (minutes) to offer fixed times, e.g. 30 for a booking. The value is ISO 8601. Bind value with { \"@path\": \"/x\" } to read it. Give it a label.',\n props: dateTimeInputSchema,\n writable: VALUE_WRITABLE,\n },\n};\n","import React, { useEffect, useId, useState } from \"react\";\nimport type {\n CSSProperties,\n FocusEvent,\n KeyboardEvent,\n ReactNode,\n} from \"react\";\nimport * as z from \"zod\";\nimport { CHILDREN_SLOT, sizeValue, weightProp } from \"./layout\";\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 TEXT_COLORS,\n TEXT_SIZES,\n TITLE_SIZES,\n WEIGHTS,\n backgroundColor,\n borderColor,\n radius,\n spacing,\n textColor,\n textFont,\n} from \"./tokens\";\nimport type { TitleSize } from \"./tokens\";\n\n// ---- Schemas ----\n\nconst colorProp = z\n .string()\n .optional()\n .describe(`One of ${TEXT_COLORS.join(\"|\")} or a CSS color`);\nconst fontWeight = z.enum(WEIGHTS).optional();\nconst textAlign = z.enum([\"start\", \"center\", \"end\"]).optional();\n\nconst typographyProps = {\n color: colorProp,\n fontWeight,\n textAlign,\n italic: z.boolean().optional(),\n truncate: z.boolean().optional(),\n maxLines: z.number().optional(),\n tabularNums: z.boolean().optional(),\n width: sizeValue.optional(),\n};\n\nconst typographySchema = z.object(typographyProps);\nconst titleSchema = z.object({\n ...typographyProps,\n text: z.string().describe(\"Heading text\"),\n size: z.enum(TITLE_SIZES).optional().describe('Default \"md\"'),\n strong: z.boolean().optional().describe(\"Default true\"),\n});\nconst textSchema = z.object({\n ...typographyProps,\n weight: weightProp,\n text: z\n .union([z.string(), z.number()])\n .optional()\n .describe(\"Text with inline markdown. A bound number shows as text\"),\n size: z.enum(TEXT_SIZES).optional().describe('Default \"md\"'),\n fontSize: sizeValue\n .optional()\n .describe(\"Pixels when a number. Wins over size\"),\n lineHeight: z\n .union([z.number(), z.string()])\n .optional()\n .describe(\"A unitless ratio, or CSS\"),\n minLines: z\n .number()\n .optional()\n .describe(\"Reserves the height of this many lines\"),\n strong: z.boolean().optional().describe(\"Default false\"),\n underline: z.boolean().optional(),\n lineThrough: z.boolean().optional(),\n inline: z.boolean().optional(),\n preserveWhitespace: z.boolean().optional(),\n highlight: z\n .union([z.enum([\"green\", \"orange\", \"pink\"]), z.boolean()])\n .optional(),\n});\nconst CAPTION_SIZES = [\"sm\", \"md\", \"lg\"] as const;\nconst captionSchema = z.object({\n text: z.union([z.string(), z.number()]).describe(\"Caption text\"),\n color: colorProp,\n size: z.enum(CAPTION_SIZES).optional().describe('Default \"lg\"'),\n fontWeight: fontWeight.describe('Default \"normal\"'),\n textAlign,\n truncate: z.boolean().optional(),\n maxLines: z.number().optional(),\n});\nconst labelSchema = z.object({\n text: z.union([z.string(), z.number()]).describe(\"Label text\"),\n htmlFor: z.string().optional(),\n color: colorProp,\n size: z.enum(TEXT_SIZES).optional().describe('Default \"sm\"'),\n fontWeight: fontWeight.describe('Default \"medium\"'),\n textAlign,\n truncate: z.boolean().optional(),\n width: sizeValue.optional(),\n});\nconst boldSchema = z.object({ text: z.string(), fontWeight });\nconst inlineTextSchema = z.object({ text: z.string() });\nconst blockquoteSchema = z.object({\n text: z.string().describe(\"The quoted text, with inline markdown\"),\n});\nconst BADGE_SIZES = [\"sm\", \"md\", \"lg\"] as const;\nconst badgeSchema = z.object({\n label: z.string().describe(\"Badge text\"),\n color: z\n .enum([\"secondary\", \"success\", \"danger\", \"warning\", \"info\", \"discovery\"])\n .optional()\n .describe('Default \"secondary\"'),\n size: z.enum(BADGE_SIZES).optional().describe('Default \"md\"'),\n pill: z.boolean().optional().describe(\"Default true\"),\n variant: z\n .enum([\"soft\", \"solid\", \"outline\"])\n .optional()\n .describe('Default \"soft\"'),\n fontWeight: fontWeight.describe('Default \"medium\"'),\n maxWidth: sizeValue.optional(),\n padding: sizeValue.optional(),\n});\nconst codeSchema = z.object({\n text: z.string().describe(\"Source code\"),\n language: z.string().optional(),\n});\nconst markdownSchema = z.object({\n text: z.string().describe(\"Markdown source\"),\n streaming: z.boolean().optional().describe(\"Default false\"),\n});\nconst mathSchema = z.object({\n value: z.string().describe(\"TeX source\"),\n block: z.boolean().optional().describe(\"Default false\"),\n});\nconst shimmerSchema = z.object({\n ...typographyProps,\n text: z.string(),\n size: z.enum(TEXT_SIZES).optional().describe('Default \"md\"'),\n lineThrough: z.boolean().optional(),\n});\nconst linkSchema = z.object({\n text: z.string().describe(\"Link text\"),\n href: z.string().describe(\"URL\"),\n title: z.string().optional(),\n});\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 = {\n Title: {\n component: Title,\n description:\n 'A heading inside a Card or next to another component. A heading alone is markdown outside the fence. Use size \"2xl\" at most once in a surface, and \"lg\" for section headings. Size \"sm\" is an h4, \"md\" and \"lg\" are an h3 (default \"md\"), \"xl\" and larger are an h2. It is bold unless strong is false.',\n props: titleSchema,\n },\n Text: {\n component: Text,\n description:\n 'Body text inside a Card or next to another component. A paragraph alone is markdown outside the fence. Use color \"default\" or \"secondary\". `text` can have inline markdown: **bold**, *italic*, ~~strike~~, ++underline++, `code` and [link](https://example.com). The `children` ids render inline after the text, for example a Badge.',\n props: textSchema,\n slots: CHILDREN_SLOT,\n },\n Caption: {\n component: Caption,\n description:\n \"Small secondary text: a hint under a control, or a label in a Row. `text` can have inline markdown.\",\n props: captionSchema,\n },\n Label: {\n component: Label,\n description: \"The label of a form field.\",\n props: labelSchema,\n },\n Bold: {\n component: Bold,\n description: \"Bold inline text.\",\n props: boldSchema,\n },\n Italic: {\n component: Italic,\n description: \"Italic inline text.\",\n props: inlineTextSchema,\n },\n Underline: {\n component: Underline,\n description: \"Underlined inline text.\",\n props: inlineTextSchema,\n },\n Strikethrough: {\n component: Strikethrough,\n description: \"Struck-through inline text.\",\n props: inlineTextSchema,\n },\n Badge: {\n component: Badge,\n description:\n \"A small status pill. Use the colors success, danger and warning only to show a status, not for decoration.\",\n props: badgeSchema,\n },\n Blockquote: {\n component: Blockquote,\n description:\n \"A block quotation with a line on the left. `text` can have inline markdown.\",\n props: blockquoteSchema,\n },\n Code: {\n component: Code,\n description: \"A block of code in a monospace font.\",\n props: codeSchema,\n },\n Markdown: {\n component: Markdown,\n description:\n \"A block of GitHub-flavored markdown. Use it only next to other components, for example in a table cell or next to a chart. Markdown alone goes outside the fence.\",\n props: markdownSchema,\n },\n Math: {\n component: MathFormula,\n description:\n \"A TeX math formula, typeset with KaTeX. Set block to true for a centered formula on its own line.\",\n props: mathSchema,\n },\n ShimmerText: {\n component: ShimmerText,\n description:\n \"Text with a moving shimmer. It shows that something is loading or pending.\",\n props: shimmerSchema,\n },\n Link: {\n component: Link,\n description:\n \"A link. Only http, https and mailto URLs work. It opens in a new tab.\",\n props: linkSchema,\n },\n Tooltip: {\n component: Tooltip,\n description:\n \"Shows `content` when the user points at `trigger` or moves keyboard focus to it. `trigger` is one child id: a Text, Icon or Badge, not a Button or Link. `content` is one child id of short text, for example a Text. Do not put links or buttons in `content`.\",\n slots: { trigger: \"single\", content: \"single\" } as const,\n },\n};\n","import type { GenerativeUIComponentDefinition } from \"../catalog\";\nimport { toJsonSchema } from \"../json-schema\";\n\n/** CopilotKit catalog design, not an A2UI-mandated list of signatures.\n * Express maps positional arguments using the exported JSON Schema property order:\n * https://a2ui.org/specification/proposals/express/a2ui_express/#schema-driven-key-mapping\n * Keep these prefixes stable. Optional styling is best passed by name.\n */\nexport const STANDARD_ARGUMENT_PREFIXES = {\n Box: [\"children\"],\n Column: [\"children\"],\n Row: [\"children\"],\n Grid: [\"children\", \"columns\"],\n GridItem: [\"children\"],\n Card: [\"children\", \"child\"],\n Flow: [\"children\"],\n FlowItem: [\"children\"],\n Carousel: [\"children\", \"activeIndex\"],\n CarouselItem: [\"children\"],\n CarouselMediaItem: [\"url\", \"children\", \"onClick\"],\n Spacer: [\"minSize\"],\n Divider: [\"axis\"],\n Tabs: [\"tabs\", \"selectedIndex\"],\n Title: [\"text\"],\n Text: [\"text\", \"children\"],\n Caption: [\"text\"],\n Label: [\"text\", \"htmlFor\"],\n Bold: [\"text\"],\n Italic: [\"text\"],\n Underline: [\"text\"],\n Strikethrough: [\"text\"],\n Badge: [\"label\"],\n Blockquote: [\"text\"],\n Code: [\"text\", \"language\"],\n Markdown: [\"text\"],\n Math: [\"value\"],\n ShimmerText: [\"text\"],\n Link: [\"text\", \"href\"],\n Tooltip: [\"trigger\", \"content\"],\n Button: [\"label\", \"onClick\"],\n Pressable: [\"children\", \"onClick\", \"href\"],\n Form: [\"children\", \"onSubmit\"],\n TextField: [\"label\", \"value\"],\n TextArea: [\"label\", \"value\"],\n Select: [\"label\", \"options\", \"value\"],\n CheckBox: [\"label\", \"value\"],\n Radio: [\"label\", \"value\"],\n RadioGroup: [\"label\", \"options\", \"value\"],\n Slider: [\"label\", \"value\", \"min\", \"max\"],\n SegmentedControl: [\"label\", \"options\", \"value\"],\n ChoicePicker: [\"label\", \"options\", \"value\"],\n DateTimeInput: [\"label\", \"value\"],\n PulseIndicator: [\"label\"],\n FlashcardFlip: [\"front\", \"back\"],\n Popover: [\"children\", \"open\"],\n PopoverTrigger: [\"children\"],\n PopoverContent: [\"children\"],\n Modal: [\"trigger\", \"content\", \"title\"],\n Table: [\"columns\", \"rows\", \"children\"],\n TableSection: [\"children\"],\n TableRow: [\"children\", \"label\"],\n TableCell: [\"text\", \"children\"],\n List: [\"items\", \"children\", \"action\"],\n ListItem: [\"label\", \"value\", \"action\", \"children\"],\n Chart: [\"data\", \"xKey\", \"series\", \"chartType\"],\n Map: [\"markers\", \"selected\", \"route\"],\n Image: [\"url\", \"description\", \"onOverlayClick\"],\n Icon: [\"name\", \"label\"],\n Favicon: [\"url\", \"alt\"],\n Svg: [\"paths\", \"viewBox\"],\n Video: [\"url\", \"title\", \"captions\"],\n AudioPlayer: [\"url\", \"description\"],\n HtmlView: [\"html\", \"title\"],\n LinkCard: [\"href\", \"title\", \"onClick\"],\n Citation: [\"index\", \"title\", \"url\"],\n FollowUp: [\"items\", \"onFollowUp\", \"title\"],\n EntityCard: [\"title\", \"actions\", \"onAction\", \"onClick\"],\n ImageGrid: [\"images\"],\n} as const;\n\nconst PRESENTATION_PARAMETERS = new Set([\n \"align\",\n \"aspectRatio\",\n \"background\",\n \"border\",\n \"borderColor\",\n \"clip\",\n \"color\",\n \"columnGap\",\n \"disableAutoSpacing\",\n \"flex\",\n \"flush\",\n \"fontSize\",\n \"fontWeight\",\n \"gap\",\n \"height\",\n \"highlight\",\n \"hoverBackground\",\n \"inline\",\n \"insetBorder\",\n \"italic\",\n \"justify\",\n \"lineHeight\",\n \"lineThrough\",\n \"maxHeight\",\n \"maxLines\",\n \"maxSize\",\n \"maxWidth\",\n \"minHeight\",\n \"minLines\",\n \"minSize\",\n \"minWidth\",\n \"padding\",\n \"pill\",\n \"preserveWhitespace\",\n \"radius\",\n \"role\",\n \"rowGap\",\n \"scrollable\",\n \"shadow\",\n \"shadowStyle\",\n \"size\",\n \"strokeWeight\",\n \"strong\",\n \"tabularNums\",\n \"textAlign\",\n \"truncate\",\n \"underline\",\n \"weight\",\n \"width\",\n \"wrap\",\n]);\n\n/** Put content/actions before presentation, across props, slots and events. */\nexport function standardParameterOrder(\n name: keyof typeof STANDARD_ARGUMENT_PREFIXES,\n definition: GenerativeUIComponentDefinition,\n): string[] {\n const keys = [\n ...Object.keys(\n definition.props ? (toJsonSchema(definition.props).properties ?? {}) : {},\n ),\n ...Object.keys(definition.slots ?? {}),\n ...Object.keys(definition.events ?? {}),\n ];\n const prefix: readonly string[] = STANDARD_ARGUMENT_PREFIXES[name];\n const remainder = keys.filter((key) => !prefix.includes(key));\n // Keep unknown prefix keys: createGenerativeUI rejects them, catching a\n // renamed property whose calling convention was not updated.\n return [\n ...prefix,\n ...remainder.filter((key) => !PRESENTATION_PARAMETERS.has(key)),\n ...remainder.filter((key) => PRESENTATION_PARAMETERS.has(key)),\n ];\n}\n","import { 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\";\nimport {\n standardParameterOrder,\n STANDARD_ARGUMENT_PREFIXES,\n} from \"./parameter-order\";\nimport { STANDARD_CATALOG_ID } from \"./tokens\";\n\nconst components = {\n ...layoutComponents,\n ...textComponents,\n ...inputComponents,\n ...feedbackComponents,\n ...dataComponents,\n ...mediaComponents,\n ...compositeComponents,\n};\n\n// Every standard component needs an intentional positional calling convention.\nSTANDARD_ARGUMENT_PREFIXES satisfies Record<\n keyof typeof components,\n readonly string[]\n>;\n\nconst orderedComponents = Object.fromEntries(\n Object.entries(components).map(([name, definition]) => [\n name,\n {\n ...definition,\n parameterOrder: standardParameterOrder(\n name as keyof typeof components,\n definition,\n ),\n },\n ]),\n) as {\n [Name in keyof typeof components]: (typeof components)[Name] & {\n parameterOrder: string[];\n };\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,MAAM,UAAU,UAAmB;AACnC,MAAM,QAAQ,QAAgB,gBAC5B,cAAc,GAAG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