@copilotkit/react-ui 1.51.2 → 1.51.3-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/{chunk-DI7DDMRS.mjs → chunk-4S4ZEKE6.mjs} +2 -2
  3. package/dist/{chunk-BVKKSSB2.mjs → chunk-HKZL4P3F.mjs} +4 -4
  4. package/dist/{chunk-VVCCMYGT.mjs → chunk-O4PPO3K3.mjs} +2 -2
  5. package/dist/{chunk-7OURDQZJ.mjs → chunk-PKSW6ZMQ.mjs} +2 -2
  6. package/dist/{chunk-IHFR6PYG.mjs → chunk-SLM2AOHF.mjs} +2 -2
  7. package/dist/{chunk-HIW7RXCD.mjs → chunk-UH5GQ7QF.mjs} +2 -2
  8. package/dist/{chunk-NCIAFFQ2.mjs → chunk-XEZ5ODJS.mjs} +2 -2
  9. package/dist/{chunk-JZ3RFQQ6.mjs → chunk-XOBQLKUU.mjs} +3 -13
  10. package/dist/chunk-XOBQLKUU.mjs.map +1 -0
  11. package/dist/{chunk-NSJWSIPR.mjs → chunk-YQOESY4Y.mjs} +4 -4
  12. package/dist/components/chat/Chat.js +57 -67
  13. package/dist/components/chat/Chat.js.map +1 -1
  14. package/dist/components/chat/Chat.mjs +6 -6
  15. package/dist/components/chat/Markdown.d.ts +4 -2
  16. package/dist/components/chat/Markdown.js +2 -12
  17. package/dist/components/chat/Markdown.js.map +1 -1
  18. package/dist/components/chat/Markdown.mjs +1 -1
  19. package/dist/components/chat/Messages.js +17 -27
  20. package/dist/components/chat/Messages.js.map +1 -1
  21. package/dist/components/chat/Messages.mjs +5 -5
  22. package/dist/components/chat/Modal.js +64 -74
  23. package/dist/components/chat/Modal.js.map +1 -1
  24. package/dist/components/chat/Modal.mjs +7 -7
  25. package/dist/components/chat/Popup.js +64 -74
  26. package/dist/components/chat/Popup.js.map +1 -1
  27. package/dist/components/chat/Popup.mjs +8 -8
  28. package/dist/components/chat/Sidebar.js +66 -76
  29. package/dist/components/chat/Sidebar.js.map +1 -1
  30. package/dist/components/chat/Sidebar.mjs +8 -8
  31. package/dist/components/chat/index.d.ts +1 -1
  32. package/dist/components/chat/index.js +66 -76
  33. package/dist/components/chat/index.js.map +1 -1
  34. package/dist/components/chat/index.mjs +9 -9
  35. package/dist/components/chat/messages/AssistantMessage.js +4 -14
  36. package/dist/components/chat/messages/AssistantMessage.js.map +1 -1
  37. package/dist/components/chat/messages/AssistantMessage.mjs +2 -2
  38. package/dist/components/chat/messages/ErrorMessage.js +4 -14
  39. package/dist/components/chat/messages/ErrorMessage.js.map +1 -1
  40. package/dist/components/chat/messages/ErrorMessage.mjs +1 -1
  41. package/dist/components/chat/messages/LegacyRenderMessage.js +6 -16
  42. package/dist/components/chat/messages/LegacyRenderMessage.js.map +1 -1
  43. package/dist/components/chat/messages/LegacyRenderMessage.mjs +4 -4
  44. package/dist/components/chat/messages/RenderMessage.js +6 -16
  45. package/dist/components/chat/messages/RenderMessage.js.map +1 -1
  46. package/dist/components/chat/messages/RenderMessage.mjs +3 -3
  47. package/dist/components/index.d.ts +1 -1
  48. package/dist/components/index.js +66 -76
  49. package/dist/components/index.js.map +1 -1
  50. package/dist/components/index.mjs +9 -9
  51. package/dist/index.d.ts +1 -1
  52. package/dist/index.js +66 -76
  53. package/dist/index.js.map +1 -1
  54. package/dist/index.mjs +9 -9
  55. package/package.json +5 -8
  56. package/src/components/chat/Markdown.tsx +8 -17
  57. package/dist/chunk-JZ3RFQQ6.mjs.map +0 -1
  58. /package/dist/{chunk-DI7DDMRS.mjs.map → chunk-4S4ZEKE6.mjs.map} +0 -0
  59. /package/dist/{chunk-BVKKSSB2.mjs.map → chunk-HKZL4P3F.mjs.map} +0 -0
  60. /package/dist/{chunk-VVCCMYGT.mjs.map → chunk-O4PPO3K3.mjs.map} +0 -0
  61. /package/dist/{chunk-7OURDQZJ.mjs.map → chunk-PKSW6ZMQ.mjs.map} +0 -0
  62. /package/dist/{chunk-IHFR6PYG.mjs.map → chunk-SLM2AOHF.mjs.map} +0 -0
  63. /package/dist/{chunk-HIW7RXCD.mjs.map → chunk-UH5GQ7QF.mjs.map} +0 -0
  64. /package/dist/{chunk-NCIAFFQ2.mjs.map → chunk-XEZ5ODJS.mjs.map} +0 -0
  65. /package/dist/{chunk-NSJWSIPR.mjs.map → chunk-YQOESY4Y.mjs.map} +0 -0
@@ -3,11 +3,11 @@ import "../chunk-SC6JRFAJ.mjs";
3
3
  import "../chunk-WB3YULQ4.mjs";
4
4
  import {
5
5
  CopilotPopup
6
- } from "../chunk-VVCCMYGT.mjs";
6
+ } from "../chunk-O4PPO3K3.mjs";
7
7
  import {
8
8
  CopilotSidebar
9
- } from "../chunk-DI7DDMRS.mjs";
10
- import "../chunk-BVKKSSB2.mjs";
9
+ } from "../chunk-4S4ZEKE6.mjs";
10
+ import "../chunk-HKZL4P3F.mjs";
11
11
  import "../chunk-C3GSYRC3.mjs";
12
12
  import "../chunk-GDSZGYCE.mjs";
13
13
  import "../chunk-V7W6IM2V.mjs";
@@ -24,7 +24,7 @@ import "../chunk-BH6PCAAL.mjs";
24
24
  import "../chunk-UFN2VWSR.mjs";
25
25
  import {
26
26
  CopilotChat
27
- } from "../chunk-NSJWSIPR.mjs";
27
+ } from "../chunk-YQOESY4Y.mjs";
28
28
  import {
29
29
  Suggestions
30
30
  } from "../chunk-VHKHX7GV.mjs";
@@ -35,12 +35,12 @@ import "../chunk-PLHTVHUW.mjs";
35
35
  import "../chunk-3W6J75HS.mjs";
36
36
  import "../chunk-ELGRNEAO.mjs";
37
37
  import "../chunk-QIOJXTIQ.mjs";
38
- import "../chunk-HIW7RXCD.mjs";
39
- import "../chunk-7OURDQZJ.mjs";
40
- import "../chunk-NCIAFFQ2.mjs";
38
+ import "../chunk-UH5GQ7QF.mjs";
39
+ import "../chunk-PKSW6ZMQ.mjs";
40
+ import "../chunk-XEZ5ODJS.mjs";
41
41
  import {
42
42
  AssistantMessage
43
- } from "../chunk-IHFR6PYG.mjs";
43
+ } from "../chunk-SLM2AOHF.mjs";
44
44
  import {
45
45
  ImageRenderer
46
46
  } from "../chunk-DBKRAOH7.mjs";
@@ -49,7 +49,7 @@ import {
49
49
  } from "../chunk-RYUCX3ZK.mjs";
50
50
  import {
51
51
  Markdown
52
- } from "../chunk-JZ3RFQQ6.mjs";
52
+ } from "../chunk-XOBQLKUU.mjs";
53
53
  import "../chunk-IK2BPURM.mjs";
54
54
  import {
55
55
  useChatContext
package/dist/index.d.ts CHANGED
@@ -18,4 +18,4 @@ import '@copilotkit/shared';
18
18
  import 'react';
19
19
  import 'react/jsx-runtime';
20
20
  import './components/chat/Modal.js';
21
- import 'react-markdown';
21
+ import 'streamdown';
package/dist/index.js CHANGED
@@ -97,7 +97,7 @@ __export(src_exports, {
97
97
  module.exports = __toCommonJS(src_exports);
98
98
 
99
99
  // src/components/chat/Modal.tsx
100
- var import_react16 = __toESM(require("react"));
100
+ var import_react15 = __toESM(require("react"));
101
101
 
102
102
  // src/components/chat/ChatContext.tsx
103
103
  var import_react = __toESM(require("react"));
@@ -1038,7 +1038,7 @@ var Header = ({}) => {
1038
1038
  };
1039
1039
 
1040
1040
  // src/components/chat/Messages.tsx
1041
- var import_react10 = require("react");
1041
+ var import_react9 = require("react");
1042
1042
  var import_react_core5 = require("@copilotkit/react-core");
1043
1043
 
1044
1044
  // src/components/chat/messages/UserMessage.tsx
@@ -1070,8 +1070,7 @@ var UserMessage = (props) => {
1070
1070
  };
1071
1071
 
1072
1072
  // src/components/chat/Markdown.tsx
1073
- var import_react7 = require("react");
1074
- var import_react_markdown = __toESM(require("react-markdown"));
1073
+ var import_streamdown = require("streamdown");
1075
1074
 
1076
1075
  // src/components/chat/CodeBlock.tsx
1077
1076
  var import_react6 = require("react");
@@ -1483,9 +1482,6 @@ var highlightStyle = {
1483
1482
  };
1484
1483
 
1485
1484
  // src/components/chat/Markdown.tsx
1486
- var import_remark_gfm = __toESM(require("remark-gfm"));
1487
- var import_remark_math = __toESM(require("remark-math"));
1488
- var import_rehype_raw = __toESM(require("rehype-raw"));
1489
1485
  var import_jsx_runtime12 = require("react/jsx-runtime");
1490
1486
  var defaultComponents = {
1491
1487
  a(_a) {
@@ -1579,24 +1575,18 @@ var defaultComponents = {
1579
1575
  return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("li", __spreadProps(__spreadValues({ className: "copilotKitMarkdownElement" }, props), { children }));
1580
1576
  }
1581
1577
  };
1582
- var MemoizedReactMarkdown = (0, import_react7.memo)(
1583
- import_react_markdown.default,
1584
- (prevProps, nextProps) => prevProps.children === nextProps.children && prevProps.components === nextProps.components
1585
- );
1586
1578
  var Markdown = ({ content, components }) => {
1587
1579
  return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "copilotKitMarkdown", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1588
- MemoizedReactMarkdown,
1580
+ import_streamdown.Streamdown,
1589
1581
  {
1590
1582
  components: __spreadValues(__spreadValues({}, defaultComponents), components),
1591
- remarkPlugins: [import_remark_gfm.default, [import_remark_math.default, { singleDollarTextMath: false }]],
1592
- rehypePlugins: [import_rehype_raw.default],
1593
1583
  children: content
1594
1584
  }
1595
1585
  ) });
1596
1586
  };
1597
1587
 
1598
1588
  // src/components/chat/messages/AssistantMessage.tsx
1599
- var import_react8 = require("react");
1589
+ var import_react7 = require("react");
1600
1590
  var import_jsx_runtime13 = require("react/jsx-runtime");
1601
1591
  var AssistantMessage = (props) => {
1602
1592
  var _a;
@@ -1612,7 +1602,7 @@ var AssistantMessage = (props) => {
1612
1602
  feedback,
1613
1603
  markdownTagRenderers
1614
1604
  } = props;
1615
- const [copied, setCopied] = (0, import_react8.useState)(false);
1605
+ const [copied, setCopied] = (0, import_react7.useState)(false);
1616
1606
  const handleCopy = () => {
1617
1607
  const content2 = (message == null ? void 0 : message.content) || "";
1618
1608
  if (content2 && onCopy) {
@@ -1701,10 +1691,10 @@ var AssistantMessage = (props) => {
1701
1691
  };
1702
1692
 
1703
1693
  // src/components/chat/messages/ImageRenderer.tsx
1704
- var import_react9 = require("react");
1694
+ var import_react8 = require("react");
1705
1695
  var import_jsx_runtime14 = require("react/jsx-runtime");
1706
1696
  var ImageRenderer = ({ image, content, className = "" }) => {
1707
- const [imageError, setImageError] = (0, import_react9.useState)(false);
1697
+ const [imageError, setImageError] = (0, import_react8.useState)(false);
1708
1698
  const imageSrc = `data:image/${image.format};base64,${image.bytes}`;
1709
1699
  const altText = content || "User uploaded image";
1710
1700
  const handleImageError = () => {
@@ -1947,18 +1937,18 @@ var Messages = ({
1947
1937
  var _a;
1948
1938
  const { labels, icons } = useChatContext();
1949
1939
  const { messages: visibleMessages, interrupt } = (0, import_react_core5.useCopilotChatInternal)();
1950
- const initialMessages = (0, import_react10.useMemo)(() => makeInitialMessages(labels.initial), [labels.initial]);
1940
+ const initialMessages = (0, import_react9.useMemo)(() => makeInitialMessages(labels.initial), [labels.initial]);
1951
1941
  const messages = [...initialMessages, ...visibleMessages];
1952
1942
  const { messagesContainerRef, messagesEndRef } = useScrollToBottom(messages);
1953
1943
  const hasLegacyProps = !!(RenderTextMessage || RenderActionExecutionMessage || RenderAgentStateMessage || RenderResultMessage || RenderImageMessage);
1954
- (0, import_react10.useEffect)(() => {
1944
+ (0, import_react9.useEffect)(() => {
1955
1945
  if (hasLegacyProps) {
1956
1946
  console.warn(
1957
1947
  "[CopilotKit] Legacy message render props (RenderTextMessage, RenderActionExecutionMessage, etc.) are deprecated. Please use the unified 'RenderMessage' prop instead. See migration guide: https://docs.copilotkit.ai/migration/render-message"
1958
1948
  );
1959
1949
  }
1960
1950
  }, [hasLegacyProps]);
1961
- const legacyProps = (0, import_react10.useMemo)(
1951
+ const legacyProps = (0, import_react9.useMemo)(
1962
1952
  () => ({
1963
1953
  RenderTextMessage,
1964
1954
  RenderActionExecutionMessage,
@@ -2029,10 +2019,10 @@ function makeInitialMessages(initial) {
2029
2019
  ];
2030
2020
  }
2031
2021
  function useScrollToBottom(messages) {
2032
- const messagesEndRef = (0, import_react10.useRef)(null);
2033
- const messagesContainerRef = (0, import_react10.useRef)(null);
2034
- const isProgrammaticScrollRef = (0, import_react10.useRef)(false);
2035
- const isUserScrollUpRef = (0, import_react10.useRef)(false);
2022
+ const messagesEndRef = (0, import_react9.useRef)(null);
2023
+ const messagesContainerRef = (0, import_react9.useRef)(null);
2024
+ const isProgrammaticScrollRef = (0, import_react9.useRef)(false);
2025
+ const isUserScrollUpRef = (0, import_react9.useRef)(false);
2036
2026
  const scrollToBottom = () => {
2037
2027
  if (messagesContainerRef.current && messagesEndRef.current) {
2038
2028
  isProgrammaticScrollRef.current = true;
@@ -2049,7 +2039,7 @@ function useScrollToBottom(messages) {
2049
2039
  isUserScrollUpRef.current = scrollTop + clientHeight < scrollHeight;
2050
2040
  }
2051
2041
  };
2052
- (0, import_react10.useEffect)(() => {
2042
+ (0, import_react9.useEffect)(() => {
2053
2043
  const container = messagesContainerRef.current;
2054
2044
  if (container) {
2055
2045
  container.addEventListener("scroll", handleScroll);
@@ -2060,7 +2050,7 @@ function useScrollToBottom(messages) {
2060
2050
  }
2061
2051
  };
2062
2052
  }, []);
2063
- (0, import_react10.useEffect)(() => {
2053
+ (0, import_react9.useEffect)(() => {
2064
2054
  const container = messagesContainerRef.current;
2065
2055
  if (!container) {
2066
2056
  return;
@@ -2079,7 +2069,7 @@ function useScrollToBottom(messages) {
2079
2069
  mutationObserver.disconnect();
2080
2070
  };
2081
2071
  }, []);
2082
- (0, import_react10.useEffect)(() => {
2072
+ (0, import_react9.useEffect)(() => {
2083
2073
  isUserScrollUpRef.current = false;
2084
2074
  scrollToBottom();
2085
2075
  }, [messages.filter((m) => m.role === "user").length]);
@@ -2087,12 +2077,12 @@ function useScrollToBottom(messages) {
2087
2077
  }
2088
2078
 
2089
2079
  // src/components/chat/Input.tsx
2090
- var import_react14 = require("react");
2080
+ var import_react13 = require("react");
2091
2081
 
2092
2082
  // src/components/chat/Textarea.tsx
2093
- var import_react11 = require("react");
2083
+ var import_react10 = require("react");
2094
2084
  var import_jsx_runtime18 = require("react/jsx-runtime");
2095
- var AutoResizingTextarea = (0, import_react11.forwardRef)(
2085
+ var AutoResizingTextarea = (0, import_react10.forwardRef)(
2096
2086
  ({
2097
2087
  maxRows = 1,
2098
2088
  placeholder,
@@ -2103,10 +2093,10 @@ var AutoResizingTextarea = (0, import_react11.forwardRef)(
2103
2093
  onCompositionEnd,
2104
2094
  autoFocus
2105
2095
  }, ref) => {
2106
- const internalTextareaRef = (0, import_react11.useRef)(null);
2107
- const [maxHeight, setMaxHeight] = (0, import_react11.useState)(0);
2108
- (0, import_react11.useImperativeHandle)(ref, () => internalTextareaRef.current);
2109
- (0, import_react11.useEffect)(() => {
2096
+ const internalTextareaRef = (0, import_react10.useRef)(null);
2097
+ const [maxHeight, setMaxHeight] = (0, import_react10.useState)(0);
2098
+ (0, import_react10.useImperativeHandle)(ref, () => internalTextareaRef.current);
2099
+ (0, import_react10.useEffect)(() => {
2110
2100
  const calculateMaxHeight = () => {
2111
2101
  const textarea = internalTextareaRef.current;
2112
2102
  if (textarea) {
@@ -2120,7 +2110,7 @@ var AutoResizingTextarea = (0, import_react11.forwardRef)(
2120
2110
  };
2121
2111
  calculateMaxHeight();
2122
2112
  }, [maxRows]);
2123
- (0, import_react11.useEffect)(() => {
2113
+ (0, import_react10.useEffect)(() => {
2124
2114
  const textarea = internalTextareaRef.current;
2125
2115
  if (textarea) {
2126
2116
  textarea.style.height = "auto";
@@ -2152,7 +2142,7 @@ var Textarea_default = AutoResizingTextarea;
2152
2142
  // src/hooks/use-push-to-talk.tsx
2153
2143
  var import_react_core6 = require("@copilotkit/react-core");
2154
2144
  var import_runtime_client_gql2 = require("@copilotkit/runtime-client-gql");
2155
- var import_react12 = require("react");
2145
+ var import_react11 = require("react");
2156
2146
  var startRecording = (mediaStreamRef, mediaRecorderRef, audioContextRef, recordedChunks, onStop) => __async(void 0, null, function* () {
2157
2147
  if (!mediaStreamRef.current || !audioContextRef.current) {
2158
2148
  mediaStreamRef.current = yield navigator.mediaDevices.getUserMedia({ audio: true });
@@ -2201,16 +2191,16 @@ var usePushToTalk = ({
2201
2191
  sendFunction,
2202
2192
  inProgress
2203
2193
  }) => {
2204
- const [pushToTalkState, setPushToTalkState] = (0, import_react12.useState)("idle");
2205
- const mediaStreamRef = (0, import_react12.useRef)(null);
2206
- const audioContextRef = (0, import_react12.useRef)(null);
2207
- const mediaRecorderRef = (0, import_react12.useRef)(null);
2208
- const recordedChunks = (0, import_react12.useRef)([]);
2194
+ const [pushToTalkState, setPushToTalkState] = (0, import_react11.useState)("idle");
2195
+ const mediaStreamRef = (0, import_react11.useRef)(null);
2196
+ const audioContextRef = (0, import_react11.useRef)(null);
2197
+ const mediaRecorderRef = (0, import_react11.useRef)(null);
2198
+ const recordedChunks = (0, import_react11.useRef)([]);
2209
2199
  const generalContext = (0, import_react_core6.useCopilotContext)();
2210
2200
  const messagesContext = (0, import_react_core6.useCopilotMessagesContext)();
2211
2201
  const context = __spreadValues(__spreadValues({}, generalContext), messagesContext);
2212
- const [startReadingFromMessageId, setStartReadingFromMessageId] = (0, import_react12.useState)(null);
2213
- (0, import_react12.useEffect)(() => {
2202
+ const [startReadingFromMessageId, setStartReadingFromMessageId] = (0, import_react11.useState)(null);
2203
+ (0, import_react11.useEffect)(() => {
2214
2204
  if (pushToTalkState === "recording") {
2215
2205
  startRecording(
2216
2206
  mediaStreamRef,
@@ -2238,7 +2228,7 @@ var usePushToTalk = ({
2238
2228
  stopRecording(mediaRecorderRef);
2239
2229
  };
2240
2230
  }, [pushToTalkState]);
2241
- (0, import_react12.useEffect)(() => {
2231
+ (0, import_react11.useEffect)(() => {
2242
2232
  if (inProgress === false && startReadingFromMessageId) {
2243
2233
  const lastMessageIndex = context.messages.findIndex(
2244
2234
  (message) => message.id === startReadingFromMessageId
@@ -2257,7 +2247,7 @@ var usePushToTalk = ({
2257
2247
  var import_react_core7 = require("@copilotkit/react-core");
2258
2248
 
2259
2249
  // src/components/chat/PoweredByTag.tsx
2260
- var import_react13 = require("react");
2250
+ var import_react12 = require("react");
2261
2251
 
2262
2252
  // src/hooks/use-dark-mode.ts
2263
2253
  var useDarkMode = () => {
@@ -2269,9 +2259,9 @@ var useDarkMode = () => {
2269
2259
  // src/components/chat/PoweredByTag.tsx
2270
2260
  var import_jsx_runtime19 = require("react/jsx-runtime");
2271
2261
  function PoweredByTag({ showPoweredBy = true }) {
2272
- const [mounted, setMounted] = (0, import_react13.useState)(false);
2262
+ const [mounted, setMounted] = (0, import_react12.useState)(false);
2273
2263
  const isDark = useDarkMode();
2274
- (0, import_react13.useEffect)(() => {
2264
+ (0, import_react12.useEffect)(() => {
2275
2265
  setMounted(true);
2276
2266
  }, []);
2277
2267
  if (!showPoweredBy) {
@@ -2305,8 +2295,8 @@ var Input = ({
2305
2295
  const copilotContext = (0, import_react_core7.useCopilotContext)();
2306
2296
  const showPoweredBy = !((_a = copilotContext.copilotApiConfig) == null ? void 0 : _a.publicApiKey);
2307
2297
  const pushToTalkConfigured = copilotContext.copilotApiConfig.textToSpeechUrl !== void 0 && copilotContext.copilotApiConfig.transcribeAudioUrl !== void 0;
2308
- const textareaRef = (0, import_react14.useRef)(null);
2309
- const [isComposing, setIsComposing] = (0, import_react14.useState)(false);
2298
+ const textareaRef = (0, import_react13.useRef)(null);
2299
+ const [isComposing, setIsComposing] = (0, import_react13.useState)(false);
2310
2300
  const handleDivClick = (event) => {
2311
2301
  var _a2;
2312
2302
  const target = event.target;
@@ -2316,7 +2306,7 @@ var Input = ({
2316
2306
  return;
2317
2307
  (_a2 = textareaRef.current) == null ? void 0 : _a2.focus();
2318
2308
  };
2319
- const [text, setText] = (0, import_react14.useState)("");
2309
+ const [text, setText] = (0, import_react13.useState)("");
2320
2310
  const send = () => {
2321
2311
  var _a2;
2322
2312
  if (inProgress)
@@ -2330,17 +2320,17 @@ var Input = ({
2330
2320
  inProgress
2331
2321
  });
2332
2322
  const isInProgress = inProgress || pushToTalkState === "transcribing";
2333
- const { buttonIcon, buttonAlt } = (0, import_react14.useMemo)(() => {
2323
+ const { buttonIcon, buttonAlt } = (0, import_react13.useMemo)(() => {
2334
2324
  if (!chatReady)
2335
2325
  return { buttonIcon: context.icons.spinnerIcon, buttonAlt: "Loading" };
2336
2326
  return isInProgress && !hideStopButton && chatReady ? { buttonIcon: context.icons.stopIcon, buttonAlt: "Stop" } : { buttonIcon: context.icons.sendIcon, buttonAlt: "Send" };
2337
2327
  }, [isInProgress, chatReady, hideStopButton, context.icons.stopIcon, context.icons.sendIcon]);
2338
2328
  const showPushToTalk = pushToTalkConfigured && (pushToTalkState === "idle" || pushToTalkState === "recording") && !inProgress;
2339
2329
  const { interrupt } = (0, import_react_core7.useCopilotChatInternal)();
2340
- const canSend = (0, import_react14.useMemo)(() => {
2330
+ const canSend = (0, import_react13.useMemo)(() => {
2341
2331
  return !isInProgress && text.trim().length > 0 && pushToTalkState === "idle" && !interrupt;
2342
2332
  }, [interrupt, isInProgress, text, pushToTalkState]);
2343
- const canStop = (0, import_react14.useMemo)(() => {
2333
+ const canStop = (0, import_react13.useMemo)(() => {
2344
2334
  return isInProgress && !hideStopButton;
2345
2335
  }, [isInProgress, hideStopButton]);
2346
2336
  const sendDisabled = !canSend && !canStop;
@@ -2397,7 +2387,7 @@ var Input = ({
2397
2387
  };
2398
2388
 
2399
2389
  // src/components/chat/Chat.tsx
2400
- var import_react15 = __toESM(require("react"));
2390
+ var import_react14 = __toESM(require("react"));
2401
2391
  var import_react_core9 = require("@copilotkit/react-core");
2402
2392
  var import_shared3 = require("@copilotkit/shared");
2403
2393
 
@@ -2574,13 +2564,13 @@ function CopilotChat({
2574
2564
  removeInternalErrorHandler
2575
2565
  } = (0, import_react_core9.useCopilotContext)();
2576
2566
  const { publicApiKey, chatApiEndpoint } = copilotApiConfig;
2577
- const [selectedImages, setSelectedImages] = (0, import_react15.useState)([]);
2578
- const [chatError, setChatError] = (0, import_react15.useState)(null);
2579
- const [messageFeedback, setMessageFeedback] = (0, import_react15.useState)(
2567
+ const [selectedImages, setSelectedImages] = (0, import_react14.useState)([]);
2568
+ const [chatError, setChatError] = (0, import_react14.useState)(null);
2569
+ const [messageFeedback, setMessageFeedback] = (0, import_react14.useState)(
2580
2570
  {}
2581
2571
  );
2582
- const fileInputRef = (0, import_react15.useRef)(null);
2583
- const triggerObservabilityHook = (0, import_react15.useCallback)(
2572
+ const fileInputRef = (0, import_react14.useRef)(null);
2573
+ const triggerObservabilityHook = (0, import_react14.useCallback)(
2584
2574
  (hookName, ...args) => {
2585
2575
  if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks[hookName])) {
2586
2576
  observabilityHooks[hookName](...args);
@@ -2599,7 +2589,7 @@ function CopilotChat({
2599
2589
  },
2600
2590
  [publicApiKey, observabilityHooks, setBannerError]
2601
2591
  );
2602
- const triggerChatError = (0, import_react15.useCallback)(
2592
+ const triggerChatError = (0, import_react14.useCallback)(
2603
2593
  (error, operation, originalError) => {
2604
2594
  const errorMessage = (error == null ? void 0 : error.message) || (error == null ? void 0 : error.toString()) || "An error occurred";
2605
2595
  setChatError({
@@ -2645,7 +2635,7 @@ function CopilotChat({
2645
2635
  },
2646
2636
  [publicApiKey, chatApiEndpoint, observabilityHooks, setBannerError]
2647
2637
  );
2648
- (0, import_react15.useEffect)(() => {
2638
+ (0, import_react14.useEffect)(() => {
2649
2639
  const id = "chat-component";
2650
2640
  setInternalErrorHandler({
2651
2641
  [id]: (error) => {
@@ -2658,7 +2648,7 @@ function CopilotChat({
2658
2648
  removeInternalErrorHandler == null ? void 0 : removeInternalErrorHandler(id);
2659
2649
  };
2660
2650
  }, [triggerChatError, setInternalErrorHandler, removeInternalErrorHandler]);
2661
- (0, import_react15.useEffect)(() => {
2651
+ (0, import_react14.useEffect)(() => {
2662
2652
  if (!imageUploadsEnabled)
2663
2653
  return;
2664
2654
  const handlePaste = (e) => __async(this, null, function* () {
@@ -2704,7 +2694,7 @@ function CopilotChat({
2704
2694
  document.addEventListener("paste", handlePaste);
2705
2695
  return () => document.removeEventListener("paste", handlePaste);
2706
2696
  }, [imageUploadsEnabled, triggerChatError]);
2707
- (0, import_react15.useEffect)(() => {
2697
+ (0, import_react14.useEffect)(() => {
2708
2698
  if (!(additionalInstructions == null ? void 0 : additionalInstructions.length)) {
2709
2699
  setChatInstructions(instructions || "");
2710
2700
  return;
@@ -2732,8 +2722,8 @@ function CopilotChat({
2732
2722
  onStopGeneration,
2733
2723
  onReloadMessages
2734
2724
  });
2735
- const prevIsLoading = (0, import_react15.useRef)(isLoading);
2736
- (0, import_react15.useEffect)(() => {
2725
+ const prevIsLoading = (0, import_react14.useRef)(isLoading);
2726
+ (0, import_react14.useEffect)(() => {
2737
2727
  if (prevIsLoading.current !== isLoading) {
2738
2728
  if (isLoading) {
2739
2729
  triggerObservabilityHook("onChatStarted");
@@ -2756,7 +2746,7 @@ function CopilotChat({
2756
2746
  role: "user"
2757
2747
  });
2758
2748
  };
2759
- const chatContext = import_react15.default.useContext(ChatContext);
2749
+ const chatContext = import_react14.default.useContext(ChatContext);
2760
2750
  const isVisible = chatContext ? chatContext.open : true;
2761
2751
  const handleRegenerate = (messageId) => {
2762
2752
  if (onRegenerate) {
@@ -2900,7 +2890,7 @@ function WrappedCopilotChat({
2900
2890
  labels,
2901
2891
  className
2902
2892
  }) {
2903
- const chatContext = import_react15.default.useContext(ChatContext);
2893
+ const chatContext = import_react14.default.useContext(ChatContext);
2904
2894
  if (!chatContext) {
2905
2895
  return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ChatContextProvider, { icons, labels, open: true, setOpen: () => {
2906
2896
  }, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: `copilotKitChat ${className != null ? className : ""}`, children }) });
@@ -2938,7 +2928,7 @@ var CopilotModalInner = (_a) => {
2938
2928
  ]);
2939
2929
  const { copilotApiConfig, setBannerError } = (0, import_react_core10.useCopilotContext)();
2940
2930
  const { publicApiKey } = copilotApiConfig;
2941
- const triggerObservabilityHook = (0, import_react16.useCallback)(
2931
+ const triggerObservabilityHook = (0, import_react15.useCallback)(
2942
2932
  (hookName, ...args) => {
2943
2933
  if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks[hookName])) {
2944
2934
  observabilityHooks[hookName](...args);
@@ -2958,8 +2948,8 @@ var CopilotModalInner = (_a) => {
2958
2948
  [publicApiKey, observabilityHooks, setBannerError]
2959
2949
  );
2960
2950
  const { open } = useChatContext();
2961
- const prevOpen = (0, import_react16.useRef)(open);
2962
- (0, import_react16.useEffect)(() => {
2951
+ const prevOpen = (0, import_react15.useRef)(open);
2952
+ (0, import_react15.useEffect)(() => {
2963
2953
  if (prevOpen.current !== open) {
2964
2954
  onSetOpen == null ? void 0 : onSetOpen(open);
2965
2955
  if (open) {
@@ -2970,8 +2960,8 @@ var CopilotModalInner = (_a) => {
2970
2960
  prevOpen.current = open;
2971
2961
  }
2972
2962
  }, [open, onSetOpen, triggerObservabilityHook]);
2973
- const memoizedHeader = (0, import_react16.useMemo)(() => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Header2, {}), [Header2]);
2974
- const memoizedChildren = (0, import_react16.useMemo)(() => children, [children]);
2963
+ const memoizedHeader = (0, import_react15.useMemo)(() => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Header2, {}), [Header2]);
2964
+ const memoizedChildren = (0, import_react15.useMemo)(() => children, [children]);
2975
2965
  return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_jsx_runtime25.Fragment, { children: [
2976
2966
  memoizedChildren,
2977
2967
  /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className, children: [
@@ -3051,7 +3041,7 @@ var CopilotModal = (_a) => {
3051
3041
  "children",
3052
3042
  "observabilityHooks"
3053
3043
  ]);
3054
- const [openState, setOpenState] = import_react16.default.useState(defaultOpen);
3044
+ const [openState, setOpenState] = import_react15.default.useState(defaultOpen);
3055
3045
  return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ChatContextProvider, { icons, labels, open: openState, setOpen: setOpenState, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
3056
3046
  CopilotModalInner,
3057
3047
  __spreadProps(__spreadValues({
@@ -3095,13 +3085,13 @@ function CopilotPopup(props) {
3095
3085
  }
3096
3086
 
3097
3087
  // src/components/chat/Sidebar.tsx
3098
- var import_react17 = require("react");
3088
+ var import_react16 = require("react");
3099
3089
  var import_jsx_runtime27 = require("react/jsx-runtime");
3100
3090
  function CopilotSidebar(props) {
3101
3091
  props = __spreadProps(__spreadValues({}, props), {
3102
3092
  className: props.className ? props.className + " copilotKitSidebar" : "copilotKitSidebar"
3103
3093
  });
3104
- const [expandedClassName, setExpandedClassName] = (0, import_react17.useState)(
3094
+ const [expandedClassName, setExpandedClassName] = (0, import_react16.useState)(
3105
3095
  props.defaultOpen ? "sidebarExpanded" : ""
3106
3096
  );
3107
3097
  const onSetOpen = (open) => {