@microsoft/omnichannel-chat-widget 1.8.3-main.ec1328d → 1.8.4-main.4478bbf

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 (185) hide show
  1. package/lib/cjs/common/Constants.js +7 -0
  2. package/lib/cjs/common/facades/FacadeChatSDK.js +6 -0
  3. package/lib/cjs/common/telemetry/AppInsightsEvents.js +4 -5
  4. package/lib/cjs/common/telemetry/TelemetryConstants.js +46 -2
  5. package/lib/cjs/common/telemetry/loggers/appInsightsLogger.js +26 -10
  6. package/lib/cjs/common/utils/SecureEventBus.js +307 -0
  7. package/lib/cjs/common/utils/dispatchCustomEvent.js +25 -0
  8. package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +16 -4
  9. package/lib/cjs/components/citationpanestateful/CitationDim.js +29 -0
  10. package/lib/cjs/components/citationpanestateful/CitationPaneStateful.js +199 -0
  11. package/lib/cjs/components/citationpanestateful/common/defaultProps/defaultCitationPaneProps.js +70 -0
  12. package/lib/cjs/components/confirmationpanestateful/interfaces/IConfirmationPaneLocalizedTexts.js +1 -0
  13. package/lib/cjs/components/headerstateful/HeaderStateful.js +8 -2
  14. package/lib/cjs/components/livechatwidget/LiveChatWidget.js +4 -4
  15. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/AddActivitySubscriber.js +127 -0
  16. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +4 -5
  17. package/lib/cjs/components/livechatwidget/common/ChatWidgetEvents.js +15 -0
  18. package/lib/cjs/components/livechatwidget/common/PersistentConversationHandler.js +284 -0
  19. package/lib/cjs/components/livechatwidget/common/createAdapter.js +2 -0
  20. package/lib/cjs/components/livechatwidget/common/defaultProps/defaultPersistentChatHistoryProps.js +18 -0
  21. package/lib/cjs/components/livechatwidget/common/endChat.js +28 -3
  22. package/lib/cjs/components/livechatwidget/common/getMockChatSDKIfApplicable.js +4 -3
  23. package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +8 -6
  24. package/lib/cjs/components/livechatwidget/common/overridePropsOnMockIfApplicable.js +2 -1
  25. package/lib/cjs/components/livechatwidget/common/renderSurveyHelpers.js +2 -2
  26. package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +3 -3
  27. package/lib/cjs/components/livechatwidget/common/startChat.js +10 -5
  28. package/lib/cjs/components/livechatwidget/common/startChatErrorHandler.js +24 -4
  29. package/lib/cjs/components/livechatwidget/interfaces/IMockProps.js +8 -2
  30. package/lib/cjs/components/livechatwidget/interfaces/IPersistentChatHistoryProps.js +1 -0
  31. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +41 -8
  32. package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +29 -2
  33. package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +12 -3
  34. package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +122 -11
  35. package/lib/cjs/components/webchatcontainerstateful/common/DesignerChatAdapter.js +43 -14
  36. package/lib/cjs/components/webchatcontainerstateful/common/DesignerChatSDK.js +6 -1
  37. package/lib/cjs/components/webchatcontainerstateful/common/activities/botActivity.js +14 -0
  38. package/lib/cjs/components/webchatcontainerstateful/common/activities/conversationDividerActivity.js +17 -0
  39. package/lib/cjs/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.js +97 -0
  40. package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +2 -1
  41. package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultWebChatStatefulProps.js +1 -1
  42. package/lib/cjs/components/webchatcontainerstateful/common/defaultStyles/defaultWebChatStyles.js +1 -1
  43. package/lib/cjs/components/webchatcontainerstateful/common/utils/chatAdapterUtils.js +36 -2
  44. package/lib/cjs/components/webchatcontainerstateful/common/utils/fontUtils.js +28 -0
  45. package/lib/cjs/components/webchatcontainerstateful/hooks/usePersistentChatHistory.js +59 -0
  46. package/lib/cjs/components/webchatcontainerstateful/interfaces/ICitation.js +1 -0
  47. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js +122 -0
  48. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/Constants.js +10 -0
  49. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/ConversationDividerActivity.js +18 -0
  50. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.js +1038 -0
  51. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LoadInlineBannerActivity.js +34 -0
  52. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +44 -0
  53. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +16 -2
  54. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultAvatarTextStyles.js +1 -1
  55. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultInLineBannerStyle.js +20 -0
  56. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageStyles.js +1 -1
  57. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +2 -2
  58. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/HistoryMessageTimestamp.js +59 -0
  59. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +5 -3
  60. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +2 -2
  61. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.js +97 -30
  62. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware.js +2 -2
  63. package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +46 -45
  64. package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +2 -0
  65. package/lib/cjs/contexts/createReducer.js +15 -0
  66. package/lib/cjs/firstresponselatency/FirstMessageTrackerFromBot.js +3 -2
  67. package/lib/cjs/firstresponselatency/FirstResponseLatencyTracker.js +6 -2
  68. package/lib/cjs/index.js +9 -1
  69. package/lib/cjs/plugins/newMessageEventHandler.js +4 -1
  70. package/lib/esm/common/Constants.js +7 -0
  71. package/lib/esm/common/facades/FacadeChatSDK.js +6 -0
  72. package/lib/esm/common/telemetry/AppInsightsEvents.js +4 -5
  73. package/lib/esm/common/telemetry/TelemetryConstants.js +44 -1
  74. package/lib/esm/common/telemetry/loggers/appInsightsLogger.js +27 -11
  75. package/lib/esm/common/utils/SecureEventBus.js +328 -0
  76. package/lib/esm/common/utils/dispatchCustomEvent.js +18 -0
  77. package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +17 -5
  78. package/lib/esm/components/citationpanestateful/CitationDim.js +20 -0
  79. package/lib/esm/components/citationpanestateful/CitationPaneStateful.js +188 -0
  80. package/lib/esm/components/citationpanestateful/common/defaultProps/defaultCitationPaneProps.js +61 -0
  81. package/lib/esm/components/confirmationpanestateful/interfaces/IConfirmationPaneLocalizedTexts.js +1 -0
  82. package/lib/esm/components/headerstateful/HeaderStateful.js +9 -3
  83. package/lib/esm/components/livechatwidget/LiveChatWidget.js +4 -4
  84. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/AddActivitySubscriber.js +120 -0
  85. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +4 -5
  86. package/lib/esm/components/livechatwidget/common/ChatWidgetEvents.js +8 -0
  87. package/lib/esm/components/livechatwidget/common/PersistentConversationHandler.js +277 -0
  88. package/lib/esm/components/livechatwidget/common/createAdapter.js +2 -0
  89. package/lib/esm/components/livechatwidget/common/defaultProps/defaultPersistentChatHistoryProps.js +11 -0
  90. package/lib/esm/components/livechatwidget/common/endChat.js +29 -4
  91. package/lib/esm/components/livechatwidget/common/getMockChatSDKIfApplicable.js +4 -3
  92. package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +8 -6
  93. package/lib/esm/components/livechatwidget/common/overridePropsOnMockIfApplicable.js +2 -1
  94. package/lib/esm/components/livechatwidget/common/renderSurveyHelpers.js +2 -2
  95. package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +3 -3
  96. package/lib/esm/components/livechatwidget/common/startChat.js +12 -7
  97. package/lib/esm/components/livechatwidget/common/startChatErrorHandler.js +23 -4
  98. package/lib/esm/components/livechatwidget/interfaces/IMockProps.js +3 -3
  99. package/lib/esm/components/livechatwidget/interfaces/IPersistentChatHistoryProps.js +1 -0
  100. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +42 -9
  101. package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +31 -4
  102. package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +13 -4
  103. package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +125 -12
  104. package/lib/esm/components/webchatcontainerstateful/common/DesignerChatAdapter.js +43 -14
  105. package/lib/esm/components/webchatcontainerstateful/common/DesignerChatSDK.js +6 -1
  106. package/lib/esm/components/webchatcontainerstateful/common/activities/botActivity.js +7 -0
  107. package/lib/esm/components/webchatcontainerstateful/common/activities/conversationDividerActivity.js +9 -0
  108. package/lib/esm/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.js +90 -0
  109. package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +2 -1
  110. package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultWebChatStatefulProps.js +2 -2
  111. package/lib/esm/components/webchatcontainerstateful/common/defaultStyles/defaultWebChatStyles.js +1 -1
  112. package/lib/esm/components/webchatcontainerstateful/common/utils/chatAdapterUtils.js +32 -0
  113. package/lib/esm/components/webchatcontainerstateful/common/utils/fontUtils.js +21 -0
  114. package/lib/esm/components/webchatcontainerstateful/hooks/usePersistentChatHistory.js +51 -0
  115. package/lib/esm/components/webchatcontainerstateful/interfaces/ICitation.js +1 -0
  116. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js +115 -0
  117. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/Constants.js +3 -0
  118. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/ConversationDividerActivity.js +10 -0
  119. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.js +1060 -0
  120. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LoadInlineBannerActivity.js +25 -0
  121. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +42 -0
  122. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +13 -0
  123. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultAvatarTextStyles.js +1 -1
  124. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultInLineBannerStyle.js +13 -0
  125. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageStyles.js +1 -1
  126. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +1 -1
  127. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/HistoryMessageTimestamp.js +52 -0
  128. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +3 -2
  129. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +1 -1
  130. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.js +98 -30
  131. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware.js +2 -2
  132. package/lib/esm/contexts/common/LiveChatWidgetActionType.js +46 -45
  133. package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +2 -0
  134. package/lib/esm/contexts/createReducer.js +15 -0
  135. package/lib/esm/firstresponselatency/FirstMessageTrackerFromBot.js +3 -2
  136. package/lib/esm/firstresponselatency/FirstResponseLatencyTracker.js +6 -2
  137. package/lib/esm/index.js +1 -0
  138. package/lib/esm/plugins/newMessageEventHandler.js +4 -1
  139. package/lib/types/common/Constants.d.ts +6 -0
  140. package/lib/types/common/facades/FacadeChatSDK.d.ts +3 -1
  141. package/lib/types/common/telemetry/TelemetryConstants.d.ts +41 -2
  142. package/lib/types/common/utils/SecureEventBus.d.ts +159 -0
  143. package/lib/types/common/utils/dispatchCustomEvent.d.ts +2 -0
  144. package/lib/types/components/citationpanestateful/CitationDim.d.ts +5 -0
  145. package/lib/types/components/citationpanestateful/CitationPaneStateful.d.ts +4 -0
  146. package/lib/types/components/citationpanestateful/common/defaultProps/defaultCitationPaneProps.d.ts +11 -0
  147. package/lib/types/components/citationpanestateful/interfaces/ICitationPaneStatefulProps.d.ts +19 -0
  148. package/lib/types/components/confirmationpanestateful/common/defaultProps/defaultConfirmationPaneLocalizedTexts.d.ts +1 -1
  149. package/lib/types/components/confirmationpanestateful/interfaces/IConfirmationPaneStatefulProps.d.ts +1 -1
  150. package/lib/types/components/livechatwidget/common/ActivitySubscriber/AddActivitySubscriber.d.ts +45 -0
  151. package/lib/types/components/livechatwidget/common/ChatWidgetEvents.d.ts +7 -0
  152. package/lib/types/components/livechatwidget/common/PersistentConversationHandler.d.ts +28 -0
  153. package/lib/types/components/livechatwidget/common/defaultProps/defaultPersistentChatHistoryProps.d.ts +2 -0
  154. package/lib/types/components/livechatwidget/common/getMockChatSDKIfApplicable.d.ts +2 -1
  155. package/lib/types/components/livechatwidget/common/startChatErrorHandler.d.ts +1 -0
  156. package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +5 -1
  157. package/lib/types/components/livechatwidget/interfaces/IMockProps.d.ts +5 -3
  158. package/lib/types/components/livechatwidget/interfaces/IPersistentChatHistoryProps.d.ts +7 -0
  159. package/lib/types/components/webchatcontainerstateful/common/DesignerChatAdapter.d.ts +4 -2
  160. package/lib/types/components/webchatcontainerstateful/common/DesignerChatSDK.d.ts +5 -0
  161. package/lib/types/components/webchatcontainerstateful/common/activities/botActivity.d.ts +7 -0
  162. package/lib/types/components/webchatcontainerstateful/common/activities/conversationDividerActivity.d.ts +10 -0
  163. package/lib/types/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.d.ts +2 -0
  164. package/lib/types/components/webchatcontainerstateful/common/utils/chatAdapterUtils.d.ts +6 -1
  165. package/lib/types/components/webchatcontainerstateful/common/utils/fontUtils.d.ts +10 -0
  166. package/lib/types/components/webchatcontainerstateful/hooks/usePersistentChatHistory.d.ts +4 -0
  167. package/lib/types/components/webchatcontainerstateful/interfaces/ICitation.d.ts +12 -0
  168. package/lib/types/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.d.ts +7 -0
  169. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/Constants.d.ts +3 -0
  170. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/ConversationDividerActivity.d.ts +4 -0
  171. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.d.ts +326 -0
  172. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LoadInlineBannerActivity.d.ts +8 -0
  173. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.d.ts +1 -0
  174. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultInLineBannerStyle.d.ts +2 -0
  175. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/HistoryMessageTimestamp.d.ts +2 -0
  176. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.d.ts +3 -4
  177. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware.d.ts +2 -2
  178. package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +1 -0
  179. package/lib/types/contexts/common/ILiveChatWidgetLocalizedTexts.d.ts +1 -0
  180. package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +46 -45
  181. package/lib/types/index.d.ts +1 -0
  182. package/package.json +3 -3
  183. /package/lib/cjs/components/{confirmationpanestateful/interfaces/IConfirmationPaneLocalizedText.js → citationpanestateful/interfaces/ICitationPaneStatefulProps.js} +0 -0
  184. /package/lib/esm/components/{confirmationpanestateful/interfaces/IConfirmationPaneLocalizedText.js → citationpanestateful/interfaces/ICitationPaneStatefulProps.js} +0 -0
  185. /package/lib/types/components/confirmationpanestateful/interfaces/{IConfirmationPaneLocalizedText.d.ts → IConfirmationPaneLocalizedTexts.d.ts} +0 -0
@@ -0,0 +1,25 @@
1
+ import React, { useMemo } from "react";
2
+ import { defaultInlineBannerStyle } from "../defaultStyles/defaultInLineBannerStyle";
3
+ import { defaultMiddlewareLocalizedTexts } from "../../../../common/defaultProps/defaultMiddlewareLocalizedTexts";
4
+ import { mergeStyles } from "@fluentui/merge-styles";
5
+ const LoadInlineBannerActivity = _ref => {
6
+ let {
7
+ webChatContainerProps,
8
+ persistentChatHistory,
9
+ id
10
+ } = _ref;
11
+ const localizedTexts = useMemo(() => ({
12
+ ...defaultMiddlewareLocalizedTexts,
13
+ ...(webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : webChatContainerProps.localizedTexts)
14
+ }), [webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : webChatContainerProps.localizedTexts]);
15
+ const bannerStyle = mergeStyles(persistentChatHistory === null || persistentChatHistory === void 0 ? void 0 : persistentChatHistory.bannerStyle, defaultInlineBannerStyle);
16
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
17
+ id: id,
18
+ className: bannerStyle,
19
+ role: "status",
20
+ "aria-live": "polite",
21
+ "aria-label": localizedTexts.PREVIOUS_MESSAGES_LOADING,
22
+ "aria-busy": "true"
23
+ }, localizedTexts.PREVIOUS_MESSAGES_LOADING));
24
+ };
25
+ export default LoadInlineBannerActivity;
@@ -1,3 +1,5 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ /* eslint-disable react/display-name */
1
3
  /******
2
4
  * ActivityMiddleware
3
5
  *
@@ -7,8 +9,10 @@
7
9
  * 3. Decodes certain html characters that came through from chat services
8
10
  ******/
9
11
 
12
+ import LazyLoadActivity, { LazyLoadHandler } from "./activities/LazyLoadActivity";
10
13
  import { LogLevel, TelemetryEvent } from "../../../../../common/telemetry/TelemetryConstants";
11
14
  import { Constants } from "../../../../../common/Constants";
15
+ import ConversationDividerActivity from "./activities/ConversationDividerActivity";
12
16
  import { DirectLineActivityType } from "../../enums/DirectLineActivityType";
13
17
  import { DirectLineSenderRole } from "../../enums/DirectLineSenderRole";
14
18
  import React from "react";
@@ -17,6 +21,7 @@ import { defaultSystemMessageStyles } from "./defaultStyles/defaultSystemMessage
17
21
  import { defaultUserMessageStyles } from "./defaultStyles/defaultUserMessageStyles";
18
22
  import { escapeHtml } from "../../../../../common/utils";
19
23
  const loggedSystemMessages = new Array();
24
+ let lastRenderedAt = 0; // Track last rendered receivedAt timestamp for deduplication
20
25
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
21
26
  const handleSystemMessage = (next, args, card, renderMarkdown, systemMessageStyleProps) => {
22
27
  var _card$activity, _card$activity$channe, _card$activity$channe2, _card$activity2, _card$activity2$chann, _card$activity3, _card$activity3$chann, _card$activity3$chann2, _card$activity4, _card$activity4$chann, _card$activity5, _card$activity5$chann, _card$nextVisibleActi, _card$nextVisibleActi2, _card$activity6, _card$activity6$chann, _card$activity7, _card$nextVisibleActi3, _card$activity8;
@@ -81,6 +86,43 @@ export const createActivityMiddleware = (renderMarkdown, systemMessageStyleProps
81
86
  if (isTagIncluded(card, Constants.systemMessageTag)) {
82
87
  return handleSystemMessage(next, args, card, renderMarkdown, systemMessageStyleProps);
83
88
  }
89
+ if (isTagIncluded(card, Constants.persistentChatHistoryMessagePullTriggerTag)) {
90
+ var _card$activity9, _card$activity9$chann, _card$activity9$chann2;
91
+ // Safety check: if this is a new chat session and flag is false, auto-correct it
92
+ if (!LazyLoadHandler.hasMoreHistoryAvailable) {
93
+ LazyLoadHandler.setHasMoreHistoryAvailable(true);
94
+ }
95
+ const receivedAt = card === null || card === void 0 ? void 0 : (_card$activity9 = card.activity) === null || _card$activity9 === void 0 ? void 0 : (_card$activity9$chann = _card$activity9.channelData) === null || _card$activity9$chann === void 0 ? void 0 : (_card$activity9$chann2 = _card$activity9$chann.webChat) === null || _card$activity9$chann2 === void 0 ? void 0 : _card$activity9$chann2.receivedAt;
96
+ if (receivedAt < lastRenderedAt) {
97
+ card.activity = null;
98
+ return () => false;
99
+ }
100
+ lastRenderedAt = receivedAt;
101
+
102
+ // Return a function that checks availability at render time
103
+ return () => {
104
+ // Double-check at render time in case history availability changed
105
+ if (!LazyLoadHandler.hasMoreHistoryAvailable) {
106
+ return null;
107
+ }
108
+ return /*#__PURE__*/React.createElement(LazyLoadActivity, null);
109
+ };
110
+ }
111
+ if (isTagIncluded(card, Constants.persistentChatHistoryMessageTag)) {
112
+ const userMessageStyles = {
113
+ ...defaultUserMessageStyles,
114
+ ...userMessageStyleProps
115
+ };
116
+ return function () {
117
+ return /*#__PURE__*/React.createElement("div", {
118
+ className: card.activity.from.role === DirectLineSenderRole.User ? Constants.sentMessageClassName : Constants.receivedMessageClassName,
119
+ style: userMessageStyles
120
+ }, next(...args)(...arguments));
121
+ };
122
+ }
123
+ if (isTagIncluded(card, Constants.conversationDividerTag)) {
124
+ return /*#__PURE__*/React.createElement(ConversationDividerActivity, null);
125
+ }
84
126
  if (card.activity.text && card.activity.type === DirectLineActivityType.Message) {
85
127
  if (!card.activity.channelData.isHtmlEncoded && card.activity.channelId === Constants.webchatChannelId) {
86
128
  card.activity.text = escapeHtml(card.activity.text);
@@ -1,5 +1,6 @@
1
1
  import { Constants, WebChatMiddlewareConstants } from "../../../../../common/Constants";
2
2
  import { DeliveredTimestamp } from "./timestamps/DeliveredTimestamp";
3
+ import { HistoryMessageTimestamp } from "./timestamps/HistoryMessageTimestamp";
3
4
  import { NotDeliveredTimestamp } from "./timestamps/NotDeliveredTimestamp";
4
5
  import React from "react";
5
6
  import { SendStatus } from "../../enums/SendStatus";
@@ -26,6 +27,11 @@ export const activityStatusMiddleware = () => next => args => {
26
27
  current_role = role,
27
28
  current_timestamp = timestamp;
28
29
  let sameTimestampGroupTemp = sameTimestampGroup;
30
+ if (tags !== null && tags !== void 0 && tags.includes(Constants.persistentChatHistoryMessageTag)) {
31
+ return /*#__PURE__*/React.createElement(HistoryMessageTimestamp, {
32
+ args: args
33
+ });
34
+ }
29
35
  if (args[WebChatMiddlewareConstants.nextVisibleActivity]) {
30
36
  const {
31
37
  nextVisibleActivity: {
@@ -35,6 +41,7 @@ export const activityStatusMiddleware = () => next => args => {
35
41
  timestamp
36
42
  }
37
43
  } = args;
44
+
38
45
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
39
46
  const next_name = name,
40
47
  next_timestamp = timestamp;
@@ -61,4 +68,10 @@ export const activityStatusMiddleware = () => next => args => {
61
68
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
62
69
  ;
63
70
  }
71
+ };
72
+
73
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
74
+ export const createActivityStatusMiddleware = function () {
75
+ let locale = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "en-us";
76
+ return activityStatusMiddleware;
64
77
  };
@@ -1,6 +1,6 @@
1
1
  export const defaultAvatarTextStyles = {
2
2
  margin: "0",
3
- fontFamily: "\"Segoe UI\", Arial, sans-serif",
3
+ fontFamily: "'Segoe UI', 'Apple Color Emoji', 'Noto Color Emoji', 'Segoe UI Emoji', Arial, sans-serif",
4
4
  fontWeight: 600,
5
5
  fontSize: "13px",
6
6
  lineHeight: "18px",
@@ -0,0 +1,13 @@
1
+ import { defaultSystemMessageStyles } from "./defaultSystemMessageStyles";
2
+ // Adjust the import path if necessary
3
+
4
+ export const defaultInlineBannerStyle = {
5
+ ...defaultSystemMessageStyles,
6
+ visibility: "visible",
7
+ height: "20px",
8
+ display: "flex",
9
+ justifyContent: "center",
10
+ alignItems: "center",
11
+ margin: "5px 10px",
12
+ cursor: "pointer"
13
+ };
@@ -5,7 +5,7 @@ export const defaultSystemMessageStyles = {
5
5
  fontSize: "12px",
6
6
  borderRadius: 0,
7
7
  minHeight: "auto",
8
- fontFamily: "Segoe UI",
8
+ fontFamily: "'Segoe UI', 'Apple Color Emoji', 'Noto Color Emoji', 'Segoe UI Emoji', Arial, sans-serif",
9
9
  lineHeight: "16px",
10
10
  padding: "0px 10px 0 10px"
11
11
  };
@@ -4,7 +4,7 @@ import { Stack } from "@fluentui/react";
4
4
  import { defaultMiddlewareLocalizedTexts } from "../../../../common/defaultProps/defaultMiddlewareLocalizedTexts";
5
5
  import { defaultTimestampContentStyles } from "../defaultStyles/defaultTimestampContentStyles";
6
6
  import { getTimestampHourMinute } from "../../../../../../common/utils";
7
- import { useChatContextStore } from "../../../../../..";
7
+ import useChatContextStore from "../../../../../../hooks/useChatContextStore";
8
8
 
9
9
  /* eslint @typescript-eslint/no-explicit-any: "off" */
10
10
  export const DeliveredTimestamp = _ref => {
@@ -0,0 +1,52 @@
1
+ import React from "react";
2
+ import { Stack } from "@fluentui/react";
3
+ import { defaultMiddlewareLocalizedTexts } from "../../../../common/defaultProps/defaultMiddlewareLocalizedTexts";
4
+ import { defaultTimestampContentStyles } from "../defaultStyles/defaultTimestampContentStyles";
5
+ import { getTimestampHourMinute } from "../../../../../../common/utils";
6
+ import useChatContextStore from "../../../../../../hooks/useChatContextStore";
7
+
8
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
9
+ export const HistoryMessageTimestamp = _ref => {
10
+ var _state$domainStates$r, _state$domainStates$r2, _state$domainStates$m;
11
+ let {
12
+ args
13
+ } = _ref;
14
+ const [state] = useChatContextStore();
15
+ const dir = ((_state$domainStates$r = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r === void 0 ? void 0 : _state$domainStates$r.timestampDir) ?? state.domainStates.globalDir;
16
+ const {
17
+ activity: {
18
+ timestamp,
19
+ from: {
20
+ name,
21
+ role
22
+ }
23
+ }
24
+ } = args;
25
+ const contentStyles = {
26
+ ...defaultTimestampContentStyles,
27
+ ...((_state$domainStates$r2 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r2 === void 0 ? void 0 : _state$domainStates$r2.timestampContentStyleProps)
28
+ };
29
+ const getTimeElement = timestamp => {
30
+ const timeString = getTimestampHourMinute(timestamp);
31
+ const isAmPmFormat = timeString.toLowerCase().includes("am") || timeString.toLowerCase().includes("pm");
32
+ if (dir === "rtl" && isAmPmFormat) {
33
+ return /*#__PURE__*/React.createElement("span", {
34
+ dir: "ltr"
35
+ }, timeString);
36
+ } else {
37
+ return /*#__PURE__*/React.createElement("span", {
38
+ dir: dir
39
+ }, timeString);
40
+ }
41
+ };
42
+ return /*#__PURE__*/React.createElement(Stack, {
43
+ style: contentStyles,
44
+ dir: dir
45
+ }, role === "bot" && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
46
+ dir: dir,
47
+ "aria-hidden": "false"
48
+ }, name, " : ", getTimeElement(timestamp))), role === "user" && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
49
+ "aria-hidden": "false",
50
+ dir: dir
51
+ }, " ", getTimeElement(timestamp), " - ", ((_state$domainStates$m = state.domainStates.middlewareLocalizedTexts) === null || _state$domainStates$m === void 0 ? void 0 : _state$domainStates$m.MIDDLEWARE_MESSAGE_DELIVERED) ?? defaultMiddlewareLocalizedTexts.MIDDLEWARE_MESSAGE_DELIVERED), " "));
52
+ };
@@ -7,9 +7,9 @@ import { defaultTimestampFailedStyles } from "../defaultStyles/defaultTimestampF
7
7
  import { defaultTimestampRetryStyles } from "../defaultStyles/defaultTimestampRetryStyles";
8
8
  import { getTimestampHourMinute } from "../../../../../../common/utils";
9
9
  import { hooks } from "botframework-webchat";
10
- import { useChatContextStore } from "../../../../../..";
10
+ import useChatContextStore from "../../../../../../hooks/useChatContextStore";
11
11
 
12
- /* eslint @typescript-eslint/no-explicit-any: "off" */
12
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
13
13
  export const NotDeliveredTimestamp = _ref => {
14
14
  var _state$domainStates$r, _state$domainStates$r2, _state$domainStates$r3, _state$domainStates$r4, _state$domainStates$m, _state$domainStates$m2;
15
15
  let {
@@ -69,6 +69,7 @@ export const NotDeliveredTimestamp = _ref => {
69
69
  style: failedTextStyles
70
70
  }, " ", ((_state$domainStates$m = state.domainStates.middlewareLocalizedTexts) === null || _state$domainStates$m === void 0 ? void 0 : _state$domainStates$m.MIDDLEWARE_MESSAGE_NOT_DELIVERED) ?? defaultMiddlewareLocalizedTexts.MIDDLEWARE_MESSAGE_NOT_DELIVERED, " "), /*#__PURE__*/React.createElement("span", null, " \xA0-\xA0 "), /*#__PURE__*/React.createElement("span", {
71
71
  style: retryTextStyles,
72
+ role: "button",
72
73
  onClick: onRetryClick,
73
74
  onKeyDown: onRetryKeyEnter,
74
75
  tabIndex: 0
@@ -2,7 +2,7 @@ import React from "react";
2
2
  import { Stack } from "@fluentui/react";
3
3
  import { defaultMiddlewareLocalizedTexts } from "../../../../common/defaultProps/defaultMiddlewareLocalizedTexts";
4
4
  import { defaultTimestampContentStyles } from "../defaultStyles/defaultTimestampContentStyles";
5
- import { useChatContextStore } from "../../../../../..";
5
+ import useChatContextStore from "../../../../../../hooks/useChatContextStore";
6
6
 
7
7
  /* eslint @typescript-eslint/no-explicit-any: "off" */
8
8
  export const SendingTimestamp = () => {
@@ -1,56 +1,125 @@
1
1
  import { LogLevel, TelemetryEvent } from "../../../../../common/telemetry/TelemetryConstants";
2
+ import { LiveChatWidgetActionType } from "../../../../../contexts/common/LiveChatWidgetActionType";
2
3
  import { TelemetryHelper } from "../../../../../common/telemetry/TelemetryHelper";
3
- export const createCitationsMiddleware = _ref => {
4
- let {
5
- dispatch
6
- } = _ref;
7
- return next => action => {
8
- var _action$payload;
9
- if ((_action$payload = action.payload) !== null && _action$payload !== void 0 && _action$payload.activity) {
10
- if (isApplicable(action)) {
4
+ import { executeReducer } from "../../../../../contexts/createReducer";
5
+
6
+ // Middleware that extracts citation metadata from incoming ACS activities and
7
+ // updates in-memory app state with a global citation map. Also rewrites
8
+ // per-message citation labels in the activity text to use a stable,
9
+ // message-scoped prefix when the producer provides a message id.
10
+
11
+ export const createCitationsMiddleware = (state, dispatch) => () => next => action => {
12
+ var _action$payload;
13
+ if ((_action$payload = action.payload) !== null && _action$payload !== void 0 && _action$payload.activity) {
14
+ if (isApplicable(action)) {
15
+ try {
16
+ var _action$payload2, _action$payload2$acti, _gptFeedback$summariz, _gptFeedback$summariz2;
17
+ const inMemoryState = executeReducer(state, {
18
+ type: LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
19
+ payload: null
20
+ });
21
+
22
+ // Use the producer-supplied messageid as a stable per-message prefix
23
+ // when present. Do not derive a prefix from activity.id or timestamps.
24
+ const messagePrefix = ((_action$payload2 = action.payload) === null || _action$payload2 === void 0 ? void 0 : (_action$payload2$acti = _action$payload2.activity) === null || _action$payload2$acti === void 0 ? void 0 : _action$payload2$acti.messageid) ?? "";
25
+ const gptFeedback = JSON.parse(action.payload.activity.channelData.metadata["pva:gpt-feedback"]);
26
+ // Extract citation objects from the model response
27
+ const citations = (_gptFeedback$summariz = gptFeedback.summarizationOpenAIResponse) === null || _gptFeedback$summariz === void 0 ? void 0 : (_gptFeedback$summariz2 = _gptFeedback$summariz.result) === null || _gptFeedback$summariz2 === void 0 ? void 0 : _gptFeedback$summariz2.textCitations;
28
+ // Rewrite inline citation labels in activity.text to match the global map keys
29
+ const updatedText = replaceCitations(action.payload.activity.text, citations, messagePrefix);
30
+ action.payload.activity.text = updatedText;
31
+ // Build a global citation map keyed by the prefixed citation id and
32
+ // dispatch it to app state so the UI container can render citations.
11
33
  try {
12
- const gptFeedback = JSON.parse(action.payload.activity.channelData.metadata["pva:gpt-feedback"]);
13
- // Replace citations in the text
14
- const updatedText = replaceCitations(action.payload.activity.text, gptFeedback.summarizationOpenAIResponse.result.textCitations);
15
- action.payload.activity.text = updatedText;
16
- } catch (error) {
17
- TelemetryHelper.logActionEvent(LogLevel.ERROR, {
34
+ var _inMemoryState$domain;
35
+ const citationMap = {};
36
+ if (citations && Array.isArray(citations)) {
37
+ citations.forEach(citation => {
38
+ if (citation !== null && citation !== void 0 && citation.id) {
39
+ // Preserve the 'cite:' scheme so renderer click handling remains consistent
40
+ const idWithoutScheme = citation.id.replace(/^cite:/, "");
41
+ const prefixedId = `cite:${messagePrefix}_${idWithoutScheme}`;
42
+ citationMap[prefixedId] = citation.text || citation.title || "";
43
+ }
44
+ });
45
+ }
46
+
47
+ // Read current in-memory state to merge with existing citations
48
+ //const inMemoryState = executeReducer(state, { type: LiveChatWidgetActionType.GET_IN_MEMORY_STATE, payload: null });
49
+ const existingCitations = (inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$domain = inMemoryState.domainStates) === null || _inMemoryState$domain === void 0 ? void 0 : _inMemoryState$domain.citations) || {};
50
+ const updatedCitations = {
51
+ ...existingCitations,
52
+ ...citationMap
53
+ };
54
+ // Always dispatch to app state
55
+ dispatch({
56
+ type: LiveChatWidgetActionType.SET_CITATIONS,
57
+ payload: updatedCitations
58
+ });
59
+ } catch (innerErr) {
60
+ TelemetryHelper.logActionEvent(LogLevel.WARN, {
18
61
  Event: TelemetryEvent.CitationMiddlewareFailed,
19
62
  ExceptionDetails: {
20
- ErrorData: "Error while converting citation labels",
21
- Exception: error
63
+ ErrorData: "Error while populating citation map",
64
+ Exception: innerErr
22
65
  }
23
66
  });
24
67
  }
68
+ } catch (error) {
69
+ TelemetryHelper.logActionEvent(LogLevel.ERROR, {
70
+ Event: TelemetryEvent.CitationMiddlewareFailed,
71
+ ExceptionDetails: {
72
+ ErrorData: "Error while converting citation labels",
73
+ Exception: error
74
+ }
75
+ });
25
76
  }
26
77
  }
27
- return next(action);
28
- };
78
+ }
79
+ return next(action);
29
80
  };
30
81
  const isApplicable = action => {
31
- var _action$payload2, _action$payload2$acti, _action$payload3, _action$payload3$acti;
32
- if ((action === null || action === void 0 ? void 0 : (_action$payload2 = action.payload) === null || _action$payload2 === void 0 ? void 0 : (_action$payload2$acti = _action$payload2.activity) === null || _action$payload2$acti === void 0 ? void 0 : _action$payload2$acti.actionType) === "DIRECT_LINE/INCOMING_ACTIVITY" && (action === null || action === void 0 ? void 0 : (_action$payload3 = action.payload) === null || _action$payload3 === void 0 ? void 0 : (_action$payload3$acti = _action$payload3.activity) === null || _action$payload3$acti === void 0 ? void 0 : _action$payload3$acti.channelId) === "ACS_CHANNEL") {
33
- var _action$payload4, _action$payload4$acti, _action$payload4$acti2, _action$payload4$acti3;
34
- // Validate if pva:gpt-feedback exists and is not null
35
- if (action !== null && action !== void 0 && (_action$payload4 = action.payload) !== null && _action$payload4 !== void 0 && (_action$payload4$acti = _action$payload4.activity) !== null && _action$payload4$acti !== void 0 && (_action$payload4$acti2 = _action$payload4$acti.channelData) !== null && _action$payload4$acti2 !== void 0 && (_action$payload4$acti3 = _action$payload4$acti2.metadata) !== null && _action$payload4$acti3 !== void 0 && _action$payload4$acti3["pva:gpt-feedback"]) {
82
+ var _action$payload3, _action$payload3$acti, _action$payload4, _action$payload4$acti;
83
+ if ((action === null || action === void 0 ? void 0 : (_action$payload3 = action.payload) === null || _action$payload3 === void 0 ? void 0 : (_action$payload3$acti = _action$payload3.activity) === null || _action$payload3$acti === void 0 ? void 0 : _action$payload3$acti.actionType) === "DIRECT_LINE/INCOMING_ACTIVITY" && (action === null || action === void 0 ? void 0 : (_action$payload4 = action.payload) === null || _action$payload4 === void 0 ? void 0 : (_action$payload4$acti = _action$payload4.activity) === null || _action$payload4$acti === void 0 ? void 0 : _action$payload4$acti.channelId) === "ACS_CHANNEL") {
84
+ var _action$payload5, _action$payload5$acti, _action$payload5$acti2, _action$payload5$acti3;
85
+ // Only applicable for ACS incoming activities that include pva:gpt-feedback
86
+ if (action !== null && action !== void 0 && (_action$payload5 = action.payload) !== null && _action$payload5 !== void 0 && (_action$payload5$acti = _action$payload5.activity) !== null && _action$payload5$acti !== void 0 && (_action$payload5$acti2 = _action$payload5$acti.channelData) !== null && _action$payload5$acti2 !== void 0 && (_action$payload5$acti3 = _action$payload5$acti2.metadata) !== null && _action$payload5$acti3 !== void 0 && _action$payload5$acti3["pva:gpt-feedback"]) {
36
87
  return true;
37
88
  }
38
89
  }
39
90
  return false;
40
91
  };
41
- const replaceCitations = (text, citations) => {
92
+ const replaceCitations = (text, citations, messagePrefix) => {
42
93
  if (!citations || !Array.isArray(citations)) {
43
94
  return text;
44
95
  }
45
96
  try {
46
- return text.replace(/\[(\d+)\]:\s(cite:\d+)\s"([^"]+)"/g, (match, number, citeId) => {
47
- const citation = citations.find(c => c.id === citeId);
97
+ let updatedText = text;
98
+
99
+ // First, handle the citation reference definitions at the end (e.g., [1]: cite:1757450535119_1 "index.html")
100
+ // These should NOT be escaped as they are proper citation definitions
101
+ updatedText = updatedText.replace(/\[(\d+)\]:\s(cite:\d+)\s"([^\\"]+)"/g, (match, number, citeId) => {
102
+ // Attempt to find a citation object matching the inline cite id and
103
+ // update the displayed id/title. When a messagePrefix exists we
104
+ // rewrite the id to the prefixed form so it aligns with the
105
+ // global citation map keys.
106
+ const lookupId = citeId;
107
+ const citation = citations.find(c => c.id === lookupId);
48
108
  if (citation) {
49
- // Replace only the citation label while preserving the original format
50
- return `[${number}]: ${citeId} "${citation.title}"`;
109
+ const idWithoutScheme = citeId.replace(/^cite:/, "");
110
+ const prefixed = messagePrefix ? `cite:${messagePrefix}_${idWithoutScheme}` : citeId;
111
+ return `[${number}]: ${prefixed} "${citation.title}"`;
51
112
  }
52
- return match; // Keep the original match if no replacement is found
113
+ return match;
114
+ });
115
+
116
+ // Second, escape inline citation references that are NOT followed by a colon
117
+ // This handles cases like "[1][2]"" in the middle of text that should be escaped for markdown
118
+ updatedText = updatedText.replace(/\[(\d+)\](?!:)/g, (match, number) => {
119
+ // Escape the brackets to prevent markdown from treating them as incomplete link syntax
120
+ return `&#91;${number}&#93;`;
53
121
  });
122
+ return updatedText;
54
123
  } catch (error) {
55
124
  TelemetryHelper.logActionEvent(LogLevel.ERROR, {
56
125
  Event: TelemetryEvent.CitationMiddlewareFailed,
@@ -59,7 +128,6 @@ const replaceCitations = (text, citations) => {
59
128
  Exception: error
60
129
  }
61
130
  });
62
- // Return the original text in case of issues
63
131
  return text;
64
132
  }
65
133
  };
@@ -1,7 +1,7 @@
1
- import { WebChatActionType } from "../../enums/WebChatActionType";
2
1
  import { LogLevel, TelemetryEvent } from "../../../../../common/telemetry/TelemetryConstants";
3
- import { TelemetryHelper } from "../../../../../common/telemetry/TelemetryHelper";
4
2
  import { LiveChatWidgetActionType } from "../../../../../contexts/common/LiveChatWidgetActionType";
3
+ import { TelemetryHelper } from "../../../../../common/telemetry/TelemetryHelper";
4
+ import { WebChatActionType } from "../../enums/WebChatActionType";
5
5
  import { executeReducer } from "../../../../../contexts/createReducer";
6
6
  import { isEndConversationDueToOverflowActivity } from "../../../../../common/utils";
7
7
  const queueOverflowHandlingHelper = async (state, dispatch) => {
@@ -3,49 +3,50 @@ export let LiveChatWidgetActionType;
3
3
  LiveChatWidgetActionType[LiveChatWidgetActionType["SET_WIDGET_ELEMENT_ID"] = 0] = "SET_WIDGET_ELEMENT_ID";
4
4
  LiveChatWidgetActionType[LiveChatWidgetActionType["SET_RENDERING_MIDDLEWARE_PROPS"] = 1] = "SET_RENDERING_MIDDLEWARE_PROPS";
5
5
  LiveChatWidgetActionType[LiveChatWidgetActionType["SET_MIDDLEWARE_LOCALIZED_TEXTS"] = 2] = "SET_MIDDLEWARE_LOCALIZED_TEXTS";
6
- LiveChatWidgetActionType[LiveChatWidgetActionType["SET_GLOBAL_DIR"] = 3] = "SET_GLOBAL_DIR";
7
- LiveChatWidgetActionType[LiveChatWidgetActionType["SET_MINIMIZED"] = 4] = "SET_MINIMIZED";
8
- LiveChatWidgetActionType[LiveChatWidgetActionType["SET_CONVERSATION_STATE"] = 5] = "SET_CONVERSATION_STATE";
9
- LiveChatWidgetActionType[LiveChatWidgetActionType["SET_PREVIOUS_FOCUSED_ELEMENT_ID"] = 6] = "SET_PREVIOUS_FOCUSED_ELEMENT_ID";
10
- LiveChatWidgetActionType[LiveChatWidgetActionType["SET_START_CHAT_FAILING"] = 7] = "SET_START_CHAT_FAILING";
11
- LiveChatWidgetActionType[LiveChatWidgetActionType["SET_START_CHAT_FAILURE_TYPE"] = 8] = "SET_START_CHAT_FAILURE_TYPE";
12
- LiveChatWidgetActionType[LiveChatWidgetActionType["SET_OUTSIDE_OPERATING_HOURS"] = 9] = "SET_OUTSIDE_OPERATING_HOURS";
13
- LiveChatWidgetActionType[LiveChatWidgetActionType["SET_PRE_CHAT_SURVEY_RESPONSE"] = 10] = "SET_PRE_CHAT_SURVEY_RESPONSE";
14
- LiveChatWidgetActionType[LiveChatWidgetActionType["SET_CUSTOM_CONTEXT"] = 11] = "SET_CUSTOM_CONTEXT";
15
- LiveChatWidgetActionType[LiveChatWidgetActionType["SET_SHOW_CONFIRMATION"] = 12] = "SET_SHOW_CONFIRMATION";
16
- LiveChatWidgetActionType[LiveChatWidgetActionType["SET_SHOW_EMAIL_TRANSCRIPT_PANE"] = 13] = "SET_SHOW_EMAIL_TRANSCRIPT_PANE";
17
- LiveChatWidgetActionType[LiveChatWidgetActionType["SET_PRECHAT_RESPONSE_EMAIL"] = 14] = "SET_PRECHAT_RESPONSE_EMAIL";
18
- LiveChatWidgetActionType[LiveChatWidgetActionType["SET_AUDIO_NOTIFICATION"] = 15] = "SET_AUDIO_NOTIFICATION";
19
- LiveChatWidgetActionType[LiveChatWidgetActionType["SET_E2VV_ENABLED"] = 16] = "SET_E2VV_ENABLED";
20
- LiveChatWidgetActionType[LiveChatWidgetActionType["SET_POST_CHAT_CONTEXT"] = 17] = "SET_POST_CHAT_CONTEXT";
21
- LiveChatWidgetActionType[LiveChatWidgetActionType["SHOW_CALLING_CONTAINER"] = 18] = "SHOW_CALLING_CONTAINER";
22
- LiveChatWidgetActionType[LiveChatWidgetActionType["SET_INCOMING_CALL"] = 19] = "SET_INCOMING_CALL";
23
- LiveChatWidgetActionType[LiveChatWidgetActionType["DISABLE_VIDEO_CALL"] = 20] = "DISABLE_VIDEO_CALL";
24
- LiveChatWidgetActionType[LiveChatWidgetActionType["DISABLE_LOCAL_VIDEO"] = 21] = "DISABLE_LOCAL_VIDEO";
25
- LiveChatWidgetActionType[LiveChatWidgetActionType["DISABLE_REMOTE_VIDEO"] = 22] = "DISABLE_REMOTE_VIDEO";
26
- LiveChatWidgetActionType[LiveChatWidgetActionType["SET_CHAT_TOKEN"] = 23] = "SET_CHAT_TOKEN";
27
- LiveChatWidgetActionType[LiveChatWidgetActionType["SET_START_CHAT_BUTTON_DISPLAY"] = 24] = "SET_START_CHAT_BUTTON_DISPLAY";
28
- LiveChatWidgetActionType[LiveChatWidgetActionType["SET_PROACTIVE_CHAT_PARAMS"] = 25] = "SET_PROACTIVE_CHAT_PARAMS";
29
- LiveChatWidgetActionType[LiveChatWidgetActionType["SET_TELEMETRY_DATA"] = 26] = "SET_TELEMETRY_DATA";
30
- LiveChatWidgetActionType[LiveChatWidgetActionType["SET_RECONNECT_ID"] = 27] = "SET_RECONNECT_ID";
31
- LiveChatWidgetActionType[LiveChatWidgetActionType["SET_UNREAD_MESSAGE_COUNT"] = 28] = "SET_UNREAD_MESSAGE_COUNT";
32
- LiveChatWidgetActionType[LiveChatWidgetActionType["SET_FOCUS_CHAT_BUTTON"] = 29] = "SET_FOCUS_CHAT_BUTTON";
33
- LiveChatWidgetActionType[LiveChatWidgetActionType["SET_CONVERSATION_ENDED_BY_AGENT_EVENT_RECEIVED"] = 30] = "SET_CONVERSATION_ENDED_BY_AGENT_EVENT_RECEIVED";
34
- LiveChatWidgetActionType[LiveChatWidgetActionType["SET_CONVERSATION_ENDED_BY"] = 31] = "SET_CONVERSATION_ENDED_BY";
35
- LiveChatWidgetActionType[LiveChatWidgetActionType["SET_WIDGET_STATE"] = 32] = "SET_WIDGET_STATE";
36
- LiveChatWidgetActionType[LiveChatWidgetActionType["SET_LIVE_CHAT_CONTEXT"] = 33] = "SET_LIVE_CHAT_CONTEXT";
37
- LiveChatWidgetActionType[LiveChatWidgetActionType["SET_BOT_OAUTH_SIGNIN_ID"] = 34] = "SET_BOT_OAUTH_SIGNIN_ID";
38
- LiveChatWidgetActionType[LiveChatWidgetActionType["SET_WIDGET_SIZE"] = 35] = "SET_WIDGET_SIZE";
39
- LiveChatWidgetActionType[LiveChatWidgetActionType["SET_WIDGET_INSTANCE_ID"] = 36] = "SET_WIDGET_INSTANCE_ID";
40
- LiveChatWidgetActionType[LiveChatWidgetActionType["SET_LIVE_CHAT_CONFIG"] = 37] = "SET_LIVE_CHAT_CONFIG";
41
- LiveChatWidgetActionType[LiveChatWidgetActionType["SET_POST_CHAT_WORKFLOW_IN_PROGRESS"] = 38] = "SET_POST_CHAT_WORKFLOW_IN_PROGRESS";
42
- LiveChatWidgetActionType[LiveChatWidgetActionType["SET_INITIAL_CHAT_SDK_REQUEST_ID"] = 39] = "SET_INITIAL_CHAT_SDK_REQUEST_ID";
43
- LiveChatWidgetActionType[LiveChatWidgetActionType["SET_SHOULD_USE_BOT_SURVEY"] = 40] = "SET_SHOULD_USE_BOT_SURVEY";
44
- LiveChatWidgetActionType[LiveChatWidgetActionType["SET_CHAT_DISCONNECT_EVENT_RECEIVED"] = 41] = "SET_CHAT_DISCONNECT_EVENT_RECEIVED";
45
- LiveChatWidgetActionType[LiveChatWidgetActionType["SET_SURVEY_MODE"] = 42] = "SET_SURVEY_MODE";
46
- LiveChatWidgetActionType[LiveChatWidgetActionType["SET_CONFIRMATION_STATE"] = 43] = "SET_CONFIRMATION_STATE";
47
- LiveChatWidgetActionType[LiveChatWidgetActionType["SET_POST_CHAT_PARTICIPANT_TYPE"] = 44] = "SET_POST_CHAT_PARTICIPANT_TYPE";
48
- LiveChatWidgetActionType[LiveChatWidgetActionType["SET_CONVERSATIONAL_SURVEY_ENABLED"] = 45] = "SET_CONVERSATIONAL_SURVEY_ENABLED";
49
- LiveChatWidgetActionType[LiveChatWidgetActionType["SET_CONVERSATIONAL_SURVEY_DISPLAY"] = 46] = "SET_CONVERSATIONAL_SURVEY_DISPLAY";
50
- LiveChatWidgetActionType[LiveChatWidgetActionType["GET_IN_MEMORY_STATE"] = 47] = "GET_IN_MEMORY_STATE";
6
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_CITATIONS"] = 3] = "SET_CITATIONS";
7
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_GLOBAL_DIR"] = 4] = "SET_GLOBAL_DIR";
8
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_MINIMIZED"] = 5] = "SET_MINIMIZED";
9
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_CONVERSATION_STATE"] = 6] = "SET_CONVERSATION_STATE";
10
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_PREVIOUS_FOCUSED_ELEMENT_ID"] = 7] = "SET_PREVIOUS_FOCUSED_ELEMENT_ID";
11
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_START_CHAT_FAILING"] = 8] = "SET_START_CHAT_FAILING";
12
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_START_CHAT_FAILURE_TYPE"] = 9] = "SET_START_CHAT_FAILURE_TYPE";
13
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_OUTSIDE_OPERATING_HOURS"] = 10] = "SET_OUTSIDE_OPERATING_HOURS";
14
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_PRE_CHAT_SURVEY_RESPONSE"] = 11] = "SET_PRE_CHAT_SURVEY_RESPONSE";
15
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_CUSTOM_CONTEXT"] = 12] = "SET_CUSTOM_CONTEXT";
16
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_SHOW_CONFIRMATION"] = 13] = "SET_SHOW_CONFIRMATION";
17
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_SHOW_EMAIL_TRANSCRIPT_PANE"] = 14] = "SET_SHOW_EMAIL_TRANSCRIPT_PANE";
18
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_PRECHAT_RESPONSE_EMAIL"] = 15] = "SET_PRECHAT_RESPONSE_EMAIL";
19
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_AUDIO_NOTIFICATION"] = 16] = "SET_AUDIO_NOTIFICATION";
20
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_E2VV_ENABLED"] = 17] = "SET_E2VV_ENABLED";
21
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_POST_CHAT_CONTEXT"] = 18] = "SET_POST_CHAT_CONTEXT";
22
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SHOW_CALLING_CONTAINER"] = 19] = "SHOW_CALLING_CONTAINER";
23
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_INCOMING_CALL"] = 20] = "SET_INCOMING_CALL";
24
+ LiveChatWidgetActionType[LiveChatWidgetActionType["DISABLE_VIDEO_CALL"] = 21] = "DISABLE_VIDEO_CALL";
25
+ LiveChatWidgetActionType[LiveChatWidgetActionType["DISABLE_LOCAL_VIDEO"] = 22] = "DISABLE_LOCAL_VIDEO";
26
+ LiveChatWidgetActionType[LiveChatWidgetActionType["DISABLE_REMOTE_VIDEO"] = 23] = "DISABLE_REMOTE_VIDEO";
27
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_CHAT_TOKEN"] = 24] = "SET_CHAT_TOKEN";
28
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_START_CHAT_BUTTON_DISPLAY"] = 25] = "SET_START_CHAT_BUTTON_DISPLAY";
29
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_PROACTIVE_CHAT_PARAMS"] = 26] = "SET_PROACTIVE_CHAT_PARAMS";
30
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_TELEMETRY_DATA"] = 27] = "SET_TELEMETRY_DATA";
31
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_RECONNECT_ID"] = 28] = "SET_RECONNECT_ID";
32
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_UNREAD_MESSAGE_COUNT"] = 29] = "SET_UNREAD_MESSAGE_COUNT";
33
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_FOCUS_CHAT_BUTTON"] = 30] = "SET_FOCUS_CHAT_BUTTON";
34
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_CONVERSATION_ENDED_BY_AGENT_EVENT_RECEIVED"] = 31] = "SET_CONVERSATION_ENDED_BY_AGENT_EVENT_RECEIVED";
35
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_CONVERSATION_ENDED_BY"] = 32] = "SET_CONVERSATION_ENDED_BY";
36
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_WIDGET_STATE"] = 33] = "SET_WIDGET_STATE";
37
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_LIVE_CHAT_CONTEXT"] = 34] = "SET_LIVE_CHAT_CONTEXT";
38
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_BOT_OAUTH_SIGNIN_ID"] = 35] = "SET_BOT_OAUTH_SIGNIN_ID";
39
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_WIDGET_SIZE"] = 36] = "SET_WIDGET_SIZE";
40
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_WIDGET_INSTANCE_ID"] = 37] = "SET_WIDGET_INSTANCE_ID";
41
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_LIVE_CHAT_CONFIG"] = 38] = "SET_LIVE_CHAT_CONFIG";
42
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_POST_CHAT_WORKFLOW_IN_PROGRESS"] = 39] = "SET_POST_CHAT_WORKFLOW_IN_PROGRESS";
43
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_INITIAL_CHAT_SDK_REQUEST_ID"] = 40] = "SET_INITIAL_CHAT_SDK_REQUEST_ID";
44
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_SHOULD_USE_BOT_SURVEY"] = 41] = "SET_SHOULD_USE_BOT_SURVEY";
45
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_CHAT_DISCONNECT_EVENT_RECEIVED"] = 42] = "SET_CHAT_DISCONNECT_EVENT_RECEIVED";
46
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_SURVEY_MODE"] = 43] = "SET_SURVEY_MODE";
47
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_CONFIRMATION_STATE"] = 44] = "SET_CONFIRMATION_STATE";
48
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_POST_CHAT_PARTICIPANT_TYPE"] = 45] = "SET_POST_CHAT_PARTICIPANT_TYPE";
49
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_CONVERSATIONAL_SURVEY_ENABLED"] = 46] = "SET_CONVERSATIONAL_SURVEY_ENABLED";
50
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_CONVERSATIONAL_SURVEY_DISPLAY"] = 47] = "SET_CONVERSATIONAL_SURVEY_DISPLAY";
51
+ LiveChatWidgetActionType[LiveChatWidgetActionType["GET_IN_MEMORY_STATE"] = 48] = "GET_IN_MEMORY_STATE";
51
52
  })(LiveChatWidgetActionType || (LiveChatWidgetActionType = {}));
@@ -39,6 +39,8 @@ export const getLiveChatWidgetContextInitialState = props => {
39
39
  domainStates: {
40
40
  liveChatConfig: props.chatConfig,
41
41
  widgetElementId: "",
42
+ // Map of citation id => content injected by citations middleware
43
+ citations: {},
42
44
  renderingMiddlewareProps: (_props$webChatContain = props.webChatContainerProps) === null || _props$webChatContain === void 0 ? void 0 : _props$webChatContain.renderingMiddlewareProps,
43
45
  middlewareLocalizedTexts: defaultMiddlewareLocalizedTexts,
44
46
  preChatSurveyResponse: "{}",
@@ -62,6 +62,21 @@ const reducer = (state, action) => {
62
62
  middlewareLocalizedTexts: action.payload
63
63
  }
64
64
  };
65
+ case LiveChatWidgetActionType.SET_CITATIONS:
66
+ inMemory = {
67
+ ...inMemory,
68
+ domainStates: {
69
+ ...inMemory.domainStates,
70
+ citations: action.payload
71
+ }
72
+ };
73
+ return {
74
+ ...state,
75
+ domainStates: {
76
+ ...state.domainStates,
77
+ citations: action.payload
78
+ }
79
+ };
65
80
  case LiveChatWidgetActionType.SET_GLOBAL_DIR:
66
81
  inMemory = {
67
82
  ...inMemory,
@@ -31,7 +31,7 @@ export const createTrackingForFirstMessage = () => {
31
31
  * Starts tracking the time for the first bot message after widget loads.
32
32
  * Sets a 5-second timeout to auto-reset if no bot message is received.
33
33
  */
34
- const widgetLoadListener = BroadcastService.getMessageByEventName(TelemetryEvent.WidgetLoadComplete).subscribe(() => {
34
+ const widgetLoadListener = BroadcastService.getMessageByEventName(TelemetryEvent.StartChatComplete).subscribe(() => {
35
35
  if (isTracking) return;
36
36
  isTracking = true;
37
37
  startTime = new Date().getTime();
@@ -86,7 +86,8 @@ export const createTrackingForFirstMessage = () => {
86
86
  CustomProperties: {
87
87
  elapsedTime,
88
88
  widgetLoadedAt: startTime,
89
- botMessage: stopTrackingMessage
89
+ botMessage: stopTrackingMessage,
90
+ type: payload === null || payload === void 0 ? void 0 : payload.type
90
91
  }
91
92
  });
92
93
  disconnectListener();