@burdenoff/fe-libs 2026.1016.1 → 2026.1016.3

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