@carbon/ai-chat 0.4.0-rc.2 → 0.4.0-rc.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/aiChatEntry.js +220 -14
- package/dist/es/chat.AppContainer.js +6491 -0
- package/dist/es/chat.AppState.js +40 -0
- package/dist/es/{chat/shared/components/BasePanelComponent.js → chat.BasePanelComponent.js} +3 -3
- package/dist/es/{chat/shared/components/panels/BodyAndFooterPanelComponent.js → chat.BodyAndFooterPanelComponent.js} +92 -9
- package/dist/es/chat.BodyWithFooterComponent.js +140 -0
- package/dist/es/{chat/shared/components/header/BotHeader.js → chat.BotHeader.js} +7 -9
- package/dist/es/{chat/shared/components/responseTypes/carousel/Carousel.js → chat.Carousel.js} +3 -3
- package/dist/es/chat.CatastrophicError.js +381 -0
- package/dist/es/chat.Chat.js +2009 -0
- package/dist/es/chat.Disclaimer.js +553 -0
- package/dist/es/chat.Header.js +1025 -0
- package/dist/es/{chat/shared/components/util/HideComponent.js → chat.HideComponent.js} +9 -2
- package/dist/es/{types/config/HomeScreenConfig.js → chat.HomeScreenConfig.js} +1 -1
- package/dist/es/{chat/shared/components/homeScreen/HomeScreen.js → chat.HomeScreenContainer.js} +159 -14
- package/dist/es/{chat/shared/components/homeScreen/HomeScreenHeader.js → chat.HomeScreenHeader.js} +3 -3
- package/dist/es/{chat/shared/services/haa/HumanAgentServiceImpl.js → chat.HumanAgentServiceImpl.js} +215 -17
- package/dist/es/{chat/shared/components/responseTypes/iframe/IFrameComponent.js → chat.IFrameComponent.js} +4 -8
- package/dist/es/chat.IFramePanel.js +151 -0
- package/dist/es/{chat/shared/components/input/Input.js → chat.Input.js} +214 -18
- package/dist/es/{types/config/ServiceDeskConfig.js → chat.LocalMessageItem.js} +17 -1
- package/dist/es/chat.MessageTypeComponent.js +3580 -0
- package/dist/es/{types/messaging/Messages.js → chat.Messages.js} +1 -1
- package/dist/es/chat.MountChildrenOnDelay.js +97 -0
- package/dist/es/{chat/shared/components/OverlayPanel.js → chat.PageObjectId.js} +70 -4
- package/dist/es/{chat/web-components/components/markdownText/src/markdownText.scss.js → chat.RichText.js} +347 -1
- package/dist/es/chat.TourContainer.js +524 -0
- package/dist/es/{chat/languages/en.json.js → chat.VideoComponent.js} +561 -1
- package/dist/es/chat.ViewSourcePanel.js +187 -0
- package/dist/es/{chat/shared/store/actions.js → chat.actions.js} +2 -2
- package/dist/es/{chat/shared/utils/browserUtils.js → chat.browserUtils.js} +1 -1
- package/dist/es/{types/utilities/carbonTypes.js → chat.carbonTypes.js} +2 -2
- package/dist/es/{chat/web-components/components/codeElement/src/codeElement.scss.js → chat.cds-aichat-code.js} +64 -1
- package/dist/es/{chat/shared/utils/constants.js → chat.constants.js} +4 -7
- package/dist/es/{types/events/eventBusTypes.js → chat.customElement.js} +32 -1
- package/dist/es/chat.dynamic-imports.js +192 -0
- package/dist/es/{chat/shared/utils/htmlUtils.js → chat.htmlUtils.js} +16 -2
- package/dist/es/{chat/shared/utils/messageUtils.js → chat.messageUtils.js} +54 -7
- package/dist/es/{chat/shared/utils/miscUtils.js → chat.miscUtils.js} +24 -5
- package/dist/es/chat.resolvablePromise.js +315 -0
- package/dist/es/{chat/shared/store/selectors.js → chat.selectors.js} +1 -1
- package/dist/es/{chat/shared/utils/lang/stringUtils.js → chat.stringUtils.js} +2 -2
- package/dist/es/{chat/shared/hooks/useCounter.js → chat.useCounter.js} +1 -1
- package/dist/es/{chat/shared/hooks/useOnMount.js → chat.useOnMount.js} +1 -1
- package/dist/es/{chat/shared/utils/domUtils.js → chat.usePrevious.js} +47 -1
- package/dist/es/{chat/shared/utils/lang/UUIDType.js → chat.uuid.js} +15 -3
- package/dist/es/web-components/cds-aichat-container/index.js +73 -4
- package/dist/es/web-components/cds-aichat-custom-element/index.js +1 -3
- package/package.json +2 -2
- package/dist/es/chat/dynamic-imports/dynamic-imports.js +0 -96
- package/dist/es/chat/react/components/AppContainer.js +0 -197
- package/dist/es/chat/react/components/UserDefinedResponsePortalsContainer.js +0 -31
- package/dist/es/chat/react/components/WriteableElementsPortalsContainer.js +0 -28
- package/dist/es/chat/react/components/chainOfThought/ChainOfThought.js +0 -20
- package/dist/es/chat/react/components/chatHeader/ChatHeaderAvatar.js +0 -20
- package/dist/es/chat/react/components/chatHeader/ChatHeaderLink.js +0 -22
- package/dist/es/chat/react/components/chatHeader/ChatHeaderMenu.js +0 -27
- package/dist/es/chat/react/components/chatHeader/ChatHeaderMenuButton.js +0 -60
- package/dist/es/chat/react/components/chatHeader/ChatHeaderMenuItem.js +0 -24
- package/dist/es/chat/react/components/chatHeader/ChatHeaderMenuItemRadioGroup.js +0 -28
- package/dist/es/chat/react/components/chatHeader/ChatHeaderOverflowMenu.js +0 -69
- package/dist/es/chat/react/components/chatHeader/ChatHeaderTitle.js +0 -22
- package/dist/es/chat/react/components/feedback/FeedbackButtonsComponent.js +0 -20
- package/dist/es/chat/react/components/feedback/FeedbackComponent.js +0 -20
- package/dist/es/chat/react/components/inlineLoading/InlineLoadingComponent.js +0 -20
- package/dist/es/chat/react/components/markdownText/MarkdownText.js +0 -20
- package/dist/es/chat/react/components/stopStreamingButton/StopStreamingButton.js +0 -20
- package/dist/es/chat/react/components/table/Table.js +0 -20
- package/dist/es/chat/shared/Chat.js +0 -115
- package/dist/es/chat/shared/ChatInstanceImpl.js +0 -360
- package/dist/es/chat/shared/chatEntryFunctions.js +0 -46
- package/dist/es/chat/shared/components/Avatar.js +0 -286
- package/dist/es/chat/shared/components/BodyWithFooterComponent.js +0 -56
- package/dist/es/chat/shared/components/CatastrophicError.js +0 -77
- package/dist/es/chat/shared/components/Chat.js +0 -244
- package/dist/es/chat/shared/components/ChatBubbleDark.js +0 -124
- package/dist/es/chat/shared/components/ChatBubbleLight.js +0 -216
- package/dist/es/chat/shared/components/Disclaimer.js +0 -86
- package/dist/es/chat/shared/components/ErrorIcon.js +0 -20
- package/dist/es/chat/shared/components/ErrorMessageDark.js +0 -89
- package/dist/es/chat/shared/components/ErrorMessageLight.js +0 -135
- package/dist/es/chat/shared/components/HydrationPanel.js +0 -58
- package/dist/es/chat/shared/components/LatestWelcomeNodes.js +0 -26
- package/dist/es/chat/shared/components/ResponseStopped.js +0 -19
- package/dist/es/chat/shared/components/SkeletonPicker.js +0 -32
- package/dist/es/chat/shared/components/WriteableElement.js +0 -22
- package/dist/es/chat/shared/components/agent/AgentAvatar.js +0 -54
- package/dist/es/chat/shared/components/agent/AgentBanner.js +0 -109
- package/dist/es/chat/shared/components/agent/AgentBannerContainer.js +0 -28
- package/dist/es/chat/shared/components/agent/AvailabilityMessage.js +0 -49
- package/dist/es/chat/shared/components/aria/AriaAnnouncerComponent.js +0 -122
- package/dist/es/chat/shared/components/aria/AriaAnnouncerProvider.js +0 -48
- package/dist/es/chat/shared/components/aria/AriaLiveMessage.js +0 -22
- package/dist/es/chat/shared/components/header/AISlug.js +0 -22
- package/dist/es/chat/shared/components/header/Header.js +0 -460
- package/dist/es/chat/shared/components/header/SimpleHeader.js +0 -27
- package/dist/es/chat/shared/components/homeScreen/HomeScreenContainer.js +0 -68
- package/dist/es/chat/shared/components/launcher/Launcher.js +0 -88
- package/dist/es/chat/shared/components/launcher/LauncherComplex.js +0 -63
- package/dist/es/chat/shared/components/launcher/LauncherContainer.js +0 -73
- package/dist/es/chat/shared/components/launcher/LauncherDesktopContainer.js +0 -221
- package/dist/es/chat/shared/components/launcher/LauncherExtended.js +0 -244
- package/dist/es/chat/shared/components/launcher/LauncherMobileContainer.js +0 -175
- package/dist/es/chat/shared/components/launcher/launcherUtils.js +0 -16
- package/dist/es/chat/shared/components/modals/ConfirmModal.js +0 -67
- package/dist/es/chat/shared/components/modals/EndAgentChatModal.js +0 -46
- package/dist/es/chat/shared/components/modals/RequestScreenShareModal.js +0 -43
- package/dist/es/chat/shared/components/notifications/Notifications.js +0 -58
- package/dist/es/chat/shared/components/panels/CustomPanel.js +0 -136
- package/dist/es/chat/shared/components/responseTypes/agent/ConnectToAgent.js +0 -30
- package/dist/es/chat/shared/components/responseTypes/agent/RealConnectToAgent.js +0 -102
- package/dist/es/chat/shared/components/responseTypes/audio/AudioComponent.js +0 -26
- package/dist/es/chat/shared/components/responseTypes/buttonItem/BaseButtonItemComponent.js +0 -69
- package/dist/es/chat/shared/components/responseTypes/buttonItem/ButtonItemComponent.js +0 -48
- package/dist/es/chat/shared/components/responseTypes/buttonItem/ButtonItemCustomEventComponent.js +0 -42
- package/dist/es/chat/shared/components/responseTypes/buttonItem/ButtonItemPostBackComponent.js +0 -54
- package/dist/es/chat/shared/components/responseTypes/buttonItem/ButtonItemShowPanelComponent.js +0 -36
- package/dist/es/chat/shared/components/responseTypes/buttonItem/ButtonItemURLComponent.js +0 -42
- package/dist/es/chat/shared/components/responseTypes/card/CardItemComponent.js +0 -34
- package/dist/es/chat/shared/components/responseTypes/carousel/CarouselItemComponent.js +0 -39
- package/dist/es/chat/shared/components/responseTypes/conversationalSearch/ConversationalSearch.js +0 -92
- package/dist/es/chat/shared/components/responseTypes/conversationalSearch/ConversationalSearchText.js +0 -158
- package/dist/es/chat/shared/components/responseTypes/custom/UserDefinedResponse.js +0 -33
- package/dist/es/chat/shared/components/responseTypes/datePicker/DatePickerComponent.js +0 -176
- package/dist/es/chat/shared/components/responseTypes/error/InlineError.js +0 -32
- package/dist/es/chat/shared/components/responseTypes/grid/GridItemComponent.js +0 -109
- package/dist/es/chat/shared/components/responseTypes/iframe/IFrameMessage.js +0 -32
- package/dist/es/chat/shared/components/responseTypes/iframe/IFramePanel.js +0 -51
- package/dist/es/chat/shared/components/responseTypes/iframe/IFramePreviewCard.js +0 -64
- package/dist/es/chat/shared/components/responseTypes/iframe/InlineIFrame.js +0 -55
- package/dist/es/chat/shared/components/responseTypes/image/Image.js +0 -120
- package/dist/es/chat/shared/components/responseTypes/options/OptionComponent.js +0 -83
- package/dist/es/chat/shared/components/responseTypes/options/SelectComponent.js +0 -84
- package/dist/es/chat/shared/components/responseTypes/table/TableContainer.js +0 -96
- package/dist/es/chat/shared/components/responseTypes/text/TextArea.js +0 -68
- package/dist/es/chat/shared/components/responseTypes/tour/TourCard.js +0 -73
- package/dist/es/chat/shared/components/responseTypes/util/BodyMessageComponents.js +0 -65
- package/dist/es/chat/shared/components/responseTypes/util/ClickableImage.js +0 -36
- package/dist/es/chat/shared/components/responseTypes/util/Description.js +0 -21
- package/dist/es/chat/shared/components/responseTypes/util/FooterButtonComponents.js +0 -36
- package/dist/es/chat/shared/components/responseTypes/util/MediaPlayer.js +0 -157
- package/dist/es/chat/shared/components/responseTypes/util/Metablock.js +0 -27
- package/dist/es/chat/shared/components/responseTypes/util/RichText.js +0 -31
- package/dist/es/chat/shared/components/responseTypes/util/SearchResultBody.js +0 -53
- package/dist/es/chat/shared/components/responseTypes/util/StreamingRichText.js +0 -38
- package/dist/es/chat/shared/components/responseTypes/util/TextHolderTile.js +0 -35
- package/dist/es/chat/shared/components/responseTypes/util/citations/CitationCard.js +0 -65
- package/dist/es/chat/shared/components/responseTypes/util/citations/CitationCardContent.js +0 -62
- package/dist/es/chat/shared/components/responseTypes/util/citations/CitationClickableCard.js +0 -23
- package/dist/es/chat/shared/components/responseTypes/util/citations/ExpandToPanelCard.js +0 -50
- package/dist/es/chat/shared/components/responseTypes/util/citations/ViewSourcePanel.js +0 -57
- package/dist/es/chat/shared/components/responseTypes/video/VideoComponent.js +0 -23
- package/dist/es/chat/shared/components/tour/TourCloseMinimizeComponent.js +0 -44
- package/dist/es/chat/shared/components/tour/TourContainer.js +0 -212
- package/dist/es/chat/shared/components/tour/TourControlsComponent.js +0 -98
- package/dist/es/chat/shared/components/tour/TourStepContentComponent.js +0 -156
- package/dist/es/chat/shared/components/tour/TourStepSkeletonComponent.js +0 -20
- package/dist/es/chat/shared/components/util/AnnounceOnMountComponent.js +0 -42
- package/dist/es/chat/shared/components/util/IconHolder.js +0 -16
- package/dist/es/chat/shared/components/util/ImageWithFallback.js +0 -31
- package/dist/es/chat/shared/components/util/MaybeDangerouslySetInnerHTML.js +0 -42
- package/dist/es/chat/shared/components/util/MountChildrenOnDelay.js +0 -40
- package/dist/es/chat/shared/components/util/VisuallyHidden.js +0 -18
- package/dist/es/chat/shared/containers/App.js +0 -181
- package/dist/es/chat/shared/containers/MessageComponent.js +0 -465
- package/dist/es/chat/shared/containers/MessageTypeComponent.js +0 -496
- package/dist/es/chat/shared/containers/MessagesComponent.js +0 -469
- package/dist/es/chat/shared/containers/ModalPortal.js +0 -53
- package/dist/es/chat/shared/containers/main/MainWindow.js +0 -708
- package/dist/es/chat/shared/contexts/AriaAnnouncerContext.js +0 -12
- package/dist/es/chat/shared/contexts/HideComponentContext.js +0 -12
- package/dist/es/chat/shared/contexts/LanguagePackContext.js +0 -12
- package/dist/es/chat/shared/contexts/ModalPortalRootContext.js +0 -12
- package/dist/es/chat/shared/contexts/ServiceManagerContext.js +0 -12
- package/dist/es/chat/shared/contexts/WindowSizeContext.js +0 -12
- package/dist/es/chat/shared/environmentVariables.js +0 -13
- package/dist/es/chat/shared/events/ChatActionsImpl.js +0 -783
- package/dist/es/chat/shared/events/EventBus.js +0 -161
- package/dist/es/chat/shared/hocs/withAriaAnnouncer.js +0 -25
- package/dist/es/chat/shared/hocs/withServiceManager.js +0 -25
- package/dist/es/chat/shared/hooks/useAriaAnnouncer.js +0 -16
- package/dist/es/chat/shared/hooks/useCSSCustomProperties.js +0 -21
- package/dist/es/chat/shared/hooks/useCallbackOnChange.js +0 -24
- package/dist/es/chat/shared/hooks/useEffectDidUpdate.js +0 -21
- package/dist/es/chat/shared/hooks/useLanguagePack.js +0 -16
- package/dist/es/chat/shared/hooks/usePrevious.js +0 -18
- package/dist/es/chat/shared/hooks/useServiceManager.js +0 -16
- package/dist/es/chat/shared/hooks/useShouldSanitizeHTML.js +0 -15
- package/dist/es/chat/shared/hooks/useUUID.js +0 -22
- package/dist/es/chat/shared/hooks/useWindowSize.js +0 -16
- package/dist/es/chat/shared/loadServices.js +0 -72
- package/dist/es/chat/shared/schema/historyToMessages.js +0 -231
- package/dist/es/chat/shared/schema/inputItemToLocalItem.js +0 -30
- package/dist/es/chat/shared/schema/outputItemToLocalItem.js +0 -124
- package/dist/es/chat/shared/services/CustomPanelInstance.js +0 -26
- package/dist/es/chat/shared/services/CustomPanelManager.js +0 -23
- package/dist/es/chat/shared/services/HistoryService.js +0 -59
- package/dist/es/chat/shared/services/MessageService.js +0 -351
- package/dist/es/chat/shared/services/NamespaceService.js +0 -26
- package/dist/es/chat/shared/services/ServiceManager.js +0 -19
- package/dist/es/chat/shared/services/UserSessionStorageService.js +0 -89
- package/dist/es/chat/shared/services/haa/agentStatusMessage.js +0 -108
- package/dist/es/chat/shared/services/haa/humanAgentUtils.js +0 -114
- package/dist/es/chat/shared/services/mockStorage.js +0 -30
- package/dist/es/chat/shared/store/agentActions.js +0 -125
- package/dist/es/chat/shared/store/agentReducers.js +0 -215
- package/dist/es/chat/shared/store/doCreateStore.js +0 -142
- package/dist/es/chat/shared/store/reducerUtils.js +0 -320
- package/dist/es/chat/shared/store/reducers.js +0 -871
- package/dist/es/chat/shared/store/subscriptions.js +0 -55
- package/dist/es/chat/shared/store/tourReducerUtils.js +0 -51
- package/dist/es/chat/shared/utils/ListenerList.js +0 -26
- package/dist/es/chat/shared/utils/PageObjectId.js +0 -25
- package/dist/es/chat/shared/utils/animationUtils.js +0 -77
- package/dist/es/chat/shared/utils/colors.js +0 -71
- package/dist/es/chat/shared/utils/customizers.js +0 -16
- package/dist/es/chat/shared/utils/dateUtils.js +0 -38
- package/dist/es/chat/shared/utils/homeScreenUtils.js +0 -27
- package/dist/es/chat/shared/utils/intlUtils.js +0 -21
- package/dist/es/chat/shared/utils/lang/arrayUtils.js +0 -53
- package/dist/es/chat/shared/utils/lang/langUtils.js +0 -13
- package/dist/es/chat/shared/utils/lang/objectUtils.js +0 -19
- package/dist/es/chat/shared/utils/lang/promiseUtils.js +0 -25
- package/dist/es/chat/shared/utils/lang/uuid.js +0 -16
- package/dist/es/chat/shared/utils/languages.js +0 -156
- package/dist/es/chat/shared/utils/memoizerUtils.js +0 -38
- package/dist/es/chat/shared/utils/messageServiceUtils.js +0 -36
- package/dist/es/chat/shared/utils/resolvablePromise.js +0 -32
- package/dist/es/chat/shared/utils/styleUtils.js +0 -231
- package/dist/es/chat/shared/utils/timeUtils.js +0 -14
- package/dist/es/chat/shared/utils/viewStateUtils.js +0 -38
- package/dist/es/chat/web-components/components/chainOfThought/cds-aichat-chain-of-thought.js +0 -26
- package/dist/es/chat/web-components/components/chainOfThought/src/ChainOfThoughtElement.js +0 -130
- package/dist/es/chat/web-components/components/chainOfThought/src/chainOfThoughtElement.scss.js +0 -3
- package/dist/es/chat/web-components/components/chainOfThought/src/chainOfThoughtElement.template.js +0 -186
- package/dist/es/chat/web-components/components/chatHeader/chatHeaderAvatar/cds-aichat-chat-header-avatar.js +0 -26
- package/dist/es/chat/web-components/components/chatHeader/chatHeaderAvatar/src/chatHeaderAvatar.template.js +0 -32
- package/dist/es/chat/web-components/components/chatHeader/chatHeaderAvatar/src/chatHeaderAvatarElement.js +0 -52
- package/dist/es/chat/web-components/components/chatHeader/chatHeaderAvatar/src/chatHeaderAvatarElement.scss.js +0 -3
- package/dist/es/chat/web-components/components/chatHeader/chatHeaderLink/cds-aichat-chat-header-link.js +0 -44
- package/dist/es/chat/web-components/components/chatHeader/chatHeaderLink/src/chatHeaderLinkElement.template.js +0 -28
- package/dist/es/chat/web-components/components/chatHeader/chatHeaderTitle/cds-aichat-chat-header-title.js +0 -42
- package/dist/es/chat/web-components/components/chatHeader/chatHeaderTitle/src/chatHeaderTitle.scss.js +0 -3
- package/dist/es/chat/web-components/components/chatHeader/chatHeaderTitle/src/chatHeaderTitle.template.js +0 -20
- package/dist/es/chat/web-components/components/codeElement/cds-aichat-code.js +0 -66
- package/dist/es/chat/web-components/components/feedbackButtonsElement/cds-aichat-feedback-buttons.js +0 -26
- package/dist/es/chat/web-components/components/feedbackButtonsElement/src/FeedbackButtonsElement.js +0 -93
- package/dist/es/chat/web-components/components/feedbackButtonsElement/src/feedbackButtonsElement.scss.js +0 -3
- package/dist/es/chat/web-components/components/feedbackButtonsElement/src/feedbackButtonsElement.template.js +0 -84
- package/dist/es/chat/web-components/components/feedbackElement/cds-aichat-feedback.js +0 -30
- package/dist/es/chat/web-components/components/feedbackElement/src/FeedbackElement.js +0 -157
- package/dist/es/chat/web-components/components/feedbackElement/src/feedbackElement.scss.js +0 -3
- package/dist/es/chat/web-components/components/feedbackElement/src/feedbackElement.template.js +0 -95
- package/dist/es/chat/web-components/components/inlineLoadingElement/cds-aichat-inline-loading.js +0 -85
- package/dist/es/chat/web-components/components/inlineLoadingElement/src/styles.scss.js +0 -3
- package/dist/es/chat/web-components/components/markdownText/cds-aichat-markdown-text.js +0 -32
- package/dist/es/chat/web-components/components/markdownText/markdown/markdownToHTML.js +0 -28
- package/dist/es/chat/web-components/components/markdownText/markdown/utils/renderTokenTree.js +0 -191
- package/dist/es/chat/web-components/components/markdownText/markdown/workers/workerManager.js +0 -16
- package/dist/es/chat/web-components/components/markdownText/src/MarkdownElement.js +0 -70
- package/dist/es/chat/web-components/components/markdownText/src/markdownElement.template.js +0 -19
- package/dist/es/chat/web-components/components/roundedButton/cds-aichat-rounded-button.js +0 -29
- package/dist/es/chat/web-components/components/stopStreamingButton/cds-aichat-stop-streaming-button.js +0 -26
- package/dist/es/chat/web-components/components/stopStreamingButton/src/StopStreamingButtonElement.js +0 -49
- package/dist/es/chat/web-components/components/stopStreamingButton/src/stopStreamingButton.scss.js +0 -3
- package/dist/es/chat/web-components/components/stopStreamingButton/src/stopStreamingButton.template.js +0 -44
- package/dist/es/chat/web-components/components/table/cds-aichat-table.js +0 -229
- package/dist/es/chat/web-components/components/table/src/table.scss.js +0 -3
- package/dist/es/chat/web-components/components/table/src/table.template.js +0 -81
- package/dist/es/chat/web-components/components/table/src/tablePagination.template.js +0 -43
- package/dist/es/chat/web-components/components/table/src/tableSkeleton.template.js +0 -17
- package/dist/es/chat/web-components/components/tagListElement/cds-aichat-tag-list.js +0 -28
- package/dist/es/chat/web-components/components/tagListElement/src/TagListElement.js +0 -70
- package/dist/es/chat/web-components/components/tagListElement/src/tagListElement.scss.js +0 -3
- package/dist/es/chat/web-components/components/tagListElement/src/tagListElement.template.js +0 -40
- package/dist/es/chat/web-components/decorators/customElement.js +0 -33
- package/dist/es/chat/web-components/internal/cds-aichat-internal.js +0 -78
- package/dist/es/chat/web-components/settings.js +0 -13
- package/dist/es/node_modules/@carbon/colors/es/index.js +0 -11
- package/dist/es/react/ChatContainer.js +0 -162
- package/dist/es/react/ChatCustomElement.js +0 -58
- package/dist/es/types/config/ChatHeaderConfig.js +0 -18
- package/dist/es/types/config/CornersType.js +0 -16
- package/dist/es/types/config/LauncherConfig.js +0 -19
- package/dist/es/types/config/PublicConfig.js +0 -36
- package/dist/es/types/instance/ChatInstance.js +0 -31
- package/dist/es/types/instance/apiTypes.js +0 -33
- package/dist/es/types/messaging/LocalMessageItem.js +0 -18
- package/dist/es/types/state/AppState.js +0 -18
- package/dist/es/types/utilities/Animation.js +0 -31
- package/dist/es/types/utilities/HasAddRemoveClassName.js +0 -27
- /package/dist/es/{chat/shared/styles/export.carbon.scss.js → chat.export.carbon.js} +0 -0
- /package/dist/es/{chat/shared/styles/export.scss.js → chat.export.js} +0 -0
- /package/dist/es/{chat/web-components/components/markdownText/markdown/utils/markdown.js → chat.markdown.js} +0 -0
- /package/dist/es/{chat/web-components/components/markdownText/markdown/utils/tokenTree.js → chat.tokenTree.js} +0 -0
|
@@ -0,0 +1,2009 @@
|
|
|
1
|
+
import React, { useState, useEffect, forwardRef, useRef, useImperativeHandle, useContext, PureComponent, Fragment, Component } from "react";
|
|
2
|
+
|
|
3
|
+
import { injectIntl, FormattedMessage } from "react-intl";
|
|
4
|
+
|
|
5
|
+
import { useSelector, shallowEqual, connect } from "react-redux";
|
|
6
|
+
|
|
7
|
+
import cx from "classnames";
|
|
8
|
+
|
|
9
|
+
import throttle from "lodash-es/throttle.js";
|
|
10
|
+
|
|
11
|
+
import { createComponent } from "@lit/react";
|
|
12
|
+
|
|
13
|
+
import { __decorate } from "tslib";
|
|
14
|
+
|
|
15
|
+
import { LitElement, html, unsafeCSS, css } from "lit";
|
|
16
|
+
|
|
17
|
+
import { property } from "lit/decorators.js";
|
|
18
|
+
|
|
19
|
+
import { c as carbonElement } from "./chat.customElement.js";
|
|
20
|
+
|
|
21
|
+
import { W as WEB_COMPONENT_PREFIX, a as WriteableElement, A as AriaLiveMessageExport, C as ConfirmModal } from "./chat.Header.js";
|
|
22
|
+
|
|
23
|
+
import { s as selectAgentDisplayState, a as selectInputState } from "./chat.selectors.js";
|
|
24
|
+
|
|
25
|
+
import ScreenOff from "@carbon/icons-react/es/ScreenOff.js";
|
|
26
|
+
|
|
27
|
+
import { Button, ActionableNotification, Loading } from "@carbon/react";
|
|
28
|
+
|
|
29
|
+
import { u as useLanguagePack } from "./chat.AppState.js";
|
|
30
|
+
|
|
31
|
+
import { u as useServiceManager, d as doFocusRef, S as ServiceManagerContext, a as doScrollElement, g as getScrollBottom, f as focusOnFirstFocusableItemInArrayOfElements } from "./chat.usePrevious.js";
|
|
32
|
+
|
|
33
|
+
import { u as useDynamicCSSProperties, A as AnnounceOnMountComponentExport, w as withAriaAnnouncer, V as VisuallyHidden } from "./chat.VideoComponent.js";
|
|
34
|
+
|
|
35
|
+
import UserAvatar from "@carbon/icons-react/es/UserAvatar.js";
|
|
36
|
+
|
|
37
|
+
import { A as AvailabilityMessage, n as nodeToText, M as MessageTypeComponent, E as EndAgentChatModal } from "./chat.MessageTypeComponent.js";
|
|
38
|
+
|
|
39
|
+
import { W as WriteableElementName, b as CarbonTheme, F as FileStatusValue } from "./chat.dynamic-imports.js";
|
|
40
|
+
|
|
41
|
+
import { a as actions } from "./chat.actions.js";
|
|
42
|
+
|
|
43
|
+
import { M as MessageErrorState, S as ScreenShareState } from "./chat.LocalMessageItem.js";
|
|
44
|
+
|
|
45
|
+
import { I as IS_MOBILE } from "./chat.browserUtils.js";
|
|
46
|
+
|
|
47
|
+
import { A as AUTO_SCROLL_EXTRA, a as AUTO_SCROLL_THROTTLE_TIMEOUT } from "./chat.constants.js";
|
|
48
|
+
|
|
49
|
+
import { i as isConnectToAgent, a as isRequest, b as isResponse, r as renderAsUserDefinedMessage, c as isOptionItem, d as isSingleItemCarousel, e as arrayLastValue } from "./chat.messageUtils.js";
|
|
50
|
+
|
|
51
|
+
import { a as createDidCatchErrorData, b as consoleError } from "./chat.miscUtils.js";
|
|
52
|
+
|
|
53
|
+
import ChatBot from "@carbon/icons-react/es/ChatBot.js";
|
|
54
|
+
|
|
55
|
+
import CheckmarkFilled from "@carbon/icons-react/es/CheckmarkFilled.js";
|
|
56
|
+
|
|
57
|
+
import Headset from "@carbon/icons-react/es/Headset.js";
|
|
58
|
+
|
|
59
|
+
import { u as uuid } from "./chat.uuid.js";
|
|
60
|
+
|
|
61
|
+
import "./chat.carbonTypes.js";
|
|
62
|
+
|
|
63
|
+
import { I as InlineError } from "./chat.MountChildrenOnDelay.js";
|
|
64
|
+
|
|
65
|
+
import dayjs from "dayjs";
|
|
66
|
+
|
|
67
|
+
import { b as MessageResponseTypes, A as AgentMessageType } from "./chat.Messages.js";
|
|
68
|
+
|
|
69
|
+
import memoizeOne from "memoize-one";
|
|
70
|
+
|
|
71
|
+
import { CatastrophicError as CatastrophicErrorExport } from "./chat.CatastrophicError.js";
|
|
72
|
+
|
|
73
|
+
import { B as BotHeaderExport } from "./chat.BotHeader.js";
|
|
74
|
+
|
|
75
|
+
import { I as InputExport } from "./chat.Input.js";
|
|
76
|
+
|
|
77
|
+
import { O as OverlayPanelName } from "./chat.PageObjectId.js";
|
|
78
|
+
|
|
79
|
+
import "@carbon/web-components/es-custom/components/slug/index.js";
|
|
80
|
+
|
|
81
|
+
import "@carbon/icons-react/es/Close.js";
|
|
82
|
+
|
|
83
|
+
import "@carbon/icons-react/es/CloseLarge.js";
|
|
84
|
+
|
|
85
|
+
import "@carbon/icons-react/es/DownToBottom.js";
|
|
86
|
+
|
|
87
|
+
import "@carbon/icons-react/es/Menu.js";
|
|
88
|
+
|
|
89
|
+
import "@carbon/icons-react/es/Restart.js";
|
|
90
|
+
|
|
91
|
+
import "@carbon/icons-react/es/SidePanelClose.js";
|
|
92
|
+
|
|
93
|
+
import "@carbon/icons-react/es/SubtractLarge.js";
|
|
94
|
+
|
|
95
|
+
import "@carbon/web-components/es-custom/components/ai-label/defs.js";
|
|
96
|
+
|
|
97
|
+
import "@carbon/web-components/es-custom/components/popover/defs.js";
|
|
98
|
+
|
|
99
|
+
import "@carbon/web-components/es-custom/components/skeleton-icon/index.js";
|
|
100
|
+
|
|
101
|
+
import "bind-decorator";
|
|
102
|
+
|
|
103
|
+
import "@carbon/web-components/es-custom/components/button/index.js";
|
|
104
|
+
|
|
105
|
+
import "@carbon/web-components/es-custom/components/overflow-menu/index.js";
|
|
106
|
+
|
|
107
|
+
import "@carbon/icons-react/es/ChevronDown.js";
|
|
108
|
+
|
|
109
|
+
import "@carbon/icons-react/es/ChevronUp.js";
|
|
110
|
+
|
|
111
|
+
import "@floating-ui/react";
|
|
112
|
+
|
|
113
|
+
import "./chat.HideComponent.js";
|
|
114
|
+
|
|
115
|
+
import "focus-trap-react";
|
|
116
|
+
|
|
117
|
+
import "react-dom";
|
|
118
|
+
|
|
119
|
+
import "@carbon/web-components/es-custom/components/ai-label/ai-label-action-button.js";
|
|
120
|
+
|
|
121
|
+
import "@carbon/web-components/es-custom/components/ai-label/ai-label.js";
|
|
122
|
+
|
|
123
|
+
import "compute-scroll-into-view";
|
|
124
|
+
|
|
125
|
+
import "tabbable";
|
|
126
|
+
|
|
127
|
+
import "dayjs/locale/en.js";
|
|
128
|
+
|
|
129
|
+
import "intl-messageformat";
|
|
130
|
+
|
|
131
|
+
import "@carbon/icons-react/es/Music.js";
|
|
132
|
+
|
|
133
|
+
import "@carbon/icons-react/es/Attachment.js";
|
|
134
|
+
|
|
135
|
+
import "@carbon/web-components/es-custom/components/textarea/index.js";
|
|
136
|
+
|
|
137
|
+
import "@carbon/web-components/es-custom/components/icon-button/index.js";
|
|
138
|
+
|
|
139
|
+
import "@carbon/icon-helpers";
|
|
140
|
+
|
|
141
|
+
import "@carbon/icons/es/thumbs-down/16.js";
|
|
142
|
+
|
|
143
|
+
import "@carbon/icons/es/thumbs-down--filled/16.js";
|
|
144
|
+
|
|
145
|
+
import "@carbon/icons/es/thumbs-up/16.js";
|
|
146
|
+
|
|
147
|
+
import "@carbon/icons/es/thumbs-up--filled/16.js";
|
|
148
|
+
|
|
149
|
+
import "lit/directives/unsafe-svg.js";
|
|
150
|
+
|
|
151
|
+
import "@carbon/web-components/es-custom/components/tag/index.js";
|
|
152
|
+
|
|
153
|
+
import "@carbon/web-components/es-custom/components/chat-button/index.js";
|
|
154
|
+
|
|
155
|
+
import "@carbon/web-components/es-custom/components/button/button.js";
|
|
156
|
+
|
|
157
|
+
import "@carbon/web-components/es-custom/components/layer/index.js";
|
|
158
|
+
|
|
159
|
+
import "@carbon/icons-react/es/Checkmark.js";
|
|
160
|
+
|
|
161
|
+
import "@carbon/icons-react/es/HelpDesk.js";
|
|
162
|
+
|
|
163
|
+
import "@carbon/icons-react/es/Logout.js";
|
|
164
|
+
|
|
165
|
+
import "./chat.RichText.js";
|
|
166
|
+
|
|
167
|
+
import "dompurify";
|
|
168
|
+
|
|
169
|
+
import "lit/directives/repeat.js";
|
|
170
|
+
|
|
171
|
+
import "lit/directives/unsafe-html.js";
|
|
172
|
+
|
|
173
|
+
import "./chat.htmlUtils.js";
|
|
174
|
+
|
|
175
|
+
import "./chat.stringUtils.js";
|
|
176
|
+
|
|
177
|
+
import "@carbon/icons-react/es/TouchInteraction.js";
|
|
178
|
+
|
|
179
|
+
import "@carbon/icons-react/es/Send.js";
|
|
180
|
+
|
|
181
|
+
import "@carbon/icons-react/es/ArrowRight.js";
|
|
182
|
+
|
|
183
|
+
import "@carbon/icons-react/es/Launch.js";
|
|
184
|
+
|
|
185
|
+
import "./chat.BodyWithFooterComponent.js";
|
|
186
|
+
|
|
187
|
+
import "lodash-es/debounce.js";
|
|
188
|
+
|
|
189
|
+
import "@carbon/icons-react/es/Link.js";
|
|
190
|
+
|
|
191
|
+
import "@carbon/icons-react/es/Maximize.js";
|
|
192
|
+
|
|
193
|
+
import "./chat.useCounter.js";
|
|
194
|
+
|
|
195
|
+
import "./chat.useOnMount.js";
|
|
196
|
+
|
|
197
|
+
import "./chat.IFrameComponent.js";
|
|
198
|
+
|
|
199
|
+
import "csv-stringify/browser/esm/sync";
|
|
200
|
+
|
|
201
|
+
import "@carbon/web-components/es-custom/components/data-table/index.js";
|
|
202
|
+
|
|
203
|
+
import "@carbon/web-components/es-custom/components/checkbox/index.js";
|
|
204
|
+
|
|
205
|
+
import "@carbon/icons/es/download/16.js";
|
|
206
|
+
|
|
207
|
+
import "lit-html/directives/repeat.js";
|
|
208
|
+
|
|
209
|
+
import "@carbon/web-components/es-custom/components/pagination/index.js";
|
|
210
|
+
|
|
211
|
+
import "@carbon/web-components/es-custom/components/select/index.js";
|
|
212
|
+
|
|
213
|
+
import "@carbon/web-components/es-custom/components/data-table/table-skeleton.js";
|
|
214
|
+
|
|
215
|
+
import "@carbon/web-components/es-custom/components/inline-loading/index.js";
|
|
216
|
+
|
|
217
|
+
import "@carbon/icons/es/checkmark--filled/16.js";
|
|
218
|
+
|
|
219
|
+
import "@carbon/icons/es/chevron--right/16.js";
|
|
220
|
+
|
|
221
|
+
import "@carbon/icons/es/error--filled/16.js";
|
|
222
|
+
|
|
223
|
+
import "detect-browser";
|
|
224
|
+
|
|
225
|
+
import "lodash-es/cloneDeep.js";
|
|
226
|
+
|
|
227
|
+
import "uuid";
|
|
228
|
+
|
|
229
|
+
import "@carbon/icons-react/es/ErrorFilled.js";
|
|
230
|
+
|
|
231
|
+
import "@carbon/icons-react/es/Home.js";
|
|
232
|
+
|
|
233
|
+
import "@carbon/icons-react/es/SendFilled.js";
|
|
234
|
+
|
|
235
|
+
import "@carbon/icons/es/stop--filled/16.js";
|
|
236
|
+
|
|
237
|
+
var css_248z = ".dots{\n block-size:32px;\n inline-size:32px;\n}\n\n.dot{\n fill:none;\n r:0;\n stroke-width:0;\n transform:translateY(0);\n}\n\n[data-carbon-theme=white] .dot,\n[data-carbon-theme=g10] .dot{\n stroke:#001d6c;\n}\n\n[data-carbon-theme=g90] .dot,\n[data-carbon-theme=g100] .dot{\n stroke:#f4f4f4;\n}\n\n@media screen and (prefers-reduced-motion: reduce){\n .linear .dot--left{\n animation:none;\n animation-delay:1s, 1s, 2s, 2s;\n animation-duration:1s;\n animation-fill-mode:forwards;\n animation-iteration-count:1, 1, infinite, infinite;\n transform-origin:25% 50%;\n }\n}\n.linear .dot--left{\n animation:linear-load-size, linear-load-stroke, linear-loop-size, linear-loop-stroke;\n animation-delay:1s, 1s, 2s, 2s;\n animation-duration:1s;\n animation-fill-mode:forwards;\n animation-iteration-count:1, 1, infinite, infinite;\n transform-origin:25% 50%;\n}\n@media screen and (prefers-reduced-motion: reduce){\n .linear .dot--center{\n animation:none;\n animation-delay:1.167s, 1.167s, 2.167s, 2.167s;\n animation-duration:1s;\n animation-fill-mode:forwards;\n animation-iteration-count:1, 1, infinite, infinite;\n transform-origin:50% 50%;\n }\n}\n.linear .dot--center{\n animation:linear-load-size, linear-load-stroke, linear-loop-size, linear-loop-stroke;\n animation-delay:1.167s, 1.167s, 2.167s, 2.167s;\n animation-duration:1s;\n animation-fill-mode:forwards;\n animation-iteration-count:1, 1, infinite, infinite;\n transform-origin:50% 50%;\n}\n@media screen and (prefers-reduced-motion: reduce){\n .linear .dot--right{\n animation:none;\n animation-delay:1.334s, 1.334s, 2.334s, 2.334s;\n animation-duration:1s;\n animation-fill-mode:forwards;\n animation-iteration-count:1, 1, infinite, infinite;\n transform-origin:75% 50%;\n }\n}\n.linear .dot--right{\n animation:linear-load-size, linear-load-stroke, linear-loop-size, linear-loop-stroke;\n animation-delay:1.334s, 1.334s, 2.334s, 2.334s;\n animation-duration:1s;\n animation-fill-mode:forwards;\n animation-iteration-count:1, 1, infinite, infinite;\n transform-origin:75% 50%;\n}\n\n[dir=rtl] .linear .dot--left{\n animation-delay:1.334s, 1.334s, 2.334s, 2.334s, 7.334s, 7.334s;\n}\n[dir=rtl] .linear .dot--center{\n animation-delay:1.167s, 1.167s, 2.167s, 2.167s, 7.167s, 7.167s;\n}\n[dir=rtl] .linear .dot--right{\n animation-delay:1s, 1s, 2s, 2s, 7s, 7s;\n}\n\n@media screen and (prefers-reduced-motion: reduce){\n .linear--no-loop .dot--left{\n animation:none;\n animation-delay:1s, 1s, 2s, 2s;\n animation-duration:1s;\n animation-fill-mode:forwards;\n animation-iteration-count:1;\n transform-origin:25% 50%;\n }\n}\n.linear--no-loop .dot--left{\n animation:linear-load-size, linear-load-stroke, linear-unload-size, linear-unload-stroke;\n animation-delay:1s, 1s, 2s, 2s;\n animation-duration:1s;\n animation-fill-mode:forwards;\n animation-iteration-count:1;\n transform-origin:25% 50%;\n}\n@media screen and (prefers-reduced-motion: reduce){\n .linear--no-loop .dot--center{\n animation:none;\n animation-delay:1.167s, 1.167s, 2.167s, 2.167s;\n animation-duration:1s;\n animation-fill-mode:forwards;\n animation-iteration-count:1;\n transform-origin:50% 50%;\n }\n}\n.linear--no-loop .dot--center{\n animation:linear-load-size, linear-load-stroke, linear-unload-size, linear-unload-stroke;\n animation-delay:1.167s, 1.167s, 2.167s, 2.167s;\n animation-duration:1s;\n animation-fill-mode:forwards;\n animation-iteration-count:1;\n transform-origin:50% 50%;\n}\n@media screen and (prefers-reduced-motion: reduce){\n .linear--no-loop .dot--right{\n animation:none;\n animation-delay:1.334s, 1.334s, 2.334s, 2.334s;\n animation-duration:1s;\n animation-fill-mode:forwards;\n animation-iteration-count:1;\n transform-origin:75% 50%;\n }\n}\n.linear--no-loop .dot--right{\n animation:linear-load-size, linear-load-stroke, linear-unload-size, linear-unload-stroke;\n animation-delay:1.334s, 1.334s, 2.334s, 2.334s;\n animation-duration:1s;\n animation-fill-mode:forwards;\n animation-iteration-count:1;\n transform-origin:75% 50%;\n}\n\n[dir=rtl] .linear--no-loop .dot--left{\n animation-delay:1.334s, 1.334s, 2.334s, 2.334s;\n}\n[dir=rtl] .linear--no-loop .dot--center{\n animation-delay:1.167s, 1.167s, 2.167s, 2.167s;\n}\n[dir=rtl] .linear--no-loop .dot--right{\n animation-delay:1s, 1s, 2s, 2s;\n}\n\n@keyframes linear-load-size{\n 0%{\n animation-timing-function:cubic-bezier(0, 0, 0.3, 1);\n r:0;\n }\n 25%{\n animation-timing-function:cubic-bezier(0, 0, 0.3, 1);\n r:2.5px;\n }\n 83.3%{\n r:0.875px;\n }\n 100%{\n r:0.875px;\n }\n}\n@keyframes linear-load-stroke{\n 0%{\n animation-timing-function:cubic-bezier(0, 0, 0.3, 1);\n stroke-width:0;\n }\n 8.33%{\n stroke-width:1.72;\n }\n 100%{\n stroke-width:1.72;\n }\n}\n@keyframes linear-loop-size{\n 0%{\n animation-timing-function:cubic-bezier(0, 0, 0.3, 1);\n r:0.875px;\n }\n 25%{\n animation-timing-function:cubic-bezier(0, 0, 0.3, 1);\n r:2.5px;\n }\n 91.66%{\n r:0.875px;\n }\n 100%{\n r:0.875px;\n }\n}\n@keyframes linear-loop-stroke{\n 0%{\n animation-timing-function:cubic-bezier(0.4, 0.14, 1, 1);\n stroke-width:1.72;\n }\n 100%{\n stroke-width:1.72;\n }\n}\n@keyframes linear-unload-size{\n 0%{\n r:0.875px;\n }\n 8.33%{\n r:0.875px;\n }\n 33.33%{\n animation-timing-function:cubic-bezier(0.4, 0.14, 1, 1);\n r:2.5px;\n }\n 58.33%{\n r:0;\n }\n 100%{\n r:0;\n }\n}\n@keyframes linear-unload-stroke{\n 0%{\n stroke-width:1.72;\n }\n 50%{\n stroke-width:1.72;\n }\n 58.33%{\n stroke-width:0;\n }\n 100%{\n stroke-width:0;\n }\n}\n@media (prefers-reduced-motion: reduce){\n .dot--left,\n .dot--center,\n .dot--right{\n animation:none;\n transition:none;\n }\n}";
|
|
238
|
+
|
|
239
|
+
/*
|
|
240
|
+
* Copyright IBM Corp. 2025
|
|
241
|
+
*
|
|
242
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
243
|
+
* LICENSE file in the root directory of this source tree.
|
|
244
|
+
*
|
|
245
|
+
* @license
|
|
246
|
+
*/ const INLINE_LOADING_TAG_NAME = `${WEB_COMPONENT_PREFIX}-inline-loading`;
|
|
247
|
+
|
|
248
|
+
let CDSInlineLoadingElement = class CDSInlineLoadingElement extends LitElement {
|
|
249
|
+
constructor() {
|
|
250
|
+
super(...arguments);
|
|
251
|
+
this.bounce = false;
|
|
252
|
+
this.loop = false;
|
|
253
|
+
this.quickLoad = false;
|
|
254
|
+
this.carbonTheme = "g10";
|
|
255
|
+
}
|
|
256
|
+
getAnimationEffect() {
|
|
257
|
+
const classNames = [];
|
|
258
|
+
if (this.quickLoad === true) {
|
|
259
|
+
classNames.push("quick-load");
|
|
260
|
+
}
|
|
261
|
+
if (this.bounce === true && this.loop === true) {
|
|
262
|
+
classNames.push("vertical");
|
|
263
|
+
}
|
|
264
|
+
if (this.bounce === false && this.loop === true) {
|
|
265
|
+
classNames.push("linear");
|
|
266
|
+
}
|
|
267
|
+
if (this.bounce === true && this.loop === false) {
|
|
268
|
+
classNames.push("vertical--no-loop");
|
|
269
|
+
}
|
|
270
|
+
if (classNames.length) {
|
|
271
|
+
return classNames.join(" ");
|
|
272
|
+
}
|
|
273
|
+
return "linear--no-loop";
|
|
274
|
+
}
|
|
275
|
+
render() {
|
|
276
|
+
return html`<div
|
|
277
|
+
data-carbon-theme=${this.carbonTheme}
|
|
278
|
+
class=${this.getAnimationEffect()}
|
|
279
|
+
>
|
|
280
|
+
<svg class="dots" viewBox="0 0 32 32">
|
|
281
|
+
<circle class="dot dot--left" cx="8" cy="16" />
|
|
282
|
+
<circle class="dot dot--center" cx="16" cy="16" r="2" />
|
|
283
|
+
<circle class="dot dot--right" cx="24" cy="16" r="2" />
|
|
284
|
+
</svg>
|
|
285
|
+
</div>`;
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
CDSInlineLoadingElement.styles = css`
|
|
290
|
+
${unsafeCSS(css_248z)}
|
|
291
|
+
`;
|
|
292
|
+
|
|
293
|
+
__decorate([ property({
|
|
294
|
+
type: Boolean
|
|
295
|
+
}) ], CDSInlineLoadingElement.prototype, "bounce", void 0);
|
|
296
|
+
|
|
297
|
+
__decorate([ property({
|
|
298
|
+
type: Boolean
|
|
299
|
+
}) ], CDSInlineLoadingElement.prototype, "loop", void 0);
|
|
300
|
+
|
|
301
|
+
__decorate([ property({
|
|
302
|
+
type: Boolean
|
|
303
|
+
}) ], CDSInlineLoadingElement.prototype, "quickLoad", void 0);
|
|
304
|
+
|
|
305
|
+
__decorate([ property({
|
|
306
|
+
type: String
|
|
307
|
+
}) ], CDSInlineLoadingElement.prototype, "carbonTheme", void 0);
|
|
308
|
+
|
|
309
|
+
CDSInlineLoadingElement = __decorate([ carbonElement(INLINE_LOADING_TAG_NAME) ], CDSInlineLoadingElement);
|
|
310
|
+
|
|
311
|
+
/*
|
|
312
|
+
* Copyright IBM Corp. 2025
|
|
313
|
+
*
|
|
314
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
315
|
+
* LICENSE file in the root directory of this source tree.
|
|
316
|
+
*
|
|
317
|
+
* @license
|
|
318
|
+
*/ const InlineLoadingComponent = createComponent({
|
|
319
|
+
tagName: INLINE_LOADING_TAG_NAME,
|
|
320
|
+
elementClass: CDSInlineLoadingElement,
|
|
321
|
+
react: React
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
/*
|
|
325
|
+
* Copyright IBM Corp. 2025
|
|
326
|
+
*
|
|
327
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
328
|
+
* LICENSE file in the root directory of this source tree.
|
|
329
|
+
*
|
|
330
|
+
* @license
|
|
331
|
+
*/ function AgentAvatar(props) {
|
|
332
|
+
const {agentProfile: agentProfile, languagePack: languagePack, width: width, height: height} = props;
|
|
333
|
+
const agentName = agentProfile?.nickname;
|
|
334
|
+
const avatarStyles = useDynamicCSSProperties({
|
|
335
|
+
width: width,
|
|
336
|
+
height: height
|
|
337
|
+
});
|
|
338
|
+
const avatarUrl = agentProfile?.profile_picture_url;
|
|
339
|
+
const [hasError, setHasError] = useState(false);
|
|
340
|
+
let component;
|
|
341
|
+
useEffect(() => {
|
|
342
|
+
setHasError(false);
|
|
343
|
+
}, [ avatarUrl ]);
|
|
344
|
+
if (!hasError && avatarUrl) {
|
|
345
|
+
component = React.createElement("img", {
|
|
346
|
+
src: avatarUrl,
|
|
347
|
+
alt: languagePack.agent_ariaAgentAvatar,
|
|
348
|
+
onError: () => setHasError(true)
|
|
349
|
+
});
|
|
350
|
+
} else if (agentName?.match(/^[\x20-\xFE]+$/)) {
|
|
351
|
+
component = React.createElement("div", {
|
|
352
|
+
"aria-label": languagePack.agent_ariaAgentAvatar,
|
|
353
|
+
className: "WACAgentAvatar__Circle",
|
|
354
|
+
style: avatarStyles
|
|
355
|
+
}, React.createElement("div", {
|
|
356
|
+
className: "WACAgentAvatar__Letter"
|
|
357
|
+
}, agentName.charAt(0)));
|
|
358
|
+
} else {
|
|
359
|
+
component = React.createElement(UserAvatar, {
|
|
360
|
+
size: 32,
|
|
361
|
+
width: width ? Number(width.replace("px", "")) : undefined,
|
|
362
|
+
height: height ? Number(height.replace("px", "")) : undefined,
|
|
363
|
+
"aria-label": languagePack.agent_ariaAgentAvatar
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
return React.createElement("div", {
|
|
367
|
+
className: "WACAgentAvatar"
|
|
368
|
+
}, component);
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
/*
|
|
372
|
+
* Copyright IBM Corp. 2025
|
|
373
|
+
*
|
|
374
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
375
|
+
* LICENSE file in the root directory of this source tree.
|
|
376
|
+
*
|
|
377
|
+
* @license
|
|
378
|
+
*/ function AgentBanner(props, ref) {
|
|
379
|
+
const {onButtonClick: onButtonClick} = props;
|
|
380
|
+
const languagePack = useLanguagePack();
|
|
381
|
+
const serviceManager = useServiceManager();
|
|
382
|
+
const persistedAgentState = useSelector(state => state.persistedToBrowserStorage.chatState.agentState);
|
|
383
|
+
const agentState = useSelector(state => state.agentState);
|
|
384
|
+
const {isConnecting: isConnecting, availability: availability, isScreenSharing: isScreenSharing} = agentState;
|
|
385
|
+
const displayState = useSelector(selectAgentDisplayState, shallowEqual);
|
|
386
|
+
const {agentProfile: agentProfile} = persistedAgentState;
|
|
387
|
+
const buttonRef = useRef();
|
|
388
|
+
let line1;
|
|
389
|
+
let line2;
|
|
390
|
+
let avatar;
|
|
391
|
+
let buttonLabel;
|
|
392
|
+
let animation;
|
|
393
|
+
if (isConnecting) {
|
|
394
|
+
animation = React.createElement("div", {
|
|
395
|
+
className: "WACLoadingBar__ConnectingAnimation"
|
|
396
|
+
});
|
|
397
|
+
line1 = languagePack.agent_connecting;
|
|
398
|
+
line2 = React.createElement(AnnounceOnMountComponentExport, {
|
|
399
|
+
announceOnce: languagePack.agent_connecting
|
|
400
|
+
}, React.createElement(AvailabilityMessage, {
|
|
401
|
+
availability: availability,
|
|
402
|
+
fallbackText: languagePack.agent_connectWaiting
|
|
403
|
+
}));
|
|
404
|
+
buttonLabel = languagePack.agent_connectButtonCancel;
|
|
405
|
+
} else {
|
|
406
|
+
line1 = agentProfile?.nickname || languagePack.agent_noName;
|
|
407
|
+
buttonLabel = languagePack.agent_connectedButtonEndChat;
|
|
408
|
+
avatar = React.createElement(AgentAvatar, {
|
|
409
|
+
agentProfile: agentProfile,
|
|
410
|
+
languagePack: languagePack,
|
|
411
|
+
width: "32px",
|
|
412
|
+
height: "32px"
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
const onStopSharing = () => {
|
|
416
|
+
serviceManager.humanAgentService.screenShareStop();
|
|
417
|
+
};
|
|
418
|
+
useImperativeHandle(ref, () => ({
|
|
419
|
+
requestFocus: () => {
|
|
420
|
+
if (buttonRef.current) {
|
|
421
|
+
doFocusRef(buttonRef);
|
|
422
|
+
return true;
|
|
423
|
+
}
|
|
424
|
+
return false;
|
|
425
|
+
}
|
|
426
|
+
}));
|
|
427
|
+
return React.createElement("div", {
|
|
428
|
+
className: cx("WACAgentBanner", {
|
|
429
|
+
"WACAgentBanner--connected": !isConnecting
|
|
430
|
+
})
|
|
431
|
+
}, displayState.isConnectingOrConnected && React.createElement("div", {
|
|
432
|
+
className: "WACAgentBanner__Body"
|
|
433
|
+
}, avatar, React.createElement("div", {
|
|
434
|
+
className: "WACAgentBanner__AgentInfo"
|
|
435
|
+
}, React.createElement("div", {
|
|
436
|
+
className: "WACAgentBanner__AgentLine1"
|
|
437
|
+
}, line1), line2 && React.createElement("div", {
|
|
438
|
+
className: "WACAgentBanner__AgentLine2"
|
|
439
|
+
}, line2)), React.createElement(Button, {
|
|
440
|
+
ref: buttonRef,
|
|
441
|
+
className: "WACAgentBanner__Button WACAgentBanner__CancelButton",
|
|
442
|
+
onClick: onButtonClick,
|
|
443
|
+
size: "sm"
|
|
444
|
+
}, buttonLabel)), isScreenSharing && React.createElement(Button, {
|
|
445
|
+
className: "WACAgentBanner__Button WACAgentBanner__StopSharingButton",
|
|
446
|
+
kind: "danger",
|
|
447
|
+
size: "sm",
|
|
448
|
+
renderIcon: ScreenOff,
|
|
449
|
+
onClick: onStopSharing
|
|
450
|
+
}, languagePack.agent_sharingStopSharingButton), animation);
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
const AgentBannerExport = React.memo(forwardRef(AgentBanner));
|
|
454
|
+
|
|
455
|
+
/*
|
|
456
|
+
* Copyright IBM Corp. 2025
|
|
457
|
+
*
|
|
458
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
459
|
+
* LICENSE file in the root directory of this source tree.
|
|
460
|
+
*
|
|
461
|
+
* @license
|
|
462
|
+
*/ function AgentBannerContainer({onButtonClick: onButtonClick, bannerRef: bannerRef}) {
|
|
463
|
+
const agentState = useSelector(state => state.agentState);
|
|
464
|
+
const displayState = useSelector(selectAgentDisplayState, shallowEqual);
|
|
465
|
+
if (displayState.isConnectingOrConnected || agentState.isScreenSharing) {
|
|
466
|
+
return React.createElement(AgentBannerExport, {
|
|
467
|
+
ref: bannerRef,
|
|
468
|
+
onButtonClick: onButtonClick
|
|
469
|
+
});
|
|
470
|
+
}
|
|
471
|
+
return null;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
/*
|
|
475
|
+
* Copyright IBM Corp. 2025
|
|
476
|
+
*
|
|
477
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
478
|
+
* LICENSE file in the root directory of this source tree.
|
|
479
|
+
*
|
|
480
|
+
* @license
|
|
481
|
+
*/ function LatestWelcomeNodes({children: children}) {
|
|
482
|
+
const {namespace: namespace} = useServiceManager();
|
|
483
|
+
return React.createElement(React.Fragment, null, React.createElement(WriteableElement, {
|
|
484
|
+
slotName: WriteableElementName.WELCOME_NODE_BEFORE_ELEMENT,
|
|
485
|
+
id: `welcomeNodeBeforeElement${namespace.suffix}`
|
|
486
|
+
}), children);
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
var LatestWelcomeNodes$1 = React.memo(LatestWelcomeNodes);
|
|
490
|
+
|
|
491
|
+
/*
|
|
492
|
+
* Copyright IBM Corp. 2025
|
|
493
|
+
*
|
|
494
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
495
|
+
* LICENSE file in the root directory of this source tree.
|
|
496
|
+
*
|
|
497
|
+
* @license
|
|
498
|
+
*/ function Notifications({notifications: notifications, serviceManager: serviceManager}) {
|
|
499
|
+
const languagePack = useLanguagePack();
|
|
500
|
+
if (notifications.length) {
|
|
501
|
+
return React.createElement("div", {
|
|
502
|
+
className: "WACNotifications"
|
|
503
|
+
}, notifications.map(notification => {
|
|
504
|
+
const item = notification.notification;
|
|
505
|
+
const onClose = () => {
|
|
506
|
+
serviceManager.store.dispatch(actions.removeNotifications({
|
|
507
|
+
notificationID: notification.id
|
|
508
|
+
}));
|
|
509
|
+
};
|
|
510
|
+
let onActionButtonClick;
|
|
511
|
+
let actionButtonLabel;
|
|
512
|
+
if (item.actionButtonLabel && item.onActionButtonClick) {
|
|
513
|
+
onActionButtonClick = () => {
|
|
514
|
+
item.onActionButtonClick();
|
|
515
|
+
onClose();
|
|
516
|
+
};
|
|
517
|
+
actionButtonLabel = item.actionButtonLabel;
|
|
518
|
+
}
|
|
519
|
+
return React.createElement("div", {
|
|
520
|
+
className: "WACNotifications__Notification",
|
|
521
|
+
key: notification.id
|
|
522
|
+
}, React.createElement(ActionableNotification, {
|
|
523
|
+
"aria-label": languagePack.notifications_toastClose,
|
|
524
|
+
actionButtonLabel: actionButtonLabel,
|
|
525
|
+
onActionButtonClick: onActionButtonClick,
|
|
526
|
+
kind: item.kind,
|
|
527
|
+
onClose: () => {
|
|
528
|
+
onClose();
|
|
529
|
+
item.onCloseButtonClick?.();
|
|
530
|
+
},
|
|
531
|
+
subtitle: item.message,
|
|
532
|
+
title: item.title,
|
|
533
|
+
hasFocus: false
|
|
534
|
+
}));
|
|
535
|
+
}));
|
|
536
|
+
}
|
|
537
|
+
return null;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
/*
|
|
541
|
+
* Copyright IBM Corp. 2025
|
|
542
|
+
*
|
|
543
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
544
|
+
* LICENSE file in the root directory of this source tree.
|
|
545
|
+
*
|
|
546
|
+
* @license
|
|
547
|
+
*/ function withServiceManager(Component) {
|
|
548
|
+
const Wrapped = React.forwardRef((props, ref) => {
|
|
549
|
+
const serviceManager = useContext(ServiceManagerContext);
|
|
550
|
+
return React.createElement(Component, {
|
|
551
|
+
...props,
|
|
552
|
+
ref: ref,
|
|
553
|
+
serviceManager: serviceManager
|
|
554
|
+
});
|
|
555
|
+
});
|
|
556
|
+
Wrapped.displayName = `withServiceManager(${Component.displayName || Component.name || "Component"})`;
|
|
557
|
+
return Wrapped;
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
/*
|
|
561
|
+
* Copyright IBM Corp. 2025
|
|
562
|
+
*
|
|
563
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
564
|
+
* LICENSE file in the root directory of this source tree.
|
|
565
|
+
*
|
|
566
|
+
* @license
|
|
567
|
+
*/ function Avatar({theme: theme}) {
|
|
568
|
+
const a = `a-${uuid()}`;
|
|
569
|
+
const b = `b-${uuid()}`;
|
|
570
|
+
const c = `c-${uuid()}`;
|
|
571
|
+
const d = `d-${uuid()}`;
|
|
572
|
+
const e = `e-${uuid()}`;
|
|
573
|
+
if (theme === CarbonTheme.WHITE || theme === CarbonTheme.G10) {
|
|
574
|
+
return React.createElement("svg", {
|
|
575
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
576
|
+
viewBox: "0 0 32 32",
|
|
577
|
+
className: "cds--watsonx-avatar",
|
|
578
|
+
"aria-hidden": "true"
|
|
579
|
+
}, React.createElement("defs", null, React.createElement("linearGradient", {
|
|
580
|
+
id: a,
|
|
581
|
+
x1: "1186.526",
|
|
582
|
+
y1: "2863.168",
|
|
583
|
+
x2: "1199.825",
|
|
584
|
+
y2: "2845.109",
|
|
585
|
+
gradientTransform: "matrix(.8312 .55596 -.27409 .40979 -198.894 -1827.398)",
|
|
586
|
+
gradientUnits: "userSpaceOnUse"
|
|
587
|
+
}, React.createElement("stop", {
|
|
588
|
+
offset: ".3"
|
|
589
|
+
}), React.createElement("stop", {
|
|
590
|
+
offset: "1",
|
|
591
|
+
stopOpacity: "0"
|
|
592
|
+
})), React.createElement("linearGradient", {
|
|
593
|
+
id: b,
|
|
594
|
+
x1: "1189.388",
|
|
595
|
+
y1: "2911.794",
|
|
596
|
+
x2: "1200.478",
|
|
597
|
+
y2: "2896.735",
|
|
598
|
+
gradientTransform: "rotate(146.223 380.87 -882.286) scale(1 -.493)",
|
|
599
|
+
gradientUnits: "userSpaceOnUse"
|
|
600
|
+
}, React.createElement("stop", {
|
|
601
|
+
offset: ".3"
|
|
602
|
+
}), React.createElement("stop", {
|
|
603
|
+
offset: ".9",
|
|
604
|
+
stopOpacity: "0"
|
|
605
|
+
})), React.createElement("linearGradient", {
|
|
606
|
+
id: c,
|
|
607
|
+
x1: "-4995.033",
|
|
608
|
+
y1: "-20162.835",
|
|
609
|
+
x2: "-4981.733",
|
|
610
|
+
y2: "-20180.895",
|
|
611
|
+
gradientTransform: "rotate(-146.223 -971.422 -5714.55) scale(1 .493)",
|
|
612
|
+
gradientUnits: "userSpaceOnUse"
|
|
613
|
+
}, React.createElement("stop", {
|
|
614
|
+
offset: ".32"
|
|
615
|
+
}), React.createElement("stop", {
|
|
616
|
+
offset: ".354",
|
|
617
|
+
stopOpacity: ".798"
|
|
618
|
+
}), React.createElement("stop", {
|
|
619
|
+
offset: ".7",
|
|
620
|
+
stopOpacity: "0"
|
|
621
|
+
})), React.createElement("linearGradient", {
|
|
622
|
+
id: d,
|
|
623
|
+
x1: "0",
|
|
624
|
+
y1: "32",
|
|
625
|
+
x2: "32",
|
|
626
|
+
y2: "0",
|
|
627
|
+
gradientUnits: "userSpaceOnUse"
|
|
628
|
+
}, React.createElement("stop", {
|
|
629
|
+
offset: ".1",
|
|
630
|
+
stopColor: "#a56eff"
|
|
631
|
+
}), React.createElement("stop", {
|
|
632
|
+
offset: ".9",
|
|
633
|
+
stopColor: "#0f62fe"
|
|
634
|
+
})), React.createElement("mask", {
|
|
635
|
+
id: e,
|
|
636
|
+
x: "0",
|
|
637
|
+
y: "0",
|
|
638
|
+
width: "32",
|
|
639
|
+
height: "32",
|
|
640
|
+
maskUnits: "userSpaceOnUse"
|
|
641
|
+
}, React.createElement("path", {
|
|
642
|
+
d: "M16 1A14.915 14.915 0 0 0 5.502 5.286l1.4 1.429A12.922 12.922 0 0 1 16 3.001c.977 0 1.929.109 2.845.315-3.402.921-5.916 4.026-5.916 7.715 0 .782.118 1.537.328 2.252a7.978 7.978 0 0 0-2.188-.312c-3.704 0-6.819 2.534-7.726 5.957a12.954 12.954 0 0 1-.345-2.927c0-2.117.492-4.134 1.462-5.996l-1.773-.924A15.037 15.037 0 0 0 .999 16c0 8.271 6.729 15 15 15 3.949 0 7.678-1.522 10.498-4.286l-1.4-1.428A12.926 12.926 0 0 1 15.999 29c-3.648 0-6.945-1.516-9.309-3.945a5.959 5.959 0 0 1-1.621-4.086c0-3.309 2.691-6 6-6a6.006 6.006 0 0 1 5.897 7.107l1.967.367a7.971 7.971 0 0 0-.192-3.726 7.976 7.976 0 0 0 2.187.312c3.71 0 6.829-2.542 7.73-5.974.22.947.34 1.931.34 2.944 0 2.117-.492 4.134-1.462 5.995l1.773.924a15.034 15.034 0 0 0 1.688-6.919C31 7.729 24.272 1 16 1zm4.93 16.03c-3.309 0-6-2.692-6-6s2.691-6 6-6 6 2.691 6 6-2.691 6-6 6z",
|
|
643
|
+
style: {
|
|
644
|
+
fill: "#fff",
|
|
645
|
+
strokeWidth: 0
|
|
646
|
+
}
|
|
647
|
+
}), React.createElement("path", {
|
|
648
|
+
style: {
|
|
649
|
+
fill: `url(#${a})`,
|
|
650
|
+
strokeWidth: 0
|
|
651
|
+
},
|
|
652
|
+
d: "M8 9 0 0h16l2.305 3.304L8 9z"
|
|
653
|
+
}), React.createElement("path", {
|
|
654
|
+
style: {
|
|
655
|
+
fill: `url(#${b})`,
|
|
656
|
+
strokeWidth: 0
|
|
657
|
+
},
|
|
658
|
+
d: "m12 31 4.386-9L6 21 2 31h10z"
|
|
659
|
+
}), React.createElement("path", {
|
|
660
|
+
style: {
|
|
661
|
+
fill: `url(#${c})`,
|
|
662
|
+
strokeWidth: 0
|
|
663
|
+
},
|
|
664
|
+
d: "m24 23 8 9H16l-2.304-3.305L24 23z"
|
|
665
|
+
}), React.createElement("path", {
|
|
666
|
+
style: {
|
|
667
|
+
strokeWidth: 0
|
|
668
|
+
},
|
|
669
|
+
d: "M16 31h-4.283L15 22h2l-1 9z"
|
|
670
|
+
}))), React.createElement("g", {
|
|
671
|
+
style: {
|
|
672
|
+
mask: `url(#${e})`
|
|
673
|
+
}
|
|
674
|
+
}, React.createElement("path", {
|
|
675
|
+
style: {
|
|
676
|
+
fill: `url(#${d})`,
|
|
677
|
+
strokeWidth: 0
|
|
678
|
+
},
|
|
679
|
+
d: "M0 0h32v32H0z"
|
|
680
|
+
})), React.createElement("circle", {
|
|
681
|
+
cx: "6",
|
|
682
|
+
cy: "6",
|
|
683
|
+
r: "2",
|
|
684
|
+
style: {
|
|
685
|
+
fill: "#001d6c",
|
|
686
|
+
strokeWidth: 0
|
|
687
|
+
}
|
|
688
|
+
}), React.createElement("circle", {
|
|
689
|
+
cx: "26",
|
|
690
|
+
cy: "26",
|
|
691
|
+
r: "2",
|
|
692
|
+
style: {
|
|
693
|
+
fill: "#001d6c",
|
|
694
|
+
strokeWidth: 0
|
|
695
|
+
}
|
|
696
|
+
}), React.createElement("path", {
|
|
697
|
+
d: "M16 31c-2.757 0-5-2.243-5-5s2.243-5 5-5 5 2.243 5 5-2.243 5-5 5zm0-8c-1.654 0-3 1.346-3 3s1.346 3 3 3 3-1.346 3-3-1.346-3-3-3z",
|
|
698
|
+
style: {
|
|
699
|
+
fill: "#001d6c",
|
|
700
|
+
strokeWidth: 0
|
|
701
|
+
}
|
|
702
|
+
}));
|
|
703
|
+
}
|
|
704
|
+
return React.createElement("svg", {
|
|
705
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
706
|
+
viewBox: "0 0 32 32",
|
|
707
|
+
className: "cds--watsonx-avatar",
|
|
708
|
+
"aria-hidden": "true"
|
|
709
|
+
}, React.createElement("defs", null, React.createElement("linearGradient", {
|
|
710
|
+
id: a,
|
|
711
|
+
x1: "1196.653",
|
|
712
|
+
y1: "2930.892",
|
|
713
|
+
x2: "1209.953",
|
|
714
|
+
y2: "2912.832",
|
|
715
|
+
gradientTransform: "matrix(.8312 .55596 -.27409 .40979 -188.767 -1860.755)",
|
|
716
|
+
gradientUnits: "userSpaceOnUse"
|
|
717
|
+
}, React.createElement("stop", {
|
|
718
|
+
offset: ".3"
|
|
719
|
+
}), React.createElement("stop", {
|
|
720
|
+
offset: "1",
|
|
721
|
+
stopOpacity: "0"
|
|
722
|
+
})), React.createElement("linearGradient", {
|
|
723
|
+
id: b,
|
|
724
|
+
x1: "1299.261",
|
|
725
|
+
y1: "2844.072",
|
|
726
|
+
x2: "1310.351",
|
|
727
|
+
y2: "2829.012",
|
|
728
|
+
gradientTransform: "rotate(146.223 440.869 -882.286) scale(1 -.493)",
|
|
729
|
+
gradientUnits: "userSpaceOnUse"
|
|
730
|
+
}, React.createElement("stop", {
|
|
731
|
+
offset: ".3"
|
|
732
|
+
}), React.createElement("stop", {
|
|
733
|
+
offset: ".9",
|
|
734
|
+
stopOpacity: "0"
|
|
735
|
+
})), React.createElement("linearGradient", {
|
|
736
|
+
id: c,
|
|
737
|
+
x1: "-4885.16",
|
|
738
|
+
y1: "-20230.559",
|
|
739
|
+
x2: "-4871.86",
|
|
740
|
+
y2: "-20248.618",
|
|
741
|
+
gradientTransform: "rotate(-146.223 -911.421 -5714.55) scale(1 .493)",
|
|
742
|
+
gradientUnits: "userSpaceOnUse"
|
|
743
|
+
}, React.createElement("stop", {
|
|
744
|
+
offset: ".32"
|
|
745
|
+
}), React.createElement("stop", {
|
|
746
|
+
offset: ".354",
|
|
747
|
+
stopOpacity: ".798"
|
|
748
|
+
}), React.createElement("stop", {
|
|
749
|
+
offset: ".7",
|
|
750
|
+
stopOpacity: "0"
|
|
751
|
+
})), React.createElement("linearGradient", {
|
|
752
|
+
id: d,
|
|
753
|
+
x1: "0",
|
|
754
|
+
y1: "32",
|
|
755
|
+
x2: "32",
|
|
756
|
+
y2: "0",
|
|
757
|
+
gradientUnits: "userSpaceOnUse"
|
|
758
|
+
}, React.createElement("stop", {
|
|
759
|
+
offset: ".1",
|
|
760
|
+
stopColor: "#be95ff"
|
|
761
|
+
}), React.createElement("stop", {
|
|
762
|
+
offset: ".9",
|
|
763
|
+
stopColor: "#4589ff"
|
|
764
|
+
})), React.createElement("mask", {
|
|
765
|
+
id: e,
|
|
766
|
+
x: "0",
|
|
767
|
+
y: "0",
|
|
768
|
+
width: "32",
|
|
769
|
+
height: "32",
|
|
770
|
+
maskUnits: "userSpaceOnUse"
|
|
771
|
+
}, React.createElement("path", {
|
|
772
|
+
d: "M16 1A14.915 14.915 0 0 0 5.502 5.286l1.4 1.429A12.922 12.922 0 0 1 16 3.001c.977 0 1.929.109 2.845.315-3.402.921-5.916 4.026-5.916 7.715 0 .782.118 1.537.328 2.252a7.978 7.978 0 0 0-2.188-.312c-3.704 0-6.819 2.534-7.726 5.957a12.954 12.954 0 0 1-.345-2.927c0-2.117.492-4.134 1.462-5.996l-1.773-.924A15.037 15.037 0 0 0 .999 16c0 8.271 6.729 15 15 15 3.949 0 7.678-1.522 10.498-4.286l-1.4-1.428A12.926 12.926 0 0 1 15.999 29c-3.648 0-6.945-1.516-9.309-3.945a5.959 5.959 0 0 1-1.621-4.086c0-3.309 2.691-6 6-6a6.006 6.006 0 0 1 5.897 7.107l1.967.367a7.971 7.971 0 0 0-.192-3.726 7.976 7.976 0 0 0 2.187.312c3.71 0 6.829-2.542 7.73-5.974.22.947.34 1.931.34 2.944 0 2.117-.492 4.134-1.462 5.995l1.773.924a15.034 15.034 0 0 0 1.688-6.919c0-8.271-6.729-15-15-15zm4.93 16.03c-3.309 0-6-2.692-6-6s2.691-6 6-6 6 2.691 6 6-2.691 6-6 6z",
|
|
773
|
+
style: {
|
|
774
|
+
fill: "#fff",
|
|
775
|
+
strokeWidth: 0
|
|
776
|
+
}
|
|
777
|
+
}), React.createElement("path", {
|
|
778
|
+
style: {
|
|
779
|
+
fill: `url(#${a})`,
|
|
780
|
+
strokeWidth: 0
|
|
781
|
+
},
|
|
782
|
+
d: "M8 9 0 0h16l2.305 3.305L8 9z"
|
|
783
|
+
}), React.createElement("path", {
|
|
784
|
+
style: {
|
|
785
|
+
fill: `url(#${b})`,
|
|
786
|
+
strokeWidth: 0
|
|
787
|
+
},
|
|
788
|
+
d: "m12 31 4.386-9L6 21 2 31h10z"
|
|
789
|
+
}), React.createElement("path", {
|
|
790
|
+
style: {
|
|
791
|
+
fill: `url(#${c})`,
|
|
792
|
+
strokeWidth: 0
|
|
793
|
+
},
|
|
794
|
+
d: "m24 23 8 9H16l-2.305-3.305L24 23z"
|
|
795
|
+
}), React.createElement("path", {
|
|
796
|
+
style: {
|
|
797
|
+
strokeWidth: 0
|
|
798
|
+
},
|
|
799
|
+
d: "M16 31h-4.283L15 22h2l-1 9z"
|
|
800
|
+
}))), React.createElement("g", {
|
|
801
|
+
style: {
|
|
802
|
+
mask: `url(#${e})`
|
|
803
|
+
}
|
|
804
|
+
}, React.createElement("path", {
|
|
805
|
+
style: {
|
|
806
|
+
fill: `url(#${d})`,
|
|
807
|
+
strokeWidth: 0
|
|
808
|
+
},
|
|
809
|
+
d: "M0 0h32v32H0z"
|
|
810
|
+
})), React.createElement("circle", {
|
|
811
|
+
cx: "6",
|
|
812
|
+
cy: "6",
|
|
813
|
+
r: "2",
|
|
814
|
+
style: {
|
|
815
|
+
fill: "#f4f4f4",
|
|
816
|
+
strokeWidth: 0
|
|
817
|
+
}
|
|
818
|
+
}), React.createElement("circle", {
|
|
819
|
+
cx: "26",
|
|
820
|
+
cy: "26",
|
|
821
|
+
r: "2",
|
|
822
|
+
style: {
|
|
823
|
+
fill: "#f4f4f4",
|
|
824
|
+
strokeWidth: 0
|
|
825
|
+
}
|
|
826
|
+
}), React.createElement("path", {
|
|
827
|
+
d: "M16 31c-2.757 0-5-2.243-5-5s2.243-5 5-5 5 2.243 5 5-2.243 5-5 5zm0-8c-1.654 0-3 1.346-3 3s1.346 3 3 3 3-1.346 3-3-1.346-3-3-3z",
|
|
828
|
+
style: {
|
|
829
|
+
fill: "#f4f4f4",
|
|
830
|
+
strokeWidth: 0
|
|
831
|
+
}
|
|
832
|
+
}));
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
const AvatarExport = React.memo(Avatar);
|
|
836
|
+
|
|
837
|
+
/*
|
|
838
|
+
* Copyright IBM Corp. 2025
|
|
839
|
+
*
|
|
840
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
841
|
+
* LICENSE file in the root directory of this source tree.
|
|
842
|
+
*
|
|
843
|
+
* @license
|
|
844
|
+
*/ function IconHolder(props) {
|
|
845
|
+
return React.createElement("div", {
|
|
846
|
+
className: "WACIconHolder"
|
|
847
|
+
}, props.icon);
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
/*
|
|
851
|
+
* Copyright IBM Corp. 2025
|
|
852
|
+
*
|
|
853
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
854
|
+
* LICENSE file in the root directory of this source tree.
|
|
855
|
+
*
|
|
856
|
+
* @license
|
|
857
|
+
*/ function ImageWithFallback(props) {
|
|
858
|
+
const {url: url, alt: alt, fallback: fallback} = props;
|
|
859
|
+
const [hasError, setHasError] = useState(false);
|
|
860
|
+
useEffect(() => {
|
|
861
|
+
setHasError(false);
|
|
862
|
+
}, [ url ]);
|
|
863
|
+
let component;
|
|
864
|
+
if (!hasError && url) {
|
|
865
|
+
component = React.createElement("img", {
|
|
866
|
+
src: url,
|
|
867
|
+
alt: alt,
|
|
868
|
+
onError: () => setHasError(true)
|
|
869
|
+
});
|
|
870
|
+
} else {
|
|
871
|
+
component = fallback;
|
|
872
|
+
}
|
|
873
|
+
return React.createElement("div", {
|
|
874
|
+
className: "WACImageWithFallback"
|
|
875
|
+
}, component);
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
/*
|
|
879
|
+
* Copyright IBM Corp. 2025
|
|
880
|
+
*
|
|
881
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
882
|
+
* LICENSE file in the root directory of this source tree.
|
|
883
|
+
*
|
|
884
|
+
* @license
|
|
885
|
+
*/ function timestampToTimeString(timestamp) {
|
|
886
|
+
return dayjs(timestamp).format("LT");
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
/*
|
|
890
|
+
* Copyright IBM Corp. 2025
|
|
891
|
+
*
|
|
892
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
893
|
+
* LICENSE file in the root directory of this source tree.
|
|
894
|
+
*
|
|
895
|
+
* @license
|
|
896
|
+
*/ var MoveFocusType;
|
|
897
|
+
|
|
898
|
+
(function(MoveFocusType) {
|
|
899
|
+
MoveFocusType[MoveFocusType["FIRST"] = 1] = "FIRST";
|
|
900
|
+
MoveFocusType[MoveFocusType["LAST"] = 2] = "LAST";
|
|
901
|
+
MoveFocusType[MoveFocusType["NEXT"] = 3] = "NEXT";
|
|
902
|
+
MoveFocusType[MoveFocusType["PREVIOUS"] = 4] = "PREVIOUS";
|
|
903
|
+
MoveFocusType[MoveFocusType["INPUT"] = 5] = "INPUT";
|
|
904
|
+
})(MoveFocusType || (MoveFocusType = {}));
|
|
905
|
+
|
|
906
|
+
class MessageComponent extends PureComponent {
|
|
907
|
+
constructor() {
|
|
908
|
+
super(...arguments);
|
|
909
|
+
this.state = {
|
|
910
|
+
didRenderErrorOccur: false,
|
|
911
|
+
focusHandleHasFocus: false
|
|
912
|
+
};
|
|
913
|
+
this.ref = React.createRef();
|
|
914
|
+
this.messageRef = React.createRef();
|
|
915
|
+
this.focusHandleRef = React.createRef();
|
|
916
|
+
this.getLocalMessage = () => this.props.localMessageItem;
|
|
917
|
+
this.onHandleFocus = () => {
|
|
918
|
+
this.setState({
|
|
919
|
+
focusHandleHasFocus: true
|
|
920
|
+
});
|
|
921
|
+
};
|
|
922
|
+
this.onHandleBlur = () => {
|
|
923
|
+
this.setState({
|
|
924
|
+
focusHandleHasFocus: false
|
|
925
|
+
});
|
|
926
|
+
};
|
|
927
|
+
this.onHandleKeyDown = event => {
|
|
928
|
+
if (event.altKey || event.metaKey || event.ctrlKey || event.shiftKey) {
|
|
929
|
+
return;
|
|
930
|
+
}
|
|
931
|
+
let moveFocus;
|
|
932
|
+
if (event.key === "ArrowUp") {
|
|
933
|
+
moveFocus = MoveFocusType.PREVIOUS;
|
|
934
|
+
} else if (event.key === "ArrowDown") {
|
|
935
|
+
moveFocus = MoveFocusType.NEXT;
|
|
936
|
+
} else if (event.key === "Home") {
|
|
937
|
+
moveFocus = MoveFocusType.FIRST;
|
|
938
|
+
} else if (event.key === "End") {
|
|
939
|
+
moveFocus = MoveFocusType.LAST;
|
|
940
|
+
} else if (event.key === "Escape") {
|
|
941
|
+
moveFocus = MoveFocusType.INPUT;
|
|
942
|
+
} else if (event.key === "Enter" || event.key === " ") {
|
|
943
|
+
event.preventDefault();
|
|
944
|
+
this.reAnnounceFocusHandle();
|
|
945
|
+
return;
|
|
946
|
+
}
|
|
947
|
+
if (moveFocus) {
|
|
948
|
+
event.preventDefault();
|
|
949
|
+
this.props.requestMoveFocus(moveFocus, this.props.messagesIndex);
|
|
950
|
+
}
|
|
951
|
+
};
|
|
952
|
+
}
|
|
953
|
+
getWidgetSaidMessage() {
|
|
954
|
+
const {intl: intl, botName: botName, localMessageItem: localMessageItem} = this.props;
|
|
955
|
+
let messageId;
|
|
956
|
+
if (localMessageItem.item.agent_message_type) {
|
|
957
|
+
if (localMessageItem.item.response_type === MessageResponseTypes.TEXT) {
|
|
958
|
+
messageId = "messages_agentSaid";
|
|
959
|
+
}
|
|
960
|
+
} else {
|
|
961
|
+
messageId = "messages_botSaid";
|
|
962
|
+
}
|
|
963
|
+
return messageId ? intl.formatMessage({
|
|
964
|
+
id: messageId
|
|
965
|
+
}, {
|
|
966
|
+
botName: botName
|
|
967
|
+
}) : null;
|
|
968
|
+
}
|
|
969
|
+
componentDidCatch(error, errorInfo) {
|
|
970
|
+
this.props.serviceManager.actions.errorOccurred(createDidCatchErrorData("Message", error, errorInfo));
|
|
971
|
+
this.setState({
|
|
972
|
+
didRenderErrorOccur: true
|
|
973
|
+
});
|
|
974
|
+
}
|
|
975
|
+
componentDidMount() {
|
|
976
|
+
const uiState = this.props.localMessageItem.ui_state;
|
|
977
|
+
if (uiState.needsAnnouncement) {
|
|
978
|
+
this.props.ariaAnnouncer(this.ref.current);
|
|
979
|
+
this.props.serviceManager.store.dispatch(actions.setMessageWasAnnounced(uiState.id));
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
componentDidUpdate() {
|
|
983
|
+
const uiState = this.props.localMessageItem.ui_state;
|
|
984
|
+
if (uiState.needsAnnouncement) {
|
|
985
|
+
this.props.ariaAnnouncer(this.ref.current);
|
|
986
|
+
this.props.serviceManager.store.dispatch(actions.setMessageWasAnnounced(uiState.id));
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
shouldRenderFailedMessage() {
|
|
990
|
+
if (this.state.didRenderErrorOccur) {
|
|
991
|
+
return true;
|
|
992
|
+
}
|
|
993
|
+
const {localMessageItem: localMessageItem, message: message} = this.props;
|
|
994
|
+
return isConnectToAgent(localMessageItem.item) && message.history?.agent_no_service_desk;
|
|
995
|
+
}
|
|
996
|
+
reAnnounceFocusHandle() {
|
|
997
|
+
const handle = this.focusHandleRef.current;
|
|
998
|
+
if (!handle) {
|
|
999
|
+
return;
|
|
1000
|
+
}
|
|
1001
|
+
this.props.ariaAnnouncer(handle.getAttribute("aria-label"));
|
|
1002
|
+
}
|
|
1003
|
+
requestHandleFocus() {
|
|
1004
|
+
const {languagePack: languagePack, intl: intl, message: message, botName: botName} = this.props;
|
|
1005
|
+
const whoAnnouncement = isRequest(message) ? languagePack.messages_youSaid : intl.formatMessage({
|
|
1006
|
+
id: "messages_botSaid"
|
|
1007
|
+
}, {
|
|
1008
|
+
botName: botName
|
|
1009
|
+
});
|
|
1010
|
+
const strings = [ whoAnnouncement ];
|
|
1011
|
+
nodeToText(this.messageRef.current, strings);
|
|
1012
|
+
this.focusHandleRef.current.setAttribute("aria-label", strings.join(" "));
|
|
1013
|
+
doFocusRef(this.focusHandleRef, true);
|
|
1014
|
+
}
|
|
1015
|
+
renderFailedRenderMessage() {
|
|
1016
|
+
const {messagesIndex: messagesIndex} = this.props;
|
|
1017
|
+
return React.createElement("div", {
|
|
1018
|
+
className: `WAC__message WAC__message--inlineError WAC__message-${messagesIndex} ${this.props.className || ""}`,
|
|
1019
|
+
ref: this.ref
|
|
1020
|
+
}, React.createElement("div", {
|
|
1021
|
+
className: "WAC__message--padding"
|
|
1022
|
+
}, React.createElement("div", {
|
|
1023
|
+
className: "WAC__bot-message"
|
|
1024
|
+
}, React.createElement(VisuallyHidden, null, this.getWidgetSaidMessage()), React.createElement("div", {
|
|
1025
|
+
className: "WAC__received WAC__message-vertical-padding WAC__received--text"
|
|
1026
|
+
}, React.createElement(InlineError, {
|
|
1027
|
+
text: this.props.languagePack.errors_singleMessage
|
|
1028
|
+
})))));
|
|
1029
|
+
}
|
|
1030
|
+
renderAvatarLine(localMessageItem, message) {
|
|
1031
|
+
let avatar;
|
|
1032
|
+
const {languagePack: languagePack, botAvatarURL: botAvatarURL, useAITheme: useAITheme, carbonTheme: carbonTheme} = this.props;
|
|
1033
|
+
const timestamp = timestampToTimeString(message.history.timestamp);
|
|
1034
|
+
let label;
|
|
1035
|
+
let actorName;
|
|
1036
|
+
let iconClassName = "";
|
|
1037
|
+
if (isResponse(message)) {
|
|
1038
|
+
const agentMessageType = localMessageItem.item.agent_message_type;
|
|
1039
|
+
const agentProfile = message.history.agent_profile;
|
|
1040
|
+
if (isAgentStatusMessage(agentMessageType)) {
|
|
1041
|
+
return null;
|
|
1042
|
+
}
|
|
1043
|
+
const fromAgent = agentMessageType === AgentMessageType.FROM_AGENT;
|
|
1044
|
+
if (fromAgent || agentProfile?.profile_picture_url) {
|
|
1045
|
+
avatar = React.createElement(ImageWithFallback, {
|
|
1046
|
+
url: agentProfile?.profile_picture_url,
|
|
1047
|
+
alt: fromAgent ? languagePack.agent_ariaAgentAvatar : languagePack.agent_ariaGenericAvatar,
|
|
1048
|
+
fallback: React.createElement(IconHolder, {
|
|
1049
|
+
icon: React.createElement(Headset, null)
|
|
1050
|
+
})
|
|
1051
|
+
});
|
|
1052
|
+
iconClassName = "WACMessage__Avatar--agent";
|
|
1053
|
+
} else {
|
|
1054
|
+
const icon = useAITheme ? React.createElement(AvatarExport, {
|
|
1055
|
+
theme: carbonTheme
|
|
1056
|
+
}) : React.createElement(IconHolder, {
|
|
1057
|
+
icon: React.createElement(ChatBot, null)
|
|
1058
|
+
});
|
|
1059
|
+
const imageUrl = useAITheme ? undefined : botAvatarURL;
|
|
1060
|
+
avatar = React.createElement(ImageWithFallback, {
|
|
1061
|
+
url: imageUrl,
|
|
1062
|
+
alt: languagePack.agent_ariaGenericBotAvatar,
|
|
1063
|
+
fallback: icon
|
|
1064
|
+
});
|
|
1065
|
+
iconClassName = "WACMessage__Avatar--bot";
|
|
1066
|
+
}
|
|
1067
|
+
if (fromAgent || agentProfile?.nickname) {
|
|
1068
|
+
actorName = agentProfile?.nickname || languagePack.agent_agentNoNameTitle;
|
|
1069
|
+
} else if (useAITheme) {
|
|
1070
|
+
actorName = "watsonx";
|
|
1071
|
+
}
|
|
1072
|
+
label = React.createElement("span", {
|
|
1073
|
+
"data-wac-exclude-node-read": true
|
|
1074
|
+
}, React.createElement(FormattedMessage, {
|
|
1075
|
+
id: "message_labelBot",
|
|
1076
|
+
values: {
|
|
1077
|
+
timestamp: timestamp,
|
|
1078
|
+
actorName: actorName
|
|
1079
|
+
}
|
|
1080
|
+
}));
|
|
1081
|
+
} else {
|
|
1082
|
+
label = React.createElement(FormattedMessage, {
|
|
1083
|
+
id: "message_labelYou",
|
|
1084
|
+
values: {
|
|
1085
|
+
timestamp: timestamp
|
|
1086
|
+
}
|
|
1087
|
+
});
|
|
1088
|
+
}
|
|
1089
|
+
return React.createElement("div", {
|
|
1090
|
+
className: "WACMessage__AvatarLine",
|
|
1091
|
+
key: `${message.id}-avatar-line`
|
|
1092
|
+
}, avatar && React.createElement("div", {
|
|
1093
|
+
className: `WACMessage__Avatar ${iconClassName}`
|
|
1094
|
+
}, avatar), React.createElement("div", {
|
|
1095
|
+
className: "WACMessage__Label"
|
|
1096
|
+
}, label));
|
|
1097
|
+
}
|
|
1098
|
+
renderMessageState(message) {
|
|
1099
|
+
const {languagePack: languagePack} = this.props;
|
|
1100
|
+
let element;
|
|
1101
|
+
let className;
|
|
1102
|
+
let showBelowMessage = false;
|
|
1103
|
+
const errorState = message.history?.error_state;
|
|
1104
|
+
const fileStatus = message.history?.file_upload_status;
|
|
1105
|
+
if (errorState === MessageErrorState.FAILED) {
|
|
1106
|
+
element = React.createElement(InlineError, {
|
|
1107
|
+
text: languagePack.errors_singleMessage
|
|
1108
|
+
});
|
|
1109
|
+
className = "WAC__message-error-failed";
|
|
1110
|
+
showBelowMessage = true;
|
|
1111
|
+
} else if (fileStatus === FileStatusValue.UPLOADING) {
|
|
1112
|
+
element = React.createElement(Loading, {
|
|
1113
|
+
withOverlay: false,
|
|
1114
|
+
small: true,
|
|
1115
|
+
"aria-label": languagePack.fileSharing_statusUploading
|
|
1116
|
+
});
|
|
1117
|
+
className = "WAC__message-status-file-uploading";
|
|
1118
|
+
} else if (fileStatus === "success") {
|
|
1119
|
+
element = React.createElement(CheckmarkFilled, {
|
|
1120
|
+
"aria-label": languagePack.fileSharing_statusUploading
|
|
1121
|
+
});
|
|
1122
|
+
className = "WAC__message-status-file-success";
|
|
1123
|
+
}
|
|
1124
|
+
return element && {
|
|
1125
|
+
element: React.createElement("div", {
|
|
1126
|
+
className: `WAC__message-status ${className}`
|
|
1127
|
+
}, element),
|
|
1128
|
+
showBelowMessage: showBelowMessage
|
|
1129
|
+
};
|
|
1130
|
+
}
|
|
1131
|
+
renderFocusHandle() {
|
|
1132
|
+
return React.createElement("div", {
|
|
1133
|
+
className: "WACMessage--focusHandle",
|
|
1134
|
+
ref: this.focusHandleRef,
|
|
1135
|
+
tabIndex: -1,
|
|
1136
|
+
onFocus: this.onHandleFocus,
|
|
1137
|
+
onBlur: this.onHandleBlur,
|
|
1138
|
+
onKeyDown: event => this.onHandleKeyDown(event),
|
|
1139
|
+
onClick: () => this.reAnnounceFocusHandle(),
|
|
1140
|
+
role: "button"
|
|
1141
|
+
});
|
|
1142
|
+
}
|
|
1143
|
+
render() {
|
|
1144
|
+
if (this.shouldRenderFailedMessage()) {
|
|
1145
|
+
return this.renderFailedRenderMessage();
|
|
1146
|
+
}
|
|
1147
|
+
const {serviceManager: serviceManager, config: config, localMessageItem: localMessageItem, message: message, languagePack: languagePack, requestInputFocus: requestInputFocus, messagesIndex: messagesIndex, disableUserInputs: disableUserInputs, showAvatarLine: showAvatarLine, className: className, doAutoScroll: doAutoScroll, isMessageForInput: isMessageForInput, scrollElementIntoView: scrollElementIntoView, isFirstMessageItem: isFirstMessageItem, hideFeedback: hideFeedback, allowNewFeedback: allowNewFeedback} = this.props;
|
|
1148
|
+
const {isIntermediateStreaming: isIntermediateStreaming, isWelcomeResponse: isWelcomeResponse, disableFadeAnimation: disableFadeAnimation} = localMessageItem.ui_state;
|
|
1149
|
+
const messageItem = localMessageItem.item;
|
|
1150
|
+
const responseType = messageItem.response_type;
|
|
1151
|
+
const agentMessageType = messageItem.agent_message_type;
|
|
1152
|
+
const fromHistory = message.history.from_history;
|
|
1153
|
+
const readWidgetSaid = isFirstMessageItem;
|
|
1154
|
+
if (isIntermediateStreaming && !canRenderIntermediateStreaming(messageItem.response_type)) {
|
|
1155
|
+
return false;
|
|
1156
|
+
}
|
|
1157
|
+
const messageComponent = React.createElement(MessageTypeComponent, {
|
|
1158
|
+
serviceManager: serviceManager,
|
|
1159
|
+
languagePack: languagePack,
|
|
1160
|
+
requestInputFocus: requestInputFocus,
|
|
1161
|
+
message: localMessageItem,
|
|
1162
|
+
originalMessage: message,
|
|
1163
|
+
disableUserInputs: disableUserInputs,
|
|
1164
|
+
isMessageForInput: isMessageForInput,
|
|
1165
|
+
config: config,
|
|
1166
|
+
doAutoScroll: doAutoScroll,
|
|
1167
|
+
scrollElementIntoView: scrollElementIntoView,
|
|
1168
|
+
hideFeedback: hideFeedback,
|
|
1169
|
+
allowNewFeedback: allowNewFeedback
|
|
1170
|
+
});
|
|
1171
|
+
const isCustomMessage = renderAsUserDefinedMessage(localMessageItem.item);
|
|
1172
|
+
const noAnimation = isWelcomeResponse || disableFadeAnimation;
|
|
1173
|
+
const agentClassName = getAgentMessageClassName(agentMessageType, responseType, isCustomMessage);
|
|
1174
|
+
const messageIsRequest = isRequest(message);
|
|
1175
|
+
const isSystemMessage = isAgentStatusMessage(localMessageItem.item.agent_message_type);
|
|
1176
|
+
let isOptionResponseWithoutTitleOrDescription = false;
|
|
1177
|
+
if (isOptionItem(localMessageItem.item)) {
|
|
1178
|
+
if (!localMessageItem.item.title && !localMessageItem.item.description) {
|
|
1179
|
+
isOptionResponseWithoutTitleOrDescription = true;
|
|
1180
|
+
}
|
|
1181
|
+
}
|
|
1182
|
+
let messageState;
|
|
1183
|
+
if (messageIsRequest) {
|
|
1184
|
+
messageState = this.renderMessageState(message);
|
|
1185
|
+
}
|
|
1186
|
+
return React.createElement("div", {
|
|
1187
|
+
id: `WAC__message-${messagesIndex}${serviceManager.namespace.suffix}`,
|
|
1188
|
+
className: cx(`WAC__message WAC__message-${messagesIndex}`, className, agentMessageType && "WAC__message--agentMessage", {
|
|
1189
|
+
"WAC__message--withAvatarLine": showAvatarLine,
|
|
1190
|
+
"WAC__message--request": messageIsRequest,
|
|
1191
|
+
"WAC__message--systemMessage": isSystemMessage,
|
|
1192
|
+
"WAC__message--response": !messageIsRequest,
|
|
1193
|
+
"WAC__message--no-animation": noAnimation,
|
|
1194
|
+
"WAC__message--custom": isCustomMessage,
|
|
1195
|
+
"WAC__message--disabled-inputs": disableUserInputs,
|
|
1196
|
+
"WAC__message--has-focus": this.state.focusHandleHasFocus,
|
|
1197
|
+
"WAC__message--option-response-without-title-or-description": isOptionResponseWithoutTitleOrDescription
|
|
1198
|
+
}),
|
|
1199
|
+
ref: this.ref
|
|
1200
|
+
}, this.renderFocusHandle(), showAvatarLine && this.renderAvatarLine(localMessageItem, message), React.createElement("div", {
|
|
1201
|
+
className: "WAC__message--padding"
|
|
1202
|
+
}, isResponse(message) && React.createElement("div", {
|
|
1203
|
+
className: "WAC__bot-message"
|
|
1204
|
+
}, readWidgetSaid && React.createElement(VisuallyHidden, null, this.getWidgetSaidMessage()), React.createElement("div", {
|
|
1205
|
+
className: cx("WAC__received", "WAC__message-vertical-padding", agentClassName, {
|
|
1206
|
+
"WAC__received--text": responseType === MessageResponseTypes.TEXT,
|
|
1207
|
+
"WAC__received--image": responseType === MessageResponseTypes.IMAGE,
|
|
1208
|
+
"WAC__received--options": responseType === MessageResponseTypes.OPTION,
|
|
1209
|
+
"WAC__received--inlineError": responseType === MessageResponseTypes.INLINE_ERROR,
|
|
1210
|
+
"WAC__received--iframePreviewCard": responseType === MessageResponseTypes.IFRAME,
|
|
1211
|
+
"WAC__received--video": responseType === MessageResponseTypes.VIDEO,
|
|
1212
|
+
"WAC__received--audio": responseType === MessageResponseTypes.AUDIO,
|
|
1213
|
+
"WAC__received--date": responseType === MessageResponseTypes.DATE,
|
|
1214
|
+
"WAC__received--card": responseType === MessageResponseTypes.CARD,
|
|
1215
|
+
"WAC__received--carousel": responseType === MessageResponseTypes.CAROUSEL,
|
|
1216
|
+
"WAC__received--conversationalSearch": responseType === MessageResponseTypes.CONVERSATIONAL_SEARCH,
|
|
1217
|
+
"WAC__received--carouselSingle": isSingleItemCarousel(localMessageItem.item),
|
|
1218
|
+
"WAC__received--button": responseType === MessageResponseTypes.BUTTON,
|
|
1219
|
+
"WAC__received--grid": responseType === MessageResponseTypes.GRID,
|
|
1220
|
+
"WAC__received--fullWidth": localMessageItem.ui_state.fullWidth,
|
|
1221
|
+
"WAC__message--historical": fromHistory
|
|
1222
|
+
}),
|
|
1223
|
+
ref: this.messageRef
|
|
1224
|
+
}, React.createElement("div", {
|
|
1225
|
+
className: "WAC__received--inner"
|
|
1226
|
+
}, messageComponent))), messageIsRequest && React.createElement("div", {
|
|
1227
|
+
className: "WAC__sent-container"
|
|
1228
|
+
}, React.createElement("div", {
|
|
1229
|
+
className: cx("WAC__sentAndMessageState-container", "WAC__message-vertical-padding", {
|
|
1230
|
+
"WAC__sentAndMessageState--belowMessage": messageState?.showBelowMessage
|
|
1231
|
+
})
|
|
1232
|
+
}, !messageState?.showBelowMessage && messageState?.element, React.createElement("div", {
|
|
1233
|
+
className: "WAC__sent"
|
|
1234
|
+
}, React.createElement(VisuallyHidden, null, languagePack.messages_youSaid), React.createElement("div", {
|
|
1235
|
+
className: "WAC__sent--bubble"
|
|
1236
|
+
}, React.createElement("div", {
|
|
1237
|
+
ref: this.messageRef
|
|
1238
|
+
}, messageComponent))), messageState?.showBelowMessage && messageState?.element))));
|
|
1239
|
+
}
|
|
1240
|
+
}
|
|
1241
|
+
|
|
1242
|
+
function getAgentMessageClassName(agentMessageType, messageResponseType, isUserDefinedResponse) {
|
|
1243
|
+
if (isUserDefinedResponse) {
|
|
1244
|
+
return "WAC__received--agentCustom";
|
|
1245
|
+
}
|
|
1246
|
+
if (!messageResponseType || messageResponseType !== MessageResponseTypes.TEXT && messageResponseType !== MessageResponseTypes.BUTTON) {
|
|
1247
|
+
return "";
|
|
1248
|
+
}
|
|
1249
|
+
switch (agentMessageType) {
|
|
1250
|
+
case null:
|
|
1251
|
+
case undefined:
|
|
1252
|
+
case AgentMessageType.FROM_USER:
|
|
1253
|
+
return null;
|
|
1254
|
+
|
|
1255
|
+
case AgentMessageType.RELOAD_WARNING:
|
|
1256
|
+
case AgentMessageType.DISCONNECTED:
|
|
1257
|
+
return "WAC__received--chatStatusMessage";
|
|
1258
|
+
|
|
1259
|
+
case AgentMessageType.FROM_AGENT:
|
|
1260
|
+
return "WAC__received--fromAgent";
|
|
1261
|
+
|
|
1262
|
+
default:
|
|
1263
|
+
return "WAC__received--agentStatusMessage";
|
|
1264
|
+
}
|
|
1265
|
+
}
|
|
1266
|
+
|
|
1267
|
+
function isAgentStatusMessage(agentMessageType) {
|
|
1268
|
+
switch (agentMessageType) {
|
|
1269
|
+
case null:
|
|
1270
|
+
case undefined:
|
|
1271
|
+
case AgentMessageType.FROM_USER:
|
|
1272
|
+
case AgentMessageType.RELOAD_WARNING:
|
|
1273
|
+
case AgentMessageType.DISCONNECTED:
|
|
1274
|
+
case AgentMessageType.FROM_AGENT:
|
|
1275
|
+
case AgentMessageType.INLINE_ERROR:
|
|
1276
|
+
return false;
|
|
1277
|
+
|
|
1278
|
+
default:
|
|
1279
|
+
return true;
|
|
1280
|
+
}
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1283
|
+
function canRenderIntermediateStreaming(type) {
|
|
1284
|
+
switch (type) {
|
|
1285
|
+
case MessageResponseTypes.IMAGE:
|
|
1286
|
+
case MessageResponseTypes.VIDEO:
|
|
1287
|
+
case MessageResponseTypes.AUDIO:
|
|
1288
|
+
case MessageResponseTypes.OPTION:
|
|
1289
|
+
case MessageResponseTypes.IFRAME:
|
|
1290
|
+
case MessageResponseTypes.INLINE_ERROR:
|
|
1291
|
+
case MessageResponseTypes.CONVERSATIONAL_SEARCH:
|
|
1292
|
+
case MessageResponseTypes.USER_DEFINED:
|
|
1293
|
+
case MessageResponseTypes.TEXT:
|
|
1294
|
+
return true;
|
|
1295
|
+
|
|
1296
|
+
default:
|
|
1297
|
+
return false;
|
|
1298
|
+
}
|
|
1299
|
+
}
|
|
1300
|
+
|
|
1301
|
+
var MessageComponent$1 = withAriaAnnouncer(injectIntl(MessageComponent, {
|
|
1302
|
+
forwardRef: true
|
|
1303
|
+
}));
|
|
1304
|
+
|
|
1305
|
+
/*
|
|
1306
|
+
* Copyright IBM Corp. 2025
|
|
1307
|
+
*
|
|
1308
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
1309
|
+
* LICENSE file in the root directory of this source tree.
|
|
1310
|
+
*
|
|
1311
|
+
* @license
|
|
1312
|
+
*/ class MessagesComponent extends PureComponent {
|
|
1313
|
+
constructor() {
|
|
1314
|
+
super(...arguments);
|
|
1315
|
+
this.state = {
|
|
1316
|
+
scrollHandleHasFocus: false
|
|
1317
|
+
};
|
|
1318
|
+
this.messageRefs = new Map;
|
|
1319
|
+
this.messagesContainerWithScrollingRef = React.createRef();
|
|
1320
|
+
this.scrollHandleRef = React.createRef();
|
|
1321
|
+
this.agentBannerRef = React.createRef();
|
|
1322
|
+
this.onResize = () => {
|
|
1323
|
+
if (this.props.messageState.isScrollAnchored) {
|
|
1324
|
+
const element = this.messagesContainerWithScrollingRef.current;
|
|
1325
|
+
if (element) {
|
|
1326
|
+
element.scrollTop = element.scrollHeight;
|
|
1327
|
+
}
|
|
1328
|
+
}
|
|
1329
|
+
};
|
|
1330
|
+
this.doAutoScroll = throttle((options = {}) => {
|
|
1331
|
+
try {
|
|
1332
|
+
debugAutoScroll("[doAutoScroll] Running doAutoScroll", options);
|
|
1333
|
+
const {scrollToTop: scrollToTop, scrollToBottom: scrollToBottom} = options;
|
|
1334
|
+
const {localMessageItems: localMessageItems, messageState: messageState, allMessagesByID: allMessagesByID} = this.props;
|
|
1335
|
+
const {isTypingCounter: isTypingCounter, isLoadingCounter: isLoadingCounter} = messageState;
|
|
1336
|
+
const {isAgentTyping: isAgentTyping} = selectAgentDisplayState(this.props);
|
|
1337
|
+
const scrollElement = this.messagesContainerWithScrollingRef.current;
|
|
1338
|
+
if (scrollToTop !== undefined) {
|
|
1339
|
+
doScrollElement(scrollElement, scrollToTop, 0, false);
|
|
1340
|
+
return;
|
|
1341
|
+
}
|
|
1342
|
+
if (scrollToBottom !== undefined) {
|
|
1343
|
+
const scrollTop = scrollElement.scrollHeight - scrollElement.offsetHeight - scrollToBottom;
|
|
1344
|
+
doScrollElement(scrollElement, scrollTop, 0, false);
|
|
1345
|
+
return;
|
|
1346
|
+
}
|
|
1347
|
+
let animate = true;
|
|
1348
|
+
let setScrollTop;
|
|
1349
|
+
const lastLocalItemIndex = localMessageItems.length - 1;
|
|
1350
|
+
const lastLocalItem = localMessageItems.length ? localMessageItems[lastLocalItemIndex] : null;
|
|
1351
|
+
const lastMessage = allMessagesByID[lastLocalItem?.fullMessageID];
|
|
1352
|
+
if (!lastLocalItem) {
|
|
1353
|
+
debugAutoScroll("[doAutoScroll] No last time");
|
|
1354
|
+
animate = false;
|
|
1355
|
+
setScrollTop = 0;
|
|
1356
|
+
} else if (isTypingCounter > 0 || isLoadingCounter > 0 || isAgentTyping) {
|
|
1357
|
+
setScrollTop = scrollElement.scrollHeight;
|
|
1358
|
+
debugAutoScroll("[doAutoScroll] isTyping visible", isTypingCounter);
|
|
1359
|
+
} else {
|
|
1360
|
+
const shouldScrollToMessage = (localItem, message) => {
|
|
1361
|
+
if (isResponse(message)) {
|
|
1362
|
+
const messageRequest = allMessagesByID[message?.request_id];
|
|
1363
|
+
return messageRequest?.history?.silent && messageRequest.input?.text !== "";
|
|
1364
|
+
}
|
|
1365
|
+
return isRequest(message);
|
|
1366
|
+
};
|
|
1367
|
+
let messageIndex = localMessageItems.length - 1;
|
|
1368
|
+
let localItem = localMessageItems[messageIndex];
|
|
1369
|
+
let lastScrollableMessageComponent = this.messageRefs.get(localItem?.ui_state.id);
|
|
1370
|
+
while (messageIndex >= 1) {
|
|
1371
|
+
localItem = localMessageItems[messageIndex];
|
|
1372
|
+
const message = allMessagesByID[localItem?.fullMessageID];
|
|
1373
|
+
if (shouldScrollToMessage(localItem, message)) {
|
|
1374
|
+
lastScrollableMessageComponent = this.messageRefs.get(localItem?.ui_state.id);
|
|
1375
|
+
debugAutoScroll(`[doAutoScroll] lastScrollableMessageComponent=${messageIndex}`, localMessageItems[messageIndex], message);
|
|
1376
|
+
break;
|
|
1377
|
+
}
|
|
1378
|
+
messageIndex--;
|
|
1379
|
+
}
|
|
1380
|
+
if (lastScrollableMessageComponent) {
|
|
1381
|
+
const offsetTop = lastScrollableMessageComponent.ref.current?.offsetTop;
|
|
1382
|
+
setScrollTop = offsetTop + AUTO_SCROLL_EXTRA;
|
|
1383
|
+
debugAutoScroll(`[doAutoScroll] Scrolling to message offsetTop=${offsetTop}`);
|
|
1384
|
+
} else {
|
|
1385
|
+
setScrollTop = -1;
|
|
1386
|
+
debugAutoScroll("[doAutoScroll] No message found");
|
|
1387
|
+
}
|
|
1388
|
+
}
|
|
1389
|
+
if (setScrollTop !== -1) {
|
|
1390
|
+
if (setScrollTop >= scrollElement.scrollTop) {
|
|
1391
|
+
if (lastMessage?.history?.from_history) {
|
|
1392
|
+
animate = false;
|
|
1393
|
+
}
|
|
1394
|
+
debugAutoScroll(`[doAutoScroll] doScrollElement`, scrollElement, setScrollTop, animate);
|
|
1395
|
+
doScrollElement(scrollElement, setScrollTop, 0, animate);
|
|
1396
|
+
this.checkScrollAnchor(true, setScrollTop);
|
|
1397
|
+
}
|
|
1398
|
+
}
|
|
1399
|
+
} catch (error) {
|
|
1400
|
+
consoleError("An error occurred while attempting to scroll.", error);
|
|
1401
|
+
}
|
|
1402
|
+
}, AUTO_SCROLL_THROTTLE_TIMEOUT);
|
|
1403
|
+
this.getContainerScrollBottom = () => getScrollBottom(this.messagesContainerWithScrollingRef?.current);
|
|
1404
|
+
this.scrollElementIntoView = (element, paddingTop = 8, paddingBottom = 8) => {
|
|
1405
|
+
const scrollElement = this.messagesContainerWithScrollingRef.current;
|
|
1406
|
+
const scrollRect = scrollElement.getBoundingClientRect();
|
|
1407
|
+
const elementRect = element.getBoundingClientRect();
|
|
1408
|
+
const topDistanceFromTop = elementRect.top - scrollRect.top + scrollElement.scrollTop - paddingTop;
|
|
1409
|
+
const bottomDistanceFromTop = elementRect.bottom - scrollRect.top + scrollElement.scrollTop + paddingBottom;
|
|
1410
|
+
const elementHeight = element.offsetHeight + paddingTop + paddingBottom;
|
|
1411
|
+
if (topDistanceFromTop < scrollElement.scrollTop || elementHeight > scrollElement.offsetHeight) {
|
|
1412
|
+
doScrollElement(scrollElement, topDistanceFromTop, 0);
|
|
1413
|
+
} else if (bottomDistanceFromTop > scrollElement.scrollTop + scrollElement.offsetHeight) {
|
|
1414
|
+
doScrollElement(scrollElement, bottomDistanceFromTop - scrollElement.offsetHeight, 0);
|
|
1415
|
+
}
|
|
1416
|
+
};
|
|
1417
|
+
this.requestMoveFocus = (moveFocusType, currentMessageIndex) => {
|
|
1418
|
+
if (moveFocusType === MoveFocusType.INPUT) {
|
|
1419
|
+
this.props.requestInputFocus();
|
|
1420
|
+
} else {
|
|
1421
|
+
const {localMessageItems: localMessageItems} = this.props;
|
|
1422
|
+
let index;
|
|
1423
|
+
switch (moveFocusType) {
|
|
1424
|
+
case MoveFocusType.LAST:
|
|
1425
|
+
index = localMessageItems.length - 1;
|
|
1426
|
+
break;
|
|
1427
|
+
|
|
1428
|
+
case MoveFocusType.NEXT:
|
|
1429
|
+
index = currentMessageIndex + 1;
|
|
1430
|
+
if (index >= localMessageItems.length) {
|
|
1431
|
+
index = 0;
|
|
1432
|
+
}
|
|
1433
|
+
break;
|
|
1434
|
+
|
|
1435
|
+
case MoveFocusType.PREVIOUS:
|
|
1436
|
+
index = currentMessageIndex - 1;
|
|
1437
|
+
if (index < 0) {
|
|
1438
|
+
index = localMessageItems.length - 1;
|
|
1439
|
+
}
|
|
1440
|
+
break;
|
|
1441
|
+
|
|
1442
|
+
default:
|
|
1443
|
+
index = 0;
|
|
1444
|
+
break;
|
|
1445
|
+
}
|
|
1446
|
+
const messageItem = localMessageItems[index];
|
|
1447
|
+
const ref = this.messageRefs.get(messageItem?.ui_state.id);
|
|
1448
|
+
if (ref) {
|
|
1449
|
+
ref.requestHandleFocus();
|
|
1450
|
+
}
|
|
1451
|
+
}
|
|
1452
|
+
};
|
|
1453
|
+
}
|
|
1454
|
+
componentDidMount() {
|
|
1455
|
+
this.scrollPanelObserver = new ResizeObserver(this.onResize);
|
|
1456
|
+
this.scrollPanelObserver.observe(this.messagesContainerWithScrollingRef.current);
|
|
1457
|
+
this.previousScrollOffsetHeight = this.messagesContainerWithScrollingRef.current.offsetHeight;
|
|
1458
|
+
}
|
|
1459
|
+
componentDidUpdate(oldProps) {
|
|
1460
|
+
const newProps = this.props;
|
|
1461
|
+
const numMessagesChanged = oldProps.localMessageItems.length !== newProps.localMessageItems.length;
|
|
1462
|
+
const oldAgentDisplayState = selectAgentDisplayState(oldProps);
|
|
1463
|
+
const newAgentDisplayState = selectAgentDisplayState(newProps);
|
|
1464
|
+
const typingChanged = oldProps.messageState.isTypingCounter !== newProps.messageState.isTypingCounter || oldProps.messageState.isLoadingCounter !== newProps.messageState.isLoadingCounter || oldAgentDisplayState.isAgentTyping !== newAgentDisplayState.isAgentTyping;
|
|
1465
|
+
if (numMessagesChanged || typingChanged) {
|
|
1466
|
+
const newLastItem = arrayLastValue(newProps.localMessageItems);
|
|
1467
|
+
const oldLastItem = arrayLastValue(oldProps.localMessageItems);
|
|
1468
|
+
const lastItemChanged = newLastItem !== oldLastItem;
|
|
1469
|
+
if (lastItemChanged || typingChanged) {
|
|
1470
|
+
this.doAutoScroll();
|
|
1471
|
+
}
|
|
1472
|
+
}
|
|
1473
|
+
}
|
|
1474
|
+
componentWillUnmount() {
|
|
1475
|
+
this.scrollPanelObserver.unobserve(this.messagesContainerWithScrollingRef.current);
|
|
1476
|
+
}
|
|
1477
|
+
checkScrollAnchor(fromAutoScroll, assumeScrollTop) {
|
|
1478
|
+
const scrollElement = this.messagesContainerWithScrollingRef.current;
|
|
1479
|
+
if (fromAutoScroll || this.previousScrollOffsetHeight === scrollElement.offsetHeight && !this.props.suspendScrollDetection) {
|
|
1480
|
+
const assumedScrollTop = assumeScrollTop !== undefined ? assumeScrollTop : scrollElement.scrollTop;
|
|
1481
|
+
const isScrollAnchored = assumedScrollTop >= scrollElement.scrollHeight - scrollElement.offsetHeight;
|
|
1482
|
+
if (isScrollAnchored !== this.props.messageState.isScrollAnchored) {
|
|
1483
|
+
this.props.serviceManager.store.dispatch(actions.setChatMessagesStateProperty("isScrollAnchored", isScrollAnchored));
|
|
1484
|
+
}
|
|
1485
|
+
}
|
|
1486
|
+
this.previousScrollOffsetHeight = scrollElement.offsetHeight;
|
|
1487
|
+
}
|
|
1488
|
+
requestAgentBannerFocus() {
|
|
1489
|
+
if (this.agentBannerRef.current) {
|
|
1490
|
+
return this.agentBannerRef.current.requestFocus();
|
|
1491
|
+
}
|
|
1492
|
+
return false;
|
|
1493
|
+
}
|
|
1494
|
+
doScrollToMessage(messageID, animate = true) {
|
|
1495
|
+
try {
|
|
1496
|
+
const {localMessageItems: localMessageItems} = this.props;
|
|
1497
|
+
let panelComponent;
|
|
1498
|
+
for (let index = 0; index <= localMessageItems.length; index++) {
|
|
1499
|
+
const messageItem = localMessageItems[index];
|
|
1500
|
+
if (messageItem.fullMessageID === messageID) {
|
|
1501
|
+
panelComponent = this.messageRefs.get(messageItem.ui_state.id);
|
|
1502
|
+
break;
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1505
|
+
if (panelComponent) {
|
|
1506
|
+
const scrollElement = this.messagesContainerWithScrollingRef.current;
|
|
1507
|
+
const setScrollTop = panelComponent.ref.current.offsetTop;
|
|
1508
|
+
doScrollElement(scrollElement, setScrollTop, 0, animate);
|
|
1509
|
+
this.checkScrollAnchor(true, setScrollTop);
|
|
1510
|
+
}
|
|
1511
|
+
} catch (error) {
|
|
1512
|
+
consoleError("An error occurred while attempting to scroll.", error);
|
|
1513
|
+
}
|
|
1514
|
+
}
|
|
1515
|
+
getLastOutputMessageElements() {
|
|
1516
|
+
const {localMessageItems: localMessageItems, allMessagesByID: allMessagesByID} = this.props;
|
|
1517
|
+
const lastMessageItem = arrayLastValue(localMessageItems);
|
|
1518
|
+
const lastMessage = allMessagesByID[lastMessageItem?.fullMessageID];
|
|
1519
|
+
if (isResponse(lastMessage)) {
|
|
1520
|
+
const elements = [];
|
|
1521
|
+
let hasFoundLastBotMessageGroupID = false;
|
|
1522
|
+
for (let index = localMessageItems.length - 1; index >= 0; index--) {
|
|
1523
|
+
const messageItem = localMessageItems[index];
|
|
1524
|
+
const componentRef = this.messageRefs.get(messageItem?.ui_state.id);
|
|
1525
|
+
if (componentRef) {
|
|
1526
|
+
const {getLocalMessage: getLocalMessage} = componentRef;
|
|
1527
|
+
if (getLocalMessage().fullMessageID === lastMessage.id) {
|
|
1528
|
+
hasFoundLastBotMessageGroupID = true;
|
|
1529
|
+
const element = componentRef.ref?.current;
|
|
1530
|
+
if (element) {
|
|
1531
|
+
elements.push(element);
|
|
1532
|
+
} else {
|
|
1533
|
+
break;
|
|
1534
|
+
}
|
|
1535
|
+
} else if (hasFoundLastBotMessageGroupID) {
|
|
1536
|
+
break;
|
|
1537
|
+
}
|
|
1538
|
+
}
|
|
1539
|
+
}
|
|
1540
|
+
return elements.reverse();
|
|
1541
|
+
}
|
|
1542
|
+
return [];
|
|
1543
|
+
}
|
|
1544
|
+
renderTypingIndicator(isTypingMessage, index) {
|
|
1545
|
+
return React.createElement("div", {
|
|
1546
|
+
className: `WAC__message WAC__message-${index} WAC__message--lastMessage`
|
|
1547
|
+
}, React.createElement("div", {
|
|
1548
|
+
className: "WAC__message--padding"
|
|
1549
|
+
}, isTypingMessage && React.createElement(AriaLiveMessageExport, {
|
|
1550
|
+
message: isTypingMessage
|
|
1551
|
+
}), React.createElement("div", {
|
|
1552
|
+
className: "WAC__bot-message"
|
|
1553
|
+
}, React.createElement("div", {
|
|
1554
|
+
className: "WAC__received WAC__received--loading WAC__message-vertical-padding"
|
|
1555
|
+
}, React.createElement("div", {
|
|
1556
|
+
className: "WAC__received--inner"
|
|
1557
|
+
}, React.createElement(InlineLoadingComponent, {
|
|
1558
|
+
loop: true,
|
|
1559
|
+
carbonTheme: this.props.carbonTheme
|
|
1560
|
+
}))))));
|
|
1561
|
+
}
|
|
1562
|
+
renderMessage(localMessage, fullMessage, messagesIndex, showBeforeWelcomeNodeElement, isMessageForInput, isFirstMessageItem, lastMessageID) {
|
|
1563
|
+
const {serviceManager: serviceManager, config: config, languagePack: languagePack, requestInputFocus: requestInputFocus, persistedToBrowserStorage: persistedToBrowserStorage, botName: botName, messageState: messageState, locale: locale, botAvatarURL: botAvatarURL, carbonTheme: carbonTheme, useAITheme: useAITheme} = this.props;
|
|
1564
|
+
const inputState = selectInputState(this.props);
|
|
1565
|
+
const {isAgentTyping: isAgentTyping} = selectAgentDisplayState(this.props);
|
|
1566
|
+
const {isTypingCounter: isTypingCounter, isLoadingCounter: isLoadingCounter} = messageState;
|
|
1567
|
+
const {chatState: chatState} = persistedToBrowserStorage;
|
|
1568
|
+
const {disclaimersAccepted: disclaimersAccepted} = chatState;
|
|
1569
|
+
if (config.public.disclaimer?.is_on && !disclaimersAccepted[window.location.hostname]) {
|
|
1570
|
+
return null;
|
|
1571
|
+
}
|
|
1572
|
+
const totalMessagesWithTyping = this.props.localMessageItems.length + (isTypingCounter > 0 || isLoadingCounter > 0 || isAgentTyping ? 1 : 0);
|
|
1573
|
+
const isLastMessage = messagesIndex === totalMessagesWithTyping - 1;
|
|
1574
|
+
const className = cx({
|
|
1575
|
+
"WAC__message--firstMessage": messagesIndex === 0,
|
|
1576
|
+
"WAC__message--lastMessage": isLastMessage
|
|
1577
|
+
});
|
|
1578
|
+
const allowNewFeedback = localMessage.fullMessageID === lastMessageID;
|
|
1579
|
+
const messageItemID = localMessage.ui_state.id;
|
|
1580
|
+
const message = React.createElement(MessageComponent$1, {
|
|
1581
|
+
ref: component => {
|
|
1582
|
+
if (component) {
|
|
1583
|
+
this.messageRefs.set(messageItemID, component);
|
|
1584
|
+
} else {
|
|
1585
|
+
this.messageRefs.delete(messageItemID);
|
|
1586
|
+
}
|
|
1587
|
+
},
|
|
1588
|
+
className: className,
|
|
1589
|
+
config: config,
|
|
1590
|
+
localMessageItem: localMessage,
|
|
1591
|
+
message: fullMessage,
|
|
1592
|
+
languagePack: languagePack,
|
|
1593
|
+
requestInputFocus: requestInputFocus,
|
|
1594
|
+
serviceManager: serviceManager,
|
|
1595
|
+
messagesIndex: messagesIndex,
|
|
1596
|
+
botName: botName,
|
|
1597
|
+
disableUserInputs: inputState.isReadonly,
|
|
1598
|
+
isMessageForInput: isMessageForInput,
|
|
1599
|
+
showAvatarLine: isFirstMessageItem,
|
|
1600
|
+
botAvatarURL: botAvatarURL,
|
|
1601
|
+
requestMoveFocus: this.requestMoveFocus,
|
|
1602
|
+
doAutoScroll: this.doAutoScroll,
|
|
1603
|
+
scrollElementIntoView: this.scrollElementIntoView,
|
|
1604
|
+
isFirstMessageItem: isFirstMessageItem,
|
|
1605
|
+
locale: locale,
|
|
1606
|
+
carbonTheme: carbonTheme,
|
|
1607
|
+
useAITheme: useAITheme,
|
|
1608
|
+
allowNewFeedback: allowNewFeedback,
|
|
1609
|
+
hideFeedback: false
|
|
1610
|
+
});
|
|
1611
|
+
if (showBeforeWelcomeNodeElement) {
|
|
1612
|
+
return React.createElement(LatestWelcomeNodes$1, {
|
|
1613
|
+
welcomeNodeBeforeElement: serviceManager.writeableElements[WriteableElementName.WELCOME_NODE_BEFORE_ELEMENT],
|
|
1614
|
+
key: messageItemID
|
|
1615
|
+
}, message);
|
|
1616
|
+
}
|
|
1617
|
+
return React.createElement(Fragment, {
|
|
1618
|
+
key: messageItemID
|
|
1619
|
+
}, message);
|
|
1620
|
+
}
|
|
1621
|
+
renderAgentBanner() {
|
|
1622
|
+
return React.createElement(AgentBannerContainer, {
|
|
1623
|
+
bannerRef: this.agentBannerRef,
|
|
1624
|
+
onButtonClick: this.props.onEndAgentChat
|
|
1625
|
+
});
|
|
1626
|
+
}
|
|
1627
|
+
renderScrollHandle(atTop) {
|
|
1628
|
+
const {languagePack: languagePack} = this.props;
|
|
1629
|
+
let labelKey;
|
|
1630
|
+
if (IS_MOBILE) {
|
|
1631
|
+
labelKey = atTop ? "messages_scrollHandle" : "messages_scrollHandleEnd";
|
|
1632
|
+
} else {
|
|
1633
|
+
labelKey = atTop ? "messages_scrollHandleDetailed" : "messages_scrollHandleEndDetailed";
|
|
1634
|
+
}
|
|
1635
|
+
const onClick = IS_MOBILE ? undefined : () => this.requestMoveFocus(atTop ? MoveFocusType.FIRST : MoveFocusType.LAST, 0);
|
|
1636
|
+
return React.createElement("button", {
|
|
1637
|
+
type: "button",
|
|
1638
|
+
className: "WACMessages--scrollHandle",
|
|
1639
|
+
ref: this.scrollHandleRef,
|
|
1640
|
+
tabIndex: 0,
|
|
1641
|
+
"aria-label": languagePack[labelKey] || languagePack.messages_scrollHandle,
|
|
1642
|
+
onClick: onClick,
|
|
1643
|
+
onFocus: () => this.setState({
|
|
1644
|
+
scrollHandleHasFocus: true
|
|
1645
|
+
}),
|
|
1646
|
+
onBlur: () => this.setState({
|
|
1647
|
+
scrollHandleHasFocus: false
|
|
1648
|
+
})
|
|
1649
|
+
});
|
|
1650
|
+
}
|
|
1651
|
+
getMessageIDForUserInput() {
|
|
1652
|
+
const {localMessageItems: localMessageItems, allMessagesByID: allMessagesByID} = this.props;
|
|
1653
|
+
for (let index = localMessageItems.length - 1; index >= 0; index--) {
|
|
1654
|
+
const message = localMessageItems[index];
|
|
1655
|
+
const originalMessage = allMessagesByID[message.fullMessageID];
|
|
1656
|
+
if (isRequest(originalMessage) && originalMessage?.history?.error_state !== MessageErrorState.FAILED) {
|
|
1657
|
+
return null;
|
|
1658
|
+
}
|
|
1659
|
+
if (isResponse(originalMessage)) {
|
|
1660
|
+
return message.fullMessageID;
|
|
1661
|
+
}
|
|
1662
|
+
}
|
|
1663
|
+
return null;
|
|
1664
|
+
}
|
|
1665
|
+
renderMessages(messageIDForInput) {
|
|
1666
|
+
const {localMessageItems: localMessageItems, allMessagesByID: allMessagesByID} = this.props;
|
|
1667
|
+
const renderMessageArray = [];
|
|
1668
|
+
const lastMessageID = arrayLastValue(localMessageItems)?.fullMessageID;
|
|
1669
|
+
let previousMessageID = null;
|
|
1670
|
+
for (let currentIndex = 0; currentIndex < localMessageItems.length; currentIndex++) {
|
|
1671
|
+
const localMessageItem = localMessageItems[currentIndex];
|
|
1672
|
+
const fullMessage = allMessagesByID[localMessageItem.fullMessageID];
|
|
1673
|
+
const isMessageForInput = messageIDForInput === localMessageItem.fullMessageID;
|
|
1674
|
+
const isFirstMessageItem = previousMessageID !== localMessageItem.fullMessageID;
|
|
1675
|
+
const showBeforeWelcomeNodeElement = localMessageItem.ui_state.isWelcomeResponse && isFirstMessageItem;
|
|
1676
|
+
previousMessageID = localMessageItem.fullMessageID;
|
|
1677
|
+
renderMessageArray.push(this.renderMessage(localMessageItem, fullMessage, currentIndex, showBeforeWelcomeNodeElement, isMessageForInput, isFirstMessageItem, lastMessageID));
|
|
1678
|
+
}
|
|
1679
|
+
return renderMessageArray;
|
|
1680
|
+
}
|
|
1681
|
+
render() {
|
|
1682
|
+
const {localMessageItems: localMessageItems, messageState: messageState, intl: intl, botName: botName, serviceManager: serviceManager, notifications: notifications} = this.props;
|
|
1683
|
+
const {isTypingCounter: isTypingCounter, isLoadingCounter: isLoadingCounter} = messageState;
|
|
1684
|
+
const {isAgentTyping: isAgentTyping} = selectAgentDisplayState(this.props);
|
|
1685
|
+
const {scrollHandleHasFocus: scrollHandleHasFocus} = this.state;
|
|
1686
|
+
const messageIDForInput = this.getMessageIDForUserInput();
|
|
1687
|
+
const regularMessages = this.renderMessages(messageIDForInput);
|
|
1688
|
+
let isTypingMessage;
|
|
1689
|
+
if (isAgentTyping) {
|
|
1690
|
+
isTypingMessage = intl.formatMessage({
|
|
1691
|
+
id: "messages_agentIsTyping"
|
|
1692
|
+
});
|
|
1693
|
+
} else if (isTypingCounter) {
|
|
1694
|
+
isTypingMessage = intl.formatMessage({
|
|
1695
|
+
id: "messages_botIsTyping"
|
|
1696
|
+
}, {
|
|
1697
|
+
botName: botName
|
|
1698
|
+
});
|
|
1699
|
+
} else if (isLoadingCounter) {
|
|
1700
|
+
isTypingMessage = intl.formatMessage({
|
|
1701
|
+
id: "messages_botIsLoading"
|
|
1702
|
+
}, {
|
|
1703
|
+
botName: botName
|
|
1704
|
+
});
|
|
1705
|
+
}
|
|
1706
|
+
return React.createElement("div", {
|
|
1707
|
+
id: `WACMessages--holder${serviceManager.namespace.suffix}`,
|
|
1708
|
+
className: "WACMessages--holder"
|
|
1709
|
+
}, this.renderAgentBanner(), React.createElement("div", {
|
|
1710
|
+
className: cx("WACMessages__Wrapper", {
|
|
1711
|
+
"WACMessages__Wrapper--scrollHandleHasFocus": scrollHandleHasFocus
|
|
1712
|
+
})
|
|
1713
|
+
}, React.createElement("div", {
|
|
1714
|
+
id: `WAC__messages${serviceManager.namespace.suffix}`,
|
|
1715
|
+
className: "WAC__messages",
|
|
1716
|
+
ref: this.messagesContainerWithScrollingRef,
|
|
1717
|
+
onScroll: () => this.checkScrollAnchor()
|
|
1718
|
+
}, this.renderScrollHandle(true), regularMessages, (Boolean(isTypingCounter) || Boolean(isLoadingCounter) || isAgentTyping) && this.renderTypingIndicator(isTypingMessage, localMessageItems.length), React.createElement(Notifications, {
|
|
1719
|
+
serviceManager: serviceManager,
|
|
1720
|
+
notifications: notifications
|
|
1721
|
+
}), this.renderScrollHandle(false))));
|
|
1722
|
+
}
|
|
1723
|
+
}
|
|
1724
|
+
|
|
1725
|
+
function debugAutoScroll(message, ...args) {}
|
|
1726
|
+
|
|
1727
|
+
var MessagesComponent$1 = withServiceManager(connect(state => state, null, null, {
|
|
1728
|
+
forwardRef: true
|
|
1729
|
+
})(MessagesComponent));
|
|
1730
|
+
|
|
1731
|
+
/*
|
|
1732
|
+
* Copyright IBM Corp. 2025
|
|
1733
|
+
*
|
|
1734
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
1735
|
+
* LICENSE file in the root directory of this source tree.
|
|
1736
|
+
*
|
|
1737
|
+
* @license
|
|
1738
|
+
*/ function createUnmappingMemoizer() {
|
|
1739
|
+
return memoizeOne((keys, map) => keys.map(key => map[key]), isUnmappingEqual);
|
|
1740
|
+
}
|
|
1741
|
+
|
|
1742
|
+
function isUnmappingEqual(newArgs, oldArgs) {
|
|
1743
|
+
const [keys1, map1] = newArgs;
|
|
1744
|
+
const [keys2, map2] = oldArgs;
|
|
1745
|
+
if (keys1 === keys2 && map1 === map2) {
|
|
1746
|
+
return true;
|
|
1747
|
+
}
|
|
1748
|
+
if (keys1.length !== keys2.length) {
|
|
1749
|
+
return false;
|
|
1750
|
+
}
|
|
1751
|
+
for (let index = 0; index <= keys1.length; index++) {
|
|
1752
|
+
const key1 = keys1[index];
|
|
1753
|
+
const key2 = keys2[index];
|
|
1754
|
+
if (key1 !== key2) {
|
|
1755
|
+
return false;
|
|
1756
|
+
}
|
|
1757
|
+
const value1 = map1[key1];
|
|
1758
|
+
const value2 = map2[key2];
|
|
1759
|
+
if (value1 !== value2) {
|
|
1760
|
+
return false;
|
|
1761
|
+
}
|
|
1762
|
+
}
|
|
1763
|
+
return true;
|
|
1764
|
+
}
|
|
1765
|
+
|
|
1766
|
+
/*
|
|
1767
|
+
* Copyright IBM Corp. 2025
|
|
1768
|
+
*
|
|
1769
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
1770
|
+
* LICENSE file in the root directory of this source tree.
|
|
1771
|
+
*
|
|
1772
|
+
* @license
|
|
1773
|
+
*/ function RequestScreenShareModal() {
|
|
1774
|
+
const serviceManager = useServiceManager();
|
|
1775
|
+
const languagePack = useLanguagePack();
|
|
1776
|
+
const onConfirm = () => {
|
|
1777
|
+
serviceManager.humanAgentService?.screenShareUpdateRequestState(ScreenShareState.ACCEPTED);
|
|
1778
|
+
};
|
|
1779
|
+
const onCancel = () => {
|
|
1780
|
+
serviceManager.humanAgentService?.screenShareUpdateRequestState(ScreenShareState.DECLINED);
|
|
1781
|
+
};
|
|
1782
|
+
const title = languagePack.agent_sharingRequestTitle;
|
|
1783
|
+
const message = languagePack.agent_sharingRequestMessage;
|
|
1784
|
+
const cancelButtonLabel = languagePack.agent_sharingDeclineButton;
|
|
1785
|
+
const confirmButtonLabel = languagePack.agent_sharingAcceptButton;
|
|
1786
|
+
return React.createElement(ConfirmModal, {
|
|
1787
|
+
title: title,
|
|
1788
|
+
message: message,
|
|
1789
|
+
onConfirm: onConfirm,
|
|
1790
|
+
onCancel: onCancel,
|
|
1791
|
+
cancelButtonLabel: cancelButtonLabel,
|
|
1792
|
+
confirmButtonLabel: confirmButtonLabel,
|
|
1793
|
+
modalAnnounceMessage: message,
|
|
1794
|
+
serviceManager: serviceManager
|
|
1795
|
+
});
|
|
1796
|
+
}
|
|
1797
|
+
|
|
1798
|
+
/*
|
|
1799
|
+
* Copyright IBM Corp. 2025
|
|
1800
|
+
*
|
|
1801
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
1802
|
+
* LICENSE file in the root directory of this source tree.
|
|
1803
|
+
*
|
|
1804
|
+
* @license
|
|
1805
|
+
*/ class Chat extends Component {
|
|
1806
|
+
constructor() {
|
|
1807
|
+
super(...arguments);
|
|
1808
|
+
this.state = {
|
|
1809
|
+
showEndChatConfirmation: false,
|
|
1810
|
+
hasCaughtError: false
|
|
1811
|
+
};
|
|
1812
|
+
this.inputRef = React.createRef();
|
|
1813
|
+
this.headerRef = React.createRef();
|
|
1814
|
+
this.messagesRef = React.createRef();
|
|
1815
|
+
this.messagesToArray = createUnmappingMemoizer();
|
|
1816
|
+
this.hideConfirmEndChat = () => {
|
|
1817
|
+
this.setState({
|
|
1818
|
+
showEndChatConfirmation: false
|
|
1819
|
+
});
|
|
1820
|
+
setTimeout(() => {
|
|
1821
|
+
this.requestInputFocus();
|
|
1822
|
+
});
|
|
1823
|
+
};
|
|
1824
|
+
this.showConfirmEndChat = () => {
|
|
1825
|
+
this.setState({
|
|
1826
|
+
showEndChatConfirmation: true
|
|
1827
|
+
});
|
|
1828
|
+
};
|
|
1829
|
+
this.confirmAgentEndChat = () => {
|
|
1830
|
+
this.hideConfirmEndChat();
|
|
1831
|
+
this.props.serviceManager.humanAgentService.endChat(true);
|
|
1832
|
+
};
|
|
1833
|
+
this.requestDefaultFocus = () => {
|
|
1834
|
+
if (!this.headerRef?.current?.requestFocus()) {
|
|
1835
|
+
doFocusRef(this.messagesRef.current?.scrollHandleRef);
|
|
1836
|
+
}
|
|
1837
|
+
};
|
|
1838
|
+
this.requestInputFocus = () => {
|
|
1839
|
+
const {agentDisplayState: agentDisplayState} = this.props;
|
|
1840
|
+
try {
|
|
1841
|
+
if (agentDisplayState.isConnectingOrConnected && agentDisplayState.disableInput) {
|
|
1842
|
+
if (this.messagesRef.current.requestAgentBannerFocus()) {
|
|
1843
|
+
return;
|
|
1844
|
+
}
|
|
1845
|
+
}
|
|
1846
|
+
if (this.inputRef.current) {
|
|
1847
|
+
if (this.props.inputState.fieldVisible && !this.shouldDisableInput()) {
|
|
1848
|
+
this.inputRef.current.takeFocus();
|
|
1849
|
+
} else {
|
|
1850
|
+
const htmlElements = this.messagesRef.current.getLastOutputMessageElements();
|
|
1851
|
+
if (!focusOnFirstFocusableItemInArrayOfElements(htmlElements)) {
|
|
1852
|
+
this.requestDefaultFocus();
|
|
1853
|
+
}
|
|
1854
|
+
}
|
|
1855
|
+
} else {
|
|
1856
|
+
this.requestDefaultFocus();
|
|
1857
|
+
}
|
|
1858
|
+
} catch (error) {
|
|
1859
|
+
consoleError("An error occurred in Chat.requestInputFocus", error);
|
|
1860
|
+
}
|
|
1861
|
+
};
|
|
1862
|
+
this.doAutoScroll = options => {
|
|
1863
|
+
this.messagesRef.current?.doAutoScroll(options);
|
|
1864
|
+
};
|
|
1865
|
+
this.getMessagesScrollBottom = () => this.messagesRef?.current?.getContainerScrollBottom();
|
|
1866
|
+
this.onFilesSelectedForUpload = uploads => {
|
|
1867
|
+
const isInputToAgent = this.props.agentDisplayState.isConnectingOrConnected;
|
|
1868
|
+
if (isInputToAgent) {
|
|
1869
|
+
this.props.serviceManager.humanAgentService.filesSelectedForUpload(uploads);
|
|
1870
|
+
if (!this.props.inputState.allowMultipleFileUploads) {
|
|
1871
|
+
this.requestInputFocus();
|
|
1872
|
+
}
|
|
1873
|
+
}
|
|
1874
|
+
};
|
|
1875
|
+
}
|
|
1876
|
+
async scrollOnHydrationComplete() {
|
|
1877
|
+
this.doAutoScroll();
|
|
1878
|
+
}
|
|
1879
|
+
componentDidMount() {
|
|
1880
|
+
if (this.props.isHydrationAnimationComplete) {
|
|
1881
|
+
setTimeout(() => {
|
|
1882
|
+
this.scrollOnHydrationComplete();
|
|
1883
|
+
});
|
|
1884
|
+
}
|
|
1885
|
+
}
|
|
1886
|
+
componentDidUpdate(prevProps) {
|
|
1887
|
+
const {isHydrationAnimationComplete: isHydrationAnimationComplete, agentState: agentState} = this.props;
|
|
1888
|
+
if (isHydrationAnimationComplete && !prevProps.isHydrationAnimationComplete) {
|
|
1889
|
+
setTimeout(() => {
|
|
1890
|
+
this.scrollOnHydrationComplete();
|
|
1891
|
+
});
|
|
1892
|
+
}
|
|
1893
|
+
const connectingChanged = agentState.isConnecting !== prevProps.agentState.isConnecting;
|
|
1894
|
+
if (this.state.showEndChatConfirmation && connectingChanged) {
|
|
1895
|
+
this.hideConfirmEndChat();
|
|
1896
|
+
}
|
|
1897
|
+
}
|
|
1898
|
+
componentDidCatch(error, errorInfo) {
|
|
1899
|
+
this.props.serviceManager.actions.errorOccurred(createDidCatchErrorData("Chat", error, errorInfo));
|
|
1900
|
+
this.setState({
|
|
1901
|
+
hasCaughtError: true
|
|
1902
|
+
});
|
|
1903
|
+
}
|
|
1904
|
+
doScrollToMessage(messageID, animate = true) {
|
|
1905
|
+
this.messagesRef.current?.doScrollToMessage(messageID, animate);
|
|
1906
|
+
}
|
|
1907
|
+
getMessageInput() {
|
|
1908
|
+
return this.inputRef.current?.getMessageInput();
|
|
1909
|
+
}
|
|
1910
|
+
shouldDisableInput() {
|
|
1911
|
+
return this.props.inputState.isReadonly || this.props.agentDisplayState.disableInput;
|
|
1912
|
+
}
|
|
1913
|
+
shouldDisableSend() {
|
|
1914
|
+
const {isHydrated: isHydrated} = this.props;
|
|
1915
|
+
return this.shouldDisableInput() || !isHydrated;
|
|
1916
|
+
}
|
|
1917
|
+
renderMessagesAndInput() {
|
|
1918
|
+
const {languagePack: languagePack, messageState: messageState, intl: intl, allMessageItemsByID: allMessageItemsByID, isHydrated: isHydrated, serviceManager: serviceManager, inputState: inputState, onUserTyping: onUserTyping, agentState: agentState, botName: botName, onSendInput: onSendInput, locale: locale, useAITheme: useAITheme, carbonTheme: carbonTheme, agentDisplayState: agentDisplayState} = this.props;
|
|
1919
|
+
const {fieldVisible: fieldVisible, files: files, allowFileUploads: allowFileUploads, allowedFileUploadTypes: allowedFileUploadTypes, allowMultipleFileUploads: allowMultipleFileUploads, stopStreamingButtonState: stopStreamingButtonState} = inputState;
|
|
1920
|
+
const {fileUploadInProgress: fileUploadInProgress} = agentState;
|
|
1921
|
+
const {inputPlaceholderKey: inputPlaceholderKey} = agentDisplayState;
|
|
1922
|
+
const numFiles = files?.length ?? 0;
|
|
1923
|
+
const anyCurrentFiles = numFiles > 0 || fileUploadInProgress;
|
|
1924
|
+
const showUploadButtonDisabled = anyCurrentFiles && !allowMultipleFileUploads;
|
|
1925
|
+
return React.createElement(React.Fragment, null, isHydrated && React.createElement("div", {
|
|
1926
|
+
className: "WACMessagesContainer__NonInputContainer"
|
|
1927
|
+
}, React.createElement(MessagesComponent$1, {
|
|
1928
|
+
ref: this.messagesRef,
|
|
1929
|
+
messageState: messageState,
|
|
1930
|
+
localMessageItems: this.messagesToArray(messageState.localMessageIDs, allMessageItemsByID),
|
|
1931
|
+
requestInputFocus: this.requestInputFocus,
|
|
1932
|
+
botName: botName,
|
|
1933
|
+
intl: intl,
|
|
1934
|
+
onEndAgentChat: this.showConfirmEndChat,
|
|
1935
|
+
locale: locale,
|
|
1936
|
+
useAITheme: useAITheme,
|
|
1937
|
+
carbonTheme: carbonTheme
|
|
1938
|
+
})), React.createElement(WriteableElement, {
|
|
1939
|
+
slotName: WriteableElementName.BEFORE_INPUT_ELEMENT,
|
|
1940
|
+
id: `beforeInputElement${serviceManager.namespace.suffix}`
|
|
1941
|
+
}), React.createElement(InputExport, {
|
|
1942
|
+
ref: this.inputRef,
|
|
1943
|
+
languagePack: languagePack,
|
|
1944
|
+
serviceManager: serviceManager,
|
|
1945
|
+
disableInput: this.shouldDisableInput(),
|
|
1946
|
+
disableSend: this.shouldDisableSend(),
|
|
1947
|
+
isInputVisible: fieldVisible,
|
|
1948
|
+
onSendInput: onSendInput,
|
|
1949
|
+
onUserTyping: onUserTyping,
|
|
1950
|
+
showUploadButton: allowFileUploads,
|
|
1951
|
+
disableUploadButton: showUploadButtonDisabled,
|
|
1952
|
+
allowedFileUploadTypes: allowedFileUploadTypes,
|
|
1953
|
+
allowMultipleFileUploads: allowMultipleFileUploads,
|
|
1954
|
+
pendingUploads: files,
|
|
1955
|
+
onFilesSelectedForUpload: this.onFilesSelectedForUpload,
|
|
1956
|
+
placeholder: languagePack[inputPlaceholderKey],
|
|
1957
|
+
isStopStreamingButtonVisible: stopStreamingButtonState.isVisible,
|
|
1958
|
+
isStopStreamingButtonDisabled: stopStreamingButtonState.isDisabled,
|
|
1959
|
+
testIdPrefix: OverlayPanelName.MAIN
|
|
1960
|
+
}), this.state.showEndChatConfirmation && React.createElement(EndAgentChatModal, {
|
|
1961
|
+
onConfirm: this.confirmAgentEndChat,
|
|
1962
|
+
onCancel: this.hideConfirmEndChat
|
|
1963
|
+
}), this.props.agentState.showScreenShareRequest && React.createElement(RequestScreenShareModal, null));
|
|
1964
|
+
}
|
|
1965
|
+
render() {
|
|
1966
|
+
const {languagePack: languagePack, onClose: onClose, onCloseAndRestart: onCloseAndRestart, onRestart: onRestart, onToggleHomeScreen: onToggleHomeScreen, botName: botName, headerDisplayName: headerDisplayName, headerAvatarConfig: headerAvatarConfig} = this.props;
|
|
1967
|
+
const {hasCaughtError: hasCaughtError} = this.state;
|
|
1968
|
+
const className = "WAC";
|
|
1969
|
+
return React.createElement("div", {
|
|
1970
|
+
className: className
|
|
1971
|
+
}, React.createElement(BotHeaderExport, {
|
|
1972
|
+
ref: this.headerRef,
|
|
1973
|
+
onClose: onClose,
|
|
1974
|
+
onCloseAndRestart: onCloseAndRestart,
|
|
1975
|
+
onRestart: onRestart,
|
|
1976
|
+
headerDisplayName: headerDisplayName,
|
|
1977
|
+
headerAvatarConfig: headerAvatarConfig,
|
|
1978
|
+
onToggleHomeScreen: onToggleHomeScreen,
|
|
1979
|
+
enableChatHeaderConfig: true,
|
|
1980
|
+
includeWriteableElement: true,
|
|
1981
|
+
testIdPrefix: OverlayPanelName.MAIN
|
|
1982
|
+
}), React.createElement(NonHeaderBackground, null), React.createElement("div", {
|
|
1983
|
+
className: "WACPanelContent WAC__ChatNonHeaderContainer"
|
|
1984
|
+
}, hasCaughtError && React.createElement("div", {
|
|
1985
|
+
className: "WAC__MessagesErrorHandler"
|
|
1986
|
+
}, React.createElement(CatastrophicErrorExport, {
|
|
1987
|
+
languagePack: languagePack,
|
|
1988
|
+
onRestart: onRestart,
|
|
1989
|
+
showHeader: false,
|
|
1990
|
+
botName: botName,
|
|
1991
|
+
headerDisplayName: headerDisplayName
|
|
1992
|
+
})), !hasCaughtError && React.createElement("div", {
|
|
1993
|
+
className: "WAC__messagesAndInputContainer"
|
|
1994
|
+
}, this.renderMessagesAndInput())));
|
|
1995
|
+
}
|
|
1996
|
+
}
|
|
1997
|
+
|
|
1998
|
+
function NonHeaderBackground() {
|
|
1999
|
+
const isVisible = useSelector(state => state.showNonHeaderBackgroundCover);
|
|
2000
|
+
return isVisible ? React.createElement("div", {
|
|
2001
|
+
className: "WACBackgroundCover WACBackgroundCover__NonHeader"
|
|
2002
|
+
}) : null;
|
|
2003
|
+
}
|
|
2004
|
+
|
|
2005
|
+
var Chat$1 = injectIntl(Chat, {
|
|
2006
|
+
forwardRef: true
|
|
2007
|
+
});
|
|
2008
|
+
|
|
2009
|
+
export { Chat as ChatClass, Chat$1 as default };
|