@athoscommerce/snap-preact 1.7.0 → 1.7.1-beta.129
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/cjs/components/src/components/Atoms/Button/Button.d.ts +1 -1
- package/dist/cjs/components/src/components/Atoms/Button/Button.d.ts.map +1 -1
- package/dist/cjs/components/src/components/Atoms/ChatLoadingIndicator/ChatLoadingIndicator.d.ts +7 -0
- package/dist/cjs/components/src/components/Atoms/ChatLoadingIndicator/ChatLoadingIndicator.d.ts.map +1 -0
- package/dist/cjs/components/src/components/Atoms/ChatLoadingIndicator/ChatLoadingIndicator.js +85 -0
- package/dist/cjs/components/src/components/Atoms/ChatLoadingIndicator/index.d.ts +2 -0
- package/dist/cjs/components/src/components/Atoms/ChatLoadingIndicator/index.d.ts.map +1 -0
- package/dist/cjs/components/src/components/Atoms/ChatLoadingIndicator/index.js +17 -0
- package/dist/cjs/components/src/components/Atoms/Dropdown/Dropdown.d.ts +4 -0
- package/dist/cjs/components/src/components/Atoms/Dropdown/Dropdown.d.ts.map +1 -1
- package/dist/cjs/components/src/components/Atoms/Dropdown/Dropdown.js +51 -14
- package/dist/cjs/components/src/components/Atoms/Icon/paths.d.ts +21 -0
- package/dist/cjs/components/src/components/Atoms/Icon/paths.d.ts.map +1 -1
- package/dist/cjs/components/src/components/Atoms/Icon/paths.js +21 -0
- package/dist/cjs/components/src/components/Molecules/CalloutBadge/CalloutBadge.js +3 -3
- package/dist/cjs/components/src/components/Molecules/ChatAttachmentContext/ChatAttachmentContext.d.ts +20 -0
- package/dist/cjs/components/src/components/Molecules/ChatAttachmentContext/ChatAttachmentContext.d.ts.map +1 -0
- package/dist/cjs/components/src/components/Molecules/ChatAttachmentContext/ChatAttachmentContext.js +187 -0
- package/dist/cjs/components/src/components/Molecules/ChatAttachmentContext/index.d.ts +2 -0
- package/dist/cjs/components/src/components/Molecules/ChatAttachmentContext/index.d.ts.map +1 -0
- package/dist/cjs/components/src/components/Molecules/ChatAttachmentContext/index.js +17 -0
- package/dist/cjs/components/src/components/Molecules/ChatInspirationResultMessage/ChatInspirationResultMessage.d.ts +18 -0
- package/dist/cjs/components/src/components/Molecules/ChatInspirationResultMessage/ChatInspirationResultMessage.d.ts.map +1 -0
- package/dist/cjs/components/src/components/Molecules/ChatInspirationResultMessage/ChatInspirationResultMessage.js +175 -0
- package/dist/cjs/components/src/components/Molecules/ChatInspirationResultMessage/index.d.ts +2 -0
- package/dist/cjs/components/src/components/Molecules/ChatInspirationResultMessage/index.d.ts.map +1 -0
- package/dist/cjs/components/src/components/Molecules/ChatInspirationResultMessage/index.js +17 -0
- package/dist/cjs/components/src/components/Molecules/ChatMessageText/ChatMessageText.d.ts +21 -0
- package/dist/cjs/components/src/components/Molecules/ChatMessageText/ChatMessageText.d.ts.map +1 -0
- package/dist/cjs/components/src/components/Molecules/ChatMessageText/ChatMessageText.js +211 -0
- package/dist/cjs/components/src/components/Molecules/ChatMessageText/index.d.ts +2 -0
- package/dist/cjs/components/src/components/Molecules/ChatMessageText/index.d.ts.map +1 -0
- package/dist/cjs/components/src/components/Molecules/ChatMessageText/index.js +17 -0
- package/dist/cjs/components/src/components/Molecules/ChatMessageUser/ChatMessageUser.d.ts +16 -0
- package/dist/cjs/components/src/components/Molecules/ChatMessageUser/ChatMessageUser.d.ts.map +1 -0
- package/dist/cjs/components/src/components/Molecules/ChatMessageUser/ChatMessageUser.js +255 -0
- package/dist/cjs/components/src/components/Molecules/ChatMessageUser/index.d.ts +2 -0
- package/dist/cjs/components/src/components/Molecules/ChatMessageUser/index.d.ts.map +1 -0
- package/dist/cjs/components/src/components/Molecules/ChatMessageUser/index.js +17 -0
- package/dist/cjs/components/src/components/Molecules/ChatProductComparisonMessage/ChatProductComparisonMessage.d.ts +17 -0
- package/dist/cjs/components/src/components/Molecules/ChatProductComparisonMessage/ChatProductComparisonMessage.d.ts.map +1 -0
- package/dist/cjs/components/src/components/Molecules/ChatProductComparisonMessage/ChatProductComparisonMessage.js +143 -0
- package/dist/cjs/components/src/components/Molecules/ChatProductComparisonMessage/index.d.ts +2 -0
- package/dist/cjs/components/src/components/Molecules/ChatProductComparisonMessage/index.d.ts.map +1 -0
- package/dist/cjs/components/src/components/Molecules/ChatProductComparisonMessage/index.js +17 -0
- package/dist/cjs/components/src/components/Molecules/ChatProductQueryMessage/ChatProductQueryMessage.d.ts +25 -0
- package/dist/cjs/components/src/components/Molecules/ChatProductQueryMessage/ChatProductQueryMessage.d.ts.map +1 -0
- package/dist/cjs/components/src/components/Molecules/ChatProductQueryMessage/ChatProductQueryMessage.js +487 -0
- package/dist/cjs/components/src/components/Molecules/ChatProductQueryMessage/index.d.ts +2 -0
- package/dist/cjs/components/src/components/Molecules/ChatProductQueryMessage/index.d.ts.map +1 -0
- package/dist/cjs/components/src/components/Molecules/ChatProductQueryMessage/index.js +17 -0
- package/dist/cjs/components/src/components/Molecules/ChatResult/ChatResult.d.ts +11 -0
- package/dist/cjs/components/src/components/Molecules/ChatResult/ChatResult.d.ts.map +1 -0
- package/dist/cjs/components/src/components/Molecules/ChatResult/ChatResult.js +200 -0
- package/dist/cjs/components/src/components/Molecules/ChatResult/index.d.ts +2 -0
- package/dist/cjs/components/src/components/Molecules/ChatResult/index.d.ts.map +1 -0
- package/dist/cjs/components/src/components/Molecules/ChatResult/index.js +17 -0
- package/dist/cjs/components/src/components/Molecules/ChatResultsDisplay/ChatResultsDisplay.d.ts +12 -0
- package/dist/cjs/components/src/components/Molecules/ChatResultsDisplay/ChatResultsDisplay.d.ts.map +1 -0
- package/dist/cjs/components/src/components/Molecules/ChatResultsDisplay/ChatResultsDisplay.js +123 -0
- package/dist/cjs/components/src/components/Molecules/ChatResultsDisplay/index.d.ts +2 -0
- package/dist/cjs/components/src/components/Molecules/ChatResultsDisplay/index.d.ts.map +1 -0
- package/dist/cjs/components/src/components/Molecules/ChatResultsDisplay/index.js +17 -0
- package/dist/cjs/components/src/components/Molecules/ChatSuggestedQuestions/ChatSuggestedQuestions.d.ts +15 -0
- package/dist/cjs/components/src/components/Molecules/ChatSuggestedQuestions/ChatSuggestedQuestions.d.ts.map +1 -0
- package/dist/cjs/components/src/components/Molecules/ChatSuggestedQuestions/ChatSuggestedQuestions.js +99 -0
- package/dist/cjs/components/src/components/Molecules/ChatSuggestedQuestions/index.d.ts +2 -0
- package/dist/cjs/components/src/components/Molecules/ChatSuggestedQuestions/index.d.ts.map +1 -0
- package/dist/cjs/components/src/components/Molecules/ChatSuggestedQuestions/index.js +17 -0
- package/dist/cjs/components/src/components/Molecules/OverlayBadge/OverlayBadge.js +2 -2
- package/dist/cjs/components/src/components/Molecules/Result/Result.d.ts +5 -3
- package/dist/cjs/components/src/components/Molecules/Result/Result.d.ts.map +1 -1
- package/dist/cjs/components/src/components/Molecules/Result/Result.js +15 -9
- package/dist/cjs/components/src/components/Molecules/SearchInput/SearchInput.d.ts +2 -0
- package/dist/cjs/components/src/components/Molecules/SearchInput/SearchInput.d.ts.map +1 -1
- package/dist/cjs/components/src/components/Molecules/SearchInput/SearchInput.js +19 -2
- package/dist/cjs/components/src/components/Molecules/Slideout/Slideout.d.ts.map +1 -1
- package/dist/cjs/components/src/components/Molecules/Slideout/Slideout.js +21 -26
- package/dist/cjs/components/src/components/Molecules/Slideshow/Slideshow.d.ts.map +1 -1
- package/dist/cjs/components/src/components/Molecules/Slideshow/Slideshow.js +5 -1
- package/dist/cjs/components/src/components/Organisms/Chat/Chat.d.ts +30 -0
- package/dist/cjs/components/src/components/Organisms/Chat/Chat.d.ts.map +1 -0
- package/dist/cjs/components/src/components/Organisms/Chat/Chat.js +1047 -0
- package/dist/cjs/components/src/components/Organisms/Chat/Chat.styles.d.ts +16 -0
- package/dist/cjs/components/src/components/Organisms/Chat/Chat.styles.d.ts.map +1 -0
- package/dist/cjs/components/src/components/Organisms/Chat/Chat.styles.js +1186 -0
- package/dist/cjs/components/src/components/Organisms/Chat/hooks/useChatFileUpload.d.ts +32 -0
- package/dist/cjs/components/src/components/Organisms/Chat/hooks/useChatFileUpload.d.ts.map +1 -0
- package/dist/cjs/components/src/components/Organisms/Chat/hooks/useChatFileUpload.js +104 -0
- package/dist/cjs/components/src/components/Organisms/Chat/hooks/useChatGestures.d.ts +40 -0
- package/dist/cjs/components/src/components/Organisms/Chat/hooks/useChatGestures.d.ts.map +1 -0
- package/dist/cjs/components/src/components/Organisms/Chat/hooks/useChatGestures.js +98 -0
- package/dist/cjs/components/src/components/Organisms/Chat/hooks/useChatOverflow.d.ts +44 -0
- package/dist/cjs/components/src/components/Organisms/Chat/hooks/useChatOverflow.d.ts.map +1 -0
- package/dist/cjs/components/src/components/Organisms/Chat/hooks/useChatOverflow.js +116 -0
- package/dist/cjs/components/src/components/Organisms/Chat/index.d.ts +2 -0
- package/dist/cjs/components/src/components/Organisms/Chat/index.d.ts.map +1 -0
- package/dist/cjs/components/src/components/Organisms/Chat/index.js +17 -0
- package/dist/cjs/components/src/components/Organisms/Facet/Facet.js +2 -1
- package/dist/cjs/components/src/components/Organisms/FacetsHorizontal/FacetsHorizontal.js +2 -1
- package/dist/cjs/components/src/components/Organisms/Results/Results.js +1 -1
- package/dist/cjs/components/src/components/Templates/AutocompleteFixed/AutocompleteFixed.d.ts +1 -1
- package/dist/cjs/components/src/components/Templates/AutocompleteFixed/AutocompleteFixed.d.ts.map +1 -1
- package/dist/cjs/components/src/components/Templates/AutocompleteFixed/AutocompleteFixed.js +3 -1
- package/dist/cjs/components/src/components/Templates/AutocompleteModal/AutocompleteModal.d.ts +1 -1
- package/dist/cjs/components/src/components/Templates/AutocompleteModal/AutocompleteModal.d.ts.map +1 -1
- package/dist/cjs/components/src/components/Templates/AutocompleteModal/AutocompleteModal.js +3 -1
- package/dist/cjs/components/src/components/Templates/AutocompleteSlideout/AutocompleteSlideout.d.ts +1 -1
- package/dist/cjs/components/src/components/Templates/AutocompleteSlideout/AutocompleteSlideout.d.ts.map +1 -1
- package/dist/cjs/components/src/components/Templates/AutocompleteSlideout/AutocompleteSlideout.js +3 -1
- package/dist/cjs/components/src/components/Templates/Chat/Chat.d.ts +12 -0
- package/dist/cjs/components/src/components/Templates/Chat/Chat.d.ts.map +1 -0
- package/dist/cjs/components/src/components/Templates/Chat/Chat.js +55 -0
- package/dist/cjs/components/src/components/Templates/Chat/index.d.ts +2 -0
- package/dist/cjs/components/src/components/Templates/Chat/index.d.ts.map +1 -0
- package/dist/cjs/components/src/components/Templates/Chat/index.js +17 -0
- package/dist/cjs/components/src/index.d.ts +11 -0
- package/dist/cjs/components/src/index.d.ts.map +1 -1
- package/dist/cjs/components/src/index.js +13 -1
- package/dist/cjs/components/src/providers/withTracking.d.ts +2 -2
- package/dist/cjs/components/src/providers/withTracking.d.ts.map +1 -1
- package/dist/cjs/components/src/setupTests.js +17 -0
- package/dist/cjs/components/src/themes/base/components/templates/chat.d.ts +4 -0
- package/dist/cjs/components/src/themes/base/components/templates/chat.d.ts.map +1 -0
- package/dist/cjs/components/src/themes/base/components/templates/chat.js +6 -0
- package/dist/cjs/components/src/themes/base/components/templates/index.d.ts.map +1 -1
- package/dist/cjs/components/src/themes/base/components/templates/index.js +5 -4
- package/dist/cjs/components/src/themes/bocachica/components/templates/chat.d.ts +4 -0
- package/dist/cjs/components/src/themes/bocachica/components/templates/chat.d.ts.map +1 -0
- package/dist/cjs/components/src/themes/bocachica/components/templates/chat.js +6 -0
- package/dist/cjs/components/src/themes/bocachica/components/templates/index.d.ts.map +1 -1
- package/dist/cjs/components/src/themes/bocachica/components/templates/index.js +5 -4
- package/dist/cjs/components/src/themes/pike/components/templates/chat.d.ts +4 -0
- package/dist/cjs/components/src/themes/pike/components/templates/chat.d.ts.map +1 -0
- package/dist/cjs/components/src/themes/pike/components/templates/chat.js +6 -0
- package/dist/cjs/components/src/themes/pike/components/templates/index.d.ts.map +1 -1
- package/dist/cjs/components/src/themes/pike/components/templates/index.js +5 -4
- package/dist/cjs/components/src/themes/snapnco/components/templates/chat.d.ts +4 -0
- package/dist/cjs/components/src/themes/snapnco/components/templates/chat.d.ts.map +1 -0
- package/dist/cjs/components/src/themes/snapnco/components/templates/chat.js +6 -0
- package/dist/cjs/components/src/themes/snapnco/components/templates/index.d.ts.map +1 -1
- package/dist/cjs/components/src/themes/snapnco/components/templates/index.js +5 -4
- package/dist/cjs/components/src/themes/snappy/components/templates/chat.d.ts +4 -0
- package/dist/cjs/components/src/themes/snappy/components/templates/chat.d.ts.map +1 -0
- package/dist/cjs/components/src/themes/snappy/components/templates/chat.js +6 -0
- package/dist/cjs/components/src/themes/snappy/components/templates/index.d.ts.map +1 -1
- package/dist/cjs/components/src/themes/snappy/components/templates/index.js +5 -4
- package/dist/cjs/components/src/themes/themeComponents/chat.d.ts +4 -0
- package/dist/cjs/components/src/themes/themeComponents/chat.d.ts.map +1 -0
- package/dist/cjs/components/src/themes/themeComponents/chat.js +14 -0
- package/dist/cjs/components/src/utilities/Colour/Colour.d.ts +11 -0
- package/dist/cjs/components/src/utilities/Colour/Colour.d.ts.map +1 -1
- package/dist/cjs/components/src/utilities/Colour/Colour.js +32 -0
- package/dist/cjs/components/src/utilities/snapify.d.ts +3 -2
- package/dist/cjs/components/src/utilities/snapify.d.ts.map +1 -1
- package/dist/cjs/components/src/utilities/snapify.js +48 -0
- package/dist/cjs/src/Snap.d.ts +2 -1
- package/dist/cjs/src/Snap.d.ts.map +1 -1
- package/dist/cjs/src/Snap.js +134 -24
- package/dist/cjs/src/Templates/SnapTemplates.d.ts +2 -1
- package/dist/cjs/src/Templates/SnapTemplates.d.ts.map +1 -1
- package/dist/cjs/src/Templates/SnapTemplates.js +67 -5
- package/dist/cjs/src/Templates/Stores/LibraryStore.d.ts +2 -0
- package/dist/cjs/src/Templates/Stores/LibraryStore.d.ts.map +1 -1
- package/dist/cjs/src/Templates/Stores/LibraryStore.js +19 -0
- package/dist/cjs/src/Templates/Stores/TemplateStore.d.ts +19 -4
- package/dist/cjs/src/Templates/Stores/TemplateStore.d.ts.map +1 -1
- package/dist/cjs/src/Templates/Stores/TemplateStore.js +2 -1
- package/dist/cjs/src/Templates/Stores/library/components/Chat.d.ts +2 -0
- package/dist/cjs/src/Templates/Stores/library/components/Chat.d.ts.map +1 -0
- package/dist/cjs/src/Templates/Stores/library/components/Chat.js +5 -0
- package/dist/cjs/src/Templates/Stores/library/languages/es.d.ts.map +1 -1
- package/dist/cjs/src/Templates/Stores/library/languages/es.js +5 -0
- package/dist/cjs/src/Templates/Stores/library/languages/fr.d.ts.map +1 -1
- package/dist/cjs/src/Templates/Stores/library/languages/fr.js +5 -0
- package/dist/cjs/src/create/createChatController.d.ts +5 -0
- package/dist/cjs/src/create/createChatController.d.ts.map +1 -0
- package/dist/cjs/src/create/createChatController.js +43 -0
- package/dist/cjs/src/setupEvents.d.ts +13 -0
- package/dist/cjs/src/setupEvents.d.ts.map +1 -1
- package/dist/cjs/src/setupEvents.js +87 -0
- package/dist/cjs/src/types.d.ts +15 -3
- package/dist/cjs/src/types.d.ts.map +1 -1
- package/dist/esm/components/src/components/Atoms/Button/Button.d.ts +1 -1
- package/dist/esm/components/src/components/Atoms/Button/Button.d.ts.map +1 -1
- package/dist/esm/components/src/components/Atoms/ChatLoadingIndicator/ChatLoadingIndicator.d.ts +7 -0
- package/dist/esm/components/src/components/Atoms/ChatLoadingIndicator/ChatLoadingIndicator.d.ts.map +1 -0
- package/dist/esm/components/src/components/Atoms/ChatLoadingIndicator/ChatLoadingIndicator.js +67 -0
- package/dist/esm/components/src/components/Atoms/ChatLoadingIndicator/index.d.ts +2 -0
- package/dist/esm/components/src/components/Atoms/ChatLoadingIndicator/index.d.ts.map +1 -0
- package/dist/esm/components/src/components/Atoms/ChatLoadingIndicator/index.js +1 -0
- package/dist/esm/components/src/components/Atoms/Dropdown/Dropdown.d.ts +4 -0
- package/dist/esm/components/src/components/Atoms/Dropdown/Dropdown.d.ts.map +1 -1
- package/dist/esm/components/src/components/Atoms/Dropdown/Dropdown.js +53 -11
- package/dist/esm/components/src/components/Atoms/Icon/paths.d.ts +21 -0
- package/dist/esm/components/src/components/Atoms/Icon/paths.d.ts.map +1 -1
- package/dist/esm/components/src/components/Atoms/Icon/paths.js +21 -0
- package/dist/esm/components/src/components/Molecules/CalloutBadge/CalloutBadge.js +1 -1
- package/dist/esm/components/src/components/Molecules/ChatAttachmentContext/ChatAttachmentContext.d.ts +20 -0
- package/dist/esm/components/src/components/Molecules/ChatAttachmentContext/ChatAttachmentContext.d.ts.map +1 -0
- package/dist/esm/components/src/components/Molecules/ChatAttachmentContext/ChatAttachmentContext.js +169 -0
- package/dist/esm/components/src/components/Molecules/ChatAttachmentContext/index.d.ts +2 -0
- package/dist/esm/components/src/components/Molecules/ChatAttachmentContext/index.d.ts.map +1 -0
- package/dist/esm/components/src/components/Molecules/ChatAttachmentContext/index.js +1 -0
- package/dist/esm/components/src/components/Molecules/ChatInspirationResultMessage/ChatInspirationResultMessage.d.ts +18 -0
- package/dist/esm/components/src/components/Molecules/ChatInspirationResultMessage/ChatInspirationResultMessage.d.ts.map +1 -0
- package/dist/esm/components/src/components/Molecules/ChatInspirationResultMessage/ChatInspirationResultMessage.js +170 -0
- package/dist/esm/components/src/components/Molecules/ChatInspirationResultMessage/index.d.ts +2 -0
- package/dist/esm/components/src/components/Molecules/ChatInspirationResultMessage/index.d.ts.map +1 -0
- package/dist/esm/components/src/components/Molecules/ChatInspirationResultMessage/index.js +1 -0
- package/dist/esm/components/src/components/Molecules/ChatMessageText/ChatMessageText.d.ts +21 -0
- package/dist/esm/components/src/components/Molecules/ChatMessageText/ChatMessageText.d.ts.map +1 -0
- package/dist/esm/components/src/components/Molecules/ChatMessageText/ChatMessageText.js +192 -0
- package/dist/esm/components/src/components/Molecules/ChatMessageText/index.d.ts +2 -0
- package/dist/esm/components/src/components/Molecules/ChatMessageText/index.d.ts.map +1 -0
- package/dist/esm/components/src/components/Molecules/ChatMessageText/index.js +1 -0
- package/dist/esm/components/src/components/Molecules/ChatMessageUser/ChatMessageUser.d.ts +16 -0
- package/dist/esm/components/src/components/Molecules/ChatMessageUser/ChatMessageUser.d.ts.map +1 -0
- package/dist/esm/components/src/components/Molecules/ChatMessageUser/ChatMessageUser.js +223 -0
- package/dist/esm/components/src/components/Molecules/ChatMessageUser/index.d.ts +2 -0
- package/dist/esm/components/src/components/Molecules/ChatMessageUser/index.d.ts.map +1 -0
- package/dist/esm/components/src/components/Molecules/ChatMessageUser/index.js +1 -0
- package/dist/esm/components/src/components/Molecules/ChatProductComparisonMessage/ChatProductComparisonMessage.d.ts +17 -0
- package/dist/esm/components/src/components/Molecules/ChatProductComparisonMessage/ChatProductComparisonMessage.d.ts.map +1 -0
- package/dist/esm/components/src/components/Molecules/ChatProductComparisonMessage/ChatProductComparisonMessage.js +121 -0
- package/dist/esm/components/src/components/Molecules/ChatProductComparisonMessage/index.d.ts +2 -0
- package/dist/esm/components/src/components/Molecules/ChatProductComparisonMessage/index.d.ts.map +1 -0
- package/dist/esm/components/src/components/Molecules/ChatProductComparisonMessage/index.js +1 -0
- package/dist/esm/components/src/components/Molecules/ChatProductQueryMessage/ChatProductQueryMessage.d.ts +25 -0
- package/dist/esm/components/src/components/Molecules/ChatProductQueryMessage/ChatProductQueryMessage.d.ts.map +1 -0
- package/dist/esm/components/src/components/Molecules/ChatProductQueryMessage/ChatProductQueryMessage.js +460 -0
- package/dist/esm/components/src/components/Molecules/ChatProductQueryMessage/index.d.ts +2 -0
- package/dist/esm/components/src/components/Molecules/ChatProductQueryMessage/index.d.ts.map +1 -0
- package/dist/esm/components/src/components/Molecules/ChatProductQueryMessage/index.js +1 -0
- package/dist/esm/components/src/components/Molecules/ChatResult/ChatResult.d.ts +11 -0
- package/dist/esm/components/src/components/Molecules/ChatResult/ChatResult.d.ts.map +1 -0
- package/dist/esm/components/src/components/Molecules/ChatResult/ChatResult.js +184 -0
- package/dist/esm/components/src/components/Molecules/ChatResult/index.d.ts +2 -0
- package/dist/esm/components/src/components/Molecules/ChatResult/index.d.ts.map +1 -0
- package/dist/esm/components/src/components/Molecules/ChatResult/index.js +1 -0
- package/dist/esm/components/src/components/Molecules/ChatResultsDisplay/ChatResultsDisplay.d.ts +12 -0
- package/dist/esm/components/src/components/Molecules/ChatResultsDisplay/ChatResultsDisplay.d.ts.map +1 -0
- package/dist/esm/components/src/components/Molecules/ChatResultsDisplay/ChatResultsDisplay.js +102 -0
- package/dist/esm/components/src/components/Molecules/ChatResultsDisplay/index.d.ts +2 -0
- package/dist/esm/components/src/components/Molecules/ChatResultsDisplay/index.d.ts.map +1 -0
- package/dist/esm/components/src/components/Molecules/ChatResultsDisplay/index.js +1 -0
- package/dist/esm/components/src/components/Molecules/ChatSuggestedQuestions/ChatSuggestedQuestions.d.ts +15 -0
- package/dist/esm/components/src/components/Molecules/ChatSuggestedQuestions/ChatSuggestedQuestions.d.ts.map +1 -0
- package/dist/esm/components/src/components/Molecules/ChatSuggestedQuestions/ChatSuggestedQuestions.js +80 -0
- package/dist/esm/components/src/components/Molecules/ChatSuggestedQuestions/index.d.ts +2 -0
- package/dist/esm/components/src/components/Molecules/ChatSuggestedQuestions/index.d.ts.map +1 -0
- package/dist/esm/components/src/components/Molecules/ChatSuggestedQuestions/index.js +1 -0
- package/dist/esm/components/src/components/Molecules/OverlayBadge/OverlayBadge.js +1 -1
- package/dist/esm/components/src/components/Molecules/Result/Result.d.ts +5 -3
- package/dist/esm/components/src/components/Molecules/Result/Result.d.ts.map +1 -1
- package/dist/esm/components/src/components/Molecules/Result/Result.js +12 -7
- package/dist/esm/components/src/components/Molecules/SearchInput/SearchInput.d.ts +2 -0
- package/dist/esm/components/src/components/Molecules/SearchInput/SearchInput.d.ts.map +1 -1
- package/dist/esm/components/src/components/Molecules/SearchInput/SearchInput.js +35 -2
- package/dist/esm/components/src/components/Molecules/Slideout/Slideout.d.ts.map +1 -1
- package/dist/esm/components/src/components/Molecules/Slideout/Slideout.js +22 -27
- package/dist/esm/components/src/components/Molecules/Slideshow/Slideshow.d.ts.map +1 -1
- package/dist/esm/components/src/components/Molecules/Slideshow/Slideshow.js +5 -1
- package/dist/esm/components/src/components/Organisms/Chat/Chat.d.ts +30 -0
- package/dist/esm/components/src/components/Organisms/Chat/Chat.d.ts.map +1 -0
- package/dist/esm/components/src/components/Organisms/Chat/Chat.js +956 -0
- package/dist/esm/components/src/components/Organisms/Chat/Chat.styles.d.ts +16 -0
- package/dist/esm/components/src/components/Organisms/Chat/Chat.styles.d.ts.map +1 -0
- package/dist/esm/components/src/components/Organisms/Chat/Chat.styles.js +1227 -0
- package/dist/esm/components/src/components/Organisms/Chat/hooks/useChatFileUpload.d.ts +32 -0
- package/dist/esm/components/src/components/Organisms/Chat/hooks/useChatFileUpload.d.ts.map +1 -0
- package/dist/esm/components/src/components/Organisms/Chat/hooks/useChatFileUpload.js +54 -0
- package/dist/esm/components/src/components/Organisms/Chat/hooks/useChatGestures.d.ts +40 -0
- package/dist/esm/components/src/components/Organisms/Chat/hooks/useChatGestures.d.ts.map +1 -0
- package/dist/esm/components/src/components/Organisms/Chat/hooks/useChatGestures.js +92 -0
- package/dist/esm/components/src/components/Organisms/Chat/hooks/useChatOverflow.d.ts +44 -0
- package/dist/esm/components/src/components/Organisms/Chat/hooks/useChatOverflow.d.ts.map +1 -0
- package/dist/esm/components/src/components/Organisms/Chat/hooks/useChatOverflow.js +110 -0
- package/dist/esm/components/src/components/Organisms/Chat/index.d.ts +2 -0
- package/dist/esm/components/src/components/Organisms/Chat/index.d.ts.map +1 -0
- package/dist/esm/components/src/components/Organisms/Chat/index.js +1 -0
- package/dist/esm/components/src/components/Organisms/Facet/Facet.js +1 -1
- package/dist/esm/components/src/components/Organisms/FacetsHorizontal/FacetsHorizontal.js +1 -1
- package/dist/esm/components/src/components/Organisms/Results/Results.js +1 -1
- package/dist/esm/components/src/components/Templates/AutocompleteFixed/AutocompleteFixed.d.ts +1 -1
- package/dist/esm/components/src/components/Templates/AutocompleteFixed/AutocompleteFixed.d.ts.map +1 -1
- package/dist/esm/components/src/components/Templates/AutocompleteFixed/AutocompleteFixed.js +4 -1
- package/dist/esm/components/src/components/Templates/AutocompleteModal/AutocompleteModal.d.ts +1 -1
- package/dist/esm/components/src/components/Templates/AutocompleteModal/AutocompleteModal.d.ts.map +1 -1
- package/dist/esm/components/src/components/Templates/AutocompleteModal/AutocompleteModal.js +4 -1
- package/dist/esm/components/src/components/Templates/AutocompleteSlideout/AutocompleteSlideout.d.ts +1 -1
- package/dist/esm/components/src/components/Templates/AutocompleteSlideout/AutocompleteSlideout.d.ts.map +1 -1
- package/dist/esm/components/src/components/Templates/AutocompleteSlideout/AutocompleteSlideout.js +4 -1
- package/dist/esm/components/src/components/Templates/Chat/Chat.d.ts +12 -0
- package/dist/esm/components/src/components/Templates/Chat/Chat.d.ts.map +1 -0
- package/dist/esm/components/src/components/Templates/Chat/Chat.js +42 -0
- package/dist/esm/components/src/components/Templates/Chat/index.d.ts +2 -0
- package/dist/esm/components/src/components/Templates/Chat/index.d.ts.map +1 -0
- package/dist/esm/components/src/components/Templates/Chat/index.js +1 -0
- package/dist/esm/components/src/index.d.ts +11 -0
- package/dist/esm/components/src/index.d.ts.map +1 -1
- package/dist/esm/components/src/index.js +11 -0
- package/dist/esm/components/src/providers/withTracking.d.ts +2 -2
- package/dist/esm/components/src/providers/withTracking.d.ts.map +1 -1
- package/dist/esm/components/src/setupTests.js +14 -0
- package/dist/esm/components/src/themes/base/components/templates/chat.d.ts +4 -0
- package/dist/esm/components/src/themes/base/components/templates/chat.d.ts.map +1 -0
- package/dist/esm/components/src/themes/base/components/templates/chat.js +3 -0
- package/dist/esm/components/src/themes/base/components/templates/index.d.ts.map +1 -1
- package/dist/esm/components/src/themes/base/components/templates/index.js +5 -0
- package/dist/esm/components/src/themes/bocachica/components/templates/chat.d.ts +4 -0
- package/dist/esm/components/src/themes/bocachica/components/templates/chat.d.ts.map +1 -0
- package/dist/esm/components/src/themes/bocachica/components/templates/chat.js +3 -0
- package/dist/esm/components/src/themes/bocachica/components/templates/index.d.ts.map +1 -1
- package/dist/esm/components/src/themes/bocachica/components/templates/index.js +5 -0
- package/dist/esm/components/src/themes/pike/components/templates/chat.d.ts +4 -0
- package/dist/esm/components/src/themes/pike/components/templates/chat.d.ts.map +1 -0
- package/dist/esm/components/src/themes/pike/components/templates/chat.js +3 -0
- package/dist/esm/components/src/themes/pike/components/templates/index.d.ts.map +1 -1
- package/dist/esm/components/src/themes/pike/components/templates/index.js +5 -0
- package/dist/esm/components/src/themes/snapnco/components/templates/chat.d.ts +4 -0
- package/dist/esm/components/src/themes/snapnco/components/templates/chat.d.ts.map +1 -0
- package/dist/esm/components/src/themes/snapnco/components/templates/chat.js +3 -0
- package/dist/esm/components/src/themes/snapnco/components/templates/index.d.ts.map +1 -1
- package/dist/esm/components/src/themes/snapnco/components/templates/index.js +5 -0
- package/dist/esm/components/src/themes/snappy/components/templates/chat.d.ts +4 -0
- package/dist/esm/components/src/themes/snappy/components/templates/chat.d.ts.map +1 -0
- package/dist/esm/components/src/themes/snappy/components/templates/chat.js +3 -0
- package/dist/esm/components/src/themes/snappy/components/templates/index.d.ts.map +1 -1
- package/dist/esm/components/src/themes/snappy/components/templates/index.js +5 -0
- package/dist/esm/components/src/themes/themeComponents/chat.d.ts +4 -0
- package/dist/esm/components/src/themes/themeComponents/chat.d.ts.map +1 -0
- package/dist/esm/components/src/themes/themeComponents/chat.js +11 -0
- package/dist/esm/components/src/utilities/Colour/Colour.d.ts +11 -0
- package/dist/esm/components/src/utilities/Colour/Colour.d.ts.map +1 -1
- package/dist/esm/components/src/utilities/Colour/Colour.js +30 -0
- package/dist/esm/components/src/utilities/snapify.d.ts +3 -2
- package/dist/esm/components/src/utilities/snapify.d.ts.map +1 -1
- package/dist/esm/components/src/utilities/snapify.js +29 -2
- package/dist/esm/src/Snap.d.ts +2 -1
- package/dist/esm/src/Snap.d.ts.map +1 -1
- package/dist/esm/src/Snap.js +72 -0
- package/dist/esm/src/Templates/SnapTemplates.d.ts +2 -1
- package/dist/esm/src/Templates/SnapTemplates.d.ts.map +1 -1
- package/dist/esm/src/Templates/SnapTemplates.js +55 -0
- package/dist/esm/src/Templates/Stores/LibraryStore.d.ts +2 -0
- package/dist/esm/src/Templates/Stores/LibraryStore.d.ts.map +1 -1
- package/dist/esm/src/Templates/Stores/LibraryStore.js +6 -0
- package/dist/esm/src/Templates/Stores/TemplateStore.d.ts +19 -4
- package/dist/esm/src/Templates/Stores/TemplateStore.d.ts.map +1 -1
- package/dist/esm/src/Templates/Stores/TemplateStore.js +2 -1
- package/dist/esm/src/Templates/Stores/library/components/Chat.d.ts +2 -0
- package/dist/esm/src/Templates/Stores/library/components/Chat.d.ts.map +1 -0
- package/dist/esm/src/Templates/Stores/library/components/Chat.js +1 -0
- package/dist/esm/src/Templates/Stores/library/languages/es.d.ts.map +1 -1
- package/dist/esm/src/Templates/Stores/library/languages/es.js +5 -0
- package/dist/esm/src/Templates/Stores/library/languages/fr.d.ts.map +1 -1
- package/dist/esm/src/Templates/Stores/library/languages/fr.js +5 -0
- package/dist/esm/src/create/createChatController.d.ts +5 -0
- package/dist/esm/src/create/createChatController.d.ts.map +1 -0
- package/dist/esm/src/create/createChatController.js +29 -0
- package/dist/esm/src/setupEvents.d.ts +13 -0
- package/dist/esm/src/setupEvents.d.ts.map +1 -1
- package/dist/esm/src/setupEvents.js +40 -0
- package/dist/esm/src/types.d.ts +15 -3
- package/dist/esm/src/types.d.ts.map +1 -1
- package/package.json +14 -12
|
@@ -0,0 +1,1047 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
24
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
50
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
51
|
+
if (ar || !(i in from)) {
|
|
52
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
53
|
+
ar[i] = from[i];
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
57
|
+
};
|
|
58
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
59
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
60
|
+
};
|
|
61
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
62
|
+
exports.ChatOrganism = void 0;
|
|
63
|
+
var jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
64
|
+
var classnames_1 = __importDefault(require("classnames"));
|
|
65
|
+
var deepmerge_1 = __importDefault(require("deepmerge"));
|
|
66
|
+
var mobx_react_lite_1 = require("mobx-react-lite");
|
|
67
|
+
var providers_1 = require("../../../providers");
|
|
68
|
+
var utilities_1 = require("../../../utilities");
|
|
69
|
+
var Chat_styles_1 = require("./Chat.styles");
|
|
70
|
+
var useChatGestures_1 = require("./hooks/useChatGestures");
|
|
71
|
+
var useChatOverflow_1 = require("./hooks/useChatOverflow");
|
|
72
|
+
var useChatFileUpload_1 = require("./hooks/useChatFileUpload");
|
|
73
|
+
var Button_1 = require("../../Atoms/Button");
|
|
74
|
+
var hooks_1 = require("preact/hooks");
|
|
75
|
+
var ChatMessageUser_1 = require("../../Molecules/ChatMessageUser");
|
|
76
|
+
var ChatMessageText_1 = require("../../Molecules/ChatMessageText");
|
|
77
|
+
var ChatSuggestedQuestions_1 = require("../../Molecules/ChatSuggestedQuestions");
|
|
78
|
+
var ChatAttachmentContext_1 = require("../../Molecules/ChatAttachmentContext");
|
|
79
|
+
var Image_1 = require("../../Atoms/Image");
|
|
80
|
+
var ChatLoadingIndicator_1 = require("../../Atoms/ChatLoadingIndicator");
|
|
81
|
+
var __1 = require("../../..");
|
|
82
|
+
var ChatInspirationResultMessage_1 = require("../../Molecules/ChatInspirationResultMessage");
|
|
83
|
+
var ChatProductComparisonMessage_1 = require("../../Molecules/ChatProductComparisonMessage/ChatProductComparisonMessage");
|
|
84
|
+
var ChatProductQueryMessage_1 = require("../../Molecules/ChatProductQueryMessage/ChatProductQueryMessage");
|
|
85
|
+
// Fallback footer copy when chat becomes disabled mid-session and store.error has
|
|
86
|
+
// been cleared (e.g. by createChat) — mirrors the controller's unavailable message.
|
|
87
|
+
var CHAT_UNAVAILABLE_MESSAGE = 'Service is temporarily unavailable. In the meantime, feel free to use the search bar above to find what you need!';
|
|
88
|
+
exports.ChatOrganism = (0, mobx_react_lite_1.observer)(function (properties) {
|
|
89
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
|
|
90
|
+
var globalTheme = (0, providers_1.useTheme)();
|
|
91
|
+
var globalTreePath = (0, providers_1.useTreePath)();
|
|
92
|
+
var isMobile = (0, __1.useMediaQuery)('(max-width: 767px)');
|
|
93
|
+
var defaultProps = {
|
|
94
|
+
treePath: globalTreePath,
|
|
95
|
+
logo: 'https://cdn.athoscommerce.net/snap/images/Athos%20Commerce_Icon_white.svg',
|
|
96
|
+
title: 'Athos Conversational Assistant',
|
|
97
|
+
subtitle: 'Your Guided Discovery Expert',
|
|
98
|
+
multiselectFacets: false,
|
|
99
|
+
disableBubbleSuggestedQuestions: isMobile ? true : false,
|
|
100
|
+
primaryColorBg: '#253B80',
|
|
101
|
+
primaryColorFg: '#fff',
|
|
102
|
+
primaryAccentColorBg: '#feeeae',
|
|
103
|
+
primaryAccentColorFg: '#000000',
|
|
104
|
+
secondaryAccentColorBg: '#000000',
|
|
105
|
+
secondaryAccentColorFg: '#ffffff',
|
|
106
|
+
position: 'right',
|
|
107
|
+
hideMessageTypeIndicatorText: false,
|
|
108
|
+
buttonBelowMessage: false,
|
|
109
|
+
};
|
|
110
|
+
var props = (0, utilities_1.mergeProps)('chat', globalTheme, defaultProps, properties);
|
|
111
|
+
var className = props.className, internalClassName = props.internalClassName, controller = props.controller, logo = props.logo, title = props.title, subtitle = props.subtitle, avatar = props.avatar, offset = props.offset, multiselectFacets = props.multiselectFacets, disableBubbleSuggestedQuestions = props.disableBubbleSuggestedQuestions, primaryColorBg = props.primaryColorBg, primaryColorFg = props.primaryColorFg, primaryAccentColorBg = props.primaryAccentColorBg, primaryAccentColorFg = props.primaryAccentColorFg, secondaryAccentColorBg = props.secondaryAccentColorBg, secondaryAccentColorFg = props.secondaryAccentColorFg, position = props.position, hideMessageTypeIndicatorText = props.hideMessageTypeIndicatorText, buttonBelowMessage = props.buttonBelowMessage, disableStyles = props.disableStyles, treePath = props.treePath;
|
|
112
|
+
var colorPrimary = primaryColorBg;
|
|
113
|
+
var colorPrimaryText = primaryColorFg;
|
|
114
|
+
var colorPrimaryAccent = primaryAccentColorBg;
|
|
115
|
+
var colorPrimaryAccentText = primaryAccentColorFg;
|
|
116
|
+
var colorSecondaryAccent = secondaryAccentColorBg;
|
|
117
|
+
var colorSecondaryAccentText = secondaryAccentColorFg;
|
|
118
|
+
var chatPosition = position === 'right' ? 'right' : 'left';
|
|
119
|
+
var isValidImageUrl = function (value) {
|
|
120
|
+
try {
|
|
121
|
+
var protocol = new URL(value).protocol;
|
|
122
|
+
return protocol === 'http:' || protocol === 'https:' || protocol === 'data:';
|
|
123
|
+
}
|
|
124
|
+
catch (_a) {
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
// A single-character avatar renders as a capitalized letter; a longer value renders
|
|
129
|
+
// as an image when it's a valid image URL. Anything else renders no avatar.
|
|
130
|
+
var avatarCharacter = avatar && avatar.length === 1 ? avatar.toUpperCase() : undefined;
|
|
131
|
+
var avatarImage = avatar && avatar.length > 1 && isValidImageUrl(avatar) ? avatar : undefined;
|
|
132
|
+
var store = controller.store;
|
|
133
|
+
// Track that the widget has been visible so a mid-session disable (status check
|
|
134
|
+
// flips chatEnabled to false) keeps it mounted with the unavailable message
|
|
135
|
+
// instead of vanishing. A disabled status at bootstrap still renders nothing.
|
|
136
|
+
var wasVisibleRef = (0, hooks_1.useRef)(false);
|
|
137
|
+
var themeDefaults = {
|
|
138
|
+
components: {},
|
|
139
|
+
};
|
|
140
|
+
// merge deeply the themeDefaults with the theme props and the displaySettings theme props (do not merge arrays, but replace them)
|
|
141
|
+
var theme = (0, deepmerge_1.default)(themeDefaults, (props === null || props === void 0 ? void 0 : props.theme) || {}, { arrayMerge: function (destinationArray, sourceArray) { return sourceArray; } });
|
|
142
|
+
props = __assign(__assign({}, props), { theme: theme });
|
|
143
|
+
var subProps = {
|
|
144
|
+
messageUser: {
|
|
145
|
+
disableStyles: disableStyles,
|
|
146
|
+
theme: props.theme,
|
|
147
|
+
treePath: treePath,
|
|
148
|
+
primaryColor: colorPrimary,
|
|
149
|
+
primaryColorText: colorPrimaryText,
|
|
150
|
+
hideMessageTypeIndicatorText: hideMessageTypeIndicatorText,
|
|
151
|
+
},
|
|
152
|
+
messageText: {
|
|
153
|
+
disableStyles: disableStyles,
|
|
154
|
+
theme: props.theme,
|
|
155
|
+
treePath: treePath,
|
|
156
|
+
primaryColor: colorPrimary,
|
|
157
|
+
primaryColorText: colorPrimaryText,
|
|
158
|
+
primaryAccentColor: colorPrimaryAccent,
|
|
159
|
+
primaryAccentColorText: colorPrimaryAccentText,
|
|
160
|
+
buttonBelowMessage: buttonBelowMessage,
|
|
161
|
+
},
|
|
162
|
+
suggestedQuestions: {
|
|
163
|
+
disableStyles: disableStyles,
|
|
164
|
+
theme: props.theme,
|
|
165
|
+
treePath: treePath,
|
|
166
|
+
primaryColor: colorPrimary,
|
|
167
|
+
},
|
|
168
|
+
attachmentContext: {
|
|
169
|
+
disableStyles: disableStyles,
|
|
170
|
+
theme: props.theme,
|
|
171
|
+
treePath: treePath,
|
|
172
|
+
},
|
|
173
|
+
loadingIndicator: {
|
|
174
|
+
disableStyles: disableStyles,
|
|
175
|
+
theme: props.theme,
|
|
176
|
+
treePath: treePath,
|
|
177
|
+
},
|
|
178
|
+
inspirationResultMessage: {
|
|
179
|
+
disableStyles: disableStyles,
|
|
180
|
+
theme: props.theme,
|
|
181
|
+
treePath: treePath,
|
|
182
|
+
},
|
|
183
|
+
productComparisonMessage: {
|
|
184
|
+
disableStyles: disableStyles,
|
|
185
|
+
theme: props.theme,
|
|
186
|
+
treePath: treePath,
|
|
187
|
+
},
|
|
188
|
+
productQueryMessage: {
|
|
189
|
+
disableStyles: disableStyles,
|
|
190
|
+
theme: props.theme,
|
|
191
|
+
treePath: treePath,
|
|
192
|
+
primaryColor: colorPrimary,
|
|
193
|
+
primaryColorText: colorPrimaryText,
|
|
194
|
+
},
|
|
195
|
+
};
|
|
196
|
+
var messagesEndRef = (0, hooks_1.useRef)(null);
|
|
197
|
+
var messagesContainerRef = (0, hooks_1.useRef)(null);
|
|
198
|
+
var headerRef = (0, hooks_1.useRef)(null);
|
|
199
|
+
var footerRef = (0, hooks_1.useRef)(null);
|
|
200
|
+
var chatRef = (0, hooks_1.useRef)(null);
|
|
201
|
+
// Ref for the mobile secondary panel — needed for swipe-to-dismiss measurements
|
|
202
|
+
var secondaryRef = (0, hooks_1.useRef)(null);
|
|
203
|
+
var _1 = (0, hooks_1.useState)(false), mobileProductInfoOpen = _1[0], setMobileProductInfoOpen = _1[1];
|
|
204
|
+
var _2 = (0, hooks_1.useState)(0), footerHeight = _2[0], setFooterHeight = _2[1];
|
|
205
|
+
var dropEnabled = store.features.imageSearch.enabled && !store.loading && !store.blocked && !((_a = store.currentChat) === null || _a === void 0 ? void 0 : _a.sessionLimitReached);
|
|
206
|
+
var _3 = (0, useChatFileUpload_1.useChatFileUpload)({
|
|
207
|
+
enabled: !!dropEnabled,
|
|
208
|
+
onUpload: function (files) { return controller.upload(files); },
|
|
209
|
+
}), fileInputRef = _3.fileInputRef, isDraggingFile = _3.isDraggingFile, dragHandlers = _3.dragHandlers;
|
|
210
|
+
// productQuery messages are filtered out of the main chat render (they only drive the side-chat panel),
|
|
211
|
+
// so don't auto-scroll when one is added — otherwise clicking a product in the side chat scrolls the main thread.
|
|
212
|
+
var visibleChat = (((_b = store.currentChat) === null || _b === void 0 ? void 0 : _b.chat) || []).filter(function (m) { return m.messageType !== 'productQuery'; });
|
|
213
|
+
var visibleChatLength = visibleChat.length;
|
|
214
|
+
var lastVisibleMessage = visibleChat[visibleChat.length - 1];
|
|
215
|
+
var _4 = (0, useChatOverflow_1.useChatOverflow)({
|
|
216
|
+
messagesContainerRef: messagesContainerRef,
|
|
217
|
+
headerRef: headerRef,
|
|
218
|
+
open: store.open,
|
|
219
|
+
loading: store.loading,
|
|
220
|
+
visibleChatLength: visibleChatLength,
|
|
221
|
+
lastVisibleMessage: lastVisibleMessage,
|
|
222
|
+
}), showNewMessages = _4.showNewMessages, setShowNewMessages = _4.setShowNewMessages, messagesOverflow = _4.messagesOverflow, scrollToBottom = _4.scrollToBottom, scrollToBottomIfNear = _4.scrollToBottomIfNear;
|
|
223
|
+
// Re-focus the chat input on desktop after a search completes.
|
|
224
|
+
// The input is disabled while loading, which causes the browser to drop focus.
|
|
225
|
+
// On mobile we intentionally skip this so the virtual keyboard dismisses.
|
|
226
|
+
// Only fire on the loading true → false transition — running on mount steals
|
|
227
|
+
// focus away from the Storybook controls whenever the story re-renders.
|
|
228
|
+
var prevLoadingRef = (0, hooks_1.useRef)(store.loading);
|
|
229
|
+
(0, hooks_1.useEffect)(function () {
|
|
230
|
+
if (prevLoadingRef.current && !store.loading && !isMobile && store.open) {
|
|
231
|
+
controller.focusInput();
|
|
232
|
+
}
|
|
233
|
+
prevLoadingRef.current = store.loading;
|
|
234
|
+
}, [store.loading]);
|
|
235
|
+
// const subProps: ChatSubProps = {};
|
|
236
|
+
var activeMessage = (_c = store.currentChat) === null || _c === void 0 ? void 0 : _c.activeMessage;
|
|
237
|
+
// On mobile, only auto-open the secondary panel for the first productComparison
|
|
238
|
+
// message in the chat session. Subsequent comparison results show a "Show Details"
|
|
239
|
+
// button instead (handled in MessageText via sideChatLabel toggle).
|
|
240
|
+
var isFirstMobileComparison = (function () {
|
|
241
|
+
var _a, _b;
|
|
242
|
+
if (!isMobile || (activeMessage === null || activeMessage === void 0 ? void 0 : activeMessage.messageType) !== 'productComparison')
|
|
243
|
+
return true;
|
|
244
|
+
// If the user explicitly activated a comparison (via "Show Details" or the
|
|
245
|
+
// view-side-chat button), always allow it regardless of position in the chat
|
|
246
|
+
if ((_a = store.currentChat) === null || _a === void 0 ? void 0 : _a.activeMessageId)
|
|
247
|
+
return true;
|
|
248
|
+
var comparisonMessages = (((_b = store.currentChat) === null || _b === void 0 ? void 0 : _b.chat) || []).filter(function (m) { return m.messageType === 'productComparison'; });
|
|
249
|
+
return comparisonMessages.length <= 1;
|
|
250
|
+
})();
|
|
251
|
+
var sideChatTypes = isMobile
|
|
252
|
+
? __spreadArray(__spreadArray(['inspirationResult'], (isFirstMobileComparison ? ['productComparison'] : []), true), (mobileProductInfoOpen ? ['productQuery'] : []), true) : ['inspirationResult', 'productComparison', 'productQuery'];
|
|
253
|
+
var shouldShowSideChat = activeMessage && sideChatTypes.includes(activeMessage === null || activeMessage === void 0 ? void 0 : activeMessage.messageType) && ((_d = store.currentChat) === null || _d === void 0 ? void 0 : _d.dismissedSideChatMessageId) !== activeMessage.id;
|
|
254
|
+
var hasSideChat = !!shouldShowSideChat;
|
|
255
|
+
var styling = (0, hooks_1.useMemo)(function () {
|
|
256
|
+
return (0, utilities_1.mergeStyles)({
|
|
257
|
+
mobile: isMobile,
|
|
258
|
+
offset: offset,
|
|
259
|
+
hasSideChat: hasSideChat,
|
|
260
|
+
footerHeight: footerHeight,
|
|
261
|
+
primaryColorBg: colorPrimary,
|
|
262
|
+
primaryColorFg: colorPrimaryText,
|
|
263
|
+
primaryAccentColorBg: colorPrimaryAccent,
|
|
264
|
+
primaryAccentColorFg: colorPrimaryAccentText,
|
|
265
|
+
secondaryAccentColorBg: colorSecondaryAccent,
|
|
266
|
+
secondaryAccentColorFg: colorSecondaryAccentText,
|
|
267
|
+
position: chatPosition,
|
|
268
|
+
}, Chat_styles_1.chatDefaultStyles);
|
|
269
|
+
}, [
|
|
270
|
+
isMobile,
|
|
271
|
+
offset,
|
|
272
|
+
hasSideChat,
|
|
273
|
+
footerHeight,
|
|
274
|
+
colorPrimary,
|
|
275
|
+
colorPrimaryText,
|
|
276
|
+
colorPrimaryAccent,
|
|
277
|
+
colorPrimaryAccentText,
|
|
278
|
+
colorSecondaryAccent,
|
|
279
|
+
colorSecondaryAccentText,
|
|
280
|
+
chatPosition,
|
|
281
|
+
]);
|
|
282
|
+
// Lock body scroll while chat is open so touch/wheel scrolls don't leak to the page behind
|
|
283
|
+
(0, hooks_1.useEffect)(function () {
|
|
284
|
+
if (!store.open)
|
|
285
|
+
return;
|
|
286
|
+
var body = document.body;
|
|
287
|
+
var previousOverflow = body.style.overflow;
|
|
288
|
+
var previousOverscroll = body.style.overscrollBehavior;
|
|
289
|
+
body.style.overflow = 'hidden';
|
|
290
|
+
body.style.overscrollBehavior = 'contain';
|
|
291
|
+
return function () {
|
|
292
|
+
body.style.overflow = previousOverflow;
|
|
293
|
+
body.style.overscrollBehavior = previousOverscroll;
|
|
294
|
+
};
|
|
295
|
+
}, [store.open]);
|
|
296
|
+
// Close chat on Escape key (or dismiss side chat first when it's open)
|
|
297
|
+
(0, hooks_1.useEffect)(function () {
|
|
298
|
+
if (!store.open)
|
|
299
|
+
return;
|
|
300
|
+
var onKeyDown = function (e) {
|
|
301
|
+
var _a, _b;
|
|
302
|
+
if (e.key !== 'Escape')
|
|
303
|
+
return;
|
|
304
|
+
if (((_a = store.currentChat) === null || _a === void 0 ? void 0 : _a.activeMessage) && shouldShowSideChat) {
|
|
305
|
+
(_b = store.currentChat) === null || _b === void 0 ? void 0 : _b.dismissSideChat();
|
|
306
|
+
}
|
|
307
|
+
else {
|
|
308
|
+
controller.handlers.button.click();
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
document.addEventListener('keydown', onKeyDown);
|
|
312
|
+
return function () { return document.removeEventListener('keydown', onKeyDown); };
|
|
313
|
+
}, [store.open, shouldShowSideChat]);
|
|
314
|
+
// Track the primary footer height so the mobile secondary panel can sit above it
|
|
315
|
+
(0, hooks_1.useEffect)(function () {
|
|
316
|
+
var el = footerRef.current;
|
|
317
|
+
if (!el)
|
|
318
|
+
return;
|
|
319
|
+
var observer = new ResizeObserver(function (entries) {
|
|
320
|
+
var _a, _b, _c;
|
|
321
|
+
for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
|
|
322
|
+
var entry = entries_1[_i];
|
|
323
|
+
setFooterHeight((_c = (_b = (_a = entry.borderBoxSize) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.blockSize) !== null && _c !== void 0 ? _c : entry.target.getBoundingClientRect().height);
|
|
324
|
+
}
|
|
325
|
+
});
|
|
326
|
+
observer.observe(el);
|
|
327
|
+
return function () { return observer.disconnect(); };
|
|
328
|
+
}, [store.open, (_e = store.currentChat) === null || _e === void 0 ? void 0 : _e.isExpired]);
|
|
329
|
+
// Prevent the background page from scrolling while the chat is open on touch
|
|
330
|
+
// devices. iOS Safari (real iPad/iPhone) rubber-band-scrolls the body when a
|
|
331
|
+
// touchmove inside `.ss__chat__messages` reaches the top/bottom — and
|
|
332
|
+
// `overscroll-behavior: contain` is ignored there.
|
|
333
|
+
//
|
|
334
|
+
// We don't touch body styles (locking via `position: fixed` on `<body>` leaves
|
|
335
|
+
// iPad Safari in a stuck viewport state where the page can't scroll after the
|
|
336
|
+
// lock is released). Instead we install a `touchmove` handler that:
|
|
337
|
+
// - allows the touchmove if it's inside a scrollable region of the chat
|
|
338
|
+
// and that region isn't at its scroll edge in the swipe direction;
|
|
339
|
+
// - calls `preventDefault()` otherwise — which is what blocks both
|
|
340
|
+
// background scrolling and iOS rubber-band overscroll.
|
|
341
|
+
// Cleanup just removes the listeners, so nothing can leak into the page.
|
|
342
|
+
(0, hooks_1.useEffect)(function () {
|
|
343
|
+
if (!store.open)
|
|
344
|
+
return;
|
|
345
|
+
if (typeof document === 'undefined')
|
|
346
|
+
return;
|
|
347
|
+
var startX = 0;
|
|
348
|
+
var startY = 0;
|
|
349
|
+
var scrollEl = null;
|
|
350
|
+
// Walk up from the touch target to find the first ancestor inside the chat
|
|
351
|
+
// that is actually scrollable in either axis. Stop at the chat root so we
|
|
352
|
+
// never consider elements outside the chat.
|
|
353
|
+
var findScrollableInChat = function (start) {
|
|
354
|
+
var chatRoot = chatRef.current;
|
|
355
|
+
if (!chatRoot)
|
|
356
|
+
return null;
|
|
357
|
+
var el = start;
|
|
358
|
+
while (el && chatRoot.contains(el)) {
|
|
359
|
+
var style = getComputedStyle(el);
|
|
360
|
+
var scrollableY = (style.overflowY === 'auto' || style.overflowY === 'scroll') && el.scrollHeight > el.clientHeight;
|
|
361
|
+
var scrollableX = (style.overflowX === 'auto' || style.overflowX === 'scroll') && el.scrollWidth > el.clientWidth;
|
|
362
|
+
if (scrollableY || scrollableX) {
|
|
363
|
+
return el;
|
|
364
|
+
}
|
|
365
|
+
if (el === chatRoot)
|
|
366
|
+
break;
|
|
367
|
+
el = el.parentElement;
|
|
368
|
+
}
|
|
369
|
+
return null;
|
|
370
|
+
};
|
|
371
|
+
var onTouchStart = function (e) {
|
|
372
|
+
if (!e.touches[0])
|
|
373
|
+
return;
|
|
374
|
+
startX = e.touches[0].clientX;
|
|
375
|
+
startY = e.touches[0].clientY;
|
|
376
|
+
scrollEl = findScrollableInChat(e.target);
|
|
377
|
+
};
|
|
378
|
+
var onTouchMove = function (e) {
|
|
379
|
+
var _a, _b, _c, _d;
|
|
380
|
+
var target = e.target;
|
|
381
|
+
var chatRoot = chatRef.current;
|
|
382
|
+
var inChat = !!(chatRoot && target && chatRoot.contains(target));
|
|
383
|
+
// Touches outside the chat shouldn't scroll the background.
|
|
384
|
+
if (!inChat) {
|
|
385
|
+
if (e.cancelable)
|
|
386
|
+
e.preventDefault();
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
389
|
+
// Inside the chat but no scrollable container — block to prevent body scroll.
|
|
390
|
+
if (!scrollEl) {
|
|
391
|
+
if (e.cancelable)
|
|
392
|
+
e.preventDefault();
|
|
393
|
+
return;
|
|
394
|
+
}
|
|
395
|
+
// Inside a scrollable container — only block when at the edge in the
|
|
396
|
+
// swipe direction, so internal scrolling continues to work. Detect the
|
|
397
|
+
// dominant axis so horizontally-scrollable rows (e.g. the facets row)
|
|
398
|
+
// also get to handle their own touch gestures.
|
|
399
|
+
var currentX = (_b = (_a = e.touches[0]) === null || _a === void 0 ? void 0 : _a.clientX) !== null && _b !== void 0 ? _b : startX;
|
|
400
|
+
var currentY = (_d = (_c = e.touches[0]) === null || _c === void 0 ? void 0 : _c.clientY) !== null && _d !== void 0 ? _d : startY;
|
|
401
|
+
var deltaX = currentX - startX;
|
|
402
|
+
var deltaY = currentY - startY;
|
|
403
|
+
var horizontal = Math.abs(deltaX) > Math.abs(deltaY);
|
|
404
|
+
if (horizontal) {
|
|
405
|
+
var scrollsX = scrollEl.scrollWidth > scrollEl.clientWidth;
|
|
406
|
+
if (!scrollsX) {
|
|
407
|
+
if (e.cancelable)
|
|
408
|
+
e.preventDefault();
|
|
409
|
+
return;
|
|
410
|
+
}
|
|
411
|
+
var atLeft = scrollEl.scrollLeft <= 0;
|
|
412
|
+
var atRight = scrollEl.scrollLeft + scrollEl.clientWidth >= scrollEl.scrollWidth - 1;
|
|
413
|
+
if ((atLeft && deltaX > 0) || (atRight && deltaX < 0)) {
|
|
414
|
+
if (e.cancelable)
|
|
415
|
+
e.preventDefault();
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
else {
|
|
419
|
+
var scrollsY = scrollEl.scrollHeight > scrollEl.clientHeight;
|
|
420
|
+
if (!scrollsY) {
|
|
421
|
+
if (e.cancelable)
|
|
422
|
+
e.preventDefault();
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
425
|
+
var atTop = scrollEl.scrollTop <= 0;
|
|
426
|
+
var atBottom = scrollEl.scrollTop + scrollEl.clientHeight >= scrollEl.scrollHeight - 1;
|
|
427
|
+
if ((atTop && deltaY > 0) || (atBottom && deltaY < 0)) {
|
|
428
|
+
if (e.cancelable)
|
|
429
|
+
e.preventDefault();
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
};
|
|
433
|
+
document.addEventListener('touchstart', onTouchStart, { passive: true });
|
|
434
|
+
document.addEventListener('touchmove', onTouchMove, { passive: false });
|
|
435
|
+
return function () {
|
|
436
|
+
document.removeEventListener('touchstart', onTouchStart);
|
|
437
|
+
document.removeEventListener('touchmove', onTouchMove);
|
|
438
|
+
};
|
|
439
|
+
}, [store.open]);
|
|
440
|
+
var HistoryButton = function (props) { return ((0, jsx_runtime_1.jsx)(Button_1.Button, { className: "ss__chat__header__button--history", disabled: props.disabled, icon: {
|
|
441
|
+
icon: 'history',
|
|
442
|
+
title: 'Chat History',
|
|
443
|
+
} })); };
|
|
444
|
+
var HistoryPopup = function (props) { return ((0, jsx_runtime_1.jsxs)("div", { className: "ss__chat__history", children: [(0, jsx_runtime_1.jsxs)("div", { className: "ss__chat__history__header", children: [(0, jsx_runtime_1.jsx)("h4", { children: "History" }), (0, jsx_runtime_1.jsx)("div", { className: "ss__chat__history__header__buttons", children: (0, jsx_runtime_1.jsx)(Button_1.Button, { content: "clear", disabled: store.loading || store.blocked, onClick: function () {
|
|
445
|
+
controller.store.clearHistory();
|
|
446
|
+
props.toggleOpen && props.toggleOpen();
|
|
447
|
+
} }) })] }), store.chats.length > 0 ? ((0, jsx_runtime_1.jsx)("div", { className: "ss__chat__history__chats", children: store.chats
|
|
448
|
+
.slice()
|
|
449
|
+
.reverse()
|
|
450
|
+
.map(function (chat) { return ((0, jsx_runtime_1.jsx)("div", { className: "ss__chat__history__chats__chat", children: (0, jsx_runtime_1.jsxs)(Button_1.Button, { className: "ss__chat__history__chat__button", onClick: function () {
|
|
451
|
+
controller.store.switchChat(chat.id);
|
|
452
|
+
}, disabled: chat.id === store.currentChatId || store.loading || store.blocked, children: [(0, jsx_runtime_1.jsx)("div", { className: "ss__chat__history__chat__button__text", children: (function () {
|
|
453
|
+
var lastUserMessage = __spreadArray([], chat.chat, true).reverse().find(function (message) { return message.messageType === 'user'; });
|
|
454
|
+
if (!lastUserMessage)
|
|
455
|
+
return 'New Chat';
|
|
456
|
+
var text = lastUserMessage.text;
|
|
457
|
+
return text.length > 50 ? "".concat(text.slice(0, 50), "...") : text;
|
|
458
|
+
})() }), (0, jsx_runtime_1.jsx)("div", { className: "ss__chat__history__chat__button__date", children: chat.createdAt.toLocaleString() })] }) }, chat.id)); }) })) : null] })); };
|
|
459
|
+
var FacetButton = function (props) { return (0, jsx_runtime_1.jsx)(Button_1.Button, { icon: props.open ? 'angle-down' : 'angle-up', children: props.label }); };
|
|
460
|
+
var getFacetButtonLabel = function (facet) {
|
|
461
|
+
var _a, _b;
|
|
462
|
+
var base = facet.label || facet.field;
|
|
463
|
+
// Slider facets show the active low-high range in the button when narrowed.
|
|
464
|
+
if (facet.type === 'range') {
|
|
465
|
+
var rangeFacet = facet;
|
|
466
|
+
var active = rangeFacet.active;
|
|
467
|
+
var range = rangeFacet.range;
|
|
468
|
+
if (active && range && (active.low !== range.low || active.high !== range.high)) {
|
|
469
|
+
return "".concat(base, " (").concat((_a = active.low) !== null && _a !== void 0 ? _a : '*', "-").concat((_b = active.high) !== null && _b !== void 0 ? _b : '*', ")");
|
|
470
|
+
}
|
|
471
|
+
return base;
|
|
472
|
+
}
|
|
473
|
+
// Count current selections from the urlManager (source of truth for live state).
|
|
474
|
+
// `value.filtered` reflects the server's snapshot at response time and goes stale
|
|
475
|
+
// once the user deselects locally.
|
|
476
|
+
var applied = (facet.values || []).filter(function (value) {
|
|
477
|
+
var _a, _b;
|
|
478
|
+
if (!value)
|
|
479
|
+
return false;
|
|
480
|
+
var optionValue = 'low' in value && 'high' in value
|
|
481
|
+
? "".concat((_a = value.low) !== null && _a !== void 0 ? _a : '*', ":").concat((_b = value.high) !== null && _b !== void 0 ? _b : '*')
|
|
482
|
+
: value.value || value.label;
|
|
483
|
+
return controller.store.isFacetSelected(facet.field, optionValue);
|
|
484
|
+
}).length;
|
|
485
|
+
return applied > 0 ? "".concat(base, " (").concat(applied, ")") : base;
|
|
486
|
+
};
|
|
487
|
+
// Slider dropdown grows to fill the remaining chat width from its anchor,
|
|
488
|
+
// so the price range slider isn't cramped inside a 150px-wide dropdown.
|
|
489
|
+
var SliderFacetDropdown = function (props) {
|
|
490
|
+
var anchorRef = (0, hooks_1.useRef)(null);
|
|
491
|
+
var _a = (0, hooks_1.useState)(null), width = _a[0], setWidth = _a[1];
|
|
492
|
+
(0, hooks_1.useEffect)(function () {
|
|
493
|
+
var compute = function () {
|
|
494
|
+
if (!anchorRef.current || !chatRef.current)
|
|
495
|
+
return;
|
|
496
|
+
var anchor = anchorRef.current.getBoundingClientRect();
|
|
497
|
+
var chat = chatRef.current.getBoundingClientRect();
|
|
498
|
+
var remaining = chat.right - anchor.left - 16;
|
|
499
|
+
setWidth(Math.max(220, remaining));
|
|
500
|
+
};
|
|
501
|
+
compute();
|
|
502
|
+
var ro = typeof ResizeObserver !== 'undefined' ? new ResizeObserver(compute) : null;
|
|
503
|
+
if (ro && chatRef.current)
|
|
504
|
+
ro.observe(chatRef.current);
|
|
505
|
+
window.addEventListener('resize', compute);
|
|
506
|
+
return function () {
|
|
507
|
+
if (ro)
|
|
508
|
+
ro.disconnect();
|
|
509
|
+
window.removeEventListener('resize', compute);
|
|
510
|
+
};
|
|
511
|
+
}, []);
|
|
512
|
+
return ((0, jsx_runtime_1.jsx)("div", { ref: anchorRef, className: "ss__chat__actions__facet ss__chat__actions__facet--range", children: (0, jsx_runtime_1.jsx)(__1.Dropdown, { usePortal: true, dropUp: true, button: (0, jsx_runtime_1.jsx)(FacetButton, { label: props.label }), style: {
|
|
513
|
+
'.ss__dropdown__content': {
|
|
514
|
+
width: width ? "".concat(width, "px") : 'auto',
|
|
515
|
+
background: 'white',
|
|
516
|
+
boxShadow: '0px 3px 6px 0px rgba(0, 0, 0, 0.2)',
|
|
517
|
+
borderRadius: '6px',
|
|
518
|
+
},
|
|
519
|
+
}, children: (0, jsx_runtime_1.jsx)("div", { className: "ss__chat__actions__facet__options", children: (0, jsx_runtime_1.jsx)("div", { className: "ss__chat__actions__facet__slider", style: { padding: '12px 16px' }, children: (0, jsx_runtime_1.jsx)(__1.FacetSlider, { facet: props.facet, onChange: function () {
|
|
520
|
+
if (!multiselectFacets) {
|
|
521
|
+
// FacetSlider fires onChange before its urlManager update; defer
|
|
522
|
+
// so controller.search() reads the updated filter state. Force
|
|
523
|
+
// productSearch with the current filters so a slider tweak doesn't
|
|
524
|
+
// fall through to `general` when hasPendingFacetChanges happens to
|
|
525
|
+
// be false (e.g. the slider returned to the seeded range).
|
|
526
|
+
queueMicrotask(function () {
|
|
527
|
+
return controller.search({
|
|
528
|
+
data: { requestType: 'productSearch', searchFilters: controller.store.searchFilters },
|
|
529
|
+
});
|
|
530
|
+
});
|
|
531
|
+
}
|
|
532
|
+
} }) }) }) }) }));
|
|
533
|
+
};
|
|
534
|
+
// TODO: if starting a new chat and it's expired, this button would then disappear
|
|
535
|
+
if (controller.store.chatEnabled) {
|
|
536
|
+
wasVisibleRef.current = true;
|
|
537
|
+
}
|
|
538
|
+
// Hide the widget entirely when chat is disabled at bootstrap (silent disable).
|
|
539
|
+
// When chat becomes disabled mid-session, keep the widget mounted so the footer
|
|
540
|
+
// unavailable message stays visible (with the input disabled).
|
|
541
|
+
if (!controller.store.chatEnabled && !wasVisibleRef.current) {
|
|
542
|
+
return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {});
|
|
543
|
+
}
|
|
544
|
+
// Dismiss the secondary panel and clear any product attachments tied to the side-chat
|
|
545
|
+
// (discuss product flow), while preserving productSimilar/productComparison attachments.
|
|
546
|
+
var dismissSideChat = function () {
|
|
547
|
+
var _a, _b;
|
|
548
|
+
var productAttachmentsToRemove = (((_a = store.currentChat) === null || _a === void 0 ? void 0 : _a.attachments.attached) || []).filter(function (item) { return item.type === 'product' && item.requestType !== 'productSimilar' && item.requestType !== 'productComparison'; });
|
|
549
|
+
productAttachmentsToRemove.forEach(function (item) { var _a; return (_a = store.currentChat) === null || _a === void 0 ? void 0 : _a.attachments.remove(item.id); });
|
|
550
|
+
setMobileProductInfoOpen(false);
|
|
551
|
+
(_b = store.currentChat) === null || _b === void 0 ? void 0 : _b.dismissSideChat();
|
|
552
|
+
};
|
|
553
|
+
var _5 = (0, useChatGestures_1.useChatGestures)({
|
|
554
|
+
panelRef: secondaryRef,
|
|
555
|
+
shouldShowSideChat: !!shouldShowSideChat,
|
|
556
|
+
activeMessageId: activeMessage === null || activeMessage === void 0 ? void 0 : activeMessage.id,
|
|
557
|
+
onDismiss: dismissSideChat,
|
|
558
|
+
}), swipeOffset = _5.swipeOffset, swipeAnimating = _5.swipeAnimating, swipeHandlers = _5.swipeHandlers;
|
|
559
|
+
var requestType = (_f = store.currentChat) === null || _f === void 0 ? void 0 : _f.requestType;
|
|
560
|
+
var loadingVerbs = (0, hooks_1.useMemo)(function () {
|
|
561
|
+
switch (requestType) {
|
|
562
|
+
case 'productQuery':
|
|
563
|
+
return ['Thinking', 'Searching', 'Analyzing', 'Gathering details'];
|
|
564
|
+
case 'productSearch':
|
|
565
|
+
return ['Searching', 'Browsing catalog', 'Finding products', 'Curating results'];
|
|
566
|
+
case 'productComparison':
|
|
567
|
+
return ['Comparing', 'Analyzing', 'Evaluating', 'Weighing options'];
|
|
568
|
+
case 'imageSearch':
|
|
569
|
+
return ['Analyzing image', 'Identifying', 'Searching', 'Matching'];
|
|
570
|
+
case 'productSimilar':
|
|
571
|
+
return ['Finding similar items', 'Searching', 'Matching', 'Curating'];
|
|
572
|
+
case 'inspirationRequest':
|
|
573
|
+
return ['Brainstorming', 'Imagining', 'Curating', 'Inspiring'];
|
|
574
|
+
case 'general':
|
|
575
|
+
default:
|
|
576
|
+
return undefined;
|
|
577
|
+
}
|
|
578
|
+
}, [requestType]);
|
|
579
|
+
var isWelcomeState = (!((_g = store.currentChat) === null || _g === void 0 ? void 0 : _g.chat) || store.currentChat.chat.length === 0) && !!store.welcomeMessage && !((_h = store.currentChat) === null || _h === void 0 ? void 0 : _h.isExpired);
|
|
580
|
+
return ((0, jsx_runtime_1.jsx)(providers_1.CacheProvider, { children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", __assign({ ref: chatRef, className: (0, classnames_1.default)('ss__chat', {
|
|
581
|
+
'ss__chat--open': store.open,
|
|
582
|
+
'ss__chat--minimized': !store.open,
|
|
583
|
+
'ss__chat--mobile': isMobile,
|
|
584
|
+
'ss__chat--welcome': isWelcomeState,
|
|
585
|
+
}, className, internalClassName) }, styling, { children: [!disableBubbleSuggestedQuestions && !store.open && !store.currentChat && ((_j = store.suggestedQuestions) === null || _j === void 0 ? void 0 : _j.length) > 0 && ((0, jsx_runtime_1.jsx)("div", { className: "ss__chat__suggested-questions", children: store.suggestedQuestions.map(function (question) { return ((0, jsx_runtime_1.jsx)("div", { className: "ss__chat__suggested-questions__item", onClick: function () {
|
|
586
|
+
controller.openChat(question);
|
|
587
|
+
}, children: question }, question)); }) })), (0, jsx_runtime_1.jsx)("button", { type: "button", className: 'ss__chat__bubble', "aria-label": store.open ? 'Close chat' : 'Open chat', "aria-expanded": store.open, onClick: function () { return controller.handlers.button.click(); }, children: (0, jsx_runtime_1.jsx)(__1.Icon, { icon: "chat", title: "Open Chat" }) }), store.open && shouldShowSideChat && activeMessage ? ((0, jsx_runtime_1.jsxs)("div", { ref: secondaryRef, className: (0, classnames_1.default)('ss__chat__secondary'), role: "region", "aria-label": "Conversation details", style: isMobile
|
|
588
|
+
? {
|
|
589
|
+
// Touch swipe animations need to be inline to prevent visual jumps
|
|
590
|
+
transform: swipeOffset > 0 ? "translateY(".concat(swipeOffset, "px)") : undefined,
|
|
591
|
+
transition: swipeAnimating ? 'transform 0.3s ease-out' : 'none',
|
|
592
|
+
}
|
|
593
|
+
: undefined, children: [isMobile && ((0, jsx_runtime_1.jsx)("div", __assign({ className: "ss__chat__secondary__drag-handle" }, swipeHandlers, { children: (0, jsx_runtime_1.jsx)("div", { className: "ss__chat__secondary__drag-handle__indicator" }) }))), (0, jsx_runtime_1.jsxs)("div", { className: 'ss__chat__header', onTouchStart: isMobile ? swipeHandlers.onTouchStart : undefined, onTouchMove: isMobile ? swipeHandlers.onTouchMove : undefined, onTouchEnd: isMobile ? swipeHandlers.onTouchEnd : undefined, children: [(0, jsx_runtime_1.jsxs)("div", { className: "ss__chat__header__title", children: [(0, jsx_runtime_1.jsx)("div", { className: "ss__chat__header__title__primary", children: {
|
|
594
|
+
inspirationResult: 'Inspiration Scenarios',
|
|
595
|
+
productComparison: 'Product Comparison',
|
|
596
|
+
productQuery: '',
|
|
597
|
+
}[activeMessage.messageType] || null }), (0, jsx_runtime_1.jsx)("div", { className: "ss__chat__header__title__secondary", children: {
|
|
598
|
+
inspirationResult: 'Choose a style direction to explore',
|
|
599
|
+
productComparison: "Comparing ".concat(((_k = activeMessage === null || activeMessage === void 0 ? void 0 : activeMessage.searchResults) === null || _k === void 0 ? void 0 : _k.length) || '', " products"),
|
|
600
|
+
productQuery: '',
|
|
601
|
+
}[activeMessage.messageType] || null })] }), (0, jsx_runtime_1.jsx)("div", { className: "ss__chat__header__buttons", children: (0, jsx_runtime_1.jsx)(Button_1.Button, { className: "ss__chat__header__button--close", "aria-label": "Close chat", icon: { icon: 'close2', title: 'Close Chat' }, onClick: function () { return dismissSideChat(); } }) })] }), (0, jsx_runtime_1.jsx)("div", { className: "ss__chat__content", children: (0, jsx_runtime_1.jsx)("div", { className: 'ss__chat__messages', children: {
|
|
602
|
+
inspirationResult: ((0, jsx_runtime_1.jsx)(ChatInspirationResultMessage_1.ChatInspirationResultMessage, __assign({}, subProps.inspirationResultMessage, { chatItem: activeMessage, controller: controller, onProductQuickView: isMobile ? function () { return setMobileProductInfoOpen(true); } : undefined }))),
|
|
603
|
+
productComparison: ((0, jsx_runtime_1.jsx)(ChatProductComparisonMessage_1.ChatProductComparisonMessage, __assign({}, subProps.productComparisonMessage, { chatItem: activeMessage, controller: controller }))),
|
|
604
|
+
productQuery: ((0, jsx_runtime_1.jsx)(ChatProductQueryMessage_1.ChatProductQueryMessage, __assign({}, subProps.productQueryMessage, { chatItem: activeMessage, controller: controller, displayFields: (_m = (_l = controller.config.settings) === null || _l === void 0 ? void 0 : _l.quickview) === null || _m === void 0 ? void 0 : _m.displayFields, primaryColor: colorPrimary, primaryColorText: colorPrimaryText }))),
|
|
605
|
+
}[activeMessage.messageType] || null }) })] })) : null, store.open ? ((0, jsx_runtime_1.jsxs)("div", { className: 'ss__chat__primary',
|
|
606
|
+
// On mobile, interacting with the primary chat (header or anywhere within)
|
|
607
|
+
// dismisses the secondary panel. Capture phase so it fires even when an
|
|
608
|
+
// inner control stops propagation.
|
|
609
|
+
onClickCapture: isMobile && shouldShowSideChat ? function () { return dismissSideChat(); } : undefined, children: [(0, jsx_runtime_1.jsxs)("div", { className: 'ss__chat__header', children: [(0, jsx_runtime_1.jsxs)("div", { className: "ss__chat__header__title", children: [logo ? (0, jsx_runtime_1.jsx)(Image_1.Image, { className: "ss__chat__header__title__logo", src: logo, alt: title || 'Chat logo' }) : null, (0, jsx_runtime_1.jsxs)("div", { className: "ss__chat__header__title__text", children: [title ? (0, jsx_runtime_1.jsx)("div", { className: "ss__chat__header__title__text__primary", children: title }) : null, subtitle ? (0, jsx_runtime_1.jsx)("div", { className: "ss__chat__header__title__text__secondary", children: subtitle }) : null] })] }), (0, jsx_runtime_1.jsxs)("div", { className: "ss__chat__header__buttons", children: [(0, jsx_runtime_1.jsx)(Button_1.Button
|
|
610
|
+
// disabled={store.currentChat?.chat && store.currentChat.chat.length <= 1}
|
|
611
|
+
, {
|
|
612
|
+
// disabled={store.currentChat?.chat && store.currentChat.chat.length <= 1}
|
|
613
|
+
className: "ss__chat__header__button--new", "aria-label": "New chat", icon: { icon: controller.store.initChatLoading ? 'spinner' : 'plus2', title: 'New Chat' }, onClick: function () { return controller.store.createChat(); } }), store.chats.length > 1 && ((0, jsx_runtime_1.jsx)(__1.Dropdown, { disabled: store.loading || store.blocked, className: "ss__chat__header__dropdown-history", button: (0, jsx_runtime_1.jsx)(HistoryButton, {}), children: (0, jsx_runtime_1.jsx)(HistoryPopup, {}) })), (0, jsx_runtime_1.jsx)(Button_1.Button, { className: "ss__chat__header__button--close", "aria-label": "Close chat", icon: { icon: 'close2', title: 'Close Chat' }, onClick: function () { return controller.handlers.button.click(); } })] })] }), (0, jsx_runtime_1.jsxs)("div", { className: "ss__chat__content", children: [(function () {
|
|
614
|
+
var _a, _b, _c, _d, _e;
|
|
615
|
+
var feedbackAfterMessages = (_a = controller.config.settings) === null || _a === void 0 ? void 0 : _a.feedbackAfterMessages;
|
|
616
|
+
var systemMessages = (((_b = store.currentChat) === null || _b === void 0 ? void 0 : _b.chat) || []).filter(function (msg) { return msg.messageType !== 'user' && msg.messageType !== 'productQuery'; });
|
|
617
|
+
var currentRating = (_c = store.currentChat) === null || _c === void 0 ? void 0 : _c.feedback.rating;
|
|
618
|
+
var hasRated = !!currentRating;
|
|
619
|
+
var shouldShowFeedback = feedbackAfterMessages &&
|
|
620
|
+
systemMessages.length >= feedbackAfterMessages &&
|
|
621
|
+
!((_d = store.currentChat) === null || _d === void 0 ? void 0 : _d.feedback.dismissed) &&
|
|
622
|
+
(!hasRated || ((_e = store.currentChat) === null || _e === void 0 ? void 0 : _e.feedback.justGiven));
|
|
623
|
+
return shouldShowFeedback ? ((0, jsx_runtime_1.jsxs)("div", { className: "ss__chat__session-feedback", children: [(0, jsx_runtime_1.jsx)("div", { className: "ss__chat__session-feedback__icon", children: (0, jsx_runtime_1.jsx)(__1.Icon, { icon: "chat", size: "16px" }) }), (0, jsx_runtime_1.jsx)("span", { className: "ss__chat__session-feedback__label", children: hasRated ? 'Thank you for your feedback' : "How's your experience so far?" }), (0, jsx_runtime_1.jsxs)("div", { className: "ss__chat__session-feedback__actions".concat(hasRated ? ' ss__chat__session-feedback__actions--rated' : ''), children: [(!hasRated || currentRating === 'UP') && ((0, jsx_runtime_1.jsx)("span", { onClick: function () { return !hasRated && controller.handleFeedback('UP'); }, children: (0, jsx_runtime_1.jsx)(__1.Icon, { icon: 'thumbs-up', size: "16px", title: 'Thumbs Up' }) })), (!hasRated || currentRating === 'DOWN') && ((0, jsx_runtime_1.jsx)("span", { onClick: function () { return !hasRated && controller.handleFeedback('DOWN'); }, children: (0, jsx_runtime_1.jsx)(__1.Icon, { icon: 'thumbs-down', size: "16px", title: 'Thumbs Down' }) }))] }), !hasRated && ((0, jsx_runtime_1.jsx)("span", { className: "ss__chat__session-feedback__close", onClick: function () {
|
|
624
|
+
if (store.currentChat) {
|
|
625
|
+
store.currentChat.feedback.dismissed = true;
|
|
626
|
+
store.currentChat.save();
|
|
627
|
+
}
|
|
628
|
+
}, children: (0, jsx_runtime_1.jsx)(__1.Icon, { icon: "close-thin", size: "14px" }) }))] })) : null;
|
|
629
|
+
})(), (0, jsx_runtime_1.jsx)("div", { ref: headerRef, className: (0, classnames_1.default)('ss__chat__content__header', {
|
|
630
|
+
'ss__chat__content__header--overlay': messagesOverflow,
|
|
631
|
+
}), children: ((_o = store.currentChat) === null || _o === void 0 ? void 0 : _o.comparisons.compared) && store.currentChat.comparisons.compared.length > 0 && ((0, jsx_runtime_1.jsxs)("div", { className: 'ss__chat__content__header__comparisons', children: [(0, jsx_runtime_1.jsxs)("div", { className: 'ss__chat__content__header__comparisons__header', children: [(0, jsx_runtime_1.jsxs)("div", { className: 'ss__chat__content__header__comparisons__header__title', children: [(0, jsx_runtime_1.jsx)(__1.Icon, { className: 'ss__chat__content__header__comparisons__header__title__icon', icon: 'clipboard' }), (0, jsx_runtime_1.jsxs)("span", { className: 'ss__chat__content__header__comparisons__header__title__text', children: ["Compare Products (", (_p = store.currentChat) === null || _p === void 0 ? void 0 : _p.comparisons.compared.length, "/", (_q = store.currentChat) === null || _q === void 0 ? void 0 : _q.comparisons.maxItems, ")"] })] }), (0, jsx_runtime_1.jsx)("div", { className: 'ss__chat__content__header__comparisons__header__actions', children: (0, jsx_runtime_1.jsx)(Button_1.Button, { onClick: function () { var _a; return (_a = store.currentChat) === null || _a === void 0 ? void 0 : _a.comparisons.reset(); }, children: "clear" }) })] }), (0, jsx_runtime_1.jsxs)("div", { className: 'ss__chat__content__header__comparisons__content', children: [(0, jsx_runtime_1.jsx)("div", { className: 'ss__chat__content__header__comparisons__content__items', children: Array.from({ length: (_r = store.currentChat) === null || _r === void 0 ? void 0 : _r.comparisons.maxItems }).map(function (_, index) {
|
|
632
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
633
|
+
var comparisonItem = (_a = store.currentChat) === null || _a === void 0 ? void 0 : _a.comparisons.compared[index];
|
|
634
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)('ss__chat__content__header__comparisons__content__comparison', {
|
|
635
|
+
'ss__chat__content__header__comparisons__content__comparison--placeholder': !comparisonItem,
|
|
636
|
+
}), children: comparisonItem ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Image_1.Image
|
|
637
|
+
// onClick={() => {
|
|
638
|
+
// controller?.productQuickView(product as any);
|
|
639
|
+
// }}
|
|
640
|
+
, {
|
|
641
|
+
// onClick={() => {
|
|
642
|
+
// controller?.productQuickView(product as any);
|
|
643
|
+
// }}
|
|
644
|
+
alt: ((_e = (_d = (_c = (((_b = comparisonItem === null || comparisonItem === void 0 ? void 0 : comparisonItem.result) === null || _b === void 0 ? void 0 : _b.display) || (comparisonItem === null || comparisonItem === void 0 ? void 0 : comparisonItem.result))) === null || _c === void 0 ? void 0 : _c.mappings) === null || _d === void 0 ? void 0 : _d.core) === null || _e === void 0 ? void 0 : _e.name) || '', src: ((_j = (_h = (_g = (((_f = comparisonItem === null || comparisonItem === void 0 ? void 0 : comparisonItem.result) === null || _f === void 0 ? void 0 : _f.display) || (comparisonItem === null || comparisonItem === void 0 ? void 0 : comparisonItem.result))) === null || _g === void 0 ? void 0 : _g.mappings) === null || _h === void 0 ? void 0 : _h.core) === null || _j === void 0 ? void 0 : _j.imageUrl) ||
|
|
645
|
+
((_o = (_m = (_l = (((_k = comparisonItem === null || comparisonItem === void 0 ? void 0 : comparisonItem.result) === null || _k === void 0 ? void 0 : _k.display) || (comparisonItem === null || comparisonItem === void 0 ? void 0 : comparisonItem.result))) === null || _l === void 0 ? void 0 : _l.mappings) === null || _m === void 0 ? void 0 : _m.core) === null || _o === void 0 ? void 0 : _o.parentImageUrl) ||
|
|
646
|
+
'' }), (0, jsx_runtime_1.jsx)("div", { className: "ss__chat__content__header__comparisons__content__comparison__remove", onClick: function () {
|
|
647
|
+
var _a;
|
|
648
|
+
(_a = store.currentChat) === null || _a === void 0 ? void 0 : _a.comparisons.remove(comparisonItem.result.id);
|
|
649
|
+
}, children: (0, jsx_runtime_1.jsx)(__1.Icon, { icon: 'close-thin', size: '12px' }) })] })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(__1.Icon, { icon: 'plus-thin' }), (0, jsx_runtime_1.jsx)("div", { className: 'ss__chat__content__header__comparisons__content__comparison--placeholder__text', children: "Add" })] })) }, index));
|
|
650
|
+
}) }), (0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)('ss__chat__content__header__comparisons__action', {
|
|
651
|
+
'ss__chat__content__header__comparisons__action--hidden': (((_s = store.currentChat) === null || _s === void 0 ? void 0 : _s.comparisons.compared.length) || 0) < 2,
|
|
652
|
+
}), children: (0, jsx_runtime_1.jsx)(Button_1.Button, { onClick: function () { return controller.search(); }, icon: { icon: 'compare', title: 'Compare' }, children: "Compare" }) })] })] })) }), (0, jsx_runtime_1.jsxs)("div", { className: 'ss__chat__messages', ref: messagesContainerRef, role: "log", "aria-live": "polite", "aria-relevant": "additions", "aria-label": "Chat messages", style: visibleChatLength ? { scrollbarGutter: 'stable' } : undefined, children: [(!((_t = store.currentChat) === null || _t === void 0 ? void 0 : _t.chat) || store.currentChat.chat.length === 0) && store.welcomeMessage && !((_u = store.currentChat) === null || _u === void 0 ? void 0 : _u.isExpired) && ((0, jsx_runtime_1.jsxs)("div", { className: "ss__chat__welcome", children: [(0, jsx_runtime_1.jsx)("div", { className: "ss__chat__welcome__message", children: store.welcomeMessage }), (0, jsx_runtime_1.jsx)(ChatSuggestedQuestions_1.ChatSuggestedQuestions, __assign({}, subProps.suggestedQuestions, { questions: store.suggestedQuestions, controller: controller }))] })), (_v = store.currentChat) === null || _v === void 0 ? void 0 : _v.chat.filter(function (chatItem) { return chatItem.messageType !== 'productQuery'; }).map(function (chatItem) {
|
|
653
|
+
var showAvatar = !!(avatarCharacter || avatarImage) && chatItem.messageType !== 'user';
|
|
654
|
+
var messageContent = {
|
|
655
|
+
user: ((0, jsx_runtime_1.jsx)(ChatMessageUser_1.ChatMessageUser, __assign({}, subProps.messageUser, { chatItem: chatItem, controller: controller, onProductQuickView: isMobile ? function () { return setMobileProductInfoOpen(true); } : undefined, primaryColor: colorPrimary, primaryColorText: colorPrimaryText }))),
|
|
656
|
+
text: ((0, jsx_runtime_1.jsx)(ChatMessageText_1.ChatMessageText, __assign({}, subProps.messageText, { chatItem: chatItem, controller: controller, scrollToBottom: scrollToBottomIfNear, onProductQuickView: isMobile ? function () { return setMobileProductInfoOpen(true); } : undefined, sideChatOpen: !!shouldShowSideChat, primaryColor: colorPrimary, primaryColorText: colorPrimaryText }))),
|
|
657
|
+
content: ((0, jsx_runtime_1.jsx)(ChatMessageText_1.ChatMessageText, __assign({}, subProps.messageText, { chatItem: chatItem, controller: controller, scrollToBottom: scrollToBottomIfNear, onProductQuickView: isMobile ? function () { return setMobileProductInfoOpen(true); } : undefined, sideChatOpen: !!shouldShowSideChat, primaryColor: colorPrimary, primaryColorText: colorPrimaryText }))),
|
|
658
|
+
productSearchResult: ((0, jsx_runtime_1.jsx)(ChatMessageText_1.ChatMessageText, __assign({}, subProps.messageText, { chatItem: chatItem, controller: controller, scrollToBottom: scrollToBottomIfNear, onProductQuickView: isMobile ? function () { return setMobileProductInfoOpen(true); } : undefined, sideChatOpen: !!shouldShowSideChat, primaryColor: colorPrimary, primaryColorText: colorPrimaryText }))),
|
|
659
|
+
inspirationResult: ((0, jsx_runtime_1.jsx)(ChatMessageText_1.ChatMessageText, __assign({}, subProps.messageText, { chatItem: chatItem, controller: controller, scrollToBottom: scrollToBottomIfNear, onProductQuickView: isMobile ? function () { return setMobileProductInfoOpen(true); } : undefined, sideChatOpen: !!shouldShowSideChat, primaryColor: colorPrimary, primaryColorText: colorPrimaryText }))),
|
|
660
|
+
productAnswer: ((0, jsx_runtime_1.jsx)(ChatMessageText_1.ChatMessageText, __assign({}, subProps.messageText, { chatItem: chatItem, controller: controller, scrollToBottom: scrollToBottomIfNear, onProductQuickView: isMobile ? function () { return setMobileProductInfoOpen(true); } : undefined, sideChatOpen: !!shouldShowSideChat, primaryColor: colorPrimary, primaryColorText: colorPrimaryText }))),
|
|
661
|
+
productComparison: (function () {
|
|
662
|
+
var _a;
|
|
663
|
+
// On mobile, only the first productComparison in the session
|
|
664
|
+
// auto-opens the secondary panel. Subsequent ones get a
|
|
665
|
+
// prominent "Show Details" button instead.
|
|
666
|
+
var comparisonMessages = (((_a = store.currentChat) === null || _a === void 0 ? void 0 : _a.chat) || []).filter(function (m) { return m.messageType === 'productComparison'; });
|
|
667
|
+
var isFirst = comparisonMessages.length > 0 && comparisonMessages[0].id === chatItem.id;
|
|
668
|
+
return ((0, jsx_runtime_1.jsx)(ChatMessageText_1.ChatMessageText, __assign({}, subProps.messageText, { chatItem: chatItem, controller: controller, scrollToBottom: scrollToBottomIfNear, onProductQuickView: isMobile ? function () { return setMobileProductInfoOpen(true); } : undefined, showDetailsButton: isMobile && !isFirst, sideChatOpen: !!shouldShowSideChat, primaryColor: colorPrimary, primaryColorText: colorPrimaryText })));
|
|
669
|
+
})(),
|
|
670
|
+
productRecommendation: ((0, jsx_runtime_1.jsx)(ChatMessageText_1.ChatMessageText, __assign({}, subProps.messageText, { chatItem: chatItem, controller: controller, scrollToBottom: scrollToBottomIfNear, onProductQuickView: isMobile ? function () { return setMobileProductInfoOpen(true); } : undefined, sideChatOpen: !!shouldShowSideChat, primaryColor: colorPrimary, primaryColorText: colorPrimaryText }))),
|
|
671
|
+
actions: ((0, jsx_runtime_1.jsx)(ChatSuggestedQuestions_1.ChatSuggestedQuestions, { actions: chatItem.actions, controller: controller })),
|
|
672
|
+
errorResponse: ((0, jsx_runtime_1.jsx)(ChatMessageText_1.ChatMessageText, __assign({}, subProps.messageText, { chatItem: chatItem, controller: controller, scrollToBottom: scrollToBottomIfNear, sideChatOpen: !!shouldShowSideChat, primaryColor: colorPrimary, primaryColorText: colorPrimaryText }))),
|
|
673
|
+
topicDrift: ((0, jsx_runtime_1.jsx)(ChatMessageText_1.ChatMessageText, __assign({}, subProps.messageText, { chatItem: chatItem, controller: controller, scrollToBottom: scrollToBottomIfNear, sideChatOpen: !!shouldShowSideChat, primaryColor: colorPrimary, primaryColorText: colorPrimaryText }))),
|
|
674
|
+
productQuery: null,
|
|
675
|
+
}[chatItem.messageType] || null;
|
|
676
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: (0, classnames_1.default)("ss__chat__message", "ss__chat__message--".concat(chatItem.messageType), {
|
|
677
|
+
'ss__chat__message--with-avatar': showAvatar,
|
|
678
|
+
}), children: [showAvatar && ((0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)('ss__chat__message__avatar', {
|
|
679
|
+
'ss__chat__message__avatar--image': !!avatarImage,
|
|
680
|
+
}), "aria-hidden": "true", children: avatarImage ? (0, jsx_runtime_1.jsx)(Image_1.Image, { src: avatarImage, alt: "" }) : avatarCharacter })), showAvatar ? (0, jsx_runtime_1.jsx)("div", { className: "ss__chat__message__content", children: messageContent }) : messageContent] }, chatItem.id));
|
|
681
|
+
}), (0, jsx_runtime_1.jsx)("div", { className: "ss__chat__messages__end", ref: messagesEndRef }), showNewMessages && messagesOverflow && ((0, jsx_runtime_1.jsxs)("div", { className: "ss__chat__new-messages", onClick: function () {
|
|
682
|
+
scrollToBottom();
|
|
683
|
+
setShowNewMessages(false);
|
|
684
|
+
}, children: [(0, jsx_runtime_1.jsx)(__1.Icon, { icon: "angle-down", size: "12px" }), (0, jsx_runtime_1.jsx)("span", { children: "New messages" })] }))] }), (0, jsx_runtime_1.jsx)(ChatLoadingIndicator_1.ChatLoadingIndicator, __assign({}, subProps.loadingIndicator, { loading: store.loading, verbs: loadingVerbs })), !((_w = store.currentChat) === null || _w === void 0 ? void 0 : _w.isExpired) ? ((0, jsx_runtime_1.jsxs)("div", __assign({ className: "ss__chat__content__footer", ref: footerRef }, dragHandlers, { children: [(store.error || store.chatEnabled === false) && ((0, jsx_runtime_1.jsx)("div", { className: "ss__chat__error", children: ((_x = store.error) === null || _x === void 0 ? void 0 : _x.message) || CHAT_UNAVAILABLE_MESSAGE })), ((_y = store.currentChat) === null || _y === void 0 ? void 0 : _y.sessionLimitReached) && ((0, jsx_runtime_1.jsxs)("div", { className: 'ss__chat__topic-drift', children: [(0, jsx_runtime_1.jsx)(__1.Icon, { icon: "info", size: "18px", className: 'ss__chat__topic-drift__icon--info' }), (0, jsx_runtime_1.jsxs)("div", { className: 'ss__chat__topic-drift__text', children: [(0, jsx_runtime_1.jsx)("span", { children: "Chat is currently unavailable due to high volume." }), (0, jsx_runtime_1.jsx)("span", { children: "In the meantime, feel free to use the search bar above to find what you need!" })] }), (0, jsx_runtime_1.jsx)(Button_1.Button, { className: 'ss__chat__topic-drift__button', onClick: function () {
|
|
685
|
+
controller.store.createChat();
|
|
686
|
+
}, children: "New Session" })] })), store.facets && store.facets.length > 0 && ((0, jsx_runtime_1.jsx)("div", { className: 'ss__chat__actions', children: (0, jsx_runtime_1.jsxs)("div", { className: "ss__chat__actions__wrap", children: [(0, jsx_runtime_1.jsxs)("div", { className: "ss__chat__actions__facets-header", children: [(0, jsx_runtime_1.jsx)("div", { className: "ss__chat__actions--title", children: "Filter by:" }), multiselectFacets && store.hasPendingFacetChanges && ((0, jsx_runtime_1.jsx)("div", { className: 'ss__chat__actions__facets-apply ss__chat__actions__facets-apply--active', children: (0, jsx_runtime_1.jsx)(Button_1.Button, { onClick: function () {
|
|
687
|
+
controller.search();
|
|
688
|
+
}, children: store.pendingFacetCount > 0 ? "Apply (".concat(store.pendingFacetCount, ")") : 'Clear facets' }) }))] }), (0, jsx_runtime_1.jsx)("div", { className: "ss__chat__actions--facets", children: store.facets.slice(0, 10).map(function (facet, idx) {
|
|
689
|
+
var _a;
|
|
690
|
+
// range/slider facets render via FacetSlider; everything else needs at least one value to be useful
|
|
691
|
+
if (facet.type !== 'range' && !((_a = facet.values) === null || _a === void 0 ? void 0 : _a.length))
|
|
692
|
+
return null;
|
|
693
|
+
if (facet.type === 'range') {
|
|
694
|
+
return (0, jsx_runtime_1.jsx)(SliderFacetDropdown, { facet: facet, label: getFacetButtonLabel(facet) }, idx);
|
|
695
|
+
}
|
|
696
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: "ss__chat__actions__facet ss__chat__actions__facet--".concat(facet.type), children: (0, jsx_runtime_1.jsx)(__1.Dropdown, { usePortal: true, dropUp: true, boundaryRef: chatRef, button: (0, jsx_runtime_1.jsx)(FacetButton, { label: getFacetButtonLabel(facet) }), style: {
|
|
697
|
+
'.ss__dropdown__content': __assign({ width: '150px', maxHeight: '200px', overflowY: 'auto', background: 'white', boxShadow: '0px 3px 6px 0px rgba(0, 0, 0, 0.2)', borderRadius: '6px' }, (multiselectFacets
|
|
698
|
+
? {
|
|
699
|
+
'.ss__chat__actions__facet__option--checkbox': {
|
|
700
|
+
display: 'flex',
|
|
701
|
+
alignItems: 'center',
|
|
702
|
+
gap: '8px',
|
|
703
|
+
padding: '6px 10px',
|
|
704
|
+
cursor: 'pointer',
|
|
705
|
+
width: '100%',
|
|
706
|
+
boxSizing: 'border-box',
|
|
707
|
+
background: '#fff',
|
|
708
|
+
border: 'none',
|
|
709
|
+
borderBottom: '1px solid #f0f0f0',
|
|
710
|
+
'&:hover': {
|
|
711
|
+
background: new utilities_1.Colour(colorPrimary).lightenHex(0.95),
|
|
712
|
+
},
|
|
713
|
+
'&:last-child': {
|
|
714
|
+
borderBottom: 'none',
|
|
715
|
+
},
|
|
716
|
+
'.ss__chat__actions__facet__option__checkbox': {
|
|
717
|
+
width: '16px',
|
|
718
|
+
height: '16px',
|
|
719
|
+
borderRadius: '3px',
|
|
720
|
+
border: '2px solid #ccc',
|
|
721
|
+
display: 'flex',
|
|
722
|
+
alignItems: 'center',
|
|
723
|
+
justifyContent: 'center',
|
|
724
|
+
flexShrink: 0,
|
|
725
|
+
'&.ss__chat__actions__facet__option__checkbox--checked': {
|
|
726
|
+
background: colorPrimary,
|
|
727
|
+
borderColor: colorPrimary,
|
|
728
|
+
color: colorPrimaryText,
|
|
729
|
+
svg: {
|
|
730
|
+
fill: colorPrimaryText,
|
|
731
|
+
stroke: colorPrimaryText,
|
|
732
|
+
},
|
|
733
|
+
},
|
|
734
|
+
},
|
|
735
|
+
'.ss__chat__actions__facet__option__label': {
|
|
736
|
+
fontSize: '14px',
|
|
737
|
+
color: '#333',
|
|
738
|
+
flex: '1 1 auto',
|
|
739
|
+
textAlign: 'left',
|
|
740
|
+
},
|
|
741
|
+
},
|
|
742
|
+
}
|
|
743
|
+
: {
|
|
744
|
+
'.ss__button': {
|
|
745
|
+
width: '100%',
|
|
746
|
+
border: 'none',
|
|
747
|
+
borderRadius: 0,
|
|
748
|
+
boxSizing: 'border-box',
|
|
749
|
+
background: '#fff',
|
|
750
|
+
'&:hover': {
|
|
751
|
+
background: new utilities_1.Colour(colorPrimary).lightenHex(0.95),
|
|
752
|
+
},
|
|
753
|
+
'&.ss__chat__actions__facet__option--selected': {
|
|
754
|
+
fontWeight: 'bold',
|
|
755
|
+
},
|
|
756
|
+
},
|
|
757
|
+
})),
|
|
758
|
+
}, children: (0, jsx_runtime_1.jsx)("div", { className: "ss__chat__actions__facet__options", children: facet.type === 'range-buckets'
|
|
759
|
+
? facet.values.map(function (option) {
|
|
760
|
+
var _a, _b;
|
|
761
|
+
var rangeOption = option;
|
|
762
|
+
var optionValue = "".concat((_a = rangeOption.low) !== null && _a !== void 0 ? _a : '*', ":").concat((_b = rangeOption.high) !== null && _b !== void 0 ? _b : '*');
|
|
763
|
+
if (multiselectFacets) {
|
|
764
|
+
var isSelected_1 = controller.store.isFacetSelected(facet.field, optionValue);
|
|
765
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "ss__chat__actions__facet__option--checkbox", onClick: function () {
|
|
766
|
+
if (isSelected_1) {
|
|
767
|
+
controller.store.removeFacet(facet.field, optionValue);
|
|
768
|
+
}
|
|
769
|
+
else {
|
|
770
|
+
controller.store.addFacet({
|
|
771
|
+
key: facet.field,
|
|
772
|
+
value: optionValue,
|
|
773
|
+
});
|
|
774
|
+
}
|
|
775
|
+
}, children: [(0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)('ss__chat__actions__facet__option__checkbox', {
|
|
776
|
+
'ss__chat__actions__facet__option__checkbox--checked': isSelected_1,
|
|
777
|
+
}), children: isSelected_1 && (0, jsx_runtime_1.jsx)(__1.Icon, { icon: "check-thin", size: "10px" }) }), (0, jsx_runtime_1.jsx)("span", { className: "ss__chat__actions__facet__option__label", children: rangeOption.label })] }, optionValue));
|
|
778
|
+
}
|
|
779
|
+
return ((0, jsx_runtime_1.jsx)(Button_1.Button, { className: (0, classnames_1.default)({
|
|
780
|
+
'ss__chat__actions__facet__option--selected': controller.store.isFacetSelected(facet.field, optionValue),
|
|
781
|
+
}), onClick: function () {
|
|
782
|
+
// Non-multiselect: clicking an already-selected value toggles it off.
|
|
783
|
+
// `addFacet` is idempotent against an existing urlManager value, so without
|
|
784
|
+
// the toggle the state wouldn't change, `hasPendingFacetChanges` would stay
|
|
785
|
+
// false, and the params getter would fall through to `general`.
|
|
786
|
+
if (controller.store.isFacetSelected(facet.field, optionValue)) {
|
|
787
|
+
controller.store.removeFacet(facet.field, optionValue);
|
|
788
|
+
}
|
|
789
|
+
else {
|
|
790
|
+
controller.store.addFacet({
|
|
791
|
+
key: facet.field,
|
|
792
|
+
value: optionValue,
|
|
793
|
+
});
|
|
794
|
+
}
|
|
795
|
+
// Force productSearch with the current filter state rather than relying
|
|
796
|
+
// on the params getter's hasPendingFacetChanges promotion — a facet click
|
|
797
|
+
// in the chat is unambiguously a search intent.
|
|
798
|
+
controller.search({
|
|
799
|
+
data: { requestType: 'productSearch', searchFilters: controller.store.searchFilters },
|
|
800
|
+
});
|
|
801
|
+
}, children: rangeOption.label }, optionValue));
|
|
802
|
+
})
|
|
803
|
+
: facet.values.map(function (option) {
|
|
804
|
+
var valueOption = option;
|
|
805
|
+
var optionValue = valueOption.value || valueOption.label;
|
|
806
|
+
if (multiselectFacets) {
|
|
807
|
+
var isSelected_2 = controller.store.isFacetSelected(facet.field, optionValue);
|
|
808
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "ss__chat__actions__facet__option--checkbox", onClick: function () {
|
|
809
|
+
if (isSelected_2) {
|
|
810
|
+
controller.store.removeFacet(facet.field, optionValue);
|
|
811
|
+
}
|
|
812
|
+
else {
|
|
813
|
+
controller.store.addFacet({
|
|
814
|
+
key: facet.field,
|
|
815
|
+
value: optionValue,
|
|
816
|
+
});
|
|
817
|
+
}
|
|
818
|
+
}, children: [(0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)('ss__chat__actions__facet__option__checkbox', {
|
|
819
|
+
'ss__chat__actions__facet__option__checkbox--checked': isSelected_2,
|
|
820
|
+
}), children: isSelected_2 && (0, jsx_runtime_1.jsx)(__1.Icon, { icon: "check-thin", size: "10px" }) }), (0, jsx_runtime_1.jsx)("span", { className: "ss__chat__actions__facet__option__label", children: valueOption.label })] }, optionValue));
|
|
821
|
+
}
|
|
822
|
+
return ((0, jsx_runtime_1.jsx)(Button_1.Button, { className: (0, classnames_1.default)({
|
|
823
|
+
'ss__chat__actions__facet__option--selected': controller.store.isFacetSelected(facet.field, optionValue),
|
|
824
|
+
}), onClick: function () {
|
|
825
|
+
// Non-multiselect: clicking an already-selected value toggles it off.
|
|
826
|
+
// `addFacet` is idempotent against an existing urlManager value, so without
|
|
827
|
+
// the toggle the state wouldn't change, `hasPendingFacetChanges` would stay
|
|
828
|
+
// false, and the params getter would fall through to `general`.
|
|
829
|
+
if (controller.store.isFacetSelected(facet.field, optionValue)) {
|
|
830
|
+
controller.store.removeFacet(facet.field, optionValue);
|
|
831
|
+
}
|
|
832
|
+
else {
|
|
833
|
+
controller.store.addFacet({
|
|
834
|
+
key: facet.field,
|
|
835
|
+
value: optionValue,
|
|
836
|
+
});
|
|
837
|
+
}
|
|
838
|
+
// Force productSearch with the current filter state rather than relying
|
|
839
|
+
// on the params getter's hasPendingFacetChanges promotion — a facet click
|
|
840
|
+
// in the chat is unambiguously a search intent.
|
|
841
|
+
controller.search({
|
|
842
|
+
data: { requestType: 'productSearch', searchFilters: controller.store.searchFilters },
|
|
843
|
+
});
|
|
844
|
+
}, children: valueOption.label }, optionValue));
|
|
845
|
+
}) }) }, facet.field) }, idx));
|
|
846
|
+
}) })] }) })), (function () {
|
|
847
|
+
var _a, _b, _c;
|
|
848
|
+
var activeComparisonSearchResults = shouldShowSideChat && (activeMessage === null || activeMessage === void 0 ? void 0 : activeMessage.messageType) === 'productComparison'
|
|
849
|
+
? activeMessage.searchResults || []
|
|
850
|
+
: null;
|
|
851
|
+
var showCommittedComparisons = !activeComparisonSearchResults &&
|
|
852
|
+
((_a = store.currentChat) === null || _a === void 0 ? void 0 : _a.comparisons.committed) &&
|
|
853
|
+
store.currentChat.comparisons.committed.length > 0 &&
|
|
854
|
+
((activeMessage === null || activeMessage === void 0 ? void 0 : activeMessage.messageType) === 'user' ||
|
|
855
|
+
(activeMessage === null || activeMessage === void 0 ? void 0 : activeMessage.messageType) === 'productComparison' ||
|
|
856
|
+
(activeMessage === null || activeMessage === void 0 ? void 0 : activeMessage.messageType) === 'productQuery');
|
|
857
|
+
var visibleAttachments = ((_b = store.currentChat) === null || _b === void 0 ? void 0 : _b.attachments.attached.filter(function (item) { return item.state === 'attached' || item.state === 'active' || item.state === 'loading' || item.state === 'error'; })) || [];
|
|
858
|
+
var productAttachments = visibleAttachments.filter(function (item) {
|
|
859
|
+
return item.type === 'product' &&
|
|
860
|
+
item.requestType !== 'productSimilar' &&
|
|
861
|
+
item.requestType !== 'productComparison';
|
|
862
|
+
});
|
|
863
|
+
var imageAttachments = visibleAttachments.filter(function (item) { return item.type === 'image'; });
|
|
864
|
+
var comparisonItems = activeComparisonSearchResults
|
|
865
|
+
? activeComparisonSearchResults.map(function (result) {
|
|
866
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
867
|
+
var d = (result === null || result === void 0 ? void 0 : result.display) || result;
|
|
868
|
+
return {
|
|
869
|
+
id: result === null || result === void 0 ? void 0 : result.id,
|
|
870
|
+
name: ((_b = (_a = d === null || d === void 0 ? void 0 : d.mappings) === null || _a === void 0 ? void 0 : _a.core) === null || _b === void 0 ? void 0 : _b.name) || '',
|
|
871
|
+
imageUrl: ((_d = (_c = d === null || d === void 0 ? void 0 : d.mappings) === null || _c === void 0 ? void 0 : _c.core) === null || _d === void 0 ? void 0 : _d.thumbnailImageUrl) || ((_f = (_e = d === null || d === void 0 ? void 0 : d.mappings) === null || _e === void 0 ? void 0 : _e.core) === null || _f === void 0 ? void 0 : _f.imageUrl) || ((_h = (_g = d === null || d === void 0 ? void 0 : d.mappings) === null || _g === void 0 ? void 0 : _g.core) === null || _h === void 0 ? void 0 : _h.parentImageUrl) || '',
|
|
872
|
+
onClick: function () {
|
|
873
|
+
controller.productQuickView(result);
|
|
874
|
+
if (isMobile)
|
|
875
|
+
setMobileProductInfoOpen(true);
|
|
876
|
+
},
|
|
877
|
+
};
|
|
878
|
+
})
|
|
879
|
+
: showCommittedComparisons
|
|
880
|
+
? (((_c = store.currentChat) === null || _c === void 0 ? void 0 : _c.comparisons.committed) || []).map(function (comparisonItem) {
|
|
881
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
882
|
+
var d = ((_a = comparisonItem === null || comparisonItem === void 0 ? void 0 : comparisonItem.result) === null || _a === void 0 ? void 0 : _a.display) || (comparisonItem === null || comparisonItem === void 0 ? void 0 : comparisonItem.result);
|
|
883
|
+
return {
|
|
884
|
+
id: (_b = comparisonItem.result) === null || _b === void 0 ? void 0 : _b.id,
|
|
885
|
+
name: ((_d = (_c = d === null || d === void 0 ? void 0 : d.mappings) === null || _c === void 0 ? void 0 : _c.core) === null || _d === void 0 ? void 0 : _d.name) || '',
|
|
886
|
+
imageUrl: ((_f = (_e = d === null || d === void 0 ? void 0 : d.mappings) === null || _e === void 0 ? void 0 : _e.core) === null || _f === void 0 ? void 0 : _f.thumbnailImageUrl) || ((_h = (_g = d === null || d === void 0 ? void 0 : d.mappings) === null || _g === void 0 ? void 0 : _g.core) === null || _h === void 0 ? void 0 : _h.imageUrl) || ((_k = (_j = d === null || d === void 0 ? void 0 : d.mappings) === null || _j === void 0 ? void 0 : _j.core) === null || _k === void 0 ? void 0 : _k.parentImageUrl) || '',
|
|
887
|
+
onClick: function () {
|
|
888
|
+
controller.productQuickView(comparisonItem.result);
|
|
889
|
+
if (isMobile)
|
|
890
|
+
setMobileProductInfoOpen(true);
|
|
891
|
+
},
|
|
892
|
+
};
|
|
893
|
+
})
|
|
894
|
+
: [];
|
|
895
|
+
var productItems = productAttachments.map(function (item) {
|
|
896
|
+
var remove = function () {
|
|
897
|
+
var _a, _b;
|
|
898
|
+
(_a = store.currentChat) === null || _a === void 0 ? void 0 : _a.attachments.remove(item.id);
|
|
899
|
+
setMobileProductInfoOpen(false);
|
|
900
|
+
(_b = store.currentChat) === null || _b === void 0 ? void 0 : _b.dismissSideChat();
|
|
901
|
+
};
|
|
902
|
+
return {
|
|
903
|
+
id: item.id,
|
|
904
|
+
name: item.name || '',
|
|
905
|
+
imageUrl: item.thumbnailUrl || '',
|
|
906
|
+
onClick: remove,
|
|
907
|
+
onRemove: remove,
|
|
908
|
+
};
|
|
909
|
+
});
|
|
910
|
+
var imageItems = imageAttachments.map(function (item) {
|
|
911
|
+
var _a;
|
|
912
|
+
return ({
|
|
913
|
+
id: item.id,
|
|
914
|
+
name: item.fileName || 'Image',
|
|
915
|
+
imageUrl: item.base64 || item.thumbnailUrl || '',
|
|
916
|
+
isLoading: item.state === 'loading',
|
|
917
|
+
hasError: !!item.error,
|
|
918
|
+
errorMessage: (_a = item.error) === null || _a === void 0 ? void 0 : _a.message,
|
|
919
|
+
onRemove: function () { var _a; return (_a = store.currentChat) === null || _a === void 0 ? void 0 : _a.attachments.remove(item.id); },
|
|
920
|
+
});
|
|
921
|
+
});
|
|
922
|
+
var productTitle = productItems.length > 1 ? 'Compare these products' : 'Ask about this product';
|
|
923
|
+
var hasImageError = imageItems.some(function (item) { return item.hasError; });
|
|
924
|
+
var imageTitle = imageItems.length > 0 && !hasImageError ? 'Find products similar to this image:' : '';
|
|
925
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [comparisonItems.length > 0 && ((0, jsx_runtime_1.jsx)(ChatAttachmentContext_1.ChatAttachmentContext, __assign({}, subProps.attachmentContext, { title: 'Compare these products', items: comparisonItems, onClose: function () {
|
|
926
|
+
var _a, _b;
|
|
927
|
+
(_a = store.currentChat) === null || _a === void 0 ? void 0 : _a.comparisons.resetCommitted();
|
|
928
|
+
(_b = store.currentChat) === null || _b === void 0 ? void 0 : _b.dismissSideChat();
|
|
929
|
+
} }))), productItems.length > 0 && ((0, jsx_runtime_1.jsx)(ChatAttachmentContext_1.ChatAttachmentContext, __assign({}, subProps.attachmentContext, { title: productTitle, items: productItems, onClose: function () {
|
|
930
|
+
var _a;
|
|
931
|
+
productAttachments.forEach(function (item) { var _a; return (_a = store.currentChat) === null || _a === void 0 ? void 0 : _a.attachments.remove(item.id); });
|
|
932
|
+
setMobileProductInfoOpen(false);
|
|
933
|
+
(_a = store.currentChat) === null || _a === void 0 ? void 0 : _a.dismissSideChat();
|
|
934
|
+
} }))), imageItems.length > 0 && (0, jsx_runtime_1.jsx)(ChatAttachmentContext_1.ChatAttachmentContext, __assign({}, subProps.attachmentContext, { title: imageTitle, items: imageItems }))] }));
|
|
935
|
+
})(), (function () {
|
|
936
|
+
var _a;
|
|
937
|
+
var drift = (_a = store.currentChat) === null || _a === void 0 ? void 0 : _a.topicDrift;
|
|
938
|
+
if (!drift)
|
|
939
|
+
return null;
|
|
940
|
+
// recommendedAction is the prescription; driftType is the diagnosis.
|
|
941
|
+
// Hide the banner when the backend says to keep flowing, or when no drift was detected.
|
|
942
|
+
if (drift.recommendedAction === 'CONTINUE' || drift.driftType === 'NO_DRIFT')
|
|
943
|
+
return null;
|
|
944
|
+
var isScopeRedirect = drift.recommendedAction === 'SCOPE_REDIRECT';
|
|
945
|
+
var primaryText = isScopeRedirect ? "I'm here to help with shopping" : 'Looking for something new?';
|
|
946
|
+
var secondaryText = isScopeRedirect
|
|
947
|
+
? 'Try asking about products, comparisons, or recommendations'
|
|
948
|
+
: 'Start a fresh session for better assistance, or keep going in this one?';
|
|
949
|
+
var buttonText = isScopeRedirect ? '' : 'New Session';
|
|
950
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: 'ss__chat__topic-drift', children: [(0, jsx_runtime_1.jsx)(__1.Icon, { icon: "info", size: "18px", className: 'ss__chat__topic-drift__icon--info' }), (0, jsx_runtime_1.jsxs)("div", { className: 'ss__chat__topic-drift__text', children: [(0, jsx_runtime_1.jsx)("span", { children: primaryText }), (0, jsx_runtime_1.jsx)("span", { children: secondaryText })] }), buttonText && ((0, jsx_runtime_1.jsx)(Button_1.Button, { className: 'ss__chat__topic-drift__button', onClick: function () {
|
|
951
|
+
var _a, _b, _c;
|
|
952
|
+
if (isScopeRedirect) {
|
|
953
|
+
(_a = store.currentChat) === null || _a === void 0 ? void 0 : _a.dismissTopicDrift();
|
|
954
|
+
return;
|
|
955
|
+
}
|
|
956
|
+
// Capture image attachments from the current chat before handleTopicDrift /
|
|
957
|
+
// createChat tear down the conversation — an imageSearch that drifted needs
|
|
958
|
+
// the same image attached to the carried-over message in the new session,
|
|
959
|
+
// otherwise params would fall back to a `general` request without the image.
|
|
960
|
+
var previousImageAttachments = (((_b = store.currentChat) === null || _b === void 0 ? void 0 : _b.attachments.attached) || [])
|
|
961
|
+
.filter(function (item) { return item.type === 'image' && item.state !== 'error'; })
|
|
962
|
+
.map(function (item) {
|
|
963
|
+
var img = item;
|
|
964
|
+
return {
|
|
965
|
+
type: 'image',
|
|
966
|
+
base64: img.base64,
|
|
967
|
+
fileName: img.fileName,
|
|
968
|
+
imageId: img.imageId,
|
|
969
|
+
imageUrl: img.imageUrl,
|
|
970
|
+
thumbnailUrl: img.thumbnailUrl,
|
|
971
|
+
// Already uploaded — skip the 'loading' default state.
|
|
972
|
+
state: 'attached',
|
|
973
|
+
};
|
|
974
|
+
});
|
|
975
|
+
var messageText = (_c = store.currentChat) === null || _c === void 0 ? void 0 : _c.handleTopicDrift();
|
|
976
|
+
if (messageText) {
|
|
977
|
+
controller.store.createChat();
|
|
978
|
+
previousImageAttachments.forEach(function (cfg) {
|
|
979
|
+
var _a;
|
|
980
|
+
(_a = controller.store.currentChat) === null || _a === void 0 ? void 0 : _a.attachments.add(cfg);
|
|
981
|
+
});
|
|
982
|
+
controller.search({ data: { message: messageText } });
|
|
983
|
+
}
|
|
984
|
+
}, children: buttonText })), (0, jsx_runtime_1.jsx)("span", { onClick: function () {
|
|
985
|
+
var _a;
|
|
986
|
+
(_a = store.currentChat) === null || _a === void 0 ? void 0 : _a.dismissTopicDrift();
|
|
987
|
+
}, children: (0, jsx_runtime_1.jsx)(__1.Icon, { icon: "close-thin", size: "14px", className: 'ss__chat__topic-drift__icon--close' }) })] }));
|
|
988
|
+
})(), (0, jsx_runtime_1.jsxs)("div", { className: 'ss__chat__input', children: [(0, jsx_runtime_1.jsxs)("div", { className: 'ss__chat__input__input', children: [(0, jsx_runtime_1.jsx)("input", { type: "text", name: "ss-chat-input", disabled: store.loading || store.blocked || ((_z = store.currentChat) === null || _z === void 0 ? void 0 : _z.sessionLimitReached) || store.chatEnabled === false, placeholder: (function () {
|
|
989
|
+
var _a, _b, _c;
|
|
990
|
+
var comparedCount = ((_a = store.currentChat) === null || _a === void 0 ? void 0 : _a.comparisons.compared.length) || 0;
|
|
991
|
+
var committedCount = ((_b = store.currentChat) === null || _b === void 0 ? void 0 : _b.comparisons.committed.length) || 0;
|
|
992
|
+
var attached = ((_c = store.currentChat) === null || _c === void 0 ? void 0 : _c.attachments.attached.filter(function (item) { return item.state === 'attached' || item.state === 'active'; })) || [];
|
|
993
|
+
var attachedProducts = attached.filter(function (item) { return item.type === 'product'; });
|
|
994
|
+
var attachedImages = attached.filter(function (item) { return item.type === 'image' && !item.error; });
|
|
995
|
+
if (attachedProducts.length === 1) {
|
|
996
|
+
return 'Ask about this product...';
|
|
997
|
+
}
|
|
998
|
+
if (comparedCount > 1 || attachedProducts.length > 1) {
|
|
999
|
+
return 'What would you like to compare?';
|
|
1000
|
+
}
|
|
1001
|
+
if (committedCount > 0) {
|
|
1002
|
+
return 'Ask about the compared products...';
|
|
1003
|
+
}
|
|
1004
|
+
if (attachedImages.length > 0) {
|
|
1005
|
+
return 'Ask about this image...';
|
|
1006
|
+
}
|
|
1007
|
+
if (comparedCount === 1) {
|
|
1008
|
+
return 'Add another product to compare...';
|
|
1009
|
+
}
|
|
1010
|
+
return 'Type your message...';
|
|
1011
|
+
})(), onInput: function (e) { return controller.handlers.input.input(e); }, onKeyDown: function (e) {
|
|
1012
|
+
controller.handlers.input.enterKey(e);
|
|
1013
|
+
if (e.keyCode === 13 && isMobile && mobileProductInfoOpen) {
|
|
1014
|
+
setMobileProductInfoOpen(false);
|
|
1015
|
+
}
|
|
1016
|
+
}, value: controller.store.inputValue }), store.features.imageSearch.enabled && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Button_1.Button, { className: 'ss__chat__upload-button', disabled: store.loading || store.blocked || ((_0 = store.currentChat) === null || _0 === void 0 ? void 0 : _0.sessionLimitReached) || store.chatEnabled === false, onClick: function () { var _a; return (_a = fileInputRef.current) === null || _a === void 0 ? void 0 : _a.click(); }, icon: { icon: 'image', title: 'Upload Image' } }), (0, jsx_runtime_1.jsx)("input", { ref: fileInputRef, onChange: function (e) { return __awaiter(void 0, void 0, void 0, function () {
|
|
1017
|
+
return __generator(this, function (_a) {
|
|
1018
|
+
switch (_a.label) {
|
|
1019
|
+
case 0: return [4 /*yield*/, controller.upload(e.target.files)];
|
|
1020
|
+
case 1:
|
|
1021
|
+
_a.sent();
|
|
1022
|
+
// reset value
|
|
1023
|
+
e.target.value = '';
|
|
1024
|
+
return [2 /*return*/];
|
|
1025
|
+
}
|
|
1026
|
+
});
|
|
1027
|
+
}); }, type: "file", accept: "image/*", className: "ss__chat__input__input__file" })] }))] }), (0, jsx_runtime_1.jsx)("div", { className: 'ss__chat__input__actions', children: (function () {
|
|
1028
|
+
var _a, _b;
|
|
1029
|
+
var hasImageAttachment = (((_a = store.currentChat) === null || _a === void 0 ? void 0 : _a.attachments.attached) || []).some(function (item) { return item.type === 'image' && !item.error; });
|
|
1030
|
+
var messageEmpty = !controller.store.inputValue.trim();
|
|
1031
|
+
var sendDisabled = store.blocked ||
|
|
1032
|
+
((_b = store.currentChat) === null || _b === void 0 ? void 0 : _b.sessionLimitReached) ||
|
|
1033
|
+
store.chatEnabled === false ||
|
|
1034
|
+
(hasImageAttachment && messageEmpty) ||
|
|
1035
|
+
messageEmpty;
|
|
1036
|
+
return ((0, jsx_runtime_1.jsx)(Button_1.Button, { className: "ss__chat__send-button", icon: { icon: 'send', title: 'Send Message' }, disabled: sendDisabled, onClick: function () {
|
|
1037
|
+
if (sendDisabled)
|
|
1038
|
+
return;
|
|
1039
|
+
controller.search();
|
|
1040
|
+
if (isMobile && mobileProductInfoOpen) {
|
|
1041
|
+
setMobileProductInfoOpen(false);
|
|
1042
|
+
}
|
|
1043
|
+
} }));
|
|
1044
|
+
})() })] }), (0, jsx_runtime_1.jsx)("div", { className: 'ss__chat__disclaimer', children: (0, jsx_runtime_1.jsxs)("i", { children: ["Powered by Athos Commerce. AI-powered assistant. It sometimes make mistakes. Avoid sharing personal data.", ' ', (0, jsx_runtime_1.jsx)("a", { href: "https://athoscommerce.com/legal/privacy-policy/", target: "_blank", rel: "noopener noreferrer", children: "Privacy Policy" })] }) }), isDraggingFile && ((0, jsx_runtime_1.jsxs)("div", { className: "ss__chat__content__footer__drop-overlay", children: [(0, jsx_runtime_1.jsx)(__1.Icon, { icon: "image", size: "24px" }), (0, jsx_runtime_1.jsx)("span", { children: "Drop image to upload" })] }))] }))) : ((0, jsx_runtime_1.jsxs)("div", { className: 'ss__chat__expired', children: [(0, jsx_runtime_1.jsx)("div", { className: 'ss__chat__expired__message', children: "This chat is expired. Please start a new chat." }), (0, jsx_runtime_1.jsx)(Button_1.Button, { className: 'ss__chat__expired__button', onClick: function () {
|
|
1045
|
+
controller.store.createChat();
|
|
1046
|
+
}, children: "New Session" })] }))] })] })) : null] })), (0, jsx_runtime_1.jsx)(__1.Overlay, { style: { zIndex: 1001 }, color: "transparent", active: store.open, onClick: function () { return controller.handlers.button.click(); } })] }) }));
|
|
1047
|
+
});
|