@microsoft/omnichannel-chat-widget 1.8.3-main.ec1328d → 1.8.4-main.7bdb634

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 (160) hide show
  1. package/lib/cjs/common/Constants.js +6 -0
  2. package/lib/cjs/common/facades/FacadeChatSDK.js +6 -0
  3. package/lib/cjs/common/telemetry/TelemetryConstants.js +34 -0
  4. package/lib/cjs/common/utils/SecureEventBus.js +307 -0
  5. package/lib/cjs/common/utils/dispatchCustomEvent.js +25 -0
  6. package/lib/cjs/components/citationpanestateful/CitationDim.js +29 -0
  7. package/lib/cjs/components/citationpanestateful/CitationPaneStateful.js +199 -0
  8. package/lib/cjs/components/citationpanestateful/common/defaultProps/defaultCitationPaneProps.js +70 -0
  9. package/lib/cjs/components/confirmationpanestateful/interfaces/IConfirmationPaneLocalizedTexts.js +1 -0
  10. package/lib/cjs/components/livechatwidget/LiveChatWidget.js +4 -4
  11. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/AddActivitySubscriber.js +127 -0
  12. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +4 -5
  13. package/lib/cjs/components/livechatwidget/common/ChatWidgetEvents.js +15 -0
  14. package/lib/cjs/components/livechatwidget/common/PersistentConversationHandler.js +284 -0
  15. package/lib/cjs/components/livechatwidget/common/createAdapter.js +2 -0
  16. package/lib/cjs/components/livechatwidget/common/defaultProps/defaultPersistentChatHistoryProps.js +18 -0
  17. package/lib/cjs/components/livechatwidget/common/endChat.js +28 -3
  18. package/lib/cjs/components/livechatwidget/common/getMockChatSDKIfApplicable.js +4 -3
  19. package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +8 -6
  20. package/lib/cjs/components/livechatwidget/common/overridePropsOnMockIfApplicable.js +2 -1
  21. package/lib/cjs/components/livechatwidget/common/startChat.js +5 -4
  22. package/lib/cjs/components/livechatwidget/interfaces/IMockProps.js +8 -2
  23. package/lib/cjs/components/livechatwidget/interfaces/IPersistentChatHistoryProps.js +1 -0
  24. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +29 -5
  25. package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +122 -11
  26. package/lib/cjs/components/webchatcontainerstateful/common/DesignerChatAdapter.js +43 -14
  27. package/lib/cjs/components/webchatcontainerstateful/common/DesignerChatSDK.js +6 -1
  28. package/lib/cjs/components/webchatcontainerstateful/common/activities/botActivity.js +14 -0
  29. package/lib/cjs/components/webchatcontainerstateful/common/activities/conversationDividerActivity.js +17 -0
  30. package/lib/cjs/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.js +97 -0
  31. package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +2 -1
  32. package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultWebChatStatefulProps.js +1 -1
  33. package/lib/cjs/components/webchatcontainerstateful/common/defaultStyles/defaultWebChatStyles.js +1 -1
  34. package/lib/cjs/components/webchatcontainerstateful/common/utils/chatAdapterUtils.js +36 -2
  35. package/lib/cjs/components/webchatcontainerstateful/common/utils/fontUtils.js +28 -0
  36. package/lib/cjs/components/webchatcontainerstateful/hooks/usePersistentChatHistory.js +59 -0
  37. package/lib/cjs/components/webchatcontainerstateful/interfaces/ICitation.js +1 -0
  38. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js +122 -0
  39. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/Constants.js +10 -0
  40. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/ConversationDividerActivity.js +18 -0
  41. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.js +1038 -0
  42. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LoadInlineBannerActivity.js +34 -0
  43. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +44 -0
  44. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +16 -2
  45. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultAvatarTextStyles.js +1 -1
  46. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultInLineBannerStyle.js +20 -0
  47. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageStyles.js +1 -1
  48. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +2 -2
  49. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/HistoryMessageTimestamp.js +59 -0
  50. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +4 -3
  51. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +2 -2
  52. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.js +97 -30
  53. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware.js +2 -2
  54. package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +46 -45
  55. package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +2 -0
  56. package/lib/cjs/contexts/createReducer.js +15 -0
  57. package/lib/cjs/index.js +9 -1
  58. package/lib/esm/common/Constants.js +6 -0
  59. package/lib/esm/common/facades/FacadeChatSDK.js +6 -0
  60. package/lib/esm/common/telemetry/TelemetryConstants.js +34 -0
  61. package/lib/esm/common/utils/SecureEventBus.js +328 -0
  62. package/lib/esm/common/utils/dispatchCustomEvent.js +18 -0
  63. package/lib/esm/components/citationpanestateful/CitationDim.js +20 -0
  64. package/lib/esm/components/citationpanestateful/CitationPaneStateful.js +188 -0
  65. package/lib/esm/components/citationpanestateful/common/defaultProps/defaultCitationPaneProps.js +61 -0
  66. package/lib/esm/components/confirmationpanestateful/interfaces/IConfirmationPaneLocalizedTexts.js +1 -0
  67. package/lib/esm/components/livechatwidget/LiveChatWidget.js +4 -4
  68. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/AddActivitySubscriber.js +120 -0
  69. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +4 -5
  70. package/lib/esm/components/livechatwidget/common/ChatWidgetEvents.js +8 -0
  71. package/lib/esm/components/livechatwidget/common/PersistentConversationHandler.js +277 -0
  72. package/lib/esm/components/livechatwidget/common/createAdapter.js +2 -0
  73. package/lib/esm/components/livechatwidget/common/defaultProps/defaultPersistentChatHistoryProps.js +11 -0
  74. package/lib/esm/components/livechatwidget/common/endChat.js +29 -4
  75. package/lib/esm/components/livechatwidget/common/getMockChatSDKIfApplicable.js +4 -3
  76. package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +8 -6
  77. package/lib/esm/components/livechatwidget/common/overridePropsOnMockIfApplicable.js +2 -1
  78. package/lib/esm/components/livechatwidget/common/startChat.js +5 -4
  79. package/lib/esm/components/livechatwidget/interfaces/IMockProps.js +3 -3
  80. package/lib/esm/components/livechatwidget/interfaces/IPersistentChatHistoryProps.js +1 -0
  81. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +29 -5
  82. package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +125 -12
  83. package/lib/esm/components/webchatcontainerstateful/common/DesignerChatAdapter.js +43 -14
  84. package/lib/esm/components/webchatcontainerstateful/common/DesignerChatSDK.js +6 -1
  85. package/lib/esm/components/webchatcontainerstateful/common/activities/botActivity.js +7 -0
  86. package/lib/esm/components/webchatcontainerstateful/common/activities/conversationDividerActivity.js +9 -0
  87. package/lib/esm/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.js +90 -0
  88. package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +2 -1
  89. package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultWebChatStatefulProps.js +2 -2
  90. package/lib/esm/components/webchatcontainerstateful/common/defaultStyles/defaultWebChatStyles.js +1 -1
  91. package/lib/esm/components/webchatcontainerstateful/common/utils/chatAdapterUtils.js +32 -0
  92. package/lib/esm/components/webchatcontainerstateful/common/utils/fontUtils.js +21 -0
  93. package/lib/esm/components/webchatcontainerstateful/hooks/usePersistentChatHistory.js +51 -0
  94. package/lib/esm/components/webchatcontainerstateful/interfaces/ICitation.js +1 -0
  95. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js +115 -0
  96. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/Constants.js +3 -0
  97. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/ConversationDividerActivity.js +10 -0
  98. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.js +1060 -0
  99. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LoadInlineBannerActivity.js +25 -0
  100. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +42 -0
  101. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +13 -0
  102. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultAvatarTextStyles.js +1 -1
  103. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultInLineBannerStyle.js +13 -0
  104. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageStyles.js +1 -1
  105. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +1 -1
  106. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/HistoryMessageTimestamp.js +52 -0
  107. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +2 -2
  108. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +1 -1
  109. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.js +98 -30
  110. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware.js +2 -2
  111. package/lib/esm/contexts/common/LiveChatWidgetActionType.js +46 -45
  112. package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +2 -0
  113. package/lib/esm/contexts/createReducer.js +15 -0
  114. package/lib/esm/index.js +1 -0
  115. package/lib/types/common/Constants.d.ts +5 -0
  116. package/lib/types/common/facades/FacadeChatSDK.d.ts +3 -1
  117. package/lib/types/common/telemetry/TelemetryConstants.d.ts +33 -2
  118. package/lib/types/common/utils/SecureEventBus.d.ts +159 -0
  119. package/lib/types/common/utils/dispatchCustomEvent.d.ts +2 -0
  120. package/lib/types/components/citationpanestateful/CitationDim.d.ts +5 -0
  121. package/lib/types/components/citationpanestateful/CitationPaneStateful.d.ts +4 -0
  122. package/lib/types/components/citationpanestateful/common/defaultProps/defaultCitationPaneProps.d.ts +11 -0
  123. package/lib/types/components/citationpanestateful/interfaces/ICitationPaneStatefulProps.d.ts +19 -0
  124. package/lib/types/components/confirmationpanestateful/common/defaultProps/defaultConfirmationPaneLocalizedTexts.d.ts +1 -1
  125. package/lib/types/components/confirmationpanestateful/interfaces/IConfirmationPaneStatefulProps.d.ts +1 -1
  126. package/lib/types/components/livechatwidget/common/ActivitySubscriber/AddActivitySubscriber.d.ts +45 -0
  127. package/lib/types/components/livechatwidget/common/ChatWidgetEvents.d.ts +7 -0
  128. package/lib/types/components/livechatwidget/common/PersistentConversationHandler.d.ts +28 -0
  129. package/lib/types/components/livechatwidget/common/defaultProps/defaultPersistentChatHistoryProps.d.ts +2 -0
  130. package/lib/types/components/livechatwidget/common/getMockChatSDKIfApplicable.d.ts +2 -1
  131. package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +5 -1
  132. package/lib/types/components/livechatwidget/interfaces/IMockProps.d.ts +5 -3
  133. package/lib/types/components/livechatwidget/interfaces/IPersistentChatHistoryProps.d.ts +7 -0
  134. package/lib/types/components/webchatcontainerstateful/common/DesignerChatAdapter.d.ts +4 -2
  135. package/lib/types/components/webchatcontainerstateful/common/DesignerChatSDK.d.ts +5 -0
  136. package/lib/types/components/webchatcontainerstateful/common/activities/botActivity.d.ts +7 -0
  137. package/lib/types/components/webchatcontainerstateful/common/activities/conversationDividerActivity.d.ts +10 -0
  138. package/lib/types/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.d.ts +2 -0
  139. package/lib/types/components/webchatcontainerstateful/common/utils/chatAdapterUtils.d.ts +6 -1
  140. package/lib/types/components/webchatcontainerstateful/common/utils/fontUtils.d.ts +10 -0
  141. package/lib/types/components/webchatcontainerstateful/hooks/usePersistentChatHistory.d.ts +4 -0
  142. package/lib/types/components/webchatcontainerstateful/interfaces/ICitation.d.ts +12 -0
  143. package/lib/types/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.d.ts +7 -0
  144. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/Constants.d.ts +3 -0
  145. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/ConversationDividerActivity.d.ts +4 -0
  146. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.d.ts +326 -0
  147. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LoadInlineBannerActivity.d.ts +8 -0
  148. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.d.ts +1 -0
  149. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultInLineBannerStyle.d.ts +2 -0
  150. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/HistoryMessageTimestamp.d.ts +2 -0
  151. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.d.ts +3 -4
  152. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware.d.ts +2 -2
  153. package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +1 -0
  154. package/lib/types/contexts/common/ILiveChatWidgetLocalizedTexts.d.ts +1 -0
  155. package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +46 -45
  156. package/lib/types/index.d.ts +1 -0
  157. package/package.json +3 -3
  158. /package/lib/cjs/components/{confirmationpanestateful/interfaces/IConfirmationPaneLocalizedText.js → citationpanestateful/interfaces/ICitationPaneStatefulProps.js} +0 -0
  159. /package/lib/esm/components/{confirmationpanestateful/interfaces/IConfirmationPaneLocalizedText.js → citationpanestateful/interfaces/ICitationPaneStatefulProps.js} +0 -0
  160. /package/lib/types/components/confirmationpanestateful/interfaces/{IConfirmationPaneLocalizedText.d.ts → IConfirmationPaneLocalizedTexts.d.ts} +0 -0
@@ -1,18 +1,19 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any */
2
-
3
1
  import { Constants, HtmlAttributeNames, HtmlClassNames } from "../../common/Constants";
4
2
  import { Stack } from "@fluentui/react";
5
3
  import { LogLevel, TelemetryEvent } from "../../common/telemetry/TelemetryConstants";
6
- import React, { useEffect } from "react";
4
+ import React, { useEffect, useRef, useState } from "react";
7
5
  import { createTimer, getDeviceType, setFocusOnSendBox } from "../../common/utils";
8
6
  import { BotMagicCodeStore } from "./webchatcontroller/BotMagicCodeStore";
7
+ import CitationPaneStateful from "../citationpanestateful/CitationPaneStateful";
9
8
  import { Components } from "botframework-webchat";
10
9
  import { LiveChatWidgetActionType } from "../../contexts/common/LiveChatWidgetActionType";
11
10
  import { NotificationHandler } from "./webchatcontroller/notification/NotificationHandler";
12
11
  import { NotificationScenarios } from "./webchatcontroller/enums/NotificationScenarios";
13
12
  import { TelemetryHelper } from "../../common/telemetry/TelemetryHelper";
14
13
  import { WebChatActionType } from "./webchatcontroller/enums/WebChatActionType";
14
+ import WebChatEventSubscribers from "./webchatcontroller/WebChatEventSubscribers";
15
15
  import { WebChatStoreLoader } from "./webchatcontroller/WebChatStoreLoader";
16
+ import { createIOSOptimizedEmojiFont } from "./common/utils/fontUtils";
16
17
  import { defaultAdaptiveCardStyles } from "./common/defaultStyles/defaultAdaptiveCardStyles";
17
18
  import { defaultMiddlewareLocalizedTexts } from "./common/defaultProps/defaultMiddlewareLocalizedTexts";
18
19
  import { defaultReceivedMessageAnchorStyles } from "./webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultReceivedMessageAnchorStyles";
@@ -20,9 +21,16 @@ import { defaultSentMessageAnchorStyles } from "./webchatcontroller/middlewares/
20
21
  import { defaultSystemMessageBoxStyles } from "./webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageBoxStyles";
21
22
  import { defaultUserMessageBoxStyles } from "./webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultUserMessageBoxStyles";
22
23
  import { defaultWebChatContainerStatefulProps } from "./common/defaultProps/defaultWebChatContainerStatefulProps";
24
+ import { isPersistentChatEnabled } from "../livechatwidget/common/liveChatConfigUtils";
23
25
  import { useChatContextStore } from "../..";
26
+ import useFacadeSDKStore from "../../hooks/useFacadeChatSDKStore";
27
+ import usePersistentChatHistory from "./hooks/usePersistentChatHistory";
28
+
29
+ // Types for better type safety
30
+
24
31
  let uiTimer;
25
32
  const broadcastChannelMessageEvent = "message";
33
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
26
34
  const postActivity = activity => {
27
35
  // eslint-disable-line @typescript-eslint/no-explicit-any
28
36
  return {
@@ -48,13 +56,29 @@ const createMagicCodeSuccessResponse = signin => {
48
56
  };
49
57
  };
50
58
  export const WebChatContainerStateful = props => {
51
- var _webChatContainerProp, _webChatContainerProp2, _webChatContainerProp3, _webChatContainerProp4, _webChatContainerProp5, _webChatContainerProp6, _webChatContainerProp7, _webChatContainerProp8, _props$webChatContain5, _props$webChatContain6, _defaultWebChatContai, _props$webChatContain7, _props$webChatContain8, _defaultWebChatContai2, _webChatContainerProp9, _webChatContainerProp10, _webChatContainerProp11, _webChatContainerProp12, _webChatContainerProp13, _webChatContainerProp14, _webChatContainerProp15, _webChatContainerProp16, _webChatContainerProp17, _webChatContainerProp18, _webChatContainerProp19, _webChatContainerProp20, _webChatContainerProp21, _webChatContainerProp22, _webChatContainerProp23, _props$webChatContain9, _props$webChatContain10;
59
+ var _props$webChatContain, _defaultWebChatContai, _extendedChatConfig$L, _props$persistentChat, _extendedChatConfig$L2, _extendedChatConfig$L3, _webChatContainerProp, _webChatContainerProp2, _webChatContainerProp3, _webChatContainerProp4, _webChatContainerProp5, _webChatContainerProp6, _webChatContainerProp7, _webChatContainerProp8, _props$webChatContain6, _props$webChatContain7, _defaultWebChatContai2, _props$webChatContain8, _props$webChatContain9, _defaultWebChatContai3, _webChatContainerProp9, _webChatContainerProp10, _webChatContainerProp11, _webChatContainerProp12, _webChatContainerProp13, _webChatContainerProp14, _webChatContainerProp15, _webChatContainerProp16, _webChatContainerProp17, _webChatContainerProp18, _webChatContainerProp19, _webChatContainerProp20, _webChatContainerProp21, _webChatContainerProp22, _webChatContainerProp23, _props$webChatContain10, _props$webChatContain11, _webChatContainerProp24, _webChatContainerProp25, _webChatContainerProp26, _webChatContainerProp27, _props$persistentChat2, _props$citationPanePr, _props$citationPanePr2, _props$citationPanePr3, _props$citationPanePr4, _props$citationPanePr5;
60
+ const [facadeChatSDK] = useFacadeSDKStore();
61
+
62
+ // Create a font family that includes emoji support, based on the primary font or default
63
+ const webChatStyles = ((_props$webChatContain = props.webChatContainerProps) === null || _props$webChatContain === void 0 ? void 0 : _props$webChatContain.webChatStyles) ?? defaultWebChatContainerStatefulProps.webChatStyles;
64
+ const primaryFont = (webChatStyles === null || webChatStyles === void 0 ? void 0 : webChatStyles.primaryFont) ?? ((_defaultWebChatContai = defaultWebChatContainerStatefulProps.webChatStyles) === null || _defaultWebChatContai === void 0 ? void 0 : _defaultWebChatContai.primaryFont);
65
+
66
+ // Use iOS-optimized emoji font that prioritizes system-ui for proper emoji rendering
67
+ const fontFamilyWithEmojis = createIOSOptimizedEmojiFont(primaryFont);
52
68
  useEffect(() => {
53
69
  uiTimer = createTimer();
54
70
  TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
55
71
  Event: TelemetryEvent.UXWebchatContainerCompleted
56
72
  });
57
73
  }, []);
74
+
75
+ // Citation pane state
76
+ const [citationPaneOpen, setCitationPaneOpen] = useState(false);
77
+ const [citationPaneText, setCitationPaneText] = useState("");
78
+
79
+ // Guard to prevent handling multiple rapid clicks which could cause
80
+ // the dim layer and pane to re-render out of sync and create a flicker.
81
+ const citationOpeningRef = useRef(false);
58
82
  const {
59
83
  BasicWebChat
60
84
  } = Components;
@@ -63,6 +87,68 @@ export const WebChatContainerStateful = props => {
63
87
  webChatContainerProps,
64
88
  contextDataStore
65
89
  } = props;
90
+
91
+ // Type the chatConfig properly to avoid 'any' usage
92
+ const extendedChatConfig = props.chatConfig;
93
+ const isHistoryEnabledInConfig = extendedChatConfig === null || extendedChatConfig === void 0 ? void 0 : (_extendedChatConfig$L = extendedChatConfig.LcwFcbConfiguration) === null || _extendedChatConfig$L === void 0 ? void 0 : _extendedChatConfig$L.lcwPersistentChatHistoryEnabled;
94
+ const isHistoryEnabledViaProps = props === null || props === void 0 ? void 0 : (_props$persistentChat = props.persistentChatHistoryProps) === null || _props$persistentChat === void 0 ? void 0 : _props$persistentChat.persistentChatHistoryEnabled;
95
+ const isPersistentChatEnabledForWidget = !!(extendedChatConfig !== null && extendedChatConfig !== void 0 && (_extendedChatConfig$L2 = extendedChatConfig.LiveChatConfigAuthSettings) !== null && _extendedChatConfig$L2 !== void 0 && _extendedChatConfig$L2.msdyn_javascriptclientfunction) || isPersistentChatEnabled(extendedChatConfig === null || extendedChatConfig === void 0 ? void 0 : (_extendedChatConfig$L3 = extendedChatConfig.LiveWSAndLiveChatEngJoin) === null || _extendedChatConfig$L3 === void 0 ? void 0 : _extendedChatConfig$L3.msdyn_conversationmode);
96
+
97
+ // Persistent chat history is enabled if explicitly set via props, or if enabled in config
98
+ // Props take precedence over config settings
99
+ const isPersistentHistoryEnabled = isHistoryEnabledViaProps || isHistoryEnabledInConfig;
100
+
101
+ // Check if both persistent chat and widget support are enabled
102
+ const shouldLoadPersistentHistoryMessages = isPersistentHistoryEnabled && isPersistentChatEnabledForWidget;
103
+ if (shouldLoadPersistentHistoryMessages) {
104
+ usePersistentChatHistory(facadeChatSDK, (props === null || props === void 0 ? void 0 : props.persistentChatHistoryProps) ?? {});
105
+ }
106
+ // Delegated click handler for citation anchors. Placed after state is
107
+ // available so we can prefer reading citations from app state and fall
108
+ // back to the legacy window map for backward-compatibility in tests.
109
+ useEffect(() => {
110
+ const clickHandler = ev => {
111
+ try {
112
+ if (citationOpeningRef.current) {
113
+ return;
114
+ }
115
+ const target = ev.target;
116
+ // Only consider anchors whose href starts with the citation scheme
117
+ const anchor = target.closest && target.closest("a[href^=\"cite:\"]");
118
+ if (anchor) {
119
+ ev.preventDefault();
120
+ citationOpeningRef.current = true;
121
+ // Rely only on the href to identify the citation key
122
+ let text = "";
123
+ try {
124
+ var _state$domainStates;
125
+ const cid = anchor.getAttribute("href");
126
+ // Prefer state-based citations injected by middleware
127
+ if (state !== null && state !== void 0 && (_state$domainStates = state.domainStates) !== null && _state$domainStates !== void 0 && _state$domainStates.citations && cid) {
128
+ text = state.domainStates.citations[cid] ?? "";
129
+ }
130
+ // If state lookup failed, fall back to the anchor's title or innerText
131
+ if (!text) {
132
+ text = anchor.getAttribute("title") || anchor.innerText || "";
133
+ }
134
+ } catch (e) {
135
+ // ignore
136
+ }
137
+ setCitationPaneOpen(true);
138
+ setCitationPaneText(text);
139
+
140
+ // Simple debounce - reset guard after a short delay
141
+ setTimeout(() => {
142
+ citationOpeningRef.current = false;
143
+ }, 100);
144
+ }
145
+ } catch (e) {
146
+ citationOpeningRef.current = false;
147
+ }
148
+ };
149
+ document.addEventListener("click", clickHandler);
150
+ return () => document.removeEventListener("click", clickHandler);
151
+ }, [state]);
66
152
  const containerStyles = {
67
153
  root: Object.assign({}, defaultWebChatContainerStatefulProps.containerStyles, webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : webChatContainerProps.containerStyles, {
68
154
  display: state.appStates.isMinimized ? "none" : ""
@@ -74,7 +160,7 @@ export const WebChatContainerStateful = props => {
74
160
  ...(webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : webChatContainerProps.localizedTexts)
75
161
  };
76
162
  useEffect(() => {
77
- var _props$webChatContain, _props$webChatContain2;
163
+ var _props$webChatContain2, _props$webChatContain3;
78
164
  if (getDeviceType() !== "standard" && (webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : webChatContainerProps.webChatHistoryMobileAccessibilityLabel) !== undefined) {
79
165
  const chatHistoryElement = document.querySelector(`.${HtmlClassNames.webChatHistoryContainer}`);
80
166
  if (chatHistoryElement) {
@@ -92,21 +178,23 @@ export const WebChatContainerStateful = props => {
92
178
  TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
93
179
  Event: TelemetryEvent.WebChatLoaded
94
180
  });
95
- if (((_props$webChatContain = props.webChatContainerProps) === null || _props$webChatContain === void 0 ? void 0 : (_props$webChatContain2 = _props$webChatContain.renderingMiddlewareProps) === null || _props$webChatContain2 === void 0 ? void 0 : _props$webChatContain2.disableThirdPartyCookiesAlert) !== true && !contextDataStore) {
181
+ if (((_props$webChatContain2 = props.webChatContainerProps) === null || _props$webChatContain2 === void 0 ? void 0 : (_props$webChatContain3 = _props$webChatContain2.renderingMiddlewareProps) === null || _props$webChatContain3 === void 0 ? void 0 : _props$webChatContain3.disableThirdPartyCookiesAlert) !== true && !contextDataStore) {
96
182
  try {
97
183
  localStorage;
98
184
  sessionStorage;
99
185
  } catch (error) {
186
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
100
187
  if (!window.TPCWarningShown) {
101
188
  NotificationHandler.notifyWarning(NotificationScenarios.TPC, (localizedTexts === null || localizedTexts === void 0 ? void 0 : localizedTexts.THIRD_PARTY_COOKIES_BLOCKED_ALERT_MESSAGE) ?? "");
189
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
102
190
  window.TPCWarningShown = true;
103
191
  }
104
192
  }
105
193
  }
106
194
  }, []);
107
195
  useEffect(() => {
108
- var _props$webChatContain3, _props$webChatContain4;
109
- if (!((_props$webChatContain3 = props.webChatContainerProps) !== null && _props$webChatContain3 !== void 0 && (_props$webChatContain4 = _props$webChatContain3.botMagicCode) !== null && _props$webChatContain4 !== void 0 && _props$webChatContain4.disabled)) {
196
+ var _props$webChatContain4, _props$webChatContain5;
197
+ if (!((_props$webChatContain4 = props.webChatContainerProps) !== null && _props$webChatContain4 !== void 0 && (_props$webChatContain5 = _props$webChatContain4.botMagicCode) !== null && _props$webChatContain5 !== void 0 && _props$webChatContain5.disabled)) {
110
198
  return;
111
199
  }
112
200
  if (!window.BroadcastChannel) {
@@ -198,8 +286,8 @@ export const WebChatContainerStateful = props => {
198
286
  }
199
287
 
200
288
  .ms_lcw_webchat_received_message>div.webchat__stacked-layout>div.webchat__stacked-layout__main>div.webchat__stacked-layout__content>div.webchat__stacked-layout__message-row>[class^=webchat]:not(.webchat__bubble--from-user)>.webchat__bubble__content {
201
- background-color: ${((_props$webChatContain5 = props.webChatContainerProps) === null || _props$webChatContain5 === void 0 ? void 0 : (_props$webChatContain6 = _props$webChatContain5.webChatStyles) === null || _props$webChatContain6 === void 0 ? void 0 : _props$webChatContain6.bubbleBackground) ?? ((_defaultWebChatContai = defaultWebChatContainerStatefulProps.webChatStyles) === null || _defaultWebChatContai === void 0 ? void 0 : _defaultWebChatContai.bubbleBackground)};
202
- color:${((_props$webChatContain7 = props.webChatContainerProps) === null || _props$webChatContain7 === void 0 ? void 0 : (_props$webChatContain8 = _props$webChatContain7.webChatStyles) === null || _props$webChatContain8 === void 0 ? void 0 : _props$webChatContain8.bubbleTextColor) ?? ((_defaultWebChatContai2 = defaultWebChatContainerStatefulProps.webChatStyles) === null || _defaultWebChatContai2 === void 0 ? void 0 : _defaultWebChatContai2.bubbleTextColor)};
289
+ background-color: ${((_props$webChatContain6 = props.webChatContainerProps) === null || _props$webChatContain6 === void 0 ? void 0 : (_props$webChatContain7 = _props$webChatContain6.webChatStyles) === null || _props$webChatContain7 === void 0 ? void 0 : _props$webChatContain7.bubbleBackground) ?? ((_defaultWebChatContai2 = defaultWebChatContainerStatefulProps.webChatStyles) === null || _defaultWebChatContai2 === void 0 ? void 0 : _defaultWebChatContai2.bubbleBackground)};
290
+ color:${((_props$webChatContain8 = props.webChatContainerProps) === null || _props$webChatContain8 === void 0 ? void 0 : (_props$webChatContain9 = _props$webChatContain8.webChatStyles) === null || _props$webChatContain9 === void 0 ? void 0 : _props$webChatContain9.bubbleTextColor) ?? ((_defaultWebChatContai3 = defaultWebChatContainerStatefulProps.webChatStyles) === null || _defaultWebChatContai3 === void 0 ? void 0 : _defaultWebChatContai3.bubbleTextColor)};
203
291
  }
204
292
 
205
293
  div[class="ac-textBlock"] a:link,
@@ -277,7 +365,7 @@ export const WebChatContainerStateful = props => {
277
365
  }
278
366
 
279
367
  .webchat__stacked-layout_container>div {
280
- background: ${(props === null || props === void 0 ? void 0 : (_props$webChatContain9 = props.webChatContainerProps) === null || _props$webChatContain9 === void 0 ? void 0 : (_props$webChatContain10 = _props$webChatContain9.containerStyles) === null || _props$webChatContain10 === void 0 ? void 0 : _props$webChatContain10.background) ?? ""}
368
+ background: ${(props === null || props === void 0 ? void 0 : (_props$webChatContain10 = props.webChatContainerProps) === null || _props$webChatContain10 === void 0 ? void 0 : (_props$webChatContain11 = _props$webChatContain10.containerStyles) === null || _props$webChatContain11 === void 0 ? void 0 : _props$webChatContain11.background) ?? ""}
281
369
  }
282
370
  .webchat__toast_text {
283
371
  display: flex;
@@ -304,9 +392,34 @@ export const WebChatContainerStateful = props => {
304
392
  height: 100% !important;
305
393
  }
306
394
 
395
+ .webchat__auto-resize-textarea__textarea.webchat__send-box-text-box__html-text-area {
396
+ font-family: ${fontFamilyWithEmojis} !important;
397
+ }
398
+
399
+ /* Suggested actions carousel previous/next navigation focus */
400
+ .webchat__suggested-actions .webchat__suggested-actions__carousel .react-film__flipper:focus-visible .react-film__flipper__body {
401
+ outline: ${(webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : (_webChatContainerProp24 = webChatContainerProps.webChatStyles) === null || _webChatContainerProp24 === void 0 ? void 0 : _webChatContainerProp24.suggestedActionKeyboardFocusIndicatorBorderStyle) ?? "dashed"} ${(webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : (_webChatContainerProp25 = webChatContainerProps.webChatStyles) === null || _webChatContainerProp25 === void 0 ? void 0 : _webChatContainerProp25.suggestedActionKeyboardFocusIndicatorBorderWidth) ?? "1px"} ${(webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : (_webChatContainerProp26 = webChatContainerProps.webChatStyles) === null || _webChatContainerProp26 === void 0 ? void 0 : _webChatContainerProp26.suggestedActionKeyboardFocusIndicatorBorderColor) ?? "#605E5C"} !important;
402
+ outline-offset: ${(webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : (_webChatContainerProp27 = webChatContainerProps.webChatStyles) === null || _webChatContainerProp27 === void 0 ? void 0 : _webChatContainerProp27.suggestedActionKeyboardFocusIndicatorInset) ?? "2px"} !important;
403
+
307
404
  `), /*#__PURE__*/React.createElement(Stack, {
308
405
  styles: containerStyles,
309
406
  className: "webchat__stacked-layout_container"
310
- }, /*#__PURE__*/React.createElement(BasicWebChat, null)));
407
+ }, /*#__PURE__*/React.createElement("div", {
408
+ id: "ms_lcw_webchat_root",
409
+ style: {
410
+ height: "100%",
411
+ width: "100%"
412
+ }
413
+ }, shouldLoadPersistentHistoryMessages && /*#__PURE__*/React.createElement(WebChatEventSubscribers, {
414
+ persistentChatHistoryEnabled: props === null || props === void 0 ? void 0 : (_props$persistentChat2 = props.persistentChatHistoryProps) === null || _props$persistentChat2 === void 0 ? void 0 : _props$persistentChat2.persistentChatHistoryEnabled
415
+ }), /*#__PURE__*/React.createElement(BasicWebChat, null))), citationPaneOpen && /*#__PURE__*/React.createElement(CitationPaneStateful, {
416
+ id: ((_props$citationPanePr = props.citationPaneProps) === null || _props$citationPanePr === void 0 ? void 0 : _props$citationPanePr.id) || HtmlAttributeNames.ocwCitationPaneClassName,
417
+ title: ((_props$citationPanePr2 = props.citationPaneProps) === null || _props$citationPanePr2 === void 0 ? void 0 : _props$citationPanePr2.title) || HtmlAttributeNames.ocwCitationPaneTitle,
418
+ contentHtml: citationPaneText,
419
+ onClose: () => setCitationPaneOpen(false),
420
+ componentOverrides: (_props$citationPanePr3 = props.citationPaneProps) === null || _props$citationPanePr3 === void 0 ? void 0 : _props$citationPanePr3.componentOverrides,
421
+ controlProps: (_props$citationPanePr4 = props.citationPaneProps) === null || _props$citationPanePr4 === void 0 ? void 0 : _props$citationPanePr4.controlProps,
422
+ styleProps: (_props$citationPanePr5 = props.citationPaneProps) === null || _props$citationPanePr5 === void 0 ? void 0 : _props$citationPanePr5.styleProps
423
+ }));
311
424
  };
312
425
  export default WebChatContainerStateful;
@@ -1,8 +1,6 @@
1
1
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2
2
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
3
3
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
4
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
5
- function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
6
4
  function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
7
5
  function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
8
6
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
@@ -10,28 +8,59 @@ function _possibleConstructorReturn(self, call) { if (call && (typeof call === "
10
8
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
11
9
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
12
10
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
13
- import { Observable } from "rxjs/Observable";
11
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
12
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
13
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
14
+ import { customerUser, postAgentAttachmentActivity, postAgentMessageActivity, postAgentSuggestedActionsActivity, postBotMessageActivity, postEchoActivity, postSystemMessageActivity } from "./utils/chatAdapterUtils";
14
15
  import MockAdapter from "./mockadapter";
15
- import { customerUser, postAgentMessageActivity, postBotMessageActivity, postEchoActivity, postSystemMessageActivity } from "./utils/chatAdapterUtils";
16
+ import { Observable } from "rxjs/Observable";
16
17
  export let DesignerChatAdapter = /*#__PURE__*/function (_MockAdapter) {
17
18
  _inherits(DesignerChatAdapter, _MockAdapter);
18
19
  var _super = _createSuper(DesignerChatAdapter);
19
- function DesignerChatAdapter() {
20
+ function DesignerChatAdapter(messages) {
20
21
  var _this;
21
22
  _classCallCheck(this, DesignerChatAdapter);
22
23
  _this = _super.call(this);
23
- setTimeout(() => {
24
- postBotMessageActivity(_this.activityObserver, "Thank you for contacting us! How can I help you today?", undefined, 0);
25
- postBotMessageActivity(_this.activityObserver, "Please accept terms and conditions to proceed. Visit the link for terms and conditions <a href=\"\">here</a>.", undefined, 0);
26
- _this.postUserActivity("I need to change my address.", 0);
27
- postBotMessageActivity(_this.activityObserver, "Okay, let me connect you with a live agent.", undefined, 100);
28
- postSystemMessageActivity(_this.activityObserver, "John has joined the chat", 100);
29
- postAgentMessageActivity(_this.activityObserver, "I'd be happy to help you update your account.", undefined, 100);
30
- _this.postUserActivity("I have trouble visiting the signin page <a href=\"\">signin</a>.", 0);
31
- }, 1000);
24
+ _defineProperty(_assertThisInitialized(_this), "messages", void 0);
25
+ _this.messages = messages;
26
+ if (_this.messages) {
27
+ if (_this.messages.length > 0) {
28
+ setTimeout(() => {
29
+ var _this$messages;
30
+ (_this$messages = _this.messages) === null || _this$messages === void 0 ? void 0 : _this$messages.forEach((msg, index) => {
31
+ _this.processMessage(msg, index);
32
+ });
33
+ }, 1000); // Initial 1 second delay to ensure activityObserver is ready
34
+ }
35
+ } else {
36
+ // Default hardcoded flow
37
+ setTimeout(() => {
38
+ postBotMessageActivity(_this.activityObserver, "Thank you for contacting us! How can I help you today?", undefined, 0);
39
+ postBotMessageActivity(_this.activityObserver, "Please accept terms and conditions to proceed. Visit the link for terms and conditions <a href=\"\">here</a>.", undefined, 0);
40
+ _this.postUserActivity("I need to change my address.", 0);
41
+ postBotMessageActivity(_this.activityObserver, "Okay, let me connect you with a live agent.", undefined, 100);
42
+ postSystemMessageActivity(_this.activityObserver, "John has joined the chat", 100);
43
+ postAgentMessageActivity(_this.activityObserver, "I'd be happy to help you update your account.", undefined, 100);
44
+ _this.postUserActivity("I have trouble visiting the signin page <a href=\"\">signin</a>.", 0);
45
+ }, 1000);
46
+ }
32
47
  return _this;
33
48
  }
34
49
  _createClass(DesignerChatAdapter, [{
50
+ key: "processMessage",
51
+ value: function processMessage(msg, index) {
52
+ if (msg.text) {
53
+ if (msg.suggestedActions) {
54
+ postAgentSuggestedActionsActivity(this.activityObserver, msg.text, msg.suggestedActions, index * 100);
55
+ } else {
56
+ postBotMessageActivity(this.activityObserver, msg.text, undefined, index * 100);
57
+ }
58
+ }
59
+ if (msg.attachments && msg.attachments.length > 0) {
60
+ postAgentAttachmentActivity(this.activityObserver, msg.attachments, index * 100, msg.attachmentLayout);
61
+ }
62
+ }
63
+ }, {
35
64
  key: "postUserActivity",
36
65
  value: function postUserActivity(text) {
37
66
  let delay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1000;
@@ -20,13 +20,18 @@ export let DesignerChatSDK = /*#__PURE__*/function (_MockChatSDK) {
20
20
  var _this;
21
21
  _classCallCheck(this, DesignerChatSDK);
22
22
  _this = _super.call(this);
23
+ /**
24
+ * Create a chat adapter for the designer. Uses this.mockMessages if set.
25
+ */
26
+ _defineProperty(_assertThisInitialized(_this), "mockMessages", void 0);
23
27
  _defineProperty(_assertThisInitialized(_this), "localeId", _this.getLiveChatConfig().ChatWidgetLanguage.msdyn_localeid);
24
28
  return _this;
25
29
  }
26
30
  _createClass(DesignerChatSDK, [{
27
31
  key: "createChatAdapter",
28
32
  value: function createChatAdapter() {
29
- return new DesignerChatAdapter();
33
+ const adapter = new DesignerChatAdapter(this.mockMessages);
34
+ return adapter;
30
35
  }
31
36
  }, {
32
37
  key: "getLiveChatConfig",
@@ -0,0 +1,7 @@
1
+ const botActivity = {
2
+ from: {
3
+ role: "bot"
4
+ },
5
+ type: "message"
6
+ };
7
+ export default botActivity;
@@ -0,0 +1,9 @@
1
+ import { Constants } from "../../../../common/Constants";
2
+ import botActivity from "./botActivity";
3
+ const conversationDividerActivity = {
4
+ ...botActivity,
5
+ channelData: {
6
+ tags: [Constants.conversationDividerTag]
7
+ }
8
+ };
9
+ export default conversationDividerActivity;
@@ -0,0 +1,90 @@
1
+ import { Constants } from "../../../../common/Constants";
2
+ import botActivity from "../activities/botActivity";
3
+
4
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
5
+ const convertStringValueToInt = value => {
6
+ if (typeof value !== "string" || value === "") {
7
+ return undefined;
8
+ }
9
+ let result;
10
+ try {
11
+ result = parseInt(value);
12
+ } catch (e) {
13
+ return undefined;
14
+ }
15
+ return isNaN(result) ? undefined : result;
16
+ };
17
+
18
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
19
+ const convertPersistentChatHistoryMessageToActivity = message => {
20
+ var _from$user, _from$application;
21
+ const {
22
+ additionalData,
23
+ attachments,
24
+ content,
25
+ created,
26
+ from,
27
+ transcriptOriginalMessageId
28
+ } = message;
29
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
30
+ const activity = {
31
+ ...botActivity,
32
+ channelData: {
33
+ tags: [Constants.persistentChatHistoryMessageTag]
34
+ }
35
+ };
36
+ let webchatSequenceId;
37
+ let timestamp;
38
+ if (transcriptOriginalMessageId) {
39
+ const id = convertStringValueToInt(transcriptOriginalMessageId); // Id used to determine the sequence of messages which is the same as the 'live' messages
40
+ if (id) {
41
+ webchatSequenceId = id;
42
+ timestamp = new Date(id) || created;
43
+ activity.channelData = {
44
+ ...activity.channelData,
45
+ "webchat:sequence-id": webchatSequenceId
46
+ };
47
+ }
48
+ }
49
+ if (additionalData !== null && additionalData !== void 0 && additionalData.tags) {
50
+ const {
51
+ tags,
52
+ ConversationId
53
+ } = additionalData;
54
+ if (ConversationId) {
55
+ activity.channelData.conversationId = ConversationId;
56
+ }
57
+ if (tags) {
58
+ const formattedTags = additionalData.tags.split(",");
59
+ activity.channelData.tags = [...activity.channelData.tags, ...formattedTags];
60
+ }
61
+ }
62
+ if (from !== null && from !== void 0 && (_from$user = from.user) !== null && _from$user !== void 0 && _from$user.displayName) {
63
+ activity.from.name = from.user.displayName;
64
+ }
65
+ if ((from === null || from === void 0 ? void 0 : (_from$application = from.application) === null || _from$application === void 0 ? void 0 : _from$application.displayName) === "Customer") {
66
+ activity.from = {
67
+ role: "user",
68
+ name: from.application.displayName
69
+ };
70
+ }
71
+ if (content) {
72
+ return {
73
+ ...activity,
74
+ text: content,
75
+ timestamp
76
+ };
77
+ }
78
+ if (attachments && attachments.length > 0) {
79
+ const fileName = attachments[0].name || "Unknown";
80
+ const text = `The following attachment was uploaded during the conversation: ${fileName}`;
81
+ return {
82
+ ...activity,
83
+ text,
84
+ timestamp
85
+ };
86
+ }
87
+ // If neither content nor attachments are present, return null to indicate no activity could be created.
88
+ return null;
89
+ };
90
+ export default convertPersistentChatHistoryMessageToActivity;
@@ -28,5 +28,6 @@ export const defaultMiddlewareLocalizedTexts = {
28
28
  THIRD_PARTY_COOKIES_BLOCKED_ALERT_MESSAGE: "Allow sites to save/read cookies in browser settings. Reloading page starts a new chat.",
29
29
  MIDDLEWARE_BANNER_FILE_IS_MALICIOUS: "{0} has been blocked because the file may contain a malware.",
30
30
  MIDDLEWARE_BANNER_FILE_EMAIL_ADDRESS_RECORDED_SUCCESS: "Email will be sent after chat ends!",
31
- MIDDLEWARE_BANNER_FILE_EMAIL_ADDRESS_RECORDED_ERROR: "Email {0} could not be saved, try again later."
31
+ MIDDLEWARE_BANNER_FILE_EMAIL_ADDRESS_RECORDED_ERROR: "Email {0} could not be saved, try again later.",
32
+ PREVIOUS_MESSAGES_LOADING: "Loading previous messages..."
32
33
  };
@@ -1,9 +1,9 @@
1
- import { activityStatusMiddleware } from "../../webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware";
1
+ import { createActivityStatusMiddleware } from "../../webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware";
2
2
  import { groupActivitiesMiddleware } from "../../webchatcontroller/middlewares/renderingmiddlewares/groupActivitiesMiddleware";
3
3
  import { typingIndicatorMiddleware } from "../../webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware";
4
4
  export const defaultWebChatStatefulProps = {
5
5
  // activityMiddleware: activityMiddleware, - this is implemented elsewhere and can be customized
6
- activityStatusMiddleware: activityStatusMiddleware,
6
+ activityStatusMiddleware: createActivityStatusMiddleware(),
7
7
  // avatarMiddleware: avatarMiddleware, - this is implemented elsewhere and can be customized
8
8
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
9
9
  groupActivitiesMiddleware: groupActivitiesMiddleware,
@@ -17,7 +17,7 @@ export const defaultWebChatStyles = {
17
17
  bubbleTextColor: "White",
18
18
  hideSendBox: false,
19
19
  hideUploadButton: true,
20
- primaryFont: "Segoe UI, Arial, sans-serif",
20
+ primaryFont: "Segoe UI, Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Noto Color Emoji\"",
21
21
  rootHeight: "100%",
22
22
  rootWidth: "100%",
23
23
  sendBoxTextWrap: true,
@@ -97,4 +97,36 @@ export const postBotAttachmentActivity = function (activityObserver) {
97
97
  timestamp: new Date().toISOString()
98
98
  });
99
99
  }, delay);
100
+ };
101
+ export const postAgentAttachmentActivity = function (activityObserver) {
102
+ let attachments = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
103
+ let delay = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1000;
104
+ let attachmentLayout = arguments.length > 3 ? arguments[3] : undefined;
105
+ setTimeout(() => {
106
+ activityObserver === null || activityObserver === void 0 ? void 0 : activityObserver.next({
107
+ id: uuidv4(),
108
+ from: {
109
+ ...agentUser
110
+ },
111
+ attachments,
112
+ attachmentLayout,
113
+ type: "message",
114
+ timestamp: new Date().toISOString()
115
+ });
116
+ }, delay);
117
+ };
118
+ export const postAgentSuggestedActionsActivity = function (activityObserver, text, suggestedActions) {
119
+ let delay = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1000;
120
+ setTimeout(() => {
121
+ activityObserver === null || activityObserver === void 0 ? void 0 : activityObserver.next({
122
+ id: uuidv4(),
123
+ from: {
124
+ ...agentUser
125
+ },
126
+ text,
127
+ type: "message",
128
+ suggestedActions,
129
+ timestamp: new Date().toISOString()
130
+ });
131
+ }, delay);
100
132
  };
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Utility functions for font handling and emoji support
3
+ */
4
+
5
+ /**
6
+ * Creates a font family optimized for iOS emoji support
7
+ * Uses system-ui as the primary font for better emoji rendering on iOS
8
+ * @param primaryFont - The base font family string (optional, used as fallback)
9
+ * @returns Font family string optimized for iOS emoji support
10
+ */
11
+ export const createIOSOptimizedEmojiFont = primaryFont => {
12
+ // For iOS emoji support, system-ui should be first
13
+ const baseFont = "system-ui";
14
+ const emojiSupport = "\"Apple Color Emoji\", \"Segoe UI Emoji\"";
15
+ if (!primaryFont || primaryFont.includes("system-ui") || primaryFont.includes("Apple Color Emoji")) {
16
+ return `${baseFont}, ${emojiSupport}`;
17
+ }
18
+
19
+ // Add configured font as fallback after emoji fonts
20
+ return `${baseFont}, ${emojiSupport}, ${primaryFont}`;
21
+ };
@@ -0,0 +1,51 @@
1
+ import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
2
+ import { useEffect, useRef } from "react";
3
+ import ChatWidgetEvents from "../../livechatwidget/common/ChatWidgetEvents";
4
+ import PersistentConversationHandler from "../../livechatwidget/common/PersistentConversationHandler";
5
+ import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
6
+ import dispatchCustomEvent from "../../../common/utils/dispatchCustomEvent";
7
+ import SecureEventBus from "../../../common/utils/SecureEventBus";
8
+ const usePersistentChatHistory = (facadeChatSDK, props) => {
9
+ const handlerRef = useRef(null);
10
+ useEffect(() => {
11
+ if (!facadeChatSDK) {
12
+ return;
13
+ }
14
+ TelemetryHelper.logLoadingEventToAllTelemetry(LogLevel.INFO, {
15
+ Event: TelemetryEvent.UXLCWPersistentChatHistoryInitialized,
16
+ Description: "Persistent chat history hook initialized"
17
+ });
18
+ handlerRef.current = new PersistentConversationHandler(facadeChatSDK, props);
19
+ const handler = async () => {
20
+ TelemetryHelper.logActionEventToAllTelemetry(LogLevel.INFO, {
21
+ Event: TelemetryEvent.LCWPersistentChatHistoryFetchStarted,
22
+ Description: "Persistent chat history fetch started"
23
+ });
24
+ try {
25
+ var _handlerRef$current;
26
+ await ((_handlerRef$current = handlerRef.current) === null || _handlerRef$current === void 0 ? void 0 : _handlerRef$current.pullHistory());
27
+ dispatchCustomEvent(ChatWidgetEvents.HIDE_LOADING_BANNER);
28
+ TelemetryHelper.logActionEventToAllTelemetry(LogLevel.INFO, {
29
+ Event: TelemetryEvent.LCWPersistentChatHistoryFetchCompleted,
30
+ Description: "Persistent chat history fetch completed successfully"
31
+ });
32
+ } catch (error) {
33
+ TelemetryHelper.logActionEventToAllTelemetry(LogLevel.ERROR, {
34
+ Event: TelemetryEvent.LCWPersistentChatHistoryFetchFailed,
35
+ Description: "Persistent chat history fetch failed",
36
+ ExceptionDetails: error
37
+ });
38
+ }
39
+ };
40
+
41
+ // Subscribe to the secure event bus instead of global window events
42
+ const eventBus = SecureEventBus.getInstance();
43
+ const unsubscribe = eventBus.subscribe(ChatWidgetEvents.FETCH_PERSISTENT_CHAT_HISTORY, handler);
44
+ return () => {
45
+ var _handlerRef$current2;
46
+ unsubscribe();
47
+ (_handlerRef$current2 = handlerRef.current) === null || _handlerRef$current2 === void 0 ? void 0 : _handlerRef$current2.destroy(); // Call destroy instead of reset to properly clean up
48
+ };
49
+ }, [facadeChatSDK]);
50
+ };
51
+ export default usePersistentChatHistory;