@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
@@ -1,8 +1,6 @@
1
1
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2
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
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
4
  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
5
  function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
8
6
  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); }; }
@@ -10,26 +8,59 @@ function _possibleConstructorReturn(self, call) { if (call && (typeof call === "
10
8
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
11
9
  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
10
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
13
- import { Observable } from "rxjs/Observable";
11
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
12
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
13
+ 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); }
14
+ import { customerUser, postAgentAttachmentActivity, postAgentMessageActivity, postAgentSuggestedActionsActivity, postBotMessageActivity, postEchoActivity, postSystemMessageActivity } from "./utils/chatAdapterUtils";
14
15
  import MockAdapter from "./mockadapter";
15
- import { customerUser, postBotMessageActivity, postEchoActivity, postSystemMessageActivity } from "./utils/chatAdapterUtils";
16
+ import { Observable } from "rxjs/Observable";
16
17
  export let DesignerChatAdapter = /*#__PURE__*/function (_MockAdapter) {
17
18
  _inherits(DesignerChatAdapter, _MockAdapter);
18
19
  var _super = _createSuper(DesignerChatAdapter);
19
- function DesignerChatAdapter() {
20
+ function DesignerChatAdapter(messages) {
20
21
  var _this;
21
22
  _classCallCheck(this, DesignerChatAdapter);
22
23
  _this = _super.call(this);
23
- setTimeout(() => {
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);
29
- }, 1000);
24
+ _defineProperty(_assertThisInitialized(_this), "messages", void 0);
25
+ _this.messages = messages;
26
+ if (_this.messages) {
27
+ if (_this.messages.length > 0) {
28
+ setTimeout(() => {
29
+ var _this$messages;
30
+ (_this$messages = _this.messages) === null || _this$messages === void 0 ? void 0 : _this$messages.forEach((msg, index) => {
31
+ _this.processMessage(msg, index);
32
+ });
33
+ }, 1000); // Initial 1 second delay to ensure activityObserver is ready
34
+ }
35
+ } else {
36
+ // Default hardcoded flow
37
+ setTimeout(() => {
38
+ postBotMessageActivity(_this.activityObserver, "Thank you for contacting us! How can I help you today?", undefined, 0);
39
+ postBotMessageActivity(_this.activityObserver, "Please accept terms and conditions to proceed. Visit the link for terms and conditions <a href=\"\">here</a>.", undefined, 0);
40
+ _this.postUserActivity("I need to change my address.", 0);
41
+ postBotMessageActivity(_this.activityObserver, "Okay, let me connect you with a live agent.", undefined, 100);
42
+ postSystemMessageActivity(_this.activityObserver, "John has joined the chat", 100);
43
+ postAgentMessageActivity(_this.activityObserver, "I'd be happy to help you update your account.", undefined, 100);
44
+ _this.postUserActivity("I have trouble visiting the signin page <a href=\"\">signin</a>.", 0);
45
+ }, 1000);
46
+ }
30
47
  return _this;
31
48
  }
32
49
  _createClass(DesignerChatAdapter, [{
50
+ key: "processMessage",
51
+ value: function processMessage(msg, index) {
52
+ if (msg.text) {
53
+ if (msg.suggestedActions) {
54
+ postAgentSuggestedActionsActivity(this.activityObserver, msg.text, msg.suggestedActions, index * 100);
55
+ } else {
56
+ postBotMessageActivity(this.activityObserver, msg.text, undefined, index * 100);
57
+ }
58
+ }
59
+ if (msg.attachments && msg.attachments.length > 0) {
60
+ postAgentAttachmentActivity(this.activityObserver, msg.attachments, index * 100, msg.attachmentLayout);
61
+ }
62
+ }
63
+ }, {
33
64
  key: "postUserActivity",
34
65
  value: function postUserActivity(text) {
35
66
  let delay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1000;
@@ -20,13 +20,18 @@ export let DesignerChatSDK = /*#__PURE__*/function (_MockChatSDK) {
20
20
  var _this;
21
21
  _classCallCheck(this, DesignerChatSDK);
22
22
  _this = _super.call(this);
23
+ /**
24
+ * Create a chat adapter for the designer. Uses this.mockMessages if set.
25
+ */
26
+ _defineProperty(_assertThisInitialized(_this), "mockMessages", void 0);
23
27
  _defineProperty(_assertThisInitialized(_this), "localeId", _this.getLiveChatConfig().ChatWidgetLanguage.msdyn_localeid);
24
28
  return _this;
25
29
  }
26
30
  _createClass(DesignerChatSDK, [{
27
31
  key: "createChatAdapter",
28
32
  value: function createChatAdapter() {
29
- return new DesignerChatAdapter();
33
+ const adapter = new DesignerChatAdapter(this.mockMessages);
34
+ return adapter;
30
35
  }
31
36
  }, {
32
37
  key: "getLiveChatConfig",
@@ -17,7 +17,7 @@ export const defaultWebChatStyles = {
17
17
  bubbleTextColor: "White",
18
18
  hideSendBox: false,
19
19
  hideUploadButton: true,
20
- primaryFont: "Segoe UI, Arial, sans-serif",
20
+ primaryFont: "Segoe UI, Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Noto Color Emoji\"",
21
21
  rootHeight: "100%",
22
22
  rootWidth: "100%",
23
23
  sendBoxTextWrap: true,
@@ -9,6 +9,11 @@ export const botUser = {
9
9
  name: "Bot",
10
10
  role: "bot"
11
11
  };
12
+ export const agentUser = {
13
+ id: "AgentId",
14
+ name: "John",
15
+ role: "bot"
16
+ };
12
17
 
13
18
  // WebChat expects an "echo" activity to confirm the message has been sent successfully
14
19
  export const postEchoActivity = function (activityObserver, activity, user) {
@@ -44,6 +49,24 @@ export const postBotMessageActivity = function (activityObserver, text) {
44
49
  });
45
50
  }, delay);
46
51
  };
52
+ export const postAgentMessageActivity = function (activityObserver, text) {
53
+ let tags = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "";
54
+ let delay = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1000;
55
+ setTimeout(() => {
56
+ activityObserver === null || activityObserver === void 0 ? void 0 : activityObserver.next({
57
+ id: uuidv4(),
58
+ from: {
59
+ ...agentUser
60
+ },
61
+ text,
62
+ type: "message",
63
+ channelData: {
64
+ tags
65
+ },
66
+ timestamp: new Date().toISOString()
67
+ });
68
+ }, delay);
69
+ };
47
70
  export const postSystemMessageActivity = function (activityObserver, text) {
48
71
  let delay = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1000;
49
72
  postBotMessageActivity(activityObserver, text, "system", delay);
@@ -74,4 +97,36 @@ export const postBotAttachmentActivity = function (activityObserver) {
74
97
  timestamp: new Date().toISOString()
75
98
  });
76
99
  }, delay);
100
+ };
101
+ export const postAgentAttachmentActivity = function (activityObserver) {
102
+ let attachments = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
103
+ let delay = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1000;
104
+ let attachmentLayout = arguments.length > 3 ? arguments[3] : undefined;
105
+ setTimeout(() => {
106
+ activityObserver === null || activityObserver === void 0 ? void 0 : activityObserver.next({
107
+ id: uuidv4(),
108
+ from: {
109
+ ...agentUser
110
+ },
111
+ attachments,
112
+ attachmentLayout,
113
+ type: "message",
114
+ timestamp: new Date().toISOString()
115
+ });
116
+ }, delay);
117
+ };
118
+ export const postAgentSuggestedActionsActivity = function (activityObserver, text, suggestedActions) {
119
+ let delay = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1000;
120
+ setTimeout(() => {
121
+ activityObserver === null || activityObserver === void 0 ? void 0 : activityObserver.next({
122
+ id: uuidv4(),
123
+ from: {
124
+ ...agentUser
125
+ },
126
+ text,
127
+ type: "message",
128
+ suggestedActions,
129
+ timestamp: new Date().toISOString()
130
+ });
131
+ }, delay);
77
132
  };
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Utility functions for font handling and emoji support
3
+ */
4
+
5
+ /**
6
+ * Creates a font family optimized for iOS emoji support
7
+ * Uses system-ui as the primary font for better emoji rendering on iOS
8
+ * @param primaryFont - The base font family string (optional, used as fallback)
9
+ * @returns Font family string optimized for iOS emoji support
10
+ */
11
+ export const createIOSOptimizedEmojiFont = primaryFont => {
12
+ // For iOS emoji support, system-ui should be first
13
+ const baseFont = "system-ui";
14
+ const emojiSupport = "\"Apple Color Emoji\", \"Segoe UI Emoji\"";
15
+ if (!primaryFont || primaryFont.includes("system-ui") || primaryFont.includes("Apple Color Emoji")) {
16
+ return `${baseFont}, ${emojiSupport}`;
17
+ }
18
+
19
+ // Add configured font as fallback after emoji fonts
20
+ return `${baseFont}, ${emojiSupport}, ${primaryFont}`;
21
+ };
@@ -1,6 +1,6 @@
1
1
  export const defaultAvatarTextStyles = {
2
2
  margin: "0",
3
- fontFamily: "\"Segoe UI\", Arial, sans-serif",
3
+ fontFamily: "'Segoe UI', 'Apple Color Emoji', 'Noto Color Emoji', 'Segoe UI Emoji', Arial, sans-serif",
4
4
  fontWeight: 600,
5
5
  fontSize: "13px",
6
6
  lineHeight: "18px",
@@ -5,7 +5,7 @@ export const defaultSystemMessageStyles = {
5
5
  fontSize: "12px",
6
6
  borderRadius: 0,
7
7
  minHeight: "auto",
8
- fontFamily: "Segoe UI",
8
+ fontFamily: "'Segoe UI', 'Apple Color Emoji', 'Noto Color Emoji', 'Segoe UI Emoji', Arial, sans-serif",
9
9
  lineHeight: "16px",
10
10
  padding: "0px 10px 0 10px"
11
11
  };
@@ -0,0 +1,36 @@
1
+ /******
2
+ * CallActionMiddleware
3
+ *
4
+ * Intercepts custom call actions and handles tel: URL navigation
5
+ ******/
6
+
7
+ import { WebChatActionType } from "../../enums/WebChatActionType";
8
+
9
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
10
+ const createCallActionMiddleware = () => () => next => action => {
11
+ // Intercept incoming activities to modify suggested actions with call type
12
+ if (action.type === WebChatActionType.DIRECT_LINE_INCOMING_ACTIVITY) {
13
+ var _action$payload, _activity$suggestedAc;
14
+ const activity = (_action$payload = action.payload) === null || _action$payload === void 0 ? void 0 : _action$payload.activity;
15
+
16
+ // Check if activity has suggested actions with call type
17
+ if (activity !== null && activity !== void 0 && (_activity$suggestedAc = activity.suggestedActions) !== null && _activity$suggestedAc !== void 0 && _activity$suggestedAc.actions) {
18
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
19
+ activity.suggestedActions.actions = activity.suggestedActions.actions.map(suggestedAction => {
20
+ if (suggestedAction.type === "call") {
21
+ // Convert call action to openUrl with encoded tel URL scheme
22
+ const telUrl = suggestedAction.value;
23
+ const convertedAction = {
24
+ ...suggestedAction,
25
+ type: "openUrl",
26
+ value: `tel:${telUrl}`
27
+ };
28
+ return convertedAction;
29
+ }
30
+ return suggestedAction;
31
+ });
32
+ }
33
+ }
34
+ return next(action);
35
+ };
36
+ export default createCallActionMiddleware;
@@ -0,0 +1,133 @@
1
+ import { LogLevel, TelemetryEvent } from "../../../../../common/telemetry/TelemetryConstants";
2
+ import { LiveChatWidgetActionType } from "../../../../../contexts/common/LiveChatWidgetActionType";
3
+ import { TelemetryHelper } from "../../../../../common/telemetry/TelemetryHelper";
4
+ import { executeReducer } from "../../../../../contexts/createReducer";
5
+
6
+ // Middleware that extracts citation metadata from incoming ACS activities and
7
+ // updates in-memory app state with a global citation map. Also rewrites
8
+ // per-message citation labels in the activity text to use a stable,
9
+ // message-scoped prefix when the producer provides a message id.
10
+
11
+ export const createCitationsMiddleware = (state, dispatch) => () => next => action => {
12
+ var _action$payload;
13
+ if ((_action$payload = action.payload) !== null && _action$payload !== void 0 && _action$payload.activity) {
14
+ if (isApplicable(action)) {
15
+ try {
16
+ var _action$payload2, _action$payload2$acti, _gptFeedback$summariz, _gptFeedback$summariz2;
17
+ const inMemoryState = executeReducer(state, {
18
+ type: LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
19
+ payload: null
20
+ });
21
+
22
+ // Use the producer-supplied messageid as a stable per-message prefix
23
+ // when present. Do not derive a prefix from activity.id or timestamps.
24
+ const messagePrefix = ((_action$payload2 = action.payload) === null || _action$payload2 === void 0 ? void 0 : (_action$payload2$acti = _action$payload2.activity) === null || _action$payload2$acti === void 0 ? void 0 : _action$payload2$acti.messageid) ?? "";
25
+ const gptFeedback = JSON.parse(action.payload.activity.channelData.metadata["pva:gpt-feedback"]);
26
+ // Extract citation objects from the model response
27
+ const citations = (_gptFeedback$summariz = gptFeedback.summarizationOpenAIResponse) === null || _gptFeedback$summariz === void 0 ? void 0 : (_gptFeedback$summariz2 = _gptFeedback$summariz.result) === null || _gptFeedback$summariz2 === void 0 ? void 0 : _gptFeedback$summariz2.textCitations;
28
+ // Rewrite inline citation labels in activity.text to match the global map keys
29
+ const updatedText = replaceCitations(action.payload.activity.text, citations, messagePrefix);
30
+ action.payload.activity.text = updatedText;
31
+ // Build a global citation map keyed by the prefixed citation id and
32
+ // dispatch it to app state so the UI container can render citations.
33
+ try {
34
+ var _inMemoryState$domain;
35
+ const citationMap = {};
36
+ if (citations && Array.isArray(citations)) {
37
+ citations.forEach(citation => {
38
+ if (citation !== null && citation !== void 0 && citation.id) {
39
+ // Preserve the 'cite:' scheme so renderer click handling remains consistent
40
+ const idWithoutScheme = citation.id.replace(/^cite:/, "");
41
+ const prefixedId = `cite:${messagePrefix}_${idWithoutScheme}`;
42
+ citationMap[prefixedId] = citation.text || citation.title || "";
43
+ }
44
+ });
45
+ }
46
+
47
+ // Read current in-memory state to merge with existing citations
48
+ //const inMemoryState = executeReducer(state, { type: LiveChatWidgetActionType.GET_IN_MEMORY_STATE, payload: null });
49
+ const existingCitations = (inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$domain = inMemoryState.domainStates) === null || _inMemoryState$domain === void 0 ? void 0 : _inMemoryState$domain.citations) || {};
50
+ const updatedCitations = {
51
+ ...existingCitations,
52
+ ...citationMap
53
+ };
54
+ // Always dispatch to app state
55
+ dispatch({
56
+ type: LiveChatWidgetActionType.SET_CITATIONS,
57
+ payload: updatedCitations
58
+ });
59
+ } catch (innerErr) {
60
+ TelemetryHelper.logActionEvent(LogLevel.WARN, {
61
+ Event: TelemetryEvent.CitationMiddlewareFailed,
62
+ ExceptionDetails: {
63
+ ErrorData: "Error while populating citation map",
64
+ Exception: innerErr
65
+ }
66
+ });
67
+ }
68
+ } catch (error) {
69
+ TelemetryHelper.logActionEvent(LogLevel.ERROR, {
70
+ Event: TelemetryEvent.CitationMiddlewareFailed,
71
+ ExceptionDetails: {
72
+ ErrorData: "Error while converting citation labels",
73
+ Exception: error
74
+ }
75
+ });
76
+ }
77
+ }
78
+ }
79
+ return next(action);
80
+ };
81
+ const isApplicable = action => {
82
+ var _action$payload3, _action$payload3$acti, _action$payload4, _action$payload4$acti;
83
+ if ((action === null || action === void 0 ? void 0 : (_action$payload3 = action.payload) === null || _action$payload3 === void 0 ? void 0 : (_action$payload3$acti = _action$payload3.activity) === null || _action$payload3$acti === void 0 ? void 0 : _action$payload3$acti.actionType) === "DIRECT_LINE/INCOMING_ACTIVITY" && (action === null || action === void 0 ? void 0 : (_action$payload4 = action.payload) === null || _action$payload4 === void 0 ? void 0 : (_action$payload4$acti = _action$payload4.activity) === null || _action$payload4$acti === void 0 ? void 0 : _action$payload4$acti.channelId) === "ACS_CHANNEL") {
84
+ var _action$payload5, _action$payload5$acti, _action$payload5$acti2, _action$payload5$acti3;
85
+ // Only applicable for ACS incoming activities that include pva:gpt-feedback
86
+ if (action !== null && action !== void 0 && (_action$payload5 = action.payload) !== null && _action$payload5 !== void 0 && (_action$payload5$acti = _action$payload5.activity) !== null && _action$payload5$acti !== void 0 && (_action$payload5$acti2 = _action$payload5$acti.channelData) !== null && _action$payload5$acti2 !== void 0 && (_action$payload5$acti3 = _action$payload5$acti2.metadata) !== null && _action$payload5$acti3 !== void 0 && _action$payload5$acti3["pva:gpt-feedback"]) {
87
+ return true;
88
+ }
89
+ }
90
+ return false;
91
+ };
92
+ const replaceCitations = (text, citations, messagePrefix) => {
93
+ if (!citations || !Array.isArray(citations)) {
94
+ return text;
95
+ }
96
+ try {
97
+ let updatedText = text;
98
+
99
+ // First, handle the citation reference definitions at the end (e.g., [1]: cite:1757450535119_1 "index.html")
100
+ // These should NOT be escaped as they are proper citation definitions
101
+ updatedText = updatedText.replace(/\[(\d+)\]:\s(cite:\d+)\s"([^\\"]+)"/g, (match, number, citeId) => {
102
+ // Attempt to find a citation object matching the inline cite id and
103
+ // update the displayed id/title. When a messagePrefix exists we
104
+ // rewrite the id to the prefixed form so it aligns with the
105
+ // global citation map keys.
106
+ const lookupId = citeId;
107
+ const citation = citations.find(c => c.id === lookupId);
108
+ if (citation) {
109
+ const idWithoutScheme = citeId.replace(/^cite:/, "");
110
+ const prefixed = messagePrefix ? `cite:${messagePrefix}_${idWithoutScheme}` : citeId;
111
+ return `[${number}]: ${prefixed} "${citation.title}"`;
112
+ }
113
+ return match;
114
+ });
115
+
116
+ // Second, escape inline citation references that are NOT followed by a colon
117
+ // This handles cases like "[1][2]"" in the middle of text that should be escaped for markdown
118
+ updatedText = updatedText.replace(/\[(\d+)\](?!:)/g, (match, number) => {
119
+ // Escape the brackets to prevent markdown from treating them as incomplete link syntax
120
+ return `&#91;${number}&#93;`;
121
+ });
122
+ return updatedText;
123
+ } catch (error) {
124
+ TelemetryHelper.logActionEvent(LogLevel.ERROR, {
125
+ Event: TelemetryEvent.CitationMiddlewareFailed,
126
+ ExceptionDetails: {
127
+ ErrorData: "Error while finding citations references",
128
+ Exception: error
129
+ }
130
+ });
131
+ return text;
132
+ }
133
+ };
@@ -0,0 +1,33 @@
1
+ /******
2
+ * CustomEventMiddleware
3
+ *
4
+ * This middleware is invoked when a custom event is received.
5
+ * The callback is then invoked to handle the custom event.
6
+ ******/
7
+
8
+ import { Constants } from "../../../../../common/Constants";
9
+ import { WebChatActionType } from "../../enums/WebChatActionType";
10
+ export const isValidCustomEvent = activity => {
11
+ var _activity$channelData, _activity$channelData2, _activity$channelData3, _activity$channelData4, _activity$channelData5, _activity$channelData6, _activity$channelData7, _activity$from, _activity$channelData8, _activity$channelData9, _activity$channelData10, _activity$channelData11;
12
+ return !!(activity !== null && activity !== void 0 && (_activity$channelData = activity.channelData) !== null && _activity$channelData !== void 0 && (_activity$channelData2 = _activity$channelData.metadata) !== null && _activity$channelData2 !== void 0 && _activity$channelData2.customEvent && typeof (activity === null || activity === void 0 ? void 0 : (_activity$channelData3 = activity.channelData) === null || _activity$channelData3 === void 0 ? void 0 : (_activity$channelData4 = _activity$channelData3.metadata) === null || _activity$channelData4 === void 0 ? void 0 : _activity$channelData4.customEvent) === Constants.String && (activity === null || activity === void 0 ? void 0 : (_activity$channelData5 = activity.channelData) === null || _activity$channelData5 === void 0 ? void 0 : (_activity$channelData6 = _activity$channelData5.metadata) === null || _activity$channelData6 === void 0 ? void 0 : (_activity$channelData7 = _activity$channelData6.customEvent) === null || _activity$channelData7 === void 0 ? void 0 : _activity$channelData7.toLowerCase()) === Constants.true && (activity === null || activity === void 0 ? void 0 : (_activity$from = activity.from) === null || _activity$from === void 0 ? void 0 : _activity$from.role) !== Constants.userMessageTag && typeof (activity === null || activity === void 0 ? void 0 : (_activity$channelData8 = activity.channelData) === null || _activity$channelData8 === void 0 ? void 0 : (_activity$channelData9 = _activity$channelData8.metadata) === null || _activity$channelData9 === void 0 ? void 0 : _activity$channelData9.customEventName) === Constants.String && activity !== null && activity !== void 0 && (_activity$channelData10 = activity.channelData) !== null && _activity$channelData10 !== void 0 && (_activity$channelData11 = _activity$channelData10.metadata) !== null && _activity$channelData11 !== void 0 && _activity$channelData11.customEventValue);
13
+ };
14
+ const createCustomEventMiddleware = broadcastservice => () => next => action => {
15
+ var _action$payload;
16
+ if ((action === null || action === void 0 ? void 0 : action.type) == WebChatActionType.DIRECT_LINE_INCOMING_ACTIVITY && (_action$payload = action.payload) !== null && _action$payload !== void 0 && _action$payload.activity) {
17
+ const activity = action.payload.activity;
18
+ if (isValidCustomEvent(activity)) {
19
+ const customEvent = {
20
+ eventName: Constants.onCustomEvent,
21
+ payload: {
22
+ messageId: activity.messageid ?? activity.id,
23
+ customEventName: activity.channelData.metadata.customEventName,
24
+ customEventValue: activity.channelData.metadata.customEventValue
25
+ }
26
+ };
27
+ broadcastservice.postMessage(customEvent);
28
+ return;
29
+ }
30
+ }
31
+ return next(action);
32
+ };
33
+ export default createCustomEventMiddleware;
@@ -0,0 +1,46 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+
3
+ import { Constants } from "../../../../../common/Constants";
4
+ import { getIconText } from "../../../../../common/utils";
5
+ import { defaultWebChatStyles } from "../../../common/defaultStyles/defaultWebChatStyles";
6
+ import { WebChatActionType } from "../../enums/WebChatActionType";
7
+ let currentAgentInitials = defaultWebChatStyles.botAvatarInitials;
8
+ export const localizedStringsBotInitialsMiddleware = () => _ref => {
9
+ let {
10
+ dispatch
11
+ } = _ref;
12
+ return next => action => {
13
+ if (action.type === WebChatActionType.DIRECT_LINE_INCOMING_ACTIVITY) {
14
+ var _action$payload, _activity$from;
15
+ const activity = (_action$payload = action.payload) === null || _action$payload === void 0 ? void 0 : _action$payload.activity;
16
+ if (activity !== null && activity !== void 0 && (_activity$from = activity.from) !== null && _activity$from !== void 0 && _activity$from.name && activity.from.role !== Constants.userMessageTag && activity.from.name !== Constants.userMessageTag) {
17
+ var _activity$channelData, _activity$channelData2, _activity$tags;
18
+ const agentName = activity.from.name.trim();
19
+ const isSystemMessage = agentName === "__agent__" || agentName.startsWith("__") || ((_activity$channelData = activity.channelData) === null || _activity$channelData === void 0 ? void 0 : (_activity$channelData2 = _activity$channelData.tags) === null || _activity$channelData2 === void 0 ? void 0 : _activity$channelData2.includes(Constants.systemMessageTag)) || ((_activity$tags = activity.tags) === null || _activity$tags === void 0 ? void 0 : _activity$tags.includes(Constants.systemMessageTag));
20
+ if (!isSystemMessage && agentName !== "") {
21
+ // Update initials for valid agent/bot names
22
+ const newInitials = getIconText(agentName) || currentAgentInitials;
23
+ currentAgentInitials = newInitials;
24
+ }
25
+ }
26
+ }
27
+ return next(action);
28
+ };
29
+ };
30
+ export const getOverriddenLocalizedStrings = existingOverrides => {
31
+ return strings => {
32
+ const result = {
33
+ ...strings,
34
+ ...existingOverrides
35
+ };
36
+
37
+ // Apply dynamic bot initials to alt text if not already overridden through props
38
+ if (!(existingOverrides !== null && existingOverrides !== void 0 && existingOverrides.ACTIVITY_BOT_SAID_ALT)) {
39
+ result.ACTIVITY_BOT_SAID_ALT = `${currentAgentInitials} said:`;
40
+ }
41
+ if (!(existingOverrides !== null && existingOverrides !== void 0 && existingOverrides.ACTIVITY_BOT_ATTACHED_ALT)) {
42
+ result.ACTIVITY_BOT_ATTACHED_ALT = `${currentAgentInitials} attached:`;
43
+ }
44
+ return result;
45
+ };
46
+ };
@@ -0,0 +1,38 @@
1
+ import { LogLevel, TelemetryEvent } from "../../../../../common/telemetry/TelemetryConstants";
2
+ import { LiveChatWidgetActionType } from "../../../../../contexts/common/LiveChatWidgetActionType";
3
+ import { TelemetryHelper } from "../../../../../common/telemetry/TelemetryHelper";
4
+ import { WebChatActionType } from "../../enums/WebChatActionType";
5
+ import { executeReducer } from "../../../../../contexts/createReducer";
6
+ import { isEndConversationDueToOverflowActivity } from "../../../../../common/utils";
7
+ const queueOverflowHandlingHelper = async (state, dispatch) => {
8
+ const {
9
+ appStates
10
+ } = executeReducer(state, {
11
+ type: LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
12
+ payload: undefined
13
+ });
14
+ if (!appStates.chatDisconnectEventReceived) {
15
+ dispatch({
16
+ type: LiveChatWidgetActionType.SET_CHAT_DISCONNECT_EVENT_RECEIVED,
17
+ payload: true
18
+ });
19
+ TelemetryHelper.logActionEvent(LogLevel.INFO, {
20
+ Event: TelemetryEvent.QueueOverflowEvent,
21
+ Description: "Set chat disconnect event received."
22
+ });
23
+ }
24
+ };
25
+ export const createQueueOverflowMiddleware = (state, dispatch) => () => next => action => {
26
+ var _action$payload;
27
+ if ((action === null || action === void 0 ? void 0 : action.type) == WebChatActionType.DIRECT_LINE_INCOMING_ACTIVITY && (_action$payload = action.payload) !== null && _action$payload !== void 0 && _action$payload.activity) {
28
+ const activity = action.payload.activity;
29
+ if (isEndConversationDueToOverflowActivity(activity)) {
30
+ TelemetryHelper.logActionEvent(LogLevel.INFO, {
31
+ Event: TelemetryEvent.QueueOverflowEvent,
32
+ Description: "Queue overflow event received."
33
+ });
34
+ queueOverflowHandlingHelper(state, dispatch);
35
+ }
36
+ }
37
+ return next(action);
38
+ };
@@ -0,0 +1 @@
1
+ export {};