@superinterface/react 5.3.0-beta.2 → 5.3.0-beta.20

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
@@ -366,7 +366,7 @@ var require_lib = __commonJS({
366
366
  Object.defineProperty(exports2, "__esModule", {
367
367
  value: true
368
368
  });
369
- function _objectWithoutPropertiesLoose10(r, e) {
369
+ function _objectWithoutPropertiesLoose12(r, e) {
370
370
  if (null == r) return {};
371
371
  var t = {};
372
372
  for(var n in r)if (({}).hasOwnProperty.call(r, n)) {
@@ -733,7 +733,7 @@ var require_lib = __commonJS({
733
733
  PrimaryTopicNotAllowed: "Topic reference was used in a lexical context without topic binding.",
734
734
  PrimaryTopicRequiresSmartPipeline: 'Topic reference is used, but the pipelineOperator plugin was not passed a "proposal": "hack" or "smart" option.'
735
735
  });
736
- var _excluded10 = [
736
+ var _excluded12 = [
737
737
  "message"
738
738
  ];
739
739
  function defineHidden(obj, key2, value) {
@@ -808,7 +808,7 @@ var require_lib = __commonJS({
808
808
  }
809
809
  } : typeof template === "function" ? {
810
810
  message: template
811
- } : template, message = _ref.message, rest = _objectWithoutPropertiesLoose10(_ref, _excluded10);
811
+ } : template, message = _ref.message, rest = _objectWithoutPropertiesLoose12(_ref, _excluded12);
812
812
  var toMessage = typeof message === "string" ? function() {
813
813
  return message;
814
814
  } : message;
@@ -47037,7 +47037,7 @@ var useAudioThreadContext = function() {
47037
47037
  var import_react_compiler_runtime90 = require("react-compiler-runtime");
47038
47038
  // src/hooks/audioRuntimes/useTtsAudioRuntime/index.ts
47039
47039
  var import_react_compiler_runtime89 = require("react-compiler-runtime");
47040
- var import_react68 = require("react");
47040
+ var import_react69 = require("react");
47041
47041
  // src/hooks/misc/usePermission/index.ts
47042
47042
  var import_react_compiler_runtime86 = require("react-compiler-runtime");
47043
47043
  var import_react64 = require("react");
@@ -47369,10 +47369,7 @@ var useRecorder = function(_ref) {
47369
47369
  };
47370
47370
  // src/hooks/audioThreads/useMessageAudio/index.ts
47371
47371
  var import_react_compiler_runtime88 = require("react-compiler-runtime");
47372
- var import_react67 = require("react");
47373
- var import_compromise = __toESM(require("compromise"), 1);
47374
- var import_howler = require("howler");
47375
- var import_react_use_audio_player2 = require("react-use-audio-player");
47372
+ var import_react68 = require("react");
47376
47373
  // src/hooks/audioThreads/useMessageAudio/lib/input.ts
47377
47374
  var import_radash16 = require("radash");
47378
47375
  var input = function(_ref) {
@@ -47386,6 +47383,10 @@ var input = function(_ref) {
47386
47383
  if ((0, import_radash16.isEmpty)(result)) return null;
47387
47384
  return result;
47388
47385
  };
47386
+ // src/hooks/audioThreads/useMessageAudio/lib/useDefaultPlay.ts
47387
+ var import_react67 = require("react");
47388
+ var import_howler = require("howler");
47389
+ var import_react_use_audio_player2 = require("react-use-audio-player");
47389
47390
  // src/hooks/audioThreads/useMessageAudio/lib/isHtmlAudioSupported.ts
47390
47391
  var import_detect_browser = require("detect-browser");
47391
47392
  var _detect;
@@ -47394,7 +47395,7 @@ var unsupportedNames = [
47394
47395
  "ios"
47395
47396
  ];
47396
47397
  var isHtmlAudioSupported = !unsupportedNames.includes(((_detect = (0, import_detect_browser.detect)()) === null || _detect === void 0 ? void 0 : _detect.name) || "");
47397
- // src/hooks/audioThreads/useMessageAudio/index.ts
47398
+ // src/hooks/audioThreads/useMessageAudio/lib/useDefaultPlay.ts
47398
47399
  function ownKeys47(e, r) {
47399
47400
  var t = Object.keys(e);
47400
47401
  if (Object.getOwnPropertySymbols) {
@@ -47438,14 +47439,516 @@ function _toPrimitive47(t, r) {
47438
47439
  }
47439
47440
  return ("string" === r ? String : Number)(t);
47440
47441
  }
47441
- var segment = function(input2) {
47442
- return (0, import_compromise.default)(input2).sentences().json().map(function(s) {
47443
- return s.text;
47444
- });
47442
+ var MAX_SEG_CACHE = 256;
47443
+ var KEEP_FINISHED_MESSAGES = 12;
47444
+ var hasLetters = function(input2) {
47445
+ for(var i = 0; i < input2.length; i++){
47446
+ var ch = input2.charAt(i);
47447
+ if (ch.toLowerCase() !== ch.toUpperCase()) return true;
47448
+ }
47449
+ return false;
47450
+ };
47451
+ var isSentencePunct = function(ch) {
47452
+ return ch === "." || ch === "!" || ch === "?" || ch === "\u3002" || ch === "\uFF01" || ch === "\uFF1F";
47453
+ };
47454
+ var normalizeBoundaries = function(text) {
47455
+ var out = "";
47456
+ for(var i = 0; i < text.length; i++){
47457
+ var ch = text.charAt(i);
47458
+ out += ch;
47459
+ if (isSentencePunct(ch)) {
47460
+ var next = text.charAt(i + 1);
47461
+ if (next && next !== " " && hasLetters(next)) {
47462
+ out += " ";
47463
+ }
47464
+ }
47465
+ }
47466
+ return out;
47467
+ };
47468
+ var splitSentencesFast = function(raw) {
47469
+ var normalized = normalizeBoundaries(raw.replace(/\s+/g, " ").trim());
47470
+ if (!normalized) return [];
47471
+ var parts = normalized.split(RegExp("(?<=[.!?])\\s+(?=[^\\s])", "g"));
47472
+ var filtered = [];
47473
+ for(var i = 0; i < parts.length; i++){
47474
+ var part = parts[i].trim();
47475
+ if (part && hasLetters(part)) filtered.push(part);
47476
+ }
47477
+ return filtered;
47478
+ };
47479
+ var getIncrementalSentences = function(prev, nextInput, now) {
47480
+ if (!prev) {
47481
+ return {
47482
+ input: nextInput,
47483
+ sentences: splitSentencesFast(nextInput),
47484
+ touched: now
47485
+ };
47486
+ }
47487
+ if (nextInput === prev.input) {
47488
+ return {
47489
+ input: prev.input,
47490
+ sentences: prev.sentences,
47491
+ touched: now
47492
+ };
47493
+ }
47494
+ if (nextInput.startsWith(prev.input)) {
47495
+ var prevSentences = prev.sentences;
47496
+ var prevLast = prevSentences[prevSentences.length - 1] || "";
47497
+ var baseLen = prev.input.length - prevLast.length;
47498
+ if (baseLen >= 0 && prev.input.slice(baseLen) === prevLast) {
47499
+ var tail = nextInput.slice(baseLen);
47500
+ var tailSegments = splitSentencesFast(tail);
47501
+ var merged = prevSentences.length > 0 ? prevSentences.slice(0, -1).concat(tailSegments) : tailSegments;
47502
+ return {
47503
+ input: nextInput,
47504
+ sentences: merged,
47505
+ touched: now
47506
+ };
47507
+ }
47508
+ }
47509
+ return {
47510
+ input: nextInput,
47511
+ sentences: splitSentencesFast(nextInput),
47512
+ touched: now
47513
+ };
47514
+ };
47515
+ var getPerformanceNow = function() {
47516
+ return typeof performance !== "undefined" && typeof performance.now === "function" ? performance.now() : Date.now();
47517
+ };
47518
+ var useDefaultPlay = function(_ref) {
47519
+ var enabled = _ref.enabled, fullSentenceRegex = _ref.fullSentenceRegex, onEnd = _ref.onEnd, superinterfaceContext = _ref.superinterfaceContext, isAudioPlayed = _ref.isAudioPlayed;
47520
+ var audioPlayer = (0, import_react_use_audio_player2.useAudioPlayer)();
47521
+ var nextAudioPlayer = (0, import_react_use_audio_player2.useAudioPlayer)();
47522
+ var _$_ref = _sliced_to_array((0, import_react67.useState)(false), 2), isPlaying = _$_ref[0], setIsPlaying = _$_ref[1];
47523
+ var _$_ref1 = _sliced_to_array((0, import_react67.useState)([]), 2), audioQueue = _$_ref1[0], setAudioQueue = _$_ref1[1];
47524
+ var audioQueueRef = (0, import_react67.useRef)(audioQueue);
47525
+ (0, import_react67.useEffect)(function() {
47526
+ audioQueueRef.current = audioQueue;
47527
+ }, [
47528
+ audioQueue
47529
+ ]);
47530
+ var messageStatesRef = (0, import_react67.useRef)(/* @__PURE__ */ new Map());
47531
+ var segCacheRef = (0, import_react67.useRef)(/* @__PURE__ */ new Map());
47532
+ var chunkQueuesRef = (0, import_react67.useRef)(/* @__PURE__ */ new Map());
47533
+ var messageOrderRef = (0, import_react67.useRef)(/* @__PURE__ */ new Map());
47534
+ var pickLockRef = (0, import_react67.useRef)(false);
47535
+ var currentSentenceRef = (0, import_react67.useRef)(null);
47536
+ var currentChunkRef = (0, import_react67.useRef)(null);
47537
+ var evictSegCache = (0, import_react67.useCallback)(function() {
47538
+ var segCache = segCacheRef.current;
47539
+ if (segCache.size <= MAX_SEG_CACHE) return;
47540
+ var entries = Array.from(segCache.entries());
47541
+ entries.sort(function(a, b) {
47542
+ return a[1].touched - b[1].touched;
47543
+ });
47544
+ var toRemove = segCache.size - MAX_SEG_CACHE;
47545
+ for(var i = 0; i < toRemove; i++)segCache.delete(entries[i][0]);
47546
+ }, []);
47547
+ var getOrder = (0, import_react67.useCallback)(function(state) {
47548
+ var explicit = messageOrderRef.current.get(state.id);
47549
+ if (explicit != null) return explicit;
47550
+ return state.order;
47551
+ }, []);
47552
+ var rebuildQueue = (0, import_react67.useCallback)(function() {
47553
+ if (!enabled) return;
47554
+ var states = Array.from(messageStatesRef.current.values());
47555
+ states.sort(function(a_0, b_0) {
47556
+ return getOrder(a_0) - getOrder(b_0);
47557
+ });
47558
+ var unfinished = [];
47559
+ var finished = [];
47560
+ for(var i_0 = 0; i_0 < states.length; i_0++){
47561
+ var state_0 = states[i_0];
47562
+ if (!state_0.stopped && (state_0.status === "in_progress" || state_0.nextIndex < state_0.sentences.length)) {
47563
+ unfinished.push(state_0);
47564
+ } else {
47565
+ finished.push(state_0);
47566
+ }
47567
+ }
47568
+ if (finished.length > KEEP_FINISHED_MESSAGES) {
47569
+ var toTrim = finished.length - KEEP_FINISHED_MESSAGES;
47570
+ for(var i_1 = 0; i_1 < toTrim; i_1++){
47571
+ var removed = finished.shift();
47572
+ if (!removed) break;
47573
+ messageStatesRef.current.delete(removed.id);
47574
+ segCacheRef.current.delete(removed.id);
47575
+ chunkQueuesRef.current.delete(removed.id);
47576
+ }
47577
+ }
47578
+ var combined = _to_consumable_array(unfinished).concat(_to_consumable_array(finished));
47579
+ audioQueueRef.current = combined;
47580
+ setAudioQueue(function(prev) {
47581
+ if (prev.length === combined.length) {
47582
+ var identical = true;
47583
+ for(var i_2 = 0; i_2 < prev.length; i_2++){
47584
+ if (prev[i_2] !== combined[i_2]) {
47585
+ identical = false;
47586
+ break;
47587
+ }
47588
+ }
47589
+ if (identical) return prev;
47590
+ }
47591
+ return combined;
47592
+ });
47593
+ }, [
47594
+ enabled,
47595
+ getOrder
47596
+ ]);
47597
+ var checkForCompletion = (0, import_react67.useCallback)(function() {
47598
+ if (!enabled) return;
47599
+ var hasPending = Array.from(messageStatesRef.current.values()).some(function(state_1) {
47600
+ if (state_1.stopped) return false;
47601
+ var hasMore = state_1.nextIndex < state_1.sentences.length;
47602
+ var streaming = state_1.status === "in_progress";
47603
+ return hasMore || streaming;
47604
+ });
47605
+ if (!hasPending) onEnd();
47606
+ }, [
47607
+ enabled,
47608
+ onEnd
47609
+ ]);
47610
+ var finishChunk = (0, import_react67.useCallback)(function(messageId, reason) {
47611
+ if (!enabled) return;
47612
+ var queues = chunkQueuesRef.current;
47613
+ var queue = queues.get(messageId);
47614
+ if (!queue || queue.length === 0) return;
47615
+ var chunk = queue[0];
47616
+ if (reason === "stop") {
47617
+ if (!chunk.stopped) {
47618
+ chunk.stopped = true;
47619
+ chunk.onStop();
47620
+ }
47621
+ queue.shift();
47622
+ if (queue.length === 0) queues.delete(messageId);
47623
+ return;
47624
+ }
47625
+ chunk.remaining -= 1;
47626
+ if (chunk.remaining <= 0) {
47627
+ chunk.onEnd();
47628
+ queue.shift();
47629
+ if (queue.length === 0) queues.delete(messageId);
47630
+ }
47631
+ }, [
47632
+ enabled
47633
+ ]);
47634
+ var startNextSegment = (0, import_react67.useCallback)(function() {
47635
+ if (!enabled) return;
47636
+ if (isPlaying) return;
47637
+ if (audioPlayer.playing) return;
47638
+ if (pickLockRef.current) return;
47639
+ var queueSnapshot = audioQueueRef.current.slice();
47640
+ queueSnapshot.sort(function(a_1, b_1) {
47641
+ return getOrder(a_1) - getOrder(b_1);
47642
+ });
47643
+ var candidate = null;
47644
+ for(var i_3 = 0; i_3 < queueSnapshot.length; i_3++){
47645
+ var state_2 = queueSnapshot[i_3];
47646
+ if (state_2.stopped) continue;
47647
+ var sentence = state_2.sentences[state_2.nextIndex];
47648
+ if (!sentence) continue;
47649
+ var isFull = isOptimistic({
47650
+ id: state_2.id
47651
+ }) || state_2.status !== "in_progress" || fullSentenceRegex.test(sentence);
47652
+ if (!isFull) continue;
47653
+ candidate = {
47654
+ messageId: state_2.id,
47655
+ sentence: sentence,
47656
+ index: state_2.nextIndex,
47657
+ status: state_2.status
47658
+ };
47659
+ break;
47660
+ }
47661
+ if (!candidate) return;
47662
+ pickLockRef.current = true;
47663
+ setIsPlaying(true);
47664
+ currentSentenceRef.current = {
47665
+ messageId: candidate.messageId,
47666
+ index: candidate.index
47667
+ };
47668
+ var state_3 = messageStatesRef.current.get(candidate.messageId);
47669
+ if (!state_3) {
47670
+ pickLockRef.current = false;
47671
+ setIsPlaying(false);
47672
+ currentSentenceRef.current = null;
47673
+ return;
47674
+ }
47675
+ state_3.nextIndex = candidate.index + 1;
47676
+ rebuildQueue();
47677
+ var chunkQueue = chunkQueuesRef.current.get(candidate.messageId);
47678
+ var activeChunk = chunkQueue && chunkQueue.length > 0 ? chunkQueue[0] : null;
47679
+ currentChunkRef.current = activeChunk;
47680
+ var searchParams = new URLSearchParams(_objectSpread47({
47681
+ input: candidate.sentence
47682
+ }, superinterfaceContext.variables));
47683
+ audioPlayer.load("".concat(superinterfaceContext.baseUrl, "/audio-runtimes/tts?").concat(searchParams), {
47684
+ format: "mp3",
47685
+ autoplay: isAudioPlayed,
47686
+ html5: isHtmlAudioSupported,
47687
+ onplay: function() {
47688
+ if (activeChunk && !activeChunk.started) {
47689
+ activeChunk.started = true;
47690
+ activeChunk.onPlay();
47691
+ }
47692
+ },
47693
+ onstop: function() {
47694
+ var stateToUpdate = messageStatesRef.current.get(candidate.messageId);
47695
+ if (stateToUpdate) {
47696
+ stateToUpdate.stopped = true;
47697
+ }
47698
+ finishChunk(candidate.messageId, "stop");
47699
+ setIsPlaying(false);
47700
+ currentSentenceRef.current = null;
47701
+ currentChunkRef.current = null;
47702
+ pickLockRef.current = false;
47703
+ rebuildQueue();
47704
+ checkForCompletion();
47705
+ },
47706
+ onload: function() {
47707
+ var current = currentSentenceRef.current;
47708
+ if (!current) return;
47709
+ var owner = messageStatesRef.current.get(current.messageId);
47710
+ if (!owner) return;
47711
+ var nextSentence = owner.sentences[owner.nextIndex];
47712
+ if (!nextSentence) return;
47713
+ var allowQueued = owner.status !== "in_progress" || isOptimistic({
47714
+ id: owner.id
47715
+ }) || fullSentenceRegex.test(nextSentence);
47716
+ if (!allowQueued) return;
47717
+ var nextSearchParams = new URLSearchParams(_objectSpread47({
47718
+ input: nextSentence
47719
+ }, superinterfaceContext.variables));
47720
+ nextAudioPlayer.load("".concat(superinterfaceContext.baseUrl, "/audio-runtimes/tts?").concat(nextSearchParams), {
47721
+ format: "mp3",
47722
+ autoplay: false,
47723
+ html5: isHtmlAudioSupported
47724
+ });
47725
+ },
47726
+ onend: function() {
47727
+ finishChunk(candidate.messageId, "end");
47728
+ setIsPlaying(false);
47729
+ currentSentenceRef.current = null;
47730
+ currentChunkRef.current = null;
47731
+ pickLockRef.current = false;
47732
+ rebuildQueue();
47733
+ checkForCompletion();
47734
+ startNextSegment();
47735
+ }
47736
+ });
47737
+ }, [
47738
+ enabled,
47739
+ isPlaying,
47740
+ audioPlayer,
47741
+ fullSentenceRegex,
47742
+ superinterfaceContext,
47743
+ isAudioPlayed,
47744
+ rebuildQueue,
47745
+ finishChunk,
47746
+ checkForCompletion,
47747
+ getOrder
47748
+ ]);
47749
+ var play = (0, import_react67.useCallback)(function(_ref2) {
47750
+ var _existing$playableCou, _ref3, _existing$fallbackOrd, _ref4, _messageOrderRef$curr, _existing$stopped, _ref5;
47751
+ var input2 = _ref2.input, message = _ref2.message, onPlay = _ref2.onPlay, onStop = _ref2.onStop, chunkOnEnd = _ref2.onEnd;
47752
+ if (!enabled) {
47753
+ chunkOnEnd();
47754
+ return;
47755
+ }
47756
+ var fullInput = input({
47757
+ message: message
47758
+ });
47759
+ if (fullInput == null) {
47760
+ chunkOnEnd();
47761
+ return;
47762
+ }
47763
+ var id = String(message.id);
47764
+ var now = getPerformanceNow();
47765
+ var segCache_0 = segCacheRef.current;
47766
+ var prevSeg = segCache_0.get(id);
47767
+ var nextSeg = getIncrementalSentences(prevSeg, fullInput, now);
47768
+ segCache_0.set(id, nextSeg);
47769
+ evictSegCache();
47770
+ var existing = messageStatesRef.current.get(id);
47771
+ var prevPlayable = (_existing$playableCou = existing === null || existing === void 0 ? void 0 : existing.playableCount) !== null && _existing$playableCou !== void 0 ? _existing$playableCou : 0;
47772
+ var sentences = nextSeg.sentences;
47773
+ var playableCount = sentences.length;
47774
+ if (!isOptimistic({
47775
+ id: id
47776
+ }) && message.status === "in_progress" && sentences.length > 0) {
47777
+ var last3 = sentences[sentences.length - 1];
47778
+ if (last3 && !fullSentenceRegex.test(last3)) {
47779
+ playableCount -= 1;
47780
+ }
47781
+ }
47782
+ if (playableCount < 0) playableCount = 0;
47783
+ var fallbackOrder = (_ref3 = (_existing$fallbackOrd = existing === null || existing === void 0 ? void 0 : existing.fallbackOrder) !== null && _existing$fallbackOrd !== void 0 ? _existing$fallbackOrd : message.created_at) !== null && _ref3 !== void 0 ? _ref3 : Date.now();
47784
+ var order2 = (_ref4 = (_messageOrderRef$curr = messageOrderRef.current.get(id)) !== null && _messageOrderRef$curr !== void 0 ? _messageOrderRef$curr : existing === null || existing === void 0 ? void 0 : existing.order) !== null && _ref4 !== void 0 ? _ref4 : fallbackOrder;
47785
+ var nextIndex = existing ? Math.min(existing.nextIndex, sentences.length) : 0;
47786
+ var stopped = (_existing$stopped = existing === null || existing === void 0 ? void 0 : existing.stopped) !== null && _existing$stopped !== void 0 ? _existing$stopped : false;
47787
+ var nextState = {
47788
+ id: id,
47789
+ status: (_ref5 = message.status) !== null && _ref5 !== void 0 ? _ref5 : "completed",
47790
+ sentences: sentences,
47791
+ nextIndex: nextIndex,
47792
+ playableCount: playableCount,
47793
+ stopped: stopped,
47794
+ order: order2,
47795
+ fallbackOrder: fallbackOrder
47796
+ };
47797
+ messageStatesRef.current.set(id, nextState);
47798
+ rebuildQueue();
47799
+ var newSegments = Math.max(playableCount - prevPlayable, 0);
47800
+ if (newSegments > 0) {
47801
+ var _chunkQueuesRef$curre;
47802
+ var queue_0 = (_chunkQueuesRef$curre = chunkQueuesRef.current.get(id)) !== null && _chunkQueuesRef$curre !== void 0 ? _chunkQueuesRef$curre : [];
47803
+ queue_0.push({
47804
+ remaining: newSegments,
47805
+ onPlay: onPlay,
47806
+ onStop: onStop,
47807
+ onEnd: chunkOnEnd,
47808
+ started: false,
47809
+ stopped: false
47810
+ });
47811
+ chunkQueuesRef.current.set(id, queue_0);
47812
+ startNextSegment();
47813
+ } else {
47814
+ chunkOnEnd();
47815
+ }
47816
+ }, [
47817
+ enabled,
47818
+ fullSentenceRegex,
47819
+ rebuildQueue,
47820
+ startNextSegment,
47821
+ evictSegCache
47822
+ ]);
47823
+ var syncMessages = (0, import_react67.useCallback)(function(messagesAsc) {
47824
+ messageOrderRef.current.clear();
47825
+ for(var i_4 = 0; i_4 < messagesAsc.length; i_4++){
47826
+ var _ref6;
47827
+ messageOrderRef.current.set(String(messagesAsc[i_4].id), i_4);
47828
+ var state_4 = messageStatesRef.current.get(String(messagesAsc[i_4].id));
47829
+ if (state_4) state_4.status = (_ref6 = messagesAsc[i_4].status) !== null && _ref6 !== void 0 ? _ref6 : "completed";
47830
+ }
47831
+ if (!enabled) return;
47832
+ rebuildQueue();
47833
+ }, [
47834
+ enabled,
47835
+ rebuildQueue
47836
+ ]);
47837
+ (0, import_react67.useEffect)(function() {
47838
+ if (!enabled) return;
47839
+ if (isHtmlAudioSupported) {
47840
+ var _Howler$_howls;
47841
+ 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;
47842
+ if (node) node.crossOrigin = "anonymous";
47843
+ }
47844
+ }, [
47845
+ enabled,
47846
+ audioPlayer
47847
+ ]);
47848
+ var _$_ref2 = _sliced_to_array((0, import_react67.useState)(null), 2), audioEngine = _$_ref2[0], setAudioEngine = _$_ref2[1];
47849
+ var isAudioEngineInited = (0, import_react67.useRef)(false);
47850
+ (0, import_react67.useEffect)(function() {
47851
+ if (!enabled) return;
47852
+ if (!audioPlayer.playing) return;
47853
+ if (isAudioEngineInited.current) return;
47854
+ isAudioEngineInited.current = true;
47855
+ if (isHtmlAudioSupported) {
47856
+ var _Howler$_howls2;
47857
+ var AudioCtx = window.AudioContext || window.webkitAudioContext;
47858
+ var audioContext = new AudioCtx();
47859
+ 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;
47860
+ if (node_0) {
47861
+ setAudioEngine({
47862
+ // @ts-ignore-next-line
47863
+ source: audioContext.createMediaElementSource(node_0),
47864
+ audioContext: audioContext
47865
+ });
47866
+ }
47867
+ } else {
47868
+ setAudioEngine({
47869
+ source: import_howler.Howler.masterGain,
47870
+ audioContext: import_howler.Howler.ctx
47871
+ });
47872
+ }
47873
+ }, [
47874
+ enabled,
47875
+ audioPlayer
47876
+ ]);
47877
+ var visualizationAnalyser = (0, import_react67.useMemo)(function() {
47878
+ if (!enabled) return null;
47879
+ if (!audioEngine) return null;
47880
+ var analyser = audioEngine.audioContext.createAnalyser();
47881
+ audioEngine.source.connect(audioEngine.audioContext.destination);
47882
+ audioEngine.source.connect(analyser);
47883
+ return analyser;
47884
+ }, [
47885
+ enabled,
47886
+ audioEngine
47887
+ ]);
47888
+ var isPending = (0, import_react67.useMemo)(function() {
47889
+ if (!enabled) return false;
47890
+ return isPlaying || Array.from(messageStatesRef.current.values()).some(function(state_5) {
47891
+ return !state_5.stopped && (state_5.status === "in_progress" || state_5.nextIndex < state_5.sentences.length);
47892
+ });
47893
+ }, [
47894
+ enabled,
47895
+ isPlaying
47896
+ ]);
47897
+ return {
47898
+ play: play,
47899
+ syncMessages: syncMessages,
47900
+ isPending: isPending,
47901
+ visualizationAnalyser: visualizationAnalyser,
47902
+ controls: audioPlayer
47903
+ };
47445
47904
  };
47905
+ // src/hooks/audioThreads/useMessageAudio/index.ts
47906
+ function ownKeys48(e, r) {
47907
+ var t = Object.keys(e);
47908
+ if (Object.getOwnPropertySymbols) {
47909
+ var o = Object.getOwnPropertySymbols(e);
47910
+ r && (o = o.filter(function(r2) {
47911
+ return Object.getOwnPropertyDescriptor(e, r2).enumerable;
47912
+ })), t.push.apply(t, o);
47913
+ }
47914
+ return t;
47915
+ }
47916
+ function _objectSpread48(e) {
47917
+ for(var r = 1; r < arguments.length; r++){
47918
+ var t = null != arguments[r] ? arguments[r] : {};
47919
+ r % 2 ? ownKeys48(Object(t), true).forEach(function(r2) {
47920
+ _defineProperty48(e, r2, t[r2]);
47921
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys48(Object(t)).forEach(function(r2) {
47922
+ Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
47923
+ });
47924
+ }
47925
+ return e;
47926
+ }
47927
+ function _defineProperty48(e, r, t) {
47928
+ return (r = _toPropertyKey48(r)) in e ? Object.defineProperty(e, r, {
47929
+ value: t,
47930
+ enumerable: true,
47931
+ configurable: true,
47932
+ writable: true
47933
+ }) : e[r] = t, e;
47934
+ }
47935
+ function _toPropertyKey48(t) {
47936
+ var i = _toPrimitive48(t, "string");
47937
+ return "symbol" == (typeof i === "undefined" ? "undefined" : _type_of(i)) ? i : i + "";
47938
+ }
47939
+ function _toPrimitive48(t, r) {
47940
+ if ("object" != (typeof t === "undefined" ? "undefined" : _type_of(t)) || !t) return t;
47941
+ var e = t[Symbol.toPrimitive];
47942
+ if (void 0 !== e) {
47943
+ var i = e.call(t, r || "default");
47944
+ if ("object" != (typeof i === "undefined" ? "undefined" : _type_of(i))) return i;
47945
+ throw new TypeError("@@toPrimitive must return a primitive value.");
47946
+ }
47947
+ return ("string" === r ? String : Number)(t);
47948
+ }
47446
47949
  var useMessageAudio = function(t0) {
47447
- var $ = (0, import_react_compiler_runtime88.c)(41);
47448
- var _onEnd = t0.onEnd, passedPlay = t0.play, t1 = t0.fullSentenceRegex;
47950
+ var $ = (0, import_react_compiler_runtime88.c)(42);
47951
+ var onEnd = t0.onEnd, passedPlay = t0.play, t1 = t0.fullSentenceRegex;
47449
47952
  var t2;
47450
47953
  if ($[0] !== t1) {
47451
47954
  t2 = t1 === void 0 ? /[\.?!]$/ : t1;
@@ -47455,193 +47958,168 @@ var useMessageAudio = function(t0) {
47455
47958
  t2 = $[1];
47456
47959
  }
47457
47960
  var fullSentenceRegex = t2;
47458
- var _ref = _sliced_to_array((0, import_react67.useState)(false), 2), isAudioPlayed = _ref[0], setIsAudioPlayed = _ref[1];
47459
- var audioPlayer = (0, import_react_use_audio_player2.useAudioPlayer)();
47460
- var nextAudioPlayer = (0, import_react_use_audio_player2.useAudioPlayer)();
47461
47961
  var superinterfaceContext = useSuperinterfaceContext();
47462
- var _ref1 = _sliced_to_array((0, import_react67.useState)(false), 2), isPlaying = _ref1[0], setIsPlaying = _ref1[1];
47962
+ var messagesProps = useMessages();
47463
47963
  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
47964
  var t4;
47472
- if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
47473
- t4 = [];
47965
+ if ($[2] !== messagesProps.messages) {
47966
+ var assistantsDesc = messagesProps.messages.filter(_temp9);
47967
+ t4 = assistantsDesc.slice().reverse();
47968
+ $[2] = messagesProps.messages;
47474
47969
  $[3] = t4;
47475
47970
  } else {
47476
47971
  t4 = $[3];
47477
47972
  }
47478
- var audioQueueRef = (0, import_react67.useRef)(t4);
47973
+ t3 = t4;
47974
+ var assistantsAsc = t3;
47975
+ var _ref = _sliced_to_array((0, import_react68.useState)(false), 2), isAudioPlayed = _ref[0], setIsAudioPlayed = _ref[1];
47976
+ var _ref1 = _sliced_to_array((0, import_react68.useState)(0), 2), activeChunks = _ref1[0], setActiveChunks = _ref1[1];
47977
+ var activeChunksRef = (0, import_react68.useRef)(0);
47479
47978
  var t5;
47480
47979
  var t6;
47481
- if ($[4] !== audioQueue) {
47980
+ if ($[4] !== activeChunks) {
47482
47981
  t5 = function() {
47483
- audioQueueRef.current = audioQueue;
47982
+ activeChunksRef.current = activeChunks;
47484
47983
  };
47485
47984
  t6 = [
47486
- audioQueue
47985
+ activeChunks
47487
47986
  ];
47488
- $[4] = audioQueue;
47987
+ $[4] = activeChunks;
47489
47988
  $[5] = t5;
47490
47989
  $[6] = t6;
47491
47990
  } else {
47492
47991
  t5 = $[5];
47493
47992
  t6 = $[6];
47494
47993
  }
47495
- (0, import_react67.useEffect)(t5, t6);
47496
- var currentSentenceRef = (0, import_react67.useRef)(null);
47497
- var messagesProps = useMessages();
47498
- var t7;
47994
+ (0, import_react68.useEffect)(t5, t6);
47995
+ var onEndPendingRef = (0, import_react68.useRef)(false);
47996
+ var t7 = !passedPlay;
47499
47997
  var t8;
47500
- if ($[7] !== messagesProps.messages) {
47501
- t7 = function() {
47502
- var assistants = messagesProps.messages.filter(_temp9);
47503
- setAudioQueue(function(prev) {
47504
- var prevById = new Map(prev.map(_temp24));
47505
- var next = [];
47506
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
47507
- try {
47508
- for(var _iterator = assistants[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
47509
- var m_0 = _step.value;
47510
- var _existing$nextIndex, _existing$stopped;
47511
- var inp = input({
47512
- message: m_0
47513
- });
47514
- if (inp == null) {
47515
- continue;
47516
- }
47517
- var sentences = segment(inp);
47518
- var existing = prevById.get(m_0.id);
47519
- next.push({
47520
- id: m_0.id,
47521
- status: m_0.status,
47522
- sentences: sentences,
47523
- nextIndex: Math.min((_existing$nextIndex = existing === null || existing === void 0 ? void 0 : existing.nextIndex) !== null && _existing$nextIndex !== void 0 ? _existing$nextIndex : 0, sentences.length),
47524
- stopped: (_existing$stopped = existing === null || existing === void 0 ? void 0 : existing.stopped) !== null && _existing$stopped !== void 0 ? _existing$stopped : false
47525
- });
47526
- }
47527
- } catch (err) {
47528
- _didIteratorError = true;
47529
- _iteratorError = err;
47530
- } finally{
47531
- try {
47532
- if (!_iteratorNormalCompletion && _iterator.return != null) {
47533
- _iterator.return();
47534
- }
47535
- } finally{
47536
- if (_didIteratorError) {
47537
- throw _iteratorError;
47538
- }
47539
- }
47540
- }
47541
- return next;
47542
- });
47998
+ if ($[7] !== fullSentenceRegex || $[8] !== isAudioPlayed || $[9] !== onEnd || $[10] !== superinterfaceContext || $[11] !== t7) {
47999
+ t8 = {
48000
+ enabled: t7,
48001
+ fullSentenceRegex: fullSentenceRegex,
48002
+ onEnd: onEnd,
48003
+ superinterfaceContext: superinterfaceContext,
48004
+ isAudioPlayed: isAudioPlayed
47543
48005
  };
47544
- t8 = [
47545
- messagesProps.messages
47546
- ];
47547
- $[7] = messagesProps.messages;
47548
- $[8] = t7;
47549
- $[9] = t8;
48006
+ $[7] = fullSentenceRegex;
48007
+ $[8] = isAudioPlayed;
48008
+ $[9] = onEnd;
48009
+ $[10] = superinterfaceContext;
48010
+ $[11] = t7;
48011
+ $[12] = t8;
47550
48012
  } else {
47551
- t7 = $[8];
47552
- t8 = $[9];
48013
+ t8 = $[12];
47553
48014
  }
47554
- (0, import_react67.useEffect)(t7, t8);
48015
+ var defaultPlayback = useDefaultPlay(t8);
48016
+ var defaultPlayFn = defaultPlayback.play, syncMessages = defaultPlayback.syncMessages, defaultIsPending = defaultPlayback.isPending, defaultVisualizer = defaultPlayback.visualizationAnalyser, controls = defaultPlayback.controls;
47555
48017
  var t9;
47556
- if ($[10] !== audioPlayer || $[11] !== fullSentenceRegex || $[12] !== isAudioPlayed || $[13] !== nextAudioPlayer || $[14] !== superinterfaceContext) {
47557
- t9 = function(t102) {
47558
- var input2 = t102.input, onPlay = t102.onPlay, onStop = t102.onStop, onEnd_0 = t102.onEnd;
47559
- var searchParams = new URLSearchParams(_objectSpread47({
47560
- input: input2
47561
- }, superinterfaceContext.variables));
47562
- audioPlayer.load("".concat(superinterfaceContext.baseUrl, "/audio-runtimes/tts?").concat(searchParams), {
47563
- format: "mp3",
47564
- autoplay: isAudioPlayed,
47565
- html5: isHtmlAudioSupported,
47566
- onplay: onPlay,
47567
- onstop: onStop,
47568
- onload: function() {
47569
- var current = currentSentenceRef.current;
47570
- if (!current) {
47571
- return;
47572
- }
47573
- var msg = audioQueueRef.current.find(function(m_1) {
47574
- return m_1.id === current.messageId;
47575
- });
47576
- if (!msg) {
47577
- return;
47578
- }
47579
- var nextSentence = msg.sentences[msg.nextIndex];
47580
- if (!nextSentence) {
47581
- return;
47582
- }
47583
- if (!fullSentenceRegex.test(nextSentence)) {
47584
- return;
47585
- }
47586
- var nextSearchParams = new URLSearchParams(_objectSpread47({
47587
- input: nextSentence
47588
- }, superinterfaceContext.variables));
47589
- nextAudioPlayer.load("".concat(superinterfaceContext.baseUrl, "/audio-runtimes/tts?").concat(nextSearchParams), {
47590
- format: "mp3",
47591
- autoplay: false,
47592
- html5: isHtmlAudioSupported
47593
- });
48018
+ t9 = passedPlay || defaultPlayFn;
48019
+ var playImpl = t9;
48020
+ var t10;
48021
+ if ($[13] !== passedPlay) {
48022
+ t10 = function() {
48023
+ if (passedPlay) {
48024
+ onEndPendingRef.current = true;
48025
+ setActiveChunks(_temp24);
48026
+ }
48027
+ var finished;
48028
+ finished = false;
48029
+ var finish = function() {
48030
+ if (finished) {
48031
+ return;
48032
+ }
48033
+ finished = true;
48034
+ if (passedPlay) {
48035
+ setActiveChunks(_temp32);
48036
+ }
48037
+ };
48038
+ return {
48039
+ onPlay: function() {
48040
+ return setIsAudioPlayed(true);
47594
48041
  },
47595
- onend: onEnd_0
47596
- });
48042
+ onStop: function() {
48043
+ return finish();
48044
+ },
48045
+ onEnd: function() {
48046
+ return finish();
48047
+ }
48048
+ };
47597
48049
  };
47598
- $[10] = audioPlayer;
47599
- $[11] = fullSentenceRegex;
47600
- $[12] = isAudioPlayed;
47601
- $[13] = nextAudioPlayer;
47602
- $[14] = superinterfaceContext;
47603
- $[15] = t9;
48050
+ $[13] = passedPlay;
48051
+ $[14] = t10;
47604
48052
  } else {
47605
- t9 = $[15];
48053
+ t10 = $[14];
47606
48054
  }
47607
- var defaultPlay = t9;
47608
- var t10;
47609
- t10 = passedPlay || defaultPlay;
47610
- var play = t10;
48055
+ var createChunkCallbacks = t10;
47611
48056
  var t11;
48057
+ if ($[15] === Symbol.for("react.memo_cache_sentinel")) {
48058
+ t11 = /* @__PURE__ */ new Map();
48059
+ $[15] = t11;
48060
+ } else {
48061
+ t11 = $[15];
48062
+ }
48063
+ var processedRef = (0, import_react68.useRef)(t11);
47612
48064
  var t12;
47613
- if ($[16] !== audioPlayer.playing || $[17] !== audioQueue || $[18] !== fullSentenceRegex || $[19] !== isPlaying || $[20] !== _onEnd || $[21] !== play) {
47614
- t11 = function() {
47615
- if (isPlaying) {
47616
- return;
47617
- }
47618
- if (audioPlayer.playing) {
47619
- return;
48065
+ var t13;
48066
+ if ($[16] !== assistantsAsc || $[17] !== createChunkCallbacks || $[18] !== passedPlay || $[19] !== playImpl || $[20] !== syncMessages) {
48067
+ t12 = function() {
48068
+ var seenIds = /* @__PURE__ */ new Set();
48069
+ for(var idx = 0; idx < assistantsAsc.length; idx++){
48070
+ var _prev_1$text;
48071
+ var message_0 = assistantsAsc[idx];
48072
+ var id = String(message_0.id);
48073
+ var input2 = input({
48074
+ message: message_0
48075
+ });
48076
+ if (input2 == null) {
48077
+ continue;
48078
+ }
48079
+ var prev_1 = processedRef.current.get(id);
48080
+ var prevText = (_prev_1$text = prev_1 === null || prev_1 === void 0 ? void 0 : prev_1.text) !== null && _prev_1$text !== void 0 ? _prev_1$text : "";
48081
+ var prevStatus = prev_1 === null || prev_1 === void 0 ? void 0 : prev_1.status;
48082
+ var hasSamePrefix = prevText.length > 0 && input2.startsWith(prevText) && prevText !== input2;
48083
+ var delta = void 0;
48084
+ if (hasSamePrefix) {
48085
+ delta = input2.slice(prevText.length);
48086
+ } else {
48087
+ if (input2 === prevText) {
48088
+ delta = "";
48089
+ } else {
48090
+ delta = input2;
48091
+ }
48092
+ }
48093
+ var statusChanged = prevStatus !== message_0.status;
48094
+ if (delta.length > 0 || statusChanged) {
48095
+ var callbacks = createChunkCallbacks();
48096
+ ;
48097
+ try {
48098
+ playImpl({
48099
+ input: delta,
48100
+ message: message_0,
48101
+ onPlay: callbacks.onPlay,
48102
+ onStop: callbacks.onStop,
48103
+ onEnd: callbacks.onEnd
48104
+ });
48105
+ } catch (t142) {
48106
+ var error = t142;
48107
+ callbacks.onEnd();
48108
+ throw error;
48109
+ }
48110
+ }
48111
+ processedRef.current.set(id, {
48112
+ text: input2,
48113
+ status: message_0.status
48114
+ });
48115
+ seenIds.add(id);
47620
48116
  }
47621
- var candidate;
47622
- candidate = null;
47623
48117
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
47624
48118
  try {
47625
- for(var _iterator = audioQueue[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
47626
- var msg_0 = _step.value;
47627
- if (msg_0.stopped) {
47628
- continue;
47629
- }
47630
- var sentence = msg_0.sentences[msg_0.nextIndex];
47631
- if (!sentence) {
47632
- continue;
47633
- }
47634
- var isFull = isOptimistic({
47635
- id: msg_0.id
47636
- }) || msg_0.status !== "in_progress" || fullSentenceRegex.test(sentence);
47637
- if (isFull) {
47638
- candidate = {
47639
- messageId: msg_0.id,
47640
- sentence: sentence,
47641
- index: msg_0.nextIndex,
47642
- ownerStatus: msg_0.status
47643
- };
47644
- break;
48119
+ for(var _iterator = Array.from(processedRef.current.keys())[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
48120
+ var id_0 = _step.value;
48121
+ if (!seenIds.has(id_0)) {
48122
+ processedRef.current.delete(id_0);
47645
48123
  }
47646
48124
  }
47647
48125
  } catch (err) {
@@ -47658,198 +48136,116 @@ var useMessageAudio = function(t0) {
47658
48136
  }
47659
48137
  }
47660
48138
  }
47661
- if (!candidate) {
47662
- return;
48139
+ if (!passedPlay) {
48140
+ syncMessages(assistantsAsc);
47663
48141
  }
47664
- setIsPlaying(true);
47665
- currentSentenceRef.current = {
47666
- messageId: candidate.messageId,
47667
- index: candidate.index
47668
- };
47669
- setAudioQueue(function(prev_0) {
47670
- return prev_0.map(function(m_2) {
47671
- return m_2.id === candidate.messageId ? _objectSpread47(_objectSpread47({}, m_2), {}, {
47672
- nextIndex: m_2.nextIndex + 1
47673
- }) : m_2;
47674
- });
47675
- });
47676
- play({
47677
- input: candidate.sentence,
47678
- onPlay: function() {
47679
- return setIsAudioPlayed(true);
47680
- },
47681
- onStop: function() {
47682
- setAudioQueue(function(prev_1) {
47683
- return prev_1.map(function(m_3) {
47684
- return m_3.id === candidate.messageId ? _objectSpread47(_objectSpread47({}, m_3), {}, {
47685
- stopped: true
47686
- }) : m_3;
47687
- });
47688
- });
47689
- setIsPlaying(false);
47690
- currentSentenceRef.current = null;
47691
- },
47692
- onEnd: function() {
47693
- setIsPlaying(false);
47694
- currentSentenceRef.current = null;
47695
- var hasPending = audioQueueRef.current.some(_temp32);
47696
- if (!hasPending) {
47697
- _onEnd();
47698
- }
47699
- }
47700
- });
47701
48142
  };
47702
- t12 = [
47703
- isPlaying,
47704
- audioPlayer.playing,
47705
- audioQueue,
47706
- play,
47707
- fullSentenceRegex,
47708
- _onEnd
47709
- ];
47710
- $[16] = audioPlayer.playing;
47711
- $[17] = audioQueue;
47712
- $[18] = fullSentenceRegex;
47713
- $[19] = isPlaying;
47714
- $[20] = _onEnd;
47715
- $[21] = play;
47716
- $[22] = t11;
47717
- $[23] = t12;
47718
- } else {
47719
- t11 = $[22];
47720
- t12 = $[23];
47721
- }
47722
- (0, import_react67.useEffect)(t11, t12);
47723
- var t13;
47724
- if ($[24] !== audioPlayer) {
47725
48143
  t13 = [
47726
- audioPlayer
48144
+ assistantsAsc,
48145
+ playImpl,
48146
+ passedPlay,
48147
+ createChunkCallbacks,
48148
+ syncMessages
47727
48149
  ];
47728
- $[24] = audioPlayer;
47729
- $[25] = t13;
47730
- } else {
47731
- t13 = $[25];
47732
- }
47733
- (0, import_react67.useEffect)(_temp42, t13);
47734
- var _ref3 = _sliced_to_array((0, import_react67.useState)(null), 2), audioEngine = _ref3[0], setAudioEngine = _ref3[1];
47735
- var isAudioEngineInited = (0, import_react67.useRef)(false);
48150
+ $[16] = assistantsAsc;
48151
+ $[17] = createChunkCallbacks;
48152
+ $[18] = passedPlay;
48153
+ $[19] = playImpl;
48154
+ $[20] = syncMessages;
48155
+ $[21] = t12;
48156
+ $[22] = t13;
48157
+ } else {
48158
+ t12 = $[21];
48159
+ t13 = $[22];
48160
+ }
48161
+ (0, import_react68.useEffect)(t12, t13);
47736
48162
  var t14;
47737
- if ($[26] !== audioPlayer.playing) {
48163
+ if ($[23] !== assistantsAsc || $[24] !== onEnd || $[25] !== passedPlay) {
47738
48164
  t14 = function() {
47739
- if (!audioPlayer.playing) {
48165
+ if (!passedPlay) {
47740
48166
  return;
47741
48167
  }
47742
- if (isAudioEngineInited.current) {
48168
+ if (!onEndPendingRef.current) {
47743
48169
  return;
47744
48170
  }
47745
- isAudioEngineInited.current = true;
47746
- if (isHtmlAudioSupported) {
47747
- var audioContext = new AudioContext();
47748
- setAudioEngine({
47749
- source: audioContext.createMediaElementSource(import_howler.Howler._howls[0]._sounds[0]._node),
47750
- audioContext: audioContext
47751
- });
47752
- } else {
47753
- setAudioEngine({
47754
- source: import_howler.Howler.masterGain,
47755
- audioContext: import_howler.Howler.ctx
47756
- });
48171
+ if (activeChunksRef.current !== 0) {
48172
+ return;
48173
+ }
48174
+ var hasStreaming = assistantsAsc.some(_temp42);
48175
+ if (!hasStreaming) {
48176
+ onEnd();
48177
+ onEndPendingRef.current = false;
47757
48178
  }
47758
48179
  };
47759
- $[26] = audioPlayer.playing;
47760
- $[27] = t14;
48180
+ $[23] = assistantsAsc;
48181
+ $[24] = onEnd;
48182
+ $[25] = passedPlay;
48183
+ $[26] = t14;
47761
48184
  } else {
47762
- t14 = $[27];
48185
+ t14 = $[26];
47763
48186
  }
47764
48187
  var t15;
47765
- if ($[28] !== audioPlayer) {
48188
+ if ($[27] !== activeChunks || $[28] !== assistantsAsc || $[29] !== onEnd || $[30] !== passedPlay) {
47766
48189
  t15 = [
47767
- audioPlayer
48190
+ passedPlay,
48191
+ assistantsAsc,
48192
+ onEnd,
48193
+ activeChunks
47768
48194
  ];
47769
- $[28] = audioPlayer;
47770
- $[29] = t15;
48195
+ $[27] = activeChunks;
48196
+ $[28] = assistantsAsc;
48197
+ $[29] = onEnd;
48198
+ $[30] = passedPlay;
48199
+ $[31] = t15;
47771
48200
  } else {
47772
- t15 = $[29];
48201
+ t15 = $[31];
47773
48202
  }
47774
- (0, import_react67.useEffect)(t14, t15);
48203
+ (0, import_react68.useEffect)(t14, t15);
47775
48204
  var t16;
47776
- bb0: {
47777
- if (!audioEngine) {
47778
- t16 = null;
47779
- break bb0;
47780
- }
47781
- var analyser;
47782
- if ($[30] !== audioEngine.audioContext || $[31] !== audioEngine.source) {
47783
- analyser = audioEngine.audioContext.createAnalyser();
47784
- audioEngine.source.connect(audioEngine.audioContext.destination);
47785
- audioEngine.source.connect(analyser);
47786
- $[30] = audioEngine.audioContext;
47787
- $[31] = audioEngine.source;
47788
- $[32] = analyser;
47789
- } else {
47790
- analyser = $[32];
47791
- }
47792
- t16 = analyser;
47793
- }
47794
- var visualizationAnalyser = t16;
48205
+ if ($[32] !== activeChunks || $[33] !== assistantsAsc || $[34] !== defaultIsPending || $[35] !== passedPlay) {
48206
+ t16 = passedPlay ? activeChunks > 0 || assistantsAsc.some(_temp52) : defaultIsPending;
48207
+ $[32] = activeChunks;
48208
+ $[33] = assistantsAsc;
48209
+ $[34] = defaultIsPending;
48210
+ $[35] = passedPlay;
48211
+ $[36] = t16;
48212
+ } else {
48213
+ t16 = $[36];
48214
+ }
48215
+ var isPending = t16;
48216
+ var visualizationAnalyser = passedPlay ? null : defaultVisualizer;
47795
48217
  var t17;
47796
- var t18;
47797
- if ($[33] !== audioQueue || $[34] !== isPlaying) {
47798
- t18 = isPlaying || audioQueue.some(_temp52);
47799
- $[33] = audioQueue;
47800
- $[34] = isPlaying;
47801
- $[35] = t18;
47802
- } else {
47803
- t18 = $[35];
47804
- }
47805
- t17 = t18;
47806
- var isPending = t17;
47807
- var t19;
47808
- if ($[36] !== audioPlayer || $[37] !== isAudioPlayed || $[38] !== isPending || $[39] !== visualizationAnalyser) {
47809
- t19 = _objectSpread47(_objectSpread47({
48218
+ if ($[37] !== controls || $[38] !== isAudioPlayed || $[39] !== isPending || $[40] !== visualizationAnalyser) {
48219
+ t17 = _objectSpread48(_objectSpread48({
47810
48220
  isPending: isPending,
47811
48221
  isAudioPlayed: isAudioPlayed
47812
- }, audioPlayer), {}, {
48222
+ }, controls), {}, {
47813
48223
  visualizationAnalyser: visualizationAnalyser
47814
48224
  });
47815
- $[36] = audioPlayer;
47816
- $[37] = isAudioPlayed;
47817
- $[38] = isPending;
47818
- $[39] = visualizationAnalyser;
47819
- $[40] = t19;
48225
+ $[37] = controls;
48226
+ $[38] = isAudioPlayed;
48227
+ $[39] = isPending;
48228
+ $[40] = visualizationAnalyser;
48229
+ $[41] = t17;
47820
48230
  } else {
47821
- t19 = $[40];
48231
+ t17 = $[41];
47822
48232
  }
47823
- return t19;
48233
+ return t17;
47824
48234
  };
47825
- function _temp9(m) {
47826
- return m.role === "assistant";
48235
+ function _temp9(message) {
48236
+ return message.role === "assistant";
47827
48237
  }
47828
- function _temp24(p) {
47829
- return [
47830
- p.id,
47831
- p
47832
- ];
48238
+ function _temp24(prev) {
48239
+ return prev + 1;
47833
48240
  }
47834
- function _temp32(m_4) {
47835
- if (m_4.stopped) {
47836
- return false;
47837
- }
47838
- var hasMore = m_4.nextIndex < m_4.sentences.length;
47839
- var streaming = m_4.status === "in_progress";
47840
- return hasMore || streaming;
48241
+ function _temp32(prev_0) {
48242
+ return Math.max(prev_0 - 1, 0);
47841
48243
  }
47842
- function _temp42() {
47843
- if (isHtmlAudioSupported) {
47844
- var _Howler$_howls$;
47845
- 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)) {
47846
- return;
47847
- }
47848
- import_howler.Howler._howls[0]._sounds[0]._node.crossOrigin = "anonymous";
47849
- }
48244
+ function _temp42(message_1) {
48245
+ return message_1.status === "in_progress";
47850
48246
  }
47851
- function _temp52(m_5) {
47852
- return !m_5.stopped && (m_5.nextIndex < m_5.sentences.length || m_5.status === "in_progress");
48247
+ function _temp52(message_2) {
48248
+ return message_2.status === "in_progress";
47853
48249
  }
47854
48250
  // src/hooks/audioRuntimes/useTtsAudioRuntime/index.ts
47855
48251
  var import_react_query10 = require("@tanstack/react-query");
@@ -47864,6 +48260,52 @@ var blobToData = function(blob) {
47864
48260
  });
47865
48261
  };
47866
48262
  // src/hooks/audioRuntimes/useTtsAudioRuntime/index.ts
48263
+ var _excluded5 = [
48264
+ "onEnd"
48265
+ ];
48266
+ function ownKeys49(e, r) {
48267
+ var t = Object.keys(e);
48268
+ if (Object.getOwnPropertySymbols) {
48269
+ var o = Object.getOwnPropertySymbols(e);
48270
+ r && (o = o.filter(function(r2) {
48271
+ return Object.getOwnPropertyDescriptor(e, r2).enumerable;
48272
+ })), t.push.apply(t, o);
48273
+ }
48274
+ return t;
48275
+ }
48276
+ function _objectSpread49(e) {
48277
+ for(var r = 1; r < arguments.length; r++){
48278
+ var t = null != arguments[r] ? arguments[r] : {};
48279
+ r % 2 ? ownKeys49(Object(t), true).forEach(function(r2) {
48280
+ _defineProperty49(e, r2, t[r2]);
48281
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys49(Object(t)).forEach(function(r2) {
48282
+ Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
48283
+ });
48284
+ }
48285
+ return e;
48286
+ }
48287
+ function _defineProperty49(e, r, t) {
48288
+ return (r = _toPropertyKey49(r)) in e ? Object.defineProperty(e, r, {
48289
+ value: t,
48290
+ enumerable: true,
48291
+ configurable: true,
48292
+ writable: true
48293
+ }) : e[r] = t, e;
48294
+ }
48295
+ function _toPropertyKey49(t) {
48296
+ var i = _toPrimitive49(t, "string");
48297
+ return "symbol" == (typeof i === "undefined" ? "undefined" : _type_of(i)) ? i : i + "";
48298
+ }
48299
+ function _toPrimitive49(t, r) {
48300
+ if ("object" != (typeof t === "undefined" ? "undefined" : _type_of(t)) || !t) return t;
48301
+ var e = t[Symbol.toPrimitive];
48302
+ if (void 0 !== e) {
48303
+ var i = e.call(t, r || "default");
48304
+ if ("object" != (typeof i === "undefined" ? "undefined" : _type_of(i))) return i;
48305
+ throw new TypeError("@@toPrimitive must return a primitive value.");
48306
+ }
48307
+ return ("string" === r ? String : Number)(t);
48308
+ }
47867
48309
  function asyncGeneratorStep11(n, t, e, r, o, a, c) {
47868
48310
  try {
47869
48311
  var i = n[a](c), u = i.value;
@@ -47887,20 +48329,52 @@ function _asyncToGenerator11(n) {
47887
48329
  });
47888
48330
  };
47889
48331
  }
48332
+ function _objectWithoutProperties5(e, t) {
48333
+ if (null == e) return {};
48334
+ var o, r, i = _objectWithoutPropertiesLoose5(e, t);
48335
+ if (Object.getOwnPropertySymbols) {
48336
+ var n = Object.getOwnPropertySymbols(e);
48337
+ for(r = 0; r < n.length; r++)o = n[r], -1 === t.indexOf(o) && ({}).propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
48338
+ }
48339
+ return i;
48340
+ }
48341
+ function _objectWithoutPropertiesLoose5(r, e) {
48342
+ if (null == r) return {};
48343
+ var t = {};
48344
+ for(var n in r)if (({}).hasOwnProperty.call(r, n)) {
48345
+ if (-1 !== e.indexOf(n)) continue;
48346
+ t[n] = r[n];
48347
+ }
48348
+ return t;
48349
+ }
47890
48350
  var useTtsAudioRuntime = function(t0) {
47891
- var $ = (0, import_react_compiler_runtime89.c)(30);
47892
- var play = t0.play, passedOnEnd = t0.onEnd;
48351
+ var $ = (0, import_react_compiler_runtime89.c)(33);
48352
+ var overrides;
48353
+ var passedOnEnd;
48354
+ if ($[0] !== t0) {
48355
+ var _t = t0;
48356
+ var ref;
48357
+ ref = _t, passedOnEnd = ref.onEnd, ref;
48358
+ overrides = _objectWithoutProperties5(_t, _excluded5);
48359
+ _t;
48360
+ $[0] = t0;
48361
+ $[1] = overrides;
48362
+ $[2] = passedOnEnd;
48363
+ } else {
48364
+ overrides = $[1];
48365
+ passedOnEnd = $[2];
48366
+ }
47893
48367
  var addToast = useToasts().addToast;
47894
48368
  var queryClient = (0, import_react_query10.useQueryClient)();
47895
48369
  var threadContext = useSuperinterfaceContext();
47896
48370
  var t1;
47897
- if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
48371
+ if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
47898
48372
  t1 = {
47899
48373
  name: "microphone"
47900
48374
  };
47901
- $[0] = t1;
48375
+ $[3] = t1;
47902
48376
  } else {
47903
- t1 = $[0];
48377
+ t1 = $[3];
47904
48378
  }
47905
48379
  var microphonePermission = usePermission(t1);
47906
48380
  var createMessageProps = useCreateMessage({
@@ -47914,7 +48388,7 @@ var useTtsAudioRuntime = function(t0) {
47914
48388
  }
47915
48389
  });
47916
48390
  var t2;
47917
- if ($[1] !== createMessageProps) {
48391
+ if ($[4] !== createMessageProps) {
47918
48392
  t2 = {
47919
48393
  isStopOnSilence: true,
47920
48394
  onStart: _temp10,
@@ -47948,10 +48422,10 @@ var useTtsAudioRuntime = function(t0) {
47948
48422
  return onStop;
47949
48423
  }()
47950
48424
  };
47951
- $[1] = createMessageProps;
47952
- $[2] = t2;
48425
+ $[4] = createMessageProps;
48426
+ $[5] = t2;
47953
48427
  } else {
47954
- t2 = $[2];
48428
+ t2 = $[5];
47955
48429
  }
47956
48430
  var recorderProps = useRecorder(t2);
47957
48431
  recorderProps;
@@ -47961,39 +48435,38 @@ var useTtsAudioRuntime = function(t0) {
47961
48435
  t3 = passedOnEnd;
47962
48436
  break bb0;
47963
48437
  }
47964
- var _t;
47965
- if ($[3] !== microphonePermission || $[4] !== recorderProps) {
47966
- _t = function() {
48438
+ var _t2;
48439
+ if ($[6] !== microphonePermission || $[7] !== recorderProps) {
48440
+ _t2 = function() {
47967
48441
  if (microphonePermission === "granted") {
47968
48442
  recorderProps.start();
47969
48443
  }
47970
48444
  };
47971
- $[3] = microphonePermission;
47972
- $[4] = recorderProps;
47973
- $[5] = _t;
48445
+ $[6] = microphonePermission;
48446
+ $[7] = recorderProps;
48447
+ $[8] = _t2;
47974
48448
  } else {
47975
- _t = $[5];
48449
+ _t2 = $[8];
47976
48450
  }
47977
- t3 = _t;
48451
+ t3 = _t2;
47978
48452
  }
47979
48453
  var onEnd = t3;
47980
48454
  var t4;
47981
- if ($[6] !== onEnd || $[7] !== play) {
47982
- t4 = {
47983
- play: play,
48455
+ if ($[9] !== onEnd || $[10] !== overrides) {
48456
+ t4 = _objectSpread49({
47984
48457
  onEnd: onEnd
47985
- };
47986
- $[6] = onEnd;
47987
- $[7] = play;
47988
- $[8] = t4;
48458
+ }, overrides);
48459
+ $[9] = onEnd;
48460
+ $[10] = overrides;
48461
+ $[11] = t4;
47989
48462
  } else {
47990
- t4 = $[8];
48463
+ t4 = $[11];
47991
48464
  }
47992
48465
  var messageAudioProps = useMessageAudio(t4);
47993
48466
  recorderProps;
47994
48467
  var t5;
47995
48468
  var t6;
47996
- if ($[9] !== createMessageProps.isPending || $[10] !== recorderProps.pause || $[11] !== recorderProps.resume || $[12] !== recorderProps.start || $[13] !== recorderProps.status || $[14] !== recorderProps.stop || $[15] !== recorderProps.visualizationAnalyser) {
48469
+ if ($[12] !== createMessageProps.isPending || $[13] !== recorderProps.pause || $[14] !== recorderProps.resume || $[15] !== recorderProps.start || $[16] !== recorderProps.status || $[17] !== recorderProps.stop || $[18] !== recorderProps.visualizationAnalyser) {
47997
48470
  t6 = {
47998
48471
  start: recorderProps.start,
47999
48472
  stop: recorderProps.stop,
@@ -48003,19 +48476,19 @@ var useTtsAudioRuntime = function(t0) {
48003
48476
  visualizationAnalyser: recorderProps.visualizationAnalyser,
48004
48477
  rawStatus: recorderProps.status
48005
48478
  };
48006
- $[9] = createMessageProps.isPending;
48007
- $[10] = recorderProps.pause;
48008
- $[11] = recorderProps.resume;
48009
- $[12] = recorderProps.start;
48010
- $[13] = recorderProps.status;
48011
- $[14] = recorderProps.stop;
48012
- $[15] = recorderProps.visualizationAnalyser;
48013
- $[16] = t6;
48479
+ $[12] = createMessageProps.isPending;
48480
+ $[13] = recorderProps.pause;
48481
+ $[14] = recorderProps.resume;
48482
+ $[15] = recorderProps.start;
48483
+ $[16] = recorderProps.status;
48484
+ $[17] = recorderProps.stop;
48485
+ $[18] = recorderProps.visualizationAnalyser;
48486
+ $[19] = t6;
48014
48487
  } else {
48015
- t6 = $[16];
48488
+ t6 = $[19];
48016
48489
  }
48017
48490
  var t7;
48018
- if ($[17] !== messageAudioProps.isAudioPlayed || $[18] !== messageAudioProps.isPending || $[19] !== messageAudioProps.isReady || $[20] !== messageAudioProps.pause || $[21] !== messageAudioProps.paused || $[22] !== messageAudioProps.play || $[23] !== messageAudioProps.playing || $[24] !== messageAudioProps.stop || $[25] !== messageAudioProps.visualizationAnalyser) {
48491
+ if ($[20] !== messageAudioProps.isAudioPlayed || $[21] !== messageAudioProps.isPending || $[22] !== messageAudioProps.isReady || $[23] !== messageAudioProps.pause || $[24] !== messageAudioProps.paused || $[25] !== messageAudioProps.play || $[26] !== messageAudioProps.playing || $[27] !== messageAudioProps.stop || $[28] !== messageAudioProps.visualizationAnalyser) {
48019
48492
  t7 = {
48020
48493
  play: messageAudioProps.play,
48021
48494
  pause: messageAudioProps.pause,
@@ -48028,32 +48501,32 @@ var useTtsAudioRuntime = function(t0) {
48028
48501
  isAudioPlayed: messageAudioProps.isAudioPlayed,
48029
48502
  rawStatus: void 0
48030
48503
  };
48031
- $[17] = messageAudioProps.isAudioPlayed;
48032
- $[18] = messageAudioProps.isPending;
48033
- $[19] = messageAudioProps.isReady;
48034
- $[20] = messageAudioProps.pause;
48035
- $[21] = messageAudioProps.paused;
48036
- $[22] = messageAudioProps.play;
48037
- $[23] = messageAudioProps.playing;
48038
- $[24] = messageAudioProps.stop;
48039
- $[25] = messageAudioProps.visualizationAnalyser;
48040
- $[26] = t7;
48041
- } else {
48042
- t7 = $[26];
48504
+ $[20] = messageAudioProps.isAudioPlayed;
48505
+ $[21] = messageAudioProps.isPending;
48506
+ $[22] = messageAudioProps.isReady;
48507
+ $[23] = messageAudioProps.pause;
48508
+ $[24] = messageAudioProps.paused;
48509
+ $[25] = messageAudioProps.play;
48510
+ $[26] = messageAudioProps.playing;
48511
+ $[27] = messageAudioProps.stop;
48512
+ $[28] = messageAudioProps.visualizationAnalyser;
48513
+ $[29] = t7;
48514
+ } else {
48515
+ t7 = $[29];
48043
48516
  }
48044
48517
  var t8;
48045
- if ($[27] !== t6 || $[28] !== t7) {
48518
+ if ($[30] !== t6 || $[31] !== t7) {
48046
48519
  t8 = {
48047
48520
  ttsAudioRuntime: {
48048
48521
  user: t6,
48049
48522
  assistant: t7
48050
48523
  }
48051
48524
  };
48052
- $[27] = t6;
48053
- $[28] = t7;
48054
- $[29] = t8;
48525
+ $[30] = t6;
48526
+ $[31] = t7;
48527
+ $[32] = t8;
48055
48528
  } else {
48056
- t8 = $[29];
48529
+ t8 = $[32];
48057
48530
  }
48058
48531
  t5 = t8;
48059
48532
  return t5;
@@ -48073,49 +48546,130 @@ function _temp25() {
48073
48546
  }
48074
48547
  // src/components/audioRuntimes/TtsAudioRuntimeProvider.tsx
48075
48548
  var import_jsx_runtime87 = require("react/jsx-runtime");
48549
+ var _excluded6 = [
48550
+ "children",
48551
+ "onEnd"
48552
+ ];
48553
+ function ownKeys50(e, r) {
48554
+ var t = Object.keys(e);
48555
+ if (Object.getOwnPropertySymbols) {
48556
+ var o = Object.getOwnPropertySymbols(e);
48557
+ r && (o = o.filter(function(r2) {
48558
+ return Object.getOwnPropertyDescriptor(e, r2).enumerable;
48559
+ })), t.push.apply(t, o);
48560
+ }
48561
+ return t;
48562
+ }
48563
+ function _objectSpread50(e) {
48564
+ for(var r = 1; r < arguments.length; r++){
48565
+ var t = null != arguments[r] ? arguments[r] : {};
48566
+ r % 2 ? ownKeys50(Object(t), true).forEach(function(r2) {
48567
+ _defineProperty50(e, r2, t[r2]);
48568
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys50(Object(t)).forEach(function(r2) {
48569
+ Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
48570
+ });
48571
+ }
48572
+ return e;
48573
+ }
48574
+ function _defineProperty50(e, r, t) {
48575
+ return (r = _toPropertyKey50(r)) in e ? Object.defineProperty(e, r, {
48576
+ value: t,
48577
+ enumerable: true,
48578
+ configurable: true,
48579
+ writable: true
48580
+ }) : e[r] = t, e;
48581
+ }
48582
+ function _toPropertyKey50(t) {
48583
+ var i = _toPrimitive50(t, "string");
48584
+ return "symbol" == (typeof i === "undefined" ? "undefined" : _type_of(i)) ? i : i + "";
48585
+ }
48586
+ function _toPrimitive50(t, r) {
48587
+ if ("object" != (typeof t === "undefined" ? "undefined" : _type_of(t)) || !t) return t;
48588
+ var e = t[Symbol.toPrimitive];
48589
+ if (void 0 !== e) {
48590
+ var i = e.call(t, r || "default");
48591
+ if ("object" != (typeof i === "undefined" ? "undefined" : _type_of(i))) return i;
48592
+ throw new TypeError("@@toPrimitive must return a primitive value.");
48593
+ }
48594
+ return ("string" === r ? String : Number)(t);
48595
+ }
48596
+ function _objectWithoutProperties6(e, t) {
48597
+ if (null == e) return {};
48598
+ var o, r, i = _objectWithoutPropertiesLoose6(e, t);
48599
+ if (Object.getOwnPropertySymbols) {
48600
+ var n = Object.getOwnPropertySymbols(e);
48601
+ for(r = 0; r < n.length; r++)o = n[r], -1 === t.indexOf(o) && ({}).propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
48602
+ }
48603
+ return i;
48604
+ }
48605
+ function _objectWithoutPropertiesLoose6(r, e) {
48606
+ if (null == r) return {};
48607
+ var t = {};
48608
+ for(var n in r)if (({}).hasOwnProperty.call(r, n)) {
48609
+ if (-1 !== e.indexOf(n)) continue;
48610
+ t[n] = r[n];
48611
+ }
48612
+ return t;
48613
+ }
48076
48614
  var TtsAudioRuntimeProvider = function(t0) {
48077
- var $ = (0, import_react_compiler_runtime90.c)(8);
48078
- var children = t0.children, play = t0.play, onEnd = t0.onEnd;
48615
+ var $ = (0, import_react_compiler_runtime90.c)(12);
48616
+ var children;
48617
+ var onEnd;
48618
+ var overrides;
48619
+ if ($[0] !== t0) {
48620
+ var _t = t0;
48621
+ var ref;
48622
+ ref = _t, children = ref.children, onEnd = ref.onEnd, ref;
48623
+ overrides = _objectWithoutProperties6(_t, _excluded6);
48624
+ _t;
48625
+ $[0] = t0;
48626
+ $[1] = children;
48627
+ $[2] = onEnd;
48628
+ $[3] = overrides;
48629
+ } else {
48630
+ children = $[1];
48631
+ onEnd = $[2];
48632
+ overrides = $[3];
48633
+ }
48079
48634
  var t1;
48080
- if ($[0] !== onEnd || $[1] !== play) {
48081
- t1 = {
48082
- play: play,
48635
+ if ($[4] !== onEnd || $[5] !== overrides) {
48636
+ t1 = _objectSpread50({
48083
48637
  onEnd: onEnd
48084
- };
48085
- $[0] = onEnd;
48086
- $[1] = play;
48087
- $[2] = t1;
48638
+ }, overrides);
48639
+ $[4] = onEnd;
48640
+ $[5] = overrides;
48641
+ $[6] = t1;
48088
48642
  } else {
48089
- t1 = $[2];
48643
+ t1 = $[6];
48090
48644
  }
48091
48645
  var ttsAudioRuntime = useTtsAudioRuntime(t1).ttsAudioRuntime;
48092
48646
  var t2;
48093
- if ($[3] !== ttsAudioRuntime) {
48647
+ if ($[7] !== ttsAudioRuntime) {
48094
48648
  t2 = {
48095
48649
  audioRuntime: ttsAudioRuntime
48096
48650
  };
48097
- $[3] = ttsAudioRuntime;
48098
- $[4] = t2;
48651
+ $[7] = ttsAudioRuntime;
48652
+ $[8] = t2;
48099
48653
  } else {
48100
- t2 = $[4];
48654
+ t2 = $[8];
48101
48655
  }
48102
48656
  var t3;
48103
- if ($[5] !== children || $[6] !== t2) {
48657
+ if ($[9] !== children || $[10] !== t2) {
48104
48658
  t3 = /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(AudioThreadContext.Provider, {
48105
48659
  value: t2,
48106
48660
  children: children
48107
48661
  });
48108
- $[5] = children;
48109
- $[6] = t2;
48110
- $[7] = t3;
48662
+ $[9] = children;
48663
+ $[10] = t2;
48664
+ $[11] = t3;
48111
48665
  } else {
48112
- t3 = $[7];
48666
+ t3 = $[11];
48113
48667
  }
48114
48668
  return t3;
48115
48669
  };
48116
48670
  // src/components/threads/AudioThread/Root/index.tsx
48117
48671
  var import_jsx_runtime88 = require("react/jsx-runtime");
48118
- var _excluded5 = [
48672
+ var _excluded7 = [
48119
48673
  "children"
48120
48674
  ];
48121
48675
  var _excluded22 = [
@@ -48125,7 +48679,7 @@ var _excluded22 = [
48125
48679
  "className",
48126
48680
  "style"
48127
48681
  ];
48128
- function ownKeys48(e, r) {
48682
+ function ownKeys51(e, r) {
48129
48683
  var t = Object.keys(e);
48130
48684
  if (Object.getOwnPropertySymbols) {
48131
48685
  var o = Object.getOwnPropertySymbols(e);
@@ -48135,30 +48689,30 @@ function ownKeys48(e, r) {
48135
48689
  }
48136
48690
  return t;
48137
48691
  }
48138
- function _objectSpread48(e) {
48692
+ function _objectSpread51(e) {
48139
48693
  for(var r = 1; r < arguments.length; r++){
48140
48694
  var t = null != arguments[r] ? arguments[r] : {};
48141
- r % 2 ? ownKeys48(Object(t), true).forEach(function(r2) {
48142
- _defineProperty48(e, r2, t[r2]);
48143
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys48(Object(t)).forEach(function(r2) {
48695
+ r % 2 ? ownKeys51(Object(t), true).forEach(function(r2) {
48696
+ _defineProperty51(e, r2, t[r2]);
48697
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys51(Object(t)).forEach(function(r2) {
48144
48698
  Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
48145
48699
  });
48146
48700
  }
48147
48701
  return e;
48148
48702
  }
48149
- function _defineProperty48(e, r, t) {
48150
- return (r = _toPropertyKey48(r)) in e ? Object.defineProperty(e, r, {
48703
+ function _defineProperty51(e, r, t) {
48704
+ return (r = _toPropertyKey51(r)) in e ? Object.defineProperty(e, r, {
48151
48705
  value: t,
48152
48706
  enumerable: true,
48153
48707
  configurable: true,
48154
48708
  writable: true
48155
48709
  }) : e[r] = t, e;
48156
48710
  }
48157
- function _toPropertyKey48(t) {
48158
- var i = _toPrimitive48(t, "string");
48711
+ function _toPropertyKey51(t) {
48712
+ var i = _toPrimitive51(t, "string");
48159
48713
  return "symbol" == (typeof i === "undefined" ? "undefined" : _type_of(i)) ? i : i + "";
48160
48714
  }
48161
- function _toPrimitive48(t, r) {
48715
+ function _toPrimitive51(t, r) {
48162
48716
  if ("object" != (typeof t === "undefined" ? "undefined" : _type_of(t)) || !t) return t;
48163
48717
  var e = t[Symbol.toPrimitive];
48164
48718
  if (void 0 !== e) {
@@ -48168,16 +48722,16 @@ function _toPrimitive48(t, r) {
48168
48722
  }
48169
48723
  return ("string" === r ? String : Number)(t);
48170
48724
  }
48171
- function _objectWithoutProperties5(e, t) {
48725
+ function _objectWithoutProperties7(e, t) {
48172
48726
  if (null == e) return {};
48173
- var o, r, i = _objectWithoutPropertiesLoose5(e, t);
48727
+ var o, r, i = _objectWithoutPropertiesLoose7(e, t);
48174
48728
  if (Object.getOwnPropertySymbols) {
48175
48729
  var n = Object.getOwnPropertySymbols(e);
48176
48730
  for(r = 0; r < n.length; r++)o = n[r], -1 === t.indexOf(o) && ({}).propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
48177
48731
  }
48178
48732
  return i;
48179
48733
  }
48180
- function _objectWithoutPropertiesLoose5(r, e) {
48734
+ function _objectWithoutPropertiesLoose7(r, e) {
48181
48735
  if (null == r) return {};
48182
48736
  var t = {};
48183
48737
  for(var n in r)if (({}).hasOwnProperty.call(r, n)) {
@@ -48210,7 +48764,7 @@ var Content9 = function(t0) {
48210
48764
  };
48211
48765
  var AudioRuntimeProvider = function(t0) {
48212
48766
  var $ = (0, import_react_compiler_runtime91.c)(4);
48213
- var children = t0.children, play = t0.play, onEnd = t0.onEnd;
48767
+ var children = t0.children, onEnd = t0.onEnd, play = t0.play;
48214
48768
  var audioThreadContext = useAudioThreadContext();
48215
48769
  if (audioThreadContext.audioRuntime) {
48216
48770
  return children;
@@ -48218,8 +48772,8 @@ var AudioRuntimeProvider = function(t0) {
48218
48772
  var t1;
48219
48773
  if ($[0] !== children || $[1] !== onEnd || $[2] !== play) {
48220
48774
  t1 = /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(TtsAudioRuntimeProvider, {
48221
- play: play,
48222
48775
  onEnd: onEnd,
48776
+ play: play,
48223
48777
  children: children
48224
48778
  });
48225
48779
  $[0] = children;
@@ -48238,7 +48792,7 @@ var Provider5 = function(t0) {
48238
48792
  if ($[0] !== t0) {
48239
48793
  var _t = t0;
48240
48794
  children = _t.children;
48241
- rest = _objectWithoutProperties5(_t, _excluded5);
48795
+ rest = _objectWithoutProperties7(_t, _excluded7);
48242
48796
  _t;
48243
48797
  $[0] = t0;
48244
48798
  $[1] = children;
@@ -48250,7 +48804,7 @@ var Provider5 = function(t0) {
48250
48804
  var audioThreadContext = useAudioThreadContext();
48251
48805
  var t1;
48252
48806
  if ($[3] !== audioThreadContext || $[4] !== rest) {
48253
- t1 = _objectSpread48(_objectSpread48({}, audioThreadContext), rest);
48807
+ t1 = _objectSpread51(_objectSpread51({}, audioThreadContext), rest);
48254
48808
  $[3] = audioThreadContext;
48255
48809
  $[4] = rest;
48256
48810
  $[5] = t1;
@@ -48283,7 +48837,7 @@ var Root16 = function(t0) {
48283
48837
  var _t2 = t0;
48284
48838
  var ref;
48285
48839
  ref = _t2, children = ref.children, play = ref.play, onEnd = ref.onEnd, className = ref.className, style = ref.style, ref;
48286
- rest = _objectWithoutProperties5(_t2, _excluded22);
48840
+ rest = _objectWithoutProperties7(_t2, _excluded22);
48287
48841
  _t2;
48288
48842
  $[0] = t0;
48289
48843
  $[1] = children;
@@ -48319,8 +48873,8 @@ var Root16 = function(t0) {
48319
48873
  var t2;
48320
48874
  if ($[11] !== onEnd || $[12] !== play || $[13] !== t1) {
48321
48875
  t2 = /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(AudioRuntimeProvider, {
48322
- play: play,
48323
48876
  onEnd: onEnd,
48877
+ play: play,
48324
48878
  children: t1
48325
48879
  });
48326
48880
  $[11] = onEnd;
@@ -48332,7 +48886,7 @@ var Root16 = function(t0) {
48332
48886
  }
48333
48887
  var t3;
48334
48888
  if ($[15] !== rest || $[16] !== t2) {
48335
- t3 = /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(Provider5, _objectSpread48(_objectSpread48({}, rest), {}, {
48889
+ t3 = /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(Provider5, _objectSpread51(_objectSpread51({}, rest), {}, {
48336
48890
  children: t2
48337
48891
  }));
48338
48892
  $[15] = rest;
@@ -48345,20 +48899,20 @@ var Root16 = function(t0) {
48345
48899
  };
48346
48900
  // src/components/threads/AudioThread/Visualization/index.tsx
48347
48901
  var import_react_compiler_runtime93 = require("react-compiler-runtime");
48348
- var import_react71 = require("react");
48902
+ var import_react72 = require("react");
48349
48903
  var import_lodash9 = __toESM(require("lodash"), 1);
48350
48904
  var import_themes60 = require("@radix-ui/themes");
48351
48905
  // src/components/threads/AudioThread/BarsVisualizer/index.tsx
48352
48906
  var import_lodash8 = __toESM(require("lodash"), 1);
48353
48907
  var import_themes59 = require("@radix-ui/themes");
48354
- var import_react69 = require("react");
48908
+ var import_react70 = require("react");
48355
48909
  var import_radash17 = require("radash");
48356
48910
  var import_jsx_runtime89 = require("react/jsx-runtime");
48357
48911
  var barCount = 4;
48358
48912
  var BarsVisualizer = function(_ref) {
48359
48913
  var visualizationAnalyser = _ref.visualizationAnalyser, backgroundColor = _ref.backgroundColor, height = _ref.height, barWidth = _ref.barWidth;
48360
- var _$_ref = _sliced_to_array((0, import_react69.useState)([]), 2), barHeights = _$_ref[0], setBarHeights = _$_ref[1];
48361
- var draw = (0, import_react69.useCallback)(function(_ref2) {
48914
+ var _$_ref = _sliced_to_array((0, import_react70.useState)([]), 2), barHeights = _$_ref[0], setBarHeights = _$_ref[1];
48915
+ var draw = (0, import_react70.useCallback)(function(_ref2) {
48362
48916
  var visualizationAnalyser_0 = _ref2.visualizationAnalyser;
48363
48917
  if (!visualizationAnalyser_0) {
48364
48918
  setBarHeights(Array(barCount).fill(0));
@@ -48376,7 +48930,7 @@ var BarsVisualizer = function(_ref) {
48376
48930
  });
48377
48931
  });
48378
48932
  }, []);
48379
- (0, import_react69.useEffect)(function() {
48933
+ (0, import_react70.useEffect)(function() {
48380
48934
  draw({
48381
48935
  visualizationAnalyser: visualizationAnalyser
48382
48936
  });
@@ -48414,7 +48968,7 @@ var BarsVisualizer = function(_ref) {
48414
48968
  };
48415
48969
  // src/hooks/audioThreads/useStatus/index.ts
48416
48970
  var import_react_compiler_runtime92 = require("react-compiler-runtime");
48417
- var import_react70 = require("react");
48971
+ var import_react71 = require("react");
48418
48972
  var useStatus = function() {
48419
48973
  var $ = (0, import_react_compiler_runtime92.c)(2);
48420
48974
  var audioRuntime = useAudioThreadContext().audioRuntime;
@@ -48465,7 +49019,7 @@ var useStatus = function() {
48465
49019
  };
48466
49020
  // src/components/threads/AudioThread/Visualization/index.tsx
48467
49021
  var import_jsx_runtime90 = require("react/jsx-runtime");
48468
- var _excluded6 = [
49022
+ var _excluded8 = [
48469
49023
  "children"
48470
49024
  ];
48471
49025
  var _excluded23 = [
@@ -48477,7 +49031,7 @@ var _excluded32 = [
48477
49031
  "height",
48478
49032
  "width"
48479
49033
  ];
48480
- function ownKeys49(e, r) {
49034
+ function ownKeys52(e, r) {
48481
49035
  var t = Object.keys(e);
48482
49036
  if (Object.getOwnPropertySymbols) {
48483
49037
  var o = Object.getOwnPropertySymbols(e);
@@ -48487,30 +49041,30 @@ function ownKeys49(e, r) {
48487
49041
  }
48488
49042
  return t;
48489
49043
  }
48490
- function _objectSpread49(e) {
49044
+ function _objectSpread52(e) {
48491
49045
  for(var r = 1; r < arguments.length; r++){
48492
49046
  var t = null != arguments[r] ? arguments[r] : {};
48493
- r % 2 ? ownKeys49(Object(t), true).forEach(function(r2) {
48494
- _defineProperty49(e, r2, t[r2]);
48495
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys49(Object(t)).forEach(function(r2) {
49047
+ r % 2 ? ownKeys52(Object(t), true).forEach(function(r2) {
49048
+ _defineProperty52(e, r2, t[r2]);
49049
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys52(Object(t)).forEach(function(r2) {
48496
49050
  Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
48497
49051
  });
48498
49052
  }
48499
49053
  return e;
48500
49054
  }
48501
- function _defineProperty49(e, r, t) {
48502
- return (r = _toPropertyKey49(r)) in e ? Object.defineProperty(e, r, {
49055
+ function _defineProperty52(e, r, t) {
49056
+ return (r = _toPropertyKey52(r)) in e ? Object.defineProperty(e, r, {
48503
49057
  value: t,
48504
49058
  enumerable: true,
48505
49059
  configurable: true,
48506
49060
  writable: true
48507
49061
  }) : e[r] = t, e;
48508
49062
  }
48509
- function _toPropertyKey49(t) {
48510
- var i = _toPrimitive49(t, "string");
49063
+ function _toPropertyKey52(t) {
49064
+ var i = _toPrimitive52(t, "string");
48511
49065
  return "symbol" == (typeof i === "undefined" ? "undefined" : _type_of(i)) ? i : i + "";
48512
49066
  }
48513
- function _toPrimitive49(t, r) {
49067
+ function _toPrimitive52(t, r) {
48514
49068
  if ("object" != (typeof t === "undefined" ? "undefined" : _type_of(t)) || !t) return t;
48515
49069
  var e = t[Symbol.toPrimitive];
48516
49070
  if (void 0 !== e) {
@@ -48520,16 +49074,16 @@ function _toPrimitive49(t, r) {
48520
49074
  }
48521
49075
  return ("string" === r ? String : Number)(t);
48522
49076
  }
48523
- function _objectWithoutProperties6(e, t) {
49077
+ function _objectWithoutProperties8(e, t) {
48524
49078
  if (null == e) return {};
48525
- var o, r, i = _objectWithoutPropertiesLoose6(e, t);
49079
+ var o, r, i = _objectWithoutPropertiesLoose8(e, t);
48526
49080
  if (Object.getOwnPropertySymbols) {
48527
49081
  var n = Object.getOwnPropertySymbols(e);
48528
49082
  for(r = 0; r < n.length; r++)o = n[r], -1 === t.indexOf(o) && ({}).propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
48529
49083
  }
48530
49084
  return i;
48531
49085
  }
48532
- function _objectWithoutPropertiesLoose6(r, e) {
49086
+ function _objectWithoutPropertiesLoose8(r, e) {
48533
49087
  if (null == r) return {};
48534
49088
  var t = {};
48535
49089
  for(var n in r)if (({}).hasOwnProperty.call(r, n)) {
@@ -48538,14 +49092,14 @@ function _objectWithoutPropertiesLoose6(r, e) {
48538
49092
  }
48539
49093
  return t;
48540
49094
  }
48541
- var AudioThreadVisualizationContext = /* @__PURE__ */ (0, import_react71.createContext)({
49095
+ var AudioThreadVisualizationContext = /* @__PURE__ */ (0, import_react72.createContext)({
48542
49096
  scale: 0
48543
49097
  });
48544
49098
  var Provider6 = function(_ref) {
48545
49099
  var children = _ref.children;
48546
49100
  var audioThreadContext = useAudioThreadContext();
48547
- var _$_ref = _sliced_to_array((0, import_react71.useState)(0), 2), scale = _$_ref[0], setScale = _$_ref[1];
48548
- var draw = (0, import_react71.useCallback)(function(_ref2) {
49101
+ var _$_ref = _sliced_to_array((0, import_react72.useState)(0), 2), scale = _$_ref[0], setScale = _$_ref[1];
49102
+ var draw = (0, import_react72.useCallback)(function(_ref2) {
48549
49103
  var visualizationAnalyser = _ref2.visualizationAnalyser;
48550
49104
  if (!visualizationAnalyser) {
48551
49105
  setScale(1);
@@ -48560,7 +49114,7 @@ var Provider6 = function(_ref) {
48560
49114
  });
48561
49115
  });
48562
49116
  }, []);
48563
- (0, import_react71.useEffect)(function() {
49117
+ (0, import_react72.useEffect)(function() {
48564
49118
  draw({
48565
49119
  visualizationAnalyser: audioThreadContext.audioRuntime.user.visualizationAnalyser
48566
49120
  });
@@ -48582,7 +49136,7 @@ var Root17 = function(t0) {
48582
49136
  if ($[0] !== t0) {
48583
49137
  var _t = t0;
48584
49138
  children = _t.children;
48585
- rest = _objectWithoutProperties6(_t, _excluded6);
49139
+ rest = _objectWithoutProperties8(_t, _excluded8);
48586
49140
  _t;
48587
49141
  $[0] = t0;
48588
49142
  $[1] = children;
@@ -48594,7 +49148,7 @@ var Root17 = function(t0) {
48594
49148
  var t1;
48595
49149
  if ($[3] !== children || $[4] !== rest) {
48596
49150
  t1 = /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(Provider6, {
48597
- children: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(import_themes60.Flex, _objectSpread49(_objectSpread49({
49151
+ children: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(import_themes60.Flex, _objectSpread52(_objectSpread52({
48598
49152
  direction: "column",
48599
49153
  align: "center",
48600
49154
  justify: "center",
@@ -48621,7 +49175,7 @@ var BarsVisualizer2 = function(t0) {
48621
49175
  var _t2 = t0;
48622
49176
  var ref;
48623
49177
  ref = _t2, t1 = ref.height, t2 = ref.barWidth, ref;
48624
- rest = _objectWithoutProperties6(_t2, _excluded23);
49178
+ rest = _objectWithoutProperties8(_t2, _excluded23);
48625
49179
  _t2;
48626
49180
  $[0] = t0;
48627
49181
  $[1] = rest;
@@ -48639,7 +49193,7 @@ var BarsVisualizer2 = function(t0) {
48639
49193
  var t3 = status === "playing" ? "var(--accent-11)" : "var(--gray-11)";
48640
49194
  var t4;
48641
49195
  if ($[4] !== audioThreadContext.audioRuntime.assistant.visualizationAnalyser || $[5] !== barWidth || $[6] !== height || $[7] !== rest || $[8] !== t3) {
48642
- t4 = /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(BarsVisualizer, _objectSpread49({
49196
+ t4 = /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(BarsVisualizer, _objectSpread52({
48643
49197
  visualizationAnalyser: audioThreadContext.audioRuntime.assistant.visualizationAnalyser,
48644
49198
  backgroundColor: t3,
48645
49199
  height: height,
@@ -48666,7 +49220,7 @@ var AssistantVisualizationRoot = function(t0) {
48666
49220
  var _t3 = t0;
48667
49221
  var ref;
48668
49222
  ref = _t3, children = ref.children, t1 = ref.height, t2 = ref.width, ref;
48669
- rest = _objectWithoutProperties6(_t3, _excluded32);
49223
+ rest = _objectWithoutProperties8(_t3, _excluded32);
48670
49224
  _t3;
48671
49225
  $[0] = t0;
48672
49226
  $[1] = children;
@@ -48682,7 +49236,7 @@ var AssistantVisualizationRoot = function(t0) {
48682
49236
  var height = t1 === void 0 ? "200px" : t1;
48683
49237
  var width2 = t2 === void 0 ? "200px" : t2;
48684
49238
  var status = useStatus().status;
48685
- var scale = (0, import_react71.useContext)(AudioThreadVisualizationContext).scale;
49239
+ var scale = (0, import_react72.useContext)(AudioThreadVisualizationContext).scale;
48686
49240
  var t3 = status === "playing" ? "var(--accent-4)" : "var(--gray-4)";
48687
49241
  var t4;
48688
49242
  if ($[5] !== rest.style) {
@@ -48695,7 +49249,7 @@ var AssistantVisualizationRoot = function(t0) {
48695
49249
  }
48696
49250
  var t5;
48697
49251
  if ($[7] !== scale || $[8] !== t3 || $[9] !== t4) {
48698
- t5 = _objectSpread49({
49252
+ t5 = _objectSpread52({
48699
49253
  backgroundColor: t3,
48700
49254
  borderRadius: "9999px",
48701
49255
  scale: scale
@@ -48709,7 +49263,7 @@ var AssistantVisualizationRoot = function(t0) {
48709
49263
  }
48710
49264
  var t6;
48711
49265
  if ($[11] !== children || $[12] !== height || $[13] !== rest || $[14] !== t5 || $[15] !== width2) {
48712
- t6 = /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(import_themes60.Flex, _objectSpread49(_objectSpread49({
49266
+ t6 = /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(import_themes60.Flex, _objectSpread52(_objectSpread52({
48713
49267
  align: "center",
48714
49268
  justify: "center",
48715
49269
  height: height,
@@ -48740,7 +49294,7 @@ var AssistantVisualization = function(props) {
48740
49294
  }
48741
49295
  var t1;
48742
49296
  if ($[1] !== props) {
48743
- t1 = /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(AssistantVisualizationRoot, _objectSpread49(_objectSpread49({}, props), {}, {
49297
+ t1 = /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(AssistantVisualizationRoot, _objectSpread52(_objectSpread52({}, props), {}, {
48744
49298
  children: t0
48745
49299
  }));
48746
49300
  $[1] = props;
@@ -48754,7 +49308,7 @@ AssistantVisualization.Root = AssistantVisualizationRoot;
48754
49308
  AssistantVisualization.BarsVisualizer = BarsVisualizer2;
48755
49309
  var AssistantInfo = function(props) {
48756
49310
  var $ = (0, import_react_compiler_runtime93.c)(6);
48757
- var assistantNameContext = (0, import_react71.useContext)(AssistantNameContext);
49311
+ var assistantNameContext = (0, import_react72.useContext)(AssistantNameContext);
48758
49312
  var t0;
48759
49313
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
48760
49314
  t0 = /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(MessageGroup.AssistantAvatar, {});
@@ -48774,7 +49328,7 @@ var AssistantInfo = function(props) {
48774
49328
  }
48775
49329
  var t2;
48776
49330
  if ($[3] !== props || $[4] !== t1) {
48777
- t2 = /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)(import_themes60.Flex, _objectSpread49(_objectSpread49({
49331
+ t2 = /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)(import_themes60.Flex, _objectSpread52(_objectSpread52({
48778
49332
  ml: "-22.5px",
48779
49333
  gap: "3",
48780
49334
  pt: "5"
@@ -48807,7 +49361,7 @@ var Visualization = function(props) {
48807
49361
  }
48808
49362
  var t2;
48809
49363
  if ($[2] !== props) {
48810
- t2 = /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)(Root17, _objectSpread49(_objectSpread49({}, props), {}, {
49364
+ t2 = /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)(Root17, _objectSpread52(_objectSpread52({}, props), {}, {
48811
49365
  children: [
48812
49366
  t0,
48813
49367
  t1
@@ -48897,7 +49451,7 @@ var StatusMessages = function(t0) {
48897
49451
  };
48898
49452
  // src/components/threads/AudioThread/Status/index.tsx
48899
49453
  var import_jsx_runtime92 = require("react/jsx-runtime");
48900
- function ownKeys50(e, r) {
49454
+ function ownKeys53(e, r) {
48901
49455
  var t = Object.keys(e);
48902
49456
  if (Object.getOwnPropertySymbols) {
48903
49457
  var o = Object.getOwnPropertySymbols(e);
@@ -48907,30 +49461,30 @@ function ownKeys50(e, r) {
48907
49461
  }
48908
49462
  return t;
48909
49463
  }
48910
- function _objectSpread50(e) {
49464
+ function _objectSpread53(e) {
48911
49465
  for(var r = 1; r < arguments.length; r++){
48912
49466
  var t = null != arguments[r] ? arguments[r] : {};
48913
- r % 2 ? ownKeys50(Object(t), true).forEach(function(r2) {
48914
- _defineProperty50(e, r2, t[r2]);
48915
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys50(Object(t)).forEach(function(r2) {
49467
+ r % 2 ? ownKeys53(Object(t), true).forEach(function(r2) {
49468
+ _defineProperty53(e, r2, t[r2]);
49469
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys53(Object(t)).forEach(function(r2) {
48916
49470
  Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
48917
49471
  });
48918
49472
  }
48919
49473
  return e;
48920
49474
  }
48921
- function _defineProperty50(e, r, t) {
48922
- return (r = _toPropertyKey50(r)) in e ? Object.defineProperty(e, r, {
49475
+ function _defineProperty53(e, r, t) {
49476
+ return (r = _toPropertyKey53(r)) in e ? Object.defineProperty(e, r, {
48923
49477
  value: t,
48924
49478
  enumerable: true,
48925
49479
  configurable: true,
48926
49480
  writable: true
48927
49481
  }) : e[r] = t, e;
48928
49482
  }
48929
- function _toPropertyKey50(t) {
48930
- var i = _toPrimitive50(t, "string");
49483
+ function _toPropertyKey53(t) {
49484
+ var i = _toPrimitive53(t, "string");
48931
49485
  return "symbol" == (typeof i === "undefined" ? "undefined" : _type_of(i)) ? i : i + "";
48932
49486
  }
48933
- function _toPrimitive50(t, r) {
49487
+ function _toPrimitive53(t, r) {
48934
49488
  if ("object" != (typeof t === "undefined" ? "undefined" : _type_of(t)) || !t) return t;
48935
49489
  var e = t[Symbol.toPrimitive];
48936
49490
  if (void 0 !== e) {
@@ -48958,7 +49512,7 @@ var Status = function(props) {
48958
49512
  }
48959
49513
  var _t2;
48960
49514
  if ($[1] !== props) {
48961
- _t2 = /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(StatusMessages, _objectSpread50({
49515
+ _t2 = /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(StatusMessages, _objectSpread53({
48962
49516
  texts: _t
48963
49517
  }, props));
48964
49518
  $[1] = props;
@@ -48984,7 +49538,7 @@ var Status = function(props) {
48984
49538
  }
48985
49539
  var _t4;
48986
49540
  if ($[4] !== props) {
48987
- _t4 = /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(StatusMessages, _objectSpread50({
49541
+ _t4 = /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(StatusMessages, _objectSpread53({
48988
49542
  texts: _t3
48989
49543
  }, props));
48990
49544
  $[4] = props;
@@ -49006,7 +49560,7 @@ var Status = function(props) {
49006
49560
  }
49007
49561
  var _t6;
49008
49562
  if ($[7] !== props) {
49009
- _t6 = /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(StatusMessages, _objectSpread50({
49563
+ _t6 = /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(StatusMessages, _objectSpread53({
49010
49564
  texts: _t5
49011
49565
  }, props));
49012
49566
  $[7] = props;
@@ -49027,7 +49581,7 @@ var Status = function(props) {
49027
49581
  }
49028
49582
  var t1;
49029
49583
  if ($[10] !== props) {
49030
- t1 = /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(StatusMessages, _objectSpread50({
49584
+ t1 = /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(StatusMessages, _objectSpread53({
49031
49585
  texts: t0
49032
49586
  }, props));
49033
49587
  $[10] = props;
@@ -49043,7 +49597,7 @@ var import_themes63 = require("@radix-ui/themes");
49043
49597
  // src/components/threads/AudioThread/Form/MicIcon.tsx
49044
49598
  var import_react_compiler_runtime96 = require("react-compiler-runtime");
49045
49599
  var import_jsx_runtime93 = require("react/jsx-runtime");
49046
- function ownKeys51(e, r) {
49600
+ function ownKeys54(e, r) {
49047
49601
  var t = Object.keys(e);
49048
49602
  if (Object.getOwnPropertySymbols) {
49049
49603
  var o = Object.getOwnPropertySymbols(e);
@@ -49053,30 +49607,30 @@ function ownKeys51(e, r) {
49053
49607
  }
49054
49608
  return t;
49055
49609
  }
49056
- function _objectSpread51(e) {
49610
+ function _objectSpread54(e) {
49057
49611
  for(var r = 1; r < arguments.length; r++){
49058
49612
  var t = null != arguments[r] ? arguments[r] : {};
49059
- r % 2 ? ownKeys51(Object(t), true).forEach(function(r2) {
49060
- _defineProperty51(e, r2, t[r2]);
49061
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys51(Object(t)).forEach(function(r2) {
49613
+ r % 2 ? ownKeys54(Object(t), true).forEach(function(r2) {
49614
+ _defineProperty54(e, r2, t[r2]);
49615
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys54(Object(t)).forEach(function(r2) {
49062
49616
  Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
49063
49617
  });
49064
49618
  }
49065
49619
  return e;
49066
49620
  }
49067
- function _defineProperty51(e, r, t) {
49068
- return (r = _toPropertyKey51(r)) in e ? Object.defineProperty(e, r, {
49621
+ function _defineProperty54(e, r, t) {
49622
+ return (r = _toPropertyKey54(r)) in e ? Object.defineProperty(e, r, {
49069
49623
  value: t,
49070
49624
  enumerable: true,
49071
49625
  configurable: true,
49072
49626
  writable: true
49073
49627
  }) : e[r] = t, e;
49074
49628
  }
49075
- function _toPropertyKey51(t) {
49076
- var i = _toPrimitive51(t, "string");
49629
+ function _toPropertyKey54(t) {
49630
+ var i = _toPrimitive54(t, "string");
49077
49631
  return "symbol" == (typeof i === "undefined" ? "undefined" : _type_of(i)) ? i : i + "";
49078
49632
  }
49079
- function _toPrimitive51(t, r) {
49633
+ function _toPrimitive54(t, r) {
49080
49634
  if ("object" != (typeof t === "undefined" ? "undefined" : _type_of(t)) || !t) return t;
49081
49635
  var e = t[Symbol.toPrimitive];
49082
49636
  if (void 0 !== e) {
@@ -49100,7 +49654,7 @@ var MicIcon = function(props) {
49100
49654
  }
49101
49655
  var t1;
49102
49656
  if ($[1] !== props) {
49103
- t1 = /* @__PURE__ */ (0, import_jsx_runtime93.jsx)("svg", _objectSpread51(_objectSpread51({
49657
+ t1 = /* @__PURE__ */ (0, import_jsx_runtime93.jsx)("svg", _objectSpread54(_objectSpread54({
49104
49658
  xmlns: "http://www.w3.org/2000/svg",
49105
49659
  fill: "currentColor",
49106
49660
  stroke: "currentColor",
@@ -49318,7 +49872,7 @@ var ActionButton = function() {
49318
49872
  };
49319
49873
  // src/components/threads/AudioThread/Form/index.tsx
49320
49874
  var import_jsx_runtime95 = require("react/jsx-runtime");
49321
- function ownKeys52(e, r) {
49875
+ function ownKeys55(e, r) {
49322
49876
  var t = Object.keys(e);
49323
49877
  if (Object.getOwnPropertySymbols) {
49324
49878
  var o = Object.getOwnPropertySymbols(e);
@@ -49328,30 +49882,30 @@ function ownKeys52(e, r) {
49328
49882
  }
49329
49883
  return t;
49330
49884
  }
49331
- function _objectSpread52(e) {
49885
+ function _objectSpread55(e) {
49332
49886
  for(var r = 1; r < arguments.length; r++){
49333
49887
  var t = null != arguments[r] ? arguments[r] : {};
49334
- r % 2 ? ownKeys52(Object(t), true).forEach(function(r2) {
49335
- _defineProperty52(e, r2, t[r2]);
49336
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys52(Object(t)).forEach(function(r2) {
49888
+ r % 2 ? ownKeys55(Object(t), true).forEach(function(r2) {
49889
+ _defineProperty55(e, r2, t[r2]);
49890
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys55(Object(t)).forEach(function(r2) {
49337
49891
  Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
49338
49892
  });
49339
49893
  }
49340
49894
  return e;
49341
49895
  }
49342
- function _defineProperty52(e, r, t) {
49343
- return (r = _toPropertyKey52(r)) in e ? Object.defineProperty(e, r, {
49896
+ function _defineProperty55(e, r, t) {
49897
+ return (r = _toPropertyKey55(r)) in e ? Object.defineProperty(e, r, {
49344
49898
  value: t,
49345
49899
  enumerable: true,
49346
49900
  configurable: true,
49347
49901
  writable: true
49348
49902
  }) : e[r] = t, e;
49349
49903
  }
49350
- function _toPropertyKey52(t) {
49351
- var i = _toPrimitive52(t, "string");
49904
+ function _toPropertyKey55(t) {
49905
+ var i = _toPrimitive55(t, "string");
49352
49906
  return "symbol" == (typeof i === "undefined" ? "undefined" : _type_of(i)) ? i : i + "";
49353
49907
  }
49354
- function _toPrimitive52(t, r) {
49908
+ function _toPrimitive55(t, r) {
49355
49909
  if ("object" != (typeof t === "undefined" ? "undefined" : _type_of(t)) || !t) return t;
49356
49910
  var e = t[Symbol.toPrimitive];
49357
49911
  if (void 0 !== e) {
@@ -49449,7 +50003,7 @@ var Form = function(props) {
49449
50003
  }
49450
50004
  var t9;
49451
50005
  if ($[14] !== props || $[15] !== t7) {
49452
- t9 = /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(import_themes63.Flex, _objectSpread52(_objectSpread52({
50006
+ t9 = /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(import_themes63.Flex, _objectSpread55(_objectSpread55({
49453
50007
  direction: "column",
49454
50008
  align: "center"
49455
50009
  }, props), {}, {
@@ -49468,7 +50022,7 @@ var Form = function(props) {
49468
50022
  };
49469
50023
  // src/components/threads/AudioThread/index.tsx
49470
50024
  var import_jsx_runtime96 = require("react/jsx-runtime");
49471
- function ownKeys53(e, r) {
50025
+ function ownKeys56(e, r) {
49472
50026
  var t = Object.keys(e);
49473
50027
  if (Object.getOwnPropertySymbols) {
49474
50028
  var o = Object.getOwnPropertySymbols(e);
@@ -49478,30 +50032,30 @@ function ownKeys53(e, r) {
49478
50032
  }
49479
50033
  return t;
49480
50034
  }
49481
- function _objectSpread53(e) {
50035
+ function _objectSpread56(e) {
49482
50036
  for(var r = 1; r < arguments.length; r++){
49483
50037
  var t = null != arguments[r] ? arguments[r] : {};
49484
- r % 2 ? ownKeys53(Object(t), true).forEach(function(r2) {
49485
- _defineProperty53(e, r2, t[r2]);
49486
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys53(Object(t)).forEach(function(r2) {
50038
+ r % 2 ? ownKeys56(Object(t), true).forEach(function(r2) {
50039
+ _defineProperty56(e, r2, t[r2]);
50040
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys56(Object(t)).forEach(function(r2) {
49487
50041
  Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
49488
50042
  });
49489
50043
  }
49490
50044
  return e;
49491
50045
  }
49492
- function _defineProperty53(e, r, t) {
49493
- return (r = _toPropertyKey53(r)) in e ? Object.defineProperty(e, r, {
50046
+ function _defineProperty56(e, r, t) {
50047
+ return (r = _toPropertyKey56(r)) in e ? Object.defineProperty(e, r, {
49494
50048
  value: t,
49495
50049
  enumerable: true,
49496
50050
  configurable: true,
49497
50051
  writable: true
49498
50052
  }) : e[r] = t, e;
49499
50053
  }
49500
- function _toPropertyKey53(t) {
49501
- var i = _toPrimitive53(t, "string");
50054
+ function _toPropertyKey56(t) {
50055
+ var i = _toPrimitive56(t, "string");
49502
50056
  return "symbol" == (typeof i === "undefined" ? "undefined" : _type_of(i)) ? i : i + "";
49503
50057
  }
49504
- function _toPrimitive53(t, r) {
50058
+ function _toPrimitive56(t, r) {
49505
50059
  if ("object" != (typeof t === "undefined" ? "undefined" : _type_of(t)) || !t) return t;
49506
50060
  var e = t[Symbol.toPrimitive];
49507
50061
  if (void 0 !== e) {
@@ -49530,7 +50084,7 @@ var AudioThread = function(props) {
49530
50084
  }
49531
50085
  var t3;
49532
50086
  if ($[3] !== props) {
49533
- t3 = /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(Root16, _objectSpread53(_objectSpread53({}, props), {}, {
50087
+ t3 = /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(Root16, _objectSpread56(_objectSpread56({}, props), {}, {
49534
50088
  children: [
49535
50089
  t0,
49536
50090
  t1,
@@ -49550,7 +50104,7 @@ AudioThread.Status = Status;
49550
50104
  AudioThread.Form = Form;
49551
50105
  // src/components/threads/AudioThreadDialog/index.tsx
49552
50106
  var import_jsx_runtime97 = require("react/jsx-runtime");
49553
- function ownKeys54(e, r) {
50107
+ function ownKeys57(e, r) {
49554
50108
  var t = Object.keys(e);
49555
50109
  if (Object.getOwnPropertySymbols) {
49556
50110
  var o = Object.getOwnPropertySymbols(e);
@@ -49560,30 +50114,30 @@ function ownKeys54(e, r) {
49560
50114
  }
49561
50115
  return t;
49562
50116
  }
49563
- function _objectSpread54(e) {
50117
+ function _objectSpread57(e) {
49564
50118
  for(var r = 1; r < arguments.length; r++){
49565
50119
  var t = null != arguments[r] ? arguments[r] : {};
49566
- r % 2 ? ownKeys54(Object(t), true).forEach(function(r2) {
49567
- _defineProperty54(e, r2, t[r2]);
49568
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys54(Object(t)).forEach(function(r2) {
50120
+ r % 2 ? ownKeys57(Object(t), true).forEach(function(r2) {
50121
+ _defineProperty57(e, r2, t[r2]);
50122
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys57(Object(t)).forEach(function(r2) {
49569
50123
  Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
49570
50124
  });
49571
50125
  }
49572
50126
  return e;
49573
50127
  }
49574
- function _defineProperty54(e, r, t) {
49575
- return (r = _toPropertyKey54(r)) in e ? Object.defineProperty(e, r, {
50128
+ function _defineProperty57(e, r, t) {
50129
+ return (r = _toPropertyKey57(r)) in e ? Object.defineProperty(e, r, {
49576
50130
  value: t,
49577
50131
  enumerable: true,
49578
50132
  configurable: true,
49579
50133
  writable: true
49580
50134
  }) : e[r] = t, e;
49581
50135
  }
49582
- function _toPropertyKey54(t) {
49583
- var i = _toPrimitive54(t, "string");
50136
+ function _toPropertyKey57(t) {
50137
+ var i = _toPrimitive57(t, "string");
49584
50138
  return "symbol" == (typeof i === "undefined" ? "undefined" : _type_of(i)) ? i : i + "";
49585
50139
  }
49586
- function _toPrimitive54(t, r) {
50140
+ function _toPrimitive57(t, r) {
49587
50141
  if ("object" != (typeof t === "undefined" ? "undefined" : _type_of(t)) || !t) return t;
49588
50142
  var e = t[Symbol.toPrimitive];
49589
50143
  if (void 0 !== e) {
@@ -49610,7 +50164,7 @@ var AudioThreadDialog = function(props) {
49610
50164
  }
49611
50165
  var t2;
49612
50166
  if ($[2] !== props) {
49613
- t2 = /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)(Root13, _objectSpread54(_objectSpread54({}, props), {}, {
50167
+ t2 = /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)(Root13, _objectSpread57(_objectSpread57({}, props), {}, {
49614
50168
  children: [
49615
50169
  t0,
49616
50170
  t1
@@ -49627,7 +50181,7 @@ AudioThreadDialog.Root = Root13;
49627
50181
  AudioThreadDialog.Trigger = Trigger;
49628
50182
  AudioThreadDialog.Content = Content8;
49629
50183
  // src/hooks/audioRuntimes/useWebrtcAudioRuntime/index.ts
49630
- var import_react72 = require("react");
50184
+ var import_react73 = require("react");
49631
50185
  function asyncGeneratorStep12(n, t, e, r, o, a, c) {
49632
50186
  try {
49633
50187
  var i = n[a](c), u = i.value;
@@ -49716,22 +50270,22 @@ var useWebrtcAudioRuntime = function() {
49716
50270
  console.warn("Could not build analyzers:", err_0);
49717
50271
  }
49718
50272
  };
49719
- var _ref = _sliced_to_array((0, import_react72.useState)("idle"), 2), recorderStatus = _ref[0], setRecorderStatus = _ref[1];
50273
+ var _ref = _sliced_to_array((0, import_react73.useState)("idle"), 2), recorderStatus = _ref[0], setRecorderStatus = _ref[1];
49720
50274
  var superinterfaceContext = useSuperinterfaceContext();
49721
- var _ref1 = _sliced_to_array((0, import_react72.useState)(false), 2), userIsPending = _ref1[0], setUserIsPending = _ref1[1];
49722
- var _ref2 = _sliced_to_array((0, import_react72.useState)(false), 2), assistantPlaying = _ref2[0], setAssistantPlaying = _ref2[1];
49723
- var _ref3 = _sliced_to_array((0, import_react72.useState)(false), 2), assistantPaused = _ref3[0], setAssistantPaused = _ref3[1];
49724
- var _ref4 = _sliced_to_array((0, import_react72.useState)(true), 2), assistantIsPending = _ref4[0], setAssistantIsPending = _ref4[1];
49725
- var _ref5 = _sliced_to_array((0, import_react72.useState)(false), 2), assistantIsReady = _ref5[0], setAssistantIsReady = _ref5[1];
49726
- var _ref6 = _sliced_to_array((0, import_react72.useState)(false), 2), assistantAudioPlayed = _ref6[0], setAssistantAudioPlayed = _ref6[1];
49727
- var sessionStartedRef = (0, import_react72.useRef)(false);
49728
- var pcRef = (0, import_react72.useRef)(null);
49729
- var localStreamRef = (0, import_react72.useRef)(null);
49730
- var remoteStreamRef = (0, import_react72.useRef)(null);
49731
- var userAnalyserRef = (0, import_react72.useRef)(null);
49732
- var assistantAnalyserRef = (0, import_react72.useRef)(null);
49733
- var assistantAudioElRef = (0, import_react72.useRef)(null);
49734
- (0, import_react72.useEffect)(function() {
50275
+ var _ref1 = _sliced_to_array((0, import_react73.useState)(false), 2), userIsPending = _ref1[0], setUserIsPending = _ref1[1];
50276
+ var _ref2 = _sliced_to_array((0, import_react73.useState)(false), 2), assistantPlaying = _ref2[0], setAssistantPlaying = _ref2[1];
50277
+ var _ref3 = _sliced_to_array((0, import_react73.useState)(false), 2), assistantPaused = _ref3[0], setAssistantPaused = _ref3[1];
50278
+ var _ref4 = _sliced_to_array((0, import_react73.useState)(true), 2), assistantIsPending = _ref4[0], setAssistantIsPending = _ref4[1];
50279
+ var _ref5 = _sliced_to_array((0, import_react73.useState)(false), 2), assistantIsReady = _ref5[0], setAssistantIsReady = _ref5[1];
50280
+ var _ref6 = _sliced_to_array((0, import_react73.useState)(false), 2), assistantAudioPlayed = _ref6[0], setAssistantAudioPlayed = _ref6[1];
50281
+ var sessionStartedRef = (0, import_react73.useRef)(false);
50282
+ var pcRef = (0, import_react73.useRef)(null);
50283
+ var localStreamRef = (0, import_react73.useRef)(null);
50284
+ var remoteStreamRef = (0, import_react73.useRef)(null);
50285
+ var userAnalyserRef = (0, import_react73.useRef)(null);
50286
+ var assistantAnalyserRef = (0, import_react73.useRef)(null);
50287
+ var assistantAudioElRef = (0, import_react73.useRef)(null);
50288
+ (0, import_react73.useEffect)(function() {
49735
50289
  return function() {
49736
50290
  if (pcRef.current) {
49737
50291
  pcRef.current.close();
@@ -50067,7 +50621,7 @@ var useWebrtcAudioRuntime = function() {
50067
50621
  return _ref7.apply(this, arguments);
50068
50622
  };
50069
50623
  }();
50070
- return (0, import_react72.useMemo)(function() {
50624
+ return (0, import_react73.useMemo)(function() {
50071
50625
  return {
50072
50626
  webrtcAudioRuntime: {
50073
50627
  user: {
@@ -50148,11 +50702,11 @@ var WebrtcAudioRuntimeProvider = function(t0) {
50148
50702
  };
50149
50703
  // src/components/gui/Gui/index.tsx
50150
50704
  var import_react_compiler_runtime104 = require("react-compiler-runtime");
50151
- var import_react75 = require("react");
50705
+ var import_react76 = require("react");
50152
50706
  var import_themes64 = require("@radix-ui/themes");
50153
50707
  // src/hooks/messages/useLatestAssistantMessage/index.ts
50154
50708
  var import_react_compiler_runtime102 = require("react-compiler-runtime");
50155
- var import_react73 = require("react");
50709
+ var import_react74 = require("react");
50156
50710
  var useLatestAssistantMessage = function() {
50157
50711
  var $ = (0, import_react_compiler_runtime102.c)(4);
50158
50712
  var _useMessages = useMessages(), messages2 = _useMessages.messages;
@@ -50185,7 +50739,7 @@ function _temp11(message) {
50185
50739
  // src/hooks/messages/useLatestAssistantMessageWithContent/index.ts
50186
50740
  var import_react_compiler_runtime103 = require("react-compiler-runtime");
50187
50741
  var import_radash18 = require("radash");
50188
- var import_react74 = require("react");
50742
+ var import_react75 = require("react");
50189
50743
  var useLatestAssistantMessageWithContent = function() {
50190
50744
  var $ = (0, import_react_compiler_runtime103.c)(4);
50191
50745
  var _useMessages = useMessages(), messages2 = _useMessages.messages;
@@ -50406,21 +50960,21 @@ function _temp13(rs) {
50406
50960
  }
50407
50961
  // src/components/markdown/MarkdownProvider/index.tsx
50408
50962
  var import_react_compiler_runtime105 = require("react-compiler-runtime");
50409
- var import_react76 = require("react");
50963
+ var import_react77 = require("react");
50410
50964
  var import_jsx_runtime100 = require("react/jsx-runtime");
50411
- var _excluded7 = [
50965
+ var _excluded9 = [
50412
50966
  "children"
50413
50967
  ];
50414
- function _objectWithoutProperties7(e, t) {
50968
+ function _objectWithoutProperties9(e, t) {
50415
50969
  if (null == e) return {};
50416
- var o, r, i = _objectWithoutPropertiesLoose7(e, t);
50970
+ var o, r, i = _objectWithoutPropertiesLoose9(e, t);
50417
50971
  if (Object.getOwnPropertySymbols) {
50418
50972
  var n = Object.getOwnPropertySymbols(e);
50419
50973
  for(r = 0; r < n.length; r++)o = n[r], -1 === t.indexOf(o) && ({}).propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
50420
50974
  }
50421
50975
  return i;
50422
50976
  }
50423
- function _objectWithoutPropertiesLoose7(r, e) {
50977
+ function _objectWithoutPropertiesLoose9(r, e) {
50424
50978
  if (null == r) return {};
50425
50979
  var t = {};
50426
50980
  for(var n in r)if (({}).hasOwnProperty.call(r, n)) {
@@ -50436,7 +50990,7 @@ var MarkdownProvider = function(t0) {
50436
50990
  if ($[0] !== t0) {
50437
50991
  var _t = t0;
50438
50992
  children = _t.children;
50439
- rest = _objectWithoutProperties7(_t, _excluded7);
50993
+ rest = _objectWithoutProperties9(_t, _excluded9);
50440
50994
  _t;
50441
50995
  $[0] = t0;
50442
50996
  $[1] = children;
@@ -50476,7 +51030,7 @@ var MarkdownProvider = function(t0) {
50476
51030
  var import_react_compiler_runtime108 = require("react-compiler-runtime");
50477
51031
  // src/components/annotations/SourceAnnotation/FileCitation/index.tsx
50478
51032
  var import_react_compiler_runtime107 = require("react-compiler-runtime");
50479
- var import_react77 = require("react");
51033
+ var import_react78 = require("react");
50480
51034
  var import_react_icons18 = require("@radix-ui/react-icons");
50481
51035
  var import_themes66 = require("@radix-ui/themes");
50482
51036
  // src/components/annotations/SourceAnnotation/FileCitation/Content.tsx
@@ -50552,7 +51106,7 @@ var import_jsx_runtime102 = require("react/jsx-runtime");
50552
51106
  var FileCitation = function(t0) {
50553
51107
  var $ = (0, import_react_compiler_runtime107.c)(18);
50554
51108
  var annotation = t0.annotation;
50555
- var _ref = _sliced_to_array((0, import_react77.useState)(null), 2), activeFileId = _ref[0], setActiveFileId = _ref[1];
51109
+ var _ref = _sliced_to_array((0, import_react78.useState)(null), 2), activeFileId = _ref[0], setActiveFileId = _ref[1];
50556
51110
  var t1;
50557
51111
  if ($[0] !== annotation.file_citation.file_id) {
50558
51112
  t1 = function() {
@@ -50677,19 +51231,19 @@ var FileCitation = function(t0) {
50677
51231
  };
50678
51232
  // src/components/annotations/SourceAnnotation/index.tsx
50679
51233
  var import_jsx_runtime103 = require("react/jsx-runtime");
50680
- var _excluded8 = [
51234
+ var _excluded10 = [
50681
51235
  "children"
50682
51236
  ];
50683
- function _objectWithoutProperties8(e, t) {
51237
+ function _objectWithoutProperties10(e, t) {
50684
51238
  if (null == e) return {};
50685
- var o, r, i = _objectWithoutPropertiesLoose8(e, t);
51239
+ var o, r, i = _objectWithoutPropertiesLoose10(e, t);
50686
51240
  if (Object.getOwnPropertySymbols) {
50687
51241
  var n = Object.getOwnPropertySymbols(e);
50688
51242
  for(r = 0; r < n.length; r++)o = n[r], -1 === t.indexOf(o) && ({}).propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
50689
51243
  }
50690
51244
  return i;
50691
51245
  }
50692
- function _objectWithoutPropertiesLoose8(r, e) {
51246
+ function _objectWithoutPropertiesLoose10(r, e) {
50693
51247
  if (null == r) return {};
50694
51248
  var t = {};
50695
51249
  for(var n in r)if (({}).hasOwnProperty.call(r, n)) {
@@ -50705,7 +51259,7 @@ var SourceAnnotation = function(t0) {
50705
51259
  if ($[0] !== t0) {
50706
51260
  var _t = t0;
50707
51261
  children = _t.children;
50708
- rest = _objectWithoutProperties8(_t, _excluded8);
51262
+ rest = _objectWithoutProperties10(_t, _excluded10);
50709
51263
  _t;
50710
51264
  $[0] = t0;
50711
51265
  $[1] = children;
@@ -50873,7 +51427,7 @@ var ImageAvatar = function(t0) {
50873
51427
  };
50874
51428
  // src/components/iconAvatars/IconAvatar.tsx
50875
51429
  var import_react_compiler_runtime110 = require("react-compiler-runtime");
50876
- var import_react78 = require("react");
51430
+ var import_react79 = require("react");
50877
51431
  var import_themes68 = require("@radix-ui/themes");
50878
51432
  // src/lib/iconAvatars/iconAvatarComponents.ts
50879
51433
  var import_react_icons19 = require("@radix-ui/react-icons");
@@ -50978,21 +51532,21 @@ var Avatar6 = function(t0) {
50978
51532
  };
50979
51533
  // src/components/components/ComponentsProvider.tsx
50980
51534
  var import_react_compiler_runtime112 = require("react-compiler-runtime");
50981
- var import_react79 = require("react");
51535
+ var import_react80 = require("react");
50982
51536
  var import_jsx_runtime107 = require("react/jsx-runtime");
50983
- var _excluded9 = [
51537
+ var _excluded11 = [
50984
51538
  "children"
50985
51539
  ];
50986
- function _objectWithoutProperties9(e, t) {
51540
+ function _objectWithoutProperties11(e, t) {
50987
51541
  if (null == e) return {};
50988
- var o, r, i = _objectWithoutPropertiesLoose9(e, t);
51542
+ var o, r, i = _objectWithoutPropertiesLoose11(e, t);
50989
51543
  if (Object.getOwnPropertySymbols) {
50990
51544
  var n = Object.getOwnPropertySymbols(e);
50991
51545
  for(r = 0; r < n.length; r++)o = n[r], -1 === t.indexOf(o) && ({}).propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
50992
51546
  }
50993
51547
  return i;
50994
51548
  }
50995
- function _objectWithoutPropertiesLoose9(r, e) {
51549
+ function _objectWithoutPropertiesLoose11(r, e) {
50996
51550
  if (null == r) return {};
50997
51551
  var t = {};
50998
51552
  for(var n in r)if (({}).hasOwnProperty.call(r, n)) {
@@ -51008,7 +51562,7 @@ var ComponentsProvider = function(t0) {
51008
51562
  if ($[0] !== t0) {
51009
51563
  var _t = t0;
51010
51564
  children = _t.children;
51011
- rest = _objectWithoutProperties9(_t, _excluded9);
51565
+ rest = _objectWithoutProperties11(_t, _excluded11);
51012
51566
  _t;
51013
51567
  $[0] = t0;
51014
51568
  $[1] = children;