@copilotkit/react-ui 1.8.12-next.4 → 1.8.12-next.6

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 +18 -0
  2. package/dist/chunk-CGEAG65D.mjs +27 -0
  3. package/dist/chunk-CGEAG65D.mjs.map +1 -0
  4. package/dist/{chunk-SJWVHGKD.mjs → chunk-ECCHEFQV.mjs} +2 -2
  5. package/dist/chunk-EMIYIMQ6.mjs +110 -0
  6. package/dist/chunk-EMIYIMQ6.mjs.map +1 -0
  7. package/dist/{chunk-QXWJ7HYU.mjs → chunk-JZAMNIUD.mjs} +8 -8
  8. package/dist/{chunk-QXWJ7HYU.mjs.map → chunk-JZAMNIUD.mjs.map} +1 -1
  9. package/dist/{chunk-T5637OOY.mjs → chunk-KCV67665.mjs} +2 -2
  10. package/dist/{chunk-SLTG4L62.mjs → chunk-LUPGADWY.mjs} +4 -4
  11. package/dist/{chunk-POWCBXRY.mjs → chunk-RVLCPPEL.mjs} +4 -4
  12. package/dist/{chunk-Q2NFQTCQ.mjs → chunk-TIDV74OE.mjs} +7 -33
  13. package/dist/chunk-TIDV74OE.mjs.map +1 -0
  14. package/dist/{chunk-W2OWARTP.mjs → chunk-WN46UIN3.mjs} +7 -7
  15. package/dist/components/chat/Chat.js +151 -118
  16. package/dist/components/chat/Chat.js.map +1 -1
  17. package/dist/components/chat/Chat.mjs +7 -5
  18. package/dist/components/chat/Input.js +79 -46
  19. package/dist/components/chat/Input.js.map +1 -1
  20. package/dist/components/chat/Input.mjs +3 -1
  21. package/dist/components/chat/Modal.js +163 -162
  22. package/dist/components/chat/Modal.js.map +1 -1
  23. package/dist/components/chat/Modal.mjs +8 -7
  24. package/dist/components/chat/Popup.js +165 -164
  25. package/dist/components/chat/Popup.js.map +1 -1
  26. package/dist/components/chat/Popup.mjs +9 -8
  27. package/dist/components/chat/PoweredByTag.d.ts +7 -0
  28. package/dist/components/chat/PoweredByTag.js +56 -0
  29. package/dist/components/chat/PoweredByTag.js.map +1 -0
  30. package/dist/components/chat/PoweredByTag.mjs +9 -0
  31. package/dist/components/chat/PoweredByTag.mjs.map +1 -0
  32. package/dist/components/chat/Sidebar.js +165 -164
  33. package/dist/components/chat/Sidebar.js.map +1 -1
  34. package/dist/components/chat/Sidebar.mjs +9 -8
  35. package/dist/components/chat/Window.js +5 -37
  36. package/dist/components/chat/Window.js.map +1 -1
  37. package/dist/components/chat/Window.mjs +1 -2
  38. package/dist/components/chat/index.js +167 -166
  39. package/dist/components/chat/index.js.map +1 -1
  40. package/dist/components/chat/index.mjs +12 -11
  41. package/dist/components/chat/messages/RenderImageMessage.mjs +2 -2
  42. package/dist/components/chat/messages/RenderTextMessage.mjs +2 -2
  43. package/dist/components/index.js +167 -166
  44. package/dist/components/index.js.map +1 -1
  45. package/dist/components/index.mjs +12 -11
  46. package/dist/index.css +23 -26
  47. package/dist/index.css.map +1 -1
  48. package/dist/index.js +167 -166
  49. package/dist/index.js.map +1 -1
  50. package/dist/index.mjs +12 -11
  51. package/package.json +4 -4
  52. package/src/components/chat/Chat.tsx +1 -1
  53. package/src/components/chat/Input.tsx +6 -2
  54. package/src/components/chat/PoweredByTag.tsx +29 -0
  55. package/src/components/chat/Window.tsx +1 -24
  56. package/src/css/input.css +27 -0
  57. package/src/css/window.css +0 -29
  58. package/dist/chunk-IWBARPUZ.mjs +0 -102
  59. package/dist/chunk-IWBARPUZ.mjs.map +0 -1
  60. package/dist/chunk-Q2NFQTCQ.mjs.map +0 -1
  61. /package/dist/{chunk-SJWVHGKD.mjs.map → chunk-ECCHEFQV.mjs.map} +0 -0
  62. /package/dist/{chunk-T5637OOY.mjs.map → chunk-KCV67665.mjs.map} +0 -0
  63. /package/dist/{chunk-SLTG4L62.mjs.map → chunk-LUPGADWY.mjs.map} +0 -0
  64. /package/dist/{chunk-POWCBXRY.mjs.map → chunk-RVLCPPEL.mjs.map} +0 -0
  65. /package/dist/{chunk-W2OWARTP.mjs.map → chunk-WN46UIN3.mjs.map} +0 -0
package/dist/index.mjs CHANGED
@@ -4,13 +4,13 @@ import "./chunk-MMVDU6DF.mjs";
4
4
  import "./chunk-PXEVB7IK.mjs";
5
5
  import {
6
6
  CopilotPopup
7
- } from "./chunk-SJWVHGKD.mjs";
7
+ } from "./chunk-ECCHEFQV.mjs";
8
8
  import {
9
9
  CopilotSidebar
10
- } from "./chunk-T5637OOY.mjs";
10
+ } from "./chunk-KCV67665.mjs";
11
11
  import "./chunk-WB3YULQ4.mjs";
12
- import "./chunk-W2OWARTP.mjs";
13
- import "./chunk-Q2NFQTCQ.mjs";
12
+ import "./chunk-WN46UIN3.mjs";
13
+ import "./chunk-TIDV74OE.mjs";
14
14
  import "./chunk-UH2UFL5W.mjs";
15
15
  import "./chunk-V7W6IM2V.mjs";
16
16
  import {
@@ -26,23 +26,24 @@ import "./chunk-BH6PCAAL.mjs";
26
26
  import "./chunk-UFN2VWSR.mjs";
27
27
  import {
28
28
  CopilotChat
29
- } from "./chunk-QXWJ7HYU.mjs";
29
+ } from "./chunk-JZAMNIUD.mjs";
30
30
  import "./chunk-DSQGQJI4.mjs";
31
31
  import "./chunk-24TDU7MY.mjs";
32
32
  import {
33
33
  RenderImageMessage
34
- } from "./chunk-SLTG4L62.mjs";
34
+ } from "./chunk-LUPGADWY.mjs";
35
35
  import "./chunk-XFCMZH2H.mjs";
36
- import "./chunk-POWCBXRY.mjs";
37
- import {
38
- UserMessage
39
- } from "./chunk-HWMFMBJC.mjs";
36
+ import "./chunk-RVLCPPEL.mjs";
40
37
  import {
41
38
  AssistantMessage
42
39
  } from "./chunk-OZXUB3V7.mjs";
40
+ import {
41
+ UserMessage
42
+ } from "./chunk-HWMFMBJC.mjs";
43
43
  import "./chunk-XZNY26GH.mjs";
44
44
  import "./chunk-PLHTVHUW.mjs";
45
- import "./chunk-IWBARPUZ.mjs";
45
+ import "./chunk-EMIYIMQ6.mjs";
46
+ import "./chunk-CGEAG65D.mjs";
46
47
  import "./chunk-YQFVRDNC.mjs";
47
48
  import {
48
49
  Markdown
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "publishConfig": {
10
10
  "access": "public"
11
11
  },
12
- "version": "1.8.12-next.4",
12
+ "version": "1.8.12-next.6",
13
13
  "sideEffects": [
14
14
  "**/*.css"
15
15
  ],
@@ -50,9 +50,9 @@
50
50
  "react-syntax-highlighter": "^15.5.0",
51
51
  "remark-gfm": "^3.0.1",
52
52
  "remark-math": "^5.1.1",
53
- "@copilotkit/react-core": "1.8.12-next.4",
54
- "@copilotkit/runtime-client-gql": "1.8.12-next.4",
55
- "@copilotkit/shared": "1.8.12-next.4"
53
+ "@copilotkit/react-core": "1.8.12-next.6",
54
+ "@copilotkit/runtime-client-gql": "1.8.12-next.6",
55
+ "@copilotkit/shared": "1.8.12-next.6"
56
56
  },
57
57
  "keywords": [
58
58
  "copilotkit",
@@ -539,7 +539,7 @@ export function WrappedCopilotChat({
539
539
  if (!chatContext) {
540
540
  return (
541
541
  <ChatContextProvider icons={icons} labels={labels} open={true} setOpen={() => {}}>
542
- <div className={`copilotKitChat ${className}`}>{children}</div>
542
+ <div className={`copilotKitChat ${className ?? ""}`}>{children}</div>
543
543
  </ChatContextProvider>
544
544
  );
545
545
  }
@@ -1,9 +1,10 @@
1
- import React, { useEffect, useRef, useState } from "react";
1
+ import React, { useRef, useState } from "react";
2
2
  import { InputProps } from "./props";
3
3
  import { useChatContext } from "./ChatContext";
4
4
  import AutoResizingTextarea from "./Textarea";
5
5
  import { usePushToTalk } from "../../hooks/use-push-to-talk";
6
6
  import { useCopilotContext } from "@copilotkit/react-core";
7
+ import { PoweredByTag } from "./PoweredByTag";
7
8
 
8
9
  const MAX_NEWLINES = 6;
9
10
 
@@ -11,6 +12,8 @@ export const Input = ({ inProgress, onSend, isVisible = false, onStop, onUpload
11
12
  const context = useChatContext();
12
13
  const copilotContext = useCopilotContext();
13
14
 
15
+ const showPoweredBy = !copilotContext.copilotApiConfig?.publicApiKey;
16
+
14
17
  const pushToTalkConfigured =
15
18
  copilotContext.copilotApiConfig.textToSpeechUrl !== undefined &&
16
19
  copilotContext.copilotApiConfig.transcribeAudioUrl !== undefined;
@@ -81,7 +84,7 @@ export const Input = ({ inProgress, onSend, isVisible = false, onStop, onUpload
81
84
  const sendDisabled = !canSend();
82
85
 
83
86
  return (
84
- <div className="copilotKitInputContainer">
87
+ <div className={`copilotKitInputContainer ${showPoweredBy ? "poweredByContainer" : ""}`}>
85
88
  <div className="copilotKitInput" onClick={handleDivClick}>
86
89
  <AutoResizingTextarea
87
90
  ref={textareaRef}
@@ -133,6 +136,7 @@ export const Input = ({ inProgress, onSend, isVisible = false, onStop, onUpload
133
136
  </button>
134
137
  </div>
135
138
  </div>
139
+ <PoweredByTag showPoweredBy={showPoweredBy} />
136
140
  </div>
137
141
  );
138
142
  };
@@ -0,0 +1,29 @@
1
+ import React from "react";
2
+ import { useDarkMode } from "../../hooks/use-dark-mode";
3
+
4
+ export function PoweredByTag({ showPoweredBy = true }: { showPoweredBy?: boolean }) {
5
+ const isDark = useDarkMode();
6
+
7
+ if (!showPoweredBy) {
8
+ return null;
9
+ }
10
+
11
+ const poweredByStyle = {
12
+ visibility: "visible",
13
+ display: "block",
14
+ position: "static",
15
+ textAlign: "center",
16
+ fontSize: "12px",
17
+ padding: "3px 0",
18
+ color: isDark ? "rgb(69, 69, 69)" : "rgb(214, 214, 214)",
19
+ };
20
+
21
+ return (
22
+ <div>
23
+ {/*@ts-expect-error -- expecting position not to be a string, but it can be.*/}
24
+ <p className="poweredBy" style={poweredByStyle}>
25
+ Powered by CopilotKit
26
+ </p>
27
+ </div>
28
+ );
29
+ }
@@ -2,7 +2,6 @@ import React, { useCallback, useEffect } from "react";
2
2
  import { WindowProps } from "./props";
3
3
  import { useChatContext } from "./ChatContext";
4
4
  import { useCopilotContext } from "@copilotkit/react-core";
5
- import { useDarkMode } from "../../hooks/use-dark-mode";
6
5
 
7
6
  export const Window = ({
8
7
  children,
@@ -124,31 +123,9 @@ export const Window = ({
124
123
  };
125
124
  }, [adjustForMobile, handleClickOutside, handleKeyDown]);
126
125
 
127
- const isDark = useDarkMode();
128
-
129
- const showPoweredBy = !context.copilotApiConfig?.publicApiKey;
130
- const poweredByStyle = {
131
- visibility: "visible",
132
- display: "block",
133
- position: "static",
134
- textAlign: "center",
135
- fontSize: "12px",
136
- padding: "3px 0",
137
- color: isDark ? "rgb(69, 69, 69)" : "rgb(214, 214, 214)",
138
- };
139
-
140
126
  return (
141
- <div
142
- className={`copilotKitWindow ${showPoweredBy ? " poweredByContainer" : ""} ${open ? " open" : ""}`}
143
- ref={windowRef}
144
- >
127
+ <div className={`copilotKitWindow ${open ? " open" : ""}`} ref={windowRef}>
145
128
  {children}
146
- {showPoweredBy && (
147
- // @ts-expect-error -- expecting position not to be a string, but it can be.
148
- <p className="poweredBy" style={poweredByStyle}>
149
- Powered by CopilotKit
150
- </p>
151
- )}
152
129
  </div>
153
130
  );
154
131
  };
package/src/css/input.css CHANGED
@@ -13,6 +13,7 @@
13
13
  .copilotKitInputContainer {
14
14
  width: 100%;
15
15
  padding: 0;
16
+ padding-bottom: 15px;
16
17
  background: var(--copilot-kit-background-color);
17
18
  border-bottom-left-radius: 0.75rem;
18
19
  border-bottom-right-radius: 0.75rem;
@@ -123,3 +124,29 @@
123
124
  .copilotKitInput textarea::-webkit-scrollbar-thumb:hover {
124
125
  background-color: color-mix(in srgb, rgb(200 200 200) 80%, black); /* Darker color on hover */
125
126
  }
127
+
128
+ .poweredByContainer {
129
+ padding: 0;
130
+ }
131
+
132
+ .poweredBy {
133
+ background: var(--copilot-kit-background-color) !important;
134
+ visibility: visible !important;
135
+ display: block !important;
136
+ position: static !important;
137
+ text-align: center !important;
138
+ font-size: 12px !important;
139
+ padding: 3px 0 !important;
140
+ color: rgb(214, 214, 214) !important;
141
+ margin: 0 !important;
142
+ }
143
+
144
+ .dark,
145
+ html.dark,
146
+ body.dark,
147
+ [data-theme="dark"],
148
+ html[style*="color-scheme: dark"],
149
+ body[style*="color-scheme: dark"] .poweredBy {
150
+ color: rgb(69, 69, 69) !important;
151
+ }
152
+
@@ -14,35 +14,6 @@
14
14
  transform: scale(0.95) translateY(20px);
15
15
  display: flex;
16
16
  pointer-events: none;
17
- padding-bottom: 15px;
18
- }
19
-
20
- .poweredByContainer {
21
- padding: 0;
22
- visibility: visible !important;
23
- display: flex !important;
24
- position: fixed !important;
25
- }
26
-
27
- .poweredBy {
28
- background: var(--copilot-kit-background-color) !important;
29
- visibility: visible !important;
30
- display: block !important;
31
- position: static !important;
32
- text-align: center !important;
33
- font-size: 12px !important;
34
- padding: 3px 0 !important;
35
- color: rgb(214, 214, 214) !important;
36
- margin: 0 !important;
37
- }
38
-
39
- .dark,
40
- html.dark,
41
- body.dark,
42
- [data-theme="dark"],
43
- html[style*="color-scheme: dark"],
44
- body[style*="color-scheme: dark"] .poweredBy {
45
- color: rgb(69, 69, 69) !important;
46
17
  }
47
18
 
48
19
  .copilotKitSidebar .copilotKitWindow {
@@ -1,102 +0,0 @@
1
- import {
2
- Textarea_default
3
- } from "./chunk-YQFVRDNC.mjs";
4
- import {
5
- useChatContext
6
- } from "./chunk-IEMQ2SQW.mjs";
7
- import {
8
- usePushToTalk
9
- } from "./chunk-S5MBUNGN.mjs";
10
-
11
- // src/components/chat/Input.tsx
12
- import { useRef, useState } from "react";
13
- import { useCopilotContext } from "@copilotkit/react-core";
14
- import { jsx, jsxs } from "react/jsx-runtime";
15
- var MAX_NEWLINES = 6;
16
- var Input = ({ inProgress, onSend, isVisible = false, onStop, onUpload }) => {
17
- const context = useChatContext();
18
- const copilotContext = useCopilotContext();
19
- const pushToTalkConfigured = copilotContext.copilotApiConfig.textToSpeechUrl !== void 0 && copilotContext.copilotApiConfig.transcribeAudioUrl !== void 0;
20
- const textareaRef = useRef(null);
21
- const handleDivClick = (event) => {
22
- var _a;
23
- const target = event.target;
24
- if (target.closest("button"))
25
- return;
26
- if (target.tagName === "TEXTAREA")
27
- return;
28
- (_a = textareaRef.current) == null ? void 0 : _a.focus();
29
- };
30
- const [text, setText] = useState("");
31
- const send = () => {
32
- var _a;
33
- if (inProgress)
34
- return;
35
- onSend(text);
36
- setText("");
37
- (_a = textareaRef.current) == null ? void 0 : _a.focus();
38
- };
39
- const { pushToTalkState, setPushToTalkState } = usePushToTalk({
40
- sendFunction: onSend,
41
- inProgress
42
- });
43
- const isInProgress = inProgress || pushToTalkState === "transcribing";
44
- const buttonIcon = isInProgress ? context.icons.stopIcon : context.icons.sendIcon;
45
- const showPushToTalk = pushToTalkConfigured && (pushToTalkState === "idle" || pushToTalkState === "recording") && !inProgress;
46
- const canSend = () => {
47
- var _a;
48
- const interruptEvent = (_a = copilotContext.langGraphInterruptAction) == null ? void 0 : _a.event;
49
- const interruptInProgress = (interruptEvent == null ? void 0 : interruptEvent.name) === "LangGraphInterruptEvent" && !(interruptEvent == null ? void 0 : interruptEvent.response);
50
- return (isInProgress || !isInProgress && text.trim().length > 0) && pushToTalkState === "idle" && !interruptInProgress;
51
- };
52
- const sendDisabled = !canSend();
53
- return /* @__PURE__ */ jsx("div", { className: "copilotKitInputContainer", children: /* @__PURE__ */ jsxs("div", { className: "copilotKitInput", onClick: handleDivClick, children: [
54
- /* @__PURE__ */ jsx(
55
- Textarea_default,
56
- {
57
- ref: textareaRef,
58
- placeholder: context.labels.placeholder,
59
- autoFocus: false,
60
- maxRows: MAX_NEWLINES,
61
- value: text,
62
- onChange: (event) => setText(event.target.value),
63
- onKeyDown: (event) => {
64
- if (event.key === "Enter" && !event.shiftKey) {
65
- event.preventDefault();
66
- if (canSend()) {
67
- send();
68
- }
69
- }
70
- }
71
- }
72
- ),
73
- /* @__PURE__ */ jsxs("div", { className: "copilotKitInputControls", children: [
74
- onUpload && /* @__PURE__ */ jsx("button", { onClick: onUpload, className: "copilotKitInputControlButton", children: context.icons.uploadIcon }),
75
- /* @__PURE__ */ jsx("div", { style: { flexGrow: 1 } }),
76
- showPushToTalk && /* @__PURE__ */ jsx(
77
- "button",
78
- {
79
- onClick: () => setPushToTalkState(pushToTalkState === "idle" ? "recording" : "transcribing"),
80
- className: pushToTalkState === "recording" ? "copilotKitInputControlButton copilotKitPushToTalkRecording" : "copilotKitInputControlButton",
81
- children: context.icons.pushToTalkIcon
82
- }
83
- ),
84
- /* @__PURE__ */ jsx(
85
- "button",
86
- {
87
- disabled: sendDisabled,
88
- onClick: isInProgress ? onStop : send,
89
- "data-copilotkit-in-progress": inProgress,
90
- "data-test-id": inProgress ? "copilot-chat-request-in-progress" : "copilot-chat-ready",
91
- className: "copilotKitInputControlButton",
92
- children: buttonIcon
93
- }
94
- )
95
- ] })
96
- ] }) });
97
- };
98
-
99
- export {
100
- Input
101
- };
102
- //# sourceMappingURL=chunk-IWBARPUZ.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/components/chat/Input.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from \"react\";\nimport { InputProps } from \"./props\";\nimport { useChatContext } from \"./ChatContext\";\nimport AutoResizingTextarea from \"./Textarea\";\nimport { usePushToTalk } from \"../../hooks/use-push-to-talk\";\nimport { useCopilotContext } from \"@copilotkit/react-core\";\n\nconst MAX_NEWLINES = 6;\n\nexport const Input = ({ inProgress, onSend, isVisible = false, onStop, onUpload }: InputProps) => {\n const context = useChatContext();\n const copilotContext = useCopilotContext();\n\n const pushToTalkConfigured =\n copilotContext.copilotApiConfig.textToSpeechUrl !== undefined &&\n copilotContext.copilotApiConfig.transcribeAudioUrl !== undefined;\n\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n\n const handleDivClick = (event: React.MouseEvent<HTMLDivElement>) => {\n const target = event.target as HTMLElement;\n\n // If the user clicked a button or inside a button, don't focus the textarea\n if (target.closest(\"button\")) return;\n\n // If the user clicked the textarea, do nothing (it's already focused)\n if (target.tagName === \"TEXTAREA\") return;\n\n // Otherwise, focus the textarea\n textareaRef.current?.focus();\n };\n\n const [text, setText] = useState(\"\");\n const send = () => {\n if (inProgress) return;\n onSend(text);\n setText(\"\");\n\n textareaRef.current?.focus();\n };\n\n // tylerslaton:\n //\n // This scrolls CopilotKit into view always. Reading the commit history, it was likely\n // added to fix a bug but it is causing issues now.\n //\n // For the future, if we want this behavior again, we will need to find a way to do it without\n // forcing CopilotKit to always be in view. This code causes this because focusing an element\n // in most browsers will scroll that element into view.\n //\n // useEffect(() => {\n // if (isVisible) {\n // textareaRef.current?.focus();\n // }\n // }, [isVisible]);\n\n const { pushToTalkState, setPushToTalkState } = usePushToTalk({\n sendFunction: onSend,\n inProgress,\n });\n\n const isInProgress = inProgress || pushToTalkState === \"transcribing\";\n const buttonIcon = isInProgress ? context.icons.stopIcon : context.icons.sendIcon;\n const showPushToTalk =\n pushToTalkConfigured &&\n (pushToTalkState === \"idle\" || pushToTalkState === \"recording\") &&\n !inProgress;\n\n const canSend = () => {\n const interruptEvent = copilotContext.langGraphInterruptAction?.event;\n const interruptInProgress =\n interruptEvent?.name === \"LangGraphInterruptEvent\" && !interruptEvent?.response;\n\n return (\n (isInProgress || (!isInProgress && text.trim().length > 0)) &&\n pushToTalkState === \"idle\" &&\n !interruptInProgress\n );\n };\n\n const sendDisabled = !canSend();\n\n return (\n <div className=\"copilotKitInputContainer\">\n <div className=\"copilotKitInput\" onClick={handleDivClick}>\n <AutoResizingTextarea\n ref={textareaRef}\n placeholder={context.labels.placeholder}\n autoFocus={false}\n maxRows={MAX_NEWLINES}\n value={text}\n onChange={(event) => setText(event.target.value)}\n onKeyDown={(event) => {\n if (event.key === \"Enter\" && !event.shiftKey) {\n event.preventDefault();\n if (canSend()) {\n send();\n }\n }\n }}\n />\n <div className=\"copilotKitInputControls\">\n {onUpload && (\n <button onClick={onUpload} className=\"copilotKitInputControlButton\">\n {context.icons.uploadIcon}\n </button>\n )}\n\n <div style={{ flexGrow: 1 }} />\n\n {showPushToTalk && (\n <button\n onClick={() =>\n setPushToTalkState(pushToTalkState === \"idle\" ? \"recording\" : \"transcribing\")\n }\n className={\n pushToTalkState === \"recording\"\n ? \"copilotKitInputControlButton copilotKitPushToTalkRecording\"\n : \"copilotKitInputControlButton\"\n }\n >\n {context.icons.pushToTalkIcon}\n </button>\n )}\n <button\n disabled={sendDisabled}\n onClick={isInProgress ? onStop : send}\n data-copilotkit-in-progress={inProgress}\n data-test-id={inProgress ? \"copilot-chat-request-in-progress\" : \"copilot-chat-ready\"}\n className=\"copilotKitInputControlButton\"\n >\n {buttonIcon}\n </button>\n </div>\n </div>\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;AAAA,SAA2B,QAAQ,gBAAgB;AAKnD,SAAS,yBAAyB;AAgF1B,cAgBA,YAhBA;AA9ER,IAAM,eAAe;AAEd,IAAM,QAAQ,CAAC,EAAE,YAAY,QAAQ,YAAY,OAAO,QAAQ,SAAS,MAAkB;AAChG,QAAM,UAAU,eAAe;AAC/B,QAAM,iBAAiB,kBAAkB;AAEzC,QAAM,uBACJ,eAAe,iBAAiB,oBAAoB,UACpD,eAAe,iBAAiB,uBAAuB;AAEzD,QAAM,cAAc,OAA4B,IAAI;AAEpD,QAAM,iBAAiB,CAAC,UAA4C;AAnBtE;AAoBI,UAAM,SAAS,MAAM;AAGrB,QAAI,OAAO,QAAQ,QAAQ;AAAG;AAG9B,QAAI,OAAO,YAAY;AAAY;AAGnC,sBAAY,YAAZ,mBAAqB;AAAA,EACvB;AAEA,QAAM,CAAC,MAAM,OAAO,IAAI,SAAS,EAAE;AACnC,QAAM,OAAO,MAAM;AAjCrB;AAkCI,QAAI;AAAY;AAChB,WAAO,IAAI;AACX,YAAQ,EAAE;AAEV,sBAAY,YAAZ,mBAAqB;AAAA,EACvB;AAiBA,QAAM,EAAE,iBAAiB,mBAAmB,IAAI,cAAc;AAAA,IAC5D,cAAc;AAAA,IACd;AAAA,EACF,CAAC;AAED,QAAM,eAAe,cAAc,oBAAoB;AACvD,QAAM,aAAa,eAAe,QAAQ,MAAM,WAAW,QAAQ,MAAM;AACzE,QAAM,iBACJ,yBACC,oBAAoB,UAAU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A;AAAA,MACH;AAAA,OACF;AAAA,KACF,GACF;AAEJ;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/components/chat/Window.tsx"],"sourcesContent":["import React, { useCallback, useEffect } from \"react\";\nimport { WindowProps } from \"./props\";\nimport { useChatContext } from \"./ChatContext\";\nimport { useCopilotContext } from \"@copilotkit/react-core\";\nimport { useDarkMode } from \"../../hooks/use-dark-mode\";\n\nexport const Window = ({\n children,\n clickOutsideToClose,\n shortcut,\n hitEscapeToClose,\n}: WindowProps) => {\n const windowRef = React.useRef<HTMLDivElement>(null);\n const context = useCopilotContext();\n\n const { open, setOpen } = useChatContext();\n\n const handleClickOutside = useCallback(\n (event: MouseEvent) => {\n if (!clickOutsideToClose) {\n return;\n }\n\n const parentElement = windowRef.current?.parentElement;\n\n let className = \"\";\n if (event.target instanceof HTMLElement) {\n className = event.target.className;\n }\n\n if (\n open &&\n parentElement &&\n !parentElement.contains(event.target as any) &&\n // prevent closing the window when clicking on the debug menu\n !className.includes(\"copilotKitDebugMenu\")\n ) {\n setOpen(false);\n }\n },\n [clickOutsideToClose, open, setOpen],\n );\n\n const handleKeyDown = useCallback(\n (event: KeyboardEvent) => {\n const target = event.target as HTMLElement;\n const isInput =\n target.tagName === \"INPUT\" ||\n target.tagName === \"SELECT\" ||\n target.tagName === \"TEXTAREA\" ||\n target.isContentEditable;\n\n const isDescendantOfWrapper = windowRef.current?.contains(target);\n\n if (\n open &&\n event.key === \"Escape\" &&\n (!isInput || isDescendantOfWrapper) &&\n hitEscapeToClose\n ) {\n setOpen(false);\n } else if (\n event.key === shortcut &&\n ((isMacOS() && event.metaKey) || (!isMacOS() && event.ctrlKey)) &&\n (!isInput || isDescendantOfWrapper)\n ) {\n setOpen(!open);\n }\n },\n [hitEscapeToClose, shortcut, open, setOpen],\n );\n\n const adjustForMobile = useCallback(() => {\n const copilotKitWindow = windowRef.current;\n const vv = window.visualViewport;\n if (!copilotKitWindow || !vv) {\n return;\n }\n\n if (window.innerWidth < 640 && open) {\n copilotKitWindow.style.height = `${vv.height}px`;\n copilotKitWindow.style.left = `${vv.offsetLeft}px`;\n copilotKitWindow.style.top = `${vv.offsetTop}px`;\n\n document.body.style.position = \"fixed\";\n document.body.style.width = \"100%\";\n document.body.style.height = `${window.innerHeight}px`;\n document.body.style.overflow = \"hidden\";\n document.body.style.touchAction = \"none\";\n\n // Prevent scrolling on iOS\n document.body.addEventListener(\"touchmove\", preventScroll, {\n passive: false,\n });\n } else {\n copilotKitWindow.style.height = \"\";\n copilotKitWindow.style.left = \"\";\n copilotKitWindow.style.top = \"\";\n document.body.style.position = \"\";\n document.body.style.height = \"\";\n document.body.style.width = \"\";\n document.body.style.overflow = \"\";\n document.body.style.top = \"\";\n document.body.style.touchAction = \"\";\n\n document.body.removeEventListener(\"touchmove\", preventScroll);\n }\n }, [open]);\n\n useEffect(() => {\n document.addEventListener(\"mousedown\", handleClickOutside);\n document.addEventListener(\"keydown\", handleKeyDown);\n if (window.visualViewport) {\n window.visualViewport.addEventListener(\"resize\", adjustForMobile);\n adjustForMobile();\n }\n\n return () => {\n document.removeEventListener(\"mousedown\", handleClickOutside);\n document.removeEventListener(\"keydown\", handleKeyDown);\n if (window.visualViewport) {\n window.visualViewport.removeEventListener(\"resize\", adjustForMobile);\n }\n };\n }, [adjustForMobile, handleClickOutside, handleKeyDown]);\n\n const isDark = useDarkMode();\n\n const showPoweredBy = !context.copilotApiConfig?.publicApiKey;\n const poweredByStyle = {\n visibility: \"visible\",\n display: \"block\",\n position: \"static\",\n textAlign: \"center\",\n fontSize: \"12px\",\n padding: \"3px 0\",\n color: isDark ? \"rgb(69, 69, 69)\" : \"rgb(214, 214, 214)\",\n };\n\n return (\n <div\n className={`copilotKitWindow ${showPoweredBy ? \" poweredByContainer\" : \"\"} ${open ? \" open\" : \"\"}`}\n ref={windowRef}\n >\n {children}\n {showPoweredBy && (\n // @ts-expect-error -- expecting position not to be a string, but it can be.\n <p className=\"poweredBy\" style={poweredByStyle}>\n Powered by CopilotKit\n </p>\n )}\n </div>\n );\n};\n\nconst preventScroll = (event: TouchEvent): void => {\n let targetElement = event.target as Element;\n\n // Function to check if the target has the parent with a given class\n const hasParentWithClass = (element: Element, className: string): boolean => {\n while (element && element !== document.body) {\n if (element.classList.contains(className)) {\n return true;\n }\n element = element.parentElement!;\n }\n return false;\n };\n\n // Check if the target of the touch event is inside an element with the 'copilotKitMessages' class\n if (!hasParentWithClass(targetElement, \"copilotKitMessages\")) {\n event.preventDefault();\n }\n};\n\nfunction isMacOS() {\n return /Mac|iMac|Macintosh/i.test(navigator.userAgent);\n}\n"],"mappings":";;;;;;;;AAAA,OAAO,SAAS,aAAa,iBAAiB;AAG9C,SAAS,yBAAyB;AAyI9B,SAOI,KAPJ;AAtIG,IAAM,SAAS,CAAC;AAAA,EACrB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAmB;AAXnB;AAYE,QAAM,YAAY,MAAM,OAAuB,IAAI;AACnD,QAAM,UAAU,kBAAkB;AAElC,QAAM,EAAE,MAAM,QAAQ,IAAI,eAAe;AAEzC,QAAM,qBAAqB;AAAA,IACzB,CAAC,UAAsB;AAlB3B,UAAAA;AAmBM,UAAI,CAAC,qBAAqB;AACxB;AAAA,MACF;AAEA,YAAM,iBAAgBA,MAAA,UAAU,YAAV,gBAAAA,IAAmB;AAEzC,UAAI,YAAY;AAChB,UAAI,MAAM,kBAAkB,aAAa;AACvC,oBAAY,MAAM,OAAO;AAAA,MAC3B;AAEA,UACE,QACA,iBACA,CAAC,cAAc,SAAS,MAAM,MAAa;AAAA,MAE3C,CAAC,UAAU,SAAS,qBAAqB,GACzC;AACA,gBAAQ,KAAK;AAAA,MACf;AAAA,IACF;AAAA,IACA,CAAC,qBAAqB,MAAM,OAAO;AAAA,EACrC;AAEA,QAAM,gBAAgB;AAAA,IACpB,CAAC,UAAyB;AA5C9B,UAAAA;AA6CM,YAAM,SAAS,MAAM;AACrB,YAAM,UACJ,OAAO,YAAY,WACnB,OAA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