@messenger-box/tailwind-ui-inbox 10.0.3-alpha.0
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/CHANGELOG.md +16 -0
- package/LICENSE +21 -0
- package/jest.config.js +9 -0
- package/lib/cdm-locales/en/translations.json +31 -0
- package/lib/cdm-locales/es/translations.json +31 -0
- package/lib/components/AIAgent/AIAgent.d.ts +32 -0
- package/lib/components/AIAgent/AIAgent.d.ts.map +1 -0
- package/lib/components/AIAgent/AIAgent.js +1135 -0
- package/lib/components/AIAgent/AIAgent.js.map +1 -0
- package/lib/components/AIAgent/InputComponent.d.ts +84 -0
- package/lib/components/AIAgent/InputComponent.d.ts.map +1 -0
- package/lib/components/AIAgent/InputComponent.js +417 -0
- package/lib/components/AIAgent/InputComponent.js.map +1 -0
- package/lib/components/AIAgent/index.d.ts +2 -0
- package/lib/components/AIAgent/index.d.ts.map +1 -0
- package/lib/components/InboxMessage/CommonMessage.d.ts +8 -0
- package/lib/components/InboxMessage/CommonMessage.d.ts.map +1 -0
- package/lib/components/InboxMessage/CommonMessage.js +35 -0
- package/lib/components/InboxMessage/CommonMessage.js.map +1 -0
- package/lib/components/InboxMessage/ConversationItem.d.ts +14 -0
- package/lib/components/InboxMessage/ConversationItem.d.ts.map +1 -0
- package/lib/components/InboxMessage/ConversationItem.js +200 -0
- package/lib/components/InboxMessage/ConversationItem.js.map +1 -0
- package/lib/components/InboxMessage/InputComponent.d.ts +20 -0
- package/lib/components/InboxMessage/InputComponent.d.ts.map +1 -0
- package/lib/components/InboxMessage/InputComponent.js +148 -0
- package/lib/components/InboxMessage/InputComponent.js.map +1 -0
- package/lib/components/InboxMessage/LeftSidebar.d.ts +20 -0
- package/lib/components/InboxMessage/LeftSidebar.d.ts.map +1 -0
- package/lib/components/InboxMessage/LeftSidebar.js +102 -0
- package/lib/components/InboxMessage/LeftSidebar.js.map +1 -0
- package/lib/components/InboxMessage/MessageInput.d.ts +9 -0
- package/lib/components/InboxMessage/MessageInput.d.ts.map +1 -0
- package/lib/components/InboxMessage/MessageInput.js +154 -0
- package/lib/components/InboxMessage/MessageInput.js.map +1 -0
- package/lib/components/InboxMessage/MessageInputComponent.d.ts +9 -0
- package/lib/components/InboxMessage/MessageInputComponent.d.ts.map +1 -0
- package/lib/components/InboxMessage/Messages.d.ts +17 -0
- package/lib/components/InboxMessage/Messages.d.ts.map +1 -0
- package/lib/components/InboxMessage/Messages.js +99 -0
- package/lib/components/InboxMessage/Messages.js.map +1 -0
- package/lib/components/InboxMessage/MessagesBuilderUi.d.ts +17 -0
- package/lib/components/InboxMessage/MessagesBuilderUi.d.ts.map +1 -0
- package/lib/components/InboxMessage/Popover.d.ts +3 -0
- package/lib/components/InboxMessage/Popover.d.ts.map +1 -0
- package/lib/components/InboxMessage/Popover.js +31 -0
- package/lib/components/InboxMessage/Popover.js.map +1 -0
- package/lib/components/InboxMessage/RightSidebar.d.ts +9 -0
- package/lib/components/InboxMessage/RightSidebar.d.ts.map +1 -0
- package/lib/components/InboxMessage/RightSidebar.js +9 -0
- package/lib/components/InboxMessage/RightSidebar.js.map +1 -0
- package/lib/components/InboxMessage/RightSidebarAi.d.ts +37 -0
- package/lib/components/InboxMessage/RightSidebarAi.d.ts.map +1 -0
- package/lib/components/InboxMessage/RightSidebarAi.js +9 -0
- package/lib/components/InboxMessage/RightSidebarAi.js.map +1 -0
- package/lib/components/InboxMessage/ServiceConversationItem.d.ts +12 -0
- package/lib/components/InboxMessage/ServiceConversationItem.d.ts.map +1 -0
- package/lib/components/InboxMessage/ServiceConversationItem.js +185 -0
- package/lib/components/InboxMessage/ServiceConversationItem.js.map +1 -0
- package/lib/components/InboxMessage/ServiceInboxItem.d.ts +12 -0
- package/lib/components/InboxMessage/ServiceInboxItem.d.ts.map +1 -0
- package/lib/components/InboxMessage/ServiceInboxItem.js +182 -0
- package/lib/components/InboxMessage/ServiceInboxItem.js.map +1 -0
- package/lib/components/InboxMessage/StreamingMessageBubble.d.ts +18 -0
- package/lib/components/InboxMessage/StreamingMessageBubble.d.ts.map +1 -0
- package/lib/components/InboxMessage/SubscriptionHandler.d.ts +19 -0
- package/lib/components/InboxMessage/SubscriptionHandler.d.ts.map +1 -0
- package/lib/components/InboxMessage/SubscriptionHandler.js +41 -0
- package/lib/components/InboxMessage/SubscriptionHandler.js.map +1 -0
- package/lib/components/InboxMessage/TypingIndicator.d.ts +11 -0
- package/lib/components/InboxMessage/TypingIndicator.d.ts.map +1 -0
- package/lib/components/InboxMessage/UploadImageButton.d.ts +7 -0
- package/lib/components/InboxMessage/UploadImageButton.d.ts.map +1 -0
- package/lib/components/InboxMessage/UploadImageButton.js +30 -0
- package/lib/components/InboxMessage/UploadImageButton.js.map +1 -0
- package/lib/components/InboxMessage/UserModalContent.d.ts +3 -0
- package/lib/components/InboxMessage/UserModalContent.d.ts.map +1 -0
- package/lib/components/InboxMessage/UserModalContent.js +60 -0
- package/lib/components/InboxMessage/UserModalContent.js.map +1 -0
- package/lib/components/InboxMessage/index.d.ts +19 -0
- package/lib/components/InboxMessage/index.d.ts.map +1 -0
- package/lib/components/InboxMessage/message-widgets/CommonMessage.d.ts +11 -0
- package/lib/components/InboxMessage/message-widgets/CommonMessage.d.ts.map +1 -0
- package/lib/components/InboxMessage/message-widgets/CommonMessage.js +44 -0
- package/lib/components/InboxMessage/message-widgets/CommonMessage.js.map +1 -0
- package/lib/components/InboxMessage/message-widgets/ErrorFixCard.d.ts +10 -0
- package/lib/components/InboxMessage/message-widgets/ErrorFixCard.d.ts.map +1 -0
- package/lib/components/InboxMessage/message-widgets/ErrorFixCard.js +194 -0
- package/lib/components/InboxMessage/message-widgets/ErrorFixCard.js.map +1 -0
- package/lib/components/InboxMessage/message-widgets/MessageCard.d.ts +8 -0
- package/lib/components/InboxMessage/message-widgets/MessageCard.d.ts.map +1 -0
- package/lib/components/InboxMessage/message-widgets/MessageSliceRenderer.d.ts +12 -0
- package/lib/components/InboxMessage/message-widgets/MessageSliceRenderer.d.ts.map +1 -0
- package/lib/components/InboxMessage/message-widgets/MessageSliceRenderer.js +37 -0
- package/lib/components/InboxMessage/message-widgets/MessageSliceRenderer.js.map +1 -0
- package/lib/components/InboxMessage/message-widgets/ModernMessageGroup.d.ts +42 -0
- package/lib/components/InboxMessage/message-widgets/ModernMessageGroup.d.ts.map +1 -0
- package/lib/components/InboxMessage/message-widgets/ModernMessageGroup.js +1339 -0
- package/lib/components/InboxMessage/message-widgets/ModernMessageGroup.js.map +1 -0
- package/lib/components/InboxMessage/message-widgets/PlainMessage.d.ts +8 -0
- package/lib/components/InboxMessage/message-widgets/PlainMessage.d.ts.map +1 -0
- package/lib/components/InboxMessage/message-widgets/PlainMessage.js +14 -0
- package/lib/components/InboxMessage/message-widgets/PlainMessage.js.map +1 -0
- package/lib/components/InboxMessage/message-widgets/PropertyMessageWidget.d.ts +9 -0
- package/lib/components/InboxMessage/message-widgets/PropertyMessageWidget.d.ts.map +1 -0
- package/lib/components/InboxMessage/message-widgets/SlackLikeMessageGroup.d.ts +14 -0
- package/lib/components/InboxMessage/message-widgets/SlackLikeMessageGroup.d.ts.map +1 -0
- package/lib/components/InboxMessage/message-widgets/SlackLikeMessageGroup.js +333 -0
- package/lib/components/InboxMessage/message-widgets/SlackLikeMessageGroup.js.map +1 -0
- package/lib/components/InboxMessage/message-widgets/index.d.ts +4 -0
- package/lib/components/InboxMessage/message-widgets/index.d.ts.map +1 -0
- package/lib/components/ModelConfigPanel.d.ts +74 -0
- package/lib/components/ModelConfigPanel.d.ts.map +1 -0
- package/lib/components/ModelConfigPanel.js +1152 -0
- package/lib/components/ModelConfigPanel.js.map +1 -0
- package/lib/components/filler-components/RightSiderBar.d.ts +3 -0
- package/lib/components/filler-components/RightSiderBar.d.ts.map +1 -0
- package/lib/components/filler-components/RightSiderBar.js +532 -0
- package/lib/components/filler-components/RightSiderBar.js.map +1 -0
- package/lib/components/inbox/FilesList.d.ts +20 -0
- package/lib/components/inbox/FilesList.d.ts.map +1 -0
- package/lib/components/inbox/FilesList.js +68 -0
- package/lib/components/inbox/FilesList.js.map +1 -0
- package/lib/components/inbox/MessageItem.d.ts +17 -0
- package/lib/components/inbox/MessageItem.d.ts.map +1 -0
- package/lib/components/inbox/MessageItem.js +50 -0
- package/lib/components/inbox/MessageItem.js.map +1 -0
- package/lib/components/inbox/ThreadItem.d.ts +11 -0
- package/lib/components/inbox/ThreadItem.d.ts.map +1 -0
- package/lib/components/inbox/ThreadItem.js +147 -0
- package/lib/components/inbox/ThreadItem.js.map +1 -0
- package/lib/components/inbox/index.d.ts +4 -0
- package/lib/components/inbox/index.d.ts.map +1 -0
- package/lib/components/index.d.ts +10 -0
- package/lib/components/index.d.ts.map +1 -0
- package/lib/components/live-code-editor/hybrid-live-editor.d.ts +20 -0
- package/lib/components/live-code-editor/hybrid-live-editor.d.ts.map +1 -0
- package/lib/components/live-code-editor/index.d.ts +4 -0
- package/lib/components/live-code-editor/index.d.ts.map +1 -0
- package/lib/components/live-code-editor/live-code-editor.d.ts +14 -0
- package/lib/components/live-code-editor/live-code-editor.d.ts.map +1 -0
- package/lib/components/messages-container-ui/MessagesContainerUI.d.ts +81 -0
- package/lib/components/messages-container-ui/MessagesContainerUI.d.ts.map +1 -0
- package/lib/components/messages-container-ui/MessagesContainerUI.js +77 -0
- package/lib/components/messages-container-ui/MessagesContainerUI.js.map +1 -0
- package/lib/components/messages-container-ui/PlanModeView.d.ts +82 -0
- package/lib/components/messages-container-ui/PlanModeView.d.ts.map +1 -0
- package/lib/components/messages-container-ui/PlanModeView.js +267 -0
- package/lib/components/messages-container-ui/PlanModeView.js.map +1 -0
- package/lib/components/messages-container-ui/index.d.ts +6 -0
- package/lib/components/messages-container-ui/index.d.ts.map +1 -0
- package/lib/components/messages-container-ui/types.d.ts +38 -0
- package/lib/components/messages-container-ui/types.d.ts.map +1 -0
- package/lib/components/slot-fill/chat-message-filler.d.ts +4 -0
- package/lib/components/slot-fill/chat-message-filler.d.ts.map +1 -0
- package/lib/components/slot-fill/chat-message-filler.js +5 -0
- package/lib/components/slot-fill/chat-message-filler.js.map +1 -0
- package/lib/components/slot-fill/chat-message-slot.d.ts +11 -0
- package/lib/components/slot-fill/chat-message-slot.d.ts.map +1 -0
- package/lib/components/slot-fill/chat-message-slot.js +6 -0
- package/lib/components/slot-fill/chat-message-slot.js.map +1 -0
- package/lib/components/slot-fill/index.d.ts +4 -0
- package/lib/components/slot-fill/index.d.ts.map +1 -0
- package/lib/components/slot-fill/right-sidebar-filler.d.ts +4 -0
- package/lib/components/slot-fill/right-sidebar-filler.d.ts.map +1 -0
- package/lib/components/slot-fill/right-sidebar-filler.js +13 -0
- package/lib/components/slot-fill/right-sidebar-filler.js.map +1 -0
- package/lib/components/ui/button.d.ts +9 -0
- package/lib/components/ui/button.d.ts.map +1 -0
- package/lib/compute.d.ts +8 -0
- package/lib/compute.d.ts.map +1 -0
- package/lib/compute.js +264 -0
- package/lib/compute.js.map +1 -0
- package/lib/config/env-config.d.ts +20 -0
- package/lib/config/env-config.d.ts.map +1 -0
- package/lib/config/env-config.js +55 -0
- package/lib/config/env-config.js.map +1 -0
- package/lib/config/index.d.ts +2 -0
- package/lib/config/index.d.ts.map +1 -0
- package/lib/constants/breakpoints.d.ts +8 -0
- package/lib/constants/breakpoints.d.ts.map +1 -0
- package/lib/constants/index.d.ts +3 -0
- package/lib/constants/index.d.ts.map +1 -0
- package/lib/container/AiInbox.d.ts +15 -0
- package/lib/container/AiInbox.d.ts.map +1 -0
- package/lib/container/AiInboxWithLoader.d.ts +36 -0
- package/lib/container/AiInboxWithLoader.d.ts.map +1 -0
- package/lib/container/AiLandingInput.d.ts +27 -0
- package/lib/container/AiLandingInput.d.ts.map +1 -0
- package/lib/container/AiLandingInput.js +149 -0
- package/lib/container/AiLandingInput.js.map +1 -0
- package/lib/container/Inbox.d.ts +15 -0
- package/lib/container/Inbox.d.ts.map +1 -0
- package/lib/container/Inbox.js +964 -0
- package/lib/container/Inbox.js.map +1 -0
- package/lib/container/InboxAiMessagesLoader.d.ts +45 -0
- package/lib/container/InboxAiMessagesLoader.d.ts.map +1 -0
- package/lib/container/InboxAiMessagesLoader.js +80 -0
- package/lib/container/InboxAiMessagesLoader.js.map +1 -0
- package/lib/container/InboxContainer.d.ts +41 -0
- package/lib/container/InboxContainer.d.ts.map +1 -0
- package/lib/container/InboxContainer.js +27 -0
- package/lib/container/InboxContainer.js.map +1 -0
- package/lib/container/InboxTemplate1.d.ts +15 -0
- package/lib/container/InboxTemplate1.d.ts.map +1 -0
- package/lib/container/InboxTemplate1WithLoader.d.ts +36 -0
- package/lib/container/InboxTemplate1WithLoader.d.ts.map +1 -0
- package/lib/container/InboxTemplate2.d.ts +15 -0
- package/lib/container/InboxTemplate2.d.ts.map +1 -0
- package/lib/container/InboxWithAiLoader.d.ts +47 -0
- package/lib/container/InboxWithAiLoader.d.ts.map +1 -0
- package/lib/container/InboxWithAiLoader.js +118 -0
- package/lib/container/InboxWithAiLoader.js.map +1 -0
- package/lib/container/InboxWithLoader.d.ts +36 -0
- package/lib/container/InboxWithLoader.d.ts.map +1 -0
- package/lib/container/InboxWithLoader.js +277 -0
- package/lib/container/InboxWithLoader.js.map +1 -0
- package/lib/container/ServiceInbox.d.ts +9 -0
- package/lib/container/ServiceInbox.d.ts.map +1 -0
- package/lib/container/ServiceInbox.js +141 -0
- package/lib/container/ServiceInbox.js.map +1 -0
- package/lib/container/TestInboxWithAiLoader.d.ts +7 -0
- package/lib/container/TestInboxWithAiLoader.d.ts.map +1 -0
- package/lib/container/TestInboxWithAiLoader.js +135 -0
- package/lib/container/TestInboxWithAiLoader.js.map +1 -0
- package/lib/container/ThreadMessages.d.ts +13 -0
- package/lib/container/ThreadMessages.d.ts.map +1 -0
- package/lib/container/ThreadMessages.js +320 -0
- package/lib/container/ThreadMessages.js.map +1 -0
- package/lib/container/ThreadMessagesInbox.d.ts +14 -0
- package/lib/container/ThreadMessagesInbox.d.ts.map +1 -0
- package/lib/container/ThreadMessagesInbox.js +347 -0
- package/lib/container/ThreadMessagesInbox.js.map +1 -0
- package/lib/container/Threads.d.ts +8 -0
- package/lib/container/Threads.d.ts.map +1 -0
- package/lib/container/Threads.js +231 -0
- package/lib/container/Threads.js.map +1 -0
- package/lib/container/ThreadsInbox.d.ts +21 -0
- package/lib/container/ThreadsInbox.d.ts.map +1 -0
- package/lib/container/ThreadsInbox.js +243 -0
- package/lib/container/ThreadsInbox.js.map +1 -0
- package/lib/container/apply-footer-styles.d.ts +2 -0
- package/lib/container/apply-footer-styles.d.ts.map +1 -0
- package/lib/container/apply-footer-styles.js +16 -0
- package/lib/container/apply-footer-styles.js.map +1 -0
- package/lib/container/index.d.ts +13 -0
- package/lib/container/index.d.ts.map +1 -0
- package/lib/enums/index.d.ts +2 -0
- package/lib/enums/index.d.ts.map +1 -0
- package/lib/enums/messenger-slot-fill-name-enum.d.ts +11 -0
- package/lib/enums/messenger-slot-fill-name-enum.d.ts.map +1 -0
- package/lib/enums/messenger-slot-fill-name-enum.js +11 -0
- package/lib/enums/messenger-slot-fill-name-enum.js.map +1 -0
- package/lib/hooks/index.d.ts +4 -0
- package/lib/hooks/index.d.ts.map +1 -0
- package/lib/hooks/usePersistentModelConfig.d.ts +33 -0
- package/lib/hooks/usePersistentModelConfig.d.ts.map +1 -0
- package/lib/hooks/usePersistentModelConfig.js +123 -0
- package/lib/hooks/usePersistentModelConfig.js.map +1 -0
- package/lib/hooks/useStreamAssembler.d.ts +8 -0
- package/lib/hooks/useStreamAssembler.d.ts.map +1 -0
- package/lib/hooks/useTemplates.d.ts +14 -0
- package/lib/hooks/useTemplates.d.ts.map +1 -0
- package/lib/hooks/useTemplates.js +59 -0
- package/lib/hooks/useTemplates.js.map +1 -0
- package/lib/index.d.ts +14 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -0
- package/lib/interfaces/index.d.ts +2 -0
- package/lib/interfaces/index.d.ts.map +1 -0
- package/lib/interfaces/message-widgets.interface.d.ts +21 -0
- package/lib/interfaces/message-widgets.interface.d.ts.map +1 -0
- package/lib/machines/aiAgentMachine.d.ts +3 -0
- package/lib/machines/aiAgentMachine.d.ts.map +1 -0
- package/lib/machines/aiAgentMachine.js +1083 -0
- package/lib/machines/aiAgentMachine.js.map +1 -0
- package/lib/machines/aiAgentMachine.simple.d.ts +3 -0
- package/lib/machines/aiAgentMachine.simple.d.ts.map +1 -0
- package/lib/machines/aiAgentMachine.simple.js +108 -0
- package/lib/machines/aiAgentMachine.simple.js.map +1 -0
- package/lib/machines/index.d.ts +3 -0
- package/lib/machines/index.d.ts.map +1 -0
- package/lib/machines/types.d.ts +77 -0
- package/lib/machines/types.d.ts.map +1 -0
- package/lib/module.d.ts +7 -0
- package/lib/module.d.ts.map +1 -0
- package/lib/module.js +26 -0
- package/lib/module.js.map +1 -0
- package/lib/routes.json +251 -0
- package/lib/styles/responsive.css +76 -0
- package/lib/templates/InboxWithAi.d.ts +44 -0
- package/lib/templates/InboxWithAi.d.ts.map +1 -0
- package/lib/templates/InboxWithAi.js +651 -0
- package/lib/templates/InboxWithAi.js.map +1 -0
- package/lib/templates/InboxWithAi.tsx +844 -0
- package/lib/templates/index.d.ts +2 -0
- package/lib/templates/index.d.ts.map +1 -0
- package/lib/templates/index.ts +1 -0
- package/lib/types/templates.d.ts +35 -0
- package/lib/types/templates.d.ts.map +1 -0
- package/lib/utils/utils.d.ts +2 -0
- package/lib/utils/utils.d.ts.map +1 -0
- package/lib/xstate/index.d.ts +3 -0
- package/lib/xstate/index.d.ts.map +1 -0
- package/lib/xstate/rightSidebar.machine.d.ts +4 -0
- package/lib/xstate/rightSidebar.machine.d.ts.map +1 -0
- package/lib/xstate/rightSidebar.types.d.ts +57 -0
- package/lib/xstate/rightSidebar.types.d.ts.map +1 -0
- package/package.json +69 -0
- package/rollup.config.mjs +47 -0
- package/src/cdm-locales/en/translations.json +31 -0
- package/src/cdm-locales/es/translations.json +31 -0
- package/src/components/AIAgent/AIAgent.tsx +1468 -0
- package/src/components/AIAgent/AIAgent.tsx.bk +1365 -0
- package/src/components/AIAgent/InputComponent.tsx +608 -0
- package/src/components/AIAgent/README.md +174 -0
- package/src/components/AIAgent/index.ts +1 -0
- package/src/components/InboxMessage/CommonMessage.tsx +40 -0
- package/src/components/InboxMessage/ConversationItem.tsx +255 -0
- package/src/components/InboxMessage/InputComponent.tsx +198 -0
- package/src/components/InboxMessage/LeftSidebar.tsx +140 -0
- package/src/components/InboxMessage/MessageInput.tsx +209 -0
- package/src/components/InboxMessage/MessageInputComponent.tsx +245 -0
- package/src/components/InboxMessage/Messages.tsx +137 -0
- package/src/components/InboxMessage/MessagesBuilderUi.tsx +205 -0
- package/src/components/InboxMessage/Popover.tsx +42 -0
- package/src/components/InboxMessage/RightSidebar.tsx +22 -0
- package/src/components/InboxMessage/RightSidebarAi.tsx +47 -0
- package/src/components/InboxMessage/ServiceConversationItem.tsx +234 -0
- package/src/components/InboxMessage/ServiceInboxItem.tsx +223 -0
- package/src/components/InboxMessage/StreamingMessageBubble.tsx +270 -0
- package/src/components/InboxMessage/SubscriptionHandler.tsx +55 -0
- package/src/components/InboxMessage/TypingIndicator.tsx +38 -0
- package/src/components/InboxMessage/UploadImageButton.tsx +46 -0
- package/src/components/InboxMessage/UserModalContent.tsx +60 -0
- package/src/components/InboxMessage/index.ts +18 -0
- package/src/components/InboxMessage/message-widgets/CommonMessage.tsx +69 -0
- package/src/components/InboxMessage/message-widgets/ErrorFixCard.tsx +239 -0
- package/src/components/InboxMessage/message-widgets/MessageCard.tsx +127 -0
- package/src/components/InboxMessage/message-widgets/MessageSliceRenderer.tsx +40 -0
- package/src/components/InboxMessage/message-widgets/ModernMessageGroup.tsx +1733 -0
- package/src/components/InboxMessage/message-widgets/PlainMessage.tsx +18 -0
- package/src/components/InboxMessage/message-widgets/PropertyMessageWidget.tsx +29 -0
- package/src/components/InboxMessage/message-widgets/SlackLikeMessageGroup.tsx +492 -0
- package/src/components/InboxMessage/message-widgets/index.ts +8 -0
- package/src/components/ModelConfigPanel.tsx +1357 -0
- package/src/components/filler-components/RightSiderBar.tsx +572 -0
- package/src/components/inbox/FilesList.tsx +89 -0
- package/src/components/inbox/MessageItem.tsx +50 -0
- package/src/components/inbox/ThreadItem.tsx +295 -0
- package/src/components/inbox/index.ts +3 -0
- package/src/components/index.ts +29 -0
- package/src/components/live-code-editor/hybrid-live-editor.tsx +105 -0
- package/src/components/live-code-editor/index.ts +3 -0
- package/src/components/live-code-editor/live-code-editor.tsx +257 -0
- package/src/components/messages-container-ui/MessagesContainerUI.tsx +151 -0
- package/src/components/messages-container-ui/PlanModeView.tsx +426 -0
- package/src/components/messages-container-ui/README.md +91 -0
- package/src/components/messages-container-ui/index.ts +5 -0
- package/src/components/messages-container-ui/types.ts +40 -0
- package/src/components/slot-fill/chat-message-filler.tsx +18 -0
- package/src/components/slot-fill/chat-message-slot.tsx +18 -0
- package/src/components/slot-fill/index.ts +3 -0
- package/src/components/slot-fill/right-sidebar-filler.tsx +48 -0
- package/src/components/ui/button.tsx +32 -0
- package/src/compute.ts +271 -0
- package/src/config/env-config.ts +24 -0
- package/src/config/index.ts +1 -0
- package/src/constants/breakpoints.ts +7 -0
- package/src/constants/index.ts +5 -0
- package/src/container/AiInbox.tsx +1879 -0
- package/src/container/AiInboxWithLoader.tsx +356 -0
- package/src/container/AiLandingInput.tsx +200 -0
- package/src/container/Inbox.tsx +1095 -0
- package/src/container/InboxAiMessagesLoader.tsx +129 -0
- package/src/container/InboxContainer.tsx +61 -0
- package/src/container/InboxTemplate1.tsx +1553 -0
- package/src/container/InboxTemplate1WithLoader.tsx +338 -0
- package/src/container/InboxTemplate2.tsx +1617 -0
- package/src/container/InboxWithAiLoader.tsx +177 -0
- package/src/container/InboxWithLoader.tsx +341 -0
- package/src/container/ServiceInbox.tsx +188 -0
- package/src/container/TestInboxWithAiLoader.tsx +147 -0
- package/src/container/ThreadMessages.tsx +378 -0
- package/src/container/ThreadMessagesInbox.tsx +457 -0
- package/src/container/Threads.tsx +270 -0
- package/src/container/ThreadsInbox.tsx +351 -0
- package/src/container/apply-footer-styles.ts +17 -0
- package/src/container/index.ts +31 -0
- package/src/enums/index.ts +1 -0
- package/src/enums/messenger-slot-fill-name-enum.ts +10 -0
- package/src/hooks/index.ts +3 -0
- package/src/hooks/usePersistentModelConfig.ts +166 -0
- package/src/hooks/useStreamAssembler.ts +7 -0
- package/src/hooks/useTemplates.ts +75 -0
- package/src/index.ts +49 -0
- package/src/interfaces/index.ts +1 -0
- package/src/interfaces/message-widgets.interface.ts +21 -0
- package/src/machines/aiAgentMachine.simple.ts +89 -0
- package/src/machines/aiAgentMachine.ts +1296 -0
- package/src/machines/aiAgentMachine.ts.bk +1296 -0
- package/src/machines/index.ts +2 -0
- package/src/machines/types.ts +59 -0
- package/src/module.tsx +32 -0
- package/src/styles/responsive.css +76 -0
- package/src/templates/InboxWithAi.tsx +844 -0
- package/src/templates/index.ts +1 -0
- package/src/types/templates.ts +35 -0
- package/src/utils/utils.ts +3 -0
- package/src/xstate/index.ts +2 -0
- package/src/xstate/rightSidebar.machine.ts +304 -0
- package/src/xstate/rightSidebar.types.ts +58 -0
- package/tsconfig.json +14 -0
- package/webpack.config.js +92 -0
|
@@ -0,0 +1,1339 @@
|
|
|
1
|
+
import React__default,{useEffect,useMemo}from'react';import {format,differenceInMinutes}from'date-fns';import {AiAgentMessageRole}from'common';import {Slot}from'@common-stack/components-pro';import {MessengerSlotFillNameEnum}from'../../../enums/messenger-slot-fill-name-enum.js';import {FilesList}from'../../inbox/FilesList.js';import'../../inbox/MessageItem.js';import'../../inbox/ThreadItem.js';import {ErrorFixCard}from'./ErrorFixCard.js';import {marked}from'marked';import ReactMarkdown from'react-markdown';import remarkGfm from'remark-gfm';// Configure marked for better markdown rendering
|
|
2
|
+
marked.setOptions({
|
|
3
|
+
breaks: true,
|
|
4
|
+
// Convert line breaks to <br>
|
|
5
|
+
gfm: true,
|
|
6
|
+
// GitHub Flavored Markdown
|
|
7
|
+
headerIds: false,
|
|
8
|
+
// Disable header IDs for cleaner HTML
|
|
9
|
+
mangle: false // Don't mangle email addresses
|
|
10
|
+
});
|
|
11
|
+
// Enhanced CSS styles for HTML content rendering with prettification
|
|
12
|
+
const htmlContentStyles = `
|
|
13
|
+
.html-content {
|
|
14
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
|
15
|
+
line-height: 1.6;
|
|
16
|
+
color: #374151;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.html-content h1, .html-content h2, .html-content h3, .html-content h4, .html-content h5, .html-content h6 {
|
|
20
|
+
margin-top: 1.5rem;
|
|
21
|
+
margin-bottom: 1rem;
|
|
22
|
+
font-weight: 600;
|
|
23
|
+
line-height: 1.25;
|
|
24
|
+
color: #111827;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.html-content h1 {
|
|
28
|
+
font-size: 1.875rem;
|
|
29
|
+
border-bottom: 2px solid #e5e7eb;
|
|
30
|
+
padding-bottom: 0.5rem;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.html-content h2 {
|
|
34
|
+
font-size: 1.5rem;
|
|
35
|
+
border-bottom: 1px solid #e5e7eb;
|
|
36
|
+
padding-bottom: 0.375rem;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.html-content h3 {
|
|
40
|
+
font-size: 1.25rem;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.html-content p {
|
|
44
|
+
margin-bottom: 1rem;
|
|
45
|
+
line-height: 1.7;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.html-content ul, .html-content ol {
|
|
49
|
+
margin-bottom: 1rem;
|
|
50
|
+
padding-left: 1.5rem;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.html-content ul {
|
|
54
|
+
list-style-type: disc;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.html-content ol {
|
|
58
|
+
list-style-type: decimal;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.html-content li {
|
|
62
|
+
margin-bottom: 0.5rem;
|
|
63
|
+
line-height: 1.6;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.html-content li > ul, .html-content li > ol {
|
|
67
|
+
margin-top: 0.5rem;
|
|
68
|
+
margin-bottom: 0.5rem;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.html-content a {
|
|
72
|
+
color: #2563eb;
|
|
73
|
+
text-decoration: none;
|
|
74
|
+
border-bottom: 1px solid transparent;
|
|
75
|
+
transition: all 0.2s ease;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.html-content a:hover {
|
|
79
|
+
color: #1d4ed8;
|
|
80
|
+
border-bottom-color: #1d4ed8;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.html-content strong, .html-content b {
|
|
84
|
+
font-weight: 600;
|
|
85
|
+
color: #111827;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.html-content em, .html-content i {
|
|
89
|
+
font-style: italic;
|
|
90
|
+
color: #6b7280;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.html-content code {
|
|
94
|
+
background-color: #f3f4f6;
|
|
95
|
+
padding: 0.25rem 0.5rem;
|
|
96
|
+
border-radius: 0.375rem;
|
|
97
|
+
font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
|
|
98
|
+
font-size: 0.875rem;
|
|
99
|
+
color: #dc2626;
|
|
100
|
+
border: 1px solid #e5e7eb;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.html-content pre {
|
|
104
|
+
background-color: #f9fafb;
|
|
105
|
+
padding: 1rem;
|
|
106
|
+
border-radius: 0.5rem;
|
|
107
|
+
overflow-x: auto;
|
|
108
|
+
font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
|
|
109
|
+
font-size: 0.875rem;
|
|
110
|
+
line-height: 1.5;
|
|
111
|
+
border: 1px solid #e5e7eb;
|
|
112
|
+
margin: 1.5rem 0;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.html-content pre code {
|
|
116
|
+
background-color: transparent;
|
|
117
|
+
padding: 0;
|
|
118
|
+
border: none;
|
|
119
|
+
color: #374151;
|
|
120
|
+
font-size: inherit;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.html-content blockquote {
|
|
124
|
+
border-left: 4px solid #3b82f6;
|
|
125
|
+
padding-left: 1rem;
|
|
126
|
+
margin: 1.5rem 0;
|
|
127
|
+
font-style: italic;
|
|
128
|
+
color: #6b7280;
|
|
129
|
+
background-color: #f8fafc;
|
|
130
|
+
padding: 1rem;
|
|
131
|
+
border-radius: 0.375rem;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.html-content blockquote p {
|
|
135
|
+
margin-bottom: 0;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.html-content table {
|
|
139
|
+
border-collapse: collapse;
|
|
140
|
+
border: 1px solid #e5e7eb;
|
|
141
|
+
width: 100%;
|
|
142
|
+
margin: 1.5rem 0;
|
|
143
|
+
border-radius: 0.5rem;
|
|
144
|
+
overflow: hidden;
|
|
145
|
+
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.html-content th,
|
|
149
|
+
.html-content td {
|
|
150
|
+
border: 1px solid #e5e7eb;
|
|
151
|
+
padding: 0.75rem;
|
|
152
|
+
text-align: left;
|
|
153
|
+
vertical-align: top;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.html-content th {
|
|
157
|
+
background-color: #f9fafb;
|
|
158
|
+
font-weight: 600;
|
|
159
|
+
color: #111827;
|
|
160
|
+
border-bottom: 2px solid #e5e7eb;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.html-content tr:nth-child(even) {
|
|
164
|
+
background-color: #f9fafb;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.html-content tr:hover {
|
|
168
|
+
background-color: #f3f4f6;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.html-content hr {
|
|
172
|
+
border: none;
|
|
173
|
+
border-top: 2px solid #e5e7eb;
|
|
174
|
+
margin: 2rem 0;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
.html-content img {
|
|
178
|
+
max-width: 100%;
|
|
179
|
+
height: auto;
|
|
180
|
+
border-radius: 0.5rem;
|
|
181
|
+
margin: 1rem 0;
|
|
182
|
+
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/* Enhanced message container styling */
|
|
186
|
+
.message-container {
|
|
187
|
+
background: #ffffff;
|
|
188
|
+
padding-top: 16px;
|
|
189
|
+
padding-bottom: 16px;
|
|
190
|
+
margin: 12px 0;
|
|
191
|
+
transition: all 0.2s ease-in-out;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/* If a message container is rendered *inside the user bubble* (Image 2),
|
|
195
|
+
* we must neutralize it so it doesn't override the pill background/padding.
|
|
196
|
+
*/
|
|
197
|
+
.user-message .message-container {
|
|
198
|
+
background: transparent !important;
|
|
199
|
+
padding-top: 0 !important;
|
|
200
|
+
padding-bottom: 0 !important;
|
|
201
|
+
margin: 0 !important;
|
|
202
|
+
transition: none !important;
|
|
203
|
+
box-shadow: none !important;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/* Markdown content styling */
|
|
207
|
+
.markdown-content {
|
|
208
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
|
209
|
+
line-height: 1.6;
|
|
210
|
+
color: #374151;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
.markdown-content h1 {
|
|
214
|
+
font-size: 1.5rem;
|
|
215
|
+
font-weight: 700;
|
|
216
|
+
margin-top: 1.5rem;
|
|
217
|
+
margin-bottom: 1rem;
|
|
218
|
+
color: #111827;
|
|
219
|
+
padding-bottom: 0.5rem;
|
|
220
|
+
border-bottom: 2px solid #e5e7eb;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
.markdown-content h2 {
|
|
224
|
+
font-size: 1.25rem;
|
|
225
|
+
font-weight: 600;
|
|
226
|
+
margin-top: 1.25rem;
|
|
227
|
+
margin-bottom: 0.75rem;
|
|
228
|
+
color: #1f2937;
|
|
229
|
+
padding-bottom: 0.375rem;
|
|
230
|
+
border-bottom: 1px solid #e5e7eb;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
.markdown-content h3 {
|
|
234
|
+
font-size: 1.125rem;
|
|
235
|
+
font-weight: 600;
|
|
236
|
+
margin-top: 1rem;
|
|
237
|
+
margin-bottom: 0.5rem;
|
|
238
|
+
color: #374151;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
.markdown-content p {
|
|
242
|
+
margin-bottom: 0.75rem;
|
|
243
|
+
line-height: 1.6;
|
|
244
|
+
color: #4b5563;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
.markdown-content ul, .markdown-content ol {
|
|
248
|
+
margin: 1rem 0;
|
|
249
|
+
padding-left: 1.5rem;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
.markdown-content li {
|
|
253
|
+
margin-bottom: 0.5rem;
|
|
254
|
+
line-height: 1.6;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
.markdown-content code {
|
|
258
|
+
background-color: #f3f4f6;
|
|
259
|
+
padding: 0.125rem 0.375rem;
|
|
260
|
+
border-radius: 0.25rem;
|
|
261
|
+
font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
|
|
262
|
+
font-size: 0.875rem;
|
|
263
|
+
color: #dc2626;
|
|
264
|
+
border: 1px solid #e5e7eb;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
.markdown-content pre {
|
|
268
|
+
color: #1f2937;
|
|
269
|
+
border-radius: 8px;
|
|
270
|
+
overflow-x: auto;
|
|
271
|
+
font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
|
|
272
|
+
font-size: 0.875rem;
|
|
273
|
+
line-height: 1.5;
|
|
274
|
+
margin: 1rem 0;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
.markdown-content pre code {
|
|
278
|
+
background-color: transparent;
|
|
279
|
+
padding: 0;
|
|
280
|
+
border: none;
|
|
281
|
+
color: #1f2937;
|
|
282
|
+
font-size: inherit;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
.markdown-content blockquote {
|
|
286
|
+
border-left: 4px solid #3b82f6;
|
|
287
|
+
background-color: #f8fafc;
|
|
288
|
+
padding: 1rem;
|
|
289
|
+
margin: 1rem 0;
|
|
290
|
+
border-radius: 6px;
|
|
291
|
+
font-style: italic;
|
|
292
|
+
color: #475569;
|
|
293
|
+
border-top: 1px solid #e5e7eb;
|
|
294
|
+
border-right: 1px solid #e5e7eb;
|
|
295
|
+
border-bottom: 1px solid #e5e7eb;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
.markdown-content table {
|
|
299
|
+
border-collapse: collapse;
|
|
300
|
+
border: 1px solid #e5e7eb;
|
|
301
|
+
width: 100%;
|
|
302
|
+
margin: 1rem 0;
|
|
303
|
+
border-radius: 8px;
|
|
304
|
+
overflow: hidden;
|
|
305
|
+
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
.markdown-content th {
|
|
309
|
+
background-color: #f9fafb;
|
|
310
|
+
color: #374151;
|
|
311
|
+
font-weight: 600;
|
|
312
|
+
padding: 0.75rem;
|
|
313
|
+
text-align: left;
|
|
314
|
+
border-bottom: 1px solid #e5e7eb;
|
|
315
|
+
font-size: 0.875rem;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
.markdown-content td {
|
|
319
|
+
border: 1px solid #e5e7eb;
|
|
320
|
+
padding: 0.75rem;
|
|
321
|
+
text-align: left;
|
|
322
|
+
vertical-align: top;
|
|
323
|
+
background-color: white;
|
|
324
|
+
font-size: 0.875rem;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
.markdown-content tr:nth-child(even) td {
|
|
328
|
+
background-color: #f9fafb;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
.markdown-content tr:hover td {
|
|
332
|
+
background-color: #f3f4f6;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/* Enhanced list styling */
|
|
336
|
+
.markdown-content ul li {
|
|
337
|
+
position: relative;
|
|
338
|
+
padding-left: 0.5rem;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
.markdown-content ul li::before {
|
|
342
|
+
content: "•";
|
|
343
|
+
color: #000;
|
|
344
|
+
font-weight: bold;
|
|
345
|
+
position: absolute;
|
|
346
|
+
left: -1rem;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
.markdown-content ol li {
|
|
350
|
+
position: relative;
|
|
351
|
+
padding-left: 0.5rem;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
.markdown-content ol li::before {
|
|
355
|
+
content: counter(list-item) ".";
|
|
356
|
+
font-weight: 600;
|
|
357
|
+
position: absolute;
|
|
358
|
+
left: -1.5rem;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/* Code block container styling */
|
|
362
|
+
.code-block-container {
|
|
363
|
+
background: #ffffff;
|
|
364
|
+
border: 1px solid #e5e7eb;
|
|
365
|
+
border-radius: 8px;
|
|
366
|
+
overflow: hidden;
|
|
367
|
+
margin: 1rem 0;
|
|
368
|
+
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
.code-block-header {
|
|
372
|
+
background: #f9fafb;
|
|
373
|
+
padding: 0.5rem 1rem;
|
|
374
|
+
border-bottom: 1px solid #e5e7eb;
|
|
375
|
+
font-weight: 600;
|
|
376
|
+
color: #374151;
|
|
377
|
+
font-size: 0.875rem;
|
|
378
|
+
text-transform: uppercase;
|
|
379
|
+
letter-spacing: 0.05em;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
.code-block-content {
|
|
383
|
+
padding: 1rem;
|
|
384
|
+
overflow-x: auto;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
/* Enhanced prose styling for markdown content */
|
|
388
|
+
.prose pre {
|
|
389
|
+
background-color: #f9fafb;
|
|
390
|
+
border: 1px solid #e5e7eb;
|
|
391
|
+
border-radius: 0.5rem;
|
|
392
|
+
padding: 1rem;
|
|
393
|
+
overflow-x: auto;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
.prose code {
|
|
397
|
+
background-color: #f3f4f6;
|
|
398
|
+
padding: 0.125rem 0.375rem;
|
|
399
|
+
border-radius: 0.25rem;
|
|
400
|
+
font-size: 0.875rem;
|
|
401
|
+
border: 1px solid #e5e7eb;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
.prose pre code {
|
|
405
|
+
background-color: transparent;
|
|
406
|
+
padding: 0;
|
|
407
|
+
border: none;
|
|
408
|
+
color:#000;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
.hover\:bg-gray-100:hover {
|
|
412
|
+
background-color: transparent !important;
|
|
413
|
+
}
|
|
414
|
+
`;
|
|
415
|
+
// Hook to inject CSS styles
|
|
416
|
+
const useInjectStyles = () => {
|
|
417
|
+
useEffect(() => {
|
|
418
|
+
// Check if styles are already injected
|
|
419
|
+
if (document.getElementById('html-content-styles')) {
|
|
420
|
+
return;
|
|
421
|
+
}
|
|
422
|
+
// Create and inject style element
|
|
423
|
+
const styleElement = document.createElement('style');
|
|
424
|
+
styleElement.id = 'html-content-styles';
|
|
425
|
+
styleElement.textContent = htmlContentStyles;
|
|
426
|
+
document.head.appendChild(styleElement);
|
|
427
|
+
// Cleanup function
|
|
428
|
+
return () => {
|
|
429
|
+
const existingStyle = document.getElementById('html-content-styles');
|
|
430
|
+
if (existingStyle) {
|
|
431
|
+
existingStyle.remove();
|
|
432
|
+
}
|
|
433
|
+
};
|
|
434
|
+
}, []);
|
|
435
|
+
};
|
|
436
|
+
// Enhanced utility function to group messages by user and time
|
|
437
|
+
const groupMessagesByUserAndTime = (messages, timeThresholdMinutes = 5) => {
|
|
438
|
+
if (!messages || messages.length === 0) return [];
|
|
439
|
+
const groups = [];
|
|
440
|
+
let currentGroup = [];
|
|
441
|
+
let lastMessage = null;
|
|
442
|
+
for (const message of messages) {
|
|
443
|
+
if (typeof message === 'string') continue; // Skip date separators
|
|
444
|
+
const shouldStartNewGroup = !lastMessage || lastMessage.author?.id !== message.author?.id || differenceInMinutes(new Date(message.createdAt), new Date(lastMessage.createdAt)) > timeThresholdMinutes;
|
|
445
|
+
if (shouldStartNewGroup) {
|
|
446
|
+
if (currentGroup.length > 0) {
|
|
447
|
+
groups.push(currentGroup);
|
|
448
|
+
}
|
|
449
|
+
currentGroup = [message];
|
|
450
|
+
} else {
|
|
451
|
+
currentGroup.push(message);
|
|
452
|
+
}
|
|
453
|
+
lastMessage = message;
|
|
454
|
+
}
|
|
455
|
+
if (currentGroup.length > 0) {
|
|
456
|
+
groups.push(currentGroup);
|
|
457
|
+
}
|
|
458
|
+
return groups;
|
|
459
|
+
};
|
|
460
|
+
// Enhanced content detection that properly identifies different content types
|
|
461
|
+
const detectContentType = value => {
|
|
462
|
+
if (!value) return 'text';
|
|
463
|
+
const trimmed = value.trim();
|
|
464
|
+
// Check for markdown patterns FIRST (before code, as markdown can contain code blocks)
|
|
465
|
+
const markdownPatterns = [/^#{1,6}\s+.+$/gm,
|
|
466
|
+
// Headers (must have text after #)
|
|
467
|
+
/^\s*[-*+]\s+.+$/gm,
|
|
468
|
+
// Unordered lists
|
|
469
|
+
/^\s*\d+\.\s+.+$/gm,
|
|
470
|
+
// Numbered lists
|
|
471
|
+
/\[.+?\]\(.+?\)/g,
|
|
472
|
+
// Links
|
|
473
|
+
/!\[.+?\]\(.+?\)/g,
|
|
474
|
+
// Images
|
|
475
|
+
/```[\s\S]*?```/g,
|
|
476
|
+
// Fenced code blocks (markdown feature)
|
|
477
|
+
/^\s*>\s+/gm,
|
|
478
|
+
// Blockquotes
|
|
479
|
+
/\*\*.*?\*\*/g,
|
|
480
|
+
// Bold
|
|
481
|
+
/\*[^*].*?\*/g,
|
|
482
|
+
// Italic (not just asterisks)
|
|
483
|
+
/^\s*\|.+\|/gm // Tables
|
|
484
|
+
];
|
|
485
|
+
// Count markdown patterns - if we have multiple, it's likely markdown
|
|
486
|
+
const markdownMatches = markdownPatterns.filter(pattern => {
|
|
487
|
+
const matches = trimmed.match(pattern);
|
|
488
|
+
return matches && matches.length > 0;
|
|
489
|
+
}).length;
|
|
490
|
+
// If we have 2+ markdown patterns, it's definitely markdown
|
|
491
|
+
if (markdownMatches >= 2) return 'markdown';
|
|
492
|
+
// If we have headers or lists, it's likely markdown
|
|
493
|
+
if (/^#{1,6}\s+/gm.test(trimmed) || /^\s*[-*+]\s+/gm.test(trimmed) || /^\s*\d+\.\s+/gm.test(trimmed)) {
|
|
494
|
+
return 'markdown';
|
|
495
|
+
}
|
|
496
|
+
// Check for pure code patterns (without markdown context)
|
|
497
|
+
const pureCodePatterns = [/^---\s*\w+\.\w+\s*---$/gm,
|
|
498
|
+
// File separators (standalone)
|
|
499
|
+
/^@tailwind\s+\w+/gm,
|
|
500
|
+
// Tailwind directives at start
|
|
501
|
+
/^export\s+default\s*\{/gm,
|
|
502
|
+
// JS/TS exports at start
|
|
503
|
+
/^import\s+.*\s+from\s+['"]/gm // Import statements at start
|
|
504
|
+
];
|
|
505
|
+
const hasPureCodePatterns = pureCodePatterns.some(pattern => pattern.test(trimmed));
|
|
506
|
+
if (hasPureCodePatterns && markdownMatches === 0) return 'code';
|
|
507
|
+
// Check for HTML patterns
|
|
508
|
+
const htmlPatterns = [/<[a-z][\s\S]*?>/i,
|
|
509
|
+
// HTML tags
|
|
510
|
+
/&[a-z0-9#]+;/i,
|
|
511
|
+
// HTML entities
|
|
512
|
+
/<[^>]+>[^<]*<\/[^>]+>/i // HTML structure
|
|
513
|
+
];
|
|
514
|
+
const hasHtmlPatterns = htmlPatterns.some(pattern => pattern.test(trimmed));
|
|
515
|
+
// Only return HTML if it's clearly HTML and not markdown
|
|
516
|
+
if (hasHtmlPatterns && markdownMatches === 0) return 'html';
|
|
517
|
+
// Default to text, but FormattedMessageContent will still try to parse as markdown
|
|
518
|
+
return 'text';
|
|
519
|
+
};
|
|
520
|
+
/** Map message type (THINKING, TOOLUSE, etc.) to slot fill name for Kimi-like streaming UI */
|
|
521
|
+
const getMessageSlotName = type => {
|
|
522
|
+
if (!type) return null;
|
|
523
|
+
const t = String(type).toUpperCase();
|
|
524
|
+
if (t === 'THINKING') return MessengerSlotFillNameEnum.THINKING_NAME;
|
|
525
|
+
if (t === 'TOOLUSE') return MessengerSlotFillNameEnum.TOOLUSE_NAME;
|
|
526
|
+
if (t === 'CODEBLOCK') return MessengerSlotFillNameEnum.CODEBLOCK_NAME;
|
|
527
|
+
if (t === 'SERVICE') return MessengerSlotFillNameEnum.SERVICE_NAME;
|
|
528
|
+
if (t === 'AIASSISTANT' || t === 'ASSISTANT') return MessengerSlotFillNameEnum.AIASSISTANT_NAME;
|
|
529
|
+
return null;
|
|
530
|
+
};
|
|
531
|
+
// Enhanced sanitizer that allows most HTML tags while maintaining security
|
|
532
|
+
const sanitizeHtml = html => {
|
|
533
|
+
try {
|
|
534
|
+
if (typeof window === 'undefined' || typeof window.DOMParser === 'undefined') {
|
|
535
|
+
return html.replace(/<script[\s\S]*?>[\s\S]*?<\/script>/gi, '').replace(/<style[\s\S]*?>[\s\S]*?<\/style>/gi, '').replace(/on\w+\s*=\s*"[^"]*"/gi, '').replace(/on\w+\s*=\s*'[^']*'/gi, '').replace(/on\w+\s*=\s*[^\s>]+/gi, '').replace(/javascript:/gi, '').replace(/data:text\/html/gi, '');
|
|
536
|
+
}
|
|
537
|
+
const parser = new window.DOMParser();
|
|
538
|
+
const doc = parser.parseFromString(html, 'text/html');
|
|
539
|
+
// Only remove the most dangerous tags
|
|
540
|
+
const dangerousTags = ['script', 'style'];
|
|
541
|
+
dangerousTags.forEach(tag => {
|
|
542
|
+
doc.querySelectorAll(tag).forEach(el => el.remove());
|
|
543
|
+
});
|
|
544
|
+
const walker = doc.createTreeWalker(doc.body, NodeFilter.SHOW_ELEMENT);
|
|
545
|
+
let node = walker.nextNode();
|
|
546
|
+
while (node) {
|
|
547
|
+
Array.from(node.attributes).forEach(attr => {
|
|
548
|
+
const name = attr.name.toLowerCase();
|
|
549
|
+
const value = (attr.value || '').toLowerCase();
|
|
550
|
+
// Remove event handlers and javascript protocols
|
|
551
|
+
if (name.startsWith('on') || value.startsWith('javascript:')) {
|
|
552
|
+
node?.removeAttribute(attr.name);
|
|
553
|
+
}
|
|
554
|
+
// Allow most attributes but validate URLs for src/href
|
|
555
|
+
if ((name === 'src' || name === 'href') && !/^https?:|^\/.*/.test(attr.value)) {
|
|
556
|
+
node?.removeAttribute(attr.name);
|
|
557
|
+
}
|
|
558
|
+
});
|
|
559
|
+
node = walker.nextNode();
|
|
560
|
+
}
|
|
561
|
+
return doc.body.innerHTML;
|
|
562
|
+
} catch (e) {
|
|
563
|
+
return html.replace(/<script[\s\S]*?>[\s\S]*?<\/script>/gi, '');
|
|
564
|
+
}
|
|
565
|
+
};
|
|
566
|
+
// Function to prettify HTML content
|
|
567
|
+
const prettifyHtmlContent = htmlContent => {
|
|
568
|
+
// Add semantic classes for better styling
|
|
569
|
+
let prettified = htmlContent;
|
|
570
|
+
// Enhance headings with better styling
|
|
571
|
+
prettified = prettified.replace(/<h([1-6])>/g, '<h$1 class="html-heading html-heading-$1">');
|
|
572
|
+
// Enhance lists with better styling
|
|
573
|
+
prettified = prettified.replace(/<ul>/g, '<ul class="html-list html-list-unordered">');
|
|
574
|
+
prettified = prettified.replace(/<ol>/g, '<ol class="html-list html-list-ordered">');
|
|
575
|
+
// Enhance paragraphs with better spacing
|
|
576
|
+
prettified = prettified.replace(/<p>/g, '<p class="html-paragraph">');
|
|
577
|
+
// Enhance code blocks
|
|
578
|
+
prettified = prettified.replace(/<code>/g, '<code class="html-inline-code">');
|
|
579
|
+
prettified = prettified.replace(/<pre>/g, '<pre class="html-code-block">');
|
|
580
|
+
// Enhance blockquotes
|
|
581
|
+
prettified = prettified.replace(/<blockquote>/g, '<blockquote class="html-blockquote">');
|
|
582
|
+
// Enhance tables
|
|
583
|
+
prettified = prettified.replace(/<table>/g, '<table class="html-table">');
|
|
584
|
+
prettified = prettified.replace(/<th>/g, '<th class="html-table-header">');
|
|
585
|
+
prettified = prettified.replace(/<td>/g, '<td class="html-table-cell">');
|
|
586
|
+
// Add info boxes for certain content patterns
|
|
587
|
+
prettified = prettified.replace(/<p>(Note|Tip|Info|Warning|Error):\s*(.*?)<\/p>/gi, '<div class="html-info-box"><strong>$1:</strong> $2</div>');
|
|
588
|
+
return prettified;
|
|
589
|
+
};
|
|
590
|
+
// Minimal Builder-like blocks renderer (text/image/button/columns)
|
|
591
|
+
const BuilderLikeRenderer = ({
|
|
592
|
+
blocks
|
|
593
|
+
}) => {
|
|
594
|
+
if (!blocks || !Array.isArray(blocks) || blocks.length === 0) return null;
|
|
595
|
+
return React__default.createElement("div", {
|
|
596
|
+
className: "space-y-3"
|
|
597
|
+
}, blocks.map((block, idx) => {
|
|
598
|
+
const type = block?.['@type'] || block?.type;
|
|
599
|
+
if (!type) return null;
|
|
600
|
+
if (/text/i.test(type)) {
|
|
601
|
+
const html = sanitizeHtml(block?.text || block?.data?.text || '');
|
|
602
|
+
return React__default.createElement("div", {
|
|
603
|
+
key: idx,
|
|
604
|
+
className: "max-w-none text-gray-800",
|
|
605
|
+
dangerouslySetInnerHTML: {
|
|
606
|
+
__html: html
|
|
607
|
+
}
|
|
608
|
+
});
|
|
609
|
+
}
|
|
610
|
+
if (/image/i.test(type)) {
|
|
611
|
+
const src = block?.src || block?.image || block?.data?.src;
|
|
612
|
+
const alt = block?.alt || block?.data?.alt || '';
|
|
613
|
+
if (!src) return null;
|
|
614
|
+
return React__default.createElement("div", {
|
|
615
|
+
key: idx,
|
|
616
|
+
className: "rounded-lg overflow-hidden border border-gray-200"
|
|
617
|
+
}, React__default.createElement("img", {
|
|
618
|
+
className: "w-full h-auto",
|
|
619
|
+
src: src,
|
|
620
|
+
alt: alt
|
|
621
|
+
}));
|
|
622
|
+
}
|
|
623
|
+
if (/button/i.test(type)) {
|
|
624
|
+
const text = block?.text || block?.data?.text || 'Button';
|
|
625
|
+
const href = block?.href || block?.link || block?.data?.href || '#';
|
|
626
|
+
return React__default.createElement("a", {
|
|
627
|
+
key: idx,
|
|
628
|
+
href: href,
|
|
629
|
+
target: "_blank",
|
|
630
|
+
rel: "noopener noreferrer",
|
|
631
|
+
className: "inline-flex items-center px-3 py-1.5 rounded-md bg-blue-600 text-white text-sm hover:bg-blue-700"
|
|
632
|
+
}, text);
|
|
633
|
+
}
|
|
634
|
+
if (/columns?/i.test(type)) {
|
|
635
|
+
const cols = block?.columns || block?.data?.columns || [];
|
|
636
|
+
return React__default.createElement("div", {
|
|
637
|
+
key: idx,
|
|
638
|
+
className: "grid grid-cols-1 sm:grid-cols-2 gap-3"
|
|
639
|
+
}, cols.map((col, colIdx) => React__default.createElement("div", {
|
|
640
|
+
key: colIdx,
|
|
641
|
+
className: "space-y-2"
|
|
642
|
+
}, React__default.createElement(BuilderLikeRenderer, {
|
|
643
|
+
blocks: col?.blocks || col?.children
|
|
644
|
+
}))));
|
|
645
|
+
}
|
|
646
|
+
return React__default.createElement("div", {
|
|
647
|
+
key: idx,
|
|
648
|
+
className: "message-container"
|
|
649
|
+
}, React__default.createElement("pre", {
|
|
650
|
+
className: "text-xs text-gray-600 overflow-x-auto"
|
|
651
|
+
}, JSON.stringify(block, null, 2)));
|
|
652
|
+
}));
|
|
653
|
+
};
|
|
654
|
+
// Code block with optional header (language + copy) and footer (copy + download) per Image 2
|
|
655
|
+
const CodeBlockWithActions = ({
|
|
656
|
+
content,
|
|
657
|
+
language,
|
|
658
|
+
showCopyDownload = true
|
|
659
|
+
}) => {
|
|
660
|
+
const [copied, setCopied] = React__default.useState(false);
|
|
661
|
+
const handleCopy = React__default.useCallback(() => {
|
|
662
|
+
navigator.clipboard.writeText(content).then(() => {
|
|
663
|
+
setCopied(true);
|
|
664
|
+
setTimeout(() => setCopied(false), 2000);
|
|
665
|
+
});
|
|
666
|
+
}, [content]);
|
|
667
|
+
const handleDownload = React__default.useCallback(() => {
|
|
668
|
+
const ext = language === 'jsx' || language === 'tsx' ? '.tsx' : language === 'js' || language === 'ts' ? '.ts' : '.txt';
|
|
669
|
+
const blob = new Blob([content], {
|
|
670
|
+
type: 'text/plain'
|
|
671
|
+
});
|
|
672
|
+
const url = URL.createObjectURL(blob);
|
|
673
|
+
const a = document.createElement('a');
|
|
674
|
+
a.href = url;
|
|
675
|
+
a.download = `snippet${ext}`;
|
|
676
|
+
a.click();
|
|
677
|
+
URL.revokeObjectURL(url);
|
|
678
|
+
}, [content, language]);
|
|
679
|
+
const langLabel = (language || 'code').toUpperCase();
|
|
680
|
+
/**
|
|
681
|
+
* Duplicate / copy: back square offset top-left (only its top-left shows behind),
|
|
682
|
+
* front square on top toward bottom-right — matches typical “two sheets” reference art.
|
|
683
|
+
*/
|
|
684
|
+
const IconCopy = ({
|
|
685
|
+
className
|
|
686
|
+
}) => React__default.createElement("svg", {
|
|
687
|
+
className: className,
|
|
688
|
+
viewBox: "0 0 24 24",
|
|
689
|
+
fill: "none",
|
|
690
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
691
|
+
"aria-hidden": true
|
|
692
|
+
}, React__default.createElement("rect", {
|
|
693
|
+
x: "3.25",
|
|
694
|
+
y: "3.25",
|
|
695
|
+
width: "10.5",
|
|
696
|
+
height: "10.5",
|
|
697
|
+
rx: "2.25",
|
|
698
|
+
ry: "2.25",
|
|
699
|
+
stroke: "currentColor",
|
|
700
|
+
strokeWidth: "1.5",
|
|
701
|
+
strokeLinecap: "round",
|
|
702
|
+
strokeLinejoin: "round"
|
|
703
|
+
}), React__default.createElement("rect", {
|
|
704
|
+
x: "8.75",
|
|
705
|
+
y: "8.75",
|
|
706
|
+
width: "10.5",
|
|
707
|
+
height: "10.5",
|
|
708
|
+
rx: "2.25",
|
|
709
|
+
ry: "2.25",
|
|
710
|
+
stroke: "currentColor",
|
|
711
|
+
strokeWidth: "1.5",
|
|
712
|
+
strokeLinecap: "round",
|
|
713
|
+
strokeLinejoin: "round"
|
|
714
|
+
}));
|
|
715
|
+
/** Arrow into tray (download) */
|
|
716
|
+
const IconDownload = ({
|
|
717
|
+
className
|
|
718
|
+
}) => React__default.createElement("svg", {
|
|
719
|
+
className: className,
|
|
720
|
+
viewBox: "0 0 24 24",
|
|
721
|
+
fill: "none",
|
|
722
|
+
stroke: "currentColor",
|
|
723
|
+
strokeWidth: 1.5,
|
|
724
|
+
strokeLinecap: "round",
|
|
725
|
+
strokeLinejoin: "round",
|
|
726
|
+
"aria-hidden": true
|
|
727
|
+
}, React__default.createElement("path", {
|
|
728
|
+
d: "M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5M16.5 12L12 16.5m0 0L7.5 12m4.5 4.5V3"
|
|
729
|
+
}));
|
|
730
|
+
const IconCheck = ({
|
|
731
|
+
className
|
|
732
|
+
}) => React__default.createElement("svg", {
|
|
733
|
+
className: className,
|
|
734
|
+
viewBox: "0 0 24 24",
|
|
735
|
+
fill: "none",
|
|
736
|
+
stroke: "currentColor",
|
|
737
|
+
strokeWidth: 1.75,
|
|
738
|
+
strokeLinecap: "round",
|
|
739
|
+
strokeLinejoin: "round",
|
|
740
|
+
"aria-hidden": true
|
|
741
|
+
}, React__default.createElement("path", {
|
|
742
|
+
d: "M5 13l4 4L19 7"
|
|
743
|
+
}));
|
|
744
|
+
const iconMuted = 'text-slate-500 hover:text-slate-600';
|
|
745
|
+
return React__default.createElement("div", {
|
|
746
|
+
className: "rounded-xl bg-white overflow-hidden my-3 shadow-sm ring-1 ring-slate-200/60"
|
|
747
|
+
}, React__default.createElement("div", {
|
|
748
|
+
className: "flex items-center justify-between px-4 pt-4 pb-3 bg-white"
|
|
749
|
+
}, React__default.createElement("span", {
|
|
750
|
+
className: "text-[11px] font-semibold uppercase tracking-wide text-slate-500"
|
|
751
|
+
}, langLabel), React__default.createElement("button", {
|
|
752
|
+
type: "button",
|
|
753
|
+
onClick: handleCopy,
|
|
754
|
+
className: `p-1 rounded-md hover:bg-slate-100/80 transition-colors ${iconMuted}`,
|
|
755
|
+
title: "Copy",
|
|
756
|
+
"aria-label": "Copy to clipboard"
|
|
757
|
+
}, React__default.createElement(IconCopy, {
|
|
758
|
+
className: "w-[15px] h-[15px] shrink-0"
|
|
759
|
+
}))), React__default.createElement("div", {
|
|
760
|
+
className: "px-4 pb-4"
|
|
761
|
+
}, React__default.createElement("div", {
|
|
762
|
+
className: "overflow-x-auto bg-white py-4"
|
|
763
|
+
}, React__default.createElement("pre", {
|
|
764
|
+
className: "text-sm text-slate-900 font-mono leading-relaxed whitespace-pre-wrap break-words m-0 p-0 border-0 bg-transparent"
|
|
765
|
+
}, React__default.createElement("code", {
|
|
766
|
+
className: "bg-transparent"
|
|
767
|
+
}, content)))), showCopyDownload && React__default.createElement("div", {
|
|
768
|
+
className: "flex items-center justify-start gap-0.5 px-4 pb-3 pt-0 mt-2 bg-white"
|
|
769
|
+
}, React__default.createElement("button", {
|
|
770
|
+
type: "button",
|
|
771
|
+
onClick: handleCopy,
|
|
772
|
+
className: `p-1 rounded-md hover:bg-slate-100/80 transition-colors ${iconMuted}`,
|
|
773
|
+
title: copied ? 'Copied' : 'Copy',
|
|
774
|
+
"aria-label": copied ? 'Copied' : 'Copy to clipboard'
|
|
775
|
+
}, copied ? React__default.createElement(IconCheck, {
|
|
776
|
+
className: "w-[15px] h-[15px] text-emerald-600"
|
|
777
|
+
}) : React__default.createElement(IconCopy, {
|
|
778
|
+
className: "w-[15px] h-[15px] shrink-0"
|
|
779
|
+
})), React__default.createElement("button", {
|
|
780
|
+
type: "button",
|
|
781
|
+
onClick: handleDownload,
|
|
782
|
+
className: `p-1 rounded-md hover:bg-slate-100/80 transition-colors ${iconMuted}`,
|
|
783
|
+
title: "Download",
|
|
784
|
+
"aria-label": "Download"
|
|
785
|
+
}, React__default.createElement(IconDownload, {
|
|
786
|
+
className: "w-[15px] h-[15px] shrink-0"
|
|
787
|
+
}))));
|
|
788
|
+
};
|
|
789
|
+
// Infer language from file extension or content
|
|
790
|
+
const inferCodeLanguage = (section, filename) => {
|
|
791
|
+
if (/\bimport\b.*from\s+['"]react['"]/i.test(section) || /<\w+[\s>]/.test(section)) return 'jsx';
|
|
792
|
+
if (/\bimport\b/.test(section) && /\.(ts|tsx)\b/.test(section)) return 'ts';
|
|
793
|
+
return 'code';
|
|
794
|
+
};
|
|
795
|
+
// Enhanced code formatter for raw code content
|
|
796
|
+
const CodeFormatter = ({
|
|
797
|
+
content,
|
|
798
|
+
showCopyDownload = true,
|
|
799
|
+
variant = 'default',
|
|
800
|
+
planMode = false
|
|
801
|
+
}) => {
|
|
802
|
+
if (!content) return null;
|
|
803
|
+
// Split content by file separators and format each section
|
|
804
|
+
const sections = content.split(/(---\s*\w+\.\w+\s*---)/g);
|
|
805
|
+
return React__default.createElement("div", {
|
|
806
|
+
className: variant === 'user' ? '' : 'message-container'
|
|
807
|
+
}, React__default.createElement("div", {
|
|
808
|
+
className: "space-y-4"
|
|
809
|
+
}, sections.map((section, index) => {
|
|
810
|
+
if (!section.trim()) return null;
|
|
811
|
+
// Check if this is a file separator
|
|
812
|
+
const fileMatch = section.match(/---\s*(\w+\.\w+)\s*---/);
|
|
813
|
+
if (fileMatch) {
|
|
814
|
+
return React__default.createElement("div", {
|
|
815
|
+
key: index,
|
|
816
|
+
className: "code-block-container"
|
|
817
|
+
}, React__default.createElement("div", {
|
|
818
|
+
className: "code-block-header"
|
|
819
|
+
}, "\uD83D\uDCC4 ", fileMatch[1]));
|
|
820
|
+
}
|
|
821
|
+
// Format the code content
|
|
822
|
+
const lines = section.trim().split('\n');
|
|
823
|
+
const isCode = lines.some(line => line.includes('@tailwind') || line.includes('export default') || line.includes('import ') || line.includes('{') || line.includes('}') || line.includes('//') || line.includes('/*'));
|
|
824
|
+
if (isCode) {
|
|
825
|
+
const lang = inferCodeLanguage(section);
|
|
826
|
+
return React__default.createElement(CodeBlockWithActions, {
|
|
827
|
+
key: index,
|
|
828
|
+
content: section.trim(),
|
|
829
|
+
language: lang,
|
|
830
|
+
showCopyDownload: showCopyDownload
|
|
831
|
+
});
|
|
832
|
+
}
|
|
833
|
+
// Regular text content
|
|
834
|
+
return React__default.createElement("div", {
|
|
835
|
+
key: index,
|
|
836
|
+
className: `text-sm ${variant === 'user' ? planMode ? 'text-primary-foreground' : 'text-gray-900' : 'text-gray-700'} leading-relaxed whitespace-pre-wrap break-words`
|
|
837
|
+
}, section.trim());
|
|
838
|
+
})));
|
|
839
|
+
};
|
|
840
|
+
// Enhanced markdown renderer using marked (similar to MessageBubble.tsx)
|
|
841
|
+
const FormattedMessageContent = ({
|
|
842
|
+
content,
|
|
843
|
+
variant = 'default',
|
|
844
|
+
planMode = false,
|
|
845
|
+
showCopyDownloadOnCodeBlock = false
|
|
846
|
+
}) => {
|
|
847
|
+
if (!content) return null;
|
|
848
|
+
// Parse markdown using marked - be more aggressive in detection
|
|
849
|
+
const {
|
|
850
|
+
htmlContent,
|
|
851
|
+
markdownSource
|
|
852
|
+
} = useMemo(() => {
|
|
853
|
+
try {
|
|
854
|
+
const trimmed = content.trim();
|
|
855
|
+
// Comprehensive markdown detection patterns
|
|
856
|
+
const markdownIndicators = [/^#{1,6}\s+.+$/gm,
|
|
857
|
+
// Headers with text
|
|
858
|
+
/^\s*[-*+]\s+.+$/gm,
|
|
859
|
+
// Unordered lists
|
|
860
|
+
/^\s*\d+\.\s+.+$/gm,
|
|
861
|
+
// Numbered lists
|
|
862
|
+
/\[.+?\]\(.+?\)/g,
|
|
863
|
+
// Links
|
|
864
|
+
/!\[.+?\]\(.+?\)/g,
|
|
865
|
+
// Images
|
|
866
|
+
/```[\s\S]*?```/g,
|
|
867
|
+
// Fenced code blocks
|
|
868
|
+
/^\s*>\s+/gm,
|
|
869
|
+
// Blockquotes
|
|
870
|
+
/\*\*[^*]+\*\*/g,
|
|
871
|
+
// Bold text
|
|
872
|
+
/\*[^*\n]+\*/g,
|
|
873
|
+
// Italic text (not just asterisks)
|
|
874
|
+
/^\s*\|.+\|/gm,
|
|
875
|
+
// Tables
|
|
876
|
+
/~~.+~~/g // Strikethrough
|
|
877
|
+
];
|
|
878
|
+
// Check if content has markdown patterns
|
|
879
|
+
const hasMarkdown = markdownIndicators.some(pattern => {
|
|
880
|
+
const matches = trimmed.match(pattern);
|
|
881
|
+
return matches && matches.length > 0;
|
|
882
|
+
});
|
|
883
|
+
// Also check for common markdown characters that suggest markdown content
|
|
884
|
+
const hasMarkdownChars = /[#*`>|\[\]()]/.test(trimmed) && trimmed.length > 10;
|
|
885
|
+
// If we detect markdown, parse it
|
|
886
|
+
if (hasMarkdown || hasMarkdownChars) {
|
|
887
|
+
const parsed = marked.parse(trimmed, {
|
|
888
|
+
async: false
|
|
889
|
+
});
|
|
890
|
+
// Only return if parsing actually produced HTML (not just the same text)
|
|
891
|
+
if (parsed && parsed.trim() !== trimmed && parsed.includes('<')) {
|
|
892
|
+
return {
|
|
893
|
+
htmlContent: parsed,
|
|
894
|
+
markdownSource: trimmed
|
|
895
|
+
};
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
return {
|
|
899
|
+
htmlContent: null,
|
|
900
|
+
markdownSource: null
|
|
901
|
+
};
|
|
902
|
+
} catch (error) {
|
|
903
|
+
console.error('Error parsing markdown:', error);
|
|
904
|
+
return {
|
|
905
|
+
htmlContent: null,
|
|
906
|
+
markdownSource: null
|
|
907
|
+
};
|
|
908
|
+
}
|
|
909
|
+
}, [content]);
|
|
910
|
+
const proseMarkdownClasses = `text-sm prose prose-sm max-w-none leading-relaxed break-words
|
|
911
|
+
prose-p:my-2 prose-p:text-gray-700
|
|
912
|
+
prose-pre:my-2 prose-pre:bg-transparent prose-pre:border-0 prose-pre:p-0
|
|
913
|
+
prose-ul:my-2 prose-ol:my-2
|
|
914
|
+
prose-code:break-words prose-code:bg-gray-50 prose-code:px-1.5 prose-code:py-0.5 prose-code:rounded prose-code:text-sm prose-code:font-mono
|
|
915
|
+
prose-headings:font-semibold prose-headings:text-gray-900 prose-headings:mt-4 prose-headings:mb-2
|
|
916
|
+
prose-h1:text-2xl prose-h1:border-b prose-h1:border-gray-200 prose-h1:pb-2
|
|
917
|
+
prose-h2:text-xl prose-h2:border-b prose-h2:border-gray-200 prose-h2:pb-1
|
|
918
|
+
prose-h3:text-lg
|
|
919
|
+
prose-h4:text-base
|
|
920
|
+
prose-a:text-blue-600 prose-a:no-underline hover:prose-a:underline
|
|
921
|
+
prose-strong:font-semibold prose-strong:text-gray-900
|
|
922
|
+
prose-em:text-gray-600
|
|
923
|
+
prose-blockquote:border-l-4 prose-blockquote:border-blue-400 prose-blockquote:pl-4 prose-blockquote:py-2 prose-blockquote:bg-blue-50 prose-blockquote:rounded-r-md prose-blockquote:my-3 prose-blockquote:italic
|
|
924
|
+
prose-table:w-full prose-table:border prose-table:border-gray-200 prose-table:rounded-md prose-table:my-4
|
|
925
|
+
prose-th:px-3 prose-th:py-2 prose-th:text-left prose-th:font-semibold prose-th:bg-gray-50 prose-th:border prose-th:border-gray-200
|
|
926
|
+
prose-td:px-3 prose-td:py-2 prose-td:border prose-td:border-gray-200 prose-td:text-gray-700
|
|
927
|
+
prose-li:my-1 prose-li:text-gray-700
|
|
928
|
+
prose-hr:my-4 prose-hr:border-gray-200
|
|
929
|
+
${variant === 'user' ? planMode ? '!prose-p:text-primary-foreground !prose-li:text-primary-foreground !prose-strong:text-primary-foreground !prose-em:text-primary-foreground !prose-a:text-primary-foreground' : '!prose-p:text-gray-900 !prose-li:text-gray-900 !prose-strong:text-gray-900 !prose-em:text-gray-700 !prose-a:text-blue-600' : ''}`;
|
|
930
|
+
const markdownComponents = useMemo(() => ({
|
|
931
|
+
pre: ({
|
|
932
|
+
children
|
|
933
|
+
}) => React__default.createElement(React__default.Fragment, null, children),
|
|
934
|
+
code: ({
|
|
935
|
+
className,
|
|
936
|
+
children,
|
|
937
|
+
...rest
|
|
938
|
+
}) => {
|
|
939
|
+
const match = /language-(\w+)/.exec(className || '');
|
|
940
|
+
const text = String(children).replace(/\n$/, '');
|
|
941
|
+
if (match) {
|
|
942
|
+
return React__default.createElement("div", {
|
|
943
|
+
className: "not-prose max-w-none"
|
|
944
|
+
}, React__default.createElement(CodeBlockWithActions, {
|
|
945
|
+
content: text,
|
|
946
|
+
language: match[1],
|
|
947
|
+
showCopyDownload: showCopyDownloadOnCodeBlock
|
|
948
|
+
}));
|
|
949
|
+
}
|
|
950
|
+
if (text.includes('\n')) {
|
|
951
|
+
return React__default.createElement("div", {
|
|
952
|
+
className: "not-prose max-w-none"
|
|
953
|
+
}, React__default.createElement(CodeBlockWithActions, {
|
|
954
|
+
content: text,
|
|
955
|
+
language: "code",
|
|
956
|
+
showCopyDownload: showCopyDownloadOnCodeBlock
|
|
957
|
+
}));
|
|
958
|
+
}
|
|
959
|
+
return React__default.createElement("code", {
|
|
960
|
+
className: `rounded px-1.5 py-0.5 text-sm font-mono bg-gray-50 break-words ${className || ''}`,
|
|
961
|
+
...rest
|
|
962
|
+
}, children);
|
|
963
|
+
}
|
|
964
|
+
}), [showCopyDownloadOnCodeBlock]);
|
|
965
|
+
// Fenced code copy/download needs React tree (not marked HTML)
|
|
966
|
+
if (showCopyDownloadOnCodeBlock && markdownSource) {
|
|
967
|
+
return React__default.createElement("div", {
|
|
968
|
+
className: variant === 'user' ? '' : 'message-container'
|
|
969
|
+
}, React__default.createElement("div", {
|
|
970
|
+
className: `${proseMarkdownClasses}`
|
|
971
|
+
}, React__default.createElement(ReactMarkdown, {
|
|
972
|
+
remarkPlugins: [remarkGfm],
|
|
973
|
+
components: markdownComponents
|
|
974
|
+
}, markdownSource)));
|
|
975
|
+
}
|
|
976
|
+
// If markdown was parsed, render as HTML with prose styling
|
|
977
|
+
if (htmlContent) {
|
|
978
|
+
return React__default.createElement("div", {
|
|
979
|
+
className: variant === 'user' ? '' : 'message-container'
|
|
980
|
+
}, React__default.createElement("div", {
|
|
981
|
+
className: `text-sm prose prose-sm max-w-none leading-relaxed break-words
|
|
982
|
+
prose-p:my-2 prose-p:text-gray-700
|
|
983
|
+
prose-pre:my-2 prose-pre:bg-gray-50 prose-pre:border prose-pre:border-gray-200 prose-pre:rounded prose-pre:p-3
|
|
984
|
+
prose-ul:my-2 prose-ol:my-2
|
|
985
|
+
prose-pre:whitespace-pre-wrap prose-pre:break-words prose-pre:overflow-x-auto
|
|
986
|
+
prose-code:break-words prose-code:bg-gray-50 prose-code:px-1.5 prose-code:py-0.5 prose-code:rounded prose-code:text-sm prose-code:font-mono
|
|
987
|
+
prose-headings:font-semibold prose-headings:text-gray-900 prose-headings:mt-4 prose-headings:mb-2
|
|
988
|
+
prose-h1:text-2xl prose-h1:border-b prose-h1:border-gray-200 prose-h1:pb-2
|
|
989
|
+
prose-h2:text-xl prose-h2:border-b prose-h2:border-gray-200 prose-h2:pb-1
|
|
990
|
+
prose-h3:text-lg
|
|
991
|
+
prose-h4:text-base
|
|
992
|
+
prose-a:text-blue-600 prose-a:no-underline hover:prose-a:underline
|
|
993
|
+
prose-strong:font-semibold prose-strong:text-gray-900
|
|
994
|
+
prose-em:text-gray-600
|
|
995
|
+
prose-blockquote:border-l-4 prose-blockquote:border-blue-400 prose-blockquote:pl-4 prose-blockquote:py-2 prose-blockquote:bg-blue-50 prose-blockquote:rounded-r-md prose-blockquote:my-3 prose-blockquote:italic
|
|
996
|
+
prose-table:w-full prose-table:border prose-table:border-gray-200 prose-table:rounded-md prose-table:my-4
|
|
997
|
+
prose-th:px-3 prose-th:py-2 prose-th:text-left prose-th:font-semibold prose-th:bg-gray-50 prose-th:border prose-th:border-gray-200
|
|
998
|
+
prose-td:px-3 prose-td:py-2 prose-td:border prose-td:border-gray-200 prose-td:text-gray-700
|
|
999
|
+
prose-li:my-1 prose-li:text-gray-700
|
|
1000
|
+
prose-hr:my-4 prose-hr:border-gray-200
|
|
1001
|
+
${variant === 'user' ? planMode ? '!prose-p:text-primary-foreground !prose-li:text-primary-foreground !prose-strong:text-primary-foreground !prose-em:text-primary-foreground !prose-a:text-primary-foreground' : '!prose-p:text-gray-900 !prose-li:text-gray-900 !prose-strong:text-gray-900 !prose-em:text-gray-700 !prose-a:text-blue-600' : ''}`,
|
|
1002
|
+
dangerouslySetInnerHTML: {
|
|
1003
|
+
__html: htmlContent
|
|
1004
|
+
}
|
|
1005
|
+
}));
|
|
1006
|
+
}
|
|
1007
|
+
// For plain text content
|
|
1008
|
+
return variant === 'user' ? React__default.createElement("p", {
|
|
1009
|
+
className: `text-sm leading-relaxed whitespace-pre-wrap break-words ${planMode ? 'text-primary-foreground' : 'text-gray-900'}`
|
|
1010
|
+
}, content) : React__default.createElement("div", {
|
|
1011
|
+
className: "message-container"
|
|
1012
|
+
}, React__default.createElement("p", {
|
|
1013
|
+
className: "text-sm text-gray-700 leading-relaxed whitespace-pre-wrap break-words"
|
|
1014
|
+
}, content));
|
|
1015
|
+
};
|
|
1016
|
+
// Detect predominant text direction (RTL/LTR) for international content
|
|
1017
|
+
const detectTextDirection = text => {
|
|
1018
|
+
if (!text) return 'ltr';
|
|
1019
|
+
const rtlRanges = /[\u0591-\u07FF\uFB1D-\uFDFD\uFE70-\uFEFC]/g; // Hebrew, Arabic, etc.
|
|
1020
|
+
const ltrRanges = /[A-Za-z\u00C0-\u024F\u1E00-\u1EFF]/g;
|
|
1021
|
+
const rtlCount = (text.match(rtlRanges) || []).length;
|
|
1022
|
+
const ltrCount = (text.match(ltrRanges) || []).length;
|
|
1023
|
+
return rtlCount > ltrCount ? 'rtl' : 'ltr';
|
|
1024
|
+
};
|
|
1025
|
+
// Lightweight language heuristic for lang attribute
|
|
1026
|
+
const detectLanguageTag = text => {
|
|
1027
|
+
if (!text) return 'en';
|
|
1028
|
+
if (/\p{Script=Arabic}/u.test(text)) return 'ar';
|
|
1029
|
+
if (/[\u0590-\u05FF]/.test(text)) return 'he';
|
|
1030
|
+
if (/[\u0600-\u06FF]/.test(text)) return 'fa';
|
|
1031
|
+
if (/[\u0900-\u097F]/.test(text)) return 'hi';
|
|
1032
|
+
if (/[\u4E00-\u9FFF]/.test(text)) return 'zh';
|
|
1033
|
+
if (/[\u3040-\u309F\u30A0-\u30FF]/.test(text)) return 'ja';
|
|
1034
|
+
if (/[\uAC00-\uD7AF]/.test(text)) return 'ko';
|
|
1035
|
+
if (/[\u0400-\u04FF]/.test(text)) return 'ru';
|
|
1036
|
+
if (/[\u0E00-\u0E7F]/.test(text)) return 'th';
|
|
1037
|
+
return 'en';
|
|
1038
|
+
};
|
|
1039
|
+
// Attempt to parse Builder.io-like JSON blocks embedded as message string
|
|
1040
|
+
const tryExtractBuilderBlocks = content => {
|
|
1041
|
+
if (!content || content.length < 2) return null;
|
|
1042
|
+
try {
|
|
1043
|
+
const trimmed = content.trim();
|
|
1044
|
+
const jsonMatch = trimmed.match(/([\[{][\s\S]*[\]}])/);
|
|
1045
|
+
const jsonText = jsonMatch ? jsonMatch[1] : trimmed;
|
|
1046
|
+
const parsed = JSON.parse(jsonText);
|
|
1047
|
+
if (Array.isArray(parsed)) {
|
|
1048
|
+
if (parsed.length && (parsed[0]['@type'] || parsed[0].type)) return parsed;
|
|
1049
|
+
} else if (parsed && typeof parsed === 'object') {
|
|
1050
|
+
if (Array.isArray(parsed.blocks)) return parsed.blocks;
|
|
1051
|
+
if (Array.isArray(parsed?.data?.blocks)) return parsed.data.blocks;
|
|
1052
|
+
}
|
|
1053
|
+
return null;
|
|
1054
|
+
} catch {
|
|
1055
|
+
return null;
|
|
1056
|
+
}
|
|
1057
|
+
};
|
|
1058
|
+
const ModernMessageGroup = ({
|
|
1059
|
+
author,
|
|
1060
|
+
messages,
|
|
1061
|
+
currentUser,
|
|
1062
|
+
showAuthorName = false,
|
|
1063
|
+
showAvatar = false,
|
|
1064
|
+
showTimestamp = false,
|
|
1065
|
+
onOpen,
|
|
1066
|
+
onMessageClick,
|
|
1067
|
+
isDesktopView = false,
|
|
1068
|
+
isSmallScreen = false,
|
|
1069
|
+
showCopyDownloadOnCodeBlock = false
|
|
1070
|
+
}) => {
|
|
1071
|
+
// Inject CSS styles for HTML content
|
|
1072
|
+
useInjectStyles();
|
|
1073
|
+
// Preserve server / store order for posts (TOOLUSE, THINKING, etc.); no client-side reordering
|
|
1074
|
+
const displayMessages = messages;
|
|
1075
|
+
//const isOwnMessage = author?.id === currentUser?.id;
|
|
1076
|
+
//const isOwnMessage = messages.some((message: any) => (message as any)?.propsConfiguration?.contents?.role === AiAgentMessageRole.User);
|
|
1077
|
+
const isOwnMessage = displayMessages.some(message => message?.propsConfiguration?.contents?.role === AiAgentMessageRole.User) || Array.isArray(author?.alias) && typeof currentUser?.authUserId === 'string' && author.alias.some(alias => alias?.toLowerCase() === currentUser.authUserId.toLowerCase());
|
|
1078
|
+
author?.givenName && author?.familyName ? `${author.givenName} ${author.familyName}` : author?.username || 'Unknown User';
|
|
1079
|
+
displayMessages[0];
|
|
1080
|
+
const formatTime = timestamp => {
|
|
1081
|
+
const date = new Date(timestamp);
|
|
1082
|
+
return format(date, 'h:mm a');
|
|
1083
|
+
};
|
|
1084
|
+
// Determine if this is an AI/system message for special styling
|
|
1085
|
+
const isSystemMessage = author?.username?.toLowerCase().includes('ai') || author?.username?.toLowerCase().includes('assistant') || author?.username?.toLowerCase().includes('system');
|
|
1086
|
+
// const isSystemMessage = messages.some(
|
|
1087
|
+
// (message: any) => (message as any)?.propsConfiguration?.contents?.role === AiAgentMessageRole.Assistant,
|
|
1088
|
+
// );
|
|
1089
|
+
// For user messages, don't show group header, just individual messages with avatars
|
|
1090
|
+
if (isOwnMessage) {
|
|
1091
|
+
return React__default.createElement("div", {
|
|
1092
|
+
className: `min-h-fit ${isDesktopView ? 'space-y-1 mb-3' : isSmallScreen ? 'space-y-0.5 mb-2' : 'space-y-0.5 mb-2'}`
|
|
1093
|
+
}, displayMessages.map((message, index) => React__default.createElement(ModernMessageBubble, {
|
|
1094
|
+
key: message.id,
|
|
1095
|
+
message: message,
|
|
1096
|
+
isOwnMessage: isOwnMessage,
|
|
1097
|
+
isSystemMessage: isSystemMessage,
|
|
1098
|
+
isFirstInGroup: index === 0,
|
|
1099
|
+
isLastInGroup: index === displayMessages.length - 1,
|
|
1100
|
+
onMessageClick: onMessageClick,
|
|
1101
|
+
formatTime: formatTime,
|
|
1102
|
+
showAuthorName: showAuthorName,
|
|
1103
|
+
showAvatar: showAvatar,
|
|
1104
|
+
showTimestamp: showTimestamp,
|
|
1105
|
+
showCopyDownloadOnCodeBlock: showCopyDownloadOnCodeBlock
|
|
1106
|
+
})));
|
|
1107
|
+
}
|
|
1108
|
+
// For other messages (non-user), show the traditional group layout
|
|
1109
|
+
return React__default.createElement("div", {
|
|
1110
|
+
className: `group transition-all duration-300 ease-in-out ${isDesktopView ? 'mb-4 px-4 py-3' : isSmallScreen ? 'mb-2 px-2 py-1' : 'mb-3 px-3 py-1'} ${isSystemMessage ? 'bg-white rounded-lg' : ' rounded-lg'}`
|
|
1111
|
+
}, React__default.createElement("div", {
|
|
1112
|
+
className: `flex items-start ${isDesktopView ? 'space-x-4' : isSmallScreen ? 'space-x-2' : 'space-x-3'}`
|
|
1113
|
+
}, React__default.createElement("div", {
|
|
1114
|
+
className: "flex-1 min-w-0 overflow-hidden"
|
|
1115
|
+
}, React__default.createElement("div", {
|
|
1116
|
+
className: "space-y-1"
|
|
1117
|
+
}, displayMessages.map((message, index) => React__default.createElement(ModernMessageBubble, {
|
|
1118
|
+
key: message.id,
|
|
1119
|
+
message: message,
|
|
1120
|
+
isOwnMessage: isOwnMessage,
|
|
1121
|
+
isSystemMessage: isSystemMessage,
|
|
1122
|
+
isFirstInGroup: index === 0,
|
|
1123
|
+
isLastInGroup: index === displayMessages.length - 1,
|
|
1124
|
+
onMessageClick: onMessageClick,
|
|
1125
|
+
formatTime: formatTime,
|
|
1126
|
+
showTimestamp: showTimestamp,
|
|
1127
|
+
showCopyDownloadOnCodeBlock: showCopyDownloadOnCodeBlock
|
|
1128
|
+
}))))));
|
|
1129
|
+
};
|
|
1130
|
+
const ModernMessageBubble = ({
|
|
1131
|
+
showAuthorName = false,
|
|
1132
|
+
showAvatar = false,
|
|
1133
|
+
showTimestamp = false,
|
|
1134
|
+
message,
|
|
1135
|
+
isOwnMessage,
|
|
1136
|
+
isSystemMessage,
|
|
1137
|
+
isFirstInGroup,
|
|
1138
|
+
isLastInGroup,
|
|
1139
|
+
onMessageClick,
|
|
1140
|
+
formatTime,
|
|
1141
|
+
showCopyDownloadOnCodeBlock = false
|
|
1142
|
+
}) => {
|
|
1143
|
+
const handleClick = () => {
|
|
1144
|
+
onMessageClick?.(message);
|
|
1145
|
+
};
|
|
1146
|
+
const isAssistantRole = message?.propsConfiguration?.contents?.role === AiAgentMessageRole.Assistant;
|
|
1147
|
+
const messageMode = message?.propsConfiguration?.contents?.mode ?? message?.propsConfiguration?.content?.mode ?? message?.props?.mode;
|
|
1148
|
+
const isPlanMode = messageMode === 'plan';
|
|
1149
|
+
// For user messages, create a right-aligned layout with avatar and name
|
|
1150
|
+
if (isOwnMessage) {
|
|
1151
|
+
const authorName = message.author?.givenName && message.author?.familyName ? `${message.author.givenName} ${message.author.familyName}` : message.author?.username || 'You';
|
|
1152
|
+
return React__default.createElement("div", {
|
|
1153
|
+
className: "py-1 px-1 sm:px-2 -mx-1 sm:-mx-2 group"
|
|
1154
|
+
}, React__default.createElement("div", {
|
|
1155
|
+
className: "flex items-start justify-end gap-2"
|
|
1156
|
+
}, React__default.createElement("div", {
|
|
1157
|
+
className: "flex flex-col items-end max-w-[85%]"
|
|
1158
|
+
}, showAuthorName && React__default.createElement("div", {
|
|
1159
|
+
className: "flex items-end space-x-2 mb-0.5"
|
|
1160
|
+
}, React__default.createElement("span", {
|
|
1161
|
+
className: "text-sm font-semibold text-gray-900"
|
|
1162
|
+
}, authorName)), React__default.createElement("div", {
|
|
1163
|
+
className: `text-sm ${isAssistantRole ? 'cursor-pointer rounded-2xl border border-gray-200 bg-gray-50 text-gray-900 px-4 py-2.5' :
|
|
1164
|
+
// : 'user-message rounded-[22px] rounded-br-[4px] px-4 py-3 bg-primary text-primary-foreground shadow-sm'
|
|
1165
|
+
isPlanMode ? 'user-message rounded-[22px] rounded-br-[4px] px-4 py-3 bg-primary text-primary-foreground shadow-sm' : 'user-message rounded-[22px] rounded-br-[4px] px-4 py-3 '}`,
|
|
1166
|
+
onClick: isAssistantRole ? handleClick : undefined,
|
|
1167
|
+
dir: detectTextDirection(message?.message || ''),
|
|
1168
|
+
lang: detectLanguageTag(message?.message || '')
|
|
1169
|
+
}, message.message && React__default.createElement("div", {
|
|
1170
|
+
className: "max-w-none"
|
|
1171
|
+
}, (() => {
|
|
1172
|
+
const contentType = detectContentType(message.message);
|
|
1173
|
+
if (contentType === 'code') {
|
|
1174
|
+
return React__default.createElement(CodeFormatter, {
|
|
1175
|
+
content: message.message,
|
|
1176
|
+
showCopyDownload: showCopyDownloadOnCodeBlock,
|
|
1177
|
+
variant: isAssistantRole ? 'default' : 'user',
|
|
1178
|
+
planMode: !isAssistantRole && isPlanMode
|
|
1179
|
+
});
|
|
1180
|
+
} else if (contentType === 'html') {
|
|
1181
|
+
return React__default.createElement("div", {
|
|
1182
|
+
className: isAssistantRole ? 'text-gray-800 html-content' : isPlanMode ? '!text-primary-foreground html-content' : 'text-gray-900 html-content',
|
|
1183
|
+
dangerouslySetInnerHTML: {
|
|
1184
|
+
__html: prettifyHtmlContent(sanitizeHtml(message.message))
|
|
1185
|
+
}
|
|
1186
|
+
});
|
|
1187
|
+
} else {
|
|
1188
|
+
return React__default.createElement(FormattedMessageContent, {
|
|
1189
|
+
content: message.message,
|
|
1190
|
+
variant: isAssistantRole ? 'default' : 'user',
|
|
1191
|
+
planMode: !isAssistantRole && isPlanMode,
|
|
1192
|
+
showCopyDownloadOnCodeBlock: showCopyDownloadOnCodeBlock
|
|
1193
|
+
});
|
|
1194
|
+
}
|
|
1195
|
+
})()), tryExtractBuilderBlocks(message?.message)?.length ? React__default.createElement("div", {
|
|
1196
|
+
className: "mt-2"
|
|
1197
|
+
}, React__default.createElement(BuilderLikeRenderer, {
|
|
1198
|
+
blocks: tryExtractBuilderBlocks(message?.message)
|
|
1199
|
+
})) : null, message?.props?.blocks?.length ? React__default.createElement("div", {
|
|
1200
|
+
className: "mt-2"
|
|
1201
|
+
}, React__default.createElement(BuilderLikeRenderer, {
|
|
1202
|
+
blocks: message.props.blocks
|
|
1203
|
+
})) : null, message.files?.totalCount > 0 && React__default.createElement("div", {
|
|
1204
|
+
className: "mt-2"
|
|
1205
|
+
}, React__default.createElement(FilesList, {
|
|
1206
|
+
uploaded: true,
|
|
1207
|
+
files: message.files.data
|
|
1208
|
+
})), showTimestamp ? React__default.createElement("div", {
|
|
1209
|
+
className: `text-[10px] mt-1 text-right ${isAssistantRole ? 'text-gray-500' : isPlanMode ? 'text-primary-foreground/80' : 'text-gray-500'}`
|
|
1210
|
+
}, formatTime(message.createdAt)) : null)), showAvatar && React__default.createElement("div", {
|
|
1211
|
+
className: "flex-shrink-0 mt-0.5"
|
|
1212
|
+
}, React__default.createElement("img", {
|
|
1213
|
+
className: `w-8 h-8 sm:w-10 sm:h-10 rounded-lg ${isAssistantRole ? '' : 'cursor-pointer hover:opacity-80'} transition-opacity object-cover`,
|
|
1214
|
+
src: message.author?.picture || '/default-avatar.svg',
|
|
1215
|
+
alt: authorName,
|
|
1216
|
+
//onClick={isAssistantRole ? undefined : handleClick}
|
|
1217
|
+
onClick: isAssistantRole ? handleClick : undefined,
|
|
1218
|
+
onError: e => {
|
|
1219
|
+
e.currentTarget.src = '/default-avatar.svg';
|
|
1220
|
+
}
|
|
1221
|
+
}))));
|
|
1222
|
+
}
|
|
1223
|
+
// For other messages (left-aligned) — use Slot for streaming types (THINKING, TOOLUSE, etc.) like Kimi
|
|
1224
|
+
const attachment = message?.props?.attachment ?? message?.propsConfiguration?.contents?.attachment;
|
|
1225
|
+
const slotName = getMessageSlotName(message?.type);
|
|
1226
|
+
// Don't show THINKING slot when attachment has no meaningful content or when dismissed
|
|
1227
|
+
const isThinkingSlot = slotName === MessengerSlotFillNameEnum.THINKING_NAME;
|
|
1228
|
+
const shouldShowThinkingSlot = !!attachment && attachment.dismissed !== true && (attachment.isThinking === true || attachment.thought != null && String(attachment.thought).trim() !== '');
|
|
1229
|
+
const shouldShowSlot = isThinkingSlot ? shouldShowThinkingSlot : !!attachment;
|
|
1230
|
+
const hasStreamingSlot = !!slotName && shouldShowSlot;
|
|
1231
|
+
return React__default.createElement("div", {
|
|
1232
|
+
className: `group/message transition-all duration-200 hover:bg-gray-50 rounded-lg px-3 py-1 -mx-3 ${isSystemMessage || isAssistantRole ? 'cursor-pointer' : ''}`,
|
|
1233
|
+
onClick: isSystemMessage || isAssistantRole ? handleClick : undefined
|
|
1234
|
+
}, React__default.createElement("div", {
|
|
1235
|
+
className: "flex items-start justify-between gap-3"
|
|
1236
|
+
}, React__default.createElement("div", {
|
|
1237
|
+
className: "flex-1 min-w-0"
|
|
1238
|
+
}, slotName && shouldShowSlot && React__default.createElement(Slot, {
|
|
1239
|
+
name: slotName,
|
|
1240
|
+
fillProps: {
|
|
1241
|
+
active: true,
|
|
1242
|
+
message,
|
|
1243
|
+
index: 0,
|
|
1244
|
+
onMessageClick
|
|
1245
|
+
}
|
|
1246
|
+
}), !hasStreamingSlot && message.message && React__default.createElement("div", {
|
|
1247
|
+
className: `max-w-none ${isSystemMessage ? 'text-gray-800' : 'text-gray-900'}`,
|
|
1248
|
+
dir: detectTextDirection(message?.message || ''),
|
|
1249
|
+
lang: detectLanguageTag(message?.message || '')
|
|
1250
|
+
}, (() => {
|
|
1251
|
+
const contentType = detectContentType(message.message);
|
|
1252
|
+
// Markdown and text both go through FormattedMessageContent
|
|
1253
|
+
// which will intelligently detect and render markdown
|
|
1254
|
+
if (contentType === 'code') {
|
|
1255
|
+
return React__default.createElement(CodeFormatter, {
|
|
1256
|
+
content: message.message,
|
|
1257
|
+
showCopyDownload: showCopyDownloadOnCodeBlock
|
|
1258
|
+
});
|
|
1259
|
+
} else if (contentType === 'html') {
|
|
1260
|
+
return React__default.createElement("div", {
|
|
1261
|
+
className: "max-w-none text-gray-800 html-content",
|
|
1262
|
+
dangerouslySetInnerHTML: {
|
|
1263
|
+
__html: prettifyHtmlContent(sanitizeHtml(message.message))
|
|
1264
|
+
}
|
|
1265
|
+
});
|
|
1266
|
+
} else {
|
|
1267
|
+
// Handle both 'markdown' and 'text' - FormattedMessageContent
|
|
1268
|
+
// will detect markdown patterns and render accordingly
|
|
1269
|
+
return React__default.createElement(FormattedMessageContent, {
|
|
1270
|
+
content: message.message,
|
|
1271
|
+
showCopyDownloadOnCodeBlock: showCopyDownloadOnCodeBlock
|
|
1272
|
+
});
|
|
1273
|
+
}
|
|
1274
|
+
})()), !hasStreamingSlot && tryExtractBuilderBlocks(message?.message)?.length ? React__default.createElement("div", {
|
|
1275
|
+
className: "mt-3 p-3 bg-gray-50 rounded-lg border border-gray-200"
|
|
1276
|
+
}, React__default.createElement(BuilderLikeRenderer, {
|
|
1277
|
+
blocks: tryExtractBuilderBlocks(message?.message)
|
|
1278
|
+
})) : null, !hasStreamingSlot && message?.props?.blocks?.length ? React__default.createElement("div", {
|
|
1279
|
+
className: "mt-3 p-3 bg-gray-50 rounded-lg border border-gray-200"
|
|
1280
|
+
}, React__default.createElement(BuilderLikeRenderer, {
|
|
1281
|
+
blocks: message.props.blocks
|
|
1282
|
+
})) : null, !hasStreamingSlot && message.files?.totalCount > 0 ? React__default.createElement("div", {
|
|
1283
|
+
className: "mt-3 p-3 bg-gray-50 rounded-lg border border-gray-200"
|
|
1284
|
+
}, React__default.createElement(FilesList, {
|
|
1285
|
+
uploaded: true,
|
|
1286
|
+
files: message.files.data
|
|
1287
|
+
})) : null)), showTimestamp ? React__default.createElement("div", {
|
|
1288
|
+
className: "text-[10px] text-gray-500 mt-1 text-right"
|
|
1289
|
+
}, formatTime(message.createdAt)) : null);
|
|
1290
|
+
};
|
|
1291
|
+
const ModernMessageGroupComponent = ({
|
|
1292
|
+
messages,
|
|
1293
|
+
currentUser,
|
|
1294
|
+
showAuthorName = false,
|
|
1295
|
+
showAvatar = false,
|
|
1296
|
+
showTimestamp = false,
|
|
1297
|
+
onOpen,
|
|
1298
|
+
onMessageClick,
|
|
1299
|
+
isDesktopView = false,
|
|
1300
|
+
isSmallScreen = false,
|
|
1301
|
+
sandboxErrors = [],
|
|
1302
|
+
currentFiles = {},
|
|
1303
|
+
onFixError,
|
|
1304
|
+
showCopyDownloadOnCodeBlock = false
|
|
1305
|
+
}) => {
|
|
1306
|
+
// Inject CSS styles for HTML content
|
|
1307
|
+
useInjectStyles();
|
|
1308
|
+
// Filter out non-message items (like date strings)
|
|
1309
|
+
const actualMessages = messages.filter(msg => typeof msg !== 'string');
|
|
1310
|
+
// Group messages by user and time
|
|
1311
|
+
const messageGroups = groupMessagesByUserAndTime(actualMessages);
|
|
1312
|
+
return React__default.createElement("div", {
|
|
1313
|
+
className: `min-h-fit ${isDesktopView ? 'space-y-6' : isSmallScreen ? 'space-y-4' : 'space-y-5'}`
|
|
1314
|
+
}, messageGroups.map((group, groupIndex) => {
|
|
1315
|
+
const author = group[0]?.author;
|
|
1316
|
+
return React__default.createElement(ModernMessageGroup, {
|
|
1317
|
+
key: `group-${groupIndex}-${group[0]?.id}`,
|
|
1318
|
+
author: author,
|
|
1319
|
+
messages: group,
|
|
1320
|
+
currentUser: currentUser,
|
|
1321
|
+
onOpen: onOpen,
|
|
1322
|
+
onMessageClick: onMessageClick,
|
|
1323
|
+
isDesktopView: isDesktopView,
|
|
1324
|
+
isSmallScreen: isSmallScreen,
|
|
1325
|
+
showAuthorName: showAuthorName,
|
|
1326
|
+
showAvatar: showAvatar,
|
|
1327
|
+
showTimestamp: showTimestamp,
|
|
1328
|
+
showCopyDownloadOnCodeBlock: showCopyDownloadOnCodeBlock
|
|
1329
|
+
});
|
|
1330
|
+
}), sandboxErrors?.map(error => React__default.createElement("div", {
|
|
1331
|
+
key: error.id,
|
|
1332
|
+
className: "px-2"
|
|
1333
|
+
}, React__default.createElement(ErrorFixCard, {
|
|
1334
|
+
error: error,
|
|
1335
|
+
onFixError: onFixError || (() => Promise.resolve()),
|
|
1336
|
+
currentFiles: currentFiles,
|
|
1337
|
+
isFixing: false
|
|
1338
|
+
}))));
|
|
1339
|
+
};export{CodeFormatter,FormattedMessageContent,ModernMessageGroupComponent,detectContentType,groupMessagesByUserAndTime};//# sourceMappingURL=ModernMessageGroup.js.map
|