reachat 2.1.0-alpha.9 → 2.1.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 (82) hide show
  1. package/README.md +4 -2
  2. package/dist/AppBar/AppBar.d.ts +1 -1
  3. package/dist/{CSVFileRenderer-CkRKGiCl.js → CSVFileRenderer-D2mDdCjs.js} +14 -15
  4. package/dist/CSVFileRenderer-D2mDdCjs.js.map +1 -0
  5. package/dist/Chat.d.ts +9 -3
  6. package/dist/ChatBubble/ChatBubble.d.ts +1 -1
  7. package/dist/ChatContext.d.ts +4 -2
  8. package/dist/ChatInput/ChatInput.d.ts +23 -13
  9. package/dist/ChatInput/FileInput.d.ts +1 -1
  10. package/dist/ChatInput/MentionList.d.ts +32 -0
  11. package/dist/ChatInput/RichTextInput.d.ts +55 -0
  12. package/dist/ChatInput/index.d.ts +3 -0
  13. package/dist/ChatInput/types.d.ts +104 -0
  14. package/dist/ChatSuggestions/ChatSuggestion.d.ts +9 -0
  15. package/dist/ChatSuggestions/ChatSuggestions.d.ts +22 -0
  16. package/dist/ChatSuggestions/index.d.ts +2 -0
  17. package/dist/{DefaultFileRenderer-C1qZ57tG.js → DefaultFileRenderer-BLV8PtJk.js} +2 -2
  18. package/dist/DefaultFileRenderer-BLV8PtJk.js.map +1 -0
  19. package/dist/ImageFileRenderer-C8tVW3I8.js.map +1 -1
  20. package/dist/Markdown/Markdown.d.ts +4 -3
  21. package/dist/Markdown/Table.d.ts +1 -1
  22. package/dist/Markdown/charts/ChartError.d.ts +21 -0
  23. package/dist/Markdown/charts/ChartPre.d.ts +6 -0
  24. package/dist/Markdown/charts/ChartRenderer.d.ts +13 -0
  25. package/dist/Markdown/charts/chartHelpers.d.ts +40 -0
  26. package/dist/Markdown/charts/chartHelpers.spec.d.ts +1 -0
  27. package/dist/Markdown/charts/index.d.ts +7 -0
  28. package/dist/Markdown/index.d.ts +3 -2
  29. package/dist/Markdown/plugins/index.d.ts +1 -0
  30. package/dist/Markdown/plugins/remarkChart.d.ts +59 -0
  31. package/dist/Markdown/plugins/remarkCve.d.ts +1 -1
  32. package/dist/MessageStatus/MessageStatus.d.ts +44 -0
  33. package/dist/MessageStatus/MessageStatusItem.d.ts +9 -0
  34. package/dist/MessageStatus/StatusIcon.d.ts +17 -0
  35. package/dist/MessageStatus/index.d.ts +3 -0
  36. package/dist/PDFFileRenderer-DQdFS2l6.js +9 -0
  37. package/dist/PDFFileRenderer-DQdFS2l6.js.map +1 -0
  38. package/dist/SessionMessages/SessionEmpty.d.ts +4 -1
  39. package/dist/SessionMessages/SessionMessage/MessageFile/renderers/index.d.ts +1 -1
  40. package/dist/SessionMessages/SessionMessage/MessageFiles.d.ts +1 -1
  41. package/dist/SessionMessages/SessionMessage/MessageSources.d.ts +1 -1
  42. package/dist/SessionMessages/SessionMessage/SessionMessage.d.ts +0 -4
  43. package/dist/SessionMessages/SessionMessage/index.d.ts +2 -2
  44. package/dist/SessionMessages/SessionMessages.d.ts +3 -7
  45. package/dist/SessionMessages/index.d.ts +2 -2
  46. package/dist/SessionsList/index.d.ts +2 -2
  47. package/dist/docs.json +1037 -183
  48. package/dist/index-B3dZT-5c.js +4369 -0
  49. package/dist/index-B3dZT-5c.js.map +1 -0
  50. package/dist/index.css +2129 -6532
  51. package/dist/index.d.ts +8 -7
  52. package/dist/index.js +49 -34
  53. package/dist/index.umd.cjs +3414 -1320
  54. package/dist/index.umd.cjs.map +1 -1
  55. package/dist/stories/Changelog.mdx +1 -1
  56. package/dist/stories/ChartError.stories.tsx +85 -0
  57. package/dist/stories/Charts.stories.tsx +371 -0
  58. package/dist/stories/Chat.stories.tsx +5 -5
  59. package/dist/stories/ChatBubble.stories.tsx +3 -3
  60. package/dist/stories/ChatSuggestions.stories.tsx +541 -0
  61. package/dist/stories/Companion.stories.tsx +6 -6
  62. package/dist/stories/Console.stories.tsx +165 -25
  63. package/dist/stories/EnhancedInput.stories.tsx +322 -0
  64. package/dist/stories/Integration.stories.tsx +2 -2
  65. package/dist/stories/Intro.mdx +1 -1
  66. package/dist/stories/MessageStatus.stories.tsx +314 -0
  67. package/dist/stories/RichTextInput.stories.tsx +198 -0
  68. package/dist/stories/assets/logo.svg +19 -38
  69. package/dist/stories/assets/paperclip.svg +1 -4
  70. package/dist/stories/assets/search.svg +1 -5
  71. package/dist/stories/assets/sparkles.svg +7 -0
  72. package/dist/stories/examples.ts +47 -20
  73. package/dist/theme.d.ts +76 -13
  74. package/dist/types.d.ts +10 -0
  75. package/package.json +69 -66
  76. package/dist/CSVFileRenderer-CkRKGiCl.js.map +0 -1
  77. package/dist/DefaultFileRenderer-C1qZ57tG.js.map +0 -1
  78. package/dist/PDFFileRenderer-BBn2EVrV.js +0 -16
  79. package/dist/PDFFileRenderer-BBn2EVrV.js.map +0 -1
  80. package/dist/index-6CsqxEMx.js +0 -2257
  81. package/dist/index-6CsqxEMx.js.map +0 -1
  82. package/dist/utils/index.d.ts +0 -1
@@ -1,2257 +0,0 @@
1
- import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
- import { cn, ConnectedOverlay, Button, Textarea, IconButton, Ellipsis, Card, Divider, useInfinityList, DateFormat, ListItem, List } from "reablocks";
3
- import { AnimatePresence, motion } from "motion/react";
4
- import * as React from "react";
5
- import { createContext, useState, useCallback, useEffect, useMemo, memo, useRef, useContext, forwardRef, useImperativeHandle, lazy, Suspense } from "react";
6
- import { useHotkeys } from "reakeys";
7
- import remarkGfm from "remark-gfm";
8
- import remarkMath from "remark-math";
9
- import remarkYoutube from "remark-youtube";
10
- import { offset } from "@floating-ui/react";
11
- import { Prism } from "react-syntax-highlighter";
12
- import ReactMarkdown from "react-markdown";
13
- import rehypeKatex from "rehype-katex";
14
- import { findAndReplace } from "mdast-util-find-and-replace";
15
- import { Slot } from "@radix-ui/react-slot";
16
- import { isToday, isYesterday, isThisWeek, differenceInYears, format } from "date-fns";
17
- const chatTheme = {
18
- base: "text-content-text-neutral-base",
19
- console: "flex w-full gap-4 h-full",
20
- companion: "w-full h-full overflow-hidden",
21
- empty: "text-center flex-1",
22
- appbar: "flex p-5",
23
- sessions: {
24
- base: "overflow-auto",
25
- console: "min-w-[150px] w-[30%] max-w-[300px] bg-gradient-neutral-200 p-5 rounded-3xl",
26
- companion: "w-full h-full",
27
- group: "text-xs text-content-text-neutral-3 mt-4 hover:bg-transparent mb-1",
28
- create: "relative mb-4 rounded-[10px] text-white",
29
- session: {
30
- base: "group my-1 rounded-[10px] p-2 text-content-text-neutral-1 border border-transparent",
31
- active: "border-select-menu-items-color-item-stroke-row-hover [&_button]:opacity-100!",
32
- delete: "[&>svg]:w-4 [&>svg]:h-4 opacity-0 group-hover:opacity-50!"
33
- }
34
- },
35
- messages: {
36
- base: "",
37
- console: "flex flex-col mx-5 flex-1 overflow-hidden",
38
- companion: "flex w-full h-full",
39
- back: "self-start pl-0 my-2 ",
40
- inner: "flex-1 h-full flex flex-col",
41
- title: "text-base font-bold",
42
- date: "text-xs whitespace-nowrap text-content-text-neutral-2",
43
- content: "mt-2 flex-1 overflow-auto",
44
- header: "flex justify-between items-center gap-2",
45
- showMore: "mb-4",
46
- message: {
47
- base: "mt-4 mb-4 flex flex-col p-0 rounded-sm border-none bg-transparent",
48
- question: "relative font-semibold mb-4 px-4 py-4 pb-2 rounded-3xl rounded-br-none text-typography border bg-(--background-neutral-raised-5) border-(--stroke-neutral-5)",
49
- response: "relative data-[compact=false]:px-4 text-content-text-neutral-base",
50
- overlay: "overflow-y-hidden max-h-[350px] after:content-[''] after:absolute after:inset-x-0 after:bottom-0 after:h-16 after:bg-linear-to-b after:from-transparent after:to-effects-shadows-base-2-xl",
51
- cursor: "inline-block w-1 h-4 bg-current",
52
- expand: "absolute bottom-0 right-1 z-10",
53
- files: {
54
- base: "mb-2 flex flex-wrap gap-3 ",
55
- file: {
56
- base: "flex items-center gap-2 border border-stroke-neutral-4 px-3 py-2 rounded-lg cursor-pointer",
57
- name: "text-sm text-content-text-neutral-4"
58
- }
59
- },
60
- sources: {
61
- base: "my-4 flex flex-wrap gap-3",
62
- source: {
63
- base: "flex gap-2 border border-stroke-neutral-4 px-4 py-2 rounded-lg cursor-pointer",
64
- companion: "flex-1 px-3 py-1.5",
65
- image: "max-w-10 max-h-10 rounded-md w-full h-fit self-center",
66
- title: "text-md block",
67
- url: "text-sm text-buttons-colors-link-primary-text-resting underline"
68
- }
69
- },
70
- markdown: {
71
- copy: "sticky py-1 [&>svg]:w-4 [&>svg]:h-4 opacity-50",
72
- p: "mb-2",
73
- a: "text-buttons-colors-link-primary-text-resting underline",
74
- table: "table-auto w-full m-2",
75
- th: "px-4 py-2 text-left font-bold border-b border-stroke-neutral-4",
76
- td: "px-4 py-2",
77
- code: "m-2 rounded-b relative",
78
- toolbar: "text-xs flex items-center justify-between px-2 py-1 rounded-t sticky top-0 backdrop-blur-md bg-gradient-neutral-500/50",
79
- li: "mb-2 ml-6",
80
- ul: "mb-4 list-disc",
81
- ol: "mb-4 list-decimal"
82
- },
83
- csvPreview: {
84
- base: "flex flex-col gap-2",
85
- header: {
86
- base: "flex justify-between items-center gap-4",
87
- icon: "csv-icon flex items-center",
88
- actions: "csv-actions flex items-center gap-6"
89
- },
90
- tableContainer: "flex justify-between",
91
- dialog: {
92
- base: "fixed inset-0 bg-background-neutral-canvas-base/70 flex justify-center items-center z-50",
93
- container: "bg-background-neutral-canvas-base rounded-md w-11/12 h-5/6 overflow-auto"
94
- }
95
- },
96
- footer: {
97
- base: "mt-3 flex gap-1.5",
98
- copy: "p-3 rounded-[10px] [&>svg]:size-4 opacity-50 hover:opacity-100!",
99
- upvote: "p-3 rounded-[10px] [&>svg]:size-4 opacity-50 hover:opacity-100!",
100
- downvote: "p-3 rounded-[10px] [&>svg]:size-4 opacity-50 hover:opacity-100!",
101
- refresh: "p-3 rounded-[10px] [&>svg]:size-4 opacity-50 hover:opacity-100!"
102
- }
103
- }
104
- },
105
- input: {
106
- base: "flex mt-4 relative",
107
- upload: "px-5 py-2 size-10 text-content-text-neutral-2 hover:text-content-text-neutral-base",
108
- input: "w-full border rounded-3xl px-3 py-2 pr-16 after:hidden after:mx-10! [&>textarea]:w-full [&>textarea]:flex-none [&>textarea]:outline-none [&>textarea]:resize-none",
109
- actions: {
110
- base: "absolute flex gap-2 items-center right-2 inset-y-1/2 -translate-y-1/2 z-10",
111
- send: "px-3 py-3 hover:bg-primary-hover rounded-full size-8",
112
- stop: "px-2 py-2 bg-content-assets-semantic-error-base text-white rounded-full hover:bg-content-assets-semantic-error-1 size-8"
113
- }
114
- }
115
- };
116
- const AppBar = ({ content, theme = chatTheme }) => {
117
- return /* @__PURE__ */ jsx("div", { className: cn(theme.appbar), children: content });
118
- };
119
- const ChatContext = createContext({
120
- sessions: [],
121
- activeSessionId: null
122
- });
123
- const useDimensions = () => {
124
- const [ref, setRef] = useState(null);
125
- const [width, setWidth] = useState(void 0);
126
- const observe = useCallback((element) => {
127
- if (element) setRef(element);
128
- }, []);
129
- useEffect(() => {
130
- if (!ref) return;
131
- const resizeObserver = new ResizeObserver((entries) => {
132
- for (const entry of entries) {
133
- setWidth(entry.contentRect.width);
134
- }
135
- });
136
- resizeObserver.observe(ref);
137
- return () => {
138
- resizeObserver.disconnect();
139
- };
140
- }, [ref]);
141
- return { width, observe };
142
- };
143
- const Chat = ({
144
- children,
145
- viewType = "console",
146
- sessions,
147
- onSelectSession,
148
- onDeleteSession,
149
- onSendMessage,
150
- onStopMessage,
151
- onFileUpload,
152
- isLoading,
153
- activeSessionId,
154
- theme = chatTheme,
155
- onNewSession,
156
- remarkPlugins = [remarkGfm, remarkYoutube, remarkMath],
157
- disabled,
158
- style,
159
- className
160
- }) => {
161
- const [internalActiveSessionID, setInternalActiveSessionID] = useState(activeSessionId);
162
- const { width, observe } = useDimensions();
163
- const isCompact = viewType === "companion" || width && width < 767;
164
- useEffect(() => {
165
- setInternalActiveSessionID(activeSessionId);
166
- }, [activeSessionId]);
167
- const handleSelectSession = useCallback(
168
- (sessionId) => {
169
- setInternalActiveSessionID(sessionId);
170
- onSelectSession?.(sessionId);
171
- },
172
- [onSelectSession]
173
- );
174
- const handleDeleteSession = useCallback(
175
- (sessionId) => {
176
- setInternalActiveSessionID(void 0);
177
- onDeleteSession?.(sessionId);
178
- },
179
- [onDeleteSession]
180
- );
181
- const handleCreateNewSession = useCallback(() => {
182
- setInternalActiveSessionID(void 0);
183
- onNewSession?.();
184
- }, [onNewSession]);
185
- useHotkeys([
186
- {
187
- name: "Create new session",
188
- category: "Chat",
189
- keys: "meta+shift+s",
190
- callback: (event) => {
191
- event.preventDefault();
192
- handleCreateNewSession();
193
- }
194
- }
195
- ]);
196
- const activeSession = useMemo(
197
- () => sessions.find((session) => session.id === internalActiveSessionID),
198
- [sessions, internalActiveSessionID]
199
- );
200
- const contextValue = useMemo(
201
- () => ({
202
- sessions,
203
- activeSession,
204
- remarkPlugins,
205
- theme,
206
- disabled,
207
- isLoading,
208
- isCompact,
209
- viewType,
210
- activeSessionId: internalActiveSessionID,
211
- selectSession: handleSelectSession,
212
- deleteSession: handleDeleteSession,
213
- createSession: handleCreateNewSession,
214
- sendMessage: onSendMessage,
215
- stopMessage: onStopMessage,
216
- fileUpload: onFileUpload
217
- }),
218
- [
219
- isLoading,
220
- isCompact,
221
- viewType,
222
- disabled,
223
- theme,
224
- remarkPlugins,
225
- sessions,
226
- activeSession,
227
- internalActiveSessionID,
228
- handleSelectSession,
229
- handleDeleteSession,
230
- handleCreateNewSession,
231
- onSendMessage,
232
- onStopMessage,
233
- onFileUpload
234
- ]
235
- );
236
- return /* @__PURE__ */ jsx(ChatContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx(AnimatePresence, { initial: false, children: /* @__PURE__ */ jsx(
237
- "div",
238
- {
239
- ref: observe,
240
- className: cn(className, theme.base, {
241
- [theme.companion]: isCompact,
242
- [theme.console]: !isCompact
243
- }),
244
- style,
245
- children
246
- }
247
- ) }) });
248
- };
249
- const ChatBubble = memo(
250
- ({
251
- children,
252
- bubbleContent,
253
- position = "right-end",
254
- modifiers = [offset({ mainAxis: 0, crossAxis: -40 })],
255
- className
256
- }) => {
257
- const [isOpen, setIsOpen] = useState(false);
258
- const ref = useRef(null);
259
- return /* @__PURE__ */ jsxs(Fragment, { children: [
260
- /* @__PURE__ */ jsx(
261
- ConnectedOverlay,
262
- {
263
- placement: position,
264
- modifiers,
265
- reference: ref.current,
266
- open: isOpen,
267
- onOpen: () => setIsOpen(true),
268
- onClose: () => setIsOpen(false),
269
- content: () => /* @__PURE__ */ jsx(Fragment, { children })
270
- }
271
- ),
272
- /* @__PURE__ */ jsx(
273
- "div",
274
- {
275
- ref,
276
- className,
277
- onClick: () => setIsOpen((prev) => !prev),
278
- children: bubbleContent
279
- }
280
- )
281
- ] });
282
- }
283
- );
284
- const SvgSend = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 16, height: 16, viewBox: "0 0 16 16", fill: "none", ...props }, /* @__PURE__ */ React.createElement("path", { d: "M15.3451 0.654003C15.0011 0.310003 14.5001 0.191003 14.0401 0.339003L1.11712 4.493C0.626116 4.651 0.286116 5.067 0.230116 5.58C0.174116 6.092 0.417116 6.572 0.862116 6.831L5.43812 9.5L9.39112 5.546C9.68412 5.253 10.1591 5.253 10.4521 5.546C10.7451 5.839 10.7451 6.314 10.4521 6.607L6.49812 10.561L9.16712 15.137C9.40211 15.539 9.81712 15.776 10.2741 15.776C10.3221 15.776 10.3711 15.773 10.4201 15.768C10.9321 15.712 11.3491 15.372 11.5061 14.882L15.6611 1.96C15.8091 1.497 15.6881 0.997003 15.3451 0.654003Z", fill: "currentColor" }));
285
- const SvgStop = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 50 50", width: "24px", height: "24px", ...props }, /* @__PURE__ */ React.createElement("path", { d: "M 25 2 C 12.309534 2 2 12.309534 2 25 C 2 37.690466 12.309534 48 25 48 C 37.690466 48 48 37.690466 48 25 C 48 12.309534 37.690466 2 25 2 z M 25 4 C 36.609534 4 46 13.390466 46 25 C 46 36.609534 36.609534 46 25 46 C 13.390466 46 4 36.609534 4 25 C 4 13.390466 13.390466 4 25 4 z M 32.990234 15.986328 A 1.0001 1.0001 0 0 0 32.292969 16.292969 L 25 23.585938 L 17.707031 16.292969 A 1.0001 1.0001 0 0 0 16.990234 15.990234 A 1.0001 1.0001 0 0 0 16.292969 17.707031 L 23.585938 25 L 16.292969 32.292969 A 1.0001 1.0001 0 1 0 17.707031 33.707031 L 25 26.414062 L 32.292969 33.707031 A 1.0001 1.0001 0 1 0 33.707031 32.292969 L 26.414062 25 L 33.707031 17.707031 A 1.0001 1.0001 0 0 0 32.990234 15.986328 z", fill: "currentColor" }));
286
- const SvgPaperclip = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 64 64", width: "24px", height: "24px", ...props }, /* @__PURE__ */ React.createElement("path", { d: "M25.3,56.007c-3.409,0-6.818-1.297-9.414-3.893c-2.595-2.596-3.893-6.005-3.893-9.415c0-3.409,1.298-6.819,3.893-9.414 l20.4-20.4c1.847-1.847,4.302-2.864,6.914-2.864c2.611,0,5.067,1.017,6.914,2.864c3.812,3.813,3.812,10.016,0,13.829l-20.4,20.4 c-2.438,2.439-6.385,2.441-8.828,0c-2.434-2.435-2.434-6.395,0-8.829l13.7-13.7c0.781-0.781,2.047-0.781,2.828,0 c0.781,0.781,0.781,2.047,0,2.828l-13.7,13.7c-0.874,0.875-0.874,2.297,0.001,3.172c0.847,0.846,2.324,0.846,3.171,0l20.4-20.4 c2.252-2.253,2.252-5.919,0-8.172c-1.092-1.091-2.543-1.692-4.086-1.692c-1.544,0-2.994,0.601-4.086,1.692l-20.4,20.4 c-1.815,1.816-2.723,4.201-2.723,6.586c0,2.385,0.908,4.77,2.723,6.586c1.816,1.815,4.201,2.723,6.586,2.723 c2.385,0,4.771-0.907,6.586-2.723l12.7-12.7c0.781-0.781,2.047-0.781,2.828,0c0.781,0.781,0.781,2.047,0,2.828l-12.7,12.7 C32.119,54.709,28.71,56.007,25.3,56.007z", fill: "currentColor" }));
287
- const FileInput = ({
288
- allowedFiles,
289
- onFileUpload,
290
- isLoading,
291
- disabled,
292
- attachIcon = /* @__PURE__ */ jsx(SvgPaperclip, {})
293
- }) => {
294
- const { theme } = useContext(ChatContext);
295
- const fileInputRef = useRef(null);
296
- return /* @__PURE__ */ jsxs(Fragment, { children: [
297
- /* @__PURE__ */ jsx(
298
- "input",
299
- {
300
- type: "file",
301
- ref: fileInputRef,
302
- className: "hidden",
303
- accept: allowedFiles.join(","),
304
- onChange: (e) => {
305
- onFileUpload(e);
306
- if (fileInputRef.current) {
307
- fileInputRef.current.value = "";
308
- }
309
- }
310
- }
311
- ),
312
- /* @__PURE__ */ jsx(
313
- Button,
314
- {
315
- title: "Upload",
316
- variant: "text",
317
- disabled: isLoading || disabled,
318
- className: cn(theme.input.upload),
319
- onClick: () => fileInputRef.current?.click(),
320
- children: attachIcon
321
- }
322
- )
323
- ] });
324
- };
325
- const ChatInput = forwardRef(
326
- ({
327
- allowedFiles,
328
- placeholder,
329
- defaultValue,
330
- className,
331
- message,
332
- sendIcon = /* @__PURE__ */ jsx(SvgSend, {}),
333
- stopIcon = /* @__PURE__ */ jsx(SvgStop, {}),
334
- attachIcon,
335
- onMessageChange
336
- }, ref) => {
337
- const {
338
- theme,
339
- isLoading,
340
- disabled,
341
- sendMessage,
342
- stopMessage,
343
- fileUpload,
344
- activeSessionId
345
- } = useContext(ChatContext);
346
- const [internalMessage, setInternalMessage] = useState("");
347
- const inputRef = useRef(null);
348
- useEffect(() => {
349
- setInternalMessage(message || "");
350
- }, [message]);
351
- useEffect(() => {
352
- if (inputRef.current) {
353
- inputRef.current.focus();
354
- }
355
- }, [activeSessionId, inputRef]);
356
- const handleSendMessage = () => {
357
- if (internalMessage.trim()) {
358
- sendMessage?.(internalMessage);
359
- setInternalMessage("");
360
- }
361
- };
362
- useImperativeHandle(ref, () => ({
363
- focus: () => {
364
- inputRef.current?.focus();
365
- },
366
- send: () => {
367
- handleSendMessage();
368
- },
369
- setValue: (value) => {
370
- setInternalMessage(value);
371
- onMessageChange?.(value);
372
- },
373
- getValue: () => {
374
- return internalMessage;
375
- }
376
- }));
377
- const handleKeyPress = (e) => {
378
- if (e.key === "Enter" && !e.shiftKey) {
379
- e.preventDefault();
380
- handleSendMessage();
381
- }
382
- };
383
- const handleFileUpload = (event) => {
384
- const file = event.target.files?.[0];
385
- if (file && fileUpload) {
386
- fileUpload(file);
387
- }
388
- };
389
- const handleMessageChange = useCallback(
390
- (event) => {
391
- setInternalMessage(event.target.value);
392
- onMessageChange?.(event.target.value);
393
- },
394
- [onMessageChange]
395
- );
396
- return /* @__PURE__ */ jsxs("div", { className: cn(theme.input.base, className), children: [
397
- /* @__PURE__ */ jsx(
398
- Textarea,
399
- {
400
- ref: inputRef,
401
- containerClassName: cn(theme.input.input),
402
- minRows: 1,
403
- autoFocus: true,
404
- value: internalMessage,
405
- defaultValue,
406
- onKeyPress: handleKeyPress,
407
- placeholder,
408
- disabled: isLoading || disabled,
409
- onChange: handleMessageChange
410
- }
411
- ),
412
- /* @__PURE__ */ jsxs("div", { className: cn(theme.input.actions.base), children: [
413
- allowedFiles?.length > 0 && /* @__PURE__ */ jsx(
414
- FileInput,
415
- {
416
- allowedFiles,
417
- onFileUpload: handleFileUpload,
418
- isLoading,
419
- disabled,
420
- attachIcon
421
- }
422
- ),
423
- isLoading && /* @__PURE__ */ jsx(
424
- Button,
425
- {
426
- title: "Stop",
427
- className: cn(theme.input.actions.stop),
428
- onClick: stopMessage,
429
- disabled,
430
- children: stopIcon
431
- }
432
- ),
433
- /* @__PURE__ */ jsx(
434
- Button,
435
- {
436
- title: "Send",
437
- className: cn(theme.input.actions.send),
438
- onClick: handleSendMessage,
439
- disabled: isLoading || disabled,
440
- children: sendIcon
441
- }
442
- )
443
- ] })
444
- ] });
445
- }
446
- );
447
- const SvgCopy = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 18, height: 18, viewBox: "0 0 18 18", fill: "none", ...props }, /* @__PURE__ */ React.createElement("path", { d: "M1.75 6C2.164 6 2.5 6.336 2.5 6.75V13.25C2.5 13.939 3.061 14.5 3.75 14.5H12.25C12.664 14.5 13 14.836 13 15.25C13 15.664 12.664 16 12.25 16H3.75C2.233 16 1 14.767 1 13.25V6.75C1 6.336 1.336 6 1.75 6ZM14.25 2C15.7688 2 17 3.23122 17 4.75V10.25C17 11.7688 15.7688 13 14.25 13H6.75C5.23122 13 4 11.7688 4 10.25V4.75C4 3.23122 5.23122 2 6.75 2H14.25Z", fill: "currentColor" }));
448
- const dark = {
449
- 'code[class*="language-"]': {
450
- background: "#11111f",
451
- color: "#e2e8f0",
452
- textShadow: "0 1px rgba(0, 0, 0, 0.3)",
453
- fontFamily: '"Fira Code", "Fira Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace',
454
- direction: "ltr",
455
- textAlign: "left",
456
- whiteSpace: "pre",
457
- wordSpacing: "normal",
458
- wordBreak: "normal",
459
- lineHeight: "1.5",
460
- MozTabSize: "2",
461
- OTabSize: "2",
462
- tabSize: "2",
463
- WebkitHyphens: "none",
464
- MozHyphens: "none",
465
- msHyphens: "none",
466
- hyphens: "none"
467
- },
468
- 'pre[class*="language-"]': {
469
- background: "#11111f",
470
- color: "#e2e8f0",
471
- textShadow: "0 1px rgba(0, 0, 0, 0.3)",
472
- fontFamily: '"Fira Code", "Fira Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace',
473
- direction: "ltr",
474
- textAlign: "left",
475
- whiteSpace: "pre",
476
- wordSpacing: "normal",
477
- wordBreak: "normal",
478
- lineHeight: "1.5",
479
- MozTabSize: "2",
480
- OTabSize: "2",
481
- tabSize: "2",
482
- WebkitHyphens: "none",
483
- MozHyphens: "none",
484
- msHyphens: "none",
485
- hyphens: "none",
486
- padding: "1em",
487
- margin: "0",
488
- overflow: "auto"
489
- },
490
- 'code[class*="language-"]::-moz-selection': {
491
- background: "#1e293b",
492
- color: "inherit",
493
- textShadow: "none"
494
- },
495
- 'code[class*="language-"] *::-moz-selection': {
496
- background: "#1e293b",
497
- color: "inherit",
498
- textShadow: "none"
499
- },
500
- 'pre[class*="language-"] *::-moz-selection': {
501
- background: "#1e293b",
502
- color: "inherit",
503
- textShadow: "none"
504
- },
505
- 'code[class*="language-"]::selection': {
506
- background: "#1e293b",
507
- color: "inherit",
508
- textShadow: "none"
509
- },
510
- 'code[class*="language-"] *::selection': {
511
- background: "#1e293b",
512
- color: "inherit",
513
- textShadow: "none"
514
- },
515
- 'pre[class*="language-"] *::selection': {
516
- background: "#1e293b",
517
- color: "inherit",
518
- textShadow: "none"
519
- },
520
- ':not(pre) > code[class*="language-"]': {
521
- padding: "0.2em 0.3em",
522
- borderRadius: "0.3em",
523
- whiteSpace: "normal"
524
- },
525
- comment: {
526
- color: "#64748b",
527
- fontStyle: "italic"
528
- },
529
- prolog: {
530
- color: "#64748b"
531
- },
532
- cdata: {
533
- color: "#64748b"
534
- },
535
- doctype: {
536
- color: "#e2e8f0"
537
- },
538
- punctuation: {
539
- color: "#e2e8f0"
540
- },
541
- entity: {
542
- color: "#3b82f6",
543
- cursor: "help"
544
- },
545
- "attr-name": {
546
- color: "#f59e0b"
547
- },
548
- "class-name": {
549
- color: "#f59e0b"
550
- },
551
- boolean: {
552
- color: "#3b82f6"
553
- },
554
- constant: {
555
- color: "#3b82f6"
556
- },
557
- number: {
558
- color: "#3b82f6"
559
- },
560
- atrule: {
561
- color: "#f59e0b"
562
- },
563
- keyword: {
564
- color: "#f472b6"
565
- },
566
- property: {
567
- color: "#3b82f6"
568
- },
569
- tag: {
570
- color: "#3b82f6"
571
- },
572
- symbol: {
573
- color: "#3b82f6"
574
- },
575
- deleted: {
576
- color: "#ef4444"
577
- },
578
- important: {
579
- color: "#f472b6"
580
- },
581
- selector: {
582
- color: "#10b981"
583
- },
584
- string: {
585
- color: "#10b981"
586
- },
587
- char: {
588
- color: "#10b981"
589
- },
590
- builtin: {
591
- color: "#10b981"
592
- },
593
- inserted: {
594
- color: "#10b981"
595
- },
596
- regex: {
597
- color: "#10b981"
598
- },
599
- "attr-value": {
600
- color: "#10b981"
601
- },
602
- "attr-value > .token.punctuation": {
603
- color: "#10b981"
604
- },
605
- variable: {
606
- color: "#60a5fa"
607
- },
608
- operator: {
609
- color: "#60a5fa"
610
- },
611
- function: {
612
- color: "#60a5fa"
613
- },
614
- url: {
615
- color: "#60a5fa"
616
- },
617
- "attr-value > .token.punctuation.attr-equals": {
618
- color: "#e2e8f0"
619
- },
620
- "special-attr > .token.attr-value > .token.value.css": {
621
- color: "#e2e8f0"
622
- },
623
- ".language-css .token.selector": {
624
- color: "#3b82f6"
625
- },
626
- ".language-css .token.property": {
627
- color: "#e2e8f0"
628
- },
629
- ".language-css .token.function": {
630
- color: "#60a5fa"
631
- },
632
- ".language-css .token.url > .token.function": {
633
- color: "#60a5fa"
634
- },
635
- ".language-css .token.url > .token.string.url": {
636
- color: "#10b981"
637
- },
638
- ".language-css .token.important": {
639
- color: "#f472b6"
640
- },
641
- ".language-css .token.atrule .token.rule": {
642
- color: "#f472b6"
643
- },
644
- ".language-javascript .token.operator": {
645
- color: "#f472b6"
646
- },
647
- ".language-javascript .token.template-string > .token.interpolation > .token.interpolation-punctuation.punctuation": {
648
- color: "#ef4444"
649
- },
650
- ".language-json .token.operator": {
651
- color: "#e2e8f0"
652
- },
653
- ".language-json .token.null.keyword": {
654
- color: "#3b82f6"
655
- },
656
- ".language-markdown .token.url": {
657
- color: "#e2e8f0"
658
- },
659
- ".language-markdown .token.url > .token.operator": {
660
- color: "#e2e8f0"
661
- },
662
- ".language-markdown .token.url-reference.url > .token.string": {
663
- color: "#e2e8f0"
664
- },
665
- ".language-markdown .token.url > .token.content": {
666
- color: "#60a5fa"
667
- },
668
- ".language-markdown .token.url > .token.url": {
669
- color: "#60a5fa"
670
- },
671
- ".language-markdown .token.url-reference.url": {
672
- color: "#60a5fa"
673
- },
674
- ".language-markdown .token.blockquote.punctuation": {
675
- color: "#64748b",
676
- fontStyle: "italic"
677
- },
678
- ".language-markdown .token.hr.punctuation": {
679
- color: "#64748b",
680
- fontStyle: "italic"
681
- },
682
- ".language-markdown .token.code-snippet": {
683
- color: "#10b981"
684
- },
685
- ".language-markdown .token.bold .token.content": {
686
- color: "#f59e0b"
687
- },
688
- ".language-markdown .token.italic .token.content": {
689
- color: "#f472b6"
690
- },
691
- ".language-markdown .token.strike .token.content": {
692
- color: "#3b82f6"
693
- },
694
- ".language-markdown .token.strike .token.punctuation": {
695
- color: "#3b82f6"
696
- },
697
- ".language-markdown .token.list.punctuation": {
698
- color: "#3b82f6"
699
- },
700
- ".language-markdown .token.title.important > .token.punctuation": {
701
- color: "#3b82f6"
702
- },
703
- bold: {
704
- fontWeight: "bold"
705
- },
706
- italic: {
707
- fontStyle: "italic"
708
- },
709
- namespace: {
710
- Opacity: "0.8"
711
- },
712
- "token.tab:not(:empty):before": {
713
- color: "#64748b",
714
- textShadow: "none"
715
- },
716
- "token.cr:before": {
717
- color: "#64748b",
718
- textShadow: "none"
719
- },
720
- "token.lf:before": {
721
- color: "#64748b",
722
- textShadow: "none"
723
- },
724
- "token.space:before": {
725
- color: "#64748b",
726
- textShadow: "none"
727
- },
728
- "div.code-toolbar > .toolbar.toolbar > .toolbar-item": {
729
- marginRight: "0.4em"
730
- },
731
- "div.code-toolbar > .toolbar.toolbar > .toolbar-item > button": {
732
- background: "#1e293b",
733
- color: "#94a3b8",
734
- padding: "0.1em 0.4em",
735
- borderRadius: "0.3em"
736
- },
737
- "div.code-toolbar > .toolbar.toolbar > .toolbar-item > a": {
738
- background: "#1e293b",
739
- color: "#94a3b8",
740
- padding: "0.1em 0.4em",
741
- borderRadius: "0.3em"
742
- },
743
- "div.code-toolbar > .toolbar.toolbar > .toolbar-item > span": {
744
- background: "#1e293b",
745
- color: "#94a3b8",
746
- padding: "0.1em 0.4em",
747
- borderRadius: "0.3em"
748
- },
749
- "div.code-toolbar > .toolbar.toolbar > .toolbar-item > button:hover": {
750
- background: "#3b82f6",
751
- color: "#ffffff"
752
- },
753
- "div.code-toolbar > .toolbar.toolbar > .toolbar-item > button:focus": {
754
- background: "#3b82f6",
755
- color: "#ffffff"
756
- },
757
- "div.code-toolbar > .toolbar.toolbar > .toolbar-item > a:hover": {
758
- background: "#3b82f6",
759
- color: "#ffffff"
760
- },
761
- "div.code-toolbar > .toolbar.toolbar > .toolbar-item > a:focus": {
762
- background: "#3b82f6",
763
- color: "#ffffff"
764
- },
765
- "div.code-toolbar > .toolbar.toolbar > .toolbar-item > span:hover": {
766
- background: "#3b82f6",
767
- color: "#ffffff"
768
- },
769
- "div.code-toolbar > .toolbar.toolbar > .toolbar-item > span:focus": {
770
- background: "#3b82f6",
771
- color: "#ffffff"
772
- },
773
- ".line-highlight.line-highlight": {
774
- background: "rgba(59, 130, 246, 0.08)"
775
- },
776
- ".line-highlight.line-highlight:before": {
777
- background: "#1e293b",
778
- color: "#e2e8f0",
779
- padding: "0.1em 0.6em",
780
- borderRadius: "0.3em",
781
- boxShadow: "0 2px 0 0 rgba(0, 0, 0, 0.2)"
782
- },
783
- ".line-highlight.line-highlight[data-end]:after": {
784
- background: "#1e293b",
785
- color: "#e2e8f0",
786
- padding: "0.1em 0.6em",
787
- borderRadius: "0.3em",
788
- boxShadow: "0 2px 0 0 rgba(0, 0, 0, 0.2)"
789
- },
790
- "pre[id].linkable-line-numbers.linkable-line-numbers span.line-numbers-rows > span:hover:before": {
791
- backgroundColor: "rgba(59, 130, 246, 0.08)"
792
- },
793
- ".line-numbers.line-numbers .line-numbers-rows": {
794
- borderRightColor: "#1e293b"
795
- },
796
- ".command-line .command-line-prompt": {
797
- borderRightColor: "#1e293b"
798
- },
799
- ".line-numbers .line-numbers-rows > span:before": {
800
- color: "#64748b"
801
- },
802
- ".command-line .command-line-prompt > span:before": {
803
- color: "#64748b"
804
- },
805
- ".rainbow-braces .token.token.punctuation.brace-level-1": {
806
- color: "#3b82f6"
807
- },
808
- ".rainbow-braces .token.token.punctuation.brace-level-5": {
809
- color: "#3b82f6"
810
- },
811
- ".rainbow-braces .token.token.punctuation.brace-level-9": {
812
- color: "#3b82f6"
813
- },
814
- ".rainbow-braces .token.token.punctuation.brace-level-2": {
815
- color: "#10b981"
816
- },
817
- ".rainbow-braces .token.token.punctuation.brace-level-6": {
818
- color: "#10b981"
819
- },
820
- ".rainbow-braces .token.token.punctuation.brace-level-10": {
821
- color: "#10b981"
822
- },
823
- ".rainbow-braces .token.token.punctuation.brace-level-3": {
824
- color: "#60a5fa"
825
- },
826
- ".rainbow-braces .token.token.punctuation.brace-level-7": {
827
- color: "#60a5fa"
828
- },
829
- ".rainbow-braces .token.token.punctuation.brace-level-11": {
830
- color: "#60a5fa"
831
- },
832
- ".rainbow-braces .token.token.punctuation.brace-level-4": {
833
- color: "#f472b6"
834
- },
835
- ".rainbow-braces .token.token.punctuation.brace-level-8": {
836
- color: "#f472b6"
837
- },
838
- ".rainbow-braces .token.token.punctuation.brace-level-12": {
839
- color: "#f472b6"
840
- },
841
- "pre.diff-highlight > code .token.token.deleted:not(.prefix)": {
842
- backgroundColor: "rgba(239, 68, 68, 0.15)"
843
- },
844
- "pre > code.diff-highlight .token.token.deleted:not(.prefix)": {
845
- backgroundColor: "rgba(239, 68, 68, 0.15)"
846
- },
847
- "pre.diff-highlight > code .token.token.deleted:not(.prefix)::-moz-selection": {
848
- backgroundColor: "rgba(239, 68, 68, 0.25)"
849
- },
850
- "pre.diff-highlight > code .token.token.deleted:not(.prefix) *::-moz-selection": {
851
- backgroundColor: "rgba(239, 68, 68, 0.25)"
852
- },
853
- "pre > code.diff-highlight .token.token.deleted:not(.prefix)::-moz-selection": {
854
- backgroundColor: "rgba(239, 68, 68, 0.25)"
855
- },
856
- "pre > code.diff-highlight .token.token.deleted:not(.prefix) *::-moz-selection": {
857
- backgroundColor: "rgba(239, 68, 68, 0.25)"
858
- },
859
- "pre.diff-highlight > code .token.token.deleted:not(.prefix)::selection": {
860
- backgroundColor: "rgba(239, 68, 68, 0.25)"
861
- },
862
- "pre.diff-highlight > code .token.token.deleted:not(.prefix) *::selection": {
863
- backgroundColor: "rgba(239, 68, 68, 0.25)"
864
- },
865
- "pre > code.diff-highlight .token.token.deleted:not(.prefix)::selection": {
866
- backgroundColor: "rgba(239, 68, 68, 0.25)"
867
- },
868
- "pre > code.diff-highlight .token.token.deleted:not(.prefix) *::selection": {
869
- backgroundColor: "rgba(239, 68, 68, 0.25)"
870
- },
871
- "pre.diff-highlight > code .token.token.inserted:not(.prefix)": {
872
- backgroundColor: "rgba(16, 185, 129, 0.15)"
873
- },
874
- "pre > code.diff-highlight .token.token.inserted:not(.prefix)": {
875
- backgroundColor: "rgba(16, 185, 129, 0.15)"
876
- },
877
- "pre.diff-highlight > code .token.token.inserted:not(.prefix)::-moz-selection": {
878
- backgroundColor: "rgba(16, 185, 129, 0.25)"
879
- },
880
- "pre.diff-highlight > code .token.token.inserted:not(.prefix) *::-moz-selection": {
881
- backgroundColor: "rgba(16, 185, 129, 0.25)"
882
- },
883
- "pre > code.diff-highlight .token.token.inserted:not(.prefix)::-moz-selection": {
884
- backgroundColor: "rgba(16, 185, 129, 0.25)"
885
- },
886
- "pre > code.diff-highlight .token.token.inserted:not(.prefix) *::-moz-selection": {
887
- backgroundColor: "rgba(16, 185, 129, 0.25)"
888
- },
889
- "pre.diff-highlight > code .token.token.inserted:not(.prefix)::selection": {
890
- backgroundColor: "rgba(16, 185, 129, 0.25)"
891
- },
892
- "pre.diff-highlight > code .token.token.inserted:not(.prefix) *::selection": {
893
- backgroundColor: "rgba(16, 185, 129, 0.25)"
894
- },
895
- "pre > code.diff-highlight .token.token.inserted:not(.prefix)::selection": {
896
- backgroundColor: "rgba(16, 185, 129, 0.25)"
897
- },
898
- "pre > code.diff-highlight .token.token.inserted:not(.prefix) *::selection": {
899
- backgroundColor: "rgba(16, 185, 129, 0.25)"
900
- },
901
- ".prism-previewer.prism-previewer:before": {
902
- borderColor: "#11111f"
903
- },
904
- ".prism-previewer-gradient.prism-previewer-gradient div": {
905
- borderColor: "#11111f",
906
- borderRadius: "0.3em"
907
- },
908
- ".prism-previewer-color.prism-previewer-color:before": {
909
- borderRadius: "0.3em"
910
- },
911
- ".prism-previewer-easing.prism-previewer-easing:before": {
912
- borderRadius: "0.3em"
913
- },
914
- ".prism-previewer.prism-previewer:after": {
915
- borderTopColor: "#11111f"
916
- },
917
- ".prism-previewer-flipped.prism-previewer-flipped.after": {
918
- borderBottomColor: "#11111f"
919
- },
920
- ".prism-previewer-angle.prism-previewer-angle:before": {
921
- background: "#1e293b"
922
- },
923
- ".prism-previewer-time.prism-previewer-time:before": {
924
- background: "#1e293b"
925
- },
926
- ".prism-previewer-easing.prism-previewer-easing": {
927
- background: "#1e293b"
928
- },
929
- ".prism-previewer-angle.prism-previewer-angle circle": {
930
- stroke: "#e2e8f0",
931
- strokeOpacity: "1"
932
- },
933
- ".prism-previewer-time.prism-previewer-time circle": {
934
- stroke: "#e2e8f0",
935
- strokeOpacity: "1"
936
- },
937
- ".prism-previewer-easing.prism-previewer-easing circle": {
938
- stroke: "#e2e8f0",
939
- fill: "transparent"
940
- },
941
- ".prism-previewer-easing.prism-previewer-easing path": {
942
- stroke: "#e2e8f0"
943
- },
944
- ".prism-previewer-easing.prism-previewer-easing line": {
945
- stroke: "#e2e8f0"
946
- }
947
- };
948
- const light = {
949
- 'code[class*="language-"]': {
950
- background: "#fff",
951
- color: "#1e293b",
952
- textShadow: "none",
953
- fontFamily: '"Fira Code", "Fira Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace',
954
- direction: "ltr",
955
- textAlign: "left",
956
- whiteSpace: "pre",
957
- wordSpacing: "normal",
958
- wordBreak: "normal",
959
- lineHeight: "1.5",
960
- MozTabSize: "2",
961
- OTabSize: "2",
962
- tabSize: "2",
963
- WebkitHyphens: "none",
964
- MozHyphens: "none",
965
- msHyphens: "none",
966
- hyphens: "none"
967
- },
968
- 'pre[class*="language-"]': {
969
- background: "#fff",
970
- color: "#1e293b",
971
- textShadow: "none",
972
- fontFamily: '"Fira Code", "Fira Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace',
973
- direction: "ltr",
974
- textAlign: "left",
975
- whiteSpace: "pre",
976
- wordSpacing: "normal",
977
- wordBreak: "normal",
978
- lineHeight: "1.5",
979
- MozTabSize: "2",
980
- OTabSize: "2",
981
- tabSize: "2",
982
- WebkitHyphens: "none",
983
- MozHyphens: "none",
984
- msHyphens: "none",
985
- hyphens: "none",
986
- padding: "1em",
987
- margin: "0.5em 0",
988
- overflow: "auto",
989
- borderRadius: "0.3em",
990
- border: "1px solid #e2e8f0"
991
- },
992
- 'code[class*="language-"]::-moz-selection': {
993
- background: "#e2e8f0",
994
- color: "inherit",
995
- textShadow: "none"
996
- },
997
- 'code[class*="language-"] *::-moz-selection': {
998
- background: "#e2e8f0",
999
- color: "inherit",
1000
- textShadow: "none"
1001
- },
1002
- 'pre[class*="language-"] *::-moz-selection': {
1003
- background: "#e2e8f0",
1004
- color: "inherit",
1005
- textShadow: "none"
1006
- },
1007
- 'code[class*="language-"]::selection': {
1008
- background: "#e2e8f0",
1009
- color: "inherit",
1010
- textShadow: "none"
1011
- },
1012
- 'code[class*="language-"] *::selection': {
1013
- background: "#e2e8f0",
1014
- color: "inherit",
1015
- textShadow: "none"
1016
- },
1017
- 'pre[class*="language-"] *::selection': {
1018
- background: "#e2e8f0",
1019
- color: "inherit",
1020
- textShadow: "none"
1021
- },
1022
- ':not(pre) > code[class*="language-"]': {
1023
- padding: "0.2em 0.3em",
1024
- borderRadius: "0.3em",
1025
- whiteSpace: "normal",
1026
- background: "#f1f5f9"
1027
- },
1028
- comment: {
1029
- color: "#64748b",
1030
- fontStyle: "italic"
1031
- },
1032
- prolog: {
1033
- color: "#64748b"
1034
- },
1035
- cdata: {
1036
- color: "#64748b"
1037
- },
1038
- doctype: {
1039
- color: "#1e293b"
1040
- },
1041
- punctuation: {
1042
- color: "#64748b"
1043
- },
1044
- entity: {
1045
- color: "#3b82f6",
1046
- cursor: "help"
1047
- },
1048
- "attr-name": {
1049
- color: "#ea580c"
1050
- },
1051
- "class-name": {
1052
- color: "#ea580c"
1053
- },
1054
- boolean: {
1055
- color: "#3b82f6"
1056
- },
1057
- constant: {
1058
- color: "#3b82f6"
1059
- },
1060
- number: {
1061
- color: "#3b82f6"
1062
- },
1063
- atrule: {
1064
- color: "#ea580c"
1065
- },
1066
- keyword: {
1067
- color: "#9333ea"
1068
- },
1069
- property: {
1070
- color: "#3b82f6"
1071
- },
1072
- tag: {
1073
- color: "#3b82f6"
1074
- },
1075
- symbol: {
1076
- color: "#3b82f6"
1077
- },
1078
- deleted: {
1079
- color: "#dc2626"
1080
- },
1081
- important: {
1082
- color: "#9333ea"
1083
- },
1084
- selector: {
1085
- color: "#16a34a"
1086
- },
1087
- string: {
1088
- color: "#16a34a"
1089
- },
1090
- char: {
1091
- color: "#16a34a"
1092
- },
1093
- builtin: {
1094
- color: "#16a34a"
1095
- },
1096
- inserted: {
1097
- color: "#16a34a"
1098
- },
1099
- regex: {
1100
- color: "#16a34a"
1101
- },
1102
- "attr-value": {
1103
- color: "#16a34a"
1104
- },
1105
- "attr-value > .token.punctuation": {
1106
- color: "#16a34a"
1107
- },
1108
- variable: {
1109
- color: "#3b82f6"
1110
- },
1111
- operator: {
1112
- color: "#3b82f6"
1113
- },
1114
- function: {
1115
- color: "#3b82f6"
1116
- },
1117
- url: {
1118
- color: "#3b82f6"
1119
- },
1120
- "attr-value > .token.punctuation.attr-equals": {
1121
- color: "#64748b"
1122
- },
1123
- "special-attr > .token.attr-value > .token.value.css": {
1124
- color: "#1e293b"
1125
- },
1126
- ".language-css .token.selector": {
1127
- color: "#3b82f6"
1128
- },
1129
- ".language-css .token.property": {
1130
- color: "#1e293b"
1131
- },
1132
- ".language-css .token.function": {
1133
- color: "#3b82f6"
1134
- },
1135
- ".language-css .token.url > .token.function": {
1136
- color: "#3b82f6"
1137
- },
1138
- ".language-css .token.url > .token.string.url": {
1139
- color: "#16a34a"
1140
- },
1141
- ".language-css .token.important": {
1142
- color: "#9333ea"
1143
- },
1144
- ".language-css .token.atrule .token.rule": {
1145
- color: "#9333ea"
1146
- },
1147
- ".language-javascript .token.operator": {
1148
- color: "#9333ea"
1149
- },
1150
- ".language-javascript .token.template-string > .token.interpolation > .token.interpolation-punctuation.punctuation": {
1151
- color: "#dc2626"
1152
- },
1153
- ".language-json .token.operator": {
1154
- color: "#1e293b"
1155
- },
1156
- ".language-json .token.null.keyword": {
1157
- color: "#3b82f6"
1158
- },
1159
- ".language-markdown .token.url": {
1160
- color: "#1e293b"
1161
- },
1162
- ".language-markdown .token.url > .token.operator": {
1163
- color: "#1e293b"
1164
- },
1165
- ".language-markdown .token.url-reference.url > .token.string": {
1166
- color: "#1e293b"
1167
- },
1168
- ".language-markdown .token.url > .token.content": {
1169
- color: "#3b82f6"
1170
- },
1171
- ".language-markdown .token.url > .token.url": {
1172
- color: "#3b82f6"
1173
- },
1174
- ".language-markdown .token.url-reference.url": {
1175
- color: "#3b82f6"
1176
- },
1177
- ".language-markdown .token.blockquote.punctuation": {
1178
- color: "#64748b",
1179
- fontStyle: "italic"
1180
- },
1181
- ".language-markdown .token.hr.punctuation": {
1182
- color: "#64748b",
1183
- fontStyle: "italic"
1184
- },
1185
- ".language-markdown .token.code-snippet": {
1186
- color: "#16a34a"
1187
- },
1188
- ".language-markdown .token.bold .token.content": {
1189
- color: "#ea580c"
1190
- },
1191
- ".language-markdown .token.italic .token.content": {
1192
- color: "#9333ea"
1193
- },
1194
- ".language-markdown .token.strike .token.content": {
1195
- color: "#3b82f6"
1196
- },
1197
- ".language-markdown .token.strike .token.punctuation": {
1198
- color: "#3b82f6"
1199
- },
1200
- ".language-markdown .token.list.punctuation": {
1201
- color: "#3b82f6"
1202
- },
1203
- ".language-markdown .token.title.important > .token.punctuation": {
1204
- color: "#3b82f6"
1205
- },
1206
- bold: {
1207
- fontWeight: "bold"
1208
- },
1209
- italic: {
1210
- fontStyle: "italic"
1211
- },
1212
- namespace: {
1213
- Opacity: "0.8"
1214
- },
1215
- "token.tab:not(:empty):before": {
1216
- color: "#94a3b8"
1217
- },
1218
- "token.cr:before": {
1219
- color: "#94a3b8"
1220
- },
1221
- "token.lf:before": {
1222
- color: "#94a3b8"
1223
- },
1224
- "token.space:before": {
1225
- color: "#94a3b8"
1226
- },
1227
- "div.code-toolbar > .toolbar.toolbar > .toolbar-item": {
1228
- marginRight: "0.4em"
1229
- },
1230
- "div.code-toolbar > .toolbar.toolbar > .toolbar-item > button": {
1231
- background: "#f1f5f9",
1232
- color: "#475569",
1233
- padding: "0.1em 0.4em",
1234
- borderRadius: "0.3em"
1235
- },
1236
- "div.code-toolbar > .toolbar.toolbar > .toolbar-item > a": {
1237
- background: "#f1f5f9",
1238
- color: "#475569",
1239
- padding: "0.1em 0.4em",
1240
- borderRadius: "0.3em"
1241
- },
1242
- "div.code-toolbar > .toolbar.toolbar > .toolbar-item > span": {
1243
- background: "#f1f5f9",
1244
- color: "#475569",
1245
- padding: "0.1em 0.4em",
1246
- borderRadius: "0.3em"
1247
- },
1248
- "div.code-toolbar > .toolbar.toolbar > .toolbar-item > button:hover": {
1249
- background: "#3b82f6",
1250
- color: "#ffffff"
1251
- },
1252
- "div.code-toolbar > .toolbar.toolbar > .toolbar-item > button:focus": {
1253
- background: "#3b82f6",
1254
- color: "#ffffff"
1255
- },
1256
- "div.code-toolbar > .toolbar.toolbar > .toolbar-item > a:hover": {
1257
- background: "#3b82f6",
1258
- color: "#ffffff"
1259
- },
1260
- "div.code-toolbar > .toolbar.toolbar > .toolbar-item > a:focus": {
1261
- background: "#3b82f6",
1262
- color: "#ffffff"
1263
- },
1264
- "div.code-toolbar > .toolbar.toolbar > .toolbar-item > span:hover": {
1265
- background: "#3b82f6",
1266
- color: "#ffffff"
1267
- },
1268
- "div.code-toolbar > .toolbar.toolbar > .toolbar-item > span:focus": {
1269
- background: "#3b82f6",
1270
- color: "#ffffff"
1271
- },
1272
- ".line-highlight.line-highlight": {
1273
- background: "rgba(59, 130, 246, 0.08)"
1274
- },
1275
- ".line-highlight.line-highlight:before": {
1276
- background: "#f1f5f9",
1277
- color: "#1e293b",
1278
- padding: "0.1em 0.6em",
1279
- borderRadius: "0.3em",
1280
- boxShadow: "0 2px 0 0 rgba(0, 0, 0, 0.1)"
1281
- },
1282
- ".line-highlight.line-highlight[data-end]:after": {
1283
- background: "#f1f5f9",
1284
- color: "#1e293b",
1285
- padding: "0.1em 0.6em",
1286
- borderRadius: "0.3em",
1287
- boxShadow: "0 2px 0 0 rgba(0, 0, 0, 0.1)"
1288
- },
1289
- "pre[id].linkable-line-numbers.linkable-line-numbers span.line-numbers-rows > span:hover:before": {
1290
- backgroundColor: "rgba(59, 130, 246, 0.08)"
1291
- },
1292
- ".line-numbers.line-numbers .line-numbers-rows": {
1293
- borderRightColor: "#e2e8f0"
1294
- },
1295
- ".command-line .command-line-prompt": {
1296
- borderRightColor: "#e2e8f0"
1297
- },
1298
- ".line-numbers .line-numbers-rows > span:before": {
1299
- color: "#94a3b8"
1300
- },
1301
- ".command-line .command-line-prompt > span:before": {
1302
- color: "#94a3b8"
1303
- },
1304
- ".rainbow-braces .token.token.punctuation.brace-level-1": {
1305
- color: "#3b82f6"
1306
- },
1307
- ".rainbow-braces .token.token.punctuation.brace-level-5": {
1308
- color: "#3b82f6"
1309
- },
1310
- ".rainbow-braces .token.token.punctuation.brace-level-9": {
1311
- color: "#3b82f6"
1312
- },
1313
- ".rainbow-braces .token.token.punctuation.brace-level-2": {
1314
- color: "#16a34a"
1315
- },
1316
- ".rainbow-braces .token.token.punctuation.brace-level-6": {
1317
- color: "#16a34a"
1318
- },
1319
- ".rainbow-braces .token.token.punctuation.brace-level-10": {
1320
- color: "#16a34a"
1321
- },
1322
- ".rainbow-braces .token.token.punctuation.brace-level-3": {
1323
- color: "#ea580c"
1324
- },
1325
- ".rainbow-braces .token.token.punctuation.brace-level-7": {
1326
- color: "#ea580c"
1327
- },
1328
- ".rainbow-braces .token.token.punctuation.brace-level-11": {
1329
- color: "#ea580c"
1330
- },
1331
- ".rainbow-braces .token.token.punctuation.brace-level-4": {
1332
- color: "#9333ea"
1333
- },
1334
- ".rainbow-braces .token.token.punctuation.brace-level-8": {
1335
- color: "#9333ea"
1336
- },
1337
- ".rainbow-braces .token.token.punctuation.brace-level-12": {
1338
- color: "#9333ea"
1339
- },
1340
- "pre.diff-highlight > code .token.token.deleted:not(.prefix)": {
1341
- backgroundColor: "rgba(220, 38, 38, 0.15)"
1342
- },
1343
- "pre > code.diff-highlight .token.token.deleted:not(.prefix)": {
1344
- backgroundColor: "rgba(220, 38, 38, 0.15)"
1345
- },
1346
- "pre.diff-highlight > code .token.token.deleted:not(.prefix)::-moz-selection": {
1347
- backgroundColor: "rgba(220, 38, 38, 0.25)"
1348
- },
1349
- "pre.diff-highlight > code .token.token.deleted:not(.prefix) *::-moz-selection": {
1350
- backgroundColor: "rgba(220, 38, 38, 0.25)"
1351
- },
1352
- "pre > code.diff-highlight .token.token.deleted:not(.prefix)::-moz-selection": {
1353
- backgroundColor: "rgba(220, 38, 38, 0.25)"
1354
- },
1355
- "pre > code.diff-highlight .token.token.deleted:not(.prefix) *::-moz-selection": {
1356
- backgroundColor: "rgba(220, 38, 38, 0.25)"
1357
- },
1358
- "pre.diff-highlight > code .token.token.deleted:not(.prefix)::selection": {
1359
- backgroundColor: "rgba(220, 38, 38, 0.25)"
1360
- },
1361
- "pre.diff-highlight > code .token.token.deleted:not(.prefix) *::selection": {
1362
- backgroundColor: "rgba(220, 38, 38, 0.25)"
1363
- },
1364
- "pre > code.diff-highlight .token.token.deleted:not(.prefix)::selection": {
1365
- backgroundColor: "rgba(220, 38, 38, 0.25)"
1366
- },
1367
- "pre > code.diff-highlight .token.token.deleted:not(.prefix) *::selection": {
1368
- backgroundColor: "rgba(220, 38, 38, 0.25)"
1369
- },
1370
- "pre.diff-highlight > code .token.token.inserted:not(.prefix)": {
1371
- backgroundColor: "rgba(22, 163, 74, 0.15)"
1372
- },
1373
- "pre > code.diff-highlight .token.token.inserted:not(.prefix)": {
1374
- backgroundColor: "rgba(22, 163, 74, 0.15)"
1375
- },
1376
- "pre.diff-highlight > code .token.token.inserted:not(.prefix)::-moz-selection": {
1377
- backgroundColor: "rgba(22, 163, 74, 0.25)"
1378
- },
1379
- "pre.diff-highlight > code .token.token.inserted:not(.prefix) *::-moz-selection": {
1380
- backgroundColor: "rgba(22, 163, 74, 0.25)"
1381
- },
1382
- "pre > code.diff-highlight .token.token.inserted:not(.prefix)::-moz-selection": {
1383
- backgroundColor: "rgba(22, 163, 74, 0.25)"
1384
- },
1385
- "pre > code.diff-highlight .token.token.inserted:not(.prefix) *::-moz-selection": {
1386
- backgroundColor: "rgba(22, 163, 74, 0.25)"
1387
- },
1388
- "pre.diff-highlight > code .token.token.inserted:not(.prefix)::selection": {
1389
- backgroundColor: "rgba(22, 163, 74, 0.25)"
1390
- },
1391
- "pre.diff-highlight > code .token.token.inserted:not(.prefix) *::selection": {
1392
- backgroundColor: "rgba(22, 163, 74, 0.25)"
1393
- },
1394
- "pre > code.diff-highlight .token.token.inserted:not(.prefix)::selection": {
1395
- backgroundColor: "rgba(22, 163, 74, 0.25)"
1396
- },
1397
- "pre > code.diff-highlight .token.token.inserted:not(.prefix) *::selection": {
1398
- backgroundColor: "rgba(22, 163, 74, 0.25)"
1399
- },
1400
- ".prism-previewer.prism-previewer:before": {
1401
- borderColor: "#fff"
1402
- },
1403
- ".prism-previewer-gradient.prism-previewer-gradient div": {
1404
- borderColor: "#fff",
1405
- borderRadius: "0.3em"
1406
- },
1407
- ".prism-previewer-color.prism-previewer-color:before": {
1408
- borderRadius: "0.3em"
1409
- },
1410
- ".prism-previewer-easing.prism-previewer-easing:before": {
1411
- borderRadius: "0.3em"
1412
- },
1413
- ".prism-previewer.prism-previewer:after": {
1414
- borderTopColor: "#fff"
1415
- },
1416
- ".prism-previewer-flipped.prism-previewer-flipped.after": {
1417
- borderBottomColor: "#fff"
1418
- },
1419
- ".prism-previewer-angle.prism-previewer-angle:before": {
1420
- background: "#f1f5f9"
1421
- },
1422
- ".prism-previewer-time.prism-previewer-time:before": {
1423
- background: "#f1f5f9"
1424
- },
1425
- ".prism-previewer-easing.prism-previewer-easing": {
1426
- background: "#f1f5f9"
1427
- },
1428
- ".prism-previewer-angle.prism-previewer-angle circle": {
1429
- stroke: "#1e293b",
1430
- strokeOpacity: "1"
1431
- },
1432
- ".prism-previewer-time.prism-previewer-time circle": {
1433
- stroke: "#1e293b",
1434
- strokeOpacity: "1"
1435
- },
1436
- ".prism-previewer-easing.prism-previewer-easing circle": {
1437
- stroke: "#1e293b",
1438
- fill: "transparent"
1439
- },
1440
- ".prism-previewer-easing.prism-previewer-easing path": {
1441
- stroke: "#1e293b"
1442
- },
1443
- ".prism-previewer-easing.prism-previewer-easing line": {
1444
- stroke: "#1e293b"
1445
- }
1446
- };
1447
- const CodeHighlighter = ({
1448
- className,
1449
- children,
1450
- copyClassName,
1451
- copyIcon = /* @__PURE__ */ jsx(SvgCopy, {}),
1452
- language,
1453
- toolbarClassName,
1454
- theme = dark
1455
- }) => {
1456
- const match = language?.match(/language-(\w+)/);
1457
- const lang = match ? match[1] : "text";
1458
- const handleCopy = (text) => {
1459
- navigator.clipboard.writeText(text).then(() => {
1460
- console.log("Text copied to clipboard");
1461
- }).catch((err) => {
1462
- console.error("Could not copy text: ", err);
1463
- });
1464
- };
1465
- return /* @__PURE__ */ jsxs("div", { className: cn("relative", className), children: [
1466
- /* @__PURE__ */ jsxs("div", { className: cn(toolbarClassName), children: [
1467
- /* @__PURE__ */ jsx("div", { children: lang }),
1468
- copyIcon && /* @__PURE__ */ jsx(
1469
- Button,
1470
- {
1471
- className: cn(copyClassName),
1472
- size: "small",
1473
- variant: "ghost",
1474
- title: "Copy code",
1475
- onClick: () => handleCopy(children),
1476
- children: copyIcon
1477
- }
1478
- )
1479
- ] }),
1480
- /* @__PURE__ */ jsx(Prism, { language: lang, style: theme, children })
1481
- ] });
1482
- };
1483
- const TableComponent = ({ children, ...props }) => /* @__PURE__ */ jsx("table", { ...props, children });
1484
- const TableHeaderCell = ({ children, ...props }) => /* @__PURE__ */ jsx("th", { ...props, children });
1485
- const TableDataCell = ({ children, ...props }) => /* @__PURE__ */ jsx("td", { ...props, children });
1486
- const Markdown = ({
1487
- children,
1488
- remarkPlugins,
1489
- rehypePlugins = [rehypeKatex],
1490
- theme
1491
- }) => /* @__PURE__ */ jsx(
1492
- ReactMarkdown,
1493
- {
1494
- remarkPlugins,
1495
- rehypePlugins,
1496
- components: {
1497
- code: ({ className, ...props }) => /* @__PURE__ */ jsx(
1498
- CodeHighlighter,
1499
- {
1500
- ...props,
1501
- language: className,
1502
- className: cn(theme.messages.message.markdown.code, className),
1503
- copyClassName: cn(theme.messages.message.markdown.copy),
1504
- toolbarClassName: cn(theme.messages.message.markdown.toolbar)
1505
- }
1506
- ),
1507
- table: (props) => /* @__PURE__ */ jsx(
1508
- TableComponent,
1509
- {
1510
- ...props,
1511
- className: cn(theme.messages.message.markdown.table)
1512
- }
1513
- ),
1514
- th: (props) => /* @__PURE__ */ jsx(
1515
- TableHeaderCell,
1516
- {
1517
- ...props,
1518
- className: cn(theme.messages.message.markdown.th)
1519
- }
1520
- ),
1521
- td: (props) => /* @__PURE__ */ jsx(
1522
- TableDataCell,
1523
- {
1524
- ...props,
1525
- className: cn(theme.messages.message.markdown.td)
1526
- }
1527
- ),
1528
- a: (props) => /* @__PURE__ */ jsx("a", { ...props, className: cn(theme.messages.message.markdown.a) }),
1529
- p: (props) => /* @__PURE__ */ jsx("p", { ...props, className: cn(theme.messages.message.markdown.p) }),
1530
- li: (props) => /* @__PURE__ */ jsx("li", { ...props, className: cn(theme.messages.message.markdown.li) }),
1531
- ul: (props) => /* @__PURE__ */ jsx("ul", { ...props, className: cn(theme.messages.message.markdown.ul) }),
1532
- ol: (props) => /* @__PURE__ */ jsx("ol", { ...props, className: cn(theme.messages.message.markdown.ol) })
1533
- },
1534
- children
1535
- }
1536
- );
1537
- const CVE_REGEX = /(CVE-(19|20)\d{2}-\d{4,7})/gi;
1538
- function remarkCve() {
1539
- return (tree) => {
1540
- findAndReplace(tree, [[CVE_REGEX, replaceCve]], {
1541
- ignore: ["link"]
1542
- });
1543
- };
1544
- function replaceCve(value, id) {
1545
- return [
1546
- {
1547
- type: "link",
1548
- url: `https://cve.mitre.org/cgi-bin/cvename.cgi?name=${id}`,
1549
- children: [{ children: [{ type: "text", value: value.trim() }] }]
1550
- }
1551
- ];
1552
- }
1553
- }
1554
- const SessionEmpty = ({ children }) => {
1555
- const { theme } = useContext(ChatContext);
1556
- return /* @__PURE__ */ jsx("div", { className: cn(theme.empty), children });
1557
- };
1558
- const SvgRefresh = (props) => /* @__PURE__ */ React.createElement("svg", { width: 18, height: 18, viewBox: "0 0 18 18", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props }, /* @__PURE__ */ React.createElement("path", { d: "M1.75 8.25098C2.16399 8.25098 2.49998 8.58699 2.5 9.00098C2.5 12.585 5.416 15.501 9 15.501C11.149 15.501 13.1291 14.4262 14.3301 12.6992L12.8701 12.9014C12.4591 12.9484 12.0814 12.6698 12.0244 12.2598C11.9685 11.8498 12.2541 11.4711 12.665 11.4141L15.6094 11.0068L15.6104 11.0078C16.0172 10.951 16.3981 11.2386 16.4551 11.6484L16.8633 14.5928C16.9203 15.0038 16.6327 15.3825 16.2227 15.4395C16.1878 15.4444 16.153 15.4463 16.1191 15.4463C15.7501 15.4463 15.429 15.1738 15.377 14.7988L15.2598 13.9551C13.7628 15.842 11.4739 17.001 9 17.001C4.589 17.001 1 13.412 1 9.00098C1.00002 8.58699 1.33601 8.25098 1.75 8.25098ZM9.00098 1C13.412 1 17.001 4.589 17.001 9C17.001 9.414 16.665 9.75 16.251 9.75C15.837 9.75 15.501 9.414 15.501 9C15.501 5.416 12.585 2.5 9.00098 2.5C6.84502 2.5 4.87188 3.57384 3.67188 5.30078L5.12988 5.09863C5.53788 5.04563 5.91859 5.32923 5.97559 5.74023C6.03148 6.15017 5.7459 6.52895 5.33496 6.58594L2.39062 6.99316C2.35579 6.99812 2.32095 6.99999 2.28711 7C1.91811 7 1.59692 6.72754 1.54492 6.35254L1.13672 3.4082C1.07972 2.9972 1.36734 2.61852 1.77734 2.56152C2.18818 2.50179 2.56607 2.79129 2.62305 3.20215L2.73926 4.04199C4.23526 2.15508 6.52006 1 9 1H9.00098Z", fill: "currentColor" }));
1559
- const SvgThumbsDown = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 18, height: 18, viewBox: "0 0 18 18", fill: "none", ...props }, /* @__PURE__ */ React.createElement("path", { d: "M11.25 1.25H4.5C3.8775 1.25 3.345 1.625 3.12 2.165L0.855 7.4525C0.7875 7.625 0.75 7.805 0.75 8V9.5C0.75 10.325 1.425 11 2.25 11H6.9825L6.27 14.4275L6.2475 14.6675C6.2475 14.975 6.375 15.26 6.5775 15.4625L7.3725 16.25L12.315 11.3075C12.585 11.0375 12.75 10.6625 12.75 10.25V2.75C12.75 1.925 12.075 1.25 11.25 1.25ZM11.25 10.25L7.995 13.505L9 9.5H2.25V8L4.5 2.75H11.25V10.25ZM14.25 1.25H17.25V10.25H14.25V1.25Z", fill: "currentColor" }));
1560
- const SvgThumbsUp = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 18, height: 18, viewBox: "0 0 18 18", fill: "none", ...props }, /* @__PURE__ */ React.createElement("path", { d: "M6.75 15.75H13.5C14.1225 15.75 14.655 15.375 14.88 14.835L17.145 9.5475C17.2125 9.375 17.25 9.195 17.25 9V7.5C17.25 6.675 16.575 6 15.75 6H11.0175L11.73 2.5725L11.7525 2.3325C11.7525 2.025 11.625 1.74 11.4225 1.5375L10.6275 0.75L5.685 5.6925C5.415 5.9625 5.25 6.3375 5.25 6.75V14.25C5.25 15.075 5.925 15.75 6.75 15.75ZM6.75 6.75L10.005 3.495L9 7.5H15.75V9L13.5 14.25H6.75V6.75ZM0.75 6.75H3.75V15.75H0.75V6.75Z", fill: "currentColor" }));
1561
- const MessageActions = ({
1562
- children,
1563
- ...props
1564
- }) => {
1565
- const { theme } = useContext(ChatContext);
1566
- const {
1567
- question,
1568
- response,
1569
- copyIcon = /* @__PURE__ */ jsx(SvgCopy, {}),
1570
- thumbsUpIcon = /* @__PURE__ */ jsx(SvgThumbsUp, {}),
1571
- thumbsDownIcon = /* @__PURE__ */ jsx(SvgThumbsDown, {}),
1572
- refreshIcon = /* @__PURE__ */ jsx(SvgRefresh, {}),
1573
- onCopy,
1574
- onUpvote,
1575
- onDownvote,
1576
- onRefresh
1577
- } = props;
1578
- const Comp = children ? Slot : "div";
1579
- const handleCopy = (text) => {
1580
- navigator.clipboard.writeText(text).then(() => {
1581
- console.log("Text copied to clipboard");
1582
- }).catch((err) => {
1583
- console.error("Could not copy text: ", err);
1584
- });
1585
- };
1586
- return (copyIcon || thumbsDownIcon || thumbsUpIcon || refreshIcon) && /* @__PURE__ */ jsx(Comp, { className: cn(theme.messages.message.footer.base), children: children || /* @__PURE__ */ jsxs(Fragment, { children: [
1587
- copyIcon && /* @__PURE__ */ jsx(
1588
- IconButton,
1589
- {
1590
- variant: "ghost",
1591
- disablePadding: true,
1592
- title: "Copy question and response",
1593
- className: cn(theme.messages.message.footer.copy),
1594
- onClick: onCopy ? onCopy : () => handleCopy(`${question}
1595
- ${response}`),
1596
- children: copyIcon
1597
- }
1598
- ),
1599
- thumbsUpIcon && /* @__PURE__ */ jsx(
1600
- IconButton,
1601
- {
1602
- variant: "ghost",
1603
- disablePadding: true,
1604
- title: "Upvote",
1605
- className: cn(theme.messages.message.footer.upvote),
1606
- onClick: onUpvote,
1607
- children: thumbsUpIcon
1608
- }
1609
- ),
1610
- thumbsDownIcon && /* @__PURE__ */ jsx(
1611
- IconButton,
1612
- {
1613
- variant: "ghost",
1614
- disablePadding: true,
1615
- title: "Downvote",
1616
- className: cn(theme.messages.message.footer.downvote),
1617
- onClick: onDownvote,
1618
- children: thumbsDownIcon
1619
- }
1620
- ),
1621
- refreshIcon && /* @__PURE__ */ jsx(
1622
- IconButton,
1623
- {
1624
- variant: "ghost",
1625
- disablePadding: true,
1626
- title: "Refresh",
1627
- className: cn(theme.messages.message.footer.refresh),
1628
- onClick: onRefresh,
1629
- children: refreshIcon
1630
- }
1631
- )
1632
- ] }) });
1633
- };
1634
- const SvgFile = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 16, height: 16, viewBox: "0 0 16 16", fill: "currentColor", ...props }, /* @__PURE__ */ React.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M2.7036 1.37034C3.04741 1.02653 3.51373 0.833374 3.99996 0.833374H9.33329H9.33331C9.47275 0.833374 9.59885 0.890449 9.68954 0.98251L13.6843 4.97722C13.7763 5.0679 13.8333 5.19398 13.8333 5.33337L13.8333 5.3379V13.3334C13.8333 13.8196 13.6401 14.2859 13.2963 14.6297C12.9525 14.9736 12.4862 15.1667 12 15.1667H3.99996C3.51373 15.1667 3.04741 14.9736 2.7036 14.6297C2.35978 14.2859 2.16663 13.8196 2.16663 13.3334V2.66671C2.16663 2.18048 2.35978 1.71416 2.7036 1.37034ZM3.99996 1.83337H8.83331V5.33337C8.83331 5.60952 9.05717 5.83337 9.33331 5.83337H12.8333V13.3334C12.8333 13.5544 12.7455 13.7663 12.5892 13.9226C12.4329 14.0789 12.221 14.1667 12 14.1667H3.99996C3.77895 14.1667 3.56698 14.0789 3.4107 13.9226C3.25442 13.7663 3.16663 13.5544 3.16663 13.3334V2.66671C3.16663 2.44569 3.25442 2.23373 3.4107 2.07745C3.56698 1.92117 3.77895 1.83337 3.99996 1.83337ZM9.83331 2.5405L12.1262 4.83337H9.83331V2.5405ZM5.33331 8.16663C5.05717 8.16663 4.83331 8.39048 4.83331 8.66663C4.83331 8.94277 5.05717 9.16663 5.33331 9.16663H10.6666C10.9428 9.16663 11.1666 8.94277 11.1666 8.66663C11.1666 8.39048 10.9428 8.16663 10.6666 8.16663H5.33331ZM4.83331 11.3334C4.83331 11.0572 5.05717 10.8334 5.33331 10.8334H10.6666C10.9428 10.8334 11.1666 11.0572 11.1666 11.3334C11.1666 11.6095 10.9428 11.8334 10.6666 11.8334H5.33331C5.05717 11.8334 4.83331 11.6095 4.83331 11.3334ZM5.33331 5.5C5.05717 5.5 4.83331 5.72386 4.83331 6C4.83331 6.27614 5.05717 6.5 5.33331 6.5H6.66665C6.94279 6.5 7.16665 6.27614 7.16665 6C7.16665 5.72386 6.94279 5.5 6.66665 5.5H5.33331Z" }));
1635
- const DefaultFileRenderer = lazy(
1636
- () => import("./DefaultFileRenderer-C1qZ57tG.js")
1637
- );
1638
- const CSVFileRenderer = lazy(() => import("./CSVFileRenderer-CkRKGiCl.js"));
1639
- const ImageFileRenderer = lazy(() => import("./ImageFileRenderer-C8tVW3I8.js"));
1640
- const PDFFileRenderer = lazy(() => import("./PDFFileRenderer-BBn2EVrV.js"));
1641
- const FILE_TYPE_RENDERER_MAP = {
1642
- "image/": ImageFileRenderer,
1643
- "text/csv": CSVFileRenderer,
1644
- "application/pdf": PDFFileRenderer
1645
- };
1646
- const MessageFile = ({
1647
- name,
1648
- type,
1649
- url,
1650
- limit = 100,
1651
- fileIcon = /* @__PURE__ */ jsx(SvgFile, {})
1652
- }) => {
1653
- const { theme } = useContext(ChatContext);
1654
- const FileRenderer = useMemo(() => {
1655
- const Renderer = Object.keys(FILE_TYPE_RENDERER_MAP).find((key) => type?.startsWith(key)) ?? "default";
1656
- return FILE_TYPE_RENDERER_MAP[Renderer] || DefaultFileRenderer;
1657
- }, [type]);
1658
- return /* @__PURE__ */ jsx("div", { className: cn(theme.messages.message.files.file.base), children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: /* @__PURE__ */ jsx(FileRenderer, { name, url, fileIcon, limit }) }) });
1659
- };
1660
- const MessageFiles = ({ files, children }) => {
1661
- const { theme } = useContext(ChatContext);
1662
- const Comp = children ? Slot : MessageFile;
1663
- const [expanded, setExpanded] = useState(false);
1664
- if (!files || files.length === 0) {
1665
- return null;
1666
- }
1667
- const { imageFiles, otherFiles } = files.reduce(
1668
- (acc, file) => {
1669
- if (file.type.startsWith("image/")) {
1670
- acc.imageFiles.push(file);
1671
- } else {
1672
- acc.otherFiles.push(file);
1673
- }
1674
- return acc;
1675
- },
1676
- {
1677
- imageFiles: [],
1678
- otherFiles: []
1679
- }
1680
- );
1681
- const maxImageLength = 3;
1682
- const truncateImages = !expanded && imageFiles.length > maxImageLength;
1683
- const renderImageFiles = (images) => {
1684
- return truncateImages ? images.slice(0, maxImageLength).map((image, index) => /* @__PURE__ */ jsxs(
1685
- "figure",
1686
- {
1687
- className: index === 0 ? "col-span-2 row-span-2" : "relative",
1688
- children: [
1689
- /* @__PURE__ */ jsx(
1690
- "img",
1691
- {
1692
- src: image.url,
1693
- alt: image.name,
1694
- className: "relative w-full h-full object-cover rounded-lg"
1695
- }
1696
- ),
1697
- index === maxImageLength - 1 && /* @__PURE__ */ jsxs(
1698
- "div",
1699
- {
1700
- className: "absolute top-0 left-0 w-full h-full flex justify-center items-center bg-black bg-opacity-50 rounded-lg cursor-pointer",
1701
- onClick: () => setExpanded(true),
1702
- children: [
1703
- "+",
1704
- (imageFiles.length - maxImageLength).toLocaleString()
1705
- ]
1706
- }
1707
- )
1708
- ]
1709
- },
1710
- index
1711
- )) : images.map((image, index) => /* @__PURE__ */ jsx(Comp, { ...image, children }, index));
1712
- };
1713
- return /* @__PURE__ */ jsxs(
1714
- "div",
1715
- {
1716
- className: cn(
1717
- theme.messages.message.files.base,
1718
- truncateImages ? "grid grid-rows-2 grid-flow-col gap-2 w-1/3" : ""
1719
- ),
1720
- children: [
1721
- imageFiles.length > 0 && renderImageFiles(imageFiles),
1722
- otherFiles.length > 0 && otherFiles.map((file, index) => /* @__PURE__ */ jsx(Comp, { ...file, children }, index))
1723
- ]
1724
- }
1725
- );
1726
- };
1727
- const MessageQuestion = ({
1728
- children,
1729
- ...props
1730
- }) => {
1731
- const { theme, remarkPlugins } = useContext(ChatContext);
1732
- const { question, files } = props;
1733
- const Comp = children ? Slot : "div";
1734
- const [expanded, setExpanded] = useState(false);
1735
- const isLong = question.length > 500;
1736
- return /* @__PURE__ */ jsx(
1737
- Comp,
1738
- {
1739
- className: cn(theme.messages.message.question, {
1740
- [theme.messages.message.overlay]: isLong && !expanded
1741
- }),
1742
- ...props,
1743
- children: children || /* @__PURE__ */ jsxs(Fragment, { children: [
1744
- /* @__PURE__ */ jsx(MessageFiles, { files }),
1745
- /* @__PURE__ */ jsx(Markdown, { remarkPlugins, theme, children: question }),
1746
- isLong && !expanded && /* @__PURE__ */ jsx(
1747
- Button,
1748
- {
1749
- variant: "link",
1750
- size: "small",
1751
- className: theme.messages.message.expand,
1752
- onClick: () => setExpanded(true),
1753
- children: "Show more"
1754
- }
1755
- )
1756
- ] })
1757
- }
1758
- );
1759
- };
1760
- const MessageResponse = ({
1761
- response,
1762
- isLoading,
1763
- children
1764
- }) => {
1765
- const { theme, isCompact, remarkPlugins } = useContext(ChatContext);
1766
- const Comp = children ? Slot : "div";
1767
- return /* @__PURE__ */ jsx(
1768
- Comp,
1769
- {
1770
- "data-compact": isCompact,
1771
- className: cn(theme.messages.message.response),
1772
- children: children || /* @__PURE__ */ jsxs(Fragment, { children: [
1773
- /* @__PURE__ */ jsx(Markdown, { remarkPlugins, theme, children: response }),
1774
- isLoading && /* @__PURE__ */ jsx(
1775
- motion.div,
1776
- {
1777
- className: cn(theme.messages.message.cursor),
1778
- animate: { opacity: [1, 0] },
1779
- transition: {
1780
- duration: 0.7,
1781
- repeat: Infinity,
1782
- repeatType: "reverse"
1783
- }
1784
- }
1785
- )
1786
- ] })
1787
- }
1788
- );
1789
- };
1790
- const MessageSource = ({
1791
- title,
1792
- url,
1793
- image,
1794
- limit = 50
1795
- }) => {
1796
- const { theme, isCompact } = useContext(ChatContext);
1797
- return /* @__PURE__ */ jsxs(
1798
- "figure",
1799
- {
1800
- className: cn(theme.messages.message.sources.source.base, {
1801
- [theme.messages.message.sources.source.companion]: isCompact
1802
- }),
1803
- onClick: () => {
1804
- if (url) {
1805
- window.open(url, "_blank");
1806
- }
1807
- },
1808
- children: [
1809
- image && /* @__PURE__ */ jsx(
1810
- "img",
1811
- {
1812
- src: image,
1813
- alt: title,
1814
- className: cn(theme.messages.message.sources.source.image)
1815
- }
1816
- ),
1817
- (title || url) && /* @__PURE__ */ jsxs("figcaption", { children: [
1818
- title && /* @__PURE__ */ jsx("span", { className: cn(theme.messages.message.sources.source.title), children: /* @__PURE__ */ jsx(Ellipsis, { value: title, limit }) }),
1819
- url && /* @__PURE__ */ jsx(
1820
- "a",
1821
- {
1822
- href: url,
1823
- target: "_blank",
1824
- rel: "noopener noreferrer",
1825
- className: cn(theme.messages.message.sources.source.url),
1826
- children: url
1827
- }
1828
- )
1829
- ] })
1830
- ]
1831
- }
1832
- );
1833
- };
1834
- const MessageSources = ({
1835
- sources,
1836
- children
1837
- }) => {
1838
- const { theme } = useContext(ChatContext);
1839
- const Comp = children ? Slot : MessageSource;
1840
- if (!sources || sources.length === 0) {
1841
- return null;
1842
- }
1843
- return sources && sources.length > 0 && /* @__PURE__ */ jsx("div", { className: cn(theme.messages.message.sources.base), children: sources.map((source, index) => /* @__PURE__ */ jsx(Comp, { ...source, children }, index)) });
1844
- };
1845
- const messageVariants = {
1846
- hidden: {
1847
- opacity: 0,
1848
- y: 20
1849
- },
1850
- visible: {
1851
- opacity: 1,
1852
- y: 0,
1853
- transition: {
1854
- duration: 0.3
1855
- }
1856
- }
1857
- };
1858
- const SessionMessage = ({
1859
- className,
1860
- conversation,
1861
- isLast,
1862
- children
1863
- }) => {
1864
- const { theme, isLoading } = useContext(ChatContext);
1865
- return /* @__PURE__ */ jsxs(motion.div, { variants: messageVariants, children: [
1866
- /* @__PURE__ */ jsx(Card, { className: cn(theme.messages.message.base, className), children: children || /* @__PURE__ */ jsxs(Fragment, { children: [
1867
- /* @__PURE__ */ jsx(
1868
- MessageQuestion,
1869
- {
1870
- question: conversation.question,
1871
- files: conversation.files
1872
- }
1873
- ),
1874
- /* @__PURE__ */ jsx(
1875
- MessageResponse,
1876
- {
1877
- response: conversation.response,
1878
- isLoading: isLast && isLoading
1879
- }
1880
- ),
1881
- /* @__PURE__ */ jsx(MessageSources, { sources: conversation.sources }),
1882
- /* @__PURE__ */ jsx(
1883
- MessageActions,
1884
- {
1885
- question: conversation.question,
1886
- response: conversation.response
1887
- }
1888
- )
1889
- ] }) }),
1890
- !isLast && /* @__PURE__ */ jsx(Divider, {})
1891
- ] }, conversation.id);
1892
- };
1893
- const SvgBack = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 50 50", width: "24px", height: "24px", ...props }, /* @__PURE__ */ React.createElement("path", { d: "M 34.980469 3.992188 C 34.71875 3.996094 34.472656 4.105469 34.292969 4.292969 L 14.292969 24.292969 C 13.902344 24.683594 13.902344 25.316406 14.292969 25.707031 L 34.292969 45.707031 C 34.542969 45.96875 34.917969 46.074219 35.265625 45.980469 C 35.617188 45.890625 35.890625 45.617188 35.980469 45.265625 C 36.074219 44.917969 35.96875 44.542969 35.707031 44.292969 L 16.414063 25 L 35.707031 5.707031 C 36.003906 5.417969 36.089844 4.980469 35.929688 4.601563 C 35.769531 4.21875 35.394531 3.976563 34.980469 3.992188 Z", fill: "currentColor" }));
1894
- const SessionMessagePanel = ({
1895
- children,
1896
- allowBack = true
1897
- }) => {
1898
- const { activeSessionId, theme, isCompact, selectSession, viewType } = useContext(ChatContext);
1899
- const isVisible = isCompact && activeSessionId || viewType === "chat" || !isCompact;
1900
- return isVisible && /* @__PURE__ */ jsx(
1901
- motion.div,
1902
- {
1903
- initial: { translateX: "200%" },
1904
- animate: {
1905
- translateX: "0%",
1906
- transition: {
1907
- type: "tween",
1908
- ease: "linear",
1909
- duration: 0.2,
1910
- when: "beforeChildren"
1911
- }
1912
- },
1913
- exit: { translateX: "200%" },
1914
- className: cn(theme.messages.base, {
1915
- [theme.messages.companion]: isCompact,
1916
- [theme.messages.console]: !isCompact
1917
- }),
1918
- children: /* @__PURE__ */ jsxs("div", { className: cn(theme.messages.inner), children: [
1919
- allowBack && isCompact && viewType !== "chat" && /* @__PURE__ */ jsxs(
1920
- Button,
1921
- {
1922
- variant: "text",
1923
- size: "small",
1924
- onClick: () => selectSession(null),
1925
- className: cn(theme.messages.back),
1926
- children: [
1927
- /* @__PURE__ */ jsx(SvgBack, {}),
1928
- "Back"
1929
- ]
1930
- }
1931
- ),
1932
- children
1933
- ] })
1934
- }
1935
- );
1936
- };
1937
- const containerVariants = {
1938
- hidden: {},
1939
- visible: {
1940
- transition: {
1941
- staggerChildren: 0.07,
1942
- when: "beforeChildren"
1943
- }
1944
- }
1945
- };
1946
- const SessionMessages = ({
1947
- children,
1948
- newSessionContent,
1949
- limit = 10,
1950
- className,
1951
- showMoreText = "Show more",
1952
- autoScroll = true
1953
- }) => {
1954
- const { activeSession, theme } = useContext(ChatContext);
1955
- const contentRef = useRef(null);
1956
- const [isAnimating, setIsAnimating] = useState(true);
1957
- useEffect(() => {
1958
- if (contentRef.current && autoScroll) {
1959
- requestAnimationFrame(
1960
- () => contentRef.current.scrollTop = contentRef.current.scrollHeight
1961
- );
1962
- }
1963
- }, [activeSession, autoScroll, isAnimating]);
1964
- function handleShowMore() {
1965
- showNext(limit);
1966
- requestAnimationFrame(() => contentRef.current.scrollTop = 0);
1967
- }
1968
- const reversedConvos = useMemo(
1969
- () => [...activeSession?.conversations ?? []].reverse(),
1970
- [activeSession]
1971
- );
1972
- const { data, hasMore, showNext } = useInfinityList({
1973
- items: reversedConvos,
1974
- size: limit
1975
- });
1976
- const reReversedConvo = useMemo(() => [...data].reverse(), [data]);
1977
- const convosToRender = limit ? reReversedConvo : activeSession?.conversations;
1978
- if (!activeSession) {
1979
- return /* @__PURE__ */ jsx(SessionEmpty, { children: newSessionContent });
1980
- }
1981
- return /* @__PURE__ */ jsxs("div", { className: cn(theme.messages.content, className), ref: contentRef, children: [
1982
- hasMore && /* @__PURE__ */ jsx(
1983
- Button,
1984
- {
1985
- variant: "outline",
1986
- className: cn(theme.messages.showMore),
1987
- fullWidth: true,
1988
- onClick: handleShowMore,
1989
- children: showMoreText
1990
- }
1991
- ),
1992
- /* @__PURE__ */ jsx(AnimatePresence, { children: /* @__PURE__ */ jsx(
1993
- motion.div,
1994
- {
1995
- variants: containerVariants,
1996
- initial: "hidden",
1997
- animate: "visible",
1998
- onAnimationComplete: () => {
1999
- requestAnimationFrame(() => setIsAnimating(false));
2000
- },
2001
- children: children ? children(convosToRender) : convosToRender.map((conversation, index) => /* @__PURE__ */ jsx(
2002
- SessionMessage,
2003
- {
2004
- conversation,
2005
- isLast: index === conversation.length - 1
2006
- },
2007
- conversation.id
2008
- ))
2009
- },
2010
- activeSession?.id
2011
- ) })
2012
- ] });
2013
- };
2014
- const SessionMessagesHeader = ({ children }) => {
2015
- const { activeSession, theme } = useContext(ChatContext);
2016
- const Comp = children ? Slot : "header";
2017
- if (!activeSession) {
2018
- return null;
2019
- }
2020
- return /* @__PURE__ */ jsx(Comp, { className: cn(theme.messages.header), children: children || /* @__PURE__ */ jsxs(Fragment, { children: [
2021
- /* @__PURE__ */ jsx("h2", { className: cn(theme.messages.title), children: /* @__PURE__ */ jsx(Ellipsis, { limit: 125, value: activeSession.title }) }),
2022
- /* @__PURE__ */ jsx(
2023
- DateFormat,
2024
- {
2025
- className: cn(theme.messages.date),
2026
- date: activeSession.createdAt
2027
- }
2028
- )
2029
- ] }) });
2030
- };
2031
- const SvgPlus = (props) => /* @__PURE__ */ React.createElement("svg", { width: 17, height: 17, viewBox: "0 0 17 17", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props }, /* @__PURE__ */ React.createElement("g", { id: "add" }, /* @__PURE__ */ React.createElement("path", { id: "Vector", d: "M13.1667 9.16658H9.16671V13.1666H7.83337V9.16658H3.83337V7.83325H7.83337V3.83325H9.16671V7.83325H13.1667V9.16658Z", fill: "currentColor" })));
2032
- const NewSessionButton = ({
2033
- children,
2034
- newSessionText = "New Session"
2035
- }) => {
2036
- const { theme, createSession, disabled } = useContext(ChatContext);
2037
- const Comp = children ? Slot : Button;
2038
- return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
2039
- Comp,
2040
- {
2041
- fullWidth: true,
2042
- disableMargins: true,
2043
- color: "primary",
2044
- startAdornment: /* @__PURE__ */ jsx(SvgPlus, {}),
2045
- className: cn(theme.sessions.create),
2046
- disabled,
2047
- onClick: createSession,
2048
- children: children || newSessionText
2049
- }
2050
- ) });
2051
- };
2052
- const sortOrder = [
2053
- "Today",
2054
- "Yesterday",
2055
- "Last Week",
2056
- "Last Month",
2057
- "January",
2058
- "February",
2059
- "March",
2060
- "April",
2061
- "May",
2062
- "June",
2063
- "July",
2064
- "August",
2065
- "September",
2066
- "October",
2067
- "November",
2068
- "December",
2069
- "Last Year"
2070
- ];
2071
- function groupSessionsByDate(sessions) {
2072
- const grouped = {};
2073
- sessions.forEach((session) => {
2074
- const createdAt = new Date(session.createdAt);
2075
- const now = /* @__PURE__ */ new Date();
2076
- if (isToday(createdAt)) {
2077
- if (!grouped["Today"]) grouped["Today"] = [];
2078
- grouped["Today"].push(session);
2079
- } else if (isYesterday(createdAt)) {
2080
- if (!grouped["Yesterday"]) grouped["Yesterday"] = [];
2081
- grouped["Yesterday"].push(session);
2082
- } else if (isThisWeek(createdAt)) {
2083
- if (!grouped["Last Week"]) grouped["Last Week"] = [];
2084
- grouped["Last Week"].push(session);
2085
- } else if (differenceInYears(now, createdAt) === 0) {
2086
- const monthDiff = now.getMonth() - createdAt.getMonth();
2087
- if (monthDiff === 1 || monthDiff === 0 && now.getDate() > createdAt.getDate()) {
2088
- if (!grouped["Last Month"]) grouped["Last Month"] = [];
2089
- grouped["Last Month"].push(session);
2090
- } else {
2091
- const monthName = format(createdAt, "MMMM");
2092
- if (!grouped[monthName]) grouped[monthName] = [];
2093
- grouped[monthName].push(session);
2094
- }
2095
- } else {
2096
- if (!grouped["Last Year"]) grouped["Last Year"] = [];
2097
- grouped["Last Year"].push(session);
2098
- }
2099
- });
2100
- Object.keys(grouped).forEach((key) => {
2101
- if (grouped[key].length === 0) {
2102
- delete grouped[key];
2103
- }
2104
- });
2105
- const sortedGroups = Object.keys(grouped).sort(
2106
- (a, b) => sortOrder.indexOf(a) - sortOrder.indexOf(b)
2107
- );
2108
- return sortedGroups.map((heading) => ({
2109
- heading,
2110
- sessions: grouped[heading].sort(
2111
- (a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime()
2112
- )
2113
- }));
2114
- }
2115
- const SvgChat = (props) => /* @__PURE__ */ React.createElement("svg", { width: 16, height: 17, viewBox: "0 0 16 17", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props }, /* @__PURE__ */ React.createElement("path", { d: "M8 3C4.55375 3 1.75 5.23753 1.75 7.98828C1.75 9.70653 2.83659 11.2762 4.62109 12.188C4.11184 13.0465 3.62587 13.7378 3.62012 13.7461C3.50687 13.9071 3.49862 14.1196 3.59912 14.2891C3.69012 14.4418 3.8543 14.5342 4.0293 14.5342C4.0483 14.5342 4.06743 14.533 4.08643 14.5308C4.15168 14.5233 5.66214 14.3364 7.50439 12.9604C7.67239 12.9712 7.8385 12.9766 8 12.9766C11.4462 12.9766 14.25 10.739 14.25 7.98828C14.25 5.23753 11.4462 3 8 3ZM8 4C10.8948 4 13.25 5.78903 13.25 7.98828C13.25 10.1875 10.8948 11.9766 8 11.9766C7.8055 11.9766 7.60225 11.968 7.396 11.9497C7.271 11.9382 7.1454 11.9752 7.0459 12.0527C6.3589 12.5855 5.72033 12.9308 5.20508 13.1528C5.38383 12.8648 5.57691 12.5418 5.76416 12.2061C5.83416 12.0813 5.84705 11.9324 5.7998 11.7974C5.75255 11.6624 5.64983 11.5542 5.51758 11.5C3.81033 10.7993 2.75 9.45328 2.75 7.98828C2.75 5.78903 5.10525 4 8 4ZM5.5 7.25C5.08575 7.25 4.75 7.58575 4.75 8C4.75 8.41425 5.08575 8.75 5.5 8.75C5.91425 8.75 6.25 8.41425 6.25 8C6.25 7.58575 5.91425 7.25 5.5 7.25ZM8 7.25C7.58575 7.25 7.25 7.58575 7.25 8C7.25 8.41425 7.58575 8.75 8 8.75C8.41425 8.75 8.75 8.41425 8.75 8C8.75 7.58575 8.41425 7.25 8 7.25ZM10.5 7.25C10.0857 7.25 9.75 7.58575 9.75 8C9.75 8.41425 10.0857 8.75 10.5 8.75C10.9143 8.75 11.25 8.41425 11.25 8C11.25 7.58575 10.9143 7.25 10.5 7.25Z", fill: "currentColor" }));
2116
- const SvgTrash = (props) => /* @__PURE__ */ React.createElement("svg", { width: 14, height: 14, viewBox: "0 0 14 14", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props }, /* @__PURE__ */ React.createElement("g", { id: "Delete" }, /* @__PURE__ */ React.createElement("path", { id: "Vector", d: "M5.97905 1.16666C5.90859 1.16576 5.83895 1.18189 5.77605 1.21368C5.71316 1.24547 5.65888 1.29199 5.61783 1.34926C5.57677 1.40654 5.55016 1.47288 5.54025 1.54265C5.53034 1.61242 5.53743 1.68355 5.56092 1.75H4.27007C3.7342 1.75 3.2324 2.01817 2.93535 2.46435L2.24492 3.5H2.18738C2.12941 3.49918 2.07185 3.50989 2.01805 3.5315C1.96425 3.55312 1.91529 3.58522 1.874 3.62593C1.83271 3.66663 1.79993 3.71514 1.77755 3.76863C1.75518 3.82211 1.74365 3.87952 1.74365 3.9375C1.74365 3.99548 1.75518 4.05288 1.77755 4.10636C1.79993 4.15985 1.83271 4.20836 1.874 4.24907C1.91529 4.28977 1.96425 4.32187 2.01805 4.34349C2.07185 4.3651 2.12941 4.37582 2.18738 4.375H2.41012C2.44765 4.38067 2.48576 4.38143 2.52348 4.37727L3.24468 11.1084C3.33169 11.9199 4.02367 12.5417 4.83973 12.5417H9.15947C9.97553 12.5417 10.6675 11.9199 10.7545 11.1084L11.4763 4.37727C11.5133 4.38124 11.5506 4.38047 11.5874 4.375H11.8124C11.8704 4.37582 11.9279 4.3651 11.9817 4.34349C12.0355 4.32187 12.0845 4.28977 12.1258 4.24907C12.1671 4.20836 12.1998 4.15985 12.2222 4.10636C12.2446 4.05288 12.2561 3.99548 12.2561 3.9375C12.2561 3.87952 12.2446 3.82211 12.2222 3.76863C12.1998 3.71514 12.1671 3.66663 12.1258 3.62593C12.0845 3.58522 12.0355 3.55312 11.9817 3.5315C11.9279 3.50989 11.8704 3.49918 11.8124 3.5H11.7548L11.0644 2.46435C10.7671 2.01841 10.2654 1.75 9.7297 1.75H8.43885C8.46234 1.68355 8.46943 1.61242 8.45952 1.54265C8.44961 1.47288 8.423 1.40654 8.38194 1.34926C8.34089 1.29199 8.2866 1.24547 8.22371 1.21368C8.16082 1.18189 8.09118 1.16576 8.02072 1.16666H5.97905ZM4.27007 2.625H9.7297C9.97394 2.625 10.2009 2.74639 10.3364 2.9497L10.7033 3.5H3.29651L3.66338 2.9497L3.66395 2.94913C3.79913 2.74608 4.02543 2.625 4.27007 2.625ZM3.40361 4.375H10.5962L9.88465 11.015C9.8445 11.3894 9.53575 11.6667 9.15947 11.6667H4.83973C4.46345 11.6667 4.15527 11.3894 4.11512 11.015L3.40361 4.375Z", fill: "currentColor" })));
2117
- const SessionListItem = ({
2118
- children,
2119
- session,
2120
- deletable = true,
2121
- limit = 100,
2122
- deleteIcon = /* @__PURE__ */ jsx(SvgTrash, {}),
2123
- chatIcon = /* @__PURE__ */ jsx(SvgChat, { className: "mr-2" })
2124
- }) => {
2125
- const { activeSessionId, selectSession, deleteSession, theme } = useContext(ChatContext);
2126
- const Comp = children ? Slot : ListItem;
2127
- return /* @__PURE__ */ jsx(
2128
- Comp,
2129
- {
2130
- dense: true,
2131
- disableGutters: true,
2132
- active: session.id === activeSessionId,
2133
- className: cn(theme.sessions.session.base, {
2134
- [theme.sessions.session.active]: session.id === activeSessionId
2135
- }),
2136
- onClick: () => selectSession?.(session.id),
2137
- start: chatIcon,
2138
- end: /* @__PURE__ */ jsx(Fragment, { children: deletable && /* @__PURE__ */ jsx(
2139
- IconButton,
2140
- {
2141
- size: "small",
2142
- variant: "ghost",
2143
- onClick: (e) => {
2144
- e.stopPropagation();
2145
- deleteSession(session.id);
2146
- },
2147
- className: cn(theme.sessions.session.delete),
2148
- children: deleteIcon
2149
- }
2150
- ) }),
2151
- children: children || /* @__PURE__ */ jsx(Ellipsis, { value: session.title, limit })
2152
- }
2153
- );
2154
- };
2155
- const SessionsGroup = ({
2156
- heading,
2157
- children
2158
- }) => {
2159
- const { theme } = useContext(ChatContext);
2160
- return /* @__PURE__ */ jsxs(Fragment, { children: [
2161
- heading && /* @__PURE__ */ jsx(
2162
- ListItem,
2163
- {
2164
- disableGutters: true,
2165
- disablePadding: true,
2166
- className: cn(theme.sessions.group),
2167
- children: heading
2168
- }
2169
- ),
2170
- children
2171
- ] });
2172
- };
2173
- const SessionGroups = ({ children }) => {
2174
- const { sessions } = useContext(ChatContext);
2175
- const groups = useMemo(() => groupSessionsByDate(sessions), [sessions]);
2176
- return /* @__PURE__ */ jsx(Fragment, { children: children ? children(groups) : groups.map(({ heading, sessions: sessions2 }) => /* @__PURE__ */ jsx(SessionsGroup, { heading, children: sessions2.map((session) => /* @__PURE__ */ jsx(SessionListItem, { session }, session.id)) }, heading)) });
2177
- };
2178
- const SessionsList = ({
2179
- children,
2180
- templates
2181
- }) => {
2182
- const { theme, isCompact, activeSessionId, createSession } = useContext(ChatContext);
2183
- const isVisible = isCompact && !activeSessionId;
2184
- return (!isCompact || isVisible) && /* @__PURE__ */ jsxs(
2185
- motion.div,
2186
- {
2187
- initial: { translateX: "-100%" },
2188
- animate: {
2189
- translateX: "0%",
2190
- transition: {
2191
- type: "tween",
2192
- ease: "linear",
2193
- duration: 0.2,
2194
- when: "beforeChildren"
2195
- }
2196
- },
2197
- exit: { translateX: "-100%" },
2198
- className: cn(theme.sessions.base, {
2199
- [theme.sessions.companion]: isCompact,
2200
- [theme.sessions.console]: !isCompact
2201
- }),
2202
- children: [
2203
- /* @__PURE__ */ jsx(List, { children }),
2204
- templates && !activeSessionId && /* @__PURE__ */ jsx("div", { className: "mt-4", children: templates.map((template) => /* @__PURE__ */ jsx("div", { onClick: () => createSession?.(), children: /* @__PURE__ */ jsx(
2205
- SessionListItem,
2206
- {
2207
- session: {
2208
- id: template.id,
2209
- title: template.title,
2210
- conversations: []
2211
- },
2212
- chatIcon: template.icon,
2213
- deletable: false
2214
- }
2215
- ) }, template.id)) })
2216
- ]
2217
- }
2218
- );
2219
- };
2220
- export {
2221
- AppBar as A,
2222
- chatTheme as B,
2223
- ChatContext as C,
2224
- groupSessionsByDate as D,
2225
- FileInput as F,
2226
- Markdown as M,
2227
- NewSessionButton as N,
2228
- SvgFile as S,
2229
- TableComponent as T,
2230
- SvgCopy as a,
2231
- Chat as b,
2232
- ChatBubble as c,
2233
- ChatInput as d,
2234
- CodeHighlighter as e,
2235
- TableHeaderCell as f,
2236
- TableDataCell as g,
2237
- dark as h,
2238
- SessionEmpty as i,
2239
- MessageActions as j,
2240
- MessageFile as k,
2241
- light as l,
2242
- MessageFiles as m,
2243
- MessageQuestion as n,
2244
- MessageResponse as o,
2245
- MessageSource as p,
2246
- MessageSources as q,
2247
- remarkCve as r,
2248
- SessionMessage as s,
2249
- SessionMessagePanel as t,
2250
- SessionMessages as u,
2251
- SessionMessagesHeader as v,
2252
- SessionGroups as w,
2253
- SessionListItem as x,
2254
- SessionsGroup as y,
2255
- SessionsList as z
2256
- };
2257
- //# sourceMappingURL=index-6CsqxEMx.js.map