@microsoft/omnichannel-chat-widget 1.8.1-main.f0e9e2f → 1.8.2-main.4b1a5f0

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 (26) hide show
  1. package/lib/cjs/common/facades/FacadeChatSDK.js +49 -7
  2. package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +8 -2
  3. package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +7 -3
  4. package/lib/cjs/components/headerstateful/HeaderStateful.js +8 -4
  5. package/lib/cjs/components/livechatwidget/LiveChatWidget.js +4 -3
  6. package/lib/cjs/components/livechatwidget/common/liveChatConfigUtils.js +1 -1
  7. package/lib/cjs/components/livechatwidget/common/persistentChatHelper.js +12 -5
  8. package/lib/cjs/components/livechatwidget/common/startChat.js +2 -2
  9. package/lib/cjs/components/livechatwidget/common/startChatErrorHandler.js +25 -8
  10. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +21 -17
  11. package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +1 -1
  12. package/lib/esm/common/facades/FacadeChatSDK.js +49 -7
  13. package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +8 -2
  14. package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +7 -3
  15. package/lib/esm/components/headerstateful/HeaderStateful.js +8 -4
  16. package/lib/esm/components/livechatwidget/LiveChatWidget.js +4 -3
  17. package/lib/esm/components/livechatwidget/common/liveChatConfigUtils.js +1 -1
  18. package/lib/esm/components/livechatwidget/common/persistentChatHelper.js +12 -5
  19. package/lib/esm/components/livechatwidget/common/startChat.js +2 -2
  20. package/lib/esm/components/livechatwidget/common/startChatErrorHandler.js +25 -8
  21. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +21 -17
  22. package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +1 -1
  23. package/lib/types/common/facades/FacadeChatSDK.d.ts +1 -0
  24. package/lib/types/components/livechatwidget/common/liveChatConfigUtils.d.ts +1 -1
  25. package/lib/types/components/livechatwidget/common/persistentChatHelper.d.ts +2 -1
  26. package/package.json +2 -2
@@ -109,7 +109,7 @@ let FacadeChatSDK = /*#__PURE__*/function () {
109
109
  token: last3digits
110
110
  }
111
111
  });
112
- throw new Error("Invalid token format, must be in JWT format");
112
+ throw new Error("Authentication Setup Error: Invalid token format, must be in JWT format");
113
113
  }
114
114
  try {
115
115
  const payload = this.enforceBase64Encoding(tokenParts[1]);
@@ -131,9 +131,9 @@ let FacadeChatSDK = /*#__PURE__*/function () {
131
131
  token: last3digits
132
132
  }
133
133
  });
134
- throw new Error("Invalid token payload, payload is not valid JSON");
134
+ throw new Error("Authentication Setup Error: Invalid token payload, payload is not valid JSON");
135
135
  } catch (e) {
136
- console.error("Failed to decode token", e);
136
+ console.error("Authentication Setup Error: Failed to decode token", e);
137
137
  _TelemetryHelper.TelemetryHelper.logFacadeChatSDKEventToAllTelemetry(_TelemetryConstants.LogLevel.ERROR, {
138
138
  Event: _TelemetryConstants.TelemetryEvent.NewTokenValidationFailed,
139
139
  Description: "Failed to decode token",
@@ -142,7 +142,7 @@ let FacadeChatSDK = /*#__PURE__*/function () {
142
142
  token: last3digits
143
143
  }
144
144
  });
145
- throw new Error("Failed to decode token");
145
+ throw new Error("Authentication Setup Error: Failed to decode authentication token");
146
146
  }
147
147
  }
148
148
  }, {
@@ -166,7 +166,7 @@ let FacadeChatSDK = /*#__PURE__*/function () {
166
166
  "Token": last3digits
167
167
  }
168
168
  });
169
- throw new Error(`New token is already expired, with epoch time ${this.expiration} , last 3 digits of token: ${last3digits}`);
169
+ throw new Error("Authentication Setup Error: New authentication token is already expired");
170
170
  }
171
171
  }
172
172
  }
@@ -280,9 +280,9 @@ let FacadeChatSDK = /*#__PURE__*/function () {
280
280
  if (pingResponse.result === true) {
281
281
  return fn();
282
282
  }
283
- const executionErrorMessage = `Authentication failed: Process to get a token failed for ${functionName}, ${pingResponse.message}`;
283
+ const executionErrorMessage = "Authentication Setup Error: Token validation failed - GetAuthToken function is not present";
284
284
  //telemetry is already logged in tokenRing, so no need to log again, just return the error and communicate to the console
285
- console.error(executionErrorMessage);
285
+ console.error(`${executionErrorMessage} Additional details: Process to get a token failed for ${functionName}, ${pingResponse.message}`);
286
286
  _omnichannelChatComponents.BroadcastService.postMessage({
287
287
  eventName: _TelemetryConstants.BroadcastEvent.OnWidgetError,
288
288
  payload: {
@@ -445,6 +445,48 @@ let FacadeChatSDK = /*#__PURE__*/function () {
445
445
  let optionalParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
446
446
  return this.validateAndExecuteCall("getAgentAvailability", () => this.chatSDK.getAgentAvailability(optionalParams));
447
447
  }
448
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
449
+ }, {
450
+ key: "getReconnectableChats",
451
+ value: async function getReconnectableChats() {
452
+ let reconnectableChatsParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
453
+ /**
454
+ *
455
+ * This is a particular case, we dont expose getReconnectableChats in the SDK,
456
+ * The only way to use is by tunneling directly from the SDK to OCSDK,
457
+ *
458
+ * In case of prechat, the function is called before any formal authentication is made,
459
+ * this is an specific case for persistent chats, to prevent the survey be loaded again for an on going chat,
460
+ *
461
+ * In this case, we check for existance of the token , otherwise we perform the authentication, error is propagated in case of issues.
462
+ *
463
+ * Once the token is obtained , this will be added to the params to call the function.
464
+ *
465
+ * This is a particular case, should not be taken as pattern.
466
+ *
467
+ */
468
+
469
+ if (this.token === null || this.token === "") {
470
+ // If token is not set, try to get it using tokenRing
471
+ const pingResponse = await this.tokenRing();
472
+ if (pingResponse.result === false) {
473
+ const errorMessage = "Authentication Setup Error: Token validation failed for reconnectable chats";
474
+ //telemetry is already logged in tokenRing, so no need to log again, just return the error and communicate to the console
475
+ console.error(`Authentication failed: Process to get a token failed for getReconnectableChats, ${pingResponse.message}`);
476
+ _omnichannelChatComponents.BroadcastService.postMessage({
477
+ eventName: _TelemetryConstants.BroadcastEvent.OnWidgetError,
478
+ payload: {
479
+ errorMessage: errorMessage
480
+ }
481
+ });
482
+ throw new Error(errorMessage);
483
+ }
484
+ }
485
+
486
+ // Always override the token in params regardless of how getReconnectableChats was called
487
+ reconnectableChatsParams.authenticatedUserToken = this.token;
488
+ return this.validateAndExecuteCall("getReconnectableChats", () => this.chatSDK.OCClient.getReconnectableChats(reconnectableChatsParams));
489
+ }
448
490
  }]);
449
491
  return FacadeChatSDK;
450
492
  }();
@@ -39,7 +39,7 @@ const ChatButtonStateful = props => {
39
39
  } = props;
40
40
  //Setting OutOfOperatingHours Flag
41
41
  //Setting OutOfOperatingHours Flag - to string conversion to normalize the value (could be boolean from other states or string directly from config)
42
- const [outOfOperatingHours, setOutOfOperatingHours] = (0, _react.useState)(state.appStates.outsideOperatingHours);
42
+ const [outOfOperatingHours, setOutOfOperatingHours] = (0, _react.useState)(false);
43
43
  const ref = (0, _react.useRef)(() => {
44
44
  return;
45
45
  });
@@ -100,7 +100,6 @@ const ChatButtonStateful = props => {
100
100
  ...(outOfOfficeButtonProps === null || outOfOfficeButtonProps === void 0 ? void 0 : outOfOfficeButtonProps.controlProps)
101
101
  };
102
102
  (0, _react.useEffect)(() => {
103
- setOutOfOperatingHours(state.appStates.outsideOperatingHours);
104
103
  _TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
105
104
  Event: _TelemetryConstants.TelemetryEvent.LCWChatButtonShow,
106
105
  ElapsedTimeInMilliseconds: _TelemetryManager.TelemetryTimers.LcwLoadToChatButtonTimer.milliSecondsElapsed
@@ -119,6 +118,13 @@ const ChatButtonStateful = props => {
119
118
  ElapsedTimeInMilliseconds: uiTimer.milliSecondsElapsed
120
119
  });
121
120
  }, []);
121
+ (0, _react.useEffect)(() => {
122
+ if (state.appStates.conversationState === _ConversationState.ConversationState.Closed) {
123
+ // If the conversation state is closed, check if we are outside operating hours
124
+ const isOutsideOperatingHours = state.appStates.outsideOperatingHours;
125
+ setOutOfOperatingHours(isOutsideOperatingHours);
126
+ }
127
+ }, [state.appStates.conversationState]);
122
128
  return /*#__PURE__*/_react.default.createElement(_omnichannelChatComponents.ChatButton, {
123
129
  componentOverrides: buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.componentOverrides,
124
130
  controlProps: outOfOperatingHours ? outOfOfficeControlProps : controlProps,
@@ -84,9 +84,13 @@ const ConfirmationPaneStateful = props => {
84
84
  (0, _react.useEffect)(() => {
85
85
  (0, _utils.preventFocusToMoveOutOfElement)(controlProps.id);
86
86
  const focusableElements = (0, _utils.findAllFocusableElement)(`#${controlProps.id}`);
87
- if (focusableElements) {
88
- focusableElements[0].focus();
89
- }
87
+ requestAnimationFrame(() => {
88
+ if (focusableElements && focusableElements.length > 0 && focusableElements[0]) {
89
+ focusableElements[0].focus({
90
+ preventScroll: true
91
+ });
92
+ }
93
+ });
90
94
  elements = (0, _utils.findParentFocusableElementsWithoutChildContainer)(controlProps.id);
91
95
  (0, _utils.setTabIndices)(elements, initialTabIndexMap, false);
92
96
  _TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
@@ -37,7 +37,7 @@ const HeaderStateful = props => {
37
37
  endChat
38
38
  } = props;
39
39
  //Setting OutOfOperatingHours Flag
40
- const [outOfOperatingHours, setOutOfOperatingHours] = (0, _react.useState)(state.appStates.outsideOperatingHours);
40
+ const [outOfOperatingHours, setOutOfOperatingHours] = (0, _react.useState)(false);
41
41
  const outOfOfficeStyleProps = Object.assign({}, _defaultOutOfOfficeHeaderStyleProps.defaultOutOfOfficeHeaderStyleProps, outOfOfficeHeaderProps === null || outOfOfficeHeaderProps === void 0 ? void 0 : outOfOfficeHeaderProps.styleProps);
42
42
 
43
43
  // For some reason state object is not getting updated values in this component
@@ -120,9 +120,6 @@ const HeaderStateful = props => {
120
120
  ...(outOfOfficeHeaderProps === null || outOfOfficeHeaderProps === void 0 ? void 0 : outOfOfficeHeaderProps.controlProps),
121
121
  hideCloseButton: state.appStates.conversationState === _ConversationState.ConversationState.OutOfOffice || (outOfOfficeHeaderProps === null || outOfOfficeHeaderProps === void 0 ? void 0 : (_outOfOfficeHeaderPro = outOfOfficeHeaderProps.controlProps) === null || _outOfOfficeHeaderPro === void 0 ? void 0 : _outOfOfficeHeaderPro.hideCloseButton)
122
122
  };
123
- (0, _react.useEffect)(() => {
124
- setOutOfOperatingHours(state.appStates.outsideOperatingHours);
125
- }, []);
126
123
  (0, _react.useEffect)(() => {
127
124
  var _state$domainStates2;
128
125
  localConfirmationPaneState.current = state === null || state === void 0 ? void 0 : (_state$domainStates2 = state.domainStates) === null || _state$domainStates2 === void 0 ? void 0 : _state$domainStates2.confirmationState;
@@ -138,6 +135,13 @@ const HeaderStateful = props => {
138
135
  ElapsedTimeInMilliseconds: uiTimer.milliSecondsElapsed
139
136
  });
140
137
  }, []);
138
+ (0, _react.useEffect)(() => {
139
+ if (state.appStates.conversationState === _ConversationState.ConversationState.Closed) {
140
+ // If the conversation state is closed, check if we are outside operating hours
141
+ const isOutsideOperatingHours = state.appStates.outsideOperatingHours;
142
+ setOutOfOperatingHours(isOutsideOperatingHours);
143
+ }
144
+ }, [state.appStates.conversationState]);
141
145
  if (props.draggable === true) {
142
146
  var _generalStyleProps;
143
147
  const styleProps = outOfOperatingHours || state.appStates.conversationState === _ConversationState.ConversationState.OutOfOffice ? outOfOfficeStyleProps : headerProps === null || headerProps === void 0 ? void 0 : headerProps.styleProps;
@@ -16,14 +16,15 @@ var _createReducer = require("../../contexts/createReducer");
16
16
  var _LiveChatWidgetContextInitialState = require("../../contexts/common/LiveChatWidgetContextInitialState");
17
17
  var _getMockChatSDKIfApplicable = require("./common/getMockChatSDKIfApplicable");
18
18
  var _utils = require("../../common/utils");
19
+ var _liveChatConfigUtils = require("./common/liveChatConfigUtils");
20
+ var _startChatErrorHandler = require("./common/startChatErrorHandler");
19
21
  var _overridePropsOnMockIfApplicable = _interopRequireDefault(require("./common/overridePropsOnMockIfApplicable"));
20
22
  var _registerTelemetryLoggers = require("./common/registerTelemetryLoggers");
21
- var _startChatErrorHandler = require("./common/startChatErrorHandler");
22
23
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
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); }
24
25
  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; }
25
26
  const LiveChatWidget = props => {
26
- var _props$mock, _props$featureConfigP, _props$chatConfig, _props$chatConfig$Liv;
27
+ var _props$mock, _props$featureConfigP, _props$chatConfig, _props$chatConfig$Liv, _props$chatConfig2, _props$chatConfig2$Li;
27
28
  const reducer = (0, _createReducer.createReducer)();
28
29
  const [state, dispatch] = (0, _react.useReducer)(reducer, (0, _LiveChatWidgetContextInitialState.getLiveChatWidgetContextInitialState)(props));
29
30
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -37,7 +38,7 @@ const LiveChatWidget = props => {
37
38
  }
38
39
 
39
40
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
40
- const isAuthenticatedChat = !!((_props$chatConfig = props.chatConfig) !== null && _props$chatConfig !== void 0 && (_props$chatConfig$Liv = _props$chatConfig.LiveChatConfigAuthSettings) !== null && _props$chatConfig$Liv !== void 0 && _props$chatConfig$Liv.msdyn_javascriptclientfunction);
41
+ const isAuthenticatedChat = !!((_props$chatConfig = props.chatConfig) !== null && _props$chatConfig !== void 0 && (_props$chatConfig$Liv = _props$chatConfig.LiveChatConfigAuthSettings) !== null && _props$chatConfig$Liv !== void 0 && _props$chatConfig$Liv.msdyn_javascriptclientfunction) || (0, _liveChatConfigUtils.isPersistentChatEnabled)((_props$chatConfig2 = props.chatConfig) === null || _props$chatConfig2 === void 0 ? void 0 : (_props$chatConfig2$Li = _props$chatConfig2.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig2$Li === void 0 ? void 0 : _props$chatConfig2$Li.msdyn_conversationmode);
41
42
  if (!facadeChatSDK) {
42
43
  var _props$mock2;
43
44
  setFacadeChatSDK(new _FacadeChatSDK.FacadeChatSDK({
@@ -13,7 +13,7 @@ const isPostChatSurveyEnabled = async facadeChatSDK => {
13
13
  return postChatEnabled === "true";
14
14
  };
15
15
  exports.isPostChatSurveyEnabled = isPostChatSurveyEnabled;
16
- const isPersistentChatEnabled = async conversationMode => {
16
+ const isPersistentChatEnabled = conversationMode => {
17
17
  if ((0, _utils.isNullOrUndefined)(conversationMode)) {
18
18
  return false;
19
19
  }
@@ -6,16 +6,23 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.shouldSetPreChatIfPersistentChat = void 0;
7
7
  var _liveChatConfigUtils = require("./liveChatConfigUtils");
8
8
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
9
- const shouldSetPreChatIfPersistentChat = async (chatSDK, conversationMode, showPreChat) => {
10
- const persistentEnabled = await (0, _liveChatConfigUtils.isPersistentChatEnabled)(conversationMode);
9
+ const shouldSetPreChatIfPersistentChat = async (facadeChatSDK, conversationMode, showPreChat) => {
10
+ const persistentEnabled = (0, _liveChatConfigUtils.isPersistentChatEnabled)(conversationMode);
11
11
  let skipPreChat = false;
12
12
  if (persistentEnabled) {
13
+ // Access private properties using type assertions
14
+ const chatSDK = facadeChatSDK.getChatSDK();
15
+
16
+ // Use type assertion to bypass private access restriction
17
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
18
+ const sdkAsAny = chatSDK;
19
+ // most likely this is not set , the facade will take care of it
13
20
  const reconnectableChatsParams = {
14
- authenticatedUserToken: chatSDK.authenticatedUserToken,
15
- requestId: chatSDK.requestId
21
+ authenticatedUserToken: sdkAsAny.authenticatedUserToken,
22
+ requestId: sdkAsAny.requestId
16
23
  };
17
24
  try {
18
- const reconnectableChatsResponse = await chatSDK.OCClient.getReconnectableChats(reconnectableChatsParams);
25
+ const reconnectableChatsResponse = await facadeChatSDK.getReconnectableChats(reconnectableChatsParams);
19
26
  if (reconnectableChatsResponse && reconnectableChatsResponse.reconnectid) {
20
27
  // Skip rendering prechat on existing persistent chat session
21
28
  skipPreChat = true;
@@ -75,7 +75,7 @@ const setPreChatAndInitiateChat = async (facadeChatSDK, dispatch, setAdapter, is
75
75
  const parseToJson = false;
76
76
  const preChatSurveyResponse = (props === null || props === void 0 ? void 0 : (_props$preChatSurveyP = props.preChatSurveyPaneProps) === null || _props$preChatSurveyP === void 0 ? void 0 : (_props$preChatSurveyP2 = _props$preChatSurveyP.controlProps) === null || _props$preChatSurveyP2 === void 0 ? void 0 : _props$preChatSurveyP2.payload) ?? (await facadeChatSDK.getPreChatSurvey(parseToJson));
77
77
  let showPrechat = isProactiveChat ? preChatSurveyResponse && proactiveChatEnablePrechatState : preChatSurveyResponse && !(props !== null && props !== void 0 && (_props$controlProps = props.controlProps) !== null && _props$controlProps !== void 0 && _props$controlProps.hidePreChatSurveyPane);
78
- showPrechat = await (0, _persistentChatHelper.shouldSetPreChatIfPersistentChat)(facadeChatSDK.getChatSDK(), state === null || state === void 0 ? void 0 : (_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : (_state$domainStates$l = _state$domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : (_state$domainStates$l2 = _state$domainStates$l.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l2 === void 0 ? void 0 : _state$domainStates$l2.msdyn_conversationmode, showPrechat);
78
+ showPrechat = await (0, _persistentChatHelper.shouldSetPreChatIfPersistentChat)(facadeChatSDK, state === null || state === void 0 ? void 0 : (_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : (_state$domainStates$l = _state$domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : (_state$domainStates$l2 = _state$domainStates$l.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l2 === void 0 ? void 0 : _state$domainStates$l2.msdyn_conversationmode, showPrechat);
79
79
  if (showPrechat) {
80
80
  var _state$domainStates2, _state$domainStates2$, _state$domainStates2$2, _state$domainStates2$3;
81
81
  const isOutOfOperatingHours = (state === null || state === void 0 ? void 0 : (_state$domainStates2 = state.domainStates) === null || _state$domainStates2 === void 0 ? void 0 : (_state$domainStates2$ = _state$domainStates2.liveChatConfig) === null || _state$domainStates2$ === void 0 ? void 0 : (_state$domainStates2$2 = _state$domainStates2$.LiveWSAndLiveChatEngJoin) === null || _state$domainStates2$2 === void 0 ? void 0 : (_state$domainStates2$3 = _state$domainStates2$2.OutOfOperatingHours) === null || _state$domainStates2$3 === void 0 ? void 0 : _state$domainStates2$3.toString().toLowerCase()) === "true";
@@ -163,7 +163,7 @@ exports.setPreChatAndInitiateChat = setPreChatAndInitiateChat;
163
163
  const initStartChat = async (facadeChatSDK, dispatch, setAdapter, state, props, params, persistedState) => {
164
164
  var _state$domainStates7, _state$domainStates7$, _state$domainStates7$2;
165
165
  let isStartChatSuccessful = false;
166
- const persistentChatEnabled = await (0, _liveChatConfigUtils.isPersistentChatEnabled)(state === null || state === void 0 ? void 0 : (_state$domainStates7 = state.domainStates) === null || _state$domainStates7 === void 0 ? void 0 : (_state$domainStates7$ = _state$domainStates7.liveChatConfig) === null || _state$domainStates7$ === void 0 ? void 0 : (_state$domainStates7$2 = _state$domainStates7$.LiveWSAndLiveChatEngJoin) === null || _state$domainStates7$2 === void 0 ? void 0 : _state$domainStates7$2.msdyn_conversationmode);
166
+ const persistentChatEnabled = (0, _liveChatConfigUtils.isPersistentChatEnabled)(state === null || state === void 0 ? void 0 : (_state$domainStates7 = state.domainStates) === null || _state$domainStates7 === void 0 ? void 0 : (_state$domainStates7$ = _state$domainStates7.liveChatConfig) === null || _state$domainStates7$ === void 0 ? void 0 : (_state$domainStates7$2 = _state$domainStates7$.LiveWSAndLiveChatEngJoin) === null || _state$domainStates7$2 === void 0 ? void 0 : _state$domainStates7$2.msdyn_conversationmode);
167
167
  if ((state === null || state === void 0 ? void 0 : state.appStates.conversationState) === _ConversationState.ConversationState.Closed) {
168
168
  // Preventive reset to avoid starting chat with previous requestId which could potentially cause problems
169
169
  (0, _endChat.chatSDKStateCleanUp)(facadeChatSDK.getChatSDK());
@@ -15,6 +15,11 @@ var _StartChatFailureType = require("../../../contexts/common/StartChatFailureTy
15
15
  var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
16
16
  var _TelemetryManager = require("../../../common/telemetry/TelemetryManager");
17
17
  var _utils = require("../../../common/utils");
18
+ // Helper function to check if error is authentication-related
19
+ const isAuthenticationError = errorMessage => {
20
+ return errorMessage === _Constants.WidgetLoadCustomErrorString.AuthenticationFailedErrorString || errorMessage.startsWith("Authentication Setup Error:") || errorMessage.includes("Token validation failed") || errorMessage.includes("Authentication token");
21
+ };
22
+
18
23
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
19
24
  const handleStartChatError = (dispatch, facadeChatSDK, props, ex, isStartChatSuccessful) => {
20
25
  var _props$controlProps;
@@ -23,19 +28,16 @@ const handleStartChatError = (dispatch, facadeChatSDK, props, ex, isStartChatSuc
23
28
  return;
24
29
  }
25
30
 
26
- // Handle internal or misc errors
27
- if (ex.message === _Constants.WidgetLoadCustomErrorString.AuthenticationFailedErrorString) {
31
+ // Handle authentication-related errors
32
+ if (isAuthenticationError(ex.message)) {
28
33
  dispatch({
29
34
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_START_CHAT_FAILURE_TYPE,
30
35
  payload: _StartChatFailureType.StartChatFailureType.AuthSetupError
31
36
  });
32
- // set conversation to error to enforce error UI pane
33
- dispatch({
34
- type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
35
- payload: _ConversationState.ConversationState.Error
36
- });
37
37
  logWidgetLoadCompleteWithError(ex);
38
+ // Don't return early - let the generic error handling logic handle hideErrorUIPane and telemetry
38
39
  }
40
+
39
41
  if (ex.message === _Constants.WidgetLoadCustomErrorString.NetworkErrorString) {
40
42
  logWidgetLoadCompleteWithError(ex);
41
43
  }
@@ -58,8 +60,11 @@ const handleStartChatError = (dispatch, facadeChatSDK, props, ex, isStartChatSuc
58
60
  case _omnichannelChatSdk.ChatSDKErrorName.UninitializedChatSDK:
59
61
  handleUninitializedChatSDK(ex);
60
62
  break;
61
- // Handle the case indicating failure to retrieve an authenticated chat conversation
62
63
  case _omnichannelChatSdk.ChatSDKErrorName.AuthenticatedChatConversationRetrievalFailure:
64
+ dispatch({
65
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_START_CHAT_FAILURE_TYPE,
66
+ payload: _StartChatFailureType.StartChatFailureType.Unauthorized
67
+ });
63
68
  logWidgetLoadCompleteWithError(ex);
64
69
  break;
65
70
  case _omnichannelChatSdk.ChatSDKErrorName.InvalidConversation:
@@ -112,6 +117,9 @@ const logWidgetLoadFailed = ex => {
112
117
  if (ex !== null && ex !== void 0 && ex.httpResponseStatusCode) {
113
118
  exDetails.HttpResponseStatusCode = ex.httpResponseStatusCode;
114
119
  }
120
+ if (ex !== null && ex !== void 0 && ex.exceptionDetails) {
121
+ exDetails.ChatSDKExceptionDetails = ex.exceptionDetails;
122
+ }
115
123
  _TelemetryHelper.TelemetryHelper.logLoadingEventToAllTelemetry(_TelemetryConstants.LogLevel.ERROR, {
116
124
  Event: _TelemetryConstants.TelemetryEvent.WidgetLoadFailed,
117
125
  Description: "Widget load complete with error",
@@ -141,6 +149,9 @@ const logWidgetLoadCompleteWithError = ex => {
141
149
  if (ex !== null && ex !== void 0 && ex.httpResponseStatusCode) {
142
150
  exDetails.HttpResponseStatusCode = ex.httpResponseStatusCode;
143
151
  }
152
+ if (ex !== null && ex !== void 0 && ex.exceptionDetails) {
153
+ exDetails.ChatSDKExceptionDetails = ex.exceptionDetails;
154
+ }
144
155
  _TelemetryHelper.TelemetryHelper.logLoadingEventToAllTelemetry(_TelemetryConstants.LogLevel.ERROR, {
145
156
  Event: _TelemetryConstants.TelemetryEvent.WidgetLoadFailed,
146
157
  Description: "Widget load complete with error",
@@ -229,6 +240,12 @@ const handleChatTokenRetrievalFailure = (dispatch, ex) => {
229
240
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_START_CHAT_FAILURE_TYPE,
230
241
  payload: _StartChatFailureType.StartChatFailureType.Unauthorized
231
242
  });
243
+ } else {
244
+ // For other authentication-related token retrieval failures, set as AuthSetupError
245
+ dispatch({
246
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_START_CHAT_FAILURE_TYPE,
247
+ payload: _StartChatFailureType.StartChatFailureType.AuthSetupError
248
+ });
232
249
  }
233
250
  logWidgetLoadCompleteWithError(ex);
234
251
  }
@@ -63,7 +63,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
63
63
  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); }
64
64
  let uiTimer;
65
65
  const LiveChatWidgetStateful = props => {
66
- var _props$webChatContain, _props$styleProps, _props$webChatContain2, _props$webChatContain3, _props$controlProps, _props$controlProps3, _state$appStates7, _props$webChatContain7, _state$appStates14, _props$webChatContain9, _props$webChatContain10, _props$controlProps12, _props$draggableChatW, _props$draggableChatW2, _props$draggableChatW3, _props$draggableChatW4, _props$draggableChatW5, _livechatProps$webCha, _props$webChatContain11, _props$webChatContain12, _props$webChatContain13, _props$webChatContain14, _props$webChatContain15, _props$webChatContain16, _props$webChatContain17, _props$webChatContain18, _livechatProps$styleP, _livechatProps$contro, _livechatProps$contro2, _livechatProps$compon, _livechatProps$contro3, _livechatProps$compon2, _livechatProps$contro4, _livechatProps$compon3, _livechatProps$contro5, _livechatProps$compon4, _livechatProps$contro6, _livechatProps$compon5, _livechatProps$contro7, _livechatProps$compon6, _livechatProps$contro8, _livechatProps$compon7, _livechatProps$contro9, _livechatProps$compon8, _livechatProps$contro10, _livechatProps$contro11, _livechatProps$compon9, _livechatProps$contro12, _livechatProps$compon10, _livechatProps$contro13, _livechatProps$compon11, _livechatProps$compon12, _livechatProps$compon13;
66
+ var _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _props$webChatContain4, _props$webChatContain5, _props$webChatContain6, _props$webChatContain7, _props$webChatContain8, _props$webChatContain9, _props$styleProps, _props$webChatContain10, _props$webChatContain11, _props$controlProps, _props$controlProps3, _state$appStates7, _props$webChatContain15, _state$appStates14, _props$webChatContain17, _props$webChatContain18, _props$controlProps12, _props$draggableChatW, _props$draggableChatW2, _props$draggableChatW3, _props$draggableChatW4, _props$draggableChatW5, _livechatProps$webCha, _livechatProps$styleP, _livechatProps$contro, _livechatProps$contro2, _livechatProps$compon, _livechatProps$contro3, _livechatProps$compon2, _livechatProps$contro4, _livechatProps$compon3, _livechatProps$contro5, _livechatProps$compon4, _livechatProps$contro6, _livechatProps$compon5, _livechatProps$contro7, _livechatProps$compon6, _livechatProps$contro8, _livechatProps$compon7, _livechatProps$contro9, _livechatProps$compon8, _livechatProps$contro10, _livechatProps$contro11, _livechatProps$compon9, _livechatProps$contro12, _livechatProps$compon10, _livechatProps$contro13, _livechatProps$compon11, _livechatProps$compon12, _livechatProps$compon13;
67
67
  (0, _react2.useEffect)(() => {
68
68
  uiTimer = (0, _utils.createTimer)();
69
69
  _TelemetryHelper.TelemetryHelper.logLoadingEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
@@ -87,6 +87,8 @@ const LiveChatWidgetStateful = props => {
87
87
  Composer
88
88
  } = _botframeworkWebchat.Components;
89
89
  const canStartProactiveChat = (0, _react2.useRef)(true);
90
+ const bubbleBackground = ((_props$webChatContain2 = props.webChatContainerProps) === null || _props$webChatContain2 === void 0 ? void 0 : (_props$webChatContain3 = _props$webChatContain2.webChatStyles) === null || _props$webChatContain3 === void 0 ? void 0 : _props$webChatContain3.bubbleBackground) ?? ((_props$webChatContain4 = props.webChatContainerProps) === null || _props$webChatContain4 === void 0 ? void 0 : (_props$webChatContain5 = _props$webChatContain4.adaptiveCardStyles) === null || _props$webChatContain5 === void 0 ? void 0 : _props$webChatContain5.background) ?? _defaultAdaptiveCardStyles.defaultAdaptiveCardStyles.background;
91
+ const bubbleTextColor = ((_props$webChatContain6 = props.webChatContainerProps) === null || _props$webChatContain6 === void 0 ? void 0 : (_props$webChatContain7 = _props$webChatContain6.webChatStyles) === null || _props$webChatContain7 === void 0 ? void 0 : _props$webChatContain7.bubbleTextColor) ?? ((_props$webChatContain8 = props.webChatContainerProps) === null || _props$webChatContain8 === void 0 ? void 0 : (_props$webChatContain9 = _props$webChatContain8.adaptiveCardStyles) === null || _props$webChatContain9 === void 0 ? void 0 : _props$webChatContain9.color) ?? _defaultAdaptiveCardStyles.defaultAdaptiveCardStyles.color;
90
92
 
91
93
  // Process general styles
92
94
  const generalStyles = {
@@ -95,7 +97,7 @@ const LiveChatWidgetStateful = props => {
95
97
 
96
98
  //Scrollbar styles
97
99
  const scrollbarProps = Object.assign({}, _defaultScrollBarProps.defaultScrollBarProps, props === null || props === void 0 ? void 0 : props.scrollBarProps);
98
- const sendBoxTextArea = props === null || props === void 0 ? void 0 : (_props$webChatContain2 = props.webChatContainerProps) === null || _props$webChatContain2 === void 0 ? void 0 : (_props$webChatContain3 = _props$webChatContain2.sendBoxTextBox) === null || _props$webChatContain3 === void 0 ? void 0 : _props$webChatContain3.textarea;
100
+ const sendBoxTextArea = props === null || props === void 0 ? void 0 : (_props$webChatContain10 = props.webChatContainerProps) === null || _props$webChatContain10 === void 0 ? void 0 : (_props$webChatContain11 = _props$webChatContain10.sendBoxTextBox) === null || _props$webChatContain11 === void 0 ? void 0 : _props$webChatContain11.textarea;
99
101
 
100
102
  // In case the broadcast channel is already initialized elsewhere; One tab can only hold 1 instance
101
103
  if ((props === null || props === void 0 ? void 0 : (_props$controlProps = props.controlProps) === null || _props$controlProps === void 0 ? void 0 : _props$controlProps.skipBroadcastChannelInit) !== true) {
@@ -282,7 +284,8 @@ const LiveChatWidgetStateful = props => {
282
284
  var _state$appStates6;
283
285
  if ((state === null || state === void 0 ? void 0 : (_state$appStates6 = state.appStates) === null || _state$appStates6 === void 0 ? void 0 : _state$appStates6.hideStartChatButton) === true) {
284
286
  //handle OOH pane
285
- if (state.appStates.outsideOperatingHours === true) {
287
+ // Only set OutOfOffice state for new conversations, allow existing Active/InActive conversations to continue
288
+ if (state.appStates.outsideOperatingHours === true && state.appStates.conversationState !== _ConversationState.ConversationState.Active) {
286
289
  dispatch({
287
290
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
288
291
  payload: _ConversationState.ConversationState.OutOfOffice
@@ -631,8 +634,8 @@ const LiveChatWidgetStateful = props => {
631
634
  });
632
635
  }
633
636
  if (state.appStates.conversationState === _ConversationState.ConversationState.InActive) {
634
- var _props$webChatContain4, _props$webChatContain5;
635
- if ((props === null || props === void 0 ? void 0 : (_props$webChatContain4 = props.webChatContainerProps) === null || _props$webChatContain4 === void 0 ? void 0 : (_props$webChatContain5 = _props$webChatContain4.renderingMiddlewareProps) === null || _props$webChatContain5 === void 0 ? void 0 : _props$webChatContain5.hideSendboxOnConversationEnd) !== false) {
637
+ var _props$webChatContain12, _props$webChatContain13;
638
+ if ((props === null || props === void 0 ? void 0 : (_props$webChatContain12 = props.webChatContainerProps) === null || _props$webChatContain12 === void 0 ? void 0 : (_props$webChatContain13 = _props$webChatContain12.renderingMiddlewareProps) === null || _props$webChatContain13 === void 0 ? void 0 : _props$webChatContain13.hideSendboxOnConversationEnd) !== false) {
636
639
  setWebChatStyles(styles => {
637
640
  return {
638
641
  ...styles,
@@ -676,12 +679,12 @@ const LiveChatWidgetStateful = props => {
676
679
  }
677
680
  }, [state.appStates.unreadMessageCount]);
678
681
  (0, _react2.useEffect)(() => {
679
- var _props$webChatContain6;
682
+ var _props$webChatContain14;
680
683
  setWebChatStyles({
681
684
  ...webChatStyles,
682
- ...((_props$webChatContain6 = props.webChatContainerProps) === null || _props$webChatContain6 === void 0 ? void 0 : _props$webChatContain6.webChatStyles)
685
+ ...((_props$webChatContain14 = props.webChatContainerProps) === null || _props$webChatContain14 === void 0 ? void 0 : _props$webChatContain14.webChatStyles)
683
686
  });
684
- }, [(_props$webChatContain7 = props.webChatContainerProps) === null || _props$webChatContain7 === void 0 ? void 0 : _props$webChatContain7.webChatStyles]);
687
+ }, [(_props$webChatContain15 = props.webChatContainerProps) === null || _props$webChatContain15 === void 0 ? void 0 : _props$webChatContain15.webChatStyles]);
685
688
  (0, _react2.useEffect)(() => {
686
689
  //Confirmation pane dismissing through OK option, so proceed with end chat
687
690
  if (state.domainStates.confirmationState === _Constants.ConfirmationState.Ok) {
@@ -780,12 +783,12 @@ const LiveChatWidgetStateful = props => {
780
783
 
781
784
  // if props state gets updates we need to update the renderingMiddlewareProps in the state
782
785
  (0, _react2.useEffect)(() => {
783
- var _props$webChatContain8;
786
+ var _props$webChatContain16;
784
787
  dispatch({
785
788
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_RENDERING_MIDDLEWARE_PROPS,
786
- payload: (_props$webChatContain8 = props.webChatContainerProps) === null || _props$webChatContain8 === void 0 ? void 0 : _props$webChatContain8.renderingMiddlewareProps
789
+ payload: (_props$webChatContain16 = props.webChatContainerProps) === null || _props$webChatContain16 === void 0 ? void 0 : _props$webChatContain16.renderingMiddlewareProps
787
790
  });
788
- }, [(_props$webChatContain9 = props.webChatContainerProps) === null || _props$webChatContain9 === void 0 ? void 0 : _props$webChatContain9.renderingMiddlewareProps]);
791
+ }, [(_props$webChatContain17 = props.webChatContainerProps) === null || _props$webChatContain17 === void 0 ? void 0 : _props$webChatContain17.renderingMiddlewareProps]);
789
792
  (0, _react2.useEffect)(() => {
790
793
  _TelemetryHelper.TelemetryHelper.logLoadingEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
791
794
  Event: _TelemetryConstants.TelemetryEvent.UXLiveChatWidgetCompleted,
@@ -828,7 +831,7 @@ const LiveChatWidgetStateful = props => {
828
831
  const webChatProps = (0, _initWebChatComposer.initWebChatComposer)(props, state, dispatch, facadeChatSDK, endChatRelay);
829
832
  const downloadTranscriptProps = (0, _createDownloadTranscriptProps.default)(props.downloadTranscriptProps, {
830
833
  ...(_defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps === null || _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps === void 0 ? void 0 : _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.webChatStyles),
831
- ...((_props$webChatContain10 = props.webChatContainerProps) === null || _props$webChatContain10 === void 0 ? void 0 : _props$webChatContain10.webChatStyles)
834
+ ...((_props$webChatContain18 = props.webChatContainerProps) === null || _props$webChatContain18 === void 0 ? void 0 : _props$webChatContain18.webChatStyles)
832
835
  }, props.webChatContainerProps);
833
836
  const livechatProps = {
834
837
  ...props,
@@ -854,6 +857,11 @@ const LiveChatWidgetStateful = props => {
854
857
  (0, _utils.setOcUserAgent)(facadeChatSDK.getChatSDK());
855
858
  const directLine = ((_livechatProps$webCha = livechatProps.webChatContainerProps) === null || _livechatProps$webCha === void 0 ? void 0 : _livechatProps$webCha.directLine) ?? adapter ?? _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.directLine;
856
859
  const userID = directLine.getState ? directLine === null || directLine === void 0 ? void 0 : directLine.getState("acs.userId") : "teamsvisitor";
860
+ const styleOptions = _react2.default.useMemo(() => ({
861
+ ...webChatStyles,
862
+ bubbleBackground,
863
+ bubbleTextColor
864
+ }), [webChatStyles, bubbleBackground, bubbleTextColor]);
857
865
 
858
866
  // WebChat's Composer can only be rendered if a directLine object is defined
859
867
  return directLine && /*#__PURE__*/_react2.default.createElement(_react2.default.Fragment, null, /*#__PURE__*/_react2.default.createElement("style", null, `
@@ -892,11 +900,7 @@ const LiveChatWidgetStateful = props => {
892
900
  }`}
893
901
  `), /*#__PURE__*/_react2.default.createElement(_DraggableChatWidget.default, chatWidgetDraggableConfig, /*#__PURE__*/_react2.default.createElement(Composer, _extends({}, webChatProps, {
894
902
  userID: userID,
895
- styleOptions: {
896
- ...webChatStyles,
897
- bubbleBackground: ((_props$webChatContain11 = props.webChatContainerProps) === null || _props$webChatContain11 === void 0 ? void 0 : (_props$webChatContain12 = _props$webChatContain11.webChatStyles) === null || _props$webChatContain12 === void 0 ? void 0 : _props$webChatContain12.bubbleBackground) ?? ((_props$webChatContain13 = props.webChatContainerProps) === null || _props$webChatContain13 === void 0 ? void 0 : (_props$webChatContain14 = _props$webChatContain13.adaptiveCardStyles) === null || _props$webChatContain14 === void 0 ? void 0 : _props$webChatContain14.background) ?? _defaultAdaptiveCardStyles.defaultAdaptiveCardStyles.background,
898
- bubbleTextColor: ((_props$webChatContain15 = props.webChatContainerProps) === null || _props$webChatContain15 === void 0 ? void 0 : (_props$webChatContain16 = _props$webChatContain15.webChatStyles) === null || _props$webChatContain16 === void 0 ? void 0 : _props$webChatContain16.bubbleTextColor) ?? ((_props$webChatContain17 = props.webChatContainerProps) === null || _props$webChatContain17 === void 0 ? void 0 : (_props$webChatContain18 = _props$webChatContain17.adaptiveCardStyles) === null || _props$webChatContain18 === void 0 ? void 0 : _props$webChatContain18.color) ?? _defaultAdaptiveCardStyles.defaultAdaptiveCardStyles.color
899
- },
903
+ styleOptions: styleOptions,
900
904
  directLine: directLine
901
905
  }), /*#__PURE__*/_react2.default.createElement(_react.Stack, {
902
906
  id: widgetElementId,
@@ -30,7 +30,7 @@ const getLiveChatWidgetContextInitialState = props => {
30
30
  * as part of the flow, the pre-chat will be detected and then it will be displayed properly
31
31
  * this case is only and only for pre-chat pane.
32
32
  * **/
33
- if (initialStateFromCache.appStates.conversationState === _ConversationState.ConversationState.Prechat || initialStateFromCache.appStates.conversationState === _ConversationState.ConversationState.OutOfOffice || outsideOperatingHours) {
33
+ if (initialStateFromCache.appStates.conversationState === _ConversationState.ConversationState.Prechat || initialStateFromCache.appStates.conversationState === _ConversationState.ConversationState.OutOfOffice || outsideOperatingHours && initialStateFromCache.appStates.conversationState !== _ConversationState.ConversationState.Active) {
34
34
  initialStateFromCache.appStates.conversationState = _ConversationState.ConversationState.Closed;
35
35
  // if we are resetting the conversation state, there is no point to obtain minimized state from cache
36
36
  initialStateFromCache.appStates.isMinimized = undefined;
@@ -103,7 +103,7 @@ export let FacadeChatSDK = /*#__PURE__*/function () {
103
103
  token: last3digits
104
104
  }
105
105
  });
106
- throw new Error("Invalid token format, must be in JWT format");
106
+ throw new Error("Authentication Setup Error: Invalid token format, must be in JWT format");
107
107
  }
108
108
  try {
109
109
  const payload = this.enforceBase64Encoding(tokenParts[1]);
@@ -125,9 +125,9 @@ export let FacadeChatSDK = /*#__PURE__*/function () {
125
125
  token: last3digits
126
126
  }
127
127
  });
128
- throw new Error("Invalid token payload, payload is not valid JSON");
128
+ throw new Error("Authentication Setup Error: Invalid token payload, payload is not valid JSON");
129
129
  } catch (e) {
130
- console.error("Failed to decode token", e);
130
+ console.error("Authentication Setup Error: Failed to decode token", e);
131
131
  TelemetryHelper.logFacadeChatSDKEventToAllTelemetry(LogLevel.ERROR, {
132
132
  Event: TelemetryEvent.NewTokenValidationFailed,
133
133
  Description: "Failed to decode token",
@@ -136,7 +136,7 @@ export let FacadeChatSDK = /*#__PURE__*/function () {
136
136
  token: last3digits
137
137
  }
138
138
  });
139
- throw new Error("Failed to decode token");
139
+ throw new Error("Authentication Setup Error: Failed to decode authentication token");
140
140
  }
141
141
  }
142
142
  }, {
@@ -160,7 +160,7 @@ export let FacadeChatSDK = /*#__PURE__*/function () {
160
160
  "Token": last3digits
161
161
  }
162
162
  });
163
- throw new Error(`New token is already expired, with epoch time ${this.expiration} , last 3 digits of token: ${last3digits}`);
163
+ throw new Error("Authentication Setup Error: New authentication token is already expired");
164
164
  }
165
165
  }
166
166
  }
@@ -274,9 +274,9 @@ export let FacadeChatSDK = /*#__PURE__*/function () {
274
274
  if (pingResponse.result === true) {
275
275
  return fn();
276
276
  }
277
- const executionErrorMessage = `Authentication failed: Process to get a token failed for ${functionName}, ${pingResponse.message}`;
277
+ const executionErrorMessage = "Authentication Setup Error: Token validation failed - GetAuthToken function is not present";
278
278
  //telemetry is already logged in tokenRing, so no need to log again, just return the error and communicate to the console
279
- console.error(executionErrorMessage);
279
+ console.error(`${executionErrorMessage} Additional details: Process to get a token failed for ${functionName}, ${pingResponse.message}`);
280
280
  BroadcastService.postMessage({
281
281
  eventName: BroadcastEvent.OnWidgetError,
282
282
  payload: {
@@ -439,6 +439,48 @@ export let FacadeChatSDK = /*#__PURE__*/function () {
439
439
  let optionalParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
440
440
  return this.validateAndExecuteCall("getAgentAvailability", () => this.chatSDK.getAgentAvailability(optionalParams));
441
441
  }
442
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
443
+ }, {
444
+ key: "getReconnectableChats",
445
+ value: async function getReconnectableChats() {
446
+ let reconnectableChatsParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
447
+ /**
448
+ *
449
+ * This is a particular case, we dont expose getReconnectableChats in the SDK,
450
+ * The only way to use is by tunneling directly from the SDK to OCSDK,
451
+ *
452
+ * In case of prechat, the function is called before any formal authentication is made,
453
+ * this is an specific case for persistent chats, to prevent the survey be loaded again for an on going chat,
454
+ *
455
+ * In this case, we check for existance of the token , otherwise we perform the authentication, error is propagated in case of issues.
456
+ *
457
+ * Once the token is obtained , this will be added to the params to call the function.
458
+ *
459
+ * This is a particular case, should not be taken as pattern.
460
+ *
461
+ */
462
+
463
+ if (this.token === null || this.token === "") {
464
+ // If token is not set, try to get it using tokenRing
465
+ const pingResponse = await this.tokenRing();
466
+ if (pingResponse.result === false) {
467
+ const errorMessage = "Authentication Setup Error: Token validation failed for reconnectable chats";
468
+ //telemetry is already logged in tokenRing, so no need to log again, just return the error and communicate to the console
469
+ console.error(`Authentication failed: Process to get a token failed for getReconnectableChats, ${pingResponse.message}`);
470
+ BroadcastService.postMessage({
471
+ eventName: BroadcastEvent.OnWidgetError,
472
+ payload: {
473
+ errorMessage: errorMessage
474
+ }
475
+ });
476
+ throw new Error(errorMessage);
477
+ }
478
+ }
479
+
480
+ // Always override the token in params regardless of how getReconnectableChats was called
481
+ reconnectableChatsParams.authenticatedUserToken = this.token;
482
+ return this.validateAndExecuteCall("getReconnectableChats", () => this.chatSDK.OCClient.getReconnectableChats(reconnectableChatsParams));
483
+ }
442
484
  }]);
443
485
  return FacadeChatSDK;
444
486
  }();
@@ -30,7 +30,7 @@ export const ChatButtonStateful = props => {
30
30
  } = props;
31
31
  //Setting OutOfOperatingHours Flag
32
32
  //Setting OutOfOperatingHours Flag - to string conversion to normalize the value (could be boolean from other states or string directly from config)
33
- const [outOfOperatingHours, setOutOfOperatingHours] = useState(state.appStates.outsideOperatingHours);
33
+ const [outOfOperatingHours, setOutOfOperatingHours] = useState(false);
34
34
  const ref = useRef(() => {
35
35
  return;
36
36
  });
@@ -91,7 +91,6 @@ export const ChatButtonStateful = props => {
91
91
  ...(outOfOfficeButtonProps === null || outOfOfficeButtonProps === void 0 ? void 0 : outOfOfficeButtonProps.controlProps)
92
92
  };
93
93
  useEffect(() => {
94
- setOutOfOperatingHours(state.appStates.outsideOperatingHours);
95
94
  TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
96
95
  Event: TelemetryEvent.LCWChatButtonShow,
97
96
  ElapsedTimeInMilliseconds: TelemetryTimers.LcwLoadToChatButtonTimer.milliSecondsElapsed
@@ -110,6 +109,13 @@ export const ChatButtonStateful = props => {
110
109
  ElapsedTimeInMilliseconds: uiTimer.milliSecondsElapsed
111
110
  });
112
111
  }, []);
112
+ useEffect(() => {
113
+ if (state.appStates.conversationState === ConversationState.Closed) {
114
+ // If the conversation state is closed, check if we are outside operating hours
115
+ const isOutsideOperatingHours = state.appStates.outsideOperatingHours;
116
+ setOutOfOperatingHours(isOutsideOperatingHours);
117
+ }
118
+ }, [state.appStates.conversationState]);
113
119
  return /*#__PURE__*/React.createElement(ChatButton, {
114
120
  componentOverrides: buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.componentOverrides,
115
121
  controlProps: outOfOperatingHours ? outOfOfficeControlProps : controlProps,
@@ -75,9 +75,13 @@ export const ConfirmationPaneStateful = props => {
75
75
  useEffect(() => {
76
76
  preventFocusToMoveOutOfElement(controlProps.id);
77
77
  const focusableElements = findAllFocusableElement(`#${controlProps.id}`);
78
- if (focusableElements) {
79
- focusableElements[0].focus();
80
- }
78
+ requestAnimationFrame(() => {
79
+ if (focusableElements && focusableElements.length > 0 && focusableElements[0]) {
80
+ focusableElements[0].focus({
81
+ preventScroll: true
82
+ });
83
+ }
84
+ });
81
85
  elements = findParentFocusableElementsWithoutChildContainer(controlProps.id);
82
86
  setTabIndices(elements, initialTabIndexMap, false);
83
87
  TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
@@ -28,7 +28,7 @@ export const HeaderStateful = props => {
28
28
  endChat
29
29
  } = props;
30
30
  //Setting OutOfOperatingHours Flag
31
- const [outOfOperatingHours, setOutOfOperatingHours] = useState(state.appStates.outsideOperatingHours);
31
+ const [outOfOperatingHours, setOutOfOperatingHours] = useState(false);
32
32
  const outOfOfficeStyleProps = Object.assign({}, defaultOutOfOfficeHeaderStyleProps, outOfOfficeHeaderProps === null || outOfOfficeHeaderProps === void 0 ? void 0 : outOfOfficeHeaderProps.styleProps);
33
33
 
34
34
  // For some reason state object is not getting updated values in this component
@@ -111,9 +111,6 @@ export const HeaderStateful = props => {
111
111
  ...(outOfOfficeHeaderProps === null || outOfOfficeHeaderProps === void 0 ? void 0 : outOfOfficeHeaderProps.controlProps),
112
112
  hideCloseButton: state.appStates.conversationState === ConversationState.OutOfOffice || (outOfOfficeHeaderProps === null || outOfOfficeHeaderProps === void 0 ? void 0 : (_outOfOfficeHeaderPro = outOfOfficeHeaderProps.controlProps) === null || _outOfOfficeHeaderPro === void 0 ? void 0 : _outOfOfficeHeaderPro.hideCloseButton)
113
113
  };
114
- useEffect(() => {
115
- setOutOfOperatingHours(state.appStates.outsideOperatingHours);
116
- }, []);
117
114
  useEffect(() => {
118
115
  var _state$domainStates2;
119
116
  localConfirmationPaneState.current = state === null || state === void 0 ? void 0 : (_state$domainStates2 = state.domainStates) === null || _state$domainStates2 === void 0 ? void 0 : _state$domainStates2.confirmationState;
@@ -129,6 +126,13 @@ export const HeaderStateful = props => {
129
126
  ElapsedTimeInMilliseconds: uiTimer.milliSecondsElapsed
130
127
  });
131
128
  }, []);
129
+ useEffect(() => {
130
+ if (state.appStates.conversationState === ConversationState.Closed) {
131
+ // If the conversation state is closed, check if we are outside operating hours
132
+ const isOutsideOperatingHours = state.appStates.outsideOperatingHours;
133
+ setOutOfOperatingHours(isOutsideOperatingHours);
134
+ }
135
+ }, [state.appStates.conversationState]);
132
136
  if (props.draggable === true) {
133
137
  var _generalStyleProps;
134
138
  const styleProps = outOfOperatingHours || state.appStates.conversationState === ConversationState.OutOfOffice ? outOfOfficeStyleProps : headerProps === null || headerProps === void 0 ? void 0 : headerProps.styleProps;
@@ -10,11 +10,12 @@ import { createReducer } from "../../contexts/createReducer";
10
10
  import { getLiveChatWidgetContextInitialState } from "../../contexts/common/LiveChatWidgetContextInitialState";
11
11
  import { getMockChatSDKIfApplicable } from "./common/getMockChatSDKIfApplicable";
12
12
  import { isNullOrUndefined } from "../../common/utils";
13
+ import { isPersistentChatEnabled } from "./common/liveChatConfigUtils";
14
+ import { logWidgetLoadWithUnexpectedError } from "./common/startChatErrorHandler";
13
15
  import overridePropsOnMockIfApplicable from "./common/overridePropsOnMockIfApplicable";
14
16
  import { registerTelemetryLoggers } from "./common/registerTelemetryLoggers";
15
- import { logWidgetLoadWithUnexpectedError } from "./common/startChatErrorHandler";
16
17
  export const LiveChatWidget = props => {
17
- var _props$mock, _props$featureConfigP, _props$chatConfig, _props$chatConfig$Liv;
18
+ var _props$mock, _props$featureConfigP, _props$chatConfig, _props$chatConfig$Liv, _props$chatConfig2, _props$chatConfig2$Li;
18
19
  const reducer = createReducer();
19
20
  const [state, dispatch] = useReducer(reducer, getLiveChatWidgetContextInitialState(props));
20
21
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -28,7 +29,7 @@ export const LiveChatWidget = props => {
28
29
  }
29
30
 
30
31
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
31
- const isAuthenticatedChat = !!((_props$chatConfig = props.chatConfig) !== null && _props$chatConfig !== void 0 && (_props$chatConfig$Liv = _props$chatConfig.LiveChatConfigAuthSettings) !== null && _props$chatConfig$Liv !== void 0 && _props$chatConfig$Liv.msdyn_javascriptclientfunction);
32
+ const isAuthenticatedChat = !!((_props$chatConfig = props.chatConfig) !== null && _props$chatConfig !== void 0 && (_props$chatConfig$Liv = _props$chatConfig.LiveChatConfigAuthSettings) !== null && _props$chatConfig$Liv !== void 0 && _props$chatConfig$Liv.msdyn_javascriptclientfunction) || isPersistentChatEnabled((_props$chatConfig2 = props.chatConfig) === null || _props$chatConfig2 === void 0 ? void 0 : (_props$chatConfig2$Li = _props$chatConfig2.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig2$Li === void 0 ? void 0 : _props$chatConfig2$Li.msdyn_conversationmode);
32
33
  if (!facadeChatSDK) {
33
34
  var _props$mock2;
34
35
  setFacadeChatSDK(new FacadeChatSDK({
@@ -6,7 +6,7 @@ export const isPostChatSurveyEnabled = async facadeChatSDK => {
6
6
  const postChatEnabled = (_chatConfig$LiveWSAnd = chatConfig.LiveWSAndLiveChatEngJoin) === null || _chatConfig$LiveWSAnd === void 0 ? void 0 : _chatConfig$LiveWSAnd.msdyn_postconversationsurveyenable.toString().toLowerCase();
7
7
  return postChatEnabled === "true";
8
8
  };
9
- export const isPersistentChatEnabled = async conversationMode => {
9
+ export const isPersistentChatEnabled = conversationMode => {
10
10
  if (isNullOrUndefined(conversationMode)) {
11
11
  return false;
12
12
  }
@@ -1,16 +1,23 @@
1
1
  import { isPersistentChatEnabled } from "./liveChatConfigUtils";
2
2
 
3
3
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
4
- export const shouldSetPreChatIfPersistentChat = async (chatSDK, conversationMode, showPreChat) => {
5
- const persistentEnabled = await isPersistentChatEnabled(conversationMode);
4
+ export const shouldSetPreChatIfPersistentChat = async (facadeChatSDK, conversationMode, showPreChat) => {
5
+ const persistentEnabled = isPersistentChatEnabled(conversationMode);
6
6
  let skipPreChat = false;
7
7
  if (persistentEnabled) {
8
+ // Access private properties using type assertions
9
+ const chatSDK = facadeChatSDK.getChatSDK();
10
+
11
+ // Use type assertion to bypass private access restriction
12
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
13
+ const sdkAsAny = chatSDK;
14
+ // most likely this is not set , the facade will take care of it
8
15
  const reconnectableChatsParams = {
9
- authenticatedUserToken: chatSDK.authenticatedUserToken,
10
- requestId: chatSDK.requestId
16
+ authenticatedUserToken: sdkAsAny.authenticatedUserToken,
17
+ requestId: sdkAsAny.requestId
11
18
  };
12
19
  try {
13
- const reconnectableChatsResponse = await chatSDK.OCClient.getReconnectableChats(reconnectableChatsParams);
20
+ const reconnectableChatsResponse = await facadeChatSDK.getReconnectableChats(reconnectableChatsParams);
14
21
  if (reconnectableChatsResponse && reconnectableChatsResponse.reconnectid) {
15
22
  // Skip rendering prechat on existing persistent chat session
16
23
  skipPreChat = true;
@@ -69,7 +69,7 @@ const setPreChatAndInitiateChat = async (facadeChatSDK, dispatch, setAdapter, is
69
69
  const parseToJson = false;
70
70
  const preChatSurveyResponse = (props === null || props === void 0 ? void 0 : (_props$preChatSurveyP = props.preChatSurveyPaneProps) === null || _props$preChatSurveyP === void 0 ? void 0 : (_props$preChatSurveyP2 = _props$preChatSurveyP.controlProps) === null || _props$preChatSurveyP2 === void 0 ? void 0 : _props$preChatSurveyP2.payload) ?? (await facadeChatSDK.getPreChatSurvey(parseToJson));
71
71
  let showPrechat = isProactiveChat ? preChatSurveyResponse && proactiveChatEnablePrechatState : preChatSurveyResponse && !(props !== null && props !== void 0 && (_props$controlProps = props.controlProps) !== null && _props$controlProps !== void 0 && _props$controlProps.hidePreChatSurveyPane);
72
- showPrechat = await shouldSetPreChatIfPersistentChat(facadeChatSDK.getChatSDK(), state === null || state === void 0 ? void 0 : (_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : (_state$domainStates$l = _state$domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : (_state$domainStates$l2 = _state$domainStates$l.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l2 === void 0 ? void 0 : _state$domainStates$l2.msdyn_conversationmode, showPrechat);
72
+ showPrechat = await shouldSetPreChatIfPersistentChat(facadeChatSDK, state === null || state === void 0 ? void 0 : (_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : (_state$domainStates$l = _state$domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : (_state$domainStates$l2 = _state$domainStates$l.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l2 === void 0 ? void 0 : _state$domainStates$l2.msdyn_conversationmode, showPrechat);
73
73
  if (showPrechat) {
74
74
  var _state$domainStates2, _state$domainStates2$, _state$domainStates2$2, _state$domainStates2$3;
75
75
  const isOutOfOperatingHours = (state === null || state === void 0 ? void 0 : (_state$domainStates2 = state.domainStates) === null || _state$domainStates2 === void 0 ? void 0 : (_state$domainStates2$ = _state$domainStates2.liveChatConfig) === null || _state$domainStates2$ === void 0 ? void 0 : (_state$domainStates2$2 = _state$domainStates2$.LiveWSAndLiveChatEngJoin) === null || _state$domainStates2$2 === void 0 ? void 0 : (_state$domainStates2$3 = _state$domainStates2$2.OutOfOperatingHours) === null || _state$domainStates2$3 === void 0 ? void 0 : _state$domainStates2$3.toString().toLowerCase()) === "true";
@@ -156,7 +156,7 @@ const setPreChatAndInitiateChat = async (facadeChatSDK, dispatch, setAdapter, is
156
156
  const initStartChat = async (facadeChatSDK, dispatch, setAdapter, state, props, params, persistedState) => {
157
157
  var _state$domainStates7, _state$domainStates7$, _state$domainStates7$2;
158
158
  let isStartChatSuccessful = false;
159
- const persistentChatEnabled = await isPersistentChatEnabled(state === null || state === void 0 ? void 0 : (_state$domainStates7 = state.domainStates) === null || _state$domainStates7 === void 0 ? void 0 : (_state$domainStates7$ = _state$domainStates7.liveChatConfig) === null || _state$domainStates7$ === void 0 ? void 0 : (_state$domainStates7$2 = _state$domainStates7$.LiveWSAndLiveChatEngJoin) === null || _state$domainStates7$2 === void 0 ? void 0 : _state$domainStates7$2.msdyn_conversationmode);
159
+ const persistentChatEnabled = isPersistentChatEnabled(state === null || state === void 0 ? void 0 : (_state$domainStates7 = state.domainStates) === null || _state$domainStates7 === void 0 ? void 0 : (_state$domainStates7$ = _state$domainStates7.liveChatConfig) === null || _state$domainStates7$ === void 0 ? void 0 : (_state$domainStates7$2 = _state$domainStates7$.LiveWSAndLiveChatEngJoin) === null || _state$domainStates7$2 === void 0 ? void 0 : _state$domainStates7$2.msdyn_conversationmode);
160
160
  if ((state === null || state === void 0 ? void 0 : state.appStates.conversationState) === ConversationState.Closed) {
161
161
  // Preventive reset to avoid starting chat with previous requestId which could potentially cause problems
162
162
  chatSDKStateCleanUp(facadeChatSDK.getChatSDK());
@@ -10,6 +10,11 @@ import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
10
10
  import { TelemetryTimers } from "../../../common/telemetry/TelemetryManager";
11
11
  import { getWidgetCacheIdfromProps } from "../../../common/utils";
12
12
 
13
+ // Helper function to check if error is authentication-related
14
+ const isAuthenticationError = errorMessage => {
15
+ return errorMessage === WidgetLoadCustomErrorString.AuthenticationFailedErrorString || errorMessage.startsWith("Authentication Setup Error:") || errorMessage.includes("Token validation failed") || errorMessage.includes("Authentication token");
16
+ };
17
+
13
18
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
14
19
  export const handleStartChatError = (dispatch, facadeChatSDK, props, ex, isStartChatSuccessful) => {
15
20
  var _props$controlProps;
@@ -18,19 +23,16 @@ export const handleStartChatError = (dispatch, facadeChatSDK, props, ex, isStart
18
23
  return;
19
24
  }
20
25
 
21
- // Handle internal or misc errors
22
- if (ex.message === WidgetLoadCustomErrorString.AuthenticationFailedErrorString) {
26
+ // Handle authentication-related errors
27
+ if (isAuthenticationError(ex.message)) {
23
28
  dispatch({
24
29
  type: LiveChatWidgetActionType.SET_START_CHAT_FAILURE_TYPE,
25
30
  payload: StartChatFailureType.AuthSetupError
26
31
  });
27
- // set conversation to error to enforce error UI pane
28
- dispatch({
29
- type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
30
- payload: ConversationState.Error
31
- });
32
32
  logWidgetLoadCompleteWithError(ex);
33
+ // Don't return early - let the generic error handling logic handle hideErrorUIPane and telemetry
33
34
  }
35
+
34
36
  if (ex.message === WidgetLoadCustomErrorString.NetworkErrorString) {
35
37
  logWidgetLoadCompleteWithError(ex);
36
38
  }
@@ -53,8 +55,11 @@ export const handleStartChatError = (dispatch, facadeChatSDK, props, ex, isStart
53
55
  case ChatSDKErrorName.UninitializedChatSDK:
54
56
  handleUninitializedChatSDK(ex);
55
57
  break;
56
- // Handle the case indicating failure to retrieve an authenticated chat conversation
57
58
  case ChatSDKErrorName.AuthenticatedChatConversationRetrievalFailure:
59
+ dispatch({
60
+ type: LiveChatWidgetActionType.SET_START_CHAT_FAILURE_TYPE,
61
+ payload: StartChatFailureType.Unauthorized
62
+ });
58
63
  logWidgetLoadCompleteWithError(ex);
59
64
  break;
60
65
  case ChatSDKErrorName.InvalidConversation:
@@ -106,6 +111,9 @@ const logWidgetLoadFailed = ex => {
106
111
  if (ex !== null && ex !== void 0 && ex.httpResponseStatusCode) {
107
112
  exDetails.HttpResponseStatusCode = ex.httpResponseStatusCode;
108
113
  }
114
+ if (ex !== null && ex !== void 0 && ex.exceptionDetails) {
115
+ exDetails.ChatSDKExceptionDetails = ex.exceptionDetails;
116
+ }
109
117
  TelemetryHelper.logLoadingEventToAllTelemetry(LogLevel.ERROR, {
110
118
  Event: TelemetryEvent.WidgetLoadFailed,
111
119
  Description: "Widget load complete with error",
@@ -134,6 +142,9 @@ const logWidgetLoadCompleteWithError = ex => {
134
142
  if (ex !== null && ex !== void 0 && ex.httpResponseStatusCode) {
135
143
  exDetails.HttpResponseStatusCode = ex.httpResponseStatusCode;
136
144
  }
145
+ if (ex !== null && ex !== void 0 && ex.exceptionDetails) {
146
+ exDetails.ChatSDKExceptionDetails = ex.exceptionDetails;
147
+ }
137
148
  TelemetryHelper.logLoadingEventToAllTelemetry(LogLevel.ERROR, {
138
149
  Event: TelemetryEvent.WidgetLoadFailed,
139
150
  Description: "Widget load complete with error",
@@ -221,6 +232,12 @@ const handleChatTokenRetrievalFailure = (dispatch, ex) => {
221
232
  type: LiveChatWidgetActionType.SET_START_CHAT_FAILURE_TYPE,
222
233
  payload: StartChatFailureType.Unauthorized
223
234
  });
235
+ } else {
236
+ // For other authentication-related token retrieval failures, set as AuthSetupError
237
+ dispatch({
238
+ type: LiveChatWidgetActionType.SET_START_CHAT_FAILURE_TYPE,
239
+ payload: StartChatFailureType.AuthSetupError
240
+ });
224
241
  }
225
242
  logWidgetLoadCompleteWithError(ex);
226
243
  }
@@ -55,7 +55,7 @@ import useChatContextStore from "../../../hooks/useChatContextStore";
55
55
  import useFacadeSDKStore from "../../../hooks/useFacadeChatSDKStore";
56
56
  let uiTimer;
57
57
  export const LiveChatWidgetStateful = props => {
58
- var _props$webChatContain, _props$styleProps, _props$webChatContain2, _props$webChatContain3, _props$controlProps, _props$controlProps3, _state$appStates7, _props$webChatContain7, _state$appStates14, _props$webChatContain9, _props$webChatContain10, _props$controlProps12, _props$draggableChatW, _props$draggableChatW2, _props$draggableChatW3, _props$draggableChatW4, _props$draggableChatW5, _livechatProps$webCha, _props$webChatContain11, _props$webChatContain12, _props$webChatContain13, _props$webChatContain14, _props$webChatContain15, _props$webChatContain16, _props$webChatContain17, _props$webChatContain18, _livechatProps$styleP, _livechatProps$contro, _livechatProps$contro2, _livechatProps$compon, _livechatProps$contro3, _livechatProps$compon2, _livechatProps$contro4, _livechatProps$compon3, _livechatProps$contro5, _livechatProps$compon4, _livechatProps$contro6, _livechatProps$compon5, _livechatProps$contro7, _livechatProps$compon6, _livechatProps$contro8, _livechatProps$compon7, _livechatProps$contro9, _livechatProps$compon8, _livechatProps$contro10, _livechatProps$contro11, _livechatProps$compon9, _livechatProps$contro12, _livechatProps$compon10, _livechatProps$contro13, _livechatProps$compon11, _livechatProps$compon12, _livechatProps$compon13;
58
+ var _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _props$webChatContain4, _props$webChatContain5, _props$webChatContain6, _props$webChatContain7, _props$webChatContain8, _props$webChatContain9, _props$styleProps, _props$webChatContain10, _props$webChatContain11, _props$controlProps, _props$controlProps3, _state$appStates7, _props$webChatContain15, _state$appStates14, _props$webChatContain17, _props$webChatContain18, _props$controlProps12, _props$draggableChatW, _props$draggableChatW2, _props$draggableChatW3, _props$draggableChatW4, _props$draggableChatW5, _livechatProps$webCha, _livechatProps$styleP, _livechatProps$contro, _livechatProps$contro2, _livechatProps$compon, _livechatProps$contro3, _livechatProps$compon2, _livechatProps$contro4, _livechatProps$compon3, _livechatProps$contro5, _livechatProps$compon4, _livechatProps$contro6, _livechatProps$compon5, _livechatProps$contro7, _livechatProps$compon6, _livechatProps$contro8, _livechatProps$compon7, _livechatProps$contro9, _livechatProps$compon8, _livechatProps$contro10, _livechatProps$contro11, _livechatProps$compon9, _livechatProps$contro12, _livechatProps$compon10, _livechatProps$contro13, _livechatProps$compon11, _livechatProps$compon12, _livechatProps$compon13;
59
59
  useEffect(() => {
60
60
  uiTimer = createTimer();
61
61
  TelemetryHelper.logLoadingEventToAllTelemetry(LogLevel.INFO, {
@@ -79,6 +79,8 @@ export const LiveChatWidgetStateful = props => {
79
79
  Composer
80
80
  } = Components;
81
81
  const canStartProactiveChat = useRef(true);
82
+ const bubbleBackground = ((_props$webChatContain2 = props.webChatContainerProps) === null || _props$webChatContain2 === void 0 ? void 0 : (_props$webChatContain3 = _props$webChatContain2.webChatStyles) === null || _props$webChatContain3 === void 0 ? void 0 : _props$webChatContain3.bubbleBackground) ?? ((_props$webChatContain4 = props.webChatContainerProps) === null || _props$webChatContain4 === void 0 ? void 0 : (_props$webChatContain5 = _props$webChatContain4.adaptiveCardStyles) === null || _props$webChatContain5 === void 0 ? void 0 : _props$webChatContain5.background) ?? defaultAdaptiveCardStyles.background;
83
+ const bubbleTextColor = ((_props$webChatContain6 = props.webChatContainerProps) === null || _props$webChatContain6 === void 0 ? void 0 : (_props$webChatContain7 = _props$webChatContain6.webChatStyles) === null || _props$webChatContain7 === void 0 ? void 0 : _props$webChatContain7.bubbleTextColor) ?? ((_props$webChatContain8 = props.webChatContainerProps) === null || _props$webChatContain8 === void 0 ? void 0 : (_props$webChatContain9 = _props$webChatContain8.adaptiveCardStyles) === null || _props$webChatContain9 === void 0 ? void 0 : _props$webChatContain9.color) ?? defaultAdaptiveCardStyles.color;
82
84
 
83
85
  // Process general styles
84
86
  const generalStyles = {
@@ -87,7 +89,7 @@ export const LiveChatWidgetStateful = props => {
87
89
 
88
90
  //Scrollbar styles
89
91
  const scrollbarProps = Object.assign({}, defaultScrollBarProps, props === null || props === void 0 ? void 0 : props.scrollBarProps);
90
- const sendBoxTextArea = props === null || props === void 0 ? void 0 : (_props$webChatContain2 = props.webChatContainerProps) === null || _props$webChatContain2 === void 0 ? void 0 : (_props$webChatContain3 = _props$webChatContain2.sendBoxTextBox) === null || _props$webChatContain3 === void 0 ? void 0 : _props$webChatContain3.textarea;
92
+ const sendBoxTextArea = props === null || props === void 0 ? void 0 : (_props$webChatContain10 = props.webChatContainerProps) === null || _props$webChatContain10 === void 0 ? void 0 : (_props$webChatContain11 = _props$webChatContain10.sendBoxTextBox) === null || _props$webChatContain11 === void 0 ? void 0 : _props$webChatContain11.textarea;
91
93
 
92
94
  // In case the broadcast channel is already initialized elsewhere; One tab can only hold 1 instance
93
95
  if ((props === null || props === void 0 ? void 0 : (_props$controlProps = props.controlProps) === null || _props$controlProps === void 0 ? void 0 : _props$controlProps.skipBroadcastChannelInit) !== true) {
@@ -274,7 +276,8 @@ export const LiveChatWidgetStateful = props => {
274
276
  var _state$appStates6;
275
277
  if ((state === null || state === void 0 ? void 0 : (_state$appStates6 = state.appStates) === null || _state$appStates6 === void 0 ? void 0 : _state$appStates6.hideStartChatButton) === true) {
276
278
  //handle OOH pane
277
- if (state.appStates.outsideOperatingHours === true) {
279
+ // Only set OutOfOffice state for new conversations, allow existing Active/InActive conversations to continue
280
+ if (state.appStates.outsideOperatingHours === true && state.appStates.conversationState !== ConversationState.Active) {
278
281
  dispatch({
279
282
  type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
280
283
  payload: ConversationState.OutOfOffice
@@ -623,8 +626,8 @@ export const LiveChatWidgetStateful = props => {
623
626
  });
624
627
  }
625
628
  if (state.appStates.conversationState === ConversationState.InActive) {
626
- var _props$webChatContain4, _props$webChatContain5;
627
- if ((props === null || props === void 0 ? void 0 : (_props$webChatContain4 = props.webChatContainerProps) === null || _props$webChatContain4 === void 0 ? void 0 : (_props$webChatContain5 = _props$webChatContain4.renderingMiddlewareProps) === null || _props$webChatContain5 === void 0 ? void 0 : _props$webChatContain5.hideSendboxOnConversationEnd) !== false) {
629
+ var _props$webChatContain12, _props$webChatContain13;
630
+ if ((props === null || props === void 0 ? void 0 : (_props$webChatContain12 = props.webChatContainerProps) === null || _props$webChatContain12 === void 0 ? void 0 : (_props$webChatContain13 = _props$webChatContain12.renderingMiddlewareProps) === null || _props$webChatContain13 === void 0 ? void 0 : _props$webChatContain13.hideSendboxOnConversationEnd) !== false) {
628
631
  setWebChatStyles(styles => {
629
632
  return {
630
633
  ...styles,
@@ -668,12 +671,12 @@ export const LiveChatWidgetStateful = props => {
668
671
  }
669
672
  }, [state.appStates.unreadMessageCount]);
670
673
  useEffect(() => {
671
- var _props$webChatContain6;
674
+ var _props$webChatContain14;
672
675
  setWebChatStyles({
673
676
  ...webChatStyles,
674
- ...((_props$webChatContain6 = props.webChatContainerProps) === null || _props$webChatContain6 === void 0 ? void 0 : _props$webChatContain6.webChatStyles)
677
+ ...((_props$webChatContain14 = props.webChatContainerProps) === null || _props$webChatContain14 === void 0 ? void 0 : _props$webChatContain14.webChatStyles)
675
678
  });
676
- }, [(_props$webChatContain7 = props.webChatContainerProps) === null || _props$webChatContain7 === void 0 ? void 0 : _props$webChatContain7.webChatStyles]);
679
+ }, [(_props$webChatContain15 = props.webChatContainerProps) === null || _props$webChatContain15 === void 0 ? void 0 : _props$webChatContain15.webChatStyles]);
677
680
  useEffect(() => {
678
681
  //Confirmation pane dismissing through OK option, so proceed with end chat
679
682
  if (state.domainStates.confirmationState === ConfirmationState.Ok) {
@@ -772,12 +775,12 @@ export const LiveChatWidgetStateful = props => {
772
775
 
773
776
  // if props state gets updates we need to update the renderingMiddlewareProps in the state
774
777
  useEffect(() => {
775
- var _props$webChatContain8;
778
+ var _props$webChatContain16;
776
779
  dispatch({
777
780
  type: LiveChatWidgetActionType.SET_RENDERING_MIDDLEWARE_PROPS,
778
- payload: (_props$webChatContain8 = props.webChatContainerProps) === null || _props$webChatContain8 === void 0 ? void 0 : _props$webChatContain8.renderingMiddlewareProps
781
+ payload: (_props$webChatContain16 = props.webChatContainerProps) === null || _props$webChatContain16 === void 0 ? void 0 : _props$webChatContain16.renderingMiddlewareProps
779
782
  });
780
- }, [(_props$webChatContain9 = props.webChatContainerProps) === null || _props$webChatContain9 === void 0 ? void 0 : _props$webChatContain9.renderingMiddlewareProps]);
783
+ }, [(_props$webChatContain17 = props.webChatContainerProps) === null || _props$webChatContain17 === void 0 ? void 0 : _props$webChatContain17.renderingMiddlewareProps]);
781
784
  useEffect(() => {
782
785
  TelemetryHelper.logLoadingEventToAllTelemetry(LogLevel.INFO, {
783
786
  Event: TelemetryEvent.UXLiveChatWidgetCompleted,
@@ -820,7 +823,7 @@ export const LiveChatWidgetStateful = props => {
820
823
  const webChatProps = initWebChatComposer(props, state, dispatch, facadeChatSDK, endChatRelay);
821
824
  const downloadTranscriptProps = createDownloadTranscriptProps(props.downloadTranscriptProps, {
822
825
  ...(defaultWebChatContainerStatefulProps === null || defaultWebChatContainerStatefulProps === void 0 ? void 0 : defaultWebChatContainerStatefulProps.webChatStyles),
823
- ...((_props$webChatContain10 = props.webChatContainerProps) === null || _props$webChatContain10 === void 0 ? void 0 : _props$webChatContain10.webChatStyles)
826
+ ...((_props$webChatContain18 = props.webChatContainerProps) === null || _props$webChatContain18 === void 0 ? void 0 : _props$webChatContain18.webChatStyles)
824
827
  }, props.webChatContainerProps);
825
828
  const livechatProps = {
826
829
  ...props,
@@ -846,6 +849,11 @@ export const LiveChatWidgetStateful = props => {
846
849
  setOcUserAgent(facadeChatSDK.getChatSDK());
847
850
  const directLine = ((_livechatProps$webCha = livechatProps.webChatContainerProps) === null || _livechatProps$webCha === void 0 ? void 0 : _livechatProps$webCha.directLine) ?? adapter ?? defaultWebChatContainerStatefulProps.directLine;
848
851
  const userID = directLine.getState ? directLine === null || directLine === void 0 ? void 0 : directLine.getState("acs.userId") : "teamsvisitor";
852
+ const styleOptions = React.useMemo(() => ({
853
+ ...webChatStyles,
854
+ bubbleBackground,
855
+ bubbleTextColor
856
+ }), [webChatStyles, bubbleBackground, bubbleTextColor]);
849
857
 
850
858
  // WebChat's Composer can only be rendered if a directLine object is defined
851
859
  return directLine && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("style", null, `
@@ -884,11 +892,7 @@ export const LiveChatWidgetStateful = props => {
884
892
  }`}
885
893
  `), /*#__PURE__*/React.createElement(DraggableChatWidget, chatWidgetDraggableConfig, /*#__PURE__*/React.createElement(Composer, _extends({}, webChatProps, {
886
894
  userID: userID,
887
- styleOptions: {
888
- ...webChatStyles,
889
- bubbleBackground: ((_props$webChatContain11 = props.webChatContainerProps) === null || _props$webChatContain11 === void 0 ? void 0 : (_props$webChatContain12 = _props$webChatContain11.webChatStyles) === null || _props$webChatContain12 === void 0 ? void 0 : _props$webChatContain12.bubbleBackground) ?? ((_props$webChatContain13 = props.webChatContainerProps) === null || _props$webChatContain13 === void 0 ? void 0 : (_props$webChatContain14 = _props$webChatContain13.adaptiveCardStyles) === null || _props$webChatContain14 === void 0 ? void 0 : _props$webChatContain14.background) ?? defaultAdaptiveCardStyles.background,
890
- bubbleTextColor: ((_props$webChatContain15 = props.webChatContainerProps) === null || _props$webChatContain15 === void 0 ? void 0 : (_props$webChatContain16 = _props$webChatContain15.webChatStyles) === null || _props$webChatContain16 === void 0 ? void 0 : _props$webChatContain16.bubbleTextColor) ?? ((_props$webChatContain17 = props.webChatContainerProps) === null || _props$webChatContain17 === void 0 ? void 0 : (_props$webChatContain18 = _props$webChatContain17.adaptiveCardStyles) === null || _props$webChatContain18 === void 0 ? void 0 : _props$webChatContain18.color) ?? defaultAdaptiveCardStyles.color
891
- },
895
+ styleOptions: styleOptions,
892
896
  directLine: directLine
893
897
  }), /*#__PURE__*/React.createElement(Stack, {
894
898
  id: widgetElementId,
@@ -24,7 +24,7 @@ export const getLiveChatWidgetContextInitialState = props => {
24
24
  * as part of the flow, the pre-chat will be detected and then it will be displayed properly
25
25
  * this case is only and only for pre-chat pane.
26
26
  * **/
27
- if (initialStateFromCache.appStates.conversationState === ConversationState.Prechat || initialStateFromCache.appStates.conversationState === ConversationState.OutOfOffice || outsideOperatingHours) {
27
+ if (initialStateFromCache.appStates.conversationState === ConversationState.Prechat || initialStateFromCache.appStates.conversationState === ConversationState.OutOfOffice || outsideOperatingHours && initialStateFromCache.appStates.conversationState !== ConversationState.Active) {
28
28
  initialStateFromCache.appStates.conversationState = ConversationState.Closed;
29
29
  // if we are resetting the conversation state, there is no point to obtain minimized state from cache
30
30
  initialStateFromCache.appStates.isMinimized = undefined;
@@ -72,4 +72,5 @@ export declare class FacadeChatSDK {
72
72
  getVoiceVideoCalling(params?: VoiceVideoCallingOptionalParams): Promise<GetVoiceVideoCallingResponse>;
73
73
  getPostChatSurveyContext(): Promise<PostChatContext>;
74
74
  getAgentAvailability(optionalParams?: GetAgentAvailabilityOptionalParams): Promise<GetAgentAvailabilityResponse>;
75
+ getReconnectableChats(reconnectableChatsParams?: any): Promise<any>;
75
76
  }
@@ -1,3 +1,3 @@
1
1
  import { FacadeChatSDK } from "../../../common/facades/FacadeChatSDK";
2
2
  export declare const isPostChatSurveyEnabled: (facadeChatSDK: FacadeChatSDK) => Promise<boolean>;
3
- export declare const isPersistentChatEnabled: (conversationMode: string | undefined) => Promise<boolean>;
3
+ export declare const isPersistentChatEnabled: (conversationMode: string | undefined) => boolean;
@@ -1 +1,2 @@
1
- export declare const shouldSetPreChatIfPersistentChat: (chatSDK: any, conversationMode: string, showPreChat: boolean) => Promise<boolean>;
1
+ import { FacadeChatSDK } from "../../../common/facades/FacadeChatSDK";
2
+ export declare const shouldSetPreChatIfPersistentChat: (facadeChatSDK: FacadeChatSDK, conversationMode: string, showPreChat: boolean) => Promise<boolean>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microsoft/omnichannel-chat-widget",
3
- "version": "1.8.1-main.f0e9e2f",
3
+ "version": "1.8.2-main.4b1a5f0",
4
4
  "description": "Microsoft Omnichannel Chat Widget",
5
5
  "main": "lib/cjs/index.js",
6
6
  "types": "lib/types/index.d.ts",
@@ -87,7 +87,7 @@
87
87
  "@azure/core-tracing": "^1.2.0",
88
88
  "@microsoft/applicationinsights-web": "^3.3.6",
89
89
  "@microsoft/omnichannel-chat-components": "1.1.12",
90
- "@microsoft/omnichannel-chat-sdk": "^1.11.1",
90
+ "@microsoft/omnichannel-chat-sdk": "^1.11.2",
91
91
  "@opentelemetry/api": "^1.9.0",
92
92
  "abort-controller": "^3",
93
93
  "abort-controller-es5": "^2.0.1",