@superinterface/react 5.3.0-beta.1 → 5.3.0-beta.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -354,7 +354,7 @@ var require_lib = __commonJS({
354
354
  Object.defineProperty(exports, "__esModule", {
355
355
  value: true
356
356
  });
357
- function _objectWithoutPropertiesLoose10(r, e) {
357
+ function _objectWithoutPropertiesLoose12(r, e) {
358
358
  if (null == r) return {};
359
359
  var t = {};
360
360
  for(var n in r)if (({}).hasOwnProperty.call(r, n)) {
@@ -721,7 +721,7 @@ var require_lib = __commonJS({
721
721
  PrimaryTopicNotAllowed: "Topic reference was used in a lexical context without topic binding.",
722
722
  PrimaryTopicRequiresSmartPipeline: 'Topic reference is used, but the pipelineOperator plugin was not passed a "proposal": "hack" or "smart" option.'
723
723
  });
724
- var _excluded10 = [
724
+ var _excluded12 = [
725
725
  "message"
726
726
  ];
727
727
  function defineHidden(obj, key2, value) {
@@ -796,7 +796,7 @@ var require_lib = __commonJS({
796
796
  }
797
797
  } : typeof template === "function" ? {
798
798
  message: template
799
- } : template, message = _ref.message, rest = _objectWithoutPropertiesLoose10(_ref, _excluded10);
799
+ } : template, message = _ref.message, rest = _objectWithoutPropertiesLoose12(_ref, _excluded12);
800
800
  var toMessage = typeof message === "string" ? function() {
801
801
  return message;
802
802
  } : message;
@@ -47220,7 +47220,6 @@ var useRecorder = function(_ref) {
47220
47220
  };
47221
47221
  // src/hooks/audioThreads/useMessageAudio/index.ts
47222
47222
  import { useMemo as useMemo17, useRef as useRef8, useState as useState9, useEffect as useEffect10, useCallback as useCallback7 } from "react";
47223
- import nlp from "compromise";
47224
47223
  import { Howler } from "howler";
47225
47224
  import { useAudioPlayer as useAudioPlayer2 } from "react-use-audio-player";
47226
47225
  // src/hooks/audioThreads/useMessageAudio/lib/input.ts
@@ -47288,198 +47287,851 @@ function _toPrimitive47(t, r) {
47288
47287
  }
47289
47288
  return ("string" === r ? String : Number)(t);
47290
47289
  }
47291
- var getMessageSentences = function(_ref) {
47292
- var messageId = _ref.messageId, input2 = _ref.input;
47293
- var sentences = nlp(input2).sentences().json();
47294
- return sentences.map(function(sentence) {
47295
- return {
47296
- messageId: messageId,
47297
- sentence: sentence.text
47298
- };
47299
- });
47290
+ function asyncGeneratorStep11(n, t, e, r, o, a, c) {
47291
+ try {
47292
+ var i = n[a](c), u = i.value;
47293
+ } catch (n2) {
47294
+ return void e(n2);
47295
+ }
47296
+ i.done ? t(u) : Promise.resolve(u).then(r, o);
47297
+ }
47298
+ function _asyncToGenerator11(n) {
47299
+ return function() {
47300
+ var t = this, e = arguments;
47301
+ return new Promise(function(r, o) {
47302
+ var a = n.apply(t, e);
47303
+ function _next(n2) {
47304
+ asyncGeneratorStep11(a, r, o, _next, _throw, "next", n2);
47305
+ }
47306
+ function _throw(n2) {
47307
+ asyncGeneratorStep11(a, r, o, _next, _throw, "throw", n2);
47308
+ }
47309
+ _next(void 0);
47310
+ });
47311
+ };
47312
+ }
47313
+ var THROTTLE_MS = 80;
47314
+ var MAX_SEG_CACHE = 256;
47315
+ var KEEP_FINISHED_MESSAGES = 12;
47316
+ var FULL_SENTENCE_REGEX = /[\.?!]$/;
47317
+ var hasLetters = function(s) {
47318
+ for(var i = 0; i < s.length; i++){
47319
+ var ch = s.charAt(i);
47320
+ if (ch.toLowerCase() !== ch.toUpperCase()) return true;
47321
+ }
47322
+ return false;
47323
+ };
47324
+ var isSentencePunct = function(ch) {
47325
+ return ch === "." || ch === "!" || ch === "?" || ch === "\u3002" || ch === "\uFF01" || ch === "\uFF1F";
47300
47326
  };
47301
- var useMessageAudio = function(_ref2) {
47302
- var _latestMessageProps$l2;
47303
- var _onEnd = _ref2.onEnd, passedPlay = _ref2.play, _ref2_fullSentenceRegex = _ref2.fullSentenceRegex, fullSentenceRegex = _ref2_fullSentenceRegex === void 0 ? /[\.?!]$/ : _ref2_fullSentenceRegex;
47327
+ var normalizeBoundaries = function(text) {
47328
+ var out = "";
47329
+ for(var i = 0; i < text.length; i++){
47330
+ var ch = text.charAt(i);
47331
+ out += ch;
47332
+ if (isSentencePunct(ch)) {
47333
+ var next = text.charAt(i + 1);
47334
+ if (next && next !== " " && hasLetters(next)) {
47335
+ out += " ";
47336
+ }
47337
+ }
47338
+ }
47339
+ return out;
47340
+ };
47341
+ var splitSentencesFast = function(raw) {
47342
+ var t = normalizeBoundaries(raw.replace(/\s+/g, " ").trim());
47343
+ if (!t) return [];
47344
+ var parts = t.split(RegExp("(?<=[.!?])\\s+(?=[^\\s])", "g"));
47345
+ var filtered = [];
47346
+ for(var i = 0; i < parts.length; i++){
47347
+ var p = parts[i].trim();
47348
+ if (p && hasLetters(p)) filtered.push(p);
47349
+ }
47350
+ return filtered;
47351
+ };
47352
+ var getIncrementalSegments = function(prev, nextInput, now) {
47353
+ if (!prev) return {
47354
+ input: nextInput,
47355
+ segments: splitSentencesFast(nextInput),
47356
+ touched: now
47357
+ };
47358
+ if (nextInput === prev.input) return {
47359
+ input: prev.input,
47360
+ segments: prev.segments,
47361
+ touched: now
47362
+ };
47363
+ if (nextInput.startsWith(prev.input)) {
47364
+ var prevSegments = prev.segments;
47365
+ var prevLast = prevSegments[prevSegments.length - 1] || "";
47366
+ var baseLen = prev.input.length - prevLast.length;
47367
+ if (baseLen >= 0 && prev.input.slice(baseLen) === prevLast) {
47368
+ var tail = nextInput.slice(baseLen);
47369
+ var tailSegments = splitSentencesFast(tail);
47370
+ var merged = prevSegments.length > 0 ? prevSegments.slice(0, -1).concat(tailSegments) : tailSegments;
47371
+ return {
47372
+ input: nextInput,
47373
+ segments: merged,
47374
+ touched: now
47375
+ };
47376
+ }
47377
+ }
47378
+ return {
47379
+ input: nextInput,
47380
+ segments: splitSentencesFast(nextInput),
47381
+ touched: now
47382
+ };
47383
+ };
47384
+ var segmentsEqual = function(a, b) {
47385
+ if (a === b) return true;
47386
+ if (a.length !== b.length) return false;
47387
+ for(var i = 0; i < a.length; i++){
47388
+ if (a[i] !== b[i]) return false;
47389
+ }
47390
+ return true;
47391
+ };
47392
+ var useMessageAudio = function(_ref) {
47393
+ var onEnd = _ref.onEnd, providedPlay = _ref.play, providedPlaySegments = _ref.playSegments, providedGetSegments = _ref.getSegments;
47304
47394
  var _useState9 = _sliced_to_array(useState9(false), 2), isAudioPlayed = _useState9[0], setIsAudioPlayed = _useState9[1];
47305
- var _useState91 = _sliced_to_array(useState9([]), 2), stoppedMessageIds = _useState91[0], setStoppedMessageIds = _useState91[1];
47306
- var _useState92 = _sliced_to_array(useState9([]), 2), playedMessageSentences = _useState92[0], setPlayedMessageSentences = _useState92[1];
47395
+ var isAudioPlayedRef = useRef8(false);
47307
47396
  var audioPlayer = useAudioPlayer2();
47308
47397
  var nextAudioPlayer = useAudioPlayer2();
47309
47398
  var superinterfaceContext = useSuperinterfaceContext();
47310
- var _useState93 = _sliced_to_array(useState9(false), 2), isPlaying = _useState93[0], setIsPlaying = _useState93[1];
47311
- var isLastSentencePlayedRef = useRef8(false);
47312
- var latestMessageProps = useLatestMessage();
47313
- var messagesProps = useMessages();
47399
+ var _useState91 = _sliced_to_array(useState9(false), 2), isPlaying = _useState91[0], setIsPlaying = _useState91[1];
47400
+ var _useState92 = _sliced_to_array(useState9([]), 2), audioQueue = _useState92[0], setAudioQueue = _useState92[1];
47401
+ var audioQueueRef = useRef8([]);
47314
47402
  useEffect10(function() {
47315
- if (!isPlaying) return;
47316
- isLastSentencePlayedRef.current = false;
47403
+ audioQueueRef.current = audioQueue;
47317
47404
  }, [
47318
- isPlaying
47405
+ audioQueue
47319
47406
  ]);
47320
- var unplayedMessageSentences = useMemo17(function() {
47321
- var playableMessages = _to_consumable_array(messagesProps.messages).reverse().filter(function(message) {
47322
- if (message.role !== "assistant") return false;
47323
- if (stoppedMessageIds.includes(message.id)) return false;
47324
- return true;
47407
+ var pickLockRef = useRef8(false);
47408
+ var activeSegmentsRef = useRef8(0);
47409
+ var currentSegmentRef = useRef8(null);
47410
+ var onEndPendingRef = useRef8(false);
47411
+ var messagesProps = useMessages();
47412
+ var messagesByIdRef = useRef8(/* @__PURE__ */ new Map());
47413
+ var segCacheRef = useRef8(/* @__PURE__ */ new Map());
47414
+ var mirrorTimerRef = useRef8(null);
47415
+ var pendingMirrorRef = useRef8(false);
47416
+ var markAudioPlayed = useCallback7(function() {
47417
+ if (!isAudioPlayedRef.current) {
47418
+ isAudioPlayedRef.current = true;
47419
+ setIsAudioPlayed(true);
47420
+ }
47421
+ }, []);
47422
+ var segmentToText = useCallback7(function(segment) {
47423
+ if (typeof segment === "string") return segment;
47424
+ if (segment && (typeof segment === "undefined" ? "undefined" : _type_of(segment)) === "object" && "text" in segment) {
47425
+ var value = segment.text;
47426
+ if (typeof value === "string") return value;
47427
+ }
47428
+ if (segment == null) return void 0;
47429
+ var stringified = String(segment);
47430
+ return stringified.length > 0 ? stringified : void 0;
47431
+ }, []);
47432
+ var checkForCompletion = useCallback7(function() {
47433
+ if (activeSegmentsRef.current > 0) return;
47434
+ var hasPending = audioQueueRef.current.some(function(m) {
47435
+ return !m.stopped && (m.nextIndex < m.segments.length || m.status === "in_progress");
47325
47436
  });
47326
- var messageInputs = playableMessages.map(function(message_0) {
47327
- return {
47328
- message: message_0,
47329
- input: input({
47330
- message: message_0
47331
- })
47437
+ if (hasPending) {
47438
+ onEndPendingRef.current = true;
47439
+ return;
47440
+ }
47441
+ if (!onEndPendingRef.current) return;
47442
+ onEndPendingRef.current = false;
47443
+ onEnd();
47444
+ }, [
47445
+ onEnd
47446
+ ]);
47447
+ useEffect10(function() {
47448
+ if (mirrorTimerRef.current != null) {
47449
+ pendingMirrorRef.current = true;
47450
+ return;
47451
+ }
47452
+ var run = /* @__PURE__ */ function() {
47453
+ var _ref2 = _asyncToGenerator11(function() {
47454
+ var assistantsDesc, assistantsAsc, nowTs, lastNIds, prevQueue, prevById, prevUnfinishedIds, streamingIds, includeIds, segCache, nextQueue, changed, touch, i, _existing$nextIndex, _existing$stopped, m_6, rawInput, prevEntry, nextEntry, playableSegments, customSegments, safeSegments, base, fullSegments, readyCount, last3, readySegments, existing, nextIndex, stopped, reuse, unfinished, finished, prunedFinished, combined, i_0, idsInQueue, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, id_3, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, id_4, entries, toRemove, i_1;
47455
+ return _ts_generator(this, function(_state) {
47456
+ switch(_state.label){
47457
+ case 0:
47458
+ assistantsDesc = messagesProps.messages.filter(function(m_0) {
47459
+ return m_0.role === "assistant";
47460
+ });
47461
+ assistantsAsc = assistantsDesc.slice().reverse();
47462
+ nowTs = typeof performance !== "undefined" && performance.now ? performance.now() : Date.now();
47463
+ lastNIds = new Set(assistantsAsc.slice(Math.max(0, assistantsAsc.length - KEEP_FINISHED_MESSAGES)).map(function(m_1) {
47464
+ return String(m_1.id);
47465
+ }));
47466
+ prevQueue = audioQueueRef.current;
47467
+ prevById = new Map(prevQueue.map(function(p) {
47468
+ return [
47469
+ p.id,
47470
+ p
47471
+ ];
47472
+ }));
47473
+ prevUnfinishedIds = new Set(prevQueue.filter(function(m_2) {
47474
+ return !m_2.stopped && (m_2.status === "in_progress" || m_2.nextIndex < m_2.segments.length);
47475
+ }).map(function(m_3) {
47476
+ return m_3.id;
47477
+ }));
47478
+ streamingIds = new Set(assistantsAsc.filter(function(m_4) {
47479
+ return m_4.status === "in_progress";
47480
+ }).map(function(m_5) {
47481
+ return String(m_5.id);
47482
+ }));
47483
+ includeIds = /* @__PURE__ */ new Set();
47484
+ lastNIds.forEach(function(id) {
47485
+ return includeIds.add(id);
47486
+ });
47487
+ prevUnfinishedIds.forEach(function(id_0) {
47488
+ return includeIds.add(id_0);
47489
+ });
47490
+ streamingIds.forEach(function(id_1) {
47491
+ return includeIds.add(id_1);
47492
+ });
47493
+ segCache = segCacheRef.current;
47494
+ nextQueue = [];
47495
+ changed = false;
47496
+ touch = function(id_2, entry) {
47497
+ segCache.set(id_2, {
47498
+ input: entry.input,
47499
+ segments: entry.segments,
47500
+ touched: nowTs
47501
+ });
47502
+ };
47503
+ i = 0;
47504
+ _state.label = 1;
47505
+ case 1:
47506
+ if (!(i < assistantsAsc.length)) return [
47507
+ 3,
47508
+ 6
47509
+ ];
47510
+ m_6 = assistantsAsc[i];
47511
+ if (!includeIds.has(String(m_6.id))) return [
47512
+ 3,
47513
+ 5
47514
+ ];
47515
+ rawInput = input({
47516
+ message: m_6
47517
+ });
47518
+ if (rawInput == null) {
47519
+ segCache.delete(m_6.id);
47520
+ messagesByIdRef.current.delete(m_6.id);
47521
+ return [
47522
+ 3,
47523
+ 5
47524
+ ];
47525
+ }
47526
+ messagesByIdRef.current.set(m_6.id, m_6);
47527
+ prevEntry = segCache.get(m_6.id);
47528
+ nextEntry = void 0;
47529
+ playableSegments = void 0;
47530
+ if (!providedGetSegments) return [
47531
+ 3,
47532
+ 3
47533
+ ];
47534
+ return [
47535
+ 4,
47536
+ Promise.resolve(providedGetSegments({
47537
+ message: m_6,
47538
+ rawInput: rawInput
47539
+ }))
47540
+ ];
47541
+ case 2:
47542
+ customSegments = _state.sent();
47543
+ safeSegments = Array.isArray(customSegments) ? customSegments : [];
47544
+ nextEntry = {
47545
+ input: rawInput,
47546
+ segments: safeSegments,
47547
+ touched: nowTs
47548
+ };
47549
+ playableSegments = safeSegments;
47550
+ return [
47551
+ 3,
47552
+ 4
47553
+ ];
47554
+ case 3:
47555
+ base = getIncrementalSegments(prevEntry, rawInput, nowTs);
47556
+ nextEntry = {
47557
+ input: base.input,
47558
+ segments: base.segments,
47559
+ touched: nowTs
47560
+ };
47561
+ fullSegments = base.segments;
47562
+ readyCount = fullSegments.length;
47563
+ if (readyCount > 0 && !isOptimistic({
47564
+ id: m_6.id
47565
+ }) && m_6.status === "in_progress") {
47566
+ last3 = fullSegments[fullSegments.length - 1];
47567
+ if (last3 && !FULL_SENTENCE_REGEX.test(last3)) readyCount -= 1;
47568
+ }
47569
+ readySegments = fullSegments.slice(0, Math.max(0, readyCount));
47570
+ playableSegments = readyCount === fullSegments.length ? fullSegments : readySegments;
47571
+ _state.label = 4;
47572
+ case 4:
47573
+ touch(m_6.id, nextEntry);
47574
+ existing = prevById.get(m_6.id);
47575
+ nextIndex = Math.min((_existing$nextIndex = existing === null || existing === void 0 ? void 0 : existing.nextIndex) !== null && _existing$nextIndex !== void 0 ? _existing$nextIndex : 0, playableSegments.length);
47576
+ stopped = (_existing$stopped = existing === null || existing === void 0 ? void 0 : existing.stopped) !== null && _existing$stopped !== void 0 ? _existing$stopped : false;
47577
+ reuse = !!existing && existing.status === m_6.status && existing.rawInput === rawInput && existing.nextIndex === nextIndex && existing.stopped === stopped && segmentsEqual(existing.segments, playableSegments);
47578
+ if (reuse) {
47579
+ nextQueue.push(existing);
47580
+ } else {
47581
+ nextQueue.push({
47582
+ id: m_6.id,
47583
+ status: m_6.status,
47584
+ segments: playableSegments,
47585
+ nextIndex: nextIndex,
47586
+ stopped: stopped,
47587
+ rawInput: rawInput
47588
+ });
47589
+ changed = true;
47590
+ }
47591
+ _state.label = 5;
47592
+ case 5:
47593
+ i++;
47594
+ return [
47595
+ 3,
47596
+ 1
47597
+ ];
47598
+ case 6:
47599
+ unfinished = nextQueue.filter(function(m_7) {
47600
+ return !m_7.stopped && (m_7.status === "in_progress" || m_7.nextIndex < m_7.segments.length);
47601
+ });
47602
+ finished = nextQueue.filter(function(m_8) {
47603
+ return !(!m_8.stopped && (m_8.status === "in_progress" || m_8.nextIndex < m_8.segments.length));
47604
+ });
47605
+ prunedFinished = finished.length > KEEP_FINISHED_MESSAGES ? finished.slice(finished.length - KEEP_FINISHED_MESSAGES) : finished;
47606
+ combined = _to_consumable_array(unfinished).concat(_to_consumable_array(prunedFinished));
47607
+ if (combined.some(function(m_9) {
47608
+ return !m_9.stopped && (m_9.nextIndex < m_9.segments.length || m_9.status === "in_progress");
47609
+ })) {
47610
+ onEndPendingRef.current = true;
47611
+ }
47612
+ if (!changed) {
47613
+ if (combined.length !== prevQueue.length) {
47614
+ changed = true;
47615
+ } else {
47616
+ for(i_0 = 0; i_0 < combined.length; i_0++){
47617
+ if (combined[i_0] !== prevQueue[i_0]) {
47618
+ changed = true;
47619
+ break;
47620
+ }
47621
+ }
47622
+ }
47623
+ }
47624
+ idsInQueue = new Set(combined.map(function(m_10) {
47625
+ return m_10.id;
47626
+ }));
47627
+ _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
47628
+ try {
47629
+ for(_iterator = Array.from(segCache.keys())[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
47630
+ id_3 = _step.value;
47631
+ if (!idsInQueue.has(id_3)) segCache.delete(id_3);
47632
+ }
47633
+ } catch (err) {
47634
+ _didIteratorError = true;
47635
+ _iteratorError = err;
47636
+ } finally{
47637
+ try {
47638
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
47639
+ _iterator.return();
47640
+ }
47641
+ } finally{
47642
+ if (_didIteratorError) {
47643
+ throw _iteratorError;
47644
+ }
47645
+ }
47646
+ }
47647
+ _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
47648
+ try {
47649
+ for(_iterator1 = Array.from(messagesByIdRef.current.keys())[Symbol.iterator](); !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
47650
+ id_4 = _step1.value;
47651
+ if (!idsInQueue.has(id_4)) messagesByIdRef.current.delete(id_4);
47652
+ }
47653
+ } catch (err) {
47654
+ _didIteratorError1 = true;
47655
+ _iteratorError1 = err;
47656
+ } finally{
47657
+ try {
47658
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
47659
+ _iterator1.return();
47660
+ }
47661
+ } finally{
47662
+ if (_didIteratorError1) {
47663
+ throw _iteratorError1;
47664
+ }
47665
+ }
47666
+ }
47667
+ if (changed) setAudioQueue(combined);
47668
+ if (segCache.size > MAX_SEG_CACHE) {
47669
+ entries = Array.from(segCache.entries());
47670
+ entries.sort(function(a, b) {
47671
+ return a[1].touched - b[1].touched;
47672
+ });
47673
+ toRemove = segCache.size - MAX_SEG_CACHE;
47674
+ for(i_1 = 0; i_1 < toRemove; i_1++)segCache.delete(entries[i_1][0]);
47675
+ }
47676
+ return [
47677
+ 2
47678
+ ];
47679
+ }
47680
+ });
47681
+ });
47682
+ return function run2() {
47683
+ return _ref2.apply(this, arguments);
47332
47684
  };
47333
- }).filter(function(_ref3) {
47334
- var input2 = _ref3.input;
47335
- return input2 !== null;
47685
+ }();
47686
+ var schedule = function() {
47687
+ mirrorTimerRef.current = window.setTimeout(/* @__PURE__ */ _asyncToGenerator11(function() {
47688
+ return _ts_generator(this, function(_state) {
47689
+ switch(_state.label){
47690
+ case 0:
47691
+ mirrorTimerRef.current = null;
47692
+ _state.label = 1;
47693
+ case 1:
47694
+ _state.trys.push([
47695
+ 1,
47696
+ ,
47697
+ 3,
47698
+ 4
47699
+ ]);
47700
+ return [
47701
+ 4,
47702
+ run()
47703
+ ];
47704
+ case 2:
47705
+ _state.sent();
47706
+ return [
47707
+ 3,
47708
+ 4
47709
+ ];
47710
+ case 3:
47711
+ if (pendingMirrorRef.current) {
47712
+ pendingMirrorRef.current = false;
47713
+ schedule();
47714
+ }
47715
+ return [
47716
+ 7
47717
+ ];
47718
+ case 4:
47719
+ return [
47720
+ 2
47721
+ ];
47722
+ }
47723
+ });
47724
+ }), THROTTLE_MS);
47725
+ };
47726
+ schedule();
47727
+ return function() {
47728
+ if (mirrorTimerRef.current != null) {
47729
+ clearTimeout(mirrorTimerRef.current);
47730
+ mirrorTimerRef.current = null;
47731
+ }
47732
+ pendingMirrorRef.current = false;
47733
+ };
47734
+ }, [
47735
+ messagesProps.messages,
47736
+ providedGetSegments
47737
+ ]);
47738
+ var defaultPlay = useCallback7(/* @__PURE__ */ function() {
47739
+ var _ref5 = _asyncToGenerator11(function(_ref4) {
47740
+ var input2, onPlay, onStop, onEnd_0, searchParams;
47741
+ return _ts_generator(this, function(_state) {
47742
+ switch(_state.label){
47743
+ case 0:
47744
+ input2 = _ref4.input, onPlay = _ref4.onPlay, onStop = _ref4.onStop, onEnd_0 = _ref4.onEnd;
47745
+ searchParams = new URLSearchParams(_objectSpread47({
47746
+ input: input2
47747
+ }, superinterfaceContext.variables));
47748
+ return [
47749
+ 4,
47750
+ new Promise(function(resolve) {
47751
+ var settled = false;
47752
+ var settle = function(cb) {
47753
+ if (settled) return;
47754
+ settled = true;
47755
+ cb();
47756
+ resolve();
47757
+ };
47758
+ audioPlayer.load("".concat(superinterfaceContext.baseUrl, "/audio-runtimes/tts?").concat(searchParams), {
47759
+ format: "mp3",
47760
+ autoplay: isAudioPlayedRef.current,
47761
+ html5: isHtmlAudioSupported,
47762
+ onplay: function() {
47763
+ markAudioPlayed();
47764
+ onPlay();
47765
+ },
47766
+ onstop: function() {
47767
+ settle(onStop);
47768
+ },
47769
+ onend: function() {
47770
+ settle(onEnd_0);
47771
+ },
47772
+ onload: function() {
47773
+ var current = currentSegmentRef.current;
47774
+ if (!current) return;
47775
+ var owner = audioQueueRef.current.find(function(m_11) {
47776
+ return m_11.id === current.messageId;
47777
+ });
47778
+ if (!owner) return;
47779
+ var nextSegment = owner.segments[current.nextIndex];
47780
+ if (!nextSegment) return;
47781
+ var nextText = segmentToText(nextSegment);
47782
+ if (!nextText) return;
47783
+ var nextSearchParams = new URLSearchParams(_objectSpread47({
47784
+ input: nextText
47785
+ }, superinterfaceContext.variables));
47786
+ nextAudioPlayer.load("".concat(superinterfaceContext.baseUrl, "/audio-runtimes/tts?").concat(nextSearchParams), {
47787
+ format: "mp3",
47788
+ autoplay: false,
47789
+ html5: isHtmlAudioSupported
47790
+ });
47791
+ }
47792
+ });
47793
+ })
47794
+ ];
47795
+ case 1:
47796
+ _state.sent();
47797
+ return [
47798
+ 2
47799
+ ];
47800
+ }
47801
+ });
47336
47802
  });
47337
- var messageSentences = messageInputs.flatMap(function(_ref4) {
47338
- var message_1 = _ref4.message, input_0 = _ref4.input;
47339
- return getMessageSentences({
47340
- messageId: message_1.id,
47341
- input: input_0
47803
+ return function(_x) {
47804
+ return _ref5.apply(this, arguments);
47805
+ };
47806
+ }(), [
47807
+ audioPlayer,
47808
+ nextAudioPlayer,
47809
+ superinterfaceContext,
47810
+ segmentToText
47811
+ ]);
47812
+ var playInternal = useCallback7(/* @__PURE__ */ function() {
47813
+ var _ref6 = _asyncToGenerator11(function(segment_0, handlers2) {
47814
+ var text, args;
47815
+ return _ts_generator(this, function(_state) {
47816
+ switch(_state.label){
47817
+ case 0:
47818
+ text = segmentToText(segment_0);
47819
+ if (!text) {
47820
+ handlers2.onEnd();
47821
+ return [
47822
+ 2
47823
+ ];
47824
+ }
47825
+ args = {
47826
+ input: text,
47827
+ onPlay: function() {
47828
+ markAudioPlayed();
47829
+ handlers2.onPlay();
47830
+ },
47831
+ onStop: handlers2.onStop,
47832
+ onEnd: handlers2.onEnd
47833
+ };
47834
+ if (!providedPlay) return [
47835
+ 3,
47836
+ 2
47837
+ ];
47838
+ return [
47839
+ 4,
47840
+ Promise.resolve(providedPlay(args))
47841
+ ];
47842
+ case 1:
47843
+ _state.sent();
47844
+ return [
47845
+ 2
47846
+ ];
47847
+ case 2:
47848
+ return [
47849
+ 4,
47850
+ defaultPlay(args)
47851
+ ];
47852
+ case 3:
47853
+ _state.sent();
47854
+ return [
47855
+ 2
47856
+ ];
47857
+ }
47342
47858
  });
47343
47859
  });
47344
- return messageSentences.filter(function(ms) {
47345
- return !playedMessageSentences.find(function(pms) {
47346
- return pms.messageId === ms.messageId && pms.sentence === ms.sentence;
47860
+ return function(_x2, _x3) {
47861
+ return _ref6.apply(this, arguments);
47862
+ };
47863
+ }(), [
47864
+ segmentToText,
47865
+ providedPlay,
47866
+ defaultPlay,
47867
+ markAudioPlayed
47868
+ ]);
47869
+ var defaultPlaySegments = useCallback7(/* @__PURE__ */ function() {
47870
+ var _ref8 = _asyncToGenerator11(function(_ref7) {
47871
+ var segments, message, play, i_2, current_0;
47872
+ return _ts_generator(this, function(_state) {
47873
+ switch(_state.label){
47874
+ case 0:
47875
+ segments = _ref7.segments, message = _ref7.message, play = _ref7.play;
47876
+ i_2 = 0;
47877
+ _state.label = 1;
47878
+ case 1:
47879
+ if (!(i_2 < segments.length)) return [
47880
+ 3,
47881
+ 4
47882
+ ];
47883
+ return [
47884
+ 4,
47885
+ play(segments[i_2])
47886
+ ];
47887
+ case 2:
47888
+ _state.sent();
47889
+ current_0 = audioQueueRef.current.find(function(m_12) {
47890
+ return m_12.id === message.id;
47891
+ });
47892
+ if (!current_0 || current_0.stopped) return [
47893
+ 3,
47894
+ 4
47895
+ ];
47896
+ _state.label = 3;
47897
+ case 3:
47898
+ i_2++;
47899
+ return [
47900
+ 3,
47901
+ 1
47902
+ ];
47903
+ case 4:
47904
+ return [
47905
+ 2
47906
+ ];
47907
+ }
47347
47908
  });
47348
47909
  });
47349
- }, [
47350
- messagesProps,
47351
- playedMessageSentences
47910
+ return function(_x4) {
47911
+ return _ref8.apply(this, arguments);
47912
+ };
47913
+ }(), []);
47914
+ var playSegmentsImpl = useCallback7(/* @__PURE__ */ function() {
47915
+ var _ref9 = _asyncToGenerator11(function(args_0) {
47916
+ return _ts_generator(this, function(_state) {
47917
+ switch(_state.label){
47918
+ case 0:
47919
+ if (!providedPlaySegments) return [
47920
+ 3,
47921
+ 2
47922
+ ];
47923
+ return [
47924
+ 4,
47925
+ Promise.resolve(providedPlaySegments(args_0))
47926
+ ];
47927
+ case 1:
47928
+ _state.sent();
47929
+ return [
47930
+ 2
47931
+ ];
47932
+ case 2:
47933
+ return [
47934
+ 4,
47935
+ defaultPlaySegments(args_0)
47936
+ ];
47937
+ case 3:
47938
+ _state.sent();
47939
+ return [
47940
+ 2
47941
+ ];
47942
+ }
47943
+ });
47944
+ });
47945
+ return function(_x5) {
47946
+ return _ref9.apply(this, arguments);
47947
+ };
47948
+ }(), [
47949
+ providedPlaySegments,
47950
+ defaultPlaySegments
47352
47951
  ]);
47353
- var defaultPlay = useCallback7(function(_ref5) {
47354
- var input_1 = _ref5.input, onPlay = _ref5.onPlay, onStop = _ref5.onStop, onEnd_0 = _ref5.onEnd;
47355
- var searchParams = new URLSearchParams(_objectSpread47({
47356
- input: input_1
47357
- }, superinterfaceContext.variables));
47358
- audioPlayer.load("".concat(superinterfaceContext.baseUrl, "/audio-runtimes/tts?").concat(searchParams), {
47359
- format: "mp3",
47360
- autoplay: isAudioPlayed,
47361
- html5: isHtmlAudioSupported,
47362
- onplay: onPlay,
47363
- onstop: onStop,
47364
- onload: function() {
47365
- var nextUnplayedMessageSentence = unplayedMessageSentences[1];
47366
- if (!nextUnplayedMessageSentence) return;
47367
- var isNextFullSentence = fullSentenceRegex.test(nextUnplayedMessageSentence.sentence);
47368
- if (!isNextFullSentence) return;
47369
- var nextSearchParams = new URLSearchParams(_objectSpread47({
47370
- input: nextUnplayedMessageSentence.sentence
47371
- }, superinterfaceContext.variables));
47372
- nextAudioPlayer.load("".concat(superinterfaceContext.baseUrl, "/audio-runtimes/tts?").concat(nextSearchParams), {
47373
- format: "mp3",
47374
- autoplay: false,
47375
- html5: isHtmlAudioSupported
47376
- });
47377
- },
47378
- onend: onEnd_0
47952
+ var handleStop = useCallback7(function(messageId) {
47953
+ setAudioQueue(function(prev) {
47954
+ return prev.map(function(m_13) {
47955
+ return m_13.id === messageId ? _objectSpread47(_objectSpread47({}, m_13), {}, {
47956
+ stopped: true
47957
+ }) : m_13;
47958
+ });
47379
47959
  });
47960
+ activeSegmentsRef.current = 0;
47961
+ setIsPlaying(false);
47962
+ currentSegmentRef.current = null;
47963
+ pickLockRef.current = false;
47964
+ checkForCompletion();
47380
47965
  }, [
47381
- superinterfaceContext,
47382
- unplayedMessageSentences,
47383
- audioPlayer,
47384
- nextAudioPlayer,
47385
- isAudioPlayed,
47386
- fullSentenceRegex
47966
+ checkForCompletion
47387
47967
  ]);
47388
- var play = useMemo17(function() {
47389
- return passedPlay || defaultPlay;
47968
+ var handleSegmentEnd = useCallback7(function() {
47969
+ if (activeSegmentsRef.current > 0) activeSegmentsRef.current -= 1;
47970
+ if (activeSegmentsRef.current === 0) {
47971
+ setIsPlaying(false);
47972
+ currentSegmentRef.current = null;
47973
+ pickLockRef.current = false;
47974
+ checkForCompletion();
47975
+ }
47390
47976
  }, [
47391
- passedPlay,
47392
- defaultPlay
47977
+ checkForCompletion
47393
47978
  ]);
47394
47979
  useEffect10(function() {
47395
47980
  if (isPlaying) return;
47396
- if (audioPlayer.playing) return;
47397
- if (!latestMessageProps.latestMessage) return;
47398
- if (latestMessageProps.latestMessage.role !== "assistant") return;
47399
- var firstUnplayedMessageSentence = unplayedMessageSentences[0];
47400
- if (!firstUnplayedMessageSentence) {
47401
- return;
47981
+ if (pickLockRef.current) return;
47982
+ if (audioQueue.length === 0) return;
47983
+ var candidate = null;
47984
+ for(var i_3 = 0; i_3 < audioQueue.length; i_3++){
47985
+ var msg = audioQueue[i_3];
47986
+ if (msg.stopped) continue;
47987
+ if (msg.nextIndex >= msg.segments.length) continue;
47988
+ var message_0 = messagesByIdRef.current.get(msg.id);
47989
+ if (!message_0) continue;
47990
+ candidate = {
47991
+ messageId: msg.id,
47992
+ message: message_0,
47993
+ rawInput: msg.rawInput,
47994
+ startIndex: msg.nextIndex,
47995
+ segments: msg.segments.slice(msg.nextIndex)
47996
+ };
47997
+ break;
47402
47998
  }
47403
- var isFullSentence = isOptimistic({
47404
- id: latestMessageProps.latestMessage.id
47405
- }) || latestMessageProps.latestMessage.status !== "in_progress" || fullSentenceRegex.test(firstUnplayedMessageSentence.sentence);
47406
- if (!isFullSentence) return;
47999
+ if (!candidate || candidate.segments.length === 0) return;
48000
+ pickLockRef.current = true;
47407
48001
  setIsPlaying(true);
47408
- setPlayedMessageSentences(function(prev) {
47409
- return _to_consumable_array(prev).concat([
47410
- firstUnplayedMessageSentence
47411
- ]);
48002
+ setAudioQueue(function(prev_0) {
48003
+ return prev_0.map(function(m_14) {
48004
+ return m_14.id === candidate.messageId ? _objectSpread47(_objectSpread47({}, m_14), {}, {
48005
+ nextIndex: m_14.segments.length
48006
+ }) : m_14;
48007
+ });
47412
48008
  });
47413
- var input_2 = firstUnplayedMessageSentence.sentence;
47414
- play({
47415
- input: input_2,
47416
- onPlay: function() {
47417
- setIsAudioPlayed(true);
47418
- },
47419
- onStop: function() {
47420
- setStoppedMessageIds(function(prev_0) {
47421
- return _to_consumable_array(prev_0).concat([
47422
- firstUnplayedMessageSentence.messageId
47423
- ]);
48009
+ var runPlayback = /* @__PURE__ */ function() {
48010
+ var _ref0 = _asyncToGenerator11(function() {
48011
+ var nextIndex_0, error;
48012
+ return _ts_generator(this, function(_state) {
48013
+ switch(_state.label){
48014
+ case 0:
48015
+ nextIndex_0 = candidate.startIndex;
48016
+ _state.label = 1;
48017
+ case 1:
48018
+ _state.trys.push([
48019
+ 1,
48020
+ 3,
48021
+ 4,
48022
+ 5
48023
+ ]);
48024
+ return [
48025
+ 4,
48026
+ playSegmentsImpl({
48027
+ segments: candidate.segments,
48028
+ startIndex: candidate.startIndex,
48029
+ message: candidate.message,
48030
+ play: function() {
48031
+ var _play = _asyncToGenerator11(function(segment_1) {
48032
+ return _ts_generator(this, function(_state) {
48033
+ switch(_state.label){
48034
+ case 0:
48035
+ activeSegmentsRef.current += 1;
48036
+ nextIndex_0 += 1;
48037
+ currentSegmentRef.current = {
48038
+ messageId: candidate.messageId,
48039
+ nextIndex: nextIndex_0
48040
+ };
48041
+ return [
48042
+ 4,
48043
+ playInternal(segment_1, {
48044
+ onPlay: function() {},
48045
+ onStop: function() {
48046
+ return handleStop(candidate.messageId);
48047
+ },
48048
+ onEnd: function() {
48049
+ return handleSegmentEnd();
48050
+ }
48051
+ })
48052
+ ];
48053
+ case 1:
48054
+ _state.sent();
48055
+ return [
48056
+ 2
48057
+ ];
48058
+ }
48059
+ });
48060
+ });
48061
+ function play(_x6) {
48062
+ return _play.apply(this, arguments);
48063
+ }
48064
+ return play;
48065
+ }()
48066
+ })
48067
+ ];
48068
+ case 2:
48069
+ _state.sent();
48070
+ return [
48071
+ 3,
48072
+ 5
48073
+ ];
48074
+ case 3:
48075
+ error = _state.sent();
48076
+ handleStop(candidate.messageId);
48077
+ console.error(error);
48078
+ return [
48079
+ 3,
48080
+ 5
48081
+ ];
48082
+ case 4:
48083
+ checkForCompletion();
48084
+ return [
48085
+ 7
48086
+ ];
48087
+ case 5:
48088
+ return [
48089
+ 2
48090
+ ];
48091
+ }
47424
48092
  });
47425
- setIsPlaying(false);
47426
- },
47427
- onEnd: function() {
47428
- setIsPlaying(false);
47429
- isLastSentencePlayedRef.current = unplayedMessageSentences.length === 1;
47430
- if (isLastSentencePlayedRef.current && latestMessageProps.latestMessage.status !== "in_progress") {
47431
- _onEnd();
47432
- isLastSentencePlayedRef.current = false;
47433
- }
47434
- }
47435
- });
47436
- }, [
47437
- unplayedMessageSentences,
47438
- isPlaying,
47439
- superinterfaceContext,
47440
- latestMessageProps,
47441
- audioPlayer,
47442
- nextAudioPlayer,
47443
- playedMessageSentences,
47444
- _onEnd,
47445
- play,
47446
- fullSentenceRegex
47447
- ]);
47448
- useEffect10(function() {
47449
- var _latestMessageProps$l;
47450
- if (isLastSentencePlayedRef.current && !isPlaying && unplayedMessageSentences.length === 0 && ((_latestMessageProps$l = latestMessageProps.latestMessage) === null || _latestMessageProps$l === void 0 ? void 0 : _latestMessageProps$l.status) !== "in_progress") {
47451
- _onEnd();
47452
- isLastSentencePlayedRef.current = false;
47453
- }
48093
+ });
48094
+ return function runPlayback2() {
48095
+ return _ref0.apply(this, arguments);
48096
+ };
48097
+ }();
48098
+ runPlayback();
47454
48099
  }, [
48100
+ audioQueue,
47455
48101
  isPlaying,
47456
- unplayedMessageSentences.length,
47457
- (_latestMessageProps$l2 = latestMessageProps.latestMessage) === null || _latestMessageProps$l2 === void 0 ? void 0 : _latestMessageProps$l2.status,
47458
- _onEnd
48102
+ playSegmentsImpl,
48103
+ playInternal,
48104
+ handleStop,
48105
+ handleSegmentEnd,
48106
+ checkForCompletion
47459
48107
  ]);
47460
48108
  useEffect10(function() {
47461
48109
  if (isHtmlAudioSupported) {
47462
- var _Howler$_howls$;
47463
- if (!(Howler !== null && Howler !== void 0 && (_Howler$_howls$ = Howler._howls[0]) !== null && _Howler$_howls$ !== void 0 && (_Howler$_howls$ = _Howler$_howls$._sounds[0]) !== null && _Howler$_howls$ !== void 0 && _Howler$_howls$._node)) return;
47464
- Howler._howls[0]._sounds[0]._node.crossOrigin = "anonymous";
48110
+ var _Howler$_howls;
48111
+ var node = Howler === null || Howler === void 0 || (_Howler$_howls = Howler._howls) === null || _Howler$_howls === void 0 || (_Howler$_howls = _Howler$_howls[0]) === null || _Howler$_howls === void 0 || (_Howler$_howls = _Howler$_howls._sounds) === null || _Howler$_howls === void 0 || (_Howler$_howls = _Howler$_howls[0]) === null || _Howler$_howls === void 0 ? void 0 : _Howler$_howls._node;
48112
+ if (node) node.crossOrigin = "anonymous";
47465
48113
  }
47466
48114
  }, [
47467
48115
  audioPlayer
47468
48116
  ]);
47469
- var _useState94 = _sliced_to_array(useState9(null), 2), audioEngine = _useState94[0], setAudioEngine = _useState94[1];
48117
+ var _useState93 = _sliced_to_array(useState9(null), 2), audioEngine = _useState93[0], setAudioEngine = _useState93[1];
47470
48118
  var isAudioEngineInited = useRef8(false);
47471
48119
  useEffect10(function() {
47472
48120
  if (!audioPlayer.playing) return;
47473
48121
  if (isAudioEngineInited.current) return;
47474
48122
  isAudioEngineInited.current = true;
47475
48123
  if (isHtmlAudioSupported) {
47476
- var audioContext = new AudioContext();
47477
- setAudioEngine({
47478
- // @ts-ignore-next-line
47479
- source: audioContext.createMediaElementSource(// @ts-ignore-next-line
47480
- Howler._howls[0]._sounds[0]._node),
47481
- audioContext: audioContext
47482
- });
48124
+ var _Howler$_howls2;
48125
+ var AudioCtx = window.AudioContext || window.webkitAudioContext;
48126
+ var audioContext = new AudioCtx();
48127
+ var node_0 = Howler === null || Howler === void 0 || (_Howler$_howls2 = Howler._howls) === null || _Howler$_howls2 === void 0 || (_Howler$_howls2 = _Howler$_howls2[0]) === null || _Howler$_howls2 === void 0 || (_Howler$_howls2 = _Howler$_howls2._sounds) === null || _Howler$_howls2 === void 0 || (_Howler$_howls2 = _Howler$_howls2[0]) === null || _Howler$_howls2 === void 0 ? void 0 : _Howler$_howls2._node;
48128
+ if (node_0) {
48129
+ setAudioEngine({
48130
+ // @ts-ignore-next-line
48131
+ source: audioContext.createMediaElementSource(node_0),
48132
+ audioContext: audioContext
48133
+ });
48134
+ }
47483
48135
  } else {
47484
48136
  setAudioEngine({
47485
48137
  source: Howler.masterGain,
@@ -47487,25 +48139,24 @@ var useMessageAudio = function(_ref2) {
47487
48139
  });
47488
48140
  }
47489
48141
  }, [
47490
- audioPlayer,
47491
- isAudioEngineInited
48142
+ audioPlayer
47492
48143
  ]);
47493
48144
  var visualizationAnalyser = useMemo17(function() {
47494
48145
  if (!audioEngine) return null;
47495
- var result = audioEngine.audioContext.createAnalyser();
48146
+ var analyser = audioEngine.audioContext.createAnalyser();
47496
48147
  audioEngine.source.connect(audioEngine.audioContext.destination);
47497
- audioEngine.source.connect(result);
47498
- return result;
48148
+ audioEngine.source.connect(analyser);
48149
+ return analyser;
47499
48150
  }, [
47500
48151
  audioEngine
47501
48152
  ]);
47502
48153
  var isPending = useMemo17(function() {
47503
- var _latestMessageProps$l3;
47504
- return isPlaying || unplayedMessageSentences.length > 0 || ((_latestMessageProps$l3 = latestMessageProps.latestMessage) === null || _latestMessageProps$l3 === void 0 ? void 0 : _latestMessageProps$l3.status) === "in_progress";
48154
+ return isPlaying || audioQueue.some(function(m_15) {
48155
+ return !m_15.stopped && (m_15.nextIndex < m_15.segments.length || m_15.status === "in_progress");
48156
+ });
47505
48157
  }, [
47506
48158
  isPlaying,
47507
- unplayedMessageSentences,
47508
- latestMessageProps
48159
+ audioQueue
47509
48160
  ]);
47510
48161
  return _objectSpread47(_objectSpread47({
47511
48162
  isPending: isPending,
@@ -47527,7 +48178,53 @@ var blobToData = function(blob) {
47527
48178
  });
47528
48179
  };
47529
48180
  // src/hooks/audioRuntimes/useTtsAudioRuntime/index.ts
47530
- function asyncGeneratorStep11(n, t, e, r, o, a, c) {
48181
+ var _excluded5 = [
48182
+ "onEnd"
48183
+ ];
48184
+ function ownKeys48(e, r) {
48185
+ var t = Object.keys(e);
48186
+ if (Object.getOwnPropertySymbols) {
48187
+ var o = Object.getOwnPropertySymbols(e);
48188
+ r && (o = o.filter(function(r2) {
48189
+ return Object.getOwnPropertyDescriptor(e, r2).enumerable;
48190
+ })), t.push.apply(t, o);
48191
+ }
48192
+ return t;
48193
+ }
48194
+ function _objectSpread48(e) {
48195
+ for(var r = 1; r < arguments.length; r++){
48196
+ var t = null != arguments[r] ? arguments[r] : {};
48197
+ r % 2 ? ownKeys48(Object(t), true).forEach(function(r2) {
48198
+ _defineProperty48(e, r2, t[r2]);
48199
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys48(Object(t)).forEach(function(r2) {
48200
+ Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
48201
+ });
48202
+ }
48203
+ return e;
48204
+ }
48205
+ function _defineProperty48(e, r, t) {
48206
+ return (r = _toPropertyKey48(r)) in e ? Object.defineProperty(e, r, {
48207
+ value: t,
48208
+ enumerable: true,
48209
+ configurable: true,
48210
+ writable: true
48211
+ }) : e[r] = t, e;
48212
+ }
48213
+ function _toPropertyKey48(t) {
48214
+ var i = _toPrimitive48(t, "string");
48215
+ return "symbol" == (typeof i === "undefined" ? "undefined" : _type_of(i)) ? i : i + "";
48216
+ }
48217
+ function _toPrimitive48(t, r) {
48218
+ if ("object" != (typeof t === "undefined" ? "undefined" : _type_of(t)) || !t) return t;
48219
+ var e = t[Symbol.toPrimitive];
48220
+ if (void 0 !== e) {
48221
+ var i = e.call(t, r || "default");
48222
+ if ("object" != (typeof i === "undefined" ? "undefined" : _type_of(i))) return i;
48223
+ throw new TypeError("@@toPrimitive must return a primitive value.");
48224
+ }
48225
+ return ("string" === r ? String : Number)(t);
48226
+ }
48227
+ function asyncGeneratorStep12(n, t, e, r, o, a, c) {
47531
48228
  try {
47532
48229
  var i = n[a](c), u = i.value;
47533
48230
  } catch (n2) {
@@ -47535,35 +48232,67 @@ function asyncGeneratorStep11(n, t, e, r, o, a, c) {
47535
48232
  }
47536
48233
  i.done ? t(u) : Promise.resolve(u).then(r, o);
47537
48234
  }
47538
- function _asyncToGenerator11(n) {
48235
+ function _asyncToGenerator12(n) {
47539
48236
  return function() {
47540
48237
  var t = this, e = arguments;
47541
48238
  return new Promise(function(r, o) {
47542
48239
  var a = n.apply(t, e);
47543
48240
  function _next(n2) {
47544
- asyncGeneratorStep11(a, r, o, _next, _throw, "next", n2);
48241
+ asyncGeneratorStep12(a, r, o, _next, _throw, "next", n2);
47545
48242
  }
47546
48243
  function _throw(n2) {
47547
- asyncGeneratorStep11(a, r, o, _next, _throw, "throw", n2);
48244
+ asyncGeneratorStep12(a, r, o, _next, _throw, "throw", n2);
47548
48245
  }
47549
48246
  _next(void 0);
47550
48247
  });
47551
48248
  };
47552
48249
  }
48250
+ function _objectWithoutProperties5(e, t) {
48251
+ if (null == e) return {};
48252
+ var o, r, i = _objectWithoutPropertiesLoose5(e, t);
48253
+ if (Object.getOwnPropertySymbols) {
48254
+ var n = Object.getOwnPropertySymbols(e);
48255
+ for(r = 0; r < n.length; r++)o = n[r], -1 === t.indexOf(o) && ({}).propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
48256
+ }
48257
+ return i;
48258
+ }
48259
+ function _objectWithoutPropertiesLoose5(r, e) {
48260
+ if (null == r) return {};
48261
+ var t = {};
48262
+ for(var n in r)if (({}).hasOwnProperty.call(r, n)) {
48263
+ if (-1 !== e.indexOf(n)) continue;
48264
+ t[n] = r[n];
48265
+ }
48266
+ return t;
48267
+ }
47553
48268
  var useTtsAudioRuntime = function(t0) {
47554
- var $ = _c88(30);
47555
- var play = t0.play, passedOnEnd = t0.onEnd;
48269
+ var $ = _c88(33);
48270
+ var overrides;
48271
+ var passedOnEnd;
48272
+ if ($[0] !== t0) {
48273
+ var _t = t0;
48274
+ var ref;
48275
+ ref = _t, passedOnEnd = ref.onEnd, ref;
48276
+ overrides = _objectWithoutProperties5(_t, _excluded5);
48277
+ _t;
48278
+ $[0] = t0;
48279
+ $[1] = overrides;
48280
+ $[2] = passedOnEnd;
48281
+ } else {
48282
+ overrides = $[1];
48283
+ passedOnEnd = $[2];
48284
+ }
47556
48285
  var addToast = useToasts().addToast;
47557
48286
  var queryClient = useQueryClient6();
47558
48287
  var threadContext = useSuperinterfaceContext();
47559
48288
  var t1;
47560
- if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
48289
+ if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
47561
48290
  t1 = {
47562
48291
  name: "microphone"
47563
48292
  };
47564
- $[0] = t1;
48293
+ $[3] = t1;
47565
48294
  } else {
47566
- t1 = $[0];
48295
+ t1 = $[3];
47567
48296
  }
47568
48297
  var microphonePermission = usePermission(t1);
47569
48298
  var createMessageProps = useCreateMessage({
@@ -47577,12 +48306,12 @@ var useTtsAudioRuntime = function(t0) {
47577
48306
  }
47578
48307
  });
47579
48308
  var t2;
47580
- if ($[1] !== createMessageProps) {
48309
+ if ($[4] !== createMessageProps) {
47581
48310
  t2 = {
47582
48311
  isStopOnSilence: true,
47583
48312
  onStart: _temp9,
47584
48313
  onStop: function() {
47585
- var _onStop = _asyncToGenerator11(function(_event, chunks) {
48314
+ var _onStop = _asyncToGenerator12(function(_event, chunks) {
47586
48315
  var blob, audioContent;
47587
48316
  return _ts_generator(this, function(_state) {
47588
48317
  switch(_state.label){
@@ -47611,10 +48340,10 @@ var useTtsAudioRuntime = function(t0) {
47611
48340
  return onStop;
47612
48341
  }()
47613
48342
  };
47614
- $[1] = createMessageProps;
47615
- $[2] = t2;
48343
+ $[4] = createMessageProps;
48344
+ $[5] = t2;
47616
48345
  } else {
47617
- t2 = $[2];
48346
+ t2 = $[5];
47618
48347
  }
47619
48348
  var recorderProps = useRecorder(t2);
47620
48349
  recorderProps;
@@ -47624,39 +48353,38 @@ var useTtsAudioRuntime = function(t0) {
47624
48353
  t3 = passedOnEnd;
47625
48354
  break bb0;
47626
48355
  }
47627
- var _t;
47628
- if ($[3] !== microphonePermission || $[4] !== recorderProps) {
47629
- _t = function() {
48356
+ var _t2;
48357
+ if ($[6] !== microphonePermission || $[7] !== recorderProps) {
48358
+ _t2 = function() {
47630
48359
  if (microphonePermission === "granted") {
47631
48360
  recorderProps.start();
47632
48361
  }
47633
48362
  };
47634
- $[3] = microphonePermission;
47635
- $[4] = recorderProps;
47636
- $[5] = _t;
48363
+ $[6] = microphonePermission;
48364
+ $[7] = recorderProps;
48365
+ $[8] = _t2;
47637
48366
  } else {
47638
- _t = $[5];
48367
+ _t2 = $[8];
47639
48368
  }
47640
- t3 = _t;
48369
+ t3 = _t2;
47641
48370
  }
47642
48371
  var onEnd = t3;
47643
48372
  var t4;
47644
- if ($[6] !== onEnd || $[7] !== play) {
47645
- t4 = {
47646
- play: play,
48373
+ if ($[9] !== onEnd || $[10] !== overrides) {
48374
+ t4 = _objectSpread48({
47647
48375
  onEnd: onEnd
47648
- };
47649
- $[6] = onEnd;
47650
- $[7] = play;
47651
- $[8] = t4;
48376
+ }, overrides);
48377
+ $[9] = onEnd;
48378
+ $[10] = overrides;
48379
+ $[11] = t4;
47652
48380
  } else {
47653
- t4 = $[8];
48381
+ t4 = $[11];
47654
48382
  }
47655
48383
  var messageAudioProps = useMessageAudio(t4);
47656
48384
  recorderProps;
47657
48385
  var t5;
47658
48386
  var t6;
47659
- if ($[9] !== createMessageProps.isPending || $[10] !== recorderProps.pause || $[11] !== recorderProps.resume || $[12] !== recorderProps.start || $[13] !== recorderProps.status || $[14] !== recorderProps.stop || $[15] !== recorderProps.visualizationAnalyser) {
48387
+ if ($[12] !== createMessageProps.isPending || $[13] !== recorderProps.pause || $[14] !== recorderProps.resume || $[15] !== recorderProps.start || $[16] !== recorderProps.status || $[17] !== recorderProps.stop || $[18] !== recorderProps.visualizationAnalyser) {
47660
48388
  t6 = {
47661
48389
  start: recorderProps.start,
47662
48390
  stop: recorderProps.stop,
@@ -47666,19 +48394,19 @@ var useTtsAudioRuntime = function(t0) {
47666
48394
  visualizationAnalyser: recorderProps.visualizationAnalyser,
47667
48395
  rawStatus: recorderProps.status
47668
48396
  };
47669
- $[9] = createMessageProps.isPending;
47670
- $[10] = recorderProps.pause;
47671
- $[11] = recorderProps.resume;
47672
- $[12] = recorderProps.start;
47673
- $[13] = recorderProps.status;
47674
- $[14] = recorderProps.stop;
47675
- $[15] = recorderProps.visualizationAnalyser;
47676
- $[16] = t6;
48397
+ $[12] = createMessageProps.isPending;
48398
+ $[13] = recorderProps.pause;
48399
+ $[14] = recorderProps.resume;
48400
+ $[15] = recorderProps.start;
48401
+ $[16] = recorderProps.status;
48402
+ $[17] = recorderProps.stop;
48403
+ $[18] = recorderProps.visualizationAnalyser;
48404
+ $[19] = t6;
47677
48405
  } else {
47678
- t6 = $[16];
48406
+ t6 = $[19];
47679
48407
  }
47680
48408
  var t7;
47681
- 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) {
48409
+ 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) {
47682
48410
  t7 = {
47683
48411
  play: messageAudioProps.play,
47684
48412
  pause: messageAudioProps.pause,
@@ -47691,32 +48419,32 @@ var useTtsAudioRuntime = function(t0) {
47691
48419
  isAudioPlayed: messageAudioProps.isAudioPlayed,
47692
48420
  rawStatus: void 0
47693
48421
  };
47694
- $[17] = messageAudioProps.isAudioPlayed;
47695
- $[18] = messageAudioProps.isPending;
47696
- $[19] = messageAudioProps.isReady;
47697
- $[20] = messageAudioProps.pause;
47698
- $[21] = messageAudioProps.paused;
47699
- $[22] = messageAudioProps.play;
47700
- $[23] = messageAudioProps.playing;
47701
- $[24] = messageAudioProps.stop;
47702
- $[25] = messageAudioProps.visualizationAnalyser;
47703
- $[26] = t7;
47704
- } else {
47705
- t7 = $[26];
48422
+ $[20] = messageAudioProps.isAudioPlayed;
48423
+ $[21] = messageAudioProps.isPending;
48424
+ $[22] = messageAudioProps.isReady;
48425
+ $[23] = messageAudioProps.pause;
48426
+ $[24] = messageAudioProps.paused;
48427
+ $[25] = messageAudioProps.play;
48428
+ $[26] = messageAudioProps.playing;
48429
+ $[27] = messageAudioProps.stop;
48430
+ $[28] = messageAudioProps.visualizationAnalyser;
48431
+ $[29] = t7;
48432
+ } else {
48433
+ t7 = $[29];
47706
48434
  }
47707
48435
  var t8;
47708
- if ($[27] !== t6 || $[28] !== t7) {
48436
+ if ($[30] !== t6 || $[31] !== t7) {
47709
48437
  t8 = {
47710
48438
  ttsAudioRuntime: {
47711
48439
  user: t6,
47712
48440
  assistant: t7
47713
48441
  }
47714
48442
  };
47715
- $[27] = t6;
47716
- $[28] = t7;
47717
- $[29] = t8;
48443
+ $[30] = t6;
48444
+ $[31] = t7;
48445
+ $[32] = t8;
47718
48446
  } else {
47719
- t8 = $[29];
48447
+ t8 = $[32];
47720
48448
  }
47721
48449
  t5 = t8;
47722
48450
  return t5;
@@ -47725,7 +48453,7 @@ function _temp9() {
47725
48453
  return _temp24.apply(this, arguments);
47726
48454
  }
47727
48455
  function _temp24() {
47728
- _temp24 = _asyncToGenerator11(function() {
48456
+ _temp24 = _asyncToGenerator12(function() {
47729
48457
  return _ts_generator(this, function(_state) {
47730
48458
  return [
47731
48459
  2
@@ -47736,59 +48464,142 @@ function _temp24() {
47736
48464
  }
47737
48465
  // src/components/audioRuntimes/TtsAudioRuntimeProvider.tsx
47738
48466
  import { jsx as _jsx87 } from "react/jsx-runtime";
48467
+ var _excluded6 = [
48468
+ "children",
48469
+ "onEnd"
48470
+ ];
48471
+ function ownKeys49(e, r) {
48472
+ var t = Object.keys(e);
48473
+ if (Object.getOwnPropertySymbols) {
48474
+ var o = Object.getOwnPropertySymbols(e);
48475
+ r && (o = o.filter(function(r2) {
48476
+ return Object.getOwnPropertyDescriptor(e, r2).enumerable;
48477
+ })), t.push.apply(t, o);
48478
+ }
48479
+ return t;
48480
+ }
48481
+ function _objectSpread49(e) {
48482
+ for(var r = 1; r < arguments.length; r++){
48483
+ var t = null != arguments[r] ? arguments[r] : {};
48484
+ r % 2 ? ownKeys49(Object(t), true).forEach(function(r2) {
48485
+ _defineProperty49(e, r2, t[r2]);
48486
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys49(Object(t)).forEach(function(r2) {
48487
+ Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
48488
+ });
48489
+ }
48490
+ return e;
48491
+ }
48492
+ function _defineProperty49(e, r, t) {
48493
+ return (r = _toPropertyKey49(r)) in e ? Object.defineProperty(e, r, {
48494
+ value: t,
48495
+ enumerable: true,
48496
+ configurable: true,
48497
+ writable: true
48498
+ }) : e[r] = t, e;
48499
+ }
48500
+ function _toPropertyKey49(t) {
48501
+ var i = _toPrimitive49(t, "string");
48502
+ return "symbol" == (typeof i === "undefined" ? "undefined" : _type_of(i)) ? i : i + "";
48503
+ }
48504
+ function _toPrimitive49(t, r) {
48505
+ if ("object" != (typeof t === "undefined" ? "undefined" : _type_of(t)) || !t) return t;
48506
+ var e = t[Symbol.toPrimitive];
48507
+ if (void 0 !== e) {
48508
+ var i = e.call(t, r || "default");
48509
+ if ("object" != (typeof i === "undefined" ? "undefined" : _type_of(i))) return i;
48510
+ throw new TypeError("@@toPrimitive must return a primitive value.");
48511
+ }
48512
+ return ("string" === r ? String : Number)(t);
48513
+ }
48514
+ function _objectWithoutProperties6(e, t) {
48515
+ if (null == e) return {};
48516
+ var o, r, i = _objectWithoutPropertiesLoose6(e, t);
48517
+ if (Object.getOwnPropertySymbols) {
48518
+ var n = Object.getOwnPropertySymbols(e);
48519
+ for(r = 0; r < n.length; r++)o = n[r], -1 === t.indexOf(o) && ({}).propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
48520
+ }
48521
+ return i;
48522
+ }
48523
+ function _objectWithoutPropertiesLoose6(r, e) {
48524
+ if (null == r) return {};
48525
+ var t = {};
48526
+ for(var n in r)if (({}).hasOwnProperty.call(r, n)) {
48527
+ if (-1 !== e.indexOf(n)) continue;
48528
+ t[n] = r[n];
48529
+ }
48530
+ return t;
48531
+ }
47739
48532
  var TtsAudioRuntimeProvider = function(t0) {
47740
- var $ = _c89(8);
47741
- var children = t0.children, play = t0.play, onEnd = t0.onEnd;
48533
+ var $ = _c89(12);
48534
+ var children;
48535
+ var onEnd;
48536
+ var overrides;
48537
+ if ($[0] !== t0) {
48538
+ var _t = t0;
48539
+ var ref;
48540
+ ref = _t, children = ref.children, onEnd = ref.onEnd, ref;
48541
+ overrides = _objectWithoutProperties6(_t, _excluded6);
48542
+ _t;
48543
+ $[0] = t0;
48544
+ $[1] = children;
48545
+ $[2] = onEnd;
48546
+ $[3] = overrides;
48547
+ } else {
48548
+ children = $[1];
48549
+ onEnd = $[2];
48550
+ overrides = $[3];
48551
+ }
47742
48552
  var t1;
47743
- if ($[0] !== onEnd || $[1] !== play) {
47744
- t1 = {
47745
- play: play,
48553
+ if ($[4] !== onEnd || $[5] !== overrides) {
48554
+ t1 = _objectSpread49({
47746
48555
  onEnd: onEnd
47747
- };
47748
- $[0] = onEnd;
47749
- $[1] = play;
47750
- $[2] = t1;
48556
+ }, overrides);
48557
+ $[4] = onEnd;
48558
+ $[5] = overrides;
48559
+ $[6] = t1;
47751
48560
  } else {
47752
- t1 = $[2];
48561
+ t1 = $[6];
47753
48562
  }
47754
48563
  var ttsAudioRuntime = useTtsAudioRuntime(t1).ttsAudioRuntime;
47755
48564
  var t2;
47756
- if ($[3] !== ttsAudioRuntime) {
48565
+ if ($[7] !== ttsAudioRuntime) {
47757
48566
  t2 = {
47758
48567
  audioRuntime: ttsAudioRuntime
47759
48568
  };
47760
- $[3] = ttsAudioRuntime;
47761
- $[4] = t2;
48569
+ $[7] = ttsAudioRuntime;
48570
+ $[8] = t2;
47762
48571
  } else {
47763
- t2 = $[4];
48572
+ t2 = $[8];
47764
48573
  }
47765
48574
  var t3;
47766
- if ($[5] !== children || $[6] !== t2) {
48575
+ if ($[9] !== children || $[10] !== t2) {
47767
48576
  t3 = /* @__PURE__ */ _jsx87(AudioThreadContext.Provider, {
47768
48577
  value: t2,
47769
48578
  children: children
47770
48579
  });
47771
- $[5] = children;
47772
- $[6] = t2;
47773
- $[7] = t3;
48580
+ $[9] = children;
48581
+ $[10] = t2;
48582
+ $[11] = t3;
47774
48583
  } else {
47775
- t3 = $[7];
48584
+ t3 = $[11];
47776
48585
  }
47777
48586
  return t3;
47778
48587
  };
47779
48588
  // src/components/threads/AudioThread/Root/index.tsx
47780
48589
  import { jsx as _jsx88 } from "react/jsx-runtime";
47781
- var _excluded5 = [
48590
+ var _excluded7 = [
47782
48591
  "children"
47783
48592
  ];
47784
48593
  var _excluded22 = [
47785
48594
  "children",
47786
48595
  "play",
48596
+ "playSegments",
48597
+ "getSegments",
47787
48598
  "onEnd",
47788
48599
  "className",
47789
48600
  "style"
47790
48601
  ];
47791
- function ownKeys48(e, r) {
48602
+ function ownKeys50(e, r) {
47792
48603
  var t = Object.keys(e);
47793
48604
  if (Object.getOwnPropertySymbols) {
47794
48605
  var o = Object.getOwnPropertySymbols(e);
@@ -47798,30 +48609,30 @@ function ownKeys48(e, r) {
47798
48609
  }
47799
48610
  return t;
47800
48611
  }
47801
- function _objectSpread48(e) {
48612
+ function _objectSpread50(e) {
47802
48613
  for(var r = 1; r < arguments.length; r++){
47803
48614
  var t = null != arguments[r] ? arguments[r] : {};
47804
- r % 2 ? ownKeys48(Object(t), true).forEach(function(r2) {
47805
- _defineProperty48(e, r2, t[r2]);
47806
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys48(Object(t)).forEach(function(r2) {
48615
+ r % 2 ? ownKeys50(Object(t), true).forEach(function(r2) {
48616
+ _defineProperty50(e, r2, t[r2]);
48617
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys50(Object(t)).forEach(function(r2) {
47807
48618
  Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
47808
48619
  });
47809
48620
  }
47810
48621
  return e;
47811
48622
  }
47812
- function _defineProperty48(e, r, t) {
47813
- return (r = _toPropertyKey48(r)) in e ? Object.defineProperty(e, r, {
48623
+ function _defineProperty50(e, r, t) {
48624
+ return (r = _toPropertyKey50(r)) in e ? Object.defineProperty(e, r, {
47814
48625
  value: t,
47815
48626
  enumerable: true,
47816
48627
  configurable: true,
47817
48628
  writable: true
47818
48629
  }) : e[r] = t, e;
47819
48630
  }
47820
- function _toPropertyKey48(t) {
47821
- var i = _toPrimitive48(t, "string");
48631
+ function _toPropertyKey50(t) {
48632
+ var i = _toPrimitive50(t, "string");
47822
48633
  return "symbol" == (typeof i === "undefined" ? "undefined" : _type_of(i)) ? i : i + "";
47823
48634
  }
47824
- function _toPrimitive48(t, r) {
48635
+ function _toPrimitive50(t, r) {
47825
48636
  if ("object" != (typeof t === "undefined" ? "undefined" : _type_of(t)) || !t) return t;
47826
48637
  var e = t[Symbol.toPrimitive];
47827
48638
  if (void 0 !== e) {
@@ -47831,16 +48642,16 @@ function _toPrimitive48(t, r) {
47831
48642
  }
47832
48643
  return ("string" === r ? String : Number)(t);
47833
48644
  }
47834
- function _objectWithoutProperties5(e, t) {
48645
+ function _objectWithoutProperties7(e, t) {
47835
48646
  if (null == e) return {};
47836
- var o, r, i = _objectWithoutPropertiesLoose5(e, t);
48647
+ var o, r, i = _objectWithoutPropertiesLoose7(e, t);
47837
48648
  if (Object.getOwnPropertySymbols) {
47838
48649
  var n = Object.getOwnPropertySymbols(e);
47839
48650
  for(r = 0; r < n.length; r++)o = n[r], -1 === t.indexOf(o) && ({}).propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
47840
48651
  }
47841
48652
  return i;
47842
48653
  }
47843
- function _objectWithoutPropertiesLoose5(r, e) {
48654
+ function _objectWithoutPropertiesLoose7(r, e) {
47844
48655
  if (null == r) return {};
47845
48656
  var t = {};
47846
48657
  for(var n in r)if (({}).hasOwnProperty.call(r, n)) {
@@ -47872,25 +48683,29 @@ var Content9 = function(t0) {
47872
48683
  return t1;
47873
48684
  };
47874
48685
  var AudioRuntimeProvider = function(t0) {
47875
- var $ = _c90(4);
47876
- var children = t0.children, play = t0.play, onEnd = t0.onEnd;
48686
+ var $ = _c90(6);
48687
+ var children = t0.children, onEnd = t0.onEnd, play = t0.play, playSegments = t0.playSegments, getSegments = t0.getSegments;
47877
48688
  var audioThreadContext = useAudioThreadContext();
47878
48689
  if (audioThreadContext.audioRuntime) {
47879
48690
  return children;
47880
48691
  }
47881
48692
  var t1;
47882
- if ($[0] !== children || $[1] !== onEnd || $[2] !== play) {
48693
+ if ($[0] !== children || $[1] !== getSegments || $[2] !== onEnd || $[3] !== play || $[4] !== playSegments) {
47883
48694
  t1 = /* @__PURE__ */ _jsx88(TtsAudioRuntimeProvider, {
47884
- play: play,
47885
48695
  onEnd: onEnd,
48696
+ play: play,
48697
+ playSegments: playSegments,
48698
+ getSegments: getSegments,
47886
48699
  children: children
47887
48700
  });
47888
48701
  $[0] = children;
47889
- $[1] = onEnd;
47890
- $[2] = play;
47891
- $[3] = t1;
48702
+ $[1] = getSegments;
48703
+ $[2] = onEnd;
48704
+ $[3] = play;
48705
+ $[4] = playSegments;
48706
+ $[5] = t1;
47892
48707
  } else {
47893
- t1 = $[3];
48708
+ t1 = $[5];
47894
48709
  }
47895
48710
  return t1;
47896
48711
  };
@@ -47901,7 +48716,7 @@ var Provider5 = function(t0) {
47901
48716
  if ($[0] !== t0) {
47902
48717
  var _t = t0;
47903
48718
  children = _t.children;
47904
- rest = _objectWithoutProperties5(_t, _excluded5);
48719
+ rest = _objectWithoutProperties7(_t, _excluded7);
47905
48720
  _t;
47906
48721
  $[0] = t0;
47907
48722
  $[1] = children;
@@ -47913,7 +48728,7 @@ var Provider5 = function(t0) {
47913
48728
  var audioThreadContext = useAudioThreadContext();
47914
48729
  var t1;
47915
48730
  if ($[3] !== audioThreadContext || $[4] !== rest) {
47916
- t1 = _objectSpread48(_objectSpread48({}, audioThreadContext), rest);
48731
+ t1 = _objectSpread50(_objectSpread50({}, audioThreadContext), rest);
47917
48732
  $[3] = audioThreadContext;
47918
48733
  $[4] = rest;
47919
48734
  $[5] = t1;
@@ -47935,36 +48750,42 @@ var Provider5 = function(t0) {
47935
48750
  return t2;
47936
48751
  };
47937
48752
  var Root16 = function(t0) {
47938
- var $ = _c90(18);
48753
+ var $ = _c90(22);
47939
48754
  var children;
47940
48755
  var className;
48756
+ var getSegments;
47941
48757
  var onEnd;
47942
48758
  var play;
48759
+ var playSegments;
47943
48760
  var rest;
47944
48761
  var style;
47945
48762
  if ($[0] !== t0) {
47946
48763
  var _t2 = t0;
47947
48764
  var ref;
47948
- ref = _t2, children = ref.children, play = ref.play, onEnd = ref.onEnd, className = ref.className, style = ref.style, ref;
47949
- rest = _objectWithoutProperties5(_t2, _excluded22);
48765
+ ref = _t2, children = ref.children, play = ref.play, playSegments = ref.playSegments, getSegments = ref.getSegments, onEnd = ref.onEnd, className = ref.className, style = ref.style, ref;
48766
+ rest = _objectWithoutProperties7(_t2, _excluded22);
47950
48767
  _t2;
47951
48768
  $[0] = t0;
47952
48769
  $[1] = children;
47953
48770
  $[2] = className;
47954
- $[3] = onEnd;
47955
- $[4] = play;
47956
- $[5] = rest;
47957
- $[6] = style;
48771
+ $[3] = getSegments;
48772
+ $[4] = onEnd;
48773
+ $[5] = play;
48774
+ $[6] = playSegments;
48775
+ $[7] = rest;
48776
+ $[8] = style;
47958
48777
  } else {
47959
48778
  children = $[1];
47960
48779
  className = $[2];
47961
- onEnd = $[3];
47962
- play = $[4];
47963
- rest = $[5];
47964
- style = $[6];
48780
+ getSegments = $[3];
48781
+ onEnd = $[4];
48782
+ play = $[5];
48783
+ playSegments = $[6];
48784
+ rest = $[7];
48785
+ style = $[8];
47965
48786
  }
47966
48787
  var t1;
47967
- if ($[7] !== children || $[8] !== className || $[9] !== style) {
48788
+ if ($[9] !== children || $[10] !== className || $[11] !== style) {
47968
48789
  t1 = /* @__PURE__ */ _jsx88(ToastsProvider, {
47969
48790
  children: /* @__PURE__ */ _jsx88(Content9, {
47970
48791
  className: className,
@@ -47972,37 +48793,41 @@ var Root16 = function(t0) {
47972
48793
  children: children
47973
48794
  })
47974
48795
  });
47975
- $[7] = children;
47976
- $[8] = className;
47977
- $[9] = style;
47978
- $[10] = t1;
48796
+ $[9] = children;
48797
+ $[10] = className;
48798
+ $[11] = style;
48799
+ $[12] = t1;
47979
48800
  } else {
47980
- t1 = $[10];
48801
+ t1 = $[12];
47981
48802
  }
47982
48803
  var t2;
47983
- if ($[11] !== onEnd || $[12] !== play || $[13] !== t1) {
48804
+ if ($[13] !== getSegments || $[14] !== onEnd || $[15] !== play || $[16] !== playSegments || $[17] !== t1) {
47984
48805
  t2 = /* @__PURE__ */ _jsx88(AudioRuntimeProvider, {
47985
- play: play,
47986
48806
  onEnd: onEnd,
48807
+ play: play,
48808
+ playSegments: playSegments,
48809
+ getSegments: getSegments,
47987
48810
  children: t1
47988
48811
  });
47989
- $[11] = onEnd;
47990
- $[12] = play;
47991
- $[13] = t1;
47992
- $[14] = t2;
48812
+ $[13] = getSegments;
48813
+ $[14] = onEnd;
48814
+ $[15] = play;
48815
+ $[16] = playSegments;
48816
+ $[17] = t1;
48817
+ $[18] = t2;
47993
48818
  } else {
47994
- t2 = $[14];
48819
+ t2 = $[18];
47995
48820
  }
47996
48821
  var t3;
47997
- if ($[15] !== rest || $[16] !== t2) {
47998
- t3 = /* @__PURE__ */ _jsx88(Provider5, _objectSpread48(_objectSpread48({}, rest), {}, {
48822
+ if ($[19] !== rest || $[20] !== t2) {
48823
+ t3 = /* @__PURE__ */ _jsx88(Provider5, _objectSpread50(_objectSpread50({}, rest), {}, {
47999
48824
  children: t2
48000
48825
  }));
48001
- $[15] = rest;
48002
- $[16] = t2;
48003
- $[17] = t3;
48826
+ $[19] = rest;
48827
+ $[20] = t2;
48828
+ $[21] = t3;
48004
48829
  } else {
48005
- t3 = $[17];
48830
+ t3 = $[21];
48006
48831
  }
48007
48832
  return t3;
48008
48833
  };
@@ -48128,7 +48953,7 @@ var useStatus = function() {
48128
48953
  };
48129
48954
  // src/components/threads/AudioThread/Visualization/index.tsx
48130
48955
  import { jsx as _jsx90, jsxs as _jsxs31 } from "react/jsx-runtime";
48131
- var _excluded6 = [
48956
+ var _excluded8 = [
48132
48957
  "children"
48133
48958
  ];
48134
48959
  var _excluded23 = [
@@ -48140,7 +48965,7 @@ var _excluded32 = [
48140
48965
  "height",
48141
48966
  "width"
48142
48967
  ];
48143
- function ownKeys49(e, r) {
48968
+ function ownKeys51(e, r) {
48144
48969
  var t = Object.keys(e);
48145
48970
  if (Object.getOwnPropertySymbols) {
48146
48971
  var o = Object.getOwnPropertySymbols(e);
@@ -48150,30 +48975,30 @@ function ownKeys49(e, r) {
48150
48975
  }
48151
48976
  return t;
48152
48977
  }
48153
- function _objectSpread49(e) {
48978
+ function _objectSpread51(e) {
48154
48979
  for(var r = 1; r < arguments.length; r++){
48155
48980
  var t = null != arguments[r] ? arguments[r] : {};
48156
- r % 2 ? ownKeys49(Object(t), true).forEach(function(r2) {
48157
- _defineProperty49(e, r2, t[r2]);
48158
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys49(Object(t)).forEach(function(r2) {
48981
+ r % 2 ? ownKeys51(Object(t), true).forEach(function(r2) {
48982
+ _defineProperty51(e, r2, t[r2]);
48983
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys51(Object(t)).forEach(function(r2) {
48159
48984
  Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
48160
48985
  });
48161
48986
  }
48162
48987
  return e;
48163
48988
  }
48164
- function _defineProperty49(e, r, t) {
48165
- return (r = _toPropertyKey49(r)) in e ? Object.defineProperty(e, r, {
48989
+ function _defineProperty51(e, r, t) {
48990
+ return (r = _toPropertyKey51(r)) in e ? Object.defineProperty(e, r, {
48166
48991
  value: t,
48167
48992
  enumerable: true,
48168
48993
  configurable: true,
48169
48994
  writable: true
48170
48995
  }) : e[r] = t, e;
48171
48996
  }
48172
- function _toPropertyKey49(t) {
48173
- var i = _toPrimitive49(t, "string");
48997
+ function _toPropertyKey51(t) {
48998
+ var i = _toPrimitive51(t, "string");
48174
48999
  return "symbol" == (typeof i === "undefined" ? "undefined" : _type_of(i)) ? i : i + "";
48175
49000
  }
48176
- function _toPrimitive49(t, r) {
49001
+ function _toPrimitive51(t, r) {
48177
49002
  if ("object" != (typeof t === "undefined" ? "undefined" : _type_of(t)) || !t) return t;
48178
49003
  var e = t[Symbol.toPrimitive];
48179
49004
  if (void 0 !== e) {
@@ -48183,16 +49008,16 @@ function _toPrimitive49(t, r) {
48183
49008
  }
48184
49009
  return ("string" === r ? String : Number)(t);
48185
49010
  }
48186
- function _objectWithoutProperties6(e, t) {
49011
+ function _objectWithoutProperties8(e, t) {
48187
49012
  if (null == e) return {};
48188
- var o, r, i = _objectWithoutPropertiesLoose6(e, t);
49013
+ var o, r, i = _objectWithoutPropertiesLoose8(e, t);
48189
49014
  if (Object.getOwnPropertySymbols) {
48190
49015
  var n = Object.getOwnPropertySymbols(e);
48191
49016
  for(r = 0; r < n.length; r++)o = n[r], -1 === t.indexOf(o) && ({}).propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
48192
49017
  }
48193
49018
  return i;
48194
49019
  }
48195
- function _objectWithoutPropertiesLoose6(r, e) {
49020
+ function _objectWithoutPropertiesLoose8(r, e) {
48196
49021
  if (null == r) return {};
48197
49022
  var t = {};
48198
49023
  for(var n in r)if (({}).hasOwnProperty.call(r, n)) {
@@ -48245,7 +49070,7 @@ var Root17 = function(t0) {
48245
49070
  if ($[0] !== t0) {
48246
49071
  var _t = t0;
48247
49072
  children = _t.children;
48248
- rest = _objectWithoutProperties6(_t, _excluded6);
49073
+ rest = _objectWithoutProperties8(_t, _excluded8);
48249
49074
  _t;
48250
49075
  $[0] = t0;
48251
49076
  $[1] = children;
@@ -48257,7 +49082,7 @@ var Root17 = function(t0) {
48257
49082
  var t1;
48258
49083
  if ($[3] !== children || $[4] !== rest) {
48259
49084
  t1 = /* @__PURE__ */ _jsx90(Provider6, {
48260
- children: /* @__PURE__ */ _jsx90(Flex31, _objectSpread49(_objectSpread49({
49085
+ children: /* @__PURE__ */ _jsx90(Flex31, _objectSpread51(_objectSpread51({
48261
49086
  direction: "column",
48262
49087
  align: "center",
48263
49088
  justify: "center",
@@ -48284,7 +49109,7 @@ var BarsVisualizer2 = function(t0) {
48284
49109
  var _t2 = t0;
48285
49110
  var ref;
48286
49111
  ref = _t2, t1 = ref.height, t2 = ref.barWidth, ref;
48287
- rest = _objectWithoutProperties6(_t2, _excluded23);
49112
+ rest = _objectWithoutProperties8(_t2, _excluded23);
48288
49113
  _t2;
48289
49114
  $[0] = t0;
48290
49115
  $[1] = rest;
@@ -48302,7 +49127,7 @@ var BarsVisualizer2 = function(t0) {
48302
49127
  var t3 = status === "playing" ? "var(--accent-11)" : "var(--gray-11)";
48303
49128
  var t4;
48304
49129
  if ($[4] !== audioThreadContext.audioRuntime.assistant.visualizationAnalyser || $[5] !== barWidth || $[6] !== height || $[7] !== rest || $[8] !== t3) {
48305
- t4 = /* @__PURE__ */ _jsx90(BarsVisualizer, _objectSpread49({
49130
+ t4 = /* @__PURE__ */ _jsx90(BarsVisualizer, _objectSpread51({
48306
49131
  visualizationAnalyser: audioThreadContext.audioRuntime.assistant.visualizationAnalyser,
48307
49132
  backgroundColor: t3,
48308
49133
  height: height,
@@ -48329,7 +49154,7 @@ var AssistantVisualizationRoot = function(t0) {
48329
49154
  var _t3 = t0;
48330
49155
  var ref;
48331
49156
  ref = _t3, children = ref.children, t1 = ref.height, t2 = ref.width, ref;
48332
- rest = _objectWithoutProperties6(_t3, _excluded32);
49157
+ rest = _objectWithoutProperties8(_t3, _excluded32);
48333
49158
  _t3;
48334
49159
  $[0] = t0;
48335
49160
  $[1] = children;
@@ -48358,7 +49183,7 @@ var AssistantVisualizationRoot = function(t0) {
48358
49183
  }
48359
49184
  var t5;
48360
49185
  if ($[7] !== scale || $[8] !== t3 || $[9] !== t4) {
48361
- t5 = _objectSpread49({
49186
+ t5 = _objectSpread51({
48362
49187
  backgroundColor: t3,
48363
49188
  borderRadius: "9999px",
48364
49189
  scale: scale
@@ -48372,7 +49197,7 @@ var AssistantVisualizationRoot = function(t0) {
48372
49197
  }
48373
49198
  var t6;
48374
49199
  if ($[11] !== children || $[12] !== height || $[13] !== rest || $[14] !== t5 || $[15] !== width2) {
48375
- t6 = /* @__PURE__ */ _jsx90(Flex31, _objectSpread49(_objectSpread49({
49200
+ t6 = /* @__PURE__ */ _jsx90(Flex31, _objectSpread51(_objectSpread51({
48376
49201
  align: "center",
48377
49202
  justify: "center",
48378
49203
  height: height,
@@ -48403,7 +49228,7 @@ var AssistantVisualization = function(props) {
48403
49228
  }
48404
49229
  var t1;
48405
49230
  if ($[1] !== props) {
48406
- t1 = /* @__PURE__ */ _jsx90(AssistantVisualizationRoot, _objectSpread49(_objectSpread49({}, props), {}, {
49231
+ t1 = /* @__PURE__ */ _jsx90(AssistantVisualizationRoot, _objectSpread51(_objectSpread51({}, props), {}, {
48407
49232
  children: t0
48408
49233
  }));
48409
49234
  $[1] = props;
@@ -48437,7 +49262,7 @@ var AssistantInfo = function(props) {
48437
49262
  }
48438
49263
  var t2;
48439
49264
  if ($[3] !== props || $[4] !== t1) {
48440
- t2 = /* @__PURE__ */ _jsxs31(Flex31, _objectSpread49(_objectSpread49({
49265
+ t2 = /* @__PURE__ */ _jsxs31(Flex31, _objectSpread51(_objectSpread51({
48441
49266
  ml: "-22.5px",
48442
49267
  gap: "3",
48443
49268
  pt: "5"
@@ -48470,7 +49295,7 @@ var Visualization = function(props) {
48470
49295
  }
48471
49296
  var t2;
48472
49297
  if ($[2] !== props) {
48473
- t2 = /* @__PURE__ */ _jsxs31(Root17, _objectSpread49(_objectSpread49({}, props), {}, {
49298
+ t2 = /* @__PURE__ */ _jsxs31(Root17, _objectSpread51(_objectSpread51({}, props), {}, {
48474
49299
  children: [
48475
49300
  t0,
48476
49301
  t1
@@ -48560,7 +49385,7 @@ var StatusMessages = function(t0) {
48560
49385
  };
48561
49386
  // src/components/threads/AudioThread/Status/index.tsx
48562
49387
  import { jsx as _jsx92 } from "react/jsx-runtime";
48563
- function ownKeys50(e, r) {
49388
+ function ownKeys52(e, r) {
48564
49389
  var t = Object.keys(e);
48565
49390
  if (Object.getOwnPropertySymbols) {
48566
49391
  var o = Object.getOwnPropertySymbols(e);
@@ -48570,30 +49395,30 @@ function ownKeys50(e, r) {
48570
49395
  }
48571
49396
  return t;
48572
49397
  }
48573
- function _objectSpread50(e) {
49398
+ function _objectSpread52(e) {
48574
49399
  for(var r = 1; r < arguments.length; r++){
48575
49400
  var t = null != arguments[r] ? arguments[r] : {};
48576
- r % 2 ? ownKeys50(Object(t), true).forEach(function(r2) {
48577
- _defineProperty50(e, r2, t[r2]);
48578
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys50(Object(t)).forEach(function(r2) {
49401
+ r % 2 ? ownKeys52(Object(t), true).forEach(function(r2) {
49402
+ _defineProperty52(e, r2, t[r2]);
49403
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys52(Object(t)).forEach(function(r2) {
48579
49404
  Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
48580
49405
  });
48581
49406
  }
48582
49407
  return e;
48583
49408
  }
48584
- function _defineProperty50(e, r, t) {
48585
- return (r = _toPropertyKey50(r)) in e ? Object.defineProperty(e, r, {
49409
+ function _defineProperty52(e, r, t) {
49410
+ return (r = _toPropertyKey52(r)) in e ? Object.defineProperty(e, r, {
48586
49411
  value: t,
48587
49412
  enumerable: true,
48588
49413
  configurable: true,
48589
49414
  writable: true
48590
49415
  }) : e[r] = t, e;
48591
49416
  }
48592
- function _toPropertyKey50(t) {
48593
- var i = _toPrimitive50(t, "string");
49417
+ function _toPropertyKey52(t) {
49418
+ var i = _toPrimitive52(t, "string");
48594
49419
  return "symbol" == (typeof i === "undefined" ? "undefined" : _type_of(i)) ? i : i + "";
48595
49420
  }
48596
- function _toPrimitive50(t, r) {
49421
+ function _toPrimitive52(t, r) {
48597
49422
  if ("object" != (typeof t === "undefined" ? "undefined" : _type_of(t)) || !t) return t;
48598
49423
  var e = t[Symbol.toPrimitive];
48599
49424
  if (void 0 !== e) {
@@ -48621,7 +49446,7 @@ var Status = function(props) {
48621
49446
  }
48622
49447
  var _t2;
48623
49448
  if ($[1] !== props) {
48624
- _t2 = /* @__PURE__ */ _jsx92(StatusMessages, _objectSpread50({
49449
+ _t2 = /* @__PURE__ */ _jsx92(StatusMessages, _objectSpread52({
48625
49450
  texts: _t
48626
49451
  }, props));
48627
49452
  $[1] = props;
@@ -48647,7 +49472,7 @@ var Status = function(props) {
48647
49472
  }
48648
49473
  var _t4;
48649
49474
  if ($[4] !== props) {
48650
- _t4 = /* @__PURE__ */ _jsx92(StatusMessages, _objectSpread50({
49475
+ _t4 = /* @__PURE__ */ _jsx92(StatusMessages, _objectSpread52({
48651
49476
  texts: _t3
48652
49477
  }, props));
48653
49478
  $[4] = props;
@@ -48669,7 +49494,7 @@ var Status = function(props) {
48669
49494
  }
48670
49495
  var _t6;
48671
49496
  if ($[7] !== props) {
48672
- _t6 = /* @__PURE__ */ _jsx92(StatusMessages, _objectSpread50({
49497
+ _t6 = /* @__PURE__ */ _jsx92(StatusMessages, _objectSpread52({
48673
49498
  texts: _t5
48674
49499
  }, props));
48675
49500
  $[7] = props;
@@ -48690,7 +49515,7 @@ var Status = function(props) {
48690
49515
  }
48691
49516
  var t1;
48692
49517
  if ($[10] !== props) {
48693
- t1 = /* @__PURE__ */ _jsx92(StatusMessages, _objectSpread50({
49518
+ t1 = /* @__PURE__ */ _jsx92(StatusMessages, _objectSpread52({
48694
49519
  texts: t0
48695
49520
  }, props));
48696
49521
  $[10] = props;
@@ -48706,7 +49531,7 @@ import { Flex as Flex34 } from "@radix-ui/themes";
48706
49531
  // src/components/threads/AudioThread/Form/MicIcon.tsx
48707
49532
  import { c as _c95 } from "react-compiler-runtime";
48708
49533
  import { jsx as _jsx93 } from "react/jsx-runtime";
48709
- function ownKeys51(e, r) {
49534
+ function ownKeys53(e, r) {
48710
49535
  var t = Object.keys(e);
48711
49536
  if (Object.getOwnPropertySymbols) {
48712
49537
  var o = Object.getOwnPropertySymbols(e);
@@ -48716,30 +49541,30 @@ function ownKeys51(e, r) {
48716
49541
  }
48717
49542
  return t;
48718
49543
  }
48719
- function _objectSpread51(e) {
49544
+ function _objectSpread53(e) {
48720
49545
  for(var r = 1; r < arguments.length; r++){
48721
49546
  var t = null != arguments[r] ? arguments[r] : {};
48722
- r % 2 ? ownKeys51(Object(t), true).forEach(function(r2) {
48723
- _defineProperty51(e, r2, t[r2]);
48724
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys51(Object(t)).forEach(function(r2) {
49547
+ r % 2 ? ownKeys53(Object(t), true).forEach(function(r2) {
49548
+ _defineProperty53(e, r2, t[r2]);
49549
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys53(Object(t)).forEach(function(r2) {
48725
49550
  Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
48726
49551
  });
48727
49552
  }
48728
49553
  return e;
48729
49554
  }
48730
- function _defineProperty51(e, r, t) {
48731
- return (r = _toPropertyKey51(r)) in e ? Object.defineProperty(e, r, {
49555
+ function _defineProperty53(e, r, t) {
49556
+ return (r = _toPropertyKey53(r)) in e ? Object.defineProperty(e, r, {
48732
49557
  value: t,
48733
49558
  enumerable: true,
48734
49559
  configurable: true,
48735
49560
  writable: true
48736
49561
  }) : e[r] = t, e;
48737
49562
  }
48738
- function _toPropertyKey51(t) {
48739
- var i = _toPrimitive51(t, "string");
49563
+ function _toPropertyKey53(t) {
49564
+ var i = _toPrimitive53(t, "string");
48740
49565
  return "symbol" == (typeof i === "undefined" ? "undefined" : _type_of(i)) ? i : i + "";
48741
49566
  }
48742
- function _toPrimitive51(t, r) {
49567
+ function _toPrimitive53(t, r) {
48743
49568
  if ("object" != (typeof t === "undefined" ? "undefined" : _type_of(t)) || !t) return t;
48744
49569
  var e = t[Symbol.toPrimitive];
48745
49570
  if (void 0 !== e) {
@@ -48763,7 +49588,7 @@ var MicIcon = function(props) {
48763
49588
  }
48764
49589
  var t1;
48765
49590
  if ($[1] !== props) {
48766
- t1 = /* @__PURE__ */ _jsx93("svg", _objectSpread51(_objectSpread51({
49591
+ t1 = /* @__PURE__ */ _jsx93("svg", _objectSpread53(_objectSpread53({
48767
49592
  xmlns: "http://www.w3.org/2000/svg",
48768
49593
  fill: "currentColor",
48769
49594
  stroke: "currentColor",
@@ -48981,7 +49806,7 @@ var ActionButton = function() {
48981
49806
  };
48982
49807
  // src/components/threads/AudioThread/Form/index.tsx
48983
49808
  import { jsx as _jsx95, jsxs as _jsxs34 } from "react/jsx-runtime";
48984
- function ownKeys52(e, r) {
49809
+ function ownKeys54(e, r) {
48985
49810
  var t = Object.keys(e);
48986
49811
  if (Object.getOwnPropertySymbols) {
48987
49812
  var o = Object.getOwnPropertySymbols(e);
@@ -48991,30 +49816,30 @@ function ownKeys52(e, r) {
48991
49816
  }
48992
49817
  return t;
48993
49818
  }
48994
- function _objectSpread52(e) {
49819
+ function _objectSpread54(e) {
48995
49820
  for(var r = 1; r < arguments.length; r++){
48996
49821
  var t = null != arguments[r] ? arguments[r] : {};
48997
- r % 2 ? ownKeys52(Object(t), true).forEach(function(r2) {
48998
- _defineProperty52(e, r2, t[r2]);
48999
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys52(Object(t)).forEach(function(r2) {
49822
+ r % 2 ? ownKeys54(Object(t), true).forEach(function(r2) {
49823
+ _defineProperty54(e, r2, t[r2]);
49824
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys54(Object(t)).forEach(function(r2) {
49000
49825
  Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
49001
49826
  });
49002
49827
  }
49003
49828
  return e;
49004
49829
  }
49005
- function _defineProperty52(e, r, t) {
49006
- return (r = _toPropertyKey52(r)) in e ? Object.defineProperty(e, r, {
49830
+ function _defineProperty54(e, r, t) {
49831
+ return (r = _toPropertyKey54(r)) in e ? Object.defineProperty(e, r, {
49007
49832
  value: t,
49008
49833
  enumerable: true,
49009
49834
  configurable: true,
49010
49835
  writable: true
49011
49836
  }) : e[r] = t, e;
49012
49837
  }
49013
- function _toPropertyKey52(t) {
49014
- var i = _toPrimitive52(t, "string");
49838
+ function _toPropertyKey54(t) {
49839
+ var i = _toPrimitive54(t, "string");
49015
49840
  return "symbol" == (typeof i === "undefined" ? "undefined" : _type_of(i)) ? i : i + "";
49016
49841
  }
49017
- function _toPrimitive52(t, r) {
49842
+ function _toPrimitive54(t, r) {
49018
49843
  if ("object" != (typeof t === "undefined" ? "undefined" : _type_of(t)) || !t) return t;
49019
49844
  var e = t[Symbol.toPrimitive];
49020
49845
  if (void 0 !== e) {
@@ -49112,7 +49937,7 @@ var Form = function(props) {
49112
49937
  }
49113
49938
  var t9;
49114
49939
  if ($[14] !== props || $[15] !== t7) {
49115
- t9 = /* @__PURE__ */ _jsxs34(Flex34, _objectSpread52(_objectSpread52({
49940
+ t9 = /* @__PURE__ */ _jsxs34(Flex34, _objectSpread54(_objectSpread54({
49116
49941
  direction: "column",
49117
49942
  align: "center"
49118
49943
  }, props), {}, {
@@ -49131,7 +49956,7 @@ var Form = function(props) {
49131
49956
  };
49132
49957
  // src/components/threads/AudioThread/index.tsx
49133
49958
  import { jsx as _jsx96, jsxs as _jsxs35 } from "react/jsx-runtime";
49134
- function ownKeys53(e, r) {
49959
+ function ownKeys55(e, r) {
49135
49960
  var t = Object.keys(e);
49136
49961
  if (Object.getOwnPropertySymbols) {
49137
49962
  var o = Object.getOwnPropertySymbols(e);
@@ -49141,30 +49966,30 @@ function ownKeys53(e, r) {
49141
49966
  }
49142
49967
  return t;
49143
49968
  }
49144
- function _objectSpread53(e) {
49969
+ function _objectSpread55(e) {
49145
49970
  for(var r = 1; r < arguments.length; r++){
49146
49971
  var t = null != arguments[r] ? arguments[r] : {};
49147
- r % 2 ? ownKeys53(Object(t), true).forEach(function(r2) {
49148
- _defineProperty53(e, r2, t[r2]);
49149
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys53(Object(t)).forEach(function(r2) {
49972
+ r % 2 ? ownKeys55(Object(t), true).forEach(function(r2) {
49973
+ _defineProperty55(e, r2, t[r2]);
49974
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys55(Object(t)).forEach(function(r2) {
49150
49975
  Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
49151
49976
  });
49152
49977
  }
49153
49978
  return e;
49154
49979
  }
49155
- function _defineProperty53(e, r, t) {
49156
- return (r = _toPropertyKey53(r)) in e ? Object.defineProperty(e, r, {
49980
+ function _defineProperty55(e, r, t) {
49981
+ return (r = _toPropertyKey55(r)) in e ? Object.defineProperty(e, r, {
49157
49982
  value: t,
49158
49983
  enumerable: true,
49159
49984
  configurable: true,
49160
49985
  writable: true
49161
49986
  }) : e[r] = t, e;
49162
49987
  }
49163
- function _toPropertyKey53(t) {
49164
- var i = _toPrimitive53(t, "string");
49988
+ function _toPropertyKey55(t) {
49989
+ var i = _toPrimitive55(t, "string");
49165
49990
  return "symbol" == (typeof i === "undefined" ? "undefined" : _type_of(i)) ? i : i + "";
49166
49991
  }
49167
- function _toPrimitive53(t, r) {
49992
+ function _toPrimitive55(t, r) {
49168
49993
  if ("object" != (typeof t === "undefined" ? "undefined" : _type_of(t)) || !t) return t;
49169
49994
  var e = t[Symbol.toPrimitive];
49170
49995
  if (void 0 !== e) {
@@ -49193,7 +50018,7 @@ var AudioThread = function(props) {
49193
50018
  }
49194
50019
  var t3;
49195
50020
  if ($[3] !== props) {
49196
- t3 = /* @__PURE__ */ _jsxs35(Root16, _objectSpread53(_objectSpread53({}, props), {}, {
50021
+ t3 = /* @__PURE__ */ _jsxs35(Root16, _objectSpread55(_objectSpread55({}, props), {}, {
49197
50022
  children: [
49198
50023
  t0,
49199
50024
  t1,
@@ -49213,7 +50038,7 @@ AudioThread.Status = Status;
49213
50038
  AudioThread.Form = Form;
49214
50039
  // src/components/threads/AudioThreadDialog/index.tsx
49215
50040
  import { jsx as _jsx97, jsxs as _jsxs36 } from "react/jsx-runtime";
49216
- function ownKeys54(e, r) {
50041
+ function ownKeys56(e, r) {
49217
50042
  var t = Object.keys(e);
49218
50043
  if (Object.getOwnPropertySymbols) {
49219
50044
  var o = Object.getOwnPropertySymbols(e);
@@ -49223,30 +50048,30 @@ function ownKeys54(e, r) {
49223
50048
  }
49224
50049
  return t;
49225
50050
  }
49226
- function _objectSpread54(e) {
50051
+ function _objectSpread56(e) {
49227
50052
  for(var r = 1; r < arguments.length; r++){
49228
50053
  var t = null != arguments[r] ? arguments[r] : {};
49229
- r % 2 ? ownKeys54(Object(t), true).forEach(function(r2) {
49230
- _defineProperty54(e, r2, t[r2]);
49231
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys54(Object(t)).forEach(function(r2) {
50054
+ r % 2 ? ownKeys56(Object(t), true).forEach(function(r2) {
50055
+ _defineProperty56(e, r2, t[r2]);
50056
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys56(Object(t)).forEach(function(r2) {
49232
50057
  Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
49233
50058
  });
49234
50059
  }
49235
50060
  return e;
49236
50061
  }
49237
- function _defineProperty54(e, r, t) {
49238
- return (r = _toPropertyKey54(r)) in e ? Object.defineProperty(e, r, {
50062
+ function _defineProperty56(e, r, t) {
50063
+ return (r = _toPropertyKey56(r)) in e ? Object.defineProperty(e, r, {
49239
50064
  value: t,
49240
50065
  enumerable: true,
49241
50066
  configurable: true,
49242
50067
  writable: true
49243
50068
  }) : e[r] = t, e;
49244
50069
  }
49245
- function _toPropertyKey54(t) {
49246
- var i = _toPrimitive54(t, "string");
50070
+ function _toPropertyKey56(t) {
50071
+ var i = _toPrimitive56(t, "string");
49247
50072
  return "symbol" == (typeof i === "undefined" ? "undefined" : _type_of(i)) ? i : i + "";
49248
50073
  }
49249
- function _toPrimitive54(t, r) {
50074
+ function _toPrimitive56(t, r) {
49250
50075
  if ("object" != (typeof t === "undefined" ? "undefined" : _type_of(t)) || !t) return t;
49251
50076
  var e = t[Symbol.toPrimitive];
49252
50077
  if (void 0 !== e) {
@@ -49273,7 +50098,7 @@ var AudioThreadDialog = function(props) {
49273
50098
  }
49274
50099
  var t2;
49275
50100
  if ($[2] !== props) {
49276
- t2 = /* @__PURE__ */ _jsxs36(Root13, _objectSpread54(_objectSpread54({}, props), {}, {
50101
+ t2 = /* @__PURE__ */ _jsxs36(Root13, _objectSpread56(_objectSpread56({}, props), {}, {
49277
50102
  children: [
49278
50103
  t0,
49279
50104
  t1
@@ -49291,7 +50116,7 @@ AudioThreadDialog.Trigger = Trigger;
49291
50116
  AudioThreadDialog.Content = Content8;
49292
50117
  // src/hooks/audioRuntimes/useWebrtcAudioRuntime/index.ts
49293
50118
  import { useEffect as useEffect13, useMemo as useMemo20, useRef as useRef9, useState as useState12 } from "react";
49294
- function asyncGeneratorStep12(n, t, e, r, o, a, c) {
50119
+ function asyncGeneratorStep13(n, t, e, r, o, a, c) {
49295
50120
  try {
49296
50121
  var i = n[a](c), u = i.value;
49297
50122
  } catch (n2) {
@@ -49299,16 +50124,16 @@ function asyncGeneratorStep12(n, t, e, r, o, a, c) {
49299
50124
  }
49300
50125
  i.done ? t(u) : Promise.resolve(u).then(r, o);
49301
50126
  }
49302
- function _asyncToGenerator12(n) {
50127
+ function _asyncToGenerator13(n) {
49303
50128
  return function() {
49304
50129
  var t = this, e = arguments;
49305
50130
  return new Promise(function(r, o) {
49306
50131
  var a = n.apply(t, e);
49307
50132
  function _next(n2) {
49308
- asyncGeneratorStep12(a, r, o, _next, _throw, "next", n2);
50133
+ asyncGeneratorStep13(a, r, o, _next, _throw, "next", n2);
49309
50134
  }
49310
50135
  function _throw(n2) {
49311
- asyncGeneratorStep12(a, r, o, _next, _throw, "throw", n2);
50136
+ asyncGeneratorStep13(a, r, o, _next, _throw, "throw", n2);
49312
50137
  }
49313
50138
  _next(void 0);
49314
50139
  });
@@ -49406,7 +50231,7 @@ var useWebrtcAudioRuntime = function() {
49406
50231
  };
49407
50232
  }, []);
49408
50233
  function _startSessionIfNeeded() {
49409
- _startSessionIfNeeded = _asyncToGenerator12(function() {
50234
+ _startSessionIfNeeded = _asyncToGenerator13(function() {
49410
50235
  return _ts_generator(this, function(_state) {
49411
50236
  switch(_state.label){
49412
50237
  case 0:
@@ -49429,7 +50254,7 @@ var useWebrtcAudioRuntime = function() {
49429
50254
  return _startSessionIfNeeded.apply(this, arguments);
49430
50255
  }
49431
50256
  function _initRealtimeSession() {
49432
- _initRealtimeSession = _asyncToGenerator12(function() {
50257
+ _initRealtimeSession = _asyncToGenerator13(function() {
49433
50258
  var peerConn, audioEl, openaiEventsDataChannel, ms, offer, searchParams_0, sdpResponse, answerSdp, answer, err1;
49434
50259
  return _ts_generator(this, function(_state) {
49435
50260
  switch(_state.label){
@@ -49477,7 +50302,7 @@ var useWebrtcAudioRuntime = function() {
49477
50302
  };
49478
50303
  openaiEventsDataChannel = peerConn.createDataChannel("oai-events");
49479
50304
  openaiEventsDataChannel.addEventListener("message", /* @__PURE__ */ function() {
49480
- var _ref8 = _asyncToGenerator12(function(e) {
50305
+ var _ref8 = _asyncToGenerator13(function(e) {
49481
50306
  var parsedData, searchParams, eventsResponse, reader, decoder, _ref, value, done, buffer, lines, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, line, event, ref;
49482
50307
  return _ts_generator(this, function(_state) {
49483
50308
  switch(_state.label){
@@ -49676,7 +50501,7 @@ var useWebrtcAudioRuntime = function() {
49676
50501
  return _initRealtimeSession.apply(this, arguments);
49677
50502
  }
49678
50503
  var start = /* @__PURE__ */ function() {
49679
- var _ref6 = _asyncToGenerator12(function() {
50504
+ var _ref6 = _asyncToGenerator13(function() {
49680
50505
  return _ts_generator(this, function(_state) {
49681
50506
  switch(_state.label){
49682
50507
  case 0:
@@ -49709,7 +50534,7 @@ var useWebrtcAudioRuntime = function() {
49709
50534
  };
49710
50535
  }();
49711
50536
  var pause = /* @__PURE__ */ function() {
49712
- var _ref7 = _asyncToGenerator12(function() {
50537
+ var _ref7 = _asyncToGenerator13(function() {
49713
50538
  return _ts_generator(this, function(_state) {
49714
50539
  if (!sessionStartedRef.current) return [
49715
50540
  2
@@ -49735,7 +50560,7 @@ var useWebrtcAudioRuntime = function() {
49735
50560
  webrtcAudioRuntime: {
49736
50561
  user: {
49737
50562
  start: function() {
49738
- var _start = _asyncToGenerator12(function() {
50563
+ var _start = _asyncToGenerator13(function() {
49739
50564
  return _ts_generator(this, function(_state) {
49740
50565
  return [
49741
50566
  2
@@ -50071,19 +50896,19 @@ function _temp12(rs) {
50071
50896
  import { c as _c104 } from "react-compiler-runtime";
50072
50897
  import { useMemo as useMemo24 } from "react";
50073
50898
  import { jsx as _jsx100 } from "react/jsx-runtime";
50074
- var _excluded7 = [
50899
+ var _excluded9 = [
50075
50900
  "children"
50076
50901
  ];
50077
- function _objectWithoutProperties7(e, t) {
50902
+ function _objectWithoutProperties9(e, t) {
50078
50903
  if (null == e) return {};
50079
- var o, r, i = _objectWithoutPropertiesLoose7(e, t);
50904
+ var o, r, i = _objectWithoutPropertiesLoose9(e, t);
50080
50905
  if (Object.getOwnPropertySymbols) {
50081
50906
  var n = Object.getOwnPropertySymbols(e);
50082
50907
  for(r = 0; r < n.length; r++)o = n[r], -1 === t.indexOf(o) && ({}).propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
50083
50908
  }
50084
50909
  return i;
50085
50910
  }
50086
- function _objectWithoutPropertiesLoose7(r, e) {
50911
+ function _objectWithoutPropertiesLoose9(r, e) {
50087
50912
  if (null == r) return {};
50088
50913
  var t = {};
50089
50914
  for(var n in r)if (({}).hasOwnProperty.call(r, n)) {
@@ -50099,7 +50924,7 @@ var MarkdownProvider = function(t0) {
50099
50924
  if ($[0] !== t0) {
50100
50925
  var _t = t0;
50101
50926
  children = _t.children;
50102
- rest = _objectWithoutProperties7(_t, _excluded7);
50927
+ rest = _objectWithoutProperties9(_t, _excluded9);
50103
50928
  _t;
50104
50929
  $[0] = t0;
50105
50930
  $[1] = children;
@@ -50340,19 +51165,19 @@ var FileCitation = function(t0) {
50340
51165
  };
50341
51166
  // src/components/annotations/SourceAnnotation/index.tsx
50342
51167
  import { jsx as _jsx103 } from "react/jsx-runtime";
50343
- var _excluded8 = [
51168
+ var _excluded10 = [
50344
51169
  "children"
50345
51170
  ];
50346
- function _objectWithoutProperties8(e, t) {
51171
+ function _objectWithoutProperties10(e, t) {
50347
51172
  if (null == e) return {};
50348
- var o, r, i = _objectWithoutPropertiesLoose8(e, t);
51173
+ var o, r, i = _objectWithoutPropertiesLoose10(e, t);
50349
51174
  if (Object.getOwnPropertySymbols) {
50350
51175
  var n = Object.getOwnPropertySymbols(e);
50351
51176
  for(r = 0; r < n.length; r++)o = n[r], -1 === t.indexOf(o) && ({}).propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
50352
51177
  }
50353
51178
  return i;
50354
51179
  }
50355
- function _objectWithoutPropertiesLoose8(r, e) {
51180
+ function _objectWithoutPropertiesLoose10(r, e) {
50356
51181
  if (null == r) return {};
50357
51182
  var t = {};
50358
51183
  for(var n in r)if (({}).hasOwnProperty.call(r, n)) {
@@ -50368,7 +51193,7 @@ var SourceAnnotation = function(t0) {
50368
51193
  if ($[0] !== t0) {
50369
51194
  var _t = t0;
50370
51195
  children = _t.children;
50371
- rest = _objectWithoutProperties8(_t, _excluded8);
51196
+ rest = _objectWithoutProperties10(_t, _excluded10);
50372
51197
  _t;
50373
51198
  $[0] = t0;
50374
51199
  $[1] = children;
@@ -50643,19 +51468,19 @@ var Avatar6 = function(t0) {
50643
51468
  import { c as _c111 } from "react-compiler-runtime";
50644
51469
  import { useMemo as useMemo26 } from "react";
50645
51470
  import { jsx as _jsx107 } from "react/jsx-runtime";
50646
- var _excluded9 = [
51471
+ var _excluded11 = [
50647
51472
  "children"
50648
51473
  ];
50649
- function _objectWithoutProperties9(e, t) {
51474
+ function _objectWithoutProperties11(e, t) {
50650
51475
  if (null == e) return {};
50651
- var o, r, i = _objectWithoutPropertiesLoose9(e, t);
51476
+ var o, r, i = _objectWithoutPropertiesLoose11(e, t);
50652
51477
  if (Object.getOwnPropertySymbols) {
50653
51478
  var n = Object.getOwnPropertySymbols(e);
50654
51479
  for(r = 0; r < n.length; r++)o = n[r], -1 === t.indexOf(o) && ({}).propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
50655
51480
  }
50656
51481
  return i;
50657
51482
  }
50658
- function _objectWithoutPropertiesLoose9(r, e) {
51483
+ function _objectWithoutPropertiesLoose11(r, e) {
50659
51484
  if (null == r) return {};
50660
51485
  var t = {};
50661
51486
  for(var n in r)if (({}).hasOwnProperty.call(r, n)) {
@@ -50671,7 +51496,7 @@ var ComponentsProvider = function(t0) {
50671
51496
  if ($[0] !== t0) {
50672
51497
  var _t = t0;
50673
51498
  children = _t.children;
50674
- rest = _objectWithoutProperties9(_t, _excluded9);
51499
+ rest = _objectWithoutProperties11(_t, _excluded11);
50675
51500
  _t;
50676
51501
  $[0] = t0;
50677
51502
  $[1] = children;