@microsoft/omnichannel-chat-widget 0.1.0-main.47ede4d → 0.1.0-main.5063558

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 (138) hide show
  1. package/README.md +32 -0
  2. package/lib/cjs/common/Constants.js +50 -6
  3. package/lib/cjs/common/telemetry/TelemetryConstants.js +38 -3
  4. package/lib/cjs/common/telemetry/TelemetryHelper.js +13 -0
  5. package/lib/cjs/common/telemetry/TelemetryManager.js +10 -1
  6. package/lib/cjs/common/telemetry/defaultConfigs/defaultTelemetryConfiguration.js +4 -1
  7. package/lib/cjs/common/telemetry/loggers/ariaTelemetryLogger.js +33 -13
  8. package/lib/cjs/common/telemetry/loggers/consoleLogger.js +6 -5
  9. package/lib/cjs/common/utils.js +89 -2
  10. package/lib/cjs/components/callingcontainerstateful/CallingContainerStateful.js +14 -0
  11. package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +20 -4
  12. package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +4 -40
  13. package/lib/cjs/components/footerstateful/FooterStateful.js +1 -2
  14. package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +11 -2
  15. package/lib/cjs/components/headerstateful/HeaderStateful.js +5 -10
  16. package/lib/cjs/components/livechatwidget/common/ActivityStreamHandler.js +44 -0
  17. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +23 -0
  18. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.js +1 -0
  19. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +39 -0
  20. package/lib/cjs/components/livechatwidget/common/ChatAdapterShim.js +70 -0
  21. package/lib/cjs/components/livechatwidget/common/Deferred.js +42 -0
  22. package/lib/cjs/components/livechatwidget/common/authHelper.js +52 -0
  23. package/lib/cjs/components/livechatwidget/common/createAdapter.js +13 -1
  24. package/lib/cjs/components/livechatwidget/common/createMarkdown.js +31 -30
  25. package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +14 -17
  26. package/lib/cjs/components/livechatwidget/common/endChat.js +93 -10
  27. package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +27 -3
  28. package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +144 -39
  29. package/lib/cjs/components/livechatwidget/common/registerTelemetryLoggers.js +3 -15
  30. package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +0 -4
  31. package/lib/cjs/components/livechatwidget/common/shareObservable.js +45 -0
  32. package/lib/cjs/components/livechatwidget/common/startChat.js +157 -50
  33. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +272 -72
  34. package/lib/cjs/components/postchatloadingpanestateful/PostChatLoadingPaneStateful.js +8 -0
  35. package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +5 -10
  36. package/lib/cjs/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +17 -1
  37. package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +80 -0
  38. package/lib/cjs/components/webchatcontainerstateful/common/mockchatsdk.js +2 -0
  39. package/lib/cjs/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.js +1 -0
  40. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +14 -0
  41. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +16 -2
  42. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.js +52 -0
  43. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.js +98 -0
  44. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.js +117 -0
  45. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +45 -0
  46. package/lib/cjs/contexts/common/ConversationState.js +3 -2
  47. package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +10 -7
  48. package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +4 -2
  49. package/lib/cjs/contexts/createReducer.js +24 -7
  50. package/lib/cjs/controller/componentController.js +3 -3
  51. package/lib/cjs/plugins/newMessageEventHandler.js +10 -13
  52. package/lib/esm/common/Constants.js +46 -5
  53. package/lib/esm/common/telemetry/TelemetryConstants.js +38 -3
  54. package/lib/esm/common/telemetry/TelemetryHelper.js +13 -1
  55. package/lib/esm/common/telemetry/TelemetryManager.js +9 -1
  56. package/lib/esm/common/telemetry/defaultConfigs/defaultTelemetryConfiguration.js +4 -1
  57. package/lib/esm/common/telemetry/loggers/ariaTelemetryLogger.js +36 -14
  58. package/lib/esm/common/telemetry/loggers/consoleLogger.js +6 -5
  59. package/lib/esm/common/utils.js +64 -1
  60. package/lib/esm/components/callingcontainerstateful/CallingContainerStateful.js +14 -0
  61. package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +22 -7
  62. package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +7 -38
  63. package/lib/esm/components/footerstateful/FooterStateful.js +1 -2
  64. package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +9 -3
  65. package/lib/esm/components/headerstateful/HeaderStateful.js +5 -10
  66. package/lib/esm/components/livechatwidget/common/ActivityStreamHandler.js +34 -0
  67. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +14 -0
  68. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.js +1 -0
  69. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +29 -0
  70. package/lib/esm/components/livechatwidget/common/ChatAdapterShim.js +59 -0
  71. package/lib/esm/components/livechatwidget/common/Deferred.js +33 -0
  72. package/lib/esm/components/livechatwidget/common/authHelper.js +39 -0
  73. package/lib/esm/components/livechatwidget/common/createAdapter.js +12 -2
  74. package/lib/esm/components/livechatwidget/common/createMarkdown.js +31 -30
  75. package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +14 -18
  76. package/lib/esm/components/livechatwidget/common/endChat.js +89 -11
  77. package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +25 -5
  78. package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +134 -41
  79. package/lib/esm/components/livechatwidget/common/registerTelemetryLoggers.js +3 -13
  80. package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +0 -4
  81. package/lib/esm/components/livechatwidget/common/shareObservable.js +38 -0
  82. package/lib/esm/components/livechatwidget/common/startChat.js +152 -53
  83. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +260 -77
  84. package/lib/esm/components/postchatloadingpanestateful/PostChatLoadingPaneStateful.js +6 -0
  85. package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +7 -11
  86. package/lib/esm/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +17 -1
  87. package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +72 -0
  88. package/lib/esm/components/webchatcontainerstateful/common/mockchatsdk.js +2 -0
  89. package/lib/esm/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.js +1 -0
  90. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +5 -0
  91. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +16 -2
  92. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.js +41 -0
  93. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.js +94 -0
  94. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.js +107 -0
  95. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +32 -0
  96. package/lib/esm/contexts/common/ConversationState.js +3 -2
  97. package/lib/esm/contexts/common/LiveChatWidgetActionType.js +10 -7
  98. package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +4 -2
  99. package/lib/esm/contexts/createReducer.js +24 -7
  100. package/lib/esm/controller/componentController.js +3 -3
  101. package/lib/esm/plugins/newMessageEventHandler.js +10 -12
  102. package/lib/types/common/Constants.d.ts +25 -2
  103. package/lib/types/common/interfaces/IContextDataStore.d.ts +2 -2
  104. package/lib/types/common/telemetry/TelemetryConstants.d.ts +32 -5
  105. package/lib/types/common/telemetry/TelemetryHelper.d.ts +2 -0
  106. package/lib/types/common/telemetry/definitions/Payload.d.ts +12 -9
  107. package/lib/types/common/telemetry/interfaces/ITelemetryConfig.d.ts +3 -3
  108. package/lib/types/common/utils.d.ts +8 -1
  109. package/lib/types/components/confirmationpanestateful/interfaces/IConfirmationPaneStatefulParams.d.ts +4 -4
  110. package/lib/types/components/footerstateful/audionotificationstateful/interfaces/IAudioNotificationStatefulParams.d.ts +0 -1
  111. package/lib/types/components/headerstateful/interfaces/IHeaderStatefulParams.d.ts +2 -1
  112. package/lib/types/components/livechatwidget/common/ActivityStreamHandler.d.ts +14 -0
  113. package/lib/types/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.d.ts +5 -0
  114. package/lib/types/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.d.ts +6 -0
  115. package/lib/types/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.d.ts +7 -0
  116. package/lib/types/components/livechatwidget/common/ChatAdapterShim.d.ts +7 -0
  117. package/lib/types/components/livechatwidget/common/Deferred.d.ts +9 -0
  118. package/lib/types/components/livechatwidget/common/authHelper.d.ts +4 -0
  119. package/lib/types/components/livechatwidget/common/endChat.d.ts +4 -1
  120. package/lib/types/components/livechatwidget/common/reconnectChatHelper.d.ts +6 -2
  121. package/lib/types/components/livechatwidget/common/shareObservable.d.ts +1 -0
  122. package/lib/types/components/livechatwidget/common/startChat.d.ts +4 -2
  123. package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetComponentOverrides.d.ts +1 -0
  124. package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetControlProps.d.ts +1 -0
  125. package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +2 -1
  126. package/lib/types/components/reconnectchatpanestateful/interfaces/IReconnectChatPaneStatefulProps.d.ts +1 -1
  127. package/lib/types/components/webchatcontainerstateful/common/mockchatsdk.d.ts +1 -0
  128. package/lib/types/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.d.ts +4 -0
  129. package/lib/types/components/webchatcontainerstateful/interfaces/IWebChatContainerStatefulProps.d.ts +2 -0
  130. package/lib/types/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.d.ts +3 -0
  131. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.d.ts +2 -0
  132. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.d.ts +1 -0
  133. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.d.ts +5 -0
  134. package/lib/types/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.d.ts +1 -0
  135. package/lib/types/contexts/common/ConversationState.d.ts +3 -2
  136. package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +3 -1
  137. package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +11 -8
  138. package/package.json +8 -8
@@ -89,16 +89,20 @@ var _useChatContextStore = _interopRequireDefault(require("../../../hooks/useCha
89
89
 
90
90
  var _useChatSDKStore = _interopRequireDefault(require("../../../hooks/useChatSDKStore"));
91
91
 
92
+ var _ActivityStreamHandler = require("../common/ActivityStreamHandler");
93
+
94
+ var _Constants = require("../../../common/Constants");
95
+
92
96
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
93
97
 
94
98
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
95
99
 
96
100
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
97
101
 
98
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
102
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
99
103
 
100
104
  const LiveChatWidgetStateful = props => {
101
- var _props$webChatContain, _props$styleProps, _props$controlProps, _props$webChatContain3, _props$webChatContain4, _props$styleProps2, _props$controlProps5, _props$componentOverr, _props$controlProps6, _props$componentOverr2, _props$controlProps7, _props$componentOverr3, _props$controlProps8, _props$componentOverr4, _props$controlProps9, _props$componentOverr5, _props$controlProps10, _props$componentOverr6, _props$controlProps11, _props$controlProps12, _props$controlProps13, _props$componentOverr7, _props$controlProps14, _props$componentOverr8, _props$controlProps15, _props$componentOverr9, _props$componentOverr10, _props$componentOverr11;
105
+ var _props$webChatContain, _props$styleProps, _props$controlProps, _props$webChatContain3, _props$webChatContain4, _props$styleProps2, _props$controlProps14, _props$controlProps15, _props$componentOverr, _props$controlProps16, _props$componentOverr2, _props$controlProps17, _props$componentOverr3, _props$controlProps18, _props$componentOverr4, _props$controlProps19, _props$componentOverr5, _props$controlProps20, _props$componentOverr6, _props$controlProps21, _props$componentOverr7, _props$controlProps22, _props$controlProps23, _props$componentOverr8, _props$controlProps24, _props$componentOverr9, _props$controlProps25, _props$componentOverr10, _props$componentOverr11, _props$componentOverr12;
102
106
 
103
107
  const [state, dispatch] = (0, _useChatContextStore.default)(); // eslint-disable-next-line @typescript-eslint/no-explicit-any
104
108
 
@@ -107,7 +111,8 @@ const LiveChatWidgetStateful = props => {
107
111
  ...((_props$webChatContain = props.webChatContainerProps) === null || _props$webChatContain === void 0 ? void 0 : _props$webChatContain.webChatStyles)
108
112
  }); // eslint-disable-next-line @typescript-eslint/no-explicit-any
109
113
 
110
- const chatSDK = (0, _useChatSDKStore.default)();
114
+ const chatSDK = (0, _useChatSDKStore.default)(); // eslint-disable-next-line @typescript-eslint/no-explicit-any
115
+
111
116
  const [voiceVideoCallingSDK, setVoiceVideoCallingSDK] = (0, _react2.useState)(undefined);
112
117
  const {
113
118
  Composer
@@ -120,9 +125,35 @@ const LiveChatWidgetStateful = props => {
120
125
  _TelemetryManager.TelemetryTimers.LcwLoadToChatButtonTimer = (0, _utils.createTimer)();
121
126
  const widgetElementId = ((_props$controlProps = props.controlProps) === null || _props$controlProps === void 0 ? void 0 : _props$controlProps.id) || "oc-lcw";
122
127
  const currentMessageCountRef = (0, _react2.useRef)(0);
128
+ let widgetStateEventName = "";
129
+
130
+ const initiateEndChatOnBrowserUnload = () => {
131
+ var _DataStoreManager$cli;
132
+
133
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
134
+ Event: _TelemetryConstants.TelemetryEvent.BrowserUnloadEventStarted,
135
+ Description: "Browser unload event received."
136
+ });
137
+
138
+ (0, _endChat.endChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, false, false, false); // Clean local storage
139
+
140
+ (_DataStoreManager$cli = _DataStoreManager.DataStoreManager.clientDataStore) === null || _DataStoreManager$cli === void 0 ? void 0 : _DataStoreManager$cli.removeData(widgetStateEventName, "localStorage"); //Dispose calling instance
141
+
142
+ if (voiceVideoCallingSDK) {
143
+ voiceVideoCallingSDK === null || voiceVideoCallingSDK === void 0 ? void 0 : voiceVideoCallingSDK.close();
144
+ } //Message for clearing window[popouTab]
145
+
146
+
147
+ _omnichannelChatComponents.BroadcastService.postMessage({
148
+ eventName: _TelemetryConstants.BroadcastEvent.ClosePopoutWindow
149
+ });
150
+ };
151
+
123
152
  (0, _react2.useEffect)(() => {
124
- var _props$controlProps2, _props$controlProps3, _props$reconnectChatP, _props$controlProps4, _props$chatConfig, _props$chatConfig$Cha, _state$domainStates;
153
+ var _chatSDK$omnichannelC, _props$controlProps2, _props$controlProps3, _props$controlProps4, _props$controlProps5, _props$controlProps7, _props$chatConfig, _props$chatConfig$Cha, _props$controlProps8, _props$reconnectChatP, _props$chatConfig2, _props$chatConfig2$Li;
125
154
 
155
+ const broadcastServiceChannelName = (0, _utils.getBroadcastChannelName)(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC === void 0 ? void 0 : _chatSDK$omnichannelC.widgetId, ((_props$controlProps2 = props.controlProps) === null || _props$controlProps2 === void 0 ? void 0 : _props$controlProps2.widgetInstanceId) ?? "");
156
+ (0, _omnichannelChatComponents.BroadcastServiceInitialize)(broadcastServiceChannelName);
126
157
  (0, _registerTelemetryLoggers.registerTelemetryLoggers)(props, dispatch);
127
158
  (0, _createInternetConnectionChangeHandler.createInternetConnectionChangeHandler)();
128
159
  _DataStoreManager.DataStoreManager.clientDataStore = props.contextDataStore ?? undefined;
@@ -132,47 +163,79 @@ const LiveChatWidgetStateful = props => {
132
163
  });
133
164
  dispatch({
134
165
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_SKIP_CHAT_BUTTON_RENDERING,
135
- payload: ((_props$controlProps2 = props.controlProps) === null || _props$controlProps2 === void 0 ? void 0 : _props$controlProps2.skipChatButtonRendering) || false
166
+ payload: ((_props$controlProps3 = props.controlProps) === null || _props$controlProps3 === void 0 ? void 0 : _props$controlProps3.skipChatButtonRendering) || false
167
+ });
168
+ dispatch({
169
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_E2VV_ENABLED,
170
+ payload: false
136
171
  });
172
+
173
+ if ((_props$controlProps4 = props.controlProps) !== null && _props$controlProps4 !== void 0 && _props$controlProps4.widgetInstanceId && !(0, _utils.isNullOrEmptyString)((_props$controlProps5 = props.controlProps) === null || _props$controlProps5 === void 0 ? void 0 : _props$controlProps5.widgetInstanceId)) {
174
+ var _props$controlProps6;
175
+
176
+ dispatch({
177
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_WIDGET_INSTANCE_ID,
178
+ payload: (_props$controlProps6 = props.controlProps) === null || _props$controlProps6 === void 0 ? void 0 : _props$controlProps6.widgetInstanceId
179
+ });
180
+ }
181
+
137
182
  (0, _initCallingSdk.initCallingSdk)(chatSDK, setVoiceVideoCallingSDK).then(sdkCreated => {
138
183
  sdkCreated && dispatch({
139
184
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_E2VV_ENABLED,
140
185
  payload: true
141
186
  });
187
+ }); // Initialize global dir
188
+
189
+ const globalDir = ((_props$controlProps7 = props.controlProps) === null || _props$controlProps7 === void 0 ? void 0 : _props$controlProps7.dir) ?? (0, _utils.getLocaleDirection)((_props$chatConfig = props.chatConfig) === null || _props$chatConfig === void 0 ? void 0 : (_props$chatConfig$Cha = _props$chatConfig.ChatWidgetLanguage) === null || _props$chatConfig$Cha === void 0 ? void 0 : _props$chatConfig$Cha.msdyn_localeid);
190
+ dispatch({
191
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_GLOBAL_DIR,
192
+ payload: globalDir
142
193
  });
143
194
 
144
- if (!((_props$controlProps3 = props.controlProps) !== null && _props$controlProps3 !== void 0 && _props$controlProps3.skipChatButtonRendering) && (_props$reconnectChatP = props.reconnectChatPaneProps) !== null && _props$reconnectChatP !== void 0 && _props$reconnectChatP.reconnectId) {
145
- var _props$reconnectChatP2;
195
+ if (!((_props$controlProps8 = props.controlProps) !== null && _props$controlProps8 !== void 0 && _props$controlProps8.skipChatButtonRendering) && (_props$reconnectChatP = props.reconnectChatPaneProps) !== null && _props$reconnectChatP !== void 0 && _props$reconnectChatP.reconnectId) {
196
+ var _props$reconnectChatP2, _props$reconnectChatP3;
197
+
198
+ (0, _reconnectChatHelper.startUnauthenticatedReconnectChat)(chatSDK, props.chatConfig, props.getAuthToken, dispatch, setAdapter, (_props$reconnectChatP2 = props.reconnectChatPaneProps) === null || _props$reconnectChatP2 === void 0 ? void 0 : _props$reconnectChatP2.isReconnectEnabled, (_props$reconnectChatP3 = props.reconnectChatPaneProps) === null || _props$reconnectChatP3 === void 0 ? void 0 : _props$reconnectChatP3.reconnectId, _startChat.initStartChat);
199
+ return;
200
+ } // Check if auth settings enabled, do not connect to existing chat from cache during refresh/re-load
201
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
146
202
 
147
- (0, _reconnectChatHelper.handleUnauthenticatedReconnectChat)(dispatch, (_props$reconnectChatP2 = props.reconnectChatPaneProps) === null || _props$reconnectChatP2 === void 0 ? void 0 : _props$reconnectChatP2.reconnectId, _startChat.initStartChat);
148
- } // Initialize global dir
203
+
204
+ const isAuthenticationSettingsEnabled = (_props$chatConfig2 = props.chatConfig) !== null && _props$chatConfig2 !== void 0 && (_props$chatConfig2$Li = _props$chatConfig2.LiveChatConfigAuthSettings) !== null && _props$chatConfig2$Li !== void 0 && _props$chatConfig2$Li.msdyn_javascriptclientfunction ? true : false;
205
+
206
+ if (isAuthenticationSettingsEnabled === false) {
207
+ var _state$domainStates;
208
+
209
+ if (!(0, _utils.isUndefinedOrEmpty)((_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : _state$domainStates.liveChatContext) && state.appStates.conversationState === _ConversationState.ConversationState.Active) {
210
+ var _state$domainStates2;
211
+
212
+ const optionalParams = {
213
+ liveChatContext: (_state$domainStates2 = state.domainStates) === null || _state$domainStates2 === void 0 ? void 0 : _state$domainStates2.liveChatContext
214
+ };
215
+ (0, _startChat.initStartChat)(chatSDK, props.chatConfig, props.getAuthToken, dispatch, setAdapter, optionalParams);
216
+ return;
217
+ }
218
+ } // All other case should show start chat button, skipChatButtonRendering will take care of it own
149
219
 
150
220
 
151
- const globalDir = ((_props$controlProps4 = props.controlProps) === null || _props$controlProps4 === void 0 ? void 0 : _props$controlProps4.dir) ?? (0, _utils.getLocaleDirection)((_props$chatConfig = props.chatConfig) === null || _props$chatConfig === void 0 ? void 0 : (_props$chatConfig$Cha = _props$chatConfig.ChatWidgetLanguage) === null || _props$chatConfig$Cha === void 0 ? void 0 : _props$chatConfig$Cha.msdyn_localeid);
152
221
  dispatch({
153
- type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_GLOBAL_DIR,
154
- payload: globalDir
222
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
223
+ payload: _ConversationState.ConversationState.Closed
155
224
  });
225
+ }, []); // useEffect for when skip chat button rendering
156
226
 
157
- if ((_state$domainStates = state.domainStates) !== null && _state$domainStates !== void 0 && _state$domainStates.chatToken) {
158
- var _state$domainStates2;
159
-
160
- const optionalParams = {
161
- liveChatContext: {
162
- chatToken: (_state$domainStates2 = state.domainStates) === null || _state$domainStates2 === void 0 ? void 0 : _state$domainStates2.chatToken
163
- }
164
- };
165
- (0, _startChat.initStartChat)(chatSDK, dispatch, setAdapter, optionalParams);
166
- }
167
- }, []);
168
227
  (0, _react2.useEffect)(() => {
169
228
  if (state.appStates.skipChatButtonRendering) {
170
- var _props$reconnectChatP3;
229
+ var _props$reconnectChatP4;
171
230
 
172
- if ((_props$reconnectChatP3 = props.reconnectChatPaneProps) !== null && _props$reconnectChatP3 !== void 0 && _props$reconnectChatP3.reconnectId && !state.appStates.reconnectId) {
173
- var _props$reconnectChatP4;
231
+ _omnichannelChatComponents.BroadcastService.postMessage({
232
+ eventName: _TelemetryConstants.BroadcastEvent.ChatInitiated
233
+ });
174
234
 
175
- (0, _reconnectChatHelper.handleUnauthenticatedReconnectChat)(dispatch, (_props$reconnectChatP4 = props.reconnectChatPaneProps) === null || _props$reconnectChatP4 === void 0 ? void 0 : _props$reconnectChatP4.reconnectId, _startChat.initStartChat);
235
+ if ((_props$reconnectChatP4 = props.reconnectChatPaneProps) !== null && _props$reconnectChatP4 !== void 0 && _props$reconnectChatP4.reconnectId && !state.appStates.reconnectId) {
236
+ var _props$reconnectChatP5, _props$reconnectChatP6, _props$reconnectChatP7;
237
+
238
+ (0, _reconnectChatHelper.handleUnauthenticatedReconnectChat)(chatSDK, props.chatConfig, props.getAuthToken, dispatch, setAdapter, (_props$reconnectChatP5 = props.reconnectChatPaneProps) === null || _props$reconnectChatP5 === void 0 ? void 0 : _props$reconnectChatP5.isReconnectEnabled, (_props$reconnectChatP6 = props.reconnectChatPaneProps) === null || _props$reconnectChatP6 === void 0 ? void 0 : _props$reconnectChatP6.reconnectId, _startChat.initStartChat, (_props$reconnectChatP7 = props.reconnectChatPaneProps) === null || _props$reconnectChatP7 === void 0 ? void 0 : _props$reconnectChatP7.redirectInSameWindow);
176
239
  } else {
177
240
  (0, _reconnectChatHelper.getReconnectIdForAuthenticatedChat)(props, chatSDK).then(authReconnectId => {
178
241
  if (authReconnectId && !state.appStates.reconnectId) {
@@ -185,24 +248,42 @@ const LiveChatWidgetStateful = props => {
185
248
  payload: _ConversationState.ConversationState.ReconnectChat
186
249
  });
187
250
  } else {
188
- dispatch({
189
- type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
190
- payload: _ConversationState.ConversationState.Loading
191
- });
192
- (0, _startChat.initStartChat)(chatSDK, dispatch, setAdapter);
251
+ const chatStartedSkippingChatButtonRendering = {
252
+ eventName: _TelemetryConstants.BroadcastEvent.StartChatSkippingChatButtonRendering
253
+ };
254
+
255
+ _omnichannelChatComponents.BroadcastService.postMessage(chatStartedSkippingChatButtonRendering);
256
+
257
+ (0, _startChat.setPreChatAndInitiateChat)(chatSDK, props.chatConfig, props.getAuthToken, dispatch, setAdapter);
193
258
  }
194
259
  });
195
260
  }
196
261
  }
197
- }, [state.appStates.skipChatButtonRendering]);
262
+ }, [state.appStates.skipChatButtonRendering]); // useEffect for when skip chat button rendering
263
+
198
264
  (0, _react2.useEffect)(() => {
199
- _omnichannelChatComponents.BroadcastService.getMessageByEventName("StartProactiveChat").subscribe(msg => {
265
+ var _chatSDK$omnichannelC6, _chatSDK$omnichannelC7, _props$controlProps11;
266
+
267
+ // Add the custom context on receiving the SetCustomContext event
268
+ _omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.SetCustomContext).subscribe(msg => {
269
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
270
+ Event: _TelemetryConstants.TelemetryEvent.CustomContextReceived,
271
+ Description: "CustomContext received."
272
+ });
273
+
274
+ dispatch({
275
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CUSTOM_CONTEXT,
276
+ payload: msg === null || msg === void 0 ? void 0 : msg.payload
277
+ });
278
+ });
279
+
280
+ _omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.StartProactiveChat).subscribe(msg => {
200
281
  _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
201
282
  Event: _TelemetryConstants.TelemetryEvent.StartProactiveChatEventReceived,
202
283
  Description: "Start proactive chat event received."
203
284
  });
204
285
 
205
- if (canStartProactiveChat.current) {
286
+ if (canStartProactiveChat.current === true) {
206
287
  var _msg$payload, _msg$payload2, _msg$payload3;
207
288
 
208
289
  (0, _startProactiveChat.startProactiveChat)(dispatch, msg === null || msg === void 0 ? void 0 : (_msg$payload = msg.payload) === null || _msg$payload === void 0 ? void 0 : _msg$payload.notificationConfig, msg === null || msg === void 0 ? void 0 : (_msg$payload2 = msg.payload) === null || _msg$payload2 === void 0 ? void 0 : _msg$payload2.enablePreChat, msg === null || msg === void 0 ? void 0 : (_msg$payload3 = msg.payload) === null || _msg$payload3 === void 0 ? void 0 : _msg$payload3.inNewWindow);
@@ -212,40 +293,138 @@ const LiveChatWidgetStateful = props => {
212
293
  Description: "Start proactive chat method called, when chat was already triggered."
213
294
  });
214
295
  }
215
- });
296
+ }); // Start chat from SDK Event
216
297
 
217
- window.addEventListener("beforeunload", () => {
218
- (0, _disposeTelemetryLoggers.disposeTelemetryLoggers)();
219
- });
220
298
 
221
- if (state.appStates.conversationEndedByAgent) {
222
- (0, _endChat.endChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter);
223
- }
224
- }, []);
225
- (0, _react2.useEffect)(() => {
226
- canStartProactiveChat.current = state.appStates.conversationState === _ConversationState.ConversationState.Closed;
299
+ _omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.StartChat).subscribe(() => {
300
+ var _chatSDK$omnichannelC2, _chatSDK$omnichannelC3, _props$controlProps9;
227
301
 
228
- if (state.appStates.conversationState === _ConversationState.ConversationState.Active) {
229
- chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.onNewMessage(() => {
302
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
303
+ Event: _TelemetryConstants.TelemetryEvent.StartChatEventRecevied,
304
+ Description: "Start chat event received."
305
+ });
306
+
307
+ const persistedState = (0, _utils.getStateFromCache)(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC2 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC2 === void 0 ? void 0 : _chatSDK$omnichannelC2.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC3 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC3 === void 0 ? void 0 : _chatSDK$omnichannelC3.widgetId, (props === null || props === void 0 ? void 0 : (_props$controlProps9 = props.controlProps) === null || _props$controlProps9 === void 0 ? void 0 : _props$controlProps9.widgetInstanceId) ?? ""); // Chat not found in cache
308
+
309
+ if (persistedState === undefined) {
230
310
  _omnichannelChatComponents.BroadcastService.postMessage({
231
- eventName: _TelemetryConstants.BroadcastEvent.NewMessageNotification
311
+ eventName: _TelemetryConstants.BroadcastEvent.ChatInitiated
232
312
  });
313
+
314
+ (0, _startChat.prepareStartChat)(props, chatSDK, state, dispatch, setAdapter);
315
+ return;
316
+ } // Chat exist in cache
317
+
318
+
319
+ if (persistedState) {
320
+ var _persistedState$domai, _persistedState$domai2, _persistedState$domai3, _persistedState$domai4;
321
+
322
+ // Only initiate new chat if widget state in cache in one of the followings
323
+ if (persistedState.appStates.conversationState === _ConversationState.ConversationState.Closed || persistedState.appStates.conversationState === _ConversationState.ConversationState.InActive || persistedState.appStates.conversationState === _ConversationState.ConversationState.Postchat) {
324
+ _omnichannelChatComponents.BroadcastService.postMessage({
325
+ eventName: _TelemetryConstants.BroadcastEvent.ChatInitiated
326
+ });
327
+
328
+ (0, _startChat.prepareStartChat)(props, chatSDK, state, dispatch, setAdapter);
329
+ return;
330
+ } // If minimized, maximize the chat
331
+
332
+
333
+ dispatch({
334
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_MINIMIZED,
335
+ payload: false
336
+ });
337
+
338
+ _omnichannelChatComponents.BroadcastService.postMessage({
339
+ eventName: _TelemetryConstants.BroadcastEvent.MaximizeChat,
340
+ payload: {
341
+ height: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai = persistedState.domainStates) === null || _persistedState$domai === void 0 ? void 0 : (_persistedState$domai2 = _persistedState$domai.widgetSize) === null || _persistedState$domai2 === void 0 ? void 0 : _persistedState$domai2.height,
342
+ width: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai3 = persistedState.domainStates) === null || _persistedState$domai3 === void 0 ? void 0 : (_persistedState$domai4 = _persistedState$domai3.widgetSize) === null || _persistedState$domai4 === void 0 ? void 0 : _persistedState$domai4.width
343
+ }
344
+ });
345
+ }
346
+ }); // End chat
347
+
348
+
349
+ _omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.InitiateEndChat).subscribe(async () => {
350
+ if (state.appStates.skipChatButtonRendering !== true) {
351
+ var _chatSDK$omnichannelC4, _chatSDK$omnichannelC5, _props$controlProps10;
352
+
353
+ // This is to ensure to get latest state from cache in multitab
354
+ const persistedState = (0, _utils.getStateFromCache)(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC4 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC4 === void 0 ? void 0 : _chatSDK$omnichannelC4.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC5 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC5 === void 0 ? void 0 : _chatSDK$omnichannelC5.widgetId, (props === null || props === void 0 ? void 0 : (_props$controlProps10 = props.controlProps) === null || _props$controlProps10 === void 0 ? void 0 : _props$controlProps10.widgetInstanceId) ?? "");
355
+
356
+ if (persistedState && persistedState.appStates.conversationState === _ConversationState.ConversationState.Active) {
357
+ (0, _endChat.prepareEndChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state);
358
+ } else {
359
+ const skipEndChatSDK = true;
360
+ const skipCloseChat = false;
361
+ (0, _endChat.endChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat);
362
+ }
363
+ }
364
+
365
+ _omnichannelChatComponents.BroadcastService.postMessage({
366
+ eventName: _TelemetryConstants.BroadcastEvent.CloseChat
233
367
  });
234
- } // Track the message count
368
+ }); // End chat on browser unload
369
+
370
+
371
+ _omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.InitiateEndChatOnBrowserUnload).subscribe(() => {
372
+ initiateEndChatOnBrowserUnload();
373
+ }); // Listen to end chat event from other tabs
374
+
375
+
376
+ const endChatEventName = (0, _utils.getWidgetEndChatEventName)(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC6 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC6 === void 0 ? void 0 : _chatSDK$omnichannelC6.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC7 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC7 === void 0 ? void 0 : _chatSDK$omnichannelC7.widgetId, ((_props$controlProps11 = props.controlProps) === null || _props$controlProps11 === void 0 ? void 0 : _props$controlProps11.widgetInstanceId) ?? "");
235
377
 
378
+ _omnichannelChatComponents.BroadcastService.getMessageByEventName(endChatEventName).subscribe(async () => {
379
+ (0, _endChat.endChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, false, false, false);
380
+ return;
381
+ }); // When conversation ended by agent
382
+
383
+
384
+ if (state.appStates.conversationEndedByAgent) {
385
+ (0, _endChat.endChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter);
386
+ } //Listen to WidgetSize, used for minimize to maximize
387
+
388
+
389
+ _omnichannelChatComponents.BroadcastService.getMessageByEventName("WidgetSize").subscribe(msg => {
390
+ dispatch({
391
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_WIDGET_SIZE,
392
+ payload: msg === null || msg === void 0 ? void 0 : msg.payload
393
+ });
394
+ });
236
395
 
396
+ return () => {
397
+ (0, _disposeTelemetryLoggers.disposeTelemetryLoggers)();
398
+ };
399
+ }, []);
400
+ (0, _react2.useEffect)(() => {
401
+ // On new message
237
402
  if (state.appStates.conversationState === _ConversationState.ConversationState.Active) {
238
403
  chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.onNewMessage(() => {
404
+ // Track the message count
239
405
  currentMessageCountRef.current++;
240
406
  dispatch({
241
407
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_UNREAD_MESSAGE_COUNT,
242
408
  payload: currentMessageCountRef.current + 1
409
+ }); // New message notification
410
+
411
+ _omnichannelChatComponents.BroadcastService.postMessage({
412
+ eventName: _TelemetryConstants.BroadcastEvent.NewMessageNotification
243
413
  });
244
414
  });
245
415
  }
246
- }, [state.appStates.conversationState]); // Reset the UnreadMessageCount when minimized is toggled and broadcast it.
416
+ }, [state.appStates.conversationState]);
417
+ (0, _react2.useEffect)(() => {
418
+ canStartProactiveChat.current = state.appStates.conversationState === _ConversationState.ConversationState.Closed && !state.appStates.proactiveChatStates.proactiveChatInNewWindow;
419
+ }, [state.appStates.conversationState, state.appStates.proactiveChatStates.proactiveChatInNewWindow]); // Reset the UnreadMessageCount when minimized is toggled and broadcast it.
247
420
 
248
421
  (0, _react2.useEffect)(() => {
422
+ if (state.appStates.isMinimized) {
423
+ _ActivityStreamHandler.ActivityStreamHandler.cork();
424
+ } else {
425
+ setTimeout(() => _ActivityStreamHandler.ActivityStreamHandler.uncork(), 500);
426
+ }
427
+
249
428
  currentMessageCountRef.current = -1;
250
429
  dispatch({
251
430
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_UNREAD_MESSAGE_COUNT,
@@ -261,7 +440,7 @@ const LiveChatWidgetStateful = props => {
261
440
  }, [state.appStates.isMinimized]); // Broadcast the UnreadMessageCount state on any change.
262
441
 
263
442
  (0, _react2.useEffect)(() => {
264
- if (state.appStates.isMinimized && state.appStates.unreadMessageCount > 0) {
443
+ if (state.appStates.isMinimized === true && state.appStates.unreadMessageCount > 0) {
265
444
  const customEvent = {
266
445
  elementType: _omnichannelChatComponents.ElementType.Custom,
267
446
  eventName: _TelemetryConstants.BroadcastEvent.UnreadMessageCount,
@@ -277,30 +456,51 @@ const LiveChatWidgetStateful = props => {
277
456
  setWebChatStyles({ ...webChatStyles,
278
457
  ...((_props$webChatContain2 = props.webChatContainerProps) === null || _props$webChatContain2 === void 0 ? void 0 : _props$webChatContain2.webChatStyles)
279
458
  });
280
- }, [(_props$webChatContain3 = props.webChatContainerProps) === null || _props$webChatContain3 === void 0 ? void 0 : _props$webChatContain3.webChatStyles]);
281
- const webChatProps = (0, _initWebChatComposer.initWebChatComposer)(props, chatSDK, state, dispatch, setWebChatStyles);
282
-
283
- const setPostChatContextRelay = () => (0, _setPostChatContextAndLoadSurvey.setPostChatContextAndLoadSurvey)(chatSDK, dispatch); // eslint-disable-next-line @typescript-eslint/no-explicit-any
459
+ }, [(_props$webChatContain3 = props.webChatContainerProps) === null || _props$webChatContain3 === void 0 ? void 0 : _props$webChatContain3.webChatStyles]); // Publish chat widget state
284
460
 
461
+ (0, _react2.useEffect)(() => {
462
+ var _props$controlProps12, _props$chatSDK, _props$chatSDK$omnich, _props$chatSDK2, _props$chatSDK2$omnic, _props$controlProps13;
285
463
 
286
- const endChatRelay = (adapter, skipEndChatSDK, skipCloseChat) => (0, _endChat.endChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat);
287
-
288
- const prepareStartChatRelay = () => (0, _startChat.prepareStartChat)(props, chatSDK, state, dispatch, setAdapter); // eslint-disable-next-line @typescript-eslint/no-explicit-any
289
-
464
+ // Only activate these windows events when conversation state is active and chat widget is in popout mode
465
+ // Ghost chat scenarios
466
+ if (state.appStates.conversationState === _ConversationState.ConversationState.Active && ((_props$controlProps12 = props.controlProps) === null || _props$controlProps12 === void 0 ? void 0 : _props$controlProps12.skipChatButtonRendering) === true) {
467
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
468
+ window.onbeforeunload = function () {
469
+ const prompt = _Constants.Constants.BrowserUnloadConfirmationMessage;
470
+ return prompt;
471
+ }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
290
472
 
291
- const initStartChatRelay = (optionalParams, persistedState) => (0, _startChat.initStartChat)(chatSDK, dispatch, setAdapter, optionalParams, persistedState);
292
473
 
293
- const confirmationPaneProps = (0, _initConfirmationPropsComposer.initConfirmationPropsComposer)(props); // publish chat widget state
474
+ window.onunload = function () {
475
+ initiateEndChatOnBrowserUnload();
476
+ };
477
+ }
294
478
 
295
- (0, _react2.useEffect)(() => {
479
+ widgetStateEventName = (0, _utils.getWidgetCacheId)(props === null || props === void 0 ? void 0 : (_props$chatSDK = props.chatSDK) === null || _props$chatSDK === void 0 ? void 0 : (_props$chatSDK$omnich = _props$chatSDK.omnichannelConfig) === null || _props$chatSDK$omnich === void 0 ? void 0 : _props$chatSDK$omnich.orgId, props === null || props === void 0 ? void 0 : (_props$chatSDK2 = props.chatSDK) === null || _props$chatSDK2 === void 0 ? void 0 : (_props$chatSDK2$omnic = _props$chatSDK2.omnichannelConfig) === null || _props$chatSDK2$omnic === void 0 ? void 0 : _props$chatSDK2$omnic.widgetId, (props === null || props === void 0 ? void 0 : (_props$controlProps13 = props.controlProps) === null || _props$controlProps13 === void 0 ? void 0 : _props$controlProps13.widgetInstanceId) ?? "");
296
480
  const chatWidgetStateChangeEvent = {
297
- eventName: _TelemetryConstants.BroadcastEvent.ChatWidgetStateChanged,
481
+ eventName: widgetStateEventName,
298
482
  payload: { ...state
299
483
  }
300
484
  };
301
485
 
302
486
  _omnichannelChatComponents.BroadcastService.postMessage(chatWidgetStateChangeEvent);
303
487
  }, [state]);
488
+ const webChatProps = (0, _initWebChatComposer.initWebChatComposer)(props, chatSDK, state, dispatch, setWebChatStyles);
489
+
490
+ const setPostChatContextRelay = () => (0, _setPostChatContextAndLoadSurvey.setPostChatContextAndLoadSurvey)(chatSDK, dispatch); // eslint-disable-next-line @typescript-eslint/no-explicit-any
491
+
492
+
493
+ const endChatRelay = (adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTab) => (0, _endChat.endChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTab); // eslint-disable-next-line @typescript-eslint/no-explicit-any
494
+
495
+
496
+ const prepareEndChatRelay = (adapter, state) => (0, _endChat.prepareEndChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state);
497
+
498
+ const prepareStartChatRelay = () => (0, _startChat.prepareStartChat)(props, chatSDK, state, dispatch, setAdapter); // eslint-disable-next-line @typescript-eslint/no-explicit-any
499
+
500
+
501
+ const initStartChatRelay = (optionalParams, persistedState) => (0, _startChat.initStartChat)(chatSDK, props.chatConfig, props.getAuthToken, dispatch, setAdapter, optionalParams, persistedState);
502
+
503
+ const confirmationPaneProps = (0, _initConfirmationPropsComposer.initConfirmationPropsComposer)(props);
304
504
  return /*#__PURE__*/_react2.default.createElement(Composer, _extends({}, webChatProps, {
305
505
  styleOptions: webChatStyles,
306
506
  directLine: ((_props$webChatContain4 = props.webChatContainerProps) === null || _props$webChatContain4 === void 0 ? void 0 : _props$webChatContain4.directLine) ?? adapter ?? _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.directLine
@@ -308,29 +508,29 @@ const LiveChatWidgetStateful = props => {
308
508
  id: widgetElementId,
309
509
  styles: generalStyles,
310
510
  className: (_props$styleProps2 = props.styleProps) === null || _props$styleProps2 === void 0 ? void 0 : _props$styleProps2.className
311
- }, !((_props$controlProps5 = props.controlProps) !== null && _props$controlProps5 !== void 0 && _props$controlProps5.hideChatButton) && (0, _componentController.shouldShowChatButton)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr = props.componentOverrides) === null || _props$componentOverr === void 0 ? void 0 : _props$componentOverr.chatButton) || /*#__PURE__*/_react2.default.createElement(_ChatButtonStateful.default, {
511
+ }, !((_props$controlProps14 = props.controlProps) !== null && _props$controlProps14 !== void 0 && _props$controlProps14.hideChatButton) && !((_props$controlProps15 = props.controlProps) !== null && _props$controlProps15 !== void 0 && _props$controlProps15.skipChatButtonRendering) && (0, _componentController.shouldShowChatButton)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr = props.componentOverrides) === null || _props$componentOverr === void 0 ? void 0 : _props$componentOverr.chatButton) || /*#__PURE__*/_react2.default.createElement(_ChatButtonStateful.default, {
312
512
  buttonProps: props.chatButtonProps,
313
513
  outOfOfficeButtonProps: props.outOfOfficeChatButtonProps,
314
514
  startChat: prepareStartChatRelay
315
- })), !((_props$controlProps6 = props.controlProps) !== null && _props$controlProps6 !== void 0 && _props$controlProps6.hideProactiveChatPane) && (0, _componentController.shouldShowProactiveChatPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr2 = props.componentOverrides) === null || _props$componentOverr2 === void 0 ? void 0 : _props$componentOverr2.proactiveChatPane) || /*#__PURE__*/_react2.default.createElement(_ProactiveChatPaneStateful.default, {
515
+ })), !((_props$controlProps16 = props.controlProps) !== null && _props$controlProps16 !== void 0 && _props$controlProps16.hideProactiveChatPane) && (0, _componentController.shouldShowProactiveChatPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr2 = props.componentOverrides) === null || _props$componentOverr2 === void 0 ? void 0 : _props$componentOverr2.proactiveChatPane) || /*#__PURE__*/_react2.default.createElement(_ProactiveChatPaneStateful.default, {
316
516
  proactiveChatProps: props.proactiveChatPaneProps,
317
517
  startChat: prepareStartChatRelay
318
- })), !((_props$controlProps7 = props.controlProps) !== null && _props$controlProps7 !== void 0 && _props$controlProps7.hideHeader) && (0, _componentController.shouldShowHeader)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr3 = props.componentOverrides) === null || _props$componentOverr3 === void 0 ? void 0 : _props$componentOverr3.header) || /*#__PURE__*/_react2.default.createElement(_HeaderStateful.default, {
518
+ })), !((_props$controlProps17 = props.controlProps) !== null && _props$controlProps17 !== void 0 && _props$controlProps17.hideHeader) && (0, _componentController.shouldShowHeader)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr3 = props.componentOverrides) === null || _props$componentOverr3 === void 0 ? void 0 : _props$componentOverr3.header) || /*#__PURE__*/_react2.default.createElement(_HeaderStateful.default, {
319
519
  headerProps: props.headerProps,
320
520
  outOfOfficeHeaderProps: props.outOfOfficeHeaderProps,
321
521
  endChat: endChatRelay
322
- })), !((_props$controlProps8 = props.controlProps) !== null && _props$controlProps8 !== void 0 && _props$controlProps8.hideLoadingPane) && (0, _componentController.shouldShowLoadingPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr4 = props.componentOverrides) === null || _props$componentOverr4 === void 0 ? void 0 : _props$componentOverr4.loadingPane) || /*#__PURE__*/_react2.default.createElement(_LoadingPaneStateful.default, props.loadingPaneProps)), !((_props$controlProps9 = props.controlProps) !== null && _props$controlProps9 !== void 0 && _props$controlProps9.hideOutOfOfficeHoursPane) && (0, _componentController.shouldShowOutOfOfficeHoursPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr5 = props.componentOverrides) === null || _props$componentOverr5 === void 0 ? void 0 : _props$componentOverr5.outOfOfficeHoursPane) || /*#__PURE__*/_react2.default.createElement(_OOOHPaneStateful.default, props.outOfOfficeHoursPaneProps)), !((_props$controlProps10 = props.controlProps) !== null && _props$controlProps10 !== void 0 && _props$controlProps10.hideReconnectChatPane) && (0, _componentController.shouldShowReconnectChatPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr6 = props.componentOverrides) === null || _props$componentOverr6 === void 0 ? void 0 : _props$componentOverr6.reconnectChatPane) || /*#__PURE__*/_react2.default.createElement(_ReconnectChatPaneStateful.default, {
522
+ })), !((_props$controlProps18 = props.controlProps) !== null && _props$controlProps18 !== void 0 && _props$controlProps18.hideLoadingPane) && (0, _componentController.shouldShowLoadingPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr4 = props.componentOverrides) === null || _props$componentOverr4 === void 0 ? void 0 : _props$componentOverr4.loadingPane) || /*#__PURE__*/_react2.default.createElement(_LoadingPaneStateful.default, props.loadingPaneProps)), !((_props$controlProps19 = props.controlProps) !== null && _props$controlProps19 !== void 0 && _props$controlProps19.hideOutOfOfficeHoursPane) && (0, _componentController.shouldShowOutOfOfficeHoursPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr5 = props.componentOverrides) === null || _props$componentOverr5 === void 0 ? void 0 : _props$componentOverr5.outOfOfficeHoursPane) || /*#__PURE__*/_react2.default.createElement(_OOOHPaneStateful.default, props.outOfOfficeHoursPaneProps)), !((_props$controlProps20 = props.controlProps) !== null && _props$controlProps20 !== void 0 && _props$controlProps20.hideReconnectChatPane) && (0, _componentController.shouldShowReconnectChatPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr6 = props.componentOverrides) === null || _props$componentOverr6 === void 0 ? void 0 : _props$componentOverr6.reconnectChatPane) || /*#__PURE__*/_react2.default.createElement(_ReconnectChatPaneStateful.default, {
323
523
  reconnectChatProps: props.reconnectChatPaneProps,
324
524
  initStartChat: initStartChatRelay
325
- })), !((_props$controlProps11 = props.controlProps) !== null && _props$controlProps11 !== void 0 && _props$controlProps11.hidePreChatSurveyPane) && (0, _componentController.shouldShowPreChatSurveyPane)(state) && /*#__PURE__*/_react2.default.createElement(_PreChatSurveyPaneStateful.default, {
525
+ })), !((_props$controlProps21 = props.controlProps) !== null && _props$controlProps21 !== void 0 && _props$controlProps21.hidePreChatSurveyPane) && (0, _componentController.shouldShowPreChatSurveyPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr7 = props.componentOverrides) === null || _props$componentOverr7 === void 0 ? void 0 : _props$componentOverr7.preChatSurveyPane) || /*#__PURE__*/_react2.default.createElement(_PreChatSurveyPaneStateful.default, {
326
526
  surveyProps: props.preChatSurveyPaneProps,
327
527
  initStartChat: initStartChatRelay
328
- }), !((_props$controlProps12 = props.controlProps) !== null && _props$controlProps12 !== void 0 && _props$controlProps12.hideCallingContainer) && (0, _componentController.shouldShowCallingContainer)(state) && /*#__PURE__*/_react2.default.createElement(_CallingContainerStateful.default, _extends({
528
+ })), !((_props$controlProps22 = props.controlProps) !== null && _props$controlProps22 !== void 0 && _props$controlProps22.hideCallingContainer) && (0, _componentController.shouldShowCallingContainer)(state) && /*#__PURE__*/_react2.default.createElement(_CallingContainerStateful.default, _extends({
329
529
  voiceVideoCallingSdk: voiceVideoCallingSDK
330
- }, props.callingContainerProps)), !((_props$controlProps13 = props.controlProps) !== null && _props$controlProps13 !== void 0 && _props$controlProps13.hideWebChatContainer) && (0, _componentController.shouldShowWebChatContainer)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr7 = props.componentOverrides) === null || _props$componentOverr7 === void 0 ? void 0 : _props$componentOverr7.webChatContainer) || /*#__PURE__*/_react2.default.createElement(_WebChatContainerStateful.default, props.webChatContainerProps)), !((_props$controlProps14 = props.controlProps) !== null && _props$controlProps14 !== void 0 && _props$controlProps14.hideConfirmationPane) && (0, _componentController.shouldShowConfirmationPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr8 = props.componentOverrides) === null || _props$componentOverr8 === void 0 ? void 0 : _props$componentOverr8.confirmationPane) || /*#__PURE__*/_react2.default.createElement(_ConfirmationPaneStateful.default, _extends({}, confirmationPaneProps, {
530
+ }, props.callingContainerProps)), !((_props$controlProps23 = props.controlProps) !== null && _props$controlProps23 !== void 0 && _props$controlProps23.hideWebChatContainer) && (0, _componentController.shouldShowWebChatContainer)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr8 = props.componentOverrides) === null || _props$componentOverr8 === void 0 ? void 0 : _props$componentOverr8.webChatContainer) || /*#__PURE__*/_react2.default.createElement(_WebChatContainerStateful.default, props.webChatContainerProps)), !((_props$controlProps24 = props.controlProps) !== null && _props$controlProps24 !== void 0 && _props$controlProps24.hideConfirmationPane) && (0, _componentController.shouldShowConfirmationPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr9 = props.componentOverrides) === null || _props$componentOverr9 === void 0 ? void 0 : _props$componentOverr9.confirmationPane) || /*#__PURE__*/_react2.default.createElement(_ConfirmationPaneStateful.default, _extends({}, confirmationPaneProps, {
331
531
  setPostChatContext: setPostChatContextRelay,
332
- endChat: endChatRelay
333
- }))), !((_props$controlProps15 = props.controlProps) !== null && _props$controlProps15 !== void 0 && _props$controlProps15.hidePostChatLoadingPane) && (0, _componentController.shouldShowPostChatLoadingPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr9 = props.componentOverrides) === null || _props$componentOverr9 === void 0 ? void 0 : _props$componentOverr9.postChatLoadingPane) || /*#__PURE__*/_react2.default.createElement(_PostChatLoadingPaneStateful.default, props.postChatLoadingPaneProps)), (0, _componentController.shouldShowPostChatSurveyPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr10 = props.componentOverrides) === null || _props$componentOverr10 === void 0 ? void 0 : _props$componentOverr10.postChatSurveyPane) || /*#__PURE__*/_react2.default.createElement(_PostChatSurveyPaneStateful.default, _extends({}, props.postChatSurveyPaneProps, props.chatSDK))), (0, _createFooter.createFooter)(props, state), (0, _componentController.shouldShowEmailTranscriptPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr11 = props.componentOverrides) === null || _props$componentOverr11 === void 0 ? void 0 : _props$componentOverr11.emailTranscriptPane) || /*#__PURE__*/_react2.default.createElement(_EmailTranscriptPaneStateful.default, props.emailTranscriptPane))));
532
+ prepareEndChat: prepareEndChatRelay
533
+ }))), !((_props$controlProps25 = props.controlProps) !== null && _props$controlProps25 !== void 0 && _props$controlProps25.hidePostChatLoadingPane) && (0, _componentController.shouldShowPostChatLoadingPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr10 = props.componentOverrides) === null || _props$componentOverr10 === void 0 ? void 0 : _props$componentOverr10.postChatLoadingPane) || /*#__PURE__*/_react2.default.createElement(_PostChatLoadingPaneStateful.default, props.postChatLoadingPaneProps)), (0, _componentController.shouldShowPostChatSurveyPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr11 = props.componentOverrides) === null || _props$componentOverr11 === void 0 ? void 0 : _props$componentOverr11.postChatSurveyPane) || /*#__PURE__*/_react2.default.createElement(_PostChatSurveyPaneStateful.default, _extends({}, props.postChatSurveyPaneProps, props.chatSDK))), (0, _createFooter.createFooter)(props, state), (0, _componentController.shouldShowEmailTranscriptPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr12 = props.componentOverrides) === null || _props$componentOverr12 === void 0 ? void 0 : _props$componentOverr12.emailTranscriptPane) || /*#__PURE__*/_react2.default.createElement(_EmailTranscriptPaneStateful.default, props.emailTranscriptPane))));
334
534
  };
335
535
 
336
536
  exports.LiveChatWidgetStateful = LiveChatWidgetStateful;
@@ -15,6 +15,10 @@ var _utils = require("../../common/utils");
15
15
 
16
16
  var _useChatContextStore = _interopRequireDefault(require("../../hooks/useChatContextStore"));
17
17
 
18
+ var _TelemetryHelper = require("../../common/telemetry/TelemetryHelper");
19
+
20
+ var _TelemetryConstants = require("../../common/telemetry/TelemetryConstants");
21
+
18
22
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
23
 
20
24
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
@@ -46,6 +50,10 @@ const PostChatLoadingPaneStateful = props => {
46
50
  if (firstElement && firstElement[0]) {
47
51
  firstElement[0].focus();
48
52
  }
53
+
54
+ _TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
55
+ Event: _TelemetryConstants.TelemetryEvent.PostChatSurveyLoadingPaneLoaded
56
+ });
49
57
  }, []);
50
58
  return /*#__PURE__*/_react.default.createElement(_omnichannelChatComponents.LoadingPane, {
51
59
  componentOverrides: props.componentOverrides,
@@ -15,8 +15,6 @@ var _utils = require("../../common/utils");
15
15
 
16
16
  var _ConversationState = require("../../contexts/common/ConversationState");
17
17
 
18
- var _DataStoreManager = require("../../common/contextDataStore/DataStoreManager");
19
-
20
18
  var _LiveChatWidgetActionType = require("../../contexts/common/LiveChatWidgetActionType");
21
19
 
22
20
  var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
@@ -93,13 +91,12 @@ const PreChatSurveyPaneStateful = props => {
93
91
  });
94
92
 
95
93
  try {
96
- var _DataStoreManager$cli, _persistedState$domai;
94
+ var _state$domainStates, _state$domainStates$t, _state$domainStates$t2, _persistedState$domai, _persistedState$appSt;
97
95
 
98
- const widgetStateFromCache = (_DataStoreManager$cli = _DataStoreManager.DataStoreManager.clientDataStore) === null || _DataStoreManager$cli === void 0 ? void 0 : _DataStoreManager$cli.getData(_Constants.Constants.widgetStateDataKey, "localStorage");
99
- const persistedState = widgetStateFromCache ? JSON.parse(widgetStateFromCache) : undefined;
100
- let optionalParams = {};
96
+ const persistedState = (0, _utils.getStateFromCache)(((_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : (_state$domainStates$t = _state$domainStates.telemetryInternalData) === null || _state$domainStates$t === void 0 ? void 0 : _state$domainStates$t.orgId) ?? "", ((_state$domainStates$t2 = state.domainStates.telemetryInternalData) === null || _state$domainStates$t2 === void 0 ? void 0 : _state$domainStates$t2.widgetId) ?? "", state.domainStates.widgetInstanceId ?? "");
97
+ let optionalParams = {}; //Connect to Active chats and chat is not popout
101
98
 
102
- if (persistedState !== null && persistedState !== void 0 && (_persistedState$domai = persistedState.domainStates) !== null && _persistedState$domai !== void 0 && _persistedState$domai.liveChatContext) {
99
+ if (persistedState && !(0, _utils.isUndefinedOrEmpty)(persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai = persistedState.domainStates) === null || _persistedState$domai === void 0 ? void 0 : _persistedState$domai.liveChatContext) && (persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$appSt = persistedState.appStates) === null || _persistedState$appSt === void 0 ? void 0 : _persistedState$appSt.conversationState) === _ConversationState.ConversationState.Active && !state.appStates.skipChatButtonRendering) {
103
100
  var _persistedState$domai2;
104
101
 
105
102
  optionalParams = {
@@ -109,9 +106,7 @@ const PreChatSurveyPaneStateful = props => {
109
106
  } else {
110
107
  const prechatResponseValues = (0, _utils.extractPreChatSurveyResponseValues)(state.domainStates.preChatSurveyResponse, values);
111
108
  optionalParams = {
112
- initContext: {
113
- preChatResponse: prechatResponseValues
114
- }
109
+ preChatResponse: prechatResponseValues
115
110
  };
116
111
  setPreChatResponseEmail(values);
117
112
  await initStartChat(optionalParams);
@@ -46,6 +46,14 @@ const ProactiveChatPaneStateful = props => {
46
46
  const handleProactiveChatInviteTimeout = () => {
47
47
  if (!timeoutRemoved) {
48
48
  setTimeoutRemoved(true);
49
+ dispatch({
50
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_PROACTIVE_CHAT_PARAMS,
51
+ payload: {
52
+ proactiveChatBodyTitle: "",
53
+ proactiveChatEnablePrechat: false,
54
+ proactiveChatInNewWindow: false
55
+ }
56
+ });
49
57
  dispatch({
50
58
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
51
59
  payload: _ConversationState.ConversationState.Closed
@@ -111,13 +119,21 @@ const ProactiveChatPaneStateful = props => {
111
119
  Description: "Proactive chat closed."
112
120
  });
113
121
 
122
+ dispatch({
123
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_PROACTIVE_CHAT_PARAMS,
124
+ payload: {
125
+ proactiveChatBodyTitle: "",
126
+ proactiveChatEnablePrechat: false,
127
+ proactiveChatInNewWindow: false
128
+ }
129
+ });
114
130
  dispatch({
115
131
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
116
132
  payload: _ConversationState.ConversationState.Closed
117
133
  });
118
134
  },
119
135
  ...(proactiveChatProps === null || proactiveChatProps === void 0 ? void 0 : proactiveChatProps.controlProps),
120
- bodyTitleText: state.appStates.proactiveChatStates.proactiveChatBodyTitle ?? (proactiveChatProps === null || proactiveChatProps === void 0 ? void 0 : (_proactiveChatProps$c = proactiveChatProps.controlProps) === null || _proactiveChatProps$c === void 0 ? void 0 : _proactiveChatProps$c.bodyTitleText)
136
+ bodyTitleText: state.appStates.proactiveChatStates.proactiveChatBodyTitle ? state.appStates.proactiveChatStates.proactiveChatBodyTitle : proactiveChatProps === null || proactiveChatProps === void 0 ? void 0 : (_proactiveChatProps$c = proactiveChatProps.controlProps) === null || _proactiveChatProps$c === void 0 ? void 0 : _proactiveChatProps$c.bodyTitleText
121
137
  };
122
138
  (0, _react.useEffect)(() => {
123
139
  (0, _utils.setFocusOnElement)(document.getElementById(controlProps.id + "-startbutton"));