@athoscommerce/snap-preact 1.2.3-beta.4 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (312) hide show
  1. package/README.md +16 -0
  2. package/dist/cjs/components/src/components/Atoms/Button/Button.d.ts +1 -1
  3. package/dist/cjs/components/src/components/Atoms/Button/Button.d.ts.map +1 -1
  4. package/dist/cjs/components/src/components/Atoms/Dropdown/Dropdown.d.ts +0 -1
  5. package/dist/cjs/components/src/components/Atoms/Dropdown/Dropdown.d.ts.map +1 -1
  6. package/dist/cjs/components/src/components/Atoms/Dropdown/Dropdown.js +13 -30
  7. package/dist/cjs/components/src/components/Atoms/Icon/paths.d.ts +0 -21
  8. package/dist/cjs/components/src/components/Atoms/Icon/paths.d.ts.map +1 -1
  9. package/dist/cjs/components/src/components/Atoms/Icon/paths.js +0 -21
  10. package/dist/cjs/components/src/components/Atoms/TemplateSelect/TemplateSelect.d.ts +3 -3
  11. package/dist/cjs/components/src/components/Atoms/TemplateSelect/TemplateSelect.d.ts.map +1 -1
  12. package/dist/cjs/components/src/components/Atoms/TemplateSelect/TemplateSelect.js +7 -8
  13. package/dist/cjs/components/src/components/Molecules/CalloutBadge/CalloutBadge.js +2 -2
  14. package/dist/cjs/components/src/components/Molecules/Filter/Filter.d.ts +1 -1
  15. package/dist/cjs/components/src/components/Molecules/Filter/Filter.d.ts.map +1 -1
  16. package/dist/cjs/components/src/components/Molecules/OverlayBadge/OverlayBadge.js +2 -2
  17. package/dist/cjs/components/src/components/Molecules/Result/Result.d.ts +3 -3
  18. package/dist/cjs/components/src/components/Molecules/Result/Result.d.ts.map +1 -1
  19. package/dist/cjs/components/src/components/Molecules/Result/Result.js +4 -4
  20. package/dist/cjs/components/src/components/Molecules/SearchInput/SearchInput.d.ts +0 -2
  21. package/dist/cjs/components/src/components/Molecules/SearchInput/SearchInput.d.ts.map +1 -1
  22. package/dist/cjs/components/src/components/Molecules/SearchInput/SearchInput.js +2 -19
  23. package/dist/cjs/components/src/components/Molecules/Slideout/Slideout.d.ts.map +1 -1
  24. package/dist/cjs/components/src/components/Molecules/Slideout/Slideout.js +12 -30
  25. package/dist/cjs/components/src/components/Molecules/TemplatesEditor/Components/AbstractedControls.js +5 -5
  26. package/dist/cjs/components/src/components/Molecules/TemplatesEditor/Components/Control.d.ts.map +1 -1
  27. package/dist/cjs/components/src/components/Molecules/TemplatesEditor/Components/Control.js +31 -31
  28. package/dist/cjs/components/src/components/Molecules/TemplatesEditor/TemplatesEditor.d.ts.map +1 -1
  29. package/dist/cjs/components/src/components/Molecules/TemplatesEditor/TemplatesEditor.js +22 -36
  30. package/dist/cjs/components/src/components/Organisms/Facet/Facet.js +1 -2
  31. package/dist/cjs/components/src/components/Organisms/FacetsHorizontal/FacetsHorizontal.js +1 -2
  32. package/dist/cjs/components/src/components/Organisms/FilterSummary/FilterSummary.d.ts +2 -2
  33. package/dist/cjs/components/src/components/Organisms/FilterSummary/FilterSummary.d.ts.map +1 -1
  34. package/dist/cjs/components/src/components/Organisms/Results/Results.js +1 -1
  35. package/dist/cjs/components/src/components/Templates/AutocompleteFixed/AutocompleteFixed.d.ts.map +1 -1
  36. package/dist/cjs/components/src/components/Templates/AutocompleteFixed/AutocompleteFixed.js +0 -2
  37. package/dist/cjs/components/src/components/Templates/AutocompleteModal/AutocompleteModal.d.ts.map +1 -1
  38. package/dist/cjs/components/src/components/Templates/AutocompleteModal/AutocompleteModal.js +0 -4
  39. package/dist/cjs/components/src/components/Templates/AutocompleteSlideout/AutocompleteSlideout.d.ts.map +1 -1
  40. package/dist/cjs/components/src/components/Templates/AutocompleteSlideout/AutocompleteSlideout.js +0 -2
  41. package/dist/cjs/components/src/hooks/useAcRenderedInput.d.ts.map +1 -1
  42. package/dist/cjs/components/src/hooks/useAcRenderedInput.js +65 -15
  43. package/dist/cjs/components/src/hooks/useMediaQuery.d.ts.map +1 -1
  44. package/dist/cjs/components/src/hooks/useMediaQuery.js +3 -1
  45. package/dist/cjs/components/src/index.d.ts +0 -1
  46. package/dist/cjs/components/src/index.d.ts.map +1 -1
  47. package/dist/cjs/components/src/index.js +0 -1
  48. package/dist/cjs/components/src/providers/theme.d.ts +1 -1
  49. package/dist/cjs/components/src/providers/theme.d.ts.map +1 -1
  50. package/dist/cjs/components/src/providers/withTracking.d.ts +2 -2
  51. package/dist/cjs/components/src/providers/withTracking.d.ts.map +1 -1
  52. package/dist/cjs/components/src/themes/base/base.js +3 -3
  53. package/dist/cjs/src/Snap.d.ts +1 -2
  54. package/dist/cjs/src/Snap.d.ts.map +1 -1
  55. package/dist/cjs/src/Snap.js +24 -124
  56. package/dist/cjs/src/SnapHybrid.d.ts.map +1 -1
  57. package/dist/cjs/src/Templates/SnapTemplates.d.ts +13 -73
  58. package/dist/cjs/src/Templates/SnapTemplates.d.ts.map +1 -1
  59. package/dist/cjs/src/Templates/SnapTemplates.js +108 -117
  60. package/dist/cjs/src/Templates/Stores/LibraryStore.d.ts +0 -4
  61. package/dist/cjs/src/Templates/Stores/LibraryStore.d.ts.map +1 -1
  62. package/dist/cjs/src/Templates/Stores/LibraryStore.js +0 -19
  63. package/dist/cjs/src/Templates/Stores/TargetStore.d.ts +7 -6
  64. package/dist/cjs/src/Templates/Stores/TargetStore.d.ts.map +1 -1
  65. package/dist/cjs/src/Templates/Stores/TargetStore.js +14 -8
  66. package/dist/cjs/src/Templates/Stores/TemplateEditor/TemplateEditorStore.d.ts +58 -8
  67. package/dist/cjs/src/Templates/Stores/TemplateEditor/TemplateEditorStore.d.ts.map +1 -1
  68. package/dist/cjs/src/Templates/Stores/TemplateEditor/TemplateEditorStore.js +467 -96
  69. package/dist/cjs/src/Templates/Stores/TemplateEditor/uiAbstractions/autocompleteControllerUI.d.ts +1 -0
  70. package/dist/cjs/src/Templates/Stores/TemplateEditor/uiAbstractions/autocompleteControllerUI.d.ts.map +1 -1
  71. package/dist/cjs/src/Templates/Stores/TemplateEditor/uiAbstractions/autocompleteControllerUI.js +123 -70
  72. package/dist/cjs/src/Templates/Stores/TemplateEditor/uiAbstractions/configUI.d.ts.map +1 -1
  73. package/dist/cjs/src/Templates/Stores/TemplateEditor/uiAbstractions/configUI.js +9 -3
  74. package/dist/cjs/src/Templates/Stores/TemplateEditor/uiAbstractions/searchControllerUI.d.ts +1 -0
  75. package/dist/cjs/src/Templates/Stores/TemplateEditor/uiAbstractions/searchControllerUI.d.ts.map +1 -1
  76. package/dist/cjs/src/Templates/Stores/TemplateEditor/uiAbstractions/searchControllerUI.js +86 -1
  77. package/dist/cjs/src/Templates/Stores/TemplateEditor/uiAbstractions/themeUI.d.ts.map +1 -1
  78. package/dist/cjs/src/Templates/Stores/TemplateEditor/uiAbstractions/themeUI.js +33 -14
  79. package/dist/cjs/src/Templates/Stores/TemplateStore.d.ts +81 -33
  80. package/dist/cjs/src/Templates/Stores/TemplateStore.d.ts.map +1 -1
  81. package/dist/cjs/src/Templates/Stores/TemplateStore.js +32 -41
  82. package/dist/cjs/src/Templates/Stores/ThemeStore.d.ts +2 -8
  83. package/dist/cjs/src/Templates/Stores/ThemeStore.d.ts.map +1 -1
  84. package/dist/cjs/src/Templates/Stores/ThemeStore.js +3 -28
  85. package/dist/cjs/src/Templates/Stores/library/languages/es.d.ts.map +1 -1
  86. package/dist/cjs/src/Templates/Stores/library/languages/es.js +0 -5
  87. package/dist/cjs/src/Templates/Stores/library/languages/fr.d.ts.map +1 -1
  88. package/dist/cjs/src/Templates/Stores/library/languages/fr.js +0 -5
  89. package/dist/cjs/src/Templates/index.d.ts +1 -1
  90. package/dist/cjs/src/Templates/index.d.ts.map +1 -1
  91. package/dist/cjs/src/index.d.ts +1 -0
  92. package/dist/cjs/src/index.d.ts.map +1 -1
  93. package/dist/cjs/src/setupEvents.d.ts.map +1 -1
  94. package/dist/cjs/src/setupEvents.js +0 -39
  95. package/dist/cjs/src/types.d.ts +6 -16
  96. package/dist/cjs/src/types.d.ts.map +1 -1
  97. package/dist/cjs/src/utils/combineMerge.d.ts +2 -0
  98. package/dist/cjs/src/utils/combineMerge.d.ts.map +1 -0
  99. package/dist/cjs/src/utils/combineMerge.js +22 -0
  100. package/dist/cjs/src/utils/index.d.ts +1 -0
  101. package/dist/cjs/src/utils/index.d.ts.map +1 -1
  102. package/dist/cjs/src/utils/index.js +3 -1
  103. package/dist/esm/components/src/components/Atoms/Button/Button.d.ts +1 -1
  104. package/dist/esm/components/src/components/Atoms/Button/Button.d.ts.map +1 -1
  105. package/dist/esm/components/src/components/Atoms/Dropdown/Dropdown.d.ts +0 -1
  106. package/dist/esm/components/src/components/Atoms/Dropdown/Dropdown.d.ts.map +1 -1
  107. package/dist/esm/components/src/components/Atoms/Dropdown/Dropdown.js +9 -33
  108. package/dist/esm/components/src/components/Atoms/Icon/paths.d.ts +0 -21
  109. package/dist/esm/components/src/components/Atoms/Icon/paths.d.ts.map +1 -1
  110. package/dist/esm/components/src/components/Atoms/Icon/paths.js +0 -21
  111. package/dist/esm/components/src/components/Atoms/TemplateSelect/TemplateSelect.d.ts +3 -3
  112. package/dist/esm/components/src/components/Atoms/TemplateSelect/TemplateSelect.d.ts.map +1 -1
  113. package/dist/esm/components/src/components/Atoms/TemplateSelect/TemplateSelect.js +7 -8
  114. package/dist/esm/components/src/components/Molecules/CalloutBadge/CalloutBadge.js +1 -1
  115. package/dist/esm/components/src/components/Molecules/Filter/Filter.d.ts +1 -1
  116. package/dist/esm/components/src/components/Molecules/Filter/Filter.d.ts.map +1 -1
  117. package/dist/esm/components/src/components/Molecules/OverlayBadge/OverlayBadge.js +1 -1
  118. package/dist/esm/components/src/components/Molecules/Result/Result.d.ts +3 -3
  119. package/dist/esm/components/src/components/Molecules/Result/Result.d.ts.map +1 -1
  120. package/dist/esm/components/src/components/Molecules/Result/Result.js +2 -2
  121. package/dist/esm/components/src/components/Molecules/SearchInput/SearchInput.d.ts +0 -2
  122. package/dist/esm/components/src/components/Molecules/SearchInput/SearchInput.d.ts.map +1 -1
  123. package/dist/esm/components/src/components/Molecules/SearchInput/SearchInput.js +2 -35
  124. package/dist/esm/components/src/components/Molecules/Slideout/Slideout.d.ts.map +1 -1
  125. package/dist/esm/components/src/components/Molecules/Slideout/Slideout.js +12 -30
  126. package/dist/esm/components/src/components/Molecules/TemplatesEditor/Components/AbstractedControls.js +5 -5
  127. package/dist/esm/components/src/components/Molecules/TemplatesEditor/Components/Control.d.ts.map +1 -1
  128. package/dist/esm/components/src/components/Molecules/TemplatesEditor/Components/Control.js +29 -29
  129. package/dist/esm/components/src/components/Molecules/TemplatesEditor/TemplatesEditor.d.ts.map +1 -1
  130. package/dist/esm/components/src/components/Molecules/TemplatesEditor/TemplatesEditor.js +22 -35
  131. package/dist/esm/components/src/components/Organisms/Facet/Facet.js +1 -1
  132. package/dist/esm/components/src/components/Organisms/FacetsHorizontal/FacetsHorizontal.js +1 -1
  133. package/dist/esm/components/src/components/Organisms/FilterSummary/FilterSummary.d.ts +2 -2
  134. package/dist/esm/components/src/components/Organisms/FilterSummary/FilterSummary.d.ts.map +1 -1
  135. package/dist/esm/components/src/components/Organisms/Results/Results.js +1 -1
  136. package/dist/esm/components/src/components/Templates/AutocompleteFixed/AutocompleteFixed.d.ts.map +1 -1
  137. package/dist/esm/components/src/components/Templates/AutocompleteFixed/AutocompleteFixed.js +0 -3
  138. package/dist/esm/components/src/components/Templates/AutocompleteModal/AutocompleteModal.d.ts.map +1 -1
  139. package/dist/esm/components/src/components/Templates/AutocompleteModal/AutocompleteModal.js +0 -5
  140. package/dist/esm/components/src/components/Templates/AutocompleteSlideout/AutocompleteSlideout.d.ts.map +1 -1
  141. package/dist/esm/components/src/components/Templates/AutocompleteSlideout/AutocompleteSlideout.js +0 -3
  142. package/dist/esm/components/src/hooks/useAcRenderedInput.d.ts.map +1 -1
  143. package/dist/esm/components/src/hooks/useAcRenderedInput.js +61 -11
  144. package/dist/esm/components/src/hooks/useMediaQuery.d.ts.map +1 -1
  145. package/dist/esm/components/src/hooks/useMediaQuery.js +3 -1
  146. package/dist/esm/components/src/index.d.ts +0 -1
  147. package/dist/esm/components/src/index.d.ts.map +1 -1
  148. package/dist/esm/components/src/index.js +0 -1
  149. package/dist/esm/components/src/providers/theme.d.ts +1 -1
  150. package/dist/esm/components/src/providers/theme.d.ts.map +1 -1
  151. package/dist/esm/components/src/providers/withTracking.d.ts +2 -2
  152. package/dist/esm/components/src/providers/withTracking.d.ts.map +1 -1
  153. package/dist/esm/components/src/themes/base/base.js +3 -3
  154. package/dist/esm/src/Snap.d.ts +1 -2
  155. package/dist/esm/src/Snap.d.ts.map +1 -1
  156. package/dist/esm/src/Snap.js +0 -59
  157. package/dist/esm/src/SnapHybrid.d.ts.map +1 -1
  158. package/dist/esm/src/Templates/SnapTemplates.d.ts +13 -73
  159. package/dist/esm/src/Templates/SnapTemplates.d.ts.map +1 -1
  160. package/dist/esm/src/Templates/SnapTemplates.js +117 -113
  161. package/dist/esm/src/Templates/Stores/LibraryStore.d.ts +0 -4
  162. package/dist/esm/src/Templates/Stores/LibraryStore.d.ts.map +1 -1
  163. package/dist/esm/src/Templates/Stores/LibraryStore.js +0 -6
  164. package/dist/esm/src/Templates/Stores/TargetStore.d.ts +7 -6
  165. package/dist/esm/src/Templates/Stores/TargetStore.d.ts.map +1 -1
  166. package/dist/esm/src/Templates/Stores/TargetStore.js +14 -8
  167. package/dist/esm/src/Templates/Stores/TemplateEditor/TemplateEditorStore.d.ts +58 -8
  168. package/dist/esm/src/Templates/Stores/TemplateEditor/TemplateEditorStore.d.ts.map +1 -1
  169. package/dist/esm/src/Templates/Stores/TemplateEditor/TemplateEditorStore.js +447 -89
  170. package/dist/esm/src/Templates/Stores/TemplateEditor/uiAbstractions/autocompleteControllerUI.d.ts +1 -0
  171. package/dist/esm/src/Templates/Stores/TemplateEditor/uiAbstractions/autocompleteControllerUI.d.ts.map +1 -1
  172. package/dist/esm/src/Templates/Stores/TemplateEditor/uiAbstractions/autocompleteControllerUI.js +118 -66
  173. package/dist/esm/src/Templates/Stores/TemplateEditor/uiAbstractions/configUI.d.ts.map +1 -1
  174. package/dist/esm/src/Templates/Stores/TemplateEditor/uiAbstractions/configUI.js +9 -3
  175. package/dist/esm/src/Templates/Stores/TemplateEditor/uiAbstractions/searchControllerUI.d.ts +1 -0
  176. package/dist/esm/src/Templates/Stores/TemplateEditor/uiAbstractions/searchControllerUI.d.ts.map +1 -1
  177. package/dist/esm/src/Templates/Stores/TemplateEditor/uiAbstractions/searchControllerUI.js +82 -1
  178. package/dist/esm/src/Templates/Stores/TemplateEditor/uiAbstractions/themeUI.d.ts.map +1 -1
  179. package/dist/esm/src/Templates/Stores/TemplateEditor/uiAbstractions/themeUI.js +27 -8
  180. package/dist/esm/src/Templates/Stores/TemplateStore.d.ts +81 -33
  181. package/dist/esm/src/Templates/Stores/TemplateStore.d.ts.map +1 -1
  182. package/dist/esm/src/Templates/Stores/TemplateStore.js +28 -38
  183. package/dist/esm/src/Templates/Stores/ThemeStore.d.ts +2 -8
  184. package/dist/esm/src/Templates/Stores/ThemeStore.d.ts.map +1 -1
  185. package/dist/esm/src/Templates/Stores/ThemeStore.js +3 -26
  186. package/dist/esm/src/Templates/Stores/library/languages/es.d.ts.map +1 -1
  187. package/dist/esm/src/Templates/Stores/library/languages/es.js +0 -5
  188. package/dist/esm/src/Templates/Stores/library/languages/fr.d.ts.map +1 -1
  189. package/dist/esm/src/Templates/Stores/library/languages/fr.js +0 -5
  190. package/dist/esm/src/Templates/index.d.ts +1 -1
  191. package/dist/esm/src/Templates/index.d.ts.map +1 -1
  192. package/dist/esm/src/index.d.ts +1 -0
  193. package/dist/esm/src/index.d.ts.map +1 -1
  194. package/dist/esm/src/setupEvents.d.ts.map +1 -1
  195. package/dist/esm/src/setupEvents.js +0 -23
  196. package/dist/esm/src/types.d.ts +6 -16
  197. package/dist/esm/src/types.d.ts.map +1 -1
  198. package/dist/esm/src/utils/combineMerge.d.ts +2 -0
  199. package/dist/esm/src/utils/combineMerge.d.ts.map +1 -0
  200. package/dist/esm/src/utils/combineMerge.js +16 -0
  201. package/dist/esm/src/utils/index.d.ts +1 -0
  202. package/dist/esm/src/utils/index.d.ts.map +1 -1
  203. package/dist/esm/src/utils/index.js +1 -0
  204. package/package.json +20 -15
  205. package/dist/cjs/components/src/components/Atoms/ChatLoadingIndicator/ChatLoadingIndicator.d.ts +0 -7
  206. package/dist/cjs/components/src/components/Atoms/ChatLoadingIndicator/ChatLoadingIndicator.d.ts.map +0 -1
  207. package/dist/cjs/components/src/components/Atoms/ChatLoadingIndicator/ChatLoadingIndicator.js +0 -85
  208. package/dist/cjs/components/src/components/Atoms/ChatLoadingIndicator/index.d.ts +0 -2
  209. package/dist/cjs/components/src/components/Atoms/ChatLoadingIndicator/index.d.ts.map +0 -1
  210. package/dist/cjs/components/src/components/Atoms/ChatLoadingIndicator/index.js +0 -17
  211. package/dist/cjs/components/src/components/Molecules/ChatInspirationResultMessage/ChatInspirationResultMessage.d.ts +0 -18
  212. package/dist/cjs/components/src/components/Molecules/ChatInspirationResultMessage/ChatInspirationResultMessage.d.ts.map +0 -1
  213. package/dist/cjs/components/src/components/Molecules/ChatInspirationResultMessage/ChatInspirationResultMessage.js +0 -118
  214. package/dist/cjs/components/src/components/Molecules/ChatInspirationResultMessage/index.d.ts +0 -2
  215. package/dist/cjs/components/src/components/Molecules/ChatInspirationResultMessage/index.d.ts.map +0 -1
  216. package/dist/cjs/components/src/components/Molecules/ChatInspirationResultMessage/index.js +0 -17
  217. package/dist/cjs/components/src/components/Molecules/ChatProductComparisonMessage/ChatProductComparisonMessage.d.ts +0 -17
  218. package/dist/cjs/components/src/components/Molecules/ChatProductComparisonMessage/ChatProductComparisonMessage.d.ts.map +0 -1
  219. package/dist/cjs/components/src/components/Molecules/ChatProductComparisonMessage/ChatProductComparisonMessage.js +0 -106
  220. package/dist/cjs/components/src/components/Molecules/ChatProductComparisonMessage/index.d.ts +0 -2
  221. package/dist/cjs/components/src/components/Molecules/ChatProductComparisonMessage/index.d.ts.map +0 -1
  222. package/dist/cjs/components/src/components/Molecules/ChatProductComparisonMessage/index.js +0 -17
  223. package/dist/cjs/components/src/components/Molecules/ChatProductQueryMessage/ChatProductQueryMessage.d.ts +0 -23
  224. package/dist/cjs/components/src/components/Molecules/ChatProductQueryMessage/ChatProductQueryMessage.d.ts.map +0 -1
  225. package/dist/cjs/components/src/components/Molecules/ChatProductQueryMessage/ChatProductQueryMessage.js +0 -451
  226. package/dist/cjs/components/src/components/Molecules/ChatProductQueryMessage/index.d.ts +0 -2
  227. package/dist/cjs/components/src/components/Molecules/ChatProductQueryMessage/index.d.ts.map +0 -1
  228. package/dist/cjs/components/src/components/Molecules/ChatProductQueryMessage/index.js +0 -17
  229. package/dist/cjs/components/src/components/Organisms/Chat/Chat.d.ts +0 -15
  230. package/dist/cjs/components/src/components/Organisms/Chat/Chat.d.ts.map +0 -1
  231. package/dist/cjs/components/src/components/Organisms/Chat/Chat.js +0 -1804
  232. package/dist/cjs/components/src/components/Organisms/Chat/ChatAttachmentContext.d.ts +0 -19
  233. package/dist/cjs/components/src/components/Organisms/Chat/ChatAttachmentContext.d.ts.map +0 -1
  234. package/dist/cjs/components/src/components/Organisms/Chat/ChatAttachmentContext.js +0 -22
  235. package/dist/cjs/components/src/components/Organisms/Chat/ChatResult.d.ts +0 -11
  236. package/dist/cjs/components/src/components/Organisms/Chat/ChatResult.d.ts.map +0 -1
  237. package/dist/cjs/components/src/components/Organisms/Chat/ChatResult.js +0 -177
  238. package/dist/cjs/components/src/components/Organisms/Chat/MessageText.d.ts +0 -13
  239. package/dist/cjs/components/src/components/Organisms/Chat/MessageText.d.ts.map +0 -1
  240. package/dist/cjs/components/src/components/Organisms/Chat/MessageText.js +0 -170
  241. package/dist/cjs/components/src/components/Organisms/Chat/MessageUser.d.ts +0 -11
  242. package/dist/cjs/components/src/components/Organisms/Chat/MessageUser.d.ts.map +0 -1
  243. package/dist/cjs/components/src/components/Organisms/Chat/MessageUser.js +0 -223
  244. package/dist/cjs/components/src/components/Organisms/Chat/ResultsDisplay.d.ts +0 -11
  245. package/dist/cjs/components/src/components/Organisms/Chat/ResultsDisplay.d.ts.map +0 -1
  246. package/dist/cjs/components/src/components/Organisms/Chat/ResultsDisplay.js +0 -94
  247. package/dist/cjs/components/src/components/Organisms/Chat/SuggestedQuestions.d.ts +0 -12
  248. package/dist/cjs/components/src/components/Organisms/Chat/SuggestedQuestions.d.ts.map +0 -1
  249. package/dist/cjs/components/src/components/Organisms/Chat/SuggestedQuestions.js +0 -73
  250. package/dist/cjs/components/src/components/Organisms/Chat/index.d.ts +0 -2
  251. package/dist/cjs/components/src/components/Organisms/Chat/index.d.ts.map +0 -1
  252. package/dist/cjs/components/src/components/Organisms/Chat/index.js +0 -17
  253. package/dist/cjs/src/Templates/Stores/library/components/Chat.d.ts +0 -2
  254. package/dist/cjs/src/Templates/Stores/library/components/Chat.d.ts.map +0 -1
  255. package/dist/cjs/src/Templates/Stores/library/components/Chat.js +0 -5
  256. package/dist/cjs/src/create/createChatController.d.ts +0 -5
  257. package/dist/cjs/src/create/createChatController.d.ts.map +0 -1
  258. package/dist/cjs/src/create/createChatController.js +0 -43
  259. package/dist/esm/components/src/components/Atoms/ChatLoadingIndicator/ChatLoadingIndicator.d.ts +0 -7
  260. package/dist/esm/components/src/components/Atoms/ChatLoadingIndicator/ChatLoadingIndicator.d.ts.map +0 -1
  261. package/dist/esm/components/src/components/Atoms/ChatLoadingIndicator/ChatLoadingIndicator.js +0 -67
  262. package/dist/esm/components/src/components/Atoms/ChatLoadingIndicator/index.d.ts +0 -2
  263. package/dist/esm/components/src/components/Atoms/ChatLoadingIndicator/index.d.ts.map +0 -1
  264. package/dist/esm/components/src/components/Atoms/ChatLoadingIndicator/index.js +0 -1
  265. package/dist/esm/components/src/components/Molecules/ChatInspirationResultMessage/ChatInspirationResultMessage.d.ts +0 -18
  266. package/dist/esm/components/src/components/Molecules/ChatInspirationResultMessage/ChatInspirationResultMessage.d.ts.map +0 -1
  267. package/dist/esm/components/src/components/Molecules/ChatInspirationResultMessage/ChatInspirationResultMessage.js +0 -112
  268. package/dist/esm/components/src/components/Molecules/ChatInspirationResultMessage/index.d.ts +0 -2
  269. package/dist/esm/components/src/components/Molecules/ChatInspirationResultMessage/index.d.ts.map +0 -1
  270. package/dist/esm/components/src/components/Molecules/ChatInspirationResultMessage/index.js +0 -1
  271. package/dist/esm/components/src/components/Molecules/ChatProductComparisonMessage/ChatProductComparisonMessage.d.ts +0 -17
  272. package/dist/esm/components/src/components/Molecules/ChatProductComparisonMessage/ChatProductComparisonMessage.d.ts.map +0 -1
  273. package/dist/esm/components/src/components/Molecules/ChatProductComparisonMessage/ChatProductComparisonMessage.js +0 -85
  274. package/dist/esm/components/src/components/Molecules/ChatProductComparisonMessage/index.d.ts +0 -2
  275. package/dist/esm/components/src/components/Molecules/ChatProductComparisonMessage/index.d.ts.map +0 -1
  276. package/dist/esm/components/src/components/Molecules/ChatProductComparisonMessage/index.js +0 -1
  277. package/dist/esm/components/src/components/Molecules/ChatProductQueryMessage/ChatProductQueryMessage.d.ts +0 -23
  278. package/dist/esm/components/src/components/Molecules/ChatProductQueryMessage/ChatProductQueryMessage.d.ts.map +0 -1
  279. package/dist/esm/components/src/components/Molecules/ChatProductQueryMessage/ChatProductQueryMessage.js +0 -427
  280. package/dist/esm/components/src/components/Molecules/ChatProductQueryMessage/index.d.ts +0 -2
  281. package/dist/esm/components/src/components/Molecules/ChatProductQueryMessage/index.d.ts.map +0 -1
  282. package/dist/esm/components/src/components/Molecules/ChatProductQueryMessage/index.js +0 -1
  283. package/dist/esm/components/src/components/Organisms/Chat/Chat.d.ts +0 -15
  284. package/dist/esm/components/src/components/Organisms/Chat/Chat.d.ts.map +0 -1
  285. package/dist/esm/components/src/components/Organisms/Chat/Chat.js +0 -1742
  286. package/dist/esm/components/src/components/Organisms/Chat/ChatAttachmentContext.d.ts +0 -19
  287. package/dist/esm/components/src/components/Organisms/Chat/ChatAttachmentContext.d.ts.map +0 -1
  288. package/dist/esm/components/src/components/Organisms/Chat/ChatAttachmentContext.js +0 -16
  289. package/dist/esm/components/src/components/Organisms/Chat/ChatResult.d.ts +0 -11
  290. package/dist/esm/components/src/components/Organisms/Chat/ChatResult.d.ts.map +0 -1
  291. package/dist/esm/components/src/components/Organisms/Chat/ChatResult.js +0 -162
  292. package/dist/esm/components/src/components/Organisms/Chat/MessageText.d.ts +0 -13
  293. package/dist/esm/components/src/components/Organisms/Chat/MessageText.d.ts.map +0 -1
  294. package/dist/esm/components/src/components/Organisms/Chat/MessageText.js +0 -152
  295. package/dist/esm/components/src/components/Organisms/Chat/MessageUser.d.ts +0 -11
  296. package/dist/esm/components/src/components/Organisms/Chat/MessageUser.d.ts.map +0 -1
  297. package/dist/esm/components/src/components/Organisms/Chat/MessageUser.js +0 -194
  298. package/dist/esm/components/src/components/Organisms/Chat/ResultsDisplay.d.ts +0 -11
  299. package/dist/esm/components/src/components/Organisms/Chat/ResultsDisplay.d.ts.map +0 -1
  300. package/dist/esm/components/src/components/Organisms/Chat/ResultsDisplay.js +0 -78
  301. package/dist/esm/components/src/components/Organisms/Chat/SuggestedQuestions.d.ts +0 -12
  302. package/dist/esm/components/src/components/Organisms/Chat/SuggestedQuestions.d.ts.map +0 -1
  303. package/dist/esm/components/src/components/Organisms/Chat/SuggestedQuestions.js +0 -58
  304. package/dist/esm/components/src/components/Organisms/Chat/index.d.ts +0 -2
  305. package/dist/esm/components/src/components/Organisms/Chat/index.d.ts.map +0 -1
  306. package/dist/esm/components/src/components/Organisms/Chat/index.js +0 -1
  307. package/dist/esm/src/Templates/Stores/library/components/Chat.d.ts +0 -2
  308. package/dist/esm/src/Templates/Stores/library/components/Chat.d.ts.map +0 -1
  309. package/dist/esm/src/Templates/Stores/library/components/Chat.js +0 -1
  310. package/dist/esm/src/create/createChatController.d.ts +0 -5
  311. package/dist/esm/src/create/createChatController.d.ts.map +0 -1
  312. package/dist/esm/src/create/createChatController.js +0 -29
@@ -1,1742 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@emotion/react/jsx-runtime";
2
- import { css } from '@emotion/react';
3
- import classnames from 'classnames';
4
- import deepmerge from 'deepmerge';
5
- import { observer } from 'mobx-react-lite';
6
- import { useTheme, CacheProvider, useTreePath } from '../../../providers';
7
- import { mergeProps, mergeStyles } from '../../../utilities';
8
- import { Button } from '../../Atoms/Button';
9
- import { useRef, useEffect, useMemo, useState } from 'preact/hooks';
10
- import { MessageUser } from './MessageUser';
11
- import { MessageText } from './MessageText';
12
- import { SuggestedQuestions } from './SuggestedQuestions';
13
- import { ChatAttachmentContext } from './ChatAttachmentContext';
14
- import { Image } from '../../Atoms/Image';
15
- import { ChatLoadingIndicator } from '../../Atoms/ChatLoadingIndicator';
16
- import { Dropdown, Icon, Overlay, useMediaQuery } from '../../..';
17
- import { ChatInspirationResultMessage } from '../../Molecules/ChatInspirationResultMessage';
18
- import { ChatProductComparisonMessage } from '../../Molecules/ChatProductComparisonMessage/ChatProductComparisonMessage';
19
- import { ChatProductQueryMessage } from '../../Molecules/ChatProductQueryMessage/ChatProductQueryMessage';
20
- const defaultStyles = ({ mobile, offset, hasSideChat, footerHeight }) => {
21
- const colorPrimary = '#253B80';
22
- const offsetValue = offset !== undefined ? (typeof offset === 'number' ? `${offset}px` : offset) : undefined;
23
- return css({
24
- position: 'fixed',
25
- left: '20px',
26
- bottom: '20px',
27
- zIndex: 1002,
28
- color: '#333',
29
- '@keyframes ss-chat-slide-up': {
30
- from: { transform: 'translateY(100%)' },
31
- to: { transform: 'translateY(0)' },
32
- },
33
- '.ss__chat__primary': {
34
- ...(mobile
35
- ? { width: '100%', height: '100%' }
36
- : hasSideChat
37
- ? { flex: '1 1 0', minWidth: 0, maxWidth: 600, height: '70vh' }
38
- : { width: 600, maxWidth: 'calc(100vw - 60px)', height: '70vh' }),
39
- display: 'flex',
40
- flexDirection: 'column',
41
- justifyContent: 'flex-end',
42
- overflow: 'hidden',
43
- order: 1,
44
- '.ss__chat__header__title': {
45
- gap: '22px',
46
- },
47
- '.ss__chat__messages': {
48
- padding: '1em',
49
- },
50
- },
51
- '.ss__chat__secondary': {
52
- ...(mobile
53
- ? {
54
- width: '100%',
55
- maxWidth: '100%',
56
- height: `calc(100% - 70px${footerHeight > 0 ? ` - ${footerHeight}px` : ''})`,
57
- maxHeight: `calc(100% - 70px${footerHeight > 0 ? ` - ${footerHeight}px` : ''})`,
58
- }
59
- : { flex: '1 1 0', minWidth: 0, maxWidth: 600, height: '70vh', maxHeight: '70vh' }),
60
- display: 'flex',
61
- flexDirection: 'column',
62
- overflow: 'hidden',
63
- order: 2,
64
- ...(mobile
65
- ? {
66
- position: 'absolute',
67
- bottom: footerHeight > 0 ? footerHeight : 0,
68
- left: 0,
69
- right: 0,
70
- zIndex: 10,
71
- borderTopLeftRadius: '12px',
72
- borderTopRightRadius: '12px',
73
- overflow: 'hidden',
74
- overscrollBehavior: 'contain',
75
- boxShadow: '0 -4px 20px rgba(0, 0, 0, 0.15)',
76
- background: '#fff',
77
- willChange: 'transform',
78
- animation: 'ss-chat-slide-up 0.3s ease-out',
79
- }
80
- : {}),
81
- '.ss__chat__secondary__drag-handle': {
82
- display: 'flex',
83
- justifyContent: 'center',
84
- alignItems: 'center',
85
- padding: '10px 0 2px',
86
- background: colorPrimary,
87
- touchAction: 'none',
88
- cursor: 'grab',
89
- '.ss__chat__secondary__drag-handle__indicator': {
90
- width: '36px',
91
- height: '4px',
92
- borderRadius: '2px',
93
- background: 'rgba(255, 255, 255, 0.4)',
94
- },
95
- },
96
- ...(mobile
97
- ? {
98
- '.ss__chat__header': {
99
- touchAction: 'none',
100
- cursor: 'grab',
101
- },
102
- }
103
- : {}),
104
- '.ss__chat__header__title': {
105
- flexDirection: 'column',
106
- gap: '2px',
107
- '.ss__chat__header__title__primary': {
108
- fontWeight: 'bold',
109
- },
110
- '.ss__chat__header__title__secondary': {
111
- fontSize: '80%',
112
- opacity: 0.85,
113
- },
114
- },
115
- '.ss__chat__messages': {
116
- background: '#fff!important',
117
- },
118
- },
119
- '.ss__button': {
120
- border: 'none',
121
- background: 'none',
122
- color: 'inherit',
123
- '&:not(.ss__button--disabled):hover': {
124
- background: '#dfeaf6',
125
- },
126
- svg: {
127
- fill: colorPrimary,
128
- stroke: colorPrimary,
129
- },
130
- },
131
- '.ss__chat__bubble': {
132
- position: mobile ? 'fixed' : 'absolute',
133
- bottom: mobile ? '20px' : 0,
134
- left: mobile ? '20px' : 0,
135
- width: '60px',
136
- height: '60px',
137
- borderRadius: '50%',
138
- background: colorPrimary,
139
- color: 'white',
140
- display: 'flex',
141
- alignItems: 'center',
142
- justifyContent: 'center',
143
- cursor: 'pointer',
144
- fontSize: '24px',
145
- boxShadow: '0 4px 8px rgba(0, 0, 0, 0.2)',
146
- zIndex: 10,
147
- '&:hover': {
148
- background: '#0052a3',
149
- transform: 'scale(1.05)',
150
- },
151
- '.ss__icon': {
152
- height: '33px',
153
- width: '33px',
154
- fill: '#fff',
155
- stroke: '#fff',
156
- },
157
- },
158
- '.ss__chat__suggested-questions': {
159
- position: mobile ? 'fixed' : 'absolute',
160
- bottom: mobile ? '90px' : '70px',
161
- left: mobile ? '20px' : 0,
162
- display: 'flex',
163
- flexDirection: 'column',
164
- gap: '8px',
165
- width: '250px',
166
- zIndex: 10,
167
- '.ss__chat__suggested-questions__item': {
168
- background: '#fff',
169
- borderRadius: '12px',
170
- padding: '12px 16px',
171
- fontSize: '14px',
172
- color: '#333',
173
- boxShadow: '0 2px 8px rgba(0, 0, 0, 0.2)',
174
- cursor: 'pointer',
175
- lineHeight: 1.4,
176
- '&:hover': {
177
- boxShadow: '0 4px 12px rgba(0, 0, 0, 0.2)',
178
- },
179
- },
180
- },
181
- '&.ss__chat--minimized': {
182
- width: '60px',
183
- height: '60px',
184
- minHeight: '60px',
185
- },
186
- '&.ss__chat--open': {
187
- display: 'flex',
188
- flexDirection: mobile ? 'column' : 'row',
189
- gap: mobile ? 0 : '12px',
190
- ...(mobile
191
- ? {
192
- top: offsetValue || 0,
193
- left: 0,
194
- right: 0,
195
- bottom: 0,
196
- width: '100%',
197
- height: offsetValue ? `calc(100% - ${offsetValue})` : '100%',
198
- }
199
- : {
200
- width: hasSideChat ? 'calc(100vw - 60px)' : 'auto',
201
- maxWidth: 'calc(100vw - 60px)',
202
- maxHeight: 'calc(100vh - 40px)',
203
- }),
204
- '.ss__chat__bubble': {
205
- display: 'none',
206
- },
207
- },
208
- '.ss__chat__header': {
209
- display: 'flex',
210
- justifyContent: 'space-between',
211
- alignItems: 'center',
212
- fontSize: '16px',
213
- position: 'relative',
214
- padding: '10px 15px',
215
- color: '#fff',
216
- background: colorPrimary,
217
- borderTopLeftRadius: mobile ? 0 : '12px',
218
- borderTopRightRadius: mobile ? 0 : '12px',
219
- '.ss__chat__header__title': {
220
- display: 'flex',
221
- '.ss__chat__header__title__logo': {
222
- height: '44px',
223
- width: 'auto',
224
- },
225
- '.ss__chat__header__title__text': {
226
- display: 'flex',
227
- flexDirection: 'column',
228
- '.ss__chat__header__title__text__primary': {
229
- fontWeight: 'bold',
230
- },
231
- '.ss__chat__header__title__text__secondary': {
232
- fontSize: '80%',
233
- },
234
- },
235
- },
236
- '.ss__chat__header__buttons': {
237
- display: 'flex',
238
- gap: '10px',
239
- '.ss__button': {
240
- display: 'flex',
241
- flexDirection: 'row-reverse',
242
- padding: '5px',
243
- border: 0,
244
- fontSize: '70%',
245
- '&:hover': {
246
- backgroundColor: 'transparent',
247
- },
248
- svg: {
249
- fill: '#fff',
250
- stroke: '#fff',
251
- },
252
- },
253
- },
254
- '.ss__chat__header__dropdown-history': {
255
- '&.ss__dropdown--open': {
256
- '.ss__dropdown__button': {
257
- backgroundColor: '#dddddd33',
258
- borderRadius: '6px',
259
- },
260
- },
261
- '.ss__dropdown__button': {
262
- display: 'flex',
263
- alignItems: 'center',
264
- },
265
- },
266
- '.ss__chat__history': {
267
- color: '#333',
268
- position: 'absolute',
269
- width: 300,
270
- minHeight: 170,
271
- top: 6,
272
- right: 0,
273
- background: 'white',
274
- zIndex: 2,
275
- boxShadow: '0px 3px 6px 0px rgba(0, 0, 0, 0.2)',
276
- borderRadius: '6px',
277
- display: 'flex',
278
- flexDirection: 'column',
279
- gap: 5,
280
- padding: '10px',
281
- boxSizing: 'border-box',
282
- '.ss__chat__history__header': {
283
- display: 'flex',
284
- justifyContent: 'space-between',
285
- alignItems: 'center',
286
- h4: {
287
- margin: 0,
288
- fontSize: '14px',
289
- },
290
- '.ss__chat__history__header__buttons': {
291
- '.ss__button': {
292
- fontSize: '14px',
293
- color: '#333',
294
- '&:hover': {
295
- background: 'none',
296
- color: '#000',
297
- },
298
- },
299
- },
300
- },
301
- '.ss__chat__history__chats': {
302
- display: 'flex',
303
- flexDirection: 'column-reverse',
304
- gap: 5,
305
- '.ss__chat__history__chats__chat': {
306
- '.ss__button': {
307
- borderRadius: '12px',
308
- width: '100%',
309
- border: '1px solid #eee',
310
- fontSize: '12px',
311
- display: 'flex',
312
- flexDirection: 'column',
313
- boxSizing: 'border-box',
314
- '.ss__chat__history__chat__button__text': {
315
- fontWeight: 'bold',
316
- },
317
- '.ss__chat__history__chat__button__date': {},
318
- },
319
- },
320
- },
321
- },
322
- },
323
- '.ss__chat__session-feedback': {
324
- display: 'flex',
325
- alignItems: 'center',
326
- gap: '10px',
327
- padding: '8px 15px',
328
- background: '#40528e',
329
- color: '#fff',
330
- fontSize: '14px',
331
- '.ss__chat__session-feedback__icon': {
332
- flex: '0 0 auto',
333
- display: 'flex',
334
- alignItems: 'center',
335
- svg: {
336
- fill: '#fff',
337
- stroke: '#fff',
338
- },
339
- },
340
- '.ss__chat__session-feedback__label': {
341
- flex: '1 1 auto',
342
- whiteSpace: 'nowrap',
343
- },
344
- '.ss__chat__session-feedback__actions': {
345
- display: 'flex',
346
- gap: '10px',
347
- alignItems: 'center',
348
- '> span': {
349
- display: 'flex',
350
- alignItems: 'center',
351
- justifyContent: 'center',
352
- },
353
- svg: {
354
- cursor: 'pointer',
355
- fill: '#fff',
356
- stroke: '#fff',
357
- opacity: 0.7,
358
- '&:hover': {
359
- opacity: 1,
360
- },
361
- },
362
- '&.ss__chat__session-feedback__actions--rated svg': {
363
- opacity: 1,
364
- cursor: 'default',
365
- },
366
- },
367
- '.ss__chat__session-feedback__close': {
368
- flex: '0 0 auto',
369
- display: 'flex',
370
- alignItems: 'center',
371
- cursor: 'pointer',
372
- svg: {
373
- fill: '#fff',
374
- stroke: '#fff',
375
- opacity: 0.7,
376
- '&:hover': {
377
- opacity: 1,
378
- },
379
- },
380
- },
381
- },
382
- '.ss__chat__content': {
383
- background: '#fff',
384
- maxHeight: mobile ? undefined : '90vh',
385
- overflow: 'hidden',
386
- display: 'flex',
387
- flexDirection: 'column',
388
- border: '1px solid #0066cc',
389
- borderTop: 'none',
390
- marginTop: '-1px',
391
- borderBottomRightRadius: mobile ? 0 : '12px',
392
- borderBottomLeftRadius: mobile ? 0 : '12px',
393
- flexGrow: 1,
394
- position: 'relative',
395
- '.ss__chat__content__header': {
396
- // In overlay mode (only applied when messages overflow), the comparisons
397
- // tray floats over the messages so toggling it doesn't shift the layout
398
- // or push the latest message out of view. When messages don't overflow,
399
- // the tray stays in flow so older messages remain reachable above it.
400
- '&.ss__chat__content__header--overlay': {
401
- position: 'absolute',
402
- top: 0,
403
- left: 0,
404
- right: 0,
405
- zIndex: 20,
406
- },
407
- // '.ss__chat__attachments': {
408
- // '.ss__chat__attachment': {
409
- // borderRadius: 0,
410
- // borderLeft: 0,
411
- // borderRight: 0,
412
- // },
413
- // },
414
- '.ss__chat__content__header__comparisons': {
415
- display: 'flex',
416
- flexDirection: 'column',
417
- gap: '1em',
418
- background: '#f4f4ff',
419
- padding: '1em',
420
- '.ss__chat__content__header__comparisons__header': {
421
- display: 'flex',
422
- justifyContent: 'space-between',
423
- '.ss__chat__content__header__comparisons__header__title': {
424
- fontWeight: 'bold',
425
- fontSize: '1.2em',
426
- display: 'flex',
427
- alignItems: 'center',
428
- gap: '0.5em',
429
- '.ss__chat__content__header__comparisons__header__title__icon': {
430
- background: colorPrimary,
431
- borderRadius: '50%',
432
- padding: '5px',
433
- fill: '#fff',
434
- height: '25px',
435
- width: '25px',
436
- },
437
- },
438
- '.ss__chat__content__header__comparisons__header__actions': {
439
- '.ss__button': {
440
- border: 'none',
441
- background: 'none',
442
- },
443
- },
444
- },
445
- '.ss__chat__content__header__comparisons__content': {
446
- display: 'flex',
447
- gap: '1em',
448
- alignItems: 'stretch',
449
- '.ss__chat__content__header__comparisons__content__items': {
450
- display: 'flex',
451
- flex: '1 1 calc(100% - 100px)',
452
- justifyContent: 'space-between',
453
- gap: '0.5em',
454
- },
455
- '.ss__chat__content__header__comparisons__content__comparison': {
456
- background: '#fff',
457
- padding: '0.5em',
458
- borderRadius: '1em',
459
- display: 'flex',
460
- flexDirection: 'column',
461
- gap: '0.5em',
462
- flex: '0 1 25%',
463
- position: 'relative',
464
- '&.ss__chat__content__header__comparisons__content__comparison--placeholder': {
465
- border: '2px dashed #ddd',
466
- display: 'flex',
467
- alignItems: 'center',
468
- justifyContent: 'center',
469
- '.ss__chat__content__header__comparisons__content__comparison--placeholder__text': {
470
- color: '#999',
471
- fontStyle: 'italic',
472
- },
473
- },
474
- '.ss__chat__content__header__comparisons__content__comparison__remove': {
475
- position: 'absolute',
476
- top: '-3px',
477
- right: '-3px',
478
- cursor: 'pointer',
479
- background: 'red',
480
- borderRadius: '50%',
481
- padding: '0.4em',
482
- height: 20,
483
- width: 20,
484
- display: 'flex',
485
- alignItems: 'center',
486
- justifyContent: 'center',
487
- svg: {
488
- fill: '#fff',
489
- stroke: '#fff',
490
- },
491
- },
492
- },
493
- '.ss__chat__content__header__comparisons__action': {
494
- display: 'flex',
495
- alignItems: 'center',
496
- marginLeft: 'auto',
497
- flex: '1 1 auto',
498
- '&.ss__chat__content__header__comparisons__action--hidden': {
499
- visibility: 'hidden',
500
- },
501
- '.ss__button': {
502
- flexDirection: 'row-reverse',
503
- borderRadius: '1em',
504
- padding: '0.5em 1em',
505
- background: colorPrimary,
506
- color: '#fff',
507
- textAlign: 'center',
508
- svg: {
509
- fill: '#fff',
510
- stroke: '#fff',
511
- },
512
- },
513
- },
514
- },
515
- },
516
- },
517
- '.ss__chat__messages': {
518
- flex: '1 1 auto',
519
- overflowY: 'auto',
520
- overscrollBehavior: 'contain',
521
- margin: 0,
522
- maxHeight: '100%',
523
- background: '#f9fafc',
524
- '.ss__chat__messages__end': {
525
- height: '1px',
526
- },
527
- '.ss__chat__new-messages': {
528
- position: 'sticky',
529
- bottom: '10px',
530
- display: 'flex',
531
- alignItems: 'center',
532
- justifyContent: 'center',
533
- gap: '6px',
534
- margin: '0 auto',
535
- width: 'fit-content',
536
- padding: '6px 16px',
537
- background: colorPrimary,
538
- color: '#fff',
539
- borderRadius: '999px',
540
- fontSize: '13px',
541
- fontWeight: 500,
542
- cursor: 'pointer',
543
- boxShadow: '0 2px 8px rgba(0, 0, 0, 0.15)',
544
- zIndex: 5,
545
- '&:hover': {
546
- background: '#1a2a5c',
547
- },
548
- svg: {
549
- fill: '#fff',
550
- stroke: '#fff',
551
- },
552
- },
553
- '.ss__chat__message': {
554
- marginBottom: '30px',
555
- ul: {
556
- margin: 0,
557
- listStyle: 'inside',
558
- },
559
- p: {
560
- margin: 0,
561
- },
562
- thead: {
563
- backgroundColor: '#eee',
564
- },
565
- 'tbody tr:nth-child(even)': {
566
- backgroundColor: '#f5f5f5',
567
- },
568
- 'table th, table td': {
569
- padding: '0.2em 0.5em',
570
- },
571
- 'table + h3': {
572
- margin: '1em 0 0 0',
573
- fontSize: '1.3em',
574
- },
575
- },
576
- '.ss__chat__welcome': {
577
- display: 'flex',
578
- flexDirection: 'column',
579
- minHeight: '100%',
580
- '.ss__chat__welcome__message': {
581
- fontSize: '15px',
582
- lineHeight: 1.5,
583
- color: '#333',
584
- padding: '2em',
585
- textAlign: 'center',
586
- },
587
- '.ss__chat__suggestions': {
588
- marginTop: 'auto',
589
- },
590
- },
591
- },
592
- '.ss__chat__actions': {
593
- display: 'flex',
594
- flexDirection: 'column',
595
- gap: '6px',
596
- overflow: 'hidden',
597
- '.ss__chat__actions__wrap': {
598
- display: 'flex',
599
- flexDirection: 'column',
600
- gap: '6px',
601
- padding: '8px 10px',
602
- background: '#f4f4ff',
603
- border: '1px solid #e3e3f5',
604
- borderRadius: '8px',
605
- },
606
- '.ss__chat__actions--title': {
607
- fontSize: '14px',
608
- color: '#333',
609
- },
610
- '.ss__chat__actions--facets, .ss__chat__actions--suggested': {
611
- display: 'flex',
612
- flexDirection: 'row',
613
- gap: '6px',
614
- '.ss__button': {
615
- flex: '0 0 auto',
616
- background: '#fff',
617
- border: '1px solid #ddd',
618
- borderRadius: '999px',
619
- padding: '3px 10px',
620
- fontSize: '14px',
621
- color: '#333',
622
- '&:hover': {
623
- background: '#f9f9ff',
624
- },
625
- },
626
- },
627
- '.ss__chat__actions--facets': {
628
- overflowX: 'auto',
629
- overflowY: 'hidden',
630
- scrollbarWidth: 'none',
631
- '&::-webkit-scrollbar': {
632
- display: 'none',
633
- },
634
- },
635
- '.ss__chat__actions--suggested': {
636
- overflowX: 'scroll',
637
- },
638
- '.ss__chat__actions__facet': {},
639
- '.ss__chat__actions__facets-dropdown': {
640
- '.ss__dropdown__content': {
641
- bottom: '0',
642
- top: 'auto',
643
- left: '-15px',
644
- width: mobile ? '100vw' : '600px',
645
- zIndex: 100,
646
- background: 'white',
647
- borderTop: '1px solid #ddd',
648
- },
649
- },
650
- },
651
- '.ss__chat__facets': {
652
- '.ss__chat__facets__header': {
653
- display: 'flex',
654
- flexDirection: mobile ? 'column' : 'row',
655
- justifyContent: 'space-between',
656
- alignItems: 'center',
657
- padding: '10px',
658
- '.ss__chat__facets__header__title': {
659
- width: mobile ? '100%' : undefined,
660
- fontSize: '18px',
661
- fontWeight: 'bold',
662
- color: '#333',
663
- order: mobile ? 1 : 0,
664
- marginTop: mobile ? '10px' : 0,
665
- },
666
- '.ss__chat__facets__close': {
667
- order: mobile ? 0 : 1,
668
- display: 'flex',
669
- justifyContent: mobile ? 'center' : 'flex-end',
670
- '.ss__chat__facets__close__button': {
671
- width: mobile ? '100px' : '20px',
672
- borderRadius: mobile ? '4px' : undefined,
673
- background: mobile ? '#ccc' : 'none',
674
- padding: '5px',
675
- flexGrow: 0,
676
- border: 'none',
677
- '.ss__icon': {
678
- display: mobile ? 'none' : 'inline',
679
- },
680
- },
681
- },
682
- },
683
- '.ss__chat__facets__wrapper': {
684
- padding: '10px',
685
- display: 'flex',
686
- flexDirection: 'column',
687
- gap: '10px',
688
- '.ss__chat__facets__facet': {
689
- display: 'flex',
690
- justifyContent: 'flex-start',
691
- alignItems: 'center',
692
- '.ss__chat__facets__facet__label': {
693
- fontWeight: 'bold',
694
- fontSize: '14px',
695
- marginRight: '10px',
696
- },
697
- '.ss__chat__facets__facet__options': {
698
- display: 'flex',
699
- gap: '5px',
700
- overflowX: 'scroll',
701
- '.ss__chat__facets__facet__options__option': {
702
- flexGrow: 0,
703
- },
704
- },
705
- },
706
- },
707
- },
708
- '.ss__chat__actions__facets-header': {
709
- display: 'flex',
710
- justifyContent: 'space-between',
711
- alignItems: 'center',
712
- },
713
- '.ss__chat__actions__facets-apply': {
714
- display: 'flex',
715
- justifyContent: 'flex-end',
716
- padding: '0 2px',
717
- // reserve the slot so toggling the button's visibility doesn't reflow the header
718
- visibility: 'hidden',
719
- '&.ss__chat__actions__facets-apply--active': {
720
- visibility: 'visible',
721
- },
722
- '.ss__button': {
723
- background: '#253B80',
724
- color: '#fff',
725
- border: 'none',
726
- borderRadius: '999px',
727
- padding: '2px 10px',
728
- fontSize: '12px',
729
- lineHeight: '1.4',
730
- cursor: 'pointer',
731
- '&:not(.ss__button--disabled):hover': {
732
- background: '#1a2a5c',
733
- },
734
- '&.ss__button--disabled': {
735
- opacity: 0.5,
736
- cursor: 'not-allowed',
737
- },
738
- },
739
- },
740
- '@keyframes ss-chat-dot-pulse': {
741
- '0%, 80%, 100%': {
742
- transform: 'scale(0.6)',
743
- opacity: 0.5,
744
- },
745
- '40%': {
746
- transform: 'scale(1)',
747
- opacity: 1,
748
- },
749
- },
750
- '.ss__chat__attachment-context': {
751
- display: 'flex',
752
- flexDirection: 'column',
753
- gap: '6px',
754
- padding: '8px 10px',
755
- background: '#f4f4ff',
756
- border: '1px solid #e3e3f5',
757
- borderRadius: '8px',
758
- '.ss__chat__attachment-context__label': {
759
- fontSize: '14px',
760
- display: 'flex',
761
- alignItems: 'center',
762
- justifyContent: 'space-between',
763
- gap: '8px',
764
- '.ss__chat__attachment-context__label__close': {
765
- display: 'flex',
766
- alignItems: 'center',
767
- justifyContent: 'center',
768
- cursor: 'pointer',
769
- flex: '0 0 auto',
770
- },
771
- },
772
- '.ss__chat__attachment-context__items': {
773
- display: 'flex',
774
- flexWrap: 'wrap',
775
- gap: '6px',
776
- },
777
- '.ss__chat__attachment-context__item': {
778
- display: 'flex',
779
- alignItems: 'center',
780
- gap: '6px',
781
- padding: '3px 8px 3px 3px',
782
- background: '#fff',
783
- border: '1px solid #ddd',
784
- borderRadius: '999px',
785
- maxWidth: 'calc(50% - 3px)',
786
- position: 'relative',
787
- '.ss__chat__attachment-context__item__content': {
788
- display: 'flex',
789
- alignItems: 'center',
790
- justifyContent: 'center',
791
- flex: '0 0 auto',
792
- '.ss__image': {
793
- width: '30px',
794
- height: '30px',
795
- margin: 0,
796
- img: {
797
- width: '30px',
798
- height: '30px',
799
- borderRadius: '50%',
800
- objectFit: 'cover',
801
- },
802
- },
803
- },
804
- '.ss__chat__attachment-context__item__name': {
805
- fontSize: '14px',
806
- color: '#333',
807
- whiteSpace: 'nowrap',
808
- overflow: 'hidden',
809
- textOverflow: 'ellipsis',
810
- flex: '1 1 auto',
811
- minWidth: 0,
812
- },
813
- '.ss__chat__attachment-context__item__remove': {
814
- width: '18px',
815
- height: '18px',
816
- minWidth: 'auto',
817
- margin: 0,
818
- padding: 0,
819
- background: 'none',
820
- border: 'none',
821
- display: 'flex',
822
- alignItems: 'center',
823
- justifyContent: 'center',
824
- cursor: 'pointer',
825
- flex: '0 0 auto',
826
- svg: {
827
- fill: '#6A7282',
828
- stroke: '#6A7282',
829
- },
830
- '&:hover': {
831
- svg: {
832
- fill: '#000',
833
- stroke: '#000',
834
- },
835
- },
836
- },
837
- '.ss__chat__attachment-context__item__loading': {
838
- display: 'flex',
839
- gap: '3px',
840
- margin: 0,
841
- '.ss__chat__loading__dot': {
842
- width: '5px',
843
- height: '5px',
844
- borderRadius: '50%',
845
- backgroundColor: '#ccc',
846
- animation: 'ss-chat-dot-pulse 1.4s infinite ease-in-out both',
847
- '&:nth-of-type(1)': {
848
- animationDelay: '-0.32s',
849
- },
850
- '&:nth-of-type(2)': {
851
- animationDelay: '-0.16s',
852
- },
853
- },
854
- },
855
- '&.error': {
856
- border: '1px solid #dc3545',
857
- background: '#fff5f5',
858
- '.ss__chat__attachment-context__item__error-icon': {
859
- fontSize: '14px',
860
- color: '#dc3545',
861
- margin: '0 4px',
862
- flex: '0 0 auto',
863
- },
864
- '.ss__chat__attachment-context__item__error-message': {
865
- fontSize: '12px',
866
- color: '#dc3545',
867
- whiteSpace: 'normal',
868
- wordBreak: 'break-word',
869
- flex: '1 1 auto',
870
- minWidth: 0,
871
- },
872
- '.ss__button': {
873
- svg: {
874
- fill: '#dc3545',
875
- stroke: '#dc3545',
876
- },
877
- },
878
- },
879
- img: {
880
- '&.loading': {
881
- opacity: 0.3,
882
- },
883
- },
884
- },
885
- },
886
- '.ss__chat__content__footer': {
887
- padding: '1em',
888
- display: 'flex',
889
- flexDirection: 'column',
890
- gap: '8px',
891
- flexShrink: 0,
892
- ...(mobile
893
- ? {
894
- position: 'relative',
895
- zIndex: 11,
896
- background: '#fff',
897
- }
898
- : {}),
899
- },
900
- '.ss__chat__topic-drift': {
901
- display: 'flex',
902
- alignItems: 'center',
903
- gap: '12px',
904
- padding: '12px 16px',
905
- border: '1px solid #93C5FD',
906
- borderRadius: '8px',
907
- backgroundColor: '#fff',
908
- '.ss__chat__topic-drift__icon--info': {
909
- flex: '0 0 auto',
910
- fill: colorPrimary,
911
- stroke: colorPrimary,
912
- svg: {
913
- fill: colorPrimary,
914
- stroke: colorPrimary,
915
- },
916
- },
917
- '.ss__chat__topic-drift__text': {
918
- flex: '1 1 0%',
919
- display: 'flex',
920
- flexDirection: 'column',
921
- gap: '2px',
922
- 'span:first-of-type': {
923
- fontWeight: 'bold',
924
- color: colorPrimary,
925
- fontSize: '14px',
926
- },
927
- 'span:last-of-type': {
928
- color: '#6A7282',
929
- fontSize: '13px',
930
- },
931
- },
932
- '.ss__chat__topic-drift__button': {
933
- flex: '0 0 auto',
934
- backgroundColor: colorPrimary,
935
- color: '#fff',
936
- borderRadius: '6px',
937
- padding: '8px 14px',
938
- fontSize: '13px',
939
- fontWeight: 500,
940
- cursor: 'pointer',
941
- whiteSpace: 'nowrap',
942
- '&:not(.ss__button--disabled):hover': {
943
- background: '#1a2a5c',
944
- },
945
- },
946
- '.ss__chat__topic-drift__icon--close': {
947
- flex: '0 0 auto',
948
- cursor: 'pointer',
949
- fill: '#6A7282',
950
- stroke: '#6A7282',
951
- svg: {
952
- fill: '#6A7282',
953
- stroke: '#6A7282',
954
- },
955
- },
956
- },
957
- '.ss__chat__input': {
958
- display: 'flex',
959
- justifyContent: 'space-between',
960
- gap: '8px',
961
- flexShrink: 0,
962
- '.ss__chat__input__input': {
963
- flex: '1 1 0%',
964
- minWidth: 0,
965
- border: '1px solid #ccc',
966
- borderRadius: '2em',
967
- display: 'flex',
968
- justifyContent: 'space-between',
969
- overflow: 'auto',
970
- 'input[type="text"]': {
971
- padding: '0.5em 0',
972
- margin: '0 0 0 1em',
973
- flex: '1 0 auto',
974
- border: 'none',
975
- '&::placeholder': {
976
- color: '#999',
977
- opacity: 0.7,
978
- },
979
- '&:focus': {
980
- outline: 'none',
981
- borderColor: '#0066cc',
982
- },
983
- },
984
- '.ss__button': {
985
- margin: '0 0.5em 0 0',
986
- '&:hover': {
987
- backgroundColor: 'transparent',
988
- },
989
- },
990
- 'input[type="file"]': {
991
- display: 'none',
992
- },
993
- },
994
- '.ss__chat__input__actions': {
995
- '.ss__button': {
996
- backgroundColor: colorPrimary,
997
- borderRadius: '50%',
998
- height: '3em',
999
- width: '3em',
1000
- cursor: 'pointer',
1001
- justifyContent: 'center',
1002
- '&:disabled': {
1003
- opacity: 0.5,
1004
- cursor: 'not-allowed',
1005
- },
1006
- svg: {
1007
- fill: '#fff',
1008
- stroke: '#fff',
1009
- },
1010
- },
1011
- },
1012
- },
1013
- '.ss__chat__disclaimer': {
1014
- fontSize: '10px',
1015
- color: '#6A7282',
1016
- textAlign: 'center',
1017
- flexShrink: 0,
1018
- },
1019
- },
1020
- });
1021
- };
1022
- export const Chat = observer((properties) => {
1023
- const globalTheme = useTheme();
1024
- const globalTreePath = useTreePath();
1025
- const isMobile = useMediaQuery('(max-width: 767px)');
1026
- const defaultProps = {
1027
- treePath: globalTreePath,
1028
- logo: 'https://cdn.athoscommerce.net/snap/images/Athos%20Commerce_Icon_white.svg',
1029
- title: 'Athos Conversational Assistant',
1030
- subtitle: 'Ready to assist you',
1031
- multiselectFacets: true,
1032
- disableBubbleSuggestedQuestions: false,
1033
- };
1034
- let props = mergeProps('facets', globalTheme, defaultProps, properties);
1035
- const { className, internalClassName, controller, logo, title, subtitle, offset, multiselectFacets, disableBubbleSuggestedQuestions } = props;
1036
- const { store } = controller;
1037
- const themeDefaults = {
1038
- components: {},
1039
- };
1040
- // merge deeply the themeDefaults with the theme props and the displaySettings theme props (do not merge arrays, but replace them)
1041
- const theme = deepmerge(themeDefaults, props?.theme || {}, { arrayMerge: (destinationArray, sourceArray) => sourceArray });
1042
- props = {
1043
- ...props,
1044
- theme,
1045
- };
1046
- const fileInputRef = useRef(null);
1047
- const messagesEndRef = useRef(null);
1048
- const messagesContainerRef = useRef(null);
1049
- const headerRef = useRef(null);
1050
- const footerRef = useRef(null);
1051
- // Swipe-to-dismiss state for mobile secondary panel
1052
- const secondaryRef = useRef(null);
1053
- const swipeStartY = useRef(0);
1054
- const swipeStartTime = useRef(0);
1055
- const swipeActive = useRef(false);
1056
- const swipeOffsetRef = useRef(0);
1057
- const [swipeOffset, setSwipeOffsetRaw] = useState(0);
1058
- const [swipeAnimating, setSwipeAnimating] = useState(false);
1059
- const [mobileProductInfoOpen, setMobileProductInfoOpen] = useState(false);
1060
- const [footerHeight, setFooterHeight] = useState(0);
1061
- const [showNewMessages, setShowNewMessages] = useState(false);
1062
- const [messagesOverflow, setMessagesOverflow] = useState(false);
1063
- const isNearBottomRef = useRef(true);
1064
- const updateSwipeOffset = (value) => {
1065
- swipeOffsetRef.current = value;
1066
- setSwipeOffsetRaw(value);
1067
- };
1068
- const scrollToBottom = () => {
1069
- // Scroll the messages container directly (instead of scrollIntoView on the
1070
- // bottom anchor) so the browser never walks up the ancestor chain. On small
1071
- // viewports a smooth scrollIntoView could otherwise animate the document/
1072
- // visual viewport and visually push the fixed-position chat off-screen.
1073
- const container = messagesContainerRef.current;
1074
- if (container) {
1075
- container.scrollTo({ top: container.scrollHeight, behavior: 'smooth' });
1076
- }
1077
- };
1078
- // Conditional scroll: only scrolls if the user is already near the bottom.
1079
- // Passed to child components (e.g. image onLoad) so they don't yank the user
1080
- // back to the bottom when they have scrolled up to read older messages.
1081
- const scrollToBottomIfNear = () => {
1082
- if (isNearBottomRef.current) {
1083
- scrollToBottom();
1084
- }
1085
- };
1086
- // productQuery messages are filtered out of the main chat render (they only drive the side-chat panel),
1087
- // so don't auto-scroll when one is added — otherwise clicking a product in the side chat scrolls the main thread.
1088
- const visibleChatLength = (store.currentChat?.chat || []).filter((m) => m.messageType !== 'productQuery').length;
1089
- // Scroll to bottom when chat opens
1090
- useEffect(() => {
1091
- if (store.open) {
1092
- scrollToBottom();
1093
- setShowNewMessages(false);
1094
- isNearBottomRef.current = true;
1095
- }
1096
- }, [store.open]);
1097
- // Handle new messages — auto-scroll for user messages, show popup for response messages when scrolled up
1098
- useEffect(() => {
1099
- if (!store.open)
1100
- return;
1101
- const chat = store.currentChat?.chat || [];
1102
- const visibleChat = chat.filter((m) => m.messageType !== 'productQuery');
1103
- const lastMessage = visibleChat[visibleChat.length - 1];
1104
- if (!lastMessage)
1105
- return;
1106
- if (lastMessage.messageType === 'user') {
1107
- scrollToBottom();
1108
- setShowNewMessages(false);
1109
- }
1110
- else {
1111
- if (isNearBottomRef.current) {
1112
- scrollToBottom();
1113
- setShowNewMessages(false);
1114
- }
1115
- else {
1116
- setShowNewMessages(true);
1117
- }
1118
- }
1119
- }, [visibleChatLength]);
1120
- // Scroll to show loading indicator when user sends a message
1121
- useEffect(() => {
1122
- if (store.open && store.loading) {
1123
- scrollToBottom();
1124
- }
1125
- }, [store.loading]);
1126
- // Track scroll position to dismiss the "New messages" popup when user scrolls to bottom
1127
- useEffect(() => {
1128
- const container = messagesContainerRef.current;
1129
- if (!container)
1130
- return;
1131
- const handleScroll = () => {
1132
- const threshold = 100;
1133
- const isNearBottom = container.scrollHeight - container.scrollTop - container.clientHeight < threshold;
1134
- isNearBottomRef.current = isNearBottom;
1135
- if (isNearBottom) {
1136
- setShowNewMessages(false);
1137
- }
1138
- };
1139
- container.addEventListener('scroll', handleScroll);
1140
- return () => container.removeEventListener('scroll', handleScroll);
1141
- }, [store.open]);
1142
- // Track whether the messages container is overflowing so the comparisons header
1143
- // can switch between in-flow (short conversations — top content stays reachable)
1144
- // and overlay (overflowing — avoid layout shift when toggling the tray).
1145
- // Hysteresis: when already in overlay, only return to in-flow if the content
1146
- // would still fit *with* the header re-inserted — otherwise the two states
1147
- // fight each other and the layout flickers.
1148
- useEffect(() => {
1149
- const container = messagesContainerRef.current;
1150
- if (!container || typeof ResizeObserver === 'undefined')
1151
- return;
1152
- const update = () => {
1153
- setMessagesOverflow((prev) => {
1154
- const headerHeight = headerRef.current?.offsetHeight || 0;
1155
- if (prev) {
1156
- // Currently overlay: header isn't taking flow space. Only switch
1157
- // back to in-flow if the content would fit with the header added.
1158
- return container.scrollHeight > container.clientHeight - headerHeight + 1;
1159
- }
1160
- // Currently in-flow: header already takes space — straightforward check.
1161
- return container.scrollHeight > container.clientHeight + 1;
1162
- });
1163
- };
1164
- update();
1165
- const observer = new ResizeObserver(update);
1166
- observer.observe(container);
1167
- if (headerRef.current)
1168
- observer.observe(headerRef.current);
1169
- return () => observer.disconnect();
1170
- }, [store.open, visibleChatLength]);
1171
- // Re-focus the chat input on desktop after a search completes.
1172
- // The input is disabled while loading, which causes the browser to drop focus.
1173
- // On mobile we intentionally skip this so the virtual keyboard dismisses.
1174
- useEffect(() => {
1175
- if (!store.loading && !isMobile && store.open) {
1176
- controller.focusInput();
1177
- }
1178
- }, [store.loading]);
1179
- // const subProps: ChatSubProps = {};
1180
- const activeMessage = store.currentChat?.activeMessage;
1181
- // On mobile, only auto-open the secondary panel for the first productComparison
1182
- // message in the chat session. Subsequent comparison results show a "Show Details"
1183
- // button instead (handled in MessageText via sideChatLabel toggle).
1184
- const isFirstMobileComparison = (() => {
1185
- if (!isMobile || activeMessage?.messageType !== 'productComparison')
1186
- return true;
1187
- // If the user explicitly activated a comparison (via "Show Details" or the
1188
- // view-side-chat button), always allow it regardless of position in the chat
1189
- if (store.currentChat?.activeMessageId)
1190
- return true;
1191
- const comparisonMessages = (store.currentChat?.chat || []).filter((m) => m.messageType === 'productComparison');
1192
- return comparisonMessages.length <= 1;
1193
- })();
1194
- const sideChatTypes = isMobile
1195
- ? ['inspirationResult', ...(isFirstMobileComparison ? ['productComparison'] : []), ...(mobileProductInfoOpen ? ['productQuery'] : [])]
1196
- : ['inspirationResult', 'productComparison', 'productQuery'];
1197
- const shouldShowSideChat = activeMessage && sideChatTypes.includes(activeMessage?.messageType) && store.currentChat?.dismissedSideChatMessageId !== activeMessage.id;
1198
- const styling = mergeStyles({ mobile: isMobile, offset, hasSideChat: !!shouldShowSideChat, footerHeight }, defaultStyles);
1199
- // Lock body scroll while chat is open so touch/wheel scrolls don't leak to the page behind
1200
- useEffect(() => {
1201
- if (!store.open)
1202
- return;
1203
- const body = document.body;
1204
- const previousOverflow = body.style.overflow;
1205
- const previousOverscroll = body.style.overscrollBehavior;
1206
- body.style.overflow = 'hidden';
1207
- body.style.overscrollBehavior = 'contain';
1208
- return () => {
1209
- body.style.overflow = previousOverflow;
1210
- body.style.overscrollBehavior = previousOverscroll;
1211
- };
1212
- }, [store.open]);
1213
- // Track the primary footer height so the mobile secondary panel can sit above it
1214
- useEffect(() => {
1215
- const el = footerRef.current;
1216
- if (!el)
1217
- return;
1218
- const observer = new ResizeObserver((entries) => {
1219
- for (const entry of entries) {
1220
- setFooterHeight(entry.borderBoxSize?.[0]?.blockSize ?? entry.target.getBoundingClientRect().height);
1221
- }
1222
- });
1223
- observer.observe(el);
1224
- return () => observer.disconnect();
1225
- }, [store.open, store.currentChat?.isExpired]);
1226
- const HistoryButton = (props) => (_jsx(Button, { className: "ss__chat__header__button--history", disabled: props.disabled, icon: {
1227
- icon: 'history',
1228
- title: 'Chat History',
1229
- } }));
1230
- 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: () => {
1231
- controller.store.clearHistory();
1232
- props.toggleOpen && props.toggleOpen();
1233
- } }) })] }), 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: () => {
1234
- controller.store.switchChat(chat.id);
1235
- }, disabled: chat.id === store.currentChatId, children: [_jsx("div", { className: "ss__chat__history__chat__button__text", children: (() => {
1236
- const lastUserMessage = [...chat.chat].reverse().find((message) => message.messageType === 'user');
1237
- if (!lastUserMessage)
1238
- return 'New Chat';
1239
- const text = lastUserMessage.text;
1240
- return text.length > 50 ? `${text.slice(0, 50)}...` : text;
1241
- })() }), _jsx("div", { className: "ss__chat__history__chat__button__date", children: chat.createdAt.toLocaleString() })] }) }, chat.id))) })) : null] }));
1242
- const FacetButton = (props) => _jsx(Button, { icon: props.open ? 'angle-down' : 'angle-up', children: props.label });
1243
- const getFacetButtonLabel = (facet) => {
1244
- const applied = new Set();
1245
- // Count values marked as filtered (already applied on the server)
1246
- (facet.values || []).forEach((value) => {
1247
- if (value?.filtered) {
1248
- if ('low' in value && 'high' in value) {
1249
- applied.add(`${value.low ?? '*'}:${value.high ?? '*'}`);
1250
- }
1251
- else {
1252
- applied.add(value.value);
1253
- }
1254
- }
1255
- });
1256
- // Count pending facet attachments (newly selected, not yet sent)
1257
- (controller.store.currentChat?.attachments.items || [])
1258
- .filter((item) => item.type === 'facet' && item.key === facet.field && (item.state === 'active' || item.state === 'attached'))
1259
- .forEach((item) => applied.add(item.value));
1260
- const base = facet.label || facet.field;
1261
- return applied.size > 0 ? `${base} (${applied.size})` : base;
1262
- };
1263
- // TODO: if starting a new chat and it's expired, this button would then disappear
1264
- if (!controller.store.chatEnabled) {
1265
- return _jsx(_Fragment, {});
1266
- }
1267
- // Reset swipe state when secondary panel opens/closes or active message changes
1268
- useEffect(() => {
1269
- updateSwipeOffset(0);
1270
- setSwipeAnimating(false);
1271
- swipeActive.current = false;
1272
- }, [shouldShowSideChat, activeMessage?.id]);
1273
- const onSwipeStart = (e) => {
1274
- swipeStartY.current = e.touches[0].clientY;
1275
- swipeStartTime.current = Date.now();
1276
- swipeActive.current = false; // only activate after dead-zone threshold
1277
- setSwipeAnimating(false);
1278
- };
1279
- const onSwipeMove = (e) => {
1280
- const diff = e.touches[0].clientY - swipeStartY.current;
1281
- // Require a minimum drag distance before activating the swipe,
1282
- // so taps on buttons (e.g. close) still fire their click events.
1283
- if (!swipeActive.current) {
1284
- if (Math.abs(diff) < 8)
1285
- return; // still within dead-zone
1286
- swipeActive.current = true;
1287
- }
1288
- if (diff > 0) {
1289
- e.preventDefault();
1290
- updateSwipeOffset(diff);
1291
- }
1292
- else {
1293
- updateSwipeOffset(0);
1294
- }
1295
- };
1296
- const onSwipeEnd = () => {
1297
- if (!swipeActive.current)
1298
- return;
1299
- swipeActive.current = false;
1300
- const offset = swipeOffsetRef.current;
1301
- const height = secondaryRef.current?.offsetHeight || 400;
1302
- const elapsed = Date.now() - swipeStartTime.current;
1303
- const velocity = offset / (elapsed || 1); // px per ms
1304
- // Dismiss if dragged past 25% threshold OR a quick flick (>0.5 px/ms with >50px travel)
1305
- const shouldDismiss = offset > height * 0.25 || (velocity > 0.5 && offset > 50);
1306
- if (shouldDismiss) {
1307
- // Animate out then dismiss
1308
- setSwipeAnimating(true);
1309
- updateSwipeOffset(height);
1310
- setTimeout(() => {
1311
- const attachments = store.currentChat?.attachments.attached || [];
1312
- const productAttachments = attachments.filter((item) => item.type === 'product' && item.requestType !== 'productSimilar' && item.requestType !== 'productComparison');
1313
- productAttachments.forEach((item) => store.currentChat?.attachments.remove(item.id));
1314
- setMobileProductInfoOpen(false);
1315
- store.currentChat?.dismissSideChat();
1316
- updateSwipeOffset(0);
1317
- setSwipeAnimating(false);
1318
- }, 300);
1319
- }
1320
- else {
1321
- // Snap back
1322
- setSwipeAnimating(true);
1323
- updateSwipeOffset(0);
1324
- setTimeout(() => setSwipeAnimating(false), 300);
1325
- }
1326
- };
1327
- const requestType = store.currentChat?.requestType;
1328
- const loadingVerbs = useMemo(() => {
1329
- switch (requestType) {
1330
- case 'productQuery':
1331
- return ['Thinking', 'Searching', 'Analyzing', 'Gathering details'];
1332
- case 'productSearch':
1333
- return ['Searching', 'Browsing catalog', 'Finding products', 'Curating results'];
1334
- case 'productComparison':
1335
- return ['Comparing', 'Analyzing', 'Evaluating', 'Weighing options'];
1336
- case 'imageSearch':
1337
- return ['Analyzing image', 'Identifying', 'Searching', 'Matching'];
1338
- case 'productSimilar':
1339
- return ['Finding similar items', 'Searching', 'Matching', 'Curating'];
1340
- case 'inspirationRequest':
1341
- return ['Brainstorming', 'Imagining', 'Curating', 'Inspiring'];
1342
- case 'general':
1343
- default:
1344
- return undefined;
1345
- }
1346
- }, [requestType]);
1347
- return (_jsx(CacheProvider, { children: _jsxs(_Fragment, { children: [_jsxs("div", { className: classnames('ss__chat', {
1348
- 'ss__chat--open': store.open,
1349
- 'ss__chat--minimized': !store.open,
1350
- 'ss__chat--mobile': isMobile,
1351
- }, 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: () => {
1352
- controller.openChat(question);
1353
- }, children: question }, index))) })), _jsx("div", { className: 'ss__chat__bubble', 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'), style: isMobile
1354
- ? {
1355
- // Touch swipe animations need to be inline to prevent visual jumps
1356
- transform: swipeOffset > 0 ? `translateY(${swipeOffset}px)` : undefined,
1357
- transition: swipeAnimating ? 'transform 0.3s ease-out' : 'none',
1358
- }
1359
- : undefined, children: [isMobile && (_jsx("div", { className: "ss__chat__secondary__drag-handle", onTouchStart: onSwipeStart, onTouchMove: onSwipeMove, onTouchEnd: onSwipeEnd, children: _jsx("div", { className: "ss__chat__secondary__drag-handle__indicator" }) })), _jsxs("div", { className: 'ss__chat__header', onTouchStart: isMobile ? onSwipeStart : undefined, onTouchMove: isMobile ? onSwipeMove : undefined, onTouchEnd: isMobile ? onSwipeEnd : undefined, children: [_jsxs("div", { className: "ss__chat__header__title", children: [_jsx("div", { className: "ss__chat__header__title__primary", children: {
1360
- inspirationResult: 'Inspiration Scenarios',
1361
- productComparison: 'Product Comparison',
1362
- productQuery: 'Product Information',
1363
- }[activeMessage.messageType] || null }), _jsx("div", { className: "ss__chat__header__title__secondary", children: {
1364
- inspirationResult: 'Choose a style direction to explore',
1365
- productComparison: `Comparing ${activeMessage?.searchResults?.length || ''} products`,
1366
- productQuery: 'Complete product details',
1367
- }[activeMessage.messageType] || null })] }), _jsx("div", { className: "ss__chat__header__buttons", children: _jsx(Button, { className: "ss__chat__header__button--close", icon: { icon: 'close2', title: 'Close Chat' }, onClick: () => {
1368
- // clear any product attachments tied to the side chat (discuss product flow)
1369
- // so the attachments bar disappears alongside the secondary panel
1370
- // but preserve productComparison attachments so the user can continue comparing
1371
- const productAttachmentsToRemove = (store.currentChat?.attachments.attached || []).filter((item) => item.type === 'product' &&
1372
- item.requestType !== 'productSimilar' &&
1373
- item.requestType !== 'productComparison');
1374
- productAttachmentsToRemove.forEach((item) => store.currentChat?.attachments.remove(item.id));
1375
- setMobileProductInfoOpen(false);
1376
- store.currentChat?.dismissSideChat();
1377
- } }) })] }), _jsx("div", { className: "ss__chat__content", children: _jsx("div", { className: 'ss__chat__messages', children: {
1378
- inspirationResult: (_jsx(ChatInspirationResultMessage, { chatItem: activeMessage, controller: controller, onViewProduct: isMobile ? () => setMobileProductInfoOpen(true) : undefined })),
1379
- productComparison: (_jsx(ChatProductComparisonMessage, { chatItem: activeMessage, controller: controller })),
1380
- productQuery: (_jsx(ChatProductQueryMessage, { chatItem: activeMessage, controller: controller, displayFields: controller.config.settings?.displayFields })),
1381
- }[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
1382
- // disabled={store.currentChat?.chat && store.currentChat.chat.length <= 1}
1383
- , {
1384
- // disabled={store.currentChat?.chat && store.currentChat.chat.length <= 1}
1385
- className: "ss__chat__header__button--new", 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", icon: { icon: 'close2', title: 'Close Chat' }, onClick: () => controller.handlers.button.click() })] })] }), (() => {
1386
- const feedbackAfterMessages = controller.config.settings?.feedbackAfterMessages;
1387
- const systemMessages = (store.currentChat?.chat || []).filter((msg) => msg.messageType !== 'user' && msg.messageType !== 'productQuery');
1388
- const currentRating = store.currentChat?.sessionFeedback?.rating;
1389
- const hasRated = !!currentRating;
1390
- const shouldShowFeedback = feedbackAfterMessages &&
1391
- systemMessages.length >= feedbackAfterMessages &&
1392
- !store.currentChat?.feedbackDismissed &&
1393
- (!hasRated || store.currentChat?.feedbackJustGiven);
1394
- 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', title: 'Thumbs Up' }) })), (!hasRated || currentRating === 'DOWN') && (_jsx("span", { onClick: () => !hasRated && controller.handleFeedback('DOWN'), children: _jsx(Icon, { icon: 'thumbs-down', title: 'Thumbs Down' }) }))] }), !hasRated && (_jsx("span", { className: "ss__chat__session-feedback__close", onClick: () => {
1395
- if (store.currentChat) {
1396
- store.currentChat.feedbackDismissed = true;
1397
- store.currentChat.save();
1398
- }
1399
- }, children: _jsx(Icon, { icon: "close-thin", size: "14px" }) }))] })) : null;
1400
- })(), _jsxs("div", { className: "ss__chat__content", children: [_jsx("div", { ref: headerRef, className: classnames('ss__chat__content__header', {
1401
- 'ss__chat__content__header--overlay': messagesOverflow,
1402
- }), 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) => {
1403
- const comparisonItem = store.currentChat?.comparisons.compared[index];
1404
- return (_jsx("div", { className: classnames('ss__chat__content__header__comparisons__content__comparison', {
1405
- 'ss__chat__content__header__comparisons__content__comparison--placeholder': !comparisonItem,
1406
- }), children: comparisonItem ? (_jsxs(_Fragment, { children: [_jsx(Image
1407
- // onClick={() => {
1408
- // controller?.viewProduct(product as any);
1409
- // }}
1410
- , {
1411
- // onClick={() => {
1412
- // controller?.viewProduct(product as any);
1413
- // }}
1414
- alt: (comparisonItem?.result?.display || comparisonItem?.result)?.mappings?.core?.name || '', src: (comparisonItem?.result?.display || comparisonItem?.result)?.mappings?.core?.imageUrl || '' }), _jsx("div", { className: "ss__chat__content__header__comparisons__content__comparison__remove", onClick: () => {
1415
- store.currentChat?.comparisons.remove(comparisonItem.result.id);
1416
- }, 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));
1417
- }) }), _jsx("div", { className: classnames('ss__chat__content__header__comparisons__action', {
1418
- 'ss__chat__content__header__comparisons__action--hidden': (store.currentChat?.comparisons.compared.length || 0) < 2,
1419
- }), children: _jsx(Button, { onClick: () => controller.search(), icon: { icon: 'compare', title: 'Compare' }, children: "Compare" }) })] })] })) }), _jsxs("div", { className: 'ss__chat__messages', ref: messagesContainerRef, 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(SuggestedQuestions, { questions: store.suggestedQuestions, controller: controller })] })), store.currentChat?.chat
1420
- .filter((chatItem) => chatItem.messageType !== 'productQuery')
1421
- .map((chatItem, index) => (_jsx("div", { className: `ss__chat__message ss__chat__message--${chatItem.messageType}`, children: {
1422
- user: (_jsx(MessageUser, { chatItem: chatItem, controller: controller, onViewProduct: isMobile ? () => setMobileProductInfoOpen(true) : undefined })),
1423
- text: (_jsx(MessageText, { chatItem: chatItem, controller: controller, scrollToBottom: scrollToBottomIfNear, onViewProduct: isMobile ? () => setMobileProductInfoOpen(true) : undefined, sideChatOpen: !!shouldShowSideChat })),
1424
- content: (_jsx(MessageText, { chatItem: chatItem, controller: controller, scrollToBottom: scrollToBottomIfNear, onViewProduct: isMobile ? () => setMobileProductInfoOpen(true) : undefined, sideChatOpen: !!shouldShowSideChat })),
1425
- productSearchResult: (_jsx(MessageText, { chatItem: chatItem, controller: controller, scrollToBottom: scrollToBottomIfNear, onViewProduct: isMobile ? () => setMobileProductInfoOpen(true) : undefined, sideChatOpen: !!shouldShowSideChat })),
1426
- inspirationResult: (_jsx(MessageText, { chatItem: chatItem, controller: controller, scrollToBottom: scrollToBottomIfNear, onViewProduct: isMobile ? () => setMobileProductInfoOpen(true) : undefined, sideChatOpen: !!shouldShowSideChat })),
1427
- productAnswer: (_jsx(MessageText, { chatItem: chatItem, controller: controller, scrollToBottom: scrollToBottomIfNear, onViewProduct: isMobile ? () => setMobileProductInfoOpen(true) : undefined, sideChatOpen: !!shouldShowSideChat })),
1428
- productComparison: (() => {
1429
- // On mobile, only the first productComparison in the session
1430
- // auto-opens the secondary panel. Subsequent ones get a
1431
- // prominent "Show Details" button instead.
1432
- const comparisonMessages = (store.currentChat?.chat || []).filter((m) => m.messageType === 'productComparison');
1433
- const isFirst = comparisonMessages.length > 0 && comparisonMessages[0].id === chatItem.id;
1434
- return (_jsx(MessageText, { chatItem: chatItem, controller: controller, scrollToBottom: scrollToBottomIfNear, onViewProduct: isMobile ? () => setMobileProductInfoOpen(true) : undefined, showDetailsButton: isMobile && !isFirst, sideChatOpen: !!shouldShowSideChat }));
1435
- })(),
1436
- productRecommendation: (_jsx(MessageText, { chatItem: chatItem, controller: controller, scrollToBottom: scrollToBottomIfNear, onViewProduct: isMobile ? () => setMobileProductInfoOpen(true) : undefined, sideChatOpen: !!shouldShowSideChat })),
1437
- actions: _jsx(SuggestedQuestions, { actions: chatItem.actions, controller: controller }),
1438
- errorResponse: (_jsx(MessageText, { chatItem: chatItem, controller: controller, scrollToBottom: scrollToBottomIfNear, sideChatOpen: !!shouldShowSideChat })),
1439
- topicDrift: (_jsx(MessageText, { chatItem: chatItem, controller: controller, scrollToBottom: scrollToBottomIfNear, sideChatOpen: !!shouldShowSideChat })),
1440
- productQuery: null,
1441
- }[chatItem.messageType] || null }, index))), _jsx("div", { className: "ss__chat__messages__end", ref: messagesEndRef }), showNewMessages && messagesOverflow && (_jsxs("div", { className: "ss__chat__new-messages", onClick: () => {
1442
- scrollToBottom();
1443
- setShowNewMessages(false);
1444
- }, children: [_jsx(Icon, { icon: "angle-down", size: "12px" }), _jsx("span", { children: "New messages" })] }))] }), _jsx(ChatLoadingIndicator, { loading: store.loading, verbs: loadingVerbs }), !store.currentChat?.isExpired ? (_jsxs("div", { className: "ss__chat__content__footer", ref: footerRef, 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: () => {
1445
- controller.store.createChat();
1446
- }, children: "New Session" })] })), store.currentChat?.actions && store.currentChat.actions.length > 0 && (_jsx("div", { className: 'ss__chat__actions', children: store.currentChat?.actions.map((action, index) => (_jsx("div", { className: "ss__chat__actions__wrap", children: {
1447
- facets: action.data.length ? (_jsxs(_Fragment, { children: [_jsxs("div", { className: "ss__chat__actions__facets-header", children: [_jsx("div", { className: "ss__chat__actions--title", children: "Filter by:" }), multiselectFacets && (_jsx("div", { className: `ss__chat__actions__facets-apply${store.currentChat?.attachments.attached.some((item) => item.type === 'facet') ||
1448
- (store.currentChat?.removedFacets && store.currentChat.removedFacets.length > 0)
1449
- ? ' ss__chat__actions__facets-apply--active'
1450
- : ''}`, children: _jsx(Button, { onClick: () => {
1451
- controller.search();
1452
- }, children: "Apply" }) }))] }), _jsx("div", { className: "ss__chat__actions--facets", children: action.data.slice(0, 10).map((facet, idx) => {
1453
- if (!facet.values?.length)
1454
- return null;
1455
- 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: {
1456
- '.ss__dropdown__content': {
1457
- width: '150px',
1458
- maxHeight: '200px',
1459
- overflowY: 'auto',
1460
- background: 'white',
1461
- boxShadow: '0px 3px 6px 0px rgba(0, 0, 0, 0.2)',
1462
- borderRadius: '6px',
1463
- ...(multiselectFacets
1464
- ? {
1465
- '.ss__chat__actions__facet__option--checkbox': {
1466
- display: 'flex',
1467
- alignItems: 'center',
1468
- gap: '8px',
1469
- padding: '6px 10px',
1470
- cursor: 'pointer',
1471
- width: '100%',
1472
- boxSizing: 'border-box',
1473
- background: '#fff',
1474
- border: 'none',
1475
- borderBottom: '1px solid #f0f0f0',
1476
- '&:hover': {
1477
- background: '#f4f4ff',
1478
- },
1479
- '&:last-child': {
1480
- borderBottom: 'none',
1481
- },
1482
- '.ss__chat__actions__facet__option__checkbox': {
1483
- width: '16px',
1484
- height: '16px',
1485
- borderRadius: '3px',
1486
- border: '2px solid #ccc',
1487
- display: 'flex',
1488
- alignItems: 'center',
1489
- justifyContent: 'center',
1490
- flexShrink: 0,
1491
- '&.ss__chat__actions__facet__option__checkbox--checked': {
1492
- background: '#253B80',
1493
- borderColor: '#253B80',
1494
- },
1495
- },
1496
- '.ss__chat__actions__facet__option__label': {
1497
- fontSize: '14px',
1498
- color: '#333',
1499
- flex: '1 1 auto',
1500
- textAlign: 'left',
1501
- },
1502
- },
1503
- }
1504
- : {
1505
- '.ss__button': {
1506
- width: '100%',
1507
- border: 'none',
1508
- borderRadius: 0,
1509
- boxSizing: 'border-box',
1510
- background: '#fff',
1511
- '&:hover': {
1512
- background: '#f4f4ff',
1513
- },
1514
- },
1515
- }),
1516
- },
1517
- }, children: _jsx("div", { className: "ss__chat__actions__facet__options", children: facet.type === 'range-buckets'
1518
- ? facet.values.map((option) => {
1519
- const rangeOption = option;
1520
- const optionValue = `${rangeOption.low ?? '*'}:${rangeOption.high ?? '*'}`;
1521
- if (multiselectFacets) {
1522
- const isSelected = (rangeOption.filtered && !controller.store.isFacetRemoved(facet.field, optionValue)) ||
1523
- controller.store.isFacetSelected(facet.field, optionValue);
1524
- return (_jsxs("div", { className: "ss__chat__actions__facet__option--checkbox", onClick: () => {
1525
- if (isSelected) {
1526
- controller.store.removeFacet(facet.field, optionValue);
1527
- }
1528
- else {
1529
- controller.store.addFacet({
1530
- key: facet.field,
1531
- facetLabel: facet.label,
1532
- value: optionValue,
1533
- label: rangeOption.label,
1534
- count: rangeOption.count,
1535
- });
1536
- }
1537
- }, children: [_jsx("div", { className: classnames('ss__chat__actions__facet__option__checkbox', {
1538
- 'ss__chat__actions__facet__option__checkbox--checked': isSelected,
1539
- }), children: isSelected && _jsx(Icon, { icon: "check-thin", size: "10px" }) }), _jsx("span", { className: "ss__chat__actions__facet__option__label", children: rangeOption.label })] }, optionValue));
1540
- }
1541
- return (_jsx(Button, { onClick: () => {
1542
- controller.store.addFacet({
1543
- key: facet.field,
1544
- facetLabel: facet.label,
1545
- value: optionValue,
1546
- label: rangeOption.label,
1547
- count: rangeOption.count,
1548
- });
1549
- controller.search();
1550
- }, children: rangeOption.label }, optionValue));
1551
- })
1552
- : facet.values.map((option) => {
1553
- const valueOption = option;
1554
- const optionValue = valueOption.value || valueOption.label;
1555
- if (multiselectFacets) {
1556
- const isSelected = (valueOption.filtered && !controller.store.isFacetRemoved(facet.field, optionValue)) ||
1557
- controller.store.isFacetSelected(facet.field, optionValue);
1558
- return (_jsxs("div", { className: "ss__chat__actions__facet__option--checkbox", onClick: () => {
1559
- if (isSelected) {
1560
- controller.store.removeFacet(facet.field, optionValue);
1561
- }
1562
- else {
1563
- controller.store.addFacet({
1564
- key: facet.field,
1565
- facetLabel: facet.label,
1566
- value: optionValue,
1567
- label: valueOption.label,
1568
- count: valueOption.count,
1569
- });
1570
- }
1571
- }, children: [_jsx("div", { className: classnames('ss__chat__actions__facet__option__checkbox', {
1572
- 'ss__chat__actions__facet__option__checkbox--checked': isSelected,
1573
- }), children: isSelected && _jsx(Icon, { icon: "check-thin", size: "10px" }) }), _jsx("span", { className: "ss__chat__actions__facet__option__label", children: valueOption.label })] }, optionValue));
1574
- }
1575
- return (_jsx(Button, { onClick: () => {
1576
- controller.store.addFacet({
1577
- key: facet.field,
1578
- facetLabel: facet.label,
1579
- value: optionValue,
1580
- label: valueOption.label,
1581
- count: valueOption.count,
1582
- });
1583
- controller.search();
1584
- }, children: valueOption.label }, optionValue));
1585
- }) }) }, facet.field) }, idx));
1586
- }) })] })) : null,
1587
- actions: (_jsx("div", { className: "ss__chat__actions--suggested" })),
1588
- }[action.type] || null }, index))) })), (() => {
1589
- const activeComparisonSearchResults = shouldShowSideChat && activeMessage?.messageType === 'productComparison'
1590
- ? activeMessage.searchResults || []
1591
- : null;
1592
- const showCommittedComparisons = !activeComparisonSearchResults &&
1593
- store.currentChat?.comparisons.committed &&
1594
- store.currentChat.comparisons.committed.length > 0 &&
1595
- (activeMessage?.messageType === 'user' ||
1596
- activeMessage?.messageType === 'productComparison' ||
1597
- activeMessage?.messageType === 'productQuery');
1598
- const visibleAttachments = store.currentChat?.attachments.attached.filter((item) => item.state === 'attached' || item.state === 'active' || item.state === 'loading' || item.state === 'error') || [];
1599
- const productAttachments = visibleAttachments.filter((item) => item.type === 'product' &&
1600
- item.requestType !== 'productSimilar' &&
1601
- item.requestType !== 'productComparison');
1602
- const imageAttachments = visibleAttachments.filter((item) => item.type === 'image');
1603
- const comparisonItems = activeComparisonSearchResults
1604
- ? activeComparisonSearchResults.map((result) => {
1605
- const d = result?.display || result;
1606
- return {
1607
- id: result?.id,
1608
- name: d?.mappings?.core?.name || '',
1609
- imageUrl: d?.mappings?.core?.thumbnailImageUrl || d?.mappings?.core?.imageUrl || '',
1610
- onClick: isMobile
1611
- ? () => {
1612
- controller.viewProduct(result);
1613
- setMobileProductInfoOpen(true);
1614
- }
1615
- : undefined,
1616
- };
1617
- })
1618
- : showCommittedComparisons
1619
- ? (store.currentChat?.comparisons.committed || []).map((comparisonItem) => {
1620
- const d = comparisonItem?.result?.display || comparisonItem?.result;
1621
- return {
1622
- id: comparisonItem.result?.id,
1623
- name: d?.mappings?.core?.name || '',
1624
- imageUrl: d?.mappings?.core?.thumbnailImageUrl || d?.mappings?.core?.imageUrl || '',
1625
- onClick: isMobile
1626
- ? () => {
1627
- controller.viewProduct(comparisonItem.result);
1628
- setMobileProductInfoOpen(true);
1629
- }
1630
- : undefined,
1631
- };
1632
- })
1633
- : [];
1634
- const productItems = productAttachments.map((item) => ({
1635
- id: item.id,
1636
- name: item.name || '',
1637
- imageUrl: item.thumbnailUrl || '',
1638
- onClick: isMobile
1639
- ? () => {
1640
- setMobileProductInfoOpen(true);
1641
- }
1642
- : () => {
1643
- store.currentChat?.setActiveMessage(store.currentChat?.activeMessage?.id || '');
1644
- },
1645
- onRemove: () => {
1646
- store.currentChat?.attachments.remove(item.id);
1647
- setMobileProductInfoOpen(false);
1648
- store.currentChat?.dismissSideChat();
1649
- },
1650
- }));
1651
- const imageItems = imageAttachments.map((item) => ({
1652
- id: item.id,
1653
- name: item.fileName || 'Image',
1654
- imageUrl: item.base64 || item.thumbnailUrl || '',
1655
- isLoading: item.state === 'loading',
1656
- hasError: !!item.error,
1657
- errorMessage: item.error?.message,
1658
- onRemove: () => store.currentChat?.attachments.remove(item.id),
1659
- }));
1660
- const productTitle = productItems.length > 1 ? 'Compare these products' : 'Ask about this product' + (isMobile ? '' : ' (click for details)');
1661
- const hasImageError = imageItems.some((item) => item.hasError);
1662
- const imageTitle = imageItems.length > 0 && !hasImageError ? 'Find products similar to this image:' : '';
1663
- return (_jsxs(_Fragment, { children: [comparisonItems.length > 0 && (_jsx(ChatAttachmentContext, { title: 'Compare these products', items: comparisonItems, onClose: () => {
1664
- store.currentChat?.comparisons.resetCommitted();
1665
- store.currentChat?.dismissSideChat();
1666
- } })), productItems.length > 0 && (_jsx(ChatAttachmentContext, { title: productTitle, items: productItems, onClose: () => {
1667
- productAttachments.forEach((item) => store.currentChat?.attachments.remove(item.id));
1668
- setMobileProductInfoOpen(false);
1669
- store.currentChat?.dismissSideChat();
1670
- } })), imageItems.length > 0 && _jsx(ChatAttachmentContext, { title: imageTitle, items: imageItems })] }));
1671
- })(), (() => {
1672
- const drift = store.currentChat?.topicDrift;
1673
- if (!drift)
1674
- return null;
1675
- // recommendedAction is the prescription; driftType is the diagnosis.
1676
- // Hide the banner when the backend says to keep flowing, or when no drift was detected.
1677
- if (drift.recommendedAction === 'CONTINUE' || drift.driftType === 'NO_DRIFT')
1678
- return null;
1679
- const isScopeRedirect = drift.recommendedAction === 'SCOPE_REDIRECT';
1680
- const primaryText = isScopeRedirect ? "I'm here to help with shopping" : 'Looking for something new?';
1681
- const secondaryText = isScopeRedirect
1682
- ? 'Try asking about products, comparisons, or recommendations'
1683
- : 'Start a fresh session for better assistance, or keep going in this one?';
1684
- const buttonText = isScopeRedirect ? '' : 'New Session';
1685
- 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: () => {
1686
- if (isScopeRedirect) {
1687
- store.currentChat?.dismissTopicDrift();
1688
- return;
1689
- }
1690
- const messageText = store.currentChat?.handleTopicDrift();
1691
- if (messageText) {
1692
- controller.store.createChat();
1693
- controller.search({ data: { message: messageText } });
1694
- }
1695
- }, children: buttonText })), _jsx("span", { onClick: () => {
1696
- store.currentChat?.dismissTopicDrift();
1697
- }, children: _jsx(Icon, { icon: "close-thin", size: "14px", className: 'ss__chat__topic-drift__icon--close' }) })] }));
1698
- })(), _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: (() => {
1699
- const comparedCount = store.currentChat?.comparisons.compared.length || 0;
1700
- const committedCount = store.currentChat?.comparisons.committed.length || 0;
1701
- const attached = store.currentChat?.attachments.attached.filter((item) => item.state === 'attached' || item.state === 'active') || [];
1702
- const attachedProducts = attached.filter((item) => item.type === 'product');
1703
- const attachedImages = attached.filter((item) => item.type === 'image' && !item.error);
1704
- if (attachedProducts.length === 1) {
1705
- return 'Ask about this product...';
1706
- }
1707
- if (comparedCount > 1 || attachedProducts.length > 1) {
1708
- return 'What would you like to compare?';
1709
- }
1710
- if (committedCount > 0) {
1711
- return 'Ask about the compared products...';
1712
- }
1713
- if (attachedImages.length > 0) {
1714
- return 'Ask about this image...';
1715
- }
1716
- if (comparedCount === 1) {
1717
- return 'Add another product to compare...';
1718
- }
1719
- return 'Type your message...';
1720
- })(), onInput: (e) => controller.handlers.input.input(e), onKeyDown: (e) => {
1721
- controller.handlers.input.enterKey(e);
1722
- if (e.keyCode === 13 && isMobile && mobileProductInfoOpen) {
1723
- setMobileProductInfoOpen(false);
1724
- }
1725
- }, 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) => {
1726
- await controller.upload(e.target.files);
1727
- // reset value
1728
- e.target.value = '';
1729
- }, multiple: true, type: "file", accept: "image/*", className: "ss__chat__input__input__file" })] }))] }), _jsx("div", { className: 'ss__chat__input__actions', children: (() => {
1730
- const hasImageAttachment = (store.currentChat?.attachments.attached || []).some((item) => item.type === 'image' && !item.error);
1731
- const messageEmpty = !controller.store.inputValue.trim();
1732
- const sendDisabled = store.blocked || store.currentChat?.sessionLimitReached || (hasImageAttachment && messageEmpty) || messageEmpty;
1733
- return (_jsx(Button, { className: "ss__chat__send-button", icon: { icon: 'send', title: 'Send Message' }, disabled: sendDisabled, onClick: () => {
1734
- if (sendDisabled)
1735
- return;
1736
- controller.search();
1737
- if (isMobile && mobileProductInfoOpen) {
1738
- setMobileProductInfoOpen(false);
1739
- }
1740
- } }));
1741
- })() })] }), _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" })] }) })] })) : (_jsx("div", { children: "This chat is expired. Please start a new chat." }))] })] })) : null] }), _jsx(Overlay, { style: { zIndex: 1001 }, color: "transparent", active: store.open, onClick: () => controller.handlers.button.click() })] }) }));
1742
- });