@optifye/dashboard-core 4.1.0 → 4.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/index.js +367 -114
  2. package/dist/index.mjs +368 -115
  3. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -12,7 +12,7 @@ import { noop, warning, invariant, progress, secondsToMilliseconds, milliseconds
12
12
  import { getValueTransition, hover, press, isPrimaryPointer, GroupPlaybackControls, setDragLock, supportsLinearEasing, attachTimeline, isGenerator, calcGeneratorDuration, isWaapiSupportedEasing, mapEasingToNativeEasing, maxGeneratorDuration, generateLinearEasing, isBezierDefinition } from 'motion-dom';
13
13
  import { ResponsiveContainer, BarChart as BarChart$1, CartesianGrid, XAxis, YAxis, Tooltip, ReferenceLine, Bar, Cell, LabelList, PieChart, Pie, Legend, LineChart as LineChart$1, Line } from 'recharts';
14
14
  import { Slot } from '@radix-ui/react-slot';
15
- import { Camera, Map as Map$1, Video, ChevronDown, ChevronUp, Check, X, Clock, Coffee, Plus, Minus, ArrowDown, ArrowUp, Search, CheckCircle, AlertTriangle, Info, Share2, Download, User, XCircle, ChevronLeft, ChevronRight, AlertCircle, Sun, Moon, MessageSquare, Trash2, Menu, ArrowLeft, Copy, RefreshCw, Send, Edit2, UserCheck, Save, LogOut, Calendar, Clock8, AlarmClock, Settings, LifeBuoy, Loader2, ArrowLeftIcon as ArrowLeftIcon$1, Settings2, CheckCircle2, Zap, UserCircle } from 'lucide-react';
15
+ import { Camera, Map as Map$1, Video, ChevronDown, ChevronUp, Check, X, Clock, Coffee, Plus, Minus, ArrowDown, ArrowUp, Search, CheckCircle, AlertTriangle, Info, Share2, Download, User, XCircle, ChevronLeft, ChevronRight, AlertCircle, Sun, Moon, MessageSquare, Trash2, ArrowLeft, Menu, RefreshCw, Send, Copy, Edit2, UserCheck, Save, LogOut, Calendar, Clock8, AlarmClock, Settings, LifeBuoy, Loader2, ArrowLeftIcon as ArrowLeftIcon$1, Settings2, CheckCircle2, Zap, UserCircle } from 'lucide-react';
16
16
  import { DayPicker, useNavigation as useNavigation$1 } from 'react-day-picker';
17
17
  import html2canvas from 'html2canvas';
18
18
  import jsPDF, { jsPDF as jsPDF$1 } from 'jspdf';
@@ -28093,9 +28093,9 @@ var SideNavBar = memo(({
28093
28093
  }
28094
28094
  )
28095
28095
  ] }),
28096
- /* @__PURE__ */ jsxs("div", { className: "mt-auto", children: [
28097
- /* @__PURE__ */ jsx("div", { className: "w-10 h-px bg-gray-200 my-4" }),
28098
- /* @__PURE__ */ jsx("div", { className: "pb-2 w-full", children: /* @__PURE__ */ jsx(
28096
+ /* @__PURE__ */ jsxs("div", { className: "mt-auto mb-2", children: [
28097
+ /* @__PURE__ */ jsx("div", { className: "w-10 h-px bg-gray-200 my-3" }),
28098
+ /* @__PURE__ */ jsx("div", { className: "w-full", children: /* @__PURE__ */ jsx(
28099
28099
  "button",
28100
28100
  {
28101
28101
  onClick: handleProfileClick,
@@ -28677,7 +28677,7 @@ var ThreadSidebar = ({
28677
28677
  if (error) {
28678
28678
  return /* @__PURE__ */ jsx("div", { className: `p-4 text-red-600 text-sm ${className}`, children: "Failed to load conversations" });
28679
28679
  }
28680
- return /* @__PURE__ */ jsxs("div", { className: `flex flex-col h-full bg-gray-50 border-r border-gray-200 ${className}`, children: [
28680
+ return /* @__PURE__ */ jsxs("div", { className: `flex flex-col h-screen bg-gray-50 border-r border-gray-200 ${className}`, children: [
28681
28681
  /* @__PURE__ */ jsx("div", { className: "flex-shrink-0 p-4 border-b border-gray-200", children: /* @__PURE__ */ jsxs(
28682
28682
  "button",
28683
28683
  {
@@ -28689,7 +28689,7 @@ var ThreadSidebar = ({
28689
28689
  ]
28690
28690
  }
28691
28691
  ) }),
28692
- /* @__PURE__ */ jsx("div", { className: "flex-1 overflow-y-auto", children: isLoading ? /* @__PURE__ */ jsx("div", { className: "flex justify-center p-8", children: /* @__PURE__ */ jsx(LoadingSpinner_default, { size: "sm" }) }) : threads.length === 0 ? /* @__PURE__ */ jsx("div", { className: "p-4 text-center text-gray-500 text-sm", children: "No conversations yet" }) : /* @__PURE__ */ jsx("div", { className: "py-2", children: threads.map((thread) => /* @__PURE__ */ jsxs(
28692
+ /* @__PURE__ */ jsx("div", { className: "flex-1 overflow-y-auto min-h-0", children: isLoading ? /* @__PURE__ */ jsx("div", { className: "flex justify-center p-8", children: /* @__PURE__ */ jsx(LoadingSpinner_default, { size: "sm" }) }) : threads.length === 0 ? /* @__PURE__ */ jsx("div", { className: "p-4 text-center text-gray-500 text-sm", children: "No conversations yet" }) : /* @__PURE__ */ jsx("div", { className: "py-2", children: threads.map((thread) => /* @__PURE__ */ jsxs(
28693
28693
  "div",
28694
28694
  {
28695
28695
  onClick: () => onSelectThread(thread.id),
@@ -28732,10 +28732,13 @@ var AIAgentView = () => {
28732
28732
  const [lastError, setLastError] = useState(null);
28733
28733
  const [copiedMessageId, setCopiedMessageId] = useState(null);
28734
28734
  const [activeThreadId, setActiveThreadId] = useState(void 0);
28735
- const [isSidebarOpen, setIsSidebarOpen] = useState(true);
28735
+ const [isSidebarOpen, setIsSidebarOpen] = useState(false);
28736
28736
  const [streamingStates, setStreamingStates] = useState(/* @__PURE__ */ new Map());
28737
28737
  const [userId, setUserId] = useState(null);
28738
28738
  const [pendingThreadId, setPendingThreadId] = useState(null);
28739
+ const [isTransitioning, setIsTransitioning] = useState(false);
28740
+ const [typedText, setTypedText] = useState("");
28741
+ const [newChatCount, setNewChatCount] = useState(0);
28739
28742
  const isThreadLoading = (threadId) => {
28740
28743
  return threadId ? loadingThreads.has(threadId) : false;
28741
28744
  };
@@ -28763,6 +28766,20 @@ var AIAgentView = () => {
28763
28766
  const lineId = getLineIdFromPath();
28764
28767
  const { shiftId } = getCurrentShift(dateTimeConfig.defaultTimezone || "Asia/Kolkata", shiftConfig);
28765
28768
  const companyId = entityConfig.companyId || "default-company-id";
28769
+ const ACTIVE_THREAD_STORAGE_KEY = `ai-agent-active-thread-${lineId}`;
28770
+ useEffect(() => {
28771
+ const savedThreadId = localStorage.getItem(ACTIVE_THREAD_STORAGE_KEY);
28772
+ if (savedThreadId && savedThreadId !== "undefined") {
28773
+ setActiveThreadId(savedThreadId);
28774
+ }
28775
+ }, [ACTIVE_THREAD_STORAGE_KEY]);
28776
+ useEffect(() => {
28777
+ if (activeThreadId) {
28778
+ localStorage.setItem(ACTIVE_THREAD_STORAGE_KEY, activeThreadId);
28779
+ } else {
28780
+ localStorage.removeItem(ACTIVE_THREAD_STORAGE_KEY);
28781
+ }
28782
+ }, [activeThreadId, ACTIVE_THREAD_STORAGE_KEY]);
28766
28783
  useEffect(() => {
28767
28784
  if (textareaRef.current) {
28768
28785
  textareaRef.current.style.height = "auto";
@@ -28777,6 +28794,27 @@ var AIAgentView = () => {
28777
28794
  setTimeout(scrollToBottom, 100);
28778
28795
  }
28779
28796
  }, [activeThreadId]);
28797
+ useEffect(() => {
28798
+ if (messages.length === 0 && !isTransitioning) {
28799
+ const fullText = "Hi, I'm Axel - Your AI Supervisor";
28800
+ let index = 0;
28801
+ setTypedText("");
28802
+ const typeInterval = setInterval(() => {
28803
+ if (index < fullText.length) {
28804
+ setTypedText(fullText.substring(0, index + 1));
28805
+ index++;
28806
+ } else {
28807
+ clearInterval(typeInterval);
28808
+ }
28809
+ }, 50);
28810
+ return () => clearInterval(typeInterval);
28811
+ }
28812
+ }, [messages.length, isTransitioning]);
28813
+ useEffect(() => {
28814
+ if (isSidebarOpen) {
28815
+ setNewChatCount(0);
28816
+ }
28817
+ }, [isSidebarOpen]);
28780
28818
  const copyToClipboard = async (text, messageId) => {
28781
28819
  try {
28782
28820
  await navigator.clipboard.writeText(text);
@@ -28791,6 +28829,8 @@ var AIAgentView = () => {
28791
28829
  setMessages([]);
28792
28830
  setInputValue("");
28793
28831
  setPendingThreadId(null);
28832
+ setTypedText("");
28833
+ localStorage.removeItem(ACTIVE_THREAD_STORAGE_KEY);
28794
28834
  textareaRef.current?.focus();
28795
28835
  };
28796
28836
  useEffect(() => {
@@ -28823,6 +28863,12 @@ var AIAgentView = () => {
28823
28863
  let currentThreadId = activeThreadId || `temp-${Date.now()}`;
28824
28864
  if (isThreadLoading(currentThreadId)) return;
28825
28865
  const userMessage = inputValue.trim();
28866
+ if (displayMessages.length === 0) {
28867
+ setIsTransitioning(true);
28868
+ setTimeout(() => {
28869
+ setIsTransitioning(false);
28870
+ }, 800);
28871
+ }
28826
28872
  setInputValue("");
28827
28873
  setLoadingThreads((prev) => new Set(prev).add(currentThreadId));
28828
28874
  setLastError(null);
@@ -28866,6 +28912,9 @@ var AIAgentView = () => {
28866
28912
  currentThreadId = threadId;
28867
28913
  setActiveThreadId(threadId);
28868
28914
  setPendingThreadId(null);
28915
+ if (!isSidebarOpen) {
28916
+ setNewChatCount((prev) => prev + 1);
28917
+ }
28869
28918
  setLoadingThreads((prev) => {
28870
28919
  const newSet = new Set(prev);
28871
28920
  if (newSet.has(oldThreadId)) {
@@ -28964,7 +29013,9 @@ var AIAgentView = () => {
28964
29013
  const handleKeyDown = (e) => {
28965
29014
  if (e.key === "Enter" && !e.shiftKey) {
28966
29015
  e.preventDefault();
28967
- handleSubmit(e);
29016
+ if (!isCurrentThreadLoading) {
29017
+ handleSubmit(e);
29018
+ }
28968
29019
  }
28969
29020
  };
28970
29021
  const formatMessage = (content) => {
@@ -28973,7 +29024,81 @@ var AIAgentView = () => {
28973
29024
  text = text.replace(/`([^`]+)`/g, '<code class="bg-gray-100 px-1.5 py-0.5 rounded text-sm font-mono text-gray-800">$1</code>');
28974
29025
  return text;
28975
29026
  };
28976
- const lines = content.split("\n");
29027
+ const parseTableFromText = (lines2, startIndex) => {
29028
+ const tableLines = [];
29029
+ let i = startIndex;
29030
+ while (i < lines2.length) {
29031
+ const line = lines2[i].trim();
29032
+ if (!line) {
29033
+ i++;
29034
+ break;
29035
+ }
29036
+ if (line.includes("|") || line.match(/^[-|=\s]+$/)) {
29037
+ tableLines.push(line);
29038
+ i++;
29039
+ } else {
29040
+ break;
29041
+ }
29042
+ }
29043
+ if (tableLines.length === 0) return { html: "", endIndex: startIndex };
29044
+ const dataLines = tableLines.filter((line) => !line.match(/^[-|=\s]+$/));
29045
+ if (dataLines.length === 0) return { html: "", endIndex: i };
29046
+ let headerRow = [];
29047
+ let dataRows = [];
29048
+ const firstLine = dataLines[0];
29049
+ if (firstLine.includes("|")) {
29050
+ const cells = firstLine.split("|").map((cell) => cell.trim()).filter((cell) => cell.length > 0);
29051
+ if (cells.length >= 2) {
29052
+ headerRow = cells;
29053
+ for (let j = 1; j < dataLines.length; j++) {
29054
+ const row = dataLines[j];
29055
+ if (row.includes("|")) {
29056
+ const rowCells = row.split("|").map((cell) => cell.trim()).filter((cell) => cell.length > 0);
29057
+ while (rowCells.length < headerRow.length) rowCells.push("");
29058
+ if (rowCells.length > headerRow.length) rowCells.splice(headerRow.length);
29059
+ dataRows.push(rowCells);
29060
+ }
29061
+ }
29062
+ }
29063
+ }
29064
+ if (headerRow.length === 0) {
29065
+ for (const line of dataLines) {
29066
+ if (line.includes("|")) {
29067
+ const rowCells = line.split("|").map((cell) => cell.trim()).filter((cell) => cell.length > 0);
29068
+ if (rowCells.length >= 2) {
29069
+ dataRows.push(rowCells);
29070
+ }
29071
+ }
29072
+ }
29073
+ if (dataRows.length > 0 && dataRows[0].length > 0) {
29074
+ headerRow = dataRows[0].map((_, index) => `Column ${index + 1}`);
29075
+ }
29076
+ }
29077
+ if (headerRow.length > 0 && dataRows.length > 0) {
29078
+ let tableHtml = '<div class="overflow-x-auto my-4"><table class="min-w-full border-collapse border border-gray-300 rounded-lg shadow-sm">';
29079
+ tableHtml += '<thead class="bg-gray-50">';
29080
+ tableHtml += "<tr>";
29081
+ headerRow.forEach((header) => {
29082
+ tableHtml += `<th class="border border-gray-300 px-4 py-2 text-left font-semibold text-gray-900">${processInlineFormatting(header)}</th>`;
29083
+ });
29084
+ tableHtml += "</tr>";
29085
+ tableHtml += "</thead>";
29086
+ tableHtml += '<tbody class="bg-white">';
29087
+ dataRows.forEach((row, rowIndex) => {
29088
+ tableHtml += `<tr class="${rowIndex % 2 === 0 ? "bg-white" : "bg-gray-50"}">`;
29089
+ row.forEach((cell) => {
29090
+ tableHtml += `<td class="border border-gray-300 px-4 py-2 text-gray-800">${processInlineFormatting(cell)}</td>`;
29091
+ });
29092
+ tableHtml += "</tr>";
29093
+ });
29094
+ tableHtml += "</tbody>";
29095
+ tableHtml += "</table></div>";
29096
+ return { html: tableHtml, endIndex: i };
29097
+ }
29098
+ return { html: "", endIndex: startIndex };
29099
+ };
29100
+ const processedContent = content;
29101
+ const lines = processedContent.split("\n");
28977
29102
  const formattedLines = [];
28978
29103
  let inList = false;
28979
29104
  for (let i = 0; i < lines.length; i++) {
@@ -28987,6 +29112,18 @@ var AIAgentView = () => {
28987
29112
  formattedLines.push("<br/>");
28988
29113
  continue;
28989
29114
  }
29115
+ if (trimmedLine.includes("|") && (trimmedLine.match(/\|/g) || []).length >= 1) {
29116
+ if (inList) {
29117
+ formattedLines.push("</ul>");
29118
+ inList = false;
29119
+ }
29120
+ const tableResult = parseTableFromText(lines, i);
29121
+ if (tableResult.html) {
29122
+ formattedLines.push(tableResult.html);
29123
+ i = tableResult.endIndex - 1;
29124
+ continue;
29125
+ }
29126
+ }
28990
29127
  if (trimmedLine.startsWith("###")) {
28991
29128
  if (inList) {
28992
29129
  formattedLines.push("</ul>");
@@ -29070,71 +29207,185 @@ var AIAgentView = () => {
29070
29207
  position: messages.length
29071
29208
  });
29072
29209
  }
29073
- return /* @__PURE__ */ jsxs("div", { className: "flex h-screen bg-white", children: [
29074
- /* @__PURE__ */ jsx("div", { className: `${isSidebarOpen ? "w-80" : "w-0"} transition-all duration-300 overflow-hidden flex-shrink-0`, children: /* @__PURE__ */ jsx(
29075
- ThreadSidebar,
29210
+ const renderAssistantContent = (content) => {
29211
+ return /* @__PURE__ */ jsx(
29212
+ "div",
29076
29213
  {
29077
- activeThreadId,
29078
- onSelectThread: setActiveThreadId,
29079
- onNewThread: handleNewThread,
29080
- className: "h-full"
29214
+ className: "formatted-content",
29215
+ dangerouslySetInnerHTML: { __html: formatMessage(content) }
29081
29216
  }
29082
- ) }),
29083
- /* @__PURE__ */ jsxs("div", { className: "flex-1 flex flex-col", children: [
29084
- /* @__PURE__ */ jsx("header", { className: "flex-shrink-0 bg-white border-b border-gray-200", children: /* @__PURE__ */ jsx("div", { className: "px-6 py-4", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
29085
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-4", children: [
29086
- /* @__PURE__ */ jsx(
29087
- "button",
29088
- {
29089
- onClick: () => setIsSidebarOpen(!isSidebarOpen),
29090
- className: "p-2 hover:bg-gray-100 rounded-lg transition-colors",
29091
- "aria-label": "Toggle sidebar",
29092
- children: isSidebarOpen ? /* @__PURE__ */ jsx(X, { className: "w-5 h-5" }) : /* @__PURE__ */ jsx(Menu, { className: "w-5 h-5" })
29217
+ );
29218
+ };
29219
+ return /* @__PURE__ */ jsxs("div", { className: "flex h-screen bg-white", children: [
29220
+ /* @__PURE__ */ jsx("style", { dangerouslySetInnerHTML: {
29221
+ __html: `
29222
+ @keyframes slideDown {
29223
+ 0% {
29224
+ transform: translateY(-40vh);
29225
+ opacity: 1;
29093
29226
  }
29094
- ),
29095
- /* @__PURE__ */ jsxs(
29096
- "button",
29097
- {
29098
- onClick: () => navigate("/"),
29099
- className: "flex items-center gap-2 text-gray-600 hover:text-gray-900 transition-colors",
29100
- "aria-label": "Go back",
29101
- children: [
29102
- /* @__PURE__ */ jsx(ArrowLeft, { className: "w-5 h-5" }),
29103
- /* @__PURE__ */ jsx("span", { className: "text-sm font-medium", children: "Back" })
29104
- ]
29227
+ 100% {
29228
+ transform: translateY(0);
29229
+ opacity: 1;
29105
29230
  }
29106
- )
29107
- ] }),
29231
+ }
29232
+ `
29233
+ } }),
29234
+ /* @__PURE__ */ jsxs("div", { className: `flex-1 flex flex-col h-screen transition-all duration-300 ${isSidebarOpen ? "mr-80" : "mr-0"}`, children: [
29235
+ /* @__PURE__ */ jsx("header", { className: "flex-shrink-0 bg-white border-b border-gray-200 sticky top-0 z-10", children: /* @__PURE__ */ jsx("div", { className: "px-6 py-4", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
29236
+ /* @__PURE__ */ jsx("div", { className: "flex items-center gap-4", children: /* @__PURE__ */ jsxs(
29237
+ "button",
29238
+ {
29239
+ onClick: () => navigate("/"),
29240
+ className: "flex items-center gap-2 text-gray-600 hover:text-gray-900 transition-colors",
29241
+ "aria-label": "Go back",
29242
+ children: [
29243
+ /* @__PURE__ */ jsx(ArrowLeft, { className: "w-5 h-5" }),
29244
+ /* @__PURE__ */ jsx("span", { className: "text-sm font-medium", children: "Back" })
29245
+ ]
29246
+ }
29247
+ ) }),
29108
29248
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center", children: [
29109
29249
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
29110
- /* @__PURE__ */ jsx("h1", { className: "text-xl sm:text-2xl md:text-3xl font-bold text-gray-800 tracking-tight leading-none", children: "Axel - AI Manufacturing Expert" }),
29250
+ /* @__PURE__ */ jsx("h1", { className: "text-xl sm:text-2xl md:text-3xl font-bold text-gray-800 tracking-tight leading-none", children: "Chat with Axel" }),
29111
29251
  /* @__PURE__ */ jsx("div", { className: "h-2 w-2 rounded-full bg-blue-500 animate-pulse ring-2 ring-blue-500/30" })
29112
29252
  ] }),
29113
29253
  /* @__PURE__ */ jsx("div", { className: "flex items-center mt-1", children: /* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-gray-500", children: /* @__PURE__ */ jsx(ISTTimer_default, {}) }) })
29114
29254
  ] }),
29115
- /* @__PURE__ */ jsx("div", { className: "w-24" })
29255
+ /* @__PURE__ */ jsx("div", { className: "flex items-center", children: /* @__PURE__ */ jsxs(
29256
+ "button",
29257
+ {
29258
+ onClick: () => setIsSidebarOpen(!isSidebarOpen),
29259
+ className: "relative p-2 hover:bg-gray-100 rounded-lg transition-colors",
29260
+ "aria-label": "Toggle sidebar",
29261
+ children: [
29262
+ isSidebarOpen ? /* @__PURE__ */ jsx(X, { className: "w-5 h-5" }) : /* @__PURE__ */ jsx(Menu, { className: "w-5 h-5" }),
29263
+ !isSidebarOpen && newChatCount > 0 && /* @__PURE__ */ jsx("div", { className: "absolute -top-1 -right-1 bg-red-500 text-white text-xs rounded-full w-5 h-5 flex items-center justify-center font-medium", children: newChatCount })
29264
+ ]
29265
+ }
29266
+ ) })
29116
29267
  ] }) }) }),
29117
29268
  /* @__PURE__ */ jsx(
29118
29269
  "main",
29119
29270
  {
29120
29271
  ref: containerRef,
29121
- className: "flex-1 overflow-y-auto bg-gray-50/50 min-h-0",
29122
- children: /* @__PURE__ */ jsxs("div", { className: "max-w-5xl mx-auto p-4 sm:p-6 md:p-8", children: [
29123
- displayMessages.length === 0 && /* @__PURE__ */ jsx("div", { className: "mb-8 bg-white border border-gray-200/80 shadow-sm rounded-2xl p-6 sm:p-8", children: /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-4", children: [
29124
- /* @__PURE__ */ jsx("div", { className: "w-16 h-16 rounded-xl overflow-hidden shadow-sm flex-shrink-0", children: /* @__PURE__ */ jsx(
29125
- "img",
29272
+ className: `flex-1 bg-gray-50/50 min-h-0 ${displayMessages.length === 0 && !isTransitioning ? "flex items-center justify-center" : "overflow-y-auto"}`,
29273
+ children: displayMessages.length === 0 && !isTransitioning ? (
29274
+ /* Centered welcome and input for new chat */
29275
+ /* @__PURE__ */ jsxs("div", { className: "w-full max-w-3xl mx-auto px-4 sm:px-6 flex flex-col items-center justify-center space-y-12 -mt-16", children: [
29276
+ /* @__PURE__ */ jsxs("div", { className: "text-center", children: [
29277
+ /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center mb-8", children: /* @__PURE__ */ jsx("div", { className: "w-24 h-24 rounded-xl overflow-hidden shadow-sm", children: /* @__PURE__ */ jsx(
29278
+ "img",
29279
+ {
29280
+ src: axelProfilePng,
29281
+ alt: "Axel - AI Manufacturing Expert",
29282
+ className: "w-full h-full object-cover"
29283
+ }
29284
+ ) }) }),
29285
+ /* @__PURE__ */ jsxs("h2", { className: "text-3xl font-semibold text-gray-900", children: [
29286
+ typedText,
29287
+ typedText.length < "Hi, I'm Axel - Your AI Supervisor".length && /* @__PURE__ */ jsx("span", { className: "animate-pulse", children: "|" })
29288
+ ] })
29289
+ ] }),
29290
+ /* @__PURE__ */ jsxs("div", { className: "w-full max-w-2xl", children: [
29291
+ activeThreadId && messages.length > 0 && /* @__PURE__ */ jsx("div", { className: "flex justify-center mb-4", children: /* @__PURE__ */ jsxs(
29292
+ "button",
29293
+ {
29294
+ onClick: handleNewThread,
29295
+ className: "inline-flex items-center gap-2 px-3 py-1.5 text-xs font-medium text-gray-500 hover:text-gray-700 hover:bg-gray-100 rounded-lg transition-colors",
29296
+ children: [
29297
+ /* @__PURE__ */ jsx(RefreshCw, { className: "w-3.5 h-3.5" }),
29298
+ "New conversation"
29299
+ ]
29300
+ }
29301
+ ) }),
29302
+ /* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, children: [
29303
+ /* @__PURE__ */ jsx("div", { className: "relative bg-white rounded-3xl shadow-lg border border-gray-200 focus-within:border-gray-300 transition-all duration-200", children: /* @__PURE__ */ jsx("div", { className: "flex items-end gap-2 p-3", children: /* @__PURE__ */ jsxs("div", { className: "flex-1 relative", children: [
29304
+ /* @__PURE__ */ jsx(
29305
+ "textarea",
29306
+ {
29307
+ ref: textareaRef,
29308
+ value: inputValue,
29309
+ onChange: (e) => setInputValue(e.target.value),
29310
+ onKeyDown: handleKeyDown,
29311
+ placeholder: "Ask me about production optimization, quality metrics, or any manufacturing challenge...",
29312
+ className: "w-full resize-none bg-transparent px-2 py-2 pr-12 focus:outline-none placeholder-gray-500 text-gray-900 text-sm leading-relaxed",
29313
+ rows: 1,
29314
+ style: { minHeight: "24px", maxHeight: "120px" }
29315
+ }
29316
+ ),
29317
+ /* @__PURE__ */ jsx("div", { className: "absolute right-2 bottom-2 flex items-center gap-2", children: /* @__PURE__ */ jsx(
29318
+ "button",
29319
+ {
29320
+ type: "submit",
29321
+ disabled: !inputValue.trim() || isCurrentThreadLoading,
29322
+ className: "inline-flex items-center justify-center w-8 h-8 bg-gray-900 text-white rounded-full hover:bg-gray-800 transition-all duration-200 disabled:opacity-50 disabled:cursor-not-allowed focus:outline-none focus:ring-2 focus:ring-gray-500/20",
29323
+ children: /* @__PURE__ */ jsx(Send, { className: "w-4 h-4" })
29324
+ }
29325
+ ) })
29326
+ ] }) }) }),
29327
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center mt-2 text-xs text-gray-400", children: [
29328
+ /* @__PURE__ */ jsx("span", { children: isCurrentThreadLoading ? "You can type your next message while Axel responds" : "Press Enter to send \u2022 Shift+Enter for new line" }),
29329
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1 ml-4", children: [
29330
+ /* @__PURE__ */ jsx("div", { className: `w-1.5 h-1.5 rounded-full ${isCurrentThreadLoading ? "bg-orange-500" : "bg-green-500"}` }),
29331
+ /* @__PURE__ */ jsx("span", { children: isCurrentThreadLoading ? "Responding..." : "Connected" })
29332
+ ] })
29333
+ ] })
29334
+ ] })
29335
+ ] })
29336
+ ] })
29337
+ ) : isTransitioning ? (
29338
+ /* Transition state - show user message first, then thinking */
29339
+ /* @__PURE__ */ jsx("div", { className: "max-w-4xl mx-auto px-4 sm:px-6 py-6 pb-32", children: /* @__PURE__ */ jsxs("div", { className: "space-y-6", children: [
29340
+ displayMessages.map((message, index) => /* @__PURE__ */ jsxs(
29341
+ "div",
29126
29342
  {
29127
- src: axelProfilePng,
29128
- alt: "Axel - AI Manufacturing Expert",
29129
- className: "w-full h-full object-cover"
29130
- }
29131
- ) }),
29132
- /* @__PURE__ */ jsxs("div", { className: "flex-1 pt-1", children: [
29133
- /* @__PURE__ */ jsx("h2", { className: "text-xl font-semibold text-gray-900 mb-2", children: "Hi, I'm Axel - Your AI Supervisor" }),
29134
- /* @__PURE__ */ jsx("p", { className: "text-gray-600 leading-relaxed", children: "Ask me anything about your shop-floor. I'll remember our conversation and help you optimize your manufacturing processes." })
29343
+ className: `flex gap-4 ${message.role === "user" ? "justify-end" : "justify-start"}`,
29344
+ children: [
29345
+ message.role === "assistant" && /* @__PURE__ */ jsx("div", { className: "flex-shrink-0", children: /* @__PURE__ */ jsx("div", { className: "w-12 h-12 rounded-xl overflow-hidden shadow-sm", children: /* @__PURE__ */ jsx(
29346
+ "img",
29347
+ {
29348
+ src: axelProfilePng,
29349
+ alt: "Axel",
29350
+ className: "w-full h-full object-cover"
29351
+ }
29352
+ ) }) }),
29353
+ /* @__PURE__ */ jsx("div", { className: `max-w-none w-full group ${message.role === "user" ? "order-1" : ""}`, children: /* @__PURE__ */ jsx(
29354
+ "div",
29355
+ {
29356
+ className: `relative px-5 py-4 rounded-2xl shadow-sm ${message.role === "user" ? "bg-blue-600 text-white max-w-[85%] ml-auto" : "bg-white border border-gray-200/80 max-w-full"}`,
29357
+ children: /* @__PURE__ */ jsxs("div", { className: `${message.role === "user" ? "text-white" : "text-gray-800"}`, children: [
29358
+ message.role === "assistant" ? renderAssistantContent(message.content) : /* @__PURE__ */ jsx("div", { className: "whitespace-pre-wrap leading-relaxed", children: message.content }),
29359
+ message.id === -1 && /* @__PURE__ */ jsx("span", { className: "inline-block w-0.5 h-4 bg-gray-400 animate-pulse ml-0.5" })
29360
+ ] })
29361
+ }
29362
+ ) })
29363
+ ]
29364
+ },
29365
+ message.id === -1 ? `streaming-${currentStreaming.message.length}` : `${message.id}-${index}`
29366
+ )),
29367
+ /* @__PURE__ */ jsxs("div", { className: "flex gap-4 justify-start", children: [
29368
+ /* @__PURE__ */ jsx("div", { className: "flex-shrink-0", children: /* @__PURE__ */ jsx("div", { className: "w-12 h-12 rounded-xl overflow-hidden shadow-sm", children: /* @__PURE__ */ jsx(
29369
+ "img",
29370
+ {
29371
+ src: axelProfilePng,
29372
+ alt: "Axel",
29373
+ className: "w-full h-full object-cover"
29374
+ }
29375
+ ) }) }),
29376
+ /* @__PURE__ */ jsx("div", { className: "bg-white border border-gray-200/80 px-5 py-4 rounded-2xl shadow-sm max-w-full", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
29377
+ /* @__PURE__ */ jsxs("div", { className: "flex space-x-1", children: [
29378
+ /* @__PURE__ */ jsx("div", { className: "w-2 h-2 bg-blue-500 rounded-full animate-bounce" }),
29379
+ /* @__PURE__ */ jsx("div", { className: "w-2 h-2 bg-blue-500 rounded-full animate-bounce", style: { animationDelay: "0.1s" } }),
29380
+ /* @__PURE__ */ jsx("div", { className: "w-2 h-2 bg-blue-500 rounded-full animate-bounce", style: { animationDelay: "0.2s" } })
29381
+ ] }),
29382
+ /* @__PURE__ */ jsx("span", { className: "text-gray-600 text-sm", children: "Axel is thinking..." })
29383
+ ] }) })
29135
29384
  ] })
29136
- ] }) }),
29137
- /* @__PURE__ */ jsxs("div", { className: "space-y-6", children: [
29385
+ ] }) })
29386
+ ) : (
29387
+ /* Regular chat view with messages */
29388
+ /* @__PURE__ */ jsx("div", { className: "max-w-4xl mx-auto px-4 sm:px-6 py-6 pb-32", children: /* @__PURE__ */ jsxs("div", { className: "space-y-6", children: [
29138
29389
  displayMessages.map((message, index) => /* @__PURE__ */ jsxs(
29139
29390
  "div",
29140
29391
  {
@@ -29148,22 +29399,14 @@ var AIAgentView = () => {
29148
29399
  className: "w-full h-full object-cover"
29149
29400
  }
29150
29401
  ) }) }),
29151
- /* @__PURE__ */ jsxs("div", { className: `max-w-[75%] group ${message.role === "user" ? "order-1" : ""}`, children: [
29402
+ /* @__PURE__ */ jsxs("div", { className: `max-w-none w-full group ${message.role === "user" ? "order-1" : ""}`, children: [
29152
29403
  /* @__PURE__ */ jsxs(
29153
29404
  "div",
29154
29405
  {
29155
- className: `relative px-5 py-4 rounded-2xl shadow-sm ${message.role === "user" ? "bg-blue-600 text-white" : "bg-white border border-gray-200/80"}`,
29406
+ className: `relative px-5 py-4 rounded-2xl shadow-sm ${message.role === "user" ? "bg-blue-600 text-white max-w-[85%] ml-auto" : "bg-white border border-gray-200/80 max-w-full"}`,
29156
29407
  children: [
29157
29408
  /* @__PURE__ */ jsxs("div", { className: `${message.role === "user" ? "text-white" : "text-gray-800"}`, children: [
29158
- message.role === "assistant" ? /* @__PURE__ */ jsx(
29159
- "div",
29160
- {
29161
- className: "formatted-content",
29162
- dangerouslySetInnerHTML: {
29163
- __html: formatMessage(message.content)
29164
- }
29165
- }
29166
- ) : /* @__PURE__ */ jsx("div", { className: "whitespace-pre-wrap leading-relaxed", children: message.content }),
29409
+ message.role === "assistant" ? renderAssistantContent(message.content) : /* @__PURE__ */ jsx("div", { className: "whitespace-pre-wrap leading-relaxed", children: message.content }),
29167
29410
  message.id === -1 && /* @__PURE__ */ jsx("span", { className: "inline-block w-0.5 h-4 bg-gray-400 animate-pulse ml-0.5" })
29168
29411
  ] }),
29169
29412
  message.role === "assistant" && message.id !== -1 && /* @__PURE__ */ jsx(
@@ -29189,15 +29432,14 @@ var AIAgentView = () => {
29189
29432
  /* @__PURE__ */ jsx("span", { children: "Axel" })
29190
29433
  ] })
29191
29434
  ] })
29192
- ] }),
29193
- message.role === "user" && /* @__PURE__ */ jsx("div", { className: "flex-shrink-0", children: /* @__PURE__ */ jsx("div", { className: "w-10 h-10 bg-gray-700 text-white rounded-xl flex items-center justify-center text-sm font-semibold", children: entityConfig.companyId?.charAt(0).toUpperCase() || "U" }) })
29435
+ ] })
29194
29436
  ]
29195
29437
  },
29196
29438
  message.id === -1 ? `streaming-${currentStreaming.message.length}` : `${message.id}-${index}`
29197
29439
  )),
29198
29440
  lastError && /* @__PURE__ */ jsxs("div", { className: "flex gap-4 justify-start", children: [
29199
29441
  /* @__PURE__ */ jsx("div", { className: "flex-shrink-0", children: /* @__PURE__ */ jsx("div", { className: "w-12 h-12 rounded-xl bg-red-100 flex items-center justify-center", children: /* @__PURE__ */ jsx(AlertCircle, { className: "w-6 h-6 text-red-600" }) }) }),
29200
- /* @__PURE__ */ jsxs("div", { className: "bg-red-50 border border-red-200 px-5 py-4 rounded-2xl shadow-sm max-w-[75%]", children: [
29442
+ /* @__PURE__ */ jsxs("div", { className: "bg-red-50 border border-red-200 px-5 py-4 rounded-2xl shadow-sm max-w-full", children: [
29201
29443
  /* @__PURE__ */ jsx("p", { className: "text-red-800 text-sm", children: lastError }),
29202
29444
  /* @__PURE__ */ jsx(
29203
29445
  "button",
@@ -29218,21 +29460,21 @@ var AIAgentView = () => {
29218
29460
  className: "w-full h-full object-cover"
29219
29461
  }
29220
29462
  ) }) }),
29221
- /* @__PURE__ */ jsx("div", { className: "bg-white border border-gray-200/80 px-5 py-4 rounded-2xl shadow-sm max-w-[75%]", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
29463
+ /* @__PURE__ */ jsx("div", { className: "bg-white border border-gray-200/80 px-5 py-4 rounded-2xl shadow-sm max-w-full", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
29222
29464
  /* @__PURE__ */ jsxs("div", { className: "flex space-x-1", children: [
29223
29465
  /* @__PURE__ */ jsx("div", { className: "w-2 h-2 bg-blue-500 rounded-full animate-bounce" }),
29224
29466
  /* @__PURE__ */ jsx("div", { className: "w-2 h-2 bg-blue-500 rounded-full animate-bounce", style: { animationDelay: "0.1s" } }),
29225
29467
  /* @__PURE__ */ jsx("div", { className: "w-2 h-2 bg-blue-500 rounded-full animate-bounce", style: { animationDelay: "0.2s" } })
29226
29468
  ] }),
29227
- /* @__PURE__ */ jsx("span", { className: "text-gray-600 text-sm", children: "Axel is analyzing your request..." })
29469
+ /* @__PURE__ */ jsx("span", { className: "text-gray-600 text-sm", children: "Axel is thinking..." })
29228
29470
  ] }) })
29229
29471
  ] }),
29230
29472
  /* @__PURE__ */ jsx("div", { ref: messagesEndRef })
29231
- ] })
29232
- ] })
29473
+ ] }) })
29474
+ )
29233
29475
  }
29234
29476
  ),
29235
- /* @__PURE__ */ jsx("footer", { className: "flex-shrink-0 border-t border-gray-200 bg-white sticky bottom-0", children: /* @__PURE__ */ jsxs("div", { className: "max-w-5xl mx-auto p-4 sm:p-6", children: [
29477
+ (displayMessages.length > 0 || isTransitioning) && /* @__PURE__ */ jsx("footer", { className: "fixed bottom-0 left-0 right-0 bg-gradient-to-t from-gray-50/50 to-transparent pointer-events-none", children: /* @__PURE__ */ jsxs("div", { className: "max-w-4xl mx-auto p-4 sm:p-6 pointer-events-auto", children: [
29236
29478
  activeThreadId && messages.length > 0 && /* @__PURE__ */ jsx("div", { className: "flex justify-center mb-4", children: /* @__PURE__ */ jsxs(
29237
29479
  "button",
29238
29480
  {
@@ -29244,48 +29486,59 @@ var AIAgentView = () => {
29244
29486
  ]
29245
29487
  }
29246
29488
  ) }),
29247
- /* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, className: "space-y-3", children: [
29248
- /* @__PURE__ */ jsxs("div", { className: "flex gap-3 items-end", children: [
29249
- /* @__PURE__ */ jsxs("div", { className: "flex-1 relative", children: [
29250
- /* @__PURE__ */ jsx(
29251
- "textarea",
29252
- {
29253
- ref: textareaRef,
29254
- value: inputValue,
29255
- onChange: (e) => setInputValue(e.target.value),
29256
- onKeyDown: handleKeyDown,
29257
- placeholder: "Ask me about production optimization, quality metrics, or any manufacturing challenge...",
29258
- className: "w-full resize-none rounded-xl border border-gray-300 px-4 py-3.5 pr-16 focus:outline-none focus:ring-2 focus:ring-blue-500/20 focus:border-blue-400 bg-white placeholder-gray-500 text-gray-900 text-sm leading-relaxed shadow-sm transition-all duration-200",
29259
- rows: 1,
29260
- disabled: isCurrentThreadLoading,
29261
- style: { minHeight: "48px", maxHeight: "120px" }
29262
- }
29263
- ),
29264
- /* @__PURE__ */ jsx("div", { className: "absolute bottom-3 right-3 flex items-center gap-2", children: inputValue.length > 0 && /* @__PURE__ */ jsx("span", { className: "text-xs text-gray-400 font-mono", children: inputValue.length }) })
29265
- ] }),
29266
- /* @__PURE__ */ jsxs(
29267
- "button",
29268
- {
29269
- type: "submit",
29270
- disabled: !inputValue.trim() || isCurrentThreadLoading,
29271
- className: "inline-flex items-center justify-center gap-2 h-12 px-5 bg-blue-600 text-white rounded-xl hover:bg-blue-700 transition-all duration-200 text-sm font-medium disabled:opacity-50 disabled:cursor-not-allowed focus:outline-none focus:ring-2 focus:ring-blue-500/20 focus:ring-offset-2 shadow-sm hover:shadow-md disabled:hover:shadow-sm",
29272
- children: [
29273
- /* @__PURE__ */ jsx(Send, { className: "w-4 h-4" }),
29274
- /* @__PURE__ */ jsx("span", { className: "hidden sm:inline", children: "Send" })
29275
- ]
29276
- }
29277
- )
29278
- ] }),
29279
- /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between text-xs text-gray-400", children: [
29280
- /* @__PURE__ */ jsx("div", { className: "flex items-center gap-4", children: /* @__PURE__ */ jsx("span", { children: "Press Enter to send \u2022 Shift+Enter for new line" }) }),
29281
- /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
29282
- /* @__PURE__ */ jsx("div", { className: "w-1.5 h-1.5 bg-green-500 rounded-full" }),
29283
- /* @__PURE__ */ jsx("span", { children: "Connected" })
29284
- ] }) })
29489
+ /* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, children: [
29490
+ /* @__PURE__ */ jsx(
29491
+ "div",
29492
+ {
29493
+ className: `relative bg-white rounded-3xl shadow-lg border border-gray-200 focus-within:border-gray-300 transition-all duration-200 ${isTransitioning ? "animate-slide-down" : ""}`,
29494
+ style: isTransitioning ? {
29495
+ animation: "slideDown 0.8s cubic-bezier(0.4, 0, 0.2, 1) forwards"
29496
+ } : {},
29497
+ children: /* @__PURE__ */ jsx("div", { className: "flex items-end gap-2 p-3", children: /* @__PURE__ */ jsxs("div", { className: "flex-1 relative", children: [
29498
+ /* @__PURE__ */ jsx(
29499
+ "textarea",
29500
+ {
29501
+ ref: textareaRef,
29502
+ value: inputValue,
29503
+ onChange: (e) => setInputValue(e.target.value),
29504
+ onKeyDown: handleKeyDown,
29505
+ placeholder: "Ask me about production optimization, quality metrics, or any manufacturing challenge...",
29506
+ className: "w-full resize-none bg-transparent px-2 py-2 pr-12 focus:outline-none placeholder-gray-500 text-gray-900 text-sm leading-relaxed",
29507
+ rows: 1,
29508
+ style: { minHeight: "24px", maxHeight: "120px" }
29509
+ }
29510
+ ),
29511
+ /* @__PURE__ */ jsx("div", { className: "absolute right-2 bottom-2 flex items-center gap-2", children: /* @__PURE__ */ jsx(
29512
+ "button",
29513
+ {
29514
+ type: "submit",
29515
+ disabled: !inputValue.trim() || isCurrentThreadLoading,
29516
+ className: "inline-flex items-center justify-center w-8 h-8 bg-gray-900 text-white rounded-full hover:bg-gray-800 transition-all duration-200 disabled:opacity-50 disabled:cursor-not-allowed focus:outline-none focus:ring-2 focus:ring-gray-500/20",
29517
+ children: /* @__PURE__ */ jsx(Send, { className: "w-4 h-4" })
29518
+ }
29519
+ ) })
29520
+ ] }) })
29521
+ }
29522
+ ),
29523
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center mt-2 text-xs text-gray-400", children: [
29524
+ /* @__PURE__ */ jsx("span", { children: isCurrentThreadLoading ? "You can type your next message while Axel responds" : "Press Enter to send \u2022 Shift+Enter for new line" }),
29525
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1 ml-4", children: [
29526
+ /* @__PURE__ */ jsx("div", { className: `w-1.5 h-1.5 rounded-full ${isCurrentThreadLoading ? "bg-orange-500" : "bg-green-500"}` }),
29527
+ /* @__PURE__ */ jsx("span", { children: isCurrentThreadLoading ? "Responding..." : "Connected" })
29528
+ ] })
29285
29529
  ] })
29286
29530
  ] })
29287
29531
  ] }) })
29288
- ] })
29532
+ ] }),
29533
+ /* @__PURE__ */ jsx("div", { className: `${isSidebarOpen ? "w-80" : "w-0"} transition-all duration-300 overflow-hidden flex-shrink-0 border-l border-gray-200 h-screen fixed right-0 top-0 z-20`, children: /* @__PURE__ */ jsx(
29534
+ ThreadSidebar,
29535
+ {
29536
+ activeThreadId,
29537
+ onSelectThread: setActiveThreadId,
29538
+ onNewThread: handleNewThread,
29539
+ className: "h-full"
29540
+ }
29541
+ ) })
29289
29542
  ] });
29290
29543
  };
29291
29544
  var AIAgentView_default = AIAgentView;