@copilotkit/react-core 2.0.0-rc.30 → 2.0.0-rc.32

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.
Files changed (34) hide show
  1. package/README.md +1 -1
  2. package/dist/MarkdownRendererContext-CPfNVyde.d.mts +241 -0
  3. package/dist/MarkdownRendererContext-CPfNVyde.d.mts.map +1 -0
  4. package/dist/MarkdownRendererContext-iOl2pj9l.d.cts +241 -0
  5. package/dist/MarkdownRendererContext-iOl2pj9l.d.cts.map +1 -0
  6. package/dist/MarkdownSurfaces-BFoO6wSB.cjs +1650 -0
  7. package/dist/MarkdownSurfaces-BFoO6wSB.cjs.map +1 -0
  8. package/dist/MarkdownSurfaces-BQ1HGCzB.mjs +1442 -0
  9. package/dist/MarkdownSurfaces-BQ1HGCzB.mjs.map +1 -0
  10. package/dist/generative-ui.cjs +687 -2964
  11. package/dist/generative-ui.cjs.map +1 -1
  12. package/dist/generative-ui.d.cts +2478 -2683
  13. package/dist/generative-ui.d.cts.map +1 -1
  14. package/dist/generative-ui.d.mts +2477 -2682
  15. package/dist/generative-ui.d.mts.map +1 -1
  16. package/dist/generative-ui.mjs +299 -2585
  17. package/dist/generative-ui.mjs.map +1 -1
  18. package/dist/index.cjs +26 -1367
  19. package/dist/index.cjs.map +1 -1
  20. package/dist/index.d.cts +1 -1
  21. package/dist/index.d.mts +1 -1
  22. package/dist/index.mjs +11 -1352
  23. package/dist/index.mjs.map +1 -1
  24. package/dist/index.umd.js +124 -3358
  25. package/dist/index.umd.js.map +1 -1
  26. package/package.json +9 -9
  27. package/dist/MarkdownRendererContext-BX26QLwl.d.cts +0 -937
  28. package/dist/MarkdownRendererContext-BX26QLwl.d.cts.map +0 -1
  29. package/dist/MarkdownRendererContext-DAOMewji.d.mts +0 -937
  30. package/dist/MarkdownRendererContext-DAOMewji.d.mts.map +0 -1
  31. package/dist/MarkdownSurfaces-BbrHcSHN.cjs +0 -3903
  32. package/dist/MarkdownSurfaces-BbrHcSHN.cjs.map +0 -1
  33. package/dist/MarkdownSurfaces-DQbRS91-.mjs +0 -3587
  34. package/dist/MarkdownSurfaces-DQbRS91-.mjs.map +0 -1
@@ -0,0 +1,1650 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
+ key = keys[i];
12
+ if (!__hasOwnProp.call(to, key) && key !== except) {
13
+ __defProp(to, key, {
14
+ get: ((k) => from[k]).bind(null, key),
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ });
17
+ }
18
+ }
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
23
+ value: mod,
24
+ enumerable: true
25
+ }) : target, mod));
26
+
27
+ //#endregion
28
+ let _copilotkit_core = require("@copilotkit/core");
29
+ let react = require("react");
30
+ react = __toESM(react);
31
+ let _copilotkit_markdown_react = require("@copilotkit/markdown/react");
32
+ let _copilotkit_markdown = require("@copilotkit/markdown");
33
+ let react_jsx_runtime = require("react/jsx-runtime");
34
+ let _copilotkit_react_core_context = require("@copilotkit/react-core/context");
35
+ let _copilotkit_shared = require("@copilotkit/shared");
36
+ let zod = require("zod");
37
+ zod = __toESM(zod);
38
+ let _copilotkit_core_generative_ui = require("@copilotkit/core/generative-ui");
39
+ let _copilotkit_shared_generative_ui = require("@copilotkit/shared/generative-ui");
40
+
41
+ //#region src/components/chat/StreamingMarkdownDefaultRenderer.tsx
42
+ /**
43
+ * react-core's built-in default markdown renderer — a thin adapter over
44
+ * `@copilotkit/markdown`'s streaming renderer. Maps the pluggable
45
+ * renderer contract (`{ content, isStreaming, className }`) onto the streaming
46
+ * renderer for streaming-safe incremental rendering + per-token animation.
47
+ * Still overridable via the slot/provider pluggable interface.
48
+ */
49
+ function StreamingMarkdownDefaultRenderer({ content, isStreaming, className, nodeRenderers, caret, options, onLinkClick, onCitationClick }) {
50
+ if (!content) return null;
51
+ (0, _copilotkit_markdown.warnUnsupportedRichSyntaxOnce)(content);
52
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_copilotkit_markdown_react.StreamingMarkdownRenderer, {
53
+ className,
54
+ isComplete: !isStreaming,
55
+ caret: caret ?? !!isStreaming,
56
+ nodeRenderers,
57
+ nodeClassNames: _copilotkit_markdown.CHAT_MARKDOWN_NODE_CLASS_NAMES,
58
+ options,
59
+ onLinkClick,
60
+ onCitationClick,
61
+ children: content
62
+ });
63
+ }
64
+ StreamingMarkdownDefaultRenderer.displayName = "StreamingMarkdownDefaultRenderer";
65
+
66
+ //#endregion
67
+ //#region src/components/icons/CopilotIcon.tsx
68
+ /** Turns SVG attribute names such as `stroke-width` into React's `strokeWidth`. */
69
+ function toReactAttributes(attributes) {
70
+ return Object.fromEntries(Object.entries(attributes).map(([key, value]) => [key.replace(/-([a-z])/g, (_match, letter) => letter.toUpperCase()), value]));
71
+ }
72
+ const svgDefaults = toReactAttributes(_copilotkit_core.ɵcopilotIconSvgAttributes);
73
+ /** True when the props give the icon an accessible name or role. */
74
+ function hasAccessibleProp(props) {
75
+ return Object.keys(props).some((key) => key.startsWith("aria-") || key === "role" || key === "title");
76
+ }
77
+ /**
78
+ * Internal. Draws a Lucide icon from its node data, the way Lucide's React package
79
+ * does: Lucide's default SVG attributes, the `lucide lucide-<name>` classes,
80
+ * and `aria-hidden="true"` when no `aria-*`, `role` or `title` prop names it.
81
+ */
82
+ const IconSvg = (0, react.forwardRef)(function IconSvg({ lucideName, nodes, size = 24, color = "currentColor", strokeWidth = 2, className, children, ...props }, ref) {
83
+ const isDecorative = !children && !hasAccessibleProp(props);
84
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
85
+ ref,
86
+ ...svgDefaults,
87
+ width: size,
88
+ height: size,
89
+ stroke: color,
90
+ strokeWidth,
91
+ className: (0, _copilotkit_core.ɵcn)("lucide", `lucide-${lucideName}`, className),
92
+ "aria-hidden": isDecorative || void 0,
93
+ ...props,
94
+ children: [nodes.map((node, index) => (0, react.createElement)(node.tag, {
95
+ key: index,
96
+ ...node.attributes
97
+ })), children]
98
+ });
99
+ });
100
+ /**
101
+ * Draws one of the chat icons as an inline `<svg>`.
102
+ *
103
+ * The `<svg>` has the classes `lucide lucide-<icon name>`, so CSS that selects
104
+ * them (for example `svg.lucide-arrow-up`) keeps working. The icon is hidden
105
+ * from screen readers unless you give it an `aria-label`, `role` or `title`.
106
+ *
107
+ * @param props.name - The chat icon, for example `"ArrowUp"` or `"X"`.
108
+ * @param props.size - Width and height. Defaults to `24`.
109
+ * @param props.strokeWidth - Line width. Defaults to `2`.
110
+ * @param props.color - Line color. Defaults to `currentColor`.
111
+ *
112
+ * @example
113
+ * ```tsx
114
+ * <CopilotIcon name="ArrowUp" className="cpk-chat-input-send-icon" />
115
+ * <CopilotIcon name="X" aria-label="Close" />
116
+ * ```
117
+ */
118
+ const CopilotIcon = (0, react.forwardRef)(function CopilotIcon({ name, ...props }, ref) {
119
+ const icon = _copilotkit_core.ɵcopilotIcons[name];
120
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconSvg, {
121
+ ref,
122
+ lucideName: icon.name,
123
+ nodes: icon.nodes,
124
+ ...props
125
+ });
126
+ });
127
+
128
+ //#endregion
129
+ //#region src/lib/shallow-stable-ref.ts
130
+ /**
131
+ * Shallow equality comparison for objects: same own keys, each holding the
132
+ * same value (`Object.is`). Core's `ɵshallowEqualRecord` holds the rule.
133
+ */
134
+ function shallowEqual(obj1, obj2) {
135
+ return (0, _copilotkit_core.ɵshallowEqualRecord)(obj1, obj2);
136
+ }
137
+ /**
138
+ * Returns true only for plain JS objects (`{}`), excluding arrays, Dates,
139
+ * class instances, and other exotic objects that happen to have typeof "object".
140
+ */
141
+ function isPlainObject(obj) {
142
+ return obj !== null && typeof obj === "object" && Object.prototype.toString.call(obj) === "[object Object]";
143
+ }
144
+ /**
145
+ * Returns the same reference as long as the value is shallowly equal to the
146
+ * previous render's value.
147
+ *
148
+ * - Identical references bail out immediately (O(1)).
149
+ * - Plain objects ({}) are shallow-compared key-by-key.
150
+ * - Arrays, Dates, class instances, functions, and primitives are compared by
151
+ * reference only — shallowEqual is never called on non-plain objects, which
152
+ * avoids incorrect equality for e.g. [1,2] vs [1,2] (different arrays).
153
+ *
154
+ * Typical use: stabilize inline slot props so MemoizedSlotWrapper's shallow
155
+ * equality check isn't defeated by a new object reference on every render.
156
+ */
157
+ function useShallowStableRef(value) {
158
+ const ref = (0, react.useRef)(value);
159
+ if (ref.current === value) return ref.current;
160
+ if (isPlainObject(ref.current) && isPlainObject(value)) {
161
+ if (shallowEqual(ref.current, value)) return ref.current;
162
+ }
163
+ ref.current = value;
164
+ return ref.current;
165
+ }
166
+
167
+ //#endregion
168
+ //#region src/providers/CopilotChatConfigurationProvider.tsx
169
+ const CopilotChatConfiguration = (0, react.createContext)(null);
170
+ const CopilotChatConfigurationProvider = ({ children, labels, agentId, threadId, hasExplicitThreadId, isModalDefaultOpen }) => {
171
+ const parentConfig = (0, react.useContext)(CopilotChatConfiguration);
172
+ const stableLabels = useShallowStableRef(labels);
173
+ const mergedLabels = (0, react.useMemo)(() => ({
174
+ ..._copilotkit_core.CopilotChatDefaultLabels,
175
+ ...parentConfig?.labels,
176
+ ...stableLabels
177
+ }), [stableLabels, parentConfig?.labels]);
178
+ const providerAgentId = (0, _copilotkit_react_core_context.useDefaultAgentId)();
179
+ const options = {
180
+ agentId,
181
+ threadId,
182
+ hasExplicitThreadId,
183
+ isModalDefaultOpen,
184
+ providerAgentId
185
+ };
186
+ const parentStore = parentConfig?.ɵstore ?? null;
187
+ const [store] = (0, react.useState)(() => new _copilotkit_core.ɵChatConfigurationStore(options, parentStore));
188
+ store.ɵsetOptions(options);
189
+ const snapshot = (0, react.useSyncExternalStore)(store.subscribe, store.getSnapshot, store.getSnapshot);
190
+ (0, react.useEffect)(() => {
191
+ store.update({
192
+ agentId,
193
+ threadId,
194
+ hasExplicitThreadId,
195
+ isModalDefaultOpen,
196
+ providerAgentId
197
+ });
198
+ }, [
199
+ store,
200
+ agentId,
201
+ threadId,
202
+ hasExplicitThreadId,
203
+ isModalDefaultOpen,
204
+ providerAgentId
205
+ ]);
206
+ const copilotkit = (0, react.useContext)(_copilotkit_react_core_context.CopilotKitContext)?.copilotkit;
207
+ (0, react.useEffect)(() => {
208
+ if (copilotkit === void 0) return;
209
+ return store.bindOpenThread(copilotkit);
210
+ }, [copilotkit, store]);
211
+ const ownsModal = isModalDefaultOpen !== void 0;
212
+ const isModalOpen = ownsModal || !parentConfig ? snapshot.isModalOpen : parentConfig.isModalOpen;
213
+ const setModalOpen = ownsModal || !parentConfig ? store.setModalOpen : parentConfig.setModalOpen;
214
+ const { agentId: resolvedAgentId, threadId: resolvedThreadId, hasExplicitThreadId: resolvedHasExplicitThreadId, drawerOpen, drawerRegistered } = snapshot;
215
+ const configurationValue = (0, react.useMemo)(() => ({
216
+ labels: mergedLabels,
217
+ agentId: resolvedAgentId,
218
+ threadId: resolvedThreadId,
219
+ hasExplicitThreadId: resolvedHasExplicitThreadId,
220
+ isModalOpen,
221
+ setModalOpen,
222
+ drawerOpen,
223
+ setDrawerOpen: store.setDrawerOpen,
224
+ drawerRegistered,
225
+ registerDrawer: store.registerDrawer,
226
+ ɵregisterModalCloser: store.registerModalCloser,
227
+ setActiveThreadId: store.setActiveThreadId,
228
+ startNewThread: store.startNewThread,
229
+ ɵstore: store
230
+ }), [
231
+ mergedLabels,
232
+ resolvedAgentId,
233
+ resolvedThreadId,
234
+ resolvedHasExplicitThreadId,
235
+ isModalOpen,
236
+ setModalOpen,
237
+ drawerOpen,
238
+ drawerRegistered,
239
+ store
240
+ ]);
241
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotChatConfiguration.Provider, {
242
+ value: configurationValue,
243
+ children
244
+ });
245
+ };
246
+ const useCopilotChatConfiguration = () => {
247
+ return (0, react.useContext)(CopilotChatConfiguration);
248
+ };
249
+ /**
250
+ * Reports modal open/close requests to the host, and — when `open` is
251
+ * supplied — makes the modal state of an already-established chat
252
+ * configuration **controlled** for the subtree it wraps.
253
+ *
254
+ * This is deliberately a scope component rather than another mode inside
255
+ * {@link CopilotChatConfigurationProvider}. The provider resolves modal state
256
+ * across a nested chain (own state, parent sync, drawer mutual-exclusion, the
257
+ * modal-closer registry); a controlled branch inside that resolution would add
258
+ * a fourth interacting mode. Overriding the context for the subtree instead
259
+ * leaves every one of those paths untouched:
260
+ *
261
+ * - `isModalOpen` is replaced with the host's `open`, so the rendered surface
262
+ * follows the prop from the very first frame (no open-then-close flash).
263
+ * - `setModalOpen` still calls the underlying setter, so the existing
264
+ * parent-sync and drawer mutual-exclusion side effects continue to run, and
265
+ * *then* reports the request through `onOpenChange`.
266
+ * - The wrapped setter is registered as the modal closer, so the drawer's
267
+ * mobile mutual-exclusion reaches the host instead of silently flipping
268
+ * state that nothing displays.
269
+ *
270
+ * A host that supplies `open` and ignores `onOpenChange` gets a modal pinned
271
+ * to `open`, which is the standard controlled-component contract. A host that
272
+ * supplies only `onOpenChange` is notified while the modal keeps managing
273
+ * itself.
274
+ *
275
+ * Renders `children` unchanged when no chat configuration is in scope.
276
+ */
277
+ const ControlledModalOpenScope = ({ children, open, onOpenChange }) => {
278
+ const parentConfig = (0, react.useContext)(CopilotChatConfiguration);
279
+ const parentSetModalOpen = parentConfig?.setModalOpen;
280
+ const registerModalCloser = parentConfig?.ɵregisterModalCloser;
281
+ const setModalOpen = (0, react.useCallback)((next) => {
282
+ parentSetModalOpen?.(next);
283
+ onOpenChange?.(next);
284
+ }, [parentSetModalOpen, onOpenChange]);
285
+ (0, react.useEffect)(() => {
286
+ if (!registerModalCloser) return;
287
+ return registerModalCloser(setModalOpen);
288
+ }, [registerModalCloser, setModalOpen]);
289
+ const configurationValue = (0, react.useMemo)(() => parentConfig ? {
290
+ ...parentConfig,
291
+ isModalOpen: open ?? parentConfig.isModalOpen,
292
+ setModalOpen
293
+ } : null, [
294
+ parentConfig,
295
+ open,
296
+ setModalOpen
297
+ ]);
298
+ if (!configurationValue) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children });
299
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotChatConfiguration.Provider, {
300
+ value: configurationValue,
301
+ children
302
+ });
303
+ };
304
+ ControlledModalOpenScope.displayName = "ControlledModalOpenScope";
305
+
306
+ //#endregion
307
+ //#region src/lib/slots.tsx
308
+ /**
309
+ * Check if a value is a React component type (function, class, forwardRef, memo, etc.)
310
+ */
311
+ function isReactComponentType(value) {
312
+ if (typeof value === "function") return true;
313
+ if (value && typeof value === "object" && "$$typeof" in value && !react.default.isValidElement(value)) return true;
314
+ return false;
315
+ }
316
+ /**
317
+ * Internal function to render a slot value as a React element (non-memoized).
318
+ */
319
+ function renderSlotElement(slot, DefaultComponent, props) {
320
+ if (typeof slot === "string") {
321
+ const existingClassName = props.className;
322
+ return react.default.createElement(DefaultComponent, {
323
+ ...props,
324
+ className: (0, _copilotkit_core.ɵcn)(existingClassName, slot)
325
+ });
326
+ }
327
+ if (isReactComponentType(slot)) return react.default.createElement(slot, props);
328
+ if (slot && typeof slot === "object" && !react.default.isValidElement(slot)) return react.default.createElement(DefaultComponent, {
329
+ ...props,
330
+ ...slot
331
+ });
332
+ return react.default.createElement(DefaultComponent, props);
333
+ }
334
+ /**
335
+ * Internal memoized wrapper component for renderSlot.
336
+ * Uses forwardRef to support ref forwarding.
337
+ */
338
+ const MemoizedSlotWrapper = react.default.memo(react.default.forwardRef(function MemoizedSlotWrapper(props, ref) {
339
+ const { $slot, $component, ...rest } = props;
340
+ return renderSlotElement($slot, $component, ref !== null ? {
341
+ ...rest,
342
+ ref
343
+ } : rest);
344
+ }), (prev, next) => {
345
+ if (prev.$slot !== next.$slot) return false;
346
+ if (prev.$component !== next.$component) return false;
347
+ const { $slot: _ps, $component: _pc, ...prevRest } = prev;
348
+ const { $slot: _ns, $component: _nc, ...nextRest } = next;
349
+ return shallowEqual(prevRest, nextRest);
350
+ });
351
+ /**
352
+ * Renders a slot value as a memoized React element.
353
+ * Automatically prevents unnecessary re-renders using shallow prop comparison.
354
+ * Supports ref forwarding.
355
+ *
356
+ * @example
357
+ * renderSlot(customInput, CopilotChatInput, { onSubmit: handleSubmit })
358
+ */
359
+ function renderSlot(slot, DefaultComponent, props) {
360
+ return react.default.createElement(MemoizedSlotWrapper, {
361
+ ...props,
362
+ $slot: slot,
363
+ $component: DefaultComponent
364
+ });
365
+ }
366
+
367
+ //#endregion
368
+ //#region src/providers/MarkdownRendererContext.tsx
369
+ const MarkdownRendererContext = (0, react.createContext)(void 0);
370
+ const MarkdownRendererProvider = ({ renderer, children }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MarkdownRendererContext.Provider, {
371
+ value: renderer,
372
+ children
373
+ });
374
+ /**
375
+ * The markdown renderer set at the provider level, or `undefined` when none was
376
+ * supplied. Message components fall back to the built-in
377
+ * `StreamingMarkdownDefaultRenderer` (via `CopilotChatAssistantMessage.MarkdownRenderer`)
378
+ * when this is `undefined`.
379
+ */
380
+ function useMarkdownRenderer() {
381
+ return (0, react.useContext)(MarkdownRendererContext);
382
+ }
383
+
384
+ //#endregion
385
+ //#region src/types/defineToolCallRenderer.ts
386
+ function defineToolCallRenderer(def) {
387
+ const argsSchema = def.name === "*" && !def.args ? _copilotkit_shared.ɵanySchema : def.args;
388
+ return {
389
+ name: def.name,
390
+ args: argsSchema,
391
+ render: def.render,
392
+ ...def.agentId ? { agentId: def.agentId } : {},
393
+ ...def.group ? { group: true } : {}
394
+ };
395
+ }
396
+
397
+ //#endregion
398
+ //#region src/generative-ui/catalog.ts
399
+ /**
400
+ * Experimental. Declares the components the model can render, the app state
401
+ * they read, and the functions they call.
402
+ *
403
+ * - A prop with the name of a top-level state key is bound to that state.
404
+ * - `bind: { prop: (state, props) => value }` binds a prop to a selector.
405
+ * - An event binds to the function with its name, else to the name without
406
+ * `on` (`onAddToCart` calls `addToCart`).
407
+ * - `writable: ["value"]` gives the component a `setValue` prop. See
408
+ * `GenerativeUIComponentDefinition.writable`.
409
+ *
410
+ * The model does not see bound props or matched events.
411
+ *
412
+ * @param config - `id`, then optional `extends`, `state`, `functions` and
413
+ * `overrides`, then `components`. Put `state` before `components`, so the selectors
414
+ * get typed state.
415
+ * @throws Error when a name comes from two places, an override names no
416
+ * component of the bases, `props` is not an object
417
+ * schema with a JSON Schema, a key is reserved or used
418
+ * twice on a component, an event matches two functions, an unmatched event
419
+ * has no `parameters`, a `bind` key is not a prop, a `writable` key is not
420
+ * a prop or is a bound prop, or a setter name is already a key of the
421
+ * component. Also throws when `parameterOrder` contains duplicate or unknown
422
+ * keys, or an ordered component declares integer-index keys whose JSON object
423
+ * enumeration order cannot be controlled.
424
+ *
425
+ * @example
426
+ * ```ts
427
+ * const ui = createGenerativeUI({
428
+ * id: "acme/store@1",
429
+ * state: { cart: cartSchema },
430
+ * functions: { addToCart: { parameters: z.object({ productId: z.string() }) } },
431
+ * components: {
432
+ * CartSummary: {
433
+ * component: CartSummary,
434
+ * props: z.object({ count: z.number() }),
435
+ * bind: { count: (state) => state.cart.count },
436
+ * },
437
+ * },
438
+ * });
439
+ * ```
440
+ */
441
+ function createGenerativeUI(config) {
442
+ return (0, _copilotkit_shared_generative_ui.createGenerativeUI)(config);
443
+ }
444
+
445
+ //#endregion
446
+ //#region src/generative-ui/runtime-context.ts
447
+ const GenerativeUIRuntimeContext = (0, react.createContext)(null);
448
+ function useGenerativeUIRuntime() {
449
+ return (0, react.useContext)(GenerativeUIRuntimeContext);
450
+ }
451
+ function useRequiredGenerativeUIRuntime() {
452
+ const runtime = (0, react.useContext)(GenerativeUIRuntimeContext);
453
+ if (!runtime) throw new Error("Generative UI components must be rendered inside <CopilotKitProvider generativeUI={{ ui }}>.");
454
+ return runtime;
455
+ }
456
+ const GenerativeUINodeContext = (0, react.createContext)(null);
457
+
458
+ //#endregion
459
+ //#region src/generative-ui/hooks.ts
460
+ const noopSubscribe$1 = () => () => {};
461
+ const zero = () => 0;
462
+ /** Re-renders on any surface-manager change. */
463
+ function useManagerVersion(runtime) {
464
+ return (0, react.useSyncExternalStore)(runtime?.manager.subscribe ?? noopSubscribe$1, runtime?.manager.getVersion ?? zero, zero);
465
+ }
466
+ /**
467
+ * Experimental. Gives one key of the app state declared in
468
+ * `createGenerativeUI({ state })` its value. Bound props of generated
469
+ * components read it. The model does not see it.
470
+ *
471
+ * The key is set on mount and when the value changes (compared as JSON). It
472
+ * is removed on unmount.
473
+ *
474
+ * @param ui - The object from `createGenerativeUI`. It gives the key and the
475
+ * value their types.
476
+ * @param key - A top-level key of `state`.
477
+ * @param value - The value of that key. It must fit the key's schema.
478
+ *
479
+ * @example
480
+ * ```tsx
481
+ * useGenerativeUIState(storeUI, "cart", { count, total, coupon, items });
482
+ * ```
483
+ */
484
+ function useGenerativeUIState(ui, key, value) {
485
+ const runtime = useRequiredGenerativeUIRuntime();
486
+ const serialized = JSON.stringify(value);
487
+ (0, react.useEffect)(() => {
488
+ const raw = JSON.parse(serialized ?? "null");
489
+ let current = true;
490
+ const apply = (parsed) => {
491
+ if (!current) return;
492
+ if (parsed.success) {
493
+ runtime.manager.setState(key, parsed.data);
494
+ return;
495
+ }
496
+ runtime.manager.removeState(key);
497
+ if (process.env.NODE_ENV !== "production") console.error(`[generativeUI] useGenerativeUIState: invalid value for "${key}": ${(0, _copilotkit_shared_generative_ui.formatIssues)(parsed.issues, "value")}`);
498
+ };
499
+ const schema = runtime.ui.state.get(key);
500
+ const parsed = schema ? (0, _copilotkit_shared_generative_ui.validateSchema)(schema, raw) : {
501
+ success: true,
502
+ data: raw
503
+ };
504
+ if (parsed instanceof Promise) parsed.then(apply);
505
+ else apply(parsed);
506
+ return () => {
507
+ current = false;
508
+ };
509
+ }, [
510
+ runtime,
511
+ key,
512
+ serialized
513
+ ]);
514
+ (0, react.useEffect)(() => () => runtime.manager.removeState(key), [runtime, key]);
515
+ }
516
+ /**
517
+ * Experimental. Mounts the handler of a function declared in
518
+ * `createGenerativeUI({ functions })`. Generated UI can call the function
519
+ * only while exactly one handler for it is mounted.
520
+ *
521
+ * The handler gets the parsed arguments: schema defaults are set. It can
522
+ * change on each render. The latest handler always runs, and the hook does
523
+ * not register again.
524
+ *
525
+ * @param ui - The object from `createGenerativeUI`. It gives the name and the
526
+ * handler arguments their types.
527
+ * @param name - A key of `functions`.
528
+ * @param handler - Runs when generated UI calls the function. Its return
529
+ * value goes back to the caller as `{ ok: true, result }`.
530
+ *
531
+ * @example
532
+ * ```tsx
533
+ * useGenerativeUIFunction(storeUI, "addToCart", ({ productId, quantity }) =>
534
+ * cart.addItem(productId, quantity),
535
+ * );
536
+ * ```
537
+ */
538
+ function useGenerativeUIFunction(ui, name, handler) {
539
+ const runtime = useRequiredGenerativeUIRuntime();
540
+ const latest = (0, react.useRef)(handler);
541
+ latest.current = handler;
542
+ (0, react.useEffect)(() => runtime.dispatcher.register(name, latest), [runtime, name]);
543
+ }
544
+
545
+ //#endregion
546
+ //#region src/generative-ui/boundaries.tsx
547
+ function DefaultNodeFallback({ message, componentId, retry }) {
548
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
549
+ role: "alert",
550
+ "data-generative-ui-error": componentId,
551
+ style: {
552
+ border: "1px solid #fca5a5",
553
+ background: "#fef2f2",
554
+ color: "#991b1b",
555
+ borderRadius: 8,
556
+ padding: "8px 12px",
557
+ fontSize: 13
558
+ },
559
+ children: [
560
+ "Couldn’t display this part: ",
561
+ message,
562
+ retry && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
563
+ type: "button",
564
+ onClick: retry,
565
+ style: {
566
+ marginLeft: 8,
567
+ textDecoration: "underline"
568
+ },
569
+ children: "Retry"
570
+ })
571
+ ]
572
+ });
573
+ }
574
+ /**
575
+ * A child that has not streamed yet renders nothing. The prose keeps
576
+ * streaming above the surface, and each component appears as soon as it is
577
+ * complete. A grey block in its place would read as a broken layout.
578
+ */
579
+ function NodePlaceholder(_props) {
580
+ return null;
581
+ }
582
+ /** Per-node boundary. Resets on retry or a new agent revision, not on data ticks. */
583
+ var NodeBoundary = class extends react.Component {
584
+ state = {
585
+ error: null,
586
+ revision: this.props.revision
587
+ };
588
+ static getDerivedStateFromError(error) {
589
+ return { error };
590
+ }
591
+ static getDerivedStateFromProps(props, state) {
592
+ return props.revision !== state.revision ? {
593
+ error: null,
594
+ revision: props.revision
595
+ } : null;
596
+ }
597
+ componentDidCatch(error) {
598
+ const { runtime, surfaceId, componentId } = this.props;
599
+ (0, _copilotkit_core_generative_ui.reportErrorSafely)(runtime, {
600
+ kind: "render",
601
+ surfaceId,
602
+ componentId,
603
+ error
604
+ });
605
+ }
606
+ retry = () => this.setState({ error: null });
607
+ render() {
608
+ const { error } = this.state;
609
+ if (!error) return this.props.children;
610
+ const { runtime, surfaceId, componentId } = this.props;
611
+ const fallback = runtime.errorFallback;
612
+ return fallback ? fallback({
613
+ error,
614
+ retry: this.retry,
615
+ surfaceId,
616
+ componentId
617
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DefaultNodeFallback, {
618
+ message: error.message,
619
+ componentId,
620
+ retry: this.retry
621
+ });
622
+ }
623
+ };
624
+ /** Outer boundary: a failure here must not reach the chat or the host page. */
625
+ var SurfaceBoundary = class extends react.Component {
626
+ state = { error: null };
627
+ static getDerivedStateFromError(error) {
628
+ return { error };
629
+ }
630
+ componentDidCatch(error) {
631
+ (0, _copilotkit_core_generative_ui.reportErrorSafely)(this.props.runtime, {
632
+ kind: "render",
633
+ surfaceId: this.props.surfaceId,
634
+ error
635
+ });
636
+ }
637
+ render() {
638
+ if (!this.state.error) return this.props.children;
639
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DefaultNodeFallback, {
640
+ message: "this generated UI failed to render",
641
+ componentId: "surface"
642
+ });
643
+ }
644
+ };
645
+
646
+ //#endregion
647
+ //#region src/generative-ui/accessibility.ts
648
+ /**
649
+ * Experimental. The ARIA attributes of the `accessibility` that the model
650
+ * gave the component being rendered, to spread on its root element. The
651
+ * standard components do this; a custom component does it itself:
652
+ *
653
+ * @example
654
+ * ```tsx
655
+ * function Panel({ children }: { children?: ReactNode }) {
656
+ * const aria = useGenerativeUIAccessibility();
657
+ * return <section {...aria}>{children}</section>;
658
+ * }
659
+ * ```
660
+ *
661
+ * Outside of generated UI it gives `{}`.
662
+ */
663
+ function useGenerativeUIAccessibility() {
664
+ const accessibility = (0, react.useContext)(GenerativeUINodeContext)?.accessibility;
665
+ return (0, react.useMemo)(() => (0, _copilotkit_core_generative_ui.accessibilityAttributes)(accessibility), [accessibility]);
666
+ }
667
+
668
+ //#endregion
669
+ //#region src/generative-ui/SurfaceView.tsx
670
+ const NO_ANCESTORS = [];
671
+ const ROOT_STYLE = { display: "contents" };
672
+ const undefinedSnapshot = () => void 0;
673
+ const noopSubscribe = () => () => {};
674
+ const zeroSnapshot = () => 0;
675
+ /** A "multiple" slot value that repeats a component for each list item. */
676
+ function isTemplateChildren(value) {
677
+ return typeof value === "object" && value !== null && "componentId" in value && typeof value.componentId === "string" && "path" in value && typeof value.path === "string";
678
+ }
679
+ function SurfaceView({ surface }) {
680
+ const runtime = useRequiredGenerativeUIRuntime();
681
+ const { theme } = runtime;
682
+ const sheet = (0, react.useMemo)(() => (0, _copilotkit_shared_generative_ui.themeStyleSheet)(theme), [theme]);
683
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
684
+ className: "a2ui-surface",
685
+ "data-generative-ui-root": surface.surfaceId,
686
+ "data-a2ui-theme": sheet?.id,
687
+ style: ROOT_STYLE,
688
+ children: [sheet ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("style", { dangerouslySetInnerHTML: { __html: sheet.css } }) : null, /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SurfaceBoundary, {
689
+ surfaceId: surface.surfaceId,
690
+ runtime,
691
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(NodeView, {
692
+ surface,
693
+ componentId: _copilotkit_shared.GENERATIVE_UI_ROOT_ID,
694
+ basePath: void 0,
695
+ ancestors: NO_ANCESTORS
696
+ })
697
+ })]
698
+ });
699
+ }
700
+ /**
701
+ * Resolves a component by id. Subscribes to the manager rather than web_core's
702
+ * `onCreated`/`onDeleted`: web_core's EventEmitter awaits each listener in turn,
703
+ * so with several subscribers (one per slotted child, or one per mount of the
704
+ * same surface) all but the first are notified a microtask late. That is only
705
+ * visible inside synchronous flushes such as `act()` / `flushSync`, where the
706
+ * old tree would still be on screen, but it makes updates order-dependent.
707
+ * The manager notifies synchronously once an ingest has been fully applied.
708
+ */
709
+ function useComponentModel(manager, model, id) {
710
+ return (0, react.useSyncExternalStore)(manager.subscribe, () => model.componentsModel.get(id), undefinedSnapshot);
711
+ }
712
+ /** Same reasoning as `useComponentModel`: never rely on web_core's emitters. */
713
+ function useComponentProperties(manager, component) {
714
+ return (0, react.useSyncExternalStore)(manager.subscribe, () => component?.properties, undefinedSnapshot);
715
+ }
716
+ /**
717
+ * The id of a node in the ancestor list. A template renders the same
718
+ * component once per item, so the item path is part of the id. A real cycle
719
+ * repeats both.
720
+ */
721
+ function scopedId(componentId, basePath) {
722
+ return `${basePath ?? ""}#${componentId}`;
723
+ }
724
+ const NodeView = (0, react.memo)(function NodeView({ surface, componentId, basePath, ancestors }) {
725
+ const runtime = useRequiredGenerativeUIRuntime();
726
+ const component = useComponentModel(runtime.manager, surface.model, componentId);
727
+ const properties = useComponentProperties(runtime.manager, component);
728
+ if (ancestors.includes(scopedId(componentId, basePath))) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DefaultNodeFallback, {
729
+ message: `cyclic reference to ${componentId}`,
730
+ componentId
731
+ });
732
+ if (!component || !properties) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(NodePlaceholder, { componentId });
733
+ const definition = runtime.ui.components.get(component.type);
734
+ if (!definition) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DefaultNodeFallback, {
735
+ message: `unknown component "${component.type}"`,
736
+ componentId
737
+ });
738
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(NodeBoundary, {
739
+ surfaceId: surface.surfaceId,
740
+ componentId,
741
+ revision: properties,
742
+ runtime,
743
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResolvedNode, {
744
+ surface,
745
+ componentId,
746
+ definition,
747
+ properties,
748
+ runtime,
749
+ basePath,
750
+ ancestors
751
+ })
752
+ }, component.type);
753
+ });
754
+ /**
755
+ * Renders the component of a template once for each item of the list at the
756
+ * template path, keyed by index. Renders nothing when there is no list.
757
+ */
758
+ function TemplateChildren({ surface, template, basePath, ancestors }) {
759
+ const dataModel = surface.model.dataModel;
760
+ const listPath = (0, _copilotkit_core_generative_ui.resolvePath)(template.path, basePath);
761
+ const subscribe = (0, react.useCallback)((onChange) => {
762
+ const subscription = dataModel.subscribe(listPath, onChange);
763
+ return () => subscription.unsubscribe();
764
+ }, [dataModel, listPath]);
765
+ const getCount = () => {
766
+ const list = dataModel.get(listPath);
767
+ return Array.isArray(list) ? list.length : 0;
768
+ };
769
+ const count = (0, react.useSyncExternalStore)(subscribe, getCount, zeroSnapshot);
770
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: Array.from({ length: count }, (_, index) => index).map((index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(NodeView, {
771
+ surface,
772
+ componentId: template.componentId,
773
+ basePath: (0, _copilotkit_core_generative_ui.joinPath)(listPath, String(index)),
774
+ ancestors
775
+ }, index)) });
776
+ }
777
+ /**
778
+ * The props the model sets, with their dynamic values resolved from the
779
+ * surface data model: `{"@path"}` bindings, `{"@call"}` function values and
780
+ * `{"@call":"@index"}` in a template, at any depth. A literal writable prop
781
+ * that the component set shows the local value from `overrides`. Bound
782
+ * props, events and slots are left out, and so are the keys of the A2UI
783
+ * component envelope; `accessibility` is resolved the same way and given
784
+ * on its own.
785
+ *
786
+ * A prop is resolved again only when its raw value or a data model value it
787
+ * read has changed, so the result keeps its identity otherwise. A function
788
+ * value that cannot be computed gives a problem instead of values.
789
+ */
790
+ function useModelDataProps(surface, definition, properties, basePath, overrides) {
791
+ const dataModel = surface.model.dataModel;
792
+ const units = (0, react.useMemo)(() => {
793
+ const list = [];
794
+ for (const key of Object.keys(properties)) {
795
+ if (definition.events?.[key] || definition.slots?.[key] || Object.hasOwn(definition.selectors, key) || _copilotkit_shared.A2UI_COMPONENT_ENVELOPE_KEYS.has(key)) continue;
796
+ list.push({
797
+ key,
798
+ raw: properties[key]
799
+ });
800
+ }
801
+ const a11y = properties.accessibility;
802
+ if (typeof a11y === "object" && a11y !== null && !Array.isArray(a11y)) for (const [field, raw] of Object.entries(a11y)) list.push({
803
+ key: `accessibility/${field}`,
804
+ raw,
805
+ field
806
+ });
807
+ return list;
808
+ }, [properties, definition]);
809
+ const [, rerender] = (0, react.useReducer)((n) => n + 1, 0);
810
+ const cache = (0, react.useRef)(/* @__PURE__ */ new Map());
811
+ const values = {};
812
+ const a11yValues = {};
813
+ const paths = /* @__PURE__ */ new Set();
814
+ let problem;
815
+ const next = /* @__PURE__ */ new Map();
816
+ for (const { key, raw, field } of units) {
817
+ const cached = cache.current.get(key);
818
+ const isFresh = cached !== void 0 && cached.raw === raw && cached.basePath === basePath && [...cached.reads].every(([path, value]) => Object.is(dataModel.get(path), value));
819
+ const resolve = () => {
820
+ const resolved = (0, _copilotkit_core_generative_ui.tryResolveDynamicValue)(raw, {
821
+ data: dataModel,
822
+ basePath
823
+ }, { isChecks: key === "checks" });
824
+ const reads = /* @__PURE__ */ new Map();
825
+ for (const path of resolved.paths) reads.set(path, dataModel.get(path));
826
+ return {
827
+ raw,
828
+ basePath,
829
+ reads,
830
+ outcome: resolved.ok ? {
831
+ ok: true,
832
+ value: resolved.value
833
+ } : {
834
+ ok: false,
835
+ message: resolved.error.message
836
+ }
837
+ };
838
+ };
839
+ const entry = isFresh && cached ? cached : resolve();
840
+ next.set(key, entry);
841
+ if (field !== void 0) {
842
+ if (entry.outcome.ok) a11yValues[field] = entry.outcome.value;
843
+ } else if (entry.outcome.ok) values[key] = entry.outcome.value;
844
+ else problem ??= `${key}: ${entry.outcome.message}`;
845
+ for (const path of entry.reads.keys()) paths.add(path);
846
+ }
847
+ cache.current = next;
848
+ const accessibility = (0, _copilotkit_core_generative_ui.readAccessibility)(a11yValues);
849
+ for (const [key, value] of Object.entries(overrides)) if (!(0, _copilotkit_shared.isPathBinding)(properties[key])) values[key] = value;
850
+ const rendered = (0, react.useRef)(next);
851
+ rendered.current = next;
852
+ const pathKey = [...paths].sort().join("\n");
853
+ (0, react.useEffect)(() => {
854
+ const list = pathKey === "" ? [] : pathKey.split("\n");
855
+ const onChange = () => {
856
+ cache.current = /* @__PURE__ */ new Map();
857
+ rerender();
858
+ };
859
+ const subscriptions = list.map((path) => dataModel.subscribe(path, onChange));
860
+ if ([...rendered.current.values()].some((entry) => [...entry.reads].some(([path, value]) => !Object.is(dataModel.get(path), value)))) rerender();
861
+ return () => subscriptions.forEach((s) => s.unsubscribe());
862
+ }, [dataModel, pathKey]);
863
+ const stable = (0, react.useRef)({
864
+ ok: true,
865
+ values: {},
866
+ accessibility: void 0
867
+ });
868
+ const result = problem === void 0 ? {
869
+ ok: true,
870
+ values,
871
+ accessibility
872
+ } : {
873
+ ok: false,
874
+ problem
875
+ };
876
+ const last = stable.current;
877
+ if (!(result.ok && last.ok ? shallowEqual(last.values, result.values) && shallowEqual(last.accessibility ?? {}, result.accessibility ?? {}) : !result.ok && !last.ok && last.problem === result.problem)) stable.current = result;
878
+ return stable.current;
879
+ }
880
+ const NO_SELECTION = {
881
+ ok: true,
882
+ values: {}
883
+ };
884
+ function isSameSelection(a, b) {
885
+ if (a.ok && b.ok) return shallowEqual(a.values, b.values);
886
+ if (!a.ok && !b.ok) return a.problem === b.problem;
887
+ return false;
888
+ }
889
+ /** Runs every selector of a node. A selector that throws gives a problem. */
890
+ function select(definition, state, modelProps) {
891
+ const values = {};
892
+ const selectors = Object.entries(definition.selectors);
893
+ for (const [key, selector] of selectors) try {
894
+ values[key] = selector(state, modelProps);
895
+ } catch (error) {
896
+ return {
897
+ ok: false,
898
+ problem: `${key}: selector threw: ${error instanceof Error ? error.message : String(error)}`
899
+ };
900
+ }
901
+ return {
902
+ ok: true,
903
+ values
904
+ };
905
+ }
906
+ /**
907
+ * The values of the bound props of a node, read from the app state.
908
+ *
909
+ * The selectors run again only when the state object or the parsed model
910
+ * props change. When the new values are shallow-equal to the last ones, the
911
+ * last snapshot is kept. So the node re-renders only when a selected value
912
+ * changes. A selector that returns a new array on each call cannot cause a
913
+ * render loop: with the same inputs, the cached snapshot comes back.
914
+ *
915
+ * A node without bound props does not subscribe to the state.
916
+ */
917
+ function useSelection(manager, definition, modelProps) {
918
+ const hasSelectors = Object.keys(definition.selectors).length > 0;
919
+ const cache = (0, react.useRef)(void 0);
920
+ const getSnapshot = () => {
921
+ if (!hasSelectors || modelProps === void 0) return NO_SELECTION;
922
+ const state = manager.getState();
923
+ const cached = cache.current;
924
+ if (cached !== void 0 && cached.state === state && cached.modelProps === modelProps) return cached.selection;
925
+ const next = select(definition, state, modelProps);
926
+ const selection = cached !== void 0 && isSameSelection(cached.selection, next) ? cached.selection : next;
927
+ cache.current = {
928
+ state,
929
+ modelProps,
930
+ selection
931
+ };
932
+ return selection;
933
+ };
934
+ return (0, react.useSyncExternalStore)(hasSelectors ? manager.subscribe : noopSubscribe, getSnapshot, getSnapshot);
935
+ }
936
+ /**
937
+ * Checks the model-set props with the props schema before the selectors run.
938
+ * The bound props are not set yet, so their issues do not count. Neither do
939
+ * issues with no path (a check over several props), which the full check
940
+ * after the selectors reports.
941
+ */
942
+ function checkModelProps(definition, modelData) {
943
+ if (!definition.props) return {
944
+ ok: true,
945
+ values: {}
946
+ };
947
+ let values = modelData;
948
+ let result = (0, _copilotkit_shared_generative_ui.validateSchemaSync)(definition.props, values);
949
+ if (!result.success) {
950
+ const unset = (0, _copilotkit_shared_generative_ui.withoutRejectedNulls)(values, result.issues);
951
+ if (unset) {
952
+ values = unset;
953
+ result = (0, _copilotkit_shared_generative_ui.validateSchemaSync)(definition.props, values);
954
+ }
955
+ }
956
+ if (!result.success) {
957
+ const issues = result.issues.filter((issue) => {
958
+ const key = (0, _copilotkit_shared_generative_ui.issueKey)(issue);
959
+ return key === void 0 ? (0, _copilotkit_shared_generative_ui.isAsyncIssue)(issue) : !Object.hasOwn(definition.selectors, key);
960
+ });
961
+ if (issues.length > 0) return {
962
+ ok: false,
963
+ problem: (0, _copilotkit_shared_generative_ui.formatIssues)(issues)
964
+ };
965
+ }
966
+ return {
967
+ ok: true,
968
+ values
969
+ };
970
+ }
971
+ /**
972
+ * The data props of a node, in three steps: check the model-set props with
973
+ * the props schema, run the selectors with them, then parse all props with
974
+ * the props schema. Gives the reason when a step fails.
975
+ */
976
+ function useDataProps(runtime, surface, definition, properties, basePath, overrides) {
977
+ const modelData = useModelDataProps(surface, definition, properties, basePath, overrides);
978
+ const modelCheck = (0, react.useMemo)(() => modelData.ok ? checkModelProps(definition, modelData.values) : modelData, [definition, modelData]);
979
+ const selection = useSelection(runtime.manager, definition, modelCheck.ok ? modelCheck.values : void 0);
980
+ const accessibility = modelData.ok ? modelData.accessibility : void 0;
981
+ return (0, react.useMemo)(() => {
982
+ if (!modelCheck.ok) return modelCheck;
983
+ if (!selection.ok) return selection;
984
+ if (!definition.props) return {
985
+ ok: true,
986
+ props: {},
987
+ accessibility
988
+ };
989
+ const input = {
990
+ ...modelCheck.values,
991
+ ...selection.values
992
+ };
993
+ let parsed = (0, _copilotkit_shared_generative_ui.validateSchemaSync)(definition.props, input);
994
+ if (!parsed.success) {
995
+ const unset = (0, _copilotkit_shared_generative_ui.withoutRejectedNulls)(input, parsed.issues);
996
+ if (unset) parsed = (0, _copilotkit_shared_generative_ui.validateSchemaSync)(definition.props, unset);
997
+ }
998
+ if (!parsed.success) return {
999
+ ok: false,
1000
+ problem: (0, _copilotkit_shared_generative_ui.formatIssues)(parsed.issues)
1001
+ };
1002
+ return {
1003
+ ok: true,
1004
+ props: parsed.data,
1005
+ accessibility
1006
+ };
1007
+ }, [
1008
+ definition,
1009
+ modelCheck,
1010
+ selection,
1011
+ accessibility
1012
+ ]);
1013
+ }
1014
+ /**
1015
+ * The event props of a node. A matched event (one that matches a declared
1016
+ * function) is always bound. An unmatched event is bound only when the model
1017
+ * bound it.
1018
+ */
1019
+ function useEventProps(runtime, surface, componentId, definition, properties, basePath) {
1020
+ const latest = (0, react.useRef)(properties);
1021
+ latest.current = properties;
1022
+ const boundNames = Object.keys(definition.events ?? {}).filter((name) => Object.hasOwn(definition.eventFunctions, name) || (0, _copilotkit_shared.isActionBinding)(properties[name])).join("|");
1023
+ return (0, react.useMemo)(() => {
1024
+ const handlers = {};
1025
+ const names = boundNames ? boundNames.split("|") : [];
1026
+ for (const name of names) {
1027
+ const call = {
1028
+ runtime,
1029
+ surface,
1030
+ componentId,
1031
+ name,
1032
+ parameters: definition.events?.[name]?.parameters
1033
+ };
1034
+ const functionName = Object.hasOwn(definition.eventFunctions, name) ? definition.eventFunctions[name] : void 0;
1035
+ handlers[name] = functionName === void 0 ? (args) => (0, _copilotkit_core_generative_ui.invokeBoundEvent)({
1036
+ ...call,
1037
+ binding: latest.current[name],
1038
+ basePath,
1039
+ args
1040
+ }) : (args) => (0, _copilotkit_core_generative_ui.invokeMatchedEvent)({
1041
+ ...call,
1042
+ functionName,
1043
+ args
1044
+ });
1045
+ }
1046
+ return handlers;
1047
+ }, [
1048
+ boundNames,
1049
+ runtime,
1050
+ surface,
1051
+ componentId,
1052
+ definition,
1053
+ basePath
1054
+ ]);
1055
+ }
1056
+ /**
1057
+ * The setter props of a node: `setValue` for the writable prop `value`. For
1058
+ * a prop the model bound to `{"@path"}`, the setter writes the data model
1059
+ * and makes the path user-owned. For a literal prop, it sets `overrides`, a
1060
+ * local value of this mounted node. The setters keep their identity.
1061
+ */
1062
+ function useSetterProps(runtime, surface, componentId, definition, properties, basePath) {
1063
+ const [overrides, setOverrides] = (0, react.useState)({});
1064
+ const latest = (0, react.useRef)(properties);
1065
+ latest.current = properties;
1066
+ return {
1067
+ overrides,
1068
+ setters: (0, react.useMemo)(() => {
1069
+ const result = {};
1070
+ const writable = definition.writable ?? [];
1071
+ for (const key of writable) result[(0, _copilotkit_shared_generative_ui.setterNameOf)(key)] = (value) => {
1072
+ const binding = latest.current[key];
1073
+ if (!(0, _copilotkit_shared.isPathBinding)(binding)) {
1074
+ setOverrides((current) => ({
1075
+ ...current,
1076
+ [key]: value
1077
+ }));
1078
+ return;
1079
+ }
1080
+ try {
1081
+ runtime.manager.setOwnedValue(surface.key, (0, _copilotkit_core_generative_ui.resolvePath)(binding["@path"], basePath), value);
1082
+ } catch (cause) {
1083
+ const message = cause instanceof Error ? cause.message : String(cause);
1084
+ (0, _copilotkit_core_generative_ui.reportErrorSafely)(runtime, {
1085
+ kind: "props",
1086
+ surfaceId: surface.surfaceId,
1087
+ componentId,
1088
+ error: /* @__PURE__ */ new Error(`${(0, _copilotkit_shared_generative_ui.setterNameOf)(key)}: ${message}`)
1089
+ });
1090
+ }
1091
+ };
1092
+ return result;
1093
+ }, [
1094
+ runtime,
1095
+ surface,
1096
+ componentId,
1097
+ definition,
1098
+ basePath
1099
+ ])
1100
+ };
1101
+ }
1102
+ function useSlotProps(surface, definition, properties, componentId, basePath, ancestors) {
1103
+ return (0, react.useMemo)(() => {
1104
+ const childAncestors = [...ancestors, scopedId(componentId, basePath)];
1105
+ const slots = {};
1106
+ for (const [name, kind] of Object.entries(definition.slots ?? {})) {
1107
+ const value = properties[name];
1108
+ if (kind === "single" && typeof value === "string") slots[name] = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(NodeView, {
1109
+ surface,
1110
+ componentId: value,
1111
+ basePath,
1112
+ ancestors: childAncestors
1113
+ });
1114
+ else if (kind === "multiple" && isTemplateChildren(value)) slots[name] = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TemplateChildren, {
1115
+ surface,
1116
+ template: value,
1117
+ basePath,
1118
+ ancestors: childAncestors
1119
+ });
1120
+ else if (kind === "multiple" && Array.isArray(value)) slots[name] = [...new Set(value.filter((id) => typeof id === "string"))].map((id) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(NodeView, {
1121
+ surface,
1122
+ componentId: id,
1123
+ basePath,
1124
+ ancestors: childAncestors
1125
+ }, id));
1126
+ }
1127
+ return slots;
1128
+ }, [
1129
+ surface,
1130
+ definition,
1131
+ properties,
1132
+ componentId,
1133
+ basePath,
1134
+ ancestors
1135
+ ]);
1136
+ }
1137
+ /**
1138
+ * The parsed data props with every typed child reference (`child()`,
1139
+ * `childList()`, at any depth) replaced by the rendered component. Without
1140
+ * references, the parsed props come back as they are.
1141
+ */
1142
+ function useChildRefProps(surface, refs, props, componentId, basePath, ancestors) {
1143
+ return (0, react.useMemo)(() => {
1144
+ if (props === void 0 || refs.length === 0) return props;
1145
+ const childAncestors = [...ancestors, scopedId(componentId, basePath)];
1146
+ const render = (kind, value) => {
1147
+ if (kind === "single") return typeof value === "string" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(NodeView, {
1148
+ surface,
1149
+ componentId: value,
1150
+ basePath,
1151
+ ancestors: childAncestors
1152
+ }) : void 0;
1153
+ if (isTemplateChildren(value)) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TemplateChildren, {
1154
+ surface,
1155
+ template: value,
1156
+ basePath,
1157
+ ancestors: childAncestors
1158
+ });
1159
+ if (!Array.isArray(value)) return void 0;
1160
+ return [...new Set(value.filter((id) => typeof id === "string"))].map((id) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(NodeView, {
1161
+ surface,
1162
+ componentId: id,
1163
+ basePath,
1164
+ ancestors: childAncestors
1165
+ }, id));
1166
+ };
1167
+ let result = props;
1168
+ for (const ref of refs) result = (0, _copilotkit_shared.mapAtChildRef)(result, ref.path, (found) => render(ref.kind, found));
1169
+ return result;
1170
+ }, [
1171
+ surface,
1172
+ refs,
1173
+ props,
1174
+ componentId,
1175
+ basePath,
1176
+ ancestors
1177
+ ]);
1178
+ }
1179
+ function ResolvedNode({ surface, componentId, definition, properties, runtime, basePath, ancestors }) {
1180
+ const { overrides, setters } = useSetterProps(runtime, surface, componentId, definition, properties, basePath);
1181
+ const dataProps = useDataProps(runtime, surface, definition, properties, basePath, overrides);
1182
+ const eventProps = useEventProps(runtime, surface, componentId, definition, properties, basePath);
1183
+ const slotProps = useSlotProps(surface, definition, properties, componentId, basePath, ancestors);
1184
+ const childRefProps = useChildRefProps(surface, definition.childRefs, dataProps.ok ? dataProps.props : void 0, componentId, basePath, ancestors);
1185
+ const accessibility = dataProps.ok ? dataProps.accessibility : void 0;
1186
+ const nodeContext = (0, react.useMemo)(() => ({
1187
+ surfaceKey: surface.key,
1188
+ surfaceId: surface.surfaceId,
1189
+ componentId,
1190
+ accessibility
1191
+ }), [
1192
+ surface.key,
1193
+ surface.surfaceId,
1194
+ componentId,
1195
+ accessibility
1196
+ ]);
1197
+ const problem = dataProps.ok ? void 0 : dataProps.problem;
1198
+ (0, react.useEffect)(() => {
1199
+ if (problem) (0, _copilotkit_core_generative_ui.reportErrorSafely)(runtime, {
1200
+ kind: "props",
1201
+ surfaceId: surface.surfaceId,
1202
+ componentId,
1203
+ error: /* @__PURE__ */ new Error(`Invalid props: ${problem}`)
1204
+ });
1205
+ }, [
1206
+ problem,
1207
+ runtime,
1208
+ surface.surfaceId,
1209
+ componentId
1210
+ ]);
1211
+ if (!dataProps.ok) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DefaultNodeFallback, {
1212
+ message: `invalid props (${problem})`,
1213
+ componentId
1214
+ });
1215
+ const Component = definition.component;
1216
+ const rendered = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Component, {
1217
+ ...childRefProps,
1218
+ ...eventProps,
1219
+ ...slotProps,
1220
+ ...setters
1221
+ });
1222
+ const hasEnvelope = properties.accessibility !== void 0 && definition.accessibility !== "self";
1223
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(GenerativeUINodeContext.Provider, {
1224
+ value: nodeContext,
1225
+ children: hasEnvelope ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1226
+ "data-a2ui-accessibility": "",
1227
+ style: ROOT_STYLE,
1228
+ ...(0, _copilotkit_core_generative_ui.wrapperAria)((0, _copilotkit_core_generative_ui.accessibilityAttributes)(accessibility)),
1229
+ children: rendered
1230
+ }) : rendered
1231
+ });
1232
+ }
1233
+
1234
+ //#endregion
1235
+ //#region src/generative-ui/chat.tsx
1236
+ const GenerativeUIChatSlotContext = (0, react.createContext)(void 0);
1237
+ function DefaultGenerativeUIChatCard({ surfaceId, error, children }) {
1238
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1239
+ "data-generative-ui-chat-surface": surfaceId,
1240
+ className: "cpk-generative-ui-chat-card",
1241
+ children: [children, error && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1242
+ role: "alert",
1243
+ className: "cpk-generative-ui-chat-card-error",
1244
+ children: "Part of this UI couldn't be shown."
1245
+ })]
1246
+ });
1247
+ }
1248
+ const ContentSchema = zod.object({
1249
+ surfaceId: zod.string(),
1250
+ target: zod.string(),
1251
+ catalogId: zod.string(),
1252
+ operations: zod.array(zod.any()),
1253
+ status: zod.enum([
1254
+ "streaming",
1255
+ "ready",
1256
+ "error"
1257
+ ]),
1258
+ rejected: zod.array(zod.object({
1259
+ index: zod.number(),
1260
+ reason: zod.string()
1261
+ })).default([])
1262
+ }).loose();
1263
+ function GenerativeUIChatActivity({ content, agent }) {
1264
+ const runtime = useGenerativeUIRuntime();
1265
+ const threadId = useCopilotChatConfiguration()?.threadId ?? agent?.threadId;
1266
+ const Wrapper = (0, react.useContext)(GenerativeUIChatSlotContext) ?? DefaultGenerativeUIChatCard;
1267
+ useManagerVersion(runtime);
1268
+ (0, react.useLayoutEffect)(() => {
1269
+ if (runtime && threadId) runtime.manager.ingest(threadId, agent?.agentId, content);
1270
+ }, [
1271
+ runtime,
1272
+ threadId,
1273
+ agent?.agentId,
1274
+ content
1275
+ ]);
1276
+ if (!runtime || !threadId || content.target !== _copilotkit_shared.GENERATIVE_UI_CHAT_TARGET) return null;
1277
+ const surface = runtime.manager.getSurface(threadId, content.surfaceId) ?? runtime.manager.getFailedSurface(threadId, content.surfaceId);
1278
+ if (!surface) return null;
1279
+ const rejected = [...content.rejected ?? [], ...surface.clientRejected];
1280
+ const error = rejected.length ? new Error(`${rejected.length} UI update(s) could not be shown`, { cause: rejected }) : void 0;
1281
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Wrapper, {
1282
+ surfaceId: content.surfaceId,
1283
+ isStreaming: content.status === "streaming",
1284
+ error,
1285
+ rejected,
1286
+ children: surface.failed ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SurfaceView, { surface })
1287
+ });
1288
+ }
1289
+ function createGenerativeUIActivityRenderer() {
1290
+ return {
1291
+ activityType: _copilotkit_shared.GENERATIVE_UI_ACTIVITY_TYPE,
1292
+ content: ContentSchema,
1293
+ render: GenerativeUIChatActivity
1294
+ };
1295
+ }
1296
+ /**
1297
+ * Shows nothing in the chat for an agent-called function. The root reads the
1298
+ * function-call activities from the messages and runs them. This renderer
1299
+ * only keeps a wildcard ("*") activity renderer from showing them.
1300
+ */
1301
+ function createGenerativeUIFunctionCallActivityRenderer() {
1302
+ return {
1303
+ activityType: _copilotkit_shared.GENERATIVE_UI_FUNCTION_CALL_ACTIVITY_TYPE,
1304
+ content: zod.unknown(),
1305
+ render: () => null
1306
+ };
1307
+ }
1308
+ /** Hides the raw `render_ui` tool call; the surface activity owns the UX. */
1309
+ function GenerativeUIToolCallRenderer() {
1310
+ const { copilotkit } = (0, _copilotkit_react_core_context.useCopilotKit)();
1311
+ (0, react.useEffect)(() => {
1312
+ const renderer = defineToolCallRenderer({
1313
+ name: _copilotkit_shared.GENERATIVE_UI_RENDER_TOOL,
1314
+ args: zod.any(),
1315
+ render: () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, {})
1316
+ });
1317
+ return copilotkit.ɵaddBuiltInRenderToolCall(renderer);
1318
+ }, [copilotkit]);
1319
+ return null;
1320
+ }
1321
+
1322
+ //#endregion
1323
+ //#region src/generative-ui/markdown/ProviderMarkdown.tsx
1324
+ /**
1325
+ * Markdown prose inside generative UI, rendered like the chat text around
1326
+ * it: the renderer set on the provider when there is one, else the built-in
1327
+ * streaming renderer. Config passed here wins over provider config.
1328
+ */
1329
+ function ProviderMarkdown({ content, isStreaming, className, ...config }) {
1330
+ const renderer = useMarkdownRenderer();
1331
+ if (renderer && isReactComponentType(renderer)) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(renderer, {
1332
+ content,
1333
+ isStreaming,
1334
+ className
1335
+ });
1336
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StreamingMarkdownDefaultRenderer, {
1337
+ ...renderer,
1338
+ ...config,
1339
+ content,
1340
+ isStreaming,
1341
+ className
1342
+ });
1343
+ }
1344
+
1345
+ //#endregion
1346
+ //#region src/generative-ui/markdown/MarkdownSurfaces.tsx
1347
+ const FADE_STYLE_ID = "a2ui-markdown-fade";
1348
+ /**
1349
+ * Components fade in as they stream: each element that appears under a
1350
+ * markdown surface runs the keyframes once on mount. React keeps the keys
1351
+ * stable per component id, so an element that is already there never
1352
+ * animates again. SVG internals are left out: a chart library re-creates
1353
+ * its nodes on each render, and a fade on each of them would read as the
1354
+ * chart flashing whenever a sibling arrives. The fade runs under reduced
1355
+ * motion too, because it moves nothing.
1356
+ */
1357
+ const FADE_CSS = ["@keyframes a2ui-fade-in{from{opacity:0}}", "[data-a2ui-markdown-surface] .a2ui-surface *:not(svg):not(svg *){animation:a2ui-fade-in .35s ease-out backwards}"].join("\n");
1358
+ const noEffect = () => {};
1359
+ const useInjectEffect = typeof document === "undefined" ? noEffect : react.useInsertionEffect;
1360
+ function useFadeStyles() {
1361
+ useInjectEffect(() => {
1362
+ if (document.getElementById(FADE_STYLE_ID)) return;
1363
+ const style = document.createElement("style");
1364
+ style.id = FADE_STYLE_ID;
1365
+ style.textContent = FADE_CSS;
1366
+ document.head.appendChild(style);
1367
+ }, []);
1368
+ }
1369
+ /**
1370
+ * The default wrapper of a chat surface in the markdown transport. It draws
1371
+ * no box: a surface sits in the flow of the reply like a paragraph, and a
1372
+ * Card draws its own box when it is interactive. Nothing shows while the
1373
+ * surface streams. A rejected operation gets one line.
1374
+ */
1375
+ function DefaultMarkdownChatSurface({ surfaceId, error, children }) {
1376
+ useFadeStyles();
1377
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1378
+ "data-generative-ui-chat-surface": surfaceId,
1379
+ "data-a2ui-markdown-surface": surfaceId,
1380
+ className: "cpk-markdown-chat-surface",
1381
+ children: [children, error && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1382
+ role: "alert",
1383
+ className: "cpk-markdown-chat-surface-error",
1384
+ children: "Part of this UI couldn't be shown."
1385
+ })]
1386
+ });
1387
+ }
1388
+ /**
1389
+ * One chat surface in the chat wrapper. Nothing renders until the surface
1390
+ * has its root component, so a half-streamed fence shows no empty card.
1391
+ */
1392
+ function ChatSurface({ runtime, threadId, surfaceId, Wrapper }) {
1393
+ const surface = runtime.manager.getSurface(threadId, surfaceId) ?? runtime.manager.getFailedSurface(threadId, surfaceId);
1394
+ const root = surface?.model.componentsModel.get(_copilotkit_shared.GENERATIVE_UI_ROOT_ID);
1395
+ if (!surface || !root && !surface.failed) return null;
1396
+ const rejected = [...surface.serverRejected, ...surface.clientRejected];
1397
+ const error = rejected.length ? new Error(`${rejected.length} UI update(s) could not be shown`, { cause: rejected }) : void 0;
1398
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Wrapper, {
1399
+ surfaceId,
1400
+ isStreaming: surface.status === "streaming",
1401
+ error,
1402
+ rejected,
1403
+ children: surface.failed ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SurfaceView, { surface })
1404
+ });
1405
+ }
1406
+ /** The blocks of one fence: lifted prose and chat surfaces, in order. */
1407
+ function FenceBlocks({ blocks, runtime, threadId, isStreaming, markdownProps }) {
1408
+ const Wrapper = (0, react.useContext)(GenerativeUIChatSlotContext) ?? DefaultMarkdownChatSurface;
1409
+ let surfaceCount = 0;
1410
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: blocks.map((block, index) => {
1411
+ if (block.kind === "markdown") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ProviderMarkdown, {
1412
+ ...markdownProps,
1413
+ content: block.markdown,
1414
+ isStreaming: isStreaming && index === blocks.length - 1
1415
+ }, `md-${surfaceCount}`);
1416
+ surfaceCount++;
1417
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ChatSurface, {
1418
+ runtime,
1419
+ threadId,
1420
+ surfaceId: block.surfaceId,
1421
+ Wrapper
1422
+ }, block.surfaceId);
1423
+ }) });
1424
+ }
1425
+ /**
1426
+ * Experimental. Renders an assistant message of the markdown transport.
1427
+ * Prose renders as markdown. In place of each ```a2ui fence:
1428
+ *
1429
+ * - the fence that created a chat surface renders that surface (and the
1430
+ * prose lifted out of it) in the chat wrapper;
1431
+ * - every other fence renders nothing: a fence that updates the surface of
1432
+ * an earlier fence, or a fence for a named target, which
1433
+ * `<GenerativeUISurface id>` renders.
1434
+ *
1435
+ * Use it inside `<CopilotKitProvider generativeUI={{ ui, transport: "markdown" }}>`.
1436
+ * `CopilotChatAssistantMessage` uses it there on its own.
1437
+ *
1438
+ * @example
1439
+ * ```tsx
1440
+ * <MarkdownSurfaces content={message.content} messageId={message.id} />
1441
+ * ```
1442
+ */
1443
+ function MarkdownSurfaces({ content, messageId, isStreaming = false, ...markdownProps }) {
1444
+ const runtime = useRequiredGenerativeUIRuntime();
1445
+ const chatThreadId = useCopilotChatConfiguration()?.threadId;
1446
+ useManagerVersion(runtime);
1447
+ const segments = (0, react.useMemo)(() => (0, _copilotkit_core.splitA2UIMarkdown)(content), [content]);
1448
+ const threadId = chatThreadId ?? runtime.manager.getActiveThread();
1449
+ const source = (0, _copilotkit_core_generative_ui.getMarkdownSurfaceSource)(runtime);
1450
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: segments.map((segment, index) => {
1451
+ const isLast = index === segments.length - 1;
1452
+ if (segment.type === "markdown") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ProviderMarkdown, {
1453
+ ...markdownProps,
1454
+ content: segment.text,
1455
+ isStreaming: isStreaming && isLast
1456
+ }, `md-${index}`);
1457
+ const blocks = threadId ? source.getFenceBlocks(threadId, messageId, segment.index) : void 0;
1458
+ if (!threadId || !blocks) return null;
1459
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FenceBlocks, {
1460
+ blocks,
1461
+ runtime,
1462
+ threadId,
1463
+ isStreaming: isStreaming && isLast,
1464
+ markdownProps
1465
+ }, `a2ui-${segment.index}`);
1466
+ }) });
1467
+ }
1468
+
1469
+ //#endregion
1470
+ Object.defineProperty(exports, 'ControlledModalOpenScope', {
1471
+ enumerable: true,
1472
+ get: function () {
1473
+ return ControlledModalOpenScope;
1474
+ }
1475
+ });
1476
+ Object.defineProperty(exports, 'CopilotChatConfigurationProvider', {
1477
+ enumerable: true,
1478
+ get: function () {
1479
+ return CopilotChatConfigurationProvider;
1480
+ }
1481
+ });
1482
+ Object.defineProperty(exports, 'CopilotIcon', {
1483
+ enumerable: true,
1484
+ get: function () {
1485
+ return CopilotIcon;
1486
+ }
1487
+ });
1488
+ Object.defineProperty(exports, 'DefaultGenerativeUIChatCard', {
1489
+ enumerable: true,
1490
+ get: function () {
1491
+ return DefaultGenerativeUIChatCard;
1492
+ }
1493
+ });
1494
+ Object.defineProperty(exports, 'GenerativeUIChatSlotContext', {
1495
+ enumerable: true,
1496
+ get: function () {
1497
+ return GenerativeUIChatSlotContext;
1498
+ }
1499
+ });
1500
+ Object.defineProperty(exports, 'GenerativeUINodeContext', {
1501
+ enumerable: true,
1502
+ get: function () {
1503
+ return GenerativeUINodeContext;
1504
+ }
1505
+ });
1506
+ Object.defineProperty(exports, 'GenerativeUIRuntimeContext', {
1507
+ enumerable: true,
1508
+ get: function () {
1509
+ return GenerativeUIRuntimeContext;
1510
+ }
1511
+ });
1512
+ Object.defineProperty(exports, 'GenerativeUIToolCallRenderer', {
1513
+ enumerable: true,
1514
+ get: function () {
1515
+ return GenerativeUIToolCallRenderer;
1516
+ }
1517
+ });
1518
+ Object.defineProperty(exports, 'IconSvg', {
1519
+ enumerable: true,
1520
+ get: function () {
1521
+ return IconSvg;
1522
+ }
1523
+ });
1524
+ Object.defineProperty(exports, 'MarkdownRendererProvider', {
1525
+ enumerable: true,
1526
+ get: function () {
1527
+ return MarkdownRendererProvider;
1528
+ }
1529
+ });
1530
+ Object.defineProperty(exports, 'MarkdownSurfaces', {
1531
+ enumerable: true,
1532
+ get: function () {
1533
+ return MarkdownSurfaces;
1534
+ }
1535
+ });
1536
+ Object.defineProperty(exports, 'ProviderMarkdown', {
1537
+ enumerable: true,
1538
+ get: function () {
1539
+ return ProviderMarkdown;
1540
+ }
1541
+ });
1542
+ Object.defineProperty(exports, 'StreamingMarkdownDefaultRenderer', {
1543
+ enumerable: true,
1544
+ get: function () {
1545
+ return StreamingMarkdownDefaultRenderer;
1546
+ }
1547
+ });
1548
+ Object.defineProperty(exports, 'SurfaceView', {
1549
+ enumerable: true,
1550
+ get: function () {
1551
+ return SurfaceView;
1552
+ }
1553
+ });
1554
+ Object.defineProperty(exports, '__toESM', {
1555
+ enumerable: true,
1556
+ get: function () {
1557
+ return __toESM;
1558
+ }
1559
+ });
1560
+ Object.defineProperty(exports, 'createGenerativeUI', {
1561
+ enumerable: true,
1562
+ get: function () {
1563
+ return createGenerativeUI;
1564
+ }
1565
+ });
1566
+ Object.defineProperty(exports, 'createGenerativeUIActivityRenderer', {
1567
+ enumerable: true,
1568
+ get: function () {
1569
+ return createGenerativeUIActivityRenderer;
1570
+ }
1571
+ });
1572
+ Object.defineProperty(exports, 'createGenerativeUIFunctionCallActivityRenderer', {
1573
+ enumerable: true,
1574
+ get: function () {
1575
+ return createGenerativeUIFunctionCallActivityRenderer;
1576
+ }
1577
+ });
1578
+ Object.defineProperty(exports, 'defineToolCallRenderer', {
1579
+ enumerable: true,
1580
+ get: function () {
1581
+ return defineToolCallRenderer;
1582
+ }
1583
+ });
1584
+ Object.defineProperty(exports, 'isReactComponentType', {
1585
+ enumerable: true,
1586
+ get: function () {
1587
+ return isReactComponentType;
1588
+ }
1589
+ });
1590
+ Object.defineProperty(exports, 'renderSlot', {
1591
+ enumerable: true,
1592
+ get: function () {
1593
+ return renderSlot;
1594
+ }
1595
+ });
1596
+ Object.defineProperty(exports, 'useCopilotChatConfiguration', {
1597
+ enumerable: true,
1598
+ get: function () {
1599
+ return useCopilotChatConfiguration;
1600
+ }
1601
+ });
1602
+ Object.defineProperty(exports, 'useGenerativeUIAccessibility', {
1603
+ enumerable: true,
1604
+ get: function () {
1605
+ return useGenerativeUIAccessibility;
1606
+ }
1607
+ });
1608
+ Object.defineProperty(exports, 'useGenerativeUIFunction', {
1609
+ enumerable: true,
1610
+ get: function () {
1611
+ return useGenerativeUIFunction;
1612
+ }
1613
+ });
1614
+ Object.defineProperty(exports, 'useGenerativeUIRuntime', {
1615
+ enumerable: true,
1616
+ get: function () {
1617
+ return useGenerativeUIRuntime;
1618
+ }
1619
+ });
1620
+ Object.defineProperty(exports, 'useGenerativeUIState', {
1621
+ enumerable: true,
1622
+ get: function () {
1623
+ return useGenerativeUIState;
1624
+ }
1625
+ });
1626
+ Object.defineProperty(exports, 'useManagerVersion', {
1627
+ enumerable: true,
1628
+ get: function () {
1629
+ return useManagerVersion;
1630
+ }
1631
+ });
1632
+ Object.defineProperty(exports, 'useMarkdownRenderer', {
1633
+ enumerable: true,
1634
+ get: function () {
1635
+ return useMarkdownRenderer;
1636
+ }
1637
+ });
1638
+ Object.defineProperty(exports, 'useRequiredGenerativeUIRuntime', {
1639
+ enumerable: true,
1640
+ get: function () {
1641
+ return useRequiredGenerativeUIRuntime;
1642
+ }
1643
+ });
1644
+ Object.defineProperty(exports, 'useShallowStableRef', {
1645
+ enumerable: true,
1646
+ get: function () {
1647
+ return useShallowStableRef;
1648
+ }
1649
+ });
1650
+ //# sourceMappingURL=MarkdownSurfaces-BFoO6wSB.cjs.map