@microsoft/omnichannel-chat-widget 1.8.3-main.3445895 → 1.8.3-main.4743fdc

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 (51) hide show
  1. package/lib/cjs/common/Constants.js +2 -0
  2. package/lib/cjs/common/telemetry/TelemetryConstants.js +3 -0
  3. package/lib/cjs/components/citationpanestateful/CitationDim.js +29 -0
  4. package/lib/cjs/components/citationpanestateful/CitationPaneStateful.js +158 -0
  5. package/lib/cjs/components/citationpanestateful/common/defaultProps/defaultCitationPaneProps.js +70 -0
  6. package/lib/cjs/components/confirmationpanestateful/interfaces/IConfirmationPaneLocalizedTexts.js +1 -0
  7. package/lib/cjs/components/livechatwidget/common/endChat.js +5 -1
  8. package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +5 -3
  9. package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +86 -3
  10. package/lib/cjs/components/webchatcontainerstateful/interfaces/ICitation.js +1 -0
  11. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.js +97 -30
  12. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware.js +54 -0
  13. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware.js +2 -2
  14. package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +46 -45
  15. package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +2 -0
  16. package/lib/cjs/contexts/createReducer.js +15 -0
  17. package/lib/esm/common/Constants.js +2 -0
  18. package/lib/esm/common/telemetry/TelemetryConstants.js +3 -0
  19. package/lib/esm/components/citationpanestateful/CitationDim.js +20 -0
  20. package/lib/esm/components/citationpanestateful/CitationPaneStateful.js +147 -0
  21. package/lib/esm/components/citationpanestateful/common/defaultProps/defaultCitationPaneProps.js +61 -0
  22. package/lib/esm/components/confirmationpanestateful/interfaces/IConfirmationPaneLocalizedTexts.js +1 -0
  23. package/lib/esm/components/livechatwidget/common/endChat.js +5 -1
  24. package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +5 -3
  25. package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +86 -4
  26. package/lib/esm/components/webchatcontainerstateful/interfaces/ICitation.js +1 -0
  27. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.js +98 -30
  28. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware.js +46 -0
  29. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware.js +2 -2
  30. package/lib/esm/contexts/common/LiveChatWidgetActionType.js +46 -45
  31. package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +2 -0
  32. package/lib/esm/contexts/createReducer.js +15 -0
  33. package/lib/types/common/Constants.d.ts +2 -0
  34. package/lib/types/common/telemetry/TelemetryConstants.d.ts +3 -0
  35. package/lib/types/components/citationpanestateful/CitationDim.d.ts +5 -0
  36. package/lib/types/components/citationpanestateful/CitationPaneStateful.d.ts +4 -0
  37. package/lib/types/components/citationpanestateful/common/defaultProps/defaultCitationPaneProps.d.ts +11 -0
  38. package/lib/types/components/citationpanestateful/interfaces/ICitationPaneStatefulProps.d.ts +10 -0
  39. package/lib/types/components/confirmationpanestateful/common/defaultProps/defaultConfirmationPaneLocalizedTexts.d.ts +1 -1
  40. package/lib/types/components/confirmationpanestateful/interfaces/IConfirmationPaneStatefulProps.d.ts +1 -1
  41. package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +3 -1
  42. package/lib/types/components/webchatcontainerstateful/interfaces/ICitation.d.ts +12 -0
  43. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.d.ts +3 -4
  44. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware.d.ts +5 -0
  45. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware.d.ts +2 -2
  46. package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +1 -0
  47. package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +46 -45
  48. package/package.json +2 -2
  49. /package/lib/cjs/components/{confirmationpanestateful/interfaces/IConfirmationPaneLocalizedText.js → citationpanestateful/interfaces/ICitationPaneStatefulProps.js} +0 -0
  50. /package/lib/esm/components/{confirmationpanestateful/interfaces/IConfirmationPaneLocalizedText.js → citationpanestateful/interfaces/ICitationPaneStatefulProps.js} +0 -0
  51. /package/lib/types/components/confirmationpanestateful/interfaces/{IConfirmationPaneLocalizedText.d.ts → IConfirmationPaneLocalizedTexts.d.ts} +0 -0
@@ -196,6 +196,8 @@ _defineProperty(HtmlAttributeNames, "adaptiveCardClassName", "ac-adaptiveCard");
196
196
  _defineProperty(HtmlAttributeNames, "adaptiveCardTextBlockClassName", "ac-textBlock");
197
197
  _defineProperty(HtmlAttributeNames, "adaptiveCardToggleInputClassName", "ac-toggleInput");
198
198
  _defineProperty(HtmlAttributeNames, "adaptiveCardActionSetClassName", "ac-actionSet");
199
+ _defineProperty(HtmlAttributeNames, "ocwCitationPaneClassName", "ocw-citation-pane");
200
+ _defineProperty(HtmlAttributeNames, "ocwCitationPaneTitle", "Citation");
199
201
  let WebChatMiddlewareConstants = /*#__PURE__*/_createClass(function WebChatMiddlewareConstants() {
200
202
  _classCallCheck(this, WebChatMiddlewareConstants);
201
203
  });
@@ -154,6 +154,7 @@ exports.TelemetryEvent = TelemetryEvent;
154
154
  TelemetryEvent["EmailTranscriptLoaded"] = "EmailTranscriptLoaded";
155
155
  TelemetryEvent["OutOfOfficePaneLoaded"] = "OutOfOfficePaneLoaded";
156
156
  TelemetryEvent["ConfirmationPaneLoaded"] = "ConfirmationPaneLoaded";
157
+ TelemetryEvent["CitationPaneLoaded"] = "CitationPaneLoaded";
157
158
  TelemetryEvent["ProactiveChatPaneLoaded"] = "ProactiveChatPaneLoaded";
158
159
  TelemetryEvent["ReconnectChatPaneLoaded"] = "ReconnectChatPaneLoaded";
159
160
  TelemetryEvent["HeaderCloseButtonClicked"] = "HeaderCloseButtonClicked";
@@ -280,7 +281,9 @@ exports.TelemetryEvent = TelemetryEvent;
280
281
  TelemetryEvent["UXLCWChatButtonLoadingStart"] = "UXLCWChatButtonLoadingStart";
281
282
  TelemetryEvent["UXLCWChatButtonLoadingCompleted"] = "UXLCWChatButtonLoadingCompleted";
282
283
  TelemetryEvent["UXConfirmationPaneStart"] = "UXConfirmationPaneStart";
284
+ TelemetryEvent["UXCitationPaneStart"] = "UXCitationPaneStart";
283
285
  TelemetryEvent["UXConfirmationPaneCompleted"] = "UXConfirmationPaneCompleted";
286
+ TelemetryEvent["UXCitationPaneCompleted"] = "UXCitationPaneCompleted";
284
287
  TelemetryEvent["UXLiveChatWidgetStart"] = "UXLiveChatWidgetStart";
285
288
  TelemetryEvent["UXLiveChatWidgetCompleted"] = "UXLiveChatWidgetCompleted";
286
289
  TelemetryEvent["AppInsightsInitialized"] = "AppInsightsInitialized";
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = exports.CitationDim = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _reactDom = _interopRequireDefault(require("react-dom"));
9
+ var _DimLayer = require("../dimlayer/DimLayer");
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+ const CONTAINER_SELECTOR = ".webchat__stacked-layout_container";
12
+ const CitationDim = _ref => {
13
+ let {
14
+ brightness = "0.2"
15
+ } = _ref;
16
+ const container = document.querySelector(CONTAINER_SELECTOR);
17
+ if (!container) return null;
18
+ return /*#__PURE__*/_reactDom.default.createPortal( /*#__PURE__*/_react.default.createElement("div", {
19
+ style: {
20
+ position: "absolute",
21
+ inset: 0
22
+ }
23
+ }, /*#__PURE__*/_react.default.createElement(_DimLayer.DimLayer, {
24
+ brightness: brightness
25
+ })), container);
26
+ };
27
+ exports.CitationDim = CitationDim;
28
+ var _default = CitationDim;
29
+ exports.default = _default;
@@ -0,0 +1,158 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = exports.CitationPaneStateful = void 0;
7
+ var _TelemetryConstants = require("../../common/telemetry/TelemetryConstants");
8
+ var _react = _interopRequireWildcard(require("react"));
9
+ var _utils = require("../../common/utils");
10
+ var _CitationDim = _interopRequireDefault(require("./CitationDim"));
11
+ var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
12
+ var _Constants = require("../../common/Constants");
13
+ var _LiveChatWidgetActionType = require("../../contexts/common/LiveChatWidgetActionType");
14
+ var _TelemetryHelper = require("../../common/telemetry/TelemetryHelper");
15
+ var _defaultCitationPaneProps = require("./common/defaultProps/defaultCitationPaneProps");
16
+ var _useChatContextStore = _interopRequireDefault(require("../../hooks/useChatContextStore"));
17
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
19
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
20
+ let uiTimer;
21
+ const CitationPaneStateful = props => {
22
+ (0, _react.useEffect)(() => {
23
+ uiTimer = (0, _utils.createTimer)();
24
+ _TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
25
+ Event: _TelemetryConstants.TelemetryEvent.UXCitationPaneStart
26
+ });
27
+ }, []);
28
+ const initialTabIndexMap = new Map();
29
+ let elements = [];
30
+
31
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
32
+ const [state, dispatch] = (0, _useChatContextStore.default)();
33
+ const controlId = _Constants.HtmlAttributeNames.ocwCitationPaneClassName;
34
+
35
+ // Pane style computed to match the webchat widget container bounds so the pane
36
+ // stays within the widget and scrolls only vertically. We also track an
37
+ // "isReady" flag so we don't render the pane contents until the style is
38
+ // computed — this prevents a transient render that can appear as a flicker.
39
+ const [paneStyle, setPaneStyle] = (0, _react.useState)(null);
40
+ const [isReady, setIsReady] = (0, _react.useState)(false);
41
+
42
+ // Move focus to the container
43
+ (0, _react.useEffect)(() => {
44
+ (0, _utils.preventFocusToMoveOutOfElement)(controlId);
45
+ const focusableElements = (0, _utils.findAllFocusableElement)(`#${controlId}`);
46
+ requestAnimationFrame(() => {
47
+ if (focusableElements && focusableElements.length > 0 && focusableElements[0]) {
48
+ focusableElements[0].focus({
49
+ preventScroll: true
50
+ });
51
+ }
52
+ });
53
+ elements = (0, _utils.findParentFocusableElementsWithoutChildContainer)(controlId);
54
+ (0, _utils.setTabIndices)(elements, initialTabIndexMap, false);
55
+ _TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
56
+ Event: _TelemetryConstants.TelemetryEvent.CitationPaneLoaded
57
+ });
58
+ _TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
59
+ Event: _TelemetryConstants.TelemetryEvent.UXCitationPaneCompleted,
60
+ ElapsedTimeInMilliseconds: uiTimer.milliSecondsElapsed
61
+ });
62
+ }, []);
63
+
64
+ // Compute the widget bounds and set pane style accordingly (95% of widget size
65
+ // and centered inside the widget). If the widget container can't be found,
66
+ // fall back to the default pane styles from defaultCitationPaneProps.
67
+ (0, _react.useEffect)(() => {
68
+ const compute = () => {
69
+ try {
70
+ const container = document.querySelector(".webchat__stacked-layout_container");
71
+ if (container) {
72
+ const rect = container.getBoundingClientRect();
73
+ const widthPx = Math.round(rect.width * 0.95);
74
+ const heightPx = Math.round(rect.height * 0.95);
75
+ const leftPx = Math.round(rect.left + (rect.width - widthPx) / 2);
76
+ const topPx = Math.round(rect.top + (rect.height - heightPx) / 2);
77
+ // Clone defaults and remove transform so explicit left/top pixel
78
+ // coordinates are respected and the pane stays within the
79
+ // widget bounds.
80
+ const base = Object.assign({}, _defaultCitationPaneProps.defaultCitationPaneStyles.pane);
81
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
82
+ if (base && base.transform) {
83
+ // remove centering transform when we compute exact pixel coords
84
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
85
+ delete base.transform;
86
+ }
87
+ setPaneStyle(Object.assign({}, base, {
88
+ left: `${leftPx}px`,
89
+ top: `${topPx}px`,
90
+ width: `${widthPx}px`,
91
+ height: `${heightPx}px`
92
+ }));
93
+ // Make the pane visible after the next paint to avoid layout
94
+ // flashes on initial mount.
95
+ requestAnimationFrame(() => setIsReady(true));
96
+ return;
97
+ }
98
+ } catch (e) {
99
+ // ignore
100
+ }
101
+
102
+ // fallback
103
+ setPaneStyle(_defaultCitationPaneProps.defaultCitationPaneStyles.pane);
104
+ requestAnimationFrame(() => setIsReady(true));
105
+ };
106
+ compute();
107
+ window.addEventListener("resize", compute);
108
+ return () => window.removeEventListener("resize", compute);
109
+ }, []);
110
+ const handleClose = () => {
111
+ if (props.onClose) props.onClose();
112
+ dispatch({
113
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_PREVIOUS_FOCUSED_ELEMENT_ID,
114
+ payload: null
115
+ });
116
+ (0, _utils.setTabIndices)(elements, initialTabIndexMap, true);
117
+ };
118
+
119
+ // Merge a safe style object for the container and cast to CSSProperties to satisfy TS
120
+ const mergedStyle = Object.assign({
121
+ position: "relative"
122
+ }, paneStyle ?? {
123
+ position: "fixed"
124
+ });
125
+
126
+ // If paneStyle hasn't been computed yet, render the DimLayer so clicks
127
+ // still close overlays but hide the pane itself to avoid flashes.
128
+ const hiddenStyle = {
129
+ visibility: isReady ? "visible" : "hidden",
130
+ pointerEvents: isReady ? "auto" : "none"
131
+ };
132
+ const controlProps = {
133
+ id: controlId,
134
+ dir: state.domainStates.globalDir,
135
+ titleText: props.title,
136
+ contentHtml: props.contentHtml,
137
+ brightnessValueOnDim: "0.2",
138
+ onClose: handleClose,
139
+ ...(props === null || props === void 0 ? void 0 : props.controlProps)
140
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
141
+ };
142
+
143
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_CitationDim.default, {
144
+ brightness: "0.2"
145
+ }), /*#__PURE__*/_react.default.createElement("div", {
146
+ style: Object.assign({}, mergedStyle, hiddenStyle, {
147
+ display: "flex",
148
+ flexDirection: "column",
149
+ zIndex: 10001
150
+ })
151
+ }, /*#__PURE__*/_react.default.createElement(_omnichannelChatComponents.CitationPane, {
152
+ controlProps: controlProps,
153
+ styleProps: props === null || props === void 0 ? void 0 : props.styleProps
154
+ })));
155
+ };
156
+ exports.CitationPaneStateful = CitationPaneStateful;
157
+ var _default = CitationPaneStateful;
158
+ exports.default = _default;
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.defaultCitationPaneStyles = exports.defaultCitationContentCSS = exports.default = void 0;
7
+ const defaultCitationPaneStyles = {
8
+ pane: {
9
+ position: "fixed",
10
+ left: "50%",
11
+ top: "18%",
12
+ transform: "translateX(-50%)",
13
+ background: "#fff",
14
+ width: "85%",
15
+ height: "85%",
16
+ overflowY: "auto",
17
+ overflowX: "hidden",
18
+ padding: 16,
19
+ borderRadius: 6,
20
+ zIndex: 10001,
21
+ boxSizing: "border-box"
22
+ }
23
+ };
24
+ exports.defaultCitationPaneStyles = defaultCitationPaneStyles;
25
+ const defaultCitationContentCSS = controlId => `
26
+ #${controlId} .citation-content {
27
+ flex: 1;
28
+ min-height: 0; /* allow flex child to scroll */
29
+ overflow-y: auto;
30
+ overflow-x: auto;
31
+ margin-bottom: 12px;
32
+ white-space: normal; /* wrap normal text */
33
+ word-break: break-word;
34
+ -webkit-overflow-scrolling: touch;
35
+ }
36
+
37
+ #${controlId} .citation-content pre,
38
+ #${controlId} .citation-content code {
39
+ white-space: pre; /* preserve formatting */
40
+ }
41
+
42
+ #${controlId} .citation-content table {
43
+ width: 100%;
44
+ border-collapse: collapse;
45
+ margin-bottom: 12px;
46
+ table-layout: auto;
47
+ overflow-x: auto;
48
+ display: block;
49
+ }
50
+
51
+ #${controlId} .citation-content table th,
52
+ #${controlId} .citation-content table td {
53
+ padding: 8px 12px;
54
+ border: 1px solid rgba(0,0,0,0.08);
55
+ text-align: left;
56
+ vertical-align: top;
57
+ word-break: break-word;
58
+ }
59
+
60
+ #${controlId} .citation-content img {
61
+ max-width: 100%;
62
+ height: auto;
63
+ }
64
+ `;
65
+ exports.defaultCitationContentCSS = defaultCitationContentCSS;
66
+ var _default = {
67
+ defaultCitationPaneStyles,
68
+ defaultCitationContentCSS
69
+ };
70
+ exports.default = _default;
@@ -44,7 +44,7 @@ const prepareEndChat = async (props, facadeChatSDK, state, dispatch, setAdapter,
44
44
  }
45
45
 
46
46
  // Use Case: If ended by Agent, stay chat in InActive state
47
- let isConversationalSurveyEnabled = state.appStates.isConversationalSurveyEnabled;
47
+ const isConversationalSurveyEnabled = state.appStates.isConversationalSurveyEnabled;
48
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)) {
49
49
  dispatch({
50
50
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
@@ -305,6 +305,10 @@ const closeChatStateCleanUp = dispatch => {
305
305
  proactiveChatInNewWindow: false
306
306
  }
307
307
  });
308
+ dispatch({
309
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CITATIONS,
310
+ payload: {}
311
+ });
308
312
 
309
313
  // Clear live chat context only if chat widget is fully closed to support transcript calls after sessionclose is called
310
314
  dispatch({
@@ -44,10 +44,11 @@ var _htmlPlayerMiddleware = _interopRequireDefault(require("../../webchatcontain
44
44
  var _htmlTextMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlTextMiddleware"));
45
45
  var _preProcessingMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/preProcessingMiddleware"));
46
46
  var _sanitizationMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware"));
47
+ var _localizedStringsBotInitialsMiddleware = require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware");
47
48
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
48
49
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
49
50
  const initWebChatComposer = (props, state, dispatch, facadeChatSDK, endChat) => {
50
- 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;
51
52
  // Add a hook to make all links open a new window
52
53
  postDomPurifyActivities();
53
54
  const localizedTexts = {
@@ -122,7 +123,7 @@ const initWebChatComposer = (props, state, dispatch, facadeChatSDK, endChat) =>
122
123
  };
123
124
  webChatStore = (0, _botframeworkWebchat.createStore)({},
124
125
  //initial state
125
- _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, _citationsMiddleware.createCitationsMiddleware, _gifUploadMiddleware.default, _htmlPlayerMiddleware.default, (0, _htmlTextMiddleware.default)(honorsTargetInHTMLLinks), (0, _maxMessageSizeValidator.default)(localizedTexts), _sanitizationMiddleware.default, (0, _callActionMiddleware.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)(),
126
127
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
127
128
  ...(((_props$webChatContain7 = props.webChatContainerProps) === null || _props$webChatContain7 === void 0 ? void 0 : _props$webChatContain7.storeMiddlewares) ?? []));
128
129
  _WebChatStoreLoader.WebChatStoreLoader.store = webChatStore;
@@ -176,7 +177,8 @@ const initWebChatComposer = (props, state, dispatch, facadeChatSDK, endChat) =>
176
177
  onTelemetry: (0, _WebChatLogger.createWebChatTelemetry)(),
177
178
  cardActionMiddleware: (0, _cardActionMiddleware.createCardActionMiddleware)(((_props$webChatContain25 = props.webChatContainerProps) === null || _props$webChatContain25 === void 0 ? void 0 : _props$webChatContain25.botMagicCode) || undefined),
178
179
  sendTypingIndicator: true,
179
- ...((_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)
180
182
  };
181
183
  return webChatProps;
182
184
  };
@@ -10,6 +10,7 @@ var _TelemetryConstants = require("../../common/telemetry/TelemetryConstants");
10
10
  var _react2 = _interopRequireWildcard(require("react"));
11
11
  var _utils = require("../../common/utils");
12
12
  var _BotMagicCodeStore = require("./webchatcontroller/BotMagicCodeStore");
13
+ var _CitationPaneStateful = _interopRequireDefault(require("../citationpanestateful/CitationPaneStateful"));
13
14
  var _botframeworkWebchat = require("botframework-webchat");
14
15
  var _LiveChatWidgetActionType = require("../../contexts/common/LiveChatWidgetActionType");
15
16
  var _NotificationHandler = require("./webchatcontroller/notification/NotificationHandler");
@@ -25,12 +26,12 @@ var _defaultSystemMessageBoxStyles = require("./webchatcontroller/middlewares/re
25
26
  var _defaultUserMessageBoxStyles = require("./webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultUserMessageBoxStyles");
26
27
  var _defaultWebChatContainerStatefulProps = require("./common/defaultProps/defaultWebChatContainerStatefulProps");
27
28
  var _ = require("../..");
29
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
28
30
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
29
31
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
30
- /* eslint-disable @typescript-eslint/no-explicit-any */
31
-
32
32
  let uiTimer;
33
33
  const broadcastChannelMessageEvent = "message";
34
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
34
35
  const postActivity = activity => {
35
36
  // eslint-disable-line @typescript-eslint/no-explicit-any
36
37
  return {
@@ -63,6 +64,17 @@ const WebChatContainerStateful = props => {
63
64
  Event: _TelemetryConstants.TelemetryEvent.UXWebchatContainerCompleted
64
65
  });
65
66
  }, []);
67
+
68
+ // Citation pane state
69
+ const [citationPaneOpen, setCitationPaneOpen] = (0, _react2.useState)(false);
70
+ const [citationPaneText, setCitationPaneText] = (0, _react2.useState)("");
71
+
72
+ // Guard to prevent handling multiple rapid clicks which could cause
73
+ // the dim layer and pane to re-render out of sync and create a flicker.
74
+ const citationOpeningRef = (0, _react2.useRef)(false);
75
+
76
+ // ...existing code...
77
+
66
78
  const {
67
79
  BasicWebChat
68
80
  } = _botframeworkWebchat.Components;
@@ -71,6 +83,53 @@ const WebChatContainerStateful = props => {
71
83
  webChatContainerProps,
72
84
  contextDataStore
73
85
  } = props;
86
+
87
+ // Delegated click handler for citation anchors. Placed after state is
88
+ // available so we can prefer reading citations from app state and fall
89
+ // back to the legacy window map for backward-compatibility in tests.
90
+ (0, _react2.useEffect)(() => {
91
+ const clickHandler = ev => {
92
+ try {
93
+ if (citationOpeningRef.current) {
94
+ return;
95
+ }
96
+ const target = ev.target;
97
+ // Only consider anchors whose href starts with the citation scheme
98
+ const anchor = target.closest && target.closest("a[href^=\"cite:\"]");
99
+ if (anchor) {
100
+ ev.preventDefault();
101
+ citationOpeningRef.current = true;
102
+ // Rely only on the href to identify the citation key
103
+ let text = "";
104
+ try {
105
+ var _state$domainStates;
106
+ const cid = anchor.getAttribute("href");
107
+ // Prefer state-based citations injected by middleware
108
+ if (state !== null && state !== void 0 && (_state$domainStates = state.domainStates) !== null && _state$domainStates !== void 0 && _state$domainStates.citations && cid) {
109
+ text = state.domainStates.citations[cid] ?? "";
110
+ }
111
+ // If state lookup failed, fall back to the anchor's title or innerText
112
+ if (!text) {
113
+ text = anchor.getAttribute("title") || anchor.innerText || "";
114
+ }
115
+ } catch (e) {
116
+ // ignore
117
+ }
118
+ setCitationPaneOpen(true);
119
+ setCitationPaneText(text);
120
+
121
+ // Simple debounce - reset guard after a short delay
122
+ setTimeout(() => {
123
+ citationOpeningRef.current = false;
124
+ }, 100);
125
+ }
126
+ } catch (e) {
127
+ citationOpeningRef.current = false;
128
+ }
129
+ };
130
+ document.addEventListener("click", clickHandler);
131
+ return () => document.removeEventListener("click", clickHandler);
132
+ }, [state]);
74
133
  const containerStyles = {
75
134
  root: Object.assign({}, _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.containerStyles, webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : webChatContainerProps.containerStyles, {
76
135
  display: state.appStates.isMinimized ? "none" : ""
@@ -105,8 +164,10 @@ const WebChatContainerStateful = props => {
105
164
  localStorage;
106
165
  sessionStorage;
107
166
  } catch (error) {
167
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
108
168
  if (!window.TPCWarningShown) {
109
169
  _NotificationHandler.NotificationHandler.notifyWarning(_NotificationScenarios.NotificationScenarios.TPC, (localizedTexts === null || localizedTexts === void 0 ? void 0 : localizedTexts.THIRD_PARTY_COOKIES_BLOCKED_ALERT_MESSAGE) ?? "");
170
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
110
171
  window.TPCWarningShown = true;
111
172
  }
112
173
  }
@@ -295,10 +356,32 @@ const WebChatContainerStateful = props => {
295
356
  overflow-y: unset;
296
357
  }
297
358
 
359
+ /* Custom styles for carousel hero cards */
360
+ ul.webchat__carousel-filmstrip__attachments .ac-image {
361
+ width: 200px !important;
362
+ height: 150px !important;
363
+ object-fit: cover !important;
364
+ border-radius: 8px !important;
365
+ border: 1px solid #e0e0e0 !important;
366
+ }
367
+
368
+ .webchat__carousel-filmstrip-attachment .webchat__bubble {
369
+ height: 100% !important;
370
+ }
371
+
372
+ .webchat__carousel-filmstrip-attachment .webchat__bubble #ms_lcw_webchat_adaptive_card {
373
+ height: 100% !important;
374
+ }
375
+
298
376
  `), /*#__PURE__*/_react2.default.createElement(_react.Stack, {
299
377
  styles: containerStyles,
300
378
  className: "webchat__stacked-layout_container"
301
- }, /*#__PURE__*/_react2.default.createElement(BasicWebChat, null)));
379
+ }, /*#__PURE__*/_react2.default.createElement(BasicWebChat, null)), citationPaneOpen && /*#__PURE__*/_react2.default.createElement(_CitationPaneStateful.default, {
380
+ id: _Constants.HtmlAttributeNames.ocwCitationPaneClassName,
381
+ title: _Constants.HtmlAttributeNames.ocwCitationPaneTitle,
382
+ contentHtml: citationPaneText,
383
+ onClose: () => setCitationPaneOpen(false)
384
+ }));
302
385
  };
303
386
  exports.WebChatContainerStateful = WebChatContainerStateful;
304
387
  var _default = WebChatContainerStateful;