@fusioni/client-sdk 1.1.2 → 1.1.5

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
@@ -4838,35 +4838,6 @@ const Map$1 = ({ lat, lng, zoom = 10, staticMap = true, width = 600, height = 40
4838
4838
  return (jsxRuntime.jsx("div", { className: "fusioni-map-container", children: staticMap ? (jsxRuntime.jsx("div", { className: "fusioni-map-static", children: jsxRuntime.jsx("img", { src: mapUrl, alt: `Map showing location at ${lat}, ${lng}`, width: width, height: height, className: "fusioni-map-image", onError: () => setError('Failed to load map image') }) })) : (jsxRuntime.jsx("div", { className: "fusioni-map-interactive", children: jsxRuntime.jsx("iframe", { src: mapUrl, width: width, height: height, style: { border: 0 }, loading: "lazy", allowFullScreen: true, title: `Map showing location at ${lat}, ${lng}`, className: "fusioni-map-iframe" }) })) }));
4839
4839
  };
4840
4840
 
4841
- const DURATION_MS = 2500;
4842
- const Spotlight = ({ text, className }) => {
4843
- const rootRef = react.useRef(null);
4844
- const startRef = react.useRef(0);
4845
- const frameRef = react.useRef(null);
4846
- react.useEffect(() => {
4847
- startRef.current = performance.now();
4848
- const tick = () => {
4849
- const elapsed = performance.now() - startRef.current;
4850
- const period = DURATION_MS * 2;
4851
- const t = (elapsed % period) / DURATION_MS;
4852
- const x = t <= 1 ? t * 100 : (2 - t) * 100;
4853
- const el = rootRef.current;
4854
- if (el) {
4855
- el.style.setProperty('--mask-x', `${x}%`);
4856
- el.style.setProperty('--mask-y', '50%');
4857
- }
4858
- frameRef.current = requestAnimationFrame(tick);
4859
- };
4860
- frameRef.current = requestAnimationFrame(tick);
4861
- return () => {
4862
- if (frameRef.current != null) {
4863
- cancelAnimationFrame(frameRef.current);
4864
- }
4865
- };
4866
- }, []);
4867
- return (jsxRuntime.jsx("div", { ref: rootRef, className: className ? `fusioni-spotlight ${className}` : 'fusioni-spotlight', children: jsxRuntime.jsxs("div", { className: "fusioni-spotlight-title", children: [jsxRuntime.jsx("span", { className: "fusioni-spotlight-text-base", children: text }), jsxRuntime.jsx("span", { className: "fusioni-spotlight-text-overlay", "aria-hidden": "true", children: text })] }) }));
4868
- };
4869
-
4870
4841
  const GALLERY_STRIP_MAX_ROWS = 2;
4871
4842
  /**
4872
4843
  * Horizontal slide of pages, each a grid with `columns` × {@link GALLERY_STRIP_MAX_ROWS} cells.
@@ -4971,7 +4942,7 @@ const DocumentVideoGrid = ({ videos, attachedVideosLabel, }) => {
4971
4942
  // Module-level Set to track which message IDs have been animated
4972
4943
  // This persists across component unmounts/remounts (e.g., when chat closes and reopens)
4973
4944
  const animatedMessageIds = new Set();
4974
- const Message = ({ message, showThoughts = false, fontSize = 'text-sm', onDelete, onConfirmation, enableButtons = true, streamMessages = [], apiBaseUrl, apiKey, agencyId, currentLanguage = 'en', onOpenGallery }) => {
4945
+ const Message = ({ message, showThoughts = false, fontSize = 'text-sm', onDelete, onConfirmation, enableButtons = true, streamLoading, apiBaseUrl, apiKey, agencyId, currentLanguage = 'en', onOpenGallery }) => {
4975
4946
  const { t } = useTranslation(currentLanguage);
4976
4947
  const [displayedContent, setDisplayedContent] = react.useState('');
4977
4948
  const typingIntervalRef = react.useRef(null);
@@ -5203,14 +5174,50 @@ const Message = ({ message, showThoughts = false, fontSize = 'text-sm', onDelete
5203
5174
  const contentToDisplay = message.shouldAnimate
5204
5175
  ? displayedContent
5205
5176
  : message.content;
5177
+ const extractedUrls = react.useMemo(() => extractUrlsFromContent(message.content), [message.content]);
5206
5178
  return (jsxRuntime.jsxs("div", { className: getMessageClasses(), children: [message.content && !message.loading && (jsxRuntime.jsx("div", { className: "fusioni-message-text", dangerouslySetInnerHTML: {
5207
5179
  __html: enhanceMessageContent(contentToDisplay)
5208
- } })), message.loading && (jsxRuntime.jsx("div", { className: "fusioni-stream-messages", children: (streamMessages.length > 0 ? streamMessages : [t('chat.messages.loading')]).map((line, index) => (jsxRuntime.jsxs("div", { className: "fusioni-stream-message-item", children: [jsxRuntime.jsx("div", { className: "fusioni-stream-message-logo-wrap", children: jsxRuntime.jsx("div", { className: "fusioni-stream-message-logo-frame", children: jsxRuntime.jsx("img", { className: "fusioni-stream-message-logo-img", src: FUSIONI_LOGO_BASE64, alt: "", width: 32, height: 32 }) }) }), jsxRuntime.jsx(Spotlight, { className: "fusioni-stream-message-spotlight", text: line })] }, streamMessages.length > 0 ? `${index}-${line}` : 'loading-placeholder'))) })), !message.loading && extractUrlsFromContent(message.content).length > 0 && message.role !== 'user' && (jsxRuntime.jsx("div", { className: "fusioni-message-url-previews", children: extractUrlsFromContent(message.content).map((url, index) => (jsxRuntime.jsx(UrlPreview, { url: url, agencyId: agencyId, showCloseButton: false, compact: true, autoFetch: true, apiBaseUrl: apiBaseUrl, apiKey: apiKey }, `${url}-${index}`))) })), message.extra_data && (jsxRuntime.jsxs("div", { className: "fusioni-message-extra m2", children: [message.extra_data.document_images &&
5180
+ } })), message.loading && streamLoading, !message.loading && extractedUrls.length > 0 && message.role !== 'user' && (jsxRuntime.jsx("div", { className: "fusioni-message-url-previews", children: extractedUrls.map((url) => (jsxRuntime.jsx(UrlPreview, { url: url, agencyId: agencyId, showCloseButton: false, compact: true, autoFetch: true, apiBaseUrl: apiBaseUrl, apiKey: apiKey }, url))) })), message.extra_data && (jsxRuntime.jsxs("div", { className: "fusioni-message-extra m2", children: [message.extra_data.document_images &&
5209
5181
  message.extra_data.document_images.length > 0 &&
5210
5182
  onOpenGallery && (jsxRuntime.jsx(DocumentImageGrid, { images: message.extra_data.document_images, onOpenGallery: onOpenGallery, attachedImagesLabel: t('chat.attachedImages') })), message.extra_data.document_videos &&
5211
5183
  message.extra_data.document_videos.length > 0 && (jsxRuntime.jsx(DocumentVideoGrid, { videos: message.extra_data.document_videos, attachedVideosLabel: t('chat.attachedVideos') })), message.extra_data.image && renderImage(message.extra_data.image), message.extra_data.image_ref && renderImage(message.extra_data.image_ref), message.extra_data.audio_ref && renderAudio(message.extra_data.audio_ref, message.extra_data.duration), message.extra_data.coordinates && renderMap(message.extra_data.coordinates), message.extra_data.map && (jsxRuntime.jsx("div", { className: "fusioni-message-map", children: jsxRuntime.jsx(Map$1, { lat: message.extra_data.map.lat, lng: message.extra_data.map.lng, zoom: message.extra_data.map.zoom, staticMap: true, width: 600, height: 400, apiBaseUrl: apiBaseUrl, apiKey: apiKey, agencyId: agencyId }) }))] })), message.extra_data?.widget === 'Confirmation' && (jsxRuntime.jsxs("div", { className: "fusioni-confirmation-widget", children: [jsxRuntime.jsx("button", { type: "button", disabled: !enableButtons, onClick: () => sendConfirmation('Confirmed', message.extra_data?.key), className: "fusioni-btn fusioni-btn-primary fusioni-btn-confirm", children: t('common.yes') }), jsxRuntime.jsx("button", { type: "button", disabled: !enableButtons, onClick: () => sendConfirmation('NotConfirmed', message.extra_data?.key), className: "fusioni-btn fusioni-btn-secondary fusioni-btn-cancel", children: t('common.no') })] })), showThoughts && message.thoughts && (jsxRuntime.jsx("div", { className: "fusioni-message-thoughts", children: jsxRuntime.jsxs("details", { children: [jsxRuntime.jsx("summary", { children: "AI Thoughts" }), jsxRuntime.jsx("p", { children: message.thoughts })] }) })), message.has_error && (jsxRuntime.jsxs("div", { className: "fusioni-message-error-indicator", children: [jsxRuntime.jsxs("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", children: [jsxRuntime.jsx("circle", { cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "2" }), jsxRuntime.jsx("line", { x1: "15", y1: "9", x2: "9", y2: "15", stroke: "currentColor", strokeWidth: "2" }), jsxRuntime.jsx("line", { x1: "9", y1: "9", x2: "15", y2: "15", stroke: "currentColor", strokeWidth: "2" })] }), jsxRuntime.jsx("span", { children: "Error occurred" })] }))] }));
5212
5184
  };
5213
5185
 
5186
+ const DURATION_MS = 2500;
5187
+ const Spotlight = ({ text, className }) => {
5188
+ const rootRef = react.useRef(null);
5189
+ const startRef = react.useRef(0);
5190
+ const frameRef = react.useRef(null);
5191
+ react.useEffect(() => {
5192
+ startRef.current = performance.now();
5193
+ const tick = () => {
5194
+ const elapsed = performance.now() - startRef.current;
5195
+ const period = DURATION_MS * 2;
5196
+ const t = (elapsed % period) / DURATION_MS;
5197
+ const x = t <= 1 ? t * 100 : (2 - t) * 100;
5198
+ const el = rootRef.current;
5199
+ if (el) {
5200
+ el.style.setProperty('--mask-x', `${x}%`);
5201
+ el.style.setProperty('--mask-y', '50%');
5202
+ }
5203
+ frameRef.current = requestAnimationFrame(tick);
5204
+ };
5205
+ frameRef.current = requestAnimationFrame(tick);
5206
+ return () => {
5207
+ if (frameRef.current != null) {
5208
+ cancelAnimationFrame(frameRef.current);
5209
+ }
5210
+ };
5211
+ }, []);
5212
+ return (jsxRuntime.jsx("div", { ref: rootRef, className: className ? `fusioni-spotlight ${className}` : 'fusioni-spotlight', children: jsxRuntime.jsxs("div", { className: "fusioni-spotlight-title", children: [jsxRuntime.jsx("span", { className: "fusioni-spotlight-text-base", children: text }), jsxRuntime.jsx("span", { className: "fusioni-spotlight-text-overlay", "aria-hidden": "true", children: text })] }) }));
5213
+ };
5214
+
5215
+ /** Logo + Spotlight: SSE stream lines, or loading label until first stream event */
5216
+ const MessageStreamLoading = ({ streamMessages, loadingLabel, }) => {
5217
+ const lines = streamMessages.length > 0 ? streamMessages : [loadingLabel];
5218
+ return (jsxRuntime.jsx("div", { className: "fusioni-stream-messages", children: lines.map((line, index) => (jsxRuntime.jsxs("div", { className: "fusioni-stream-message-item", children: [jsxRuntime.jsx("div", { className: "fusioni-stream-message-logo-wrap", children: jsxRuntime.jsx("div", { className: "fusioni-stream-message-logo-frame", children: jsxRuntime.jsx("img", { className: "fusioni-stream-message-logo-img", src: FUSIONI_LOGO_BASE64, alt: "", width: 32, height: 32 }) }) }), jsxRuntime.jsx(Spotlight, { className: "fusioni-stream-message-spotlight", text: line })] }, streamMessages.length > 0 ? `${index}-${line}` : 'loading-placeholder'))) }));
5219
+ };
5220
+
5214
5221
  /**
5215
5222
  * Full-screen image lightbox: main image + prev/next, keyboard nav,
5216
5223
  * and a two-row thumbnail strip with horizontal pages and dot indicators (fusioni-web parity).
@@ -5325,6 +5332,7 @@ const ImageGallery = ({ images, initialIndex = 0, onClose, theme = 'light', }) =
5325
5332
  };
5326
5333
 
5327
5334
  const MessageList = ({ messages, streamMessages, showThoughts = false, onDeleteMessage, onEditMessage, onConfirmation, enableButtons = true, apiBaseUrl, apiKey, agencyId, currentLanguage = 'en', theme = 'light' }) => {
5335
+ const { t } = useTranslation(currentLanguage);
5328
5336
  const messagesEndRef = react.useRef(null);
5329
5337
  const scrollContainerRef = react.useRef(null);
5330
5338
  const editRef = react.useRef(null);
@@ -5427,7 +5435,7 @@ const MessageList = ({ messages, streamMessages, showThoughts = false, onDeleteM
5427
5435
  event.preventDefault();
5428
5436
  cancelEdit();
5429
5437
  }
5430
- } })) : (jsxRuntime.jsx(Message, { message: message, showThoughts: showThoughts, onDelete: onDeleteMessage, onConfirmation: onConfirmation, enableButtons: enableButtons && isLastMessage, streamMessages: message.loading ? streamMessages : [], apiBaseUrl: apiBaseUrl, apiKey: apiKey, agencyId: agencyId, currentLanguage: currentLanguage, onOpenGallery: openGallery })) }), jsxRuntime.jsxs("div", { className: "fusioni-message-footer", children: [jsxRuntime.jsx("span", { className: "fusioni-message-time", children: formatDate(message.created) }), message.id && (onDeleteMessage || (message.role === 'user' && onEditMessage)) && (jsxRuntime.jsx("div", { className: "fusioni-message-actions", children: message.role === 'user' && editingMessageId === message.id ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("button", { onClick: confirmEdit, className: "fusioni-btn fusioni-btn-icon", title: "Save edit", children: jsxRuntime.jsx("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", children: jsxRuntime.jsx("polyline", { points: "20 6 9 17 4 12", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }) }), jsxRuntime.jsx("button", { onClick: cancelEdit, className: "fusioni-btn fusioni-btn-icon", title: "Cancel edit", children: jsxRuntime.jsxs("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", children: [jsxRuntime.jsx("line", { x1: "18", y1: "6", x2: "6", y2: "18", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }), jsxRuntime.jsx("line", { x1: "6", y1: "6", x2: "18", y2: "18", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" })] }) })] })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [message.role === 'user' && onEditMessage && (jsxRuntime.jsx("button", { onClick: () => startEdit(message), className: "fusioni-btn fusioni-btn-icon", title: "Edit message", children: jsxRuntime.jsxs("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", children: [jsxRuntime.jsx("path", { d: "M12 20H21", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }), jsxRuntime.jsx("path", { d: "M16.5 3.5C16.8978 3.10218 17.4374 2.87868 18 2.87868C18.5626 2.87868 19.1022 3.10218 19.5 3.5C19.8978 3.89782 20.1213 4.43739 20.1213 5C20.1213 5.56261 19.8978 6.10218 19.5 6.5L7 19L3 20L4 16L16.5 3.5Z", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" })] }) })), onDeleteMessage && (jsxRuntime.jsx("button", { onClick: () => onDeleteMessage(message.id), className: "fusioni-btn fusioni-btn-icon", title: "Delete message", children: jsxRuntime.jsxs("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", children: [jsxRuntime.jsx("path", { d: "M3 6H5H21", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }), jsxRuntime.jsx("path", { d: "M8 6V4C8 3.46957 8.21071 2.96086 8.58579 2.58579C8.96086 2.21071 9.46957 2 10 2H14C14.5304 2 15.0391 2.21071 15.4142 2.58579C15.7893 2.96086 16 3.46957 16 4V6M19 6V20C19 20.5304 18.7893 21.0391 18.4142 21.4142C18.0391 21.7893 17.5304 22 17 22H7C6.46957 22 5.96086 21.7893 5.58579 21.4142C5.21071 21.0391 5 20.5304 5 20V6H19Z", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" })] }) }))] })) }))] }), showThoughts && message.thoughts && (jsxRuntime.jsx("div", { className: "fusioni-message-thoughts", children: jsxRuntime.jsxs("details", { children: [jsxRuntime.jsx("summary", { children: "Thoughts" }), jsxRuntime.jsx("p", { children: message.thoughts })] }) }))] })] }) }, messageKey));
5438
+ } })) : (jsxRuntime.jsx(Message, { message: message, showThoughts: showThoughts, onDelete: onDeleteMessage, onConfirmation: onConfirmation, enableButtons: enableButtons && isLastMessage, streamLoading: message.loading ? (jsxRuntime.jsx(MessageStreamLoading, { streamMessages: streamMessages, loadingLabel: t('chat.messages.loading') })) : undefined, apiBaseUrl: apiBaseUrl, apiKey: apiKey, agencyId: agencyId, currentLanguage: currentLanguage, onOpenGallery: openGallery })) }), jsxRuntime.jsxs("div", { className: "fusioni-message-footer", children: [jsxRuntime.jsx("span", { className: "fusioni-message-time", children: formatDate(message.created) }), message.id && (onDeleteMessage || (message.role === 'user' && onEditMessage)) && (jsxRuntime.jsx("div", { className: "fusioni-message-actions", children: message.role === 'user' && editingMessageId === message.id ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("button", { onClick: confirmEdit, className: "fusioni-btn fusioni-btn-icon", title: "Save edit", children: jsxRuntime.jsx("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", children: jsxRuntime.jsx("polyline", { points: "20 6 9 17 4 12", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }) }), jsxRuntime.jsx("button", { onClick: cancelEdit, className: "fusioni-btn fusioni-btn-icon", title: "Cancel edit", children: jsxRuntime.jsxs("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", children: [jsxRuntime.jsx("line", { x1: "18", y1: "6", x2: "6", y2: "18", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }), jsxRuntime.jsx("line", { x1: "6", y1: "6", x2: "18", y2: "18", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" })] }) })] })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [message.role === 'user' && onEditMessage && (jsxRuntime.jsx("button", { onClick: () => startEdit(message), className: "fusioni-btn fusioni-btn-icon", title: "Edit message", children: jsxRuntime.jsxs("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", children: [jsxRuntime.jsx("path", { d: "M12 20H21", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }), jsxRuntime.jsx("path", { d: "M16.5 3.5C16.8978 3.10218 17.4374 2.87868 18 2.87868C18.5626 2.87868 19.1022 3.10218 19.5 3.5C19.8978 3.89782 20.1213 4.43739 20.1213 5C20.1213 5.56261 19.8978 6.10218 19.5 6.5L7 19L3 20L4 16L16.5 3.5Z", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" })] }) })), onDeleteMessage && (jsxRuntime.jsx("button", { onClick: () => onDeleteMessage(message.id), className: "fusioni-btn fusioni-btn-icon", title: "Delete message", children: jsxRuntime.jsxs("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", children: [jsxRuntime.jsx("path", { d: "M3 6H5H21", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }), jsxRuntime.jsx("path", { d: "M8 6V4C8 3.46957 8.21071 2.96086 8.58579 2.58579C8.96086 2.21071 9.46957 2 10 2H14C14.5304 2 15.0391 2.21071 15.4142 2.58579C15.7893 2.96086 16 3.46957 16 4V6M19 6V20C19 20.5304 18.7893 21.0391 18.4142 21.4142C18.0391 21.7893 17.5304 22 17 22H7C6.46957 22 5.96086 21.7893 5.58579 21.4142C5.21071 21.0391 5 20.5304 5 20V6H19Z", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" })] }) }))] })) }))] }), showThoughts && message.thoughts && (jsxRuntime.jsx("div", { className: "fusioni-message-thoughts", children: jsxRuntime.jsxs("details", { children: [jsxRuntime.jsx("summary", { children: "Thoughts" }), jsxRuntime.jsx("p", { children: message.thoughts })] }) }))] })] }) }, messageKey));
5431
5439
  }) })), jsxRuntime.jsx("div", { ref: messagesEndRef })] }) }), gallerySession &&
5432
5440
  typeof document !== 'undefined' &&
5433
5441
  reactDom.createPortal(jsxRuntime.jsx(ImageGallery, { images: gallerySession.images, initialIndex: gallerySession.index, theme: theme, onClose: () => setGallerySession(null) }, gallerySession.key), document.body)] }));
@@ -6011,6 +6019,24 @@ const useTheme = (initialTheme) => {
6011
6019
  };
6012
6020
  };
6013
6021
 
6022
+ /** Matches `index.css` mobile breakpoint for chat layout. */
6023
+ const MOBILE_MEDIA_QUERY = '(max-width: 768px)';
6024
+ function useIsMobileLayout() {
6025
+ const [isMobile, setIsMobile] = react.useState(() => {
6026
+ if (typeof window === 'undefined')
6027
+ return false;
6028
+ return window.matchMedia(MOBILE_MEDIA_QUERY).matches;
6029
+ });
6030
+ react.useEffect(() => {
6031
+ const mq = window.matchMedia(MOBILE_MEDIA_QUERY);
6032
+ const onChange = () => setIsMobile(mq.matches);
6033
+ onChange();
6034
+ mq.addEventListener('change', onChange);
6035
+ return () => mq.removeEventListener('change', onChange);
6036
+ }, []);
6037
+ return isMobile;
6038
+ }
6039
+
6014
6040
  const ChatWidget = ({ config, onMessageSent, onMessageReceived, onConversationCreated, onConversationDeleted, onError }) => {
6015
6041
  const [isOpen, setIsOpen] = react.useState(false);
6016
6042
  const [isLoading, setIsLoading] = react.useState(false);
@@ -6030,6 +6056,7 @@ const ChatWidget = ({ config, onMessageSent, onMessageReceived, onConversationCr
6030
6056
  const { t, currentLanguage, changeLanguage } = useTranslation(mergedConfig?.language || config.language || 'en');
6031
6057
  const { conversations, currentConversation, messages, streamMessages, setCurrentConversation, setStreamMessages, addMessage, updateMessage, removeMessage, removeOptimisticUserMessages, truncateMessagesAt, addConversation, updateConversation, removeConversation, loadConversations, loadMessages, clearMessages } = useChatState(mergedConfig?.agencyId || config.agencyId);
6032
6058
  const { theme, toggleTheme } = useTheme(mergedConfig?.theme || config.theme);
6059
+ const isMobileLayout = useIsMobileLayout();
6033
6060
  // Initialize API client and fetch server configuration
6034
6061
  react.useEffect(() => {
6035
6062
  const initializeAndFetchConfig = async () => {
@@ -6517,7 +6544,7 @@ const ChatWidget = ({ config, onMessageSent, onMessageReceived, onConversationCr
6517
6544
  // Debug: Log the primary color and button variant being applied
6518
6545
  console.log('Primary color being applied:', mergedConfig.primaryColor || '#6366f1');
6519
6546
  console.log('Button variant being applied:', mergedConfig.buttonVariant || 'glass');
6520
- 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 }), 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: [mergedConfig.showConversationList !== false && (jsxRuntime.jsxs("div", { className: "fusioni-chat-main-header", children: [jsxRuntime.jsxs("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.jsxs("div", { className: "fusioni-header-actions", children: [jsxRuntime.jsx("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" }) })) }), jsxRuntime.jsx("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" }) })) }), jsxRuntime.jsx(LanguageSwitcher, { currentLanguage: currentLanguage, onLanguageChange: changeLanguage })] })] })), 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" })] }));
6547
+ 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" }) }) })), 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" }) })) }), 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" }) })) }), jsxRuntime.jsx(LanguageSwitcher, { currentLanguage: currentLanguage, onLanguageChange: changeLanguage })] })] }), 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" })] }));
6521
6548
  };
6522
6549
 
6523
6550
  const FileUpload = ({ onFileSelect, accept = 'image/*', maxSize = 10, disabled = false, className = '' }) => {
@@ -6577,6 +6604,7 @@ exports.getTranslation = getTranslation;
6577
6604
  exports.initializeApiClient = initializeApiClient;
6578
6605
  exports.isValidLanguage = isValidLanguage;
6579
6606
  exports.useChatState = useChatState;
6607
+ exports.useIsMobileLayout = useIsMobileLayout;
6580
6608
  exports.useSSE = useSSE;
6581
6609
  exports.useTheme = useTheme;
6582
6610
  exports.useTranslation = useTranslation;