@microsoft/omnichannel-chat-widget 0.1.0-main.1f10a2e → 0.1.0-main.3cfca4d

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 (45) hide show
  1. package/lib/cjs/common/Constants.js +2 -0
  2. package/lib/cjs/common/telemetry/TelemetryConstants.js +4 -0
  3. package/lib/cjs/common/utils.js +48 -2
  4. package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +4 -0
  5. package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +0 -1
  6. package/lib/cjs/components/livechatwidget/common/endChat.js +49 -17
  7. package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +9 -0
  8. package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +0 -4
  9. package/lib/cjs/components/livechatwidget/common/startChat.js +115 -80
  10. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +80 -84
  11. package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +4 -8
  12. package/lib/cjs/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +1 -1
  13. package/lib/cjs/contexts/common/ConversationState.js +3 -2
  14. package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +0 -1
  15. package/lib/cjs/controller/componentController.js +3 -3
  16. package/lib/esm/common/Constants.js +2 -0
  17. package/lib/esm/common/telemetry/TelemetryConstants.js +4 -0
  18. package/lib/esm/common/utils.js +36 -0
  19. package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +4 -0
  20. package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +0 -1
  21. package/lib/esm/components/livechatwidget/common/endChat.js +50 -18
  22. package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +10 -2
  23. package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +0 -4
  24. package/lib/esm/components/livechatwidget/common/startChat.js +114 -80
  25. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +80 -84
  26. package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +5 -8
  27. package/lib/esm/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +1 -1
  28. package/lib/esm/contexts/common/ConversationState.js +3 -2
  29. package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +0 -1
  30. package/lib/esm/controller/componentController.js +3 -3
  31. package/lib/types/common/Constants.d.ts +1 -0
  32. package/lib/types/common/telemetry/TelemetryConstants.d.ts +4 -1
  33. package/lib/types/common/telemetry/TelemetryHelper.d.ts +1 -1
  34. package/lib/types/common/utils.d.ts +3 -0
  35. package/lib/types/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.d.ts +1 -1
  36. package/lib/types/components/livechatwidget/common/endChat.d.ts +1 -1
  37. package/lib/types/components/livechatwidget/common/reconnectChatHelper.d.ts +1 -1
  38. package/lib/types/components/livechatwidget/common/setPostChatContextAndLoadSurvey.d.ts +1 -1
  39. package/lib/types/components/livechatwidget/common/startChat.d.ts +2 -1
  40. package/lib/types/components/livechatwidget/common/startProactiveChat.d.ts +1 -1
  41. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.d.ts +1 -1
  42. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/avatarMiddleware.d.ts +1 -1
  43. package/lib/types/contexts/common/ConversationState.d.ts +3 -2
  44. package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +0 -1
  45. package/package.json +1 -1
@@ -95,10 +95,10 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
95
95
 
96
96
  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
97
 
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); }
98
+ 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
99
 
100
100
  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$componentOverr7, _props$controlProps12, _props$controlProps13, _props$componentOverr8, _props$controlProps14, _props$componentOverr9, _props$controlProps15, _props$componentOverr10, _props$componentOverr11, _props$componentOverr12;
101
+ var _props$webChatContain, _props$styleProps, _props$controlProps, _props$webChatContain3, _props$webChatContain4, _props$styleProps2, _props$controlProps5, _props$controlProps6, _props$componentOverr, _props$controlProps7, _props$componentOverr2, _props$controlProps8, _props$componentOverr3, _props$controlProps9, _props$componentOverr4, _props$controlProps10, _props$componentOverr5, _props$controlProps11, _props$componentOverr6, _props$controlProps12, _props$componentOverr7, _props$controlProps13, _props$controlProps14, _props$componentOverr8, _props$controlProps15, _props$componentOverr9, _props$controlProps16, _props$componentOverr10, _props$componentOverr11, _props$componentOverr12;
102
102
 
103
103
  const [state, dispatch] = (0, _useChatContextStore.default)(); // eslint-disable-next-line @typescript-eslint/no-explicit-any
104
104
 
@@ -113,8 +113,7 @@ const LiveChatWidgetStateful = props => {
113
113
  const {
114
114
  Composer
115
115
  } = _botframeworkWebchat.Components;
116
- const canStartProactiveChat = (0, _react2.useRef)(true);
117
- const canEndChat = (0, _react2.useRef)(true); // Process general styles
116
+ const canStartProactiveChat = (0, _react2.useRef)(true); // Process general styles
118
117
 
119
118
  const generalStyles = {
120
119
  root: Object.assign({}, (0, _getGeneralStylesForButton.getGeneralStylesForButton)(state), (_props$styleProps = props.styleProps) === null || _props$styleProps === void 0 ? void 0 : _props$styleProps.generalStyles)
@@ -125,9 +124,14 @@ const LiveChatWidgetStateful = props => {
125
124
  let widgetStateEventName = "";
126
125
 
127
126
  const initiateEndChatOnBrowserUnload = () => {
128
- var _DataStoreManager$cli;
127
+ var _chatSDK$omnichannelC, _chatSDK$omnichannelC2, _DataStoreManager$cli;
129
128
 
130
- const persistedState = getStateFromCache(); // End chat if the chat is still active and browser closed
129
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
130
+ Event: _TelemetryConstants.TelemetryEvent.BrowserUnloadEventStarted,
131
+ Description: "Browser unload event received."
132
+ });
133
+
134
+ const persistedState = (0, _utils.getStateFromCache)(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC === void 0 ? void 0 : _chatSDK$omnichannelC.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC2 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC2 === void 0 ? void 0 : _chatSDK$omnichannelC2.widgetId); // End chat if the chat is still active and browser closed
131
135
 
132
136
  if (persistedState.appStates.conversationState === _ConversationState.ConversationState.Active) {
133
137
  //Browser close scenario/no room for PCS/so just end chat and notify agent immidiately
@@ -135,22 +139,15 @@ const LiveChatWidgetStateful = props => {
135
139
  } // Clean local storage
136
140
 
137
141
 
138
- (_DataStoreManager$cli = _DataStoreManager.DataStoreManager.clientDataStore) === null || _DataStoreManager$cli === void 0 ? void 0 : _DataStoreManager$cli.removeData(widgetStateEventName, "localStorage");
139
- }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
140
-
142
+ (_DataStoreManager$cli = _DataStoreManager.DataStoreManager.clientDataStore) === null || _DataStoreManager$cli === void 0 ? void 0 : _DataStoreManager$cli.removeData(widgetStateEventName, "localStorage"); //Message for clearing window[popouTab]
141
143
 
142
- const getStateFromCache = () => {
143
- var _chatSDK$omnichannelC, _chatSDK$omnichannelC2, _DataStoreManager$cli2;
144
-
145
- // Getting updated state from cache
146
- const widgetStateEventName = (0, _utils.getWidgetCacheId)((chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC === void 0 ? void 0 : _chatSDK$omnichannelC.orgId) ?? "", (chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC2 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC2 === void 0 ? void 0 : _chatSDK$omnichannelC2.widgetId) ?? "");
147
- const widgetStateFromCache = (_DataStoreManager$cli2 = _DataStoreManager.DataStoreManager.clientDataStore) === null || _DataStoreManager$cli2 === void 0 ? void 0 : _DataStoreManager$cli2.getData(widgetStateEventName, "localStorage");
148
- const persistedState = widgetStateFromCache ? JSON.parse(widgetStateFromCache) : undefined;
149
- return persistedState;
144
+ _omnichannelChatComponents.BroadcastService.postMessage({
145
+ eventName: _TelemetryConstants.BroadcastEvent.ClosePopoutWindow
146
+ });
150
147
  };
151
148
 
152
149
  (0, _react2.useEffect)(() => {
153
- var _props$controlProps2, _props$controlProps3, _props$reconnectChatP, _props$controlProps4, _props$chatConfig, _props$chatConfig$Cha, _state$domainStates;
150
+ var _props$controlProps2, _props$controlProps3, _props$reconnectChatP, _props$controlProps4, _props$chatConfig, _props$chatConfig$Cha, _props$chatConfig2, _props$chatConfig2$Li;
154
151
 
155
152
  (0, _registerTelemetryLoggers.registerTelemetryLoggers)(props, dispatch);
156
153
  (0, _createInternetConnectionChangeHandler.createInternetConnectionChangeHandler)();
@@ -185,15 +182,28 @@ const LiveChatWidgetStateful = props => {
185
182
  dispatch({
186
183
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_GLOBAL_DIR,
187
184
  payload: globalDir
188
- });
185
+ }); //Check if auth settings enabled, do not connect to existing chat from cache during refresh/re-load
186
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
189
187
 
190
- if ((_state$domainStates = state.domainStates) !== null && _state$domainStates !== void 0 && _state$domainStates.liveChatContext) {
191
- var _state$domainStates2;
188
+ 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;
192
189
 
193
- const optionalParams = {
194
- liveChatContext: (_state$domainStates2 = state.domainStates) === null || _state$domainStates2 === void 0 ? void 0 : _state$domainStates2.liveChatContext
195
- };
196
- (0, _startChat.initStartChat)(chatSDK, dispatch, setAdapter, optionalParams);
190
+ if (!isAuthenticationSettingsEnabled) {
191
+ var _state$domainStates;
192
+
193
+ if (!(0, _utils.isUndefinedOrEmpty)((_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : _state$domainStates.liveChatContext) && state.appStates.conversationState === _ConversationState.ConversationState.Active) {
194
+ var _state$domainStates2;
195
+
196
+ const optionalParams = {
197
+ liveChatContext: (_state$domainStates2 = state.domainStates) === null || _state$domainStates2 === void 0 ? void 0 : _state$domainStates2.liveChatContext
198
+ };
199
+ (0, _startChat.initStartChat)(chatSDK, dispatch, setAdapter, optionalParams);
200
+ } else {
201
+ // All other case should show start chat button, skipChatButtonRendering will take care of it own
202
+ dispatch({
203
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
204
+ payload: _ConversationState.ConversationState.Closed
205
+ });
206
+ }
197
207
  }
198
208
  }, []); // useEffect for when skip chat button rendering
199
209
 
@@ -227,11 +237,7 @@ const LiveChatWidgetStateful = props => {
227
237
 
228
238
  _omnichannelChatComponents.BroadcastService.postMessage(chatStartedSkippingChatButtonRendering);
229
239
 
230
- dispatch({
231
- type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
232
- payload: _ConversationState.ConversationState.Loading
233
- });
234
- (0, _startChat.initStartChat)(chatSDK, dispatch, setAdapter);
240
+ (0, _startChat.setPreChatAndInitiateChat)(chatSDK, dispatch, setAdapter);
235
241
  }
236
242
  });
237
243
  }
@@ -239,7 +245,7 @@ const LiveChatWidgetStateful = props => {
239
245
  }, [state.appStates.skipChatButtonRendering]); // useEffect for when skip chat button rendering
240
246
 
241
247
  (0, _react2.useEffect)(() => {
242
- var _chatSDK$omnichannelC3, _chatSDK$omnichannelC4;
248
+ var _chatSDK$omnichannelC7, _chatSDK$omnichannelC8;
243
249
 
244
250
  // Add the custom context on receiving the SetCustomContext event
245
251
  _omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.SetCustomContext).subscribe(msg => {
@@ -274,14 +280,17 @@ const LiveChatWidgetStateful = props => {
274
280
 
275
281
 
276
282
  _omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.StartChat).subscribe(() => {
283
+ var _chatSDK$omnichannelC3, _chatSDK$omnichannelC4;
284
+
277
285
  _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
278
286
  Event: _TelemetryConstants.TelemetryEvent.StartChatEventRecevied,
279
287
  Description: "Start chat event received."
280
288
  });
281
289
 
282
- const persistedState = getStateFromCache();
290
+ const persistedState = (0, _utils.getStateFromCache)(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC3 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC3 === void 0 ? void 0 : _chatSDK$omnichannelC3.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC4 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC4 === void 0 ? void 0 : _chatSDK$omnichannelC4.widgetId);
283
291
 
284
- if (persistedState.appStates.conversationState === _ConversationState.ConversationState.Closed || persistedState.appStates.conversationState === _ConversationState.ConversationState.InActive || persistedState.appStates.conversationState === _ConversationState.ConversationState.Postchat) {
292
+ if (persistedState && (persistedState.appStates.conversationState === _ConversationState.ConversationState.Closed || persistedState.appStates.conversationState === _ConversationState.ConversationState.InActive || persistedState.appStates.conversationState === _ConversationState.ConversationState.Postchat)) {
293
+ // Embedded mode
285
294
  _omnichannelChatComponents.BroadcastService.postMessage({
286
295
  eventName: _TelemetryConstants.BroadcastEvent.ChatInitiated
287
296
  });
@@ -290,6 +299,7 @@ const LiveChatWidgetStateful = props => {
290
299
  } else {
291
300
  var _persistedState$domai, _persistedState$domai2, _persistedState$domai3, _persistedState$domai4;
292
301
 
302
+ // Minimize to Maximize
293
303
  dispatch({
294
304
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_MINIMIZED,
295
305
  payload: false
@@ -307,55 +317,42 @@ const LiveChatWidgetStateful = props => {
307
317
 
308
318
 
309
319
  _omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.InitiateEndChat).subscribe(async () => {
310
- if (canEndChat.current) {
311
- (0, _endChat.prepareEndChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state);
312
- } else {
313
- const skipEndChatSDK = true;
314
- const skipCloseChat = false;
315
- (0, _endChat.endChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat);
320
+ if (state.appStates.skipChatButtonRendering !== true) {
321
+ var _chatSDK$omnichannelC5, _chatSDK$omnichannelC6;
322
+
323
+ // This is to ensure to get latest state from cache in multitab
324
+ const persistedState = (0, _utils.getStateFromCache)(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC5 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC5 === void 0 ? void 0 : _chatSDK$omnichannelC5.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC6 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC6 === void 0 ? void 0 : _chatSDK$omnichannelC6.widgetId);
325
+
326
+ if (persistedState && persistedState.appStates.conversationState === _ConversationState.ConversationState.Active) {
327
+ (0, _endChat.prepareEndChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state);
328
+ } else {
329
+ const skipEndChatSDK = true;
330
+ const skipCloseChat = false;
331
+ (0, _endChat.endChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat);
332
+ }
316
333
  }
317
334
 
318
335
  _omnichannelChatComponents.BroadcastService.postMessage({
319
336
  eventName: _TelemetryConstants.BroadcastEvent.CloseChat
320
337
  });
321
- });
338
+ }); // End chat on browser unload
339
+
322
340
 
323
341
  _omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.InitiateEndChatOnBrowserUnload).subscribe(() => {
324
342
  initiateEndChatOnBrowserUnload();
325
- }); // reset proactive chat params
326
-
327
-
328
- _omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.ResetProactiveChatParams).subscribe(async () => {
329
- dispatch({
330
- type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_PROACTIVE_CHAT_PARAMS,
331
- payload: {
332
- proactiveChatBodyTitle: "",
333
- proactiveChatEnablePrechat: false,
334
- proactiveChatInNewWindow: false
335
- }
336
- });
337
343
  }); // Listen to end chat event from other tabs
338
344
 
339
345
 
340
- const endChatEventName = (0, _utils.getWidgetEndChatEventName)(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC3 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC3 === void 0 ? void 0 : _chatSDK$omnichannelC3.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC4 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC4 === void 0 ? void 0 : _chatSDK$omnichannelC4.widgetId);
346
+ const endChatEventName = (0, _utils.getWidgetEndChatEventName)(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC7 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC7 === void 0 ? void 0 : _chatSDK$omnichannelC7.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC8 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC8 === void 0 ? void 0 : _chatSDK$omnichannelC8.widgetId);
341
347
 
342
348
  _omnichannelChatComponents.BroadcastService.getMessageByEventName(endChatEventName).subscribe(async () => {
343
349
  (0, _endChat.endChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, false, false, false);
344
- }); // Close popout window
345
-
346
-
347
- window.addEventListener("beforeunload", () => {
348
- _TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
349
- Event: _TelemetryConstants.TelemetryEvent.WindowClosed,
350
- Description: "Closed window."
351
- });
350
+ }); // When conversation ended by agent
352
351
 
353
- (0, _disposeTelemetryLoggers.disposeTelemetryLoggers)();
354
- });
355
352
 
356
353
  if (state.appStates.conversationEndedByAgent) {
357
354
  (0, _endChat.endChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter);
358
- } //Listen to WidgetSize
355
+ } //Listen to WidgetSize, used for minimize to maximize
359
356
 
360
357
 
361
358
  _omnichannelChatComponents.BroadcastService.getMessageByEventName("WidgetSize").subscribe(msg => {
@@ -364,25 +361,24 @@ const LiveChatWidgetStateful = props => {
364
361
  payload: msg === null || msg === void 0 ? void 0 : msg.payload
365
362
  });
366
363
  });
364
+
365
+ return () => {
366
+ (0, _disposeTelemetryLoggers.disposeTelemetryLoggers)();
367
+ };
367
368
  }, []);
368
369
  (0, _react2.useEffect)(() => {
369
- canEndChat.current = state.appStates.conversationState === _ConversationState.ConversationState.Active;
370
-
371
- if (state.appStates.conversationState === _ConversationState.ConversationState.Active) {
372
- chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.onNewMessage(() => {
373
- _omnichannelChatComponents.BroadcastService.postMessage({
374
- eventName: _TelemetryConstants.BroadcastEvent.NewMessageNotification
375
- });
376
- });
377
- } // Track the message count
378
-
379
-
370
+ // On new message
380
371
  if (state.appStates.conversationState === _ConversationState.ConversationState.Active) {
381
372
  chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.onNewMessage(() => {
373
+ // Track the message count
382
374
  currentMessageCountRef.current++;
383
375
  dispatch({
384
376
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_UNREAD_MESSAGE_COUNT,
385
377
  payload: currentMessageCountRef.current + 1
378
+ }); // New message notification
379
+
380
+ _omnichannelChatComponents.BroadcastService.postMessage({
381
+ eventName: _TelemetryConstants.BroadcastEvent.NewMessageNotification
386
382
  });
387
383
  });
388
384
  }
@@ -407,7 +403,7 @@ const LiveChatWidgetStateful = props => {
407
403
  }, [state.appStates.isMinimized]); // Broadcast the UnreadMessageCount state on any change.
408
404
 
409
405
  (0, _react2.useEffect)(() => {
410
- if (state.appStates.isMinimized && state.appStates.unreadMessageCount > 0) {
406
+ if (state.appStates.isMinimized === true && state.appStates.unreadMessageCount > 0) {
411
407
  const customEvent = {
412
408
  elementType: _omnichannelChatComponents.ElementType.Custom,
413
409
  eventName: _TelemetryConstants.BroadcastEvent.UnreadMessageCount,
@@ -460,29 +456,29 @@ const LiveChatWidgetStateful = props => {
460
456
  id: widgetElementId,
461
457
  styles: generalStyles,
462
458
  className: (_props$styleProps2 = props.styleProps) === null || _props$styleProps2 === void 0 ? void 0 : _props$styleProps2.className
463
- }, !((_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, {
459
+ }, !((_props$controlProps5 = props.controlProps) !== null && _props$controlProps5 !== void 0 && _props$controlProps5.hideChatButton) && !((_props$controlProps6 = props.controlProps) !== null && _props$controlProps6 !== void 0 && _props$controlProps6.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, {
464
460
  buttonProps: props.chatButtonProps,
465
461
  outOfOfficeButtonProps: props.outOfOfficeChatButtonProps,
466
462
  startChat: prepareStartChatRelay
467
- })), !((_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, {
463
+ })), !((_props$controlProps7 = props.controlProps) !== null && _props$controlProps7 !== void 0 && _props$controlProps7.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, {
468
464
  proactiveChatProps: props.proactiveChatPaneProps,
469
465
  startChat: prepareStartChatRelay
470
- })), !((_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, {
466
+ })), !((_props$controlProps8 = props.controlProps) !== null && _props$controlProps8 !== void 0 && _props$controlProps8.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, {
471
467
  headerProps: props.headerProps,
472
468
  outOfOfficeHeaderProps: props.outOfOfficeHeaderProps,
473
469
  endChat: endChatRelay
474
- })), !((_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, {
470
+ })), !((_props$controlProps9 = props.controlProps) !== null && _props$controlProps9 !== void 0 && _props$controlProps9.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$controlProps10 = props.controlProps) !== null && _props$controlProps10 !== void 0 && _props$controlProps10.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$controlProps11 = props.controlProps) !== null && _props$controlProps11 !== void 0 && _props$controlProps11.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, {
475
471
  reconnectChatProps: props.reconnectChatPaneProps,
476
472
  initStartChat: initStartChatRelay
477
- })), !((_props$controlProps11 = props.controlProps) !== null && _props$controlProps11 !== void 0 && _props$controlProps11.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, {
473
+ })), !((_props$controlProps12 = props.controlProps) !== null && _props$controlProps12 !== void 0 && _props$controlProps12.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, {
478
474
  surveyProps: props.preChatSurveyPaneProps,
479
475
  initStartChat: initStartChatRelay
480
- })), !((_props$controlProps12 = props.controlProps) !== null && _props$controlProps12 !== void 0 && _props$controlProps12.hideCallingContainer) && (0, _componentController.shouldShowCallingContainer)(state) && /*#__PURE__*/_react2.default.createElement(_CallingContainerStateful.default, _extends({
476
+ })), !((_props$controlProps13 = props.controlProps) !== null && _props$controlProps13 !== void 0 && _props$controlProps13.hideCallingContainer) && (0, _componentController.shouldShowCallingContainer)(state) && /*#__PURE__*/_react2.default.createElement(_CallingContainerStateful.default, _extends({
481
477
  voiceVideoCallingSdk: voiceVideoCallingSDK
482
- }, props.callingContainerProps)), !((_props$controlProps13 = props.controlProps) !== null && _props$controlProps13 !== void 0 && _props$controlProps13.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$controlProps14 = props.controlProps) !== null && _props$controlProps14 !== void 0 && _props$controlProps14.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, {
478
+ }, props.callingContainerProps)), !((_props$controlProps14 = props.controlProps) !== null && _props$controlProps14 !== void 0 && _props$controlProps14.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$controlProps15 = props.controlProps) !== null && _props$controlProps15 !== void 0 && _props$controlProps15.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, {
483
479
  setPostChatContext: setPostChatContextRelay,
484
480
  prepareEndChat: prepareEndChatRelay
485
- }))), !((_props$controlProps15 = props.controlProps) !== null && _props$controlProps15 !== void 0 && _props$controlProps15.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))));
481
+ }))), !((_props$controlProps16 = props.controlProps) !== null && _props$controlProps16 !== void 0 && _props$controlProps16.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))));
486
482
  };
487
483
 
488
484
  exports.LiveChatWidgetStateful = LiveChatWidgetStateful;
@@ -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,14 +91,12 @@ const PreChatSurveyPaneStateful = props => {
93
91
  });
94
92
 
95
93
  try {
96
- var _state$domainStates, _state$domainStates$t, _state$domainStates$t2, _DataStoreManager$cli, _persistedState$domai;
94
+ var _state$domainStates, _state$domainStates$t, _state$domainStates$t2, _persistedState$domai, _persistedState$appSt;
97
95
 
98
- const widgetStateCacheId = (0, _utils.getWidgetCacheId)(((_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) ?? "");
99
- const widgetStateFromCache = (_DataStoreManager$cli = _DataStoreManager.DataStoreManager.clientDataStore) === null || _DataStoreManager$cli === void 0 ? void 0 : _DataStoreManager$cli.getData(widgetStateCacheId, "localStorage");
100
- const persistedState = widgetStateFromCache ? JSON.parse(widgetStateFromCache) : undefined;
101
- 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) ?? "");
97
+ let optionalParams = {}; //Connect to Active chats and chat is not popout
102
98
 
103
- 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) {
104
100
  var _persistedState$domai2;
105
101
 
106
102
  optionalParams = {
@@ -133,7 +133,7 @@ const ProactiveChatPaneStateful = props => {
133
133
  });
134
134
  },
135
135
  ...(proactiveChatProps === null || proactiveChatProps === void 0 ? void 0 : proactiveChatProps.controlProps),
136
- 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
137
137
  };
138
138
  (0, _react.useEffect)(() => {
139
139
  (0, _utils.setFocusOnElement)(document.getElementById(controlProps.id + "-startbutton"));
@@ -15,6 +15,7 @@ exports.ConversationState = ConversationState;
15
15
  ConversationState[ConversationState["ProactiveChat"] = 4] = "ProactiveChat";
16
16
  ConversationState[ConversationState["Active"] = 5] = "Active";
17
17
  ConversationState[ConversationState["InActive"] = 6] = "InActive";
18
- ConversationState[ConversationState["Postchat"] = 7] = "Postchat";
19
- ConversationState[ConversationState["Closed"] = 8] = "Closed";
18
+ ConversationState[ConversationState["PostchatLoading"] = 7] = "PostchatLoading";
19
+ ConversationState[ConversationState["Postchat"] = 8] = "Postchat";
20
+ ConversationState[ConversationState["Closed"] = 9] = "Closed";
20
21
  })(ConversationState || (exports.ConversationState = ConversationState = {}));
@@ -36,7 +36,6 @@ const getLiveChatWidgetContextInitialState = props => {
36
36
  isMinimized: false,
37
37
  previousElementOnFocusBeforeModalOpen: null,
38
38
  outsideOperatingHours: false,
39
- shouldShowPostChat: false,
40
39
  preChatResponseEmail: "",
41
40
  isAudioMuted: null,
42
41
  newMessage: false,
@@ -8,7 +8,7 @@ exports.shouldShowWebChatContainer = exports.shouldShowReconnectChatPane = expor
8
8
  var _ConversationState = require("../contexts/common/ConversationState");
9
9
 
10
10
  const shouldShowChatButton = state => {
11
- return state.appStates.isMinimized || state.appStates.conversationState === _ConversationState.ConversationState.Closed;
11
+ return (state.appStates.isMinimized || state.appStates.conversationState === _ConversationState.ConversationState.Closed) && state.appStates.skipChatButtonRendering == false; // Do not show chat button in case of popout
12
12
  };
13
13
 
14
14
  exports.shouldShowChatButton = shouldShowChatButton;
@@ -44,7 +44,7 @@ const shouldShowWebChatContainer = state => {
44
44
  exports.shouldShowWebChatContainer = shouldShowWebChatContainer;
45
45
 
46
46
  const shouldShowLoadingPane = state => {
47
- return !state.appStates.isMinimized && !state.appStates.shouldShowPostChat && state.appStates.conversationState === _ConversationState.ConversationState.Loading;
47
+ return !state.appStates.isMinimized && state.appStates.conversationState === _ConversationState.ConversationState.Loading;
48
48
  };
49
49
 
50
50
  exports.shouldShowLoadingPane = shouldShowLoadingPane;
@@ -56,7 +56,7 @@ const shouldShowReconnectChatPane = state => {
56
56
  exports.shouldShowReconnectChatPane = shouldShowReconnectChatPane;
57
57
 
58
58
  const shouldShowPostChatLoadingPane = state => {
59
- return !state.appStates.isMinimized && state.appStates.shouldShowPostChat && state.appStates.conversationState === _ConversationState.ConversationState.Loading;
59
+ return !state.appStates.isMinimized && state.appStates.conversationState === _ConversationState.ConversationState.PostchatLoading;
60
60
  };
61
61
 
62
62
  exports.shouldShowPostChatLoadingPane = shouldShowPostChatLoadingPane;
@@ -158,6 +158,8 @@ _defineProperty(Constants, "internetConnectionTestUrlText", "Omnichannel Connect
158
158
 
159
159
  _defineProperty(Constants, "ChatWidgetStateChangedPrefix", "ChatWidgetStateChanged");
160
160
 
161
+ _defineProperty(Constants, "PostChatLoadingDurationInMs", 2000);
162
+
161
163
  export const Regex = (_class = class Regex {}, _defineProperty(_class, "EmailRegex", "(?:[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*\")@(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?|\\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-zA-Z0-9-]*[a-zA-Z0-9]:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21-\\x5a\\x53-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)\\])"), _class);
162
164
  export class HtmlIdNames {}
163
165
 
@@ -48,6 +48,7 @@ export let BroadcastEvent; // Events being logged
48
48
  BroadcastEvent["ChatInitiated"] = "ChatInitiated";
49
49
  BroadcastEvent["CloseChat"] = "CloseChat";
50
50
  BroadcastEvent["InitiateEndChatOnBrowserUnload"] = "InitiateEndChatOnBrowserUnload";
51
+ BroadcastEvent["ClosePopoutWindow"] = "ClosePopoutWindow";
51
52
  })(BroadcastEvent || (BroadcastEvent = {}));
52
53
 
53
54
  export let TelemetryEvent;
@@ -128,6 +129,8 @@ export let TelemetryEvent;
128
129
  TelemetryEvent["AudioToggleButtonClicked"] = "AudioToggleButtonClicked";
129
130
  TelemetryEvent["SuppressBotMagicCodeSucceeded"] = "SuppressBotMagicCodeSucceeded";
130
131
  TelemetryEvent["SuppressBotMagicCodeFailed"] = "SuppressBotMagicCodeFailed";
132
+ TelemetryEvent["GetConversationDetailsException"] = "GetConversationDetailsException";
133
+ TelemetryEvent["BrowserUnloadEventStarted"] = "BrowserUnloadEventStarted";
131
134
  TelemetryEvent["ProcessingHTMLTextMiddlewareFailed"] = "ProcessingHTMLTextMiddlewareFailed";
132
135
  TelemetryEvent["ProcessingSanitizationMiddlewareFailed"] = "ProcessingSanitizationMiddlewareFailed";
133
136
  TelemetryEvent["FormatTagsMiddlewareJSONStringifyFailed"] = "FormatTagsMiddlewareJSONStringifyFailed";
@@ -199,6 +202,7 @@ export class TelemetryConstants {
199
202
  case TelemetryEvent.MessageSent:
200
203
  case TelemetryEvent.MessageReceived:
201
204
  case TelemetryEvent.CustomContextReceived:
205
+ case TelemetryEvent.BrowserUnloadEventStarted:
202
206
  return ScenarioType.ACTIONS;
203
207
 
204
208
  case TelemetryEvent.StartChatSDKCall:
@@ -1,4 +1,5 @@
1
1
  import { AriaTelemetryConstants, Constants, LocaleConstants } from "./Constants";
2
+ import { DataStoreManager } from "./contextDataStore/DataStoreManager";
2
3
  import { KeyCodes } from "./KeyCodes";
3
4
  import { BroadcastEvent } from "./telemetry/TelemetryConstants";
4
5
 
@@ -294,4 +295,39 @@ export const getWidgetCacheId = (orgId, widgetId) => {
294
295
  };
295
296
  export const getWidgetEndChatEventName = (orgId, widgetId) => {
296
297
  return `${BroadcastEvent.ChatEnded}_${orgId}_${widgetId}`;
298
+ }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
299
+
300
+ export const getStateFromCache = (orgId, widgetId) => {
301
+ // Getting updated state from cache
302
+ try {
303
+ if (DataStoreManager.clientDataStore) {
304
+ var _DataStoreManager$cli;
305
+
306
+ const widgetStateEventName = getWidgetCacheId(orgId, widgetId);
307
+ const widgetStateFromCache = (_DataStoreManager$cli = DataStoreManager.clientDataStore) === null || _DataStoreManager$cli === void 0 ? void 0 : _DataStoreManager$cli.getData(widgetStateEventName, "localStorage");
308
+ const persistedState = widgetStateFromCache ? JSON.parse(widgetStateFromCache) : undefined;
309
+ return persistedState;
310
+ } else {
311
+ return null;
312
+ }
313
+ } catch (error) {
314
+ console.log(error);
315
+ return null;
316
+ }
317
+ }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
318
+
319
+ export const isUndefinedOrEmpty = object => {
320
+ if (object) {
321
+ if (Object.keys(object).length === 0) {
322
+ return true;
323
+ }
324
+
325
+ return false;
326
+ } else {
327
+ return true;
328
+ }
329
+ }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
330
+
331
+ export const addDelayInMs = ms => {
332
+ return new Promise(resolve => setTimeout(resolve, ms));
297
333
  };
@@ -57,6 +57,10 @@ export const ChatButtonStateful = props => {
57
57
  titleText: "We're Offline",
58
58
  subtitleText: "No agents available",
59
59
  onClick: async () => {
60
+ TelemetryHelper.logActionEvent(LogLevel.INFO, {
61
+ Event: TelemetryEvent.LCWChatButtonClicked
62
+ });
63
+
60
64
  if (state.appStates.isMinimized) {
61
65
  dispatch({
62
66
  type: LiveChatWidgetActionType.SET_MINIMIZED,
@@ -17,7 +17,6 @@ export const ConfirmationPaneStateful = props => {
17
17
  const {
18
18
  prepareEndChat
19
19
  } = props; // eslint-disable-next-line @typescript-eslint/no-explicit-any
20
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
21
20
 
22
21
  const [adapter] = useChatAdapterStore();
23
22
  const controlProps = {