@kite-copilot/chat-panel 0.2.16 → 0.2.18

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
@@ -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");
@@ -1587,7 +1715,11 @@ function ChatPanel({
1587
1715
  const isRespondingToNotification = lastAssistantMessage?.isNotificationMessage === true;
1588
1716
  const now = Date.now();
1589
1717
  const userMessage = { id: now, role: "user", content: userText };
1590
- setMessages((prev) => [...prev, userMessage]);
1718
+ setMessages(
1719
+ (prev) => prev.map(
1720
+ (m) => m.followups && m.followups.length > 0 ? { ...m, followupSelected: true } : m
1721
+ ).concat(userMessage)
1722
+ );
1591
1723
  if (isRespondingToNotification) {
1592
1724
  const thankYouMessageId = Date.now() + 1;
1593
1725
  const thankYouMessage = {
@@ -1597,7 +1729,10 @@ function ChatPanel({
1597
1729
  content: ""
1598
1730
  };
1599
1731
  setMessages((prev) => [...prev, thankYouMessage]);
1600
- streamAssistantMessage(thankYouMessageId, "Thank you, your feedback is saved.");
1732
+ streamAssistantMessage(
1733
+ thankYouMessageId,
1734
+ "Thank you, your feedback is saved."
1735
+ );
1601
1736
  return;
1602
1737
  }
1603
1738
  setPendingNavigation(null);
@@ -1655,7 +1790,10 @@ function ChatPanel({
1655
1790
  } else if (data.status === "executing") {
1656
1791
  setPhase("executing");
1657
1792
  setProgressSteps((prev) => {
1658
- const updated = prev.map((step) => ({ ...step, completed: true }));
1793
+ const updated = prev.map((step) => ({
1794
+ ...step,
1795
+ completed: true
1796
+ }));
1659
1797
  const lastStep = updated[updated.length - 1];
1660
1798
  if (!lastStep || lastStep.message !== data.message) {
1661
1799
  updated.push({ message: data.message, completed: false });
@@ -1664,7 +1802,9 @@ function ChatPanel({
1664
1802
  });
1665
1803
  } else if (data.status === "responding") {
1666
1804
  setPhase("responding");
1667
- setProgressSteps((prev) => prev.map((step) => ({ ...step, completed: true })));
1805
+ setProgressSteps(
1806
+ (prev) => prev.map((step) => ({ ...step, completed: true }))
1807
+ );
1668
1808
  }
1669
1809
  } else if (eventType === "response") {
1670
1810
  setProgressSteps([]);
@@ -1710,7 +1850,11 @@ function ChatPanel({
1710
1850
  content: ""
1711
1851
  };
1712
1852
  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);
1853
+ streamAssistantMessage(
1854
+ assistantMessageId,
1855
+ agentResponse.response || agentResponse.message || "For bulk operations, you can upload a CSV file - just click the \u{1F4CE} button!",
1856
+ agentResponse.followups
1857
+ );
1714
1858
  streamCompleted = true;
1715
1859
  } else if (agentResponse.action === "bulk_preview") {
1716
1860
  setPendingBulkSession(agentResponse.bulk_session_id);
@@ -1742,12 +1886,18 @@ function ChatPanel({
1742
1886
  structuredData: agentResponse.structuredData || void 0
1743
1887
  };
1744
1888
  setMessages((prev) => [...prev, assistantMessage]);
1745
- streamAssistantMessage(assistantMessageId, agentResponse.response, agentResponse.followups);
1889
+ streamAssistantMessage(
1890
+ assistantMessageId,
1891
+ agentResponse.response,
1892
+ agentResponse.followups
1893
+ );
1746
1894
  streamCompleted = true;
1747
1895
  setTimeout(() => {
1748
- window.dispatchEvent(new CustomEvent("agentActionComplete", {
1749
- detail: { result: agentResponse.executionResult }
1750
- }));
1896
+ window.dispatchEvent(
1897
+ new CustomEvent("agentActionComplete", {
1898
+ detail: { result: agentResponse.executionResult }
1899
+ })
1900
+ );
1751
1901
  }, 100);
1752
1902
  } else {
1753
1903
  const assistantMessageId = now + 1;
@@ -1758,7 +1908,11 @@ function ChatPanel({
1758
1908
  content: ""
1759
1909
  };
1760
1910
  setMessages((prev) => [...prev, assistantMessage]);
1761
- streamAssistantMessage(assistantMessageId, agentResponse.response, agentResponse.followups);
1911
+ streamAssistantMessage(
1912
+ assistantMessageId,
1913
+ agentResponse.response,
1914
+ agentResponse.followups
1915
+ );
1762
1916
  streamCompleted = true;
1763
1917
  }
1764
1918
  } else if (eventType === "error") {
@@ -1773,7 +1927,10 @@ function ChatPanel({
1773
1927
  content: ""
1774
1928
  };
1775
1929
  setMessages((prev) => [...prev, errorMessage]);
1776
- streamAssistantMessage(errorMessageId, data.message || "An error occurred processing your request.");
1930
+ streamAssistantMessage(
1931
+ errorMessageId,
1932
+ data.message || "An error occurred processing your request."
1933
+ );
1777
1934
  } else if (eventType === "done") {
1778
1935
  setProgressSteps([]);
1779
1936
  setPhase("idle");
@@ -1799,7 +1956,18 @@ function ChatPanel({
1799
1956
  content: ""
1800
1957
  };
1801
1958
  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.");
1959
+ let errorText = "I'm having trouble connecting to my backend.";
1960
+ if (error instanceof Error) {
1961
+ if (error.name === "AbortError") {
1962
+ errorText = "The request timed out. The server might be busy - please try again.";
1963
+ } else if (error.message.includes("Failed to fetch") || error.message.includes("NetworkError")) {
1964
+ errorText = "I'm having trouble connecting to my backend. Please make sure the agent server is running on port 5002.";
1965
+ } else if (error.message.includes("Agent request failed:")) {
1966
+ errorText = "The server encountered an error. Please try again.";
1967
+ }
1968
+ }
1969
+ errorText += " For simple navigation requests, I can still help you locally.";
1970
+ streamAssistantMessage(errorMessageId, errorText);
1803
1971
  } finally {
1804
1972
  setProgressSteps([]);
1805
1973
  }
@@ -1883,33 +2051,41 @@ ${userText}`
1883
2051
  setMessages((prev) => [...prev, previewMessage]);
1884
2052
  } else if (eventType === "progress") {
1885
2053
  setPhase("executing");
1886
- setProgressSteps([{
1887
- message: `Processing row ${data.row} of ${data.total}...`,
1888
- completed: false
1889
- }]);
2054
+ setProgressSteps([
2055
+ {
2056
+ message: `Processing row ${data.row} of ${data.total}...`,
2057
+ completed: false
2058
+ }
2059
+ ]);
1890
2060
  setMessages((prev) => {
1891
2061
  const lastMsg = prev[prev.length - 1];
1892
2062
  if (lastMsg?.kind === "bulkProgress") {
1893
2063
  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
2064
+ (m, i) => i === prev.length - 1 ? {
2065
+ ...m,
2066
+ bulkProgress: {
2067
+ processed: data.row,
2068
+ total: data.total,
2069
+ successes: data.successes || 0,
2070
+ failures: data.failures || 0
2071
+ }
2072
+ } : m
1900
2073
  );
1901
2074
  } 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
2075
+ return [
2076
+ ...prev,
2077
+ {
2078
+ id: Date.now(),
2079
+ role: "assistant",
2080
+ kind: "bulkProgress",
2081
+ bulkProgress: {
2082
+ processed: data.row,
2083
+ total: data.total,
2084
+ successes: data.successes || 0,
2085
+ failures: data.failures || 0
2086
+ }
1911
2087
  }
1912
- }];
2088
+ ];
1913
2089
  }
1914
2090
  });
1915
2091
  } else if (eventType === "summary") {
@@ -1918,23 +2094,34 @@ ${userText}`
1918
2094
  setPendingBulkSession(null);
1919
2095
  setMessages((prev) => {
1920
2096
  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
2097
+ return [
2098
+ ...filtered,
2099
+ {
2100
+ id: Date.now(),
2101
+ role: "assistant",
2102
+ kind: "bulkSummary",
2103
+ content: data.message,
2104
+ bulkSummary: {
2105
+ total: data.total,
2106
+ successes: data.successes,
2107
+ failures: data.failures || [],
2108
+ navigationPage: data.navigationPage
2109
+ }
1931
2110
  }
1932
- }];
2111
+ ];
1933
2112
  });
1934
2113
  setTimeout(() => {
1935
- window.dispatchEvent(new CustomEvent("agentActionComplete", {
1936
- detail: { result: { bulk: true, total: data.total, successes: data.successes } }
1937
- }));
2114
+ window.dispatchEvent(
2115
+ new CustomEvent("agentActionComplete", {
2116
+ detail: {
2117
+ result: {
2118
+ bulk: true,
2119
+ total: data.total,
2120
+ successes: data.successes
2121
+ }
2122
+ }
2123
+ })
2124
+ );
1938
2125
  }, 100);
1939
2126
  } else if (eventType === "error") {
1940
2127
  setPhase("idle");
@@ -1962,18 +2149,31 @@ ${userText}`
1962
2149
  console.error("Bulk upload failed:", error);
1963
2150
  setProgressSteps([]);
1964
2151
  setPhase("idle");
2152
+ let errorText = "I'm having trouble processing your CSV file.";
2153
+ if (error instanceof Error) {
2154
+ if (error.name === "AbortError") {
2155
+ errorText = "The bulk upload request timed out. The file might be too large or the server is busy - please try again.";
2156
+ } else if (error.message.includes("Failed to fetch") || error.message.includes("NetworkError")) {
2157
+ errorText = "I'm having trouble connecting to my backend. Please make sure the agent server is running on port 5002.";
2158
+ } else if (error.message.includes("Bulk upload failed:")) {
2159
+ errorText = "The server encountered an error processing your CSV file. Please try again.";
2160
+ }
2161
+ }
2162
+ errorText += " Please try again.";
1965
2163
  const errorMessage = {
1966
2164
  id: now + 1,
1967
2165
  role: "assistant",
1968
2166
  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."
2167
+ content: errorText
1970
2168
  };
1971
2169
  setMessages((prev) => [...prev, errorMessage]);
1972
2170
  }
1973
2171
  }
1974
2172
  async function confirmBulkOperation(bulkSessionId) {
1975
2173
  setPhase("executing");
1976
- setProgressSteps([{ message: "Starting bulk operation...", completed: false }]);
2174
+ setProgressSteps([
2175
+ { message: "Starting bulk operation...", completed: false }
2176
+ ]);
1977
2177
  try {
1978
2178
  const response = await fetch(`${agentUrl}/chat/bulk/confirm`, {
1979
2179
  method: "POST",
@@ -2009,43 +2209,56 @@ ${userText}`
2009
2209
  try {
2010
2210
  const data = JSON.parse(eventData);
2011
2211
  if (eventType === "progress") {
2012
- setProgressSteps([{
2013
- message: `Processing row ${data.row} of ${data.total}...`,
2014
- completed: false
2015
- }]);
2212
+ setProgressSteps([
2213
+ {
2214
+ message: `Processing row ${data.row} of ${data.total}...`,
2215
+ completed: false
2216
+ }
2217
+ ]);
2016
2218
  setMessages((prev) => {
2017
2219
  const lastMsg = prev[prev.length - 1];
2018
2220
  if (lastMsg?.kind === "bulkProgress") {
2019
2221
  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
2222
+ (m, i) => i === prev.length - 1 ? {
2223
+ ...m,
2224
+ bulkProgress: {
2225
+ processed: data.row,
2226
+ total: data.total,
2227
+ successes: data.successes || 0,
2228
+ failures: data.failures || 0
2229
+ }
2230
+ } : m
2026
2231
  );
2027
2232
  } 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
2233
+ return [
2234
+ ...prev,
2235
+ {
2236
+ id: Date.now(),
2237
+ role: "assistant",
2238
+ kind: "bulkProgress",
2239
+ bulkProgress: {
2240
+ processed: data.row,
2241
+ total: data.total,
2242
+ successes: data.successes || 0,
2243
+ failures: data.failures || 0
2244
+ }
2037
2245
  }
2038
- }];
2246
+ ];
2039
2247
  }
2040
2248
  });
2041
2249
  } else if (eventType === "summary") {
2042
2250
  console.log("[DEBUG] Received summary event - data:", data);
2043
- console.log("[DEBUG] navigationPage from backend:", data.navigationPage);
2251
+ console.log(
2252
+ "[DEBUG] navigationPage from backend:",
2253
+ data.navigationPage
2254
+ );
2044
2255
  setPhase("idle");
2045
2256
  setProgressSteps([]);
2046
2257
  setPendingBulkSession(null);
2047
2258
  setMessages((prev) => {
2048
- const filtered = prev.filter((m) => m.kind !== "bulkProgress" && m.kind !== "bulkPreview");
2259
+ const filtered = prev.filter(
2260
+ (m) => m.kind !== "bulkProgress" && m.kind !== "bulkPreview"
2261
+ );
2049
2262
  const newMsg = {
2050
2263
  id: Date.now(),
2051
2264
  role: "assistant",
@@ -2062,9 +2275,17 @@ ${userText}`
2062
2275
  return [...filtered, newMsg];
2063
2276
  });
2064
2277
  setTimeout(() => {
2065
- window.dispatchEvent(new CustomEvent("agentActionComplete", {
2066
- detail: { result: { bulk: true, total: data.total, successes: data.successes } }
2067
- }));
2278
+ window.dispatchEvent(
2279
+ new CustomEvent("agentActionComplete", {
2280
+ detail: {
2281
+ result: {
2282
+ bulk: true,
2283
+ total: data.total,
2284
+ successes: data.successes
2285
+ }
2286
+ }
2287
+ })
2288
+ );
2068
2289
  }, 100);
2069
2290
  } else if (eventType === "error") {
2070
2291
  setPhase("idle");
@@ -2106,7 +2327,10 @@ ${userText}`
2106
2327
  }
2107
2328
  function appendAssistantText(text) {
2108
2329
  const id = Date.now() + Math.floor(Math.random() * 1e3);
2109
- setMessages((prev) => [...prev, { id, role: "assistant", kind: "text", content: text }]);
2330
+ setMessages((prev) => [
2331
+ ...prev,
2332
+ { id, role: "assistant", kind: "text", content: text }
2333
+ ]);
2110
2334
  }
2111
2335
  function startGuide(guideId) {
2112
2336
  const guide = guides[guideId];
@@ -2119,7 +2343,9 @@ ${userText}`
2119
2343
  appendAssistantText(`I'll help you with ${guide.title}.`);
2120
2344
  const firstStep = guide.steps[0];
2121
2345
  const isNavigationButton = firstStep.cursorTarget?.selector.includes("[data-page=");
2122
- const isTabButton = firstStep.cursorTarget?.selector.includes("[data-settings-tab=");
2346
+ const isTabButton = firstStep.cursorTarget?.selector.includes(
2347
+ "[data-settings-tab="
2348
+ );
2123
2349
  if (firstStep.cursorTarget && (isNavigationButton || isTabButton)) {
2124
2350
  const cursorTarget = firstStep.cursorTarget;
2125
2351
  if (isTabButton && firstStep.navigation && onNavigate) {
@@ -2128,7 +2354,9 @@ ${userText}`
2128
2354
  const initialDelay = isTabButton ? 800 : 400;
2129
2355
  setTimeout(() => {
2130
2356
  const waitForElement = () => {
2131
- const element = document.querySelector(cursorTarget.selector);
2357
+ const element = document.querySelector(
2358
+ cursorTarget.selector
2359
+ );
2132
2360
  if (element && element.offsetParent !== null) {
2133
2361
  moveTo(cursorTarget);
2134
2362
  if (cursorTarget.onClick) {
@@ -2153,7 +2381,9 @@ ${userText}`
2153
2381
  const initialDelay = isDialogElement ? 700 : isSettingsTab ? 600 : 400;
2154
2382
  setTimeout(() => {
2155
2383
  const waitForElement = () => {
2156
- const element = document.querySelector(cursorTarget.selector);
2384
+ const element = document.querySelector(
2385
+ cursorTarget.selector
2386
+ );
2157
2387
  if (element && element.offsetParent !== null) {
2158
2388
  moveTo(cursorTarget);
2159
2389
  if (cursorTarget.onClick) {
@@ -2167,7 +2397,9 @@ ${userText}`
2167
2397
  moveTo(cursorTarget);
2168
2398
  if (cursorTarget.onClick) {
2169
2399
  setTimeout(() => {
2170
- const el = document.querySelector(cursorTarget.selector);
2400
+ const el = document.querySelector(
2401
+ cursorTarget.selector
2402
+ );
2171
2403
  if (el) el.click();
2172
2404
  }, 1e3);
2173
2405
  }
@@ -2204,7 +2436,12 @@ ${userText}`
2204
2436
  const id = Date.now() + 1;
2205
2437
  setMessages((prev) => [
2206
2438
  ...prev,
2207
- { id, role: "assistant", kind: "guideComplete", content: "Guide Complete" }
2439
+ {
2440
+ id,
2441
+ role: "assistant",
2442
+ kind: "guideComplete",
2443
+ content: "Guide Complete"
2444
+ }
2208
2445
  ]);
2209
2446
  setActiveGuide(void 0);
2210
2447
  setGuideComplete(true);
@@ -2223,7 +2460,9 @@ ${userText}`
2223
2460
  };
2224
2461
  setMessages((prev) => [...prev, draft]);
2225
2462
  const isNavigationButton = nextStep.cursorTarget?.selector.includes("[data-page=");
2226
- const isTabButton = nextStep.cursorTarget?.selector.includes("[data-settings-tab=");
2463
+ const isTabButton = nextStep.cursorTarget?.selector.includes(
2464
+ "[data-settings-tab="
2465
+ );
2227
2466
  if (nextStep.cursorTarget && (isNavigationButton || isTabButton)) {
2228
2467
  const cursorTarget = nextStep.cursorTarget;
2229
2468
  if (isTabButton && nextStep.navigation && onNavigate) {
@@ -2240,7 +2479,9 @@ ${userText}`
2240
2479
  if (!currentGuide3 || currentGuide3.id !== guide.id || currentGuide3.stepIndex !== nextIndex) {
2241
2480
  return;
2242
2481
  }
2243
- const element = document.querySelector(cursorTarget.selector);
2482
+ const element = document.querySelector(
2483
+ cursorTarget.selector
2484
+ );
2244
2485
  if (element && element.offsetParent !== null) {
2245
2486
  moveTo(cursorTarget);
2246
2487
  if (cursorTarget.onClick) {
@@ -2266,7 +2507,9 @@ ${userText}`
2266
2507
  const cursorTarget = nextStep.cursorTarget;
2267
2508
  const isDialogElement = cursorTarget.selector.includes("dialog") || cursorTarget.selector.includes("api-key-name-input");
2268
2509
  const isSettingsTab = cursorTarget.selector.includes("data-settings-tab");
2269
- const navigationSetTab = nextStep.navigation?.subtab && isSettingsTab && cursorTarget.selector.includes(`data-settings-tab="${nextStep.navigation.subtab}"`);
2510
+ const navigationSetTab = nextStep.navigation?.subtab && isSettingsTab && cursorTarget.selector.includes(
2511
+ `data-settings-tab="${nextStep.navigation.subtab}"`
2512
+ );
2270
2513
  const shouldAutoClick = cursorTarget.onClick && !navigationSetTab;
2271
2514
  const hasNavigation = !!nextStep.navigation;
2272
2515
  const hasSubtab = !!nextStep.navigation?.subtab;
@@ -2282,7 +2525,9 @@ ${userText}`
2282
2525
  if (!currentGuide3 || currentGuide3.id !== guide.id || currentGuide3.stepIndex !== nextIndex) {
2283
2526
  return;
2284
2527
  }
2285
- const element = document.querySelector(cursorTarget.selector);
2528
+ const element = document.querySelector(
2529
+ cursorTarget.selector
2530
+ );
2286
2531
  if (element && element.offsetParent !== null) {
2287
2532
  moveTo(cursorTarget);
2288
2533
  if (shouldAutoClick) {
@@ -2304,7 +2549,9 @@ ${userText}`
2304
2549
  if (!currentGuide4 || currentGuide4.id !== guide.id || currentGuide4.stepIndex !== nextIndex) {
2305
2550
  return;
2306
2551
  }
2307
- const el = document.querySelector(cursorTarget.selector);
2552
+ const el = document.querySelector(
2553
+ cursorTarget.selector
2554
+ );
2308
2555
  if (el) el.click();
2309
2556
  }, 1e3);
2310
2557
  }
@@ -2336,10 +2583,17 @@ ${userText}`
2336
2583
  } else {
2337
2584
  hide();
2338
2585
  }
2339
- const existingMessages = messages.filter((m) => m.kind !== "guideStep" && m.kind !== "guideComplete");
2586
+ const existingMessages = messages.filter(
2587
+ (m) => m.kind !== "guideStep" && m.kind !== "guideComplete"
2588
+ );
2340
2589
  setMessages([
2341
2590
  ...existingMessages,
2342
- { id: Date.now(), role: "assistant", kind: "guideStep", content: prevStep.text }
2591
+ {
2592
+ id: Date.now(),
2593
+ role: "assistant",
2594
+ kind: "guideStep",
2595
+ content: prevStep.text
2596
+ }
2343
2597
  ]);
2344
2598
  }
2345
2599
  }
@@ -2362,6 +2616,7 @@ ${userText}`
2362
2616
  size: "sm",
2363
2617
  className: "h-7 w-7 p-0 text-gray-400 hover:text-gray-600 hover:bg-gray-100 rounded-full",
2364
2618
  onClick: () => {
2619
+ resetSession();
2365
2620
  setMessages([]);
2366
2621
  setPanelView("landing");
2367
2622
  setCurrentFolderId(void 0);
@@ -2384,919 +2639,1148 @@ ${userText}`
2384
2639
  )
2385
2640
  ] })
2386
2641
  ] }),
2387
- /* @__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: [
2388
- /* @__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?" }) }),
2389
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "pb-4 px-4", children: [
2390
- 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) => {
2391
- const iconColors = ["bg-blue-400", "bg-green-400", "bg-purple-400", "bg-orange-400", "bg-pink-400"];
2392
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
2393
- Button,
2394
- {
2395
- type: "button",
2396
- size: "sm",
2397
- variant: "ghost",
2398
- className: "w-full justify-start rounded-lg px-3 py-1.5 text-xs text-gray-700 hover:bg-gray-100 h-auto",
2399
- onClick: () => sendTopic(question.prompt),
2400
- children: [
2401
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: `mr-2 inline-block h-1.5 w-1.5 rounded-full ${iconColors[index % iconColors.length]}` }),
2402
- question.label
2403
- ]
2404
- },
2405
- question.id
2406
- );
2407
- }) }) }),
2408
- panelView === "folder" && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
2409
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "mb-3 flex items-center gap-2", children: [
2410
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2411
- Button,
2412
- {
2413
- type: "button",
2414
- size: "icon",
2415
- variant: "ghost",
2416
- className: "h-7 w-7 rounded-full hover:bg-gray-100",
2417
- onClick: closeFolder,
2418
- "aria-label": "Back to suggestions",
2419
- children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.ArrowLeft, { className: "h-4 w-4 text-gray-500" })
2420
- }
2421
- ),
2422
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "text-xs font-medium uppercase tracking-wide text-gray-400", children: "Topics" })
2423
- ] }),
2424
- /* @__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)(
2425
- Button,
2426
- {
2427
- type: "button",
2428
- size: "sm",
2429
- variant: "secondary",
2430
- 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",
2431
- onClick: () => sendTopic(topic.prompt),
2432
- children: topic.label
2433
- },
2434
- topic.id
2435
- )) })
2436
- ] })
2437
- ] })
2438
- ] }) : /* @__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: [
2439
- messages.map((message, index) => {
2440
- const isUser = message.role === "user";
2441
- const previousRole = index > 0 ? messages[index - 1].role : void 0;
2442
- const isRoleChange = previousRole !== void 0 && previousRole !== message.role;
2443
- const currentGuide = activeGuideRef.current || activeGuide;
2444
- let isCurrentGuideStep = false;
2445
- if (currentGuide && message.kind === "guideStep") {
2446
- if (message.guideStepIndex !== void 0) {
2447
- isCurrentGuideStep = message.guideStepIndex === currentGuide.stepIndex;
2448
- } else {
2449
- isCurrentGuideStep = index === messages.length - 1;
2450
- }
2451
- } else if (message.kind === "guideComplete") {
2452
- isCurrentGuideStep = index === messages.length - 1;
2453
- }
2454
- if (message.kind === "guideStep" && !isCurrentGuideStep) {
2455
- return null;
2456
- }
2457
- if (isUser) {
2458
- 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);
2459
- }
2460
- if (message.kind === "searchSummary") {
2461
- 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);
2462
- }
2463
- if (message.kind === "guideComplete") {
2464
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2465
- "div",
2466
- {
2467
- ref: isCurrentGuideStep ? currentStepRef : null,
2468
- className: `${isRoleChange ? "mt-3" : ""}`,
2469
- 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: [
2470
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.CheckCircle2, { className: "h-5 w-5 text-green-600 flex-shrink-0" }),
2471
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "font-medium text-green-800", children: message.content })
2472
- ] })
2473
- },
2474
- message.id
2475
- );
2476
- }
2477
- if (message.kind === "navigationAction") {
2478
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: `${isRoleChange ? "mt-3" : ""}`, children: [
2479
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "whitespace-pre-wrap text-sm leading-6 mb-2 text-gray-700", children: message.content || "" }),
2480
- message.navigationTarget && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "mt-2", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
2481
- Button,
2482
- {
2483
- type: "button",
2484
- size: "sm",
2485
- variant: "secondary",
2486
- className: "h-8 rounded-xl px-3 text-xs gap-1.5 bg-gray-100 hover:bg-gray-200 border border-gray-200",
2487
- onClick: () => message.navigationTarget && handleConfirmNavigation(message.navigationTarget),
2488
- children: [
2489
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { children: "Confirm" }),
2490
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "flex items-center gap-0.5 text-gray-400", children: [
2491
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.Command, { className: "h-3 w-3" }),
2492
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.CornerDownLeft, { className: "h-3 w-3" })
2493
- ] })
2494
- ]
2495
- }
2496
- ) })
2497
- ] }, message.id);
2498
- }
2499
- if (message.kind === "actionForm") {
2500
- const actionType = message.actionType;
2501
- const formData = Object.keys(actionFormData).length > 0 ? actionFormData : message.actionData || {};
2502
- if (message.isSubmitted) {
2503
- let successContent = "";
2504
- if (actionType === "updateCompanyInfo") {
2505
- successContent = "Company information has been updated successfully.";
2506
- } else if (actionType === "addApiKey") {
2507
- successContent = "API key has been added successfully.";
2508
- } else if (actionType === "addCustomer") {
2509
- successContent = "Customer has been added successfully.";
2510
- } else if (actionType === "enable2FA") {
2511
- successContent = "Two-factor authentication has been enabled successfully.";
2512
- } else if (actionType === "disable2FA") {
2513
- successContent = "Two-factor authentication has been disabled successfully.";
2514
- } else if (actionType === "changePassword") {
2515
- successContent = "Your password has been changed successfully.";
2516
- } else if (actionType === "revokeSession") {
2517
- successContent = "Session has been revoked successfully.";
2518
- } else if (actionType === "toggleNotification") {
2519
- successContent = "Notification preferences have been updated successfully.";
2520
- } else if (actionType === "connectIntegration") {
2521
- successContent = "Integration has been connected successfully.";
2522
- } else if (actionType === "disconnectIntegration") {
2523
- successContent = "Integration has been disconnected successfully.";
2524
- } else if (actionType === "addPaymentMethod") {
2525
- successContent = "Payment method has been added successfully.";
2526
- } else if (actionType === "removePaymentMethod") {
2527
- successContent = "Payment method has been removed successfully.";
2528
- } else if (actionType === "deleteApiKey") {
2529
- successContent = "API key has been deleted successfully.";
2530
- } else if (actionType === "addWebhook") {
2531
- successContent = "Webhook endpoint has been added successfully.";
2532
- } else if (actionType === "updateCurrency") {
2533
- successContent = "Currency preference has been updated successfully.";
2534
- } else if (actionType === "updateTimezone") {
2535
- successContent = "Timezone has been updated successfully.";
2536
- } else if (actionType === "refundPayment") {
2537
- successContent = "Refund has been processed successfully.";
2538
- } else if (actionType === "exportCertificate") {
2539
- successContent = "Certificate of Incorporation has been downloaded successfully.";
2540
- } else if (actionType === "createSubscription") {
2541
- successContent = "Subscription has been created successfully.";
2542
- } else if (actionType === "toggleBlockRule" || actionType === "enableBlockRule" || actionType === "disableBlockRule") {
2543
- successContent = "Block rule has been updated successfully.";
2544
- } else {
2545
- successContent = "Action completed successfully.";
2546
- }
2547
- 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);
2548
- }
2549
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: `min-w-0 ${isRoleChange ? "mt-3" : ""}`, children: [
2550
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "whitespace-pre-wrap text-sm leading-6 mb-3 text-gray-700", children: message.content || "" }),
2551
- 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: [
2552
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "grid grid-cols-2 gap-2", children: [
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: "Company Name" }),
2555
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2556
- Input,
2557
- {
2558
- placeholder: "Acme Corporation",
2559
- value: formData.companyName || "",
2560
- onChange: (e) => setActionFormData({ ...actionFormData, companyName: e.target.value }),
2561
- className: "h-8 text-xs border-gray-200"
2562
- }
2563
- )
2564
- ] }),
2565
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2566
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Email" }),
2567
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2568
- Input,
2569
- {
2570
- type: "email",
2571
- placeholder: "contact@acme.com",
2572
- value: formData.email || "",
2573
- onChange: (e) => setActionFormData({ ...actionFormData, email: e.target.value }),
2574
- className: "h-8 text-xs border-gray-200"
2575
- }
2576
- )
2577
- ] })
2578
- ] }),
2579
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2580
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Address" }),
2642
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2643
+ "div",
2644
+ {
2645
+ 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",
2646
+ children: isEmpty ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "w-full overflow-y-auto px-4", children: [
2647
+ /* @__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?" }) }),
2648
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "pb-4 px-4", children: [
2649
+ 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) => {
2650
+ const iconColors = [
2651
+ "bg-blue-400",
2652
+ "bg-green-400",
2653
+ "bg-purple-400",
2654
+ "bg-orange-400",
2655
+ "bg-pink-400"
2656
+ ];
2657
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
2658
+ Button,
2659
+ {
2660
+ type: "button",
2661
+ size: "sm",
2662
+ variant: "ghost",
2663
+ className: "w-full justify-start rounded-lg px-3 py-1.5 text-xs text-gray-700 hover:bg-gray-100 h-auto",
2664
+ onClick: () => sendTopic(question.prompt),
2665
+ children: [
2666
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2667
+ "span",
2668
+ {
2669
+ className: `mr-2 inline-block h-1.5 w-1.5 rounded-full ${iconColors[index % iconColors.length]}`
2670
+ }
2671
+ ),
2672
+ question.label
2673
+ ]
2674
+ },
2675
+ question.id
2676
+ );
2677
+ }) }) }),
2678
+ panelView === "folder" && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
2679
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "mb-3 flex items-center gap-2", children: [
2581
2680
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2582
- Input,
2681
+ Button,
2583
2682
  {
2584
- placeholder: "123 Main St, San Francisco, CA",
2585
- value: formData.address || "",
2586
- onChange: (e) => setActionFormData({ ...actionFormData, address: e.target.value }),
2587
- className: "h-8 text-xs border-gray-200"
2683
+ type: "button",
2684
+ size: "icon",
2685
+ variant: "ghost",
2686
+ className: "h-7 w-7 rounded-full hover:bg-gray-100",
2687
+ onClick: closeFolder,
2688
+ "aria-label": "Back to suggestions",
2689
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.ArrowLeft, { className: "h-4 w-4 text-gray-500" })
2588
2690
  }
2589
- )
2691
+ ),
2692
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "text-xs font-medium uppercase tracking-wide text-gray-400", children: "Topics" })
2590
2693
  ] }),
2591
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "grid grid-cols-2 gap-2", children: [
2592
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2593
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Phone" }),
2594
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2595
- Input,
2596
- {
2597
- type: "tel",
2598
- placeholder: "+1 (555) 123-4567",
2599
- value: formData.phone || "",
2600
- onChange: (e) => setActionFormData({ ...actionFormData, phone: e.target.value }),
2601
- className: "h-8 text-xs border-gray-200"
2602
- }
2603
- )
2604
- ] }),
2605
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2606
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Website" }),
2607
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2608
- Input,
2609
- {
2610
- type: "url",
2611
- placeholder: "https://acme.com",
2612
- value: formData.website || "",
2613
- onChange: (e) => setActionFormData({ ...actionFormData, website: e.target.value }),
2614
- className: "h-8 text-xs border-gray-200"
2615
- }
2616
- )
2617
- ] })
2618
- ] })
2619
- ] }),
2620
- 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: [
2621
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "API Key Name" }),
2622
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2623
- Input,
2694
+ /* @__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)(
2695
+ Button,
2624
2696
  {
2625
- placeholder: "Production Key",
2626
- value: formData.name || "",
2627
- onChange: (e) => setActionFormData({ ...actionFormData, name: e.target.value }),
2628
- className: "h-8 text-xs border-gray-200"
2629
- }
2630
- )
2631
- ] }) }),
2632
- 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: [
2633
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "grid grid-cols-2 gap-2", children: [
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: "Company Name" }),
2636
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2637
- Input,
2638
- {
2639
- placeholder: "Acme Corporation",
2640
- value: formData.name || "",
2641
- onChange: (e) => setActionFormData({ ...actionFormData, name: e.target.value }),
2642
- className: "h-8 text-xs border-gray-200"
2643
- }
2644
- )
2645
- ] }),
2646
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2647
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Email" }),
2648
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2649
- Input,
2697
+ type: "button",
2698
+ size: "sm",
2699
+ variant: "secondary",
2700
+ 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",
2701
+ onClick: () => sendTopic(topic.prompt),
2702
+ children: topic.label
2703
+ },
2704
+ topic.id
2705
+ )) })
2706
+ ] })
2707
+ ] })
2708
+ ] }) : /* @__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: [
2709
+ messages.map((message, index) => {
2710
+ const isUser = message.role === "user";
2711
+ const previousRole = index > 0 ? messages[index - 1].role : void 0;
2712
+ const isRoleChange = previousRole !== void 0 && previousRole !== message.role;
2713
+ const currentGuide = activeGuideRef.current || activeGuide;
2714
+ let isCurrentGuideStep = false;
2715
+ if (currentGuide && message.kind === "guideStep") {
2716
+ if (message.guideStepIndex !== void 0) {
2717
+ isCurrentGuideStep = message.guideStepIndex === currentGuide.stepIndex;
2718
+ } else {
2719
+ isCurrentGuideStep = index === messages.length - 1;
2720
+ }
2721
+ } else if (message.kind === "guideComplete") {
2722
+ isCurrentGuideStep = index === messages.length - 1;
2723
+ }
2724
+ if (message.kind === "guideStep" && !isCurrentGuideStep) {
2725
+ return null;
2726
+ }
2727
+ if (isUser) {
2728
+ 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);
2729
+ }
2730
+ if (message.kind === "searchSummary") {
2731
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2732
+ "div",
2733
+ {
2734
+ className: `${isRoleChange ? "mt-3" : ""}`,
2735
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2736
+ AssistantSearchSummary,
2650
2737
  {
2651
- type: "email",
2652
- placeholder: "contact@acme.com",
2653
- value: formData.email || "",
2654
- onChange: (e) => setActionFormData({ ...actionFormData, email: e.target.value }),
2655
- className: "h-8 text-xs border-gray-200"
2738
+ title: message.title ?? "Search results",
2739
+ links: message.links ?? []
2656
2740
  }
2657
2741
  )
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: "Location" }),
2662
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2663
- Input,
2664
- {
2665
- placeholder: "San Francisco, CA",
2666
- value: formData.location || "",
2667
- onChange: (e) => setActionFormData({ ...actionFormData, location: e.target.value }),
2668
- className: "h-8 text-xs border-gray-200"
2669
- }
2670
- )
2671
- ] }),
2672
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2673
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Subscription Tier" }),
2674
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
2675
- "select",
2676
- {
2677
- value: formData.subscription || "Starter",
2678
- onChange: (e) => setActionFormData({ ...actionFormData, subscription: e.target.value }),
2679
- 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",
2680
- children: [
2681
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "Starter", children: "Starter" }),
2682
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "Professional", children: "Professional" }),
2683
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "Enterprise", children: "Enterprise" })
2684
- ]
2685
- }
2686
- )
2687
- ] })
2688
- ] }),
2689
- (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." }) }),
2690
- 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: [
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: "Current Password" }),
2693
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2694
- Input,
2695
- {
2696
- type: "password",
2697
- value: formData.currentPassword || "",
2698
- onChange: (e) => setActionFormData({ ...actionFormData, currentPassword: 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: "New Password" }),
2705
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2706
- Input,
2707
- {
2708
- type: "password",
2709
- value: formData.newPassword || "",
2710
- onChange: (e) => setActionFormData({ ...actionFormData, newPassword: e.target.value }),
2711
- className: "h-8 text-xs border-gray-200"
2712
- }
2713
- )
2714
- ] }),
2715
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2716
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Confirm New Password" }),
2717
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2718
- Input,
2719
- {
2720
- type: "password",
2721
- value: formData.confirmPassword || "",
2722
- onChange: (e) => setActionFormData({ ...actionFormData, confirmPassword: e.target.value }),
2723
- className: "h-8 text-xs border-gray-200"
2724
- }
2725
- )
2726
- ] })
2727
- ] }),
2728
- 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: [
2729
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2730
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Notification Type" }),
2731
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
2732
- "select",
2733
- {
2734
- value: formData.notificationType || "paymentReceived",
2735
- onChange: (e) => setActionFormData({ ...actionFormData, notificationType: e.target.value }),
2736
- 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",
2737
- children: [
2738
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "paymentReceived", children: "Payment Received" }),
2739
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "paymentFailed", children: "Payment Failed" }),
2740
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "invoicePaid", children: "Invoice Paid" }),
2741
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "monthlySummary", children: "Monthly Summary" }),
2742
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "productUpdates", children: "Product Updates" })
2743
- ]
2744
- }
2745
- )
2746
- ] }),
2747
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex items-center gap-2", children: [
2748
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2749
- "input",
2750
- {
2751
- type: "checkbox",
2752
- checked: formData.enabled !== false,
2753
- onChange: (e) => setActionFormData({ ...actionFormData, enabled: e.target.checked }),
2754
- className: "h-4 w-4 rounded border-gray-300 text-primary focus:ring-primary"
2755
- }
2756
- ),
2757
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs text-black", children: "Enable this notification" })
2758
- ] })
2759
- ] }),
2760
- (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: [
2761
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Integration" }),
2762
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
2763
- "select",
2742
+ },
2743
+ message.id
2744
+ );
2745
+ }
2746
+ if (message.kind === "guideComplete") {
2747
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2748
+ "div",
2764
2749
  {
2765
- value: formData.integrationName || "Slack",
2766
- onChange: (e) => setActionFormData({ ...actionFormData, integrationName: e.target.value }),
2767
- 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",
2750
+ ref: isCurrentGuideStep ? currentStepRef : null,
2751
+ className: `${isRoleChange ? "mt-3" : ""}`,
2752
+ 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: [
2753
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.CheckCircle2, { className: "h-5 w-5 text-green-600 flex-shrink-0" }),
2754
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "font-medium text-green-800", children: message.content })
2755
+ ] })
2756
+ },
2757
+ message.id
2758
+ );
2759
+ }
2760
+ if (message.kind === "navigationAction") {
2761
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
2762
+ "div",
2763
+ {
2764
+ className: `${isRoleChange ? "mt-3" : ""}`,
2768
2765
  children: [
2769
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "Slack", children: "Slack" }),
2770
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "Zapier", children: "Zapier" }),
2771
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "Webhook", children: "Webhook" })
2766
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "whitespace-pre-wrap text-sm leading-6 mb-2 text-gray-700", children: message.content || "" }),
2767
+ message.navigationTarget && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "mt-2", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
2768
+ Button,
2769
+ {
2770
+ type: "button",
2771
+ size: "sm",
2772
+ variant: "secondary",
2773
+ className: "h-8 rounded-xl px-3 text-xs gap-1.5 bg-gray-100 hover:bg-gray-200 border border-gray-200",
2774
+ onClick: () => message.navigationTarget && handleConfirmNavigation(
2775
+ message.navigationTarget
2776
+ ),
2777
+ children: [
2778
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { children: "Confirm" }),
2779
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "flex items-center gap-0.5 text-gray-400", children: [
2780
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.Command, { className: "h-3 w-3" }),
2781
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.CornerDownLeft, { className: "h-3 w-3" })
2782
+ ] })
2783
+ ]
2784
+ }
2785
+ ) })
2772
2786
  ]
2787
+ },
2788
+ message.id
2789
+ );
2790
+ }
2791
+ if (message.kind === "actionForm") {
2792
+ const actionType = message.actionType;
2793
+ const formData = Object.keys(actionFormData).length > 0 ? actionFormData : message.actionData || {};
2794
+ if (message.isSubmitted) {
2795
+ let successContent = "";
2796
+ if (actionType === "updateCompanyInfo") {
2797
+ successContent = "Company information has been updated successfully.";
2798
+ } else if (actionType === "addApiKey") {
2799
+ successContent = "API key has been added successfully.";
2800
+ } else if (actionType === "addCustomer") {
2801
+ successContent = "Customer has been added successfully.";
2802
+ } else if (actionType === "enable2FA") {
2803
+ successContent = "Two-factor authentication has been enabled successfully.";
2804
+ } else if (actionType === "disable2FA") {
2805
+ successContent = "Two-factor authentication has been disabled successfully.";
2806
+ } else if (actionType === "changePassword") {
2807
+ successContent = "Your password has been changed successfully.";
2808
+ } else if (actionType === "revokeSession") {
2809
+ successContent = "Session has been revoked successfully.";
2810
+ } else if (actionType === "toggleNotification") {
2811
+ successContent = "Notification preferences have been updated successfully.";
2812
+ } else if (actionType === "connectIntegration") {
2813
+ successContent = "Integration has been connected successfully.";
2814
+ } else if (actionType === "disconnectIntegration") {
2815
+ successContent = "Integration has been disconnected successfully.";
2816
+ } else if (actionType === "addPaymentMethod") {
2817
+ successContent = "Payment method has been added successfully.";
2818
+ } else if (actionType === "removePaymentMethod") {
2819
+ successContent = "Payment method has been removed successfully.";
2820
+ } else if (actionType === "deleteApiKey") {
2821
+ successContent = "API key has been deleted successfully.";
2822
+ } else if (actionType === "addWebhook") {
2823
+ successContent = "Webhook endpoint has been added successfully.";
2824
+ } else if (actionType === "updateCurrency") {
2825
+ successContent = "Currency preference has been updated successfully.";
2826
+ } else if (actionType === "updateTimezone") {
2827
+ successContent = "Timezone has been updated successfully.";
2828
+ } else if (actionType === "refundPayment") {
2829
+ successContent = "Refund has been processed successfully.";
2830
+ } else if (actionType === "exportCertificate") {
2831
+ successContent = "Certificate of Incorporation has been downloaded successfully.";
2832
+ } else if (actionType === "createSubscription") {
2833
+ successContent = "Subscription has been created successfully.";
2834
+ } else if (actionType === "toggleBlockRule" || actionType === "enableBlockRule" || actionType === "disableBlockRule") {
2835
+ successContent = "Block rule has been updated successfully.";
2836
+ } else {
2837
+ successContent = "Action completed successfully.";
2773
2838
  }
2774
- )
2775
- ] }) }),
2776
- 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: [
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: "Card Number" }),
2779
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2780
- Input,
2781
- {
2782
- placeholder: "1234 5678 9012 3456",
2783
- value: formData.cardNumber || "",
2784
- onChange: (e) => setActionFormData({ ...actionFormData, cardNumber: e.target.value }),
2785
- className: "h-8 text-xs border-gray-200"
2786
- }
2787
- )
2788
- ] }),
2789
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2790
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Expiry Date" }),
2791
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2792
- Input,
2793
- {
2794
- placeholder: "MM/YY",
2795
- value: formData.expiryDate || "",
2796
- onChange: (e) => setActionFormData({ ...actionFormData, expiryDate: e.target.value }),
2797
- className: "h-8 text-xs border-gray-200"
2798
- }
2799
- )
2800
- ] })
2801
- ] }),
2802
- 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." }) }),
2803
- 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: [
2804
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2805
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Transaction ID or Customer Name" }),
2806
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2807
- Input,
2839
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2840
+ "div",
2808
2841
  {
2809
- placeholder: "e.g., txn_1234 or Acme Corp",
2810
- value: formData.transactionId || formData.customer || "",
2811
- onChange: (e) => {
2812
- const value = e.target.value;
2813
- if (value.startsWith("txn_") || /^\d+$/.test(value)) {
2814
- setActionFormData({ ...actionFormData, transactionId: value, customer: void 0 });
2815
- } else {
2816
- setActionFormData({ ...actionFormData, customer: value, transactionId: void 0 });
2817
- }
2818
- },
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: "Amount (optional)" }),
2825
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2826
- Input,
2827
- {
2828
- placeholder: "$0.00",
2829
- value: formData.amount || "",
2830
- onChange: (e) => setActionFormData({ ...actionFormData, amount: e.target.value }),
2831
- className: "h-8 text-xs border-gray-200"
2832
- }
2833
- )
2834
- ] }),
2835
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2836
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Reason (optional)" }),
2837
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2838
- Input,
2839
- {
2840
- placeholder: "e.g., Customer request",
2841
- value: formData.reason || "",
2842
- onChange: (e) => setActionFormData({ ...actionFormData, reason: e.target.value }),
2843
- className: "h-8 text-xs border-gray-200"
2844
- }
2845
- )
2846
- ] })
2847
- ] }),
2848
- 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: [
2849
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2850
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "API Key Name or ID" }),
2851
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2852
- Input,
2853
- {
2854
- placeholder: "Production Key",
2855
- value: formData.keyId || formData.name || "",
2856
- onChange: (e) => setActionFormData({ ...actionFormData, keyId: e.target.value, name: e.target.value }),
2857
- className: "h-8 text-xs border-gray-200"
2858
- }
2859
- )
2860
- ] }),
2861
- /* @__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." })
2862
- ] }),
2863
- 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: [
2864
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2865
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Webhook URL" }),
2866
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2867
- Input,
2868
- {
2869
- type: "url",
2870
- placeholder: "https://example.com/webhook",
2871
- value: formData.url || "",
2872
- onChange: (e) => setActionFormData({ ...actionFormData, url: e.target.value }),
2873
- className: "h-8 text-xs border-gray-200"
2874
- }
2875
- )
2876
- ] }),
2877
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2878
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Name (optional)" }),
2879
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2880
- Input,
2881
- {
2882
- placeholder: "Production Webhook",
2883
- value: formData.name || "",
2884
- onChange: (e) => setActionFormData({ ...actionFormData, name: e.target.value }),
2885
- className: "h-8 text-xs border-gray-200"
2886
- }
2887
- )
2888
- ] })
2889
- ] }),
2890
- 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: [
2891
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Currency" }),
2892
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
2893
- "select",
2842
+ className: `${isRoleChange ? "mt-3" : ""}`,
2843
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "whitespace-pre-wrap text-sm leading-6 text-gray-700", children: successContent })
2844
+ },
2845
+ message.id
2846
+ );
2847
+ }
2848
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
2849
+ "div",
2894
2850
  {
2895
- value: formData.currency || "USD",
2896
- onChange: (e) => setActionFormData({ ...actionFormData, currency: e.target.value }),
2897
- 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",
2851
+ className: `min-w-0 ${isRoleChange ? "mt-3" : ""}`,
2898
2852
  children: [
2899
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "USD", children: "USD ($)" }),
2900
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "EUR", children: "EUR (\u20AC)" }),
2901
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "GBP", children: "GBP (\xA3)" }),
2902
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "JPY", children: "JPY (\xA5)" })
2853
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "whitespace-pre-wrap text-sm leading-6 mb-3 text-gray-700", children: message.content || "" }),
2854
+ 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: [
2855
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "grid grid-cols-2 gap-2", children: [
2856
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2857
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Company Name" }),
2858
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2859
+ Input,
2860
+ {
2861
+ placeholder: "Acme Corporation",
2862
+ value: formData.companyName || "",
2863
+ onChange: (e) => setActionFormData({
2864
+ ...actionFormData,
2865
+ companyName: e.target.value
2866
+ }),
2867
+ className: "h-8 text-xs border-gray-200"
2868
+ }
2869
+ )
2870
+ ] }),
2871
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2872
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Email" }),
2873
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2874
+ Input,
2875
+ {
2876
+ type: "email",
2877
+ placeholder: "contact@acme.com",
2878
+ value: formData.email || "",
2879
+ onChange: (e) => setActionFormData({
2880
+ ...actionFormData,
2881
+ email: e.target.value
2882
+ }),
2883
+ className: "h-8 text-xs border-gray-200"
2884
+ }
2885
+ )
2886
+ ] })
2887
+ ] }),
2888
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2889
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Address" }),
2890
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2891
+ Input,
2892
+ {
2893
+ placeholder: "123 Main St, San Francisco, CA",
2894
+ value: formData.address || "",
2895
+ onChange: (e) => setActionFormData({
2896
+ ...actionFormData,
2897
+ address: e.target.value
2898
+ }),
2899
+ className: "h-8 text-xs border-gray-200"
2900
+ }
2901
+ )
2902
+ ] }),
2903
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "grid grid-cols-2 gap-2", children: [
2904
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2905
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Phone" }),
2906
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2907
+ Input,
2908
+ {
2909
+ type: "tel",
2910
+ placeholder: "+1 (555) 123-4567",
2911
+ value: formData.phone || "",
2912
+ onChange: (e) => setActionFormData({
2913
+ ...actionFormData,
2914
+ phone: e.target.value
2915
+ }),
2916
+ className: "h-8 text-xs border-gray-200"
2917
+ }
2918
+ )
2919
+ ] }),
2920
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2921
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Website" }),
2922
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2923
+ Input,
2924
+ {
2925
+ type: "url",
2926
+ placeholder: "https://acme.com",
2927
+ value: formData.website || "",
2928
+ onChange: (e) => setActionFormData({
2929
+ ...actionFormData,
2930
+ website: e.target.value
2931
+ }),
2932
+ className: "h-8 text-xs border-gray-200"
2933
+ }
2934
+ )
2935
+ ] })
2936
+ ] })
2937
+ ] }),
2938
+ 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: [
2939
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "API Key Name" }),
2940
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2941
+ Input,
2942
+ {
2943
+ placeholder: "Production Key",
2944
+ value: formData.name || "",
2945
+ onChange: (e) => setActionFormData({
2946
+ ...actionFormData,
2947
+ name: e.target.value
2948
+ }),
2949
+ className: "h-8 text-xs border-gray-200"
2950
+ }
2951
+ )
2952
+ ] }) }),
2953
+ 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: [
2954
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "grid grid-cols-2 gap-2", children: [
2955
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2956
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Company Name" }),
2957
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2958
+ Input,
2959
+ {
2960
+ placeholder: "Acme Corporation",
2961
+ value: formData.name || "",
2962
+ onChange: (e) => setActionFormData({
2963
+ ...actionFormData,
2964
+ name: e.target.value
2965
+ }),
2966
+ className: "h-8 text-xs border-gray-200"
2967
+ }
2968
+ )
2969
+ ] }),
2970
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2971
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Email" }),
2972
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2973
+ Input,
2974
+ {
2975
+ type: "email",
2976
+ placeholder: "contact@acme.com",
2977
+ value: formData.email || "",
2978
+ onChange: (e) => setActionFormData({
2979
+ ...actionFormData,
2980
+ email: e.target.value
2981
+ }),
2982
+ className: "h-8 text-xs border-gray-200"
2983
+ }
2984
+ )
2985
+ ] })
2986
+ ] }),
2987
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2988
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Location" }),
2989
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2990
+ Input,
2991
+ {
2992
+ placeholder: "San Francisco, CA",
2993
+ value: formData.location || "",
2994
+ onChange: (e) => setActionFormData({
2995
+ ...actionFormData,
2996
+ location: e.target.value
2997
+ }),
2998
+ className: "h-8 text-xs border-gray-200"
2999
+ }
3000
+ )
3001
+ ] }),
3002
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3003
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Subscription Tier" }),
3004
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3005
+ "select",
3006
+ {
3007
+ value: formData.subscription || "Starter",
3008
+ onChange: (e) => setActionFormData({
3009
+ ...actionFormData,
3010
+ subscription: e.target.value
3011
+ }),
3012
+ 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",
3013
+ children: [
3014
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "Starter", children: "Starter" }),
3015
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "Professional", children: "Professional" }),
3016
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "Enterprise", children: "Enterprise" })
3017
+ ]
3018
+ }
3019
+ )
3020
+ ] })
3021
+ ] }),
3022
+ (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." }) }),
3023
+ 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: [
3024
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3025
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Current Password" }),
3026
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3027
+ Input,
3028
+ {
3029
+ type: "password",
3030
+ value: formData.currentPassword || "",
3031
+ onChange: (e) => setActionFormData({
3032
+ ...actionFormData,
3033
+ currentPassword: e.target.value
3034
+ }),
3035
+ className: "h-8 text-xs border-gray-200"
3036
+ }
3037
+ )
3038
+ ] }),
3039
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3040
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "New Password" }),
3041
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3042
+ Input,
3043
+ {
3044
+ type: "password",
3045
+ value: formData.newPassword || "",
3046
+ onChange: (e) => setActionFormData({
3047
+ ...actionFormData,
3048
+ newPassword: e.target.value
3049
+ }),
3050
+ className: "h-8 text-xs border-gray-200"
3051
+ }
3052
+ )
3053
+ ] }),
3054
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3055
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Confirm New Password" }),
3056
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3057
+ Input,
3058
+ {
3059
+ type: "password",
3060
+ value: formData.confirmPassword || "",
3061
+ onChange: (e) => setActionFormData({
3062
+ ...actionFormData,
3063
+ confirmPassword: e.target.value
3064
+ }),
3065
+ className: "h-8 text-xs border-gray-200"
3066
+ }
3067
+ )
3068
+ ] })
3069
+ ] }),
3070
+ 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: [
3071
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3072
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Notification Type" }),
3073
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3074
+ "select",
3075
+ {
3076
+ value: formData.notificationType || "paymentReceived",
3077
+ onChange: (e) => setActionFormData({
3078
+ ...actionFormData,
3079
+ notificationType: e.target.value
3080
+ }),
3081
+ 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",
3082
+ children: [
3083
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "paymentReceived", children: "Payment Received" }),
3084
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "paymentFailed", children: "Payment Failed" }),
3085
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "invoicePaid", children: "Invoice Paid" }),
3086
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "monthlySummary", children: "Monthly Summary" }),
3087
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "productUpdates", children: "Product Updates" })
3088
+ ]
3089
+ }
3090
+ )
3091
+ ] }),
3092
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex items-center gap-2", children: [
3093
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3094
+ "input",
3095
+ {
3096
+ type: "checkbox",
3097
+ checked: formData.enabled !== false,
3098
+ onChange: (e) => setActionFormData({
3099
+ ...actionFormData,
3100
+ enabled: e.target.checked
3101
+ }),
3102
+ className: "h-4 w-4 rounded border-gray-300 text-primary focus:ring-primary"
3103
+ }
3104
+ ),
3105
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs text-black", children: "Enable this notification" })
3106
+ ] })
3107
+ ] }),
3108
+ (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: [
3109
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Integration" }),
3110
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3111
+ "select",
3112
+ {
3113
+ value: formData.integrationName || "Slack",
3114
+ onChange: (e) => setActionFormData({
3115
+ ...actionFormData,
3116
+ integrationName: e.target.value
3117
+ }),
3118
+ 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",
3119
+ children: [
3120
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "Slack", children: "Slack" }),
3121
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "Zapier", children: "Zapier" }),
3122
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "Webhook", children: "Webhook" })
3123
+ ]
3124
+ }
3125
+ )
3126
+ ] }) }),
3127
+ 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: [
3128
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3129
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Card Number" }),
3130
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3131
+ Input,
3132
+ {
3133
+ placeholder: "1234 5678 9012 3456",
3134
+ value: formData.cardNumber || "",
3135
+ onChange: (e) => setActionFormData({
3136
+ ...actionFormData,
3137
+ cardNumber: e.target.value
3138
+ }),
3139
+ className: "h-8 text-xs border-gray-200"
3140
+ }
3141
+ )
3142
+ ] }),
3143
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3144
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Expiry Date" }),
3145
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3146
+ Input,
3147
+ {
3148
+ placeholder: "MM/YY",
3149
+ value: formData.expiryDate || "",
3150
+ onChange: (e) => setActionFormData({
3151
+ ...actionFormData,
3152
+ expiryDate: e.target.value
3153
+ }),
3154
+ className: "h-8 text-xs border-gray-200"
3155
+ }
3156
+ )
3157
+ ] })
3158
+ ] }),
3159
+ 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." }) }),
3160
+ 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: [
3161
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3162
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Transaction ID or Customer Name" }),
3163
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3164
+ Input,
3165
+ {
3166
+ placeholder: "e.g., txn_1234 or Acme Corp",
3167
+ value: formData.transactionId || formData.customer || "",
3168
+ onChange: (e) => {
3169
+ const value = e.target.value;
3170
+ if (value.startsWith("txn_") || /^\d+$/.test(value)) {
3171
+ setActionFormData({
3172
+ ...actionFormData,
3173
+ transactionId: value,
3174
+ customer: void 0
3175
+ });
3176
+ } else {
3177
+ setActionFormData({
3178
+ ...actionFormData,
3179
+ customer: value,
3180
+ transactionId: void 0
3181
+ });
3182
+ }
3183
+ },
3184
+ className: "h-8 text-xs border-gray-200"
3185
+ }
3186
+ )
3187
+ ] }),
3188
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3189
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Amount (optional)" }),
3190
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3191
+ Input,
3192
+ {
3193
+ placeholder: "$0.00",
3194
+ value: formData.amount || "",
3195
+ onChange: (e) => setActionFormData({
3196
+ ...actionFormData,
3197
+ amount: e.target.value
3198
+ }),
3199
+ className: "h-8 text-xs border-gray-200"
3200
+ }
3201
+ )
3202
+ ] }),
3203
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3204
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Reason (optional)" }),
3205
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3206
+ Input,
3207
+ {
3208
+ placeholder: "e.g., Customer request",
3209
+ value: formData.reason || "",
3210
+ onChange: (e) => setActionFormData({
3211
+ ...actionFormData,
3212
+ reason: e.target.value
3213
+ }),
3214
+ className: "h-8 text-xs border-gray-200"
3215
+ }
3216
+ )
3217
+ ] })
3218
+ ] }),
3219
+ 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: [
3220
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3221
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "API Key Name or ID" }),
3222
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3223
+ Input,
3224
+ {
3225
+ placeholder: "Production Key",
3226
+ value: formData.keyId || formData.name || "",
3227
+ onChange: (e) => setActionFormData({
3228
+ ...actionFormData,
3229
+ keyId: e.target.value,
3230
+ name: e.target.value
3231
+ }),
3232
+ className: "h-8 text-xs border-gray-200"
3233
+ }
3234
+ )
3235
+ ] }),
3236
+ /* @__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." })
3237
+ ] }),
3238
+ 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: [
3239
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3240
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Webhook URL" }),
3241
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3242
+ Input,
3243
+ {
3244
+ type: "url",
3245
+ placeholder: "https://example.com/webhook",
3246
+ value: formData.url || "",
3247
+ onChange: (e) => setActionFormData({
3248
+ ...actionFormData,
3249
+ url: e.target.value
3250
+ }),
3251
+ className: "h-8 text-xs border-gray-200"
3252
+ }
3253
+ )
3254
+ ] }),
3255
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3256
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Name (optional)" }),
3257
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3258
+ Input,
3259
+ {
3260
+ placeholder: "Production Webhook",
3261
+ value: formData.name || "",
3262
+ onChange: (e) => setActionFormData({
3263
+ ...actionFormData,
3264
+ name: e.target.value
3265
+ }),
3266
+ className: "h-8 text-xs border-gray-200"
3267
+ }
3268
+ )
3269
+ ] })
3270
+ ] }),
3271
+ 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: [
3272
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Currency" }),
3273
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3274
+ "select",
3275
+ {
3276
+ value: formData.currency || "USD",
3277
+ onChange: (e) => setActionFormData({
3278
+ ...actionFormData,
3279
+ currency: e.target.value
3280
+ }),
3281
+ 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",
3282
+ children: [
3283
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "USD", children: "USD ($)" }),
3284
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "EUR", children: "EUR (\u20AC)" }),
3285
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "GBP", children: "GBP (\xA3)" }),
3286
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "JPY", children: "JPY (\xA5)" })
3287
+ ]
3288
+ }
3289
+ )
3290
+ ] }) }),
3291
+ 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: [
3292
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Timezone" }),
3293
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3294
+ "select",
3295
+ {
3296
+ value: formData.timezone || "America/Los_Angeles",
3297
+ onChange: (e) => setActionFormData({
3298
+ ...actionFormData,
3299
+ timezone: e.target.value
3300
+ }),
3301
+ 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",
3302
+ children: [
3303
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "America/Los_Angeles", children: "Pacific Time (PT)" }),
3304
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "America/New_York", children: "Eastern Time (ET)" }),
3305
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "Europe/London", children: "GMT" }),
3306
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "Asia/Tokyo", children: "JST" })
3307
+ ]
3308
+ }
3309
+ )
3310
+ ] }) }),
3311
+ 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: [
3312
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3313
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Device/Session" }),
3314
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3315
+ Input,
3316
+ {
3317
+ placeholder: "MacBook Pro",
3318
+ value: formData.device || "",
3319
+ onChange: (e) => setActionFormData({
3320
+ ...actionFormData,
3321
+ device: e.target.value
3322
+ }),
3323
+ className: "h-8 text-xs border-gray-200"
3324
+ }
3325
+ )
3326
+ ] }),
3327
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "text-xs text-black", children: "This will sign out the device and invalidate its session." })
3328
+ ] }),
3329
+ 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: [
3330
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3331
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Customer Email" }),
3332
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3333
+ Input,
3334
+ {
3335
+ type: "email",
3336
+ placeholder: "customer@example.com",
3337
+ value: formData.customerEmail || "",
3338
+ onChange: (e) => setActionFormData({
3339
+ ...actionFormData,
3340
+ customerEmail: e.target.value
3341
+ }),
3342
+ className: "h-8 text-xs border-gray-200"
3343
+ }
3344
+ )
3345
+ ] }),
3346
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3347
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Plan" }),
3348
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3349
+ "select",
3350
+ {
3351
+ value: formData.plan || "Starter",
3352
+ onChange: (e) => setActionFormData({
3353
+ ...actionFormData,
3354
+ plan: e.target.value
3355
+ }),
3356
+ 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",
3357
+ children: [
3358
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "Starter", children: "Starter ($29/mo)" }),
3359
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "Professional", children: "Professional ($99/mo)" }),
3360
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "Enterprise", children: "Enterprise ($299/mo)" })
3361
+ ]
3362
+ }
3363
+ )
3364
+ ] }),
3365
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3366
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Billing Cycle" }),
3367
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3368
+ "select",
3369
+ {
3370
+ value: formData.billingCycle || "monthly",
3371
+ onChange: (e) => setActionFormData({
3372
+ ...actionFormData,
3373
+ billingCycle: e.target.value
3374
+ }),
3375
+ 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",
3376
+ children: [
3377
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "monthly", children: "Monthly" }),
3378
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "yearly", children: "Yearly (Save 15%)" })
3379
+ ]
3380
+ }
3381
+ )
3382
+ ] })
3383
+ ] }),
3384
+ 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: [
3385
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "text-xs text-black", children: "This will export your certificate of incorporation document." }),
3386
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3387
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Format" }),
3388
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3389
+ "select",
3390
+ {
3391
+ value: formData.format || "pdf",
3392
+ onChange: (e) => setActionFormData({
3393
+ ...actionFormData,
3394
+ format: e.target.value
3395
+ }),
3396
+ 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",
3397
+ children: [
3398
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "pdf", children: "PDF" }),
3399
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "json", children: "JSON" })
3400
+ ]
3401
+ }
3402
+ )
3403
+ ] })
3404
+ ] }),
3405
+ (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: [
3406
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3407
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Block Rule" }),
3408
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3409
+ "select",
3410
+ {
3411
+ value: formData.ruleId || "rule_1",
3412
+ onChange: (e) => setActionFormData({
3413
+ ...actionFormData,
3414
+ ruleId: e.target.value
3415
+ }),
3416
+ 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",
3417
+ children: [
3418
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "rule_1", children: "Block if risk level = 'highest'" }),
3419
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "rule_2", children: "Block if matches Stripe block lists" }),
3420
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "rule_3", children: "Block if CVC verification fails" }),
3421
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "rule_4", children: "Block if Postal code verification fails" })
3422
+ ]
3423
+ }
3424
+ )
3425
+ ] }),
3426
+ /* @__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." })
3427
+ ] }),
3428
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "mt-3", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3429
+ Button,
3430
+ {
3431
+ type: "button",
3432
+ size: "sm",
3433
+ variant: "secondary",
3434
+ className: "h-8 rounded-xl px-3 text-xs gap-1.5 bg-gray-100 hover:bg-gray-200 border border-gray-200",
3435
+ onClick: handleActionSubmit,
3436
+ children: [
3437
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { children: "Confirm" }),
3438
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "flex items-center gap-0.5 text-gray-400", children: [
3439
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.Command, { className: "h-3 w-3" }),
3440
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.CornerDownLeft, { className: "h-3 w-3" })
3441
+ ] })
3442
+ ]
3443
+ }
3444
+ ) })
2903
3445
  ]
2904
- }
2905
- )
2906
- ] }) }),
2907
- 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: [
2908
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Timezone" }),
2909
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
2910
- "select",
3446
+ },
3447
+ message.id
3448
+ );
3449
+ }
3450
+ if (message.kind === "bulkPreview" && message.csvData) {
3451
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3452
+ "div",
2911
3453
  {
2912
- value: formData.timezone || "America/Los_Angeles",
2913
- onChange: (e) => setActionFormData({ ...actionFormData, timezone: e.target.value }),
2914
- 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",
3454
+ className: `${isRoleChange ? "mt-3" : ""}`,
2915
3455
  children: [
2916
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "America/Los_Angeles", children: "Pacific Time (PT)" }),
2917
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "America/New_York", children: "Eastern Time (ET)" }),
2918
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "Europe/London", children: "GMT" }),
2919
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "Asia/Tokyo", children: "JST" })
2920
- ]
2921
- }
2922
- )
2923
- ] }) }),
2924
- 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: [
2925
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2926
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Device/Session" }),
2927
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2928
- Input,
2929
- {
2930
- placeholder: "MacBook Pro",
2931
- value: formData.device || "",
2932
- onChange: (e) => setActionFormData({ ...actionFormData, device: e.target.value }),
2933
- className: "h-8 text-xs border-gray-200"
2934
- }
2935
- )
2936
- ] }),
2937
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "text-xs text-black", children: "This will sign out the device and invalidate its session." })
2938
- ] }),
2939
- 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: [
2940
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2941
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Customer Email" }),
2942
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2943
- Input,
2944
- {
2945
- type: "email",
2946
- placeholder: "customer@example.com",
2947
- value: formData.customerEmail || "",
2948
- onChange: (e) => setActionFormData({ ...actionFormData, customerEmail: e.target.value }),
2949
- className: "h-8 text-xs border-gray-200"
2950
- }
2951
- )
2952
- ] }),
2953
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2954
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Plan" }),
2955
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
2956
- "select",
2957
- {
2958
- value: formData.plan || "Starter",
2959
- onChange: (e) => setActionFormData({ ...actionFormData, plan: e.target.value }),
2960
- 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",
2961
- children: [
2962
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "Starter", children: "Starter ($29/mo)" }),
2963
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "Professional", children: "Professional ($99/mo)" }),
2964
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "Enterprise", children: "Enterprise ($299/mo)" })
2965
- ]
2966
- }
2967
- )
2968
- ] }),
2969
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2970
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Billing Cycle" }),
2971
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
2972
- "select",
2973
- {
2974
- value: formData.billingCycle || "monthly",
2975
- onChange: (e) => setActionFormData({ ...actionFormData, billingCycle: e.target.value }),
2976
- 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",
2977
- children: [
2978
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "monthly", children: "Monthly" }),
2979
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "yearly", children: "Yearly (Save 15%)" })
2980
- ]
2981
- }
2982
- )
2983
- ] })
2984
- ] }),
2985
- 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: [
2986
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "text-xs text-black", children: "This will export your certificate of incorporation document." }),
2987
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2988
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Format" }),
2989
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
2990
- "select",
2991
- {
2992
- value: formData.format || "pdf",
2993
- onChange: (e) => setActionFormData({ ...actionFormData, format: e.target.value }),
2994
- 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",
2995
- children: [
2996
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "pdf", children: "PDF" }),
2997
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "json", children: "JSON" })
2998
- ]
2999
- }
3000
- )
3001
- ] })
3002
- ] }),
3003
- (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: [
3004
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3005
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Block Rule" }),
3006
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3007
- "select",
3008
- {
3009
- value: formData.ruleId || "rule_1",
3010
- onChange: (e) => setActionFormData({ ...actionFormData, ruleId: e.target.value }),
3011
- 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",
3012
- children: [
3013
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "rule_1", children: "Block if risk level = 'highest'" }),
3014
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "rule_2", children: "Block if matches Stripe block lists" }),
3015
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "rule_3", children: "Block if CVC verification fails" }),
3016
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "rule_4", children: "Block if Postal code verification fails" })
3017
- ]
3018
- }
3019
- )
3020
- ] }),
3021
- /* @__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." })
3022
- ] }),
3023
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "mt-3", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3024
- Button,
3025
- {
3026
- type: "button",
3027
- size: "sm",
3028
- variant: "secondary",
3029
- className: "h-8 rounded-xl px-3 text-xs gap-1.5 bg-gray-100 hover:bg-gray-200 border border-gray-200",
3030
- onClick: handleActionSubmit,
3031
- children: [
3032
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { children: "Confirm" }),
3033
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "flex items-center gap-0.5 text-gray-400", children: [
3034
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.Command, { className: "h-3 w-3" }),
3035
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.CornerDownLeft, { className: "h-3 w-3" })
3036
- ] })
3037
- ]
3038
- }
3039
- ) })
3040
- ] }, message.id);
3041
- }
3042
- if (message.kind === "bulkPreview" && message.csvData) {
3043
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: `${isRoleChange ? "mt-3" : ""}`, children: [
3044
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "whitespace-pre-wrap text-sm leading-6 mb-3 text-gray-700", children: message.content || "" }),
3045
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "bg-gray-50 rounded-lg border border-gray-200 overflow-hidden", children: [
3046
- /* @__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: [
3047
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.FileSpreadsheet, { className: "h-4 w-4 text-gray-600" }),
3048
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "text-xs font-medium text-gray-700", children: message.csvData.fileName }),
3049
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "text-xs text-gray-500", children: [
3050
- "\u2022 ",
3051
- message.csvData.rowCount,
3052
- " rows"
3053
- ] })
3054
- ] }),
3055
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "px-3 py-2 border-b border-gray-100", children: [
3056
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "text-[10px] uppercase tracking-wider text-gray-500 mb-1", children: "Columns" }),
3057
- /* @__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)) })
3058
- ] }),
3059
- message.csvData.sampleRows.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "px-3 py-2", children: [
3060
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "text-[10px] uppercase tracking-wider text-gray-500 mb-1", children: "Sample Data" }),
3061
- /* @__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: [
3062
- Object.entries(row).slice(0, 3).map(([key, val], j) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { children: [
3063
- j > 0 && " \u2022 ",
3064
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "text-gray-400", children: [
3065
- key,
3066
- ":"
3456
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "whitespace-pre-wrap text-sm leading-6 mb-3 text-gray-700", children: message.content || "" }),
3457
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "bg-gray-50 rounded-lg border border-gray-200 overflow-hidden", children: [
3458
+ /* @__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: [
3459
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.FileSpreadsheet, { className: "h-4 w-4 text-gray-600" }),
3460
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "text-xs font-medium text-gray-700", children: message.csvData.fileName }),
3461
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "text-xs text-gray-500", children: [
3462
+ "\u2022 ",
3463
+ message.csvData.rowCount,
3464
+ " rows"
3465
+ ] })
3466
+ ] }),
3467
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "px-3 py-2 border-b border-gray-100", children: [
3468
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "text-[10px] uppercase tracking-wider text-gray-500 mb-1", children: "Columns" }),
3469
+ /* @__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)(
3470
+ "span",
3471
+ {
3472
+ className: "text-xs bg-blue-100 text-blue-700 px-1.5 py-0.5 rounded",
3473
+ children: col
3474
+ },
3475
+ i
3476
+ )) })
3477
+ ] }),
3478
+ message.csvData.sampleRows.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "px-3 py-2", children: [
3479
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "text-[10px] uppercase tracking-wider text-gray-500 mb-1", children: "Sample Data" }),
3480
+ /* @__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)(
3481
+ "div",
3482
+ {
3483
+ className: "text-xs text-gray-600 bg-white rounded px-2 py-1 border border-gray-100",
3484
+ children: [
3485
+ Object.entries(row).slice(0, 3).map(([key, val], j) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { children: [
3486
+ j > 0 && " \u2022 ",
3487
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "text-gray-400", children: [
3488
+ key,
3489
+ ":"
3490
+ ] }),
3491
+ " ",
3492
+ val
3493
+ ] }, key)),
3494
+ Object.keys(row).length > 3 && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "text-gray-400", children: [
3495
+ " ",
3496
+ "..."
3497
+ ] })
3498
+ ]
3499
+ },
3500
+ i
3501
+ )) })
3502
+ ] }),
3503
+ 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: [
3504
+ "Suggested action:",
3505
+ " ",
3506
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("strong", { children: message.suggestedAction.replace(/_/g, " ") })
3507
+ ] }) })
3067
3508
  ] }),
3068
- " ",
3069
- val
3070
- ] }, key)),
3071
- Object.keys(row).length > 3 && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "text-gray-400", children: " ..." })
3072
- ] }, i)) })
3073
- ] }),
3074
- 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: [
3075
- "Suggested action: ",
3076
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("strong", { children: message.suggestedAction.replace(/_/g, " ") })
3077
- ] }) })
3078
- ] }),
3079
- message.bulkSessionId && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "mt-3 flex items-center gap-2", children: [
3080
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3081
- Button,
3509
+ message.bulkSessionId && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "mt-3 flex items-center gap-2", children: [
3510
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3511
+ Button,
3512
+ {
3513
+ type: "button",
3514
+ size: "sm",
3515
+ variant: "secondary",
3516
+ className: "h-8 rounded-xl px-3 text-xs gap-1.5 bg-gray-100 hover:bg-gray-200 border border-gray-200",
3517
+ onClick: () => message.bulkSessionId && confirmBulkOperation(message.bulkSessionId),
3518
+ children: [
3519
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { children: [
3520
+ "Process ",
3521
+ message.csvData.rowCount,
3522
+ " rows"
3523
+ ] }),
3524
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "flex items-center gap-0.5 text-gray-400", children: [
3525
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.Command, { className: "h-3 w-3" }),
3526
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.CornerDownLeft, { className: "h-3 w-3" })
3527
+ ] })
3528
+ ]
3529
+ }
3530
+ ),
3531
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3532
+ Button,
3533
+ {
3534
+ type: "button",
3535
+ size: "sm",
3536
+ variant: "ghost",
3537
+ className: "h-8 rounded-xl px-3 text-xs text-gray-500 hover:text-gray-700 hover:bg-gray-100",
3538
+ onClick: cancelBulkOperation,
3539
+ children: "Cancel"
3540
+ }
3541
+ )
3542
+ ] })
3543
+ ]
3544
+ },
3545
+ message.id
3546
+ );
3547
+ }
3548
+ if (message.kind === "bulkProgress" && message.bulkProgress) {
3549
+ const { processed, total, successes, failures } = message.bulkProgress;
3550
+ const percentage = Math.round(processed / total * 100);
3551
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3552
+ "div",
3082
3553
  {
3083
- type: "button",
3084
- size: "sm",
3085
- variant: "secondary",
3086
- className: "h-8 rounded-xl px-3 text-xs gap-1.5 bg-gray-100 hover:bg-gray-200 border border-gray-200",
3087
- onClick: () => message.bulkSessionId && confirmBulkOperation(message.bulkSessionId),
3088
- children: [
3089
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { children: [
3090
- "Process ",
3091
- message.csvData.rowCount,
3092
- " rows"
3554
+ className: `${isRoleChange ? "mt-3" : ""}`,
3555
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "bg-gray-50 rounded-lg border border-gray-200 p-3", children: [
3556
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex items-center gap-2 mb-2", children: [
3557
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.Loader2, { className: "h-4 w-4 animate-spin text-blue-600" }),
3558
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "text-sm font-medium text-gray-700", children: [
3559
+ "Processing... ",
3560
+ processed,
3561
+ " of ",
3562
+ total
3563
+ ] })
3093
3564
  ] }),
3094
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "flex items-center gap-0.5 text-gray-400", children: [
3095
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.Command, { className: "h-3 w-3" }),
3096
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.CornerDownLeft, { className: "h-3 w-3" })
3565
+ /* @__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)(
3566
+ "div",
3567
+ {
3568
+ className: "h-full bg-blue-600 transition-all duration-300",
3569
+ style: { width: `${percentage}%` }
3570
+ }
3571
+ ) }),
3572
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex items-center gap-3 text-xs text-gray-600", children: [
3573
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "flex items-center gap-1", children: [
3574
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.CheckCircle2, { className: "h-3 w-3 text-green-600" }),
3575
+ successes,
3576
+ " successful"
3577
+ ] }),
3578
+ failures > 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "flex items-center gap-1 text-red-600", children: [
3579
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.X, { className: "h-3 w-3" }),
3580
+ failures,
3581
+ " failed"
3582
+ ] })
3097
3583
  ] })
3098
- ]
3099
- }
3100
- ),
3101
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3102
- Button,
3584
+ ] })
3585
+ },
3586
+ message.id
3587
+ );
3588
+ }
3589
+ if (message.kind === "bulkSummary" && message.bulkSummary) {
3590
+ const { total, successes, failures, navigationPage } = message.bulkSummary;
3591
+ const hasFailures = failures.length > 0;
3592
+ const pageLabel = navigationPage?.page === "customers" ? "Customers" : navigationPage?.page === "dashboard" ? "Dashboard" : navigationPage?.page === "settings" ? "Settings" : "Results";
3593
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3594
+ "div",
3103
3595
  {
3104
- type: "button",
3105
- size: "sm",
3106
- variant: "ghost",
3107
- className: "h-8 rounded-xl px-3 text-xs text-gray-500 hover:text-gray-700 hover:bg-gray-100",
3108
- onClick: cancelBulkOperation,
3109
- children: "Cancel"
3110
- }
3111
- )
3112
- ] })
3113
- ] }, message.id);
3114
- }
3115
- if (message.kind === "bulkProgress" && message.bulkProgress) {
3116
- const { processed, total, successes, failures } = message.bulkProgress;
3117
- const percentage = Math.round(processed / total * 100);
3118
- 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: [
3119
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex items-center gap-2 mb-2", children: [
3120
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.Loader2, { className: "h-4 w-4 animate-spin text-blue-600" }),
3121
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "text-sm font-medium text-gray-700", children: [
3122
- "Processing... ",
3123
- processed,
3124
- " of ",
3125
- total
3126
- ] })
3127
- ] }),
3128
- /* @__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)(
3596
+ className: `${isRoleChange ? "mt-3" : ""}`,
3597
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3598
+ "div",
3599
+ {
3600
+ className: `rounded-lg border p-3 ${hasFailures ? "bg-amber-50 border-amber-200" : "bg-green-50 border-green-200"}`,
3601
+ children: [
3602
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex items-center gap-2 mb-2", children: [
3603
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3604
+ import_lucide_react4.CheckCircle2,
3605
+ {
3606
+ className: `h-5 w-5 ${hasFailures ? "text-amber-600" : "text-green-600"}`
3607
+ }
3608
+ ),
3609
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "text-sm font-medium text-gray-800", children: "Bulk operation complete" })
3610
+ ] }),
3611
+ /* @__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` : ""}.` }),
3612
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex items-center gap-4 text-xs", children: [
3613
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "flex items-center gap-1 text-green-700", children: [
3614
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.CheckCircle2, { className: "h-3 w-3" }),
3615
+ successes,
3616
+ " successful"
3617
+ ] }),
3618
+ hasFailures && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "flex items-center gap-1 text-red-600", children: [
3619
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.X, { className: "h-3 w-3" }),
3620
+ failures.length,
3621
+ " failed"
3622
+ ] })
3623
+ ] }),
3624
+ hasFailures && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "mt-3 pt-2 border-t border-amber-200", children: [
3625
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "text-[10px] uppercase tracking-wider text-amber-700 mb-1", children: "Failed Rows" }),
3626
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "space-y-1 max-h-32 overflow-y-auto", children: [
3627
+ failures.slice(0, 5).map((failure, i) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3628
+ "div",
3629
+ {
3630
+ className: "text-xs text-red-700 bg-red-50 rounded px-2 py-1",
3631
+ children: [
3632
+ "Row ",
3633
+ failure.row,
3634
+ ":",
3635
+ " ",
3636
+ failure.error || "Unknown error"
3637
+ ]
3638
+ },
3639
+ i
3640
+ )),
3641
+ failures.length > 5 && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "text-xs text-amber-600", children: [
3642
+ "...and ",
3643
+ failures.length - 5,
3644
+ " more"
3645
+ ] })
3646
+ ] })
3647
+ ] }),
3648
+ 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)(
3649
+ "button",
3650
+ {
3651
+ type: "button",
3652
+ onClick: (e) => {
3653
+ e.preventDefault();
3654
+ e.stopPropagation();
3655
+ console.log(
3656
+ "[DEBUG] Button clicked - navigationPage:",
3657
+ navigationPage,
3658
+ "onNavigate:",
3659
+ !!onNavigate
3660
+ );
3661
+ if (onNavigate && navigationPage.page) {
3662
+ console.log(
3663
+ "[DEBUG] Calling onNavigate with page:",
3664
+ navigationPage.page
3665
+ );
3666
+ onNavigate(
3667
+ navigationPage.page,
3668
+ navigationPage.subtab
3669
+ );
3670
+ } else {
3671
+ console.log(
3672
+ "[DEBUG] Condition failed - onNavigate:",
3673
+ !!onNavigate,
3674
+ "navigationPage.page:",
3675
+ navigationPage.page
3676
+ );
3677
+ }
3678
+ },
3679
+ className: "flex items-center gap-2 text-xs text-gray-500 hover:text-gray-700 transition-colors group cursor-pointer",
3680
+ children: [
3681
+ /* @__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: [
3682
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.Command, { className: "h-2.5 w-2.5" }),
3683
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { children: "+" }),
3684
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.CornerDownLeft, { className: "h-2.5 w-2.5" })
3685
+ ] }),
3686
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { children: [
3687
+ "View ",
3688
+ pageLabel
3689
+ ] })
3690
+ ]
3691
+ }
3692
+ ) })
3693
+ ]
3694
+ }
3695
+ )
3696
+ },
3697
+ message.id
3698
+ );
3699
+ }
3700
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(React4.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3129
3701
  "div",
3130
3702
  {
3131
- className: "h-full bg-blue-600 transition-all duration-300",
3132
- style: { width: `${percentage}%` }
3703
+ ref: isCurrentGuideStep ? currentStepRef : null,
3704
+ className: `${isRoleChange ? "mt-3" : ""}`,
3705
+ children: [
3706
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "text-sm leading-6 text-gray-700", children: (() => {
3707
+ const text = message.content || "";
3708
+ if (message.kind === "guideStep") {
3709
+ const m = text.match(/^(Step\s+\d+:)([\s\S]*)/);
3710
+ if (m) {
3711
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
3712
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("strong", { children: m[1] }),
3713
+ m[2]
3714
+ ] });
3715
+ }
3716
+ }
3717
+ if (message.role === "assistant" && text) {
3718
+ return renderMarkdown(text);
3719
+ }
3720
+ return text || /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "opacity-70", children: "Thinking\u2026" });
3721
+ })() }),
3722
+ message.role === "assistant" && message.structuredData && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "mt-3", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3723
+ DataRenderer,
3724
+ {
3725
+ type: message.structuredData.type,
3726
+ data: message.structuredData.data
3727
+ }
3728
+ ) }),
3729
+ 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)(
3730
+ "button",
3731
+ {
3732
+ type: "button",
3733
+ onClick: () => handleFollowupClick(message.id, followup),
3734
+ 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",
3735
+ children: followup.label
3736
+ },
3737
+ followup.id
3738
+ )) })
3739
+ ]
3133
3740
  }
3134
- ) }),
3135
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex items-center gap-3 text-xs text-gray-600", children: [
3136
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "flex items-center gap-1", children: [
3137
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.CheckCircle2, { className: "h-3 w-3 text-green-600" }),
3138
- successes,
3139
- " successful"
3140
- ] }),
3141
- failures > 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "flex items-center gap-1 text-red-600", children: [
3142
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.X, { className: "h-3 w-3" }),
3143
- failures,
3144
- " failed"
3145
- ] })
3146
- ] })
3147
- ] }) }, message.id);
3148
- }
3149
- if (message.kind === "bulkSummary" && message.bulkSummary) {
3150
- const { total, successes, failures, navigationPage } = message.bulkSummary;
3151
- const hasFailures = failures.length > 0;
3152
- const pageLabel = navigationPage?.page === "customers" ? "Customers" : navigationPage?.page === "dashboard" ? "Dashboard" : navigationPage?.page === "settings" ? "Settings" : "Results";
3153
- 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: [
3154
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex items-center gap-2 mb-2", children: [
3155
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.CheckCircle2, { className: `h-5 w-5 ${hasFailures ? "text-amber-600" : "text-green-600"}` }),
3156
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "text-sm font-medium text-gray-800", children: "Bulk operation complete" })
3157
- ] }),
3158
- /* @__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` : ""}.` }),
3159
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex items-center gap-4 text-xs", children: [
3160
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "flex items-center gap-1 text-green-700", children: [
3161
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.CheckCircle2, { className: "h-3 w-3" }),
3162
- successes,
3163
- " successful"
3164
- ] }),
3165
- hasFailures && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "flex items-center gap-1 text-red-600", children: [
3166
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.X, { className: "h-3 w-3" }),
3167
- failures.length,
3168
- " failed"
3169
- ] })
3170
- ] }),
3171
- hasFailures && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "mt-3 pt-2 border-t border-amber-200", children: [
3172
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "text-[10px] uppercase tracking-wider text-amber-700 mb-1", children: "Failed Rows" }),
3173
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "space-y-1 max-h-32 overflow-y-auto", children: [
3174
- 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: [
3175
- "Row ",
3176
- failure.row,
3177
- ": ",
3178
- failure.error || "Unknown error"
3179
- ] }, i)),
3180
- failures.length > 5 && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "text-xs text-amber-600", children: [
3181
- "...and ",
3182
- failures.length - 5,
3183
- " more"
3184
- ] })
3185
- ] })
3186
- ] }),
3187
- 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)(
3188
- "button",
3741
+ ) }, message.id);
3742
+ }),
3743
+ (activeGuide || guideComplete) && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "mt-3 flex items-center gap-2", children: [
3744
+ activeGuide && activeGuide.stepIndex > 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3745
+ Button,
3189
3746
  {
3190
3747
  type: "button",
3191
- onClick: (e) => {
3192
- e.preventDefault();
3193
- e.stopPropagation();
3194
- console.log("[DEBUG] Button clicked - navigationPage:", navigationPage, "onNavigate:", !!onNavigate);
3195
- if (onNavigate && navigationPage.page) {
3196
- console.log("[DEBUG] Calling onNavigate with page:", navigationPage.page);
3197
- onNavigate(navigationPage.page, navigationPage.subtab);
3198
- } else {
3199
- console.log("[DEBUG] Condition failed - onNavigate:", !!onNavigate, "navigationPage.page:", navigationPage.page);
3200
- }
3201
- },
3202
- className: "flex items-center gap-2 text-xs text-gray-500 hover:text-gray-700 transition-colors group cursor-pointer",
3748
+ size: "sm",
3749
+ variant: "secondary",
3750
+ className: "h-7 w-7 rounded-full p-0 bg-gray-100 hover:bg-gray-200 border border-gray-200",
3751
+ onClick: goBackGuide,
3752
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.ArrowLeft, { className: "h-3.5 w-3.5 text-gray-600" })
3753
+ }
3754
+ ),
3755
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3756
+ Button,
3757
+ {
3758
+ type: "button",
3759
+ size: "sm",
3760
+ variant: "secondary",
3761
+ className: "h-8 rounded-xl px-3 text-xs gap-1.5 bg-gray-100 hover:bg-gray-200 border border-gray-200",
3762
+ onClick: guideComplete ? handleBack : advanceGuide,
3203
3763
  children: [
3204
- /* @__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: [
3205
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.Command, { className: "h-2.5 w-2.5" }),
3206
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { children: "+" }),
3207
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.CornerDownLeft, { className: "h-2.5 w-2.5" })
3208
- ] }),
3209
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { children: [
3210
- "View ",
3211
- pageLabel
3764
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { children: guideComplete ? "Done" : "Next" }),
3765
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "flex items-center gap-0.5 text-gray-400", children: [
3766
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.Command, { className: "h-3 w-3" }),
3767
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.CornerDownLeft, { className: "h-3 w-3" })
3212
3768
  ] })
3213
3769
  ]
3214
3770
  }
3215
- ) })
3216
- ] }) }, message.id);
3217
- }
3218
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(React4.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3219
- "div",
3220
- {
3221
- ref: isCurrentGuideStep ? currentStepRef : null,
3222
- className: `${isRoleChange ? "mt-3" : ""}`,
3223
- children: [
3224
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "text-sm leading-6 text-gray-700", children: (() => {
3225
- const text = message.content || "";
3226
- if (message.kind === "guideStep") {
3227
- const m = text.match(/^(Step\s+\d+:)([\s\S]*)/);
3228
- if (m) {
3229
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
3230
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("strong", { children: m[1] }),
3231
- m[2]
3232
- ] });
3233
- }
3234
- }
3235
- if (message.role === "assistant" && text) {
3236
- return renderMarkdown(text);
3237
- }
3238
- return text || /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "opacity-70", children: "Thinking\u2026" });
3239
- })() }),
3240
- message.role === "assistant" && message.structuredData && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "mt-3", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3241
- DataRenderer,
3242
- {
3243
- type: message.structuredData.type,
3244
- data: message.structuredData.data
3245
- }
3246
- ) }),
3247
- 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)(
3248
- "button",
3249
- {
3250
- type: "button",
3251
- onClick: () => handleFollowupClick(message.id, followup),
3252
- 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",
3253
- children: followup.label
3254
- },
3255
- followup.id
3256
- )) })
3257
- ]
3258
- }
3259
- ) }, message.id);
3260
- }),
3261
- (activeGuide || guideComplete) && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "mt-3 flex items-center gap-2", children: [
3262
- activeGuide && activeGuide.stepIndex > 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3263
- Button,
3264
- {
3265
- type: "button",
3266
- size: "sm",
3267
- variant: "secondary",
3268
- className: "h-7 w-7 rounded-full p-0 bg-gray-100 hover:bg-gray-200 border border-gray-200",
3269
- onClick: goBackGuide,
3270
- children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.ArrowLeft, { className: "h-3.5 w-3.5 text-gray-600" })
3271
- }
3272
- ),
3273
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3274
- Button,
3275
- {
3276
- type: "button",
3277
- size: "sm",
3278
- variant: "secondary",
3279
- className: "h-8 rounded-xl px-3 text-xs gap-1.5 bg-gray-100 hover:bg-gray-200 border border-gray-200",
3280
- onClick: guideComplete ? handleBack : advanceGuide,
3281
- children: [
3282
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { children: guideComplete ? "Done" : "Next" }),
3283
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "flex items-center gap-0.5 text-gray-400", children: [
3284
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.Command, { className: "h-3 w-3" }),
3285
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.CornerDownLeft, { className: "h-3 w-3" })
3286
- ] })
3287
- ]
3288
- }
3289
- )
3290
- ] }),
3291
- (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)(
3292
- AssistantActivity,
3293
- {
3294
- phase,
3295
- progressSteps
3296
- }
3297
- ) }),
3298
- !activeGuide && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { ref: messagesEndRef })
3299
- ] }) }) }) }) }),
3771
+ )
3772
+ ] }),
3773
+ (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)(
3774
+ AssistantActivity,
3775
+ {
3776
+ phase,
3777
+ progressSteps
3778
+ }
3779
+ ) }),
3780
+ !activeGuide && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { ref: messagesEndRef })
3781
+ ] }) }) }) })
3782
+ }
3783
+ ),
3300
3784
  /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "px-4 py-3 border-t border-gray-100 bg-gray-50/50 shrink-0", children: [
3301
3785
  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: [
3302
3786
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.FileSpreadsheet, { className: "h-4 w-4 text-blue-600" }),
@@ -3425,7 +3909,11 @@ ${userText}`
3425
3909
  }
3426
3910
  );
3427
3911
  }
3428
- function PanelToggle({ isOpen, onClick, className = "" }) {
3912
+ function PanelToggle({
3913
+ isOpen,
3914
+ onClick,
3915
+ className = ""
3916
+ }) {
3429
3917
  return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3430
3918
  "button",
3431
3919
  {
@@ -3471,13 +3959,7 @@ function ChatPanelWithToggle({
3471
3959
  };
3472
3960
  }, [isOpen]);
3473
3961
  return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
3474
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3475
- PanelToggle,
3476
- {
3477
- isOpen,
3478
- onClick: () => setIsOpen(!isOpen)
3479
- }
3480
- ),
3962
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(PanelToggle, { isOpen, onClick: () => setIsOpen(!isOpen) }),
3481
3963
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3482
3964
  ChatPanel,
3483
3965
  {