@fusioni/client-sdk 1.1.11 → 1.1.13

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
@@ -6106,6 +6106,33 @@ function useIsMobileLayout() {
6106
6106
  return isMobile;
6107
6107
  }
6108
6108
 
6109
+ const getStoredConversationIdKey = (agencyId) => `fusioni:selectedConversationId:${agencyId}`;
6110
+ const readStoredConversationId = (agencyId) => {
6111
+ if (typeof window === 'undefined')
6112
+ return null;
6113
+ try {
6114
+ return window.sessionStorage.getItem(getStoredConversationIdKey(agencyId));
6115
+ }
6116
+ catch {
6117
+ return null;
6118
+ }
6119
+ };
6120
+ const writeStoredConversationId = (agencyId, conversationId) => {
6121
+ if (typeof window === 'undefined')
6122
+ return;
6123
+ try {
6124
+ const key = getStoredConversationIdKey(agencyId);
6125
+ if (conversationId) {
6126
+ window.sessionStorage.setItem(key, conversationId);
6127
+ }
6128
+ else {
6129
+ window.sessionStorage.removeItem(key);
6130
+ }
6131
+ }
6132
+ catch {
6133
+ // Storage can be unavailable in restricted browser contexts.
6134
+ }
6135
+ };
6109
6136
  const ChatWidget = react.forwardRef(function ChatWidget({ config, onMessageSent, onMessageReceived, onConversationCreated, onConversationDeleted, onError }, ref) {
6110
6137
  const [languageOverride, setLanguageOverride] = react.useState(null);
6111
6138
  const [isOpen, setIsOpen] = react.useState(false);
@@ -6120,12 +6147,15 @@ const ChatWidget = react.forwardRef(function ChatWidget({ config, onMessageSent,
6120
6147
  const [isDeleteDialogOpen, setIsDeleteDialogOpen] = react.useState(false);
6121
6148
  const [messageToDelete, setMessageToDelete] = react.useState(null);
6122
6149
  const [isDeleteMessageDialogOpen, setIsDeleteMessageDialogOpen] = react.useState(false);
6150
+ const [hasLoadedConversations, setHasLoadedConversations] = react.useState(false);
6123
6151
  // Refs
6124
6152
  const floatingButtonRef = react.useRef(null);
6153
+ const restoredConversationIdRef = react.useRef(null);
6125
6154
  const translationDefault = languageOverride ?? mergedConfig?.language ?? config.language ?? 'en';
6126
6155
  // Translation and language management - use merged config or fallback to user config
6127
6156
  const { t, currentLanguage, changeLanguage } = useTranslation(translationDefault);
6128
- const { conversations, currentConversation, messages, streamMessages, setCurrentConversation, setStreamMessages, addMessage, updateMessage, removeMessage, removeOptimisticUserMessages, truncateMessagesAt, addConversation, updateConversation, removeConversation, loadConversations, loadMessages, clearMessages } = useChatState(mergedConfig?.agencyId || config.agencyId);
6157
+ const activeAgencyId = mergedConfig?.agencyId || config.agencyId;
6158
+ const { conversations, currentConversation, messages, streamMessages, setCurrentConversation, setStreamMessages, addMessage, updateMessage, removeMessage, removeOptimisticUserMessages, truncateMessagesAt, addConversation, updateConversation, removeConversation, loadConversations, loadMessages, clearMessages } = useChatState(activeAgencyId);
6129
6159
  const { theme, toggleTheme, setTheme } = useTheme(mergedConfig?.theme || config.theme);
6130
6160
  const isMobileLayout = useIsMobileLayout();
6131
6161
  const handleLanguageChange = react.useCallback((language) => {
@@ -6192,12 +6222,22 @@ const ChatWidget = react.forwardRef(function ChatWidget({ config, onMessageSent,
6192
6222
  }, [config, onError, t]);
6193
6223
  // Load initial conversations
6194
6224
  react.useEffect(() => {
6195
- if (mergedConfig?.agencyId) {
6196
- loadConversations().then();
6225
+ if (activeAgencyId) {
6226
+ let isCancelled = false;
6227
+ restoredConversationIdRef.current = null;
6228
+ setHasLoadedConversations(false);
6229
+ loadConversations().finally(() => {
6230
+ if (!isCancelled) {
6231
+ setHasLoadedConversations(true);
6232
+ }
6233
+ });
6234
+ return () => {
6235
+ isCancelled = true;
6236
+ };
6197
6237
  }
6198
- }, [mergedConfig?.agencyId, loadConversations]);
6238
+ }, [activeAgencyId, loadConversations]);
6199
6239
  // SSE connection for real-time updates - only when a chat panel is open
6200
- useSSE(mergedConfig?.agencyId || config.agencyId, (data) => {
6240
+ useSSE(activeAgencyId, (data) => {
6201
6241
  // Same as fusioni-web chat.component: latest SSE line replaces stream (single loading row updates)
6202
6242
  if (data?.data != null && String(data.data).trim() !== '') {
6203
6243
  setStreamMessages([String(data.data)]);
@@ -6221,6 +6261,7 @@ const ChatWidget = react.forwardRef(function ChatWidget({ config, onMessageSent,
6221
6261
  const handleCreateConversation = react.useCallback(() => {
6222
6262
  if (!mergedConfig)
6223
6263
  return;
6264
+ writeStoredConversationId(activeAgencyId, null);
6224
6265
  // Create a new conversation with null ID - will be created on server when first message is sent
6225
6266
  const newConversation = {
6226
6267
  id: null,
@@ -6236,7 +6277,7 @@ const ChatWidget = react.forwardRef(function ChatWidget({ config, onMessageSent,
6236
6277
  // Auto-hide conversation list when a new conversation is created
6237
6278
  setIsConversationListOpen(false);
6238
6279
  onConversationCreated?.(newConversation);
6239
- }, [mergedConfig, addConversation, setCurrentConversation, clearMessages, onConversationCreated, t]);
6280
+ }, [activeAgencyId, mergedConfig, addConversation, setCurrentConversation, clearMessages, onConversationCreated, t]);
6240
6281
  const handleSelectConversation = react.useCallback(async (conversation) => {
6241
6282
  try {
6242
6283
  setIsLoading(true);
@@ -6244,6 +6285,9 @@ const ChatWidget = react.forwardRef(function ChatWidget({ config, onMessageSent,
6244
6285
  clearMessages();
6245
6286
  setStreamMessages([]);
6246
6287
  setCurrentConversation(conversation);
6288
+ if (conversation.id) {
6289
+ writeStoredConversationId(activeAgencyId, conversation.id);
6290
+ }
6247
6291
  // Auto-hide conversation list when a conversation is selected
6248
6292
  setIsConversationListOpen(false);
6249
6293
  if (conversation.id) {
@@ -6258,7 +6302,51 @@ const ChatWidget = react.forwardRef(function ChatWidget({ config, onMessageSent,
6258
6302
  finally {
6259
6303
  setIsLoading(false);
6260
6304
  }
6261
- }, [setCurrentConversation, loadMessages, clearMessages, onError]);
6305
+ }, [activeAgencyId, setCurrentConversation, loadMessages, clearMessages, onError, t]);
6306
+ react.useEffect(() => {
6307
+ if (!hasLoadedConversations || !activeAgencyId || currentConversation) {
6308
+ return;
6309
+ }
6310
+ const storedConversationId = readStoredConversationId(activeAgencyId);
6311
+ if (!storedConversationId || restoredConversationIdRef.current === storedConversationId) {
6312
+ return;
6313
+ }
6314
+ restoredConversationIdRef.current = storedConversationId;
6315
+ let isCancelled = false;
6316
+ const restoreConversation = async () => {
6317
+ let storedConversation = conversations.find((conversation) => conversation.id === storedConversationId);
6318
+ if (!storedConversation) {
6319
+ try {
6320
+ storedConversation = await getConversationService().getConversation(storedConversationId);
6321
+ }
6322
+ catch {
6323
+ storedConversation = undefined;
6324
+ }
6325
+ }
6326
+ if (isCancelled) {
6327
+ return;
6328
+ }
6329
+ if (!storedConversation) {
6330
+ writeStoredConversationId(activeAgencyId, null);
6331
+ return;
6332
+ }
6333
+ if (!conversations.some((conversation) => conversation.id === storedConversation?.id)) {
6334
+ addConversation(storedConversation);
6335
+ }
6336
+ handleSelectConversation(storedConversation);
6337
+ };
6338
+ restoreConversation();
6339
+ return () => {
6340
+ isCancelled = true;
6341
+ };
6342
+ }, [
6343
+ addConversation,
6344
+ activeAgencyId,
6345
+ conversations,
6346
+ currentConversation,
6347
+ handleSelectConversation,
6348
+ hasLoadedConversations
6349
+ ]);
6262
6350
  const handleDeleteConversation = react.useCallback((conversationId) => {
6263
6351
  setConversationToDelete(conversationId);
6264
6352
  setIsDeleteDialogOpen(true);
@@ -6271,6 +6359,9 @@ const ChatWidget = react.forwardRef(function ChatWidget({ config, onMessageSent,
6271
6359
  const conversationService = getConversationService();
6272
6360
  await conversationService.deleteConversation(conversationToDelete);
6273
6361
  removeConversation(conversationToDelete);
6362
+ if (readStoredConversationId(activeAgencyId) === conversationToDelete) {
6363
+ writeStoredConversationId(activeAgencyId, null);
6364
+ }
6274
6365
  if (currentConversation?.id === conversationToDelete) {
6275
6366
  setCurrentConversation(null);
6276
6367
  clearMessages();
@@ -6292,7 +6383,7 @@ const ChatWidget = react.forwardRef(function ChatWidget({ config, onMessageSent,
6292
6383
  finally {
6293
6384
  setIsLoading(false);
6294
6385
  }
6295
- }, [conversationToDelete, removeConversation, currentConversation, setCurrentConversation, clearMessages, setStreamMessages, onConversationDeleted, onError, t]);
6386
+ }, [activeAgencyId, conversationToDelete, removeConversation, currentConversation, setCurrentConversation, clearMessages, setStreamMessages, onConversationDeleted, onError, t]);
6296
6387
  const cancelDeleteConversation = react.useCallback(() => {
6297
6388
  setIsDeleteDialogOpen(false);
6298
6389
  setConversationToDelete(null);
@@ -6321,6 +6412,7 @@ const ChatWidget = react.forwardRef(function ChatWidget({ config, onMessageSent,
6321
6412
  // Update the conversation in the list and set as current
6322
6413
  updateConversation(updatedConversation.id, updatedConversation);
6323
6414
  setCurrentConversation(updatedConversation);
6415
+ writeStoredConversationId(activeAgencyId, conversationId);
6324
6416
  }
6325
6417
  // Clear stream messages for new conversation
6326
6418
  setStreamMessages([]);
@@ -6433,6 +6525,7 @@ const ChatWidget = react.forwardRef(function ChatWidget({ config, onMessageSent,
6433
6525
  }
6434
6526
  }, [
6435
6527
  currentConversation,
6528
+ activeAgencyId,
6436
6529
  mergedConfig,
6437
6530
  messages,
6438
6531
  addMessage,
@@ -6592,7 +6685,7 @@ const ChatWidget = react.forwardRef(function ChatWidget({ config, onMessageSent,
6592
6685
  if (error) {
6593
6686
  return (jsxRuntime.jsxs("div", { className: "fusioni-chat-error", children: [jsxRuntime.jsxs("p", { children: [t('common.error'), ": ", error] }), jsxRuntime.jsx("button", { onClick: () => setError(null), children: t('chat.errors.retry') })] }));
6594
6687
  }
6595
- return (jsxRuntime.jsxs("div", { className: `fusioni-chat-widget ${theme}`, style: { '--primary-color': mergedConfig.primaryColor || '#6366f1' }, children: [jsxRuntime.jsx(FloatingButton, { isOpen: isOpen, onClick: handleToggleChat, position: mergedConfig.position || 'bottom-right', primaryColor: mergedConfig.primaryColor, buttonRef: floatingButtonRef, variant: mergedConfig.buttonVariant || 'glass', shouldDisplay: !hasConfigError && (!isMobileLayout || !isOpen) }), isOpen && (jsxRuntime.jsx(ChatPanel, { isOpen: isOpen, onClose: () => setIsOpen(false), position: mergedConfig.position || 'bottom-right', isFullscreen: isFullscreen, floatingButtonRef: floatingButtonRef, children: jsxRuntime.jsxs("div", { className: "fusioni-chat-container", children: [mergedConfig.showConversationList !== false && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: `fusioni-conversation-backdrop ${isConversationListOpen ? 'open' : ''}`, onClick: () => setIsConversationListOpen(false) }), jsxRuntime.jsx(ConversationList, { conversations: conversations, selectedConversationId: currentConversation?.id || undefined, onSelectConversation: handleSelectConversation, onDeleteConversation: handleDeleteConversation, onCreateConversation: handleCreateConversation, isOpen: isConversationListOpen, currentLanguage: currentLanguage })] })), jsxRuntime.jsxs("div", { className: "fusioni-chat-main", children: [jsxRuntime.jsxs("div", { className: "fusioni-chat-main-header", children: [mergedConfig.showConversationList !== false ? (jsxRuntime.jsxs("button", { type: "button", onClick: handleToggleConversationList, className: `fusioni-conversation-toggle ${isConversationListOpen ? 'open' : ''}`, children: [jsxRuntime.jsx("svg", { className: "fusioni-conversation-toggle-icon", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: jsxRuntime.jsx("path", { d: "M3 12h18M3 6h18M3 18h18" }) }), t('chat.conversations.title')] })) : (jsxRuntime.jsx("span", { className: "fusioni-chat-main-header-title", children: t('chat.title') })), jsxRuntime.jsxs("div", { className: "fusioni-header-actions", children: [isMobileLayout && (jsxRuntime.jsx("button", { type: "button", onClick: () => setIsOpen(false), className: "fusioni-btn fusioni-btn-icon fusioni-chat-toolbar-close-mobile", title: t('common.close'), "aria-label": t('common.close'), children: jsxRuntime.jsx("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", "aria-hidden": "true", children: jsxRuntime.jsx("path", { d: "M18 6L6 18M6 6L18 18", strokeLinecap: "round", strokeLinejoin: "round" }) }) })), mergedConfig.showThemeToggle !== false && (jsxRuntime.jsx("button", { type: "button", onClick: toggleTheme, className: "fusioni-btn fusioni-btn-icon", title: theme === 'dark' ? t('chat.theme.light') : t('chat.theme.dark'), children: theme === 'dark' ? (jsxRuntime.jsxs("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [jsxRuntime.jsx("circle", { cx: "12", cy: "12", r: "5" }), jsxRuntime.jsx("line", { x1: "12", y1: "1", x2: "12", y2: "3" }), jsxRuntime.jsx("line", { x1: "12", y1: "21", x2: "12", y2: "23" }), jsxRuntime.jsx("line", { x1: "4.22", y1: "4.22", x2: "5.64", y2: "5.64" }), jsxRuntime.jsx("line", { x1: "18.36", y1: "18.36", x2: "19.78", y2: "19.78" }), jsxRuntime.jsx("line", { x1: "1", y1: "12", x2: "3", y2: "12" }), jsxRuntime.jsx("line", { x1: "21", y1: "12", x2: "23", y2: "12" }), jsxRuntime.jsx("line", { x1: "4.22", y1: "19.78", x2: "5.64", y2: "18.36" }), jsxRuntime.jsx("line", { x1: "18.36", y1: "5.64", x2: "19.78", y2: "4.22" })] })) : (jsxRuntime.jsx("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: jsxRuntime.jsx("path", { d: "M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z" }) })) })), mergedConfig.showFullscreenToggle !== false && (jsxRuntime.jsx("button", { type: "button", onClick: handleToggleFullscreen, className: "fusioni-btn fusioni-btn-icon", title: isFullscreen ? t('chat.fullscreen.exit') : t('chat.fullscreen.enter'), children: isFullscreen ? (jsxRuntime.jsx("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: jsxRuntime.jsx("path", { d: "M8 3V5M8 3H5M8 3L3 8M16 3V5M16 3H19M16 3L21 8M8 21V19M8 21H5M8 21L3 16M16 21V19M16 21H19M16 21L21 16" }) })) : (jsxRuntime.jsx("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: jsxRuntime.jsx("path", { d: "M8 3H5C4.46957 3 3.96086 3.21071 3.58579 3.58579C3.21071 3.96086 3 4.46957 3 5V8M21 8V5C21 4.46957 20.7893 3.96086 20.4142 3.58579C20.0391 3.21071 19.5304 3 19 3H16M16 21H19C19.5304 21 20.0391 20.7893 20.4142 20.4142C20.7893 20.0391 21 19.5304 21 19V16M3 16V19C3 19.5304 3.21071 20.0391 3.58579 20.4142C3.96086 20.7893 4.46957 21 5 21H8" }) })) })), mergedConfig.showLanguageSwitcher !== false && (jsxRuntime.jsx(LanguageSwitcher, { currentLanguage: currentLanguage, onLanguageChange: handleLanguageChange }))] })] }), currentConversation ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(MessageList, { messages: messages, streamMessages: streamMessages, showThoughts: false, onDeleteMessage: handleDeleteMessage, onEditMessage: handleEditMessage, onConfirmation: handleConfirmation, enableButtons: !isLoading, apiBaseUrl: mergedConfig.apiBaseUrl, apiKey: mergedConfig.accessToken, agencyId: mergedConfig.agencyId, currentLanguage: currentLanguage, theme: theme }), jsxRuntime.jsx(ChatInput, { onSendMessage: handleSendMessage, onFileUpload: handleFileUpload, disabled: isLoading, placeholder: t('chat.input.placeholder'), enableAudioRecording: mergedConfig.enableAudioRecording !== false, enableFileUpload: mergedConfig.enableFileUpload !== false, maxFileSize: mergedConfig.maxFileSize || 10, allowedFileTypes: mergedConfig.allowedFileTypes || ['image/*'], currentLanguage: currentLanguage })] })) : (jsxRuntime.jsx("div", { className: "fusioni-chat-welcome", children: jsxRuntime.jsxs("div", { className: "fusioni-chat-welcome-content", children: [jsxRuntime.jsx("h3", { children: t('chat.welcome.title') }), jsxRuntime.jsx("p", { children: t('chat.welcome.description') }), jsxRuntime.jsx("button", { onClick: handleCreateConversation, disabled: isLoading, className: "fusioni-btn fusioni-btn-primary", children: isLoading ? t('chat.welcome.creating') : t('chat.welcome.startButton') })] }) }))] })] }) })), jsxRuntime.jsx(ConfirmationDialog, { isOpen: isDeleteDialogOpen, title: t('chat.conversations.deleteConfirm.title'), message: t('chat.conversations.deleteConfirm.message'), confirmText: t('chat.conversations.deleteConfirm.confirm'), cancelText: t('chat.conversations.deleteConfirm.cancel'), onConfirm: confirmDeleteConversation, onCancel: cancelDeleteConversation, currentLanguage: currentLanguage, variant: "danger" }), jsxRuntime.jsx(ConfirmationDialog, { isOpen: isDeleteMessageDialogOpen, title: t('chat.messages.deleteConfirm.title'), message: t('chat.messages.deleteConfirm.message'), confirmText: t('chat.messages.deleteConfirm.confirm'), cancelText: t('chat.messages.deleteConfirm.cancel'), onConfirm: confirmDeleteMessage, onCancel: cancelDeleteMessage, currentLanguage: currentLanguage, variant: "danger" })] }));
6688
+ return (jsxRuntime.jsxs("div", { className: `fusioni-chat-widget ${theme}`, style: { '--primary-color': mergedConfig.primaryColor || '#6366f1' }, children: [jsxRuntime.jsx(FloatingButton, { isOpen: isOpen, onClick: handleToggleChat, position: mergedConfig.position || 'bottom-right', primaryColor: mergedConfig.primaryColor, buttonRef: floatingButtonRef, variant: mergedConfig.buttonVariant || 'glass', shouldDisplay: !hasConfigError && (!isMobileLayout || !isOpen) }), isOpen && (jsxRuntime.jsx(ChatPanel, { isOpen: isOpen, onClose: () => setIsOpen(false), position: mergedConfig.position || 'bottom-right', isFullscreen: isFullscreen, floatingButtonRef: floatingButtonRef, children: jsxRuntime.jsxs("div", { className: "fusioni-chat-container", children: [mergedConfig.showConversationList !== false && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: `fusioni-conversation-backdrop ${isConversationListOpen ? 'open' : ''}`, onClick: () => setIsConversationListOpen(false) }), jsxRuntime.jsx(ConversationList, { conversations: conversations, selectedConversationId: currentConversation?.id || undefined, onSelectConversation: handleSelectConversation, onDeleteConversation: handleDeleteConversation, onCreateConversation: handleCreateConversation, isOpen: isConversationListOpen, currentLanguage: currentLanguage })] })), jsxRuntime.jsxs("div", { className: "fusioni-chat-main", children: [jsxRuntime.jsxs("div", { className: "fusioni-chat-main-header", children: [mergedConfig.showConversationList !== false ? (jsxRuntime.jsxs("button", { type: "button", onClick: handleToggleConversationList, className: `fusioni-conversation-toggle ${isConversationListOpen ? 'open' : ''}`, children: [jsxRuntime.jsx("svg", { className: "fusioni-conversation-toggle-icon", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: jsxRuntime.jsx("path", { d: "M3 12h18M3 6h18M3 18h18" }) }), t('chat.conversations.title')] })) : (jsxRuntime.jsx("span", { className: "fusioni-chat-main-header-title", children: t('chat.title') })), jsxRuntime.jsxs("div", { className: "fusioni-header-actions", children: [jsxRuntime.jsx("button", { type: "button", onClick: handleCreateConversation, disabled: isLoading, className: "fusioni-btn fusioni-btn-icon", title: t('chat.conversations.newConversation'), "aria-label": t('chat.conversations.newConversation'), children: jsxRuntime.jsx("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: jsxRuntime.jsx("path", { d: "M12 5V19M5 12H19", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }) }), mergedConfig.showThemeToggle !== false && (jsxRuntime.jsx("button", { type: "button", onClick: toggleTheme, className: "fusioni-btn fusioni-btn-icon", title: theme === 'dark' ? t('chat.theme.light') : t('chat.theme.dark'), children: theme === 'dark' ? (jsxRuntime.jsxs("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [jsxRuntime.jsx("circle", { cx: "12", cy: "12", r: "5" }), jsxRuntime.jsx("line", { x1: "12", y1: "1", x2: "12", y2: "3" }), jsxRuntime.jsx("line", { x1: "12", y1: "21", x2: "12", y2: "23" }), jsxRuntime.jsx("line", { x1: "4.22", y1: "4.22", x2: "5.64", y2: "5.64" }), jsxRuntime.jsx("line", { x1: "18.36", y1: "18.36", x2: "19.78", y2: "19.78" }), jsxRuntime.jsx("line", { x1: "1", y1: "12", x2: "3", y2: "12" }), jsxRuntime.jsx("line", { x1: "21", y1: "12", x2: "23", y2: "12" }), jsxRuntime.jsx("line", { x1: "4.22", y1: "19.78", x2: "5.64", y2: "18.36" }), jsxRuntime.jsx("line", { x1: "18.36", y1: "5.64", x2: "19.78", y2: "4.22" })] })) : (jsxRuntime.jsx("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: jsxRuntime.jsx("path", { d: "M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z" }) })) })), mergedConfig.showFullscreenToggle !== false && (jsxRuntime.jsx("button", { type: "button", onClick: handleToggleFullscreen, className: "fusioni-btn fusioni-btn-icon", title: isFullscreen ? t('chat.fullscreen.exit') : t('chat.fullscreen.enter'), children: isFullscreen ? (jsxRuntime.jsx("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: jsxRuntime.jsx("path", { d: "M8 3V5M8 3H5M8 3L3 8M16 3V5M16 3H19M16 3L21 8M8 21V19M8 21H5M8 21L3 16M16 21V19M16 21H19M16 21L21 16" }) })) : (jsxRuntime.jsx("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: jsxRuntime.jsx("path", { d: "M8 3H5C4.46957 3 3.96086 3.21071 3.58579 3.58579C3.21071 3.96086 3 4.46957 3 5V8M21 8V5C21 4.46957 20.7893 3.96086 20.4142 3.58579C20.0391 3.21071 19.5304 3 19 3H16M16 21H19C19.5304 21 20.0391 20.7893 20.4142 20.4142C20.7893 20.0391 21 19.5304 21 19V16M3 16V19C3 19.5304 3.21071 20.0391 3.58579 20.4142C3.96086 20.7893 4.46957 21 5 21H8" }) })) })), mergedConfig.showLanguageSwitcher !== false && (jsxRuntime.jsx(LanguageSwitcher, { currentLanguage: currentLanguage, onLanguageChange: handleLanguageChange })), jsxRuntime.jsx("button", { type: "button", onClick: () => setIsOpen(false), className: "fusioni-btn fusioni-btn-icon fusioni-chat-toolbar-close-mobile", title: t('common.close'), "aria-label": t('common.close'), children: jsxRuntime.jsx("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", "aria-hidden": "true", children: jsxRuntime.jsx("path", { d: "M18 6L6 18M6 6L18 18", strokeLinecap: "round", strokeLinejoin: "round" }) }) })] })] }), currentConversation ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(MessageList, { messages: messages, streamMessages: streamMessages, showThoughts: false, onDeleteMessage: handleDeleteMessage, onEditMessage: handleEditMessage, onConfirmation: handleConfirmation, enableButtons: !isLoading, apiBaseUrl: mergedConfig.apiBaseUrl, apiKey: mergedConfig.accessToken, agencyId: mergedConfig.agencyId, currentLanguage: currentLanguage, theme: theme }), jsxRuntime.jsx(ChatInput, { onSendMessage: handleSendMessage, onFileUpload: handleFileUpload, disabled: isLoading, placeholder: t('chat.input.placeholder'), enableAudioRecording: mergedConfig.enableAudioRecording !== false, enableFileUpload: mergedConfig.enableFileUpload !== false, maxFileSize: mergedConfig.maxFileSize || 10, allowedFileTypes: mergedConfig.allowedFileTypes || ['image/*'], currentLanguage: currentLanguage })] })) : (jsxRuntime.jsx("div", { className: "fusioni-chat-welcome", children: jsxRuntime.jsxs("div", { className: "fusioni-chat-welcome-content", children: [jsxRuntime.jsx("h3", { children: t('chat.welcome.title') }), jsxRuntime.jsx("p", { children: t('chat.welcome.description') }), jsxRuntime.jsx("button", { onClick: handleCreateConversation, disabled: isLoading, className: "fusioni-btn fusioni-btn-primary", children: isLoading ? t('chat.welcome.creating') : t('chat.welcome.startButton') })] }) }))] })] }) })), jsxRuntime.jsx(ConfirmationDialog, { isOpen: isDeleteDialogOpen, title: t('chat.conversations.deleteConfirm.title'), message: t('chat.conversations.deleteConfirm.message'), confirmText: t('chat.conversations.deleteConfirm.confirm'), cancelText: t('chat.conversations.deleteConfirm.cancel'), onConfirm: confirmDeleteConversation, onCancel: cancelDeleteConversation, currentLanguage: currentLanguage, variant: "danger" }), jsxRuntime.jsx(ConfirmationDialog, { isOpen: isDeleteMessageDialogOpen, title: t('chat.messages.deleteConfirm.title'), message: t('chat.messages.deleteConfirm.message'), confirmText: t('chat.messages.deleteConfirm.confirm'), cancelText: t('chat.messages.deleteConfirm.cancel'), onConfirm: confirmDeleteMessage, onCancel: cancelDeleteMessage, currentLanguage: currentLanguage, variant: "danger" })] }));
6596
6689
  });
6597
6690
  ChatWidget.displayName = 'ChatWidget';
6598
6691