@superinterface/react 5.3.0-beta.3 → 5.3.0-beta.4

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
@@ -46868,11 +46868,11 @@ ThreadDialog.Root = Root13;
46868
46868
  ThreadDialog.Trigger = Trigger;
46869
46869
  ThreadDialog.Content = Content8;
46870
46870
  // src/components/threads/AudioThreadDialog/index.tsx
46871
- import { c as _c100 } from "react-compiler-runtime";
46872
- // src/components/threads/AudioThread/index.tsx
46873
46871
  import { c as _c99 } from "react-compiler-runtime";
46872
+ // src/components/threads/AudioThread/index.tsx
46873
+ import { c as _c98 } from "react-compiler-runtime";
46874
46874
  // src/components/threads/AudioThread/Root/index.tsx
46875
- import { c as _c91 } from "react-compiler-runtime";
46875
+ import { c as _c90 } from "react-compiler-runtime";
46876
46876
  import { Flex as Flex29 } from "@radix-ui/themes";
46877
46877
  // src/contexts/threads/AudioThreadContext/index.ts
46878
46878
  import { createContext as createContext13 } from "react";
@@ -46885,9 +46885,9 @@ var useAudioThreadContext = function() {
46885
46885
  return useContext19(AudioThreadContext);
46886
46886
  };
46887
46887
  // src/components/audioRuntimes/TtsAudioRuntimeProvider.tsx
46888
- import { c as _c90 } from "react-compiler-runtime";
46889
- // src/hooks/audioRuntimes/useTtsAudioRuntime/index.ts
46890
46888
  import { c as _c89 } from "react-compiler-runtime";
46889
+ // src/hooks/audioRuntimes/useTtsAudioRuntime/index.ts
46890
+ import { c as _c88 } from "react-compiler-runtime";
46891
46891
  import { useMemo as useMemo18 } from "react";
46892
46892
  // src/hooks/misc/usePermission/index.ts
46893
46893
  import { c as _c86 } from "react-compiler-runtime";
@@ -47219,9 +47219,7 @@ var useRecorder = function(_ref) {
47219
47219
  });
47220
47220
  };
47221
47221
  // src/hooks/audioThreads/useMessageAudio/index.ts
47222
- import { c as _c88 } from "react-compiler-runtime";
47223
47222
  import { useMemo as useMemo17, useRef as useRef8, useState as useState9, useEffect as useEffect10, useCallback as useCallback7 } from "react";
47224
- import nlp from "compromise";
47225
47223
  import { Howler } from "howler";
47226
47224
  import { useAudioPlayer as useAudioPlayer2 } from "react-use-audio-player";
47227
47225
  // src/hooks/audioThreads/useMessageAudio/lib/input.ts
@@ -47289,215 +47287,104 @@ function _toPrimitive47(t, r) {
47289
47287
  }
47290
47288
  return ("string" === r ? String : Number)(t);
47291
47289
  }
47292
- var segment = function(input2) {
47293
- return nlp(input2).sentences().json().map(function(s) {
47294
- return s.text;
47295
- });
47290
+ var splitSentencesFast = function(text) {
47291
+ var t = text.replace(/\s+/g, " ").trim();
47292
+ if (!t) return [];
47293
+ var parts = t.split(RegExp("(?<=[.!?])\\s+(?=[^\\s])", "g"));
47294
+ return parts;
47296
47295
  };
47297
- var useMessageAudio = function(t0) {
47298
- var $ = _c88(41);
47299
- var _onEnd = t0.onEnd, passedPlay = t0.play, t1 = t0.fullSentenceRegex;
47300
- var t2;
47301
- if ($[0] !== t1) {
47302
- t2 = t1 === void 0 ? /[\.?!]$/ : t1;
47303
- $[0] = t1;
47304
- $[1] = t2;
47305
- } else {
47306
- t2 = $[1];
47296
+ var getIncrementalSentences = function(prev, nextInput) {
47297
+ if (!prev) {
47298
+ return {
47299
+ input: nextInput,
47300
+ sentences: splitSentencesFast(nextInput)
47301
+ };
47302
+ }
47303
+ if (nextInput === prev.input) {
47304
+ return prev;
47305
+ }
47306
+ if (nextInput.startsWith(prev.input)) {
47307
+ var _prev$sentences;
47308
+ var prevLast = (_prev$sentences = prev.sentences[prev.sentences.length - 1]) !== null && _prev$sentences !== void 0 ? _prev$sentences : "";
47309
+ var baseLen = prev.input.length - prevLast.length;
47310
+ if (baseLen >= 0 && prev.input.slice(baseLen) === prevLast) {
47311
+ var tail = nextInput.slice(baseLen);
47312
+ var tailSegments = splitSentencesFast(tail);
47313
+ var merged = prev.sentences.length > 0 ? _to_consumable_array(prev.sentences.slice(0, -1)).concat(_to_consumable_array(tailSegments)) : tailSegments;
47314
+ return {
47315
+ input: nextInput,
47316
+ sentences: merged
47317
+ };
47318
+ }
47307
47319
  }
47308
- var fullSentenceRegex = t2;
47320
+ return {
47321
+ input: nextInput,
47322
+ sentences: splitSentencesFast(nextInput)
47323
+ };
47324
+ };
47325
+ var useMessageAudio = function(_ref) {
47326
+ var _onEnd = _ref.onEnd, passedPlay = _ref.play, _ref_fullSentenceRegex = _ref.fullSentenceRegex, fullSentenceRegex = _ref_fullSentenceRegex === void 0 ? /[\.?!]$/ : _ref_fullSentenceRegex;
47309
47327
  var _useState9 = _sliced_to_array(useState9(false), 2), isAudioPlayed = _useState9[0], setIsAudioPlayed = _useState9[1];
47310
47328
  var audioPlayer = useAudioPlayer2();
47311
47329
  var nextAudioPlayer = useAudioPlayer2();
47312
47330
  var superinterfaceContext = useSuperinterfaceContext();
47313
47331
  var _useState91 = _sliced_to_array(useState9(false), 2), isPlaying = _useState91[0], setIsPlaying = _useState91[1];
47314
- var t3;
47315
- if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
47316
- t3 = [];
47317
- $[2] = t3;
47318
- } else {
47319
- t3 = $[2];
47320
- }
47321
- var _useState92 = _sliced_to_array(useState9(t3), 2), audioQueue = _useState92[0], setAudioQueue = _useState92[1];
47322
- var t4;
47323
- if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
47324
- t4 = [];
47325
- $[3] = t4;
47326
- } else {
47327
- t4 = $[3];
47328
- }
47329
- var audioQueueRef = useRef8(t4);
47330
- var t5;
47331
- var t6;
47332
- if ($[4] !== audioQueue) {
47333
- t5 = function() {
47334
- audioQueueRef.current = audioQueue;
47335
- };
47336
- t6 = [
47337
- audioQueue
47338
- ];
47339
- $[4] = audioQueue;
47340
- $[5] = t5;
47341
- $[6] = t6;
47342
- } else {
47343
- t5 = $[5];
47344
- t6 = $[6];
47345
- }
47346
- useEffect10(t5, t6);
47332
+ var _useState92 = _sliced_to_array(useState9([]), 2), audioQueue = _useState92[0], setAudioQueue = _useState92[1];
47333
+ var audioQueueRef = useRef8([]);
47334
+ useEffect10(function() {
47335
+ audioQueueRef.current = audioQueue;
47336
+ }, [
47337
+ audioQueue
47338
+ ]);
47347
47339
  var pickLockRef = useRef8(false);
47348
47340
  var currentSentenceRef = useRef8(null);
47349
47341
  var messagesProps = useMessages();
47350
- var t7;
47351
- var t8;
47352
- if ($[7] !== messagesProps.messages) {
47353
- t7 = function() {
47354
- var assistantsDesc = messagesProps.messages.filter(_temp9);
47355
- var assistantsAsc = _to_consumable_array(assistantsDesc).reverse();
47356
- setAudioQueue(function(prev) {
47357
- var prevById = new Map(prev.map(_temp24));
47358
- var next = [];
47359
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
47360
- try {
47361
- for(var _iterator = assistantsAsc[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
47362
- var m_0 = _step.value;
47363
- var _existing$nextIndex, _existing$stopped;
47364
- var inp = input({
47365
- message: m_0
47366
- });
47367
- if (inp == null) {
47368
- continue;
47369
- }
47370
- var sentences = segment(inp);
47371
- var existing = prevById.get(m_0.id);
47342
+ var segCacheRef = useRef8(/* @__PURE__ */ new Map());
47343
+ useEffect10(function() {
47344
+ var assistantsDesc = messagesProps.messages.filter(function(m) {
47345
+ return m.role === "assistant";
47346
+ });
47347
+ var assistantsAsc = _to_consumable_array(assistantsDesc).reverse();
47348
+ setAudioQueue(function(prev) {
47349
+ var prevById = new Map(prev.map(function(p) {
47350
+ return [
47351
+ p.id,
47352
+ p
47353
+ ];
47354
+ }));
47355
+ var changed = false;
47356
+ var next = [];
47357
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
47358
+ try {
47359
+ for(var _iterator = assistantsAsc[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
47360
+ var m_0 = _step.value;
47361
+ var _existing$nextIndex, _existing$stopped;
47362
+ var inp = input({
47363
+ message: m_0
47364
+ });
47365
+ if (inp == null) continue;
47366
+ var prevSeg = segCacheRef.current.get(m_0.id);
47367
+ var nextSeg = getIncrementalSentences(prevSeg, inp);
47368
+ if (!prevSeg || nextSeg.input !== prevSeg.input) {
47369
+ segCacheRef.current.set(m_0.id, nextSeg);
47370
+ }
47371
+ var existing = prevById.get(m_0.id);
47372
+ var sentences = nextSeg.sentences;
47373
+ var nextIndex = Math.min((_existing$nextIndex = existing === null || existing === void 0 ? void 0 : existing.nextIndex) !== null && _existing$nextIndex !== void 0 ? _existing$nextIndex : 0, sentences.length);
47374
+ var stopped = (_existing$stopped = existing === null || existing === void 0 ? void 0 : existing.stopped) !== null && _existing$stopped !== void 0 ? _existing$stopped : false;
47375
+ var reuseExisting = !!existing && existing.status === m_0.status && existing.sentences === sentences && // same array ref -> no change
47376
+ existing.nextIndex === nextIndex && existing.stopped === stopped;
47377
+ if (reuseExisting) {
47378
+ next.push(existing);
47379
+ } else {
47372
47380
  next.push({
47373
47381
  id: m_0.id,
47374
47382
  status: m_0.status,
47375
47383
  sentences: sentences,
47376
- nextIndex: Math.min((_existing$nextIndex = existing === null || existing === void 0 ? void 0 : existing.nextIndex) !== null && _existing$nextIndex !== void 0 ? _existing$nextIndex : 0, sentences.length),
47377
- stopped: (_existing$stopped = existing === null || existing === void 0 ? void 0 : existing.stopped) !== null && _existing$stopped !== void 0 ? _existing$stopped : false
47384
+ nextIndex: nextIndex,
47385
+ stopped: stopped
47378
47386
  });
47379
- }
47380
- } catch (err) {
47381
- _didIteratorError = true;
47382
- _iteratorError = err;
47383
- } finally{
47384
- try {
47385
- if (!_iteratorNormalCompletion && _iterator.return != null) {
47386
- _iterator.return();
47387
- }
47388
- } finally{
47389
- if (_didIteratorError) {
47390
- throw _iteratorError;
47391
- }
47392
- }
47393
- }
47394
- return next;
47395
- });
47396
- };
47397
- t8 = [
47398
- messagesProps.messages
47399
- ];
47400
- $[7] = messagesProps.messages;
47401
- $[8] = t7;
47402
- $[9] = t8;
47403
- } else {
47404
- t7 = $[8];
47405
- t8 = $[9];
47406
- }
47407
- useEffect10(t7, t8);
47408
- var t9;
47409
- if ($[10] !== audioPlayer || $[11] !== fullSentenceRegex || $[12] !== isAudioPlayed || $[13] !== nextAudioPlayer || $[14] !== superinterfaceContext) {
47410
- t9 = function(t102) {
47411
- var input2 = t102.input, onPlay = t102.onPlay, onStop = t102.onStop, onEnd_0 = t102.onEnd;
47412
- var searchParams = new URLSearchParams(_objectSpread47({
47413
- input: input2
47414
- }, superinterfaceContext.variables));
47415
- audioPlayer.load("".concat(superinterfaceContext.baseUrl, "/audio-runtimes/tts?").concat(searchParams), {
47416
- format: "mp3",
47417
- autoplay: isAudioPlayed,
47418
- html5: isHtmlAudioSupported,
47419
- onplay: onPlay,
47420
- onstop: onStop,
47421
- onload: function() {
47422
- var current = currentSentenceRef.current;
47423
- if (!current) {
47424
- return;
47425
- }
47426
- var msg = audioQueueRef.current.find(function(m_1) {
47427
- return m_1.id === current.messageId;
47428
- });
47429
- if (!msg) {
47430
- return;
47431
- }
47432
- var nextSentence = msg.sentences[msg.nextIndex];
47433
- if (!nextSentence) {
47434
- return;
47435
- }
47436
- if (!fullSentenceRegex.test(nextSentence)) {
47437
- return;
47438
- }
47439
- var nextSearchParams = new URLSearchParams(_objectSpread47({
47440
- input: nextSentence
47441
- }, superinterfaceContext.variables));
47442
- nextAudioPlayer.load("".concat(superinterfaceContext.baseUrl, "/audio-runtimes/tts?").concat(nextSearchParams), {
47443
- format: "mp3",
47444
- autoplay: false,
47445
- html5: isHtmlAudioSupported
47446
- });
47447
- },
47448
- onend: onEnd_0
47449
- });
47450
- };
47451
- $[10] = audioPlayer;
47452
- $[11] = fullSentenceRegex;
47453
- $[12] = isAudioPlayed;
47454
- $[13] = nextAudioPlayer;
47455
- $[14] = superinterfaceContext;
47456
- $[15] = t9;
47457
- } else {
47458
- t9 = $[15];
47459
- }
47460
- var defaultPlay = t9;
47461
- var t10;
47462
- t10 = passedPlay || defaultPlay;
47463
- var play = t10;
47464
- var t11;
47465
- var t12;
47466
- if ($[16] !== audioPlayer.playing || $[17] !== audioQueue || $[18] !== fullSentenceRegex || $[19] !== isPlaying || $[20] !== _onEnd || $[21] !== play) {
47467
- t11 = function() {
47468
- if (isPlaying) {
47469
- return;
47470
- }
47471
- if (audioPlayer.playing) {
47472
- return;
47473
- }
47474
- if (pickLockRef.current) {
47475
- return;
47476
- }
47477
- var candidate;
47478
- candidate = null;
47479
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
47480
- try {
47481
- for(var _iterator = audioQueue[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
47482
- var msg_0 = _step.value;
47483
- if (msg_0.stopped) {
47484
- continue;
47485
- }
47486
- var sentence = msg_0.sentences[msg_0.nextIndex];
47487
- if (!sentence) {
47488
- continue;
47489
- }
47490
- var isFull = isOptimistic({
47491
- id: msg_0.id
47492
- }) || msg_0.status !== "in_progress" || fullSentenceRegex.test(sentence);
47493
- if (isFull) {
47494
- candidate = {
47495
- messageId: msg_0.id,
47496
- sentence: sentence,
47497
- index: msg_0.nextIndex,
47498
- ownerStatus: msg_0.status
47499
- };
47500
- break;
47387
+ changed = true;
47501
47388
  }
47502
47389
  }
47503
47390
  } catch (err) {
@@ -47514,202 +47401,219 @@ var useMessageAudio = function(t0) {
47514
47401
  }
47515
47402
  }
47516
47403
  }
47517
- if (!candidate) {
47518
- return;
47404
+ if (next.length !== prev.length) {
47405
+ changed = true;
47406
+ } else {
47407
+ for(var i = 0; i < next.length; i++){
47408
+ if (next[i] !== prev[i]) {
47409
+ changed = true;
47410
+ break;
47411
+ }
47412
+ }
47519
47413
  }
47520
- pickLockRef.current = true;
47521
- setIsPlaying(true);
47522
- currentSentenceRef.current = {
47523
- messageId: candidate.messageId,
47524
- index: candidate.index
47525
- };
47526
- setAudioQueue(function(prev_0) {
47527
- return prev_0.map(function(m_2) {
47528
- return m_2.id === candidate.messageId ? _objectSpread47(_objectSpread47({}, m_2), {}, {
47529
- nextIndex: m_2.nextIndex + 1
47530
- }) : m_2;
47414
+ return changed ? next : prev;
47415
+ });
47416
+ }, [
47417
+ messagesProps.messages
47418
+ ]);
47419
+ var defaultPlay = useCallback7(function(_ref2) {
47420
+ var input2 = _ref2.input, onPlay = _ref2.onPlay, onStop = _ref2.onStop, onEnd_0 = _ref2.onEnd;
47421
+ var searchParams = new URLSearchParams(_objectSpread47({
47422
+ input: input2
47423
+ }, superinterfaceContext.variables));
47424
+ audioPlayer.load("".concat(superinterfaceContext.baseUrl, "/audio-runtimes/tts?").concat(searchParams), {
47425
+ format: "mp3",
47426
+ autoplay: isAudioPlayed,
47427
+ // first call false; then true for snappier chaining
47428
+ html5: isHtmlAudioSupported,
47429
+ onplay: onPlay,
47430
+ onstop: onStop,
47431
+ onload: function() {
47432
+ var current = currentSentenceRef.current;
47433
+ if (!current) return;
47434
+ var msg = audioQueueRef.current.find(function(m_1) {
47435
+ return m_1.id === current.messageId;
47531
47436
  });
47532
- });
47533
- play({
47534
- input: candidate.sentence,
47535
- onPlay: function() {
47536
- setIsAudioPlayed(true);
47537
- },
47538
- onStop: function() {
47539
- setAudioQueue(function(prev_1) {
47540
- return prev_1.map(function(m_3) {
47541
- return m_3.id === candidate.messageId ? _objectSpread47(_objectSpread47({}, m_3), {}, {
47542
- stopped: true
47543
- }) : m_3;
47544
- });
47545
- });
47546
- setIsPlaying(false);
47547
- currentSentenceRef.current = null;
47548
- pickLockRef.current = false;
47549
- },
47550
- onEnd: function() {
47551
- setIsPlaying(false);
47552
- currentSentenceRef.current = null;
47553
- pickLockRef.current = false;
47554
- var hasPending = audioQueueRef.current.some(_temp32);
47555
- if (!hasPending) {
47556
- _onEnd();
47557
- }
47437
+ if (!msg) return;
47438
+ var nextSentence = msg.sentences[msg.nextIndex];
47439
+ if (!nextSentence) return;
47440
+ if (!fullSentenceRegex.test(nextSentence)) return;
47441
+ var nextSearchParams = new URLSearchParams(_objectSpread47({
47442
+ input: nextSentence
47443
+ }, superinterfaceContext.variables));
47444
+ nextAudioPlayer.load("".concat(superinterfaceContext.baseUrl, "/audio-runtimes/tts?").concat(nextSearchParams), {
47445
+ format: "mp3",
47446
+ autoplay: false,
47447
+ html5: isHtmlAudioSupported
47448
+ });
47449
+ },
47450
+ onend: onEnd_0
47451
+ });
47452
+ }, [
47453
+ superinterfaceContext,
47454
+ audioPlayer,
47455
+ nextAudioPlayer,
47456
+ isAudioPlayed,
47457
+ fullSentenceRegex
47458
+ ]);
47459
+ var play = useMemo17(function() {
47460
+ return passedPlay || defaultPlay;
47461
+ }, [
47462
+ passedPlay,
47463
+ defaultPlay
47464
+ ]);
47465
+ useEffect10(function() {
47466
+ if (isPlaying) return;
47467
+ if (audioPlayer.playing) return;
47468
+ if (pickLockRef.current) return;
47469
+ var candidate = null;
47470
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
47471
+ try {
47472
+ for(var _iterator = audioQueue[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
47473
+ var msg_0 = _step.value;
47474
+ if (msg_0.stopped) continue;
47475
+ var sentence = msg_0.sentences[msg_0.nextIndex];
47476
+ while(sentence && !/\S/.test(sentence)){
47477
+ msg_0.nextIndex++;
47478
+ sentence = msg_0.sentences[msg_0.nextIndex];
47479
+ }
47480
+ if (!sentence) continue;
47481
+ var isFull = isOptimistic({
47482
+ id: msg_0.id
47483
+ }) || msg_0.status !== "in_progress" || fullSentenceRegex.test(sentence);
47484
+ if (isFull) {
47485
+ candidate = {
47486
+ messageId: msg_0.id,
47487
+ sentence: sentence,
47488
+ index: msg_0.nextIndex,
47489
+ ownerStatus: msg_0.status
47490
+ };
47491
+ break;
47558
47492
  }
47559
- });
47560
- };
47561
- t12 = [
47562
- isPlaying,
47563
- audioPlayer.playing,
47564
- audioQueue,
47565
- play,
47566
- fullSentenceRegex,
47567
- _onEnd
47568
- ];
47569
- $[16] = audioPlayer.playing;
47570
- $[17] = audioQueue;
47571
- $[18] = fullSentenceRegex;
47572
- $[19] = isPlaying;
47573
- $[20] = _onEnd;
47574
- $[21] = play;
47575
- $[22] = t11;
47576
- $[23] = t12;
47577
- } else {
47578
- t11 = $[22];
47579
- t12 = $[23];
47580
- }
47581
- useEffect10(t11, t12);
47582
- var t13;
47583
- if ($[24] !== audioPlayer) {
47584
- t13 = [
47585
- audioPlayer
47586
- ];
47587
- $[24] = audioPlayer;
47588
- $[25] = t13;
47589
- } else {
47590
- t13 = $[25];
47591
- }
47592
- useEffect10(_temp42, t13);
47593
- var _useState93 = _sliced_to_array(useState9(null), 2), audioEngine = _useState93[0], setAudioEngine = _useState93[1];
47594
- var isAudioEngineInited = useRef8(false);
47595
- var t14;
47596
- if ($[26] !== audioPlayer.playing) {
47597
- t14 = function() {
47598
- if (!audioPlayer.playing) {
47599
- return;
47600
47493
  }
47601
- if (isAudioEngineInited.current) {
47602
- return;
47494
+ } catch (err) {
47495
+ _didIteratorError = true;
47496
+ _iteratorError = err;
47497
+ } finally{
47498
+ try {
47499
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
47500
+ _iterator.return();
47501
+ }
47502
+ } finally{
47503
+ if (_didIteratorError) {
47504
+ throw _iteratorError;
47505
+ }
47603
47506
  }
47604
- isAudioEngineInited.current = true;
47605
- if (isHtmlAudioSupported) {
47606
- var audioContext = new AudioContext();
47607
- setAudioEngine({
47608
- source: audioContext.createMediaElementSource(Howler._howls[0]._sounds[0]._node),
47609
- audioContext: audioContext
47507
+ }
47508
+ if (!candidate) return;
47509
+ pickLockRef.current = true;
47510
+ setIsPlaying(true);
47511
+ currentSentenceRef.current = {
47512
+ messageId: candidate.messageId,
47513
+ index: candidate.index
47514
+ };
47515
+ setAudioQueue(function(prev_0) {
47516
+ return prev_0.map(function(m_2) {
47517
+ return m_2.id === candidate.messageId ? _objectSpread47(_objectSpread47({}, m_2), {}, {
47518
+ nextIndex: m_2.nextIndex + 1
47519
+ }) : m_2;
47520
+ });
47521
+ });
47522
+ play({
47523
+ input: candidate.sentence,
47524
+ onPlay: function() {
47525
+ return setIsAudioPlayed(true);
47526
+ },
47527
+ onStop: function() {
47528
+ setAudioQueue(function(prev_1) {
47529
+ return prev_1.map(function(m_3) {
47530
+ return m_3.id === candidate.messageId ? _objectSpread47(_objectSpread47({}, m_3), {}, {
47531
+ stopped: true
47532
+ }) : m_3;
47533
+ });
47610
47534
  });
47611
- } else {
47612
- setAudioEngine({
47613
- source: Howler.masterGain,
47614
- audioContext: Howler.ctx
47535
+ setIsPlaying(false);
47536
+ currentSentenceRef.current = null;
47537
+ pickLockRef.current = false;
47538
+ },
47539
+ onEnd: function() {
47540
+ setIsPlaying(false);
47541
+ currentSentenceRef.current = null;
47542
+ pickLockRef.current = false;
47543
+ var hasPending = audioQueueRef.current.some(function(m_4) {
47544
+ if (m_4.stopped) return false;
47545
+ var hasMore = m_4.nextIndex < m_4.sentences.length;
47546
+ var streaming = m_4.status === "in_progress";
47547
+ return hasMore || streaming;
47615
47548
  });
47549
+ if (!hasPending) _onEnd();
47616
47550
  }
47617
- };
47618
- $[26] = audioPlayer.playing;
47619
- $[27] = t14;
47620
- } else {
47621
- t14 = $[27];
47622
- }
47623
- var t15;
47624
- if ($[28] !== audioPlayer) {
47625
- t15 = [
47626
- audioPlayer
47627
- ];
47628
- $[28] = audioPlayer;
47629
- $[29] = t15;
47630
- } else {
47631
- t15 = $[29];
47632
- }
47633
- useEffect10(t14, t15);
47634
- var t16;
47635
- bb0: {
47636
- if (!audioEngine) {
47637
- t16 = null;
47638
- break bb0;
47551
+ });
47552
+ }, [
47553
+ isPlaying,
47554
+ audioPlayer.playing,
47555
+ audioQueue,
47556
+ play,
47557
+ fullSentenceRegex,
47558
+ _onEnd
47559
+ ]);
47560
+ useEffect10(function() {
47561
+ if (isHtmlAudioSupported) {
47562
+ var _Howler$_howls$;
47563
+ if (!(Howler !== null && Howler !== void 0 && (_Howler$_howls$ = Howler._howls[0]) !== null && _Howler$_howls$ !== void 0 && (_Howler$_howls$ = _Howler$_howls$._sounds[0]) !== null && _Howler$_howls$ !== void 0 && _Howler$_howls$._node)) return;
47564
+ Howler._howls[0]._sounds[0]._node.crossOrigin = "anonymous";
47639
47565
  }
47640
- var analyser;
47641
- if ($[30] !== audioEngine.audioContext || $[31] !== audioEngine.source) {
47642
- analyser = audioEngine.audioContext.createAnalyser();
47643
- audioEngine.source.connect(audioEngine.audioContext.destination);
47644
- audioEngine.source.connect(analyser);
47645
- $[30] = audioEngine.audioContext;
47646
- $[31] = audioEngine.source;
47647
- $[32] = analyser;
47566
+ }, [
47567
+ audioPlayer
47568
+ ]);
47569
+ var _useState93 = _sliced_to_array(useState9(null), 2), audioEngine = _useState93[0], setAudioEngine = _useState93[1];
47570
+ var isAudioEngineInited = useRef8(false);
47571
+ useEffect10(function() {
47572
+ if (!audioPlayer.playing) return;
47573
+ if (isAudioEngineInited.current) return;
47574
+ isAudioEngineInited.current = true;
47575
+ if (isHtmlAudioSupported) {
47576
+ var _Howler$_howls$2;
47577
+ var audioContext = new AudioContext();
47578
+ setAudioEngine({
47579
+ // @ts-ignore-next-line
47580
+ source: audioContext.createMediaElementSource(// @ts-ignore-next-line
47581
+ (_Howler$_howls$2 = Howler._howls[0]) === null || _Howler$_howls$2 === void 0 || (_Howler$_howls$2 = _Howler$_howls$2._sounds[0]) === null || _Howler$_howls$2 === void 0 ? void 0 : _Howler$_howls$2._node),
47582
+ audioContext: audioContext
47583
+ });
47648
47584
  } else {
47649
- analyser = $[32];
47650
- }
47651
- t16 = analyser;
47652
- }
47653
- var visualizationAnalyser = t16;
47654
- var t17;
47655
- var t18;
47656
- if ($[33] !== audioQueue || $[34] !== isPlaying) {
47657
- t18 = isPlaying || audioQueue.some(_temp52);
47658
- $[33] = audioQueue;
47659
- $[34] = isPlaying;
47660
- $[35] = t18;
47661
- } else {
47662
- t18 = $[35];
47663
- }
47664
- t17 = t18;
47665
- var isPending = t17;
47666
- var t19;
47667
- if ($[36] !== audioPlayer || $[37] !== isAudioPlayed || $[38] !== isPending || $[39] !== visualizationAnalyser) {
47668
- t19 = _objectSpread47(_objectSpread47({
47669
- isPending: isPending,
47670
- isAudioPlayed: isAudioPlayed
47671
- }, audioPlayer), {}, {
47672
- visualizationAnalyser: visualizationAnalyser
47585
+ setAudioEngine({
47586
+ source: Howler.masterGain,
47587
+ audioContext: Howler.ctx
47588
+ });
47589
+ }
47590
+ }, [
47591
+ audioPlayer
47592
+ ]);
47593
+ var visualizationAnalyser = useMemo17(function() {
47594
+ if (!audioEngine) return null;
47595
+ var analyser = audioEngine.audioContext.createAnalyser();
47596
+ audioEngine.source.connect(audioEngine.audioContext.destination);
47597
+ audioEngine.source.connect(analyser);
47598
+ return analyser;
47599
+ }, [
47600
+ audioEngine
47601
+ ]);
47602
+ var isPending = useMemo17(function() {
47603
+ return isPlaying || audioQueue.some(function(m_5) {
47604
+ return !m_5.stopped && (m_5.nextIndex < m_5.sentences.length || m_5.status === "in_progress");
47673
47605
  });
47674
- $[36] = audioPlayer;
47675
- $[37] = isAudioPlayed;
47676
- $[38] = isPending;
47677
- $[39] = visualizationAnalyser;
47678
- $[40] = t19;
47679
- } else {
47680
- t19 = $[40];
47681
- }
47682
- return t19;
47606
+ }, [
47607
+ isPlaying,
47608
+ audioQueue
47609
+ ]);
47610
+ return _objectSpread47(_objectSpread47({
47611
+ isPending: isPending,
47612
+ isAudioPlayed: isAudioPlayed
47613
+ }, audioPlayer), {}, {
47614
+ visualizationAnalyser: visualizationAnalyser
47615
+ });
47683
47616
  };
47684
- function _temp9(m) {
47685
- return m.role === "assistant";
47686
- }
47687
- function _temp24(p) {
47688
- return [
47689
- p.id,
47690
- p
47691
- ];
47692
- }
47693
- function _temp32(m_4) {
47694
- if (m_4.stopped) {
47695
- return false;
47696
- }
47697
- var hasMore = m_4.nextIndex < m_4.sentences.length;
47698
- var streaming = m_4.status === "in_progress";
47699
- return hasMore || streaming;
47700
- }
47701
- function _temp42() {
47702
- if (isHtmlAudioSupported) {
47703
- var _Howler$_howls$;
47704
- if (!(Howler !== null && Howler !== void 0 && (_Howler$_howls$ = Howler._howls[0]) !== null && _Howler$_howls$ !== void 0 && (_Howler$_howls$ = _Howler$_howls$._sounds[0]) !== null && _Howler$_howls$ !== void 0 && _Howler$_howls$._node)) {
47705
- return;
47706
- }
47707
- Howler._howls[0]._sounds[0]._node.crossOrigin = "anonymous";
47708
- }
47709
- }
47710
- function _temp52(m_5) {
47711
- return !m_5.stopped && (m_5.nextIndex < m_5.sentences.length || m_5.status === "in_progress");
47712
- }
47713
47617
  // src/hooks/audioRuntimes/useTtsAudioRuntime/index.ts
47714
47618
  import { useQueryClient as useQueryClient6 } from "@tanstack/react-query";
47715
47619
  // src/hooks/audioRuntimes/useTtsAudioRuntime/blobToData.ts
@@ -47747,7 +47651,7 @@ function _asyncToGenerator11(n) {
47747
47651
  };
47748
47652
  }
47749
47653
  var useTtsAudioRuntime = function(t0) {
47750
- var $ = _c89(30);
47654
+ var $ = _c88(30);
47751
47655
  var play = t0.play, passedOnEnd = t0.onEnd;
47752
47656
  var addToast = useToasts().addToast;
47753
47657
  var queryClient = useQueryClient6();
@@ -47776,7 +47680,7 @@ var useTtsAudioRuntime = function(t0) {
47776
47680
  if ($[1] !== createMessageProps) {
47777
47681
  t2 = {
47778
47682
  isStopOnSilence: true,
47779
- onStart: _temp10,
47683
+ onStart: _temp9,
47780
47684
  onStop: function() {
47781
47685
  var _onStop = _asyncToGenerator11(function(_event, chunks) {
47782
47686
  var blob, audioContent;
@@ -47917,23 +47821,23 @@ var useTtsAudioRuntime = function(t0) {
47917
47821
  t5 = t8;
47918
47822
  return t5;
47919
47823
  };
47920
- function _temp10() {
47921
- return _temp25.apply(this, arguments);
47824
+ function _temp9() {
47825
+ return _temp24.apply(this, arguments);
47922
47826
  }
47923
- function _temp25() {
47924
- _temp25 = _asyncToGenerator11(function() {
47827
+ function _temp24() {
47828
+ _temp24 = _asyncToGenerator11(function() {
47925
47829
  return _ts_generator(this, function(_state) {
47926
47830
  return [
47927
47831
  2
47928
47832
  ];
47929
47833
  });
47930
47834
  });
47931
- return _temp25.apply(this, arguments);
47835
+ return _temp24.apply(this, arguments);
47932
47836
  }
47933
47837
  // src/components/audioRuntimes/TtsAudioRuntimeProvider.tsx
47934
47838
  import { jsx as _jsx87 } from "react/jsx-runtime";
47935
47839
  var TtsAudioRuntimeProvider = function(t0) {
47936
- var $ = _c90(8);
47840
+ var $ = _c89(8);
47937
47841
  var children = t0.children, play = t0.play, onEnd = t0.onEnd;
47938
47842
  var t1;
47939
47843
  if ($[0] !== onEnd || $[1] !== play) {
@@ -48046,7 +47950,7 @@ function _objectWithoutPropertiesLoose5(r, e) {
48046
47950
  return t;
48047
47951
  }
48048
47952
  var Content9 = function(t0) {
48049
- var $ = _c91(4);
47953
+ var $ = _c90(4);
48050
47954
  var children = t0.children, className = t0.className, style = t0.style;
48051
47955
  var t1;
48052
47956
  if ($[0] !== children || $[1] !== className || $[2] !== style) {
@@ -48068,7 +47972,7 @@ var Content9 = function(t0) {
48068
47972
  return t1;
48069
47973
  };
48070
47974
  var AudioRuntimeProvider = function(t0) {
48071
- var $ = _c91(4);
47975
+ var $ = _c90(4);
48072
47976
  var children = t0.children, play = t0.play, onEnd = t0.onEnd;
48073
47977
  var audioThreadContext = useAudioThreadContext();
48074
47978
  if (audioThreadContext.audioRuntime) {
@@ -48091,7 +47995,7 @@ var AudioRuntimeProvider = function(t0) {
48091
47995
  return t1;
48092
47996
  };
48093
47997
  var Provider5 = function(t0) {
48094
- var $ = _c91(9);
47998
+ var $ = _c90(9);
48095
47999
  var children;
48096
48000
  var rest;
48097
48001
  if ($[0] !== t0) {
@@ -48131,7 +48035,7 @@ var Provider5 = function(t0) {
48131
48035
  return t2;
48132
48036
  };
48133
48037
  var Root16 = function(t0) {
48134
- var $ = _c91(18);
48038
+ var $ = _c90(18);
48135
48039
  var children;
48136
48040
  var className;
48137
48041
  var onEnd;
@@ -48203,7 +48107,7 @@ var Root16 = function(t0) {
48203
48107
  return t3;
48204
48108
  };
48205
48109
  // src/components/threads/AudioThread/Visualization/index.tsx
48206
- import { c as _c93 } from "react-compiler-runtime";
48110
+ import { c as _c92 } from "react-compiler-runtime";
48207
48111
  import { useState as useState11, useCallback as useCallback9, useEffect as useEffect12, useContext as useContext20, createContext as createContext14 } from "react";
48208
48112
  import _9 from "lodash";
48209
48113
  import { Flex as Flex31 } from "@radix-ui/themes";
@@ -48272,10 +48176,10 @@ var BarsVisualizer = function(_ref) {
48272
48176
  });
48273
48177
  };
48274
48178
  // src/hooks/audioThreads/useStatus/index.ts
48275
- import { c as _c92 } from "react-compiler-runtime";
48179
+ import { c as _c91 } from "react-compiler-runtime";
48276
48180
  import { useMemo as useMemo19 } from "react";
48277
48181
  var useStatus = function() {
48278
- var $ = _c92(2);
48182
+ var $ = _c91(2);
48279
48183
  var audioRuntime = useAudioThreadContext().audioRuntime;
48280
48184
  var t0;
48281
48185
  bb0: {
@@ -48435,7 +48339,7 @@ var Provider6 = function(_ref) {
48435
48339
  });
48436
48340
  };
48437
48341
  var Root17 = function(t0) {
48438
- var $ = _c93(6);
48342
+ var $ = _c92(6);
48439
48343
  var children;
48440
48344
  var rest;
48441
48345
  if ($[0] !== t0) {
@@ -48472,7 +48376,7 @@ var Root17 = function(t0) {
48472
48376
  return t1;
48473
48377
  };
48474
48378
  var BarsVisualizer2 = function(t0) {
48475
- var $ = _c93(10);
48379
+ var $ = _c92(10);
48476
48380
  var rest;
48477
48381
  var t1;
48478
48382
  var t2;
@@ -48516,7 +48420,7 @@ var BarsVisualizer2 = function(t0) {
48516
48420
  return t4;
48517
48421
  };
48518
48422
  var AssistantVisualizationRoot = function(t0) {
48519
- var $ = _c93(17);
48423
+ var $ = _c92(17);
48520
48424
  var children;
48521
48425
  var rest;
48522
48426
  var t1;
@@ -48589,7 +48493,7 @@ var AssistantVisualizationRoot = function(t0) {
48589
48493
  return t6;
48590
48494
  };
48591
48495
  var AssistantVisualization = function(props) {
48592
- var $ = _c93(3);
48496
+ var $ = _c92(3);
48593
48497
  var t0;
48594
48498
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
48595
48499
  t0 = /* @__PURE__ */ _jsx90(BarsVisualizer2, {});
@@ -48612,7 +48516,7 @@ var AssistantVisualization = function(props) {
48612
48516
  AssistantVisualization.Root = AssistantVisualizationRoot;
48613
48517
  AssistantVisualization.BarsVisualizer = BarsVisualizer2;
48614
48518
  var AssistantInfo = function(props) {
48615
- var $ = _c93(6);
48519
+ var $ = _c92(6);
48616
48520
  var assistantNameContext = useContext20(AssistantNameContext);
48617
48521
  var t0;
48618
48522
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
@@ -48652,7 +48556,7 @@ var AssistantInfo = function(props) {
48652
48556
  return t2;
48653
48557
  };
48654
48558
  var Visualization = function(props) {
48655
- var $ = _c93(4);
48559
+ var $ = _c92(4);
48656
48560
  var t0;
48657
48561
  var t1;
48658
48562
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
@@ -48684,9 +48588,9 @@ Visualization.Provider = Provider6;
48684
48588
  Visualization.AssistantVisualization = AssistantVisualization;
48685
48589
  Visualization.AssistantInfo = AssistantInfo;
48686
48590
  // src/components/threads/AudioThread/Status/index.tsx
48687
- import { c as _c95 } from "react-compiler-runtime";
48688
- // src/components/threads/AudioThread/Status/StatusMessages.tsx
48689
48591
  import { c as _c94 } from "react-compiler-runtime";
48592
+ // src/components/threads/AudioThread/Status/StatusMessages.tsx
48593
+ import { c as _c93 } from "react-compiler-runtime";
48690
48594
  import { Flex as Flex32, Text as Text9 } from "@radix-ui/themes";
48691
48595
  import { jsx as _jsx91, jsxs as _jsxs32 } from "react/jsx-runtime";
48692
48596
  var html = function(_ref) {
@@ -48696,7 +48600,7 @@ var html = function(_ref) {
48696
48600
  }).join(""), "\n }");
48697
48601
  };
48698
48602
  var StatusMessages = function(t0) {
48699
- var $ = _c94(9);
48603
+ var $ = _c93(9);
48700
48604
  var texts = t0.texts, className = t0.className, style = t0.style;
48701
48605
  var t1;
48702
48606
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
@@ -48800,7 +48704,7 @@ function _toPrimitive50(t, r) {
48800
48704
  return ("string" === r ? String : Number)(t);
48801
48705
  }
48802
48706
  var Status = function(props) {
48803
- var $ = _c95(12);
48707
+ var $ = _c94(12);
48804
48708
  var status = useStatus().status;
48805
48709
  if (status === "recording") {
48806
48710
  var _t;
@@ -48897,10 +48801,10 @@ var Status = function(props) {
48897
48801
  return t1;
48898
48802
  };
48899
48803
  // src/components/threads/AudioThread/Form/index.tsx
48900
- import { c as _c98 } from "react-compiler-runtime";
48804
+ import { c as _c97 } from "react-compiler-runtime";
48901
48805
  import { Flex as Flex34 } from "@radix-ui/themes";
48902
48806
  // src/components/threads/AudioThread/Form/MicIcon.tsx
48903
- import { c as _c96 } from "react-compiler-runtime";
48807
+ import { c as _c95 } from "react-compiler-runtime";
48904
48808
  import { jsx as _jsx93 } from "react/jsx-runtime";
48905
48809
  function ownKeys51(e, r) {
48906
48810
  var t = Object.keys(e);
@@ -48946,7 +48850,7 @@ function _toPrimitive51(t, r) {
48946
48850
  return ("string" === r ? String : Number)(t);
48947
48851
  }
48948
48852
  var MicIcon = function(props) {
48949
- var $ = _c96(3);
48853
+ var $ = _c95(3);
48950
48854
  var t0;
48951
48855
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
48952
48856
  t0 = /* @__PURE__ */ _jsx93("path", {
@@ -48978,12 +48882,12 @@ var MicIcon = function(props) {
48978
48882
  return t1;
48979
48883
  };
48980
48884
  // src/components/threads/AudioThread/Form/ActionButton/index.tsx
48981
- import { c as _c97 } from "react-compiler-runtime";
48885
+ import { c as _c96 } from "react-compiler-runtime";
48982
48886
  import { Flex as Flex33, IconButton as IconButton10 } from "@radix-ui/themes";
48983
48887
  import { StopIcon as StopIcon2, PauseIcon as PauseIcon2, ArrowUpIcon as ArrowUpIcon3, ResumeIcon } from "@radix-ui/react-icons";
48984
48888
  import { jsx as _jsx94, jsxs as _jsxs33 } from "react/jsx-runtime";
48985
48889
  var ActionButton = function() {
48986
- var $ = _c97(27);
48890
+ var $ = _c96(27);
48987
48891
  var status = useStatus().status;
48988
48892
  var audioThreadContext = useAudioThreadContext();
48989
48893
  var superinterfaceContext = useSuperinterfaceContext();
@@ -49221,7 +49125,7 @@ function _toPrimitive52(t, r) {
49221
49125
  return ("string" === r ? String : Number)(t);
49222
49126
  }
49223
49127
  var Form = function(props) {
49224
- var $ = _c98(17);
49128
+ var $ = _c97(17);
49225
49129
  var status = useStatus().status;
49226
49130
  var audioThreadContext = useAudioThreadContext();
49227
49131
  var t0 = status === "recording" ? "var(--accent-11)" : "var(--gray-11)";
@@ -49371,7 +49275,7 @@ function _toPrimitive53(t, r) {
49371
49275
  return ("string" === r ? String : Number)(t);
49372
49276
  }
49373
49277
  var AudioThread = function(props) {
49374
- var $ = _c99(5);
49278
+ var $ = _c98(5);
49375
49279
  var t0;
49376
49280
  var t1;
49377
49281
  var t2;
@@ -49453,7 +49357,7 @@ function _toPrimitive54(t, r) {
49453
49357
  return ("string" === r ? String : Number)(t);
49454
49358
  }
49455
49359
  var AudioThreadDialog = function(props) {
49456
- var $ = _c100(4);
49360
+ var $ = _c99(4);
49457
49361
  var t0;
49458
49362
  var t1;
49459
49363
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
@@ -49975,10 +49879,10 @@ var useWebrtcAudioRuntime = function() {
49975
49879
  ]);
49976
49880
  };
49977
49881
  // src/components/audioRuntimes/WebrtcAudioRuntimeProvider.tsx
49978
- import { c as _c101 } from "react-compiler-runtime";
49882
+ import { c as _c100 } from "react-compiler-runtime";
49979
49883
  import { jsx as _jsx98 } from "react/jsx-runtime";
49980
49884
  var WebrtcAudioRuntimeProvider = function(t0) {
49981
- var $ = _c101(5);
49885
+ var $ = _c100(5);
49982
49886
  var children = t0.children;
49983
49887
  var webrtcAudioRuntime = useWebrtcAudioRuntime().webrtcAudioRuntime;
49984
49888
  var t1;
@@ -50006,20 +49910,20 @@ var WebrtcAudioRuntimeProvider = function(t0) {
50006
49910
  return t2;
50007
49911
  };
50008
49912
  // src/components/gui/Gui/index.tsx
50009
- import { c as _c104 } from "react-compiler-runtime";
49913
+ import { c as _c103 } from "react-compiler-runtime";
50010
49914
  import { useMemo as useMemo23 } from "react";
50011
49915
  import { Flex as Flex35, Card as Card5, Spinner as Spinner3 } from "@radix-ui/themes";
50012
49916
  // src/hooks/messages/useLatestAssistantMessage/index.ts
50013
- import { c as _c102 } from "react-compiler-runtime";
49917
+ import { c as _c101 } from "react-compiler-runtime";
50014
49918
  import { useMemo as useMemo21 } from "react";
50015
49919
  var useLatestAssistantMessage = function() {
50016
- var $ = _c102(4);
49920
+ var $ = _c101(4);
50017
49921
  var _useMessages = useMessages(), messages2 = _useMessages.messages;
50018
49922
  var t0;
50019
49923
  var t1;
50020
49924
  if ($[0] !== messages2) {
50021
49925
  var _messages$find;
50022
- t1 = (_messages$find = messages2.find(_temp11)) !== null && _messages$find !== void 0 ? _messages$find : null;
49926
+ t1 = (_messages$find = messages2.find(_temp10)) !== null && _messages$find !== void 0 ? _messages$find : null;
50023
49927
  $[0] = messages2;
50024
49928
  $[1] = t1;
50025
49929
  } else {
@@ -50038,21 +49942,21 @@ var useLatestAssistantMessage = function() {
50038
49942
  t0 = t2;
50039
49943
  return t0;
50040
49944
  };
50041
- function _temp11(message) {
49945
+ function _temp10(message) {
50042
49946
  return message.role === "assistant";
50043
49947
  }
50044
49948
  // src/hooks/messages/useLatestAssistantMessageWithContent/index.ts
50045
- import { c as _c103 } from "react-compiler-runtime";
49949
+ import { c as _c102 } from "react-compiler-runtime";
50046
49950
  import { isEmpty as isEmpty3 } from "radash";
50047
49951
  import { useMemo as useMemo22 } from "react";
50048
49952
  var useLatestAssistantMessageWithContent = function() {
50049
- var $ = _c103(4);
49953
+ var $ = _c102(4);
50050
49954
  var _useMessages = useMessages(), messages2 = _useMessages.messages;
50051
49955
  var t0;
50052
49956
  var t1;
50053
49957
  if ($[0] !== messages2) {
50054
49958
  var _messages$find;
50055
- t1 = (_messages$find = messages2.find(_temp26)) !== null && _messages$find !== void 0 ? _messages$find : null;
49959
+ t1 = (_messages$find = messages2.find(_temp25)) !== null && _messages$find !== void 0 ? _messages$find : null;
50056
49960
  $[0] = messages2;
50057
49961
  $[1] = t1;
50058
49962
  } else {
@@ -50071,16 +49975,16 @@ var useLatestAssistantMessageWithContent = function() {
50071
49975
  t0 = t2;
50072
49976
  return t0;
50073
49977
  };
50074
- function _temp12(content2) {
49978
+ function _temp11(content2) {
50075
49979
  return content2.type === "text" && !isEmpty3(content2.text.value);
50076
49980
  }
50077
- function _temp26(message) {
50078
- return message.role === "assistant" && message.content.some(_temp12);
49981
+ function _temp25(message) {
49982
+ return message.role === "assistant" && message.content.some(_temp11);
50079
49983
  }
50080
49984
  // src/components/gui/Gui/index.tsx
50081
49985
  import { jsx as _jsx99, jsxs as _jsxs37 } from "react/jsx-runtime";
50082
49986
  var StartingToolCalls3 = function() {
50083
- var $ = _c104(2);
49987
+ var $ = _c103(2);
50084
49988
  var _useComponents = useComponents(), t0 = _useComponents.components;
50085
49989
  var StartingToolCalls4 = t0.StartingToolCalls;
50086
49990
  var t1;
@@ -50094,7 +49998,7 @@ var StartingToolCalls3 = function() {
50094
49998
  return t1;
50095
49999
  };
50096
50000
  var Content10 = function(t0) {
50097
- var $ = _c104(5);
50001
+ var $ = _c103(5);
50098
50002
  var latestRunStep = t0.latestRunStep;
50099
50003
  var t1;
50100
50004
  bb0: {
@@ -50148,14 +50052,14 @@ var Content10 = function(t0) {
50148
50052
  return t2;
50149
50053
  };
50150
50054
  var Progress2 = function(t0) {
50151
- var $ = _c104(5);
50055
+ var $ = _c103(5);
50152
50056
  var latestAssistantMessage = t0.latestAssistantMessage;
50153
50057
  var isMutatingMessage = useIsMutatingMessage();
50154
50058
  var t1;
50155
50059
  var t2;
50156
50060
  if ($[0] !== latestAssistantMessage.runSteps) {
50157
50061
  var _latestAssistantMessa;
50158
- t2 = (_latestAssistantMessa = latestAssistantMessage.runSteps.find(_temp13)) !== null && _latestAssistantMessa !== void 0 ? _latestAssistantMessa : null;
50062
+ t2 = (_latestAssistantMessa = latestAssistantMessage.runSteps.find(_temp12)) !== null && _latestAssistantMessa !== void 0 ? _latestAssistantMessa : null;
50159
50063
  $[0] = latestAssistantMessage.runSteps;
50160
50064
  $[1] = t2;
50161
50065
  } else {
@@ -50198,7 +50102,7 @@ var Progress2 = function(t0) {
50198
50102
  return t4;
50199
50103
  };
50200
50104
  var Gui = function() {
50201
- var $ = _c104(8);
50105
+ var $ = _c103(8);
50202
50106
  var latestAssistantMessage = useLatestAssistantMessage().latestAssistantMessage;
50203
50107
  var latestAssistantMessageWithContent = useLatestAssistantMessageWithContent().latestAssistantMessageWithContent;
50204
50108
  if (!latestAssistantMessage || !latestAssistantMessageWithContent) {
@@ -50260,11 +50164,11 @@ var Gui = function() {
50260
50164
  }
50261
50165
  return t2;
50262
50166
  };
50263
- function _temp13(rs) {
50167
+ function _temp12(rs) {
50264
50168
  return rs.status === "in_progress";
50265
50169
  }
50266
50170
  // src/components/markdown/MarkdownProvider/index.tsx
50267
- import { c as _c105 } from "react-compiler-runtime";
50171
+ import { c as _c104 } from "react-compiler-runtime";
50268
50172
  import { useMemo as useMemo24 } from "react";
50269
50173
  import { jsx as _jsx100 } from "react/jsx-runtime";
50270
50174
  var _excluded7 = [
@@ -50289,7 +50193,7 @@ function _objectWithoutPropertiesLoose7(r, e) {
50289
50193
  return t;
50290
50194
  }
50291
50195
  var MarkdownProvider = function(t0) {
50292
- var $ = _c105(9);
50196
+ var $ = _c104(9);
50293
50197
  var children;
50294
50198
  var rest;
50295
50199
  if ($[0] !== t0) {
@@ -50332,18 +50236,18 @@ var MarkdownProvider = function(t0) {
50332
50236
  return t3;
50333
50237
  };
50334
50238
  // src/components/annotations/SourceAnnotation/index.tsx
50335
- import { c as _c108 } from "react-compiler-runtime";
50336
- // src/components/annotations/SourceAnnotation/FileCitation/index.tsx
50337
50239
  import { c as _c107 } from "react-compiler-runtime";
50240
+ // src/components/annotations/SourceAnnotation/FileCitation/index.tsx
50241
+ import { c as _c106 } from "react-compiler-runtime";
50338
50242
  import { useState as useState13 } from "react";
50339
50243
  import { QuoteIcon as QuoteIcon2 } from "@radix-ui/react-icons";
50340
50244
  import { Dialog, VisuallyHidden, IconButton as IconButton11 } from "@radix-ui/themes";
50341
50245
  // src/components/annotations/SourceAnnotation/FileCitation/Content.tsx
50342
- import { c as _c106 } from "react-compiler-runtime";
50246
+ import { c as _c105 } from "react-compiler-runtime";
50343
50247
  import { Flex as Flex36, Card as Card6, Inset as Inset3 } from "@radix-ui/themes";
50344
50248
  import { jsx as _jsx101 } from "react/jsx-runtime";
50345
50249
  var Content11 = function(t0) {
50346
- var $ = _c106(5);
50250
+ var $ = _c105(5);
50347
50251
  var fileId = t0.fileId;
50348
50252
  var superinterfaceContext = useSuperinterfaceContext();
50349
50253
  var nextSearchParams = new URLSearchParams(superinterfaceContext.variables);
@@ -50409,7 +50313,7 @@ var Content11 = function(t0) {
50409
50313
  // src/components/annotations/SourceAnnotation/FileCitation/index.tsx
50410
50314
  import { jsx as _jsx102, jsxs as _jsxs38, Fragment as _Fragment6 } from "react/jsx-runtime";
50411
50315
  var FileCitation = function(t0) {
50412
- var $ = _c107(18);
50316
+ var $ = _c106(18);
50413
50317
  var annotation = t0.annotation;
50414
50318
  var _useState13 = _sliced_to_array(useState13(null), 2), activeFileId = _useState13[0], setActiveFileId = _useState13[1];
50415
50319
  var t1;
@@ -50558,7 +50462,7 @@ function _objectWithoutPropertiesLoose8(r, e) {
50558
50462
  return t;
50559
50463
  }
50560
50464
  var SourceAnnotation = function(t0) {
50561
- var $ = _c108(10);
50465
+ var $ = _c107(10);
50562
50466
  var children;
50563
50467
  var rest;
50564
50468
  if ($[0] !== t0) {
@@ -50615,7 +50519,7 @@ var SourceAnnotation = function(t0) {
50615
50519
  return null;
50616
50520
  };
50617
50521
  // src/components/avatars/Avatar.tsx
50618
- import { c as _c111 } from "react-compiler-runtime";
50522
+ import { c as _c110 } from "react-compiler-runtime";
50619
50523
  // src/enums/index.ts
50620
50524
  var IconAvatarName = /* @__PURE__ */ function(IconAvatarName2) {
50621
50525
  IconAvatarName2["BACKPACK"] = "BACKPACK";
@@ -50640,7 +50544,7 @@ var AvatarType = /* @__PURE__ */ function(AvatarType2) {
50640
50544
  // src/components/avatars/Avatar.tsx
50641
50545
  import { Avatar as RadixAvatar } from "@radix-ui/themes";
50642
50546
  // src/components/imageAvatars/ImageAvatar/index.tsx
50643
- import { c as _c109 } from "react-compiler-runtime";
50547
+ import { c as _c108 } from "react-compiler-runtime";
50644
50548
  import { Avatar as Avatar4 } from "@radix-ui/themes";
50645
50549
  // src/components/imageAvatars/ImageAvatar/lib/optimizedSrc/path.ts
50646
50550
  var width = function(_ref) {
@@ -50694,7 +50598,7 @@ var optimizedSrc = function(_ref) {
50694
50598
  // src/components/imageAvatars/ImageAvatar/index.tsx
50695
50599
  import { jsx as _jsx104 } from "react/jsx-runtime";
50696
50600
  var ImageAvatar = function(t0) {
50697
- var $ = _c109(9);
50601
+ var $ = _c108(9);
50698
50602
  var imageAvatar = t0.imageAvatar, size = t0.size, className = t0.className, style = t0.style;
50699
50603
  var superinterfaceContext = useSuperinterfaceContext();
50700
50604
  var t1;
@@ -50731,7 +50635,7 @@ var ImageAvatar = function(t0) {
50731
50635
  return t2;
50732
50636
  };
50733
50637
  // src/components/iconAvatars/IconAvatar.tsx
50734
- import { c as _c110 } from "react-compiler-runtime";
50638
+ import { c as _c109 } from "react-compiler-runtime";
50735
50639
  import { useMemo as useMemo25 } from "react";
50736
50640
  import { Avatar as Avatar5 } from "@radix-ui/themes";
50737
50641
  // src/lib/iconAvatars/iconAvatarComponents.ts
@@ -50741,7 +50645,7 @@ var iconAvatarComponents = (_obj = {}, _define_property(_obj, IconAvatarName.BAC
50741
50645
  // src/components/iconAvatars/IconAvatar.tsx
50742
50646
  import { jsx as _jsx105 } from "react/jsx-runtime";
50743
50647
  var IconAvatar = function(t0) {
50744
- var $ = _c110(7);
50648
+ var $ = _c109(7);
50745
50649
  var iconAvatar = t0.iconAvatar, size = t0.size, className = t0.className, style = t0.style;
50746
50650
  var t1;
50747
50651
  t1 = iconAvatarComponents[iconAvatar.name];
@@ -50775,7 +50679,7 @@ var IconAvatar = function(t0) {
50775
50679
  // src/components/avatars/Avatar.tsx
50776
50680
  import { jsx as _jsx106 } from "react/jsx-runtime";
50777
50681
  var Avatar6 = function(t0) {
50778
- var $ = _c111(14);
50682
+ var $ = _c110(14);
50779
50683
  var avatar = t0.avatar, t1 = t0.size, className = t0.className, style = t0.style;
50780
50684
  var size = t1 === void 0 ? "1" : t1;
50781
50685
  if (avatar) {
@@ -50836,7 +50740,7 @@ var Avatar6 = function(t0) {
50836
50740
  return t2;
50837
50741
  };
50838
50742
  // src/components/components/ComponentsProvider.tsx
50839
- import { c as _c112 } from "react-compiler-runtime";
50743
+ import { c as _c111 } from "react-compiler-runtime";
50840
50744
  import { useMemo as useMemo26 } from "react";
50841
50745
  import { jsx as _jsx107 } from "react/jsx-runtime";
50842
50746
  var _excluded9 = [
@@ -50861,7 +50765,7 @@ function _objectWithoutPropertiesLoose9(r, e) {
50861
50765
  return t;
50862
50766
  }
50863
50767
  var ComponentsProvider = function(t0) {
50864
- var $ = _c112(9);
50768
+ var $ = _c111(9);
50865
50769
  var children;
50866
50770
  var rest;
50867
50771
  if ($[0] !== t0) {
@@ -50904,11 +50808,11 @@ var ComponentsProvider = function(t0) {
50904
50808
  return t3;
50905
50809
  };
50906
50810
  // src/components/assistants/AssistantProvider/index.tsx
50907
- import { c as _c113 } from "react-compiler-runtime";
50811
+ import { c as _c112 } from "react-compiler-runtime";
50908
50812
  import { jsx as _jsx108 } from "react/jsx-runtime";
50909
50813
  var AssistantProvider = function(t0) {
50910
50814
  var _assistant$name;
50911
- var $ = _c113(10);
50815
+ var $ = _c112(10);
50912
50816
  var children = t0.children;
50913
50817
  var superinterfaceContext = useSuperinterfaceContext();
50914
50818
  var t1;