@davi-ai/retorik-framework 1.0.17 → 1.0.18

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.
package/dist/index.js CHANGED
@@ -1204,10 +1204,11 @@ const $5f7f457957bd2c8d$var$initialState = {
1204
1204
  activeRecognitionState: (0, $71c613e2e831c34c$export$3f0071308968cd80).Closed,
1205
1205
  lastRecognitionInterim: "",
1206
1206
  streamingReplyToId: null,
1207
- streamingReplyToIdForText: null,
1208
1207
  streamingQueue: [],
1209
1208
  streamingQueueForText: [],
1210
- currentStreaming: null
1209
+ currentStreaming: null,
1210
+ streamingQueueFullLength: 0,
1211
+ streamingReplyToIdToIgnore: null
1211
1212
  };
1212
1213
  const $5f7f457957bd2c8d$export$f299240efcda25a2 = (0, $dWhh5$zustand.create)()(()=>{
1213
1214
  return $5f7f457957bd2c8d$var$initialState;
@@ -1266,16 +1267,7 @@ const $5f7f457957bd2c8d$export$a5c8d6d0ec4b5ccb = (value)=>{
1266
1267
  };
1267
1268
  const $5f7f457957bd2c8d$export$614a80601162ec38 = (value)=>{
1268
1269
  $5f7f457957bd2c8d$export$f299240efcda25a2.setState({
1269
- streamingReplyToId: value,
1270
- streamingReplyToIdForText: value
1271
- });
1272
- value === null && $5f7f457957bd2c8d$export$f299240efcda25a2.setState({
1273
- currentStreaming: null
1274
- });
1275
- };
1276
- const $5f7f457957bd2c8d$export$de8aad637f733113 = (value)=>{
1277
- $5f7f457957bd2c8d$export$f299240efcda25a2.setState({
1278
- streamingReplyToIdForText: value
1270
+ streamingReplyToId: value
1279
1271
  });
1280
1272
  };
1281
1273
  const $5f7f457957bd2c8d$export$87afd75c41a617d7 = (value)=>{
@@ -1285,11 +1277,12 @@ const $5f7f457957bd2c8d$export$87afd75c41a617d7 = (value)=>{
1285
1277
  });
1286
1278
  };
1287
1279
  const $5f7f457957bd2c8d$export$9a026d007e335fc0 = (value)=>{
1288
- if (value.replyToId) {
1280
+ const idToIgnore = $5f7f457957bd2c8d$export$f299240efcda25a2.getState().streamingReplyToIdToIgnore;
1281
+ if (value.replyToId && value.replyToId !== idToIgnore) {
1289
1282
  // Set replyToId and new queue if replyToId is different from the current one
1290
1283
  if ($5f7f457957bd2c8d$export$f299240efcda25a2.getState().streamingReplyToId !== value.replyToId) $5f7f457957bd2c8d$export$f299240efcda25a2.setState({
1284
+ streamingQueueFullLength: 0,
1291
1285
  streamingReplyToId: value.replyToId,
1292
- streamingReplyToIdForText: value.replyToId,
1293
1286
  streamingQueue: [
1294
1287
  value
1295
1288
  ],
@@ -1322,11 +1315,36 @@ const $5f7f457957bd2c8d$export$eb50624bfd363865 = ()=>{
1322
1315
  });
1323
1316
  }
1324
1317
  };
1318
+ const $5f7f457957bd2c8d$export$8505d436556ca045 = (replyToId)=>{
1319
+ const currentId = $5f7f457957bd2c8d$export$f299240efcda25a2.getState().streamingReplyToId;
1320
+ currentId !== replyToId && $5f7f457957bd2c8d$export$c3296e37e9ef3fed();
1321
+ };
1322
+ const $5f7f457957bd2c8d$export$c3296e37e9ef3fed = ()=>{
1323
+ const currentId = $5f7f457957bd2c8d$export$f299240efcda25a2.getState().streamingReplyToId;
1324
+ $5f7f457957bd2c8d$export$f299240efcda25a2.setState({
1325
+ streamingReplyToId: null,
1326
+ streamingQueue: [],
1327
+ streamingQueueForText: [],
1328
+ currentStreaming: null,
1329
+ streamingQueueFullLength: 0,
1330
+ streamingReplyToIdToIgnore: currentId
1331
+ });
1332
+ };
1325
1333
  const $5f7f457957bd2c8d$export$d300d9470f5679ba = (value)=>{
1326
1334
  $5f7f457957bd2c8d$export$f299240efcda25a2.setState({
1327
1335
  currentStreaming: value
1328
1336
  });
1329
1337
  };
1338
+ const $5f7f457957bd2c8d$export$e9ca045daeb00700 = (value, replyToId)=>{
1339
+ if (replyToId) {
1340
+ const currentStreamingId = $5f7f457957bd2c8d$export$f299240efcda25a2.getState().streamingReplyToId;
1341
+ replyToId === currentStreamingId && $5f7f457957bd2c8d$export$f299240efcda25a2.setState({
1342
+ streamingQueueFullLength: value
1343
+ });
1344
+ } else $5f7f457957bd2c8d$export$f299240efcda25a2.setState({
1345
+ streamingQueueFullLength: value
1346
+ });
1347
+ };
1330
1348
  const $5f7f457957bd2c8d$export$b6d2196a3ce412d8 = ()=>{
1331
1349
  $5f7f457957bd2c8d$export$f299240efcda25a2.setState({
1332
1350
  ...$5f7f457957bd2c8d$var$initialState
@@ -1370,7 +1388,9 @@ const $9acd31406c230961$var$addActivity = async (activity, resetQueue)=>{
1370
1388
  const isBot = activity.from.role === "bot" || activity.replyToId || ((_activity_from_name = activity.from.name) === null || _activity_from_name === void 0 ? void 0 : _activity_from_name.toLowerCase()) === "bot";
1371
1389
  if (activity.type === "message") {
1372
1390
  if (isBot) {
1373
- var _currentState_botMessageActivities, _activity_replyToId;
1391
+ var _activity_value, _currentState_botMessageActivities, _activity_replyToId;
1392
+ // If this activity is the one concluding a streaming, let's set the amount of streams previously generated
1393
+ if (!currentState.retrievingConversation && ((_activity_value = activity.value) === null || _activity_value === void 0 ? void 0 : _activity_value.streamingCount)) (0, $5f7f457957bd2c8d$export$e9ca045daeb00700)(activity.value.streamingCount, activity.replyToId);
1374
1394
  if (((_currentState_botMessageActivities = currentState.botMessageActivities) === null || _currentState_botMessageActivities === void 0 ? void 0 : _currentState_botMessageActivities.length) && ((_activity_replyToId = activity.replyToId) === null || _activity_replyToId === void 0 ? void 0 : _activity_replyToId.substring(activity.replyToId.length - 4)) === "0000") // Special process when retrieving conversation from directline : the first activity is delayed by botframwork-webchat and is treated after the other.
1375
1395
  // We must put this activity back in first place in the array.
1376
1396
  $9acd31406c230961$export$b56465394e2b1287.setState({
@@ -1497,6 +1517,8 @@ const $9acd31406c230961$export$f9786f6b1a1e81e3 = (activity)=>{
1497
1517
  $9acd31406c230961$var$timerRef && clearTimeout($9acd31406c230961$var$timerRef);
1498
1518
  $9acd31406c230961$var$timerRef = setTimeout(()=>{
1499
1519
  $9acd31406c230961$var$updateActivities();
1520
+ // Let speechStore check if this activity has an impact on a curent streaming
1521
+ (0, $5f7f457957bd2c8d$export$8505d436556ca045)(activity.replyToId);
1500
1522
  }, 500);
1501
1523
  };
1502
1524
  const $9acd31406c230961$export$210f7e70e69f7df5 = (activity)=>{
@@ -1508,12 +1530,6 @@ const $9acd31406c230961$export$210f7e70e69f7df5 = (activity)=>{
1508
1530
  const currentConversationId = $9acd31406c230961$export$b56465394e2b1287.getState().conversationId;
1509
1531
  currentConversationId && ((_activity_id = activity.id) === null || _activity_id === void 0 ? void 0 : _activity_id.includes(currentConversationId)) && $9acd31406c230961$export$f9786f6b1a1e81e3(activity);
1510
1532
  };
1511
- const $9acd31406c230961$export$35bf93b87d9ffb15 = (activity)=>{
1512
- var _activity_id;
1513
- const retrieving = $9acd31406c230961$export$b56465394e2b1287.getState().retrievingConversation;
1514
- const currentConversationId = $9acd31406c230961$export$b56465394e2b1287.getState().conversationId;
1515
- currentConversationId && !retrieving && ((_activity_id = activity.id) === null || _activity_id === void 0 ? void 0 : _activity_id.includes(currentConversationId)) && (0, $5f7f457957bd2c8d$export$9a026d007e335fc0)(activity);
1516
- };
1517
1533
  const $9acd31406c230961$export$4365557467e67cdc = (value)=>{
1518
1534
  const currentState = $9acd31406c230961$export$b56465394e2b1287.getState();
1519
1535
  // Check directline id to know if we have to reset the activities
@@ -1550,7 +1566,6 @@ const $9acd31406c230961$export$b7b23f8e09258fa6 = ()=>{
1550
1566
  };
1551
1567
 
1552
1568
 
1553
-
1554
1569
  const $c79349f4444d81d7$var$regexDataCommand = /(\{data-command=")[\p{L}\p{N}\p{Po}\p{Pd}\p{Pc}\s\u0027\u2019]+("\})(<br\s\/>)?/gu;
1555
1570
  const $c79349f4444d81d7$var$createCustomStore = (enableConversationCookie, conversationCookieMaxAge, addressData, locale, externalEventHandler, isUsedOnBorne, isRetorikNews)=>{
1556
1571
  return (0, $dWhh5$botframeworkwebchat.createStore)({}, ({ dispatch: dispatch })=>(next)=>async (action)=>{
@@ -1641,10 +1656,14 @@ const $c79349f4444d81d7$var$createCustomStore = (enableConversationCookie, conve
1641
1656
  var _action_payload_activity_text;
1642
1657
  if ((_action_payload_activity_text = action.payload.activity.text) === null || _action_payload_activity_text === void 0 ? void 0 : _action_payload_activity_text.trim().length) {
1643
1658
  // Create speak field from the text one
1644
- const processedText = (0, $48f0df83bc0817a8$export$1b8fbc30fb87d9aa)(action.payload.activity.text, true);
1645
- action.payload.activity.text = processedText.text;
1659
+ // const processedText = processMarkdownAndSpeechMarkdown(
1660
+ // action.payload.activity.text,
1661
+ // true
1662
+ // )
1663
+ const processedText = (0, $175044c5f3c2d8cc$export$2e2bcd8739ae039)(action);
1664
+ // action.payload.activity.text = processedText.htmlText
1646
1665
  action.payload.activity.speak = processedText.text;
1647
- (0, $9acd31406c230961$export$35bf93b87d9ffb15)(action.payload.activity);
1666
+ (0, $5f7f457957bd2c8d$export$9a026d007e335fc0)(action.payload.activity);
1648
1667
  }
1649
1668
  return next(action);
1650
1669
  }
@@ -5437,17 +5456,15 @@ const $0425d21c89c76455$var$DiscoverAttachment = ({ title: title, mainButtons: m
5437
5456
  } else if (index !== undefined) {
5438
5457
  setDiscoverClicked(index);
5439
5458
  const tempData = data;
5440
- const value = tempData.FilterId ? {
5459
+ dataToSend = {
5460
+ type: "event",
5461
+ name: tempData.EventName,
5441
5462
  value: {
5442
5463
  filterId: tempData.FilterId,
5443
5464
  filterValue: tempData.FilterValue,
5444
- followingCardText: tempData.FollowingCardText
5465
+ followingCardText: tempData.FollowingCardText,
5466
+ identifier: tempData.Identifier
5445
5467
  }
5446
- } : {};
5447
- dataToSend = {
5448
- type: "event",
5449
- name: tempData.EventName,
5450
- ...value
5451
5468
  };
5452
5469
  }
5453
5470
  sendPostBack(dataToSend);
@@ -15645,7 +15662,6 @@ const $1068fd56b5926747$export$f0e9d14ede4c01bd = ()=>{
15645
15662
 
15646
15663
 
15647
15664
 
15648
-
15649
15665
  const $016ac743b008b7bc$export$aa0c5ba341a0028 = ({ agentName: agentName = "L\xe9a", companyName: companyName, companyNameLocalized: companyNameLocalized, subCompanyMessage: subCompanyMessage, subCompanyMessageLocalized: subCompanyMessageLocalized, imageUrl: imageUrl = "" })=>{
15650
15666
  const locale = (0, $b6a8688e7db7a7b9$export$6650dace022cfacc)((state)=>state.locale);
15651
15667
  const translation = (0, $b6a8688e7db7a7b9$export$6650dace022cfacc)((state)=>state.currentTranslations);
@@ -15705,107 +15721,131 @@ const $016ac743b008b7bc$export$aa0c5ba341a0028 = ({ agentName: agentName = "L\xe
15705
15721
  };
15706
15722
 
15707
15723
 
15708
- const $a2a195f52aaf1332$var$DisplayStandard = ({ botResponses: botResponses, isMobile: isMobile })=>{
15709
- const locale = (0, $b6a8688e7db7a7b9$export$6650dace022cfacc)((state)=>state.locale);
15710
- const { configuration: { forceMobileView: forceMobileView } } = (0, $1d4f8108de9ab73a$export$d8760bee47331b1d)();
15711
- return /*#__PURE__*/ (0, $dWhh5$reactjsxruntime.jsx)("div", {
15712
- id: "retorik-botResponses",
15713
- className: "rf-flex rf-flex-col rf-text-size-auto rf-gap-2 rf-scrollbar-hidden",
15714
- children: botResponses.map((activity, key)=>{
15715
- var _activity_attachments;
15716
- const answerTime = activity.localTimestamp ? new Date(activity.localTimestamp) : activity.timestamp ? new Date(activity.timestamp) : new Date();
15717
- return /*#__PURE__*/ (0, $dWhh5$reactjsxruntime.jsxs)("div", {
15718
- className: `${key > 0 && "rf-pt-2"} rf-text-textModePanelConversationBot rf-animate-slideBottom rf-flex rf-flex-col rf-items-start rf-gap-2`,
15719
- children: [
15720
- isMobile && /*#__PURE__*/ (0, $dWhh5$reactjsxruntime.jsx)("div", {
15721
- className: "rf-px-4 rf-text-[#9A9A9A]",
15722
- children: answerTime.toLocaleString(locale, {
15723
- hour: "numeric",
15724
- minute: "numeric"
15725
- })
15726
- }),
15727
- activity.htmlText ? /*#__PURE__*/ (0, $dWhh5$reactjsxruntime.jsx)("div", {
15728
- className: "rf-px-4",
15729
- dangerouslySetInnerHTML: {
15730
- __html: activity.htmlText
15731
- }
15732
- }) : activity.text ? /*#__PURE__*/ (0, $dWhh5$reactjsxruntime.jsx)("div", {
15733
- className: "rf-px-4",
15734
- children: (0, $547da4225675b90f$export$d6c6ec86eedacfd9)(activity.text)
15735
- }) : /*#__PURE__*/ (0, $dWhh5$reactjsxruntime.jsx)((0, ($parcel$interopDefault($dWhh5$react))).Fragment, {}),
15736
- !!(activity === null || activity === void 0 ? void 0 : (_activity_attachments = activity.attachments) === null || _activity_attachments === void 0 ? void 0 : _activity_attachments.length) && !(0, $1a0bdae30bc87d45$export$7c55936a30618336)(activity) && /*#__PURE__*/ (0, $dWhh5$reactjsxruntime.jsx)("div", {
15737
- className: `${forceMobileView ? "rf-m-auto" : "rf-w-full"} ${activity.attachments.length <= 1 && "rf-px-4"} rf-flex rf-flex-col rf-gap-2`,
15738
- children: /*#__PURE__*/ (0, $dWhh5$reactjsxruntime.jsx)((0, $c0f9a707e7db7f07$export$2e2bcd8739ae039), {
15739
- activity: activity
15740
- })
15741
- })
15742
- ]
15743
- }, key);
15744
- })
15745
- });
15746
- };
15747
- var $a2a195f52aaf1332$export$2e2bcd8739ae039 = $a2a195f52aaf1332$var$DisplayStandard;
15748
15724
 
15749
15725
 
15750
15726
 
15751
15727
 
15752
15728
 
15753
- const $8113fa9a024156c4$var$interval = 25;
15754
- const $8113fa9a024156c4$var$DisplayStreaming = ({ streamingQueue: streamingQueue, triggerScroll: triggerScroll })=>{
15729
+
15730
+
15731
+ const $8113fa9a024156c4$var$interval = 150 // 20 // 25
15732
+ ;
15733
+ const $8113fa9a024156c4$var$md = new (0, ($parcel$interopDefault($dWhh5$markdownit)))({
15734
+ breaks: true,
15735
+ html: true,
15736
+ xhtmlOut: true,
15737
+ typographer: true,
15738
+ quotes: `""''`
15739
+ });
15740
+ const $8113fa9a024156c4$var$DisplayStreaming = ({ triggerScroll: triggerScroll, setStreamingEnded: setStreamingEnded, streamingActivity: streamingActivity, currentStreaming: currentStreaming, isMobile: isMobile })=>{
15741
+ var _streamingActivity_attachments;
15742
+ const locale = (0, $b6a8688e7db7a7b9$export$6650dace022cfacc)((state)=>state.locale);
15743
+ const streamingQueue = (0, $5f7f457957bd2c8d$export$f299240efcda25a2)((state)=>state.streamingQueueForText);
15744
+ const streamingCount = (0, $5f7f457957bd2c8d$export$f299240efcda25a2)((state)=>state.streamingQueueFullLength);
15745
+ const { configuration: { forceMobileView: forceMobileView } } = (0, $1d4f8108de9ab73a$export$d8760bee47331b1d)();
15755
15746
  const [streamingTextToDisplay, setStreamingTextToDisplay] = (0, $dWhh5$react.useState)("");
15756
15747
  const [currentTextEnded, setCurrentTextEnded] = (0, $dWhh5$react.useState)(true);
15757
15748
  const [currentQueueIndex, setCurrentQueueIndex] = (0, $dWhh5$react.useState)(0);
15749
+ const time = (0, $dWhh5$react.useMemo)(()=>{
15750
+ if (streamingQueue.length) {
15751
+ const answerTime = streamingQueue[0].localTimestamp ? new Date(streamingQueue[0].localTimestamp) : streamingQueue[0].timestamp ? new Date(streamingQueue[0].timestamp) : new Date();
15752
+ return answerTime;
15753
+ }
15754
+ return null;
15755
+ }, [
15756
+ streamingQueue
15757
+ ]);
15758
15758
  const intervalRef = (0, $dWhh5$react.useRef)(null);
15759
15759
  const streamRef = (0, $dWhh5$react.useRef)([]);
15760
+ const streamIndexRef = (0, $dWhh5$react.useRef)(0);
15761
+ const previousTextRef = (0, $dWhh5$react.useRef)([]);
15762
+ // const handleNewStreaming = (text: string): void => {
15763
+ // text = md.render(text)
15764
+ // if (previousTextRef.current) {
15765
+ // for (let i = 0; i < previousTextRef.current.length; i++) {
15766
+ // if (text[i] !== previousTextRef.current[i]) {
15767
+ // streamIndexRef.current = i
15768
+ // break
15769
+ // }
15770
+ // }
15771
+ // } else {
15772
+ // streamIndexRef.current = 0
15773
+ // }
15774
+ // setCurrentTextEnded(false)
15775
+ // streamRef.current = text.split('')
15776
+ // previousTextRef.current = text
15777
+ // streamIndexRef.current !== streamingTextToDisplay.length &&
15778
+ // setStreamingTextToDisplay((value) =>
15779
+ // value.substring(0, streamIndexRef.current)
15780
+ // )
15781
+ // intervalRef.current = setInterval(() => {
15782
+ // if (streamIndexRef.current < streamRef.current?.length) {
15783
+ // const current = streamRef.current[streamIndexRef.current]
15784
+ // setStreamingTextToDisplay((value) => `${value}${current}`)
15785
+ // streamIndexRef.current = streamIndexRef.current + 1
15786
+ // } else {
15787
+ // setCurrentTextEnded(true)
15788
+ // intervalRef.current && clearInterval(intervalRef.current)
15789
+ // }
15790
+ // }, interval)
15791
+ // }
15760
15792
  const handleNewStreaming = (text)=>{
15793
+ text = $8113fa9a024156c4$var$md.render(text);
15794
+ streamRef.current = text.split(" ");
15761
15795
  setCurrentTextEnded(false);
15762
- // Create array containing indexes of \n parts to replace them with html <br /> tag later
15763
- const slashNIndexesArray = [];
15764
- let searchIndex = 0;
15765
- while(text.indexOf("\n", searchIndex) !== -1){
15766
- const index = text.indexOf("\n", searchIndex);
15767
- slashNIndexesArray.push(index);
15768
- searchIndex = index + 2;
15769
- }
15770
- streamRef.current = text.split("");
15771
- let currentIndex = 0;
15772
15796
  intervalRef.current = setInterval(()=>{
15773
- var _streamRef_current;
15774
- if ((_streamRef_current = streamRef.current) === null || _streamRef_current === void 0 ? void 0 : _streamRef_current.length) {
15775
- const current = streamRef.current[0];
15776
- if (slashNIndexesArray.includes(currentIndex)) {
15777
- // If the current index is present in the array of indexes, then it means it is a \n so replace it with <br /> and jump 2 characters after
15778
- setStreamingTextToDisplay((value)=>`${value}<br />`);
15779
- streamRef.current = streamRef.current.slice(1);
15780
- } else {
15781
- setStreamingTextToDisplay((value)=>`${value}${current}`);
15782
- streamRef.current = streamRef.current.slice(1);
15783
- }
15784
- currentIndex++;
15797
+ if (streamIndexRef.current < streamRef.current.length - 1) {
15798
+ const current = streamRef.current[streamIndexRef.current];
15799
+ setStreamingTextToDisplay((value)=>`${value} ${current}`);
15800
+ streamIndexRef.current = streamIndexRef.current + 1;
15801
+ streamIndexRef.current % 10 === 0 && triggerScroll();
15785
15802
  } else {
15786
15803
  setCurrentTextEnded(true);
15804
+ triggerScroll();
15787
15805
  intervalRef.current && clearInterval(intervalRef.current);
15788
15806
  }
15789
15807
  }, $8113fa9a024156c4$var$interval);
15790
15808
  };
15809
+ const resetData = ()=>{
15810
+ setCurrentQueueIndex(0);
15811
+ streamIndexRef.current = 0;
15812
+ previousTextRef.current = [];
15813
+ (0, $5f7f457957bd2c8d$export$e9ca045daeb00700)(0);
15814
+ (intervalRef === null || intervalRef === void 0 ? void 0 : intervalRef.current) && clearInterval(intervalRef.current);
15815
+ };
15791
15816
  (0, $dWhh5$react.useEffect)(()=>{
15792
- if ((streamingQueue === null || streamingQueue === void 0 ? void 0 : streamingQueue.length) && currentTextEnded) {
15793
- if (streamingQueue.length > currentQueueIndex) {
15794
- handleNewStreaming(streamingQueue[currentQueueIndex].text || "");
15795
- setCurrentQueueIndex((value)=>value + 1);
15817
+ if (currentTextEnded && (streamingQueue === null || streamingQueue === void 0 ? void 0 : streamingQueue.length)) {
15818
+ if (streamingCount === 0 || currentQueueIndex < streamingCount) {
15819
+ if (streamingQueue.length > currentQueueIndex) {
15820
+ setStreamingEnded(false);
15821
+ let text = "";
15822
+ for(let i = 0; i <= currentQueueIndex; i++)text = text + streamingQueue[i].text;
15823
+ handleNewStreaming(text);
15824
+ setCurrentQueueIndex((value)=>value + 1);
15825
+ }
15796
15826
  } else {
15797
- setCurrentQueueIndex(0);
15798
- (0, $5f7f457957bd2c8d$export$de8aad637f733113)(null);
15827
+ let fullText = "";
15828
+ streamingQueue.forEach((activity)=>{
15829
+ fullText = `${fullText} ${activity.text}`;
15830
+ });
15831
+ setStreamingTextToDisplay($8113fa9a024156c4$var$md.render(fullText));
15832
+ setStreamingEnded(true);
15833
+ resetData();
15799
15834
  }
15800
15835
  }
15801
15836
  }, [
15802
15837
  streamingQueue,
15803
- currentTextEnded
15838
+ currentTextEnded,
15839
+ streamingCount
15804
15840
  ]);
15805
15841
  (0, $dWhh5$react.useEffect)(()=>{
15806
- streamingTextToDisplay.length % 20 === 0 && triggerScroll();
15842
+ if (!currentStreaming) {
15843
+ setCurrentTextEnded(true);
15844
+ setStreamingTextToDisplay("");
15845
+ resetData();
15846
+ }
15807
15847
  }, [
15808
- streamingTextToDisplay
15848
+ currentStreaming
15809
15849
  ]);
15810
15850
  (0, $dWhh5$react.useEffect)(()=>{
15811
15851
  return ()=>{
@@ -15813,17 +15853,30 @@ const $8113fa9a024156c4$var$DisplayStreaming = ({ streamingQueue: streamingQueue
15813
15853
  };
15814
15854
  }, []);
15815
15855
  return /*#__PURE__*/ (0, $dWhh5$reactjsxruntime.jsxs)("div", {
15816
- id: "retorik-botResponses",
15817
- className: "rf-flex rf-flex-col rf-text-size-auto rf-scrollbar-hidden",
15856
+ className: "rf-text-textModePanelConversationBot rf-flex rf-flex-col rf-items-start rf-gap-2",
15818
15857
  children: [
15858
+ isMobile && time && /*#__PURE__*/ (0, $dWhh5$reactjsxruntime.jsx)("div", {
15859
+ className: "rf-px-4 rf-text-[#9A9A9A]",
15860
+ children: time.toLocaleString(locale, {
15861
+ hour: "numeric",
15862
+ minute: "numeric"
15863
+ })
15864
+ }),
15819
15865
  streamingTextToDisplay && /*#__PURE__*/ (0, $dWhh5$reactjsxruntime.jsx)("div", {
15820
- className: "rf-px-4 rf-text-textModePanelConversationBot",
15866
+ className: "rf-px-4",
15821
15867
  dangerouslySetInnerHTML: {
15822
15868
  __html: streamingTextToDisplay
15823
15869
  }
15824
15870
  }),
15825
- currentQueueIndex !== 0 && /*#__PURE__*/ (0, $dWhh5$reactjsxruntime.jsx)("div", {
15826
- className: "rf-px-4 rf-font-bold rf-text-textModePanelConversationBot rf-animate-blink",
15871
+ currentQueueIndex === 0 ? /*#__PURE__*/ (0, $dWhh5$reactjsxruntime.jsx)((0, ($parcel$interopDefault($dWhh5$react))).Fragment, {
15872
+ children: !!(streamingActivity === null || streamingActivity === void 0 ? void 0 : (_streamingActivity_attachments = streamingActivity.attachments) === null || _streamingActivity_attachments === void 0 ? void 0 : _streamingActivity_attachments.length) && /*#__PURE__*/ (0, $dWhh5$reactjsxruntime.jsx)("div", {
15873
+ className: `${forceMobileView ? "rf-m-auto" : "rf-w-full"} ${streamingActivity.attachments.length <= 1 && "rf-px-4"}`,
15874
+ children: /*#__PURE__*/ (0, $dWhh5$reactjsxruntime.jsx)((0, $c0f9a707e7db7f07$export$2e2bcd8739ae039), {
15875
+ activity: streamingActivity
15876
+ })
15877
+ })
15878
+ }) : /*#__PURE__*/ (0, $dWhh5$reactjsxruntime.jsx)("div", {
15879
+ className: "rf-px-4 rf-font-bold rf-animate-blink",
15827
15880
  children: "..."
15828
15881
  })
15829
15882
  ]
@@ -15832,7 +15885,79 @@ const $8113fa9a024156c4$var$DisplayStreaming = ({ streamingQueue: streamingQueue
15832
15885
  var $8113fa9a024156c4$export$2e2bcd8739ae039 = $8113fa9a024156c4$var$DisplayStreaming;
15833
15886
 
15834
15887
 
15835
- const $4d9ea07b04f0d01b$var$ConversationDisplay = ({ userQuestion: userQuestion, botResponses: botResponses, streamingId: streamingId, streamingQueue: streamingQueue, userQuestionTime: userQuestionTime, isMobile: isMobile, triggerScroll: triggerScroll })=>{
15888
+
15889
+ const $a2a195f52aaf1332$var$DisplayStandard = ({ botResponses: botResponses, isMobile: isMobile, triggerScroll: triggerScroll, canBeStreaming: canBeStreaming })=>{
15890
+ const locale = (0, $b6a8688e7db7a7b9$export$6650dace022cfacc)((state)=>state.locale);
15891
+ const currentStreaming = (0, $5f7f457957bd2c8d$export$f299240efcda25a2)((state)=>state.currentStreaming);
15892
+ const streamingId = (0, $5f7f457957bd2c8d$export$f299240efcda25a2)((state)=>state.streamingReplyToId);
15893
+ const { configuration: { forceMobileView: forceMobileView } } = (0, $1d4f8108de9ab73a$export$d8760bee47331b1d)();
15894
+ const [streamingActivity, setStreamingActivity] = (0, $dWhh5$react.useState)(undefined);
15895
+ const [streamingEnded, setStreamingEnded] = (0, $dWhh5$react.useState)(false);
15896
+ const nonStreamingActivities = (0, $dWhh5$react.useMemo)(()=>{
15897
+ if (streamingActivity) return botResponses.filter((act)=>act.id !== streamingActivity.id && act.replyToId === streamingActivity.replyToId);
15898
+ return botResponses;
15899
+ }, [
15900
+ streamingActivity,
15901
+ botResponses
15902
+ ]);
15903
+ (0, $dWhh5$react.useEffect)(()=>{
15904
+ if (botResponses.length && currentStreaming) setStreamingActivity(botResponses.find((act)=>{
15905
+ var _act_value;
15906
+ return act.replyToId === streamingId && ((_act_value = act.value) === null || _act_value === void 0 ? void 0 : _act_value.streamingCount);
15907
+ }));
15908
+ else setStreamingActivity(undefined);
15909
+ }, [
15910
+ botResponses,
15911
+ currentStreaming,
15912
+ streamingId
15913
+ ]);
15914
+ return /*#__PURE__*/ (0, $dWhh5$reactjsxruntime.jsxs)((0, ($parcel$interopDefault($dWhh5$react))).Fragment, {
15915
+ children: [
15916
+ canBeStreaming && /*#__PURE__*/ (0, $dWhh5$reactjsxruntime.jsx)((0, $8113fa9a024156c4$export$2e2bcd8739ae039), {
15917
+ triggerScroll: triggerScroll,
15918
+ setStreamingEnded: setStreamingEnded,
15919
+ streamingActivity: streamingActivity,
15920
+ currentStreaming: currentStreaming,
15921
+ isMobile: isMobile
15922
+ }),
15923
+ (!streamingActivity || streamingActivity && streamingEnded) && nonStreamingActivities.map((activity, key)=>{
15924
+ var _activity_attachments;
15925
+ const answerTime = activity.localTimestamp ? new Date(activity.localTimestamp) : activity.timestamp ? new Date(activity.timestamp) : new Date();
15926
+ return /*#__PURE__*/ (0, $dWhh5$reactjsxruntime.jsxs)("div", {
15927
+ className: `${key > 0 && "rf-pt-2"} rf-text-textModePanelConversationBot rf-animate-slideBottom rf-flex rf-flex-col rf-items-start rf-gap-2`,
15928
+ children: [
15929
+ isMobile && /*#__PURE__*/ (0, $dWhh5$reactjsxruntime.jsx)("div", {
15930
+ className: "rf-px-4 rf-text-[#9A9A9A]",
15931
+ children: answerTime.toLocaleString(locale, {
15932
+ hour: "numeric",
15933
+ minute: "numeric"
15934
+ })
15935
+ }),
15936
+ activity.htmlText ? /*#__PURE__*/ (0, $dWhh5$reactjsxruntime.jsx)("div", {
15937
+ className: "rf-px-4",
15938
+ dangerouslySetInnerHTML: {
15939
+ __html: activity.htmlText
15940
+ }
15941
+ }) : activity.text ? /*#__PURE__*/ (0, $dWhh5$reactjsxruntime.jsx)("div", {
15942
+ className: "rf-px-4",
15943
+ children: (0, $547da4225675b90f$export$d6c6ec86eedacfd9)(activity.text)
15944
+ }) : /*#__PURE__*/ (0, $dWhh5$reactjsxruntime.jsx)((0, ($parcel$interopDefault($dWhh5$react))).Fragment, {}),
15945
+ !!(activity === null || activity === void 0 ? void 0 : (_activity_attachments = activity.attachments) === null || _activity_attachments === void 0 ? void 0 : _activity_attachments.length) && !(0, $1a0bdae30bc87d45$export$7c55936a30618336)(activity) && /*#__PURE__*/ (0, $dWhh5$reactjsxruntime.jsx)("div", {
15946
+ className: `${forceMobileView ? "rf-m-auto" : "rf-w-full"} ${activity.attachments.length <= 1 && "rf-px-4"} rf-flex rf-flex-col rf-gap-2`,
15947
+ children: /*#__PURE__*/ (0, $dWhh5$reactjsxruntime.jsx)((0, $c0f9a707e7db7f07$export$2e2bcd8739ae039), {
15948
+ activity: activity
15949
+ })
15950
+ })
15951
+ ]
15952
+ }, key);
15953
+ })
15954
+ ]
15955
+ });
15956
+ };
15957
+ var $a2a195f52aaf1332$export$2e2bcd8739ae039 = $a2a195f52aaf1332$var$DisplayStandard;
15958
+
15959
+
15960
+ const $4d9ea07b04f0d01b$var$ConversationDisplay = ({ userQuestion: userQuestion, botResponses: botResponses, userQuestionTime: userQuestionTime, isMobile: isMobile, triggerScroll: triggerScroll, canBeStreaming: canBeStreaming })=>{
15836
15961
  const locale = (0, $b6a8688e7db7a7b9$export$6650dace022cfacc)((state)=>state.locale);
15837
15962
  return /*#__PURE__*/ (0, $dWhh5$reactjsxruntime.jsxs)((0, ($parcel$interopDefault($dWhh5$react))).Fragment, {
15838
15963
  children: [
@@ -15853,12 +15978,15 @@ const $4d9ea07b04f0d01b$var$ConversationDisplay = ({ userQuestion: userQuestion,
15853
15978
  })
15854
15979
  ]
15855
15980
  }, userQuestion.id),
15856
- streamingId && (streamingQueue === null || streamingQueue === void 0 ? void 0 : streamingQueue.length) ? /*#__PURE__*/ (0, $dWhh5$reactjsxruntime.jsx)((0, $8113fa9a024156c4$export$2e2bcd8739ae039), {
15857
- streamingQueue: streamingQueue,
15858
- triggerScroll: triggerScroll
15859
- }) : /*#__PURE__*/ (0, $dWhh5$reactjsxruntime.jsx)((0, $a2a195f52aaf1332$export$2e2bcd8739ae039), {
15860
- botResponses: botResponses || [],
15861
- isMobile: isMobile
15981
+ /*#__PURE__*/ (0, $dWhh5$reactjsxruntime.jsx)("div", {
15982
+ id: "retorik-botResponses",
15983
+ className: "rf-flex rf-flex-col rf-text-size-auto rf-gap-2 rf-scrollbar-hidden",
15984
+ children: /*#__PURE__*/ (0, $dWhh5$reactjsxruntime.jsx)((0, $a2a195f52aaf1332$export$2e2bcd8739ae039), {
15985
+ triggerScroll: triggerScroll,
15986
+ botResponses: botResponses || [],
15987
+ isMobile: isMobile,
15988
+ canBeStreaming: canBeStreaming
15989
+ })
15862
15990
  })
15863
15991
  ]
15864
15992
  });
@@ -15880,8 +16008,6 @@ const $7df5d708684c32ba$var$ConversationPanelMobile = ({ homeActivity: homeActiv
15880
16008
  const [scrollButtonDisplay, setScrollButtonDisplay] = (0, $dWhh5$react.useState)(false);
15881
16009
  const [scrollButtonDirection, setScrollButtonDirection] = (0, $dWhh5$react.useState)("bottom");
15882
16010
  const [preventScroll, setPreventScroll] = (0, $dWhh5$react.useState)(false);
15883
- const streamingId = (0, $5f7f457957bd2c8d$export$f299240efcda25a2)((state)=>state.streamingReplyToIdForText);
15884
- const streamingQueue = (0, $5f7f457957bd2c8d$export$f299240efcda25a2)((state)=>state.streamingQueueForText);
15885
16011
  const retorikConversationRef = (0, $dWhh5$react.useRef)(null);
15886
16012
  const botEndRef = (0, $dWhh5$react.useRef)(null);
15887
16013
  const timerRef = (0, $dWhh5$react.useRef)(null);
@@ -15985,11 +16111,10 @@ const $7df5d708684c32ba$var$ConversationPanelMobile = ({ homeActivity: homeActiv
15985
16111
  children: /*#__PURE__*/ (0, $dWhh5$reactjsxruntime.jsx)((0, $4d9ea07b04f0d01b$export$2e2bcd8739ae039), {
15986
16112
  userQuestion: activity.question,
15987
16113
  botResponses: activity.answers,
15988
- streamingId: index === activities.length - 1 ? streamingId : null,
15989
- streamingQueue: streamingQueue,
15990
16114
  userQuestionTime: userQuestionTime,
15991
16115
  isMobile: true,
15992
- triggerScroll: ()=>scrollHandler("bottom", "newMessage")
16116
+ triggerScroll: ()=>scrollHandler("bottom", "newMessage"),
16117
+ canBeStreaming: index === activities.length - 1
15993
16118
  })
15994
16119
  }, index);
15995
16120
  }),
@@ -16010,8 +16135,7 @@ const $7df5d708684c32ba$var$ConversationPanelMobile = ({ homeActivity: homeActiv
16010
16135
  var $7df5d708684c32ba$export$2e2bcd8739ae039 = $7df5d708684c32ba$var$ConversationPanelMobile;
16011
16136
 
16012
16137
 
16013
-
16014
-
16138
+ /* eslint-disable react/jsx-boolean-value */
16015
16139
 
16016
16140
 
16017
16141
 
@@ -16021,8 +16145,6 @@ const $d65b086bfae1b3b3$var$ConversationPanelLarge = ({ homeActivity: homeActivi
16021
16145
  var _homeActivity_attachments, _homeActivity_attachments1;
16022
16146
  const activities = (0, $970df85ce5628c51$export$2e2bcd8739ae039)();
16023
16147
  const { mediumLandscape: mediumLandscape } = (0, $6acc5d637072b42e$export$3abe3478af3cb63b)();
16024
- const streamingId = (0, $5f7f457957bd2c8d$export$f299240efcda25a2)((state)=>state.streamingReplyToIdForText);
16025
- const streamingQueue = (0, $5f7f457957bd2c8d$export$f299240efcda25a2)((state)=>state.streamingQueueForText);
16026
16148
  const botEndRef = (0, $dWhh5$react.useRef)(null);
16027
16149
  const timerRef = (0, $dWhh5$react.useRef)(null);
16028
16150
  const userQuestion = (0, $dWhh5$react.useMemo)(()=>{
@@ -16054,7 +16176,7 @@ const $d65b086bfae1b3b3$var$ConversationPanelLarge = ({ homeActivity: homeActivi
16054
16176
  }, [
16055
16177
  itemsInConversation
16056
16178
  ]);
16057
- return (homeActivity === null || homeActivity === void 0 ? void 0 : (_homeActivity_attachments = homeActivity.attachments) === null || _homeActivity_attachments === void 0 ? void 0 : _homeActivity_attachments.length) || streamingId || userQuestion || botResponses ? /*#__PURE__*/ (0, $dWhh5$reactjsxruntime.jsx)("div", {
16179
+ return (homeActivity === null || homeActivity === void 0 ? void 0 : (_homeActivity_attachments = homeActivity.attachments) === null || _homeActivity_attachments === void 0 ? void 0 : _homeActivity_attachments.length) || userQuestion || botResponses ? /*#__PURE__*/ (0, $dWhh5$reactjsxruntime.jsx)("div", {
16058
16180
  className: `rf-relative rf-max-h-full ${mediumLandscape ? "rf-col-start-4" : "rf-col-start-5"} vertical:rf-col-start-1 rf-col-span-full rf-row-start-4 rf-row-end-12 large-vertical:rf-row-start-7 large-vertical:rf-row-span-6 rf-self-start rf-overflow-hidden rf-justify-self-center rf-w-3/5 rf-flex rf-flex-col rf-rounded rf-bg-textModePanelBackground`,
16059
16181
  children: /*#__PURE__*/ (0, $dWhh5$reactjsxruntime.jsxs)("div", {
16060
16182
  id: "retorik-conversation",
@@ -16068,9 +16190,8 @@ const $d65b086bfae1b3b3$var$ConversationPanelLarge = ({ homeActivity: homeActivi
16068
16190
  }) : /*#__PURE__*/ (0, $dWhh5$reactjsxruntime.jsx)((0, $4d9ea07b04f0d01b$export$2e2bcd8739ae039), {
16069
16191
  userQuestion: userQuestion,
16070
16192
  botResponses: botResponses,
16071
- streamingId: streamingId,
16072
- streamingQueue: streamingQueue,
16073
- triggerScroll: handleScroll
16193
+ triggerScroll: handleScroll,
16194
+ canBeStreaming: true
16074
16195
  }),
16075
16196
  /*#__PURE__*/ (0, $dWhh5$reactjsxruntime.jsx)("div", {
16076
16197
  ref: botEndRef
@@ -18818,6 +18939,7 @@ const $ad561f5c61e38c20$var$SynthesisManager = ({ isRetorikNews: isRetorikNews }
18818
18939
  if (cancel) {
18819
18940
  utterance ? setUtterance(null) : (0, $5f7f457957bd2c8d$export$d0df6aec4e971f52)(false);
18820
18941
  setNextUtterance(null);
18942
+ (0, $5f7f457957bd2c8d$export$c3296e37e9ef3fed)();
18821
18943
  }
18822
18944
  }, [
18823
18945
  cancel
@@ -19004,9 +19126,8 @@ const $ad561f5c61e38c20$var$SynthesisManager = ({ isRetorikNews: isRetorikNews }
19004
19126
  // Check if the audio ended because of a cancel call
19005
19127
  if (cancelRef.current) {
19006
19128
  queuedActivitiesRef.current = [];
19007
- (0, $5f7f457957bd2c8d$export$614a80601162ec38)(null);
19008
19129
  tempCurrentStreamingRef.current = null;
19009
- (0, $5f7f457957bd2c8d$export$87afd75c41a617d7)([]);
19130
+ // killCurrentStreaming()
19010
19131
  (0, $5f7f457957bd2c8d$export$d0df6aec4e971f52)(false);
19011
19132
  } else if (streamingQueue.length) {
19012
19133
  const tempActivity = streamingQueue[0];
@@ -19020,7 +19141,7 @@ const $ad561f5c61e38c20$var$SynthesisManager = ({ isRetorikNews: isRetorikNews }
19020
19141
  tempCurrentStreamingRef.current = tempActivity.text || null;
19021
19142
  } else {
19022
19143
  var _queuedActivitiesRef_current, _currentPlayingRef_current;
19023
- (0, $5f7f457957bd2c8d$export$614a80601162ec38)(null);
19144
+ // setStreamingReplyToId(null)
19024
19145
  // Launch next activity in the queue and remove it from the queue
19025
19146
  if ((_queuedActivitiesRef_current = queuedActivitiesRef.current) === null || _queuedActivitiesRef_current === void 0 ? void 0 : _queuedActivitiesRef_current.length) {
19026
19147
  const activity = queuedActivitiesRef.current[0];
@@ -19277,8 +19398,11 @@ var $9e19251bfed127fc$export$2e2bcd8739ae039 = $9e19251bfed127fc$var$SpeechManag
19277
19398
 
19278
19399
 
19279
19400
 
19401
+
19402
+
19280
19403
  const $fa132146e65c60c8$var$FocusManager = ()=>{
19281
- const currentDeviceType = (0, $30fe6c40d8e8a888$export$d13b2577cb75f2ad)((state)=>state.currentDeviceType);
19404
+ const isWidget = (0, $30fe6c40d8e8a888$export$d13b2577cb75f2ad)((state)=>state.isWidget);
19405
+ const open = (0, $1068fd56b5926747$export$d95eb9b67812311f)((state)=>state.open);
19282
19406
  const muted = (0, $5f7f457957bd2c8d$export$f299240efcda25a2)((state)=>state.muted);
19283
19407
  const activeRecognitionState = (0, $5f7f457957bd2c8d$export$f299240efcda25a2)((state)=>state.activeRecognitionState);
19284
19408
  const focusedRef = (0, $dWhh5$react.useRef)(true);
@@ -19294,6 +19418,23 @@ const $fa132146e65c60c8$var$FocusManager = ()=>{
19294
19418
  }, [
19295
19419
  activeRecognitionState
19296
19420
  ]);
19421
+ (0, $dWhh5$react.useEffect)(()=>{
19422
+ if ((0, $dWhh5$reactdevicedetect.isMobile) && isWidget) {
19423
+ if (open) {
19424
+ focusedRef.current = true;
19425
+ oldMutedRef.current === false && (0, $5f7f457957bd2c8d$export$a1680ba91cc9be33)(false);
19426
+ } else {
19427
+ focusedRef.current = false;
19428
+ (0, $5f7f457957bd2c8d$export$d0df6aec4e971f52)(true);
19429
+ (0, $5f7f457957bd2c8d$export$a1680ba91cc9be33)(true);
19430
+ recognitionStateRef.current === (0, $71c613e2e831c34c$export$3f0071308968cd80).Listening && (0, $5f7f457957bd2c8d$export$45913366c4ba414f)((0, $71c613e2e831c34c$export$3f0071308968cd80).ForceClosing);
19431
+ }
19432
+ }
19433
+ }, [
19434
+ open,
19435
+ isWidget,
19436
+ (0, $dWhh5$reactdevicedetect.isMobile)
19437
+ ]);
19297
19438
  const handleVisibilityChange = ()=>{
19298
19439
  if (document.visibilityState === "visible") {
19299
19440
  focusedRef.current = true;
@@ -19306,12 +19447,12 @@ const $fa132146e65c60c8$var$FocusManager = ()=>{
19306
19447
  }
19307
19448
  };
19308
19449
  (0, $dWhh5$react.useEffect)(()=>{
19309
- currentDeviceType === (0, $71c613e2e831c34c$export$ec1e04e4e5ef8233).mobile && document.addEventListener("visibilitychange", handleVisibilityChange);
19450
+ (0, $dWhh5$reactdevicedetect.isMobile) && document.addEventListener("visibilitychange", handleVisibilityChange);
19310
19451
  return ()=>{
19311
19452
  document.removeEventListener("visibilitychange", handleVisibilityChange);
19312
19453
  };
19313
19454
  }, [
19314
- currentDeviceType
19455
+ (0, $dWhh5$reactdevicedetect.isMobile)
19315
19456
  ]);
19316
19457
  return /*#__PURE__*/ (0, $dWhh5$reactjsxruntime.jsx)((0, ($parcel$interopDefault($dWhh5$react))).Fragment, {});
19317
19458
  };