@athoscommerce/snap-preact 1.4.0 → 1.5.1-beta.110
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 +1 -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 +30 -13
- 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 +2 -2
- 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 +186 -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 +124 -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 +18 -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 +183 -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 +15 -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 +122 -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 +474 -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 +189 -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 +133 -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 +14 -8
- package/dist/cjs/components/src/components/Molecules/SearchInput/SearchInput.d.ts +6 -1
- package/dist/cjs/components/src/components/Molecules/SearchInput/SearchInput.d.ts.map +1 -1
- package/dist/cjs/components/src/components/Molecules/SearchInput/SearchInput.js +20 -3
- package/dist/cjs/components/src/components/Molecules/Slideout/Slideout.d.ts.map +1 -1
- package/dist/cjs/components/src/components/Molecules/Slideout/Slideout.js +30 -12
- package/dist/cjs/components/src/components/Organisms/Chat/Chat.d.ts +27 -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 +815 -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 +1090 -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 +87 -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/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/everest/components/templates/chat.d.ts +4 -0
- package/dist/cjs/components/src/themes/everest/components/templates/chat.d.ts.map +1 -0
- package/dist/cjs/components/src/themes/everest/components/templates/chat.js +6 -0
- package/dist/cjs/components/src/themes/everest/components/templates/index.d.ts.map +1 -1
- package/dist/cjs/components/src/themes/everest/components/templates/index.js +5 -4
- package/dist/cjs/components/src/themes/matterhorn/components/templates/chat.d.ts +4 -0
- package/dist/cjs/components/src/themes/matterhorn/components/templates/chat.d.ts.map +1 -0
- package/dist/cjs/components/src/themes/matterhorn/components/templates/chat.js +6 -0
- package/dist/cjs/components/src/themes/matterhorn/components/templates/index.d.ts.map +1 -1
- package/dist/cjs/components/src/themes/matterhorn/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/Instantiators/RecommendationInstantiator.d.ts +1 -0
- package/dist/cjs/src/Instantiators/RecommendationInstantiator.d.ts.map +1 -1
- package/dist/cjs/src/Instantiators/RecommendationInstantiator.js +161 -123
- package/dist/cjs/src/Snap.d.ts +3 -2
- package/dist/cjs/src/Snap.d.ts.map +1 -1
- package/dist/cjs/src/Snap.js +142 -30
- 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 -7
- package/dist/cjs/src/Templates/Stores/LibraryStore.d.ts +4 -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 +21 -6
- 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 +1 -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 +33 -9
- 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 +168 -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 +118 -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 +18 -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 +164 -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 +15 -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 +100 -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 +449 -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 +171 -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 +112 -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 +6 -1
- package/dist/esm/components/src/components/Molecules/SearchInput/SearchInput.d.ts.map +1 -1
- package/dist/esm/components/src/components/Molecules/SearchInput/SearchInput.js +36 -3
- package/dist/esm/components/src/components/Molecules/Slideout/Slideout.d.ts.map +1 -1
- package/dist/esm/components/src/components/Molecules/Slideout/Slideout.js +30 -12
- package/dist/esm/components/src/components/Organisms/Chat/Chat.d.ts +27 -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 +726 -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 +1105 -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 +81 -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/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/everest/components/templates/chat.d.ts +4 -0
- package/dist/esm/components/src/themes/everest/components/templates/chat.d.ts.map +1 -0
- package/dist/esm/components/src/themes/everest/components/templates/chat.js +3 -0
- package/dist/esm/components/src/themes/everest/components/templates/index.d.ts.map +1 -1
- package/dist/esm/components/src/themes/everest/components/templates/index.js +5 -0
- package/dist/esm/components/src/themes/matterhorn/components/templates/chat.d.ts +4 -0
- package/dist/esm/components/src/themes/matterhorn/components/templates/chat.d.ts.map +1 -0
- package/dist/esm/components/src/themes/matterhorn/components/templates/chat.js +3 -0
- package/dist/esm/components/src/themes/matterhorn/components/templates/index.d.ts.map +1 -1
- package/dist/esm/components/src/themes/matterhorn/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/Instantiators/RecommendationInstantiator.d.ts +1 -0
- package/dist/esm/src/Instantiators/RecommendationInstantiator.d.ts.map +1 -1
- package/dist/esm/src/Instantiators/RecommendationInstantiator.js +130 -84
- package/dist/esm/src/Snap.d.ts +3 -2
- package/dist/esm/src/Snap.d.ts.map +1 -1
- package/dist/esm/src/Snap.js +80 -6
- 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 +61 -6
- package/dist/esm/src/Templates/Stores/LibraryStore.d.ts +4 -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 +21 -6
- 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 +13 -12
|
@@ -0,0 +1,726 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import classnames from 'classnames';
|
|
3
|
+
import deepmerge from 'deepmerge';
|
|
4
|
+
import { observer } from 'mobx-react-lite';
|
|
5
|
+
import { useTheme, CacheProvider, useTreePath } from '../../../providers';
|
|
6
|
+
import { Colour, mergeProps, mergeStyles } from '../../../utilities';
|
|
7
|
+
import { chatDefaultStyles } from './Chat.styles';
|
|
8
|
+
import { useChatGestures } from './hooks/useChatGestures';
|
|
9
|
+
import { useChatOverflow } from './hooks/useChatOverflow';
|
|
10
|
+
import { useChatFileUpload } from './hooks/useChatFileUpload';
|
|
11
|
+
import { Button } from '../../Atoms/Button';
|
|
12
|
+
import { useRef, useEffect, useMemo, useState } from 'preact/hooks';
|
|
13
|
+
import { ChatMessageUser } from '../../Molecules/ChatMessageUser';
|
|
14
|
+
import { ChatMessageText } from '../../Molecules/ChatMessageText';
|
|
15
|
+
import { ChatSuggestedQuestions } from '../../Molecules/ChatSuggestedQuestions';
|
|
16
|
+
import { ChatAttachmentContext } from '../../Molecules/ChatAttachmentContext';
|
|
17
|
+
import { Image } from '../../Atoms/Image';
|
|
18
|
+
import { ChatLoadingIndicator } from '../../Atoms/ChatLoadingIndicator';
|
|
19
|
+
import { Dropdown, FacetSlider, Icon, Overlay, useMediaQuery } from '../../..';
|
|
20
|
+
import { ChatInspirationResultMessage } from '../../Molecules/ChatInspirationResultMessage';
|
|
21
|
+
import { ChatProductComparisonMessage, } from '../../Molecules/ChatProductComparisonMessage/ChatProductComparisonMessage';
|
|
22
|
+
import { ChatProductQueryMessage, } from '../../Molecules/ChatProductQueryMessage/ChatProductQueryMessage';
|
|
23
|
+
export const ChatOrganism = observer((properties) => {
|
|
24
|
+
const globalTheme = useTheme();
|
|
25
|
+
const globalTreePath = useTreePath();
|
|
26
|
+
const isMobile = useMediaQuery('(max-width: 767px)');
|
|
27
|
+
const defaultProps = {
|
|
28
|
+
treePath: globalTreePath,
|
|
29
|
+
logo: 'https://cdn.athoscommerce.net/snap/images/Athos%20Commerce_Icon_white.svg',
|
|
30
|
+
title: 'Athos Conversational Assistant',
|
|
31
|
+
subtitle: 'Your Guided Discovery Expert',
|
|
32
|
+
multiselectFacets: true,
|
|
33
|
+
disableBubbleSuggestedQuestions: isMobile ? true : false,
|
|
34
|
+
primaryColorBg: '#253B80',
|
|
35
|
+
primaryColorFg: '#fff',
|
|
36
|
+
primaryAccentColorBg: '#feeeae',
|
|
37
|
+
primaryAccentColorFg: '#000000',
|
|
38
|
+
secondaryAccentColorBg: '#000000',
|
|
39
|
+
secondaryAccentColorFg: '#ffffff',
|
|
40
|
+
position: 'right',
|
|
41
|
+
};
|
|
42
|
+
let props = mergeProps('chat', globalTheme, defaultProps, properties);
|
|
43
|
+
const { className, internalClassName, controller, logo, title, subtitle, offset, multiselectFacets, disableBubbleSuggestedQuestions, primaryColorBg, primaryColorFg, primaryAccentColorBg, primaryAccentColorFg, secondaryAccentColorBg, secondaryAccentColorFg, position, disableStyles, treePath, } = props;
|
|
44
|
+
const colorPrimary = primaryColorBg;
|
|
45
|
+
const colorPrimaryText = primaryColorFg;
|
|
46
|
+
const colorPrimaryAccent = primaryAccentColorBg;
|
|
47
|
+
const colorPrimaryAccentText = primaryAccentColorFg;
|
|
48
|
+
const colorSecondaryAccent = secondaryAccentColorBg;
|
|
49
|
+
const colorSecondaryAccentText = secondaryAccentColorFg;
|
|
50
|
+
const chatPosition = position === 'right' ? 'right' : 'left';
|
|
51
|
+
const { store } = controller;
|
|
52
|
+
const themeDefaults = {
|
|
53
|
+
components: {},
|
|
54
|
+
};
|
|
55
|
+
// merge deeply the themeDefaults with the theme props and the displaySettings theme props (do not merge arrays, but replace them)
|
|
56
|
+
const theme = deepmerge(themeDefaults, props?.theme || {}, { arrayMerge: (destinationArray, sourceArray) => sourceArray });
|
|
57
|
+
props = {
|
|
58
|
+
...props,
|
|
59
|
+
theme,
|
|
60
|
+
};
|
|
61
|
+
const subProps = {
|
|
62
|
+
messageUser: {
|
|
63
|
+
disableStyles,
|
|
64
|
+
theme: props.theme,
|
|
65
|
+
treePath,
|
|
66
|
+
primaryColor: colorPrimary,
|
|
67
|
+
primaryColorText: colorPrimaryText,
|
|
68
|
+
},
|
|
69
|
+
messageText: {
|
|
70
|
+
disableStyles,
|
|
71
|
+
theme: props.theme,
|
|
72
|
+
treePath,
|
|
73
|
+
primaryColor: colorPrimary,
|
|
74
|
+
primaryColorText: colorPrimaryText,
|
|
75
|
+
},
|
|
76
|
+
suggestedQuestions: {
|
|
77
|
+
disableStyles,
|
|
78
|
+
theme: props.theme,
|
|
79
|
+
treePath,
|
|
80
|
+
primaryColor: colorPrimary,
|
|
81
|
+
},
|
|
82
|
+
attachmentContext: {
|
|
83
|
+
disableStyles,
|
|
84
|
+
theme: props.theme,
|
|
85
|
+
treePath,
|
|
86
|
+
},
|
|
87
|
+
loadingIndicator: {
|
|
88
|
+
disableStyles,
|
|
89
|
+
theme: props.theme,
|
|
90
|
+
treePath,
|
|
91
|
+
},
|
|
92
|
+
inspirationResultMessage: {
|
|
93
|
+
disableStyles,
|
|
94
|
+
theme: props.theme,
|
|
95
|
+
treePath,
|
|
96
|
+
},
|
|
97
|
+
productComparisonMessage: {
|
|
98
|
+
disableStyles,
|
|
99
|
+
theme: props.theme,
|
|
100
|
+
treePath,
|
|
101
|
+
},
|
|
102
|
+
productQueryMessage: {
|
|
103
|
+
disableStyles,
|
|
104
|
+
theme: props.theme,
|
|
105
|
+
treePath,
|
|
106
|
+
primaryColor: colorPrimary,
|
|
107
|
+
primaryColorText: colorPrimaryText,
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
const messagesEndRef = useRef(null);
|
|
111
|
+
const messagesContainerRef = useRef(null);
|
|
112
|
+
const headerRef = useRef(null);
|
|
113
|
+
const footerRef = useRef(null);
|
|
114
|
+
const chatRef = useRef(null);
|
|
115
|
+
// Ref for the mobile secondary panel — needed for swipe-to-dismiss measurements
|
|
116
|
+
const secondaryRef = useRef(null);
|
|
117
|
+
const [mobileProductInfoOpen, setMobileProductInfoOpen] = useState(false);
|
|
118
|
+
const [footerHeight, setFooterHeight] = useState(0);
|
|
119
|
+
const dropEnabled = store.features.imageSearch.enabled && !store.loading && !store.blocked && !store.currentChat?.sessionLimitReached;
|
|
120
|
+
const { fileInputRef, isDraggingFile, dragHandlers } = useChatFileUpload({
|
|
121
|
+
enabled: !!dropEnabled,
|
|
122
|
+
onUpload: (files) => controller.upload(files),
|
|
123
|
+
});
|
|
124
|
+
// productQuery messages are filtered out of the main chat render (they only drive the side-chat panel),
|
|
125
|
+
// so don't auto-scroll when one is added — otherwise clicking a product in the side chat scrolls the main thread.
|
|
126
|
+
const visibleChat = (store.currentChat?.chat || []).filter((m) => m.messageType !== 'productQuery');
|
|
127
|
+
const visibleChatLength = visibleChat.length;
|
|
128
|
+
const lastVisibleMessage = visibleChat[visibleChat.length - 1];
|
|
129
|
+
const { showNewMessages, setShowNewMessages, messagesOverflow, scrollToBottom, scrollToBottomIfNear } = useChatOverflow({
|
|
130
|
+
messagesContainerRef,
|
|
131
|
+
headerRef,
|
|
132
|
+
open: store.open,
|
|
133
|
+
loading: store.loading,
|
|
134
|
+
visibleChatLength,
|
|
135
|
+
lastVisibleMessage,
|
|
136
|
+
});
|
|
137
|
+
// Re-focus the chat input on desktop after a search completes.
|
|
138
|
+
// The input is disabled while loading, which causes the browser to drop focus.
|
|
139
|
+
// On mobile we intentionally skip this so the virtual keyboard dismisses.
|
|
140
|
+
useEffect(() => {
|
|
141
|
+
if (!store.loading && !isMobile && store.open) {
|
|
142
|
+
controller.focusInput();
|
|
143
|
+
}
|
|
144
|
+
}, [store.loading]);
|
|
145
|
+
// const subProps: ChatSubProps = {};
|
|
146
|
+
const activeMessage = store.currentChat?.activeMessage;
|
|
147
|
+
// On mobile, only auto-open the secondary panel for the first productComparison
|
|
148
|
+
// message in the chat session. Subsequent comparison results show a "Show Details"
|
|
149
|
+
// button instead (handled in MessageText via sideChatLabel toggle).
|
|
150
|
+
const isFirstMobileComparison = (() => {
|
|
151
|
+
if (!isMobile || activeMessage?.messageType !== 'productComparison')
|
|
152
|
+
return true;
|
|
153
|
+
// If the user explicitly activated a comparison (via "Show Details" or the
|
|
154
|
+
// view-side-chat button), always allow it regardless of position in the chat
|
|
155
|
+
if (store.currentChat?.activeMessageId)
|
|
156
|
+
return true;
|
|
157
|
+
const comparisonMessages = (store.currentChat?.chat || []).filter((m) => m.messageType === 'productComparison');
|
|
158
|
+
return comparisonMessages.length <= 1;
|
|
159
|
+
})();
|
|
160
|
+
const sideChatTypes = isMobile
|
|
161
|
+
? ['inspirationResult', ...(isFirstMobileComparison ? ['productComparison'] : []), ...(mobileProductInfoOpen ? ['productQuery'] : [])]
|
|
162
|
+
: ['inspirationResult', 'productComparison', 'productQuery'];
|
|
163
|
+
const shouldShowSideChat = activeMessage && sideChatTypes.includes(activeMessage?.messageType) && store.currentChat?.dismissedSideChatMessageId !== activeMessage.id;
|
|
164
|
+
const styling = mergeStyles({
|
|
165
|
+
mobile: isMobile,
|
|
166
|
+
offset,
|
|
167
|
+
hasSideChat: !!shouldShowSideChat,
|
|
168
|
+
footerHeight,
|
|
169
|
+
primaryColorBg: colorPrimary,
|
|
170
|
+
primaryColorFg: colorPrimaryText,
|
|
171
|
+
primaryAccentColorBg: colorPrimaryAccent,
|
|
172
|
+
primaryAccentColorFg: colorPrimaryAccentText,
|
|
173
|
+
secondaryAccentColorBg: colorSecondaryAccent,
|
|
174
|
+
secondaryAccentColorFg: colorSecondaryAccentText,
|
|
175
|
+
position: chatPosition,
|
|
176
|
+
}, chatDefaultStyles);
|
|
177
|
+
// Lock body scroll while chat is open so touch/wheel scrolls don't leak to the page behind
|
|
178
|
+
useEffect(() => {
|
|
179
|
+
if (!store.open)
|
|
180
|
+
return;
|
|
181
|
+
const body = document.body;
|
|
182
|
+
const previousOverflow = body.style.overflow;
|
|
183
|
+
const previousOverscroll = body.style.overscrollBehavior;
|
|
184
|
+
body.style.overflow = 'hidden';
|
|
185
|
+
body.style.overscrollBehavior = 'contain';
|
|
186
|
+
return () => {
|
|
187
|
+
body.style.overflow = previousOverflow;
|
|
188
|
+
body.style.overscrollBehavior = previousOverscroll;
|
|
189
|
+
};
|
|
190
|
+
}, [store.open]);
|
|
191
|
+
// Close chat on Escape key (or dismiss side chat first when it's open)
|
|
192
|
+
useEffect(() => {
|
|
193
|
+
if (!store.open)
|
|
194
|
+
return;
|
|
195
|
+
const onKeyDown = (e) => {
|
|
196
|
+
if (e.key !== 'Escape')
|
|
197
|
+
return;
|
|
198
|
+
if (store.currentChat?.activeMessage && shouldShowSideChat) {
|
|
199
|
+
store.currentChat?.dismissSideChat();
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
controller.handlers.button.click();
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
document.addEventListener('keydown', onKeyDown);
|
|
206
|
+
return () => document.removeEventListener('keydown', onKeyDown);
|
|
207
|
+
}, [store.open, shouldShowSideChat]);
|
|
208
|
+
// Track the primary footer height so the mobile secondary panel can sit above it
|
|
209
|
+
useEffect(() => {
|
|
210
|
+
const el = footerRef.current;
|
|
211
|
+
if (!el)
|
|
212
|
+
return;
|
|
213
|
+
const observer = new ResizeObserver((entries) => {
|
|
214
|
+
for (const entry of entries) {
|
|
215
|
+
setFooterHeight(entry.borderBoxSize?.[0]?.blockSize ?? entry.target.getBoundingClientRect().height);
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
observer.observe(el);
|
|
219
|
+
return () => observer.disconnect();
|
|
220
|
+
}, [store.open, store.currentChat?.isExpired]);
|
|
221
|
+
const HistoryButton = (props) => (_jsx(Button, { className: "ss__chat__header__button--history", disabled: props.disabled, icon: {
|
|
222
|
+
icon: 'history',
|
|
223
|
+
title: 'Chat History',
|
|
224
|
+
} }));
|
|
225
|
+
const HistoryPopup = (props) => (_jsxs("div", { className: "ss__chat__history", children: [_jsxs("div", { className: "ss__chat__history__header", children: [_jsx("h4", { children: "History" }), _jsx("div", { className: "ss__chat__history__header__buttons", children: _jsx(Button, { content: "clear", onClick: () => {
|
|
226
|
+
controller.store.clearHistory();
|
|
227
|
+
props.toggleOpen && props.toggleOpen();
|
|
228
|
+
} }) })] }), store.chats.length > 0 ? (_jsx("div", { className: "ss__chat__history__chats", children: store.chats.map((chat) => (_jsx("div", { className: "ss__chat__history__chats__chat", children: _jsxs(Button, { className: "ss__chat__history__chat__button", onClick: () => {
|
|
229
|
+
controller.store.switchChat(chat.id);
|
|
230
|
+
}, disabled: chat.id === store.currentChatId, children: [_jsx("div", { className: "ss__chat__history__chat__button__text", children: (() => {
|
|
231
|
+
const lastUserMessage = [...chat.chat].reverse().find((message) => message.messageType === 'user');
|
|
232
|
+
if (!lastUserMessage)
|
|
233
|
+
return 'New Chat';
|
|
234
|
+
const text = lastUserMessage.text;
|
|
235
|
+
return text.length > 50 ? `${text.slice(0, 50)}...` : text;
|
|
236
|
+
})() }), _jsx("div", { className: "ss__chat__history__chat__button__date", children: chat.createdAt.toLocaleString() })] }) }, chat.id))) })) : null] }));
|
|
237
|
+
const FacetButton = (props) => _jsx(Button, { icon: props.open ? 'angle-down' : 'angle-up', children: props.label });
|
|
238
|
+
const getFacetButtonLabel = (facet) => {
|
|
239
|
+
const base = facet.label || facet.field;
|
|
240
|
+
// Slider facets show the active low-high range in the button when narrowed.
|
|
241
|
+
if (facet.type === 'range') {
|
|
242
|
+
const rangeFacet = facet;
|
|
243
|
+
const active = rangeFacet.active;
|
|
244
|
+
const range = rangeFacet.range;
|
|
245
|
+
if (active && range && (active.low !== range.low || active.high !== range.high)) {
|
|
246
|
+
return `${base} (${active.low ?? '*'}-${active.high ?? '*'})`;
|
|
247
|
+
}
|
|
248
|
+
return base;
|
|
249
|
+
}
|
|
250
|
+
const applied = new Set();
|
|
251
|
+
// Count values marked as filtered (already applied on the server)
|
|
252
|
+
(facet.values || []).forEach((value) => {
|
|
253
|
+
if (value?.filtered) {
|
|
254
|
+
if ('low' in value && 'high' in value) {
|
|
255
|
+
applied.add(`${value.low ?? '*'}:${value.high ?? '*'}`);
|
|
256
|
+
}
|
|
257
|
+
else {
|
|
258
|
+
applied.add(value.value);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
// Count pending facet attachments (newly selected, not yet sent)
|
|
263
|
+
(controller.store.currentChat?.attachments.items || [])
|
|
264
|
+
.filter((item) => item.type === 'facet' && item.key === facet.field && (item.state === 'active' || item.state === 'attached'))
|
|
265
|
+
.forEach((item) => applied.add(item.value));
|
|
266
|
+
return applied.size > 0 ? `${base} (${applied.size})` : base;
|
|
267
|
+
};
|
|
268
|
+
// Slider dropdown grows to fill the remaining chat width from its anchor,
|
|
269
|
+
// so the price range slider isn't cramped inside a 150px-wide dropdown.
|
|
270
|
+
const SliderFacetDropdown = (props) => {
|
|
271
|
+
const anchorRef = useRef(null);
|
|
272
|
+
const [width, setWidth] = useState(null);
|
|
273
|
+
useEffect(() => {
|
|
274
|
+
const compute = () => {
|
|
275
|
+
if (!anchorRef.current || !chatRef.current)
|
|
276
|
+
return;
|
|
277
|
+
const anchor = anchorRef.current.getBoundingClientRect();
|
|
278
|
+
const chat = chatRef.current.getBoundingClientRect();
|
|
279
|
+
const remaining = chat.right - anchor.left - 16;
|
|
280
|
+
setWidth(Math.max(220, remaining));
|
|
281
|
+
};
|
|
282
|
+
compute();
|
|
283
|
+
const ro = typeof ResizeObserver !== 'undefined' ? new ResizeObserver(compute) : null;
|
|
284
|
+
if (ro && chatRef.current)
|
|
285
|
+
ro.observe(chatRef.current);
|
|
286
|
+
window.addEventListener('resize', compute);
|
|
287
|
+
return () => {
|
|
288
|
+
if (ro)
|
|
289
|
+
ro.disconnect();
|
|
290
|
+
window.removeEventListener('resize', compute);
|
|
291
|
+
};
|
|
292
|
+
}, []);
|
|
293
|
+
return (_jsx("div", { ref: anchorRef, className: "ss__chat__actions__facet ss__chat__actions__facet--range", children: _jsx(Dropdown, { usePortal: true, dropUp: true, button: _jsx(FacetButton, { label: props.label }), style: {
|
|
294
|
+
'.ss__dropdown__content': {
|
|
295
|
+
width: width ? `${width}px` : 'auto',
|
|
296
|
+
background: 'white',
|
|
297
|
+
boxShadow: '0px 3px 6px 0px rgba(0, 0, 0, 0.2)',
|
|
298
|
+
borderRadius: '6px',
|
|
299
|
+
},
|
|
300
|
+
}, children: _jsx("div", { className: "ss__chat__actions__facet__options", children: _jsx("div", { className: "ss__chat__actions__facet__slider", style: { padding: '12px 16px' }, children: _jsx(FacetSlider, { facet: props.facet }) }) }) }) }));
|
|
301
|
+
};
|
|
302
|
+
// TODO: if starting a new chat and it's expired, this button would then disappear
|
|
303
|
+
if (!controller.store.chatEnabled) {
|
|
304
|
+
return _jsx(_Fragment, {});
|
|
305
|
+
}
|
|
306
|
+
const { swipeOffset, swipeAnimating, swipeHandlers } = useChatGestures({
|
|
307
|
+
panelRef: secondaryRef,
|
|
308
|
+
shouldShowSideChat: !!shouldShowSideChat,
|
|
309
|
+
activeMessageId: activeMessage?.id,
|
|
310
|
+
onDismiss: () => {
|
|
311
|
+
const attachments = store.currentChat?.attachments.attached || [];
|
|
312
|
+
const productAttachments = attachments.filter((item) => item.type === 'product' && item.requestType !== 'productSimilar' && item.requestType !== 'productComparison');
|
|
313
|
+
productAttachments.forEach((item) => store.currentChat?.attachments.remove(item.id));
|
|
314
|
+
setMobileProductInfoOpen(false);
|
|
315
|
+
store.currentChat?.dismissSideChat();
|
|
316
|
+
},
|
|
317
|
+
});
|
|
318
|
+
const requestType = store.currentChat?.requestType;
|
|
319
|
+
const loadingVerbs = useMemo(() => {
|
|
320
|
+
switch (requestType) {
|
|
321
|
+
case 'productQuery':
|
|
322
|
+
return ['Thinking', 'Searching', 'Analyzing', 'Gathering details'];
|
|
323
|
+
case 'productSearch':
|
|
324
|
+
return ['Searching', 'Browsing catalog', 'Finding products', 'Curating results'];
|
|
325
|
+
case 'productComparison':
|
|
326
|
+
return ['Comparing', 'Analyzing', 'Evaluating', 'Weighing options'];
|
|
327
|
+
case 'imageSearch':
|
|
328
|
+
return ['Analyzing image', 'Identifying', 'Searching', 'Matching'];
|
|
329
|
+
case 'productSimilar':
|
|
330
|
+
return ['Finding similar items', 'Searching', 'Matching', 'Curating'];
|
|
331
|
+
case 'inspirationRequest':
|
|
332
|
+
return ['Brainstorming', 'Imagining', 'Curating', 'Inspiring'];
|
|
333
|
+
case 'general':
|
|
334
|
+
default:
|
|
335
|
+
return undefined;
|
|
336
|
+
}
|
|
337
|
+
}, [requestType]);
|
|
338
|
+
return (_jsx(CacheProvider, { children: _jsxs(_Fragment, { children: [_jsxs("div", { ref: chatRef, className: classnames('ss__chat', {
|
|
339
|
+
'ss__chat--open': store.open,
|
|
340
|
+
'ss__chat--minimized': !store.open,
|
|
341
|
+
'ss__chat--mobile': isMobile,
|
|
342
|
+
}, className, internalClassName), ...styling, children: [!disableBubbleSuggestedQuestions && !store.open && !store.currentChat && store.suggestedQuestions?.length > 0 && (_jsx("div", { className: "ss__chat__suggested-questions", children: store.suggestedQuestions.map((question, index) => (_jsx("div", { className: "ss__chat__suggested-questions__item", onClick: () => {
|
|
343
|
+
controller.openChat(question);
|
|
344
|
+
}, children: question }, index))) })), _jsx("button", { type: "button", className: 'ss__chat__bubble', "aria-label": store.open ? 'Close chat' : 'Open chat', "aria-expanded": store.open, onClick: () => controller.handlers.button.click(), children: _jsx(Icon, { icon: "chat", title: "Open Chat" }) }), store.open && shouldShowSideChat && activeMessage ? (_jsxs("div", { ref: secondaryRef, className: classnames('ss__chat__secondary'), role: "region", "aria-label": "Conversation details", style: isMobile
|
|
345
|
+
? {
|
|
346
|
+
// Touch swipe animations need to be inline to prevent visual jumps
|
|
347
|
+
transform: swipeOffset > 0 ? `translateY(${swipeOffset}px)` : undefined,
|
|
348
|
+
transition: swipeAnimating ? 'transform 0.3s ease-out' : 'none',
|
|
349
|
+
}
|
|
350
|
+
: undefined, children: [isMobile && (_jsx("div", { className: "ss__chat__secondary__drag-handle", ...swipeHandlers, children: _jsx("div", { className: "ss__chat__secondary__drag-handle__indicator" }) })), _jsxs("div", { className: 'ss__chat__header', onTouchStart: isMobile ? swipeHandlers.onTouchStart : undefined, onTouchMove: isMobile ? swipeHandlers.onTouchMove : undefined, onTouchEnd: isMobile ? swipeHandlers.onTouchEnd : undefined, children: [_jsxs("div", { className: "ss__chat__header__title", children: [_jsx("div", { className: "ss__chat__header__title__primary", children: {
|
|
351
|
+
inspirationResult: 'Inspiration Scenarios',
|
|
352
|
+
productComparison: 'Product Comparison',
|
|
353
|
+
productQuery: 'Product Information',
|
|
354
|
+
}[activeMessage.messageType] || null }), _jsx("div", { className: "ss__chat__header__title__secondary", children: {
|
|
355
|
+
inspirationResult: 'Choose a style direction to explore',
|
|
356
|
+
productComparison: `Comparing ${activeMessage?.searchResults?.length || ''} products`,
|
|
357
|
+
productQuery: 'Complete product details',
|
|
358
|
+
}[activeMessage.messageType] || null })] }), _jsx("div", { className: "ss__chat__header__buttons", children: _jsx(Button, { className: "ss__chat__header__button--close", "aria-label": "Close chat", icon: { icon: 'close2', title: 'Close Chat' }, onClick: () => {
|
|
359
|
+
// clear any product attachments tied to the side chat (discuss product flow)
|
|
360
|
+
// so the attachments bar disappears alongside the secondary panel
|
|
361
|
+
// but preserve productComparison attachments so the user can continue comparing
|
|
362
|
+
const productAttachmentsToRemove = (store.currentChat?.attachments.attached || []).filter((item) => item.type === 'product' &&
|
|
363
|
+
item.requestType !== 'productSimilar' &&
|
|
364
|
+
item.requestType !== 'productComparison');
|
|
365
|
+
productAttachmentsToRemove.forEach((item) => store.currentChat?.attachments.remove(item.id));
|
|
366
|
+
setMobileProductInfoOpen(false);
|
|
367
|
+
store.currentChat?.dismissSideChat();
|
|
368
|
+
} }) })] }), _jsx("div", { className: "ss__chat__content", children: _jsx("div", { className: 'ss__chat__messages', children: {
|
|
369
|
+
inspirationResult: (_jsx(ChatInspirationResultMessage, { ...subProps.inspirationResultMessage, chatItem: activeMessage, controller: controller, onProductQuickView: isMobile ? () => setMobileProductInfoOpen(true) : undefined })),
|
|
370
|
+
productComparison: (_jsx(ChatProductComparisonMessage, { ...subProps.productComparisonMessage, chatItem: activeMessage, controller: controller })),
|
|
371
|
+
productQuery: (_jsx(ChatProductQueryMessage, { ...subProps.productQueryMessage, chatItem: activeMessage, controller: controller, displayFields: controller.config.settings?.quickview?.displayFields, primaryColor: colorPrimary, primaryColorText: colorPrimaryText })),
|
|
372
|
+
}[activeMessage.messageType] || null }) })] })) : null, store.open ? (_jsxs("div", { className: 'ss__chat__primary', children: [_jsxs("div", { className: 'ss__chat__header', children: [_jsxs("div", { className: "ss__chat__header__title", children: [logo ? _jsx("img", { className: "ss__chat__header__title__logo", src: logo }) : null, _jsxs("div", { className: "ss__chat__header__title__text", children: [title ? _jsx("div", { className: "ss__chat__header__title__text__primary", children: title }) : null, subtitle ? _jsx("div", { className: "ss__chat__header__title__text__secondary", children: subtitle }) : null] })] }), _jsxs("div", { className: "ss__chat__header__buttons", children: [_jsx(Button
|
|
373
|
+
// disabled={store.currentChat?.chat && store.currentChat.chat.length <= 1}
|
|
374
|
+
, {
|
|
375
|
+
// disabled={store.currentChat?.chat && store.currentChat.chat.length <= 1}
|
|
376
|
+
className: "ss__chat__header__button--new", "aria-label": "New chat", icon: { icon: controller.store.initChatLoading ? 'spinner' : 'plus2', title: 'New Chat' }, onClick: () => controller.store.createChat() }), store.chats.length > 1 && (_jsx(Dropdown, { disabled: store.chats.length == 1 && store.currentChat && store.currentChat.chat.length <= 1, className: "ss__chat__header__dropdown-history", button: _jsx(HistoryButton, {}), children: _jsx(HistoryPopup, {}) })), _jsx(Button, { className: "ss__chat__header__button--close", "aria-label": "Close chat", icon: { icon: 'close2', title: 'Close Chat' }, onClick: () => controller.handlers.button.click() })] })] }), (() => {
|
|
377
|
+
const feedbackAfterMessages = controller.config.settings?.feedbackAfterMessages;
|
|
378
|
+
const systemMessages = (store.currentChat?.chat || []).filter((msg) => msg.messageType !== 'user' && msg.messageType !== 'productQuery');
|
|
379
|
+
const currentRating = store.currentChat?.sessionFeedback?.rating;
|
|
380
|
+
const hasRated = !!currentRating;
|
|
381
|
+
const shouldShowFeedback = feedbackAfterMessages &&
|
|
382
|
+
systemMessages.length >= feedbackAfterMessages &&
|
|
383
|
+
!store.currentChat?.feedbackDismissed &&
|
|
384
|
+
(!hasRated || store.currentChat?.feedbackJustGiven);
|
|
385
|
+
return shouldShowFeedback ? (_jsxs("div", { className: "ss__chat__session-feedback", children: [_jsx("div", { className: "ss__chat__session-feedback__icon", children: _jsx(Icon, { icon: "chat", size: "16px" }) }), _jsx("span", { className: "ss__chat__session-feedback__label", children: hasRated ? 'Thank you for your feedback' : "How's your experience so far?" }), _jsxs("div", { className: `ss__chat__session-feedback__actions${hasRated ? ' ss__chat__session-feedback__actions--rated' : ''}`, children: [(!hasRated || currentRating === 'UP') && (_jsx("span", { onClick: () => !hasRated && controller.handleFeedback('UP'), children: _jsx(Icon, { icon: 'thumbs-up', size: "16px", title: 'Thumbs Up' }) })), (!hasRated || currentRating === 'DOWN') && (_jsx("span", { onClick: () => !hasRated && controller.handleFeedback('DOWN'), children: _jsx(Icon, { icon: 'thumbs-down', size: "16px", title: 'Thumbs Down' }) }))] }), !hasRated && (_jsx("span", { className: "ss__chat__session-feedback__close", onClick: () => {
|
|
386
|
+
if (store.currentChat) {
|
|
387
|
+
store.currentChat.feedbackDismissed = true;
|
|
388
|
+
store.currentChat.save();
|
|
389
|
+
}
|
|
390
|
+
}, children: _jsx(Icon, { icon: "close-thin", size: "14px" }) }))] })) : null;
|
|
391
|
+
})(), _jsxs("div", { className: "ss__chat__content", children: [_jsx("div", { ref: headerRef, className: classnames('ss__chat__content__header', {
|
|
392
|
+
'ss__chat__content__header--overlay': messagesOverflow,
|
|
393
|
+
}), children: store.currentChat?.comparisons.compared && store.currentChat.comparisons.compared.length > 0 && (_jsxs("div", { className: 'ss__chat__content__header__comparisons', children: [_jsxs("div", { className: 'ss__chat__content__header__comparisons__header', children: [_jsxs("div", { className: 'ss__chat__content__header__comparisons__header__title', children: [_jsx(Icon, { className: 'ss__chat__content__header__comparisons__header__title__icon', icon: 'clipboard' }), _jsxs("span", { className: 'ss__chat__content__header__comparisons__header__title__text', children: ["Compare Products (", store.currentChat?.comparisons.compared.length, "/", store.currentChat?.comparisons.maxItems, ")"] })] }), _jsx("div", { className: 'ss__chat__content__header__comparisons__header__actions', children: _jsx(Button, { onClick: () => store.currentChat?.comparisons.reset(), children: "clear" }) })] }), _jsxs("div", { className: 'ss__chat__content__header__comparisons__content', children: [_jsx("div", { className: 'ss__chat__content__header__comparisons__content__items', children: Array.from({ length: store.currentChat?.comparisons.maxItems }).map((_, index) => {
|
|
394
|
+
const comparisonItem = store.currentChat?.comparisons.compared[index];
|
|
395
|
+
return (_jsx("div", { className: classnames('ss__chat__content__header__comparisons__content__comparison', {
|
|
396
|
+
'ss__chat__content__header__comparisons__content__comparison--placeholder': !comparisonItem,
|
|
397
|
+
}), children: comparisonItem ? (_jsxs(_Fragment, { children: [_jsx(Image
|
|
398
|
+
// onClick={() => {
|
|
399
|
+
// controller?.productQuickView(product as any);
|
|
400
|
+
// }}
|
|
401
|
+
, {
|
|
402
|
+
// onClick={() => {
|
|
403
|
+
// controller?.productQuickView(product as any);
|
|
404
|
+
// }}
|
|
405
|
+
alt: (comparisonItem?.result?.display || comparisonItem?.result)?.mappings?.core?.name || '', src: (comparisonItem?.result?.display || comparisonItem?.result)?.mappings?.core?.imageUrl ||
|
|
406
|
+
(comparisonItem?.result?.display || comparisonItem?.result)?.mappings?.core?.parentImageUrl ||
|
|
407
|
+
'' }), _jsx("div", { className: "ss__chat__content__header__comparisons__content__comparison__remove", onClick: () => {
|
|
408
|
+
store.currentChat?.comparisons.remove(comparisonItem.result.id);
|
|
409
|
+
}, children: _jsx(Icon, { icon: 'close-thin', size: '12px' }) })] })) : (_jsxs(_Fragment, { children: [_jsx(Icon, { icon: 'plus-thin' }), _jsx("div", { className: 'ss__chat__content__header__comparisons__content__comparison--placeholder__text', children: "Add" })] })) }, index));
|
|
410
|
+
}) }), _jsx("div", { className: classnames('ss__chat__content__header__comparisons__action', {
|
|
411
|
+
'ss__chat__content__header__comparisons__action--hidden': (store.currentChat?.comparisons.compared.length || 0) < 2,
|
|
412
|
+
}), children: _jsx(Button, { onClick: () => controller.search(), icon: { icon: 'compare', title: 'Compare' }, children: "Compare" }) })] })] })) }), _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: [(!store.currentChat?.chat || store.currentChat.chat.length === 0) && store.welcomeMessage && !store.currentChat?.isExpired && (_jsxs("div", { className: "ss__chat__welcome", children: [_jsx("div", { className: "ss__chat__welcome__message", children: store.welcomeMessage }), _jsx(ChatSuggestedQuestions, { ...subProps.suggestedQuestions, questions: store.suggestedQuestions, controller: controller })] })), store.currentChat?.chat
|
|
413
|
+
.filter((chatItem) => chatItem.messageType !== 'productQuery')
|
|
414
|
+
.map((chatItem, index) => (_jsx("div", { className: `ss__chat__message ss__chat__message--${chatItem.messageType}`, children: {
|
|
415
|
+
user: (_jsx(ChatMessageUser, { ...subProps.messageUser, chatItem: chatItem, controller: controller, onProductQuickView: isMobile ? () => setMobileProductInfoOpen(true) : undefined, primaryColor: colorPrimary, primaryColorText: colorPrimaryText })),
|
|
416
|
+
text: (_jsx(ChatMessageText, { ...subProps.messageText, chatItem: chatItem, controller: controller, scrollToBottom: scrollToBottomIfNear, onProductQuickView: isMobile ? () => setMobileProductInfoOpen(true) : undefined, sideChatOpen: !!shouldShowSideChat, primaryColor: colorPrimary, primaryColorText: colorPrimaryText })),
|
|
417
|
+
content: (_jsx(ChatMessageText, { ...subProps.messageText, chatItem: chatItem, controller: controller, scrollToBottom: scrollToBottomIfNear, onProductQuickView: isMobile ? () => setMobileProductInfoOpen(true) : undefined, sideChatOpen: !!shouldShowSideChat, primaryColor: colorPrimary, primaryColorText: colorPrimaryText })),
|
|
418
|
+
productSearchResult: (_jsx(ChatMessageText, { ...subProps.messageText, chatItem: chatItem, controller: controller, scrollToBottom: scrollToBottomIfNear, onProductQuickView: isMobile ? () => setMobileProductInfoOpen(true) : undefined, sideChatOpen: !!shouldShowSideChat, primaryColor: colorPrimary, primaryColorText: colorPrimaryText })),
|
|
419
|
+
inspirationResult: (_jsx(ChatMessageText, { ...subProps.messageText, chatItem: chatItem, controller: controller, scrollToBottom: scrollToBottomIfNear, onProductQuickView: isMobile ? () => setMobileProductInfoOpen(true) : undefined, sideChatOpen: !!shouldShowSideChat, primaryColor: colorPrimary, primaryColorText: colorPrimaryText })),
|
|
420
|
+
productAnswer: (_jsx(ChatMessageText, { ...subProps.messageText, chatItem: chatItem, controller: controller, scrollToBottom: scrollToBottomIfNear, onProductQuickView: isMobile ? () => setMobileProductInfoOpen(true) : undefined, sideChatOpen: !!shouldShowSideChat, primaryColor: colorPrimary, primaryColorText: colorPrimaryText })),
|
|
421
|
+
productComparison: (() => {
|
|
422
|
+
// On mobile, only the first productComparison in the session
|
|
423
|
+
// auto-opens the secondary panel. Subsequent ones get a
|
|
424
|
+
// prominent "Show Details" button instead.
|
|
425
|
+
const comparisonMessages = (store.currentChat?.chat || []).filter((m) => m.messageType === 'productComparison');
|
|
426
|
+
const isFirst = comparisonMessages.length > 0 && comparisonMessages[0].id === chatItem.id;
|
|
427
|
+
return (_jsx(ChatMessageText, { ...subProps.messageText, chatItem: chatItem, controller: controller, scrollToBottom: scrollToBottomIfNear, onProductQuickView: isMobile ? () => setMobileProductInfoOpen(true) : undefined, showDetailsButton: isMobile && !isFirst, sideChatOpen: !!shouldShowSideChat, primaryColor: colorPrimary, primaryColorText: colorPrimaryText }));
|
|
428
|
+
})(),
|
|
429
|
+
productRecommendation: (_jsx(ChatMessageText, { ...subProps.messageText, chatItem: chatItem, controller: controller, scrollToBottom: scrollToBottomIfNear, onProductQuickView: isMobile ? () => setMobileProductInfoOpen(true) : undefined, sideChatOpen: !!shouldShowSideChat, primaryColor: colorPrimary, primaryColorText: colorPrimaryText })),
|
|
430
|
+
actions: (_jsx(ChatSuggestedQuestions, { actions: chatItem.actions, controller: controller })),
|
|
431
|
+
errorResponse: (_jsx(ChatMessageText, { ...subProps.messageText, chatItem: chatItem, controller: controller, scrollToBottom: scrollToBottomIfNear, sideChatOpen: !!shouldShowSideChat, primaryColor: colorPrimary, primaryColorText: colorPrimaryText })),
|
|
432
|
+
topicDrift: (_jsx(ChatMessageText, { ...subProps.messageText, chatItem: chatItem, controller: controller, scrollToBottom: scrollToBottomIfNear, sideChatOpen: !!shouldShowSideChat, primaryColor: colorPrimary, primaryColorText: colorPrimaryText })),
|
|
433
|
+
productQuery: null,
|
|
434
|
+
}[chatItem.messageType] || null }, index))), _jsx("div", { className: "ss__chat__messages__end", ref: messagesEndRef }), showNewMessages && messagesOverflow && (_jsxs("div", { className: "ss__chat__new-messages", onClick: () => {
|
|
435
|
+
scrollToBottom();
|
|
436
|
+
setShowNewMessages(false);
|
|
437
|
+
}, children: [_jsx(Icon, { icon: "angle-down", size: "12px" }), _jsx("span", { children: "New messages" })] }))] }), _jsx(ChatLoadingIndicator, { ...subProps.loadingIndicator, loading: store.loading, verbs: loadingVerbs }), !store.currentChat?.isExpired ? (_jsxs("div", { className: "ss__chat__content__footer", ref: footerRef, ...dragHandlers, children: [store.error && _jsx("div", { className: "ss__chat__error", children: store.error.message }), store.currentChat?.sessionLimitReached && (_jsxs("div", { className: 'ss__chat__topic-drift', children: [_jsx(Icon, { icon: "info", size: "18px", className: 'ss__chat__topic-drift__icon--info' }), _jsxs("div", { className: 'ss__chat__topic-drift__text', children: [_jsx("span", { children: "Session limit reached" }), _jsx("span", { children: "This chat has reached its maximum number of interactions. Start a new session to continue." })] }), _jsx(Button, { className: 'ss__chat__topic-drift__button', onClick: () => {
|
|
438
|
+
controller.store.createChat();
|
|
439
|
+
}, children: "New Session" })] })), store.facets && store.facets.length > 0 && (_jsx("div", { className: 'ss__chat__actions', children: _jsxs("div", { className: "ss__chat__actions__wrap", children: [_jsxs("div", { className: "ss__chat__actions__facets-header", children: [_jsx("div", { className: "ss__chat__actions--title", children: "Filter by:" }), multiselectFacets && store.hasPendingFacetChanges && (_jsx("div", { className: 'ss__chat__actions__facets-apply ss__chat__actions__facets-apply--active', children: _jsx(Button, { onClick: () => {
|
|
440
|
+
controller.search();
|
|
441
|
+
}, children: "Apply" }) }))] }), _jsx("div", { className: "ss__chat__actions--facets", children: store.facets.slice(0, 10).map((facet, idx) => {
|
|
442
|
+
// range/slider facets render via FacetSlider; everything else needs at least one value to be useful
|
|
443
|
+
if (facet.type !== 'range' && !facet.values?.length)
|
|
444
|
+
return null;
|
|
445
|
+
if (facet.type === 'range') {
|
|
446
|
+
return _jsx(SliderFacetDropdown, { facet: facet, label: getFacetButtonLabel(facet) }, idx);
|
|
447
|
+
}
|
|
448
|
+
return (_jsx("div", { className: `ss__chat__actions__facet ss__chat__actions__facet--${facet.type}`, children: _jsx(Dropdown, { usePortal: true, dropUp: true, button: _jsx(FacetButton, { label: getFacetButtonLabel(facet) }), style: {
|
|
449
|
+
'.ss__dropdown__content': {
|
|
450
|
+
width: '150px',
|
|
451
|
+
maxHeight: '200px',
|
|
452
|
+
overflowY: 'auto',
|
|
453
|
+
background: 'white',
|
|
454
|
+
boxShadow: '0px 3px 6px 0px rgba(0, 0, 0, 0.2)',
|
|
455
|
+
borderRadius: '6px',
|
|
456
|
+
...(multiselectFacets
|
|
457
|
+
? {
|
|
458
|
+
'.ss__chat__actions__facet__option--checkbox': {
|
|
459
|
+
display: 'flex',
|
|
460
|
+
alignItems: 'center',
|
|
461
|
+
gap: '8px',
|
|
462
|
+
padding: '6px 10px',
|
|
463
|
+
cursor: 'pointer',
|
|
464
|
+
width: '100%',
|
|
465
|
+
boxSizing: 'border-box',
|
|
466
|
+
background: '#fff',
|
|
467
|
+
border: 'none',
|
|
468
|
+
borderBottom: '1px solid #f0f0f0',
|
|
469
|
+
'&:hover': {
|
|
470
|
+
background: new Colour(colorPrimary).lightenHex(0.95),
|
|
471
|
+
},
|
|
472
|
+
'&:last-child': {
|
|
473
|
+
borderBottom: 'none',
|
|
474
|
+
},
|
|
475
|
+
'.ss__chat__actions__facet__option__checkbox': {
|
|
476
|
+
width: '16px',
|
|
477
|
+
height: '16px',
|
|
478
|
+
borderRadius: '3px',
|
|
479
|
+
border: '2px solid #ccc',
|
|
480
|
+
display: 'flex',
|
|
481
|
+
alignItems: 'center',
|
|
482
|
+
justifyContent: 'center',
|
|
483
|
+
flexShrink: 0,
|
|
484
|
+
'&.ss__chat__actions__facet__option__checkbox--checked': {
|
|
485
|
+
background: colorPrimary,
|
|
486
|
+
borderColor: colorPrimary,
|
|
487
|
+
color: colorPrimaryText,
|
|
488
|
+
svg: {
|
|
489
|
+
fill: colorPrimaryText,
|
|
490
|
+
stroke: colorPrimaryText,
|
|
491
|
+
},
|
|
492
|
+
},
|
|
493
|
+
},
|
|
494
|
+
'.ss__chat__actions__facet__option__label': {
|
|
495
|
+
fontSize: '14px',
|
|
496
|
+
color: '#333',
|
|
497
|
+
flex: '1 1 auto',
|
|
498
|
+
textAlign: 'left',
|
|
499
|
+
},
|
|
500
|
+
},
|
|
501
|
+
}
|
|
502
|
+
: {
|
|
503
|
+
'.ss__button': {
|
|
504
|
+
width: '100%',
|
|
505
|
+
border: 'none',
|
|
506
|
+
borderRadius: 0,
|
|
507
|
+
boxSizing: 'border-box',
|
|
508
|
+
background: '#fff',
|
|
509
|
+
'&:hover': {
|
|
510
|
+
background: new Colour(colorPrimary).lightenHex(0.95),
|
|
511
|
+
},
|
|
512
|
+
},
|
|
513
|
+
}),
|
|
514
|
+
},
|
|
515
|
+
}, children: _jsx("div", { className: "ss__chat__actions__facet__options", children: facet.type === 'range-buckets'
|
|
516
|
+
? facet.values.map((option) => {
|
|
517
|
+
const rangeOption = option;
|
|
518
|
+
const optionValue = `${rangeOption.low ?? '*'}:${rangeOption.high ?? '*'}`;
|
|
519
|
+
if (multiselectFacets) {
|
|
520
|
+
const isSelected = controller.store.isFacetSelected(facet.field, optionValue);
|
|
521
|
+
return (_jsxs("div", { className: "ss__chat__actions__facet__option--checkbox", onClick: () => {
|
|
522
|
+
if (isSelected) {
|
|
523
|
+
controller.store.removeFacet(facet.field, optionValue);
|
|
524
|
+
}
|
|
525
|
+
else {
|
|
526
|
+
controller.store.addFacet({
|
|
527
|
+
key: facet.field,
|
|
528
|
+
value: optionValue,
|
|
529
|
+
});
|
|
530
|
+
}
|
|
531
|
+
}, children: [_jsx("div", { className: classnames('ss__chat__actions__facet__option__checkbox', {
|
|
532
|
+
'ss__chat__actions__facet__option__checkbox--checked': isSelected,
|
|
533
|
+
}), children: isSelected && _jsx(Icon, { icon: "check-thin", size: "10px" }) }), _jsx("span", { className: "ss__chat__actions__facet__option__label", children: rangeOption.label })] }, optionValue));
|
|
534
|
+
}
|
|
535
|
+
return (_jsx(Button, { onClick: () => {
|
|
536
|
+
controller.store.addFacet({
|
|
537
|
+
key: facet.field,
|
|
538
|
+
value: optionValue,
|
|
539
|
+
});
|
|
540
|
+
controller.search();
|
|
541
|
+
}, children: rangeOption.label }, optionValue));
|
|
542
|
+
})
|
|
543
|
+
: facet.values.map((option) => {
|
|
544
|
+
const valueOption = option;
|
|
545
|
+
const optionValue = valueOption.value || valueOption.label;
|
|
546
|
+
if (multiselectFacets) {
|
|
547
|
+
const isSelected = controller.store.isFacetSelected(facet.field, optionValue);
|
|
548
|
+
return (_jsxs("div", { className: "ss__chat__actions__facet__option--checkbox", onClick: () => {
|
|
549
|
+
if (isSelected) {
|
|
550
|
+
controller.store.removeFacet(facet.field, optionValue);
|
|
551
|
+
}
|
|
552
|
+
else {
|
|
553
|
+
controller.store.addFacet({
|
|
554
|
+
key: facet.field,
|
|
555
|
+
value: optionValue,
|
|
556
|
+
});
|
|
557
|
+
}
|
|
558
|
+
}, children: [_jsx("div", { className: classnames('ss__chat__actions__facet__option__checkbox', {
|
|
559
|
+
'ss__chat__actions__facet__option__checkbox--checked': isSelected,
|
|
560
|
+
}), children: isSelected && _jsx(Icon, { icon: "check-thin", size: "10px" }) }), _jsx("span", { className: "ss__chat__actions__facet__option__label", children: valueOption.label })] }, optionValue));
|
|
561
|
+
}
|
|
562
|
+
return (_jsx(Button, { onClick: () => {
|
|
563
|
+
controller.store.addFacet({
|
|
564
|
+
key: facet.field,
|
|
565
|
+
value: optionValue,
|
|
566
|
+
});
|
|
567
|
+
controller.search();
|
|
568
|
+
}, children: valueOption.label }, optionValue));
|
|
569
|
+
}) }) }, facet.field) }, idx));
|
|
570
|
+
}) })] }) })), (() => {
|
|
571
|
+
const activeComparisonSearchResults = shouldShowSideChat && activeMessage?.messageType === 'productComparison'
|
|
572
|
+
? activeMessage.searchResults || []
|
|
573
|
+
: null;
|
|
574
|
+
const showCommittedComparisons = !activeComparisonSearchResults &&
|
|
575
|
+
store.currentChat?.comparisons.committed &&
|
|
576
|
+
store.currentChat.comparisons.committed.length > 0 &&
|
|
577
|
+
(activeMessage?.messageType === 'user' ||
|
|
578
|
+
activeMessage?.messageType === 'productComparison' ||
|
|
579
|
+
activeMessage?.messageType === 'productQuery');
|
|
580
|
+
const visibleAttachments = store.currentChat?.attachments.attached.filter((item) => item.state === 'attached' || item.state === 'active' || item.state === 'loading' || item.state === 'error') || [];
|
|
581
|
+
const productAttachments = visibleAttachments.filter((item) => item.type === 'product' &&
|
|
582
|
+
item.requestType !== 'productSimilar' &&
|
|
583
|
+
item.requestType !== 'productComparison');
|
|
584
|
+
const imageAttachments = visibleAttachments.filter((item) => item.type === 'image');
|
|
585
|
+
const comparisonItems = activeComparisonSearchResults
|
|
586
|
+
? activeComparisonSearchResults.map((result) => {
|
|
587
|
+
const d = result?.display || result;
|
|
588
|
+
return {
|
|
589
|
+
id: result?.id,
|
|
590
|
+
name: d?.mappings?.core?.name || '',
|
|
591
|
+
imageUrl: d?.mappings?.core?.thumbnailImageUrl || d?.mappings?.core?.imageUrl || d?.mappings?.core?.parentImageUrl || '',
|
|
592
|
+
onClick: isMobile
|
|
593
|
+
? () => {
|
|
594
|
+
controller.productQuickView(result);
|
|
595
|
+
setMobileProductInfoOpen(true);
|
|
596
|
+
}
|
|
597
|
+
: undefined,
|
|
598
|
+
};
|
|
599
|
+
})
|
|
600
|
+
: showCommittedComparisons
|
|
601
|
+
? (store.currentChat?.comparisons.committed || []).map((comparisonItem) => {
|
|
602
|
+
const d = comparisonItem?.result?.display || comparisonItem?.result;
|
|
603
|
+
return {
|
|
604
|
+
id: comparisonItem.result?.id,
|
|
605
|
+
name: d?.mappings?.core?.name || '',
|
|
606
|
+
imageUrl: d?.mappings?.core?.thumbnailImageUrl || d?.mappings?.core?.imageUrl || d?.mappings?.core?.parentImageUrl || '',
|
|
607
|
+
onClick: isMobile
|
|
608
|
+
? () => {
|
|
609
|
+
controller.productQuickView(comparisonItem.result);
|
|
610
|
+
setMobileProductInfoOpen(true);
|
|
611
|
+
}
|
|
612
|
+
: undefined,
|
|
613
|
+
};
|
|
614
|
+
})
|
|
615
|
+
: [];
|
|
616
|
+
const productItems = productAttachments.map((item) => ({
|
|
617
|
+
id: item.id,
|
|
618
|
+
name: item.name || '',
|
|
619
|
+
imageUrl: item.thumbnailUrl || '',
|
|
620
|
+
onClick: isMobile
|
|
621
|
+
? () => {
|
|
622
|
+
setMobileProductInfoOpen(true);
|
|
623
|
+
}
|
|
624
|
+
: () => {
|
|
625
|
+
store.currentChat?.setActiveMessage(store.currentChat?.activeMessage?.id || '');
|
|
626
|
+
},
|
|
627
|
+
onRemove: () => {
|
|
628
|
+
store.currentChat?.attachments.remove(item.id);
|
|
629
|
+
setMobileProductInfoOpen(false);
|
|
630
|
+
store.currentChat?.dismissSideChat();
|
|
631
|
+
},
|
|
632
|
+
}));
|
|
633
|
+
const imageItems = imageAttachments.map((item) => ({
|
|
634
|
+
id: item.id,
|
|
635
|
+
name: item.fileName || 'Image',
|
|
636
|
+
imageUrl: item.base64 || item.thumbnailUrl || '',
|
|
637
|
+
isLoading: item.state === 'loading',
|
|
638
|
+
hasError: !!item.error,
|
|
639
|
+
errorMessage: item.error?.message,
|
|
640
|
+
onRemove: () => store.currentChat?.attachments.remove(item.id),
|
|
641
|
+
}));
|
|
642
|
+
const productTitle = productItems.length > 1 ? 'Compare these products' : 'Ask about this product' + (isMobile ? '' : ' (click for details)');
|
|
643
|
+
const hasImageError = imageItems.some((item) => item.hasError);
|
|
644
|
+
const imageTitle = imageItems.length > 0 && !hasImageError ? 'Find products similar to this image:' : '';
|
|
645
|
+
return (_jsxs(_Fragment, { children: [comparisonItems.length > 0 && (_jsx(ChatAttachmentContext, { ...subProps.attachmentContext, title: 'Compare these products', items: comparisonItems, onClose: () => {
|
|
646
|
+
store.currentChat?.comparisons.resetCommitted();
|
|
647
|
+
store.currentChat?.dismissSideChat();
|
|
648
|
+
} })), productItems.length > 0 && (_jsx(ChatAttachmentContext, { ...subProps.attachmentContext, title: productTitle, items: productItems, onClose: () => {
|
|
649
|
+
productAttachments.forEach((item) => store.currentChat?.attachments.remove(item.id));
|
|
650
|
+
setMobileProductInfoOpen(false);
|
|
651
|
+
store.currentChat?.dismissSideChat();
|
|
652
|
+
} })), imageItems.length > 0 && _jsx(ChatAttachmentContext, { ...subProps.attachmentContext, title: imageTitle, items: imageItems })] }));
|
|
653
|
+
})(), (() => {
|
|
654
|
+
const drift = store.currentChat?.topicDrift;
|
|
655
|
+
if (!drift)
|
|
656
|
+
return null;
|
|
657
|
+
// recommendedAction is the prescription; driftType is the diagnosis.
|
|
658
|
+
// Hide the banner when the backend says to keep flowing, or when no drift was detected.
|
|
659
|
+
if (drift.recommendedAction === 'CONTINUE' || drift.driftType === 'NO_DRIFT')
|
|
660
|
+
return null;
|
|
661
|
+
const isScopeRedirect = drift.recommendedAction === 'SCOPE_REDIRECT';
|
|
662
|
+
const primaryText = isScopeRedirect ? "I'm here to help with shopping" : 'Looking for something new?';
|
|
663
|
+
const secondaryText = isScopeRedirect
|
|
664
|
+
? 'Try asking about products, comparisons, or recommendations'
|
|
665
|
+
: 'Start a fresh session for better assistance, or keep going in this one?';
|
|
666
|
+
const buttonText = isScopeRedirect ? '' : 'New Session';
|
|
667
|
+
return (_jsxs("div", { className: 'ss__chat__topic-drift', children: [_jsx(Icon, { icon: "info", size: "18px", className: 'ss__chat__topic-drift__icon--info' }), _jsxs("div", { className: 'ss__chat__topic-drift__text', children: [_jsx("span", { children: primaryText }), _jsx("span", { children: secondaryText })] }), buttonText && (_jsx(Button, { className: 'ss__chat__topic-drift__button', onClick: () => {
|
|
668
|
+
if (isScopeRedirect) {
|
|
669
|
+
store.currentChat?.dismissTopicDrift();
|
|
670
|
+
return;
|
|
671
|
+
}
|
|
672
|
+
const messageText = store.currentChat?.handleTopicDrift();
|
|
673
|
+
if (messageText) {
|
|
674
|
+
controller.store.createChat();
|
|
675
|
+
controller.search({ data: { message: messageText } });
|
|
676
|
+
}
|
|
677
|
+
}, children: buttonText })), _jsx("span", { onClick: () => {
|
|
678
|
+
store.currentChat?.dismissTopicDrift();
|
|
679
|
+
}, children: _jsx(Icon, { icon: "close-thin", size: "14px", className: 'ss__chat__topic-drift__icon--close' }) })] }));
|
|
680
|
+
})(), _jsxs("div", { className: 'ss__chat__input', children: [_jsxs("div", { className: 'ss__chat__input__input', children: [_jsx("input", { type: "text", name: "ss-chat-input", disabled: store.loading || store.blocked || store.currentChat?.sessionLimitReached, placeholder: (() => {
|
|
681
|
+
const comparedCount = store.currentChat?.comparisons.compared.length || 0;
|
|
682
|
+
const committedCount = store.currentChat?.comparisons.committed.length || 0;
|
|
683
|
+
const attached = store.currentChat?.attachments.attached.filter((item) => item.state === 'attached' || item.state === 'active') || [];
|
|
684
|
+
const attachedProducts = attached.filter((item) => item.type === 'product');
|
|
685
|
+
const attachedImages = attached.filter((item) => item.type === 'image' && !item.error);
|
|
686
|
+
if (attachedProducts.length === 1) {
|
|
687
|
+
return 'Ask about this product...';
|
|
688
|
+
}
|
|
689
|
+
if (comparedCount > 1 || attachedProducts.length > 1) {
|
|
690
|
+
return 'What would you like to compare?';
|
|
691
|
+
}
|
|
692
|
+
if (committedCount > 0) {
|
|
693
|
+
return 'Ask about the compared products...';
|
|
694
|
+
}
|
|
695
|
+
if (attachedImages.length > 0) {
|
|
696
|
+
return 'Ask about this image...';
|
|
697
|
+
}
|
|
698
|
+
if (comparedCount === 1) {
|
|
699
|
+
return 'Add another product to compare...';
|
|
700
|
+
}
|
|
701
|
+
return 'Type your message...';
|
|
702
|
+
})(), onInput: (e) => controller.handlers.input.input(e), onKeyDown: (e) => {
|
|
703
|
+
controller.handlers.input.enterKey(e);
|
|
704
|
+
if (e.keyCode === 13 && isMobile && mobileProductInfoOpen) {
|
|
705
|
+
setMobileProductInfoOpen(false);
|
|
706
|
+
}
|
|
707
|
+
}, value: controller.store.inputValue }), store.features.imageSearch.enabled && (_jsxs(_Fragment, { children: [_jsx(Button, { className: 'ss__chat__upload-button', disabled: store.loading || store.blocked || store.currentChat?.sessionLimitReached, onClick: () => fileInputRef.current?.click(), icon: { icon: 'image', title: 'Upload Image' } }), _jsx("input", { ref: fileInputRef, onChange: async (e) => {
|
|
708
|
+
await controller.upload(e.target.files);
|
|
709
|
+
// reset value
|
|
710
|
+
e.target.value = '';
|
|
711
|
+
}, multiple: true, type: "file", accept: "image/*", className: "ss__chat__input__input__file" })] }))] }), _jsx("div", { className: 'ss__chat__input__actions', children: (() => {
|
|
712
|
+
const hasImageAttachment = (store.currentChat?.attachments.attached || []).some((item) => item.type === 'image' && !item.error);
|
|
713
|
+
const messageEmpty = !controller.store.inputValue.trim();
|
|
714
|
+
const sendDisabled = store.blocked || store.currentChat?.sessionLimitReached || (hasImageAttachment && messageEmpty) || messageEmpty;
|
|
715
|
+
return (_jsx(Button, { className: "ss__chat__send-button", icon: { icon: 'send', title: 'Send Message' }, disabled: sendDisabled, onClick: () => {
|
|
716
|
+
if (sendDisabled)
|
|
717
|
+
return;
|
|
718
|
+
controller.search();
|
|
719
|
+
if (isMobile && mobileProductInfoOpen) {
|
|
720
|
+
setMobileProductInfoOpen(false);
|
|
721
|
+
}
|
|
722
|
+
} }));
|
|
723
|
+
})() })] }), _jsx("div", { className: 'ss__chat__disclaimer', children: _jsxs("i", { children: ["Powered by Athos Commerce. AI-powered assistant. It sometimes make mistakes. Avoid sharing personal data.", ' ', _jsx("a", { href: "https://athoscommerce.com/legal/privacy-policy/", target: "_blank", rel: "noopener noreferrer", children: "Privacy Policy" })] }) }), isDraggingFile && (_jsxs("div", { className: "ss__chat__content__footer__drop-overlay", children: [_jsx(Icon, { icon: "image", size: "24px" }), _jsx("span", { children: "Drop image to upload" })] }))] })) : (_jsxs("div", { className: 'ss__chat__expired', children: [_jsx("div", { className: 'ss__chat__expired__message', children: "This chat is expired. Please start a new chat." }), _jsx(Button, { className: 'ss__chat__expired__button', onClick: () => {
|
|
724
|
+
controller.store.createChat();
|
|
725
|
+
}, children: "New Session" })] }))] })] })) : null] }), _jsx(Overlay, { style: { zIndex: 1001 }, color: "transparent", active: store.open, onClick: () => controller.handlers.button.click() })] }) }));
|
|
726
|
+
});
|