@topconsultnpm/sdkui-react 6.22.0-dev3.32 → 6.22.0-dev3.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/lib/components/NewComponents/ContextMenu/styles.d.ts +43 -45
  2. package/lib/components/NewComponents/FloatingMenuBar/styles.d.ts +60 -67
  3. package/lib/components/base/Styled.d.ts +77 -93
  4. package/lib/components/base/TMCounterBar.d.ts +2 -2
  5. package/lib/components/base/TMCounterContainer.d.ts +1 -2
  6. package/lib/components/base/TMCustomButton.d.ts +1 -1
  7. package/lib/components/base/TMDataGridExportForm.d.ts +1 -2
  8. package/lib/components/base/TMFileManager.d.ts +1 -2
  9. package/lib/components/base/TMFileManagerDataGridView.d.ts +1 -2
  10. package/lib/components/base/TMFileManagerThumbnailItems.d.ts +1 -1
  11. package/lib/components/base/TMFileManagerThumbnailsView.d.ts +1 -1
  12. package/lib/components/base/TMFileManagerUtils.d.ts +6 -4
  13. package/lib/components/base/TMLayout.d.ts +4 -4
  14. package/lib/components/base/TMList.d.ts +1 -2
  15. package/lib/components/base/TMListView.d.ts +1 -1
  16. package/lib/components/base/TMSpinner.d.ts +2 -3
  17. package/lib/components/base/TMTab.d.ts +3 -4
  18. package/lib/components/base/TMTabControl.js +208 -208
  19. package/lib/components/base/TMTooltip.d.ts +1 -1
  20. package/lib/components/base/TMTreeView.d.ts +8 -14
  21. package/lib/components/base/TMUserAvatar.d.ts +1 -2
  22. package/lib/components/base/TMVilViewer.d.ts +1 -2
  23. package/lib/components/base/TMWaitPanel.d.ts +2 -3
  24. package/lib/components/base/waitPanel/TMWaitPanelView.d.ts +1 -2
  25. package/lib/components/choosers/TMDynDataListItemChooser.d.ts +1 -1
  26. package/lib/components/choosers/TMInvoiceRetrieveFormats.d.ts +1 -2
  27. package/lib/components/choosers/TMOrderRetrieveFormats.d.ts +1 -2
  28. package/lib/components/choosers/TMQuickSearchInfo.d.ts +1 -2
  29. package/lib/components/choosers/TMRelationChooser.d.ts +3 -3
  30. package/lib/components/choosers/TMUserChooser.d.ts +2 -2
  31. package/lib/components/editors/TMEditorStyled.d.ts +42 -20
  32. package/lib/components/editors/TMFormulaEditor.d.ts +1 -1
  33. package/lib/components/editors/TMHtmlContentDisplay.d.ts +1 -2
  34. package/lib/components/editors/TMHtmlEditor.d.ts +1 -2
  35. package/lib/components/editors/TMTreeDropDown.d.ts +1 -1
  36. package/lib/components/features/assistant/TMHelpOnLineChat.d.ts +1 -0
  37. package/lib/components/features/assistant/TMHelpOnLineChat.js +975 -498
  38. package/lib/components/features/assistant/TMToppyDraggableHelpCenter.d.ts +1 -1
  39. package/lib/components/features/assistant/dataset/Designer-Suggested-Questions.json +102 -0
  40. package/lib/components/features/assistant/dataset/Login-Suggested-Questions.json +32 -0
  41. package/lib/components/features/assistant/dataset/Surfer-Suggested-Questions.json +102 -0
  42. package/lib/components/features/blog/TMBlogCommentForm.d.ts +1 -2
  43. package/lib/components/features/documents/TMDcmtFormActionButtons.d.ts +1 -1
  44. package/lib/components/features/documents/TMDcmtIcon.d.ts +1 -2
  45. package/lib/components/features/documents/TMDcmtPreview.d.ts +6 -8
  46. package/lib/components/features/documents/TMDcmtTasks.d.ts +1 -2
  47. package/lib/components/features/documents/TMDragDropOverlay.d.ts +1 -1
  48. package/lib/components/features/documents/TMFileUploader.js +21 -21
  49. package/lib/components/features/documents/TMMasterInfoFields.d.ts +1 -2
  50. package/lib/components/features/documents/TMMergeToPdfForm.d.ts +1 -2
  51. package/lib/components/features/documents/TMMultiMasterDetailDcmtsForm.d.ts +1 -2
  52. package/lib/components/features/documents/TMMultiMasterDetailDcmtsUtils.d.ts +4 -4
  53. package/lib/components/features/search/TMDcmtCheckoutInfoForm.d.ts +1 -2
  54. package/lib/components/features/search/TMMetadataOutputForm.d.ts +1 -2
  55. package/lib/components/features/search/TMMetadataSorterForm.d.ts +1 -2
  56. package/lib/components/features/search/TMSavedQuerySelector.d.ts +2 -2
  57. package/lib/components/features/search/TMSearch.d.ts +1 -2
  58. package/lib/components/features/search/TMSearchQueryPanel.d.ts +3 -9
  59. package/lib/components/features/search/TMSearchResultFloatingActionButton.d.ts +1 -1
  60. package/lib/components/features/search/TMSignatureInfoContent.d.ts +1 -2
  61. package/lib/components/features/search/TMViewHistoryDcmt.d.ts +1 -2
  62. package/lib/components/features/tasks/TMTaskForm.d.ts +1 -1
  63. package/lib/components/features/tasks/TMTaskFormUtils.d.ts +10 -10
  64. package/lib/components/features/tasks/TMTasksAgenda.d.ts +1 -1
  65. package/lib/components/features/tasks/TMTasksCalendar.d.ts +1 -1
  66. package/lib/components/features/tasks/TMTasksHeader.d.ts +1 -1
  67. package/lib/components/features/tasks/TMTasksPanelContent.d.ts +1 -1
  68. package/lib/components/features/tasks/TMTasksUtilsView.d.ts +5 -5
  69. package/lib/components/features/tasks/TMTasksView.d.ts +1 -1
  70. package/lib/components/features/wg/TMWGsCopyMoveForm.d.ts +2 -3
  71. package/lib/components/features/workflow/TMWorkflowPopup.d.ts +7 -8
  72. package/lib/components/features/workflow/diagram/WorkitemRecipientsEditor.d.ts +1 -3
  73. package/lib/components/forms/Login/ChangePasswordInputs.d.ts +1 -3
  74. package/lib/components/forms/Login/Chooser.d.ts +2 -2
  75. package/lib/components/forms/TMChooserForm.d.ts +1 -2
  76. package/lib/components/forms/TMSaveForm.d.ts +4 -4
  77. package/lib/components/grids/TMBlogAttachments.d.ts +1 -2
  78. package/lib/components/grids/TMBlogHeader.d.ts +1 -1
  79. package/lib/components/grids/TMBlogsPost.d.ts +1 -1
  80. package/lib/components/grids/TMBlogsPostUtils.d.ts +9 -9
  81. package/lib/components/grids/TMValidationItemsList.d.ts +1 -2
  82. package/lib/components/layout/panelManager/TMPanelManagerContainer.d.ts +1 -2
  83. package/lib/components/layout/panelManager/TMPanelManagerContext.d.ts +2 -2
  84. package/lib/components/layout/panelManager/TMPanelManagerToolbar.d.ts +6 -5
  85. package/lib/components/layout/panelManager/TMPanelManagerWithPersistenceProvider.d.ts +2 -2
  86. package/lib/components/layout/panelManager/TMPanelWrapper.d.ts +2 -2
  87. package/lib/components/pages/TMPage.d.ts +1 -1
  88. package/lib/components/query/TMQueryEditor.d.ts +10 -14
  89. package/lib/components/settings/SettingsAppearance.d.ts +1 -2
  90. package/lib/components/sidebar/TMAboutApp.d.ts +1 -2
  91. package/lib/components/sidebar/TMCommandsPanel.d.ts +4 -4
  92. package/lib/components/sidebar/TMHeader.d.ts +3 -3
  93. package/lib/components/viewers/TMDataListItemViewer.d.ts +2 -3
  94. package/lib/components/viewers/TMDataUserIdItemViewer.d.ts +2 -3
  95. package/lib/components/viewers/TMMidViewer.d.ts +2 -2
  96. package/lib/components/viewers/TMTidViewer.d.ts +2 -2
  97. package/lib/helper/TMAppUpdatedModal.d.ts +1 -2
  98. package/lib/helper/TMAppUpdatedModal.js +93 -93
  99. package/lib/helper/TMCommandsContextMenu.d.ts +1 -1
  100. package/lib/helper/TMIcons.d.ts +280 -280
  101. package/lib/helper/TMPdfViewer.d.ts +1 -2
  102. package/lib/helper/TMToppyMessage.d.ts +2 -2
  103. package/lib/helper/TMUtils.d.ts +4 -10
  104. package/lib/helper/helpers.d.ts +1 -1
  105. package/lib/hooks/useInputDialog.d.ts +1 -2
  106. package/lib/services/platform_services.d.ts +2 -3
  107. package/package.json +1 -1
@@ -1,11 +1,15 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useCallback, useEffect, useRef, useState } from 'react';
3
3
  import styled, { keyframes } from 'styled-components';
4
- import { HolAskDescriptor, SDK_Globals, TopMediaServer } from '@topconsultnpm/sdk-ts';
4
+ import { locale as dxLocale } from 'devextreme/localization';
5
+ import { AppModules, CultureIDs, HolAskDescriptor, SDK_Globals, TopMediaServer } from '@topconsultnpm/sdk-ts';
5
6
  import TMTooltip from '../../base/TMTooltip';
6
7
  import { TMColors } from '../../../utils/theme';
7
8
  import { SDKUI_Localizator } from '../../../helper';
8
9
  import ToppyImage from '../../../assets/Toppy-help-center.png';
10
+ import LoginSuggestedQuestions from './dataset/Login-Suggested-Questions.json';
11
+ import SurferSuggestedQuestions from './dataset/Surfer-Suggested-Questions.json';
12
+ import DesignerSuggestedQuestions from './dataset/Designer-Suggested-Questions.json';
9
13
  const generateGUID = () => {
10
14
  return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replaceAll(/[xy]/g, (c) => {
11
15
  const r = Math.trunc(Math.random() * 16);
@@ -16,6 +20,56 @@ const generateGUID = () => {
16
20
  const PANEL_DEFAULT_WIDTH = 600;
17
21
  const PANEL_MIN_WIDTH = 340;
18
22
  const PANEL_MAX_WIDTH = 900;
23
+ const SUGGESTIONS_COUNT = 4;
24
+ const FEEDBACK_MAX_LENGTH = 200;
25
+ const NO_ANSWER_TEXT = 'Nessuna risposta ricevuta.';
26
+ const ERROR_TEXT = 'Si è verificato un errore, riprova più tardi.';
27
+ const FEEDBACK_TAGS = {
28
+ like: ['Aggiornata', 'Accurata', 'Utile', 'Pertinente', 'Fonti affidabili', 'Altro'],
29
+ dislike: ['Non aggiornata', 'Imprecisa', 'Troppo lunga', 'Troppo corta', 'Fonti non affidabili', 'Inappropriata', 'Altro'],
30
+ };
31
+ const FEEDBACK_TITLES = {
32
+ like: 'Cosa ti è piaciuto di questa risposta?',
33
+ dislike: 'Cosa non ha funzionato in questa risposta?',
34
+ };
35
+ const copyToClipboard = async (text) => {
36
+ try {
37
+ if (globalThis.isSecureContext && navigator.clipboard?.writeText) {
38
+ await navigator.clipboard.writeText(text);
39
+ return true;
40
+ }
41
+ const textarea = document.createElement('textarea');
42
+ textarea.value = text;
43
+ textarea.setAttribute('readonly', '');
44
+ textarea.style.position = 'fixed';
45
+ textarea.style.opacity = '0';
46
+ document.body.appendChild(textarea);
47
+ textarea.select();
48
+ const copied = document.execCommand('copy');
49
+ document.body.removeChild(textarea);
50
+ return copied;
51
+ }
52
+ catch {
53
+ return false;
54
+ }
55
+ };
56
+ const getDefaultSuggestedQuestions = (isLogged) => {
57
+ if (!isLogged)
58
+ return LoginSuggestedQuestions;
59
+ switch (SDK_Globals.appModule) {
60
+ case AppModules.SURFER: return SurferSuggestedQuestions;
61
+ case AppModules.DESIGNER: return DesignerSuggestedQuestions;
62
+ default: return [];
63
+ }
64
+ };
65
+ const pickRandom = (items, count) => {
66
+ const pool = [...items];
67
+ for (let i = pool.length - 1; i > 0; i--) {
68
+ const j = Math.floor(Math.random() * (i + 1));
69
+ [pool[i], pool[j]] = [pool[j], pool[i]];
70
+ }
71
+ return pool.slice(0, count);
72
+ };
19
73
  const getSafeSession = () => {
20
74
  try {
21
75
  return SDK_Globals.tmSession;
@@ -24,6 +78,15 @@ const getSafeSession = () => {
24
78
  return undefined;
25
79
  }
26
80
  };
81
+ const DX_LOCALE_TO_CULTURE_ID = {
82
+ de: CultureIDs.De_DE,
83
+ en: CultureIDs.En_US,
84
+ es: CultureIDs.Es_ES,
85
+ fr: CultureIDs.Fr_FR,
86
+ it: CultureIDs.It_IT,
87
+ pt: CultureIDs.Pt_PT,
88
+ };
89
+ const getCurrentCultureId = () => DX_LOCALE_TO_CULTURE_ID[dxLocale().split('-')[0]] ?? getSafeSession()?.SessionDescr?.cultureID;
27
90
  let preLoginSession;
28
91
  let preLoginSessionUrl;
29
92
  const getPreLoginSession = (endpointUrl) => {
@@ -37,10 +100,15 @@ const getPreLoginSession = (endpointUrl) => {
37
100
  }
38
101
  return preLoginSession;
39
102
  };
40
- const TMHelpOnLineChat = ({ isOpen, showChatButton, isLogged, messages, conversationId, isThinking, endpointUrl, onClose, onToggle, onNewConversation, onAddMessage, onSetThinking, onSetConversationId }) => {
103
+ const TMHelpOnLineChat = ({ isOpen, showChatButton, isLogged, messages, conversationId, isThinking, endpointUrl, onClose, onToggle, onNewConversation, onAddMessage, onSetThinking, onSetConversationId, suggestedQuestions }) => {
41
104
  const [width, setWidth] = useState(PANEL_DEFAULT_WIDTH);
42
105
  const showFab = !isLogged && showChatButton && !isOpen;
43
- return (_jsxs(_Fragment, { children: [isOpen && (_jsxs(_Fragment, { children: [_jsx(Overlay, { onClick: onClose }), _jsx(ChatPanel, { width: width, onWidthChange: setWidth, messages: messages, conversationId: conversationId, isThinking: isThinking, endpointUrl: endpointUrl, onClose: onClose, onNewConversation: onNewConversation, onAddMessage: onAddMessage, onSetThinking: onSetThinking, onSetConversationId: onSetConversationId })] })), showFab && (_jsx(Fab, { onClick: onToggle, title: "Chiedi a Toppy", "aria-label": "Chiedi a Toppy", children: _jsx(FabAvatar, { src: ToppyImage, alt: "Toppy" }) }))] }));
106
+ const questions = suggestedQuestions ?? getDefaultSuggestedQuestions(isLogged);
107
+ const [submittedRatings, setSubmittedRatings] = useState({});
108
+ const onFeedbackSubmitted = useCallback((messageId, rating) => {
109
+ setSubmittedRatings(prev => ({ ...prev, [messageId]: rating }));
110
+ }, []);
111
+ return (_jsxs(_Fragment, { children: [isOpen && (_jsxs(_Fragment, { children: [_jsx(Overlay, { onClick: onClose }), _jsx(ChatPanel, { width: width, onWidthChange: setWidth, messages: messages, conversationId: conversationId, isThinking: isThinking, endpointUrl: endpointUrl, onClose: onClose, onNewConversation: onNewConversation, onAddMessage: onAddMessage, onSetThinking: onSetThinking, onSetConversationId: onSetConversationId, suggestedQuestions: questions, isLogged: isLogged, submittedRatings: submittedRatings, onFeedbackSubmitted: onFeedbackSubmitted })] })), showFab && (_jsx(Fab, { onClick: onToggle, title: "Chiedi a Toppy", "aria-label": "Chiedi a Toppy", children: _jsx(FabAvatar, { src: ToppyImage, alt: "Toppy" }) }))] }));
44
112
  };
45
113
  export default TMHelpOnLineChat;
46
114
  //#region Header button
@@ -49,8 +117,11 @@ export const TMToppyHeaderButton = ({ showChatButton, onToggle }) => {
49
117
  return null;
50
118
  return (_jsx(TMTooltip, { content: "Chiedi a Toppy", children: _jsxs(ToppyHeaderButton, { onClick: onToggle, title: "Chiedi a Toppy", children: [_jsx(ToppyHeaderAvatar, { src: ToppyImage, alt: "Toppy" }), _jsx(ToppyHeaderText, { children: "Chiedi a Toppy" })] }) }));
51
119
  };
52
- const ChatPanel = ({ width, onWidthChange, messages, conversationId, isThinking, endpointUrl, onClose, onNewConversation, onAddMessage, onSetThinking, onSetConversationId }) => {
120
+ const ChatPanel = ({ width, onWidthChange, messages, conversationId, isThinking, endpointUrl, onClose, onNewConversation, onAddMessage, onSetThinking, onSetConversationId, suggestedQuestions, isLogged, submittedRatings, onFeedbackSubmitted }) => {
53
121
  const [chatInput, setChatInput] = useState('');
122
+ const [suggestions, setSuggestions] = useState(() => pickRandom(suggestedQuestions, SUGGESTIONS_COUNT));
123
+ const [hoveredSuggestion, setHoveredSuggestion] = useState(undefined);
124
+ const prevMessagesCountRef = useRef(messages.length);
54
125
  const inputRef = useRef(null);
55
126
  const messagesEndRef = useRef(null);
56
127
  const onCloseRef = useRef(onClose);
@@ -62,6 +133,12 @@ const ChatPanel = ({ width, onWidthChange, messages, conversationId, isThinking,
62
133
  useEffect(() => {
63
134
  inputRef.current?.focus();
64
135
  }, []);
136
+ useEffect(() => {
137
+ if (messages.length === 0 && prevMessagesCountRef.current > 0) {
138
+ setSuggestions(pickRandom(suggestedQuestions, SUGGESTIONS_COUNT));
139
+ }
140
+ prevMessagesCountRef.current = messages.length;
141
+ }, [messages.length, suggestedQuestions]);
65
142
  useEffect(() => {
66
143
  const onKeyDown = (e) => {
67
144
  if (e.key === 'Escape')
@@ -90,8 +167,8 @@ const ChatPanel = ({ width, onWidthChange, messages, conversationId, isThinking,
90
167
  globalThis.addEventListener('mousemove', onMove);
91
168
  globalThis.addEventListener('mouseup', onUp);
92
169
  }, [width, onWidthChange]);
93
- const askHandler = useCallback(async () => {
94
- const question = chatInput.trim();
170
+ const ask = useCallback(async (text) => {
171
+ const question = text.trim();
95
172
  if (question.length < 2 || isThinking) {
96
173
  return;
97
174
  }
@@ -124,17 +201,41 @@ const ChatPanel = ({ width, onWidthChange, messages, conversationId, isThinking,
124
201
  else {
125
202
  console.error('[HOL] NO SESSION -> nothing called. endpointUrl =', endpointUrl);
126
203
  }
127
- onAddMessage({ id: generateGUID(), text: answer || 'Nessuna risposta ricevuta.', isUser: false });
204
+ onAddMessage({ id: generateGUID(), text: answer || NO_ANSWER_TEXT, isUser: false });
128
205
  }
129
206
  catch (error) {
130
- onAddMessage({ id: generateGUID(), text: 'Si è verificato un errore, riprova più tardi.', isUser: false });
207
+ onAddMessage({ id: generateGUID(), text: ERROR_TEXT, isUser: false });
131
208
  console.error('[HOL]', error);
132
209
  }
133
210
  finally {
134
211
  onSetThinking(false);
135
212
  }
136
- }, [chatInput, conversationId, isThinking, endpointUrl, onAddMessage, onSetThinking, onSetConversationId]);
137
- return (_jsxs(PanelContainer, { $width: width, children: [_jsx(ResizeHandle, { onMouseDown: onResizeStart }), _jsxs(ChatHeader, { children: [_jsxs(HeaderLeft, { children: [_jsx(ToppyAvatar, { src: ToppyImage, alt: "Toppy" }), _jsxs(HeaderText, { children: [_jsxs(HeaderGreeting, { children: ["Ciao ", userName] }), _jsx(HeaderQuestion, { children: "Come posso aiutarti?" })] })] }), _jsxs(HeaderRight, { children: [_jsx(TMTooltip, { content: "Nuova conversazione", children: _jsx(HeaderButton, { onClick: onNewConversation, disabled: !conversationId && messages.length === 0, title: "Nuova conversazione", children: _jsx(IconNewChat, { color: "white", fontSize: 18 }) }) }), _jsx(TMTooltip, { content: "Chiudi", children: _jsx(HeaderButton, { onClick: onClose, title: "Chiudi", children: _jsx(IconClose, { fontSize: 18 }) }) })] })] }), _jsxs(ChatBody, { children: [messages.length === 0 ? (_jsxs(WelcomeMessage, { children: [_jsx(WelcomeIcon, { children: "\uD83D\uDCA1" }), _jsxs(WelcomeText, { children: ["Ciao! Sono ", _jsx("strong", { children: "Toppy" }), ", il tuo assistente.", _jsx("br", {}), "Fai una domanda e ti aiuter\u00F2 a trovare la risposta."] })] })) : (messages.map(msg => (_jsxs(MessageBubble, { $isUser: msg.isUser, children: [!msg.isUser && _jsx(BotAvatar, { src: ToppyImage, alt: "Toppy" }), _jsx(MessageContent, { $isUser: msg.isUser, children: msg.isUser ? msg.text : _jsx(MarkdownContent, { children: renderMarkdown(msg.text) }) })] }, msg.id)))), isThinking && (_jsxs(MessageBubble, { $isUser: false, children: [_jsx(BotAvatar, { src: ToppyImage, alt: "Toppy" }), _jsx(ThinkingStatus, {}, messages.length)] })), _jsx("div", { ref: messagesEndRef })] }), _jsxs(ChatFooter, { children: [_jsx(TMChatInput, { inputRef: inputRef, value: chatInput, onChange: setChatInput, onSend: askHandler, placeholder: "Scrivi la tua domanda...", tooltip: "Invia", disabled: isThinking }), _jsx(FooterHint, { children: SDKUI_Localizator.HelpOnLineShiftEnterHint })] })] }));
213
+ }, [conversationId, isThinking, endpointUrl, onAddMessage, onSetThinking, onSetConversationId]);
214
+ const askHandler = useCallback(() => ask(chatInput), [ask, chatInput]);
215
+ const onSuggestionClick = (question) => {
216
+ setHoveredSuggestion(undefined);
217
+ ask(question);
218
+ };
219
+ const onFeedbackSubmit = (index, rating, tags, feedback) => {
220
+ const answer = messages[index];
221
+ const question = messages.slice(0, index).reverse().find(m => m.isUser)?.text ?? '';
222
+ const session = getSafeSession();
223
+ console.log('[HOL] feedback', {
224
+ userName: session?.SessionDescr?.userName ?? '',
225
+ app: isLogged ? SDK_Globals.appModule : 'LOGIN',
226
+ cultureId: getCurrentCultureId(),
227
+ question,
228
+ answer: answer.text,
229
+ rating,
230
+ tags,
231
+ feedback,
232
+ conversationId,
233
+ timestamp: new Date().toISOString(),
234
+ });
235
+ onFeedbackSubmitted(answer.id, rating);
236
+ };
237
+ const showSuggestions = messages.length === 0 && !isThinking && suggestions.length > 0;
238
+ return (_jsxs(PanelContainer, { $width: width, children: [_jsx(ResizeHandle, { onMouseDown: onResizeStart }), _jsxs(ChatHeader, { children: [_jsxs(HeaderLeft, { children: [_jsx(ToppyAvatar, { src: ToppyImage, alt: "Toppy" }), _jsxs(HeaderText, { children: [_jsxs(HeaderGreeting, { children: ["Ciao ", userName] }), _jsx(HeaderQuestion, { children: "Come posso aiutarti?" })] })] }), _jsxs(HeaderRight, { children: [_jsx(TMTooltip, { content: "Nuova conversazione", children: _jsx(HeaderButton, { onClick: onNewConversation, disabled: !conversationId && messages.length === 0, title: "Nuova conversazione", children: _jsx(IconNewChat, { color: "white", fontSize: 18 }) }) }), _jsx(TMTooltip, { content: "Chiudi", children: _jsx(HeaderButton, { onClick: onClose, title: "Chiudi", children: _jsx(IconClose, { fontSize: 18 }) }) })] })] }), _jsxs(ChatBody, { children: [messages.length === 0 ? (_jsxs(WelcomeMessage, { children: [_jsx(WelcomeIcon, { children: "\uD83D\uDCA1" }), _jsxs(WelcomeText, { children: ["Ciao! Sono ", _jsx("strong", { children: "Toppy" }), ", il tuo assistente.", _jsx("br", {}), "Fai una domanda e ti aiuter\u00F2 a trovare la risposta."] })] })) : (messages.map((msg, index) => (_jsxs(MessageBubble, { $isUser: msg.isUser, children: [!msg.isUser && _jsx(BotAvatar, { src: ToppyImage, alt: "Toppy" }), msg.isUser ? (_jsx(MessageContent, { $isUser: true, children: msg.text })) : (_jsxs(BotMessageColumn, { children: [_jsx(BotMessageContent, { $isUser: false, children: _jsx(MarkdownContent, { children: renderMarkdown(msg.text) }) }), msg.text !== NO_ANSWER_TEXT && msg.text !== ERROR_TEXT && (_jsx(MessageFeedback, { answer: msg.text, submittedRating: submittedRatings[msg.id], onSubmit: (rating, tags, feedback) => onFeedbackSubmit(index, rating, tags, feedback) }))] }))] }, msg.id)))), isThinking && (_jsxs(MessageBubble, { $isUser: false, children: [_jsx(BotAvatar, { src: ToppyImage, alt: "Toppy" }), _jsx(ThinkingStatus, {}, messages.length)] })), _jsx("div", { ref: messagesEndRef })] }), _jsxs(ChatFooter, { children: [showSuggestions && (_jsxs(SuggestionsSection, { children: [_jsxs(SuggestionsTitle, { children: [_jsx(IconSparkle, { fontSize: 14 }), _jsx("span", { children: "Domande suggerite" })] }), _jsx(SuggestionsGrid, { children: suggestions.map((question, index) => (_jsxs(SuggestionCard, { type: "button", $index: index, title: question, onClick: () => onSuggestionClick(question), onMouseEnter: () => setHoveredSuggestion(question), onMouseLeave: () => setHoveredSuggestion(undefined), onFocus: () => setHoveredSuggestion(question), onBlur: () => setHoveredSuggestion(undefined), children: [_jsx(SuggestionIcon, { children: _jsx(IconQuestion, { fontSize: 16 }) }), _jsx(SuggestionText, { children: question }), _jsx(SuggestionArrow, { children: _jsx(IconArrowForward, { fontSize: 16 }) })] }, question))) })] })), _jsx(TMChatInput, { inputRef: inputRef, value: chatInput, onChange: setChatInput, onSend: askHandler, placeholder: hoveredSuggestion ?? 'Scrivi la tua domanda...', tooltip: "Invia", disabled: isThinking }), _jsx(FooterHint, { children: SDKUI_Localizator.HelpOnLineShiftEnterHint })] })] }));
138
239
  };
139
240
  const TMChatInput = ({ value, onChange, onSend, placeholder = 'Scrivi la tua domanda...', disabled = false, inputRef, tooltip = 'Ricerca AI' }) => {
140
241
  const isDisabled = disabled || value.length < 2;
@@ -149,6 +250,50 @@ const TMChatInput = ({ value, onChange, onSend, placeholder = 'Scrivi la tua dom
149
250
  }
150
251
  } }), _jsx(TMTooltip, { content: tooltip, children: _jsx(InlineSendButton, { $disabled: isDisabled, disabled: isDisabled, onClick: onSend, title: tooltip, children: _jsx(IconSendFilled, { fontSize: 20 }) }) })] }));
151
252
  };
253
+ const MessageFeedback = ({ answer, submittedRating, onSubmit }) => {
254
+ const [draftRating, setDraftRating] = useState(undefined);
255
+ const [selectedTags, setSelectedTags] = useState([]);
256
+ const [feedback, setFeedback] = useState('');
257
+ const [copied, setCopied] = useState(false);
258
+ const copiedTimerRef = useRef();
259
+ useEffect(() => () => clearTimeout(copiedTimerRef.current), []);
260
+ const isSubmitted = submittedRating !== undefined;
261
+ const activeRating = submittedRating ?? draftRating;
262
+ const canSubmit = draftRating === 'like' || selectedTags.length > 0 || feedback.trim().length > 0;
263
+ const resetDraft = () => {
264
+ setDraftRating(undefined);
265
+ setSelectedTags([]);
266
+ setFeedback('');
267
+ };
268
+ const onRatingClick = (rating) => {
269
+ if (isSubmitted)
270
+ return;
271
+ if (draftRating === rating) {
272
+ resetDraft();
273
+ return;
274
+ }
275
+ setDraftRating(rating);
276
+ setSelectedTags([]);
277
+ };
278
+ const onTagClick = (tag) => {
279
+ setSelectedTags(prev => prev.includes(tag) ? prev.filter(t => t !== tag) : [...prev, tag]);
280
+ };
281
+ const onCopyClick = async () => {
282
+ if (!(await copyToClipboard(answer)))
283
+ return;
284
+ setCopied(true);
285
+ clearTimeout(copiedTimerRef.current);
286
+ copiedTimerRef.current = setTimeout(() => setCopied(false), 2000);
287
+ };
288
+ const onSubmitClick = () => {
289
+ if (!draftRating || !canSubmit)
290
+ return;
291
+ onSubmit(draftRating, selectedTags, feedback.trim());
292
+ resetDraft();
293
+ };
294
+ return (_jsxs(FeedbackContainer, { children: [_jsxs(FeedbackActions, { children: [_jsx(TMTooltip, { content: "Mi piace", children: _jsx(FeedbackActionButton, { type: "button", $active: activeRating === 'like', $locked: isSubmitted, disabled: isSubmitted && submittedRating !== 'like', "aria-pressed": activeRating === 'like', "aria-label": "Mi piace", onClick: () => onRatingClick('like'), children: _jsx(IconThumbUp, { fontSize: 16 }) }) }), _jsx(TMTooltip, { content: "Non mi piace", children: _jsx(FeedbackActionButton, { type: "button", $active: activeRating === 'dislike', $locked: isSubmitted, disabled: isSubmitted && submittedRating !== 'dislike', "aria-pressed": activeRating === 'dislike', "aria-label": "Non mi piace", onClick: () => onRatingClick('dislike'), children: _jsx(IconThumbUp, { fontSize: 16, style: { transform: 'rotate(180deg)' } }) }) }), _jsx(TMTooltip, { content: copied ? 'Copiato' : 'Copia', children: _jsx(FeedbackActionButton, { type: "button", $active: false, $locked: false, $success: copied, "aria-label": "Copia", onClick: onCopyClick, children: copied ? _jsx(IconCheck, { fontSize: 16 }) : _jsx(IconCopy, { fontSize: 16 }) }) }), isSubmitted && (_jsxs(SentBadge, { role: "status", children: [_jsx(IconCheck, { fontSize: 12 }), "Inviato"] }))] }), !isSubmitted && draftRating && (_jsxs(FeedbackPanel, { children: [_jsxs(FeedbackPanelHeader, { children: [_jsx(FeedbackPanelTitle, { children: FEEDBACK_TITLES[draftRating] }), _jsx(FeedbackCloseButton, { type: "button", "aria-label": "Chiudi", title: "Chiudi", onClick: resetDraft, children: _jsx(IconClose, { fontSize: 16 }) })] }), _jsx(FeedbackLabel, { children: "Era..." }), _jsx(FeedbackTags, { children: FEEDBACK_TAGS[draftRating].map(tag => (_jsx(FeedbackTag, { type: "button", $selected: selectedTags.includes(tag), "aria-pressed": selectedTags.includes(tag), onClick: () => onTagClick(tag), children: tag }, tag))) }), _jsx(FeedbackLabel, { children: "Feedback aggiuntivo" }), _jsx(FeedbackTextarea, { value: feedback, maxLength: FEEDBACK_MAX_LENGTH, placeholder: "Raccontaci di pi\u00F9", onChange: (e) => setFeedback(e.target.value.slice(0, FEEDBACK_MAX_LENGTH)), onKeyDown: (e) => { if (e.key === 'Enter')
295
+ e.stopPropagation(); } }), _jsxs(FeedbackPanelFooter, { children: [_jsxs(FeedbackCounter, { $full: feedback.length >= FEEDBACK_MAX_LENGTH, children: [feedback.length, "/", FEEDBACK_MAX_LENGTH] }), _jsx(FeedbackSubmitButton, { type: "button", disabled: !canSubmit, onClick: onSubmitClick, children: "Invia" })] })] }, draftRating))] }));
296
+ };
152
297
  //#endregion
153
298
  //#region Thinking status (phrases + elapsed seconds)
154
299
  const getThinkingPhrases = () => [
@@ -395,494 +540,826 @@ function IconSendFilled(props) {
395
540
  function IconNewChat(props) {
396
541
  return (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "1em", height: "1em", fill: props.color || "currentColor", ...props, children: _jsx("path", { d: "M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm0 14H6l-2 2V4h16v12z" }) }));
397
542
  }
543
+ function IconSparkle(props) {
544
+ return (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "1em", height: "1em", fill: "currentColor", ...props, children: _jsx("path", { d: "M19 9l1.25-2.75L23 5l-2.75-1.25L19 1l-1.25 2.75L15 5l2.75 1.25L19 9zm-7.5.5L9 4 6.5 9.5 1 12l5.5 2.5L9 20l2.5-5.5L17 12l-5.5-2.5zM19 15l-1.25 2.75L15 19l2.75 1.25L19 23l1.25-2.75L23 19l-2.75-1.25L19 15z" }) }));
545
+ }
546
+ function IconQuestion(props) {
547
+ return (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "1em", height: "1em", fill: "currentColor", ...props, children: _jsx("path", { d: "M11 18h2v-2h-2v2zm1-16C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm0-14c-2.21 0-4 1.79-4 4h2c0-1.1.9-2 2-2s2 .9 2 2c0 2-3 1.75-3 5h2c0-2.25 3-2.5 3-5 0-2.21-1.79-4-4-4z" }) }));
548
+ }
549
+ function IconArrowForward(props) {
550
+ return (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "1em", height: "1em", fill: "currentColor", ...props, children: _jsx("path", { d: "M12 4l-1.41 1.41L16.17 11H4v2h12.17l-5.58 5.59L12 20l8-8z" }) }));
551
+ }
552
+ function IconThumbUp(props) {
553
+ return (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "1em", height: "1em", fill: "currentColor", ...props, children: _jsx("path", { d: "M9 21h9c.83 0 1.54-.5 1.84-1.22l3.02-7.05c.09-.23.14-.47.14-.73v-2c0-1.1-.9-2-2-2h-6.31l.95-4.57.03-.32c0-.41-.17-.79-.44-1.06L14.17 1 7.58 7.59C7.22 7.95 7 8.45 7 9v10c0 1.1.9 2 2 2zM9 9l4.34-4.34L12 10h9v2l-3 7H9V9zM1 9h4v12H1z" }) }));
554
+ }
555
+ function IconCopy(props) {
556
+ return (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "1em", height: "1em", fill: "currentColor", ...props, children: _jsx("path", { d: "M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z" }) }));
557
+ }
558
+ function IconCheck(props) {
559
+ return (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "1em", height: "1em", fill: "currentColor", ...props, children: _jsx("path", { d: "M9 16.17 4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z" }) }));
560
+ }
398
561
  //#endregion
399
562
  //#region Styled Components
400
- const fadeIn = keyframes `
401
- from { opacity: 0; }
402
- to { opacity: 1; }
403
- `;
404
- const slideInRight = keyframes `
405
- from { transform: translateX(100%); }
406
- to { transform: translateX(0); }
407
- `;
408
- const phraseIn = keyframes `
409
- from { opacity: 0; transform: translateY(4px); }
410
- to { opacity: 1; transform: translateY(0); }
411
- `;
412
- const dotCycle = keyframes `
413
- 0% { opacity: 0; }
414
- 25%, 75% { opacity: 1; }
415
- 100% { opacity: 0; }
416
- `;
417
- const ToppyHeaderButton = styled.button `
418
- display: flex;
419
- align-items: center;
420
- gap: 8px;
421
- height: 36px;
422
- padding: 0 14px 0 5px;
423
- border-radius: 18px;
424
- border: 1px solid ${TMColors.primary}35;
425
- background: ${TMColors.primary}0d;
426
- color: ${TMColors.primary};
427
- font-size: 13px;
428
- font-weight: 600;
429
- white-space: nowrap;
430
- cursor: pointer;
431
- flex-shrink: 0;
432
- transition: all 0.2s ease;
433
-
434
- &:hover {
435
- background: ${TMColors.primary}1a;
436
- border-color: ${TMColors.primary}66;
437
- transform: translateY(-1px);
438
- box-shadow: 0 4px 12px ${TMColors.primary}25;
439
- }
440
- &:active { transform: translateY(0); }
441
- `;
442
- const ToppyHeaderAvatar = styled.img `
443
- width: 28px;
444
- height: 28px;
445
- border-radius: 50%;
446
- object-fit: contain;
447
- pointer-events: none;
448
- `;
449
- const ToppyHeaderText = styled.span `
450
- line-height: 1;
451
- `;
452
- const Fab = styled.button `
453
- position: fixed;
454
- bottom: 24px;
455
- right: 24px;
456
- width: 60px;
457
- height: 60px;
458
- border-radius: 50%;
459
- border: none;
460
- padding: 0;
461
- cursor: pointer;
462
- display: flex;
463
- align-items: center;
464
- justify-content: center;
465
- background: white;
466
- box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
467
- z-index: 100000;
468
- transition: transform 0.2s ease, box-shadow 0.2s ease;
469
- animation: ${fadeIn} 0.3s ease-out;
470
-
471
- &:hover { transform: scale(1.08); box-shadow: 0 8px 26px rgba(0, 0, 0, 0.3); }
472
- &:active { transform: scale(0.96); }
473
- `;
474
- const FabAvatar = styled.img `
475
- width: 52px;
476
- height: 52px;
477
- border-radius: 50%;
478
- object-fit: contain;
479
- pointer-events: none;
480
- `;
481
- const Overlay = styled.div `
482
- position: fixed;
483
- inset: 0;
484
- background: rgba(0, 0, 0, 0.45);
485
- z-index: 100000;
486
- animation: ${fadeIn} 0.2s ease-out;
487
- `;
488
- const PanelContainer = styled.div `
489
- position: fixed;
490
- top: 0;
491
- right: 0;
492
- height: 100vh;
493
- width: ${props => props.$width}px;
494
- max-width: 100vw;
495
- background: white;
496
- display: flex;
497
- flex-direction: column;
498
- box-shadow: -8px 0 32px rgba(0, 0, 0, 0.28);
499
- z-index: 100001;
500
- animation: ${slideInRight} 0.25s ease-out;
501
- `;
502
- const ResizeHandle = styled.div `
503
- position: absolute;
504
- left: 0;
505
- top: 0;
506
- bottom: 0;
507
- width: 6px;
508
- cursor: col-resize;
509
- background: transparent;
510
- z-index: 2;
511
- transition: background 0.2s ease;
512
-
513
- &:hover { background: ${TMColors.primary}55; }
514
- `;
515
- const ChatHeader = styled.div `
516
- display: flex;
517
- align-items: center;
518
- justify-content: space-between;
519
- padding: 16px 20px;
520
- background: linear-gradient(135deg, ${TMColors.primary} 0%, ${TMColors.primary}dd 100%);
521
- color: white;
522
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
523
- `;
524
- const HeaderLeft = styled.div `
525
- display: flex;
526
- align-items: center;
527
- gap: 12px;
528
- flex: 1;
529
- min-width: 0;
530
- `;
531
- const HeaderRight = styled.div `
532
- display: flex;
533
- align-items: center;
534
- gap: 8px;
535
- margin-left: 12px;
536
- flex-shrink: 0;
537
- `;
538
- const ToppyAvatar = styled.img `
539
- width: 44px;
540
- height: 44px;
541
- border-radius: 50%;
542
- background: white;
543
- padding: 4px;
544
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
545
- flex-shrink: 0;
546
- object-fit: contain;
547
- `;
548
- const HeaderText = styled.div `
549
- display: flex;
550
- flex-direction: column;
551
- gap: 2px;
552
- min-width: 0;
553
- `;
554
- const HeaderGreeting = styled.h2 `
555
- margin: 0;
556
- font-size: 17px;
557
- font-weight: 600;
558
- color: white;
559
- white-space: nowrap;
560
- overflow: hidden;
561
- text-overflow: ellipsis;
562
- `;
563
- const HeaderQuestion = styled.p `
564
- margin: 0;
565
- font-size: 13px;
566
- color: rgba(255, 255, 255, 0.9);
567
- `;
568
- const HeaderButton = styled.button `
569
- width: 32px;
570
- height: 32px;
571
- border-radius: 50%;
572
- background: rgba(255, 255, 255, 0.2);
573
- border: 1px solid rgba(255, 255, 255, 0.3);
574
- color: white;
575
- cursor: pointer;
576
- display: flex;
577
- align-items: center;
578
- justify-content: center;
579
- flex-shrink: 0;
580
- transition: all 0.2s ease;
581
-
582
- &:hover:not(:disabled) { background: rgba(255, 255, 255, 0.3); transform: scale(1.05); }
583
- &:active:not(:disabled) { transform: scale(0.95); }
584
- &:disabled { opacity: 0.45; cursor: default; }
585
- `;
586
- const ChatBody = styled.div `
587
- flex: 1;
588
- padding: 20px;
589
- overflow-y: auto;
590
- background: linear-gradient(to bottom, #f8f9fa 0%, #ffffff 100%);
591
- `;
592
- const WelcomeMessage = styled.div `
593
- display: flex;
594
- gap: 16px;
595
- padding: 18px;
596
- background: white;
597
- border-radius: 12px;
598
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
599
- border-left: 4px solid ${TMColors.primary};
600
- animation: ${fadeIn} 0.5s ease-out;
601
- `;
602
- const WelcomeIcon = styled.div `
603
- font-size: 30px;
604
- flex-shrink: 0;
605
- `;
606
- const WelcomeText = styled.p `
607
- margin: 0;
608
- font-size: 14px;
609
- line-height: 1.6;
610
- color: #242424;
611
-
612
- strong { color: ${TMColors.primary}; font-weight: 600; }
613
- `;
614
- const MessageBubble = styled.div `
615
- display: flex;
616
- gap: 10px;
617
- margin-bottom: 16px;
618
- align-items: flex-start;
619
- justify-content: ${props => (props.$isUser ? 'flex-end' : 'flex-start')};
620
- animation: ${fadeIn} 0.3s ease-out;
621
- `;
622
- const BotAvatar = styled.img `
623
- width: 32px;
624
- height: 32px;
625
- border-radius: 50%;
626
- background: white;
627
- padding: 2px;
628
- box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
629
- flex-shrink: 0;
630
- object-fit: contain;
631
- `;
632
- const MessageContent = styled.div `
633
- max-width: 80%;
634
- padding: 10px 14px;
635
- border-radius: 12px;
636
- font-size: 14px;
637
- line-height: 1.5;
638
- background: ${props => (props.$isUser ? TMColors.primary : '#f0f2f5')};
639
- color: ${props => (props.$isUser ? 'white' : '#242424')};
640
- box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
641
- word-wrap: break-word;
642
- overflow-wrap: anywhere;
643
- white-space: ${props => (props.$isUser ? 'pre-wrap' : 'normal')};
644
- border-bottom-${props => (props.$isUser ? 'right' : 'left')}-radius: 4px;
645
- `;
646
- const MarkdownContent = styled.div `
647
- & > *:first-child { margin-top: 0; }
648
- & > *:last-child { margin-bottom: 0; }
649
-
650
- a { color: ${TMColors.primary}; text-decoration: underline; }
651
- strong { font-weight: 600; }
652
- `;
653
- const MdParagraph = styled.p `
654
- margin: 0 0 8px 0;
655
- line-height: 1.55;
656
- `;
657
- const MdHeading = styled.div `
658
- margin: 12px 0 6px 0;
659
- font-weight: 700;
660
- line-height: 1.3;
661
- font-size: ${props => `${Math.max(14, 20 - (props.$level - 1) * 2)}px`};
662
- `;
663
- const MdUl = styled.ul `
664
- margin: 4px 0 8px 0;
665
- padding-left: 20px;
666
- li { margin: 2px 0; line-height: 1.5; }
667
- `;
668
- const MdOl = styled.ol `
669
- margin: 4px 0 8px 0;
670
- padding-left: 22px;
671
- li { margin: 2px 0; line-height: 1.5; }
672
- `;
673
- const MdCode = styled.code `
674
- background: rgba(0, 0, 0, 0.06);
675
- padding: 1px 5px;
676
- border-radius: 4px;
677
- font-family: 'Consolas', 'Monaco', monospace;
678
- font-size: 0.9em;
679
- `;
680
- const MdPre = styled.pre `
681
- background: rgba(0, 0, 0, 0.06);
682
- padding: 10px 12px;
683
- border-radius: 8px;
684
- overflow-x: auto;
685
- margin: 8px 0;
686
- font-family: 'Consolas', 'Monaco', monospace;
687
- font-size: 0.88em;
688
- white-space: pre;
689
- `;
690
- const MdTableWrapper = styled.div `
691
- margin: 8px 0;
692
- max-width: 100%;
693
- overflow-x: auto;
694
- border: 1px solid #dcdfe3;
695
- border-radius: 8px;
696
-
697
- &::-webkit-scrollbar { height: 6px; }
698
- &::-webkit-scrollbar-track { background: transparent; }
699
- &::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }
700
- &::-webkit-scrollbar-thumb:hover { background: #999; }
701
- `;
702
- const MdTable = styled.table `
703
- border-collapse: collapse;
704
- width: 100%;
705
- font-size: 0.92em;
706
- background: white;
707
- `;
708
- const MdTh = styled.th `
709
- padding: 7px 10px;
710
- background: ${TMColors.primary}14;
711
- color: #242424;
712
- font-weight: 600;
713
- text-align: ${props => props.$align ?? 'left'};
714
- border-bottom: 1px solid #dcdfe3;
715
- white-space: nowrap;
716
-
717
- &:not(:last-child) { border-right: 1px solid #e6e8eb; }
718
- `;
719
- const MdTd = styled.td `
720
- padding: 7px 10px;
721
- text-align: ${props => props.$align ?? 'left'};
722
- vertical-align: top;
723
- border-top: 1px solid #eceef0;
724
-
725
- &:not(:last-child) { border-right: 1px solid #eceef0; }
726
-
727
- tr:nth-child(even) & { background: #fafbfc; }
728
- `;
729
- const MdBlockquote = styled.blockquote `
730
- margin: 8px 0;
731
- padding: 6px 12px;
732
- border-left: 3px solid ${TMColors.primary}66;
733
- background: ${TMColors.primary}0a;
734
- border-radius: 0 6px 6px 0;
735
- color: #444;
736
-
737
- & > *:first-child { margin-top: 0; }
738
- & > *:last-child { margin-bottom: 0; }
739
- `;
740
- const MdHr = styled.hr `
741
- border: none;
742
- border-top: 1px solid #dcdfe3;
743
- margin: 12px 0;
744
- `;
745
- const ThinkingIndicator = styled.div `
746
- display: flex;
747
- align-items: center;
748
- gap: 10px;
749
- max-width: 80%;
750
- padding: 7px 12px;
751
- background: #f0f2f5;
752
- border-radius: 12px;
753
- border-bottom-left-radius: 4px;
754
- box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
755
- `;
756
- const ThinkingCaption = styled.div `
757
- display: flex;
758
- flex-direction: column;
759
- align-items: flex-start;
760
- gap: 0;
761
- min-width: 0;
762
- `;
763
- const ThinkingPhrase = styled.span `
764
- display: inline-flex;
765
- align-items: center;
766
- min-width: 0;
767
- font-size: 12px;
768
- font-style: italic;
769
- line-height: 1.15;
770
- color: #6b7280;
771
- animation: ${phraseIn} 0.25s ease-out;
772
- `;
773
- const ThinkingDots = styled.span `
774
- display: inline-flex;
775
- width: 12px;
776
- flex-shrink: 0;
777
- `;
778
- const ThinkingDot = styled.span `
779
- animation: ${dotCycle} 1.2s linear infinite;
780
- animation-delay: ${props => props.$delay}s;
781
- will-change: opacity;
782
-
783
- @media (prefers-reduced-motion: reduce) {
784
- animation: none;
785
- opacity: 1;
786
- }
787
- `;
788
- const ThinkingCounter = styled.span `
789
- margin-top: 2px;
790
- font-size: 10px;
791
- font-weight: 600;
792
- line-height: 1.1;
793
- letter-spacing: 0.02em;
794
- color: ${TMColors.primary}b3;
795
- font-variant-numeric: tabular-nums;
796
- font-feature-settings: 'tnum';
797
- opacity: ${props => (props.$visible ? 1 : 0)};
798
- transition: opacity 0.3s ease;
799
- `;
800
- const ChatFooter = styled.div `
801
- padding: 16px 20px;
802
- background: white;
803
- border-top: 1px solid #e1e5e9;
804
- box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05);
805
- `;
806
- const FooterHint = styled.p `
807
- margin: 6px 0 0 0;
808
- font-size: 11px;
809
- color: #999;
810
- text-align: center;
811
- `;
812
- const ChatInputWrapper = styled.div `
813
- position: relative;
814
- flex: 1;
815
- display: flex;
816
- `;
817
- const ChatInputTextarea = styled.textarea `
818
- width: 100%;
819
- padding: 14px 60px 14px 16px;
820
- border: 2px solid #e1e5e9;
821
- border-radius: 12px;
822
- font-size: 15px;
823
- font-family: inherit;
824
- line-height: 1.5;
825
- transition: all 0.2s ease;
826
- background: #f8f9fa;
827
- resize: none;
828
- min-height: 100px;
829
- max-height: 120px;
830
- overflow-y: hidden;
831
-
832
- &:focus {
833
- outline: none;
834
- border-color: ${TMColors.primary};
835
- background: white;
836
- box-shadow: 0 0 0 4px ${TMColors.primary}15;
837
- }
838
-
839
- &::placeholder {
840
- color: #999;
841
- }
842
-
843
- &::-webkit-scrollbar {
844
- width: 6px;
845
- }
846
-
847
- &::-webkit-scrollbar-track {
848
- background: transparent;
849
- }
850
-
851
- &::-webkit-scrollbar-thumb {
852
- background: #ccc;
853
- border-radius: 3px;
854
- }
855
-
856
- &::-webkit-scrollbar-thumb:hover {
857
- background: #999;
858
- }
859
- `;
860
- const InlineSendButton = styled.button `
861
- position: absolute;
862
- bottom: 8px;
863
- right: 8px;
864
- width: 40px;
865
- height: 40px;
866
- border-radius: 10px;
867
- background: ${props => props.$disabled ? '#ccc' : '#4caf50'};
868
- border: none;
869
- color: white;
870
- cursor: ${props => props.$disabled ? 'default' : 'pointer'};
871
- display: flex;
872
- align-items: center;
873
- justify-content: center;
874
- transition: all 0.2s ease;
875
-
876
- &:hover:not(:disabled) {
877
- background: #45a049;
878
- transform: scale(1.05);
879
- }
880
-
881
- &:active:not(:disabled) {
882
- transform: scale(0.95);
883
- }
884
-
885
- &:disabled {
886
- opacity: 0.6;
887
- }
563
+ const fadeIn = keyframes `
564
+ from { opacity: 0; }
565
+ to { opacity: 1; }
566
+ `;
567
+ const slideInRight = keyframes `
568
+ from { transform: translateX(100%); }
569
+ to { transform: translateX(0); }
570
+ `;
571
+ const phraseIn = keyframes `
572
+ from { opacity: 0; transform: translateY(4px); }
573
+ to { opacity: 1; transform: translateY(0); }
574
+ `;
575
+ const suggestionIn = keyframes `
576
+ from { opacity: 0; transform: translateY(6px); }
577
+ to { opacity: 1; transform: translateY(0); }
578
+ `;
579
+ const feedbackIn = keyframes `
580
+ from { opacity: 0; transform: translateY(-4px); }
581
+ to { opacity: 1; transform: translateY(0); }
582
+ `;
583
+ const badgeIn = keyframes `
584
+ 0% { opacity: 0; transform: scale(0.85); }
585
+ 60% { opacity: 1; transform: scale(1.05); }
586
+ 100% { opacity: 1; transform: scale(1); }
587
+ `;
588
+ const dotCycle = keyframes `
589
+ 0% { opacity: 0; }
590
+ 25%, 75% { opacity: 1; }
591
+ 100% { opacity: 0; }
592
+ `;
593
+ const ToppyHeaderButton = styled.button `
594
+ display: flex;
595
+ align-items: center;
596
+ gap: 8px;
597
+ height: 36px;
598
+ padding: 0 14px 0 5px;
599
+ border-radius: 18px;
600
+ border: 1px solid ${TMColors.primary}35;
601
+ background: ${TMColors.primary}0d;
602
+ color: ${TMColors.primary};
603
+ font-size: 13px;
604
+ font-weight: 600;
605
+ white-space: nowrap;
606
+ cursor: pointer;
607
+ flex-shrink: 0;
608
+ transition: all 0.2s ease;
609
+
610
+ &:hover {
611
+ background: ${TMColors.primary}1a;
612
+ border-color: ${TMColors.primary}66;
613
+ transform: translateY(-1px);
614
+ box-shadow: 0 4px 12px ${TMColors.primary}25;
615
+ }
616
+ &:active { transform: translateY(0); }
617
+ `;
618
+ const ToppyHeaderAvatar = styled.img `
619
+ width: 28px;
620
+ height: 28px;
621
+ border-radius: 50%;
622
+ object-fit: contain;
623
+ pointer-events: none;
624
+ `;
625
+ const ToppyHeaderText = styled.span `
626
+ line-height: 1;
627
+ `;
628
+ const Fab = styled.button `
629
+ position: fixed;
630
+ bottom: 24px;
631
+ right: 24px;
632
+ width: 60px;
633
+ height: 60px;
634
+ border-radius: 50%;
635
+ border: none;
636
+ padding: 0;
637
+ cursor: pointer;
638
+ display: flex;
639
+ align-items: center;
640
+ justify-content: center;
641
+ background: white;
642
+ box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
643
+ z-index: 100000;
644
+ transition: transform 0.2s ease, box-shadow 0.2s ease;
645
+ animation: ${fadeIn} 0.3s ease-out;
646
+
647
+ &:hover { transform: scale(1.08); box-shadow: 0 8px 26px rgba(0, 0, 0, 0.3); }
648
+ &:active { transform: scale(0.96); }
649
+ `;
650
+ const FabAvatar = styled.img `
651
+ width: 52px;
652
+ height: 52px;
653
+ border-radius: 50%;
654
+ object-fit: contain;
655
+ pointer-events: none;
656
+ `;
657
+ const Overlay = styled.div `
658
+ position: fixed;
659
+ inset: 0;
660
+ background: rgba(0, 0, 0, 0.45);
661
+ z-index: 100000;
662
+ animation: ${fadeIn} 0.2s ease-out;
663
+ `;
664
+ const PanelContainer = styled.div `
665
+ position: fixed;
666
+ top: 0;
667
+ right: 0;
668
+ height: 100vh;
669
+ width: ${props => props.$width}px;
670
+ max-width: 100vw;
671
+ background: white;
672
+ display: flex;
673
+ flex-direction: column;
674
+ box-shadow: -8px 0 32px rgba(0, 0, 0, 0.28);
675
+ z-index: 100001;
676
+ animation: ${slideInRight} 0.25s ease-out;
677
+ `;
678
+ const ResizeHandle = styled.div `
679
+ position: absolute;
680
+ left: 0;
681
+ top: 0;
682
+ bottom: 0;
683
+ width: 6px;
684
+ cursor: col-resize;
685
+ background: transparent;
686
+ z-index: 2;
687
+ transition: background 0.2s ease;
688
+
689
+ &:hover { background: ${TMColors.primary}55; }
690
+ `;
691
+ const ChatHeader = styled.div `
692
+ display: flex;
693
+ align-items: center;
694
+ justify-content: space-between;
695
+ padding: 16px 20px;
696
+ background: linear-gradient(135deg, ${TMColors.primary} 0%, ${TMColors.primary}dd 100%);
697
+ color: white;
698
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
699
+ `;
700
+ const HeaderLeft = styled.div `
701
+ display: flex;
702
+ align-items: center;
703
+ gap: 12px;
704
+ flex: 1;
705
+ min-width: 0;
706
+ `;
707
+ const HeaderRight = styled.div `
708
+ display: flex;
709
+ align-items: center;
710
+ gap: 8px;
711
+ margin-left: 12px;
712
+ flex-shrink: 0;
713
+ `;
714
+ const ToppyAvatar = styled.img `
715
+ width: 44px;
716
+ height: 44px;
717
+ border-radius: 50%;
718
+ background: white;
719
+ padding: 4px;
720
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
721
+ flex-shrink: 0;
722
+ object-fit: contain;
723
+ `;
724
+ const HeaderText = styled.div `
725
+ display: flex;
726
+ flex-direction: column;
727
+ gap: 2px;
728
+ min-width: 0;
729
+ `;
730
+ const HeaderGreeting = styled.h2 `
731
+ margin: 0;
732
+ font-size: 17px;
733
+ font-weight: 600;
734
+ color: white;
735
+ white-space: nowrap;
736
+ overflow: hidden;
737
+ text-overflow: ellipsis;
738
+ `;
739
+ const HeaderQuestion = styled.p `
740
+ margin: 0;
741
+ font-size: 13px;
742
+ color: rgba(255, 255, 255, 0.9);
743
+ `;
744
+ const HeaderButton = styled.button `
745
+ width: 32px;
746
+ height: 32px;
747
+ border-radius: 50%;
748
+ background: rgba(255, 255, 255, 0.2);
749
+ border: 1px solid rgba(255, 255, 255, 0.3);
750
+ color: white;
751
+ cursor: pointer;
752
+ display: flex;
753
+ align-items: center;
754
+ justify-content: center;
755
+ flex-shrink: 0;
756
+ transition: all 0.2s ease;
757
+
758
+ &:hover:not(:disabled) { background: rgba(255, 255, 255, 0.3); transform: scale(1.05); }
759
+ &:active:not(:disabled) { transform: scale(0.95); }
760
+ &:disabled { opacity: 0.45; cursor: default; }
761
+ `;
762
+ const ChatBody = styled.div `
763
+ flex: 1;
764
+ padding: 20px;
765
+ overflow-y: auto;
766
+ background: linear-gradient(to bottom, #f8f9fa 0%, #ffffff 100%);
767
+ `;
768
+ const WelcomeMessage = styled.div `
769
+ display: flex;
770
+ gap: 16px;
771
+ padding: 18px;
772
+ background: white;
773
+ border-radius: 12px;
774
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
775
+ border-left: 4px solid ${TMColors.primary};
776
+ animation: ${fadeIn} 0.5s ease-out;
777
+ `;
778
+ const WelcomeIcon = styled.div `
779
+ font-size: 30px;
780
+ flex-shrink: 0;
781
+ `;
782
+ const WelcomeText = styled.p `
783
+ margin: 0;
784
+ font-size: 14px;
785
+ line-height: 1.6;
786
+ color: #242424;
787
+
788
+ strong { color: ${TMColors.primary}; font-weight: 600; }
789
+ `;
790
+ const MessageBubble = styled.div `
791
+ display: flex;
792
+ gap: 10px;
793
+ margin-bottom: 16px;
794
+ align-items: flex-start;
795
+ justify-content: ${props => (props.$isUser ? 'flex-end' : 'flex-start')};
796
+ animation: ${fadeIn} 0.3s ease-out;
797
+ `;
798
+ const BotAvatar = styled.img `
799
+ width: 32px;
800
+ height: 32px;
801
+ border-radius: 50%;
802
+ background: white;
803
+ padding: 2px;
804
+ box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
805
+ flex-shrink: 0;
806
+ object-fit: contain;
807
+ `;
808
+ const MessageContent = styled.div `
809
+ max-width: 80%;
810
+ padding: 10px 14px;
811
+ border-radius: 12px;
812
+ font-size: 14px;
813
+ line-height: 1.5;
814
+ background: ${props => (props.$isUser ? TMColors.primary : '#f0f2f5')};
815
+ color: ${props => (props.$isUser ? 'white' : '#242424')};
816
+ box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
817
+ word-wrap: break-word;
818
+ overflow-wrap: anywhere;
819
+ white-space: ${props => (props.$isUser ? 'pre-wrap' : 'normal')};
820
+ border-bottom-${props => (props.$isUser ? 'right' : 'left')}-radius: 4px;
821
+ `;
822
+ const BotMessageColumn = styled.div `
823
+ display: flex;
824
+ flex-direction: column;
825
+ align-items: flex-start;
826
+ width: 80%;
827
+ min-width: 0;
828
+ `;
829
+ const BotMessageContent = styled(MessageContent) `
830
+ max-width: 100%;
831
+ `;
832
+ const FeedbackContainer = styled.div `
833
+ width: 100%;
834
+ margin-top: 4px;
835
+ `;
836
+ const FeedbackActions = styled.div `
837
+ display: flex;
838
+ align-items: center;
839
+ gap: 2px;
840
+ `;
841
+ const FeedbackActionButton = styled.button `
842
+ display: flex;
843
+ align-items: center;
844
+ justify-content: center;
845
+ width: 28px;
846
+ height: 28px;
847
+ padding: 0;
848
+ border-radius: 8px;
849
+ border: 1px solid ${props => (props.$active ? `${TMColors.primary}55` : 'transparent')};
850
+ background: ${props => (props.$active ? `${TMColors.primary}12` : 'transparent')};
851
+ color: ${props => (props.$success ? '#2e7d32' : props.$active ? TMColors.primary : '#8a8f98')};
852
+ cursor: ${props => (props.$locked ? 'default' : 'pointer')};
853
+ transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
854
+
855
+ &:hover:not(:disabled) {
856
+ background: ${props => (props.$active ? `${TMColors.primary}12` : 'rgba(0, 0, 0, 0.05)')};
857
+ color: ${props => (props.$success ? '#2e7d32' : props.$active ? TMColors.primary : '#242424')};
858
+ }
859
+
860
+ &:focus-visible {
861
+ outline: 2px solid ${TMColors.primary}55;
862
+ outline-offset: 1px;
863
+ }
864
+
865
+ &:disabled {
866
+ opacity: 0.35;
867
+ cursor: default;
868
+ }
869
+ `;
870
+ const SentBadge = styled.span `
871
+ display: inline-flex;
872
+ align-items: center;
873
+ gap: 4px;
874
+ margin-left: 6px;
875
+ padding: 3px 9px 3px 7px;
876
+ border-radius: 999px;
877
+ background: #e8f5e9;
878
+ border: 1px solid #c8e6c9;
879
+ color: #2e7d32;
880
+ font-size: 11px;
881
+ font-weight: 600;
882
+ line-height: 1;
883
+ letter-spacing: 0.02em;
884
+ animation: ${badgeIn} 0.35s ease-out;
885
+
886
+ @media (prefers-reduced-motion: reduce) {
887
+ animation: none;
888
+ }
889
+ `;
890
+ const FeedbackPanel = styled.div `
891
+ margin-top: 6px;
892
+ padding: 14px 16px;
893
+ border: 1px solid #e5e7eb;
894
+ border-radius: 12px;
895
+ background: white;
896
+ box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
897
+ animation: ${feedbackIn} 0.2s ease-out;
898
+ `;
899
+ const FeedbackPanelHeader = styled.div `
900
+ display: flex;
901
+ align-items: flex-start;
902
+ justify-content: space-between;
903
+ gap: 12px;
904
+ margin-bottom: 10px;
905
+ `;
906
+ const FeedbackPanelTitle = styled.div `
907
+ font-size: 14px;
908
+ font-weight: 600;
909
+ color: #242424;
910
+ line-height: 1.35;
911
+ `;
912
+ const FeedbackCloseButton = styled.button `
913
+ display: flex;
914
+ align-items: center;
915
+ justify-content: center;
916
+ width: 24px;
917
+ height: 24px;
918
+ padding: 0;
919
+ border: none;
920
+ border-radius: 6px;
921
+ background: transparent;
922
+ color: #6b7280;
923
+ cursor: pointer;
924
+ flex-shrink: 0;
925
+ transition: background 0.2s ease, color 0.2s ease;
926
+
927
+ &:hover { background: rgba(0, 0, 0, 0.06); color: #242424; }
928
+ `;
929
+ const FeedbackLabel = styled.div `
930
+ margin: 0 0 8px 0;
931
+ font-size: 12px;
932
+ font-weight: 600;
933
+ color: #6b7280;
934
+ `;
935
+ const FeedbackTags = styled.div `
936
+ display: flex;
937
+ flex-wrap: wrap;
938
+ gap: 8px;
939
+ margin-bottom: 14px;
940
+ `;
941
+ const FeedbackTag = styled.button `
942
+ padding: 6px 12px;
943
+ border-radius: 8px;
944
+ border: 1px solid ${props => (props.$selected ? TMColors.primary : '#dcdfe3')};
945
+ background: ${props => (props.$selected ? `${TMColors.primary}10` : 'white')};
946
+ color: ${props => (props.$selected ? TMColors.primary : '#242424')};
947
+ font-family: inherit;
948
+ font-size: 13px;
949
+ font-weight: ${props => (props.$selected ? 600 : 400)};
950
+ line-height: 1.2;
951
+ cursor: pointer;
952
+ transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
953
+
954
+ &:hover { border-color: ${TMColors.primary}88; }
955
+
956
+ &:focus-visible {
957
+ outline: 2px solid ${TMColors.primary}55;
958
+ outline-offset: 1px;
959
+ }
960
+ `;
961
+ const FeedbackTextarea = styled.textarea `
962
+ display: block;
963
+ width: 100%;
964
+ min-height: 70px;
965
+ padding: 9px 11px;
966
+ border: 1px solid #dcdfe3;
967
+ border-radius: 8px;
968
+ font-family: inherit;
969
+ font-size: 13px;
970
+ line-height: 1.45;
971
+ color: #242424;
972
+ background: white;
973
+ resize: none;
974
+ box-sizing: border-box;
975
+ transition: border-color 0.2s ease, box-shadow 0.2s ease;
976
+
977
+ &::placeholder { color: #9ca3af; }
978
+
979
+ &:focus {
980
+ outline: none;
981
+ border-color: ${TMColors.primary};
982
+ box-shadow: 0 0 0 3px ${TMColors.primary}15;
983
+ }
984
+ `;
985
+ const FeedbackPanelFooter = styled.div `
986
+ display: flex;
987
+ align-items: center;
988
+ justify-content: space-between;
989
+ margin-top: 10px;
990
+ `;
991
+ const FeedbackCounter = styled.span `
992
+ font-size: 11px;
993
+ color: ${props => (props.$full ? '#c62828' : '#9ca3af')};
994
+ font-variant-numeric: tabular-nums;
995
+ `;
996
+ const FeedbackSubmitButton = styled.button `
997
+ padding: 7px 18px;
998
+ border: none;
999
+ border-radius: 8px;
1000
+ background: ${TMColors.primary};
1001
+ color: white;
1002
+ font-family: inherit;
1003
+ font-size: 13px;
1004
+ font-weight: 600;
1005
+ cursor: pointer;
1006
+ transition: opacity 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
1007
+
1008
+ &:hover:not(:disabled) {
1009
+ box-shadow: 0 4px 12px ${TMColors.primary}40;
1010
+ transform: translateY(-1px);
1011
+ }
1012
+
1013
+ &:active:not(:disabled) { transform: translateY(0); }
1014
+
1015
+ &:disabled {
1016
+ opacity: 0.4;
1017
+ cursor: default;
1018
+ }
1019
+ `;
1020
+ const MarkdownContent = styled.div `
1021
+ & > *:first-child { margin-top: 0; }
1022
+ & > *:last-child { margin-bottom: 0; }
1023
+
1024
+ a { color: ${TMColors.primary}; text-decoration: underline; }
1025
+ strong { font-weight: 600; }
1026
+ `;
1027
+ const MdParagraph = styled.p `
1028
+ margin: 0 0 8px 0;
1029
+ line-height: 1.55;
1030
+ `;
1031
+ const MdHeading = styled.div `
1032
+ margin: 12px 0 6px 0;
1033
+ font-weight: 700;
1034
+ line-height: 1.3;
1035
+ font-size: ${props => `${Math.max(14, 20 - (props.$level - 1) * 2)}px`};
1036
+ `;
1037
+ const MdUl = styled.ul `
1038
+ margin: 4px 0 8px 0;
1039
+ padding-left: 20px;
1040
+ li { margin: 2px 0; line-height: 1.5; }
1041
+ `;
1042
+ const MdOl = styled.ol `
1043
+ margin: 4px 0 8px 0;
1044
+ padding-left: 22px;
1045
+ li { margin: 2px 0; line-height: 1.5; }
1046
+ `;
1047
+ const MdCode = styled.code `
1048
+ background: rgba(0, 0, 0, 0.06);
1049
+ padding: 1px 5px;
1050
+ border-radius: 4px;
1051
+ font-family: 'Consolas', 'Monaco', monospace;
1052
+ font-size: 0.9em;
1053
+ `;
1054
+ const MdPre = styled.pre `
1055
+ background: rgba(0, 0, 0, 0.06);
1056
+ padding: 10px 12px;
1057
+ border-radius: 8px;
1058
+ overflow-x: auto;
1059
+ margin: 8px 0;
1060
+ font-family: 'Consolas', 'Monaco', monospace;
1061
+ font-size: 0.88em;
1062
+ white-space: pre;
1063
+ `;
1064
+ const MdTableWrapper = styled.div `
1065
+ margin: 8px 0;
1066
+ max-width: 100%;
1067
+ overflow-x: auto;
1068
+ border: 1px solid #dcdfe3;
1069
+ border-radius: 8px;
1070
+
1071
+ &::-webkit-scrollbar { height: 6px; }
1072
+ &::-webkit-scrollbar-track { background: transparent; }
1073
+ &::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }
1074
+ &::-webkit-scrollbar-thumb:hover { background: #999; }
1075
+ `;
1076
+ const MdTable = styled.table `
1077
+ border-collapse: collapse;
1078
+ width: 100%;
1079
+ font-size: 0.92em;
1080
+ background: white;
1081
+ `;
1082
+ const MdTh = styled.th `
1083
+ padding: 7px 10px;
1084
+ background: ${TMColors.primary}14;
1085
+ color: #242424;
1086
+ font-weight: 600;
1087
+ text-align: ${props => props.$align ?? 'left'};
1088
+ border-bottom: 1px solid #dcdfe3;
1089
+ white-space: nowrap;
1090
+
1091
+ &:not(:last-child) { border-right: 1px solid #e6e8eb; }
1092
+ `;
1093
+ const MdTd = styled.td `
1094
+ padding: 7px 10px;
1095
+ text-align: ${props => props.$align ?? 'left'};
1096
+ vertical-align: top;
1097
+ border-top: 1px solid #eceef0;
1098
+
1099
+ &:not(:last-child) { border-right: 1px solid #eceef0; }
1100
+
1101
+ tr:nth-child(even) & { background: #fafbfc; }
1102
+ `;
1103
+ const MdBlockquote = styled.blockquote `
1104
+ margin: 8px 0;
1105
+ padding: 6px 12px;
1106
+ border-left: 3px solid ${TMColors.primary}66;
1107
+ background: ${TMColors.primary}0a;
1108
+ border-radius: 0 6px 6px 0;
1109
+ color: #444;
1110
+
1111
+ & > *:first-child { margin-top: 0; }
1112
+ & > *:last-child { margin-bottom: 0; }
1113
+ `;
1114
+ const MdHr = styled.hr `
1115
+ border: none;
1116
+ border-top: 1px solid #dcdfe3;
1117
+ margin: 12px 0;
1118
+ `;
1119
+ const ThinkingIndicator = styled.div `
1120
+ display: flex;
1121
+ align-items: center;
1122
+ gap: 10px;
1123
+ max-width: 80%;
1124
+ padding: 7px 12px;
1125
+ background: #f0f2f5;
1126
+ border-radius: 12px;
1127
+ border-bottom-left-radius: 4px;
1128
+ box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
1129
+ `;
1130
+ const ThinkingCaption = styled.div `
1131
+ display: flex;
1132
+ flex-direction: column;
1133
+ align-items: flex-start;
1134
+ gap: 0;
1135
+ min-width: 0;
1136
+ `;
1137
+ const ThinkingPhrase = styled.span `
1138
+ display: inline-flex;
1139
+ align-items: center;
1140
+ min-width: 0;
1141
+ font-size: 12px;
1142
+ font-style: italic;
1143
+ line-height: 1.15;
1144
+ color: #6b7280;
1145
+ animation: ${phraseIn} 0.25s ease-out;
1146
+ `;
1147
+ const ThinkingDots = styled.span `
1148
+ display: inline-flex;
1149
+ width: 12px;
1150
+ flex-shrink: 0;
1151
+ `;
1152
+ const ThinkingDot = styled.span `
1153
+ animation: ${dotCycle} 1.2s linear infinite;
1154
+ animation-delay: ${props => props.$delay}s;
1155
+ will-change: opacity;
1156
+
1157
+ @media (prefers-reduced-motion: reduce) {
1158
+ animation: none;
1159
+ opacity: 1;
1160
+ }
1161
+ `;
1162
+ const ThinkingCounter = styled.span `
1163
+ margin-top: 2px;
1164
+ font-size: 10px;
1165
+ font-weight: 600;
1166
+ line-height: 1.1;
1167
+ letter-spacing: 0.02em;
1168
+ color: ${TMColors.primary}b3;
1169
+ font-variant-numeric: tabular-nums;
1170
+ font-feature-settings: 'tnum';
1171
+ opacity: ${props => (props.$visible ? 1 : 0)};
1172
+ transition: opacity 0.3s ease;
1173
+ `;
1174
+ const ChatFooter = styled.div `
1175
+ padding: 16px 20px;
1176
+ background: white;
1177
+ border-top: 1px solid #e1e5e9;
1178
+ box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05);
1179
+ `;
1180
+ const SuggestionsSection = styled.div `
1181
+ margin-bottom: 14px;
1182
+ `;
1183
+ const SuggestionsTitle = styled.div `
1184
+ display: flex;
1185
+ align-items: center;
1186
+ gap: 6px;
1187
+ margin: 0 0 8px 2px;
1188
+ font-size: 11px;
1189
+ font-weight: 600;
1190
+ letter-spacing: 0.06em;
1191
+ text-transform: uppercase;
1192
+ color: #6b7280;
1193
+
1194
+ svg { color: ${TMColors.primary}; }
1195
+ `;
1196
+ const SuggestionsGrid = styled.div `
1197
+ display: grid;
1198
+ grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
1199
+ gap: 8px;
1200
+ `;
1201
+ const SuggestionIcon = styled.span `
1202
+ display: flex;
1203
+ align-items: center;
1204
+ justify-content: center;
1205
+ width: 28px;
1206
+ height: 28px;
1207
+ border-radius: 8px;
1208
+ flex-shrink: 0;
1209
+ background: ${TMColors.primary}14;
1210
+ color: ${TMColors.primary};
1211
+ transition: background 0.2s ease, color 0.2s ease;
1212
+ `;
1213
+ const SuggestionText = styled.span `
1214
+ flex: 1;
1215
+ min-width: 0;
1216
+ display: -webkit-box;
1217
+ -webkit-line-clamp: 2;
1218
+ -webkit-box-orient: vertical;
1219
+ overflow: hidden;
1220
+ `;
1221
+ const SuggestionArrow = styled.span `
1222
+ display: flex;
1223
+ flex-shrink: 0;
1224
+ color: ${TMColors.primary};
1225
+ opacity: 0;
1226
+ transform: translateX(-4px);
1227
+ transition: opacity 0.2s ease, transform 0.2s ease;
1228
+ `;
1229
+ const SuggestionCard = styled.button `
1230
+ display: flex;
1231
+ align-items: center;
1232
+ gap: 10px;
1233
+ width: 100%;
1234
+ min-height: 52px;
1235
+ padding: 9px 12px;
1236
+ border: 1px solid ${TMColors.primary}22;
1237
+ border-radius: 12px;
1238
+ background: linear-gradient(135deg, #ffffff 0%, ${TMColors.primary}08 100%);
1239
+ box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
1240
+ color: #242424;
1241
+ font-family: inherit;
1242
+ font-size: 13px;
1243
+ line-height: 1.35;
1244
+ text-align: left;
1245
+ cursor: pointer;
1246
+ opacity: 0;
1247
+ animation: ${suggestionIn} 0.35s ease-out forwards;
1248
+ animation-delay: ${props => props.$index * 70}ms;
1249
+ transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
1250
+
1251
+ &:hover, &:focus-visible {
1252
+ border-color: ${TMColors.primary}66;
1253
+ background: ${TMColors.primary}0d;
1254
+ box-shadow: 0 4px 14px ${TMColors.primary}1f;
1255
+ transform: translateY(-1px);
1256
+ }
1257
+
1258
+ &:hover ${SuggestionIcon}, &:focus-visible ${SuggestionIcon} {
1259
+ background: ${TMColors.primary};
1260
+ color: white;
1261
+ }
1262
+
1263
+ &:hover ${SuggestionArrow}, &:focus-visible ${SuggestionArrow} {
1264
+ opacity: 1;
1265
+ transform: translateX(0);
1266
+ }
1267
+
1268
+ &:focus-visible {
1269
+ outline: 2px solid ${TMColors.primary}55;
1270
+ outline-offset: 2px;
1271
+ }
1272
+
1273
+ &:active {
1274
+ transform: translateY(0) scale(0.99);
1275
+ }
1276
+
1277
+ @media (prefers-reduced-motion: reduce) {
1278
+ animation: none;
1279
+ opacity: 1;
1280
+ transition: none;
1281
+ }
1282
+ `;
1283
+ const FooterHint = styled.p `
1284
+ margin: 6px 0 0 0;
1285
+ font-size: 11px;
1286
+ color: #999;
1287
+ text-align: center;
1288
+ `;
1289
+ const ChatInputWrapper = styled.div `
1290
+ position: relative;
1291
+ flex: 1;
1292
+ display: flex;
1293
+ `;
1294
+ const ChatInputTextarea = styled.textarea `
1295
+ width: 100%;
1296
+ padding: 14px 60px 14px 16px;
1297
+ border: 2px solid #e1e5e9;
1298
+ border-radius: 12px;
1299
+ font-size: 15px;
1300
+ font-family: inherit;
1301
+ line-height: 1.5;
1302
+ transition: all 0.2s ease;
1303
+ background: #f8f9fa;
1304
+ resize: none;
1305
+ min-height: 100px;
1306
+ max-height: 120px;
1307
+ overflow-y: hidden;
1308
+
1309
+ &:focus {
1310
+ outline: none;
1311
+ border-color: ${TMColors.primary};
1312
+ background: white;
1313
+ box-shadow: 0 0 0 4px ${TMColors.primary}15;
1314
+ }
1315
+
1316
+ &::placeholder {
1317
+ color: #999;
1318
+ }
1319
+
1320
+ &::-webkit-scrollbar {
1321
+ width: 6px;
1322
+ }
1323
+
1324
+ &::-webkit-scrollbar-track {
1325
+ background: transparent;
1326
+ }
1327
+
1328
+ &::-webkit-scrollbar-thumb {
1329
+ background: #ccc;
1330
+ border-radius: 3px;
1331
+ }
1332
+
1333
+ &::-webkit-scrollbar-thumb:hover {
1334
+ background: #999;
1335
+ }
1336
+ `;
1337
+ const InlineSendButton = styled.button `
1338
+ position: absolute;
1339
+ bottom: 8px;
1340
+ right: 8px;
1341
+ width: 40px;
1342
+ height: 40px;
1343
+ border-radius: 10px;
1344
+ background: ${props => props.$disabled ? '#ccc' : '#4caf50'};
1345
+ border: none;
1346
+ color: white;
1347
+ cursor: ${props => props.$disabled ? 'default' : 'pointer'};
1348
+ display: flex;
1349
+ align-items: center;
1350
+ justify-content: center;
1351
+ transition: all 0.2s ease;
1352
+
1353
+ &:hover:not(:disabled) {
1354
+ background: #45a049;
1355
+ transform: scale(1.05);
1356
+ }
1357
+
1358
+ &:active:not(:disabled) {
1359
+ transform: scale(0.95);
1360
+ }
1361
+
1362
+ &:disabled {
1363
+ opacity: 0.6;
1364
+ }
888
1365
  `;