@mordn/chat-widget 0.1.1 → 0.1.3
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.
- package/README.md +260 -103
- package/dist/api/index.d.mts +2 -1
- package/dist/api/index.d.ts +2 -1
- package/dist/api/index.js +2 -1
- package/dist/api/index.js.map +1 -1
- package/dist/api/index.mjs +2 -1
- package/dist/api/index.mjs.map +1 -1
- package/dist/cli/init.js +430 -0
- package/dist/db/index.d.mts +4 -277
- package/dist/db/index.d.ts +4 -277
- package/dist/db/index.js +2 -1
- package/dist/db/index.js.map +1 -1
- package/dist/db/index.mjs +2 -1
- package/dist/db/index.mjs.map +1 -1
- package/dist/index-uiN6exzS.d.mts +278 -0
- package/dist/index-uiN6exzS.d.ts +278 -0
- package/dist/index.d.mts +64 -5
- package/dist/index.d.ts +64 -5
- package/dist/index.js +311 -236
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +257 -186
- package/dist/index.mjs.map +1 -1
- package/dist/schema/index.d.mts +2 -0
- package/dist/schema/index.d.ts +2 -0
- package/dist/schema/index.js +63 -0
- package/dist/schema/index.js.map +1 -0
- package/dist/schema/index.mjs +35 -0
- package/dist/schema/index.mjs.map +1 -0
- package/dist/styles.css +1 -1
- package/package.json +13 -4
package/dist/index.js
CHANGED
|
@@ -33,6 +33,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
33
33
|
var src_exports = {};
|
|
34
34
|
__export(src_exports, {
|
|
35
35
|
Button: () => Button,
|
|
36
|
+
ChatStorageProvider: () => ChatStorageProvider,
|
|
36
37
|
ChatWidget: () => ChatWidget,
|
|
37
38
|
Dialog: () => Dialog,
|
|
38
39
|
DialogContent: () => DialogContent,
|
|
@@ -40,14 +41,17 @@ __export(src_exports, {
|
|
|
40
41
|
DialogHeader: () => DialogHeader,
|
|
41
42
|
DialogTitle: () => DialogTitle,
|
|
42
43
|
Input: () => Input,
|
|
44
|
+
StarterMessageItem: () => StarterMessageItem,
|
|
45
|
+
StarterMessages: () => StarterMessages,
|
|
43
46
|
default: () => ChatWidget_default,
|
|
44
47
|
fontOptions: () => fontOptions,
|
|
48
|
+
useChatStorageKey: () => useChatStorageKey,
|
|
45
49
|
useChatTheme: () => useChatTheme
|
|
46
50
|
});
|
|
47
51
|
module.exports = __toCommonJS(src_exports);
|
|
48
52
|
|
|
49
53
|
// src/ChatWidget.tsx
|
|
50
|
-
var
|
|
54
|
+
var import_react12 = require("react");
|
|
51
55
|
|
|
52
56
|
// src/ui/button.tsx
|
|
53
57
|
var import_react_slot = require("@radix-ui/react-slot");
|
|
@@ -516,7 +520,7 @@ var PromptInput = ({
|
|
|
516
520
|
"form",
|
|
517
521
|
{
|
|
518
522
|
className: cn(
|
|
519
|
-
"w-full divide-y overflow-hidden rounded-xl border bg-background focus-within:border-ring transition-colors",
|
|
523
|
+
"w-full divide-y divide-[hsl(var(--chat-text)/0.1)] focus-within:divide-ring overflow-hidden rounded-xl border border-[hsl(var(--chat-text)/0.1)] bg-background focus-within:border-ring transition-colors",
|
|
520
524
|
"[&:focus-within]:shadow-none [&:focus]:shadow-none shadow-none",
|
|
521
525
|
className
|
|
522
526
|
),
|
|
@@ -579,7 +583,7 @@ var PromptInputTextarea = ({
|
|
|
579
583
|
"w-full resize-none rounded-none border-none p-3 shadow-none outline-none ring-0",
|
|
580
584
|
"field-sizing-content",
|
|
581
585
|
"max-h-48 min-h-16",
|
|
582
|
-
"focus-visible:ring-0 focus-visible:
|
|
586
|
+
"focus-visible:ring-0 focus-visible:shadow-none focus:ring-0 focus:shadow-none",
|
|
583
587
|
className
|
|
584
588
|
),
|
|
585
589
|
name: "message",
|
|
@@ -724,10 +728,10 @@ function MessageAttachments({ attachments, className }) {
|
|
|
724
728
|
}
|
|
725
729
|
|
|
726
730
|
// src/components/interface.tsx
|
|
727
|
-
var import_react8 = require("react");
|
|
728
|
-
var import_lucide_react10 = require("lucide-react");
|
|
729
731
|
var import_react9 = require("react");
|
|
730
|
-
var
|
|
732
|
+
var import_lucide_react10 = require("lucide-react");
|
|
733
|
+
var import_react10 = require("react");
|
|
734
|
+
var import_react11 = require("@ai-sdk/react");
|
|
731
735
|
var import_ai = require("ai");
|
|
732
736
|
|
|
733
737
|
// src/components/response.tsx
|
|
@@ -1190,7 +1194,7 @@ var CodeBlock = ({
|
|
|
1190
1194
|
"div",
|
|
1191
1195
|
{
|
|
1192
1196
|
className: cn(
|
|
1193
|
-
"relative w-full overflow-hidden rounded-
|
|
1197
|
+
"relative w-full overflow-hidden rounded-lg bg-[hsl(var(--chat-text)/0.03)] border border-[hsl(var(--chat-text)/0.1)]",
|
|
1194
1198
|
className
|
|
1195
1199
|
),
|
|
1196
1200
|
...props,
|
|
@@ -1206,12 +1210,13 @@ var CodeBlock = ({
|
|
|
1206
1210
|
margin: 0,
|
|
1207
1211
|
padding: "1rem",
|
|
1208
1212
|
fontSize: "0.875rem",
|
|
1209
|
-
background: "
|
|
1210
|
-
color: "hsl(var(--
|
|
1213
|
+
background: "transparent",
|
|
1214
|
+
color: "hsl(var(--chat-text))",
|
|
1215
|
+
border: "none"
|
|
1211
1216
|
},
|
|
1212
1217
|
language,
|
|
1213
1218
|
lineNumberStyle: {
|
|
1214
|
-
color: "hsl(var(--
|
|
1219
|
+
color: "hsl(var(--chat-text) / 0.4)",
|
|
1215
1220
|
paddingRight: "1rem",
|
|
1216
1221
|
minWidth: "2.5rem"
|
|
1217
1222
|
},
|
|
@@ -1231,12 +1236,13 @@ var CodeBlock = ({
|
|
|
1231
1236
|
margin: 0,
|
|
1232
1237
|
padding: "1rem",
|
|
1233
1238
|
fontSize: "0.875rem",
|
|
1234
|
-
background: "
|
|
1235
|
-
color: "hsl(var(--
|
|
1239
|
+
background: "transparent",
|
|
1240
|
+
color: "hsl(var(--chat-text))",
|
|
1241
|
+
border: "none"
|
|
1236
1242
|
},
|
|
1237
1243
|
language,
|
|
1238
1244
|
lineNumberStyle: {
|
|
1239
|
-
color: "hsl(var(--
|
|
1245
|
+
color: "hsl(var(--chat-text) / 0.4)",
|
|
1240
1246
|
paddingRight: "1rem",
|
|
1241
1247
|
minWidth: "2.5rem"
|
|
1242
1248
|
},
|
|
@@ -1255,7 +1261,7 @@ var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
|
1255
1261
|
var Tool = ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1256
1262
|
Collapsible,
|
|
1257
1263
|
{
|
|
1258
|
-
className: cn("not-prose w-full rounded-md border", className),
|
|
1264
|
+
className: cn("not-prose w-full rounded-md border border-[hsl(var(--chat-text)/0.1)]", className),
|
|
1259
1265
|
...props
|
|
1260
1266
|
}
|
|
1261
1267
|
);
|
|
@@ -1348,32 +1354,107 @@ var ToolOutput = ({
|
|
|
1348
1354
|
] });
|
|
1349
1355
|
};
|
|
1350
1356
|
|
|
1351
|
-
// src/components/
|
|
1357
|
+
// src/components/suggestion2.tsx
|
|
1352
1358
|
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
1359
|
+
function StarterMessages({
|
|
1360
|
+
className,
|
|
1361
|
+
prompts,
|
|
1362
|
+
onPromptSelect,
|
|
1363
|
+
...props
|
|
1364
|
+
}) {
|
|
1365
|
+
if (prompts.length === 0) return null;
|
|
1366
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
1367
|
+
"div",
|
|
1368
|
+
{
|
|
1369
|
+
className: cn(
|
|
1370
|
+
"mb-3",
|
|
1371
|
+
className
|
|
1372
|
+
),
|
|
1373
|
+
...props,
|
|
1374
|
+
children: prompts.map((prompt, index) => /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { children: [
|
|
1375
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
1376
|
+
StarterMessageItem,
|
|
1377
|
+
{
|
|
1378
|
+
prompt,
|
|
1379
|
+
onClick: () => onPromptSelect(prompt)
|
|
1380
|
+
}
|
|
1381
|
+
),
|
|
1382
|
+
index < prompts.length - 1 && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "h-px bg-[hsl(var(--chat-text)/0.08)] mx-3" })
|
|
1383
|
+
] }, index))
|
|
1384
|
+
}
|
|
1385
|
+
);
|
|
1386
|
+
}
|
|
1387
|
+
function StarterMessageItem({
|
|
1388
|
+
className,
|
|
1389
|
+
prompt,
|
|
1390
|
+
onClick,
|
|
1391
|
+
...props
|
|
1392
|
+
}) {
|
|
1393
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
|
|
1394
|
+
"button",
|
|
1395
|
+
{
|
|
1396
|
+
type: "button",
|
|
1397
|
+
onClick,
|
|
1398
|
+
className: cn(
|
|
1399
|
+
"w-full text-left px-3 py-2.5 rounded-lg",
|
|
1400
|
+
"bg-transparent",
|
|
1401
|
+
"hover:bg-[hsl(var(--chat-text)/0.03)]",
|
|
1402
|
+
"transition-colors duration-150 ease-out",
|
|
1403
|
+
"cursor-pointer",
|
|
1404
|
+
className
|
|
1405
|
+
),
|
|
1406
|
+
...props,
|
|
1407
|
+
children: [
|
|
1408
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "text-[13px] text-[hsl(var(--chat-text)/0.7)]", children: prompt.title }),
|
|
1409
|
+
prompt.subtitle && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "block text-[11px] text-[hsl(var(--chat-text)/0.4)] mt-0.5", children: prompt.subtitle })
|
|
1410
|
+
]
|
|
1411
|
+
}
|
|
1412
|
+
);
|
|
1413
|
+
}
|
|
1414
|
+
|
|
1415
|
+
// src/contexts/chat-storage-context.tsx
|
|
1416
|
+
var import_react8 = require("react");
|
|
1417
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
1418
|
+
var ChatStorageContext = (0, import_react8.createContext)({
|
|
1419
|
+
storageKeyPrefix: ""
|
|
1420
|
+
});
|
|
1421
|
+
function ChatStorageProvider({
|
|
1422
|
+
children,
|
|
1423
|
+
userId
|
|
1424
|
+
}) {
|
|
1425
|
+
const storageKeyPrefix = userId || "";
|
|
1426
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ChatStorageContext.Provider, { value: { storageKeyPrefix }, children });
|
|
1427
|
+
}
|
|
1428
|
+
function useChatStorageKey() {
|
|
1429
|
+
return (0, import_react8.useContext)(ChatStorageContext);
|
|
1430
|
+
}
|
|
1431
|
+
|
|
1432
|
+
// src/components/interface.tsx
|
|
1433
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
1353
1434
|
function ChatInterface({ id, initialMessages, config, onClose } = {}) {
|
|
1435
|
+
const { storageKeyPrefix } = useChatStorageKey();
|
|
1436
|
+
const storageKey = (key) => storageKeyPrefix ? `chat-${storageKeyPrefix}-${key}` : `chat-${key}`;
|
|
1354
1437
|
const themeMode = config?.theme?.mode || "light";
|
|
1355
|
-
const [input, setInput] = (0,
|
|
1356
|
-
const [showHistory, setShowHistory] = (0,
|
|
1357
|
-
const [conversations, setConversations] = (0,
|
|
1358
|
-
const [loadingHistory, setLoadingHistory] = (0,
|
|
1359
|
-
const [historyLoaded, setHistoryLoaded] = (0,
|
|
1360
|
-
const [searchQuery, setSearchQuery] = (0,
|
|
1361
|
-
const [uploadError, setUploadError] = (0,
|
|
1362
|
-
(0,
|
|
1438
|
+
const [input, setInput] = (0, import_react9.useState)("");
|
|
1439
|
+
const [showHistory, setShowHistory] = (0, import_react9.useState)(false);
|
|
1440
|
+
const [conversations, setConversations] = (0, import_react9.useState)([]);
|
|
1441
|
+
const [loadingHistory, setLoadingHistory] = (0, import_react9.useState)(false);
|
|
1442
|
+
const [historyLoaded, setHistoryLoaded] = (0, import_react9.useState)(false);
|
|
1443
|
+
const [searchQuery, setSearchQuery] = (0, import_react9.useState)("");
|
|
1444
|
+
const [uploadError, setUploadError] = (0, import_react9.useState)(null);
|
|
1445
|
+
(0, import_react9.useEffect)(() => {
|
|
1363
1446
|
if (uploadError) {
|
|
1364
1447
|
const timeoutId = setTimeout(() => setUploadError(null), 5e3);
|
|
1365
1448
|
return () => clearTimeout(timeoutId);
|
|
1366
1449
|
}
|
|
1367
1450
|
}, [uploadError]);
|
|
1368
|
-
const [tabs, setTabs] = (0,
|
|
1369
|
-
const [activeTabId, setActiveTabId] = (0,
|
|
1370
|
-
const [initialTabCreated, setInitialTabCreated] = (0,
|
|
1371
|
-
const [isInitializing, setIsInitializing] = (0,
|
|
1372
|
-
const
|
|
1373
|
-
const
|
|
1374
|
-
const
|
|
1375
|
-
const hasInitialized = (0, import_react8.useRef)(false);
|
|
1376
|
-
const { messages, sendMessage, status, setMessages } = (0, import_react10.useChat)({
|
|
1451
|
+
const [tabs, setTabs] = (0, import_react9.useState)([]);
|
|
1452
|
+
const [activeTabId, setActiveTabId] = (0, import_react9.useState)("");
|
|
1453
|
+
const [initialTabCreated, setInitialTabCreated] = (0, import_react9.useState)(false);
|
|
1454
|
+
const [isInitializing, setIsInitializing] = (0, import_react9.useState)(true);
|
|
1455
|
+
const lastSyncedTabId = (0, import_react9.useRef)("");
|
|
1456
|
+
const hasInitialized = (0, import_react9.useRef)(false);
|
|
1457
|
+
const { messages, sendMessage, status, setMessages } = (0, import_react11.useChat)({
|
|
1377
1458
|
id: activeTabId || "temp-id",
|
|
1378
1459
|
transport: new import_ai.DefaultChatTransport({
|
|
1379
1460
|
api: "/api/chat",
|
|
@@ -1462,12 +1543,12 @@ function ChatInterface({ id, initialMessages, config, onClose } = {}) {
|
|
|
1462
1543
|
};
|
|
1463
1544
|
const AttachButton = () => {
|
|
1464
1545
|
const attachments = usePromptInputAttachments();
|
|
1465
|
-
return /* @__PURE__ */ (0,
|
|
1546
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
1466
1547
|
PromptInputButton,
|
|
1467
1548
|
{
|
|
1468
1549
|
variant: "ghost",
|
|
1469
1550
|
onClick: () => attachments.openFileDialog(),
|
|
1470
|
-
children: /* @__PURE__ */ (0,
|
|
1551
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_lucide_react10.PlusIcon, { className: "size-4" })
|
|
1471
1552
|
}
|
|
1472
1553
|
);
|
|
1473
1554
|
};
|
|
@@ -1506,7 +1587,7 @@ function ChatInterface({ id, initialMessages, config, onClose } = {}) {
|
|
|
1506
1587
|
}
|
|
1507
1588
|
return newTabId;
|
|
1508
1589
|
};
|
|
1509
|
-
const createNewTab = (0,
|
|
1590
|
+
const createNewTab = (0, import_react9.useCallback)(() => {
|
|
1510
1591
|
if (!initialTabCreated) {
|
|
1511
1592
|
console.warn("Cannot create new tab while initializing");
|
|
1512
1593
|
return;
|
|
@@ -1533,10 +1614,10 @@ function ChatInterface({ id, initialMessages, config, onClose } = {}) {
|
|
|
1533
1614
|
setMessages([]);
|
|
1534
1615
|
setInput("");
|
|
1535
1616
|
}, [initialTabCreated]);
|
|
1536
|
-
const startNewConversation = (0,
|
|
1617
|
+
const startNewConversation = (0, import_react9.useCallback)(() => {
|
|
1537
1618
|
createNewTab();
|
|
1538
1619
|
}, [createNewTab]);
|
|
1539
|
-
(0,
|
|
1620
|
+
(0, import_react9.useEffect)(() => {
|
|
1540
1621
|
return () => {
|
|
1541
1622
|
};
|
|
1542
1623
|
}, []);
|
|
@@ -1566,10 +1647,10 @@ function ChatInterface({ id, initialMessages, config, onClose } = {}) {
|
|
|
1566
1647
|
setTabs(filteredTabs);
|
|
1567
1648
|
}
|
|
1568
1649
|
if (filteredTabs.length > 0) {
|
|
1569
|
-
localStorage.setItem("
|
|
1650
|
+
localStorage.setItem(storageKey("tabs"), JSON.stringify(filteredTabs));
|
|
1570
1651
|
if (tabId === activeTabId) {
|
|
1571
1652
|
const newActiveTab = filteredTabs[0];
|
|
1572
|
-
localStorage.setItem("active-tab-id", newActiveTab.id);
|
|
1653
|
+
localStorage.setItem(storageKey("active-tab-id"), newActiveTab.id);
|
|
1573
1654
|
}
|
|
1574
1655
|
}
|
|
1575
1656
|
};
|
|
@@ -1596,31 +1677,31 @@ function ChatInterface({ id, initialMessages, config, onClose } = {}) {
|
|
|
1596
1677
|
setLoadingHistory(false);
|
|
1597
1678
|
}
|
|
1598
1679
|
};
|
|
1599
|
-
(0,
|
|
1680
|
+
(0, import_react9.useEffect)(() => {
|
|
1600
1681
|
if (showHistory && !historyLoaded && config?.userId) {
|
|
1601
1682
|
fetchConversations();
|
|
1602
1683
|
}
|
|
1603
1684
|
}, [showHistory, historyLoaded, config?.userId]);
|
|
1604
|
-
(0,
|
|
1685
|
+
(0, import_react9.useEffect)(() => {
|
|
1605
1686
|
if (!historyLoaded && config?.userId) {
|
|
1606
1687
|
fetchConversations();
|
|
1607
1688
|
}
|
|
1608
1689
|
}, [historyLoaded, config?.userId]);
|
|
1609
|
-
(0,
|
|
1690
|
+
(0, import_react9.useEffect)(() => {
|
|
1610
1691
|
if (tabs.length > 0) {
|
|
1611
1692
|
const timeoutId = setTimeout(() => {
|
|
1612
|
-
localStorage.setItem("
|
|
1613
|
-
localStorage.setItem("active-tab-id", activeTabId);
|
|
1693
|
+
localStorage.setItem(storageKey("tabs"), JSON.stringify(tabs));
|
|
1694
|
+
localStorage.setItem(storageKey("active-tab-id"), activeTabId);
|
|
1614
1695
|
}, 500);
|
|
1615
1696
|
return () => clearTimeout(timeoutId);
|
|
1616
1697
|
}
|
|
1617
|
-
}, [tabs, activeTabId]);
|
|
1618
|
-
(0,
|
|
1698
|
+
}, [tabs, activeTabId, storageKey]);
|
|
1699
|
+
(0, import_react9.useEffect)(() => {
|
|
1619
1700
|
if (hasInitialized.current) return;
|
|
1620
1701
|
const loadInitialTabs = () => {
|
|
1621
1702
|
try {
|
|
1622
|
-
const savedTabs = localStorage.getItem("
|
|
1623
|
-
const savedActiveTabId = localStorage.getItem("active-tab-id");
|
|
1703
|
+
const savedTabs = localStorage.getItem(storageKey("tabs"));
|
|
1704
|
+
const savedActiveTabId = localStorage.getItem(storageKey("active-tab-id"));
|
|
1624
1705
|
if (savedTabs && savedTabs !== "[]") {
|
|
1625
1706
|
const parsedTabs = JSON.parse(savedTabs);
|
|
1626
1707
|
setTabs(parsedTabs);
|
|
@@ -1645,8 +1726,8 @@ function ChatInterface({ id, initialMessages, config, onClose } = {}) {
|
|
|
1645
1726
|
loadInitialTabs();
|
|
1646
1727
|
hasInitialized.current = true;
|
|
1647
1728
|
}, []);
|
|
1648
|
-
const hasLoadedInitialMessages = (0,
|
|
1649
|
-
(0,
|
|
1729
|
+
const hasLoadedInitialMessages = (0, import_react9.useRef)(false);
|
|
1730
|
+
(0, import_react9.useEffect)(() => {
|
|
1650
1731
|
if (hasLoadedInitialMessages.current) return;
|
|
1651
1732
|
if (!config?.userId) return;
|
|
1652
1733
|
if (!activeTabId) return;
|
|
@@ -1654,14 +1735,14 @@ function ChatInterface({ id, initialMessages, config, onClose } = {}) {
|
|
|
1654
1735
|
loadConversation(activeTabId);
|
|
1655
1736
|
hasLoadedInitialMessages.current = true;
|
|
1656
1737
|
}, [config?.userId, activeTabId, isInitializing]);
|
|
1657
|
-
(0,
|
|
1738
|
+
(0, import_react9.useEffect)(() => {
|
|
1658
1739
|
if (isInitializing) return;
|
|
1659
1740
|
if (activeTabId && tabs.length > 0 && activeTabId !== lastSyncedTabId.current) {
|
|
1660
1741
|
lastSyncedTabId.current = activeTabId;
|
|
1661
1742
|
setInput("");
|
|
1662
1743
|
}
|
|
1663
1744
|
}, [activeTabId, isInitializing, tabs.length]);
|
|
1664
|
-
const groupedConversations = (0,
|
|
1745
|
+
const groupedConversations = (0, import_react9.useMemo)(() => {
|
|
1665
1746
|
const filtered = conversations.filter(
|
|
1666
1747
|
(conv) => searchQuery === "" || conv.title.toLowerCase().includes(searchQuery.toLowerCase())
|
|
1667
1748
|
);
|
|
@@ -1722,10 +1803,10 @@ function ChatInterface({ id, initialMessages, config, onClose } = {}) {
|
|
|
1722
1803
|
const renderMessages = () => messages.map((message, index) => {
|
|
1723
1804
|
const sourceParts = message.parts?.filter((part) => part.type === "source-url") || [];
|
|
1724
1805
|
const fileParts = message.parts?.filter((part) => part.type === "file") || [];
|
|
1725
|
-
return /* @__PURE__ */ (0,
|
|
1726
|
-
message.role === "assistant" && sourceParts.length > 0 && /* @__PURE__ */ (0,
|
|
1727
|
-
/* @__PURE__ */ (0,
|
|
1728
|
-
sourceParts.map((part, i) => /* @__PURE__ */ (0,
|
|
1806
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: index > 0 ? "mt-6" : "", children: [
|
|
1807
|
+
message.role === "assistant" && sourceParts.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(Sources, { children: [
|
|
1808
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(SourcesTrigger, { count: sourceParts.length }),
|
|
1809
|
+
sourceParts.map((part, i) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(SourcesContent, { children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
1729
1810
|
Source,
|
|
1730
1811
|
{
|
|
1731
1812
|
href: part.url,
|
|
@@ -1734,10 +1815,10 @@ function ChatInterface({ id, initialMessages, config, onClose } = {}) {
|
|
|
1734
1815
|
`${message.id}-${i}`
|
|
1735
1816
|
) }, `${message.id}-${i}`))
|
|
1736
1817
|
] }),
|
|
1737
|
-
fileParts.length > 0 && /* @__PURE__ */ (0,
|
|
1818
|
+
fileParts.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: cn(
|
|
1738
1819
|
"flex mb-1",
|
|
1739
1820
|
message.role === "user" ? "justify-end" : "justify-start"
|
|
1740
|
-
), children: /* @__PURE__ */ (0,
|
|
1821
|
+
), children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
1741
1822
|
MessageAttachments,
|
|
1742
1823
|
{
|
|
1743
1824
|
attachments: fileParts.map((part) => ({
|
|
@@ -1748,14 +1829,14 @@ function ChatInterface({ id, initialMessages, config, onClose } = {}) {
|
|
|
1748
1829
|
}))
|
|
1749
1830
|
}
|
|
1750
1831
|
) }),
|
|
1751
|
-
message.parts ? /* @__PURE__ */ (0,
|
|
1832
|
+
message.parts ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "space-y-2", children: message.parts.map((part, i) => {
|
|
1752
1833
|
switch (part.type) {
|
|
1753
1834
|
case "text":
|
|
1754
1835
|
const isTextStreaming = status === "streaming" && i === message.parts.length - 1 && message.id === messages.at(-1)?.id;
|
|
1755
|
-
return /* @__PURE__ */ (0,
|
|
1836
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_react10.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Message, { from: message.role, children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(MessageContent, { children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Response, { isStreaming: isTextStreaming, children: part.text }) }) }) }, `${message.id}-${i}`);
|
|
1756
1837
|
case "reasoning":
|
|
1757
1838
|
const isCurrentlyStreaming = status === "streaming" && i === message.parts.length - 1 && message.id === messages.at(-1)?.id;
|
|
1758
|
-
return /* @__PURE__ */ (0,
|
|
1839
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
|
1759
1840
|
Reasoning,
|
|
1760
1841
|
{
|
|
1761
1842
|
className: "w-full",
|
|
@@ -1763,8 +1844,8 @@ function ChatInterface({ id, initialMessages, config, onClose } = {}) {
|
|
|
1763
1844
|
defaultOpen: false,
|
|
1764
1845
|
open: isCurrentlyStreaming ? true : void 0,
|
|
1765
1846
|
children: [
|
|
1766
|
-
/* @__PURE__ */ (0,
|
|
1767
|
-
/* @__PURE__ */ (0,
|
|
1847
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ReasoningTrigger, {}),
|
|
1848
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ReasoningContent, { children: part.text })
|
|
1768
1849
|
]
|
|
1769
1850
|
},
|
|
1770
1851
|
`${message.id}-${i}`
|
|
@@ -1772,11 +1853,11 @@ function ChatInterface({ id, initialMessages, config, onClose } = {}) {
|
|
|
1772
1853
|
default:
|
|
1773
1854
|
if (part.type.startsWith("tool-") || part.type === "dynamic-tool") {
|
|
1774
1855
|
const toolPart = part;
|
|
1775
|
-
return /* @__PURE__ */ (0,
|
|
1776
|
-
/* @__PURE__ */ (0,
|
|
1777
|
-
/* @__PURE__ */ (0,
|
|
1778
|
-
/* @__PURE__ */ (0,
|
|
1779
|
-
/* @__PURE__ */ (0,
|
|
1856
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(Tool, { children: [
|
|
1857
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ToolHeader, { type: part.type, state: toolPart.state }),
|
|
1858
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(ToolContent, { children: [
|
|
1859
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ToolInput, { input: toolPart.input }),
|
|
1860
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ToolOutput, { output: toolPart.output, errorText: toolPart.errorText })
|
|
1780
1861
|
] })
|
|
1781
1862
|
] }, `${message.id}-${i}`);
|
|
1782
1863
|
}
|
|
@@ -1784,7 +1865,7 @@ function ChatInterface({ id, initialMessages, config, onClose } = {}) {
|
|
|
1784
1865
|
}
|
|
1785
1866
|
}) }) : (
|
|
1786
1867
|
/* Handle standard AI SDK messages with content or text property */
|
|
1787
|
-
/* @__PURE__ */ (0,
|
|
1868
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_react10.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Message, { from: message.role, children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(MessageContent, { children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Response, { children: message.content || message.text }) }) }) }, `${message.id}-content`)
|
|
1788
1869
|
)
|
|
1789
1870
|
] }, message.id);
|
|
1790
1871
|
});
|
|
@@ -1816,8 +1897,8 @@ function ChatInterface({ id, initialMessages, config, onClose } = {}) {
|
|
|
1816
1897
|
console.error("Error loading conversation:", error);
|
|
1817
1898
|
}
|
|
1818
1899
|
};
|
|
1819
|
-
const dropdownRef = (0,
|
|
1820
|
-
(0,
|
|
1900
|
+
const dropdownRef = (0, import_react9.useRef)(null);
|
|
1901
|
+
(0, import_react9.useEffect)(() => {
|
|
1821
1902
|
const handleClickOutside = (event) => {
|
|
1822
1903
|
if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
|
|
1823
1904
|
setShowHistory(false);
|
|
@@ -1830,25 +1911,7 @@ function ChatInterface({ id, initialMessages, config, onClose } = {}) {
|
|
|
1830
1911
|
document.removeEventListener("mousedown", handleClickOutside);
|
|
1831
1912
|
};
|
|
1832
1913
|
}, [showHistory]);
|
|
1833
|
-
(0,
|
|
1834
|
-
if (!isResizing) return;
|
|
1835
|
-
const handleMouseMove = (e) => {
|
|
1836
|
-
const newWidth = window.innerWidth - e.clientX;
|
|
1837
|
-
const minWidth = 300;
|
|
1838
|
-
const maxWidth = window.innerWidth * 0.8;
|
|
1839
|
-
setComponentWidth(Math.max(minWidth, Math.min(maxWidth, newWidth)));
|
|
1840
|
-
};
|
|
1841
|
-
const handleMouseUp = () => {
|
|
1842
|
-
setIsResizing(false);
|
|
1843
|
-
};
|
|
1844
|
-
document.addEventListener("mousemove", handleMouseMove);
|
|
1845
|
-
document.addEventListener("mouseup", handleMouseUp);
|
|
1846
|
-
return () => {
|
|
1847
|
-
document.removeEventListener("mousemove", handleMouseMove);
|
|
1848
|
-
document.removeEventListener("mouseup", handleMouseUp);
|
|
1849
|
-
};
|
|
1850
|
-
}, [isResizing]);
|
|
1851
|
-
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: cn("w-full h-full flex flex-col bg-white dark:bg-gray-900 overflow-hidden ring-1 ring-black/[0.02] dark:ring-white/[0.03]", themeMode === "dark" && "dark"), children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
|
|
1914
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: cn("w-full h-full flex flex-col bg-white dark:bg-gray-900 overflow-hidden ring-1 ring-black/[0.02] dark:ring-white/[0.03]", themeMode === "dark" && "dark"), children: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
|
1852
1915
|
"div",
|
|
1853
1916
|
{
|
|
1854
1917
|
className: cn(
|
|
@@ -1856,11 +1919,11 @@ function ChatInterface({ id, initialMessages, config, onClose } = {}) {
|
|
|
1856
1919
|
themeMode === "dark" && "dark"
|
|
1857
1920
|
),
|
|
1858
1921
|
children: [
|
|
1859
|
-
/* @__PURE__ */ (0,
|
|
1922
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex items-center gap-2 px-3 py-2 border-b backdrop-blur-sm relative z-20", style: {
|
|
1860
1923
|
borderColor: themeMode === "dark" ? "rgba(255,255,255,0.08)" : "rgba(0,0,0,0.08)",
|
|
1861
1924
|
backgroundColor: themeMode === "dark" ? "rgba(37,37,37,0.8)" : "rgba(255,255,255,0.8)"
|
|
1862
1925
|
}, children: [
|
|
1863
|
-
/* @__PURE__ */ (0,
|
|
1926
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "flex items-center gap-1 flex-1 min-w-0 overflow-x-auto scrollbar-hide py-0.5 scroll-smooth", children: tabs.map((tab, index) => /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
|
1864
1927
|
"div",
|
|
1865
1928
|
{
|
|
1866
1929
|
className: "relative flex items-center gap-1.5 px-3 py-1.5 rounded-lg cursor-pointer transition-all duration-150 group flex-shrink-0 min-w-0",
|
|
@@ -1883,8 +1946,8 @@ function ChatInterface({ id, initialMessages, config, onClose } = {}) {
|
|
|
1883
1946
|
switchToTab(tab.id);
|
|
1884
1947
|
},
|
|
1885
1948
|
children: [
|
|
1886
|
-
/* @__PURE__ */ (0,
|
|
1887
|
-
tabs.length > 1 && /* @__PURE__ */ (0,
|
|
1949
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "truncate max-w-28 text-[13px] font-medium transition-colors", children: tab.title }),
|
|
1950
|
+
tabs.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
1888
1951
|
"button",
|
|
1889
1952
|
{
|
|
1890
1953
|
onClick: (e) => {
|
|
@@ -1903,15 +1966,15 @@ function ChatInterface({ id, initialMessages, config, onClose } = {}) {
|
|
|
1903
1966
|
e.currentTarget.style.opacity = tab.isActive ? "0.6" : "0";
|
|
1904
1967
|
e.currentTarget.style.backgroundColor = "transparent";
|
|
1905
1968
|
},
|
|
1906
|
-
children: /* @__PURE__ */ (0,
|
|
1969
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_lucide_react10.XIcon, { className: "h-3 w-3", strokeWidth: 2.5 })
|
|
1907
1970
|
}
|
|
1908
1971
|
)
|
|
1909
1972
|
]
|
|
1910
1973
|
},
|
|
1911
1974
|
tab.id
|
|
1912
1975
|
)) }),
|
|
1913
|
-
/* @__PURE__ */ (0,
|
|
1914
|
-
/* @__PURE__ */ (0,
|
|
1976
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex items-center gap-0.5 flex-shrink-0", children: [
|
|
1977
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
1915
1978
|
"button",
|
|
1916
1979
|
{
|
|
1917
1980
|
onClick: createNewTab,
|
|
@@ -1928,11 +1991,11 @@ function ChatInterface({ id, initialMessages, config, onClose } = {}) {
|
|
|
1928
1991
|
e.currentTarget.style.backgroundColor = "transparent";
|
|
1929
1992
|
},
|
|
1930
1993
|
title: "New Chat",
|
|
1931
|
-
children: /* @__PURE__ */ (0,
|
|
1994
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_lucide_react10.PlusIcon, { className: "h-4 w-4", strokeWidth: 2 })
|
|
1932
1995
|
}
|
|
1933
1996
|
),
|
|
1934
|
-
/* @__PURE__ */ (0,
|
|
1935
|
-
/* @__PURE__ */ (0,
|
|
1997
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "relative", ref: dropdownRef, children: [
|
|
1998
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
1936
1999
|
"button",
|
|
1937
2000
|
{
|
|
1938
2001
|
onClick: () => setShowHistory(!showHistory),
|
|
@@ -1954,21 +2017,21 @@ function ChatInterface({ id, initialMessages, config, onClose } = {}) {
|
|
|
1954
2017
|
}
|
|
1955
2018
|
},
|
|
1956
2019
|
title: "Chat History",
|
|
1957
|
-
children: /* @__PURE__ */ (0,
|
|
2020
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_lucide_react10.HistoryIcon, { className: "h-4 w-4", strokeWidth: 2 })
|
|
1958
2021
|
}
|
|
1959
2022
|
),
|
|
1960
|
-
showHistory && /* @__PURE__ */ (0,
|
|
2023
|
+
showHistory && /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "absolute right-0 top-full mt-1.5 w-72 rounded-xl shadow-[0_4px_24px_rgba(0,0,0,0.08)] dark:shadow-[0_4px_24px_rgba(0,0,0,0.3)] z-50 animate-in fade-in slide-in-from-top-1 duration-150 overflow-hidden", style: {
|
|
1961
2024
|
backgroundColor: themeMode === "dark" ? "#252525" : "#ffffff",
|
|
1962
2025
|
border: `1px solid ${themeMode === "dark" ? "rgba(255,255,255,0.1)" : "rgba(0,0,0,0.1)"}`
|
|
1963
2026
|
}, children: [
|
|
1964
|
-
/* @__PURE__ */ (0,
|
|
2027
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "p-2.5 border-b", style: {
|
|
1965
2028
|
borderColor: themeMode === "dark" ? "rgba(255,255,255,0.08)" : "rgba(0,0,0,0.08)",
|
|
1966
2029
|
backgroundColor: themeMode === "dark" ? "rgba(0,0,0,0.2)" : "rgba(0,0,0,0.02)"
|
|
1967
|
-
}, children: /* @__PURE__ */ (0,
|
|
1968
|
-
/* @__PURE__ */ (0,
|
|
2030
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "relative", children: [
|
|
2031
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_lucide_react10.SearchIcon, { className: "absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5", style: {
|
|
1969
2032
|
color: themeMode === "dark" ? "#666666" : "#999999"
|
|
1970
2033
|
}, strokeWidth: 2 }),
|
|
1971
|
-
/* @__PURE__ */ (0,
|
|
2034
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
1972
2035
|
"input",
|
|
1973
2036
|
{
|
|
1974
2037
|
type: "text",
|
|
@@ -1984,25 +2047,25 @@ function ChatInterface({ id, initialMessages, config, onClose } = {}) {
|
|
|
1984
2047
|
}
|
|
1985
2048
|
)
|
|
1986
2049
|
] }) }),
|
|
1987
|
-
/* @__PURE__ */ (0,
|
|
1988
|
-
/* @__PURE__ */ (0,
|
|
2050
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "max-h-[300px] overflow-y-auto ai-assistant-scrollbar", children: loadingHistory ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "flex items-center justify-center py-12", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "text-[13px]", style: { color: themeMode === "dark" ? "#999999" : "#737373" }, children: "Loading..." }) }) : conversations.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex flex-col items-center justify-center py-12 px-4 text-center", children: [
|
|
2051
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "w-12 h-12 rounded-full flex items-center justify-center mb-3", style: {
|
|
1989
2052
|
backgroundColor: themeMode === "dark" ? "#333333" : "#f5f5f5"
|
|
1990
|
-
}, children: /* @__PURE__ */ (0,
|
|
1991
|
-
/* @__PURE__ */ (0,
|
|
1992
|
-
/* @__PURE__ */ (0,
|
|
1993
|
-
] }) : groupedConversations.length === 0 ? /* @__PURE__ */ (0,
|
|
1994
|
-
/* @__PURE__ */ (0,
|
|
2053
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_lucide_react10.MessageSquareIcon, { className: "h-5 w-5", style: { color: themeMode === "dark" ? "#666666" : "#a3a3a3" }, strokeWidth: 2 }) }),
|
|
2054
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { className: "text-[13px] font-medium mb-0.5", style: { color: themeMode === "dark" ? "#e5e5e5" : "#171717" }, children: "No Conversations" }),
|
|
2055
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { className: "text-[12px]", style: { color: themeMode === "dark" ? "#999999" : "#737373" }, children: "Start a new chat to begin" })
|
|
2056
|
+
] }) : groupedConversations.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex flex-col items-center justify-center py-12 px-4 text-center", children: [
|
|
2057
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "w-12 h-12 rounded-full flex items-center justify-center mb-3", style: {
|
|
1995
2058
|
backgroundColor: themeMode === "dark" ? "#333333" : "#f5f5f5"
|
|
1996
|
-
}, children: /* @__PURE__ */ (0,
|
|
1997
|
-
/* @__PURE__ */ (0,
|
|
1998
|
-
/* @__PURE__ */ (0,
|
|
1999
|
-
] }) : /* @__PURE__ */ (0,
|
|
2000
|
-
/* @__PURE__ */ (0,
|
|
2059
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_lucide_react10.SearchIcon, { className: "h-5 w-5", style: { color: themeMode === "dark" ? "#666666" : "#a3a3a3" }, strokeWidth: 2 }) }),
|
|
2060
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { className: "text-[13px] font-medium mb-0.5", style: { color: themeMode === "dark" ? "#e5e5e5" : "#171717" }, children: "No Results" }),
|
|
2061
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { className: "text-[12px]", style: { color: themeMode === "dark" ? "#999999" : "#737373" }, children: "Try a different search" })
|
|
2062
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "py-0.5", children: groupedConversations.map(([groupName, groupConversations]) => /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "mb-0.5", children: [
|
|
2063
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "px-2.5 py-1 sticky top-0 backdrop-blur-sm z-10", style: {
|
|
2001
2064
|
backgroundColor: themeMode === "dark" ? "rgba(37,37,37,0.95)" : "rgba(255,255,255,0.95)"
|
|
2002
|
-
}, children: /* @__PURE__ */ (0,
|
|
2003
|
-
/* @__PURE__ */ (0,
|
|
2065
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("h3", { className: "text-[10px] font-semibold uppercase tracking-wide", style: { color: themeMode === "dark" ? "#999999" : "#737373" }, children: groupName }) }),
|
|
2066
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "px-1 space-y-0.5", children: groupConversations.map((conversation) => {
|
|
2004
2067
|
const isActiveConversation = activeTabId === conversation.id;
|
|
2005
|
-
return /* @__PURE__ */ (0,
|
|
2068
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2006
2069
|
"button",
|
|
2007
2070
|
{
|
|
2008
2071
|
className: "w-full px-2 py-1 rounded-md transition-all duration-150 text-left group relative",
|
|
@@ -2020,12 +2083,12 @@ function ChatInterface({ id, initialMessages, config, onClose } = {}) {
|
|
|
2020
2083
|
}
|
|
2021
2084
|
},
|
|
2022
2085
|
onClick: () => handleSelectConversation(conversation.id, conversation.title),
|
|
2023
|
-
children: /* @__PURE__ */ (0,
|
|
2024
|
-
/* @__PURE__ */ (0,
|
|
2086
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex items-center gap-1.5", children: [
|
|
2087
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "flex-1 min-w-0", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { className: "text-[12px] line-clamp-1 transition-colors leading-tight", style: {
|
|
2025
2088
|
fontWeight: isActiveConversation ? 500 : 400,
|
|
2026
2089
|
color: isActiveConversation ? themeMode === "dark" ? "#e5e5e5" : "#171717" : themeMode === "dark" ? "#cccccc" : "#404040"
|
|
2027
2090
|
}, children: conversation.title }) }),
|
|
2028
|
-
/* @__PURE__ */ (0,
|
|
2091
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2029
2092
|
import_lucide_react10.ChevronRightIcon,
|
|
2030
2093
|
{
|
|
2031
2094
|
className: "h-3 w-3 transition-all duration-150 flex-shrink-0",
|
|
@@ -2044,7 +2107,7 @@ function ChatInterface({ id, initialMessages, config, onClose } = {}) {
|
|
|
2044
2107
|
] }, groupName)) }) })
|
|
2045
2108
|
] })
|
|
2046
2109
|
] }),
|
|
2047
|
-
onClose && /* @__PURE__ */ (0,
|
|
2110
|
+
onClose && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2048
2111
|
"button",
|
|
2049
2112
|
{
|
|
2050
2113
|
onClick: onClose,
|
|
@@ -2061,24 +2124,33 @@ function ChatInterface({ id, initialMessages, config, onClose } = {}) {
|
|
|
2061
2124
|
e.currentTarget.style.backgroundColor = "transparent";
|
|
2062
2125
|
},
|
|
2063
2126
|
title: "Close Chat",
|
|
2064
|
-
children: /* @__PURE__ */ (0,
|
|
2127
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_lucide_react10.XIcon, { className: "h-4 w-4", strokeWidth: 2 })
|
|
2065
2128
|
}
|
|
2066
2129
|
)
|
|
2067
2130
|
] })
|
|
2068
2131
|
] }),
|
|
2069
|
-
/* @__PURE__ */ (0,
|
|
2070
|
-
/* @__PURE__ */ (0,
|
|
2132
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(Conversation, { className: "flex-1 max-w-full ai-assistant-scrollbar", children: [
|
|
2133
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(ConversationContent, { className: "max-w-[96%] mx-auto py-6", children: [
|
|
2071
2134
|
renderMessages(),
|
|
2072
|
-
status === "submitted" && /* @__PURE__ */ (0,
|
|
2135
|
+
status === "submitted" && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "mt-6", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Message, { from: "assistant", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(MessageContent, { children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Loader, { size: 16 }) }) }) })
|
|
2073
2136
|
] }),
|
|
2074
|
-
/* @__PURE__ */ (0,
|
|
2137
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ConversationScrollButton, {})
|
|
2075
2138
|
] }),
|
|
2076
|
-
/* @__PURE__ */ (0,
|
|
2077
|
-
uploadError && /* @__PURE__ */ (0,
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2139
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "px-5 pb-5", children: [
|
|
2140
|
+
uploadError && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "mb-3 px-4 py-3 bg-red-50 dark:bg-red-900/20 border border-red-200/60 dark:border-red-800/60 rounded-2xl text-sm text-red-700 dark:text-red-400 shadow-sm", children: uploadError }),
|
|
2141
|
+
messages.length === 0 && status !== "submitted" && config?.starterPrompts && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2142
|
+
StarterMessages,
|
|
2143
|
+
{
|
|
2144
|
+
prompts: config.starterPrompts,
|
|
2145
|
+
onPromptSelect: (prompt) => {
|
|
2146
|
+
handleSubmit({ text: prompt.title });
|
|
2147
|
+
}
|
|
2148
|
+
}
|
|
2149
|
+
),
|
|
2150
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(PromptInput, { onSubmit: handleSubmit, globalDrop: true, multiple: true, accept: "image/*", children: [
|
|
2151
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(PromptInputBody, { children: [
|
|
2152
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(PromptInputAttachments, { children: (attachment) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(PromptInputAttachment, { data: attachment }) }),
|
|
2153
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2082
2154
|
PromptInputTextarea,
|
|
2083
2155
|
{
|
|
2084
2156
|
onChange: (e) => setInput(e.target.value),
|
|
@@ -2086,9 +2158,9 @@ function ChatInterface({ id, initialMessages, config, onClose } = {}) {
|
|
|
2086
2158
|
}
|
|
2087
2159
|
)
|
|
2088
2160
|
] }),
|
|
2089
|
-
/* @__PURE__ */ (0,
|
|
2090
|
-
/* @__PURE__ */ (0,
|
|
2091
|
-
/* @__PURE__ */ (0,
|
|
2161
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(PromptInputToolbar, { children: [
|
|
2162
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(PromptInputTools, { children: config?.features?.fileUpload !== false && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(AttachButton, {}) }),
|
|
2163
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(PromptInputSubmit, { disabled: !input, status })
|
|
2092
2164
|
] })
|
|
2093
2165
|
] })
|
|
2094
2166
|
] })
|
|
@@ -2099,7 +2171,7 @@ function ChatInterface({ id, initialMessages, config, onClose } = {}) {
|
|
|
2099
2171
|
|
|
2100
2172
|
// src/ChatWidget.tsx
|
|
2101
2173
|
var import_lucide_react11 = require("lucide-react");
|
|
2102
|
-
var
|
|
2174
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
2103
2175
|
function ChatWidget({
|
|
2104
2176
|
userId,
|
|
2105
2177
|
conversationId,
|
|
@@ -2110,93 +2182,90 @@ function ChatWidget({
|
|
|
2110
2182
|
temperature,
|
|
2111
2183
|
theme,
|
|
2112
2184
|
features,
|
|
2113
|
-
display
|
|
2185
|
+
display,
|
|
2186
|
+
starterPrompts
|
|
2114
2187
|
}) {
|
|
2115
|
-
const initialWidth = display?.width || "30vw";
|
|
2116
2188
|
const showToggleButton = display?.showToggleButton !== false;
|
|
2117
|
-
const
|
|
2118
|
-
const
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2189
|
+
const resizable = display?.resizable !== false;
|
|
2190
|
+
const size = display?.size || "default";
|
|
2191
|
+
const [isOpen, setIsOpen] = (0, import_react12.useState)(display?.defaultOpen || false);
|
|
2192
|
+
const [isResizing, setIsResizing] = (0, import_react12.useState)(false);
|
|
2193
|
+
const containerRef = (0, import_react12.useRef)(null);
|
|
2194
|
+
const customStyles = (0, import_react12.useMemo)(() => {
|
|
2195
|
+
const styles = {};
|
|
2196
|
+
if (display?.width) {
|
|
2197
|
+
styles["--chat-widget-width"] = display.width;
|
|
2122
2198
|
}
|
|
2123
|
-
return
|
|
2124
|
-
});
|
|
2125
|
-
const
|
|
2126
|
-
|
|
2199
|
+
return styles;
|
|
2200
|
+
}, [display?.width]);
|
|
2201
|
+
const handleMouseDown = (0, import_react12.useCallback)((e) => {
|
|
2202
|
+
if (!resizable) return;
|
|
2127
2203
|
e.preventDefault();
|
|
2128
|
-
|
|
2204
|
+
setIsResizing(true);
|
|
2129
2205
|
document.body.style.cursor = "ew-resize";
|
|
2130
2206
|
document.body.style.userSelect = "none";
|
|
2131
|
-
}, []);
|
|
2132
|
-
(0,
|
|
2133
|
-
|
|
2134
|
-
minWidth: window.innerWidth * 0.2,
|
|
2135
|
-
maxWidth: window.innerWidth * 0.6
|
|
2136
|
-
});
|
|
2207
|
+
}, [resizable]);
|
|
2208
|
+
(0, import_react12.useEffect)(() => {
|
|
2209
|
+
if (!isResizing) return;
|
|
2137
2210
|
const handleMouseMove = (e) => {
|
|
2138
|
-
if (!
|
|
2139
|
-
const { minWidth, maxWidth } = getConstraints();
|
|
2211
|
+
if (!containerRef.current) return;
|
|
2140
2212
|
const newWidth = window.innerWidth - e.clientX;
|
|
2141
|
-
|
|
2213
|
+
const minWidth = 300;
|
|
2214
|
+
const maxWidth = Math.min(800, window.innerWidth * 0.8);
|
|
2215
|
+
const clampedWidth = Math.min(maxWidth, Math.max(minWidth, newWidth));
|
|
2216
|
+
containerRef.current.style.setProperty("--chat-widget-width", `${clampedWidth}px`);
|
|
2142
2217
|
};
|
|
2143
2218
|
const handleMouseUp = () => {
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
document.body.style.userSelect = "";
|
|
2148
|
-
}
|
|
2149
|
-
};
|
|
2150
|
-
const handleWindowResize = () => {
|
|
2151
|
-
const { minWidth, maxWidth } = getConstraints();
|
|
2152
|
-
setWidth((prev) => Math.min(maxWidth, Math.max(minWidth, prev)));
|
|
2219
|
+
setIsResizing(false);
|
|
2220
|
+
document.body.style.cursor = "";
|
|
2221
|
+
document.body.style.userSelect = "";
|
|
2153
2222
|
};
|
|
2154
2223
|
document.addEventListener("mousemove", handleMouseMove);
|
|
2155
2224
|
document.addEventListener("mouseup", handleMouseUp);
|
|
2156
|
-
window.addEventListener("resize", handleWindowResize);
|
|
2157
2225
|
return () => {
|
|
2158
2226
|
document.removeEventListener("mousemove", handleMouseMove);
|
|
2159
2227
|
document.removeEventListener("mouseup", handleMouseUp);
|
|
2160
|
-
window.removeEventListener("resize", handleWindowResize);
|
|
2161
2228
|
};
|
|
2162
|
-
}, []);
|
|
2163
|
-
const config = (0,
|
|
2229
|
+
}, [isResizing]);
|
|
2230
|
+
const config = (0, import_react12.useMemo)(() => ({
|
|
2164
2231
|
userId,
|
|
2165
2232
|
model,
|
|
2166
2233
|
systemPrompt,
|
|
2167
2234
|
temperature,
|
|
2168
2235
|
theme,
|
|
2169
|
-
features
|
|
2170
|
-
|
|
2236
|
+
features,
|
|
2237
|
+
starterPrompts
|
|
2238
|
+
}), [userId, model, systemPrompt, temperature, theme, features, starterPrompts]);
|
|
2171
2239
|
const togglePosition = display?.toggleButtonPosition || { bottom: "24px", right: "24px" };
|
|
2172
|
-
return /* @__PURE__ */ (0,
|
|
2173
|
-
showToggleButton && !isOpen && /* @__PURE__ */ (0,
|
|
2240
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(ChatStorageProvider, { userId, children: [
|
|
2241
|
+
showToggleButton && !isOpen && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2174
2242
|
"button",
|
|
2175
2243
|
{
|
|
2176
2244
|
onClick: () => setIsOpen(true),
|
|
2177
2245
|
className: "fixed z-50 rounded-full bg-primary text-primary-foreground shadow-lg hover:opacity-90 transition-all p-4",
|
|
2178
2246
|
style: togglePosition,
|
|
2179
2247
|
"aria-label": "Open chat",
|
|
2180
|
-
children: /* @__PURE__ */ (0,
|
|
2248
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_lucide_react11.MessageCircle, { className: "h-6 w-6" })
|
|
2181
2249
|
}
|
|
2182
2250
|
),
|
|
2183
|
-
isOpen && /* @__PURE__ */ (0,
|
|
2251
|
+
isOpen && /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
|
2184
2252
|
"div",
|
|
2185
2253
|
{
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2254
|
+
ref: containerRef,
|
|
2255
|
+
className: `chat-widget-container chat-widget-popup chat-widget-content ${theme?.mode === "dark" ? "dark" : ""} ${className || ""}`,
|
|
2256
|
+
"data-size": size,
|
|
2257
|
+
"data-resizing": isResizing,
|
|
2258
|
+
style: customStyles,
|
|
2191
2259
|
children: [
|
|
2192
|
-
/* @__PURE__ */ (0,
|
|
2260
|
+
resizable && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2193
2261
|
"div",
|
|
2194
2262
|
{
|
|
2195
2263
|
onMouseDown: handleMouseDown,
|
|
2196
|
-
className: "
|
|
2264
|
+
className: "chat-widget-resize-handle",
|
|
2265
|
+
"aria-label": "Resize chat widget"
|
|
2197
2266
|
}
|
|
2198
2267
|
),
|
|
2199
|
-
/* @__PURE__ */ (0,
|
|
2268
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "w-full h-full overflow-hidden", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2200
2269
|
ChatInterface,
|
|
2201
2270
|
{
|
|
2202
2271
|
id: conversationId,
|
|
@@ -2213,7 +2282,7 @@ function ChatWidget({
|
|
|
2213
2282
|
var ChatWidget_default = ChatWidget;
|
|
2214
2283
|
|
|
2215
2284
|
// src/hooks/use-chat-theme.ts
|
|
2216
|
-
var
|
|
2285
|
+
var import_react13 = require("react");
|
|
2217
2286
|
|
|
2218
2287
|
// src/utils/models.ts
|
|
2219
2288
|
var MODELS = [
|
|
@@ -2331,14 +2400,16 @@ var defaultSystemPrompt = "You are a helpful AI assistant.";
|
|
|
2331
2400
|
var defaultTemperature = 0.7;
|
|
2332
2401
|
var defaultThemeMode = "light";
|
|
2333
2402
|
function useChatTheme() {
|
|
2334
|
-
const
|
|
2335
|
-
const
|
|
2336
|
-
const [
|
|
2337
|
-
const [
|
|
2338
|
-
const [
|
|
2339
|
-
const [
|
|
2340
|
-
(0,
|
|
2341
|
-
|
|
2403
|
+
const { storageKeyPrefix } = useChatStorageKey();
|
|
2404
|
+
const keyPrefix = storageKeyPrefix ? `chat-${storageKeyPrefix}-` : "chat-";
|
|
2405
|
+
const [theme, setTheme] = (0, import_react13.useState)(defaultTheme);
|
|
2406
|
+
const [conversationStarters, setConversationStarters] = (0, import_react13.useState)(defaultConversationStarters);
|
|
2407
|
+
const [model, setModel] = (0, import_react13.useState)(defaultModel);
|
|
2408
|
+
const [systemPrompt, setSystemPrompt] = (0, import_react13.useState)(defaultSystemPrompt);
|
|
2409
|
+
const [temperature, setTemperature] = (0, import_react13.useState)(defaultTemperature);
|
|
2410
|
+
const [themeMode, setThemeMode] = (0, import_react13.useState)(defaultThemeMode);
|
|
2411
|
+
(0, import_react13.useEffect)(() => {
|
|
2412
|
+
const savedTheme = localStorage.getItem(`${keyPrefix}theme`);
|
|
2342
2413
|
if (savedTheme) {
|
|
2343
2414
|
try {
|
|
2344
2415
|
setTheme(JSON.parse(savedTheme));
|
|
@@ -2346,7 +2417,7 @@ function useChatTheme() {
|
|
|
2346
2417
|
console.error("Error loading theme:", error);
|
|
2347
2418
|
}
|
|
2348
2419
|
}
|
|
2349
|
-
const savedStarters = localStorage.getItem(
|
|
2420
|
+
const savedStarters = localStorage.getItem(`${keyPrefix}conversation-starters`);
|
|
2350
2421
|
if (savedStarters) {
|
|
2351
2422
|
try {
|
|
2352
2423
|
setConversationStarters(JSON.parse(savedStarters));
|
|
@@ -2354,7 +2425,7 @@ function useChatTheme() {
|
|
|
2354
2425
|
console.error("Error loading conversation starters:", error);
|
|
2355
2426
|
}
|
|
2356
2427
|
}
|
|
2357
|
-
const savedModel = localStorage.getItem(
|
|
2428
|
+
const savedModel = localStorage.getItem(`${keyPrefix}model`);
|
|
2358
2429
|
if (savedModel) {
|
|
2359
2430
|
try {
|
|
2360
2431
|
setModel(savedModel);
|
|
@@ -2362,7 +2433,7 @@ function useChatTheme() {
|
|
|
2362
2433
|
console.error("Error loading model:", error);
|
|
2363
2434
|
}
|
|
2364
2435
|
}
|
|
2365
|
-
const savedSystemPrompt = localStorage.getItem(
|
|
2436
|
+
const savedSystemPrompt = localStorage.getItem(`${keyPrefix}system-prompt`);
|
|
2366
2437
|
if (savedSystemPrompt) {
|
|
2367
2438
|
try {
|
|
2368
2439
|
setSystemPrompt(savedSystemPrompt);
|
|
@@ -2370,7 +2441,7 @@ function useChatTheme() {
|
|
|
2370
2441
|
console.error("Error loading system prompt:", error);
|
|
2371
2442
|
}
|
|
2372
2443
|
}
|
|
2373
|
-
const savedTemperature = localStorage.getItem(
|
|
2444
|
+
const savedTemperature = localStorage.getItem(`${keyPrefix}temperature`);
|
|
2374
2445
|
if (savedTemperature) {
|
|
2375
2446
|
try {
|
|
2376
2447
|
setTemperature(parseFloat(savedTemperature));
|
|
@@ -2378,7 +2449,7 @@ function useChatTheme() {
|
|
|
2378
2449
|
console.error("Error loading temperature:", error);
|
|
2379
2450
|
}
|
|
2380
2451
|
}
|
|
2381
|
-
const savedThemeMode = localStorage.getItem(
|
|
2452
|
+
const savedThemeMode = localStorage.getItem(`${keyPrefix}theme-mode`);
|
|
2382
2453
|
if (savedThemeMode) {
|
|
2383
2454
|
try {
|
|
2384
2455
|
setThemeMode(savedThemeMode);
|
|
@@ -2424,9 +2495,9 @@ function useChatTheme() {
|
|
|
2424
2495
|
window.removeEventListener("chat-temperature-change", handleTemperatureChange);
|
|
2425
2496
|
window.removeEventListener("chat-theme-mode-change", handleThemeModeChange);
|
|
2426
2497
|
};
|
|
2427
|
-
}, []);
|
|
2428
|
-
(0,
|
|
2429
|
-
localStorage.setItem(
|
|
2498
|
+
}, [keyPrefix]);
|
|
2499
|
+
(0, import_react13.useEffect)(() => {
|
|
2500
|
+
localStorage.setItem(`${keyPrefix}theme`, JSON.stringify(theme));
|
|
2430
2501
|
const root = document.documentElement;
|
|
2431
2502
|
if (themeMode === "light") {
|
|
2432
2503
|
root.style.setProperty("--chat-primary", hexToHSL(theme.lightPrimary));
|
|
@@ -2440,27 +2511,27 @@ function useChatTheme() {
|
|
|
2440
2511
|
root.style.setProperty("--chat-font-family", theme.fontFamily);
|
|
2441
2512
|
root.style.setProperty("--chat-font-size", `${theme.fontSize}px`);
|
|
2442
2513
|
window.dispatchEvent(new CustomEvent("chat-theme-change", { detail: theme }));
|
|
2443
|
-
}, [theme, themeMode]);
|
|
2444
|
-
(0,
|
|
2445
|
-
localStorage.setItem(
|
|
2514
|
+
}, [theme, themeMode, keyPrefix]);
|
|
2515
|
+
(0, import_react13.useEffect)(() => {
|
|
2516
|
+
localStorage.setItem(`${keyPrefix}conversation-starters`, JSON.stringify(conversationStarters));
|
|
2446
2517
|
window.dispatchEvent(new CustomEvent("chat-starters-change", { detail: conversationStarters }));
|
|
2447
|
-
}, [conversationStarters]);
|
|
2448
|
-
(0,
|
|
2449
|
-
localStorage.setItem(
|
|
2518
|
+
}, [conversationStarters, keyPrefix]);
|
|
2519
|
+
(0, import_react13.useEffect)(() => {
|
|
2520
|
+
localStorage.setItem(`${keyPrefix}model`, model);
|
|
2450
2521
|
window.dispatchEvent(new CustomEvent("chat-model-change", { detail: model }));
|
|
2451
|
-
}, [model]);
|
|
2452
|
-
(0,
|
|
2453
|
-
localStorage.setItem(
|
|
2522
|
+
}, [model, keyPrefix]);
|
|
2523
|
+
(0, import_react13.useEffect)(() => {
|
|
2524
|
+
localStorage.setItem(`${keyPrefix}system-prompt`, systemPrompt);
|
|
2454
2525
|
window.dispatchEvent(new CustomEvent("chat-system-prompt-change", { detail: systemPrompt }));
|
|
2455
|
-
}, [systemPrompt]);
|
|
2456
|
-
(0,
|
|
2457
|
-
localStorage.setItem(
|
|
2526
|
+
}, [systemPrompt, keyPrefix]);
|
|
2527
|
+
(0, import_react13.useEffect)(() => {
|
|
2528
|
+
localStorage.setItem(`${keyPrefix}temperature`, temperature.toString());
|
|
2458
2529
|
window.dispatchEvent(new CustomEvent("chat-temperature-change", { detail: temperature }));
|
|
2459
|
-
}, [temperature]);
|
|
2460
|
-
(0,
|
|
2461
|
-
localStorage.setItem(
|
|
2530
|
+
}, [temperature, keyPrefix]);
|
|
2531
|
+
(0, import_react13.useEffect)(() => {
|
|
2532
|
+
localStorage.setItem(`${keyPrefix}theme-mode`, themeMode);
|
|
2462
2533
|
window.dispatchEvent(new CustomEvent("chat-theme-mode-change", { detail: themeMode }));
|
|
2463
|
-
}, [themeMode]);
|
|
2534
|
+
}, [themeMode, keyPrefix]);
|
|
2464
2535
|
const updateColor = (key, value) => {
|
|
2465
2536
|
setTheme((prev) => ({ ...prev, [key]: value }));
|
|
2466
2537
|
};
|
|
@@ -2527,10 +2598,10 @@ function useChatTheme() {
|
|
|
2527
2598
|
|
|
2528
2599
|
// src/ui/input.tsx
|
|
2529
2600
|
var React = __toESM(require("react"));
|
|
2530
|
-
var
|
|
2601
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
2531
2602
|
var Input = React.forwardRef(
|
|
2532
2603
|
({ className, type, ...props }, ref) => {
|
|
2533
|
-
return /* @__PURE__ */ (0,
|
|
2604
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2534
2605
|
"input",
|
|
2535
2606
|
{
|
|
2536
2607
|
type,
|
|
@@ -2549,22 +2620,22 @@ Input.displayName = "Input";
|
|
|
2549
2620
|
// src/ui/dialog.tsx
|
|
2550
2621
|
var DialogPrimitive = __toESM(require("@radix-ui/react-dialog"));
|
|
2551
2622
|
var import_lucide_react12 = require("lucide-react");
|
|
2552
|
-
var
|
|
2623
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
2553
2624
|
function Dialog({
|
|
2554
2625
|
...props
|
|
2555
2626
|
}) {
|
|
2556
|
-
return /* @__PURE__ */ (0,
|
|
2627
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(DialogPrimitive.Root, { "data-slot": "dialog", ...props });
|
|
2557
2628
|
}
|
|
2558
2629
|
function DialogPortal({
|
|
2559
2630
|
...props
|
|
2560
2631
|
}) {
|
|
2561
|
-
return /* @__PURE__ */ (0,
|
|
2632
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(DialogPrimitive.Portal, { "data-slot": "dialog-portal", ...props });
|
|
2562
2633
|
}
|
|
2563
2634
|
function DialogOverlay({
|
|
2564
2635
|
className,
|
|
2565
2636
|
...props
|
|
2566
2637
|
}) {
|
|
2567
|
-
return /* @__PURE__ */ (0,
|
|
2638
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2568
2639
|
DialogPrimitive.Overlay,
|
|
2569
2640
|
{
|
|
2570
2641
|
"data-slot": "dialog-overlay",
|
|
@@ -2582,9 +2653,9 @@ function DialogContent({
|
|
|
2582
2653
|
showCloseButton = true,
|
|
2583
2654
|
...props
|
|
2584
2655
|
}) {
|
|
2585
|
-
return /* @__PURE__ */ (0,
|
|
2586
|
-
/* @__PURE__ */ (0,
|
|
2587
|
-
/* @__PURE__ */ (0,
|
|
2656
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(DialogPortal, { "data-slot": "dialog-portal", children: [
|
|
2657
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(DialogOverlay, {}),
|
|
2658
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
|
|
2588
2659
|
DialogPrimitive.Content,
|
|
2589
2660
|
{
|
|
2590
2661
|
"data-slot": "dialog-content",
|
|
@@ -2595,14 +2666,14 @@ function DialogContent({
|
|
|
2595
2666
|
...props,
|
|
2596
2667
|
children: [
|
|
2597
2668
|
children,
|
|
2598
|
-
showCloseButton && /* @__PURE__ */ (0,
|
|
2669
|
+
showCloseButton && /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
|
|
2599
2670
|
DialogPrimitive.Close,
|
|
2600
2671
|
{
|
|
2601
2672
|
"data-slot": "dialog-close",
|
|
2602
2673
|
className: "ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
2603
2674
|
children: [
|
|
2604
|
-
/* @__PURE__ */ (0,
|
|
2605
|
-
/* @__PURE__ */ (0,
|
|
2675
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_lucide_react12.XIcon, {}),
|
|
2676
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "sr-only", children: "Close" })
|
|
2606
2677
|
]
|
|
2607
2678
|
}
|
|
2608
2679
|
)
|
|
@@ -2612,7 +2683,7 @@ function DialogContent({
|
|
|
2612
2683
|
] });
|
|
2613
2684
|
}
|
|
2614
2685
|
function DialogHeader({ className, ...props }) {
|
|
2615
|
-
return /* @__PURE__ */ (0,
|
|
2686
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2616
2687
|
"div",
|
|
2617
2688
|
{
|
|
2618
2689
|
"data-slot": "dialog-header",
|
|
@@ -2625,7 +2696,7 @@ function DialogTitle({
|
|
|
2625
2696
|
className,
|
|
2626
2697
|
...props
|
|
2627
2698
|
}) {
|
|
2628
|
-
return /* @__PURE__ */ (0,
|
|
2699
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2629
2700
|
DialogPrimitive.Title,
|
|
2630
2701
|
{
|
|
2631
2702
|
"data-slot": "dialog-title",
|
|
@@ -2638,7 +2709,7 @@ function DialogDescription({
|
|
|
2638
2709
|
className,
|
|
2639
2710
|
...props
|
|
2640
2711
|
}) {
|
|
2641
|
-
return /* @__PURE__ */ (0,
|
|
2712
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2642
2713
|
DialogPrimitive.Description,
|
|
2643
2714
|
{
|
|
2644
2715
|
"data-slot": "dialog-description",
|
|
@@ -2650,6 +2721,7 @@ function DialogDescription({
|
|
|
2650
2721
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2651
2722
|
0 && (module.exports = {
|
|
2652
2723
|
Button,
|
|
2724
|
+
ChatStorageProvider,
|
|
2653
2725
|
ChatWidget,
|
|
2654
2726
|
Dialog,
|
|
2655
2727
|
DialogContent,
|
|
@@ -2657,7 +2729,10 @@ function DialogDescription({
|
|
|
2657
2729
|
DialogHeader,
|
|
2658
2730
|
DialogTitle,
|
|
2659
2731
|
Input,
|
|
2732
|
+
StarterMessageItem,
|
|
2733
|
+
StarterMessages,
|
|
2660
2734
|
fontOptions,
|
|
2735
|
+
useChatStorageKey,
|
|
2661
2736
|
useChatTheme
|
|
2662
2737
|
});
|
|
2663
2738
|
//# sourceMappingURL=index.js.map
|