@microsoft/omnichannel-chat-widget 1.8.1-main.f0e9e2f → 1.8.2-main.2af2b9e
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.
- package/lib/cjs/common/Constants.js +1 -1
- package/lib/cjs/common/facades/FacadeChatSDK.js +49 -7
- package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +34 -15
- package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +7 -3
- package/lib/cjs/components/headerstateful/HeaderStateful.js +18 -4
- package/lib/cjs/components/livechatwidget/LiveChatWidget.js +5 -10
- package/lib/cjs/components/livechatwidget/common/liveChatConfigUtils.js +1 -1
- package/lib/cjs/components/livechatwidget/common/persistentChatHelper.js +12 -5
- package/lib/cjs/components/livechatwidget/common/startChat.js +2 -2
- package/lib/cjs/components/livechatwidget/common/startChatErrorHandler.js +25 -8
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +21 -17
- package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +42 -8
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +1 -1
- package/lib/esm/common/Constants.js +1 -1
- package/lib/esm/common/facades/FacadeChatSDK.js +49 -7
- package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +34 -15
- package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +7 -3
- package/lib/esm/components/headerstateful/HeaderStateful.js +18 -4
- package/lib/esm/components/livechatwidget/LiveChatWidget.js +5 -10
- package/lib/esm/components/livechatwidget/common/liveChatConfigUtils.js +1 -1
- package/lib/esm/components/livechatwidget/common/persistentChatHelper.js +12 -5
- package/lib/esm/components/livechatwidget/common/startChat.js +2 -2
- package/lib/esm/components/livechatwidget/common/startChatErrorHandler.js +25 -8
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +21 -17
- package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +42 -8
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +1 -1
- package/lib/types/common/Constants.d.ts +1 -1
- package/lib/types/common/facades/FacadeChatSDK.d.ts +1 -0
- package/lib/types/components/livechatwidget/common/liveChatConfigUtils.d.ts +1 -1
- package/lib/types/components/livechatwidget/common/persistentChatHelper.d.ts +2 -1
- package/package.json +2 -2
|
@@ -131,7 +131,7 @@ _defineProperty(Constants, "WebchatSequenceIdAttribute", "webchat:sequence-id");
|
|
|
131
131
|
_defineProperty(Constants, "MessageSequenceIdOverride", "MessageSequenceIdOverride");
|
|
132
132
|
const Regex = (_class = /*#__PURE__*/_createClass(function Regex() {
|
|
133
133
|
_classCallCheck(this, Regex);
|
|
134
|
-
}), _defineProperty(_class, "EmailRegex", "(?:[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"
|
|
134
|
+
}), _defineProperty(_class, "EmailRegex", "^(?:[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*\")@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?)*|\\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\])$"), _class);
|
|
135
135
|
exports.Regex = Regex;
|
|
136
136
|
let HtmlIdNames = /*#__PURE__*/_createClass(function HtmlIdNames() {
|
|
137
137
|
_classCallCheck(this, HtmlIdNames);
|
|
@@ -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(
|
|
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 =
|
|
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
|
}();
|
|
@@ -20,7 +20,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
20
20
|
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; }
|
|
21
21
|
let uiTimer;
|
|
22
22
|
const ChatButtonStateful = props => {
|
|
23
|
-
var _buttonProps$controlP, _props$buttonProps, _props$buttonProps$co, _props$buttonProps2, _props$buttonProps2$c, _props$buttonProps3, _props$buttonProps3$c;
|
|
23
|
+
var _buttonProps$controlP, _props$buttonProps, _props$buttonProps$co, _props$buttonProps2, _props$buttonProps2$c, _outOfOfficeButtonPro, _outOfOfficeButtonPro2, _props$buttonProps3, _props$buttonProps3$c;
|
|
24
24
|
// this is to ensure the telemetry is set only once and start the load timer
|
|
25
25
|
(0, _react.useEffect)(() => {
|
|
26
26
|
uiTimer = (0, _utils.createTimer)();
|
|
@@ -39,7 +39,10 @@ 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
|
-
|
|
42
|
+
// Initialize with the current state value to prevent visual flicker
|
|
43
|
+
const [outOfOperatingHours, setOutOfOperatingHours] = (0, _react.useState)(() => {
|
|
44
|
+
return state.appStates.conversationState === _ConversationState.ConversationState.Closed && state.appStates.outsideOperatingHours;
|
|
45
|
+
});
|
|
43
46
|
const ref = (0, _react.useRef)(() => {
|
|
44
47
|
return;
|
|
45
48
|
});
|
|
@@ -71,36 +74,40 @@ const ChatButtonStateful = props => {
|
|
|
71
74
|
};
|
|
72
75
|
const outOfOfficeStyleProps = Object.assign({}, _defaultOutOfOfficeChatButtonStyleProps.defaultOutOfOfficeChatButtonStyleProps, outOfOfficeButtonProps === null || outOfOfficeButtonProps === void 0 ? void 0 : outOfOfficeButtonProps.styleProps);
|
|
73
76
|
const controlProps = {
|
|
77
|
+
...(buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.controlProps),
|
|
74
78
|
id: "oc-lcw-chat-button",
|
|
75
79
|
dir: state.domainStates.globalDir,
|
|
76
80
|
titleText: "Let's Chat!",
|
|
77
81
|
subtitleText: "We're online.",
|
|
78
82
|
hideNotificationBubble: (buttonProps === null || buttonProps === void 0 ? void 0 : (_buttonProps$controlP = buttonProps.controlProps) === null || _buttonProps$controlP === void 0 ? void 0 : _buttonProps$controlP.hideNotificationBubble) === true || state.appStates.isMinimized === false,
|
|
79
83
|
unreadMessageCount: state.appStates.unreadMessageCount ? state.appStates.unreadMessageCount > _Constants.Constants.maximumUnreadMessageCount ? (_props$buttonProps = props.buttonProps) === null || _props$buttonProps === void 0 ? void 0 : (_props$buttonProps$co = _props$buttonProps.controlProps) === null || _props$buttonProps$co === void 0 ? void 0 : _props$buttonProps$co.largeUnreadMessageString : state.appStates.unreadMessageCount.toString() : "0",
|
|
80
|
-
onClick: () => ref.current(),
|
|
81
84
|
unreadMessageString: (_props$buttonProps2 = props.buttonProps) === null || _props$buttonProps2 === void 0 ? void 0 : (_props$buttonProps2$c = _props$buttonProps2.controlProps) === null || _props$buttonProps2$c === void 0 ? void 0 : _props$buttonProps2$c.unreadMessageString,
|
|
82
|
-
|
|
85
|
+
// Regular chat button onClick - this will always take precedence
|
|
86
|
+
onClick: () => ref.current()
|
|
83
87
|
};
|
|
84
88
|
const outOfOfficeControlProps = {
|
|
89
|
+
// Only take specific properties from outOfOfficeButtonProps, never onClick
|
|
85
90
|
id: "oc-lcw-chat-button",
|
|
86
91
|
dir: state.domainStates.globalDir,
|
|
87
|
-
titleText: "We're Offline",
|
|
88
|
-
subtitleText: "No agents available",
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
titleText: (outOfOfficeButtonProps === null || outOfOfficeButtonProps === void 0 ? void 0 : (_outOfOfficeButtonPro = outOfOfficeButtonProps.controlProps) === null || _outOfOfficeButtonPro === void 0 ? void 0 : _outOfOfficeButtonPro.titleText) || "We're Offline",
|
|
93
|
+
subtitleText: (outOfOfficeButtonProps === null || outOfOfficeButtonProps === void 0 ? void 0 : (_outOfOfficeButtonPro2 = outOfOfficeButtonProps.controlProps) === null || _outOfOfficeButtonPro2 === void 0 ? void 0 : _outOfOfficeButtonPro2.subtitleText) || "No agents available",
|
|
94
|
+
unreadMessageString: (_props$buttonProps3 = props.buttonProps) === null || _props$buttonProps3 === void 0 ? void 0 : (_props$buttonProps3$c = _props$buttonProps3.controlProps) === null || _props$buttonProps3$c === void 0 ? void 0 : _props$buttonProps3$c.unreadMessageString,
|
|
95
|
+
...(outOfOfficeButtonProps === null || outOfOfficeButtonProps === void 0 ? void 0 : outOfOfficeButtonProps.controlProps),
|
|
96
|
+
// Out-of-office specific onClick - this will ALWAYS take precedence
|
|
97
|
+
onClick: () => {
|
|
98
|
+
if (state.appStates.isMinimized) {
|
|
99
|
+
dispatch({
|
|
100
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_MINIMIZED,
|
|
101
|
+
payload: false
|
|
102
|
+
});
|
|
103
|
+
}
|
|
94
104
|
dispatch({
|
|
95
105
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
96
106
|
payload: _ConversationState.ConversationState.OutOfOffice
|
|
97
107
|
});
|
|
98
|
-
}
|
|
99
|
-
unreadMessageString: (_props$buttonProps3 = props.buttonProps) === null || _props$buttonProps3 === void 0 ? void 0 : (_props$buttonProps3$c = _props$buttonProps3.controlProps) === null || _props$buttonProps3$c === void 0 ? void 0 : _props$buttonProps3$c.unreadMessageString,
|
|
100
|
-
...(outOfOfficeButtonProps === null || outOfOfficeButtonProps === void 0 ? void 0 : outOfOfficeButtonProps.controlProps)
|
|
108
|
+
}
|
|
101
109
|
};
|
|
102
110
|
(0, _react.useEffect)(() => {
|
|
103
|
-
setOutOfOperatingHours(state.appStates.outsideOperatingHours);
|
|
104
111
|
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
105
112
|
Event: _TelemetryConstants.TelemetryEvent.LCWChatButtonShow,
|
|
106
113
|
ElapsedTimeInMilliseconds: _TelemetryManager.TelemetryTimers.LcwLoadToChatButtonTimer.milliSecondsElapsed
|
|
@@ -119,6 +126,18 @@ const ChatButtonStateful = props => {
|
|
|
119
126
|
ElapsedTimeInMilliseconds: uiTimer.milliSecondsElapsed
|
|
120
127
|
});
|
|
121
128
|
}, []);
|
|
129
|
+
(0, _react.useEffect)(() => {
|
|
130
|
+
if (state.appStates.conversationState === _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
|
+
} else {
|
|
135
|
+
// If conversation state is not Closed, we should not be in out-of-office mode
|
|
136
|
+
if (outOfOperatingHours) {
|
|
137
|
+
setOutOfOperatingHours(false);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}, [state.appStates.conversationState, state.appStates.outsideOperatingHours, state.appStates.isMinimized]);
|
|
122
141
|
return /*#__PURE__*/_react.default.createElement(_omnichannelChatComponents.ChatButton, {
|
|
123
142
|
componentOverrides: buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.componentOverrides,
|
|
124
143
|
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
|
-
|
|
88
|
-
focusableElements[0]
|
|
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,10 @@ const HeaderStateful = props => {
|
|
|
37
37
|
endChat
|
|
38
38
|
} = props;
|
|
39
39
|
//Setting OutOfOperatingHours Flag
|
|
40
|
-
|
|
40
|
+
// Initialize with the current state value to prevent visual flicker
|
|
41
|
+
const [outOfOperatingHours, setOutOfOperatingHours] = (0, _react.useState)(() => {
|
|
42
|
+
return state.appStates.conversationState === _ConversationState.ConversationState.Closed && state.appStates.outsideOperatingHours;
|
|
43
|
+
});
|
|
41
44
|
const outOfOfficeStyleProps = Object.assign({}, _defaultOutOfOfficeHeaderStyleProps.defaultOutOfOfficeHeaderStyleProps, outOfOfficeHeaderProps === null || outOfOfficeHeaderProps === void 0 ? void 0 : outOfOfficeHeaderProps.styleProps);
|
|
42
45
|
|
|
43
46
|
// For some reason state object is not getting updated values in this component
|
|
@@ -112,6 +115,13 @@ const HeaderStateful = props => {
|
|
|
112
115
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_MINIMIZED,
|
|
113
116
|
payload: true
|
|
114
117
|
});
|
|
118
|
+
// Ensure conversation state remains Closed to maintain out-of-office mode
|
|
119
|
+
if (state.appStates.conversationState !== _ConversationState.ConversationState.Closed) {
|
|
120
|
+
dispatch({
|
|
121
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
122
|
+
payload: _ConversationState.ConversationState.Closed
|
|
123
|
+
});
|
|
124
|
+
}
|
|
115
125
|
_TelemetryHelper.TelemetryHelper.logActionEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
|
|
116
126
|
Event: _TelemetryConstants.TelemetryEvent.MinimizeChatActionCompleted,
|
|
117
127
|
Description: "Header Minimize action completed."
|
|
@@ -120,9 +130,6 @@ const HeaderStateful = props => {
|
|
|
120
130
|
...(outOfOfficeHeaderProps === null || outOfOfficeHeaderProps === void 0 ? void 0 : outOfOfficeHeaderProps.controlProps),
|
|
121
131
|
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
132
|
};
|
|
123
|
-
(0, _react.useEffect)(() => {
|
|
124
|
-
setOutOfOperatingHours(state.appStates.outsideOperatingHours);
|
|
125
|
-
}, []);
|
|
126
133
|
(0, _react.useEffect)(() => {
|
|
127
134
|
var _state$domainStates2;
|
|
128
135
|
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 +145,13 @@ const HeaderStateful = props => {
|
|
|
138
145
|
ElapsedTimeInMilliseconds: uiTimer.milliSecondsElapsed
|
|
139
146
|
});
|
|
140
147
|
}, []);
|
|
148
|
+
(0, _react.useEffect)(() => {
|
|
149
|
+
if (state.appStates.conversationState === _ConversationState.ConversationState.Closed) {
|
|
150
|
+
// If the conversation state is closed, check if we are outside operating hours
|
|
151
|
+
const isOutsideOperatingHours = state.appStates.outsideOperatingHours;
|
|
152
|
+
setOutOfOperatingHours(isOutsideOperatingHours);
|
|
153
|
+
}
|
|
154
|
+
}, [state.appStates.conversationState, state.appStates.outsideOperatingHours]);
|
|
141
155
|
if (props.draggable === true) {
|
|
142
156
|
var _generalStyleProps;
|
|
143
157
|
const styleProps = outOfOperatingHours || state.appStates.conversationState === _ConversationState.ConversationState.OutOfOffice ? outOfOfficeStyleProps : headerProps === null || headerProps === void 0 ? void 0 : headerProps.styleProps;
|
|
@@ -8,7 +8,6 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
8
8
|
var _ChatAdapterStore = require("../../contexts/ChatAdapterStore");
|
|
9
9
|
var _ChatContextStore = require("../../contexts/ChatContextStore");
|
|
10
10
|
var _ChatSDKStore = require("../../contexts/ChatSDKStore");
|
|
11
|
-
var _ErrorBoundary = _interopRequireDefault(require("../errorboundary/ErrorBoundary"));
|
|
12
11
|
var _FacadeChatSDK = require("../../common/facades/FacadeChatSDK");
|
|
13
12
|
var _FacadeChatSDKStore = require("../../contexts/FacadeChatSDKStore");
|
|
14
13
|
var _LiveChatWidgetStateful = _interopRequireDefault(require("./livechatwidgetstateful/LiveChatWidgetStateful"));
|
|
@@ -16,14 +15,14 @@ var _createReducer = require("../../contexts/createReducer");
|
|
|
16
15
|
var _LiveChatWidgetContextInitialState = require("../../contexts/common/LiveChatWidgetContextInitialState");
|
|
17
16
|
var _getMockChatSDKIfApplicable = require("./common/getMockChatSDKIfApplicable");
|
|
18
17
|
var _utils = require("../../common/utils");
|
|
18
|
+
var _liveChatConfigUtils = require("./common/liveChatConfigUtils");
|
|
19
19
|
var _overridePropsOnMockIfApplicable = _interopRequireDefault(require("./common/overridePropsOnMockIfApplicable"));
|
|
20
20
|
var _registerTelemetryLoggers = require("./common/registerTelemetryLoggers");
|
|
21
|
-
var _startChatErrorHandler = require("./common/startChatErrorHandler");
|
|
22
21
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
22
|
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
23
|
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
24
|
const LiveChatWidget = props => {
|
|
26
|
-
var _props$mock, _props$featureConfigP, _props$chatConfig, _props$chatConfig$Liv;
|
|
25
|
+
var _props$mock, _props$featureConfigP, _props$chatConfig, _props$chatConfig$Liv, _props$chatConfig2, _props$chatConfig2$Li;
|
|
27
26
|
const reducer = (0, _createReducer.createReducer)();
|
|
28
27
|
const [state, dispatch] = (0, _react.useReducer)(reducer, (0, _LiveChatWidgetContextInitialState.getLiveChatWidgetContextInitialState)(props));
|
|
29
28
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -37,7 +36,7 @@ const LiveChatWidget = props => {
|
|
|
37
36
|
}
|
|
38
37
|
|
|
39
38
|
// 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);
|
|
39
|
+
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
40
|
if (!facadeChatSDK) {
|
|
42
41
|
var _props$mock2;
|
|
43
42
|
setFacadeChatSDK(new _FacadeChatSDK.FacadeChatSDK({
|
|
@@ -52,11 +51,7 @@ const LiveChatWidget = props => {
|
|
|
52
51
|
(0, _react.useEffect)(() => {
|
|
53
52
|
(0, _registerTelemetryLoggers.registerTelemetryLoggers)(props, dispatch);
|
|
54
53
|
}, [dispatch]);
|
|
55
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
56
|
-
onError: error => {
|
|
57
|
-
(0, _startChatErrorHandler.logWidgetLoadWithUnexpectedError)(error);
|
|
58
|
-
}
|
|
59
|
-
}, /*#__PURE__*/_react.default.createElement(_FacadeChatSDKStore.FacadeChatSDKStore.Provider, {
|
|
54
|
+
return /*#__PURE__*/_react.default.createElement(_FacadeChatSDKStore.FacadeChatSDKStore.Provider, {
|
|
60
55
|
value: [facadeChatSDK, setFacadeChatSDK]
|
|
61
56
|
}, /*#__PURE__*/_react.default.createElement(_ChatSDKStore.ChatSDKStore.Provider, {
|
|
62
57
|
value: chatSDK
|
|
@@ -64,7 +59,7 @@ const LiveChatWidget = props => {
|
|
|
64
59
|
value: [adapter, setAdapter]
|
|
65
60
|
}, /*#__PURE__*/_react.default.createElement(_ChatContextStore.ChatContextStore.Provider, {
|
|
66
61
|
value: [state, dispatch]
|
|
67
|
-
}, /*#__PURE__*/_react.default.createElement(_LiveChatWidgetStateful.default, props)))))
|
|
62
|
+
}, /*#__PURE__*/_react.default.createElement(_LiveChatWidgetStateful.default, props)))));
|
|
68
63
|
};
|
|
69
64
|
exports.LiveChatWidget = LiveChatWidget;
|
|
70
65
|
var _default = LiveChatWidget;
|
|
@@ -13,7 +13,7 @@ const isPostChatSurveyEnabled = async facadeChatSDK => {
|
|
|
13
13
|
return postChatEnabled === "true";
|
|
14
14
|
};
|
|
15
15
|
exports.isPostChatSurveyEnabled = isPostChatSurveyEnabled;
|
|
16
|
-
const isPersistentChatEnabled =
|
|
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 (
|
|
10
|
-
const persistentEnabled =
|
|
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:
|
|
15
|
-
requestId:
|
|
21
|
+
authenticatedUserToken: sdkAsAny.authenticatedUserToken,
|
|
22
|
+
requestId: sdkAsAny.requestId
|
|
16
23
|
};
|
|
17
24
|
try {
|
|
18
|
-
const reconnectableChatsResponse = await
|
|
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
|
|
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 =
|
|
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
|
|
27
|
-
if (ex.message
|
|
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$
|
|
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$
|
|
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
|
-
|
|
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$
|
|
635
|
-
if ((props === null || props === void 0 ? void 0 : (_props$
|
|
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$
|
|
682
|
+
var _props$webChatContain14;
|
|
680
683
|
setWebChatStyles({
|
|
681
684
|
...webChatStyles,
|
|
682
|
-
...((_props$
|
|
685
|
+
...((_props$webChatContain14 = props.webChatContainerProps) === null || _props$webChatContain14 === void 0 ? void 0 : _props$webChatContain14.webChatStyles)
|
|
683
686
|
});
|
|
684
|
-
}, [(_props$
|
|
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$
|
|
786
|
+
var _props$webChatContain16;
|
|
784
787
|
dispatch({
|
|
785
788
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_RENDERING_MIDDLEWARE_PROPS,
|
|
786
|
-
payload: (_props$
|
|
789
|
+
payload: (_props$webChatContain16 = props.webChatContainerProps) === null || _props$webChatContain16 === void 0 ? void 0 : _props$webChatContain16.renderingMiddlewareProps
|
|
787
790
|
});
|
|
788
|
-
}, [(_props$
|
|
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$
|
|
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,
|