@kite-copilot/chat-panel 0.2.15 → 0.2.17

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/dist/auto.cjs CHANGED
@@ -887,7 +887,7 @@ function DataRenderer({ type, data }) {
887
887
  // src/ChatPanel.tsx
888
888
  var import_jsx_runtime9 = require("react/jsx-runtime");
889
889
  var DEFAULT_AGENT_URL = "http://localhost:5002";
890
- var PANEL_WIDTH = 340;
890
+ var PANEL_WIDTH = 400;
891
891
  function renderMarkdown(text) {
892
892
  if (!text) return null;
893
893
  const lines = text.split("\n");
@@ -904,7 +904,14 @@ function renderMarkdown(text) {
904
904
  const codeMatch = remaining.match(/^`([^`]+)`/);
905
905
  if (codeMatch) {
906
906
  parts.push(
907
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("code", { className: "bg-gray-100 px-1 py-0.5 rounded text-xs font-mono", children: codeMatch[1] }, keyIndex++)
907
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
908
+ "code",
909
+ {
910
+ className: "bg-gray-100 px-1 py-0.5 rounded text-xs font-mono",
911
+ children: codeMatch[1]
912
+ },
913
+ keyIndex++
914
+ )
908
915
  );
909
916
  remaining = remaining.slice(codeMatch[0].length);
910
917
  continue;
@@ -924,7 +931,17 @@ function renderMarkdown(text) {
924
931
  const linkMatch = remaining.match(/^\[([^\]]+)\]\(([^)]+)\)/);
925
932
  if (linkMatch) {
926
933
  parts.push(
927
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("a", { href: linkMatch[2], className: "text-blue-600 hover:underline", target: "_blank", rel: "noopener noreferrer", children: linkMatch[1] }, keyIndex++)
934
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
935
+ "a",
936
+ {
937
+ href: linkMatch[2],
938
+ className: "text-blue-600 hover:underline",
939
+ target: "_blank",
940
+ rel: "noopener noreferrer",
941
+ children: linkMatch[1]
942
+ },
943
+ keyIndex++
944
+ )
928
945
  );
929
946
  remaining = remaining.slice(linkMatch[0].length);
930
947
  continue;
@@ -947,7 +964,14 @@ function renderMarkdown(text) {
947
964
  if (currentList) {
948
965
  const ListTag = currentList.type === "ul" ? "ul" : "ol";
949
966
  elements.push(
950
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ListTag, { className: `${currentList.type === "ul" ? "list-disc" : "list-decimal"} ml-4 my-1`, children: currentList.items.map((item, i) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("li", { className: "ml-2", children: item }, i)) }, elements.length)
967
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
968
+ ListTag,
969
+ {
970
+ className: `${currentList.type === "ul" ? "list-disc" : "list-decimal"} ml-4 my-1`,
971
+ children: currentList.items.map((item, i) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("li", { className: "ml-2", children: item }, i))
972
+ },
973
+ elements.length
974
+ )
951
975
  );
952
976
  currentList = null;
953
977
  }
@@ -957,7 +981,14 @@ function renderMarkdown(text) {
957
981
  if (line.startsWith("```")) {
958
982
  if (inCodeBlock) {
959
983
  elements.push(
960
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("pre", { className: "bg-gray-100 rounded p-2 my-1 overflow-x-auto", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("code", { className: "text-xs font-mono", children: codeContent.join("\n") }) }, elements.length)
984
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
985
+ "pre",
986
+ {
987
+ className: "bg-gray-100 rounded p-2 my-1 overflow-x-auto",
988
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("code", { className: "text-xs font-mono", children: codeContent.join("\n") })
989
+ },
990
+ elements.length
991
+ )
961
992
  );
962
993
  inCodeBlock = false;
963
994
  codeContent = [];
@@ -979,7 +1010,9 @@ function renderMarkdown(text) {
979
1010
  const level = headerMatch[1].length;
980
1011
  const content = processInlineFormatting(headerMatch[2]);
981
1012
  const className = level === 1 ? "text-lg font-bold my-1" : level === 2 ? "text-base font-bold my-1" : "text-sm font-semibold my-1";
982
- elements.push(/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className, children: content }, elements.length));
1013
+ elements.push(
1014
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className, children: content }, elements.length)
1015
+ );
983
1016
  continue;
984
1017
  }
985
1018
  const ulMatch = line.match(/^[-*]\s+(.+)/);
@@ -1007,11 +1040,15 @@ function renderMarkdown(text) {
1007
1040
  }
1008
1041
  if (line.match(/^[-*_]{3,}$/)) {
1009
1042
  flushList();
1010
- elements.push(/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("hr", { className: "my-2 border-gray-200" }, elements.length));
1043
+ elements.push(
1044
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("hr", { className: "my-2 border-gray-200" }, elements.length)
1045
+ );
1011
1046
  continue;
1012
1047
  }
1013
1048
  flushList();
1014
- elements.push(/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { children: processInlineFormatting(line) }, elements.length));
1049
+ elements.push(
1050
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { children: processInlineFormatting(line) }, elements.length)
1051
+ );
1015
1052
  }
1016
1053
  flushList();
1017
1054
  return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_jsx_runtime9.Fragment, { children: elements });
@@ -1041,31 +1078,59 @@ var folders = [
1041
1078
  id: "customers",
1042
1079
  title: "Customer Management",
1043
1080
  topics: [
1044
- { id: "add-customer", label: "Add a new customer", prompt: "How do I add a new customer to the system and what information is required?" },
1045
- { id: "customer-details", label: "View customer details", prompt: "Show me how to view and edit customer information and their payment history." }
1081
+ {
1082
+ id: "add-customer",
1083
+ label: "Add a new customer",
1084
+ prompt: "How do I add a new customer to the system and what information is required?"
1085
+ },
1086
+ {
1087
+ id: "customer-details",
1088
+ label: "View customer details",
1089
+ prompt: "Show me how to view and edit customer information and their payment history."
1090
+ }
1046
1091
  ]
1047
1092
  },
1048
1093
  {
1049
1094
  id: "payments",
1050
1095
  title: "Payment Processing",
1051
1096
  topics: [
1052
- { id: "process-payment", label: "Process a payment", prompt: "How do I process a one-time payment for a customer?" },
1053
- { id: "refund-payment", label: "Issue a refund", prompt: "Walk me through issuing a refund for a customer payment." }
1097
+ {
1098
+ id: "process-payment",
1099
+ label: "Process a payment",
1100
+ prompt: "How do I process a one-time payment for a customer?"
1101
+ },
1102
+ {
1103
+ id: "refund-payment",
1104
+ label: "Issue a refund",
1105
+ prompt: "Walk me through issuing a refund for a customer payment."
1106
+ }
1054
1107
  ]
1055
1108
  },
1056
1109
  {
1057
1110
  id: "subscriptions",
1058
1111
  title: "Subscription Management",
1059
1112
  topics: [
1060
- { id: "create-subscription", label: "Create a subscription", prompt: "How do I set up a new subscription plan for a customer?" },
1061
- { id: "update-subscription", label: "Update subscription tier", prompt: "How can I change a customer's subscription plan or upgrade them?" }
1113
+ {
1114
+ id: "create-subscription",
1115
+ label: "Create a subscription",
1116
+ prompt: "How do I set up a new subscription plan for a customer?"
1117
+ },
1118
+ {
1119
+ id: "update-subscription",
1120
+ label: "Update subscription tier",
1121
+ prompt: "How can I change a customer's subscription plan or upgrade them?"
1122
+ }
1062
1123
  ]
1063
1124
  },
1064
1125
  {
1065
1126
  id: "billing",
1066
1127
  title: "Billing",
1067
1128
  topics: [
1068
- { id: "payment-methods", label: "Manage payment methods", prompt: "How do customers add or update their payment methods?" }
1129
+ {
1130
+ id: "payment-methods",
1131
+ label: "Manage payment methods",
1132
+ prompt: "How do customers add or update their payment methods?"
1133
+ }
1069
1134
  ]
1070
1135
  }
1071
1136
  ];
@@ -1211,18 +1276,21 @@ function ChatPanel({
1211
1276
  } = {}) {
1212
1277
  const [messages, setMessages] = React4.useState(initialMessages);
1213
1278
  const [input, setInput] = React4.useState("");
1214
- const [sessionId] = React4.useState(() => crypto.randomUUID());
1279
+ const [sessionId, setSessionId] = React4.useState(() => crypto.randomUUID());
1280
+ const resetSession = React4.useCallback(() => {
1281
+ setSessionId(crypto.randomUUID());
1282
+ }, []);
1215
1283
  const streamIntervals = React4.useRef({});
1216
1284
  const isEmpty = messages.length === 0;
1217
1285
  const [phase, setPhase] = React4.useState("idle");
1218
1286
  const [progressSteps, setProgressSteps] = React4.useState([]);
1219
1287
  const phaseTimers = React4.useRef([]);
1220
1288
  const lastRole = messages.length ? messages[messages.length - 1].role : void 0;
1221
- const [panelView, setPanelView] = React4.useState("landing");
1222
- const [currentFolderId, setCurrentFolderId] = React4.useState(void 0);
1223
- const [startingQuestions, setStartingQuestions] = React4.useState(
1224
- startingQuestionsProp || defaultStartingQuestions
1289
+ const [panelView, setPanelView] = React4.useState(
1290
+ "landing"
1225
1291
  );
1292
+ const [currentFolderId, setCurrentFolderId] = React4.useState(void 0);
1293
+ const [startingQuestions, setStartingQuestions] = React4.useState(startingQuestionsProp || defaultStartingQuestions);
1226
1294
  const [loadingQuestions, setLoadingQuestions] = React4.useState(false);
1227
1295
  React4.useEffect(() => {
1228
1296
  if (startingQuestionsEndpoint && !startingQuestionsProp) {
@@ -1246,10 +1314,11 @@ function ChatPanel({
1246
1314
  const latestBulkSummaryNavigationRef = React4.useRef(null);
1247
1315
  const [guideComplete, setGuideComplete] = React4.useState(false);
1248
1316
  React4.useEffect(() => {
1249
- ;
1250
1317
  window.resetIntegrationNotification = () => {
1251
1318
  localStorage.removeItem("gmailNotificationSeen");
1252
- console.log("Integration notification reset! Click the Integrations tab to see it again.");
1319
+ console.log(
1320
+ "Integration notification reset! Click the Integrations tab to see it again."
1321
+ );
1253
1322
  };
1254
1323
  const handleIntegrationTabClick = () => {
1255
1324
  const hasSeenNotification = localStorage.getItem("gmailNotificationSeen");
@@ -1272,7 +1341,10 @@ function ChatPanel({
1272
1341
  };
1273
1342
  window.addEventListener("integrationTabClicked", handleIntegrationTabClick);
1274
1343
  return () => {
1275
- window.removeEventListener("integrationTabClicked", handleIntegrationTabClick);
1344
+ window.removeEventListener(
1345
+ "integrationTabClicked",
1346
+ handleIntegrationTabClick
1347
+ );
1276
1348
  };
1277
1349
  }, []);
1278
1350
  React4.useEffect(() => {
@@ -1307,7 +1379,12 @@ function ChatPanel({
1307
1379
  const id = Date.now() + 1;
1308
1380
  setMessages((prev) => [
1309
1381
  ...prev,
1310
- { id, role: "assistant", kind: "guideComplete", content: "Perfect! The dialog is now open. You can enter a name and create your API key." }
1382
+ {
1383
+ id,
1384
+ role: "assistant",
1385
+ kind: "guideComplete",
1386
+ content: "Perfect! The dialog is now open. You can enter a name and create your API key."
1387
+ }
1311
1388
  ]);
1312
1389
  setActiveGuide(void 0);
1313
1390
  setGuideComplete(true);
@@ -1318,7 +1395,9 @@ function ChatPanel({
1318
1395
  }, [activeGuide, hide]);
1319
1396
  React4.useEffect(() => {
1320
1397
  return () => {
1321
- Object.values(streamIntervals.current).forEach((id) => window.clearInterval(id));
1398
+ Object.values(streamIntervals.current).forEach(
1399
+ (id) => window.clearInterval(id)
1400
+ );
1322
1401
  streamIntervals.current = {};
1323
1402
  phaseTimers.current.forEach((id) => window.clearTimeout(id));
1324
1403
  phaseTimers.current = [];
@@ -1379,9 +1458,17 @@ function ChatPanel({
1379
1458
  return;
1380
1459
  }
1381
1460
  const currentBulkNav = latestBulkSummaryNavigationRef.current;
1382
- console.log("[DEBUG] Keyboard handler - latestBulkSummaryNavigation:", currentBulkNav, "onNavigate:", !!onNavigate);
1461
+ console.log(
1462
+ "[DEBUG] Keyboard handler - latestBulkSummaryNavigation:",
1463
+ currentBulkNav,
1464
+ "onNavigate:",
1465
+ !!onNavigate
1466
+ );
1383
1467
  if (currentBulkNav && onNavigate) {
1384
- console.log("[DEBUG] Navigating via keyboard to:", currentBulkNav.page);
1468
+ console.log(
1469
+ "[DEBUG] Navigating via keyboard to:",
1470
+ currentBulkNav.page
1471
+ );
1385
1472
  e.preventDefault();
1386
1473
  e.stopPropagation();
1387
1474
  onNavigate(currentBulkNav.page, currentBulkNav.subtab);
@@ -1404,21 +1491,57 @@ function ChatPanel({
1404
1491
  };
1405
1492
  window.addEventListener("keydown", handleKeyDown);
1406
1493
  return () => window.removeEventListener("keydown", handleKeyDown);
1407
- }, [pendingAction, pendingNavigation, activeGuide, guideComplete, onNavigate]);
1494
+ }, [
1495
+ pendingAction,
1496
+ pendingNavigation,
1497
+ activeGuide,
1498
+ guideComplete,
1499
+ onNavigate
1500
+ ]);
1408
1501
  function streamAssistantMessage(messageId, fullText, followups) {
1409
- const tokens = fullText.split(" ");
1502
+ let textToStream = fullText;
1503
+ let extractedFollowups = followups;
1504
+ if (fullText && fullText.startsWith("{") && fullText.includes('"response"')) {
1505
+ try {
1506
+ let depth = 0, endIdx = 0;
1507
+ for (let i2 = 0; i2 < fullText.length; i2++) {
1508
+ if (fullText[i2] === "{") depth++;
1509
+ else if (fullText[i2] === "}") {
1510
+ depth--;
1511
+ if (depth === 0) {
1512
+ endIdx = i2 + 1;
1513
+ break;
1514
+ }
1515
+ }
1516
+ }
1517
+ const firstJson = endIdx > 0 ? fullText.slice(0, endIdx) : fullText;
1518
+ const parsed = JSON.parse(firstJson);
1519
+ if (parsed.response && typeof parsed.response === "string") {
1520
+ textToStream = parsed.response;
1521
+ if (!extractedFollowups && parsed.followups) {
1522
+ extractedFollowups = parsed.followups;
1523
+ }
1524
+ }
1525
+ } catch {
1526
+ }
1527
+ }
1528
+ const tokens = textToStream.split(" ");
1410
1529
  let i = 0;
1411
1530
  const intervalId = window.setInterval(() => {
1412
1531
  i += 1;
1413
1532
  setMessages(
1414
- (prev) => prev.map((m) => m.id === messageId ? { ...m, content: tokens.slice(0, i).join(" ") } : m)
1533
+ (prev) => prev.map(
1534
+ (m) => m.id === messageId ? { ...m, content: tokens.slice(0, i).join(" ") } : m
1535
+ )
1415
1536
  );
1416
1537
  if (i >= tokens.length) {
1417
1538
  window.clearInterval(intervalId);
1418
1539
  delete streamIntervals.current[messageId];
1419
- if (followups && followups.length > 0) {
1540
+ if (extractedFollowups && extractedFollowups.length > 0) {
1420
1541
  setMessages(
1421
- (prev) => prev.map((m) => m.id === messageId ? { ...m, followups } : m)
1542
+ (prev) => prev.map(
1543
+ (m) => m.id === messageId ? { ...m, followups: extractedFollowups } : m
1544
+ )
1422
1545
  );
1423
1546
  }
1424
1547
  setPhase("idle");
@@ -1428,16 +1551,21 @@ function ChatPanel({
1428
1551
  }
1429
1552
  function handleFollowupClick(messageId, followup) {
1430
1553
  setMessages(
1431
- (prev) => prev.map((m) => m.id === messageId ? { ...m, followupSelected: true } : m)
1554
+ (prev) => prev.map(
1555
+ (m) => m.id === messageId ? { ...m, followupSelected: true } : m
1556
+ )
1432
1557
  );
1433
1558
  startChatFlow(followup.label);
1434
1559
  }
1435
1560
  function handleBack() {
1436
- Object.values(streamIntervals.current).forEach((id) => window.clearInterval(id));
1561
+ Object.values(streamIntervals.current).forEach(
1562
+ (id) => window.clearInterval(id)
1563
+ );
1437
1564
  streamIntervals.current = {};
1438
1565
  phaseTimers.current.forEach((id) => window.clearTimeout(id));
1439
1566
  phaseTimers.current = [];
1440
1567
  hide();
1568
+ resetSession();
1441
1569
  setMessages([]);
1442
1570
  setInput("");
1443
1571
  setPhase("idle");
@@ -1597,7 +1725,10 @@ function ChatPanel({
1597
1725
  content: ""
1598
1726
  };
1599
1727
  setMessages((prev) => [...prev, thankYouMessage]);
1600
- streamAssistantMessage(thankYouMessageId, "Thank you, your feedback is saved.");
1728
+ streamAssistantMessage(
1729
+ thankYouMessageId,
1730
+ "Thank you, your feedback is saved."
1731
+ );
1601
1732
  return;
1602
1733
  }
1603
1734
  setPendingNavigation(null);
@@ -1655,7 +1786,10 @@ function ChatPanel({
1655
1786
  } else if (data.status === "executing") {
1656
1787
  setPhase("executing");
1657
1788
  setProgressSteps((prev) => {
1658
- const updated = prev.map((step) => ({ ...step, completed: true }));
1789
+ const updated = prev.map((step) => ({
1790
+ ...step,
1791
+ completed: true
1792
+ }));
1659
1793
  const lastStep = updated[updated.length - 1];
1660
1794
  if (!lastStep || lastStep.message !== data.message) {
1661
1795
  updated.push({ message: data.message, completed: false });
@@ -1664,7 +1798,9 @@ function ChatPanel({
1664
1798
  });
1665
1799
  } else if (data.status === "responding") {
1666
1800
  setPhase("responding");
1667
- setProgressSteps((prev) => prev.map((step) => ({ ...step, completed: true })));
1801
+ setProgressSteps(
1802
+ (prev) => prev.map((step) => ({ ...step, completed: true }))
1803
+ );
1668
1804
  }
1669
1805
  } else if (eventType === "response") {
1670
1806
  setProgressSteps([]);
@@ -1710,7 +1846,11 @@ function ChatPanel({
1710
1846
  content: ""
1711
1847
  };
1712
1848
  setMessages((prev) => [...prev, assistantMessage]);
1713
- streamAssistantMessage(assistantMessageId, agentResponse.response || agentResponse.message || "For bulk operations, you can upload a CSV file - just click the \u{1F4CE} button!", agentResponse.followups);
1849
+ streamAssistantMessage(
1850
+ assistantMessageId,
1851
+ agentResponse.response || agentResponse.message || "For bulk operations, you can upload a CSV file - just click the \u{1F4CE} button!",
1852
+ agentResponse.followups
1853
+ );
1714
1854
  streamCompleted = true;
1715
1855
  } else if (agentResponse.action === "bulk_preview") {
1716
1856
  setPendingBulkSession(agentResponse.bulk_session_id);
@@ -1742,12 +1882,18 @@ function ChatPanel({
1742
1882
  structuredData: agentResponse.structuredData || void 0
1743
1883
  };
1744
1884
  setMessages((prev) => [...prev, assistantMessage]);
1745
- streamAssistantMessage(assistantMessageId, agentResponse.response, agentResponse.followups);
1885
+ streamAssistantMessage(
1886
+ assistantMessageId,
1887
+ agentResponse.response,
1888
+ agentResponse.followups
1889
+ );
1746
1890
  streamCompleted = true;
1747
1891
  setTimeout(() => {
1748
- window.dispatchEvent(new CustomEvent("agentActionComplete", {
1749
- detail: { result: agentResponse.executionResult }
1750
- }));
1892
+ window.dispatchEvent(
1893
+ new CustomEvent("agentActionComplete", {
1894
+ detail: { result: agentResponse.executionResult }
1895
+ })
1896
+ );
1751
1897
  }, 100);
1752
1898
  } else {
1753
1899
  const assistantMessageId = now + 1;
@@ -1758,7 +1904,11 @@ function ChatPanel({
1758
1904
  content: ""
1759
1905
  };
1760
1906
  setMessages((prev) => [...prev, assistantMessage]);
1761
- streamAssistantMessage(assistantMessageId, agentResponse.response, agentResponse.followups);
1907
+ streamAssistantMessage(
1908
+ assistantMessageId,
1909
+ agentResponse.response,
1910
+ agentResponse.followups
1911
+ );
1762
1912
  streamCompleted = true;
1763
1913
  }
1764
1914
  } else if (eventType === "error") {
@@ -1773,7 +1923,10 @@ function ChatPanel({
1773
1923
  content: ""
1774
1924
  };
1775
1925
  setMessages((prev) => [...prev, errorMessage]);
1776
- streamAssistantMessage(errorMessageId, data.message || "An error occurred processing your request.");
1926
+ streamAssistantMessage(
1927
+ errorMessageId,
1928
+ data.message || "An error occurred processing your request."
1929
+ );
1777
1930
  } else if (eventType === "done") {
1778
1931
  setProgressSteps([]);
1779
1932
  setPhase("idle");
@@ -1799,7 +1952,18 @@ function ChatPanel({
1799
1952
  content: ""
1800
1953
  };
1801
1954
  setMessages((prev) => [...prev, errorMessage]);
1802
- streamAssistantMessage(errorMessageId, "I'm having trouble connecting to my backend. Please make sure the agent server is running on port 5002. For simple navigation requests, I can still help you locally.");
1955
+ let errorText = "I'm having trouble connecting to my backend.";
1956
+ if (error instanceof Error) {
1957
+ if (error.name === "AbortError") {
1958
+ errorText = "The request timed out. The server might be busy - please try again.";
1959
+ } else if (error.message.includes("Failed to fetch") || error.message.includes("NetworkError")) {
1960
+ errorText = "I'm having trouble connecting to my backend. Please make sure the agent server is running on port 5002.";
1961
+ } else if (error.message.includes("Agent request failed:")) {
1962
+ errorText = "The server encountered an error. Please try again.";
1963
+ }
1964
+ }
1965
+ errorText += " For simple navigation requests, I can still help you locally.";
1966
+ streamAssistantMessage(errorMessageId, errorText);
1803
1967
  } finally {
1804
1968
  setProgressSteps([]);
1805
1969
  }
@@ -1883,33 +2047,41 @@ ${userText}`
1883
2047
  setMessages((prev) => [...prev, previewMessage]);
1884
2048
  } else if (eventType === "progress") {
1885
2049
  setPhase("executing");
1886
- setProgressSteps([{
1887
- message: `Processing row ${data.row} of ${data.total}...`,
1888
- completed: false
1889
- }]);
2050
+ setProgressSteps([
2051
+ {
2052
+ message: `Processing row ${data.row} of ${data.total}...`,
2053
+ completed: false
2054
+ }
2055
+ ]);
1890
2056
  setMessages((prev) => {
1891
2057
  const lastMsg = prev[prev.length - 1];
1892
2058
  if (lastMsg?.kind === "bulkProgress") {
1893
2059
  return prev.map(
1894
- (m, i) => i === prev.length - 1 ? { ...m, bulkProgress: {
1895
- processed: data.row,
1896
- total: data.total,
1897
- successes: data.successes || 0,
1898
- failures: data.failures || 0
1899
- } } : m
2060
+ (m, i) => i === prev.length - 1 ? {
2061
+ ...m,
2062
+ bulkProgress: {
2063
+ processed: data.row,
2064
+ total: data.total,
2065
+ successes: data.successes || 0,
2066
+ failures: data.failures || 0
2067
+ }
2068
+ } : m
1900
2069
  );
1901
2070
  } else {
1902
- return [...prev, {
1903
- id: Date.now(),
1904
- role: "assistant",
1905
- kind: "bulkProgress",
1906
- bulkProgress: {
1907
- processed: data.row,
1908
- total: data.total,
1909
- successes: data.successes || 0,
1910
- failures: data.failures || 0
2071
+ return [
2072
+ ...prev,
2073
+ {
2074
+ id: Date.now(),
2075
+ role: "assistant",
2076
+ kind: "bulkProgress",
2077
+ bulkProgress: {
2078
+ processed: data.row,
2079
+ total: data.total,
2080
+ successes: data.successes || 0,
2081
+ failures: data.failures || 0
2082
+ }
1911
2083
  }
1912
- }];
2084
+ ];
1913
2085
  }
1914
2086
  });
1915
2087
  } else if (eventType === "summary") {
@@ -1918,23 +2090,34 @@ ${userText}`
1918
2090
  setPendingBulkSession(null);
1919
2091
  setMessages((prev) => {
1920
2092
  const filtered = prev.filter((m) => m.kind !== "bulkProgress");
1921
- return [...filtered, {
1922
- id: Date.now(),
1923
- role: "assistant",
1924
- kind: "bulkSummary",
1925
- content: data.message,
1926
- bulkSummary: {
1927
- total: data.total,
1928
- successes: data.successes,
1929
- failures: data.failures || [],
1930
- navigationPage: data.navigationPage
2093
+ return [
2094
+ ...filtered,
2095
+ {
2096
+ id: Date.now(),
2097
+ role: "assistant",
2098
+ kind: "bulkSummary",
2099
+ content: data.message,
2100
+ bulkSummary: {
2101
+ total: data.total,
2102
+ successes: data.successes,
2103
+ failures: data.failures || [],
2104
+ navigationPage: data.navigationPage
2105
+ }
1931
2106
  }
1932
- }];
2107
+ ];
1933
2108
  });
1934
2109
  setTimeout(() => {
1935
- window.dispatchEvent(new CustomEvent("agentActionComplete", {
1936
- detail: { result: { bulk: true, total: data.total, successes: data.successes } }
1937
- }));
2110
+ window.dispatchEvent(
2111
+ new CustomEvent("agentActionComplete", {
2112
+ detail: {
2113
+ result: {
2114
+ bulk: true,
2115
+ total: data.total,
2116
+ successes: data.successes
2117
+ }
2118
+ }
2119
+ })
2120
+ );
1938
2121
  }, 100);
1939
2122
  } else if (eventType === "error") {
1940
2123
  setPhase("idle");
@@ -1962,18 +2145,31 @@ ${userText}`
1962
2145
  console.error("Bulk upload failed:", error);
1963
2146
  setProgressSteps([]);
1964
2147
  setPhase("idle");
2148
+ let errorText = "I'm having trouble processing your CSV file.";
2149
+ if (error instanceof Error) {
2150
+ if (error.name === "AbortError") {
2151
+ errorText = "The bulk upload request timed out. The file might be too large or the server is busy - please try again.";
2152
+ } else if (error.message.includes("Failed to fetch") || error.message.includes("NetworkError")) {
2153
+ errorText = "I'm having trouble connecting to my backend. Please make sure the agent server is running on port 5002.";
2154
+ } else if (error.message.includes("Bulk upload failed:")) {
2155
+ errorText = "The server encountered an error processing your CSV file. Please try again.";
2156
+ }
2157
+ }
2158
+ errorText += " Please try again.";
1965
2159
  const errorMessage = {
1966
2160
  id: now + 1,
1967
2161
  role: "assistant",
1968
2162
  kind: "text",
1969
- content: "I'm having trouble processing your CSV file. Please make sure the agent server is running on port 5002 and try again."
2163
+ content: errorText
1970
2164
  };
1971
2165
  setMessages((prev) => [...prev, errorMessage]);
1972
2166
  }
1973
2167
  }
1974
2168
  async function confirmBulkOperation(bulkSessionId) {
1975
2169
  setPhase("executing");
1976
- setProgressSteps([{ message: "Starting bulk operation...", completed: false }]);
2170
+ setProgressSteps([
2171
+ { message: "Starting bulk operation...", completed: false }
2172
+ ]);
1977
2173
  try {
1978
2174
  const response = await fetch(`${agentUrl}/chat/bulk/confirm`, {
1979
2175
  method: "POST",
@@ -2009,43 +2205,56 @@ ${userText}`
2009
2205
  try {
2010
2206
  const data = JSON.parse(eventData);
2011
2207
  if (eventType === "progress") {
2012
- setProgressSteps([{
2013
- message: `Processing row ${data.row} of ${data.total}...`,
2014
- completed: false
2015
- }]);
2208
+ setProgressSteps([
2209
+ {
2210
+ message: `Processing row ${data.row} of ${data.total}...`,
2211
+ completed: false
2212
+ }
2213
+ ]);
2016
2214
  setMessages((prev) => {
2017
2215
  const lastMsg = prev[prev.length - 1];
2018
2216
  if (lastMsg?.kind === "bulkProgress") {
2019
2217
  return prev.map(
2020
- (m, i) => i === prev.length - 1 ? { ...m, bulkProgress: {
2021
- processed: data.row,
2022
- total: data.total,
2023
- successes: data.successes || 0,
2024
- failures: data.failures || 0
2025
- } } : m
2218
+ (m, i) => i === prev.length - 1 ? {
2219
+ ...m,
2220
+ bulkProgress: {
2221
+ processed: data.row,
2222
+ total: data.total,
2223
+ successes: data.successes || 0,
2224
+ failures: data.failures || 0
2225
+ }
2226
+ } : m
2026
2227
  );
2027
2228
  } else {
2028
- return [...prev, {
2029
- id: Date.now(),
2030
- role: "assistant",
2031
- kind: "bulkProgress",
2032
- bulkProgress: {
2033
- processed: data.row,
2034
- total: data.total,
2035
- successes: data.successes || 0,
2036
- failures: data.failures || 0
2229
+ return [
2230
+ ...prev,
2231
+ {
2232
+ id: Date.now(),
2233
+ role: "assistant",
2234
+ kind: "bulkProgress",
2235
+ bulkProgress: {
2236
+ processed: data.row,
2237
+ total: data.total,
2238
+ successes: data.successes || 0,
2239
+ failures: data.failures || 0
2240
+ }
2037
2241
  }
2038
- }];
2242
+ ];
2039
2243
  }
2040
2244
  });
2041
2245
  } else if (eventType === "summary") {
2042
2246
  console.log("[DEBUG] Received summary event - data:", data);
2043
- console.log("[DEBUG] navigationPage from backend:", data.navigationPage);
2247
+ console.log(
2248
+ "[DEBUG] navigationPage from backend:",
2249
+ data.navigationPage
2250
+ );
2044
2251
  setPhase("idle");
2045
2252
  setProgressSteps([]);
2046
2253
  setPendingBulkSession(null);
2047
2254
  setMessages((prev) => {
2048
- const filtered = prev.filter((m) => m.kind !== "bulkProgress" && m.kind !== "bulkPreview");
2255
+ const filtered = prev.filter(
2256
+ (m) => m.kind !== "bulkProgress" && m.kind !== "bulkPreview"
2257
+ );
2049
2258
  const newMsg = {
2050
2259
  id: Date.now(),
2051
2260
  role: "assistant",
@@ -2062,9 +2271,17 @@ ${userText}`
2062
2271
  return [...filtered, newMsg];
2063
2272
  });
2064
2273
  setTimeout(() => {
2065
- window.dispatchEvent(new CustomEvent("agentActionComplete", {
2066
- detail: { result: { bulk: true, total: data.total, successes: data.successes } }
2067
- }));
2274
+ window.dispatchEvent(
2275
+ new CustomEvent("agentActionComplete", {
2276
+ detail: {
2277
+ result: {
2278
+ bulk: true,
2279
+ total: data.total,
2280
+ successes: data.successes
2281
+ }
2282
+ }
2283
+ })
2284
+ );
2068
2285
  }, 100);
2069
2286
  } else if (eventType === "error") {
2070
2287
  setPhase("idle");
@@ -2106,7 +2323,10 @@ ${userText}`
2106
2323
  }
2107
2324
  function appendAssistantText(text) {
2108
2325
  const id = Date.now() + Math.floor(Math.random() * 1e3);
2109
- setMessages((prev) => [...prev, { id, role: "assistant", kind: "text", content: text }]);
2326
+ setMessages((prev) => [
2327
+ ...prev,
2328
+ { id, role: "assistant", kind: "text", content: text }
2329
+ ]);
2110
2330
  }
2111
2331
  function startGuide(guideId) {
2112
2332
  const guide = guides[guideId];
@@ -2119,7 +2339,9 @@ ${userText}`
2119
2339
  appendAssistantText(`I'll help you with ${guide.title}.`);
2120
2340
  const firstStep = guide.steps[0];
2121
2341
  const isNavigationButton = firstStep.cursorTarget?.selector.includes("[data-page=");
2122
- const isTabButton = firstStep.cursorTarget?.selector.includes("[data-settings-tab=");
2342
+ const isTabButton = firstStep.cursorTarget?.selector.includes(
2343
+ "[data-settings-tab="
2344
+ );
2123
2345
  if (firstStep.cursorTarget && (isNavigationButton || isTabButton)) {
2124
2346
  const cursorTarget = firstStep.cursorTarget;
2125
2347
  if (isTabButton && firstStep.navigation && onNavigate) {
@@ -2128,7 +2350,9 @@ ${userText}`
2128
2350
  const initialDelay = isTabButton ? 800 : 400;
2129
2351
  setTimeout(() => {
2130
2352
  const waitForElement = () => {
2131
- const element = document.querySelector(cursorTarget.selector);
2353
+ const element = document.querySelector(
2354
+ cursorTarget.selector
2355
+ );
2132
2356
  if (element && element.offsetParent !== null) {
2133
2357
  moveTo(cursorTarget);
2134
2358
  if (cursorTarget.onClick) {
@@ -2153,7 +2377,9 @@ ${userText}`
2153
2377
  const initialDelay = isDialogElement ? 700 : isSettingsTab ? 600 : 400;
2154
2378
  setTimeout(() => {
2155
2379
  const waitForElement = () => {
2156
- const element = document.querySelector(cursorTarget.selector);
2380
+ const element = document.querySelector(
2381
+ cursorTarget.selector
2382
+ );
2157
2383
  if (element && element.offsetParent !== null) {
2158
2384
  moveTo(cursorTarget);
2159
2385
  if (cursorTarget.onClick) {
@@ -2167,7 +2393,9 @@ ${userText}`
2167
2393
  moveTo(cursorTarget);
2168
2394
  if (cursorTarget.onClick) {
2169
2395
  setTimeout(() => {
2170
- const el = document.querySelector(cursorTarget.selector);
2396
+ const el = document.querySelector(
2397
+ cursorTarget.selector
2398
+ );
2171
2399
  if (el) el.click();
2172
2400
  }, 1e3);
2173
2401
  }
@@ -2204,7 +2432,12 @@ ${userText}`
2204
2432
  const id = Date.now() + 1;
2205
2433
  setMessages((prev) => [
2206
2434
  ...prev,
2207
- { id, role: "assistant", kind: "guideComplete", content: "Guide Complete" }
2435
+ {
2436
+ id,
2437
+ role: "assistant",
2438
+ kind: "guideComplete",
2439
+ content: "Guide Complete"
2440
+ }
2208
2441
  ]);
2209
2442
  setActiveGuide(void 0);
2210
2443
  setGuideComplete(true);
@@ -2223,7 +2456,9 @@ ${userText}`
2223
2456
  };
2224
2457
  setMessages((prev) => [...prev, draft]);
2225
2458
  const isNavigationButton = nextStep.cursorTarget?.selector.includes("[data-page=");
2226
- const isTabButton = nextStep.cursorTarget?.selector.includes("[data-settings-tab=");
2459
+ const isTabButton = nextStep.cursorTarget?.selector.includes(
2460
+ "[data-settings-tab="
2461
+ );
2227
2462
  if (nextStep.cursorTarget && (isNavigationButton || isTabButton)) {
2228
2463
  const cursorTarget = nextStep.cursorTarget;
2229
2464
  if (isTabButton && nextStep.navigation && onNavigate) {
@@ -2240,7 +2475,9 @@ ${userText}`
2240
2475
  if (!currentGuide3 || currentGuide3.id !== guide.id || currentGuide3.stepIndex !== nextIndex) {
2241
2476
  return;
2242
2477
  }
2243
- const element = document.querySelector(cursorTarget.selector);
2478
+ const element = document.querySelector(
2479
+ cursorTarget.selector
2480
+ );
2244
2481
  if (element && element.offsetParent !== null) {
2245
2482
  moveTo(cursorTarget);
2246
2483
  if (cursorTarget.onClick) {
@@ -2266,7 +2503,9 @@ ${userText}`
2266
2503
  const cursorTarget = nextStep.cursorTarget;
2267
2504
  const isDialogElement = cursorTarget.selector.includes("dialog") || cursorTarget.selector.includes("api-key-name-input");
2268
2505
  const isSettingsTab = cursorTarget.selector.includes("data-settings-tab");
2269
- const navigationSetTab = nextStep.navigation?.subtab && isSettingsTab && cursorTarget.selector.includes(`data-settings-tab="${nextStep.navigation.subtab}"`);
2506
+ const navigationSetTab = nextStep.navigation?.subtab && isSettingsTab && cursorTarget.selector.includes(
2507
+ `data-settings-tab="${nextStep.navigation.subtab}"`
2508
+ );
2270
2509
  const shouldAutoClick = cursorTarget.onClick && !navigationSetTab;
2271
2510
  const hasNavigation = !!nextStep.navigation;
2272
2511
  const hasSubtab = !!nextStep.navigation?.subtab;
@@ -2282,7 +2521,9 @@ ${userText}`
2282
2521
  if (!currentGuide3 || currentGuide3.id !== guide.id || currentGuide3.stepIndex !== nextIndex) {
2283
2522
  return;
2284
2523
  }
2285
- const element = document.querySelector(cursorTarget.selector);
2524
+ const element = document.querySelector(
2525
+ cursorTarget.selector
2526
+ );
2286
2527
  if (element && element.offsetParent !== null) {
2287
2528
  moveTo(cursorTarget);
2288
2529
  if (shouldAutoClick) {
@@ -2304,7 +2545,9 @@ ${userText}`
2304
2545
  if (!currentGuide4 || currentGuide4.id !== guide.id || currentGuide4.stepIndex !== nextIndex) {
2305
2546
  return;
2306
2547
  }
2307
- const el = document.querySelector(cursorTarget.selector);
2548
+ const el = document.querySelector(
2549
+ cursorTarget.selector
2550
+ );
2308
2551
  if (el) el.click();
2309
2552
  }, 1e3);
2310
2553
  }
@@ -2336,10 +2579,17 @@ ${userText}`
2336
2579
  } else {
2337
2580
  hide();
2338
2581
  }
2339
- const existingMessages = messages.filter((m) => m.kind !== "guideStep" && m.kind !== "guideComplete");
2582
+ const existingMessages = messages.filter(
2583
+ (m) => m.kind !== "guideStep" && m.kind !== "guideComplete"
2584
+ );
2340
2585
  setMessages([
2341
2586
  ...existingMessages,
2342
- { id: Date.now(), role: "assistant", kind: "guideStep", content: prevStep.text }
2587
+ {
2588
+ id: Date.now(),
2589
+ role: "assistant",
2590
+ kind: "guideStep",
2591
+ content: prevStep.text
2592
+ }
2343
2593
  ]);
2344
2594
  }
2345
2595
  }
@@ -2354,937 +2604,1192 @@ ${userText}`
2354
2604
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.Sparkles, { className: "h-3.5 w-3.5 text-black", fill: "currentColor" }),
2355
2605
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("h3", { className: "text-sm font-semibold text-gray-800", children: "Copilot" })
2356
2606
  ] }),
2357
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "flex items-center gap-1", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2358
- Button,
2359
- {
2360
- variant: "ghost",
2361
- size: "sm",
2362
- className: "h-7 w-7 p-0 text-gray-400 hover:text-gray-600 hover:bg-gray-100 rounded-full",
2363
- onClick: () => {
2364
- setMessages([]);
2365
- setPanelView("landing");
2366
- setCurrentFolderId(void 0);
2367
- setActiveGuide(void 0);
2368
- activeGuideRef.current = void 0;
2369
- setGuideComplete(false);
2370
- },
2371
- children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.SquarePen, { className: "h-3.5 w-3.5" })
2372
- }
2373
- ) })
2374
- ] }),
2375
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: isEmpty ? "grid flex-1 place-items-center transition-all duration-300" : "flex flex-1 flex-col transition-all duration-300 min-h-0 overflow-hidden", children: isEmpty ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "w-full overflow-y-auto px-4", children: [
2376
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "py-3 transition-all duration-300", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("h2", { className: "text-center text-2xl font-semibold text-gray-900", children: panelView === "folder" ? folders.find((f) => f.id === currentFolderId)?.title || "" : "How can I help?" }) }),
2377
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "pb-4 px-4", children: [
2378
- panelView === "landing" && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_jsx_runtime9.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "flex flex-col gap-1", children: loadingQuestions ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "flex items-center justify-center py-4", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.Loader2, { className: "h-4 w-4 animate-spin text-gray-400" }) }) : startingQuestions.map((question, index) => {
2379
- const iconColors = ["bg-blue-400", "bg-green-400", "bg-purple-400", "bg-orange-400", "bg-pink-400"];
2380
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
2381
- Button,
2382
- {
2383
- type: "button",
2384
- size: "sm",
2385
- variant: "ghost",
2386
- className: "w-full justify-start rounded-lg px-3 py-1.5 text-xs text-gray-700 hover:bg-gray-100 h-auto",
2387
- onClick: () => sendTopic(question.prompt),
2388
- children: [
2389
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: `mr-2 inline-block h-1.5 w-1.5 rounded-full ${iconColors[index % iconColors.length]}` }),
2390
- question.label
2391
- ]
2392
- },
2393
- question.id
2394
- );
2395
- }) }) }),
2396
- panelView === "folder" && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
2397
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "mb-3 flex items-center gap-2", children: [
2398
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2399
- Button,
2400
- {
2401
- type: "button",
2402
- size: "icon",
2403
- variant: "ghost",
2404
- className: "h-7 w-7 rounded-full hover:bg-gray-100",
2405
- onClick: closeFolder,
2406
- "aria-label": "Back to suggestions",
2407
- children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.ArrowLeft, { className: "h-4 w-4 text-gray-500" })
2408
- }
2409
- ),
2410
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "text-xs font-medium uppercase tracking-wide text-gray-400", children: "Topics" })
2411
- ] }),
2412
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "flex flex-col gap-1.5", children: folders.find((f) => f.id === currentFolderId)?.topics.map((topic) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2413
- Button,
2414
- {
2415
- type: "button",
2416
- size: "sm",
2417
- variant: "secondary",
2418
- className: "justify-start rounded-xl border border-gray-200 bg-gray-50 px-3 py-2.5 text-xs text-gray-700 shadow-none transition-all hover:bg-gray-100 hover:border-gray-300 h-auto",
2419
- onClick: () => sendTopic(topic.prompt),
2420
- children: topic.label
2607
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex items-center gap-1", children: [
2608
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2609
+ Button,
2610
+ {
2611
+ variant: "ghost",
2612
+ size: "sm",
2613
+ className: "h-7 w-7 p-0 text-gray-400 hover:text-gray-600 hover:bg-gray-100 rounded-full",
2614
+ onClick: () => {
2615
+ resetSession();
2616
+ setMessages([]);
2617
+ setPanelView("landing");
2618
+ setCurrentFolderId(void 0);
2619
+ setActiveGuide(void 0);
2620
+ activeGuideRef.current = void 0;
2621
+ setGuideComplete(false);
2421
2622
  },
2422
- topic.id
2423
- )) })
2424
- ] })
2425
- ] })
2426
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_jsx_runtime9.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "flex-1 min-h-0 overflow-hidden", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ScrollArea, { ref: messagesContainerRef, className: "h-full", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex flex-col gap-2 px-4 py-3", children: [
2427
- messages.map((message, index) => {
2428
- const isUser = message.role === "user";
2429
- const previousRole = index > 0 ? messages[index - 1].role : void 0;
2430
- const isRoleChange = previousRole !== void 0 && previousRole !== message.role;
2431
- const currentGuide = activeGuideRef.current || activeGuide;
2432
- let isCurrentGuideStep = false;
2433
- if (currentGuide && message.kind === "guideStep") {
2434
- if (message.guideStepIndex !== void 0) {
2435
- isCurrentGuideStep = message.guideStepIndex === currentGuide.stepIndex;
2436
- } else {
2437
- isCurrentGuideStep = index === messages.length - 1;
2623
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.SquarePen, { className: "h-3 w-3" })
2438
2624
  }
2439
- } else if (message.kind === "guideComplete") {
2440
- isCurrentGuideStep = index === messages.length - 1;
2441
- }
2442
- if (message.kind === "guideStep" && !isCurrentGuideStep) {
2443
- return null;
2444
- }
2445
- if (isUser) {
2446
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: `flex justify-end ${isRoleChange ? "mt-3" : ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "max-w-[260px] rounded-2xl rounded-br-md bg-gray-900 px-3.5 py-2.5 text-sm text-white shadow-sm", children: message.content }) }, message.id);
2447
- }
2448
- if (message.kind === "searchSummary") {
2449
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: `${isRoleChange ? "mt-3" : ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(AssistantSearchSummary, { title: message.title ?? "Search results", links: message.links ?? [] }) }, message.id);
2450
- }
2451
- if (message.kind === "guideComplete") {
2452
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2453
- "div",
2454
- {
2455
- ref: isCurrentGuideStep ? currentStepRef : null,
2456
- className: `${isRoleChange ? "mt-3" : ""}`,
2457
- children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex items-center gap-2 rounded-xl bg-green-50 border border-green-200 px-3 py-2.5 text-sm leading-6", children: [
2458
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.CheckCircle2, { className: "h-5 w-5 text-green-600 flex-shrink-0" }),
2459
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "font-medium text-green-800", children: message.content })
2460
- ] })
2461
- },
2462
- message.id
2463
- );
2464
- }
2465
- if (message.kind === "navigationAction") {
2466
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: `${isRoleChange ? "mt-3" : ""}`, children: [
2467
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "whitespace-pre-wrap text-sm leading-6 mb-2 text-gray-700", children: message.content || "" }),
2468
- message.navigationTarget && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "mt-2", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
2469
- Button,
2470
- {
2471
- type: "button",
2472
- size: "sm",
2473
- variant: "secondary",
2474
- className: "h-8 rounded-xl px-3 text-xs gap-1.5 bg-gray-100 hover:bg-gray-200 border border-gray-200",
2475
- onClick: () => message.navigationTarget && handleConfirmNavigation(message.navigationTarget),
2476
- children: [
2477
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { children: "Confirm" }),
2478
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "flex items-center gap-0.5 text-gray-400", children: [
2479
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.Command, { className: "h-3 w-3" }),
2480
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.CornerDownLeft, { className: "h-3 w-3" })
2481
- ] })
2482
- ]
2483
- }
2484
- ) })
2485
- ] }, message.id);
2486
- }
2487
- if (message.kind === "actionForm") {
2488
- const actionType = message.actionType;
2489
- const formData = Object.keys(actionFormData).length > 0 ? actionFormData : message.actionData || {};
2490
- if (message.isSubmitted) {
2491
- let successContent = "";
2492
- if (actionType === "updateCompanyInfo") {
2493
- successContent = "Company information has been updated successfully.";
2494
- } else if (actionType === "addApiKey") {
2495
- successContent = "API key has been added successfully.";
2496
- } else if (actionType === "addCustomer") {
2497
- successContent = "Customer has been added successfully.";
2498
- } else if (actionType === "enable2FA") {
2499
- successContent = "Two-factor authentication has been enabled successfully.";
2500
- } else if (actionType === "disable2FA") {
2501
- successContent = "Two-factor authentication has been disabled successfully.";
2502
- } else if (actionType === "changePassword") {
2503
- successContent = "Your password has been changed successfully.";
2504
- } else if (actionType === "revokeSession") {
2505
- successContent = "Session has been revoked successfully.";
2506
- } else if (actionType === "toggleNotification") {
2507
- successContent = "Notification preferences have been updated successfully.";
2508
- } else if (actionType === "connectIntegration") {
2509
- successContent = "Integration has been connected successfully.";
2510
- } else if (actionType === "disconnectIntegration") {
2511
- successContent = "Integration has been disconnected successfully.";
2512
- } else if (actionType === "addPaymentMethod") {
2513
- successContent = "Payment method has been added successfully.";
2514
- } else if (actionType === "removePaymentMethod") {
2515
- successContent = "Payment method has been removed successfully.";
2516
- } else if (actionType === "deleteApiKey") {
2517
- successContent = "API key has been deleted successfully.";
2518
- } else if (actionType === "addWebhook") {
2519
- successContent = "Webhook endpoint has been added successfully.";
2520
- } else if (actionType === "updateCurrency") {
2521
- successContent = "Currency preference has been updated successfully.";
2522
- } else if (actionType === "updateTimezone") {
2523
- successContent = "Timezone has been updated successfully.";
2524
- } else if (actionType === "refundPayment") {
2525
- successContent = "Refund has been processed successfully.";
2526
- } else if (actionType === "exportCertificate") {
2527
- successContent = "Certificate of Incorporation has been downloaded successfully.";
2528
- } else if (actionType === "createSubscription") {
2529
- successContent = "Subscription has been created successfully.";
2530
- } else if (actionType === "toggleBlockRule" || actionType === "enableBlockRule" || actionType === "disableBlockRule") {
2531
- successContent = "Block rule has been updated successfully.";
2532
- } else {
2533
- successContent = "Action completed successfully.";
2534
- }
2535
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: `${isRoleChange ? "mt-3" : ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "whitespace-pre-wrap text-sm leading-6 text-gray-700", children: successContent }) }, message.id);
2625
+ ),
2626
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2627
+ Button,
2628
+ {
2629
+ variant: "ghost",
2630
+ size: "sm",
2631
+ className: "h-7 w-7 p-0 text-gray-400 hover:text-gray-600 hover:bg-gray-100 rounded-full",
2632
+ onClick: () => onClose?.(),
2633
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.X, { className: "h-3.5 w-3.5" })
2536
2634
  }
2537
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: `min-w-0 ${isRoleChange ? "mt-3" : ""}`, children: [
2538
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "whitespace-pre-wrap text-sm leading-6 mb-3 text-gray-700", children: message.content || "" }),
2539
- actionType === "updateCompanyInfo" && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "space-y-2 bg-gray-50 rounded-lg p-2 border border-gray-200 overflow-hidden", children: [
2540
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "grid grid-cols-2 gap-2", children: [
2541
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2542
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Company Name" }),
2543
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2544
- Input,
2545
- {
2546
- placeholder: "Acme Corporation",
2547
- value: formData.companyName || "",
2548
- onChange: (e) => setActionFormData({ ...actionFormData, companyName: e.target.value }),
2549
- className: "h-8 text-xs border-gray-200"
2550
- }
2551
- )
2552
- ] }),
2553
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2554
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Email" }),
2555
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2556
- Input,
2557
- {
2558
- type: "email",
2559
- placeholder: "contact@acme.com",
2560
- value: formData.email || "",
2561
- onChange: (e) => setActionFormData({ ...actionFormData, email: e.target.value }),
2562
- className: "h-8 text-xs border-gray-200"
2563
- }
2564
- )
2565
- ] })
2566
- ] }),
2567
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2568
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Address" }),
2569
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2570
- Input,
2571
- {
2572
- placeholder: "123 Main St, San Francisco, CA",
2573
- value: formData.address || "",
2574
- onChange: (e) => setActionFormData({ ...actionFormData, address: e.target.value }),
2575
- className: "h-8 text-xs border-gray-200"
2576
- }
2577
- )
2578
- ] }),
2579
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "grid grid-cols-2 gap-2", children: [
2580
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2581
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Phone" }),
2582
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2583
- Input,
2584
- {
2585
- type: "tel",
2586
- placeholder: "+1 (555) 123-4567",
2587
- value: formData.phone || "",
2588
- onChange: (e) => setActionFormData({ ...actionFormData, phone: e.target.value }),
2589
- className: "h-8 text-xs border-gray-200"
2590
- }
2591
- )
2592
- ] }),
2593
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2594
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Website" }),
2595
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2596
- Input,
2597
- {
2598
- type: "url",
2599
- placeholder: "https://acme.com",
2600
- value: formData.website || "",
2601
- onChange: (e) => setActionFormData({ ...actionFormData, website: e.target.value }),
2602
- className: "h-8 text-xs border-gray-200"
2603
- }
2604
- )
2605
- ] })
2606
- ] })
2607
- ] }),
2608
- actionType === "addApiKey" && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2609
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "API Key Name" }),
2610
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2611
- Input,
2612
- {
2613
- placeholder: "Production Key",
2614
- value: formData.name || "",
2615
- onChange: (e) => setActionFormData({ ...actionFormData, name: e.target.value }),
2616
- className: "h-8 text-xs border-gray-200"
2617
- }
2618
- )
2619
- ] }) }),
2620
- actionType === "addCustomer" && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "space-y-2 bg-gray-50 rounded-lg p-2 border border-gray-200 overflow-hidden", children: [
2621
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "grid grid-cols-2 gap-2", children: [
2622
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2623
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Company Name" }),
2624
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2625
- Input,
2626
- {
2627
- placeholder: "Acme Corporation",
2628
- value: formData.name || "",
2629
- onChange: (e) => setActionFormData({ ...actionFormData, name: e.target.value }),
2630
- className: "h-8 text-xs border-gray-200"
2631
- }
2632
- )
2633
- ] }),
2634
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2635
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Email" }),
2636
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2637
- Input,
2638
- {
2639
- type: "email",
2640
- placeholder: "contact@acme.com",
2641
- value: formData.email || "",
2642
- onChange: (e) => setActionFormData({ ...actionFormData, email: e.target.value }),
2643
- className: "h-8 text-xs border-gray-200"
2644
- }
2645
- )
2646
- ] })
2647
- ] }),
2648
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2649
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Location" }),
2650
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2651
- Input,
2652
- {
2653
- placeholder: "San Francisco, CA",
2654
- value: formData.location || "",
2655
- onChange: (e) => setActionFormData({ ...actionFormData, location: e.target.value }),
2656
- className: "h-8 text-xs border-gray-200"
2657
- }
2658
- )
2659
- ] }),
2660
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2661
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Subscription Tier" }),
2662
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
2663
- "select",
2635
+ )
2636
+ ] })
2637
+ ] }),
2638
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2639
+ "div",
2640
+ {
2641
+ className: isEmpty ? "grid flex-1 place-items-center transition-all duration-300" : "flex flex-1 flex-col transition-all duration-300 min-h-0 overflow-hidden",
2642
+ children: isEmpty ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "w-full overflow-y-auto px-4", children: [
2643
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "py-3 transition-all duration-300", children: [
2644
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("h2", { className: "text-center text-2xl font-semibold text-gray-900", children: panelView === "folder" ? folders.find((f) => f.id === currentFolderId)?.title || "" : "What can I help with?" }),
2645
+ panelView === "landing" && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "mt-1 text-center text-xs text-gray-500", children: "Ask me anything about your account" })
2646
+ ] }),
2647
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "pb-4 px-4", children: [
2648
+ panelView === "landing" && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
2649
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "mb-2 text-[10px] font-semibold uppercase tracking-wider text-gray-400", children: "Suggested Questions" }),
2650
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "flex flex-col gap-1", children: loadingQuestions ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "flex items-center justify-center py-4", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.Loader2, { className: "h-4 w-4 animate-spin text-gray-400" }) }) : startingQuestions.map((question, index) => {
2651
+ const iconColors = [
2652
+ "bg-blue-400",
2653
+ "bg-green-400",
2654
+ "bg-purple-400",
2655
+ "bg-orange-400",
2656
+ "bg-pink-400"
2657
+ ];
2658
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
2659
+ Button,
2664
2660
  {
2665
- value: formData.subscription || "Starter",
2666
- onChange: (e) => setActionFormData({ ...actionFormData, subscription: e.target.value }),
2667
- className: "h-8 w-full rounded-md border border-gray-200 bg-transparent px-3 py-1 text-xs shadow-xs transition-colors focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] outline-none",
2661
+ type: "button",
2662
+ size: "sm",
2663
+ variant: "ghost",
2664
+ className: "w-full justify-start rounded-lg px-3 py-1.5 text-xs text-gray-700 hover:bg-gray-100 h-auto",
2665
+ onClick: () => sendTopic(question.prompt),
2668
2666
  children: [
2669
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "Starter", children: "Starter" }),
2670
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "Professional", children: "Professional" }),
2671
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "Enterprise", children: "Enterprise" })
2667
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2668
+ "span",
2669
+ {
2670
+ className: `mr-2 inline-block h-1.5 w-1.5 rounded-full ${iconColors[index % iconColors.length]}`
2671
+ }
2672
+ ),
2673
+ question.label
2672
2674
  ]
2673
- }
2674
- )
2675
- ] })
2675
+ },
2676
+ question.id
2677
+ );
2678
+ }) })
2676
2679
  ] }),
2677
- (actionType === "enable2FA" || actionType === "disable2FA") && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "text-xs text-black", children: actionType === "enable2FA" ? "This will enable two-factor authentication for your account. You'll need to set up an authenticator app." : "This will disable two-factor authentication for your account. Your account will be less secure." }) }),
2678
- actionType === "changePassword" && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
2679
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2680
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Current Password" }),
2681
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2682
- Input,
2683
- {
2684
- type: "password",
2685
- value: formData.currentPassword || "",
2686
- onChange: (e) => setActionFormData({ ...actionFormData, currentPassword: e.target.value }),
2687
- className: "h-8 text-xs border-gray-200"
2688
- }
2689
- )
2690
- ] }),
2691
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2692
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "New Password" }),
2680
+ panelView === "folder" && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
2681
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "mb-3 flex items-center gap-2", children: [
2693
2682
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2694
- Input,
2683
+ Button,
2695
2684
  {
2696
- type: "password",
2697
- value: formData.newPassword || "",
2698
- onChange: (e) => setActionFormData({ ...actionFormData, newPassword: e.target.value }),
2699
- className: "h-8 text-xs border-gray-200"
2700
- }
2701
- )
2702
- ] }),
2703
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2704
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Confirm New Password" }),
2705
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2706
- Input,
2707
- {
2708
- type: "password",
2709
- value: formData.confirmPassword || "",
2710
- onChange: (e) => setActionFormData({ ...actionFormData, confirmPassword: e.target.value }),
2711
- className: "h-8 text-xs border-gray-200"
2712
- }
2713
- )
2714
- ] })
2715
- ] }),
2716
- actionType === "toggleNotification" && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
2717
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2718
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Notification Type" }),
2719
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
2720
- "select",
2721
- {
2722
- value: formData.notificationType || "paymentReceived",
2723
- onChange: (e) => setActionFormData({ ...actionFormData, notificationType: e.target.value }),
2724
- className: "h-8 w-full rounded-md border border-gray-200 bg-transparent px-3 py-1 text-xs shadow-xs transition-colors focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] outline-none",
2725
- children: [
2726
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "paymentReceived", children: "Payment Received" }),
2727
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "paymentFailed", children: "Payment Failed" }),
2728
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "invoicePaid", children: "Invoice Paid" }),
2729
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "monthlySummary", children: "Monthly Summary" }),
2730
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "productUpdates", children: "Product Updates" })
2731
- ]
2732
- }
2733
- )
2734
- ] }),
2735
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex items-center gap-2", children: [
2736
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2737
- "input",
2738
- {
2739
- type: "checkbox",
2740
- checked: formData.enabled !== false,
2741
- onChange: (e) => setActionFormData({ ...actionFormData, enabled: e.target.checked }),
2742
- className: "h-4 w-4 rounded border-gray-300 text-primary focus:ring-primary"
2685
+ type: "button",
2686
+ size: "icon",
2687
+ variant: "ghost",
2688
+ className: "h-7 w-7 rounded-full hover:bg-gray-100",
2689
+ onClick: closeFolder,
2690
+ "aria-label": "Back to suggestions",
2691
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.ArrowLeft, { className: "h-4 w-4 text-gray-500" })
2743
2692
  }
2744
2693
  ),
2745
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs text-black", children: "Enable this notification" })
2746
- ] })
2747
- ] }),
2748
- (actionType === "connectIntegration" || actionType === "disconnectIntegration") && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2749
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Integration" }),
2750
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
2751
- "select",
2752
- {
2753
- value: formData.integrationName || "Slack",
2754
- onChange: (e) => setActionFormData({ ...actionFormData, integrationName: e.target.value }),
2755
- className: "h-8 w-full rounded-md border border-gray-200 bg-transparent px-3 py-1 text-xs shadow-xs transition-colors focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] outline-none",
2756
- children: [
2757
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "Slack", children: "Slack" }),
2758
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "Zapier", children: "Zapier" }),
2759
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "Webhook", children: "Webhook" })
2760
- ]
2761
- }
2762
- )
2763
- ] }) }),
2764
- actionType === "addPaymentMethod" && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
2765
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2766
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Card Number" }),
2767
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2768
- Input,
2769
- {
2770
- placeholder: "1234 5678 9012 3456",
2771
- value: formData.cardNumber || "",
2772
- onChange: (e) => setActionFormData({ ...actionFormData, cardNumber: e.target.value }),
2773
- className: "h-8 text-xs border-gray-200"
2774
- }
2775
- )
2694
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "text-xs font-medium uppercase tracking-wide text-gray-400", children: "Topics" })
2776
2695
  ] }),
2777
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2778
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Expiry Date" }),
2779
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2780
- Input,
2781
- {
2782
- placeholder: "MM/YY",
2783
- value: formData.expiryDate || "",
2784
- onChange: (e) => setActionFormData({ ...actionFormData, expiryDate: e.target.value }),
2785
- className: "h-8 text-xs border-gray-200"
2786
- }
2787
- )
2788
- ] })
2789
- ] }),
2790
- actionType === "removePaymentMethod" && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "text-xs text-black", children: "This will remove the default payment method from your account." }) }),
2791
- actionType === "refundPayment" && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
2792
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2793
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Transaction ID or Customer Name" }),
2794
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2795
- Input,
2796
- {
2797
- placeholder: "e.g., txn_1234 or Acme Corp",
2798
- value: formData.transactionId || formData.customer || "",
2799
- onChange: (e) => {
2800
- const value = e.target.value;
2801
- if (value.startsWith("txn_") || /^\d+$/.test(value)) {
2802
- setActionFormData({ ...actionFormData, transactionId: value, customer: void 0 });
2803
- } else {
2804
- setActionFormData({ ...actionFormData, customer: value, transactionId: void 0 });
2805
- }
2806
- },
2807
- className: "h-8 text-xs border-gray-200"
2808
- }
2809
- )
2810
- ] }),
2811
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2812
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Amount (optional)" }),
2813
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2814
- Input,
2815
- {
2816
- placeholder: "$0.00",
2817
- value: formData.amount || "",
2818
- onChange: (e) => setActionFormData({ ...actionFormData, amount: e.target.value }),
2819
- className: "h-8 text-xs border-gray-200"
2820
- }
2821
- )
2822
- ] }),
2823
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2824
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Reason (optional)" }),
2825
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2826
- Input,
2827
- {
2828
- placeholder: "e.g., Customer request",
2829
- value: formData.reason || "",
2830
- onChange: (e) => setActionFormData({ ...actionFormData, reason: e.target.value }),
2831
- className: "h-8 text-xs border-gray-200"
2832
- }
2833
- )
2834
- ] })
2835
- ] }),
2836
- actionType === "deleteApiKey" && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
2837
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2838
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "API Key Name or ID" }),
2839
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2840
- Input,
2841
- {
2842
- placeholder: "Production Key",
2843
- value: formData.keyId || formData.name || "",
2844
- onChange: (e) => setActionFormData({ ...actionFormData, keyId: e.target.value, name: e.target.value }),
2845
- className: "h-8 text-xs border-gray-200"
2846
- }
2847
- )
2848
- ] }),
2849
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "text-xs text-red-600", children: "Warning: This action cannot be undone. The API key will be permanently deleted." })
2850
- ] }),
2851
- actionType === "addWebhook" && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
2852
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2853
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Webhook URL" }),
2854
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2855
- Input,
2856
- {
2857
- type: "url",
2858
- placeholder: "https://example.com/webhook",
2859
- value: formData.url || "",
2860
- onChange: (e) => setActionFormData({ ...actionFormData, url: e.target.value }),
2861
- className: "h-8 text-xs border-gray-200"
2862
- }
2863
- )
2864
- ] }),
2865
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2866
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Name (optional)" }),
2867
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2868
- Input,
2869
- {
2870
- placeholder: "Production Webhook",
2871
- value: formData.name || "",
2872
- onChange: (e) => setActionFormData({ ...actionFormData, name: e.target.value }),
2873
- className: "h-8 text-xs border-gray-200"
2874
- }
2875
- )
2876
- ] })
2877
- ] }),
2878
- actionType === "updateCurrency" && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2879
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Currency" }),
2880
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
2881
- "select",
2696
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "flex flex-col gap-1.5", children: folders.find((f) => f.id === currentFolderId)?.topics.map((topic) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2697
+ Button,
2882
2698
  {
2883
- value: formData.currency || "USD",
2884
- onChange: (e) => setActionFormData({ ...actionFormData, currency: e.target.value }),
2885
- className: "h-8 w-full rounded-md border border-gray-200 bg-transparent px-3 py-1 text-xs shadow-xs transition-colors focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] outline-none",
2886
- children: [
2887
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "USD", children: "USD ($)" }),
2888
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "EUR", children: "EUR (\u20AC)" }),
2889
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "GBP", children: "GBP (\xA3)" }),
2890
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "JPY", children: "JPY (\xA5)" })
2891
- ]
2892
- }
2893
- )
2894
- ] }) }),
2895
- actionType === "updateTimezone" && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2896
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Timezone" }),
2897
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
2898
- "select",
2699
+ type: "button",
2700
+ size: "sm",
2701
+ variant: "secondary",
2702
+ className: "justify-start rounded-xl border border-gray-200 bg-gray-50 px-3 py-2.5 text-xs text-gray-700 shadow-none transition-all hover:bg-gray-100 hover:border-gray-300 h-auto",
2703
+ onClick: () => sendTopic(topic.prompt),
2704
+ children: topic.label
2705
+ },
2706
+ topic.id
2707
+ )) })
2708
+ ] })
2709
+ ] })
2710
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_jsx_runtime9.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "flex-1 min-h-0 overflow-hidden", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ScrollArea, { ref: messagesContainerRef, className: "h-full", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex flex-col gap-2 px-4 py-3", children: [
2711
+ messages.map((message, index) => {
2712
+ const isUser = message.role === "user";
2713
+ const previousRole = index > 0 ? messages[index - 1].role : void 0;
2714
+ const isRoleChange = previousRole !== void 0 && previousRole !== message.role;
2715
+ const currentGuide = activeGuideRef.current || activeGuide;
2716
+ let isCurrentGuideStep = false;
2717
+ if (currentGuide && message.kind === "guideStep") {
2718
+ if (message.guideStepIndex !== void 0) {
2719
+ isCurrentGuideStep = message.guideStepIndex === currentGuide.stepIndex;
2720
+ } else {
2721
+ isCurrentGuideStep = index === messages.length - 1;
2722
+ }
2723
+ } else if (message.kind === "guideComplete") {
2724
+ isCurrentGuideStep = index === messages.length - 1;
2725
+ }
2726
+ if (message.kind === "guideStep" && !isCurrentGuideStep) {
2727
+ return null;
2728
+ }
2729
+ if (isUser) {
2730
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2731
+ "div",
2732
+ {
2733
+ className: `flex justify-end ${isRoleChange ? "mt-3" : ""}`,
2734
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "max-w-[280px] rounded-2xl rounded-br-md bg-gray-900 px-3.5 py-2.5 text-sm text-white shadow-sm", children: message.content })
2735
+ },
2736
+ message.id
2737
+ );
2738
+ }
2739
+ if (message.kind === "searchSummary") {
2740
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2741
+ "div",
2742
+ {
2743
+ className: `${isRoleChange ? "mt-3" : ""}`,
2744
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2745
+ AssistantSearchSummary,
2746
+ {
2747
+ title: message.title ?? "Search results",
2748
+ links: message.links ?? []
2749
+ }
2750
+ )
2751
+ },
2752
+ message.id
2753
+ );
2754
+ }
2755
+ if (message.kind === "guideComplete") {
2756
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2757
+ "div",
2758
+ {
2759
+ ref: isCurrentGuideStep ? currentStepRef : null,
2760
+ className: `${isRoleChange ? "mt-3" : ""}`,
2761
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex items-center gap-2 rounded-xl bg-green-50 border border-green-200 px-3 py-2.5 text-sm leading-6", children: [
2762
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.CheckCircle2, { className: "h-5 w-5 text-green-600 flex-shrink-0" }),
2763
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "font-medium text-green-800", children: message.content })
2764
+ ] })
2765
+ },
2766
+ message.id
2767
+ );
2768
+ }
2769
+ if (message.kind === "navigationAction") {
2770
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
2771
+ "div",
2899
2772
  {
2900
- value: formData.timezone || "America/Los_Angeles",
2901
- onChange: (e) => setActionFormData({ ...actionFormData, timezone: e.target.value }),
2902
- className: "h-8 w-full rounded-md border border-gray-200 bg-transparent px-3 py-1 text-xs shadow-xs transition-colors focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] outline-none",
2773
+ className: `${isRoleChange ? "mt-3" : ""}`,
2903
2774
  children: [
2904
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "America/Los_Angeles", children: "Pacific Time (PT)" }),
2905
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "America/New_York", children: "Eastern Time (ET)" }),
2906
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "Europe/London", children: "GMT" }),
2907
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "Asia/Tokyo", children: "JST" })
2775
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "whitespace-pre-wrap text-sm leading-6 mb-2 text-gray-700", children: message.content || "" }),
2776
+ message.navigationTarget && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "mt-2", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
2777
+ Button,
2778
+ {
2779
+ type: "button",
2780
+ size: "sm",
2781
+ variant: "secondary",
2782
+ className: "h-8 rounded-xl px-3 text-xs gap-1.5 bg-gray-100 hover:bg-gray-200 border border-gray-200",
2783
+ onClick: () => message.navigationTarget && handleConfirmNavigation(
2784
+ message.navigationTarget
2785
+ ),
2786
+ children: [
2787
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { children: "Confirm" }),
2788
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "flex items-center gap-0.5 text-gray-400", children: [
2789
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.Command, { className: "h-3 w-3" }),
2790
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.CornerDownLeft, { className: "h-3 w-3" })
2791
+ ] })
2792
+ ]
2793
+ }
2794
+ ) })
2908
2795
  ]
2796
+ },
2797
+ message.id
2798
+ );
2799
+ }
2800
+ if (message.kind === "actionForm") {
2801
+ const actionType = message.actionType;
2802
+ const formData = Object.keys(actionFormData).length > 0 ? actionFormData : message.actionData || {};
2803
+ if (message.isSubmitted) {
2804
+ let successContent = "";
2805
+ if (actionType === "updateCompanyInfo") {
2806
+ successContent = "Company information has been updated successfully.";
2807
+ } else if (actionType === "addApiKey") {
2808
+ successContent = "API key has been added successfully.";
2809
+ } else if (actionType === "addCustomer") {
2810
+ successContent = "Customer has been added successfully.";
2811
+ } else if (actionType === "enable2FA") {
2812
+ successContent = "Two-factor authentication has been enabled successfully.";
2813
+ } else if (actionType === "disable2FA") {
2814
+ successContent = "Two-factor authentication has been disabled successfully.";
2815
+ } else if (actionType === "changePassword") {
2816
+ successContent = "Your password has been changed successfully.";
2817
+ } else if (actionType === "revokeSession") {
2818
+ successContent = "Session has been revoked successfully.";
2819
+ } else if (actionType === "toggleNotification") {
2820
+ successContent = "Notification preferences have been updated successfully.";
2821
+ } else if (actionType === "connectIntegration") {
2822
+ successContent = "Integration has been connected successfully.";
2823
+ } else if (actionType === "disconnectIntegration") {
2824
+ successContent = "Integration has been disconnected successfully.";
2825
+ } else if (actionType === "addPaymentMethod") {
2826
+ successContent = "Payment method has been added successfully.";
2827
+ } else if (actionType === "removePaymentMethod") {
2828
+ successContent = "Payment method has been removed successfully.";
2829
+ } else if (actionType === "deleteApiKey") {
2830
+ successContent = "API key has been deleted successfully.";
2831
+ } else if (actionType === "addWebhook") {
2832
+ successContent = "Webhook endpoint has been added successfully.";
2833
+ } else if (actionType === "updateCurrency") {
2834
+ successContent = "Currency preference has been updated successfully.";
2835
+ } else if (actionType === "updateTimezone") {
2836
+ successContent = "Timezone has been updated successfully.";
2837
+ } else if (actionType === "refundPayment") {
2838
+ successContent = "Refund has been processed successfully.";
2839
+ } else if (actionType === "exportCertificate") {
2840
+ successContent = "Certificate of Incorporation has been downloaded successfully.";
2841
+ } else if (actionType === "createSubscription") {
2842
+ successContent = "Subscription has been created successfully.";
2843
+ } else if (actionType === "toggleBlockRule" || actionType === "enableBlockRule" || actionType === "disableBlockRule") {
2844
+ successContent = "Block rule has been updated successfully.";
2845
+ } else {
2846
+ successContent = "Action completed successfully.";
2909
2847
  }
2910
- )
2911
- ] }) }),
2912
- actionType === "revokeSession" && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
2913
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2914
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Device/Session" }),
2915
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2916
- Input,
2917
- {
2918
- placeholder: "MacBook Pro",
2919
- value: formData.device || "",
2920
- onChange: (e) => setActionFormData({ ...actionFormData, device: e.target.value }),
2921
- className: "h-8 text-xs border-gray-200"
2922
- }
2923
- )
2924
- ] }),
2925
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "text-xs text-black", children: "This will sign out the device and invalidate its session." })
2926
- ] }),
2927
- actionType === "createSubscription" && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
2928
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2929
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Customer Email" }),
2930
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2931
- Input,
2932
- {
2933
- type: "email",
2934
- placeholder: "customer@example.com",
2935
- value: formData.customerEmail || "",
2936
- onChange: (e) => setActionFormData({ ...actionFormData, customerEmail: e.target.value }),
2937
- className: "h-8 text-xs border-gray-200"
2938
- }
2939
- )
2940
- ] }),
2941
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2942
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Plan" }),
2943
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
2944
- "select",
2945
- {
2946
- value: formData.plan || "Starter",
2947
- onChange: (e) => setActionFormData({ ...actionFormData, plan: e.target.value }),
2948
- className: "h-8 w-full rounded-md border border-gray-200 bg-transparent px-3 py-1 text-xs shadow-xs transition-colors focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] outline-none",
2949
- children: [
2950
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "Starter", children: "Starter ($29/mo)" }),
2951
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "Professional", children: "Professional ($99/mo)" }),
2952
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "Enterprise", children: "Enterprise ($299/mo)" })
2953
- ]
2954
- }
2955
- )
2956
- ] }),
2957
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2958
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Billing Cycle" }),
2959
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
2960
- "select",
2961
- {
2962
- value: formData.billingCycle || "monthly",
2963
- onChange: (e) => setActionFormData({ ...actionFormData, billingCycle: e.target.value }),
2964
- className: "h-8 w-full rounded-md border border-gray-200 bg-transparent px-3 py-1 text-xs shadow-xs transition-colors focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] outline-none",
2965
- children: [
2966
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "monthly", children: "Monthly" }),
2967
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "yearly", children: "Yearly (Save 15%)" })
2968
- ]
2969
- }
2970
- )
2971
- ] })
2972
- ] }),
2973
- actionType === "exportCertificate" && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
2974
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "text-xs text-black", children: "This will export your certificate of incorporation document." }),
2975
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2976
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Format" }),
2977
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
2978
- "select",
2979
- {
2980
- value: formData.format || "pdf",
2981
- onChange: (e) => setActionFormData({ ...actionFormData, format: e.target.value }),
2982
- className: "h-8 w-full rounded-md border border-gray-200 bg-transparent px-3 py-1 text-xs shadow-xs transition-colors focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] outline-none",
2983
- children: [
2984
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "pdf", children: "PDF" }),
2985
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "json", children: "JSON" })
2986
- ]
2987
- }
2988
- )
2989
- ] })
2990
- ] }),
2991
- (actionType === "toggleBlockRule" || actionType === "enableBlockRule" || actionType === "disableBlockRule") && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
2992
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2993
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Block Rule" }),
2994
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
2995
- "select",
2848
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2849
+ "div",
2996
2850
  {
2997
- value: formData.ruleId || "rule_1",
2998
- onChange: (e) => setActionFormData({ ...actionFormData, ruleId: e.target.value }),
2999
- className: "h-8 w-full rounded-md border border-gray-200 bg-transparent px-3 py-1 text-xs shadow-xs transition-colors focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] outline-none",
3000
- children: [
3001
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "rule_1", children: "Block if risk level = 'highest'" }),
3002
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "rule_2", children: "Block if matches Stripe block lists" }),
3003
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "rule_3", children: "Block if CVC verification fails" }),
3004
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "rule_4", children: "Block if Postal code verification fails" })
3005
- ]
3006
- }
3007
- )
3008
- ] }),
3009
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "text-xs text-black", children: actionType === "enableBlockRule" ? "This will enable the selected block rule to actively block matching payments." : actionType === "disableBlockRule" ? "This will disable the selected block rule. Matching payments will no longer be blocked." : "This will toggle the selected block rule's state." })
3010
- ] }),
3011
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "mt-3", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3012
- Button,
3013
- {
3014
- type: "button",
3015
- size: "sm",
3016
- variant: "secondary",
3017
- className: "h-8 rounded-xl px-3 text-xs gap-1.5 bg-gray-100 hover:bg-gray-200 border border-gray-200",
3018
- onClick: handleActionSubmit,
3019
- children: [
3020
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { children: "Confirm" }),
3021
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "flex items-center gap-0.5 text-gray-400", children: [
3022
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.Command, { className: "h-3 w-3" }),
3023
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.CornerDownLeft, { className: "h-3 w-3" })
3024
- ] })
3025
- ]
2851
+ className: `${isRoleChange ? "mt-3" : ""}`,
2852
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "whitespace-pre-wrap text-sm leading-6 text-gray-700", children: successContent })
2853
+ },
2854
+ message.id
2855
+ );
3026
2856
  }
3027
- ) })
3028
- ] }, message.id);
3029
- }
3030
- if (message.kind === "bulkPreview" && message.csvData) {
3031
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: `${isRoleChange ? "mt-3" : ""}`, children: [
3032
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "whitespace-pre-wrap text-sm leading-6 mb-3 text-gray-700", children: message.content || "" }),
3033
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "bg-gray-50 rounded-lg border border-gray-200 overflow-hidden", children: [
3034
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "bg-gray-100 px-3 py-2 border-b border-gray-200 flex items-center gap-2", children: [
3035
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.FileSpreadsheet, { className: "h-4 w-4 text-gray-600" }),
3036
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "text-xs font-medium text-gray-700", children: message.csvData.fileName }),
3037
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "text-xs text-gray-500", children: [
3038
- "\u2022 ",
3039
- message.csvData.rowCount,
3040
- " rows"
3041
- ] })
3042
- ] }),
3043
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "px-3 py-2 border-b border-gray-100", children: [
3044
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "text-[10px] uppercase tracking-wider text-gray-500 mb-1", children: "Columns" }),
3045
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "flex flex-wrap gap-1", children: message.csvData.columns.map((col, i) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "text-xs bg-blue-100 text-blue-700 px-1.5 py-0.5 rounded", children: col }, i)) })
3046
- ] }),
3047
- message.csvData.sampleRows.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "px-3 py-2", children: [
3048
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "text-[10px] uppercase tracking-wider text-gray-500 mb-1", children: "Sample Data" }),
3049
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "space-y-1", children: message.csvData.sampleRows.slice(0, 3).map((row, i) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "text-xs text-gray-600 bg-white rounded px-2 py-1 border border-gray-100", children: [
3050
- Object.entries(row).slice(0, 3).map(([key, val], j) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { children: [
3051
- j > 0 && " \u2022 ",
3052
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "text-gray-400", children: [
3053
- key,
3054
- ":"
2857
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
2858
+ "div",
2859
+ {
2860
+ className: `min-w-0 ${isRoleChange ? "mt-3" : ""}`,
2861
+ children: [
2862
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "whitespace-pre-wrap text-sm leading-6 mb-3 text-gray-700", children: message.content || "" }),
2863
+ actionType === "updateCompanyInfo" && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "space-y-2 bg-gray-50 rounded-lg p-2 border border-gray-200 overflow-hidden", children: [
2864
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "grid grid-cols-2 gap-2", children: [
2865
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2866
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Company Name" }),
2867
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2868
+ Input,
2869
+ {
2870
+ placeholder: "Acme Corporation",
2871
+ value: formData.companyName || "",
2872
+ onChange: (e) => setActionFormData({
2873
+ ...actionFormData,
2874
+ companyName: e.target.value
2875
+ }),
2876
+ className: "h-8 text-xs border-gray-200"
2877
+ }
2878
+ )
2879
+ ] }),
2880
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2881
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Email" }),
2882
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2883
+ Input,
2884
+ {
2885
+ type: "email",
2886
+ placeholder: "contact@acme.com",
2887
+ value: formData.email || "",
2888
+ onChange: (e) => setActionFormData({
2889
+ ...actionFormData,
2890
+ email: e.target.value
2891
+ }),
2892
+ className: "h-8 text-xs border-gray-200"
2893
+ }
2894
+ )
2895
+ ] })
2896
+ ] }),
2897
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2898
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Address" }),
2899
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2900
+ Input,
2901
+ {
2902
+ placeholder: "123 Main St, San Francisco, CA",
2903
+ value: formData.address || "",
2904
+ onChange: (e) => setActionFormData({
2905
+ ...actionFormData,
2906
+ address: e.target.value
2907
+ }),
2908
+ className: "h-8 text-xs border-gray-200"
2909
+ }
2910
+ )
2911
+ ] }),
2912
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "grid grid-cols-2 gap-2", children: [
2913
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2914
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Phone" }),
2915
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2916
+ Input,
2917
+ {
2918
+ type: "tel",
2919
+ placeholder: "+1 (555) 123-4567",
2920
+ value: formData.phone || "",
2921
+ onChange: (e) => setActionFormData({
2922
+ ...actionFormData,
2923
+ phone: e.target.value
2924
+ }),
2925
+ className: "h-8 text-xs border-gray-200"
2926
+ }
2927
+ )
2928
+ ] }),
2929
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2930
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Website" }),
2931
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2932
+ Input,
2933
+ {
2934
+ type: "url",
2935
+ placeholder: "https://acme.com",
2936
+ value: formData.website || "",
2937
+ onChange: (e) => setActionFormData({
2938
+ ...actionFormData,
2939
+ website: e.target.value
2940
+ }),
2941
+ className: "h-8 text-xs border-gray-200"
2942
+ }
2943
+ )
2944
+ ] })
2945
+ ] })
3055
2946
  ] }),
3056
- " ",
3057
- val
3058
- ] }, key)),
3059
- Object.keys(row).length > 3 && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "text-gray-400", children: " ..." })
3060
- ] }, i)) })
3061
- ] }),
3062
- message.suggestedAction && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "px-3 py-2 bg-blue-50 border-t border-blue-100", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "text-xs text-blue-700", children: [
3063
- "Suggested action: ",
3064
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("strong", { children: message.suggestedAction.replace(/_/g, " ") })
3065
- ] }) })
3066
- ] }),
3067
- message.bulkSessionId && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "mt-3 flex items-center gap-2", children: [
3068
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3069
- Button,
2947
+ actionType === "addApiKey" && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2948
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "API Key Name" }),
2949
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2950
+ Input,
2951
+ {
2952
+ placeholder: "Production Key",
2953
+ value: formData.name || "",
2954
+ onChange: (e) => setActionFormData({
2955
+ ...actionFormData,
2956
+ name: e.target.value
2957
+ }),
2958
+ className: "h-8 text-xs border-gray-200"
2959
+ }
2960
+ )
2961
+ ] }) }),
2962
+ actionType === "addCustomer" && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "space-y-2 bg-gray-50 rounded-lg p-2 border border-gray-200 overflow-hidden", children: [
2963
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "grid grid-cols-2 gap-2", children: [
2964
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2965
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Company Name" }),
2966
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2967
+ Input,
2968
+ {
2969
+ placeholder: "Acme Corporation",
2970
+ value: formData.name || "",
2971
+ onChange: (e) => setActionFormData({
2972
+ ...actionFormData,
2973
+ name: e.target.value
2974
+ }),
2975
+ className: "h-8 text-xs border-gray-200"
2976
+ }
2977
+ )
2978
+ ] }),
2979
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2980
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Email" }),
2981
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2982
+ Input,
2983
+ {
2984
+ type: "email",
2985
+ placeholder: "contact@acme.com",
2986
+ value: formData.email || "",
2987
+ onChange: (e) => setActionFormData({
2988
+ ...actionFormData,
2989
+ email: e.target.value
2990
+ }),
2991
+ className: "h-8 text-xs border-gray-200"
2992
+ }
2993
+ )
2994
+ ] })
2995
+ ] }),
2996
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2997
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Location" }),
2998
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2999
+ Input,
3000
+ {
3001
+ placeholder: "San Francisco, CA",
3002
+ value: formData.location || "",
3003
+ onChange: (e) => setActionFormData({
3004
+ ...actionFormData,
3005
+ location: e.target.value
3006
+ }),
3007
+ className: "h-8 text-xs border-gray-200"
3008
+ }
3009
+ )
3010
+ ] }),
3011
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3012
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Subscription Tier" }),
3013
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3014
+ "select",
3015
+ {
3016
+ value: formData.subscription || "Starter",
3017
+ onChange: (e) => setActionFormData({
3018
+ ...actionFormData,
3019
+ subscription: e.target.value
3020
+ }),
3021
+ className: "h-8 w-full rounded-md border border-gray-200 bg-transparent px-3 py-1 text-xs shadow-xs transition-colors focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] outline-none",
3022
+ children: [
3023
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "Starter", children: "Starter" }),
3024
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "Professional", children: "Professional" }),
3025
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "Enterprise", children: "Enterprise" })
3026
+ ]
3027
+ }
3028
+ )
3029
+ ] })
3030
+ ] }),
3031
+ (actionType === "enable2FA" || actionType === "disable2FA") && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "text-xs text-black", children: actionType === "enable2FA" ? "This will enable two-factor authentication for your account. You'll need to set up an authenticator app." : "This will disable two-factor authentication for your account. Your account will be less secure." }) }),
3032
+ actionType === "changePassword" && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
3033
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3034
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Current Password" }),
3035
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3036
+ Input,
3037
+ {
3038
+ type: "password",
3039
+ value: formData.currentPassword || "",
3040
+ onChange: (e) => setActionFormData({
3041
+ ...actionFormData,
3042
+ currentPassword: e.target.value
3043
+ }),
3044
+ className: "h-8 text-xs border-gray-200"
3045
+ }
3046
+ )
3047
+ ] }),
3048
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3049
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "New Password" }),
3050
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3051
+ Input,
3052
+ {
3053
+ type: "password",
3054
+ value: formData.newPassword || "",
3055
+ onChange: (e) => setActionFormData({
3056
+ ...actionFormData,
3057
+ newPassword: e.target.value
3058
+ }),
3059
+ className: "h-8 text-xs border-gray-200"
3060
+ }
3061
+ )
3062
+ ] }),
3063
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3064
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Confirm New Password" }),
3065
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3066
+ Input,
3067
+ {
3068
+ type: "password",
3069
+ value: formData.confirmPassword || "",
3070
+ onChange: (e) => setActionFormData({
3071
+ ...actionFormData,
3072
+ confirmPassword: e.target.value
3073
+ }),
3074
+ className: "h-8 text-xs border-gray-200"
3075
+ }
3076
+ )
3077
+ ] })
3078
+ ] }),
3079
+ actionType === "toggleNotification" && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
3080
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3081
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Notification Type" }),
3082
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3083
+ "select",
3084
+ {
3085
+ value: formData.notificationType || "paymentReceived",
3086
+ onChange: (e) => setActionFormData({
3087
+ ...actionFormData,
3088
+ notificationType: e.target.value
3089
+ }),
3090
+ className: "h-8 w-full rounded-md border border-gray-200 bg-transparent px-3 py-1 text-xs shadow-xs transition-colors focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] outline-none",
3091
+ children: [
3092
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "paymentReceived", children: "Payment Received" }),
3093
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "paymentFailed", children: "Payment Failed" }),
3094
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "invoicePaid", children: "Invoice Paid" }),
3095
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "monthlySummary", children: "Monthly Summary" }),
3096
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "productUpdates", children: "Product Updates" })
3097
+ ]
3098
+ }
3099
+ )
3100
+ ] }),
3101
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex items-center gap-2", children: [
3102
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3103
+ "input",
3104
+ {
3105
+ type: "checkbox",
3106
+ checked: formData.enabled !== false,
3107
+ onChange: (e) => setActionFormData({
3108
+ ...actionFormData,
3109
+ enabled: e.target.checked
3110
+ }),
3111
+ className: "h-4 w-4 rounded border-gray-300 text-primary focus:ring-primary"
3112
+ }
3113
+ ),
3114
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs text-black", children: "Enable this notification" })
3115
+ ] })
3116
+ ] }),
3117
+ (actionType === "connectIntegration" || actionType === "disconnectIntegration") && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3118
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Integration" }),
3119
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3120
+ "select",
3121
+ {
3122
+ value: formData.integrationName || "Slack",
3123
+ onChange: (e) => setActionFormData({
3124
+ ...actionFormData,
3125
+ integrationName: e.target.value
3126
+ }),
3127
+ className: "h-8 w-full rounded-md border border-gray-200 bg-transparent px-3 py-1 text-xs shadow-xs transition-colors focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] outline-none",
3128
+ children: [
3129
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "Slack", children: "Slack" }),
3130
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "Zapier", children: "Zapier" }),
3131
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "Webhook", children: "Webhook" })
3132
+ ]
3133
+ }
3134
+ )
3135
+ ] }) }),
3136
+ actionType === "addPaymentMethod" && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
3137
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3138
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Card Number" }),
3139
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3140
+ Input,
3141
+ {
3142
+ placeholder: "1234 5678 9012 3456",
3143
+ value: formData.cardNumber || "",
3144
+ onChange: (e) => setActionFormData({
3145
+ ...actionFormData,
3146
+ cardNumber: e.target.value
3147
+ }),
3148
+ className: "h-8 text-xs border-gray-200"
3149
+ }
3150
+ )
3151
+ ] }),
3152
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3153
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Expiry Date" }),
3154
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3155
+ Input,
3156
+ {
3157
+ placeholder: "MM/YY",
3158
+ value: formData.expiryDate || "",
3159
+ onChange: (e) => setActionFormData({
3160
+ ...actionFormData,
3161
+ expiryDate: e.target.value
3162
+ }),
3163
+ className: "h-8 text-xs border-gray-200"
3164
+ }
3165
+ )
3166
+ ] })
3167
+ ] }),
3168
+ actionType === "removePaymentMethod" && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "text-xs text-black", children: "This will remove the default payment method from your account." }) }),
3169
+ actionType === "refundPayment" && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
3170
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3171
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Transaction ID or Customer Name" }),
3172
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3173
+ Input,
3174
+ {
3175
+ placeholder: "e.g., txn_1234 or Acme Corp",
3176
+ value: formData.transactionId || formData.customer || "",
3177
+ onChange: (e) => {
3178
+ const value = e.target.value;
3179
+ if (value.startsWith("txn_") || /^\d+$/.test(value)) {
3180
+ setActionFormData({
3181
+ ...actionFormData,
3182
+ transactionId: value,
3183
+ customer: void 0
3184
+ });
3185
+ } else {
3186
+ setActionFormData({
3187
+ ...actionFormData,
3188
+ customer: value,
3189
+ transactionId: void 0
3190
+ });
3191
+ }
3192
+ },
3193
+ className: "h-8 text-xs border-gray-200"
3194
+ }
3195
+ )
3196
+ ] }),
3197
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3198
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Amount (optional)" }),
3199
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3200
+ Input,
3201
+ {
3202
+ placeholder: "$0.00",
3203
+ value: formData.amount || "",
3204
+ onChange: (e) => setActionFormData({
3205
+ ...actionFormData,
3206
+ amount: e.target.value
3207
+ }),
3208
+ className: "h-8 text-xs border-gray-200"
3209
+ }
3210
+ )
3211
+ ] }),
3212
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3213
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Reason (optional)" }),
3214
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3215
+ Input,
3216
+ {
3217
+ placeholder: "e.g., Customer request",
3218
+ value: formData.reason || "",
3219
+ onChange: (e) => setActionFormData({
3220
+ ...actionFormData,
3221
+ reason: e.target.value
3222
+ }),
3223
+ className: "h-8 text-xs border-gray-200"
3224
+ }
3225
+ )
3226
+ ] })
3227
+ ] }),
3228
+ actionType === "deleteApiKey" && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
3229
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3230
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "API Key Name or ID" }),
3231
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3232
+ Input,
3233
+ {
3234
+ placeholder: "Production Key",
3235
+ value: formData.keyId || formData.name || "",
3236
+ onChange: (e) => setActionFormData({
3237
+ ...actionFormData,
3238
+ keyId: e.target.value,
3239
+ name: e.target.value
3240
+ }),
3241
+ className: "h-8 text-xs border-gray-200"
3242
+ }
3243
+ )
3244
+ ] }),
3245
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "text-xs text-red-600", children: "Warning: This action cannot be undone. The API key will be permanently deleted." })
3246
+ ] }),
3247
+ actionType === "addWebhook" && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
3248
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3249
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Webhook URL" }),
3250
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3251
+ Input,
3252
+ {
3253
+ type: "url",
3254
+ placeholder: "https://example.com/webhook",
3255
+ value: formData.url || "",
3256
+ onChange: (e) => setActionFormData({
3257
+ ...actionFormData,
3258
+ url: e.target.value
3259
+ }),
3260
+ className: "h-8 text-xs border-gray-200"
3261
+ }
3262
+ )
3263
+ ] }),
3264
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3265
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Name (optional)" }),
3266
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3267
+ Input,
3268
+ {
3269
+ placeholder: "Production Webhook",
3270
+ value: formData.name || "",
3271
+ onChange: (e) => setActionFormData({
3272
+ ...actionFormData,
3273
+ name: e.target.value
3274
+ }),
3275
+ className: "h-8 text-xs border-gray-200"
3276
+ }
3277
+ )
3278
+ ] })
3279
+ ] }),
3280
+ actionType === "updateCurrency" && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3281
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Currency" }),
3282
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3283
+ "select",
3284
+ {
3285
+ value: formData.currency || "USD",
3286
+ onChange: (e) => setActionFormData({
3287
+ ...actionFormData,
3288
+ currency: e.target.value
3289
+ }),
3290
+ className: "h-8 w-full rounded-md border border-gray-200 bg-transparent px-3 py-1 text-xs shadow-xs transition-colors focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] outline-none",
3291
+ children: [
3292
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "USD", children: "USD ($)" }),
3293
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "EUR", children: "EUR (\u20AC)" }),
3294
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "GBP", children: "GBP (\xA3)" }),
3295
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "JPY", children: "JPY (\xA5)" })
3296
+ ]
3297
+ }
3298
+ )
3299
+ ] }) }),
3300
+ actionType === "updateTimezone" && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3301
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Timezone" }),
3302
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3303
+ "select",
3304
+ {
3305
+ value: formData.timezone || "America/Los_Angeles",
3306
+ onChange: (e) => setActionFormData({
3307
+ ...actionFormData,
3308
+ timezone: e.target.value
3309
+ }),
3310
+ className: "h-8 w-full rounded-md border border-gray-200 bg-transparent px-3 py-1 text-xs shadow-xs transition-colors focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] outline-none",
3311
+ children: [
3312
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "America/Los_Angeles", children: "Pacific Time (PT)" }),
3313
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "America/New_York", children: "Eastern Time (ET)" }),
3314
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "Europe/London", children: "GMT" }),
3315
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "Asia/Tokyo", children: "JST" })
3316
+ ]
3317
+ }
3318
+ )
3319
+ ] }) }),
3320
+ actionType === "revokeSession" && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
3321
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3322
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Device/Session" }),
3323
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3324
+ Input,
3325
+ {
3326
+ placeholder: "MacBook Pro",
3327
+ value: formData.device || "",
3328
+ onChange: (e) => setActionFormData({
3329
+ ...actionFormData,
3330
+ device: e.target.value
3331
+ }),
3332
+ className: "h-8 text-xs border-gray-200"
3333
+ }
3334
+ )
3335
+ ] }),
3336
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "text-xs text-black", children: "This will sign out the device and invalidate its session." })
3337
+ ] }),
3338
+ actionType === "createSubscription" && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
3339
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3340
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Customer Email" }),
3341
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3342
+ Input,
3343
+ {
3344
+ type: "email",
3345
+ placeholder: "customer@example.com",
3346
+ value: formData.customerEmail || "",
3347
+ onChange: (e) => setActionFormData({
3348
+ ...actionFormData,
3349
+ customerEmail: e.target.value
3350
+ }),
3351
+ className: "h-8 text-xs border-gray-200"
3352
+ }
3353
+ )
3354
+ ] }),
3355
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3356
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Plan" }),
3357
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3358
+ "select",
3359
+ {
3360
+ value: formData.plan || "Starter",
3361
+ onChange: (e) => setActionFormData({
3362
+ ...actionFormData,
3363
+ plan: e.target.value
3364
+ }),
3365
+ className: "h-8 w-full rounded-md border border-gray-200 bg-transparent px-3 py-1 text-xs shadow-xs transition-colors focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] outline-none",
3366
+ children: [
3367
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "Starter", children: "Starter ($29/mo)" }),
3368
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "Professional", children: "Professional ($99/mo)" }),
3369
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "Enterprise", children: "Enterprise ($299/mo)" })
3370
+ ]
3371
+ }
3372
+ )
3373
+ ] }),
3374
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3375
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Billing Cycle" }),
3376
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3377
+ "select",
3378
+ {
3379
+ value: formData.billingCycle || "monthly",
3380
+ onChange: (e) => setActionFormData({
3381
+ ...actionFormData,
3382
+ billingCycle: e.target.value
3383
+ }),
3384
+ className: "h-8 w-full rounded-md border border-gray-200 bg-transparent px-3 py-1 text-xs shadow-xs transition-colors focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] outline-none",
3385
+ children: [
3386
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "monthly", children: "Monthly" }),
3387
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "yearly", children: "Yearly (Save 15%)" })
3388
+ ]
3389
+ }
3390
+ )
3391
+ ] })
3392
+ ] }),
3393
+ actionType === "exportCertificate" && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
3394
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "text-xs text-black", children: "This will export your certificate of incorporation document." }),
3395
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3396
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Format" }),
3397
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3398
+ "select",
3399
+ {
3400
+ value: formData.format || "pdf",
3401
+ onChange: (e) => setActionFormData({
3402
+ ...actionFormData,
3403
+ format: e.target.value
3404
+ }),
3405
+ className: "h-8 w-full rounded-md border border-gray-200 bg-transparent px-3 py-1 text-xs shadow-xs transition-colors focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] outline-none",
3406
+ children: [
3407
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "pdf", children: "PDF" }),
3408
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "json", children: "JSON" })
3409
+ ]
3410
+ }
3411
+ )
3412
+ ] })
3413
+ ] }),
3414
+ (actionType === "toggleBlockRule" || actionType === "enableBlockRule" || actionType === "disableBlockRule") && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
3415
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3416
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Block Rule" }),
3417
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3418
+ "select",
3419
+ {
3420
+ value: formData.ruleId || "rule_1",
3421
+ onChange: (e) => setActionFormData({
3422
+ ...actionFormData,
3423
+ ruleId: e.target.value
3424
+ }),
3425
+ className: "h-8 w-full rounded-md border border-gray-200 bg-transparent px-3 py-1 text-xs shadow-xs transition-colors focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] outline-none",
3426
+ children: [
3427
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "rule_1", children: "Block if risk level = 'highest'" }),
3428
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "rule_2", children: "Block if matches Stripe block lists" }),
3429
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "rule_3", children: "Block if CVC verification fails" }),
3430
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "rule_4", children: "Block if Postal code verification fails" })
3431
+ ]
3432
+ }
3433
+ )
3434
+ ] }),
3435
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "text-xs text-black", children: actionType === "enableBlockRule" ? "This will enable the selected block rule to actively block matching payments." : actionType === "disableBlockRule" ? "This will disable the selected block rule. Matching payments will no longer be blocked." : "This will toggle the selected block rule's state." })
3436
+ ] }),
3437
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "mt-3", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3438
+ Button,
3439
+ {
3440
+ type: "button",
3441
+ size: "sm",
3442
+ variant: "secondary",
3443
+ className: "h-8 rounded-xl px-3 text-xs gap-1.5 bg-gray-100 hover:bg-gray-200 border border-gray-200",
3444
+ onClick: handleActionSubmit,
3445
+ children: [
3446
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { children: "Confirm" }),
3447
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "flex items-center gap-0.5 text-gray-400", children: [
3448
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.Command, { className: "h-3 w-3" }),
3449
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.CornerDownLeft, { className: "h-3 w-3" })
3450
+ ] })
3451
+ ]
3452
+ }
3453
+ ) })
3454
+ ]
3455
+ },
3456
+ message.id
3457
+ );
3458
+ }
3459
+ if (message.kind === "bulkPreview" && message.csvData) {
3460
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3461
+ "div",
3070
3462
  {
3071
- type: "button",
3072
- size: "sm",
3073
- variant: "secondary",
3074
- className: "h-8 rounded-xl px-3 text-xs gap-1.5 bg-gray-100 hover:bg-gray-200 border border-gray-200",
3075
- onClick: () => message.bulkSessionId && confirmBulkOperation(message.bulkSessionId),
3463
+ className: `${isRoleChange ? "mt-3" : ""}`,
3076
3464
  children: [
3077
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { children: [
3078
- "Process ",
3079
- message.csvData.rowCount,
3080
- " rows"
3465
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "whitespace-pre-wrap text-sm leading-6 mb-3 text-gray-700", children: message.content || "" }),
3466
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "bg-gray-50 rounded-lg border border-gray-200 overflow-hidden", children: [
3467
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "bg-gray-100 px-3 py-2 border-b border-gray-200 flex items-center gap-2", children: [
3468
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.FileSpreadsheet, { className: "h-4 w-4 text-gray-600" }),
3469
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "text-xs font-medium text-gray-700", children: message.csvData.fileName }),
3470
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "text-xs text-gray-500", children: [
3471
+ "\u2022 ",
3472
+ message.csvData.rowCount,
3473
+ " rows"
3474
+ ] })
3475
+ ] }),
3476
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "px-3 py-2 border-b border-gray-100", children: [
3477
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "text-[10px] uppercase tracking-wider text-gray-500 mb-1", children: "Columns" }),
3478
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "flex flex-wrap gap-1", children: message.csvData.columns.map((col, i) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3479
+ "span",
3480
+ {
3481
+ className: "text-xs bg-blue-100 text-blue-700 px-1.5 py-0.5 rounded",
3482
+ children: col
3483
+ },
3484
+ i
3485
+ )) })
3486
+ ] }),
3487
+ message.csvData.sampleRows.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "px-3 py-2", children: [
3488
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "text-[10px] uppercase tracking-wider text-gray-500 mb-1", children: "Sample Data" }),
3489
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "space-y-1", children: message.csvData.sampleRows.slice(0, 3).map((row, i) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3490
+ "div",
3491
+ {
3492
+ className: "text-xs text-gray-600 bg-white rounded px-2 py-1 border border-gray-100",
3493
+ children: [
3494
+ Object.entries(row).slice(0, 3).map(([key, val], j) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { children: [
3495
+ j > 0 && " \u2022 ",
3496
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "text-gray-400", children: [
3497
+ key,
3498
+ ":"
3499
+ ] }),
3500
+ " ",
3501
+ val
3502
+ ] }, key)),
3503
+ Object.keys(row).length > 3 && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "text-gray-400", children: [
3504
+ " ",
3505
+ "..."
3506
+ ] })
3507
+ ]
3508
+ },
3509
+ i
3510
+ )) })
3511
+ ] }),
3512
+ message.suggestedAction && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "px-3 py-2 bg-blue-50 border-t border-blue-100", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "text-xs text-blue-700", children: [
3513
+ "Suggested action:",
3514
+ " ",
3515
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("strong", { children: message.suggestedAction.replace(/_/g, " ") })
3516
+ ] }) })
3081
3517
  ] }),
3082
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "flex items-center gap-0.5 text-gray-400", children: [
3083
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.Command, { className: "h-3 w-3" }),
3084
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.CornerDownLeft, { className: "h-3 w-3" })
3518
+ message.bulkSessionId && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "mt-3 flex items-center gap-2", children: [
3519
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3520
+ Button,
3521
+ {
3522
+ type: "button",
3523
+ size: "sm",
3524
+ variant: "secondary",
3525
+ className: "h-8 rounded-xl px-3 text-xs gap-1.5 bg-gray-100 hover:bg-gray-200 border border-gray-200",
3526
+ onClick: () => message.bulkSessionId && confirmBulkOperation(message.bulkSessionId),
3527
+ children: [
3528
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { children: [
3529
+ "Process ",
3530
+ message.csvData.rowCount,
3531
+ " rows"
3532
+ ] }),
3533
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "flex items-center gap-0.5 text-gray-400", children: [
3534
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.Command, { className: "h-3 w-3" }),
3535
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.CornerDownLeft, { className: "h-3 w-3" })
3536
+ ] })
3537
+ ]
3538
+ }
3539
+ ),
3540
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3541
+ Button,
3542
+ {
3543
+ type: "button",
3544
+ size: "sm",
3545
+ variant: "ghost",
3546
+ className: "h-8 rounded-xl px-3 text-xs text-gray-500 hover:text-gray-700 hover:bg-gray-100",
3547
+ onClick: cancelBulkOperation,
3548
+ children: "Cancel"
3549
+ }
3550
+ )
3085
3551
  ] })
3086
3552
  ]
3087
- }
3088
- ),
3089
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3090
- Button,
3553
+ },
3554
+ message.id
3555
+ );
3556
+ }
3557
+ if (message.kind === "bulkProgress" && message.bulkProgress) {
3558
+ const { processed, total, successes, failures } = message.bulkProgress;
3559
+ const percentage = Math.round(processed / total * 100);
3560
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3561
+ "div",
3091
3562
  {
3092
- type: "button",
3093
- size: "sm",
3094
- variant: "ghost",
3095
- className: "h-8 rounded-xl px-3 text-xs text-gray-500 hover:text-gray-700 hover:bg-gray-100",
3096
- onClick: cancelBulkOperation,
3097
- children: "Cancel"
3098
- }
3099
- )
3100
- ] })
3101
- ] }, message.id);
3102
- }
3103
- if (message.kind === "bulkProgress" && message.bulkProgress) {
3104
- const { processed, total, successes, failures } = message.bulkProgress;
3105
- const percentage = Math.round(processed / total * 100);
3106
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: `${isRoleChange ? "mt-3" : ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "bg-gray-50 rounded-lg border border-gray-200 p-3", children: [
3107
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex items-center gap-2 mb-2", children: [
3108
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.Loader2, { className: "h-4 w-4 animate-spin text-blue-600" }),
3109
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "text-sm font-medium text-gray-700", children: [
3110
- "Processing... ",
3111
- processed,
3112
- " of ",
3113
- total
3114
- ] })
3115
- ] }),
3116
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "h-2 bg-gray-200 rounded-full overflow-hidden mb-2", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3563
+ className: `${isRoleChange ? "mt-3" : ""}`,
3564
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "bg-gray-50 rounded-lg border border-gray-200 p-3", children: [
3565
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex items-center gap-2 mb-2", children: [
3566
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.Loader2, { className: "h-4 w-4 animate-spin text-blue-600" }),
3567
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "text-sm font-medium text-gray-700", children: [
3568
+ "Processing... ",
3569
+ processed,
3570
+ " of ",
3571
+ total
3572
+ ] })
3573
+ ] }),
3574
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "h-2 bg-gray-200 rounded-full overflow-hidden mb-2", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3575
+ "div",
3576
+ {
3577
+ className: "h-full bg-blue-600 transition-all duration-300",
3578
+ style: { width: `${percentage}%` }
3579
+ }
3580
+ ) }),
3581
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex items-center gap-3 text-xs text-gray-600", children: [
3582
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "flex items-center gap-1", children: [
3583
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.CheckCircle2, { className: "h-3 w-3 text-green-600" }),
3584
+ successes,
3585
+ " successful"
3586
+ ] }),
3587
+ failures > 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "flex items-center gap-1 text-red-600", children: [
3588
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.X, { className: "h-3 w-3" }),
3589
+ failures,
3590
+ " failed"
3591
+ ] })
3592
+ ] })
3593
+ ] })
3594
+ },
3595
+ message.id
3596
+ );
3597
+ }
3598
+ if (message.kind === "bulkSummary" && message.bulkSummary) {
3599
+ const { total, successes, failures, navigationPage } = message.bulkSummary;
3600
+ const hasFailures = failures.length > 0;
3601
+ const pageLabel = navigationPage?.page === "customers" ? "Customers" : navigationPage?.page === "dashboard" ? "Dashboard" : navigationPage?.page === "settings" ? "Settings" : "Results";
3602
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3603
+ "div",
3604
+ {
3605
+ className: `${isRoleChange ? "mt-3" : ""}`,
3606
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3607
+ "div",
3608
+ {
3609
+ className: `rounded-lg border p-3 ${hasFailures ? "bg-amber-50 border-amber-200" : "bg-green-50 border-green-200"}`,
3610
+ children: [
3611
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex items-center gap-2 mb-2", children: [
3612
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3613
+ import_lucide_react4.CheckCircle2,
3614
+ {
3615
+ className: `h-5 w-5 ${hasFailures ? "text-amber-600" : "text-green-600"}`
3616
+ }
3617
+ ),
3618
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "text-sm font-medium text-gray-800", children: "Bulk operation complete" })
3619
+ ] }),
3620
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "text-sm text-gray-600 mb-2", children: message.content || `Processed ${total} rows: ${successes} successful${hasFailures ? `, ${failures.length} failed` : ""}.` }),
3621
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex items-center gap-4 text-xs", children: [
3622
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "flex items-center gap-1 text-green-700", children: [
3623
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.CheckCircle2, { className: "h-3 w-3" }),
3624
+ successes,
3625
+ " successful"
3626
+ ] }),
3627
+ hasFailures && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "flex items-center gap-1 text-red-600", children: [
3628
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.X, { className: "h-3 w-3" }),
3629
+ failures.length,
3630
+ " failed"
3631
+ ] })
3632
+ ] }),
3633
+ hasFailures && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "mt-3 pt-2 border-t border-amber-200", children: [
3634
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "text-[10px] uppercase tracking-wider text-amber-700 mb-1", children: "Failed Rows" }),
3635
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "space-y-1 max-h-32 overflow-y-auto", children: [
3636
+ failures.slice(0, 5).map((failure, i) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3637
+ "div",
3638
+ {
3639
+ className: "text-xs text-red-700 bg-red-50 rounded px-2 py-1",
3640
+ children: [
3641
+ "Row ",
3642
+ failure.row,
3643
+ ":",
3644
+ " ",
3645
+ failure.error || "Unknown error"
3646
+ ]
3647
+ },
3648
+ i
3649
+ )),
3650
+ failures.length > 5 && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "text-xs text-amber-600", children: [
3651
+ "...and ",
3652
+ failures.length - 5,
3653
+ " more"
3654
+ ] })
3655
+ ] })
3656
+ ] }),
3657
+ navigationPage && successes > 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "mt-3 pt-2 border-t border-gray-200", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3658
+ "button",
3659
+ {
3660
+ type: "button",
3661
+ onClick: (e) => {
3662
+ e.preventDefault();
3663
+ e.stopPropagation();
3664
+ console.log(
3665
+ "[DEBUG] Button clicked - navigationPage:",
3666
+ navigationPage,
3667
+ "onNavigate:",
3668
+ !!onNavigate
3669
+ );
3670
+ if (onNavigate && navigationPage.page) {
3671
+ console.log(
3672
+ "[DEBUG] Calling onNavigate with page:",
3673
+ navigationPage.page
3674
+ );
3675
+ onNavigate(
3676
+ navigationPage.page,
3677
+ navigationPage.subtab
3678
+ );
3679
+ } else {
3680
+ console.log(
3681
+ "[DEBUG] Condition failed - onNavigate:",
3682
+ !!onNavigate,
3683
+ "navigationPage.page:",
3684
+ navigationPage.page
3685
+ );
3686
+ }
3687
+ },
3688
+ className: "flex items-center gap-2 text-xs text-gray-500 hover:text-gray-700 transition-colors group cursor-pointer",
3689
+ children: [
3690
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "flex items-center gap-1 px-1.5 py-0.5 bg-gray-100 rounded text-[10px] font-medium text-gray-600 group-hover:bg-gray-200", children: [
3691
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.Command, { className: "h-2.5 w-2.5" }),
3692
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { children: "+" }),
3693
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.CornerDownLeft, { className: "h-2.5 w-2.5" })
3694
+ ] }),
3695
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { children: [
3696
+ "View ",
3697
+ pageLabel
3698
+ ] })
3699
+ ]
3700
+ }
3701
+ ) })
3702
+ ]
3703
+ }
3704
+ )
3705
+ },
3706
+ message.id
3707
+ );
3708
+ }
3709
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(React4.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3117
3710
  "div",
3118
3711
  {
3119
- className: "h-full bg-blue-600 transition-all duration-300",
3120
- style: { width: `${percentage}%` }
3712
+ ref: isCurrentGuideStep ? currentStepRef : null,
3713
+ className: `${isRoleChange ? "mt-3" : ""}`,
3714
+ children: [
3715
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "text-sm leading-6 text-gray-700", children: (() => {
3716
+ const text = message.content || "";
3717
+ if (message.kind === "guideStep") {
3718
+ const m = text.match(/^(Step\s+\d+:)([\s\S]*)/);
3719
+ if (m) {
3720
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
3721
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("strong", { children: m[1] }),
3722
+ m[2]
3723
+ ] });
3724
+ }
3725
+ }
3726
+ if (message.role === "assistant" && text) {
3727
+ return renderMarkdown(text);
3728
+ }
3729
+ return text || /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "opacity-70", children: "Thinking\u2026" });
3730
+ })() }),
3731
+ message.role === "assistant" && message.structuredData && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "mt-3", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3732
+ DataRenderer,
3733
+ {
3734
+ type: message.structuredData.type,
3735
+ data: message.structuredData.data
3736
+ }
3737
+ ) }),
3738
+ message.role === "assistant" && message.followups && message.followups.length > 0 && !message.followupSelected && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "mt-3 flex flex-wrap gap-1.5", children: message.followups.map((followup) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3739
+ "button",
3740
+ {
3741
+ type: "button",
3742
+ onClick: () => handleFollowupClick(message.id, followup),
3743
+ className: "inline-flex items-center px-3 py-1.5 text-xs font-medium rounded-xl\n bg-white hover:bg-gray-50 text-gray-600 hover:text-gray-800\n border border-gray-200 hover:border-gray-300 shadow-sm\n transition-all duration-150 ease-in-out",
3744
+ children: followup.label
3745
+ },
3746
+ followup.id
3747
+ )) })
3748
+ ]
3121
3749
  }
3122
- ) }),
3123
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex items-center gap-3 text-xs text-gray-600", children: [
3124
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "flex items-center gap-1", children: [
3125
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.CheckCircle2, { className: "h-3 w-3 text-green-600" }),
3126
- successes,
3127
- " successful"
3128
- ] }),
3129
- failures > 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "flex items-center gap-1 text-red-600", children: [
3130
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.X, { className: "h-3 w-3" }),
3131
- failures,
3132
- " failed"
3133
- ] })
3134
- ] })
3135
- ] }) }, message.id);
3136
- }
3137
- if (message.kind === "bulkSummary" && message.bulkSummary) {
3138
- const { total, successes, failures, navigationPage } = message.bulkSummary;
3139
- const hasFailures = failures.length > 0;
3140
- const pageLabel = navigationPage?.page === "customers" ? "Customers" : navigationPage?.page === "dashboard" ? "Dashboard" : navigationPage?.page === "settings" ? "Settings" : "Results";
3141
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: `${isRoleChange ? "mt-3" : ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: `rounded-lg border p-3 ${hasFailures ? "bg-amber-50 border-amber-200" : "bg-green-50 border-green-200"}`, children: [
3142
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex items-center gap-2 mb-2", children: [
3143
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.CheckCircle2, { className: `h-5 w-5 ${hasFailures ? "text-amber-600" : "text-green-600"}` }),
3144
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "text-sm font-medium text-gray-800", children: "Bulk operation complete" })
3145
- ] }),
3146
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "text-sm text-gray-600 mb-2", children: message.content || `Processed ${total} rows: ${successes} successful${hasFailures ? `, ${failures.length} failed` : ""}.` }),
3147
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex items-center gap-4 text-xs", children: [
3148
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "flex items-center gap-1 text-green-700", children: [
3149
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.CheckCircle2, { className: "h-3 w-3" }),
3150
- successes,
3151
- " successful"
3152
- ] }),
3153
- hasFailures && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "flex items-center gap-1 text-red-600", children: [
3154
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.X, { className: "h-3 w-3" }),
3155
- failures.length,
3156
- " failed"
3157
- ] })
3158
- ] }),
3159
- hasFailures && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "mt-3 pt-2 border-t border-amber-200", children: [
3160
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "text-[10px] uppercase tracking-wider text-amber-700 mb-1", children: "Failed Rows" }),
3161
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "space-y-1 max-h-32 overflow-y-auto", children: [
3162
- failures.slice(0, 5).map((failure, i) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "text-xs text-red-700 bg-red-50 rounded px-2 py-1", children: [
3163
- "Row ",
3164
- failure.row,
3165
- ": ",
3166
- failure.error || "Unknown error"
3167
- ] }, i)),
3168
- failures.length > 5 && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "text-xs text-amber-600", children: [
3169
- "...and ",
3170
- failures.length - 5,
3171
- " more"
3172
- ] })
3173
- ] })
3174
- ] }),
3175
- navigationPage && successes > 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "mt-3 pt-2 border-t border-gray-200", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3176
- "button",
3750
+ ) }, message.id);
3751
+ }),
3752
+ (activeGuide || guideComplete) && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "mt-3 flex items-center gap-2", children: [
3753
+ activeGuide && activeGuide.stepIndex > 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3754
+ Button,
3177
3755
  {
3178
3756
  type: "button",
3179
- onClick: (e) => {
3180
- e.preventDefault();
3181
- e.stopPropagation();
3182
- console.log("[DEBUG] Button clicked - navigationPage:", navigationPage, "onNavigate:", !!onNavigate);
3183
- if (onNavigate && navigationPage.page) {
3184
- console.log("[DEBUG] Calling onNavigate with page:", navigationPage.page);
3185
- onNavigate(navigationPage.page, navigationPage.subtab);
3186
- } else {
3187
- console.log("[DEBUG] Condition failed - onNavigate:", !!onNavigate, "navigationPage.page:", navigationPage.page);
3188
- }
3189
- },
3190
- className: "flex items-center gap-2 text-xs text-gray-500 hover:text-gray-700 transition-colors group cursor-pointer",
3757
+ size: "sm",
3758
+ variant: "secondary",
3759
+ className: "h-7 w-7 rounded-full p-0 bg-gray-100 hover:bg-gray-200 border border-gray-200",
3760
+ onClick: goBackGuide,
3761
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.ArrowLeft, { className: "h-3.5 w-3.5 text-gray-600" })
3762
+ }
3763
+ ),
3764
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3765
+ Button,
3766
+ {
3767
+ type: "button",
3768
+ size: "sm",
3769
+ variant: "secondary",
3770
+ className: "h-8 rounded-xl px-3 text-xs gap-1.5 bg-gray-100 hover:bg-gray-200 border border-gray-200",
3771
+ onClick: guideComplete ? handleBack : advanceGuide,
3191
3772
  children: [
3192
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "flex items-center gap-1 px-1.5 py-0.5 bg-gray-100 rounded text-[10px] font-medium text-gray-600 group-hover:bg-gray-200", children: [
3193
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.Command, { className: "h-2.5 w-2.5" }),
3194
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { children: "+" }),
3195
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.CornerDownLeft, { className: "h-2.5 w-2.5" })
3196
- ] }),
3197
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { children: [
3198
- "View ",
3199
- pageLabel
3773
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { children: guideComplete ? "Done" : "Next" }),
3774
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "flex items-center gap-0.5 text-gray-400", children: [
3775
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.Command, { className: "h-3 w-3" }),
3776
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.CornerDownLeft, { className: "h-3 w-3" })
3200
3777
  ] })
3201
3778
  ]
3202
3779
  }
3203
- ) })
3204
- ] }) }, message.id);
3205
- }
3206
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(React4.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3207
- "div",
3208
- {
3209
- ref: isCurrentGuideStep ? currentStepRef : null,
3210
- className: `${isRoleChange ? "mt-3" : ""}`,
3211
- children: [
3212
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "text-sm leading-6 text-gray-700", children: (() => {
3213
- const text = message.content || "";
3214
- if (message.kind === "guideStep") {
3215
- const m = text.match(/^(Step\s+\d+:)([\s\S]*)/);
3216
- if (m) {
3217
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
3218
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("strong", { children: m[1] }),
3219
- m[2]
3220
- ] });
3221
- }
3222
- }
3223
- if (message.role === "assistant" && text) {
3224
- return renderMarkdown(text);
3225
- }
3226
- return text || /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "opacity-70", children: "Thinking\u2026" });
3227
- })() }),
3228
- message.role === "assistant" && message.structuredData && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "mt-3", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3229
- DataRenderer,
3230
- {
3231
- type: message.structuredData.type,
3232
- data: message.structuredData.data
3233
- }
3234
- ) }),
3235
- message.role === "assistant" && message.followups && message.followups.length > 0 && !message.followupSelected && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "mt-3 flex flex-wrap gap-1.5", children: message.followups.map((followup) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3236
- "button",
3237
- {
3238
- type: "button",
3239
- onClick: () => handleFollowupClick(message.id, followup),
3240
- className: "inline-flex items-center px-3 py-1.5 text-xs font-medium rounded-xl\n bg-white hover:bg-gray-50 text-gray-600 hover:text-gray-800\n border border-gray-200 hover:border-gray-300 shadow-sm\n transition-all duration-150 ease-in-out",
3241
- children: followup.label
3242
- },
3243
- followup.id
3244
- )) })
3245
- ]
3246
- }
3247
- ) }, message.id);
3248
- }),
3249
- (activeGuide || guideComplete) && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "mt-3 flex items-center gap-2", children: [
3250
- activeGuide && activeGuide.stepIndex > 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3251
- Button,
3252
- {
3253
- type: "button",
3254
- size: "sm",
3255
- variant: "secondary",
3256
- className: "h-7 w-7 rounded-full p-0 bg-gray-100 hover:bg-gray-200 border border-gray-200",
3257
- onClick: goBackGuide,
3258
- children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.ArrowLeft, { className: "h-3.5 w-3.5 text-gray-600" })
3259
- }
3260
- ),
3261
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3262
- Button,
3263
- {
3264
- type: "button",
3265
- size: "sm",
3266
- variant: "secondary",
3267
- className: "h-8 rounded-xl px-3 text-xs gap-1.5 bg-gray-100 hover:bg-gray-200 border border-gray-200",
3268
- onClick: guideComplete ? handleBack : advanceGuide,
3269
- children: [
3270
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { children: guideComplete ? "Done" : "Next" }),
3271
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "flex items-center gap-0.5 text-gray-400", children: [
3272
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.Command, { className: "h-3 w-3" }),
3273
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.CornerDownLeft, { className: "h-3 w-3" })
3274
- ] })
3275
- ]
3276
- }
3277
- )
3278
- ] }),
3279
- (phase === "thinking" || phase === "searching" || phase === "executing" || phase === "responding") && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: `${lastRole === "user" ? "mt-3" : ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3280
- AssistantActivity,
3281
- {
3282
- phase,
3283
- progressSteps
3284
- }
3285
- ) }),
3286
- !activeGuide && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { ref: messagesEndRef })
3287
- ] }) }) }) }) }),
3780
+ )
3781
+ ] }),
3782
+ (phase === "thinking" || phase === "searching" || phase === "executing" || phase === "responding") && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: `${lastRole === "user" ? "mt-3" : ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3783
+ AssistantActivity,
3784
+ {
3785
+ phase,
3786
+ progressSteps
3787
+ }
3788
+ ) }),
3789
+ !activeGuide && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { ref: messagesEndRef })
3790
+ ] }) }) }) })
3791
+ }
3792
+ ),
3288
3793
  /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "px-4 py-3 border-t border-gray-100 bg-gray-50/50 shrink-0", children: [
3289
3794
  pendingFile && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "mb-2 flex items-center gap-2 rounded-xl bg-blue-50 border border-blue-200 px-3 py-2", children: [
3290
3795
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.FileSpreadsheet, { className: "h-4 w-4 text-blue-600" }),
@@ -3318,7 +3823,7 @@ ${userText}`
3318
3823
  }
3319
3824
  }
3320
3825
  ),
3321
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex w-full items-center gap-2 rounded-2xl border border-gray-200 bg-white px-3 py-2 shadow-sm", children: [
3826
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex w-full items-start gap-2 rounded-xl border border-gray-200 bg-white px-3 py-2 shadow-sm", children: [
3322
3827
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3323
3828
  Button,
3324
3829
  {
@@ -3326,9 +3831,9 @@ ${userText}`
3326
3831
  size: "icon",
3327
3832
  variant: "ghost",
3328
3833
  onClick: () => fileInputRef.current?.click(),
3329
- className: "h-8 w-8 rounded-full text-gray-400 hover:text-gray-600 hover:bg-gray-100",
3834
+ className: "h-5 w-5 rounded-full text-gray-400 hover:text-gray-600 hover:bg-gray-100",
3330
3835
  title: "Upload CSV for bulk operations",
3331
- children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.Paperclip, { className: "h-4 w-4" })
3836
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.Paperclip, { className: "h-2.5 w-2.5" })
3332
3837
  }
3333
3838
  ),
3334
3839
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
@@ -3380,9 +3885,7 @@ ${userText}`
3380
3885
  return;
3381
3886
  }
3382
3887
  }
3383
- },
3384
- rows: 1,
3385
- className: "flex-1 border-0 bg-transparent focus-visible:ring-0 focus-visible:ring-offset-0 text-sm placeholder:text-gray-400 resize-none overflow-y-auto min-h-[24px] max-h-[120px] py-0 leading-6"
3888
+ }
3386
3889
  }
3387
3890
  ),
3388
3891
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
@@ -3391,8 +3894,8 @@ ${userText}`
3391
3894
  type: "submit",
3392
3895
  size: "icon",
3393
3896
  disabled: !input.trim() && !pendingFile,
3394
- className: "h-8 w-8 rounded-full bg-gray-900 hover:bg-gray-800 disabled:bg-gray-300",
3395
- children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.ArrowUp, { className: "h-4 w-4" })
3897
+ className: "h-6 w-6 rounded-full bg-gray-900 hover:bg-gray-800 disabled:bg-gray-300",
3898
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.ArrowUp, { className: "h-2.5 w-2.5" })
3396
3899
  }
3397
3900
  )
3398
3901
  ] })
@@ -3411,7 +3914,11 @@ ${userText}`
3411
3914
  }
3412
3915
  );
3413
3916
  }
3414
- function PanelToggle({ isOpen, onClick, className = "" }) {
3917
+ function PanelToggle({
3918
+ isOpen,
3919
+ onClick,
3920
+ className = ""
3921
+ }) {
3415
3922
  return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3416
3923
  "button",
3417
3924
  {
@@ -3457,13 +3964,7 @@ function ChatPanelWithToggle({
3457
3964
  };
3458
3965
  }, [isOpen]);
3459
3966
  return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
3460
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3461
- PanelToggle,
3462
- {
3463
- isOpen,
3464
- onClick: () => setIsOpen(!isOpen)
3465
- }
3466
- ),
3967
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(PanelToggle, { isOpen, onClick: () => setIsOpen(!isOpen) }),
3467
3968
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3468
3969
  ChatPanel,
3469
3970
  {