@terryavg/neptune-ai-chatbot 1.0.1 → 1.0.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.
Files changed (74) hide show
  1. package/README.md +116 -1
  2. package/dist/chat-input-2CHIBULE.mjs +510 -0
  3. package/dist/chat-input-42V4ESQB.mjs +478 -0
  4. package/dist/chat-input-4T42R7FR.mjs +481 -0
  5. package/dist/chat-input-BJVIIYOP.mjs +484 -0
  6. package/dist/chat-input-G2LRENLB.mjs +512 -0
  7. package/dist/chat-input-HT47ZLQN.mjs +456 -0
  8. package/dist/chat-input-IIV2HQOZ.mjs +509 -0
  9. package/dist/chat-input-JFGPZBBQ.mjs +495 -0
  10. package/dist/chat-input-JQ7PSHNW.mjs +515 -0
  11. package/dist/chat-input-MLF62KV7.mjs +512 -0
  12. package/dist/chat-input-MOPCNDRR.mjs +517 -0
  13. package/dist/chat-input-TYNO3J5S.mjs +519 -0
  14. package/dist/chat-input-USWVSAYY.mjs +461 -0
  15. package/dist/chat-input-VQZ3WNBT.mjs +509 -0
  16. package/dist/chat-input-VTCTV5ED.mjs +495 -0
  17. package/dist/chat-input-WJMGLQJI.mjs +495 -0
  18. package/dist/chat-input-ZAFYBUO7.mjs +507 -0
  19. package/dist/chat-message-2VQW74CO.mjs +2230 -0
  20. package/dist/chat-message-35ZWSSQV.mjs +1926 -0
  21. package/dist/chat-message-3CUUWTZG.mjs +2429 -0
  22. package/dist/chat-message-3NHSJNKL.mjs +2241 -0
  23. package/dist/chat-message-3Z7B2WYC.mjs +2228 -0
  24. package/dist/chat-message-564AHZHH.mjs +2186 -0
  25. package/dist/chat-message-5QLTW4K7.mjs +2122 -0
  26. package/dist/chat-message-7EH2TDZG.mjs +1910 -0
  27. package/dist/chat-message-7QHJRHQG.mjs +1909 -0
  28. package/dist/chat-message-AAXNH5TF.mjs +2088 -0
  29. package/dist/chat-message-D36YF274.mjs +1910 -0
  30. package/dist/chat-message-DVCXEL4Z.mjs +2111 -0
  31. package/dist/chat-message-E6KB3AST.mjs +1906 -0
  32. package/dist/chat-message-EQTB6N5X.mjs +2306 -0
  33. package/dist/chat-message-G2NWPAXK.mjs +1904 -0
  34. package/dist/chat-message-GUOL4RZU.mjs +2306 -0
  35. package/dist/chat-message-H62Z3DW5.mjs +2368 -0
  36. package/dist/chat-message-HIEZ7B5R.mjs +2190 -0
  37. package/dist/chat-message-HWBFOYOJ.mjs +2306 -0
  38. package/dist/chat-message-I6AKFPK6.mjs +2156 -0
  39. package/dist/chat-message-IKYSAVAB.mjs +1918 -0
  40. package/dist/chat-message-IZL6JHV2.mjs +2429 -0
  41. package/dist/chat-message-J7PVUQO6.mjs +1878 -0
  42. package/dist/chat-message-K6QILTW5.mjs +1897 -0
  43. package/dist/chat-message-MDORLI2R.mjs +2228 -0
  44. package/dist/chat-message-MFUY6KOE.mjs +1910 -0
  45. package/dist/chat-message-MYKOR5OF.mjs +1890 -0
  46. package/dist/chat-message-NKMTAMGG.mjs +1906 -0
  47. package/dist/chat-message-NNGD3FUH.mjs +2168 -0
  48. package/dist/chat-message-NZNZX6VS.mjs +2306 -0
  49. package/dist/chat-message-QAPRO542.mjs +1915 -0
  50. package/dist/chat-message-R4IJ3MXU.mjs +2146 -0
  51. package/dist/chat-message-U7UCBLHI.mjs +2145 -0
  52. package/dist/chat-message-UKXGFKUR.mjs +1903 -0
  53. package/dist/chat-message-UNIBCF3T.mjs +1900 -0
  54. package/dist/chat-message-UXLPL76T.mjs +1890 -0
  55. package/dist/chat-message-VB54UOHB.mjs +2306 -0
  56. package/dist/chat-message-WUNUZLKI.mjs +2228 -0
  57. package/dist/chat-message-WYN5UZRD.mjs +1927 -0
  58. package/dist/chat-message-Y5OJSR2O.mjs +2228 -0
  59. package/dist/chat-message-YPDHL6WW.mjs +2114 -0
  60. package/dist/chunk-26656QB3.mjs +406 -0
  61. package/dist/chunk-2RXQ2EZ2.mjs +295 -0
  62. package/dist/chunk-DVWFDUN4.mjs +407 -0
  63. package/dist/chunk-JLRHY3SB.mjs +405 -0
  64. package/dist/chunk-VONUV37R.mjs +268 -0
  65. package/dist/chunk-XFSEOBLD.mjs +432 -0
  66. package/dist/chunk-XQVUOR36.mjs +438 -0
  67. package/dist/chunk-Y7QF5535.mjs +268 -0
  68. package/dist/index.css +174 -43
  69. package/dist/index.d.mts +214 -2
  70. package/dist/index.d.ts +214 -2
  71. package/dist/index.js +2232 -1839
  72. package/dist/index.mjs +693 -622
  73. package/dist/styles.css +1 -1
  74. package/package.json +2 -1
package/dist/index.mjs CHANGED
@@ -1,11 +1,11 @@
1
- import {
2
- chatClient,
3
- configureChatClient
4
- } from "./chunk-5VL3YPMQ.mjs";
5
1
  import {
6
2
  ToolExecutionIndicator,
7
3
  ToolExecutionWidget
8
- } from "./chunk-C2VGAYER.mjs";
4
+ } from "./chunk-2RXQ2EZ2.mjs";
5
+ import {
6
+ chatClient,
7
+ configureChatClient
8
+ } from "./chunk-VONUV37R.mjs";
9
9
  import {
10
10
  __spreadProps,
11
11
  __spreadValues
@@ -17,7 +17,8 @@ import {
17
17
  useEffect as useEffect4,
18
18
  useRef as useRef2,
19
19
  useLayoutEffect,
20
- useCallback as useCallback2
20
+ useCallback as useCallback2,
21
+ startTransition as startTransition2
21
22
  } from "react";
22
23
  import {
23
24
  Trash2,
@@ -29,6 +30,7 @@ import {
29
30
  PanelRightOpen,
30
31
  MoreHorizontal
31
32
  } from "lucide-react";
33
+ import { motion as motion2, AnimatePresence as AnimatePresence2 } from "framer-motion";
32
34
 
33
35
  // app/components/chat-content.tsx
34
36
  import {
@@ -38,9 +40,11 @@ import {
38
40
  useMemo as useMemo2,
39
41
  useCallback,
40
42
  lazy,
41
- Suspense
43
+ Suspense,
44
+ startTransition
42
45
  } from "react";
43
46
  import { X as X2, ArrowDownCircle } from "lucide-react";
47
+ import { motion, AnimatePresence } from "framer-motion";
44
48
 
45
49
  // app/components/analytics-panel.tsx
46
50
  import { useState, useMemo, useEffect } from "react";
@@ -64,8 +68,7 @@ import {
64
68
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
65
69
  function AnalyticsPanel({
66
70
  name,
67
- csvData,
68
- theme
71
+ csvData
69
72
  }) {
70
73
  const { headers, data } = useMemo(() => {
71
74
  var _a;
@@ -1267,19 +1270,35 @@ function AnalyticsPanel({
1267
1270
 
1268
1271
  // app/components/chat-content.tsx
1269
1272
  import { Fragment as Fragment2, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
1270
- var ChatInput = lazy(() => import("./chat-input-L5LIF4NP.mjs"));
1271
- var DynamicChatMessage = lazy(() => import("./chat-message-FTACCRMO.mjs"));
1273
+ var ChatInput = lazy(() => import("./chat-input-ZAFYBUO7.mjs"));
1274
+ var DynamicChatMessage = lazy(() => import("./chat-message-NZNZX6VS.mjs"));
1272
1275
  var SCROLL_BOTTOM_THRESHOLD = 50;
1273
1276
  function ChatContent({
1274
1277
  conversation,
1275
1278
  agentId,
1276
- debug = false,
1277
- onConversationUpdate,
1278
1279
  theme,
1279
- onAppStateChange,
1280
1280
  onSidebarToggle,
1281
1281
  isReadOnly = false,
1282
- onThreadCreated
1282
+ onThreadCreated,
1283
+ messageBubbleColor,
1284
+ accentColor,
1285
+ scrollButtonColor = "#6366F1",
1286
+ streamingText = "NAIA is working on it...",
1287
+ streamingTextColor = "#2563EB",
1288
+ welcomeMessagePrimary = "How can I help you today?",
1289
+ welcomeMessageSecondary = "Feel free to ask any question you like \u2014 just be precise, as if you're speaking to a real person.",
1290
+ welcomeIcon,
1291
+ welcomeIconSize = "4rem",
1292
+ streaming = true,
1293
+ inputBackgroundColor = "#ffffff",
1294
+ inputBackgroundColorDark = "#303030",
1295
+ vectorColor,
1296
+ vectorColorDark,
1297
+ onToolStart,
1298
+ onToolInput,
1299
+ onToolFinish,
1300
+ onChunk,
1301
+ onFinish
1283
1302
  }) {
1284
1303
  const messagesEndRef = useRef(null);
1285
1304
  const scrollContainerRef = useRef(null);
@@ -1291,10 +1310,10 @@ function ChatContent({
1291
1310
  null
1292
1311
  );
1293
1312
  const streamingMessageRef = useRef(null);
1313
+ const previousConversationIdRef = useRef(conversation.id);
1294
1314
  const [errorDialog, setErrorDialog] = useState2(null);
1295
1315
  const [showScrollToBottomButton, setShowScrollToBottomButton] = useState2(false);
1296
1316
  const [userHasScrolledUp, setUserHasScrolledUp] = useState2(false);
1297
- const [openApp, setOpenApp] = useState2(null);
1298
1317
  const [openAnalytic, setOpenAnalytic] = useState2(null);
1299
1318
  const [chatWidth, setChatWidth] = useState2(30);
1300
1319
  const [isResizingChatApp, setIsResizingChatApp] = useState2(false);
@@ -1303,7 +1322,7 @@ function ChatContent({
1303
1322
  const minChatWidth = 20;
1304
1323
  const maxChatWidth = 80;
1305
1324
  const hasMessages = messages.length > 0 || !!streamingMessage;
1306
- const hasOpenPanel = !!openApp || !!openAnalytic;
1325
+ const hasOpenPanel = !!openAnalytic;
1307
1326
  const isWaitingForInput = useMemo2(() => {
1308
1327
  return conversation.waiting === true || messages.some((message) => message.waiting === true);
1309
1328
  }, [conversation.waiting, messages]);
@@ -1387,16 +1406,61 @@ function ChatContent({
1387
1406
  return () => clearTimeout(timeoutId);
1388
1407
  }, [conversation.id, scrollToBottom]);
1389
1408
  useEffect2(() => {
1390
- setMessages(conversation.messages || []);
1391
- }, [conversation.id, conversation.messages]);
1392
- useEffect2(() => {
1393
- if (openApp) {
1394
- setOpenApp(null);
1409
+ const conversationMessages = conversation.messages || [];
1410
+ const previousId = previousConversationIdRef.current;
1411
+ const currentId = conversation.id;
1412
+ const isTempToRealTransition = (previousId == null ? void 0 : previousId.startsWith("temp-")) && !currentId.startsWith("temp-") && isStreaming;
1413
+ if (previousId !== currentId && !isTempToRealTransition) {
1414
+ setMessages(conversationMessages);
1415
+ previousConversationIdRef.current = currentId;
1416
+ return;
1417
+ }
1418
+ if (isTempToRealTransition) {
1419
+ previousConversationIdRef.current = currentId;
1420
+ }
1421
+ if (isStreaming && !isTempToRealTransition) {
1422
+ return;
1423
+ }
1424
+ if (conversationMessages.length > 0 || isTempToRealTransition) {
1425
+ setMessages((prevMessages) => {
1426
+ if (prevMessages.length === 0) {
1427
+ return conversationMessages;
1428
+ }
1429
+ const filteredLocalMessages = prevMessages.filter((localMsg) => {
1430
+ if (localMsg.role === "assistant") {
1431
+ return true;
1432
+ }
1433
+ const localTime = new Date(localMsg.createdAt).getTime();
1434
+ const isLocalMessage = localMsg.id.startsWith("local-");
1435
+ if (isLocalMessage) {
1436
+ const hasBackendVersion = conversationMessages.some((backendMsg) => {
1437
+ const backendTime = new Date(backendMsg.createdAt).getTime();
1438
+ const timeDiff = Math.abs(backendTime - localTime);
1439
+ return backendMsg.role === localMsg.role && timeDiff < 5e3;
1440
+ });
1441
+ return !hasBackendVersion;
1442
+ }
1443
+ return true;
1444
+ });
1445
+ const combined = [...filteredLocalMessages, ...conversationMessages];
1446
+ const seen = /* @__PURE__ */ new Set();
1447
+ const deduplicated = combined.filter((msg) => {
1448
+ if (seen.has(msg.id)) {
1449
+ return false;
1450
+ }
1451
+ seen.add(msg.id);
1452
+ return true;
1453
+ });
1454
+ return deduplicated.sort((a, b) => {
1455
+ return new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime();
1456
+ });
1457
+ });
1395
1458
  }
1459
+ }, [conversation.id, conversation.messages, isStreaming]);
1460
+ useEffect2(() => {
1396
1461
  if (openAnalytic) {
1397
1462
  setOpenAnalytic(null);
1398
1463
  }
1399
- onAppStateChange == null ? void 0 : onAppStateChange(false);
1400
1464
  }, [conversation.id]);
1401
1465
  useEffect2(() => {
1402
1466
  if (messages.length > 0 && !userHasScrolledUp) {
@@ -1433,14 +1497,16 @@ function ChatContent({
1433
1497
  }, []);
1434
1498
  const handleAddUserMessage = useCallback(
1435
1499
  (message) => {
1436
- setMessages((prev) => [...prev, message]);
1437
- setUserHasScrolledUp(false);
1438
- setShowScrollToBottomButton(false);
1500
+ startTransition(() => {
1501
+ setMessages((prev) => [...prev, message]);
1502
+ setUserHasScrolledUp(false);
1503
+ setShowScrollToBottomButton(false);
1504
+ });
1439
1505
  setTimeout(() => {
1440
- scrollToBottom("smooth");
1441
- }, 50);
1506
+ scrollToBottom(messages.length === 0 ? "instant" : "smooth");
1507
+ }, messages.length === 0 ? 600 : 50);
1442
1508
  },
1443
- [scrollToBottom]
1509
+ [messages.length, scrollToBottom]
1444
1510
  );
1445
1511
  const handleStreamStart = useCallback(() => {
1446
1512
  const newStreamingMessage = {
@@ -1454,8 +1520,10 @@ function ChatContent({
1454
1520
  role: newStreamingMessage.role,
1455
1521
  createdAt: newStreamingMessage.createdAt
1456
1522
  };
1457
- setStreamingMessage(newStreamingMessage);
1458
- setIsStreaming(true);
1523
+ startTransition(() => {
1524
+ setStreamingMessage(newStreamingMessage);
1525
+ setIsStreaming(true);
1526
+ });
1459
1527
  }, []);
1460
1528
  const handleToolExecutionStart = useCallback((toolName) => {
1461
1529
  setStreamingMessage((prev) => {
@@ -1527,21 +1595,30 @@ function ChatContent({
1527
1595
  }), metadata && {
1528
1596
  metadata: {
1529
1597
  logId: metadata.logId,
1530
- steps: metadata.steps
1598
+ steps: metadata.steps,
1599
+ vectors: metadata.vectors
1531
1600
  }
1532
1601
  });
1533
1602
  }
1534
1603
  if (messageToAdd) {
1535
1604
  setMessages((prev) => [...prev, messageToAdd]);
1605
+ streamingMessageRef.current = {
1606
+ id: messageToAdd.id,
1607
+ role: messageToAdd.role,
1608
+ createdAt: messageToAdd.createdAt
1609
+ };
1610
+ setTimeout(() => {
1611
+ streamingMessageRef.current = null;
1612
+ }, 1e3);
1613
+ } else {
1614
+ streamingMessageRef.current = null;
1536
1615
  }
1537
1616
  setIsStreaming(false);
1538
1617
  setStreamingMessage(null);
1539
- streamingMessageRef.current = null;
1540
1618
  },
1541
1619
  []
1542
1620
  );
1543
1621
  const handleError = useCallback((details) => {
1544
- console.log("handleError called with:", details);
1545
1622
  setIsStreaming(false);
1546
1623
  setStreamingMessage(null);
1547
1624
  streamingMessageRef.current = null;
@@ -1549,191 +1626,20 @@ function ChatContent({
1549
1626
  setShowScrollToBottomButton(false);
1550
1627
  }, []);
1551
1628
  const handleStopStreaming = useCallback(() => {
1552
- console.log("Stop streaming requested");
1553
1629
  setIsStreaming(false);
1554
1630
  setStreamingMessage(null);
1555
1631
  streamingMessageRef.current = null;
1556
1632
  }, []);
1557
- const handleAppOpen = useCallback(
1558
- (name, url) => {
1559
- setOpenAnalytic(null);
1560
- setOpenApp({ name, url });
1561
- onAppStateChange == null ? void 0 : onAppStateChange(true);
1562
- },
1563
- [onAppStateChange]
1564
- );
1565
1633
  const handleAnalyticOpen = useCallback(
1566
1634
  (name, data) => {
1567
- setOpenApp(null);
1568
1635
  setOpenAnalytic({ name, data });
1569
- onAppStateChange == null ? void 0 : onAppStateChange(true);
1570
1636
  onSidebarToggle == null ? void 0 : onSidebarToggle();
1571
1637
  },
1572
- [onAppStateChange, onSidebarToggle]
1638
+ [onSidebarToggle]
1573
1639
  );
1574
1640
  const handlePanelClose = useCallback(() => {
1575
- setOpenApp(null);
1576
1641
  setOpenAnalytic(null);
1577
- onAppStateChange == null ? void 0 : onAppStateChange(false);
1578
- }, [onAppStateChange]);
1579
- const handleWidgetSubmit = useCallback(
1580
- async (data, actionId, messageId, widgetId) => {
1581
- try {
1582
- setMessages(
1583
- (prev) => prev.map(
1584
- (message) => message.id === messageId ? __spreadProps(__spreadValues({}, message), { waiting: false }) : message
1585
- )
1586
- );
1587
- if (conversation.waiting === true) {
1588
- }
1589
- const stepData = {
1590
- action: actionId,
1591
- data,
1592
- id: widgetId,
1593
- // Use the actual widget ID passed from the form
1594
- messageId
1595
- // Backend will use this to update message.waiting = false
1596
- };
1597
- if (agentId) {
1598
- handleStreamStart();
1599
- const { stream } = await chatClient.messages.sendMessage(
1600
- agentId,
1601
- conversation.id,
1602
- "",
1603
- //`Processing form submission...`, // Simple processing message
1604
- messages,
1605
- new AbortController().signal,
1606
- debug,
1607
- stepData,
1608
- conversation.isTemporary
1609
- // Pass isTemporary flag
1610
- );
1611
- const reader = stream.getReader();
1612
- const decoder = new TextDecoder();
1613
- let done = false;
1614
- let accumulatedResponse = "";
1615
- while (!done) {
1616
- const { value, done: readerDone } = await reader.read();
1617
- done = readerDone;
1618
- if (value) {
1619
- const chunk = decoder.decode(value, {
1620
- stream: !done
1621
- });
1622
- if (chunk) {
1623
- accumulatedResponse += chunk;
1624
- handleStreamUpdate(chunk);
1625
- }
1626
- }
1627
- }
1628
- handleStreamEnd(accumulatedResponse);
1629
- if (onConversationUpdate) {
1630
- try {
1631
- await onConversationUpdate();
1632
- } catch (error) {
1633
- console.error(
1634
- "Failed to refresh conversation after form submission:",
1635
- error
1636
- );
1637
- }
1638
- }
1639
- }
1640
- } catch (error) {
1641
- console.error("Error submitting form:", error);
1642
- handleError({
1643
- title: "Form Submission Error",
1644
- message: "Failed to submit form data. Please try again."
1645
- });
1646
- }
1647
- },
1648
- [
1649
- agentId,
1650
- conversation.id,
1651
- messages,
1652
- debug,
1653
- handleStreamStart,
1654
- handleStreamUpdate,
1655
- handleStreamEnd,
1656
- handleError
1657
- ]
1658
- );
1659
- const handleWidgetCancel = useCallback(
1660
- async (messageId, widgetId) => {
1661
- try {
1662
- setMessages(
1663
- (prev) => prev.map(
1664
- (message) => message.id === messageId ? __spreadProps(__spreadValues({}, message), { waiting: false }) : message
1665
- )
1666
- );
1667
- const stepData = {
1668
- action: "cancel",
1669
- data: null,
1670
- // No form data for cancellation
1671
- id: widgetId,
1672
- messageId
1673
- };
1674
- if (agentId) {
1675
- handleStreamStart();
1676
- const { stream } = await chatClient.messages.sendMessage(
1677
- agentId,
1678
- conversation.id,
1679
- "",
1680
- //cancelMessage.content,
1681
- messages,
1682
- new AbortController().signal,
1683
- debug,
1684
- stepData,
1685
- conversation.isTemporary
1686
- // Pass isTemporary flag
1687
- );
1688
- const reader = stream.getReader();
1689
- const decoder = new TextDecoder();
1690
- let done = false;
1691
- let accumulatedResponse = "";
1692
- while (!done) {
1693
- const { value, done: readerDone } = await reader.read();
1694
- done = readerDone;
1695
- if (value) {
1696
- const chunk = decoder.decode(value, {
1697
- stream: !done
1698
- });
1699
- if (chunk) {
1700
- accumulatedResponse += chunk;
1701
- handleStreamUpdate(chunk);
1702
- }
1703
- }
1704
- }
1705
- handleStreamEnd(accumulatedResponse);
1706
- if (onConversationUpdate) {
1707
- try {
1708
- await onConversationUpdate();
1709
- } catch (error) {
1710
- console.error(
1711
- "Failed to refresh conversation after form cancellation:",
1712
- error
1713
- );
1714
- }
1715
- }
1716
- }
1717
- } catch (error) {
1718
- console.error("Error cancelling form:", error);
1719
- handleError({
1720
- title: "Form Cancellation Error",
1721
- message: "Failed to cancel form. Please try again."
1722
- });
1723
- }
1724
- },
1725
- [
1726
- agentId,
1727
- conversation.id,
1728
- messages,
1729
- debug,
1730
- handleStreamStart,
1731
- handleStreamUpdate,
1732
- handleStreamEnd,
1733
- handleError,
1734
- onConversationUpdate
1735
- ]
1736
- );
1642
+ }, []);
1737
1643
  const startResizingChatApp = useCallback(
1738
1644
  (e) => {
1739
1645
  e.preventDefault();
@@ -1821,161 +1727,264 @@ function ChatContent({
1821
1727
  style: hasOpenPanel ? { width: `${chatWidth}%` } : {},
1822
1728
  children: [
1823
1729
  isResizingChatApp && /* @__PURE__ */ jsx2("div", { className: "absolute inset-0 z-40 bg-transparent cursor-col-resize" }),
1824
- hasMessages ? (
1825
- // Standard layout with messages and input at bottom
1826
- /* @__PURE__ */ jsxs2(Fragment2, { children: [
1827
- /* @__PURE__ */ jsx2(
1828
- "div",
1829
- {
1830
- ref: scrollContainerRef,
1831
- className: `flex-1 overflow-y-auto py-6 relative ${hasOpenPanel ? "px-2 sm:px-4" : "px-4 sm:px-8"}`,
1832
- "data-ref": "scrollContainerRef",
1833
- "data-main-chat-scroll": "true",
1834
- children: /* @__PURE__ */ jsxs2("div", { className: "space-y-2", children: [
1835
- allMessages.map((message, index) => {
1836
- const isCurrentlyStreaming = isStreaming && (streamingMessage == null ? void 0 : streamingMessage.id) === message.id;
1837
- return (
1838
- // @ts-ignore - Typescript doesn't recognize dynamic imports properly
1730
+ /* @__PURE__ */ jsxs2(Fragment2, { children: [
1731
+ /* @__PURE__ */ jsxs2(
1732
+ "div",
1733
+ {
1734
+ ref: scrollContainerRef,
1735
+ className: `flex-1 overflow-y-auto py-6 relative ${hasOpenPanel ? "px-2 sm:px-4" : "px-4 sm:px-8"} ${!hasMessages ? "flex flex-col items-center justify-center" : ""}`,
1736
+ "data-ref": "scrollContainerRef",
1737
+ "data-main-chat-scroll": "true",
1738
+ children: [
1739
+ /* @__PURE__ */ jsx2(AnimatePresence, { mode: "wait", children: !hasMessages && !isReadOnly && /* @__PURE__ */ jsxs2(
1740
+ motion.div,
1741
+ {
1742
+ initial: { opacity: 0, y: 20 },
1743
+ animate: { opacity: 1, y: 0 },
1744
+ exit: { opacity: 0, y: -20 },
1745
+ transition: { duration: 0.6, type: "spring", bounce: 0.15 },
1746
+ className: "flex flex-col items-center w-full max-w-4xl mx-auto",
1747
+ children: [
1748
+ welcomeIcon && /* @__PURE__ */ jsx2(
1749
+ motion.div,
1750
+ {
1751
+ initial: { scale: 0.8, opacity: 0 },
1752
+ animate: { scale: 1, opacity: 1 },
1753
+ transition: { delay: 0.1, duration: 0.5 },
1754
+ className: "mb-4",
1755
+ children: /* @__PURE__ */ jsx2(
1756
+ "img",
1757
+ {
1758
+ src: welcomeIcon,
1759
+ alt: "Welcome icon",
1760
+ style: {
1761
+ width: welcomeIconSize,
1762
+ height: welcomeIconSize
1763
+ },
1764
+ className: "object-contain"
1765
+ }
1766
+ )
1767
+ }
1768
+ ),
1839
1769
  /* @__PURE__ */ jsx2(
1840
- DynamicChatMessage,
1770
+ motion.h2,
1841
1771
  {
1842
- message,
1843
- isStreaming: isCurrentlyStreaming,
1844
- theme,
1845
- onAppOpen: handleAppOpen,
1846
- onAnalyticOpen: handleAnalyticOpen,
1847
- onWidgetSubmit: handleWidgetSubmit,
1848
- onWidgetCancel: handleWidgetCancel
1849
- },
1850
- message.id || index
1772
+ initial: { opacity: 0, y: 10 },
1773
+ animate: { opacity: 1, y: 0 },
1774
+ transition: { delay: 0.2, duration: 0.5 },
1775
+ className: `mb-2 font-bold ${hasOpenPanel ? "text-lg" : "text-2xl"}`,
1776
+ children: welcomeMessagePrimary
1777
+ }
1778
+ ),
1779
+ /* @__PURE__ */ jsx2(
1780
+ motion.p,
1781
+ {
1782
+ initial: { opacity: 0, y: 10 },
1783
+ animate: { opacity: 1, y: 0 },
1784
+ transition: { delay: 0.3, duration: 0.5 },
1785
+ className: `text-center text-gray-500 mb-8 ${hasOpenPanel ? "text-sm max-w-xs" : "max-w-md"}`,
1786
+ children: welcomeMessageSecondary
1787
+ }
1788
+ ),
1789
+ /* @__PURE__ */ jsx2(
1790
+ motion.div,
1791
+ {
1792
+ initial: { opacity: 0, y: 10 },
1793
+ animate: { opacity: 1, y: 0 },
1794
+ transition: { delay: 0.4, duration: 0.5 },
1795
+ className: `w-full ${hasOpenPanel ? "max-w-xs" : "max-w-xl"}`,
1796
+ children: /* @__PURE__ */ jsx2(Suspense, { fallback: null, children: /* @__PURE__ */ jsx2(
1797
+ ChatInput,
1798
+ {
1799
+ conversationId: conversation.id,
1800
+ agentId,
1801
+ onAddUserMessage: handleAddUserMessage,
1802
+ onStreamStart: handleStreamStart,
1803
+ onStreamUpdate: handleStreamUpdate,
1804
+ onStreamEnd: handleStreamEnd,
1805
+ onError: handleError,
1806
+ messages: [],
1807
+ isStreaming,
1808
+ onStopStreaming: handleStopStreaming,
1809
+ disabled: isWaitingForInput,
1810
+ onThreadCreated,
1811
+ onToolExecutionStart: handleToolExecutionStart,
1812
+ onToolExecutionEnd: handleToolExecutionEnd,
1813
+ onToolStart,
1814
+ onToolInput,
1815
+ onToolFinish,
1816
+ onChunk,
1817
+ onFinish,
1818
+ accentColor,
1819
+ streaming,
1820
+ theme,
1821
+ inputBackgroundColor,
1822
+ inputBackgroundColorDark
1823
+ }
1824
+ ) })
1825
+ }
1851
1826
  )
1852
- );
1853
- }),
1854
- /* @__PURE__ */ jsx2(
1855
- "div",
1856
- {
1857
- ref: messagesEndRef,
1858
- "data-ref": "messagesEndRef"
1859
- }
1860
- )
1861
- ] })
1862
- }
1863
- ),
1864
- !isReadOnly && /* @__PURE__ */ jsxs2(
1865
- "div",
1866
- {
1867
- className: `border-t border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-900 ${hasOpenPanel ? "p-2 sm:p-3" : "p-4 sm:p-6"}`,
1868
- children: [
1869
- isWaitingForInput && /* @__PURE__ */ jsxs2("div", { className: "mb-4 p-3 bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800 rounded-lg", children: [
1870
- /* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-2", children: [
1871
- /* @__PURE__ */ jsxs2("div", { className: "flex space-x-1", children: [
1872
- /* @__PURE__ */ jsx2("div", { className: "w-2 h-2 bg-amber-500 rounded-full animate-pulse" }),
1873
- /* @__PURE__ */ jsx2(
1874
- "div",
1827
+ ]
1828
+ },
1829
+ "welcome-state"
1830
+ ) }),
1831
+ !hasMessages && isReadOnly && /* @__PURE__ */ jsxs2("div", { className: "text-center", children: [
1832
+ /* @__PURE__ */ jsx2("h3", { className: "text-lg font-medium text-gray-900 dark:text-gray-100 mb-2", children: "Log View" }),
1833
+ /* @__PURE__ */ jsx2("p", { className: "text-gray-500 dark:text-gray-400", children: "This log contains no messages." })
1834
+ ] }),
1835
+ hasMessages && /* @__PURE__ */ jsxs2(
1836
+ motion.div,
1837
+ {
1838
+ initial: { opacity: 0, y: 20 },
1839
+ animate: { opacity: 1, y: 0 },
1840
+ exit: { opacity: 0, y: -20 },
1841
+ transition: { duration: 0.4, ease: "easeOut" },
1842
+ className: "space-y-2",
1843
+ children: [
1844
+ allMessages.map((message, index) => {
1845
+ var _a;
1846
+ const isCurrentlyStreaming = isStreaming && (streamingMessage == null ? void 0 : streamingMessage.id) === message.id;
1847
+ const wasJustStreamed = ((_a = streamingMessageRef.current) == null ? void 0 : _a.id) === message.id;
1848
+ return /* @__PURE__ */ jsx2(
1849
+ motion.div,
1875
1850
  {
1876
- className: "w-2 h-2 bg-amber-500 rounded-full animate-pulse",
1877
- style: {
1878
- animationDelay: "0.2s"
1879
- }
1851
+ initial: { opacity: wasJustStreamed ? 1 : 0, x: wasJustStreamed ? 0 : -20 },
1852
+ animate: { opacity: 1, x: 0 },
1853
+ transition: {
1854
+ duration: isCurrentlyStreaming || wasJustStreamed ? 0 : 0.3,
1855
+ delay: isCurrentlyStreaming || wasJustStreamed ? 0 : index * 0.05,
1856
+ ease: "easeOut"
1857
+ },
1858
+ children: /* @__PURE__ */ jsx2(
1859
+ DynamicChatMessage,
1860
+ {
1861
+ message,
1862
+ isStreaming: isCurrentlyStreaming,
1863
+ theme,
1864
+ onAnalyticOpen: handleAnalyticOpen,
1865
+ messageBubbleColor,
1866
+ streamingText,
1867
+ streamingTextColor,
1868
+ vectorColor,
1869
+ vectorColorDark,
1870
+ agentId,
1871
+ onFeedbackChange: (messageId, feedbackPositive) => {
1872
+ setMessages((prev) => prev.map(
1873
+ (msg) => msg.id === messageId ? __spreadProps(__spreadValues({}, msg), {
1874
+ metadata: __spreadProps(__spreadValues({}, msg.metadata), {
1875
+ feedbackPositive
1876
+ })
1877
+ }) : msg
1878
+ ));
1879
+ }
1880
+ }
1881
+ )
1882
+ },
1883
+ message.id || index
1884
+ );
1885
+ }),
1886
+ /* @__PURE__ */ jsx2(
1887
+ "div",
1888
+ {
1889
+ ref: messagesEndRef,
1890
+ "data-ref": "messagesEndRef"
1891
+ }
1892
+ )
1893
+ ]
1894
+ },
1895
+ conversation.id
1896
+ )
1897
+ ]
1898
+ }
1899
+ ),
1900
+ !isReadOnly && hasMessages && /* @__PURE__ */ jsx2(
1901
+ motion.div,
1902
+ {
1903
+ layout: true,
1904
+ initial: false,
1905
+ transition: {
1906
+ layout: { duration: 0.6, type: "spring", bounce: 0.15 }
1907
+ },
1908
+ className: "relative border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-900 z-20",
1909
+ children: /* @__PURE__ */ jsxs2("div", { className: hasOpenPanel ? "p-2 sm:p-3 w-full" : "p-4 sm:p-6 w-full max-w-4xl mx-auto", children: [
1910
+ isWaitingForInput && /* @__PURE__ */ jsxs2("div", { className: "mb-4 p-3 bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800 rounded-lg", children: [
1911
+ /* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-2", children: [
1912
+ /* @__PURE__ */ jsxs2("div", { className: "flex space-x-1", children: [
1913
+ /* @__PURE__ */ jsx2("div", { className: "w-2 h-2 bg-amber-500 rounded-full animate-pulse" }),
1914
+ /* @__PURE__ */ jsx2(
1915
+ "div",
1916
+ {
1917
+ className: "w-2 h-2 bg-amber-500 rounded-full animate-pulse",
1918
+ style: {
1919
+ animationDelay: "0.2s"
1880
1920
  }
1881
- ),
1882
- /* @__PURE__ */ jsx2(
1883
- "div",
1884
- {
1885
- className: "w-2 h-2 bg-amber-500 rounded-full animate-pulse",
1886
- style: {
1887
- animationDelay: "0.4s"
1888
- }
1921
+ }
1922
+ ),
1923
+ /* @__PURE__ */ jsx2(
1924
+ "div",
1925
+ {
1926
+ className: "w-2 h-2 bg-amber-500 rounded-full animate-pulse",
1927
+ style: {
1928
+ animationDelay: "0.4s"
1889
1929
  }
1890
- )
1891
- ] }),
1892
- /* @__PURE__ */ jsx2("p", { className: "text-sm text-amber-800 dark:text-amber-200 font-medium", children: "Waiting for form input..." })
1930
+ }
1931
+ )
1893
1932
  ] }),
1894
- /* @__PURE__ */ jsx2("p", { className: "text-xs text-amber-700 dark:text-amber-300 mt-1", children: "Complete the form above or click Cancel to continue without data capture." })
1933
+ /* @__PURE__ */ jsx2("p", { className: "text-sm text-amber-800 dark:text-amber-200 font-medium", children: "Waiting for form input..." })
1895
1934
  ] }),
1896
- showScrollToBottomButton && /* @__PURE__ */ jsx2("div", { className: "absolute bottom-22 left-1/2 transform -translate-x-1/2 z-10", children: /* @__PURE__ */ jsx2(
1897
- "button",
1898
- {
1899
- onClick: () => scrollToBottom("smooth"),
1900
- className: "bg-indigo-600 hover:bg-indigo-700 text-white rounded-full p-3 shadow-lg transition-opacity duration-200 ease-in-out animate-bounce",
1901
- title: "Scroll to bottom",
1902
- children: /* @__PURE__ */ jsx2(ArrowDownCircle, { size: 24 })
1903
- }
1904
- ) }),
1905
- /* @__PURE__ */ jsx2(Suspense, { fallback: null, children: /* @__PURE__ */ jsx2(
1906
- ChatInput,
1907
- {
1908
- conversationId: conversation.id,
1909
- agentId,
1910
- debug,
1911
- onAddUserMessage: handleAddUserMessage,
1912
- onStreamStart: handleStreamStart,
1913
- onStreamUpdate: handleStreamUpdate,
1914
- onStreamEnd: handleStreamEnd,
1915
- onError: handleError,
1916
- messages,
1917
- isStreaming,
1918
- onStopStreaming: handleStopStreaming,
1919
- disabled: isWaitingForInput,
1920
- onThreadCreated,
1921
- onToolExecutionStart: handleToolExecutionStart,
1922
- onToolExecutionEnd: handleToolExecutionEnd
1923
- }
1924
- ) })
1925
- ]
1926
- }
1927
- )
1928
- ] })
1929
- ) : (
1930
- // Empty state with centered input - or read-only message for log mode
1931
- /* @__PURE__ */ jsx2("div", { className: "flex h-full flex-col items-center justify-center p-4", children: isReadOnly ? /* @__PURE__ */ jsxs2("div", { className: "text-center", children: [
1932
- /* @__PURE__ */ jsx2("h3", { className: "text-lg font-medium text-gray-900 dark:text-gray-100 mb-2", children: "Log View" }),
1933
- /* @__PURE__ */ jsx2("p", { className: "text-gray-500 dark:text-gray-400", children: "This log contains no messages." })
1934
- ] }) : /* @__PURE__ */ jsxs2(Fragment2, { children: [
1935
- /* @__PURE__ */ jsxs2("div", { className: "mb-8 flex flex-col items-center", children: [
1936
- /* @__PURE__ */ jsx2("div", { className: "mb-4 text-gray-500" }),
1937
- /* @__PURE__ */ jsx2(
1938
- "h2",
1939
- {
1940
- className: `mb-2 font-bold ${hasOpenPanel ? "text-lg" : "text-2xl"}`,
1941
- children: "How can I help you today?"
1942
- }
1943
- ),
1944
- /* @__PURE__ */ jsx2(
1945
- "p",
1946
- {
1947
- className: `text-center text-gray-500 ${hasOpenPanel ? "text-sm max-w-xs" : "max-w-md"}`,
1948
- children: "Feel free to ask any question you like \u2014 just be precise, as if you're speaking to a real person."
1949
- }
1950
- )
1951
- ] }),
1952
- /* @__PURE__ */ jsx2(
1953
- "div",
1954
- {
1955
- className: `w-full ${hasOpenPanel ? "max-w-sm" : "max-w-2xl"} px-4`,
1956
- children: /* @__PURE__ */ jsx2(Suspense, { fallback: null, children: /* @__PURE__ */ jsx2(
1935
+ /* @__PURE__ */ jsx2("p", { className: "text-xs text-amber-700 dark:text-amber-300 mt-1", children: "Complete the form above or click Cancel to continue without data capture." })
1936
+ ] }),
1937
+ showScrollToBottomButton && /* @__PURE__ */ jsx2("div", { className: "absolute bottom-22 left-1/2 transform -translate-x-1/2 z-10", children: /* @__PURE__ */ jsx2(
1938
+ "button",
1939
+ {
1940
+ onClick: () => scrollToBottom("smooth"),
1941
+ className: "text-white rounded-full p-3 shadow-lg transition-all duration-200 ease-in-out animate-bounce",
1942
+ style: {
1943
+ backgroundColor: scrollButtonColor
1944
+ },
1945
+ onMouseEnter: (e) => {
1946
+ e.currentTarget.style.filter = "brightness(0.85)";
1947
+ },
1948
+ onMouseLeave: (e) => {
1949
+ e.currentTarget.style.filter = "brightness(1)";
1950
+ },
1951
+ title: "Scroll to bottom",
1952
+ children: /* @__PURE__ */ jsx2(ArrowDownCircle, { size: 24 })
1953
+ }
1954
+ ) }),
1955
+ /* @__PURE__ */ jsx2(Suspense, { fallback: null, children: /* @__PURE__ */ jsx2(
1957
1956
  ChatInput,
1958
1957
  {
1959
1958
  conversationId: conversation.id,
1960
1959
  agentId,
1961
- debug,
1962
1960
  onAddUserMessage: handleAddUserMessage,
1963
1961
  onStreamStart: handleStreamStart,
1964
1962
  onStreamUpdate: handleStreamUpdate,
1965
1963
  onStreamEnd: handleStreamEnd,
1966
1964
  onError: handleError,
1967
- messages: [],
1965
+ messages,
1968
1966
  isStreaming,
1969
1967
  onStopStreaming: handleStopStreaming,
1968
+ disabled: isWaitingForInput,
1970
1969
  onThreadCreated,
1971
1970
  onToolExecutionStart: handleToolExecutionStart,
1972
- onToolExecutionEnd: handleToolExecutionEnd
1971
+ onToolExecutionEnd: handleToolExecutionEnd,
1972
+ onToolStart,
1973
+ onToolInput,
1974
+ onToolFinish,
1975
+ onChunk,
1976
+ onFinish,
1977
+ accentColor,
1978
+ streaming,
1979
+ theme,
1980
+ inputBackgroundColor,
1981
+ inputBackgroundColorDark
1973
1982
  }
1974
1983
  ) })
1975
- }
1976
- )
1977
- ] }) })
1978
- )
1984
+ ] })
1985
+ }
1986
+ )
1987
+ ] })
1979
1988
  ]
1980
1989
  }
1981
1990
  ),
@@ -1999,8 +2008,8 @@ function ChatContent({
1999
2008
  /* @__PURE__ */ jsx2(
2000
2009
  "div",
2001
2010
  {
2002
- className: `w-8 h-8 rounded-lg flex items-center justify-center ${openApp ? "bg-blue-500" : "bg-emerald-500"}`,
2003
- children: openApp ? /* @__PURE__ */ jsx2(
2011
+ className: `w-8 h-8 rounded-lg flex items-center justify-center ${false ? "bg-blue-500" : "bg-emerald-500"}`,
2012
+ children: false ? /* @__PURE__ */ jsx2(
2004
2013
  "svg",
2005
2014
  {
2006
2015
  className: "w-5 h-5 text-white",
@@ -2040,7 +2049,7 @@ function ChatContent({
2040
2049
  }
2041
2050
  ),
2042
2051
  /* @__PURE__ */ jsxs2("div", { children: [
2043
- /* @__PURE__ */ jsx2("h3", { className: "font-semibold text-gray-800 dark:text-gray-200", children: openApp ? openApp.name : "Analytics Dashboard" }),
2052
+ /* @__PURE__ */ jsx2("h3", { className: "font-semibold text-gray-800 dark:text-gray-200", children: false ? "openApp" : "Analytics Dashboard" }),
2044
2053
  openAnalytic && /* @__PURE__ */ jsx2("p", { className: "text-xs text-gray-500 dark:text-gray-400", children: openAnalytic.name })
2045
2054
  ] })
2046
2055
  ] }),
@@ -2062,12 +2071,10 @@ function ChatContent({
2062
2071
  ] }),
2063
2072
  /* @__PURE__ */ jsxs2("div", { className: "flex-1 relative h-full", children: [
2064
2073
  isResizingChatApp && /* @__PURE__ */ jsx2("div", { className: "absolute inset-0 z-50 bg-transparent cursor-col-resize" }),
2065
- openApp ? /* @__PURE__ */ jsx2(
2074
+ false ? /* @__PURE__ */ jsx2(
2066
2075
  "iframe",
2067
2076
  {
2068
- src: openApp.url,
2069
2077
  className: "w-full h-full border-0",
2070
- title: openApp.name,
2071
2078
  allow: "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",
2072
2079
  sandbox: "allow-scripts allow-same-origin allow-forms allow-popups allow-top-navigation-by-user-activation"
2073
2080
  }
@@ -2149,9 +2156,36 @@ import { Fragment as Fragment3, jsx as jsx4, jsxs as jsxs4 } from "react/jsx-run
2149
2156
  var useIsomorphicLayoutEffect = typeof window !== "undefined" ? useLayoutEffect : useEffect4;
2150
2157
  function NeptuneChatBot({
2151
2158
  agentId: propAgentId,
2152
- debug: propDebug = false,
2153
2159
  theme: propTheme = "light",
2154
- localDebug: propLocalDebug
2160
+ localDebug: propLocalDebug,
2161
+ title: propTitle = "Naia",
2162
+ messageBubbleColor = "#E5E3F8",
2163
+ messageBubbleColorDark = "rgba(168, 140, 250, 0.3)",
2164
+ accentColor = "#8B7FD9",
2165
+ accentColorDark = "#A88CFA",
2166
+ scrollButtonColor = "#6366F1",
2167
+ scrollButtonColorDark = "#818CF8",
2168
+ streamingText = "NAIA is working on it...",
2169
+ streamingTextColor = "#2563EB",
2170
+ streamingTextColorDark = "#60A5FA",
2171
+ welcomeMessagePrimary = "How can I help you today?",
2172
+ welcomeMessageSecondary = "Feel free to ask any question you like \u2014 just be precise, as if you're speaking to a real person.",
2173
+ welcomeIcon,
2174
+ welcomeIconSize = "4rem",
2175
+ streaming = true,
2176
+ sidebarBackgroundColor = "#f9f9f9",
2177
+ onToolStart,
2178
+ onToolInput,
2179
+ onToolFinish,
2180
+ onChunk,
2181
+ onFinish,
2182
+ sidebarBackgroundColorDark = "#171717",
2183
+ inputBackgroundColor = "#ffffff",
2184
+ inputBackgroundColorDark = "#303030",
2185
+ headerBackgroundColor = "#ffffff",
2186
+ headerBackgroundColorDark = "#171717",
2187
+ vectorColor = "#9333EA",
2188
+ vectorColorDark = "#A855F7"
2155
2189
  }) {
2156
2190
  const [conversations, setConversations] = useState4([]);
2157
2191
  const [selectedConversationId, setSelectedConversationId] = useState4(null);
@@ -2167,14 +2201,12 @@ function NeptuneChatBot({
2167
2201
  const [conversationToRename, setConversationToRename] = useState4(null);
2168
2202
  const [theme, setTheme] = useState4(propTheme);
2169
2203
  const [agentId] = useState4(propAgentId);
2170
- const [debug] = useState4(propDebug);
2171
2204
  const [initialAssistantIdChecked] = useState4(true);
2172
2205
  const [initialLoadComplete, setInitialLoadComplete] = useState4(false);
2173
2206
  const [openMenuId, setOpenMenuId] = useState4(null);
2174
2207
  const [isCreatingConversation, setIsCreatingConversation] = useState4(false);
2175
2208
  const [sidebarWidth, setSidebarWidth] = useState4(250);
2176
2209
  const [isResizing, setIsResizing] = useState4(false);
2177
- const [hasOpenApp, setHasOpenApp] = useState4(false);
2178
2210
  const titleInputRef = useRef2(null);
2179
2211
  const resizeHandleRef = useRef2(null);
2180
2212
  const hasFetchedRef = useRef2(false);
@@ -2196,9 +2228,6 @@ function NeptuneChatBot({
2196
2228
  useEffect4(() => {
2197
2229
  applyTheme(theme);
2198
2230
  }, [theme, applyTheme]);
2199
- const handleAppStateChange = useCallback2((hasApp) => {
2200
- setHasOpenApp(hasApp);
2201
- }, []);
2202
2231
  const toggleTheme = () => {
2203
2232
  const newTheme = theme === "dark" ? "light" : "dark";
2204
2233
  setTheme(newTheme);
@@ -2260,7 +2289,7 @@ function NeptuneChatBot({
2260
2289
  };
2261
2290
  conversations2.forEach((conversation) => {
2262
2291
  try {
2263
- const convDate = new Date(parseInt(conversation.updatedAt));
2292
+ const convDate = new Date(conversation.updatedAt);
2264
2293
  if (convDate >= today) {
2265
2294
  groups["Today"].push(conversation);
2266
2295
  } else if (convDate >= yesterday) {
@@ -2278,27 +2307,13 @@ function NeptuneChatBot({
2278
2307
  });
2279
2308
  Object.keys(groups).forEach((key) => {
2280
2309
  groups[key].sort(
2281
- (a, b) => new Date(parseInt(b.updatedAt)).getTime() - new Date(parseInt(a.updatedAt)).getTime()
2310
+ (a, b) => new Date(b.updatedAt).getTime() - new Date(a.updatedAt).getTime()
2282
2311
  );
2283
2312
  });
2284
2313
  return groups;
2285
2314
  },
2286
2315
  []
2287
2316
  );
2288
- const isJson = useCallback2((content) => {
2289
- if (typeof content === "object" && content !== null) {
2290
- return Array.isArray(content) || Object.prototype.toString.call(content) === "[object Object]";
2291
- }
2292
- if (typeof content === "string") {
2293
- try {
2294
- const parsed = JSON.parse(content);
2295
- return typeof parsed === "object" && parsed !== null;
2296
- } catch (e) {
2297
- return false;
2298
- }
2299
- }
2300
- return false;
2301
- }, []);
2302
2317
  useEffect4(() => {
2303
2318
  const fetchConversations = async () => {
2304
2319
  if (!initialAssistantIdChecked || hasFetchedRef.current) {
@@ -2317,44 +2332,15 @@ function NeptuneChatBot({
2317
2332
  return;
2318
2333
  }
2319
2334
  setConversations(data);
2320
- if (data.length > 0) {
2321
- const validConversations = data.filter(
2322
- (conv) => conv && conv.updatedAt
2323
- );
2324
- if (validConversations.length > 0) {
2325
- try {
2326
- const mostRecent = [...validConversations].sort(
2327
- (a, b) => new Date(parseInt(b.updatedAt)).getTime() - new Date(parseInt(a.updatedAt)).getTime()
2328
- )[0];
2329
- selectConversation(mostRecent.id);
2330
- } catch (sortError) {
2331
- console.error(
2332
- "Error sorting conversations:",
2333
- sortError
2334
- );
2335
- selectConversation(validConversations[0].id);
2336
- }
2337
- }
2338
- } else {
2339
- if (agentId && !isCreatingConversation) {
2340
- try {
2341
- setIsCreatingConversation(true);
2342
- const newConversation = await chatClient.conversations.create(
2343
- "New Chat",
2344
- agentId
2345
- );
2346
- setConversations([newConversation]);
2347
- selectConversation(newConversation.id);
2348
- } catch (createError) {
2349
- } finally {
2350
- setIsCreatingConversation(false);
2351
- }
2352
- } else {
2353
- console.warn(
2354
- "Cannot create conversation: agentId not available or already creating"
2355
- );
2356
- }
2357
- }
2335
+ const tempConversation = {
2336
+ id: `temp-${Date.now()}`,
2337
+ title: "New Chat",
2338
+ messages: [],
2339
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
2340
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
2341
+ isTemporary: true
2342
+ };
2343
+ setSelectedConversation(tempConversation);
2358
2344
  } catch (error) {
2359
2345
  console.error("Failed to fetch conversations:", error);
2360
2346
  } finally {
@@ -2407,7 +2393,6 @@ function NeptuneChatBot({
2407
2393
  } else {
2408
2394
  loadConversationData(id);
2409
2395
  }
2410
- setHasOpenApp(false);
2411
2396
  }, []);
2412
2397
  const createNewConversation = async () => {
2413
2398
  try {
@@ -2429,36 +2414,51 @@ function NeptuneChatBot({
2429
2414
  };
2430
2415
  setSelectedConversationId(tempConversation.id);
2431
2416
  setSelectedConversation(tempConversation);
2432
- setConversations((prev) => [tempConversation, ...prev]);
2433
- setHasOpenApp(false);
2434
2417
  } catch (error) {
2435
2418
  console.error("Failed to create new conversation:", error);
2436
2419
  }
2437
2420
  };
2438
2421
  const handleThreadCreated = useCallback2(
2439
- async (oldId, newId) => {
2440
- console.log(`Thread created: ${oldId} -> ${newId}`);
2441
- setConversations(
2442
- (prev) => prev.map(
2443
- (conv) => conv.id === oldId ? __spreadProps(__spreadValues({}, conv), { id: newId, isTemporary: false }) : conv
2444
- )
2445
- );
2446
- if (selectedConversationId === oldId) {
2447
- setSelectedConversationId(newId);
2448
- try {
2449
- const updatedConv = await chatClient.conversations.get(
2450
- newId
2451
- );
2422
+ async (oldId, newId, backendConversation) => {
2423
+ startTransition2(() => {
2424
+ if (backendConversation) {
2425
+ const updatedConv = __spreadProps(__spreadValues({}, backendConversation), {
2426
+ isTemporary: false
2427
+ });
2428
+ setConversations((prev) => {
2429
+ const filtered = prev.filter((conv) => conv.id !== oldId);
2430
+ return [updatedConv, ...filtered];
2431
+ });
2432
+ setSelectedConversationId(newId);
2452
2433
  setSelectedConversation(updatedConv);
2453
- } catch (error) {
2454
- console.error(
2455
- "Failed to fetch updated conversation:",
2456
- error
2457
- );
2434
+ } else {
2435
+ setSelectedConversation((currentSelected) => {
2436
+ if (currentSelected && currentSelected.id === oldId) {
2437
+ const updatedConv = __spreadProps(__spreadValues({}, currentSelected), {
2438
+ id: newId,
2439
+ isTemporary: false
2440
+ });
2441
+ setConversations((prev) => {
2442
+ const existingIndex = prev.findIndex(
2443
+ (conv) => conv.id === oldId || conv.id === newId
2444
+ );
2445
+ if (existingIndex !== -1) {
2446
+ const updated = [...prev];
2447
+ updated[existingIndex] = updatedConv;
2448
+ return updated;
2449
+ } else {
2450
+ return [updatedConv, ...prev];
2451
+ }
2452
+ });
2453
+ setSelectedConversationId(newId);
2454
+ return updatedConv;
2455
+ }
2456
+ return currentSelected;
2457
+ });
2458
2458
  }
2459
- }
2459
+ });
2460
2460
  },
2461
- [selectedConversationId]
2461
+ []
2462
2462
  );
2463
2463
  const deleteConversation = async (id) => {
2464
2464
  try {
@@ -2468,27 +2468,16 @@ function NeptuneChatBot({
2468
2468
  );
2469
2469
  setConversations(updatedConversations);
2470
2470
  if (selectedConversationId === id) {
2471
- if (updatedConversations.length > 0) {
2472
- selectConversation(updatedConversations[0].id);
2473
- } else {
2474
- setSelectedConversationId(null);
2475
- setSelectedConversation(null);
2476
- if (agentId) {
2477
- try {
2478
- const newConversation = await chatClient.conversations.create(
2479
- "New Chat",
2480
- agentId
2481
- );
2482
- setConversations([newConversation]);
2483
- selectConversation(newConversation.id);
2484
- } catch (error) {
2485
- console.error(
2486
- "Failed to create new conversation after deletion:",
2487
- error
2488
- );
2489
- }
2490
- }
2491
- }
2471
+ const tempConversation = {
2472
+ id: `temp-${Date.now()}`,
2473
+ title: "New Chat",
2474
+ messages: [],
2475
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
2476
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
2477
+ isTemporary: true
2478
+ };
2479
+ setSelectedConversationId(tempConversation.id);
2480
+ setSelectedConversation(tempConversation);
2492
2481
  }
2493
2482
  } catch (error) {
2494
2483
  console.error("Failed to delete conversation:", error);
@@ -2636,198 +2625,263 @@ function NeptuneChatBot({
2636
2625
  )
2637
2626
  ] })
2638
2627
  ] }) }),
2639
- sidebarOpen && /* @__PURE__ */ jsx4(
2640
- "div",
2628
+ /* @__PURE__ */ jsx4(AnimatePresence2, { children: sidebarOpen && /* @__PURE__ */ jsx4(
2629
+ motion2.div,
2641
2630
  {
2631
+ initial: { opacity: 0 },
2632
+ animate: { opacity: 1 },
2633
+ exit: { opacity: 0 },
2634
+ transition: { duration: 0.3 },
2642
2635
  className: "lg:hidden fixed inset-0 bg-black bg-opacity-50 z-10",
2643
2636
  onClick: () => setSidebarOpen(false),
2644
2637
  "aria-hidden": "true"
2645
2638
  }
2646
- ),
2647
- /* @__PURE__ */ jsx4(
2648
- "div",
2639
+ ) }),
2640
+ /* @__PURE__ */ jsx4(AnimatePresence2, { children: sidebarOpen && /* @__PURE__ */ jsx4(
2641
+ motion2.div,
2649
2642
  {
2650
- className: `bg-[#f9f9f9] dark:bg-gray-900 dark:!bg-gray-900 border-r border-gray-200 dark:border-gray-700 h-full relative z-20 ${sidebarOpen ? "block" : "hidden"}`,
2651
- style: {
2652
- width: sidebarOpen ? `${sidebarWidth}px` : "0"
2643
+ initial: { width: 0, opacity: 0 },
2644
+ animate: { width: sidebarWidth, opacity: 1 },
2645
+ exit: { width: 0, opacity: 0 },
2646
+ transition: {
2647
+ duration: 0.3,
2648
+ ease: [0.4, 0, 0.2, 1]
2653
2649
  },
2654
- children: /* @__PURE__ */ jsx4("div", { className: "flex flex-col h-full", children: /* @__PURE__ */ jsx4("div", { className: "flex-1 overflow-y-auto p-2 bg-[#f9f9f9] dark:bg-[#171717]", children: /* @__PURE__ */ jsx4("div", { className: "flex-1", children: isLoading ? /* @__PURE__ */ jsx4("div", { className: "space-y-4" }) : conversations.length > 0 ? /* @__PURE__ */ jsx4("div", { className: "space-y-0", children: (() => {
2655
- const groupedConversations = categorizeConversationsByDate(
2656
- conversations
2657
- );
2658
- return Object.entries(
2659
- groupedConversations
2660
- ).map(
2661
- ([
2662
- groupName,
2663
- groupConversations
2664
- ]) => {
2665
- if (groupConversations.length === 0)
2666
- return null;
2667
- return /* @__PURE__ */ jsxs4(
2668
- "div",
2669
- {
2670
- className: "mb-4",
2671
- children: [
2672
- /* @__PURE__ */ jsx4("div", { className: "text-xs font-medium text-gray-500 dark:text-gray-400 px-2 py-2 uppercase tracking-wide", children: groupName }),
2673
- /* @__PURE__ */ jsx4("div", { className: "space-y-0", children: groupConversations.map(
2674
- (conversation) => {
2675
- var _a;
2676
- const hasWaitingMessages = conversation.waiting === true || ((_a = conversation.messages) == null ? void 0 : _a.some(
2677
- (message) => message.waiting === true
2678
- )) || false;
2679
- return /* @__PURE__ */ jsxs4(
2680
- "div",
2681
- {
2682
- onClick: () => {
2683
- selectConversation(
2684
- conversation.id
2685
- );
2686
- if (window.innerWidth < 1024) {
2687
- setSidebarOpen(
2688
- false
2689
- );
2690
- }
2691
- },
2692
- className: `flex items-center w-full pl-4 pr-2 py-2 mb-1 rounded-xl text-left group cursor-pointer ${selectedConversationId === conversation.id ? "bg-naia-200 text-gray-800 dark:text-gray-200" : "text-gray-800 dark:text-gray-100 conversation-item-background"}`,
2693
- children: [
2694
- /* @__PURE__ */ jsx4("div", { className: "flex-1 min-w-0", children: /* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-2", children: [
2695
- /* @__PURE__ */ jsx4("div", { className: "font-medium overflow-hidden text-ellipsis whitespace-nowrap", children: conversation.title || "New Chat" }),
2696
- hasWaitingMessages && /* @__PURE__ */ jsx4("div", { className: "flex-shrink-0", children: /* @__PURE__ */ jsx4(
2697
- "div",
2698
- {
2699
- className: "w-2 h-2 bg-amber-500 dark:bg-amber-400 rounded-full animate-pulse",
2700
- title: "Waiting for input"
2650
+ className: "bg-[#f9f9f9] dark:bg-gray-900 dark:!bg-gray-900 border-r border-gray-200 dark:border-gray-700 h-full relative z-20 overflow-hidden",
2651
+ children: /* @__PURE__ */ jsx4("div", { className: "flex flex-col h-full", children: /* @__PURE__ */ jsx4(
2652
+ "div",
2653
+ {
2654
+ className: "flex-1 overflow-y-auto p-2",
2655
+ style: {
2656
+ backgroundColor: theme === "dark" ? sidebarBackgroundColorDark : sidebarBackgroundColor
2657
+ },
2658
+ children: /* @__PURE__ */ jsx4("div", { className: "flex-1", children: isLoading ? /* @__PURE__ */ jsx4("div", { className: "space-y-4" }) : conversations.length > 0 ? /* @__PURE__ */ jsx4("div", { className: "space-y-0", children: (() => {
2659
+ const groupedConversations = categorizeConversationsByDate(
2660
+ conversations
2661
+ );
2662
+ return Object.entries(
2663
+ groupedConversations
2664
+ ).map(
2665
+ ([
2666
+ groupName,
2667
+ groupConversations
2668
+ ]) => {
2669
+ if (groupConversations.length === 0)
2670
+ return null;
2671
+ return /* @__PURE__ */ jsxs4(
2672
+ "div",
2673
+ {
2674
+ className: "mb-4",
2675
+ children: [
2676
+ /* @__PURE__ */ jsx4("div", { className: "text-xs font-medium text-gray-500 dark:text-gray-400 px-2 py-2 uppercase tracking-wide", children: groupName }),
2677
+ /* @__PURE__ */ jsx4("div", { className: "space-y-0", children: groupConversations.map(
2678
+ (conversation) => {
2679
+ var _a;
2680
+ const hasWaitingMessages = conversation.waiting === true || ((_a = conversation.messages) == null ? void 0 : _a.some(
2681
+ (message) => message.waiting === true
2682
+ )) || false;
2683
+ return /* @__PURE__ */ jsxs4(
2684
+ "div",
2685
+ {
2686
+ onClick: () => {
2687
+ selectConversation(
2688
+ conversation.id
2689
+ );
2690
+ if (window.innerWidth < 1024) {
2691
+ setSidebarOpen(
2692
+ false
2693
+ );
2701
2694
  }
2702
- ) })
2703
- ] }) }),
2704
- !conversation.isTemporary && /* @__PURE__ */ jsxs4("div", { className: "relative", children: [
2705
- /* @__PURE__ */ jsx4(
2706
- "button",
2707
- {
2708
- onClick: (e) => toggleConversationMenu(
2709
- e,
2710
- conversation.id
2711
- ),
2712
- className: "p-1.5 cursor-pointer rounded-full text-gray-500 hover:text-gray-700 dark:hover:text-gray-300 opacity-0 hover:bg-gray-300 dark:hover:bg-gray-700 group-hover:opacity-100 transition-opacity",
2713
- "aria-label": "More options",
2714
- children: /* @__PURE__ */ jsx4(
2715
- MoreHorizontal,
2695
+ },
2696
+ className: `flex items-center w-full pl-4 pr-2 py-2 mb-1 rounded-xl text-left group cursor-pointer ${selectedConversationId === conversation.id ? "text-gray-800 dark:text-gray-200" : "text-gray-800 dark:text-gray-100 conversation-item-background"}`,
2697
+ style: selectedConversationId === conversation.id ? {
2698
+ backgroundColor: theme === "dark" ? messageBubbleColorDark : messageBubbleColor
2699
+ } : void 0,
2700
+ children: [
2701
+ /* @__PURE__ */ jsx4("div", { className: "flex-1 min-w-0", children: /* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-2", children: [
2702
+ /* @__PURE__ */ jsx4("div", { className: "font-medium overflow-hidden text-ellipsis whitespace-nowrap", children: conversation.title || "New Chat" }),
2703
+ hasWaitingMessages && /* @__PURE__ */ jsx4("div", { className: "flex-shrink-0", children: /* @__PURE__ */ jsx4(
2704
+ "div",
2716
2705
  {
2717
- size: 16
2706
+ className: "w-2 h-2 bg-amber-500 dark:bg-amber-400 rounded-full animate-pulse",
2707
+ title: "Waiting for input"
2718
2708
  }
2719
- )
2720
- }
2721
- ),
2722
- openMenuId === conversation.id && /* @__PURE__ */ jsxs4("div", { className: "absolute right-0 top-10 w-40 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-xl shadow-lg z-50 p-2", children: [
2723
- /* @__PURE__ */ jsxs4(
2724
- "button",
2725
- {
2726
- onClick: (e) => handleRenameClick(
2727
- e,
2728
- conversation
2729
- ),
2730
- className: "w-full text-left px-3 py-2 text-md flex cursor-pointer items-center gap-2 hover:bg-gray-300 dark:hover:bg-gray-700 rounded-md",
2731
- children: [
2732
- /* @__PURE__ */ jsx4(
2733
- Edit,
2734
- {
2735
- size: 14
2736
- }
2709
+ ) })
2710
+ ] }) }),
2711
+ !conversation.isTemporary && /* @__PURE__ */ jsxs4("div", { className: "relative", children: [
2712
+ /* @__PURE__ */ jsx4(
2713
+ "button",
2714
+ {
2715
+ onClick: (e) => toggleConversationMenu(
2716
+ e,
2717
+ conversation.id
2737
2718
  ),
2738
- "Rename"
2739
- ]
2740
- }
2741
- ),
2742
- /* @__PURE__ */ jsxs4(
2743
- "button",
2744
- {
2745
- onClick: (e) => handleDeleteClick(
2746
- e,
2747
- conversation.id
2748
- ),
2749
- className: "w-full text-left px-3 py-2 text-md text-red-600 cursor-pointer flex items-center gap-2 hover:bg-gray-300 dark:hover:bg-gray-700 rounded-md",
2750
- children: [
2751
- /* @__PURE__ */ jsx4(
2752
- Trash2,
2719
+ className: "p-1.5 cursor-pointer rounded-full text-gray-500 hover:text-gray-700 dark:hover:text-gray-300 opacity-0 hover:bg-gray-300 dark:hover:bg-gray-700 group-hover:opacity-100 transition-opacity",
2720
+ "aria-label": "More options",
2721
+ children: /* @__PURE__ */ jsx4(
2722
+ MoreHorizontal,
2753
2723
  {
2754
- size: 14
2724
+ size: 16
2755
2725
  }
2756
- ),
2757
- "Delete"
2758
- ]
2759
- }
2760
- )
2761
- ] })
2762
- ] })
2763
- ]
2764
- },
2765
- conversation.id
2766
- );
2767
- }
2768
- ) })
2769
- ]
2770
- },
2771
- groupName
2772
- );
2773
- }
2774
- ).filter(Boolean);
2775
- })() }) : /* @__PURE__ */ jsx4("div", { className: "text-center py-8 text-gray-500", children: "No conversations yet" }) }) }) })
2726
+ )
2727
+ }
2728
+ ),
2729
+ openMenuId === conversation.id && /* @__PURE__ */ jsxs4("div", { className: "absolute right-0 top-10 w-40 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-xl shadow-lg z-50 p-2", children: [
2730
+ /* @__PURE__ */ jsxs4(
2731
+ "button",
2732
+ {
2733
+ onClick: (e) => handleRenameClick(
2734
+ e,
2735
+ conversation
2736
+ ),
2737
+ className: "w-full text-left px-3 py-2 text-md flex cursor-pointer items-center gap-2 hover:bg-gray-300 dark:hover:bg-gray-700 rounded-md",
2738
+ children: [
2739
+ /* @__PURE__ */ jsx4(
2740
+ Edit,
2741
+ {
2742
+ size: 14
2743
+ }
2744
+ ),
2745
+ "Rename"
2746
+ ]
2747
+ }
2748
+ ),
2749
+ /* @__PURE__ */ jsxs4(
2750
+ "button",
2751
+ {
2752
+ onClick: (e) => handleDeleteClick(
2753
+ e,
2754
+ conversation.id
2755
+ ),
2756
+ className: "w-full text-left px-3 py-2 text-md text-red-600 cursor-pointer flex items-center gap-2 hover:bg-gray-300 dark:hover:bg-gray-700 rounded-md",
2757
+ children: [
2758
+ /* @__PURE__ */ jsx4(
2759
+ Trash2,
2760
+ {
2761
+ size: 14
2762
+ }
2763
+ ),
2764
+ "Delete"
2765
+ ]
2766
+ }
2767
+ )
2768
+ ] })
2769
+ ] })
2770
+ ]
2771
+ },
2772
+ conversation.id
2773
+ );
2774
+ }
2775
+ ) })
2776
+ ]
2777
+ },
2778
+ groupName
2779
+ );
2780
+ }
2781
+ ).filter(Boolean);
2782
+ })() }) : /* @__PURE__ */ jsx4("div", { className: "text-center py-8 text-gray-500", children: "No conversations yet" }) })
2783
+ }
2784
+ ) })
2776
2785
  }
2777
- ),
2778
- sidebarOpen && /* @__PURE__ */ jsx4(
2779
- "div",
2786
+ ) }),
2787
+ /* @__PURE__ */ jsx4(AnimatePresence2, { children: sidebarOpen && /* @__PURE__ */ jsx4(
2788
+ motion2.div,
2780
2789
  {
2781
- ref: resizeHandleRef,
2782
- onMouseDown: startResizing,
2783
- className: "w-1 hover:w-2 bg-gray-300 dark:bg-gray-700 h-full cursor-col-resize transition-all hover:bg-indigo-500 dark:hover:bg-indigo-400 z-30 relative",
2784
- title: "Drag to resize"
2785
- }
2786
- ),
2787
- /* @__PURE__ */ jsxs4("div", { className: "flex-1 flex flex-col overflow-hidden", children: [
2788
- /* @__PURE__ */ jsxs4("header", { className: "h-14 border-b border-gray-200 dark:border-gray-700 flex items-center justify-between px-4 bg-white dark:bg-gray-900", children: [
2789
- /* @__PURE__ */ jsx4("div", { className: "flex items-center", children: /* @__PURE__ */ jsxs4(Fragment3, { children: [
2790
- /* @__PURE__ */ jsx4(
2791
- "button",
2792
- {
2793
- onClick: () => setSidebarOpen(!sidebarOpen),
2794
- className: "p-2 cursor-pointer rounded-lg text-gray-500 hover:bg-naia-hover disabled:opacity-50 transition-colors",
2795
- title: "Toggle Sidebar",
2796
- "aria-label": "Toggle Sidebar",
2797
- children: sidebarOpen ? /* @__PURE__ */ jsx4(PanelRightOpen, { size: 20 }) : /* @__PURE__ */ jsx4(PanelRightClose, { size: 20 })
2798
- }
2799
- ),
2800
- /* @__PURE__ */ jsx4(
2801
- "button",
2802
- {
2803
- onClick: createNewConversation,
2804
- className: "p-2 cursor-pointer rounded-lg text-gray-500 hover:bg-naia-hover disabled:opacity-50 transition-colors",
2805
- title: "New Chat",
2806
- "aria-label": "New Chat",
2807
- children: /* @__PURE__ */ jsx4(MessageCirclePlus, { size: 20 })
2808
- }
2809
- )
2810
- ] }) }),
2811
- /* @__PURE__ */ jsx4("div", { className: "flex items-center justify-center", children: /* @__PURE__ */ jsx4("div", { className: "relative flex items-center", children: /* @__PURE__ */ jsx4("span", { className: "text-2xl font-bold mr-1", children: "Naia" }) }) }),
2812
- /* @__PURE__ */ jsx4("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ jsx4(
2813
- "button",
2790
+ initial: { opacity: 0 },
2791
+ animate: { opacity: 1 },
2792
+ exit: { opacity: 0 },
2793
+ transition: { duration: 0.3 },
2794
+ children: /* @__PURE__ */ jsx4(
2795
+ "div",
2814
2796
  {
2815
- onClick: toggleTheme,
2816
- className: "p-2 cursor-pointer rounded-lg text-gray-500 hover:bg-naia-hover transition-colors",
2817
- title: `Switch to ${theme === "dark" ? "light" : "dark"} mode`,
2818
- "aria-label": `Switch to ${theme === "dark" ? "light" : "dark"} mode`,
2819
- children: theme === "dark" ? /* @__PURE__ */ jsx4(Sun, { size: 20 }) : /* @__PURE__ */ jsx4(Moon, { size: 20 })
2797
+ ref: resizeHandleRef,
2798
+ onMouseDown: startResizing,
2799
+ className: "w-1 hover:w-2 bg-gray-300 dark:bg-gray-700 h-full cursor-col-resize transition-all hover:bg-indigo-500 dark:hover:bg-indigo-400 z-30 relative",
2800
+ title: "Drag to resize"
2820
2801
  }
2821
- ) })
2822
- ] }),
2802
+ )
2803
+ }
2804
+ ) }),
2805
+ /* @__PURE__ */ jsxs4("div", { className: "flex-1 flex flex-col overflow-hidden", children: [
2806
+ /* @__PURE__ */ jsxs4(
2807
+ "header",
2808
+ {
2809
+ className: "h-14 border-b border-gray-200 dark:border-gray-700 flex items-center justify-between px-4",
2810
+ style: {
2811
+ backgroundColor: theme === "dark" ? headerBackgroundColorDark : headerBackgroundColor
2812
+ },
2813
+ children: [
2814
+ /* @__PURE__ */ jsx4("div", { className: "flex items-center", children: /* @__PURE__ */ jsxs4(Fragment3, { children: [
2815
+ /* @__PURE__ */ jsx4(
2816
+ "button",
2817
+ {
2818
+ onClick: () => setSidebarOpen(!sidebarOpen),
2819
+ className: "p-2 cursor-pointer rounded-lg text-gray-500 disabled:opacity-50 transition-colors",
2820
+ style: {
2821
+ backgroundColor: "transparent"
2822
+ },
2823
+ onMouseEnter: (e) => {
2824
+ e.currentTarget.style.backgroundColor = theme === "dark" ? messageBubbleColorDark : messageBubbleColor;
2825
+ },
2826
+ onMouseLeave: (e) => {
2827
+ e.currentTarget.style.backgroundColor = "transparent";
2828
+ },
2829
+ title: "Toggle Sidebar",
2830
+ "aria-label": "Toggle Sidebar",
2831
+ children: sidebarOpen ? /* @__PURE__ */ jsx4(PanelRightOpen, { size: 20 }) : /* @__PURE__ */ jsx4(PanelRightClose, { size: 20 })
2832
+ }
2833
+ ),
2834
+ /* @__PURE__ */ jsx4(
2835
+ "button",
2836
+ {
2837
+ onClick: createNewConversation,
2838
+ className: "p-2 cursor-pointer rounded-lg text-gray-500 disabled:opacity-50 transition-colors",
2839
+ style: {
2840
+ backgroundColor: "transparent"
2841
+ },
2842
+ onMouseEnter: (e) => {
2843
+ e.currentTarget.style.backgroundColor = theme === "dark" ? messageBubbleColorDark : messageBubbleColor;
2844
+ },
2845
+ onMouseLeave: (e) => {
2846
+ e.currentTarget.style.backgroundColor = "transparent";
2847
+ },
2848
+ title: "New Chat",
2849
+ "aria-label": "New Chat",
2850
+ children: /* @__PURE__ */ jsx4(MessageCirclePlus, { size: 20 })
2851
+ }
2852
+ )
2853
+ ] }) }),
2854
+ /* @__PURE__ */ jsx4("div", { className: "flex items-center justify-center", children: /* @__PURE__ */ jsx4("div", { className: "relative flex items-center", children: /* @__PURE__ */ jsx4("span", { className: "text-2xl font-bold mr-1", children: propTitle }) }) }),
2855
+ /* @__PURE__ */ jsx4("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ jsx4(
2856
+ "button",
2857
+ {
2858
+ onClick: toggleTheme,
2859
+ className: "p-2 cursor-pointer rounded-lg text-gray-500 transition-colors",
2860
+ style: {
2861
+ backgroundColor: "transparent"
2862
+ },
2863
+ onMouseEnter: (e) => {
2864
+ e.currentTarget.style.backgroundColor = theme === "dark" ? messageBubbleColorDark : messageBubbleColor;
2865
+ },
2866
+ onMouseLeave: (e) => {
2867
+ e.currentTarget.style.backgroundColor = "transparent";
2868
+ },
2869
+ title: `Switch to ${theme === "dark" ? "light" : "dark"} mode`,
2870
+ "aria-label": `Switch to ${theme === "dark" ? "light" : "dark"} mode`,
2871
+ children: theme === "dark" ? /* @__PURE__ */ jsx4(Sun, { size: 20 }) : /* @__PURE__ */ jsx4(Moon, { size: 20 })
2872
+ }
2873
+ ) })
2874
+ ]
2875
+ }
2876
+ ),
2823
2877
  /* @__PURE__ */ jsx4(
2824
2878
  "div",
2825
2879
  {
2826
- className: `flex-1 overflow-hidden bg-white dark:bg-gray-900 text-lg transition-all duration-300 ${hasOpenApp ? "flex" : "flex justify-center"}`,
2880
+ className: `flex-1 overflow-hidden bg-white dark:bg-gray-900 text-lg transition-all duration-300 ${false ? "flex" : "flex justify-center"}`,
2827
2881
  children: /* @__PURE__ */ jsx4(
2828
2882
  "div",
2829
2883
  {
2830
- className: `flex flex-col transition-all duration-300 ${hasOpenApp ? "w-full" : "w-full max-w-6xl"}`,
2884
+ className: `flex flex-col transition-all duration-300 ${false ? "w-full" : "w-full max-w-6xl"}`,
2831
2885
  children: isLoading || !initialAssistantIdChecked ? /* @__PURE__ */ jsx4("div", { className: "flex h-full items-center justify-center", children: /* @__PURE__ */ jsx4("div", { className: "animate-pulse text-gray-500", children: isLoading ? "Loading conversations..." : "Initializing Assistant..." }) }) : !agentId ? /* @__PURE__ */ jsxs4("div", { className: "flex h-full flex-col items-center justify-center p-4 text-center", children: [
2832
2886
  /* @__PURE__ */ jsx4("h2", { className: "text-xl font-semibold text-red-600 dark:text-red-400 mb-2", children: "Agent Not Configured" }),
2833
2887
  /* @__PURE__ */ jsxs4("p", { className: "text-gray-700 dark:text-gray-300 max-w-md", children: [
@@ -2842,12 +2896,29 @@ function NeptuneChatBot({
2842
2896
  {
2843
2897
  conversation: selectedConversation,
2844
2898
  agentId,
2845
- debug,
2846
2899
  onConversationUpdate: refreshSelectedConversation,
2847
2900
  theme,
2848
- onAppStateChange: handleAppStateChange,
2849
2901
  onSidebarToggle: () => setSidebarOpen(false),
2850
- onThreadCreated: handleThreadCreated
2902
+ onThreadCreated: handleThreadCreated,
2903
+ messageBubbleColor: theme === "dark" ? messageBubbleColorDark : messageBubbleColor,
2904
+ accentColor: theme === "dark" ? accentColorDark : accentColor,
2905
+ scrollButtonColor: theme === "dark" ? scrollButtonColorDark : scrollButtonColor,
2906
+ streamingText,
2907
+ streamingTextColor: theme === "dark" ? streamingTextColorDark : streamingTextColor,
2908
+ welcomeMessagePrimary,
2909
+ welcomeMessageSecondary,
2910
+ welcomeIcon,
2911
+ welcomeIconSize,
2912
+ streaming,
2913
+ inputBackgroundColor,
2914
+ inputBackgroundColorDark,
2915
+ vectorColor,
2916
+ vectorColorDark,
2917
+ onToolStart,
2918
+ onToolInput,
2919
+ onToolFinish,
2920
+ onChunk,
2921
+ onFinish
2851
2922
  }
2852
2923
  ) : (
2853
2924
  // Show loading while the useEffect handles conversation creation