@microsoft/omnichannel-chat-widget 1.4.0 → 1.4.1-main.4e8dedc

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 (22) hide show
  1. package/lib/cjs/common/utils.js +19 -2
  2. package/lib/cjs/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +4 -1
  3. package/lib/cjs/components/livechatwidget/common/endChat.js +18 -15
  4. package/lib/cjs/components/livechatwidget/common/renderSurveyHelpers.js +11 -9
  5. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +24 -15
  6. package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +22 -9
  7. package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +3 -1
  8. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios.js +1 -0
  9. package/lib/esm/common/utils.js +16 -0
  10. package/lib/esm/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +5 -2
  11. package/lib/esm/components/livechatwidget/common/endChat.js +18 -18
  12. package/lib/esm/components/livechatwidget/common/renderSurveyHelpers.js +11 -9
  13. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +27 -18
  14. package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +22 -9
  15. package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +3 -1
  16. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios.js +1 -0
  17. package/lib/types/common/utils.d.ts +9 -0
  18. package/lib/types/components/livechatwidget/common/endChat.d.ts +5 -2
  19. package/lib/types/components/livechatwidget/common/renderSurveyHelpers.d.ts +1 -1
  20. package/lib/types/components/webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios.d.ts +1 -0
  21. package/lib/types/contexts/common/ILiveChatWidgetLocalizedTexts.d.ts +9 -0
  22. package/package.json +2 -2
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.setTabIndices = exports.setFocusOnSendBox = exports.setFocusOnElement = exports.preventFocusToMoveOutOfElement = exports.parseAdaptiveCardPayload = exports.newGuid = exports.isUndefinedOrEmpty = exports.isNullOrUndefined = exports.isNullOrEmptyString = exports.getWidgetEndChatEventName = exports.getWidgetCacheIdfromProps = exports.getWidgetCacheId = exports.getTimestampHourMinute = exports.getStateFromCache = exports.getLocaleDirection = exports.getIconText = exports.getDomain = exports.getConversationDetailsCall = exports.getBroadcastChannelName = exports.findParentFocusableElementsWithoutChildContainer = exports.findAllFocusableElement = exports.extractPreChatSurveyResponseValues = exports.escapeHtml = exports.debounceLeading = exports.createTimer = exports.createFileAndDownload = exports.checkContactIdError = exports.changeLanguageCodeFormatForWebChat = exports.addDelayInMs = void 0;
6
+ exports.setTabIndices = exports.setFocusOnSendBox = exports.setFocusOnElement = exports.preventFocusToMoveOutOfElement = exports.parseAdaptiveCardPayload = exports.newGuid = exports.isUndefinedOrEmpty = exports.isNullOrUndefined = exports.isNullOrEmptyString = exports.getWidgetEndChatEventName = exports.getWidgetCacheIdfromProps = exports.getWidgetCacheId = exports.getTimestampHourMinute = exports.getStateFromCache = exports.getLocaleDirection = exports.getIconText = exports.getDomain = exports.getConversationDetailsCall = exports.getBroadcastChannelName = exports.formatTemplateString = exports.findParentFocusableElementsWithoutChildContainer = exports.findAllFocusableElement = exports.extractPreChatSurveyResponseValues = exports.escapeHtml = exports.debounceLeading = exports.createTimer = exports.createFileAndDownload = exports.checkContactIdError = exports.changeLanguageCodeFormatForWebChat = exports.addDelayInMs = void 0;
7
7
  var _Constants = require("./Constants");
8
8
  var _TelemetryConstants = require("./telemetry/TelemetryConstants");
9
9
  var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
@@ -431,4 +431,21 @@ const createFileAndDownload = (fileName, blobData, mimeType) => {
431
431
  aElement.click();
432
432
  document.body.removeChild(aElement);
433
433
  };
434
- exports.createFileAndDownload = createFileAndDownload;
434
+
435
+ /**
436
+ *
437
+ * Replace placeholders with format {0}..{n} , in a string with values
438
+ *
439
+ * @param template String with placeholders to be replaced
440
+ * @param values array of values to replace the placeholders
441
+ * @returns formatted string with replaced values
442
+ */
443
+ // use of any for values as array of any type is passed
444
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
445
+ exports.createFileAndDownload = createFileAndDownload;
446
+ const formatTemplateString = (templateMessage, values) => {
447
+ return templateMessage.replace(/{(\d+)}/g, (match, index) => {
448
+ return typeof values[index] !== "undefined" ? values[index] : match;
449
+ });
450
+ };
451
+ exports.formatTemplateString = formatTemplateString;
@@ -16,6 +16,7 @@ var _Constants = require("../../common/Constants");
16
16
  var _TelemetryHelper = require("../../common/telemetry/TelemetryHelper");
17
17
  var _useChatContextStore = _interopRequireDefault(require("../../hooks/useChatContextStore"));
18
18
  var _useChatSDKStore = _interopRequireDefault(require("../../hooks/useChatSDKStore"));
19
+ var _defaultMiddlewareLocalizedTexts = require("../webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts");
19
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
21
  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); }
21
22
  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; }
@@ -55,6 +56,7 @@ const EmailTranscriptPaneStateful = props => {
55
56
  };
56
57
  try {
57
58
  await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.emailLiveChatTranscript(chatTranscriptBody));
59
+ _NotificationHandler.NotificationHandler.notifySuccess(_NotificationScenarios.NotificationScenarios.EmailAddressSaved, _defaultMiddlewareLocalizedTexts.defaultMiddlewareLocalizedTexts === null || _defaultMiddlewareLocalizedTexts.defaultMiddlewareLocalizedTexts === void 0 ? void 0 : _defaultMiddlewareLocalizedTexts.defaultMiddlewareLocalizedTexts.MIDDLEWARE_BANNER_FILE_EMAIL_ADDRESS_RECORDED_SUCCESS);
58
60
  _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
59
61
  Event: _TelemetryConstants.TelemetryEvent.EmailTranscriptSent,
60
62
  Description: "Transcript sent to email successfully."
@@ -66,7 +68,8 @@ const EmailTranscriptPaneStateful = props => {
66
68
  exception: ex
67
69
  }
68
70
  });
69
- _NotificationHandler.NotificationHandler.notifyError(_NotificationScenarios.NotificationScenarios.EmailTranscriptError, (props === null || props === void 0 ? void 0 : props.bannerMessageOnError) ?? "Email transcript to " + email + " failed.");
71
+ const message = (0, _utils.formatTemplateString)(_defaultMiddlewareLocalizedTexts.defaultMiddlewareLocalizedTexts.MIDDLEWARE_BANNER_FILE_EMAIL_ADDRESS_RECORDED_ERROR, [email]);
72
+ _NotificationHandler.NotificationHandler.notifyError(_NotificationScenarios.NotificationScenarios.EmailTranscriptError, (props === null || props === void 0 ? void 0 : props.bannerMessageOnError) ?? message);
70
73
  }
71
74
  },
72
75
  onCancel: () => {
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.prepareEndChat = exports.endVoiceVideoCallIfOngoing = exports.endChat = void 0;
6
+ exports.prepareEndChat = exports.endVoiceVideoCallIfOngoing = exports.endChatStateCleanUp = exports.endChat = exports.closeChatStateCleanUp = exports.callingStateCleanUp = void 0;
7
7
  var _Constants = require("../../../common/Constants");
8
8
  var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants");
9
9
  var _authHelper = require("./authHelper");
@@ -15,10 +15,11 @@ var _LiveChatWidgetActionType = require("../../../contexts/common/LiveChatWidget
15
15
  var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
16
16
  var _WebChatStoreLoader = require("../../webchatcontainerstateful/webchatcontroller/WebChatStoreLoader");
17
17
  var _defaultWebChatContainerStatefulProps = require("../../webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps");
18
+ var _TelemetryManager = require("../../../common/telemetry/TelemetryManager");
18
19
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
19
- const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, uwid) => {
20
+ const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter) => {
20
21
  try {
21
- var _conversationDetails$, _state$domainStates, _state$domainStates2;
22
+ var _conversationDetails$, _state$domainStates;
22
23
  // Use Case: If call is ongoing, end the call by simulating end call button click
23
24
  endVoiceVideoCallIfOngoing(chatSDK, dispatch);
24
25
  const conversationDetails = await (0, _utils.getConversationDetailsCall)(chatSDK);
@@ -28,7 +29,7 @@ const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWe
28
29
  var _state$appStates;
29
30
  // If ended by customer, just close chat
30
31
  if ((state === null || state === void 0 ? void 0 : (_state$appStates = state.appStates) === null || _state$appStates === void 0 ? void 0 : _state$appStates.conversationEndedBy) === _Constants.ConversationEndEntity.Customer) {
31
- await endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, true, uwid);
32
+ await endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, true);
32
33
  }
33
34
  // Use Case: If ended by Agent, stay chat in InActive state
34
35
  return;
@@ -43,15 +44,13 @@ const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWe
43
44
  }
44
45
 
45
46
  // Use Case: Can render post chat scenarios
46
- await (0, _renderSurveyHelpers.getPostChatContext)(chatSDK, state, dispatch);
47
-
48
47
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
49
- const postchatContext = state === null || state === void 0 ? void 0 : (_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : _state$domainStates.postChatContext;
48
+ const postchatContext = (await (0, _renderSurveyHelpers.getPostChatContext)(chatSDK, state, dispatch)) ?? (state === null || state === void 0 ? void 0 : (_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : _state$domainStates.postChatContext);
50
49
  if (postchatContext === undefined) {
51
50
  var _state$appStates2;
52
51
  // For Customer intiated conversations, just close chat widget
53
52
  if ((state === null || state === void 0 ? void 0 : (_state$appStates2 = state.appStates) === null || _state$appStates2 === void 0 ? void 0 : _state$appStates2.conversationEndedBy) === _Constants.ConversationEndEntity.Customer) {
54
- await endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, true, uwid);
53
+ await endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, true);
55
54
  return;
56
55
  }
57
56
 
@@ -62,10 +61,10 @@ const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWe
62
61
  });
63
62
  return;
64
63
  }
65
- endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, true, true, uwid);
64
+ endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, true, true);
66
65
 
67
66
  // Initiate post chat render
68
- if (state !== null && state !== void 0 && (_state$domainStates2 = state.domainStates) !== null && _state$domainStates2 !== void 0 && _state$domainStates2.postChatContext) {
67
+ if (postchatContext) {
69
68
  await (0, _renderSurveyHelpers.initiatePostChat)(props, conversationDetails, state, dispatch, postchatContext);
70
69
  return;
71
70
  }
@@ -80,7 +79,7 @@ const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWe
80
79
 
81
80
  //Close chat widget for any failure in embedded to allow to show start chat button
82
81
  if (((_props$controlProps = props.controlProps) === null || _props$controlProps === void 0 ? void 0 : _props$controlProps.hideStartChatButton) === false) {
83
- await endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, true, uwid);
82
+ await endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, true);
84
83
  }
85
84
  } finally {
86
85
  //Chat token clean up
@@ -90,8 +89,7 @@ const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWe
90
89
 
91
90
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
92
91
  exports.prepareEndChat = prepareEndChat;
93
- const endChat = async function (props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTab) {
94
- let uwid = arguments.length > 10 && arguments[10] !== undefined ? arguments[10] : "";
92
+ const endChat = async (props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTab) => {
95
93
  if (!skipEndChatSDK && chatSDK.conversation) {
96
94
  try {
97
95
  _TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.INFO, {
@@ -143,11 +141,13 @@ const endChat = async function (props, chatSDK, state, dispatch, setAdapter, set
143
141
  closeChatWidget(dispatch, props, state);
144
142
  }
145
143
  }
146
- if (postMessageToOtherTab && !(0, _utils.isNullOrEmptyString)(uwid)) {
144
+ if (postMessageToOtherTab) {
147
145
  const endChatEventName = await getEndChatEventName(chatSDK, props);
148
146
  _omnichannelChatComponents.BroadcastService.postMessage({
149
147
  eventName: endChatEventName,
150
- payload: uwid
148
+ payload: {
149
+ runtimeId: _TelemetryManager.TelemetryManager.InternalTelemetryData.lcwRuntimeId
150
+ }
151
151
  });
152
152
  }
153
153
  };
@@ -174,6 +174,7 @@ const callingStateCleanUp = async dispatch => {
174
174
  payload: true
175
175
  });
176
176
  };
177
+ exports.callingStateCleanUp = callingStateCleanUp;
177
178
  const endChatStateCleanUp = async dispatch => {
178
179
  // Need to clear these states immediately when chat ended from OC.
179
180
  dispatch({
@@ -189,6 +190,7 @@ const endChatStateCleanUp = async dispatch => {
189
190
  payload: false
190
191
  });
191
192
  };
193
+ exports.endChatStateCleanUp = endChatStateCleanUp;
192
194
  const closeChatStateCleanUp = async dispatch => {
193
195
  dispatch({
194
196
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CHAT_TOKEN,
@@ -226,6 +228,7 @@ const closeChatStateCleanUp = async dispatch => {
226
228
  };
227
229
 
228
230
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
231
+ exports.closeChatStateCleanUp = closeChatStateCleanUp;
229
232
  const endVoiceVideoCallIfOngoing = async (chatSDK, dispatch) => {
230
233
  let callId = "";
231
234
  try {
@@ -48,24 +48,25 @@ const setSurveyMode = async (props, participantType, state, dispatch) => {
48
48
  return;
49
49
  }
50
50
  };
51
- const renderSurvey = async (state, dispatch) => {
51
+
52
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
53
+ const renderSurvey = async (postChatContext, dispatch) => {
52
54
  if (postChatSurveyMode === _PostChatSurveyMode.PostChatSurveyMode.Link) {
53
55
  setWidgetStateToInactive(dispatch);
54
56
  return;
55
57
  }
56
58
  if (postChatSurveyMode === _PostChatSurveyMode.PostChatSurveyMode.Embed) {
57
- await embedModePostChatWorkflow(state, dispatch);
59
+ await embedModePostChatWorkflow(postChatContext, dispatch);
58
60
  }
59
61
  };
60
62
 
61
63
  // Function for embed mode postchat workflow which is essentially same for both customer and agent
62
64
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
63
- const embedModePostChatWorkflow = async (state, dispatch) => {
64
- var _state$domainStates2;
65
+ const embedModePostChatWorkflow = async (postChatContext, dispatch) => {
65
66
  _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
66
67
  Event: _TelemetryConstants.TelemetryEvent.EmbedModePostChatWorkflowStarted
67
68
  });
68
- if (state !== null && state !== void 0 && (_state$domainStates2 = state.domainStates) !== null && _state$domainStates2 !== void 0 && _state$domainStates2.postChatContext) {
69
+ if (postChatContext) {
69
70
  dispatch({
70
71
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
71
72
  payload: _ConversationState.ConversationState.PostchatLoading
@@ -76,7 +77,7 @@ const embedModePostChatWorkflow = async (state, dispatch) => {
76
77
  payload: _ConversationState.ConversationState.Postchat
77
78
  });
78
79
  } else {
79
- const error = `Conversation was Ended but App State was not set correctly: postChatContext = ${state.domainStates.postChatContext}`;
80
+ const error = `Conversation was Ended but App State was not set correctly: postChatContext = ${postChatContext}`;
80
81
  _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
81
82
  Event: _TelemetryConstants.TelemetryEvent.AppStatesException,
82
83
  ExceptionDetails: {
@@ -92,7 +93,7 @@ const initiatePostChat = async (props, conversationDetailsParam, state, dispatch
92
93
  conversationDetails = conversationDetailsParam;
93
94
  const participantType = ((_conversationDetails = conversationDetails) === null || _conversationDetails === void 0 ? void 0 : _conversationDetails.participantType) ?? postchatContext.participantType;
94
95
  await setSurveyMode(props, participantType, state, dispatch);
95
- await renderSurvey(state, dispatch);
96
+ await renderSurvey(postchatContext, dispatch);
96
97
  };
97
98
 
98
99
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -107,8 +108,8 @@ const isPostChatEnabled = (props, state) => {
107
108
  exports.checkPostChatEnabled = isPostChatEnabled;
108
109
  const getPostChatContext = async (chatSDK, state, dispatch) => {
109
110
  try {
110
- var _state$domainStates3;
111
- if ((state === null || state === void 0 ? void 0 : (_state$domainStates3 = state.domainStates) === null || _state$domainStates3 === void 0 ? void 0 : _state$domainStates3.postChatContext) === undefined) {
111
+ var _state$domainStates2;
112
+ if ((state === null || state === void 0 ? void 0 : (_state$domainStates2 = state.domainStates) === null || _state$domainStates2 === void 0 ? void 0 : _state$domainStates2.postChatContext) === undefined) {
112
113
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
113
114
  const context = await chatSDK.getPostChatSurveyContext();
114
115
  _TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.INFO, {
@@ -119,6 +120,7 @@ const getPostChatContext = async (chatSDK, state, dispatch) => {
119
120
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_POST_CHAT_CONTEXT,
120
121
  payload: context
121
122
  });
123
+ return context;
122
124
  }
123
125
  } catch (error) {
124
126
  _TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.INFO, {
@@ -55,6 +55,7 @@ var _useChatAdapterStore = _interopRequireDefault(require("../../../hooks/useCha
55
55
  var _useChatContextStore = _interopRequireDefault(require("../../../hooks/useChatContextStore"));
56
56
  var _useChatSDKStore = _interopRequireDefault(require("../../../hooks/useChatSDKStore"));
57
57
  var _defaultAdaptiveCardStyles = require("../../webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles");
58
+ var _omnichannelChatSdk = require("@microsoft/omnichannel-chat-sdk");
58
59
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
59
60
  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); }
60
61
  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; }
@@ -93,8 +94,6 @@ const LiveChatWidgetStateful = props => {
93
94
  const lastLWICheckTimeRef = (0, _react2.useRef)(0);
94
95
  let optionalParams;
95
96
  let activeCachedChatExist = false;
96
- const uwid = (0, _react2.useRef)(""); // its an uniqueid per chatr instance
97
-
98
97
  const setOptionalParams = () => {
99
98
  var _state$appStates, _state$domainStates, _state$appStates3;
100
99
  if (!(0, _utils.isUndefinedOrEmpty)((_state$appStates = state.appStates) === null || _state$appStates === void 0 ? void 0 : _state$appStates.reconnectId)) {
@@ -195,7 +194,6 @@ const LiveChatWidgetStateful = props => {
195
194
  setupClientDataStore();
196
195
  (0, _registerTelemetryLoggers.registerTelemetryLoggers)(props, dispatch);
197
196
  (0, _createInternetConnectionChangeHandler.createInternetConnectionChangeHandler)();
198
- uwid.current = (0, _utils.newGuid)();
199
197
  dispatch({
200
198
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_WIDGET_ELEMENT_ID,
201
199
  payload: widgetElementId
@@ -328,23 +326,27 @@ const LiveChatWidgetStateful = props => {
328
326
 
329
327
  // Start chat from SDK Event
330
328
  _omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.StartChat).subscribe(msg => {
331
- var _msg$payload4;
329
+ var _msg$payload4, _msg$payload5, _msg$payload6;
330
+ // If the startChat event is not initiated by the same tab. Ignore the call
331
+ if (!(0, _utils.isNullOrUndefined)(msg === null || msg === void 0 ? void 0 : (_msg$payload4 = msg.payload) === null || _msg$payload4 === void 0 ? void 0 : _msg$payload4.runtimeId) && (msg === null || msg === void 0 ? void 0 : (_msg$payload5 = msg.payload) === null || _msg$payload5 === void 0 ? void 0 : _msg$payload5.runtimeId) !== _TelemetryManager.TelemetryManager.InternalTelemetryData.lcwRuntimeId) {
332
+ return;
333
+ }
332
334
  let stateWithUpdatedContext = state;
333
- if (msg !== null && msg !== void 0 && (_msg$payload4 = msg.payload) !== null && _msg$payload4 !== void 0 && _msg$payload4.customContext) {
334
- var _msg$payload5, _msg$payload6;
335
+ if (msg !== null && msg !== void 0 && (_msg$payload6 = msg.payload) !== null && _msg$payload6 !== void 0 && _msg$payload6.customContext) {
336
+ var _msg$payload7, _msg$payload8;
335
337
  _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
336
338
  Event: _TelemetryConstants.TelemetryEvent.CustomContextReceived,
337
339
  Description: "CustomContext received through startChat event."
338
340
  });
339
341
  dispatch({
340
342
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CUSTOM_CONTEXT,
341
- payload: msg === null || msg === void 0 ? void 0 : (_msg$payload5 = msg.payload) === null || _msg$payload5 === void 0 ? void 0 : _msg$payload5.customContext
343
+ payload: msg === null || msg === void 0 ? void 0 : (_msg$payload7 = msg.payload) === null || _msg$payload7 === void 0 ? void 0 : _msg$payload7.customContext
342
344
  });
343
345
  stateWithUpdatedContext = {
344
346
  ...state,
345
347
  domainStates: {
346
348
  ...state.domainStates,
347
- customContext: msg === null || msg === void 0 ? void 0 : (_msg$payload6 = msg.payload) === null || _msg$payload6 === void 0 ? void 0 : _msg$payload6.customContext
349
+ customContext: msg === null || msg === void 0 ? void 0 : (_msg$payload8 = msg.payload) === null || _msg$payload8 === void 0 ? void 0 : _msg$payload8.customContext
348
350
  }
349
351
  };
350
352
  }
@@ -422,9 +424,16 @@ const LiveChatWidgetStateful = props => {
422
424
  // Listen to end chat event from other tabs
423
425
  const endChatEventName = (0, _utils.getWidgetEndChatEventName)(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC2 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC2 === void 0 ? void 0 : _chatSDK$omnichannelC2.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC3 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC3 === void 0 ? void 0 : _chatSDK$omnichannelC3.widgetId, ((_props$controlProps10 = props.controlProps) === null || _props$controlProps10 === void 0 ? void 0 : _props$controlProps10.widgetInstanceId) ?? "");
424
426
  _omnichannelChatComponents.BroadcastService.getMessageByEventName(endChatEventName).subscribe(msg => {
425
- console.log("Receiving end chat event", JSON.stringify(msg.payload));
426
- if (msg.payload !== uwid.current) {
427
+ var _msg$payload9;
428
+ if ((msg === null || msg === void 0 ? void 0 : (_msg$payload9 = msg.payload) === null || _msg$payload9 === void 0 ? void 0 : _msg$payload9.runtimeId) !== _TelemetryManager.TelemetryManager.InternalTelemetryData.lcwRuntimeId) {
427
429
  (0, _endChat.endChat)(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, true, false, false);
430
+ (0, _endChat.endChatStateCleanUp)(dispatch);
431
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
432
+ chatSDK.requestId = (0, _omnichannelChatSdk.uuidv4)();
433
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
434
+ chatSDK.chatToken = {};
435
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
436
+ chatSDK.reconnectId = null;
428
437
  return;
429
438
  }
430
439
  });
@@ -552,13 +561,13 @@ const LiveChatWidgetStateful = props => {
552
561
 
553
562
  // If start chat failed, and C2 is trying to close chat widget
554
563
  if (state !== null && state !== void 0 && (_state$appStates9 = state.appStates) !== null && _state$appStates9 !== void 0 && _state$appStates9.startChatFailed || (state === null || state === void 0 ? void 0 : (_state$appStates10 = state.appStates) === null || _state$appStates10 === void 0 ? void 0 : _state$appStates10.conversationState) === _ConversationState.ConversationState.Postchat) {
555
- (0, _endChat.endChat)(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, true, false, true, uwid.current);
564
+ (0, _endChat.endChat)(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, true, false, true);
556
565
  return;
557
566
  }
558
567
 
559
568
  // Scenario -> Chat was InActive and closing the chat (Refresh scenario on post chat)
560
569
  if ((state === null || state === void 0 ? void 0 : (_state$appStates11 = state.appStates) === null || _state$appStates11 === void 0 ? void 0 : _state$appStates11.conversationState) === _ConversationState.ConversationState.InActive) {
561
- (0, _endChat.endChat)(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, true, uwid.current);
570
+ (0, _endChat.endChat)(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, true);
562
571
  return;
563
572
  }
564
573
  if ((state === null || state === void 0 ? void 0 : (_state$appStates12 = state.appStates) === null || _state$appStates12 === void 0 ? void 0 : _state$appStates12.conversationEndedBy) === _Constants.ConversationEndEntity.Agent || (state === null || state === void 0 ? void 0 : (_state$appStates13 = state.appStates) === null || _state$appStates13 === void 0 ? void 0 : _state$appStates13.conversationEndedBy) === _Constants.ConversationEndEntity.Bot) {
@@ -569,7 +578,7 @@ const LiveChatWidgetStateful = props => {
569
578
  }
570
579
 
571
580
  // All other cases
572
- (0, _endChat.prepareEndChat)(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, uwid.current);
581
+ (0, _endChat.prepareEndChat)(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter);
573
582
  }, [state === null || state === void 0 ? void 0 : (_state$appStates14 = state.appStates) === null || _state$appStates14 === void 0 ? void 0 : _state$appStates14.conversationEndedBy]);
574
583
 
575
584
  // Publish chat widget state
@@ -627,13 +636,13 @@ const LiveChatWidgetStateful = props => {
627
636
  };
628
637
  const setPostChatContextRelay = () => (0, _setPostChatContextAndLoadSurvey.setPostChatContextAndLoadSurvey)(chatSDK, dispatch);
629
638
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
630
- const endChatRelay = (adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTab) => (0, _endChat.endChat)(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTab, uwid.current);
639
+ const endChatRelay = (adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTab) => (0, _endChat.endChat)(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTab);
631
640
  const prepareStartChatRelay = () => (0, _startChat.prepareStartChat)(props, chatSDK, state, dispatch, setAdapter);
632
641
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
633
642
  const initStartChatRelay = (optionalParams, persistedState) => (0, _startChat.initStartChat)(chatSDK, dispatch, setAdapter, state, props, optionalParams, persistedState);
634
643
  const confirmationPaneProps = (0, _initConfirmationPropsComposer.initConfirmationPropsComposer)(props);
635
644
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
636
- const prepareEndChatRelay = () => (0, _endChat.prepareEndChat)(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, uwid.current);
645
+ const prepareEndChatRelay = () => (0, _endChat.prepareEndChat)(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter);
637
646
  const webChatProps = (0, _initWebChatComposer.initWebChatComposer)(props, state, dispatch, chatSDK, endChatRelay);
638
647
  const downloadTranscriptProps = (0, _createDownloadTranscriptProps.default)(props.downloadTranscriptProps, {
639
648
  ...(_defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps === null || _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps === void 0 ? void 0 : _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.webChatStyles),
@@ -55,13 +55,11 @@ const createMagicCodeSuccessResponse = signin => {
55
55
  };
56
56
  };
57
57
  const WebChatContainerStateful = props => {
58
- var _webChatContainerProp, _webChatContainerProp2, _webChatContainerProp3, _webChatContainerProp4, _webChatContainerProp5, _webChatContainerProp6, _props$webChatContain3, _props$webChatContain4, _defaultWebChatContai, _props$webChatContain5, _props$webChatContain6, _defaultWebChatContai2, _webChatContainerProp7, _webChatContainerProp8, _webChatContainerProp9, _webChatContainerProp10, _webChatContainerProp11, _webChatContainerProp12, _webChatContainerProp13, _webChatContainerProp14;
58
+ var _webChatContainerProp, _webChatContainerProp2, _webChatContainerProp3, _webChatContainerProp4, _webChatContainerProp5, _webChatContainerProp6, _props$webChatContain5, _props$webChatContain6, _defaultWebChatContai, _props$webChatContain7, _props$webChatContain8, _defaultWebChatContai2, _webChatContainerProp7, _webChatContainerProp8, _webChatContainerProp9, _webChatContainerProp10, _webChatContainerProp11, _webChatContainerProp12, _webChatContainerProp13, _webChatContainerProp14;
59
59
  const {
60
60
  BasicWebChat
61
61
  } = _botframeworkWebchat.Components;
62
62
  const [state, dispatch] = (0, _.useChatContextStore)();
63
- const magicCodeBroadcastChannel = new window.BroadcastChannel(_Constants.Constants.magicCodeBroadcastChannel); // eslint-disable-line @typescript-eslint/no-explicit-any
64
- const magicCodeResponseBroadcastChannel = new window.BroadcastChannel(_Constants.Constants.magicCodeResponseBroadcastChannel); // eslint-disable-line @typescript-eslint/no-explicit-any
65
63
  const {
66
64
  webChatContainerProps,
67
65
  contextDataStore
@@ -69,7 +67,7 @@ const WebChatContainerStateful = props => {
69
67
  const containerStyles = {
70
68
  root: Object.assign({}, _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.containerStyles, webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : webChatContainerProps.containerStyles, {
71
69
  display: state.appStates.isMinimized ? "none" : ""
72
- }) // Use this instead of removing WebChat from the picture so that the activity observer inside the adapter is not invoked
70
+ }) // Use this instead of removing WebChat from the picture so that the activity observer inside the adapter is not invoked
73
71
  };
74
72
 
75
73
  const localizedTexts = {
@@ -103,6 +101,21 @@ const WebChatContainerStateful = props => {
103
101
  }
104
102
  }, []);
105
103
  (0, _react2.useEffect)(() => {
104
+ var _props$webChatContain3, _props$webChatContain4;
105
+ if (!((_props$webChatContain3 = props.webChatContainerProps) !== null && _props$webChatContain3 !== void 0 && (_props$webChatContain4 = _props$webChatContain3.botMagicCode) !== null && _props$webChatContain4 !== void 0 && _props$webChatContain4.disabled)) {
106
+ return;
107
+ }
108
+ if (!window.BroadcastChannel) {
109
+ // eslint-disable-line @typescript-eslint/no-explicit-any
110
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
111
+ Event: _TelemetryConstants.TelemetryEvent.SuppressBotMagicCodeFailed,
112
+ Description: "BroadcastChannel not supported by default on current browser"
113
+ });
114
+ return;
115
+ }
116
+ const magicCodeBroadcastChannel = new window.BroadcastChannel(_Constants.Constants.magicCodeBroadcastChannel); // eslint-disable-line @typescript-eslint/no-explicit-any
117
+ const magicCodeResponseBroadcastChannel = new window.BroadcastChannel(_Constants.Constants.magicCodeResponseBroadcastChannel); // eslint-disable-line @typescript-eslint/no-explicit-any
118
+
106
119
  const eventListener = event => {
107
120
  // eslint-disable-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-empty-function
108
121
  const {
@@ -156,8 +169,8 @@ const WebChatContainerStateful = props => {
156
169
  div[class="ac-input-container"] * {white-space:${(webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : (_webChatContainerProp6 = webChatContainerProps.adaptiveCardStyles) === null || _webChatContainerProp6 === void 0 ? void 0 : _webChatContainerProp6.textWhiteSpace) ?? _defaultAdaptiveCardStyles.defaultAdaptiveCardStyles.textWhiteSpace}}
157
170
 
158
171
  .ms_lcw_webchat_received_message>div.webchat__stacked-layout>div.webchat__stacked-layout__main>div.webchat__stacked-layout__content>div.webchat__stacked-layout__message-row>[class^=webchat]:not(.webchat__bubble--from-user)>.webchat__bubble__content {
159
- background-color: ${((_props$webChatContain3 = props.webChatContainerProps) === null || _props$webChatContain3 === void 0 ? void 0 : (_props$webChatContain4 = _props$webChatContain3.webChatStyles) === null || _props$webChatContain4 === void 0 ? void 0 : _props$webChatContain4.bubbleBackground) ?? ((_defaultWebChatContai = _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.webChatStyles) === null || _defaultWebChatContai === void 0 ? void 0 : _defaultWebChatContai.bubbleBackground)};
160
- color:${((_props$webChatContain5 = props.webChatContainerProps) === null || _props$webChatContain5 === void 0 ? void 0 : (_props$webChatContain6 = _props$webChatContain5.webChatStyles) === null || _props$webChatContain6 === void 0 ? void 0 : _props$webChatContain6.bubbleTextColor) ?? ((_defaultWebChatContai2 = _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.webChatStyles) === null || _defaultWebChatContai2 === void 0 ? void 0 : _defaultWebChatContai2.bubbleTextColor)};
172
+ background-color: ${((_props$webChatContain5 = props.webChatContainerProps) === null || _props$webChatContain5 === void 0 ? void 0 : (_props$webChatContain6 = _props$webChatContain5.webChatStyles) === null || _props$webChatContain6 === void 0 ? void 0 : _props$webChatContain6.bubbleBackground) ?? ((_defaultWebChatContai = _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.webChatStyles) === null || _defaultWebChatContai === void 0 ? void 0 : _defaultWebChatContai.bubbleBackground)};
173
+ color:${((_props$webChatContain7 = props.webChatContainerProps) === null || _props$webChatContain7 === void 0 ? void 0 : (_props$webChatContain8 = _props$webChatContain7.webChatStyles) === null || _props$webChatContain8 === void 0 ? void 0 : _props$webChatContain8.bubbleTextColor) ?? ((_defaultWebChatContai2 = _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.webChatStyles) === null || _defaultWebChatContai2 === void 0 ? void 0 : _defaultWebChatContai2.bubbleTextColor)};
161
174
  }
162
175
 
163
176
  div[class="ac-textBlock"] a:link,
@@ -165,11 +178,11 @@ const WebChatContainerStateful = props => {
165
178
  div[class="ac-textBlock"] a:hover,
166
179
  div[class="ac-textBlock"] a:active {
167
180
  color: ${(webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : (_webChatContainerProp7 = webChatContainerProps.adaptiveCardStyles) === null || _webChatContainerProp7 === void 0 ? void 0 : _webChatContainerProp7.anchorColor) ?? _defaultAdaptiveCardStyles.defaultAdaptiveCardStyles.anchorColor};
168
- }
181
+ }
169
182
 
170
183
  .webchat__stacked-layout__content .ac-actionSet > .ac-pushButton > div {white-space: ${(webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : (_webChatContainerProp8 = webChatContainerProps.adaptiveCardStyles) === null || _webChatContainerProp8 === void 0 ? void 0 : _webChatContainerProp8.buttonWhiteSpace) ?? _defaultAdaptiveCardStyles.defaultAdaptiveCardStyles.buttonWhiteSpace} !important;}
171
184
 
172
- .ms_lcw_webchat_received_message img.webchat__markdown__external-link-icon {
185
+ .ms_lcw_webchat_received_message img.webchat__markdown__external-link-icon {
173
186
  background-image : url(data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIzIDMgMTggMTgiICB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxwYXRoIGQ9Ik03LjI1MDEgNC41MDAxN0gxMC43NDk1QzExLjE2MzcgNC41MDAxNyAxMS40OTk1IDQuODM1OTYgMTEuNDk5NSA1LjI1MDE3QzExLjQ5OTUgNS42Mjk4NiAxMS4yMTczIDUuOTQzNjYgMTAuODUxMyA1Ljk5MzMyTDEwLjc0OTUgNi4wMDAxN0g3LjI0OTc0QzYuMDcwNzkgNS45OTk2MSA1LjEwMzQ5IDYuOTA2NTYgNS4wMDc4NiA4LjA2MTEyTDUuMDAwMjggOC4yMjAwM0w1LjAwMzEyIDE2Ljc1MDdDNS4wMDM0MyAxNy45NDE1IDUuOTI4ODUgMTguOTE2MSA3LjA5OTY2IDE4Ljk5NDlMNy4yNTM3MSAxOS4wMDAxTDE1Ljc1MTggMTguOTg4NEMxNi45NDE1IDE4Ljk4NjggMTcuOTE0NSAxOC4wNjIgMTcuOTkzNSAxNi44OTIzTDE3Ljk5ODcgMTYuNzM4NFYxMy4yMzIxQzE3Ljk5ODcgMTIuODE3OSAxOC4zMzQ1IDEyLjQ4MjEgMTguNzQ4NyAxMi40ODIxQzE5LjEyODQgMTIuNDgyMSAxOS40NDIyIDEyLjc2NDMgMTkuNDkxOCAxMy4xMzAzTDE5LjQ5ODcgMTMuMjMyMVYxNi43Mzg0QzE5LjQ5ODcgMTguNzQwNyAxNy45MjkzIDIwLjM3NjkgMTUuOTUyOCAyMC40ODI5TDE1Ljc1MzggMjAuNDg4NEw3LjI1ODI3IDIwLjUwMDFMNy4wNTQ5NSAyMC40OTQ5QzUuMTQyMzkgMjAuMzk1NCAzLjYwODk1IDE4Ljg2MjcgMy41MDgzNyAxNi45NTAyTDMuNTAzMTIgMTYuNzUxMUwzLjUwMDg5IDguMjUyN0wzLjUwNTI5IDguMDUwMkMzLjYwNTM5IDYuMTM3NDkgNS4xMzg2NyA0LjYwNDQ5IDcuMDUwOTYgNC41MDUyN0w3LjI1MDEgNC41MDAxN0gxMC43NDk1SDcuMjUwMVpNMTMuNzQ4MSAzLjAwMTQ2TDIwLjMwMTggMy4wMDE5N0wyMC40MDE0IDMuMDE1NzVMMjAuNTAyMiAzLjA0MzkzTDIwLjU1OSAzLjA2ODAzQzIwLjYxMjIgMy4wOTEyMiAyMC42NjM0IDMuMTIxNjMgMjAuNzExMSAzLjE1ODg1TDIwLjc4MDQgMy4yMjE1NkwyMC44NjQxIDMuMzIwMTRMMjAuOTE4MyAzLjQxMDI1TDIwLjk1NyAzLjUwMDU3TDIwLjk3NjIgMy41NjQ3NkwyMC45ODk4IDMuNjI4NjJMMjAuOTk5MiAzLjcyMjgyTDIwLjk5OTcgMTAuMjU1NEMyMC45OTk3IDEwLjY2OTYgMjAuNjYzOSAxMS4wMDU0IDIwLjI0OTcgMTEuMDA1NEMxOS44NyAxMS4wMDU0IDE5LjU1NjIgMTAuNzIzMiAxOS41MDY1IDEwLjM1NzFMMTkuNDk5NyAxMC4yNTU0TDE5LjQ5ODkgNS41NjE0N0wxMi4yNzk3IDEyLjc4NDdDMTIuMDEzNCAxMy4wNTEgMTEuNTk2OCAxMy4wNzUzIDExLjMwMzEgMTIuODU3NUwxMS4yMTkgMTIuNzg0OUMxMC45NTI3IDEyLjUxODcgMTAuOTI4NCAxMi4xMDIxIDExLjE0NjIgMTEuODA4NEwxMS4yMTg4IDExLjcyNDNMMTguNDM2OSA0LjUwMTQ2SDEzLjc0ODFDMTMuMzY4NCA0LjUwMTQ2IDEzLjA1NDYgNC4yMTkzMSAxMy4wMDUgMy44NTMyNEwxMi45OTgxIDMuNzUxNDZDMTIuOTk4MSAzLjM3MTc3IDEzLjI4MDMgMy4wNTc5NyAxMy42NDY0IDMuMDA4MzFMMTMuNzQ4MSAzLjAwMTQ2WiIgZmlsbD0iI0ZGRkZGRiIgLz48L3N2Zz4) !important;
174
187
  height: '.75em';
175
188
  marginLeft: '.25em';
@@ -187,7 +200,7 @@ const WebChatContainerStateful = props => {
187
200
  .ms_lcw_webchat_received_message a:hover,
188
201
  .ms_lcw_webchat_received_message a:active {
189
202
  color: ${(webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : (_webChatContainerProp11 = webChatContainerProps.renderingMiddlewareProps) === null || _webChatContainerProp11 === void 0 ? void 0 : (_webChatContainerProp12 = _webChatContainerProp11.receivedMessageAnchorStyles) === null || _webChatContainerProp12 === void 0 ? void 0 : _webChatContainerProp12.color) ?? (_defaultReceivedMessageAnchorStyles.defaultReceivedMessageAnchorStyles === null || _defaultReceivedMessageAnchorStyles.defaultReceivedMessageAnchorStyles === void 0 ? void 0 : _defaultReceivedMessageAnchorStyles.defaultReceivedMessageAnchorStyles.color)};
190
- }
203
+ }
191
204
  .ms_lcw_webchat_sent_message a:link,
192
205
  .ms_lcw_webchat_sent_message a:visited,
193
206
  .ms_lcw_webchat_sent_message a:hover,
@@ -32,6 +32,8 @@ const defaultMiddlewareLocalizedTexts = {
32
32
  MIDDLEWARE_MESSAGE_RETRY: "Retry",
33
33
  MIDDLEWARE_BANNER_CHAT_DISCONNECT: "Your conversation has been disconnected. For additional assistance, please start a new chat.",
34
34
  THIRD_PARTY_COOKIES_BLOCKED_ALERT_MESSAGE: "Third party cookies are blocked. Reloading this page will start a new conversation.",
35
- MIDDLEWARE_BANNER_FILE_IS_MALICIOUS: "{0} has been blocked because the file may contain a malware."
35
+ MIDDLEWARE_BANNER_FILE_IS_MALICIOUS: "{0} has been blocked because the file may contain a malware.",
36
+ MIDDLEWARE_BANNER_FILE_EMAIL_ADDRESS_RECORDED_SUCCESS: "Email will be sent after chat ends!",
37
+ MIDDLEWARE_BANNER_FILE_EMAIL_ADDRESS_RECORDED_ERROR: "Email {0} could not be saved, try again later."
36
38
  };
37
39
  exports.defaultMiddlewareLocalizedTexts = defaultMiddlewareLocalizedTexts;
@@ -10,6 +10,7 @@ exports.NotificationScenarios = NotificationScenarios;
10
10
  NotificationScenarios["Connection"] = "connection";
11
11
  NotificationScenarios["DownloadTranscriptError"] = "download transcript";
12
12
  NotificationScenarios["EmailTranscriptError"] = "email transcript";
13
+ NotificationScenarios["EmailAddressSaved"] = "email address saved";
13
14
  NotificationScenarios["AttachmentError"] = "attachment";
14
15
  NotificationScenarios["InternetConnection"] = "internet connection";
15
16
  NotificationScenarios["MaxSizeError"] = "max size";
@@ -396,4 +396,20 @@ export const createFileAndDownload = (fileName, blobData, mimeType) => {
396
396
  document.body.appendChild(aElement);
397
397
  aElement.click();
398
398
  document.body.removeChild(aElement);
399
+ };
400
+
401
+ /**
402
+ *
403
+ * Replace placeholders with format {0}..{n} , in a string with values
404
+ *
405
+ * @param template String with placeholders to be replaced
406
+ * @param values array of values to replace the placeholders
407
+ * @returns formatted string with replaced values
408
+ */
409
+ // use of any for values as array of any type is passed
410
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
411
+ export const formatTemplateString = (templateMessage, values) => {
412
+ return templateMessage.replace(/{(\d+)}/g, (match, index) => {
413
+ return typeof values[index] !== "undefined" ? values[index] : match;
414
+ });
399
415
  };
@@ -1,6 +1,6 @@
1
1
  import { LogLevel, TelemetryEvent } from "../../common/telemetry/TelemetryConstants";
2
2
  import React, { useEffect, useState } from "react";
3
- import { findAllFocusableElement, findParentFocusableElementsWithoutChildContainer, preventFocusToMoveOutOfElement, setFocusOnElement, setFocusOnSendBox, setTabIndices } from "../../common/utils";
3
+ import { findAllFocusableElement, findParentFocusableElementsWithoutChildContainer, formatTemplateString, preventFocusToMoveOutOfElement, setFocusOnElement, setFocusOnSendBox, setTabIndices } from "../../common/utils";
4
4
  import { DimLayer } from "../dimlayer/DimLayer";
5
5
  import { InputValidationPane } from "@microsoft/omnichannel-chat-components";
6
6
  import { LiveChatWidgetActionType } from "../../contexts/common/LiveChatWidgetActionType";
@@ -10,6 +10,7 @@ import { Regex } from "../../common/Constants";
10
10
  import { TelemetryHelper } from "../../common/telemetry/TelemetryHelper";
11
11
  import useChatContextStore from "../../hooks/useChatContextStore";
12
12
  import useChatSDKStore from "../../hooks/useChatSDKStore";
13
+ import { defaultMiddlewareLocalizedTexts } from "../webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts";
13
14
  export const EmailTranscriptPaneStateful = props => {
14
15
  var _props$controlProps;
15
16
  const initialTabIndexMap = new Map();
@@ -46,6 +47,7 @@ export const EmailTranscriptPaneStateful = props => {
46
47
  };
47
48
  try {
48
49
  await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.emailLiveChatTranscript(chatTranscriptBody));
50
+ NotificationHandler.notifySuccess(NotificationScenarios.EmailAddressSaved, defaultMiddlewareLocalizedTexts === null || defaultMiddlewareLocalizedTexts === void 0 ? void 0 : defaultMiddlewareLocalizedTexts.MIDDLEWARE_BANNER_FILE_EMAIL_ADDRESS_RECORDED_SUCCESS);
49
51
  TelemetryHelper.logActionEvent(LogLevel.INFO, {
50
52
  Event: TelemetryEvent.EmailTranscriptSent,
51
53
  Description: "Transcript sent to email successfully."
@@ -57,7 +59,8 @@ export const EmailTranscriptPaneStateful = props => {
57
59
  exception: ex
58
60
  }
59
61
  });
60
- NotificationHandler.notifyError(NotificationScenarios.EmailTranscriptError, (props === null || props === void 0 ? void 0 : props.bannerMessageOnError) ?? "Email transcript to " + email + " failed.");
62
+ const message = formatTemplateString(defaultMiddlewareLocalizedTexts.MIDDLEWARE_BANNER_FILE_EMAIL_ADDRESS_RECORDED_ERROR, [email]);
63
+ NotificationHandler.notifyError(NotificationScenarios.EmailTranscriptError, (props === null || props === void 0 ? void 0 : props.bannerMessageOnError) ?? message);
61
64
  }
62
65
  },
63
66
  onCancel: () => {
@@ -1,7 +1,7 @@
1
1
  import { ConfirmationState, Constants, ConversationEndEntity, ParticipantType } from "../../../common/Constants";
2
2
  import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
3
3
  import { getAuthClientFunction, handleAuthentication } from "./authHelper";
4
- import { getConversationDetailsCall, getWidgetEndChatEventName, isNullOrEmptyString } from "../../../common/utils";
4
+ import { getConversationDetailsCall, getWidgetEndChatEventName } from "../../../common/utils";
5
5
  import { getPostChatContext, initiatePostChat } from "./renderSurveyHelpers";
6
6
  import { BroadcastService } from "@microsoft/omnichannel-chat-components";
7
7
  import { ConversationState } from "../../../contexts/common/ConversationState";
@@ -9,11 +9,12 @@ import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidge
9
9
  import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
10
10
  import { WebChatStoreLoader } from "../../webchatcontainerstateful/webchatcontroller/WebChatStoreLoader";
11
11
  import { defaultWebChatContainerStatefulProps } from "../../webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps";
12
+ import { TelemetryManager } from "../../../common/telemetry/TelemetryManager";
12
13
 
13
14
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
14
- const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, uwid) => {
15
+ const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter) => {
15
16
  try {
16
- var _conversationDetails$, _state$domainStates, _state$domainStates2;
17
+ var _conversationDetails$, _state$domainStates;
17
18
  // Use Case: If call is ongoing, end the call by simulating end call button click
18
19
  endVoiceVideoCallIfOngoing(chatSDK, dispatch);
19
20
  const conversationDetails = await getConversationDetailsCall(chatSDK);
@@ -23,7 +24,7 @@ const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWe
23
24
  var _state$appStates;
24
25
  // If ended by customer, just close chat
25
26
  if ((state === null || state === void 0 ? void 0 : (_state$appStates = state.appStates) === null || _state$appStates === void 0 ? void 0 : _state$appStates.conversationEndedBy) === ConversationEndEntity.Customer) {
26
- await endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, true, uwid);
27
+ await endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, true);
27
28
  }
28
29
  // Use Case: If ended by Agent, stay chat in InActive state
29
30
  return;
@@ -38,15 +39,13 @@ const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWe
38
39
  }
39
40
 
40
41
  // Use Case: Can render post chat scenarios
41
- await getPostChatContext(chatSDK, state, dispatch);
42
-
43
42
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
44
- const postchatContext = state === null || state === void 0 ? void 0 : (_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : _state$domainStates.postChatContext;
43
+ const postchatContext = (await getPostChatContext(chatSDK, state, dispatch)) ?? (state === null || state === void 0 ? void 0 : (_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : _state$domainStates.postChatContext);
45
44
  if (postchatContext === undefined) {
46
45
  var _state$appStates2;
47
46
  // For Customer intiated conversations, just close chat widget
48
47
  if ((state === null || state === void 0 ? void 0 : (_state$appStates2 = state.appStates) === null || _state$appStates2 === void 0 ? void 0 : _state$appStates2.conversationEndedBy) === ConversationEndEntity.Customer) {
49
- await endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, true, uwid);
48
+ await endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, true);
50
49
  return;
51
50
  }
52
51
 
@@ -57,10 +56,10 @@ const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWe
57
56
  });
58
57
  return;
59
58
  }
60
- endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, true, true, uwid);
59
+ endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, true, true);
61
60
 
62
61
  // Initiate post chat render
63
- if (state !== null && state !== void 0 && (_state$domainStates2 = state.domainStates) !== null && _state$domainStates2 !== void 0 && _state$domainStates2.postChatContext) {
62
+ if (postchatContext) {
64
63
  await initiatePostChat(props, conversationDetails, state, dispatch, postchatContext);
65
64
  return;
66
65
  }
@@ -75,7 +74,7 @@ const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWe
75
74
 
76
75
  //Close chat widget for any failure in embedded to allow to show start chat button
77
76
  if (((_props$controlProps = props.controlProps) === null || _props$controlProps === void 0 ? void 0 : _props$controlProps.hideStartChatButton) === false) {
78
- await endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, true, uwid);
77
+ await endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, true);
79
78
  }
80
79
  } finally {
81
80
  //Chat token clean up
@@ -84,8 +83,7 @@ const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWe
84
83
  };
85
84
 
86
85
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
87
- const endChat = async function (props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTab) {
88
- let uwid = arguments.length > 10 && arguments[10] !== undefined ? arguments[10] : "";
86
+ const endChat = async (props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTab) => {
89
87
  if (!skipEndChatSDK && chatSDK.conversation) {
90
88
  try {
91
89
  TelemetryHelper.logSDKEvent(LogLevel.INFO, {
@@ -137,15 +135,17 @@ const endChat = async function (props, chatSDK, state, dispatch, setAdapter, set
137
135
  closeChatWidget(dispatch, props, state);
138
136
  }
139
137
  }
140
- if (postMessageToOtherTab && !isNullOrEmptyString(uwid)) {
138
+ if (postMessageToOtherTab) {
141
139
  const endChatEventName = await getEndChatEventName(chatSDK, props);
142
140
  BroadcastService.postMessage({
143
141
  eventName: endChatEventName,
144
- payload: uwid
142
+ payload: {
143
+ runtimeId: TelemetryManager.InternalTelemetryData.lcwRuntimeId
144
+ }
145
145
  });
146
146
  }
147
147
  };
148
- const callingStateCleanUp = async dispatch => {
148
+ export const callingStateCleanUp = async dispatch => {
149
149
  dispatch({
150
150
  type: LiveChatWidgetActionType.SHOW_CALLING_CONTAINER,
151
151
  payload: false
@@ -167,7 +167,7 @@ const callingStateCleanUp = async dispatch => {
167
167
  payload: true
168
168
  });
169
169
  };
170
- const endChatStateCleanUp = async dispatch => {
170
+ export const endChatStateCleanUp = async dispatch => {
171
171
  // Need to clear these states immediately when chat ended from OC.
172
172
  dispatch({
173
173
  type: LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
@@ -182,7 +182,7 @@ const endChatStateCleanUp = async dispatch => {
182
182
  payload: false
183
183
  });
184
184
  };
185
- const closeChatStateCleanUp = async dispatch => {
185
+ export const closeChatStateCleanUp = async dispatch => {
186
186
  dispatch({
187
187
  type: LiveChatWidgetActionType.SET_CHAT_TOKEN,
188
188
  payload: undefined
@@ -42,24 +42,25 @@ const setSurveyMode = async (props, participantType, state, dispatch) => {
42
42
  return;
43
43
  }
44
44
  };
45
- const renderSurvey = async (state, dispatch) => {
45
+
46
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
47
+ const renderSurvey = async (postChatContext, dispatch) => {
46
48
  if (postChatSurveyMode === PostChatSurveyMode.Link) {
47
49
  setWidgetStateToInactive(dispatch);
48
50
  return;
49
51
  }
50
52
  if (postChatSurveyMode === PostChatSurveyMode.Embed) {
51
- await embedModePostChatWorkflow(state, dispatch);
53
+ await embedModePostChatWorkflow(postChatContext, dispatch);
52
54
  }
53
55
  };
54
56
 
55
57
  // Function for embed mode postchat workflow which is essentially same for both customer and agent
56
58
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
57
- const embedModePostChatWorkflow = async (state, dispatch) => {
58
- var _state$domainStates2;
59
+ const embedModePostChatWorkflow = async (postChatContext, dispatch) => {
59
60
  TelemetryHelper.logActionEvent(LogLevel.INFO, {
60
61
  Event: TelemetryEvent.EmbedModePostChatWorkflowStarted
61
62
  });
62
- if (state !== null && state !== void 0 && (_state$domainStates2 = state.domainStates) !== null && _state$domainStates2 !== void 0 && _state$domainStates2.postChatContext) {
63
+ if (postChatContext) {
63
64
  dispatch({
64
65
  type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
65
66
  payload: ConversationState.PostchatLoading
@@ -70,7 +71,7 @@ const embedModePostChatWorkflow = async (state, dispatch) => {
70
71
  payload: ConversationState.Postchat
71
72
  });
72
73
  } else {
73
- const error = `Conversation was Ended but App State was not set correctly: postChatContext = ${state.domainStates.postChatContext}`;
74
+ const error = `Conversation was Ended but App State was not set correctly: postChatContext = ${postChatContext}`;
74
75
  TelemetryHelper.logActionEvent(LogLevel.ERROR, {
75
76
  Event: TelemetryEvent.AppStatesException,
76
77
  ExceptionDetails: {
@@ -86,7 +87,7 @@ const initiatePostChat = async (props, conversationDetailsParam, state, dispatch
86
87
  conversationDetails = conversationDetailsParam;
87
88
  const participantType = ((_conversationDetails = conversationDetails) === null || _conversationDetails === void 0 ? void 0 : _conversationDetails.participantType) ?? postchatContext.participantType;
88
89
  await setSurveyMode(props, participantType, state, dispatch);
89
- await renderSurvey(state, dispatch);
90
+ await renderSurvey(postchatContext, dispatch);
90
91
  };
91
92
 
92
93
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -99,8 +100,8 @@ const isPostChatEnabled = (props, state) => {
99
100
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
100
101
  const getPostChatContext = async (chatSDK, state, dispatch) => {
101
102
  try {
102
- var _state$domainStates3;
103
- if ((state === null || state === void 0 ? void 0 : (_state$domainStates3 = state.domainStates) === null || _state$domainStates3 === void 0 ? void 0 : _state$domainStates3.postChatContext) === undefined) {
103
+ var _state$domainStates2;
104
+ if ((state === null || state === void 0 ? void 0 : (_state$domainStates2 = state.domainStates) === null || _state$domainStates2 === void 0 ? void 0 : _state$domainStates2.postChatContext) === undefined) {
104
105
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
105
106
  const context = await chatSDK.getPostChatSurveyContext();
106
107
  TelemetryHelper.logSDKEvent(LogLevel.INFO, {
@@ -111,6 +112,7 @@ const getPostChatContext = async (chatSDK, state, dispatch) => {
111
112
  type: LiveChatWidgetActionType.SET_POST_CHAT_CONTEXT,
112
113
  payload: context
113
114
  });
115
+ return context;
114
116
  }
115
117
  } catch (error) {
116
118
  TelemetryHelper.logSDKEvent(LogLevel.INFO, {
@@ -6,9 +6,9 @@ import { ConfirmationState, Constants, ConversationEndEntity, E2VVOptions, LiveW
6
6
  import { Stack } from "@fluentui/react";
7
7
  import React, { useEffect, useRef, useState } from "react";
8
8
  import { checkIfConversationStillValid, initStartChat, prepareStartChat, setPreChatAndInitiateChat } from "../common/startChat";
9
- import { createTimer, getBroadcastChannelName, getConversationDetailsCall, getLocaleDirection, getStateFromCache, getWidgetCacheIdfromProps, getWidgetEndChatEventName, isNullOrEmptyString, isUndefinedOrEmpty, newGuid } from "../../../common/utils";
9
+ import { createTimer, getBroadcastChannelName, getConversationDetailsCall, getLocaleDirection, getStateFromCache, getWidgetCacheIdfromProps, getWidgetEndChatEventName, isNullOrEmptyString, isNullOrUndefined, isUndefinedOrEmpty } from "../../../common/utils";
10
10
  import { defaultClientDataStoreProvider, isCookieAllowed } from "../../../common/storage/default/defaultClientDataStoreProvider";
11
- import { endChat, prepareEndChat } from "../common/endChat";
11
+ import { endChat, endChatStateCleanUp, prepareEndChat } from "../common/endChat";
12
12
  import { handleChatReconnect, isPersistentEnabled, isReconnectEnabled } from "../common/reconnectChatHelper";
13
13
  import { shouldShowCallingContainer, shouldShowChatButton, shouldShowConfirmationPane, shouldShowEmailTranscriptPane, shouldShowHeader, shouldShowLoadingPane, shouldShowOutOfOfficeHoursPane, shouldShowPostChatLoadingPane, shouldShowPostChatSurveyPane, shouldShowPreChatSurveyPane, shouldShowProactiveChatPane, shouldShowReconnectChatPane, shouldShowWebChatContainer } from "../../../controller/componentController";
14
14
  import { ActivityStreamHandler } from "../common/ActivityStreamHandler";
@@ -30,7 +30,7 @@ import PreChatSurveyPaneStateful from "../../prechatsurveypanestateful/PreChatSu
30
30
  import ProactiveChatPaneStateful from "../../proactivechatpanestateful/ProactiveChatPaneStateful";
31
31
  import ReconnectChatPaneStateful from "../../reconnectchatpanestateful/ReconnectChatPaneStateful";
32
32
  import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
33
- import { TelemetryTimers } from "../../../common/telemetry/TelemetryManager";
33
+ import { TelemetryManager, TelemetryTimers } from "../../../common/telemetry/TelemetryManager";
34
34
  import WebChatContainerStateful from "../../webchatcontainerstateful/WebChatContainerStateful";
35
35
  import createDownloadTranscriptProps from "../common/createDownloadTranscriptProps";
36
36
  import { createFooter } from "../common/createFooter";
@@ -51,6 +51,7 @@ import useChatAdapterStore from "../../../hooks/useChatAdapterStore";
51
51
  import useChatContextStore from "../../../hooks/useChatContextStore";
52
52
  import useChatSDKStore from "../../../hooks/useChatSDKStore";
53
53
  import { defaultAdaptiveCardStyles } from "../../webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles";
54
+ import { uuidv4 } from "@microsoft/omnichannel-chat-sdk";
54
55
  export const LiveChatWidgetStateful = props => {
55
56
  var _props$webChatContain, _props$styleProps, _chatSDK$omnichannelC, _props$controlProps, _props$controlProps2, _state$appStates7, _props$webChatContain5, _state$appStates14, _props$webChatContain6, _props$controlProps11, _props$draggableChatW, _props$draggableChatW2, _props$draggableChatW3, _props$draggableChatW4, _props$draggableChatW5, _props$webChatContain7, _props$webChatContain8, _props$webChatContain9, _props$webChatContain10, _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$contro10, _livechatProps$compon8, _livechatProps$contro11, _livechatProps$compon9, _livechatProps$contro12, _livechatProps$compon10, _livechatProps$compon11, _livechatProps$compon12;
56
57
  const [state, dispatch] = useChatContextStore();
@@ -85,8 +86,6 @@ export const LiveChatWidgetStateful = props => {
85
86
  const lastLWICheckTimeRef = useRef(0);
86
87
  let optionalParams;
87
88
  let activeCachedChatExist = false;
88
- const uwid = useRef(""); // its an uniqueid per chatr instance
89
-
90
89
  const setOptionalParams = () => {
91
90
  var _state$appStates, _state$domainStates, _state$appStates3;
92
91
  if (!isUndefinedOrEmpty((_state$appStates = state.appStates) === null || _state$appStates === void 0 ? void 0 : _state$appStates.reconnectId)) {
@@ -187,7 +186,6 @@ export const LiveChatWidgetStateful = props => {
187
186
  setupClientDataStore();
188
187
  registerTelemetryLoggers(props, dispatch);
189
188
  createInternetConnectionChangeHandler();
190
- uwid.current = newGuid();
191
189
  dispatch({
192
190
  type: LiveChatWidgetActionType.SET_WIDGET_ELEMENT_ID,
193
191
  payload: widgetElementId
@@ -320,23 +318,27 @@ export const LiveChatWidgetStateful = props => {
320
318
 
321
319
  // Start chat from SDK Event
322
320
  BroadcastService.getMessageByEventName(BroadcastEvent.StartChat).subscribe(msg => {
323
- var _msg$payload4;
321
+ var _msg$payload4, _msg$payload5, _msg$payload6;
322
+ // If the startChat event is not initiated by the same tab. Ignore the call
323
+ if (!isNullOrUndefined(msg === null || msg === void 0 ? void 0 : (_msg$payload4 = msg.payload) === null || _msg$payload4 === void 0 ? void 0 : _msg$payload4.runtimeId) && (msg === null || msg === void 0 ? void 0 : (_msg$payload5 = msg.payload) === null || _msg$payload5 === void 0 ? void 0 : _msg$payload5.runtimeId) !== TelemetryManager.InternalTelemetryData.lcwRuntimeId) {
324
+ return;
325
+ }
324
326
  let stateWithUpdatedContext = state;
325
- if (msg !== null && msg !== void 0 && (_msg$payload4 = msg.payload) !== null && _msg$payload4 !== void 0 && _msg$payload4.customContext) {
326
- var _msg$payload5, _msg$payload6;
327
+ if (msg !== null && msg !== void 0 && (_msg$payload6 = msg.payload) !== null && _msg$payload6 !== void 0 && _msg$payload6.customContext) {
328
+ var _msg$payload7, _msg$payload8;
327
329
  TelemetryHelper.logActionEvent(LogLevel.INFO, {
328
330
  Event: TelemetryEvent.CustomContextReceived,
329
331
  Description: "CustomContext received through startChat event."
330
332
  });
331
333
  dispatch({
332
334
  type: LiveChatWidgetActionType.SET_CUSTOM_CONTEXT,
333
- payload: msg === null || msg === void 0 ? void 0 : (_msg$payload5 = msg.payload) === null || _msg$payload5 === void 0 ? void 0 : _msg$payload5.customContext
335
+ payload: msg === null || msg === void 0 ? void 0 : (_msg$payload7 = msg.payload) === null || _msg$payload7 === void 0 ? void 0 : _msg$payload7.customContext
334
336
  });
335
337
  stateWithUpdatedContext = {
336
338
  ...state,
337
339
  domainStates: {
338
340
  ...state.domainStates,
339
- customContext: msg === null || msg === void 0 ? void 0 : (_msg$payload6 = msg.payload) === null || _msg$payload6 === void 0 ? void 0 : _msg$payload6.customContext
341
+ customContext: msg === null || msg === void 0 ? void 0 : (_msg$payload8 = msg.payload) === null || _msg$payload8 === void 0 ? void 0 : _msg$payload8.customContext
340
342
  }
341
343
  };
342
344
  }
@@ -414,9 +416,16 @@ export const LiveChatWidgetStateful = props => {
414
416
  // Listen to end chat event from other tabs
415
417
  const endChatEventName = getWidgetEndChatEventName(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC2 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC2 === void 0 ? void 0 : _chatSDK$omnichannelC2.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC3 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC3 === void 0 ? void 0 : _chatSDK$omnichannelC3.widgetId, ((_props$controlProps10 = props.controlProps) === null || _props$controlProps10 === void 0 ? void 0 : _props$controlProps10.widgetInstanceId) ?? "");
416
418
  BroadcastService.getMessageByEventName(endChatEventName).subscribe(msg => {
417
- console.log("Receiving end chat event", JSON.stringify(msg.payload));
418
- if (msg.payload !== uwid.current) {
419
+ var _msg$payload9;
420
+ if ((msg === null || msg === void 0 ? void 0 : (_msg$payload9 = msg.payload) === null || _msg$payload9 === void 0 ? void 0 : _msg$payload9.runtimeId) !== TelemetryManager.InternalTelemetryData.lcwRuntimeId) {
419
421
  endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, true, false, false);
422
+ endChatStateCleanUp(dispatch);
423
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
424
+ chatSDK.requestId = uuidv4();
425
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
426
+ chatSDK.chatToken = {};
427
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
428
+ chatSDK.reconnectId = null;
420
429
  return;
421
430
  }
422
431
  });
@@ -544,13 +553,13 @@ export const LiveChatWidgetStateful = props => {
544
553
 
545
554
  // If start chat failed, and C2 is trying to close chat widget
546
555
  if (state !== null && state !== void 0 && (_state$appStates9 = state.appStates) !== null && _state$appStates9 !== void 0 && _state$appStates9.startChatFailed || (state === null || state === void 0 ? void 0 : (_state$appStates10 = state.appStates) === null || _state$appStates10 === void 0 ? void 0 : _state$appStates10.conversationState) === ConversationState.Postchat) {
547
- endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, true, false, true, uwid.current);
556
+ endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, true, false, true);
548
557
  return;
549
558
  }
550
559
 
551
560
  // Scenario -> Chat was InActive and closing the chat (Refresh scenario on post chat)
552
561
  if ((state === null || state === void 0 ? void 0 : (_state$appStates11 = state.appStates) === null || _state$appStates11 === void 0 ? void 0 : _state$appStates11.conversationState) === ConversationState.InActive) {
553
- endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, true, uwid.current);
562
+ endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, true);
554
563
  return;
555
564
  }
556
565
  if ((state === null || state === void 0 ? void 0 : (_state$appStates12 = state.appStates) === null || _state$appStates12 === void 0 ? void 0 : _state$appStates12.conversationEndedBy) === ConversationEndEntity.Agent || (state === null || state === void 0 ? void 0 : (_state$appStates13 = state.appStates) === null || _state$appStates13 === void 0 ? void 0 : _state$appStates13.conversationEndedBy) === ConversationEndEntity.Bot) {
@@ -561,7 +570,7 @@ export const LiveChatWidgetStateful = props => {
561
570
  }
562
571
 
563
572
  // All other cases
564
- prepareEndChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, uwid.current);
573
+ prepareEndChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter);
565
574
  }, [state === null || state === void 0 ? void 0 : (_state$appStates14 = state.appStates) === null || _state$appStates14 === void 0 ? void 0 : _state$appStates14.conversationEndedBy]);
566
575
 
567
576
  // Publish chat widget state
@@ -619,13 +628,13 @@ export const LiveChatWidgetStateful = props => {
619
628
  };
620
629
  const setPostChatContextRelay = () => setPostChatContextAndLoadSurvey(chatSDK, dispatch);
621
630
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
622
- const endChatRelay = (adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTab) => endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTab, uwid.current);
631
+ const endChatRelay = (adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTab) => endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTab);
623
632
  const prepareStartChatRelay = () => prepareStartChat(props, chatSDK, state, dispatch, setAdapter);
624
633
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
625
634
  const initStartChatRelay = (optionalParams, persistedState) => initStartChat(chatSDK, dispatch, setAdapter, state, props, optionalParams, persistedState);
626
635
  const confirmationPaneProps = initConfirmationPropsComposer(props);
627
636
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
628
- const prepareEndChatRelay = () => prepareEndChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, uwid.current);
637
+ const prepareEndChatRelay = () => prepareEndChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter);
629
638
  const webChatProps = initWebChatComposer(props, state, dispatch, chatSDK, endChatRelay);
630
639
  const downloadTranscriptProps = createDownloadTranscriptProps(props.downloadTranscriptProps, {
631
640
  ...(defaultWebChatContainerStatefulProps === null || defaultWebChatContainerStatefulProps === void 0 ? void 0 : defaultWebChatContainerStatefulProps.webChatStyles),
@@ -47,13 +47,11 @@ const createMagicCodeSuccessResponse = signin => {
47
47
  };
48
48
  };
49
49
  export const WebChatContainerStateful = props => {
50
- var _webChatContainerProp, _webChatContainerProp2, _webChatContainerProp3, _webChatContainerProp4, _webChatContainerProp5, _webChatContainerProp6, _props$webChatContain3, _props$webChatContain4, _defaultWebChatContai, _props$webChatContain5, _props$webChatContain6, _defaultWebChatContai2, _webChatContainerProp7, _webChatContainerProp8, _webChatContainerProp9, _webChatContainerProp10, _webChatContainerProp11, _webChatContainerProp12, _webChatContainerProp13, _webChatContainerProp14;
50
+ var _webChatContainerProp, _webChatContainerProp2, _webChatContainerProp3, _webChatContainerProp4, _webChatContainerProp5, _webChatContainerProp6, _props$webChatContain5, _props$webChatContain6, _defaultWebChatContai, _props$webChatContain7, _props$webChatContain8, _defaultWebChatContai2, _webChatContainerProp7, _webChatContainerProp8, _webChatContainerProp9, _webChatContainerProp10, _webChatContainerProp11, _webChatContainerProp12, _webChatContainerProp13, _webChatContainerProp14;
51
51
  const {
52
52
  BasicWebChat
53
53
  } = Components;
54
54
  const [state, dispatch] = useChatContextStore();
55
- const magicCodeBroadcastChannel = new window.BroadcastChannel(Constants.magicCodeBroadcastChannel); // eslint-disable-line @typescript-eslint/no-explicit-any
56
- const magicCodeResponseBroadcastChannel = new window.BroadcastChannel(Constants.magicCodeResponseBroadcastChannel); // eslint-disable-line @typescript-eslint/no-explicit-any
57
55
  const {
58
56
  webChatContainerProps,
59
57
  contextDataStore
@@ -61,7 +59,7 @@ export const WebChatContainerStateful = props => {
61
59
  const containerStyles = {
62
60
  root: Object.assign({}, defaultWebChatContainerStatefulProps.containerStyles, webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : webChatContainerProps.containerStyles, {
63
61
  display: state.appStates.isMinimized ? "none" : ""
64
- }) // Use this instead of removing WebChat from the picture so that the activity observer inside the adapter is not invoked
62
+ }) // Use this instead of removing WebChat from the picture so that the activity observer inside the adapter is not invoked
65
63
  };
66
64
 
67
65
  const localizedTexts = {
@@ -95,6 +93,21 @@ export const WebChatContainerStateful = props => {
95
93
  }
96
94
  }, []);
97
95
  useEffect(() => {
96
+ var _props$webChatContain3, _props$webChatContain4;
97
+ if (!((_props$webChatContain3 = props.webChatContainerProps) !== null && _props$webChatContain3 !== void 0 && (_props$webChatContain4 = _props$webChatContain3.botMagicCode) !== null && _props$webChatContain4 !== void 0 && _props$webChatContain4.disabled)) {
98
+ return;
99
+ }
100
+ if (!window.BroadcastChannel) {
101
+ // eslint-disable-line @typescript-eslint/no-explicit-any
102
+ TelemetryHelper.logActionEvent(LogLevel.ERROR, {
103
+ Event: TelemetryEvent.SuppressBotMagicCodeFailed,
104
+ Description: "BroadcastChannel not supported by default on current browser"
105
+ });
106
+ return;
107
+ }
108
+ const magicCodeBroadcastChannel = new window.BroadcastChannel(Constants.magicCodeBroadcastChannel); // eslint-disable-line @typescript-eslint/no-explicit-any
109
+ const magicCodeResponseBroadcastChannel = new window.BroadcastChannel(Constants.magicCodeResponseBroadcastChannel); // eslint-disable-line @typescript-eslint/no-explicit-any
110
+
98
111
  const eventListener = event => {
99
112
  // eslint-disable-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-empty-function
100
113
  const {
@@ -148,8 +161,8 @@ export const WebChatContainerStateful = props => {
148
161
  div[class="ac-input-container"] * {white-space:${(webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : (_webChatContainerProp6 = webChatContainerProps.adaptiveCardStyles) === null || _webChatContainerProp6 === void 0 ? void 0 : _webChatContainerProp6.textWhiteSpace) ?? defaultAdaptiveCardStyles.textWhiteSpace}}
149
162
 
150
163
  .ms_lcw_webchat_received_message>div.webchat__stacked-layout>div.webchat__stacked-layout__main>div.webchat__stacked-layout__content>div.webchat__stacked-layout__message-row>[class^=webchat]:not(.webchat__bubble--from-user)>.webchat__bubble__content {
151
- background-color: ${((_props$webChatContain3 = props.webChatContainerProps) === null || _props$webChatContain3 === void 0 ? void 0 : (_props$webChatContain4 = _props$webChatContain3.webChatStyles) === null || _props$webChatContain4 === void 0 ? void 0 : _props$webChatContain4.bubbleBackground) ?? ((_defaultWebChatContai = defaultWebChatContainerStatefulProps.webChatStyles) === null || _defaultWebChatContai === void 0 ? void 0 : _defaultWebChatContai.bubbleBackground)};
152
- color:${((_props$webChatContain5 = props.webChatContainerProps) === null || _props$webChatContain5 === void 0 ? void 0 : (_props$webChatContain6 = _props$webChatContain5.webChatStyles) === null || _props$webChatContain6 === void 0 ? void 0 : _props$webChatContain6.bubbleTextColor) ?? ((_defaultWebChatContai2 = defaultWebChatContainerStatefulProps.webChatStyles) === null || _defaultWebChatContai2 === void 0 ? void 0 : _defaultWebChatContai2.bubbleTextColor)};
164
+ background-color: ${((_props$webChatContain5 = props.webChatContainerProps) === null || _props$webChatContain5 === void 0 ? void 0 : (_props$webChatContain6 = _props$webChatContain5.webChatStyles) === null || _props$webChatContain6 === void 0 ? void 0 : _props$webChatContain6.bubbleBackground) ?? ((_defaultWebChatContai = defaultWebChatContainerStatefulProps.webChatStyles) === null || _defaultWebChatContai === void 0 ? void 0 : _defaultWebChatContai.bubbleBackground)};
165
+ color:${((_props$webChatContain7 = props.webChatContainerProps) === null || _props$webChatContain7 === void 0 ? void 0 : (_props$webChatContain8 = _props$webChatContain7.webChatStyles) === null || _props$webChatContain8 === void 0 ? void 0 : _props$webChatContain8.bubbleTextColor) ?? ((_defaultWebChatContai2 = defaultWebChatContainerStatefulProps.webChatStyles) === null || _defaultWebChatContai2 === void 0 ? void 0 : _defaultWebChatContai2.bubbleTextColor)};
153
166
  }
154
167
 
155
168
  div[class="ac-textBlock"] a:link,
@@ -157,11 +170,11 @@ export const WebChatContainerStateful = props => {
157
170
  div[class="ac-textBlock"] a:hover,
158
171
  div[class="ac-textBlock"] a:active {
159
172
  color: ${(webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : (_webChatContainerProp7 = webChatContainerProps.adaptiveCardStyles) === null || _webChatContainerProp7 === void 0 ? void 0 : _webChatContainerProp7.anchorColor) ?? defaultAdaptiveCardStyles.anchorColor};
160
- }
173
+ }
161
174
 
162
175
  .webchat__stacked-layout__content .ac-actionSet > .ac-pushButton > div {white-space: ${(webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : (_webChatContainerProp8 = webChatContainerProps.adaptiveCardStyles) === null || _webChatContainerProp8 === void 0 ? void 0 : _webChatContainerProp8.buttonWhiteSpace) ?? defaultAdaptiveCardStyles.buttonWhiteSpace} !important;}
163
176
 
164
- .ms_lcw_webchat_received_message img.webchat__markdown__external-link-icon {
177
+ .ms_lcw_webchat_received_message img.webchat__markdown__external-link-icon {
165
178
  background-image : url(data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIzIDMgMTggMTgiICB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxwYXRoIGQ9Ik03LjI1MDEgNC41MDAxN0gxMC43NDk1QzExLjE2MzcgNC41MDAxNyAxMS40OTk1IDQuODM1OTYgMTEuNDk5NSA1LjI1MDE3QzExLjQ5OTUgNS42Mjk4NiAxMS4yMTczIDUuOTQzNjYgMTAuODUxMyA1Ljk5MzMyTDEwLjc0OTUgNi4wMDAxN0g3LjI0OTc0QzYuMDcwNzkgNS45OTk2MSA1LjEwMzQ5IDYuOTA2NTYgNS4wMDc4NiA4LjA2MTEyTDUuMDAwMjggOC4yMjAwM0w1LjAwMzEyIDE2Ljc1MDdDNS4wMDM0MyAxNy45NDE1IDUuOTI4ODUgMTguOTE2MSA3LjA5OTY2IDE4Ljk5NDlMNy4yNTM3MSAxOS4wMDAxTDE1Ljc1MTggMTguOTg4NEMxNi45NDE1IDE4Ljk4NjggMTcuOTE0NSAxOC4wNjIgMTcuOTkzNSAxNi44OTIzTDE3Ljk5ODcgMTYuNzM4NFYxMy4yMzIxQzE3Ljk5ODcgMTIuODE3OSAxOC4zMzQ1IDEyLjQ4MjEgMTguNzQ4NyAxMi40ODIxQzE5LjEyODQgMTIuNDgyMSAxOS40NDIyIDEyLjc2NDMgMTkuNDkxOCAxMy4xMzAzTDE5LjQ5ODcgMTMuMjMyMVYxNi43Mzg0QzE5LjQ5ODcgMTguNzQwNyAxNy45MjkzIDIwLjM3NjkgMTUuOTUyOCAyMC40ODI5TDE1Ljc1MzggMjAuNDg4NEw3LjI1ODI3IDIwLjUwMDFMNy4wNTQ5NSAyMC40OTQ5QzUuMTQyMzkgMjAuMzk1NCAzLjYwODk1IDE4Ljg2MjcgMy41MDgzNyAxNi45NTAyTDMuNTAzMTIgMTYuNzUxMUwzLjUwMDg5IDguMjUyN0wzLjUwNTI5IDguMDUwMkMzLjYwNTM5IDYuMTM3NDkgNS4xMzg2NyA0LjYwNDQ5IDcuMDUwOTYgNC41MDUyN0w3LjI1MDEgNC41MDAxN0gxMC43NDk1SDcuMjUwMVpNMTMuNzQ4MSAzLjAwMTQ2TDIwLjMwMTggMy4wMDE5N0wyMC40MDE0IDMuMDE1NzVMMjAuNTAyMiAzLjA0MzkzTDIwLjU1OSAzLjA2ODAzQzIwLjYxMjIgMy4wOTEyMiAyMC42NjM0IDMuMTIxNjMgMjAuNzExMSAzLjE1ODg1TDIwLjc4MDQgMy4yMjE1NkwyMC44NjQxIDMuMzIwMTRMMjAuOTE4MyAzLjQxMDI1TDIwLjk1NyAzLjUwMDU3TDIwLjk3NjIgMy41NjQ3NkwyMC45ODk4IDMuNjI4NjJMMjAuOTk5MiAzLjcyMjgyTDIwLjk5OTcgMTAuMjU1NEMyMC45OTk3IDEwLjY2OTYgMjAuNjYzOSAxMS4wMDU0IDIwLjI0OTcgMTEuMDA1NEMxOS44NyAxMS4wMDU0IDE5LjU1NjIgMTAuNzIzMiAxOS41MDY1IDEwLjM1NzFMMTkuNDk5NyAxMC4yNTU0TDE5LjQ5ODkgNS41NjE0N0wxMi4yNzk3IDEyLjc4NDdDMTIuMDEzNCAxMy4wNTEgMTEuNTk2OCAxMy4wNzUzIDExLjMwMzEgMTIuODU3NUwxMS4yMTkgMTIuNzg0OUMxMC45NTI3IDEyLjUxODcgMTAuOTI4NCAxMi4xMDIxIDExLjE0NjIgMTEuODA4NEwxMS4yMTg4IDExLjcyNDNMMTguNDM2OSA0LjUwMTQ2SDEzLjc0ODFDMTMuMzY4NCA0LjUwMTQ2IDEzLjA1NDYgNC4yMTkzMSAxMy4wMDUgMy44NTMyNEwxMi45OTgxIDMuNzUxNDZDMTIuOTk4MSAzLjM3MTc3IDEzLjI4MDMgMy4wNTc5NyAxMy42NDY0IDMuMDA4MzFMMTMuNzQ4MSAzLjAwMTQ2WiIgZmlsbD0iI0ZGRkZGRiIgLz48L3N2Zz4) !important;
166
179
  height: '.75em';
167
180
  marginLeft: '.25em';
@@ -179,7 +192,7 @@ export const WebChatContainerStateful = props => {
179
192
  .ms_lcw_webchat_received_message a:hover,
180
193
  .ms_lcw_webchat_received_message a:active {
181
194
  color: ${(webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : (_webChatContainerProp11 = webChatContainerProps.renderingMiddlewareProps) === null || _webChatContainerProp11 === void 0 ? void 0 : (_webChatContainerProp12 = _webChatContainerProp11.receivedMessageAnchorStyles) === null || _webChatContainerProp12 === void 0 ? void 0 : _webChatContainerProp12.color) ?? (defaultReceivedMessageAnchorStyles === null || defaultReceivedMessageAnchorStyles === void 0 ? void 0 : defaultReceivedMessageAnchorStyles.color)};
182
- }
195
+ }
183
196
  .ms_lcw_webchat_sent_message a:link,
184
197
  .ms_lcw_webchat_sent_message a:visited,
185
198
  .ms_lcw_webchat_sent_message a:hover,
@@ -26,5 +26,7 @@ export const defaultMiddlewareLocalizedTexts = {
26
26
  MIDDLEWARE_MESSAGE_RETRY: "Retry",
27
27
  MIDDLEWARE_BANNER_CHAT_DISCONNECT: "Your conversation has been disconnected. For additional assistance, please start a new chat.",
28
28
  THIRD_PARTY_COOKIES_BLOCKED_ALERT_MESSAGE: "Third party cookies are blocked. Reloading this page will start a new conversation.",
29
- MIDDLEWARE_BANNER_FILE_IS_MALICIOUS: "{0} has been blocked because the file may contain a malware."
29
+ MIDDLEWARE_BANNER_FILE_IS_MALICIOUS: "{0} has been blocked because the file may contain a malware.",
30
+ MIDDLEWARE_BANNER_FILE_EMAIL_ADDRESS_RECORDED_SUCCESS: "Email will be sent after chat ends!",
31
+ MIDDLEWARE_BANNER_FILE_EMAIL_ADDRESS_RECORDED_ERROR: "Email {0} could not be saved, try again later."
30
32
  };
@@ -3,6 +3,7 @@ export let NotificationScenarios;
3
3
  NotificationScenarios["Connection"] = "connection";
4
4
  NotificationScenarios["DownloadTranscriptError"] = "download transcript";
5
5
  NotificationScenarios["EmailTranscriptError"] = "email transcript";
6
+ NotificationScenarios["EmailAddressSaved"] = "email address saved";
6
7
  NotificationScenarios["AttachmentError"] = "attachment";
7
8
  NotificationScenarios["InternetConnection"] = "internet connection";
8
9
  NotificationScenarios["MaxSizeError"] = "max size";
@@ -33,3 +33,12 @@ export declare const debounceLeading: (fn: any, ms?: number) => (...args: any[])
33
33
  export declare const getConversationDetailsCall: (chatSDK: any) => Promise<any>;
34
34
  export declare const checkContactIdError: (e: any) => void;
35
35
  export declare const createFileAndDownload: (fileName: string, blobData: string, mimeType: string) => void;
36
+ /**
37
+ *
38
+ * Replace placeholders with format {0}..{n} , in a string with values
39
+ *
40
+ * @param template String with placeholders to be replaced
41
+ * @param values array of values to replace the placeholders
42
+ * @returns formatted string with replaced values
43
+ */
44
+ export declare const formatTemplateString: (templateMessage: string, values: any) => string;
@@ -2,7 +2,10 @@ import { Dispatch } from "react";
2
2
  import { ILiveChatWidgetAction } from "../../../contexts/common/ILiveChatWidgetAction";
3
3
  import { ILiveChatWidgetContext } from "../../../contexts/common/ILiveChatWidgetContext";
4
4
  import { ILiveChatWidgetProps } from "../interfaces/ILiveChatWidgetProps";
5
- declare const prepareEndChat: (props: ILiveChatWidgetProps, chatSDK: any, state: ILiveChatWidgetContext, dispatch: Dispatch<ILiveChatWidgetAction>, setAdapter: any, setWebChatStyles: any, adapter: any, uwid: string) => Promise<void>;
6
- declare const endChat: (props: ILiveChatWidgetProps, chatSDK: any, state: ILiveChatWidgetContext, dispatch: Dispatch<ILiveChatWidgetAction>, setAdapter: any, setWebChatStyles: any, adapter: any, skipEndChatSDK?: boolean | undefined, skipCloseChat?: boolean | undefined, postMessageToOtherTab?: boolean | undefined, uwid?: string) => Promise<void>;
5
+ declare const prepareEndChat: (props: ILiveChatWidgetProps, chatSDK: any, state: ILiveChatWidgetContext, dispatch: Dispatch<ILiveChatWidgetAction>, setAdapter: any, setWebChatStyles: any, adapter: any) => Promise<void>;
6
+ declare const endChat: (props: ILiveChatWidgetProps, chatSDK: any, state: ILiveChatWidgetContext, dispatch: Dispatch<ILiveChatWidgetAction>, setAdapter: any, setWebChatStyles: any, adapter: any, skipEndChatSDK?: boolean | undefined, skipCloseChat?: boolean | undefined, postMessageToOtherTab?: boolean | undefined) => Promise<void>;
7
+ export declare const callingStateCleanUp: (dispatch: Dispatch<ILiveChatWidgetAction>) => Promise<void>;
8
+ export declare const endChatStateCleanUp: (dispatch: Dispatch<ILiveChatWidgetAction>) => Promise<void>;
9
+ export declare const closeChatStateCleanUp: (dispatch: Dispatch<ILiveChatWidgetAction>) => Promise<void>;
7
10
  export declare const endVoiceVideoCallIfOngoing: (chatSDK: any, dispatch: Dispatch<ILiveChatWidgetAction>) => Promise<void>;
8
11
  export { prepareEndChat, endChat };
@@ -4,6 +4,6 @@ import { ILiveChatWidgetContext } from "../../../contexts/common/ILiveChatWidget
4
4
  import { ILiveChatWidgetProps } from "../interfaces/ILiveChatWidgetProps";
5
5
  declare const initiatePostChat: (props: ILiveChatWidgetProps, conversationDetailsParam: any, state: ILiveChatWidgetContext, dispatch: Dispatch<ILiveChatWidgetAction>, postchatContext: any) => Promise<void>;
6
6
  declare const isPostChatEnabled: (props: ILiveChatWidgetProps, state: ILiveChatWidgetContext) => boolean;
7
- declare const getPostChatContext: (chatSDK: any, state: ILiveChatWidgetContext, dispatch: Dispatch<ILiveChatWidgetAction>) => Promise<void>;
7
+ declare const getPostChatContext: (chatSDK: any, state: ILiveChatWidgetContext, dispatch: Dispatch<ILiveChatWidgetAction>) => Promise<any>;
8
8
  declare const setWidgetStateToInactive: (dispatch: Dispatch<ILiveChatWidgetAction>) => Promise<void>;
9
9
  export { initiatePostChat, setWidgetStateToInactive, getPostChatContext, isPostChatEnabled as checkPostChatEnabled };
@@ -2,6 +2,7 @@ export declare enum NotificationScenarios {
2
2
  Connection = "connection",
3
3
  DownloadTranscriptError = "download transcript",
4
4
  EmailTranscriptError = "email transcript",
5
+ EmailAddressSaved = "email address saved",
5
6
  AttachmentError = "attachment",
6
7
  InternetConnection = "internet connection",
7
8
  MaxSizeError = "max size",
@@ -28,4 +28,13 @@ export interface ILiveChatWidgetLocalizedTexts {
28
28
  * e.g. "{0} has been blocked because the file may contain a malware."
29
29
  */
30
30
  MIDDLEWARE_BANNER_FILE_IS_MALICIOUS?: string;
31
+ /**
32
+ * Success message, indicating the email address introduced has been registered to receive the transcript.
33
+ */
34
+ MIDDLEWARE_BANNER_FILE_EMAIL_ADDRESS_RECORDED_SUCCESS?: string;
35
+ /**
36
+ * Error message, indicating the email address introduced couldnt be registered.
37
+ * {0} - e-mail address introduced
38
+ */
39
+ MIDDLEWARE_BANNER_FILE_EMAIL_ADDRESS_RECORDED_ERROR?: string;
31
40
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microsoft/omnichannel-chat-widget",
3
- "version": "1.4.0",
3
+ "version": "1.4.1-main.4e8dedc",
4
4
  "description": "Microsoft Omnichannel Chat Widget",
5
5
  "main": "lib/cjs/index.js",
6
6
  "types": "lib/types/index.d.ts",
@@ -74,7 +74,7 @@
74
74
  "webpack-cli": "^4.9.2"
75
75
  },
76
76
  "dependencies": {
77
- "@microsoft/omnichannel-chat-components": "^1.0.7",
77
+ "@microsoft/omnichannel-chat-components": "^1.0.9",
78
78
  "@microsoft/omnichannel-chat-sdk": "1.5.4",
79
79
  "abort-controller-es5": "^2.0.1",
80
80
  "dompurify": "^2.3.4",