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

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.cjs CHANGED
@@ -47017,11 +47017,11 @@ ThreadDialog.Root = Root13;
47017
47017
  ThreadDialog.Trigger = Trigger;
47018
47018
  ThreadDialog.Content = Content8;
47019
47019
  // src/components/threads/AudioThreadDialog/index.tsx
47020
- var import_react_compiler_runtime100 = require("react-compiler-runtime");
47021
- // src/components/threads/AudioThread/index.tsx
47022
47020
  var import_react_compiler_runtime99 = require("react-compiler-runtime");
47021
+ // src/components/threads/AudioThread/index.tsx
47022
+ var import_react_compiler_runtime98 = require("react-compiler-runtime");
47023
47023
  // src/components/threads/AudioThread/Root/index.tsx
47024
- var import_react_compiler_runtime91 = require("react-compiler-runtime");
47024
+ var import_react_compiler_runtime90 = require("react-compiler-runtime");
47025
47025
  var import_themes58 = require("@radix-ui/themes");
47026
47026
  // src/contexts/threads/AudioThreadContext/index.ts
47027
47027
  var import_react62 = require("react");
@@ -47034,9 +47034,9 @@ var useAudioThreadContext = function() {
47034
47034
  return (0, import_react63.useContext)(AudioThreadContext);
47035
47035
  };
47036
47036
  // src/components/audioRuntimes/TtsAudioRuntimeProvider.tsx
47037
- var import_react_compiler_runtime90 = require("react-compiler-runtime");
47038
- // src/hooks/audioRuntimes/useTtsAudioRuntime/index.ts
47039
47037
  var import_react_compiler_runtime89 = require("react-compiler-runtime");
47038
+ // src/hooks/audioRuntimes/useTtsAudioRuntime/index.ts
47039
+ var import_react_compiler_runtime88 = require("react-compiler-runtime");
47040
47040
  var import_react68 = require("react");
47041
47041
  // src/hooks/misc/usePermission/index.ts
47042
47042
  var import_react_compiler_runtime86 = require("react-compiler-runtime");
@@ -47368,9 +47368,7 @@ var useRecorder = function(_ref) {
47368
47368
  });
47369
47369
  };
47370
47370
  // src/hooks/audioThreads/useMessageAudio/index.ts
47371
- var import_react_compiler_runtime88 = require("react-compiler-runtime");
47372
47371
  var import_react67 = require("react");
47373
- var import_compromise = __toESM(require("compromise"), 1);
47374
47372
  var import_howler = require("howler");
47375
47373
  var import_react_use_audio_player2 = require("react-use-audio-player");
47376
47374
  // src/hooks/audioThreads/useMessageAudio/lib/input.ts
@@ -47438,93 +47436,179 @@ function _toPrimitive47(t, r) {
47438
47436
  }
47439
47437
  return ("string" === r ? String : Number)(t);
47440
47438
  }
47441
- var segment = function(input2) {
47442
- return (0, import_compromise.default)(input2).sentences().json().map(function(s) {
47443
- return s.text;
47444
- });
47439
+ var THROTTLE_MS = 80;
47440
+ var MAX_SEG_CACHE = 256;
47441
+ var KEEP_FINISHED_MESSAGES = 12;
47442
+ var hasLetters = function(s) {
47443
+ for(var i = 0; i < s.length; i++){
47444
+ var ch = s.charAt(i);
47445
+ if (ch.toLowerCase() !== ch.toUpperCase()) return true;
47446
+ }
47447
+ return false;
47445
47448
  };
47446
- var useMessageAudio = function(t0) {
47447
- var $ = (0, import_react_compiler_runtime88.c)(41);
47448
- var _onEnd = t0.onEnd, passedPlay = t0.play, t1 = t0.fullSentenceRegex;
47449
- var t2;
47450
- if ($[0] !== t1) {
47451
- t2 = t1 === void 0 ? /[\.?!]$/ : t1;
47452
- $[0] = t1;
47453
- $[1] = t2;
47454
- } else {
47455
- t2 = $[1];
47449
+ var splitSentencesFast = function(text) {
47450
+ var t = text.replace(/\s+/g, " ").trim();
47451
+ if (!t) return [];
47452
+ var parts = t.split(RegExp("(?<=[.!?])\\s+(?=[^\\s])", "g"));
47453
+ var filtered = [];
47454
+ for(var i = 0; i < parts.length; i++){
47455
+ var p = parts[i].trim();
47456
+ if (p && hasLetters(p)) filtered.push(p);
47457
+ }
47458
+ return filtered;
47459
+ };
47460
+ var getIncrementalSentences = function(prev, nextInput, now) {
47461
+ if (!prev) return {
47462
+ input: nextInput,
47463
+ sentences: splitSentencesFast(nextInput),
47464
+ touched: now
47465
+ };
47466
+ if (nextInput === prev.input) return {
47467
+ input: prev.input,
47468
+ sentences: prev.sentences,
47469
+ touched: now
47470
+ };
47471
+ if (nextInput.startsWith(prev.input)) {
47472
+ var prevSentences = prev.sentences;
47473
+ var prevLast = prevSentences[prevSentences.length - 1] || "";
47474
+ var baseLen = prev.input.length - prevLast.length;
47475
+ if (baseLen >= 0 && prev.input.slice(baseLen) === prevLast) {
47476
+ var tail = nextInput.slice(baseLen);
47477
+ var tailSegments = splitSentencesFast(tail);
47478
+ var merged = prevSentences.length > 0 ? prevSentences.slice(0, -1).concat(tailSegments) : tailSegments;
47479
+ return {
47480
+ input: nextInput,
47481
+ sentences: merged,
47482
+ touched: now
47483
+ };
47484
+ }
47456
47485
  }
47457
- var fullSentenceRegex = t2;
47458
- var _ref = _sliced_to_array((0, import_react67.useState)(false), 2), isAudioPlayed = _ref[0], setIsAudioPlayed = _ref[1];
47486
+ return {
47487
+ input: nextInput,
47488
+ sentences: splitSentencesFast(nextInput),
47489
+ touched: now
47490
+ };
47491
+ };
47492
+ var useMessageAudio = function(_ref) {
47493
+ var _onEnd = _ref.onEnd, passedPlay = _ref.play, _ref_fullSentenceRegex = _ref.fullSentenceRegex, fullSentenceRegex = _ref_fullSentenceRegex === void 0 ? /[\.?!]$/ : _ref_fullSentenceRegex;
47494
+ var _$_ref = _sliced_to_array((0, import_react67.useState)(false), 2), isAudioPlayed = _$_ref[0], setIsAudioPlayed = _$_ref[1];
47459
47495
  var audioPlayer = (0, import_react_use_audio_player2.useAudioPlayer)();
47460
47496
  var nextAudioPlayer = (0, import_react_use_audio_player2.useAudioPlayer)();
47461
47497
  var superinterfaceContext = useSuperinterfaceContext();
47462
- var _ref1 = _sliced_to_array((0, import_react67.useState)(false), 2), isPlaying = _ref1[0], setIsPlaying = _ref1[1];
47463
- var t3;
47464
- if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
47465
- t3 = [];
47466
- $[2] = t3;
47467
- } else {
47468
- t3 = $[2];
47469
- }
47470
- var _ref2 = _sliced_to_array((0, import_react67.useState)(t3), 2), audioQueue = _ref2[0], setAudioQueue = _ref2[1];
47471
- var t4;
47472
- if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
47473
- t4 = [];
47474
- $[3] = t4;
47475
- } else {
47476
- t4 = $[3];
47477
- }
47478
- var audioQueueRef = (0, import_react67.useRef)(t4);
47479
- var t5;
47480
- var t6;
47481
- if ($[4] !== audioQueue) {
47482
- t5 = function() {
47483
- audioQueueRef.current = audioQueue;
47484
- };
47485
- t6 = [
47486
- audioQueue
47487
- ];
47488
- $[4] = audioQueue;
47489
- $[5] = t5;
47490
- $[6] = t6;
47491
- } else {
47492
- t5 = $[5];
47493
- t6 = $[6];
47494
- }
47495
- (0, import_react67.useEffect)(t5, t6);
47498
+ var _$_ref1 = _sliced_to_array((0, import_react67.useState)(false), 2), isPlaying = _$_ref1[0], setIsPlaying = _$_ref1[1];
47499
+ var _$_ref2 = _sliced_to_array((0, import_react67.useState)([]), 2), audioQueue = _$_ref2[0], setAudioQueue = _$_ref2[1];
47500
+ var audioQueueRef = (0, import_react67.useRef)([]);
47501
+ (0, import_react67.useEffect)(function() {
47502
+ audioQueueRef.current = audioQueue;
47503
+ }, [
47504
+ audioQueue
47505
+ ]);
47496
47506
  var pickLockRef = (0, import_react67.useRef)(false);
47497
47507
  var currentSentenceRef = (0, import_react67.useRef)(null);
47498
47508
  var messagesProps = useMessages();
47499
- var t7;
47500
- var t8;
47501
- if ($[7] !== messagesProps.messages) {
47502
- t7 = function() {
47503
- var assistantsDesc = messagesProps.messages.filter(_temp9);
47504
- var assistantsAsc = _to_consumable_array(assistantsDesc).reverse();
47509
+ var segCacheRef = (0, import_react67.useRef)(/* @__PURE__ */ new Map());
47510
+ var mirrorTimerRef = (0, import_react67.useRef)(null);
47511
+ var pendingMirrorRef = (0, import_react67.useRef)(false);
47512
+ (0, import_react67.useEffect)(function() {
47513
+ if (mirrorTimerRef.current != null) {
47514
+ pendingMirrorRef.current = true;
47515
+ return;
47516
+ }
47517
+ var run = function() {
47518
+ var assistantsDesc = messagesProps.messages.filter(function(m) {
47519
+ return m.role === "assistant";
47520
+ });
47521
+ var assistantsAsc = assistantsDesc.slice().reverse();
47522
+ var nowTs = typeof performance !== "undefined" && performance.now ? performance.now() : Date.now();
47523
+ var segCache = segCacheRef.current;
47524
+ var touch = function(id, entry) {
47525
+ segCache.set(id, {
47526
+ input: entry.input,
47527
+ sentences: entry.sentences,
47528
+ touched: nowTs
47529
+ });
47530
+ };
47531
+ var evictLRU = function() {
47532
+ if (segCache.size <= MAX_SEG_CACHE) return;
47533
+ var entries = Array.from(segCache.entries());
47534
+ entries.sort(function(a, b) {
47535
+ return a[1].touched - b[1].touched;
47536
+ });
47537
+ var toRemove = segCache.size - MAX_SEG_CACHE;
47538
+ for(var i = 0; i < toRemove; i++)segCache.delete(entries[i][0]);
47539
+ };
47505
47540
  setAudioQueue(function(prev) {
47506
- var prevById = new Map(prev.map(_temp24));
47541
+ var prevById = new Map(prev.map(function(p) {
47542
+ return [
47543
+ p.id,
47544
+ p
47545
+ ];
47546
+ }));
47507
47547
  var next = [];
47508
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
47509
- try {
47510
- for(var _iterator = assistantsAsc[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
47511
- var m_0 = _step.value;
47512
- var _existing$nextIndex, _existing$stopped;
47513
- var inp = input({
47514
- message: m_0
47515
- });
47516
- if (inp == null) {
47517
- continue;
47518
- }
47519
- var sentences = segment(inp);
47520
- var existing = prevById.get(m_0.id);
47548
+ var changed = false;
47549
+ for(var i_0 = 0; i_0 < assistantsAsc.length; i_0++){
47550
+ var _existing$nextIndex, _existing$stopped;
47551
+ var m_0 = assistantsAsc[i_0];
47552
+ var inp = input({
47553
+ message: m_0
47554
+ });
47555
+ if (inp == null) continue;
47556
+ var prevSeg = segCache.get(m_0.id);
47557
+ var nextSeg = getIncrementalSentences(prevSeg, inp, nowTs);
47558
+ if (!prevSeg || nextSeg.input !== prevSeg.input || nextSeg.sentences !== prevSeg.sentences) {
47559
+ touch(m_0.id, nextSeg);
47560
+ } else {
47561
+ touch(m_0.id, prevSeg);
47562
+ }
47563
+ var existing = prevById.get(m_0.id);
47564
+ var sentences = nextSeg.sentences;
47565
+ 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);
47566
+ var stopped = (_existing$stopped = existing === null || existing === void 0 ? void 0 : existing.stopped) !== null && _existing$stopped !== void 0 ? _existing$stopped : false;
47567
+ var reuse = !!existing && existing.status === m_0.status && existing.sentences === sentences && existing.nextIndex === nextIndex && existing.stopped === stopped;
47568
+ if (reuse) {
47569
+ next.push(existing);
47570
+ } else {
47521
47571
  next.push({
47522
47572
  id: m_0.id,
47523
47573
  status: m_0.status,
47524
47574
  sentences: sentences,
47525
- nextIndex: Math.min((_existing$nextIndex = existing === null || existing === void 0 ? void 0 : existing.nextIndex) !== null && _existing$nextIndex !== void 0 ? _existing$nextIndex : 0, sentences.length),
47526
- stopped: (_existing$stopped = existing === null || existing === void 0 ? void 0 : existing.stopped) !== null && _existing$stopped !== void 0 ? _existing$stopped : false
47575
+ nextIndex: nextIndex,
47576
+ stopped: stopped
47527
47577
  });
47578
+ changed = true;
47579
+ }
47580
+ }
47581
+ var unfinished = [];
47582
+ var finished = [];
47583
+ for(var i_1 = 0; i_1 < next.length; i_1++){
47584
+ var m_1 = next[i_1];
47585
+ if (!m_1.stopped && (m_1.status === "in_progress" || m_1.nextIndex < m_1.sentences.length)) {
47586
+ unfinished.push(m_1);
47587
+ } else {
47588
+ finished.push(m_1);
47589
+ }
47590
+ }
47591
+ var prunedFinished = finished.length > KEEP_FINISHED_MESSAGES ? finished.slice(finished.length - KEEP_FINISHED_MESSAGES) : finished;
47592
+ var combined = unfinished.concat(prunedFinished);
47593
+ if (!changed) {
47594
+ if (combined.length !== prev.length) changed = true;
47595
+ else {
47596
+ for(var i_2 = 0; i_2 < combined.length; i_2++){
47597
+ if (combined[i_2] !== prev[i_2]) {
47598
+ changed = true;
47599
+ break;
47600
+ }
47601
+ }
47602
+ }
47603
+ }
47604
+ var idsInQueue = new Set(combined.map(function(m_2) {
47605
+ return m_2.id;
47606
+ }));
47607
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
47608
+ try {
47609
+ for(var _iterator = Array.from(segCache.keys())[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
47610
+ var id_0 = _step.value;
47611
+ if (!idsInQueue.has(id_0)) segCache.delete(id_0);
47528
47612
  }
47529
47613
  } catch (err) {
47530
47614
  _didIteratorError = true;
@@ -47540,325 +47624,207 @@ var useMessageAudio = function(t0) {
47540
47624
  }
47541
47625
  }
47542
47626
  }
47543
- return next;
47544
- });
47545
- };
47546
- t8 = [
47547
- messagesProps.messages
47548
- ];
47549
- $[7] = messagesProps.messages;
47550
- $[8] = t7;
47551
- $[9] = t8;
47552
- } else {
47553
- t7 = $[8];
47554
- t8 = $[9];
47555
- }
47556
- (0, import_react67.useEffect)(t7, t8);
47557
- var t9;
47558
- if ($[10] !== audioPlayer || $[11] !== fullSentenceRegex || $[12] !== isAudioPlayed || $[13] !== nextAudioPlayer || $[14] !== superinterfaceContext) {
47559
- t9 = function(t102) {
47560
- var input2 = t102.input, onPlay = t102.onPlay, onStop = t102.onStop, onEnd_0 = t102.onEnd;
47561
- var searchParams = new URLSearchParams(_objectSpread47({
47562
- input: input2
47563
- }, superinterfaceContext.variables));
47564
- audioPlayer.load("".concat(superinterfaceContext.baseUrl, "/audio-runtimes/tts?").concat(searchParams), {
47565
- format: "mp3",
47566
- autoplay: isAudioPlayed,
47567
- html5: isHtmlAudioSupported,
47568
- onplay: onPlay,
47569
- onstop: onStop,
47570
- onload: function() {
47571
- var current = currentSentenceRef.current;
47572
- if (!current) {
47573
- return;
47574
- }
47575
- var msg = audioQueueRef.current.find(function(m_1) {
47576
- return m_1.id === current.messageId;
47577
- });
47578
- if (!msg) {
47579
- return;
47580
- }
47581
- var nextSentence = msg.sentences[msg.nextIndex];
47582
- if (!nextSentence) {
47583
- return;
47584
- }
47585
- if (!fullSentenceRegex.test(nextSentence)) {
47586
- return;
47587
- }
47588
- var nextSearchParams = new URLSearchParams(_objectSpread47({
47589
- input: nextSentence
47590
- }, superinterfaceContext.variables));
47591
- nextAudioPlayer.load("".concat(superinterfaceContext.baseUrl, "/audio-runtimes/tts?").concat(nextSearchParams), {
47592
- format: "mp3",
47593
- autoplay: false,
47594
- html5: isHtmlAudioSupported
47595
- });
47596
- },
47597
- onend: onEnd_0
47627
+ evictLRU();
47628
+ return changed ? combined : prev;
47598
47629
  });
47599
- };
47600
- $[10] = audioPlayer;
47601
- $[11] = fullSentenceRegex;
47602
- $[12] = isAudioPlayed;
47603
- $[13] = nextAudioPlayer;
47604
- $[14] = superinterfaceContext;
47605
- $[15] = t9;
47606
- } else {
47607
- t9 = $[15];
47608
- }
47609
- var defaultPlay = t9;
47610
- var t10;
47611
- t10 = passedPlay || defaultPlay;
47612
- var play = t10;
47613
- var t11;
47614
- var t12;
47615
- if ($[16] !== audioPlayer.playing || $[17] !== audioQueue || $[18] !== fullSentenceRegex || $[19] !== isPlaying || $[20] !== _onEnd || $[21] !== play) {
47616
- t11 = function() {
47617
- if (isPlaying) {
47618
- return;
47619
- }
47620
- if (audioPlayer.playing) {
47621
- return;
47630
+ mirrorTimerRef.current = null;
47631
+ if (pendingMirrorRef.current) {
47632
+ pendingMirrorRef.current = false;
47633
+ mirrorTimerRef.current = window.setTimeout(run, THROTTLE_MS);
47622
47634
  }
47623
- if (pickLockRef.current) {
47624
- return;
47625
- }
47626
- var candidate;
47627
- candidate = null;
47628
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
47629
- try {
47630
- for(var _iterator = audioQueue[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
47631
- var msg_0 = _step.value;
47632
- if (msg_0.stopped) {
47633
- continue;
47634
- }
47635
- var sentence = msg_0.sentences[msg_0.nextIndex];
47636
- if (!sentence) {
47637
- continue;
47638
- }
47639
- var isFull = isOptimistic({
47640
- id: msg_0.id
47641
- }) || msg_0.status !== "in_progress" || fullSentenceRegex.test(sentence);
47642
- if (isFull) {
47643
- candidate = {
47644
- messageId: msg_0.id,
47645
- sentence: sentence,
47646
- index: msg_0.nextIndex,
47647
- ownerStatus: msg_0.status
47648
- };
47649
- break;
47650
- }
47651
- }
47652
- } catch (err) {
47653
- _didIteratorError = true;
47654
- _iteratorError = err;
47655
- } finally{
47656
- try {
47657
- if (!_iteratorNormalCompletion && _iterator.return != null) {
47658
- _iterator.return();
47659
- }
47660
- } finally{
47661
- if (_didIteratorError) {
47662
- throw _iteratorError;
47663
- }
47664
- }
47665
- }
47666
- if (!candidate) {
47667
- return;
47635
+ };
47636
+ mirrorTimerRef.current = window.setTimeout(run, THROTTLE_MS);
47637
+ return function() {
47638
+ if (mirrorTimerRef.current != null) {
47639
+ clearTimeout(mirrorTimerRef.current);
47640
+ mirrorTimerRef.current = null;
47668
47641
  }
47669
- pickLockRef.current = true;
47670
- setIsPlaying(true);
47671
- currentSentenceRef.current = {
47672
- messageId: candidate.messageId,
47673
- index: candidate.index
47674
- };
47675
- setAudioQueue(function(prev_0) {
47676
- return prev_0.map(function(m_2) {
47677
- return m_2.id === candidate.messageId ? _objectSpread47(_objectSpread47({}, m_2), {}, {
47678
- nextIndex: m_2.nextIndex + 1
47679
- }) : m_2;
47642
+ pendingMirrorRef.current = false;
47643
+ };
47644
+ }, [
47645
+ messagesProps.messages
47646
+ ]);
47647
+ var defaultPlay = (0, import_react67.useCallback)(function(_ref2) {
47648
+ var input2 = _ref2.input, onPlay = _ref2.onPlay, onStop = _ref2.onStop, onEnd_0 = _ref2.onEnd;
47649
+ var searchParams = new URLSearchParams(_objectSpread47({
47650
+ input: input2
47651
+ }, superinterfaceContext.variables));
47652
+ audioPlayer.load("".concat(superinterfaceContext.baseUrl, "/audio-runtimes/tts?").concat(searchParams), {
47653
+ format: "mp3",
47654
+ autoplay: isAudioPlayed,
47655
+ html5: isHtmlAudioSupported,
47656
+ onplay: onPlay,
47657
+ onstop: onStop,
47658
+ onload: function() {
47659
+ var current = currentSentenceRef.current;
47660
+ if (!current) return;
47661
+ var msg = audioQueueRef.current.find(function(m_3) {
47662
+ return m_3.id === current.messageId;
47663
+ });
47664
+ if (!msg) return;
47665
+ var nextSentence = msg.sentences[msg.nextIndex];
47666
+ if (!nextSentence) return;
47667
+ if (!fullSentenceRegex.test(nextSentence)) return;
47668
+ var nextSearchParams = new URLSearchParams(_objectSpread47({
47669
+ input: nextSentence
47670
+ }, superinterfaceContext.variables));
47671
+ nextAudioPlayer.load("".concat(superinterfaceContext.baseUrl, "/audio-runtimes/tts?").concat(nextSearchParams), {
47672
+ format: "mp3",
47673
+ autoplay: false,
47674
+ html5: isHtmlAudioSupported
47680
47675
  });
47676
+ },
47677
+ onend: onEnd_0
47678
+ });
47679
+ }, [
47680
+ superinterfaceContext,
47681
+ audioPlayer,
47682
+ nextAudioPlayer,
47683
+ isAudioPlayed,
47684
+ fullSentenceRegex
47685
+ ]);
47686
+ var play = (0, import_react67.useMemo)(function() {
47687
+ return passedPlay || defaultPlay;
47688
+ }, [
47689
+ passedPlay,
47690
+ defaultPlay
47691
+ ]);
47692
+ (0, import_react67.useEffect)(function() {
47693
+ if (isPlaying) return;
47694
+ if (audioPlayer.playing) return;
47695
+ if (pickLockRef.current) return;
47696
+ var candidate = null;
47697
+ for(var mIdx = 0; mIdx < audioQueue.length; mIdx++){
47698
+ var msg_0 = audioQueue[mIdx];
47699
+ if (msg_0.stopped) continue;
47700
+ var idx = msg_0.nextIndex;
47701
+ var sentence = msg_0.sentences[idx];
47702
+ if (!sentence) continue;
47703
+ var isFull = isOptimistic({
47704
+ id: msg_0.id
47705
+ }) || msg_0.status !== "in_progress" || fullSentenceRegex.test(sentence);
47706
+ if (isFull) {
47707
+ candidate = {
47708
+ messageId: msg_0.id,
47709
+ sentence: sentence,
47710
+ index: idx,
47711
+ ownerStatus: msg_0.status
47712
+ };
47713
+ break;
47714
+ }
47715
+ }
47716
+ if (!candidate) return;
47717
+ pickLockRef.current = true;
47718
+ setIsPlaying(true);
47719
+ currentSentenceRef.current = {
47720
+ messageId: candidate.messageId,
47721
+ index: candidate.index
47722
+ };
47723
+ setAudioQueue(function(prev_0) {
47724
+ return prev_0.map(function(m_4) {
47725
+ return m_4.id === candidate.messageId ? _objectSpread47(_objectSpread47({}, m_4), {}, {
47726
+ nextIndex: candidate.index + 1
47727
+ }) : m_4;
47681
47728
  });
47682
- play({
47683
- input: candidate.sentence,
47684
- onPlay: function() {
47685
- setIsAudioPlayed(true);
47686
- },
47687
- onStop: function() {
47688
- setAudioQueue(function(prev_1) {
47689
- return prev_1.map(function(m_3) {
47690
- return m_3.id === candidate.messageId ? _objectSpread47(_objectSpread47({}, m_3), {}, {
47691
- stopped: true
47692
- }) : m_3;
47693
- });
47729
+ });
47730
+ play({
47731
+ input: candidate.sentence,
47732
+ onPlay: function() {
47733
+ return setIsAudioPlayed(true);
47734
+ },
47735
+ onStop: function() {
47736
+ setAudioQueue(function(prev_1) {
47737
+ return prev_1.map(function(m_5) {
47738
+ return m_5.id === candidate.messageId ? _objectSpread47(_objectSpread47({}, m_5), {}, {
47739
+ stopped: true
47740
+ }) : m_5;
47694
47741
  });
47695
- setIsPlaying(false);
47696
- currentSentenceRef.current = null;
47697
- pickLockRef.current = false;
47698
- },
47699
- onEnd: function() {
47700
- setIsPlaying(false);
47701
- currentSentenceRef.current = null;
47702
- pickLockRef.current = false;
47703
- var hasPending = audioQueueRef.current.some(_temp32);
47704
- if (!hasPending) {
47705
- _onEnd();
47706
- }
47707
- }
47708
- });
47709
- };
47710
- t12 = [
47711
- isPlaying,
47712
- audioPlayer.playing,
47713
- audioQueue,
47714
- play,
47715
- fullSentenceRegex,
47716
- _onEnd
47717
- ];
47718
- $[16] = audioPlayer.playing;
47719
- $[17] = audioQueue;
47720
- $[18] = fullSentenceRegex;
47721
- $[19] = isPlaying;
47722
- $[20] = _onEnd;
47723
- $[21] = play;
47724
- $[22] = t11;
47725
- $[23] = t12;
47726
- } else {
47727
- t11 = $[22];
47728
- t12 = $[23];
47729
- }
47730
- (0, import_react67.useEffect)(t11, t12);
47731
- var t13;
47732
- if ($[24] !== audioPlayer) {
47733
- t13 = [
47734
- audioPlayer
47735
- ];
47736
- $[24] = audioPlayer;
47737
- $[25] = t13;
47738
- } else {
47739
- t13 = $[25];
47740
- }
47741
- (0, import_react67.useEffect)(_temp42, t13);
47742
- var _ref3 = _sliced_to_array((0, import_react67.useState)(null), 2), audioEngine = _ref3[0], setAudioEngine = _ref3[1];
47743
- var isAudioEngineInited = (0, import_react67.useRef)(false);
47744
- var t14;
47745
- if ($[26] !== audioPlayer.playing) {
47746
- t14 = function() {
47747
- if (!audioPlayer.playing) {
47748
- return;
47749
- }
47750
- if (isAudioEngineInited.current) {
47751
- return;
47742
+ });
47743
+ setIsPlaying(false);
47744
+ currentSentenceRef.current = null;
47745
+ pickLockRef.current = false;
47746
+ },
47747
+ onEnd: function() {
47748
+ setIsPlaying(false);
47749
+ currentSentenceRef.current = null;
47750
+ pickLockRef.current = false;
47751
+ var hasPending = audioQueueRef.current.some(function(m_6) {
47752
+ if (m_6.stopped) return false;
47753
+ var hasMore = m_6.nextIndex < m_6.sentences.length;
47754
+ var streaming = m_6.status === "in_progress";
47755
+ return hasMore || streaming;
47756
+ });
47757
+ if (!hasPending) _onEnd();
47752
47758
  }
47753
- isAudioEngineInited.current = true;
47754
- if (isHtmlAudioSupported) {
47755
- var audioContext = new AudioContext();
47759
+ });
47760
+ }, [
47761
+ isPlaying,
47762
+ audioPlayer.playing,
47763
+ audioQueue,
47764
+ play,
47765
+ fullSentenceRegex,
47766
+ _onEnd
47767
+ ]);
47768
+ (0, import_react67.useEffect)(function() {
47769
+ if (isHtmlAudioSupported) {
47770
+ var _Howler$_howls;
47771
+ var node = import_howler.Howler === null || import_howler.Howler === void 0 || (_Howler$_howls = import_howler.Howler._howls) === null || _Howler$_howls === void 0 || (_Howler$_howls = _Howler$_howls[0]) === null || _Howler$_howls === void 0 || (_Howler$_howls = _Howler$_howls._sounds) === null || _Howler$_howls === void 0 || (_Howler$_howls = _Howler$_howls[0]) === null || _Howler$_howls === void 0 ? void 0 : _Howler$_howls._node;
47772
+ if (node) node.crossOrigin = "anonymous";
47773
+ }
47774
+ }, [
47775
+ audioPlayer
47776
+ ]);
47777
+ var _$_ref3 = _sliced_to_array((0, import_react67.useState)(null), 2), audioEngine = _$_ref3[0], setAudioEngine = _$_ref3[1];
47778
+ var isAudioEngineInited = (0, import_react67.useRef)(false);
47779
+ (0, import_react67.useEffect)(function() {
47780
+ if (!audioPlayer.playing) return;
47781
+ if (isAudioEngineInited.current) return;
47782
+ isAudioEngineInited.current = true;
47783
+ if (isHtmlAudioSupported) {
47784
+ var _Howler$_howls2;
47785
+ var AudioCtx = window.AudioContext || window.webkitAudioContext;
47786
+ var audioContext = new AudioCtx();
47787
+ var node_0 = import_howler.Howler === null || import_howler.Howler === void 0 || (_Howler$_howls2 = import_howler.Howler._howls) === null || _Howler$_howls2 === void 0 || (_Howler$_howls2 = _Howler$_howls2[0]) === null || _Howler$_howls2 === void 0 || (_Howler$_howls2 = _Howler$_howls2._sounds) === null || _Howler$_howls2 === void 0 || (_Howler$_howls2 = _Howler$_howls2[0]) === null || _Howler$_howls2 === void 0 ? void 0 : _Howler$_howls2._node;
47788
+ if (node_0) {
47756
47789
  setAudioEngine({
47757
- source: audioContext.createMediaElementSource(import_howler.Howler._howls[0]._sounds[0]._node),
47790
+ // @ts-ignore-next-line
47791
+ source: audioContext.createMediaElementSource(node_0),
47758
47792
  audioContext: audioContext
47759
47793
  });
47760
- } else {
47761
- setAudioEngine({
47762
- source: import_howler.Howler.masterGain,
47763
- audioContext: import_howler.Howler.ctx
47764
- });
47765
47794
  }
47766
- };
47767
- $[26] = audioPlayer.playing;
47768
- $[27] = t14;
47769
- } else {
47770
- t14 = $[27];
47771
- }
47772
- var t15;
47773
- if ($[28] !== audioPlayer) {
47774
- t15 = [
47775
- audioPlayer
47776
- ];
47777
- $[28] = audioPlayer;
47778
- $[29] = t15;
47779
- } else {
47780
- t15 = $[29];
47781
- }
47782
- (0, import_react67.useEffect)(t14, t15);
47783
- var t16;
47784
- bb0: {
47785
- if (!audioEngine) {
47786
- t16 = null;
47787
- break bb0;
47788
- }
47789
- var analyser;
47790
- if ($[30] !== audioEngine.audioContext || $[31] !== audioEngine.source) {
47791
- analyser = audioEngine.audioContext.createAnalyser();
47792
- audioEngine.source.connect(audioEngine.audioContext.destination);
47793
- audioEngine.source.connect(analyser);
47794
- $[30] = audioEngine.audioContext;
47795
- $[31] = audioEngine.source;
47796
- $[32] = analyser;
47797
47795
  } else {
47798
- analyser = $[32];
47799
- }
47800
- t16 = analyser;
47801
- }
47802
- var visualizationAnalyser = t16;
47803
- var t17;
47804
- var t18;
47805
- if ($[33] !== audioQueue || $[34] !== isPlaying) {
47806
- t18 = isPlaying || audioQueue.some(_temp52);
47807
- $[33] = audioQueue;
47808
- $[34] = isPlaying;
47809
- $[35] = t18;
47810
- } else {
47811
- t18 = $[35];
47812
- }
47813
- t17 = t18;
47814
- var isPending = t17;
47815
- var t19;
47816
- if ($[36] !== audioPlayer || $[37] !== isAudioPlayed || $[38] !== isPending || $[39] !== visualizationAnalyser) {
47817
- t19 = _objectSpread47(_objectSpread47({
47818
- isPending: isPending,
47819
- isAudioPlayed: isAudioPlayed
47820
- }, audioPlayer), {}, {
47821
- visualizationAnalyser: visualizationAnalyser
47796
+ setAudioEngine({
47797
+ source: import_howler.Howler.masterGain,
47798
+ audioContext: import_howler.Howler.ctx
47799
+ });
47800
+ }
47801
+ }, [
47802
+ audioPlayer
47803
+ ]);
47804
+ var visualizationAnalyser = (0, import_react67.useMemo)(function() {
47805
+ if (!audioEngine) return null;
47806
+ var analyser = audioEngine.audioContext.createAnalyser();
47807
+ audioEngine.source.connect(audioEngine.audioContext.destination);
47808
+ audioEngine.source.connect(analyser);
47809
+ return analyser;
47810
+ }, [
47811
+ audioEngine
47812
+ ]);
47813
+ var isPending = (0, import_react67.useMemo)(function() {
47814
+ return isPlaying || audioQueue.some(function(m_7) {
47815
+ return !m_7.stopped && (m_7.nextIndex < m_7.sentences.length || m_7.status === "in_progress");
47822
47816
  });
47823
- $[36] = audioPlayer;
47824
- $[37] = isAudioPlayed;
47825
- $[38] = isPending;
47826
- $[39] = visualizationAnalyser;
47827
- $[40] = t19;
47828
- } else {
47829
- t19 = $[40];
47830
- }
47831
- return t19;
47817
+ }, [
47818
+ isPlaying,
47819
+ audioQueue
47820
+ ]);
47821
+ return _objectSpread47(_objectSpread47({
47822
+ isPending: isPending,
47823
+ isAudioPlayed: isAudioPlayed
47824
+ }, audioPlayer), {}, {
47825
+ visualizationAnalyser: visualizationAnalyser
47826
+ });
47832
47827
  };
47833
- function _temp9(m) {
47834
- return m.role === "assistant";
47835
- }
47836
- function _temp24(p) {
47837
- return [
47838
- p.id,
47839
- p
47840
- ];
47841
- }
47842
- function _temp32(m_4) {
47843
- if (m_4.stopped) {
47844
- return false;
47845
- }
47846
- var hasMore = m_4.nextIndex < m_4.sentences.length;
47847
- var streaming = m_4.status === "in_progress";
47848
- return hasMore || streaming;
47849
- }
47850
- function _temp42() {
47851
- if (isHtmlAudioSupported) {
47852
- var _Howler$_howls$;
47853
- if (!(import_howler.Howler !== null && import_howler.Howler !== void 0 && (_Howler$_howls$ = import_howler.Howler._howls[0]) !== null && _Howler$_howls$ !== void 0 && (_Howler$_howls$ = _Howler$_howls$._sounds[0]) !== null && _Howler$_howls$ !== void 0 && _Howler$_howls$._node)) {
47854
- return;
47855
- }
47856
- import_howler.Howler._howls[0]._sounds[0]._node.crossOrigin = "anonymous";
47857
- }
47858
- }
47859
- function _temp52(m_5) {
47860
- return !m_5.stopped && (m_5.nextIndex < m_5.sentences.length || m_5.status === "in_progress");
47861
- }
47862
47828
  // src/hooks/audioRuntimes/useTtsAudioRuntime/index.ts
47863
47829
  var import_react_query10 = require("@tanstack/react-query");
47864
47830
  // src/hooks/audioRuntimes/useTtsAudioRuntime/blobToData.ts
@@ -47896,7 +47862,7 @@ function _asyncToGenerator11(n) {
47896
47862
  };
47897
47863
  }
47898
47864
  var useTtsAudioRuntime = function(t0) {
47899
- var $ = (0, import_react_compiler_runtime89.c)(30);
47865
+ var $ = (0, import_react_compiler_runtime88.c)(30);
47900
47866
  var play = t0.play, passedOnEnd = t0.onEnd;
47901
47867
  var addToast = useToasts().addToast;
47902
47868
  var queryClient = (0, import_react_query10.useQueryClient)();
@@ -47925,7 +47891,7 @@ var useTtsAudioRuntime = function(t0) {
47925
47891
  if ($[1] !== createMessageProps) {
47926
47892
  t2 = {
47927
47893
  isStopOnSilence: true,
47928
- onStart: _temp10,
47894
+ onStart: _temp9,
47929
47895
  onStop: function() {
47930
47896
  var _onStop = _asyncToGenerator11(function(_event, chunks) {
47931
47897
  var blob, audioContent;
@@ -48066,23 +48032,23 @@ var useTtsAudioRuntime = function(t0) {
48066
48032
  t5 = t8;
48067
48033
  return t5;
48068
48034
  };
48069
- function _temp10() {
48070
- return _temp25.apply(this, arguments);
48035
+ function _temp9() {
48036
+ return _temp24.apply(this, arguments);
48071
48037
  }
48072
- function _temp25() {
48073
- _temp25 = _asyncToGenerator11(function() {
48038
+ function _temp24() {
48039
+ _temp24 = _asyncToGenerator11(function() {
48074
48040
  return _ts_generator(this, function(_state) {
48075
48041
  return [
48076
48042
  2
48077
48043
  ];
48078
48044
  });
48079
48045
  });
48080
- return _temp25.apply(this, arguments);
48046
+ return _temp24.apply(this, arguments);
48081
48047
  }
48082
48048
  // src/components/audioRuntimes/TtsAudioRuntimeProvider.tsx
48083
48049
  var import_jsx_runtime87 = require("react/jsx-runtime");
48084
48050
  var TtsAudioRuntimeProvider = function(t0) {
48085
- var $ = (0, import_react_compiler_runtime90.c)(8);
48051
+ var $ = (0, import_react_compiler_runtime89.c)(8);
48086
48052
  var children = t0.children, play = t0.play, onEnd = t0.onEnd;
48087
48053
  var t1;
48088
48054
  if ($[0] !== onEnd || $[1] !== play) {
@@ -48195,7 +48161,7 @@ function _objectWithoutPropertiesLoose5(r, e) {
48195
48161
  return t;
48196
48162
  }
48197
48163
  var Content9 = function(t0) {
48198
- var $ = (0, import_react_compiler_runtime91.c)(4);
48164
+ var $ = (0, import_react_compiler_runtime90.c)(4);
48199
48165
  var children = t0.children, className = t0.className, style = t0.style;
48200
48166
  var t1;
48201
48167
  if ($[0] !== children || $[1] !== className || $[2] !== style) {
@@ -48217,7 +48183,7 @@ var Content9 = function(t0) {
48217
48183
  return t1;
48218
48184
  };
48219
48185
  var AudioRuntimeProvider = function(t0) {
48220
- var $ = (0, import_react_compiler_runtime91.c)(4);
48186
+ var $ = (0, import_react_compiler_runtime90.c)(4);
48221
48187
  var children = t0.children, play = t0.play, onEnd = t0.onEnd;
48222
48188
  var audioThreadContext = useAudioThreadContext();
48223
48189
  if (audioThreadContext.audioRuntime) {
@@ -48240,7 +48206,7 @@ var AudioRuntimeProvider = function(t0) {
48240
48206
  return t1;
48241
48207
  };
48242
48208
  var Provider5 = function(t0) {
48243
- var $ = (0, import_react_compiler_runtime91.c)(9);
48209
+ var $ = (0, import_react_compiler_runtime90.c)(9);
48244
48210
  var children;
48245
48211
  var rest;
48246
48212
  if ($[0] !== t0) {
@@ -48280,7 +48246,7 @@ var Provider5 = function(t0) {
48280
48246
  return t2;
48281
48247
  };
48282
48248
  var Root16 = function(t0) {
48283
- var $ = (0, import_react_compiler_runtime91.c)(18);
48249
+ var $ = (0, import_react_compiler_runtime90.c)(18);
48284
48250
  var children;
48285
48251
  var className;
48286
48252
  var onEnd;
@@ -48352,7 +48318,7 @@ var Root16 = function(t0) {
48352
48318
  return t3;
48353
48319
  };
48354
48320
  // src/components/threads/AudioThread/Visualization/index.tsx
48355
- var import_react_compiler_runtime93 = require("react-compiler-runtime");
48321
+ var import_react_compiler_runtime92 = require("react-compiler-runtime");
48356
48322
  var import_react71 = require("react");
48357
48323
  var import_lodash9 = __toESM(require("lodash"), 1);
48358
48324
  var import_themes60 = require("@radix-ui/themes");
@@ -48421,10 +48387,10 @@ var BarsVisualizer = function(_ref) {
48421
48387
  });
48422
48388
  };
48423
48389
  // src/hooks/audioThreads/useStatus/index.ts
48424
- var import_react_compiler_runtime92 = require("react-compiler-runtime");
48390
+ var import_react_compiler_runtime91 = require("react-compiler-runtime");
48425
48391
  var import_react70 = require("react");
48426
48392
  var useStatus = function() {
48427
- var $ = (0, import_react_compiler_runtime92.c)(2);
48393
+ var $ = (0, import_react_compiler_runtime91.c)(2);
48428
48394
  var audioRuntime = useAudioThreadContext().audioRuntime;
48429
48395
  var t0;
48430
48396
  bb0: {
@@ -48584,7 +48550,7 @@ var Provider6 = function(_ref) {
48584
48550
  });
48585
48551
  };
48586
48552
  var Root17 = function(t0) {
48587
- var $ = (0, import_react_compiler_runtime93.c)(6);
48553
+ var $ = (0, import_react_compiler_runtime92.c)(6);
48588
48554
  var children;
48589
48555
  var rest;
48590
48556
  if ($[0] !== t0) {
@@ -48621,7 +48587,7 @@ var Root17 = function(t0) {
48621
48587
  return t1;
48622
48588
  };
48623
48589
  var BarsVisualizer2 = function(t0) {
48624
- var $ = (0, import_react_compiler_runtime93.c)(10);
48590
+ var $ = (0, import_react_compiler_runtime92.c)(10);
48625
48591
  var rest;
48626
48592
  var t1;
48627
48593
  var t2;
@@ -48665,7 +48631,7 @@ var BarsVisualizer2 = function(t0) {
48665
48631
  return t4;
48666
48632
  };
48667
48633
  var AssistantVisualizationRoot = function(t0) {
48668
- var $ = (0, import_react_compiler_runtime93.c)(17);
48634
+ var $ = (0, import_react_compiler_runtime92.c)(17);
48669
48635
  var children;
48670
48636
  var rest;
48671
48637
  var t1;
@@ -48738,7 +48704,7 @@ var AssistantVisualizationRoot = function(t0) {
48738
48704
  return t6;
48739
48705
  };
48740
48706
  var AssistantVisualization = function(props) {
48741
- var $ = (0, import_react_compiler_runtime93.c)(3);
48707
+ var $ = (0, import_react_compiler_runtime92.c)(3);
48742
48708
  var t0;
48743
48709
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
48744
48710
  t0 = /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(BarsVisualizer2, {});
@@ -48761,7 +48727,7 @@ var AssistantVisualization = function(props) {
48761
48727
  AssistantVisualization.Root = AssistantVisualizationRoot;
48762
48728
  AssistantVisualization.BarsVisualizer = BarsVisualizer2;
48763
48729
  var AssistantInfo = function(props) {
48764
- var $ = (0, import_react_compiler_runtime93.c)(6);
48730
+ var $ = (0, import_react_compiler_runtime92.c)(6);
48765
48731
  var assistantNameContext = (0, import_react71.useContext)(AssistantNameContext);
48766
48732
  var t0;
48767
48733
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
@@ -48801,7 +48767,7 @@ var AssistantInfo = function(props) {
48801
48767
  return t2;
48802
48768
  };
48803
48769
  var Visualization = function(props) {
48804
- var $ = (0, import_react_compiler_runtime93.c)(4);
48770
+ var $ = (0, import_react_compiler_runtime92.c)(4);
48805
48771
  var t0;
48806
48772
  var t1;
48807
48773
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
@@ -48833,9 +48799,9 @@ Visualization.Provider = Provider6;
48833
48799
  Visualization.AssistantVisualization = AssistantVisualization;
48834
48800
  Visualization.AssistantInfo = AssistantInfo;
48835
48801
  // src/components/threads/AudioThread/Status/index.tsx
48836
- var import_react_compiler_runtime95 = require("react-compiler-runtime");
48837
- // src/components/threads/AudioThread/Status/StatusMessages.tsx
48838
48802
  var import_react_compiler_runtime94 = require("react-compiler-runtime");
48803
+ // src/components/threads/AudioThread/Status/StatusMessages.tsx
48804
+ var import_react_compiler_runtime93 = require("react-compiler-runtime");
48839
48805
  var import_themes61 = require("@radix-ui/themes");
48840
48806
  var import_jsx_runtime91 = require("react/jsx-runtime");
48841
48807
  var html = function(_ref) {
@@ -48845,7 +48811,7 @@ var html = function(_ref) {
48845
48811
  }).join(""), "\n }");
48846
48812
  };
48847
48813
  var StatusMessages = function(t0) {
48848
- var $ = (0, import_react_compiler_runtime94.c)(9);
48814
+ var $ = (0, import_react_compiler_runtime93.c)(9);
48849
48815
  var texts = t0.texts, className = t0.className, style = t0.style;
48850
48816
  var t1;
48851
48817
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
@@ -48949,7 +48915,7 @@ function _toPrimitive50(t, r) {
48949
48915
  return ("string" === r ? String : Number)(t);
48950
48916
  }
48951
48917
  var Status = function(props) {
48952
- var $ = (0, import_react_compiler_runtime95.c)(12);
48918
+ var $ = (0, import_react_compiler_runtime94.c)(12);
48953
48919
  var status = useStatus().status;
48954
48920
  if (status === "recording") {
48955
48921
  var _t;
@@ -49046,10 +49012,10 @@ var Status = function(props) {
49046
49012
  return t1;
49047
49013
  };
49048
49014
  // src/components/threads/AudioThread/Form/index.tsx
49049
- var import_react_compiler_runtime98 = require("react-compiler-runtime");
49015
+ var import_react_compiler_runtime97 = require("react-compiler-runtime");
49050
49016
  var import_themes63 = require("@radix-ui/themes");
49051
49017
  // src/components/threads/AudioThread/Form/MicIcon.tsx
49052
- var import_react_compiler_runtime96 = require("react-compiler-runtime");
49018
+ var import_react_compiler_runtime95 = require("react-compiler-runtime");
49053
49019
  var import_jsx_runtime93 = require("react/jsx-runtime");
49054
49020
  function ownKeys51(e, r) {
49055
49021
  var t = Object.keys(e);
@@ -49095,7 +49061,7 @@ function _toPrimitive51(t, r) {
49095
49061
  return ("string" === r ? String : Number)(t);
49096
49062
  }
49097
49063
  var MicIcon = function(props) {
49098
- var $ = (0, import_react_compiler_runtime96.c)(3);
49064
+ var $ = (0, import_react_compiler_runtime95.c)(3);
49099
49065
  var t0;
49100
49066
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
49101
49067
  t0 = /* @__PURE__ */ (0, import_jsx_runtime93.jsx)("path", {
@@ -49127,12 +49093,12 @@ var MicIcon = function(props) {
49127
49093
  return t1;
49128
49094
  };
49129
49095
  // src/components/threads/AudioThread/Form/ActionButton/index.tsx
49130
- var import_react_compiler_runtime97 = require("react-compiler-runtime");
49096
+ var import_react_compiler_runtime96 = require("react-compiler-runtime");
49131
49097
  var import_themes62 = require("@radix-ui/themes");
49132
49098
  var import_react_icons17 = require("@radix-ui/react-icons");
49133
49099
  var import_jsx_runtime94 = require("react/jsx-runtime");
49134
49100
  var ActionButton = function() {
49135
- var $ = (0, import_react_compiler_runtime97.c)(27);
49101
+ var $ = (0, import_react_compiler_runtime96.c)(27);
49136
49102
  var status = useStatus().status;
49137
49103
  var audioThreadContext = useAudioThreadContext();
49138
49104
  var superinterfaceContext = useSuperinterfaceContext();
@@ -49370,7 +49336,7 @@ function _toPrimitive52(t, r) {
49370
49336
  return ("string" === r ? String : Number)(t);
49371
49337
  }
49372
49338
  var Form = function(props) {
49373
- var $ = (0, import_react_compiler_runtime98.c)(17);
49339
+ var $ = (0, import_react_compiler_runtime97.c)(17);
49374
49340
  var status = useStatus().status;
49375
49341
  var audioThreadContext = useAudioThreadContext();
49376
49342
  var t0 = status === "recording" ? "var(--accent-11)" : "var(--gray-11)";
@@ -49520,7 +49486,7 @@ function _toPrimitive53(t, r) {
49520
49486
  return ("string" === r ? String : Number)(t);
49521
49487
  }
49522
49488
  var AudioThread = function(props) {
49523
- var $ = (0, import_react_compiler_runtime99.c)(5);
49489
+ var $ = (0, import_react_compiler_runtime98.c)(5);
49524
49490
  var t0;
49525
49491
  var t1;
49526
49492
  var t2;
@@ -49602,7 +49568,7 @@ function _toPrimitive54(t, r) {
49602
49568
  return ("string" === r ? String : Number)(t);
49603
49569
  }
49604
49570
  var AudioThreadDialog = function(props) {
49605
- var $ = (0, import_react_compiler_runtime100.c)(4);
49571
+ var $ = (0, import_react_compiler_runtime99.c)(4);
49606
49572
  var t0;
49607
49573
  var t1;
49608
49574
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
@@ -50124,10 +50090,10 @@ var useWebrtcAudioRuntime = function() {
50124
50090
  ]);
50125
50091
  };
50126
50092
  // src/components/audioRuntimes/WebrtcAudioRuntimeProvider.tsx
50127
- var import_react_compiler_runtime101 = require("react-compiler-runtime");
50093
+ var import_react_compiler_runtime100 = require("react-compiler-runtime");
50128
50094
  var import_jsx_runtime98 = require("react/jsx-runtime");
50129
50095
  var WebrtcAudioRuntimeProvider = function(t0) {
50130
- var $ = (0, import_react_compiler_runtime101.c)(5);
50096
+ var $ = (0, import_react_compiler_runtime100.c)(5);
50131
50097
  var children = t0.children;
50132
50098
  var webrtcAudioRuntime = useWebrtcAudioRuntime().webrtcAudioRuntime;
50133
50099
  var t1;
@@ -50155,20 +50121,20 @@ var WebrtcAudioRuntimeProvider = function(t0) {
50155
50121
  return t2;
50156
50122
  };
50157
50123
  // src/components/gui/Gui/index.tsx
50158
- var import_react_compiler_runtime104 = require("react-compiler-runtime");
50124
+ var import_react_compiler_runtime103 = require("react-compiler-runtime");
50159
50125
  var import_react75 = require("react");
50160
50126
  var import_themes64 = require("@radix-ui/themes");
50161
50127
  // src/hooks/messages/useLatestAssistantMessage/index.ts
50162
- var import_react_compiler_runtime102 = require("react-compiler-runtime");
50128
+ var import_react_compiler_runtime101 = require("react-compiler-runtime");
50163
50129
  var import_react73 = require("react");
50164
50130
  var useLatestAssistantMessage = function() {
50165
- var $ = (0, import_react_compiler_runtime102.c)(4);
50131
+ var $ = (0, import_react_compiler_runtime101.c)(4);
50166
50132
  var _useMessages = useMessages(), messages2 = _useMessages.messages;
50167
50133
  var t0;
50168
50134
  var t1;
50169
50135
  if ($[0] !== messages2) {
50170
50136
  var _messages$find;
50171
- t1 = (_messages$find = messages2.find(_temp11)) !== null && _messages$find !== void 0 ? _messages$find : null;
50137
+ t1 = (_messages$find = messages2.find(_temp10)) !== null && _messages$find !== void 0 ? _messages$find : null;
50172
50138
  $[0] = messages2;
50173
50139
  $[1] = t1;
50174
50140
  } else {
@@ -50187,21 +50153,21 @@ var useLatestAssistantMessage = function() {
50187
50153
  t0 = t2;
50188
50154
  return t0;
50189
50155
  };
50190
- function _temp11(message) {
50156
+ function _temp10(message) {
50191
50157
  return message.role === "assistant";
50192
50158
  }
50193
50159
  // src/hooks/messages/useLatestAssistantMessageWithContent/index.ts
50194
- var import_react_compiler_runtime103 = require("react-compiler-runtime");
50160
+ var import_react_compiler_runtime102 = require("react-compiler-runtime");
50195
50161
  var import_radash18 = require("radash");
50196
50162
  var import_react74 = require("react");
50197
50163
  var useLatestAssistantMessageWithContent = function() {
50198
- var $ = (0, import_react_compiler_runtime103.c)(4);
50164
+ var $ = (0, import_react_compiler_runtime102.c)(4);
50199
50165
  var _useMessages = useMessages(), messages2 = _useMessages.messages;
50200
50166
  var t0;
50201
50167
  var t1;
50202
50168
  if ($[0] !== messages2) {
50203
50169
  var _messages$find;
50204
- t1 = (_messages$find = messages2.find(_temp26)) !== null && _messages$find !== void 0 ? _messages$find : null;
50170
+ t1 = (_messages$find = messages2.find(_temp25)) !== null && _messages$find !== void 0 ? _messages$find : null;
50205
50171
  $[0] = messages2;
50206
50172
  $[1] = t1;
50207
50173
  } else {
@@ -50220,16 +50186,16 @@ var useLatestAssistantMessageWithContent = function() {
50220
50186
  t0 = t2;
50221
50187
  return t0;
50222
50188
  };
50223
- function _temp12(content2) {
50189
+ function _temp11(content2) {
50224
50190
  return content2.type === "text" && !(0, import_radash18.isEmpty)(content2.text.value);
50225
50191
  }
50226
- function _temp26(message) {
50227
- return message.role === "assistant" && message.content.some(_temp12);
50192
+ function _temp25(message) {
50193
+ return message.role === "assistant" && message.content.some(_temp11);
50228
50194
  }
50229
50195
  // src/components/gui/Gui/index.tsx
50230
50196
  var import_jsx_runtime99 = require("react/jsx-runtime");
50231
50197
  var StartingToolCalls3 = function() {
50232
- var $ = (0, import_react_compiler_runtime104.c)(2);
50198
+ var $ = (0, import_react_compiler_runtime103.c)(2);
50233
50199
  var _useComponents = useComponents(), t0 = _useComponents.components;
50234
50200
  var StartingToolCalls4 = t0.StartingToolCalls;
50235
50201
  var t1;
@@ -50243,7 +50209,7 @@ var StartingToolCalls3 = function() {
50243
50209
  return t1;
50244
50210
  };
50245
50211
  var Content10 = function(t0) {
50246
- var $ = (0, import_react_compiler_runtime104.c)(5);
50212
+ var $ = (0, import_react_compiler_runtime103.c)(5);
50247
50213
  var latestRunStep = t0.latestRunStep;
50248
50214
  var t1;
50249
50215
  bb0: {
@@ -50297,14 +50263,14 @@ var Content10 = function(t0) {
50297
50263
  return t2;
50298
50264
  };
50299
50265
  var Progress2 = function(t0) {
50300
- var $ = (0, import_react_compiler_runtime104.c)(5);
50266
+ var $ = (0, import_react_compiler_runtime103.c)(5);
50301
50267
  var latestAssistantMessage = t0.latestAssistantMessage;
50302
50268
  var isMutatingMessage = useIsMutatingMessage();
50303
50269
  var t1;
50304
50270
  var t2;
50305
50271
  if ($[0] !== latestAssistantMessage.runSteps) {
50306
50272
  var _latestAssistantMessa;
50307
- t2 = (_latestAssistantMessa = latestAssistantMessage.runSteps.find(_temp13)) !== null && _latestAssistantMessa !== void 0 ? _latestAssistantMessa : null;
50273
+ t2 = (_latestAssistantMessa = latestAssistantMessage.runSteps.find(_temp12)) !== null && _latestAssistantMessa !== void 0 ? _latestAssistantMessa : null;
50308
50274
  $[0] = latestAssistantMessage.runSteps;
50309
50275
  $[1] = t2;
50310
50276
  } else {
@@ -50347,7 +50313,7 @@ var Progress2 = function(t0) {
50347
50313
  return t4;
50348
50314
  };
50349
50315
  var Gui = function() {
50350
- var $ = (0, import_react_compiler_runtime104.c)(8);
50316
+ var $ = (0, import_react_compiler_runtime103.c)(8);
50351
50317
  var latestAssistantMessage = useLatestAssistantMessage().latestAssistantMessage;
50352
50318
  var latestAssistantMessageWithContent = useLatestAssistantMessageWithContent().latestAssistantMessageWithContent;
50353
50319
  if (!latestAssistantMessage || !latestAssistantMessageWithContent) {
@@ -50409,11 +50375,11 @@ var Gui = function() {
50409
50375
  }
50410
50376
  return t2;
50411
50377
  };
50412
- function _temp13(rs) {
50378
+ function _temp12(rs) {
50413
50379
  return rs.status === "in_progress";
50414
50380
  }
50415
50381
  // src/components/markdown/MarkdownProvider/index.tsx
50416
- var import_react_compiler_runtime105 = require("react-compiler-runtime");
50382
+ var import_react_compiler_runtime104 = require("react-compiler-runtime");
50417
50383
  var import_react76 = require("react");
50418
50384
  var import_jsx_runtime100 = require("react/jsx-runtime");
50419
50385
  var _excluded7 = [
@@ -50438,7 +50404,7 @@ function _objectWithoutPropertiesLoose7(r, e) {
50438
50404
  return t;
50439
50405
  }
50440
50406
  var MarkdownProvider = function(t0) {
50441
- var $ = (0, import_react_compiler_runtime105.c)(9);
50407
+ var $ = (0, import_react_compiler_runtime104.c)(9);
50442
50408
  var children;
50443
50409
  var rest;
50444
50410
  if ($[0] !== t0) {
@@ -50481,18 +50447,18 @@ var MarkdownProvider = function(t0) {
50481
50447
  return t3;
50482
50448
  };
50483
50449
  // src/components/annotations/SourceAnnotation/index.tsx
50484
- var import_react_compiler_runtime108 = require("react-compiler-runtime");
50485
- // src/components/annotations/SourceAnnotation/FileCitation/index.tsx
50486
50450
  var import_react_compiler_runtime107 = require("react-compiler-runtime");
50451
+ // src/components/annotations/SourceAnnotation/FileCitation/index.tsx
50452
+ var import_react_compiler_runtime106 = require("react-compiler-runtime");
50487
50453
  var import_react77 = require("react");
50488
50454
  var import_react_icons18 = require("@radix-ui/react-icons");
50489
50455
  var import_themes66 = require("@radix-ui/themes");
50490
50456
  // src/components/annotations/SourceAnnotation/FileCitation/Content.tsx
50491
- var import_react_compiler_runtime106 = require("react-compiler-runtime");
50457
+ var import_react_compiler_runtime105 = require("react-compiler-runtime");
50492
50458
  var import_themes65 = require("@radix-ui/themes");
50493
50459
  var import_jsx_runtime101 = require("react/jsx-runtime");
50494
50460
  var Content11 = function(t0) {
50495
- var $ = (0, import_react_compiler_runtime106.c)(5);
50461
+ var $ = (0, import_react_compiler_runtime105.c)(5);
50496
50462
  var fileId = t0.fileId;
50497
50463
  var superinterfaceContext = useSuperinterfaceContext();
50498
50464
  var nextSearchParams = new URLSearchParams(superinterfaceContext.variables);
@@ -50558,7 +50524,7 @@ var Content11 = function(t0) {
50558
50524
  // src/components/annotations/SourceAnnotation/FileCitation/index.tsx
50559
50525
  var import_jsx_runtime102 = require("react/jsx-runtime");
50560
50526
  var FileCitation = function(t0) {
50561
- var $ = (0, import_react_compiler_runtime107.c)(18);
50527
+ var $ = (0, import_react_compiler_runtime106.c)(18);
50562
50528
  var annotation = t0.annotation;
50563
50529
  var _ref = _sliced_to_array((0, import_react77.useState)(null), 2), activeFileId = _ref[0], setActiveFileId = _ref[1];
50564
50530
  var t1;
@@ -50707,7 +50673,7 @@ function _objectWithoutPropertiesLoose8(r, e) {
50707
50673
  return t;
50708
50674
  }
50709
50675
  var SourceAnnotation = function(t0) {
50710
- var $ = (0, import_react_compiler_runtime108.c)(10);
50676
+ var $ = (0, import_react_compiler_runtime107.c)(10);
50711
50677
  var children;
50712
50678
  var rest;
50713
50679
  if ($[0] !== t0) {
@@ -50764,7 +50730,7 @@ var SourceAnnotation = function(t0) {
50764
50730
  return null;
50765
50731
  };
50766
50732
  // src/components/avatars/Avatar.tsx
50767
- var import_react_compiler_runtime111 = require("react-compiler-runtime");
50733
+ var import_react_compiler_runtime110 = require("react-compiler-runtime");
50768
50734
  // src/enums/index.ts
50769
50735
  var IconAvatarName = /* @__PURE__ */ function(IconAvatarName2) {
50770
50736
  IconAvatarName2["BACKPACK"] = "BACKPACK";
@@ -50789,7 +50755,7 @@ var AvatarType = /* @__PURE__ */ function(AvatarType2) {
50789
50755
  // src/components/avatars/Avatar.tsx
50790
50756
  var import_themes69 = require("@radix-ui/themes");
50791
50757
  // src/components/imageAvatars/ImageAvatar/index.tsx
50792
- var import_react_compiler_runtime109 = require("react-compiler-runtime");
50758
+ var import_react_compiler_runtime108 = require("react-compiler-runtime");
50793
50759
  var import_themes67 = require("@radix-ui/themes");
50794
50760
  // src/components/imageAvatars/ImageAvatar/lib/optimizedSrc/path.ts
50795
50761
  var width = function(_ref) {
@@ -50843,7 +50809,7 @@ var optimizedSrc = function(_ref) {
50843
50809
  // src/components/imageAvatars/ImageAvatar/index.tsx
50844
50810
  var import_jsx_runtime104 = require("react/jsx-runtime");
50845
50811
  var ImageAvatar = function(t0) {
50846
- var $ = (0, import_react_compiler_runtime109.c)(9);
50812
+ var $ = (0, import_react_compiler_runtime108.c)(9);
50847
50813
  var imageAvatar = t0.imageAvatar, size = t0.size, className = t0.className, style = t0.style;
50848
50814
  var superinterfaceContext = useSuperinterfaceContext();
50849
50815
  var t1;
@@ -50880,7 +50846,7 @@ var ImageAvatar = function(t0) {
50880
50846
  return t2;
50881
50847
  };
50882
50848
  // src/components/iconAvatars/IconAvatar.tsx
50883
- var import_react_compiler_runtime110 = require("react-compiler-runtime");
50849
+ var import_react_compiler_runtime109 = require("react-compiler-runtime");
50884
50850
  var import_react78 = require("react");
50885
50851
  var import_themes68 = require("@radix-ui/themes");
50886
50852
  // src/lib/iconAvatars/iconAvatarComponents.ts
@@ -50890,7 +50856,7 @@ var iconAvatarComponents = (_obj = {}, _define_property(_obj, IconAvatarName.BAC
50890
50856
  // src/components/iconAvatars/IconAvatar.tsx
50891
50857
  var import_jsx_runtime105 = require("react/jsx-runtime");
50892
50858
  var IconAvatar = function(t0) {
50893
- var $ = (0, import_react_compiler_runtime110.c)(7);
50859
+ var $ = (0, import_react_compiler_runtime109.c)(7);
50894
50860
  var iconAvatar = t0.iconAvatar, size = t0.size, className = t0.className, style = t0.style;
50895
50861
  var t1;
50896
50862
  t1 = iconAvatarComponents[iconAvatar.name];
@@ -50924,7 +50890,7 @@ var IconAvatar = function(t0) {
50924
50890
  // src/components/avatars/Avatar.tsx
50925
50891
  var import_jsx_runtime106 = require("react/jsx-runtime");
50926
50892
  var Avatar6 = function(t0) {
50927
- var $ = (0, import_react_compiler_runtime111.c)(14);
50893
+ var $ = (0, import_react_compiler_runtime110.c)(14);
50928
50894
  var avatar = t0.avatar, t1 = t0.size, className = t0.className, style = t0.style;
50929
50895
  var size = t1 === void 0 ? "1" : t1;
50930
50896
  if (avatar) {
@@ -50985,7 +50951,7 @@ var Avatar6 = function(t0) {
50985
50951
  return t2;
50986
50952
  };
50987
50953
  // src/components/components/ComponentsProvider.tsx
50988
- var import_react_compiler_runtime112 = require("react-compiler-runtime");
50954
+ var import_react_compiler_runtime111 = require("react-compiler-runtime");
50989
50955
  var import_react79 = require("react");
50990
50956
  var import_jsx_runtime107 = require("react/jsx-runtime");
50991
50957
  var _excluded9 = [
@@ -51010,7 +50976,7 @@ function _objectWithoutPropertiesLoose9(r, e) {
51010
50976
  return t;
51011
50977
  }
51012
50978
  var ComponentsProvider = function(t0) {
51013
- var $ = (0, import_react_compiler_runtime112.c)(9);
50979
+ var $ = (0, import_react_compiler_runtime111.c)(9);
51014
50980
  var children;
51015
50981
  var rest;
51016
50982
  if ($[0] !== t0) {
@@ -51053,11 +51019,11 @@ var ComponentsProvider = function(t0) {
51053
51019
  return t3;
51054
51020
  };
51055
51021
  // src/components/assistants/AssistantProvider/index.tsx
51056
- var import_react_compiler_runtime113 = require("react-compiler-runtime");
51022
+ var import_react_compiler_runtime112 = require("react-compiler-runtime");
51057
51023
  var import_jsx_runtime108 = require("react/jsx-runtime");
51058
51024
  var AssistantProvider = function(t0) {
51059
51025
  var _assistant$name;
51060
- var $ = (0, import_react_compiler_runtime113.c)(10);
51026
+ var $ = (0, import_react_compiler_runtime112.c)(10);
51061
51027
  var children = t0.children;
51062
51028
  var superinterfaceContext = useSuperinterfaceContext();
51063
51029
  var t1;