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

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 +20 -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
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  CopilotModal
3
- } from "../../chunk-BVKKSSB2.mjs";
3
+ } from "../../chunk-HKZL4P3F.mjs";
4
4
  import "../../chunk-C3GSYRC3.mjs";
5
5
  import "../../chunk-GDSZGYCE.mjs";
6
6
  import "../../chunk-V7W6IM2V.mjs";
@@ -11,20 +11,20 @@ import "../../chunk-KXE2JCUH.mjs";
11
11
  import "../../chunk-NRA3CFEE.mjs";
12
12
  import "../../chunk-BH6PCAAL.mjs";
13
13
  import "../../chunk-UFN2VWSR.mjs";
14
- import "../../chunk-NSJWSIPR.mjs";
14
+ import "../../chunk-YQOESY4Y.mjs";
15
15
  import "../../chunk-VHKHX7GV.mjs";
16
16
  import "../../chunk-6TWQUA2Q.mjs";
17
17
  import "../../chunk-PLHTVHUW.mjs";
18
18
  import "../../chunk-3W6J75HS.mjs";
19
19
  import "../../chunk-ELGRNEAO.mjs";
20
20
  import "../../chunk-QIOJXTIQ.mjs";
21
- import "../../chunk-HIW7RXCD.mjs";
22
- import "../../chunk-7OURDQZJ.mjs";
23
- import "../../chunk-NCIAFFQ2.mjs";
24
- import "../../chunk-IHFR6PYG.mjs";
21
+ import "../../chunk-UH5GQ7QF.mjs";
22
+ import "../../chunk-PKSW6ZMQ.mjs";
23
+ import "../../chunk-XEZ5ODJS.mjs";
24
+ import "../../chunk-SLM2AOHF.mjs";
25
25
  import "../../chunk-DBKRAOH7.mjs";
26
26
  import "../../chunk-RYUCX3ZK.mjs";
27
- import "../../chunk-JZ3RFQQ6.mjs";
27
+ import "../../chunk-XOBQLKUU.mjs";
28
28
  import "../../chunk-IK2BPURM.mjs";
29
29
  import "../../chunk-IEMQ2SQW.mjs";
30
30
  import "../../chunk-XWG3L6QC.mjs";
@@ -84,7 +84,7 @@ __export(Popup_exports, {
84
84
  module.exports = __toCommonJS(Popup_exports);
85
85
 
86
86
  // src/components/chat/Modal.tsx
87
- var import_react16 = __toESM(require("react"));
87
+ var import_react15 = __toESM(require("react"));
88
88
 
89
89
  // src/components/chat/ChatContext.tsx
90
90
  var import_react = __toESM(require("react"));
@@ -1025,7 +1025,7 @@ var Header = ({}) => {
1025
1025
  };
1026
1026
 
1027
1027
  // src/components/chat/Messages.tsx
1028
- var import_react10 = require("react");
1028
+ var import_react9 = require("react");
1029
1029
  var import_react_core5 = require("@copilotkit/react-core");
1030
1030
 
1031
1031
  // src/components/chat/messages/UserMessage.tsx
@@ -1057,8 +1057,7 @@ var UserMessage = (props) => {
1057
1057
  };
1058
1058
 
1059
1059
  // src/components/chat/Markdown.tsx
1060
- var import_react7 = require("react");
1061
- var import_react_markdown = __toESM(require("react-markdown"));
1060
+ var import_streamdown = require("streamdown");
1062
1061
 
1063
1062
  // src/components/chat/CodeBlock.tsx
1064
1063
  var import_react6 = require("react");
@@ -1470,9 +1469,6 @@ var highlightStyle = {
1470
1469
  };
1471
1470
 
1472
1471
  // src/components/chat/Markdown.tsx
1473
- var import_remark_gfm = __toESM(require("remark-gfm"));
1474
- var import_remark_math = __toESM(require("remark-math"));
1475
- var import_rehype_raw = __toESM(require("rehype-raw"));
1476
1472
  var import_jsx_runtime12 = require("react/jsx-runtime");
1477
1473
  var defaultComponents = {
1478
1474
  a(_a) {
@@ -1566,24 +1562,18 @@ var defaultComponents = {
1566
1562
  return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("li", __spreadProps(__spreadValues({ className: "copilotKitMarkdownElement" }, props), { children }));
1567
1563
  }
1568
1564
  };
1569
- var MemoizedReactMarkdown = (0, import_react7.memo)(
1570
- import_react_markdown.default,
1571
- (prevProps, nextProps) => prevProps.children === nextProps.children && prevProps.components === nextProps.components
1572
- );
1573
1565
  var Markdown = ({ content, components }) => {
1574
1566
  return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "copilotKitMarkdown", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1575
- MemoizedReactMarkdown,
1567
+ import_streamdown.Streamdown,
1576
1568
  {
1577
1569
  components: __spreadValues(__spreadValues({}, defaultComponents), components),
1578
- remarkPlugins: [import_remark_gfm.default, [import_remark_math.default, { singleDollarTextMath: false }]],
1579
- rehypePlugins: [import_rehype_raw.default],
1580
1570
  children: content
1581
1571
  }
1582
1572
  ) });
1583
1573
  };
1584
1574
 
1585
1575
  // src/components/chat/messages/AssistantMessage.tsx
1586
- var import_react8 = require("react");
1576
+ var import_react7 = require("react");
1587
1577
  var import_jsx_runtime13 = require("react/jsx-runtime");
1588
1578
  var AssistantMessage = (props) => {
1589
1579
  var _a;
@@ -1599,7 +1589,7 @@ var AssistantMessage = (props) => {
1599
1589
  feedback,
1600
1590
  markdownTagRenderers
1601
1591
  } = props;
1602
- const [copied, setCopied] = (0, import_react8.useState)(false);
1592
+ const [copied, setCopied] = (0, import_react7.useState)(false);
1603
1593
  const handleCopy = () => {
1604
1594
  const content2 = (message == null ? void 0 : message.content) || "";
1605
1595
  if (content2 && onCopy) {
@@ -1688,10 +1678,10 @@ var AssistantMessage = (props) => {
1688
1678
  };
1689
1679
 
1690
1680
  // src/components/chat/messages/ImageRenderer.tsx
1691
- var import_react9 = require("react");
1681
+ var import_react8 = require("react");
1692
1682
  var import_jsx_runtime14 = require("react/jsx-runtime");
1693
1683
  var ImageRenderer = ({ image, content, className = "" }) => {
1694
- const [imageError, setImageError] = (0, import_react9.useState)(false);
1684
+ const [imageError, setImageError] = (0, import_react8.useState)(false);
1695
1685
  const imageSrc = `data:image/${image.format};base64,${image.bytes}`;
1696
1686
  const altText = content || "User uploaded image";
1697
1687
  const handleImageError = () => {
@@ -1934,18 +1924,18 @@ var Messages = ({
1934
1924
  var _a;
1935
1925
  const { labels, icons } = useChatContext();
1936
1926
  const { messages: visibleMessages, interrupt } = (0, import_react_core5.useCopilotChatInternal)();
1937
- const initialMessages = (0, import_react10.useMemo)(() => makeInitialMessages(labels.initial), [labels.initial]);
1927
+ const initialMessages = (0, import_react9.useMemo)(() => makeInitialMessages(labels.initial), [labels.initial]);
1938
1928
  const messages = [...initialMessages, ...visibleMessages];
1939
1929
  const { messagesContainerRef, messagesEndRef } = useScrollToBottom(messages);
1940
1930
  const hasLegacyProps = !!(RenderTextMessage || RenderActionExecutionMessage || RenderAgentStateMessage || RenderResultMessage || RenderImageMessage);
1941
- (0, import_react10.useEffect)(() => {
1931
+ (0, import_react9.useEffect)(() => {
1942
1932
  if (hasLegacyProps) {
1943
1933
  console.warn(
1944
1934
  "[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"
1945
1935
  );
1946
1936
  }
1947
1937
  }, [hasLegacyProps]);
1948
- const legacyProps = (0, import_react10.useMemo)(
1938
+ const legacyProps = (0, import_react9.useMemo)(
1949
1939
  () => ({
1950
1940
  RenderTextMessage,
1951
1941
  RenderActionExecutionMessage,
@@ -2016,10 +2006,10 @@ function makeInitialMessages(initial) {
2016
2006
  ];
2017
2007
  }
2018
2008
  function useScrollToBottom(messages) {
2019
- const messagesEndRef = (0, import_react10.useRef)(null);
2020
- const messagesContainerRef = (0, import_react10.useRef)(null);
2021
- const isProgrammaticScrollRef = (0, import_react10.useRef)(false);
2022
- const isUserScrollUpRef = (0, import_react10.useRef)(false);
2009
+ const messagesEndRef = (0, import_react9.useRef)(null);
2010
+ const messagesContainerRef = (0, import_react9.useRef)(null);
2011
+ const isProgrammaticScrollRef = (0, import_react9.useRef)(false);
2012
+ const isUserScrollUpRef = (0, import_react9.useRef)(false);
2023
2013
  const scrollToBottom = () => {
2024
2014
  if (messagesContainerRef.current && messagesEndRef.current) {
2025
2015
  isProgrammaticScrollRef.current = true;
@@ -2036,7 +2026,7 @@ function useScrollToBottom(messages) {
2036
2026
  isUserScrollUpRef.current = scrollTop + clientHeight < scrollHeight;
2037
2027
  }
2038
2028
  };
2039
- (0, import_react10.useEffect)(() => {
2029
+ (0, import_react9.useEffect)(() => {
2040
2030
  const container = messagesContainerRef.current;
2041
2031
  if (container) {
2042
2032
  container.addEventListener("scroll", handleScroll);
@@ -2047,7 +2037,7 @@ function useScrollToBottom(messages) {
2047
2037
  }
2048
2038
  };
2049
2039
  }, []);
2050
- (0, import_react10.useEffect)(() => {
2040
+ (0, import_react9.useEffect)(() => {
2051
2041
  const container = messagesContainerRef.current;
2052
2042
  if (!container) {
2053
2043
  return;
@@ -2066,7 +2056,7 @@ function useScrollToBottom(messages) {
2066
2056
  mutationObserver.disconnect();
2067
2057
  };
2068
2058
  }, []);
2069
- (0, import_react10.useEffect)(() => {
2059
+ (0, import_react9.useEffect)(() => {
2070
2060
  isUserScrollUpRef.current = false;
2071
2061
  scrollToBottom();
2072
2062
  }, [messages.filter((m) => m.role === "user").length]);
@@ -2074,12 +2064,12 @@ function useScrollToBottom(messages) {
2074
2064
  }
2075
2065
 
2076
2066
  // src/components/chat/Input.tsx
2077
- var import_react14 = require("react");
2067
+ var import_react13 = require("react");
2078
2068
 
2079
2069
  // src/components/chat/Textarea.tsx
2080
- var import_react11 = require("react");
2070
+ var import_react10 = require("react");
2081
2071
  var import_jsx_runtime18 = require("react/jsx-runtime");
2082
- var AutoResizingTextarea = (0, import_react11.forwardRef)(
2072
+ var AutoResizingTextarea = (0, import_react10.forwardRef)(
2083
2073
  ({
2084
2074
  maxRows = 1,
2085
2075
  placeholder,
@@ -2090,10 +2080,10 @@ var AutoResizingTextarea = (0, import_react11.forwardRef)(
2090
2080
  onCompositionEnd,
2091
2081
  autoFocus
2092
2082
  }, ref) => {
2093
- const internalTextareaRef = (0, import_react11.useRef)(null);
2094
- const [maxHeight, setMaxHeight] = (0, import_react11.useState)(0);
2095
- (0, import_react11.useImperativeHandle)(ref, () => internalTextareaRef.current);
2096
- (0, import_react11.useEffect)(() => {
2083
+ const internalTextareaRef = (0, import_react10.useRef)(null);
2084
+ const [maxHeight, setMaxHeight] = (0, import_react10.useState)(0);
2085
+ (0, import_react10.useImperativeHandle)(ref, () => internalTextareaRef.current);
2086
+ (0, import_react10.useEffect)(() => {
2097
2087
  const calculateMaxHeight = () => {
2098
2088
  const textarea = internalTextareaRef.current;
2099
2089
  if (textarea) {
@@ -2107,7 +2097,7 @@ var AutoResizingTextarea = (0, import_react11.forwardRef)(
2107
2097
  };
2108
2098
  calculateMaxHeight();
2109
2099
  }, [maxRows]);
2110
- (0, import_react11.useEffect)(() => {
2100
+ (0, import_react10.useEffect)(() => {
2111
2101
  const textarea = internalTextareaRef.current;
2112
2102
  if (textarea) {
2113
2103
  textarea.style.height = "auto";
@@ -2139,7 +2129,7 @@ var Textarea_default = AutoResizingTextarea;
2139
2129
  // src/hooks/use-push-to-talk.tsx
2140
2130
  var import_react_core6 = require("@copilotkit/react-core");
2141
2131
  var import_runtime_client_gql2 = require("@copilotkit/runtime-client-gql");
2142
- var import_react12 = require("react");
2132
+ var import_react11 = require("react");
2143
2133
  var startRecording = (mediaStreamRef, mediaRecorderRef, audioContextRef, recordedChunks, onStop) => __async(void 0, null, function* () {
2144
2134
  if (!mediaStreamRef.current || !audioContextRef.current) {
2145
2135
  mediaStreamRef.current = yield navigator.mediaDevices.getUserMedia({ audio: true });
@@ -2188,16 +2178,16 @@ var usePushToTalk = ({
2188
2178
  sendFunction,
2189
2179
  inProgress
2190
2180
  }) => {
2191
- const [pushToTalkState, setPushToTalkState] = (0, import_react12.useState)("idle");
2192
- const mediaStreamRef = (0, import_react12.useRef)(null);
2193
- const audioContextRef = (0, import_react12.useRef)(null);
2194
- const mediaRecorderRef = (0, import_react12.useRef)(null);
2195
- const recordedChunks = (0, import_react12.useRef)([]);
2181
+ const [pushToTalkState, setPushToTalkState] = (0, import_react11.useState)("idle");
2182
+ const mediaStreamRef = (0, import_react11.useRef)(null);
2183
+ const audioContextRef = (0, import_react11.useRef)(null);
2184
+ const mediaRecorderRef = (0, import_react11.useRef)(null);
2185
+ const recordedChunks = (0, import_react11.useRef)([]);
2196
2186
  const generalContext = (0, import_react_core6.useCopilotContext)();
2197
2187
  const messagesContext = (0, import_react_core6.useCopilotMessagesContext)();
2198
2188
  const context = __spreadValues(__spreadValues({}, generalContext), messagesContext);
2199
- const [startReadingFromMessageId, setStartReadingFromMessageId] = (0, import_react12.useState)(null);
2200
- (0, import_react12.useEffect)(() => {
2189
+ const [startReadingFromMessageId, setStartReadingFromMessageId] = (0, import_react11.useState)(null);
2190
+ (0, import_react11.useEffect)(() => {
2201
2191
  if (pushToTalkState === "recording") {
2202
2192
  startRecording(
2203
2193
  mediaStreamRef,
@@ -2225,7 +2215,7 @@ var usePushToTalk = ({
2225
2215
  stopRecording(mediaRecorderRef);
2226
2216
  };
2227
2217
  }, [pushToTalkState]);
2228
- (0, import_react12.useEffect)(() => {
2218
+ (0, import_react11.useEffect)(() => {
2229
2219
  if (inProgress === false && startReadingFromMessageId) {
2230
2220
  const lastMessageIndex = context.messages.findIndex(
2231
2221
  (message) => message.id === startReadingFromMessageId
@@ -2244,7 +2234,7 @@ var usePushToTalk = ({
2244
2234
  var import_react_core7 = require("@copilotkit/react-core");
2245
2235
 
2246
2236
  // src/components/chat/PoweredByTag.tsx
2247
- var import_react13 = require("react");
2237
+ var import_react12 = require("react");
2248
2238
 
2249
2239
  // src/hooks/use-dark-mode.ts
2250
2240
  var useDarkMode = () => {
@@ -2256,9 +2246,9 @@ var useDarkMode = () => {
2256
2246
  // src/components/chat/PoweredByTag.tsx
2257
2247
  var import_jsx_runtime19 = require("react/jsx-runtime");
2258
2248
  function PoweredByTag({ showPoweredBy = true }) {
2259
- const [mounted, setMounted] = (0, import_react13.useState)(false);
2249
+ const [mounted, setMounted] = (0, import_react12.useState)(false);
2260
2250
  const isDark = useDarkMode();
2261
- (0, import_react13.useEffect)(() => {
2251
+ (0, import_react12.useEffect)(() => {
2262
2252
  setMounted(true);
2263
2253
  }, []);
2264
2254
  if (!showPoweredBy) {
@@ -2292,8 +2282,8 @@ var Input = ({
2292
2282
  const copilotContext = (0, import_react_core7.useCopilotContext)();
2293
2283
  const showPoweredBy = !((_a = copilotContext.copilotApiConfig) == null ? void 0 : _a.publicApiKey);
2294
2284
  const pushToTalkConfigured = copilotContext.copilotApiConfig.textToSpeechUrl !== void 0 && copilotContext.copilotApiConfig.transcribeAudioUrl !== void 0;
2295
- const textareaRef = (0, import_react14.useRef)(null);
2296
- const [isComposing, setIsComposing] = (0, import_react14.useState)(false);
2285
+ const textareaRef = (0, import_react13.useRef)(null);
2286
+ const [isComposing, setIsComposing] = (0, import_react13.useState)(false);
2297
2287
  const handleDivClick = (event) => {
2298
2288
  var _a2;
2299
2289
  const target = event.target;
@@ -2303,7 +2293,7 @@ var Input = ({
2303
2293
  return;
2304
2294
  (_a2 = textareaRef.current) == null ? void 0 : _a2.focus();
2305
2295
  };
2306
- const [text, setText] = (0, import_react14.useState)("");
2296
+ const [text, setText] = (0, import_react13.useState)("");
2307
2297
  const send = () => {
2308
2298
  var _a2;
2309
2299
  if (inProgress)
@@ -2317,17 +2307,17 @@ var Input = ({
2317
2307
  inProgress
2318
2308
  });
2319
2309
  const isInProgress = inProgress || pushToTalkState === "transcribing";
2320
- const { buttonIcon, buttonAlt } = (0, import_react14.useMemo)(() => {
2310
+ const { buttonIcon, buttonAlt } = (0, import_react13.useMemo)(() => {
2321
2311
  if (!chatReady)
2322
2312
  return { buttonIcon: context.icons.spinnerIcon, buttonAlt: "Loading" };
2323
2313
  return isInProgress && !hideStopButton && chatReady ? { buttonIcon: context.icons.stopIcon, buttonAlt: "Stop" } : { buttonIcon: context.icons.sendIcon, buttonAlt: "Send" };
2324
2314
  }, [isInProgress, chatReady, hideStopButton, context.icons.stopIcon, context.icons.sendIcon]);
2325
2315
  const showPushToTalk = pushToTalkConfigured && (pushToTalkState === "idle" || pushToTalkState === "recording") && !inProgress;
2326
2316
  const { interrupt } = (0, import_react_core7.useCopilotChatInternal)();
2327
- const canSend = (0, import_react14.useMemo)(() => {
2317
+ const canSend = (0, import_react13.useMemo)(() => {
2328
2318
  return !isInProgress && text.trim().length > 0 && pushToTalkState === "idle" && !interrupt;
2329
2319
  }, [interrupt, isInProgress, text, pushToTalkState]);
2330
- const canStop = (0, import_react14.useMemo)(() => {
2320
+ const canStop = (0, import_react13.useMemo)(() => {
2331
2321
  return isInProgress && !hideStopButton;
2332
2322
  }, [isInProgress, hideStopButton]);
2333
2323
  const sendDisabled = !canSend && !canStop;
@@ -2384,7 +2374,7 @@ var Input = ({
2384
2374
  };
2385
2375
 
2386
2376
  // src/components/chat/Chat.tsx
2387
- var import_react15 = __toESM(require("react"));
2377
+ var import_react14 = __toESM(require("react"));
2388
2378
  var import_react_core9 = require("@copilotkit/react-core");
2389
2379
  var import_shared3 = require("@copilotkit/shared");
2390
2380
 
@@ -2561,13 +2551,13 @@ function CopilotChat({
2561
2551
  removeInternalErrorHandler
2562
2552
  } = (0, import_react_core9.useCopilotContext)();
2563
2553
  const { publicApiKey, chatApiEndpoint } = copilotApiConfig;
2564
- const [selectedImages, setSelectedImages] = (0, import_react15.useState)([]);
2565
- const [chatError, setChatError] = (0, import_react15.useState)(null);
2566
- const [messageFeedback, setMessageFeedback] = (0, import_react15.useState)(
2554
+ const [selectedImages, setSelectedImages] = (0, import_react14.useState)([]);
2555
+ const [chatError, setChatError] = (0, import_react14.useState)(null);
2556
+ const [messageFeedback, setMessageFeedback] = (0, import_react14.useState)(
2567
2557
  {}
2568
2558
  );
2569
- const fileInputRef = (0, import_react15.useRef)(null);
2570
- const triggerObservabilityHook = (0, import_react15.useCallback)(
2559
+ const fileInputRef = (0, import_react14.useRef)(null);
2560
+ const triggerObservabilityHook = (0, import_react14.useCallback)(
2571
2561
  (hookName, ...args) => {
2572
2562
  if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks[hookName])) {
2573
2563
  observabilityHooks[hookName](...args);
@@ -2586,7 +2576,7 @@ function CopilotChat({
2586
2576
  },
2587
2577
  [publicApiKey, observabilityHooks, setBannerError]
2588
2578
  );
2589
- const triggerChatError = (0, import_react15.useCallback)(
2579
+ const triggerChatError = (0, import_react14.useCallback)(
2590
2580
  (error, operation, originalError) => {
2591
2581
  const errorMessage = (error == null ? void 0 : error.message) || (error == null ? void 0 : error.toString()) || "An error occurred";
2592
2582
  setChatError({
@@ -2632,7 +2622,7 @@ function CopilotChat({
2632
2622
  },
2633
2623
  [publicApiKey, chatApiEndpoint, observabilityHooks, setBannerError]
2634
2624
  );
2635
- (0, import_react15.useEffect)(() => {
2625
+ (0, import_react14.useEffect)(() => {
2636
2626
  const id = "chat-component";
2637
2627
  setInternalErrorHandler({
2638
2628
  [id]: (error) => {
@@ -2645,7 +2635,7 @@ function CopilotChat({
2645
2635
  removeInternalErrorHandler == null ? void 0 : removeInternalErrorHandler(id);
2646
2636
  };
2647
2637
  }, [triggerChatError, setInternalErrorHandler, removeInternalErrorHandler]);
2648
- (0, import_react15.useEffect)(() => {
2638
+ (0, import_react14.useEffect)(() => {
2649
2639
  if (!imageUploadsEnabled)
2650
2640
  return;
2651
2641
  const handlePaste = (e) => __async(this, null, function* () {
@@ -2691,7 +2681,7 @@ function CopilotChat({
2691
2681
  document.addEventListener("paste", handlePaste);
2692
2682
  return () => document.removeEventListener("paste", handlePaste);
2693
2683
  }, [imageUploadsEnabled, triggerChatError]);
2694
- (0, import_react15.useEffect)(() => {
2684
+ (0, import_react14.useEffect)(() => {
2695
2685
  if (!(additionalInstructions == null ? void 0 : additionalInstructions.length)) {
2696
2686
  setChatInstructions(instructions || "");
2697
2687
  return;
@@ -2719,8 +2709,8 @@ function CopilotChat({
2719
2709
  onStopGeneration,
2720
2710
  onReloadMessages
2721
2711
  });
2722
- const prevIsLoading = (0, import_react15.useRef)(isLoading);
2723
- (0, import_react15.useEffect)(() => {
2712
+ const prevIsLoading = (0, import_react14.useRef)(isLoading);
2713
+ (0, import_react14.useEffect)(() => {
2724
2714
  if (prevIsLoading.current !== isLoading) {
2725
2715
  if (isLoading) {
2726
2716
  triggerObservabilityHook("onChatStarted");
@@ -2743,7 +2733,7 @@ function CopilotChat({
2743
2733
  role: "user"
2744
2734
  });
2745
2735
  };
2746
- const chatContext = import_react15.default.useContext(ChatContext);
2736
+ const chatContext = import_react14.default.useContext(ChatContext);
2747
2737
  const isVisible = chatContext ? chatContext.open : true;
2748
2738
  const handleRegenerate = (messageId) => {
2749
2739
  if (onRegenerate) {
@@ -2887,7 +2877,7 @@ function WrappedCopilotChat({
2887
2877
  labels,
2888
2878
  className
2889
2879
  }) {
2890
- const chatContext = import_react15.default.useContext(ChatContext);
2880
+ const chatContext = import_react14.default.useContext(ChatContext);
2891
2881
  if (!chatContext) {
2892
2882
  return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ChatContextProvider, { icons, labels, open: true, setOpen: () => {
2893
2883
  }, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: `copilotKitChat ${className != null ? className : ""}`, children }) });
@@ -2925,7 +2915,7 @@ var CopilotModalInner = (_a) => {
2925
2915
  ]);
2926
2916
  const { copilotApiConfig, setBannerError } = (0, import_react_core10.useCopilotContext)();
2927
2917
  const { publicApiKey } = copilotApiConfig;
2928
- const triggerObservabilityHook = (0, import_react16.useCallback)(
2918
+ const triggerObservabilityHook = (0, import_react15.useCallback)(
2929
2919
  (hookName, ...args) => {
2930
2920
  if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks[hookName])) {
2931
2921
  observabilityHooks[hookName](...args);
@@ -2945,8 +2935,8 @@ var CopilotModalInner = (_a) => {
2945
2935
  [publicApiKey, observabilityHooks, setBannerError]
2946
2936
  );
2947
2937
  const { open } = useChatContext();
2948
- const prevOpen = (0, import_react16.useRef)(open);
2949
- (0, import_react16.useEffect)(() => {
2938
+ const prevOpen = (0, import_react15.useRef)(open);
2939
+ (0, import_react15.useEffect)(() => {
2950
2940
  if (prevOpen.current !== open) {
2951
2941
  onSetOpen == null ? void 0 : onSetOpen(open);
2952
2942
  if (open) {
@@ -2957,8 +2947,8 @@ var CopilotModalInner = (_a) => {
2957
2947
  prevOpen.current = open;
2958
2948
  }
2959
2949
  }, [open, onSetOpen, triggerObservabilityHook]);
2960
- const memoizedHeader = (0, import_react16.useMemo)(() => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Header2, {}), [Header2]);
2961
- const memoizedChildren = (0, import_react16.useMemo)(() => children, [children]);
2950
+ const memoizedHeader = (0, import_react15.useMemo)(() => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Header2, {}), [Header2]);
2951
+ const memoizedChildren = (0, import_react15.useMemo)(() => children, [children]);
2962
2952
  return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_jsx_runtime25.Fragment, { children: [
2963
2953
  memoizedChildren,
2964
2954
  /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className, children: [
@@ -3038,7 +3028,7 @@ var CopilotModal = (_a) => {
3038
3028
  "children",
3039
3029
  "observabilityHooks"
3040
3030
  ]);
3041
- const [openState, setOpenState] = import_react16.default.useState(defaultOpen);
3031
+ const [openState, setOpenState] = import_react15.default.useState(defaultOpen);
3042
3032
  return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ChatContextProvider, { icons, labels, open: openState, setOpen: setOpenState, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
3043
3033
  CopilotModalInner,
3044
3034
  __spreadProps(__spreadValues({