reachat 1.5.1 → 1.6.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.
@@ -0,0 +1,2149 @@
1
+ import { jsxs, Fragment, jsx } from "react/jsx-runtime";
2
+ import * as React from "react";
3
+ import { createContext, useContext, useRef, forwardRef, useState, useEffect, useImperativeHandle, lazy, useMemo, Suspense, useCallback } from "react";
4
+ import { Button, cn, Textarea, Ellipsis, DateFormat, IconButton, Card, Divider, useInfinityList, useComponentTheme, List, ListItem } from "reablocks";
5
+ import { Slot } from "@radix-ui/react-slot";
6
+ import { motion, AnimatePresence } from "motion/react";
7
+ import ReactMarkdown from "react-markdown";
8
+ import { Prism } from "react-syntax-highlighter";
9
+ import rehypeKatex from "rehype-katex";
10
+ import { findAndReplace } from "mdast-util-find-and-replace";
11
+ import { useHotkeys } from "reakeys";
12
+ import remarkGfm from "remark-gfm";
13
+ import remarkYoutube from "remark-youtube";
14
+ import remarkMath from "remark-math";
15
+ import { isToday, isYesterday, isThisWeek, isThisMonth, isThisYear, format } from "date-fns";
16
+ const SvgSend = (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: "send" }, /* @__PURE__ */ React.createElement("path", { id: "Vector", d: "M14.6111 2.33327C14.5349 2.3339 14.4598 2.35194 14.3917 2.386L2.39168 8.386C2.31456 8.42456 2.24872 8.4824 2.20055 8.55391C2.15238 8.62543 2.12352 8.70818 2.11677 8.79414C2.11002 8.88009 2.12561 8.96634 2.16203 9.04449C2.19845 9.12264 2.25446 9.19005 2.32462 9.24017L4.52514 10.8124L5.47371 13.6581C5.50257 13.7447 5.55457 13.8217 5.62406 13.8808C5.69355 13.9399 5.7779 13.9789 5.86796 13.9935C5.95802 14.0082 6.05036 13.9979 6.13499 13.9638C6.21962 13.9297 6.2933 13.873 6.34806 13.8001L7.05249 12.8606L10.3207 15.2376C10.3843 15.2839 10.4579 15.3146 10.5355 15.3271C10.6132 15.3396 10.6927 15.3336 10.7676 15.3097C10.8425 15.2857 10.9107 15.2444 10.9667 15.1891C11.0226 15.1338 11.0647 15.0661 11.0896 14.9915L15.0896 2.99147C15.1148 2.91597 15.1216 2.83555 15.1094 2.7569C15.0972 2.67825 15.0665 2.60363 15.0197 2.53926C14.9729 2.47488 14.9114 2.42261 14.8403 2.38678C14.7693 2.35096 14.6907 2.33261 14.6111 2.33327ZM13.2478 5.35345L10.3565 14.0266L7.67293 12.0755L13.2478 5.35345ZM10.684 5.35801L4.934 9.87559L3.58113 8.90879L10.684 5.35801ZM11.2784 6.16205L6.56746 11.843C6.56681 11.8437 6.56616 11.8443 6.56551 11.845L6.56355 11.8476C6.55841 11.8538 6.55342 11.8601 6.54858 11.8665C6.54319 11.8733 6.53798 11.8802 6.53295 11.8873L6.12085 12.4361L5.53426 10.6751L11.2784 6.16205Z", fill: "currentColor" })));
17
+ const SvgStop = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 24, height: 24, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 1, strokeLinecap: "round", strokeLinejoin: "round", className: "lucide lucide-octagon-x", ...props }, /* @__PURE__ */ React.createElement("path", { d: "m15 9-6 6" }), /* @__PURE__ */ React.createElement("path", { d: "M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z" }), /* @__PURE__ */ React.createElement("path", { d: "m9 9 6 6" }));
18
+ const ChatContext = createContext({
19
+ sessions: [],
20
+ activeSessionId: null
21
+ });
22
+ const SvgPaperclip = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 24, height: 24, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 1, strokeLinecap: "round", strokeLinejoin: "round", className: "lucide lucide-paperclip", ...props }, /* @__PURE__ */ React.createElement("path", { d: "m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48" }));
23
+ const FileInput = ({
24
+ allowedFiles,
25
+ onFileUpload,
26
+ isLoading,
27
+ disabled,
28
+ attachIcon = /* @__PURE__ */ jsx(SvgPaperclip, {})
29
+ }) => {
30
+ const { theme } = useContext(ChatContext);
31
+ const fileInputRef = useRef(null);
32
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
33
+ /* @__PURE__ */ jsx(
34
+ "input",
35
+ {
36
+ type: "file",
37
+ ref: fileInputRef,
38
+ className: "hidden",
39
+ accept: allowedFiles.join(","),
40
+ onChange: onFileUpload
41
+ }
42
+ ),
43
+ /* @__PURE__ */ jsx(
44
+ Button,
45
+ {
46
+ title: "Upload",
47
+ variant: "text",
48
+ disabled: isLoading || disabled,
49
+ className: cn(theme.input.upload),
50
+ onClick: () => {
51
+ var _a;
52
+ return (_a = fileInputRef.current) == null ? void 0 : _a.click();
53
+ },
54
+ children: attachIcon
55
+ }
56
+ )
57
+ ] });
58
+ };
59
+ const ChatInput = forwardRef(({
60
+ allowedFiles,
61
+ placeholder,
62
+ defaultValue,
63
+ sendIcon = /* @__PURE__ */ jsx(SvgSend, {}),
64
+ stopIcon = /* @__PURE__ */ jsx(SvgStop, {}),
65
+ attachIcon
66
+ }, ref) => {
67
+ const { theme, isLoading, disabled, sendMessage, stopMessage, fileUpload, activeSessionId } = useContext(ChatContext);
68
+ const [message, setMessage] = useState("");
69
+ const inputRef = useRef(null);
70
+ useEffect(() => {
71
+ if (inputRef.current) {
72
+ inputRef.current.focus();
73
+ }
74
+ }, [activeSessionId, inputRef]);
75
+ useImperativeHandle(ref, () => ({
76
+ focus: () => {
77
+ var _a;
78
+ (_a = inputRef.current) == null ? void 0 : _a.focus();
79
+ }
80
+ }));
81
+ const handleSendMessage = () => {
82
+ if (message.trim()) {
83
+ sendMessage == null ? void 0 : sendMessage(message);
84
+ setMessage("");
85
+ }
86
+ };
87
+ const handleKeyPress = (e) => {
88
+ if (e.key === "Enter" && !e.shiftKey) {
89
+ e.preventDefault();
90
+ handleSendMessage();
91
+ }
92
+ };
93
+ const handleFileUpload = (event) => {
94
+ var _a;
95
+ const file = (_a = event.target.files) == null ? void 0 : _a[0];
96
+ if (file && fileUpload) {
97
+ fileUpload(file);
98
+ }
99
+ };
100
+ return /* @__PURE__ */ jsxs("div", { className: cn(theme.input.base), children: [
101
+ /* @__PURE__ */ jsx(
102
+ Textarea,
103
+ {
104
+ ref: inputRef,
105
+ containerClassName: cn(theme.input.input),
106
+ minRows: 1,
107
+ autoFocus: true,
108
+ value: message,
109
+ defaultValue,
110
+ onKeyPress: handleKeyPress,
111
+ placeholder,
112
+ disabled: isLoading || disabled,
113
+ onChange: (e) => setMessage(e.target.value)
114
+ }
115
+ ),
116
+ /* @__PURE__ */ jsxs("div", { className: cn(theme.input.actions.base), children: [
117
+ (allowedFiles == null ? void 0 : allowedFiles.length) > 0 && /* @__PURE__ */ jsx(
118
+ FileInput,
119
+ {
120
+ allowedFiles,
121
+ onFileUpload: handleFileUpload,
122
+ isLoading,
123
+ disabled,
124
+ attachIcon
125
+ }
126
+ ),
127
+ isLoading && /* @__PURE__ */ jsx(
128
+ Button,
129
+ {
130
+ title: "Stop",
131
+ className: cn(theme.input.actions.stop),
132
+ onClick: stopMessage,
133
+ disabled,
134
+ children: stopIcon
135
+ }
136
+ ),
137
+ /* @__PURE__ */ jsx(
138
+ Button,
139
+ {
140
+ title: "Send",
141
+ className: cn(theme.input.actions.send),
142
+ onClick: handleSendMessage,
143
+ disabled: isLoading || disabled,
144
+ children: sendIcon
145
+ }
146
+ )
147
+ ] })
148
+ ] });
149
+ });
150
+ const SessionEmpty = ({
151
+ children
152
+ }) => {
153
+ const { theme } = useContext(ChatContext);
154
+ return /* @__PURE__ */ jsx("div", { className: cn(theme.empty), children });
155
+ };
156
+ const SessionMessagesHeader = ({ children }) => {
157
+ const { activeSession, theme } = useContext(ChatContext);
158
+ const Comp = children ? Slot : "header";
159
+ if (!activeSession) {
160
+ return null;
161
+ }
162
+ return /* @__PURE__ */ jsx(Comp, { className: cn(theme.messages.header), children: children || /* @__PURE__ */ jsxs(Fragment, { children: [
163
+ /* @__PURE__ */ jsx("h2", { className: cn(theme.messages.title), children: /* @__PURE__ */ jsx(Ellipsis, { limit: 125, value: activeSession.title }) }),
164
+ /* @__PURE__ */ jsx(
165
+ DateFormat,
166
+ {
167
+ className: cn(theme.messages.date),
168
+ date: activeSession.createdAt
169
+ }
170
+ )
171
+ ] }) });
172
+ };
173
+ const SvgBack = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 24, height: 24, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 1, strokeLinecap: "round", strokeLinejoin: "round", className: "lucide lucide-chevron-left", ...props }, /* @__PURE__ */ React.createElement("path", { d: "m15 18-6-6 6-6" }));
174
+ const SessionMessagePanel = ({ children }) => {
175
+ const { activeSessionId, theme, isCompact, selectSession, viewType } = useContext(ChatContext);
176
+ const isVisible = isCompact && activeSessionId || viewType === "chat" || !isCompact;
177
+ return isVisible && /* @__PURE__ */ jsx(
178
+ motion.div,
179
+ {
180
+ initial: { translateX: "200%" },
181
+ animate: {
182
+ translateX: "0%",
183
+ transition: {
184
+ type: "tween",
185
+ ease: "linear",
186
+ duration: 0.2,
187
+ when: "beforeChildren"
188
+ }
189
+ },
190
+ exit: { translateX: "200%" },
191
+ className: cn(theme.messages.base, {
192
+ [theme.messages.companion]: isCompact,
193
+ [theme.messages.console]: !isCompact
194
+ }),
195
+ children: /* @__PURE__ */ jsxs("div", { className: cn(theme.messages.inner), children: [
196
+ isCompact && viewType !== "chat" && /* @__PURE__ */ jsxs(
197
+ Button,
198
+ {
199
+ variant: "text",
200
+ size: "small",
201
+ onClick: () => selectSession(null),
202
+ className: cn(theme.messages.back),
203
+ children: [
204
+ /* @__PURE__ */ jsx(SvgBack, {}),
205
+ "Back"
206
+ ]
207
+ }
208
+ ),
209
+ children
210
+ ] })
211
+ }
212
+ );
213
+ };
214
+ const SvgCopy = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 24, height: 24, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 1, strokeLinecap: "round", strokeLinejoin: "round", className: "lucide lucide-copy", ...props }, /* @__PURE__ */ React.createElement("rect", { width: 14, height: 14, x: 8, y: 8, rx: 2, ry: 2 }), /* @__PURE__ */ React.createElement("path", { d: "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" }));
215
+ const dark = {
216
+ 'code[class*="language-"]': {
217
+ "background": "#11111f",
218
+ "color": "#e2e8f0",
219
+ "textShadow": "0 1px rgba(0, 0, 0, 0.3)",
220
+ "fontFamily": '"Fira Code", "Fira Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace',
221
+ "direction": "ltr",
222
+ "textAlign": "left",
223
+ "whiteSpace": "pre",
224
+ "wordSpacing": "normal",
225
+ "wordBreak": "normal",
226
+ "lineHeight": "1.5",
227
+ "MozTabSize": "2",
228
+ "OTabSize": "2",
229
+ "tabSize": "2",
230
+ "WebkitHyphens": "none",
231
+ "MozHyphens": "none",
232
+ "msHyphens": "none",
233
+ "hyphens": "none"
234
+ },
235
+ 'pre[class*="language-"]': {
236
+ "background": "#11111f",
237
+ "color": "#e2e8f0",
238
+ "textShadow": "0 1px rgba(0, 0, 0, 0.3)",
239
+ "fontFamily": '"Fira Code", "Fira Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace',
240
+ "direction": "ltr",
241
+ "textAlign": "left",
242
+ "whiteSpace": "pre",
243
+ "wordSpacing": "normal",
244
+ "wordBreak": "normal",
245
+ "lineHeight": "1.5",
246
+ "MozTabSize": "2",
247
+ "OTabSize": "2",
248
+ "tabSize": "2",
249
+ "WebkitHyphens": "none",
250
+ "MozHyphens": "none",
251
+ "msHyphens": "none",
252
+ "hyphens": "none",
253
+ "padding": "1em",
254
+ "margin": "0",
255
+ "overflow": "auto"
256
+ },
257
+ 'code[class*="language-"]::-moz-selection': {
258
+ "background": "#1e293b",
259
+ "color": "inherit",
260
+ "textShadow": "none"
261
+ },
262
+ 'code[class*="language-"] *::-moz-selection': {
263
+ "background": "#1e293b",
264
+ "color": "inherit",
265
+ "textShadow": "none"
266
+ },
267
+ 'pre[class*="language-"] *::-moz-selection': {
268
+ "background": "#1e293b",
269
+ "color": "inherit",
270
+ "textShadow": "none"
271
+ },
272
+ 'code[class*="language-"]::selection': {
273
+ "background": "#1e293b",
274
+ "color": "inherit",
275
+ "textShadow": "none"
276
+ },
277
+ 'code[class*="language-"] *::selection': {
278
+ "background": "#1e293b",
279
+ "color": "inherit",
280
+ "textShadow": "none"
281
+ },
282
+ 'pre[class*="language-"] *::selection': {
283
+ "background": "#1e293b",
284
+ "color": "inherit",
285
+ "textShadow": "none"
286
+ },
287
+ ':not(pre) > code[class*="language-"]': {
288
+ "padding": "0.2em 0.3em",
289
+ "borderRadius": "0.3em",
290
+ "whiteSpace": "normal"
291
+ },
292
+ "comment": {
293
+ "color": "#64748b",
294
+ "fontStyle": "italic"
295
+ },
296
+ "prolog": {
297
+ "color": "#64748b"
298
+ },
299
+ "cdata": {
300
+ "color": "#64748b"
301
+ },
302
+ "doctype": {
303
+ "color": "#e2e8f0"
304
+ },
305
+ "punctuation": {
306
+ "color": "#e2e8f0"
307
+ },
308
+ "entity": {
309
+ "color": "#3b82f6",
310
+ "cursor": "help"
311
+ },
312
+ "attr-name": {
313
+ "color": "#f59e0b"
314
+ },
315
+ "class-name": {
316
+ "color": "#f59e0b"
317
+ },
318
+ "boolean": {
319
+ "color": "#3b82f6"
320
+ },
321
+ "constant": {
322
+ "color": "#3b82f6"
323
+ },
324
+ "number": {
325
+ "color": "#3b82f6"
326
+ },
327
+ "atrule": {
328
+ "color": "#f59e0b"
329
+ },
330
+ "keyword": {
331
+ "color": "#f472b6"
332
+ },
333
+ "property": {
334
+ "color": "#3b82f6"
335
+ },
336
+ "tag": {
337
+ "color": "#3b82f6"
338
+ },
339
+ "symbol": {
340
+ "color": "#3b82f6"
341
+ },
342
+ "deleted": {
343
+ "color": "#ef4444"
344
+ },
345
+ "important": {
346
+ "color": "#f472b6"
347
+ },
348
+ "selector": {
349
+ "color": "#10b981"
350
+ },
351
+ "string": {
352
+ "color": "#10b981"
353
+ },
354
+ "char": {
355
+ "color": "#10b981"
356
+ },
357
+ "builtin": {
358
+ "color": "#10b981"
359
+ },
360
+ "inserted": {
361
+ "color": "#10b981"
362
+ },
363
+ "regex": {
364
+ "color": "#10b981"
365
+ },
366
+ "attr-value": {
367
+ "color": "#10b981"
368
+ },
369
+ "attr-value > .token.punctuation": {
370
+ "color": "#10b981"
371
+ },
372
+ "variable": {
373
+ "color": "#60a5fa"
374
+ },
375
+ "operator": {
376
+ "color": "#60a5fa"
377
+ },
378
+ "function": {
379
+ "color": "#60a5fa"
380
+ },
381
+ "url": {
382
+ "color": "#60a5fa"
383
+ },
384
+ "attr-value > .token.punctuation.attr-equals": {
385
+ "color": "#e2e8f0"
386
+ },
387
+ "special-attr > .token.attr-value > .token.value.css": {
388
+ "color": "#e2e8f0"
389
+ },
390
+ ".language-css .token.selector": {
391
+ "color": "#3b82f6"
392
+ },
393
+ ".language-css .token.property": {
394
+ "color": "#e2e8f0"
395
+ },
396
+ ".language-css .token.function": {
397
+ "color": "#60a5fa"
398
+ },
399
+ ".language-css .token.url > .token.function": {
400
+ "color": "#60a5fa"
401
+ },
402
+ ".language-css .token.url > .token.string.url": {
403
+ "color": "#10b981"
404
+ },
405
+ ".language-css .token.important": {
406
+ "color": "#f472b6"
407
+ },
408
+ ".language-css .token.atrule .token.rule": {
409
+ "color": "#f472b6"
410
+ },
411
+ ".language-javascript .token.operator": {
412
+ "color": "#f472b6"
413
+ },
414
+ ".language-javascript .token.template-string > .token.interpolation > .token.interpolation-punctuation.punctuation": {
415
+ "color": "#ef4444"
416
+ },
417
+ ".language-json .token.operator": {
418
+ "color": "#e2e8f0"
419
+ },
420
+ ".language-json .token.null.keyword": {
421
+ "color": "#3b82f6"
422
+ },
423
+ ".language-markdown .token.url": {
424
+ "color": "#e2e8f0"
425
+ },
426
+ ".language-markdown .token.url > .token.operator": {
427
+ "color": "#e2e8f0"
428
+ },
429
+ ".language-markdown .token.url-reference.url > .token.string": {
430
+ "color": "#e2e8f0"
431
+ },
432
+ ".language-markdown .token.url > .token.content": {
433
+ "color": "#60a5fa"
434
+ },
435
+ ".language-markdown .token.url > .token.url": {
436
+ "color": "#60a5fa"
437
+ },
438
+ ".language-markdown .token.url-reference.url": {
439
+ "color": "#60a5fa"
440
+ },
441
+ ".language-markdown .token.blockquote.punctuation": {
442
+ "color": "#64748b",
443
+ "fontStyle": "italic"
444
+ },
445
+ ".language-markdown .token.hr.punctuation": {
446
+ "color": "#64748b",
447
+ "fontStyle": "italic"
448
+ },
449
+ ".language-markdown .token.code-snippet": {
450
+ "color": "#10b981"
451
+ },
452
+ ".language-markdown .token.bold .token.content": {
453
+ "color": "#f59e0b"
454
+ },
455
+ ".language-markdown .token.italic .token.content": {
456
+ "color": "#f472b6"
457
+ },
458
+ ".language-markdown .token.strike .token.content": {
459
+ "color": "#3b82f6"
460
+ },
461
+ ".language-markdown .token.strike .token.punctuation": {
462
+ "color": "#3b82f6"
463
+ },
464
+ ".language-markdown .token.list.punctuation": {
465
+ "color": "#3b82f6"
466
+ },
467
+ ".language-markdown .token.title.important > .token.punctuation": {
468
+ "color": "#3b82f6"
469
+ },
470
+ "bold": {
471
+ "fontWeight": "bold"
472
+ },
473
+ "italic": {
474
+ "fontStyle": "italic"
475
+ },
476
+ "namespace": {
477
+ "Opacity": "0.8"
478
+ },
479
+ "token.tab:not(:empty):before": {
480
+ "color": "#64748b",
481
+ "textShadow": "none"
482
+ },
483
+ "token.cr:before": {
484
+ "color": "#64748b",
485
+ "textShadow": "none"
486
+ },
487
+ "token.lf:before": {
488
+ "color": "#64748b",
489
+ "textShadow": "none"
490
+ },
491
+ "token.space:before": {
492
+ "color": "#64748b",
493
+ "textShadow": "none"
494
+ },
495
+ "div.code-toolbar > .toolbar.toolbar > .toolbar-item": {
496
+ "marginRight": "0.4em"
497
+ },
498
+ "div.code-toolbar > .toolbar.toolbar > .toolbar-item > button": {
499
+ "background": "#1e293b",
500
+ "color": "#94a3b8",
501
+ "padding": "0.1em 0.4em",
502
+ "borderRadius": "0.3em"
503
+ },
504
+ "div.code-toolbar > .toolbar.toolbar > .toolbar-item > a": {
505
+ "background": "#1e293b",
506
+ "color": "#94a3b8",
507
+ "padding": "0.1em 0.4em",
508
+ "borderRadius": "0.3em"
509
+ },
510
+ "div.code-toolbar > .toolbar.toolbar > .toolbar-item > span": {
511
+ "background": "#1e293b",
512
+ "color": "#94a3b8",
513
+ "padding": "0.1em 0.4em",
514
+ "borderRadius": "0.3em"
515
+ },
516
+ "div.code-toolbar > .toolbar.toolbar > .toolbar-item > button:hover": {
517
+ "background": "#3b82f6",
518
+ "color": "#ffffff"
519
+ },
520
+ "div.code-toolbar > .toolbar.toolbar > .toolbar-item > button:focus": {
521
+ "background": "#3b82f6",
522
+ "color": "#ffffff"
523
+ },
524
+ "div.code-toolbar > .toolbar.toolbar > .toolbar-item > a:hover": {
525
+ "background": "#3b82f6",
526
+ "color": "#ffffff"
527
+ },
528
+ "div.code-toolbar > .toolbar.toolbar > .toolbar-item > a:focus": {
529
+ "background": "#3b82f6",
530
+ "color": "#ffffff"
531
+ },
532
+ "div.code-toolbar > .toolbar.toolbar > .toolbar-item > span:hover": {
533
+ "background": "#3b82f6",
534
+ "color": "#ffffff"
535
+ },
536
+ "div.code-toolbar > .toolbar.toolbar > .toolbar-item > span:focus": {
537
+ "background": "#3b82f6",
538
+ "color": "#ffffff"
539
+ },
540
+ ".line-highlight.line-highlight": {
541
+ "background": "rgba(59, 130, 246, 0.08)"
542
+ },
543
+ ".line-highlight.line-highlight:before": {
544
+ "background": "#1e293b",
545
+ "color": "#e2e8f0",
546
+ "padding": "0.1em 0.6em",
547
+ "borderRadius": "0.3em",
548
+ "boxShadow": "0 2px 0 0 rgba(0, 0, 0, 0.2)"
549
+ },
550
+ ".line-highlight.line-highlight[data-end]:after": {
551
+ "background": "#1e293b",
552
+ "color": "#e2e8f0",
553
+ "padding": "0.1em 0.6em",
554
+ "borderRadius": "0.3em",
555
+ "boxShadow": "0 2px 0 0 rgba(0, 0, 0, 0.2)"
556
+ },
557
+ "pre[id].linkable-line-numbers.linkable-line-numbers span.line-numbers-rows > span:hover:before": {
558
+ "backgroundColor": "rgba(59, 130, 246, 0.08)"
559
+ },
560
+ ".line-numbers.line-numbers .line-numbers-rows": {
561
+ "borderRightColor": "#1e293b"
562
+ },
563
+ ".command-line .command-line-prompt": {
564
+ "borderRightColor": "#1e293b"
565
+ },
566
+ ".line-numbers .line-numbers-rows > span:before": {
567
+ "color": "#64748b"
568
+ },
569
+ ".command-line .command-line-prompt > span:before": {
570
+ "color": "#64748b"
571
+ },
572
+ ".rainbow-braces .token.token.punctuation.brace-level-1": {
573
+ "color": "#3b82f6"
574
+ },
575
+ ".rainbow-braces .token.token.punctuation.brace-level-5": {
576
+ "color": "#3b82f6"
577
+ },
578
+ ".rainbow-braces .token.token.punctuation.brace-level-9": {
579
+ "color": "#3b82f6"
580
+ },
581
+ ".rainbow-braces .token.token.punctuation.brace-level-2": {
582
+ "color": "#10b981"
583
+ },
584
+ ".rainbow-braces .token.token.punctuation.brace-level-6": {
585
+ "color": "#10b981"
586
+ },
587
+ ".rainbow-braces .token.token.punctuation.brace-level-10": {
588
+ "color": "#10b981"
589
+ },
590
+ ".rainbow-braces .token.token.punctuation.brace-level-3": {
591
+ "color": "#60a5fa"
592
+ },
593
+ ".rainbow-braces .token.token.punctuation.brace-level-7": {
594
+ "color": "#60a5fa"
595
+ },
596
+ ".rainbow-braces .token.token.punctuation.brace-level-11": {
597
+ "color": "#60a5fa"
598
+ },
599
+ ".rainbow-braces .token.token.punctuation.brace-level-4": {
600
+ "color": "#f472b6"
601
+ },
602
+ ".rainbow-braces .token.token.punctuation.brace-level-8": {
603
+ "color": "#f472b6"
604
+ },
605
+ ".rainbow-braces .token.token.punctuation.brace-level-12": {
606
+ "color": "#f472b6"
607
+ },
608
+ "pre.diff-highlight > code .token.token.deleted:not(.prefix)": {
609
+ "backgroundColor": "rgba(239, 68, 68, 0.15)"
610
+ },
611
+ "pre > code.diff-highlight .token.token.deleted:not(.prefix)": {
612
+ "backgroundColor": "rgba(239, 68, 68, 0.15)"
613
+ },
614
+ "pre.diff-highlight > code .token.token.deleted:not(.prefix)::-moz-selection": {
615
+ "backgroundColor": "rgba(239, 68, 68, 0.25)"
616
+ },
617
+ "pre.diff-highlight > code .token.token.deleted:not(.prefix) *::-moz-selection": {
618
+ "backgroundColor": "rgba(239, 68, 68, 0.25)"
619
+ },
620
+ "pre > code.diff-highlight .token.token.deleted:not(.prefix)::-moz-selection": {
621
+ "backgroundColor": "rgba(239, 68, 68, 0.25)"
622
+ },
623
+ "pre > code.diff-highlight .token.token.deleted:not(.prefix) *::-moz-selection": {
624
+ "backgroundColor": "rgba(239, 68, 68, 0.25)"
625
+ },
626
+ "pre.diff-highlight > code .token.token.deleted:not(.prefix)::selection": {
627
+ "backgroundColor": "rgba(239, 68, 68, 0.25)"
628
+ },
629
+ "pre.diff-highlight > code .token.token.deleted:not(.prefix) *::selection": {
630
+ "backgroundColor": "rgba(239, 68, 68, 0.25)"
631
+ },
632
+ "pre > code.diff-highlight .token.token.deleted:not(.prefix)::selection": {
633
+ "backgroundColor": "rgba(239, 68, 68, 0.25)"
634
+ },
635
+ "pre > code.diff-highlight .token.token.deleted:not(.prefix) *::selection": {
636
+ "backgroundColor": "rgba(239, 68, 68, 0.25)"
637
+ },
638
+ "pre.diff-highlight > code .token.token.inserted:not(.prefix)": {
639
+ "backgroundColor": "rgba(16, 185, 129, 0.15)"
640
+ },
641
+ "pre > code.diff-highlight .token.token.inserted:not(.prefix)": {
642
+ "backgroundColor": "rgba(16, 185, 129, 0.15)"
643
+ },
644
+ "pre.diff-highlight > code .token.token.inserted:not(.prefix)::-moz-selection": {
645
+ "backgroundColor": "rgba(16, 185, 129, 0.25)"
646
+ },
647
+ "pre.diff-highlight > code .token.token.inserted:not(.prefix) *::-moz-selection": {
648
+ "backgroundColor": "rgba(16, 185, 129, 0.25)"
649
+ },
650
+ "pre > code.diff-highlight .token.token.inserted:not(.prefix)::-moz-selection": {
651
+ "backgroundColor": "rgba(16, 185, 129, 0.25)"
652
+ },
653
+ "pre > code.diff-highlight .token.token.inserted:not(.prefix) *::-moz-selection": {
654
+ "backgroundColor": "rgba(16, 185, 129, 0.25)"
655
+ },
656
+ "pre.diff-highlight > code .token.token.inserted:not(.prefix)::selection": {
657
+ "backgroundColor": "rgba(16, 185, 129, 0.25)"
658
+ },
659
+ "pre.diff-highlight > code .token.token.inserted:not(.prefix) *::selection": {
660
+ "backgroundColor": "rgba(16, 185, 129, 0.25)"
661
+ },
662
+ "pre > code.diff-highlight .token.token.inserted:not(.prefix)::selection": {
663
+ "backgroundColor": "rgba(16, 185, 129, 0.25)"
664
+ },
665
+ "pre > code.diff-highlight .token.token.inserted:not(.prefix) *::selection": {
666
+ "backgroundColor": "rgba(16, 185, 129, 0.25)"
667
+ },
668
+ ".prism-previewer.prism-previewer:before": {
669
+ "borderColor": "#11111f"
670
+ },
671
+ ".prism-previewer-gradient.prism-previewer-gradient div": {
672
+ "borderColor": "#11111f",
673
+ "borderRadius": "0.3em"
674
+ },
675
+ ".prism-previewer-color.prism-previewer-color:before": {
676
+ "borderRadius": "0.3em"
677
+ },
678
+ ".prism-previewer-easing.prism-previewer-easing:before": {
679
+ "borderRadius": "0.3em"
680
+ },
681
+ ".prism-previewer.prism-previewer:after": {
682
+ "borderTopColor": "#11111f"
683
+ },
684
+ ".prism-previewer-flipped.prism-previewer-flipped.after": {
685
+ "borderBottomColor": "#11111f"
686
+ },
687
+ ".prism-previewer-angle.prism-previewer-angle:before": {
688
+ "background": "#1e293b"
689
+ },
690
+ ".prism-previewer-time.prism-previewer-time:before": {
691
+ "background": "#1e293b"
692
+ },
693
+ ".prism-previewer-easing.prism-previewer-easing": {
694
+ "background": "#1e293b"
695
+ },
696
+ ".prism-previewer-angle.prism-previewer-angle circle": {
697
+ "stroke": "#e2e8f0",
698
+ "strokeOpacity": "1"
699
+ },
700
+ ".prism-previewer-time.prism-previewer-time circle": {
701
+ "stroke": "#e2e8f0",
702
+ "strokeOpacity": "1"
703
+ },
704
+ ".prism-previewer-easing.prism-previewer-easing circle": {
705
+ "stroke": "#e2e8f0",
706
+ "fill": "transparent"
707
+ },
708
+ ".prism-previewer-easing.prism-previewer-easing path": {
709
+ "stroke": "#e2e8f0"
710
+ },
711
+ ".prism-previewer-easing.prism-previewer-easing line": {
712
+ "stroke": "#e2e8f0"
713
+ }
714
+ };
715
+ const light = {
716
+ 'code[class*="language-"]': {
717
+ "background": "#fff",
718
+ "color": "#1e293b",
719
+ "textShadow": "none",
720
+ "fontFamily": '"Fira Code", "Fira Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace',
721
+ "direction": "ltr",
722
+ "textAlign": "left",
723
+ "whiteSpace": "pre",
724
+ "wordSpacing": "normal",
725
+ "wordBreak": "normal",
726
+ "lineHeight": "1.5",
727
+ "MozTabSize": "2",
728
+ "OTabSize": "2",
729
+ "tabSize": "2",
730
+ "WebkitHyphens": "none",
731
+ "MozHyphens": "none",
732
+ "msHyphens": "none",
733
+ "hyphens": "none"
734
+ },
735
+ 'pre[class*="language-"]': {
736
+ "background": "#fff",
737
+ "color": "#1e293b",
738
+ "textShadow": "none",
739
+ "fontFamily": '"Fira Code", "Fira Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace',
740
+ "direction": "ltr",
741
+ "textAlign": "left",
742
+ "whiteSpace": "pre",
743
+ "wordSpacing": "normal",
744
+ "wordBreak": "normal",
745
+ "lineHeight": "1.5",
746
+ "MozTabSize": "2",
747
+ "OTabSize": "2",
748
+ "tabSize": "2",
749
+ "WebkitHyphens": "none",
750
+ "MozHyphens": "none",
751
+ "msHyphens": "none",
752
+ "hyphens": "none",
753
+ "padding": "1em",
754
+ "margin": "0.5em 0",
755
+ "overflow": "auto",
756
+ "borderRadius": "0.3em",
757
+ "border": "1px solid #e2e8f0"
758
+ },
759
+ 'code[class*="language-"]::-moz-selection': {
760
+ "background": "#e2e8f0",
761
+ "color": "inherit",
762
+ "textShadow": "none"
763
+ },
764
+ 'code[class*="language-"] *::-moz-selection': {
765
+ "background": "#e2e8f0",
766
+ "color": "inherit",
767
+ "textShadow": "none"
768
+ },
769
+ 'pre[class*="language-"] *::-moz-selection': {
770
+ "background": "#e2e8f0",
771
+ "color": "inherit",
772
+ "textShadow": "none"
773
+ },
774
+ 'code[class*="language-"]::selection': {
775
+ "background": "#e2e8f0",
776
+ "color": "inherit",
777
+ "textShadow": "none"
778
+ },
779
+ 'code[class*="language-"] *::selection': {
780
+ "background": "#e2e8f0",
781
+ "color": "inherit",
782
+ "textShadow": "none"
783
+ },
784
+ 'pre[class*="language-"] *::selection': {
785
+ "background": "#e2e8f0",
786
+ "color": "inherit",
787
+ "textShadow": "none"
788
+ },
789
+ ':not(pre) > code[class*="language-"]': {
790
+ "padding": "0.2em 0.3em",
791
+ "borderRadius": "0.3em",
792
+ "whiteSpace": "normal",
793
+ "background": "#f1f5f9"
794
+ },
795
+ "comment": {
796
+ "color": "#64748b",
797
+ "fontStyle": "italic"
798
+ },
799
+ "prolog": {
800
+ "color": "#64748b"
801
+ },
802
+ "cdata": {
803
+ "color": "#64748b"
804
+ },
805
+ "doctype": {
806
+ "color": "#1e293b"
807
+ },
808
+ "punctuation": {
809
+ "color": "#64748b"
810
+ },
811
+ "entity": {
812
+ "color": "#3b82f6",
813
+ "cursor": "help"
814
+ },
815
+ "attr-name": {
816
+ "color": "#ea580c"
817
+ },
818
+ "class-name": {
819
+ "color": "#ea580c"
820
+ },
821
+ "boolean": {
822
+ "color": "#3b82f6"
823
+ },
824
+ "constant": {
825
+ "color": "#3b82f6"
826
+ },
827
+ "number": {
828
+ "color": "#3b82f6"
829
+ },
830
+ "atrule": {
831
+ "color": "#ea580c"
832
+ },
833
+ "keyword": {
834
+ "color": "#9333ea"
835
+ },
836
+ "property": {
837
+ "color": "#3b82f6"
838
+ },
839
+ "tag": {
840
+ "color": "#3b82f6"
841
+ },
842
+ "symbol": {
843
+ "color": "#3b82f6"
844
+ },
845
+ "deleted": {
846
+ "color": "#dc2626"
847
+ },
848
+ "important": {
849
+ "color": "#9333ea"
850
+ },
851
+ "selector": {
852
+ "color": "#16a34a"
853
+ },
854
+ "string": {
855
+ "color": "#16a34a"
856
+ },
857
+ "char": {
858
+ "color": "#16a34a"
859
+ },
860
+ "builtin": {
861
+ "color": "#16a34a"
862
+ },
863
+ "inserted": {
864
+ "color": "#16a34a"
865
+ },
866
+ "regex": {
867
+ "color": "#16a34a"
868
+ },
869
+ "attr-value": {
870
+ "color": "#16a34a"
871
+ },
872
+ "attr-value > .token.punctuation": {
873
+ "color": "#16a34a"
874
+ },
875
+ "variable": {
876
+ "color": "#3b82f6"
877
+ },
878
+ "operator": {
879
+ "color": "#3b82f6"
880
+ },
881
+ "function": {
882
+ "color": "#3b82f6"
883
+ },
884
+ "url": {
885
+ "color": "#3b82f6"
886
+ },
887
+ "attr-value > .token.punctuation.attr-equals": {
888
+ "color": "#64748b"
889
+ },
890
+ "special-attr > .token.attr-value > .token.value.css": {
891
+ "color": "#1e293b"
892
+ },
893
+ ".language-css .token.selector": {
894
+ "color": "#3b82f6"
895
+ },
896
+ ".language-css .token.property": {
897
+ "color": "#1e293b"
898
+ },
899
+ ".language-css .token.function": {
900
+ "color": "#3b82f6"
901
+ },
902
+ ".language-css .token.url > .token.function": {
903
+ "color": "#3b82f6"
904
+ },
905
+ ".language-css .token.url > .token.string.url": {
906
+ "color": "#16a34a"
907
+ },
908
+ ".language-css .token.important": {
909
+ "color": "#9333ea"
910
+ },
911
+ ".language-css .token.atrule .token.rule": {
912
+ "color": "#9333ea"
913
+ },
914
+ ".language-javascript .token.operator": {
915
+ "color": "#9333ea"
916
+ },
917
+ ".language-javascript .token.template-string > .token.interpolation > .token.interpolation-punctuation.punctuation": {
918
+ "color": "#dc2626"
919
+ },
920
+ ".language-json .token.operator": {
921
+ "color": "#1e293b"
922
+ },
923
+ ".language-json .token.null.keyword": {
924
+ "color": "#3b82f6"
925
+ },
926
+ ".language-markdown .token.url": {
927
+ "color": "#1e293b"
928
+ },
929
+ ".language-markdown .token.url > .token.operator": {
930
+ "color": "#1e293b"
931
+ },
932
+ ".language-markdown .token.url-reference.url > .token.string": {
933
+ "color": "#1e293b"
934
+ },
935
+ ".language-markdown .token.url > .token.content": {
936
+ "color": "#3b82f6"
937
+ },
938
+ ".language-markdown .token.url > .token.url": {
939
+ "color": "#3b82f6"
940
+ },
941
+ ".language-markdown .token.url-reference.url": {
942
+ "color": "#3b82f6"
943
+ },
944
+ ".language-markdown .token.blockquote.punctuation": {
945
+ "color": "#64748b",
946
+ "fontStyle": "italic"
947
+ },
948
+ ".language-markdown .token.hr.punctuation": {
949
+ "color": "#64748b",
950
+ "fontStyle": "italic"
951
+ },
952
+ ".language-markdown .token.code-snippet": {
953
+ "color": "#16a34a"
954
+ },
955
+ ".language-markdown .token.bold .token.content": {
956
+ "color": "#ea580c"
957
+ },
958
+ ".language-markdown .token.italic .token.content": {
959
+ "color": "#9333ea"
960
+ },
961
+ ".language-markdown .token.strike .token.content": {
962
+ "color": "#3b82f6"
963
+ },
964
+ ".language-markdown .token.strike .token.punctuation": {
965
+ "color": "#3b82f6"
966
+ },
967
+ ".language-markdown .token.list.punctuation": {
968
+ "color": "#3b82f6"
969
+ },
970
+ ".language-markdown .token.title.important > .token.punctuation": {
971
+ "color": "#3b82f6"
972
+ },
973
+ "bold": {
974
+ "fontWeight": "bold"
975
+ },
976
+ "italic": {
977
+ "fontStyle": "italic"
978
+ },
979
+ "namespace": {
980
+ "Opacity": "0.8"
981
+ },
982
+ "token.tab:not(:empty):before": {
983
+ "color": "#94a3b8"
984
+ },
985
+ "token.cr:before": {
986
+ "color": "#94a3b8"
987
+ },
988
+ "token.lf:before": {
989
+ "color": "#94a3b8"
990
+ },
991
+ "token.space:before": {
992
+ "color": "#94a3b8"
993
+ },
994
+ "div.code-toolbar > .toolbar.toolbar > .toolbar-item": {
995
+ "marginRight": "0.4em"
996
+ },
997
+ "div.code-toolbar > .toolbar.toolbar > .toolbar-item > button": {
998
+ "background": "#f1f5f9",
999
+ "color": "#475569",
1000
+ "padding": "0.1em 0.4em",
1001
+ "borderRadius": "0.3em"
1002
+ },
1003
+ "div.code-toolbar > .toolbar.toolbar > .toolbar-item > a": {
1004
+ "background": "#f1f5f9",
1005
+ "color": "#475569",
1006
+ "padding": "0.1em 0.4em",
1007
+ "borderRadius": "0.3em"
1008
+ },
1009
+ "div.code-toolbar > .toolbar.toolbar > .toolbar-item > span": {
1010
+ "background": "#f1f5f9",
1011
+ "color": "#475569",
1012
+ "padding": "0.1em 0.4em",
1013
+ "borderRadius": "0.3em"
1014
+ },
1015
+ "div.code-toolbar > .toolbar.toolbar > .toolbar-item > button:hover": {
1016
+ "background": "#3b82f6",
1017
+ "color": "#ffffff"
1018
+ },
1019
+ "div.code-toolbar > .toolbar.toolbar > .toolbar-item > button:focus": {
1020
+ "background": "#3b82f6",
1021
+ "color": "#ffffff"
1022
+ },
1023
+ "div.code-toolbar > .toolbar.toolbar > .toolbar-item > a:hover": {
1024
+ "background": "#3b82f6",
1025
+ "color": "#ffffff"
1026
+ },
1027
+ "div.code-toolbar > .toolbar.toolbar > .toolbar-item > a:focus": {
1028
+ "background": "#3b82f6",
1029
+ "color": "#ffffff"
1030
+ },
1031
+ "div.code-toolbar > .toolbar.toolbar > .toolbar-item > span:hover": {
1032
+ "background": "#3b82f6",
1033
+ "color": "#ffffff"
1034
+ },
1035
+ "div.code-toolbar > .toolbar.toolbar > .toolbar-item > span:focus": {
1036
+ "background": "#3b82f6",
1037
+ "color": "#ffffff"
1038
+ },
1039
+ ".line-highlight.line-highlight": {
1040
+ "background": "rgba(59, 130, 246, 0.08)"
1041
+ },
1042
+ ".line-highlight.line-highlight:before": {
1043
+ "background": "#f1f5f9",
1044
+ "color": "#1e293b",
1045
+ "padding": "0.1em 0.6em",
1046
+ "borderRadius": "0.3em",
1047
+ "boxShadow": "0 2px 0 0 rgba(0, 0, 0, 0.1)"
1048
+ },
1049
+ ".line-highlight.line-highlight[data-end]:after": {
1050
+ "background": "#f1f5f9",
1051
+ "color": "#1e293b",
1052
+ "padding": "0.1em 0.6em",
1053
+ "borderRadius": "0.3em",
1054
+ "boxShadow": "0 2px 0 0 rgba(0, 0, 0, 0.1)"
1055
+ },
1056
+ "pre[id].linkable-line-numbers.linkable-line-numbers span.line-numbers-rows > span:hover:before": {
1057
+ "backgroundColor": "rgba(59, 130, 246, 0.08)"
1058
+ },
1059
+ ".line-numbers.line-numbers .line-numbers-rows": {
1060
+ "borderRightColor": "#e2e8f0"
1061
+ },
1062
+ ".command-line .command-line-prompt": {
1063
+ "borderRightColor": "#e2e8f0"
1064
+ },
1065
+ ".line-numbers .line-numbers-rows > span:before": {
1066
+ "color": "#94a3b8"
1067
+ },
1068
+ ".command-line .command-line-prompt > span:before": {
1069
+ "color": "#94a3b8"
1070
+ },
1071
+ ".rainbow-braces .token.token.punctuation.brace-level-1": {
1072
+ "color": "#3b82f6"
1073
+ },
1074
+ ".rainbow-braces .token.token.punctuation.brace-level-5": {
1075
+ "color": "#3b82f6"
1076
+ },
1077
+ ".rainbow-braces .token.token.punctuation.brace-level-9": {
1078
+ "color": "#3b82f6"
1079
+ },
1080
+ ".rainbow-braces .token.token.punctuation.brace-level-2": {
1081
+ "color": "#16a34a"
1082
+ },
1083
+ ".rainbow-braces .token.token.punctuation.brace-level-6": {
1084
+ "color": "#16a34a"
1085
+ },
1086
+ ".rainbow-braces .token.token.punctuation.brace-level-10": {
1087
+ "color": "#16a34a"
1088
+ },
1089
+ ".rainbow-braces .token.token.punctuation.brace-level-3": {
1090
+ "color": "#ea580c"
1091
+ },
1092
+ ".rainbow-braces .token.token.punctuation.brace-level-7": {
1093
+ "color": "#ea580c"
1094
+ },
1095
+ ".rainbow-braces .token.token.punctuation.brace-level-11": {
1096
+ "color": "#ea580c"
1097
+ },
1098
+ ".rainbow-braces .token.token.punctuation.brace-level-4": {
1099
+ "color": "#9333ea"
1100
+ },
1101
+ ".rainbow-braces .token.token.punctuation.brace-level-8": {
1102
+ "color": "#9333ea"
1103
+ },
1104
+ ".rainbow-braces .token.token.punctuation.brace-level-12": {
1105
+ "color": "#9333ea"
1106
+ },
1107
+ "pre.diff-highlight > code .token.token.deleted:not(.prefix)": {
1108
+ "backgroundColor": "rgba(220, 38, 38, 0.15)"
1109
+ },
1110
+ "pre > code.diff-highlight .token.token.deleted:not(.prefix)": {
1111
+ "backgroundColor": "rgba(220, 38, 38, 0.15)"
1112
+ },
1113
+ "pre.diff-highlight > code .token.token.deleted:not(.prefix)::-moz-selection": {
1114
+ "backgroundColor": "rgba(220, 38, 38, 0.25)"
1115
+ },
1116
+ "pre.diff-highlight > code .token.token.deleted:not(.prefix) *::-moz-selection": {
1117
+ "backgroundColor": "rgba(220, 38, 38, 0.25)"
1118
+ },
1119
+ "pre > code.diff-highlight .token.token.deleted:not(.prefix)::-moz-selection": {
1120
+ "backgroundColor": "rgba(220, 38, 38, 0.25)"
1121
+ },
1122
+ "pre > code.diff-highlight .token.token.deleted:not(.prefix) *::-moz-selection": {
1123
+ "backgroundColor": "rgba(220, 38, 38, 0.25)"
1124
+ },
1125
+ "pre.diff-highlight > code .token.token.deleted:not(.prefix)::selection": {
1126
+ "backgroundColor": "rgba(220, 38, 38, 0.25)"
1127
+ },
1128
+ "pre.diff-highlight > code .token.token.deleted:not(.prefix) *::selection": {
1129
+ "backgroundColor": "rgba(220, 38, 38, 0.25)"
1130
+ },
1131
+ "pre > code.diff-highlight .token.token.deleted:not(.prefix)::selection": {
1132
+ "backgroundColor": "rgba(220, 38, 38, 0.25)"
1133
+ },
1134
+ "pre > code.diff-highlight .token.token.deleted:not(.prefix) *::selection": {
1135
+ "backgroundColor": "rgba(220, 38, 38, 0.25)"
1136
+ },
1137
+ "pre.diff-highlight > code .token.token.inserted:not(.prefix)": {
1138
+ "backgroundColor": "rgba(22, 163, 74, 0.15)"
1139
+ },
1140
+ "pre > code.diff-highlight .token.token.inserted:not(.prefix)": {
1141
+ "backgroundColor": "rgba(22, 163, 74, 0.15)"
1142
+ },
1143
+ "pre.diff-highlight > code .token.token.inserted:not(.prefix)::-moz-selection": {
1144
+ "backgroundColor": "rgba(22, 163, 74, 0.25)"
1145
+ },
1146
+ "pre.diff-highlight > code .token.token.inserted:not(.prefix) *::-moz-selection": {
1147
+ "backgroundColor": "rgba(22, 163, 74, 0.25)"
1148
+ },
1149
+ "pre > code.diff-highlight .token.token.inserted:not(.prefix)::-moz-selection": {
1150
+ "backgroundColor": "rgba(22, 163, 74, 0.25)"
1151
+ },
1152
+ "pre > code.diff-highlight .token.token.inserted:not(.prefix) *::-moz-selection": {
1153
+ "backgroundColor": "rgba(22, 163, 74, 0.25)"
1154
+ },
1155
+ "pre.diff-highlight > code .token.token.inserted:not(.prefix)::selection": {
1156
+ "backgroundColor": "rgba(22, 163, 74, 0.25)"
1157
+ },
1158
+ "pre.diff-highlight > code .token.token.inserted:not(.prefix) *::selection": {
1159
+ "backgroundColor": "rgba(22, 163, 74, 0.25)"
1160
+ },
1161
+ "pre > code.diff-highlight .token.token.inserted:not(.prefix)::selection": {
1162
+ "backgroundColor": "rgba(22, 163, 74, 0.25)"
1163
+ },
1164
+ "pre > code.diff-highlight .token.token.inserted:not(.prefix) *::selection": {
1165
+ "backgroundColor": "rgba(22, 163, 74, 0.25)"
1166
+ },
1167
+ ".prism-previewer.prism-previewer:before": {
1168
+ "borderColor": "#fff"
1169
+ },
1170
+ ".prism-previewer-gradient.prism-previewer-gradient div": {
1171
+ "borderColor": "#fff",
1172
+ "borderRadius": "0.3em"
1173
+ },
1174
+ ".prism-previewer-color.prism-previewer-color:before": {
1175
+ "borderRadius": "0.3em"
1176
+ },
1177
+ ".prism-previewer-easing.prism-previewer-easing:before": {
1178
+ "borderRadius": "0.3em"
1179
+ },
1180
+ ".prism-previewer.prism-previewer:after": {
1181
+ "borderTopColor": "#fff"
1182
+ },
1183
+ ".prism-previewer-flipped.prism-previewer-flipped.after": {
1184
+ "borderBottomColor": "#fff"
1185
+ },
1186
+ ".prism-previewer-angle.prism-previewer-angle:before": {
1187
+ "background": "#f1f5f9"
1188
+ },
1189
+ ".prism-previewer-time.prism-previewer-time:before": {
1190
+ "background": "#f1f5f9"
1191
+ },
1192
+ ".prism-previewer-easing.prism-previewer-easing": {
1193
+ "background": "#f1f5f9"
1194
+ },
1195
+ ".prism-previewer-angle.prism-previewer-angle circle": {
1196
+ "stroke": "#1e293b",
1197
+ "strokeOpacity": "1"
1198
+ },
1199
+ ".prism-previewer-time.prism-previewer-time circle": {
1200
+ "stroke": "#1e293b",
1201
+ "strokeOpacity": "1"
1202
+ },
1203
+ ".prism-previewer-easing.prism-previewer-easing circle": {
1204
+ "stroke": "#1e293b",
1205
+ "fill": "transparent"
1206
+ },
1207
+ ".prism-previewer-easing.prism-previewer-easing path": {
1208
+ "stroke": "#1e293b"
1209
+ },
1210
+ ".prism-previewer-easing.prism-previewer-easing line": {
1211
+ "stroke": "#1e293b"
1212
+ }
1213
+ };
1214
+ const CodeHighlighter = ({
1215
+ className,
1216
+ children,
1217
+ copyClassName,
1218
+ copyIcon = /* @__PURE__ */ jsx(SvgCopy, {}),
1219
+ language,
1220
+ toolbarClassName,
1221
+ theme = dark
1222
+ }) => {
1223
+ const match = language == null ? void 0 : language.match(/language-(\w+)/);
1224
+ const lang = match ? match[1] : "text";
1225
+ const handleCopy = (text) => {
1226
+ navigator.clipboard.writeText(text).then(() => {
1227
+ console.log("Text copied to clipboard");
1228
+ }).catch((err) => {
1229
+ console.error("Could not copy text: ", err);
1230
+ });
1231
+ };
1232
+ return /* @__PURE__ */ jsxs("div", { className: cn("relative", className), children: [
1233
+ /* @__PURE__ */ jsxs("div", { className: cn(toolbarClassName), children: [
1234
+ /* @__PURE__ */ jsx("div", { children: lang }),
1235
+ copyIcon && /* @__PURE__ */ jsx(
1236
+ Button,
1237
+ {
1238
+ className: cn(copyClassName),
1239
+ size: "small",
1240
+ variant: "text",
1241
+ title: "Copy code",
1242
+ onClick: () => handleCopy(children),
1243
+ children: copyIcon
1244
+ }
1245
+ )
1246
+ ] }),
1247
+ /* @__PURE__ */ jsx(
1248
+ Prism,
1249
+ {
1250
+ language: lang,
1251
+ style: theme,
1252
+ children
1253
+ }
1254
+ )
1255
+ ] });
1256
+ };
1257
+ const TableComponent = ({ children, ...props }) => /* @__PURE__ */ jsx("table", { ...props, children });
1258
+ const TableHeaderCell = ({ children, ...props }) => /* @__PURE__ */ jsx("th", { ...props, children });
1259
+ const TableDataCell = ({ children, ...props }) => /* @__PURE__ */ jsx("td", { ...props, children });
1260
+ const Markdown = ({
1261
+ children,
1262
+ remarkPlugins,
1263
+ rehypePlugins = [rehypeKatex]
1264
+ }) => {
1265
+ const { theme } = useContext(ChatContext);
1266
+ return /* @__PURE__ */ jsx(
1267
+ ReactMarkdown,
1268
+ {
1269
+ remarkPlugins,
1270
+ rehypePlugins,
1271
+ components: {
1272
+ code: ({ className, ...props }) => /* @__PURE__ */ jsx(
1273
+ CodeHighlighter,
1274
+ {
1275
+ ...props,
1276
+ language: className,
1277
+ className: cn(theme.messages.message.markdown.code, className),
1278
+ copyClassName: cn(theme.messages.message.markdown.copy),
1279
+ toolbarClassName: cn(theme.messages.message.markdown.toolbar)
1280
+ }
1281
+ ),
1282
+ table: (props) => /* @__PURE__ */ jsx(TableComponent, { ...props, className: cn(theme.messages.message.markdown.table) }),
1283
+ th: (props) => /* @__PURE__ */ jsx(TableHeaderCell, { ...props, className: cn(theme.messages.message.markdown.th) }),
1284
+ td: (props) => /* @__PURE__ */ jsx(TableDataCell, { ...props, className: cn(theme.messages.message.markdown.td) }),
1285
+ a: (props) => /* @__PURE__ */ jsx("a", { ...props, className: cn(theme.messages.message.markdown.a) }),
1286
+ p: (props) => /* @__PURE__ */ jsx("p", { ...props, className: cn(theme.messages.message.markdown.p) }),
1287
+ li: (props) => /* @__PURE__ */ jsx("li", { ...props, className: cn(theme.messages.message.markdown.li) }),
1288
+ ul: (props) => /* @__PURE__ */ jsx("ul", { ...props, className: cn(theme.messages.message.markdown.ul) }),
1289
+ ol: (props) => /* @__PURE__ */ jsx("ol", { ...props, className: cn(theme.messages.message.markdown.ol) })
1290
+ },
1291
+ children
1292
+ }
1293
+ );
1294
+ };
1295
+ const CVE_REGEX = /(CVE-(19|20)\d{2}-\d{4,7})/gi;
1296
+ function remarkCve() {
1297
+ return (tree, _file) => {
1298
+ findAndReplace(tree, [[
1299
+ CVE_REGEX,
1300
+ replaceCve
1301
+ ]]);
1302
+ };
1303
+ function replaceCve(value, id) {
1304
+ return [
1305
+ {
1306
+ type: "link",
1307
+ url: `https://cve.mitre.org/cgi-bin/cvename.cgi?name=${id}`,
1308
+ children: [
1309
+ { children: [{ type: "text", value: value.trim() }] }
1310
+ ]
1311
+ }
1312
+ ];
1313
+ }
1314
+ }
1315
+ 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" }));
1316
+ const DefaultFileRenderer = lazy(() => import("./DefaultFileRenderer-DZL5GRed.js"));
1317
+ const CSVFileRenderer = lazy(() => import("./CSVFileRenderer-6glCQ4gs.js"));
1318
+ const ImageFileRenderer = lazy(() => import("./ImageFileRenderer-C8tVW3I8.js"));
1319
+ const PDFFileRenderer = lazy(() => import("./PDFFileRenderer-DQdFS2l6.js"));
1320
+ const FILE_TYPE_RENDERER_MAP = {
1321
+ "image/": ImageFileRenderer,
1322
+ "text/csv": CSVFileRenderer,
1323
+ "application/pdf": PDFFileRenderer
1324
+ };
1325
+ const MessageFile = ({
1326
+ name,
1327
+ type,
1328
+ url,
1329
+ limit = 100,
1330
+ fileIcon = /* @__PURE__ */ jsx(SvgFile, {})
1331
+ }) => {
1332
+ const { theme } = useContext(ChatContext);
1333
+ const FileRenderer = useMemo(() => {
1334
+ const Renderer = Object.keys(FILE_TYPE_RENDERER_MAP).find((key) => type == null ? void 0 : type.startsWith(key)) ?? "default";
1335
+ return FILE_TYPE_RENDERER_MAP[Renderer] || DefaultFileRenderer;
1336
+ }, [type]);
1337
+ return /* @__PURE__ */ jsx(
1338
+ "div",
1339
+ {
1340
+ className: cn(theme.messages.message.files.file.base),
1341
+ children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: /* @__PURE__ */ jsx(FileRenderer, { name, url, fileIcon, limit }) })
1342
+ }
1343
+ );
1344
+ };
1345
+ const MessageFiles = ({ files, children }) => {
1346
+ const { theme } = useContext(ChatContext);
1347
+ const Comp = children ? Slot : MessageFile;
1348
+ const [expanded, setExpanded] = useState(false);
1349
+ if (!files || files.length === 0) {
1350
+ return null;
1351
+ }
1352
+ const { imageFiles, otherFiles } = files.reduce(
1353
+ (acc, file) => {
1354
+ if (file.type.startsWith("image/")) {
1355
+ acc.imageFiles.push(file);
1356
+ } else {
1357
+ acc.otherFiles.push(file);
1358
+ }
1359
+ return acc;
1360
+ },
1361
+ {
1362
+ imageFiles: [],
1363
+ otherFiles: []
1364
+ }
1365
+ );
1366
+ const maxImageLength = 3;
1367
+ const truncateImages = !expanded && imageFiles.length > maxImageLength;
1368
+ const renderImageFiles = (images) => {
1369
+ return truncateImages ? images.slice(0, maxImageLength).map((image, index) => /* @__PURE__ */ jsxs(
1370
+ "figure",
1371
+ {
1372
+ className: index === 0 ? "col-span-2 row-span-2" : "relative",
1373
+ children: [
1374
+ /* @__PURE__ */ jsx(
1375
+ "img",
1376
+ {
1377
+ src: image.url,
1378
+ alt: image.name,
1379
+ className: "relative w-full h-full object-cover rounded-lg"
1380
+ }
1381
+ ),
1382
+ index === maxImageLength - 1 && /* @__PURE__ */ jsxs(
1383
+ "div",
1384
+ {
1385
+ className: "absolute top-0 left-0 w-full h-full flex justify-center items-center bg-black bg-opacity-50 rounded-lg cursor-pointer",
1386
+ onClick: () => setExpanded(true),
1387
+ children: [
1388
+ "+",
1389
+ (imageFiles.length - maxImageLength).toLocaleString()
1390
+ ]
1391
+ }
1392
+ )
1393
+ ]
1394
+ },
1395
+ index
1396
+ )) : images.map((image, index) => /* @__PURE__ */ jsx(Comp, { ...image, children }, index));
1397
+ };
1398
+ return /* @__PURE__ */ jsxs(
1399
+ "div",
1400
+ {
1401
+ className: cn(
1402
+ theme.messages.message.files.base,
1403
+ truncateImages ? "grid grid-rows-2 grid-flow-col gap-2 w-1/3" : ""
1404
+ ),
1405
+ children: [
1406
+ imageFiles.length > 0 && renderImageFiles(imageFiles),
1407
+ otherFiles.length > 0 && otherFiles.map((file, index) => /* @__PURE__ */ jsx(Comp, { ...file, children }, index))
1408
+ ]
1409
+ }
1410
+ );
1411
+ };
1412
+ const MessageQuestion = ({
1413
+ children,
1414
+ ...props
1415
+ }) => {
1416
+ const { theme, remarkPlugins } = useContext(ChatContext);
1417
+ const { question, files } = props;
1418
+ const Comp = children ? Slot : "div";
1419
+ const [expanded, setExpanded] = useState(false);
1420
+ const isLong = question.length > 500;
1421
+ return /* @__PURE__ */ jsx(
1422
+ Comp,
1423
+ {
1424
+ className: cn(theme.messages.message.question, {
1425
+ [theme.messages.message.overlay]: isLong && !expanded
1426
+ }),
1427
+ ...props,
1428
+ children: children || /* @__PURE__ */ jsxs(Fragment, { children: [
1429
+ /* @__PURE__ */ jsx(MessageFiles, { files }),
1430
+ /* @__PURE__ */ jsx(Markdown, { remarkPlugins, children: question }),
1431
+ isLong && !expanded && /* @__PURE__ */ jsx(
1432
+ Button,
1433
+ {
1434
+ variant: "link",
1435
+ size: "small",
1436
+ className: theme.messages.message.expand,
1437
+ onClick: () => setExpanded(true),
1438
+ children: "Show more"
1439
+ }
1440
+ )
1441
+ ] })
1442
+ }
1443
+ );
1444
+ };
1445
+ const MessageResponse = ({
1446
+ response,
1447
+ isLoading,
1448
+ children
1449
+ }) => {
1450
+ const {
1451
+ theme,
1452
+ isCompact,
1453
+ remarkPlugins
1454
+ } = useContext(ChatContext);
1455
+ const Comp = children ? Slot : "div";
1456
+ return /* @__PURE__ */ jsx(
1457
+ Comp,
1458
+ {
1459
+ "data-compact": isCompact,
1460
+ className: cn(theme.messages.message.response),
1461
+ children: children || /* @__PURE__ */ jsxs(Fragment, { children: [
1462
+ /* @__PURE__ */ jsx(Markdown, { remarkPlugins, children: response }),
1463
+ isLoading && /* @__PURE__ */ jsx(
1464
+ motion.div,
1465
+ {
1466
+ className: cn(theme.messages.message.cursor),
1467
+ animate: { opacity: [1, 0] },
1468
+ transition: {
1469
+ duration: 0.7,
1470
+ repeat: Infinity,
1471
+ repeatType: "reverse"
1472
+ }
1473
+ }
1474
+ )
1475
+ ] })
1476
+ }
1477
+ );
1478
+ };
1479
+ const MessageSource = ({ title, url, image, limit = 50 }) => {
1480
+ const { theme, isCompact } = useContext(ChatContext);
1481
+ return /* @__PURE__ */ jsxs(
1482
+ "figure",
1483
+ {
1484
+ className: cn(theme.messages.message.sources.source.base, {
1485
+ [theme.messages.message.sources.source.companion]: isCompact
1486
+ }),
1487
+ onClick: () => {
1488
+ if (url) {
1489
+ window.open(url, "_blank");
1490
+ }
1491
+ },
1492
+ children: [
1493
+ image && /* @__PURE__ */ jsx("img", { src: image, alt: title, className: cn(theme.messages.message.sources.source.image) }),
1494
+ (title || url) && /* @__PURE__ */ jsxs("figcaption", { children: [
1495
+ title && /* @__PURE__ */ jsx("span", { className: cn(theme.messages.message.sources.source.title), children: /* @__PURE__ */ jsx(Ellipsis, { value: title, limit }) }),
1496
+ url && /* @__PURE__ */ jsx("a", { href: url, target: "_blank", rel: "noopener noreferrer", className: cn(theme.messages.message.sources.source.url), children: url })
1497
+ ] })
1498
+ ]
1499
+ }
1500
+ );
1501
+ };
1502
+ const MessageSources = ({
1503
+ sources,
1504
+ children
1505
+ }) => {
1506
+ const { theme } = useContext(ChatContext);
1507
+ const Comp = children ? Slot : MessageSource;
1508
+ if (!sources || sources.length === 0) {
1509
+ return null;
1510
+ }
1511
+ 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)) });
1512
+ };
1513
+ const SvgThumbsDown = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 24, height: 24, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 1, strokeLinecap: "round", strokeLinejoin: "round", className: "lucide lucide-thumbs-down", ...props }, /* @__PURE__ */ React.createElement("path", { d: "M17 14V2" }), /* @__PURE__ */ React.createElement("path", { d: "M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z" }));
1514
+ const SvgThumbsUp = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 24, height: 24, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 1, strokeLinecap: "round", strokeLinejoin: "round", className: "lucide lucide-thumbs-up", ...props }, /* @__PURE__ */ React.createElement("path", { d: "M7 10v12" }), /* @__PURE__ */ React.createElement("path", { d: "M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z" }));
1515
+ const SvgRefresh = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 24, height: 24, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 1, strokeLinecap: "round", strokeLinejoin: "round", className: "lucide lucide-refresh-ccw", ...props }, /* @__PURE__ */ React.createElement("path", { d: "M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" }), /* @__PURE__ */ React.createElement("path", { d: "M3 3v5h5" }), /* @__PURE__ */ React.createElement("path", { d: "M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16" }), /* @__PURE__ */ React.createElement("path", { d: "M16 16h5v5" }));
1516
+ const MessageActions = ({
1517
+ children,
1518
+ ...props
1519
+ }) => {
1520
+ const { theme } = useContext(ChatContext);
1521
+ const {
1522
+ question,
1523
+ response,
1524
+ copyIcon = /* @__PURE__ */ jsx(SvgCopy, {}),
1525
+ thumbsUpIcon = /* @__PURE__ */ jsx(SvgThumbsUp, {}),
1526
+ thumbsDownIcon = /* @__PURE__ */ jsx(SvgThumbsDown, {}),
1527
+ refreshIcon = /* @__PURE__ */ jsx(SvgRefresh, {}),
1528
+ onCopy,
1529
+ onUpvote,
1530
+ onDownvote,
1531
+ onRefresh
1532
+ } = props;
1533
+ const Comp = children ? Slot : "div";
1534
+ const handleCopy = (text) => {
1535
+ navigator.clipboard.writeText(text).then(() => {
1536
+ console.log("Text copied to clipboard");
1537
+ }).catch((err) => {
1538
+ console.error("Could not copy text: ", err);
1539
+ });
1540
+ };
1541
+ return (copyIcon || thumbsDownIcon || thumbsUpIcon || refreshIcon) && /* @__PURE__ */ jsx(Comp, { className: cn(theme.messages.message.footer.base), children: children || /* @__PURE__ */ jsxs(Fragment, { children: [
1542
+ copyIcon && /* @__PURE__ */ jsx(
1543
+ IconButton,
1544
+ {
1545
+ variant: "text",
1546
+ disablePadding: true,
1547
+ title: "Copy question and response",
1548
+ className: cn(theme.messages.message.footer.copy),
1549
+ onClick: onCopy ? onCopy : () => handleCopy(`${question}
1550
+ ${response}`),
1551
+ children: copyIcon
1552
+ }
1553
+ ),
1554
+ thumbsUpIcon && /* @__PURE__ */ jsx(
1555
+ IconButton,
1556
+ {
1557
+ variant: "text",
1558
+ disablePadding: true,
1559
+ title: "Upvote",
1560
+ className: cn(theme.messages.message.footer.upvote),
1561
+ onClick: onUpvote,
1562
+ children: thumbsUpIcon
1563
+ }
1564
+ ),
1565
+ thumbsDownIcon && /* @__PURE__ */ jsx(
1566
+ IconButton,
1567
+ {
1568
+ variant: "text",
1569
+ disablePadding: true,
1570
+ title: "Downvote",
1571
+ className: cn(theme.messages.message.footer.downvote),
1572
+ onClick: onDownvote,
1573
+ children: thumbsDownIcon
1574
+ }
1575
+ ),
1576
+ refreshIcon && /* @__PURE__ */ jsx(
1577
+ IconButton,
1578
+ {
1579
+ variant: "text",
1580
+ disablePadding: true,
1581
+ title: "Refresh",
1582
+ className: cn(theme.messages.message.footer.refresh),
1583
+ onClick: onRefresh,
1584
+ children: refreshIcon
1585
+ }
1586
+ )
1587
+ ] }) });
1588
+ };
1589
+ const messageVariants = {
1590
+ hidden: {
1591
+ opacity: 0,
1592
+ y: 20
1593
+ },
1594
+ visible: {
1595
+ opacity: 1,
1596
+ y: 0,
1597
+ transition: {
1598
+ duration: 0.3
1599
+ }
1600
+ }
1601
+ };
1602
+ const SessionMessage = ({
1603
+ conversation,
1604
+ isLast,
1605
+ children
1606
+ }) => {
1607
+ const { theme, isLoading } = useContext(ChatContext);
1608
+ return /* @__PURE__ */ jsxs(motion.div, { variants: messageVariants, children: [
1609
+ /* @__PURE__ */ jsx(Card, { className: cn(theme.messages.message.base), children: children || /* @__PURE__ */ jsxs(Fragment, { children: [
1610
+ /* @__PURE__ */ jsx(MessageQuestion, { question: conversation.question, files: conversation.files }),
1611
+ /* @__PURE__ */ jsx(
1612
+ MessageResponse,
1613
+ {
1614
+ response: conversation.response,
1615
+ isLoading: isLast && isLoading
1616
+ }
1617
+ ),
1618
+ /* @__PURE__ */ jsx(MessageSources, { sources: conversation.sources }),
1619
+ /* @__PURE__ */ jsx(
1620
+ MessageActions,
1621
+ {
1622
+ question: conversation.question,
1623
+ response: conversation.response
1624
+ }
1625
+ )
1626
+ ] }) }),
1627
+ !isLast && /* @__PURE__ */ jsx(Divider, {})
1628
+ ] }, conversation.id);
1629
+ };
1630
+ const containerVariants = {
1631
+ hidden: {},
1632
+ visible: {
1633
+ transition: {
1634
+ staggerChildren: 0.07,
1635
+ when: "beforeChildren"
1636
+ }
1637
+ }
1638
+ };
1639
+ const SessionMessages = ({
1640
+ children,
1641
+ newSessionContent,
1642
+ limit = 10,
1643
+ showMoreText = "Show more"
1644
+ }) => {
1645
+ const { activeSession, theme } = useContext(ChatContext);
1646
+ const contentRef = useRef(null);
1647
+ const [isAnimating, setIsAnimating] = useState(true);
1648
+ useEffect(() => {
1649
+ if (contentRef.current) {
1650
+ requestAnimationFrame(
1651
+ () => contentRef.current.scrollTop = contentRef.current.scrollHeight
1652
+ );
1653
+ }
1654
+ }, [activeSession, isAnimating]);
1655
+ function handleShowMore() {
1656
+ showNext(limit);
1657
+ requestAnimationFrame(() => contentRef.current.scrollTop = 0);
1658
+ }
1659
+ const reversedConvos = useMemo(
1660
+ () => [...(activeSession == null ? void 0 : activeSession.conversations) ?? []].reverse(),
1661
+ [activeSession]
1662
+ );
1663
+ const { data, hasMore, showNext } = useInfinityList({
1664
+ items: reversedConvos,
1665
+ size: limit
1666
+ });
1667
+ const reReversedConvo = useMemo(() => [...data].reverse(), [data]);
1668
+ const convosToRender = limit ? reReversedConvo : activeSession == null ? void 0 : activeSession.conversations;
1669
+ if (!activeSession) {
1670
+ return /* @__PURE__ */ jsx(SessionEmpty, { children: newSessionContent });
1671
+ }
1672
+ return /* @__PURE__ */ jsxs("div", { className: cn(theme.messages.content), ref: contentRef, children: [
1673
+ hasMore && /* @__PURE__ */ jsx(
1674
+ Button,
1675
+ {
1676
+ variant: "outline",
1677
+ className: cn(theme.messages.showMore),
1678
+ fullWidth: true,
1679
+ onClick: handleShowMore,
1680
+ children: showMoreText
1681
+ }
1682
+ ),
1683
+ /* @__PURE__ */ jsx(AnimatePresence, { children: /* @__PURE__ */ jsx(
1684
+ motion.div,
1685
+ {
1686
+ variants: containerVariants,
1687
+ initial: "hidden",
1688
+ animate: "visible",
1689
+ onAnimationComplete: () => {
1690
+ requestAnimationFrame(() => setIsAnimating(false));
1691
+ },
1692
+ children: children ? children(convosToRender) : convosToRender.map((conversation, index) => /* @__PURE__ */ jsx(
1693
+ SessionMessage,
1694
+ {
1695
+ conversation,
1696
+ isLast: index === conversation.length - 1
1697
+ },
1698
+ conversation.id
1699
+ ))
1700
+ },
1701
+ activeSession == null ? void 0 : activeSession.id
1702
+ ) })
1703
+ ] });
1704
+ };
1705
+ const chatTheme = {
1706
+ base: "dark:text-white text-gray-500",
1707
+ console: "flex w-full gap-4 h-full",
1708
+ companion: "w-full h-full overflow-hidden",
1709
+ empty: "text-center flex-1",
1710
+ sessions: {
1711
+ base: "overflow-auto",
1712
+ console: "min-w-[150px] w-[30%] max-w-[300px] dark:bg-[#11111F] bg-[#F2F3F7] p-5 rounded-3xl",
1713
+ companion: "w-full h-full",
1714
+ group: "text-xs dart:text-gray-400 text-gray-700 mt-4 hover:bg-transparent mb-1",
1715
+ create: "relative mb-4 rounded-[10px] text-white",
1716
+ session: {
1717
+ base: [
1718
+ "group my-1 rounded-[10px] p-2 text-gray-500 border border-transparent hover:bg-gray-300 hover:border-gray-400 [&_svg]:text-gray-500",
1719
+ "dark:text-typography dark:text-gray-400 dark:hover:bg-gray-800/50 dark:hover:border-gray-700/50 dark:[&_svg]:text-gray-200"
1720
+ ].join(" "),
1721
+ active: [
1722
+ "border border-gray-300 hover:border-gray-400 text-gray-700 bg-gray-200 hover:bg-gray-300 ",
1723
+ "dark:text-gray-500 dark:bg-gray-800/70 dark:border-gray-700/50 dark:text-white dark:border-gray-700/70 dark:hover:bg-gray-800/50",
1724
+ "[&_button]:!opacity-100"
1725
+ ].join(" "),
1726
+ delete: "[&>svg]:w-4 [&>svg]:h-4 opacity-0 group-hover:!opacity-50"
1727
+ }
1728
+ },
1729
+ messages: {
1730
+ base: "",
1731
+ console: "flex flex-col mx-5 flex-1 overflow-hidden",
1732
+ companion: "flex w-full h-full",
1733
+ back: "self-start p-0 my-2",
1734
+ inner: "flex-1 h-full flex flex-col",
1735
+ title: ["text-base font-bold text-gray-500", "dark:text-gray-200"].join(
1736
+ " "
1737
+ ),
1738
+ date: "text-xs whitespace-nowrap text-gray-400",
1739
+ content: [
1740
+ "mt-2 flex-1 overflow-auto [&_hr]:bg-gray-200",
1741
+ "dark:[&_hr]:bg-gray-800/60"
1742
+ ].join(" "),
1743
+ header: "flex justify-between items-center gap-2",
1744
+ showMore: "mb-4",
1745
+ message: {
1746
+ base: "mt-4 mb-4 flex flex-col p-0 rounded border-none bg-transparent",
1747
+ question: [
1748
+ "relative font-semibold mb-4 px-4 py-4 pb-2 rounded-3xl rounded-br-none text-typography border bg-gray-200 border-gray-300 text-gray-900",
1749
+ "dark:bg-gray-900/60 dark:border-gray-700/50 dark:text-gray-100"
1750
+ ].join(" "),
1751
+ response: ["relative data-[compact=false]:px-4 text-gray-900", "dark:text-gray-100"].join(" "),
1752
+ overlay: `overflow-y-hidden max-h-[350px] after:content-[''] after:absolute after:inset-x-0 after:bottom-0 after:h-16 after:bg-gradient-to-b after:from-transparent dark:after:to-gray-900 after:to-gray-200`,
1753
+ cursor: "inline-block w-1 h-4 bg-current",
1754
+ expand: "absolute bottom-1 right-1 z-10",
1755
+ files: {
1756
+ base: "mb-2 flex flex-wrap gap-3 ",
1757
+ file: {
1758
+ base: [
1759
+ "flex items-center gap-2 border border-gray-300 px-3 py-2 rounded-lg cursor-pointer",
1760
+ "dark:border-gray-700"
1761
+ ].join(" "),
1762
+ name: ["text-sm text-gray-500", "dark:text-gray-200"].join(" ")
1763
+ }
1764
+ },
1765
+ sources: {
1766
+ base: "my-4 flex flex-wrap gap-3",
1767
+ source: {
1768
+ base: [
1769
+ "flex gap-2 border border-gray-200 px-4 py-2 rounded-lg cursor-pointer",
1770
+ "dark:border-gray-700"
1771
+ ].join(" "),
1772
+ companion: "flex-1 px-3 py-1.5",
1773
+ image: "max-w-10 max-h-10 rounded-md w-full h-fit self-center",
1774
+ title: "text-md block",
1775
+ url: "text-sm text-blue-400 underline"
1776
+ }
1777
+ },
1778
+ markdown: {
1779
+ copy: "sticky py-1 [&>svg]:w-4 [&>svg]:h-4 opacity-50",
1780
+ p: "mb-2",
1781
+ a: "text-blue-400 underline",
1782
+ table: "table-auto w-full m-2",
1783
+ th: "px-4 py-2 text-left font-bold border-b border-gray-500",
1784
+ td: "px-4 py-2",
1785
+ code: "m-2 rounded-b relative",
1786
+ toolbar: "text-xs dark:bg-gray-700/50 flex items-center justify-between px-2 py-1 rounded-t sticky top-0 backdrop-blur-md bg-gray-200 ",
1787
+ li: "mb-2 ml-6",
1788
+ ul: "mb-4 list-disc",
1789
+ ol: "mb-4 list-decimal"
1790
+ },
1791
+ footer: {
1792
+ base: "mt-3 flex gap-1.5 text-gray-400",
1793
+ copy: [
1794
+ "p-3 rounded-[10px] [&>svg]:w-4 [&>svg]:h-4 opacity-50 hover:!opacity-100 hover:bg-gray-200 hover:text-gray-500",
1795
+ "dark:hover:bg-gray-800 dark:hover:text-white"
1796
+ ].join(" "),
1797
+ upvote: "p-3 rounded-[10px] [&>svg]:w-4 [&>svg]:h-4 opacity-50 hover:!opacity-100 hover:bg-gray-700/40 hover:text-white",
1798
+ downvote: "p-3 rounded-[10px] [&>svg]:w-4 [&>svg]:h-4 opacity-50 hover:!opacity-100 hover:bg-gray-700/40 hover:text-white",
1799
+ refresh: "p-3 rounded-[10px] [&>svg]:w-4 [&>svg]:h-4 opacity-50 hover:!opacity-100 hover:bg-gray-700/40 hover:text-white"
1800
+ }
1801
+ }
1802
+ },
1803
+ input: {
1804
+ base: "flex mt-4 relative",
1805
+ upload: ["px-5 py-2 text-gray-400 size-10", "dark:gray-500"].join(" "),
1806
+ input: [
1807
+ "w-full border rounded-3xl px-3 py-2 pr-16 text-gray-500 border-gray-200 hover:bg-blue-100 hover:border-blue-500 after:hidden after:!mx-10 bg-white [&>textarea]:w-full [&>textarea]:flex-none",
1808
+ "dark:border-gray-700/50 dark:text-gray-200 dark:bg-gray-950 dark:hover:bg-blue-950/40"
1809
+ ].join(" "),
1810
+ actions: {
1811
+ base: "absolute flex gap-2 items-center right-5 inset-y-1/2 -translate-y-1/2 z-10",
1812
+ send: [
1813
+ "px-3 py-3 hover:bg-primary-hover rounded-full bg-gray-200 hover:bg-gray-300 text-gray-500",
1814
+ "dark:text-white dark:bg-gray-800 hover:dark:bg-gray-700"
1815
+ ].join(" "),
1816
+ stop: "px-2 py-2 bg-red-500 text-white rounded-full hover:bg-red-700 "
1817
+ }
1818
+ }
1819
+ };
1820
+ const useDimensions = () => {
1821
+ const [ref, setRef] = useState(null);
1822
+ const [width, setWidth] = useState(void 0);
1823
+ const observe = useCallback((element) => {
1824
+ if (element) setRef(element);
1825
+ }, []);
1826
+ useEffect(() => {
1827
+ if (!ref) return;
1828
+ const resizeObserver = new ResizeObserver((entries) => {
1829
+ for (let entry of entries) {
1830
+ setWidth(entry.contentRect.width);
1831
+ }
1832
+ });
1833
+ resizeObserver.observe(ref);
1834
+ return () => {
1835
+ resizeObserver.disconnect();
1836
+ };
1837
+ }, [ref]);
1838
+ return { width, observe };
1839
+ };
1840
+ const Chat = ({
1841
+ children,
1842
+ viewType = "console",
1843
+ sessions,
1844
+ onSelectSession,
1845
+ onDeleteSession,
1846
+ onSendMessage,
1847
+ onStopMessage,
1848
+ onFileUpload,
1849
+ isLoading,
1850
+ activeSessionId,
1851
+ theme: customTheme = chatTheme,
1852
+ onNewSession,
1853
+ remarkPlugins = [remarkGfm, remarkYoutube, remarkMath],
1854
+ disabled,
1855
+ style,
1856
+ className
1857
+ }) => {
1858
+ const theme = useComponentTheme("chat", customTheme);
1859
+ const [internalActiveSessionID, setInternalActiveSessionID] = useState(activeSessionId);
1860
+ const { width, observe } = useDimensions();
1861
+ const isCompact = viewType === "companion" || width && width < 767;
1862
+ useEffect(() => {
1863
+ setInternalActiveSessionID(activeSessionId);
1864
+ }, [activeSessionId]);
1865
+ const handleSelectSession = useCallback(
1866
+ (sessionId) => {
1867
+ setInternalActiveSessionID(sessionId);
1868
+ onSelectSession == null ? void 0 : onSelectSession(sessionId);
1869
+ },
1870
+ [onSelectSession]
1871
+ );
1872
+ const handleDeleteSession = useCallback(
1873
+ (sessionId) => {
1874
+ setInternalActiveSessionID(void 0);
1875
+ onDeleteSession == null ? void 0 : onDeleteSession(sessionId);
1876
+ },
1877
+ [onDeleteSession]
1878
+ );
1879
+ const handleCreateNewSession = useCallback(() => {
1880
+ setInternalActiveSessionID(void 0);
1881
+ onNewSession == null ? void 0 : onNewSession();
1882
+ }, [onNewSession]);
1883
+ useHotkeys([
1884
+ {
1885
+ name: "Create new session",
1886
+ category: "Chat",
1887
+ keys: "meta+shift+s",
1888
+ callback: (event) => {
1889
+ event.preventDefault();
1890
+ handleCreateNewSession();
1891
+ }
1892
+ }
1893
+ ]);
1894
+ const activeSession = useMemo(
1895
+ () => sessions.find((session) => session.id === internalActiveSessionID),
1896
+ [sessions, internalActiveSessionID]
1897
+ );
1898
+ const contextValue = useMemo(
1899
+ () => ({
1900
+ sessions,
1901
+ activeSession,
1902
+ remarkPlugins,
1903
+ theme,
1904
+ disabled,
1905
+ isLoading,
1906
+ isCompact,
1907
+ viewType,
1908
+ activeSessionId: internalActiveSessionID,
1909
+ selectSession: handleSelectSession,
1910
+ deleteSession: handleDeleteSession,
1911
+ createSession: handleCreateNewSession,
1912
+ sendMessage: onSendMessage,
1913
+ stopMessage: onStopMessage,
1914
+ fileUpload: onFileUpload
1915
+ }),
1916
+ [
1917
+ isLoading,
1918
+ isCompact,
1919
+ viewType,
1920
+ disabled,
1921
+ theme,
1922
+ remarkPlugins,
1923
+ sessions,
1924
+ activeSession,
1925
+ internalActiveSessionID,
1926
+ handleSelectSession,
1927
+ handleDeleteSession,
1928
+ handleCreateNewSession,
1929
+ onSendMessage,
1930
+ onStopMessage,
1931
+ onFileUpload
1932
+ ]
1933
+ );
1934
+ return /* @__PURE__ */ jsx(ChatContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx(AnimatePresence, { initial: false, children: /* @__PURE__ */ jsx(
1935
+ "div",
1936
+ {
1937
+ ref: observe,
1938
+ className: cn(className, theme.base, {
1939
+ [theme.companion]: isCompact,
1940
+ [theme.console]: !isCompact
1941
+ }),
1942
+ style,
1943
+ children
1944
+ }
1945
+ ) }) });
1946
+ };
1947
+ const SessionsList = ({ children }) => {
1948
+ const { theme, isCompact, activeSessionId } = useContext(ChatContext);
1949
+ const isVisible = isCompact && !activeSessionId;
1950
+ return (!isCompact || isVisible) && /* @__PURE__ */ jsx(
1951
+ motion.div,
1952
+ {
1953
+ initial: { translateX: "-100%" },
1954
+ animate: {
1955
+ translateX: "0%",
1956
+ transition: {
1957
+ type: "tween",
1958
+ ease: "linear",
1959
+ duration: 0.2,
1960
+ when: "beforeChildren"
1961
+ }
1962
+ },
1963
+ exit: { translateX: "-100%" },
1964
+ className: cn(theme.sessions.base, {
1965
+ [theme.sessions.companion]: isCompact,
1966
+ [theme.sessions.console]: !isCompact
1967
+ }),
1968
+ children: /* @__PURE__ */ jsx(List, { children })
1969
+ }
1970
+ );
1971
+ };
1972
+ 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" })));
1973
+ 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" }));
1974
+ const SessionListItem = ({
1975
+ children,
1976
+ session,
1977
+ deletable = true,
1978
+ limit = 100,
1979
+ deleteIcon = /* @__PURE__ */ jsx(SvgTrash, {}),
1980
+ chatIcon = /* @__PURE__ */ jsx(SvgChat, { className: "mr-2" })
1981
+ }) => {
1982
+ const { activeSessionId, selectSession, deleteSession, theme } = useContext(ChatContext);
1983
+ const Comp = children ? Slot : ListItem;
1984
+ return /* @__PURE__ */ jsx(
1985
+ Comp,
1986
+ {
1987
+ dense: true,
1988
+ disableGutters: true,
1989
+ active: session.id === activeSessionId,
1990
+ className: cn(theme.sessions.session.base, {
1991
+ [theme.sessions.session.active]: session.id === activeSessionId
1992
+ }),
1993
+ onClick: () => selectSession == null ? void 0 : selectSession(session.id),
1994
+ start: chatIcon,
1995
+ end: /* @__PURE__ */ jsx(Fragment, { children: deletable && /* @__PURE__ */ jsx(
1996
+ IconButton,
1997
+ {
1998
+ size: "small",
1999
+ variant: "text",
2000
+ onClick: (e) => {
2001
+ e.stopPropagation();
2002
+ deleteSession(session.id);
2003
+ },
2004
+ className: cn(theme.sessions.session.delete),
2005
+ children: deleteIcon
2006
+ }
2007
+ ) }),
2008
+ children: children || /* @__PURE__ */ jsx(Ellipsis, { value: session.title, limit })
2009
+ }
2010
+ );
2011
+ };
2012
+ 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" })));
2013
+ const NewSessionButton = ({
2014
+ children,
2015
+ newSessionText = "New Session"
2016
+ }) => {
2017
+ const { theme, createSession, disabled } = useContext(ChatContext);
2018
+ const Comp = children ? Slot : Button;
2019
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
2020
+ Comp,
2021
+ {
2022
+ fullWidth: true,
2023
+ disableMargins: true,
2024
+ color: "primary",
2025
+ startAdornment: /* @__PURE__ */ jsx(SvgPlus, {}),
2026
+ className: cn(theme.sessions.create),
2027
+ disabled,
2028
+ onClick: createSession,
2029
+ children: children || newSessionText
2030
+ }
2031
+ ) });
2032
+ };
2033
+ const sortOrder = [
2034
+ "Today",
2035
+ "Yesterday",
2036
+ "Last Week",
2037
+ "Last Month",
2038
+ "January",
2039
+ "February",
2040
+ "March",
2041
+ "April",
2042
+ "May",
2043
+ "June",
2044
+ "July",
2045
+ "August",
2046
+ "September",
2047
+ "October",
2048
+ "November",
2049
+ "December",
2050
+ "Last Year"
2051
+ ];
2052
+ function groupSessionsByDate(sessions) {
2053
+ const grouped = {};
2054
+ sessions.forEach((session) => {
2055
+ const createdAt = new Date(session.createdAt);
2056
+ if (isToday(createdAt)) {
2057
+ if (!grouped["Today"]) grouped["Today"] = [];
2058
+ grouped["Today"].push(session);
2059
+ } else if (isYesterday(createdAt)) {
2060
+ if (!grouped["Yesterday"]) grouped["Yesterday"] = [];
2061
+ grouped["Yesterday"].push(session);
2062
+ } else if (isThisWeek(createdAt)) {
2063
+ if (!grouped["Last Week"]) grouped["Last Week"] = [];
2064
+ grouped["Last Week"].push(session);
2065
+ } else if (isThisMonth(createdAt)) {
2066
+ if (!grouped["Last Month"]) grouped["Last Month"] = [];
2067
+ grouped["Last Month"].push(session);
2068
+ } else if (isThisYear(createdAt)) {
2069
+ const monthName = format(createdAt, "MMMM");
2070
+ if (!grouped[monthName]) grouped[monthName] = [];
2071
+ grouped[monthName].push(session);
2072
+ } else {
2073
+ if (!grouped["Last Year"]) grouped["Last Year"] = [];
2074
+ grouped["Last Year"].push(session);
2075
+ }
2076
+ });
2077
+ Object.keys(grouped).forEach((key) => {
2078
+ if (grouped[key].length === 0) {
2079
+ delete grouped[key];
2080
+ }
2081
+ });
2082
+ const sortedGroups = Object.keys(grouped).sort(
2083
+ (a, b) => sortOrder.indexOf(a) - sortOrder.indexOf(b)
2084
+ );
2085
+ return sortedGroups.map((heading) => ({
2086
+ heading,
2087
+ sessions: grouped[heading].sort(
2088
+ (a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime()
2089
+ )
2090
+ }));
2091
+ }
2092
+ const SessionsGroup = ({
2093
+ heading,
2094
+ children
2095
+ }) => {
2096
+ const { theme } = useContext(ChatContext);
2097
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
2098
+ heading && /* @__PURE__ */ jsx(
2099
+ ListItem,
2100
+ {
2101
+ disableGutters: true,
2102
+ disablePadding: true,
2103
+ className: cn(theme.sessions.group),
2104
+ children: heading
2105
+ }
2106
+ ),
2107
+ children
2108
+ ] });
2109
+ };
2110
+ const SessionGroups = ({ children }) => {
2111
+ const { sessions } = useContext(ChatContext);
2112
+ const groups = useMemo(() => groupSessionsByDate(sessions), [sessions]);
2113
+ 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)) })) });
2114
+ };
2115
+ export {
2116
+ ChatInput as C,
2117
+ FileInput as F,
2118
+ MessageSource as M,
2119
+ NewSessionButton as N,
2120
+ SvgFile as S,
2121
+ TableComponent as T,
2122
+ SvgCopy as a,
2123
+ SessionEmpty as b,
2124
+ SessionMessagesHeader as c,
2125
+ SessionMessagePanel as d,
2126
+ SessionMessage as e,
2127
+ MessageActions as f,
2128
+ MessageFile as g,
2129
+ MessageFiles as h,
2130
+ MessageQuestion as i,
2131
+ MessageResponse as j,
2132
+ MessageSources as k,
2133
+ SessionMessages as l,
2134
+ Chat as m,
2135
+ SessionsList as n,
2136
+ SessionListItem as o,
2137
+ SessionGroups as p,
2138
+ SessionsGroup as q,
2139
+ chatTheme as r,
2140
+ Markdown as s,
2141
+ TableHeaderCell as t,
2142
+ TableDataCell as u,
2143
+ CodeHighlighter as v,
2144
+ remarkCve as w,
2145
+ dark as x,
2146
+ light as y,
2147
+ ChatContext as z
2148
+ };
2149
+ //# sourceMappingURL=index-D-JgMn3h.js.map