@microsoft/omnichannel-chat-widget 1.7.8-main.2e1cc2b → 1.7.8-main.50111af

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 (100) hide show
  1. package/lib/cjs/common/Constants.js +57 -18
  2. package/lib/cjs/common/KeyCodes.js +6 -1
  3. package/lib/cjs/common/contextDataStore/DataStoreManager.js +6 -1
  4. package/lib/cjs/common/facades/FacadeChatSDK.js +385 -291
  5. package/lib/cjs/common/storage/default/defaultCacheManager.js +6 -3
  6. package/lib/cjs/common/telemetry/TelemetryConstants.js +139 -116
  7. package/lib/cjs/common/telemetry/TelemetryHelper.js +219 -181
  8. package/lib/cjs/common/telemetry/TelemetryManager.js +9 -2
  9. package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +4 -5
  10. package/lib/cjs/components/headerstateful/HeaderStateful.js +3 -5
  11. package/lib/cjs/components/livechatwidget/common/ActivityStreamHandler.js +32 -19
  12. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +71 -56
  13. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +17 -8
  14. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/HiddenAdaptiveCardActivitySubscriber.js +65 -52
  15. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +31 -18
  16. package/lib/cjs/components/livechatwidget/common/ChatAdapterShim.js +14 -6
  17. package/lib/cjs/components/livechatwidget/common/Deferred.js +14 -6
  18. package/lib/cjs/components/livechatwidget/common/authHelper.js +15 -0
  19. package/lib/cjs/components/livechatwidget/common/chatDisconnectHelper.js +3 -1
  20. package/lib/cjs/components/livechatwidget/common/endChat.js +4 -18
  21. package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +0 -5
  22. package/lib/cjs/components/livechatwidget/common/startChat.js +2 -23
  23. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +17 -11
  24. package/lib/cjs/components/ooohpanestateful/OOOHPaneStateful.js +9 -3
  25. package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +22 -6
  26. package/lib/cjs/components/postchatsurveypanestateful/common/isValidSurveyUrl.js +28 -0
  27. package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +4 -3
  28. package/lib/cjs/components/webchatcontainerstateful/common/DemoChatAdapter.js +88 -65
  29. package/lib/cjs/components/webchatcontainerstateful/common/DemoChatSDK.js +26 -7
  30. package/lib/cjs/components/webchatcontainerstateful/common/DesignerChatAdapter.js +49 -26
  31. package/lib/cjs/components/webchatcontainerstateful/common/DesignerChatSDK.js +57 -35
  32. package/lib/cjs/components/webchatcontainerstateful/common/mockadapter.js +62 -52
  33. package/lib/cjs/components/webchatcontainerstateful/common/mockchatsdk.js +95 -61
  34. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +6 -1
  35. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/WebChatStoreLoader.js +6 -1
  36. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/markdownrenderers/HyperlinkTextOverrideRenderer.js +53 -39
  37. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +4 -0
  38. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/notification/NotificationHandler.js +88 -60
  39. package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +18 -6
  40. package/lib/cjs/firstresponselatency/Constants.js +13 -0
  41. package/lib/cjs/firstresponselatency/FirstMessageTrackerFromBot.js +118 -0
  42. package/lib/cjs/firstresponselatency/FirstResponseLatencyTracker.js +201 -0
  43. package/lib/cjs/firstresponselatency/util.js +98 -0
  44. package/lib/cjs/plugins/createChatTranscript.js +92 -62
  45. package/lib/cjs/plugins/newMessageEventHandler.js +102 -88
  46. package/lib/esm/common/Constants.js +57 -18
  47. package/lib/esm/common/KeyCodes.js +6 -1
  48. package/lib/esm/common/contextDataStore/DataStoreManager.js +6 -1
  49. package/lib/esm/common/facades/FacadeChatSDK.js +385 -291
  50. package/lib/esm/common/storage/default/defaultCacheManager.js +6 -1
  51. package/lib/esm/common/telemetry/TelemetryConstants.js +139 -116
  52. package/lib/esm/common/telemetry/TelemetryHelper.js +219 -181
  53. package/lib/esm/common/telemetry/TelemetryManager.js +9 -2
  54. package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +4 -5
  55. package/lib/esm/components/headerstateful/HeaderStateful.js +3 -5
  56. package/lib/esm/components/livechatwidget/common/ActivityStreamHandler.js +32 -19
  57. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +71 -56
  58. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +17 -8
  59. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/HiddenAdaptiveCardActivitySubscriber.js +65 -52
  60. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +31 -18
  61. package/lib/esm/components/livechatwidget/common/ChatAdapterShim.js +14 -6
  62. package/lib/esm/components/livechatwidget/common/Deferred.js +14 -6
  63. package/lib/esm/components/livechatwidget/common/authHelper.js +15 -0
  64. package/lib/esm/components/livechatwidget/common/chatDisconnectHelper.js +3 -1
  65. package/lib/esm/components/livechatwidget/common/endChat.js +4 -18
  66. package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +1 -6
  67. package/lib/esm/components/livechatwidget/common/startChat.js +3 -24
  68. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +17 -11
  69. package/lib/esm/components/ooohpanestateful/OOOHPaneStateful.js +9 -3
  70. package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +22 -6
  71. package/lib/esm/components/postchatsurveypanestateful/common/isValidSurveyUrl.js +21 -0
  72. package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +4 -3
  73. package/lib/esm/components/webchatcontainerstateful/common/DemoChatAdapter.js +88 -65
  74. package/lib/esm/components/webchatcontainerstateful/common/DemoChatSDK.js +26 -7
  75. package/lib/esm/components/webchatcontainerstateful/common/DesignerChatAdapter.js +49 -26
  76. package/lib/esm/components/webchatcontainerstateful/common/DesignerChatSDK.js +57 -35
  77. package/lib/esm/components/webchatcontainerstateful/common/mockadapter.js +63 -52
  78. package/lib/esm/components/webchatcontainerstateful/common/mockchatsdk.js +95 -61
  79. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +6 -1
  80. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/WebChatStoreLoader.js +6 -1
  81. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/markdownrenderers/HyperlinkTextOverrideRenderer.js +53 -39
  82. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +4 -0
  83. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/notification/NotificationHandler.js +88 -60
  84. package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +18 -6
  85. package/lib/esm/firstresponselatency/Constants.js +6 -0
  86. package/lib/esm/firstresponselatency/FirstMessageTrackerFromBot.js +112 -0
  87. package/lib/esm/firstresponselatency/FirstResponseLatencyTracker.js +194 -0
  88. package/lib/esm/firstresponselatency/util.js +87 -0
  89. package/lib/esm/plugins/createChatTranscript.js +92 -62
  90. package/lib/esm/plugins/newMessageEventHandler.js +100 -86
  91. package/lib/types/common/facades/FacadeChatSDK.d.ts +1 -0
  92. package/lib/types/common/telemetry/TelemetryConstants.d.ts +10 -1
  93. package/lib/types/components/postchatsurveypanestateful/common/isValidSurveyUrl.d.ts +2 -0
  94. package/lib/types/components/webchatcontainerstateful/interfaces/IWebChatProps.d.ts +2 -2
  95. package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +1 -1
  96. package/lib/types/firstresponselatency/Constants.d.ts +30 -0
  97. package/lib/types/firstresponselatency/FirstMessageTrackerFromBot.d.ts +1 -0
  98. package/lib/types/firstresponselatency/FirstResponseLatencyTracker.d.ts +22 -0
  99. package/lib/types/firstresponselatency/util.d.ts +7 -0
  100. package/package.json +18 -6
@@ -1,7 +1,6 @@
1
1
  import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
2
- import { Constants, LiveWorkItemState, WidgetLoadCustomErrorString, WidgetLoadTelemetryMessage } from "../../../common/Constants";
2
+ import { Constants, LiveWorkItemState, WidgetLoadTelemetryMessage } from "../../../common/Constants";
3
3
  import { checkContactIdError, createTimer, getConversationDetailsCall, getStateFromCache, getWidgetCacheIdfromProps, isNullOrEmptyString, isNullOrUndefined, isUndefinedOrEmpty } from "../../../common/utils";
4
- import { getAuthClientFunction, handleAuthentication } from "./authHelper";
5
4
  import { handleChatReconnect, isPersistentEnabled, isReconnectEnabled } from "./reconnectChatHelper";
6
5
  import { handleStartChatError, logWidgetLoadComplete } from "./startChatErrorHandler";
7
6
  import { ActivityStreamHandler } from "./ActivityStreamHandler";
@@ -13,6 +12,7 @@ import { TelemetryTimers } from "../../../common/telemetry/TelemetryManager";
13
12
  import { chatSDKStateCleanUp } from "./endChat";
14
13
  import { createAdapter } from "./createAdapter";
15
14
  import { createOnNewAdapterActivityHandler } from "../../../plugins/newMessageEventHandler";
15
+ import { createTrackingForFirstMessage } from "../../../firstresponselatency/FirstMessageTrackerFromBot";
16
16
  import { isPersistentChatEnabled } from "./liveChatConfigUtils";
17
17
  import { setPostChatContextAndLoadSurvey } from "./setPostChatContextAndLoadSurvey";
18
18
  import { shouldSetPreChatIfPersistentChat } from "./persistentChatHelper";
@@ -25,20 +25,6 @@ let widgetInstanceId;
25
25
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
26
26
  let popoutWidgetInstanceId;
27
27
 
28
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
29
- const setAuthenticationIfApplicable = async (props, facadeChatSDK) => {
30
- const chatConfig = props === null || props === void 0 ? void 0 : props.chatConfig;
31
- const getAuthToken = props === null || props === void 0 ? void 0 : props.getAuthToken;
32
- const authClientFunction = getAuthClientFunction(chatConfig);
33
- if (getAuthToken && authClientFunction) {
34
- // set auth token to chat sdk before start chat
35
- const authSuccess = await handleAuthentication(facadeChatSDK.getChatSDK(), chatConfig, getAuthToken);
36
- if (!authSuccess.result) {
37
- throw new Error(WidgetLoadCustomErrorString.AuthenticationFailedErrorString);
38
- }
39
- }
40
- };
41
-
42
28
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
43
29
  const prepareStartChat = async (props, facadeChatSDK, state, dispatch, setAdapter) => {
44
30
  optionalParams = {}; //Resetting to ensure no stale values
@@ -66,11 +52,6 @@ const prepareStartChat = async (props, facadeChatSDK, state, dispatch, setAdapte
66
52
  const isProactiveChat = state.appStates.conversationState === ConversationState.ProactiveChat;
67
53
  const isPreChatEnabledInProactiveChat = state.appStates.proactiveChatStates.proactiveChatEnablePrechat;
68
54
 
69
- // Setting auth settings to OC API to retrieve existing persistent chat session before start chat if any
70
- if (isPersistentEnabled(props.chatConfig)) {
71
- await setAuthenticationIfApplicable(props, facadeChatSDK);
72
- }
73
-
74
55
  //Setting PreChat and intiate chat
75
56
  await setPreChatAndInitiateChat(facadeChatSDK, dispatch, setAdapter, isProactiveChat, isPreChatEnabledInProactiveChat, state, props);
76
57
  };
@@ -145,6 +126,7 @@ const setPreChatAndInitiateChat = async (facadeChatSDK, dispatch, setAdapter, is
145
126
  const optionalParams = {
146
127
  isProactiveChat
147
128
  };
129
+ createTrackingForFirstMessage();
148
130
  await initStartChat(facadeChatSDK, dispatch, setAdapter, state, props, optionalParams);
149
131
  };
150
132
 
@@ -172,9 +154,6 @@ const initStartChat = async (facadeChatSDK, dispatch, setAdapter, state, props,
172
154
  Description: "Widget loading started"
173
155
  });
174
156
 
175
- // Auth token retrieval needs to happen during start chat to support pop-out chat
176
- await setAuthenticationIfApplicable(props, facadeChatSDK);
177
-
178
157
  //Check if chat retrieved from cache
179
158
  if (persistedState || params !== null && params !== void 0 && params.liveChatContext) {
180
159
  var _persistedState$domai, _persistedState$domai2, _persistedState$domai3, _persistedState$domai4, _persistedState$domai5;
@@ -56,7 +56,7 @@ import useChatContextStore from "../../../hooks/useChatContextStore";
56
56
  import useFacadeSDKStore from "../../../hooks/useFacadeChatSDKStore";
57
57
  let uiTimer;
58
58
  export const LiveChatWidgetStateful = props => {
59
- var _props$webChatContain, _props$styleProps, _props$webChatContain2, _props$webChatContain3, _props$controlProps, _props$controlProps3, _state$appStates7, _props$webChatContain7, _state$appStates14, _props$webChatContain9, _props$webChatContain10, _props$controlProps12, _props$draggableChatW, _props$draggableChatW2, _props$draggableChatW3, _props$draggableChatW4, _props$draggableChatW5, _livechatProps$webCha, _props$webChatContain11, _props$webChatContain12, _props$webChatContain13, _props$webChatContain14, _livechatProps$styleP, _livechatProps$contro, _livechatProps$contro2, _livechatProps$compon, _livechatProps$contro3, _livechatProps$compon2, _livechatProps$contro4, _livechatProps$compon3, _livechatProps$contro5, _livechatProps$compon4, _livechatProps$contro6, _livechatProps$compon5, _livechatProps$contro7, _livechatProps$compon6, _livechatProps$contro8, _livechatProps$compon7, _livechatProps$contro9, _livechatProps$compon8, _livechatProps$contro10, _livechatProps$contro11, _livechatProps$compon9, _livechatProps$contro12, _livechatProps$compon10, _livechatProps$contro13, _livechatProps$compon11, _livechatProps$compon12, _livechatProps$compon13;
59
+ var _props$webChatContain, _props$styleProps, _props$webChatContain2, _props$webChatContain3, _props$controlProps, _props$controlProps3, _state$appStates7, _props$webChatContain7, _state$appStates14, _props$webChatContain9, _props$webChatContain10, _props$controlProps12, _props$draggableChatW, _props$draggableChatW2, _props$draggableChatW3, _props$draggableChatW4, _props$draggableChatW5, _livechatProps$webCha, _props$webChatContain11, _props$webChatContain12, _props$webChatContain13, _props$webChatContain14, _props$webChatContain15, _props$webChatContain16, _props$webChatContain17, _props$webChatContain18, _livechatProps$styleP, _livechatProps$contro, _livechatProps$contro2, _livechatProps$compon, _livechatProps$contro3, _livechatProps$compon2, _livechatProps$contro4, _livechatProps$compon3, _livechatProps$contro5, _livechatProps$compon4, _livechatProps$contro6, _livechatProps$compon5, _livechatProps$contro7, _livechatProps$compon6, _livechatProps$contro8, _livechatProps$compon7, _livechatProps$contro9, _livechatProps$compon8, _livechatProps$contro10, _livechatProps$contro11, _livechatProps$compon9, _livechatProps$contro12, _livechatProps$compon10, _livechatProps$contro13, _livechatProps$compon11, _livechatProps$compon12, _livechatProps$compon13;
60
60
  useEffect(() => {
61
61
  uiTimer = createTimer();
62
62
  TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
@@ -409,7 +409,7 @@ export const LiveChatWidgetStateful = props => {
409
409
 
410
410
  // Start chat from SDK Event
411
411
  BroadcastService.getMessageByEventName(BroadcastEvent.StartChat).subscribe(msg => {
412
- var _props$chatConfig5, _props$chatConfig5$Li, _props$chatConfig6, _props$chatConfig6$Li, _msg$payload5, _msg$payload6, _msg$payload7, _msg$payload9, _inMemoryState$appSta2, _inMemoryState$appSta3, _inMemoryState$appSta4, _inMemoryState$appSta5;
412
+ var _props$chatConfig5, _props$chatConfig5$Li, _props$chatConfig6, _props$chatConfig6$Li, _msg$payload5, _msg$payload6, _msg$payload7, _msg$payload9, _inMemoryState$appSta2, _inMemoryState$appSta3;
413
413
  // If chat is out of operating hours chat widget sets the conversation state to OutOfOffice.
414
414
  if (typeof (props === null || props === void 0 ? void 0 : (_props$chatConfig5 = props.chatConfig) === null || _props$chatConfig5 === void 0 ? void 0 : (_props$chatConfig5$Li = _props$chatConfig5.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig5$Li === void 0 ? void 0 : _props$chatConfig5$Li.OutOfOperatingHours) === "string" && (props === null || props === void 0 ? void 0 : (_props$chatConfig6 = props.chatConfig) === null || _props$chatConfig6 === void 0 ? void 0 : (_props$chatConfig6$Li = _props$chatConfig6.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig6$Li === void 0 ? void 0 : _props$chatConfig6$Li.OutOfOperatingHours.toLowerCase()) === "true") {
415
415
  (state === null || state === void 0 ? void 0 : state.appStates.isMinimized) && dispatch({
@@ -447,8 +447,14 @@ export const LiveChatWidgetStateful = props => {
447
447
  });
448
448
  inMemoryState.domainStates.customContext = msg === null || msg === void 0 ? void 0 : (_msg$payload9 = msg.payload) === null || _msg$payload9 === void 0 ? void 0 : _msg$payload9.customContext;
449
449
 
450
- // Only initiate new chat if widget runtime state is one of the followings
451
- if (((_inMemoryState$appSta2 = inMemoryState.appStates) === null || _inMemoryState$appSta2 === void 0 ? void 0 : _inMemoryState$appSta2.conversationState) === ConversationState.Closed || ((_inMemoryState$appSta3 = inMemoryState.appStates) === null || _inMemoryState$appSta3 === void 0 ? void 0 : _inMemoryState$appSta3.conversationState) === ConversationState.InActive || ((_inMemoryState$appSta4 = inMemoryState.appStates) === null || _inMemoryState$appSta4 === void 0 ? void 0 : _inMemoryState$appSta4.conversationState) === ConversationState.Postchat) {
450
+ /*
451
+ * If the conversation is in closed state then we start a new chat,
452
+ * else if the conversation is in active state then we maximize the chat
453
+ * If the conversation is in inactive or postchat state then we maximize the chat.
454
+ *
455
+ * To start a new chat, it needs to be called via the close button or close chat via SDK.
456
+ **/
457
+ if (((_inMemoryState$appSta2 = inMemoryState.appStates) === null || _inMemoryState$appSta2 === void 0 ? void 0 : _inMemoryState$appSta2.conversationState) === ConversationState.Closed) {
452
458
  BroadcastService.postMessage({
453
459
  eventName: BroadcastEvent.ChatInitiated
454
460
  });
@@ -457,7 +463,7 @@ export const LiveChatWidgetStateful = props => {
457
463
  }
458
464
 
459
465
  // If minimized, maximize the chat
460
- if ((inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$appSta5 = inMemoryState.appStates) === null || _inMemoryState$appSta5 === void 0 ? void 0 : _inMemoryState$appSta5.isMinimized) === true) {
466
+ if ((inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$appSta3 = inMemoryState.appStates) === null || _inMemoryState$appSta3 === void 0 ? void 0 : _inMemoryState$appSta3.isMinimized) === true) {
461
467
  var _inMemoryState$domain, _inMemoryState$domain2, _inMemoryState$domain3, _inMemoryState$domain4;
462
468
  dispatch({
463
469
  type: LiveChatWidgetActionType.SET_MINIMIZED,
@@ -585,12 +591,12 @@ export const LiveChatWidgetStateful = props => {
585
591
  disablePolling: true
586
592
  });
587
593
  facadeChatSDK === null || facadeChatSDK === void 0 ? void 0 : facadeChatSDK.onAgentEndSession(event => {
588
- var _inMemoryState$appSta6;
594
+ var _inMemoryState$appSta4;
589
595
  const inMemoryState = executeReducer(state, {
590
596
  type: LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
591
597
  payload: null
592
598
  });
593
- if ("participantsRemoved" in event && (inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$appSta6 = inMemoryState.appStates) === null || _inMemoryState$appSta6 === void 0 ? void 0 : _inMemoryState$appSta6.conversationState) === ConversationState.Active) {
599
+ if ("participantsRemoved" in event && (inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$appSta4 = inMemoryState.appStates) === null || _inMemoryState$appSta4 === void 0 ? void 0 : _inMemoryState$appSta4.conversationState) === ConversationState.Active) {
594
600
  setWebChatStyles(styles => {
595
601
  return {
596
602
  ...styles,
@@ -733,13 +739,13 @@ export const LiveChatWidgetStateful = props => {
733
739
 
734
740
  // Handle Chat disconnect cases
735
741
  useEffect(() => {
736
- var _inMemoryState$appSta7;
742
+ var _inMemoryState$appSta5;
737
743
  const inMemoryState = executeReducer(state, {
738
744
  type: LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
739
745
  payload: null
740
746
  });
741
747
  handleChatDisconnect(props, inMemoryState, setWebChatStyles);
742
- const chatDisconnectState = inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$appSta7 = inMemoryState.appStates) === null || _inMemoryState$appSta7 === void 0 ? void 0 : _inMemoryState$appSta7.chatDisconnectEventReceived;
748
+ const chatDisconnectState = inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$appSta5 = inMemoryState.appStates) === null || _inMemoryState$appSta5 === void 0 ? void 0 : _inMemoryState$appSta5.chatDisconnectEventReceived;
743
749
  if (chatDisconnectState && adapter) {
744
750
  try {
745
751
  adapter.end();
@@ -868,8 +874,8 @@ export const LiveChatWidgetStateful = props => {
868
874
  userID: userID,
869
875
  styleOptions: {
870
876
  ...webChatStyles,
871
- bubbleBackground: ((_props$webChatContain11 = props.webChatContainerProps) === null || _props$webChatContain11 === void 0 ? void 0 : (_props$webChatContain12 = _props$webChatContain11.adaptiveCardStyles) === null || _props$webChatContain12 === void 0 ? void 0 : _props$webChatContain12.background) ?? defaultAdaptiveCardStyles.background,
872
- bubbleTextColor: ((_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.color) ?? defaultAdaptiveCardStyles.color
877
+ bubbleBackground: ((_props$webChatContain11 = props.webChatContainerProps) === null || _props$webChatContain11 === void 0 ? void 0 : (_props$webChatContain12 = _props$webChatContain11.webChatStyles) === null || _props$webChatContain12 === void 0 ? void 0 : _props$webChatContain12.bubbleBackground) ?? ((_props$webChatContain13 = props.webChatContainerProps) === null || _props$webChatContain13 === void 0 ? void 0 : (_props$webChatContain14 = _props$webChatContain13.adaptiveCardStyles) === null || _props$webChatContain14 === void 0 ? void 0 : _props$webChatContain14.background) ?? defaultAdaptiveCardStyles.background,
878
+ bubbleTextColor: ((_props$webChatContain15 = props.webChatContainerProps) === null || _props$webChatContain15 === void 0 ? void 0 : (_props$webChatContain16 = _props$webChatContain15.webChatStyles) === null || _props$webChatContain16 === void 0 ? void 0 : _props$webChatContain16.bubbleTextColor) ?? ((_props$webChatContain17 = props.webChatContainerProps) === null || _props$webChatContain17 === void 0 ? void 0 : (_props$webChatContain18 = _props$webChatContain17.adaptiveCardStyles) === null || _props$webChatContain18 === void 0 ? void 0 : _props$webChatContain18.color) ?? defaultAdaptiveCardStyles.color
873
879
  },
874
880
  directLine: directLine
875
881
  }), /*#__PURE__*/React.createElement(Stack, {
@@ -1,6 +1,7 @@
1
1
  import { LogLevel, TelemetryEvent } from "../../common/telemetry/TelemetryConstants";
2
2
  import React, { useEffect } from "react";
3
3
  import { createTimer, findAllFocusableElement } from "../../common/utils";
4
+ import DOMPurify from "dompurify";
4
5
  import { OutOfOfficeHoursPane } from "@microsoft/omnichannel-chat-components";
5
6
  import { TelemetryHelper } from "../../common/telemetry/TelemetryHelper";
6
7
  import { defaultGeneralStyleProps } from "./common/defaultStyleProps/defaultgeneralOOOHPaneStyleProps";
@@ -28,9 +29,11 @@ export const OutOfOfficeHoursPaneStateful = props => {
28
29
 
29
30
  // Move focus to the first button
30
31
  useEffect(() => {
31
- const firstElement = findAllFocusableElement(`#${state.domainStates.widgetElementId}`);
32
- if (firstElement && firstElement[0]) {
33
- firstElement[0].focus();
32
+ if (state.domainStates.widgetElementId !== null && state.domainStates.widgetElementId !== undefined && state.domainStates.widgetElementId.trim() !== "") {
33
+ const firstElement = findAllFocusableElement(`#${state.domainStates.widgetElementId}`);
34
+ if (firstElement && firstElement[0]) {
35
+ firstElement[0].focus();
36
+ }
34
37
  }
35
38
  TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
36
39
  Event: TelemetryEvent.OutOfOfficePaneLoaded
@@ -40,6 +43,9 @@ export const OutOfOfficeHoursPaneStateful = props => {
40
43
  ElapsedTimeInMilliseconds: uiTimer.milliSecondsElapsed
41
44
  });
42
45
  }, []);
46
+ if (controlProps !== null && controlProps !== void 0 && controlProps.titleText) {
47
+ controlProps.titleText = DOMPurify.sanitize(controlProps.titleText);
48
+ }
43
49
  return /*#__PURE__*/React.createElement(OutOfOfficeHoursPane, {
44
50
  componentOverrides: props.componentOverrides,
45
51
  controlProps: controlProps,
@@ -8,14 +8,16 @@ import { TelemetryHelper } from "../../common/telemetry/TelemetryHelper";
8
8
  import { defaultGeneralPostChatSurveyPaneStyleProps } from "./common/defaultStyleProps/defaultgeneralPostChatSurveyPaneStyleProps";
9
9
  import { findAllFocusableElement } from "../../common/utils";
10
10
  import useChatContextStore from "../../hooks/useChatContextStore";
11
+ import isValidSurveyUrl from "./common/isValidSurveyUrl";
11
12
  const generateSurveyInviteLink = function (surveyInviteLink, isEmbed, locale, compact) {
12
13
  let showMultiLingual = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
13
- const surveyLink = `${surveyInviteLink}
14
- &embed=${isEmbed.toString()}
15
- &compact=${compact.toString() ?? "true"}
16
- &lang=${locale ?? "en-us"}
17
- &showmultilingual=${showMultiLingual.toString() ?? "false"}`;
18
- return surveyLink;
14
+ const surveyLinkParams = new URLSearchParams({
15
+ embed: isEmbed.toString(),
16
+ compact: (compact ?? true).toString(),
17
+ lang: locale ?? "en-us",
18
+ showmultilingual: (showMultiLingual ?? false).toString()
19
+ });
20
+ return `${surveyInviteLink}&${surveyLinkParams.toString()}`;
19
21
  };
20
22
  export const PostChatSurveyPaneStateful = props => {
21
23
  var _props$styleProps, _state$appStates, _props$controlProps;
@@ -45,6 +47,20 @@ export const PostChatSurveyPaneStateful = props => {
45
47
  surveyURL: ((_props$controlProps = props.controlProps) === null || _props$controlProps === void 0 ? void 0 : _props$controlProps.surveyURL) ?? surveyInviteLink,
46
48
  ...props.controlProps
47
49
  };
50
+ if (controlProps.surveyURL) {
51
+ if (!isValidSurveyUrl(controlProps.surveyURL)) {
52
+ TelemetryHelper.logLoadingEvent(LogLevel.ERROR, {
53
+ Event: TelemetryEvent.PostChatSurveyUrlValidationFailed,
54
+ Description: `${controlProps.surveyURL} is not a valid Survey URL`
55
+ });
56
+ controlProps.surveyURL = "";
57
+ } else {
58
+ TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
59
+ Event: TelemetryEvent.PostChatSurveyUrlValidationCompleted,
60
+ Description: `${controlProps.surveyURL} is a valid Survey URL`
61
+ });
62
+ }
63
+ }
48
64
 
49
65
  // Move focus to the first button
50
66
  useEffect(() => {
@@ -0,0 +1,21 @@
1
+ import { isNullOrEmptyString } from "../../../common/utils";
2
+ const validRootDomains = ["microsoft.com", "microsoft.us", "appsplatform.us", "powervirtualagents.cn"];
3
+ const isValidSurveyUrl = url => {
4
+ if (isNullOrEmptyString(url)) {
5
+ return false;
6
+ }
7
+ try {
8
+ const objectUrl = new URL(url);
9
+ if (!objectUrl.origin || objectUrl.origin === "null") {
10
+ return false;
11
+ }
12
+ const validDomain = validRootDomains.find(domain => objectUrl.origin.endsWith(domain));
13
+ if (validDomain) {
14
+ return true;
15
+ }
16
+ } catch (error) {
17
+ return false;
18
+ }
19
+ return false;
20
+ };
21
+ export default isValidSurveyUrl;
@@ -1,12 +1,12 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
2
 
3
+ import { Constants, HtmlAttributeNames, HtmlClassNames } from "../../common/Constants";
3
4
  import { Stack } from "@fluentui/react";
4
5
  import { LogLevel, TelemetryEvent } from "../../common/telemetry/TelemetryConstants";
5
6
  import React, { useEffect } from "react";
6
7
  import { createTimer, getDeviceType, setFocusOnSendBox } from "../../common/utils";
7
8
  import { BotMagicCodeStore } from "./webchatcontroller/BotMagicCodeStore";
8
9
  import { Components } from "botframework-webchat";
9
- import { Constants, HtmlAttributeNames, HtmlClassNames } from "../../common/Constants";
10
10
  import { LiveChatWidgetActionType } from "../../contexts/common/LiveChatWidgetActionType";
11
11
  import { NotificationHandler } from "./webchatcontroller/notification/NotificationHandler";
12
12
  import { NotificationScenarios } from "./webchatcontroller/enums/NotificationScenarios";
@@ -48,7 +48,7 @@ const createMagicCodeSuccessResponse = signin => {
48
48
  };
49
49
  };
50
50
  export const WebChatContainerStateful = props => {
51
- var _webChatContainerProp, _webChatContainerProp2, _webChatContainerProp3, _webChatContainerProp4, _webChatContainerProp5, _webChatContainerProp6, _webChatContainerProp7, _props$webChatContain5, _props$webChatContain6, _defaultWebChatContai, _props$webChatContain7, _props$webChatContain8, _defaultWebChatContai2, _webChatContainerProp8, _webChatContainerProp9, _webChatContainerProp10, _webChatContainerProp11, _webChatContainerProp12, _webChatContainerProp13, _webChatContainerProp14, _webChatContainerProp15, _props$webChatContain9, _props$webChatContain10;
51
+ var _webChatContainerProp, _webChatContainerProp2, _webChatContainerProp3, _webChatContainerProp4, _webChatContainerProp5, _webChatContainerProp6, _webChatContainerProp7, _props$webChatContain5, _props$webChatContain6, _defaultWebChatContai, _props$webChatContain7, _props$webChatContain8, _defaultWebChatContai2, _webChatContainerProp8, _webChatContainerProp9, _webChatContainerProp10, _webChatContainerProp11, _webChatContainerProp12, _webChatContainerProp13, _webChatContainerProp14, _webChatContainerProp15, _webChatContainerProp16, _props$webChatContain9, _props$webChatContain10;
52
52
  useEffect(() => {
53
53
  uiTimer = createTimer();
54
54
  TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
@@ -233,8 +233,9 @@ export const WebChatContainerStateful = props => {
233
233
  color: ${(webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : (_webChatContainerProp14 = webChatContainerProps.renderingMiddlewareProps) === null || _webChatContainerProp14 === void 0 ? void 0 : (_webChatContainerProp15 = _webChatContainerProp14.sentMessageAnchorStyles) === null || _webChatContainerProp15 === void 0 ? void 0 : _webChatContainerProp15.color) ?? (defaultSentMessageAnchorStyles === null || defaultSentMessageAnchorStyles === void 0 ? void 0 : defaultSentMessageAnchorStyles.color)};
234
234
  }
235
235
 
236
+ // we had a nasty bug long time ago with crashing borders messing with the sendbox, so if customer adds this value, they need to deal with that
236
237
  .webchat__bubble:not(.webchat__bubble--from-user) .webchat__bubble__content {
237
- border-radius: 0 !important; /* Override border-radius */
238
+ border-radius: ${(webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : (_webChatContainerProp16 = webChatContainerProps.webChatStyles) === null || _webChatContainerProp16 === void 0 ? void 0 : _webChatContainerProp16.bubbleBorderRadius) ?? 0} !important; /* Override border-radius */
238
239
  }
239
240
 
240
241
  .webchat__stacked-layout_container>div {
@@ -1,3 +1,15 @@
1
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
3
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
4
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
5
+ 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); }
6
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
7
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
8
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
9
+ function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
10
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
11
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
12
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
1
13
  import "rxjs/add/operator/share";
2
14
  import "rxjs/add/observable/of";
3
15
  import { Observable } from "rxjs/Observable";
@@ -6,74 +18,85 @@ import { customerUser, postBotMessageActivity, postBotAttachmentActivity, postBo
6
18
  import { createHeroCardAttachment, createJpgFileAttachment, createSigninCardAttachment, createThumbnailCardAttachment } from "./utils/attachmentActivityUtils";
7
19
  import MockBotCommand from "./MockBotCommand";
8
20
  import MockBotCardCommandType from "./MockBotCardCommandType";
9
- export class DemoChatAdapter extends MockAdapter {
10
- constructor() {
11
- super();
21
+ export let DemoChatAdapter = /*#__PURE__*/function (_MockAdapter) {
22
+ _inherits(DemoChatAdapter, _MockAdapter);
23
+ var _super = _createSuper(DemoChatAdapter);
24
+ function DemoChatAdapter() {
25
+ var _this;
26
+ _classCallCheck(this, DemoChatAdapter);
27
+ _this = _super.call(this);
12
28
  setTimeout(() => {
13
- postSystemMessageActivity(this.activityObserver, "You're currently using a demo.", 0);
14
- postBotMessageActivity(this.activityObserver, "Type `/help` to learn more", undefined, 0); // send init message from bot
29
+ postSystemMessageActivity(_this.activityObserver, "You're currently using a demo.", 0);
30
+ postBotMessageActivity(_this.activityObserver, "Type `/help` to learn more", undefined, 0); // send init message from bot
15
31
  }, 1000);
32
+ return _this;
16
33
  }
17
- postBotCommandsActivity() {
18
- let delay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1000;
19
- postBotAttachmentActivity(this.activityObserver, [{
20
- contentType: "application/vnd.microsoft.card.thumbnail",
21
- content: {
22
- buttons: [{
23
- title: "Send system message",
24
- type: "imBack",
25
- value: "send system message"
26
- }, {
27
- title: "Send typing",
28
- type: "imBack",
29
- value: "send typing"
30
- }, {
31
- title: "Send bot message",
32
- type: "imBack",
33
- value: "send bot message"
34
- }],
35
- title: "Commands"
36
- }
37
- }], delay);
38
- }
39
- postActivity(activity) {
40
- if (activity) {
41
- postEchoActivity(this.activityObserver, activity, customerUser);
42
- if (activity.text) {
43
- switch (true) {
44
- case activity.text === MockBotCommand.Help:
45
- this.postBotCommandsActivity();
46
- break;
47
- case activity.text === MockBotCommand.SendSystemMessage:
48
- postSystemMessageActivity(this.activityObserver, "Contoso has joined the chat.");
49
- break;
50
- case activity.text === MockBotCommand.SendTyping:
51
- postBotTypingActivity(this.activityObserver);
52
- break;
53
- case activity.text === MockBotCommand.SendAttachment:
54
- postBotAttachmentActivity(this.activityObserver, [createJpgFileAttachment()]);
55
- break;
56
- case activity.text === MockBotCommand.SendBotMessage:
57
- postBotMessageActivity(this.activityObserver, "Hi, how can I help you?");
58
- break;
59
- case activity.text === `${MockBotCommand.Card} ${MockBotCardCommandType.Signin}`:
60
- postBotAttachmentActivity(this.activityObserver, [createSigninCardAttachment()]);
61
- break;
62
- case activity.text === `${MockBotCommand.Card} ${MockBotCardCommandType.Hero}`:
63
- postBotAttachmentActivity(this.activityObserver, [createHeroCardAttachment()]);
64
- break;
65
- case activity.text === `${MockBotCommand.Card} ${MockBotCardCommandType.Thumbnail}`:
66
- postBotAttachmentActivity(this.activityObserver, [createThumbnailCardAttachment()]);
67
- break;
68
- case activity.text.startsWith(`${MockBotCommand.Bot} `):
69
- postBotMessageActivity(this.activityObserver, activity.text.substring(5));
70
- break;
71
- case activity.text.startsWith(`${MockBotCommand.System} `):
72
- postSystemMessageActivity(this.activityObserver, activity.text.substring(8));
73
- break;
34
+ _createClass(DemoChatAdapter, [{
35
+ key: "postBotCommandsActivity",
36
+ value: function postBotCommandsActivity() {
37
+ let delay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1000;
38
+ postBotAttachmentActivity(this.activityObserver, [{
39
+ contentType: "application/vnd.microsoft.card.thumbnail",
40
+ content: {
41
+ buttons: [{
42
+ title: "Send system message",
43
+ type: "imBack",
44
+ value: "send system message"
45
+ }, {
46
+ title: "Send typing",
47
+ type: "imBack",
48
+ value: "send typing"
49
+ }, {
50
+ title: "Send bot message",
51
+ type: "imBack",
52
+ value: "send bot message"
53
+ }],
54
+ title: "Commands"
55
+ }
56
+ }], delay);
57
+ }
58
+ }, {
59
+ key: "postActivity",
60
+ value: function postActivity(activity) {
61
+ if (activity) {
62
+ postEchoActivity(this.activityObserver, activity, customerUser);
63
+ if (activity.text) {
64
+ switch (true) {
65
+ case activity.text === MockBotCommand.Help:
66
+ this.postBotCommandsActivity();
67
+ break;
68
+ case activity.text === MockBotCommand.SendSystemMessage:
69
+ postSystemMessageActivity(this.activityObserver, "Contoso has joined the chat.");
70
+ break;
71
+ case activity.text === MockBotCommand.SendTyping:
72
+ postBotTypingActivity(this.activityObserver);
73
+ break;
74
+ case activity.text === MockBotCommand.SendAttachment:
75
+ postBotAttachmentActivity(this.activityObserver, [createJpgFileAttachment()]);
76
+ break;
77
+ case activity.text === MockBotCommand.SendBotMessage:
78
+ postBotMessageActivity(this.activityObserver, "Hi, how can I help you?");
79
+ break;
80
+ case activity.text === `${MockBotCommand.Card} ${MockBotCardCommandType.Signin}`:
81
+ postBotAttachmentActivity(this.activityObserver, [createSigninCardAttachment()]);
82
+ break;
83
+ case activity.text === `${MockBotCommand.Card} ${MockBotCardCommandType.Hero}`:
84
+ postBotAttachmentActivity(this.activityObserver, [createHeroCardAttachment()]);
85
+ break;
86
+ case activity.text === `${MockBotCommand.Card} ${MockBotCardCommandType.Thumbnail}`:
87
+ postBotAttachmentActivity(this.activityObserver, [createThumbnailCardAttachment()]);
88
+ break;
89
+ case activity.text.startsWith(`${MockBotCommand.Bot} `):
90
+ postBotMessageActivity(this.activityObserver, activity.text.substring(5));
91
+ break;
92
+ case activity.text.startsWith(`${MockBotCommand.System} `):
93
+ postSystemMessageActivity(this.activityObserver, activity.text.substring(8));
94
+ break;
95
+ }
74
96
  }
75
97
  }
98
+ return Observable.of(activity.id || "");
76
99
  }
77
- return Observable.of(activity.id || "");
78
- }
79
- }
100
+ }]);
101
+ return DemoChatAdapter;
102
+ }(MockAdapter);
@@ -1,10 +1,29 @@
1
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
3
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
4
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
5
+ 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); }
6
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
7
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
8
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
9
+ function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
10
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
11
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
12
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
1
13
  import { DemoChatAdapter } from "./DemoChatAdapter";
2
14
  import { MockChatSDK } from "./mockchatsdk";
3
- export class DemoChatSDK extends MockChatSDK {
4
- constructor() {
5
- super();
15
+ export let DemoChatSDK = /*#__PURE__*/function (_MockChatSDK) {
16
+ _inherits(DemoChatSDK, _MockChatSDK);
17
+ var _super = _createSuper(DemoChatSDK);
18
+ function DemoChatSDK() {
19
+ _classCallCheck(this, DemoChatSDK);
20
+ return _super.call(this);
6
21
  }
7
- createChatAdapter() {
8
- return new DemoChatAdapter();
9
- }
10
- }
22
+ _createClass(DemoChatSDK, [{
23
+ key: "createChatAdapter",
24
+ value: function createChatAdapter() {
25
+ return new DemoChatAdapter();
26
+ }
27
+ }]);
28
+ return DemoChatSDK;
29
+ }(MockChatSDK);
@@ -1,33 +1,56 @@
1
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
3
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
4
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
5
+ 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); }
6
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
7
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
8
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
9
+ function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
10
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
11
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
12
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
1
13
  import { Observable } from "rxjs/Observable";
2
14
  import MockAdapter from "./mockadapter";
3
15
  import { customerUser, postBotMessageActivity, postEchoActivity, postSystemMessageActivity } from "./utils/chatAdapterUtils";
4
- export class DesignerChatAdapter extends MockAdapter {
5
- constructor() {
6
- super();
16
+ export let DesignerChatAdapter = /*#__PURE__*/function (_MockAdapter) {
17
+ _inherits(DesignerChatAdapter, _MockAdapter);
18
+ var _super = _createSuper(DesignerChatAdapter);
19
+ function DesignerChatAdapter() {
20
+ var _this;
21
+ _classCallCheck(this, DesignerChatAdapter);
22
+ _this = _super.call(this);
7
23
  setTimeout(() => {
8
- postBotMessageActivity(this.activityObserver, "Thank you for contacting us! How can I help you today?", undefined, 0);
9
- this.postUserActivity("I need to change my address.", 0);
10
- postBotMessageActivity(this.activityObserver, "Okay, let me connect you with a live agent.", undefined, 100);
11
- postSystemMessageActivity(this.activityObserver, "John has joined the chat", 100);
12
- postBotMessageActivity(this.activityObserver, "I'd be happy to help you update your account.", undefined, 100);
24
+ postBotMessageActivity(_this.activityObserver, "Thank you for contacting us! How can I help you today?", undefined, 0);
25
+ _this.postUserActivity("I need to change my address.", 0);
26
+ postBotMessageActivity(_this.activityObserver, "Okay, let me connect you with a live agent.", undefined, 100);
27
+ postSystemMessageActivity(_this.activityObserver, "John has joined the chat", 100);
28
+ postBotMessageActivity(_this.activityObserver, "I'd be happy to help you update your account.", undefined, 100);
13
29
  }, 1000);
30
+ return _this;
14
31
  }
15
- postUserActivity(text) {
16
- let delay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1000;
17
- setTimeout(() => {
18
- postEchoActivity(this.activityObserver, {
19
- text,
20
- from: {
21
- ...customerUser
22
- },
23
- type: "message"
24
- }, customerUser, 0);
25
- }, delay);
26
- }
27
- postActivity(activity) {
28
- if (activity) {
29
- postEchoActivity(this.activityObserver, activity, customerUser);
32
+ _createClass(DesignerChatAdapter, [{
33
+ key: "postUserActivity",
34
+ value: function postUserActivity(text) {
35
+ let delay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1000;
36
+ setTimeout(() => {
37
+ postEchoActivity(this.activityObserver, {
38
+ text,
39
+ from: {
40
+ ...customerUser
41
+ },
42
+ type: "message"
43
+ }, customerUser, 0);
44
+ }, delay);
30
45
  }
31
- return Observable.of(activity.id || "");
32
- }
33
- }
46
+ }, {
47
+ key: "postActivity",
48
+ value: function postActivity(activity) {
49
+ if (activity) {
50
+ postEchoActivity(this.activityObserver, activity, customerUser);
51
+ }
52
+ return Observable.of(activity.id || "");
53
+ }
54
+ }]);
55
+ return DesignerChatAdapter;
56
+ }(MockAdapter);