@microsoft/omnichannel-chat-widget 1.7.4-main.f0f5d34 → 1.7.4

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 (99) hide show
  1. package/lib/cjs/common/facades/FacadeChatSDK.js +298 -0
  2. package/lib/cjs/common/facades/types/IFacadeChatSDKInput.js +1 -0
  3. package/lib/cjs/common/telemetry/TelemetryConstants.js +7 -0
  4. package/lib/cjs/common/telemetry/TelemetryHelper.js +12 -0
  5. package/lib/cjs/common/utils.js +2 -2
  6. package/lib/cjs/components/callingcontainerstateful/CallingContainerStateful.js +4 -8
  7. package/lib/cjs/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +5 -6
  8. package/lib/cjs/components/footerstateful/FooterStateful.js +15 -13
  9. package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +8 -10
  10. package/lib/cjs/components/headerstateful/HeaderStateful.js +4 -0
  11. package/lib/cjs/components/livechatwidget/LiveChatWidget.js +26 -3
  12. package/lib/cjs/components/livechatwidget/common/authHelper.js +14 -5
  13. package/lib/cjs/components/livechatwidget/common/createAdapter.js +9 -9
  14. package/lib/cjs/components/livechatwidget/common/endChat.js +40 -30
  15. package/lib/cjs/components/livechatwidget/common/initCallingSdk.js +3 -3
  16. package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +10 -6
  17. package/lib/cjs/components/livechatwidget/common/liveChatConfigUtils.js +2 -3
  18. package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +11 -12
  19. package/lib/cjs/components/livechatwidget/common/renderSurveyHelpers.js +5 -5
  20. package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +4 -4
  21. package/lib/cjs/components/livechatwidget/common/startChat.js +54 -39
  22. package/lib/cjs/components/livechatwidget/common/startChatErrorHandler.js +7 -7
  23. package/lib/cjs/components/livechatwidget/common/updateSessionDataForTelemetry.js +8 -8
  24. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +63 -40
  25. package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +3 -0
  26. package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +1 -1
  27. package/lib/cjs/components/reconnectchatpanestateful/ReconnectChatPaneStateful.js +4 -2
  28. package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +11 -6
  29. package/lib/cjs/components/webchatcontainerstateful/common/mockchatsdk.js +4 -1
  30. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +2 -1
  31. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware.js +4 -4
  32. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/notification/NotificationHandler.js +8 -0
  33. package/lib/cjs/contexts/FacadeChatSDKStore.js +10 -0
  34. package/lib/cjs/hooks/useFacadeChatSDKStore.js +17 -0
  35. package/lib/cjs/index.js +9 -2
  36. package/lib/cjs/plugins/createChatTranscript.js +2 -2
  37. package/lib/esm/common/facades/FacadeChatSDK.js +291 -0
  38. package/lib/esm/common/facades/types/IFacadeChatSDKInput.js +1 -0
  39. package/lib/esm/common/telemetry/TelemetryConstants.js +7 -0
  40. package/lib/esm/common/telemetry/TelemetryHelper.js +12 -0
  41. package/lib/esm/common/utils.js +2 -2
  42. package/lib/esm/components/callingcontainerstateful/CallingContainerStateful.js +4 -8
  43. package/lib/esm/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +5 -6
  44. package/lib/esm/components/footerstateful/FooterStateful.js +15 -13
  45. package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +8 -10
  46. package/lib/esm/components/headerstateful/HeaderStateful.js +4 -0
  47. package/lib/esm/components/livechatwidget/LiveChatWidget.js +26 -3
  48. package/lib/esm/components/livechatwidget/common/authHelper.js +14 -5
  49. package/lib/esm/components/livechatwidget/common/createAdapter.js +9 -9
  50. package/lib/esm/components/livechatwidget/common/endChat.js +40 -30
  51. package/lib/esm/components/livechatwidget/common/initCallingSdk.js +3 -3
  52. package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +10 -6
  53. package/lib/esm/components/livechatwidget/common/liveChatConfigUtils.js +2 -4
  54. package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +11 -12
  55. package/lib/esm/components/livechatwidget/common/renderSurveyHelpers.js +5 -5
  56. package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +4 -4
  57. package/lib/esm/components/livechatwidget/common/startChat.js +55 -40
  58. package/lib/esm/components/livechatwidget/common/startChatErrorHandler.js +7 -7
  59. package/lib/esm/components/livechatwidget/common/updateSessionDataForTelemetry.js +8 -8
  60. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +63 -40
  61. package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +3 -0
  62. package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +1 -1
  63. package/lib/esm/components/reconnectchatpanestateful/ReconnectChatPaneStateful.js +4 -2
  64. package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +11 -6
  65. package/lib/esm/components/webchatcontainerstateful/common/mockchatsdk.js +4 -1
  66. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +2 -1
  67. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware.js +4 -4
  68. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/notification/NotificationHandler.js +8 -0
  69. package/lib/esm/contexts/FacadeChatSDKStore.js +4 -0
  70. package/lib/esm/hooks/useFacadeChatSDKStore.js +10 -0
  71. package/lib/esm/index.js +5 -4
  72. package/lib/esm/plugins/createChatTranscript.js +2 -2
  73. package/lib/types/common/facades/FacadeChatSDK.d.ts +71 -0
  74. package/lib/types/common/facades/types/IFacadeChatSDKInput.d.ts +13 -0
  75. package/lib/types/common/telemetry/TelemetryConstants.d.ts +9 -2
  76. package/lib/types/common/telemetry/TelemetryHelper.d.ts +1 -0
  77. package/lib/types/common/telemetry/definitions/Payload.d.ts +7 -0
  78. package/lib/types/common/utils.d.ts +2 -1
  79. package/lib/types/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.d.ts +3 -2
  80. package/lib/types/components/livechatwidget/common/authHelper.d.ts +14 -1
  81. package/lib/types/components/livechatwidget/common/createAdapter.d.ts +2 -1
  82. package/lib/types/components/livechatwidget/common/endChat.d.ts +4 -3
  83. package/lib/types/components/livechatwidget/common/initCallingSdk.d.ts +2 -1
  84. package/lib/types/components/livechatwidget/common/initWebChatComposer.d.ts +2 -1
  85. package/lib/types/components/livechatwidget/common/liveChatConfigUtils.d.ts +2 -1
  86. package/lib/types/components/livechatwidget/common/reconnectChatHelper.d.ts +3 -2
  87. package/lib/types/components/livechatwidget/common/renderSurveyHelpers.d.ts +2 -1
  88. package/lib/types/components/livechatwidget/common/setPostChatContextAndLoadSurvey.d.ts +2 -1
  89. package/lib/types/components/livechatwidget/common/startChat.d.ts +5 -4
  90. package/lib/types/components/livechatwidget/common/startChatErrorHandler.d.ts +2 -1
  91. package/lib/types/components/livechatwidget/common/updateSessionDataForTelemetry.d.ts +2 -1
  92. package/lib/types/components/postchatsurveypanestateful/interfaces/IPostChatSurveyPaneStatefulProps.d.ts +1 -0
  93. package/lib/types/components/webchatcontainerstateful/common/mockchatsdk.d.ts +2 -1
  94. package/lib/types/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.d.ts +1 -0
  95. package/lib/types/contexts/FacadeChatSDKStore.d.ts +1 -0
  96. package/lib/types/hooks/useFacadeChatSDKStore.d.ts +3 -0
  97. package/lib/types/index.d.ts +4 -3
  98. package/lib/types/plugins/createChatTranscript.d.ts +2 -1
  99. package/package.json +4 -2
@@ -0,0 +1,291 @@
1
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
3
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
4
+ import { BroadcastEvent, LogLevel, TelemetryEvent } from "../telemetry/TelemetryConstants";
5
+ import { getAuthClientFunction, handleAuthentication } from "../../components/livechatwidget/common/authHelper";
6
+ import { BroadcastService } from "@microsoft/omnichannel-chat-components";
7
+ import { TelemetryHelper } from "../telemetry/TelemetryHelper";
8
+ import { isNullOrEmptyString } from "../utils";
9
+ export class FacadeChatSDK {
10
+ isSDKMocked() {
11
+ return this.sdkMocked;
12
+ }
13
+ getChatSDK() {
14
+ return this.chatSDK;
15
+ }
16
+ destroy() {
17
+ this.token = null;
18
+ this.expiration = 0;
19
+ }
20
+ isTokenSet() {
21
+ return !isNullOrEmptyString(this.token);
22
+ }
23
+ constructor(input) {
24
+ _defineProperty(this, "chatSDK", void 0);
25
+ _defineProperty(this, "chatConfig", void 0);
26
+ _defineProperty(this, "token", "");
27
+ _defineProperty(this, "expiration", 0);
28
+ _defineProperty(this, "isAuthenticated", void 0);
29
+ _defineProperty(this, "getAuthToken", void 0);
30
+ _defineProperty(this, "sdkMocked", void 0);
31
+ this.chatSDK = input.chatSDK;
32
+ this.chatConfig = input.chatConfig;
33
+ this.getAuthToken = input.getAuthToken;
34
+ this.isAuthenticated = input.isAuthenticated;
35
+ this.sdkMocked = input.isSDKMocked;
36
+ }
37
+
38
+ //set default expiration to zero, for undefined or missed exp in jwt
39
+ convertExpiration() {
40
+ let expiration = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
41
+ // Converting expiration to seconds, if contains decimals or is identified as milliseconds
42
+ if (expiration.toString().length === 13) {
43
+ return Math.floor(expiration / 1000);
44
+ }
45
+ // If the epoch value is already in seconds, return it as is
46
+ return expiration;
47
+ }
48
+ isTokenExpired() {
49
+ // if expiration is 0, token is not going to be validated ( this is to cover the case of token with no expiration)
50
+ if (this.expiration === 0) {
51
+ return false;
52
+ }
53
+
54
+ // obtain current time in seconds
55
+ const now = Math.floor(Date.now() / 1000);
56
+
57
+ // compare expiration time with current time
58
+ if (now > this.expiration) {
59
+ console.log("Token is expired", now, this.expiration, now > this.expiration);
60
+ return true;
61
+ }
62
+ return false;
63
+ }
64
+ async setToken(token) {
65
+ // token must be not null, and must be new
66
+ if (!isNullOrEmptyString(token) && token !== this.token) {
67
+ var _this$token;
68
+ const instant = Math.floor(Date.now() / 1000);
69
+ this.token = token;
70
+ // decompose token
71
+ const tokenParts = (_this$token = this.token) === null || _this$token === void 0 ? void 0 : _this$token.split(".");
72
+ if (!tokenParts || tokenParts.length <= 1) {
73
+ TelemetryHelper.logFacadeChatSDKEvent(LogLevel.ERROR, {
74
+ Event: TelemetryEvent.NewTokenFailed,
75
+ Description: "Invalid token format",
76
+ ExceptionDetails: "Token must be in JWT format"
77
+ });
78
+ throw new Error("Invalid token format, must be in JWT format");
79
+ }
80
+ // decode token
81
+ const tokenDecoded = JSON.parse(atob(tokenParts[1]));
82
+ // calculate expiration time
83
+ this.expiration = this.convertExpiration(tokenDecoded.exp);
84
+
85
+ // this is a control , in case the getAuthToken function returns same token
86
+ if (this.expiration > 0 && this.expiration < instant) {
87
+ TelemetryHelper.logFacadeChatSDKEvent(LogLevel.ERROR, {
88
+ Event: TelemetryEvent.NewTokenExpired,
89
+ Description: "New token is already expired",
90
+ ExceptionDetails: {
91
+ "Instant": instant,
92
+ "Expiration": this.expiration
93
+ }
94
+ });
95
+ throw new Error("New token is already expired, with epoch time " + this.expiration);
96
+ }
97
+ }
98
+ }
99
+ async tokenRing() {
100
+ // this is needed for storybooks, specifically for reconnect pane which requires authentication bypass
101
+ if (this.sdkMocked === true) {
102
+ return {
103
+ result: true,
104
+ message: "Authentication not needed"
105
+ };
106
+ }
107
+ if (!this.isAuthenticated) {
108
+ return {
109
+ result: true,
110
+ message: "Authentication not needed"
111
+ };
112
+ }
113
+ if (this.isTokenSet() && !this.isTokenExpired()) {
114
+ return {
115
+ result: true,
116
+ message: "Token is valid"
117
+ };
118
+ }
119
+ if (this.getAuthToken === undefined) {
120
+ TelemetryHelper.logFacadeChatSDKEvent(LogLevel.ERROR, {
121
+ Event: TelemetryEvent.NewTokenFailed,
122
+ Description: "GetAuthToken function is not present",
123
+ ExceptionDetails: "Missing function : " + getAuthClientFunction(this.chatConfig)
124
+ });
125
+ return {
126
+ result: false,
127
+ message: "GetAuthToken function is not present"
128
+ };
129
+ }
130
+
131
+ // if token is not set, or token is already expired , then go to grab a token
132
+ this.token = "";
133
+ this.expiration = 0;
134
+ try {
135
+ const ring = await handleAuthentication(this.chatSDK, this.chatConfig, this.getAuthToken);
136
+ if (ring.result === true && ring.token) {
137
+ await this.setToken(ring.token);
138
+ TelemetryHelper.logFacadeChatSDKEvent(LogLevel.INFO, {
139
+ Event: TelemetryEvent.NewTokenSuccess,
140
+ Description: "New Token obtained",
141
+ Data: {
142
+ "Token_Expiration": this.expiration
143
+ }
144
+ });
145
+ return {
146
+ result: true,
147
+ message: "New Token obtained"
148
+ };
149
+ } else {
150
+ var _ring$error, _ring$error2;
151
+ console.error("Failed to get token", ring);
152
+ TelemetryHelper.logFacadeChatSDKEvent(LogLevel.ERROR, {
153
+ Event: TelemetryEvent.NewTokenFailed,
154
+ Description: (_ring$error = ring.error) === null || _ring$error === void 0 ? void 0 : _ring$error.message,
155
+ ExceptionDetails: ring.error
156
+ });
157
+ return {
158
+ result: false,
159
+ message: ((_ring$error2 = ring.error) === null || _ring$error2 === void 0 ? void 0 : _ring$error2.message) || "Failed to get token"
160
+ };
161
+ }
162
+ } catch (e) {
163
+ console.error("Unexpected error while getting token", e);
164
+ TelemetryHelper.logFacadeChatSDKEvent(LogLevel.ERROR, {
165
+ Event: TelemetryEvent.NewTokenFailed,
166
+ Description: "Unexpected error while getting token",
167
+ ExceptionDetails: e
168
+ });
169
+ return {
170
+ result: false,
171
+ message: "Unexpected error while getting token"
172
+ };
173
+ }
174
+ }
175
+ async validateAndExecuteCall(functionName, fn) {
176
+ const pingResponse = await this.tokenRing();
177
+ if (pingResponse.result === true) {
178
+ return fn();
179
+ }
180
+ const executionErrorMessage = `Authentication failed: Process to get a token failed for ${functionName}, ${pingResponse.message}`;
181
+ //telemetry is already logged in tokenRing, so no need to log again, just return the error and communicate to the console
182
+ console.error(executionErrorMessage);
183
+ BroadcastService.postMessage({
184
+ eventName: BroadcastEvent.OnWidgetError,
185
+ payload: {
186
+ errorMessage: executionErrorMessage
187
+ }
188
+ });
189
+ throw new Error(executionErrorMessage);
190
+ }
191
+ async initialize() {
192
+ let optionalParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
193
+ return this.validateAndExecuteCall("initialize", () => this.chatSDK.initialize(optionalParams));
194
+ }
195
+ async getChatReconnectContext() {
196
+ let optionalParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
197
+ return this.validateAndExecuteCall("getChatReconnectContext", () => this.chatSDK.getChatReconnectContext(optionalParams));
198
+ }
199
+ async startChat() {
200
+ let optionalParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
201
+ return this.validateAndExecuteCall("startChat", () => this.chatSDK.startChat(optionalParams));
202
+ }
203
+ async endChat() {
204
+ let optionalParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
205
+ return this.validateAndExecuteCall("endChat", () => this.chatSDK.endChat(optionalParams));
206
+ }
207
+ async getCurrentLiveChatContext() {
208
+ return this.validateAndExecuteCall("getCurrentLiveChatContext", () => this.chatSDK.getCurrentLiveChatContext());
209
+ }
210
+ async getConversationDetails() {
211
+ let optionalParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
212
+ return this.validateAndExecuteCall("getConversationDetails", () => this.chatSDK.getConversationDetails(optionalParams));
213
+ }
214
+
215
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
216
+ async getPreChatSurvey() {
217
+ let parse = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
218
+ //prechat survey is obtained from config object, which is not required to be authenticated
219
+ // removing the tokenRing function from this call for backward compatibility
220
+ // TODO :: wrap this function around authentication
221
+ return this.chatSDK.getPreChatSurvey(parse);
222
+ }
223
+ async getLiveChatConfig(optionalParams) {
224
+ return this.validateAndExecuteCall("getLiveChatConfig", () => this.chatSDK.getLiveChatConfig(optionalParams));
225
+ }
226
+ async getChatToken() {
227
+ let cached = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
228
+ let optionalParams = arguments.length > 1 ? arguments[1] : undefined;
229
+ return this.validateAndExecuteCall("getChatToken", () => this.chatSDK.getChatToken(cached, optionalParams));
230
+ }
231
+ async getCallingToken() {
232
+ return this.validateAndExecuteCall("getCallingToken", () => this.chatSDK.getCallingToken());
233
+ }
234
+ async getMessages() {
235
+ return this.validateAndExecuteCall("getMessages", () => this.chatSDK.getMessages());
236
+ }
237
+ async getDataMaskingRules() {
238
+ return this.validateAndExecuteCall("getDataMaskingRules", () => this.chatSDK.getDataMaskingRules());
239
+ }
240
+ async sendMessage(message) {
241
+ return this.validateAndExecuteCall("sendMessage", () => this.chatSDK.sendMessage(message));
242
+ }
243
+ async onNewMessage(onNewMessageCallback) {
244
+ let optionalParams = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
245
+ return this.validateAndExecuteCall("onNewMessage", () => this.chatSDK.onNewMessage(onNewMessageCallback, optionalParams));
246
+ }
247
+ async sendTypingEvent() {
248
+ return this.validateAndExecuteCall("sendTypingEvent", () => this.chatSDK.sendTypingEvent());
249
+ }
250
+ async onTypingEvent(onTypingEventCallback) {
251
+ return this.validateAndExecuteCall("onTypingEvent", () => this.chatSDK.onTypingEvent(onTypingEventCallback));
252
+ }
253
+ async onAgentEndSession(onAgentEndSessionCallback) {
254
+ return this.validateAndExecuteCall("onAgentEndSession", () => this.chatSDK.onAgentEndSession(onAgentEndSessionCallback));
255
+ }
256
+ async uploadFileAttachment(fileInfo) {
257
+ return this.validateAndExecuteCall("uploadFileAttachment", () => this.chatSDK.uploadFileAttachment(fileInfo));
258
+ }
259
+ async downloadFileAttachment(fileMetadata) {
260
+ return this.validateAndExecuteCall("downloadFileAttachment", () => this.chatSDK.downloadFileAttachment(fileMetadata));
261
+ }
262
+ async emailLiveChatTranscript(body) {
263
+ let optionalParams = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
264
+ return this.validateAndExecuteCall("emailLiveChatTranscript", () => this.chatSDK.emailLiveChatTranscript(body, optionalParams));
265
+ }
266
+ async getLiveChatTranscript() {
267
+ let optionalParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
268
+ return this.validateAndExecuteCall("getLiveChatTranscript", () => this.chatSDK.getLiveChatTranscript(optionalParams));
269
+ }
270
+
271
+ // response from origin is unknown, but this definition breaks create adapter for shimAdapter, switching to any until type is returned from origin
272
+ async createChatAdapter() {
273
+ let optionalParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
274
+ return this.validateAndExecuteCall("createChatAdapter", () => this.chatSDK.createChatAdapter(optionalParams));
275
+ }
276
+ async isVoiceVideoCallingEnabled() {
277
+ this.tokenRing();
278
+ return this.chatSDK.isVoiceVideoCallingEnabled();
279
+ }
280
+ async getVoiceVideoCalling() {
281
+ let params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
282
+ return this.validateAndExecuteCall("getVoiceVideoCalling", () => this.chatSDK.getVoiceVideoCalling(params));
283
+ }
284
+ async getPostChatSurveyContext() {
285
+ return this.validateAndExecuteCall("getPostChatSurveyContext", () => this.chatSDK.getPostChatSurveyContext());
286
+ }
287
+ async getAgentAvailability() {
288
+ let optionalParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
289
+ return this.validateAndExecuteCall("getAgentAvailability", () => this.chatSDK.getAgentAvailability(optionalParams));
290
+ }
291
+ }
@@ -60,6 +60,7 @@ export let BroadcastEvent;
60
60
  BroadcastEvent["UpdateConversationDataForTelemetry"] = "UpdateConversationDataForTelemetry";
61
61
  BroadcastEvent["ContactIdNotFound"] = "ContactIdNotFound";
62
62
  BroadcastEvent["SyncMinimize"] = "SyncMinimize";
63
+ BroadcastEvent["OnWidgetError"] = "OnWidgetError";
63
64
  })(BroadcastEvent || (BroadcastEvent = {}));
64
65
  export let TelemetryEvent;
65
66
  (function (TelemetryEvent) {
@@ -115,6 +116,7 @@ export let TelemetryEvent;
115
116
  TelemetryEvent["CloseChatCall"] = "CloseChatCall";
116
117
  TelemetryEvent["CloseChatMethodException"] = "CloseChatMethodException";
117
118
  TelemetryEvent["PrechatSurveyLoaded"] = "PrechatSurveyLoaded";
119
+ TelemetryEvent["PrechatSurveyExpected"] = "PrechatSurveyExpected";
118
120
  TelemetryEvent["PrechatSubmitted"] = "PrechatSubmitted";
119
121
  TelemetryEvent["StartChatSDKCall"] = "StartChatCall";
120
122
  TelemetryEvent["StartChatEventRecevied"] = "StartChatEventReceived";
@@ -181,6 +183,7 @@ export let TelemetryEvent;
181
183
  TelemetryEvent["SendTypingIndicatorSucceeded"] = "SendTypingIndicatorSucceeded";
182
184
  TelemetryEvent["SendTypingIndicatorFailed"] = "SendTypingIndicatorFailed";
183
185
  TelemetryEvent["WebChatEvent"] = "WebChatEvent";
186
+ TelemetryEvent["FacadeChatSDKEvent"] = "FacadeChatSDKEvent";
184
187
  TelemetryEvent["PreChatSurveyStartChatMethodFailed"] = "PreChatSurveyStartChatMethodFailed";
185
188
  TelemetryEvent["ChatAlreadyTriggered"] = "ChatAlreadyTriggered";
186
189
  TelemetryEvent["StartProactiveChatEventReceived"] = "StartProactiveChatEventReceived";
@@ -211,6 +214,10 @@ export let TelemetryEvent;
211
214
  TelemetryEvent["ChatDisconnectThreadEventReceived"] = "ChatDisconnectThreadEventReceived";
212
215
  TelemetryEvent["HiddenAdaptiveCardMessageReceived"] = "HiddenAdaptiveCardMessageReceived";
213
216
  TelemetryEvent["EndingAdapterAfterDisconnectionError"] = "EndingAdapterAfterDisconnectionError";
217
+ TelemetryEvent["NewTokenSuccess"] = "NewTokenSuccess";
218
+ TelemetryEvent["NewTokenFailed"] = "NewTokenFailed";
219
+ TelemetryEvent["NewTokenExpired"] = "NewTokenExpired";
220
+ TelemetryEvent["TokenEmptyOrSame"] = "TokenEmptyOrSame";
214
221
  })(TelemetryEvent || (TelemetryEvent = {}));
215
222
  export class TelemetryConstants {
216
223
  static map(eventTypeOrScenarioType) {
@@ -15,6 +15,7 @@ export class TelemetryHelper {
15
15
  case ScenarioType.WEBCHAT:
16
16
  return TelemetryHelper.conformToWebChatContract(level, input);
17
17
  case ScenarioType.OCCHATSDK:
18
+ case ScenarioType.SDK:
18
19
  return TelemetryHelper.conformToOCChatSDKContract(level, input);
19
20
  case ScenarioType.ACTIONS:
20
21
  return TelemetryHelper.conformToActionsContract(level, input);
@@ -150,6 +151,7 @@ export class TelemetryHelper {
150
151
  event.TransactionId = payload.TransactionId;
151
152
  event.ElapsedTimeInMilliseconds = payload.ElapsedTimeInMilliseconds;
152
153
  event.ExceptionDetails = JSON.stringify(payload.ExceptionDetails);
154
+ event.Description = payload.Description;
153
155
  });
154
156
  }
155
157
  static addChatConfigDataToTelemetry(chatConfig, telemetryInternalData) {
@@ -255,4 +257,14 @@ _defineProperty(TelemetryHelper, "logWebChatEvent", (logLevel, payload) => {
255
257
  }
256
258
  };
257
259
  BroadcastService.postMessage(telemetryEvent);
260
+ });
261
+ _defineProperty(TelemetryHelper, "logFacadeChatSDKEvent", (logLevel, payload) => {
262
+ const telemetryEvent = {
263
+ eventName: (payload === null || payload === void 0 ? void 0 : payload.Event) ?? TelemetryEvent.FacadeChatSDKEvent,
264
+ logLevel: logLevel,
265
+ payload: {
266
+ ...payload
267
+ }
268
+ };
269
+ BroadcastService.postMessage(telemetryEvent);
258
270
  });
@@ -357,7 +357,7 @@ export const isThisSessionPopout = href => {
357
357
  return false;
358
358
  };
359
359
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
360
- export const getConversationDetailsCall = async function (chatSDK) {
360
+ export const getConversationDetailsCall = async function (facadeChatSDK) {
361
361
  let liveChatContext = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
362
362
  let conversationDetails = undefined; // eslint-disable-line @typescript-eslint/no-explicit-any
363
363
  const optionalParams = {}; // eslint-disable-line @typescript-eslint/no-explicit-any
@@ -370,7 +370,7 @@ export const getConversationDetailsCall = async function (chatSDK) {
370
370
  Event: TelemetryEvent.GetConversationDetailsCallStarted,
371
371
  Description: "Conversation details call started"
372
372
  });
373
- conversationDetails = await chatSDK.getConversationDetails(optionalParams);
373
+ conversationDetails = await facadeChatSDK.getConversationDetails(optionalParams);
374
374
  } catch (error) {
375
375
  checkContactIdError(error);
376
376
  TelemetryHelper.logSDKEvent(LogLevel.ERROR, {
@@ -4,15 +4,11 @@ import { CallingContainer } from "@microsoft/omnichannel-chat-components";
4
4
  import { LiveChatWidgetActionType } from "../../contexts/common/LiveChatWidgetActionType";
5
5
  import { TelemetryHelper } from "../../common/telemetry/TelemetryHelper";
6
6
  import useChatContextStore from "../../hooks/useChatContextStore";
7
- import useChatSDKStore from "../../hooks/useChatSDKStore";
7
+ import useFacadeSDKStore from "../../hooks/useFacadeChatSDKStore";
8
8
  export const CallingContainerStateful = props => {
9
9
  var _props$controlProps, _props$controlProps2, _props$controlProps2$, _props$controlProps3, _props$controlProps3$, _props$controlProps3$2, _props$controlProps4, _props$controlProps4$, _props$controlProps4$2, _props$controlProps5;
10
- //TODO : Close button confirmation implmentation is pending
11
-
12
10
  const [state, dispatch] = useChatContextStore();
13
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
14
- const chatSDK = useChatSDKStore();
15
-
11
+ const [facadeChatSDK] = useFacadeSDKStore();
16
12
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
17
13
  const {
18
14
  voiceVideoCallingSdk
@@ -45,7 +41,7 @@ export const CallingContainerStateful = props => {
45
41
  useEffect(() => {
46
42
  const init = async () => {
47
43
  try {
48
- var _controlProps$current, _controlProps$current2, _controlProps$current3, _controlProps$current4;
44
+ var _controlProps$current, _controlProps$current2, _controlProps$current3, _controlProps$current4, _facadeChatSDK$getCha;
49
45
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
50
46
  TelemetryHelper.callId = callId;
51
47
  await voiceVideoCallingSdk.initialize({
@@ -54,7 +50,7 @@ export const CallingContainerStateful = props => {
54
50
  // HTML element id where video stream of the agent will be rendered
55
51
  remoteVideoHTMLElementId: (_controlProps$current3 = controlProps.currentCallControlProps) === null || _controlProps$current3 === void 0 ? void 0 : (_controlProps$current4 = _controlProps$current3.nonActionIds) === null || _controlProps$current4 === void 0 ? void 0 : _controlProps$current4.remoteVideoTileId,
56
52
  // HTML element id where video stream of the customer will be rendered
57
- OCClient: chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.OCClient
53
+ OCClient: (_facadeChatSDK$getCha = facadeChatSDK.getChatSDK()) === null || _facadeChatSDK$getCha === void 0 ? void 0 : _facadeChatSDK$getCha.OCClient
58
54
  });
59
55
  } catch (e) {
60
56
  TelemetryHelper.logCallingEvent(LogLevel.ERROR, {
@@ -8,16 +8,15 @@ import { NotificationHandler } from "../webchatcontainerstateful/webchatcontroll
8
8
  import { NotificationScenarios } from "../webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios";
9
9
  import { Regex } from "../../common/Constants";
10
10
  import { TelemetryHelper } from "../../common/telemetry/TelemetryHelper";
11
- import useChatContextStore from "../../hooks/useChatContextStore";
12
- import useChatSDKStore from "../../hooks/useChatSDKStore";
13
11
  import { defaultMiddlewareLocalizedTexts } from "../webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts";
12
+ import useChatContextStore from "../../hooks/useChatContextStore";
13
+ import useFacadeSDKStore from "../../hooks/useFacadeChatSDKStore";
14
14
  export const EmailTranscriptPaneStateful = props => {
15
15
  var _props$controlProps;
16
16
  const initialTabIndexMap = new Map();
17
17
  let elements = [];
18
18
  const [state, dispatch] = useChatContextStore();
19
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
20
- const chatSDK = useChatSDKStore();
19
+ const [facadeChatSDK] = useFacadeSDKStore();
21
20
  const [initialEmail, setInitialEmail] = useState("");
22
21
  const closeEmailTranscriptPane = () => {
23
22
  dispatch({
@@ -45,7 +44,7 @@ export const EmailTranscriptPaneStateful = props => {
45
44
  attachmentMessage: (props === null || props === void 0 ? void 0 : props.attachmentMessage) ?? "The following attachment was uploaded during the conversation:"
46
45
  };
47
46
  try {
48
- await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.emailLiveChatTranscript(chatTranscriptBody, {
47
+ await (facadeChatSDK === null || facadeChatSDK === void 0 ? void 0 : facadeChatSDK.emailLiveChatTranscript(chatTranscriptBody, {
49
48
  liveChatContext
50
49
  }));
51
50
  NotificationHandler.notifySuccess(NotificationScenarios.EmailAddressSaved, defaultMiddlewareLocalizedTexts === null || defaultMiddlewareLocalizedTexts === void 0 ? void 0 : defaultMiddlewareLocalizedTexts.MIDDLEWARE_BANNER_FILE_EMAIL_ADDRESS_RECORDED_SUCCESS);
@@ -63,7 +62,7 @@ export const EmailTranscriptPaneStateful = props => {
63
62
  const message = formatTemplateString(defaultMiddlewareLocalizedTexts.MIDDLEWARE_BANNER_FILE_EMAIL_ADDRESS_RECORDED_ERROR, [email]);
64
63
  NotificationHandler.notifyError(NotificationScenarios.EmailTranscriptError, (props === null || props === void 0 ? void 0 : props.bannerMessageOnError) ?? message);
65
64
  }
66
- }, [props.attachmentMessage, props.bannerMessageOnError, chatSDK, state.domainStates.liveChatContext]);
65
+ }, [props.attachmentMessage, props.bannerMessageOnError, facadeChatSDK, state.domainStates.liveChatContext]);
67
66
  const controlProps = {
68
67
  id: "oclcw-emailTranscriptDialogContainer",
69
68
  dir: state.domainStates.globalDir,
@@ -2,6 +2,7 @@ import { LogLevel, TelemetryEvent } from "../../common/telemetry/TelemetryConsta
2
2
  import React, { useEffect } from "react";
3
3
  import AudioNotificationStateful from "./audionotificationstateful/AudioNotificationStateful";
4
4
  import { Constants } from "../../common/Constants";
5
+ import { ConversationState } from "../../contexts/common/ConversationState";
5
6
  import { Footer } from "@microsoft/omnichannel-chat-components";
6
7
  import { LiveChatWidgetActionType } from "../../contexts/common/LiveChatWidgetActionType";
7
8
  import { NewMessageNotificationSoundBase64 } from "../../assets/Audios";
@@ -10,11 +11,11 @@ import { NotificationScenarios } from "../webchatcontainerstateful/webchatcontro
10
11
  import { TelemetryHelper } from "../../common/telemetry/TelemetryHelper";
11
12
  import { downloadTranscript } from "./downloadtranscriptstateful/DownloadTranscriptStateful";
12
13
  import useChatContextStore from "../../hooks/useChatContextStore";
13
- import useChatSDKStore from "../../hooks/useChatSDKStore";
14
+ import useFacadeSDKStore from "../../hooks/useFacadeChatSDKStore";
14
15
 
15
16
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
17
  export const FooterStateful = props => {
17
- var _footerProps$controlP3, _footerProps$controlP6;
18
+ var _footerProps$controlP3;
18
19
  const [state, dispatch] = useChatContextStore();
19
20
  // hideFooterDisplay - the purpose of this is to keep the footer always "active",
20
21
  // but hide it visually in certain states (e.g., loading state) and show in some other states (e.g. active state).
@@ -25,8 +26,7 @@ export const FooterStateful = props => {
25
26
  audioNotificationProps,
26
27
  hideFooterDisplay
27
28
  } = props;
28
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
29
- const chatSDK = useChatSDKStore();
29
+ const [facadeChatSDK] = useFacadeSDKStore();
30
30
  const controlProps = {
31
31
  id: "oc-lcw-footer",
32
32
  dir: state.domainStates.globalDir,
@@ -36,7 +36,7 @@ export const FooterStateful = props => {
36
36
  Event: TelemetryEvent.DownloadTranscriptButtonClicked,
37
37
  Description: "Download Transcript button clicked."
38
38
  });
39
- await downloadTranscript(chatSDK, downloadTranscriptProps, state);
39
+ await downloadTranscript(facadeChatSDK, downloadTranscriptProps, state);
40
40
  } catch (ex) {
41
41
  TelemetryHelper.logActionEvent(LogLevel.ERROR, {
42
42
  Event: TelemetryEvent.DownloadTranscriptFailed,
@@ -82,21 +82,23 @@ export const FooterStateful = props => {
82
82
  }
83
83
  };
84
84
  useEffect(() => {
85
- if (state.appStates.isAudioMuted === null) {
86
- var _footerProps$controlP4, _footerProps$controlP5;
87
- dispatch({
88
- type: LiveChatWidgetActionType.SET_AUDIO_NOTIFICATION,
89
- payload: (footerProps === null || footerProps === void 0 ? void 0 : (_footerProps$controlP4 = footerProps.controlProps) === null || _footerProps$controlP4 === void 0 ? void 0 : (_footerProps$controlP5 = _footerProps$controlP4.audioNotificationButtonProps) === null || _footerProps$controlP5 === void 0 ? void 0 : _footerProps$controlP5.isAudioMuted) ?? false
90
- });
85
+ if (state.appStates.conversationState === ConversationState.Active) {
86
+ if (state.appStates.isAudioMuted === null) {
87
+ var _footerProps$controlP4, _footerProps$controlP5, _footerProps$controlP6;
88
+ dispatch({
89
+ type: LiveChatWidgetActionType.SET_AUDIO_NOTIFICATION,
90
+ payload: footerProps !== null && footerProps !== void 0 && (_footerProps$controlP4 = footerProps.controlProps) !== null && _footerProps$controlP4 !== void 0 && _footerProps$controlP4.hideAudioNotificationButton ? true : (footerProps === null || footerProps === void 0 ? void 0 : (_footerProps$controlP5 = footerProps.controlProps) === null || _footerProps$controlP5 === void 0 ? void 0 : (_footerProps$controlP6 = _footerProps$controlP5.audioNotificationButtonProps) === null || _footerProps$controlP6 === void 0 ? void 0 : _footerProps$controlP6.isAudioMuted) ?? false
91
+ });
92
+ }
91
93
  }
92
- }, []);
94
+ }, [state.appStates.conversationState]);
93
95
  return /*#__PURE__*/React.createElement(React.Fragment, null, !hideFooterDisplay && /*#__PURE__*/React.createElement(Footer, {
94
96
  componentOverrides: footerProps === null || footerProps === void 0 ? void 0 : footerProps.componentOverrides,
95
97
  controlProps: controlProps,
96
98
  styleProps: footerProps === null || footerProps === void 0 ? void 0 : footerProps.styleProps
97
99
  }), /*#__PURE__*/React.createElement(AudioNotificationStateful, {
98
100
  audioSrc: (audioNotificationProps === null || audioNotificationProps === void 0 ? void 0 : audioNotificationProps.audioSrc) ?? NewMessageNotificationSoundBase64,
99
- isAudioMuted: state.appStates.isAudioMuted === null ? (footerProps === null || footerProps === void 0 ? void 0 : (_footerProps$controlP6 = footerProps.controlProps) === null || _footerProps$controlP6 === void 0 ? void 0 : _footerProps$controlP6.hideAudioNotificationButton) ?? false : state.appStates.isAudioMuted ?? false
101
+ isAudioMuted: state.appStates.isAudioMuted ?? false
100
102
  }));
101
103
  };
102
104
  export default FooterStateful;
@@ -1,13 +1,13 @@
1
1
  import { Constants, TranscriptConstants } from "../../../common/Constants";
2
- import { NotificationScenarios } from "../../webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios";
2
+ import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
3
+ import { createFileAndDownload, isNullOrUndefined } from "../../../common/utils";
4
+ import DOMPurify from "dompurify";
5
+ import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
3
6
  import { NotificationHandler } from "../../webchatcontainerstateful/webchatcontroller/notification/NotificationHandler";
7
+ import { NotificationScenarios } from "../../webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios";
4
8
  import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
5
- import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
6
9
  import createChatTranscript from "../../../plugins/createChatTranscript";
7
- import DOMPurify from "dompurify";
8
- import { createFileAndDownload, isNullOrUndefined } from "../../../common/utils";
9
10
  import { executeReducer } from "../../../contexts/createReducer";
10
- import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
11
11
  const processDisplayName = displayName => {
12
12
  // if displayname matches "teamsvisitor:<some alphanumeric string>", we replace it with "Customer"
13
13
  const displayNameRegex = ".+:.+";
@@ -156,9 +156,7 @@ const beautifyChatTranscripts = (chatTranscripts, renderMarkDown, attachmentMess
156
156
  const str = docTypeTag + docStartTag + docMetaTag + bodyStartTag + mainTranscriptSection + beautifiedChats + divEndTag + bodyEndTag + docEndTag;
157
157
  return str;
158
158
  };
159
-
160
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
161
- export const downloadTranscript = async (chatSDK, downloadTranscriptProps, state) => {
159
+ export const downloadTranscript = async (facadeChatSDK, downloadTranscriptProps, state) => {
162
160
  var _state$domainStates;
163
161
  // Need to keep existing live chat context for scenarios when transcript is downloaded after endchat
164
162
  let liveChatContext = state === null || state === void 0 ? void 0 : (_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : _state$domainStates.liveChatContext;
@@ -169,7 +167,7 @@ export const downloadTranscript = async (chatSDK, downloadTranscriptProps, state
169
167
  });
170
168
  liveChatContext = inMemoryState.domainStates.liveChatContext;
171
169
  }
172
- let data = await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.getLiveChatTranscript({
170
+ let data = await (facadeChatSDK === null || facadeChatSDK === void 0 ? void 0 : facadeChatSDK.getLiveChatTranscript({
173
171
  liveChatContext
174
172
  }));
175
173
  if (typeof data === Constants.String) {
@@ -187,7 +185,7 @@ export const downloadTranscript = async (chatSDK, downloadTranscriptProps, state
187
185
  const transcriptOptions = {
188
186
  ...webChatTranscript
189
187
  };
190
- await createChatTranscript(data[Constants.ChatMessagesJson], chatSDK, false, transcriptOptions);
188
+ await createChatTranscript(data[Constants.ChatMessagesJson], facadeChatSDK, false, transcriptOptions);
191
189
  } else {
192
190
  // Legacy Transcript
193
191
  const chatTranscripts = window.btoa(encodeURIComponent(beautifyChatTranscripts(data[Constants.ChatMessagesJson], renderMarkDown, attachmentMessage)));
@@ -79,6 +79,10 @@ export const HeaderStateful = props => {
79
79
  text: "We're Offline"
80
80
  },
81
81
  onMinimizeClick: () => {
82
+ TelemetryHelper.logActionEvent(LogLevel.INFO, {
83
+ Event: TelemetryEvent.HeaderMinimizeButtonClicked,
84
+ Description: "Header Minimize button clicked."
85
+ });
82
86
  dispatch({
83
87
  type: LiveChatWidgetActionType.SET_MINIMIZED,
84
88
  payload: true
@@ -2,25 +2,48 @@ import React, { useReducer, useState } from "react";
2
2
  import { ChatAdapterStore } from "../../contexts/ChatAdapterStore";
3
3
  import { ChatContextStore } from "../../contexts/ChatContextStore";
4
4
  import { ChatSDKStore } from "../../contexts/ChatSDKStore";
5
+ import { FacadeChatSDK } from "../../common/facades/FacadeChatSDK";
6
+ import { FacadeChatSDKStore } from "../../contexts/FacadeChatSDKStore";
5
7
  import LiveChatWidgetStateful from "./livechatwidgetstateful/LiveChatWidgetStateful";
6
8
  import { createReducer } from "../../contexts/createReducer";
7
9
  import { getLiveChatWidgetContextInitialState } from "../../contexts/common/LiveChatWidgetContextInitialState";
8
10
  import { getMockChatSDKIfApplicable } from "./common/getMockChatSDKIfApplicable";
11
+ import { isNullOrUndefined } from "../../common/utils";
9
12
  import overridePropsOnMockIfApplicable from "./common/overridePropsOnMockIfApplicable";
10
13
  export const LiveChatWidget = props => {
11
- var _props$mock;
14
+ var _props$mock, _props$chatConfig, _props$chatConfig$Liv;
12
15
  const reducer = createReducer();
13
16
  const [state, dispatch] = useReducer(reducer, getLiveChatWidgetContextInitialState(props));
14
17
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
15
18
  const [adapter, setAdapter] = useState(undefined);
19
+ const [facadeChatSDK, setFacadeChatSDK] = useState(undefined);
16
20
  const chatSDK = getMockChatSDKIfApplicable(props.chatSDK, props === null || props === void 0 ? void 0 : (_props$mock = props.mock) === null || _props$mock === void 0 ? void 0 : _props$mock.type);
17
21
  overridePropsOnMockIfApplicable(props);
18
- return /*#__PURE__*/React.createElement(ChatSDKStore.Provider, {
22
+ if (!props.chatConfig) {
23
+ throw new Error("chatConfig is required");
24
+ }
25
+
26
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
27
+ 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);
28
+ if (!facadeChatSDK) {
29
+ var _props$mock2;
30
+ setFacadeChatSDK(new FacadeChatSDK({
31
+ "chatSDK": chatSDK,
32
+ "chatConfig": props.chatConfig,
33
+ "isAuthenticated": isAuthenticatedChat,
34
+ "getAuthToken": props === null || props === void 0 ? void 0 : props.getAuthToken,
35
+ //when type is not undefined, it means the SDK is mocked
36
+ "isSDKMocked": !isNullOrUndefined(props === null || props === void 0 ? void 0 : (_props$mock2 = props.mock) === null || _props$mock2 === void 0 ? void 0 : _props$mock2.type)
37
+ }));
38
+ }
39
+ return /*#__PURE__*/React.createElement(FacadeChatSDKStore.Provider, {
40
+ value: [facadeChatSDK, setFacadeChatSDK]
41
+ }, /*#__PURE__*/React.createElement(ChatSDKStore.Provider, {
19
42
  value: chatSDK
20
43
  }, /*#__PURE__*/React.createElement(ChatAdapterStore.Provider, {
21
44
  value: [adapter, setAdapter]
22
45
  }, /*#__PURE__*/React.createElement(ChatContextStore.Provider, {
23
46
  value: [state, dispatch]
24
- }, /*#__PURE__*/React.createElement(LiveChatWidgetStateful, props))));
47
+ }, /*#__PURE__*/React.createElement(LiveChatWidgetStateful, props)))));
25
48
  };
26
49
  export default LiveChatWidget;