@burdenoff/fe-libs 2026.1028.3 → 2026.1028.5

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