@copilotkit/react-ui 1.8.6 → 1.8.7

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 (149) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/{chunk-Q2YY2NX3.mjs → chunk-24TDU7MY.mjs} +2 -2
  3. package/dist/{chunk-XNQO5AZZ.mjs → chunk-ABHUX6T6.mjs} +2 -2
  4. package/dist/{chunk-QJKMOGWN.mjs → chunk-BDNHZ3GW.mjs} +4 -3
  5. package/dist/chunk-BDNHZ3GW.mjs.map +1 -0
  6. package/dist/{chunk-NMNC4ROZ.mjs → chunk-DSQGQJI4.mjs} +2 -2
  7. package/dist/{chunk-HEIDCT7I.mjs → chunk-HWMFMBJC.mjs} +2 -2
  8. package/dist/chunk-HWMFMBJC.mjs.map +1 -0
  9. package/dist/{chunk-UN2E3HCK.mjs → chunk-IEMQ2SQW.mjs} +6 -4
  10. package/dist/chunk-IEMQ2SQW.mjs.map +1 -0
  11. package/dist/{chunk-ZY25LVYR.mjs → chunk-IJADIQAR.mjs} +20 -2
  12. package/dist/chunk-IJADIQAR.mjs.map +1 -0
  13. package/dist/{chunk-X6EFGEBJ.mjs → chunk-JOL7NS2W.mjs} +2 -2
  14. package/dist/{chunk-PCTCOQK2.mjs → chunk-KENCH7RN.mjs} +2 -2
  15. package/dist/{chunk-ZLRUNNS7.mjs → chunk-O34Z4XM2.mjs} +170 -30
  16. package/dist/chunk-O34Z4XM2.mjs.map +1 -0
  17. package/dist/{chunk-5M7ODWKH.mjs → chunk-OZXUB3V7.mjs} +3 -3
  18. package/dist/chunk-PLHTVHUW.mjs +82 -0
  19. package/dist/chunk-PLHTVHUW.mjs.map +1 -0
  20. package/dist/{chunk-62QMTKMJ.mjs → chunk-POWCBXRY.mjs} +3 -3
  21. package/dist/chunk-PXEVB7IK.mjs +1 -0
  22. package/dist/{chunk-HIORSNVD.mjs → chunk-Q2NFQTCQ.mjs} +2 -2
  23. package/dist/chunk-SLTG4L62.mjs +78 -0
  24. package/dist/chunk-SLTG4L62.mjs.map +1 -0
  25. package/dist/{chunk-SMJ3QQCE.mjs → chunk-T7N77F5Y.mjs} +2 -2
  26. package/dist/{chunk-YOEL33HG.mjs → chunk-UFN2VWSR.mjs} +2 -2
  27. package/dist/{chunk-2OTVZXDX.mjs → chunk-UH2UFL5W.mjs} +3 -3
  28. package/dist/{chunk-D5XIJNXQ.mjs → chunk-VGPQYMKJ.mjs} +8 -8
  29. package/dist/{chunk-WNC6OCIB.mjs → chunk-XFCMZH2H.mjs} +2 -2
  30. package/dist/{chunk-ORSMX3SE.mjs → chunk-XWG3L6QC.mjs} +15 -1
  31. package/dist/{chunk-ORSMX3SE.mjs.map → chunk-XWG3L6QC.mjs.map} +1 -1
  32. package/dist/{chunk-TOQ7P4DO.mjs → chunk-XZNY26GH.mjs} +2 -2
  33. package/dist/{chunk-GOAED4H6.mjs → chunk-Y7UO3RPW.mjs} +10 -10
  34. package/dist/components/chat/Button.js.map +1 -1
  35. package/dist/components/chat/Button.mjs +3 -3
  36. package/dist/components/chat/Chat.d.ts +23 -3
  37. package/dist/components/chat/Chat.js +341 -30
  38. package/dist/components/chat/Chat.js.map +1 -1
  39. package/dist/components/chat/Chat.mjs +16 -14
  40. package/dist/components/chat/ChatContext.d.ts +5 -0
  41. package/dist/components/chat/ChatContext.js +15 -1
  42. package/dist/components/chat/ChatContext.js.map +1 -1
  43. package/dist/components/chat/ChatContext.mjs +2 -2
  44. package/dist/components/chat/CodeBlock.js.map +1 -1
  45. package/dist/components/chat/CodeBlock.mjs +2 -2
  46. package/dist/components/chat/Header.js.map +1 -1
  47. package/dist/components/chat/Header.mjs +5 -5
  48. package/dist/components/chat/Icons.d.ts +2 -1
  49. package/dist/components/chat/Icons.js +17 -2
  50. package/dist/components/chat/Icons.js.map +1 -1
  51. package/dist/components/chat/Icons.mjs +5 -3
  52. package/dist/components/chat/ImageUploadQueue.d.ts +13 -0
  53. package/dist/components/chat/ImageUploadQueue.js +106 -0
  54. package/dist/components/chat/ImageUploadQueue.js.map +1 -0
  55. package/dist/components/chat/ImageUploadQueue.mjs +8 -0
  56. package/dist/components/chat/ImageUploadQueue.mjs.map +1 -0
  57. package/dist/components/chat/Input.d.ts +1 -1
  58. package/dist/components/chat/Input.js +2 -1
  59. package/dist/components/chat/Input.js.map +1 -1
  60. package/dist/components/chat/Input.mjs +3 -3
  61. package/dist/components/chat/Markdown.js.map +1 -1
  62. package/dist/components/chat/Markdown.mjs +3 -3
  63. package/dist/components/chat/Messages.d.ts +1 -1
  64. package/dist/components/chat/Messages.js +18 -0
  65. package/dist/components/chat/Messages.js.map +1 -1
  66. package/dist/components/chat/Messages.mjs +3 -3
  67. package/dist/components/chat/Modal.js +348 -37
  68. package/dist/components/chat/Modal.js.map +1 -1
  69. package/dist/components/chat/Modal.mjs +22 -20
  70. package/dist/components/chat/Popup.js +350 -39
  71. package/dist/components/chat/Popup.js.map +1 -1
  72. package/dist/components/chat/Popup.mjs +23 -21
  73. package/dist/components/chat/Sidebar.js +350 -39
  74. package/dist/components/chat/Sidebar.js.map +1 -1
  75. package/dist/components/chat/Sidebar.mjs +23 -21
  76. package/dist/components/chat/Suggestion.js.map +1 -1
  77. package/dist/components/chat/Suggestion.mjs +2 -2
  78. package/dist/components/chat/Window.js.map +1 -1
  79. package/dist/components/chat/Window.mjs +3 -3
  80. package/dist/components/chat/index.d.ts +1 -0
  81. package/dist/components/chat/index.js +354 -41
  82. package/dist/components/chat/index.js.map +1 -1
  83. package/dist/components/chat/index.mjs +30 -25
  84. package/dist/components/chat/messages/AssistantMessage.js.map +1 -1
  85. package/dist/components/chat/messages/AssistantMessage.mjs +5 -5
  86. package/dist/components/chat/messages/RenderActionExecutionMessage.js.map +1 -1
  87. package/dist/components/chat/messages/RenderActionExecutionMessage.mjs +6 -6
  88. package/dist/components/chat/messages/RenderAgentStateMessage.js.map +1 -1
  89. package/dist/components/chat/messages/RenderAgentStateMessage.mjs +6 -6
  90. package/dist/components/chat/messages/RenderImageMessage.d.ts +7 -0
  91. package/dist/components/chat/messages/RenderImageMessage.js +774 -0
  92. package/dist/components/chat/messages/RenderImageMessage.js.map +1 -0
  93. package/dist/components/chat/messages/RenderImageMessage.mjs +15 -0
  94. package/dist/components/chat/messages/RenderImageMessage.mjs.map +1 -0
  95. package/dist/components/chat/messages/RenderResultMessage.js.map +1 -1
  96. package/dist/components/chat/messages/RenderResultMessage.mjs +6 -6
  97. package/dist/components/chat/messages/RenderTextMessage.js +1 -1
  98. package/dist/components/chat/messages/RenderTextMessage.js.map +1 -1
  99. package/dist/components/chat/messages/RenderTextMessage.mjs +7 -7
  100. package/dist/components/chat/messages/UserMessage.js +1 -1
  101. package/dist/components/chat/messages/UserMessage.js.map +1 -1
  102. package/dist/components/chat/messages/UserMessage.mjs +1 -1
  103. package/dist/components/chat/props.d.ts +3 -0
  104. package/dist/components/chat/props.js.map +1 -1
  105. package/dist/components/dev-console/console.js.map +1 -1
  106. package/dist/components/dev-console/console.mjs +3 -3
  107. package/dist/components/dev-console/index.js.map +1 -1
  108. package/dist/components/dev-console/index.mjs +3 -3
  109. package/dist/components/index.d.ts +1 -0
  110. package/dist/components/index.js +354 -41
  111. package/dist/components/index.js.map +1 -1
  112. package/dist/components/index.mjs +30 -25
  113. package/dist/index.d.ts +1 -0
  114. package/dist/index.js +354 -41
  115. package/dist/index.js.map +1 -1
  116. package/dist/index.mjs +30 -25
  117. package/package.json +6 -6
  118. package/src/components/chat/Chat.tsx +198 -18
  119. package/src/components/chat/ChatContext.tsx +7 -0
  120. package/src/components/chat/Icons.tsx +14 -0
  121. package/src/components/chat/ImageUploadQueue.tsx +77 -0
  122. package/src/components/chat/Input.tsx +8 -1
  123. package/src/components/chat/Messages.tsx +17 -0
  124. package/src/components/chat/index.tsx +1 -0
  125. package/src/components/chat/messages/RenderImageMessage.tsx +64 -0
  126. package/src/components/chat/messages/UserMessage.tsx +5 -1
  127. package/src/components/chat/props.ts +3 -0
  128. package/dist/chunk-HEIDCT7I.mjs.map +0 -1
  129. package/dist/chunk-QJKMOGWN.mjs.map +0 -1
  130. package/dist/chunk-SQMEPWVT.mjs +0 -1
  131. package/dist/chunk-UN2E3HCK.mjs.map +0 -1
  132. package/dist/chunk-ZLRUNNS7.mjs.map +0 -1
  133. package/dist/chunk-ZY25LVYR.mjs.map +0 -1
  134. /package/dist/{chunk-Q2YY2NX3.mjs.map → chunk-24TDU7MY.mjs.map} +0 -0
  135. /package/dist/{chunk-XNQO5AZZ.mjs.map → chunk-ABHUX6T6.mjs.map} +0 -0
  136. /package/dist/{chunk-NMNC4ROZ.mjs.map → chunk-DSQGQJI4.mjs.map} +0 -0
  137. /package/dist/{chunk-X6EFGEBJ.mjs.map → chunk-JOL7NS2W.mjs.map} +0 -0
  138. /package/dist/{chunk-PCTCOQK2.mjs.map → chunk-KENCH7RN.mjs.map} +0 -0
  139. /package/dist/{chunk-5M7ODWKH.mjs.map → chunk-OZXUB3V7.mjs.map} +0 -0
  140. /package/dist/{chunk-62QMTKMJ.mjs.map → chunk-POWCBXRY.mjs.map} +0 -0
  141. /package/dist/{chunk-SQMEPWVT.mjs.map → chunk-PXEVB7IK.mjs.map} +0 -0
  142. /package/dist/{chunk-HIORSNVD.mjs.map → chunk-Q2NFQTCQ.mjs.map} +0 -0
  143. /package/dist/{chunk-SMJ3QQCE.mjs.map → chunk-T7N77F5Y.mjs.map} +0 -0
  144. /package/dist/{chunk-YOEL33HG.mjs.map → chunk-UFN2VWSR.mjs.map} +0 -0
  145. /package/dist/{chunk-2OTVZXDX.mjs.map → chunk-UH2UFL5W.mjs.map} +0 -0
  146. /package/dist/{chunk-D5XIJNXQ.mjs.map → chunk-VGPQYMKJ.mjs.map} +0 -0
  147. /package/dist/{chunk-WNC6OCIB.mjs.map → chunk-XFCMZH2H.mjs.map} +0 -0
  148. /package/dist/{chunk-TOQ7P4DO.mjs.map → chunk-XZNY26GH.mjs.map} +0 -0
  149. /package/dist/{chunk-GOAED4H6.mjs.map → chunk-Y7UO3RPW.mjs.map} +0 -0
@@ -0,0 +1,774 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __defProps = Object.defineProperties;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
9
+ var __getProtoOf = Object.getPrototypeOf;
10
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
11
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
12
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
13
+ var __spreadValues = (a, b) => {
14
+ for (var prop in b || (b = {}))
15
+ if (__hasOwnProp.call(b, prop))
16
+ __defNormalProp(a, prop, b[prop]);
17
+ if (__getOwnPropSymbols)
18
+ for (var prop of __getOwnPropSymbols(b)) {
19
+ if (__propIsEnum.call(b, prop))
20
+ __defNormalProp(a, prop, b[prop]);
21
+ }
22
+ return a;
23
+ };
24
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
25
+ var __objRest = (source, exclude) => {
26
+ var target = {};
27
+ for (var prop in source)
28
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
29
+ target[prop] = source[prop];
30
+ if (source != null && __getOwnPropSymbols)
31
+ for (var prop of __getOwnPropSymbols(source)) {
32
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
33
+ target[prop] = source[prop];
34
+ }
35
+ return target;
36
+ };
37
+ var __export = (target, all) => {
38
+ for (var name in all)
39
+ __defProp(target, name, { get: all[name], enumerable: true });
40
+ };
41
+ var __copyProps = (to, from, except, desc) => {
42
+ if (from && typeof from === "object" || typeof from === "function") {
43
+ for (let key of __getOwnPropNames(from))
44
+ if (!__hasOwnProp.call(to, key) && key !== except)
45
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
46
+ }
47
+ return to;
48
+ };
49
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
50
+ // If the importer is in node compatibility mode or this is not an ESM
51
+ // file that has been converted to a CommonJS file using a Babel-
52
+ // compatible transform (i.e. "__esModule" has not been set), then set
53
+ // "default" to the CommonJS "module.exports" for node compatibility.
54
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
55
+ mod
56
+ ));
57
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
58
+
59
+ // src/components/chat/messages/RenderImageMessage.tsx
60
+ var RenderImageMessage_exports = {};
61
+ __export(RenderImageMessage_exports, {
62
+ RenderImageMessage: () => RenderImageMessage
63
+ });
64
+ module.exports = __toCommonJS(RenderImageMessage_exports);
65
+
66
+ // src/components/chat/messages/UserMessage.tsx
67
+ var import_jsx_runtime = require("react/jsx-runtime");
68
+ var UserMessage = (props) => {
69
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "copilotKitMessage copilotKitUserMessage", children: props.subComponent || props.message });
70
+ };
71
+
72
+ // src/components/chat/ChatContext.tsx
73
+ var import_react = __toESM(require("react"));
74
+
75
+ // src/components/chat/Icons.tsx
76
+ var import_jsx_runtime2 = require("react/jsx-runtime");
77
+ var CopyIcon = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
78
+ "svg",
79
+ {
80
+ xmlns: "http://www.w3.org/2000/svg",
81
+ fill: "none",
82
+ viewBox: "0 0 24 24",
83
+ strokeWidth: "2",
84
+ stroke: "currentColor",
85
+ width: "16",
86
+ height: "16",
87
+ style: { minWidth: "16px", minHeight: "16px" },
88
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
89
+ "path",
90
+ {
91
+ strokeLinecap: "round",
92
+ strokeLinejoin: "round",
93
+ d: "M15.75 17.25v3.375c0 .621-.504 1.125-1.125 1.125h-9.75a1.125 1.125 0 01-1.125-1.125V7.875c0-.621.504-1.125 1.125-1.125H6.75a9.06 9.06 0 011.5.124m7.5 10.376h3.375c.621 0 1.125-.504 1.125-1.125V11.25c0-4.46-3.243-8.161-7.5-8.876a9.06 9.06 0 00-1.5-.124H9.375c-.621 0-1.125.504-1.125 1.125v3.5m7.5 10.375H9.375a1.125 1.125 0 01-1.125-1.125v-9.25m12 6.625v-1.875a3.375 3.375 0 00-3.375-3.375h-1.5a1.125 1.125 0 01-1.125-1.125v-1.5a3.375 3.375 0 00-3.375-3.375H9.75"
94
+ }
95
+ )
96
+ }
97
+ );
98
+ var DownloadIcon = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
99
+ "svg",
100
+ {
101
+ xmlns: "http://www.w3.org/2000/svg",
102
+ fill: "none",
103
+ viewBox: "0 0 24 24",
104
+ strokeWidth: "2",
105
+ stroke: "currentColor",
106
+ width: "16",
107
+ height: "16",
108
+ style: { minWidth: "16px", minHeight: "16px" },
109
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
110
+ "path",
111
+ {
112
+ strokeLinecap: "round",
113
+ strokeLinejoin: "round",
114
+ d: "M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5M16.5 12L12 16.5m0 0L7.5 12m4.5 4.5V3"
115
+ }
116
+ )
117
+ }
118
+ );
119
+ var CheckIcon = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
120
+ "svg",
121
+ {
122
+ xmlns: "http://www.w3.org/2000/svg",
123
+ fill: "none",
124
+ viewBox: "0 0 24 24",
125
+ strokeWidth: "2",
126
+ stroke: "currentColor",
127
+ width: "16",
128
+ height: "16",
129
+ style: { minWidth: "16px", minHeight: "16px" },
130
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M4.5 12.75l6 6 9-13.5" })
131
+ }
132
+ );
133
+
134
+ // src/components/chat/ChatContext.tsx
135
+ var import_jsx_runtime3 = require("react/jsx-runtime");
136
+ var ChatContext = import_react.default.createContext(void 0);
137
+ function useChatContext() {
138
+ const context = import_react.default.useContext(ChatContext);
139
+ if (context === void 0) {
140
+ throw new Error(
141
+ "Context not found. Did you forget to wrap your app in a <ChatContextProvider> component?"
142
+ );
143
+ }
144
+ return context;
145
+ }
146
+
147
+ // src/components/chat/Markdown.tsx
148
+ var import_react3 = require("react");
149
+ var import_react_markdown = __toESM(require("react-markdown"));
150
+
151
+ // src/components/chat/CodeBlock.tsx
152
+ var import_react2 = require("react");
153
+ var import_react_syntax_highlighter = require("react-syntax-highlighter");
154
+
155
+ // src/hooks/use-copy-to-clipboard.tsx
156
+ var React2 = __toESM(require("react"));
157
+ function useCopyToClipboard({ timeout = 2e3 }) {
158
+ const [isCopied, setIsCopied] = React2.useState(false);
159
+ const copyToClipboard = (value) => {
160
+ var _a;
161
+ if (typeof window === "undefined" || !((_a = navigator.clipboard) == null ? void 0 : _a.writeText)) {
162
+ return;
163
+ }
164
+ if (!value) {
165
+ return;
166
+ }
167
+ navigator.clipboard.writeText(value).then(() => {
168
+ setIsCopied(true);
169
+ setTimeout(() => {
170
+ setIsCopied(false);
171
+ }, timeout);
172
+ });
173
+ };
174
+ return { isCopied, copyToClipboard };
175
+ }
176
+
177
+ // src/components/chat/CodeBlock.tsx
178
+ var import_jsx_runtime4 = require("react/jsx-runtime");
179
+ var programmingLanguages = {
180
+ javascript: ".js",
181
+ python: ".py",
182
+ java: ".java",
183
+ c: ".c",
184
+ cpp: ".cpp",
185
+ "c++": ".cpp",
186
+ "c#": ".cs",
187
+ ruby: ".rb",
188
+ php: ".php",
189
+ swift: ".swift",
190
+ "objective-c": ".m",
191
+ kotlin: ".kt",
192
+ typescript: ".ts",
193
+ go: ".go",
194
+ perl: ".pl",
195
+ rust: ".rs",
196
+ scala: ".scala",
197
+ haskell: ".hs",
198
+ lua: ".lua",
199
+ shell: ".sh",
200
+ sql: ".sql",
201
+ html: ".html",
202
+ css: ".css"
203
+ // add more file extensions here, make sure the key is same as language prop in CodeBlock.tsx component
204
+ };
205
+ var generateRandomString = (length, lowercase = false) => {
206
+ const chars = "ABCDEFGHJKLMNPQRSTUVWXY3456789";
207
+ let result = "";
208
+ for (let i = 0; i < length; i++) {
209
+ result += chars.charAt(Math.floor(Math.random() * chars.length));
210
+ }
211
+ return lowercase ? result.toLowerCase() : result;
212
+ };
213
+ var CodeBlock = (0, import_react2.memo)(({ language, value }) => {
214
+ const { isCopied, copyToClipboard } = useCopyToClipboard({ timeout: 2e3 });
215
+ const downloadAsFile = () => {
216
+ if (typeof window === "undefined") {
217
+ return;
218
+ }
219
+ const fileExtension = programmingLanguages[language] || ".file";
220
+ const suggestedFileName = `file-${generateRandomString(3, true)}${fileExtension}`;
221
+ const fileName = window.prompt("Enter file name", suggestedFileName);
222
+ if (!fileName) {
223
+ return;
224
+ }
225
+ const blob = new Blob([value], { type: "text/plain" });
226
+ const url = URL.createObjectURL(blob);
227
+ const link = document.createElement("a");
228
+ link.download = fileName;
229
+ link.href = url;
230
+ link.style.display = "none";
231
+ document.body.appendChild(link);
232
+ link.click();
233
+ document.body.removeChild(link);
234
+ URL.revokeObjectURL(url);
235
+ };
236
+ const onCopy = () => {
237
+ if (isCopied)
238
+ return;
239
+ copyToClipboard(value);
240
+ };
241
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "copilotKitCodeBlock", children: [
242
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "copilotKitCodeBlockToolbar", children: [
243
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "copilotKitCodeBlockToolbarLanguage", children: language }),
244
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "copilotKitCodeBlockToolbarButtons", children: [
245
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { className: "copilotKitCodeBlockToolbarButton", onClick: downloadAsFile, children: DownloadIcon }),
246
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { className: "copilotKitCodeBlockToolbarButton", onClick: onCopy, children: isCopied ? CheckIcon : CopyIcon })
247
+ ] })
248
+ ] }),
249
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
250
+ import_react_syntax_highlighter.Prism,
251
+ {
252
+ language,
253
+ style: highlightStyle,
254
+ PreTag: "div",
255
+ customStyle: {
256
+ margin: 0,
257
+ borderBottomLeftRadius: "0.375rem",
258
+ borderBottomRightRadius: "0.375rem"
259
+ },
260
+ children: value
261
+ }
262
+ )
263
+ ] });
264
+ });
265
+ CodeBlock.displayName = "CodeBlock";
266
+ var highlightStyle = {
267
+ 'pre[class*="language-"]': {
268
+ color: "#d4d4d4",
269
+ fontSize: "13px",
270
+ textShadow: "none",
271
+ fontFamily: 'Menlo, Monaco, Consolas, "Andale Mono", "Ubuntu Mono", "Courier New", monospace',
272
+ direction: "ltr",
273
+ textAlign: "left",
274
+ whiteSpace: "pre",
275
+ wordSpacing: "normal",
276
+ wordBreak: "normal",
277
+ lineHeight: "1.5",
278
+ MozTabSize: "4",
279
+ OTabSize: "4",
280
+ tabSize: "4",
281
+ WebkitHyphens: "none",
282
+ MozHyphens: "none",
283
+ msHyphens: "none",
284
+ hyphens: "none",
285
+ padding: "1em",
286
+ margin: ".5em 0",
287
+ overflow: "auto",
288
+ background: "#1e1e1e"
289
+ },
290
+ 'code[class*="language-"]': {
291
+ color: "#d4d4d4",
292
+ fontSize: "13px",
293
+ textShadow: "none",
294
+ fontFamily: 'Menlo, Monaco, Consolas, "Andale Mono", "Ubuntu Mono", "Courier New", monospace',
295
+ direction: "ltr",
296
+ textAlign: "left",
297
+ whiteSpace: "pre",
298
+ wordSpacing: "normal",
299
+ wordBreak: "normal",
300
+ lineHeight: "1.5",
301
+ MozTabSize: "4",
302
+ OTabSize: "4",
303
+ tabSize: "4",
304
+ WebkitHyphens: "none",
305
+ MozHyphens: "none",
306
+ msHyphens: "none",
307
+ hyphens: "none"
308
+ },
309
+ 'pre[class*="language-"]::selection': {
310
+ textShadow: "none",
311
+ background: "#264F78"
312
+ },
313
+ 'code[class*="language-"]::selection': {
314
+ textShadow: "none",
315
+ background: "#264F78"
316
+ },
317
+ 'pre[class*="language-"] *::selection': {
318
+ textShadow: "none",
319
+ background: "#264F78"
320
+ },
321
+ 'code[class*="language-"] *::selection': {
322
+ textShadow: "none",
323
+ background: "#264F78"
324
+ },
325
+ ':not(pre) > code[class*="language-"]': {
326
+ padding: ".1em .3em",
327
+ borderRadius: ".3em",
328
+ color: "#db4c69",
329
+ background: "#1e1e1e"
330
+ },
331
+ ".namespace": {
332
+ Opacity: ".7"
333
+ },
334
+ "doctype.doctype-tag": {
335
+ color: "#569CD6"
336
+ },
337
+ "doctype.name": {
338
+ color: "#9cdcfe"
339
+ },
340
+ comment: {
341
+ color: "#6a9955"
342
+ },
343
+ prolog: {
344
+ color: "#6a9955"
345
+ },
346
+ punctuation: {
347
+ color: "#d4d4d4"
348
+ },
349
+ ".language-html .language-css .token.punctuation": {
350
+ color: "#d4d4d4"
351
+ },
352
+ ".language-html .language-javascript .token.punctuation": {
353
+ color: "#d4d4d4"
354
+ },
355
+ property: {
356
+ color: "#9cdcfe"
357
+ },
358
+ tag: {
359
+ color: "#569cd6"
360
+ },
361
+ boolean: {
362
+ color: "#569cd6"
363
+ },
364
+ number: {
365
+ color: "#b5cea8"
366
+ },
367
+ constant: {
368
+ color: "#9cdcfe"
369
+ },
370
+ symbol: {
371
+ color: "#b5cea8"
372
+ },
373
+ inserted: {
374
+ color: "#b5cea8"
375
+ },
376
+ unit: {
377
+ color: "#b5cea8"
378
+ },
379
+ selector: {
380
+ color: "#d7ba7d"
381
+ },
382
+ "attr-name": {
383
+ color: "#9cdcfe"
384
+ },
385
+ string: {
386
+ color: "#ce9178"
387
+ },
388
+ char: {
389
+ color: "#ce9178"
390
+ },
391
+ builtin: {
392
+ color: "#ce9178"
393
+ },
394
+ deleted: {
395
+ color: "#ce9178"
396
+ },
397
+ ".language-css .token.string.url": {
398
+ textDecoration: "underline"
399
+ },
400
+ operator: {
401
+ color: "#d4d4d4"
402
+ },
403
+ entity: {
404
+ color: "#569cd6"
405
+ },
406
+ "operator.arrow": {
407
+ color: "#569CD6"
408
+ },
409
+ atrule: {
410
+ color: "#ce9178"
411
+ },
412
+ "atrule.rule": {
413
+ color: "#c586c0"
414
+ },
415
+ "atrule.url": {
416
+ color: "#9cdcfe"
417
+ },
418
+ "atrule.url.function": {
419
+ color: "#dcdcaa"
420
+ },
421
+ "atrule.url.punctuation": {
422
+ color: "#d4d4d4"
423
+ },
424
+ keyword: {
425
+ color: "#569CD6"
426
+ },
427
+ "keyword.module": {
428
+ color: "#c586c0"
429
+ },
430
+ "keyword.control-flow": {
431
+ color: "#c586c0"
432
+ },
433
+ function: {
434
+ color: "#dcdcaa"
435
+ },
436
+ "function.maybe-class-name": {
437
+ color: "#dcdcaa"
438
+ },
439
+ regex: {
440
+ color: "#d16969"
441
+ },
442
+ important: {
443
+ color: "#569cd6"
444
+ },
445
+ italic: {
446
+ fontStyle: "italic"
447
+ },
448
+ "class-name": {
449
+ color: "#4ec9b0"
450
+ },
451
+ "maybe-class-name": {
452
+ color: "#4ec9b0"
453
+ },
454
+ console: {
455
+ color: "#9cdcfe"
456
+ },
457
+ parameter: {
458
+ color: "#9cdcfe"
459
+ },
460
+ interpolation: {
461
+ color: "#9cdcfe"
462
+ },
463
+ "punctuation.interpolation-punctuation": {
464
+ color: "#569cd6"
465
+ },
466
+ variable: {
467
+ color: "#9cdcfe"
468
+ },
469
+ "imports.maybe-class-name": {
470
+ color: "#9cdcfe"
471
+ },
472
+ "exports.maybe-class-name": {
473
+ color: "#9cdcfe"
474
+ },
475
+ escape: {
476
+ color: "#d7ba7d"
477
+ },
478
+ "tag.punctuation": {
479
+ color: "#808080"
480
+ },
481
+ cdata: {
482
+ color: "#808080"
483
+ },
484
+ "attr-value": {
485
+ color: "#ce9178"
486
+ },
487
+ "attr-value.punctuation": {
488
+ color: "#ce9178"
489
+ },
490
+ "attr-value.punctuation.attr-equals": {
491
+ color: "#d4d4d4"
492
+ },
493
+ namespace: {
494
+ color: "#4ec9b0"
495
+ },
496
+ 'pre[class*="language-javascript"]': {
497
+ color: "#9cdcfe"
498
+ },
499
+ 'code[class*="language-javascript"]': {
500
+ color: "#9cdcfe"
501
+ },
502
+ 'pre[class*="language-jsx"]': {
503
+ color: "#9cdcfe"
504
+ },
505
+ 'code[class*="language-jsx"]': {
506
+ color: "#9cdcfe"
507
+ },
508
+ 'pre[class*="language-typescript"]': {
509
+ color: "#9cdcfe"
510
+ },
511
+ 'code[class*="language-typescript"]': {
512
+ color: "#9cdcfe"
513
+ },
514
+ 'pre[class*="language-tsx"]': {
515
+ color: "#9cdcfe"
516
+ },
517
+ 'code[class*="language-tsx"]': {
518
+ color: "#9cdcfe"
519
+ },
520
+ 'pre[class*="language-css"]': {
521
+ color: "#ce9178"
522
+ },
523
+ 'code[class*="language-css"]': {
524
+ color: "#ce9178"
525
+ },
526
+ 'pre[class*="language-html"]': {
527
+ color: "#d4d4d4"
528
+ },
529
+ 'code[class*="language-html"]': {
530
+ color: "#d4d4d4"
531
+ },
532
+ ".language-regex .token.anchor": {
533
+ color: "#dcdcaa"
534
+ },
535
+ ".language-html .token.punctuation": {
536
+ color: "#808080"
537
+ },
538
+ 'pre[class*="language-"] > code[class*="language-"]': {
539
+ position: "relative",
540
+ zIndex: "1"
541
+ },
542
+ ".line-highlight.line-highlight": {
543
+ background: "#f7ebc6",
544
+ boxShadow: "inset 5px 0 0 #f7d87c",
545
+ zIndex: "0"
546
+ }
547
+ };
548
+
549
+ // src/components/chat/Markdown.tsx
550
+ var import_remark_gfm = __toESM(require("remark-gfm"));
551
+ var import_remark_math = __toESM(require("remark-math"));
552
+ var import_jsx_runtime5 = require("react/jsx-runtime");
553
+ var MemoizedReactMarkdown = (0, import_react3.memo)(
554
+ import_react_markdown.default,
555
+ (prevProps, nextProps) => prevProps.children === nextProps.children && prevProps.className === nextProps.className
556
+ );
557
+ var Markdown = ({ content }) => {
558
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "copilotKitMarkdown", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(MemoizedReactMarkdown, { components, remarkPlugins: [import_remark_gfm.default, import_remark_math.default], children: content }) });
559
+ };
560
+ var components = {
561
+ a(_a) {
562
+ var _b = _a, { children } = _b, props = __objRest(_b, ["children"]);
563
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
564
+ "a",
565
+ __spreadProps(__spreadValues({
566
+ style: { color: "blue", textDecoration: "underline" }
567
+ }, props), {
568
+ target: "_blank",
569
+ rel: "noopener noreferrer",
570
+ children
571
+ })
572
+ );
573
+ },
574
+ code(_c) {
575
+ var _d = _c, { children, className, inline } = _d, props = __objRest(_d, ["children", "className", "inline"]);
576
+ if (children.length) {
577
+ if (children[0] == "\u258D") {
578
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
579
+ "span",
580
+ {
581
+ style: {
582
+ animation: "pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite",
583
+ marginTop: "0.25rem"
584
+ },
585
+ children: "\u258D"
586
+ }
587
+ );
588
+ }
589
+ children[0] = children[0].replace("`\u258D`", "\u258D");
590
+ }
591
+ const match = /language-(\w+)/.exec(className || "");
592
+ if (inline) {
593
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("code", __spreadProps(__spreadValues({ className }, props), { children }));
594
+ }
595
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
596
+ CodeBlock,
597
+ __spreadValues({
598
+ language: match && match[1] || "",
599
+ value: String(children).replace(/\n$/, "")
600
+ }, props),
601
+ Math.random()
602
+ );
603
+ }
604
+ };
605
+
606
+ // src/components/chat/messages/AssistantMessage.tsx
607
+ var import_react4 = require("react");
608
+ var import_jsx_runtime6 = require("react/jsx-runtime");
609
+ var AssistantMessage = (props) => {
610
+ const { icons, labels } = useChatContext();
611
+ const {
612
+ message,
613
+ isLoading,
614
+ subComponent,
615
+ onRegenerate,
616
+ onCopy,
617
+ onThumbsUp,
618
+ onThumbsDown,
619
+ isCurrentMessage
620
+ } = props;
621
+ const [copied, setCopied] = (0, import_react4.useState)(false);
622
+ const handleCopy = () => {
623
+ if (message && onCopy) {
624
+ navigator.clipboard.writeText(message);
625
+ setCopied(true);
626
+ onCopy(message);
627
+ setTimeout(() => setCopied(false), 2e3);
628
+ } else if (message) {
629
+ navigator.clipboard.writeText(message);
630
+ setCopied(true);
631
+ setTimeout(() => setCopied(false), 2e3);
632
+ }
633
+ };
634
+ const handleRegenerate = () => {
635
+ if (onRegenerate) {
636
+ onRegenerate();
637
+ }
638
+ };
639
+ const handleThumbsUp = () => {
640
+ if (onThumbsUp && message) {
641
+ onThumbsUp(message);
642
+ }
643
+ };
644
+ const handleThumbsDown = () => {
645
+ if (onThumbsDown && message) {
646
+ onThumbsDown(message);
647
+ }
648
+ };
649
+ const LoadingIcon = () => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: icons.activityIcon });
650
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
651
+ (message || isLoading) && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "copilotKitMessage copilotKitAssistantMessage", children: [
652
+ message && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Markdown, { content: message || "" }),
653
+ isLoading && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(LoadingIcon, {}),
654
+ message && !isLoading && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
655
+ "div",
656
+ {
657
+ className: `copilotKitMessageControls ${isCurrentMessage ? "currentMessage" : ""}`,
658
+ children: [
659
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
660
+ "button",
661
+ {
662
+ className: "copilotKitMessageControlButton",
663
+ onClick: handleRegenerate,
664
+ "aria-label": labels.regenerateResponse,
665
+ title: labels.regenerateResponse,
666
+ children: icons.regenerateIcon
667
+ }
668
+ ),
669
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
670
+ "button",
671
+ {
672
+ className: "copilotKitMessageControlButton",
673
+ onClick: handleCopy,
674
+ "aria-label": labels.copyToClipboard,
675
+ title: labels.copyToClipboard,
676
+ children: copied ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { style: { fontSize: "10px", fontWeight: "bold" }, children: "\u2713" }) : icons.copyIcon
677
+ }
678
+ ),
679
+ onThumbsUp && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
680
+ "button",
681
+ {
682
+ className: "copilotKitMessageControlButton",
683
+ onClick: handleThumbsUp,
684
+ "aria-label": labels.thumbsUp,
685
+ title: labels.thumbsUp,
686
+ children: icons.thumbsUpIcon
687
+ }
688
+ ),
689
+ onThumbsDown && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
690
+ "button",
691
+ {
692
+ className: "copilotKitMessageControlButton",
693
+ onClick: handleThumbsDown,
694
+ "aria-label": labels.thumbsDown,
695
+ title: labels.thumbsDown,
696
+ children: icons.thumbsDownIcon
697
+ }
698
+ )
699
+ ]
700
+ }
701
+ )
702
+ ] }),
703
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: { marginBottom: "0.5rem" }, children: subComponent })
704
+ ] });
705
+ };
706
+
707
+ // src/components/chat/messages/RenderImageMessage.tsx
708
+ var import_jsx_runtime7 = require("react/jsx-runtime");
709
+ function RenderImageMessage(_a) {
710
+ var _b = _a, {
711
+ UserMessage: UserMessage2 = UserMessage,
712
+ AssistantMessage: AssistantMessage2 = AssistantMessage
713
+ } = _b, props = __objRest(_b, [
714
+ "UserMessage",
715
+ "AssistantMessage"
716
+ ]);
717
+ const {
718
+ message,
719
+ inProgress,
720
+ index,
721
+ isCurrentMessage,
722
+ onRegenerate,
723
+ onCopy,
724
+ onThumbsUp,
725
+ onThumbsDown
726
+ } = props;
727
+ if (message.isImageMessage()) {
728
+ const imageData = `data:${message.format};base64,${message.bytes}`;
729
+ const imageComponent = /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "copilotKitImage", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
730
+ "img",
731
+ {
732
+ src: imageData,
733
+ alt: "User uploaded image",
734
+ style: { maxWidth: "100%", maxHeight: "300px", borderRadius: "8px" }
735
+ }
736
+ ) });
737
+ if (message.role === "user") {
738
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
739
+ UserMessage2,
740
+ {
741
+ "data-message-role": "user",
742
+ message: "",
743
+ rawData: message,
744
+ subComponent: imageComponent
745
+ },
746
+ index
747
+ );
748
+ } else if (message.role === "assistant") {
749
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
750
+ AssistantMessage2,
751
+ {
752
+ "data-message-role": "assistant",
753
+ message: "",
754
+ rawData: message,
755
+ subComponent: imageComponent,
756
+ isLoading: inProgress && isCurrentMessage && !message.bytes,
757
+ isGenerating: inProgress && isCurrentMessage && !!message.bytes,
758
+ isCurrentMessage,
759
+ onRegenerate: () => onRegenerate == null ? void 0 : onRegenerate(message.id),
760
+ onCopy,
761
+ onThumbsUp,
762
+ onThumbsDown
763
+ },
764
+ index
765
+ );
766
+ }
767
+ }
768
+ return null;
769
+ }
770
+ // Annotate the CommonJS export names for ESM import in node:
771
+ 0 && (module.exports = {
772
+ RenderImageMessage
773
+ });
774
+ //# sourceMappingURL=RenderImageMessage.js.map