@chatwidgetai/chat-widget 0.1.6 → 0.1.8

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/index.js CHANGED
@@ -261,8 +261,10 @@ function generateMessageId() {
261
261
  /**
262
262
  * Local Storage Utilities
263
263
  * Handles conversation persistence in browser localStorage
264
+ * Supports multiple conversations per widget with history
264
265
  */
265
266
  const STORAGE_PREFIX = 'ai-chat-widget';
267
+ const MAX_STORED_CONVERSATIONS = 20;
266
268
  /**
267
269
  * Generate a storage key for a widget
268
270
  */
@@ -270,33 +272,113 @@ function getStorageKey(widgetId) {
270
272
  return `${STORAGE_PREFIX}:${widgetId}`;
271
273
  }
272
274
  /**
273
- * Save conversation to localStorage
275
+ * Get widget storage data
274
276
  */
275
- function saveConversation(widgetId, conversationId, messages) {
277
+ function getWidgetStorage(widgetId) {
276
278
  try {
277
279
  const key = getStorageKey(widgetId);
278
- const data = {
280
+ const data = localStorage.getItem(key);
281
+ if (!data) {
282
+ return { activeConversationId: null, conversations: {}, history: [] };
283
+ }
284
+ const parsed = JSON.parse(data);
285
+ // Handle legacy format (single conversation)
286
+ if (parsed.conversationId && parsed.messages) {
287
+ const legacy = parsed;
288
+ return {
289
+ activeConversationId: legacy.conversationId,
290
+ conversations: { [legacy.conversationId]: legacy },
291
+ history: [{
292
+ id: legacy.conversationId,
293
+ preview: getConversationPreview(legacy.messages),
294
+ lastUpdated: legacy.lastUpdated,
295
+ messageCount: legacy.messages.length,
296
+ }],
297
+ };
298
+ }
299
+ return parsed;
300
+ }
301
+ catch (error) {
302
+ console.error('Failed to get widget storage:', error);
303
+ return { activeConversationId: null, conversations: {}, history: [] };
304
+ }
305
+ }
306
+ /**
307
+ * Save widget storage data
308
+ */
309
+ function setWidgetStorage(widgetId, storage) {
310
+ try {
311
+ const key = getStorageKey(widgetId);
312
+ localStorage.setItem(key, JSON.stringify(storage));
313
+ }
314
+ catch (error) {
315
+ console.error('Failed to save widget storage:', error);
316
+ }
317
+ }
318
+ /**
319
+ * Get preview text from messages
320
+ */
321
+ function getConversationPreview(messages) {
322
+ const firstUserMessage = messages.find(m => m.message.type === 'human');
323
+ if (firstUserMessage) {
324
+ return firstUserMessage.message.content.slice(0, 100);
325
+ }
326
+ return 'New conversation';
327
+ }
328
+ /**
329
+ * Save conversation to localStorage (updates both conversation and history)
330
+ */
331
+ function saveConversation(widgetId, conversationId, messages) {
332
+ try {
333
+ const storage = getWidgetStorage(widgetId);
334
+ const now = new Date().toISOString();
335
+ // Update conversation data
336
+ storage.conversations[conversationId] = {
279
337
  conversationId,
280
338
  messages,
281
- lastUpdated: new Date().toISOString(),
339
+ lastUpdated: now,
340
+ };
341
+ // Update active conversation
342
+ storage.activeConversationId = conversationId;
343
+ // Update history entry
344
+ const existingIndex = storage.history.findIndex(h => h.id === conversationId);
345
+ const historyEntry = {
346
+ id: conversationId,
347
+ preview: getConversationPreview(messages),
348
+ lastUpdated: now,
349
+ messageCount: messages.length,
282
350
  };
283
- localStorage.setItem(key, JSON.stringify(data));
351
+ if (existingIndex >= 0) {
352
+ storage.history[existingIndex] = historyEntry;
353
+ }
354
+ else {
355
+ storage.history.unshift(historyEntry);
356
+ }
357
+ // Sort by lastUpdated (most recent first)
358
+ storage.history.sort((a, b) => new Date(b.lastUpdated).getTime() - new Date(a.lastUpdated).getTime());
359
+ // Limit stored conversations
360
+ if (storage.history.length > MAX_STORED_CONVERSATIONS) {
361
+ const toRemove = storage.history.slice(MAX_STORED_CONVERSATIONS);
362
+ storage.history = storage.history.slice(0, MAX_STORED_CONVERSATIONS);
363
+ toRemove.forEach(entry => {
364
+ delete storage.conversations[entry.id];
365
+ });
366
+ }
367
+ setWidgetStorage(widgetId, storage);
284
368
  }
285
369
  catch (error) {
286
370
  console.error('Failed to save conversation:', error);
287
371
  }
288
372
  }
289
373
  /**
290
- * Load conversation from localStorage
374
+ * Load active conversation from localStorage (legacy compatibility)
291
375
  */
292
376
  function loadConversation(widgetId) {
293
377
  try {
294
- const key = getStorageKey(widgetId);
295
- const data = localStorage.getItem(key);
296
- if (!data)
378
+ const storage = getWidgetStorage(widgetId);
379
+ if (!storage.activeConversationId)
297
380
  return null;
298
- const parsed = JSON.parse(data);
299
- return parsed;
381
+ return storage.conversations[storage.activeConversationId] || null;
300
382
  }
301
383
  catch (error) {
302
384
  console.error('Failed to load conversation:', error);
@@ -304,12 +386,52 @@ function loadConversation(widgetId) {
304
386
  }
305
387
  }
306
388
  /**
307
- * Clear conversation from localStorage
389
+ * Load a specific conversation by ID
390
+ */
391
+ function loadConversationById(widgetId, conversationId) {
392
+ try {
393
+ const storage = getWidgetStorage(widgetId);
394
+ return storage.conversations[conversationId] || null;
395
+ }
396
+ catch (error) {
397
+ console.error('Failed to load conversation by ID:', error);
398
+ return null;
399
+ }
400
+ }
401
+ /**
402
+ * Get conversation history list
403
+ */
404
+ function getConversationHistory(widgetId) {
405
+ try {
406
+ const storage = getWidgetStorage(widgetId);
407
+ return storage.history;
408
+ }
409
+ catch (error) {
410
+ console.error('Failed to get conversation history:', error);
411
+ return [];
412
+ }
413
+ }
414
+ /**
415
+ * Set active conversation
416
+ */
417
+ function setActiveConversation(widgetId, conversationId) {
418
+ try {
419
+ const storage = getWidgetStorage(widgetId);
420
+ storage.activeConversationId = conversationId;
421
+ setWidgetStorage(widgetId, storage);
422
+ }
423
+ catch (error) {
424
+ console.error('Failed to set active conversation:', error);
425
+ }
426
+ }
427
+ /**
428
+ * Clear current conversation (start fresh, but keep history)
308
429
  */
309
430
  function clearConversation(widgetId) {
310
431
  try {
311
- const key = getStorageKey(widgetId);
312
- localStorage.removeItem(key);
432
+ const storage = getWidgetStorage(widgetId);
433
+ storage.activeConversationId = null;
434
+ setWidgetStorage(widgetId, storage);
313
435
  }
314
436
  catch (error) {
315
437
  console.error('Failed to clear conversation:', error);
@@ -406,6 +528,8 @@ function useChat(options) {
406
528
  conversationId: '', // Will be set after loading conversation
407
529
  config: null,
408
530
  });
531
+ // Chat history state
532
+ const [conversations, setConversations] = react.useState([]);
409
533
  const apiClient = react.useRef(new WidgetApiClient({ widgetId, apiUrl }));
410
534
  // Load configuration on mount and hydrate with existing conversation if available
411
535
  react.useEffect(() => {
@@ -417,8 +541,6 @@ function useChat(options) {
417
541
  const config = await apiClient.current.getConfig();
418
542
  console.log('[useChat] Config fetched successfully:', {
419
543
  hasAppearance: !!config.appearance,
420
- hasLightMode: !!config.appearance?.lightMode,
421
- hasDarkMode: !!config.appearance?.darkMode,
422
544
  });
423
545
  const persistConversation = config.behavior.persistConversation ?? true;
424
546
  let conversationId = '';
@@ -693,6 +815,78 @@ function useChat(options) {
693
815
  onError?.(err);
694
816
  }
695
817
  }, [state.conversationId, onError]);
818
+ /**
819
+ * Load conversation history list from localStorage
820
+ */
821
+ const loadConversations = react.useCallback(() => {
822
+ const persistConversation = state.config?.behavior.persistConversation ?? true;
823
+ if (!persistConversation || !isStorageAvailable()) {
824
+ setConversations([]);
825
+ return;
826
+ }
827
+ const history = getConversationHistory(widgetId);
828
+ setConversations(history.map(entry => ({
829
+ id: entry.id,
830
+ preview: entry.preview,
831
+ lastMessageAt: entry.lastUpdated,
832
+ messageCount: entry.messageCount,
833
+ startedAt: entry.lastUpdated,
834
+ })));
835
+ }, [widgetId, state.config?.behavior.persistConversation]);
836
+ /**
837
+ * Switch to a different conversation (from localStorage first, then fetch from server if needed)
838
+ */
839
+ const switchConversation = react.useCallback(async (conversationId) => {
840
+ const persistConversation = state.config?.behavior.persistConversation ?? true;
841
+ // First try to load from localStorage
842
+ if (persistConversation && isStorageAvailable()) {
843
+ const stored = loadConversationById(widgetId, conversationId);
844
+ if (stored) {
845
+ setState(prev => ({
846
+ ...prev,
847
+ conversationId: stored.conversationId,
848
+ messages: stored.messages,
849
+ }));
850
+ setActiveConversation(widgetId, conversationId);
851
+ return;
852
+ }
853
+ }
854
+ // If not in localStorage, fetch from server
855
+ setState(prev => ({ ...prev, isLoading: true, error: null }));
856
+ try {
857
+ const conversation = await apiClient.current.getOrCreateConversation(conversationId);
858
+ setState(prev => ({
859
+ ...prev,
860
+ conversationId: conversation.id,
861
+ messages: conversation.messages,
862
+ isLoading: false,
863
+ }));
864
+ // Save to local storage
865
+ if (persistConversation && isStorageAvailable()) {
866
+ saveConversation(widgetId, conversation.id, conversation.messages);
867
+ }
868
+ }
869
+ catch (error) {
870
+ const errorInfo = deriveErrorInfo(error);
871
+ setState(prev => ({ ...prev, isLoading: false, error: errorInfo.message }));
872
+ }
873
+ }, [widgetId, state.config?.behavior.persistConversation]);
874
+ /**
875
+ * Start a new conversation (keeps history)
876
+ */
877
+ const startNewConversation = react.useCallback(() => {
878
+ setState(prev => ({
879
+ ...prev,
880
+ messages: [],
881
+ conversationId: '',
882
+ error: null,
883
+ }));
884
+ // Clear active conversation but keep history
885
+ const persistConversation = state.config?.behavior.persistConversation ?? true;
886
+ if (persistConversation && isStorageAvailable()) {
887
+ clearConversation(widgetId);
888
+ }
889
+ }, [widgetId, state.config?.behavior.persistConversation]);
696
890
  return {
697
891
  messages: state.messages,
698
892
  isLoading: state.isLoading,
@@ -703,6 +897,11 @@ function useChat(options) {
703
897
  sendMessage,
704
898
  clearMessages,
705
899
  submitFeedback,
900
+ // Chat history features
901
+ conversations,
902
+ loadConversations,
903
+ switchConversation,
904
+ startNewConversation,
706
905
  };
707
906
  }
708
907
 
@@ -21574,26 +21773,53 @@ const SuggestedQuestions = ({ questions, onQuestionClick, }) => {
21574
21773
  };
21575
21774
 
21576
21775
  const MinimizeIcon = () => (jsxRuntime.jsx("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: jsxRuntime.jsx("path", { d: "M5 12h14" }) }));
21577
- const ChatWindow = ({ messages, isLoading, isTyping, error, config, onSendMessage, onClose, onFeedback, }) => {
21776
+ const HistoryIcon = () => (jsxRuntime.jsxs("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [jsxRuntime.jsx("circle", { cx: "12", cy: "12", r: "10" }), jsxRuntime.jsx("polyline", { points: "12 6 12 12 16 14" })] }));
21777
+ const NewChatIcon = () => (jsxRuntime.jsx("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: jsxRuntime.jsx("path", { d: "M12 5v14M5 12h14" }) }));
21778
+ const BackIcon = () => (jsxRuntime.jsx("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: jsxRuntime.jsx("path", { d: "M19 12H5M12 19l-7-7 7-7" }) }));
21779
+ const ChatWindow = ({ messages, isLoading, isTyping, error, config, onSendMessage, onClose, onFeedback,
21780
+ // Chat history props (only active when persistConversation is true)
21781
+ conversations = [], onLoadConversations, onSwitchConversation, onStartNewConversation, currentConversationId, }) => {
21578
21782
  console.log('[ChatWindow] Rendering ChatWindow component');
21579
21783
  const appearance = config?.appearance;
21580
21784
  const behavior = config?.behavior;
21785
+ // Use simplified appearance fields
21581
21786
  const size = appearance?.size || 'medium';
21582
- console.log('[ChatWindow] Size:', size, 'Appearance:', !!appearance);
21583
- // Determine current theme config
21584
- const themePreference = appearance?.theme ?? 'light';
21585
- const canUseDarkMode = appearance?.darkModeEnabled !== false;
21586
- const prefersDark = typeof window !== 'undefined' && window.matchMedia('(prefers-color-scheme: dark)').matches;
21587
- const isDarkMode = themePreference === 'auto'
21588
- ? (canUseDarkMode && prefersDark)
21589
- : themePreference === 'dark' && canUseDarkMode;
21590
- const themeConfig = (isDarkMode ? appearance?.darkMode : appearance?.lightMode) ?? (appearance?.lightMode || appearance?.darkMode);
21591
- const headerTitle = themeConfig?.header?.title ?? appearance?.header?.title ?? appearance?.companyName ?? 'AI Assistant';
21592
- const welcomeTitle = themeConfig?.chat?.welcomeTitle ?? 'Welcome!';
21593
- const welcomeMessage = themeConfig?.chat?.welcomeMessage ?? appearance?.welcomeMessage ?? '👋 Hi there! How can I assist you today?';
21594
- const inputPlaceholder = themeConfig?.footer?.inputPlaceholder ?? appearance?.placeholder ?? 'Ask me anything...';
21787
+ const headerTitle = appearance?.headerTitle || 'AI Assistant';
21788
+ const welcomeMessage = appearance?.welcomeMessage || '👋 Hi there! How can I assist you today?';
21789
+ const inputPlaceholder = appearance?.placeholder || 'Ask me anything...';
21790
+ console.log('[ChatWindow] Appearance values:', {
21791
+ size,
21792
+ headerTitle,
21793
+ welcomeMessage,
21794
+ inputPlaceholder,
21795
+ });
21595
21796
  // Track if suggested questions should be shown
21596
21797
  const [showSuggestedQuestions, setShowSuggestedQuestions] = react.useState(true);
21798
+ // Track if history panel is open
21799
+ const [showHistory, setShowHistory] = react.useState(false);
21800
+ // Check if chat history feature is enabled (only when persistConversation is true)
21801
+ const isHistoryEnabled = behavior?.persistConversation !== false && !!onLoadConversations;
21802
+ // Load conversations when history panel opens
21803
+ const handleOpenHistory = () => {
21804
+ setShowHistory(true);
21805
+ if (onLoadConversations) {
21806
+ onLoadConversations();
21807
+ }
21808
+ };
21809
+ // Handle conversation selection
21810
+ const handleSelectConversation = async (conversationId) => {
21811
+ if (onSwitchConversation) {
21812
+ await onSwitchConversation(conversationId);
21813
+ setShowHistory(false);
21814
+ }
21815
+ };
21816
+ // Handle new conversation
21817
+ const handleNewConversation = () => {
21818
+ if (onStartNewConversation) {
21819
+ onStartNewConversation();
21820
+ setShowHistory(false);
21821
+ }
21822
+ };
21597
21823
  // Hide suggested questions after first user message
21598
21824
  react.useEffect(() => {
21599
21825
  const userMessages = messages.filter(m => m.message.type === 'human');
@@ -21611,241 +21837,39 @@ const ChatWindow = ({ messages, isLoading, isTyping, error, config, onSendMessag
21611
21837
  onSendMessage(question);
21612
21838
  };
21613
21839
  const hasMessages = messages.length > 0;
21614
- return (jsxRuntime.jsxs("div", { className: `ai-chat-window size-${size}`, role: "dialog", "aria-label": "Chat window", children: [jsxRuntime.jsxs("div", { className: "ai-chat-header", children: [jsxRuntime.jsxs("div", { className: "ai-chat-header-content", children: [appearance?.logo && (jsxRuntime.jsx("img", { src: appearance.logo, alt: "Logo", className: "ai-chat-logo" })), jsxRuntime.jsx("div", { className: "ai-chat-title", children: headerTitle })] }), jsxRuntime.jsx("button", { className: "ai-chat-close-button", onClick: onClose, "aria-label": "Minimize chat", children: jsxRuntime.jsx(MinimizeIcon, {}) })] }), error && (jsxRuntime.jsx("div", { className: "ai-chat-error", role: "alert", children: error })), maxMessages && userMessageCount >= maxMessages - 2 && !isLimitReached && (jsxRuntime.jsxs("div", { className: "ai-chat-warning", role: "alert", children: [maxMessages - userMessageCount, " message", maxMessages - userMessageCount !== 1 ? 's' : '', " remaining"] })), isLimitReached && (jsxRuntime.jsx("div", { className: "ai-chat-error", role: "alert", children: "Message limit reached. Please start a new conversation." })), jsxRuntime.jsx(MessageList, { messages: messages, isTyping: isTyping, showTypingIndicator: behavior?.showTypingIndicator, showTimestamps: behavior?.showTimestamps, enableFeedback: behavior?.enableFeedback, showSources: behavior?.showSources, sourceDisplayMode: behavior?.sourceDisplayMode, welcomeTitle: welcomeTitle, welcomeMessage: welcomeMessage, onFeedback: onFeedback }), showSuggestedQuestions && !hasMessages && behavior?.suggestedQuestions && behavior.suggestedQuestions.length > 0 && (jsxRuntime.jsx(SuggestedQuestions, { questions: behavior.suggestedQuestions, onQuestionClick: handleQuestionClick })), jsxRuntime.jsx(MessageInput, { onSend: onSendMessage, placeholder: isLimitReached ? 'Message limit reached' : inputPlaceholder, disabled: isLoading || isLimitReached, enableFileUpload: behavior?.enableFileUpload, separateFromChat: themeConfig?.footer?.separateFromChat })] }));
21840
+ // Format date for conversation list
21841
+ const formatDate = (dateString) => {
21842
+ const date = new Date(dateString);
21843
+ const now = new Date();
21844
+ const diffMs = now.getTime() - date.getTime();
21845
+ const diffDays = Math.floor(diffMs / (1000 * 60 * 60 * 24));
21846
+ if (diffDays === 0)
21847
+ return 'Today';
21848
+ if (diffDays === 1)
21849
+ return 'Yesterday';
21850
+ if (diffDays < 7)
21851
+ return `${diffDays} days ago`;
21852
+ return date.toLocaleDateString();
21853
+ };
21854
+ return (jsxRuntime.jsxs("div", { className: `ai-chat-window size-${size}`, role: "dialog", "aria-label": "Chat window", children: [jsxRuntime.jsx("div", { className: "ai-chat-header", children: showHistory ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("button", { className: "ai-chat-header-button", onClick: () => setShowHistory(false), "aria-label": "Back to chat", children: jsxRuntime.jsx(BackIcon, {}) }), jsxRuntime.jsx("div", { className: "ai-chat-title", children: "Chat History" }), jsxRuntime.jsx("button", { className: "ai-chat-header-button", onClick: handleNewConversation, "aria-label": "New conversation", children: jsxRuntime.jsx(NewChatIcon, {}) })] })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", { className: "ai-chat-header-content", children: [appearance?.logo && (jsxRuntime.jsx("img", { src: appearance.logo, alt: "Logo", className: "ai-chat-logo" })), jsxRuntime.jsx("div", { className: "ai-chat-title", children: headerTitle })] }), jsxRuntime.jsxs("div", { className: "ai-chat-header-actions", children: [isHistoryEnabled && (jsxRuntime.jsx("button", { className: "ai-chat-header-button", onClick: handleOpenHistory, "aria-label": "Chat history", children: jsxRuntime.jsx(HistoryIcon, {}) })), jsxRuntime.jsx("button", { className: "ai-chat-close-button", onClick: onClose, "aria-label": "Minimize chat", children: jsxRuntime.jsx(MinimizeIcon, {}) })] })] })) }), showHistory ? (jsxRuntime.jsx("div", { className: "ai-chat-history-panel", children: conversations.length === 0 ? (jsxRuntime.jsx("div", { className: "ai-chat-history-empty", children: "No previous conversations" })) : (jsxRuntime.jsx("div", { className: "ai-chat-history-list", children: conversations.map((conv) => (jsxRuntime.jsxs("button", { className: `ai-chat-history-item ${conv.id === currentConversationId ? 'active' : ''}`, onClick: () => handleSelectConversation(conv.id), children: [jsxRuntime.jsx("div", { className: "ai-chat-history-item-preview", children: conv.preview }), jsxRuntime.jsxs("div", { className: "ai-chat-history-item-meta", children: [jsxRuntime.jsx("span", { children: formatDate(conv.lastMessageAt) }), jsxRuntime.jsxs("span", { children: [conv.messageCount, " messages"] })] })] }, conv.id))) })) })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [error && (jsxRuntime.jsx("div", { className: "ai-chat-error", role: "alert", children: error })), maxMessages && userMessageCount >= maxMessages - 2 && !isLimitReached && (jsxRuntime.jsxs("div", { className: "ai-chat-warning", role: "alert", children: [maxMessages - userMessageCount, " message", maxMessages - userMessageCount !== 1 ? 's' : '', " remaining"] })), isLimitReached && (jsxRuntime.jsx("div", { className: "ai-chat-error", role: "alert", children: "Message limit reached. Please start a new conversation." })), jsxRuntime.jsx(MessageList, { messages: messages, isTyping: isTyping, showTypingIndicator: behavior?.showTypingIndicator, showTimestamps: behavior?.showTimestamps, enableFeedback: behavior?.enableFeedback, showSources: behavior?.showSources, sourceDisplayMode: behavior?.sourceDisplayMode, welcomeMessage: welcomeMessage, onFeedback: onFeedback }), showSuggestedQuestions && !hasMessages && behavior?.suggestedQuestions && behavior.suggestedQuestions.length > 0 && (jsxRuntime.jsx(SuggestedQuestions, { questions: behavior.suggestedQuestions, onQuestionClick: handleQuestionClick })), jsxRuntime.jsx(MessageInput, { onSend: onSendMessage, placeholder: isLimitReached ? 'Message limit reached' : inputPlaceholder, disabled: isLoading || isLimitReached, enableFileUpload: behavior?.enableFileUpload })] }))] }));
21615
21855
  };
21616
21856
 
21617
- /**
21618
- * Convert shadow size to CSS box-shadow value
21619
- */
21620
- function getShadowValue(size) {
21621
- const shadows = {
21622
- 'none': 'none',
21623
- 'sm': '0 1px 2px 0 rgba(0, 0, 0, 0.05)',
21624
- 'md': '0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)',
21625
- 'lg': '0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)',
21626
- 'xl': '0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04)',
21627
- '2xl': '0 25px 50px -12px rgba(0, 0, 0, 0.25)',
21628
- };
21629
- return shadows[size] || shadows.none;
21630
- }
21631
21857
  /**
21632
21858
  * Apply appearance configuration as CSS custom properties
21633
- * This allows the widget to be fully customizable via the appearance config
21859
+ * Simplified to only handle flat appearance schema
21634
21860
  *
21635
21861
  * @param appearance - Widget appearance configuration
21636
- * @param theme - Current theme ('light' or 'dark')
21862
+ * @param theme - Current theme ('light' or 'dark') - kept for compatibility but not used for theme selection
21637
21863
  */
21638
- function applyAppearanceStyles(appearance, theme = 'light') {
21864
+ function applyAppearanceStyles(appearance) {
21639
21865
  const styles = {};
21640
- // Global font family
21641
- if (appearance.fontFamily) {
21642
- styles.fontFamily = appearance.fontFamily;
21643
- }
21644
- // Select the correct theme configuration
21645
- const themeConfig = theme === 'dark' ? appearance.darkMode : appearance.lightMode;
21646
- // If theme config exists and has required properties, use it
21647
- if (themeConfig && themeConfig.button) {
21648
- // ========================================================================
21649
- // BUTTON APPEARANCE
21650
- // ========================================================================
21651
- const btn = themeConfig.button;
21652
- if (btn.color)
21653
- styles['--button-color'] = btn.color;
21654
- if (btn.opacity !== undefined)
21655
- styles['--button-opacity'] = btn.opacity.toString();
21656
- if (btn.size)
21657
- styles['--button-size'] = `${btn.size}px`;
21658
- if (btn.icon)
21659
- styles['--button-icon'] = btn.icon;
21660
- if (btn.iconColor)
21661
- styles['--button-icon-color'] = btn.iconColor;
21662
- if (btn.borderRadius !== undefined)
21663
- styles['--button-border-radius'] = `${btn.borderRadius}px`;
21664
- if (btn.borderWidth !== undefined)
21665
- styles['--button-border-width'] = `${btn.borderWidth}px`;
21666
- if (btn.borderColor)
21667
- styles['--button-border-color'] = btn.borderColor;
21668
- if (btn.borderOpacity !== undefined)
21669
- styles['--button-border-opacity'] = btn.borderOpacity.toString();
21670
- if (btn.backdropBlur !== undefined)
21671
- styles['--button-backdrop-blur'] = `${btn.backdropBlur}px`;
21672
- if (btn.shadow)
21673
- styles['--button-shadow'] = getShadowValue(btn.shadow);
21674
- // ========================================================================
21675
- // CARD/WINDOW APPEARANCE
21676
- // ========================================================================
21677
- const card = themeConfig.card;
21678
- if (card.backgroundColor)
21679
- styles['--card-background'] = card.backgroundColor;
21680
- if (card.opacity !== undefined)
21681
- styles['--card-opacity'] = card.opacity.toString();
21682
- if (card.borderRadius !== undefined)
21683
- styles['--card-border-radius'] = `${card.borderRadius}px`;
21684
- if (card.borderWidth !== undefined)
21685
- styles['--card-border-width'] = `${card.borderWidth}px`;
21686
- if (card.borderColor) {
21687
- styles['--card-border-color'] = card.borderColor;
21688
- // Create rgba border color with opacity for box-shadow
21689
- if (card.borderOpacity !== undefined) {
21690
- const opacity = card.borderOpacity;
21691
- // Convert hex to rgba
21692
- const hex = card.borderColor.replace('#', '');
21693
- const r = parseInt(hex.substring(0, 2), 16);
21694
- const g = parseInt(hex.substring(2, 4), 16);
21695
- const b = parseInt(hex.substring(4, 6), 16);
21696
- styles['--card-border-color-rgba'] = `rgba(${r}, ${g}, ${b}, ${opacity})`;
21697
- }
21698
- }
21699
- if (card.borderOpacity !== undefined)
21700
- styles['--card-border-opacity'] = card.borderOpacity.toString();
21701
- if (card.backdropBlur !== undefined)
21702
- styles['--card-backdrop-blur'] = `${card.backdropBlur}px`;
21703
- if (card.shadow)
21704
- styles['--card-shadow'] = getShadowValue(card.shadow);
21705
- // ========================================================================
21706
- // HEADER APPEARANCE
21707
- // ========================================================================
21708
- const header = themeConfig.header;
21709
- if (header.backgroundColor)
21710
- styles['--header-background'] = header.backgroundColor;
21711
- if (header.opacity !== undefined)
21712
- styles['--header-opacity'] = header.opacity.toString();
21713
- if (header.textColor)
21714
- styles['--header-text-color'] = header.textColor;
21715
- if (header.borderBottomWidth !== undefined)
21716
- styles['--header-border-bottom-width'] = `${header.borderBottomWidth}px`;
21717
- if (header.borderBottomColor)
21718
- styles['--header-border-bottom-color'] = header.borderBottomColor;
21719
- if (header.borderBottomOpacity !== undefined)
21720
- styles['--header-border-bottom-opacity'] = header.borderBottomOpacity.toString();
21721
- // ========================================================================
21722
- // CHAT APPEARANCE
21723
- // ========================================================================
21724
- const chat = themeConfig.chat;
21725
- if (chat.backgroundColor)
21726
- styles['--chat-background'] = chat.backgroundColor;
21727
- if (chat.opacity !== undefined)
21728
- styles['--chat-opacity'] = chat.opacity.toString();
21729
- // Welcome message
21730
- if (chat.welcomeColor)
21731
- styles['--welcome-color'] = chat.welcomeColor;
21732
- // Message bubbles
21733
- if (chat.enableBubbles) {
21734
- if (chat.bubbleUserColor)
21735
- styles['--bubble-user-color'] = chat.bubbleUserColor;
21736
- if (chat.bubbleUserOpacity !== undefined)
21737
- styles['--bubble-user-opacity'] = chat.bubbleUserOpacity.toString();
21738
- if (chat.bubbleAssistantColor)
21739
- styles['--bubble-assistant-color'] = chat.bubbleAssistantColor;
21740
- if (chat.bubbleAssistantOpacity !== undefined)
21741
- styles['--bubble-assistant-opacity'] = chat.bubbleAssistantOpacity.toString();
21742
- if (chat.bubbleBorderWidth !== undefined)
21743
- styles['--bubble-border-width'] = `${chat.bubbleBorderWidth}px`;
21744
- if (chat.bubbleBorderColor)
21745
- styles['--bubble-border-color'] = chat.bubbleBorderColor;
21746
- if (chat.bubbleBorderOpacity !== undefined)
21747
- styles['--bubble-border-opacity'] = chat.bubbleBorderOpacity.toString();
21748
- }
21749
- else {
21750
- // Plain text mode
21751
- if (chat.textColor)
21752
- styles['--message-text-color'] = chat.textColor;
21753
- }
21754
- // ========================================================================
21755
- // FOOTER APPEARANCE
21756
- // ========================================================================
21757
- const footer = themeConfig.footer;
21758
- // Only if separate from chat
21759
- if (footer.separateFromChat) {
21760
- if (footer.backgroundColor)
21761
- styles['--footer-background'] = footer.backgroundColor;
21762
- if (footer.opacity !== undefined)
21763
- styles['--footer-opacity'] = footer.opacity.toString();
21764
- if (footer.borderTopWidth !== undefined)
21765
- styles['--footer-border-top-width'] = `${footer.borderTopWidth}px`;
21766
- if (footer.borderTopColor)
21767
- styles['--footer-border-top-color'] = footer.borderTopColor;
21768
- if (footer.borderTopOpacity !== undefined)
21769
- styles['--footer-border-top-opacity'] = footer.borderTopOpacity.toString();
21770
- }
21771
- // Backdrop blur (only when floating)
21772
- if (!footer.separateFromChat && footer.backdropBlur !== undefined) {
21773
- styles['--footer-backdrop-blur'] = `${footer.backdropBlur}px`;
21774
- }
21775
- // Input field
21776
- if (footer.inputBackgroundColor)
21777
- styles['--input-background'] = footer.inputBackgroundColor;
21778
- if (footer.inputBackgroundOpacity !== undefined)
21779
- styles['--input-background-opacity'] = footer.inputBackgroundOpacity.toString();
21780
- if (footer.inputBorderRadius !== undefined)
21781
- styles['--input-border-radius'] = `${footer.inputBorderRadius}px`;
21782
- if (footer.inputBorderWidth !== undefined)
21783
- styles['--input-border-width'] = `${footer.inputBorderWidth}px`;
21784
- if (footer.inputBorderColor)
21785
- styles['--input-border-color'] = footer.inputBorderColor;
21786
- if (footer.inputBorderOpacity !== undefined)
21787
- styles['--input-border-opacity'] = footer.inputBorderOpacity.toString();
21788
- if (footer.inputShadow)
21789
- styles['--input-shadow'] = getShadowValue(footer.inputShadow);
21790
- // Send button
21791
- if (footer.buttonBackgroundColor)
21792
- styles['--send-button-background'] = footer.buttonBackgroundColor;
21793
- if (footer.buttonOpacity !== undefined)
21794
- styles['--send-button-opacity'] = footer.buttonOpacity.toString();
21795
- if (footer.buttonBorderRadius !== undefined)
21796
- styles['--send-button-border-radius'] = `${footer.buttonBorderRadius}px`;
21797
- if (footer.buttonBorderWidth !== undefined)
21798
- styles['--send-button-border-width'] = `${footer.buttonBorderWidth}px`;
21799
- if (footer.buttonBorderColor)
21800
- styles['--send-button-border-color'] = footer.buttonBorderColor;
21801
- if (footer.buttonBorderOpacity !== undefined)
21802
- styles['--send-button-border-opacity'] = footer.buttonBorderOpacity.toString();
21803
- // ========================================================================
21804
- // HOVER STATES
21805
- // ========================================================================
21806
- const hover = themeConfig.hover;
21807
- if (hover.buttonScale !== undefined)
21808
- styles['--hover-button-scale'] = hover.buttonScale.toString();
21809
- if (hover.buttonOpacity !== undefined)
21810
- styles['--hover-button-opacity'] = hover.buttonOpacity.toString();
21811
- if (hover.inputBorderColor)
21812
- styles['--hover-input-border-color'] = hover.inputBorderColor;
21813
- if (hover.sendButtonOpacity !== undefined)
21814
- styles['--hover-send-button-opacity'] = hover.sendButtonOpacity.toString();
21815
- if (hover.closeButtonOpacity !== undefined)
21816
- styles['--hover-close-button-opacity'] = hover.closeButtonOpacity.toString();
21817
- // ========================================================================
21818
- // ACTIVE STATES
21819
- // ========================================================================
21820
- const active = themeConfig.active;
21821
- if (active.inputBorderColor)
21822
- styles['--active-input-border-color'] = active.inputBorderColor;
21823
- if (active.inputShadow)
21824
- styles['--active-input-shadow'] = active.inputShadow;
21825
- }
21826
- else {
21827
- // Fallback to legacy fields if no theme config
21828
- if (appearance.primaryColor)
21829
- styles['--primary-color'] = appearance.primaryColor;
21830
- if (appearance.borderRadius !== undefined)
21831
- styles['--border-radius'] = `${appearance.borderRadius}px`;
21832
- // Legacy button
21833
- if (appearance.button) {
21834
- const btn = appearance.button;
21835
- if (btn.color)
21836
- styles['--button-color'] = btn.color;
21837
- if (btn.size)
21838
- styles['--button-size'] = `${btn.size}px`;
21839
- if (btn.borderRadius !== undefined)
21840
- styles['--button-border-radius'] = `${btn.borderRadius}px`;
21841
- if (btn.borderWidth !== undefined)
21842
- styles['--button-border-width'] = `${btn.borderWidth}px`;
21843
- if (btn.borderColor)
21844
- styles['--button-border-color'] = btn.borderColor;
21845
- if (btn.opacity !== undefined)
21846
- styles['--button-opacity'] = btn.opacity.toString();
21847
- }
21866
+ // Apply primary color
21867
+ if (appearance.primaryColor) {
21868
+ styles['--primary-color'] = appearance.primaryColor;
21848
21869
  }
21870
+ // Note: All legacy theme system code (lightMode, darkMode, ThemeAppearanceConfig)
21871
+ // has been removed. The widget now uses a simplified flat appearance schema.
21872
+ // Theme-specific styling is handled by generateThemeStyles() using auto-detected theme.
21849
21873
  return styles;
21850
21874
  }
21851
21875
 
@@ -22207,19 +22231,23 @@ function detectTheme(element) {
22207
22231
  * Create a MutationObserver to watch for theme changes
22208
22232
  */
22209
22233
  function createThemeObserver(element, callback) {
22234
+ let lastTheme = detectTheme(element);
22210
22235
  const observer = new MutationObserver(() => {
22211
22236
  const theme = detectTheme(element);
22212
- callback(theme);
22237
+ if (theme !== lastTheme) {
22238
+ lastTheme = theme;
22239
+ callback(theme);
22240
+ }
22213
22241
  });
22214
22242
  // Observe body for class/style changes (common for theme switching)
22215
22243
  observer.observe(document.body, {
22216
22244
  attributes: true,
22217
- attributeFilter: ['class', 'style', 'data-theme'],
22245
+ attributeFilter: ['class', 'style', 'data-theme', 'data-bs-theme'],
22218
22246
  });
22219
22247
  // Also observe html element
22220
22248
  observer.observe(document.documentElement, {
22221
22249
  attributes: true,
22222
- attributeFilter: ['class', 'style', 'data-theme'],
22250
+ attributeFilter: ['class', 'style', 'data-theme', 'data-bs-theme'],
22223
22251
  });
22224
22252
  return observer;
22225
22253
  }
@@ -22251,7 +22279,7 @@ function styleInject(css, ref) {
22251
22279
  }
22252
22280
  }
22253
22281
 
22254
- var css_248z$1 = ".ai-chat-widget{--primary-color:#07f;--background-color:#fff;--text-color:#1f2937;--border-color:#e5e7eb;--user-message-bg:var(--primary-color);--user-message-text:#fff;--assistant-message-bg:#f3f4f6;--assistant-message-text:#374151;--input-bg:#fff;--input-border:#d1d5db;--shadow:0 4px 6px -1px rgba(0,0,0,.1),0 2px 4px -1px rgba(0,0,0,.06);--shadow-lg:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -2px rgba(0,0,0,.05);--button-color:#07f;--button-size:56px;--button-border-radius:28px;--button-border-width:0px;--button-border-color:#07f;--button-opacity:1;--button-backdrop-blur:0px;--button-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -2px rgba(0,0,0,.05);--card-background:#fff;--card-border-radius:16px;--card-border-width:0px;--card-border-color:#e5e7eb;--card-opacity:1;--card-backdrop-blur:0px;--card-shadow:0 25px 50px -12px rgba(0,0,0,.25);--header-background:#07f;--header-text-color:#fff;--header-font-size:18px;--header-border-bottom-width:0px;--header-border-bottom-color:#e5e7eb;--header-opacity:1;--header-backdrop-blur:0px;--chat-background:#fff;--chat-opacity:1;--chat-backdrop-blur:0px;--welcome-font-size:16px;--welcome-color:#1f2937;--welcome-opacity:1;--bubble-user-color:#07f;--bubble-assistant-color:#f3f4f6;--bubble-border-radius:16px;--bubble-border-width:0px;--bubble-border-color:#e5e7eb;--bubble-opacity:1;--typing-animation-color:#f3f4f6;--typing-animation-opacity:1;--typing-animation-border-width:0px;--typing-animation-border-color:#e5e7eb;--typing-animation-border-radius:16px;--footer-background:#fff;--footer-border-top-width:1px;--footer-border-top-color:#e5e7eb;--footer-opacity:1;--footer-backdrop-blur:0px;--input-background:#fff;--input-border-radius:24px;--input-border-width:1.5px;--input-border-color:#d1d5db;--input-opacity:1;--input-shadow:0 1px 2px 0 rgba(0,0,0,.05);--send-button-background:#07f;--send-button-border-radius:20px;--send-button-border-width:0px;--send-button-border-color:#07f;--send-button-opacity:1;--hover-button-scale:1.05;--hover-button-opacity:0.9;--hover-input-border-color:#9ca3af;--hover-send-button-opacity:0.85;--hover-close-button-opacity:1;--active-input-border-color:#07f;--active-input-shadow:0 0 0 3px rgba(0,119,255,.1);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif}.ai-chat-widget.dark{--background-color:#001d3d;--text-color:#f9fafb;--border-color:#374151;--assistant-message-bg:#036;--assistant-message-text:#e5e7eb;--input-bg:#002855;--input-border:#374151}.ai-chat-widget.dark .ai-chat-message.system .ai-chat-message-content{background-color:#78350f;color:#fef3c7}.ai-chat-widget.dark .ai-chat-message.tool .ai-chat-message-content{background-color:#1e3a8a;color:#dbeafe}.ai-chat-widget-container{font-size:14px;line-height:1.5;position:fixed;z-index:9999}.ai-chat-widget-container.bottom-right{bottom:20px;right:20px}.ai-chat-widget-container.bottom-left{bottom:20px;left:20px}.ai-chat-widget-container.top-right{right:20px;top:20px}.ai-chat-widget-container.top-left{left:20px;top:20px}.ai-chat-button{align-items:center;backdrop-filter:blur(var(--button-backdrop-blur));-webkit-backdrop-filter:blur(var(--button-backdrop-blur));background-color:var(--button-color);border:var(--button-border-width) solid var(--button-border-color);border-radius:var(--button-border-radius);box-shadow:var(--button-shadow);color:#fff;cursor:pointer;display:flex;height:var(--button-size);justify-content:center;opacity:var(--button-opacity);transition:all .3s cubic-bezier(.4,0,.2,1);width:var(--button-size)}.ai-chat-button:hover{opacity:.9}.ai-chat-button:active{opacity:.8}.ai-chat-button-svg{height:50%;min-height:24px;min-width:24px;width:50%}.ai-chat-button-icon{font-size:1.5em;line-height:1}.ai-chat-window{border-radius:var(--card-border-radius);box-shadow:0 0 0 var(--card-border-width) var(--card-border-color-rgba,var(--card-border-color)),var(--card-shadow);display:flex;flex-direction:column;overflow:hidden;position:absolute}.ai-chat-window>*{position:relative;z-index:1}.ai-chat-window:before{backdrop-filter:blur(var(--card-backdrop-blur));-webkit-backdrop-filter:blur(var(--card-backdrop-blur));background-color:var(--card-background);border-radius:var(--card-border-radius);content:\"\";inset:0;opacity:var(--card-opacity);pointer-events:none;position:absolute;z-index:0}.ai-chat-widget-container.bottom-right .ai-chat-window{bottom:calc(var(--button-size, 60px) + 16px);right:0}.ai-chat-widget-container.bottom-left .ai-chat-window{bottom:calc(var(--button-size, 60px) + 16px);left:0}.ai-chat-widget-container.top-right .ai-chat-window{right:0;top:calc(var(--button-size, 60px) + 16px)}.ai-chat-widget-container.top-left .ai-chat-window{left:0;top:calc(var(--button-size, 60px) + 16px)}.ai-chat-button{z-index:1}.ai-chat-window{z-index:2}.ai-chat-window.size-small{height:500px;width:380px}.ai-chat-window.size-medium{height:650px;width:440px}.ai-chat-window.size-large{height:750px;width:520px}.ai-chat-logo{border-radius:50%;height:32px;object-fit:cover;width:32px}.ai-chat-messages::-webkit-scrollbar{width:6px}.ai-chat-messages::-webkit-scrollbar-track{background:transparent}.ai-chat-messages::-webkit-scrollbar-thumb{background:var(--border-color);border-radius:3px}.ai-chat-messages::-webkit-scrollbar-thumb:hover{background:var(--input-border)}.ai-chat-message{display:flex;flex-direction:column;gap:4px}.ai-chat-message.user{align-items:flex-end}.ai-chat-message.assistant{align-items:flex-start}.ai-chat-message.system{align-items:center}.ai-chat-message.tool{align-items:flex-start}.ai-chat-message-content{word-wrap:break-word;border:var(--bubble-border-width) solid var(--bubble-border-color);border-radius:var(--bubble-border-radius);font-size:15px;line-height:1.6;max-width:80%;opacity:var(--bubble-opacity);padding:12px 16px}.ai-chat-message.user .ai-chat-message-content{background-color:var(--bubble-user-color);border-bottom-right-radius:4px;box-shadow:0 1px 2px rgba(0,0,0,.1);color:var(--user-message-text)}.ai-chat-message.assistant .ai-chat-message-content{background-color:var(--bubble-assistant-color,#f3f4f6);border:1px solid var(--bubble-border-color,rgba(0,0,0,.08));border-radius:var(--bubble-border-radius,16px);border-bottom-left-radius:4px;box-shadow:none;color:var(--assistant-message-text);max-width:85%;padding:12px 16px}.ai-chat-message.assistant .ai-chat-message-content p{margin:0 0 12px}.ai-chat-message.assistant .ai-chat-message-content p:last-child{margin-bottom:0}.ai-chat-message.assistant .ai-chat-message-content ol,.ai-chat-message.assistant .ai-chat-message-content ul{margin:8px 0 12px;padding-left:24px}.ai-chat-message.assistant .ai-chat-message-content li{line-height:1.5;margin:6px 0}.ai-chat-message.assistant .ai-chat-message-content li::marker{color:var(--primary-color,#07f)}.ai-chat-message.assistant .ai-chat-message-content ol li::marker{font-weight:600}.ai-chat-message.assistant .ai-chat-message-content strong{font-weight:600}.ai-chat-message.assistant .ai-chat-message-content em{font-style:italic}.ai-chat-message.assistant .ai-chat-message-content code{background-color:rgba(0,0,0,.06);border-radius:4px;font-family:SF Mono,Consolas,Monaco,monospace;font-size:.9em;padding:2px 6px}.ai-chat-widget.dark .ai-chat-message.assistant .ai-chat-message-content code{background-color:hsla(0,0%,100%,.1)}.ai-chat-message.assistant .ai-chat-message-content pre{background-color:rgba(0,0,0,.06);border-radius:8px;margin:8px 0 12px;overflow-x:auto;padding:12px}.ai-chat-widget.dark .ai-chat-message.assistant .ai-chat-message-content pre{background-color:hsla(0,0%,100%,.08)}.ai-chat-message.assistant .ai-chat-message-content pre code{background-color:transparent;border-radius:0;padding:0}.ai-chat-message.assistant .ai-chat-message-content blockquote{border-left:3px solid var(--primary-color,#07f);color:var(--text-muted,#6b7280);margin:8px 0 12px;padding:4px 0 4px 12px}.ai-chat-message.assistant .ai-chat-message-content a{color:var(--primary-color,#07f);text-decoration:underline}.ai-chat-message.assistant .ai-chat-message-content a:hover{opacity:.8}.ai-chat-message.assistant .ai-chat-message-content h1,.ai-chat-message.assistant .ai-chat-message-content h2,.ai-chat-message.assistant .ai-chat-message-content h3,.ai-chat-message.assistant .ai-chat-message-content h4,.ai-chat-message.assistant .ai-chat-message-content h5,.ai-chat-message.assistant .ai-chat-message-content h6{font-weight:600;line-height:1.3;margin:16px 0 8px}.ai-chat-message.assistant .ai-chat-message-content h1:first-child,.ai-chat-message.assistant .ai-chat-message-content h2:first-child,.ai-chat-message.assistant .ai-chat-message-content h3:first-child{margin-top:0}.ai-chat-message.assistant .ai-chat-message-content hr{border:none;border-top:1px solid var(--border-color,#e5e7eb);margin:12px 0}.ai-chat-message.system .ai-chat-message-content{background-color:#fef3c7;border-radius:8px;color:#92400e;font-size:12px;font-style:italic;max-width:90%;text-align:center}.ai-chat-message.tool .ai-chat-message-content{background-color:#dbeafe;border-bottom-left-radius:4px;color:#1e40af;font-family:Courier New,monospace;font-size:13px}.ai-chat-tool-indicators{display:flex;gap:6px;margin-top:6px}.tool-indicator{align-items:center;background:#dbeafe;border-radius:50%;color:#1e40af;display:inline-flex;height:18px;justify-content:center;overflow:hidden;position:relative;width:18px}.tool-indicator .icon{font-size:12px;line-height:1;z-index:1}.tool-indicator.started:after{animation:ai-spin 1s linear infinite;border:2px solid rgba(30,64,175,.25);border-radius:50%;border-top-color:#1e40af;content:\"\";inset:0;position:absolute}@keyframes ai-spin{to{transform:rotate(1turn)}}.ai-chat-tool-message{align-items:center;background:rgba(16,185,129,.1);border:1px solid rgba(16,185,129,.2);border-radius:20px;color:#059669;display:inline-flex;gap:8px;padding:8px 14px}.ai-chat-widget.dark .ai-chat-tool-message{background:rgba(16,185,129,.15);border-color:rgba(16,185,129,.25);color:#34d399}.tool-finished{align-items:center;display:inline-flex;font-size:14px;justify-content:center}.tool-finished .tool-icon{display:none}.tool-finished .tool-check{font-size:14px;font-weight:700}.tool-name{font-size:13px;font-weight:500}.ai-chat-message-timestamp{color:rgba(0,0,0,.6);filter:invert(1) grayscale(1) contrast(1.2);mix-blend-mode:difference;padding:0 4px}.ai-chat-welcome{align-items:center;color:var(--welcome-color);display:flex;flex-direction:column;justify-content:center;min-height:200px;opacity:var(--welcome-opacity);padding:60px 32px 40px;text-align:center}.ai-chat-welcome-title{color:var(--primary-color);font-size:28px;font-weight:700;letter-spacing:-.03em;margin-bottom:12px}.ai-chat-welcome-text{color:var(--assistant-message-text);font-size:16px;line-height:1.6;max-width:280px;opacity:.7}.ai-chat-typing{align-items:center;background-color:var(--assistant-message-bg);border-radius:12px;border-bottom-left-radius:4px;display:flex;gap:4px;max-width:80px;padding:10px 14px}.ai-chat-typing-dot{animation:typingBounce 1.4s infinite;background-color:#9ca3af;border-radius:50%;height:8px;width:8px}.ai-chat-typing-dot:nth-child(2){animation-delay:.2s}.ai-chat-typing-dot:nth-child(3){animation-delay:.4s}@keyframes typingBounce{0%,60%,to{transform:translateY(0)}30%{transform:translateY(-8px)}}.ai-chat-file-button{align-items:center;background:none;border:none;border-radius:6px;color:var(--text-color);cursor:pointer;display:flex;justify-content:center;padding:8px;transition:background-color .2s}.ai-chat-file-button:hover:not(:disabled){background-color:rgba(0,0,0,.05)}.ai-chat-file-button:disabled{cursor:not-allowed;opacity:.5}.ai-chat-file-list{display:flex;flex-wrap:wrap;gap:8px;padding:8px 12px}.ai-chat-file-item{align-items:center;background-color:rgba(0,0,0,.05);border-radius:6px;display:flex;font-size:12px;gap:8px;padding:6px 10px}.ai-chat-file-extension{background-color:var(--primary-color);border-radius:3px;color:#fff;display:inline-block;font-size:10px;font-weight:600;min-width:40px;padding:2px 6px;text-align:center;text-transform:uppercase}.ai-chat-file-info{display:flex;flex:1;flex-direction:column;gap:2px;min-width:0}.ai-chat-file-name{font-weight:500;max-width:150px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.ai-chat-file-size{color:var(--text-muted);font-size:10px;opacity:.7}.ai-chat-file-remove{align-items:center;background:none;border:none;color:inherit;cursor:pointer;display:flex;justify-content:center;opacity:.5;padding:4px;transition:opacity .15s ease}.ai-chat-file-remove:hover{opacity:1}.ai-chat-message-attachments{display:flex;flex-wrap:wrap;gap:6px;margin-top:6px}.ai-chat-message-attachment{align-items:center;background-color:rgba(0,0,0,.08);border-radius:4px;display:inline-flex;font-size:11px;gap:4px;padding:3px 8px}.ai-chat-attachment-icon{font-size:12px}.ai-chat-attachment-ext{background-color:var(--primary-color);border-radius:2px;color:#fff;display:inline-block;font-size:9px;font-weight:600;padding:1px 4px;text-transform:uppercase}.ai-chat-attachment-name{max-width:120px;opacity:.8;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.ai-chat-sources{background-color:rgba(0,0,0,.02);border-radius:6px;font-size:12px;margin-top:8px;overflow:hidden}.ai-chat-sources-toggle{align-items:center;background:none;border:none;cursor:pointer;display:flex;gap:6px;padding:8px 10px;text-align:left;transition:background-color .2s;width:100%}.ai-chat-sources-toggle:hover{background-color:rgba(0,0,0,.03)}.ai-chat-sources-icon{color:var(--text-muted);font-size:10px;transition:transform .2s}.ai-chat-sources-title{color:var(--text-color);flex:1;font-size:11px;font-weight:600;letter-spacing:.5px;text-transform:uppercase}.ai-chat-source-item{border-top:1px solid rgba(0,0,0,.05);color:#6b7280;display:flex;gap:8px;padding:8px 10px}.ai-chat-source-item:last-child{border-bottom:none}.ai-chat-source-number{color:var(--primary-color);flex-shrink:0;font-weight:600}.ai-chat-source-details{display:flex;flex:1;flex-direction:column;gap:4px}.ai-chat-source-score{color:#9ca3af;font-size:11px}.ai-chat-source-content{color:#6b7280;font-size:11px;font-style:italic;line-height:1.4}.ai-chat-source-metadata{display:flex;flex-wrap:wrap;gap:6px;margin-top:2px}.ai-chat-source-meta-item{background-color:rgba(0,0,0,.05);border-radius:3px;color:#6b7280;font-size:10px;padding:2px 6px}.ai-chat-message-meta{align-items:center;display:inline-flex;gap:6px;height:20px}.ai-chat-message-timestamp{color:#71717a;font-size:11px;line-height:1}.ai-chat-feedback{gap:0}.ai-chat-feedback,.ai-chat-feedback-button{align-items:center;display:inline-flex;height:20px}.ai-chat-feedback-button{background:none!important;border:none;border-radius:0;color:#71717a;cursor:pointer;justify-content:center;padding:0 4px;transition:color .15s ease}.ai-chat-feedback-button:hover:not(:disabled){background:none!important;color:#52525b}.ai-chat-feedback-button:active:not(:disabled){opacity:.7}.ai-chat-feedback-button:disabled{cursor:not-allowed;opacity:.4}.ai-chat-feedback-button.active{background:none!important;color:var(--primary-color,#07f)}.ai-chat-feedback-submitted{align-items:center;animation:feedbackMorph .3s cubic-bezier(.34,1.56,.64,1);display:flex;gap:6px}.ai-chat-feedback-checkmark{animation:checkmarkPop .3s cubic-bezier(.34,1.56,.64,1);color:#10b981;font-size:16px;font-weight:700}.ai-chat-feedback-text{animation:textSlideIn .3s ease;color:#10b981;font-size:13px;font-weight:500}@keyframes feedbackMorph{0%{opacity:.5;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes checkmarkPop{0%{opacity:0;transform:scale(0) rotate(-45deg)}50%{transform:scale(1.3) rotate(0deg)}to{opacity:1;transform:scale(1) rotate(0deg)}}@keyframes textSlideIn{0%{opacity:0;transform:translateX(-10px)}to{opacity:1;transform:translateX(0)}}.ai-chat-error{align-items:flex-start;background-color:rgba(239,68,68,.1);border:1px solid rgba(239,68,68,.2);border-radius:12px;color:#ef4444;display:flex;font-size:14px;font-weight:500;gap:10px;line-height:1.5;margin:8px 16px;padding:12px 16px}.ai-chat-widget.dark .ai-chat-error{background-color:rgba(239,68,68,.15);border-color:rgba(239,68,68,.25);color:#fca5a5}.ai-chat-error:before{align-items:center;background:rgba(239,68,68,.2);border-radius:50%;content:\"⚠\";display:flex;flex-shrink:0;font-size:14px;font-weight:700;height:20px;justify-content:center;width:20px}.ai-chat-widget.dark .ai-chat-error:before{background:rgba(239,68,68,.25)}.ai-chat-warning{background-color:rgba(245,158,11,.1);border:1px solid rgba(245,158,11,.2);border-radius:12px;color:#d97706;font-size:13px;margin:8px 16px;padding:12px 16px}.ai-chat-widget.dark .ai-chat-warning{background-color:rgba(245,158,11,.15);border-color:rgba(245,158,11,.25);color:#fbbf24}.ai-chat-suggested-questions{bottom:80px;left:0;padding:0 20px 16px;position:absolute;right:0;z-index:5}.ai-chat-suggested-questions-list{display:flex;flex-direction:column;gap:8px}.ai-chat-suggested-question{align-items:center;background:#fff;border:1px solid rgba(0,0,0,.08);border-radius:14px;box-shadow:0 1px 3px rgba(0,0,0,.04);color:#374151;cursor:pointer;display:flex;font-size:14px;font-weight:500;gap:12px;justify-content:space-between;padding:14px 16px;text-align:left;transition:all .15s ease;width:100%}.ai-chat-suggested-question:hover{background:#f9fafb;border-color:rgba(0,0,0,.12);box-shadow:0 2px 8px rgba(0,0,0,.06)}.ai-chat-suggested-question:active{transform:scale(.98)}.ai-chat-suggested-question-text{flex:1;line-height:1.4}.ai-chat-suggested-question-icon{color:var(--primary-color,#07f);flex-shrink:0;opacity:.7;transition:transform .15s ease,opacity .15s ease}.ai-chat-suggested-question:hover .ai-chat-suggested-question-icon{opacity:1;transform:translateX(3px)}@media (max-width:480px){.ai-chat-window{border-radius:0!important;bottom:0!important;height:100%!important;left:0!important;position:fixed!important;right:0!important;top:0!important;width:100%!important}.ai-chat-widget-container{bottom:20px!important;right:20px!important}.ai-chat-suggested-question{font-size:13px;padding:9px 10px}}.ai-chat-action-approval{background:linear-gradient(135deg,#07f,#001d3d);border-radius:16px;box-shadow:0 4px 12px rgba(0,119,255,.3);color:#fff;margin:16px;padding:16px}.ai-chat-action-approval-content{align-items:flex-start;display:flex;gap:12px;margin-bottom:16px}.ai-chat-action-approval-icon{align-items:center;background:hsla(0,0%,100%,.2);border-radius:8px;display:flex;flex-shrink:0;height:40px;justify-content:center;width:40px}.ai-chat-action-approval-text{flex:1}.ai-chat-action-approval-title{font-size:15px;font-weight:600;margin-bottom:4px}.ai-chat-action-approval-description{font-size:13px;line-height:1.4;opacity:.95}.ai-chat-action-approval-buttons{display:flex;gap:8px;justify-content:flex-end}.ai-chat-action-button{align-items:center;border:none;border-radius:8px;cursor:pointer;display:flex;font-family:inherit;font-size:14px;font-weight:500;gap:6px;padding:8px 16px;transition:all .2s ease}.ai-chat-action-button:disabled{cursor:not-allowed;opacity:.6}.ai-chat-action-button-reject{background:hsla(0,0%,100%,.2);color:#fff}.ai-chat-action-button-reject:hover:not(:disabled){background:hsla(0,0%,100%,.3)}.ai-chat-action-button-approve{background:#fff;color:#07f}.ai-chat-action-button-approve:hover:not(:disabled){background:#f0f0f0;box-shadow:0 2px 8px rgba(0,0,0,.15);transform:translateY(-1px)}.ai-chat-action-spinner{animation:ai-chat-spin .6s linear infinite;border:2px solid rgba(0,119,255,.3);border-radius:50%;border-top-color:#07f;display:inline-block;height:14px;width:14px}@keyframes ai-chat-spin{to{transform:rotate(1turn)}}";
22282
+ var css_248z$1 = ".ai-chat-widget{--primary-color:#07f;--background-color:#fff;--text-color:#1f2937;--border-color:#e5e7eb;--user-message-bg:var(--primary-color);--user-message-text:#fff;--assistant-message-bg:#f3f4f6;--assistant-message-text:#374151;--input-bg:#fff;--input-border:#d1d5db;--shadow:0 4px 6px -1px rgba(0,0,0,.1),0 2px 4px -1px rgba(0,0,0,.06);--shadow-lg:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -2px rgba(0,0,0,.05);--button-color:#07f;--button-size:56px;--button-border-radius:28px;--button-border-width:0px;--button-border-color:#07f;--button-opacity:1;--button-backdrop-blur:0px;--button-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -2px rgba(0,0,0,.05);--card-background:#fff;--card-border-radius:16px;--card-border-width:0px;--card-border-color:#e5e7eb;--card-opacity:1;--card-backdrop-blur:0px;--card-shadow:0 25px 50px -12px rgba(0,0,0,.25);--header-background:#07f;--header-text-color:#fff;--header-font-size:18px;--header-border-bottom-width:0px;--header-border-bottom-color:#e5e7eb;--header-opacity:1;--header-backdrop-blur:0px;--chat-background:#fff;--chat-opacity:1;--chat-backdrop-blur:0px;--welcome-font-size:16px;--welcome-color:#1f2937;--welcome-opacity:1;--bubble-user-color:#07f;--bubble-assistant-color:#f3f4f6;--bubble-border-radius:16px;--bubble-border-width:0px;--bubble-border-color:#e5e7eb;--bubble-opacity:1;--typing-animation-color:#f3f4f6;--typing-animation-opacity:1;--typing-animation-border-width:0px;--typing-animation-border-color:#e5e7eb;--typing-animation-border-radius:16px;--footer-background:#fff;--footer-border-top-width:1px;--footer-border-top-color:#e5e7eb;--footer-opacity:1;--footer-backdrop-blur:0px;--input-background:#fff;--input-border-radius:24px;--input-border-width:1.5px;--input-border-color:#d1d5db;--input-opacity:1;--input-shadow:0 1px 2px 0 rgba(0,0,0,.05);--send-button-background:#07f;--send-button-border-radius:20px;--send-button-border-width:0px;--send-button-border-color:#07f;--send-button-opacity:1;--hover-button-scale:1.05;--hover-button-opacity:0.9;--hover-input-border-color:#9ca3af;--hover-send-button-opacity:0.85;--hover-close-button-opacity:1;--active-input-border-color:#07f;--active-input-shadow:0 0 0 3px rgba(0,119,255,.1);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif}.ai-chat-widget.dark{--background-color:#001d3d;--text-color:#f9fafb;--border-color:#374151;--assistant-message-bg:#036;--assistant-message-text:#e5e7eb;--input-bg:#002855;--input-border:#374151}.ai-chat-widget.dark .ai-chat-message.system .ai-chat-message-content{background-color:#78350f;color:#fef3c7}.ai-chat-widget.dark .ai-chat-message.tool .ai-chat-message-content{background-color:#1e3a8a;color:#dbeafe}.ai-chat-widget-container{font-size:14px;line-height:1.5;position:fixed;z-index:9999}.ai-chat-widget-container.bottom-right{bottom:20px;right:20px}.ai-chat-widget-container.bottom-left{bottom:20px;left:20px}.ai-chat-widget-container.top-right{right:20px;top:20px}.ai-chat-widget-container.top-left{left:20px;top:20px}.ai-chat-button{align-items:center;backdrop-filter:blur(var(--button-backdrop-blur));-webkit-backdrop-filter:blur(var(--button-backdrop-blur));background-color:var(--button-color);border:var(--button-border-width) solid var(--button-border-color);border-radius:var(--button-border-radius);box-shadow:var(--button-shadow);color:#fff;cursor:pointer;display:flex;height:var(--button-size);justify-content:center;opacity:var(--button-opacity);transition:all .3s cubic-bezier(.4,0,.2,1);width:var(--button-size)}.ai-chat-button:hover{opacity:.9}.ai-chat-button:active{opacity:.8}.ai-chat-button-svg{height:50%;min-height:24px;min-width:24px;width:50%}.ai-chat-button-icon{font-size:1.5em;line-height:1}.ai-chat-window{border-radius:var(--card-border-radius);box-shadow:0 0 0 var(--card-border-width) var(--card-border-color-rgba,var(--card-border-color)),var(--card-shadow);display:flex;flex-direction:column;overflow:hidden;position:absolute}.ai-chat-window>*{position:relative;z-index:1}.ai-chat-window:before{backdrop-filter:blur(var(--card-backdrop-blur));-webkit-backdrop-filter:blur(var(--card-backdrop-blur));background-color:var(--card-background);border-radius:var(--card-border-radius);content:\"\";inset:0;opacity:var(--card-opacity);pointer-events:none;position:absolute;z-index:0}.ai-chat-widget-container.bottom-right .ai-chat-window{bottom:calc(var(--button-size, 60px) + 16px);right:0}.ai-chat-widget-container.bottom-left .ai-chat-window{bottom:calc(var(--button-size, 60px) + 16px);left:0}.ai-chat-widget-container.top-right .ai-chat-window{right:0;top:calc(var(--button-size, 60px) + 16px)}.ai-chat-widget-container.top-left .ai-chat-window{left:0;top:calc(var(--button-size, 60px) + 16px)}.ai-chat-button{z-index:1}.ai-chat-window{z-index:2}.ai-chat-window.size-small{height:500px;width:380px}.ai-chat-window.size-medium{height:650px;width:440px}.ai-chat-window.size-large{height:750px;width:520px}.ai-chat-logo{border-radius:50%;height:32px;object-fit:cover;width:32px}.ai-chat-messages::-webkit-scrollbar{width:6px}.ai-chat-messages::-webkit-scrollbar-track{background:transparent}.ai-chat-messages::-webkit-scrollbar-thumb{background:var(--border-color);border-radius:3px}.ai-chat-messages::-webkit-scrollbar-thumb:hover{background:var(--input-border)}.ai-chat-message{display:flex;flex-direction:column;gap:4px}.ai-chat-message.user{align-items:flex-end}.ai-chat-message.assistant{align-items:flex-start}.ai-chat-message.system{align-items:center}.ai-chat-message.tool{align-items:flex-start}.ai-chat-message-content{word-wrap:break-word;border:var(--bubble-border-width) solid var(--bubble-border-color);border-radius:var(--bubble-border-radius);font-size:15px;line-height:1.6;max-width:80%;opacity:var(--bubble-opacity);padding:12px 16px}.ai-chat-message.user .ai-chat-message-content{background-color:var(--bubble-user-color);border-bottom-right-radius:4px;box-shadow:0 1px 2px rgba(0,0,0,.1);color:var(--user-message-text)}.ai-chat-message.assistant .ai-chat-message-content{background-color:var(--bubble-assistant-color,#f3f4f6);border:1px solid var(--bubble-border-color,rgba(0,0,0,.08));border-radius:var(--bubble-border-radius,16px);border-bottom-left-radius:4px;box-shadow:none;color:var(--assistant-message-text);max-width:85%;padding:12px 16px}.ai-chat-message.assistant .ai-chat-message-content p{margin:0 0 12px}.ai-chat-message.assistant .ai-chat-message-content p:last-child{margin-bottom:0}.ai-chat-message.assistant .ai-chat-message-content ol,.ai-chat-message.assistant .ai-chat-message-content ul{margin:8px 0 12px;padding-left:24px}.ai-chat-message.assistant .ai-chat-message-content li{line-height:1.5;margin:6px 0}.ai-chat-message.assistant .ai-chat-message-content li::marker{color:var(--primary-color,#07f)}.ai-chat-message.assistant .ai-chat-message-content ol li::marker{font-weight:600}.ai-chat-message.assistant .ai-chat-message-content strong{font-weight:600}.ai-chat-message.assistant .ai-chat-message-content em{font-style:italic}.ai-chat-message.assistant .ai-chat-message-content code{background-color:rgba(0,0,0,.06);border-radius:4px;font-family:SF Mono,Consolas,Monaco,monospace;font-size:.9em;padding:2px 6px}.ai-chat-widget.dark .ai-chat-message.assistant .ai-chat-message-content code{background-color:hsla(0,0%,100%,.1)}.ai-chat-message.assistant .ai-chat-message-content pre{background-color:rgba(0,0,0,.06);border-radius:8px;margin:8px 0 12px;overflow-x:auto;padding:12px}.ai-chat-widget.dark .ai-chat-message.assistant .ai-chat-message-content pre{background-color:hsla(0,0%,100%,.08)}.ai-chat-message.assistant .ai-chat-message-content pre code{background-color:transparent;border-radius:0;padding:0}.ai-chat-message.assistant .ai-chat-message-content blockquote{border-left:3px solid var(--primary-color,#07f);color:var(--text-muted,#6b7280);margin:8px 0 12px;padding:4px 0 4px 12px}.ai-chat-message.assistant .ai-chat-message-content a{color:var(--primary-color,#07f);text-decoration:underline}.ai-chat-message.assistant .ai-chat-message-content a:hover{opacity:.8}.ai-chat-message.assistant .ai-chat-message-content h1,.ai-chat-message.assistant .ai-chat-message-content h2,.ai-chat-message.assistant .ai-chat-message-content h3,.ai-chat-message.assistant .ai-chat-message-content h4,.ai-chat-message.assistant .ai-chat-message-content h5,.ai-chat-message.assistant .ai-chat-message-content h6{font-weight:600;line-height:1.3;margin:16px 0 8px}.ai-chat-message.assistant .ai-chat-message-content h1:first-child,.ai-chat-message.assistant .ai-chat-message-content h2:first-child,.ai-chat-message.assistant .ai-chat-message-content h3:first-child{margin-top:0}.ai-chat-message.assistant .ai-chat-message-content hr{border:none;border-top:1px solid var(--border-color,#e5e7eb);margin:12px 0}.ai-chat-message.system .ai-chat-message-content{background-color:#fef3c7;border-radius:8px;color:#92400e;font-size:12px;font-style:italic;max-width:90%;text-align:center}.ai-chat-message.tool .ai-chat-message-content{background-color:#dbeafe;border-bottom-left-radius:4px;color:#1e40af;font-family:Courier New,monospace;font-size:13px}.ai-chat-tool-indicators{display:flex;gap:6px;margin-top:6px}.tool-indicator{align-items:center;background:#dbeafe;border-radius:50%;color:#1e40af;display:inline-flex;height:18px;justify-content:center;overflow:hidden;position:relative;width:18px}.tool-indicator .icon{font-size:12px;line-height:1;z-index:1}.tool-indicator.started:after{animation:ai-spin 1s linear infinite;border:2px solid rgba(30,64,175,.25);border-radius:50%;border-top-color:#1e40af;content:\"\";inset:0;position:absolute}@keyframes ai-spin{to{transform:rotate(1turn)}}.ai-chat-tool-message{align-items:center;background:rgba(16,185,129,.1);border:1px solid rgba(16,185,129,.2);border-radius:20px;color:#059669;display:inline-flex;gap:8px;padding:8px 14px}.ai-chat-widget.dark .ai-chat-tool-message{background:rgba(16,185,129,.15);border-color:rgba(16,185,129,.25);color:#34d399}.tool-finished{align-items:center;display:inline-flex;font-size:14px;justify-content:center}.tool-finished .tool-icon{display:none}.tool-finished .tool-check{font-size:14px;font-weight:700}.tool-name{font-size:13px;font-weight:500}.ai-chat-message-timestamp{color:rgba(0,0,0,.6);filter:invert(1) grayscale(1) contrast(1.2);mix-blend-mode:difference;padding:0 4px}.ai-chat-welcome{align-items:center;color:var(--welcome-color);display:flex;flex-direction:column;justify-content:center;min-height:200px;opacity:var(--welcome-opacity);padding:60px 32px 40px;text-align:center}.ai-chat-welcome-title{color:var(--primary-color);font-size:28px;font-weight:700;letter-spacing:-.03em;margin-bottom:12px}.ai-chat-welcome-text{color:var(--assistant-message-text);font-size:16px;line-height:1.6;max-width:280px;opacity:.7}.ai-chat-typing{align-items:center;background-color:var(--assistant-message-bg);border-radius:12px;border-bottom-left-radius:4px;display:flex;gap:4px;max-width:80px;padding:10px 14px}.ai-chat-typing-dot{animation:typingBounce 1.4s infinite;background-color:#9ca3af;border-radius:50%;height:8px;width:8px}.ai-chat-typing-dot:nth-child(2){animation-delay:.2s}.ai-chat-typing-dot:nth-child(3){animation-delay:.4s}@keyframes typingBounce{0%,60%,to{transform:translateY(0)}30%{transform:translateY(-8px)}}.ai-chat-file-button{align-items:center;background:none;border:none;border-radius:6px;color:var(--text-color);cursor:pointer;display:flex;justify-content:center;padding:8px;transition:background-color .2s}.ai-chat-file-button:hover:not(:disabled){background-color:rgba(0,0,0,.05)}.ai-chat-file-button:disabled{cursor:not-allowed;opacity:.5}.ai-chat-file-list{display:flex;flex-wrap:wrap;gap:8px;padding:8px 12px}.ai-chat-file-item{align-items:center;background-color:rgba(0,0,0,.05);border-radius:6px;display:flex;font-size:12px;gap:8px;padding:6px 10px}.ai-chat-file-extension{background-color:var(--primary-color);border-radius:3px;color:#fff;display:inline-block;font-size:10px;font-weight:600;min-width:40px;padding:2px 6px;text-align:center;text-transform:uppercase}.ai-chat-file-info{display:flex;flex:1;flex-direction:column;gap:2px;min-width:0}.ai-chat-file-name{font-weight:500;max-width:150px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.ai-chat-file-size{color:var(--text-muted);font-size:10px;opacity:.7}.ai-chat-file-remove{align-items:center;background:none;border:none;color:inherit;cursor:pointer;display:flex;justify-content:center;opacity:.5;padding:4px;transition:opacity .15s ease}.ai-chat-file-remove:hover{opacity:1}.ai-chat-message-attachments{display:flex;flex-wrap:wrap;gap:6px;margin-top:6px}.ai-chat-message-attachment{align-items:center;background-color:rgba(0,0,0,.08);border-radius:4px;display:inline-flex;font-size:11px;gap:4px;padding:3px 8px}.ai-chat-attachment-icon{font-size:12px}.ai-chat-attachment-ext{background-color:var(--primary-color);border-radius:2px;color:#fff;display:inline-block;font-size:9px;font-weight:600;padding:1px 4px;text-transform:uppercase}.ai-chat-attachment-name{max-width:120px;opacity:.8;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.ai-chat-sources{background-color:rgba(0,0,0,.02);border-radius:6px;font-size:12px;margin-top:8px;overflow:hidden}.ai-chat-sources-toggle{align-items:center;background:none;border:none;cursor:pointer;display:flex;gap:6px;padding:8px 10px;text-align:left;transition:background-color .2s;width:100%}.ai-chat-sources-toggle:hover{background-color:rgba(0,0,0,.03)}.ai-chat-sources-icon{color:var(--text-muted);font-size:10px;transition:transform .2s}.ai-chat-sources-title{color:var(--text-color);flex:1;font-size:11px;font-weight:600;letter-spacing:.5px;text-transform:uppercase}.ai-chat-source-item{border-top:1px solid rgba(0,0,0,.05);color:#6b7280;display:flex;gap:8px;padding:8px 10px}.ai-chat-source-item:last-child{border-bottom:none}.ai-chat-source-number{color:var(--primary-color);flex-shrink:0;font-weight:600}.ai-chat-source-details{display:flex;flex:1;flex-direction:column;gap:4px}.ai-chat-source-score{color:#9ca3af;font-size:11px}.ai-chat-source-content{color:#6b7280;font-size:11px;font-style:italic;line-height:1.4}.ai-chat-source-metadata{display:flex;flex-wrap:wrap;gap:6px;margin-top:2px}.ai-chat-source-meta-item{background-color:rgba(0,0,0,.05);border-radius:3px;color:#6b7280;font-size:10px;padding:2px 6px}.ai-chat-message-meta{align-items:center;display:inline-flex;gap:6px;height:20px}.ai-chat-message-timestamp{color:#71717a;font-size:11px;line-height:1}.ai-chat-feedback{gap:0}.ai-chat-feedback,.ai-chat-feedback-button{align-items:center;display:inline-flex;height:20px}.ai-chat-feedback-button{background:none!important;border:none;border-radius:0;color:#71717a;cursor:pointer;justify-content:center;padding:0 4px;transition:color .15s ease}.ai-chat-feedback-button:hover:not(:disabled){background:none!important;color:#52525b}.ai-chat-feedback-button:active:not(:disabled){opacity:.7}.ai-chat-feedback-button:disabled{cursor:not-allowed;opacity:.4}.ai-chat-feedback-button.active{background:none!important;color:var(--primary-color,#07f)}.ai-chat-feedback-submitted{align-items:center;animation:feedbackMorph .3s cubic-bezier(.34,1.56,.64,1);display:flex;gap:6px}.ai-chat-feedback-checkmark{animation:checkmarkPop .3s cubic-bezier(.34,1.56,.64,1);color:#10b981;font-size:16px;font-weight:700}.ai-chat-feedback-text{animation:textSlideIn .3s ease;color:#10b981;font-size:13px;font-weight:500}@keyframes feedbackMorph{0%{opacity:.5;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes checkmarkPop{0%{opacity:0;transform:scale(0) rotate(-45deg)}50%{transform:scale(1.3) rotate(0deg)}to{opacity:1;transform:scale(1) rotate(0deg)}}@keyframes textSlideIn{0%{opacity:0;transform:translateX(-10px)}to{opacity:1;transform:translateX(0)}}.ai-chat-error{align-items:flex-start;background-color:rgba(239,68,68,.1);border:1px solid rgba(239,68,68,.2);border-radius:12px;color:#ef4444;display:flex;font-size:14px;font-weight:500;gap:10px;line-height:1.5;margin:8px 16px;padding:12px 16px}.ai-chat-widget.dark .ai-chat-error{background-color:rgba(239,68,68,.15);border-color:rgba(239,68,68,.25);color:#fca5a5}.ai-chat-error:before{align-items:center;background:rgba(239,68,68,.2);border-radius:50%;content:\"⚠\";display:flex;flex-shrink:0;font-size:14px;font-weight:700;height:20px;justify-content:center;width:20px}.ai-chat-widget.dark .ai-chat-error:before{background:rgba(239,68,68,.25)}.ai-chat-warning{background-color:rgba(245,158,11,.1);border:1px solid rgba(245,158,11,.2);border-radius:12px;color:#d97706;font-size:13px;margin:8px 16px;padding:12px 16px}.ai-chat-widget.dark .ai-chat-warning{background-color:rgba(245,158,11,.15);border-color:rgba(245,158,11,.25);color:#fbbf24}.ai-chat-suggested-questions{bottom:80px;left:0;padding:0 20px 16px;position:absolute;right:0;z-index:5}.ai-chat-suggested-questions-list{display:flex;flex-direction:column;gap:8px}.ai-chat-suggested-question{align-items:center;background:#fff;border:1px solid rgba(0,0,0,.08);border-radius:14px;box-shadow:0 1px 3px rgba(0,0,0,.04);color:#374151;cursor:pointer;display:flex;font-size:14px;font-weight:500;gap:12px;justify-content:space-between;padding:14px 16px;text-align:left;transition:all .15s ease;width:100%}.ai-chat-suggested-question:hover{background:#f9fafb;border-color:rgba(0,0,0,.12);box-shadow:0 2px 8px rgba(0,0,0,.06)}.ai-chat-suggested-question:active{transform:scale(.98)}.ai-chat-suggested-question-text{flex:1;line-height:1.4}.ai-chat-suggested-question-icon{color:var(--primary-color,#07f);flex-shrink:0;opacity:.7;transition:transform .15s ease,opacity .15s ease}.ai-chat-suggested-question:hover .ai-chat-suggested-question-icon{opacity:1;transform:translateX(3px)}@media (max-width:480px){.ai-chat-window{border-radius:0!important;bottom:0!important;height:100%!important;left:0!important;position:fixed!important;right:0!important;top:0!important;width:100%!important}.ai-chat-widget-container{bottom:20px!important;right:20px!important}.ai-chat-suggested-question{font-size:13px;padding:9px 10px}}.ai-chat-action-approval{background:linear-gradient(135deg,#07f,#001d3d);border-radius:16px;box-shadow:0 4px 12px rgba(0,119,255,.3);color:#fff;margin:16px;padding:16px}.ai-chat-action-approval-content{align-items:flex-start;display:flex;gap:12px;margin-bottom:16px}.ai-chat-action-approval-icon{align-items:center;background:hsla(0,0%,100%,.2);border-radius:8px;display:flex;flex-shrink:0;height:40px;justify-content:center;width:40px}.ai-chat-action-approval-text{flex:1}.ai-chat-action-approval-title{font-size:15px;font-weight:600;margin-bottom:4px}.ai-chat-action-approval-description{font-size:13px;line-height:1.4;opacity:.95}.ai-chat-action-approval-buttons{display:flex;gap:8px;justify-content:flex-end}.ai-chat-action-button{align-items:center;border:none;border-radius:8px;cursor:pointer;display:flex;font-family:inherit;font-size:14px;font-weight:500;gap:6px;padding:8px 16px;transition:all .2s ease}.ai-chat-action-button:disabled{cursor:not-allowed;opacity:.6}.ai-chat-action-button-reject{background:hsla(0,0%,100%,.2);color:#fff}.ai-chat-action-button-reject:hover:not(:disabled){background:hsla(0,0%,100%,.3)}.ai-chat-action-button-approve{background:#fff;color:#07f}.ai-chat-action-button-approve:hover:not(:disabled){background:#f0f0f0;box-shadow:0 2px 8px rgba(0,0,0,.15);transform:translateY(-1px)}.ai-chat-action-spinner{animation:ai-chat-spin .6s linear infinite;border:2px solid rgba(0,119,255,.3);border-radius:50%;border-top-color:#07f;display:inline-block;height:14px;width:14px}@keyframes ai-chat-spin{to{transform:rotate(1turn)}}.ai-chat-header-actions{align-items:center;display:flex;gap:4px}.ai-chat-header-button{align-items:center;background:transparent;border:none;border-radius:8px;color:var(--header-text-color,#fff);cursor:pointer;display:flex;height:32px;justify-content:center;opacity:.8;transition:background-color .15s ease;width:32px}.ai-chat-header-button:hover{background:hsla(0,0%,100%,.15);opacity:1}.ai-chat-header-button svg{height:18px;width:18px}.ai-chat-history-panel{background:var(--chat-background,#fff);display:flex;flex:1;flex-direction:column;overflow:hidden}.ai-chat-history-empty,.ai-chat-history-loading{align-items:center;color:var(--text-color,#6b7280);display:flex;flex:1;font-size:14px;justify-content:center;padding:24px;text-align:center}.ai-chat-history-list{flex:1;overflow-y:auto;padding:8px}.ai-chat-history-item{align-items:stretch;background:transparent;border:none;border-bottom:1px solid var(--border-color,rgba(0,0,0,.06));border-radius:0;cursor:pointer;display:flex;flex-direction:column;padding:12px 16px;text-align:left;transition:background-color .12s ease;width:100%}.ai-chat-history-item:last-child{border-bottom:none}.ai-chat-history-item:hover{background:rgba(0,0,0,.03)}.ai-chat-widget.dark .ai-chat-history-item:hover{background:hsla(0,0%,100%,.05)}.ai-chat-history-item.active{background:rgba(0,0,0,.05)}.ai-chat-widget.dark .ai-chat-history-item.active{background:hsla(0,0%,100%,.08)}.ai-chat-history-item.active .ai-chat-history-item-meta{opacity:.8}.ai-chat-history-item-preview{color:var(--text-color,#1f2937);font-size:14px;font-weight:400;line-height:1.4;margin-bottom:2px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.ai-chat-history-item.active .ai-chat-history-item-preview{font-weight:500}.ai-chat-history-item-meta{color:var(--text-color,#9ca3af);display:flex;font-size:11px;gap:8px;opacity:.8}.ai-chat-history-list::-webkit-scrollbar{width:6px}.ai-chat-history-list::-webkit-scrollbar-track{background:transparent}.ai-chat-history-list::-webkit-scrollbar-thumb{background:var(--border-color,#e5e7eb);border-radius:3px}.ai-chat-history-list::-webkit-scrollbar-thumb:hover{background:var(--input-border,#d1d5db)}";
22255
22283
  styleInject(css_248z$1);
22256
22284
 
22257
22285
  var css_248z = ".ai-chat-widget{--spring-bounce:cubic-bezier(0.34,1.56,0.64,1);--spring-smooth:cubic-bezier(0.4,0,0.2,1);--spring-snappy:cubic-bezier(0.2,0,0,1);--duration-fast:0.2s;--duration-normal:0.35s;--duration-slow:0.5s}.ai-chat-button{align-items:center;background:var(--button-color,var(--primary-color,#07f));border:none;border-radius:50%;box-shadow:0 2px 8px rgba(0,0,0,.15);cursor:pointer;display:flex;height:48px;justify-content:center;overflow:hidden;position:relative;transition:opacity .15s ease;width:48px}.ai-chat-button:hover{opacity:.9}.ai-chat-button:active{opacity:.8}.ai-chat-button-svg{height:20px;transition:transform .15s ease;width:20px}.ai-chat-button.is-open .ai-chat-button-svg{transform:rotate(0deg)}.ai-chat-window{animation:windowOpen var(--duration-slow) var(--spring-bounce);background:#fff;border:1px solid #e5e7eb;border-radius:16px;box-shadow:0 4px 24px rgba(0,0,0,.12),0 1px 3px rgba(0,0,0,.08);display:flex;flex-direction:column;overflow:hidden;position:absolute;transform-origin:bottom right}.ai-chat-widget.dark .ai-chat-window{background:#18181b;border-color:#27272a}@keyframes windowOpen{0%{opacity:0;transform:scale(.9) translateY(20px)}to{opacity:1;transform:scale(1) translateY(0)}}.ai-chat-window.closing{animation:windowClose var(--duration-normal) var(--spring-smooth) forwards}@keyframes windowClose{0%{opacity:1;transform:scale(1) translateY(0)}to{opacity:0;transform:scale(.9) translateY(20px)}}.ai-chat-header{align-items:center;background:#fff;border-bottom:1px solid #e5e7eb;display:flex;justify-content:space-between;padding:16px 20px;position:relative;z-index:10}.ai-chat-widget.dark .ai-chat-header{background:#18181b;border-bottom-color:#27272a}.ai-chat-header-content{align-items:center;display:flex;flex:1;gap:12px}.ai-chat-logo{border-radius:10px;height:36px;object-fit:cover;width:36px}.ai-chat-title{color:#18181b;font-size:15px;font-weight:600;letter-spacing:-.01em}.ai-chat-widget.dark .ai-chat-title{color:#fafafa}.ai-chat-close-button{align-items:center;background:transparent;border:none;border-radius:8px;color:#a1a1aa;cursor:pointer;display:flex;height:32px;justify-content:center;padding:0;transition:all .15s ease;width:32px}.ai-chat-widget.dark .ai-chat-close-button{color:#71717a}.ai-chat-close-button:hover{background:#f4f4f5;color:#52525b}.ai-chat-widget.dark .ai-chat-close-button:hover{background:#27272a;color:#a1a1aa}.ai-chat-close-button:active{transform:scale(.95)}.ai-chat-messages{-webkit-overflow-scrolling:touch;background:#f4f4f5;display:flex;flex:1;flex-direction:column;gap:12px;overflow-x:hidden;overflow-y:auto;padding:16px 16px 90px;position:relative;scroll-behavior:smooth}.ai-chat-widget.dark .ai-chat-messages{background:#18181b}.ai-chat-messages::-webkit-scrollbar{width:4px}.ai-chat-messages::-webkit-scrollbar-track{background:transparent}.ai-chat-messages::-webkit-scrollbar-thumb{background:rgba(0,0,0,.15);border-radius:4px}.ai-chat-messages::-webkit-scrollbar-thumb:hover{background:rgba(0,0,0,.25)}.ai-chat-message{animation:messageSlideIn var(--duration-normal) var(--spring-bounce);display:flex;flex-direction:column;gap:6px}@keyframes messageSlideIn{0%{opacity:0;transform:translateY(12px)}to{opacity:1;transform:translateY(0)}}.ai-chat-message-content{word-wrap:break-word;border-radius:12px;font-size:14px;line-height:1.5;max-width:85%;padding:8px 14px}.ai-chat-message.user .ai-chat-message-content{background:var(--bubble-user-color,var(--primary-color,#07f));border-bottom-right-radius:4px;color:#fff;margin-left:auto}.ai-chat-message.assistant .ai-chat-message-content{background:#fff;border:1px solid #e5e7eb;border-bottom-left-radius:4px;color:#374151}.ai-chat-widget.dark .ai-chat-message.assistant .ai-chat-message-content{background:#18181b;border-color:#27272a;color:#e4e4e7}.ai-chat-typing{align-items:center;animation:messageSlideIn var(--duration-normal) var(--spring-bounce);background:#fff;border:1px solid #e5e7eb;border-radius:12px;border-bottom-left-radius:4px;display:flex;gap:4px;max-width:64px;padding:12px 16px}.ai-chat-widget.dark .ai-chat-typing{background:#18181b;border-color:#27272a}.ai-chat-typing-dot{animation:typingPulse 1.4s ease-in-out infinite;background:linear-gradient(135deg,var(--primary-color) 0,color-mix(in srgb,var(--primary-color) 70%,#000) 100%);border-radius:50%;height:8px;width:8px}.ai-chat-typing-dot:nth-child(2){animation-delay:.15s}.ai-chat-typing-dot:nth-child(3){animation-delay:.3s}@keyframes typingPulse{0%,60%,to{opacity:.4;transform:translateY(0) scale(1)}30%{opacity:1;transform:translateY(-6px) scale(1.1)}}.ai-chat-input-container{background:transparent;bottom:0;left:0;padding:0 16px 16px;position:absolute;right:0;z-index:10}.ai-chat-input-container:before{background:linear-gradient(0deg,#f4f4f5 80%,transparent);bottom:0;content:\"\";height:48px;left:0;pointer-events:none;position:absolute;right:0;z-index:-1}.ai-chat-widget.dark .ai-chat-input-container:before{background:linear-gradient(0deg,#18181b 80%,transparent)}.ai-chat-input-wrapper{align-items:center;background:#f4f4f5;border:1px solid #e5e7eb;border-radius:9999px;display:flex;gap:0;padding:4px 4px 4px 16px;position:relative;transition:all .15s ease;z-index:5}.ai-chat-widget.dark .ai-chat-input-wrapper{background:#27272a;border-color:#3f3f46}.ai-chat-input-wrapper:focus-within{border-color:var(--primary-color);box-shadow:0 0 0 2px rgba(var(--primary-color-rgb,0,119,255),.15)}.ai-chat-input{background:transparent;border:none;color:var(--text-color);flex:1;font-family:inherit;font-size:14px;line-height:1.4;max-height:100px;min-height:20px;outline:none;padding:8px 0;resize:none}.ai-chat-input::placeholder{color:rgba(0,0,0,.35)}.ai-chat-widget.dark .ai-chat-input::placeholder{color:hsla(0,0%,100%,.35)}.ai-chat-send-button{align-items:center;background:transparent;border:none;border-radius:8px;color:#a1a1aa;cursor:pointer;display:flex;flex-shrink:0;height:36px;justify-content:center;padding:0;transition:all .15s ease;width:36px}.ai-chat-widget.dark .ai-chat-send-button{color:#71717a}.ai-chat-send-button.active{background:var(--primary-color,#07f);color:#fff}.ai-chat-send-button.active:hover:not(:disabled){opacity:.9}.ai-chat-send-button:active:not(:disabled){transform:scale(.95)}.ai-chat-send-button:disabled{cursor:not-allowed;opacity:.4}.ai-chat-tool-message{align-items:center;animation:toolPulse 2s ease-in-out infinite;backdrop-filter:blur(8px);-webkit-backdrop-filter:blur(8px);background:linear-gradient(135deg,rgba(16,185,129,.15),rgba(16,185,129,.08));border:1px solid rgba(16,185,129,.2);border-radius:16px;display:inline-flex;gap:10px;padding:10px 16px}@keyframes toolPulse{0%,to{box-shadow:0 0 0 0 rgba(16,185,129,.2)}50%{box-shadow:0 0 0 8px rgba(16,185,129,0)}}.tool-finished{align-items:center;animation:toolComplete .5s var(--spring-bounce);background:linear-gradient(135deg,#10b981,#059669);border-radius:50%;color:#fff;display:inline-flex;height:28px;justify-content:center;position:relative;width:28px}@keyframes toolComplete{0%{transform:scale(0) rotate(-180deg)}to{transform:scale(1) rotate(0deg)}}.tool-indicator{align-items:center;background:linear-gradient(135deg,rgba(59,130,246,.2),rgba(59,130,246,.1));border-radius:50%;color:#3b82f6;display:inline-flex;height:24px;justify-content:center;position:relative;width:24px}.tool-indicator.started:after{animation:toolSpin .8s linear infinite;border:2px solid transparent;border-radius:50%;border-top-color:#3b82f6;content:\"\";inset:-2px;position:absolute}@keyframes toolSpin{to{transform:rotate(1turn)}}.ai-chat-welcome{align-items:center;animation:welcomeFadeIn var(--duration-slow) var(--spring-smooth);display:flex;flex-direction:column;justify-content:center;min-height:200px;padding:60px 32px 40px;text-align:center}@keyframes welcomeFadeIn{0%{opacity:0;transform:translateY(16px)}to{opacity:1;transform:translateY(0)}}.ai-chat-welcome-title{color:var(--primary-color);font-size:28px;font-weight:700;letter-spacing:-.03em;margin-bottom:12px}.ai-chat-welcome-text{color:var(--text-color);font-size:16px;line-height:1.6;max-width:280px;opacity:.6}.ai-chat-suggested-questions{bottom:76px;left:0;padding:0 16px 12px;position:absolute;right:0;z-index:5}.ai-chat-suggested-questions-list{display:flex;flex-direction:column;gap:6px}.ai-chat-suggested-question{align-items:center;background:#fff;border:1px solid #e5e7eb;border-radius:10px;color:#374151;cursor:pointer;display:flex;font-size:13px;font-weight:500;gap:10px;justify-content:space-between;padding:10px 14px;text-align:left;transition:all .15s ease;width:100%}.ai-chat-widget.dark .ai-chat-suggested-question{background:#18181b;border-color:#27272a;color:#e4e4e7}.ai-chat-suggested-question:hover{background:#f4f4f5;border-color:#d4d4d8}.ai-chat-widget.dark .ai-chat-suggested-question:hover{background:#27272a;border-color:#3f3f46}.ai-chat-suggested-question:active{transform:scale(.98)}.ai-chat-suggested-question-text{flex:1;line-height:1.4}.ai-chat-suggested-question-icon{color:var(--primary-color,#07f);flex-shrink:0;opacity:.7;transition:transform .15s ease,opacity .15s ease}.ai-chat-suggested-question:hover .ai-chat-suggested-question-icon{opacity:1;transform:translateX(3px)}.ai-chat-feedback-button{align-items:center;background:rgba(0,0,0,.04);border:none;border-radius:8px;cursor:pointer;display:flex;font-size:16px;gap:4px;padding:6px 10px;transition:all var(--duration-fast) var(--spring-bounce)}.ai-chat-feedback-button:hover:not(:disabled){background:rgba(0,0,0,.08);transform:scale(1.15)}.ai-chat-feedback-button:active:not(:disabled){transform:scale(.9)}.ai-chat-feedback-button.active{background:rgba(var(--primary-color-rgb,0,119,255),.15)}@media (max-width:480px){.ai-chat-window{animation:mobileSlideUp var(--duration-normal) var(--spring-smooth);border-radius:0!important;bottom:0!important;height:100%!important;left:0!important;position:fixed!important;right:0!important;top:0!important;width:100%!important}@keyframes mobileSlideUp{0%{transform:translateY(100%)}to{transform:translateY(0)}}.ai-chat-header{padding-top:max(16px,env(safe-area-inset-top))}.ai-chat-input-container{padding-bottom:max(20px,env(safe-area-inset-bottom))}}";
@@ -22260,24 +22288,16 @@ styleInject(css_248z);
22260
22288
  // Icon components mapping
22261
22289
  const iconComponents = {
22262
22290
  FiMessageCircle: () => (jsxRuntime.jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: jsxRuntime.jsx("path", { d: "M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z" }) })),
22263
- FiMessageSquare: () => (jsxRuntime.jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: jsxRuntime.jsx("path", { d: "M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z" }) })),
22264
- FiMail: () => (jsxRuntime.jsxs("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [jsxRuntime.jsx("path", { d: "M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z" }), jsxRuntime.jsx("polyline", { points: "22,6 12,13 2,6" })] })),
22265
- FiPhone: () => (jsxRuntime.jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: jsxRuntime.jsx("path", { d: "M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z" }) })),
22266
- FiHelpCircle: () => (jsxRuntime.jsxs("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [jsxRuntime.jsx("circle", { cx: "12", cy: "12", r: "10" }), jsxRuntime.jsx("path", { d: "M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3" }), jsxRuntime.jsx("line", { x1: "12", y1: "17", x2: "12.01", y2: "17" })] })),
22267
- FiZap: () => (jsxRuntime.jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: jsxRuntime.jsx("polygon", { points: "13 2 3 14 12 14 11 22 21 10 12 10 13 2" }) })),
22268
- FiSend: () => (jsxRuntime.jsxs("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [jsxRuntime.jsx("line", { x1: "22", y1: "2", x2: "11", y2: "13" }), jsxRuntime.jsx("polygon", { points: "22 2 15 22 11 13 2 9 22 2" })] })),
22269
- FiUser: () => (jsxRuntime.jsxs("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [jsxRuntime.jsx("path", { d: "M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2" }), jsxRuntime.jsx("circle", { cx: "12", cy: "7", r: "4" })] })),
22270
- FiUsers: () => (jsxRuntime.jsxs("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [jsxRuntime.jsx("path", { d: "M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2" }), jsxRuntime.jsx("circle", { cx: "9", cy: "7", r: "4" }), jsxRuntime.jsx("path", { d: "M23 21v-2a4 4 0 0 0-3-3.87" }), jsxRuntime.jsx("path", { d: "M16 3.13a4 4 0 0 1 0 7.75" })] })),
22271
- FiHeadphones: () => (jsxRuntime.jsxs("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [jsxRuntime.jsx("path", { d: "M3 18v-6a9 9 0 0 1 18 0v6" }), jsxRuntime.jsx("path", { d: "M21 19a2 2 0 0 1-2 2h-1a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h3zM3 19a2 2 0 0 0 2 2h1a2 2 0 0 0 2-2v-3a2 2 0 0 0-2-2H3z" })] })),
22272
- FiCpu: () => (jsxRuntime.jsxs("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [jsxRuntime.jsx("rect", { x: "4", y: "4", width: "16", height: "16", rx: "2", ry: "2" }), jsxRuntime.jsx("rect", { x: "9", y: "9", width: "6", height: "6" }), jsxRuntime.jsx("line", { x1: "9", y1: "1", x2: "9", y2: "4" }), jsxRuntime.jsx("line", { x1: "15", y1: "1", x2: "15", y2: "4" }), jsxRuntime.jsx("line", { x1: "9", y1: "20", x2: "9", y2: "23" }), jsxRuntime.jsx("line", { x1: "15", y1: "20", x2: "15", y2: "23" }), jsxRuntime.jsx("line", { x1: "20", y1: "9", x2: "23", y2: "9" }), jsxRuntime.jsx("line", { x1: "20", y1: "14", x2: "23", y2: "14" }), jsxRuntime.jsx("line", { x1: "1", y1: "9", x2: "4", y2: "9" }), jsxRuntime.jsx("line", { x1: "1", y1: "14", x2: "4", y2: "14" })] })),
22273
22291
  FiChevronDown: () => (jsxRuntime.jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", children: jsxRuntime.jsx("polyline", { points: "6 9 12 15 18 9" }) })),
22274
22292
  };
22275
- const ChatWidget = ({ widgetId, apiUrl = window.location.origin, position = 'bottom-right', theme: themeOverride, primaryColor, onOpen, onClose, onMessage, onError, }) => {
22293
+ const ChatWidget = ({ widgetId, apiUrl = window.location.origin, position = 'bottom-right', primaryColor, onOpen, onClose, onMessage, onError, }) => {
22276
22294
  const [isOpen, setIsOpen] = react.useState(false);
22277
22295
  const [autoDetectedTheme, setAutoDetectedTheme] = react.useState('light');
22278
22296
  const widgetRef = react.useRef(null);
22279
22297
  const containerRef = react.useRef(null);
22280
- const { messages, isLoading, isTyping, error, config, sendMessage, submitFeedback, } = useChat({
22298
+ const { messages, isLoading, isTyping, error, config, sendMessage, submitFeedback,
22299
+ // Chat history (only active when persistConversation is true)
22300
+ conversations, loadConversations, switchConversation, startNewConversation, conversationId, } = useChat({
22281
22301
  widgetId,
22282
22302
  apiUrl,
22283
22303
  onMessage,
@@ -22313,7 +22333,6 @@ const ChatWidget = ({ widgetId, apiUrl = window.location.origin, position = 'bot
22313
22333
  console.log('[ChatWidget] Config loaded:', config ? 'YES' : 'NO');
22314
22334
  if (config) {
22315
22335
  console.log('[ChatWidget] Config details:', {
22316
- theme: config.appearance?.theme,
22317
22336
  accentColor: config.appearance?.primaryColor,
22318
22337
  autoDetectedTheme,
22319
22338
  });
@@ -22331,29 +22350,9 @@ const ChatWidget = ({ widgetId, apiUrl = window.location.origin, position = 'bot
22331
22350
  }
22332
22351
  return undefined;
22333
22352
  }, [config, onOpen]);
22334
- // Handle close on outside click - always enabled for better UX
22335
- react.useEffect(() => {
22336
- if (!isOpen)
22337
- return;
22338
- const handleClickOutside = (event) => {
22339
- // Check if click is outside the widget container
22340
- if (widgetRef.current && !widgetRef.current.contains(event.target)) {
22341
- setIsOpen(false);
22342
- onClose?.();
22343
- }
22344
- };
22345
- // Small delay to prevent immediate close on open
22346
- const timer = setTimeout(() => {
22347
- document.addEventListener('mousedown', handleClickOutside);
22348
- }, 150);
22349
- return () => {
22350
- clearTimeout(timer);
22351
- document.removeEventListener('mousedown', handleClickOutside);
22352
- };
22353
- }, [isOpen, onClose]);
22354
22353
  // Handle close on Escape key
22355
22354
  react.useEffect(() => {
22356
- if (!isOpen || !config?.appearance.closeOnEscape)
22355
+ if (!isOpen)
22357
22356
  return;
22358
22357
  const handleEscapeKey = (event) => {
22359
22358
  if (event.key === 'Escape') {
@@ -22363,16 +22362,10 @@ const ChatWidget = ({ widgetId, apiUrl = window.location.origin, position = 'bot
22363
22362
  };
22364
22363
  document.addEventListener('keydown', handleEscapeKey);
22365
22364
  return () => document.removeEventListener('keydown', handleEscapeKey);
22366
- }, [isOpen, config, onClose]);
22367
- // Determine theme - simplified: always auto-detect unless explicitly overridden
22365
+ }, [isOpen, onClose]);
22366
+ // Determine theme - always auto-detect from background
22368
22367
  const appearanceConfig = config?.appearance;
22369
- const themeSetting = themeOverride || appearanceConfig?.theme || 'auto';
22370
- // Use auto-detected theme, or explicit override
22371
- const effectiveTheme = themeSetting === 'auto'
22372
- ? autoDetectedTheme
22373
- : themeSetting === 'dark'
22374
- ? 'dark'
22375
- : 'light';
22368
+ const effectiveTheme = autoDetectedTheme;
22376
22369
  // Determine position (config takes priority over prop)
22377
22370
  const effectivePosition = config?.appearance.position || position;
22378
22371
  // Get accent color from config or prop
@@ -22381,17 +22374,15 @@ const ChatWidget = ({ widgetId, apiUrl = window.location.origin, position = 'bot
22381
22374
  const simpleAppearance = {
22382
22375
  accentColor,
22383
22376
  size: appearanceConfig?.size || 'small',
22384
- welcomeTitle: appearanceConfig?.lightMode?.chat?.welcomeTitle,
22385
- welcomeMessage: appearanceConfig?.welcomeMessage || appearanceConfig?.lightMode?.chat?.welcomeMessage,
22386
- placeholder: appearanceConfig?.placeholder || appearanceConfig?.lightMode?.footer?.inputPlaceholder,
22387
- headerTitle: appearanceConfig?.lightMode?.header?.title,
22388
- buttonIcon: appearanceConfig?.buttonIcon || appearanceConfig?.lightMode?.button?.icon,
22377
+ welcomeMessage: appearanceConfig?.welcomeMessage || '',
22378
+ placeholder: appearanceConfig?.placeholder || '',
22379
+ headerTitle: appearanceConfig?.headerTitle || '',
22389
22380
  };
22390
22381
  // Generate theme styles from accent color
22391
22382
  const generatedStyles = generateThemeStyles(simpleAppearance, effectiveTheme);
22392
22383
  // Also apply legacy styles for backward compatibility
22393
22384
  const legacyStyles = appearanceConfig
22394
- ? applyAppearanceStyles(appearanceConfig, effectiveTheme)
22385
+ ? applyAppearanceStyles(appearanceConfig)
22395
22386
  : {};
22396
22387
  // Merge styles (generated takes priority for new simplified system)
22397
22388
  const customStyles = {
@@ -22403,10 +22394,9 @@ const ChatWidget = ({ widgetId, apiUrl = window.location.origin, position = 'bot
22403
22394
  console.log('[ChatWidget] Theme info:', {
22404
22395
  effectiveTheme,
22405
22396
  autoDetectedTheme,
22406
- themeSetting,
22407
22397
  accentColor,
22408
22398
  });
22409
- }, [effectiveTheme, autoDetectedTheme, themeSetting, accentColor]);
22399
+ }, [effectiveTheme, autoDetectedTheme, accentColor]);
22410
22400
  const handleToggle = () => {
22411
22401
  const newState = !isOpen;
22412
22402
  console.log('[ChatWidget] handleToggle called, setting isOpen to:', newState);
@@ -22428,24 +22418,10 @@ const ChatWidget = ({ widgetId, apiUrl = window.location.origin, position = 'bot
22428
22418
  }
22429
22419
  console.log('[ChatWidget] Rendering widget', { isOpen, hasConfig: !!config });
22430
22420
  // Get button icon based on state
22431
- const getButtonIcon = () => {
22432
- if (isOpen) {
22433
- return iconComponents.FiChevronDown;
22434
- }
22435
- const themeConfig = effectiveTheme === 'dark'
22436
- ? appearanceConfig?.darkMode
22437
- : appearanceConfig?.lightMode;
22438
- const buttonIcon = themeConfig?.button?.icon || 'FiMessageCircle';
22439
- return iconComponents[buttonIcon] || iconComponents.FiMessageCircle;
22440
- };
22441
- const buttonIconColor = (() => {
22442
- const themeConfig = effectiveTheme === 'dark'
22443
- ? appearanceConfig?.darkMode
22444
- : appearanceConfig?.lightMode;
22445
- return themeConfig?.button?.iconColor || customStyles['--button-icon-color'] || '#ffffff';
22446
- })();
22447
- const IconComponent = getButtonIcon();
22448
- return (jsxRuntime.jsx("div", { ref: containerRef, className: `ai-chat-widget ${effectiveTheme}`, style: customStyles, children: jsxRuntime.jsxs("div", { ref: widgetRef, className: `ai-chat-widget-container ${effectivePosition}`, children: [isOpen && (jsxRuntime.jsx(ChatWindow, { messages: messages, isLoading: isLoading, isTyping: isTyping, error: error, config: config, onSendMessage: sendMessage, onClose: handleToggle, onFeedback: handleFeedback })), jsxRuntime.jsx("button", { className: `ai-chat-button ${isOpen ? 'is-open' : ''}`, onClick: handleToggle, "aria-label": isOpen ? "Minimize chat" : "Open chat", style: { color: buttonIconColor }, children: jsxRuntime.jsx("div", { className: "ai-chat-button-svg", children: jsxRuntime.jsx(IconComponent, {}) }) })] }) }));
22421
+ const IconComponent = isOpen ? iconComponents.FiChevronDown : iconComponents.FiMessageCircle;
22422
+ return (jsxRuntime.jsx("div", { ref: containerRef, className: `ai-chat-widget ${effectiveTheme}`, style: customStyles, children: jsxRuntime.jsxs("div", { ref: widgetRef, className: `ai-chat-widget-container ${effectivePosition}`, children: [isOpen && (jsxRuntime.jsx(ChatWindow, { messages: messages, isLoading: isLoading, isTyping: isTyping, error: error, config: config, onSendMessage: sendMessage, onClose: handleToggle, onFeedback: handleFeedback,
22423
+ // Chat history props (only active when persistConversation is true)
22424
+ conversations: conversations, onLoadConversations: loadConversations, onSwitchConversation: switchConversation, onStartNewConversation: startNewConversation, currentConversationId: conversationId })), jsxRuntime.jsx("button", { className: `ai-chat-button ${isOpen ? 'is-open' : ''}`, onClick: handleToggle, "aria-label": isOpen ? "Minimize chat" : "Open chat", children: jsxRuntime.jsx("div", { className: "ai-chat-button-svg", children: jsxRuntime.jsx(IconComponent, {}) }) })] }) }));
22449
22425
  };
22450
22426
 
22451
22427
  exports.ApiError = ApiError;