@copilotkitnext/react 0.0.22-alpha.9 → 0.0.22

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/index.js CHANGED
@@ -1,47 +1,87 @@
1
- 'use strict';
2
-
3
- var React2 = require('react');
4
- var tailwindMerge = require('tailwind-merge');
5
- var lucideReact = require('lucide-react');
6
- var shared = require('@copilotkitnext/shared');
7
- var jsxRuntime = require('react/jsx-runtime');
8
- var reactSlot = require('@radix-ui/react-slot');
9
- var classVarianceAuthority = require('class-variance-authority');
10
- var clsx = require('clsx');
11
- var TooltipPrimitive = require('@radix-ui/react-tooltip');
12
- var DropdownMenuPrimitive = require('@radix-ui/react-dropdown-menu');
13
- require('katex/dist/katex.min.css');
14
- var streamdown = require('streamdown');
15
- var core = require('@copilotkitnext/core');
16
- var zod = require('zod');
17
- var react = require('@lit-labs/react');
18
- var webInspector = require('@copilotkitnext/web-inspector');
19
- var useStickToBottom = require('use-stick-to-bottom');
20
- var tsDeepmerge = require('ts-deepmerge');
21
- var client = require('@ag-ui/client');
22
-
23
- function _interopNamespace(e) {
24
- if (e && e.__esModule) return e;
25
- var n = Object.create(null);
26
- if (e) {
27
- Object.keys(e).forEach(function (k) {
28
- if (k !== 'default') {
29
- var d = Object.getOwnPropertyDescriptor(e, k);
30
- Object.defineProperty(n, k, d.get ? d : {
31
- enumerable: true,
32
- get: function () { return e[k]; }
33
- });
34
- }
35
- });
1
+ "use strict";
2
+ "use client";
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __export = (target, all) => {
10
+ for (var name in all)
11
+ __defProp(target, name, { get: all[name], enumerable: true });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(to, key) && key !== except)
17
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
36
18
  }
37
- n.default = e;
38
- return Object.freeze(n);
39
- }
19
+ return to;
20
+ };
21
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23
+ // If the importer is in node compatibility mode or this is not an ESM
24
+ // file that has been converted to a CommonJS file using a Babel-
25
+ // compatible transform (i.e. "__esModule" has not been set), then set
26
+ // "default" to the CommonJS "module.exports" for node compatibility.
27
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
28
+ mod
29
+ ));
30
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
31
+
32
+ // src/index.ts
33
+ var index_exports = {};
34
+ __export(index_exports, {
35
+ AudioRecorderError: () => AudioRecorderError,
36
+ CopilotChat: () => CopilotChat,
37
+ CopilotChatAssistantMessage: () => CopilotChatAssistantMessage_default,
38
+ CopilotChatAudioRecorder: () => CopilotChatAudioRecorder,
39
+ CopilotChatConfigurationProvider: () => CopilotChatConfigurationProvider,
40
+ CopilotChatInput: () => CopilotChatInput_default,
41
+ CopilotChatMessageView: () => CopilotChatMessageView_default,
42
+ CopilotChatSuggestionPill: () => CopilotChatSuggestionPill_default,
43
+ CopilotChatSuggestionView: () => CopilotChatSuggestionView_default,
44
+ CopilotChatToggleButton: () => CopilotChatToggleButton,
45
+ CopilotChatToggleButtonCloseIcon: () => DefaultCloseIcon,
46
+ CopilotChatToggleButtonOpenIcon: () => DefaultOpenIcon,
47
+ CopilotChatToolCallsView: () => CopilotChatToolCallsView_default,
48
+ CopilotChatUserMessage: () => CopilotChatUserMessage_default,
49
+ CopilotChatView: () => CopilotChatView_default,
50
+ CopilotKitCoreReact: () => CopilotKitCoreReact,
51
+ CopilotKitInspector: () => CopilotKitInspector,
52
+ CopilotKitProvider: () => CopilotKitProvider,
53
+ CopilotModalHeader: () => CopilotModalHeader,
54
+ CopilotPopup: () => CopilotPopup,
55
+ CopilotPopupView: () => CopilotPopupView,
56
+ CopilotSidebar: () => CopilotSidebar,
57
+ CopilotSidebarView: () => CopilotSidebarView,
58
+ WildcardToolCallRender: () => WildcardToolCallRender,
59
+ defineToolCallRenderer: () => defineToolCallRenderer,
60
+ useAgent: () => useAgent,
61
+ useAgentContext: () => useAgentContext,
62
+ useConfigureSuggestions: () => useConfigureSuggestions,
63
+ useCopilotChatConfiguration: () => useCopilotChatConfiguration,
64
+ useCopilotKit: () => useCopilotKit,
65
+ useFrontendTool: () => useFrontendTool,
66
+ useHumanInTheLoop: () => useHumanInTheLoop,
67
+ useRenderActivityMessage: () => useRenderActivityMessage,
68
+ useRenderCustomMessages: () => useRenderCustomMessages,
69
+ useRenderToolCall: () => useRenderToolCall,
70
+ useSuggestions: () => useSuggestions
71
+ });
72
+ module.exports = __toCommonJS(index_exports);
73
+ __reExport(index_exports, require("@ag-ui/core"), module.exports);
74
+ __reExport(index_exports, require("@ag-ui/client"), module.exports);
40
75
 
41
- var React2__namespace = /*#__PURE__*/_interopNamespace(React2);
42
- var TooltipPrimitive__namespace = /*#__PURE__*/_interopNamespace(TooltipPrimitive);
43
- var DropdownMenuPrimitive__namespace = /*#__PURE__*/_interopNamespace(DropdownMenuPrimitive);
76
+ // src/components/chat/CopilotChatInput.tsx
77
+ var import_react4 = require("react");
78
+ var import_tailwind_merge3 = require("tailwind-merge");
79
+ var import_lucide_react2 = require("lucide-react");
44
80
 
81
+ // src/providers/CopilotChatConfigurationProvider.tsx
82
+ var import_react = require("react");
83
+ var import_shared = require("@copilotkitnext/shared");
84
+ var import_jsx_runtime = require("react/jsx-runtime");
45
85
  var CopilotChatDefaultLabels = {
46
86
  chatInputPlaceholder: "Type a message...",
47
87
  chatInputToolbarStartTranscribeButtonLabel: "Transcribe",
@@ -63,10 +103,10 @@ var CopilotChatDefaultLabels = {
63
103
  chatToggleCloseLabel: "Close chat",
64
104
  modalHeaderTitle: "CopilotKit Chat"
65
105
  };
66
- var CopilotChatConfiguration = React2.createContext(null);
106
+ var CopilotChatConfiguration = (0, import_react.createContext)(null);
67
107
  var CopilotChatConfigurationProvider = ({ children, labels, agentId, threadId, isModalDefaultOpen }) => {
68
- const parentConfig = React2.useContext(CopilotChatConfiguration);
69
- const mergedLabels = React2.useMemo(
108
+ const parentConfig = (0, import_react.useContext)(CopilotChatConfiguration);
109
+ const mergedLabels = (0, import_react.useMemo)(
70
110
  () => ({
71
111
  ...CopilotChatDefaultLabels,
72
112
  ...parentConfig?.labels ?? {},
@@ -74,23 +114,23 @@ var CopilotChatConfigurationProvider = ({ children, labels, agentId, threadId, i
74
114
  }),
75
115
  [labels, parentConfig?.labels]
76
116
  );
77
- const resolvedAgentId = agentId ?? parentConfig?.agentId ?? shared.DEFAULT_AGENT_ID;
78
- const resolvedThreadId = React2.useMemo(() => {
117
+ const resolvedAgentId = agentId ?? parentConfig?.agentId ?? import_shared.DEFAULT_AGENT_ID;
118
+ const resolvedThreadId = (0, import_react.useMemo)(() => {
79
119
  if (threadId) {
80
120
  return threadId;
81
121
  }
82
122
  if (parentConfig?.threadId) {
83
123
  return parentConfig.threadId;
84
124
  }
85
- return shared.randomUUID();
125
+ return (0, import_shared.randomUUID)();
86
126
  }, [threadId, parentConfig?.threadId]);
87
127
  const resolvedDefaultOpen = isModalDefaultOpen ?? parentConfig?.isModalDefaultOpen ?? true;
88
- const [internalModalOpen, setInternalModalOpen] = React2.useState(
128
+ const [internalModalOpen, setInternalModalOpen] = (0, import_react.useState)(
89
129
  parentConfig?.isModalOpen ?? resolvedDefaultOpen
90
130
  );
91
131
  const resolvedIsModalOpen = parentConfig?.isModalOpen ?? internalModalOpen;
92
132
  const resolvedSetModalOpen = parentConfig?.setModalOpen ?? setInternalModalOpen;
93
- const configurationValue = React2.useMemo(
133
+ const configurationValue = (0, import_react.useMemo)(
94
134
  () => ({
95
135
  labels: mergedLabels,
96
136
  agentId: resolvedAgentId,
@@ -108,16 +148,27 @@ var CopilotChatConfigurationProvider = ({ children, labels, agentId, threadId, i
108
148
  resolvedDefaultOpen
109
149
  ]
110
150
  );
111
- return /* @__PURE__ */ jsxRuntime.jsx(CopilotChatConfiguration.Provider, { value: configurationValue, children });
151
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CopilotChatConfiguration.Provider, { value: configurationValue, children });
112
152
  };
113
153
  var useCopilotChatConfiguration = () => {
114
- const configuration = React2.useContext(CopilotChatConfiguration);
154
+ const configuration = (0, import_react.useContext)(CopilotChatConfiguration);
115
155
  return configuration;
116
156
  };
157
+
158
+ // src/components/ui/button.tsx
159
+ var import_react_slot = require("@radix-ui/react-slot");
160
+ var import_class_variance_authority = require("class-variance-authority");
161
+
162
+ // src/lib/utils.ts
163
+ var import_clsx = require("clsx");
164
+ var import_tailwind_merge = require("tailwind-merge");
117
165
  function cn(...inputs) {
118
- return tailwindMerge.twMerge(clsx.clsx(inputs));
166
+ return (0, import_tailwind_merge.twMerge)((0, import_clsx.clsx)(inputs));
119
167
  }
120
- var buttonVariants = classVarianceAuthority.cva(
168
+
169
+ // src/components/ui/button.tsx
170
+ var import_jsx_runtime2 = require("react/jsx-runtime");
171
+ var buttonVariants = (0, import_class_variance_authority.cva)(
121
172
  "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
122
173
  {
123
174
  variants: {
@@ -213,8 +264,8 @@ function Button({
213
264
  asChild = false,
214
265
  ...props
215
266
  }) {
216
- const Comp = asChild ? reactSlot.Slot : "button";
217
- return /* @__PURE__ */ jsxRuntime.jsx(
267
+ const Comp = asChild ? import_react_slot.Slot : "button";
268
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
218
269
  Comp,
219
270
  {
220
271
  "data-slot": "button",
@@ -223,12 +274,16 @@ function Button({
223
274
  }
224
275
  );
225
276
  }
277
+
278
+ // src/components/ui/tooltip.tsx
279
+ var TooltipPrimitive = __toESM(require("@radix-ui/react-tooltip"));
280
+ var import_jsx_runtime3 = require("react/jsx-runtime");
226
281
  function TooltipProvider({
227
282
  delayDuration = 0,
228
283
  ...props
229
284
  }) {
230
- return /* @__PURE__ */ jsxRuntime.jsx(
231
- TooltipPrimitive__namespace.Provider,
285
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
286
+ TooltipPrimitive.Provider,
232
287
  {
233
288
  "data-slot": "tooltip-provider",
234
289
  delayDuration,
@@ -239,12 +294,12 @@ function TooltipProvider({
239
294
  function Tooltip({
240
295
  ...props
241
296
  }) {
242
- return /* @__PURE__ */ jsxRuntime.jsx(TooltipProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(TooltipPrimitive__namespace.Root, { "data-slot": "tooltip", ...props }) });
297
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(TooltipProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(TooltipPrimitive.Root, { "data-slot": "tooltip", ...props }) });
243
298
  }
244
299
  function TooltipTrigger({
245
300
  ...props
246
301
  }) {
247
- return /* @__PURE__ */ jsxRuntime.jsx(TooltipPrimitive__namespace.Trigger, { "data-slot": "tooltip-trigger", ...props });
302
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(TooltipPrimitive.Trigger, { "data-slot": "tooltip-trigger", ...props });
248
303
  }
249
304
  function TooltipContent({
250
305
  className,
@@ -252,8 +307,8 @@ function TooltipContent({
252
307
  children,
253
308
  ...props
254
309
  }) {
255
- return /* @__PURE__ */ jsxRuntime.jsx(TooltipPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsxs(
256
- TooltipPrimitive__namespace.Content,
310
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(TooltipPrimitive.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
311
+ TooltipPrimitive.Content,
257
312
  {
258
313
  "data-slot": "tooltip-content",
259
314
  sideOffset,
@@ -264,21 +319,26 @@ function TooltipContent({
264
319
  ...props,
265
320
  children: [
266
321
  children,
267
- /* @__PURE__ */ jsxRuntime.jsx(TooltipPrimitive__namespace.Arrow, { className: "bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]" })
322
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(TooltipPrimitive.Arrow, { className: "bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]" })
268
323
  ]
269
324
  }
270
325
  ) });
271
326
  }
327
+
328
+ // src/components/ui/dropdown-menu.tsx
329
+ var DropdownMenuPrimitive = __toESM(require("@radix-ui/react-dropdown-menu"));
330
+ var import_lucide_react = require("lucide-react");
331
+ var import_jsx_runtime4 = require("react/jsx-runtime");
272
332
  function DropdownMenu({
273
333
  ...props
274
334
  }) {
275
- return /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuPrimitive__namespace.Root, { "data-slot": "dropdown-menu", ...props });
335
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(DropdownMenuPrimitive.Root, { "data-slot": "dropdown-menu", ...props });
276
336
  }
277
337
  function DropdownMenuTrigger({
278
338
  ...props
279
339
  }) {
280
- return /* @__PURE__ */ jsxRuntime.jsx(
281
- DropdownMenuPrimitive__namespace.Trigger,
340
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
341
+ DropdownMenuPrimitive.Trigger,
282
342
  {
283
343
  "data-slot": "dropdown-menu-trigger",
284
344
  ...props
@@ -290,8 +350,8 @@ function DropdownMenuContent({
290
350
  sideOffset = 4,
291
351
  ...props
292
352
  }) {
293
- return /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(
294
- DropdownMenuPrimitive__namespace.Content,
353
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(DropdownMenuPrimitive.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
354
+ DropdownMenuPrimitive.Content,
295
355
  {
296
356
  "data-slot": "dropdown-menu-content",
297
357
  sideOffset,
@@ -309,8 +369,8 @@ function DropdownMenuItem({
309
369
  variant = "default",
310
370
  ...props
311
371
  }) {
312
- return /* @__PURE__ */ jsxRuntime.jsx(
313
- DropdownMenuPrimitive__namespace.Item,
372
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
373
+ DropdownMenuPrimitive.Item,
314
374
  {
315
375
  "data-slot": "dropdown-menu-item",
316
376
  "data-inset": inset,
@@ -327,8 +387,8 @@ function DropdownMenuSeparator({
327
387
  className,
328
388
  ...props
329
389
  }) {
330
- return /* @__PURE__ */ jsxRuntime.jsx(
331
- DropdownMenuPrimitive__namespace.Separator,
390
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
391
+ DropdownMenuPrimitive.Separator,
332
392
  {
333
393
  "data-slot": "dropdown-menu-separator",
334
394
  className: cn("bg-border -mx-1 my-1 h-px", className),
@@ -339,7 +399,7 @@ function DropdownMenuSeparator({
339
399
  function DropdownMenuSub({
340
400
  ...props
341
401
  }) {
342
- return /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuPrimitive__namespace.Sub, { "data-slot": "dropdown-menu-sub", ...props });
402
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(DropdownMenuPrimitive.Sub, { "data-slot": "dropdown-menu-sub", ...props });
343
403
  }
344
404
  function DropdownMenuSubTrigger({
345
405
  className,
@@ -347,8 +407,8 @@ function DropdownMenuSubTrigger({
347
407
  children,
348
408
  ...props
349
409
  }) {
350
- return /* @__PURE__ */ jsxRuntime.jsxs(
351
- DropdownMenuPrimitive__namespace.SubTrigger,
410
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
411
+ DropdownMenuPrimitive.SubTrigger,
352
412
  {
353
413
  "data-slot": "dropdown-menu-sub-trigger",
354
414
  "data-inset": inset,
@@ -359,7 +419,7 @@ function DropdownMenuSubTrigger({
359
419
  ...props,
360
420
  children: [
361
421
  children,
362
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronRightIcon, { className: "ml-auto size-4" })
422
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_lucide_react.ChevronRightIcon, { className: "ml-auto size-4" })
363
423
  ]
364
424
  }
365
425
  );
@@ -368,8 +428,8 @@ function DropdownMenuSubContent({
368
428
  className,
369
429
  ...props
370
430
  }) {
371
- return /* @__PURE__ */ jsxRuntime.jsx(
372
- DropdownMenuPrimitive__namespace.SubContent,
431
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
432
+ DropdownMenuPrimitive.SubContent,
373
433
  {
374
434
  "data-slot": "dropdown-menu-sub-content",
375
435
  className: cn(
@@ -380,15 +440,20 @@ function DropdownMenuSubContent({
380
440
  }
381
441
  );
382
442
  }
443
+
444
+ // src/components/chat/CopilotChatAudioRecorder.tsx
445
+ var import_react2 = require("react");
446
+ var import_tailwind_merge2 = require("tailwind-merge");
447
+ var import_jsx_runtime5 = require("react/jsx-runtime");
383
448
  var AudioRecorderError = class extends Error {
384
449
  constructor(message) {
385
450
  super(message);
386
451
  this.name = "AudioRecorderError";
387
452
  }
388
453
  };
389
- var CopilotChatAudioRecorder = React2.forwardRef((props, ref) => {
454
+ var CopilotChatAudioRecorder = (0, import_react2.forwardRef)((props, ref) => {
390
455
  const { className, ...divProps } = props;
391
- const canvasRef = React2.useRef(null);
456
+ const canvasRef = (0, import_react2.useRef)(null);
392
457
  const getLoudness = (n) => {
393
458
  const elapsed = Date.now() / 1e3;
394
459
  const samples = [];
@@ -405,7 +470,7 @@ var CopilotChatAudioRecorder = React2.forwardRef((props, ref) => {
405
470
  }
406
471
  return samples;
407
472
  };
408
- React2.useEffect(() => {
473
+ (0, import_react2.useEffect)(() => {
409
474
  const canvas = canvasRef.current;
410
475
  if (!canvas) return;
411
476
  const ctx = canvas.getContext("2d");
@@ -449,7 +514,7 @@ var CopilotChatAudioRecorder = React2.forwardRef((props, ref) => {
449
514
  }
450
515
  };
451
516
  }, []);
452
- React2.useImperativeHandle(
517
+ (0, import_react2.useImperativeHandle)(
453
518
  ref,
454
519
  () => ({
455
520
  get state() {
@@ -466,7 +531,7 @@ var CopilotChatAudioRecorder = React2.forwardRef((props, ref) => {
466
531
  }),
467
532
  []
468
533
  );
469
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: tailwindMerge.twMerge("h-[44px] w-full px-5", className), ...divProps, children: /* @__PURE__ */ jsxRuntime.jsx(
534
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: (0, import_tailwind_merge2.twMerge)("h-[44px] w-full px-5", className), ...divProps, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
470
535
  "canvas",
471
536
  {
472
537
  ref: canvasRef,
@@ -476,25 +541,31 @@ var CopilotChatAudioRecorder = React2.forwardRef((props, ref) => {
476
541
  ) });
477
542
  });
478
543
  CopilotChatAudioRecorder.displayName = "WebAudioRecorder";
544
+
545
+ // src/lib/slots.tsx
546
+ var import_react3 = __toESM(require("react"));
479
547
  function renderSlot(slot, DefaultComponent, props) {
480
548
  if (typeof slot === "string") {
481
- return React2__namespace.default.createElement(DefaultComponent, {
549
+ return import_react3.default.createElement(DefaultComponent, {
482
550
  ...props,
483
551
  className: slot
484
552
  });
485
553
  }
486
554
  if (typeof slot === "function") {
487
555
  const Comp = slot;
488
- return React2__namespace.default.createElement(Comp, props);
556
+ return import_react3.default.createElement(Comp, props);
489
557
  }
490
- if (slot && typeof slot === "object" && !React2__namespace.default.isValidElement(slot)) {
491
- return React2__namespace.default.createElement(DefaultComponent, {
558
+ if (slot && typeof slot === "object" && !import_react3.default.isValidElement(slot)) {
559
+ return import_react3.default.createElement(DefaultComponent, {
492
560
  ...props,
493
561
  ...slot
494
562
  });
495
563
  }
496
- return React2__namespace.default.createElement(DefaultComponent, props);
564
+ return import_react3.default.createElement(DefaultComponent, props);
497
565
  }
566
+
567
+ // src/components/chat/CopilotChatInput.tsx
568
+ var import_jsx_runtime6 = require("react/jsx-runtime");
498
569
  var SLASH_MENU_MAX_VISIBLE_ITEMS = 5;
499
570
  var SLASH_MENU_ITEM_HEIGHT_PX = 40;
500
571
  function CopilotChatInput({
@@ -522,36 +593,36 @@ function CopilotChatInput({
522
593
  ...props
523
594
  }) {
524
595
  const isControlled = value !== void 0;
525
- const [internalValue, setInternalValue] = React2.useState(() => value ?? "");
526
- React2.useEffect(() => {
596
+ const [internalValue, setInternalValue] = (0, import_react4.useState)(() => value ?? "");
597
+ (0, import_react4.useEffect)(() => {
527
598
  if (!isControlled && value !== void 0) {
528
599
  setInternalValue(value);
529
600
  }
530
601
  }, [isControlled, value]);
531
602
  const resolvedValue = isControlled ? value ?? "" : internalValue;
532
- const [layout, setLayout] = React2.useState("compact");
533
- const ignoreResizeRef = React2.useRef(false);
534
- const resizeEvaluationRafRef = React2.useRef(null);
603
+ const [layout, setLayout] = (0, import_react4.useState)("compact");
604
+ const ignoreResizeRef = (0, import_react4.useRef)(false);
605
+ const resizeEvaluationRafRef = (0, import_react4.useRef)(null);
535
606
  const isExpanded = mode === "input" && layout === "expanded";
536
- const [commandQuery, setCommandQuery] = React2.useState(null);
537
- const [slashHighlightIndex, setSlashHighlightIndex] = React2.useState(0);
538
- const inputRef = React2.useRef(null);
539
- const gridRef = React2.useRef(null);
540
- const addButtonContainerRef = React2.useRef(null);
541
- const actionsContainerRef = React2.useRef(null);
542
- const audioRecorderRef = React2.useRef(null);
543
- const slashMenuRef = React2.useRef(null);
607
+ const [commandQuery, setCommandQuery] = (0, import_react4.useState)(null);
608
+ const [slashHighlightIndex, setSlashHighlightIndex] = (0, import_react4.useState)(0);
609
+ const inputRef = (0, import_react4.useRef)(null);
610
+ const gridRef = (0, import_react4.useRef)(null);
611
+ const addButtonContainerRef = (0, import_react4.useRef)(null);
612
+ const actionsContainerRef = (0, import_react4.useRef)(null);
613
+ const audioRecorderRef = (0, import_react4.useRef)(null);
614
+ const slashMenuRef = (0, import_react4.useRef)(null);
544
615
  const config = useCopilotChatConfiguration();
545
616
  const labels = config?.labels ?? CopilotChatDefaultLabels;
546
- const previousModalStateRef = React2.useRef(void 0);
547
- const measurementCanvasRef = React2.useRef(null);
548
- const measurementsRef = React2.useRef({
617
+ const previousModalStateRef = (0, import_react4.useRef)(void 0);
618
+ const measurementCanvasRef = (0, import_react4.useRef)(null);
619
+ const measurementsRef = (0, import_react4.useRef)({
549
620
  singleLineHeight: 0,
550
621
  maxHeight: 0,
551
622
  paddingLeft: 0,
552
623
  paddingRight: 0
553
624
  });
554
- const commandItems = React2.useMemo(() => {
625
+ const commandItems = (0, import_react4.useMemo)(() => {
555
626
  const entries = [];
556
627
  const seen = /* @__PURE__ */ new Set();
557
628
  const pushItem = (item) => {
@@ -582,7 +653,7 @@ function CopilotChatInput({
582
653
  }
583
654
  return entries;
584
655
  }, [labels.chatInputToolbarAddButtonLabel, onAddFile, toolsMenu]);
585
- const filteredCommands = React2.useMemo(() => {
656
+ const filteredCommands = (0, import_react4.useMemo)(() => {
586
657
  if (commandQuery === null) {
587
658
  return [];
588
659
  }
@@ -605,7 +676,7 @@ function CopilotChatInput({
605
676
  }
606
677
  return [...startsWith, ...contains];
607
678
  }, [commandItems, commandQuery]);
608
- React2.useEffect(() => {
679
+ (0, import_react4.useEffect)(() => {
609
680
  if (!autoFocus) {
610
681
  previousModalStateRef.current = config?.isModalOpen;
611
682
  return;
@@ -615,19 +686,19 @@ function CopilotChatInput({
615
686
  }
616
687
  previousModalStateRef.current = config?.isModalOpen;
617
688
  }, [config?.isModalOpen, autoFocus]);
618
- React2.useEffect(() => {
689
+ (0, import_react4.useEffect)(() => {
619
690
  if (commandItems.length === 0 && commandQuery !== null) {
620
691
  setCommandQuery(null);
621
692
  }
622
693
  }, [commandItems.length, commandQuery]);
623
- const previousCommandQueryRef = React2.useRef(null);
624
- React2.useEffect(() => {
694
+ const previousCommandQueryRef = (0, import_react4.useRef)(null);
695
+ (0, import_react4.useEffect)(() => {
625
696
  if (commandQuery !== null && commandQuery !== previousCommandQueryRef.current && filteredCommands.length > 0) {
626
697
  setSlashHighlightIndex(0);
627
698
  }
628
699
  previousCommandQueryRef.current = commandQuery;
629
700
  }, [commandQuery, filteredCommands.length]);
630
- React2.useEffect(() => {
701
+ (0, import_react4.useEffect)(() => {
631
702
  if (commandQuery === null) {
632
703
  setSlashHighlightIndex(0);
633
704
  return;
@@ -638,7 +709,7 @@ function CopilotChatInput({
638
709
  setSlashHighlightIndex(0);
639
710
  }
640
711
  }, [commandQuery, filteredCommands, slashHighlightIndex]);
641
- React2.useEffect(() => {
712
+ (0, import_react4.useEffect)(() => {
642
713
  const recorder = audioRecorderRef.current;
643
714
  if (!recorder) {
644
715
  return;
@@ -651,13 +722,13 @@ function CopilotChatInput({
651
722
  }
652
723
  }
653
724
  }, [mode]);
654
- React2.useEffect(() => {
725
+ (0, import_react4.useEffect)(() => {
655
726
  if (mode !== "input") {
656
727
  setLayout("compact");
657
728
  setCommandQuery(null);
658
729
  }
659
730
  }, [mode]);
660
- const updateSlashState = React2.useCallback(
731
+ const updateSlashState = (0, import_react4.useCallback)(
661
732
  (value2) => {
662
733
  if (commandItems.length === 0) {
663
734
  setCommandQuery((prev) => prev === null ? prev : null);
@@ -673,7 +744,7 @@ function CopilotChatInput({
673
744
  },
674
745
  [commandItems.length]
675
746
  );
676
- React2.useEffect(() => {
747
+ (0, import_react4.useEffect)(() => {
677
748
  updateSlashState(resolvedValue);
678
749
  }, [resolvedValue, updateSlashState]);
679
750
  const handleChange = (e) => {
@@ -684,7 +755,7 @@ function CopilotChatInput({
684
755
  onChange?.(nextValue);
685
756
  updateSlashState(nextValue);
686
757
  };
687
- const clearInputValue = React2.useCallback(() => {
758
+ const clearInputValue = (0, import_react4.useCallback)(() => {
688
759
  if (!isControlled) {
689
760
  setInternalValue("");
690
761
  }
@@ -692,7 +763,7 @@ function CopilotChatInput({
692
763
  onChange("");
693
764
  }
694
765
  }, [isControlled, onChange]);
695
- const runCommand = React2.useCallback(
766
+ const runCommand = (0, import_react4.useCallback)(
696
767
  (item) => {
697
768
  clearInputValue();
698
769
  item.action?.();
@@ -780,7 +851,7 @@ function CopilotChatInput({
780
851
  onChange: handleChange,
781
852
  onKeyDown: handleKeyDown,
782
853
  autoFocus,
783
- className: tailwindMerge.twMerge(
854
+ className: (0, import_tailwind_merge3.twMerge)(
784
855
  "w-full py-3",
785
856
  isExpanded ? "px-5" : "pr-5"
786
857
  )
@@ -801,7 +872,7 @@ function CopilotChatInput({
801
872
  const BoundSendButton = renderSlot(sendButton, CopilotChatInput.SendButton, {
802
873
  onClick: handleSendButtonClick,
803
874
  disabled: isProcessing ? !canStop : !canSend,
804
- children: isProcessing && canStop ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Square, { className: "size-[18px] fill-current" }) : void 0
875
+ children: isProcessing && canStop ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react2.Square, { className: "size-[18px] fill-current" }) : void 0
805
876
  });
806
877
  const BoundStartTranscribeButton = renderSlot(startTranscribeButton, CopilotChatInput.StartTranscribeButton, {
807
878
  onClick: onStartTranscribe
@@ -837,7 +908,7 @@ function CopilotChatInput({
837
908
  toolsMenu,
838
909
  autoFocus
839
910
  };
840
- return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: children(childProps) });
911
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_jsx_runtime6.Fragment, { children: children(childProps) });
841
912
  }
842
913
  const handleContainerClick = (e) => {
843
914
  const target = e.target;
@@ -845,7 +916,7 @@ function CopilotChatInput({
845
916
  inputRef.current.focus();
846
917
  }
847
918
  };
848
- const ensureMeasurements = React2.useCallback(() => {
919
+ const ensureMeasurements = (0, import_react4.useCallback)(() => {
849
920
  const textarea = inputRef.current;
850
921
  if (!textarea) {
851
922
  return;
@@ -872,7 +943,7 @@ function CopilotChatInput({
872
943
  textarea.style.height = previousHeight;
873
944
  textarea.style.maxHeight = `${maxHeight}px`;
874
945
  }, []);
875
- const adjustTextareaHeight = React2.useCallback(() => {
946
+ const adjustTextareaHeight = (0, import_react4.useCallback)(() => {
876
947
  const textarea = inputRef.current;
877
948
  if (!textarea) {
878
949
  return 0;
@@ -893,7 +964,7 @@ function CopilotChatInput({
893
964
  }
894
965
  return scrollHeight;
895
966
  }, [ensureMeasurements]);
896
- const updateLayout = React2.useCallback((nextLayout) => {
967
+ const updateLayout = (0, import_react4.useCallback)((nextLayout) => {
897
968
  setLayout((prev) => {
898
969
  if (prev === nextLayout) {
899
970
  return prev;
@@ -902,7 +973,7 @@ function CopilotChatInput({
902
973
  return nextLayout;
903
974
  });
904
975
  }, []);
905
- const evaluateLayout = React2.useCallback(() => {
976
+ const evaluateLayout = (0, import_react4.useCallback)(() => {
906
977
  if (mode !== "input") {
907
978
  updateLayout("compact");
908
979
  return;
@@ -973,10 +1044,10 @@ function CopilotChatInput({
973
1044
  const nextLayout = shouldExpand ? "expanded" : "compact";
974
1045
  updateLayout(nextLayout);
975
1046
  }, [adjustTextareaHeight, ensureMeasurements, mode, resolvedValue, updateLayout]);
976
- React2.useLayoutEffect(() => {
1047
+ (0, import_react4.useLayoutEffect)(() => {
977
1048
  evaluateLayout();
978
1049
  }, [evaluateLayout]);
979
- React2.useEffect(() => {
1050
+ (0, import_react4.useEffect)(() => {
980
1051
  if (typeof ResizeObserver === "undefined") {
981
1052
  return;
982
1053
  }
@@ -1020,7 +1091,7 @@ function CopilotChatInput({
1020
1091
  };
1021
1092
  }, [evaluateLayout]);
1022
1093
  const slashMenuVisible = commandQuery !== null && commandItems.length > 0;
1023
- React2.useEffect(() => {
1094
+ (0, import_react4.useEffect)(() => {
1024
1095
  if (!slashMenuVisible || slashHighlightIndex < 0) {
1025
1096
  return;
1026
1097
  }
@@ -1029,7 +1100,7 @@ function CopilotChatInput({
1029
1100
  );
1030
1101
  active?.scrollIntoView({ block: "nearest" });
1031
1102
  }, [slashMenuVisible, slashHighlightIndex]);
1032
- const slashMenu = slashMenuVisible ? /* @__PURE__ */ jsxRuntime.jsx(
1103
+ const slashMenu = slashMenuVisible ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1033
1104
  "div",
1034
1105
  {
1035
1106
  "data-testid": "copilot-slash-menu",
@@ -1038,9 +1109,9 @@ function CopilotChatInput({
1038
1109
  ref: slashMenuRef,
1039
1110
  className: "absolute bottom-full left-0 right-0 z-30 mb-2 max-h-64 overflow-y-auto rounded-lg border border-border bg-white shadow-lg dark:border-[#3a3a3a] dark:bg-[#1f1f1f]",
1040
1111
  style: { maxHeight: `${SLASH_MENU_MAX_VISIBLE_ITEMS * SLASH_MENU_ITEM_HEIGHT_PX}px` },
1041
- children: filteredCommands.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-3 py-2 text-sm text-muted-foreground", children: "No commands found" }) : filteredCommands.map((item, index) => {
1112
+ children: filteredCommands.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "px-3 py-2 text-sm text-muted-foreground", children: "No commands found" }) : filteredCommands.map((item, index) => {
1042
1113
  const isActive = index === slashHighlightIndex;
1043
- return /* @__PURE__ */ jsxRuntime.jsx(
1114
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1044
1115
  "button",
1045
1116
  {
1046
1117
  type: "button",
@@ -1048,7 +1119,7 @@ function CopilotChatInput({
1048
1119
  "aria-selected": isActive,
1049
1120
  "data-active": isActive ? "true" : void 0,
1050
1121
  "data-slash-index": index,
1051
- className: tailwindMerge.twMerge(
1122
+ className: (0, import_tailwind_merge3.twMerge)(
1052
1123
  "w-full px-3 py-2 text-left text-sm transition-colors",
1053
1124
  "hover:bg-muted dark:hover:bg-[#2f2f2f]",
1054
1125
  isActive ? "bg-muted dark:bg-[#2f2f2f]" : "bg-transparent"
@@ -1065,10 +1136,10 @@ function CopilotChatInput({
1065
1136
  })
1066
1137
  }
1067
1138
  ) : null;
1068
- return /* @__PURE__ */ jsxRuntime.jsx(
1139
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1069
1140
  "div",
1070
1141
  {
1071
- className: tailwindMerge.twMerge(
1142
+ className: (0, import_tailwind_merge3.twMerge)(
1072
1143
  // Layout
1073
1144
  "flex w-full flex-col items-center justify-center",
1074
1145
  // Interaction
@@ -1084,21 +1155,21 @@ function CopilotChatInput({
1084
1155
  onClick: handleContainerClick,
1085
1156
  ...props,
1086
1157
  "data-layout": isExpanded ? "expanded" : "compact",
1087
- children: /* @__PURE__ */ jsxRuntime.jsxs(
1158
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
1088
1159
  "div",
1089
1160
  {
1090
1161
  ref: gridRef,
1091
- className: tailwindMerge.twMerge(
1162
+ className: (0, import_tailwind_merge3.twMerge)(
1092
1163
  "grid w-full gap-x-3 gap-y-3 px-3 py-2",
1093
1164
  isExpanded ? "grid-cols-[auto_minmax(0,1fr)_auto] grid-rows-[auto_auto]" : "grid-cols-[auto_minmax(0,1fr)_auto] items-center"
1094
1165
  ),
1095
1166
  "data-layout": isExpanded ? "expanded" : "compact",
1096
1167
  children: [
1097
- /* @__PURE__ */ jsxRuntime.jsx(
1168
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1098
1169
  "div",
1099
1170
  {
1100
1171
  ref: addButtonContainerRef,
1101
- className: tailwindMerge.twMerge(
1172
+ className: (0, import_tailwind_merge3.twMerge)(
1102
1173
  "flex items-center",
1103
1174
  isExpanded ? "row-start-2" : "row-start-1",
1104
1175
  "col-start-1"
@@ -1106,31 +1177,31 @@ function CopilotChatInput({
1106
1177
  children: BoundAddMenuButton
1107
1178
  }
1108
1179
  ),
1109
- /* @__PURE__ */ jsxRuntime.jsx(
1180
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1110
1181
  "div",
1111
1182
  {
1112
- className: tailwindMerge.twMerge(
1183
+ className: (0, import_tailwind_merge3.twMerge)(
1113
1184
  "relative flex min-w-0 flex-col",
1114
1185
  isExpanded ? "col-span-3 row-start-1" : "col-start-2 row-start-1"
1115
1186
  ),
1116
- children: mode === "transcribe" ? BoundAudioRecorder : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1187
+ children: mode === "transcribe" ? BoundAudioRecorder : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
1117
1188
  BoundTextArea,
1118
1189
  slashMenu
1119
1190
  ] })
1120
1191
  }
1121
1192
  ),
1122
- /* @__PURE__ */ jsxRuntime.jsx(
1193
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1123
1194
  "div",
1124
1195
  {
1125
1196
  ref: actionsContainerRef,
1126
- className: tailwindMerge.twMerge(
1197
+ className: (0, import_tailwind_merge3.twMerge)(
1127
1198
  "flex items-center justify-end gap-2",
1128
1199
  isExpanded ? "col-start-3 row-start-2" : "col-start-3 row-start-1"
1129
1200
  ),
1130
- children: mode === "transcribe" ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1201
+ children: mode === "transcribe" ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
1131
1202
  onCancelTranscribe && BoundCancelTranscribeButton,
1132
1203
  onFinishTranscribe && BoundFinishTranscribeButton
1133
- ] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1204
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
1134
1205
  onStartTranscribe && BoundStartTranscribeButton,
1135
1206
  BoundSendButton
1136
1207
  ] })
@@ -1143,7 +1214,7 @@ function CopilotChatInput({
1143
1214
  );
1144
1215
  }
1145
1216
  ((CopilotChatInput2) => {
1146
- CopilotChatInput2.SendButton = ({ className, children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mr-[10px]", children: /* @__PURE__ */ jsxRuntime.jsx(
1217
+ CopilotChatInput2.SendButton = ({ className, children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "mr-[10px]", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1147
1218
  Button,
1148
1219
  {
1149
1220
  type: "button",
@@ -1151,49 +1222,49 @@ function CopilotChatInput({
1151
1222
  size: "chatInputToolbarIcon",
1152
1223
  className,
1153
1224
  ...props,
1154
- children: children ?? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowUp, { className: "size-[18px]" })
1225
+ children: children ?? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react2.ArrowUp, { className: "size-[18px]" })
1155
1226
  }
1156
1227
  ) });
1157
1228
  CopilotChatInput2.ToolbarButton = ({ icon, labelKey, defaultClassName, className, ...props }) => {
1158
1229
  const config = useCopilotChatConfiguration();
1159
1230
  const labels = config?.labels ?? CopilotChatDefaultLabels;
1160
- return /* @__PURE__ */ jsxRuntime.jsxs(Tooltip, { children: [
1161
- /* @__PURE__ */ jsxRuntime.jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
1231
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Tooltip, { children: [
1232
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1162
1233
  Button,
1163
1234
  {
1164
1235
  type: "button",
1165
1236
  variant: "chatInputToolbarSecondary",
1166
1237
  size: "chatInputToolbarIcon",
1167
- className: tailwindMerge.twMerge(defaultClassName, className),
1238
+ className: (0, import_tailwind_merge3.twMerge)(defaultClassName, className),
1168
1239
  ...props,
1169
1240
  children: icon
1170
1241
  }
1171
1242
  ) }),
1172
- /* @__PURE__ */ jsxRuntime.jsx(TooltipContent, { side: "bottom", children: /* @__PURE__ */ jsxRuntime.jsx("p", { children: labels[labelKey] }) })
1243
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(TooltipContent, { side: "bottom", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { children: labels[labelKey] }) })
1173
1244
  ] });
1174
1245
  };
1175
- CopilotChatInput2.StartTranscribeButton = (props) => /* @__PURE__ */ jsxRuntime.jsx(
1246
+ CopilotChatInput2.StartTranscribeButton = (props) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1176
1247
  CopilotChatInput2.ToolbarButton,
1177
1248
  {
1178
- icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Mic, { className: "size-[18px]" }),
1249
+ icon: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react2.Mic, { className: "size-[18px]" }),
1179
1250
  labelKey: "chatInputToolbarStartTranscribeButtonLabel",
1180
1251
  defaultClassName: "mr-2",
1181
1252
  ...props
1182
1253
  }
1183
1254
  );
1184
- CopilotChatInput2.CancelTranscribeButton = (props) => /* @__PURE__ */ jsxRuntime.jsx(
1255
+ CopilotChatInput2.CancelTranscribeButton = (props) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1185
1256
  CopilotChatInput2.ToolbarButton,
1186
1257
  {
1187
- icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "size-[18px]" }),
1258
+ icon: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react2.X, { className: "size-[18px]" }),
1188
1259
  labelKey: "chatInputToolbarCancelTranscribeButtonLabel",
1189
1260
  defaultClassName: "mr-2",
1190
1261
  ...props
1191
1262
  }
1192
1263
  );
1193
- CopilotChatInput2.FinishTranscribeButton = (props) => /* @__PURE__ */ jsxRuntime.jsx(
1264
+ CopilotChatInput2.FinishTranscribeButton = (props) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1194
1265
  CopilotChatInput2.ToolbarButton,
1195
1266
  {
1196
- icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "size-[18px]" }),
1267
+ icon: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react2.Check, { className: "size-[18px]" }),
1197
1268
  labelKey: "chatInputToolbarFinishTranscribeButtonLabel",
1198
1269
  defaultClassName: "mr-[10px]",
1199
1270
  ...props
@@ -1202,7 +1273,7 @@ function CopilotChatInput({
1202
1273
  CopilotChatInput2.AddMenuButton = ({ className, toolsMenu, onAddFile, disabled, ...props }) => {
1203
1274
  const config = useCopilotChatConfiguration();
1204
1275
  const labels = config?.labels ?? CopilotChatDefaultLabels;
1205
- const menuItems = React2.useMemo(() => {
1276
+ const menuItems = (0, import_react4.useMemo)(() => {
1206
1277
  const items = [];
1207
1278
  if (onAddFile) {
1208
1279
  items.push({
@@ -1230,51 +1301,51 @@ function CopilotChatInput({
1230
1301
  }
1231
1302
  return items;
1232
1303
  }, [onAddFile, toolsMenu, labels.chatInputToolbarAddButtonLabel]);
1233
- const renderMenuItems = React2.useCallback(
1304
+ const renderMenuItems = (0, import_react4.useCallback)(
1234
1305
  (items) => items.map((item, index) => {
1235
1306
  if (item === "-") {
1236
- return /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuSeparator, {}, `separator-${index}`);
1307
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(DropdownMenuSeparator, {}, `separator-${index}`);
1237
1308
  }
1238
1309
  if (item.items && item.items.length > 0) {
1239
- return /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenuSub, { children: [
1240
- /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuSubTrigger, { children: item.label }),
1241
- /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuSubContent, { children: renderMenuItems(item.items) })
1310
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(DropdownMenuSub, { children: [
1311
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(DropdownMenuSubTrigger, { children: item.label }),
1312
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(DropdownMenuSubContent, { children: renderMenuItems(item.items) })
1242
1313
  ] }, `group-${index}`);
1243
1314
  }
1244
- return /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuItem, { onClick: item.action, children: item.label }, `item-${index}`);
1315
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(DropdownMenuItem, { onClick: item.action, children: item.label }, `item-${index}`);
1245
1316
  }),
1246
1317
  []
1247
1318
  );
1248
1319
  const hasMenuItems = menuItems.length > 0;
1249
1320
  const isDisabled = disabled || !hasMenuItems;
1250
- return /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenu, { children: [
1251
- /* @__PURE__ */ jsxRuntime.jsxs(Tooltip, { children: [
1252
- /* @__PURE__ */ jsxRuntime.jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
1321
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(DropdownMenu, { children: [
1322
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Tooltip, { children: [
1323
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1253
1324
  Button,
1254
1325
  {
1255
1326
  type: "button",
1256
1327
  variant: "chatInputToolbarSecondary",
1257
1328
  size: "chatInputToolbarIcon",
1258
- className: tailwindMerge.twMerge("ml-1", className),
1329
+ className: (0, import_tailwind_merge3.twMerge)("ml-1", className),
1259
1330
  disabled: isDisabled,
1260
1331
  ...props,
1261
- children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { className: "size-[20px]" })
1332
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react2.Plus, { className: "size-[20px]" })
1262
1333
  }
1263
1334
  ) }) }),
1264
- /* @__PURE__ */ jsxRuntime.jsx(TooltipContent, { side: "bottom", children: /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "flex items-center gap-1 text-xs font-medium", children: [
1265
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Add files and more" }),
1266
- /* @__PURE__ */ jsxRuntime.jsx("code", { className: "rounded bg-[#4a4a4a] px-1 py-[1px] font-mono text-[11px] text-white dark:bg-[#e0e0e0] dark:text-black", children: "/" })
1335
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(TooltipContent, { side: "bottom", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("p", { className: "flex items-center gap-1 text-xs font-medium", children: [
1336
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "Add files and more" }),
1337
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("code", { className: "rounded bg-[#4a4a4a] px-1 py-[1px] font-mono text-[11px] text-white dark:bg-[#e0e0e0] dark:text-black", children: "/" })
1267
1338
  ] }) })
1268
1339
  ] }),
1269
- hasMenuItems && /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuContent, { side: "top", align: "start", children: renderMenuItems(menuItems) })
1340
+ hasMenuItems && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(DropdownMenuContent, { side: "top", align: "start", children: renderMenuItems(menuItems) })
1270
1341
  ] });
1271
1342
  };
1272
- CopilotChatInput2.TextArea = React2.forwardRef(function TextArea2({ style, className, autoFocus, ...props }, ref) {
1273
- const internalTextareaRef = React2.useRef(null);
1343
+ CopilotChatInput2.TextArea = (0, import_react4.forwardRef)(function TextArea2({ style, className, autoFocus, ...props }, ref) {
1344
+ const internalTextareaRef = (0, import_react4.useRef)(null);
1274
1345
  const config = useCopilotChatConfiguration();
1275
1346
  const labels = config?.labels ?? CopilotChatDefaultLabels;
1276
- React2.useImperativeHandle(ref, () => internalTextareaRef.current);
1277
- React2.useEffect(() => {
1347
+ (0, import_react4.useImperativeHandle)(ref, () => internalTextareaRef.current);
1348
+ (0, import_react4.useEffect)(() => {
1278
1349
  const textarea = internalTextareaRef.current;
1279
1350
  if (!textarea) return;
1280
1351
  const handleFocus = () => {
@@ -1285,12 +1356,12 @@ function CopilotChatInput({
1285
1356
  textarea.addEventListener("focus", handleFocus);
1286
1357
  return () => textarea.removeEventListener("focus", handleFocus);
1287
1358
  }, []);
1288
- React2.useEffect(() => {
1359
+ (0, import_react4.useEffect)(() => {
1289
1360
  if (autoFocus) {
1290
1361
  internalTextareaRef.current?.focus();
1291
1362
  }
1292
1363
  }, [autoFocus]);
1293
- return /* @__PURE__ */ jsxRuntime.jsx(
1364
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1294
1365
  "textarea",
1295
1366
  {
1296
1367
  ref: internalTextareaRef,
@@ -1301,7 +1372,7 @@ function CopilotChatInput({
1301
1372
  ...style
1302
1373
  },
1303
1374
  placeholder: labels.chatInputPlaceholder,
1304
- className: tailwindMerge.twMerge(
1375
+ className: (0, import_tailwind_merge3.twMerge)(
1305
1376
  "bg-transparent outline-none antialiased font-regular leading-relaxed text-[16px] placeholder:text-[#00000077] dark:placeholder:text-[#fffc]",
1306
1377
  className
1307
1378
  ),
@@ -1319,7 +1390,25 @@ CopilotChatInput.CancelTranscribeButton.displayName = "CopilotChatInput.CancelTr
1319
1390
  CopilotChatInput.FinishTranscribeButton.displayName = "CopilotChatInput.FinishTranscribeButton";
1320
1391
  CopilotChatInput.AddMenuButton.displayName = "CopilotChatInput.AddMenuButton";
1321
1392
  var CopilotChatInput_default = CopilotChatInput;
1322
- var CopilotKitCoreReact = class extends core.CopilotKitCore {
1393
+
1394
+ // src/components/chat/CopilotChatAssistantMessage.tsx
1395
+ var import_react17 = require("react");
1396
+ var import_lucide_react3 = require("lucide-react");
1397
+ var import_tailwind_merge4 = require("tailwind-merge");
1398
+ var import_katex_min = require("katex/dist/katex.min.css");
1399
+ var import_streamdown = require("streamdown");
1400
+
1401
+ // src/hooks/use-render-tool-call.tsx
1402
+ var import_react7 = require("react");
1403
+ var import_core2 = require("@copilotkitnext/core");
1404
+
1405
+ // src/providers/CopilotKitProvider.tsx
1406
+ var import_react6 = require("react");
1407
+ var import_zod = require("zod");
1408
+
1409
+ // src/lib/react-core.ts
1410
+ var import_core = require("@copilotkitnext/core");
1411
+ var CopilotKitCoreReact = class extends import_core.CopilotKitCore {
1323
1412
  _renderToolCalls = [];
1324
1413
  _renderCustomMessages = [];
1325
1414
  _renderActivityMessages = [];
@@ -1357,26 +1446,29 @@ var CopilotKitCoreReact = class extends core.CopilotKitCore {
1357
1446
  subscribe(subscriber) {
1358
1447
  return super.subscribe(subscriber);
1359
1448
  }
1360
- unsubscribe(subscriber) {
1361
- super.unsubscribe(subscriber);
1362
- }
1363
1449
  };
1364
- webInspector.defineWebInspector();
1365
- var CopilotKitInspectorBase = react.createComponent({
1366
- tagName: webInspector.WEB_INSPECTOR_TAG,
1367
- elementClass: webInspector.WebInspectorElement,
1368
- react: React2__namespace
1450
+
1451
+ // src/components/CopilotKitInspector.tsx
1452
+ var React4 = __toESM(require("react"));
1453
+ var import_react5 = require("@lit-labs/react");
1454
+ var import_web_inspector = require("@copilotkitnext/web-inspector");
1455
+ var import_jsx_runtime7 = require("react/jsx-runtime");
1456
+ (0, import_web_inspector.defineWebInspector)();
1457
+ var CopilotKitInspectorBase = (0, import_react5.createComponent)({
1458
+ tagName: import_web_inspector.WEB_INSPECTOR_TAG,
1459
+ elementClass: import_web_inspector.WebInspectorElement,
1460
+ react: React4
1369
1461
  });
1370
- var CopilotKitInspector = React2__namespace.forwardRef(
1462
+ var CopilotKitInspector = React4.forwardRef(
1371
1463
  ({ core, ...rest }, ref) => {
1372
- const innerRef = React2__namespace.useRef(null);
1373
- React2__namespace.useImperativeHandle(ref, () => innerRef.current, []);
1374
- React2__namespace.useEffect(() => {
1464
+ const innerRef = React4.useRef(null);
1465
+ React4.useImperativeHandle(ref, () => innerRef.current, []);
1466
+ React4.useEffect(() => {
1375
1467
  if (innerRef.current) {
1376
1468
  innerRef.current.core = core ?? null;
1377
1469
  }
1378
1470
  }, [core]);
1379
- return /* @__PURE__ */ jsxRuntime.jsx(
1471
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1380
1472
  CopilotKitInspectorBase,
1381
1473
  {
1382
1474
  ...rest,
@@ -1386,14 +1478,17 @@ var CopilotKitInspector = React2__namespace.forwardRef(
1386
1478
  }
1387
1479
  );
1388
1480
  CopilotKitInspector.displayName = "CopilotKitInspector";
1389
- var CopilotKitContext = React2.createContext({
1481
+
1482
+ // src/providers/CopilotKitProvider.tsx
1483
+ var import_jsx_runtime8 = require("react/jsx-runtime");
1484
+ var CopilotKitContext = (0, import_react6.createContext)({
1390
1485
  copilotkit: null
1391
1486
  });
1392
1487
  function useStableArrayProp(prop, warningMessage, isMeaningfulChange) {
1393
- const empty = React2.useMemo(() => [], []);
1488
+ const empty = (0, import_react6.useMemo)(() => [], []);
1394
1489
  const value = prop ?? empty;
1395
- const initial = React2.useRef(value);
1396
- React2.useEffect(() => {
1490
+ const initial = (0, import_react6.useRef)(value);
1491
+ (0, import_react6.useEffect)(() => {
1397
1492
  if (warningMessage && value !== initial.current && (isMeaningfulChange ? isMeaningfulChange(initial.current, value) : true)) {
1398
1493
  console.error(warningMessage);
1399
1494
  }
@@ -1414,8 +1509,8 @@ var CopilotKitProvider = ({
1414
1509
  showDevConsole = false,
1415
1510
  useSingleEndpoint = false
1416
1511
  }) => {
1417
- const [shouldRenderInspector, setShouldRenderInspector] = React2.useState(false);
1418
- React2.useEffect(() => {
1512
+ const [shouldRenderInspector, setShouldRenderInspector] = (0, import_react6.useState)(false);
1513
+ (0, import_react6.useEffect)(() => {
1419
1514
  if (typeof window === "undefined") {
1420
1515
  return;
1421
1516
  }
@@ -1461,7 +1556,7 @@ var CopilotKitProvider = ({
1461
1556
  humanInTheLoop,
1462
1557
  "humanInTheLoop must be a stable array. If you want to dynamically add or remove human-in-the-loop tools, use `useHumanInTheLoop` instead."
1463
1558
  );
1464
- const processedHumanInTheLoopTools = React2.useMemo(() => {
1559
+ const processedHumanInTheLoopTools = (0, import_react6.useMemo)(() => {
1465
1560
  const processedTools = [];
1466
1561
  const processedRenderToolCalls = [];
1467
1562
  humanInTheLoopList.forEach((tool) => {
@@ -1490,17 +1585,17 @@ var CopilotKitProvider = ({
1490
1585
  });
1491
1586
  return { tools: processedTools, renderToolCalls: processedRenderToolCalls };
1492
1587
  }, [humanInTheLoopList]);
1493
- const allTools = React2.useMemo(() => {
1588
+ const allTools = (0, import_react6.useMemo)(() => {
1494
1589
  const tools = [];
1495
1590
  tools.push(...frontendToolsList);
1496
1591
  tools.push(...processedHumanInTheLoopTools.tools);
1497
1592
  return tools;
1498
1593
  }, [frontendToolsList, processedHumanInTheLoopTools]);
1499
- const allRenderToolCalls = React2.useMemo(() => {
1594
+ const allRenderToolCalls = (0, import_react6.useMemo)(() => {
1500
1595
  const combined = [...renderToolCallsList];
1501
1596
  frontendToolsList.forEach((tool) => {
1502
1597
  if (tool.render) {
1503
- const args = tool.parameters || (tool.name === "*" ? zod.z.any() : void 0);
1598
+ const args = tool.parameters || (tool.name === "*" ? import_zod.z.any() : void 0);
1504
1599
  if (args) {
1505
1600
  combined.push({
1506
1601
  name: tool.name,
@@ -1513,7 +1608,7 @@ var CopilotKitProvider = ({
1513
1608
  combined.push(...processedHumanInTheLoopTools.renderToolCalls);
1514
1609
  return combined;
1515
1610
  }, [renderToolCallsList, frontendToolsList, processedHumanInTheLoopTools]);
1516
- const copilotkit = React2.useMemo(() => {
1611
+ const copilotkit = (0, import_react6.useMemo)(() => {
1517
1612
  const copilotkit2 = new CopilotKitCoreReact({
1518
1613
  runtimeUrl,
1519
1614
  runtimeTransport: useSingleEndpoint ? "single" : "rest",
@@ -1527,25 +1622,25 @@ var CopilotKitProvider = ({
1527
1622
  });
1528
1623
  return copilotkit2;
1529
1624
  }, [allTools, allRenderToolCalls, renderActivityMessagesList, renderCustomMessagesList, useSingleEndpoint]);
1530
- const [, forceUpdate] = React2.useReducer((x) => x + 1, 0);
1531
- React2.useEffect(() => {
1532
- const unsubscribe = copilotkit.subscribe({
1625
+ const [, forceUpdate] = (0, import_react6.useReducer)((x) => x + 1, 0);
1626
+ (0, import_react6.useEffect)(() => {
1627
+ const subscription = copilotkit.subscribe({
1533
1628
  onRenderToolCallsChanged: () => {
1534
1629
  forceUpdate();
1535
1630
  }
1536
1631
  });
1537
1632
  return () => {
1538
- unsubscribe();
1633
+ subscription.unsubscribe();
1539
1634
  };
1540
1635
  }, [copilotkit]);
1541
- React2.useEffect(() => {
1636
+ (0, import_react6.useEffect)(() => {
1542
1637
  copilotkit.setRuntimeUrl(runtimeUrl);
1543
1638
  copilotkit.setRuntimeTransport(useSingleEndpoint ? "single" : "rest");
1544
1639
  copilotkit.setHeaders(headers);
1545
1640
  copilotkit.setProperties(properties);
1546
1641
  copilotkit.setAgents__unsafe_dev_only(agents);
1547
1642
  }, [runtimeUrl, headers, properties, agents, useSingleEndpoint]);
1548
- return /* @__PURE__ */ jsxRuntime.jsxs(
1643
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
1549
1644
  CopilotKitContext.Provider,
1550
1645
  {
1551
1646
  value: {
@@ -1553,45 +1648,50 @@ var CopilotKitProvider = ({
1553
1648
  },
1554
1649
  children: [
1555
1650
  children,
1556
- shouldRenderInspector ? /* @__PURE__ */ jsxRuntime.jsx(CopilotKitInspector, { core: copilotkit }) : null
1651
+ shouldRenderInspector ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(CopilotKitInspector, { core: copilotkit }) : null
1557
1652
  ]
1558
1653
  }
1559
1654
  );
1560
1655
  };
1561
1656
  var useCopilotKit = () => {
1562
- const context = React2.useContext(CopilotKitContext);
1563
- const [, forceUpdate] = React2.useReducer((x) => x + 1, 0);
1657
+ const context = (0, import_react6.useContext)(CopilotKitContext);
1658
+ const [, forceUpdate] = (0, import_react6.useReducer)((x) => x + 1, 0);
1564
1659
  if (!context) {
1565
1660
  throw new Error("useCopilotKit must be used within CopilotKitProvider");
1566
1661
  }
1567
- React2.useEffect(() => {
1568
- const unsubscribe = context.copilotkit.subscribe({
1662
+ (0, import_react6.useEffect)(() => {
1663
+ const subscription = context.copilotkit.subscribe({
1569
1664
  onRuntimeConnectionStatusChanged: () => {
1570
1665
  forceUpdate();
1571
1666
  }
1572
1667
  });
1573
1668
  return () => {
1574
- unsubscribe();
1669
+ subscription.unsubscribe();
1575
1670
  };
1576
1671
  }, []);
1577
1672
  return context;
1578
1673
  };
1674
+
1675
+ // src/hooks/use-render-tool-call.tsx
1676
+ var import_shared2 = require("@copilotkitnext/shared");
1677
+ var import_shared3 = require("@copilotkitnext/shared");
1678
+ var import_jsx_runtime9 = require("react/jsx-runtime");
1579
1679
  function useRenderToolCall() {
1580
1680
  const { copilotkit } = useCopilotKit();
1581
1681
  const config = useCopilotChatConfiguration();
1582
- const agentId = config?.agentId ?? shared.DEFAULT_AGENT_ID;
1583
- const [executingToolCallIds, setExecutingToolCallIds] = React2.useState(() => /* @__PURE__ */ new Set());
1584
- const renderToolCalls = React2.useSyncExternalStore(
1682
+ const agentId = config?.agentId ?? import_shared2.DEFAULT_AGENT_ID;
1683
+ const [executingToolCallIds, setExecutingToolCallIds] = (0, import_react7.useState)(() => /* @__PURE__ */ new Set());
1684
+ const renderToolCalls = (0, import_react7.useSyncExternalStore)(
1585
1685
  (callback) => {
1586
1686
  return copilotkit.subscribe({
1587
1687
  onRenderToolCallsChanged: callback
1588
- });
1688
+ }).unsubscribe;
1589
1689
  },
1590
1690
  () => copilotkit.renderToolCalls,
1591
1691
  () => copilotkit.renderToolCalls
1592
1692
  );
1593
- React2.useEffect(() => {
1594
- const unsubscribe = copilotkit.subscribe({
1693
+ (0, import_react7.useEffect)(() => {
1694
+ const subscription = copilotkit.subscribe({
1595
1695
  onToolExecutionStart: ({ toolCallId }) => {
1596
1696
  setExecutingToolCallIds((prev) => {
1597
1697
  if (prev.has(toolCallId)) return prev;
@@ -1609,9 +1709,9 @@ function useRenderToolCall() {
1609
1709
  });
1610
1710
  }
1611
1711
  });
1612
- return () => unsubscribe();
1712
+ return () => subscription.unsubscribe();
1613
1713
  }, [copilotkit]);
1614
- const renderToolCall = React2.useCallback(
1714
+ const renderToolCall = (0, import_react7.useCallback)(
1615
1715
  ({
1616
1716
  toolCall,
1617
1717
  toolMessage
@@ -1624,37 +1724,37 @@ function useRenderToolCall() {
1624
1724
  return null;
1625
1725
  }
1626
1726
  const RenderComponent = renderConfig.render;
1627
- const args = shared.partialJSONParse(toolCall.function.arguments);
1727
+ const args = (0, import_shared3.partialJSONParse)(toolCall.function.arguments);
1628
1728
  const toolName = toolCall.function.name;
1629
1729
  if (toolMessage) {
1630
- return /* @__PURE__ */ jsxRuntime.jsx(
1730
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1631
1731
  RenderComponent,
1632
1732
  {
1633
1733
  name: toolName,
1634
1734
  args,
1635
- status: core.ToolCallStatus.Complete,
1735
+ status: import_core2.ToolCallStatus.Complete,
1636
1736
  result: toolMessage.content
1637
1737
  },
1638
1738
  toolCall.id
1639
1739
  );
1640
1740
  } else if (executingToolCallIds.has(toolCall.id)) {
1641
- return /* @__PURE__ */ jsxRuntime.jsx(
1741
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1642
1742
  RenderComponent,
1643
1743
  {
1644
1744
  name: toolName,
1645
1745
  args,
1646
- status: core.ToolCallStatus.Executing,
1746
+ status: import_core2.ToolCallStatus.Executing,
1647
1747
  result: void 0
1648
1748
  },
1649
1749
  toolCall.id
1650
1750
  );
1651
1751
  } else {
1652
- return /* @__PURE__ */ jsxRuntime.jsx(
1752
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1653
1753
  RenderComponent,
1654
1754
  {
1655
1755
  name: toolName,
1656
1756
  args,
1657
- status: core.ToolCallStatus.InProgress,
1757
+ status: import_core2.ToolCallStatus.InProgress,
1658
1758
  result: void 0
1659
1759
  },
1660
1760
  toolCall.id
@@ -1665,6 +1765,9 @@ function useRenderToolCall() {
1665
1765
  );
1666
1766
  return renderToolCall;
1667
1767
  }
1768
+
1769
+ // src/hooks/use-render-custom-messages.tsx
1770
+ var import_jsx_runtime10 = require("react/jsx-runtime");
1668
1771
  function useRenderCustomMessages() {
1669
1772
  const { copilotkit } = useCopilotKit();
1670
1773
  const config = useCopilotChatConfiguration();
@@ -1699,7 +1802,7 @@ function useRenderCustomMessages() {
1699
1802
  continue;
1700
1803
  }
1701
1804
  const Component = renderer.render;
1702
- result = /* @__PURE__ */ jsxRuntime.jsx(
1805
+ result = /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1703
1806
  Component,
1704
1807
  {
1705
1808
  message,
@@ -1720,12 +1823,17 @@ function useRenderCustomMessages() {
1720
1823
  return result;
1721
1824
  };
1722
1825
  }
1826
+
1827
+ // src/hooks/use-render-activity-message.tsx
1828
+ var import_shared4 = require("@copilotkitnext/shared");
1829
+ var import_react8 = require("react");
1830
+ var import_jsx_runtime11 = require("react/jsx-runtime");
1723
1831
  function useRenderActivityMessage() {
1724
1832
  const { copilotkit } = useCopilotKit();
1725
1833
  const config = useCopilotChatConfiguration();
1726
- const agentId = config?.agentId ?? shared.DEFAULT_AGENT_ID;
1834
+ const agentId = config?.agentId ?? import_shared4.DEFAULT_AGENT_ID;
1727
1835
  const renderers = copilotkit.renderActivityMessages;
1728
- return React2.useCallback(
1836
+ return (0, import_react8.useCallback)(
1729
1837
  (message) => {
1730
1838
  if (!renderers.length) {
1731
1839
  return null;
@@ -1747,7 +1855,7 @@ function useRenderActivityMessage() {
1747
1855
  }
1748
1856
  const Component = renderer.render;
1749
1857
  const agent = copilotkit.getAgent(agentId);
1750
- return /* @__PURE__ */ jsxRuntime.jsx(
1858
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1751
1859
  Component,
1752
1860
  {
1753
1861
  activityType: message.activityType,
@@ -1761,9 +1869,12 @@ function useRenderActivityMessage() {
1761
1869
  [agentId, copilotkit, renderers]
1762
1870
  );
1763
1871
  }
1872
+
1873
+ // src/hooks/use-frontend-tool.tsx
1874
+ var import_react9 = require("react");
1764
1875
  function useFrontendTool(tool) {
1765
1876
  const { copilotkit } = useCopilotKit();
1766
- React2.useEffect(() => {
1877
+ (0, import_react9.useEffect)(() => {
1767
1878
  const name = tool.name;
1768
1879
  if (copilotkit.getTool({ toolName: name, agentId: tool.agentId })) {
1769
1880
  console.warn(
@@ -1793,21 +1904,25 @@ function useFrontendTool(tool) {
1793
1904
  };
1794
1905
  }, [tool.name, copilotkit]);
1795
1906
  }
1907
+
1908
+ // src/hooks/use-human-in-the-loop.tsx
1909
+ var import_react10 = require("react");
1910
+ var import_react11 = __toESM(require("react"));
1796
1911
  function useHumanInTheLoop(tool) {
1797
1912
  const { copilotkit } = useCopilotKit();
1798
- const resolvePromiseRef = React2.useRef(null);
1799
- const respond = React2.useCallback(async (result) => {
1913
+ const resolvePromiseRef = (0, import_react10.useRef)(null);
1914
+ const respond = (0, import_react10.useCallback)(async (result) => {
1800
1915
  if (resolvePromiseRef.current) {
1801
1916
  resolvePromiseRef.current(result);
1802
1917
  resolvePromiseRef.current = null;
1803
1918
  }
1804
1919
  }, []);
1805
- const handler = React2.useCallback(async () => {
1920
+ const handler = (0, import_react10.useCallback)(async () => {
1806
1921
  return new Promise((resolve) => {
1807
1922
  resolvePromiseRef.current = resolve;
1808
1923
  });
1809
1924
  }, []);
1810
- const RenderComponent = React2.useCallback(
1925
+ const RenderComponent = (0, import_react10.useCallback)(
1811
1926
  (props) => {
1812
1927
  const ToolComponent = tool.render;
1813
1928
  if (props.status === "inProgress") {
@@ -1817,7 +1932,7 @@ function useHumanInTheLoop(tool) {
1817
1932
  description: tool.description || "",
1818
1933
  respond: void 0
1819
1934
  };
1820
- return React2__namespace.default.createElement(ToolComponent, enhancedProps);
1935
+ return import_react11.default.createElement(ToolComponent, enhancedProps);
1821
1936
  } else if (props.status === "executing") {
1822
1937
  const enhancedProps = {
1823
1938
  ...props,
@@ -1825,7 +1940,7 @@ function useHumanInTheLoop(tool) {
1825
1940
  description: tool.description || "",
1826
1941
  respond
1827
1942
  };
1828
- return React2__namespace.default.createElement(ToolComponent, enhancedProps);
1943
+ return import_react11.default.createElement(ToolComponent, enhancedProps);
1829
1944
  } else if (props.status === "complete") {
1830
1945
  const enhancedProps = {
1831
1946
  ...props,
@@ -1833,9 +1948,9 @@ function useHumanInTheLoop(tool) {
1833
1948
  description: tool.description || "",
1834
1949
  respond: void 0
1835
1950
  };
1836
- return React2__namespace.default.createElement(ToolComponent, enhancedProps);
1951
+ return import_react11.default.createElement(ToolComponent, enhancedProps);
1837
1952
  }
1838
- return React2__namespace.default.createElement(ToolComponent, props);
1953
+ return import_react11.default.createElement(ToolComponent, props);
1839
1954
  },
1840
1955
  [tool.render, tool.name, tool.description, respond]
1841
1956
  );
@@ -1845,7 +1960,7 @@ function useHumanInTheLoop(tool) {
1845
1960
  render: RenderComponent
1846
1961
  };
1847
1962
  useFrontendTool(frontendTool);
1848
- React2.useEffect(() => {
1963
+ (0, import_react10.useEffect)(() => {
1849
1964
  return () => {
1850
1965
  const keyOf = (rc) => `${rc.agentId ?? ""}:${rc.name}`;
1851
1966
  const currentRenderToolCalls = copilotkit.renderToolCalls;
@@ -1856,31 +1971,55 @@ function useHumanInTheLoop(tool) {
1856
1971
  };
1857
1972
  }, [copilotkit, tool.name, tool.agentId]);
1858
1973
  }
1974
+
1975
+ // src/hooks/use-agent.tsx
1976
+ var import_react12 = require("react");
1977
+ var import_shared5 = require("@copilotkitnext/shared");
1978
+ var import_core3 = require("@copilotkitnext/core");
1859
1979
  var ALL_UPDATES = [
1860
1980
  "OnMessagesChanged" /* OnMessagesChanged */,
1861
1981
  "OnStateChanged" /* OnStateChanged */,
1862
1982
  "OnRunStatusChanged" /* OnRunStatusChanged */
1863
1983
  ];
1864
1984
  function useAgent({ agentId, updates } = {}) {
1865
- agentId ??= shared.DEFAULT_AGENT_ID;
1985
+ agentId ??= import_shared5.DEFAULT_AGENT_ID;
1866
1986
  const { copilotkit } = useCopilotKit();
1867
- const [, forceUpdate] = React2.useReducer((x) => x + 1, 0);
1868
- const updateFlags = React2.useMemo(
1987
+ const [, forceUpdate] = (0, import_react12.useReducer)((x) => x + 1, 0);
1988
+ const updateFlags = (0, import_react12.useMemo)(
1869
1989
  () => updates ?? ALL_UPDATES,
1870
1990
  [JSON.stringify(updates)]
1871
1991
  );
1872
- const agent = React2.useMemo(() => {
1873
- return copilotkit.getAgent(agentId);
1992
+ const agent = (0, import_react12.useMemo)(() => {
1993
+ const existing = copilotkit.getAgent(agentId);
1994
+ if (existing) {
1995
+ return existing;
1996
+ }
1997
+ const isRuntimeConfigured = copilotkit.runtimeUrl !== void 0;
1998
+ const status = copilotkit.runtimeConnectionStatus;
1999
+ if (isRuntimeConfigured && (status === import_core3.CopilotKitCoreRuntimeConnectionStatus.Disconnected || status === import_core3.CopilotKitCoreRuntimeConnectionStatus.Connecting)) {
2000
+ const provisional = new import_core3.ProxiedCopilotRuntimeAgent({
2001
+ runtimeUrl: copilotkit.runtimeUrl,
2002
+ agentId,
2003
+ transport: copilotkit.runtimeTransport
2004
+ });
2005
+ provisional.headers = { ...copilotkit.headers };
2006
+ return provisional;
2007
+ }
2008
+ const knownAgents = Object.keys(copilotkit.agents ?? {});
2009
+ const runtimePart = isRuntimeConfigured ? `runtimeUrl=${copilotkit.runtimeUrl}` : "no runtimeUrl";
2010
+ throw new Error(
2011
+ `useAgent: Agent '${agentId}' not found after runtime sync (${runtimePart}). ` + (knownAgents.length ? `Known agents: [${knownAgents.join(", ")}]` : "No agents registered.") + " Verify your runtime /info and/or agents__unsafe_dev_only."
2012
+ );
1874
2013
  }, [
1875
2014
  agentId,
1876
2015
  copilotkit.agents,
1877
2016
  copilotkit.runtimeConnectionStatus,
2017
+ copilotkit.runtimeUrl,
2018
+ copilotkit.runtimeTransport,
2019
+ JSON.stringify(copilotkit.headers),
1878
2020
  copilotkit
1879
2021
  ]);
1880
- React2.useEffect(() => {
1881
- if (!agent) {
1882
- return;
1883
- }
2022
+ (0, import_react12.useEffect)(() => {
1884
2023
  if (updateFlags.length === 0) {
1885
2024
  return;
1886
2025
  }
@@ -1913,10 +2052,13 @@ function useAgent({ agentId, updates } = {}) {
1913
2052
  agent
1914
2053
  };
1915
2054
  }
2055
+
2056
+ // src/hooks/use-agent-context.tsx
2057
+ var import_react13 = require("react");
1916
2058
  function useAgentContext(context) {
1917
2059
  const { description, value } = context;
1918
2060
  const { copilotkit } = useCopilotKit();
1919
- React2.useEffect(() => {
2061
+ (0, import_react13.useEffect)(() => {
1920
2062
  if (!copilotkit) return;
1921
2063
  const id = copilotkit.addContext(context);
1922
2064
  return () => {
@@ -1924,25 +2066,29 @@ function useAgentContext(context) {
1924
2066
  };
1925
2067
  }, [description, value, copilotkit]);
1926
2068
  }
2069
+
2070
+ // src/hooks/use-suggestions.tsx
2071
+ var import_react14 = require("react");
2072
+ var import_shared6 = require("@copilotkitnext/shared");
1927
2073
  function useSuggestions({ agentId } = {}) {
1928
2074
  const { copilotkit } = useCopilotKit();
1929
2075
  const config = useCopilotChatConfiguration();
1930
- const resolvedAgentId = React2.useMemo(() => agentId ?? config?.agentId ?? shared.DEFAULT_AGENT_ID, [agentId, config?.agentId]);
1931
- const [suggestions, setSuggestions] = React2.useState(() => {
2076
+ const resolvedAgentId = (0, import_react14.useMemo)(() => agentId ?? config?.agentId ?? import_shared6.DEFAULT_AGENT_ID, [agentId, config?.agentId]);
2077
+ const [suggestions, setSuggestions] = (0, import_react14.useState)(() => {
1932
2078
  const result = copilotkit.getSuggestions(resolvedAgentId);
1933
2079
  return result.suggestions;
1934
2080
  });
1935
- const [isLoading, setIsLoading] = React2.useState(() => {
2081
+ const [isLoading, setIsLoading] = (0, import_react14.useState)(() => {
1936
2082
  const result = copilotkit.getSuggestions(resolvedAgentId);
1937
2083
  return result.isLoading;
1938
2084
  });
1939
- React2.useEffect(() => {
2085
+ (0, import_react14.useEffect)(() => {
1940
2086
  const result = copilotkit.getSuggestions(resolvedAgentId);
1941
2087
  setSuggestions(result.suggestions);
1942
2088
  setIsLoading(result.isLoading);
1943
2089
  }, [copilotkit, resolvedAgentId]);
1944
- React2.useEffect(() => {
1945
- const unsubscribe = copilotkit.subscribe({
2090
+ (0, import_react14.useEffect)(() => {
2091
+ const subscription = copilotkit.subscribe({
1946
2092
  onSuggestionsChanged: ({ agentId: changedAgentId, suggestions: suggestions2 }) => {
1947
2093
  if (changedAgentId !== resolvedAgentId) {
1948
2094
  return;
@@ -1968,13 +2114,13 @@ function useSuggestions({ agentId } = {}) {
1968
2114
  }
1969
2115
  });
1970
2116
  return () => {
1971
- unsubscribe();
2117
+ subscription.unsubscribe();
1972
2118
  };
1973
2119
  }, [copilotkit, resolvedAgentId]);
1974
- const reloadSuggestions = React2.useCallback(() => {
2120
+ const reloadSuggestions = (0, import_react14.useCallback)(() => {
1975
2121
  copilotkit.reloadSuggestions(resolvedAgentId);
1976
2122
  }, [copilotkit, resolvedAgentId]);
1977
- const clearSuggestions = React2.useCallback(() => {
2123
+ const clearSuggestions = (0, import_react14.useCallback)(() => {
1978
2124
  copilotkit.clearSuggestions(resolvedAgentId);
1979
2125
  }, [copilotkit, resolvedAgentId]);
1980
2126
  return {
@@ -1984,18 +2130,22 @@ function useSuggestions({ agentId } = {}) {
1984
2130
  isLoading
1985
2131
  };
1986
2132
  }
2133
+
2134
+ // src/hooks/use-configure-suggestions.tsx
2135
+ var import_react15 = require("react");
2136
+ var import_shared7 = require("@copilotkitnext/shared");
1987
2137
  var EMPTY_DEPS = [];
1988
2138
  function useConfigureSuggestions(config, options) {
1989
2139
  const { copilotkit } = useCopilotKit();
1990
2140
  const chatConfig = useCopilotChatConfiguration();
1991
2141
  const extraDeps = options?.deps ?? EMPTY_DEPS;
1992
- const resolvedConsumerAgentId = React2.useMemo(() => chatConfig?.agentId ?? shared.DEFAULT_AGENT_ID, [chatConfig?.agentId]);
1993
- const rawConsumerAgentId = React2.useMemo(() => config ? config.consumerAgentId : void 0, [config]);
1994
- const normalizationCacheRef = React2.useRef({
2142
+ const resolvedConsumerAgentId = (0, import_react15.useMemo)(() => chatConfig?.agentId ?? import_shared7.DEFAULT_AGENT_ID, [chatConfig?.agentId]);
2143
+ const rawConsumerAgentId = (0, import_react15.useMemo)(() => config ? config.consumerAgentId : void 0, [config]);
2144
+ const normalizationCacheRef = (0, import_react15.useRef)({
1995
2145
  serialized: null,
1996
2146
  config: null
1997
2147
  });
1998
- const { normalizedConfig, serializedConfig } = React2.useMemo(() => {
2148
+ const { normalizedConfig, serializedConfig } = (0, import_react15.useMemo)(() => {
1999
2149
  if (!config) {
2000
2150
  normalizationCacheRef.current = { serialized: null, config: null };
2001
2151
  return { normalizedConfig: null, serializedConfig: null };
@@ -2025,10 +2175,10 @@ function useConfigureSuggestions(config, options) {
2025
2175
  normalizationCacheRef.current = { serialized, config: built };
2026
2176
  return { normalizedConfig: built, serializedConfig: serialized };
2027
2177
  }, [config, resolvedConsumerAgentId, ...extraDeps]);
2028
- const latestConfigRef = React2.useRef(null);
2178
+ const latestConfigRef = (0, import_react15.useRef)(null);
2029
2179
  latestConfigRef.current = normalizedConfig;
2030
- const previousSerializedConfigRef = React2.useRef(null);
2031
- const targetAgentId = React2.useMemo(() => {
2180
+ const previousSerializedConfigRef = (0, import_react15.useRef)(null);
2181
+ const targetAgentId = (0, import_react15.useMemo)(() => {
2032
2182
  if (!normalizedConfig) {
2033
2183
  return resolvedConsumerAgentId;
2034
2184
  }
@@ -2039,7 +2189,7 @@ function useConfigureSuggestions(config, options) {
2039
2189
  return consumer;
2040
2190
  }, [normalizedConfig, resolvedConsumerAgentId]);
2041
2191
  const isGlobalConfig = rawConsumerAgentId === void 0 || rawConsumerAgentId === "*";
2042
- const requestReload = React2.useCallback(() => {
2192
+ const requestReload = (0, import_react15.useCallback)(() => {
2043
2193
  if (!normalizedConfig) {
2044
2194
  return;
2045
2195
  }
@@ -2061,7 +2211,7 @@ function useConfigureSuggestions(config, options) {
2061
2211
  }
2062
2212
  copilotkit.reloadSuggestions(targetAgentId);
2063
2213
  }, [copilotkit, isGlobalConfig, normalizedConfig, targetAgentId]);
2064
- React2.useEffect(() => {
2214
+ (0, import_react15.useEffect)(() => {
2065
2215
  if (!serializedConfig || !latestConfigRef.current) {
2066
2216
  return;
2067
2217
  }
@@ -2071,7 +2221,7 @@ function useConfigureSuggestions(config, options) {
2071
2221
  copilotkit.removeSuggestionsConfig(id);
2072
2222
  };
2073
2223
  }, [copilotkit, serializedConfig, requestReload]);
2074
- React2.useEffect(() => {
2224
+ (0, import_react15.useEffect)(() => {
2075
2225
  if (!normalizedConfig) {
2076
2226
  previousSerializedConfigRef.current = null;
2077
2227
  return;
@@ -2084,7 +2234,7 @@ function useConfigureSuggestions(config, options) {
2084
2234
  }
2085
2235
  requestReload();
2086
2236
  }, [normalizedConfig, requestReload, serializedConfig]);
2087
- React2.useEffect(() => {
2237
+ (0, import_react15.useEffect)(() => {
2088
2238
  if (!normalizedConfig || extraDeps.length === 0) {
2089
2239
  return;
2090
2240
  }
@@ -2100,6 +2250,10 @@ function normalizeStaticSuggestions(suggestions) {
2100
2250
  isLoading: suggestion.isLoading ?? false
2101
2251
  }));
2102
2252
  }
2253
+
2254
+ // src/components/chat/CopilotChatToolCallsView.tsx
2255
+ var import_react16 = __toESM(require("react"));
2256
+ var import_jsx_runtime12 = require("react/jsx-runtime");
2103
2257
  function CopilotChatToolCallsView({
2104
2258
  message,
2105
2259
  messages = []
@@ -2108,17 +2262,20 @@ function CopilotChatToolCallsView({
2108
2262
  if (!message.toolCalls || message.toolCalls.length === 0) {
2109
2263
  return null;
2110
2264
  }
2111
- return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: message.toolCalls.map((toolCall) => {
2265
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_jsx_runtime12.Fragment, { children: message.toolCalls.map((toolCall) => {
2112
2266
  const toolMessage = messages.find(
2113
2267
  (m) => m.role === "tool" && m.toolCallId === toolCall.id
2114
2268
  );
2115
- return /* @__PURE__ */ jsxRuntime.jsx(React2__namespace.default.Fragment, { children: renderToolCall({
2269
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react16.default.Fragment, { children: renderToolCall({
2116
2270
  toolCall,
2117
2271
  toolMessage
2118
2272
  }) }, toolCall.id);
2119
2273
  }) });
2120
2274
  }
2121
2275
  var CopilotChatToolCallsView_default = CopilotChatToolCallsView;
2276
+
2277
+ // src/components/chat/CopilotChatAssistantMessage.tsx
2278
+ var import_jsx_runtime13 = require("react/jsx-runtime");
2122
2279
  function CopilotChatAssistantMessage({
2123
2280
  message,
2124
2281
  messages,
@@ -2195,7 +2352,7 @@ function CopilotChatAssistantMessage({
2195
2352
  toolbar,
2196
2353
  CopilotChatAssistantMessage.Toolbar,
2197
2354
  {
2198
- children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1", children: [
2355
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex items-center gap-1", children: [
2199
2356
  boundCopyButton,
2200
2357
  (onThumbsUp || thumbsUpButton) && boundThumbsUpButton,
2201
2358
  (onThumbsDown || thumbsDownButton) && boundThumbsDownButton,
@@ -2217,7 +2374,7 @@ function CopilotChatAssistantMessage({
2217
2374
  const isLatestAssistantMessage = message.role === "assistant" && messages?.[messages.length - 1]?.id === message.id;
2218
2375
  const shouldShowToolbar = toolbarVisible && hasContent && !(isRunning && isLatestAssistantMessage);
2219
2376
  if (children) {
2220
- return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: children({
2377
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_jsx_runtime13.Fragment, { children: children({
2221
2378
  markdownRenderer: boundMarkdownRenderer,
2222
2379
  toolbar: boundToolbar,
2223
2380
  toolCallsView: boundToolCallsView,
@@ -2237,10 +2394,10 @@ function CopilotChatAssistantMessage({
2237
2394
  toolbarVisible: shouldShowToolbar
2238
2395
  }) });
2239
2396
  }
2240
- return /* @__PURE__ */ jsxRuntime.jsxs(
2397
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
2241
2398
  "div",
2242
2399
  {
2243
- className: tailwindMerge.twMerge(
2400
+ className: (0, import_tailwind_merge4.twMerge)(
2244
2401
  "prose max-w-full break-words dark:prose-invert",
2245
2402
  className
2246
2403
  ),
@@ -2255,14 +2412,14 @@ function CopilotChatAssistantMessage({
2255
2412
  );
2256
2413
  }
2257
2414
  ((CopilotChatAssistantMessage2) => {
2258
- CopilotChatAssistantMessage2.MarkdownRenderer = ({ content, className, ...props }) => /* @__PURE__ */ jsxRuntime.jsx(streamdown.Streamdown, { className, ...props, children: content ?? "" });
2415
+ CopilotChatAssistantMessage2.MarkdownRenderer = ({ content, className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_streamdown.Streamdown, { className, ...props, children: content ?? "" });
2259
2416
  CopilotChatAssistantMessage2.Toolbar = ({
2260
2417
  className,
2261
2418
  ...props
2262
- }) => /* @__PURE__ */ jsxRuntime.jsx(
2419
+ }) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2263
2420
  "div",
2264
2421
  {
2265
- className: tailwindMerge.twMerge(
2422
+ className: (0, import_tailwind_merge4.twMerge)(
2266
2423
  "w-full bg-transparent flex items-center -ml-[5px] -mt-[0px]",
2267
2424
  className
2268
2425
  ),
@@ -2270,8 +2427,8 @@ function CopilotChatAssistantMessage({
2270
2427
  }
2271
2428
  );
2272
2429
  CopilotChatAssistantMessage2.ToolbarButton = ({ title, children, ...props }) => {
2273
- return /* @__PURE__ */ jsxRuntime.jsxs(Tooltip, { children: [
2274
- /* @__PURE__ */ jsxRuntime.jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
2430
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(Tooltip, { children: [
2431
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2275
2432
  Button,
2276
2433
  {
2277
2434
  type: "button",
@@ -2281,13 +2438,13 @@ function CopilotChatAssistantMessage({
2281
2438
  children
2282
2439
  }
2283
2440
  ) }),
2284
- /* @__PURE__ */ jsxRuntime.jsx(TooltipContent, { side: "bottom", children: /* @__PURE__ */ jsxRuntime.jsx("p", { children: title }) })
2441
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(TooltipContent, { side: "bottom", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { children: title }) })
2285
2442
  ] });
2286
2443
  };
2287
2444
  CopilotChatAssistantMessage2.CopyButton = ({ className, title, onClick, ...props }) => {
2288
2445
  const config = useCopilotChatConfiguration();
2289
2446
  const labels = config?.labels ?? CopilotChatDefaultLabels;
2290
- const [copied, setCopied] = React2.useState(false);
2447
+ const [copied, setCopied] = (0, import_react17.useState)(false);
2291
2448
  const handleClick = (event) => {
2292
2449
  setCopied(true);
2293
2450
  setTimeout(() => setCopied(false), 2e3);
@@ -2295,62 +2452,62 @@ function CopilotChatAssistantMessage({
2295
2452
  onClick(event);
2296
2453
  }
2297
2454
  };
2298
- return /* @__PURE__ */ jsxRuntime.jsx(
2455
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2299
2456
  CopilotChatAssistantMessage2.ToolbarButton,
2300
2457
  {
2301
2458
  title: title || labels.assistantMessageToolbarCopyMessageLabel,
2302
2459
  onClick: handleClick,
2303
2460
  className,
2304
2461
  ...props,
2305
- children: copied ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "size-[18px]" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Copy, { className: "size-[18px]" })
2462
+ children: copied ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react3.Check, { className: "size-[18px]" }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react3.Copy, { className: "size-[18px]" })
2306
2463
  }
2307
2464
  );
2308
2465
  };
2309
2466
  CopilotChatAssistantMessage2.ThumbsUpButton = ({ title, ...props }) => {
2310
2467
  const config = useCopilotChatConfiguration();
2311
2468
  const labels = config?.labels ?? CopilotChatDefaultLabels;
2312
- return /* @__PURE__ */ jsxRuntime.jsx(
2469
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2313
2470
  CopilotChatAssistantMessage2.ToolbarButton,
2314
2471
  {
2315
2472
  title: title || labels.assistantMessageToolbarThumbsUpLabel,
2316
2473
  ...props,
2317
- children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ThumbsUp, { className: "size-[18px]" })
2474
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react3.ThumbsUp, { className: "size-[18px]" })
2318
2475
  }
2319
2476
  );
2320
2477
  };
2321
2478
  CopilotChatAssistantMessage2.ThumbsDownButton = ({ title, ...props }) => {
2322
2479
  const config = useCopilotChatConfiguration();
2323
2480
  const labels = config?.labels ?? CopilotChatDefaultLabels;
2324
- return /* @__PURE__ */ jsxRuntime.jsx(
2481
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2325
2482
  CopilotChatAssistantMessage2.ToolbarButton,
2326
2483
  {
2327
2484
  title: title || labels.assistantMessageToolbarThumbsDownLabel,
2328
2485
  ...props,
2329
- children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ThumbsDown, { className: "size-[18px]" })
2486
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react3.ThumbsDown, { className: "size-[18px]" })
2330
2487
  }
2331
2488
  );
2332
2489
  };
2333
2490
  CopilotChatAssistantMessage2.ReadAloudButton = ({ title, ...props }) => {
2334
2491
  const config = useCopilotChatConfiguration();
2335
2492
  const labels = config?.labels ?? CopilotChatDefaultLabels;
2336
- return /* @__PURE__ */ jsxRuntime.jsx(
2493
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2337
2494
  CopilotChatAssistantMessage2.ToolbarButton,
2338
2495
  {
2339
2496
  title: title || labels.assistantMessageToolbarReadAloudLabel,
2340
2497
  ...props,
2341
- children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Volume2, { className: "size-[20px]" })
2498
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react3.Volume2, { className: "size-[20px]" })
2342
2499
  }
2343
2500
  );
2344
2501
  };
2345
2502
  CopilotChatAssistantMessage2.RegenerateButton = ({ title, ...props }) => {
2346
2503
  const config = useCopilotChatConfiguration();
2347
2504
  const labels = config?.labels ?? CopilotChatDefaultLabels;
2348
- return /* @__PURE__ */ jsxRuntime.jsx(
2505
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2349
2506
  CopilotChatAssistantMessage2.ToolbarButton,
2350
2507
  {
2351
2508
  title: title || labels.assistantMessageToolbarRegenerateLabel,
2352
2509
  ...props,
2353
- children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.RefreshCw, { className: "size-[18px]" })
2510
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react3.RefreshCw, { className: "size-[18px]" })
2354
2511
  }
2355
2512
  );
2356
2513
  };
@@ -2363,6 +2520,12 @@ CopilotChatAssistantMessage.ThumbsDownButton.displayName = "CopilotChatAssistant
2363
2520
  CopilotChatAssistantMessage.ReadAloudButton.displayName = "CopilotChatAssistantMessage.ReadAloudButton";
2364
2521
  CopilotChatAssistantMessage.RegenerateButton.displayName = "CopilotChatAssistantMessage.RegenerateButton";
2365
2522
  var CopilotChatAssistantMessage_default = CopilotChatAssistantMessage;
2523
+
2524
+ // src/components/chat/CopilotChatUserMessage.tsx
2525
+ var import_react18 = require("react");
2526
+ var import_lucide_react4 = require("lucide-react");
2527
+ var import_tailwind_merge5 = require("tailwind-merge");
2528
+ var import_jsx_runtime14 = require("react/jsx-runtime");
2366
2529
  function flattenUserMessageContent(content) {
2367
2530
  if (!content) {
2368
2531
  return "";
@@ -2393,7 +2556,7 @@ function CopilotChatUserMessage({
2393
2556
  className,
2394
2557
  ...props
2395
2558
  }) {
2396
- const flattenedContent = React2.useMemo(
2559
+ const flattenedContent = (0, import_react18.useMemo)(
2397
2560
  () => flattenUserMessageContent(message.content),
2398
2561
  [message.content]
2399
2562
  );
@@ -2438,7 +2601,7 @@ function CopilotChatUserMessage({
2438
2601
  );
2439
2602
  const showBranchNavigation = numberOfBranches && numberOfBranches > 1 && onSwitchToBranch;
2440
2603
  const BoundToolbar = renderSlot(toolbar, CopilotChatUserMessage.Toolbar, {
2441
- children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1 justify-end", children: [
2604
+ children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex items-center gap-1 justify-end", children: [
2442
2605
  additionalToolbarItems,
2443
2606
  BoundCopyButton,
2444
2607
  onEditMessage && BoundEditButton,
@@ -2446,7 +2609,7 @@ function CopilotChatUserMessage({
2446
2609
  ] })
2447
2610
  });
2448
2611
  if (children) {
2449
- return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: children({
2612
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_jsx_runtime14.Fragment, { children: children({
2450
2613
  messageRenderer: BoundMessageRenderer,
2451
2614
  toolbar: BoundToolbar,
2452
2615
  copyButton: BoundCopyButton,
@@ -2458,10 +2621,10 @@ function CopilotChatUserMessage({
2458
2621
  additionalToolbarItems
2459
2622
  }) });
2460
2623
  }
2461
- return /* @__PURE__ */ jsxRuntime.jsxs(
2624
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
2462
2625
  "div",
2463
2626
  {
2464
- className: tailwindMerge.twMerge("flex flex-col items-end group pt-10", className),
2627
+ className: (0, import_tailwind_merge5.twMerge)("flex flex-col items-end group pt-10", className),
2465
2628
  "data-message-id": message.id,
2466
2629
  ...props,
2467
2630
  children: [
@@ -2472,18 +2635,18 @@ function CopilotChatUserMessage({
2472
2635
  );
2473
2636
  }
2474
2637
  ((CopilotChatUserMessage2) => {
2475
- CopilotChatUserMessage2.Container = ({ children, className, ...props }) => /* @__PURE__ */ jsxRuntime.jsx(
2638
+ CopilotChatUserMessage2.Container = ({ children, className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2476
2639
  "div",
2477
2640
  {
2478
- className: tailwindMerge.twMerge("flex flex-col items-end group", className),
2641
+ className: (0, import_tailwind_merge5.twMerge)("flex flex-col items-end group", className),
2479
2642
  ...props,
2480
2643
  children
2481
2644
  }
2482
2645
  );
2483
- CopilotChatUserMessage2.MessageRenderer = ({ content, className }) => /* @__PURE__ */ jsxRuntime.jsx(
2646
+ CopilotChatUserMessage2.MessageRenderer = ({ content, className }) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2484
2647
  "div",
2485
2648
  {
2486
- className: tailwindMerge.twMerge(
2649
+ className: (0, import_tailwind_merge5.twMerge)(
2487
2650
  "prose dark:prose-invert bg-muted relative max-w-[80%] rounded-[18px] px-4 py-1.5 data-[multiline]:py-3 inline-block whitespace-pre-wrap",
2488
2651
  className
2489
2652
  ),
@@ -2493,10 +2656,10 @@ function CopilotChatUserMessage({
2493
2656
  CopilotChatUserMessage2.Toolbar = ({
2494
2657
  className,
2495
2658
  ...props
2496
- }) => /* @__PURE__ */ jsxRuntime.jsx(
2659
+ }) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2497
2660
  "div",
2498
2661
  {
2499
- className: tailwindMerge.twMerge(
2662
+ className: (0, import_tailwind_merge5.twMerge)(
2500
2663
  "w-full bg-transparent flex items-center justify-end -mr-[5px] mt-[4px] invisible group-hover:visible",
2501
2664
  className
2502
2665
  ),
@@ -2504,25 +2667,25 @@ function CopilotChatUserMessage({
2504
2667
  }
2505
2668
  );
2506
2669
  CopilotChatUserMessage2.ToolbarButton = ({ title, children, className, ...props }) => {
2507
- return /* @__PURE__ */ jsxRuntime.jsxs(Tooltip, { children: [
2508
- /* @__PURE__ */ jsxRuntime.jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
2670
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(Tooltip, { children: [
2671
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2509
2672
  Button,
2510
2673
  {
2511
2674
  type: "button",
2512
2675
  variant: "assistantMessageToolbarButton",
2513
2676
  "aria-label": title,
2514
- className: tailwindMerge.twMerge(className),
2677
+ className: (0, import_tailwind_merge5.twMerge)(className),
2515
2678
  ...props,
2516
2679
  children
2517
2680
  }
2518
2681
  ) }),
2519
- /* @__PURE__ */ jsxRuntime.jsx(TooltipContent, { side: "bottom", children: /* @__PURE__ */ jsxRuntime.jsx("p", { children: title }) })
2682
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(TooltipContent, { side: "bottom", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { children: title }) })
2520
2683
  ] });
2521
2684
  };
2522
2685
  CopilotChatUserMessage2.CopyButton = ({ className, title, onClick, ...props }) => {
2523
2686
  const config = useCopilotChatConfiguration();
2524
2687
  const labels = config?.labels ?? CopilotChatDefaultLabels;
2525
- const [copied, setCopied] = React2.useState(false);
2688
+ const [copied, setCopied] = (0, import_react18.useState)(false);
2526
2689
  const handleClick = (event) => {
2527
2690
  setCopied(true);
2528
2691
  setTimeout(() => setCopied(false), 2e3);
@@ -2530,27 +2693,27 @@ function CopilotChatUserMessage({
2530
2693
  onClick(event);
2531
2694
  }
2532
2695
  };
2533
- return /* @__PURE__ */ jsxRuntime.jsx(
2696
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2534
2697
  CopilotChatUserMessage2.ToolbarButton,
2535
2698
  {
2536
2699
  title: title || labels.userMessageToolbarCopyMessageLabel,
2537
2700
  onClick: handleClick,
2538
2701
  className,
2539
2702
  ...props,
2540
- children: copied ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "size-[18px]" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Copy, { className: "size-[18px]" })
2703
+ children: copied ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react4.Check, { className: "size-[18px]" }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react4.Copy, { className: "size-[18px]" })
2541
2704
  }
2542
2705
  );
2543
2706
  };
2544
2707
  CopilotChatUserMessage2.EditButton = ({ className, title, ...props }) => {
2545
2708
  const config = useCopilotChatConfiguration();
2546
2709
  const labels = config?.labels ?? CopilotChatDefaultLabels;
2547
- return /* @__PURE__ */ jsxRuntime.jsx(
2710
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2548
2711
  CopilotChatUserMessage2.ToolbarButton,
2549
2712
  {
2550
2713
  title: title || labels.userMessageToolbarEditMessageLabel,
2551
2714
  className,
2552
2715
  ...props,
2553
- children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Edit, { className: "size-[18px]" })
2716
+ children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react4.Edit, { className: "size-[18px]" })
2554
2717
  }
2555
2718
  );
2556
2719
  };
@@ -2567,8 +2730,8 @@ function CopilotChatUserMessage({
2567
2730
  }
2568
2731
  const canGoPrev = currentBranch > 0;
2569
2732
  const canGoNext = currentBranch < numberOfBranches - 1;
2570
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: tailwindMerge.twMerge("flex items-center gap-1", className), ...props, children: [
2571
- /* @__PURE__ */ jsxRuntime.jsx(
2733
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: (0, import_tailwind_merge5.twMerge)("flex items-center gap-1", className), ...props, children: [
2734
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2572
2735
  Button,
2573
2736
  {
2574
2737
  type: "button",
@@ -2580,15 +2743,15 @@ function CopilotChatUserMessage({
2580
2743
  }),
2581
2744
  disabled: !canGoPrev,
2582
2745
  className: "h-6 w-6 p-0",
2583
- children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronLeft, { className: "size-[20px]" })
2746
+ children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react4.ChevronLeft, { className: "size-[20px]" })
2584
2747
  }
2585
2748
  ),
2586
- /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-sm text-muted-foreground px-0 font-medium", children: [
2749
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { className: "text-sm text-muted-foreground px-0 font-medium", children: [
2587
2750
  currentBranch + 1,
2588
2751
  "/",
2589
2752
  numberOfBranches
2590
2753
  ] }),
2591
- /* @__PURE__ */ jsxRuntime.jsx(
2754
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2592
2755
  Button,
2593
2756
  {
2594
2757
  type: "button",
@@ -2600,7 +2763,7 @@ function CopilotChatUserMessage({
2600
2763
  }),
2601
2764
  disabled: !canGoNext,
2602
2765
  className: "h-6 w-6 p-0",
2603
- children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronRight, { className: "size-[20px]" })
2766
+ children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react4.ChevronRight, { className: "size-[20px]" })
2604
2767
  }
2605
2768
  )
2606
2769
  ] });
@@ -2614,11 +2777,16 @@ CopilotChatUserMessage.CopyButton.displayName = "CopilotChatUserMessage.CopyButt
2614
2777
  CopilotChatUserMessage.EditButton.displayName = "CopilotChatUserMessage.EditButton";
2615
2778
  CopilotChatUserMessage.BranchNavigation.displayName = "CopilotChatUserMessage.BranchNavigation";
2616
2779
  var CopilotChatUserMessage_default = CopilotChatUserMessage;
2780
+
2781
+ // src/components/chat/CopilotChatSuggestionPill.tsx
2782
+ var import_react19 = __toESM(require("react"));
2783
+ var import_lucide_react5 = require("lucide-react");
2784
+ var import_jsx_runtime15 = require("react/jsx-runtime");
2617
2785
  var baseClasses = "group inline-flex h-7 sm:h-8 items-center gap-1 sm:gap-1.5 rounded-full border border-border/60 bg-background px-2.5 sm:px-3 text-[11px] sm:text-xs leading-none text-foreground transition-colors cursor-pointer hover:bg-accent/60 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:text-muted-foreground disabled:hover:bg-background disabled:hover:text-muted-foreground pointer-events-auto";
2618
2786
  var labelClasses = "whitespace-nowrap font-medium leading-none";
2619
- var CopilotChatSuggestionPill = React2__namespace.default.forwardRef(function CopilotChatSuggestionPill2({ className, children, icon, isLoading, type, ...props }, ref) {
2787
+ var CopilotChatSuggestionPill = import_react19.default.forwardRef(function CopilotChatSuggestionPill2({ className, children, icon, isLoading, type, ...props }, ref) {
2620
2788
  const showIcon = !isLoading && icon;
2621
- return /* @__PURE__ */ jsxRuntime.jsxs(
2789
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
2622
2790
  "button",
2623
2791
  {
2624
2792
  ref,
@@ -2629,16 +2797,20 @@ var CopilotChatSuggestionPill = React2__namespace.default.forwardRef(function Co
2629
2797
  disabled: isLoading || props.disabled,
2630
2798
  ...props,
2631
2799
  children: [
2632
- isLoading ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex h-3.5 sm:h-4 w-3.5 sm:w-4 items-center justify-center text-muted-foreground", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "h-3.5 sm:h-4 w-3.5 sm:w-4 animate-spin", "aria-hidden": "true" }) }) : showIcon && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex h-3.5 sm:h-4 w-3.5 sm:w-4 items-center justify-center text-muted-foreground", children: icon }),
2633
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: labelClasses, children })
2800
+ isLoading ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "flex h-3.5 sm:h-4 w-3.5 sm:w-4 items-center justify-center text-muted-foreground", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_lucide_react5.Loader2, { className: "h-3.5 sm:h-4 w-3.5 sm:w-4 animate-spin", "aria-hidden": "true" }) }) : showIcon && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "flex h-3.5 sm:h-4 w-3.5 sm:w-4 items-center justify-center text-muted-foreground", children: icon }),
2801
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: labelClasses, children })
2634
2802
  ]
2635
2803
  }
2636
2804
  );
2637
2805
  });
2638
2806
  CopilotChatSuggestionPill.displayName = "CopilotChatSuggestionPill";
2639
2807
  var CopilotChatSuggestionPill_default = CopilotChatSuggestionPill;
2640
- var DefaultContainer = React2__namespace.default.forwardRef(function DefaultContainer2({ className, ...props }, ref) {
2641
- return /* @__PURE__ */ jsxRuntime.jsx(
2808
+
2809
+ // src/components/chat/CopilotChatSuggestionView.tsx
2810
+ var import_react20 = __toESM(require("react"));
2811
+ var import_jsx_runtime16 = require("react/jsx-runtime");
2812
+ var DefaultContainer = import_react20.default.forwardRef(function DefaultContainer2({ className, ...props }, ref) {
2813
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
2642
2814
  "div",
2643
2815
  {
2644
2816
  ref,
@@ -2650,7 +2822,7 @@ var DefaultContainer = React2__namespace.default.forwardRef(function DefaultCont
2650
2822
  }
2651
2823
  );
2652
2824
  });
2653
- var CopilotChatSuggestionView = React2__namespace.default.forwardRef(function CopilotChatSuggestionView2({
2825
+ var CopilotChatSuggestionView = import_react20.default.forwardRef(function CopilotChatSuggestionView2({
2654
2826
  suggestions,
2655
2827
  onSelectSuggestion,
2656
2828
  loadingIndexes,
@@ -2660,7 +2832,7 @@ var CopilotChatSuggestionView = React2__namespace.default.forwardRef(function Co
2660
2832
  children,
2661
2833
  ...restProps
2662
2834
  }, ref) {
2663
- const loadingSet = React2__namespace.default.useMemo(() => {
2835
+ const loadingSet = import_react20.default.useMemo(() => {
2664
2836
  if (!loadingIndexes || loadingIndexes.length === 0) {
2665
2837
  return /* @__PURE__ */ new Set();
2666
2838
  }
@@ -2679,11 +2851,11 @@ var CopilotChatSuggestionView = React2__namespace.default.forwardRef(function Co
2679
2851
  type: "button",
2680
2852
  onClick: () => onSelectSuggestion?.(suggestion, index)
2681
2853
  });
2682
- return React2__namespace.default.cloneElement(pill, {
2854
+ return import_react20.default.cloneElement(pill, {
2683
2855
  key: `${suggestion.title}-${index}`
2684
2856
  });
2685
2857
  });
2686
- const boundContainer = React2__namespace.default.cloneElement(
2858
+ const boundContainer = import_react20.default.cloneElement(
2687
2859
  ContainerElement,
2688
2860
  void 0,
2689
2861
  suggestionElements
@@ -2694,7 +2866,7 @@ var CopilotChatSuggestionView = React2__namespace.default.forwardRef(function Co
2694
2866
  isLoading: suggestions.length > 0 ? loadingSet.has(0) || suggestions[0]?.isLoading === true : false,
2695
2867
  type: "button"
2696
2868
  });
2697
- return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: children({
2869
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_jsx_runtime16.Fragment, { children: children({
2698
2870
  container: boundContainer,
2699
2871
  suggestion: sampleSuggestion,
2700
2872
  suggestions,
@@ -2705,7 +2877,7 @@ var CopilotChatSuggestionView = React2__namespace.default.forwardRef(function Co
2705
2877
  }) });
2706
2878
  }
2707
2879
  if (children) {
2708
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2880
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
2709
2881
  boundContainer,
2710
2882
  children
2711
2883
  ] });
@@ -2714,6 +2886,10 @@ var CopilotChatSuggestionView = React2__namespace.default.forwardRef(function Co
2714
2886
  });
2715
2887
  CopilotChatSuggestionView.displayName = "CopilotChatSuggestionView";
2716
2888
  var CopilotChatSuggestionView_default = CopilotChatSuggestionView;
2889
+
2890
+ // src/components/chat/CopilotChatMessageView.tsx
2891
+ var import_tailwind_merge6 = require("tailwind-merge");
2892
+ var import_jsx_runtime17 = require("react/jsx-runtime");
2717
2893
  function CopilotChatMessageView({
2718
2894
  messages = [],
2719
2895
  assistantMessage,
@@ -2771,29 +2947,38 @@ function CopilotChatMessageView({
2771
2947
  if (children) {
2772
2948
  return children({ messageElements, messages, isRunning });
2773
2949
  }
2774
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: tailwindMerge.twMerge("flex flex-col", className), ...props, children: [
2950
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: (0, import_tailwind_merge6.twMerge)("flex flex-col", className), ...props, children: [
2775
2951
  messageElements,
2776
2952
  isRunning && renderSlot(cursor, CopilotChatMessageView.Cursor, {})
2777
2953
  ] });
2778
2954
  }
2779
2955
  CopilotChatMessageView.Cursor = function Cursor({ className, ...props }) {
2780
- return /* @__PURE__ */ jsxRuntime.jsx(
2956
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2781
2957
  "div",
2782
2958
  {
2783
- className: tailwindMerge.twMerge("w-[11px] h-[11px] rounded-full bg-foreground animate-pulse-cursor ml-1", className),
2959
+ className: (0, import_tailwind_merge6.twMerge)("w-[11px] h-[11px] rounded-full bg-foreground animate-pulse-cursor ml-1", className),
2784
2960
  ...props
2785
2961
  }
2786
2962
  );
2787
2963
  };
2788
2964
  var CopilotChatMessageView_default = CopilotChatMessageView;
2965
+
2966
+ // src/components/chat/CopilotChatView.tsx
2967
+ var import_react22 = __toESM(require("react"));
2968
+ var import_tailwind_merge7 = require("tailwind-merge");
2969
+ var import_use_stick_to_bottom = require("use-stick-to-bottom");
2970
+ var import_lucide_react6 = require("lucide-react");
2971
+
2972
+ // src/hooks/use-keyboard-height.tsx
2973
+ var import_react21 = require("react");
2789
2974
  function useKeyboardHeight() {
2790
- const [keyboardState, setKeyboardState] = React2.useState({
2975
+ const [keyboardState, setKeyboardState] = (0, import_react21.useState)({
2791
2976
  isKeyboardOpen: false,
2792
2977
  keyboardHeight: 0,
2793
2978
  availableHeight: typeof window !== "undefined" ? window.innerHeight : 0,
2794
2979
  viewportHeight: typeof window !== "undefined" ? window.innerHeight : 0
2795
2980
  });
2796
- React2.useEffect(() => {
2981
+ (0, import_react21.useEffect)(() => {
2797
2982
  if (typeof window === "undefined") {
2798
2983
  return;
2799
2984
  }
@@ -2823,6 +3008,9 @@ function useKeyboardHeight() {
2823
3008
  }, []);
2824
3009
  return keyboardState;
2825
3010
  }
3011
+
3012
+ // src/components/chat/CopilotChatView.tsx
3013
+ var import_jsx_runtime18 = require("react/jsx-runtime");
2826
3014
  function CopilotChatView({
2827
3015
  messageView,
2828
3016
  input,
@@ -2843,12 +3031,12 @@ function CopilotChatView({
2843
3031
  className,
2844
3032
  ...props
2845
3033
  }) {
2846
- const inputContainerRef = React2.useRef(null);
2847
- const [inputContainerHeight, setInputContainerHeight] = React2.useState(0);
2848
- const [isResizing, setIsResizing] = React2.useState(false);
2849
- const resizeTimeoutRef = React2.useRef(null);
3034
+ const inputContainerRef = (0, import_react22.useRef)(null);
3035
+ const [inputContainerHeight, setInputContainerHeight] = (0, import_react22.useState)(0);
3036
+ const [isResizing, setIsResizing] = (0, import_react22.useState)(false);
3037
+ const resizeTimeoutRef = (0, import_react22.useRef)(null);
2850
3038
  const { isKeyboardOpen, keyboardHeight, availableHeight } = useKeyboardHeight();
2851
- React2.useEffect(() => {
3039
+ (0, import_react22.useEffect)(() => {
2852
3040
  const element = inputContainerRef.current;
2853
3041
  if (!element) return;
2854
3042
  const resizeObserver = new ResizeObserver((entries) => {
@@ -2900,9 +3088,9 @@ function CopilotChatView({
2900
3088
  scrollToBottomButton,
2901
3089
  inputContainerHeight,
2902
3090
  isResizing,
2903
- children: /* @__PURE__ */ jsxRuntime.jsx("div", { style: { paddingBottom: `${inputContainerHeight + (hasSuggestions ? 4 : 32)}px` }, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "max-w-3xl mx-auto", children: [
3091
+ children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { style: { paddingBottom: `${inputContainerHeight + (hasSuggestions ? 4 : 32)}px` }, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "max-w-3xl mx-auto", children: [
2904
3092
  BoundMessageView,
2905
- hasSuggestions ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pl-0 pr-4 sm:px-0 mt-4", children: BoundSuggestionView }) : null
3093
+ hasSuggestions ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "pl-0 pr-4 sm:px-0 mt-4", children: BoundSuggestionView }) : null
2906
3094
  ] }) })
2907
3095
  });
2908
3096
  const BoundScrollToBottomButton = renderSlot(scrollToBottomButton, CopilotChatView.ScrollToBottomButton, {});
@@ -2910,8 +3098,8 @@ function CopilotChatView({
2910
3098
  const BoundInputContainer = renderSlot(inputContainer, CopilotChatView.InputContainer, {
2911
3099
  ref: inputContainerRef,
2912
3100
  keyboardHeight: isKeyboardOpen ? keyboardHeight : 0,
2913
- children: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2914
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "max-w-3xl mx-auto py-0 px-4 sm:px-0 [div[data-sidebar-chat]_&]:px-8 [div[data-popup-chat]_&]:px-6 pointer-events-auto", children: BoundInput }),
3101
+ children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_jsx_runtime18.Fragment, { children: [
3102
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "max-w-3xl mx-auto py-0 px-4 sm:px-0 [div[data-sidebar-chat]_&]:px-8 [div[data-popup-chat]_&]:px-6 pointer-events-auto", children: BoundInput }),
2915
3103
  BoundDisclaimer
2916
3104
  ] })
2917
3105
  });
@@ -2924,10 +3112,10 @@ function CopilotChatView({
2924
3112
  feather: BoundFeather,
2925
3113
  inputContainer: BoundInputContainer,
2926
3114
  disclaimer: BoundDisclaimer,
2927
- suggestionView: BoundSuggestionView ?? /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {})
3115
+ suggestionView: BoundSuggestionView ?? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_jsx_runtime18.Fragment, {})
2928
3116
  });
2929
3117
  }
2930
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: tailwindMerge.twMerge("relative h-full", className), ...props, children: [
3118
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: (0, import_tailwind_merge7.twMerge)("relative h-full", className), ...props, children: [
2931
3119
  BoundScrollView,
2932
3120
  BoundFeather,
2933
3121
  BoundInputContainer
@@ -2935,10 +3123,10 @@ function CopilotChatView({
2935
3123
  }
2936
3124
  ((CopilotChatView2) => {
2937
3125
  const ScrollContent = ({ children, scrollToBottomButton, inputContainerHeight, isResizing }) => {
2938
- const { isAtBottom, scrollToBottom } = useStickToBottom.useStickToBottomContext();
2939
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2940
- /* @__PURE__ */ jsxRuntime.jsx(useStickToBottom.StickToBottom.Content, { className: "overflow-y-scroll overflow-x-hidden", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-4 sm:px-0 [div[data-sidebar-chat]_&]:px-8 [div[data-popup-chat]_&]:px-6", children }) }),
2941
- !isAtBottom && !isResizing && /* @__PURE__ */ jsxRuntime.jsx(
3126
+ const { isAtBottom, scrollToBottom } = (0, import_use_stick_to_bottom.useStickToBottomContext)();
3127
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_jsx_runtime18.Fragment, { children: [
3128
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_use_stick_to_bottom.StickToBottom.Content, { className: "overflow-y-scroll overflow-x-hidden", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "px-4 sm:px-0 [div[data-sidebar-chat]_&]:px-8 [div[data-popup-chat]_&]:px-6", children }) }),
3129
+ !isAtBottom && !isResizing && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2942
3130
  "div",
2943
3131
  {
2944
3132
  className: "absolute inset-x-0 flex justify-center z-10 pointer-events-none",
@@ -2961,13 +3149,13 @@ function CopilotChatView({
2961
3149
  className,
2962
3150
  ...props
2963
3151
  }) => {
2964
- const [hasMounted, setHasMounted] = React2.useState(false);
2965
- const { scrollRef, contentRef, scrollToBottom } = useStickToBottom.useStickToBottom();
2966
- const [showScrollButton, setShowScrollButton] = React2.useState(false);
2967
- React2.useEffect(() => {
3152
+ const [hasMounted, setHasMounted] = (0, import_react22.useState)(false);
3153
+ const { scrollRef, contentRef, scrollToBottom } = (0, import_use_stick_to_bottom.useStickToBottom)();
3154
+ const [showScrollButton, setShowScrollButton] = (0, import_react22.useState)(false);
3155
+ (0, import_react22.useEffect)(() => {
2968
3156
  setHasMounted(true);
2969
3157
  }, []);
2970
- React2.useEffect(() => {
3158
+ (0, import_react22.useEffect)(() => {
2971
3159
  if (autoScroll) return;
2972
3160
  const scrollElement = scrollRef.current;
2973
3161
  if (!scrollElement) return;
@@ -2985,10 +3173,10 @@ function CopilotChatView({
2985
3173
  };
2986
3174
  }, [scrollRef, autoScroll]);
2987
3175
  if (!hasMounted) {
2988
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-full max-h-full flex flex-col min-h-0 overflow-y-scroll overflow-x-hidden", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-4 sm:px-0 [div[data-sidebar-chat]_&]:px-8 [div[data-popup-chat]_&]:px-6", children }) });
3176
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "h-full max-h-full flex flex-col min-h-0 overflow-y-scroll overflow-x-hidden", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "px-4 sm:px-0 [div[data-sidebar-chat]_&]:px-8 [div[data-popup-chat]_&]:px-6", children }) });
2989
3177
  }
2990
3178
  if (!autoScroll) {
2991
- return /* @__PURE__ */ jsxRuntime.jsxs(
3179
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
2992
3180
  "div",
2993
3181
  {
2994
3182
  ref: scrollRef,
@@ -2998,8 +3186,8 @@ function CopilotChatView({
2998
3186
  ),
2999
3187
  ...props,
3000
3188
  children: [
3001
- /* @__PURE__ */ jsxRuntime.jsx("div", { ref: contentRef, className: "px-4 sm:px-0 [div[data-sidebar-chat]_&]:px-8 [div[data-popup-chat]_&]:px-6", children }),
3002
- showScrollButton && !isResizing && /* @__PURE__ */ jsxRuntime.jsx(
3189
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { ref: contentRef, className: "px-4 sm:px-0 [div[data-sidebar-chat]_&]:px-8 [div[data-popup-chat]_&]:px-6", children }),
3190
+ showScrollButton && !isResizing && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3003
3191
  "div",
3004
3192
  {
3005
3193
  className: "absolute inset-x-0 flex justify-center z-10 pointer-events-none",
@@ -3015,14 +3203,14 @@ function CopilotChatView({
3015
3203
  }
3016
3204
  );
3017
3205
  }
3018
- return /* @__PURE__ */ jsxRuntime.jsx(
3019
- useStickToBottom.StickToBottom,
3206
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3207
+ import_use_stick_to_bottom.StickToBottom,
3020
3208
  {
3021
3209
  className: cn("h-full max-h-full flex flex-col min-h-0 relative", className),
3022
3210
  resize: "smooth",
3023
3211
  initial: "smooth",
3024
3212
  ...props,
3025
- children: /* @__PURE__ */ jsxRuntime.jsx(
3213
+ children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3026
3214
  ScrollContent,
3027
3215
  {
3028
3216
  scrollToBottomButton,
@@ -3037,12 +3225,12 @@ function CopilotChatView({
3037
3225
  CopilotChatView2.ScrollToBottomButton = ({
3038
3226
  className,
3039
3227
  ...props
3040
- }) => /* @__PURE__ */ jsxRuntime.jsx(
3228
+ }) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3041
3229
  Button,
3042
3230
  {
3043
3231
  variant: "outline",
3044
3232
  size: "sm",
3045
- className: tailwindMerge.twMerge(
3233
+ className: (0, import_tailwind_merge7.twMerge)(
3046
3234
  "rounded-full w-10 h-10 p-0 pointer-events-auto",
3047
3235
  "bg-white dark:bg-gray-900",
3048
3236
  "shadow-lg border border-gray-200 dark:border-gray-700",
@@ -3051,10 +3239,10 @@ function CopilotChatView({
3051
3239
  className
3052
3240
  ),
3053
3241
  ...props,
3054
- children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, { className: "w-4 h-4 text-gray-600 dark:text-white" })
3242
+ children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_lucide_react6.ChevronDown, { className: "w-4 h-4 text-gray-600 dark:text-white" })
3055
3243
  }
3056
3244
  );
3057
- CopilotChatView2.Feather = ({ className, style, ...props }) => /* @__PURE__ */ jsxRuntime.jsx(
3245
+ CopilotChatView2.Feather = ({ className, style, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3058
3246
  "div",
3059
3247
  {
3060
3248
  className: cn(
@@ -3067,7 +3255,7 @@ function CopilotChatView({
3067
3255
  ...props
3068
3256
  }
3069
3257
  );
3070
- CopilotChatView2.InputContainer = React2__namespace.default.forwardRef(({ children, className, keyboardHeight = 0, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
3258
+ CopilotChatView2.InputContainer = import_react22.default.forwardRef(({ children, className, keyboardHeight = 0, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3071
3259
  "div",
3072
3260
  {
3073
3261
  ref,
@@ -3085,7 +3273,7 @@ function CopilotChatView({
3085
3273
  CopilotChatView2.Disclaimer = ({ className, ...props }) => {
3086
3274
  const config = useCopilotChatConfiguration();
3087
3275
  const labels = config?.labels ?? CopilotChatDefaultLabels;
3088
- return /* @__PURE__ */ jsxRuntime.jsx(
3276
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3089
3277
  "div",
3090
3278
  {
3091
3279
  className: cn("text-center text-xs text-muted-foreground py-3 px-4 max-w-3xl mx-auto", className),
@@ -3096,11 +3284,18 @@ function CopilotChatView({
3096
3284
  };
3097
3285
  })(CopilotChatView || (CopilotChatView = {}));
3098
3286
  var CopilotChatView_default = CopilotChatView;
3287
+
3288
+ // src/components/chat/CopilotChat.tsx
3289
+ var import_shared8 = require("@copilotkitnext/shared");
3290
+ var import_react23 = require("react");
3291
+ var import_ts_deepmerge = require("ts-deepmerge");
3292
+ var import_client = require("@ag-ui/client");
3293
+ var import_jsx_runtime19 = require("react/jsx-runtime");
3099
3294
  function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen, ...props }) {
3100
3295
  const existingConfig = useCopilotChatConfiguration();
3101
- const resolvedAgentId = agentId ?? existingConfig?.agentId ?? shared.DEFAULT_AGENT_ID;
3102
- const resolvedThreadId = React2.useMemo(
3103
- () => threadId ?? existingConfig?.threadId ?? shared.randomUUID(),
3296
+ const resolvedAgentId = agentId ?? existingConfig?.agentId ?? import_shared8.DEFAULT_AGENT_ID;
3297
+ const resolvedThreadId = (0, import_react23.useMemo)(
3298
+ () => threadId ?? existingConfig?.threadId ?? (0, import_shared8.randomUUID)(),
3104
3299
  [threadId, existingConfig?.threadId]
3105
3300
  );
3106
3301
  const { agent } = useAgent({ agentId: resolvedAgentId });
@@ -3112,47 +3307,41 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
3112
3307
  suggestionView: providedSuggestionView,
3113
3308
  ...restProps
3114
3309
  } = props;
3115
- React2.useEffect(() => {
3310
+ (0, import_react23.useEffect)(() => {
3116
3311
  const connect = async (agent2) => {
3117
3312
  try {
3118
3313
  await copilotkit.connectAgent({ agent: agent2 });
3119
3314
  } catch (error) {
3120
- if (error instanceof client.AGUIConnectNotImplementedError) ; else {
3315
+ if (error instanceof import_client.AGUIConnectNotImplementedError) {
3316
+ } else {
3121
3317
  throw error;
3122
3318
  }
3123
3319
  }
3124
3320
  };
3125
- if (agent) {
3126
- agent.threadId = resolvedThreadId;
3127
- connect(agent);
3128
- }
3321
+ agent.threadId = resolvedThreadId;
3322
+ connect(agent);
3129
3323
  return () => {
3130
3324
  };
3131
3325
  }, [resolvedThreadId, agent, copilotkit, resolvedAgentId]);
3132
- const onSubmitInput = React2.useCallback(
3326
+ const onSubmitInput = (0, import_react23.useCallback)(
3133
3327
  async (value) => {
3134
- agent?.addMessage({
3135
- id: shared.randomUUID(),
3328
+ agent.addMessage({
3329
+ id: (0, import_shared8.randomUUID)(),
3136
3330
  role: "user",
3137
3331
  content: value
3138
3332
  });
3139
- if (agent) {
3140
- try {
3141
- await copilotkit.runAgent({ agent });
3142
- } catch (error) {
3143
- console.error("CopilotChat: runAgent failed", error);
3144
- }
3333
+ try {
3334
+ await copilotkit.runAgent({ agent });
3335
+ } catch (error) {
3336
+ console.error("CopilotChat: runAgent failed", error);
3145
3337
  }
3146
3338
  },
3147
3339
  [agent, copilotkit]
3148
3340
  );
3149
- const handleSelectSuggestion = React2.useCallback(
3341
+ const handleSelectSuggestion = (0, import_react23.useCallback)(
3150
3342
  async (suggestion) => {
3151
- if (!agent) {
3152
- return;
3153
- }
3154
3343
  agent.addMessage({
3155
- id: shared.randomUUID(),
3344
+ id: (0, import_shared8.randomUUID)(),
3156
3345
  role: "user",
3157
3346
  content: suggestion.message
3158
3347
  });
@@ -3164,10 +3353,7 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
3164
3353
  },
3165
3354
  [agent, copilotkit]
3166
3355
  );
3167
- const stopCurrentRun = React2.useCallback(() => {
3168
- if (!agent) {
3169
- return;
3170
- }
3356
+ const stopCurrentRun = (0, import_react23.useCallback)(() => {
3171
3357
  try {
3172
3358
  copilotkit.stopAgent({ agent });
3173
3359
  } catch (error) {
@@ -3179,9 +3365,9 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
3179
3365
  }
3180
3366
  }
3181
3367
  }, [agent, copilotkit]);
3182
- const mergedProps = tsDeepmerge.merge(
3368
+ const mergedProps = (0, import_ts_deepmerge.merge)(
3183
3369
  {
3184
- isRunning: agent?.isRunning ?? false,
3370
+ isRunning: agent.isRunning,
3185
3371
  suggestions: autoSuggestions,
3186
3372
  onSelectSuggestion: handleSelectSuggestion,
3187
3373
  suggestionView: providedSuggestionView
@@ -3192,22 +3378,22 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
3192
3378
  }
3193
3379
  );
3194
3380
  const providedStopHandler = providedInputProps?.onStop;
3195
- const hasMessages = (agent?.messages?.length ?? 0) > 0;
3196
- const shouldAllowStop = (agent?.isRunning ?? false) && hasMessages;
3381
+ const hasMessages = agent.messages.length > 0;
3382
+ const shouldAllowStop = agent.isRunning && hasMessages;
3197
3383
  const effectiveStopHandler = shouldAllowStop ? providedStopHandler ?? stopCurrentRun : providedStopHandler;
3198
3384
  const finalInputProps = {
3199
3385
  ...providedInputProps,
3200
3386
  onSubmitMessage: onSubmitInput,
3201
3387
  onStop: effectiveStopHandler,
3202
- isRunning: agent?.isRunning ?? false
3388
+ isRunning: agent.isRunning
3203
3389
  };
3204
- finalInputProps.mode = agent?.isRunning ? "processing" : finalInputProps.mode ?? "input";
3205
- const finalProps = tsDeepmerge.merge(mergedProps, {
3206
- messages: agent?.messages ?? [],
3390
+ finalInputProps.mode = agent.isRunning ? "processing" : finalInputProps.mode ?? "input";
3391
+ const finalProps = (0, import_ts_deepmerge.merge)(mergedProps, {
3392
+ messages: agent.messages,
3207
3393
  inputProps: finalInputProps
3208
3394
  });
3209
3395
  const RenderedChatView = renderSlot(chatView, CopilotChatView, finalProps);
3210
- return /* @__PURE__ */ jsxRuntime.jsx(
3396
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
3211
3397
  CopilotChatConfigurationProvider,
3212
3398
  {
3213
3399
  agentId: resolvedAgentId,
@@ -3221,14 +3407,19 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
3221
3407
  ((CopilotChat2) => {
3222
3408
  CopilotChat2.View = CopilotChatView;
3223
3409
  })(CopilotChat || (CopilotChat = {}));
3410
+
3411
+ // src/components/chat/CopilotChatToggleButton.tsx
3412
+ var import_react24 = __toESM(require("react"));
3413
+ var import_lucide_react7 = require("lucide-react");
3414
+ var import_jsx_runtime20 = require("react/jsx-runtime");
3224
3415
  var DefaultOpenIcon = ({
3225
3416
  className,
3226
3417
  ...props
3227
- }) => /* @__PURE__ */ jsxRuntime.jsx(lucideReact.MessageCircle, { className: cn("h-6 w-6", className), strokeWidth: 1.75, fill: "currentColor", ...props });
3418
+ }) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_lucide_react7.MessageCircle, { className: cn("h-6 w-6", className), strokeWidth: 1.75, fill: "currentColor", ...props });
3228
3419
  var DefaultCloseIcon = ({
3229
3420
  className,
3230
3421
  ...props
3231
- }) => /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: cn("h-6 w-6", className), strokeWidth: 1.75, ...props });
3422
+ }) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_lucide_react7.X, { className: cn("h-6 w-6", className), strokeWidth: 1.75, ...props });
3232
3423
  DefaultOpenIcon.displayName = "CopilotChatToggleButton.OpenIcon";
3233
3424
  DefaultCloseIcon.displayName = "CopilotChatToggleButton.CloseIcon";
3234
3425
  var ICON_TRANSITION_STYLE = Object.freeze({
@@ -3245,11 +3436,11 @@ var BUTTON_BASE_CLASSES = cn(
3245
3436
  "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 focus-visible:ring-offset-2 focus-visible:ring-offset-background",
3246
3437
  "disabled:pointer-events-none disabled:opacity-60"
3247
3438
  );
3248
- var CopilotChatToggleButton = React2__namespace.default.forwardRef(function CopilotChatToggleButton2({ openIcon, closeIcon, className, ...buttonProps }, ref) {
3439
+ var CopilotChatToggleButton = import_react24.default.forwardRef(function CopilotChatToggleButton2({ openIcon, closeIcon, className, ...buttonProps }, ref) {
3249
3440
  const { onClick, type, disabled, ...restProps } = buttonProps;
3250
3441
  const configuration = useCopilotChatConfiguration();
3251
3442
  const labels = configuration?.labels ?? CopilotChatDefaultLabels;
3252
- const [fallbackOpen, setFallbackOpen] = React2.useState(false);
3443
+ const [fallbackOpen, setFallbackOpen] = (0, import_react24.useState)(false);
3253
3444
  const isOpen = configuration?.isModalOpen ?? fallbackOpen;
3254
3445
  const setModalOpen = configuration?.setModalOpen ?? setFallbackOpen;
3255
3446
  const handleClick = (event) => {
@@ -3283,7 +3474,7 @@ var CopilotChatToggleButton = React2__namespace.default.forwardRef(function Copi
3283
3474
  focusable: false
3284
3475
  }
3285
3476
  );
3286
- const openIconElement = /* @__PURE__ */ jsxRuntime.jsx(
3477
+ const openIconElement = /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
3287
3478
  "span",
3288
3479
  {
3289
3480
  "aria-hidden": "true",
@@ -3297,7 +3488,7 @@ var CopilotChatToggleButton = React2__namespace.default.forwardRef(function Copi
3297
3488
  children: renderedOpenIcon
3298
3489
  }
3299
3490
  );
3300
- const closeIconElement = /* @__PURE__ */ jsxRuntime.jsx(
3491
+ const closeIconElement = /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
3301
3492
  "span",
3302
3493
  {
3303
3494
  "aria-hidden": "true",
@@ -3311,7 +3502,7 @@ var CopilotChatToggleButton = React2__namespace.default.forwardRef(function Copi
3311
3502
  children: renderedCloseIcon
3312
3503
  }
3313
3504
  );
3314
- return /* @__PURE__ */ jsxRuntime.jsxs(
3505
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
3315
3506
  "button",
3316
3507
  {
3317
3508
  ref,
@@ -3333,6 +3524,14 @@ var CopilotChatToggleButton = React2__namespace.default.forwardRef(function Copi
3333
3524
  });
3334
3525
  CopilotChatToggleButton.displayName = "CopilotChatToggleButton";
3335
3526
  var CopilotChatToggleButton_default = CopilotChatToggleButton;
3527
+
3528
+ // src/components/chat/CopilotSidebarView.tsx
3529
+ var import_react26 = require("react");
3530
+
3531
+ // src/components/chat/CopilotModalHeader.tsx
3532
+ var import_react25 = require("react");
3533
+ var import_lucide_react8 = require("lucide-react");
3534
+ var import_jsx_runtime21 = require("react/jsx-runtime");
3336
3535
  function CopilotModalHeader({
3337
3536
  title,
3338
3537
  titleContent,
@@ -3344,7 +3543,7 @@ function CopilotModalHeader({
3344
3543
  const configuration = useCopilotChatConfiguration();
3345
3544
  const fallbackTitle = configuration?.labels.modalHeaderTitle ?? CopilotChatDefaultLabels.modalHeaderTitle;
3346
3545
  const resolvedTitle = title ?? fallbackTitle;
3347
- const handleClose = React2.useCallback(() => {
3546
+ const handleClose = (0, import_react25.useCallback)(() => {
3348
3547
  configuration?.setModalOpen(false);
3349
3548
  }, [configuration]);
3350
3549
  const BoundTitle = renderSlot(titleContent, CopilotModalHeader.Title, {
@@ -3361,7 +3560,7 @@ function CopilotModalHeader({
3361
3560
  ...rest
3362
3561
  });
3363
3562
  }
3364
- return /* @__PURE__ */ jsxRuntime.jsx(
3563
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
3365
3564
  "header",
3366
3565
  {
3367
3566
  "data-slot": "copilot-modal-header",
@@ -3371,17 +3570,17 @@ function CopilotModalHeader({
3371
3570
  className
3372
3571
  ),
3373
3572
  ...rest,
3374
- children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full items-center gap-2", children: [
3375
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1", "aria-hidden": "true" }),
3376
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-1 justify-center text-center", children: BoundTitle }),
3377
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-1 justify-end", children: BoundCloseButton })
3573
+ children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex w-full items-center gap-2", children: [
3574
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "flex-1", "aria-hidden": "true" }),
3575
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "flex flex-1 justify-center text-center", children: BoundTitle }),
3576
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "flex flex-1 justify-end", children: BoundCloseButton })
3378
3577
  ] })
3379
3578
  }
3380
3579
  );
3381
3580
  }
3382
3581
  CopilotModalHeader.displayName = "CopilotModalHeader";
3383
3582
  ((CopilotModalHeader2) => {
3384
- CopilotModalHeader2.Title = ({ children, className, ...props }) => /* @__PURE__ */ jsxRuntime.jsx(
3583
+ CopilotModalHeader2.Title = ({ children, className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
3385
3584
  "div",
3386
3585
  {
3387
3586
  className: cn(
@@ -3395,7 +3594,7 @@ CopilotModalHeader.displayName = "CopilotModalHeader";
3395
3594
  CopilotModalHeader2.CloseButton = ({
3396
3595
  className,
3397
3596
  ...props
3398
- }) => /* @__PURE__ */ jsxRuntime.jsx(
3597
+ }) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
3399
3598
  "button",
3400
3599
  {
3401
3600
  type: "button",
@@ -3406,19 +3605,22 @@ CopilotModalHeader.displayName = "CopilotModalHeader";
3406
3605
  ),
3407
3606
  "aria-label": "Close",
3408
3607
  ...props,
3409
- children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "h-4 w-4", "aria-hidden": "true" })
3608
+ children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_lucide_react8.X, { className: "h-4 w-4", "aria-hidden": "true" })
3410
3609
  }
3411
3610
  );
3412
3611
  })(CopilotModalHeader || (CopilotModalHeader = {}));
3413
3612
  CopilotModalHeader.Title.displayName = "CopilotModalHeader.Title";
3414
3613
  CopilotModalHeader.CloseButton.displayName = "CopilotModalHeader.CloseButton";
3614
+
3615
+ // src/components/chat/CopilotSidebarView.tsx
3616
+ var import_jsx_runtime22 = require("react/jsx-runtime");
3415
3617
  var DEFAULT_SIDEBAR_WIDTH = 480;
3416
3618
  var SIDEBAR_TRANSITION_MS = 260;
3417
3619
  function CopilotSidebarView({ header, width, ...props }) {
3418
3620
  const configuration = useCopilotChatConfiguration();
3419
3621
  const isSidebarOpen = configuration?.isModalOpen ?? false;
3420
- const sidebarRef = React2.useRef(null);
3421
- const [sidebarWidth, setSidebarWidth] = React2.useState(width ?? DEFAULT_SIDEBAR_WIDTH);
3622
+ const sidebarRef = (0, import_react26.useRef)(null);
3623
+ const [sidebarWidth, setSidebarWidth] = (0, import_react26.useState)(width ?? DEFAULT_SIDEBAR_WIDTH);
3422
3624
  const widthToCss = (w) => {
3423
3625
  return typeof w === "number" ? `${w}px` : w;
3424
3626
  };
@@ -3428,7 +3630,7 @@ function CopilotSidebarView({ header, width, ...props }) {
3428
3630
  }
3429
3631
  return w;
3430
3632
  };
3431
- React2.useEffect(() => {
3633
+ (0, import_react26.useEffect)(() => {
3432
3634
  if (width !== void 0) {
3433
3635
  return;
3434
3636
  }
@@ -3455,8 +3657,8 @@ function CopilotSidebarView({ header, width, ...props }) {
3455
3657
  return () => window.removeEventListener("resize", updateWidth);
3456
3658
  }, [width]);
3457
3659
  const headerElement = renderSlot(header, CopilotModalHeader, {});
3458
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3459
- isSidebarOpen && /* @__PURE__ */ jsxRuntime.jsx(
3660
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(import_jsx_runtime22.Fragment, { children: [
3661
+ isSidebarOpen && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
3460
3662
  "style",
3461
3663
  {
3462
3664
  dangerouslySetInnerHTML: {
@@ -3470,8 +3672,8 @@ function CopilotSidebarView({ header, width, ...props }) {
3470
3672
  }
3471
3673
  }
3472
3674
  ),
3473
- /* @__PURE__ */ jsxRuntime.jsx(CopilotChatToggleButton_default, {}),
3474
- /* @__PURE__ */ jsxRuntime.jsx(
3675
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(CopilotChatToggleButton_default, {}),
3676
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
3475
3677
  "aside",
3476
3678
  {
3477
3679
  ref: sidebarRef,
@@ -3496,15 +3698,19 @@ function CopilotSidebarView({ header, width, ...props }) {
3496
3698
  "aria-hidden": !isSidebarOpen,
3497
3699
  "aria-label": "Copilot chat sidebar",
3498
3700
  role: "complementary",
3499
- children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-full w-full flex-col overflow-hidden", children: [
3701
+ children: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "flex h-full w-full flex-col overflow-hidden", children: [
3500
3702
  headerElement,
3501
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 overflow-hidden", "data-sidebar-chat": true, children: /* @__PURE__ */ jsxRuntime.jsx(CopilotChatView_default, { ...props }) })
3703
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "flex-1 overflow-hidden", "data-sidebar-chat": true, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(CopilotChatView_default, { ...props }) })
3502
3704
  ] })
3503
3705
  }
3504
3706
  )
3505
3707
  ] });
3506
3708
  }
3507
3709
  CopilotSidebarView.displayName = "CopilotSidebarView";
3710
+
3711
+ // src/components/chat/CopilotPopupView.tsx
3712
+ var import_react27 = require("react");
3713
+ var import_jsx_runtime23 = require("react/jsx-runtime");
3508
3714
  var DEFAULT_POPUP_WIDTH = 420;
3509
3715
  var DEFAULT_POPUP_HEIGHT = 560;
3510
3716
  var dimensionToCss = (value, fallback) => {
@@ -3528,10 +3734,10 @@ function CopilotPopupView({
3528
3734
  const isPopupOpen = configuration?.isModalOpen ?? false;
3529
3735
  const setModalOpen = configuration?.setModalOpen;
3530
3736
  const labels = configuration?.labels ?? CopilotChatDefaultLabels;
3531
- const containerRef = React2.useRef(null);
3532
- const [isRendered, setIsRendered] = React2.useState(isPopupOpen);
3533
- const [isAnimatingOut, setIsAnimatingOut] = React2.useState(false);
3534
- React2.useEffect(() => {
3737
+ const containerRef = (0, import_react27.useRef)(null);
3738
+ const [isRendered, setIsRendered] = (0, import_react27.useState)(isPopupOpen);
3739
+ const [isAnimatingOut, setIsAnimatingOut] = (0, import_react27.useState)(false);
3740
+ (0, import_react27.useEffect)(() => {
3535
3741
  if (isPopupOpen) {
3536
3742
  setIsRendered(true);
3537
3743
  setIsAnimatingOut(false);
@@ -3547,7 +3753,7 @@ function CopilotPopupView({
3547
3753
  }, 200);
3548
3754
  return () => clearTimeout(timeout);
3549
3755
  }, [isPopupOpen, isRendered]);
3550
- React2.useEffect(() => {
3756
+ (0, import_react27.useEffect)(() => {
3551
3757
  if (!isPopupOpen) {
3552
3758
  return;
3553
3759
  }
@@ -3563,7 +3769,7 @@ function CopilotPopupView({
3563
3769
  window.addEventListener("keydown", handleKeyDown);
3564
3770
  return () => window.removeEventListener("keydown", handleKeyDown);
3565
3771
  }, [isPopupOpen, setModalOpen]);
3566
- React2.useEffect(() => {
3772
+ (0, import_react27.useEffect)(() => {
3567
3773
  if (!isPopupOpen) {
3568
3774
  return;
3569
3775
  }
@@ -3572,7 +3778,7 @@ function CopilotPopupView({
3572
3778
  }, 200);
3573
3779
  return () => clearTimeout(focusTimer);
3574
3780
  }, [isPopupOpen]);
3575
- React2.useEffect(() => {
3781
+ (0, import_react27.useEffect)(() => {
3576
3782
  if (!isPopupOpen || !clickOutsideToClose) {
3577
3783
  return;
3578
3784
  }
@@ -3597,10 +3803,10 @@ function CopilotPopupView({
3597
3803
  document.addEventListener("pointerdown", handlePointerDown);
3598
3804
  return () => document.removeEventListener("pointerdown", handlePointerDown);
3599
3805
  }, [isPopupOpen, clickOutsideToClose, setModalOpen]);
3600
- const headerElement = React2.useMemo(() => renderSlot(header, CopilotModalHeader, {}), [header]);
3806
+ const headerElement = (0, import_react27.useMemo)(() => renderSlot(header, CopilotModalHeader, {}), [header]);
3601
3807
  const resolvedWidth = dimensionToCss(width, DEFAULT_POPUP_WIDTH);
3602
3808
  const resolvedHeight = dimensionToCss(height, DEFAULT_POPUP_HEIGHT);
3603
- const popupStyle = React2.useMemo(
3809
+ const popupStyle = (0, import_react27.useMemo)(
3604
3810
  () => ({
3605
3811
  "--copilot-popup-width": resolvedWidth,
3606
3812
  "--copilot-popup-height": resolvedHeight,
@@ -3614,14 +3820,14 @@ function CopilotPopupView({
3614
3820
  [resolvedHeight, resolvedWidth]
3615
3821
  );
3616
3822
  const popupAnimationClass = isPopupOpen && !isAnimatingOut ? "pointer-events-auto translate-y-0 opacity-100 md:scale-100" : "pointer-events-none translate-y-4 opacity-0 md:translate-y-5 md:scale-[0.95]";
3617
- const popupContent = isRendered ? /* @__PURE__ */ jsxRuntime.jsx(
3823
+ const popupContent = isRendered ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
3618
3824
  "div",
3619
3825
  {
3620
3826
  className: cn(
3621
3827
  "fixed inset-0 z-[1200] flex max-w-full flex-col items-stretch",
3622
3828
  "md:inset-auto md:bottom-24 md:right-6 md:items-end md:gap-4"
3623
3829
  ),
3624
- children: /* @__PURE__ */ jsxRuntime.jsxs(
3830
+ children: /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
3625
3831
  "div",
3626
3832
  {
3627
3833
  ref: containerRef,
@@ -3642,7 +3848,7 @@ function CopilotPopupView({
3642
3848
  style: popupStyle,
3643
3849
  children: [
3644
3850
  headerElement,
3645
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 overflow-hidden", "data-popup-chat": true, children: /* @__PURE__ */ jsxRuntime.jsx(
3851
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "flex-1 overflow-hidden", "data-popup-chat": true, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
3646
3852
  CopilotChatView_default,
3647
3853
  {
3648
3854
  ...restProps,
@@ -3654,17 +3860,21 @@ function CopilotPopupView({
3654
3860
  )
3655
3861
  }
3656
3862
  ) : null;
3657
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3658
- /* @__PURE__ */ jsxRuntime.jsx(CopilotChatToggleButton_default, {}),
3863
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(import_jsx_runtime23.Fragment, { children: [
3864
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(CopilotChatToggleButton_default, {}),
3659
3865
  popupContent
3660
3866
  ] });
3661
3867
  }
3662
3868
  CopilotPopupView.displayName = "CopilotPopupView";
3869
+
3870
+ // src/components/chat/CopilotSidebar.tsx
3871
+ var import_react28 = require("react");
3872
+ var import_jsx_runtime24 = require("react/jsx-runtime");
3663
3873
  function CopilotSidebar({ header, defaultOpen, width, ...chatProps }) {
3664
- const SidebarViewOverride = React2.useMemo(() => {
3874
+ const SidebarViewOverride = (0, import_react28.useMemo)(() => {
3665
3875
  const Component = (viewProps) => {
3666
3876
  const { header: viewHeader, width: viewWidth, ...restProps } = viewProps;
3667
- return /* @__PURE__ */ jsxRuntime.jsx(
3877
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
3668
3878
  CopilotSidebarView,
3669
3879
  {
3670
3880
  ...restProps,
@@ -3675,7 +3885,7 @@ function CopilotSidebar({ header, defaultOpen, width, ...chatProps }) {
3675
3885
  };
3676
3886
  return Object.assign(Component, CopilotChatView_default);
3677
3887
  }, [header, width]);
3678
- return /* @__PURE__ */ jsxRuntime.jsx(
3888
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
3679
3889
  CopilotChat,
3680
3890
  {
3681
3891
  ...chatProps,
@@ -3685,6 +3895,10 @@ function CopilotSidebar({ header, defaultOpen, width, ...chatProps }) {
3685
3895
  );
3686
3896
  }
3687
3897
  CopilotSidebar.displayName = "CopilotSidebar";
3898
+
3899
+ // src/components/chat/CopilotPopup.tsx
3900
+ var import_react29 = require("react");
3901
+ var import_jsx_runtime25 = require("react/jsx-runtime");
3688
3902
  function CopilotPopup({
3689
3903
  header,
3690
3904
  defaultOpen,
@@ -3693,7 +3907,7 @@ function CopilotPopup({
3693
3907
  clickOutsideToClose,
3694
3908
  ...chatProps
3695
3909
  }) {
3696
- const PopupViewOverride = React2.useMemo(() => {
3910
+ const PopupViewOverride = (0, import_react29.useMemo)(() => {
3697
3911
  const Component = (viewProps) => {
3698
3912
  const {
3699
3913
  header: viewHeader,
@@ -3702,7 +3916,7 @@ function CopilotPopup({
3702
3916
  clickOutsideToClose: viewClickOutsideToClose,
3703
3917
  ...restProps
3704
3918
  } = viewProps;
3705
- return /* @__PURE__ */ jsxRuntime.jsx(
3919
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
3706
3920
  CopilotPopupView,
3707
3921
  {
3708
3922
  ...restProps,
@@ -3715,7 +3929,7 @@ function CopilotPopup({
3715
3929
  };
3716
3930
  return Object.assign(Component, CopilotChatView_default);
3717
3931
  }, [clickOutsideToClose, header, height, width]);
3718
- return /* @__PURE__ */ jsxRuntime.jsx(
3932
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
3719
3933
  CopilotChat,
3720
3934
  {
3721
3935
  ...chatProps,
@@ -3725,8 +3939,11 @@ function CopilotPopup({
3725
3939
  );
3726
3940
  }
3727
3941
  CopilotPopup.displayName = "CopilotPopup";
3942
+
3943
+ // src/types/defineToolCallRenderer.ts
3944
+ var import_zod2 = require("zod");
3728
3945
  function defineToolCallRenderer(def) {
3729
- const argsSchema = def.name === "*" && !def.args ? zod.z.any() : def.args;
3946
+ const argsSchema = def.name === "*" && !def.args ? import_zod2.z.any() : def.args;
3730
3947
  return {
3731
3948
  name: def.name,
3732
3949
  args: argsSchema,
@@ -3734,23 +3951,27 @@ function defineToolCallRenderer(def) {
3734
3951
  ...def.agentId ? { agentId: def.agentId } : {}
3735
3952
  };
3736
3953
  }
3954
+
3955
+ // src/components/WildcardToolCallRender.tsx
3956
+ var import_react30 = require("react");
3957
+ var import_jsx_runtime26 = require("react/jsx-runtime");
3737
3958
  var WildcardToolCallRender = defineToolCallRenderer({
3738
3959
  name: "*",
3739
3960
  render: ({ args, result, name, status }) => {
3740
- const [isExpanded, setIsExpanded] = React2.useState(false);
3961
+ const [isExpanded, setIsExpanded] = (0, import_react30.useState)(false);
3741
3962
  const statusString = String(status);
3742
3963
  const isActive = statusString === "inProgress" || statusString === "executing";
3743
3964
  const isComplete = statusString === "complete";
3744
3965
  const statusStyles = isActive ? "bg-amber-100 text-amber-800 dark:bg-amber-500/15 dark:text-amber-400" : isComplete ? "bg-emerald-100 text-emerald-800 dark:bg-emerald-500/15 dark:text-emerald-400" : "bg-zinc-100 text-zinc-800 dark:bg-zinc-700/40 dark:text-zinc-300";
3745
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-2 pb-2", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-xl border border-zinc-200/60 dark:border-zinc-800/60 bg-white/70 dark:bg-zinc-900/50 shadow-sm backdrop-blur p-4", children: [
3746
- /* @__PURE__ */ jsxRuntime.jsxs(
3966
+ return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "mt-2 pb-2", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "rounded-xl border border-zinc-200/60 dark:border-zinc-800/60 bg-white/70 dark:bg-zinc-900/50 shadow-sm backdrop-blur p-4", children: [
3967
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
3747
3968
  "div",
3748
3969
  {
3749
3970
  className: "flex items-center justify-between gap-3 cursor-pointer",
3750
3971
  onClick: () => setIsExpanded(!isExpanded),
3751
3972
  children: [
3752
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 min-w-0", children: [
3753
- /* @__PURE__ */ jsxRuntime.jsx(
3973
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "flex items-center gap-2 min-w-0", children: [
3974
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
3754
3975
  "svg",
3755
3976
  {
3756
3977
  className: `h-4 w-4 text-zinc-500 dark:text-zinc-400 transition-transform ${isExpanded ? "rotate-90" : ""}`,
@@ -3758,7 +3979,7 @@ var WildcardToolCallRender = defineToolCallRenderer({
3758
3979
  viewBox: "0 0 24 24",
3759
3980
  strokeWidth: 2,
3760
3981
  stroke: "currentColor",
3761
- children: /* @__PURE__ */ jsxRuntime.jsx(
3982
+ children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
3762
3983
  "path",
3763
3984
  {
3764
3985
  strokeLinecap: "round",
@@ -3768,10 +3989,10 @@ var WildcardToolCallRender = defineToolCallRenderer({
3768
3989
  )
3769
3990
  }
3770
3991
  ),
3771
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "inline-block h-2 w-2 rounded-full bg-blue-500" }),
3772
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate text-sm font-medium text-zinc-900 dark:text-zinc-100", children: name })
3992
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "inline-block h-2 w-2 rounded-full bg-blue-500" }),
3993
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "truncate text-sm font-medium text-zinc-900 dark:text-zinc-100", children: name })
3773
3994
  ] }),
3774
- /* @__PURE__ */ jsxRuntime.jsx(
3995
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
3775
3996
  "span",
3776
3997
  {
3777
3998
  className: `inline-flex items-center rounded-full px-2 py-1 text-xs font-medium ${statusStyles}`,
@@ -3781,55 +4002,58 @@ var WildcardToolCallRender = defineToolCallRenderer({
3781
4002
  ]
3782
4003
  }
3783
4004
  ),
3784
- isExpanded && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-3 grid gap-4", children: [
3785
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
3786
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-xs uppercase tracking-wide text-zinc-500 dark:text-zinc-400", children: "Arguments" }),
3787
- /* @__PURE__ */ jsxRuntime.jsx("pre", { className: "mt-2 max-h-64 overflow-auto rounded-md bg-zinc-50 dark:bg-zinc-800/60 p-3 text-xs leading-relaxed text-zinc-800 dark:text-zinc-200 whitespace-pre-wrap break-words", children: JSON.stringify(args ?? {}, null, 2) })
4005
+ isExpanded && /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "mt-3 grid gap-4", children: [
4006
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { children: [
4007
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "text-xs uppercase tracking-wide text-zinc-500 dark:text-zinc-400", children: "Arguments" }),
4008
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("pre", { className: "mt-2 max-h-64 overflow-auto rounded-md bg-zinc-50 dark:bg-zinc-800/60 p-3 text-xs leading-relaxed text-zinc-800 dark:text-zinc-200 whitespace-pre-wrap break-words", children: JSON.stringify(args ?? {}, null, 2) })
3788
4009
  ] }),
3789
- result !== void 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
3790
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-xs uppercase tracking-wide text-zinc-500 dark:text-zinc-400", children: "Result" }),
3791
- /* @__PURE__ */ jsxRuntime.jsx("pre", { className: "mt-2 max-h-64 overflow-auto rounded-md bg-zinc-50 dark:bg-zinc-800/60 p-3 text-xs leading-relaxed text-zinc-800 dark:text-zinc-200 whitespace-pre-wrap break-words", children: typeof result === "string" ? result : JSON.stringify(result, null, 2) })
4010
+ result !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { children: [
4011
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "text-xs uppercase tracking-wide text-zinc-500 dark:text-zinc-400", children: "Result" }),
4012
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("pre", { className: "mt-2 max-h-64 overflow-auto rounded-md bg-zinc-50 dark:bg-zinc-800/60 p-3 text-xs leading-relaxed text-zinc-800 dark:text-zinc-200 whitespace-pre-wrap break-words", children: typeof result === "string" ? result : JSON.stringify(result, null, 2) })
3792
4013
  ] })
3793
4014
  ] })
3794
4015
  ] }) });
3795
4016
  }
3796
4017
  });
3797
-
3798
- exports.AudioRecorderError = AudioRecorderError;
3799
- exports.CopilotChat = CopilotChat;
3800
- exports.CopilotChatAssistantMessage = CopilotChatAssistantMessage_default;
3801
- exports.CopilotChatAudioRecorder = CopilotChatAudioRecorder;
3802
- exports.CopilotChatConfigurationProvider = CopilotChatConfigurationProvider;
3803
- exports.CopilotChatInput = CopilotChatInput_default;
3804
- exports.CopilotChatMessageView = CopilotChatMessageView_default;
3805
- exports.CopilotChatSuggestionPill = CopilotChatSuggestionPill_default;
3806
- exports.CopilotChatSuggestionView = CopilotChatSuggestionView_default;
3807
- exports.CopilotChatToggleButton = CopilotChatToggleButton;
3808
- exports.CopilotChatToggleButtonCloseIcon = DefaultCloseIcon;
3809
- exports.CopilotChatToggleButtonOpenIcon = DefaultOpenIcon;
3810
- exports.CopilotChatToolCallsView = CopilotChatToolCallsView_default;
3811
- exports.CopilotChatUserMessage = CopilotChatUserMessage_default;
3812
- exports.CopilotChatView = CopilotChatView_default;
3813
- exports.CopilotKitCoreReact = CopilotKitCoreReact;
3814
- exports.CopilotKitInspector = CopilotKitInspector;
3815
- exports.CopilotKitProvider = CopilotKitProvider;
3816
- exports.CopilotModalHeader = CopilotModalHeader;
3817
- exports.CopilotPopup = CopilotPopup;
3818
- exports.CopilotPopupView = CopilotPopupView;
3819
- exports.CopilotSidebar = CopilotSidebar;
3820
- exports.CopilotSidebarView = CopilotSidebarView;
3821
- exports.WildcardToolCallRender = WildcardToolCallRender;
3822
- exports.defineToolCallRenderer = defineToolCallRenderer;
3823
- exports.useAgent = useAgent;
3824
- exports.useAgentContext = useAgentContext;
3825
- exports.useConfigureSuggestions = useConfigureSuggestions;
3826
- exports.useCopilotChatConfiguration = useCopilotChatConfiguration;
3827
- exports.useCopilotKit = useCopilotKit;
3828
- exports.useFrontendTool = useFrontendTool;
3829
- exports.useHumanInTheLoop = useHumanInTheLoop;
3830
- exports.useRenderActivityMessage = useRenderActivityMessage;
3831
- exports.useRenderCustomMessages = useRenderCustomMessages;
3832
- exports.useRenderToolCall = useRenderToolCall;
3833
- exports.useSuggestions = useSuggestions;
3834
- //# sourceMappingURL=index.js.map
4018
+ // Annotate the CommonJS export names for ESM import in node:
4019
+ 0 && (module.exports = {
4020
+ AudioRecorderError,
4021
+ CopilotChat,
4022
+ CopilotChatAssistantMessage,
4023
+ CopilotChatAudioRecorder,
4024
+ CopilotChatConfigurationProvider,
4025
+ CopilotChatInput,
4026
+ CopilotChatMessageView,
4027
+ CopilotChatSuggestionPill,
4028
+ CopilotChatSuggestionView,
4029
+ CopilotChatToggleButton,
4030
+ CopilotChatToggleButtonCloseIcon,
4031
+ CopilotChatToggleButtonOpenIcon,
4032
+ CopilotChatToolCallsView,
4033
+ CopilotChatUserMessage,
4034
+ CopilotChatView,
4035
+ CopilotKitCoreReact,
4036
+ CopilotKitInspector,
4037
+ CopilotKitProvider,
4038
+ CopilotModalHeader,
4039
+ CopilotPopup,
4040
+ CopilotPopupView,
4041
+ CopilotSidebar,
4042
+ CopilotSidebarView,
4043
+ WildcardToolCallRender,
4044
+ defineToolCallRenderer,
4045
+ useAgent,
4046
+ useAgentContext,
4047
+ useConfigureSuggestions,
4048
+ useCopilotChatConfiguration,
4049
+ useCopilotKit,
4050
+ useFrontendTool,
4051
+ useHumanInTheLoop,
4052
+ useRenderActivityMessage,
4053
+ useRenderCustomMessages,
4054
+ useRenderToolCall,
4055
+ useSuggestions,
4056
+ ...require("@ag-ui/core"),
4057
+ ...require("@ag-ui/client")
4058
+ });
3835
4059
  //# sourceMappingURL=index.js.map