@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.
@@ -1156,10 +1156,11 @@ const $04ce41b46d359821$var$initialState = {
1156
1156
  activeRecognitionState: (0, $f5ca62954d1f1f5b$export$3f0071308968cd80).Closed,
1157
1157
  lastRecognitionInterim: "",
1158
1158
  streamingReplyToId: null,
1159
- streamingReplyToIdForText: null,
1160
1159
  streamingQueue: [],
1161
1160
  streamingQueueForText: [],
1162
- currentStreaming: null
1161
+ currentStreaming: null,
1162
+ streamingQueueFullLength: 0,
1163
+ streamingReplyToIdToIgnore: null
1163
1164
  };
1164
1165
  const $04ce41b46d359821$export$f299240efcda25a2 = (0, $b3y7N$create)()(()=>{
1165
1166
  return $04ce41b46d359821$var$initialState;
@@ -1218,16 +1219,7 @@ const $04ce41b46d359821$export$a5c8d6d0ec4b5ccb = (value)=>{
1218
1219
  };
1219
1220
  const $04ce41b46d359821$export$614a80601162ec38 = (value)=>{
1220
1221
  $04ce41b46d359821$export$f299240efcda25a2.setState({
1221
- streamingReplyToId: value,
1222
- streamingReplyToIdForText: value
1223
- });
1224
- value === null && $04ce41b46d359821$export$f299240efcda25a2.setState({
1225
- currentStreaming: null
1226
- });
1227
- };
1228
- const $04ce41b46d359821$export$de8aad637f733113 = (value)=>{
1229
- $04ce41b46d359821$export$f299240efcda25a2.setState({
1230
- streamingReplyToIdForText: value
1222
+ streamingReplyToId: value
1231
1223
  });
1232
1224
  };
1233
1225
  const $04ce41b46d359821$export$87afd75c41a617d7 = (value)=>{
@@ -1237,11 +1229,12 @@ const $04ce41b46d359821$export$87afd75c41a617d7 = (value)=>{
1237
1229
  });
1238
1230
  };
1239
1231
  const $04ce41b46d359821$export$9a026d007e335fc0 = (value)=>{
1240
- if (value.replyToId) {
1232
+ const idToIgnore = $04ce41b46d359821$export$f299240efcda25a2.getState().streamingReplyToIdToIgnore;
1233
+ if (value.replyToId && value.replyToId !== idToIgnore) {
1241
1234
  // Set replyToId and new queue if replyToId is different from the current one
1242
1235
  if ($04ce41b46d359821$export$f299240efcda25a2.getState().streamingReplyToId !== value.replyToId) $04ce41b46d359821$export$f299240efcda25a2.setState({
1236
+ streamingQueueFullLength: 0,
1243
1237
  streamingReplyToId: value.replyToId,
1244
- streamingReplyToIdForText: value.replyToId,
1245
1238
  streamingQueue: [
1246
1239
  value
1247
1240
  ],
@@ -1274,11 +1267,36 @@ const $04ce41b46d359821$export$eb50624bfd363865 = ()=>{
1274
1267
  });
1275
1268
  }
1276
1269
  };
1270
+ const $04ce41b46d359821$export$8505d436556ca045 = (replyToId)=>{
1271
+ const currentId = $04ce41b46d359821$export$f299240efcda25a2.getState().streamingReplyToId;
1272
+ currentId !== replyToId && $04ce41b46d359821$export$c3296e37e9ef3fed();
1273
+ };
1274
+ const $04ce41b46d359821$export$c3296e37e9ef3fed = ()=>{
1275
+ const currentId = $04ce41b46d359821$export$f299240efcda25a2.getState().streamingReplyToId;
1276
+ $04ce41b46d359821$export$f299240efcda25a2.setState({
1277
+ streamingReplyToId: null,
1278
+ streamingQueue: [],
1279
+ streamingQueueForText: [],
1280
+ currentStreaming: null,
1281
+ streamingQueueFullLength: 0,
1282
+ streamingReplyToIdToIgnore: currentId
1283
+ });
1284
+ };
1277
1285
  const $04ce41b46d359821$export$d300d9470f5679ba = (value)=>{
1278
1286
  $04ce41b46d359821$export$f299240efcda25a2.setState({
1279
1287
  currentStreaming: value
1280
1288
  });
1281
1289
  };
1290
+ const $04ce41b46d359821$export$e9ca045daeb00700 = (value, replyToId)=>{
1291
+ if (replyToId) {
1292
+ const currentStreamingId = $04ce41b46d359821$export$f299240efcda25a2.getState().streamingReplyToId;
1293
+ replyToId === currentStreamingId && $04ce41b46d359821$export$f299240efcda25a2.setState({
1294
+ streamingQueueFullLength: value
1295
+ });
1296
+ } else $04ce41b46d359821$export$f299240efcda25a2.setState({
1297
+ streamingQueueFullLength: value
1298
+ });
1299
+ };
1282
1300
  const $04ce41b46d359821$export$b6d2196a3ce412d8 = ()=>{
1283
1301
  $04ce41b46d359821$export$f299240efcda25a2.setState({
1284
1302
  ...$04ce41b46d359821$var$initialState
@@ -1321,6 +1339,8 @@ const $9b100ac34d01a331$var$addActivity = async (activity, resetQueue)=>{
1321
1339
  const isBot = activity.from.role === "bot" || activity.replyToId || activity.from.name?.toLowerCase() === "bot";
1322
1340
  if (activity.type === "message") {
1323
1341
  if (isBot) {
1342
+ // If this activity is the one concluding a streaming, let's set the amount of streams previously generated
1343
+ if (!currentState.retrievingConversation && activity.value?.streamingCount) (0, $04ce41b46d359821$export$e9ca045daeb00700)(activity.value.streamingCount, activity.replyToId);
1324
1344
  if (currentState.botMessageActivities?.length && 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.
1325
1345
  // We must put this activity back in first place in the array.
1326
1346
  $9b100ac34d01a331$export$b56465394e2b1287.setState({
@@ -1447,6 +1467,8 @@ const $9b100ac34d01a331$export$f9786f6b1a1e81e3 = (activity)=>{
1447
1467
  $9b100ac34d01a331$var$timerRef && clearTimeout($9b100ac34d01a331$var$timerRef);
1448
1468
  $9b100ac34d01a331$var$timerRef = setTimeout(()=>{
1449
1469
  $9b100ac34d01a331$var$updateActivities();
1470
+ // Let speechStore check if this activity has an impact on a curent streaming
1471
+ (0, $04ce41b46d359821$export$8505d436556ca045)(activity.replyToId);
1450
1472
  }, 500);
1451
1473
  };
1452
1474
  const $9b100ac34d01a331$export$210f7e70e69f7df5 = (activity)=>{
@@ -1457,11 +1479,6 @@ const $9b100ac34d01a331$export$210f7e70e69f7df5 = (activity)=>{
1457
1479
  const currentConversationId = $9b100ac34d01a331$export$b56465394e2b1287.getState().conversationId;
1458
1480
  currentConversationId && activity.id?.includes(currentConversationId) && $9b100ac34d01a331$export$f9786f6b1a1e81e3(activity);
1459
1481
  };
1460
- const $9b100ac34d01a331$export$35bf93b87d9ffb15 = (activity)=>{
1461
- const retrieving = $9b100ac34d01a331$export$b56465394e2b1287.getState().retrievingConversation;
1462
- const currentConversationId = $9b100ac34d01a331$export$b56465394e2b1287.getState().conversationId;
1463
- currentConversationId && !retrieving && activity.id?.includes(currentConversationId) && (0, $04ce41b46d359821$export$9a026d007e335fc0)(activity);
1464
- };
1465
1482
  const $9b100ac34d01a331$export$4365557467e67cdc = (value)=>{
1466
1483
  const currentState = $9b100ac34d01a331$export$b56465394e2b1287.getState();
1467
1484
  // Check directline id to know if we have to reset the activities
@@ -1498,7 +1515,6 @@ const $9b100ac34d01a331$export$b7b23f8e09258fa6 = ()=>{
1498
1515
  };
1499
1516
 
1500
1517
 
1501
-
1502
1518
  const $9a5f0912c55d1da2$var$regexDataCommand = /(\{data-command=")[\p{L}\p{N}\p{Po}\p{Pd}\p{Pc}\s\u0027\u2019]+("\})(<br\s\/>)?/gu;
1503
1519
  const $9a5f0912c55d1da2$var$createCustomStore = (enableConversationCookie, conversationCookieMaxAge, addressData, locale, externalEventHandler, isUsedOnBorne, isRetorikNews)=>{
1504
1520
  return (0, $b3y7N$createStore)({}, ({ dispatch: dispatch })=>(next)=>async (action)=>{
@@ -1585,10 +1601,14 @@ const $9a5f0912c55d1da2$var$createCustomStore = (enableConversationCookie, conve
1585
1601
  if (action.payload?.activity?.type === "event" && action.payload?.activity?.name?.toLowerCase() === "davi.streammessageactivity") {
1586
1602
  if (action.payload.activity.text?.trim().length) {
1587
1603
  // Create speak field from the text one
1588
- const processedText = (0, $2e5b8b358de6cd42$export$1b8fbc30fb87d9aa)(action.payload.activity.text, true);
1589
- action.payload.activity.text = processedText.text;
1604
+ // const processedText = processMarkdownAndSpeechMarkdown(
1605
+ // action.payload.activity.text,
1606
+ // true
1607
+ // )
1608
+ const processedText = (0, $6e91c96224d17014$export$2e2bcd8739ae039)(action);
1609
+ // action.payload.activity.text = processedText.htmlText
1590
1610
  action.payload.activity.speak = processedText.text;
1591
- (0, $9b100ac34d01a331$export$35bf93b87d9ffb15)(action.payload.activity);
1611
+ (0, $04ce41b46d359821$export$9a026d007e335fc0)(action.payload.activity);
1592
1612
  }
1593
1613
  return next(action);
1594
1614
  }
@@ -5370,17 +5390,15 @@ const $b82cb9309c705ea4$var$DiscoverAttachment = ({ title: title, mainButtons: m
5370
5390
  } else if (index !== undefined) {
5371
5391
  setDiscoverClicked(index);
5372
5392
  const tempData = data;
5373
- const value = tempData.FilterId ? {
5393
+ dataToSend = {
5394
+ type: "event",
5395
+ name: tempData.EventName,
5374
5396
  value: {
5375
5397
  filterId: tempData.FilterId,
5376
5398
  filterValue: tempData.FilterValue,
5377
- followingCardText: tempData.FollowingCardText
5399
+ followingCardText: tempData.FollowingCardText,
5400
+ identifier: tempData.Identifier
5378
5401
  }
5379
- } : {};
5380
- dataToSend = {
5381
- type: "event",
5382
- name: tempData.EventName,
5383
- ...value
5384
5402
  };
5385
5403
  }
5386
5404
  sendPostBack(dataToSend);
@@ -15510,7 +15528,6 @@ const $f9b55dee2122a017$export$f0e9d14ede4c01bd = ()=>{
15510
15528
 
15511
15529
 
15512
15530
 
15513
-
15514
15531
  const $0d96395552e34116$export$aa0c5ba341a0028 = ({ agentName: agentName = "L\xe9a", companyName: companyName, companyNameLocalized: companyNameLocalized, subCompanyMessage: subCompanyMessage, subCompanyMessageLocalized: subCompanyMessageLocalized, imageUrl: imageUrl = "" })=>{
15515
15532
  const locale = (0, $f902d4436881b887$export$6650dace022cfacc)((state)=>state.locale);
15516
15533
  const translation = (0, $f902d4436881b887$export$6650dace022cfacc)((state)=>state.currentTranslations);
@@ -15569,105 +15586,130 @@ const $0d96395552e34116$export$aa0c5ba341a0028 = ({ agentName: agentName = "L\xe
15569
15586
  };
15570
15587
 
15571
15588
 
15572
- const $ea27a870d6ff37c7$var$DisplayStandard = ({ botResponses: botResponses, isMobile: isMobile })=>{
15573
- const locale = (0, $f902d4436881b887$export$6650dace022cfacc)((state)=>state.locale);
15574
- const { configuration: { forceMobileView: forceMobileView } } = (0, $15b0bc93a9787124$export$d8760bee47331b1d)();
15575
- return /*#__PURE__*/ (0, $b3y7N$jsx)("div", {
15576
- id: "retorik-botResponses",
15577
- className: "rf-flex rf-flex-col rf-text-size-auto rf-gap-2 rf-scrollbar-hidden",
15578
- children: botResponses.map((activity, key)=>{
15579
- const answerTime = activity.localTimestamp ? new Date(activity.localTimestamp) : activity.timestamp ? new Date(activity.timestamp) : new Date();
15580
- return /*#__PURE__*/ (0, $b3y7N$jsxs)("div", {
15581
- className: `${key > 0 && "rf-pt-2"} rf-text-textModePanelConversationBot rf-animate-slideBottom rf-flex rf-flex-col rf-items-start rf-gap-2`,
15582
- children: [
15583
- isMobile && /*#__PURE__*/ (0, $b3y7N$jsx)("div", {
15584
- className: "rf-px-4 rf-text-[#9A9A9A]",
15585
- children: answerTime.toLocaleString(locale, {
15586
- hour: "numeric",
15587
- minute: "numeric"
15588
- })
15589
- }),
15590
- activity.htmlText ? /*#__PURE__*/ (0, $b3y7N$jsx)("div", {
15591
- className: "rf-px-4",
15592
- dangerouslySetInnerHTML: {
15593
- __html: activity.htmlText
15594
- }
15595
- }) : activity.text ? /*#__PURE__*/ (0, $b3y7N$jsx)("div", {
15596
- className: "rf-px-4",
15597
- children: (0, $3792187fd212489a$export$d6c6ec86eedacfd9)(activity.text)
15598
- }) : /*#__PURE__*/ (0, $b3y7N$jsx)((0, $b3y7N$react).Fragment, {}),
15599
- !!activity?.attachments?.length && !(0, $1136774ec828a7ed$export$7c55936a30618336)(activity) && /*#__PURE__*/ (0, $b3y7N$jsx)("div", {
15600
- className: `${forceMobileView ? "rf-m-auto" : "rf-w-full"} ${activity.attachments.length <= 1 && "rf-px-4"} rf-flex rf-flex-col rf-gap-2`,
15601
- children: /*#__PURE__*/ (0, $b3y7N$jsx)((0, $d7c37f48f10c5387$export$2e2bcd8739ae039), {
15602
- activity: activity
15603
- })
15604
- })
15605
- ]
15606
- }, key);
15607
- })
15608
- });
15609
- };
15610
- var $ea27a870d6ff37c7$export$2e2bcd8739ae039 = $ea27a870d6ff37c7$var$DisplayStandard;
15611
15589
 
15612
15590
 
15613
15591
 
15614
15592
 
15615
15593
 
15616
- const $b22a7bbed115cb27$var$interval = 25;
15617
- const $b22a7bbed115cb27$var$DisplayStreaming = ({ streamingQueue: streamingQueue, triggerScroll: triggerScroll })=>{
15594
+
15595
+
15596
+ const $b22a7bbed115cb27$var$interval = 150 // 20 // 25
15597
+ ;
15598
+ const $b22a7bbed115cb27$var$md = new (0, $b3y7N$markdownit)({
15599
+ breaks: true,
15600
+ html: true,
15601
+ xhtmlOut: true,
15602
+ typographer: true,
15603
+ quotes: `""''`
15604
+ });
15605
+ const $b22a7bbed115cb27$var$DisplayStreaming = ({ triggerScroll: triggerScroll, setStreamingEnded: setStreamingEnded, streamingActivity: streamingActivity, currentStreaming: currentStreaming, isMobile: isMobile })=>{
15606
+ const locale = (0, $f902d4436881b887$export$6650dace022cfacc)((state)=>state.locale);
15607
+ const streamingQueue = (0, $04ce41b46d359821$export$f299240efcda25a2)((state)=>state.streamingQueueForText);
15608
+ const streamingCount = (0, $04ce41b46d359821$export$f299240efcda25a2)((state)=>state.streamingQueueFullLength);
15609
+ const { configuration: { forceMobileView: forceMobileView } } = (0, $15b0bc93a9787124$export$d8760bee47331b1d)();
15618
15610
  const [streamingTextToDisplay, setStreamingTextToDisplay] = (0, $b3y7N$useState)("");
15619
15611
  const [currentTextEnded, setCurrentTextEnded] = (0, $b3y7N$useState)(true);
15620
15612
  const [currentQueueIndex, setCurrentQueueIndex] = (0, $b3y7N$useState)(0);
15613
+ const time = (0, $b3y7N$useMemo)(()=>{
15614
+ if (streamingQueue.length) {
15615
+ const answerTime = streamingQueue[0].localTimestamp ? new Date(streamingQueue[0].localTimestamp) : streamingQueue[0].timestamp ? new Date(streamingQueue[0].timestamp) : new Date();
15616
+ return answerTime;
15617
+ }
15618
+ return null;
15619
+ }, [
15620
+ streamingQueue
15621
+ ]);
15621
15622
  const intervalRef = (0, $b3y7N$useRef)(null);
15622
15623
  const streamRef = (0, $b3y7N$useRef)([]);
15624
+ const streamIndexRef = (0, $b3y7N$useRef)(0);
15625
+ const previousTextRef = (0, $b3y7N$useRef)([]);
15626
+ // const handleNewStreaming = (text: string): void => {
15627
+ // text = md.render(text)
15628
+ // if (previousTextRef.current) {
15629
+ // for (let i = 0; i < previousTextRef.current.length; i++) {
15630
+ // if (text[i] !== previousTextRef.current[i]) {
15631
+ // streamIndexRef.current = i
15632
+ // break
15633
+ // }
15634
+ // }
15635
+ // } else {
15636
+ // streamIndexRef.current = 0
15637
+ // }
15638
+ // setCurrentTextEnded(false)
15639
+ // streamRef.current = text.split('')
15640
+ // previousTextRef.current = text
15641
+ // streamIndexRef.current !== streamingTextToDisplay.length &&
15642
+ // setStreamingTextToDisplay((value) =>
15643
+ // value.substring(0, streamIndexRef.current)
15644
+ // )
15645
+ // intervalRef.current = setInterval(() => {
15646
+ // if (streamIndexRef.current < streamRef.current?.length) {
15647
+ // const current = streamRef.current[streamIndexRef.current]
15648
+ // setStreamingTextToDisplay((value) => `${value}${current}`)
15649
+ // streamIndexRef.current = streamIndexRef.current + 1
15650
+ // } else {
15651
+ // setCurrentTextEnded(true)
15652
+ // intervalRef.current && clearInterval(intervalRef.current)
15653
+ // }
15654
+ // }, interval)
15655
+ // }
15623
15656
  const handleNewStreaming = (text)=>{
15657
+ text = $b22a7bbed115cb27$var$md.render(text);
15658
+ streamRef.current = text.split(" ");
15624
15659
  setCurrentTextEnded(false);
15625
- // Create array containing indexes of \n parts to replace them with html <br /> tag later
15626
- const slashNIndexesArray = [];
15627
- let searchIndex = 0;
15628
- while(text.indexOf("\n", searchIndex) !== -1){
15629
- const index = text.indexOf("\n", searchIndex);
15630
- slashNIndexesArray.push(index);
15631
- searchIndex = index + 2;
15632
- }
15633
- streamRef.current = text.split("");
15634
- let currentIndex = 0;
15635
15660
  intervalRef.current = setInterval(()=>{
15636
- if (streamRef.current?.length) {
15637
- const current = streamRef.current[0];
15638
- if (slashNIndexesArray.includes(currentIndex)) {
15639
- // 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
15640
- setStreamingTextToDisplay((value)=>`${value}<br />`);
15641
- streamRef.current = streamRef.current.slice(1);
15642
- } else {
15643
- setStreamingTextToDisplay((value)=>`${value}${current}`);
15644
- streamRef.current = streamRef.current.slice(1);
15645
- }
15646
- currentIndex++;
15661
+ if (streamIndexRef.current < streamRef.current.length - 1) {
15662
+ const current = streamRef.current[streamIndexRef.current];
15663
+ setStreamingTextToDisplay((value)=>`${value} ${current}`);
15664
+ streamIndexRef.current = streamIndexRef.current + 1;
15665
+ streamIndexRef.current % 10 === 0 && triggerScroll();
15647
15666
  } else {
15648
15667
  setCurrentTextEnded(true);
15668
+ triggerScroll();
15649
15669
  intervalRef.current && clearInterval(intervalRef.current);
15650
15670
  }
15651
15671
  }, $b22a7bbed115cb27$var$interval);
15652
15672
  };
15673
+ const resetData = ()=>{
15674
+ setCurrentQueueIndex(0);
15675
+ streamIndexRef.current = 0;
15676
+ previousTextRef.current = [];
15677
+ (0, $04ce41b46d359821$export$e9ca045daeb00700)(0);
15678
+ intervalRef?.current && clearInterval(intervalRef.current);
15679
+ };
15653
15680
  (0, $b3y7N$useEffect)(()=>{
15654
- if (streamingQueue?.length && currentTextEnded) {
15655
- if (streamingQueue.length > currentQueueIndex) {
15656
- handleNewStreaming(streamingQueue[currentQueueIndex].text || "");
15657
- setCurrentQueueIndex((value)=>value + 1);
15681
+ if (currentTextEnded && streamingQueue?.length) {
15682
+ if (streamingCount === 0 || currentQueueIndex < streamingCount) {
15683
+ if (streamingQueue.length > currentQueueIndex) {
15684
+ setStreamingEnded(false);
15685
+ let text = "";
15686
+ for(let i = 0; i <= currentQueueIndex; i++)text = text + streamingQueue[i].text;
15687
+ handleNewStreaming(text);
15688
+ setCurrentQueueIndex((value)=>value + 1);
15689
+ }
15658
15690
  } else {
15659
- setCurrentQueueIndex(0);
15660
- (0, $04ce41b46d359821$export$de8aad637f733113)(null);
15691
+ let fullText = "";
15692
+ streamingQueue.forEach((activity)=>{
15693
+ fullText = `${fullText} ${activity.text}`;
15694
+ });
15695
+ setStreamingTextToDisplay($b22a7bbed115cb27$var$md.render(fullText));
15696
+ setStreamingEnded(true);
15697
+ resetData();
15661
15698
  }
15662
15699
  }
15663
15700
  }, [
15664
15701
  streamingQueue,
15665
- currentTextEnded
15702
+ currentTextEnded,
15703
+ streamingCount
15666
15704
  ]);
15667
15705
  (0, $b3y7N$useEffect)(()=>{
15668
- streamingTextToDisplay.length % 20 === 0 && triggerScroll();
15706
+ if (!currentStreaming) {
15707
+ setCurrentTextEnded(true);
15708
+ setStreamingTextToDisplay("");
15709
+ resetData();
15710
+ }
15669
15711
  }, [
15670
- streamingTextToDisplay
15712
+ currentStreaming
15671
15713
  ]);
15672
15714
  (0, $b3y7N$useEffect)(()=>{
15673
15715
  return ()=>{
@@ -15675,17 +15717,30 @@ const $b22a7bbed115cb27$var$DisplayStreaming = ({ streamingQueue: streamingQueue
15675
15717
  };
15676
15718
  }, []);
15677
15719
  return /*#__PURE__*/ (0, $b3y7N$jsxs)("div", {
15678
- id: "retorik-botResponses",
15679
- className: "rf-flex rf-flex-col rf-text-size-auto rf-scrollbar-hidden",
15720
+ className: "rf-text-textModePanelConversationBot rf-flex rf-flex-col rf-items-start rf-gap-2",
15680
15721
  children: [
15722
+ isMobile && time && /*#__PURE__*/ (0, $b3y7N$jsx)("div", {
15723
+ className: "rf-px-4 rf-text-[#9A9A9A]",
15724
+ children: time.toLocaleString(locale, {
15725
+ hour: "numeric",
15726
+ minute: "numeric"
15727
+ })
15728
+ }),
15681
15729
  streamingTextToDisplay && /*#__PURE__*/ (0, $b3y7N$jsx)("div", {
15682
- className: "rf-px-4 rf-text-textModePanelConversationBot",
15730
+ className: "rf-px-4",
15683
15731
  dangerouslySetInnerHTML: {
15684
15732
  __html: streamingTextToDisplay
15685
15733
  }
15686
15734
  }),
15687
- currentQueueIndex !== 0 && /*#__PURE__*/ (0, $b3y7N$jsx)("div", {
15688
- className: "rf-px-4 rf-font-bold rf-text-textModePanelConversationBot rf-animate-blink",
15735
+ currentQueueIndex === 0 ? /*#__PURE__*/ (0, $b3y7N$jsx)((0, $b3y7N$react).Fragment, {
15736
+ children: !!streamingActivity?.attachments?.length && /*#__PURE__*/ (0, $b3y7N$jsx)("div", {
15737
+ className: `${forceMobileView ? "rf-m-auto" : "rf-w-full"} ${streamingActivity.attachments.length <= 1 && "rf-px-4"}`,
15738
+ children: /*#__PURE__*/ (0, $b3y7N$jsx)((0, $d7c37f48f10c5387$export$2e2bcd8739ae039), {
15739
+ activity: streamingActivity
15740
+ })
15741
+ })
15742
+ }) : /*#__PURE__*/ (0, $b3y7N$jsx)("div", {
15743
+ className: "rf-px-4 rf-font-bold rf-animate-blink",
15689
15744
  children: "..."
15690
15745
  })
15691
15746
  ]
@@ -15694,7 +15749,75 @@ const $b22a7bbed115cb27$var$DisplayStreaming = ({ streamingQueue: streamingQueue
15694
15749
  var $b22a7bbed115cb27$export$2e2bcd8739ae039 = $b22a7bbed115cb27$var$DisplayStreaming;
15695
15750
 
15696
15751
 
15697
- const $df2e46a0b1d75dd8$var$ConversationDisplay = ({ userQuestion: userQuestion, botResponses: botResponses, streamingId: streamingId, streamingQueue: streamingQueue, userQuestionTime: userQuestionTime, isMobile: isMobile, triggerScroll: triggerScroll })=>{
15752
+
15753
+ const $ea27a870d6ff37c7$var$DisplayStandard = ({ botResponses: botResponses, isMobile: isMobile, triggerScroll: triggerScroll, canBeStreaming: canBeStreaming })=>{
15754
+ const locale = (0, $f902d4436881b887$export$6650dace022cfacc)((state)=>state.locale);
15755
+ const currentStreaming = (0, $04ce41b46d359821$export$f299240efcda25a2)((state)=>state.currentStreaming);
15756
+ const streamingId = (0, $04ce41b46d359821$export$f299240efcda25a2)((state)=>state.streamingReplyToId);
15757
+ const { configuration: { forceMobileView: forceMobileView } } = (0, $15b0bc93a9787124$export$d8760bee47331b1d)();
15758
+ const [streamingActivity, setStreamingActivity] = (0, $b3y7N$useState)(undefined);
15759
+ const [streamingEnded, setStreamingEnded] = (0, $b3y7N$useState)(false);
15760
+ const nonStreamingActivities = (0, $b3y7N$useMemo)(()=>{
15761
+ if (streamingActivity) return botResponses.filter((act)=>act.id !== streamingActivity.id && act.replyToId === streamingActivity.replyToId);
15762
+ return botResponses;
15763
+ }, [
15764
+ streamingActivity,
15765
+ botResponses
15766
+ ]);
15767
+ (0, $b3y7N$useEffect)(()=>{
15768
+ if (botResponses.length && currentStreaming) setStreamingActivity(botResponses.find((act)=>act.replyToId === streamingId && act.value?.streamingCount));
15769
+ else setStreamingActivity(undefined);
15770
+ }, [
15771
+ botResponses,
15772
+ currentStreaming,
15773
+ streamingId
15774
+ ]);
15775
+ return /*#__PURE__*/ (0, $b3y7N$jsxs)((0, $b3y7N$react).Fragment, {
15776
+ children: [
15777
+ canBeStreaming && /*#__PURE__*/ (0, $b3y7N$jsx)((0, $b22a7bbed115cb27$export$2e2bcd8739ae039), {
15778
+ triggerScroll: triggerScroll,
15779
+ setStreamingEnded: setStreamingEnded,
15780
+ streamingActivity: streamingActivity,
15781
+ currentStreaming: currentStreaming,
15782
+ isMobile: isMobile
15783
+ }),
15784
+ (!streamingActivity || streamingActivity && streamingEnded) && nonStreamingActivities.map((activity, key)=>{
15785
+ const answerTime = activity.localTimestamp ? new Date(activity.localTimestamp) : activity.timestamp ? new Date(activity.timestamp) : new Date();
15786
+ return /*#__PURE__*/ (0, $b3y7N$jsxs)("div", {
15787
+ className: `${key > 0 && "rf-pt-2"} rf-text-textModePanelConversationBot rf-animate-slideBottom rf-flex rf-flex-col rf-items-start rf-gap-2`,
15788
+ children: [
15789
+ isMobile && /*#__PURE__*/ (0, $b3y7N$jsx)("div", {
15790
+ className: "rf-px-4 rf-text-[#9A9A9A]",
15791
+ children: answerTime.toLocaleString(locale, {
15792
+ hour: "numeric",
15793
+ minute: "numeric"
15794
+ })
15795
+ }),
15796
+ activity.htmlText ? /*#__PURE__*/ (0, $b3y7N$jsx)("div", {
15797
+ className: "rf-px-4",
15798
+ dangerouslySetInnerHTML: {
15799
+ __html: activity.htmlText
15800
+ }
15801
+ }) : activity.text ? /*#__PURE__*/ (0, $b3y7N$jsx)("div", {
15802
+ className: "rf-px-4",
15803
+ children: (0, $3792187fd212489a$export$d6c6ec86eedacfd9)(activity.text)
15804
+ }) : /*#__PURE__*/ (0, $b3y7N$jsx)((0, $b3y7N$react).Fragment, {}),
15805
+ !!activity?.attachments?.length && !(0, $1136774ec828a7ed$export$7c55936a30618336)(activity) && /*#__PURE__*/ (0, $b3y7N$jsx)("div", {
15806
+ className: `${forceMobileView ? "rf-m-auto" : "rf-w-full"} ${activity.attachments.length <= 1 && "rf-px-4"} rf-flex rf-flex-col rf-gap-2`,
15807
+ children: /*#__PURE__*/ (0, $b3y7N$jsx)((0, $d7c37f48f10c5387$export$2e2bcd8739ae039), {
15808
+ activity: activity
15809
+ })
15810
+ })
15811
+ ]
15812
+ }, key);
15813
+ })
15814
+ ]
15815
+ });
15816
+ };
15817
+ var $ea27a870d6ff37c7$export$2e2bcd8739ae039 = $ea27a870d6ff37c7$var$DisplayStandard;
15818
+
15819
+
15820
+ const $df2e46a0b1d75dd8$var$ConversationDisplay = ({ userQuestion: userQuestion, botResponses: botResponses, userQuestionTime: userQuestionTime, isMobile: isMobile, triggerScroll: triggerScroll, canBeStreaming: canBeStreaming })=>{
15698
15821
  const locale = (0, $f902d4436881b887$export$6650dace022cfacc)((state)=>state.locale);
15699
15822
  return /*#__PURE__*/ (0, $b3y7N$jsxs)((0, $b3y7N$react).Fragment, {
15700
15823
  children: [
@@ -15715,12 +15838,15 @@ const $df2e46a0b1d75dd8$var$ConversationDisplay = ({ userQuestion: userQuestion,
15715
15838
  })
15716
15839
  ]
15717
15840
  }, userQuestion.id),
15718
- streamingId && streamingQueue?.length ? /*#__PURE__*/ (0, $b3y7N$jsx)((0, $b22a7bbed115cb27$export$2e2bcd8739ae039), {
15719
- streamingQueue: streamingQueue,
15720
- triggerScroll: triggerScroll
15721
- }) : /*#__PURE__*/ (0, $b3y7N$jsx)((0, $ea27a870d6ff37c7$export$2e2bcd8739ae039), {
15722
- botResponses: botResponses || [],
15723
- isMobile: isMobile
15841
+ /*#__PURE__*/ (0, $b3y7N$jsx)("div", {
15842
+ id: "retorik-botResponses",
15843
+ className: "rf-flex rf-flex-col rf-text-size-auto rf-gap-2 rf-scrollbar-hidden",
15844
+ children: /*#__PURE__*/ (0, $b3y7N$jsx)((0, $ea27a870d6ff37c7$export$2e2bcd8739ae039), {
15845
+ triggerScroll: triggerScroll,
15846
+ botResponses: botResponses || [],
15847
+ isMobile: isMobile,
15848
+ canBeStreaming: canBeStreaming
15849
+ })
15724
15850
  })
15725
15851
  ]
15726
15852
  });
@@ -15741,8 +15867,6 @@ const $2aae80cf8e050a0a$var$ConversationPanelMobile = ({ homeActivity: homeActiv
15741
15867
  const [scrollButtonDisplay, setScrollButtonDisplay] = (0, $b3y7N$useState)(false);
15742
15868
  const [scrollButtonDirection, setScrollButtonDirection] = (0, $b3y7N$useState)("bottom");
15743
15869
  const [preventScroll, setPreventScroll] = (0, $b3y7N$useState)(false);
15744
- const streamingId = (0, $04ce41b46d359821$export$f299240efcda25a2)((state)=>state.streamingReplyToIdForText);
15745
- const streamingQueue = (0, $04ce41b46d359821$export$f299240efcda25a2)((state)=>state.streamingQueueForText);
15746
15870
  const retorikConversationRef = (0, $b3y7N$useRef)(null);
15747
15871
  const botEndRef = (0, $b3y7N$useRef)(null);
15748
15872
  const timerRef = (0, $b3y7N$useRef)(null);
@@ -15846,11 +15970,10 @@ const $2aae80cf8e050a0a$var$ConversationPanelMobile = ({ homeActivity: homeActiv
15846
15970
  children: /*#__PURE__*/ (0, $b3y7N$jsx)((0, $df2e46a0b1d75dd8$export$2e2bcd8739ae039), {
15847
15971
  userQuestion: activity.question,
15848
15972
  botResponses: activity.answers,
15849
- streamingId: index === activities.length - 1 ? streamingId : null,
15850
- streamingQueue: streamingQueue,
15851
15973
  userQuestionTime: userQuestionTime,
15852
15974
  isMobile: true,
15853
- triggerScroll: ()=>scrollHandler("bottom", "newMessage")
15975
+ triggerScroll: ()=>scrollHandler("bottom", "newMessage"),
15976
+ canBeStreaming: index === activities.length - 1
15854
15977
  })
15855
15978
  }, index);
15856
15979
  }),
@@ -15871,8 +15994,7 @@ const $2aae80cf8e050a0a$var$ConversationPanelMobile = ({ homeActivity: homeActiv
15871
15994
  var $2aae80cf8e050a0a$export$2e2bcd8739ae039 = $2aae80cf8e050a0a$var$ConversationPanelMobile;
15872
15995
 
15873
15996
 
15874
-
15875
-
15997
+ /* eslint-disable react/jsx-boolean-value */
15876
15998
 
15877
15999
 
15878
16000
 
@@ -15881,8 +16003,6 @@ var $2aae80cf8e050a0a$export$2e2bcd8739ae039 = $2aae80cf8e050a0a$var$Conversatio
15881
16003
  const $158745933e0ea53f$var$ConversationPanelLarge = ({ homeActivity: homeActivity, itemsInConversation: itemsInConversation })=>{
15882
16004
  const activities = (0, $d8c9d0fe519d0cbe$export$2e2bcd8739ae039)();
15883
16005
  const { mediumLandscape: mediumLandscape } = (0, $c7fecc7ec9b4c272$export$3abe3478af3cb63b)();
15884
- const streamingId = (0, $04ce41b46d359821$export$f299240efcda25a2)((state)=>state.streamingReplyToIdForText);
15885
- const streamingQueue = (0, $04ce41b46d359821$export$f299240efcda25a2)((state)=>state.streamingQueueForText);
15886
16006
  const botEndRef = (0, $b3y7N$useRef)(null);
15887
16007
  const timerRef = (0, $b3y7N$useRef)(null);
15888
16008
  const userQuestion = (0, $b3y7N$useMemo)(()=>{
@@ -15912,7 +16032,7 @@ const $158745933e0ea53f$var$ConversationPanelLarge = ({ homeActivity: homeActivi
15912
16032
  }, [
15913
16033
  itemsInConversation
15914
16034
  ]);
15915
- return homeActivity?.attachments?.length || streamingId || userQuestion || botResponses ? /*#__PURE__*/ (0, $b3y7N$jsx)("div", {
16035
+ return homeActivity?.attachments?.length || userQuestion || botResponses ? /*#__PURE__*/ (0, $b3y7N$jsx)("div", {
15916
16036
  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`,
15917
16037
  children: /*#__PURE__*/ (0, $b3y7N$jsxs)("div", {
15918
16038
  id: "retorik-conversation",
@@ -15926,9 +16046,8 @@ const $158745933e0ea53f$var$ConversationPanelLarge = ({ homeActivity: homeActivi
15926
16046
  }) : /*#__PURE__*/ (0, $b3y7N$jsx)((0, $df2e46a0b1d75dd8$export$2e2bcd8739ae039), {
15927
16047
  userQuestion: userQuestion,
15928
16048
  botResponses: botResponses,
15929
- streamingId: streamingId,
15930
- streamingQueue: streamingQueue,
15931
- triggerScroll: handleScroll
16049
+ triggerScroll: handleScroll,
16050
+ canBeStreaming: true
15932
16051
  }),
15933
16052
  /*#__PURE__*/ (0, $b3y7N$jsx)("div", {
15934
16053
  ref: botEndRef
@@ -18658,6 +18777,7 @@ const $45f8218489149157$var$SynthesisManager = ({ isRetorikNews: isRetorikNews }
18658
18777
  if (cancel) {
18659
18778
  utterance ? setUtterance(null) : (0, $04ce41b46d359821$export$d0df6aec4e971f52)(false);
18660
18779
  setNextUtterance(null);
18780
+ (0, $04ce41b46d359821$export$c3296e37e9ef3fed)();
18661
18781
  }
18662
18782
  }, [
18663
18783
  cancel
@@ -18841,9 +18961,8 @@ const $45f8218489149157$var$SynthesisManager = ({ isRetorikNews: isRetorikNews }
18841
18961
  // Check if the audio ended because of a cancel call
18842
18962
  if (cancelRef.current) {
18843
18963
  queuedActivitiesRef.current = [];
18844
- (0, $04ce41b46d359821$export$614a80601162ec38)(null);
18845
18964
  tempCurrentStreamingRef.current = null;
18846
- (0, $04ce41b46d359821$export$87afd75c41a617d7)([]);
18965
+ // killCurrentStreaming()
18847
18966
  (0, $04ce41b46d359821$export$d0df6aec4e971f52)(false);
18848
18967
  } else if (streamingQueue.length) {
18849
18968
  const tempActivity = streamingQueue[0];
@@ -18856,7 +18975,7 @@ const $45f8218489149157$var$SynthesisManager = ({ isRetorikNews: isRetorikNews }
18856
18975
  futureUtterance = checkSayAsWordsAndCreateUtterance(params);
18857
18976
  tempCurrentStreamingRef.current = tempActivity.text || null;
18858
18977
  } else {
18859
- (0, $04ce41b46d359821$export$614a80601162ec38)(null);
18978
+ // setStreamingReplyToId(null)
18860
18979
  // Launch next activity in the queue and remove it from the queue
18861
18980
  if (queuedActivitiesRef.current?.length) {
18862
18981
  const activity = queuedActivitiesRef.current[0];
@@ -19111,8 +19230,11 @@ var $efe892d829a9a26a$export$2e2bcd8739ae039 = $efe892d829a9a26a$var$SpeechManag
19111
19230
 
19112
19231
 
19113
19232
 
19233
+
19234
+
19114
19235
  const $86772fb907b8c462$var$FocusManager = ()=>{
19115
- const currentDeviceType = (0, $957e950ca3ff2781$export$d13b2577cb75f2ad)((state)=>state.currentDeviceType);
19236
+ const isWidget = (0, $957e950ca3ff2781$export$d13b2577cb75f2ad)((state)=>state.isWidget);
19237
+ const open = (0, $f9b55dee2122a017$export$d95eb9b67812311f)((state)=>state.open);
19116
19238
  const muted = (0, $04ce41b46d359821$export$f299240efcda25a2)((state)=>state.muted);
19117
19239
  const activeRecognitionState = (0, $04ce41b46d359821$export$f299240efcda25a2)((state)=>state.activeRecognitionState);
19118
19240
  const focusedRef = (0, $b3y7N$useRef)(true);
@@ -19128,6 +19250,23 @@ const $86772fb907b8c462$var$FocusManager = ()=>{
19128
19250
  }, [
19129
19251
  activeRecognitionState
19130
19252
  ]);
19253
+ (0, $b3y7N$useEffect)(()=>{
19254
+ if ((0, $b3y7N$isMobile) && isWidget) {
19255
+ if (open) {
19256
+ focusedRef.current = true;
19257
+ oldMutedRef.current === false && (0, $04ce41b46d359821$export$a1680ba91cc9be33)(false);
19258
+ } else {
19259
+ focusedRef.current = false;
19260
+ (0, $04ce41b46d359821$export$d0df6aec4e971f52)(true);
19261
+ (0, $04ce41b46d359821$export$a1680ba91cc9be33)(true);
19262
+ recognitionStateRef.current === (0, $f5ca62954d1f1f5b$export$3f0071308968cd80).Listening && (0, $04ce41b46d359821$export$45913366c4ba414f)((0, $f5ca62954d1f1f5b$export$3f0071308968cd80).ForceClosing);
19263
+ }
19264
+ }
19265
+ }, [
19266
+ open,
19267
+ isWidget,
19268
+ (0, $b3y7N$isMobile)
19269
+ ]);
19131
19270
  const handleVisibilityChange = ()=>{
19132
19271
  if (document.visibilityState === "visible") {
19133
19272
  focusedRef.current = true;
@@ -19140,12 +19279,12 @@ const $86772fb907b8c462$var$FocusManager = ()=>{
19140
19279
  }
19141
19280
  };
19142
19281
  (0, $b3y7N$useEffect)(()=>{
19143
- currentDeviceType === (0, $f5ca62954d1f1f5b$export$ec1e04e4e5ef8233).mobile && document.addEventListener("visibilitychange", handleVisibilityChange);
19282
+ (0, $b3y7N$isMobile) && document.addEventListener("visibilitychange", handleVisibilityChange);
19144
19283
  return ()=>{
19145
19284
  document.removeEventListener("visibilitychange", handleVisibilityChange);
19146
19285
  };
19147
19286
  }, [
19148
- currentDeviceType
19287
+ (0, $b3y7N$isMobile)
19149
19288
  ]);
19150
19289
  return /*#__PURE__*/ (0, $b3y7N$jsx)((0, $b3y7N$react).Fragment, {});
19151
19290
  };