@microsoft/omnichannel-chat-widget 1.8.2-main.fc93d3d → 1.8.3-main.1381896

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 (126) hide show
  1. package/README.md +46 -1
  2. package/lib/cjs/common/Constants.js +10 -2
  3. package/lib/cjs/common/telemetry/TelemetryConstants.js +6 -0
  4. package/lib/cjs/common/telemetry/TelemetryHelper.js +7 -5
  5. package/lib/cjs/common/utils.js +27 -2
  6. package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +4 -4
  7. package/lib/cjs/components/citationpanestateful/CitationDim.js +29 -0
  8. package/lib/cjs/components/citationpanestateful/CitationPaneStateful.js +199 -0
  9. package/lib/cjs/components/citationpanestateful/common/defaultProps/defaultCitationPaneProps.js +70 -0
  10. package/lib/cjs/components/confirmationpanestateful/interfaces/IConfirmationPaneLocalizedTexts.js +1 -0
  11. package/lib/cjs/components/livechatwidget/LiveChatWidget.js +4 -4
  12. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +4 -5
  13. package/lib/cjs/components/livechatwidget/common/createInternetConnectionChangeHandler.js +22 -9
  14. package/lib/cjs/components/livechatwidget/common/createMarkdown.js +54 -1
  15. package/lib/cjs/components/livechatwidget/common/customEventHandler.js +53 -0
  16. package/lib/cjs/components/livechatwidget/common/endChat.js +34 -4
  17. package/lib/cjs/components/livechatwidget/common/getMockChatSDKIfApplicable.js +4 -3
  18. package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +12 -5
  19. package/lib/cjs/components/livechatwidget/common/overridePropsOnMockIfApplicable.js +2 -1
  20. package/lib/cjs/components/livechatwidget/common/renderSurveyHelpers.js +23 -0
  21. package/lib/cjs/components/livechatwidget/common/startChat.js +8 -6
  22. package/lib/cjs/components/livechatwidget/interfaces/IMockProps.js +8 -2
  23. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +45 -11
  24. package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +114 -13
  25. package/lib/cjs/components/webchatcontainerstateful/common/DesignerChatAdapter.js +43 -12
  26. package/lib/cjs/components/webchatcontainerstateful/common/DesignerChatSDK.js +6 -1
  27. package/lib/cjs/components/webchatcontainerstateful/common/defaultStyles/defaultWebChatStyles.js +1 -1
  28. package/lib/cjs/components/webchatcontainerstateful/common/utils/chatAdapterUtils.js +62 -3
  29. package/lib/cjs/components/webchatcontainerstateful/common/utils/fontUtils.js +28 -0
  30. package/lib/cjs/components/webchatcontainerstateful/interfaces/ICitation.js +1 -0
  31. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultAvatarTextStyles.js +1 -1
  32. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageStyles.js +1 -1
  33. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/callActionMiddleware.js +42 -0
  34. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.js +139 -0
  35. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/customEventMiddleware.js +41 -0
  36. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware.js +54 -0
  37. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware.js +45 -0
  38. package/lib/cjs/contexts/common/CustomEventType.js +1 -0
  39. package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +46 -45
  40. package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +2 -0
  41. package/lib/cjs/contexts/createReducer.js +15 -0
  42. package/lib/cjs/firstresponselatency/FirstMessageTrackerFromBot.js +101 -36
  43. package/lib/cjs/firstresponselatency/FirstResponseLatencyTracker.js +39 -21
  44. package/lib/cjs/firstresponselatency/util.js +24 -10
  45. package/lib/cjs/index.js +9 -1
  46. package/lib/cjs/plugins/createChatTranscript.js +13 -0
  47. package/lib/cjs/plugins/newMessageEventHandler.js +2 -2
  48. package/lib/esm/common/Constants.js +10 -2
  49. package/lib/esm/common/telemetry/TelemetryConstants.js +6 -0
  50. package/lib/esm/common/telemetry/TelemetryHelper.js +7 -5
  51. package/lib/esm/common/utils.js +21 -0
  52. package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +4 -4
  53. package/lib/esm/components/citationpanestateful/CitationDim.js +20 -0
  54. package/lib/esm/components/citationpanestateful/CitationPaneStateful.js +188 -0
  55. package/lib/esm/components/citationpanestateful/common/defaultProps/defaultCitationPaneProps.js +61 -0
  56. package/lib/esm/components/confirmationpanestateful/interfaces/IConfirmationPaneLocalizedTexts.js +1 -0
  57. package/lib/esm/components/livechatwidget/LiveChatWidget.js +4 -4
  58. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +4 -5
  59. package/lib/esm/components/livechatwidget/common/createInternetConnectionChangeHandler.js +22 -9
  60. package/lib/esm/components/livechatwidget/common/createMarkdown.js +54 -1
  61. package/lib/esm/components/livechatwidget/common/customEventHandler.js +45 -0
  62. package/lib/esm/components/livechatwidget/common/endChat.js +35 -5
  63. package/lib/esm/components/livechatwidget/common/getMockChatSDKIfApplicable.js +4 -3
  64. package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +13 -6
  65. package/lib/esm/components/livechatwidget/common/overridePropsOnMockIfApplicable.js +2 -1
  66. package/lib/esm/components/livechatwidget/common/renderSurveyHelpers.js +23 -0
  67. package/lib/esm/components/livechatwidget/common/startChat.js +8 -6
  68. package/lib/esm/components/livechatwidget/interfaces/IMockProps.js +3 -3
  69. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +45 -11
  70. package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +114 -14
  71. package/lib/esm/components/webchatcontainerstateful/common/DesignerChatAdapter.js +43 -12
  72. package/lib/esm/components/webchatcontainerstateful/common/DesignerChatSDK.js +6 -1
  73. package/lib/esm/components/webchatcontainerstateful/common/defaultStyles/defaultWebChatStyles.js +1 -1
  74. package/lib/esm/components/webchatcontainerstateful/common/utils/chatAdapterUtils.js +55 -0
  75. package/lib/esm/components/webchatcontainerstateful/common/utils/fontUtils.js +21 -0
  76. package/lib/esm/components/webchatcontainerstateful/interfaces/ICitation.js +1 -0
  77. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultAvatarTextStyles.js +1 -1
  78. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageStyles.js +1 -1
  79. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/callActionMiddleware.js +36 -0
  80. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.js +133 -0
  81. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/customEventMiddleware.js +33 -0
  82. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware.js +46 -0
  83. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware.js +38 -0
  84. package/lib/esm/contexts/common/CustomEventType.js +1 -0
  85. package/lib/esm/contexts/common/LiveChatWidgetActionType.js +46 -45
  86. package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +2 -0
  87. package/lib/esm/contexts/createReducer.js +15 -0
  88. package/lib/esm/firstresponselatency/FirstMessageTrackerFromBot.js +101 -36
  89. package/lib/esm/firstresponselatency/FirstResponseLatencyTracker.js +39 -21
  90. package/lib/esm/firstresponselatency/util.js +21 -8
  91. package/lib/esm/index.js +1 -0
  92. package/lib/esm/plugins/createChatTranscript.js +13 -0
  93. package/lib/esm/plugins/newMessageEventHandler.js +3 -3
  94. package/lib/types/common/Constants.d.ts +10 -2
  95. package/lib/types/common/telemetry/TelemetryConstants.d.ts +6 -0
  96. package/lib/types/common/utils.d.ts +8 -0
  97. package/lib/types/components/citationpanestateful/CitationDim.d.ts +5 -0
  98. package/lib/types/components/citationpanestateful/CitationPaneStateful.d.ts +4 -0
  99. package/lib/types/components/citationpanestateful/common/defaultProps/defaultCitationPaneProps.d.ts +11 -0
  100. package/lib/types/components/citationpanestateful/interfaces/ICitationPaneStatefulProps.d.ts +19 -0
  101. package/lib/types/components/confirmationpanestateful/common/defaultProps/defaultConfirmationPaneLocalizedTexts.d.ts +1 -1
  102. package/lib/types/components/confirmationpanestateful/interfaces/IConfirmationPaneStatefulProps.d.ts +1 -1
  103. package/lib/types/components/livechatwidget/common/customEventHandler.d.ts +4 -0
  104. package/lib/types/components/livechatwidget/common/getMockChatSDKIfApplicable.d.ts +2 -1
  105. package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +3 -1
  106. package/lib/types/components/livechatwidget/interfaces/IMockProps.d.ts +5 -3
  107. package/lib/types/components/webchatcontainerstateful/common/DesignerChatAdapter.d.ts +4 -2
  108. package/lib/types/components/webchatcontainerstateful/common/DesignerChatSDK.d.ts +5 -0
  109. package/lib/types/components/webchatcontainerstateful/common/utils/chatAdapterUtils.d.ts +8 -1
  110. package/lib/types/components/webchatcontainerstateful/common/utils/fontUtils.d.ts +10 -0
  111. package/lib/types/components/webchatcontainerstateful/interfaces/ICitation.d.ts +12 -0
  112. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/callActionMiddleware.d.ts +8 -0
  113. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.d.ts +4 -0
  114. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/customEventMiddleware.d.ts +22 -0
  115. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware.d.ts +5 -0
  116. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware.d.ts +5 -0
  117. package/lib/types/contexts/common/CustomEventType.d.ts +6 -0
  118. package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +1 -0
  119. package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +46 -45
  120. package/lib/types/firstresponselatency/FirstResponseLatencyTracker.d.ts +2 -2
  121. package/lib/types/firstresponselatency/util.d.ts +1 -0
  122. package/lib/types/index.d.ts +1 -0
  123. package/package.json +5 -4
  124. /package/lib/cjs/components/{confirmationpanestateful/interfaces/IConfirmationPaneLocalizedText.js → citationpanestateful/interfaces/ICitationPaneStatefulProps.js} +0 -0
  125. /package/lib/esm/components/{confirmationpanestateful/interfaces/IConfirmationPaneLocalizedText.js → citationpanestateful/interfaces/ICitationPaneStatefulProps.js} +0 -0
  126. /package/lib/types/components/confirmationpanestateful/interfaces/{IConfirmationPaneLocalizedText.d.ts → IConfirmationPaneLocalizedTexts.d.ts} +0 -0
@@ -13,34 +13,47 @@ var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
13
13
  var _defaultMiddlewareLocalizedTexts = require("../../webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts");
14
14
  var _createReducer = require("../../../contexts/createReducer");
15
15
  var _LiveChatWidgetActionType = require("../../../contexts/common/LiveChatWidgetActionType");
16
- const isInternetConnected = async () => {
16
+ const getRegionBasedInternetTestUrl = widgetSnippet => {
17
+ var _widgetSnippet$match;
18
+ if (!widgetSnippet) {
19
+ return null;
20
+ }
21
+ const widgetSnippetSourceRegex = new RegExp("src=\"(https:\\/\\/[\\w-.]+)[\\w-.\\/]+\"");
22
+ const baseCdnUrl = (_widgetSnippet$match = widgetSnippet.match(widgetSnippetSourceRegex)) === null || _widgetSnippet$match === void 0 ? void 0 : _widgetSnippet$match[1];
23
+ return baseCdnUrl ? `${baseCdnUrl}${_Constants.Constants.internetConnectionTestPath}` : null;
24
+ };
25
+ const isInternetConnected = async testUrl => {
17
26
  try {
18
- const response = await fetch(_Constants.Constants.internetConnectionTestUrl);
19
- const text = await response.text();
20
- return text === _Constants.Constants.internetConnectionTestUrlText;
27
+ const response = await fetch(testUrl, {
28
+ method: "GET",
29
+ cache: "no-cache"
30
+ });
31
+ return response.ok;
21
32
  } catch {
22
33
  return false;
23
34
  }
24
35
  };
25
36
  const createInternetConnectionChangeHandler = async state => {
26
37
  const handler = async () => {
27
- const connected = await isInternetConnected();
38
+ var _inMemoryState$domain, _inMemoryState$domain2;
28
39
  const inMemoryState = (0, _createReducer.executeReducer)(state, {
29
40
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
30
41
  payload: null
31
42
  });
43
+ const testUrl = getRegionBasedInternetTestUrl((_inMemoryState$domain = inMemoryState.domainStates.liveChatConfig) === null || _inMemoryState$domain === void 0 ? void 0 : (_inMemoryState$domain2 = _inMemoryState$domain.LiveWSAndLiveChatEngJoin) === null || _inMemoryState$domain2 === void 0 ? void 0 : _inMemoryState$domain2.msdyn_widgetsnippet);
44
+ const connected = testUrl ? await isInternetConnected(testUrl) : false;
32
45
  if (!connected) {
33
- var _inMemoryState$domain, _inMemoryState$domain2;
46
+ var _inMemoryState$domain3, _inMemoryState$domain4;
34
47
  _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.WARN, {
35
48
  Event: _TelemetryConstants.TelemetryEvent.NetworkDisconnected
36
49
  });
37
- _NotificationHandler.NotificationHandler.notifyError(_NotificationScenarios.NotificationScenarios.InternetConnection, (inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$domain = inMemoryState.domainStates) === null || _inMemoryState$domain === void 0 ? void 0 : (_inMemoryState$domain2 = _inMemoryState$domain.middlewareLocalizedTexts) === null || _inMemoryState$domain2 === void 0 ? void 0 : _inMemoryState$domain2.MIDDLEWARE_BANNER_NO_INTERNET_CONNECTION) ?? _defaultMiddlewareLocalizedTexts.defaultMiddlewareLocalizedTexts.MIDDLEWARE_BANNER_NO_INTERNET_CONNECTION);
50
+ _NotificationHandler.NotificationHandler.notifyError(_NotificationScenarios.NotificationScenarios.InternetConnection, (inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$domain3 = inMemoryState.domainStates) === null || _inMemoryState$domain3 === void 0 ? void 0 : (_inMemoryState$domain4 = _inMemoryState$domain3.middlewareLocalizedTexts) === null || _inMemoryState$domain4 === void 0 ? void 0 : _inMemoryState$domain4.MIDDLEWARE_BANNER_NO_INTERNET_CONNECTION) ?? _defaultMiddlewareLocalizedTexts.defaultMiddlewareLocalizedTexts.MIDDLEWARE_BANNER_NO_INTERNET_CONNECTION);
38
51
  } else {
39
- var _inMemoryState$domain3, _inMemoryState$domain4;
52
+ var _inMemoryState$domain5, _inMemoryState$domain6;
40
53
  _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.WARN, {
41
54
  Event: _TelemetryConstants.TelemetryEvent.NetworkReconnected
42
55
  });
43
- _NotificationHandler.NotificationHandler.notifySuccess(_NotificationScenarios.NotificationScenarios.InternetConnection, (inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$domain3 = inMemoryState.domainStates) === null || _inMemoryState$domain3 === void 0 ? void 0 : (_inMemoryState$domain4 = _inMemoryState$domain3.middlewareLocalizedTexts) === null || _inMemoryState$domain4 === void 0 ? void 0 : _inMemoryState$domain4.MIDDLEWARE_BANNER_INTERNET_BACK_ONLINE) ?? _defaultMiddlewareLocalizedTexts.defaultMiddlewareLocalizedTexts.MIDDLEWARE_BANNER_INTERNET_BACK_ONLINE);
56
+ _NotificationHandler.NotificationHandler.notifySuccess(_NotificationScenarios.NotificationScenarios.InternetConnection, (inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$domain5 = inMemoryState.domainStates) === null || _inMemoryState$domain5 === void 0 ? void 0 : (_inMemoryState$domain6 = _inMemoryState$domain5.middlewareLocalizedTexts) === null || _inMemoryState$domain6 === void 0 ? void 0 : _inMemoryState$domain6.MIDDLEWARE_BANNER_INTERNET_BACK_ONLINE) ?? _defaultMiddlewareLocalizedTexts.defaultMiddlewareLocalizedTexts.MIDDLEWARE_BANNER_INTERNET_BACK_ONLINE);
44
57
  _omnichannelChatComponents.BroadcastService.postMessage({
45
58
  eventName: _TelemetryConstants.BroadcastEvent.NetworkReconnected
46
59
  });
@@ -34,12 +34,65 @@ const createMarkdown = (disableMarkdownMessageFormatting, disableNewLineMarkdown
34
34
  // Rule to process html blocks and paragraphs
35
35
  "html_inline",
36
36
  // Rule to process html tags
37
- "newline" // Rule to proceess '\n'
37
+ "newline",
38
+ // Rule to proceess '\n'
39
+ "list" // Enable list parsing rule
38
40
  ]);
39
41
  }
40
42
 
41
43
  markdown.disable(["strikethrough"]);
42
44
 
45
+ // Custom plugin to fix numbered list continuity
46
+ markdown.use(function (md) {
47
+ const originalRender = md.render.bind(md);
48
+ const originalRenderInline = md.renderInline.bind(md);
49
+ function preprocessText(text) {
50
+ // Handle numbered lists that come with double line breaks (knowledge article format)
51
+ // This ensures proper continuous numbering instead of separate lists
52
+
53
+ let result = text;
54
+
55
+ // Only process if the text contains the double line break pattern
56
+ // But exclude simple numbered lists (where content after \n\n starts with another number)
57
+ if (!/\d+\.\s+.*?\n\n(?!\d+\.\s)[\s\S]*?(?:\n\n\d+\.|\s*$)/.test(text)) {
58
+ return result;
59
+ }
60
+
61
+ // Convert "1. Item\n\nContent\n\n2. Item" to proper markdown list format
62
+ // Use improved pattern with negative lookahead to exclude cases where content starts with numbered list
63
+ const listPattern = /(\d+\.\s+[^\n]+)(\n\n(?!\d+\.\s)[\s\S]*?)(?=\n\n\d+\.|\s*$)/g;
64
+ if (listPattern.test(result)) {
65
+ // Reset regex state for actual replacement
66
+ listPattern.lastIndex = 0;
67
+ result = result.replace(listPattern, (match, listItem, content) => {
68
+ if (!content) {
69
+ return match;
70
+ }
71
+
72
+ // Format content with proper indentation
73
+ const cleanContent = content.substring(2); // Remove leading \n\n
74
+ const lines = cleanContent.split("\n");
75
+ const indentedContent = lines.map(line => line.trim() ? `${_Constants.Constants.MARKDOWN_LIST_INDENTATION}${line}` : "").join("\n");
76
+ const lineBreak = disableNewLineMarkdownSupport ? "\n" : "\n\n";
77
+ return `${listItem}${lineBreak}${indentedContent}`;
78
+ });
79
+ }
80
+ return result;
81
+ }
82
+
83
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
84
+ md.render = function (text, env) {
85
+ const processedText = preprocessText(text);
86
+ return originalRender(processedText, env);
87
+ };
88
+
89
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
90
+ md.renderInline = function (text, env) {
91
+ const processedText = preprocessText(text);
92
+ return originalRenderInline(processedText, env);
93
+ };
94
+ });
95
+
43
96
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
44
97
  markdown.use(_markdownItForInline.default, "url_new_win", "link_open", function (tokens, idx, env) {
45
98
  const targetAttrIndex = tokens[idx].attrIndex(_Constants.Constants.Target);
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.subscribeToSendCustomEvent = exports.customEventCallback = void 0;
7
+ var _Constants = require("../../../common/Constants");
8
+ var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
9
+ var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants");
10
+ var _utils = require("../../../common/utils");
11
+ const customEventCallback = facadeChatSDK => event => {
12
+ if (!(_Constants.Constants.payload in event)) return;
13
+ if ((0, _utils.isValidCustomEvent)(event.payload)) {
14
+ const customEventPayload = event.payload;
15
+ try {
16
+ const customEventValueStr = (0, _utils.getCustomEventValue)(customEventPayload);
17
+ const customEventName = customEventPayload.customEventName;
18
+ const messageMeta = {
19
+ customEvent: _Constants.Constants.true,
20
+ customEventName: customEventName,
21
+ customEventValue: customEventValueStr
22
+ };
23
+ const messagePayload = {
24
+ content: "",
25
+ tags: [_Constants.Constants.Hidden],
26
+ metadata: messageMeta,
27
+ timestamp: new Date()
28
+ };
29
+ facadeChatSDK.sendMessage(messagePayload);
30
+ _TelemetryHelper.TelemetryHelper.logActionEventToAllTelemetry(_TelemetryConstants.LogLevel.DEBUG, {
31
+ Event: _TelemetryConstants.TelemetryEvent.CustomEventAction,
32
+ Description: "Sent customEvent.",
33
+ CustomProperties: {
34
+ customEventName,
35
+ lengthCustomEventValue: customEventValueStr.length
36
+ }
37
+ });
38
+ } catch (error) {
39
+ _TelemetryHelper.TelemetryHelper.logActionEventToAllTelemetry(_TelemetryConstants.LogLevel.ERROR, {
40
+ Event: _TelemetryConstants.TelemetryEvent.CustomEventAction,
41
+ Description: "Failed to process CustomEvent.",
42
+ ExceptionDetails: {
43
+ error
44
+ }
45
+ });
46
+ }
47
+ }
48
+ };
49
+ exports.customEventCallback = customEventCallback;
50
+ const subscribeToSendCustomEvent = (broadcastService, facadeChatSDK, customEventCallback) => {
51
+ broadcastService.getMessageByEventName(_Constants.Constants.sendCustomEvent).subscribe(customEventCallback(facadeChatSDK));
52
+ };
53
+ exports.subscribeToSendCustomEvent = subscribeToSendCustomEvent;
@@ -40,10 +40,11 @@ const prepareEndChat = async (props, facadeChatSDK, state, dispatch, setAdapter,
40
40
  Description: _Constants.PrepareEndChatDescriptionConstants.ConversationEndedByCustomerWithoutPostChat
41
41
  });
42
42
  await endChat(props, facadeChatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, true);
43
+ return;
43
44
  }
44
45
 
45
46
  // Use Case: If ended by Agent, stay chat in InActive state
46
- let isConversationalSurveyEnabled = state.appStates.isConversationalSurveyEnabled;
47
+ const isConversationalSurveyEnabled = state.appStates.isConversationalSurveyEnabled;
47
48
  if (isConversationalSurveyEnabled && ((state === null || state === void 0 ? void 0 : (_state$appStates2 = state.appStates) === null || _state$appStates2 === void 0 ? void 0 : _state$appStates2.conversationEndedBy) === _Constants.ConversationEndEntity.Agent || (state === null || state === void 0 ? void 0 : (_state$appStates3 = state.appStates) === null || _state$appStates3 === void 0 ? void 0 : _state$appStates3.conversationEndedBy) === _Constants.ConversationEndEntity.Bot)) {
48
49
  dispatch({
49
50
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
@@ -152,8 +153,23 @@ const endChat = async (props, facadeChatSDK, state, dispatch, setAdapter, setWeb
152
153
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
153
154
  payload: null
154
155
  });
156
+ let isSessionEnded = inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$appSta = inMemoryState.appStates) === null || _inMemoryState$appSta === void 0 ? void 0 : _inMemoryState$appSta.chatDisconnectEventReceived;
157
+ if (!isSessionEnded) {
158
+ // double check by fetching the latest conversation details
159
+ const conversationDetails = await (0, _utils.getConversationDetailsCall)(facadeChatSDK);
160
+ if ((conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.state) === _Constants.LiveWorkItemState.WrapUp || (conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.state) === _Constants.LiveWorkItemState.Closed) {
161
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
162
+ Event: _TelemetryConstants.TelemetryEvent.ChatDisconnectThreadEventReceived,
163
+ Description: "Checking conversation details upon endChat. Chat disconnected.",
164
+ CustomProperties: {
165
+ conversationDetails
166
+ }
167
+ });
168
+ isSessionEnded = true;
169
+ }
170
+ }
155
171
  const endChatOptionalParameters = {
156
- isSessionEnded: inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$appSta = inMemoryState.appStates) === null || _inMemoryState$appSta === void 0 ? void 0 : _inMemoryState$appSta.chatDisconnectEventReceived
172
+ isSessionEnded
157
173
  };
158
174
  try {
159
175
  _TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.INFO, {
@@ -216,7 +232,7 @@ const endChat = async (props, facadeChatSDK, state, dispatch, setAdapter, setWeb
216
232
  payload: undefined
217
233
  });
218
234
  // Always allow to close the chat for embedded mode irrespective of end chat errors
219
- closeChatWidget(dispatch);
235
+ closeChatWidget(dispatch, setWebChatStyles, props);
220
236
  facadeChatSDK.destroy();
221
237
  }
222
238
  }
@@ -304,6 +320,10 @@ const closeChatStateCleanUp = dispatch => {
304
320
  proactiveChatInNewWindow: false
305
321
  }
306
322
  });
323
+ dispatch({
324
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CITATIONS,
325
+ payload: {}
326
+ });
307
327
 
308
328
  // Clear live chat context only if chat widget is fully closed to support transcript calls after sessionclose is called
309
329
  dispatch({
@@ -349,13 +369,23 @@ const endVoiceVideoCallIfOngoing = async (facadeChatSDK, dispatch) => {
349
369
  }, callId);
350
370
  }
351
371
  };
372
+
373
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
352
374
  exports.endVoiceVideoCallIfOngoing = endVoiceVideoCallIfOngoing;
353
- const closeChatWidget = dispatch => {
375
+ const closeChatWidget = (dispatch, setWebChatStyles, props) => {
376
+ var _props$webChatContain2, _props$webChatContain3;
354
377
  // Embedded chat
355
378
  dispatch({
356
379
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
357
380
  payload: _ConversationState.ConversationState.Closed
358
381
  });
382
+
383
+ // if customer is setting the hideSendbox, we should not alter its value
384
+ if ((props === null || props === void 0 ? void 0 : (_props$webChatContain2 = props.webChatContainerProps) === null || _props$webChatContain2 === void 0 ? void 0 : (_props$webChatContain3 = _props$webChatContain2.webChatStyles) === null || _props$webChatContain3 === void 0 ? void 0 : _props$webChatContain3.hideSendBox) === true) return;
385
+ setWebChatStyles(styles => ({
386
+ ...styles,
387
+ hideSendBox: false
388
+ }));
359
389
  };
360
390
 
361
391
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -8,14 +8,15 @@ var _DemoChatSDK = require("../../webchatcontainerstateful/common/DemoChatSDK");
8
8
  var _DesignerChatSDK = require("../../webchatcontainerstateful/common/DesignerChatSDK");
9
9
  var _mockchatsdk = require("../../webchatcontainerstateful/common/mockchatsdk");
10
10
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
11
- const getMockChatSDKIfApplicable = (chatSDK, type) => {
12
- if (type) {
13
- switch (type.toLowerCase()) {
11
+ const getMockChatSDKIfApplicable = (chatSDK, mockProps) => {
12
+ if (mockProps !== null && mockProps !== void 0 && mockProps.type) {
13
+ switch (mockProps.type.toLowerCase()) {
14
14
  case "demo":
15
15
  chatSDK = new _DemoChatSDK.DemoChatSDK();
16
16
  break;
17
17
  case "designer":
18
18
  chatSDK = new _DesignerChatSDK.DesignerChatSDK();
19
+ chatSDK.mockMessages = mockProps === null || mockProps === void 0 ? void 0 : mockProps.mockMessages;
19
20
  break;
20
21
  default:
21
22
  chatSDK = new _mockchatsdk.MockChatSDK();
@@ -7,6 +7,8 @@ exports.initWebChatComposer = void 0;
7
7
  var _Constants = require("../../../common/Constants");
8
8
  var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants");
9
9
  var _utils = require("../../../common/utils");
10
+ var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
11
+ var _ConversationState = require("../../../contexts/common/ConversationState");
10
12
  var _dompurify = _interopRequireDefault(require("dompurify"));
11
13
  var _HyperlinkTextOverrideRenderer = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/markdownrenderers/HyperlinkTextOverrideRenderer"));
12
14
  var _LiveChatWidgetActionType = require("../../../contexts/common/LiveChatWidgetActionType");
@@ -18,31 +20,35 @@ var _activityMiddleware = require("../../webchatcontainerstateful/webchatcontrol
18
20
  var _attachmentMiddleware = require("../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware");
19
21
  var _attachmentUploadValidatorMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware"));
20
22
  var _avatarMiddleware = require("../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/avatarMiddleware");
23
+ var _callActionMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/callActionMiddleware"));
21
24
  var _cardActionMiddleware = require("../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware");
25
+ var _citationsMiddleware = require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware");
22
26
  var _conversationEndMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware"));
27
+ var _customEventMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/customEventMiddleware"));
23
28
  var _dataMaskingMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/dataMaskingMiddleware"));
24
29
  var _createMarkdown = require("./createMarkdown");
25
30
  var _maxMessageSizeValidator = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/maxMessageSizeValidator"));
26
31
  var _messageSequenceIdOverrideMiddleware = require("../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageSequenceIdOverrideMiddleware");
27
32
  var _messageTimestampMiddleware = require("../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware");
33
+ var _queueOverflowHandlerMiddleware = require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware");
28
34
  var _botframeworkWebchat = require("botframework-webchat");
29
35
  var _toastMiddleware = require("../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/toastMiddleware");
30
36
  var _WebChatLogger = require("../../webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger");
31
37
  var _defaultAttachmentProps = require("../../webchatcontainerstateful/common/defaultProps/defaultAttachmentProps");
32
38
  var _defaultMiddlewareLocalizedTexts = require("../../webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts");
33
39
  var _defaultWebChatContainerStatefulProps = require("../../webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps");
40
+ var _createReducer = require("../../../contexts/createReducer");
34
41
  var _omnichannelChatSdk = require("@microsoft/omnichannel-chat-sdk");
35
42
  var _gifUploadMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/gifUploadMiddleware"));
36
43
  var _htmlPlayerMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlPlayerMiddleware"));
37
44
  var _htmlTextMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlTextMiddleware"));
38
45
  var _preProcessingMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/preProcessingMiddleware"));
39
46
  var _sanitizationMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware"));
40
- var _ConversationState = require("../../../contexts/common/ConversationState");
41
- var _createReducer = require("../../../contexts/createReducer");
47
+ var _localizedStringsBotInitialsMiddleware = require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware");
42
48
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
43
49
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
44
50
  const initWebChatComposer = (props, state, dispatch, facadeChatSDK, endChat) => {
45
- var _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _props$webChatContain4, _props$webChatContain5, _props$webChatContain6, _state$domainStates$l4, _state$domainStates$l5, _props$webChatContain11, _props$webChatContain12, _state$domainStates$r, _state$domainStates$r2, _props$webChatContain13, _props$webChatContain14, _state$domainStates$r3, _state$domainStates$r4, _props$webChatContain15, _props$webChatContain16, _defaultWebChatContai, _props$webChatContain17, _props$webChatContain18, _props$webChatContain19, _props$webChatContain20, _state$domainStates$r5, _state$domainStates$r6, _props$webChatContain21, _props$webChatContain22, _defaultWebChatContai2, _props$webChatContain23, _props$webChatContain24, _defaultWebChatContai3, _props$webChatContain25, _props$webChatContain26;
51
+ var _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _props$webChatContain4, _props$webChatContain5, _props$webChatContain6, _state$domainStates$l4, _state$domainStates$l5, _props$webChatContain11, _props$webChatContain12, _state$domainStates$r, _state$domainStates$r2, _props$webChatContain13, _props$webChatContain14, _state$domainStates$r3, _state$domainStates$r4, _props$webChatContain15, _props$webChatContain16, _defaultWebChatContai, _props$webChatContain17, _props$webChatContain18, _props$webChatContain19, _props$webChatContain20, _state$domainStates$r5, _state$domainStates$r6, _props$webChatContain21, _props$webChatContain22, _defaultWebChatContai2, _props$webChatContain23, _props$webChatContain24, _defaultWebChatContai3, _props$webChatContain25, _props$webChatContain26, _props$webChatContain27, _props$webChatContain28;
46
52
  // Add a hook to make all links open a new window
47
53
  postDomPurifyActivities();
48
54
  const localizedTexts = {
@@ -117,7 +123,7 @@ const initWebChatComposer = (props, state, dispatch, facadeChatSDK, endChat) =>
117
123
  };
118
124
  webChatStore = (0, _botframeworkWebchat.createStore)({},
119
125
  //initial state
120
- _preProcessingMiddleware.default, _attachmentProcessingMiddleware.default, (0, _attachmentUploadValidatorMiddleware.default)((_state$domainStates$l = state.domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : _state$domainStates$l.allowedFileExtensions, (_state$domainStates$l2 = state.domainStates.liveChatConfig) === null || _state$domainStates$l2 === void 0 ? void 0 : _state$domainStates$l2.maxUploadFileSize, localizedTexts), (0, _channelDataMiddleware.default)(addConversationalSurveyTagsCallback), (0, _conversationEndMiddleware.default)(conversationEndCallback, startConversationalSurveyCallback, endConversationalSurveyCallback), (0, _dataMaskingMiddleware.default)((_state$domainStates$l3 = state.domainStates.liveChatConfig) === null || _state$domainStates$l3 === void 0 ? void 0 : _state$domainStates$l3.DataMaskingInfo), _messageTimestampMiddleware.createMessageTimeStampMiddleware, _messageSequenceIdOverrideMiddleware.createMessageSequenceIdOverrideMiddleware, _gifUploadMiddleware.default, _htmlPlayerMiddleware.default, (0, _htmlTextMiddleware.default)(honorsTargetInHTMLLinks), (0, _maxMessageSizeValidator.default)(localizedTexts), _sanitizationMiddleware.default,
126
+ _preProcessingMiddleware.default, _attachmentProcessingMiddleware.default, (0, _attachmentUploadValidatorMiddleware.default)((_state$domainStates$l = state.domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : _state$domainStates$l.allowedFileExtensions, (_state$domainStates$l2 = state.domainStates.liveChatConfig) === null || _state$domainStates$l2 === void 0 ? void 0 : _state$domainStates$l2.maxUploadFileSize, localizedTexts), (0, _customEventMiddleware.default)(_omnichannelChatComponents.BroadcastService), (0, _queueOverflowHandlerMiddleware.createQueueOverflowMiddleware)(state, dispatch), (0, _channelDataMiddleware.default)(addConversationalSurveyTagsCallback), (0, _conversationEndMiddleware.default)(conversationEndCallback, startConversationalSurveyCallback, endConversationalSurveyCallback), (0, _dataMaskingMiddleware.default)((_state$domainStates$l3 = state.domainStates.liveChatConfig) === null || _state$domainStates$l3 === void 0 ? void 0 : _state$domainStates$l3.DataMaskingInfo), _messageTimestampMiddleware.createMessageTimeStampMiddleware, _messageSequenceIdOverrideMiddleware.createMessageSequenceIdOverrideMiddleware, (0, _citationsMiddleware.createCitationsMiddleware)(state, dispatch), _gifUploadMiddleware.default, _htmlPlayerMiddleware.default, (0, _htmlTextMiddleware.default)(honorsTargetInHTMLLinks), (0, _maxMessageSizeValidator.default)(localizedTexts), _sanitizationMiddleware.default, (0, _callActionMiddleware.default)(), (0, _localizedStringsBotInitialsMiddleware.localizedStringsBotInitialsMiddleware)(),
121
127
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
122
128
  ...(((_props$webChatContain7 = props.webChatContainerProps) === null || _props$webChatContain7 === void 0 ? void 0 : _props$webChatContain7.storeMiddlewares) ?? []));
123
129
  _WebChatStoreLoader.WebChatStoreLoader.store = webChatStore;
@@ -171,7 +177,8 @@ const initWebChatComposer = (props, state, dispatch, facadeChatSDK, endChat) =>
171
177
  onTelemetry: (0, _WebChatLogger.createWebChatTelemetry)(),
172
178
  cardActionMiddleware: (0, _cardActionMiddleware.createCardActionMiddleware)(((_props$webChatContain25 = props.webChatContainerProps) === null || _props$webChatContain25 === void 0 ? void 0 : _props$webChatContain25.botMagicCode) || undefined),
173
179
  sendTypingIndicator: true,
174
- ...((_props$webChatContain26 = props.webChatContainerProps) === null || _props$webChatContain26 === void 0 ? void 0 : _props$webChatContain26.webChatProps)
180
+ overrideLocalizedStrings: (0, _localizedStringsBotInitialsMiddleware.getOverriddenLocalizedStrings)((_props$webChatContain26 = props.webChatContainerProps) === null || _props$webChatContain26 === void 0 ? void 0 : (_props$webChatContain27 = _props$webChatContain26.webChatProps) === null || _props$webChatContain27 === void 0 ? void 0 : _props$webChatContain27.overrideLocalizedStrings),
181
+ ...((_props$webChatContain28 = props.webChatContainerProps) === null || _props$webChatContain28 === void 0 ? void 0 : _props$webChatContain28.webChatProps)
175
182
  };
176
183
  return webChatProps;
177
184
  };
@@ -7,6 +7,7 @@ exports.default = void 0;
7
7
  const overridePropsOnMockIfApplicable = props => {
8
8
  var _props$mock, _props$mock2;
9
9
  if (props !== null && props !== void 0 && (_props$mock = props.mock) !== null && _props$mock !== void 0 && _props$mock.type && (props === null || props === void 0 ? void 0 : (_props$mock2 = props.mock) === null || _props$mock2 === void 0 ? void 0 : _props$mock2.type.toLowerCase()) === "designer") {
10
+ var _props$mock3, _props$mock3$mockMess;
10
11
  if (!props.webChatContainerProps) {
11
12
  props.webChatContainerProps = {};
12
13
  }
@@ -22,7 +23,7 @@ const overridePropsOnMockIfApplicable = props => {
22
23
  props.webChatContainerProps = {
23
24
  ...props.webChatContainerProps,
24
25
  webChatProps: {
25
- disabled: true,
26
+ disabled: !(props !== null && props !== void 0 && (_props$mock3 = props.mock) !== null && _props$mock3 !== void 0 && (_props$mock3$mockMess = _props$mock3.mockMessages) !== null && _props$mock3$mockMess !== void 0 && _props$mock3$mockMess.length),
26
27
  ...props.webChatContainerProps.webChatProps,
27
28
  overrideLocalizedStrings: {
28
29
  TEXT_INPUT_PLACEHOLDER: "Send a message . . .",
@@ -12,6 +12,7 @@ var _PostChatSurveyMode = require("../../postchatsurveypanestateful/enums/PostCh
12
12
  var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
13
13
  var _utils = require("../../../common/utils");
14
14
  var _liveChatConfigUtils = require("./liveChatConfigUtils");
15
+ var _createReducer = require("../../../contexts/createReducer");
15
16
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
17
  let conversationDetails = undefined;
17
18
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -64,6 +65,13 @@ const renderSurvey = async (postChatContext, state, dispatch) => {
64
65
  // Function for embed mode postchat workflow which is essentially same for both customer and agent
65
66
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
66
67
  const embedModePostChatWorkflow = async (postChatContext, state, dispatch) => {
68
+ const inMemoryState = (0, _createReducer.executeReducer)(state, {
69
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
70
+ payload: null
71
+ });
72
+ if (inMemoryState.appStates.conversationState === _ConversationState.ConversationState.Closed) {
73
+ return;
74
+ }
67
75
  _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
68
76
  Event: _TelemetryConstants.TelemetryEvent.EmbedModePostChatWorkflowStarted
69
77
  });
@@ -84,6 +92,13 @@ const embedModePostChatWorkflow = async (postChatContext, state, dispatch) => {
84
92
  payload: _ConversationState.ConversationState.PostchatLoading
85
93
  });
86
94
  await (0, _utils.addDelayInMs)(_Constants.Constants.PostChatLoadingDurationInMs);
95
+ const inMemoryState = (0, _createReducer.executeReducer)(state, {
96
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
97
+ payload: null
98
+ });
99
+ if (inMemoryState.appStates.conversationState === _ConversationState.ConversationState.Closed) {
100
+ return;
101
+ }
87
102
  dispatch({
88
103
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
89
104
  payload: _ConversationState.ConversationState.Postchat
@@ -102,6 +117,14 @@ const embedModePostChatWorkflow = async (postChatContext, state, dispatch) => {
102
117
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
103
118
  const initiatePostChat = async (props, conversationDetailsParam, state, dispatch, postchatContext) => {
104
119
  var _conversationDetails;
120
+ const inMemoryState = (0, _createReducer.executeReducer)(state, {
121
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
122
+ payload: null
123
+ });
124
+ if (inMemoryState.appStates.conversationState === _ConversationState.ConversationState.Closed) {
125
+ // If the conversation is closed, we need to reset the state
126
+ return;
127
+ }
105
128
  conversationDetails = conversationDetailsParam;
106
129
  const participantType = ((_conversationDetails = conversationDetails) === null || _conversationDetails === void 0 ? void 0 : _conversationDetails.participantType) ?? postchatContext.participantType;
107
130
  await setSurveyMode(props, participantType, state, dispatch);
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.setPreChatAndInitiateChat = exports.prepareStartChat = exports.initStartChat = exports.checkIfConversationStillValid = void 0;
7
7
  var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants");
8
8
  var _Constants = require("../../../common/Constants");
9
+ var _TelemetryManager = require("../../../common/telemetry/TelemetryManager");
9
10
  var _utils = require("../../../common/utils");
10
11
  var _reconnectChatHelper = require("./reconnectChatHelper");
11
12
  var _startChatErrorHandler = require("./startChatErrorHandler");
@@ -14,7 +15,6 @@ var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components
14
15
  var _ConversationState = require("../../../contexts/common/ConversationState");
15
16
  var _LiveChatWidgetActionType = require("../../../contexts/common/LiveChatWidgetActionType");
16
17
  var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
17
- var _TelemetryManager = require("../../../common/telemetry/TelemetryManager");
18
18
  var _endChat = require("./endChat");
19
19
  var _createAdapter = require("./createAdapter");
20
20
  var _newMessageEventHandler = require("../../../plugins/newMessageEventHandler");
@@ -105,7 +105,7 @@ const setPreChatAndInitiateChat = async (facadeChatSDK, dispatch, setAdapter, is
105
105
 
106
106
  // If minimized, maximize the chat, if the state is missing, consider it as minimized
107
107
  if ((state === null || state === void 0 ? void 0 : state.appStates.isMinimized) === undefined || (state === null || state === void 0 ? void 0 : (_state$appStates = state.appStates) === null || _state$appStates === void 0 ? void 0 : _state$appStates.isMinimized) === true) {
108
- var _state$domainStates3, _state$domainStates3$, _state$domainStates4, _state$domainStates4$;
108
+ var _state$domainStates3, _state$domainStates3$, _state$domainStates4, _state$domainStates4$, _TelemetryManager$Int;
109
109
  dispatch({
110
110
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_MINIMIZED,
111
111
  payload: false
@@ -116,7 +116,8 @@ const setPreChatAndInitiateChat = async (facadeChatSDK, dispatch, setAdapter, is
116
116
  eventName: _TelemetryConstants.BroadcastEvent.MaximizeChat,
117
117
  payload: {
118
118
  height: state === null || state === void 0 ? void 0 : (_state$domainStates3 = state.domainStates) === null || _state$domainStates3 === void 0 ? void 0 : (_state$domainStates3$ = _state$domainStates3.widgetSize) === null || _state$domainStates3$ === void 0 ? void 0 : _state$domainStates3$.height,
119
- width: state === null || state === void 0 ? void 0 : (_state$domainStates4 = state.domainStates) === null || _state$domainStates4 === void 0 ? void 0 : (_state$domainStates4$ = _state$domainStates4.widgetSize) === null || _state$domainStates4$ === void 0 ? void 0 : _state$domainStates4$.width
119
+ width: state === null || state === void 0 ? void 0 : (_state$domainStates4 = state.domainStates) === null || _state$domainStates4 === void 0 ? void 0 : (_state$domainStates4$ = _state$domainStates4.widgetSize) === null || _state$domainStates4$ === void 0 ? void 0 : _state$domainStates4$.width,
120
+ runtimeId: _TelemetryManager.TelemetryManager === null || _TelemetryManager.TelemetryManager === void 0 ? void 0 : (_TelemetryManager$Int = _TelemetryManager.TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int === void 0 ? void 0 : _TelemetryManager$Int.lcwRuntimeId
120
121
  }
121
122
  });
122
123
  }
@@ -137,7 +138,7 @@ const setPreChatAndInitiateChat = async (facadeChatSDK, dispatch, setAdapter, is
137
138
  * This is because a new change to control OOH as closed event when a widget is coming from chat.
138
139
  */
139
140
  if ((state === null || state === void 0 ? void 0 : state.appStates.isMinimized) === undefined || (state === null || state === void 0 ? void 0 : (_state$appStates2 = state.appStates) === null || _state$appStates2 === void 0 ? void 0 : _state$appStates2.isMinimized) === true) {
140
- var _state$domainStates5, _state$domainStates5$, _state$domainStates6, _state$domainStates6$;
141
+ var _state$domainStates5, _state$domainStates5$, _state$domainStates6, _state$domainStates6$, _TelemetryManager$Int2;
141
142
  dispatch({
142
143
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_MINIMIZED,
143
144
  payload: false
@@ -147,14 +148,14 @@ const setPreChatAndInitiateChat = async (facadeChatSDK, dispatch, setAdapter, is
147
148
  eventName: _TelemetryConstants.BroadcastEvent.MaximizeChat,
148
149
  payload: {
149
150
  height: state === null || state === void 0 ? void 0 : (_state$domainStates5 = state.domainStates) === null || _state$domainStates5 === void 0 ? void 0 : (_state$domainStates5$ = _state$domainStates5.widgetSize) === null || _state$domainStates5$ === void 0 ? void 0 : _state$domainStates5$.height,
150
- width: state === null || state === void 0 ? void 0 : (_state$domainStates6 = state.domainStates) === null || _state$domainStates6 === void 0 ? void 0 : (_state$domainStates6$ = _state$domainStates6.widgetSize) === null || _state$domainStates6$ === void 0 ? void 0 : _state$domainStates6$.width
151
+ width: state === null || state === void 0 ? void 0 : (_state$domainStates6 = state.domainStates) === null || _state$domainStates6 === void 0 ? void 0 : (_state$domainStates6$ = _state$domainStates6.widgetSize) === null || _state$domainStates6$ === void 0 ? void 0 : _state$domainStates6$.width,
152
+ runtimeId: _TelemetryManager.TelemetryManager === null || _TelemetryManager.TelemetryManager === void 0 ? void 0 : (_TelemetryManager$Int2 = _TelemetryManager.TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int2 === void 0 ? void 0 : _TelemetryManager$Int2.lcwRuntimeId
151
153
  }
152
154
  });
153
155
  }
154
156
  const optionalParams = {
155
157
  isProactiveChat
156
158
  };
157
- (0, _FirstMessageTrackerFromBot.createTrackingForFirstMessage)();
158
159
  await initStartChat(facadeChatSDK, dispatch, setAdapter, state, props, optionalParams);
159
160
  };
160
161
 
@@ -206,6 +207,7 @@ const initStartChat = async (facadeChatSDK, dispatch, setAdapter, state, props,
206
207
  const startChatOptionalParams = Object.assign({}, params, optionalParams, defaultOptionalParams);
207
208
  // startTime is used to determine if a message is history or new, better to be set before creating the adapter to get bandwidth
208
209
  const startTime = new Date().getTime();
210
+ (0, _FirstMessageTrackerFromBot.createTrackingForFirstMessage)();
209
211
  await facadeChatSDK.startChat(startChatOptionalParams);
210
212
  isStartChatSuccessful = true;
211
213
  await createAdapterAndSubscribe(facadeChatSDK, dispatch, setAdapter, startTime, props);
@@ -1,7 +1,13 @@
1
1
  "use strict";
2
2
 
3
- var LiveChatWidgetMockType;
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.LiveChatWidgetMockType = void 0;
7
+ let LiveChatWidgetMockType;
8
+ exports.LiveChatWidgetMockType = LiveChatWidgetMockType;
4
9
  (function (LiveChatWidgetMockType) {
5
10
  LiveChatWidgetMockType["Test"] = "Test";
6
11
  LiveChatWidgetMockType["Demo"] = "Demo";
7
- })(LiveChatWidgetMockType || (LiveChatWidgetMockType = {}));
12
+ LiveChatWidgetMockType["Designer"] = "Designer";
13
+ })(LiveChatWidgetMockType || (exports.LiveChatWidgetMockType = LiveChatWidgetMockType = {}));