@superinterface/react 5.3.0-beta.2 → 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,210 +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
+ ]);
47339
+ var pickLockRef = useRef8(false);
47347
47340
  var currentSentenceRef = useRef8(null);
47348
47341
  var messagesProps = useMessages();
47349
- var t7;
47350
- var t8;
47351
- if ($[7] !== messagesProps.messages) {
47352
- t7 = function() {
47353
- var assistants = messagesProps.messages.filter(_temp9);
47354
- setAudioQueue(function(prev) {
47355
- var prevById = new Map(prev.map(_temp24));
47356
- var next = [];
47357
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
47358
- try {
47359
- for(var _iterator = assistants[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) {
47366
- continue;
47367
- }
47368
- var sentences = segment(inp);
47369
- 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 {
47370
47380
  next.push({
47371
47381
  id: m_0.id,
47372
47382
  status: m_0.status,
47373
47383
  sentences: sentences,
47374
- nextIndex: Math.min((_existing$nextIndex = existing === null || existing === void 0 ? void 0 : existing.nextIndex) !== null && _existing$nextIndex !== void 0 ? _existing$nextIndex : 0, sentences.length),
47375
- 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
47376
47386
  });
47377
- }
47378
- } catch (err) {
47379
- _didIteratorError = true;
47380
- _iteratorError = err;
47381
- } finally{
47382
- try {
47383
- if (!_iteratorNormalCompletion && _iterator.return != null) {
47384
- _iterator.return();
47385
- }
47386
- } finally{
47387
- if (_didIteratorError) {
47388
- throw _iteratorError;
47389
- }
47390
- }
47391
- }
47392
- return next;
47393
- });
47394
- };
47395
- t8 = [
47396
- messagesProps.messages
47397
- ];
47398
- $[7] = messagesProps.messages;
47399
- $[8] = t7;
47400
- $[9] = t8;
47401
- } else {
47402
- t7 = $[8];
47403
- t8 = $[9];
47404
- }
47405
- useEffect10(t7, t8);
47406
- var t9;
47407
- if ($[10] !== audioPlayer || $[11] !== fullSentenceRegex || $[12] !== isAudioPlayed || $[13] !== nextAudioPlayer || $[14] !== superinterfaceContext) {
47408
- t9 = function(t102) {
47409
- var input2 = t102.input, onPlay = t102.onPlay, onStop = t102.onStop, onEnd_0 = t102.onEnd;
47410
- var searchParams = new URLSearchParams(_objectSpread47({
47411
- input: input2
47412
- }, superinterfaceContext.variables));
47413
- audioPlayer.load("".concat(superinterfaceContext.baseUrl, "/audio-runtimes/tts?").concat(searchParams), {
47414
- format: "mp3",
47415
- autoplay: isAudioPlayed,
47416
- html5: isHtmlAudioSupported,
47417
- onplay: onPlay,
47418
- onstop: onStop,
47419
- onload: function() {
47420
- var current = currentSentenceRef.current;
47421
- if (!current) {
47422
- return;
47423
- }
47424
- var msg = audioQueueRef.current.find(function(m_1) {
47425
- return m_1.id === current.messageId;
47426
- });
47427
- if (!msg) {
47428
- return;
47429
- }
47430
- var nextSentence = msg.sentences[msg.nextIndex];
47431
- if (!nextSentence) {
47432
- return;
47433
- }
47434
- if (!fullSentenceRegex.test(nextSentence)) {
47435
- return;
47436
- }
47437
- var nextSearchParams = new URLSearchParams(_objectSpread47({
47438
- input: nextSentence
47439
- }, superinterfaceContext.variables));
47440
- nextAudioPlayer.load("".concat(superinterfaceContext.baseUrl, "/audio-runtimes/tts?").concat(nextSearchParams), {
47441
- format: "mp3",
47442
- autoplay: false,
47443
- html5: isHtmlAudioSupported
47444
- });
47445
- },
47446
- onend: onEnd_0
47447
- });
47448
- };
47449
- $[10] = audioPlayer;
47450
- $[11] = fullSentenceRegex;
47451
- $[12] = isAudioPlayed;
47452
- $[13] = nextAudioPlayer;
47453
- $[14] = superinterfaceContext;
47454
- $[15] = t9;
47455
- } else {
47456
- t9 = $[15];
47457
- }
47458
- var defaultPlay = t9;
47459
- var t10;
47460
- t10 = passedPlay || defaultPlay;
47461
- var play = t10;
47462
- var t11;
47463
- var t12;
47464
- if ($[16] !== audioPlayer.playing || $[17] !== audioQueue || $[18] !== fullSentenceRegex || $[19] !== isPlaying || $[20] !== _onEnd || $[21] !== play) {
47465
- t11 = function() {
47466
- if (isPlaying) {
47467
- return;
47468
- }
47469
- if (audioPlayer.playing) {
47470
- return;
47471
- }
47472
- var candidate;
47473
- candidate = null;
47474
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
47475
- try {
47476
- for(var _iterator = audioQueue[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
47477
- var msg_0 = _step.value;
47478
- if (msg_0.stopped) {
47479
- continue;
47480
- }
47481
- var sentence = msg_0.sentences[msg_0.nextIndex];
47482
- if (!sentence) {
47483
- continue;
47484
- }
47485
- var isFull = isOptimistic({
47486
- id: msg_0.id
47487
- }) || msg_0.status !== "in_progress" || fullSentenceRegex.test(sentence);
47488
- if (isFull) {
47489
- candidate = {
47490
- messageId: msg_0.id,
47491
- sentence: sentence,
47492
- index: msg_0.nextIndex,
47493
- ownerStatus: msg_0.status
47494
- };
47495
- break;
47387
+ changed = true;
47496
47388
  }
47497
47389
  }
47498
47390
  } catch (err) {
@@ -47509,199 +47401,219 @@ var useMessageAudio = function(t0) {
47509
47401
  }
47510
47402
  }
47511
47403
  }
47512
- if (!candidate) {
47513
- 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
+ }
47514
47413
  }
47515
- setIsPlaying(true);
47516
- currentSentenceRef.current = {
47517
- messageId: candidate.messageId,
47518
- index: candidate.index
47519
- };
47520
- setAudioQueue(function(prev_0) {
47521
- return prev_0.map(function(m_2) {
47522
- return m_2.id === candidate.messageId ? _objectSpread47(_objectSpread47({}, m_2), {}, {
47523
- nextIndex: m_2.nextIndex + 1
47524
- }) : 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;
47525
47436
  });
47526
- });
47527
- play({
47528
- input: candidate.sentence,
47529
- onPlay: function() {
47530
- return setIsAudioPlayed(true);
47531
- },
47532
- onStop: function() {
47533
- setAudioQueue(function(prev_1) {
47534
- return prev_1.map(function(m_3) {
47535
- return m_3.id === candidate.messageId ? _objectSpread47(_objectSpread47({}, m_3), {}, {
47536
- stopped: true
47537
- }) : m_3;
47538
- });
47539
- });
47540
- setIsPlaying(false);
47541
- currentSentenceRef.current = null;
47542
- },
47543
- onEnd: function() {
47544
- setIsPlaying(false);
47545
- currentSentenceRef.current = null;
47546
- var hasPending = audioQueueRef.current.some(_temp32);
47547
- if (!hasPending) {
47548
- _onEnd();
47549
- }
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;
47550
47492
  }
47551
- });
47552
- };
47553
- t12 = [
47554
- isPlaying,
47555
- audioPlayer.playing,
47556
- audioQueue,
47557
- play,
47558
- fullSentenceRegex,
47559
- _onEnd
47560
- ];
47561
- $[16] = audioPlayer.playing;
47562
- $[17] = audioQueue;
47563
- $[18] = fullSentenceRegex;
47564
- $[19] = isPlaying;
47565
- $[20] = _onEnd;
47566
- $[21] = play;
47567
- $[22] = t11;
47568
- $[23] = t12;
47569
- } else {
47570
- t11 = $[22];
47571
- t12 = $[23];
47572
- }
47573
- useEffect10(t11, t12);
47574
- var t13;
47575
- if ($[24] !== audioPlayer) {
47576
- t13 = [
47577
- audioPlayer
47578
- ];
47579
- $[24] = audioPlayer;
47580
- $[25] = t13;
47581
- } else {
47582
- t13 = $[25];
47583
- }
47584
- useEffect10(_temp42, t13);
47585
- var _useState93 = _sliced_to_array(useState9(null), 2), audioEngine = _useState93[0], setAudioEngine = _useState93[1];
47586
- var isAudioEngineInited = useRef8(false);
47587
- var t14;
47588
- if ($[26] !== audioPlayer.playing) {
47589
- t14 = function() {
47590
- if (!audioPlayer.playing) {
47591
- return;
47592
47493
  }
47593
- if (isAudioEngineInited.current) {
47594
- 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
+ }
47595
47506
  }
47596
- isAudioEngineInited.current = true;
47597
- if (isHtmlAudioSupported) {
47598
- var audioContext = new AudioContext();
47599
- setAudioEngine({
47600
- source: audioContext.createMediaElementSource(Howler._howls[0]._sounds[0]._node),
47601
- 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
+ });
47602
47534
  });
47603
- } else {
47604
- setAudioEngine({
47605
- source: Howler.masterGain,
47606
- 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;
47607
47548
  });
47549
+ if (!hasPending) _onEnd();
47608
47550
  }
47609
- };
47610
- $[26] = audioPlayer.playing;
47611
- $[27] = t14;
47612
- } else {
47613
- t14 = $[27];
47614
- }
47615
- var t15;
47616
- if ($[28] !== audioPlayer) {
47617
- t15 = [
47618
- audioPlayer
47619
- ];
47620
- $[28] = audioPlayer;
47621
- $[29] = t15;
47622
- } else {
47623
- t15 = $[29];
47624
- }
47625
- useEffect10(t14, t15);
47626
- var t16;
47627
- bb0: {
47628
- if (!audioEngine) {
47629
- t16 = null;
47630
- 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";
47631
47565
  }
47632
- var analyser;
47633
- if ($[30] !== audioEngine.audioContext || $[31] !== audioEngine.source) {
47634
- analyser = audioEngine.audioContext.createAnalyser();
47635
- audioEngine.source.connect(audioEngine.audioContext.destination);
47636
- audioEngine.source.connect(analyser);
47637
- $[30] = audioEngine.audioContext;
47638
- $[31] = audioEngine.source;
47639
- $[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
+ });
47640
47584
  } else {
47641
- analyser = $[32];
47642
- }
47643
- t16 = analyser;
47644
- }
47645
- var visualizationAnalyser = t16;
47646
- var t17;
47647
- var t18;
47648
- if ($[33] !== audioQueue || $[34] !== isPlaying) {
47649
- t18 = isPlaying || audioQueue.some(_temp52);
47650
- $[33] = audioQueue;
47651
- $[34] = isPlaying;
47652
- $[35] = t18;
47653
- } else {
47654
- t18 = $[35];
47655
- }
47656
- t17 = t18;
47657
- var isPending = t17;
47658
- var t19;
47659
- if ($[36] !== audioPlayer || $[37] !== isAudioPlayed || $[38] !== isPending || $[39] !== visualizationAnalyser) {
47660
- t19 = _objectSpread47(_objectSpread47({
47661
- isPending: isPending,
47662
- isAudioPlayed: isAudioPlayed
47663
- }, audioPlayer), {}, {
47664
- 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");
47665
47605
  });
47666
- $[36] = audioPlayer;
47667
- $[37] = isAudioPlayed;
47668
- $[38] = isPending;
47669
- $[39] = visualizationAnalyser;
47670
- $[40] = t19;
47671
- } else {
47672
- t19 = $[40];
47673
- }
47674
- return t19;
47606
+ }, [
47607
+ isPlaying,
47608
+ audioQueue
47609
+ ]);
47610
+ return _objectSpread47(_objectSpread47({
47611
+ isPending: isPending,
47612
+ isAudioPlayed: isAudioPlayed
47613
+ }, audioPlayer), {}, {
47614
+ visualizationAnalyser: visualizationAnalyser
47615
+ });
47675
47616
  };
47676
- function _temp9(m) {
47677
- return m.role === "assistant";
47678
- }
47679
- function _temp24(p) {
47680
- return [
47681
- p.id,
47682
- p
47683
- ];
47684
- }
47685
- function _temp32(m_4) {
47686
- if (m_4.stopped) {
47687
- return false;
47688
- }
47689
- var hasMore = m_4.nextIndex < m_4.sentences.length;
47690
- var streaming = m_4.status === "in_progress";
47691
- return hasMore || streaming;
47692
- }
47693
- function _temp42() {
47694
- if (isHtmlAudioSupported) {
47695
- var _Howler$_howls$;
47696
- 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)) {
47697
- return;
47698
- }
47699
- Howler._howls[0]._sounds[0]._node.crossOrigin = "anonymous";
47700
- }
47701
- }
47702
- function _temp52(m_5) {
47703
- return !m_5.stopped && (m_5.nextIndex < m_5.sentences.length || m_5.status === "in_progress");
47704
- }
47705
47617
  // src/hooks/audioRuntimes/useTtsAudioRuntime/index.ts
47706
47618
  import { useQueryClient as useQueryClient6 } from "@tanstack/react-query";
47707
47619
  // src/hooks/audioRuntimes/useTtsAudioRuntime/blobToData.ts
@@ -47739,7 +47651,7 @@ function _asyncToGenerator11(n) {
47739
47651
  };
47740
47652
  }
47741
47653
  var useTtsAudioRuntime = function(t0) {
47742
- var $ = _c89(30);
47654
+ var $ = _c88(30);
47743
47655
  var play = t0.play, passedOnEnd = t0.onEnd;
47744
47656
  var addToast = useToasts().addToast;
47745
47657
  var queryClient = useQueryClient6();
@@ -47768,7 +47680,7 @@ var useTtsAudioRuntime = function(t0) {
47768
47680
  if ($[1] !== createMessageProps) {
47769
47681
  t2 = {
47770
47682
  isStopOnSilence: true,
47771
- onStart: _temp10,
47683
+ onStart: _temp9,
47772
47684
  onStop: function() {
47773
47685
  var _onStop = _asyncToGenerator11(function(_event, chunks) {
47774
47686
  var blob, audioContent;
@@ -47909,23 +47821,23 @@ var useTtsAudioRuntime = function(t0) {
47909
47821
  t5 = t8;
47910
47822
  return t5;
47911
47823
  };
47912
- function _temp10() {
47913
- return _temp25.apply(this, arguments);
47824
+ function _temp9() {
47825
+ return _temp24.apply(this, arguments);
47914
47826
  }
47915
- function _temp25() {
47916
- _temp25 = _asyncToGenerator11(function() {
47827
+ function _temp24() {
47828
+ _temp24 = _asyncToGenerator11(function() {
47917
47829
  return _ts_generator(this, function(_state) {
47918
47830
  return [
47919
47831
  2
47920
47832
  ];
47921
47833
  });
47922
47834
  });
47923
- return _temp25.apply(this, arguments);
47835
+ return _temp24.apply(this, arguments);
47924
47836
  }
47925
47837
  // src/components/audioRuntimes/TtsAudioRuntimeProvider.tsx
47926
47838
  import { jsx as _jsx87 } from "react/jsx-runtime";
47927
47839
  var TtsAudioRuntimeProvider = function(t0) {
47928
- var $ = _c90(8);
47840
+ var $ = _c89(8);
47929
47841
  var children = t0.children, play = t0.play, onEnd = t0.onEnd;
47930
47842
  var t1;
47931
47843
  if ($[0] !== onEnd || $[1] !== play) {
@@ -48038,7 +47950,7 @@ function _objectWithoutPropertiesLoose5(r, e) {
48038
47950
  return t;
48039
47951
  }
48040
47952
  var Content9 = function(t0) {
48041
- var $ = _c91(4);
47953
+ var $ = _c90(4);
48042
47954
  var children = t0.children, className = t0.className, style = t0.style;
48043
47955
  var t1;
48044
47956
  if ($[0] !== children || $[1] !== className || $[2] !== style) {
@@ -48060,7 +47972,7 @@ var Content9 = function(t0) {
48060
47972
  return t1;
48061
47973
  };
48062
47974
  var AudioRuntimeProvider = function(t0) {
48063
- var $ = _c91(4);
47975
+ var $ = _c90(4);
48064
47976
  var children = t0.children, play = t0.play, onEnd = t0.onEnd;
48065
47977
  var audioThreadContext = useAudioThreadContext();
48066
47978
  if (audioThreadContext.audioRuntime) {
@@ -48083,7 +47995,7 @@ var AudioRuntimeProvider = function(t0) {
48083
47995
  return t1;
48084
47996
  };
48085
47997
  var Provider5 = function(t0) {
48086
- var $ = _c91(9);
47998
+ var $ = _c90(9);
48087
47999
  var children;
48088
48000
  var rest;
48089
48001
  if ($[0] !== t0) {
@@ -48123,7 +48035,7 @@ var Provider5 = function(t0) {
48123
48035
  return t2;
48124
48036
  };
48125
48037
  var Root16 = function(t0) {
48126
- var $ = _c91(18);
48038
+ var $ = _c90(18);
48127
48039
  var children;
48128
48040
  var className;
48129
48041
  var onEnd;
@@ -48195,7 +48107,7 @@ var Root16 = function(t0) {
48195
48107
  return t3;
48196
48108
  };
48197
48109
  // src/components/threads/AudioThread/Visualization/index.tsx
48198
- import { c as _c93 } from "react-compiler-runtime";
48110
+ import { c as _c92 } from "react-compiler-runtime";
48199
48111
  import { useState as useState11, useCallback as useCallback9, useEffect as useEffect12, useContext as useContext20, createContext as createContext14 } from "react";
48200
48112
  import _9 from "lodash";
48201
48113
  import { Flex as Flex31 } from "@radix-ui/themes";
@@ -48264,10 +48176,10 @@ var BarsVisualizer = function(_ref) {
48264
48176
  });
48265
48177
  };
48266
48178
  // src/hooks/audioThreads/useStatus/index.ts
48267
- import { c as _c92 } from "react-compiler-runtime";
48179
+ import { c as _c91 } from "react-compiler-runtime";
48268
48180
  import { useMemo as useMemo19 } from "react";
48269
48181
  var useStatus = function() {
48270
- var $ = _c92(2);
48182
+ var $ = _c91(2);
48271
48183
  var audioRuntime = useAudioThreadContext().audioRuntime;
48272
48184
  var t0;
48273
48185
  bb0: {
@@ -48427,7 +48339,7 @@ var Provider6 = function(_ref) {
48427
48339
  });
48428
48340
  };
48429
48341
  var Root17 = function(t0) {
48430
- var $ = _c93(6);
48342
+ var $ = _c92(6);
48431
48343
  var children;
48432
48344
  var rest;
48433
48345
  if ($[0] !== t0) {
@@ -48464,7 +48376,7 @@ var Root17 = function(t0) {
48464
48376
  return t1;
48465
48377
  };
48466
48378
  var BarsVisualizer2 = function(t0) {
48467
- var $ = _c93(10);
48379
+ var $ = _c92(10);
48468
48380
  var rest;
48469
48381
  var t1;
48470
48382
  var t2;
@@ -48508,7 +48420,7 @@ var BarsVisualizer2 = function(t0) {
48508
48420
  return t4;
48509
48421
  };
48510
48422
  var AssistantVisualizationRoot = function(t0) {
48511
- var $ = _c93(17);
48423
+ var $ = _c92(17);
48512
48424
  var children;
48513
48425
  var rest;
48514
48426
  var t1;
@@ -48581,7 +48493,7 @@ var AssistantVisualizationRoot = function(t0) {
48581
48493
  return t6;
48582
48494
  };
48583
48495
  var AssistantVisualization = function(props) {
48584
- var $ = _c93(3);
48496
+ var $ = _c92(3);
48585
48497
  var t0;
48586
48498
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
48587
48499
  t0 = /* @__PURE__ */ _jsx90(BarsVisualizer2, {});
@@ -48604,7 +48516,7 @@ var AssistantVisualization = function(props) {
48604
48516
  AssistantVisualization.Root = AssistantVisualizationRoot;
48605
48517
  AssistantVisualization.BarsVisualizer = BarsVisualizer2;
48606
48518
  var AssistantInfo = function(props) {
48607
- var $ = _c93(6);
48519
+ var $ = _c92(6);
48608
48520
  var assistantNameContext = useContext20(AssistantNameContext);
48609
48521
  var t0;
48610
48522
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
@@ -48644,7 +48556,7 @@ var AssistantInfo = function(props) {
48644
48556
  return t2;
48645
48557
  };
48646
48558
  var Visualization = function(props) {
48647
- var $ = _c93(4);
48559
+ var $ = _c92(4);
48648
48560
  var t0;
48649
48561
  var t1;
48650
48562
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
@@ -48676,9 +48588,9 @@ Visualization.Provider = Provider6;
48676
48588
  Visualization.AssistantVisualization = AssistantVisualization;
48677
48589
  Visualization.AssistantInfo = AssistantInfo;
48678
48590
  // src/components/threads/AudioThread/Status/index.tsx
48679
- import { c as _c95 } from "react-compiler-runtime";
48680
- // src/components/threads/AudioThread/Status/StatusMessages.tsx
48681
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";
48682
48594
  import { Flex as Flex32, Text as Text9 } from "@radix-ui/themes";
48683
48595
  import { jsx as _jsx91, jsxs as _jsxs32 } from "react/jsx-runtime";
48684
48596
  var html = function(_ref) {
@@ -48688,7 +48600,7 @@ var html = function(_ref) {
48688
48600
  }).join(""), "\n }");
48689
48601
  };
48690
48602
  var StatusMessages = function(t0) {
48691
- var $ = _c94(9);
48603
+ var $ = _c93(9);
48692
48604
  var texts = t0.texts, className = t0.className, style = t0.style;
48693
48605
  var t1;
48694
48606
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
@@ -48792,7 +48704,7 @@ function _toPrimitive50(t, r) {
48792
48704
  return ("string" === r ? String : Number)(t);
48793
48705
  }
48794
48706
  var Status = function(props) {
48795
- var $ = _c95(12);
48707
+ var $ = _c94(12);
48796
48708
  var status = useStatus().status;
48797
48709
  if (status === "recording") {
48798
48710
  var _t;
@@ -48889,10 +48801,10 @@ var Status = function(props) {
48889
48801
  return t1;
48890
48802
  };
48891
48803
  // src/components/threads/AudioThread/Form/index.tsx
48892
- import { c as _c98 } from "react-compiler-runtime";
48804
+ import { c as _c97 } from "react-compiler-runtime";
48893
48805
  import { Flex as Flex34 } from "@radix-ui/themes";
48894
48806
  // src/components/threads/AudioThread/Form/MicIcon.tsx
48895
- import { c as _c96 } from "react-compiler-runtime";
48807
+ import { c as _c95 } from "react-compiler-runtime";
48896
48808
  import { jsx as _jsx93 } from "react/jsx-runtime";
48897
48809
  function ownKeys51(e, r) {
48898
48810
  var t = Object.keys(e);
@@ -48938,7 +48850,7 @@ function _toPrimitive51(t, r) {
48938
48850
  return ("string" === r ? String : Number)(t);
48939
48851
  }
48940
48852
  var MicIcon = function(props) {
48941
- var $ = _c96(3);
48853
+ var $ = _c95(3);
48942
48854
  var t0;
48943
48855
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
48944
48856
  t0 = /* @__PURE__ */ _jsx93("path", {
@@ -48970,12 +48882,12 @@ var MicIcon = function(props) {
48970
48882
  return t1;
48971
48883
  };
48972
48884
  // src/components/threads/AudioThread/Form/ActionButton/index.tsx
48973
- import { c as _c97 } from "react-compiler-runtime";
48885
+ import { c as _c96 } from "react-compiler-runtime";
48974
48886
  import { Flex as Flex33, IconButton as IconButton10 } from "@radix-ui/themes";
48975
48887
  import { StopIcon as StopIcon2, PauseIcon as PauseIcon2, ArrowUpIcon as ArrowUpIcon3, ResumeIcon } from "@radix-ui/react-icons";
48976
48888
  import { jsx as _jsx94, jsxs as _jsxs33 } from "react/jsx-runtime";
48977
48889
  var ActionButton = function() {
48978
- var $ = _c97(27);
48890
+ var $ = _c96(27);
48979
48891
  var status = useStatus().status;
48980
48892
  var audioThreadContext = useAudioThreadContext();
48981
48893
  var superinterfaceContext = useSuperinterfaceContext();
@@ -49213,7 +49125,7 @@ function _toPrimitive52(t, r) {
49213
49125
  return ("string" === r ? String : Number)(t);
49214
49126
  }
49215
49127
  var Form = function(props) {
49216
- var $ = _c98(17);
49128
+ var $ = _c97(17);
49217
49129
  var status = useStatus().status;
49218
49130
  var audioThreadContext = useAudioThreadContext();
49219
49131
  var t0 = status === "recording" ? "var(--accent-11)" : "var(--gray-11)";
@@ -49363,7 +49275,7 @@ function _toPrimitive53(t, r) {
49363
49275
  return ("string" === r ? String : Number)(t);
49364
49276
  }
49365
49277
  var AudioThread = function(props) {
49366
- var $ = _c99(5);
49278
+ var $ = _c98(5);
49367
49279
  var t0;
49368
49280
  var t1;
49369
49281
  var t2;
@@ -49445,7 +49357,7 @@ function _toPrimitive54(t, r) {
49445
49357
  return ("string" === r ? String : Number)(t);
49446
49358
  }
49447
49359
  var AudioThreadDialog = function(props) {
49448
- var $ = _c100(4);
49360
+ var $ = _c99(4);
49449
49361
  var t0;
49450
49362
  var t1;
49451
49363
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
@@ -49967,10 +49879,10 @@ var useWebrtcAudioRuntime = function() {
49967
49879
  ]);
49968
49880
  };
49969
49881
  // src/components/audioRuntimes/WebrtcAudioRuntimeProvider.tsx
49970
- import { c as _c101 } from "react-compiler-runtime";
49882
+ import { c as _c100 } from "react-compiler-runtime";
49971
49883
  import { jsx as _jsx98 } from "react/jsx-runtime";
49972
49884
  var WebrtcAudioRuntimeProvider = function(t0) {
49973
- var $ = _c101(5);
49885
+ var $ = _c100(5);
49974
49886
  var children = t0.children;
49975
49887
  var webrtcAudioRuntime = useWebrtcAudioRuntime().webrtcAudioRuntime;
49976
49888
  var t1;
@@ -49998,20 +49910,20 @@ var WebrtcAudioRuntimeProvider = function(t0) {
49998
49910
  return t2;
49999
49911
  };
50000
49912
  // src/components/gui/Gui/index.tsx
50001
- import { c as _c104 } from "react-compiler-runtime";
49913
+ import { c as _c103 } from "react-compiler-runtime";
50002
49914
  import { useMemo as useMemo23 } from "react";
50003
49915
  import { Flex as Flex35, Card as Card5, Spinner as Spinner3 } from "@radix-ui/themes";
50004
49916
  // src/hooks/messages/useLatestAssistantMessage/index.ts
50005
- import { c as _c102 } from "react-compiler-runtime";
49917
+ import { c as _c101 } from "react-compiler-runtime";
50006
49918
  import { useMemo as useMemo21 } from "react";
50007
49919
  var useLatestAssistantMessage = function() {
50008
- var $ = _c102(4);
49920
+ var $ = _c101(4);
50009
49921
  var _useMessages = useMessages(), messages2 = _useMessages.messages;
50010
49922
  var t0;
50011
49923
  var t1;
50012
49924
  if ($[0] !== messages2) {
50013
49925
  var _messages$find;
50014
- 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;
50015
49927
  $[0] = messages2;
50016
49928
  $[1] = t1;
50017
49929
  } else {
@@ -50030,21 +49942,21 @@ var useLatestAssistantMessage = function() {
50030
49942
  t0 = t2;
50031
49943
  return t0;
50032
49944
  };
50033
- function _temp11(message) {
49945
+ function _temp10(message) {
50034
49946
  return message.role === "assistant";
50035
49947
  }
50036
49948
  // src/hooks/messages/useLatestAssistantMessageWithContent/index.ts
50037
- import { c as _c103 } from "react-compiler-runtime";
49949
+ import { c as _c102 } from "react-compiler-runtime";
50038
49950
  import { isEmpty as isEmpty3 } from "radash";
50039
49951
  import { useMemo as useMemo22 } from "react";
50040
49952
  var useLatestAssistantMessageWithContent = function() {
50041
- var $ = _c103(4);
49953
+ var $ = _c102(4);
50042
49954
  var _useMessages = useMessages(), messages2 = _useMessages.messages;
50043
49955
  var t0;
50044
49956
  var t1;
50045
49957
  if ($[0] !== messages2) {
50046
49958
  var _messages$find;
50047
- 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;
50048
49960
  $[0] = messages2;
50049
49961
  $[1] = t1;
50050
49962
  } else {
@@ -50063,16 +49975,16 @@ var useLatestAssistantMessageWithContent = function() {
50063
49975
  t0 = t2;
50064
49976
  return t0;
50065
49977
  };
50066
- function _temp12(content2) {
49978
+ function _temp11(content2) {
50067
49979
  return content2.type === "text" && !isEmpty3(content2.text.value);
50068
49980
  }
50069
- function _temp26(message) {
50070
- return message.role === "assistant" && message.content.some(_temp12);
49981
+ function _temp25(message) {
49982
+ return message.role === "assistant" && message.content.some(_temp11);
50071
49983
  }
50072
49984
  // src/components/gui/Gui/index.tsx
50073
49985
  import { jsx as _jsx99, jsxs as _jsxs37 } from "react/jsx-runtime";
50074
49986
  var StartingToolCalls3 = function() {
50075
- var $ = _c104(2);
49987
+ var $ = _c103(2);
50076
49988
  var _useComponents = useComponents(), t0 = _useComponents.components;
50077
49989
  var StartingToolCalls4 = t0.StartingToolCalls;
50078
49990
  var t1;
@@ -50086,7 +49998,7 @@ var StartingToolCalls3 = function() {
50086
49998
  return t1;
50087
49999
  };
50088
50000
  var Content10 = function(t0) {
50089
- var $ = _c104(5);
50001
+ var $ = _c103(5);
50090
50002
  var latestRunStep = t0.latestRunStep;
50091
50003
  var t1;
50092
50004
  bb0: {
@@ -50140,14 +50052,14 @@ var Content10 = function(t0) {
50140
50052
  return t2;
50141
50053
  };
50142
50054
  var Progress2 = function(t0) {
50143
- var $ = _c104(5);
50055
+ var $ = _c103(5);
50144
50056
  var latestAssistantMessage = t0.latestAssistantMessage;
50145
50057
  var isMutatingMessage = useIsMutatingMessage();
50146
50058
  var t1;
50147
50059
  var t2;
50148
50060
  if ($[0] !== latestAssistantMessage.runSteps) {
50149
50061
  var _latestAssistantMessa;
50150
- 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;
50151
50063
  $[0] = latestAssistantMessage.runSteps;
50152
50064
  $[1] = t2;
50153
50065
  } else {
@@ -50190,7 +50102,7 @@ var Progress2 = function(t0) {
50190
50102
  return t4;
50191
50103
  };
50192
50104
  var Gui = function() {
50193
- var $ = _c104(8);
50105
+ var $ = _c103(8);
50194
50106
  var latestAssistantMessage = useLatestAssistantMessage().latestAssistantMessage;
50195
50107
  var latestAssistantMessageWithContent = useLatestAssistantMessageWithContent().latestAssistantMessageWithContent;
50196
50108
  if (!latestAssistantMessage || !latestAssistantMessageWithContent) {
@@ -50252,11 +50164,11 @@ var Gui = function() {
50252
50164
  }
50253
50165
  return t2;
50254
50166
  };
50255
- function _temp13(rs) {
50167
+ function _temp12(rs) {
50256
50168
  return rs.status === "in_progress";
50257
50169
  }
50258
50170
  // src/components/markdown/MarkdownProvider/index.tsx
50259
- import { c as _c105 } from "react-compiler-runtime";
50171
+ import { c as _c104 } from "react-compiler-runtime";
50260
50172
  import { useMemo as useMemo24 } from "react";
50261
50173
  import { jsx as _jsx100 } from "react/jsx-runtime";
50262
50174
  var _excluded7 = [
@@ -50281,7 +50193,7 @@ function _objectWithoutPropertiesLoose7(r, e) {
50281
50193
  return t;
50282
50194
  }
50283
50195
  var MarkdownProvider = function(t0) {
50284
- var $ = _c105(9);
50196
+ var $ = _c104(9);
50285
50197
  var children;
50286
50198
  var rest;
50287
50199
  if ($[0] !== t0) {
@@ -50324,18 +50236,18 @@ var MarkdownProvider = function(t0) {
50324
50236
  return t3;
50325
50237
  };
50326
50238
  // src/components/annotations/SourceAnnotation/index.tsx
50327
- import { c as _c108 } from "react-compiler-runtime";
50328
- // src/components/annotations/SourceAnnotation/FileCitation/index.tsx
50329
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";
50330
50242
  import { useState as useState13 } from "react";
50331
50243
  import { QuoteIcon as QuoteIcon2 } from "@radix-ui/react-icons";
50332
50244
  import { Dialog, VisuallyHidden, IconButton as IconButton11 } from "@radix-ui/themes";
50333
50245
  // src/components/annotations/SourceAnnotation/FileCitation/Content.tsx
50334
- import { c as _c106 } from "react-compiler-runtime";
50246
+ import { c as _c105 } from "react-compiler-runtime";
50335
50247
  import { Flex as Flex36, Card as Card6, Inset as Inset3 } from "@radix-ui/themes";
50336
50248
  import { jsx as _jsx101 } from "react/jsx-runtime";
50337
50249
  var Content11 = function(t0) {
50338
- var $ = _c106(5);
50250
+ var $ = _c105(5);
50339
50251
  var fileId = t0.fileId;
50340
50252
  var superinterfaceContext = useSuperinterfaceContext();
50341
50253
  var nextSearchParams = new URLSearchParams(superinterfaceContext.variables);
@@ -50401,7 +50313,7 @@ var Content11 = function(t0) {
50401
50313
  // src/components/annotations/SourceAnnotation/FileCitation/index.tsx
50402
50314
  import { jsx as _jsx102, jsxs as _jsxs38, Fragment as _Fragment6 } from "react/jsx-runtime";
50403
50315
  var FileCitation = function(t0) {
50404
- var $ = _c107(18);
50316
+ var $ = _c106(18);
50405
50317
  var annotation = t0.annotation;
50406
50318
  var _useState13 = _sliced_to_array(useState13(null), 2), activeFileId = _useState13[0], setActiveFileId = _useState13[1];
50407
50319
  var t1;
@@ -50550,7 +50462,7 @@ function _objectWithoutPropertiesLoose8(r, e) {
50550
50462
  return t;
50551
50463
  }
50552
50464
  var SourceAnnotation = function(t0) {
50553
- var $ = _c108(10);
50465
+ var $ = _c107(10);
50554
50466
  var children;
50555
50467
  var rest;
50556
50468
  if ($[0] !== t0) {
@@ -50607,7 +50519,7 @@ var SourceAnnotation = function(t0) {
50607
50519
  return null;
50608
50520
  };
50609
50521
  // src/components/avatars/Avatar.tsx
50610
- import { c as _c111 } from "react-compiler-runtime";
50522
+ import { c as _c110 } from "react-compiler-runtime";
50611
50523
  // src/enums/index.ts
50612
50524
  var IconAvatarName = /* @__PURE__ */ function(IconAvatarName2) {
50613
50525
  IconAvatarName2["BACKPACK"] = "BACKPACK";
@@ -50632,7 +50544,7 @@ var AvatarType = /* @__PURE__ */ function(AvatarType2) {
50632
50544
  // src/components/avatars/Avatar.tsx
50633
50545
  import { Avatar as RadixAvatar } from "@radix-ui/themes";
50634
50546
  // src/components/imageAvatars/ImageAvatar/index.tsx
50635
- import { c as _c109 } from "react-compiler-runtime";
50547
+ import { c as _c108 } from "react-compiler-runtime";
50636
50548
  import { Avatar as Avatar4 } from "@radix-ui/themes";
50637
50549
  // src/components/imageAvatars/ImageAvatar/lib/optimizedSrc/path.ts
50638
50550
  var width = function(_ref) {
@@ -50686,7 +50598,7 @@ var optimizedSrc = function(_ref) {
50686
50598
  // src/components/imageAvatars/ImageAvatar/index.tsx
50687
50599
  import { jsx as _jsx104 } from "react/jsx-runtime";
50688
50600
  var ImageAvatar = function(t0) {
50689
- var $ = _c109(9);
50601
+ var $ = _c108(9);
50690
50602
  var imageAvatar = t0.imageAvatar, size = t0.size, className = t0.className, style = t0.style;
50691
50603
  var superinterfaceContext = useSuperinterfaceContext();
50692
50604
  var t1;
@@ -50723,7 +50635,7 @@ var ImageAvatar = function(t0) {
50723
50635
  return t2;
50724
50636
  };
50725
50637
  // src/components/iconAvatars/IconAvatar.tsx
50726
- import { c as _c110 } from "react-compiler-runtime";
50638
+ import { c as _c109 } from "react-compiler-runtime";
50727
50639
  import { useMemo as useMemo25 } from "react";
50728
50640
  import { Avatar as Avatar5 } from "@radix-ui/themes";
50729
50641
  // src/lib/iconAvatars/iconAvatarComponents.ts
@@ -50733,7 +50645,7 @@ var iconAvatarComponents = (_obj = {}, _define_property(_obj, IconAvatarName.BAC
50733
50645
  // src/components/iconAvatars/IconAvatar.tsx
50734
50646
  import { jsx as _jsx105 } from "react/jsx-runtime";
50735
50647
  var IconAvatar = function(t0) {
50736
- var $ = _c110(7);
50648
+ var $ = _c109(7);
50737
50649
  var iconAvatar = t0.iconAvatar, size = t0.size, className = t0.className, style = t0.style;
50738
50650
  var t1;
50739
50651
  t1 = iconAvatarComponents[iconAvatar.name];
@@ -50767,7 +50679,7 @@ var IconAvatar = function(t0) {
50767
50679
  // src/components/avatars/Avatar.tsx
50768
50680
  import { jsx as _jsx106 } from "react/jsx-runtime";
50769
50681
  var Avatar6 = function(t0) {
50770
- var $ = _c111(14);
50682
+ var $ = _c110(14);
50771
50683
  var avatar = t0.avatar, t1 = t0.size, className = t0.className, style = t0.style;
50772
50684
  var size = t1 === void 0 ? "1" : t1;
50773
50685
  if (avatar) {
@@ -50828,7 +50740,7 @@ var Avatar6 = function(t0) {
50828
50740
  return t2;
50829
50741
  };
50830
50742
  // src/components/components/ComponentsProvider.tsx
50831
- import { c as _c112 } from "react-compiler-runtime";
50743
+ import { c as _c111 } from "react-compiler-runtime";
50832
50744
  import { useMemo as useMemo26 } from "react";
50833
50745
  import { jsx as _jsx107 } from "react/jsx-runtime";
50834
50746
  var _excluded9 = [
@@ -50853,7 +50765,7 @@ function _objectWithoutPropertiesLoose9(r, e) {
50853
50765
  return t;
50854
50766
  }
50855
50767
  var ComponentsProvider = function(t0) {
50856
- var $ = _c112(9);
50768
+ var $ = _c111(9);
50857
50769
  var children;
50858
50770
  var rest;
50859
50771
  if ($[0] !== t0) {
@@ -50896,11 +50808,11 @@ var ComponentsProvider = function(t0) {
50896
50808
  return t3;
50897
50809
  };
50898
50810
  // src/components/assistants/AssistantProvider/index.tsx
50899
- import { c as _c113 } from "react-compiler-runtime";
50811
+ import { c as _c112 } from "react-compiler-runtime";
50900
50812
  import { jsx as _jsx108 } from "react/jsx-runtime";
50901
50813
  var AssistantProvider = function(t0) {
50902
50814
  var _assistant$name;
50903
- var $ = _c113(10);
50815
+ var $ = _c112(10);
50904
50816
  var children = t0.children;
50905
50817
  var superinterfaceContext = useSuperinterfaceContext();
50906
50818
  var t1;