@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.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,93 +47287,179 @@ 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 THROTTLE_MS = 80;
47291
+ var MAX_SEG_CACHE = 256;
47292
+ var KEEP_FINISHED_MESSAGES = 12;
47293
+ var hasLetters = function(s) {
47294
+ for(var i = 0; i < s.length; i++){
47295
+ var ch = s.charAt(i);
47296
+ if (ch.toLowerCase() !== ch.toUpperCase()) return true;
47297
+ }
47298
+ return false;
47296
47299
  };
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];
47300
+ var splitSentencesFast = function(text) {
47301
+ var t = text.replace(/\s+/g, " ").trim();
47302
+ if (!t) return [];
47303
+ var parts = t.split(RegExp("(?<=[.!?])\\s+(?=[^\\s])", "g"));
47304
+ var filtered = [];
47305
+ for(var i = 0; i < parts.length; i++){
47306
+ var p = parts[i].trim();
47307
+ if (p && hasLetters(p)) filtered.push(p);
47308
+ }
47309
+ return filtered;
47310
+ };
47311
+ var getIncrementalSentences = function(prev, nextInput, now) {
47312
+ if (!prev) return {
47313
+ input: nextInput,
47314
+ sentences: splitSentencesFast(nextInput),
47315
+ touched: now
47316
+ };
47317
+ if (nextInput === prev.input) return {
47318
+ input: prev.input,
47319
+ sentences: prev.sentences,
47320
+ touched: now
47321
+ };
47322
+ if (nextInput.startsWith(prev.input)) {
47323
+ var prevSentences = prev.sentences;
47324
+ var prevLast = prevSentences[prevSentences.length - 1] || "";
47325
+ var baseLen = prev.input.length - prevLast.length;
47326
+ if (baseLen >= 0 && prev.input.slice(baseLen) === prevLast) {
47327
+ var tail = nextInput.slice(baseLen);
47328
+ var tailSegments = splitSentencesFast(tail);
47329
+ var merged = prevSentences.length > 0 ? prevSentences.slice(0, -1).concat(tailSegments) : tailSegments;
47330
+ return {
47331
+ input: nextInput,
47332
+ sentences: merged,
47333
+ touched: now
47334
+ };
47335
+ }
47307
47336
  }
47308
- var fullSentenceRegex = t2;
47337
+ return {
47338
+ input: nextInput,
47339
+ sentences: splitSentencesFast(nextInput),
47340
+ touched: now
47341
+ };
47342
+ };
47343
+ var useMessageAudio = function(_ref) {
47344
+ var _onEnd = _ref.onEnd, passedPlay = _ref.play, _ref_fullSentenceRegex = _ref.fullSentenceRegex, fullSentenceRegex = _ref_fullSentenceRegex === void 0 ? /[\.?!]$/ : _ref_fullSentenceRegex;
47309
47345
  var _useState9 = _sliced_to_array(useState9(false), 2), isAudioPlayed = _useState9[0], setIsAudioPlayed = _useState9[1];
47310
47346
  var audioPlayer = useAudioPlayer2();
47311
47347
  var nextAudioPlayer = useAudioPlayer2();
47312
47348
  var superinterfaceContext = useSuperinterfaceContext();
47313
47349
  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);
47350
+ var _useState92 = _sliced_to_array(useState9([]), 2), audioQueue = _useState92[0], setAudioQueue = _useState92[1];
47351
+ var audioQueueRef = useRef8([]);
47352
+ useEffect10(function() {
47353
+ audioQueueRef.current = audioQueue;
47354
+ }, [
47355
+ audioQueue
47356
+ ]);
47347
47357
  var pickLockRef = useRef8(false);
47348
47358
  var currentSentenceRef = useRef8(null);
47349
47359
  var messagesProps = useMessages();
47350
- var t7;
47351
- var t8;
47352
- if ($[7] !== messagesProps.messages) {
47353
- t7 = function() {
47354
- var assistantsDesc = messagesProps.messages.filter(_temp9);
47355
- var assistantsAsc = _to_consumable_array(assistantsDesc).reverse();
47360
+ var segCacheRef = useRef8(/* @__PURE__ */ new Map());
47361
+ var mirrorTimerRef = useRef8(null);
47362
+ var pendingMirrorRef = useRef8(false);
47363
+ useEffect10(function() {
47364
+ if (mirrorTimerRef.current != null) {
47365
+ pendingMirrorRef.current = true;
47366
+ return;
47367
+ }
47368
+ var run = function() {
47369
+ var assistantsDesc = messagesProps.messages.filter(function(m) {
47370
+ return m.role === "assistant";
47371
+ });
47372
+ var assistantsAsc = assistantsDesc.slice().reverse();
47373
+ var nowTs = typeof performance !== "undefined" && performance.now ? performance.now() : Date.now();
47374
+ var segCache = segCacheRef.current;
47375
+ var touch = function(id, entry) {
47376
+ segCache.set(id, {
47377
+ input: entry.input,
47378
+ sentences: entry.sentences,
47379
+ touched: nowTs
47380
+ });
47381
+ };
47382
+ var evictLRU = function() {
47383
+ if (segCache.size <= MAX_SEG_CACHE) return;
47384
+ var entries = Array.from(segCache.entries());
47385
+ entries.sort(function(a, b) {
47386
+ return a[1].touched - b[1].touched;
47387
+ });
47388
+ var toRemove = segCache.size - MAX_SEG_CACHE;
47389
+ for(var i = 0; i < toRemove; i++)segCache.delete(entries[i][0]);
47390
+ };
47356
47391
  setAudioQueue(function(prev) {
47357
- var prevById = new Map(prev.map(_temp24));
47392
+ var prevById = new Map(prev.map(function(p) {
47393
+ return [
47394
+ p.id,
47395
+ p
47396
+ ];
47397
+ }));
47358
47398
  var next = [];
47359
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
47360
- try {
47361
- for(var _iterator = assistantsAsc[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
47362
- var m_0 = _step.value;
47363
- var _existing$nextIndex, _existing$stopped;
47364
- var inp = input({
47365
- message: m_0
47366
- });
47367
- if (inp == null) {
47368
- continue;
47369
- }
47370
- var sentences = segment(inp);
47371
- var existing = prevById.get(m_0.id);
47399
+ var changed = false;
47400
+ for(var i_0 = 0; i_0 < assistantsAsc.length; i_0++){
47401
+ var _existing$nextIndex, _existing$stopped;
47402
+ var m_0 = assistantsAsc[i_0];
47403
+ var inp = input({
47404
+ message: m_0
47405
+ });
47406
+ if (inp == null) continue;
47407
+ var prevSeg = segCache.get(m_0.id);
47408
+ var nextSeg = getIncrementalSentences(prevSeg, inp, nowTs);
47409
+ if (!prevSeg || nextSeg.input !== prevSeg.input || nextSeg.sentences !== prevSeg.sentences) {
47410
+ touch(m_0.id, nextSeg);
47411
+ } else {
47412
+ touch(m_0.id, prevSeg);
47413
+ }
47414
+ var existing = prevById.get(m_0.id);
47415
+ var sentences = nextSeg.sentences;
47416
+ 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);
47417
+ var stopped = (_existing$stopped = existing === null || existing === void 0 ? void 0 : existing.stopped) !== null && _existing$stopped !== void 0 ? _existing$stopped : false;
47418
+ var reuse = !!existing && existing.status === m_0.status && existing.sentences === sentences && existing.nextIndex === nextIndex && existing.stopped === stopped;
47419
+ if (reuse) {
47420
+ next.push(existing);
47421
+ } else {
47372
47422
  next.push({
47373
47423
  id: m_0.id,
47374
47424
  status: m_0.status,
47375
47425
  sentences: sentences,
47376
- nextIndex: Math.min((_existing$nextIndex = existing === null || existing === void 0 ? void 0 : existing.nextIndex) !== null && _existing$nextIndex !== void 0 ? _existing$nextIndex : 0, sentences.length),
47377
- stopped: (_existing$stopped = existing === null || existing === void 0 ? void 0 : existing.stopped) !== null && _existing$stopped !== void 0 ? _existing$stopped : false
47426
+ nextIndex: nextIndex,
47427
+ stopped: stopped
47378
47428
  });
47429
+ changed = true;
47430
+ }
47431
+ }
47432
+ var unfinished = [];
47433
+ var finished = [];
47434
+ for(var i_1 = 0; i_1 < next.length; i_1++){
47435
+ var m_1 = next[i_1];
47436
+ if (!m_1.stopped && (m_1.status === "in_progress" || m_1.nextIndex < m_1.sentences.length)) {
47437
+ unfinished.push(m_1);
47438
+ } else {
47439
+ finished.push(m_1);
47440
+ }
47441
+ }
47442
+ var prunedFinished = finished.length > KEEP_FINISHED_MESSAGES ? finished.slice(finished.length - KEEP_FINISHED_MESSAGES) : finished;
47443
+ var combined = unfinished.concat(prunedFinished);
47444
+ if (!changed) {
47445
+ if (combined.length !== prev.length) changed = true;
47446
+ else {
47447
+ for(var i_2 = 0; i_2 < combined.length; i_2++){
47448
+ if (combined[i_2] !== prev[i_2]) {
47449
+ changed = true;
47450
+ break;
47451
+ }
47452
+ }
47453
+ }
47454
+ }
47455
+ var idsInQueue = new Set(combined.map(function(m_2) {
47456
+ return m_2.id;
47457
+ }));
47458
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
47459
+ try {
47460
+ for(var _iterator = Array.from(segCache.keys())[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
47461
+ var id_0 = _step.value;
47462
+ if (!idsInQueue.has(id_0)) segCache.delete(id_0);
47379
47463
  }
47380
47464
  } catch (err) {
47381
47465
  _didIteratorError = true;
@@ -47391,325 +47475,207 @@ var useMessageAudio = function(t0) {
47391
47475
  }
47392
47476
  }
47393
47477
  }
47394
- return next;
47395
- });
47396
- };
47397
- t8 = [
47398
- messagesProps.messages
47399
- ];
47400
- $[7] = messagesProps.messages;
47401
- $[8] = t7;
47402
- $[9] = t8;
47403
- } else {
47404
- t7 = $[8];
47405
- t8 = $[9];
47406
- }
47407
- useEffect10(t7, t8);
47408
- var t9;
47409
- if ($[10] !== audioPlayer || $[11] !== fullSentenceRegex || $[12] !== isAudioPlayed || $[13] !== nextAudioPlayer || $[14] !== superinterfaceContext) {
47410
- t9 = function(t102) {
47411
- var input2 = t102.input, onPlay = t102.onPlay, onStop = t102.onStop, onEnd_0 = t102.onEnd;
47412
- var searchParams = new URLSearchParams(_objectSpread47({
47413
- input: input2
47414
- }, superinterfaceContext.variables));
47415
- audioPlayer.load("".concat(superinterfaceContext.baseUrl, "/audio-runtimes/tts?").concat(searchParams), {
47416
- format: "mp3",
47417
- autoplay: isAudioPlayed,
47418
- html5: isHtmlAudioSupported,
47419
- onplay: onPlay,
47420
- onstop: onStop,
47421
- onload: function() {
47422
- var current = currentSentenceRef.current;
47423
- if (!current) {
47424
- return;
47425
- }
47426
- var msg = audioQueueRef.current.find(function(m_1) {
47427
- return m_1.id === current.messageId;
47428
- });
47429
- if (!msg) {
47430
- return;
47431
- }
47432
- var nextSentence = msg.sentences[msg.nextIndex];
47433
- if (!nextSentence) {
47434
- return;
47435
- }
47436
- if (!fullSentenceRegex.test(nextSentence)) {
47437
- return;
47438
- }
47439
- var nextSearchParams = new URLSearchParams(_objectSpread47({
47440
- input: nextSentence
47441
- }, superinterfaceContext.variables));
47442
- nextAudioPlayer.load("".concat(superinterfaceContext.baseUrl, "/audio-runtimes/tts?").concat(nextSearchParams), {
47443
- format: "mp3",
47444
- autoplay: false,
47445
- html5: isHtmlAudioSupported
47446
- });
47447
- },
47448
- onend: onEnd_0
47478
+ evictLRU();
47479
+ return changed ? combined : prev;
47449
47480
  });
47450
- };
47451
- $[10] = audioPlayer;
47452
- $[11] = fullSentenceRegex;
47453
- $[12] = isAudioPlayed;
47454
- $[13] = nextAudioPlayer;
47455
- $[14] = superinterfaceContext;
47456
- $[15] = t9;
47457
- } else {
47458
- t9 = $[15];
47459
- }
47460
- var defaultPlay = t9;
47461
- var t10;
47462
- t10 = passedPlay || defaultPlay;
47463
- var play = t10;
47464
- var t11;
47465
- var t12;
47466
- if ($[16] !== audioPlayer.playing || $[17] !== audioQueue || $[18] !== fullSentenceRegex || $[19] !== isPlaying || $[20] !== _onEnd || $[21] !== play) {
47467
- t11 = function() {
47468
- if (isPlaying) {
47469
- return;
47470
- }
47471
- if (audioPlayer.playing) {
47472
- return;
47473
- }
47474
- if (pickLockRef.current) {
47475
- return;
47476
- }
47477
- var candidate;
47478
- candidate = null;
47479
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
47480
- try {
47481
- for(var _iterator = audioQueue[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
47482
- var msg_0 = _step.value;
47483
- if (msg_0.stopped) {
47484
- continue;
47485
- }
47486
- var sentence = msg_0.sentences[msg_0.nextIndex];
47487
- if (!sentence) {
47488
- continue;
47489
- }
47490
- var isFull = isOptimistic({
47491
- id: msg_0.id
47492
- }) || msg_0.status !== "in_progress" || fullSentenceRegex.test(sentence);
47493
- if (isFull) {
47494
- candidate = {
47495
- messageId: msg_0.id,
47496
- sentence: sentence,
47497
- index: msg_0.nextIndex,
47498
- ownerStatus: msg_0.status
47499
- };
47500
- break;
47501
- }
47502
- }
47503
- } catch (err) {
47504
- _didIteratorError = true;
47505
- _iteratorError = err;
47506
- } finally{
47507
- try {
47508
- if (!_iteratorNormalCompletion && _iterator.return != null) {
47509
- _iterator.return();
47510
- }
47511
- } finally{
47512
- if (_didIteratorError) {
47513
- throw _iteratorError;
47514
- }
47515
- }
47481
+ mirrorTimerRef.current = null;
47482
+ if (pendingMirrorRef.current) {
47483
+ pendingMirrorRef.current = false;
47484
+ mirrorTimerRef.current = window.setTimeout(run, THROTTLE_MS);
47516
47485
  }
47517
- if (!candidate) {
47518
- return;
47486
+ };
47487
+ mirrorTimerRef.current = window.setTimeout(run, THROTTLE_MS);
47488
+ return function() {
47489
+ if (mirrorTimerRef.current != null) {
47490
+ clearTimeout(mirrorTimerRef.current);
47491
+ mirrorTimerRef.current = null;
47519
47492
  }
47520
- pickLockRef.current = true;
47521
- setIsPlaying(true);
47522
- currentSentenceRef.current = {
47523
- messageId: candidate.messageId,
47524
- index: candidate.index
47525
- };
47526
- setAudioQueue(function(prev_0) {
47527
- return prev_0.map(function(m_2) {
47528
- return m_2.id === candidate.messageId ? _objectSpread47(_objectSpread47({}, m_2), {}, {
47529
- nextIndex: m_2.nextIndex + 1
47530
- }) : m_2;
47493
+ pendingMirrorRef.current = false;
47494
+ };
47495
+ }, [
47496
+ messagesProps.messages
47497
+ ]);
47498
+ var defaultPlay = useCallback7(function(_ref2) {
47499
+ var input2 = _ref2.input, onPlay = _ref2.onPlay, onStop = _ref2.onStop, onEnd_0 = _ref2.onEnd;
47500
+ var searchParams = new URLSearchParams(_objectSpread47({
47501
+ input: input2
47502
+ }, superinterfaceContext.variables));
47503
+ audioPlayer.load("".concat(superinterfaceContext.baseUrl, "/audio-runtimes/tts?").concat(searchParams), {
47504
+ format: "mp3",
47505
+ autoplay: isAudioPlayed,
47506
+ html5: isHtmlAudioSupported,
47507
+ onplay: onPlay,
47508
+ onstop: onStop,
47509
+ onload: function() {
47510
+ var current = currentSentenceRef.current;
47511
+ if (!current) return;
47512
+ var msg = audioQueueRef.current.find(function(m_3) {
47513
+ return m_3.id === current.messageId;
47531
47514
  });
47515
+ if (!msg) return;
47516
+ var nextSentence = msg.sentences[msg.nextIndex];
47517
+ if (!nextSentence) return;
47518
+ if (!fullSentenceRegex.test(nextSentence)) return;
47519
+ var nextSearchParams = new URLSearchParams(_objectSpread47({
47520
+ input: nextSentence
47521
+ }, superinterfaceContext.variables));
47522
+ nextAudioPlayer.load("".concat(superinterfaceContext.baseUrl, "/audio-runtimes/tts?").concat(nextSearchParams), {
47523
+ format: "mp3",
47524
+ autoplay: false,
47525
+ html5: isHtmlAudioSupported
47526
+ });
47527
+ },
47528
+ onend: onEnd_0
47529
+ });
47530
+ }, [
47531
+ superinterfaceContext,
47532
+ audioPlayer,
47533
+ nextAudioPlayer,
47534
+ isAudioPlayed,
47535
+ fullSentenceRegex
47536
+ ]);
47537
+ var play = useMemo17(function() {
47538
+ return passedPlay || defaultPlay;
47539
+ }, [
47540
+ passedPlay,
47541
+ defaultPlay
47542
+ ]);
47543
+ useEffect10(function() {
47544
+ if (isPlaying) return;
47545
+ if (audioPlayer.playing) return;
47546
+ if (pickLockRef.current) return;
47547
+ var candidate = null;
47548
+ for(var mIdx = 0; mIdx < audioQueue.length; mIdx++){
47549
+ var msg_0 = audioQueue[mIdx];
47550
+ if (msg_0.stopped) continue;
47551
+ var idx = msg_0.nextIndex;
47552
+ var sentence = msg_0.sentences[idx];
47553
+ if (!sentence) continue;
47554
+ var isFull = isOptimistic({
47555
+ id: msg_0.id
47556
+ }) || msg_0.status !== "in_progress" || fullSentenceRegex.test(sentence);
47557
+ if (isFull) {
47558
+ candidate = {
47559
+ messageId: msg_0.id,
47560
+ sentence: sentence,
47561
+ index: idx,
47562
+ ownerStatus: msg_0.status
47563
+ };
47564
+ break;
47565
+ }
47566
+ }
47567
+ if (!candidate) return;
47568
+ pickLockRef.current = true;
47569
+ setIsPlaying(true);
47570
+ currentSentenceRef.current = {
47571
+ messageId: candidate.messageId,
47572
+ index: candidate.index
47573
+ };
47574
+ setAudioQueue(function(prev_0) {
47575
+ return prev_0.map(function(m_4) {
47576
+ return m_4.id === candidate.messageId ? _objectSpread47(_objectSpread47({}, m_4), {}, {
47577
+ nextIndex: candidate.index + 1
47578
+ }) : m_4;
47532
47579
  });
47533
- play({
47534
- input: candidate.sentence,
47535
- onPlay: function() {
47536
- setIsAudioPlayed(true);
47537
- },
47538
- onStop: function() {
47539
- setAudioQueue(function(prev_1) {
47540
- return prev_1.map(function(m_3) {
47541
- return m_3.id === candidate.messageId ? _objectSpread47(_objectSpread47({}, m_3), {}, {
47542
- stopped: true
47543
- }) : m_3;
47544
- });
47580
+ });
47581
+ play({
47582
+ input: candidate.sentence,
47583
+ onPlay: function() {
47584
+ return setIsAudioPlayed(true);
47585
+ },
47586
+ onStop: function() {
47587
+ setAudioQueue(function(prev_1) {
47588
+ return prev_1.map(function(m_5) {
47589
+ return m_5.id === candidate.messageId ? _objectSpread47(_objectSpread47({}, m_5), {}, {
47590
+ stopped: true
47591
+ }) : m_5;
47545
47592
  });
47546
- setIsPlaying(false);
47547
- currentSentenceRef.current = null;
47548
- pickLockRef.current = false;
47549
- },
47550
- onEnd: function() {
47551
- setIsPlaying(false);
47552
- currentSentenceRef.current = null;
47553
- pickLockRef.current = false;
47554
- var hasPending = audioQueueRef.current.some(_temp32);
47555
- if (!hasPending) {
47556
- _onEnd();
47557
- }
47558
- }
47559
- });
47560
- };
47561
- t12 = [
47562
- isPlaying,
47563
- audioPlayer.playing,
47564
- audioQueue,
47565
- play,
47566
- fullSentenceRegex,
47567
- _onEnd
47568
- ];
47569
- $[16] = audioPlayer.playing;
47570
- $[17] = audioQueue;
47571
- $[18] = fullSentenceRegex;
47572
- $[19] = isPlaying;
47573
- $[20] = _onEnd;
47574
- $[21] = play;
47575
- $[22] = t11;
47576
- $[23] = t12;
47577
- } else {
47578
- t11 = $[22];
47579
- t12 = $[23];
47580
- }
47581
- useEffect10(t11, t12);
47582
- var t13;
47583
- if ($[24] !== audioPlayer) {
47584
- t13 = [
47585
- audioPlayer
47586
- ];
47587
- $[24] = audioPlayer;
47588
- $[25] = t13;
47589
- } else {
47590
- t13 = $[25];
47591
- }
47592
- useEffect10(_temp42, t13);
47593
+ });
47594
+ setIsPlaying(false);
47595
+ currentSentenceRef.current = null;
47596
+ pickLockRef.current = false;
47597
+ },
47598
+ onEnd: function() {
47599
+ setIsPlaying(false);
47600
+ currentSentenceRef.current = null;
47601
+ pickLockRef.current = false;
47602
+ var hasPending = audioQueueRef.current.some(function(m_6) {
47603
+ if (m_6.stopped) return false;
47604
+ var hasMore = m_6.nextIndex < m_6.sentences.length;
47605
+ var streaming = m_6.status === "in_progress";
47606
+ return hasMore || streaming;
47607
+ });
47608
+ if (!hasPending) _onEnd();
47609
+ }
47610
+ });
47611
+ }, [
47612
+ isPlaying,
47613
+ audioPlayer.playing,
47614
+ audioQueue,
47615
+ play,
47616
+ fullSentenceRegex,
47617
+ _onEnd
47618
+ ]);
47619
+ useEffect10(function() {
47620
+ if (isHtmlAudioSupported) {
47621
+ var _Howler$_howls;
47622
+ var node = Howler === null || Howler === void 0 || (_Howler$_howls = 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;
47623
+ if (node) node.crossOrigin = "anonymous";
47624
+ }
47625
+ }, [
47626
+ audioPlayer
47627
+ ]);
47593
47628
  var _useState93 = _sliced_to_array(useState9(null), 2), audioEngine = _useState93[0], setAudioEngine = _useState93[1];
47594
47629
  var isAudioEngineInited = useRef8(false);
47595
- var t14;
47596
- if ($[26] !== audioPlayer.playing) {
47597
- t14 = function() {
47598
- if (!audioPlayer.playing) {
47599
- return;
47600
- }
47601
- if (isAudioEngineInited.current) {
47602
- return;
47603
- }
47604
- isAudioEngineInited.current = true;
47605
- if (isHtmlAudioSupported) {
47606
- var audioContext = new AudioContext();
47630
+ useEffect10(function() {
47631
+ if (!audioPlayer.playing) return;
47632
+ if (isAudioEngineInited.current) return;
47633
+ isAudioEngineInited.current = true;
47634
+ if (isHtmlAudioSupported) {
47635
+ var _Howler$_howls2;
47636
+ var AudioCtx = window.AudioContext || window.webkitAudioContext;
47637
+ var audioContext = new AudioCtx();
47638
+ var node_0 = Howler === null || Howler === void 0 || (_Howler$_howls2 = 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;
47639
+ if (node_0) {
47607
47640
  setAudioEngine({
47608
- source: audioContext.createMediaElementSource(Howler._howls[0]._sounds[0]._node),
47641
+ // @ts-ignore-next-line
47642
+ source: audioContext.createMediaElementSource(node_0),
47609
47643
  audioContext: audioContext
47610
47644
  });
47611
- } else {
47612
- setAudioEngine({
47613
- source: Howler.masterGain,
47614
- audioContext: Howler.ctx
47615
- });
47616
47645
  }
47617
- };
47618
- $[26] = audioPlayer.playing;
47619
- $[27] = t14;
47620
- } else {
47621
- t14 = $[27];
47622
- }
47623
- var t15;
47624
- if ($[28] !== audioPlayer) {
47625
- t15 = [
47626
- audioPlayer
47627
- ];
47628
- $[28] = audioPlayer;
47629
- $[29] = t15;
47630
- } else {
47631
- t15 = $[29];
47632
- }
47633
- useEffect10(t14, t15);
47634
- var t16;
47635
- bb0: {
47636
- if (!audioEngine) {
47637
- t16 = null;
47638
- break bb0;
47639
- }
47640
- var analyser;
47641
- if ($[30] !== audioEngine.audioContext || $[31] !== audioEngine.source) {
47642
- analyser = audioEngine.audioContext.createAnalyser();
47643
- audioEngine.source.connect(audioEngine.audioContext.destination);
47644
- audioEngine.source.connect(analyser);
47645
- $[30] = audioEngine.audioContext;
47646
- $[31] = audioEngine.source;
47647
- $[32] = analyser;
47648
47646
  } else {
47649
- analyser = $[32];
47650
- }
47651
- t16 = analyser;
47652
- }
47653
- var visualizationAnalyser = t16;
47654
- var t17;
47655
- var t18;
47656
- if ($[33] !== audioQueue || $[34] !== isPlaying) {
47657
- t18 = isPlaying || audioQueue.some(_temp52);
47658
- $[33] = audioQueue;
47659
- $[34] = isPlaying;
47660
- $[35] = t18;
47661
- } else {
47662
- t18 = $[35];
47663
- }
47664
- t17 = t18;
47665
- var isPending = t17;
47666
- var t19;
47667
- if ($[36] !== audioPlayer || $[37] !== isAudioPlayed || $[38] !== isPending || $[39] !== visualizationAnalyser) {
47668
- t19 = _objectSpread47(_objectSpread47({
47669
- isPending: isPending,
47670
- isAudioPlayed: isAudioPlayed
47671
- }, audioPlayer), {}, {
47672
- visualizationAnalyser: visualizationAnalyser
47647
+ setAudioEngine({
47648
+ source: Howler.masterGain,
47649
+ audioContext: Howler.ctx
47650
+ });
47651
+ }
47652
+ }, [
47653
+ audioPlayer
47654
+ ]);
47655
+ var visualizationAnalyser = useMemo17(function() {
47656
+ if (!audioEngine) return null;
47657
+ var analyser = audioEngine.audioContext.createAnalyser();
47658
+ audioEngine.source.connect(audioEngine.audioContext.destination);
47659
+ audioEngine.source.connect(analyser);
47660
+ return analyser;
47661
+ }, [
47662
+ audioEngine
47663
+ ]);
47664
+ var isPending = useMemo17(function() {
47665
+ return isPlaying || audioQueue.some(function(m_7) {
47666
+ return !m_7.stopped && (m_7.nextIndex < m_7.sentences.length || m_7.status === "in_progress");
47673
47667
  });
47674
- $[36] = audioPlayer;
47675
- $[37] = isAudioPlayed;
47676
- $[38] = isPending;
47677
- $[39] = visualizationAnalyser;
47678
- $[40] = t19;
47679
- } else {
47680
- t19 = $[40];
47681
- }
47682
- return t19;
47668
+ }, [
47669
+ isPlaying,
47670
+ audioQueue
47671
+ ]);
47672
+ return _objectSpread47(_objectSpread47({
47673
+ isPending: isPending,
47674
+ isAudioPlayed: isAudioPlayed
47675
+ }, audioPlayer), {}, {
47676
+ visualizationAnalyser: visualizationAnalyser
47677
+ });
47683
47678
  };
47684
- function _temp9(m) {
47685
- return m.role === "assistant";
47686
- }
47687
- function _temp24(p) {
47688
- return [
47689
- p.id,
47690
- p
47691
- ];
47692
- }
47693
- function _temp32(m_4) {
47694
- if (m_4.stopped) {
47695
- return false;
47696
- }
47697
- var hasMore = m_4.nextIndex < m_4.sentences.length;
47698
- var streaming = m_4.status === "in_progress";
47699
- return hasMore || streaming;
47700
- }
47701
- function _temp42() {
47702
- if (isHtmlAudioSupported) {
47703
- var _Howler$_howls$;
47704
- if (!(Howler !== null && Howler !== void 0 && (_Howler$_howls$ = Howler._howls[0]) !== null && _Howler$_howls$ !== void 0 && (_Howler$_howls$ = _Howler$_howls$._sounds[0]) !== null && _Howler$_howls$ !== void 0 && _Howler$_howls$._node)) {
47705
- return;
47706
- }
47707
- Howler._howls[0]._sounds[0]._node.crossOrigin = "anonymous";
47708
- }
47709
- }
47710
- function _temp52(m_5) {
47711
- return !m_5.stopped && (m_5.nextIndex < m_5.sentences.length || m_5.status === "in_progress");
47712
- }
47713
47679
  // src/hooks/audioRuntimes/useTtsAudioRuntime/index.ts
47714
47680
  import { useQueryClient as useQueryClient6 } from "@tanstack/react-query";
47715
47681
  // src/hooks/audioRuntimes/useTtsAudioRuntime/blobToData.ts
@@ -47747,7 +47713,7 @@ function _asyncToGenerator11(n) {
47747
47713
  };
47748
47714
  }
47749
47715
  var useTtsAudioRuntime = function(t0) {
47750
- var $ = _c89(30);
47716
+ var $ = _c88(30);
47751
47717
  var play = t0.play, passedOnEnd = t0.onEnd;
47752
47718
  var addToast = useToasts().addToast;
47753
47719
  var queryClient = useQueryClient6();
@@ -47776,7 +47742,7 @@ var useTtsAudioRuntime = function(t0) {
47776
47742
  if ($[1] !== createMessageProps) {
47777
47743
  t2 = {
47778
47744
  isStopOnSilence: true,
47779
- onStart: _temp10,
47745
+ onStart: _temp9,
47780
47746
  onStop: function() {
47781
47747
  var _onStop = _asyncToGenerator11(function(_event, chunks) {
47782
47748
  var blob, audioContent;
@@ -47917,23 +47883,23 @@ var useTtsAudioRuntime = function(t0) {
47917
47883
  t5 = t8;
47918
47884
  return t5;
47919
47885
  };
47920
- function _temp10() {
47921
- return _temp25.apply(this, arguments);
47886
+ function _temp9() {
47887
+ return _temp24.apply(this, arguments);
47922
47888
  }
47923
- function _temp25() {
47924
- _temp25 = _asyncToGenerator11(function() {
47889
+ function _temp24() {
47890
+ _temp24 = _asyncToGenerator11(function() {
47925
47891
  return _ts_generator(this, function(_state) {
47926
47892
  return [
47927
47893
  2
47928
47894
  ];
47929
47895
  });
47930
47896
  });
47931
- return _temp25.apply(this, arguments);
47897
+ return _temp24.apply(this, arguments);
47932
47898
  }
47933
47899
  // src/components/audioRuntimes/TtsAudioRuntimeProvider.tsx
47934
47900
  import { jsx as _jsx87 } from "react/jsx-runtime";
47935
47901
  var TtsAudioRuntimeProvider = function(t0) {
47936
- var $ = _c90(8);
47902
+ var $ = _c89(8);
47937
47903
  var children = t0.children, play = t0.play, onEnd = t0.onEnd;
47938
47904
  var t1;
47939
47905
  if ($[0] !== onEnd || $[1] !== play) {
@@ -48046,7 +48012,7 @@ function _objectWithoutPropertiesLoose5(r, e) {
48046
48012
  return t;
48047
48013
  }
48048
48014
  var Content9 = function(t0) {
48049
- var $ = _c91(4);
48015
+ var $ = _c90(4);
48050
48016
  var children = t0.children, className = t0.className, style = t0.style;
48051
48017
  var t1;
48052
48018
  if ($[0] !== children || $[1] !== className || $[2] !== style) {
@@ -48068,7 +48034,7 @@ var Content9 = function(t0) {
48068
48034
  return t1;
48069
48035
  };
48070
48036
  var AudioRuntimeProvider = function(t0) {
48071
- var $ = _c91(4);
48037
+ var $ = _c90(4);
48072
48038
  var children = t0.children, play = t0.play, onEnd = t0.onEnd;
48073
48039
  var audioThreadContext = useAudioThreadContext();
48074
48040
  if (audioThreadContext.audioRuntime) {
@@ -48091,7 +48057,7 @@ var AudioRuntimeProvider = function(t0) {
48091
48057
  return t1;
48092
48058
  };
48093
48059
  var Provider5 = function(t0) {
48094
- var $ = _c91(9);
48060
+ var $ = _c90(9);
48095
48061
  var children;
48096
48062
  var rest;
48097
48063
  if ($[0] !== t0) {
@@ -48131,7 +48097,7 @@ var Provider5 = function(t0) {
48131
48097
  return t2;
48132
48098
  };
48133
48099
  var Root16 = function(t0) {
48134
- var $ = _c91(18);
48100
+ var $ = _c90(18);
48135
48101
  var children;
48136
48102
  var className;
48137
48103
  var onEnd;
@@ -48203,7 +48169,7 @@ var Root16 = function(t0) {
48203
48169
  return t3;
48204
48170
  };
48205
48171
  // src/components/threads/AudioThread/Visualization/index.tsx
48206
- import { c as _c93 } from "react-compiler-runtime";
48172
+ import { c as _c92 } from "react-compiler-runtime";
48207
48173
  import { useState as useState11, useCallback as useCallback9, useEffect as useEffect12, useContext as useContext20, createContext as createContext14 } from "react";
48208
48174
  import _9 from "lodash";
48209
48175
  import { Flex as Flex31 } from "@radix-ui/themes";
@@ -48272,10 +48238,10 @@ var BarsVisualizer = function(_ref) {
48272
48238
  });
48273
48239
  };
48274
48240
  // src/hooks/audioThreads/useStatus/index.ts
48275
- import { c as _c92 } from "react-compiler-runtime";
48241
+ import { c as _c91 } from "react-compiler-runtime";
48276
48242
  import { useMemo as useMemo19 } from "react";
48277
48243
  var useStatus = function() {
48278
- var $ = _c92(2);
48244
+ var $ = _c91(2);
48279
48245
  var audioRuntime = useAudioThreadContext().audioRuntime;
48280
48246
  var t0;
48281
48247
  bb0: {
@@ -48435,7 +48401,7 @@ var Provider6 = function(_ref) {
48435
48401
  });
48436
48402
  };
48437
48403
  var Root17 = function(t0) {
48438
- var $ = _c93(6);
48404
+ var $ = _c92(6);
48439
48405
  var children;
48440
48406
  var rest;
48441
48407
  if ($[0] !== t0) {
@@ -48472,7 +48438,7 @@ var Root17 = function(t0) {
48472
48438
  return t1;
48473
48439
  };
48474
48440
  var BarsVisualizer2 = function(t0) {
48475
- var $ = _c93(10);
48441
+ var $ = _c92(10);
48476
48442
  var rest;
48477
48443
  var t1;
48478
48444
  var t2;
@@ -48516,7 +48482,7 @@ var BarsVisualizer2 = function(t0) {
48516
48482
  return t4;
48517
48483
  };
48518
48484
  var AssistantVisualizationRoot = function(t0) {
48519
- var $ = _c93(17);
48485
+ var $ = _c92(17);
48520
48486
  var children;
48521
48487
  var rest;
48522
48488
  var t1;
@@ -48589,7 +48555,7 @@ var AssistantVisualizationRoot = function(t0) {
48589
48555
  return t6;
48590
48556
  };
48591
48557
  var AssistantVisualization = function(props) {
48592
- var $ = _c93(3);
48558
+ var $ = _c92(3);
48593
48559
  var t0;
48594
48560
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
48595
48561
  t0 = /* @__PURE__ */ _jsx90(BarsVisualizer2, {});
@@ -48612,7 +48578,7 @@ var AssistantVisualization = function(props) {
48612
48578
  AssistantVisualization.Root = AssistantVisualizationRoot;
48613
48579
  AssistantVisualization.BarsVisualizer = BarsVisualizer2;
48614
48580
  var AssistantInfo = function(props) {
48615
- var $ = _c93(6);
48581
+ var $ = _c92(6);
48616
48582
  var assistantNameContext = useContext20(AssistantNameContext);
48617
48583
  var t0;
48618
48584
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
@@ -48652,7 +48618,7 @@ var AssistantInfo = function(props) {
48652
48618
  return t2;
48653
48619
  };
48654
48620
  var Visualization = function(props) {
48655
- var $ = _c93(4);
48621
+ var $ = _c92(4);
48656
48622
  var t0;
48657
48623
  var t1;
48658
48624
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
@@ -48684,9 +48650,9 @@ Visualization.Provider = Provider6;
48684
48650
  Visualization.AssistantVisualization = AssistantVisualization;
48685
48651
  Visualization.AssistantInfo = AssistantInfo;
48686
48652
  // src/components/threads/AudioThread/Status/index.tsx
48687
- import { c as _c95 } from "react-compiler-runtime";
48688
- // src/components/threads/AudioThread/Status/StatusMessages.tsx
48689
48653
  import { c as _c94 } from "react-compiler-runtime";
48654
+ // src/components/threads/AudioThread/Status/StatusMessages.tsx
48655
+ import { c as _c93 } from "react-compiler-runtime";
48690
48656
  import { Flex as Flex32, Text as Text9 } from "@radix-ui/themes";
48691
48657
  import { jsx as _jsx91, jsxs as _jsxs32 } from "react/jsx-runtime";
48692
48658
  var html = function(_ref) {
@@ -48696,7 +48662,7 @@ var html = function(_ref) {
48696
48662
  }).join(""), "\n }");
48697
48663
  };
48698
48664
  var StatusMessages = function(t0) {
48699
- var $ = _c94(9);
48665
+ var $ = _c93(9);
48700
48666
  var texts = t0.texts, className = t0.className, style = t0.style;
48701
48667
  var t1;
48702
48668
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
@@ -48800,7 +48766,7 @@ function _toPrimitive50(t, r) {
48800
48766
  return ("string" === r ? String : Number)(t);
48801
48767
  }
48802
48768
  var Status = function(props) {
48803
- var $ = _c95(12);
48769
+ var $ = _c94(12);
48804
48770
  var status = useStatus().status;
48805
48771
  if (status === "recording") {
48806
48772
  var _t;
@@ -48897,10 +48863,10 @@ var Status = function(props) {
48897
48863
  return t1;
48898
48864
  };
48899
48865
  // src/components/threads/AudioThread/Form/index.tsx
48900
- import { c as _c98 } from "react-compiler-runtime";
48866
+ import { c as _c97 } from "react-compiler-runtime";
48901
48867
  import { Flex as Flex34 } from "@radix-ui/themes";
48902
48868
  // src/components/threads/AudioThread/Form/MicIcon.tsx
48903
- import { c as _c96 } from "react-compiler-runtime";
48869
+ import { c as _c95 } from "react-compiler-runtime";
48904
48870
  import { jsx as _jsx93 } from "react/jsx-runtime";
48905
48871
  function ownKeys51(e, r) {
48906
48872
  var t = Object.keys(e);
@@ -48946,7 +48912,7 @@ function _toPrimitive51(t, r) {
48946
48912
  return ("string" === r ? String : Number)(t);
48947
48913
  }
48948
48914
  var MicIcon = function(props) {
48949
- var $ = _c96(3);
48915
+ var $ = _c95(3);
48950
48916
  var t0;
48951
48917
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
48952
48918
  t0 = /* @__PURE__ */ _jsx93("path", {
@@ -48978,12 +48944,12 @@ var MicIcon = function(props) {
48978
48944
  return t1;
48979
48945
  };
48980
48946
  // src/components/threads/AudioThread/Form/ActionButton/index.tsx
48981
- import { c as _c97 } from "react-compiler-runtime";
48947
+ import { c as _c96 } from "react-compiler-runtime";
48982
48948
  import { Flex as Flex33, IconButton as IconButton10 } from "@radix-ui/themes";
48983
48949
  import { StopIcon as StopIcon2, PauseIcon as PauseIcon2, ArrowUpIcon as ArrowUpIcon3, ResumeIcon } from "@radix-ui/react-icons";
48984
48950
  import { jsx as _jsx94, jsxs as _jsxs33 } from "react/jsx-runtime";
48985
48951
  var ActionButton = function() {
48986
- var $ = _c97(27);
48952
+ var $ = _c96(27);
48987
48953
  var status = useStatus().status;
48988
48954
  var audioThreadContext = useAudioThreadContext();
48989
48955
  var superinterfaceContext = useSuperinterfaceContext();
@@ -49221,7 +49187,7 @@ function _toPrimitive52(t, r) {
49221
49187
  return ("string" === r ? String : Number)(t);
49222
49188
  }
49223
49189
  var Form = function(props) {
49224
- var $ = _c98(17);
49190
+ var $ = _c97(17);
49225
49191
  var status = useStatus().status;
49226
49192
  var audioThreadContext = useAudioThreadContext();
49227
49193
  var t0 = status === "recording" ? "var(--accent-11)" : "var(--gray-11)";
@@ -49371,7 +49337,7 @@ function _toPrimitive53(t, r) {
49371
49337
  return ("string" === r ? String : Number)(t);
49372
49338
  }
49373
49339
  var AudioThread = function(props) {
49374
- var $ = _c99(5);
49340
+ var $ = _c98(5);
49375
49341
  var t0;
49376
49342
  var t1;
49377
49343
  var t2;
@@ -49453,7 +49419,7 @@ function _toPrimitive54(t, r) {
49453
49419
  return ("string" === r ? String : Number)(t);
49454
49420
  }
49455
49421
  var AudioThreadDialog = function(props) {
49456
- var $ = _c100(4);
49422
+ var $ = _c99(4);
49457
49423
  var t0;
49458
49424
  var t1;
49459
49425
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
@@ -49975,10 +49941,10 @@ var useWebrtcAudioRuntime = function() {
49975
49941
  ]);
49976
49942
  };
49977
49943
  // src/components/audioRuntimes/WebrtcAudioRuntimeProvider.tsx
49978
- import { c as _c101 } from "react-compiler-runtime";
49944
+ import { c as _c100 } from "react-compiler-runtime";
49979
49945
  import { jsx as _jsx98 } from "react/jsx-runtime";
49980
49946
  var WebrtcAudioRuntimeProvider = function(t0) {
49981
- var $ = _c101(5);
49947
+ var $ = _c100(5);
49982
49948
  var children = t0.children;
49983
49949
  var webrtcAudioRuntime = useWebrtcAudioRuntime().webrtcAudioRuntime;
49984
49950
  var t1;
@@ -50006,20 +49972,20 @@ var WebrtcAudioRuntimeProvider = function(t0) {
50006
49972
  return t2;
50007
49973
  };
50008
49974
  // src/components/gui/Gui/index.tsx
50009
- import { c as _c104 } from "react-compiler-runtime";
49975
+ import { c as _c103 } from "react-compiler-runtime";
50010
49976
  import { useMemo as useMemo23 } from "react";
50011
49977
  import { Flex as Flex35, Card as Card5, Spinner as Spinner3 } from "@radix-ui/themes";
50012
49978
  // src/hooks/messages/useLatestAssistantMessage/index.ts
50013
- import { c as _c102 } from "react-compiler-runtime";
49979
+ import { c as _c101 } from "react-compiler-runtime";
50014
49980
  import { useMemo as useMemo21 } from "react";
50015
49981
  var useLatestAssistantMessage = function() {
50016
- var $ = _c102(4);
49982
+ var $ = _c101(4);
50017
49983
  var _useMessages = useMessages(), messages2 = _useMessages.messages;
50018
49984
  var t0;
50019
49985
  var t1;
50020
49986
  if ($[0] !== messages2) {
50021
49987
  var _messages$find;
50022
- t1 = (_messages$find = messages2.find(_temp11)) !== null && _messages$find !== void 0 ? _messages$find : null;
49988
+ t1 = (_messages$find = messages2.find(_temp10)) !== null && _messages$find !== void 0 ? _messages$find : null;
50023
49989
  $[0] = messages2;
50024
49990
  $[1] = t1;
50025
49991
  } else {
@@ -50038,21 +50004,21 @@ var useLatestAssistantMessage = function() {
50038
50004
  t0 = t2;
50039
50005
  return t0;
50040
50006
  };
50041
- function _temp11(message) {
50007
+ function _temp10(message) {
50042
50008
  return message.role === "assistant";
50043
50009
  }
50044
50010
  // src/hooks/messages/useLatestAssistantMessageWithContent/index.ts
50045
- import { c as _c103 } from "react-compiler-runtime";
50011
+ import { c as _c102 } from "react-compiler-runtime";
50046
50012
  import { isEmpty as isEmpty3 } from "radash";
50047
50013
  import { useMemo as useMemo22 } from "react";
50048
50014
  var useLatestAssistantMessageWithContent = function() {
50049
- var $ = _c103(4);
50015
+ var $ = _c102(4);
50050
50016
  var _useMessages = useMessages(), messages2 = _useMessages.messages;
50051
50017
  var t0;
50052
50018
  var t1;
50053
50019
  if ($[0] !== messages2) {
50054
50020
  var _messages$find;
50055
- t1 = (_messages$find = messages2.find(_temp26)) !== null && _messages$find !== void 0 ? _messages$find : null;
50021
+ t1 = (_messages$find = messages2.find(_temp25)) !== null && _messages$find !== void 0 ? _messages$find : null;
50056
50022
  $[0] = messages2;
50057
50023
  $[1] = t1;
50058
50024
  } else {
@@ -50071,16 +50037,16 @@ var useLatestAssistantMessageWithContent = function() {
50071
50037
  t0 = t2;
50072
50038
  return t0;
50073
50039
  };
50074
- function _temp12(content2) {
50040
+ function _temp11(content2) {
50075
50041
  return content2.type === "text" && !isEmpty3(content2.text.value);
50076
50042
  }
50077
- function _temp26(message) {
50078
- return message.role === "assistant" && message.content.some(_temp12);
50043
+ function _temp25(message) {
50044
+ return message.role === "assistant" && message.content.some(_temp11);
50079
50045
  }
50080
50046
  // src/components/gui/Gui/index.tsx
50081
50047
  import { jsx as _jsx99, jsxs as _jsxs37 } from "react/jsx-runtime";
50082
50048
  var StartingToolCalls3 = function() {
50083
- var $ = _c104(2);
50049
+ var $ = _c103(2);
50084
50050
  var _useComponents = useComponents(), t0 = _useComponents.components;
50085
50051
  var StartingToolCalls4 = t0.StartingToolCalls;
50086
50052
  var t1;
@@ -50094,7 +50060,7 @@ var StartingToolCalls3 = function() {
50094
50060
  return t1;
50095
50061
  };
50096
50062
  var Content10 = function(t0) {
50097
- var $ = _c104(5);
50063
+ var $ = _c103(5);
50098
50064
  var latestRunStep = t0.latestRunStep;
50099
50065
  var t1;
50100
50066
  bb0: {
@@ -50148,14 +50114,14 @@ var Content10 = function(t0) {
50148
50114
  return t2;
50149
50115
  };
50150
50116
  var Progress2 = function(t0) {
50151
- var $ = _c104(5);
50117
+ var $ = _c103(5);
50152
50118
  var latestAssistantMessage = t0.latestAssistantMessage;
50153
50119
  var isMutatingMessage = useIsMutatingMessage();
50154
50120
  var t1;
50155
50121
  var t2;
50156
50122
  if ($[0] !== latestAssistantMessage.runSteps) {
50157
50123
  var _latestAssistantMessa;
50158
- t2 = (_latestAssistantMessa = latestAssistantMessage.runSteps.find(_temp13)) !== null && _latestAssistantMessa !== void 0 ? _latestAssistantMessa : null;
50124
+ t2 = (_latestAssistantMessa = latestAssistantMessage.runSteps.find(_temp12)) !== null && _latestAssistantMessa !== void 0 ? _latestAssistantMessa : null;
50159
50125
  $[0] = latestAssistantMessage.runSteps;
50160
50126
  $[1] = t2;
50161
50127
  } else {
@@ -50198,7 +50164,7 @@ var Progress2 = function(t0) {
50198
50164
  return t4;
50199
50165
  };
50200
50166
  var Gui = function() {
50201
- var $ = _c104(8);
50167
+ var $ = _c103(8);
50202
50168
  var latestAssistantMessage = useLatestAssistantMessage().latestAssistantMessage;
50203
50169
  var latestAssistantMessageWithContent = useLatestAssistantMessageWithContent().latestAssistantMessageWithContent;
50204
50170
  if (!latestAssistantMessage || !latestAssistantMessageWithContent) {
@@ -50260,11 +50226,11 @@ var Gui = function() {
50260
50226
  }
50261
50227
  return t2;
50262
50228
  };
50263
- function _temp13(rs) {
50229
+ function _temp12(rs) {
50264
50230
  return rs.status === "in_progress";
50265
50231
  }
50266
50232
  // src/components/markdown/MarkdownProvider/index.tsx
50267
- import { c as _c105 } from "react-compiler-runtime";
50233
+ import { c as _c104 } from "react-compiler-runtime";
50268
50234
  import { useMemo as useMemo24 } from "react";
50269
50235
  import { jsx as _jsx100 } from "react/jsx-runtime";
50270
50236
  var _excluded7 = [
@@ -50289,7 +50255,7 @@ function _objectWithoutPropertiesLoose7(r, e) {
50289
50255
  return t;
50290
50256
  }
50291
50257
  var MarkdownProvider = function(t0) {
50292
- var $ = _c105(9);
50258
+ var $ = _c104(9);
50293
50259
  var children;
50294
50260
  var rest;
50295
50261
  if ($[0] !== t0) {
@@ -50332,18 +50298,18 @@ var MarkdownProvider = function(t0) {
50332
50298
  return t3;
50333
50299
  };
50334
50300
  // src/components/annotations/SourceAnnotation/index.tsx
50335
- import { c as _c108 } from "react-compiler-runtime";
50336
- // src/components/annotations/SourceAnnotation/FileCitation/index.tsx
50337
50301
  import { c as _c107 } from "react-compiler-runtime";
50302
+ // src/components/annotations/SourceAnnotation/FileCitation/index.tsx
50303
+ import { c as _c106 } from "react-compiler-runtime";
50338
50304
  import { useState as useState13 } from "react";
50339
50305
  import { QuoteIcon as QuoteIcon2 } from "@radix-ui/react-icons";
50340
50306
  import { Dialog, VisuallyHidden, IconButton as IconButton11 } from "@radix-ui/themes";
50341
50307
  // src/components/annotations/SourceAnnotation/FileCitation/Content.tsx
50342
- import { c as _c106 } from "react-compiler-runtime";
50308
+ import { c as _c105 } from "react-compiler-runtime";
50343
50309
  import { Flex as Flex36, Card as Card6, Inset as Inset3 } from "@radix-ui/themes";
50344
50310
  import { jsx as _jsx101 } from "react/jsx-runtime";
50345
50311
  var Content11 = function(t0) {
50346
- var $ = _c106(5);
50312
+ var $ = _c105(5);
50347
50313
  var fileId = t0.fileId;
50348
50314
  var superinterfaceContext = useSuperinterfaceContext();
50349
50315
  var nextSearchParams = new URLSearchParams(superinterfaceContext.variables);
@@ -50409,7 +50375,7 @@ var Content11 = function(t0) {
50409
50375
  // src/components/annotations/SourceAnnotation/FileCitation/index.tsx
50410
50376
  import { jsx as _jsx102, jsxs as _jsxs38, Fragment as _Fragment6 } from "react/jsx-runtime";
50411
50377
  var FileCitation = function(t0) {
50412
- var $ = _c107(18);
50378
+ var $ = _c106(18);
50413
50379
  var annotation = t0.annotation;
50414
50380
  var _useState13 = _sliced_to_array(useState13(null), 2), activeFileId = _useState13[0], setActiveFileId = _useState13[1];
50415
50381
  var t1;
@@ -50558,7 +50524,7 @@ function _objectWithoutPropertiesLoose8(r, e) {
50558
50524
  return t;
50559
50525
  }
50560
50526
  var SourceAnnotation = function(t0) {
50561
- var $ = _c108(10);
50527
+ var $ = _c107(10);
50562
50528
  var children;
50563
50529
  var rest;
50564
50530
  if ($[0] !== t0) {
@@ -50615,7 +50581,7 @@ var SourceAnnotation = function(t0) {
50615
50581
  return null;
50616
50582
  };
50617
50583
  // src/components/avatars/Avatar.tsx
50618
- import { c as _c111 } from "react-compiler-runtime";
50584
+ import { c as _c110 } from "react-compiler-runtime";
50619
50585
  // src/enums/index.ts
50620
50586
  var IconAvatarName = /* @__PURE__ */ function(IconAvatarName2) {
50621
50587
  IconAvatarName2["BACKPACK"] = "BACKPACK";
@@ -50640,7 +50606,7 @@ var AvatarType = /* @__PURE__ */ function(AvatarType2) {
50640
50606
  // src/components/avatars/Avatar.tsx
50641
50607
  import { Avatar as RadixAvatar } from "@radix-ui/themes";
50642
50608
  // src/components/imageAvatars/ImageAvatar/index.tsx
50643
- import { c as _c109 } from "react-compiler-runtime";
50609
+ import { c as _c108 } from "react-compiler-runtime";
50644
50610
  import { Avatar as Avatar4 } from "@radix-ui/themes";
50645
50611
  // src/components/imageAvatars/ImageAvatar/lib/optimizedSrc/path.ts
50646
50612
  var width = function(_ref) {
@@ -50694,7 +50660,7 @@ var optimizedSrc = function(_ref) {
50694
50660
  // src/components/imageAvatars/ImageAvatar/index.tsx
50695
50661
  import { jsx as _jsx104 } from "react/jsx-runtime";
50696
50662
  var ImageAvatar = function(t0) {
50697
- var $ = _c109(9);
50663
+ var $ = _c108(9);
50698
50664
  var imageAvatar = t0.imageAvatar, size = t0.size, className = t0.className, style = t0.style;
50699
50665
  var superinterfaceContext = useSuperinterfaceContext();
50700
50666
  var t1;
@@ -50731,7 +50697,7 @@ var ImageAvatar = function(t0) {
50731
50697
  return t2;
50732
50698
  };
50733
50699
  // src/components/iconAvatars/IconAvatar.tsx
50734
- import { c as _c110 } from "react-compiler-runtime";
50700
+ import { c as _c109 } from "react-compiler-runtime";
50735
50701
  import { useMemo as useMemo25 } from "react";
50736
50702
  import { Avatar as Avatar5 } from "@radix-ui/themes";
50737
50703
  // src/lib/iconAvatars/iconAvatarComponents.ts
@@ -50741,7 +50707,7 @@ var iconAvatarComponents = (_obj = {}, _define_property(_obj, IconAvatarName.BAC
50741
50707
  // src/components/iconAvatars/IconAvatar.tsx
50742
50708
  import { jsx as _jsx105 } from "react/jsx-runtime";
50743
50709
  var IconAvatar = function(t0) {
50744
- var $ = _c110(7);
50710
+ var $ = _c109(7);
50745
50711
  var iconAvatar = t0.iconAvatar, size = t0.size, className = t0.className, style = t0.style;
50746
50712
  var t1;
50747
50713
  t1 = iconAvatarComponents[iconAvatar.name];
@@ -50775,7 +50741,7 @@ var IconAvatar = function(t0) {
50775
50741
  // src/components/avatars/Avatar.tsx
50776
50742
  import { jsx as _jsx106 } from "react/jsx-runtime";
50777
50743
  var Avatar6 = function(t0) {
50778
- var $ = _c111(14);
50744
+ var $ = _c110(14);
50779
50745
  var avatar = t0.avatar, t1 = t0.size, className = t0.className, style = t0.style;
50780
50746
  var size = t1 === void 0 ? "1" : t1;
50781
50747
  if (avatar) {
@@ -50836,7 +50802,7 @@ var Avatar6 = function(t0) {
50836
50802
  return t2;
50837
50803
  };
50838
50804
  // src/components/components/ComponentsProvider.tsx
50839
- import { c as _c112 } from "react-compiler-runtime";
50805
+ import { c as _c111 } from "react-compiler-runtime";
50840
50806
  import { useMemo as useMemo26 } from "react";
50841
50807
  import { jsx as _jsx107 } from "react/jsx-runtime";
50842
50808
  var _excluded9 = [
@@ -50861,7 +50827,7 @@ function _objectWithoutPropertiesLoose9(r, e) {
50861
50827
  return t;
50862
50828
  }
50863
50829
  var ComponentsProvider = function(t0) {
50864
- var $ = _c112(9);
50830
+ var $ = _c111(9);
50865
50831
  var children;
50866
50832
  var rest;
50867
50833
  if ($[0] !== t0) {
@@ -50904,11 +50870,11 @@ var ComponentsProvider = function(t0) {
50904
50870
  return t3;
50905
50871
  };
50906
50872
  // src/components/assistants/AssistantProvider/index.tsx
50907
- import { c as _c113 } from "react-compiler-runtime";
50873
+ import { c as _c112 } from "react-compiler-runtime";
50908
50874
  import { jsx as _jsx108 } from "react/jsx-runtime";
50909
50875
  var AssistantProvider = function(t0) {
50910
50876
  var _assistant$name;
50911
- var $ = _c113(10);
50877
+ var $ = _c112(10);
50912
50878
  var children = t0.children;
50913
50879
  var superinterfaceContext = useSuperinterfaceContext();
50914
50880
  var t1;