@microsoft/omnichannel-chat-widget 1.8.3-main.ec1328d → 1.8.4-main.7bdb634

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 (160) hide show
  1. package/lib/cjs/common/Constants.js +6 -0
  2. package/lib/cjs/common/facades/FacadeChatSDK.js +6 -0
  3. package/lib/cjs/common/telemetry/TelemetryConstants.js +34 -0
  4. package/lib/cjs/common/utils/SecureEventBus.js +307 -0
  5. package/lib/cjs/common/utils/dispatchCustomEvent.js +25 -0
  6. package/lib/cjs/components/citationpanestateful/CitationDim.js +29 -0
  7. package/lib/cjs/components/citationpanestateful/CitationPaneStateful.js +199 -0
  8. package/lib/cjs/components/citationpanestateful/common/defaultProps/defaultCitationPaneProps.js +70 -0
  9. package/lib/cjs/components/confirmationpanestateful/interfaces/IConfirmationPaneLocalizedTexts.js +1 -0
  10. package/lib/cjs/components/livechatwidget/LiveChatWidget.js +4 -4
  11. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/AddActivitySubscriber.js +127 -0
  12. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +4 -5
  13. package/lib/cjs/components/livechatwidget/common/ChatWidgetEvents.js +15 -0
  14. package/lib/cjs/components/livechatwidget/common/PersistentConversationHandler.js +284 -0
  15. package/lib/cjs/components/livechatwidget/common/createAdapter.js +2 -0
  16. package/lib/cjs/components/livechatwidget/common/defaultProps/defaultPersistentChatHistoryProps.js +18 -0
  17. package/lib/cjs/components/livechatwidget/common/endChat.js +28 -3
  18. package/lib/cjs/components/livechatwidget/common/getMockChatSDKIfApplicable.js +4 -3
  19. package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +8 -6
  20. package/lib/cjs/components/livechatwidget/common/overridePropsOnMockIfApplicable.js +2 -1
  21. package/lib/cjs/components/livechatwidget/common/startChat.js +5 -4
  22. package/lib/cjs/components/livechatwidget/interfaces/IMockProps.js +8 -2
  23. package/lib/cjs/components/livechatwidget/interfaces/IPersistentChatHistoryProps.js +1 -0
  24. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +29 -5
  25. package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +122 -11
  26. package/lib/cjs/components/webchatcontainerstateful/common/DesignerChatAdapter.js +43 -14
  27. package/lib/cjs/components/webchatcontainerstateful/common/DesignerChatSDK.js +6 -1
  28. package/lib/cjs/components/webchatcontainerstateful/common/activities/botActivity.js +14 -0
  29. package/lib/cjs/components/webchatcontainerstateful/common/activities/conversationDividerActivity.js +17 -0
  30. package/lib/cjs/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.js +97 -0
  31. package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +2 -1
  32. package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultWebChatStatefulProps.js +1 -1
  33. package/lib/cjs/components/webchatcontainerstateful/common/defaultStyles/defaultWebChatStyles.js +1 -1
  34. package/lib/cjs/components/webchatcontainerstateful/common/utils/chatAdapterUtils.js +36 -2
  35. package/lib/cjs/components/webchatcontainerstateful/common/utils/fontUtils.js +28 -0
  36. package/lib/cjs/components/webchatcontainerstateful/hooks/usePersistentChatHistory.js +59 -0
  37. package/lib/cjs/components/webchatcontainerstateful/interfaces/ICitation.js +1 -0
  38. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js +122 -0
  39. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/Constants.js +10 -0
  40. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/ConversationDividerActivity.js +18 -0
  41. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.js +1038 -0
  42. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LoadInlineBannerActivity.js +34 -0
  43. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +44 -0
  44. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +16 -2
  45. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultAvatarTextStyles.js +1 -1
  46. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultInLineBannerStyle.js +20 -0
  47. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageStyles.js +1 -1
  48. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +2 -2
  49. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/HistoryMessageTimestamp.js +59 -0
  50. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +4 -3
  51. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +2 -2
  52. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.js +97 -30
  53. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware.js +2 -2
  54. package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +46 -45
  55. package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +2 -0
  56. package/lib/cjs/contexts/createReducer.js +15 -0
  57. package/lib/cjs/index.js +9 -1
  58. package/lib/esm/common/Constants.js +6 -0
  59. package/lib/esm/common/facades/FacadeChatSDK.js +6 -0
  60. package/lib/esm/common/telemetry/TelemetryConstants.js +34 -0
  61. package/lib/esm/common/utils/SecureEventBus.js +328 -0
  62. package/lib/esm/common/utils/dispatchCustomEvent.js +18 -0
  63. package/lib/esm/components/citationpanestateful/CitationDim.js +20 -0
  64. package/lib/esm/components/citationpanestateful/CitationPaneStateful.js +188 -0
  65. package/lib/esm/components/citationpanestateful/common/defaultProps/defaultCitationPaneProps.js +61 -0
  66. package/lib/esm/components/confirmationpanestateful/interfaces/IConfirmationPaneLocalizedTexts.js +1 -0
  67. package/lib/esm/components/livechatwidget/LiveChatWidget.js +4 -4
  68. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/AddActivitySubscriber.js +120 -0
  69. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +4 -5
  70. package/lib/esm/components/livechatwidget/common/ChatWidgetEvents.js +8 -0
  71. package/lib/esm/components/livechatwidget/common/PersistentConversationHandler.js +277 -0
  72. package/lib/esm/components/livechatwidget/common/createAdapter.js +2 -0
  73. package/lib/esm/components/livechatwidget/common/defaultProps/defaultPersistentChatHistoryProps.js +11 -0
  74. package/lib/esm/components/livechatwidget/common/endChat.js +29 -4
  75. package/lib/esm/components/livechatwidget/common/getMockChatSDKIfApplicable.js +4 -3
  76. package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +8 -6
  77. package/lib/esm/components/livechatwidget/common/overridePropsOnMockIfApplicable.js +2 -1
  78. package/lib/esm/components/livechatwidget/common/startChat.js +5 -4
  79. package/lib/esm/components/livechatwidget/interfaces/IMockProps.js +3 -3
  80. package/lib/esm/components/livechatwidget/interfaces/IPersistentChatHistoryProps.js +1 -0
  81. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +29 -5
  82. package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +125 -12
  83. package/lib/esm/components/webchatcontainerstateful/common/DesignerChatAdapter.js +43 -14
  84. package/lib/esm/components/webchatcontainerstateful/common/DesignerChatSDK.js +6 -1
  85. package/lib/esm/components/webchatcontainerstateful/common/activities/botActivity.js +7 -0
  86. package/lib/esm/components/webchatcontainerstateful/common/activities/conversationDividerActivity.js +9 -0
  87. package/lib/esm/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.js +90 -0
  88. package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +2 -1
  89. package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultWebChatStatefulProps.js +2 -2
  90. package/lib/esm/components/webchatcontainerstateful/common/defaultStyles/defaultWebChatStyles.js +1 -1
  91. package/lib/esm/components/webchatcontainerstateful/common/utils/chatAdapterUtils.js +32 -0
  92. package/lib/esm/components/webchatcontainerstateful/common/utils/fontUtils.js +21 -0
  93. package/lib/esm/components/webchatcontainerstateful/hooks/usePersistentChatHistory.js +51 -0
  94. package/lib/esm/components/webchatcontainerstateful/interfaces/ICitation.js +1 -0
  95. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js +115 -0
  96. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/Constants.js +3 -0
  97. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/ConversationDividerActivity.js +10 -0
  98. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.js +1060 -0
  99. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LoadInlineBannerActivity.js +25 -0
  100. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +42 -0
  101. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +13 -0
  102. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultAvatarTextStyles.js +1 -1
  103. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultInLineBannerStyle.js +13 -0
  104. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageStyles.js +1 -1
  105. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +1 -1
  106. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/HistoryMessageTimestamp.js +52 -0
  107. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +2 -2
  108. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +1 -1
  109. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.js +98 -30
  110. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware.js +2 -2
  111. package/lib/esm/contexts/common/LiveChatWidgetActionType.js +46 -45
  112. package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +2 -0
  113. package/lib/esm/contexts/createReducer.js +15 -0
  114. package/lib/esm/index.js +1 -0
  115. package/lib/types/common/Constants.d.ts +5 -0
  116. package/lib/types/common/facades/FacadeChatSDK.d.ts +3 -1
  117. package/lib/types/common/telemetry/TelemetryConstants.d.ts +33 -2
  118. package/lib/types/common/utils/SecureEventBus.d.ts +159 -0
  119. package/lib/types/common/utils/dispatchCustomEvent.d.ts +2 -0
  120. package/lib/types/components/citationpanestateful/CitationDim.d.ts +5 -0
  121. package/lib/types/components/citationpanestateful/CitationPaneStateful.d.ts +4 -0
  122. package/lib/types/components/citationpanestateful/common/defaultProps/defaultCitationPaneProps.d.ts +11 -0
  123. package/lib/types/components/citationpanestateful/interfaces/ICitationPaneStatefulProps.d.ts +19 -0
  124. package/lib/types/components/confirmationpanestateful/common/defaultProps/defaultConfirmationPaneLocalizedTexts.d.ts +1 -1
  125. package/lib/types/components/confirmationpanestateful/interfaces/IConfirmationPaneStatefulProps.d.ts +1 -1
  126. package/lib/types/components/livechatwidget/common/ActivitySubscriber/AddActivitySubscriber.d.ts +45 -0
  127. package/lib/types/components/livechatwidget/common/ChatWidgetEvents.d.ts +7 -0
  128. package/lib/types/components/livechatwidget/common/PersistentConversationHandler.d.ts +28 -0
  129. package/lib/types/components/livechatwidget/common/defaultProps/defaultPersistentChatHistoryProps.d.ts +2 -0
  130. package/lib/types/components/livechatwidget/common/getMockChatSDKIfApplicable.d.ts +2 -1
  131. package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +5 -1
  132. package/lib/types/components/livechatwidget/interfaces/IMockProps.d.ts +5 -3
  133. package/lib/types/components/livechatwidget/interfaces/IPersistentChatHistoryProps.d.ts +7 -0
  134. package/lib/types/components/webchatcontainerstateful/common/DesignerChatAdapter.d.ts +4 -2
  135. package/lib/types/components/webchatcontainerstateful/common/DesignerChatSDK.d.ts +5 -0
  136. package/lib/types/components/webchatcontainerstateful/common/activities/botActivity.d.ts +7 -0
  137. package/lib/types/components/webchatcontainerstateful/common/activities/conversationDividerActivity.d.ts +10 -0
  138. package/lib/types/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.d.ts +2 -0
  139. package/lib/types/components/webchatcontainerstateful/common/utils/chatAdapterUtils.d.ts +6 -1
  140. package/lib/types/components/webchatcontainerstateful/common/utils/fontUtils.d.ts +10 -0
  141. package/lib/types/components/webchatcontainerstateful/hooks/usePersistentChatHistory.d.ts +4 -0
  142. package/lib/types/components/webchatcontainerstateful/interfaces/ICitation.d.ts +12 -0
  143. package/lib/types/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.d.ts +7 -0
  144. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/Constants.d.ts +3 -0
  145. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/ConversationDividerActivity.d.ts +4 -0
  146. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.d.ts +326 -0
  147. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LoadInlineBannerActivity.d.ts +8 -0
  148. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.d.ts +1 -0
  149. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultInLineBannerStyle.d.ts +2 -0
  150. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/HistoryMessageTimestamp.d.ts +2 -0
  151. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.d.ts +3 -4
  152. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware.d.ts +2 -2
  153. package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +1 -0
  154. package/lib/types/contexts/common/ILiveChatWidgetLocalizedTexts.d.ts +1 -0
  155. package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +46 -45
  156. package/lib/types/index.d.ts +1 -0
  157. package/package.json +3 -3
  158. /package/lib/cjs/components/{confirmationpanestateful/interfaces/IConfirmationPaneLocalizedText.js → citationpanestateful/interfaces/ICitationPaneStatefulProps.js} +0 -0
  159. /package/lib/esm/components/{confirmationpanestateful/interfaces/IConfirmationPaneLocalizedText.js → citationpanestateful/interfaces/ICitationPaneStatefulProps.js} +0 -0
  160. /package/lib/types/components/confirmationpanestateful/interfaces/{IConfirmationPaneLocalizedText.d.ts → IConfirmationPaneLocalizedTexts.d.ts} +0 -0
@@ -45,6 +45,10 @@ _defineProperty(Constants, "botParticipantTypeTag", "Bot");
45
45
  _defineProperty(Constants, "channelIdKey", "ChannelId-");
46
46
  _defineProperty(Constants, "ChannelId", "lcw");
47
47
  _defineProperty(Constants, "CustomerTag", "FromCustomer");
48
+ // LCW only tags (Only applicable on client-side for additional processing, not recognized by service)
49
+ _defineProperty(Constants, "persistentChatHistoryMessageTag", "PersistentChatHistory");
50
+ _defineProperty(Constants, "persistentChatHistoryMessagePullTriggerTag", "PersistentChatHistoryMessagePullTrigger");
51
+ _defineProperty(Constants, "conversationDividerTag", "ConversationDivider");
48
52
  // gifUploadMiddleware
49
53
  _defineProperty(Constants, "GifContentType", "image/gif");
50
54
  // htmlPlayerMiddleware
@@ -196,6 +200,8 @@ _defineProperty(HtmlAttributeNames, "adaptiveCardClassName", "ac-adaptiveCard");
196
200
  _defineProperty(HtmlAttributeNames, "adaptiveCardTextBlockClassName", "ac-textBlock");
197
201
  _defineProperty(HtmlAttributeNames, "adaptiveCardToggleInputClassName", "ac-toggleInput");
198
202
  _defineProperty(HtmlAttributeNames, "adaptiveCardActionSetClassName", "ac-actionSet");
203
+ _defineProperty(HtmlAttributeNames, "ocwCitationPaneClassName", "ocw-citation-pane");
204
+ _defineProperty(HtmlAttributeNames, "ocwCitationPaneTitle", "Citation");
199
205
  let WebChatMiddlewareConstants = /*#__PURE__*/_createClass(function WebChatMiddlewareConstants() {
200
206
  _classCallCheck(this, WebChatMiddlewareConstants);
201
207
  });
@@ -487,6 +487,12 @@ let FacadeChatSDK = /*#__PURE__*/function () {
487
487
  reconnectableChatsParams.authenticatedUserToken = this.token;
488
488
  return this.validateAndExecuteCall("getReconnectableChats", () => this.chatSDK.OCClient.getReconnectableChats(reconnectableChatsParams));
489
489
  }
490
+ }, {
491
+ key: "fetchPersistentConversationHistory",
492
+ value: async function fetchPersistentConversationHistory() {
493
+ let getPersistentChatHistoryOptionalParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
494
+ return this.validateAndExecuteCall("getPersistentChatHistory", () => this.chatSDK.getPersistentChatHistory(getPersistentChatHistoryOptionalParams));
495
+ }
490
496
  }]);
491
497
  return FacadeChatSDK;
492
498
  }();
@@ -73,10 +73,12 @@ exports.BroadcastEvent = BroadcastEvent;
73
73
  BroadcastEvent["OnWidgetError"] = "OnWidgetError";
74
74
  BroadcastEvent["FMLTrackingCompletedAck"] = "FMLTrackingCompletedAck";
75
75
  BroadcastEvent["FMLTrackingCompleted"] = "FMLTrackingCompleted";
76
+ BroadcastEvent["PersistentConversationReset"] = "PersistentConversationReset";
76
77
  })(BroadcastEvent || (exports.BroadcastEvent = BroadcastEvent = {}));
77
78
  let TelemetryEvent;
78
79
  exports.TelemetryEvent = TelemetryEvent;
79
80
  (function (TelemetryEvent) {
81
+ TelemetryEvent["FetchPersistentChatHistoryFailed"] = "FetchPersistentChatHistoryFailed";
80
82
  TelemetryEvent["CallAdded"] = "CallAdded";
81
83
  TelemetryEvent["LocalVideoStreamAdded"] = "LocalVideoStreamAdded";
82
84
  TelemetryEvent["LocalVideoStreamRemoved"] = "LocalVideoStreamRemoved";
@@ -154,6 +156,7 @@ exports.TelemetryEvent = TelemetryEvent;
154
156
  TelemetryEvent["EmailTranscriptLoaded"] = "EmailTranscriptLoaded";
155
157
  TelemetryEvent["OutOfOfficePaneLoaded"] = "OutOfOfficePaneLoaded";
156
158
  TelemetryEvent["ConfirmationPaneLoaded"] = "ConfirmationPaneLoaded";
159
+ TelemetryEvent["CitationPaneLoaded"] = "CitationPaneLoaded";
157
160
  TelemetryEvent["ProactiveChatPaneLoaded"] = "ProactiveChatPaneLoaded";
158
161
  TelemetryEvent["ReconnectChatPaneLoaded"] = "ReconnectChatPaneLoaded";
159
162
  TelemetryEvent["HeaderCloseButtonClicked"] = "HeaderCloseButtonClicked";
@@ -280,11 +283,39 @@ exports.TelemetryEvent = TelemetryEvent;
280
283
  TelemetryEvent["UXLCWChatButtonLoadingStart"] = "UXLCWChatButtonLoadingStart";
281
284
  TelemetryEvent["UXLCWChatButtonLoadingCompleted"] = "UXLCWChatButtonLoadingCompleted";
282
285
  TelemetryEvent["UXConfirmationPaneStart"] = "UXConfirmationPaneStart";
286
+ TelemetryEvent["UXCitationPaneStart"] = "UXCitationPaneStart";
283
287
  TelemetryEvent["UXConfirmationPaneCompleted"] = "UXConfirmationPaneCompleted";
288
+ TelemetryEvent["UXCitationPaneCompleted"] = "UXCitationPaneCompleted";
284
289
  TelemetryEvent["UXLiveChatWidgetStart"] = "UXLiveChatWidgetStart";
285
290
  TelemetryEvent["UXLiveChatWidgetCompleted"] = "UXLiveChatWidgetCompleted";
286
291
  TelemetryEvent["AppInsightsInitialized"] = "AppInsightsInitialized";
287
292
  TelemetryEvent["AppInsightsInitFailed"] = "AppInsightsInitFailed";
293
+ TelemetryEvent["ConvertPersistentChatHistoryMessageToActivityFailed"] = "ConvertPersistentChatHistoryMessageToActivityFailed";
294
+ TelemetryEvent["UXLCWPersistentChatHistoryInitialized"] = "UXLCWPersistentChatHistoryInitialized";
295
+ TelemetryEvent["LCWPersistentChatHistoryFetchStarted"] = "LCWPersistentChatHistoryFetchStarted";
296
+ TelemetryEvent["LCWPersistentChatHistoryFetchCompleted"] = "LCWPersistentChatHistoryFetchCompleted";
297
+ TelemetryEvent["LCWPersistentChatHistoryFetchFailed"] = "LCWPersistentChatHistoryFetchFailed";
298
+ TelemetryEvent["LCWWebChatStorePollingStarted"] = "LCWWebChatStorePollingStarted";
299
+ TelemetryEvent["LCWWebChatStoreReady"] = "LCWWebChatStoreReady";
300
+ TelemetryEvent["LCWWebChatConnected"] = "LCWWebChatConnected";
301
+ TelemetryEvent["LCWWebChatDisconnected"] = "LCWWebChatDisconnected";
302
+ TelemetryEvent["LCWWebChatConnectionCheckFailed"] = "LCWWebChatConnectionCheckFailed";
303
+ TelemetryEvent["LCWPersistentConversationHandlerInitialized"] = "LCWPersistentConversationHandlerInitialized";
304
+ TelemetryEvent["LCWPersistentHistoryPullBlocked"] = "LCWPersistentHistoryPullBlocked";
305
+ TelemetryEvent["LCWPersistentHistoryPullCompleted"] = "LCWPersistentHistoryPullCompleted";
306
+ TelemetryEvent["LCWLazyLoadInitializationStarted"] = "LCWLazyLoadInitializationStarted";
307
+ TelemetryEvent["LCWLazyLoadContainerNotFound"] = "LCWLazyLoadContainerNotFound";
308
+ TelemetryEvent["LCWLazyLoadInitializationCompleted"] = "LCWLazyLoadInitializationCompleted";
309
+ TelemetryEvent["LCWLazyLoadSessionMetrics"] = "LCWLazyLoadSessionMetrics";
310
+ TelemetryEvent["LCWLazyLoadTargetElementNotFound"] = "LCWLazyLoadTargetElementNotFound";
311
+ TelemetryEvent["LCWLazyLoadScrollFailed"] = "LCWLazyLoadScrollFailed";
312
+ TelemetryEvent["LCWLazyLoadActivityMounted"] = "LCWLazyLoadActivityMounted";
313
+ TelemetryEvent["LCWLazyLoadReset"] = "LCWLazyLoadReset";
314
+ TelemetryEvent["LCWLazyLoadNoMoreHistory"] = "LCWLazyLoadNoMoreHistory";
315
+ TelemetryEvent["LCWLazyLoadDestroyed"] = "LCWLazyLoadDestroyed";
316
+ TelemetryEvent["SecureEventBusUnauthorizedDispatch"] = "SecureEventBusUnauthorizedDispatch";
317
+ TelemetryEvent["SecureEventBusListenerError"] = "SecureEventBusListenerError";
318
+ TelemetryEvent["SecureEventBusDispatchError"] = "SecureEventBusDispatchError";
288
319
  })(TelemetryEvent || (exports.TelemetryEvent = TelemetryEvent = {}));
289
320
  let TelemetryConstants = /*#__PURE__*/function () {
290
321
  function TelemetryConstants() {
@@ -352,6 +383,9 @@ let TelemetryConstants = /*#__PURE__*/function () {
352
383
  case TelemetryEvent.PostChatWorkflowFromAgent:
353
384
  case TelemetryEvent.PostChatWorkflowFromBot:
354
385
  case TelemetryEvent.AppStatesException:
386
+ case TelemetryEvent.SecureEventBusUnauthorizedDispatch:
387
+ case TelemetryEvent.SecureEventBusListenerError:
388
+ case TelemetryEvent.SecureEventBusDispatchError:
355
389
  return ScenarioType.ACTIONS;
356
390
  case TelemetryEvent.StartChatSDKCall:
357
391
  case TelemetryEvent.StartChatEventReceived:
@@ -0,0 +1,307 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _TelemetryHelper = require("../telemetry/TelemetryHelper");
8
+ var _TelemetryConstants = require("../telemetry/TelemetryConstants");
9
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
10
+ 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); } }
11
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
12
+ 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; }
13
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
14
+ 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); }
15
+ /**
16
+ * SecureEventBus class implementing the singleton pattern for secure event communication.
17
+ * Provides authentication-based event dispatching to prevent unauthorized external access.
18
+ */
19
+ let SecureEventBus = /*#__PURE__*/function () {
20
+ /**
21
+ * Private constructor to enforce singleton pattern.
22
+ * Generates a unique authentication token for this session.
23
+ */
24
+ function SecureEventBus() {
25
+ _classCallCheck(this, SecureEventBus);
26
+ _defineProperty(this, "listeners", new Map());
27
+ _defineProperty(this, "authToken", void 0);
28
+ _defineProperty(this, "eventCounter", 0);
29
+ // Generate a secure, unique token for this session
30
+ this.authToken = this.generateAuthToken();
31
+ }
32
+
33
+ /**
34
+ * Get the singleton instance of SecureEventBus.
35
+ * Creates a new instance if one doesn't exist.
36
+ *
37
+ * @returns The singleton instance of SecureEventBus
38
+ *
39
+ * @example
40
+ * ```typescript
41
+ * const eventBus = SecureEventBus.getInstance();
42
+ * ```
43
+ */
44
+ _createClass(SecureEventBus, [{
45
+ key: "generateAuthToken",
46
+ value:
47
+ /**
48
+ * Generate a cryptographically secure authentication token.
49
+ * Uses crypto.getRandomValues when available, falls back to Math.random.
50
+ *
51
+ * @private
52
+ * @returns A 64-character hexadecimal string representing the authentication token
53
+ */
54
+ function generateAuthToken() {
55
+ const array = new Uint8Array(32);
56
+ if (typeof crypto !== "undefined" && crypto.getRandomValues) {
57
+ crypto.getRandomValues(array);
58
+ } else {
59
+ // Fallback for environments without crypto.getRandomValues
60
+ for (let i = 0; i < array.length; i++) {
61
+ array[i] = Math.floor(Math.random() * 256);
62
+ }
63
+ }
64
+ return Array.from(array, byte => byte.toString(16).padStart(2, "0")).join("");
65
+ }
66
+
67
+ /**
68
+ * Get the authentication token for this SecureEventBus instance.
69
+ * This token is required for dispatching events and should only be used internally.
70
+ *
71
+ * @returns The authentication token string
72
+ *
73
+ * @example
74
+ * ```typescript
75
+ * const eventBus = SecureEventBus.getInstance();
76
+ * const token = eventBus.getAuthToken();
77
+ * eventBus.dispatch('myEvent', { data: 'value' }, token);
78
+ * ```
79
+ */
80
+ }, {
81
+ key: "getAuthToken",
82
+ value: function getAuthToken() {
83
+ return this.authToken;
84
+ }
85
+
86
+ /**
87
+ * Dispatch an event with authentication to all registered listeners.
88
+ * Verifies the authentication token before dispatching to prevent unauthorized access.
89
+ *
90
+ * @param eventName - The name of the event to dispatch
91
+ * @param payload - The data to send with the event (optional)
92
+ * @param token - Authentication token (must match the internal token)
93
+ * @returns true if event was successfully dispatched, false if unauthorized or error occurred
94
+ *
95
+ * @example
96
+ * ```typescript
97
+ * const eventBus = SecureEventBus.getInstance();
98
+ * const token = eventBus.getAuthToken();
99
+ *
100
+ * // Dispatch with payload
101
+ * const success = eventBus.dispatch('userAction', { action: 'click', target: 'button' }, token);
102
+ *
103
+ * // Dispatch without payload
104
+ * eventBus.dispatch('windowClosed', undefined, token);
105
+ * ```
106
+ */
107
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
108
+ }, {
109
+ key: "dispatch",
110
+ value: function dispatch(eventName, payload, token) {
111
+ // Verify authentication token
112
+ if (token !== this.authToken) {
113
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
114
+ Event: _TelemetryConstants.TelemetryEvent.SecureEventBusUnauthorizedDispatch,
115
+ Description: `Unauthorized event dispatch attempt blocked: ${eventName}`,
116
+ ExceptionDetails: {
117
+ eventName,
118
+ providedToken: token ? "provided" : "missing",
119
+ expectedToken: "secured"
120
+ }
121
+ });
122
+ return false;
123
+ }
124
+ const listeners = this.listeners.get(eventName);
125
+ if (!listeners || listeners.length === 0) {
126
+ return true; // No listeners, but not an error
127
+ }
128
+
129
+ // Dispatch to all registered listeners
130
+ try {
131
+ listeners.forEach(listener => {
132
+ try {
133
+ listener.callback(payload);
134
+ } catch (error) {
135
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
136
+ Event: _TelemetryConstants.TelemetryEvent.SecureEventBusListenerError,
137
+ Description: `Error in event listener for event: ${eventName}`,
138
+ ExceptionDetails: error
139
+ });
140
+ }
141
+ });
142
+ return true;
143
+ } catch (error) {
144
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
145
+ Event: _TelemetryConstants.TelemetryEvent.SecureEventBusDispatchError,
146
+ Description: `Error dispatching event: ${eventName}`,
147
+ ExceptionDetails: error
148
+ });
149
+ return false;
150
+ }
151
+ }
152
+
153
+ /**
154
+ * Subscribe to an event with a callback function.
155
+ * The callback will be executed whenever the specified event is dispatched.
156
+ *
157
+ * @param eventName - The name of the event to listen for
158
+ * @param callback - The function to execute when the event is fired
159
+ * @returns A function that can be called to unsubscribe from the event
160
+ *
161
+ * @example
162
+ * ```typescript
163
+ * const eventBus = SecureEventBus.getInstance();
164
+ *
165
+ * // Subscribe to an event
166
+ * const unsubscribe = eventBus.subscribe('chatMessage', (message) => {
167
+ * console.log('New message:', message.text);
168
+ * console.log('From user:', message.userId);
169
+ * });
170
+ *
171
+ * // Later, unsubscribe
172
+ * unsubscribe();
173
+ * ```
174
+ */
175
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
176
+ }, {
177
+ key: "subscribe",
178
+ value: function subscribe(eventName, callback) {
179
+ const listenerId = `listener_${++this.eventCounter}`;
180
+ if (!this.listeners.has(eventName)) {
181
+ this.listeners.set(eventName, []);
182
+ }
183
+ const listeners = this.listeners.get(eventName);
184
+ if (!listeners) {
185
+ throw new Error(`Listeners for event "${eventName}" not found.`);
186
+ }
187
+ const listener = {
188
+ callback,
189
+ id: listenerId
190
+ };
191
+ listeners.push(listener);
192
+
193
+ // Return unsubscribe function
194
+ return () => {
195
+ const currentListeners = this.listeners.get(eventName);
196
+ if (currentListeners) {
197
+ const index = currentListeners.findIndex(l => l.id === listenerId);
198
+ if (index !== -1) {
199
+ currentListeners.splice(index, 1);
200
+ }
201
+
202
+ // Clean up empty listener arrays
203
+ if (currentListeners.length === 0) {
204
+ this.listeners.delete(eventName);
205
+ }
206
+ }
207
+ };
208
+ }
209
+
210
+ /**
211
+ * Remove all listeners for a specific event.
212
+ * This completely removes the event from the internal listeners map.
213
+ *
214
+ * @param eventName - The name of the event to remove all listeners for
215
+ *
216
+ * @example
217
+ * ```typescript
218
+ * const eventBus = SecureEventBus.getInstance();
219
+ *
220
+ * // Remove all listeners for 'chatClosed' event
221
+ * eventBus.removeAllListeners('chatClosed');
222
+ * ```
223
+ */
224
+ }, {
225
+ key: "removeAllListeners",
226
+ value: function removeAllListeners(eventName) {
227
+ this.listeners.delete(eventName);
228
+ }
229
+
230
+ /**
231
+ * Clear all listeners for all events.
232
+ * This resets the entire event bus to its initial state.
233
+ * Useful for cleanup during application shutdown or testing.
234
+ *
235
+ * @example
236
+ * ```typescript
237
+ * const eventBus = SecureEventBus.getInstance();
238
+ *
239
+ * // Clear all event listeners
240
+ * eventBus.clear();
241
+ * ```
242
+ */
243
+ }, {
244
+ key: "clear",
245
+ value: function clear() {
246
+ this.listeners.clear();
247
+ }
248
+
249
+ /**
250
+ * Get the number of listeners for a specific event.
251
+ * Useful for debugging and monitoring purposes.
252
+ *
253
+ * @param eventName - The name of the event to count listeners for
254
+ * @returns The number of listeners registered for the event
255
+ *
256
+ * @example
257
+ * ```typescript
258
+ * const eventBus = SecureEventBus.getInstance();
259
+ *
260
+ * // Check how many listeners are registered for 'userAction'
261
+ * const count = eventBus.getListenerCount('userAction');
262
+ * console.log(`${count} listeners registered for userAction`);
263
+ * ```
264
+ */
265
+ }, {
266
+ key: "getListenerCount",
267
+ value: function getListenerCount(eventName) {
268
+ var _this$listeners$get;
269
+ return ((_this$listeners$get = this.listeners.get(eventName)) === null || _this$listeners$get === void 0 ? void 0 : _this$listeners$get.length) || 0;
270
+ }
271
+
272
+ /**
273
+ * Get all registered event names.
274
+ * Returns an array of event names that currently have listeners.
275
+ * Useful for debugging and monitoring purposes.
276
+ *
277
+ * @returns An array of event names that have registered listeners
278
+ *
279
+ * @example
280
+ * ```typescript
281
+ * const eventBus = SecureEventBus.getInstance();
282
+ *
283
+ * // Get all registered events
284
+ * const events = eventBus.getRegisteredEvents();
285
+ * console.log('Active events:', events);
286
+ * // Output: ['userAction', 'chatMessage', 'windowResize']
287
+ * ```
288
+ */
289
+ }, {
290
+ key: "getRegisteredEvents",
291
+ value: function getRegisteredEvents() {
292
+ return Array.from(this.listeners.keys());
293
+ }
294
+ }], [{
295
+ key: "getInstance",
296
+ value: function getInstance() {
297
+ if (!SecureEventBus.instance) {
298
+ SecureEventBus.instance = new SecureEventBus();
299
+ }
300
+ return SecureEventBus.instance;
301
+ }
302
+ }]);
303
+ return SecureEventBus;
304
+ }();
305
+ _defineProperty(SecureEventBus, "instance", null);
306
+ var _default = SecureEventBus;
307
+ exports.default = _default;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _SecureEventBus = _interopRequireDefault(require("./SecureEventBus"));
8
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
+ const dispatchCustomEvent = (name, payload) => {
11
+ try {
12
+ const eventBus = _SecureEventBus.default.getInstance();
13
+ const authToken = eventBus.getAuthToken();
14
+
15
+ // Dispatch through the secure event bus instead of global window
16
+ const success = eventBus.dispatch(name, payload, authToken);
17
+ if (!success) {
18
+ console.error("Failed to dispatch secure event:", name);
19
+ }
20
+ } catch (error) {
21
+ console.error("Error dispatching secure custom event:", name, payload, error);
22
+ }
23
+ };
24
+ var _default = dispatchCustomEvent;
25
+ exports.default = _default;
@@ -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,199 @@
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
+ var _props$styleProps3;
23
+ (0, _react.useEffect)(() => {
24
+ uiTimer = (0, _utils.createTimer)();
25
+ _TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
26
+ Event: _TelemetryConstants.TelemetryEvent.UXCitationPaneStart
27
+ });
28
+ }, []);
29
+ const initialTabIndexMap = new Map();
30
+ let elements = [];
31
+
32
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
33
+ const [state, dispatch] = (0, _useChatContextStore.default)();
34
+
35
+ // Use props.id if provided, otherwise fall back to default
36
+ const controlId = props.id || _Constants.HtmlAttributeNames.ocwCitationPaneClassName;
37
+
38
+ // Pane style computed to match the webchat widget container bounds so the pane
39
+ // stays within the widget and scrolls only vertically. We also track an
40
+ // "isReady" flag so we don't render the pane contents until the style is
41
+ // computed — this prevents a transient render that can appear as a flicker.
42
+ const [paneStyle, setPaneStyle] = (0, _react.useState)(null);
43
+ const [isReady, setIsReady] = (0, _react.useState)(false);
44
+
45
+ // Move focus to the container
46
+ (0, _react.useEffect)(() => {
47
+ (0, _utils.preventFocusToMoveOutOfElement)(controlId);
48
+ const focusableElements = (0, _utils.findAllFocusableElement)(`#${controlId}`);
49
+ requestAnimationFrame(() => {
50
+ if (focusableElements && focusableElements.length > 0 && focusableElements[0]) {
51
+ focusableElements[0].focus({
52
+ preventScroll: true
53
+ });
54
+ }
55
+ });
56
+ elements = (0, _utils.findParentFocusableElementsWithoutChildContainer)(controlId);
57
+ (0, _utils.setTabIndices)(elements, initialTabIndexMap, false);
58
+ _TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
59
+ Event: _TelemetryConstants.TelemetryEvent.CitationPaneLoaded
60
+ });
61
+ _TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
62
+ Event: _TelemetryConstants.TelemetryEvent.UXCitationPaneCompleted,
63
+ ElapsedTimeInMilliseconds: uiTimer.milliSecondsElapsed
64
+ });
65
+ }, []);
66
+
67
+ // Compute the widget bounds and set pane style accordingly (95% of widget size
68
+ // and centered inside the widget). If the widget container can't be found,
69
+ // fall back to the default pane styles from defaultCitationPaneProps.
70
+ (0, _react.useEffect)(() => {
71
+ const compute = () => {
72
+ var _props$styleProps2;
73
+ try {
74
+ const container = document.querySelector(".webchat__stacked-layout_container");
75
+ if (container) {
76
+ var _props$styleProps;
77
+ const rect = container.getBoundingClientRect();
78
+ const widthPx = Math.round(rect.width * 0.95);
79
+ const heightPx = Math.round(rect.height * 0.95);
80
+ const leftPx = Math.round(rect.left + (rect.width - widthPx) / 2);
81
+ const topPx = Math.round(rect.top + (rect.height - heightPx) / 2);
82
+ // Clone defaults and remove transform so explicit left/top pixel
83
+ // coordinates are respected and the pane stays within the
84
+ // widget bounds.
85
+ const base = Object.assign({}, _defaultCitationPaneProps.defaultCitationPaneStyles.pane);
86
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
87
+ if (base && base.transform) {
88
+ // remove centering transform when we compute exact pixel coords
89
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
90
+ delete base.transform;
91
+ }
92
+
93
+ // Merge user styles first, then computed positioning to ensure proper positioning
94
+ const computedStyle = {
95
+ left: `${leftPx}px`,
96
+ top: `${topPx}px`,
97
+ width: `${widthPx}px`,
98
+ height: `${heightPx}px`
99
+ };
100
+
101
+ // Apply user styles first, then override with computed positioning
102
+ const generalProps = (_props$styleProps = props.styleProps) === null || _props$styleProps === void 0 ? void 0 : _props$styleProps.generalStyleProps;
103
+ const userStyles = generalProps && typeof generalProps === "object" ? Object.assign({}, generalProps) : {};
104
+ // Remove positioning properties from user styles that would interfere
105
+ delete userStyles.position;
106
+ delete userStyles.left;
107
+ delete userStyles.top;
108
+ delete userStyles.width;
109
+ delete userStyles.height;
110
+ setPaneStyle(Object.assign({}, base, userStyles, computedStyle));
111
+ // Make the pane visible after the next paint to avoid layout
112
+ // flashes on initial mount.
113
+ requestAnimationFrame(() => setIsReady(true));
114
+ return;
115
+ }
116
+ } catch (e) {
117
+ // ignore
118
+ }
119
+
120
+ // fallback - merge defaults with user-provided styles but preserve positioning
121
+ const generalProps = (_props$styleProps2 = props.styleProps) === null || _props$styleProps2 === void 0 ? void 0 : _props$styleProps2.generalStyleProps;
122
+ const userStyles = generalProps && typeof generalProps === "object" ? Object.assign({}, generalProps) : {};
123
+ // Remove positioning properties from user styles for fallback
124
+ delete userStyles.position;
125
+ delete userStyles.left;
126
+ delete userStyles.top;
127
+ delete userStyles.width;
128
+ delete userStyles.height;
129
+ const fallbackStyle = Object.assign({}, _defaultCitationPaneProps.defaultCitationPaneStyles.pane, userStyles);
130
+ setPaneStyle(fallbackStyle);
131
+ requestAnimationFrame(() => setIsReady(true));
132
+ };
133
+ compute();
134
+ window.addEventListener("resize", compute);
135
+ return () => window.removeEventListener("resize", compute);
136
+ }, [(_props$styleProps3 = props.styleProps) === null || _props$styleProps3 === void 0 ? void 0 : _props$styleProps3.generalStyleProps]);
137
+ const handleClose = () => {
138
+ if (props.onClose) props.onClose();
139
+ dispatch({
140
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_PREVIOUS_FOCUSED_ELEMENT_ID,
141
+ payload: null
142
+ });
143
+ (0, _utils.setTabIndices)(elements, initialTabIndexMap, true);
144
+ };
145
+
146
+ // Merge a safe style object for the container and cast to CSSProperties to satisfy TS
147
+ const baseStyle = Object.assign({
148
+ position: "relative"
149
+ }, paneStyle ?? {
150
+ position: "fixed"
151
+ });
152
+
153
+ // If paneStyle hasn't been computed yet, render the DimLayer so clicks
154
+ // still close overlays but hide the pane itself to avoid flashes.
155
+ const hiddenStyle = {
156
+ visibility: isReady ? "visible" : "hidden",
157
+ pointerEvents: isReady ? "auto" : "none"
158
+ };
159
+
160
+ // Default wrapper styles - these control the positioning container
161
+ const defaultWrapperStyles = {
162
+ display: "flex",
163
+ flexDirection: "column",
164
+ zIndex: 10001
165
+ };
166
+
167
+ // Wrapper styles for the positioning container
168
+ const wrapperStyles = Object.assign({}, baseStyle, hiddenStyle, defaultWrapperStyles);
169
+
170
+ // Merge the computed positioning styles with user's generalStyleProps for the CitationPane
171
+ const mergedStyleProps = props.styleProps ? {
172
+ ...props.styleProps,
173
+ generalStyleProps: Object.assign({}, props.styleProps.generalStyleProps)
174
+ } : undefined;
175
+ const controlProps = {
176
+ id: controlId,
177
+ dir: state.domainStates.globalDir,
178
+ titleText: props.title,
179
+ contentHtml: props.contentHtml,
180
+ brightnessValueOnDim: "0.2",
181
+ // Default brightness
182
+ onClose: handleClose,
183
+ ...(props === null || props === void 0 ? void 0 : props.controlProps) // User props override defaults
184
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
185
+ };
186
+
187
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_CitationDim.default, {
188
+ brightness: controlProps.brightnessValueOnDim
189
+ }), /*#__PURE__*/_react.default.createElement("div", {
190
+ style: wrapperStyles
191
+ }, /*#__PURE__*/_react.default.createElement(_omnichannelChatComponents.CitationPane, {
192
+ componentOverrides: props === null || props === void 0 ? void 0 : props.componentOverrides,
193
+ controlProps: controlProps,
194
+ styleProps: mergedStyleProps
195
+ })));
196
+ };
197
+ exports.CitationPaneStateful = CitationPaneStateful;
198
+ var _default = CitationPaneStateful;
199
+ exports.default = _default;