@burdenoff/fe-libs 2026.1013.10 → 2026.1013.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.
@@ -3,24 +3,24 @@ import { useAssistantTr as t } from "../i18n.js";
3
3
  import { useAssistantStore as n } from "../store.js";
4
4
  import { isVoiceTurn as r } from "../voice/turnVisibility.js";
5
5
  import { VOICE_LIST_TIMEOUT_MS as i, languageDisplayName as a, selectVoiceForLocale as o, speechGate as s, speechLangForLocale as c, voiceAvailability as l, voicesForLocale as u } from "../voice/speechVoices.js";
6
- import { getSpeechEngine as d, subscribeSpeechEngine as ee } from "../speech/createSpeechEngine.js";
7
- import { speechFeed as f } from "../speech/speechFeed.js";
8
- import { isTurnSuperseded as p } from "../voice/supersededTurns.js";
9
- import { chunkForSpeech as te, toSpeakableText as m } from "../voice/speakableText.js";
10
- import { voicePreviewText as ne } from "../voice/voicePreview.js";
11
- import { findAssistantLanguage as re } from "../voice/languages.js";
12
- import { resolveLanguagePair as ie } from "../voice/languagePair.js";
13
- import { speechLabelsFor as ae } from "../voice/speechLabels.js";
14
- import { resolveSpeechLocale as oe } from "../voice/replyLanguage.js";
15
- import { IDLE_PLAYBACK as se, isSpeakingMessage as ce, publishedChunks as le, speechPlaybackReducer as ue } from "../voice/speechPlayback.js";
16
- import { isTurnInFlight as de } from "../turnState.js";
17
- import { parseToolActivity as fe } from "./AssistantToolActivity.js";
6
+ import { getSpeechEngine as d, subscribeSpeechEngine as f } from "../speech/createSpeechEngine.js";
7
+ import { speechFeed as p } from "../speech/speechFeed.js";
8
+ import { isTurnSuperseded as m } from "../voice/supersededTurns.js";
9
+ import { chunkForSpeech as ee, toSpeakableText as h } from "../voice/speakableText.js";
10
+ import { voicePreviewText as te } from "../voice/voicePreview.js";
11
+ import { findAssistantLanguage as ne } from "../voice/languages.js";
12
+ import { resolveLanguagePair as re } from "../voice/languagePair.js";
13
+ import { speechLabelsFor as ie } from "../voice/speechLabels.js";
14
+ import { resolveSpeechLocale as ae } from "../voice/replyLanguage.js";
15
+ import { IDLE_PLAYBACK as oe, isSpeakingMessage as se, publishedChunks as ce, speechPlaybackReducer as le } from "../voice/speechPlayback.js";
16
+ import { isTurnInFlight as ue } from "../turnState.js";
17
+ import { parseToolActivity as de } from "./AssistantToolActivity.js";
18
18
  import "../speech/index.js";
19
- import { markTurn as h } from "../turnTimeline.js";
20
- import { createContext as pe, useCallback as g, useContext as _, useEffect as v, useMemo as y, useReducer as me, useRef as b, useState as x, useSyncExternalStore as he } from "react";
21
- import { jsx as ge } from "react/jsx-runtime";
19
+ import { markTurn as g } from "../turnTimeline.js";
20
+ import { createContext as fe, useCallback as _, useContext as v, useEffect as y, useMemo as b, useReducer as pe, useRef as x, useState as S, useSyncExternalStore as me } from "react";
21
+ import { jsx as he } from "react/jsx-runtime";
22
22
  //#region src/shared/assistant/ui/AssistantSpeechProvider.tsx
23
- var _e = {
23
+ var ge = {
24
24
  codeBlock: "",
25
25
  image: "",
26
26
  link: "",
@@ -29,7 +29,7 @@ var _e = {
29
29
  emailAt: "at",
30
30
  emailDot: "dot",
31
31
  nestedItem: ""
32
- }, ve = 4e3, ye = pe({
32
+ }, _e = 4e3, ve = fe({
33
33
  isSupported: !1,
34
34
  availability: "unsupported",
35
35
  isBlocked: !0,
@@ -41,6 +41,7 @@ var _e = {
41
41
  preferredVoiceName: null,
42
42
  setVoice: () => {},
43
43
  speakingMessageId: null,
44
+ outputNotCleared: null,
44
45
  isSpeaking: () => !1,
45
46
  toggle: () => {},
46
47
  stop: () => {},
@@ -52,359 +53,363 @@ var _e = {
52
53
  speakFinishedReply: () => {},
53
54
  previewVoice: () => {}
54
55
  });
55
- function be() {
56
- return _(ye);
56
+ function ye() {
57
+ return v(ve);
57
58
  }
58
- var xe = ({ children: pe, visible: _ = !0, engine: be }) => {
59
- let xe = he(ee, d, d), S = be ?? xe, C = t(), { locale: w } = e(), [T, E] = me(ue, se), [D, O] = x(() => S.listVoices()), [k, Se] = x(!1), [Ce, A] = x(() => /* @__PURE__ */ new Map()), j = b(0), M = b(null), N = b(null), P = b(null);
60
- v(() => () => {
61
- P.current !== null && clearTimeout(P.current);
59
+ var be = ({ children: fe, visible: v = !0, engine: ye }) => {
60
+ let be = me(f, d, d), C = ye ?? be, w = t(), { locale: T } = e(), [E, D] = pe(le, oe), [O, k] = S(() => C.listVoices()), [A, xe] = S(!1), [Se, j] = S(() => /* @__PURE__ */ new Map()), [Ce, we] = S(null), M = x(0), N = x(null), P = x(null), F = x(null);
61
+ y(() => () => {
62
+ F.current !== null && clearTimeout(F.current);
62
63
  }, []);
63
- let [we, F] = x(null), I = b(null), Te = b(() => {}), L = g(() => {
64
- I.current?.(), I.current = null;
65
- }, []), R = n((e) => e.autoSpeakEnabled), Ee = n((e) => e.setAutoSpeak), [z, De] = x(!1), B = b(!1), Oe = g((e) => {
66
- B.current = e;
67
- }, []), V = n((e) => e.activeConversationId), H = y(() => S.isSupported(), [S]);
68
- v(() => {
69
- if (!H) return;
64
+ let [Te, I] = S(null), L = x(null), Ee = x(() => {}), R = _(() => {
65
+ L.current?.(), L.current = null;
66
+ }, []), z = n((e) => e.autoSpeakEnabled), De = n((e) => e.setAutoSpeak), [B, Oe] = S(!1), V = x(!1), ke = _((e) => {
67
+ V.current = e;
68
+ }, []), H = n((e) => e.activeConversationId), U = b(() => C.isSupported(), [C]);
69
+ y(() => {
70
+ if (!U) return;
70
71
  let e = () => {
71
- O(S.listVoices()), A((e) => e.size === 0 ? e : /* @__PURE__ */ new Map());
72
+ k(C.listVoices()), j((e) => e.size === 0 ? e : /* @__PURE__ */ new Map());
72
73
  };
73
- return e(), S.subscribeVoices(e);
74
- }, [S, H]);
75
- let ke = n((e) => e.assistantLanguage), Ae = n((e) => e.replyLanguage), U = n((e) => e.preferredVoices), je = n((e) => e.setPreferredVoice), W = y(() => ie(ke, Ae, w).reply, [
76
- ke,
74
+ return e(), C.subscribeVoices(e);
75
+ }, [C, U]);
76
+ let Ae = n((e) => e.assistantLanguage), je = n((e) => e.replyLanguage), W = n((e) => e.preferredVoices), Me = n((e) => e.setPreferredVoice), G = b(() => re(Ae, je, T).reply, [
77
77
  Ae,
78
- w
79
- ]), G = W.code, K = g((e) => re(e)?.tag ?? c(e), []), Me = g((e) => re(e)?.rate ?? .9, []), q = y(() => l(H, D, W.tag, k), [
80
- H,
81
- D,
82
- W,
83
- k
84
- ]), Ne = y(() => ({
85
- codeBlock: C("speech.codeBlock", "Code block"),
86
- image: C("speech.image", "image"),
87
- link: C("speech.link", "link"),
88
- largeTable: C("speech.largeTable", "Table with {{rows}} rows and {{columns}} columns"),
89
- truncated: C("speech.truncated", "The rest of this message is not read aloud"),
90
- nestedItem: C("speech.nestedItem", "Sub-item {{ordinal}}"),
91
- emailAt: C("speech.emailAt", "at"),
92
- emailDot: C("speech.emailDot", "dot")
93
- }), [C]), J = g(() => {
94
- L(), M.current = null, S.cancel(), E({ type: "stop" });
95
- }, [L, S]), Pe = g((e) => {
96
- let t = S.listVoices().find((t) => t.name === e) ?? null;
78
+ je,
79
+ T
80
+ ]), K = G.code, q = _((e) => ne(e)?.tag ?? c(e), []), Ne = _((e) => ne(e)?.rate ?? .9, []), J = b(() => l(U, O, G.tag, A), [
81
+ U,
82
+ O,
83
+ G,
84
+ A
85
+ ]), Pe = b(() => ({
86
+ codeBlock: w("speech.codeBlock", "Code block"),
87
+ image: w("speech.image", "image"),
88
+ link: w("speech.link", "link"),
89
+ largeTable: w("speech.largeTable", "Table with {{rows}} rows and {{columns}} columns"),
90
+ truncated: w("speech.truncated", "The rest of this message is not read aloud"),
91
+ nestedItem: w("speech.nestedItem", "Sub-item {{ordinal}}"),
92
+ emailAt: w("speech.emailAt", "at"),
93
+ emailDot: w("speech.emailDot", "dot")
94
+ }), [w]), Y = _(() => {
95
+ R(), N.current = null, C.cancel(), D({ type: "stop" });
96
+ }, [R, C]), Fe = _((e) => {
97
+ let t = C.listVoices().find((t) => t.name === e) ?? null;
97
98
  if (t) {
98
- J();
99
+ Y();
99
100
  try {
100
- S.speak([ne(G)], {
101
+ C.speak([te(K)], {
101
102
  voice: t,
102
- lang: K(G),
103
+ lang: q(K),
103
104
  fallback: !1
104
105
  });
105
106
  } catch {}
106
107
  }
107
108
  }, [
108
- S,
109
- G,
110
- J,
111
- K
112
- ]), Fe = g((e) => Ce.get(e) ?? null, [Ce]), Ie = g((e, t, n, r, a) => {
113
- L();
109
+ C,
110
+ K,
111
+ Y,
112
+ q
113
+ ]), Ie = _((e) => Se.get(e) ?? null, [Se]), Le = _((e, t, n, r, a) => {
114
+ R();
114
115
  let o = !1, s = () => {}, c = (i) => {
115
116
  if (!o) {
116
- if (o = !0, I.current = null, clearTimeout(l), s(), i.length === 0) {
117
- Se(!0);
117
+ if (o = !0, L.current = null, clearTimeout(l), s(), i.length === 0) {
118
+ xe(!0);
118
119
  return;
119
120
  }
120
- O(i), Te.current(e, t, i, n, r, a);
121
+ k(i), Ee.current(e, t, i, n, r, a);
121
122
  }
122
- }, l = setTimeout(() => c(S.listVoices()), i);
123
- s = S.subscribeVoices(() => c(S.listVoices())), I.current = () => {
124
- o || (o = !0, clearTimeout(l), s(), I.current = null);
123
+ }, l = setTimeout(() => c(C.listVoices()), i);
124
+ s = C.subscribeVoices(() => c(C.listVoices())), L.current = () => {
125
+ o || (o = !0, clearTimeout(l), s(), L.current = null);
125
126
  };
126
- }, [L, S]), Y = g((e, t, n, r, i = !1, c) => {
127
+ }, [R, C]), X = _((e, t, n, r, i = !1, c) => {
127
128
  let u = n;
128
129
  if (u.length === 0) {
129
- let e = S.listVoices();
130
- e.length > 0 && (u = e, O(e));
130
+ let e = C.listVoices();
131
+ e.length > 0 && (u = e, k(e));
131
132
  }
132
- let d = K(r), ee = s(l(!0, u, r, k));
133
- if (ee === "block") {
134
- let t = C("speech.noVoiceForReply", "This reply is in {{language}}, and no {{language}} voice is installed on this device.", { language: a(d, w) });
135
- A((n) => new Map(n).set(e, t));
133
+ let d = q(r), f = s(l(!0, u, r, A));
134
+ if (f === "block") {
135
+ let t = w("speech.noVoiceForReply", "This reply is in {{language}}, and no {{language}} voice is installed on this device.", { language: a(d, T) });
136
+ j((n) => new Map(n).set(e, t));
136
137
  return;
137
138
  }
138
- if (ee === "wait-for-voices") {
139
- Ie(e, t, r, i, c);
139
+ if (f === "wait-for-voices") {
140
+ Le(e, t, r, i, c);
140
141
  return;
141
142
  }
142
- A((t) => {
143
+ j((t) => {
143
144
  if (!t.has(e)) return t;
144
145
  let n = new Map(t);
145
146
  return n.delete(e), n;
146
- }), L();
147
- let f = j.current + 1;
148
- j.current = f, E({
147
+ }), R();
148
+ let p = M.current + 1;
149
+ M.current = p, D({
149
150
  type: "start",
150
151
  messageId: e,
151
- requestId: f
152
- }), M.current = i ? f : null, i && h(e, "ttsStarted");
153
- let p = c === void 0 ? te(t) : te(t, void 0, void 0, { firstChunkMaxChars: c });
154
- F({
155
- requestId: f,
156
- chunks: p,
152
+ requestId: p
153
+ }), N.current = i ? p : null, i && g(e, "ttsStarted");
154
+ let m = c === void 0 ? ee(t) : ee(t, void 0, void 0, { firstChunkMaxChars: c });
155
+ I({
156
+ requestId: p,
157
+ chunks: m,
157
158
  index: -1
158
- }), P.current !== null && clearTimeout(P.current), P.current = setTimeout(() => {
159
- F((e) => e?.requestId === f && e.index < 0 ? null : e);
160
- }, ve);
161
- let m = () => {
162
- j.current === f && P.current !== null && (clearTimeout(P.current), P.current = null), E({
159
+ }), F.current !== null && clearTimeout(F.current), F.current = setTimeout(() => {
160
+ I((e) => e?.requestId === p && e.index < 0 ? null : e);
161
+ }, _e);
162
+ let h = () => {
163
+ M.current === p && F.current !== null && (clearTimeout(F.current), F.current = null), D({
163
164
  type: "failed",
164
- requestId: f
165
+ requestId: p
165
166
  });
166
167
  };
167
168
  try {
168
- S.speak(p, {
169
- voice: o(u, d, U[r]),
169
+ C.speak(m, {
170
+ voice: o(u, d, W[r]),
170
171
  lang: d,
171
- rate: Me(r)
172
+ rate: Ne(r)
172
173
  }, {
173
174
  onStart: () => {
174
- j.current === f && M.current === f && h(e, "firstAudio");
175
+ M.current === p && N.current === p && g(e, "firstAudio");
175
176
  },
176
177
  onChunkStart: (e) => {
177
- j.current === f && P.current !== null && (clearTimeout(P.current), P.current = null), F((t) => t?.requestId === f ? {
178
+ M.current === p && F.current !== null && (clearTimeout(F.current), F.current = null), I((t) => t?.requestId === p ? {
178
179
  ...t,
179
180
  index: e
180
- } : j.current === f ? {
181
- requestId: f,
182
- chunks: p,
181
+ } : M.current === p ? {
182
+ requestId: p,
183
+ chunks: m,
183
184
  index: e
184
185
  } : t);
185
186
  },
186
187
  onEnd: () => {
187
- j.current === f && M.current === f && h(e, "audioEnded"), E({
188
+ M.current === p && N.current === p && g(e, "audioEnded"), D({
188
189
  type: "finished",
189
- requestId: f
190
+ requestId: p
190
191
  });
191
192
  },
192
- onError: () => E({
193
- type: "failed",
194
- requestId: f
195
- })
193
+ onError: (t) => {
194
+ t === "output-not-cleared" && M.current === p && we({ messageId: e }), D({
195
+ type: "failed",
196
+ requestId: p
197
+ });
198
+ }
196
199
  });
197
200
  } catch {
198
- m();
201
+ h();
199
202
  }
200
203
  }, [
201
- L,
202
- S,
203
- w,
204
- U,
205
- Me,
206
- K,
204
+ R,
207
205
  C,
208
- k,
209
- Ie
206
+ T,
207
+ W,
208
+ Ne,
209
+ q,
210
+ w,
211
+ A,
212
+ Le
210
213
  ]);
211
- v(() => {
212
- Te.current = Y;
213
- }, [Y]);
214
- let X = g((e, t, n, r) => {
215
- if (!H) return;
216
- let i = oe(m(t, { labels: _e }), n ?? G), a = m(t, { labels: ae(i, Ne) });
217
- a && Y(e, a, D, i, r?.auto === !0, r?.firstChunkMaxChars);
214
+ y(() => {
215
+ Ee.current = X;
216
+ }, [X]);
217
+ let Z = _((e, t, n, r) => {
218
+ if (!U) return;
219
+ let i = ae(h(t, { labels: ge }), n ?? K), a = h(t, { labels: ie(i, Pe) });
220
+ a && X(e, a, O, i, r?.auto === !0, r?.firstChunkMaxChars);
218
221
  }, [
219
- H,
220
- Ne,
221
- G,
222
- Y,
223
- D
224
- ]), Le = g((e, t, n) => {
225
- if (ce(T, e)) {
226
- J();
222
+ U,
223
+ Pe,
224
+ K,
225
+ X,
226
+ O
227
+ ]), Re = _((e, t, n) => {
228
+ if (se(E, e)) {
229
+ Y();
227
230
  return;
228
231
  }
229
- X(e, t, n);
232
+ Z(e, t, n);
230
233
  }, [
231
- T,
232
- X,
233
- J
234
+ E,
235
+ Z,
236
+ Y
234
237
  ]);
235
- v(() => {
236
- _ || J();
237
- }, [_, J]);
238
- let Z = b({
239
- autoSpeakEnabled: R,
240
- sessionSpeaking: z,
241
- visible: _,
242
- isSupported: H
238
+ y(() => {
239
+ v || Y();
240
+ }, [v, Y]);
241
+ let ze = x({
242
+ autoSpeakEnabled: z,
243
+ sessionSpeaking: B,
244
+ visible: v,
245
+ isSupported: U
243
246
  });
244
- v(() => {
245
- Z.current = {
246
- autoSpeakEnabled: R,
247
- sessionSpeaking: z,
248
- visible: _,
249
- isSupported: H
247
+ y(() => {
248
+ ze.current = {
249
+ autoSpeakEnabled: z,
250
+ sessionSpeaking: B,
251
+ visible: v,
252
+ isSupported: U
250
253
  };
251
254
  }, [
252
- R,
253
255
  z,
254
- _,
255
- H
256
+ B,
257
+ v,
258
+ U
256
259
  ]);
257
- let Re = b(null), ze = b(null), Be = b(() => {});
258
- v(() => {
259
- J(), A(/* @__PURE__ */ new Map()), Re.current = V;
260
- let e = ze.current;
261
- ze.current = null, e && e.conversationId === V && Be.current(e.conversationId, e.messageId);
262
- }, [V, J]), v(() => {
263
- A((e) => e.size === 0 ? e : /* @__PURE__ */ new Map()), J();
264
- }, [G, J]), v(() => () => {
265
- I.current?.(), I.current = null, S.cancel();
266
- }, [S]), v(() => {
260
+ let Be = x(null), Ve = x(null), He = x(() => {});
261
+ y(() => {
262
+ Y(), j(/* @__PURE__ */ new Map()), Be.current = H;
263
+ let e = Ve.current;
264
+ Ve.current = null, e && e.conversationId === H && He.current(e.conversationId, e.messageId);
265
+ }, [H, Y]), y(() => {
266
+ j((e) => e.size === 0 ? e : /* @__PURE__ */ new Map()), Y();
267
+ }, [K, Y]), y(() => () => {
268
+ L.current?.(), L.current = null, C.cancel();
269
+ }, [C]), y(() => {
267
270
  if (typeof window > "u") return;
268
- let e = () => S.cancel();
271
+ let e = () => C.cancel();
269
272
  return window.addEventListener("pagehide", e), () => window.removeEventListener("pagehide", e);
270
- }, [S]), v(() => {
271
- if (typeof document > "u" || !H) return;
273
+ }, [C]), y(() => {
274
+ if (typeof document > "u" || !U) return;
272
275
  let e = () => {
273
276
  if (document.visibilityState !== "visible") return;
274
- let e = S.listVoices();
275
- e.length > 0 && L(), O(e), Se(!1), A((e) => e.size === 0 ? e : /* @__PURE__ */ new Map());
277
+ let e = C.listVoices();
278
+ e.length > 0 && R(), k(e), xe(!1), j((e) => e.size === 0 ? e : /* @__PURE__ */ new Map());
276
279
  };
277
280
  return document.addEventListener("visibilitychange", e), window.addEventListener("focus", e), () => {
278
281
  document.removeEventListener("visibilitychange", e), window.removeEventListener("focus", e);
279
282
  };
280
283
  }, [
281
- L,
282
- S,
283
- H
284
+ R,
285
+ C,
286
+ U
284
287
  ]);
285
- let Ve = b(X);
286
- v(() => {
287
- Ve.current = X;
288
- }, [X]);
289
- let Q = g((e, t) => {
290
- if (r(e) !== t || p(e.id) || N.current?.messageId === e.id || B.current) return;
291
- let { text: n } = fe(e.content);
288
+ let Ue = x(Z);
289
+ y(() => {
290
+ Ue.current = Z;
291
+ }, [Z]);
292
+ let Q = _((e, t) => {
293
+ if (r(e) !== t || m(e.id) || P.current?.messageId === e.id || V.current) return;
294
+ let { text: n } = de(e.content);
292
295
  if (n.trim()) try {
293
- Ve.current(e.id, n, e.metadata?.lang, { auto: !0 });
296
+ Ue.current(e.id, n, e.metadata?.lang, { auto: !0 });
294
297
  } catch {}
295
- }, []), $ = g((e, t) => {
296
- if (e !== Re.current) {
297
- n.getState().activeConversationId === e && (ze.current = {
298
+ }, []), $ = _((e, t) => {
299
+ if (e !== Be.current) {
300
+ n.getState().activeConversationId === e && (Ve.current = {
298
301
  conversationId: e,
299
302
  messageId: t
300
303
  });
301
304
  return;
302
305
  }
303
- let r = Z.current;
306
+ let r = ze.current;
304
307
  if (!r.autoSpeakEnabled && !r.sessionSpeaking || !r.visible || !r.isSupported) return;
305
308
  let i = n.getState();
306
309
  if (i.activeConversationId !== e) return;
307
310
  let a = i.conversations.find((t) => t.id === e)?.messages.find((e) => e.id === t);
308
311
  !a || a.role !== "assistant" || Q(a, r.sessionSpeaking);
309
312
  }, [Q]);
310
- v(() => {
311
- Be.current = $;
312
- }, [$]), v(() => {
313
- if (!(!R && !z || !_ || !H)) return n.subscribe((e, t) => {
313
+ y(() => {
314
+ He.current = $;
315
+ }, [$]), y(() => {
316
+ if (!(!z && !B || !v || !U)) return n.subscribe((e, t) => {
314
317
  let n = e.activeConversationId;
315
318
  if (!n || n !== t.activeConversationId) return;
316
319
  let r = e.processingByConversationId[n], i = t.processingByConversationId[n];
317
- if (r?.status !== "complete" || !de(i?.status)) return;
320
+ if (r?.status !== "complete" || !ue(i?.status)) return;
318
321
  let a = r.messageId ?? i?.messageId ?? null;
319
322
  if (!a) return;
320
323
  let o = e.conversations.find((e) => e.id === n)?.messages.find((e) => e.id === a);
321
- !o || o.role !== "assistant" || Q(o, z);
324
+ !o || o.role !== "assistant" || Q(o, B);
322
325
  });
323
326
  }, [
324
- R,
325
327
  z,
326
- H,
327
- _,
328
+ B,
329
+ U,
330
+ v,
328
331
  Q
329
332
  ]);
330
- let He = g((e) => {
333
+ let We = _((e) => {
331
334
  if (e.type === "abort") {
332
- let t = N.current;
335
+ let t = P.current;
333
336
  if (!t || t.messageId !== e.messageId) return;
334
- N.current = null, (t.requestId === null ? t.waiting && I.current !== null : j.current === t.requestId) && J();
337
+ P.current = null, (t.requestId === null ? t.waiting && L.current !== null : M.current === t.requestId) && Y();
335
338
  return;
336
339
  }
337
- let { messageId: t, item: r } = e, i = Z.current;
338
- if (!i.autoSpeakEnabled && !i.sessionSpeaking || !i.visible || !i.isSupported || r.channel === "voice" !== i.sessionSpeaking || p(t) || B.current || N.current?.messageId === t || n.getState().activeConversationId !== r.conversationId || Re.current !== r.conversationId) return;
339
- let { text: a } = fe(r.text);
340
+ let { messageId: t, item: r } = e, i = ze.current;
341
+ if (!i.autoSpeakEnabled && !i.sessionSpeaking || !i.visible || !i.isSupported || r.channel === "voice" !== i.sessionSpeaking || m(t) || V.current || P.current?.messageId === t || n.getState().activeConversationId !== r.conversationId || Be.current !== r.conversationId) return;
342
+ let { text: a } = de(r.text);
340
343
  if (!a.trim()) return;
341
- let o = j.current;
344
+ let o = M.current;
342
345
  try {
343
- Ve.current(t, a, r.lang, {
346
+ Ue.current(t, a, r.lang, {
344
347
  auto: !0,
345
348
  firstChunkMaxChars: 110
346
349
  });
347
350
  } catch {}
348
- let s = j.current !== o;
349
- N.current = {
351
+ let s = M.current !== o;
352
+ P.current = {
350
353
  messageId: t,
351
- requestId: s ? j.current : null,
352
- waiting: !s && I.current !== null
354
+ requestId: s ? M.current : null,
355
+ waiting: !s && L.current !== null
353
356
  };
354
- }, [J]);
355
- v(() => f.subscribe(He), [He]);
356
- let Ue = y(() => u(D, W.tag), [D, W]), We = y(() => o(D, W.tag, U[G]), [
357
- D,
357
+ }, [Y]);
358
+ y(() => p.subscribe(We), [We]);
359
+ let Ge = b(() => u(O, G.tag), [O, G]), Ke = b(() => o(O, G.tag, W[K]), [
360
+ O,
361
+ G,
358
362
  W,
359
- U,
360
- G
361
- ]), Ge = y(() => ({
362
- isSupported: H,
363
- availability: q,
364
- isBlocked: q === "no-voices",
365
- disabledReason: q === "no-voices" ? C("speech.noVoicesOnDevice", "This device has no speech voices installed. Add one in your device speech or accessibility settings.") : null,
366
- blockedFor: Fe,
367
- voiceChoices: Ue,
368
- spokenChunks: le(T, we),
369
- activeVoiceName: We?.name ?? null,
370
- preferredVoiceName: U[G] ?? null,
371
- setVoice: (e) => je(G, e),
372
- speakingMessageId: T.status === "speaking" ? T.messageId : null,
373
- isSpeaking: (e) => ce(T, e),
374
- toggle: Le,
375
- stop: J,
376
- autoSpeakEnabled: R,
377
- setAutoSpeak: Ee,
378
- sessionSpeaking: z,
379
- setSessionSpeaking: De,
380
- setSessionMicOpen: Oe,
363
+ K
364
+ ]), qe = b(() => ({
365
+ isSupported: U,
366
+ availability: J,
367
+ isBlocked: J === "no-voices",
368
+ disabledReason: J === "no-voices" ? w("speech.noVoicesOnDevice", "This device has no speech voices installed. Add one in your device speech or accessibility settings.") : null,
369
+ blockedFor: Ie,
370
+ voiceChoices: Ge,
371
+ spokenChunks: ce(E, Te),
372
+ activeVoiceName: Ke?.name ?? null,
373
+ preferredVoiceName: W[K] ?? null,
374
+ setVoice: (e) => Me(K, e),
375
+ speakingMessageId: E.status === "speaking" ? E.messageId : null,
376
+ outputNotCleared: Ce,
377
+ isSpeaking: (e) => se(E, e),
378
+ toggle: Re,
379
+ stop: Y,
380
+ autoSpeakEnabled: z,
381
+ setAutoSpeak: De,
382
+ sessionSpeaking: B,
383
+ setSessionSpeaking: Oe,
384
+ setSessionMicOpen: ke,
381
385
  speakFinishedReply: $,
382
- previewVoice: Pe
386
+ previewVoice: Fe
383
387
  }), [
384
- H,
385
- q,
386
- Fe,
387
- Ue,
388
- We,
389
388
  U,
390
- je,
391
- G,
392
- T,
393
- Le,
394
389
  J,
395
- R,
396
- Ee,
390
+ Ie,
391
+ Ge,
392
+ Ke,
393
+ W,
394
+ Me,
395
+ K,
396
+ E,
397
+ Ce,
398
+ Re,
399
+ Y,
397
400
  z,
398
- Oe,
401
+ De,
402
+ B,
403
+ ke,
399
404
  $,
400
- Pe,
401
- C,
402
- we
405
+ Fe,
406
+ w,
407
+ Te
403
408
  ]);
404
- return /* @__PURE__ */ ge(ye.Provider, {
405
- value: Ge,
406
- children: pe
409
+ return /* @__PURE__ */ he(ve.Provider, {
410
+ value: qe,
411
+ children: fe
407
412
  });
408
413
  };
409
414
  //#endregion
410
- export { xe as AssistantSpeechProvider, be as useAssistantSpeech };
415
+ export { be as AssistantSpeechProvider, ye as useAssistantSpeech };